echarts.js 3.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664
  1. (function (global, factory) {
  2. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : factory(global.echarts = {});
  3. })(this, function (exports) {
  4. 'use strict';
  5. /*! *****************************************************************************
  6. Copyright (c) Microsoft Corporation.
  7. Permission to use, copy, modify, and/or distribute this software for any
  8. purpose with or without fee is hereby granted.
  9. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  10. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  11. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  12. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  13. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  14. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. PERFORMANCE OF THIS SOFTWARE.
  16. ***************************************************************************** */
  17. /* global Reflect, Promise */
  18. var extendStatics = function (d, b) {
  19. extendStatics = Object.setPrototypeOf || {
  20. __proto__: []
  21. } instanceof Array && function (d, b) {
  22. d.__proto__ = b;
  23. } || function (d, b) {
  24. for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
  25. };
  26. return extendStatics(d, b);
  27. };
  28. function __extends(d, b) {
  29. extendStatics(d, b);
  30. function __() {
  31. this.constructor = d;
  32. }
  33. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  34. }
  35. var __assign = function () {
  36. __assign = Object.assign || function __assign(t) {
  37. for (var s, i = 1, n = arguments.length; i < n; i++) {
  38. s = arguments[i];
  39. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  40. }
  41. return t;
  42. };
  43. return __assign.apply(this, arguments);
  44. };
  45. function __spreadArrays() {
  46. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  47. for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
  48. return r;
  49. }
  50. var Browser = function () {
  51. function Browser() {
  52. this.firefox = false;
  53. this.ie = false;
  54. this.edge = false;
  55. this.newEdge = false;
  56. this.weChat = false;
  57. }
  58. return Browser;
  59. }();
  60. var Env = function () {
  61. function Env() {
  62. this.browser = new Browser();
  63. this.node = false;
  64. this.wxa = false;
  65. this.worker = false;
  66. this.canvasSupported = false;
  67. this.svgSupported = false;
  68. this.touchEventsSupported = false;
  69. this.pointerEventsSupported = false;
  70. this.domSupported = false;
  71. this.transformSupported = false;
  72. this.transform3dSupported = false;
  73. }
  74. return Env;
  75. }();
  76. var env = new Env();
  77. if (typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function') {
  78. env.wxa = true;
  79. env.canvasSupported = true;
  80. env.touchEventsSupported = true;
  81. } else if (typeof document === 'undefined' && typeof self !== 'undefined') {
  82. env.worker = true;
  83. env.canvasSupported = true;
  84. } else if (typeof navigator === 'undefined') {
  85. env.node = true;
  86. env.canvasSupported = true;
  87. env.svgSupported = true;
  88. } else {
  89. detect(navigator.userAgent, env);
  90. }
  91. function detect(ua, env) {
  92. var browser = env.browser;
  93. var firefox = ua.match(/Firefox\/([\d.]+)/);
  94. var ie = ua.match(/MSIE\s([\d.]+)/) || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  95. var edge = ua.match(/Edge?\/([\d.]+)/);
  96. var weChat = /micromessenger/i.test(ua);
  97. if (firefox) {
  98. browser.firefox = true;
  99. browser.version = firefox[1];
  100. }
  101. if (ie) {
  102. browser.ie = true;
  103. browser.version = ie[1];
  104. }
  105. if (edge) {
  106. browser.edge = true;
  107. browser.version = edge[1];
  108. browser.newEdge = +edge[1].split('.')[0] > 18;
  109. }
  110. if (weChat) {
  111. browser.weChat = true;
  112. }
  113. env.canvasSupported = !!document.createElement('canvas').getContext;
  114. env.svgSupported = typeof SVGRect !== 'undefined';
  115. env.touchEventsSupported = 'ontouchstart' in window && !browser.ie && !browser.edge;
  116. env.pointerEventsSupported = 'onpointerdown' in window && (browser.edge || browser.ie && +browser.version >= 11);
  117. env.domSupported = typeof document !== 'undefined';
  118. var style = document.documentElement.style;
  119. env.transform3dSupported = (browser.ie && 'transition' in style || browser.edge || 'WebKitCSSMatrix' in window && 'm11' in new WebKitCSSMatrix() || 'MozPerspective' in style) && !('OTransition' in style);
  120. env.transformSupported = env.transform3dSupported || browser.ie && +browser.version >= 9;
  121. }
  122. var BUILTIN_OBJECT = {
  123. '[object Function]': true,
  124. '[object RegExp]': true,
  125. '[object Date]': true,
  126. '[object Error]': true,
  127. '[object CanvasGradient]': true,
  128. '[object CanvasPattern]': true,
  129. '[object Image]': true,
  130. '[object Canvas]': true
  131. };
  132. var TYPED_ARRAY = {
  133. '[object Int8Array]': true,
  134. '[object Uint8Array]': true,
  135. '[object Uint8ClampedArray]': true,
  136. '[object Int16Array]': true,
  137. '[object Uint16Array]': true,
  138. '[object Int32Array]': true,
  139. '[object Uint32Array]': true,
  140. '[object Float32Array]': true,
  141. '[object Float64Array]': true
  142. };
  143. var objToString = Object.prototype.toString;
  144. var arrayProto = Array.prototype;
  145. var nativeForEach = arrayProto.forEach;
  146. var nativeFilter = arrayProto.filter;
  147. var nativeSlice = arrayProto.slice;
  148. var nativeMap = arrayProto.map;
  149. var ctorFunction = function () {}.constructor;
  150. var protoFunction = ctorFunction ? ctorFunction.prototype : null;
  151. var methods = {};
  152. function $override(name, fn) {
  153. methods[name] = fn;
  154. }
  155. var idStart = 0x0907;
  156. function guid() {
  157. return idStart++;
  158. }
  159. function logError() {
  160. var args = [];
  161. for (var _i = 0; _i < arguments.length; _i++) {
  162. args[_i] = arguments[_i];
  163. }
  164. if (typeof console !== 'undefined') {
  165. console.error.apply(console, args);
  166. }
  167. }
  168. function clone(source) {
  169. if (source == null || typeof source !== 'object') {
  170. return source;
  171. }
  172. var result = source;
  173. var typeStr = objToString.call(source);
  174. if (typeStr === '[object Array]') {
  175. if (!isPrimitive(source)) {
  176. result = [];
  177. for (var i = 0, len = source.length; i < len; i++) {
  178. result[i] = clone(source[i]);
  179. }
  180. }
  181. } else if (TYPED_ARRAY[typeStr]) {
  182. if (!isPrimitive(source)) {
  183. var Ctor = source.constructor;
  184. if (Ctor.from) {
  185. result = Ctor.from(source);
  186. } else {
  187. result = new Ctor(source.length);
  188. for (var i = 0, len = source.length; i < len; i++) {
  189. result[i] = clone(source[i]);
  190. }
  191. }
  192. }
  193. } else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
  194. result = {};
  195. for (var key in source) {
  196. if (source.hasOwnProperty(key)) {
  197. result[key] = clone(source[key]);
  198. }
  199. }
  200. }
  201. return result;
  202. }
  203. function merge(target, source, overwrite) {
  204. if (!isObject$1(source) || !isObject$1(target)) {
  205. return overwrite ? clone(source) : target;
  206. }
  207. for (var key in source) {
  208. if (source.hasOwnProperty(key)) {
  209. var targetProp = target[key];
  210. var sourceProp = source[key];
  211. if (isObject$1(sourceProp) && isObject$1(targetProp) && !isArray(sourceProp) && !isArray(targetProp) && !isDom(sourceProp) && !isDom(targetProp) && !isBuiltInObject(sourceProp) && !isBuiltInObject(targetProp) && !isPrimitive(sourceProp) && !isPrimitive(targetProp)) {
  212. merge(targetProp, sourceProp, overwrite);
  213. } else if (overwrite || !(key in target)) {
  214. target[key] = clone(source[key]);
  215. }
  216. }
  217. }
  218. return target;
  219. }
  220. function mergeAll(targetAndSources, overwrite) {
  221. var result = targetAndSources[0];
  222. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  223. result = merge(result, targetAndSources[i], overwrite);
  224. }
  225. return result;
  226. }
  227. function extend(target, source) {
  228. if (Object.assign) {
  229. Object.assign(target, source);
  230. } else {
  231. for (var key in source) {
  232. if (source.hasOwnProperty(key)) {
  233. target[key] = source[key];
  234. }
  235. }
  236. }
  237. return target;
  238. }
  239. function defaults(target, source, overlay) {
  240. var keysArr = keys(source);
  241. for (var i = 0; i < keysArr.length; i++) {
  242. var key = keysArr[i];
  243. if (overlay ? source[key] != null : target[key] == null) {
  244. target[key] = source[key];
  245. }
  246. }
  247. return target;
  248. }
  249. var createCanvas = function () {
  250. return methods.createCanvas();
  251. };
  252. methods.createCanvas = function () {
  253. return document.createElement('canvas');
  254. };
  255. function indexOf$1(array, value) {
  256. if (array) {
  257. if (array.indexOf) {
  258. return array.indexOf(value);
  259. }
  260. for (var i = 0, len = array.length; i < len; i++) {
  261. if (array[i] === value) {
  262. return i;
  263. }
  264. }
  265. }
  266. return -1;
  267. }
  268. function inherits(clazz, baseClazz) {
  269. var clazzPrototype = clazz.prototype;
  270. function F() {}
  271. F.prototype = baseClazz.prototype;
  272. clazz.prototype = new F();
  273. for (var prop in clazzPrototype) {
  274. if (clazzPrototype.hasOwnProperty(prop)) {
  275. clazz.prototype[prop] = clazzPrototype[prop];
  276. }
  277. }
  278. clazz.prototype.constructor = clazz;
  279. clazz.superClass = baseClazz;
  280. }
  281. function mixin(target, source, override) {
  282. target = 'prototype' in target ? target.prototype : target;
  283. source = 'prototype' in source ? source.prototype : source;
  284. if (Object.getOwnPropertyNames) {
  285. var keyList = Object.getOwnPropertyNames(source);
  286. for (var i = 0; i < keyList.length; i++) {
  287. var key = keyList[i];
  288. if (key !== 'constructor') {
  289. if (override ? source[key] != null : target[key] == null) {
  290. target[key] = source[key];
  291. }
  292. }
  293. }
  294. } else {
  295. defaults(target, source, override);
  296. }
  297. }
  298. function isArrayLike(data) {
  299. if (!data) {
  300. return false;
  301. }
  302. if (typeof data === 'string') {
  303. return false;
  304. }
  305. return typeof data.length === 'number';
  306. }
  307. function each$1(arr, cb, context) {
  308. if (!(arr && cb)) {
  309. return;
  310. }
  311. if (arr.forEach && arr.forEach === nativeForEach) {
  312. arr.forEach(cb, context);
  313. } else if (arr.length === +arr.length) {
  314. for (var i = 0, len = arr.length; i < len; i++) {
  315. cb.call(context, arr[i], i, arr);
  316. }
  317. } else {
  318. for (var key in arr) {
  319. if (arr.hasOwnProperty(key)) {
  320. cb.call(context, arr[key], key, arr);
  321. }
  322. }
  323. }
  324. }
  325. function map(arr, cb, context) {
  326. if (!arr) {
  327. return [];
  328. }
  329. if (!cb) {
  330. return slice(arr);
  331. }
  332. if (arr.map && arr.map === nativeMap) {
  333. return arr.map(cb, context);
  334. } else {
  335. var result = [];
  336. for (var i = 0, len = arr.length; i < len; i++) {
  337. result.push(cb.call(context, arr[i], i, arr));
  338. }
  339. return result;
  340. }
  341. }
  342. function reduce(arr, cb, memo, context) {
  343. if (!(arr && cb)) {
  344. return;
  345. }
  346. for (var i = 0, len = arr.length; i < len; i++) {
  347. memo = cb.call(context, memo, arr[i], i, arr);
  348. }
  349. return memo;
  350. }
  351. function filter(arr, cb, context) {
  352. if (!arr) {
  353. return [];
  354. }
  355. if (!cb) {
  356. return slice(arr);
  357. }
  358. if (arr.filter && arr.filter === nativeFilter) {
  359. return arr.filter(cb, context);
  360. } else {
  361. var result = [];
  362. for (var i = 0, len = arr.length; i < len; i++) {
  363. if (cb.call(context, arr[i], i, arr)) {
  364. result.push(arr[i]);
  365. }
  366. }
  367. return result;
  368. }
  369. }
  370. function find(arr, cb, context) {
  371. if (!(arr && cb)) {
  372. return;
  373. }
  374. for (var i = 0, len = arr.length; i < len; i++) {
  375. if (cb.call(context, arr[i], i, arr)) {
  376. return arr[i];
  377. }
  378. }
  379. }
  380. function keys(obj) {
  381. if (!obj) {
  382. return [];
  383. }
  384. if (Object.keys) {
  385. return Object.keys(obj);
  386. }
  387. var keyList = [];
  388. for (var key in obj) {
  389. if (obj.hasOwnProperty(key)) {
  390. keyList.push(key);
  391. }
  392. }
  393. return keyList;
  394. }
  395. function bindPolyfill(func, context) {
  396. var args = [];
  397. for (var _i = 2; _i < arguments.length; _i++) {
  398. args[_i - 2] = arguments[_i];
  399. }
  400. return function () {
  401. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  402. };
  403. }
  404. var bind = protoFunction && isFunction$1(protoFunction.bind) ? protoFunction.call.bind(protoFunction.bind) : bindPolyfill;
  405. function curry(func) {
  406. var args = [];
  407. for (var _i = 1; _i < arguments.length; _i++) {
  408. args[_i - 1] = arguments[_i];
  409. }
  410. return function () {
  411. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  412. };
  413. }
  414. function isArray(value) {
  415. if (Array.isArray) {
  416. return Array.isArray(value);
  417. }
  418. return objToString.call(value) === '[object Array]';
  419. }
  420. function isFunction$1(value) {
  421. return typeof value === 'function';
  422. }
  423. function isString(value) {
  424. return typeof value === 'string';
  425. }
  426. function isStringSafe(value) {
  427. return objToString.call(value) === '[object String]';
  428. }
  429. function isNumber(value) {
  430. return typeof value === 'number';
  431. }
  432. function isObject$1(value) {
  433. var type = typeof value;
  434. return type === 'function' || !!value && type === 'object';
  435. }
  436. function isBuiltInObject(value) {
  437. return !!BUILTIN_OBJECT[objToString.call(value)];
  438. }
  439. function isTypedArray(value) {
  440. return !!TYPED_ARRAY[objToString.call(value)];
  441. }
  442. function isDom(value) {
  443. return typeof value === 'object' && typeof value.nodeType === 'number' && typeof value.ownerDocument === 'object';
  444. }
  445. function isGradientObject(value) {
  446. return value.colorStops != null;
  447. }
  448. function isPatternObject(value) {
  449. return value.image != null;
  450. }
  451. function isRegExp(value) {
  452. return objToString.call(value) === '[object RegExp]';
  453. }
  454. function eqNaN(value) {
  455. return value !== value;
  456. }
  457. function retrieve() {
  458. var args = [];
  459. for (var _i = 0; _i < arguments.length; _i++) {
  460. args[_i] = arguments[_i];
  461. }
  462. for (var i = 0, len = args.length; i < len; i++) {
  463. if (args[i] != null) {
  464. return args[i];
  465. }
  466. }
  467. }
  468. function retrieve2(value0, value1) {
  469. return value0 != null ? value0 : value1;
  470. }
  471. function retrieve3(value0, value1, value2) {
  472. return value0 != null ? value0 : value1 != null ? value1 : value2;
  473. }
  474. function slice(arr) {
  475. var args = [];
  476. for (var _i = 1; _i < arguments.length; _i++) {
  477. args[_i - 1] = arguments[_i];
  478. }
  479. return nativeSlice.apply(arr, args);
  480. }
  481. function normalizeCssArray(val) {
  482. if (typeof val === 'number') {
  483. return [val, val, val, val];
  484. }
  485. var len = val.length;
  486. if (len === 2) {
  487. return [val[0], val[1], val[0], val[1]];
  488. } else if (len === 3) {
  489. return [val[0], val[1], val[2], val[1]];
  490. }
  491. return val;
  492. }
  493. function assert$1(condition, message) {
  494. if (!condition) {
  495. throw new Error(message);
  496. }
  497. }
  498. function trim(str) {
  499. if (str == null) {
  500. return null;
  501. } else if (typeof str.trim === 'function') {
  502. return str.trim();
  503. } else {
  504. return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  505. }
  506. }
  507. var primitiveKey = '__ec_primitive__';
  508. function setAsPrimitive(obj) {
  509. obj[primitiveKey] = true;
  510. }
  511. function isPrimitive(obj) {
  512. return obj[primitiveKey];
  513. }
  514. var HashMap = function () {
  515. function HashMap(obj) {
  516. this.data = {};
  517. var isArr = isArray(obj);
  518. this.data = {};
  519. var thisMap = this;
  520. obj instanceof HashMap ? obj.each(visit) : obj && each$1(obj, visit);
  521. function visit(value, key) {
  522. isArr ? thisMap.set(value, key) : thisMap.set(key, value);
  523. }
  524. }
  525. HashMap.prototype.get = function (key) {
  526. return this.data.hasOwnProperty(key) ? this.data[key] : null;
  527. };
  528. HashMap.prototype.set = function (key, value) {
  529. return this.data[key] = value;
  530. };
  531. HashMap.prototype.each = function (cb, context) {
  532. for (var key in this.data) {
  533. if (this.data.hasOwnProperty(key)) {
  534. cb.call(context, this.data[key], key);
  535. }
  536. }
  537. };
  538. HashMap.prototype.keys = function () {
  539. return keys(this.data);
  540. };
  541. HashMap.prototype.removeKey = function (key) {
  542. delete this.data[key];
  543. };
  544. return HashMap;
  545. }();
  546. function createHashMap(obj) {
  547. return new HashMap(obj);
  548. }
  549. function concatArray(a, b) {
  550. var newArray = new a.constructor(a.length + b.length);
  551. for (var i = 0; i < a.length; i++) {
  552. newArray[i] = a[i];
  553. }
  554. var offset = a.length;
  555. for (var i = 0; i < b.length; i++) {
  556. newArray[i + offset] = b[i];
  557. }
  558. return newArray;
  559. }
  560. function createObject(proto, properties) {
  561. var obj;
  562. if (Object.create) {
  563. obj = Object.create(proto);
  564. } else {
  565. var StyleCtor = function () {};
  566. StyleCtor.prototype = proto;
  567. obj = new StyleCtor();
  568. }
  569. if (properties) {
  570. extend(obj, properties);
  571. }
  572. return obj;
  573. }
  574. function hasOwn(own, prop) {
  575. return own.hasOwnProperty(prop);
  576. }
  577. function noop() {}
  578. var util = (Object.freeze || Object)({
  579. $override: $override,
  580. guid: guid,
  581. logError: logError,
  582. clone: clone,
  583. merge: merge,
  584. mergeAll: mergeAll,
  585. extend: extend,
  586. defaults: defaults,
  587. createCanvas: createCanvas,
  588. indexOf: indexOf$1,
  589. inherits: inherits,
  590. mixin: mixin,
  591. isArrayLike: isArrayLike,
  592. each: each$1,
  593. map: map,
  594. reduce: reduce,
  595. filter: filter,
  596. find: find,
  597. keys: keys,
  598. bind: bind,
  599. curry: curry,
  600. isArray: isArray,
  601. isFunction: isFunction$1,
  602. isString: isString,
  603. isStringSafe: isStringSafe,
  604. isNumber: isNumber,
  605. isObject: isObject$1,
  606. isBuiltInObject: isBuiltInObject,
  607. isTypedArray: isTypedArray,
  608. isDom: isDom,
  609. isGradientObject: isGradientObject,
  610. isPatternObject: isPatternObject,
  611. isRegExp: isRegExp,
  612. eqNaN: eqNaN,
  613. retrieve: retrieve,
  614. retrieve2: retrieve2,
  615. retrieve3: retrieve3,
  616. slice: slice,
  617. normalizeCssArray: normalizeCssArray,
  618. assert: assert$1,
  619. trim: trim,
  620. setAsPrimitive: setAsPrimitive,
  621. isPrimitive: isPrimitive,
  622. HashMap: HashMap,
  623. createHashMap: createHashMap,
  624. concatArray: concatArray,
  625. createObject: createObject,
  626. hasOwn: hasOwn,
  627. noop: noop
  628. });
  629. function create(x, y) {
  630. if (x == null) {
  631. x = 0;
  632. }
  633. if (y == null) {
  634. y = 0;
  635. }
  636. return [x, y];
  637. }
  638. function copy(out, v) {
  639. out[0] = v[0];
  640. out[1] = v[1];
  641. return out;
  642. }
  643. function clone$1(v) {
  644. return [v[0], v[1]];
  645. }
  646. function set(out, a, b) {
  647. out[0] = a;
  648. out[1] = b;
  649. return out;
  650. }
  651. function add(out, v1, v2) {
  652. out[0] = v1[0] + v2[0];
  653. out[1] = v1[1] + v2[1];
  654. return out;
  655. }
  656. function scaleAndAdd(out, v1, v2, a) {
  657. out[0] = v1[0] + v2[0] * a;
  658. out[1] = v1[1] + v2[1] * a;
  659. return out;
  660. }
  661. function sub(out, v1, v2) {
  662. out[0] = v1[0] - v2[0];
  663. out[1] = v1[1] - v2[1];
  664. return out;
  665. }
  666. function len(v) {
  667. return Math.sqrt(lenSquare(v));
  668. }
  669. var length = len;
  670. function lenSquare(v) {
  671. return v[0] * v[0] + v[1] * v[1];
  672. }
  673. var lengthSquare = lenSquare;
  674. function mul(out, v1, v2) {
  675. out[0] = v1[0] * v2[0];
  676. out[1] = v1[1] * v2[1];
  677. return out;
  678. }
  679. function div(out, v1, v2) {
  680. out[0] = v1[0] / v2[0];
  681. out[1] = v1[1] / v2[1];
  682. return out;
  683. }
  684. function dot(v1, v2) {
  685. return v1[0] * v2[0] + v1[1] * v2[1];
  686. }
  687. function scale(out, v, s) {
  688. out[0] = v[0] * s;
  689. out[1] = v[1] * s;
  690. return out;
  691. }
  692. function normalize(out, v) {
  693. var d = len(v);
  694. if (d === 0) {
  695. out[0] = 0;
  696. out[1] = 0;
  697. } else {
  698. out[0] = v[0] / d;
  699. out[1] = v[1] / d;
  700. }
  701. return out;
  702. }
  703. function distance(v1, v2) {
  704. return Math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]));
  705. }
  706. var dist = distance;
  707. function distanceSquare(v1, v2) {
  708. return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  709. }
  710. var distSquare = distanceSquare;
  711. function negate(out, v) {
  712. out[0] = -v[0];
  713. out[1] = -v[1];
  714. return out;
  715. }
  716. function lerp(out, v1, v2, t) {
  717. out[0] = v1[0] + t * (v2[0] - v1[0]);
  718. out[1] = v1[1] + t * (v2[1] - v1[1]);
  719. return out;
  720. }
  721. function applyTransform(out, v, m) {
  722. var x = v[0];
  723. var y = v[1];
  724. out[0] = m[0] * x + m[2] * y + m[4];
  725. out[1] = m[1] * x + m[3] * y + m[5];
  726. return out;
  727. }
  728. function min(out, v1, v2) {
  729. out[0] = Math.min(v1[0], v2[0]);
  730. out[1] = Math.min(v1[1], v2[1]);
  731. return out;
  732. }
  733. function max(out, v1, v2) {
  734. out[0] = Math.max(v1[0], v2[0]);
  735. out[1] = Math.max(v1[1], v2[1]);
  736. return out;
  737. }
  738. var vector = (Object.freeze || Object)({
  739. create: create,
  740. copy: copy,
  741. clone: clone$1,
  742. set: set,
  743. add: add,
  744. scaleAndAdd: scaleAndAdd,
  745. sub: sub,
  746. len: len,
  747. length: length,
  748. lenSquare: lenSquare,
  749. lengthSquare: lengthSquare,
  750. mul: mul,
  751. div: div,
  752. dot: dot,
  753. scale: scale,
  754. normalize: normalize,
  755. distance: distance,
  756. dist: dist,
  757. distanceSquare: distanceSquare,
  758. distSquare: distSquare,
  759. negate: negate,
  760. lerp: lerp,
  761. applyTransform: applyTransform,
  762. min: min,
  763. max: max
  764. });
  765. var Param = function () {
  766. function Param(target, e) {
  767. this.target = target;
  768. this.topTarget = e && e.topTarget;
  769. }
  770. return Param;
  771. }();
  772. var Draggable = function () {
  773. function Draggable(handler) {
  774. this.handler = handler;
  775. handler.on('mousedown', this._dragStart, this);
  776. handler.on('mousemove', this._drag, this);
  777. handler.on('mouseup', this._dragEnd, this);
  778. }
  779. Draggable.prototype._dragStart = function (e) {
  780. var draggingTarget = e.target;
  781. while (draggingTarget && !draggingTarget.draggable) {
  782. draggingTarget = draggingTarget.parent;
  783. }
  784. if (draggingTarget) {
  785. this._draggingTarget = draggingTarget;
  786. draggingTarget.dragging = true;
  787. this._x = e.offsetX;
  788. this._y = e.offsetY;
  789. this.handler.dispatchToElement(new Param(draggingTarget, e), 'dragstart', e.event);
  790. }
  791. };
  792. Draggable.prototype._drag = function (e) {
  793. var draggingTarget = this._draggingTarget;
  794. if (draggingTarget) {
  795. var x = e.offsetX;
  796. var y = e.offsetY;
  797. var dx = x - this._x;
  798. var dy = y - this._y;
  799. this._x = x;
  800. this._y = y;
  801. draggingTarget.drift(dx, dy, e);
  802. this.handler.dispatchToElement(new Param(draggingTarget, e), 'drag', e.event);
  803. var dropTarget = this.handler.findHover(x, y, draggingTarget).target;
  804. var lastDropTarget = this._dropTarget;
  805. this._dropTarget = dropTarget;
  806. if (draggingTarget !== dropTarget) {
  807. if (lastDropTarget && dropTarget !== lastDropTarget) {
  808. this.handler.dispatchToElement(new Param(lastDropTarget, e), 'dragleave', e.event);
  809. }
  810. if (dropTarget && dropTarget !== lastDropTarget) {
  811. this.handler.dispatchToElement(new Param(dropTarget, e), 'dragenter', e.event);
  812. }
  813. }
  814. }
  815. };
  816. Draggable.prototype._dragEnd = function (e) {
  817. var draggingTarget = this._draggingTarget;
  818. if (draggingTarget) {
  819. draggingTarget.dragging = false;
  820. }
  821. this.handler.dispatchToElement(new Param(draggingTarget, e), 'dragend', e.event);
  822. if (this._dropTarget) {
  823. this.handler.dispatchToElement(new Param(this._dropTarget, e), 'drop', e.event);
  824. }
  825. this._draggingTarget = null;
  826. this._dropTarget = null;
  827. };
  828. return Draggable;
  829. }();
  830. var Eventful = function () {
  831. function Eventful(eventProcessors) {
  832. if (eventProcessors) {
  833. this._$eventProcessor = eventProcessors;
  834. }
  835. }
  836. Eventful.prototype.on = function (event, query, handler, context) {
  837. if (!this._$handlers) {
  838. this._$handlers = {};
  839. }
  840. var _h = this._$handlers;
  841. if (typeof query === 'function') {
  842. context = handler;
  843. handler = query;
  844. query = null;
  845. }
  846. if (!handler || !event) {
  847. return this;
  848. }
  849. var eventProcessor = this._$eventProcessor;
  850. if (query != null && eventProcessor && eventProcessor.normalizeQuery) {
  851. query = eventProcessor.normalizeQuery(query);
  852. }
  853. if (!_h[event]) {
  854. _h[event] = [];
  855. }
  856. for (var i = 0; i < _h[event].length; i++) {
  857. if (_h[event][i].h === handler) {
  858. return this;
  859. }
  860. }
  861. var wrap = {
  862. h: handler,
  863. query: query,
  864. ctx: context || this,
  865. callAtLast: handler.zrEventfulCallAtLast
  866. };
  867. var lastIndex = _h[event].length - 1;
  868. var lastWrap = _h[event][lastIndex];
  869. lastWrap && lastWrap.callAtLast ? _h[event].splice(lastIndex, 0, wrap) : _h[event].push(wrap);
  870. return this;
  871. };
  872. Eventful.prototype.isSilent = function (eventName) {
  873. var _h = this._$handlers;
  874. return !_h || !_h[eventName] || !_h[eventName].length;
  875. };
  876. Eventful.prototype.off = function (eventType, handler) {
  877. var _h = this._$handlers;
  878. if (!_h) {
  879. return this;
  880. }
  881. if (!eventType) {
  882. this._$handlers = {};
  883. return this;
  884. }
  885. if (handler) {
  886. if (_h[eventType]) {
  887. var newList = [];
  888. for (var i = 0, l = _h[eventType].length; i < l; i++) {
  889. if (_h[eventType][i].h !== handler) {
  890. newList.push(_h[eventType][i]);
  891. }
  892. }
  893. _h[eventType] = newList;
  894. }
  895. if (_h[eventType] && _h[eventType].length === 0) {
  896. delete _h[eventType];
  897. }
  898. } else {
  899. delete _h[eventType];
  900. }
  901. return this;
  902. };
  903. Eventful.prototype.trigger = function (eventType) {
  904. var args = [];
  905. for (var _i = 1; _i < arguments.length; _i++) {
  906. args[_i - 1] = arguments[_i];
  907. }
  908. if (!this._$handlers) {
  909. return this;
  910. }
  911. var _h = this._$handlers[eventType];
  912. var eventProcessor = this._$eventProcessor;
  913. if (_h) {
  914. var argLen = args.length;
  915. var len = _h.length;
  916. for (var i = 0; i < len; i++) {
  917. var hItem = _h[i];
  918. if (eventProcessor && eventProcessor.filter && hItem.query != null && !eventProcessor.filter(eventType, hItem.query)) {
  919. continue;
  920. }
  921. switch (argLen) {
  922. case 0:
  923. hItem.h.call(hItem.ctx);
  924. break;
  925. case 1:
  926. hItem.h.call(hItem.ctx, args[0]);
  927. break;
  928. case 2:
  929. hItem.h.call(hItem.ctx, args[0], args[1]);
  930. break;
  931. default:
  932. hItem.h.apply(hItem.ctx, args);
  933. break;
  934. }
  935. }
  936. }
  937. eventProcessor && eventProcessor.afterTrigger && eventProcessor.afterTrigger(eventType);
  938. return this;
  939. };
  940. Eventful.prototype.triggerWithContext = function (type) {
  941. if (!this._$handlers) {
  942. return this;
  943. }
  944. var _h = this._$handlers[type];
  945. var eventProcessor = this._$eventProcessor;
  946. if (_h) {
  947. var args = arguments;
  948. var argLen = args.length;
  949. var ctx = args[argLen - 1];
  950. var len = _h.length;
  951. for (var i = 0; i < len; i++) {
  952. var hItem = _h[i];
  953. if (eventProcessor && eventProcessor.filter && hItem.query != null && !eventProcessor.filter(type, hItem.query)) {
  954. continue;
  955. }
  956. switch (argLen) {
  957. case 0:
  958. hItem.h.call(ctx);
  959. break;
  960. case 1:
  961. hItem.h.call(ctx, args[0]);
  962. break;
  963. case 2:
  964. hItem.h.call(ctx, args[0], args[1]);
  965. break;
  966. default:
  967. hItem.h.apply(ctx, args.slice(1, argLen - 1));
  968. break;
  969. }
  970. }
  971. }
  972. eventProcessor && eventProcessor.afterTrigger && eventProcessor.afterTrigger(type);
  973. return this;
  974. };
  975. return Eventful;
  976. }();
  977. var LN2 = Math.log(2);
  978. function determinant(rows, rank, rowStart, rowMask, colMask, detCache) {
  979. var cacheKey = rowMask + '-' + colMask;
  980. var fullRank = rows.length;
  981. if (detCache.hasOwnProperty(cacheKey)) {
  982. return detCache[cacheKey];
  983. }
  984. if (rank === 1) {
  985. var colStart = Math.round(Math.log((1 << fullRank) - 1 & ~colMask) / LN2);
  986. return rows[rowStart][colStart];
  987. }
  988. var subRowMask = rowMask | 1 << rowStart;
  989. var subRowStart = rowStart + 1;
  990. while (rowMask & 1 << subRowStart) {
  991. subRowStart++;
  992. }
  993. var sum = 0;
  994. for (var j = 0, colLocalIdx = 0; j < fullRank; j++) {
  995. var colTag = 1 << j;
  996. if (!(colTag & colMask)) {
  997. sum += (colLocalIdx % 2 ? -1 : 1) * rows[rowStart][j] * determinant(rows, rank - 1, subRowStart, subRowMask, colMask | colTag, detCache);
  998. colLocalIdx++;
  999. }
  1000. }
  1001. detCache[cacheKey] = sum;
  1002. return sum;
  1003. }
  1004. function buildTransformer(src, dest) {
  1005. var mA = [[src[0], src[1], 1, 0, 0, 0, -dest[0] * src[0], -dest[0] * src[1]], [0, 0, 0, src[0], src[1], 1, -dest[1] * src[0], -dest[1] * src[1]], [src[2], src[3], 1, 0, 0, 0, -dest[2] * src[2], -dest[2] * src[3]], [0, 0, 0, src[2], src[3], 1, -dest[3] * src[2], -dest[3] * src[3]], [src[4], src[5], 1, 0, 0, 0, -dest[4] * src[4], -dest[4] * src[5]], [0, 0, 0, src[4], src[5], 1, -dest[5] * src[4], -dest[5] * src[5]], [src[6], src[7], 1, 0, 0, 0, -dest[6] * src[6], -dest[6] * src[7]], [0, 0, 0, src[6], src[7], 1, -dest[7] * src[6], -dest[7] * src[7]]];
  1006. var detCache = {};
  1007. var det = determinant(mA, 8, 0, 0, 0, detCache);
  1008. if (det === 0) {
  1009. return;
  1010. }
  1011. var vh = [];
  1012. for (var i = 0; i < 8; i++) {
  1013. for (var j = 0; j < 8; j++) {
  1014. vh[j] == null && (vh[j] = 0);
  1015. vh[j] += ((i + j) % 2 ? -1 : 1) * determinant(mA, 7, i === 0 ? 1 : 0, 1 << i, 1 << j, detCache) / det * dest[i];
  1016. }
  1017. }
  1018. return function (out, srcPointX, srcPointY) {
  1019. var pk = srcPointX * vh[6] + srcPointY * vh[7] + 1;
  1020. out[0] = (srcPointX * vh[0] + srcPointY * vh[1] + vh[2]) / pk;
  1021. out[1] = (srcPointX * vh[3] + srcPointY * vh[4] + vh[5]) / pk;
  1022. };
  1023. }
  1024. var EVENT_SAVED_PROP = '___zrEVENTSAVED';
  1025. var _calcOut$1 = [];
  1026. function transformLocalCoord(out, elFrom, elTarget, inX, inY) {
  1027. return transformCoordWithViewport(_calcOut$1, elFrom, inX, inY, true) && transformCoordWithViewport(out, elTarget, _calcOut$1[0], _calcOut$1[1]);
  1028. }
  1029. function transformCoordWithViewport(out, el, inX, inY, inverse) {
  1030. if (el.getBoundingClientRect && env.domSupported && !isCanvasEl(el)) {
  1031. var saved = el[EVENT_SAVED_PROP] || (el[EVENT_SAVED_PROP] = {});
  1032. var markers = prepareCoordMarkers(el, saved);
  1033. var transformer = preparePointerTransformer(markers, saved, inverse);
  1034. if (transformer) {
  1035. transformer(out, inX, inY);
  1036. return true;
  1037. }
  1038. }
  1039. return false;
  1040. }
  1041. function prepareCoordMarkers(el, saved) {
  1042. var markers = saved.markers;
  1043. if (markers) {
  1044. return markers;
  1045. }
  1046. markers = saved.markers = [];
  1047. var propLR = ['left', 'right'];
  1048. var propTB = ['top', 'bottom'];
  1049. for (var i = 0; i < 4; i++) {
  1050. var marker = document.createElement('div');
  1051. var stl = marker.style;
  1052. var idxLR = i % 2;
  1053. var idxTB = (i >> 1) % 2;
  1054. stl.cssText = ['position: absolute', 'visibility: hidden', 'padding: 0', 'margin: 0', 'border-width: 0', 'user-select: none', 'width:0', 'height:0', propLR[idxLR] + ':0', propTB[idxTB] + ':0', propLR[1 - idxLR] + ':auto', propTB[1 - idxTB] + ':auto', ''].join('!important;');
  1055. el.appendChild(marker);
  1056. markers.push(marker);
  1057. }
  1058. return markers;
  1059. }
  1060. function preparePointerTransformer(markers, saved, inverse) {
  1061. var transformerName = inverse ? 'invTrans' : 'trans';
  1062. var transformer = saved[transformerName];
  1063. var oldSrcCoords = saved.srcCoords;
  1064. var srcCoords = [];
  1065. var destCoords = [];
  1066. var oldCoordTheSame = true;
  1067. for (var i = 0; i < 4; i++) {
  1068. var rect = markers[i].getBoundingClientRect();
  1069. var ii = 2 * i;
  1070. var x = rect.left;
  1071. var y = rect.top;
  1072. srcCoords.push(x, y);
  1073. oldCoordTheSame = oldCoordTheSame && oldSrcCoords && x === oldSrcCoords[ii] && y === oldSrcCoords[ii + 1];
  1074. destCoords.push(markers[i].offsetLeft, markers[i].offsetTop);
  1075. }
  1076. return oldCoordTheSame && transformer ? transformer : (saved.srcCoords = srcCoords, saved[transformerName] = inverse ? buildTransformer(destCoords, srcCoords) : buildTransformer(srcCoords, destCoords));
  1077. }
  1078. function isCanvasEl(el) {
  1079. return el.nodeName.toUpperCase() === 'CANVAS';
  1080. }
  1081. var isDomLevel2 = typeof window !== 'undefined' && !!window.addEventListener;
  1082. var MOUSE_EVENT_REG = /^(?:mouse|pointer|contextmenu|drag|drop)|click/;
  1083. var _calcOut = [];
  1084. function clientToLocal(el, e, out, calculate) {
  1085. out = out || {};
  1086. if (calculate || !env.canvasSupported) {
  1087. calculateZrXY(el, e, out);
  1088. } else if (env.browser.firefox && e.layerX != null && e.layerX !== e.offsetX) {
  1089. out.zrX = e.layerX;
  1090. out.zrY = e.layerY;
  1091. } else if (e.offsetX != null) {
  1092. out.zrX = e.offsetX;
  1093. out.zrY = e.offsetY;
  1094. } else {
  1095. calculateZrXY(el, e, out);
  1096. }
  1097. return out;
  1098. }
  1099. function calculateZrXY(el, e, out) {
  1100. if (env.domSupported && el.getBoundingClientRect) {
  1101. var ex = e.clientX;
  1102. var ey = e.clientY;
  1103. if (isCanvasEl(el)) {
  1104. var box = el.getBoundingClientRect();
  1105. out.zrX = ex - box.left;
  1106. out.zrY = ey - box.top;
  1107. return;
  1108. } else {
  1109. if (transformCoordWithViewport(_calcOut, el, ex, ey)) {
  1110. out.zrX = _calcOut[0];
  1111. out.zrY = _calcOut[1];
  1112. return;
  1113. }
  1114. }
  1115. }
  1116. out.zrX = out.zrY = 0;
  1117. }
  1118. function getNativeEvent(e) {
  1119. return e || window.event;
  1120. }
  1121. function normalizeEvent(el, e, calculate) {
  1122. e = getNativeEvent(e);
  1123. if (e.zrX != null) {
  1124. return e;
  1125. }
  1126. var eventType = e.type;
  1127. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  1128. if (!isTouch) {
  1129. clientToLocal(el, e, e, calculate);
  1130. var wheelDelta = getWheelDeltaMayPolyfill(e);
  1131. e.zrDelta = wheelDelta ? wheelDelta / 120 : -(e.detail || 0) / 3;
  1132. } else {
  1133. var touch = eventType !== 'touchend' ? e.targetTouches[0] : e.changedTouches[0];
  1134. touch && clientToLocal(el, touch, e, calculate);
  1135. }
  1136. var button = e.button;
  1137. if (e.which == null && button !== undefined && MOUSE_EVENT_REG.test(e.type)) {
  1138. e.which = button & 1 ? 1 : button & 2 ? 3 : button & 4 ? 2 : 0;
  1139. }
  1140. return e;
  1141. }
  1142. function getWheelDeltaMayPolyfill(e) {
  1143. var rawWheelDelta = e.wheelDelta;
  1144. if (rawWheelDelta) {
  1145. return rawWheelDelta;
  1146. }
  1147. var deltaX = e.deltaX;
  1148. var deltaY = e.deltaY;
  1149. if (deltaX == null || deltaY == null) {
  1150. return rawWheelDelta;
  1151. }
  1152. var delta = deltaY !== 0 ? Math.abs(deltaY) : Math.abs(deltaX);
  1153. var sign = deltaY > 0 ? -1 : deltaY < 0 ? 1 : deltaX > 0 ? -1 : 1;
  1154. return 3 * delta * sign;
  1155. }
  1156. function addEventListener(el, name, handler, opt) {
  1157. if (isDomLevel2) {
  1158. el.addEventListener(name, handler, opt);
  1159. } else {
  1160. el.attachEvent('on' + name, handler);
  1161. }
  1162. }
  1163. function removeEventListener(el, name, handler, opt) {
  1164. if (isDomLevel2) {
  1165. el.removeEventListener(name, handler, opt);
  1166. } else {
  1167. el.detachEvent('on' + name, handler);
  1168. }
  1169. }
  1170. var stop = isDomLevel2 ? function (e) {
  1171. e.preventDefault();
  1172. e.stopPropagation();
  1173. e.cancelBubble = true;
  1174. } : function (e) {
  1175. e.returnValue = false;
  1176. e.cancelBubble = true;
  1177. };
  1178. function isMiddleOrRightButtonOnMouseUpDown(e) {
  1179. return e.which === 2 || e.which === 3;
  1180. }
  1181. var GestureMgr = function () {
  1182. function GestureMgr() {
  1183. this._track = [];
  1184. }
  1185. GestureMgr.prototype.recognize = function (event, target, root) {
  1186. this._doTrack(event, target, root);
  1187. return this._recognize(event);
  1188. };
  1189. GestureMgr.prototype.clear = function () {
  1190. this._track.length = 0;
  1191. return this;
  1192. };
  1193. GestureMgr.prototype._doTrack = function (event, target, root) {
  1194. var touches = event.touches;
  1195. if (!touches) {
  1196. return;
  1197. }
  1198. var trackItem = {
  1199. points: [],
  1200. touches: [],
  1201. target: target,
  1202. event: event
  1203. };
  1204. for (var i = 0, len = touches.length; i < len; i++) {
  1205. var touch = touches[i];
  1206. var pos = clientToLocal(root, touch, {});
  1207. trackItem.points.push([pos.zrX, pos.zrY]);
  1208. trackItem.touches.push(touch);
  1209. }
  1210. this._track.push(trackItem);
  1211. };
  1212. GestureMgr.prototype._recognize = function (event) {
  1213. for (var eventName in recognizers) {
  1214. if (recognizers.hasOwnProperty(eventName)) {
  1215. var gestureInfo = recognizers[eventName](this._track, event);
  1216. if (gestureInfo) {
  1217. return gestureInfo;
  1218. }
  1219. }
  1220. }
  1221. };
  1222. return GestureMgr;
  1223. }();
  1224. function dist$1(pointPair) {
  1225. var dx = pointPair[1][0] - pointPair[0][0];
  1226. var dy = pointPair[1][1] - pointPair[0][1];
  1227. return Math.sqrt(dx * dx + dy * dy);
  1228. }
  1229. function center(pointPair) {
  1230. return [(pointPair[0][0] + pointPair[1][0]) / 2, (pointPair[0][1] + pointPair[1][1]) / 2];
  1231. }
  1232. var recognizers = {
  1233. pinch: function (tracks, event) {
  1234. var trackLen = tracks.length;
  1235. if (!trackLen) {
  1236. return;
  1237. }
  1238. var pinchEnd = (tracks[trackLen - 1] || {}).points;
  1239. var pinchPre = (tracks[trackLen - 2] || {}).points || pinchEnd;
  1240. if (pinchPre && pinchPre.length > 1 && pinchEnd && pinchEnd.length > 1) {
  1241. var pinchScale = dist$1(pinchEnd) / dist$1(pinchPre);
  1242. !isFinite(pinchScale) && (pinchScale = 1);
  1243. event.pinchScale = pinchScale;
  1244. var pinchCenter = center(pinchEnd);
  1245. event.pinchX = pinchCenter[0];
  1246. event.pinchY = pinchCenter[1];
  1247. return {
  1248. type: 'pinch',
  1249. target: tracks[0].target,
  1250. event: event
  1251. };
  1252. }
  1253. }
  1254. };
  1255. var SILENT = 'silent';
  1256. function makeEventPacket(eveType, targetInfo, event) {
  1257. return {
  1258. type: eveType,
  1259. event: event,
  1260. target: targetInfo.target,
  1261. topTarget: targetInfo.topTarget,
  1262. cancelBubble: false,
  1263. offsetX: event.zrX,
  1264. offsetY: event.zrY,
  1265. gestureEvent: event.gestureEvent,
  1266. pinchX: event.pinchX,
  1267. pinchY: event.pinchY,
  1268. pinchScale: event.pinchScale,
  1269. wheelDelta: event.zrDelta,
  1270. zrByTouch: event.zrByTouch,
  1271. which: event.which,
  1272. stop: stopEvent
  1273. };
  1274. }
  1275. function stopEvent() {
  1276. stop(this.event);
  1277. }
  1278. var EmptyProxy = function (_super) {
  1279. __extends(EmptyProxy, _super);
  1280. function EmptyProxy() {
  1281. var _this = _super !== null && _super.apply(this, arguments) || this;
  1282. _this.handler = null;
  1283. return _this;
  1284. }
  1285. EmptyProxy.prototype.dispose = function () {};
  1286. EmptyProxy.prototype.setCursor = function () {};
  1287. return EmptyProxy;
  1288. }(Eventful);
  1289. var HoveredResult = function () {
  1290. function HoveredResult(x, y) {
  1291. this.x = x;
  1292. this.y = y;
  1293. }
  1294. return HoveredResult;
  1295. }();
  1296. var handlerNames = ['click', 'dblclick', 'mousewheel', 'mouseout', 'mouseup', 'mousedown', 'mousemove', 'contextmenu'];
  1297. var Handler = function (_super) {
  1298. __extends(Handler, _super);
  1299. function Handler(storage, painter, proxy, painterRoot) {
  1300. var _this = _super.call(this) || this;
  1301. _this._hovered = new HoveredResult(0, 0);
  1302. _this.storage = storage;
  1303. _this.painter = painter;
  1304. _this.painterRoot = painterRoot;
  1305. proxy = proxy || new EmptyProxy();
  1306. _this.proxy = null;
  1307. _this.setHandlerProxy(proxy);
  1308. _this._draggingMgr = new Draggable(_this);
  1309. return _this;
  1310. }
  1311. Handler.prototype.setHandlerProxy = function (proxy) {
  1312. if (this.proxy) {
  1313. this.proxy.dispose();
  1314. }
  1315. if (proxy) {
  1316. each$1(handlerNames, function (name) {
  1317. proxy.on && proxy.on(name, this[name], this);
  1318. }, this);
  1319. proxy.handler = this;
  1320. }
  1321. this.proxy = proxy;
  1322. };
  1323. Handler.prototype.mousemove = function (event) {
  1324. var x = event.zrX;
  1325. var y = event.zrY;
  1326. var isOutside = isOutsideBoundary(this, x, y);
  1327. var lastHovered = this._hovered;
  1328. var lastHoveredTarget = lastHovered.target;
  1329. if (lastHoveredTarget && !lastHoveredTarget.__zr) {
  1330. lastHovered = this.findHover(lastHovered.x, lastHovered.y);
  1331. lastHoveredTarget = lastHovered.target;
  1332. }
  1333. var hovered = this._hovered = isOutside ? new HoveredResult(x, y) : this.findHover(x, y);
  1334. var hoveredTarget = hovered.target;
  1335. var proxy = this.proxy;
  1336. proxy.setCursor && proxy.setCursor(hoveredTarget ? hoveredTarget.cursor : 'default');
  1337. if (lastHoveredTarget && hoveredTarget !== lastHoveredTarget) {
  1338. this.dispatchToElement(lastHovered, 'mouseout', event);
  1339. }
  1340. this.dispatchToElement(hovered, 'mousemove', event);
  1341. if (hoveredTarget && hoveredTarget !== lastHoveredTarget) {
  1342. this.dispatchToElement(hovered, 'mouseover', event);
  1343. }
  1344. };
  1345. Handler.prototype.mouseout = function (event) {
  1346. var eventControl = event.zrEventControl;
  1347. if (eventControl !== 'only_globalout') {
  1348. this.dispatchToElement(this._hovered, 'mouseout', event);
  1349. }
  1350. if (eventControl !== 'no_globalout') {
  1351. this.trigger('globalout', {
  1352. type: 'globalout',
  1353. event: event
  1354. });
  1355. }
  1356. };
  1357. Handler.prototype.resize = function () {
  1358. this._hovered = new HoveredResult(0, 0);
  1359. };
  1360. Handler.prototype.dispatch = function (eventName, eventArgs) {
  1361. var handler = this[eventName];
  1362. handler && handler.call(this, eventArgs);
  1363. };
  1364. Handler.prototype.dispose = function () {
  1365. this.proxy.dispose();
  1366. this.storage = null;
  1367. this.proxy = null;
  1368. this.painter = null;
  1369. };
  1370. Handler.prototype.setCursorStyle = function (cursorStyle) {
  1371. var proxy = this.proxy;
  1372. proxy.setCursor && proxy.setCursor(cursorStyle);
  1373. };
  1374. Handler.prototype.dispatchToElement = function (targetInfo, eventName, event) {
  1375. targetInfo = targetInfo || {};
  1376. var el = targetInfo.target;
  1377. if (el && el.silent) {
  1378. return;
  1379. }
  1380. var eventKey = 'on' + eventName;
  1381. var eventPacket = makeEventPacket(eventName, targetInfo, event);
  1382. while (el) {
  1383. el[eventKey] && (eventPacket.cancelBubble = !!el[eventKey].call(el, eventPacket));
  1384. el.trigger(eventName, eventPacket);
  1385. el = el.__hostTarget ? el.__hostTarget : el.parent;
  1386. if (eventPacket.cancelBubble) {
  1387. break;
  1388. }
  1389. }
  1390. if (!eventPacket.cancelBubble) {
  1391. this.trigger(eventName, eventPacket);
  1392. if (this.painter && this.painter.eachOtherLayer) {
  1393. this.painter.eachOtherLayer(function (layer) {
  1394. if (typeof layer[eventKey] === 'function') {
  1395. layer[eventKey].call(layer, eventPacket);
  1396. }
  1397. if (layer.trigger) {
  1398. layer.trigger(eventName, eventPacket);
  1399. }
  1400. });
  1401. }
  1402. }
  1403. };
  1404. Handler.prototype.findHover = function (x, y, exclude) {
  1405. var list = this.storage.getDisplayList();
  1406. var out = new HoveredResult(x, y);
  1407. for (var i = list.length - 1; i >= 0; i--) {
  1408. var hoverCheckResult = void 0;
  1409. if (list[i] !== exclude && !list[i].ignore && (hoverCheckResult = isHover(list[i], x, y))) {
  1410. !out.topTarget && (out.topTarget = list[i]);
  1411. if (hoverCheckResult !== SILENT) {
  1412. out.target = list[i];
  1413. break;
  1414. }
  1415. }
  1416. }
  1417. return out;
  1418. };
  1419. Handler.prototype.processGesture = function (event, stage) {
  1420. if (!this._gestureMgr) {
  1421. this._gestureMgr = new GestureMgr();
  1422. }
  1423. var gestureMgr = this._gestureMgr;
  1424. stage === 'start' && gestureMgr.clear();
  1425. var gestureInfo = gestureMgr.recognize(event, this.findHover(event.zrX, event.zrY, null).target, this.proxy.dom);
  1426. stage === 'end' && gestureMgr.clear();
  1427. if (gestureInfo) {
  1428. var type = gestureInfo.type;
  1429. event.gestureEvent = type;
  1430. var res = new HoveredResult();
  1431. res.target = gestureInfo.target;
  1432. this.dispatchToElement(res, type, gestureInfo.event);
  1433. }
  1434. };
  1435. return Handler;
  1436. }(Eventful);
  1437. each$1(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick', 'contextmenu'], function (name) {
  1438. Handler.prototype[name] = function (event) {
  1439. var x = event.zrX;
  1440. var y = event.zrY;
  1441. var isOutside = isOutsideBoundary(this, x, y);
  1442. var hovered;
  1443. var hoveredTarget;
  1444. if (name !== 'mouseup' || !isOutside) {
  1445. hovered = this.findHover(x, y);
  1446. hoveredTarget = hovered.target;
  1447. }
  1448. if (name === 'mousedown') {
  1449. this._downEl = hoveredTarget;
  1450. this._downPoint = [event.zrX, event.zrY];
  1451. this._upEl = hoveredTarget;
  1452. } else if (name === 'mouseup') {
  1453. this._upEl = hoveredTarget;
  1454. } else if (name === 'click') {
  1455. if (this._downEl !== this._upEl || !this._downPoint || dist(this._downPoint, [event.zrX, event.zrY]) > 4) {
  1456. return;
  1457. }
  1458. this._downPoint = null;
  1459. }
  1460. this.dispatchToElement(hovered, name, event);
  1461. };
  1462. });
  1463. function isHover(displayable, x, y) {
  1464. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  1465. var el = displayable;
  1466. var isSilent = void 0;
  1467. var ignoreClip = false;
  1468. while (el) {
  1469. if (el.ignoreClip) {
  1470. ignoreClip = true;
  1471. }
  1472. if (!ignoreClip) {
  1473. var clipPath = el.getClipPath();
  1474. if (clipPath && !clipPath.contain(x, y)) {
  1475. return false;
  1476. }
  1477. if (el.silent) {
  1478. isSilent = true;
  1479. }
  1480. }
  1481. var hostEl = el.__hostTarget;
  1482. el = hostEl ? hostEl : el.parent;
  1483. }
  1484. return isSilent ? SILENT : true;
  1485. }
  1486. return false;
  1487. }
  1488. function isOutsideBoundary(handlerInstance, x, y) {
  1489. var painter = handlerInstance.painter;
  1490. return x < 0 || x > painter.getWidth() || y < 0 || y > painter.getHeight();
  1491. }
  1492. function create$1() {
  1493. return [1, 0, 0, 1, 0, 0];
  1494. }
  1495. function identity(out) {
  1496. out[0] = 1;
  1497. out[1] = 0;
  1498. out[2] = 0;
  1499. out[3] = 1;
  1500. out[4] = 0;
  1501. out[5] = 0;
  1502. return out;
  1503. }
  1504. function copy$1(out, m) {
  1505. out[0] = m[0];
  1506. out[1] = m[1];
  1507. out[2] = m[2];
  1508. out[3] = m[3];
  1509. out[4] = m[4];
  1510. out[5] = m[5];
  1511. return out;
  1512. }
  1513. function mul$1(out, m1, m2) {
  1514. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  1515. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  1516. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  1517. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  1518. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  1519. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  1520. out[0] = out0;
  1521. out[1] = out1;
  1522. out[2] = out2;
  1523. out[3] = out3;
  1524. out[4] = out4;
  1525. out[5] = out5;
  1526. return out;
  1527. }
  1528. function translate(out, a, v) {
  1529. out[0] = a[0];
  1530. out[1] = a[1];
  1531. out[2] = a[2];
  1532. out[3] = a[3];
  1533. out[4] = a[4] + v[0];
  1534. out[5] = a[5] + v[1];
  1535. return out;
  1536. }
  1537. function rotate(out, a, rad) {
  1538. var aa = a[0];
  1539. var ac = a[2];
  1540. var atx = a[4];
  1541. var ab = a[1];
  1542. var ad = a[3];
  1543. var aty = a[5];
  1544. var st = Math.sin(rad);
  1545. var ct = Math.cos(rad);
  1546. out[0] = aa * ct + ab * st;
  1547. out[1] = -aa * st + ab * ct;
  1548. out[2] = ac * ct + ad * st;
  1549. out[3] = -ac * st + ct * ad;
  1550. out[4] = ct * atx + st * aty;
  1551. out[5] = ct * aty - st * atx;
  1552. return out;
  1553. }
  1554. function scale$1(out, a, v) {
  1555. var vx = v[0];
  1556. var vy = v[1];
  1557. out[0] = a[0] * vx;
  1558. out[1] = a[1] * vy;
  1559. out[2] = a[2] * vx;
  1560. out[3] = a[3] * vy;
  1561. out[4] = a[4] * vx;
  1562. out[5] = a[5] * vy;
  1563. return out;
  1564. }
  1565. function invert(out, a) {
  1566. var aa = a[0];
  1567. var ac = a[2];
  1568. var atx = a[4];
  1569. var ab = a[1];
  1570. var ad = a[3];
  1571. var aty = a[5];
  1572. var det = aa * ad - ab * ac;
  1573. if (!det) {
  1574. return null;
  1575. }
  1576. det = 1.0 / det;
  1577. out[0] = ad * det;
  1578. out[1] = -ab * det;
  1579. out[2] = -ac * det;
  1580. out[3] = aa * det;
  1581. out[4] = (ac * aty - ad * atx) * det;
  1582. out[5] = (ab * atx - aa * aty) * det;
  1583. return out;
  1584. }
  1585. function clone$2(a) {
  1586. var b = create$1();
  1587. copy$1(b, a);
  1588. return b;
  1589. }
  1590. var matrix = (Object.freeze || Object)({
  1591. create: create$1,
  1592. identity: identity,
  1593. copy: copy$1,
  1594. mul: mul$1,
  1595. translate: translate,
  1596. rotate: rotate,
  1597. scale: scale$1,
  1598. invert: invert,
  1599. clone: clone$2
  1600. });
  1601. var mIdentity = identity;
  1602. var EPSILON = 5e-5;
  1603. function isNotAroundZero(val) {
  1604. return val > EPSILON || val < -EPSILON;
  1605. }
  1606. var scaleTmp = [];
  1607. var tmpTransform = [];
  1608. var originTransform = create$1();
  1609. var abs = Math.abs;
  1610. var Transformable = function () {
  1611. function Transformable() {}
  1612. Transformable.prototype.setPosition = function (arr) {
  1613. this.x = arr[0];
  1614. this.y = arr[1];
  1615. };
  1616. Transformable.prototype.setScale = function (arr) {
  1617. this.scaleX = arr[0];
  1618. this.scaleY = arr[1];
  1619. };
  1620. Transformable.prototype.setOrigin = function (arr) {
  1621. this.originX = arr[0];
  1622. this.originY = arr[1];
  1623. };
  1624. Transformable.prototype.needLocalTransform = function () {
  1625. return isNotAroundZero(this.rotation) || isNotAroundZero(this.x) || isNotAroundZero(this.y) || isNotAroundZero(this.scaleX - 1) || isNotAroundZero(this.scaleY - 1);
  1626. };
  1627. Transformable.prototype.updateTransform = function () {
  1628. var parent = this.parent;
  1629. var parentHasTransform = parent && parent.transform;
  1630. var needLocalTransform = this.needLocalTransform();
  1631. var m = this.transform;
  1632. if (!(needLocalTransform || parentHasTransform)) {
  1633. m && mIdentity(m);
  1634. return;
  1635. }
  1636. m = m || create$1();
  1637. if (needLocalTransform) {
  1638. this.getLocalTransform(m);
  1639. } else {
  1640. mIdentity(m);
  1641. }
  1642. if (parentHasTransform) {
  1643. if (needLocalTransform) {
  1644. mul$1(m, parent.transform, m);
  1645. } else {
  1646. copy$1(m, parent.transform);
  1647. }
  1648. }
  1649. this.transform = m;
  1650. this._resolveGlobalScaleRatio(m);
  1651. };
  1652. Transformable.prototype._resolveGlobalScaleRatio = function (m) {
  1653. var globalScaleRatio = this.globalScaleRatio;
  1654. if (globalScaleRatio != null && globalScaleRatio !== 1) {
  1655. this.getGlobalScale(scaleTmp);
  1656. var relX = scaleTmp[0] < 0 ? -1 : 1;
  1657. var relY = scaleTmp[1] < 0 ? -1 : 1;
  1658. var sx = ((scaleTmp[0] - relX) * globalScaleRatio + relX) / scaleTmp[0] || 0;
  1659. var sy = ((scaleTmp[1] - relY) * globalScaleRatio + relY) / scaleTmp[1] || 0;
  1660. m[0] *= sx;
  1661. m[1] *= sx;
  1662. m[2] *= sy;
  1663. m[3] *= sy;
  1664. }
  1665. this.invTransform = this.invTransform || create$1();
  1666. invert(this.invTransform, m);
  1667. };
  1668. Transformable.prototype.getLocalTransform = function (m) {
  1669. return Transformable.getLocalTransform(this, m);
  1670. };
  1671. Transformable.prototype.getComputedTransform = function () {
  1672. var transformNode = this;
  1673. var ancestors = [];
  1674. while (transformNode) {
  1675. ancestors.push(transformNode);
  1676. transformNode = transformNode.parent;
  1677. }
  1678. while (transformNode = ancestors.pop()) {
  1679. transformNode.updateTransform();
  1680. }
  1681. return this.transform;
  1682. };
  1683. Transformable.prototype.setLocalTransform = function (m) {
  1684. if (!m) {
  1685. return;
  1686. }
  1687. var sx = m[0] * m[0] + m[1] * m[1];
  1688. var sy = m[2] * m[2] + m[3] * m[3];
  1689. if (isNotAroundZero(sx - 1)) {
  1690. sx = Math.sqrt(sx);
  1691. }
  1692. if (isNotAroundZero(sy - 1)) {
  1693. sy = Math.sqrt(sy);
  1694. }
  1695. if (m[0] < 0) {
  1696. sx = -sx;
  1697. }
  1698. if (m[3] < 0) {
  1699. sy = -sy;
  1700. }
  1701. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  1702. if (sx < 0 && sy < 0) {
  1703. this.rotation += Math.PI;
  1704. sx = -sx;
  1705. sy = -sy;
  1706. }
  1707. this.x = m[4];
  1708. this.y = m[5];
  1709. this.scaleX = sx;
  1710. this.scaleY = sy;
  1711. };
  1712. Transformable.prototype.decomposeTransform = function () {
  1713. if (!this.transform) {
  1714. return;
  1715. }
  1716. var parent = this.parent;
  1717. var m = this.transform;
  1718. if (parent && parent.transform) {
  1719. mul$1(tmpTransform, parent.invTransform, m);
  1720. m = tmpTransform;
  1721. }
  1722. var ox = this.originX;
  1723. var oy = this.originY;
  1724. if (ox || oy) {
  1725. originTransform[4] = ox;
  1726. originTransform[5] = oy;
  1727. mul$1(tmpTransform, m, originTransform);
  1728. tmpTransform[4] -= ox;
  1729. tmpTransform[5] -= oy;
  1730. m = tmpTransform;
  1731. }
  1732. this.setLocalTransform(m);
  1733. };
  1734. Transformable.prototype.getGlobalScale = function (out) {
  1735. var m = this.transform;
  1736. out = out || [];
  1737. if (!m) {
  1738. out[0] = 1;
  1739. out[1] = 1;
  1740. return out;
  1741. }
  1742. out[0] = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  1743. out[1] = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  1744. if (m[0] < 0) {
  1745. out[0] = -out[0];
  1746. }
  1747. if (m[3] < 0) {
  1748. out[1] = -out[1];
  1749. }
  1750. return out;
  1751. };
  1752. Transformable.prototype.transformCoordToLocal = function (x, y) {
  1753. var v2 = [x, y];
  1754. var invTransform = this.invTransform;
  1755. if (invTransform) {
  1756. applyTransform(v2, v2, invTransform);
  1757. }
  1758. return v2;
  1759. };
  1760. Transformable.prototype.transformCoordToGlobal = function (x, y) {
  1761. var v2 = [x, y];
  1762. var transform = this.transform;
  1763. if (transform) {
  1764. applyTransform(v2, v2, transform);
  1765. }
  1766. return v2;
  1767. };
  1768. Transformable.prototype.getLineScale = function () {
  1769. var m = this.transform;
  1770. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) : 1;
  1771. };
  1772. Transformable.getLocalTransform = function (target, m) {
  1773. m = m || [];
  1774. mIdentity(m);
  1775. var ox = target.originX || 0;
  1776. var oy = target.originY || 0;
  1777. var sx = target.scaleX;
  1778. var sy = target.scaleY;
  1779. var rotation = target.rotation || 0;
  1780. var x = target.x;
  1781. var y = target.y;
  1782. m[4] -= ox;
  1783. m[5] -= oy;
  1784. m[0] *= sx;
  1785. m[1] *= sy;
  1786. m[2] *= sx;
  1787. m[3] *= sy;
  1788. m[4] *= sx;
  1789. m[5] *= sy;
  1790. if (rotation) {
  1791. rotate(m, m, rotation);
  1792. }
  1793. m[4] += ox;
  1794. m[5] += oy;
  1795. m[4] += x;
  1796. m[5] += y;
  1797. return m;
  1798. };
  1799. Transformable.initDefaultProps = function () {
  1800. var proto = Transformable.prototype;
  1801. proto.x = 0;
  1802. proto.y = 0;
  1803. proto.scaleX = 1;
  1804. proto.scaleY = 1;
  1805. proto.originX = 0;
  1806. proto.originY = 0;
  1807. proto.rotation = 0;
  1808. proto.globalScaleRatio = 1;
  1809. }();
  1810. return Transformable;
  1811. }();
  1812. var easing = {
  1813. linear: function (k) {
  1814. return k;
  1815. },
  1816. quadraticIn: function (k) {
  1817. return k * k;
  1818. },
  1819. quadraticOut: function (k) {
  1820. return k * (2 - k);
  1821. },
  1822. quadraticInOut: function (k) {
  1823. if ((k *= 2) < 1) {
  1824. return 0.5 * k * k;
  1825. }
  1826. return -0.5 * (--k * (k - 2) - 1);
  1827. },
  1828. cubicIn: function (k) {
  1829. return k * k * k;
  1830. },
  1831. cubicOut: function (k) {
  1832. return --k * k * k + 1;
  1833. },
  1834. cubicInOut: function (k) {
  1835. if ((k *= 2) < 1) {
  1836. return 0.5 * k * k * k;
  1837. }
  1838. return 0.5 * ((k -= 2) * k * k + 2);
  1839. },
  1840. quarticIn: function (k) {
  1841. return k * k * k * k;
  1842. },
  1843. quarticOut: function (k) {
  1844. return 1 - --k * k * k * k;
  1845. },
  1846. quarticInOut: function (k) {
  1847. if ((k *= 2) < 1) {
  1848. return 0.5 * k * k * k * k;
  1849. }
  1850. return -0.5 * ((k -= 2) * k * k * k - 2);
  1851. },
  1852. quinticIn: function (k) {
  1853. return k * k * k * k * k;
  1854. },
  1855. quinticOut: function (k) {
  1856. return --k * k * k * k * k + 1;
  1857. },
  1858. quinticInOut: function (k) {
  1859. if ((k *= 2) < 1) {
  1860. return 0.5 * k * k * k * k * k;
  1861. }
  1862. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  1863. },
  1864. sinusoidalIn: function (k) {
  1865. return 1 - Math.cos(k * Math.PI / 2);
  1866. },
  1867. sinusoidalOut: function (k) {
  1868. return Math.sin(k * Math.PI / 2);
  1869. },
  1870. sinusoidalInOut: function (k) {
  1871. return 0.5 * (1 - Math.cos(Math.PI * k));
  1872. },
  1873. exponentialIn: function (k) {
  1874. return k === 0 ? 0 : Math.pow(1024, k - 1);
  1875. },
  1876. exponentialOut: function (k) {
  1877. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  1878. },
  1879. exponentialInOut: function (k) {
  1880. if (k === 0) {
  1881. return 0;
  1882. }
  1883. if (k === 1) {
  1884. return 1;
  1885. }
  1886. if ((k *= 2) < 1) {
  1887. return 0.5 * Math.pow(1024, k - 1);
  1888. }
  1889. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  1890. },
  1891. circularIn: function (k) {
  1892. return 1 - Math.sqrt(1 - k * k);
  1893. },
  1894. circularOut: function (k) {
  1895. return Math.sqrt(1 - --k * k);
  1896. },
  1897. circularInOut: function (k) {
  1898. if ((k *= 2) < 1) {
  1899. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  1900. }
  1901. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  1902. },
  1903. elasticIn: function (k) {
  1904. var s;
  1905. var a = 0.1;
  1906. var p = 0.4;
  1907. if (k === 0) {
  1908. return 0;
  1909. }
  1910. if (k === 1) {
  1911. return 1;
  1912. }
  1913. if (!a || a < 1) {
  1914. a = 1;
  1915. s = p / 4;
  1916. } else {
  1917. s = p * Math.asin(1 / a) / (2 * Math.PI);
  1918. }
  1919. return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  1920. },
  1921. elasticOut: function (k) {
  1922. var s;
  1923. var a = 0.1;
  1924. var p = 0.4;
  1925. if (k === 0) {
  1926. return 0;
  1927. }
  1928. if (k === 1) {
  1929. return 1;
  1930. }
  1931. if (!a || a < 1) {
  1932. a = 1;
  1933. s = p / 4;
  1934. } else {
  1935. s = p * Math.asin(1 / a) / (2 * Math.PI);
  1936. }
  1937. return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
  1938. },
  1939. elasticInOut: function (k) {
  1940. var s;
  1941. var a = 0.1;
  1942. var p = 0.4;
  1943. if (k === 0) {
  1944. return 0;
  1945. }
  1946. if (k === 1) {
  1947. return 1;
  1948. }
  1949. if (!a || a < 1) {
  1950. a = 1;
  1951. s = p / 4;
  1952. } else {
  1953. s = p * Math.asin(1 / a) / (2 * Math.PI);
  1954. }
  1955. if ((k *= 2) < 1) {
  1956. return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  1957. }
  1958. return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  1959. },
  1960. backIn: function (k) {
  1961. var s = 1.70158;
  1962. return k * k * ((s + 1) * k - s);
  1963. },
  1964. backOut: function (k) {
  1965. var s = 1.70158;
  1966. return --k * k * ((s + 1) * k + s) + 1;
  1967. },
  1968. backInOut: function (k) {
  1969. var s = 1.70158 * 1.525;
  1970. if ((k *= 2) < 1) {
  1971. return 0.5 * (k * k * ((s + 1) * k - s));
  1972. }
  1973. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  1974. },
  1975. bounceIn: function (k) {
  1976. return 1 - easing.bounceOut(1 - k);
  1977. },
  1978. bounceOut: function (k) {
  1979. if (k < 1 / 2.75) {
  1980. return 7.5625 * k * k;
  1981. } else if (k < 2 / 2.75) {
  1982. return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
  1983. } else if (k < 2.5 / 2.75) {
  1984. return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
  1985. } else {
  1986. return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
  1987. }
  1988. },
  1989. bounceInOut: function (k) {
  1990. if (k < 0.5) {
  1991. return easing.bounceIn(k * 2) * 0.5;
  1992. }
  1993. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  1994. }
  1995. };
  1996. var Clip = function () {
  1997. function Clip(opts) {
  1998. this._initialized = false;
  1999. this._startTime = 0;
  2000. this._pausedTime = 0;
  2001. this._paused = false;
  2002. this._life = opts.life || 1000;
  2003. this._delay = opts.delay || 0;
  2004. this.loop = opts.loop == null ? false : opts.loop;
  2005. this.gap = opts.gap || 0;
  2006. this.easing = opts.easing || 'linear';
  2007. this.onframe = opts.onframe;
  2008. this.ondestroy = opts.ondestroy;
  2009. this.onrestart = opts.onrestart;
  2010. }
  2011. Clip.prototype.step = function (globalTime, deltaTime) {
  2012. if (!this._initialized) {
  2013. this._startTime = globalTime + this._delay;
  2014. this._initialized = true;
  2015. }
  2016. if (this._paused) {
  2017. this._pausedTime += deltaTime;
  2018. return;
  2019. }
  2020. var percent = (globalTime - this._startTime - this._pausedTime) / this._life;
  2021. if (percent < 0) {
  2022. percent = 0;
  2023. }
  2024. percent = Math.min(percent, 1);
  2025. var easing$$1 = this.easing;
  2026. var easingFunc = typeof easing$$1 === 'string' ? easing[easing$$1] : easing$$1;
  2027. var schedule = typeof easingFunc === 'function' ? easingFunc(percent) : percent;
  2028. this.onframe && this.onframe(schedule);
  2029. if (percent === 1) {
  2030. if (this.loop) {
  2031. this._restart(globalTime);
  2032. this.onrestart && this.onrestart();
  2033. } else {
  2034. return true;
  2035. }
  2036. }
  2037. return false;
  2038. };
  2039. Clip.prototype._restart = function (globalTime) {
  2040. var remainder = (globalTime - this._startTime - this._pausedTime) % this._life;
  2041. this._startTime = globalTime - remainder + this.gap;
  2042. this._pausedTime = 0;
  2043. };
  2044. Clip.prototype.pause = function () {
  2045. this._paused = true;
  2046. };
  2047. Clip.prototype.resume = function () {
  2048. this._paused = false;
  2049. };
  2050. return Clip;
  2051. }();
  2052. var Entry = function () {
  2053. function Entry(val) {
  2054. this.value = val;
  2055. }
  2056. return Entry;
  2057. }();
  2058. var LinkedList = function () {
  2059. function LinkedList() {
  2060. this._len = 0;
  2061. }
  2062. LinkedList.prototype.insert = function (val) {
  2063. var entry = new Entry(val);
  2064. this.insertEntry(entry);
  2065. return entry;
  2066. };
  2067. LinkedList.prototype.insertEntry = function (entry) {
  2068. if (!this.head) {
  2069. this.head = this.tail = entry;
  2070. } else {
  2071. this.tail.next = entry;
  2072. entry.prev = this.tail;
  2073. entry.next = null;
  2074. this.tail = entry;
  2075. }
  2076. this._len++;
  2077. };
  2078. LinkedList.prototype.remove = function (entry) {
  2079. var prev = entry.prev;
  2080. var next = entry.next;
  2081. if (prev) {
  2082. prev.next = next;
  2083. } else {
  2084. this.head = next;
  2085. }
  2086. if (next) {
  2087. next.prev = prev;
  2088. } else {
  2089. this.tail = prev;
  2090. }
  2091. entry.next = entry.prev = null;
  2092. this._len--;
  2093. };
  2094. LinkedList.prototype.len = function () {
  2095. return this._len;
  2096. };
  2097. LinkedList.prototype.clear = function () {
  2098. this.head = this.tail = null;
  2099. this._len = 0;
  2100. };
  2101. return LinkedList;
  2102. }();
  2103. var LRU = function () {
  2104. function LRU(maxSize) {
  2105. this._list = new LinkedList();
  2106. this._maxSize = 10;
  2107. this._map = {};
  2108. this._maxSize = maxSize;
  2109. }
  2110. LRU.prototype.put = function (key, value) {
  2111. var list = this._list;
  2112. var map = this._map;
  2113. var removed = null;
  2114. if (map[key] == null) {
  2115. var len = list.len();
  2116. var entry = this._lastRemovedEntry;
  2117. if (len >= this._maxSize && len > 0) {
  2118. var leastUsedEntry = list.head;
  2119. list.remove(leastUsedEntry);
  2120. delete map[leastUsedEntry.key];
  2121. removed = leastUsedEntry.value;
  2122. this._lastRemovedEntry = leastUsedEntry;
  2123. }
  2124. if (entry) {
  2125. entry.value = value;
  2126. } else {
  2127. entry = new Entry(value);
  2128. }
  2129. entry.key = key;
  2130. list.insertEntry(entry);
  2131. map[key] = entry;
  2132. }
  2133. return removed;
  2134. };
  2135. LRU.prototype.get = function (key) {
  2136. var entry = this._map[key];
  2137. var list = this._list;
  2138. if (entry != null) {
  2139. if (entry !== list.tail) {
  2140. list.remove(entry);
  2141. list.insertEntry(entry);
  2142. }
  2143. return entry.value;
  2144. }
  2145. };
  2146. LRU.prototype.clear = function () {
  2147. this._list.clear();
  2148. this._map = {};
  2149. };
  2150. LRU.prototype.len = function () {
  2151. return this._list.len();
  2152. };
  2153. return LRU;
  2154. }();
  2155. var kCSSColorTable = {
  2156. 'transparent': [0, 0, 0, 0],
  2157. 'aliceblue': [240, 248, 255, 1],
  2158. 'antiquewhite': [250, 235, 215, 1],
  2159. 'aqua': [0, 255, 255, 1],
  2160. 'aquamarine': [127, 255, 212, 1],
  2161. 'azure': [240, 255, 255, 1],
  2162. 'beige': [245, 245, 220, 1],
  2163. 'bisque': [255, 228, 196, 1],
  2164. 'black': [0, 0, 0, 1],
  2165. 'blanchedalmond': [255, 235, 205, 1],
  2166. 'blue': [0, 0, 255, 1],
  2167. 'blueviolet': [138, 43, 226, 1],
  2168. 'brown': [165, 42, 42, 1],
  2169. 'burlywood': [222, 184, 135, 1],
  2170. 'cadetblue': [95, 158, 160, 1],
  2171. 'chartreuse': [127, 255, 0, 1],
  2172. 'chocolate': [210, 105, 30, 1],
  2173. 'coral': [255, 127, 80, 1],
  2174. 'cornflowerblue': [100, 149, 237, 1],
  2175. 'cornsilk': [255, 248, 220, 1],
  2176. 'crimson': [220, 20, 60, 1],
  2177. 'cyan': [0, 255, 255, 1],
  2178. 'darkblue': [0, 0, 139, 1],
  2179. 'darkcyan': [0, 139, 139, 1],
  2180. 'darkgoldenrod': [184, 134, 11, 1],
  2181. 'darkgray': [169, 169, 169, 1],
  2182. 'darkgreen': [0, 100, 0, 1],
  2183. 'darkgrey': [169, 169, 169, 1],
  2184. 'darkkhaki': [189, 183, 107, 1],
  2185. 'darkmagenta': [139, 0, 139, 1],
  2186. 'darkolivegreen': [85, 107, 47, 1],
  2187. 'darkorange': [255, 140, 0, 1],
  2188. 'darkorchid': [153, 50, 204, 1],
  2189. 'darkred': [139, 0, 0, 1],
  2190. 'darksalmon': [233, 150, 122, 1],
  2191. 'darkseagreen': [143, 188, 143, 1],
  2192. 'darkslateblue': [72, 61, 139, 1],
  2193. 'darkslategray': [47, 79, 79, 1],
  2194. 'darkslategrey': [47, 79, 79, 1],
  2195. 'darkturquoise': [0, 206, 209, 1],
  2196. 'darkviolet': [148, 0, 211, 1],
  2197. 'deeppink': [255, 20, 147, 1],
  2198. 'deepskyblue': [0, 191, 255, 1],
  2199. 'dimgray': [105, 105, 105, 1],
  2200. 'dimgrey': [105, 105, 105, 1],
  2201. 'dodgerblue': [30, 144, 255, 1],
  2202. 'firebrick': [178, 34, 34, 1],
  2203. 'floralwhite': [255, 250, 240, 1],
  2204. 'forestgreen': [34, 139, 34, 1],
  2205. 'fuchsia': [255, 0, 255, 1],
  2206. 'gainsboro': [220, 220, 220, 1],
  2207. 'ghostwhite': [248, 248, 255, 1],
  2208. 'gold': [255, 215, 0, 1],
  2209. 'goldenrod': [218, 165, 32, 1],
  2210. 'gray': [128, 128, 128, 1],
  2211. 'green': [0, 128, 0, 1],
  2212. 'greenyellow': [173, 255, 47, 1],
  2213. 'grey': [128, 128, 128, 1],
  2214. 'honeydew': [240, 255, 240, 1],
  2215. 'hotpink': [255, 105, 180, 1],
  2216. 'indianred': [205, 92, 92, 1],
  2217. 'indigo': [75, 0, 130, 1],
  2218. 'ivory': [255, 255, 240, 1],
  2219. 'khaki': [240, 230, 140, 1],
  2220. 'lavender': [230, 230, 250, 1],
  2221. 'lavenderblush': [255, 240, 245, 1],
  2222. 'lawngreen': [124, 252, 0, 1],
  2223. 'lemonchiffon': [255, 250, 205, 1],
  2224. 'lightblue': [173, 216, 230, 1],
  2225. 'lightcoral': [240, 128, 128, 1],
  2226. 'lightcyan': [224, 255, 255, 1],
  2227. 'lightgoldenrodyellow': [250, 250, 210, 1],
  2228. 'lightgray': [211, 211, 211, 1],
  2229. 'lightgreen': [144, 238, 144, 1],
  2230. 'lightgrey': [211, 211, 211, 1],
  2231. 'lightpink': [255, 182, 193, 1],
  2232. 'lightsalmon': [255, 160, 122, 1],
  2233. 'lightseagreen': [32, 178, 170, 1],
  2234. 'lightskyblue': [135, 206, 250, 1],
  2235. 'lightslategray': [119, 136, 153, 1],
  2236. 'lightslategrey': [119, 136, 153, 1],
  2237. 'lightsteelblue': [176, 196, 222, 1],
  2238. 'lightyellow': [255, 255, 224, 1],
  2239. 'lime': [0, 255, 0, 1],
  2240. 'limegreen': [50, 205, 50, 1],
  2241. 'linen': [250, 240, 230, 1],
  2242. 'magenta': [255, 0, 255, 1],
  2243. 'maroon': [128, 0, 0, 1],
  2244. 'mediumaquamarine': [102, 205, 170, 1],
  2245. 'mediumblue': [0, 0, 205, 1],
  2246. 'mediumorchid': [186, 85, 211, 1],
  2247. 'mediumpurple': [147, 112, 219, 1],
  2248. 'mediumseagreen': [60, 179, 113, 1],
  2249. 'mediumslateblue': [123, 104, 238, 1],
  2250. 'mediumspringgreen': [0, 250, 154, 1],
  2251. 'mediumturquoise': [72, 209, 204, 1],
  2252. 'mediumvioletred': [199, 21, 133, 1],
  2253. 'midnightblue': [25, 25, 112, 1],
  2254. 'mintcream': [245, 255, 250, 1],
  2255. 'mistyrose': [255, 228, 225, 1],
  2256. 'moccasin': [255, 228, 181, 1],
  2257. 'navajowhite': [255, 222, 173, 1],
  2258. 'navy': [0, 0, 128, 1],
  2259. 'oldlace': [253, 245, 230, 1],
  2260. 'olive': [128, 128, 0, 1],
  2261. 'olivedrab': [107, 142, 35, 1],
  2262. 'orange': [255, 165, 0, 1],
  2263. 'orangered': [255, 69, 0, 1],
  2264. 'orchid': [218, 112, 214, 1],
  2265. 'palegoldenrod': [238, 232, 170, 1],
  2266. 'palegreen': [152, 251, 152, 1],
  2267. 'paleturquoise': [175, 238, 238, 1],
  2268. 'palevioletred': [219, 112, 147, 1],
  2269. 'papayawhip': [255, 239, 213, 1],
  2270. 'peachpuff': [255, 218, 185, 1],
  2271. 'peru': [205, 133, 63, 1],
  2272. 'pink': [255, 192, 203, 1],
  2273. 'plum': [221, 160, 221, 1],
  2274. 'powderblue': [176, 224, 230, 1],
  2275. 'purple': [128, 0, 128, 1],
  2276. 'red': [255, 0, 0, 1],
  2277. 'rosybrown': [188, 143, 143, 1],
  2278. 'royalblue': [65, 105, 225, 1],
  2279. 'saddlebrown': [139, 69, 19, 1],
  2280. 'salmon': [250, 128, 114, 1],
  2281. 'sandybrown': [244, 164, 96, 1],
  2282. 'seagreen': [46, 139, 87, 1],
  2283. 'seashell': [255, 245, 238, 1],
  2284. 'sienna': [160, 82, 45, 1],
  2285. 'silver': [192, 192, 192, 1],
  2286. 'skyblue': [135, 206, 235, 1],
  2287. 'slateblue': [106, 90, 205, 1],
  2288. 'slategray': [112, 128, 144, 1],
  2289. 'slategrey': [112, 128, 144, 1],
  2290. 'snow': [255, 250, 250, 1],
  2291. 'springgreen': [0, 255, 127, 1],
  2292. 'steelblue': [70, 130, 180, 1],
  2293. 'tan': [210, 180, 140, 1],
  2294. 'teal': [0, 128, 128, 1],
  2295. 'thistle': [216, 191, 216, 1],
  2296. 'tomato': [255, 99, 71, 1],
  2297. 'turquoise': [64, 224, 208, 1],
  2298. 'violet': [238, 130, 238, 1],
  2299. 'wheat': [245, 222, 179, 1],
  2300. 'white': [255, 255, 255, 1],
  2301. 'whitesmoke': [245, 245, 245, 1],
  2302. 'yellow': [255, 255, 0, 1],
  2303. 'yellowgreen': [154, 205, 50, 1]
  2304. };
  2305. function clampCssByte(i) {
  2306. i = Math.round(i);
  2307. return i < 0 ? 0 : i > 255 ? 255 : i;
  2308. }
  2309. function clampCssAngle(i) {
  2310. i = Math.round(i);
  2311. return i < 0 ? 0 : i > 360 ? 360 : i;
  2312. }
  2313. function clampCssFloat(f) {
  2314. return f < 0 ? 0 : f > 1 ? 1 : f;
  2315. }
  2316. function parseCssInt(val) {
  2317. var str = val;
  2318. if (str.length && str.charAt(str.length - 1) === '%') {
  2319. return clampCssByte(parseFloat(str) / 100 * 255);
  2320. }
  2321. return clampCssByte(parseInt(str, 10));
  2322. }
  2323. function parseCssFloat(val) {
  2324. var str = val;
  2325. if (str.length && str.charAt(str.length - 1) === '%') {
  2326. return clampCssFloat(parseFloat(str) / 100);
  2327. }
  2328. return clampCssFloat(parseFloat(str));
  2329. }
  2330. function cssHueToRgb(m1, m2, h) {
  2331. if (h < 0) {
  2332. h += 1;
  2333. } else if (h > 1) {
  2334. h -= 1;
  2335. }
  2336. if (h * 6 < 1) {
  2337. return m1 + (m2 - m1) * h * 6;
  2338. }
  2339. if (h * 2 < 1) {
  2340. return m2;
  2341. }
  2342. if (h * 3 < 2) {
  2343. return m1 + (m2 - m1) * (2 / 3 - h) * 6;
  2344. }
  2345. return m1;
  2346. }
  2347. function lerpNumber(a, b, p) {
  2348. return a + (b - a) * p;
  2349. }
  2350. function setRgba(out, r, g, b, a) {
  2351. out[0] = r;
  2352. out[1] = g;
  2353. out[2] = b;
  2354. out[3] = a;
  2355. return out;
  2356. }
  2357. function copyRgba(out, a) {
  2358. out[0] = a[0];
  2359. out[1] = a[1];
  2360. out[2] = a[2];
  2361. out[3] = a[3];
  2362. return out;
  2363. }
  2364. var colorCache = new LRU(20);
  2365. var lastRemovedArr = null;
  2366. function putToCache(colorStr, rgbaArr) {
  2367. if (lastRemovedArr) {
  2368. copyRgba(lastRemovedArr, rgbaArr);
  2369. }
  2370. lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || rgbaArr.slice());
  2371. }
  2372. function parse(colorStr, rgbaArr) {
  2373. if (!colorStr) {
  2374. return;
  2375. }
  2376. rgbaArr = rgbaArr || [];
  2377. var cached = colorCache.get(colorStr);
  2378. if (cached) {
  2379. return copyRgba(rgbaArr, cached);
  2380. }
  2381. colorStr = colorStr + '';
  2382. var str = colorStr.replace(/ /g, '').toLowerCase();
  2383. if (str in kCSSColorTable) {
  2384. copyRgba(rgbaArr, kCSSColorTable[str]);
  2385. putToCache(colorStr, rgbaArr);
  2386. return rgbaArr;
  2387. }
  2388. var strLen = str.length;
  2389. if (str.charAt(0) === '#') {
  2390. if (strLen === 4 || strLen === 5) {
  2391. var iv = parseInt(str.slice(1, 4), 16);
  2392. if (!(iv >= 0 && iv <= 0xfff)) {
  2393. setRgba(rgbaArr, 0, 0, 0, 1);
  2394. return;
  2395. }
  2396. setRgba(rgbaArr, (iv & 0xf00) >> 4 | (iv & 0xf00) >> 8, iv & 0xf0 | (iv & 0xf0) >> 4, iv & 0xf | (iv & 0xf) << 4, strLen === 5 ? parseInt(str.slice(4), 16) / 0xf : 1);
  2397. putToCache(colorStr, rgbaArr);
  2398. return rgbaArr;
  2399. } else if (strLen === 7 || strLen === 9) {
  2400. var iv = parseInt(str.slice(1, 7), 16);
  2401. if (!(iv >= 0 && iv <= 0xffffff)) {
  2402. setRgba(rgbaArr, 0, 0, 0, 1);
  2403. return;
  2404. }
  2405. setRgba(rgbaArr, (iv & 0xff0000) >> 16, (iv & 0xff00) >> 8, iv & 0xff, strLen === 9 ? parseInt(str.slice(7), 16) / 0xff : 1);
  2406. putToCache(colorStr, rgbaArr);
  2407. return rgbaArr;
  2408. }
  2409. return;
  2410. }
  2411. var op = str.indexOf('(');
  2412. var ep = str.indexOf(')');
  2413. if (op !== -1 && ep + 1 === strLen) {
  2414. var fname = str.substr(0, op);
  2415. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  2416. var alpha = 1;
  2417. switch (fname) {
  2418. case 'rgba':
  2419. if (params.length !== 4) {
  2420. return params.length === 3 ? setRgba(rgbaArr, +params[0], +params[1], +params[2], 1) : setRgba(rgbaArr, 0, 0, 0, 1);
  2421. }
  2422. alpha = parseCssFloat(params.pop());
  2423. case 'rgb':
  2424. if (params.length !== 3) {
  2425. setRgba(rgbaArr, 0, 0, 0, 1);
  2426. return;
  2427. }
  2428. setRgba(rgbaArr, parseCssInt(params[0]), parseCssInt(params[1]), parseCssInt(params[2]), alpha);
  2429. putToCache(colorStr, rgbaArr);
  2430. return rgbaArr;
  2431. case 'hsla':
  2432. if (params.length !== 4) {
  2433. setRgba(rgbaArr, 0, 0, 0, 1);
  2434. return;
  2435. }
  2436. params[3] = parseCssFloat(params[3]);
  2437. hsla2rgba(params, rgbaArr);
  2438. putToCache(colorStr, rgbaArr);
  2439. return rgbaArr;
  2440. case 'hsl':
  2441. if (params.length !== 3) {
  2442. setRgba(rgbaArr, 0, 0, 0, 1);
  2443. return;
  2444. }
  2445. hsla2rgba(params, rgbaArr);
  2446. putToCache(colorStr, rgbaArr);
  2447. return rgbaArr;
  2448. default:
  2449. return;
  2450. }
  2451. }
  2452. setRgba(rgbaArr, 0, 0, 0, 1);
  2453. return;
  2454. }
  2455. function hsla2rgba(hsla, rgba) {
  2456. var h = (parseFloat(hsla[0]) % 360 + 360) % 360 / 360;
  2457. var s = parseCssFloat(hsla[1]);
  2458. var l = parseCssFloat(hsla[2]);
  2459. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  2460. var m1 = l * 2 - m2;
  2461. rgba = rgba || [];
  2462. setRgba(rgba, clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), clampCssByte(cssHueToRgb(m1, m2, h) * 255), clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255), 1);
  2463. if (hsla.length === 4) {
  2464. rgba[3] = hsla[3];
  2465. }
  2466. return rgba;
  2467. }
  2468. function rgba2hsla(rgba) {
  2469. if (!rgba) {
  2470. return;
  2471. }
  2472. var R = rgba[0] / 255;
  2473. var G = rgba[1] / 255;
  2474. var B = rgba[2] / 255;
  2475. var vMin = Math.min(R, G, B);
  2476. var vMax = Math.max(R, G, B);
  2477. var delta = vMax - vMin;
  2478. var L = (vMax + vMin) / 2;
  2479. var H;
  2480. var S;
  2481. if (delta === 0) {
  2482. H = 0;
  2483. S = 0;
  2484. } else {
  2485. if (L < 0.5) {
  2486. S = delta / (vMax + vMin);
  2487. } else {
  2488. S = delta / (2 - vMax - vMin);
  2489. }
  2490. var deltaR = ((vMax - R) / 6 + delta / 2) / delta;
  2491. var deltaG = ((vMax - G) / 6 + delta / 2) / delta;
  2492. var deltaB = ((vMax - B) / 6 + delta / 2) / delta;
  2493. if (R === vMax) {
  2494. H = deltaB - deltaG;
  2495. } else if (G === vMax) {
  2496. H = 1 / 3 + deltaR - deltaB;
  2497. } else if (B === vMax) {
  2498. H = 2 / 3 + deltaG - deltaR;
  2499. }
  2500. if (H < 0) {
  2501. H += 1;
  2502. }
  2503. if (H > 1) {
  2504. H -= 1;
  2505. }
  2506. }
  2507. var hsla = [H * 360, S, L];
  2508. if (rgba[3] != null) {
  2509. hsla.push(rgba[3]);
  2510. }
  2511. return hsla;
  2512. }
  2513. function lift(color, level) {
  2514. var colorArr = parse(color);
  2515. if (colorArr) {
  2516. for (var i = 0; i < 3; i++) {
  2517. if (level < 0) {
  2518. colorArr[i] = colorArr[i] * (1 - level) | 0;
  2519. } else {
  2520. colorArr[i] = (255 - colorArr[i]) * level + colorArr[i] | 0;
  2521. }
  2522. if (colorArr[i] > 255) {
  2523. colorArr[i] = 255;
  2524. } else if (colorArr[i] < 0) {
  2525. colorArr[i] = 0;
  2526. }
  2527. }
  2528. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  2529. }
  2530. }
  2531. function toHex(color) {
  2532. var colorArr = parse(color);
  2533. if (colorArr) {
  2534. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + +colorArr[2]).toString(16).slice(1);
  2535. }
  2536. }
  2537. function fastLerp(normalizedValue, colors, out) {
  2538. if (!(colors && colors.length) || !(normalizedValue >= 0 && normalizedValue <= 1)) {
  2539. return;
  2540. }
  2541. out = out || [];
  2542. var value = normalizedValue * (colors.length - 1);
  2543. var leftIndex = Math.floor(value);
  2544. var rightIndex = Math.ceil(value);
  2545. var leftColor = colors[leftIndex];
  2546. var rightColor = colors[rightIndex];
  2547. var dv = value - leftIndex;
  2548. out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
  2549. out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
  2550. out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
  2551. out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
  2552. return out;
  2553. }
  2554. var fastMapToColor = fastLerp;
  2555. function lerp$1(normalizedValue, colors, fullOutput) {
  2556. if (!(colors && colors.length) || !(normalizedValue >= 0 && normalizedValue <= 1)) {
  2557. return;
  2558. }
  2559. var value = normalizedValue * (colors.length - 1);
  2560. var leftIndex = Math.floor(value);
  2561. var rightIndex = Math.ceil(value);
  2562. var leftColor = parse(colors[leftIndex]);
  2563. var rightColor = parse(colors[rightIndex]);
  2564. var dv = value - leftIndex;
  2565. var color = stringify([clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)), clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)), clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)), clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))], 'rgba');
  2566. return fullOutput ? {
  2567. color: color,
  2568. leftIndex: leftIndex,
  2569. rightIndex: rightIndex,
  2570. value: value
  2571. } : color;
  2572. }
  2573. var mapToColor = lerp$1;
  2574. function modifyHSL(color, h, s, l) {
  2575. var colorArr = parse(color);
  2576. if (color) {
  2577. colorArr = rgba2hsla(colorArr);
  2578. h != null && (colorArr[0] = clampCssAngle(h));
  2579. s != null && (colorArr[1] = parseCssFloat(s));
  2580. l != null && (colorArr[2] = parseCssFloat(l));
  2581. return stringify(hsla2rgba(colorArr), 'rgba');
  2582. }
  2583. }
  2584. function modifyAlpha(color, alpha) {
  2585. var colorArr = parse(color);
  2586. if (colorArr && alpha != null) {
  2587. colorArr[3] = clampCssFloat(alpha);
  2588. return stringify(colorArr, 'rgba');
  2589. }
  2590. }
  2591. function stringify(arrColor, type) {
  2592. if (!arrColor || !arrColor.length) {
  2593. return;
  2594. }
  2595. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
  2596. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  2597. colorStr += ',' + arrColor[3];
  2598. }
  2599. return type + '(' + colorStr + ')';
  2600. }
  2601. function lum(color, backgroundLum) {
  2602. var arr = parse(color);
  2603. return arr ? (0.299 * arr[0] + 0.587 * arr[1] + 0.114 * arr[2]) * arr[3] / 255 + (1 - arr[3]) * backgroundLum : 0;
  2604. }
  2605. function random() {
  2606. var r = Math.round(Math.random() * 255);
  2607. var g = Math.round(Math.random() * 255);
  2608. var b = Math.round(Math.random() * 255);
  2609. return 'rgb(' + r + ',' + g + ',' + b + ')';
  2610. }
  2611. var color = (Object.freeze || Object)({
  2612. parse: parse,
  2613. lift: lift,
  2614. toHex: toHex,
  2615. fastLerp: fastLerp,
  2616. fastMapToColor: fastMapToColor,
  2617. lerp: lerp$1,
  2618. mapToColor: mapToColor,
  2619. modifyHSL: modifyHSL,
  2620. modifyAlpha: modifyAlpha,
  2621. stringify: stringify,
  2622. lum: lum,
  2623. random: random
  2624. });
  2625. var arraySlice = Array.prototype.slice;
  2626. function interpolateNumber(p0, p1, percent) {
  2627. return (p1 - p0) * percent + p0;
  2628. }
  2629. function step(p0, p1, percent) {
  2630. return percent > 0.5 ? p1 : p0;
  2631. }
  2632. function interpolate1DArray(out, p0, p1, percent) {
  2633. var len = p0.length;
  2634. for (var i = 0; i < len; i++) {
  2635. out[i] = interpolateNumber(p0[i], p1[i], percent);
  2636. }
  2637. }
  2638. function interpolate2DArray(out, p0, p1, percent) {
  2639. var len = p0.length;
  2640. var len2 = len && p0[0].length;
  2641. for (var i = 0; i < len; i++) {
  2642. if (!out[i]) {
  2643. out[i] = [];
  2644. }
  2645. for (var j = 0; j < len2; j++) {
  2646. out[i][j] = interpolateNumber(p0[i][j], p1[i][j], percent);
  2647. }
  2648. }
  2649. }
  2650. function add1DArray(out, p0, p1, sign) {
  2651. var len = p0.length;
  2652. for (var i = 0; i < len; i++) {
  2653. out[i] = p0[i] + p1[i] * sign;
  2654. }
  2655. return out;
  2656. }
  2657. function add2DArray(out, p0, p1, sign) {
  2658. var len = p0.length;
  2659. var len2 = len && p0[0].length;
  2660. for (var i = 0; i < len; i++) {
  2661. if (!out[i]) {
  2662. out[i] = [];
  2663. }
  2664. for (var j = 0; j < len2; j++) {
  2665. out[i][j] = p0[i][j] + p1[i][j] * sign;
  2666. }
  2667. }
  2668. return out;
  2669. }
  2670. function fillArray(val0, val1, arrDim) {
  2671. var arr0 = val0;
  2672. var arr1 = val1;
  2673. if (!arr0.push || !arr1.push) {
  2674. return;
  2675. }
  2676. var arr0Len = arr0.length;
  2677. var arr1Len = arr1.length;
  2678. if (arr0Len !== arr1Len) {
  2679. var isPreviousLarger = arr0Len > arr1Len;
  2680. if (isPreviousLarger) {
  2681. arr0.length = arr1Len;
  2682. } else {
  2683. for (var i = arr0Len; i < arr1Len; i++) {
  2684. arr0.push(arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]));
  2685. }
  2686. }
  2687. }
  2688. var len2 = arr0[0] && arr0[0].length;
  2689. for (var i = 0; i < arr0.length; i++) {
  2690. if (arrDim === 1) {
  2691. if (isNaN(arr0[i])) {
  2692. arr0[i] = arr1[i];
  2693. }
  2694. } else {
  2695. for (var j = 0; j < len2; j++) {
  2696. if (isNaN(arr0[i][j])) {
  2697. arr0[i][j] = arr1[i][j];
  2698. }
  2699. }
  2700. }
  2701. }
  2702. }
  2703. function is1DArraySame(arr0, arr1) {
  2704. var len = arr0.length;
  2705. if (len !== arr1.length) {
  2706. return false;
  2707. }
  2708. for (var i = 0; i < len; i++) {
  2709. if (arr0[i] !== arr1[i]) {
  2710. return false;
  2711. }
  2712. }
  2713. return true;
  2714. }
  2715. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  2716. var v0 = (p2 - p0) * 0.5;
  2717. var v1 = (p3 - p1) * 0.5;
  2718. return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
  2719. }
  2720. function catmullRomInterpolate1DArray(out, p0, p1, p2, p3, t, t2, t3) {
  2721. var len = p0.length;
  2722. for (var i = 0; i < len; i++) {
  2723. out[i] = catmullRomInterpolate(p0[i], p1[i], p2[i], p3[i], t, t2, t3);
  2724. }
  2725. }
  2726. function catmullRomInterpolate2DArray(out, p0, p1, p2, p3, t, t2, t3) {
  2727. var len = p0.length;
  2728. var len2 = p0[0].length;
  2729. for (var i = 0; i < len; i++) {
  2730. if (!out[i]) {
  2731. out[1] = [];
  2732. }
  2733. for (var j = 0; j < len2; j++) {
  2734. out[i][j] = catmullRomInterpolate(p0[i][j], p1[i][j], p2[i][j], p3[i][j], t, t2, t3);
  2735. }
  2736. }
  2737. }
  2738. function cloneValue(value) {
  2739. if (isArrayLike(value)) {
  2740. var len = value.length;
  2741. if (isArrayLike(value[0])) {
  2742. var ret = [];
  2743. for (var i = 0; i < len; i++) {
  2744. ret.push(arraySlice.call(value[i]));
  2745. }
  2746. return ret;
  2747. }
  2748. return arraySlice.call(value);
  2749. }
  2750. return value;
  2751. }
  2752. function rgba2String(rgba) {
  2753. rgba[0] = Math.floor(rgba[0]);
  2754. rgba[1] = Math.floor(rgba[1]);
  2755. rgba[2] = Math.floor(rgba[2]);
  2756. return 'rgba(' + rgba.join(',') + ')';
  2757. }
  2758. function guessArrayDim(value) {
  2759. return isArrayLike(value && value[0]) ? 2 : 1;
  2760. }
  2761. var tmpRgba = [0, 0, 0, 0];
  2762. var Track = function () {
  2763. function Track(propName) {
  2764. this.keyframes = [];
  2765. this.maxTime = 0;
  2766. this.arrDim = 0;
  2767. this.interpolable = true;
  2768. this._needsSort = false;
  2769. this._isAllValueEqual = true;
  2770. this._lastFrame = 0;
  2771. this._lastFramePercent = 0;
  2772. this.propName = propName;
  2773. }
  2774. Track.prototype.isFinished = function () {
  2775. return this._finished;
  2776. };
  2777. Track.prototype.setFinished = function () {
  2778. this._finished = true;
  2779. if (this._additiveTrack) {
  2780. this._additiveTrack.setFinished();
  2781. }
  2782. };
  2783. Track.prototype.needsAnimate = function () {
  2784. return !this._isAllValueEqual && this.keyframes.length >= 2 && this.interpolable;
  2785. };
  2786. Track.prototype.getAdditiveTrack = function () {
  2787. return this._additiveTrack;
  2788. };
  2789. Track.prototype.addKeyframe = function (time, value) {
  2790. if (time >= this.maxTime) {
  2791. this.maxTime = time;
  2792. } else {
  2793. this._needsSort = true;
  2794. }
  2795. var keyframes = this.keyframes;
  2796. var len = keyframes.length;
  2797. if (this.interpolable) {
  2798. if (isArrayLike(value)) {
  2799. var arrayDim = guessArrayDim(value);
  2800. if (len > 0 && this.arrDim !== arrayDim) {
  2801. this.interpolable = false;
  2802. return;
  2803. }
  2804. if (arrayDim === 1 && typeof value[0] !== 'number' || arrayDim === 2 && typeof value[0][0] !== 'number') {
  2805. this.interpolable = false;
  2806. return;
  2807. }
  2808. if (len > 0) {
  2809. var lastFrame = keyframes[len - 1];
  2810. if (this._isAllValueEqual) {
  2811. if (arrayDim === 1) {
  2812. if (!is1DArraySame(value, lastFrame.value)) {
  2813. this._isAllValueEqual = false;
  2814. }
  2815. } else {
  2816. this._isAllValueEqual = false;
  2817. }
  2818. }
  2819. }
  2820. this.arrDim = arrayDim;
  2821. } else {
  2822. if (this.arrDim > 0) {
  2823. this.interpolable = false;
  2824. return;
  2825. }
  2826. if (typeof value === 'string') {
  2827. var colorArray = parse(value);
  2828. if (colorArray) {
  2829. value = colorArray;
  2830. this.isValueColor = true;
  2831. } else {
  2832. this.interpolable = false;
  2833. }
  2834. } else if (typeof value !== 'number' || isNaN(value)) {
  2835. this.interpolable = false;
  2836. return;
  2837. }
  2838. if (this._isAllValueEqual && len > 0) {
  2839. var lastFrame = keyframes[len - 1];
  2840. if (this.isValueColor && !is1DArraySame(lastFrame.value, value)) {
  2841. this._isAllValueEqual = false;
  2842. } else if (lastFrame.value !== value) {
  2843. this._isAllValueEqual = false;
  2844. }
  2845. }
  2846. }
  2847. }
  2848. var kf = {
  2849. time: time,
  2850. value: value,
  2851. percent: 0
  2852. };
  2853. this.keyframes.push(kf);
  2854. return kf;
  2855. };
  2856. Track.prototype.prepare = function (additiveTrack) {
  2857. var kfs = this.keyframes;
  2858. if (this._needsSort) {
  2859. kfs.sort(function (a, b) {
  2860. return a.time - b.time;
  2861. });
  2862. }
  2863. var arrDim = this.arrDim;
  2864. var kfsLen = kfs.length;
  2865. var lastKf = kfs[kfsLen - 1];
  2866. for (var i = 0; i < kfsLen; i++) {
  2867. kfs[i].percent = kfs[i].time / this.maxTime;
  2868. if (arrDim > 0 && i !== kfsLen - 1) {
  2869. fillArray(kfs[i].value, lastKf.value, arrDim);
  2870. }
  2871. }
  2872. if (additiveTrack && this.needsAnimate() && additiveTrack.needsAnimate() && arrDim === additiveTrack.arrDim && this.isValueColor === additiveTrack.isValueColor && !additiveTrack._finished) {
  2873. this._additiveTrack = additiveTrack;
  2874. var startValue = kfs[0].value;
  2875. for (var i = 0; i < kfsLen; i++) {
  2876. if (arrDim === 0) {
  2877. if (this.isValueColor) {
  2878. kfs[i].additiveValue = add1DArray([], kfs[i].value, startValue, -1);
  2879. } else {
  2880. kfs[i].additiveValue = kfs[i].value - startValue;
  2881. }
  2882. } else if (arrDim === 1) {
  2883. kfs[i].additiveValue = add1DArray([], kfs[i].value, startValue, -1);
  2884. } else if (arrDim === 2) {
  2885. kfs[i].additiveValue = add2DArray([], kfs[i].value, startValue, -1);
  2886. }
  2887. }
  2888. }
  2889. };
  2890. Track.prototype.step = function (target, percent) {
  2891. if (this._finished) {
  2892. return;
  2893. }
  2894. if (this._additiveTrack && this._additiveTrack._finished) {
  2895. this._additiveTrack = null;
  2896. }
  2897. var isAdditive = this._additiveTrack != null;
  2898. var valueKey = isAdditive ? 'additiveValue' : 'value';
  2899. var keyframes = this.keyframes;
  2900. var kfsNum = this.keyframes.length;
  2901. var propName = this.propName;
  2902. var arrDim = this.arrDim;
  2903. var isValueColor = this.isValueColor;
  2904. var frameIdx;
  2905. if (percent < 0) {
  2906. frameIdx = 0;
  2907. } else if (percent < this._lastFramePercent) {
  2908. var start = Math.min(this._lastFrame + 1, kfsNum - 1);
  2909. for (frameIdx = start; frameIdx >= 0; frameIdx--) {
  2910. if (keyframes[frameIdx].percent <= percent) {
  2911. break;
  2912. }
  2913. }
  2914. frameIdx = Math.min(frameIdx, kfsNum - 2);
  2915. } else {
  2916. for (frameIdx = this._lastFrame; frameIdx < kfsNum; frameIdx++) {
  2917. if (keyframes[frameIdx].percent > percent) {
  2918. break;
  2919. }
  2920. }
  2921. frameIdx = Math.min(frameIdx - 1, kfsNum - 2);
  2922. }
  2923. var nextFrame = keyframes[frameIdx + 1];
  2924. var frame = keyframes[frameIdx];
  2925. if (!(frame && nextFrame)) {
  2926. return;
  2927. }
  2928. this._lastFrame = frameIdx;
  2929. this._lastFramePercent = percent;
  2930. var range = nextFrame.percent - frame.percent;
  2931. if (range === 0) {
  2932. return;
  2933. }
  2934. var w = (percent - frame.percent) / range;
  2935. var targetArr = isAdditive ? this._additiveValue : isValueColor ? tmpRgba : target[propName];
  2936. if ((arrDim > 0 || isValueColor) && !targetArr) {
  2937. targetArr = this._additiveValue = [];
  2938. }
  2939. if (this.useSpline) {
  2940. var p1 = keyframes[frameIdx][valueKey];
  2941. var p0 = keyframes[frameIdx === 0 ? frameIdx : frameIdx - 1][valueKey];
  2942. var p2 = keyframes[frameIdx > kfsNum - 2 ? kfsNum - 1 : frameIdx + 1][valueKey];
  2943. var p3 = keyframes[frameIdx > kfsNum - 3 ? kfsNum - 1 : frameIdx + 2][valueKey];
  2944. if (arrDim > 0) {
  2945. arrDim === 1 ? catmullRomInterpolate1DArray(targetArr, p0, p1, p2, p3, w, w * w, w * w * w) : catmullRomInterpolate2DArray(targetArr, p0, p1, p2, p3, w, w * w, w * w * w);
  2946. } else if (isValueColor) {
  2947. catmullRomInterpolate1DArray(targetArr, p0, p1, p2, p3, w, w * w, w * w * w);
  2948. if (!isAdditive) {
  2949. target[propName] = rgba2String(targetArr);
  2950. }
  2951. } else {
  2952. var value = void 0;
  2953. if (!this.interpolable) {
  2954. value = p2;
  2955. } else {
  2956. value = catmullRomInterpolate(p0, p1, p2, p3, w, w * w, w * w * w);
  2957. }
  2958. if (isAdditive) {
  2959. this._additiveValue = value;
  2960. } else {
  2961. target[propName] = value;
  2962. }
  2963. }
  2964. } else {
  2965. if (arrDim > 0) {
  2966. arrDim === 1 ? interpolate1DArray(targetArr, frame[valueKey], nextFrame[valueKey], w) : interpolate2DArray(targetArr, frame[valueKey], nextFrame[valueKey], w);
  2967. } else if (isValueColor) {
  2968. interpolate1DArray(targetArr, frame[valueKey], nextFrame[valueKey], w);
  2969. if (!isAdditive) {
  2970. target[propName] = rgba2String(targetArr);
  2971. }
  2972. } else {
  2973. var value = void 0;
  2974. if (!this.interpolable) {
  2975. value = step(frame[valueKey], nextFrame[valueKey], w);
  2976. } else {
  2977. value = interpolateNumber(frame[valueKey], nextFrame[valueKey], w);
  2978. }
  2979. if (isAdditive) {
  2980. this._additiveValue = value;
  2981. } else {
  2982. target[propName] = value;
  2983. }
  2984. }
  2985. }
  2986. if (isAdditive) {
  2987. this._addToTarget(target);
  2988. }
  2989. };
  2990. Track.prototype._addToTarget = function (target) {
  2991. var arrDim = this.arrDim;
  2992. var propName = this.propName;
  2993. var additiveValue = this._additiveValue;
  2994. if (arrDim === 0) {
  2995. if (this.isValueColor) {
  2996. parse(target[propName], tmpRgba);
  2997. add1DArray(tmpRgba, tmpRgba, additiveValue, 1);
  2998. target[propName] = rgba2String(tmpRgba);
  2999. } else {
  3000. target[propName] = target[propName] + additiveValue;
  3001. }
  3002. } else if (arrDim === 1) {
  3003. add1DArray(target[propName], target[propName], additiveValue, 1);
  3004. } else if (arrDim === 2) {
  3005. add2DArray(target[propName], target[propName], additiveValue, 1);
  3006. }
  3007. };
  3008. return Track;
  3009. }();
  3010. var Animator = function () {
  3011. function Animator(target, loop, additiveTo) {
  3012. this._tracks = {};
  3013. this._trackKeys = [];
  3014. this._delay = 0;
  3015. this._maxTime = 0;
  3016. this._paused = false;
  3017. this._started = 0;
  3018. this._clip = null;
  3019. this._target = target;
  3020. this._loop = loop;
  3021. if (loop && additiveTo) {
  3022. logError('Can\' use additive animation on looped animation.');
  3023. return;
  3024. }
  3025. this._additiveAnimators = additiveTo;
  3026. }
  3027. Animator.prototype.getTarget = function () {
  3028. return this._target;
  3029. };
  3030. Animator.prototype.changeTarget = function (target) {
  3031. this._target = target;
  3032. };
  3033. Animator.prototype.when = function (time, props) {
  3034. return this.whenWithKeys(time, props, keys(props));
  3035. };
  3036. Animator.prototype.whenWithKeys = function (time, props, propNames) {
  3037. var tracks = this._tracks;
  3038. for (var i = 0; i < propNames.length; i++) {
  3039. var propName = propNames[i];
  3040. var track = tracks[propName];
  3041. if (!track) {
  3042. track = tracks[propName] = new Track(propName);
  3043. var initialValue = void 0;
  3044. var additiveTrack = this._getAdditiveTrack(propName);
  3045. if (additiveTrack) {
  3046. var lastFinalKf = additiveTrack.keyframes[additiveTrack.keyframes.length - 1];
  3047. initialValue = lastFinalKf && lastFinalKf.value;
  3048. if (additiveTrack.isValueColor && initialValue) {
  3049. initialValue = rgba2String(initialValue);
  3050. }
  3051. } else {
  3052. initialValue = this._target[propName];
  3053. }
  3054. if (initialValue == null) {
  3055. continue;
  3056. }
  3057. if (time !== 0) {
  3058. track.addKeyframe(0, cloneValue(initialValue));
  3059. }
  3060. this._trackKeys.push(propName);
  3061. }
  3062. track.addKeyframe(time, cloneValue(props[propName]));
  3063. }
  3064. this._maxTime = Math.max(this._maxTime, time);
  3065. return this;
  3066. };
  3067. Animator.prototype.pause = function () {
  3068. this._clip.pause();
  3069. this._paused = true;
  3070. };
  3071. Animator.prototype.resume = function () {
  3072. this._clip.resume();
  3073. this._paused = false;
  3074. };
  3075. Animator.prototype.isPaused = function () {
  3076. return !!this._paused;
  3077. };
  3078. Animator.prototype._doneCallback = function () {
  3079. this._setTracksFinished();
  3080. this._clip = null;
  3081. var doneList = this._doneList;
  3082. if (doneList) {
  3083. var len = doneList.length;
  3084. for (var i = 0; i < len; i++) {
  3085. doneList[i].call(this);
  3086. }
  3087. }
  3088. };
  3089. Animator.prototype._abortedCallback = function () {
  3090. this._setTracksFinished();
  3091. var animation = this.animation;
  3092. var abortedList = this._abortedList;
  3093. if (animation) {
  3094. animation.removeClip(this._clip);
  3095. }
  3096. this._clip = null;
  3097. if (abortedList) {
  3098. for (var i = 0; i < abortedList.length; i++) {
  3099. abortedList[i].call(this);
  3100. }
  3101. }
  3102. };
  3103. Animator.prototype._setTracksFinished = function () {
  3104. var tracks = this._tracks;
  3105. var tracksKeys = this._trackKeys;
  3106. for (var i = 0; i < tracksKeys.length; i++) {
  3107. tracks[tracksKeys[i]].setFinished();
  3108. }
  3109. };
  3110. Animator.prototype._getAdditiveTrack = function (trackName) {
  3111. var additiveTrack;
  3112. var additiveAnimators = this._additiveAnimators;
  3113. if (additiveAnimators) {
  3114. for (var i = 0; i < additiveAnimators.length; i++) {
  3115. var track = additiveAnimators[i].getTrack(trackName);
  3116. if (track) {
  3117. additiveTrack = track;
  3118. }
  3119. }
  3120. }
  3121. return additiveTrack;
  3122. };
  3123. Animator.prototype.start = function (easing, forceAnimate) {
  3124. if (this._started > 0) {
  3125. return;
  3126. }
  3127. this._started = 1;
  3128. var self = this;
  3129. var tracks = [];
  3130. for (var i = 0; i < this._trackKeys.length; i++) {
  3131. var propName = this._trackKeys[i];
  3132. var track = this._tracks[propName];
  3133. var additiveTrack = this._getAdditiveTrack(propName);
  3134. var kfs = track.keyframes;
  3135. track.prepare(additiveTrack);
  3136. if (track.needsAnimate()) {
  3137. tracks.push(track);
  3138. } else if (!track.interpolable) {
  3139. var lastKf = kfs[kfs.length - 1];
  3140. if (lastKf) {
  3141. self._target[track.propName] = lastKf.value;
  3142. }
  3143. }
  3144. }
  3145. if (tracks.length || forceAnimate) {
  3146. var clip = new Clip({
  3147. life: this._maxTime,
  3148. loop: this._loop,
  3149. delay: this._delay,
  3150. onframe: function (percent) {
  3151. self._started = 2;
  3152. var additiveAnimators = self._additiveAnimators;
  3153. if (additiveAnimators) {
  3154. var stillHasAdditiveAnimator = false;
  3155. for (var i = 0; i < additiveAnimators.length; i++) {
  3156. if (additiveAnimators[i]._clip) {
  3157. stillHasAdditiveAnimator = true;
  3158. break;
  3159. }
  3160. }
  3161. if (!stillHasAdditiveAnimator) {
  3162. self._additiveAnimators = null;
  3163. }
  3164. }
  3165. for (var i = 0; i < tracks.length; i++) {
  3166. tracks[i].step(self._target, percent);
  3167. }
  3168. var onframeList = self._onframeList;
  3169. if (onframeList) {
  3170. for (var i = 0; i < onframeList.length; i++) {
  3171. onframeList[i](self._target, percent);
  3172. }
  3173. }
  3174. },
  3175. ondestroy: function () {
  3176. self._doneCallback();
  3177. }
  3178. });
  3179. this._clip = clip;
  3180. if (this.animation) {
  3181. this.animation.addClip(clip);
  3182. }
  3183. if (easing && easing !== 'spline') {
  3184. clip.easing = easing;
  3185. }
  3186. } else {
  3187. this._doneCallback();
  3188. }
  3189. return this;
  3190. };
  3191. Animator.prototype.stop = function (forwardToLast) {
  3192. if (!this._clip) {
  3193. return;
  3194. }
  3195. var clip = this._clip;
  3196. if (forwardToLast) {
  3197. clip.onframe(1);
  3198. }
  3199. this._abortedCallback();
  3200. };
  3201. Animator.prototype.delay = function (time) {
  3202. this._delay = time;
  3203. return this;
  3204. };
  3205. Animator.prototype.during = function (cb) {
  3206. if (cb) {
  3207. if (!this._onframeList) {
  3208. this._onframeList = [];
  3209. }
  3210. this._onframeList.push(cb);
  3211. }
  3212. return this;
  3213. };
  3214. Animator.prototype.done = function (cb) {
  3215. if (cb) {
  3216. if (!this._doneList) {
  3217. this._doneList = [];
  3218. }
  3219. this._doneList.push(cb);
  3220. }
  3221. return this;
  3222. };
  3223. Animator.prototype.aborted = function (cb) {
  3224. if (cb) {
  3225. if (!this._abortedList) {
  3226. this._abortedList = [];
  3227. }
  3228. this._abortedList.push(cb);
  3229. }
  3230. return this;
  3231. };
  3232. Animator.prototype.getClip = function () {
  3233. return this._clip;
  3234. };
  3235. Animator.prototype.getTrack = function (propName) {
  3236. return this._tracks[propName];
  3237. };
  3238. Animator.prototype.stopTracks = function (propNames, forwardToLast) {
  3239. if (!propNames.length || !this._clip) {
  3240. return true;
  3241. }
  3242. var tracks = this._tracks;
  3243. var tracksKeys = this._trackKeys;
  3244. for (var i = 0; i < propNames.length; i++) {
  3245. var track = tracks[propNames[i]];
  3246. if (track) {
  3247. if (forwardToLast) {
  3248. track.step(this._target, 1);
  3249. } else if (this._started === 1) {
  3250. track.step(this._target, 0);
  3251. }
  3252. track.setFinished();
  3253. }
  3254. }
  3255. var allAborted = true;
  3256. for (var i = 0; i < tracksKeys.length; i++) {
  3257. if (!tracks[tracksKeys[i]].isFinished()) {
  3258. allAborted = false;
  3259. break;
  3260. }
  3261. }
  3262. if (allAborted) {
  3263. this._abortedCallback();
  3264. }
  3265. return allAborted;
  3266. };
  3267. Animator.prototype.saveFinalToTarget = function (target, trackKeys) {
  3268. if (!target) {
  3269. return;
  3270. }
  3271. trackKeys = trackKeys || this._trackKeys;
  3272. for (var i = 0; i < trackKeys.length; i++) {
  3273. var propName = trackKeys[i];
  3274. var track = this._tracks[propName];
  3275. if (!track || track.isFinished()) {
  3276. continue;
  3277. }
  3278. var kfs = track.keyframes;
  3279. var lastKf = kfs[kfs.length - 1];
  3280. if (lastKf) {
  3281. var val = cloneValue(lastKf.value);
  3282. if (track.isValueColor) {
  3283. val = rgba2String(val);
  3284. }
  3285. target[propName] = val;
  3286. }
  3287. }
  3288. };
  3289. Animator.prototype.__changeFinalValue = function (finalProps, trackKeys) {
  3290. trackKeys = trackKeys || keys(finalProps);
  3291. for (var i = 0; i < trackKeys.length; i++) {
  3292. var propName = trackKeys[i];
  3293. var track = this._tracks[propName];
  3294. if (!track) {
  3295. continue;
  3296. }
  3297. var kfs = track.keyframes;
  3298. if (kfs.length > 1) {
  3299. var lastKf = kfs.pop();
  3300. track.addKeyframe(lastKf.time, finalProps[propName]);
  3301. track.prepare(track.getAdditiveTrack());
  3302. }
  3303. }
  3304. };
  3305. return Animator;
  3306. }();
  3307. var Point = function () {
  3308. function Point(x, y) {
  3309. this.x = x || 0;
  3310. this.y = y || 0;
  3311. }
  3312. Point.prototype.copy = function (other) {
  3313. this.x = other.x;
  3314. this.y = other.y;
  3315. return this;
  3316. };
  3317. Point.prototype.clone = function () {
  3318. return new Point(this.x, this.y);
  3319. };
  3320. Point.prototype.set = function (x, y) {
  3321. this.x = x;
  3322. this.y = y;
  3323. return this;
  3324. };
  3325. Point.prototype.equal = function (other) {
  3326. return other.x === this.x && other.y === this.y;
  3327. };
  3328. Point.prototype.add = function (other) {
  3329. this.x += other.x;
  3330. this.y += other.y;
  3331. return this;
  3332. };
  3333. Point.prototype.scale = function (scalar) {
  3334. this.x *= scalar;
  3335. this.y *= scalar;
  3336. };
  3337. Point.prototype.scaleAndAdd = function (other, scalar) {
  3338. this.x += other.x * scalar;
  3339. this.y += other.y * scalar;
  3340. };
  3341. Point.prototype.sub = function (other) {
  3342. this.x -= other.x;
  3343. this.y -= other.y;
  3344. return this;
  3345. };
  3346. Point.prototype.dot = function (other) {
  3347. return this.x * other.x + this.y * other.y;
  3348. };
  3349. Point.prototype.len = function () {
  3350. return Math.sqrt(this.x * this.x + this.y * this.y);
  3351. };
  3352. Point.prototype.lenSquare = function () {
  3353. return this.x * this.x + this.y * this.y;
  3354. };
  3355. Point.prototype.normalize = function () {
  3356. var len = this.len();
  3357. this.x /= len;
  3358. this.y /= len;
  3359. return this;
  3360. };
  3361. Point.prototype.distance = function (other) {
  3362. var dx = this.x - other.x;
  3363. var dy = this.y - other.y;
  3364. return Math.sqrt(dx * dx + dy * dy);
  3365. };
  3366. Point.prototype.distanceSquare = function (other) {
  3367. var dx = this.x - other.x;
  3368. var dy = this.y - other.y;
  3369. return dx * dx + dy * dy;
  3370. };
  3371. Point.prototype.negate = function () {
  3372. this.x = -this.x;
  3373. this.y = -this.y;
  3374. return this;
  3375. };
  3376. Point.prototype.transform = function (m) {
  3377. if (!m) {
  3378. return;
  3379. }
  3380. var x = this.x;
  3381. var y = this.y;
  3382. this.x = m[0] * x + m[2] * y + m[4];
  3383. this.y = m[1] * x + m[3] * y + m[5];
  3384. return this;
  3385. };
  3386. Point.prototype.toArray = function (out) {
  3387. out[0] = this.x;
  3388. out[1] = this.y;
  3389. return out;
  3390. };
  3391. Point.prototype.fromArray = function (input) {
  3392. this.x = input[0];
  3393. this.y = input[1];
  3394. };
  3395. Point.set = function (p, x, y) {
  3396. p.x = x;
  3397. p.y = y;
  3398. };
  3399. Point.copy = function (p, p2) {
  3400. p.x = p2.x;
  3401. p.y = p2.y;
  3402. };
  3403. Point.len = function (p) {
  3404. return Math.sqrt(p.x * p.x + p.y * p.y);
  3405. };
  3406. Point.lenSquare = function (p) {
  3407. return p.x * p.x + p.y * p.y;
  3408. };
  3409. Point.dot = function (p0, p1) {
  3410. return p0.x * p1.x + p0.y * p1.y;
  3411. };
  3412. Point.add = function (out, p0, p1) {
  3413. out.x = p0.x + p1.x;
  3414. out.y = p0.y + p1.y;
  3415. };
  3416. Point.sub = function (out, p0, p1) {
  3417. out.x = p0.x - p1.x;
  3418. out.y = p0.y - p1.y;
  3419. };
  3420. Point.scale = function (out, p0, scalar) {
  3421. out.x = p0.x * scalar;
  3422. out.y = p0.y * scalar;
  3423. };
  3424. Point.scaleAndAdd = function (out, p0, p1, scalar) {
  3425. out.x = p0.x + p1.x * scalar;
  3426. out.y = p0.y + p1.y * scalar;
  3427. };
  3428. Point.lerp = function (out, p0, p1, t) {
  3429. var onet = 1 - t;
  3430. out.x = onet * p0.x + t * p1.x;
  3431. out.y = onet * p0.y + t * p1.y;
  3432. };
  3433. return Point;
  3434. }();
  3435. var mathMin = Math.min;
  3436. var mathMax = Math.max;
  3437. var lt = new Point();
  3438. var rb = new Point();
  3439. var lb = new Point();
  3440. var rt = new Point();
  3441. var minTv = new Point();
  3442. var maxTv = new Point();
  3443. var BoundingRect = function () {
  3444. function BoundingRect(x, y, width, height) {
  3445. if (width < 0 && isFinite(width)) {
  3446. x = x + width;
  3447. width = -width;
  3448. }
  3449. if (height < 0 && isFinite(height)) {
  3450. y = y + height;
  3451. height = -height;
  3452. }
  3453. this.x = x;
  3454. this.y = y;
  3455. this.width = width;
  3456. this.height = height;
  3457. }
  3458. BoundingRect.prototype.union = function (other) {
  3459. var x = mathMin(other.x, this.x);
  3460. var y = mathMin(other.y, this.y);
  3461. if (isFinite(this.x) && isFinite(this.width)) {
  3462. this.width = mathMax(other.x + other.width, this.x + this.width) - x;
  3463. } else {
  3464. this.width = other.width;
  3465. }
  3466. if (isFinite(this.y) && isFinite(this.height)) {
  3467. this.height = mathMax(other.y + other.height, this.y + this.height) - y;
  3468. } else {
  3469. this.height = other.height;
  3470. }
  3471. this.x = x;
  3472. this.y = y;
  3473. };
  3474. BoundingRect.prototype.applyTransform = function (m) {
  3475. BoundingRect.applyTransform(this, this, m);
  3476. };
  3477. BoundingRect.prototype.calculateTransform = function (b) {
  3478. var a = this;
  3479. var sx = b.width / a.width;
  3480. var sy = b.height / a.height;
  3481. var m = create$1();
  3482. translate(m, m, [-a.x, -a.y]);
  3483. scale$1(m, m, [sx, sy]);
  3484. translate(m, m, [b.x, b.y]);
  3485. return m;
  3486. };
  3487. BoundingRect.prototype.intersect = function (b, mtv) {
  3488. if (!b) {
  3489. return false;
  3490. }
  3491. if (!(b instanceof BoundingRect)) {
  3492. b = BoundingRect.create(b);
  3493. }
  3494. var a = this;
  3495. var ax0 = a.x;
  3496. var ax1 = a.x + a.width;
  3497. var ay0 = a.y;
  3498. var ay1 = a.y + a.height;
  3499. var bx0 = b.x;
  3500. var bx1 = b.x + b.width;
  3501. var by0 = b.y;
  3502. var by1 = b.y + b.height;
  3503. var overlap = !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  3504. if (mtv) {
  3505. var dMin = Infinity;
  3506. var dMax = 0;
  3507. var d0 = Math.abs(ax1 - bx0);
  3508. var d1 = Math.abs(bx1 - ax0);
  3509. var d2 = Math.abs(ay1 - by0);
  3510. var d3 = Math.abs(by1 - ay0);
  3511. var dx = Math.min(d0, d1);
  3512. var dy = Math.min(d2, d3);
  3513. if (ax1 < bx0 || bx1 < ax0) {
  3514. if (dx > dMax) {
  3515. dMax = dx;
  3516. if (d0 < d1) {
  3517. Point.set(maxTv, -d0, 0);
  3518. } else {
  3519. Point.set(maxTv, d1, 0);
  3520. }
  3521. }
  3522. } else {
  3523. if (dx < dMin) {
  3524. dMin = dx;
  3525. if (d0 < d1) {
  3526. Point.set(minTv, d0, 0);
  3527. } else {
  3528. Point.set(minTv, -d1, 0);
  3529. }
  3530. }
  3531. }
  3532. if (ay1 < by0 || by1 < ay0) {
  3533. if (dy > dMax) {
  3534. dMax = dy;
  3535. if (d2 < d3) {
  3536. Point.set(maxTv, 0, -d2);
  3537. } else {
  3538. Point.set(maxTv, 0, d3);
  3539. }
  3540. }
  3541. } else {
  3542. if (dx < dMin) {
  3543. dMin = dx;
  3544. if (d2 < d3) {
  3545. Point.set(minTv, 0, d2);
  3546. } else {
  3547. Point.set(minTv, 0, -d3);
  3548. }
  3549. }
  3550. }
  3551. }
  3552. if (mtv) {
  3553. Point.copy(mtv, overlap ? minTv : maxTv);
  3554. }
  3555. return overlap;
  3556. };
  3557. BoundingRect.prototype.contain = function (x, y) {
  3558. var rect = this;
  3559. return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
  3560. };
  3561. BoundingRect.prototype.clone = function () {
  3562. return new BoundingRect(this.x, this.y, this.width, this.height);
  3563. };
  3564. BoundingRect.prototype.copy = function (other) {
  3565. BoundingRect.copy(this, other);
  3566. };
  3567. BoundingRect.prototype.plain = function () {
  3568. return {
  3569. x: this.x,
  3570. y: this.y,
  3571. width: this.width,
  3572. height: this.height
  3573. };
  3574. };
  3575. BoundingRect.prototype.isFinite = function () {
  3576. return isFinite(this.x) && isFinite(this.y) && isFinite(this.width) && isFinite(this.height);
  3577. };
  3578. BoundingRect.prototype.isZero = function () {
  3579. return this.width === 0 || this.height === 0;
  3580. };
  3581. BoundingRect.create = function (rect) {
  3582. return new BoundingRect(rect.x, rect.y, rect.width, rect.height);
  3583. };
  3584. BoundingRect.copy = function (target, source) {
  3585. target.x = source.x;
  3586. target.y = source.y;
  3587. target.width = source.width;
  3588. target.height = source.height;
  3589. };
  3590. BoundingRect.applyTransform = function (target, source, m) {
  3591. if (!m) {
  3592. if (target !== source) {
  3593. BoundingRect.copy(target, source);
  3594. }
  3595. return;
  3596. }
  3597. if (m[1] < 1e-5 && m[1] > -1e-5 && m[2] < 1e-5 && m[2] > -1e-5) {
  3598. var sx = m[0];
  3599. var sy = m[3];
  3600. var tx = m[4];
  3601. var ty = m[5];
  3602. target.x = source.x * sx + tx;
  3603. target.y = source.y * sy + ty;
  3604. target.width = source.width * sx;
  3605. target.height = source.height * sy;
  3606. if (target.width < 0) {
  3607. target.x += target.width;
  3608. target.width = -target.width;
  3609. }
  3610. if (target.height < 0) {
  3611. target.y += target.height;
  3612. target.height = -target.height;
  3613. }
  3614. return;
  3615. }
  3616. lt.x = lb.x = source.x;
  3617. lt.y = rt.y = source.y;
  3618. rb.x = rt.x = source.x + source.width;
  3619. rb.y = lb.y = source.y + source.height;
  3620. lt.transform(m);
  3621. rt.transform(m);
  3622. rb.transform(m);
  3623. lb.transform(m);
  3624. target.x = mathMin(lt.x, rb.x, lb.x, rt.x);
  3625. target.y = mathMin(lt.y, rb.y, lb.y, rt.y);
  3626. var maxX = mathMax(lt.x, rb.x, lb.x, rt.x);
  3627. var maxY = mathMax(lt.y, rb.y, lb.y, rt.y);
  3628. target.width = maxX - target.x;
  3629. target.height = maxY - target.y;
  3630. };
  3631. return BoundingRect;
  3632. }();
  3633. var textWidthCache = {};
  3634. var DEFAULT_FONT = '12px sans-serif';
  3635. var _ctx;
  3636. var _cachedFont;
  3637. function defaultMeasureText(text, font) {
  3638. if (!_ctx) {
  3639. _ctx = createCanvas().getContext('2d');
  3640. }
  3641. if (_cachedFont !== font) {
  3642. _cachedFont = _ctx.font = font || DEFAULT_FONT;
  3643. }
  3644. return _ctx.measureText(text);
  3645. }
  3646. var methods$1 = {
  3647. measureText: defaultMeasureText
  3648. };
  3649. function getWidth(text, font) {
  3650. font = font || DEFAULT_FONT;
  3651. var cacheOfFont = textWidthCache[font];
  3652. if (!cacheOfFont) {
  3653. cacheOfFont = textWidthCache[font] = new LRU(500);
  3654. }
  3655. var width = cacheOfFont.get(text);
  3656. if (width == null) {
  3657. width = methods$1.measureText(text, font).width;
  3658. cacheOfFont.put(text, width);
  3659. }
  3660. return width;
  3661. }
  3662. function innerGetBoundingRect(text, font, textAlign, textBaseline) {
  3663. var width = getWidth(text, font);
  3664. var height = getLineHeight(font);
  3665. var x = adjustTextX(0, width, textAlign);
  3666. var y = adjustTextY(0, height, textBaseline);
  3667. var rect = new BoundingRect(x, y, width, height);
  3668. return rect;
  3669. }
  3670. function getBoundingRect(text, font, textAlign, textBaseline) {
  3671. var textLines = ((text || '') + '').split('\n');
  3672. var len = textLines.length;
  3673. if (len === 1) {
  3674. return innerGetBoundingRect(textLines[0], font, textAlign, textBaseline);
  3675. } else {
  3676. var uniondRect = new BoundingRect(0, 0, 0, 0);
  3677. for (var i = 0; i < textLines.length; i++) {
  3678. var rect = innerGetBoundingRect(textLines[i], font, textAlign, textBaseline);
  3679. i === 0 ? uniondRect.copy(rect) : uniondRect.union(rect);
  3680. }
  3681. return uniondRect;
  3682. }
  3683. }
  3684. function adjustTextX(x, width, textAlign) {
  3685. if (textAlign === 'right') {
  3686. x -= width;
  3687. } else if (textAlign === 'center') {
  3688. x -= width / 2;
  3689. }
  3690. return x;
  3691. }
  3692. function adjustTextY(y, height, verticalAlign) {
  3693. if (verticalAlign === 'middle') {
  3694. y -= height / 2;
  3695. } else if (verticalAlign === 'bottom') {
  3696. y -= height;
  3697. }
  3698. return y;
  3699. }
  3700. function getLineHeight(font) {
  3701. return getWidth('国', font);
  3702. }
  3703. function parsePercent(value, maxValue) {
  3704. if (typeof value === 'string') {
  3705. if (value.lastIndexOf('%') >= 0) {
  3706. return parseFloat(value) / 100 * maxValue;
  3707. }
  3708. return parseFloat(value);
  3709. }
  3710. return value;
  3711. }
  3712. function calculateTextPosition(out, opts, rect) {
  3713. var textPosition = opts.position || 'inside';
  3714. var distance = opts.distance != null ? opts.distance : 5;
  3715. var height = rect.height;
  3716. var width = rect.width;
  3717. var halfHeight = height / 2;
  3718. var x = rect.x;
  3719. var y = rect.y;
  3720. var textAlign = 'left';
  3721. var textVerticalAlign = 'top';
  3722. if (textPosition instanceof Array) {
  3723. x += parsePercent(textPosition[0], rect.width);
  3724. y += parsePercent(textPosition[1], rect.height);
  3725. textAlign = null;
  3726. textVerticalAlign = null;
  3727. } else {
  3728. switch (textPosition) {
  3729. case 'left':
  3730. x -= distance;
  3731. y += halfHeight;
  3732. textAlign = 'right';
  3733. textVerticalAlign = 'middle';
  3734. break;
  3735. case 'right':
  3736. x += distance + width;
  3737. y += halfHeight;
  3738. textVerticalAlign = 'middle';
  3739. break;
  3740. case 'top':
  3741. x += width / 2;
  3742. y -= distance;
  3743. textAlign = 'center';
  3744. textVerticalAlign = 'bottom';
  3745. break;
  3746. case 'bottom':
  3747. x += width / 2;
  3748. y += height + distance;
  3749. textAlign = 'center';
  3750. break;
  3751. case 'inside':
  3752. x += width / 2;
  3753. y += halfHeight;
  3754. textAlign = 'center';
  3755. textVerticalAlign = 'middle';
  3756. break;
  3757. case 'insideLeft':
  3758. x += distance;
  3759. y += halfHeight;
  3760. textVerticalAlign = 'middle';
  3761. break;
  3762. case 'insideRight':
  3763. x += width - distance;
  3764. y += halfHeight;
  3765. textAlign = 'right';
  3766. textVerticalAlign = 'middle';
  3767. break;
  3768. case 'insideTop':
  3769. x += width / 2;
  3770. y += distance;
  3771. textAlign = 'center';
  3772. break;
  3773. case 'insideBottom':
  3774. x += width / 2;
  3775. y += height - distance;
  3776. textAlign = 'center';
  3777. textVerticalAlign = 'bottom';
  3778. break;
  3779. case 'insideTopLeft':
  3780. x += distance;
  3781. y += distance;
  3782. break;
  3783. case 'insideTopRight':
  3784. x += width - distance;
  3785. y += distance;
  3786. textAlign = 'right';
  3787. break;
  3788. case 'insideBottomLeft':
  3789. x += distance;
  3790. y += height - distance;
  3791. textVerticalAlign = 'bottom';
  3792. break;
  3793. case 'insideBottomRight':
  3794. x += width - distance;
  3795. y += height - distance;
  3796. textAlign = 'right';
  3797. textVerticalAlign = 'bottom';
  3798. break;
  3799. }
  3800. }
  3801. out = out || {};
  3802. out.x = x;
  3803. out.y = y;
  3804. out.align = textAlign;
  3805. out.verticalAlign = textVerticalAlign;
  3806. return out;
  3807. }
  3808. var dpr = 1;
  3809. if (typeof window !== 'undefined') {
  3810. dpr = Math.max(window.devicePixelRatio || window.screen && window.screen.deviceXDPI / window.screen.logicalXDPI || 1, 1);
  3811. }
  3812. var devicePixelRatio = dpr;
  3813. var DARK_MODE_THRESHOLD = 0.4;
  3814. var DARK_LABEL_COLOR = '#333';
  3815. var LIGHT_LABEL_COLOR = '#ccc';
  3816. var LIGHTER_LABEL_COLOR = '#eee';
  3817. var PRESERVED_NORMAL_STATE = '__zr_normal__';
  3818. var PRIMARY_STATES_KEYS = ['x', 'y', 'scaleX', 'scaleY', 'originX', 'originY', 'rotation', 'ignore'];
  3819. var DEFAULT_ANIMATABLE_MAP = {
  3820. x: true,
  3821. y: true,
  3822. scaleX: true,
  3823. scaleY: true,
  3824. originX: true,
  3825. originY: true,
  3826. rotation: true,
  3827. ignore: false
  3828. };
  3829. var tmpTextPosCalcRes = {};
  3830. var tmpBoundingRect = new BoundingRect(0, 0, 0, 0);
  3831. var Element = function () {
  3832. function Element(props) {
  3833. this.id = guid();
  3834. this.animators = [];
  3835. this.currentStates = [];
  3836. this.states = {};
  3837. this._init(props);
  3838. }
  3839. Element.prototype._init = function (props) {
  3840. this.attr(props);
  3841. };
  3842. Element.prototype.drift = function (dx, dy, e) {
  3843. switch (this.draggable) {
  3844. case 'horizontal':
  3845. dy = 0;
  3846. break;
  3847. case 'vertical':
  3848. dx = 0;
  3849. break;
  3850. }
  3851. var m = this.transform;
  3852. if (!m) {
  3853. m = this.transform = [1, 0, 0, 1, 0, 0];
  3854. }
  3855. m[4] += dx;
  3856. m[5] += dy;
  3857. this.decomposeTransform();
  3858. this.markRedraw();
  3859. };
  3860. Element.prototype.beforeUpdate = function () {};
  3861. Element.prototype.afterUpdate = function () {};
  3862. Element.prototype.update = function () {
  3863. this.updateTransform();
  3864. if (this.__dirty) {
  3865. this.updateInnerText();
  3866. }
  3867. };
  3868. Element.prototype.updateInnerText = function (forceUpdate) {
  3869. var textEl = this._textContent;
  3870. if (textEl && (!textEl.ignore || forceUpdate)) {
  3871. if (!this.textConfig) {
  3872. this.textConfig = {};
  3873. }
  3874. var textConfig = this.textConfig;
  3875. var isLocal = textConfig.local;
  3876. var attachedTransform = textEl.attachedTransform;
  3877. var textAlign = void 0;
  3878. var textVerticalAlign = void 0;
  3879. var textStyleChanged = false;
  3880. if (isLocal) {
  3881. attachedTransform.parent = this;
  3882. } else {
  3883. attachedTransform.parent = null;
  3884. }
  3885. var innerOrigin = false;
  3886. attachedTransform.x = textEl.x;
  3887. attachedTransform.y = textEl.y;
  3888. attachedTransform.originX = textEl.originX;
  3889. attachedTransform.originY = textEl.originY;
  3890. attachedTransform.rotation = textEl.rotation;
  3891. attachedTransform.scaleX = textEl.scaleX;
  3892. attachedTransform.scaleY = textEl.scaleY;
  3893. if (textConfig.position != null) {
  3894. var layoutRect = tmpBoundingRect;
  3895. if (textConfig.layoutRect) {
  3896. layoutRect.copy(textConfig.layoutRect);
  3897. } else {
  3898. layoutRect.copy(this.getBoundingRect());
  3899. }
  3900. if (!isLocal) {
  3901. layoutRect.applyTransform(this.transform);
  3902. }
  3903. if (this.calculateTextPosition) {
  3904. this.calculateTextPosition(tmpTextPosCalcRes, textConfig, layoutRect);
  3905. } else {
  3906. calculateTextPosition(tmpTextPosCalcRes, textConfig, layoutRect);
  3907. }
  3908. attachedTransform.x = tmpTextPosCalcRes.x;
  3909. attachedTransform.y = tmpTextPosCalcRes.y;
  3910. textAlign = tmpTextPosCalcRes.align;
  3911. textVerticalAlign = tmpTextPosCalcRes.verticalAlign;
  3912. var textOrigin = textConfig.origin;
  3913. if (textOrigin && textConfig.rotation != null) {
  3914. var relOriginX = void 0;
  3915. var relOriginY = void 0;
  3916. if (textOrigin === 'center') {
  3917. relOriginX = layoutRect.width * 0.5;
  3918. relOriginY = layoutRect.height * 0.5;
  3919. } else {
  3920. relOriginX = parsePercent(textOrigin[0], layoutRect.width);
  3921. relOriginY = parsePercent(textOrigin[1], layoutRect.height);
  3922. }
  3923. innerOrigin = true;
  3924. attachedTransform.originX = -attachedTransform.x + relOriginX + (isLocal ? 0 : layoutRect.x);
  3925. attachedTransform.originY = -attachedTransform.y + relOriginY + (isLocal ? 0 : layoutRect.y);
  3926. }
  3927. }
  3928. if (textConfig.rotation != null) {
  3929. attachedTransform.rotation = textConfig.rotation;
  3930. }
  3931. var textOffset = textConfig.offset;
  3932. if (textOffset) {
  3933. attachedTransform.x += textOffset[0];
  3934. attachedTransform.y += textOffset[1];
  3935. if (!innerOrigin) {
  3936. attachedTransform.originX = -textOffset[0];
  3937. attachedTransform.originY = -textOffset[1];
  3938. }
  3939. }
  3940. var isInside = textConfig.inside == null ? typeof textConfig.position === 'string' && textConfig.position.indexOf('inside') >= 0 : textConfig.inside;
  3941. var innerTextDefaultStyle = this._innerTextDefaultStyle || (this._innerTextDefaultStyle = {});
  3942. var textFill = void 0;
  3943. var textStroke = void 0;
  3944. var autoStroke = void 0;
  3945. if (isInside && this.canBeInsideText()) {
  3946. textFill = textConfig.insideFill;
  3947. textStroke = textConfig.insideStroke;
  3948. if (textFill == null || textFill === 'auto') {
  3949. textFill = this.getInsideTextFill();
  3950. }
  3951. if (textStroke == null || textStroke === 'auto') {
  3952. textStroke = this.getInsideTextStroke(textFill);
  3953. autoStroke = true;
  3954. }
  3955. } else {
  3956. textFill = textConfig.outsideFill;
  3957. textStroke = textConfig.outsideStroke;
  3958. if (textFill == null || textFill === 'auto') {
  3959. textFill = this.getOutsideFill();
  3960. }
  3961. if (textStroke == null || textStroke === 'auto') {
  3962. textStroke = this.getOutsideStroke(textFill);
  3963. autoStroke = true;
  3964. }
  3965. }
  3966. textFill = textFill || '#000';
  3967. if (textFill !== innerTextDefaultStyle.fill || textStroke !== innerTextDefaultStyle.stroke || autoStroke !== innerTextDefaultStyle.autoStroke || textAlign !== innerTextDefaultStyle.align || textVerticalAlign !== innerTextDefaultStyle.verticalAlign) {
  3968. textStyleChanged = true;
  3969. innerTextDefaultStyle.fill = textFill;
  3970. innerTextDefaultStyle.stroke = textStroke;
  3971. innerTextDefaultStyle.autoStroke = autoStroke;
  3972. innerTextDefaultStyle.align = textAlign;
  3973. innerTextDefaultStyle.verticalAlign = textVerticalAlign;
  3974. textEl.setDefaultTextStyle(innerTextDefaultStyle);
  3975. }
  3976. if (textStyleChanged) {
  3977. textEl.dirtyStyle();
  3978. }
  3979. textEl.markRedraw();
  3980. }
  3981. };
  3982. Element.prototype.canBeInsideText = function () {
  3983. return true;
  3984. };
  3985. Element.prototype.getInsideTextFill = function () {
  3986. return '#fff';
  3987. };
  3988. Element.prototype.getInsideTextStroke = function (textFill) {
  3989. return '#000';
  3990. };
  3991. Element.prototype.getOutsideFill = function () {
  3992. return this.__zr && this.__zr.isDarkMode() ? LIGHT_LABEL_COLOR : DARK_LABEL_COLOR;
  3993. };
  3994. Element.prototype.getOutsideStroke = function (textFill) {
  3995. var backgroundColor = this.__zr && this.__zr.getBackgroundColor();
  3996. var colorArr = typeof backgroundColor === 'string' && parse(backgroundColor);
  3997. if (!colorArr) {
  3998. colorArr = [255, 255, 255, 1];
  3999. }
  4000. var alpha = colorArr[3];
  4001. var isDark = this.__zr.isDarkMode();
  4002. for (var i = 0; i < 3; i++) {
  4003. colorArr[i] = colorArr[i] * alpha + (isDark ? 0 : 255) * (1 - alpha);
  4004. }
  4005. colorArr[3] = 1;
  4006. return stringify(colorArr, 'rgba');
  4007. };
  4008. Element.prototype.traverse = function (cb, context) {};
  4009. Element.prototype.attrKV = function (key, value) {
  4010. if (key === 'textConfig') {
  4011. this.setTextConfig(value);
  4012. } else if (key === 'textContent') {
  4013. this.setTextContent(value);
  4014. } else if (key === 'clipPath') {
  4015. this.setClipPath(value);
  4016. } else if (key === 'extra') {
  4017. this.extra = this.extra || {};
  4018. extend(this.extra, value);
  4019. } else {
  4020. this[key] = value;
  4021. }
  4022. };
  4023. Element.prototype.hide = function () {
  4024. this.ignore = true;
  4025. this.markRedraw();
  4026. };
  4027. Element.prototype.show = function () {
  4028. this.ignore = false;
  4029. this.markRedraw();
  4030. };
  4031. Element.prototype.attr = function (keyOrObj, value) {
  4032. if (typeof keyOrObj === 'string') {
  4033. this.attrKV(keyOrObj, value);
  4034. } else if (isObject$1(keyOrObj)) {
  4035. var obj = keyOrObj;
  4036. var keysArr = keys(obj);
  4037. for (var i = 0; i < keysArr.length; i++) {
  4038. var key = keysArr[i];
  4039. this.attrKV(key, keyOrObj[key]);
  4040. }
  4041. }
  4042. this.markRedraw();
  4043. return this;
  4044. };
  4045. Element.prototype.saveCurrentToNormalState = function (toState) {
  4046. this._innerSaveToNormal(toState);
  4047. var normalState = this._normalState;
  4048. for (var i = 0; i < this.animators.length; i++) {
  4049. var animator = this.animators[i];
  4050. var fromStateTransition = animator.__fromStateTransition;
  4051. if (fromStateTransition && fromStateTransition !== PRESERVED_NORMAL_STATE) {
  4052. continue;
  4053. }
  4054. var targetName = animator.targetName;
  4055. var target = targetName ? normalState[targetName] : normalState;
  4056. animator.saveFinalToTarget(target);
  4057. }
  4058. };
  4059. Element.prototype._innerSaveToNormal = function (toState) {
  4060. var normalState = this._normalState;
  4061. if (!normalState) {
  4062. normalState = this._normalState = {};
  4063. }
  4064. if (toState.textConfig && !normalState.textConfig) {
  4065. normalState.textConfig = this.textConfig;
  4066. }
  4067. this._savePrimaryToNormal(toState, normalState, PRIMARY_STATES_KEYS);
  4068. };
  4069. Element.prototype._savePrimaryToNormal = function (toState, normalState, primaryKeys) {
  4070. for (var i = 0; i < primaryKeys.length; i++) {
  4071. var key = primaryKeys[i];
  4072. if (toState[key] != null && !(key in normalState)) {
  4073. normalState[key] = this[key];
  4074. }
  4075. }
  4076. };
  4077. Element.prototype.hasState = function () {
  4078. return this.currentStates.length > 0;
  4079. };
  4080. Element.prototype.getState = function (name) {
  4081. return this.states[name];
  4082. };
  4083. Element.prototype.ensureState = function (name) {
  4084. var states = this.states;
  4085. if (!states[name]) {
  4086. states[name] = {};
  4087. }
  4088. return states[name];
  4089. };
  4090. Element.prototype.clearStates = function (noAnimation) {
  4091. this.useState(PRESERVED_NORMAL_STATE, false, noAnimation);
  4092. };
  4093. Element.prototype.useState = function (stateName, keepCurrentStates, noAnimation) {
  4094. var toNormalState = stateName === PRESERVED_NORMAL_STATE;
  4095. var hasStates = this.hasState();
  4096. if (!hasStates && toNormalState) {
  4097. return;
  4098. }
  4099. var currentStates = this.currentStates;
  4100. var animationCfg = this.stateTransition;
  4101. if (indexOf$1(currentStates, stateName) >= 0 && (keepCurrentStates || currentStates.length === 1)) {
  4102. return;
  4103. }
  4104. var state;
  4105. if (this.stateProxy && !toNormalState) {
  4106. state = this.stateProxy(stateName);
  4107. }
  4108. if (!state) {
  4109. state = this.states && this.states[stateName];
  4110. }
  4111. if (!state && !toNormalState) {
  4112. logError("State " + stateName + " not exists.");
  4113. return;
  4114. }
  4115. if (!toNormalState) {
  4116. this.saveCurrentToNormalState(state);
  4117. }
  4118. var useHoverLayer = !!(state && state.hoverLayer);
  4119. if (useHoverLayer) {
  4120. this._toggleHoverLayerFlag(true);
  4121. }
  4122. this._applyStateObj(stateName, state, this._normalState, keepCurrentStates, !noAnimation && !this.__inHover && animationCfg && animationCfg.duration > 0, animationCfg);
  4123. if (this._textContent) {
  4124. this._textContent.useState(stateName, keepCurrentStates);
  4125. }
  4126. if (this._textGuide) {
  4127. this._textGuide.useState(stateName, keepCurrentStates);
  4128. }
  4129. if (toNormalState) {
  4130. this.currentStates = [];
  4131. this._normalState = {};
  4132. } else {
  4133. if (!keepCurrentStates) {
  4134. this.currentStates = [stateName];
  4135. } else {
  4136. this.currentStates.push(stateName);
  4137. }
  4138. }
  4139. this._updateAnimationTargets();
  4140. this.markRedraw();
  4141. if (!useHoverLayer && this.__inHover) {
  4142. this._toggleHoverLayerFlag(false);
  4143. this.__dirty &= ~Element.REDARAW_BIT;
  4144. }
  4145. return state;
  4146. };
  4147. Element.prototype.useStates = function (states, noAnimation) {
  4148. if (!states.length) {
  4149. this.clearStates();
  4150. } else {
  4151. var stateObjects = [];
  4152. var currentStates = this.currentStates;
  4153. var len = states.length;
  4154. var notChange = len === currentStates.length;
  4155. if (notChange) {
  4156. for (var i = 0; i < len; i++) {
  4157. if (states[i] !== currentStates[i]) {
  4158. notChange = false;
  4159. break;
  4160. }
  4161. }
  4162. }
  4163. if (notChange) {
  4164. return;
  4165. }
  4166. for (var i = 0; i < len; i++) {
  4167. var stateName = states[i];
  4168. var stateObj = void 0;
  4169. if (this.stateProxy) {
  4170. stateObj = this.stateProxy(stateName, states);
  4171. }
  4172. if (!stateObj) {
  4173. stateObj = this.states[stateName];
  4174. }
  4175. if (stateObj) {
  4176. stateObjects.push(stateObj);
  4177. }
  4178. }
  4179. var useHoverLayer = !!(stateObjects[len - 1] && stateObjects[len - 1].hoverLayer);
  4180. if (useHoverLayer) {
  4181. this._toggleHoverLayerFlag(true);
  4182. }
  4183. var mergedState = this._mergeStates(stateObjects);
  4184. var animationCfg = this.stateTransition;
  4185. this.saveCurrentToNormalState(mergedState);
  4186. this._applyStateObj(states.join(','), mergedState, this._normalState, false, !noAnimation && !this.__inHover && animationCfg && animationCfg.duration > 0, animationCfg);
  4187. if (this._textContent) {
  4188. this._textContent.useStates(states);
  4189. }
  4190. if (this._textGuide) {
  4191. this._textGuide.useStates(states);
  4192. }
  4193. this._updateAnimationTargets();
  4194. this.currentStates = states.slice();
  4195. this.markRedraw();
  4196. if (!useHoverLayer && this.__inHover) {
  4197. this._toggleHoverLayerFlag(false);
  4198. this.__dirty &= ~Element.REDARAW_BIT;
  4199. }
  4200. }
  4201. };
  4202. Element.prototype._updateAnimationTargets = function () {
  4203. for (var i = 0; i < this.animators.length; i++) {
  4204. var animator = this.animators[i];
  4205. if (animator.targetName) {
  4206. animator.changeTarget(this[animator.targetName]);
  4207. }
  4208. }
  4209. };
  4210. Element.prototype.removeState = function (state) {
  4211. var idx = indexOf$1(this.currentStates, state);
  4212. if (idx >= 0) {
  4213. var currentStates = this.currentStates.slice();
  4214. currentStates.splice(idx, 1);
  4215. this.useStates(currentStates);
  4216. }
  4217. };
  4218. Element.prototype.replaceState = function (oldState, newState, forceAdd) {
  4219. var currentStates = this.currentStates.slice();
  4220. var idx = indexOf$1(currentStates, oldState);
  4221. var newStateExists = indexOf$1(currentStates, newState) >= 0;
  4222. if (idx >= 0) {
  4223. if (!newStateExists) {
  4224. currentStates[idx] = newState;
  4225. } else {
  4226. currentStates.splice(idx, 1);
  4227. }
  4228. } else if (forceAdd && !newStateExists) {
  4229. currentStates.push(newState);
  4230. }
  4231. this.useStates(currentStates);
  4232. };
  4233. Element.prototype.toggleState = function (state, enable) {
  4234. if (enable) {
  4235. this.useState(state, true);
  4236. } else {
  4237. this.removeState(state);
  4238. }
  4239. };
  4240. Element.prototype._mergeStates = function (states) {
  4241. var mergedState = {};
  4242. var mergedTextConfig;
  4243. for (var i = 0; i < states.length; i++) {
  4244. var state = states[i];
  4245. extend(mergedState, state);
  4246. if (state.textConfig) {
  4247. mergedTextConfig = mergedTextConfig || {};
  4248. extend(mergedTextConfig, state.textConfig);
  4249. }
  4250. }
  4251. if (mergedTextConfig) {
  4252. mergedState.textConfig = mergedTextConfig;
  4253. }
  4254. return mergedState;
  4255. };
  4256. Element.prototype._applyStateObj = function (stateName, state, normalState, keepCurrentStates, transition, animationCfg) {
  4257. var needsRestoreToNormal = !(state && keepCurrentStates);
  4258. if (state && state.textConfig) {
  4259. this.textConfig = extend({}, keepCurrentStates ? this.textConfig : normalState.textConfig);
  4260. extend(this.textConfig, state.textConfig);
  4261. } else if (needsRestoreToNormal) {
  4262. if (normalState.textConfig) {
  4263. this.textConfig = normalState.textConfig;
  4264. }
  4265. }
  4266. var transitionTarget = {};
  4267. var hasTransition = false;
  4268. for (var i = 0; i < PRIMARY_STATES_KEYS.length; i++) {
  4269. var key = PRIMARY_STATES_KEYS[i];
  4270. var propNeedsTransition = transition && DEFAULT_ANIMATABLE_MAP[key];
  4271. if (state && state[key] != null) {
  4272. if (propNeedsTransition) {
  4273. hasTransition = true;
  4274. transitionTarget[key] = state[key];
  4275. } else {
  4276. this[key] = state[key];
  4277. }
  4278. } else if (needsRestoreToNormal) {
  4279. if (normalState[key] != null) {
  4280. if (propNeedsTransition) {
  4281. hasTransition = true;
  4282. transitionTarget[key] = normalState[key];
  4283. } else {
  4284. this[key] = normalState[key];
  4285. }
  4286. }
  4287. }
  4288. }
  4289. if (!transition) {
  4290. for (var i = 0; i < this.animators.length; i++) {
  4291. var animator = this.animators[i];
  4292. var targetName = animator.targetName;
  4293. animator.__changeFinalValue(targetName ? (state || normalState)[targetName] : state || normalState);
  4294. }
  4295. }
  4296. if (hasTransition) {
  4297. this._transitionState(stateName, transitionTarget, animationCfg);
  4298. }
  4299. };
  4300. Element.prototype._attachComponent = function (componentEl) {
  4301. if (componentEl.__zr && !componentEl.__hostTarget) {
  4302. throw new Error('Text element has been added to zrender.');
  4303. }
  4304. if (componentEl === this) {
  4305. throw new Error('Recursive component attachment.');
  4306. }
  4307. var zr = this.__zr;
  4308. if (zr) {
  4309. componentEl.addSelfToZr(zr);
  4310. }
  4311. componentEl.__zr = zr;
  4312. componentEl.__hostTarget = this;
  4313. };
  4314. Element.prototype._detachComponent = function (componentEl) {
  4315. if (componentEl.__zr) {
  4316. componentEl.removeSelfFromZr(componentEl.__zr);
  4317. }
  4318. componentEl.__zr = null;
  4319. componentEl.__hostTarget = null;
  4320. };
  4321. Element.prototype.getClipPath = function () {
  4322. return this._clipPath;
  4323. };
  4324. Element.prototype.setClipPath = function (clipPath) {
  4325. if (this._clipPath && this._clipPath !== clipPath) {
  4326. this.removeClipPath();
  4327. }
  4328. this._attachComponent(clipPath);
  4329. this._clipPath = clipPath;
  4330. this.markRedraw();
  4331. };
  4332. Element.prototype.removeClipPath = function () {
  4333. var clipPath = this._clipPath;
  4334. if (clipPath) {
  4335. this._detachComponent(clipPath);
  4336. this._clipPath = null;
  4337. this.markRedraw();
  4338. }
  4339. };
  4340. Element.prototype.getTextContent = function () {
  4341. return this._textContent;
  4342. };
  4343. Element.prototype.setTextContent = function (textEl) {
  4344. var previousTextContent = this._textContent;
  4345. if (previousTextContent === textEl) {
  4346. return;
  4347. }
  4348. if (previousTextContent && previousTextContent !== textEl) {
  4349. this.removeTextContent();
  4350. }
  4351. if (textEl.__zr && !textEl.__hostTarget) {
  4352. throw new Error('Text element has been added to zrender.');
  4353. }
  4354. textEl.attachedTransform = new Transformable();
  4355. this._attachComponent(textEl);
  4356. this._textContent = textEl;
  4357. this.markRedraw();
  4358. };
  4359. Element.prototype.setTextConfig = function (cfg) {
  4360. if (!this.textConfig) {
  4361. this.textConfig = {};
  4362. }
  4363. extend(this.textConfig, cfg);
  4364. this.markRedraw();
  4365. };
  4366. Element.prototype.removeTextConfig = function () {
  4367. this.textConfig = null;
  4368. this.markRedraw();
  4369. };
  4370. Element.prototype.removeTextContent = function () {
  4371. var textEl = this._textContent;
  4372. if (textEl) {
  4373. textEl.attachedTransform = null;
  4374. this._detachComponent(textEl);
  4375. this._textContent = null;
  4376. this._innerTextDefaultStyle = null;
  4377. this.markRedraw();
  4378. }
  4379. };
  4380. Element.prototype.getTextGuideLine = function () {
  4381. return this._textGuide;
  4382. };
  4383. Element.prototype.setTextGuideLine = function (guideLine) {
  4384. if (this._textGuide && this._textGuide !== guideLine) {
  4385. this.removeTextGuideLine();
  4386. }
  4387. this._attachComponent(guideLine);
  4388. this._textGuide = guideLine;
  4389. this.markRedraw();
  4390. };
  4391. Element.prototype.removeTextGuideLine = function () {
  4392. var textGuide = this._textGuide;
  4393. if (textGuide) {
  4394. this._detachComponent(textGuide);
  4395. this._textGuide = null;
  4396. this.markRedraw();
  4397. }
  4398. };
  4399. Element.prototype.markRedraw = function () {
  4400. this.__dirty |= Element.REDARAW_BIT;
  4401. var zr = this.__zr;
  4402. if (zr) {
  4403. if (this.__inHover) {
  4404. zr.refreshHover();
  4405. } else {
  4406. zr.refresh();
  4407. }
  4408. }
  4409. if (this.__hostTarget) {
  4410. this.__hostTarget.markRedraw();
  4411. }
  4412. };
  4413. Element.prototype.dirty = function () {
  4414. this.markRedraw();
  4415. };
  4416. Element.prototype._toggleHoverLayerFlag = function (inHover) {
  4417. this.__inHover = inHover;
  4418. var textContent = this._textContent;
  4419. var textGuide = this._textGuide;
  4420. if (textContent) {
  4421. textContent.__inHover = inHover;
  4422. }
  4423. if (textGuide) {
  4424. textGuide.__inHover = inHover;
  4425. }
  4426. };
  4427. Element.prototype.addSelfToZr = function (zr) {
  4428. this.__zr = zr;
  4429. var animators = this.animators;
  4430. if (animators) {
  4431. for (var i = 0; i < animators.length; i++) {
  4432. zr.animation.addAnimator(animators[i]);
  4433. }
  4434. }
  4435. if (this._clipPath) {
  4436. this._clipPath.addSelfToZr(zr);
  4437. }
  4438. if (this._textContent) {
  4439. this._textContent.addSelfToZr(zr);
  4440. }
  4441. if (this._textGuide) {
  4442. this._textGuide.addSelfToZr(zr);
  4443. }
  4444. };
  4445. Element.prototype.removeSelfFromZr = function (zr) {
  4446. this.__zr = null;
  4447. var animators = this.animators;
  4448. if (animators) {
  4449. for (var i = 0; i < animators.length; i++) {
  4450. zr.animation.removeAnimator(animators[i]);
  4451. }
  4452. }
  4453. if (this._clipPath) {
  4454. this._clipPath.removeSelfFromZr(zr);
  4455. }
  4456. if (this._textContent) {
  4457. this._textContent.removeSelfFromZr(zr);
  4458. }
  4459. if (this._textGuide) {
  4460. this._textGuide.removeSelfFromZr(zr);
  4461. }
  4462. };
  4463. Element.prototype.animate = function (key, loop) {
  4464. var target = key ? this[key] : this;
  4465. if (!target) {
  4466. logError('Property "' + key + '" is not existed in element ' + this.id);
  4467. return;
  4468. }
  4469. var animator = new Animator(target, loop);
  4470. this.addAnimator(animator, key);
  4471. return animator;
  4472. };
  4473. Element.prototype.addAnimator = function (animator, key) {
  4474. var zr = this.__zr;
  4475. var el = this;
  4476. animator.during(function () {
  4477. el.updateDuringAnimation(key);
  4478. }).done(function () {
  4479. var animators = el.animators;
  4480. var idx = indexOf$1(animators, animator);
  4481. if (idx >= 0) {
  4482. animators.splice(idx, 1);
  4483. }
  4484. });
  4485. this.animators.push(animator);
  4486. if (zr) {
  4487. zr.animation.addAnimator(animator);
  4488. }
  4489. zr && zr.wakeUp();
  4490. };
  4491. Element.prototype.updateDuringAnimation = function (key) {
  4492. this.markRedraw();
  4493. };
  4494. Element.prototype.stopAnimation = function (scope, forwardToLast) {
  4495. var animators = this.animators;
  4496. var len = animators.length;
  4497. var leftAnimators = [];
  4498. for (var i = 0; i < len; i++) {
  4499. var animator = animators[i];
  4500. if (!scope || scope === animator.scope) {
  4501. animator.stop(forwardToLast);
  4502. } else {
  4503. leftAnimators.push(animator);
  4504. }
  4505. }
  4506. this.animators = leftAnimators;
  4507. return this;
  4508. };
  4509. Element.prototype.animateTo = function (target, cfg, animationProps) {
  4510. animateTo(this, target, cfg, animationProps);
  4511. };
  4512. Element.prototype.animateFrom = function (target, cfg, animationProps) {
  4513. animateTo(this, target, cfg, animationProps, true);
  4514. };
  4515. Element.prototype._transitionState = function (stateName, target, cfg, animationProps) {
  4516. var animators = animateTo(this, target, cfg, animationProps);
  4517. for (var i = 0; i < animators.length; i++) {
  4518. animators[i].__fromStateTransition = stateName;
  4519. }
  4520. };
  4521. Element.prototype.getBoundingRect = function () {
  4522. return null;
  4523. };
  4524. Element.prototype.getPaintRect = function () {
  4525. return null;
  4526. };
  4527. Element.REDARAW_BIT = 1;
  4528. Element.initDefaultProps = function () {
  4529. var elProto = Element.prototype;
  4530. elProto.type = 'element';
  4531. elProto.name = '';
  4532. elProto.ignore = false;
  4533. elProto.silent = false;
  4534. elProto.isGroup = false;
  4535. elProto.draggable = false;
  4536. elProto.dragging = false;
  4537. elProto.ignoreClip = false;
  4538. elProto.__inHover = false;
  4539. elProto.__dirty = Element.REDARAW_BIT;
  4540. var logs = {};
  4541. function logDeprecatedError(key, xKey, yKey) {
  4542. if (!logs[key + xKey + yKey]) {
  4543. console.warn("DEPRECATED: '" + key + "' has been deprecated. use '" + xKey + "', '" + yKey + "' instead");
  4544. logs[key + xKey + yKey] = true;
  4545. }
  4546. }
  4547. function createLegacyProperty(key, privateKey, xKey, yKey) {
  4548. Object.defineProperty(elProto, key, {
  4549. get: function () {
  4550. logDeprecatedError(key, xKey, yKey);
  4551. if (!this[privateKey]) {
  4552. var pos = this[privateKey] = [];
  4553. enhanceArray(this, pos);
  4554. }
  4555. return this[privateKey];
  4556. },
  4557. set: function (pos) {
  4558. logDeprecatedError(key, xKey, yKey);
  4559. this[xKey] = pos[0];
  4560. this[yKey] = pos[1];
  4561. this[privateKey] = pos;
  4562. enhanceArray(this, pos);
  4563. }
  4564. });
  4565. function enhanceArray(self, pos) {
  4566. Object.defineProperty(pos, 0, {
  4567. get: function () {
  4568. return self[xKey];
  4569. },
  4570. set: function (val) {
  4571. self[xKey] = val;
  4572. }
  4573. });
  4574. Object.defineProperty(pos, 1, {
  4575. get: function () {
  4576. return self[yKey];
  4577. },
  4578. set: function (val) {
  4579. self[yKey] = val;
  4580. }
  4581. });
  4582. }
  4583. }
  4584. if (Object.defineProperty && (!env.browser.ie || env.browser.version > 8)) {
  4585. createLegacyProperty('position', '_legacyPos', 'x', 'y');
  4586. createLegacyProperty('scale', '_legacyScale', 'scaleX', 'scaleY');
  4587. createLegacyProperty('origin', '_legacyOrigin', 'originX', 'originY');
  4588. }
  4589. }();
  4590. return Element;
  4591. }();
  4592. mixin(Element, Eventful);
  4593. mixin(Element, Transformable);
  4594. function animateTo(animatable, target, cfg, animationProps, reverse) {
  4595. cfg = cfg || {};
  4596. var animators = [];
  4597. animateToShallow(animatable, '', animatable, target, cfg, animationProps, animators, reverse);
  4598. var finishCount = animators.length;
  4599. var doneHappened = false;
  4600. var cfgDone = cfg.done;
  4601. var cfgAborted = cfg.aborted;
  4602. var doneCb = function () {
  4603. doneHappened = true;
  4604. finishCount--;
  4605. if (finishCount <= 0) {
  4606. doneHappened ? cfgDone && cfgDone() : cfgAborted && cfgAborted();
  4607. }
  4608. };
  4609. var abortedCb = function () {
  4610. finishCount--;
  4611. if (finishCount <= 0) {
  4612. doneHappened ? cfgDone && cfgDone() : cfgAborted && cfgAborted();
  4613. }
  4614. };
  4615. if (!finishCount) {
  4616. cfgDone && cfgDone();
  4617. }
  4618. if (animators.length > 0 && cfg.during) {
  4619. animators[0].during(function (target, percent) {
  4620. cfg.during(percent);
  4621. });
  4622. }
  4623. for (var i = 0; i < animators.length; i++) {
  4624. var animator = animators[i];
  4625. if (doneCb) {
  4626. animator.done(doneCb);
  4627. }
  4628. if (abortedCb) {
  4629. animator.aborted(abortedCb);
  4630. }
  4631. animator.start(cfg.easing, cfg.force);
  4632. }
  4633. return animators;
  4634. }
  4635. function copyArrShallow(source, target, len) {
  4636. for (var i = 0; i < len; i++) {
  4637. source[i] = target[i];
  4638. }
  4639. }
  4640. function is2DArray(value) {
  4641. return isArrayLike(value[0]);
  4642. }
  4643. function copyValue(target, source, key) {
  4644. if (isArrayLike(source[key])) {
  4645. if (!isArrayLike(target[key])) {
  4646. target[key] = [];
  4647. }
  4648. if (isTypedArray(source[key])) {
  4649. var len = source[key].length;
  4650. if (target[key].length !== len) {
  4651. target[key] = new source[key].constructor(len);
  4652. copyArrShallow(target[key], source[key], len);
  4653. }
  4654. } else {
  4655. var sourceArr = source[key];
  4656. var targetArr = target[key];
  4657. var len0 = sourceArr.length;
  4658. if (is2DArray(sourceArr)) {
  4659. var len1 = sourceArr[0].length;
  4660. for (var i = 0; i < len0; i++) {
  4661. if (!targetArr[i]) {
  4662. targetArr[i] = Array.prototype.slice.call(sourceArr[i]);
  4663. } else {
  4664. copyArrShallow(targetArr[i], sourceArr[i], len1);
  4665. }
  4666. }
  4667. } else {
  4668. copyArrShallow(targetArr, sourceArr, len0);
  4669. }
  4670. targetArr.length = sourceArr.length;
  4671. }
  4672. } else {
  4673. target[key] = source[key];
  4674. }
  4675. }
  4676. function animateToShallow(animatable, topKey, source, target, cfg, animationProps, animators, reverse) {
  4677. var animatableKeys = [];
  4678. var changedKeys = [];
  4679. var targetKeys = keys(target);
  4680. var duration = cfg.duration;
  4681. var delay = cfg.delay;
  4682. var additive = cfg.additive;
  4683. var setToFinal = cfg.setToFinal;
  4684. var animateAll = !isObject$1(animationProps);
  4685. for (var k = 0; k < targetKeys.length; k++) {
  4686. var innerKey = targetKeys[k];
  4687. if (source[innerKey] != null && target[innerKey] != null && (animateAll || animationProps[innerKey])) {
  4688. if (isObject$1(target[innerKey]) && !isArrayLike(target[innerKey])) {
  4689. if (topKey) {
  4690. if (!reverse) {
  4691. source[innerKey] = target[innerKey];
  4692. animatable.updateDuringAnimation(topKey);
  4693. }
  4694. continue;
  4695. }
  4696. animateToShallow(animatable, innerKey, source[innerKey], target[innerKey], cfg, animationProps && animationProps[innerKey], animators, reverse);
  4697. } else {
  4698. animatableKeys.push(innerKey);
  4699. changedKeys.push(innerKey);
  4700. }
  4701. } else if (!reverse) {
  4702. source[innerKey] = target[innerKey];
  4703. animatable.updateDuringAnimation(topKey);
  4704. changedKeys.push(innerKey);
  4705. }
  4706. }
  4707. var keyLen = animatableKeys.length;
  4708. if (keyLen > 0 || cfg.force && !animators.length) {
  4709. var existsAnimators = animatable.animators;
  4710. var existsAnimatorsOnSameTarget = [];
  4711. for (var i = 0; i < existsAnimators.length; i++) {
  4712. if (existsAnimators[i].targetName === topKey) {
  4713. existsAnimatorsOnSameTarget.push(existsAnimators[i]);
  4714. }
  4715. }
  4716. if (!additive && existsAnimatorsOnSameTarget.length) {
  4717. for (var i = 0; i < existsAnimatorsOnSameTarget.length; i++) {
  4718. var allAborted = existsAnimatorsOnSameTarget[i].stopTracks(changedKeys);
  4719. if (allAborted) {
  4720. var idx = indexOf$1(existsAnimators, existsAnimatorsOnSameTarget[i]);
  4721. existsAnimators.splice(idx, 1);
  4722. }
  4723. }
  4724. }
  4725. var revertedSource = void 0;
  4726. var reversedTarget = void 0;
  4727. var sourceClone = void 0;
  4728. if (reverse) {
  4729. reversedTarget = {};
  4730. if (setToFinal) {
  4731. revertedSource = {};
  4732. }
  4733. for (var i = 0; i < keyLen; i++) {
  4734. var innerKey = animatableKeys[i];
  4735. reversedTarget[innerKey] = source[innerKey];
  4736. if (setToFinal) {
  4737. revertedSource[innerKey] = target[innerKey];
  4738. } else {
  4739. source[innerKey] = target[innerKey];
  4740. }
  4741. }
  4742. } else if (setToFinal) {
  4743. sourceClone = {};
  4744. for (var i = 0; i < keyLen; i++) {
  4745. var innerKey = animatableKeys[i];
  4746. sourceClone[innerKey] = cloneValue(source[innerKey]);
  4747. copyValue(source, target, innerKey);
  4748. }
  4749. }
  4750. var animator = new Animator(source, false, additive ? existsAnimatorsOnSameTarget : null);
  4751. animator.targetName = topKey;
  4752. if (cfg.scope) {
  4753. animator.scope = cfg.scope;
  4754. }
  4755. if (setToFinal && revertedSource) {
  4756. animator.whenWithKeys(0, revertedSource, animatableKeys);
  4757. }
  4758. if (sourceClone) {
  4759. animator.whenWithKeys(0, sourceClone, animatableKeys);
  4760. }
  4761. animator.whenWithKeys(duration == null ? 500 : duration, reverse ? reversedTarget : target, animatableKeys).delay(delay || 0);
  4762. animatable.addAnimator(animator, topKey);
  4763. animators.push(animator);
  4764. }
  4765. }
  4766. var DEFAULT_MIN_MERGE = 32;
  4767. var DEFAULT_MIN_GALLOPING = 7;
  4768. function minRunLength(n) {
  4769. var r = 0;
  4770. while (n >= DEFAULT_MIN_MERGE) {
  4771. r |= n & 1;
  4772. n >>= 1;
  4773. }
  4774. return n + r;
  4775. }
  4776. function makeAscendingRun(array, lo, hi, compare) {
  4777. var runHi = lo + 1;
  4778. if (runHi === hi) {
  4779. return 1;
  4780. }
  4781. if (compare(array[runHi++], array[lo]) < 0) {
  4782. while (runHi < hi && compare(array[runHi], array[runHi - 1]) < 0) {
  4783. runHi++;
  4784. }
  4785. reverseRun(array, lo, runHi);
  4786. } else {
  4787. while (runHi < hi && compare(array[runHi], array[runHi - 1]) >= 0) {
  4788. runHi++;
  4789. }
  4790. }
  4791. return runHi - lo;
  4792. }
  4793. function reverseRun(array, lo, hi) {
  4794. hi--;
  4795. while (lo < hi) {
  4796. var t = array[lo];
  4797. array[lo++] = array[hi];
  4798. array[hi--] = t;
  4799. }
  4800. }
  4801. function binaryInsertionSort(array, lo, hi, start, compare) {
  4802. if (start === lo) {
  4803. start++;
  4804. }
  4805. for (; start < hi; start++) {
  4806. var pivot = array[start];
  4807. var left = lo;
  4808. var right = start;
  4809. var mid;
  4810. while (left < right) {
  4811. mid = left + right >>> 1;
  4812. if (compare(pivot, array[mid]) < 0) {
  4813. right = mid;
  4814. } else {
  4815. left = mid + 1;
  4816. }
  4817. }
  4818. var n = start - left;
  4819. switch (n) {
  4820. case 3:
  4821. array[left + 3] = array[left + 2];
  4822. case 2:
  4823. array[left + 2] = array[left + 1];
  4824. case 1:
  4825. array[left + 1] = array[left];
  4826. break;
  4827. default:
  4828. while (n > 0) {
  4829. array[left + n] = array[left + n - 1];
  4830. n--;
  4831. }
  4832. }
  4833. array[left] = pivot;
  4834. }
  4835. }
  4836. function gallopLeft(value, array, start, length, hint, compare) {
  4837. var lastOffset = 0;
  4838. var maxOffset = 0;
  4839. var offset = 1;
  4840. if (compare(value, array[start + hint]) > 0) {
  4841. maxOffset = length - hint;
  4842. while (offset < maxOffset && compare(value, array[start + hint + offset]) > 0) {
  4843. lastOffset = offset;
  4844. offset = (offset << 1) + 1;
  4845. if (offset <= 0) {
  4846. offset = maxOffset;
  4847. }
  4848. }
  4849. if (offset > maxOffset) {
  4850. offset = maxOffset;
  4851. }
  4852. lastOffset += hint;
  4853. offset += hint;
  4854. } else {
  4855. maxOffset = hint + 1;
  4856. while (offset < maxOffset && compare(value, array[start + hint - offset]) <= 0) {
  4857. lastOffset = offset;
  4858. offset = (offset << 1) + 1;
  4859. if (offset <= 0) {
  4860. offset = maxOffset;
  4861. }
  4862. }
  4863. if (offset > maxOffset) {
  4864. offset = maxOffset;
  4865. }
  4866. var tmp = lastOffset;
  4867. lastOffset = hint - offset;
  4868. offset = hint - tmp;
  4869. }
  4870. lastOffset++;
  4871. while (lastOffset < offset) {
  4872. var m = lastOffset + (offset - lastOffset >>> 1);
  4873. if (compare(value, array[start + m]) > 0) {
  4874. lastOffset = m + 1;
  4875. } else {
  4876. offset = m;
  4877. }
  4878. }
  4879. return offset;
  4880. }
  4881. function gallopRight(value, array, start, length, hint, compare) {
  4882. var lastOffset = 0;
  4883. var maxOffset = 0;
  4884. var offset = 1;
  4885. if (compare(value, array[start + hint]) < 0) {
  4886. maxOffset = hint + 1;
  4887. while (offset < maxOffset && compare(value, array[start + hint - offset]) < 0) {
  4888. lastOffset = offset;
  4889. offset = (offset << 1) + 1;
  4890. if (offset <= 0) {
  4891. offset = maxOffset;
  4892. }
  4893. }
  4894. if (offset > maxOffset) {
  4895. offset = maxOffset;
  4896. }
  4897. var tmp = lastOffset;
  4898. lastOffset = hint - offset;
  4899. offset = hint - tmp;
  4900. } else {
  4901. maxOffset = length - hint;
  4902. while (offset < maxOffset && compare(value, array[start + hint + offset]) >= 0) {
  4903. lastOffset = offset;
  4904. offset = (offset << 1) + 1;
  4905. if (offset <= 0) {
  4906. offset = maxOffset;
  4907. }
  4908. }
  4909. if (offset > maxOffset) {
  4910. offset = maxOffset;
  4911. }
  4912. lastOffset += hint;
  4913. offset += hint;
  4914. }
  4915. lastOffset++;
  4916. while (lastOffset < offset) {
  4917. var m = lastOffset + (offset - lastOffset >>> 1);
  4918. if (compare(value, array[start + m]) < 0) {
  4919. offset = m;
  4920. } else {
  4921. lastOffset = m + 1;
  4922. }
  4923. }
  4924. return offset;
  4925. }
  4926. function TimSort(array, compare) {
  4927. var minGallop = DEFAULT_MIN_GALLOPING;
  4928. var runStart;
  4929. var runLength;
  4930. var stackSize = 0;
  4931. var tmp = [];
  4932. runStart = [];
  4933. runLength = [];
  4934. function pushRun(_runStart, _runLength) {
  4935. runStart[stackSize] = _runStart;
  4936. runLength[stackSize] = _runLength;
  4937. stackSize += 1;
  4938. }
  4939. function mergeRuns() {
  4940. while (stackSize > 1) {
  4941. var n = stackSize - 2;
  4942. if (n >= 1 && runLength[n - 1] <= runLength[n] + runLength[n + 1] || n >= 2 && runLength[n - 2] <= runLength[n] + runLength[n - 1]) {
  4943. if (runLength[n - 1] < runLength[n + 1]) {
  4944. n--;
  4945. }
  4946. } else if (runLength[n] > runLength[n + 1]) {
  4947. break;
  4948. }
  4949. mergeAt(n);
  4950. }
  4951. }
  4952. function forceMergeRuns() {
  4953. while (stackSize > 1) {
  4954. var n = stackSize - 2;
  4955. if (n > 0 && runLength[n - 1] < runLength[n + 1]) {
  4956. n--;
  4957. }
  4958. mergeAt(n);
  4959. }
  4960. }
  4961. function mergeAt(i) {
  4962. var start1 = runStart[i];
  4963. var length1 = runLength[i];
  4964. var start2 = runStart[i + 1];
  4965. var length2 = runLength[i + 1];
  4966. runLength[i] = length1 + length2;
  4967. if (i === stackSize - 3) {
  4968. runStart[i + 1] = runStart[i + 2];
  4969. runLength[i + 1] = runLength[i + 2];
  4970. }
  4971. stackSize--;
  4972. var k = gallopRight(array[start2], array, start1, length1, 0, compare);
  4973. start1 += k;
  4974. length1 -= k;
  4975. if (length1 === 0) {
  4976. return;
  4977. }
  4978. length2 = gallopLeft(array[start1 + length1 - 1], array, start2, length2, length2 - 1, compare);
  4979. if (length2 === 0) {
  4980. return;
  4981. }
  4982. if (length1 <= length2) {
  4983. mergeLow(start1, length1, start2, length2);
  4984. } else {
  4985. mergeHigh(start1, length1, start2, length2);
  4986. }
  4987. }
  4988. function mergeLow(start1, length1, start2, length2) {
  4989. var i = 0;
  4990. for (i = 0; i < length1; i++) {
  4991. tmp[i] = array[start1 + i];
  4992. }
  4993. var cursor1 = 0;
  4994. var cursor2 = start2;
  4995. var dest = start1;
  4996. array[dest++] = array[cursor2++];
  4997. if (--length2 === 0) {
  4998. for (i = 0; i < length1; i++) {
  4999. array[dest + i] = tmp[cursor1 + i];
  5000. }
  5001. return;
  5002. }
  5003. if (length1 === 1) {
  5004. for (i = 0; i < length2; i++) {
  5005. array[dest + i] = array[cursor2 + i];
  5006. }
  5007. array[dest + length2] = tmp[cursor1];
  5008. return;
  5009. }
  5010. var _minGallop = minGallop;
  5011. var count1;
  5012. var count2;
  5013. var exit;
  5014. while (1) {
  5015. count1 = 0;
  5016. count2 = 0;
  5017. exit = false;
  5018. do {
  5019. if (compare(array[cursor2], tmp[cursor1]) < 0) {
  5020. array[dest++] = array[cursor2++];
  5021. count2++;
  5022. count1 = 0;
  5023. if (--length2 === 0) {
  5024. exit = true;
  5025. break;
  5026. }
  5027. } else {
  5028. array[dest++] = tmp[cursor1++];
  5029. count1++;
  5030. count2 = 0;
  5031. if (--length1 === 1) {
  5032. exit = true;
  5033. break;
  5034. }
  5035. }
  5036. } while ((count1 | count2) < _minGallop);
  5037. if (exit) {
  5038. break;
  5039. }
  5040. do {
  5041. count1 = gallopRight(array[cursor2], tmp, cursor1, length1, 0, compare);
  5042. if (count1 !== 0) {
  5043. for (i = 0; i < count1; i++) {
  5044. array[dest + i] = tmp[cursor1 + i];
  5045. }
  5046. dest += count1;
  5047. cursor1 += count1;
  5048. length1 -= count1;
  5049. if (length1 <= 1) {
  5050. exit = true;
  5051. break;
  5052. }
  5053. }
  5054. array[dest++] = array[cursor2++];
  5055. if (--length2 === 0) {
  5056. exit = true;
  5057. break;
  5058. }
  5059. count2 = gallopLeft(tmp[cursor1], array, cursor2, length2, 0, compare);
  5060. if (count2 !== 0) {
  5061. for (i = 0; i < count2; i++) {
  5062. array[dest + i] = array[cursor2 + i];
  5063. }
  5064. dest += count2;
  5065. cursor2 += count2;
  5066. length2 -= count2;
  5067. if (length2 === 0) {
  5068. exit = true;
  5069. break;
  5070. }
  5071. }
  5072. array[dest++] = tmp[cursor1++];
  5073. if (--length1 === 1) {
  5074. exit = true;
  5075. break;
  5076. }
  5077. _minGallop--;
  5078. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  5079. if (exit) {
  5080. break;
  5081. }
  5082. if (_minGallop < 0) {
  5083. _minGallop = 0;
  5084. }
  5085. _minGallop += 2;
  5086. }
  5087. minGallop = _minGallop;
  5088. minGallop < 1 && (minGallop = 1);
  5089. if (length1 === 1) {
  5090. for (i = 0; i < length2; i++) {
  5091. array[dest + i] = array[cursor2 + i];
  5092. }
  5093. array[dest + length2] = tmp[cursor1];
  5094. } else if (length1 === 0) {
  5095. throw new Error();
  5096. } else {
  5097. for (i = 0; i < length1; i++) {
  5098. array[dest + i] = tmp[cursor1 + i];
  5099. }
  5100. }
  5101. }
  5102. function mergeHigh(start1, length1, start2, length2) {
  5103. var i = 0;
  5104. for (i = 0; i < length2; i++) {
  5105. tmp[i] = array[start2 + i];
  5106. }
  5107. var cursor1 = start1 + length1 - 1;
  5108. var cursor2 = length2 - 1;
  5109. var dest = start2 + length2 - 1;
  5110. var customCursor = 0;
  5111. var customDest = 0;
  5112. array[dest--] = array[cursor1--];
  5113. if (--length1 === 0) {
  5114. customCursor = dest - (length2 - 1);
  5115. for (i = 0; i < length2; i++) {
  5116. array[customCursor + i] = tmp[i];
  5117. }
  5118. return;
  5119. }
  5120. if (length2 === 1) {
  5121. dest -= length1;
  5122. cursor1 -= length1;
  5123. customDest = dest + 1;
  5124. customCursor = cursor1 + 1;
  5125. for (i = length1 - 1; i >= 0; i--) {
  5126. array[customDest + i] = array[customCursor + i];
  5127. }
  5128. array[dest] = tmp[cursor2];
  5129. return;
  5130. }
  5131. var _minGallop = minGallop;
  5132. while (true) {
  5133. var count1 = 0;
  5134. var count2 = 0;
  5135. var exit = false;
  5136. do {
  5137. if (compare(tmp[cursor2], array[cursor1]) < 0) {
  5138. array[dest--] = array[cursor1--];
  5139. count1++;
  5140. count2 = 0;
  5141. if (--length1 === 0) {
  5142. exit = true;
  5143. break;
  5144. }
  5145. } else {
  5146. array[dest--] = tmp[cursor2--];
  5147. count2++;
  5148. count1 = 0;
  5149. if (--length2 === 1) {
  5150. exit = true;
  5151. break;
  5152. }
  5153. }
  5154. } while ((count1 | count2) < _minGallop);
  5155. if (exit) {
  5156. break;
  5157. }
  5158. do {
  5159. count1 = length1 - gallopRight(tmp[cursor2], array, start1, length1, length1 - 1, compare);
  5160. if (count1 !== 0) {
  5161. dest -= count1;
  5162. cursor1 -= count1;
  5163. length1 -= count1;
  5164. customDest = dest + 1;
  5165. customCursor = cursor1 + 1;
  5166. for (i = count1 - 1; i >= 0; i--) {
  5167. array[customDest + i] = array[customCursor + i];
  5168. }
  5169. if (length1 === 0) {
  5170. exit = true;
  5171. break;
  5172. }
  5173. }
  5174. array[dest--] = tmp[cursor2--];
  5175. if (--length2 === 1) {
  5176. exit = true;
  5177. break;
  5178. }
  5179. count2 = length2 - gallopLeft(array[cursor1], tmp, 0, length2, length2 - 1, compare);
  5180. if (count2 !== 0) {
  5181. dest -= count2;
  5182. cursor2 -= count2;
  5183. length2 -= count2;
  5184. customDest = dest + 1;
  5185. customCursor = cursor2 + 1;
  5186. for (i = 0; i < count2; i++) {
  5187. array[customDest + i] = tmp[customCursor + i];
  5188. }
  5189. if (length2 <= 1) {
  5190. exit = true;
  5191. break;
  5192. }
  5193. }
  5194. array[dest--] = array[cursor1--];
  5195. if (--length1 === 0) {
  5196. exit = true;
  5197. break;
  5198. }
  5199. _minGallop--;
  5200. } while (count1 >= DEFAULT_MIN_GALLOPING || count2 >= DEFAULT_MIN_GALLOPING);
  5201. if (exit) {
  5202. break;
  5203. }
  5204. if (_minGallop < 0) {
  5205. _minGallop = 0;
  5206. }
  5207. _minGallop += 2;
  5208. }
  5209. minGallop = _minGallop;
  5210. if (minGallop < 1) {
  5211. minGallop = 1;
  5212. }
  5213. if (length2 === 1) {
  5214. dest -= length1;
  5215. cursor1 -= length1;
  5216. customDest = dest + 1;
  5217. customCursor = cursor1 + 1;
  5218. for (i = length1 - 1; i >= 0; i--) {
  5219. array[customDest + i] = array[customCursor + i];
  5220. }
  5221. array[dest] = tmp[cursor2];
  5222. } else if (length2 === 0) {
  5223. throw new Error();
  5224. } else {
  5225. customCursor = dest - (length2 - 1);
  5226. for (i = 0; i < length2; i++) {
  5227. array[customCursor + i] = tmp[i];
  5228. }
  5229. }
  5230. }
  5231. return {
  5232. mergeRuns: mergeRuns,
  5233. forceMergeRuns: forceMergeRuns,
  5234. pushRun: pushRun
  5235. };
  5236. }
  5237. function sort(array, compare, lo, hi) {
  5238. if (!lo) {
  5239. lo = 0;
  5240. }
  5241. if (!hi) {
  5242. hi = array.length;
  5243. }
  5244. var remaining = hi - lo;
  5245. if (remaining < 2) {
  5246. return;
  5247. }
  5248. var runLength = 0;
  5249. if (remaining < DEFAULT_MIN_MERGE) {
  5250. runLength = makeAscendingRun(array, lo, hi, compare);
  5251. binaryInsertionSort(array, lo, hi, lo + runLength, compare);
  5252. return;
  5253. }
  5254. var ts = TimSort(array, compare);
  5255. var minRun = minRunLength(remaining);
  5256. do {
  5257. runLength = makeAscendingRun(array, lo, hi, compare);
  5258. if (runLength < minRun) {
  5259. var force = remaining;
  5260. if (force > minRun) {
  5261. force = minRun;
  5262. }
  5263. binaryInsertionSort(array, lo, lo + force, lo + runLength, compare);
  5264. runLength = force;
  5265. }
  5266. ts.pushRun(lo, runLength);
  5267. ts.mergeRuns();
  5268. remaining -= runLength;
  5269. lo += runLength;
  5270. } while (remaining !== 0);
  5271. ts.forceMergeRuns();
  5272. }
  5273. var invalidZErrorLogged = false;
  5274. function logInvalidZError() {
  5275. if (invalidZErrorLogged) {
  5276. return;
  5277. }
  5278. invalidZErrorLogged = true;
  5279. console.warn('z / z2 / zlevel of displayable is invalid, which may cause unexpected errors');
  5280. }
  5281. function shapeCompareFunc(a, b) {
  5282. if (a.zlevel === b.zlevel) {
  5283. if (a.z === b.z) {
  5284. return a.z2 - b.z2;
  5285. }
  5286. return a.z - b.z;
  5287. }
  5288. return a.zlevel - b.zlevel;
  5289. }
  5290. var Storage = function () {
  5291. function Storage() {
  5292. this._roots = [];
  5293. this._displayList = [];
  5294. this._displayListLen = 0;
  5295. this.displayableSortFunc = shapeCompareFunc;
  5296. }
  5297. Storage.prototype.traverse = function (cb, context) {
  5298. for (var i = 0; i < this._roots.length; i++) {
  5299. this._roots[i].traverse(cb, context);
  5300. }
  5301. };
  5302. Storage.prototype.getDisplayList = function (update, includeIgnore) {
  5303. includeIgnore = includeIgnore || false;
  5304. var displayList = this._displayList;
  5305. if (update || !displayList.length) {
  5306. this.updateDisplayList(includeIgnore);
  5307. }
  5308. return displayList;
  5309. };
  5310. Storage.prototype.updateDisplayList = function (includeIgnore) {
  5311. this._displayListLen = 0;
  5312. var roots = this._roots;
  5313. var displayList = this._displayList;
  5314. for (var i = 0, len = roots.length; i < len; i++) {
  5315. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  5316. }
  5317. displayList.length = this._displayListLen;
  5318. env.canvasSupported && sort(displayList, shapeCompareFunc);
  5319. };
  5320. Storage.prototype._updateAndAddDisplayable = function (el, clipPaths, includeIgnore) {
  5321. if (el.ignore && !includeIgnore) {
  5322. return;
  5323. }
  5324. el.beforeUpdate();
  5325. el.update();
  5326. el.afterUpdate();
  5327. var userSetClipPath = el.getClipPath();
  5328. if (el.ignoreClip) {
  5329. clipPaths = null;
  5330. } else if (userSetClipPath) {
  5331. if (clipPaths) {
  5332. clipPaths = clipPaths.slice();
  5333. } else {
  5334. clipPaths = [];
  5335. }
  5336. var currentClipPath = userSetClipPath;
  5337. var parentClipPath = el;
  5338. while (currentClipPath) {
  5339. currentClipPath.parent = parentClipPath;
  5340. currentClipPath.updateTransform();
  5341. clipPaths.push(currentClipPath);
  5342. parentClipPath = currentClipPath;
  5343. currentClipPath = currentClipPath.getClipPath();
  5344. }
  5345. }
  5346. if (el.childrenRef) {
  5347. var children = el.childrenRef();
  5348. for (var i = 0; i < children.length; i++) {
  5349. var child = children[i];
  5350. if (el.__dirty) {
  5351. child.__dirty |= Element.REDARAW_BIT;
  5352. }
  5353. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  5354. }
  5355. el.__dirty = 0;
  5356. } else {
  5357. var disp = el;
  5358. if (clipPaths && clipPaths.length) {
  5359. disp.__clipPaths = clipPaths;
  5360. } else if (disp.__clipPaths && disp.__clipPaths.length > 0) {
  5361. disp.__clipPaths = [];
  5362. }
  5363. if (isNaN(disp.z)) {
  5364. logInvalidZError();
  5365. disp.z = 0;
  5366. }
  5367. if (isNaN(disp.z2)) {
  5368. logInvalidZError();
  5369. disp.z2 = 0;
  5370. }
  5371. if (isNaN(disp.zlevel)) {
  5372. logInvalidZError();
  5373. disp.zlevel = 0;
  5374. }
  5375. this._displayList[this._displayListLen++] = disp;
  5376. }
  5377. var decalEl = el.getDecalElement && el.getDecalElement();
  5378. if (decalEl) {
  5379. this._updateAndAddDisplayable(decalEl, clipPaths, includeIgnore);
  5380. }
  5381. var textGuide = el.getTextGuideLine();
  5382. if (textGuide) {
  5383. this._updateAndAddDisplayable(textGuide, clipPaths, includeIgnore);
  5384. }
  5385. var textEl = el.getTextContent();
  5386. if (textEl) {
  5387. this._updateAndAddDisplayable(textEl, clipPaths, includeIgnore);
  5388. }
  5389. };
  5390. Storage.prototype.addRoot = function (el) {
  5391. if (el.__zr && el.__zr.storage === this) {
  5392. return;
  5393. }
  5394. this._roots.push(el);
  5395. };
  5396. Storage.prototype.delRoot = function (el) {
  5397. if (el instanceof Array) {
  5398. for (var i = 0, l = el.length; i < l; i++) {
  5399. this.delRoot(el[i]);
  5400. }
  5401. return;
  5402. }
  5403. var idx = indexOf$1(this._roots, el);
  5404. if (idx >= 0) {
  5405. this._roots.splice(idx, 1);
  5406. }
  5407. };
  5408. Storage.prototype.delAllRoots = function () {
  5409. this._roots = [];
  5410. this._displayList = [];
  5411. this._displayListLen = 0;
  5412. return;
  5413. };
  5414. Storage.prototype.getRoots = function () {
  5415. return this._roots;
  5416. };
  5417. Storage.prototype.dispose = function () {
  5418. this._displayList = null;
  5419. this._roots = null;
  5420. };
  5421. return Storage;
  5422. }();
  5423. var requestAnimationFrame;
  5424. requestAnimationFrame = typeof window !== 'undefined' && (window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.msRequestAnimationFrame && window.msRequestAnimationFrame.bind(window) || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame) || function (func) {
  5425. return setTimeout(func, 16);
  5426. };
  5427. var requestAnimationFrame$1 = requestAnimationFrame;
  5428. var Animation = function (_super) {
  5429. __extends(Animation, _super);
  5430. function Animation(opts) {
  5431. var _this = _super.call(this) || this;
  5432. _this._running = false;
  5433. _this._time = 0;
  5434. _this._pausedTime = 0;
  5435. _this._pauseStart = 0;
  5436. _this._paused = false;
  5437. opts = opts || {};
  5438. _this.stage = opts.stage || {};
  5439. _this.onframe = opts.onframe || function () {};
  5440. return _this;
  5441. }
  5442. Animation.prototype.addClip = function (clip) {
  5443. if (clip.animation) {
  5444. this.removeClip(clip);
  5445. }
  5446. if (!this._clipsHead) {
  5447. this._clipsHead = this._clipsTail = clip;
  5448. } else {
  5449. this._clipsTail.next = clip;
  5450. clip.prev = this._clipsTail;
  5451. clip.next = null;
  5452. this._clipsTail = clip;
  5453. }
  5454. clip.animation = this;
  5455. };
  5456. Animation.prototype.addAnimator = function (animator) {
  5457. animator.animation = this;
  5458. var clip = animator.getClip();
  5459. if (clip) {
  5460. this.addClip(clip);
  5461. }
  5462. };
  5463. Animation.prototype.removeClip = function (clip) {
  5464. if (!clip.animation) {
  5465. return;
  5466. }
  5467. var prev = clip.prev;
  5468. var next = clip.next;
  5469. if (prev) {
  5470. prev.next = next;
  5471. } else {
  5472. this._clipsHead = next;
  5473. }
  5474. if (next) {
  5475. next.prev = prev;
  5476. } else {
  5477. this._clipsTail = prev;
  5478. }
  5479. clip.next = clip.prev = clip.animation = null;
  5480. };
  5481. Animation.prototype.removeAnimator = function (animator) {
  5482. var clip = animator.getClip();
  5483. if (clip) {
  5484. this.removeClip(clip);
  5485. }
  5486. animator.animation = null;
  5487. };
  5488. Animation.prototype.update = function (notTriggerFrameAndStageUpdate) {
  5489. var time = new Date().getTime() - this._pausedTime;
  5490. var delta = time - this._time;
  5491. var clip = this._clipsHead;
  5492. while (clip) {
  5493. var nextClip = clip.next;
  5494. var finished = clip.step(time, delta);
  5495. if (finished) {
  5496. clip.ondestroy && clip.ondestroy();
  5497. this.removeClip(clip);
  5498. clip = nextClip;
  5499. } else {
  5500. clip = nextClip;
  5501. }
  5502. }
  5503. this._time = time;
  5504. if (!notTriggerFrameAndStageUpdate) {
  5505. this.onframe(delta);
  5506. this.trigger('frame', delta);
  5507. this.stage.update && this.stage.update();
  5508. }
  5509. };
  5510. Animation.prototype._startLoop = function () {
  5511. var self = this;
  5512. this._running = true;
  5513. function step$$1() {
  5514. if (self._running) {
  5515. requestAnimationFrame$1(step$$1);
  5516. !self._paused && self.update();
  5517. }
  5518. }
  5519. requestAnimationFrame$1(step$$1);
  5520. };
  5521. Animation.prototype.start = function () {
  5522. if (this._running) {
  5523. return;
  5524. }
  5525. this._time = new Date().getTime();
  5526. this._pausedTime = 0;
  5527. this._startLoop();
  5528. };
  5529. Animation.prototype.stop = function () {
  5530. this._running = false;
  5531. };
  5532. Animation.prototype.pause = function () {
  5533. if (!this._paused) {
  5534. this._pauseStart = new Date().getTime();
  5535. this._paused = true;
  5536. }
  5537. };
  5538. Animation.prototype.resume = function () {
  5539. if (this._paused) {
  5540. this._pausedTime += new Date().getTime() - this._pauseStart;
  5541. this._paused = false;
  5542. }
  5543. };
  5544. Animation.prototype.clear = function () {
  5545. var clip = this._clipsHead;
  5546. while (clip) {
  5547. var nextClip = clip.next;
  5548. clip.prev = clip.next = clip.animation = null;
  5549. clip = nextClip;
  5550. }
  5551. this._clipsHead = this._clipsTail = null;
  5552. };
  5553. Animation.prototype.isFinished = function () {
  5554. return this._clipsHead == null;
  5555. };
  5556. Animation.prototype.animate = function (target, options) {
  5557. options = options || {};
  5558. this.start();
  5559. var animator = new Animator(target, options.loop);
  5560. this.addAnimator(animator);
  5561. return animator;
  5562. };
  5563. return Animation;
  5564. }(Eventful);
  5565. var TOUCH_CLICK_DELAY = 300;
  5566. var globalEventSupported = env.domSupported;
  5567. var localNativeListenerNames = function () {
  5568. var mouseHandlerNames = ['click', 'dblclick', 'mousewheel', 'wheel', 'mouseout', 'mouseup', 'mousedown', 'mousemove', 'contextmenu'];
  5569. var touchHandlerNames = ['touchstart', 'touchend', 'touchmove'];
  5570. var pointerEventNameMap = {
  5571. pointerdown: 1,
  5572. pointerup: 1,
  5573. pointermove: 1,
  5574. pointerout: 1
  5575. };
  5576. var pointerHandlerNames = map(mouseHandlerNames, function (name) {
  5577. var nm = name.replace('mouse', 'pointer');
  5578. return pointerEventNameMap.hasOwnProperty(nm) ? nm : name;
  5579. });
  5580. return {
  5581. mouse: mouseHandlerNames,
  5582. touch: touchHandlerNames,
  5583. pointer: pointerHandlerNames
  5584. };
  5585. }();
  5586. var globalNativeListenerNames = {
  5587. mouse: ['mousemove', 'mouseup'],
  5588. pointer: ['pointermove', 'pointerup']
  5589. };
  5590. var wheelEventSupported = false;
  5591. function isPointerFromTouch(event) {
  5592. var pointerType = event.pointerType;
  5593. return pointerType === 'pen' || pointerType === 'touch';
  5594. }
  5595. function setTouchTimer(scope) {
  5596. scope.touching = true;
  5597. if (scope.touchTimer != null) {
  5598. clearTimeout(scope.touchTimer);
  5599. scope.touchTimer = null;
  5600. }
  5601. scope.touchTimer = setTimeout(function () {
  5602. scope.touching = false;
  5603. scope.touchTimer = null;
  5604. }, 700);
  5605. }
  5606. function markTouch(event) {
  5607. event && (event.zrByTouch = true);
  5608. }
  5609. function normalizeGlobalEvent(instance, event) {
  5610. return normalizeEvent(instance.dom, new FakeGlobalEvent(instance, event), true);
  5611. }
  5612. function isLocalEl(instance, el) {
  5613. var elTmp = el;
  5614. var isLocal = false;
  5615. while (elTmp && elTmp.nodeType !== 9 && !(isLocal = elTmp.domBelongToZr || elTmp !== el && elTmp === instance.painterRoot)) {
  5616. elTmp = elTmp.parentNode;
  5617. }
  5618. return isLocal;
  5619. }
  5620. var FakeGlobalEvent = function () {
  5621. function FakeGlobalEvent(instance, event) {
  5622. this.stopPropagation = noop;
  5623. this.stopImmediatePropagation = noop;
  5624. this.preventDefault = noop;
  5625. this.type = event.type;
  5626. this.target = this.currentTarget = instance.dom;
  5627. this.pointerType = event.pointerType;
  5628. this.clientX = event.clientX;
  5629. this.clientY = event.clientY;
  5630. }
  5631. return FakeGlobalEvent;
  5632. }();
  5633. var localDOMHandlers = {
  5634. mousedown: function (event) {
  5635. event = normalizeEvent(this.dom, event);
  5636. this.__mayPointerCapture = [event.zrX, event.zrY];
  5637. this.trigger('mousedown', event);
  5638. },
  5639. mousemove: function (event) {
  5640. event = normalizeEvent(this.dom, event);
  5641. var downPoint = this.__mayPointerCapture;
  5642. if (downPoint && (event.zrX !== downPoint[0] || event.zrY !== downPoint[1])) {
  5643. this.__togglePointerCapture(true);
  5644. }
  5645. this.trigger('mousemove', event);
  5646. },
  5647. mouseup: function (event) {
  5648. event = normalizeEvent(this.dom, event);
  5649. this.__togglePointerCapture(false);
  5650. this.trigger('mouseup', event);
  5651. },
  5652. mouseout: function (event) {
  5653. event = normalizeEvent(this.dom, event);
  5654. var element = event.toElement || event.relatedTarget;
  5655. if (!isLocalEl(this, element)) {
  5656. if (this.__pointerCapturing) {
  5657. event.zrEventControl = 'no_globalout';
  5658. }
  5659. this.trigger('mouseout', event);
  5660. }
  5661. },
  5662. wheel: function (event) {
  5663. wheelEventSupported = true;
  5664. event = normalizeEvent(this.dom, event);
  5665. this.trigger('mousewheel', event);
  5666. },
  5667. mousewheel: function (event) {
  5668. if (wheelEventSupported) {
  5669. return;
  5670. }
  5671. event = normalizeEvent(this.dom, event);
  5672. this.trigger('mousewheel', event);
  5673. },
  5674. touchstart: function (event) {
  5675. event = normalizeEvent(this.dom, event);
  5676. markTouch(event);
  5677. this.__lastTouchMoment = new Date();
  5678. this.handler.processGesture(event, 'start');
  5679. localDOMHandlers.mousemove.call(this, event);
  5680. localDOMHandlers.mousedown.call(this, event);
  5681. },
  5682. touchmove: function (event) {
  5683. event = normalizeEvent(this.dom, event);
  5684. markTouch(event);
  5685. this.handler.processGesture(event, 'change');
  5686. localDOMHandlers.mousemove.call(this, event);
  5687. },
  5688. touchend: function (event) {
  5689. event = normalizeEvent(this.dom, event);
  5690. markTouch(event);
  5691. this.handler.processGesture(event, 'end');
  5692. localDOMHandlers.mouseup.call(this, event);
  5693. if (+new Date() - +this.__lastTouchMoment < TOUCH_CLICK_DELAY) {
  5694. localDOMHandlers.click.call(this, event);
  5695. }
  5696. },
  5697. pointerdown: function (event) {
  5698. localDOMHandlers.mousedown.call(this, event);
  5699. },
  5700. pointermove: function (event) {
  5701. if (!isPointerFromTouch(event)) {
  5702. localDOMHandlers.mousemove.call(this, event);
  5703. }
  5704. },
  5705. pointerup: function (event) {
  5706. localDOMHandlers.mouseup.call(this, event);
  5707. },
  5708. pointerout: function (event) {
  5709. if (!isPointerFromTouch(event)) {
  5710. localDOMHandlers.mouseout.call(this, event);
  5711. }
  5712. }
  5713. };
  5714. each$1(['click', 'dblclick', 'contextmenu'], function (name) {
  5715. localDOMHandlers[name] = function (event) {
  5716. event = normalizeEvent(this.dom, event);
  5717. this.trigger(name, event);
  5718. };
  5719. });
  5720. var globalDOMHandlers = {
  5721. pointermove: function (event) {
  5722. if (!isPointerFromTouch(event)) {
  5723. globalDOMHandlers.mousemove.call(this, event);
  5724. }
  5725. },
  5726. pointerup: function (event) {
  5727. globalDOMHandlers.mouseup.call(this, event);
  5728. },
  5729. mousemove: function (event) {
  5730. this.trigger('mousemove', event);
  5731. },
  5732. mouseup: function (event) {
  5733. var pointerCaptureReleasing = this.__pointerCapturing;
  5734. this.__togglePointerCapture(false);
  5735. this.trigger('mouseup', event);
  5736. if (pointerCaptureReleasing) {
  5737. event.zrEventControl = 'only_globalout';
  5738. this.trigger('mouseout', event);
  5739. }
  5740. }
  5741. };
  5742. function mountLocalDOMEventListeners(instance, scope) {
  5743. var domHandlers = scope.domHandlers;
  5744. if (env.pointerEventsSupported) {
  5745. each$1(localNativeListenerNames.pointer, function (nativeEventName) {
  5746. mountSingleDOMEventListener(scope, nativeEventName, function (event) {
  5747. domHandlers[nativeEventName].call(instance, event);
  5748. });
  5749. });
  5750. } else {
  5751. if (env.touchEventsSupported) {
  5752. each$1(localNativeListenerNames.touch, function (nativeEventName) {
  5753. mountSingleDOMEventListener(scope, nativeEventName, function (event) {
  5754. domHandlers[nativeEventName].call(instance, event);
  5755. setTouchTimer(scope);
  5756. });
  5757. });
  5758. }
  5759. each$1(localNativeListenerNames.mouse, function (nativeEventName) {
  5760. mountSingleDOMEventListener(scope, nativeEventName, function (event) {
  5761. event = getNativeEvent(event);
  5762. if (!scope.touching) {
  5763. domHandlers[nativeEventName].call(instance, event);
  5764. }
  5765. });
  5766. });
  5767. }
  5768. }
  5769. function mountGlobalDOMEventListeners(instance, scope) {
  5770. if (env.pointerEventsSupported) {
  5771. each$1(globalNativeListenerNames.pointer, mount);
  5772. } else if (!env.touchEventsSupported) {
  5773. each$1(globalNativeListenerNames.mouse, mount);
  5774. }
  5775. function mount(nativeEventName) {
  5776. function nativeEventListener(event) {
  5777. event = getNativeEvent(event);
  5778. if (!isLocalEl(instance, event.target)) {
  5779. event = normalizeGlobalEvent(instance, event);
  5780. scope.domHandlers[nativeEventName].call(instance, event);
  5781. }
  5782. }
  5783. mountSingleDOMEventListener(scope, nativeEventName, nativeEventListener, {
  5784. capture: true
  5785. });
  5786. }
  5787. }
  5788. function mountSingleDOMEventListener(scope, nativeEventName, listener, opt) {
  5789. scope.mounted[nativeEventName] = listener;
  5790. scope.listenerOpts[nativeEventName] = opt;
  5791. addEventListener(scope.domTarget, nativeEventName, listener, opt);
  5792. }
  5793. function unmountDOMEventListeners(scope) {
  5794. var mounted = scope.mounted;
  5795. for (var nativeEventName in mounted) {
  5796. if (mounted.hasOwnProperty(nativeEventName)) {
  5797. removeEventListener(scope.domTarget, nativeEventName, mounted[nativeEventName], scope.listenerOpts[nativeEventName]);
  5798. }
  5799. }
  5800. scope.mounted = {};
  5801. }
  5802. var DOMHandlerScope = function () {
  5803. function DOMHandlerScope(domTarget, domHandlers) {
  5804. this.mounted = {};
  5805. this.listenerOpts = {};
  5806. this.touching = false;
  5807. this.domTarget = domTarget;
  5808. this.domHandlers = domHandlers;
  5809. }
  5810. return DOMHandlerScope;
  5811. }();
  5812. var HandlerDomProxy = function (_super) {
  5813. __extends(HandlerDomProxy, _super);
  5814. function HandlerDomProxy(dom, painterRoot) {
  5815. var _this = _super.call(this) || this;
  5816. _this.__pointerCapturing = false;
  5817. _this.dom = dom;
  5818. _this.painterRoot = painterRoot;
  5819. _this._localHandlerScope = new DOMHandlerScope(dom, localDOMHandlers);
  5820. if (globalEventSupported) {
  5821. _this._globalHandlerScope = new DOMHandlerScope(document, globalDOMHandlers);
  5822. }
  5823. mountLocalDOMEventListeners(_this, _this._localHandlerScope);
  5824. return _this;
  5825. }
  5826. HandlerDomProxy.prototype.dispose = function () {
  5827. unmountDOMEventListeners(this._localHandlerScope);
  5828. if (globalEventSupported) {
  5829. unmountDOMEventListeners(this._globalHandlerScope);
  5830. }
  5831. };
  5832. HandlerDomProxy.prototype.setCursor = function (cursorStyle) {
  5833. this.dom.style && (this.dom.style.cursor = cursorStyle || 'default');
  5834. };
  5835. HandlerDomProxy.prototype.__togglePointerCapture = function (isPointerCapturing) {
  5836. this.__mayPointerCapture = null;
  5837. if (globalEventSupported && +this.__pointerCapturing ^ +isPointerCapturing) {
  5838. this.__pointerCapturing = isPointerCapturing;
  5839. var globalHandlerScope = this._globalHandlerScope;
  5840. isPointerCapturing ? mountGlobalDOMEventListeners(this, globalHandlerScope) : unmountDOMEventListeners(globalHandlerScope);
  5841. }
  5842. };
  5843. return HandlerDomProxy;
  5844. }(Eventful);
  5845. var Group = function (_super) {
  5846. __extends(Group, _super);
  5847. function Group(opts) {
  5848. var _this = _super.call(this) || this;
  5849. _this.isGroup = true;
  5850. _this._children = [];
  5851. _this.attr(opts);
  5852. return _this;
  5853. }
  5854. Group.prototype.childrenRef = function () {
  5855. return this._children;
  5856. };
  5857. Group.prototype.children = function () {
  5858. return this._children.slice();
  5859. };
  5860. Group.prototype.childAt = function (idx) {
  5861. return this._children[idx];
  5862. };
  5863. Group.prototype.childOfName = function (name) {
  5864. var children = this._children;
  5865. for (var i = 0; i < children.length; i++) {
  5866. if (children[i].name === name) {
  5867. return children[i];
  5868. }
  5869. }
  5870. };
  5871. Group.prototype.childCount = function () {
  5872. return this._children.length;
  5873. };
  5874. Group.prototype.add = function (child) {
  5875. if (child) {
  5876. if (child !== this && child.parent !== this) {
  5877. this._children.push(child);
  5878. this._doAdd(child);
  5879. }
  5880. if (child.__hostTarget) {
  5881. throw 'This elemenet has been used as an attachment';
  5882. }
  5883. }
  5884. return this;
  5885. };
  5886. Group.prototype.addBefore = function (child, nextSibling) {
  5887. if (child && child !== this && child.parent !== this && nextSibling && nextSibling.parent === this) {
  5888. var children = this._children;
  5889. var idx = children.indexOf(nextSibling);
  5890. if (idx >= 0) {
  5891. children.splice(idx, 0, child);
  5892. this._doAdd(child);
  5893. }
  5894. }
  5895. return this;
  5896. };
  5897. Group.prototype.replaceAt = function (child, index) {
  5898. var children = this._children;
  5899. var old = children[index];
  5900. if (child && child !== this && child.parent !== this && child !== old) {
  5901. children[index] = child;
  5902. old.parent = null;
  5903. var zr = this.__zr;
  5904. if (zr) {
  5905. old.removeSelfFromZr(zr);
  5906. }
  5907. this._doAdd(child);
  5908. }
  5909. return this;
  5910. };
  5911. Group.prototype._doAdd = function (child) {
  5912. if (child.parent) {
  5913. child.parent.remove(child);
  5914. }
  5915. child.parent = this;
  5916. var zr = this.__zr;
  5917. if (zr && zr !== child.__zr) {
  5918. child.addSelfToZr(zr);
  5919. }
  5920. zr && zr.refresh();
  5921. };
  5922. Group.prototype.remove = function (child) {
  5923. var zr = this.__zr;
  5924. var children = this._children;
  5925. var idx = indexOf$1(children, child);
  5926. if (idx < 0) {
  5927. return this;
  5928. }
  5929. children.splice(idx, 1);
  5930. child.parent = null;
  5931. if (zr) {
  5932. child.removeSelfFromZr(zr);
  5933. }
  5934. zr && zr.refresh();
  5935. return this;
  5936. };
  5937. Group.prototype.removeAll = function () {
  5938. var children = this._children;
  5939. var zr = this.__zr;
  5940. for (var i = 0; i < children.length; i++) {
  5941. var child = children[i];
  5942. if (zr) {
  5943. child.removeSelfFromZr(zr);
  5944. }
  5945. child.parent = null;
  5946. }
  5947. children.length = 0;
  5948. return this;
  5949. };
  5950. Group.prototype.eachChild = function (cb, context) {
  5951. var children = this._children;
  5952. for (var i = 0; i < children.length; i++) {
  5953. var child = children[i];
  5954. cb.call(context, child, i);
  5955. }
  5956. return this;
  5957. };
  5958. Group.prototype.traverse = function (cb, context) {
  5959. for (var i = 0; i < this._children.length; i++) {
  5960. var child = this._children[i];
  5961. var stopped = cb.call(context, child);
  5962. if (child.isGroup && !stopped) {
  5963. child.traverse(cb, context);
  5964. }
  5965. }
  5966. return this;
  5967. };
  5968. Group.prototype.addSelfToZr = function (zr) {
  5969. _super.prototype.addSelfToZr.call(this, zr);
  5970. for (var i = 0; i < this._children.length; i++) {
  5971. var child = this._children[i];
  5972. child.addSelfToZr(zr);
  5973. }
  5974. };
  5975. Group.prototype.removeSelfFromZr = function (zr) {
  5976. _super.prototype.removeSelfFromZr.call(this, zr);
  5977. for (var i = 0; i < this._children.length; i++) {
  5978. var child = this._children[i];
  5979. child.removeSelfFromZr(zr);
  5980. }
  5981. };
  5982. Group.prototype.getBoundingRect = function (includeChildren) {
  5983. var tmpRect = new BoundingRect(0, 0, 0, 0);
  5984. var children = includeChildren || this._children;
  5985. var tmpMat = [];
  5986. var rect = null;
  5987. for (var i = 0; i < children.length; i++) {
  5988. var child = children[i];
  5989. if (child.ignore || child.invisible) {
  5990. continue;
  5991. }
  5992. var childRect = child.getBoundingRect();
  5993. var transform = child.getLocalTransform(tmpMat);
  5994. if (transform) {
  5995. BoundingRect.applyTransform(tmpRect, childRect, transform);
  5996. rect = rect || tmpRect.clone();
  5997. rect.union(tmpRect);
  5998. } else {
  5999. rect = rect || childRect.clone();
  6000. rect.union(childRect);
  6001. }
  6002. }
  6003. return rect || tmpRect;
  6004. };
  6005. return Group;
  6006. }(Element);
  6007. Group.prototype.type = 'group';
  6008. /*!
  6009. * ZRender, a high performance 2d drawing library.
  6010. *
  6011. * Copyright (c) 2013, Baidu Inc.
  6012. * All rights reserved.
  6013. *
  6014. * LICENSE
  6015. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  6016. */
  6017. var useVML = !env.canvasSupported;
  6018. var painterCtors = {};
  6019. var instances$1 = {};
  6020. function delInstance(id) {
  6021. delete instances$1[id];
  6022. }
  6023. function isDarkMode(backgroundColor) {
  6024. if (!backgroundColor) {
  6025. return false;
  6026. }
  6027. if (typeof backgroundColor === 'string') {
  6028. return lum(backgroundColor, 1) < DARK_MODE_THRESHOLD;
  6029. } else if (backgroundColor.colorStops) {
  6030. var colorStops = backgroundColor.colorStops;
  6031. var totalLum = 0;
  6032. var len = colorStops.length;
  6033. for (var i = 0; i < len; i++) {
  6034. totalLum += lum(colorStops[i].color, 1);
  6035. }
  6036. totalLum /= len;
  6037. return totalLum < DARK_MODE_THRESHOLD;
  6038. }
  6039. return false;
  6040. }
  6041. var ZRender = function () {
  6042. function ZRender(id, dom, opts) {
  6043. var _this = this;
  6044. this._sleepAfterStill = 10;
  6045. this._stillFrameAccum = 0;
  6046. this._needsRefresh = true;
  6047. this._needsRefreshHover = true;
  6048. this._darkMode = false;
  6049. opts = opts || {};
  6050. this.dom = dom;
  6051. this.id = id;
  6052. var storage = new Storage();
  6053. var rendererType = opts.renderer || 'canvas';
  6054. if (useVML) {
  6055. throw new Error('IE8 support has been dropped since 5.0');
  6056. }
  6057. if (!painterCtors[rendererType]) {
  6058. rendererType = keys(painterCtors)[0];
  6059. }
  6060. if (!painterCtors[rendererType]) {
  6061. throw new Error("Renderer '" + rendererType + "' is not imported. Please import it first.");
  6062. }
  6063. opts.useDirtyRect = opts.useDirtyRect == null ? false : opts.useDirtyRect;
  6064. var painter = new painterCtors[rendererType](dom, storage, opts, id);
  6065. this.storage = storage;
  6066. this.painter = painter;
  6067. var handerProxy = !env.node && !env.worker ? new HandlerDomProxy(painter.getViewportRoot(), painter.root) : null;
  6068. this.handler = new Handler(storage, painter, handerProxy, painter.root);
  6069. this.animation = new Animation({
  6070. stage: {
  6071. update: function () {
  6072. return _this._flush(true);
  6073. }
  6074. }
  6075. });
  6076. this.animation.start();
  6077. }
  6078. ZRender.prototype.add = function (el) {
  6079. if (!el) {
  6080. return;
  6081. }
  6082. this.storage.addRoot(el);
  6083. el.addSelfToZr(this);
  6084. this.refresh();
  6085. };
  6086. ZRender.prototype.remove = function (el) {
  6087. if (!el) {
  6088. return;
  6089. }
  6090. this.storage.delRoot(el);
  6091. el.removeSelfFromZr(this);
  6092. this.refresh();
  6093. };
  6094. ZRender.prototype.configLayer = function (zLevel, config) {
  6095. if (this.painter.configLayer) {
  6096. this.painter.configLayer(zLevel, config);
  6097. }
  6098. this.refresh();
  6099. };
  6100. ZRender.prototype.setBackgroundColor = function (backgroundColor) {
  6101. if (this.painter.setBackgroundColor) {
  6102. this.painter.setBackgroundColor(backgroundColor);
  6103. }
  6104. this.refresh();
  6105. this._backgroundColor = backgroundColor;
  6106. this._darkMode = isDarkMode(backgroundColor);
  6107. };
  6108. ZRender.prototype.getBackgroundColor = function () {
  6109. return this._backgroundColor;
  6110. };
  6111. ZRender.prototype.setDarkMode = function (darkMode) {
  6112. this._darkMode = darkMode;
  6113. };
  6114. ZRender.prototype.isDarkMode = function () {
  6115. return this._darkMode;
  6116. };
  6117. ZRender.prototype.refreshImmediately = function (fromInside) {
  6118. if (!fromInside) {
  6119. this.animation.update(true);
  6120. }
  6121. this._needsRefresh = false;
  6122. this.painter.refresh();
  6123. this._needsRefresh = false;
  6124. };
  6125. ZRender.prototype.refresh = function () {
  6126. this._needsRefresh = true;
  6127. this.animation.start();
  6128. };
  6129. ZRender.prototype.flush = function () {
  6130. this._flush(false);
  6131. };
  6132. ZRender.prototype._flush = function (fromInside) {
  6133. var triggerRendered;
  6134. var start = new Date().getTime();
  6135. if (this._needsRefresh) {
  6136. triggerRendered = true;
  6137. this.refreshImmediately(fromInside);
  6138. }
  6139. if (this._needsRefreshHover) {
  6140. triggerRendered = true;
  6141. this.refreshHoverImmediately();
  6142. }
  6143. var end = new Date().getTime();
  6144. if (triggerRendered) {
  6145. this._stillFrameAccum = 0;
  6146. this.trigger('rendered', {
  6147. elapsedTime: end - start
  6148. });
  6149. } else if (this._sleepAfterStill > 0) {
  6150. this._stillFrameAccum++;
  6151. if (this._stillFrameAccum > this._sleepAfterStill) {
  6152. this.animation.stop();
  6153. }
  6154. }
  6155. };
  6156. ZRender.prototype.setSleepAfterStill = function (stillFramesCount) {
  6157. this._sleepAfterStill = stillFramesCount;
  6158. };
  6159. ZRender.prototype.wakeUp = function () {
  6160. this.animation.start();
  6161. this._stillFrameAccum = 0;
  6162. };
  6163. ZRender.prototype.addHover = function (el) {};
  6164. ZRender.prototype.removeHover = function (el) {};
  6165. ZRender.prototype.clearHover = function () {};
  6166. ZRender.prototype.refreshHover = function () {
  6167. this._needsRefreshHover = true;
  6168. };
  6169. ZRender.prototype.refreshHoverImmediately = function () {
  6170. this._needsRefreshHover = false;
  6171. if (this.painter.refreshHover && this.painter.getType() === 'canvas') {
  6172. this.painter.refreshHover();
  6173. }
  6174. };
  6175. ZRender.prototype.resize = function (opts) {
  6176. opts = opts || {};
  6177. this.painter.resize(opts.width, opts.height);
  6178. this.handler.resize();
  6179. };
  6180. ZRender.prototype.clearAnimation = function () {
  6181. this.animation.clear();
  6182. };
  6183. ZRender.prototype.getWidth = function () {
  6184. return this.painter.getWidth();
  6185. };
  6186. ZRender.prototype.getHeight = function () {
  6187. return this.painter.getHeight();
  6188. };
  6189. ZRender.prototype.pathToImage = function (e, dpr) {
  6190. if (this.painter.pathToImage) {
  6191. return this.painter.pathToImage(e, dpr);
  6192. }
  6193. };
  6194. ZRender.prototype.setCursorStyle = function (cursorStyle) {
  6195. this.handler.setCursorStyle(cursorStyle);
  6196. };
  6197. ZRender.prototype.findHover = function (x, y) {
  6198. return this.handler.findHover(x, y);
  6199. };
  6200. ZRender.prototype.on = function (eventName, eventHandler, context) {
  6201. this.handler.on(eventName, eventHandler, context);
  6202. return this;
  6203. };
  6204. ZRender.prototype.off = function (eventName, eventHandler) {
  6205. this.handler.off(eventName, eventHandler);
  6206. };
  6207. ZRender.prototype.trigger = function (eventName, event) {
  6208. this.handler.trigger(eventName, event);
  6209. };
  6210. ZRender.prototype.clear = function () {
  6211. var roots = this.storage.getRoots();
  6212. for (var i = 0; i < roots.length; i++) {
  6213. if (roots[i] instanceof Group) {
  6214. roots[i].removeSelfFromZr(this);
  6215. }
  6216. }
  6217. this.storage.delAllRoots();
  6218. this.painter.clear();
  6219. };
  6220. ZRender.prototype.dispose = function () {
  6221. this.animation.stop();
  6222. this.clear();
  6223. this.storage.dispose();
  6224. this.painter.dispose();
  6225. this.handler.dispose();
  6226. this.animation = this.storage = this.painter = this.handler = null;
  6227. delInstance(this.id);
  6228. };
  6229. return ZRender;
  6230. }();
  6231. function init$1(dom, opts) {
  6232. var zr = new ZRender(guid(), dom, opts);
  6233. instances$1[zr.id] = zr;
  6234. return zr;
  6235. }
  6236. function dispose$1(zr) {
  6237. zr.dispose();
  6238. }
  6239. function disposeAll() {
  6240. for (var key in instances$1) {
  6241. if (instances$1.hasOwnProperty(key)) {
  6242. instances$1[key].dispose();
  6243. }
  6244. }
  6245. instances$1 = {};
  6246. }
  6247. function getInstance(id) {
  6248. return instances$1[id];
  6249. }
  6250. function registerPainter(name, Ctor) {
  6251. painterCtors[name] = Ctor;
  6252. }
  6253. var version$1 = '5.1.0';
  6254. var zrender = (Object.freeze || Object)({
  6255. init: init$1,
  6256. dispose: dispose$1,
  6257. disposeAll: disposeAll,
  6258. getInstance: getInstance,
  6259. registerPainter: registerPainter,
  6260. version: version$1
  6261. });
  6262. /*
  6263. * Licensed to the Apache Software Foundation (ASF) under one
  6264. * or more contributor license agreements. See the NOTICE file
  6265. * distributed with this work for additional information
  6266. * regarding copyright ownership. The ASF licenses this file
  6267. * to you under the Apache License, Version 2.0 (the
  6268. * "License"); you may not use this file except in compliance
  6269. * with the License. You may obtain a copy of the License at
  6270. *
  6271. * http://www.apache.org/licenses/LICENSE-2.0
  6272. *
  6273. * Unless required by applicable law or agreed to in writing,
  6274. * software distributed under the License is distributed on an
  6275. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  6276. * KIND, either express or implied. See the License for the
  6277. * specific language governing permissions and limitations
  6278. * under the License.
  6279. */
  6280. /**
  6281. * AUTO-GENERATED FILE. DO NOT MODIFY.
  6282. */
  6283. /*
  6284. * Licensed to the Apache Software Foundation (ASF) under one
  6285. * or more contributor license agreements. See the NOTICE file
  6286. * distributed with this work for additional information
  6287. * regarding copyright ownership. The ASF licenses this file
  6288. * to you under the Apache License, Version 2.0 (the
  6289. * "License"); you may not use this file except in compliance
  6290. * with the License. You may obtain a copy of the License at
  6291. *
  6292. * http://www.apache.org/licenses/LICENSE-2.0
  6293. *
  6294. * Unless required by applicable law or agreed to in writing,
  6295. * software distributed under the License is distributed on an
  6296. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  6297. * KIND, either express or implied. See the License for the
  6298. * specific language governing permissions and limitations
  6299. * under the License.
  6300. */
  6301. /*
  6302. * A third-party license is embeded for some of the code in this file:
  6303. * The method "quantile" was copied from "d3.js".
  6304. * (See more details in the comment of the method below.)
  6305. * The use of the source code of this file is also subject to the terms
  6306. * and consitions of the license of "d3.js" (BSD-3Clause, see
  6307. * </licenses/LICENSE-d3>).
  6308. */
  6309. var RADIAN_EPSILON = 1e-4;
  6310. function _trim(str) {
  6311. return str.replace(/^\s+|\s+$/g, '');
  6312. }
  6313. /**
  6314. * Linear mapping a value from domain to range
  6315. * @param val
  6316. * @param domain Domain extent domain[0] can be bigger than domain[1]
  6317. * @param range Range extent range[0] can be bigger than range[1]
  6318. * @param clamp Default to be false
  6319. */
  6320. function linearMap(val, domain, range, clamp) {
  6321. var subDomain = domain[1] - domain[0];
  6322. var subRange = range[1] - range[0];
  6323. if (subDomain === 0) {
  6324. return subRange === 0 ? range[0] : (range[0] + range[1]) / 2;
  6325. } // Avoid accuracy problem in edge, such as
  6326. // 146.39 - 62.83 === 83.55999999999999.
  6327. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  6328. // It is a little verbose for efficiency considering this method
  6329. // is a hotspot.
  6330. if (clamp) {
  6331. if (subDomain > 0) {
  6332. if (val <= domain[0]) {
  6333. return range[0];
  6334. } else if (val >= domain[1]) {
  6335. return range[1];
  6336. }
  6337. } else {
  6338. if (val >= domain[0]) {
  6339. return range[0];
  6340. } else if (val <= domain[1]) {
  6341. return range[1];
  6342. }
  6343. }
  6344. } else {
  6345. if (val === domain[0]) {
  6346. return range[0];
  6347. }
  6348. if (val === domain[1]) {
  6349. return range[1];
  6350. }
  6351. }
  6352. return (val - domain[0]) / subDomain * subRange + range[0];
  6353. }
  6354. /**
  6355. * Convert a percent string to absolute number.
  6356. * Returns NaN if percent is not a valid string or number
  6357. */
  6358. function parsePercent$1(percent, all) {
  6359. switch (percent) {
  6360. case 'center':
  6361. case 'middle':
  6362. percent = '50%';
  6363. break;
  6364. case 'left':
  6365. case 'top':
  6366. percent = '0%';
  6367. break;
  6368. case 'right':
  6369. case 'bottom':
  6370. percent = '100%';
  6371. break;
  6372. }
  6373. if (typeof percent === 'string') {
  6374. if (_trim(percent).match(/%$/)) {
  6375. return parseFloat(percent) / 100 * all;
  6376. }
  6377. return parseFloat(percent);
  6378. }
  6379. return percent == null ? NaN : +percent;
  6380. }
  6381. function round(x, precision, returnStr) {
  6382. if (precision == null) {
  6383. precision = 10;
  6384. } // Avoid range error
  6385. precision = Math.min(Math.max(0, precision), 20);
  6386. x = (+x).toFixed(precision);
  6387. return returnStr ? x : +x;
  6388. }
  6389. /**
  6390. * Inplacd asc sort arr.
  6391. * The input arr will be modified.
  6392. */
  6393. function asc(arr) {
  6394. arr.sort(function (a, b) {
  6395. return a - b;
  6396. });
  6397. return arr;
  6398. }
  6399. /**
  6400. * Get precision
  6401. */
  6402. function getPrecision(val) {
  6403. val = +val;
  6404. if (isNaN(val)) {
  6405. return 0;
  6406. } // It is much faster than methods converting number to string as follows
  6407. // let tmp = val.toString();
  6408. // return tmp.length - 1 - tmp.indexOf('.');
  6409. // especially when precision is low
  6410. var e = 1;
  6411. var count = 0;
  6412. while (Math.round(val * e) / e !== val) {
  6413. e *= 10;
  6414. count++;
  6415. }
  6416. return count;
  6417. }
  6418. /**
  6419. * Get precision with slow but safe method
  6420. */
  6421. function getPrecisionSafe(val) {
  6422. var str = val.toString(); // Consider scientific notation: '3.4e-12' '3.4e+12'
  6423. var eIndex = str.indexOf('e');
  6424. if (eIndex > 0) {
  6425. var precision = +str.slice(eIndex + 1);
  6426. return precision < 0 ? -precision : 0;
  6427. } else {
  6428. var dotIndex = str.indexOf('.');
  6429. return dotIndex < 0 ? 0 : str.length - 1 - dotIndex;
  6430. }
  6431. }
  6432. /**
  6433. * Minimal dicernible data precisioin according to a single pixel.
  6434. */
  6435. function getPixelPrecision(dataExtent, pixelExtent) {
  6436. var log = Math.log;
  6437. var LN10 = Math.LN10;
  6438. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  6439. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10); // toFixed() digits argument must be between 0 and 20.
  6440. var precision = Math.min(Math.max(-dataQuantity + sizeQuantity, 0), 20);
  6441. return !isFinite(precision) ? 20 : precision;
  6442. }
  6443. /**
  6444. * Get a data of given precision, assuring the sum of percentages
  6445. * in valueList is 1.
  6446. * The largest remainer method is used.
  6447. * https://en.wikipedia.org/wiki/Largest_remainder_method
  6448. *
  6449. * @param valueList a list of all data
  6450. * @param idx index of the data to be processed in valueList
  6451. * @param precision integer number showing digits of precision
  6452. * @return percent ranging from 0 to 100
  6453. */
  6454. function getPercentWithPrecision(valueList, idx, precision) {
  6455. if (!valueList[idx]) {
  6456. return 0;
  6457. }
  6458. var sum = reduce(valueList, function (acc, val) {
  6459. return acc + (isNaN(val) ? 0 : val);
  6460. }, 0);
  6461. if (sum === 0) {
  6462. return 0;
  6463. }
  6464. var digits = Math.pow(10, precision);
  6465. var votesPerQuota = map(valueList, function (val) {
  6466. return (isNaN(val) ? 0 : val) / sum * digits * 100;
  6467. });
  6468. var targetSeats = digits * 100;
  6469. var seats = map(votesPerQuota, function (votes) {
  6470. // Assign automatic seats.
  6471. return Math.floor(votes);
  6472. });
  6473. var currentSum = reduce(seats, function (acc, val) {
  6474. return acc + val;
  6475. }, 0);
  6476. var remainder = map(votesPerQuota, function (votes, idx) {
  6477. return votes - seats[idx];
  6478. }); // Has remainding votes.
  6479. while (currentSum < targetSeats) {
  6480. // Find next largest remainder.
  6481. var max = Number.NEGATIVE_INFINITY;
  6482. var maxId = null;
  6483. for (var i = 0, len = remainder.length; i < len; ++i) {
  6484. if (remainder[i] > max) {
  6485. max = remainder[i];
  6486. maxId = i;
  6487. }
  6488. } // Add a vote to max remainder.
  6489. ++seats[maxId];
  6490. remainder[maxId] = 0;
  6491. ++currentSum;
  6492. }
  6493. return seats[idx] / digits;
  6494. } // Number.MAX_SAFE_INTEGER, ie do not support.
  6495. var MAX_SAFE_INTEGER = 9007199254740991;
  6496. /**
  6497. * To 0 - 2 * PI, considering negative radian.
  6498. */
  6499. function remRadian(radian) {
  6500. var pi2 = Math.PI * 2;
  6501. return (radian % pi2 + pi2) % pi2;
  6502. }
  6503. /**
  6504. * @param {type} radian
  6505. * @return {boolean}
  6506. */
  6507. function isRadianAroundZero(val) {
  6508. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  6509. } // eslint-disable-next-line
  6510. var TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/; // jshint ignore:line
  6511. /**
  6512. * @param value valid type: number | string | Date, otherwise return `new Date(NaN)`
  6513. * These values can be accepted:
  6514. * + An instance of Date, represent a time in its own time zone.
  6515. * + Or string in a subset of ISO 8601, only including:
  6516. * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
  6517. * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
  6518. * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
  6519. * all of which will be treated as local time if time zone is not specified
  6520. * (see <https://momentjs.com/>).
  6521. * + Or other string format, including (all of which will be treated as loacal time):
  6522. * '2012', '2012-3-1', '2012/3/1', '2012/03/01',
  6523. * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
  6524. * + a timestamp, which represent a time in UTC.
  6525. * @return date Never be null/undefined. If invalid, return `new Date(NaN)`.
  6526. */
  6527. function parseDate(value) {
  6528. if (value instanceof Date) {
  6529. return value;
  6530. } else if (typeof value === 'string') {
  6531. // Different browsers parse date in different way, so we parse it manually.
  6532. // Some other issues:
  6533. // new Date('1970-01-01') is UTC,
  6534. // new Date('1970/01/01') and new Date('1970-1-01') is local.
  6535. // See issue #3623
  6536. var match = TIME_REG.exec(value);
  6537. if (!match) {
  6538. // return Invalid Date.
  6539. return new Date(NaN);
  6540. } // Use local time when no timezone offset specifed.
  6541. if (!match[8]) {
  6542. // match[n] can only be string or undefined.
  6543. // But take care of '12' + 1 => '121'.
  6544. return new Date(+match[1], +(match[2] || 1) - 1, +match[3] || 1, +match[4] || 0, +(match[5] || 0), +match[6] || 0, +match[7] || 0);
  6545. } // Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
  6546. // https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
  6547. // For example, system timezone is set as "Time Zone: America/Toronto",
  6548. // then these code will get different result:
  6549. // `new Date(1478411999999).getTimezoneOffset(); // get 240`
  6550. // `new Date(1478412000000).getTimezoneOffset(); // get 300`
  6551. // So we should not use `new Date`, but use `Date.UTC`.
  6552. else {
  6553. var hour = +match[4] || 0;
  6554. if (match[8].toUpperCase() !== 'Z') {
  6555. hour -= +match[8].slice(0, 3);
  6556. }
  6557. return new Date(Date.UTC(+match[1], +(match[2] || 1) - 1, +match[3] || 1, hour, +(match[5] || 0), +match[6] || 0, +match[7] || 0));
  6558. }
  6559. } else if (value == null) {
  6560. return new Date(NaN);
  6561. }
  6562. return new Date(Math.round(value));
  6563. }
  6564. /**
  6565. * Quantity of a number. e.g. 0.1, 1, 10, 100
  6566. *
  6567. * @param val
  6568. * @return
  6569. */
  6570. function quantity(val) {
  6571. return Math.pow(10, quantityExponent(val));
  6572. }
  6573. /**
  6574. * Exponent of the quantity of a number
  6575. * e.g., 1234 equals to 1.234*10^3, so quantityExponent(1234) is 3
  6576. *
  6577. * @param val non-negative value
  6578. * @return
  6579. */
  6580. function quantityExponent(val) {
  6581. if (val === 0) {
  6582. return 0;
  6583. }
  6584. var exp = Math.floor(Math.log(val) / Math.LN10);
  6585. /**
  6586. * exp is expected to be the rounded-down result of the base-10 log of val.
  6587. * But due to the precision loss with Math.log(val), we need to restore it
  6588. * using 10^exp to make sure we can get val back from exp. #11249
  6589. */
  6590. if (val / Math.pow(10, exp) >= 10) {
  6591. exp++;
  6592. }
  6593. return exp;
  6594. }
  6595. /**
  6596. * find a “nice” number approximately equal to x. Round the number if round = true,
  6597. * take ceiling if round = false. The primary observation is that the “nicest”
  6598. * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  6599. *
  6600. * See "Nice Numbers for Graph Labels" of Graphic Gems.
  6601. *
  6602. * @param val Non-negative value.
  6603. * @param round
  6604. * @return Niced number
  6605. */
  6606. function nice(val, round) {
  6607. var exponent = quantityExponent(val);
  6608. var exp10 = Math.pow(10, exponent);
  6609. var f = val / exp10; // 1 <= f < 10
  6610. var nf;
  6611. if (round) {
  6612. if (f < 1.5) {
  6613. nf = 1;
  6614. } else if (f < 2.5) {
  6615. nf = 2;
  6616. } else if (f < 4) {
  6617. nf = 3;
  6618. } else if (f < 7) {
  6619. nf = 5;
  6620. } else {
  6621. nf = 10;
  6622. }
  6623. } else {
  6624. if (f < 1) {
  6625. nf = 1;
  6626. } else if (f < 2) {
  6627. nf = 2;
  6628. } else if (f < 3) {
  6629. nf = 3;
  6630. } else if (f < 5) {
  6631. nf = 5;
  6632. } else {
  6633. nf = 10;
  6634. }
  6635. }
  6636. val = nf * exp10; // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
  6637. // 20 is the uppper bound of toFixed.
  6638. return exponent >= -20 ? +val.toFixed(exponent < 0 ? -exponent : 0) : val;
  6639. }
  6640. /**
  6641. * This code was copied from "d3.js"
  6642. * <https://github.com/d3/d3/blob/9cc9a875e636a1dcf36cc1e07bdf77e1ad6e2c74/src/arrays/quantile.js>.
  6643. * See the license statement at the head of this file.
  6644. * @param ascArr
  6645. */
  6646. function quantile(ascArr, p) {
  6647. var H = (ascArr.length - 1) * p + 1;
  6648. var h = Math.floor(H);
  6649. var v = +ascArr[h - 1];
  6650. var e = H - h;
  6651. return e ? v + e * (ascArr[h] - v) : v;
  6652. }
  6653. /**
  6654. * Order intervals asc, and split them when overlap.
  6655. * expect(numberUtil.reformIntervals([
  6656. * {interval: [18, 62], close: [1, 1]},
  6657. * {interval: [-Infinity, -70], close: [0, 0]},
  6658. * {interval: [-70, -26], close: [1, 1]},
  6659. * {interval: [-26, 18], close: [1, 1]},
  6660. * {interval: [62, 150], close: [1, 1]},
  6661. * {interval: [106, 150], close: [1, 1]},
  6662. * {interval: [150, Infinity], close: [0, 0]}
  6663. * ])).toEqual([
  6664. * {interval: [-Infinity, -70], close: [0, 0]},
  6665. * {interval: [-70, -26], close: [1, 1]},
  6666. * {interval: [-26, 18], close: [0, 1]},
  6667. * {interval: [18, 62], close: [0, 1]},
  6668. * {interval: [62, 150], close: [0, 1]},
  6669. * {interval: [150, Infinity], close: [0, 0]}
  6670. * ]);
  6671. * @param list, where `close` mean open or close
  6672. * of the interval, and Infinity can be used.
  6673. * @return The origin list, which has been reformed.
  6674. */
  6675. function reformIntervals(list) {
  6676. list.sort(function (a, b) {
  6677. return littleThan(a, b, 0) ? -1 : 1;
  6678. });
  6679. var curr = -Infinity;
  6680. var currClose = 1;
  6681. for (var i = 0; i < list.length;) {
  6682. var interval = list[i].interval;
  6683. var close_1 = list[i].close;
  6684. for (var lg = 0; lg < 2; lg++) {
  6685. if (interval[lg] <= curr) {
  6686. interval[lg] = curr;
  6687. close_1[lg] = !lg ? 1 - currClose : 1;
  6688. }
  6689. curr = interval[lg];
  6690. currClose = close_1[lg];
  6691. }
  6692. if (interval[0] === interval[1] && close_1[0] * close_1[1] !== 1) {
  6693. list.splice(i, 1);
  6694. } else {
  6695. i++;
  6696. }
  6697. }
  6698. return list;
  6699. function littleThan(a, b, lg) {
  6700. return a.interval[lg] < b.interval[lg] || a.interval[lg] === b.interval[lg] && (a.close[lg] - b.close[lg] === (!lg ? 1 : -1) || !lg && littleThan(a, b, 1));
  6701. }
  6702. }
  6703. /**
  6704. * [Numberic is defined as]:
  6705. * `parseFloat(val) == val`
  6706. * For example:
  6707. * numeric:
  6708. * typeof number except NaN, '-123', '123', '2e3', '-2e3', '011', 'Infinity', Infinity,
  6709. * and they rounded by white-spaces or line-terminal like ' -123 \n ' (see es spec)
  6710. * not-numeric:
  6711. * null, undefined, [], {}, true, false, 'NaN', NaN, '123ab',
  6712. * empty string, string with only white-spaces or line-terminal (see es spec),
  6713. * 0x12, '0x12', '-0x12', 012, '012', '-012',
  6714. * non-string, ...
  6715. *
  6716. * @test See full test cases in `test/ut/spec/util/number.js`.
  6717. * @return Must be a typeof number. If not numeric, return NaN.
  6718. */
  6719. function numericToNumber(val) {
  6720. var valFloat = parseFloat(val);
  6721. return valFloat == val // eslint-disable-line eqeqeq
  6722. && (valFloat !== 0 || typeof val !== 'string' || val.indexOf('x') <= 0) // For case ' 0x0 '.
  6723. ? valFloat : NaN;
  6724. }
  6725. /**
  6726. * Definition of "numeric": see `numericToNumber`.
  6727. */
  6728. function isNumeric(val) {
  6729. return !isNaN(numericToNumber(val));
  6730. }
  6731. /**
  6732. * Use random base to prevent users hard code depending on
  6733. * this auto generated marker id.
  6734. * @return An positive integer.
  6735. */
  6736. function getRandomIdBase() {
  6737. return Math.round(Math.random() * 9);
  6738. }
  6739. /**
  6740. * Get the greatest common dividor
  6741. *
  6742. * @param {number} a one number
  6743. * @param {number} b the other number
  6744. */
  6745. function getGreatestCommonDividor(a, b) {
  6746. if (b === 0) {
  6747. return a;
  6748. }
  6749. return getGreatestCommonDividor(b, a % b);
  6750. }
  6751. /**
  6752. * Get the least common multiple
  6753. *
  6754. * @param {number} a one number
  6755. * @param {number} b the other number
  6756. */
  6757. function getLeastCommonMultiple(a, b) {
  6758. if (a == null) {
  6759. return b;
  6760. }
  6761. if (b == null) {
  6762. return a;
  6763. }
  6764. return a * b / getGreatestCommonDividor(a, b);
  6765. }
  6766. /*
  6767. * Licensed to the Apache Software Foundation (ASF) under one
  6768. * or more contributor license agreements. See the NOTICE file
  6769. * distributed with this work for additional information
  6770. * regarding copyright ownership. The ASF licenses this file
  6771. * to you under the Apache License, Version 2.0 (the
  6772. * "License"); you may not use this file except in compliance
  6773. * with the License. You may obtain a copy of the License at
  6774. *
  6775. * http://www.apache.org/licenses/LICENSE-2.0
  6776. *
  6777. * Unless required by applicable law or agreed to in writing,
  6778. * software distributed under the License is distributed on an
  6779. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  6780. * KIND, either express or implied. See the License for the
  6781. * specific language governing permissions and limitations
  6782. * under the License.
  6783. */
  6784. /**
  6785. * AUTO-GENERATED FILE. DO NOT MODIFY.
  6786. */
  6787. /*
  6788. * Licensed to the Apache Software Foundation (ASF) under one
  6789. * or more contributor license agreements. See the NOTICE file
  6790. * distributed with this work for additional information
  6791. * regarding copyright ownership. The ASF licenses this file
  6792. * to you under the Apache License, Version 2.0 (the
  6793. * "License"); you may not use this file except in compliance
  6794. * with the License. You may obtain a copy of the License at
  6795. *
  6796. * http://www.apache.org/licenses/LICENSE-2.0
  6797. *
  6798. * Unless required by applicable law or agreed to in writing,
  6799. * software distributed under the License is distributed on an
  6800. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  6801. * KIND, either express or implied. See the License for the
  6802. * specific language governing permissions and limitations
  6803. * under the License.
  6804. */
  6805. var ECHARTS_PREFIX = '[ECharts] ';
  6806. var storedLogs = {};
  6807. var hasConsole = typeof console !== 'undefined' // eslint-disable-next-line
  6808. && console.warn && console.log;
  6809. function warn(str) {
  6810. if (hasConsole) {
  6811. console.warn(ECHARTS_PREFIX + str);
  6812. }
  6813. }
  6814. function error(str) {
  6815. if (hasConsole) {
  6816. console.error(ECHARTS_PREFIX + str);
  6817. }
  6818. }
  6819. function deprecateLog(str) {
  6820. {
  6821. if (storedLogs[str]) {
  6822. // Not display duplicate message.
  6823. return;
  6824. }
  6825. if (hasConsole) {
  6826. storedLogs[str] = true;
  6827. console.warn(ECHARTS_PREFIX + 'DEPRECATED: ' + str);
  6828. }
  6829. }
  6830. }
  6831. function deprecateReplaceLog(oldOpt, newOpt, scope) {
  6832. {
  6833. deprecateLog((scope ? "[" + scope + "]" : '') + (oldOpt + " is deprecated, use " + newOpt + " instead."));
  6834. }
  6835. }
  6836. function consoleLog() {
  6837. var args = [];
  6838. for (var _i = 0; _i < arguments.length; _i++) {
  6839. args[_i] = arguments[_i];
  6840. }
  6841. {
  6842. /* eslint-disable no-console */
  6843. if (typeof console !== 'undefined' && console.log) {
  6844. console.log.apply(console, args);
  6845. }
  6846. /* eslint-enable no-console */
  6847. }
  6848. }
  6849. /**
  6850. * If in __DEV__ environment, get console printable message for users hint.
  6851. * Parameters are separated by ' '.
  6852. * @usuage
  6853. * makePrintable('This is an error on', someVar, someObj);
  6854. *
  6855. * @param hintInfo anything about the current execution context to hint users.
  6856. * @throws Error
  6857. */
  6858. function makePrintable() {
  6859. var hintInfo = [];
  6860. for (var _i = 0; _i < arguments.length; _i++) {
  6861. hintInfo[_i] = arguments[_i];
  6862. }
  6863. var msg = '';
  6864. {
  6865. // Fuzzy stringify for print.
  6866. // This code only exist in dev environment.
  6867. var makePrintableStringIfPossible_1 = function (val) {
  6868. return val === void 0 ? 'undefined' : val === Infinity ? 'Infinity' : val === -Infinity ? '-Infinity' : eqNaN(val) ? 'NaN' : val instanceof Date ? 'Date(' + val.toISOString() + ')' : isFunction$1(val) ? 'function () { ... }' : isRegExp(val) ? val + '' : null;
  6869. };
  6870. msg = map(hintInfo, function (arg) {
  6871. if (isString(arg)) {
  6872. // Print without quotation mark for some statement.
  6873. return arg;
  6874. } else {
  6875. var printableStr = makePrintableStringIfPossible_1(arg);
  6876. if (printableStr != null) {
  6877. return printableStr;
  6878. } else if (typeof JSON !== 'undefined' && JSON.stringify) {
  6879. try {
  6880. return JSON.stringify(arg, function (n, val) {
  6881. var printableStr = makePrintableStringIfPossible_1(val);
  6882. return printableStr == null ? val : printableStr;
  6883. }); // In most cases the info object is small, so do not line break.
  6884. } catch (err) {
  6885. return '?';
  6886. }
  6887. } else {
  6888. return '?';
  6889. }
  6890. }
  6891. }).join(' ');
  6892. }
  6893. return msg;
  6894. }
  6895. /**
  6896. * @throws Error
  6897. */
  6898. function throwError(msg) {
  6899. throw new Error(msg);
  6900. }
  6901. /*
  6902. * Licensed to the Apache Software Foundation (ASF) under one
  6903. * or more contributor license agreements. See the NOTICE file
  6904. * distributed with this work for additional information
  6905. * regarding copyright ownership. The ASF licenses this file
  6906. * to you under the Apache License, Version 2.0 (the
  6907. * "License"); you may not use this file except in compliance
  6908. * with the License. You may obtain a copy of the License at
  6909. *
  6910. * http://www.apache.org/licenses/LICENSE-2.0
  6911. *
  6912. * Unless required by applicable law or agreed to in writing,
  6913. * software distributed under the License is distributed on an
  6914. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  6915. * KIND, either express or implied. See the License for the
  6916. * specific language governing permissions and limitations
  6917. * under the License.
  6918. */
  6919. /**
  6920. * AUTO-GENERATED FILE. DO NOT MODIFY.
  6921. */
  6922. /*
  6923. * Licensed to the Apache Software Foundation (ASF) under one
  6924. * or more contributor license agreements. See the NOTICE file
  6925. * distributed with this work for additional information
  6926. * regarding copyright ownership. The ASF licenses this file
  6927. * to you under the Apache License, Version 2.0 (the
  6928. * "License"); you may not use this file except in compliance
  6929. * with the License. You may obtain a copy of the License at
  6930. *
  6931. * http://www.apache.org/licenses/LICENSE-2.0
  6932. *
  6933. * Unless required by applicable law or agreed to in writing,
  6934. * software distributed under the License is distributed on an
  6935. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  6936. * KIND, either express or implied. See the License for the
  6937. * specific language governing permissions and limitations
  6938. * under the License.
  6939. */
  6940. /**
  6941. * Make the name displayable. But we should
  6942. * make sure it is not duplicated with user
  6943. * specified name, so use '\0';
  6944. */
  6945. var DUMMY_COMPONENT_NAME_PREFIX = 'series\0';
  6946. var INTERNAL_COMPONENT_ID_PREFIX = '\0_ec_\0';
  6947. /**
  6948. * If value is not array, then translate it to array.
  6949. * @param {*} value
  6950. * @return {Array} [value] or value
  6951. */
  6952. function normalizeToArray(value) {
  6953. return value instanceof Array ? value : value == null ? [] : [value];
  6954. }
  6955. /**
  6956. * Sync default option between normal and emphasis like `position` and `show`
  6957. * In case some one will write code like
  6958. * label: {
  6959. * show: false,
  6960. * position: 'outside',
  6961. * fontSize: 18
  6962. * },
  6963. * emphasis: {
  6964. * label: { show: true }
  6965. * }
  6966. */
  6967. function defaultEmphasis(opt, key, subOpts) {
  6968. // Caution: performance sensitive.
  6969. if (opt) {
  6970. opt[key] = opt[key] || {};
  6971. opt.emphasis = opt.emphasis || {};
  6972. opt.emphasis[key] = opt.emphasis[key] || {}; // Default emphasis option from normal
  6973. for (var i = 0, len = subOpts.length; i < len; i++) {
  6974. var subOptName = subOpts[i];
  6975. if (!opt.emphasis[key].hasOwnProperty(subOptName) && opt[key].hasOwnProperty(subOptName)) {
  6976. opt.emphasis[key][subOptName] = opt[key][subOptName];
  6977. }
  6978. }
  6979. }
  6980. }
  6981. var TEXT_STYLE_OPTIONS = ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'rich', 'tag', 'color', 'textBorderColor', 'textBorderWidth', 'width', 'height', 'lineHeight', 'align', 'verticalAlign', 'baseline', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'textShadowColor', 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY', 'backgroundColor', 'borderColor', 'borderWidth', 'borderRadius', 'padding']; // modelUtil.LABEL_OPTIONS = modelUtil.TEXT_STYLE_OPTIONS.concat([
  6982. // 'position', 'offset', 'rotate', 'origin', 'show', 'distance', 'formatter',
  6983. // 'fontStyle', 'fontWeight', 'fontSize', 'fontFamily',
  6984. // // FIXME: deprecated, check and remove it.
  6985. // 'textStyle'
  6986. // ]);
  6987. /**
  6988. * The method do not ensure performance.
  6989. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  6990. * This helper method retieves value from data.
  6991. */
  6992. function getDataItemValue(dataItem) {
  6993. return isObject$1(dataItem) && !isArray(dataItem) && !(dataItem instanceof Date) ? dataItem.value : dataItem;
  6994. }
  6995. /**
  6996. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  6997. * This helper method determine if dataItem has extra option besides value
  6998. */
  6999. function isDataItemOption(dataItem) {
  7000. return isObject$1(dataItem) && !(dataItem instanceof Array); // // markLine data can be array
  7001. // && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  7002. }
  7003. /**
  7004. * Mapping to existings for merge.
  7005. *
  7006. * Mode "normalMege":
  7007. * The mapping result (merge result) will keep the order of the existing
  7008. * component, rather than the order of new option. Because we should ensure
  7009. * some specified index reference (like xAxisIndex) keep work.
  7010. * And in most cases, "merge option" is used to update partial option but not
  7011. * be expected to change the order.
  7012. *
  7013. * Mode "replaceMege":
  7014. * (1) Only the id mapped components will be merged.
  7015. * (2) Other existing components (except internal compoonets) will be removed.
  7016. * (3) Other new options will be used to create new component.
  7017. * (4) The index of the existing compoents will not be modified.
  7018. * That means their might be "hole" after the removal.
  7019. * The new components are created first at those available index.
  7020. *
  7021. * Mode "replaceAll":
  7022. * This mode try to support that reproduce an echarts instance from another
  7023. * echarts instance (via `getOption`) in some simple cases.
  7024. * In this senario, the `result` index are exactly the consistent with the `newCmptOptions`,
  7025. * which ensures the compoennt index referring (like `xAxisIndex: ?`) corrent. That is,
  7026. * the "hole" in `newCmptOptions` will also be kept.
  7027. * On the contrary, other modes try best to eliminate holes.
  7028. * PENDING: This is an experimental mode yet.
  7029. *
  7030. * @return See the comment of <MappingResult>.
  7031. */
  7032. function mappingToExists(existings, newCmptOptions, mode) {
  7033. var isNormalMergeMode = mode === 'normalMerge';
  7034. var isReplaceMergeMode = mode === 'replaceMerge';
  7035. var isReplaceAllMode = mode === 'replaceAll';
  7036. existings = existings || [];
  7037. newCmptOptions = (newCmptOptions || []).slice();
  7038. var existingIdIdxMap = createHashMap(); // Validate id and name on user input option.
  7039. each$1(newCmptOptions, function (cmptOption, index) {
  7040. if (!isObject$1(cmptOption)) {
  7041. newCmptOptions[index] = null;
  7042. return;
  7043. }
  7044. {
  7045. // There is some legacy case that name is set as `false`.
  7046. // But should work normally rather than throw error.
  7047. if (cmptOption.id != null && !isValidIdOrName(cmptOption.id)) {
  7048. warnInvalidateIdOrName(cmptOption.id);
  7049. }
  7050. if (cmptOption.name != null && !isValidIdOrName(cmptOption.name)) {
  7051. warnInvalidateIdOrName(cmptOption.name);
  7052. }
  7053. }
  7054. });
  7055. var result = prepareResult(existings, existingIdIdxMap, mode);
  7056. if (isNormalMergeMode || isReplaceMergeMode) {
  7057. mappingById(result, existings, existingIdIdxMap, newCmptOptions);
  7058. }
  7059. if (isNormalMergeMode) {
  7060. mappingByName(result, newCmptOptions);
  7061. }
  7062. if (isNormalMergeMode || isReplaceMergeMode) {
  7063. mappingByIndex(result, newCmptOptions, isReplaceMergeMode);
  7064. } else if (isReplaceAllMode) {
  7065. mappingInReplaceAllMode(result, newCmptOptions);
  7066. }
  7067. makeIdAndName(result); // The array `result` MUST NOT contain elided items, otherwise the
  7068. // forEach will ommit those items and result in incorrect result.
  7069. return result;
  7070. }
  7071. function prepareResult(existings, existingIdIdxMap, mode) {
  7072. var result = [];
  7073. if (mode === 'replaceAll') {
  7074. return result;
  7075. } // Do not use native `map` to in case that the array `existings`
  7076. // contains elided items, which will be ommited.
  7077. for (var index = 0; index < existings.length; index++) {
  7078. var existing = existings[index]; // Because of replaceMerge, `existing` may be null/undefined.
  7079. if (existing && existing.id != null) {
  7080. existingIdIdxMap.set(existing.id, index);
  7081. } // For non-internal-componnets:
  7082. // Mode "normalMerge": all existings kept.
  7083. // Mode "replaceMerge": all existing removed unless mapped by id.
  7084. // For internal-components:
  7085. // go with "replaceMerge" approach in both mode.
  7086. result.push({
  7087. existing: mode === 'replaceMerge' || isComponentIdInternal(existing) ? null : existing,
  7088. newOption: null,
  7089. keyInfo: null,
  7090. brandNew: null
  7091. });
  7092. }
  7093. return result;
  7094. }
  7095. function mappingById(result, existings, existingIdIdxMap, newCmptOptions) {
  7096. // Mapping by id if specified.
  7097. each$1(newCmptOptions, function (cmptOption, index) {
  7098. if (!cmptOption || cmptOption.id == null) {
  7099. return;
  7100. }
  7101. var optionId = makeComparableKey(cmptOption.id);
  7102. var existingIdx = existingIdIdxMap.get(optionId);
  7103. if (existingIdx != null) {
  7104. var resultItem = result[existingIdx];
  7105. assert$1(!resultItem.newOption, 'Duplicated option on id "' + optionId + '".');
  7106. resultItem.newOption = cmptOption; // In both mode, if id matched, new option will be merged to
  7107. // the existings rather than creating new component model.
  7108. resultItem.existing = existings[existingIdx];
  7109. newCmptOptions[index] = null;
  7110. }
  7111. });
  7112. }
  7113. function mappingByName(result, newCmptOptions) {
  7114. // Mapping by name if specified.
  7115. each$1(newCmptOptions, function (cmptOption, index) {
  7116. if (!cmptOption || cmptOption.name == null) {
  7117. return;
  7118. }
  7119. for (var i = 0; i < result.length; i++) {
  7120. var existing = result[i].existing;
  7121. if (!result[i].newOption // Consider name: two map to one.
  7122. // Can not match when both ids existing but different.
  7123. && existing && (existing.id == null || cmptOption.id == null) && !isComponentIdInternal(cmptOption) && !isComponentIdInternal(existing) && keyExistAndEqual('name', existing, cmptOption)) {
  7124. result[i].newOption = cmptOption;
  7125. newCmptOptions[index] = null;
  7126. return;
  7127. }
  7128. }
  7129. });
  7130. }
  7131. function mappingByIndex(result, newCmptOptions, brandNew) {
  7132. each$1(newCmptOptions, function (cmptOption) {
  7133. if (!cmptOption) {
  7134. return;
  7135. } // Find the first place that not mapped by id and not internal component (consider the "hole").
  7136. var resultItem;
  7137. var nextIdx = 0;
  7138. while ( // Be `!resultItem` only when `nextIdx >= result.length`.
  7139. (resultItem = result[nextIdx]) && ( // (1) Existing models that already have id should be able to mapped to. Because
  7140. // after mapping performed, model will always be assigned with an id if user not given.
  7141. // After that all models have id.
  7142. // (2) If new option has id, it can only set to a hole or append to the last. It should
  7143. // not be merged to the existings with different id. Because id should not be overwritten.
  7144. // (3) Name can be overwritten, because axis use name as 'show label text'.
  7145. resultItem.newOption || isComponentIdInternal(resultItem.existing) || // In mode "replaceMerge", here no not-mapped-non-internal-existing.
  7146. resultItem.existing && cmptOption.id != null && !keyExistAndEqual('id', cmptOption, resultItem.existing))) {
  7147. nextIdx++;
  7148. }
  7149. if (resultItem) {
  7150. resultItem.newOption = cmptOption;
  7151. resultItem.brandNew = brandNew;
  7152. } else {
  7153. result.push({
  7154. newOption: cmptOption,
  7155. brandNew: brandNew,
  7156. existing: null,
  7157. keyInfo: null
  7158. });
  7159. }
  7160. nextIdx++;
  7161. });
  7162. }
  7163. function mappingInReplaceAllMode(result, newCmptOptions) {
  7164. each$1(newCmptOptions, function (cmptOption) {
  7165. // The feature "reproduce" requires "hole" will also reproduced
  7166. // in case that compoennt index referring are broken.
  7167. result.push({
  7168. newOption: cmptOption,
  7169. brandNew: true,
  7170. existing: null,
  7171. keyInfo: null
  7172. });
  7173. });
  7174. }
  7175. /**
  7176. * Make id and name for mapping result (result of mappingToExists)
  7177. * into `keyInfo` field.
  7178. */
  7179. function makeIdAndName(mapResult) {
  7180. // We use this id to hash component models and view instances
  7181. // in echarts. id can be specified by user, or auto generated.
  7182. // The id generation rule ensures new view instance are able
  7183. // to mapped to old instance when setOption are called in
  7184. // no-merge mode. So we generate model id by name and plus
  7185. // type in view id.
  7186. // name can be duplicated among components, which is convenient
  7187. // to specify multi components (like series) by one name.
  7188. // Ensure that each id is distinct.
  7189. var idMap = createHashMap();
  7190. each$1(mapResult, function (item) {
  7191. var existing = item.existing;
  7192. existing && idMap.set(existing.id, item);
  7193. });
  7194. each$1(mapResult, function (item) {
  7195. var opt = item.newOption; // Force ensure id not duplicated.
  7196. assert$1(!opt || opt.id == null || !idMap.get(opt.id) || idMap.get(opt.id) === item, 'id duplicates: ' + (opt && opt.id));
  7197. opt && opt.id != null && idMap.set(opt.id, item);
  7198. !item.keyInfo && (item.keyInfo = {});
  7199. }); // Make name and id.
  7200. each$1(mapResult, function (item, index) {
  7201. var existing = item.existing;
  7202. var opt = item.newOption;
  7203. var keyInfo = item.keyInfo;
  7204. if (!isObject$1(opt)) {
  7205. return;
  7206. } // name can be overwitten. Consider case: axis.name = '20km'.
  7207. // But id generated by name will not be changed, which affect
  7208. // only in that case: setOption with 'not merge mode' and view
  7209. // instance will be recreated, which can be accepted.
  7210. keyInfo.name = opt.name != null ? makeComparableKey(opt.name) : existing ? existing.name // Avoid diffferent series has the same name,
  7211. // because name may be used like in color pallet.
  7212. : DUMMY_COMPONENT_NAME_PREFIX + index;
  7213. if (existing) {
  7214. keyInfo.id = makeComparableKey(existing.id);
  7215. } else if (opt.id != null) {
  7216. keyInfo.id = makeComparableKey(opt.id);
  7217. } else {
  7218. // Consider this situatoin:
  7219. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  7220. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  7221. // Series with the same name between optionA and optionB
  7222. // should be mapped.
  7223. var idNum = 0;
  7224. do {
  7225. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  7226. } while (idMap.get(keyInfo.id));
  7227. }
  7228. idMap.set(keyInfo.id, item);
  7229. });
  7230. }
  7231. function keyExistAndEqual(attr, obj1, obj2) {
  7232. var key1 = convertOptionIdName(obj1[attr], null);
  7233. var key2 = convertOptionIdName(obj2[attr], null); // See `MappingExistingItem`. `id` and `name` trade string equals to number.
  7234. return key1 != null && key2 != null && key1 === key2;
  7235. }
  7236. /**
  7237. * @return return null if not exist.
  7238. */
  7239. function makeComparableKey(val) {
  7240. {
  7241. if (val == null) {
  7242. throw new Error();
  7243. }
  7244. }
  7245. return convertOptionIdName(val, '');
  7246. }
  7247. function convertOptionIdName(idOrName, defaultValue) {
  7248. if (idOrName == null) {
  7249. return defaultValue;
  7250. }
  7251. var type = typeof idOrName;
  7252. return type === 'string' ? idOrName : type === 'number' || isStringSafe(idOrName) ? idOrName + '' : defaultValue;
  7253. }
  7254. function warnInvalidateIdOrName(idOrName) {
  7255. {
  7256. warn('`' + idOrName + '` is invalid id or name. Must be a string or number.');
  7257. }
  7258. }
  7259. function isValidIdOrName(idOrName) {
  7260. return isStringSafe(idOrName) || isNumeric(idOrName);
  7261. }
  7262. function isNameSpecified(componentModel) {
  7263. var name = componentModel.name; // Is specified when `indexOf` get -1 or > 0.
  7264. return !!(name && name.indexOf(DUMMY_COMPONENT_NAME_PREFIX));
  7265. }
  7266. /**
  7267. * @public
  7268. * @param {Object} cmptOption
  7269. * @return {boolean}
  7270. */
  7271. function isComponentIdInternal(cmptOption) {
  7272. return cmptOption && cmptOption.id != null && makeComparableKey(cmptOption.id).indexOf(INTERNAL_COMPONENT_ID_PREFIX) === 0;
  7273. }
  7274. function makeInternalComponentId(idSuffix) {
  7275. return INTERNAL_COMPONENT_ID_PREFIX + idSuffix;
  7276. }
  7277. function setComponentTypeToKeyInfo(mappingResult, mainType, componentModelCtor) {
  7278. // Set mainType and complete subType.
  7279. each$1(mappingResult, function (item) {
  7280. var newOption = item.newOption;
  7281. if (isObject$1(newOption)) {
  7282. item.keyInfo.mainType = mainType;
  7283. item.keyInfo.subType = determineSubType(mainType, newOption, item.existing, componentModelCtor);
  7284. }
  7285. });
  7286. }
  7287. function determineSubType(mainType, newCmptOption, existComponent, componentModelCtor) {
  7288. var subType = newCmptOption.type ? newCmptOption.type : existComponent ? existComponent.subType // Use determineSubType only when there is no existComponent.
  7289. : componentModelCtor.determineSubType(mainType, newCmptOption); // tooltip, markline, markpoint may always has no subType
  7290. return subType;
  7291. }
  7292. /**
  7293. * A helper for removing duplicate items between batchA and batchB,
  7294. * and in themselves, and categorize by series.
  7295. *
  7296. * @param batchA Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  7297. * @param batchB Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  7298. * @return result: [resultBatchA, resultBatchB]
  7299. */
  7300. function compressBatches(batchA, batchB) {
  7301. var mapA = {};
  7302. var mapB = {};
  7303. makeMap(batchA || [], mapA);
  7304. makeMap(batchB || [], mapB, mapA);
  7305. return [mapToArray(mapA), mapToArray(mapB)];
  7306. function makeMap(sourceBatch, map$$1, otherMap) {
  7307. for (var i = 0, len = sourceBatch.length; i < len; i++) {
  7308. var seriesId = convertOptionIdName(sourceBatch[i].seriesId, null);
  7309. if (seriesId == null) {
  7310. return;
  7311. }
  7312. var dataIndices = normalizeToArray(sourceBatch[i].dataIndex);
  7313. var otherDataIndices = otherMap && otherMap[seriesId];
  7314. for (var j = 0, lenj = dataIndices.length; j < lenj; j++) {
  7315. var dataIndex = dataIndices[j];
  7316. if (otherDataIndices && otherDataIndices[dataIndex]) {
  7317. otherDataIndices[dataIndex] = null;
  7318. } else {
  7319. (map$$1[seriesId] || (map$$1[seriesId] = {}))[dataIndex] = 1;
  7320. }
  7321. }
  7322. }
  7323. }
  7324. function mapToArray(map$$1, isData) {
  7325. var result = [];
  7326. for (var i in map$$1) {
  7327. if (map$$1.hasOwnProperty(i) && map$$1[i] != null) {
  7328. if (isData) {
  7329. result.push(+i);
  7330. } else {
  7331. var dataIndices = mapToArray(map$$1[i], true);
  7332. dataIndices.length && result.push({
  7333. seriesId: i,
  7334. dataIndex: dataIndices
  7335. });
  7336. }
  7337. }
  7338. }
  7339. return result;
  7340. }
  7341. }
  7342. /**
  7343. * @param payload Contains dataIndex (means rawIndex) / dataIndexInside / name
  7344. * each of which can be Array or primary type.
  7345. * @return dataIndex If not found, return undefined/null.
  7346. */
  7347. function queryDataIndex(data, payload) {
  7348. if (payload.dataIndexInside != null) {
  7349. return payload.dataIndexInside;
  7350. } else if (payload.dataIndex != null) {
  7351. return isArray(payload.dataIndex) ? map(payload.dataIndex, function (value) {
  7352. return data.indexOfRawIndex(value);
  7353. }) : data.indexOfRawIndex(payload.dataIndex);
  7354. } else if (payload.name != null) {
  7355. return isArray(payload.name) ? map(payload.name, function (value) {
  7356. return data.indexOfName(value);
  7357. }) : data.indexOfName(payload.name);
  7358. }
  7359. }
  7360. /**
  7361. * Enable property storage to any host object.
  7362. * Notice: Serialization is not supported.
  7363. *
  7364. * For example:
  7365. * let inner = zrUitl.makeInner();
  7366. *
  7367. * function some1(hostObj) {
  7368. * inner(hostObj).someProperty = 1212;
  7369. * ...
  7370. * }
  7371. * function some2() {
  7372. * let fields = inner(this);
  7373. * fields.someProperty1 = 1212;
  7374. * fields.someProperty2 = 'xx';
  7375. * ...
  7376. * }
  7377. *
  7378. * @return {Function}
  7379. */
  7380. function makeInner() {
  7381. var key = '__ec_inner_' + innerUniqueIndex++;
  7382. return function (hostObj) {
  7383. return hostObj[key] || (hostObj[key] = {});
  7384. };
  7385. }
  7386. var innerUniqueIndex = getRandomIdBase();
  7387. /**
  7388. * The same behavior as `component.getReferringComponents`.
  7389. */
  7390. function parseFinder(ecModel, finderInput, opt) {
  7391. var _a = preParseFinder(finderInput, opt),
  7392. mainTypeSpecified = _a.mainTypeSpecified,
  7393. queryOptionMap = _a.queryOptionMap,
  7394. others = _a.others;
  7395. var result = others;
  7396. var defaultMainType = opt ? opt.defaultMainType : null;
  7397. if (!mainTypeSpecified && defaultMainType) {
  7398. queryOptionMap.set(defaultMainType, {});
  7399. }
  7400. queryOptionMap.each(function (queryOption, mainType) {
  7401. var queryResult = queryReferringComponents(ecModel, mainType, queryOption, {
  7402. useDefault: defaultMainType === mainType,
  7403. enableAll: opt && opt.enableAll != null ? opt.enableAll : true,
  7404. enableNone: opt && opt.enableNone != null ? opt.enableNone : true
  7405. });
  7406. result[mainType + 'Models'] = queryResult.models;
  7407. result[mainType + 'Model'] = queryResult.models[0];
  7408. });
  7409. return result;
  7410. }
  7411. function preParseFinder(finderInput, opt) {
  7412. var finder;
  7413. if (isString(finderInput)) {
  7414. var obj = {};
  7415. obj[finderInput + 'Index'] = 0;
  7416. finder = obj;
  7417. } else {
  7418. finder = finderInput;
  7419. }
  7420. var queryOptionMap = createHashMap();
  7421. var others = {};
  7422. var mainTypeSpecified = false;
  7423. each$1(finder, function (value, key) {
  7424. // Exclude 'dataIndex' and other illgal keys.
  7425. if (key === 'dataIndex' || key === 'dataIndexInside') {
  7426. others[key] = value;
  7427. return;
  7428. }
  7429. var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || [];
  7430. var mainType = parsedKey[1];
  7431. var queryType = (parsedKey[2] || '').toLowerCase();
  7432. if (!mainType || !queryType || opt && opt.includeMainTypes && indexOf$1(opt.includeMainTypes, mainType) < 0) {
  7433. return;
  7434. }
  7435. mainTypeSpecified = mainTypeSpecified || !!mainType;
  7436. var queryOption = queryOptionMap.get(mainType) || queryOptionMap.set(mainType, {});
  7437. queryOption[queryType] = value;
  7438. });
  7439. return {
  7440. mainTypeSpecified: mainTypeSpecified,
  7441. queryOptionMap: queryOptionMap,
  7442. others: others
  7443. };
  7444. }
  7445. var SINGLE_REFERRING = {
  7446. useDefault: true,
  7447. enableAll: false,
  7448. enableNone: false
  7449. };
  7450. var MULTIPLE_REFERRING = {
  7451. useDefault: false,
  7452. enableAll: true,
  7453. enableNone: true
  7454. };
  7455. function queryReferringComponents(ecModel, mainType, userOption, opt) {
  7456. opt = opt || SINGLE_REFERRING;
  7457. var indexOption = userOption.index;
  7458. var idOption = userOption.id;
  7459. var nameOption = userOption.name;
  7460. var result = {
  7461. models: null,
  7462. specified: indexOption != null || idOption != null || nameOption != null
  7463. };
  7464. if (!result.specified) {
  7465. // Use the first as default if `useDefault`.
  7466. var firstCmpt = void 0;
  7467. result.models = opt.useDefault && (firstCmpt = ecModel.getComponent(mainType)) ? [firstCmpt] : [];
  7468. return result;
  7469. }
  7470. if (indexOption === 'none' || indexOption === false) {
  7471. assert$1(opt.enableNone, '`"none"` or `false` is not a valid value on index option.');
  7472. result.models = [];
  7473. return result;
  7474. } // `queryComponents` will return all components if
  7475. // both all of index/id/name are null/undefined.
  7476. if (indexOption === 'all') {
  7477. assert$1(opt.enableAll, '`"all"` is not a valid value on index option.');
  7478. indexOption = idOption = nameOption = null;
  7479. }
  7480. result.models = ecModel.queryComponents({
  7481. mainType: mainType,
  7482. index: indexOption,
  7483. id: idOption,
  7484. name: nameOption
  7485. });
  7486. return result;
  7487. }
  7488. function setAttribute(dom, key, value) {
  7489. dom.setAttribute ? dom.setAttribute(key, value) : dom[key] = value;
  7490. }
  7491. function getAttribute(dom, key) {
  7492. return dom.getAttribute ? dom.getAttribute(key) : dom[key];
  7493. }
  7494. function getTooltipRenderMode(renderModeOption) {
  7495. if (renderModeOption === 'auto') {
  7496. // Using html when `document` exists, use richText otherwise
  7497. return env.domSupported ? 'html' : 'richText';
  7498. } else {
  7499. return renderModeOption || 'html';
  7500. }
  7501. }
  7502. /**
  7503. * Group a list by key.
  7504. */
  7505. function groupData(array, getKey // return key
  7506. ) {
  7507. var buckets = createHashMap();
  7508. var keys$$1 = [];
  7509. each$1(array, function (item) {
  7510. var key = getKey(item);
  7511. (buckets.get(key) || (keys$$1.push(key), buckets.set(key, []))).push(item);
  7512. });
  7513. return {
  7514. keys: keys$$1,
  7515. buckets: buckets
  7516. };
  7517. }
  7518. /**
  7519. * Interpolate raw values of a series with percent
  7520. *
  7521. * @param data data
  7522. * @param labelModel label model of the text element
  7523. * @param sourceValue start value. May be null/undefined when init.
  7524. * @param targetValue end value
  7525. * @param percent 0~1 percentage; 0 uses start value while 1 uses end value
  7526. * @return interpolated values
  7527. * If `sourceValue` and `targetValue` are `number`, return `number`.
  7528. * If `sourceValue` and `targetValue` are `string`, return `string`.
  7529. * If `sourceValue` and `targetValue` are `(string | number)[]`, return `(string | number)[]`.
  7530. * Other cases do not supported.
  7531. */
  7532. function interpolateRawValues(data, precision, sourceValue, targetValue, percent) {
  7533. var isAutoPrecision = precision == null || precision === 'auto';
  7534. if (targetValue == null) {
  7535. return targetValue;
  7536. }
  7537. if (typeof targetValue === 'number') {
  7538. var value = interpolateNumber(sourceValue || 0, targetValue, percent);
  7539. return round(value, isAutoPrecision ? Math.max(getPrecisionSafe(sourceValue || 0), getPrecisionSafe(targetValue)) : precision);
  7540. } else if (typeof targetValue === 'string') {
  7541. return percent < 1 ? sourceValue : targetValue;
  7542. } else {
  7543. var interpolated = [];
  7544. var leftArr = sourceValue;
  7545. var rightArr = targetValue;
  7546. var length_1 = Math.max(leftArr ? leftArr.length : 0, rightArr.length);
  7547. for (var i = 0; i < length_1; ++i) {
  7548. var info = data.getDimensionInfo(i); // Don't interpolate ordinal dims
  7549. if (info.type === 'ordinal') {
  7550. // In init, there is no `sourceValue`, but should better not to get undefined result.
  7551. interpolated[i] = (percent < 1 && leftArr ? leftArr : rightArr)[i];
  7552. } else {
  7553. var leftVal = leftArr && leftArr[i] ? leftArr[i] : 0;
  7554. var rightVal = rightArr[i];
  7555. var value = interpolateNumber(leftVal, rightVal, percent);
  7556. interpolated[i] = round(value, isAutoPrecision ? Math.max(getPrecisionSafe(leftVal), getPrecisionSafe(rightVal)) : precision);
  7557. }
  7558. }
  7559. return interpolated;
  7560. }
  7561. }
  7562. /*
  7563. * Licensed to the Apache Software Foundation (ASF) under one
  7564. * or more contributor license agreements. See the NOTICE file
  7565. * distributed with this work for additional information
  7566. * regarding copyright ownership. The ASF licenses this file
  7567. * to you under the Apache License, Version 2.0 (the
  7568. * "License"); you may not use this file except in compliance
  7569. * with the License. You may obtain a copy of the License at
  7570. *
  7571. * http://www.apache.org/licenses/LICENSE-2.0
  7572. *
  7573. * Unless required by applicable law or agreed to in writing,
  7574. * software distributed under the License is distributed on an
  7575. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7576. * KIND, either express or implied. See the License for the
  7577. * specific language governing permissions and limitations
  7578. * under the License.
  7579. */
  7580. /**
  7581. * AUTO-GENERATED FILE. DO NOT MODIFY.
  7582. */
  7583. /*
  7584. * Licensed to the Apache Software Foundation (ASF) under one
  7585. * or more contributor license agreements. See the NOTICE file
  7586. * distributed with this work for additional information
  7587. * regarding copyright ownership. The ASF licenses this file
  7588. * to you under the Apache License, Version 2.0 (the
  7589. * "License"); you may not use this file except in compliance
  7590. * with the License. You may obtain a copy of the License at
  7591. *
  7592. * http://www.apache.org/licenses/LICENSE-2.0
  7593. *
  7594. * Unless required by applicable law or agreed to in writing,
  7595. * software distributed under the License is distributed on an
  7596. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7597. * KIND, either express or implied. See the License for the
  7598. * specific language governing permissions and limitations
  7599. * under the License.
  7600. */
  7601. var TYPE_DELIMITER = '.';
  7602. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  7603. var IS_EXTENDED_CLASS = '___EC__EXTENDED_CLASS___';
  7604. /**
  7605. * Notice, parseClassType('') should returns {main: '', sub: ''}
  7606. * @public
  7607. */
  7608. function parseClassType(componentType) {
  7609. var ret = {
  7610. main: '',
  7611. sub: ''
  7612. };
  7613. if (componentType) {
  7614. var typeArr = componentType.split(TYPE_DELIMITER);
  7615. ret.main = typeArr[0] || '';
  7616. ret.sub = typeArr[1] || '';
  7617. }
  7618. return ret;
  7619. }
  7620. /**
  7621. * @public
  7622. */
  7623. function checkClassType(componentType) {
  7624. assert$1(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType), 'componentType "' + componentType + '" illegal');
  7625. }
  7626. function isExtendedClass(clz) {
  7627. return !!(clz && clz[IS_EXTENDED_CLASS]);
  7628. }
  7629. /**
  7630. * Implements `ExtendableConstructor` for `rootClz`.
  7631. *
  7632. * @usage
  7633. * ```ts
  7634. * class Xxx {}
  7635. * type XxxConstructor = typeof Xxx & ExtendableConstructor
  7636. * enableClassExtend(Xxx as XxxConstructor);
  7637. * ```
  7638. */
  7639. function enableClassExtend(rootClz, mandatoryMethods) {
  7640. rootClz.$constructor = rootClz; // FIXME: not necessary?
  7641. rootClz.extend = function (proto) {
  7642. {
  7643. each$1(mandatoryMethods, function (method) {
  7644. if (!proto[method]) {
  7645. console.warn('Method `' + method + '` should be implemented' + (proto.type ? ' in ' + proto.type : '') + '.');
  7646. }
  7647. });
  7648. }
  7649. var superClass = this; // For backward compat, we both support ts class inheritance and this
  7650. // "extend" approach.
  7651. // The constructor should keep the same behavior as ts class inheritance:
  7652. // If this constructor/$constructor is not declared, auto invoke the super
  7653. // constructor.
  7654. // If this constructor/$constructor is declared, it is responsible for
  7655. // calling the super constructor.
  7656. function ExtendedClass() {
  7657. var args = [];
  7658. for (var _i = 0; _i < arguments.length; _i++) {
  7659. args[_i] = arguments[_i];
  7660. }
  7661. if (!proto.$constructor) {
  7662. if (!isESClass(superClass)) {
  7663. // Will throw error if superClass is an es6 native class.
  7664. superClass.apply(this, arguments);
  7665. } else {
  7666. var ins = createObject( // @ts-ignore
  7667. ExtendedClass.prototype, new (superClass.bind.apply(superClass, __spreadArrays([void 0], args)))());
  7668. return ins;
  7669. }
  7670. } else {
  7671. proto.$constructor.apply(this, arguments);
  7672. }
  7673. }
  7674. ExtendedClass[IS_EXTENDED_CLASS] = true;
  7675. extend(ExtendedClass.prototype, proto);
  7676. ExtendedClass.extend = this.extend;
  7677. ExtendedClass.superCall = superCall;
  7678. ExtendedClass.superApply = superApply;
  7679. inherits(ExtendedClass, this);
  7680. ExtendedClass.superClass = superClass;
  7681. return ExtendedClass;
  7682. };
  7683. }
  7684. function isESClass(fn) {
  7685. return typeof fn === 'function' && /^class\s/.test(Function.prototype.toString.call(fn));
  7686. }
  7687. /**
  7688. * A work around to both support ts extend and this extend mechanism.
  7689. * on sub-class.
  7690. * @usage
  7691. * ```ts
  7692. * class Component { ... }
  7693. * classUtil.enableClassExtend(Component);
  7694. * classUtil.enableClassManagement(Component, {registerWhenExtend: true});
  7695. *
  7696. * class Series extends Component { ... }
  7697. * // Without calling `markExtend`, `registerWhenExtend` will not work.
  7698. * Component.markExtend(Series);
  7699. * ```
  7700. */
  7701. function mountExtend(SubClz, SupperClz) {
  7702. SubClz.extend = SupperClz.extend;
  7703. } // A random offset.
  7704. var classBase = Math.round(Math.random() * 10);
  7705. /**
  7706. * Implements `CheckableConstructor` for `target`.
  7707. * Can not use instanceof, consider different scope by
  7708. * cross domain or es module import in ec extensions.
  7709. * Mount a method "isInstance()" to Clz.
  7710. *
  7711. * @usage
  7712. * ```ts
  7713. * class Xxx {}
  7714. * type XxxConstructor = typeof Xxx & CheckableConstructor;
  7715. * enableClassCheck(Xxx as XxxConstructor)
  7716. * ```
  7717. */
  7718. function enableClassCheck(target) {
  7719. var classAttr = ['__\0is_clz', classBase++].join('_');
  7720. target.prototype[classAttr] = true;
  7721. {
  7722. assert$1(!target.isInstance, 'The method "is" can not be defined.');
  7723. }
  7724. target.isInstance = function (obj) {
  7725. return !!(obj && obj[classAttr]);
  7726. };
  7727. } // superCall should have class info, which can not be fetch from 'this'.
  7728. // Consider this case:
  7729. // class A has method f,
  7730. // class B inherits class A, overrides method f, f call superApply('f'),
  7731. // class C inherits class B, do not overrides method f,
  7732. // then when method of class C is called, dead loop occured.
  7733. function superCall(context, methodName) {
  7734. var args = [];
  7735. for (var _i = 2; _i < arguments.length; _i++) {
  7736. args[_i - 2] = arguments[_i];
  7737. }
  7738. return this.superClass.prototype[methodName].apply(context, args);
  7739. }
  7740. function superApply(context, methodName, args) {
  7741. return this.superClass.prototype[methodName].apply(context, args);
  7742. }
  7743. /**
  7744. * Implements `ClassManager` for `target`
  7745. *
  7746. * @usage
  7747. * ```ts
  7748. * class Xxx {}
  7749. * type XxxConstructor = typeof Xxx & ClassManager
  7750. * enableClassManagement(Xxx as XxxConstructor);
  7751. * ```
  7752. */
  7753. function enableClassManagement(target) {
  7754. /**
  7755. * Component model classes
  7756. * key: componentType,
  7757. * value:
  7758. * componentClass, when componentType is 'xxx'
  7759. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  7760. */
  7761. var storage = {};
  7762. target.registerClass = function (clz) {
  7763. // `type` should not be a "instance memeber".
  7764. // If using TS class, should better declared as `static type = 'series.pie'`.
  7765. // otherwise users have to mount `type` on prototype manually.
  7766. // For backward compat and enable instance visit type via `this.type`,
  7767. // we stil support fetch `type` from prototype.
  7768. var componentFullType = clz.type || clz.prototype.type;
  7769. if (componentFullType) {
  7770. checkClassType(componentFullType); // If only static type declared, we assign it to prototype mandatorily.
  7771. clz.prototype.type = componentFullType;
  7772. var componentTypeInfo = parseClassType(componentFullType);
  7773. if (!componentTypeInfo.sub) {
  7774. {
  7775. if (storage[componentTypeInfo.main]) {
  7776. console.warn(componentTypeInfo.main + ' exists.');
  7777. }
  7778. }
  7779. storage[componentTypeInfo.main] = clz;
  7780. } else if (componentTypeInfo.sub !== IS_CONTAINER) {
  7781. var container = makeContainer(componentTypeInfo);
  7782. container[componentTypeInfo.sub] = clz;
  7783. }
  7784. }
  7785. return clz;
  7786. };
  7787. target.getClass = function (mainType, subType, throwWhenNotFound) {
  7788. var clz = storage[mainType];
  7789. if (clz && clz[IS_CONTAINER]) {
  7790. clz = subType ? clz[subType] : null;
  7791. }
  7792. if (throwWhenNotFound && !clz) {
  7793. throw new Error(!subType ? mainType + '.' + 'type should be specified.' : 'Component ' + mainType + '.' + (subType || '') + ' is used but not imported.');
  7794. }
  7795. return clz;
  7796. };
  7797. target.getClassesByMainType = function (componentType) {
  7798. var componentTypeInfo = parseClassType(componentType);
  7799. var result = [];
  7800. var obj = storage[componentTypeInfo.main];
  7801. if (obj && obj[IS_CONTAINER]) {
  7802. each$1(obj, function (o, type) {
  7803. type !== IS_CONTAINER && result.push(o);
  7804. });
  7805. } else {
  7806. result.push(obj);
  7807. }
  7808. return result;
  7809. };
  7810. target.hasClass = function (componentType) {
  7811. // Just consider componentType.main.
  7812. var componentTypeInfo = parseClassType(componentType);
  7813. return !!storage[componentTypeInfo.main];
  7814. };
  7815. /**
  7816. * @return Like ['aa', 'bb'], but can not be ['aa.xx']
  7817. */
  7818. target.getAllClassMainTypes = function () {
  7819. var types = [];
  7820. each$1(storage, function (obj, type) {
  7821. types.push(type);
  7822. });
  7823. return types;
  7824. };
  7825. /**
  7826. * If a main type is container and has sub types
  7827. */
  7828. target.hasSubTypes = function (componentType) {
  7829. var componentTypeInfo = parseClassType(componentType);
  7830. var obj = storage[componentTypeInfo.main];
  7831. return obj && obj[IS_CONTAINER];
  7832. };
  7833. function makeContainer(componentTypeInfo) {
  7834. var container = storage[componentTypeInfo.main];
  7835. if (!container || !container[IS_CONTAINER]) {
  7836. container = storage[componentTypeInfo.main] = {};
  7837. container[IS_CONTAINER] = true;
  7838. }
  7839. return container;
  7840. }
  7841. } // /**
  7842. // * @param {string|Array.<string>} properties
  7843. // */
  7844. // export function setReadOnly(obj, properties) {
  7845. // FIXME It seems broken in IE8 simulation of IE11
  7846. // if (!zrUtil.isArray(properties)) {
  7847. // properties = properties != null ? [properties] : [];
  7848. // }
  7849. // zrUtil.each(properties, function (prop) {
  7850. // let value = obj[prop];
  7851. // Object.defineProperty
  7852. // && Object.defineProperty(obj, prop, {
  7853. // value: value, writable: false
  7854. // });
  7855. // zrUtil.isArray(obj[prop])
  7856. // && Object.freeze
  7857. // && Object.freeze(obj[prop]);
  7858. // });
  7859. // }
  7860. /*
  7861. * Licensed to the Apache Software Foundation (ASF) under one
  7862. * or more contributor license agreements. See the NOTICE file
  7863. * distributed with this work for additional information
  7864. * regarding copyright ownership. The ASF licenses this file
  7865. * to you under the Apache License, Version 2.0 (the
  7866. * "License"); you may not use this file except in compliance
  7867. * with the License. You may obtain a copy of the License at
  7868. *
  7869. * http://www.apache.org/licenses/LICENSE-2.0
  7870. *
  7871. * Unless required by applicable law or agreed to in writing,
  7872. * software distributed under the License is distributed on an
  7873. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7874. * KIND, either express or implied. See the License for the
  7875. * specific language governing permissions and limitations
  7876. * under the License.
  7877. */
  7878. /**
  7879. * AUTO-GENERATED FILE. DO NOT MODIFY.
  7880. */
  7881. /*
  7882. * Licensed to the Apache Software Foundation (ASF) under one
  7883. * or more contributor license agreements. See the NOTICE file
  7884. * distributed with this work for additional information
  7885. * regarding copyright ownership. The ASF licenses this file
  7886. * to you under the Apache License, Version 2.0 (the
  7887. * "License"); you may not use this file except in compliance
  7888. * with the License. You may obtain a copy of the License at
  7889. *
  7890. * http://www.apache.org/licenses/LICENSE-2.0
  7891. *
  7892. * Unless required by applicable law or agreed to in writing,
  7893. * software distributed under the License is distributed on an
  7894. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7895. * KIND, either express or implied. See the License for the
  7896. * specific language governing permissions and limitations
  7897. * under the License.
  7898. */
  7899. // TODO Parse shadow style
  7900. // TODO Only shallow path support
  7901. function makeStyleMapper(properties, ignoreParent) {
  7902. // Normalize
  7903. for (var i = 0; i < properties.length; i++) {
  7904. if (!properties[i][1]) {
  7905. properties[i][1] = properties[i][0];
  7906. }
  7907. }
  7908. ignoreParent = ignoreParent || false;
  7909. return function (model, excludes, includes) {
  7910. var style = {};
  7911. for (var i = 0; i < properties.length; i++) {
  7912. var propName = properties[i][1];
  7913. if (excludes && indexOf$1(excludes, propName) >= 0 || includes && indexOf$1(includes, propName) < 0) {
  7914. continue;
  7915. }
  7916. var val = model.getShallow(propName, ignoreParent);
  7917. if (val != null) {
  7918. style[properties[i][0]] = val;
  7919. }
  7920. } // TODO Text or image?
  7921. return style;
  7922. };
  7923. }
  7924. /*
  7925. * Licensed to the Apache Software Foundation (ASF) under one
  7926. * or more contributor license agreements. See the NOTICE file
  7927. * distributed with this work for additional information
  7928. * regarding copyright ownership. The ASF licenses this file
  7929. * to you under the Apache License, Version 2.0 (the
  7930. * "License"); you may not use this file except in compliance
  7931. * with the License. You may obtain a copy of the License at
  7932. *
  7933. * http://www.apache.org/licenses/LICENSE-2.0
  7934. *
  7935. * Unless required by applicable law or agreed to in writing,
  7936. * software distributed under the License is distributed on an
  7937. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7938. * KIND, either express or implied. See the License for the
  7939. * specific language governing permissions and limitations
  7940. * under the License.
  7941. */
  7942. /**
  7943. * AUTO-GENERATED FILE. DO NOT MODIFY.
  7944. */
  7945. /*
  7946. * Licensed to the Apache Software Foundation (ASF) under one
  7947. * or more contributor license agreements. See the NOTICE file
  7948. * distributed with this work for additional information
  7949. * regarding copyright ownership. The ASF licenses this file
  7950. * to you under the Apache License, Version 2.0 (the
  7951. * "License"); you may not use this file except in compliance
  7952. * with the License. You may obtain a copy of the License at
  7953. *
  7954. * http://www.apache.org/licenses/LICENSE-2.0
  7955. *
  7956. * Unless required by applicable law or agreed to in writing,
  7957. * software distributed under the License is distributed on an
  7958. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7959. * KIND, either express or implied. See the License for the
  7960. * specific language governing permissions and limitations
  7961. * under the License.
  7962. */
  7963. var AREA_STYLE_KEY_MAP = [['fill', 'color'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['opacity'], ['shadowColor'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  7964. // So do not transfer decal directly.
  7965. ];
  7966. var getAreaStyle = makeStyleMapper(AREA_STYLE_KEY_MAP);
  7967. var AreaStyleMixin =
  7968. /** @class */
  7969. function () {
  7970. function AreaStyleMixin() {}
  7971. AreaStyleMixin.prototype.getAreaStyle = function (excludes, includes) {
  7972. return getAreaStyle(this, excludes, includes);
  7973. };
  7974. return AreaStyleMixin;
  7975. }();
  7976. var globalImageCache = new LRU(50);
  7977. function findExistImage(newImageOrSrc) {
  7978. if (typeof newImageOrSrc === 'string') {
  7979. var cachedImgObj = globalImageCache.get(newImageOrSrc);
  7980. return cachedImgObj && cachedImgObj.image;
  7981. } else {
  7982. return newImageOrSrc;
  7983. }
  7984. }
  7985. function createOrUpdateImage(newImageOrSrc, image, hostEl, onload, cbPayload) {
  7986. if (!newImageOrSrc) {
  7987. return image;
  7988. } else if (typeof newImageOrSrc === 'string') {
  7989. if (image && image.__zrImageSrc === newImageOrSrc || !hostEl) {
  7990. return image;
  7991. }
  7992. var cachedImgObj = globalImageCache.get(newImageOrSrc);
  7993. var pendingWrap = {
  7994. hostEl: hostEl,
  7995. cb: onload,
  7996. cbPayload: cbPayload
  7997. };
  7998. if (cachedImgObj) {
  7999. image = cachedImgObj.image;
  8000. !isImageReady(image) && cachedImgObj.pending.push(pendingWrap);
  8001. } else {
  8002. image = new Image();
  8003. image.onload = image.onerror = imageOnLoad;
  8004. globalImageCache.put(newImageOrSrc, image.__cachedImgObj = {
  8005. image: image,
  8006. pending: [pendingWrap]
  8007. });
  8008. image.src = image.__zrImageSrc = newImageOrSrc;
  8009. }
  8010. return image;
  8011. } else {
  8012. return newImageOrSrc;
  8013. }
  8014. }
  8015. function imageOnLoad() {
  8016. var cachedImgObj = this.__cachedImgObj;
  8017. this.onload = this.onerror = this.__cachedImgObj = null;
  8018. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  8019. var pendingWrap = cachedImgObj.pending[i];
  8020. var cb = pendingWrap.cb;
  8021. cb && cb(this, pendingWrap.cbPayload);
  8022. pendingWrap.hostEl.dirty();
  8023. }
  8024. cachedImgObj.pending.length = 0;
  8025. }
  8026. function isImageReady(image) {
  8027. return image && image.width && image.height;
  8028. }
  8029. var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
  8030. function truncateText(text, containerWidth, font, ellipsis, options) {
  8031. if (!containerWidth) {
  8032. return '';
  8033. }
  8034. var textLines = (text + '').split('\n');
  8035. options = prepareTruncateOptions(containerWidth, font, ellipsis, options);
  8036. for (var i = 0, len = textLines.length; i < len; i++) {
  8037. textLines[i] = truncateSingleLine(textLines[i], options);
  8038. }
  8039. return textLines.join('\n');
  8040. }
  8041. function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
  8042. options = options || {};
  8043. var preparedOpts = extend({}, options);
  8044. preparedOpts.font = font;
  8045. ellipsis = retrieve2(ellipsis, '...');
  8046. preparedOpts.maxIterations = retrieve2(options.maxIterations, 2);
  8047. var minChar = preparedOpts.minChar = retrieve2(options.minChar, 0);
  8048. preparedOpts.cnCharWidth = getWidth('国', font);
  8049. var ascCharWidth = preparedOpts.ascCharWidth = getWidth('a', font);
  8050. preparedOpts.placeholder = retrieve2(options.placeholder, '');
  8051. var contentWidth = containerWidth = Math.max(0, containerWidth - 1);
  8052. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  8053. contentWidth -= ascCharWidth;
  8054. }
  8055. var ellipsisWidth = getWidth(ellipsis, font);
  8056. if (ellipsisWidth > contentWidth) {
  8057. ellipsis = '';
  8058. ellipsisWidth = 0;
  8059. }
  8060. contentWidth = containerWidth - ellipsisWidth;
  8061. preparedOpts.ellipsis = ellipsis;
  8062. preparedOpts.ellipsisWidth = ellipsisWidth;
  8063. preparedOpts.contentWidth = contentWidth;
  8064. preparedOpts.containerWidth = containerWidth;
  8065. return preparedOpts;
  8066. }
  8067. function truncateSingleLine(textLine, options) {
  8068. var containerWidth = options.containerWidth;
  8069. var font = options.font;
  8070. var contentWidth = options.contentWidth;
  8071. if (!containerWidth) {
  8072. return '';
  8073. }
  8074. var lineWidth = getWidth(textLine, font);
  8075. if (lineWidth <= containerWidth) {
  8076. return textLine;
  8077. }
  8078. for (var j = 0;; j++) {
  8079. if (lineWidth <= contentWidth || j >= options.maxIterations) {
  8080. textLine += options.ellipsis;
  8081. break;
  8082. }
  8083. var subLength = j === 0 ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth) : lineWidth > 0 ? Math.floor(textLine.length * contentWidth / lineWidth) : 0;
  8084. textLine = textLine.substr(0, subLength);
  8085. lineWidth = getWidth(textLine, font);
  8086. }
  8087. if (textLine === '') {
  8088. textLine = options.placeholder;
  8089. }
  8090. return textLine;
  8091. }
  8092. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  8093. var width = 0;
  8094. var i = 0;
  8095. for (var len = text.length; i < len && width < contentWidth; i++) {
  8096. var charCode = text.charCodeAt(i);
  8097. width += 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth;
  8098. }
  8099. return i;
  8100. }
  8101. function parsePlainText(text, style) {
  8102. text != null && (text += '');
  8103. var overflow = style.overflow;
  8104. var padding = style.padding;
  8105. var font = style.font;
  8106. var truncate = overflow === 'truncate';
  8107. var calculatedLineHeight = getLineHeight(font);
  8108. var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);
  8109. var truncateLineOverflow = style.lineOverflow === 'truncate';
  8110. var width = style.width;
  8111. var lines;
  8112. if (width != null && overflow === 'break' || overflow === 'breakAll') {
  8113. lines = text ? wrapText(text, style.font, width, overflow === 'breakAll', 0).lines : [];
  8114. } else {
  8115. lines = text ? text.split('\n') : [];
  8116. }
  8117. var contentHeight = lines.length * lineHeight;
  8118. var height = retrieve2(style.height, contentHeight);
  8119. if (contentHeight > height && truncateLineOverflow) {
  8120. var lineCount = Math.floor(height / lineHeight);
  8121. lines = lines.slice(0, lineCount);
  8122. }
  8123. var outerHeight = height;
  8124. var outerWidth = width;
  8125. if (padding) {
  8126. outerHeight += padding[0] + padding[2];
  8127. if (outerWidth != null) {
  8128. outerWidth += padding[1] + padding[3];
  8129. }
  8130. }
  8131. if (text && truncate && outerWidth != null) {
  8132. var options = prepareTruncateOptions(width, font, style.ellipsis, {
  8133. minChar: style.truncateMinChar,
  8134. placeholder: style.placeholder
  8135. });
  8136. for (var i = 0; i < lines.length; i++) {
  8137. lines[i] = truncateSingleLine(lines[i], options);
  8138. }
  8139. }
  8140. if (width == null) {
  8141. var maxWidth = 0;
  8142. for (var i = 0; i < lines.length; i++) {
  8143. maxWidth = Math.max(getWidth(lines[i], font), maxWidth);
  8144. }
  8145. width = maxWidth;
  8146. }
  8147. return {
  8148. lines: lines,
  8149. height: height,
  8150. outerHeight: outerHeight,
  8151. lineHeight: lineHeight,
  8152. calculatedLineHeight: calculatedLineHeight,
  8153. contentHeight: contentHeight,
  8154. width: width
  8155. };
  8156. }
  8157. var RichTextToken = function () {
  8158. function RichTextToken() {}
  8159. return RichTextToken;
  8160. }();
  8161. var RichTextLine = function () {
  8162. function RichTextLine(tokens) {
  8163. this.tokens = [];
  8164. if (tokens) {
  8165. this.tokens = tokens;
  8166. }
  8167. }
  8168. return RichTextLine;
  8169. }();
  8170. var RichTextContentBlock = function () {
  8171. function RichTextContentBlock() {
  8172. this.width = 0;
  8173. this.height = 0;
  8174. this.contentWidth = 0;
  8175. this.contentHeight = 0;
  8176. this.outerWidth = 0;
  8177. this.outerHeight = 0;
  8178. this.lines = [];
  8179. }
  8180. return RichTextContentBlock;
  8181. }();
  8182. function parseRichText(text, style) {
  8183. var contentBlock = new RichTextContentBlock();
  8184. text != null && (text += '');
  8185. if (!text) {
  8186. return contentBlock;
  8187. }
  8188. var topWidth = style.width;
  8189. var topHeight = style.height;
  8190. var overflow = style.overflow;
  8191. var wrapInfo = (overflow === 'break' || overflow === 'breakAll') && topWidth != null ? {
  8192. width: topWidth,
  8193. accumWidth: 0,
  8194. breakAll: overflow === 'breakAll'
  8195. } : null;
  8196. var lastIndex = STYLE_REG.lastIndex = 0;
  8197. var result;
  8198. while ((result = STYLE_REG.exec(text)) != null) {
  8199. var matchedIndex = result.index;
  8200. if (matchedIndex > lastIndex) {
  8201. pushTokens(contentBlock, text.substring(lastIndex, matchedIndex), style, wrapInfo);
  8202. }
  8203. pushTokens(contentBlock, result[2], style, wrapInfo, result[1]);
  8204. lastIndex = STYLE_REG.lastIndex;
  8205. }
  8206. if (lastIndex < text.length) {
  8207. pushTokens(contentBlock, text.substring(lastIndex, text.length), style, wrapInfo);
  8208. }
  8209. var pendingList = [];
  8210. var calculatedHeight = 0;
  8211. var calculatedWidth = 0;
  8212. var stlPadding = style.padding;
  8213. var truncate = overflow === 'truncate';
  8214. var truncateLine = style.lineOverflow === 'truncate';
  8215. function finishLine(line, lineWidth, lineHeight) {
  8216. line.width = lineWidth;
  8217. line.lineHeight = lineHeight;
  8218. calculatedHeight += lineHeight;
  8219. calculatedWidth = Math.max(calculatedWidth, lineWidth);
  8220. }
  8221. outer: for (var i = 0; i < contentBlock.lines.length; i++) {
  8222. var line = contentBlock.lines[i];
  8223. var lineHeight = 0;
  8224. var lineWidth = 0;
  8225. for (var j = 0; j < line.tokens.length; j++) {
  8226. var token = line.tokens[j];
  8227. var tokenStyle = token.styleName && style.rich[token.styleName] || {};
  8228. var textPadding = token.textPadding = tokenStyle.padding;
  8229. var paddingH = textPadding ? textPadding[1] + textPadding[3] : 0;
  8230. var font = token.font = tokenStyle.font || style.font;
  8231. token.contentHeight = getLineHeight(font);
  8232. var tokenHeight = retrieve2(tokenStyle.height, token.contentHeight);
  8233. token.innerHeight = tokenHeight;
  8234. textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
  8235. token.height = tokenHeight;
  8236. token.lineHeight = retrieve3(tokenStyle.lineHeight, style.lineHeight, tokenHeight);
  8237. token.align = tokenStyle && tokenStyle.align || style.align;
  8238. token.verticalAlign = tokenStyle && tokenStyle.verticalAlign || 'middle';
  8239. if (truncateLine && topHeight != null && calculatedHeight + token.lineHeight > topHeight) {
  8240. if (j > 0) {
  8241. line.tokens = line.tokens.slice(0, j);
  8242. finishLine(line, lineWidth, lineHeight);
  8243. contentBlock.lines = contentBlock.lines.slice(0, i + 1);
  8244. } else {
  8245. contentBlock.lines = contentBlock.lines.slice(0, i);
  8246. }
  8247. break outer;
  8248. }
  8249. var styleTokenWidth = tokenStyle.width;
  8250. var tokenWidthNotSpecified = styleTokenWidth == null || styleTokenWidth === 'auto';
  8251. if (typeof styleTokenWidth === 'string' && styleTokenWidth.charAt(styleTokenWidth.length - 1) === '%') {
  8252. token.percentWidth = styleTokenWidth;
  8253. pendingList.push(token);
  8254. token.contentWidth = getWidth(token.text, font);
  8255. } else {
  8256. if (tokenWidthNotSpecified) {
  8257. var textBackgroundColor = tokenStyle.backgroundColor;
  8258. var bgImg = textBackgroundColor && textBackgroundColor.image;
  8259. if (bgImg) {
  8260. bgImg = findExistImage(bgImg);
  8261. if (isImageReady(bgImg)) {
  8262. token.width = Math.max(token.width, bgImg.width * tokenHeight / bgImg.height);
  8263. }
  8264. }
  8265. }
  8266. var remainTruncWidth = truncate && topWidth != null ? topWidth - lineWidth : null;
  8267. if (remainTruncWidth != null && remainTruncWidth < token.width) {
  8268. if (!tokenWidthNotSpecified || remainTruncWidth < paddingH) {
  8269. token.text = '';
  8270. token.width = token.contentWidth = 0;
  8271. } else {
  8272. token.text = truncateText(token.text, remainTruncWidth - paddingH, font, style.ellipsis, {
  8273. minChar: style.truncateMinChar
  8274. });
  8275. token.width = token.contentWidth = getWidth(token.text, font);
  8276. }
  8277. } else {
  8278. token.contentWidth = getWidth(token.text, font);
  8279. }
  8280. }
  8281. token.width += paddingH;
  8282. lineWidth += token.width;
  8283. tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));
  8284. }
  8285. finishLine(line, lineWidth, lineHeight);
  8286. }
  8287. contentBlock.outerWidth = contentBlock.width = retrieve2(topWidth, calculatedWidth);
  8288. contentBlock.outerHeight = contentBlock.height = retrieve2(topHeight, calculatedHeight);
  8289. contentBlock.contentHeight = calculatedHeight;
  8290. contentBlock.contentWidth = calculatedWidth;
  8291. if (stlPadding) {
  8292. contentBlock.outerWidth += stlPadding[1] + stlPadding[3];
  8293. contentBlock.outerHeight += stlPadding[0] + stlPadding[2];
  8294. }
  8295. for (var i = 0; i < pendingList.length; i++) {
  8296. var token = pendingList[i];
  8297. var percentWidth = token.percentWidth;
  8298. token.width = parseInt(percentWidth, 10) / 100 * contentBlock.width;
  8299. }
  8300. return contentBlock;
  8301. }
  8302. function pushTokens(block, str, style, wrapInfo, styleName) {
  8303. var isEmptyStr = str === '';
  8304. var tokenStyle = styleName && style.rich[styleName] || {};
  8305. var lines = block.lines;
  8306. var font = tokenStyle.font || style.font;
  8307. var newLine = false;
  8308. var strLines;
  8309. var linesWidths;
  8310. if (wrapInfo) {
  8311. var tokenPadding = tokenStyle.padding;
  8312. var tokenPaddingH = tokenPadding ? tokenPadding[1] + tokenPadding[3] : 0;
  8313. if (tokenStyle.width != null && tokenStyle.width !== 'auto') {
  8314. var outerWidth_1 = parsePercent(tokenStyle.width, wrapInfo.width) + tokenPaddingH;
  8315. if (lines.length > 0) {
  8316. if (outerWidth_1 + wrapInfo.accumWidth > wrapInfo.width) {
  8317. strLines = str.split('\n');
  8318. newLine = true;
  8319. }
  8320. }
  8321. wrapInfo.accumWidth = outerWidth_1;
  8322. } else {
  8323. var res = wrapText(str, font, wrapInfo.width, wrapInfo.breakAll, wrapInfo.accumWidth);
  8324. wrapInfo.accumWidth = res.accumWidth + tokenPaddingH;
  8325. linesWidths = res.linesWidths;
  8326. strLines = res.lines;
  8327. }
  8328. } else {
  8329. strLines = str.split('\n');
  8330. }
  8331. for (var i = 0; i < strLines.length; i++) {
  8332. var text = strLines[i];
  8333. var token = new RichTextToken();
  8334. token.styleName = styleName;
  8335. token.text = text;
  8336. token.isLineHolder = !text && !isEmptyStr;
  8337. if (typeof tokenStyle.width === 'number') {
  8338. token.width = tokenStyle.width;
  8339. } else {
  8340. token.width = linesWidths ? linesWidths[i] : getWidth(text, font);
  8341. }
  8342. if (!i && !newLine) {
  8343. var tokens = (lines[lines.length - 1] || (lines[0] = new RichTextLine())).tokens;
  8344. var tokensLen = tokens.length;
  8345. tokensLen === 1 && tokens[0].isLineHolder ? tokens[0] = token : (text || !tokensLen || isEmptyStr) && tokens.push(token);
  8346. } else {
  8347. lines.push(new RichTextLine([token]));
  8348. }
  8349. }
  8350. }
  8351. function isLatin(ch) {
  8352. var code = ch.charCodeAt(0);
  8353. return code >= 0x21 && code <= 0xFF;
  8354. }
  8355. var breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {
  8356. obj[ch] = true;
  8357. return obj;
  8358. }, {});
  8359. function isWordBreakChar(ch) {
  8360. if (isLatin(ch)) {
  8361. if (breakCharMap[ch]) {
  8362. return true;
  8363. }
  8364. return false;
  8365. }
  8366. return true;
  8367. }
  8368. function wrapText(text, font, lineWidth, isBreakAll, lastAccumWidth) {
  8369. var lines = [];
  8370. var linesWidths = [];
  8371. var line = '';
  8372. var currentWord = '';
  8373. var currentWordWidth = 0;
  8374. var accumWidth = 0;
  8375. for (var i = 0; i < text.length; i++) {
  8376. var ch = text.charAt(i);
  8377. if (ch === '\n') {
  8378. if (currentWord) {
  8379. line += currentWord;
  8380. accumWidth += currentWordWidth;
  8381. }
  8382. lines.push(line);
  8383. linesWidths.push(accumWidth);
  8384. line = '';
  8385. currentWord = '';
  8386. currentWordWidth = 0;
  8387. accumWidth = 0;
  8388. continue;
  8389. }
  8390. var chWidth = getWidth(ch, font);
  8391. var inWord = isBreakAll ? false : !isWordBreakChar(ch);
  8392. if (!lines.length ? lastAccumWidth + accumWidth + chWidth > lineWidth : accumWidth + chWidth > lineWidth) {
  8393. if (!accumWidth) {
  8394. if (inWord) {
  8395. lines.push(currentWord);
  8396. linesWidths.push(currentWordWidth);
  8397. currentWord = ch;
  8398. currentWordWidth = chWidth;
  8399. } else {
  8400. lines.push(ch);
  8401. linesWidths.push(chWidth);
  8402. }
  8403. } else if (line || currentWord) {
  8404. if (inWord) {
  8405. if (!line) {
  8406. line = currentWord;
  8407. currentWord = '';
  8408. currentWordWidth = 0;
  8409. accumWidth = currentWordWidth;
  8410. }
  8411. lines.push(line);
  8412. linesWidths.push(accumWidth - currentWordWidth);
  8413. currentWord += ch;
  8414. currentWordWidth += chWidth;
  8415. line = '';
  8416. accumWidth = currentWordWidth;
  8417. } else {
  8418. if (currentWord) {
  8419. line += currentWord;
  8420. accumWidth += currentWordWidth;
  8421. currentWord = '';
  8422. currentWordWidth = 0;
  8423. }
  8424. lines.push(line);
  8425. linesWidths.push(accumWidth);
  8426. line = ch;
  8427. accumWidth = chWidth;
  8428. }
  8429. }
  8430. continue;
  8431. }
  8432. accumWidth += chWidth;
  8433. if (inWord) {
  8434. currentWord += ch;
  8435. currentWordWidth += chWidth;
  8436. } else {
  8437. if (currentWord) {
  8438. line += currentWord;
  8439. currentWord = '';
  8440. currentWordWidth = 0;
  8441. }
  8442. line += ch;
  8443. }
  8444. }
  8445. if (!lines.length && !line) {
  8446. line = text;
  8447. currentWord = '';
  8448. currentWordWidth = 0;
  8449. }
  8450. if (currentWord) {
  8451. line += currentWord;
  8452. }
  8453. if (line) {
  8454. lines.push(line);
  8455. linesWidths.push(accumWidth);
  8456. }
  8457. if (lines.length === 1) {
  8458. accumWidth += lastAccumWidth;
  8459. }
  8460. return {
  8461. accumWidth: accumWidth,
  8462. lines: lines,
  8463. linesWidths: linesWidths
  8464. };
  8465. }
  8466. var STYLE_MAGIC_KEY = '__zr_style_' + Math.round(Math.random() * 10);
  8467. var DEFAULT_COMMON_STYLE = {
  8468. shadowBlur: 0,
  8469. shadowOffsetX: 0,
  8470. shadowOffsetY: 0,
  8471. shadowColor: '#000',
  8472. opacity: 1,
  8473. blend: 'source-over'
  8474. };
  8475. var DEFAULT_COMMON_ANIMATION_PROPS = {
  8476. style: {
  8477. shadowBlur: true,
  8478. shadowOffsetX: true,
  8479. shadowOffsetY: true,
  8480. shadowColor: true,
  8481. opacity: true
  8482. }
  8483. };
  8484. DEFAULT_COMMON_STYLE[STYLE_MAGIC_KEY] = true;
  8485. var PRIMARY_STATES_KEYS$1 = ['z', 'z2', 'invisible'];
  8486. var Displayable = function (_super) {
  8487. __extends(Displayable, _super);
  8488. function Displayable(props) {
  8489. return _super.call(this, props) || this;
  8490. }
  8491. Displayable.prototype._init = function (props) {
  8492. var keysArr = keys(props);
  8493. for (var i = 0; i < keysArr.length; i++) {
  8494. var key = keysArr[i];
  8495. if (key === 'style') {
  8496. this.useStyle(props[key]);
  8497. } else {
  8498. _super.prototype.attrKV.call(this, key, props[key]);
  8499. }
  8500. }
  8501. if (!this.style) {
  8502. this.useStyle({});
  8503. }
  8504. };
  8505. Displayable.prototype.beforeBrush = function () {};
  8506. Displayable.prototype.afterBrush = function () {};
  8507. Displayable.prototype.innerBeforeBrush = function () {};
  8508. Displayable.prototype.innerAfterBrush = function () {};
  8509. Displayable.prototype.shouldBePainted = function (viewWidth, viewHeight, considerClipPath, considerAncestors) {
  8510. var m = this.transform;
  8511. if (this.ignore || this.invisible || this.style.opacity === 0 || this.culling && isDisplayableCulled(this, viewWidth, viewHeight) || m && !m[0] && !m[3]) {
  8512. return false;
  8513. }
  8514. if (considerClipPath && this.__clipPaths) {
  8515. for (var i = 0; i < this.__clipPaths.length; ++i) {
  8516. if (this.__clipPaths[i].isZeroArea()) {
  8517. return false;
  8518. }
  8519. }
  8520. }
  8521. if (considerAncestors && this.parent) {
  8522. var parent_1 = this.parent;
  8523. while (parent_1) {
  8524. if (parent_1.ignore) {
  8525. return false;
  8526. }
  8527. parent_1 = parent_1.parent;
  8528. }
  8529. }
  8530. return true;
  8531. };
  8532. Displayable.prototype.contain = function (x, y) {
  8533. return this.rectContain(x, y);
  8534. };
  8535. Displayable.prototype.traverse = function (cb, context) {
  8536. cb.call(context, this);
  8537. };
  8538. Displayable.prototype.rectContain = function (x, y) {
  8539. var coord = this.transformCoordToLocal(x, y);
  8540. var rect = this.getBoundingRect();
  8541. return rect.contain(coord[0], coord[1]);
  8542. };
  8543. Displayable.prototype.getPaintRect = function () {
  8544. var rect = this._paintRect;
  8545. if (!this._paintRect || this.__dirty) {
  8546. var transform = this.transform;
  8547. var elRect = this.getBoundingRect();
  8548. var style = this.style;
  8549. var shadowSize = style.shadowBlur || 0;
  8550. var shadowOffsetX = style.shadowOffsetX || 0;
  8551. var shadowOffsetY = style.shadowOffsetY || 0;
  8552. rect = this._paintRect || (this._paintRect = new BoundingRect(0, 0, 0, 0));
  8553. if (transform) {
  8554. BoundingRect.applyTransform(rect, elRect, transform);
  8555. } else {
  8556. rect.copy(elRect);
  8557. }
  8558. if (shadowSize || shadowOffsetX || shadowOffsetY) {
  8559. rect.width += shadowSize * 2 + Math.abs(shadowOffsetX);
  8560. rect.height += shadowSize * 2 + Math.abs(shadowOffsetY);
  8561. rect.x = Math.min(rect.x, rect.x + shadowOffsetX - shadowSize);
  8562. rect.y = Math.min(rect.y, rect.y + shadowOffsetY - shadowSize);
  8563. }
  8564. var tolerance = this.dirtyRectTolerance;
  8565. if (!rect.isZero()) {
  8566. rect.x = Math.floor(rect.x - tolerance);
  8567. rect.y = Math.floor(rect.y - tolerance);
  8568. rect.width = Math.ceil(rect.width + 1 + tolerance * 2);
  8569. rect.height = Math.ceil(rect.height + 1 + tolerance * 2);
  8570. }
  8571. }
  8572. return rect;
  8573. };
  8574. Displayable.prototype.setPrevPaintRect = function (paintRect) {
  8575. if (paintRect) {
  8576. this._prevPaintRect = this._prevPaintRect || new BoundingRect(0, 0, 0, 0);
  8577. this._prevPaintRect.copy(paintRect);
  8578. } else {
  8579. this._prevPaintRect = null;
  8580. }
  8581. };
  8582. Displayable.prototype.getPrevPaintRect = function () {
  8583. return this._prevPaintRect;
  8584. };
  8585. Displayable.prototype.animateStyle = function (loop) {
  8586. return this.animate('style', loop);
  8587. };
  8588. Displayable.prototype.updateDuringAnimation = function (targetKey) {
  8589. if (targetKey === 'style') {
  8590. this.dirtyStyle();
  8591. } else {
  8592. this.markRedraw();
  8593. }
  8594. };
  8595. Displayable.prototype.attrKV = function (key, value) {
  8596. if (key !== 'style') {
  8597. _super.prototype.attrKV.call(this, key, value);
  8598. } else {
  8599. if (!this.style) {
  8600. this.useStyle(value);
  8601. } else {
  8602. this.setStyle(value);
  8603. }
  8604. }
  8605. };
  8606. Displayable.prototype.setStyle = function (keyOrObj, value) {
  8607. if (typeof keyOrObj === 'string') {
  8608. this.style[keyOrObj] = value;
  8609. } else {
  8610. extend(this.style, keyOrObj);
  8611. }
  8612. this.dirtyStyle();
  8613. return this;
  8614. };
  8615. Displayable.prototype.dirtyStyle = function () {
  8616. this.markRedraw();
  8617. this.__dirty |= Displayable.STYLE_CHANGED_BIT;
  8618. if (this._rect) {
  8619. this._rect = null;
  8620. }
  8621. };
  8622. Displayable.prototype.dirty = function () {
  8623. this.dirtyStyle();
  8624. };
  8625. Displayable.prototype.styleChanged = function () {
  8626. return !!(this.__dirty & Displayable.STYLE_CHANGED_BIT);
  8627. };
  8628. Displayable.prototype.styleUpdated = function () {
  8629. this.__dirty &= ~Displayable.STYLE_CHANGED_BIT;
  8630. };
  8631. Displayable.prototype.createStyle = function (obj) {
  8632. return createObject(DEFAULT_COMMON_STYLE, obj);
  8633. };
  8634. Displayable.prototype.useStyle = function (obj) {
  8635. if (!obj[STYLE_MAGIC_KEY]) {
  8636. obj = this.createStyle(obj);
  8637. }
  8638. if (this.__inHover) {
  8639. this.__hoverStyle = obj;
  8640. } else {
  8641. this.style = obj;
  8642. }
  8643. this.dirtyStyle();
  8644. };
  8645. Displayable.prototype.isStyleObject = function (obj) {
  8646. return obj[STYLE_MAGIC_KEY];
  8647. };
  8648. Displayable.prototype._innerSaveToNormal = function (toState) {
  8649. _super.prototype._innerSaveToNormal.call(this, toState);
  8650. var normalState = this._normalState;
  8651. if (toState.style && !normalState.style) {
  8652. normalState.style = this._mergeStyle(this.createStyle(), this.style);
  8653. }
  8654. this._savePrimaryToNormal(toState, normalState, PRIMARY_STATES_KEYS$1);
  8655. };
  8656. Displayable.prototype._applyStateObj = function (stateName, state, normalState, keepCurrentStates, transition, animationCfg) {
  8657. _super.prototype._applyStateObj.call(this, stateName, state, normalState, keepCurrentStates, transition, animationCfg);
  8658. var needsRestoreToNormal = !(state && keepCurrentStates);
  8659. var targetStyle;
  8660. if (state && state.style) {
  8661. if (transition) {
  8662. if (keepCurrentStates) {
  8663. targetStyle = state.style;
  8664. } else {
  8665. targetStyle = this._mergeStyle(this.createStyle(), normalState.style);
  8666. this._mergeStyle(targetStyle, state.style);
  8667. }
  8668. } else {
  8669. targetStyle = this._mergeStyle(this.createStyle(), keepCurrentStates ? this.style : normalState.style);
  8670. this._mergeStyle(targetStyle, state.style);
  8671. }
  8672. } else if (needsRestoreToNormal) {
  8673. targetStyle = normalState.style;
  8674. }
  8675. if (targetStyle) {
  8676. if (transition) {
  8677. var sourceStyle = this.style;
  8678. this.style = this.createStyle(needsRestoreToNormal ? {} : sourceStyle);
  8679. if (needsRestoreToNormal) {
  8680. var changedKeys = keys(sourceStyle);
  8681. for (var i = 0; i < changedKeys.length; i++) {
  8682. var key = changedKeys[i];
  8683. if (key in targetStyle) {
  8684. targetStyle[key] = targetStyle[key];
  8685. this.style[key] = sourceStyle[key];
  8686. }
  8687. }
  8688. }
  8689. var targetKeys = keys(targetStyle);
  8690. for (var i = 0; i < targetKeys.length; i++) {
  8691. var key = targetKeys[i];
  8692. this.style[key] = this.style[key];
  8693. }
  8694. this._transitionState(stateName, {
  8695. style: targetStyle
  8696. }, animationCfg, this.getAnimationStyleProps());
  8697. } else {
  8698. this.useStyle(targetStyle);
  8699. }
  8700. }
  8701. for (var i = 0; i < PRIMARY_STATES_KEYS$1.length; i++) {
  8702. var key = PRIMARY_STATES_KEYS$1[i];
  8703. if (state && state[key] != null) {
  8704. this[key] = state[key];
  8705. } else if (needsRestoreToNormal) {
  8706. if (normalState[key] != null) {
  8707. this[key] = normalState[key];
  8708. }
  8709. }
  8710. }
  8711. };
  8712. Displayable.prototype._mergeStates = function (states) {
  8713. var mergedState = _super.prototype._mergeStates.call(this, states);
  8714. var mergedStyle;
  8715. for (var i = 0; i < states.length; i++) {
  8716. var state = states[i];
  8717. if (state.style) {
  8718. mergedStyle = mergedStyle || {};
  8719. this._mergeStyle(mergedStyle, state.style);
  8720. }
  8721. }
  8722. if (mergedStyle) {
  8723. mergedState.style = mergedStyle;
  8724. }
  8725. return mergedState;
  8726. };
  8727. Displayable.prototype._mergeStyle = function (targetStyle, sourceStyle) {
  8728. extend(targetStyle, sourceStyle);
  8729. return targetStyle;
  8730. };
  8731. Displayable.prototype.getAnimationStyleProps = function () {
  8732. return DEFAULT_COMMON_ANIMATION_PROPS;
  8733. };
  8734. Displayable.STYLE_CHANGED_BIT = 2;
  8735. Displayable.initDefaultProps = function () {
  8736. var dispProto = Displayable.prototype;
  8737. dispProto.type = 'displayable';
  8738. dispProto.invisible = false;
  8739. dispProto.z = 0;
  8740. dispProto.z2 = 0;
  8741. dispProto.zlevel = 0;
  8742. dispProto.culling = false;
  8743. dispProto.cursor = 'pointer';
  8744. dispProto.rectHover = false;
  8745. dispProto.incremental = false;
  8746. dispProto._rect = null;
  8747. dispProto.dirtyRectTolerance = 0;
  8748. dispProto.__dirty = Element.REDARAW_BIT | Displayable.STYLE_CHANGED_BIT;
  8749. }();
  8750. return Displayable;
  8751. }(Element);
  8752. var tmpRect = new BoundingRect(0, 0, 0, 0);
  8753. var viewRect = new BoundingRect(0, 0, 0, 0);
  8754. function isDisplayableCulled(el, width, height) {
  8755. tmpRect.copy(el.getBoundingRect());
  8756. if (el.transform) {
  8757. tmpRect.applyTransform(el.transform);
  8758. }
  8759. viewRect.width = width;
  8760. viewRect.height = height;
  8761. return !tmpRect.intersect(viewRect);
  8762. }
  8763. var mathPow = Math.pow;
  8764. var mathSqrt$1 = Math.sqrt;
  8765. var EPSILON$1 = 1e-8;
  8766. var EPSILON_NUMERIC = 1e-4;
  8767. var THREE_SQRT = mathSqrt$1(3);
  8768. var ONE_THIRD = 1 / 3;
  8769. var _v0 = create();
  8770. var _v1 = create();
  8771. var _v2 = create();
  8772. function isAroundZero(val) {
  8773. return val > -EPSILON$1 && val < EPSILON$1;
  8774. }
  8775. function isNotAroundZero$1(val) {
  8776. return val > EPSILON$1 || val < -EPSILON$1;
  8777. }
  8778. function cubicAt(p0, p1, p2, p3, t) {
  8779. var onet = 1 - t;
  8780. return onet * onet * (onet * p0 + 3 * t * p1) + t * t * (t * p3 + 3 * onet * p2);
  8781. }
  8782. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  8783. var onet = 1 - t;
  8784. return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
  8785. }
  8786. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  8787. var a = p3 + 3 * (p1 - p2) - p0;
  8788. var b = 3 * (p2 - p1 * 2 + p0);
  8789. var c = 3 * (p1 - p0);
  8790. var d = p0 - val;
  8791. var A = b * b - 3 * a * c;
  8792. var B = b * c - 9 * a * d;
  8793. var C = c * c - 3 * b * d;
  8794. var n = 0;
  8795. if (isAroundZero(A) && isAroundZero(B)) {
  8796. if (isAroundZero(b)) {
  8797. roots[0] = 0;
  8798. } else {
  8799. var t1 = -c / b;
  8800. if (t1 >= 0 && t1 <= 1) {
  8801. roots[n++] = t1;
  8802. }
  8803. }
  8804. } else {
  8805. var disc = B * B - 4 * A * C;
  8806. if (isAroundZero(disc)) {
  8807. var K = B / A;
  8808. var t1 = -b / a + K;
  8809. var t2 = -K / 2;
  8810. if (t1 >= 0 && t1 <= 1) {
  8811. roots[n++] = t1;
  8812. }
  8813. if (t2 >= 0 && t2 <= 1) {
  8814. roots[n++] = t2;
  8815. }
  8816. } else if (disc > 0) {
  8817. var discSqrt = mathSqrt$1(disc);
  8818. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  8819. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  8820. if (Y1 < 0) {
  8821. Y1 = -mathPow(-Y1, ONE_THIRD);
  8822. } else {
  8823. Y1 = mathPow(Y1, ONE_THIRD);
  8824. }
  8825. if (Y2 < 0) {
  8826. Y2 = -mathPow(-Y2, ONE_THIRD);
  8827. } else {
  8828. Y2 = mathPow(Y2, ONE_THIRD);
  8829. }
  8830. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  8831. if (t1 >= 0 && t1 <= 1) {
  8832. roots[n++] = t1;
  8833. }
  8834. } else {
  8835. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt$1(A * A * A));
  8836. var theta = Math.acos(T) / 3;
  8837. var ASqrt = mathSqrt$1(A);
  8838. var tmp = Math.cos(theta);
  8839. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  8840. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  8841. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  8842. if (t1 >= 0 && t1 <= 1) {
  8843. roots[n++] = t1;
  8844. }
  8845. if (t2 >= 0 && t2 <= 1) {
  8846. roots[n++] = t2;
  8847. }
  8848. if (t3 >= 0 && t3 <= 1) {
  8849. roots[n++] = t3;
  8850. }
  8851. }
  8852. }
  8853. return n;
  8854. }
  8855. function cubicExtrema(p0, p1, p2, p3, extrema) {
  8856. var b = 6 * p2 - 12 * p1 + 6 * p0;
  8857. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  8858. var c = 3 * p1 - 3 * p0;
  8859. var n = 0;
  8860. if (isAroundZero(a)) {
  8861. if (isNotAroundZero$1(b)) {
  8862. var t1 = -c / b;
  8863. if (t1 >= 0 && t1 <= 1) {
  8864. extrema[n++] = t1;
  8865. }
  8866. }
  8867. } else {
  8868. var disc = b * b - 4 * a * c;
  8869. if (isAroundZero(disc)) {
  8870. extrema[0] = -b / (2 * a);
  8871. } else if (disc > 0) {
  8872. var discSqrt = mathSqrt$1(disc);
  8873. var t1 = (-b + discSqrt) / (2 * a);
  8874. var t2 = (-b - discSqrt) / (2 * a);
  8875. if (t1 >= 0 && t1 <= 1) {
  8876. extrema[n++] = t1;
  8877. }
  8878. if (t2 >= 0 && t2 <= 1) {
  8879. extrema[n++] = t2;
  8880. }
  8881. }
  8882. }
  8883. return n;
  8884. }
  8885. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  8886. var p01 = (p1 - p0) * t + p0;
  8887. var p12 = (p2 - p1) * t + p1;
  8888. var p23 = (p3 - p2) * t + p2;
  8889. var p012 = (p12 - p01) * t + p01;
  8890. var p123 = (p23 - p12) * t + p12;
  8891. var p0123 = (p123 - p012) * t + p012;
  8892. out[0] = p0;
  8893. out[1] = p01;
  8894. out[2] = p012;
  8895. out[3] = p0123;
  8896. out[4] = p0123;
  8897. out[5] = p123;
  8898. out[6] = p23;
  8899. out[7] = p3;
  8900. }
  8901. function cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, out) {
  8902. var t;
  8903. var interval = 0.005;
  8904. var d = Infinity;
  8905. var prev;
  8906. var next;
  8907. var d1;
  8908. var d2;
  8909. _v0[0] = x;
  8910. _v0[1] = y;
  8911. for (var _t = 0; _t < 1; _t += 0.05) {
  8912. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  8913. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  8914. d1 = distSquare(_v0, _v1);
  8915. if (d1 < d) {
  8916. t = _t;
  8917. d = d1;
  8918. }
  8919. }
  8920. d = Infinity;
  8921. for (var i = 0; i < 32; i++) {
  8922. if (interval < EPSILON_NUMERIC) {
  8923. break;
  8924. }
  8925. prev = t - interval;
  8926. next = t + interval;
  8927. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  8928. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  8929. d1 = distSquare(_v1, _v0);
  8930. if (prev >= 0 && d1 < d) {
  8931. t = prev;
  8932. d = d1;
  8933. } else {
  8934. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  8935. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  8936. d2 = distSquare(_v2, _v0);
  8937. if (next <= 1 && d2 < d) {
  8938. t = next;
  8939. d = d2;
  8940. } else {
  8941. interval *= 0.5;
  8942. }
  8943. }
  8944. }
  8945. if (out) {
  8946. out[0] = cubicAt(x0, x1, x2, x3, t);
  8947. out[1] = cubicAt(y0, y1, y2, y3, t);
  8948. }
  8949. return mathSqrt$1(d);
  8950. }
  8951. function cubicLength(x0, y0, x1, y1, x2, y2, x3, y3, iteration) {
  8952. var px = x0;
  8953. var py = y0;
  8954. var d = 0;
  8955. var step = 1 / iteration;
  8956. for (var i = 1; i <= iteration; i++) {
  8957. var t = i * step;
  8958. var x = cubicAt(x0, x1, x2, x3, t);
  8959. var y = cubicAt(y0, y1, y2, y3, t);
  8960. var dx = x - px;
  8961. var dy = y - py;
  8962. d += Math.sqrt(dx * dx + dy * dy);
  8963. px = x;
  8964. py = y;
  8965. }
  8966. return d;
  8967. }
  8968. function quadraticAt(p0, p1, p2, t) {
  8969. var onet = 1 - t;
  8970. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  8971. }
  8972. function quadraticDerivativeAt(p0, p1, p2, t) {
  8973. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  8974. }
  8975. function quadraticRootAt(p0, p1, p2, val, roots) {
  8976. var a = p0 - 2 * p1 + p2;
  8977. var b = 2 * (p1 - p0);
  8978. var c = p0 - val;
  8979. var n = 0;
  8980. if (isAroundZero(a)) {
  8981. if (isNotAroundZero$1(b)) {
  8982. var t1 = -c / b;
  8983. if (t1 >= 0 && t1 <= 1) {
  8984. roots[n++] = t1;
  8985. }
  8986. }
  8987. } else {
  8988. var disc = b * b - 4 * a * c;
  8989. if (isAroundZero(disc)) {
  8990. var t1 = -b / (2 * a);
  8991. if (t1 >= 0 && t1 <= 1) {
  8992. roots[n++] = t1;
  8993. }
  8994. } else if (disc > 0) {
  8995. var discSqrt = mathSqrt$1(disc);
  8996. var t1 = (-b + discSqrt) / (2 * a);
  8997. var t2 = (-b - discSqrt) / (2 * a);
  8998. if (t1 >= 0 && t1 <= 1) {
  8999. roots[n++] = t1;
  9000. }
  9001. if (t2 >= 0 && t2 <= 1) {
  9002. roots[n++] = t2;
  9003. }
  9004. }
  9005. }
  9006. return n;
  9007. }
  9008. function quadraticExtremum(p0, p1, p2) {
  9009. var divider = p0 + p2 - 2 * p1;
  9010. if (divider === 0) {
  9011. return 0.5;
  9012. } else {
  9013. return (p0 - p1) / divider;
  9014. }
  9015. }
  9016. function quadraticSubdivide(p0, p1, p2, t, out) {
  9017. var p01 = (p1 - p0) * t + p0;
  9018. var p12 = (p2 - p1) * t + p1;
  9019. var p012 = (p12 - p01) * t + p01;
  9020. out[0] = p0;
  9021. out[1] = p01;
  9022. out[2] = p012;
  9023. out[3] = p012;
  9024. out[4] = p12;
  9025. out[5] = p2;
  9026. }
  9027. function quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, out) {
  9028. var t;
  9029. var interval = 0.005;
  9030. var d = Infinity;
  9031. _v0[0] = x;
  9032. _v0[1] = y;
  9033. for (var _t = 0; _t < 1; _t += 0.05) {
  9034. _v1[0] = quadraticAt(x0, x1, x2, _t);
  9035. _v1[1] = quadraticAt(y0, y1, y2, _t);
  9036. var d1 = distSquare(_v0, _v1);
  9037. if (d1 < d) {
  9038. t = _t;
  9039. d = d1;
  9040. }
  9041. }
  9042. d = Infinity;
  9043. for (var i = 0; i < 32; i++) {
  9044. if (interval < EPSILON_NUMERIC) {
  9045. break;
  9046. }
  9047. var prev = t - interval;
  9048. var next = t + interval;
  9049. _v1[0] = quadraticAt(x0, x1, x2, prev);
  9050. _v1[1] = quadraticAt(y0, y1, y2, prev);
  9051. var d1 = distSquare(_v1, _v0);
  9052. if (prev >= 0 && d1 < d) {
  9053. t = prev;
  9054. d = d1;
  9055. } else {
  9056. _v2[0] = quadraticAt(x0, x1, x2, next);
  9057. _v2[1] = quadraticAt(y0, y1, y2, next);
  9058. var d2 = distSquare(_v2, _v0);
  9059. if (next <= 1 && d2 < d) {
  9060. t = next;
  9061. d = d2;
  9062. } else {
  9063. interval *= 0.5;
  9064. }
  9065. }
  9066. }
  9067. if (out) {
  9068. out[0] = quadraticAt(x0, x1, x2, t);
  9069. out[1] = quadraticAt(y0, y1, y2, t);
  9070. }
  9071. return mathSqrt$1(d);
  9072. }
  9073. function quadraticLength(x0, y0, x1, y1, x2, y2, iteration) {
  9074. var px = x0;
  9075. var py = y0;
  9076. var d = 0;
  9077. var step = 1 / iteration;
  9078. for (var i = 1; i <= iteration; i++) {
  9079. var t = i * step;
  9080. var x = quadraticAt(x0, x1, x2, t);
  9081. var y = quadraticAt(y0, y1, y2, t);
  9082. var dx = x - px;
  9083. var dy = y - py;
  9084. d += Math.sqrt(dx * dx + dy * dy);
  9085. px = x;
  9086. py = y;
  9087. }
  9088. return d;
  9089. }
  9090. var mathMin$2 = Math.min;
  9091. var mathMax$2 = Math.max;
  9092. var mathSin$1 = Math.sin;
  9093. var mathCos$1 = Math.cos;
  9094. var PI2$1 = Math.PI * 2;
  9095. var start = create();
  9096. var end = create();
  9097. var extremity = create();
  9098. function fromPoints(points, min$$1, max$$1) {
  9099. if (points.length === 0) {
  9100. return;
  9101. }
  9102. var p = points[0];
  9103. var left = p[0];
  9104. var right = p[0];
  9105. var top = p[1];
  9106. var bottom = p[1];
  9107. for (var i = 1; i < points.length; i++) {
  9108. p = points[i];
  9109. left = mathMin$2(left, p[0]);
  9110. right = mathMax$2(right, p[0]);
  9111. top = mathMin$2(top, p[1]);
  9112. bottom = mathMax$2(bottom, p[1]);
  9113. }
  9114. min$$1[0] = left;
  9115. min$$1[1] = top;
  9116. max$$1[0] = right;
  9117. max$$1[1] = bottom;
  9118. }
  9119. function fromLine(x0, y0, x1, y1, min$$1, max$$1) {
  9120. min$$1[0] = mathMin$2(x0, x1);
  9121. min$$1[1] = mathMin$2(y0, y1);
  9122. max$$1[0] = mathMax$2(x0, x1);
  9123. max$$1[1] = mathMax$2(y0, y1);
  9124. }
  9125. var xDim = [];
  9126. var yDim = [];
  9127. function fromCubic(x0, y0, x1, y1, x2, y2, x3, y3, min$$1, max$$1) {
  9128. var cubicExtrema$$1 = cubicExtrema;
  9129. var cubicAt$$1 = cubicAt;
  9130. var n = cubicExtrema$$1(x0, x1, x2, x3, xDim);
  9131. min$$1[0] = Infinity;
  9132. min$$1[1] = Infinity;
  9133. max$$1[0] = -Infinity;
  9134. max$$1[1] = -Infinity;
  9135. for (var i = 0; i < n; i++) {
  9136. var x = cubicAt$$1(x0, x1, x2, x3, xDim[i]);
  9137. min$$1[0] = mathMin$2(x, min$$1[0]);
  9138. max$$1[0] = mathMax$2(x, max$$1[0]);
  9139. }
  9140. n = cubicExtrema$$1(y0, y1, y2, y3, yDim);
  9141. for (var i = 0; i < n; i++) {
  9142. var y = cubicAt$$1(y0, y1, y2, y3, yDim[i]);
  9143. min$$1[1] = mathMin$2(y, min$$1[1]);
  9144. max$$1[1] = mathMax$2(y, max$$1[1]);
  9145. }
  9146. min$$1[0] = mathMin$2(x0, min$$1[0]);
  9147. max$$1[0] = mathMax$2(x0, max$$1[0]);
  9148. min$$1[0] = mathMin$2(x3, min$$1[0]);
  9149. max$$1[0] = mathMax$2(x3, max$$1[0]);
  9150. min$$1[1] = mathMin$2(y0, min$$1[1]);
  9151. max$$1[1] = mathMax$2(y0, max$$1[1]);
  9152. min$$1[1] = mathMin$2(y3, min$$1[1]);
  9153. max$$1[1] = mathMax$2(y3, max$$1[1]);
  9154. }
  9155. function fromQuadratic(x0, y0, x1, y1, x2, y2, min$$1, max$$1) {
  9156. var quadraticExtremum$$1 = quadraticExtremum;
  9157. var quadraticAt$$1 = quadraticAt;
  9158. var tx = mathMax$2(mathMin$2(quadraticExtremum$$1(x0, x1, x2), 1), 0);
  9159. var ty = mathMax$2(mathMin$2(quadraticExtremum$$1(y0, y1, y2), 1), 0);
  9160. var x = quadraticAt$$1(x0, x1, x2, tx);
  9161. var y = quadraticAt$$1(y0, y1, y2, ty);
  9162. min$$1[0] = mathMin$2(x0, x2, x);
  9163. min$$1[1] = mathMin$2(y0, y2, y);
  9164. max$$1[0] = mathMax$2(x0, x2, x);
  9165. max$$1[1] = mathMax$2(y0, y2, y);
  9166. }
  9167. function fromArc(x, y, rx, ry, startAngle, endAngle, anticlockwise, min$$1, max$$1) {
  9168. var vec2Min = min;
  9169. var vec2Max = max;
  9170. var diff = Math.abs(startAngle - endAngle);
  9171. if (diff % PI2$1 < 1e-4 && diff > 1e-4) {
  9172. min$$1[0] = x - rx;
  9173. min$$1[1] = y - ry;
  9174. max$$1[0] = x + rx;
  9175. max$$1[1] = y + ry;
  9176. return;
  9177. }
  9178. start[0] = mathCos$1(startAngle) * rx + x;
  9179. start[1] = mathSin$1(startAngle) * ry + y;
  9180. end[0] = mathCos$1(endAngle) * rx + x;
  9181. end[1] = mathSin$1(endAngle) * ry + y;
  9182. vec2Min(min$$1, start, end);
  9183. vec2Max(max$$1, start, end);
  9184. startAngle = startAngle % PI2$1;
  9185. if (startAngle < 0) {
  9186. startAngle = startAngle + PI2$1;
  9187. }
  9188. endAngle = endAngle % PI2$1;
  9189. if (endAngle < 0) {
  9190. endAngle = endAngle + PI2$1;
  9191. }
  9192. if (startAngle > endAngle && !anticlockwise) {
  9193. endAngle += PI2$1;
  9194. } else if (startAngle < endAngle && anticlockwise) {
  9195. startAngle += PI2$1;
  9196. }
  9197. if (anticlockwise) {
  9198. var tmp = endAngle;
  9199. endAngle = startAngle;
  9200. startAngle = tmp;
  9201. }
  9202. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  9203. if (angle > startAngle) {
  9204. extremity[0] = mathCos$1(angle) * rx + x;
  9205. extremity[1] = mathSin$1(angle) * ry + y;
  9206. vec2Min(min$$1, extremity, min$$1);
  9207. vec2Max(max$$1, extremity, max$$1);
  9208. }
  9209. }
  9210. }
  9211. var CMD = {
  9212. M: 1,
  9213. L: 2,
  9214. C: 3,
  9215. Q: 4,
  9216. A: 5,
  9217. Z: 6,
  9218. R: 7
  9219. };
  9220. var tmpOutX = [];
  9221. var tmpOutY = [];
  9222. var min$1 = [];
  9223. var max$1 = [];
  9224. var min2 = [];
  9225. var max2 = [];
  9226. var mathMin$1 = Math.min;
  9227. var mathMax$1 = Math.max;
  9228. var mathCos = Math.cos;
  9229. var mathSin = Math.sin;
  9230. var mathSqrt = Math.sqrt;
  9231. var mathAbs = Math.abs;
  9232. var PI = Math.PI;
  9233. var PI2 = PI * 2;
  9234. var hasTypedArray = typeof Float32Array !== 'undefined';
  9235. var tmpAngles = [];
  9236. function modPI2(radian) {
  9237. var n = Math.round(radian / PI * 1e8) / 1e8;
  9238. return n % 2 * PI;
  9239. }
  9240. function normalizeArcAngles(angles, anticlockwise) {
  9241. var newStartAngle = modPI2(angles[0]);
  9242. if (newStartAngle < 0) {
  9243. newStartAngle += PI2;
  9244. }
  9245. var delta = newStartAngle - angles[0];
  9246. var newEndAngle = angles[1];
  9247. newEndAngle += delta;
  9248. if (!anticlockwise && newEndAngle - newStartAngle >= PI2) {
  9249. newEndAngle = newStartAngle + PI2;
  9250. } else if (anticlockwise && newStartAngle - newEndAngle >= PI2) {
  9251. newEndAngle = newStartAngle - PI2;
  9252. } else if (!anticlockwise && newStartAngle > newEndAngle) {
  9253. newEndAngle = newStartAngle + (PI2 - modPI2(newStartAngle - newEndAngle));
  9254. } else if (anticlockwise && newStartAngle < newEndAngle) {
  9255. newEndAngle = newStartAngle - (PI2 - modPI2(newEndAngle - newStartAngle));
  9256. }
  9257. angles[0] = newStartAngle;
  9258. angles[1] = newEndAngle;
  9259. }
  9260. var PathProxy = function () {
  9261. function PathProxy(notSaveData) {
  9262. this.dpr = 1;
  9263. this._version = 0;
  9264. this._xi = 0;
  9265. this._yi = 0;
  9266. this._x0 = 0;
  9267. this._y0 = 0;
  9268. this._len = 0;
  9269. if (notSaveData) {
  9270. this._saveData = false;
  9271. }
  9272. if (this._saveData) {
  9273. this.data = [];
  9274. }
  9275. }
  9276. PathProxy.prototype.increaseVersion = function () {
  9277. this._version++;
  9278. };
  9279. PathProxy.prototype.getVersion = function () {
  9280. return this._version;
  9281. };
  9282. PathProxy.prototype.setScale = function (sx, sy, segmentIgnoreThreshold) {
  9283. segmentIgnoreThreshold = segmentIgnoreThreshold || 0;
  9284. if (segmentIgnoreThreshold > 0) {
  9285. this._ux = mathAbs(segmentIgnoreThreshold / devicePixelRatio / sx) || 0;
  9286. this._uy = mathAbs(segmentIgnoreThreshold / devicePixelRatio / sy) || 0;
  9287. }
  9288. };
  9289. PathProxy.prototype.setDPR = function (dpr) {
  9290. this.dpr = dpr;
  9291. };
  9292. PathProxy.prototype.setContext = function (ctx) {
  9293. this._ctx = ctx;
  9294. };
  9295. PathProxy.prototype.getContext = function () {
  9296. return this._ctx;
  9297. };
  9298. PathProxy.prototype.beginPath = function () {
  9299. this._ctx && this._ctx.beginPath();
  9300. this.reset();
  9301. return this;
  9302. };
  9303. PathProxy.prototype.reset = function () {
  9304. if (this._saveData) {
  9305. this._len = 0;
  9306. }
  9307. if (this._lineDash) {
  9308. this._lineDash = null;
  9309. this._dashOffset = 0;
  9310. }
  9311. if (this._pathSegLen) {
  9312. this._pathSegLen = null;
  9313. this._pathLen = 0;
  9314. }
  9315. this._version++;
  9316. };
  9317. PathProxy.prototype.moveTo = function (x, y) {
  9318. this.addData(CMD.M, x, y);
  9319. this._ctx && this._ctx.moveTo(x, y);
  9320. this._x0 = x;
  9321. this._y0 = y;
  9322. this._xi = x;
  9323. this._yi = y;
  9324. return this;
  9325. };
  9326. PathProxy.prototype.lineTo = function (x, y) {
  9327. var exceedUnit = mathAbs(x - this._xi) > this._ux || mathAbs(y - this._yi) > this._uy || this._len < 5;
  9328. this.addData(CMD.L, x, y);
  9329. if (this._ctx && exceedUnit) {
  9330. this._needsDash ? this._dashedLineTo(x, y) : this._ctx.lineTo(x, y);
  9331. }
  9332. if (exceedUnit) {
  9333. this._xi = x;
  9334. this._yi = y;
  9335. }
  9336. return this;
  9337. };
  9338. PathProxy.prototype.bezierCurveTo = function (x1, y1, x2, y2, x3, y3) {
  9339. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  9340. if (this._ctx) {
  9341. this._needsDash ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  9342. }
  9343. this._xi = x3;
  9344. this._yi = y3;
  9345. return this;
  9346. };
  9347. PathProxy.prototype.quadraticCurveTo = function (x1, y1, x2, y2) {
  9348. this.addData(CMD.Q, x1, y1, x2, y2);
  9349. if (this._ctx) {
  9350. this._needsDash ? this._dashedQuadraticTo(x1, y1, x2, y2) : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  9351. }
  9352. this._xi = x2;
  9353. this._yi = y2;
  9354. return this;
  9355. };
  9356. PathProxy.prototype.arc = function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  9357. tmpAngles[0] = startAngle;
  9358. tmpAngles[1] = endAngle;
  9359. normalizeArcAngles(tmpAngles, anticlockwise);
  9360. startAngle = tmpAngles[0];
  9361. endAngle = tmpAngles[1];
  9362. var delta = endAngle - startAngle;
  9363. this.addData(CMD.A, cx, cy, r, r, startAngle, delta, 0, anticlockwise ? 0 : 1);
  9364. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  9365. this._xi = mathCos(endAngle) * r + cx;
  9366. this._yi = mathSin(endAngle) * r + cy;
  9367. return this;
  9368. };
  9369. PathProxy.prototype.arcTo = function (x1, y1, x2, y2, radius) {
  9370. if (this._ctx) {
  9371. this._ctx.arcTo(x1, y1, x2, y2, radius);
  9372. }
  9373. return this;
  9374. };
  9375. PathProxy.prototype.rect = function (x, y, w, h) {
  9376. this._ctx && this._ctx.rect(x, y, w, h);
  9377. this.addData(CMD.R, x, y, w, h);
  9378. return this;
  9379. };
  9380. PathProxy.prototype.closePath = function () {
  9381. this.addData(CMD.Z);
  9382. var ctx = this._ctx;
  9383. var x0 = this._x0;
  9384. var y0 = this._y0;
  9385. if (ctx) {
  9386. this._needsDash && this._dashedLineTo(x0, y0);
  9387. ctx.closePath();
  9388. }
  9389. this._xi = x0;
  9390. this._yi = y0;
  9391. return this;
  9392. };
  9393. PathProxy.prototype.fill = function (ctx) {
  9394. ctx && ctx.fill();
  9395. this.toStatic();
  9396. };
  9397. PathProxy.prototype.stroke = function (ctx) {
  9398. ctx && ctx.stroke();
  9399. this.toStatic();
  9400. };
  9401. PathProxy.prototype.setLineDash = function (lineDash) {
  9402. if (lineDash instanceof Array) {
  9403. this._lineDash = lineDash;
  9404. this._dashIdx = 0;
  9405. var lineDashSum = 0;
  9406. for (var i = 0; i < lineDash.length; i++) {
  9407. lineDashSum += lineDash[i];
  9408. }
  9409. this._dashSum = lineDashSum;
  9410. this._needsDash = true;
  9411. } else {
  9412. this._lineDash = null;
  9413. this._needsDash = false;
  9414. }
  9415. return this;
  9416. };
  9417. PathProxy.prototype.setLineDashOffset = function (offset) {
  9418. this._dashOffset = offset;
  9419. return this;
  9420. };
  9421. PathProxy.prototype.len = function () {
  9422. return this._len;
  9423. };
  9424. PathProxy.prototype.setData = function (data) {
  9425. var len$$1 = data.length;
  9426. if (!(this.data && this.data.length === len$$1) && hasTypedArray) {
  9427. this.data = new Float32Array(len$$1);
  9428. }
  9429. for (var i = 0; i < len$$1; i++) {
  9430. this.data[i] = data[i];
  9431. }
  9432. this._len = len$$1;
  9433. };
  9434. PathProxy.prototype.appendPath = function (path) {
  9435. if (!(path instanceof Array)) {
  9436. path = [path];
  9437. }
  9438. var len$$1 = path.length;
  9439. var appendSize = 0;
  9440. var offset = this._len;
  9441. for (var i = 0; i < len$$1; i++) {
  9442. appendSize += path[i].len();
  9443. }
  9444. if (hasTypedArray && this.data instanceof Float32Array) {
  9445. this.data = new Float32Array(offset + appendSize);
  9446. }
  9447. for (var i = 0; i < len$$1; i++) {
  9448. var appendPathData = path[i].data;
  9449. for (var k = 0; k < appendPathData.length; k++) {
  9450. this.data[offset++] = appendPathData[k];
  9451. }
  9452. }
  9453. this._len = offset;
  9454. };
  9455. PathProxy.prototype.addData = function (cmd, a, b, c, d, e, f, g, h) {
  9456. if (!this._saveData) {
  9457. return;
  9458. }
  9459. var data = this.data;
  9460. if (this._len + arguments.length > data.length) {
  9461. this._expandData();
  9462. data = this.data;
  9463. }
  9464. for (var i = 0; i < arguments.length; i++) {
  9465. data[this._len++] = arguments[i];
  9466. }
  9467. };
  9468. PathProxy.prototype._expandData = function () {
  9469. if (!(this.data instanceof Array)) {
  9470. var newData = [];
  9471. for (var i = 0; i < this._len; i++) {
  9472. newData[i] = this.data[i];
  9473. }
  9474. this.data = newData;
  9475. }
  9476. };
  9477. PathProxy.prototype._dashedLineTo = function (x1, y1) {
  9478. var dashSum = this._dashSum;
  9479. var lineDash = this._lineDash;
  9480. var ctx = this._ctx;
  9481. var offset = this._dashOffset;
  9482. var x0 = this._xi;
  9483. var y0 = this._yi;
  9484. var dx = x1 - x0;
  9485. var dy = y1 - y0;
  9486. var dist$$1 = mathSqrt(dx * dx + dy * dy);
  9487. var x = x0;
  9488. var y = y0;
  9489. var nDash = lineDash.length;
  9490. var dash;
  9491. var idx;
  9492. dx /= dist$$1;
  9493. dy /= dist$$1;
  9494. if (offset < 0) {
  9495. offset = dashSum + offset;
  9496. }
  9497. offset %= dashSum;
  9498. x -= offset * dx;
  9499. y -= offset * dy;
  9500. while (dx > 0 && x <= x1 || dx < 0 && x >= x1 || dx === 0 && (dy > 0 && y <= y1 || dy < 0 && y >= y1)) {
  9501. idx = this._dashIdx;
  9502. dash = lineDash[idx];
  9503. x += dx * dash;
  9504. y += dy * dash;
  9505. this._dashIdx = (idx + 1) % nDash;
  9506. if (dx > 0 && x < x0 || dx < 0 && x > x0 || dy > 0 && y < y0 || dy < 0 && y > y0) {
  9507. continue;
  9508. }
  9509. ctx[idx % 2 ? 'moveTo' : 'lineTo'](dx >= 0 ? mathMin$1(x, x1) : mathMax$1(x, x1), dy >= 0 ? mathMin$1(y, y1) : mathMax$1(y, y1));
  9510. }
  9511. dx = x - x1;
  9512. dy = y - y1;
  9513. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  9514. };
  9515. PathProxy.prototype._dashedBezierTo = function (x1, y1, x2, y2, x3, y3) {
  9516. var ctx = this._ctx;
  9517. var dashSum = this._dashSum;
  9518. var offset = this._dashOffset;
  9519. var lineDash = this._lineDash;
  9520. var x0 = this._xi;
  9521. var y0 = this._yi;
  9522. var bezierLen = 0;
  9523. var idx = this._dashIdx;
  9524. var nDash = lineDash.length;
  9525. var t;
  9526. var dx;
  9527. var dy;
  9528. var x;
  9529. var y;
  9530. var tmpLen = 0;
  9531. if (offset < 0) {
  9532. offset = dashSum + offset;
  9533. }
  9534. offset %= dashSum;
  9535. for (t = 0; t < 1; t += 0.1) {
  9536. dx = cubicAt(x0, x1, x2, x3, t + 0.1) - cubicAt(x0, x1, x2, x3, t);
  9537. dy = cubicAt(y0, y1, y2, y3, t + 0.1) - cubicAt(y0, y1, y2, y3, t);
  9538. bezierLen += mathSqrt(dx * dx + dy * dy);
  9539. }
  9540. for (; idx < nDash; idx++) {
  9541. tmpLen += lineDash[idx];
  9542. if (tmpLen > offset) {
  9543. break;
  9544. }
  9545. }
  9546. t = (tmpLen - offset) / bezierLen;
  9547. while (t <= 1) {
  9548. x = cubicAt(x0, x1, x2, x3, t);
  9549. y = cubicAt(y0, y1, y2, y3, t);
  9550. idx % 2 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
  9551. t += lineDash[idx] / bezierLen;
  9552. idx = (idx + 1) % nDash;
  9553. }
  9554. idx % 2 !== 0 && ctx.lineTo(x3, y3);
  9555. dx = x3 - x;
  9556. dy = y3 - y;
  9557. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  9558. };
  9559. PathProxy.prototype._dashedQuadraticTo = function (x1, y1, x2, y2) {
  9560. var x3 = x2;
  9561. var y3 = y2;
  9562. x2 = (x2 + 2 * x1) / 3;
  9563. y2 = (y2 + 2 * y1) / 3;
  9564. x1 = (this._xi + 2 * x1) / 3;
  9565. y1 = (this._yi + 2 * y1) / 3;
  9566. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  9567. };
  9568. PathProxy.prototype.toStatic = function () {
  9569. if (!this._saveData) {
  9570. return;
  9571. }
  9572. var data = this.data;
  9573. if (data instanceof Array) {
  9574. data.length = this._len;
  9575. if (hasTypedArray && this._len > 11) {
  9576. this.data = new Float32Array(data);
  9577. }
  9578. }
  9579. };
  9580. PathProxy.prototype.getBoundingRect = function () {
  9581. min$1[0] = min$1[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  9582. max$1[0] = max$1[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  9583. var data = this.data;
  9584. var xi = 0;
  9585. var yi = 0;
  9586. var x0 = 0;
  9587. var y0 = 0;
  9588. var i;
  9589. for (i = 0; i < this._len;) {
  9590. var cmd = data[i++];
  9591. var isFirst = i === 1;
  9592. if (isFirst) {
  9593. xi = data[i];
  9594. yi = data[i + 1];
  9595. x0 = xi;
  9596. y0 = yi;
  9597. }
  9598. switch (cmd) {
  9599. case CMD.M:
  9600. xi = x0 = data[i++];
  9601. yi = y0 = data[i++];
  9602. min2[0] = x0;
  9603. min2[1] = y0;
  9604. max2[0] = x0;
  9605. max2[1] = y0;
  9606. break;
  9607. case CMD.L:
  9608. fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  9609. xi = data[i++];
  9610. yi = data[i++];
  9611. break;
  9612. case CMD.C:
  9613. fromCubic(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], min2, max2);
  9614. xi = data[i++];
  9615. yi = data[i++];
  9616. break;
  9617. case CMD.Q:
  9618. fromQuadratic(xi, yi, data[i++], data[i++], data[i], data[i + 1], min2, max2);
  9619. xi = data[i++];
  9620. yi = data[i++];
  9621. break;
  9622. case CMD.A:
  9623. var cx = data[i++];
  9624. var cy = data[i++];
  9625. var rx = data[i++];
  9626. var ry = data[i++];
  9627. var startAngle = data[i++];
  9628. var endAngle = data[i++] + startAngle;
  9629. i += 1;
  9630. var anticlockwise = !data[i++];
  9631. if (isFirst) {
  9632. x0 = mathCos(startAngle) * rx + cx;
  9633. y0 = mathSin(startAngle) * ry + cy;
  9634. }
  9635. fromArc(cx, cy, rx, ry, startAngle, endAngle, anticlockwise, min2, max2);
  9636. xi = mathCos(endAngle) * rx + cx;
  9637. yi = mathSin(endAngle) * ry + cy;
  9638. break;
  9639. case CMD.R:
  9640. x0 = xi = data[i++];
  9641. y0 = yi = data[i++];
  9642. var width = data[i++];
  9643. var height = data[i++];
  9644. fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  9645. break;
  9646. case CMD.Z:
  9647. xi = x0;
  9648. yi = y0;
  9649. break;
  9650. }
  9651. min(min$1, min$1, min2);
  9652. max(max$1, max$1, max2);
  9653. }
  9654. if (i === 0) {
  9655. min$1[0] = min$1[1] = max$1[0] = max$1[1] = 0;
  9656. }
  9657. return new BoundingRect(min$1[0], min$1[1], max$1[0] - min$1[0], max$1[1] - min$1[1]);
  9658. };
  9659. PathProxy.prototype._calculateLength = function () {
  9660. var data = this.data;
  9661. var len$$1 = this._len;
  9662. var ux = this._ux;
  9663. var uy = this._uy;
  9664. var xi = 0;
  9665. var yi = 0;
  9666. var x0 = 0;
  9667. var y0 = 0;
  9668. if (!this._pathSegLen) {
  9669. this._pathSegLen = [];
  9670. }
  9671. var pathSegLen = this._pathSegLen;
  9672. var pathTotalLen = 0;
  9673. var segCount = 0;
  9674. for (var i = 0; i < len$$1;) {
  9675. var cmd = data[i++];
  9676. var isFirst = i === 1;
  9677. if (isFirst) {
  9678. xi = data[i];
  9679. yi = data[i + 1];
  9680. x0 = xi;
  9681. y0 = yi;
  9682. }
  9683. var l = -1;
  9684. switch (cmd) {
  9685. case CMD.M:
  9686. xi = x0 = data[i++];
  9687. yi = y0 = data[i++];
  9688. break;
  9689. case CMD.L:
  9690. {
  9691. var x2 = data[i++];
  9692. var y2 = data[i++];
  9693. var dx = x2 - xi;
  9694. var dy = y2 - yi;
  9695. if (mathAbs(dx) > ux || mathAbs(dy) > uy || i === len$$1 - 1) {
  9696. l = Math.sqrt(dx * dx + dy * dy);
  9697. xi = x2;
  9698. yi = y2;
  9699. }
  9700. break;
  9701. }
  9702. case CMD.C:
  9703. {
  9704. var x1 = data[i++];
  9705. var y1 = data[i++];
  9706. var x2 = data[i++];
  9707. var y2 = data[i++];
  9708. var x3 = data[i++];
  9709. var y3 = data[i++];
  9710. l = cubicLength(xi, yi, x1, y1, x2, y2, x3, y3, 10);
  9711. xi = x3;
  9712. yi = y3;
  9713. break;
  9714. }
  9715. case CMD.Q:
  9716. {
  9717. var x1 = data[i++];
  9718. var y1 = data[i++];
  9719. var x2 = data[i++];
  9720. var y2 = data[i++];
  9721. l = quadraticLength(xi, yi, x1, y1, x2, y2, 10);
  9722. xi = x2;
  9723. yi = y2;
  9724. break;
  9725. }
  9726. case CMD.A:
  9727. var cx = data[i++];
  9728. var cy = data[i++];
  9729. var rx = data[i++];
  9730. var ry = data[i++];
  9731. var startAngle = data[i++];
  9732. var delta = data[i++];
  9733. var endAngle = delta + startAngle;
  9734. i += 1;
  9735. var anticlockwise = !data[i++];
  9736. if (isFirst) {
  9737. x0 = mathCos(startAngle) * rx + cx;
  9738. y0 = mathSin(startAngle) * ry + cy;
  9739. }
  9740. l = mathMax$1(rx, ry) * mathMin$1(PI2, Math.abs(delta));
  9741. xi = mathCos(endAngle) * rx + cx;
  9742. yi = mathSin(endAngle) * ry + cy;
  9743. break;
  9744. case CMD.R:
  9745. {
  9746. x0 = xi = data[i++];
  9747. y0 = yi = data[i++];
  9748. var width = data[i++];
  9749. var height = data[i++];
  9750. l = width * 2 + height * 2;
  9751. break;
  9752. }
  9753. case CMD.Z:
  9754. {
  9755. var dx = x0 - xi;
  9756. var dy = y0 - yi;
  9757. l = Math.sqrt(dx * dx + dy * dy);
  9758. xi = x0;
  9759. yi = y0;
  9760. break;
  9761. }
  9762. }
  9763. if (l >= 0) {
  9764. pathSegLen[segCount++] = l;
  9765. pathTotalLen += l;
  9766. }
  9767. }
  9768. this._pathLen = pathTotalLen;
  9769. return pathTotalLen;
  9770. };
  9771. PathProxy.prototype.rebuildPath = function (ctx, percent) {
  9772. var d = this.data;
  9773. var ux = this._ux;
  9774. var uy = this._uy;
  9775. var len$$1 = this._len;
  9776. var x0;
  9777. var y0;
  9778. var xi;
  9779. var yi;
  9780. var x;
  9781. var y;
  9782. var drawPart = percent < 1;
  9783. var pathSegLen;
  9784. var pathTotalLen;
  9785. var accumLength = 0;
  9786. var segCount = 0;
  9787. var displayedLength;
  9788. if (drawPart) {
  9789. if (!this._pathSegLen) {
  9790. this._calculateLength();
  9791. }
  9792. pathSegLen = this._pathSegLen;
  9793. pathTotalLen = this._pathLen;
  9794. displayedLength = percent * pathTotalLen;
  9795. if (!displayedLength) {
  9796. return;
  9797. }
  9798. }
  9799. lo: for (var i = 0; i < len$$1;) {
  9800. var cmd = d[i++];
  9801. var isFirst = i === 1;
  9802. if (isFirst) {
  9803. xi = d[i];
  9804. yi = d[i + 1];
  9805. x0 = xi;
  9806. y0 = yi;
  9807. }
  9808. switch (cmd) {
  9809. case CMD.M:
  9810. x0 = xi = d[i++];
  9811. y0 = yi = d[i++];
  9812. ctx.moveTo(xi, yi);
  9813. break;
  9814. case CMD.L:
  9815. {
  9816. x = d[i++];
  9817. y = d[i++];
  9818. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len$$1 - 1) {
  9819. if (drawPart) {
  9820. var l = pathSegLen[segCount++];
  9821. if (accumLength + l > displayedLength) {
  9822. var t = (displayedLength - accumLength) / l;
  9823. ctx.lineTo(xi * (1 - t) + x * t, yi * (1 - t) + y * t);
  9824. break lo;
  9825. }
  9826. accumLength += l;
  9827. }
  9828. ctx.lineTo(x, y);
  9829. xi = x;
  9830. yi = y;
  9831. }
  9832. break;
  9833. }
  9834. case CMD.C:
  9835. {
  9836. var x1 = d[i++];
  9837. var y1 = d[i++];
  9838. var x2 = d[i++];
  9839. var y2 = d[i++];
  9840. var x3 = d[i++];
  9841. var y3 = d[i++];
  9842. if (drawPart) {
  9843. var l = pathSegLen[segCount++];
  9844. if (accumLength + l > displayedLength) {
  9845. var t = (displayedLength - accumLength) / l;
  9846. cubicSubdivide(xi, x1, x2, x3, t, tmpOutX);
  9847. cubicSubdivide(yi, y1, y2, y3, t, tmpOutY);
  9848. ctx.bezierCurveTo(tmpOutX[1], tmpOutY[1], tmpOutX[2], tmpOutY[2], tmpOutX[3], tmpOutY[3]);
  9849. break lo;
  9850. }
  9851. accumLength += l;
  9852. }
  9853. ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  9854. xi = x3;
  9855. yi = y3;
  9856. break;
  9857. }
  9858. case CMD.Q:
  9859. {
  9860. var x1 = d[i++];
  9861. var y1 = d[i++];
  9862. var x2 = d[i++];
  9863. var y2 = d[i++];
  9864. if (drawPart) {
  9865. var l = pathSegLen[segCount++];
  9866. if (accumLength + l > displayedLength) {
  9867. var t = (displayedLength - accumLength) / l;
  9868. quadraticSubdivide(xi, x1, x2, t, tmpOutX);
  9869. quadraticSubdivide(yi, y1, y2, t, tmpOutY);
  9870. ctx.quadraticCurveTo(tmpOutX[1], tmpOutY[1], tmpOutX[2], tmpOutY[2]);
  9871. break lo;
  9872. }
  9873. accumLength += l;
  9874. }
  9875. ctx.quadraticCurveTo(x1, y1, x2, y2);
  9876. xi = x2;
  9877. yi = y2;
  9878. break;
  9879. }
  9880. case CMD.A:
  9881. var cx = d[i++];
  9882. var cy = d[i++];
  9883. var rx = d[i++];
  9884. var ry = d[i++];
  9885. var startAngle = d[i++];
  9886. var delta = d[i++];
  9887. var psi = d[i++];
  9888. var anticlockwise = !d[i++];
  9889. var r = rx > ry ? rx : ry;
  9890. var isEllipse = mathAbs(rx - ry) > 1e-3;
  9891. var endAngle = startAngle + delta;
  9892. var breakBuild = false;
  9893. if (drawPart) {
  9894. var l = pathSegLen[segCount++];
  9895. if (accumLength + l > displayedLength) {
  9896. endAngle = startAngle + delta * (displayedLength - accumLength) / l;
  9897. breakBuild = true;
  9898. }
  9899. accumLength += l;
  9900. }
  9901. if (isEllipse && ctx.ellipse) {
  9902. ctx.ellipse(cx, cy, rx, ry, psi, startAngle, endAngle, anticlockwise);
  9903. } else {
  9904. ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  9905. }
  9906. if (breakBuild) {
  9907. break lo;
  9908. }
  9909. if (isFirst) {
  9910. x0 = mathCos(startAngle) * rx + cx;
  9911. y0 = mathSin(startAngle) * ry + cy;
  9912. }
  9913. xi = mathCos(endAngle) * rx + cx;
  9914. yi = mathSin(endAngle) * ry + cy;
  9915. break;
  9916. case CMD.R:
  9917. x0 = xi = d[i];
  9918. y0 = yi = d[i + 1];
  9919. x = d[i++];
  9920. y = d[i++];
  9921. var width = d[i++];
  9922. var height = d[i++];
  9923. if (drawPart) {
  9924. var l = pathSegLen[segCount++];
  9925. if (accumLength + l > displayedLength) {
  9926. var d_1 = displayedLength - accumLength;
  9927. ctx.moveTo(x, y);
  9928. ctx.lineTo(x + mathMin$1(d_1, width), y);
  9929. d_1 -= width;
  9930. if (d_1 > 0) {
  9931. ctx.lineTo(x + width, y + mathMin$1(d_1, height));
  9932. }
  9933. d_1 -= height;
  9934. if (d_1 > 0) {
  9935. ctx.lineTo(x + mathMax$1(width - d_1, 0), y + height);
  9936. }
  9937. d_1 -= width;
  9938. if (d_1 > 0) {
  9939. ctx.lineTo(x, y + mathMax$1(height - d_1, 0));
  9940. }
  9941. break lo;
  9942. }
  9943. accumLength += l;
  9944. }
  9945. ctx.rect(x, y, width, height);
  9946. break;
  9947. case CMD.Z:
  9948. if (drawPart) {
  9949. var l = pathSegLen[segCount++];
  9950. if (accumLength + l > displayedLength) {
  9951. var t = (displayedLength - accumLength) / l;
  9952. ctx.lineTo(xi * (1 - t) + x0 * t, yi * (1 - t) + y0 * t);
  9953. break lo;
  9954. }
  9955. accumLength += l;
  9956. }
  9957. ctx.closePath();
  9958. xi = x0;
  9959. yi = y0;
  9960. }
  9961. }
  9962. };
  9963. PathProxy.CMD = CMD;
  9964. PathProxy.initDefaultProps = function () {
  9965. var proto = PathProxy.prototype;
  9966. proto._saveData = true;
  9967. proto._needsDash = false;
  9968. proto._dashOffset = 0;
  9969. proto._dashIdx = 0;
  9970. proto._dashSum = 0;
  9971. proto._ux = 0;
  9972. proto._uy = 0;
  9973. }();
  9974. return PathProxy;
  9975. }();
  9976. function containStroke$1(x0, y0, x1, y1, lineWidth, x, y) {
  9977. if (lineWidth === 0) {
  9978. return false;
  9979. }
  9980. var _l = lineWidth;
  9981. var _a = 0;
  9982. var _b = x0;
  9983. if (y > y0 + _l && y > y1 + _l || y < y0 - _l && y < y1 - _l || x > x0 + _l && x > x1 + _l || x < x0 - _l && x < x1 - _l) {
  9984. return false;
  9985. }
  9986. if (x0 !== x1) {
  9987. _a = (y0 - y1) / (x0 - x1);
  9988. _b = (x0 * y1 - x1 * y0) / (x0 - x1);
  9989. } else {
  9990. return Math.abs(x - x0) <= _l / 2;
  9991. }
  9992. var tmp = _a * x - y + _b;
  9993. var _s = tmp * tmp / (_a * _a + 1);
  9994. return _s <= _l / 2 * _l / 2;
  9995. }
  9996. function containStroke$2(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  9997. if (lineWidth === 0) {
  9998. return false;
  9999. }
  10000. var _l = lineWidth;
  10001. if (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l) {
  10002. return false;
  10003. }
  10004. var d = cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, null);
  10005. return d <= _l / 2;
  10006. }
  10007. function containStroke$3(x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  10008. if (lineWidth === 0) {
  10009. return false;
  10010. }
  10011. var _l = lineWidth;
  10012. if (y > y0 + _l && y > y1 + _l && y > y2 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l) {
  10013. return false;
  10014. }
  10015. var d = quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, null);
  10016. return d <= _l / 2;
  10017. }
  10018. var PI2$4 = Math.PI * 2;
  10019. function normalizeRadian(angle) {
  10020. angle %= PI2$4;
  10021. if (angle < 0) {
  10022. angle += PI2$4;
  10023. }
  10024. return angle;
  10025. }
  10026. var PI2$3 = Math.PI * 2;
  10027. function containStroke$4(cx, cy, r, startAngle, endAngle, anticlockwise, lineWidth, x, y) {
  10028. if (lineWidth === 0) {
  10029. return false;
  10030. }
  10031. var _l = lineWidth;
  10032. x -= cx;
  10033. y -= cy;
  10034. var d = Math.sqrt(x * x + y * y);
  10035. if (d - _l > r || d + _l < r) {
  10036. return false;
  10037. }
  10038. if (Math.abs(startAngle - endAngle) % PI2$3 < 1e-4) {
  10039. return true;
  10040. }
  10041. if (anticlockwise) {
  10042. var tmp = startAngle;
  10043. startAngle = normalizeRadian(endAngle);
  10044. endAngle = normalizeRadian(tmp);
  10045. } else {
  10046. startAngle = normalizeRadian(startAngle);
  10047. endAngle = normalizeRadian(endAngle);
  10048. }
  10049. if (startAngle > endAngle) {
  10050. endAngle += PI2$3;
  10051. }
  10052. var angle = Math.atan2(y, x);
  10053. if (angle < 0) {
  10054. angle += PI2$3;
  10055. }
  10056. return angle >= startAngle && angle <= endAngle || angle + PI2$3 >= startAngle && angle + PI2$3 <= endAngle;
  10057. }
  10058. function windingLine(x0, y0, x1, y1, x, y) {
  10059. if (y > y0 && y > y1 || y < y0 && y < y1) {
  10060. return 0;
  10061. }
  10062. if (y1 === y0) {
  10063. return 0;
  10064. }
  10065. var t = (y - y0) / (y1 - y0);
  10066. var dir = y1 < y0 ? 1 : -1;
  10067. if (t === 1 || t === 0) {
  10068. dir = y1 < y0 ? 0.5 : -0.5;
  10069. }
  10070. var x_ = t * (x1 - x0) + x0;
  10071. return x_ === x ? Infinity : x_ > x ? dir : 0;
  10072. }
  10073. var CMD$1 = PathProxy.CMD;
  10074. var PI2$2 = Math.PI * 2;
  10075. var EPSILON$2 = 1e-4;
  10076. function isAroundEqual(a, b) {
  10077. return Math.abs(a - b) < EPSILON$2;
  10078. }
  10079. var roots = [-1, -1, -1];
  10080. var extrema = [-1, -1];
  10081. function swapExtrema() {
  10082. var tmp = extrema[0];
  10083. extrema[0] = extrema[1];
  10084. extrema[1] = tmp;
  10085. }
  10086. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  10087. if (y > y0 && y > y1 && y > y2 && y > y3 || y < y0 && y < y1 && y < y2 && y < y3) {
  10088. return 0;
  10089. }
  10090. var nRoots = cubicRootAt(y0, y1, y2, y3, y, roots);
  10091. if (nRoots === 0) {
  10092. return 0;
  10093. } else {
  10094. var w = 0;
  10095. var nExtrema = -1;
  10096. var y0_ = void 0;
  10097. var y1_ = void 0;
  10098. for (var i = 0; i < nRoots; i++) {
  10099. var t = roots[i];
  10100. var unit = t === 0 || t === 1 ? 0.5 : 1;
  10101. var x_ = cubicAt(x0, x1, x2, x3, t);
  10102. if (x_ < x) {
  10103. continue;
  10104. }
  10105. if (nExtrema < 0) {
  10106. nExtrema = cubicExtrema(y0, y1, y2, y3, extrema);
  10107. if (extrema[1] < extrema[0] && nExtrema > 1) {
  10108. swapExtrema();
  10109. }
  10110. y0_ = cubicAt(y0, y1, y2, y3, extrema[0]);
  10111. if (nExtrema > 1) {
  10112. y1_ = cubicAt(y0, y1, y2, y3, extrema[1]);
  10113. }
  10114. }
  10115. if (nExtrema === 2) {
  10116. if (t < extrema[0]) {
  10117. w += y0_ < y0 ? unit : -unit;
  10118. } else if (t < extrema[1]) {
  10119. w += y1_ < y0_ ? unit : -unit;
  10120. } else {
  10121. w += y3 < y1_ ? unit : -unit;
  10122. }
  10123. } else {
  10124. if (t < extrema[0]) {
  10125. w += y0_ < y0 ? unit : -unit;
  10126. } else {
  10127. w += y3 < y0_ ? unit : -unit;
  10128. }
  10129. }
  10130. }
  10131. return w;
  10132. }
  10133. }
  10134. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  10135. if (y > y0 && y > y1 && y > y2 || y < y0 && y < y1 && y < y2) {
  10136. return 0;
  10137. }
  10138. var nRoots = quadraticRootAt(y0, y1, y2, y, roots);
  10139. if (nRoots === 0) {
  10140. return 0;
  10141. } else {
  10142. var t = quadraticExtremum(y0, y1, y2);
  10143. if (t >= 0 && t <= 1) {
  10144. var w = 0;
  10145. var y_ = quadraticAt(y0, y1, y2, t);
  10146. for (var i = 0; i < nRoots; i++) {
  10147. var unit = roots[i] === 0 || roots[i] === 1 ? 0.5 : 1;
  10148. var x_ = quadraticAt(x0, x1, x2, roots[i]);
  10149. if (x_ < x) {
  10150. continue;
  10151. }
  10152. if (roots[i] < t) {
  10153. w += y_ < y0 ? unit : -unit;
  10154. } else {
  10155. w += y2 < y_ ? unit : -unit;
  10156. }
  10157. }
  10158. return w;
  10159. } else {
  10160. var unit = roots[0] === 0 || roots[0] === 1 ? 0.5 : 1;
  10161. var x_ = quadraticAt(x0, x1, x2, roots[0]);
  10162. if (x_ < x) {
  10163. return 0;
  10164. }
  10165. return y2 < y0 ? unit : -unit;
  10166. }
  10167. }
  10168. }
  10169. function windingArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y) {
  10170. y -= cy;
  10171. if (y > r || y < -r) {
  10172. return 0;
  10173. }
  10174. var tmp = Math.sqrt(r * r - y * y);
  10175. roots[0] = -tmp;
  10176. roots[1] = tmp;
  10177. var dTheta = Math.abs(startAngle - endAngle);
  10178. if (dTheta < 1e-4) {
  10179. return 0;
  10180. }
  10181. if (dTheta >= PI2$2 - 1e-4) {
  10182. startAngle = 0;
  10183. endAngle = PI2$2;
  10184. var dir = anticlockwise ? 1 : -1;
  10185. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  10186. return dir;
  10187. } else {
  10188. return 0;
  10189. }
  10190. }
  10191. if (startAngle > endAngle) {
  10192. var tmp_1 = startAngle;
  10193. startAngle = endAngle;
  10194. endAngle = tmp_1;
  10195. }
  10196. if (startAngle < 0) {
  10197. startAngle += PI2$2;
  10198. endAngle += PI2$2;
  10199. }
  10200. var w = 0;
  10201. for (var i = 0; i < 2; i++) {
  10202. var x_ = roots[i];
  10203. if (x_ + cx > x) {
  10204. var angle = Math.atan2(y, x_);
  10205. var dir = anticlockwise ? 1 : -1;
  10206. if (angle < 0) {
  10207. angle = PI2$2 + angle;
  10208. }
  10209. if (angle >= startAngle && angle <= endAngle || angle + PI2$2 >= startAngle && angle + PI2$2 <= endAngle) {
  10210. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  10211. dir = -dir;
  10212. }
  10213. w += dir;
  10214. }
  10215. }
  10216. }
  10217. return w;
  10218. }
  10219. function containPath(path, lineWidth, isStroke, x, y) {
  10220. var data = path.data;
  10221. var len = path.len();
  10222. var w = 0;
  10223. var xi = 0;
  10224. var yi = 0;
  10225. var x0 = 0;
  10226. var y0 = 0;
  10227. var x1;
  10228. var y1;
  10229. for (var i = 0; i < len;) {
  10230. var cmd = data[i++];
  10231. var isFirst = i === 1;
  10232. if (cmd === CMD$1.M && i > 1) {
  10233. if (!isStroke) {
  10234. w += windingLine(xi, yi, x0, y0, x, y);
  10235. }
  10236. }
  10237. if (isFirst) {
  10238. xi = data[i];
  10239. yi = data[i + 1];
  10240. x0 = xi;
  10241. y0 = yi;
  10242. }
  10243. switch (cmd) {
  10244. case CMD$1.M:
  10245. x0 = data[i++];
  10246. y0 = data[i++];
  10247. xi = x0;
  10248. yi = y0;
  10249. break;
  10250. case CMD$1.L:
  10251. if (isStroke) {
  10252. if (containStroke$1(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  10253. return true;
  10254. }
  10255. } else {
  10256. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  10257. }
  10258. xi = data[i++];
  10259. yi = data[i++];
  10260. break;
  10261. case CMD$1.C:
  10262. if (isStroke) {
  10263. if (containStroke$2(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], lineWidth, x, y)) {
  10264. return true;
  10265. }
  10266. } else {
  10267. w += windingCubic(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], x, y) || 0;
  10268. }
  10269. xi = data[i++];
  10270. yi = data[i++];
  10271. break;
  10272. case CMD$1.Q:
  10273. if (isStroke) {
  10274. if (containStroke$3(xi, yi, data[i++], data[i++], data[i], data[i + 1], lineWidth, x, y)) {
  10275. return true;
  10276. }
  10277. } else {
  10278. w += windingQuadratic(xi, yi, data[i++], data[i++], data[i], data[i + 1], x, y) || 0;
  10279. }
  10280. xi = data[i++];
  10281. yi = data[i++];
  10282. break;
  10283. case CMD$1.A:
  10284. var cx = data[i++];
  10285. var cy = data[i++];
  10286. var rx = data[i++];
  10287. var ry = data[i++];
  10288. var theta = data[i++];
  10289. var dTheta = data[i++];
  10290. i += 1;
  10291. var anticlockwise = !!(1 - data[i++]);
  10292. x1 = Math.cos(theta) * rx + cx;
  10293. y1 = Math.sin(theta) * ry + cy;
  10294. if (!isFirst) {
  10295. w += windingLine(xi, yi, x1, y1, x, y);
  10296. } else {
  10297. x0 = x1;
  10298. y0 = y1;
  10299. }
  10300. var _x = (x - cx) * ry / rx + cx;
  10301. if (isStroke) {
  10302. if (containStroke$4(cx, cy, ry, theta, theta + dTheta, anticlockwise, lineWidth, _x, y)) {
  10303. return true;
  10304. }
  10305. } else {
  10306. w += windingArc(cx, cy, ry, theta, theta + dTheta, anticlockwise, _x, y);
  10307. }
  10308. xi = Math.cos(theta + dTheta) * rx + cx;
  10309. yi = Math.sin(theta + dTheta) * ry + cy;
  10310. break;
  10311. case CMD$1.R:
  10312. x0 = xi = data[i++];
  10313. y0 = yi = data[i++];
  10314. var width = data[i++];
  10315. var height = data[i++];
  10316. x1 = x0 + width;
  10317. y1 = y0 + height;
  10318. if (isStroke) {
  10319. if (containStroke$1(x0, y0, x1, y0, lineWidth, x, y) || containStroke$1(x1, y0, x1, y1, lineWidth, x, y) || containStroke$1(x1, y1, x0, y1, lineWidth, x, y) || containStroke$1(x0, y1, x0, y0, lineWidth, x, y)) {
  10320. return true;
  10321. }
  10322. } else {
  10323. w += windingLine(x1, y0, x1, y1, x, y);
  10324. w += windingLine(x0, y1, x0, y0, x, y);
  10325. }
  10326. break;
  10327. case CMD$1.Z:
  10328. if (isStroke) {
  10329. if (containStroke$1(xi, yi, x0, y0, lineWidth, x, y)) {
  10330. return true;
  10331. }
  10332. } else {
  10333. w += windingLine(xi, yi, x0, y0, x, y);
  10334. }
  10335. xi = x0;
  10336. yi = y0;
  10337. break;
  10338. }
  10339. }
  10340. if (!isStroke && !isAroundEqual(yi, y0)) {
  10341. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  10342. }
  10343. return w !== 0;
  10344. }
  10345. function contain(pathProxy, x, y) {
  10346. return containPath(pathProxy, 0, false, x, y);
  10347. }
  10348. function containStroke(pathProxy, lineWidth, x, y) {
  10349. return containPath(pathProxy, lineWidth, true, x, y);
  10350. }
  10351. var DEFAULT_PATH_STYLE = defaults({
  10352. fill: '#000',
  10353. stroke: null,
  10354. strokePercent: 1,
  10355. fillOpacity: 1,
  10356. strokeOpacity: 1,
  10357. lineDashOffset: 0,
  10358. lineWidth: 1,
  10359. lineCap: 'butt',
  10360. miterLimit: 10,
  10361. strokeNoScale: false,
  10362. strokeFirst: false
  10363. }, DEFAULT_COMMON_STYLE);
  10364. var DEFAULT_PATH_ANIMATION_PROPS = {
  10365. style: defaults({
  10366. fill: true,
  10367. stroke: true,
  10368. strokePercent: true,
  10369. fillOpacity: true,
  10370. strokeOpacity: true,
  10371. lineDashOffset: true,
  10372. lineWidth: true,
  10373. miterLimit: true
  10374. }, DEFAULT_COMMON_ANIMATION_PROPS.style)
  10375. };
  10376. var pathCopyParams = ['x', 'y', 'rotation', 'scaleX', 'scaleY', 'originX', 'originY', 'invisible', 'culling', 'z', 'z2', 'zlevel', 'parent'];
  10377. var Path = function (_super) {
  10378. __extends(Path, _super);
  10379. function Path(opts) {
  10380. return _super.call(this, opts) || this;
  10381. }
  10382. Path.prototype.update = function () {
  10383. var _this = this;
  10384. _super.prototype.update.call(this);
  10385. var style = this.style;
  10386. if (style.decal) {
  10387. var decalEl = this._decalEl = this._decalEl || new Path();
  10388. if (decalEl.buildPath === Path.prototype.buildPath) {
  10389. decalEl.buildPath = function (ctx) {
  10390. _this.buildPath(ctx, _this.shape);
  10391. };
  10392. }
  10393. decalEl.silent = true;
  10394. var decalElStyle = decalEl.style;
  10395. for (var key in style) {
  10396. if (decalElStyle[key] !== style[key]) {
  10397. decalElStyle[key] = style[key];
  10398. }
  10399. }
  10400. decalElStyle.fill = style.fill ? style.decal : null;
  10401. decalElStyle.decal = null;
  10402. decalElStyle.shadowColor = null;
  10403. style.strokeFirst && (decalElStyle.stroke = null);
  10404. for (var i = 0; i < pathCopyParams.length; ++i) {
  10405. decalEl[pathCopyParams[i]] = this[pathCopyParams[i]];
  10406. }
  10407. decalEl.__dirty |= Element.REDARAW_BIT;
  10408. } else if (this._decalEl) {
  10409. this._decalEl = null;
  10410. }
  10411. };
  10412. Path.prototype.getDecalElement = function () {
  10413. return this._decalEl;
  10414. };
  10415. Path.prototype._init = function (props) {
  10416. var keysArr = keys(props);
  10417. this.shape = this.getDefaultShape();
  10418. var defaultStyle = this.getDefaultStyle();
  10419. if (defaultStyle) {
  10420. this.useStyle(defaultStyle);
  10421. }
  10422. for (var i = 0; i < keysArr.length; i++) {
  10423. var key = keysArr[i];
  10424. var value = props[key];
  10425. if (key === 'style') {
  10426. if (!this.style) {
  10427. this.useStyle(value);
  10428. } else {
  10429. extend(this.style, value);
  10430. }
  10431. } else if (key === 'shape') {
  10432. extend(this.shape, value);
  10433. } else {
  10434. _super.prototype.attrKV.call(this, key, value);
  10435. }
  10436. }
  10437. if (!this.style) {
  10438. this.useStyle({});
  10439. }
  10440. };
  10441. Path.prototype.getDefaultStyle = function () {
  10442. return null;
  10443. };
  10444. Path.prototype.getDefaultShape = function () {
  10445. return {};
  10446. };
  10447. Path.prototype.canBeInsideText = function () {
  10448. return this.hasFill();
  10449. };
  10450. Path.prototype.getInsideTextFill = function () {
  10451. var pathFill = this.style.fill;
  10452. if (pathFill !== 'none') {
  10453. if (isString(pathFill)) {
  10454. var fillLum = lum(pathFill, 0);
  10455. if (fillLum > 0.5) {
  10456. return DARK_LABEL_COLOR;
  10457. } else if (fillLum > 0.2) {
  10458. return LIGHTER_LABEL_COLOR;
  10459. }
  10460. return LIGHT_LABEL_COLOR;
  10461. } else if (pathFill) {
  10462. return LIGHT_LABEL_COLOR;
  10463. }
  10464. }
  10465. return DARK_LABEL_COLOR;
  10466. };
  10467. Path.prototype.getInsideTextStroke = function (textFill) {
  10468. var pathFill = this.style.fill;
  10469. if (isString(pathFill)) {
  10470. var zr = this.__zr;
  10471. var isDarkMode = !!(zr && zr.isDarkMode());
  10472. var isDarkLabel = lum(textFill, 0) < DARK_MODE_THRESHOLD;
  10473. if (isDarkMode === isDarkLabel) {
  10474. return pathFill;
  10475. }
  10476. }
  10477. };
  10478. Path.prototype.buildPath = function (ctx, shapeCfg, inBundle) {};
  10479. Path.prototype.pathUpdated = function () {
  10480. this.__dirty &= ~Path.SHAPE_CHANGED_BIT;
  10481. };
  10482. Path.prototype.createPathProxy = function () {
  10483. this.path = new PathProxy(false);
  10484. };
  10485. Path.prototype.hasStroke = function () {
  10486. var style = this.style;
  10487. var stroke = style.stroke;
  10488. return !(stroke == null || stroke === 'none' || !(style.lineWidth > 0));
  10489. };
  10490. Path.prototype.hasFill = function () {
  10491. var style = this.style;
  10492. var fill = style.fill;
  10493. return fill != null && fill !== 'none';
  10494. };
  10495. Path.prototype.getBoundingRect = function () {
  10496. var rect = this._rect;
  10497. var style = this.style;
  10498. var needsUpdateRect = !rect;
  10499. if (needsUpdateRect) {
  10500. var firstInvoke = false;
  10501. if (!this.path) {
  10502. firstInvoke = true;
  10503. this.createPathProxy();
  10504. }
  10505. var path = this.path;
  10506. if (firstInvoke || this.__dirty & Path.SHAPE_CHANGED_BIT) {
  10507. path.beginPath();
  10508. this.buildPath(path, this.shape, false);
  10509. this.pathUpdated();
  10510. }
  10511. rect = path.getBoundingRect();
  10512. }
  10513. this._rect = rect;
  10514. if (this.hasStroke() && this.path && this.path.len() > 0) {
  10515. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  10516. if (this.__dirty || needsUpdateRect) {
  10517. rectWithStroke.copy(rect);
  10518. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  10519. var w = style.lineWidth;
  10520. if (!this.hasFill()) {
  10521. var strokeContainThreshold = this.strokeContainThreshold;
  10522. w = Math.max(w, strokeContainThreshold == null ? 4 : strokeContainThreshold);
  10523. }
  10524. if (lineScale > 1e-10) {
  10525. rectWithStroke.width += w / lineScale;
  10526. rectWithStroke.height += w / lineScale;
  10527. rectWithStroke.x -= w / lineScale / 2;
  10528. rectWithStroke.y -= w / lineScale / 2;
  10529. }
  10530. }
  10531. return rectWithStroke;
  10532. }
  10533. return rect;
  10534. };
  10535. Path.prototype.contain = function (x, y) {
  10536. var localPos = this.transformCoordToLocal(x, y);
  10537. var rect = this.getBoundingRect();
  10538. var style = this.style;
  10539. x = localPos[0];
  10540. y = localPos[1];
  10541. if (rect.contain(x, y)) {
  10542. var pathProxy = this.path;
  10543. if (this.hasStroke()) {
  10544. var lineWidth = style.lineWidth;
  10545. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  10546. if (lineScale > 1e-10) {
  10547. if (!this.hasFill()) {
  10548. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  10549. }
  10550. if (containStroke(pathProxy, lineWidth / lineScale, x, y)) {
  10551. return true;
  10552. }
  10553. }
  10554. }
  10555. if (this.hasFill()) {
  10556. return contain(pathProxy, x, y);
  10557. }
  10558. }
  10559. return false;
  10560. };
  10561. Path.prototype.dirtyShape = function () {
  10562. this.__dirty |= Path.SHAPE_CHANGED_BIT;
  10563. if (this._rect) {
  10564. this._rect = null;
  10565. }
  10566. if (this._decalEl) {
  10567. this._decalEl.dirtyShape();
  10568. }
  10569. this.markRedraw();
  10570. };
  10571. Path.prototype.dirty = function () {
  10572. this.dirtyStyle();
  10573. this.dirtyShape();
  10574. };
  10575. Path.prototype.animateShape = function (loop) {
  10576. return this.animate('shape', loop);
  10577. };
  10578. Path.prototype.updateDuringAnimation = function (targetKey) {
  10579. if (targetKey === 'style') {
  10580. this.dirtyStyle();
  10581. } else if (targetKey === 'shape') {
  10582. this.dirtyShape();
  10583. } else {
  10584. this.markRedraw();
  10585. }
  10586. };
  10587. Path.prototype.attrKV = function (key, value) {
  10588. if (key === 'shape') {
  10589. this.setShape(value);
  10590. } else {
  10591. _super.prototype.attrKV.call(this, key, value);
  10592. }
  10593. };
  10594. Path.prototype.setShape = function (keyOrObj, value) {
  10595. var shape = this.shape;
  10596. if (!shape) {
  10597. shape = this.shape = {};
  10598. }
  10599. if (typeof keyOrObj === 'string') {
  10600. shape[keyOrObj] = value;
  10601. } else {
  10602. extend(shape, keyOrObj);
  10603. }
  10604. this.dirtyShape();
  10605. return this;
  10606. };
  10607. Path.prototype.shapeChanged = function () {
  10608. return !!(this.__dirty & Path.SHAPE_CHANGED_BIT);
  10609. };
  10610. Path.prototype.createStyle = function (obj) {
  10611. return createObject(DEFAULT_PATH_STYLE, obj);
  10612. };
  10613. Path.prototype._innerSaveToNormal = function (toState) {
  10614. _super.prototype._innerSaveToNormal.call(this, toState);
  10615. var normalState = this._normalState;
  10616. if (toState.shape && !normalState.shape) {
  10617. normalState.shape = extend({}, this.shape);
  10618. }
  10619. };
  10620. Path.prototype._applyStateObj = function (stateName, state, normalState, keepCurrentStates, transition, animationCfg) {
  10621. _super.prototype._applyStateObj.call(this, stateName, state, normalState, keepCurrentStates, transition, animationCfg);
  10622. var needsRestoreToNormal = !(state && keepCurrentStates);
  10623. var targetShape;
  10624. if (state && state.shape) {
  10625. if (transition) {
  10626. if (keepCurrentStates) {
  10627. targetShape = state.shape;
  10628. } else {
  10629. targetShape = extend({}, normalState.shape);
  10630. extend(targetShape, state.shape);
  10631. }
  10632. } else {
  10633. targetShape = extend({}, keepCurrentStates ? this.shape : normalState.shape);
  10634. extend(targetShape, state.shape);
  10635. }
  10636. } else if (needsRestoreToNormal) {
  10637. targetShape = normalState.shape;
  10638. }
  10639. if (targetShape) {
  10640. if (transition) {
  10641. this.shape = extend({}, this.shape);
  10642. var targetShapePrimaryProps = {};
  10643. var shapeKeys = keys(targetShape);
  10644. for (var i = 0; i < shapeKeys.length; i++) {
  10645. var key = shapeKeys[i];
  10646. if (typeof targetShape[key] === 'object') {
  10647. this.shape[key] = targetShape[key];
  10648. } else {
  10649. targetShapePrimaryProps[key] = targetShape[key];
  10650. }
  10651. }
  10652. this._transitionState(stateName, {
  10653. shape: targetShapePrimaryProps
  10654. }, animationCfg);
  10655. } else {
  10656. this.shape = targetShape;
  10657. this.dirtyShape();
  10658. }
  10659. }
  10660. };
  10661. Path.prototype._mergeStates = function (states) {
  10662. var mergedState = _super.prototype._mergeStates.call(this, states);
  10663. var mergedShape;
  10664. for (var i = 0; i < states.length; i++) {
  10665. var state = states[i];
  10666. if (state.shape) {
  10667. mergedShape = mergedShape || {};
  10668. this._mergeStyle(mergedShape, state.shape);
  10669. }
  10670. }
  10671. if (mergedShape) {
  10672. mergedState.shape = mergedShape;
  10673. }
  10674. return mergedState;
  10675. };
  10676. Path.prototype.getAnimationStyleProps = function () {
  10677. return DEFAULT_PATH_ANIMATION_PROPS;
  10678. };
  10679. Path.prototype.isZeroArea = function () {
  10680. return false;
  10681. };
  10682. Path.extend = function (defaultProps) {
  10683. var Sub = function (_super) {
  10684. __extends(Sub, _super);
  10685. function Sub(opts) {
  10686. var _this = _super.call(this, opts) || this;
  10687. defaultProps.init && defaultProps.init.call(_this, opts);
  10688. return _this;
  10689. }
  10690. Sub.prototype.getDefaultStyle = function () {
  10691. return clone(defaultProps.style);
  10692. };
  10693. Sub.prototype.getDefaultShape = function () {
  10694. return clone(defaultProps.shape);
  10695. };
  10696. return Sub;
  10697. }(Path);
  10698. for (var key in defaultProps) {
  10699. if (typeof defaultProps[key] === 'function') {
  10700. Sub.prototype[key] = defaultProps[key];
  10701. }
  10702. }
  10703. return Sub;
  10704. };
  10705. Path.SHAPE_CHANGED_BIT = 4;
  10706. Path.initDefaultProps = function () {
  10707. var pathProto = Path.prototype;
  10708. pathProto.type = 'path';
  10709. pathProto.strokeContainThreshold = 5;
  10710. pathProto.segmentIgnoreThreshold = 0;
  10711. pathProto.subPixelOptimize = false;
  10712. pathProto.autoBatch = false;
  10713. pathProto.__dirty = Element.REDARAW_BIT | Displayable.STYLE_CHANGED_BIT | Path.SHAPE_CHANGED_BIT;
  10714. }();
  10715. return Path;
  10716. }(Displayable);
  10717. var DEFAULT_TSPAN_STYLE = defaults({
  10718. strokeFirst: true,
  10719. font: DEFAULT_FONT,
  10720. x: 0,
  10721. y: 0,
  10722. textAlign: 'left',
  10723. textBaseline: 'top',
  10724. miterLimit: 2
  10725. }, DEFAULT_PATH_STYLE);
  10726. var TSpan = function (_super) {
  10727. __extends(TSpan, _super);
  10728. function TSpan() {
  10729. return _super !== null && _super.apply(this, arguments) || this;
  10730. }
  10731. TSpan.prototype.hasStroke = function () {
  10732. var style = this.style;
  10733. var stroke = style.stroke;
  10734. return stroke != null && stroke !== 'none' && style.lineWidth > 0;
  10735. };
  10736. TSpan.prototype.hasFill = function () {
  10737. var style = this.style;
  10738. var fill = style.fill;
  10739. return fill != null && fill !== 'none';
  10740. };
  10741. TSpan.prototype.createStyle = function (obj) {
  10742. return createObject(DEFAULT_TSPAN_STYLE, obj);
  10743. };
  10744. TSpan.prototype.setBoundingRect = function (rect) {
  10745. this._rect = rect;
  10746. };
  10747. TSpan.prototype.getBoundingRect = function () {
  10748. var style = this.style;
  10749. if (!this._rect) {
  10750. var text = style.text;
  10751. text != null ? text += '' : text = '';
  10752. var rect = getBoundingRect(text, style.font, style.textAlign, style.textBaseline);
  10753. rect.x += style.x || 0;
  10754. rect.y += style.y || 0;
  10755. if (this.hasStroke()) {
  10756. var w = style.lineWidth;
  10757. rect.x -= w / 2;
  10758. rect.y -= w / 2;
  10759. rect.width += w;
  10760. rect.height += w;
  10761. }
  10762. this._rect = rect;
  10763. }
  10764. return this._rect;
  10765. };
  10766. TSpan.initDefaultProps = function () {
  10767. var tspanProto = TSpan.prototype;
  10768. tspanProto.dirtyRectTolerance = 10;
  10769. }();
  10770. return TSpan;
  10771. }(Displayable);
  10772. TSpan.prototype.type = 'tspan';
  10773. var DEFAULT_IMAGE_STYLE = defaults({
  10774. x: 0,
  10775. y: 0
  10776. }, DEFAULT_COMMON_STYLE);
  10777. var DEFAULT_IMAGE_ANIMATION_PROPS = {
  10778. style: defaults({
  10779. x: true,
  10780. y: true,
  10781. width: true,
  10782. height: true,
  10783. sx: true,
  10784. sy: true,
  10785. sWidth: true,
  10786. sHeight: true
  10787. }, DEFAULT_COMMON_ANIMATION_PROPS.style)
  10788. };
  10789. function isImageLike(source) {
  10790. return !!(source && typeof source !== 'string' && source.width && source.height);
  10791. }
  10792. var ZRImage = function (_super) {
  10793. __extends(ZRImage, _super);
  10794. function ZRImage() {
  10795. return _super !== null && _super.apply(this, arguments) || this;
  10796. }
  10797. ZRImage.prototype.createStyle = function (obj) {
  10798. return createObject(DEFAULT_IMAGE_STYLE, obj);
  10799. };
  10800. ZRImage.prototype._getSize = function (dim) {
  10801. var style = this.style;
  10802. var size = style[dim];
  10803. if (size != null) {
  10804. return size;
  10805. }
  10806. var imageSource = isImageLike(style.image) ? style.image : this.__image;
  10807. if (!imageSource) {
  10808. return 0;
  10809. }
  10810. var otherDim = dim === 'width' ? 'height' : 'width';
  10811. var otherDimSize = style[otherDim];
  10812. if (otherDimSize == null) {
  10813. return imageSource[dim];
  10814. } else {
  10815. return imageSource[dim] / imageSource[otherDim] * otherDimSize;
  10816. }
  10817. };
  10818. ZRImage.prototype.getWidth = function () {
  10819. return this._getSize('width');
  10820. };
  10821. ZRImage.prototype.getHeight = function () {
  10822. return this._getSize('height');
  10823. };
  10824. ZRImage.prototype.getAnimationStyleProps = function () {
  10825. return DEFAULT_IMAGE_ANIMATION_PROPS;
  10826. };
  10827. ZRImage.prototype.getBoundingRect = function () {
  10828. var style = this.style;
  10829. if (!this._rect) {
  10830. this._rect = new BoundingRect(style.x || 0, style.y || 0, this.getWidth(), this.getHeight());
  10831. }
  10832. return this._rect;
  10833. };
  10834. return ZRImage;
  10835. }(Displayable);
  10836. ZRImage.prototype.type = 'image';
  10837. function buildPath(ctx, shape) {
  10838. var x = shape.x;
  10839. var y = shape.y;
  10840. var width = shape.width;
  10841. var height = shape.height;
  10842. var r = shape.r;
  10843. var r1;
  10844. var r2;
  10845. var r3;
  10846. var r4;
  10847. if (width < 0) {
  10848. x = x + width;
  10849. width = -width;
  10850. }
  10851. if (height < 0) {
  10852. y = y + height;
  10853. height = -height;
  10854. }
  10855. if (typeof r === 'number') {
  10856. r1 = r2 = r3 = r4 = r;
  10857. } else if (r instanceof Array) {
  10858. if (r.length === 1) {
  10859. r1 = r2 = r3 = r4 = r[0];
  10860. } else if (r.length === 2) {
  10861. r1 = r3 = r[0];
  10862. r2 = r4 = r[1];
  10863. } else if (r.length === 3) {
  10864. r1 = r[0];
  10865. r2 = r4 = r[1];
  10866. r3 = r[2];
  10867. } else {
  10868. r1 = r[0];
  10869. r2 = r[1];
  10870. r3 = r[2];
  10871. r4 = r[3];
  10872. }
  10873. } else {
  10874. r1 = r2 = r3 = r4 = 0;
  10875. }
  10876. var total;
  10877. if (r1 + r2 > width) {
  10878. total = r1 + r2;
  10879. r1 *= width / total;
  10880. r2 *= width / total;
  10881. }
  10882. if (r3 + r4 > width) {
  10883. total = r3 + r4;
  10884. r3 *= width / total;
  10885. r4 *= width / total;
  10886. }
  10887. if (r2 + r3 > height) {
  10888. total = r2 + r3;
  10889. r2 *= height / total;
  10890. r3 *= height / total;
  10891. }
  10892. if (r1 + r4 > height) {
  10893. total = r1 + r4;
  10894. r1 *= height / total;
  10895. r4 *= height / total;
  10896. }
  10897. ctx.moveTo(x + r1, y);
  10898. ctx.lineTo(x + width - r2, y);
  10899. r2 !== 0 && ctx.arc(x + width - r2, y + r2, r2, -Math.PI / 2, 0);
  10900. ctx.lineTo(x + width, y + height - r3);
  10901. r3 !== 0 && ctx.arc(x + width - r3, y + height - r3, r3, 0, Math.PI / 2);
  10902. ctx.lineTo(x + r4, y + height);
  10903. r4 !== 0 && ctx.arc(x + r4, y + height - r4, r4, Math.PI / 2, Math.PI);
  10904. ctx.lineTo(x, y + r1);
  10905. r1 !== 0 && ctx.arc(x + r1, y + r1, r1, Math.PI, Math.PI * 1.5);
  10906. }
  10907. var round$1 = Math.round;
  10908. function subPixelOptimizeLine(outputShape, inputShape, style) {
  10909. if (!inputShape) {
  10910. return;
  10911. }
  10912. var x1 = inputShape.x1;
  10913. var x2 = inputShape.x2;
  10914. var y1 = inputShape.y1;
  10915. var y2 = inputShape.y2;
  10916. outputShape.x1 = x1;
  10917. outputShape.x2 = x2;
  10918. outputShape.y1 = y1;
  10919. outputShape.y2 = y2;
  10920. var lineWidth = style && style.lineWidth;
  10921. if (!lineWidth) {
  10922. return outputShape;
  10923. }
  10924. if (round$1(x1 * 2) === round$1(x2 * 2)) {
  10925. outputShape.x1 = outputShape.x2 = subPixelOptimize(x1, lineWidth, true);
  10926. }
  10927. if (round$1(y1 * 2) === round$1(y2 * 2)) {
  10928. outputShape.y1 = outputShape.y2 = subPixelOptimize(y1, lineWidth, true);
  10929. }
  10930. return outputShape;
  10931. }
  10932. function subPixelOptimizeRect(outputShape, inputShape, style) {
  10933. if (!inputShape) {
  10934. return;
  10935. }
  10936. var originX = inputShape.x;
  10937. var originY = inputShape.y;
  10938. var originWidth = inputShape.width;
  10939. var originHeight = inputShape.height;
  10940. outputShape.x = originX;
  10941. outputShape.y = originY;
  10942. outputShape.width = originWidth;
  10943. outputShape.height = originHeight;
  10944. var lineWidth = style && style.lineWidth;
  10945. if (!lineWidth) {
  10946. return outputShape;
  10947. }
  10948. outputShape.x = subPixelOptimize(originX, lineWidth, true);
  10949. outputShape.y = subPixelOptimize(originY, lineWidth, true);
  10950. outputShape.width = Math.max(subPixelOptimize(originX + originWidth, lineWidth, false) - outputShape.x, originWidth === 0 ? 0 : 1);
  10951. outputShape.height = Math.max(subPixelOptimize(originY + originHeight, lineWidth, false) - outputShape.y, originHeight === 0 ? 0 : 1);
  10952. return outputShape;
  10953. }
  10954. function subPixelOptimize(position, lineWidth, positiveOrNegative) {
  10955. if (!lineWidth) {
  10956. return position;
  10957. }
  10958. var doubledPosition = round$1(position * 2);
  10959. return (doubledPosition + round$1(lineWidth)) % 2 === 0 ? doubledPosition / 2 : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  10960. }
  10961. var RectShape = function () {
  10962. function RectShape() {
  10963. this.x = 0;
  10964. this.y = 0;
  10965. this.width = 0;
  10966. this.height = 0;
  10967. }
  10968. return RectShape;
  10969. }();
  10970. var subPixelOptimizeOutputShape = {};
  10971. var Rect = function (_super) {
  10972. __extends(Rect, _super);
  10973. function Rect(opts) {
  10974. return _super.call(this, opts) || this;
  10975. }
  10976. Rect.prototype.getDefaultShape = function () {
  10977. return new RectShape();
  10978. };
  10979. Rect.prototype.buildPath = function (ctx, shape) {
  10980. var x;
  10981. var y;
  10982. var width;
  10983. var height;
  10984. if (this.subPixelOptimize) {
  10985. var optimizedShape = subPixelOptimizeRect(subPixelOptimizeOutputShape, shape, this.style);
  10986. x = optimizedShape.x;
  10987. y = optimizedShape.y;
  10988. width = optimizedShape.width;
  10989. height = optimizedShape.height;
  10990. optimizedShape.r = shape.r;
  10991. shape = optimizedShape;
  10992. } else {
  10993. x = shape.x;
  10994. y = shape.y;
  10995. width = shape.width;
  10996. height = shape.height;
  10997. }
  10998. if (!shape.r) {
  10999. ctx.rect(x, y, width, height);
  11000. } else {
  11001. buildPath(ctx, shape);
  11002. }
  11003. };
  11004. Rect.prototype.isZeroArea = function () {
  11005. return !this.shape.width || !this.shape.height;
  11006. };
  11007. return Rect;
  11008. }(Path);
  11009. Rect.prototype.type = 'rect';
  11010. var DEFAULT_RICH_TEXT_COLOR = {
  11011. fill: '#000'
  11012. };
  11013. var DEFAULT_STROKE_LINE_WIDTH = 2;
  11014. var DEFAULT_TEXT_ANIMATION_PROPS = {
  11015. style: defaults({
  11016. fill: true,
  11017. stroke: true,
  11018. fillOpacity: true,
  11019. strokeOpacity: true,
  11020. lineWidth: true,
  11021. fontSize: true,
  11022. lineHeight: true,
  11023. width: true,
  11024. height: true,
  11025. textShadowColor: true,
  11026. textShadowBlur: true,
  11027. textShadowOffsetX: true,
  11028. textShadowOffsetY: true,
  11029. backgroundColor: true,
  11030. padding: true,
  11031. borderColor: true,
  11032. borderWidth: true,
  11033. borderRadius: true
  11034. }, DEFAULT_COMMON_ANIMATION_PROPS.style)
  11035. };
  11036. var ZRText = function (_super) {
  11037. __extends(ZRText, _super);
  11038. function ZRText(opts) {
  11039. var _this = _super.call(this) || this;
  11040. _this.type = 'text';
  11041. _this._children = [];
  11042. _this._defaultStyle = DEFAULT_RICH_TEXT_COLOR;
  11043. _this.attr(opts);
  11044. return _this;
  11045. }
  11046. ZRText.prototype.childrenRef = function () {
  11047. return this._children;
  11048. };
  11049. ZRText.prototype.update = function () {
  11050. if (this.styleChanged()) {
  11051. this._updateSubTexts();
  11052. }
  11053. for (var i = 0; i < this._children.length; i++) {
  11054. var child = this._children[i];
  11055. child.zlevel = this.zlevel;
  11056. child.z = this.z;
  11057. child.z2 = this.z2;
  11058. child.culling = this.culling;
  11059. child.cursor = this.cursor;
  11060. child.invisible = this.invisible;
  11061. }
  11062. var attachedTransform = this.attachedTransform;
  11063. if (attachedTransform) {
  11064. attachedTransform.updateTransform();
  11065. var m = attachedTransform.transform;
  11066. if (m) {
  11067. this.transform = this.transform || [];
  11068. copy$1(this.transform, m);
  11069. } else {
  11070. this.transform = null;
  11071. }
  11072. } else {
  11073. _super.prototype.update.call(this);
  11074. }
  11075. };
  11076. ZRText.prototype.getComputedTransform = function () {
  11077. if (this.__hostTarget) {
  11078. this.__hostTarget.getComputedTransform();
  11079. this.__hostTarget.updateInnerText(true);
  11080. }
  11081. return this.attachedTransform ? this.attachedTransform.getComputedTransform() : _super.prototype.getComputedTransform.call(this);
  11082. };
  11083. ZRText.prototype._updateSubTexts = function () {
  11084. this._childCursor = 0;
  11085. normalizeTextStyle(this.style);
  11086. this.style.rich ? this._updateRichTexts() : this._updatePlainTexts();
  11087. this._children.length = this._childCursor;
  11088. this.styleUpdated();
  11089. };
  11090. ZRText.prototype.addSelfToZr = function (zr) {
  11091. _super.prototype.addSelfToZr.call(this, zr);
  11092. for (var i = 0; i < this._children.length; i++) {
  11093. this._children[i].__zr = zr;
  11094. }
  11095. };
  11096. ZRText.prototype.removeSelfFromZr = function (zr) {
  11097. _super.prototype.removeSelfFromZr.call(this, zr);
  11098. for (var i = 0; i < this._children.length; i++) {
  11099. this._children[i].__zr = null;
  11100. }
  11101. };
  11102. ZRText.prototype.getBoundingRect = function () {
  11103. if (this.styleChanged()) {
  11104. this._updateSubTexts();
  11105. }
  11106. if (!this._rect) {
  11107. var tmpRect = new BoundingRect(0, 0, 0, 0);
  11108. var children = this._children;
  11109. var tmpMat = [];
  11110. var rect = null;
  11111. for (var i = 0; i < children.length; i++) {
  11112. var child = children[i];
  11113. var childRect = child.getBoundingRect();
  11114. var transform = child.getLocalTransform(tmpMat);
  11115. if (transform) {
  11116. tmpRect.copy(childRect);
  11117. tmpRect.applyTransform(transform);
  11118. rect = rect || tmpRect.clone();
  11119. rect.union(tmpRect);
  11120. } else {
  11121. rect = rect || childRect.clone();
  11122. rect.union(childRect);
  11123. }
  11124. }
  11125. this._rect = rect || tmpRect;
  11126. }
  11127. return this._rect;
  11128. };
  11129. ZRText.prototype.setDefaultTextStyle = function (defaultTextStyle) {
  11130. this._defaultStyle = defaultTextStyle || DEFAULT_RICH_TEXT_COLOR;
  11131. };
  11132. ZRText.prototype.setTextContent = function (textContent) {
  11133. throw new Error('Can\'t attach text on another text');
  11134. };
  11135. ZRText.prototype._mergeStyle = function (targetStyle, sourceStyle) {
  11136. if (!sourceStyle) {
  11137. return targetStyle;
  11138. }
  11139. var sourceRich = sourceStyle.rich;
  11140. var targetRich = targetStyle.rich || sourceRich && {};
  11141. extend(targetStyle, sourceStyle);
  11142. if (sourceRich && targetRich) {
  11143. this._mergeRich(targetRich, sourceRich);
  11144. targetStyle.rich = targetRich;
  11145. } else if (targetRich) {
  11146. targetStyle.rich = targetRich;
  11147. }
  11148. return targetStyle;
  11149. };
  11150. ZRText.prototype._mergeRich = function (targetRich, sourceRich) {
  11151. var richNames = keys(sourceRich);
  11152. for (var i = 0; i < richNames.length; i++) {
  11153. var richName = richNames[i];
  11154. targetRich[richName] = targetRich[richName] || {};
  11155. extend(targetRich[richName], sourceRich[richName]);
  11156. }
  11157. };
  11158. ZRText.prototype.getAnimationStyleProps = function () {
  11159. return DEFAULT_TEXT_ANIMATION_PROPS;
  11160. };
  11161. ZRText.prototype._getOrCreateChild = function (Ctor) {
  11162. var child = this._children[this._childCursor];
  11163. if (!child || !(child instanceof Ctor)) {
  11164. child = new Ctor();
  11165. }
  11166. this._children[this._childCursor++] = child;
  11167. child.__zr = this.__zr;
  11168. child.parent = this;
  11169. return child;
  11170. };
  11171. ZRText.prototype._updatePlainTexts = function () {
  11172. var style = this.style;
  11173. var textFont = style.font || DEFAULT_FONT;
  11174. var textPadding = style.padding;
  11175. var text = getStyleText(style);
  11176. var contentBlock = parsePlainText(text, style);
  11177. var needDrawBg = needDrawBackground(style);
  11178. var bgColorDrawn = !!style.backgroundColor;
  11179. var outerHeight = contentBlock.outerHeight;
  11180. var textLines = contentBlock.lines;
  11181. var lineHeight = contentBlock.lineHeight;
  11182. var defaultStyle = this._defaultStyle;
  11183. var baseX = style.x || 0;
  11184. var baseY = style.y || 0;
  11185. var textAlign = style.align || defaultStyle.align || 'left';
  11186. var verticalAlign = style.verticalAlign || defaultStyle.verticalAlign || 'top';
  11187. var textX = baseX;
  11188. var textY = adjustTextY(baseY, contentBlock.contentHeight, verticalAlign);
  11189. if (needDrawBg || textPadding) {
  11190. var outerWidth_1 = contentBlock.width;
  11191. textPadding && (outerWidth_1 += textPadding[1] + textPadding[3]);
  11192. var boxX = adjustTextX(baseX, outerWidth_1, textAlign);
  11193. var boxY = adjustTextY(baseY, outerHeight, verticalAlign);
  11194. needDrawBg && this._renderBackground(style, style, boxX, boxY, outerWidth_1, outerHeight);
  11195. }
  11196. textY += lineHeight / 2;
  11197. if (textPadding) {
  11198. textX = getTextXForPadding(baseX, textAlign, textPadding);
  11199. if (verticalAlign === 'top') {
  11200. textY += textPadding[0];
  11201. } else if (verticalAlign === 'bottom') {
  11202. textY -= textPadding[2];
  11203. }
  11204. }
  11205. var defaultLineWidth = 0;
  11206. var useDefaultFill = false;
  11207. var textFill = getFill('fill' in style ? style.fill : (useDefaultFill = true, defaultStyle.fill));
  11208. var textStroke = getStroke('stroke' in style ? style.stroke : !bgColorDrawn && (!defaultStyle.autoStroke || useDefaultFill) ? (defaultLineWidth = DEFAULT_STROKE_LINE_WIDTH, defaultStyle.stroke) : null);
  11209. var hasShadow = style.textShadowBlur > 0;
  11210. var fixedBoundingRect = style.width != null && (style.overflow === 'truncate' || style.overflow === 'break' || style.overflow === 'breakAll');
  11211. var calculatedLineHeight = contentBlock.calculatedLineHeight;
  11212. for (var i = 0; i < textLines.length; i++) {
  11213. var el = this._getOrCreateChild(TSpan);
  11214. var subElStyle = el.createStyle();
  11215. el.useStyle(subElStyle);
  11216. subElStyle.text = textLines[i];
  11217. subElStyle.x = textX;
  11218. subElStyle.y = textY;
  11219. if (textAlign) {
  11220. subElStyle.textAlign = textAlign;
  11221. }
  11222. subElStyle.textBaseline = 'middle';
  11223. subElStyle.opacity = style.opacity;
  11224. subElStyle.strokeFirst = true;
  11225. if (hasShadow) {
  11226. subElStyle.shadowBlur = style.textShadowBlur || 0;
  11227. subElStyle.shadowColor = style.textShadowColor || 'transparent';
  11228. subElStyle.shadowOffsetX = style.textShadowOffsetX || 0;
  11229. subElStyle.shadowOffsetY = style.textShadowOffsetY || 0;
  11230. }
  11231. if (textStroke) {
  11232. subElStyle.stroke = textStroke;
  11233. subElStyle.lineWidth = style.lineWidth || defaultLineWidth;
  11234. subElStyle.lineDash = style.lineDash;
  11235. subElStyle.lineDashOffset = style.lineDashOffset || 0;
  11236. }
  11237. if (textFill) {
  11238. subElStyle.fill = textFill;
  11239. }
  11240. subElStyle.font = textFont;
  11241. textY += lineHeight;
  11242. if (fixedBoundingRect) {
  11243. el.setBoundingRect(new BoundingRect(adjustTextX(subElStyle.x, style.width, subElStyle.textAlign), adjustTextY(subElStyle.y, calculatedLineHeight, subElStyle.textBaseline), style.width, calculatedLineHeight));
  11244. }
  11245. }
  11246. };
  11247. ZRText.prototype._updateRichTexts = function () {
  11248. var style = this.style;
  11249. var text = getStyleText(style);
  11250. var contentBlock = parseRichText(text, style);
  11251. var contentWidth = contentBlock.width;
  11252. var outerWidth = contentBlock.outerWidth;
  11253. var outerHeight = contentBlock.outerHeight;
  11254. var textPadding = style.padding;
  11255. var baseX = style.x || 0;
  11256. var baseY = style.y || 0;
  11257. var defaultStyle = this._defaultStyle;
  11258. var textAlign = style.align || defaultStyle.align;
  11259. var verticalAlign = style.verticalAlign || defaultStyle.verticalAlign;
  11260. var boxX = adjustTextX(baseX, outerWidth, textAlign);
  11261. var boxY = adjustTextY(baseY, outerHeight, verticalAlign);
  11262. var xLeft = boxX;
  11263. var lineTop = boxY;
  11264. if (textPadding) {
  11265. xLeft += textPadding[3];
  11266. lineTop += textPadding[0];
  11267. }
  11268. var xRight = xLeft + contentWidth;
  11269. if (needDrawBackground(style)) {
  11270. this._renderBackground(style, style, boxX, boxY, outerWidth, outerHeight);
  11271. }
  11272. var bgColorDrawn = !!style.backgroundColor;
  11273. for (var i = 0; i < contentBlock.lines.length; i++) {
  11274. var line = contentBlock.lines[i];
  11275. var tokens = line.tokens;
  11276. var tokenCount = tokens.length;
  11277. var lineHeight = line.lineHeight;
  11278. var remainedWidth = line.width;
  11279. var leftIndex = 0;
  11280. var lineXLeft = xLeft;
  11281. var lineXRight = xRight;
  11282. var rightIndex = tokenCount - 1;
  11283. var token = void 0;
  11284. while (leftIndex < tokenCount && (token = tokens[leftIndex], !token.align || token.align === 'left')) {
  11285. this._placeToken(token, style, lineHeight, lineTop, lineXLeft, 'left', bgColorDrawn);
  11286. remainedWidth -= token.width;
  11287. lineXLeft += token.width;
  11288. leftIndex++;
  11289. }
  11290. while (rightIndex >= 0 && (token = tokens[rightIndex], token.align === 'right')) {
  11291. this._placeToken(token, style, lineHeight, lineTop, lineXRight, 'right', bgColorDrawn);
  11292. remainedWidth -= token.width;
  11293. lineXRight -= token.width;
  11294. rightIndex--;
  11295. }
  11296. lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - remainedWidth) / 2;
  11297. while (leftIndex <= rightIndex) {
  11298. token = tokens[leftIndex];
  11299. this._placeToken(token, style, lineHeight, lineTop, lineXLeft + token.width / 2, 'center', bgColorDrawn);
  11300. lineXLeft += token.width;
  11301. leftIndex++;
  11302. }
  11303. lineTop += lineHeight;
  11304. }
  11305. };
  11306. ZRText.prototype._placeToken = function (token, style, lineHeight, lineTop, x, textAlign, parentBgColorDrawn) {
  11307. var tokenStyle = style.rich[token.styleName] || {};
  11308. tokenStyle.text = token.text;
  11309. var verticalAlign = token.verticalAlign;
  11310. var y = lineTop + lineHeight / 2;
  11311. if (verticalAlign === 'top') {
  11312. y = lineTop + token.height / 2;
  11313. } else if (verticalAlign === 'bottom') {
  11314. y = lineTop + lineHeight - token.height / 2;
  11315. }
  11316. var needDrawBg = !token.isLineHolder && needDrawBackground(tokenStyle);
  11317. needDrawBg && this._renderBackground(tokenStyle, style, textAlign === 'right' ? x - token.width : textAlign === 'center' ? x - token.width / 2 : x, y - token.height / 2, token.width, token.height);
  11318. var bgColorDrawn = !!tokenStyle.backgroundColor;
  11319. var textPadding = token.textPadding;
  11320. if (textPadding) {
  11321. x = getTextXForPadding(x, textAlign, textPadding);
  11322. y -= token.height / 2 - textPadding[0] - token.innerHeight / 2;
  11323. }
  11324. var el = this._getOrCreateChild(TSpan);
  11325. var subElStyle = el.createStyle();
  11326. el.useStyle(subElStyle);
  11327. var defaultStyle = this._defaultStyle;
  11328. var useDefaultFill = false;
  11329. var defaultLineWidth = 0;
  11330. var textFill = getStroke('fill' in tokenStyle ? tokenStyle.fill : 'fill' in style ? style.fill : (useDefaultFill = true, defaultStyle.fill));
  11331. var textStroke = getStroke('stroke' in tokenStyle ? tokenStyle.stroke : 'stroke' in style ? style.stroke : !bgColorDrawn && !parentBgColorDrawn && (!defaultStyle.autoStroke || useDefaultFill) ? (defaultLineWidth = DEFAULT_STROKE_LINE_WIDTH, defaultStyle.stroke) : null);
  11332. var hasShadow = tokenStyle.textShadowBlur > 0 || style.textShadowBlur > 0;
  11333. subElStyle.text = token.text;
  11334. subElStyle.x = x;
  11335. subElStyle.y = y;
  11336. if (hasShadow) {
  11337. subElStyle.shadowBlur = tokenStyle.textShadowBlur || style.textShadowBlur || 0;
  11338. subElStyle.shadowColor = tokenStyle.textShadowColor || style.textShadowColor || 'transparent';
  11339. subElStyle.shadowOffsetX = tokenStyle.textShadowOffsetX || style.textShadowOffsetX || 0;
  11340. subElStyle.shadowOffsetY = tokenStyle.textShadowOffsetY || style.textShadowOffsetY || 0;
  11341. }
  11342. subElStyle.textAlign = textAlign;
  11343. subElStyle.textBaseline = 'middle';
  11344. subElStyle.font = token.font || DEFAULT_FONT;
  11345. subElStyle.opacity = retrieve3(tokenStyle.opacity, style.opacity, 1);
  11346. if (textStroke) {
  11347. subElStyle.lineWidth = retrieve3(tokenStyle.lineWidth, style.lineWidth, defaultLineWidth);
  11348. subElStyle.lineDash = retrieve2(tokenStyle.lineDash, style.lineDash);
  11349. subElStyle.lineDashOffset = style.lineDashOffset || 0;
  11350. subElStyle.stroke = textStroke;
  11351. }
  11352. if (textFill) {
  11353. subElStyle.fill = textFill;
  11354. }
  11355. var textWidth = token.contentWidth;
  11356. var textHeight = token.contentHeight;
  11357. el.setBoundingRect(new BoundingRect(adjustTextX(subElStyle.x, textWidth, subElStyle.textAlign), adjustTextY(subElStyle.y, textHeight, subElStyle.textBaseline), textWidth, textHeight));
  11358. };
  11359. ZRText.prototype._renderBackground = function (style, topStyle, x, y, width, height) {
  11360. var textBackgroundColor = style.backgroundColor;
  11361. var textBorderWidth = style.borderWidth;
  11362. var textBorderColor = style.borderColor;
  11363. var isPlainBg = isString(textBackgroundColor);
  11364. var textBorderRadius = style.borderRadius;
  11365. var self = this;
  11366. var rectEl;
  11367. var imgEl;
  11368. if (isPlainBg || textBorderWidth && textBorderColor) {
  11369. rectEl = this._getOrCreateChild(Rect);
  11370. rectEl.useStyle(rectEl.createStyle());
  11371. rectEl.style.fill = null;
  11372. var rectShape = rectEl.shape;
  11373. rectShape.x = x;
  11374. rectShape.y = y;
  11375. rectShape.width = width;
  11376. rectShape.height = height;
  11377. rectShape.r = textBorderRadius;
  11378. rectEl.dirtyShape();
  11379. }
  11380. if (isPlainBg) {
  11381. var rectStyle = rectEl.style;
  11382. rectStyle.fill = textBackgroundColor || null;
  11383. rectStyle.fillOpacity = retrieve2(style.fillOpacity, 1);
  11384. } else if (textBackgroundColor && textBackgroundColor.image) {
  11385. imgEl = this._getOrCreateChild(ZRImage);
  11386. imgEl.onload = function () {
  11387. self.dirtyStyle();
  11388. };
  11389. var imgStyle = imgEl.style;
  11390. imgStyle.image = textBackgroundColor.image;
  11391. imgStyle.x = x;
  11392. imgStyle.y = y;
  11393. imgStyle.width = width;
  11394. imgStyle.height = height;
  11395. }
  11396. if (textBorderWidth && textBorderColor) {
  11397. var rectStyle = rectEl.style;
  11398. rectStyle.lineWidth = textBorderWidth;
  11399. rectStyle.stroke = textBorderColor;
  11400. rectStyle.strokeOpacity = retrieve2(style.strokeOpacity, 1);
  11401. rectStyle.lineDash = style.borderDash;
  11402. rectStyle.lineDashOffset = style.borderDashOffset || 0;
  11403. rectEl.strokeContainThreshold = 0;
  11404. if (rectEl.hasFill() && rectEl.hasStroke()) {
  11405. rectStyle.strokeFirst = true;
  11406. rectStyle.lineWidth *= 2;
  11407. }
  11408. }
  11409. var commonStyle = (rectEl || imgEl).style;
  11410. commonStyle.shadowBlur = style.shadowBlur || 0;
  11411. commonStyle.shadowColor = style.shadowColor || 'transparent';
  11412. commonStyle.shadowOffsetX = style.shadowOffsetX || 0;
  11413. commonStyle.shadowOffsetY = style.shadowOffsetY || 0;
  11414. commonStyle.opacity = retrieve3(style.opacity, topStyle.opacity, 1);
  11415. };
  11416. ZRText.makeFont = function (style) {
  11417. var font = '';
  11418. if (style.fontSize || style.fontFamily || style.fontWeight) {
  11419. var fontSize = '';
  11420. if (typeof style.fontSize === 'string' && (style.fontSize.indexOf('px') !== -1 || style.fontSize.indexOf('rem') !== -1 || style.fontSize.indexOf('em') !== -1)) {
  11421. fontSize = style.fontSize;
  11422. } else if (!isNaN(+style.fontSize)) {
  11423. fontSize = style.fontSize + 'px';
  11424. } else {
  11425. fontSize = '12px';
  11426. }
  11427. font = [style.fontStyle, style.fontWeight, fontSize, style.fontFamily || 'sans-serif'].join(' ');
  11428. }
  11429. return font && trim(font) || style.textFont || style.font;
  11430. };
  11431. return ZRText;
  11432. }(Displayable);
  11433. var VALID_TEXT_ALIGN = {
  11434. left: true,
  11435. right: 1,
  11436. center: 1
  11437. };
  11438. var VALID_TEXT_VERTICAL_ALIGN = {
  11439. top: 1,
  11440. bottom: 1,
  11441. middle: 1
  11442. };
  11443. function normalizeTextStyle(style) {
  11444. normalizeStyle(style);
  11445. each$1(style.rich, normalizeStyle);
  11446. return style;
  11447. }
  11448. function normalizeStyle(style) {
  11449. if (style) {
  11450. style.font = ZRText.makeFont(style);
  11451. var textAlign = style.align;
  11452. textAlign === 'middle' && (textAlign = 'center');
  11453. style.align = textAlign == null || VALID_TEXT_ALIGN[textAlign] ? textAlign : 'left';
  11454. var verticalAlign = style.verticalAlign;
  11455. verticalAlign === 'center' && (verticalAlign = 'middle');
  11456. style.verticalAlign = verticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[verticalAlign] ? verticalAlign : 'top';
  11457. var textPadding = style.padding;
  11458. if (textPadding) {
  11459. style.padding = normalizeCssArray(style.padding);
  11460. }
  11461. }
  11462. }
  11463. function getStroke(stroke, lineWidth) {
  11464. return stroke == null || lineWidth <= 0 || stroke === 'transparent' || stroke === 'none' ? null : stroke.image || stroke.colorStops ? '#000' : stroke;
  11465. }
  11466. function getFill(fill) {
  11467. return fill == null || fill === 'none' ? null : fill.image || fill.colorStops ? '#000' : fill;
  11468. }
  11469. function getTextXForPadding(x, textAlign, textPadding) {
  11470. return textAlign === 'right' ? x - textPadding[1] : textAlign === 'center' ? x + textPadding[3] / 2 - textPadding[1] / 2 : x + textPadding[3];
  11471. }
  11472. function getStyleText(style) {
  11473. var text = style.text;
  11474. text != null && (text += '');
  11475. return text;
  11476. }
  11477. function needDrawBackground(style) {
  11478. return !!(style.backgroundColor || style.borderWidth && style.borderColor);
  11479. }
  11480. /*
  11481. * Licensed to the Apache Software Foundation (ASF) under one
  11482. * or more contributor license agreements. See the NOTICE file
  11483. * distributed with this work for additional information
  11484. * regarding copyright ownership. The ASF licenses this file
  11485. * to you under the Apache License, Version 2.0 (the
  11486. * "License"); you may not use this file except in compliance
  11487. * with the License. You may obtain a copy of the License at
  11488. *
  11489. * http://www.apache.org/licenses/LICENSE-2.0
  11490. *
  11491. * Unless required by applicable law or agreed to in writing,
  11492. * software distributed under the License is distributed on an
  11493. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  11494. * KIND, either express or implied. See the License for the
  11495. * specific language governing permissions and limitations
  11496. * under the License.
  11497. */
  11498. /**
  11499. * AUTO-GENERATED FILE. DO NOT MODIFY.
  11500. */
  11501. /*
  11502. * Licensed to the Apache Software Foundation (ASF) under one
  11503. * or more contributor license agreements. See the NOTICE file
  11504. * distributed with this work for additional information
  11505. * regarding copyright ownership. The ASF licenses this file
  11506. * to you under the Apache License, Version 2.0 (the
  11507. * "License"); you may not use this file except in compliance
  11508. * with the License. You may obtain a copy of the License at
  11509. *
  11510. * http://www.apache.org/licenses/LICENSE-2.0
  11511. *
  11512. * Unless required by applicable law or agreed to in writing,
  11513. * software distributed under the License is distributed on an
  11514. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  11515. * KIND, either express or implied. See the License for the
  11516. * specific language governing permissions and limitations
  11517. * under the License.
  11518. */
  11519. var getECData = makeInner();
  11520. /*
  11521. * Licensed to the Apache Software Foundation (ASF) under one
  11522. * or more contributor license agreements. See the NOTICE file
  11523. * distributed with this work for additional information
  11524. * regarding copyright ownership. The ASF licenses this file
  11525. * to you under the Apache License, Version 2.0 (the
  11526. * "License"); you may not use this file except in compliance
  11527. * with the License. You may obtain a copy of the License at
  11528. *
  11529. * http://www.apache.org/licenses/LICENSE-2.0
  11530. *
  11531. * Unless required by applicable law or agreed to in writing,
  11532. * software distributed under the License is distributed on an
  11533. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  11534. * KIND, either express or implied. See the License for the
  11535. * specific language governing permissions and limitations
  11536. * under the License.
  11537. */
  11538. /**
  11539. * AUTO-GENERATED FILE. DO NOT MODIFY.
  11540. */
  11541. /*
  11542. * Licensed to the Apache Software Foundation (ASF) under one
  11543. * or more contributor license agreements. See the NOTICE file
  11544. * distributed with this work for additional information
  11545. * regarding copyright ownership. The ASF licenses this file
  11546. * to you under the Apache License, Version 2.0 (the
  11547. * "License"); you may not use this file except in compliance
  11548. * with the License. You may obtain a copy of the License at
  11549. *
  11550. * http://www.apache.org/licenses/LICENSE-2.0
  11551. *
  11552. * Unless required by applicable law or agreed to in writing,
  11553. * software distributed under the License is distributed on an
  11554. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  11555. * KIND, either express or implied. See the License for the
  11556. * specific language governing permissions and limitations
  11557. * under the License.
  11558. */
  11559. var _highlightNextDigit = 1;
  11560. var _highlightKeyMap = {};
  11561. var getSavedStates = makeInner();
  11562. var HOVER_STATE_NORMAL = 0;
  11563. var HOVER_STATE_BLUR = 1;
  11564. var HOVER_STATE_EMPHASIS = 2;
  11565. var SPECIAL_STATES = ['emphasis', 'blur', 'select'];
  11566. var DISPLAY_STATES = ['normal', 'emphasis', 'blur', 'select'];
  11567. var Z2_EMPHASIS_LIFT = 10;
  11568. var Z2_SELECT_LIFT = 9;
  11569. var HIGHLIGHT_ACTION_TYPE = 'highlight';
  11570. var DOWNPLAY_ACTION_TYPE = 'downplay';
  11571. var SELECT_ACTION_TYPE = 'select';
  11572. var UNSELECT_ACTION_TYPE = 'unselect';
  11573. var TOGGLE_SELECT_ACTION_TYPE = 'toggleSelect';
  11574. function hasFillOrStroke(fillOrStroke) {
  11575. return fillOrStroke != null && fillOrStroke !== 'none';
  11576. } // Most lifted color are duplicated.
  11577. var liftedColorCache = new LRU(100);
  11578. function liftColor(color) {
  11579. if (typeof color !== 'string') {
  11580. return color;
  11581. }
  11582. var liftedColor = liftedColorCache.get(color);
  11583. if (!liftedColor) {
  11584. liftedColor = lift(color, -0.1);
  11585. liftedColorCache.put(color, liftedColor);
  11586. }
  11587. return liftedColor;
  11588. }
  11589. function doChangeHoverState(el, stateName, hoverStateEnum) {
  11590. if (el.onHoverStateChange && (el.hoverState || 0) !== hoverStateEnum) {
  11591. el.onHoverStateChange(stateName);
  11592. }
  11593. el.hoverState = hoverStateEnum;
  11594. }
  11595. function singleEnterEmphasis(el) {
  11596. // Only mark the flag.
  11597. // States will be applied in the echarts.ts in next frame.
  11598. doChangeHoverState(el, 'emphasis', HOVER_STATE_EMPHASIS);
  11599. }
  11600. function singleLeaveEmphasis(el) {
  11601. // Only mark the flag.
  11602. // States will be applied in the echarts.ts in next frame.
  11603. if (el.hoverState === HOVER_STATE_EMPHASIS) {
  11604. doChangeHoverState(el, 'normal', HOVER_STATE_NORMAL);
  11605. }
  11606. }
  11607. function singleEnterBlur(el) {
  11608. doChangeHoverState(el, 'blur', HOVER_STATE_BLUR);
  11609. }
  11610. function singleLeaveBlur(el) {
  11611. if (el.hoverState === HOVER_STATE_BLUR) {
  11612. doChangeHoverState(el, 'normal', HOVER_STATE_NORMAL);
  11613. }
  11614. }
  11615. function singleEnterSelect(el) {
  11616. el.selected = true;
  11617. }
  11618. function singleLeaveSelect(el) {
  11619. el.selected = false;
  11620. }
  11621. function updateElementState(el, updater, commonParam) {
  11622. updater(el, commonParam);
  11623. }
  11624. function traverseUpdateState(el, updater, commonParam) {
  11625. updateElementState(el, updater, commonParam);
  11626. el.isGroup && el.traverse(function (child) {
  11627. updateElementState(child, updater, commonParam);
  11628. });
  11629. }
  11630. function setStatesFlag(el, stateName) {
  11631. switch (stateName) {
  11632. case 'emphasis':
  11633. el.hoverState = HOVER_STATE_EMPHASIS;
  11634. break;
  11635. case 'normal':
  11636. el.hoverState = HOVER_STATE_NORMAL;
  11637. break;
  11638. case 'blur':
  11639. el.hoverState = HOVER_STATE_BLUR;
  11640. break;
  11641. case 'select':
  11642. el.selected = true;
  11643. }
  11644. }
  11645. /**
  11646. * If we reuse elements when rerender.
  11647. * DONT forget to clearStates before we update the style and shape.
  11648. * Or we may update on the wrong state instead of normal state.
  11649. */
  11650. function getFromStateStyle(el, props, toStateName, defaultValue) {
  11651. var style = el.style;
  11652. var fromState = {};
  11653. for (var i = 0; i < props.length; i++) {
  11654. var propName = props[i];
  11655. var val = style[propName];
  11656. fromState[propName] = val == null ? defaultValue && defaultValue[propName] : val;
  11657. }
  11658. for (var i = 0; i < el.animators.length; i++) {
  11659. var animator = el.animators[i];
  11660. if (animator.__fromStateTransition // Dont consider the animation to emphasis state.
  11661. && animator.__fromStateTransition.indexOf(toStateName) < 0 && animator.targetName === 'style') {
  11662. animator.saveFinalToTarget(fromState, props);
  11663. }
  11664. }
  11665. return fromState;
  11666. }
  11667. function createEmphasisDefaultState(el, stateName, targetStates, state) {
  11668. var hasSelect = targetStates && indexOf$1(targetStates, 'select') >= 0;
  11669. var cloned = false;
  11670. if (el instanceof Path) {
  11671. var store = getSavedStates(el);
  11672. var fromFill = hasSelect ? store.selectFill || store.normalFill : store.normalFill;
  11673. var fromStroke = hasSelect ? store.selectStroke || store.normalStroke : store.normalStroke;
  11674. if (hasFillOrStroke(fromFill) || hasFillOrStroke(fromStroke)) {
  11675. state = state || {}; // Apply default color lift
  11676. var emphasisStyle = state.style || {};
  11677. if (!hasFillOrStroke(emphasisStyle.fill) && hasFillOrStroke(fromFill)) {
  11678. cloned = true; // Not modify the original value.
  11679. state = extend({}, state);
  11680. emphasisStyle = extend({}, emphasisStyle); // Already being applied 'emphasis'. DON'T lift color multiple times.
  11681. emphasisStyle.fill = liftColor(fromFill);
  11682. } // Not highlight stroke if fill has been highlighted.
  11683. else if (!hasFillOrStroke(emphasisStyle.stroke) && hasFillOrStroke(fromStroke)) {
  11684. if (!cloned) {
  11685. state = extend({}, state);
  11686. emphasisStyle = extend({}, emphasisStyle);
  11687. }
  11688. emphasisStyle.stroke = liftColor(fromStroke);
  11689. }
  11690. state.style = emphasisStyle;
  11691. }
  11692. }
  11693. if (state) {
  11694. // TODO Share with textContent?
  11695. if (state.z2 == null) {
  11696. if (!cloned) {
  11697. state = extend({}, state);
  11698. }
  11699. var z2EmphasisLift = el.z2EmphasisLift;
  11700. state.z2 = el.z2 + (z2EmphasisLift != null ? z2EmphasisLift : Z2_EMPHASIS_LIFT);
  11701. }
  11702. }
  11703. return state;
  11704. }
  11705. function createSelectDefaultState(el, stateName, state) {
  11706. // const hasSelect = indexOf(el.currentStates, stateName) >= 0;
  11707. if (state) {
  11708. // TODO Share with textContent?
  11709. if (state.z2 == null) {
  11710. state = extend({}, state);
  11711. var z2SelectLift = el.z2SelectLift;
  11712. state.z2 = el.z2 + (z2SelectLift != null ? z2SelectLift : Z2_SELECT_LIFT);
  11713. }
  11714. }
  11715. return state;
  11716. }
  11717. function createBlurDefaultState(el, stateName, state) {
  11718. var hasBlur = indexOf$1(el.currentStates, stateName) >= 0;
  11719. var currentOpacity = el.style.opacity;
  11720. var fromState = !hasBlur ? getFromStateStyle(el, ['opacity'], stateName, {
  11721. opacity: 1
  11722. }) : null;
  11723. state = state || {};
  11724. var blurStyle = state.style || {};
  11725. if (blurStyle.opacity == null) {
  11726. // clone state
  11727. state = extend({}, state);
  11728. blurStyle = extend({
  11729. // Already being applied 'emphasis'. DON'T mul opacity multiple times.
  11730. opacity: hasBlur ? currentOpacity : fromState.opacity * 0.1
  11731. }, blurStyle);
  11732. state.style = blurStyle;
  11733. }
  11734. return state;
  11735. }
  11736. function elementStateProxy(stateName, targetStates) {
  11737. var state = this.states[stateName];
  11738. if (this.style) {
  11739. if (stateName === 'emphasis') {
  11740. return createEmphasisDefaultState(this, stateName, targetStates, state);
  11741. } else if (stateName === 'blur') {
  11742. return createBlurDefaultState(this, stateName, state);
  11743. } else if (stateName === 'select') {
  11744. return createSelectDefaultState(this, stateName, state);
  11745. }
  11746. }
  11747. return state;
  11748. }
  11749. /**FI
  11750. * Set hover style (namely "emphasis style") of element.
  11751. * @param el Should not be `zrender/graphic/Group`.
  11752. * @param focus 'self' | 'selfInSeries' | 'series'
  11753. */
  11754. function setDefaultStateProxy(el) {
  11755. el.stateProxy = elementStateProxy;
  11756. var textContent = el.getTextContent();
  11757. var textGuide = el.getTextGuideLine();
  11758. if (textContent) {
  11759. textContent.stateProxy = elementStateProxy;
  11760. }
  11761. if (textGuide) {
  11762. textGuide.stateProxy = elementStateProxy;
  11763. }
  11764. }
  11765. function enterEmphasisWhenMouseOver(el, e) {
  11766. !shouldSilent(el, e) // "emphasis" event highlight has higher priority than mouse highlight.
  11767. && !el.__highByOuter && traverseUpdateState(el, singleEnterEmphasis);
  11768. }
  11769. function leaveEmphasisWhenMouseOut(el, e) {
  11770. !shouldSilent(el, e) // "emphasis" event highlight has higher priority than mouse highlight.
  11771. && !el.__highByOuter && traverseUpdateState(el, singleLeaveEmphasis);
  11772. }
  11773. function enterEmphasis(el, highlightDigit) {
  11774. el.__highByOuter |= 1 << (highlightDigit || 0);
  11775. traverseUpdateState(el, singleEnterEmphasis);
  11776. }
  11777. function leaveEmphasis(el, highlightDigit) {
  11778. !(el.__highByOuter &= ~(1 << (highlightDigit || 0))) && traverseUpdateState(el, singleLeaveEmphasis);
  11779. }
  11780. function enterBlur(el) {
  11781. traverseUpdateState(el, singleEnterBlur);
  11782. }
  11783. function leaveBlur(el) {
  11784. traverseUpdateState(el, singleLeaveBlur);
  11785. }
  11786. function enterSelect(el) {
  11787. traverseUpdateState(el, singleEnterSelect);
  11788. }
  11789. function leaveSelect(el) {
  11790. traverseUpdateState(el, singleLeaveSelect);
  11791. }
  11792. function shouldSilent(el, e) {
  11793. return el.__highDownSilentOnTouch && e.zrByTouch;
  11794. }
  11795. function allLeaveBlur(api) {
  11796. var model = api.getModel();
  11797. model.eachComponent(function (componentType, componentModel) {
  11798. var view = componentType === 'series' ? api.getViewOfSeriesModel(componentModel) : api.getViewOfComponentModel(componentModel); // Leave blur anyway
  11799. view.group.traverse(function (child) {
  11800. singleLeaveBlur(child);
  11801. });
  11802. });
  11803. }
  11804. function blurSeries(targetSeriesIndex, focus, blurScope, api) {
  11805. var ecModel = api.getModel();
  11806. blurScope = blurScope || 'coordinateSystem';
  11807. function leaveBlurOfIndices(data, dataIndices) {
  11808. for (var i = 0; i < dataIndices.length; i++) {
  11809. var itemEl = data.getItemGraphicEl(dataIndices[i]);
  11810. itemEl && leaveBlur(itemEl);
  11811. }
  11812. }
  11813. if (targetSeriesIndex == null) {
  11814. return;
  11815. }
  11816. if (!focus || focus === 'none') {
  11817. return;
  11818. }
  11819. var targetSeriesModel = ecModel.getSeriesByIndex(targetSeriesIndex);
  11820. var targetCoordSys = targetSeriesModel.coordinateSystem;
  11821. if (targetCoordSys && targetCoordSys.master) {
  11822. targetCoordSys = targetCoordSys.master;
  11823. }
  11824. var blurredSeries = [];
  11825. ecModel.eachSeries(function (seriesModel) {
  11826. var sameSeries = targetSeriesModel === seriesModel;
  11827. var coordSys = seriesModel.coordinateSystem;
  11828. if (coordSys && coordSys.master) {
  11829. coordSys = coordSys.master;
  11830. }
  11831. var sameCoordSys = coordSys && targetCoordSys ? coordSys === targetCoordSys : sameSeries; // If there is no coordinate system. use sameSeries instead.
  11832. if (!( // Not blur other series if blurScope series
  11833. blurScope === 'series' && !sameSeries // Not blur other coordinate system if blurScope is coordinateSystem
  11834. || blurScope === 'coordinateSystem' && !sameCoordSys // Not blur self series if focus is series.
  11835. || focus === 'series' && sameSeries // TODO blurScope: coordinate system
  11836. )) {
  11837. var view = api.getViewOfSeriesModel(seriesModel);
  11838. view.group.traverse(function (child) {
  11839. singleEnterBlur(child);
  11840. });
  11841. if (isArrayLike(focus)) {
  11842. leaveBlurOfIndices(seriesModel.getData(), focus);
  11843. } else if (isObject$1(focus)) {
  11844. var dataTypes = keys(focus);
  11845. for (var d = 0; d < dataTypes.length; d++) {
  11846. leaveBlurOfIndices(seriesModel.getData(dataTypes[d]), focus[dataTypes[d]]);
  11847. }
  11848. }
  11849. blurredSeries.push(seriesModel);
  11850. }
  11851. });
  11852. ecModel.eachComponent(function (componentType, componentModel) {
  11853. if (componentType === 'series') {
  11854. return;
  11855. }
  11856. var view = api.getViewOfComponentModel(componentModel);
  11857. if (view && view.blurSeries) {
  11858. view.blurSeries(blurredSeries, ecModel);
  11859. }
  11860. });
  11861. }
  11862. function blurComponent(componentMainType, componentIndex, api) {
  11863. if (componentMainType == null || componentIndex == null) {
  11864. return;
  11865. }
  11866. var componentModel = api.getModel().getComponent(componentMainType, componentIndex);
  11867. if (!componentModel) {
  11868. return;
  11869. }
  11870. var view = api.getViewOfComponentModel(componentModel);
  11871. if (!view || !view.focusBlurEnabled) {
  11872. return;
  11873. }
  11874. view.group.traverse(function (child) {
  11875. singleEnterBlur(child);
  11876. });
  11877. }
  11878. function blurSeriesFromHighlightPayload(seriesModel, payload, api) {
  11879. var seriesIndex = seriesModel.seriesIndex;
  11880. var data = seriesModel.getData(payload.dataType);
  11881. var dataIndex = queryDataIndex(data, payload); // Pick the first one if there is multiple/none exists.
  11882. dataIndex = (isArray(dataIndex) ? dataIndex[0] : dataIndex) || 0;
  11883. var el = data.getItemGraphicEl(dataIndex);
  11884. if (!el) {
  11885. var count = data.count();
  11886. var current = 0; // If data on dataIndex is NaN.
  11887. while (!el && current < count) {
  11888. el = data.getItemGraphicEl(current++);
  11889. }
  11890. }
  11891. if (el) {
  11892. var ecData = getECData(el);
  11893. blurSeries(seriesIndex, ecData.focus, ecData.blurScope, api);
  11894. } else {
  11895. // If there is no element put on the data. Try getting it from raw option
  11896. // TODO Should put it on seriesModel?
  11897. var focus_1 = seriesModel.get(['emphasis', 'focus']);
  11898. var blurScope = seriesModel.get(['emphasis', 'blurScope']);
  11899. if (focus_1 != null) {
  11900. blurSeries(seriesIndex, focus_1, blurScope, api);
  11901. }
  11902. }
  11903. }
  11904. function findComponentHighDownDispatchers(componentMainType, componentIndex, name, api) {
  11905. var ret = {
  11906. focusSelf: false,
  11907. dispatchers: null
  11908. };
  11909. if (componentMainType == null || componentMainType === 'series' || componentIndex == null || name == null) {
  11910. return ret;
  11911. }
  11912. var componentModel = api.getModel().getComponent(componentMainType, componentIndex);
  11913. if (!componentModel) {
  11914. return ret;
  11915. }
  11916. var view = api.getViewOfComponentModel(componentModel);
  11917. if (!view || !view.findHighDownDispatchers) {
  11918. return ret;
  11919. }
  11920. var dispatchers = view.findHighDownDispatchers(name); // At presnet, the component (like Geo) only blur inside itself.
  11921. // So we do not use `blurScope` in component.
  11922. var focusSelf;
  11923. for (var i = 0; i < dispatchers.length; i++) {
  11924. if ("development" !== 'production' && !isHighDownDispatcher(dispatchers[i])) {
  11925. error('param should be highDownDispatcher');
  11926. }
  11927. if (getECData(dispatchers[i]).focus === 'self') {
  11928. focusSelf = true;
  11929. break;
  11930. }
  11931. }
  11932. return {
  11933. focusSelf: focusSelf,
  11934. dispatchers: dispatchers
  11935. };
  11936. }
  11937. function handleGlobalMouseOverForHighDown(dispatcher, e, api) {
  11938. if ("development" !== 'production' && !isHighDownDispatcher(dispatcher)) {
  11939. error('param should be highDownDispatcher');
  11940. }
  11941. var ecData = getECData(dispatcher);
  11942. var _a = findComponentHighDownDispatchers(ecData.componentMainType, ecData.componentIndex, ecData.componentHighDownName, api),
  11943. dispatchers = _a.dispatchers,
  11944. focusSelf = _a.focusSelf; // If `findHighDownDispatchers` is supported on the component,
  11945. // highlight/downplay elements with the same name.
  11946. if (dispatchers) {
  11947. if (focusSelf) {
  11948. blurComponent(ecData.componentMainType, ecData.componentIndex, api);
  11949. }
  11950. each$1(dispatchers, function (dispatcher) {
  11951. return enterEmphasisWhenMouseOver(dispatcher, e);
  11952. });
  11953. } else {
  11954. // Try blur all in the related series. Then emphasis the hoverred.
  11955. // TODO. progressive mode.
  11956. blurSeries(ecData.seriesIndex, ecData.focus, ecData.blurScope, api);
  11957. if (ecData.focus === 'self') {
  11958. blurComponent(ecData.componentMainType, ecData.componentIndex, api);
  11959. } // Other than series, component that not support `findHighDownDispatcher` will
  11960. // also use it. But in this case, highlight/downplay are only supported in
  11961. // mouse hover but not in dispatchAction.
  11962. enterEmphasisWhenMouseOver(dispatcher, e);
  11963. }
  11964. }
  11965. function handleGlboalMouseOutForHighDown(dispatcher, e, api) {
  11966. if ("development" !== 'production' && !isHighDownDispatcher(dispatcher)) {
  11967. error('param should be highDownDispatcher');
  11968. }
  11969. allLeaveBlur(api);
  11970. var ecData = getECData(dispatcher);
  11971. var dispatchers = findComponentHighDownDispatchers(ecData.componentMainType, ecData.componentIndex, ecData.componentHighDownName, api).dispatchers;
  11972. if (dispatchers) {
  11973. each$1(dispatchers, function (dispatcher) {
  11974. return leaveEmphasisWhenMouseOut(dispatcher, e);
  11975. });
  11976. } else {
  11977. leaveEmphasisWhenMouseOut(dispatcher, e);
  11978. }
  11979. }
  11980. function toggleSelectionFromPayload(seriesModel, payload, api) {
  11981. if (!isSelectChangePayload(payload)) {
  11982. return;
  11983. }
  11984. var dataType = payload.dataType;
  11985. var data = seriesModel.getData(dataType);
  11986. var dataIndex = queryDataIndex(data, payload);
  11987. if (!isArray(dataIndex)) {
  11988. dataIndex = [dataIndex];
  11989. }
  11990. seriesModel[payload.type === TOGGLE_SELECT_ACTION_TYPE ? 'toggleSelect' : payload.type === SELECT_ACTION_TYPE ? 'select' : 'unselect'](dataIndex, dataType);
  11991. }
  11992. function updateSeriesElementSelection(seriesModel) {
  11993. var allData = seriesModel.getAllData();
  11994. each$1(allData, function (_a) {
  11995. var data = _a.data,
  11996. type = _a.type;
  11997. data.eachItemGraphicEl(function (el, idx) {
  11998. seriesModel.isSelected(idx, type) ? enterSelect(el) : leaveSelect(el);
  11999. });
  12000. });
  12001. }
  12002. function getAllSelectedIndices(ecModel) {
  12003. var ret = [];
  12004. ecModel.eachSeries(function (seriesModel) {
  12005. var allData = seriesModel.getAllData();
  12006. each$1(allData, function (_a) {
  12007. var data = _a.data,
  12008. type = _a.type;
  12009. var dataIndices = seriesModel.getSelectedDataIndices();
  12010. if (dataIndices.length > 0) {
  12011. var item = {
  12012. dataIndex: dataIndices,
  12013. seriesIndex: seriesModel.seriesIndex
  12014. };
  12015. if (type != null) {
  12016. item.dataType = type;
  12017. }
  12018. ret.push(item);
  12019. }
  12020. });
  12021. });
  12022. return ret;
  12023. }
  12024. /**
  12025. * Enable the function that mouseover will trigger the emphasis state.
  12026. *
  12027. * NOTE:
  12028. * This function should be used on the element with dataIndex, seriesIndex.
  12029. *
  12030. */
  12031. function enableHoverEmphasis(el, focus, blurScope) {
  12032. setAsHighDownDispatcher(el, true);
  12033. traverseUpdateState(el, setDefaultStateProxy);
  12034. enableHoverFocus(el, focus, blurScope);
  12035. }
  12036. function enableHoverFocus(el, focus, blurScope) {
  12037. var ecData = getECData(el);
  12038. if (focus != null) {
  12039. // TODO dataIndex may be set after this function. This check is not useful.
  12040. // if (ecData.dataIndex == null) {
  12041. // if (__DEV__) {
  12042. // console.warn('focus can only been set on element with dataIndex');
  12043. // }
  12044. // }
  12045. // else {
  12046. ecData.focus = focus;
  12047. ecData.blurScope = blurScope; // }
  12048. } else if (ecData.focus) {
  12049. ecData.focus = null;
  12050. }
  12051. }
  12052. var OTHER_STATES = ['emphasis', 'blur', 'select'];
  12053. var defaultStyleGetterMap = {
  12054. itemStyle: 'getItemStyle',
  12055. lineStyle: 'getLineStyle',
  12056. areaStyle: 'getAreaStyle'
  12057. };
  12058. /**
  12059. * Set emphasis/blur/selected states of element.
  12060. */
  12061. function setStatesStylesFromModel(el, itemModel, styleType, // default itemStyle
  12062. getter) {
  12063. styleType = styleType || 'itemStyle';
  12064. for (var i = 0; i < OTHER_STATES.length; i++) {
  12065. var stateName = OTHER_STATES[i];
  12066. var model = itemModel.getModel([stateName, styleType]);
  12067. var state = el.ensureState(stateName); // Let it throw error if getterType is not found.
  12068. state.style = getter ? getter(model) : model[defaultStyleGetterMap[styleType]]();
  12069. }
  12070. }
  12071. /**
  12072. * @parame el
  12073. * @param el.highDownSilentOnTouch
  12074. * In touch device, mouseover event will be trigger on touchstart event
  12075. * (see module:zrender/dom/HandlerProxy). By this mechanism, we can
  12076. * conveniently use hoverStyle when tap on touch screen without additional
  12077. * code for compatibility.
  12078. * But if the chart/component has select feature, which usually also use
  12079. * hoverStyle, there might be conflict between 'select-highlight' and
  12080. * 'hover-highlight' especially when roam is enabled (see geo for example).
  12081. * In this case, `highDownSilentOnTouch` should be used to disable
  12082. * hover-highlight on touch device.
  12083. * @param asDispatcher If `false`, do not set as "highDownDispatcher".
  12084. */
  12085. function setAsHighDownDispatcher(el, asDispatcher) {
  12086. var disable = asDispatcher === false;
  12087. var extendedEl = el; // Make `highDownSilentOnTouch` and `onStateChange` only work after
  12088. // `setAsHighDownDispatcher` called. Avoid it is modified by user unexpectedly.
  12089. if (el.highDownSilentOnTouch) {
  12090. extendedEl.__highDownSilentOnTouch = el.highDownSilentOnTouch;
  12091. } // Simple optimize, since this method might be
  12092. // called for each elements of a group in some cases.
  12093. if (!disable || extendedEl.__highDownDispatcher) {
  12094. // Emphasis, normal can be triggered manually by API or other components like hover link.
  12095. // el[method]('emphasis', onElementEmphasisEvent)[method]('normal', onElementNormalEvent);
  12096. // Also keep previous record.
  12097. extendedEl.__highByOuter = extendedEl.__highByOuter || 0;
  12098. extendedEl.__highDownDispatcher = !disable;
  12099. }
  12100. }
  12101. function isHighDownDispatcher(el) {
  12102. return !!(el && el.__highDownDispatcher);
  12103. }
  12104. /**
  12105. * Enable component highlight/downplay features:
  12106. * + hover link (within the same name)
  12107. * + focus blur in component
  12108. */
  12109. function enableComponentHighDownFeatures(el, componentModel, componentHighDownName) {
  12110. var ecData = getECData(el);
  12111. ecData.componentMainType = componentModel.mainType;
  12112. ecData.componentIndex = componentModel.componentIndex;
  12113. ecData.componentHighDownName = componentHighDownName;
  12114. }
  12115. /**
  12116. * Support hightlight/downplay record on each elements.
  12117. * For the case: hover highlight/downplay (legend, visualMap, ...) and
  12118. * user triggerred hightlight/downplay should not conflict.
  12119. * Only all of the highlightDigit cleared, return to normal.
  12120. * @param {string} highlightKey
  12121. * @return {number} highlightDigit
  12122. */
  12123. function getHighlightDigit(highlightKey) {
  12124. var highlightDigit = _highlightKeyMap[highlightKey];
  12125. if (highlightDigit == null && _highlightNextDigit <= 32) {
  12126. highlightDigit = _highlightKeyMap[highlightKey] = _highlightNextDigit++;
  12127. }
  12128. return highlightDigit;
  12129. }
  12130. function isSelectChangePayload(payload) {
  12131. var payloadType = payload.type;
  12132. return payloadType === SELECT_ACTION_TYPE || payloadType === UNSELECT_ACTION_TYPE || payloadType === TOGGLE_SELECT_ACTION_TYPE;
  12133. }
  12134. function isHighDownPayload(payload) {
  12135. var payloadType = payload.type;
  12136. return payloadType === HIGHLIGHT_ACTION_TYPE || payloadType === DOWNPLAY_ACTION_TYPE;
  12137. }
  12138. function savePathStates(el) {
  12139. var store = getSavedStates(el);
  12140. store.normalFill = el.style.fill;
  12141. store.normalStroke = el.style.stroke;
  12142. var selectState = el.states.select || {};
  12143. store.selectFill = selectState.style && selectState.style.fill || null;
  12144. store.selectStroke = selectState.style && selectState.style.stroke || null;
  12145. }
  12146. var CMD$2 = PathProxy.CMD;
  12147. var points = [[], [], []];
  12148. var mathSqrt$3 = Math.sqrt;
  12149. var mathAtan2 = Math.atan2;
  12150. function transformPath(path, m) {
  12151. var data = path.data;
  12152. var len$$1 = path.len();
  12153. var cmd;
  12154. var nPoint;
  12155. var i;
  12156. var j;
  12157. var k;
  12158. var p;
  12159. var M = CMD$2.M;
  12160. var C = CMD$2.C;
  12161. var L = CMD$2.L;
  12162. var R = CMD$2.R;
  12163. var A = CMD$2.A;
  12164. var Q = CMD$2.Q;
  12165. for (i = 0, j = 0; i < len$$1;) {
  12166. cmd = data[i++];
  12167. j = i;
  12168. nPoint = 0;
  12169. switch (cmd) {
  12170. case M:
  12171. nPoint = 1;
  12172. break;
  12173. case L:
  12174. nPoint = 1;
  12175. break;
  12176. case C:
  12177. nPoint = 3;
  12178. break;
  12179. case Q:
  12180. nPoint = 2;
  12181. break;
  12182. case A:
  12183. var x = m[4];
  12184. var y = m[5];
  12185. var sx = mathSqrt$3(m[0] * m[0] + m[1] * m[1]);
  12186. var sy = mathSqrt$3(m[2] * m[2] + m[3] * m[3]);
  12187. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  12188. data[i] *= sx;
  12189. data[i++] += x;
  12190. data[i] *= sy;
  12191. data[i++] += y;
  12192. data[i++] *= sx;
  12193. data[i++] *= sy;
  12194. data[i++] += angle;
  12195. data[i++] += angle;
  12196. i += 2;
  12197. j = i;
  12198. break;
  12199. case R:
  12200. p[0] = data[i++];
  12201. p[1] = data[i++];
  12202. applyTransform(p, p, m);
  12203. data[j++] = p[0];
  12204. data[j++] = p[1];
  12205. p[0] += data[i++];
  12206. p[1] += data[i++];
  12207. applyTransform(p, p, m);
  12208. data[j++] = p[0];
  12209. data[j++] = p[1];
  12210. }
  12211. for (k = 0; k < nPoint; k++) {
  12212. var p_1 = points[k];
  12213. p_1[0] = data[i++];
  12214. p_1[1] = data[i++];
  12215. applyTransform(p_1, p_1, m);
  12216. data[j++] = p_1[0];
  12217. data[j++] = p_1[1];
  12218. }
  12219. }
  12220. path.increaseVersion();
  12221. }
  12222. var mathSqrt$2 = Math.sqrt;
  12223. var mathSin$2 = Math.sin;
  12224. var mathCos$2 = Math.cos;
  12225. var PI$1 = Math.PI;
  12226. function vMag(v) {
  12227. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  12228. }
  12229. function vRatio(u, v) {
  12230. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  12231. }
  12232. function vAngle(u, v) {
  12233. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
  12234. }
  12235. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  12236. var psi = psiDeg * (PI$1 / 180.0);
  12237. var xp = mathCos$2(psi) * (x1 - x2) / 2.0 + mathSin$2(psi) * (y1 - y2) / 2.0;
  12238. var yp = -1 * mathSin$2(psi) * (x1 - x2) / 2.0 + mathCos$2(psi) * (y1 - y2) / 2.0;
  12239. var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
  12240. if (lambda > 1) {
  12241. rx *= mathSqrt$2(lambda);
  12242. ry *= mathSqrt$2(lambda);
  12243. }
  12244. var f = (fa === fs ? -1 : 1) * mathSqrt$2((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) / (rx * rx * (yp * yp) + ry * ry * (xp * xp))) || 0;
  12245. var cxp = f * rx * yp / ry;
  12246. var cyp = f * -ry * xp / rx;
  12247. var cx = (x1 + x2) / 2.0 + mathCos$2(psi) * cxp - mathSin$2(psi) * cyp;
  12248. var cy = (y1 + y2) / 2.0 + mathSin$2(psi) * cxp + mathCos$2(psi) * cyp;
  12249. var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
  12250. var u = [(xp - cxp) / rx, (yp - cyp) / ry];
  12251. var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
  12252. var dTheta = vAngle(u, v);
  12253. if (vRatio(u, v) <= -1) {
  12254. dTheta = PI$1;
  12255. }
  12256. if (vRatio(u, v) >= 1) {
  12257. dTheta = 0;
  12258. }
  12259. if (dTheta < 0) {
  12260. var n = Math.round(dTheta / PI$1 * 1e6) / 1e6;
  12261. dTheta = PI$1 * 2 + n % 2 * PI$1;
  12262. }
  12263. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  12264. }
  12265. var commandReg = /([mlvhzcqtsa])([^mlvhzcqtsa]*)/ig;
  12266. var numberReg = /-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;
  12267. function createPathProxyFromString(data) {
  12268. var path = new PathProxy();
  12269. if (!data) {
  12270. return path;
  12271. }
  12272. var cpx = 0;
  12273. var cpy = 0;
  12274. var subpathX = cpx;
  12275. var subpathY = cpy;
  12276. var prevCmd;
  12277. var CMD = PathProxy.CMD;
  12278. var cmdList = data.match(commandReg);
  12279. if (!cmdList) {
  12280. return path;
  12281. }
  12282. for (var l = 0; l < cmdList.length; l++) {
  12283. var cmdText = cmdList[l];
  12284. var cmdStr = cmdText.charAt(0);
  12285. var cmd = void 0;
  12286. var p = cmdText.match(numberReg) || [];
  12287. var pLen = p.length;
  12288. for (var i = 0; i < pLen; i++) {
  12289. p[i] = parseFloat(p[i]);
  12290. }
  12291. var off = 0;
  12292. while (off < pLen) {
  12293. var ctlPtx = void 0;
  12294. var ctlPty = void 0;
  12295. var rx = void 0;
  12296. var ry = void 0;
  12297. var psi = void 0;
  12298. var fa = void 0;
  12299. var fs = void 0;
  12300. var x1 = cpx;
  12301. var y1 = cpy;
  12302. var len = void 0;
  12303. var pathData = void 0;
  12304. switch (cmdStr) {
  12305. case 'l':
  12306. cpx += p[off++];
  12307. cpy += p[off++];
  12308. cmd = CMD.L;
  12309. path.addData(cmd, cpx, cpy);
  12310. break;
  12311. case 'L':
  12312. cpx = p[off++];
  12313. cpy = p[off++];
  12314. cmd = CMD.L;
  12315. path.addData(cmd, cpx, cpy);
  12316. break;
  12317. case 'm':
  12318. cpx += p[off++];
  12319. cpy += p[off++];
  12320. cmd = CMD.M;
  12321. path.addData(cmd, cpx, cpy);
  12322. subpathX = cpx;
  12323. subpathY = cpy;
  12324. cmdStr = 'l';
  12325. break;
  12326. case 'M':
  12327. cpx = p[off++];
  12328. cpy = p[off++];
  12329. cmd = CMD.M;
  12330. path.addData(cmd, cpx, cpy);
  12331. subpathX = cpx;
  12332. subpathY = cpy;
  12333. cmdStr = 'L';
  12334. break;
  12335. case 'h':
  12336. cpx += p[off++];
  12337. cmd = CMD.L;
  12338. path.addData(cmd, cpx, cpy);
  12339. break;
  12340. case 'H':
  12341. cpx = p[off++];
  12342. cmd = CMD.L;
  12343. path.addData(cmd, cpx, cpy);
  12344. break;
  12345. case 'v':
  12346. cpy += p[off++];
  12347. cmd = CMD.L;
  12348. path.addData(cmd, cpx, cpy);
  12349. break;
  12350. case 'V':
  12351. cpy = p[off++];
  12352. cmd = CMD.L;
  12353. path.addData(cmd, cpx, cpy);
  12354. break;
  12355. case 'C':
  12356. cmd = CMD.C;
  12357. path.addData(cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]);
  12358. cpx = p[off - 2];
  12359. cpy = p[off - 1];
  12360. break;
  12361. case 'c':
  12362. cmd = CMD.C;
  12363. path.addData(cmd, p[off++] + cpx, p[off++] + cpy, p[off++] + cpx, p[off++] + cpy, p[off++] + cpx, p[off++] + cpy);
  12364. cpx += p[off - 2];
  12365. cpy += p[off - 1];
  12366. break;
  12367. case 'S':
  12368. ctlPtx = cpx;
  12369. ctlPty = cpy;
  12370. len = path.len();
  12371. pathData = path.data;
  12372. if (prevCmd === CMD.C) {
  12373. ctlPtx += cpx - pathData[len - 4];
  12374. ctlPty += cpy - pathData[len - 3];
  12375. }
  12376. cmd = CMD.C;
  12377. x1 = p[off++];
  12378. y1 = p[off++];
  12379. cpx = p[off++];
  12380. cpy = p[off++];
  12381. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  12382. break;
  12383. case 's':
  12384. ctlPtx = cpx;
  12385. ctlPty = cpy;
  12386. len = path.len();
  12387. pathData = path.data;
  12388. if (prevCmd === CMD.C) {
  12389. ctlPtx += cpx - pathData[len - 4];
  12390. ctlPty += cpy - pathData[len - 3];
  12391. }
  12392. cmd = CMD.C;
  12393. x1 = cpx + p[off++];
  12394. y1 = cpy + p[off++];
  12395. cpx += p[off++];
  12396. cpy += p[off++];
  12397. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  12398. break;
  12399. case 'Q':
  12400. x1 = p[off++];
  12401. y1 = p[off++];
  12402. cpx = p[off++];
  12403. cpy = p[off++];
  12404. cmd = CMD.Q;
  12405. path.addData(cmd, x1, y1, cpx, cpy);
  12406. break;
  12407. case 'q':
  12408. x1 = p[off++] + cpx;
  12409. y1 = p[off++] + cpy;
  12410. cpx += p[off++];
  12411. cpy += p[off++];
  12412. cmd = CMD.Q;
  12413. path.addData(cmd, x1, y1, cpx, cpy);
  12414. break;
  12415. case 'T':
  12416. ctlPtx = cpx;
  12417. ctlPty = cpy;
  12418. len = path.len();
  12419. pathData = path.data;
  12420. if (prevCmd === CMD.Q) {
  12421. ctlPtx += cpx - pathData[len - 4];
  12422. ctlPty += cpy - pathData[len - 3];
  12423. }
  12424. cpx = p[off++];
  12425. cpy = p[off++];
  12426. cmd = CMD.Q;
  12427. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  12428. break;
  12429. case 't':
  12430. ctlPtx = cpx;
  12431. ctlPty = cpy;
  12432. len = path.len();
  12433. pathData = path.data;
  12434. if (prevCmd === CMD.Q) {
  12435. ctlPtx += cpx - pathData[len - 4];
  12436. ctlPty += cpy - pathData[len - 3];
  12437. }
  12438. cpx += p[off++];
  12439. cpy += p[off++];
  12440. cmd = CMD.Q;
  12441. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  12442. break;
  12443. case 'A':
  12444. rx = p[off++];
  12445. ry = p[off++];
  12446. psi = p[off++];
  12447. fa = p[off++];
  12448. fs = p[off++];
  12449. x1 = cpx, y1 = cpy;
  12450. cpx = p[off++];
  12451. cpy = p[off++];
  12452. cmd = CMD.A;
  12453. processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path);
  12454. break;
  12455. case 'a':
  12456. rx = p[off++];
  12457. ry = p[off++];
  12458. psi = p[off++];
  12459. fa = p[off++];
  12460. fs = p[off++];
  12461. x1 = cpx, y1 = cpy;
  12462. cpx += p[off++];
  12463. cpy += p[off++];
  12464. cmd = CMD.A;
  12465. processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path);
  12466. break;
  12467. }
  12468. }
  12469. if (cmdStr === 'z' || cmdStr === 'Z') {
  12470. cmd = CMD.Z;
  12471. path.addData(cmd);
  12472. cpx = subpathX;
  12473. cpy = subpathY;
  12474. }
  12475. prevCmd = cmd;
  12476. }
  12477. path.toStatic();
  12478. return path;
  12479. }
  12480. var SVGPath = function (_super) {
  12481. __extends(SVGPath, _super);
  12482. function SVGPath() {
  12483. return _super !== null && _super.apply(this, arguments) || this;
  12484. }
  12485. SVGPath.prototype.applyTransform = function (m) {};
  12486. return SVGPath;
  12487. }(Path);
  12488. function isPathProxy(path) {
  12489. return path.setData != null;
  12490. }
  12491. function createPathOptions(str, opts) {
  12492. var pathProxy = createPathProxyFromString(str);
  12493. var innerOpts = extend({}, opts);
  12494. innerOpts.buildPath = function (path) {
  12495. if (isPathProxy(path)) {
  12496. path.setData(pathProxy.data);
  12497. var ctx = path.getContext();
  12498. if (ctx) {
  12499. path.rebuildPath(ctx, 1);
  12500. }
  12501. } else {
  12502. var ctx = path;
  12503. pathProxy.rebuildPath(ctx, 1);
  12504. }
  12505. };
  12506. innerOpts.applyTransform = function (m) {
  12507. transformPath(pathProxy, m);
  12508. this.dirtyShape();
  12509. };
  12510. return innerOpts;
  12511. }
  12512. function createFromString(str, opts) {
  12513. return new SVGPath(createPathOptions(str, opts));
  12514. }
  12515. function extendFromString(str, defaultOpts) {
  12516. var innerOpts = createPathOptions(str, defaultOpts);
  12517. var Sub = function (_super) {
  12518. __extends(Sub, _super);
  12519. function Sub(opts) {
  12520. var _this = _super.call(this, opts) || this;
  12521. _this.applyTransform = innerOpts.applyTransform;
  12522. _this.buildPath = innerOpts.buildPath;
  12523. return _this;
  12524. }
  12525. return Sub;
  12526. }(SVGPath);
  12527. return Sub;
  12528. }
  12529. function mergePath$1(pathEls, opts) {
  12530. var pathList = [];
  12531. var len = pathEls.length;
  12532. for (var i = 0; i < len; i++) {
  12533. var pathEl = pathEls[i];
  12534. if (!pathEl.path) {
  12535. pathEl.createPathProxy();
  12536. }
  12537. if (pathEl.shapeChanged()) {
  12538. pathEl.buildPath(pathEl.path, pathEl.shape, true);
  12539. }
  12540. pathList.push(pathEl.path);
  12541. }
  12542. var pathBundle = new Path(opts);
  12543. pathBundle.createPathProxy();
  12544. pathBundle.buildPath = function (path) {
  12545. if (isPathProxy(path)) {
  12546. path.appendPath(pathList);
  12547. var ctx = path.getContext();
  12548. if (ctx) {
  12549. path.rebuildPath(ctx, 1);
  12550. }
  12551. }
  12552. };
  12553. return pathBundle;
  12554. }
  12555. var CircleShape = function () {
  12556. function CircleShape() {
  12557. this.cx = 0;
  12558. this.cy = 0;
  12559. this.r = 0;
  12560. }
  12561. return CircleShape;
  12562. }();
  12563. var Circle = function (_super) {
  12564. __extends(Circle, _super);
  12565. function Circle(opts) {
  12566. return _super.call(this, opts) || this;
  12567. }
  12568. Circle.prototype.getDefaultShape = function () {
  12569. return new CircleShape();
  12570. };
  12571. Circle.prototype.buildPath = function (ctx, shape, inBundle) {
  12572. if (inBundle) {
  12573. ctx.moveTo(shape.cx + shape.r, shape.cy);
  12574. }
  12575. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2);
  12576. };
  12577. return Circle;
  12578. }(Path);
  12579. Circle.prototype.type = 'circle';
  12580. var EllipseShape = function () {
  12581. function EllipseShape() {
  12582. this.cx = 0;
  12583. this.cy = 0;
  12584. this.rx = 0;
  12585. this.ry = 0;
  12586. }
  12587. return EllipseShape;
  12588. }();
  12589. var Ellipse = function (_super) {
  12590. __extends(Ellipse, _super);
  12591. function Ellipse(opts) {
  12592. return _super.call(this, opts) || this;
  12593. }
  12594. Ellipse.prototype.getDefaultShape = function () {
  12595. return new EllipseShape();
  12596. };
  12597. Ellipse.prototype.buildPath = function (ctx, shape) {
  12598. var k = 0.5522848;
  12599. var x = shape.cx;
  12600. var y = shape.cy;
  12601. var a = shape.rx;
  12602. var b = shape.ry;
  12603. var ox = a * k;
  12604. var oy = b * k;
  12605. ctx.moveTo(x - a, y);
  12606. ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
  12607. ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
  12608. ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b);
  12609. ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y);
  12610. ctx.closePath();
  12611. };
  12612. return Ellipse;
  12613. }(Path);
  12614. Ellipse.prototype.type = 'ellipse';
  12615. var PI$2 = Math.PI;
  12616. var PI2$5 = PI$2 * 2;
  12617. var mathSin$3 = Math.sin;
  12618. var mathCos$3 = Math.cos;
  12619. var mathACos = Math.acos;
  12620. var mathATan2 = Math.atan2;
  12621. var mathAbs$1 = Math.abs;
  12622. var mathSqrt$4 = Math.sqrt;
  12623. var mathMax$4 = Math.max;
  12624. var mathMin$4 = Math.min;
  12625. var e = 1e-4;
  12626. function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
  12627. var x10 = x1 - x0;
  12628. var y10 = y1 - y0;
  12629. var x32 = x3 - x2;
  12630. var y32 = y3 - y2;
  12631. var t = y32 * x10 - x32 * y10;
  12632. if (t * t < e) {
  12633. return;
  12634. }
  12635. t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / t;
  12636. return [x0 + t * x10, y0 + t * y10];
  12637. }
  12638. function computeCornerTangents(x0, y0, x1, y1, radius, cr, clockwise) {
  12639. var x01 = x0 - x1;
  12640. var y01 = y0 - y1;
  12641. var lo = (clockwise ? cr : -cr) / mathSqrt$4(x01 * x01 + y01 * y01);
  12642. var ox = lo * y01;
  12643. var oy = -lo * x01;
  12644. var x11 = x0 + ox;
  12645. var y11 = y0 + oy;
  12646. var x10 = x1 + ox;
  12647. var y10 = y1 + oy;
  12648. var x00 = (x11 + x10) / 2;
  12649. var y00 = (y11 + y10) / 2;
  12650. var dx = x10 - x11;
  12651. var dy = y10 - y11;
  12652. var d2 = dx * dx + dy * dy;
  12653. var r = radius - cr;
  12654. var s = x11 * y10 - x10 * y11;
  12655. var d = (dy < 0 ? -1 : 1) * mathSqrt$4(mathMax$4(0, r * r * d2 - s * s));
  12656. var cx0 = (s * dy - dx * d) / d2;
  12657. var cy0 = (-s * dx - dy * d) / d2;
  12658. var cx1 = (s * dy + dx * d) / d2;
  12659. var cy1 = (-s * dx + dy * d) / d2;
  12660. var dx0 = cx0 - x00;
  12661. var dy0 = cy0 - y00;
  12662. var dx1 = cx1 - x00;
  12663. var dy1 = cy1 - y00;
  12664. if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) {
  12665. cx0 = cx1;
  12666. cy0 = cy1;
  12667. }
  12668. return {
  12669. cx: cx0,
  12670. cy: cy0,
  12671. x01: -ox,
  12672. y01: -oy,
  12673. x11: cx0 * (radius / r - 1),
  12674. y11: cy0 * (radius / r - 1)
  12675. };
  12676. }
  12677. function buildPath$1(ctx, shape) {
  12678. var radius = mathMax$4(shape.r, 0);
  12679. var innerRadius = mathMax$4(shape.r0 || 0, 0);
  12680. var hasRadius = radius > 0;
  12681. var hasInnerRadius = innerRadius > 0;
  12682. if (!hasRadius && !hasInnerRadius) {
  12683. return;
  12684. }
  12685. if (!hasRadius) {
  12686. radius = innerRadius;
  12687. innerRadius = 0;
  12688. }
  12689. if (innerRadius > radius) {
  12690. var tmp = radius;
  12691. radius = innerRadius;
  12692. innerRadius = tmp;
  12693. }
  12694. var clockwise = !!shape.clockwise;
  12695. var startAngle = shape.startAngle;
  12696. var endAngle = shape.endAngle;
  12697. var arc;
  12698. if (startAngle === endAngle) {
  12699. arc = 0;
  12700. } else {
  12701. var tmpAngles = [startAngle, endAngle];
  12702. normalizeArcAngles(tmpAngles, !clockwise);
  12703. arc = mathAbs$1(tmpAngles[0] - tmpAngles[1]);
  12704. }
  12705. var x = shape.cx;
  12706. var y = shape.cy;
  12707. var cornerRadius = shape.cornerRadius || 0;
  12708. var innerCornerRadius = shape.innerCornerRadius || 0;
  12709. if (!(radius > e)) {
  12710. ctx.moveTo(x, y);
  12711. } else if (arc > PI2$5 - e) {
  12712. ctx.moveTo(x + radius * mathCos$3(startAngle), y + radius * mathSin$3(startAngle));
  12713. ctx.arc(x, y, radius, startAngle, endAngle, !clockwise);
  12714. if (innerRadius > e) {
  12715. ctx.moveTo(x + innerRadius * mathCos$3(endAngle), y + innerRadius * mathSin$3(endAngle));
  12716. ctx.arc(x, y, innerRadius, endAngle, startAngle, clockwise);
  12717. }
  12718. } else {
  12719. var halfRd = mathAbs$1(radius - innerRadius) / 2;
  12720. var cr = mathMin$4(halfRd, cornerRadius);
  12721. var icr = mathMin$4(halfRd, innerCornerRadius);
  12722. var cr0 = icr;
  12723. var cr1 = cr;
  12724. var xrs = radius * mathCos$3(startAngle);
  12725. var yrs = radius * mathSin$3(startAngle);
  12726. var xire = innerRadius * mathCos$3(endAngle);
  12727. var yire = innerRadius * mathSin$3(endAngle);
  12728. var xre = void 0;
  12729. var yre = void 0;
  12730. var xirs = void 0;
  12731. var yirs = void 0;
  12732. if (cr > e || icr > e) {
  12733. xre = radius * mathCos$3(endAngle);
  12734. yre = radius * mathSin$3(endAngle);
  12735. xirs = innerRadius * mathCos$3(startAngle);
  12736. yirs = innerRadius * mathSin$3(startAngle);
  12737. if (arc < PI$2) {
  12738. var it_1 = intersect(xrs, yrs, xirs, yirs, xre, yre, xire, yire);
  12739. if (it_1) {
  12740. var x0 = xrs - it_1[0];
  12741. var y0 = yrs - it_1[1];
  12742. var x1 = xre - it_1[0];
  12743. var y1 = yre - it_1[1];
  12744. var a = 1 / mathSin$3(mathACos((x0 * x1 + y0 * y1) / (mathSqrt$4(x0 * x0 + y0 * y0) * mathSqrt$4(x1 * x1 + y1 * y1))) / 2);
  12745. var b = mathSqrt$4(it_1[0] * it_1[0] + it_1[1] * it_1[1]);
  12746. cr0 = mathMin$4(icr, (innerRadius - b) / (a - 1));
  12747. cr1 = mathMin$4(cr, (radius - b) / (a + 1));
  12748. }
  12749. }
  12750. }
  12751. if (!(arc > e)) {
  12752. ctx.moveTo(x + xrs, y + yrs);
  12753. } else if (cr1 > e) {
  12754. var ct0 = computeCornerTangents(xirs, yirs, xrs, yrs, radius, cr1, clockwise);
  12755. var ct1 = computeCornerTangents(xre, yre, xire, yire, radius, cr1, clockwise);
  12756. ctx.moveTo(x + ct0.cx + ct0.x01, y + ct0.cy + ct0.y01);
  12757. if (cr1 < cr) {
  12758. ctx.arc(x + ct0.cx, y + ct0.cy, cr1, mathATan2(ct0.y01, ct0.x01), mathATan2(ct1.y01, ct1.x01), !clockwise);
  12759. } else {
  12760. ctx.arc(x + ct0.cx, y + ct0.cy, cr1, mathATan2(ct0.y01, ct0.x01), mathATan2(ct0.y11, ct0.x11), !clockwise);
  12761. ctx.arc(x, y, radius, mathATan2(ct0.cy + ct0.y11, ct0.cx + ct0.x11), mathATan2(ct1.cy + ct1.y11, ct1.cx + ct1.x11), !clockwise);
  12762. ctx.arc(x + ct1.cx, y + ct1.cy, cr1, mathATan2(ct1.y11, ct1.x11), mathATan2(ct1.y01, ct1.x01), !clockwise);
  12763. }
  12764. } else {
  12765. ctx.moveTo(x + xrs, y + yrs);
  12766. ctx.arc(x, y, radius, startAngle, endAngle, !clockwise);
  12767. }
  12768. if (!(innerRadius > e) || !(arc > e)) {
  12769. ctx.lineTo(x + xire, y + yire);
  12770. } else if (cr0 > e) {
  12771. var ct0 = computeCornerTangents(xire, yire, xre, yre, innerRadius, -cr0, clockwise);
  12772. var ct1 = computeCornerTangents(xrs, yrs, xirs, yirs, innerRadius, -cr0, clockwise);
  12773. ctx.lineTo(x + ct0.cx + ct0.x01, y + ct0.cy + ct0.y01);
  12774. if (cr0 < icr) {
  12775. ctx.arc(x + ct0.cx, y + ct0.cy, cr0, mathATan2(ct0.y01, ct0.x01), mathATan2(ct1.y01, ct1.x01), !clockwise);
  12776. } else {
  12777. ctx.arc(x + ct0.cx, y + ct0.cy, cr0, mathATan2(ct0.y01, ct0.x01), mathATan2(ct0.y11, ct0.x11), !clockwise);
  12778. ctx.arc(x, y, innerRadius, mathATan2(ct0.cy + ct0.y11, ct0.cx + ct0.x11), mathATan2(ct1.cy + ct1.y11, ct1.cx + ct1.x11), clockwise);
  12779. ctx.arc(x + ct1.cx, y + ct1.cy, cr0, mathATan2(ct1.y11, ct1.x11), mathATan2(ct1.y01, ct1.x01), !clockwise);
  12780. }
  12781. } else {
  12782. ctx.lineTo(x + xire, y + yire);
  12783. ctx.arc(x, y, innerRadius, endAngle, startAngle, clockwise);
  12784. }
  12785. }
  12786. ctx.closePath();
  12787. }
  12788. var SectorShape = function () {
  12789. function SectorShape() {
  12790. this.cx = 0;
  12791. this.cy = 0;
  12792. this.r0 = 0;
  12793. this.r = 0;
  12794. this.startAngle = 0;
  12795. this.endAngle = Math.PI * 2;
  12796. this.clockwise = true;
  12797. this.cornerRadius = 0;
  12798. this.innerCornerRadius = 0;
  12799. }
  12800. return SectorShape;
  12801. }();
  12802. var Sector = function (_super) {
  12803. __extends(Sector, _super);
  12804. function Sector(opts) {
  12805. return _super.call(this, opts) || this;
  12806. }
  12807. Sector.prototype.getDefaultShape = function () {
  12808. return new SectorShape();
  12809. };
  12810. Sector.prototype.buildPath = function (ctx, shape) {
  12811. buildPath$1(ctx, shape);
  12812. };
  12813. Sector.prototype.isZeroArea = function () {
  12814. return this.shape.startAngle === this.shape.endAngle || this.shape.r === this.shape.r0;
  12815. };
  12816. return Sector;
  12817. }(Path);
  12818. Sector.prototype.type = 'sector';
  12819. var RingShape = function () {
  12820. function RingShape() {
  12821. this.cx = 0;
  12822. this.cy = 0;
  12823. this.r = 0;
  12824. this.r0 = 0;
  12825. }
  12826. return RingShape;
  12827. }();
  12828. var Ring = function (_super) {
  12829. __extends(Ring, _super);
  12830. function Ring(opts) {
  12831. return _super.call(this, opts) || this;
  12832. }
  12833. Ring.prototype.getDefaultShape = function () {
  12834. return new RingShape();
  12835. };
  12836. Ring.prototype.buildPath = function (ctx, shape) {
  12837. var x = shape.cx;
  12838. var y = shape.cy;
  12839. var PI2 = Math.PI * 2;
  12840. ctx.moveTo(x + shape.r, y);
  12841. ctx.arc(x, y, shape.r, 0, PI2, false);
  12842. ctx.moveTo(x + shape.r0, y);
  12843. ctx.arc(x, y, shape.r0, 0, PI2, true);
  12844. };
  12845. return Ring;
  12846. }(Path);
  12847. Ring.prototype.type = 'ring';
  12848. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  12849. var v0 = (p2 - p0) * 0.5;
  12850. var v1 = (p3 - p1) * 0.5;
  12851. return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
  12852. }
  12853. function smoothSpline(points, isLoop) {
  12854. var len$$1 = points.length;
  12855. var ret = [];
  12856. var distance$$1 = 0;
  12857. for (var i = 1; i < len$$1; i++) {
  12858. distance$$1 += distance(points[i - 1], points[i]);
  12859. }
  12860. var segs = distance$$1 / 2;
  12861. segs = segs < len$$1 ? len$$1 : segs;
  12862. for (var i = 0; i < segs; i++) {
  12863. var pos = i / (segs - 1) * (isLoop ? len$$1 : len$$1 - 1);
  12864. var idx = Math.floor(pos);
  12865. var w = pos - idx;
  12866. var p0 = void 0;
  12867. var p1 = points[idx % len$$1];
  12868. var p2 = void 0;
  12869. var p3 = void 0;
  12870. if (!isLoop) {
  12871. p0 = points[idx === 0 ? idx : idx - 1];
  12872. p2 = points[idx > len$$1 - 2 ? len$$1 - 1 : idx + 1];
  12873. p3 = points[idx > len$$1 - 3 ? len$$1 - 1 : idx + 2];
  12874. } else {
  12875. p0 = points[(idx - 1 + len$$1) % len$$1];
  12876. p2 = points[(idx + 1) % len$$1];
  12877. p3 = points[(idx + 2) % len$$1];
  12878. }
  12879. var w2 = w * w;
  12880. var w3 = w * w2;
  12881. ret.push([interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)]);
  12882. }
  12883. return ret;
  12884. }
  12885. function smoothBezier(points, smooth, isLoop, constraint) {
  12886. var cps = [];
  12887. var v = [];
  12888. var v1 = [];
  12889. var v2 = [];
  12890. var prevPoint;
  12891. var nextPoint;
  12892. var min$$1;
  12893. var max$$1;
  12894. if (constraint) {
  12895. min$$1 = [Infinity, Infinity];
  12896. max$$1 = [-Infinity, -Infinity];
  12897. for (var i = 0, len$$1 = points.length; i < len$$1; i++) {
  12898. min(min$$1, min$$1, points[i]);
  12899. max(max$$1, max$$1, points[i]);
  12900. }
  12901. min(min$$1, min$$1, constraint[0]);
  12902. max(max$$1, max$$1, constraint[1]);
  12903. }
  12904. for (var i = 0, len$$1 = points.length; i < len$$1; i++) {
  12905. var point = points[i];
  12906. if (isLoop) {
  12907. prevPoint = points[i ? i - 1 : len$$1 - 1];
  12908. nextPoint = points[(i + 1) % len$$1];
  12909. } else {
  12910. if (i === 0 || i === len$$1 - 1) {
  12911. cps.push(clone$1(points[i]));
  12912. continue;
  12913. } else {
  12914. prevPoint = points[i - 1];
  12915. nextPoint = points[i + 1];
  12916. }
  12917. }
  12918. sub(v, nextPoint, prevPoint);
  12919. scale(v, v, smooth);
  12920. var d0 = distance(point, prevPoint);
  12921. var d1 = distance(point, nextPoint);
  12922. var sum = d0 + d1;
  12923. if (sum !== 0) {
  12924. d0 /= sum;
  12925. d1 /= sum;
  12926. }
  12927. scale(v1, v, -d0);
  12928. scale(v2, v, d1);
  12929. var cp0 = add([], point, v1);
  12930. var cp1 = add([], point, v2);
  12931. if (constraint) {
  12932. max(cp0, cp0, min$$1);
  12933. min(cp0, cp0, max$$1);
  12934. max(cp1, cp1, min$$1);
  12935. min(cp1, cp1, max$$1);
  12936. }
  12937. cps.push(cp0);
  12938. cps.push(cp1);
  12939. }
  12940. if (isLoop) {
  12941. cps.push(cps.shift());
  12942. }
  12943. return cps;
  12944. }
  12945. function buildPath$2(ctx, shape, closePath) {
  12946. var smooth = shape.smooth;
  12947. var points = shape.points;
  12948. if (points && points.length >= 2) {
  12949. if (smooth && smooth !== 'spline') {
  12950. var controlPoints = smoothBezier(points, smooth, closePath, shape.smoothConstraint);
  12951. ctx.moveTo(points[0][0], points[0][1]);
  12952. var len = points.length;
  12953. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  12954. var cp1 = controlPoints[i * 2];
  12955. var cp2 = controlPoints[i * 2 + 1];
  12956. var p = points[(i + 1) % len];
  12957. ctx.bezierCurveTo(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]);
  12958. }
  12959. } else {
  12960. if (smooth === 'spline') {
  12961. points = smoothSpline(points, closePath);
  12962. }
  12963. ctx.moveTo(points[0][0], points[0][1]);
  12964. for (var i = 1, l = points.length; i < l; i++) {
  12965. ctx.lineTo(points[i][0], points[i][1]);
  12966. }
  12967. }
  12968. closePath && ctx.closePath();
  12969. }
  12970. }
  12971. var PolygonShape = function () {
  12972. function PolygonShape() {
  12973. this.points = null;
  12974. this.smooth = 0;
  12975. this.smoothConstraint = null;
  12976. }
  12977. return PolygonShape;
  12978. }();
  12979. var Polygon = function (_super) {
  12980. __extends(Polygon, _super);
  12981. function Polygon(opts) {
  12982. return _super.call(this, opts) || this;
  12983. }
  12984. Polygon.prototype.getDefaultShape = function () {
  12985. return new PolygonShape();
  12986. };
  12987. Polygon.prototype.buildPath = function (ctx, shape) {
  12988. buildPath$2(ctx, shape, true);
  12989. };
  12990. return Polygon;
  12991. }(Path);
  12992. Polygon.prototype.type = 'polygon';
  12993. var PolylineShape = function () {
  12994. function PolylineShape() {
  12995. this.points = null;
  12996. this.percent = 1;
  12997. this.smooth = 0;
  12998. this.smoothConstraint = null;
  12999. }
  13000. return PolylineShape;
  13001. }();
  13002. var Polyline = function (_super) {
  13003. __extends(Polyline, _super);
  13004. function Polyline(opts) {
  13005. return _super.call(this, opts) || this;
  13006. }
  13007. Polyline.prototype.getDefaultStyle = function () {
  13008. return {
  13009. stroke: '#000',
  13010. fill: null
  13011. };
  13012. };
  13013. Polyline.prototype.getDefaultShape = function () {
  13014. return new PolylineShape();
  13015. };
  13016. Polyline.prototype.buildPath = function (ctx, shape) {
  13017. buildPath$2(ctx, shape, false);
  13018. };
  13019. return Polyline;
  13020. }(Path);
  13021. Polyline.prototype.type = 'polyline';
  13022. var subPixelOptimizeOutputShape$1 = {};
  13023. var LineShape = function () {
  13024. function LineShape() {
  13025. this.x1 = 0;
  13026. this.y1 = 0;
  13027. this.x2 = 0;
  13028. this.y2 = 0;
  13029. this.percent = 1;
  13030. }
  13031. return LineShape;
  13032. }();
  13033. var Line = function (_super) {
  13034. __extends(Line, _super);
  13035. function Line(opts) {
  13036. return _super.call(this, opts) || this;
  13037. }
  13038. Line.prototype.getDefaultStyle = function () {
  13039. return {
  13040. stroke: '#000',
  13041. fill: null
  13042. };
  13043. };
  13044. Line.prototype.getDefaultShape = function () {
  13045. return new LineShape();
  13046. };
  13047. Line.prototype.buildPath = function (ctx, shape) {
  13048. var x1;
  13049. var y1;
  13050. var x2;
  13051. var y2;
  13052. if (this.subPixelOptimize) {
  13053. var optimizedShape = subPixelOptimizeLine(subPixelOptimizeOutputShape$1, shape, this.style);
  13054. x1 = optimizedShape.x1;
  13055. y1 = optimizedShape.y1;
  13056. x2 = optimizedShape.x2;
  13057. y2 = optimizedShape.y2;
  13058. } else {
  13059. x1 = shape.x1;
  13060. y1 = shape.y1;
  13061. x2 = shape.x2;
  13062. y2 = shape.y2;
  13063. }
  13064. var percent = shape.percent;
  13065. if (percent === 0) {
  13066. return;
  13067. }
  13068. ctx.moveTo(x1, y1);
  13069. if (percent < 1) {
  13070. x2 = x1 * (1 - percent) + x2 * percent;
  13071. y2 = y1 * (1 - percent) + y2 * percent;
  13072. }
  13073. ctx.lineTo(x2, y2);
  13074. };
  13075. Line.prototype.pointAt = function (p) {
  13076. var shape = this.shape;
  13077. return [shape.x1 * (1 - p) + shape.x2 * p, shape.y1 * (1 - p) + shape.y2 * p];
  13078. };
  13079. return Line;
  13080. }(Path);
  13081. Line.prototype.type = 'line';
  13082. var out = [];
  13083. var BezierCurveShape = function () {
  13084. function BezierCurveShape() {
  13085. this.x1 = 0;
  13086. this.y1 = 0;
  13087. this.x2 = 0;
  13088. this.y2 = 0;
  13089. this.cpx1 = 0;
  13090. this.cpy1 = 0;
  13091. this.percent = 1;
  13092. }
  13093. return BezierCurveShape;
  13094. }();
  13095. function someVectorAt(shape, t, isTangent) {
  13096. var cpx2 = shape.cpx2;
  13097. var cpy2 = shape.cpy2;
  13098. if (cpx2 === null || cpy2 === null) {
  13099. return [(isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t), (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)];
  13100. } else {
  13101. return [(isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t), (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)];
  13102. }
  13103. }
  13104. var BezierCurve = function (_super) {
  13105. __extends(BezierCurve, _super);
  13106. function BezierCurve(opts) {
  13107. return _super.call(this, opts) || this;
  13108. }
  13109. BezierCurve.prototype.getDefaultStyle = function () {
  13110. return {
  13111. stroke: '#000',
  13112. fill: null
  13113. };
  13114. };
  13115. BezierCurve.prototype.getDefaultShape = function () {
  13116. return new BezierCurveShape();
  13117. };
  13118. BezierCurve.prototype.buildPath = function (ctx, shape) {
  13119. var x1 = shape.x1;
  13120. var y1 = shape.y1;
  13121. var x2 = shape.x2;
  13122. var y2 = shape.y2;
  13123. var cpx1 = shape.cpx1;
  13124. var cpy1 = shape.cpy1;
  13125. var cpx2 = shape.cpx2;
  13126. var cpy2 = shape.cpy2;
  13127. var percent = shape.percent;
  13128. if (percent === 0) {
  13129. return;
  13130. }
  13131. ctx.moveTo(x1, y1);
  13132. if (cpx2 == null || cpy2 == null) {
  13133. if (percent < 1) {
  13134. quadraticSubdivide(x1, cpx1, x2, percent, out);
  13135. cpx1 = out[1];
  13136. x2 = out[2];
  13137. quadraticSubdivide(y1, cpy1, y2, percent, out);
  13138. cpy1 = out[1];
  13139. y2 = out[2];
  13140. }
  13141. ctx.quadraticCurveTo(cpx1, cpy1, x2, y2);
  13142. } else {
  13143. if (percent < 1) {
  13144. cubicSubdivide(x1, cpx1, cpx2, x2, percent, out);
  13145. cpx1 = out[1];
  13146. cpx2 = out[2];
  13147. x2 = out[3];
  13148. cubicSubdivide(y1, cpy1, cpy2, y2, percent, out);
  13149. cpy1 = out[1];
  13150. cpy2 = out[2];
  13151. y2 = out[3];
  13152. }
  13153. ctx.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x2, y2);
  13154. }
  13155. };
  13156. BezierCurve.prototype.pointAt = function (t) {
  13157. return someVectorAt(this.shape, t, false);
  13158. };
  13159. BezierCurve.prototype.tangentAt = function (t) {
  13160. var p = someVectorAt(this.shape, t, true);
  13161. return normalize(p, p);
  13162. };
  13163. return BezierCurve;
  13164. }(Path);
  13165. BezierCurve.prototype.type = 'bezier-curve';
  13166. var ArcShape = function () {
  13167. function ArcShape() {
  13168. this.cx = 0;
  13169. this.cy = 0;
  13170. this.r = 0;
  13171. this.startAngle = 0;
  13172. this.endAngle = Math.PI * 2;
  13173. this.clockwise = true;
  13174. }
  13175. return ArcShape;
  13176. }();
  13177. var Arc = function (_super) {
  13178. __extends(Arc, _super);
  13179. function Arc(opts) {
  13180. return _super.call(this, opts) || this;
  13181. }
  13182. Arc.prototype.getDefaultStyle = function () {
  13183. return {
  13184. stroke: '#000',
  13185. fill: null
  13186. };
  13187. };
  13188. Arc.prototype.getDefaultShape = function () {
  13189. return new ArcShape();
  13190. };
  13191. Arc.prototype.buildPath = function (ctx, shape) {
  13192. var x = shape.cx;
  13193. var y = shape.cy;
  13194. var r = Math.max(shape.r, 0);
  13195. var startAngle = shape.startAngle;
  13196. var endAngle = shape.endAngle;
  13197. var clockwise = shape.clockwise;
  13198. var unitX = Math.cos(startAngle);
  13199. var unitY = Math.sin(startAngle);
  13200. ctx.moveTo(unitX * r + x, unitY * r + y);
  13201. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13202. };
  13203. return Arc;
  13204. }(Path);
  13205. Arc.prototype.type = 'arc';
  13206. var CompoundPath = function (_super) {
  13207. __extends(CompoundPath, _super);
  13208. function CompoundPath() {
  13209. var _this = _super !== null && _super.apply(this, arguments) || this;
  13210. _this.type = 'compound';
  13211. return _this;
  13212. }
  13213. CompoundPath.prototype._updatePathDirty = function () {
  13214. var paths = this.shape.paths;
  13215. var dirtyPath = this.shapeChanged();
  13216. for (var i = 0; i < paths.length; i++) {
  13217. dirtyPath = dirtyPath || paths[i].shapeChanged();
  13218. }
  13219. if (dirtyPath) {
  13220. this.dirtyShape();
  13221. }
  13222. };
  13223. CompoundPath.prototype.beforeBrush = function () {
  13224. this._updatePathDirty();
  13225. var paths = this.shape.paths || [];
  13226. var scale = this.getGlobalScale();
  13227. for (var i = 0; i < paths.length; i++) {
  13228. if (!paths[i].path) {
  13229. paths[i].createPathProxy();
  13230. }
  13231. paths[i].path.setScale(scale[0], scale[1], paths[i].segmentIgnoreThreshold);
  13232. }
  13233. };
  13234. CompoundPath.prototype.buildPath = function (ctx, shape) {
  13235. var paths = shape.paths || [];
  13236. for (var i = 0; i < paths.length; i++) {
  13237. paths[i].buildPath(ctx, paths[i].shape, true);
  13238. }
  13239. };
  13240. CompoundPath.prototype.afterBrush = function () {
  13241. var paths = this.shape.paths || [];
  13242. for (var i = 0; i < paths.length; i++) {
  13243. paths[i].pathUpdated();
  13244. }
  13245. };
  13246. CompoundPath.prototype.getBoundingRect = function () {
  13247. this._updatePathDirty.call(this);
  13248. return Path.prototype.getBoundingRect.call(this);
  13249. };
  13250. return CompoundPath;
  13251. }(Path);
  13252. var Gradient = function () {
  13253. function Gradient(colorStops) {
  13254. this.colorStops = colorStops || [];
  13255. }
  13256. Gradient.prototype.addColorStop = function (offset, color) {
  13257. this.colorStops.push({
  13258. offset: offset,
  13259. color: color
  13260. });
  13261. };
  13262. return Gradient;
  13263. }();
  13264. var LinearGradient = function (_super) {
  13265. __extends(LinearGradient, _super);
  13266. function LinearGradient(x, y, x2, y2, colorStops, globalCoord) {
  13267. var _this = _super.call(this, colorStops) || this;
  13268. _this.x = x == null ? 0 : x;
  13269. _this.y = y == null ? 0 : y;
  13270. _this.x2 = x2 == null ? 1 : x2;
  13271. _this.y2 = y2 == null ? 0 : y2;
  13272. _this.type = 'linear';
  13273. _this.global = globalCoord || false;
  13274. return _this;
  13275. }
  13276. return LinearGradient;
  13277. }(Gradient);
  13278. var RadialGradient = function (_super) {
  13279. __extends(RadialGradient, _super);
  13280. function RadialGradient(x, y, r, colorStops, globalCoord) {
  13281. var _this = _super.call(this, colorStops) || this;
  13282. _this.x = x == null ? 0.5 : x;
  13283. _this.y = y == null ? 0.5 : y;
  13284. _this.r = r == null ? 0.5 : r;
  13285. _this.type = 'radial';
  13286. _this.global = globalCoord || false;
  13287. return _this;
  13288. }
  13289. return RadialGradient;
  13290. }(Gradient);
  13291. var extent = [0, 0];
  13292. var extent2 = [0, 0];
  13293. var minTv$1 = new Point();
  13294. var maxTv$1 = new Point();
  13295. var OrientedBoundingRect = function () {
  13296. function OrientedBoundingRect(rect, transform) {
  13297. this._corners = [];
  13298. this._axes = [];
  13299. this._origin = [0, 0];
  13300. for (var i = 0; i < 4; i++) {
  13301. this._corners[i] = new Point();
  13302. }
  13303. for (var i = 0; i < 2; i++) {
  13304. this._axes[i] = new Point();
  13305. }
  13306. if (rect) {
  13307. this.fromBoundingRect(rect, transform);
  13308. }
  13309. }
  13310. OrientedBoundingRect.prototype.fromBoundingRect = function (rect, transform) {
  13311. var corners = this._corners;
  13312. var axes = this._axes;
  13313. var x = rect.x;
  13314. var y = rect.y;
  13315. var x2 = x + rect.width;
  13316. var y2 = y + rect.height;
  13317. corners[0].set(x, y);
  13318. corners[1].set(x2, y);
  13319. corners[2].set(x2, y2);
  13320. corners[3].set(x, y2);
  13321. if (transform) {
  13322. for (var i = 0; i < 4; i++) {
  13323. corners[i].transform(transform);
  13324. }
  13325. }
  13326. Point.sub(axes[0], corners[1], corners[0]);
  13327. Point.sub(axes[1], corners[3], corners[0]);
  13328. axes[0].normalize();
  13329. axes[1].normalize();
  13330. for (var i = 0; i < 2; i++) {
  13331. this._origin[i] = axes[i].dot(corners[0]);
  13332. }
  13333. };
  13334. OrientedBoundingRect.prototype.intersect = function (other, mtv) {
  13335. var overlapped = true;
  13336. var noMtv = !mtv;
  13337. minTv$1.set(Infinity, Infinity);
  13338. maxTv$1.set(0, 0);
  13339. if (!this._intersectCheckOneSide(this, other, minTv$1, maxTv$1, noMtv, 1)) {
  13340. overlapped = false;
  13341. if (noMtv) {
  13342. return overlapped;
  13343. }
  13344. }
  13345. if (!this._intersectCheckOneSide(other, this, minTv$1, maxTv$1, noMtv, -1)) {
  13346. overlapped = false;
  13347. if (noMtv) {
  13348. return overlapped;
  13349. }
  13350. }
  13351. if (!noMtv) {
  13352. Point.copy(mtv, overlapped ? minTv$1 : maxTv$1);
  13353. }
  13354. return overlapped;
  13355. };
  13356. OrientedBoundingRect.prototype._intersectCheckOneSide = function (self, other, minTv, maxTv, noMtv, inverse) {
  13357. var overlapped = true;
  13358. for (var i = 0; i < 2; i++) {
  13359. var axis = this._axes[i];
  13360. this._getProjMinMaxOnAxis(i, self._corners, extent);
  13361. this._getProjMinMaxOnAxis(i, other._corners, extent2);
  13362. if (extent[1] < extent2[0] || extent[0] > extent2[1]) {
  13363. overlapped = false;
  13364. if (noMtv) {
  13365. return overlapped;
  13366. }
  13367. var dist0 = Math.abs(extent2[0] - extent[1]);
  13368. var dist1 = Math.abs(extent[0] - extent2[1]);
  13369. if (Math.min(dist0, dist1) > maxTv.len()) {
  13370. if (dist0 < dist1) {
  13371. Point.scale(maxTv, axis, -dist0 * inverse);
  13372. } else {
  13373. Point.scale(maxTv, axis, dist1 * inverse);
  13374. }
  13375. }
  13376. } else if (minTv) {
  13377. var dist0 = Math.abs(extent2[0] - extent[1]);
  13378. var dist1 = Math.abs(extent[0] - extent2[1]);
  13379. if (Math.min(dist0, dist1) < minTv.len()) {
  13380. if (dist0 < dist1) {
  13381. Point.scale(minTv, axis, dist0 * inverse);
  13382. } else {
  13383. Point.scale(minTv, axis, -dist1 * inverse);
  13384. }
  13385. }
  13386. }
  13387. }
  13388. return overlapped;
  13389. };
  13390. OrientedBoundingRect.prototype._getProjMinMaxOnAxis = function (dim, corners, out) {
  13391. var axis = this._axes[dim];
  13392. var origin = this._origin;
  13393. var proj = corners[0].dot(axis) + origin[dim];
  13394. var min = proj;
  13395. var max = proj;
  13396. for (var i = 1; i < corners.length; i++) {
  13397. var proj_1 = corners[i].dot(axis) + origin[dim];
  13398. min = Math.min(proj_1, min);
  13399. max = Math.max(proj_1, max);
  13400. }
  13401. out[0] = min;
  13402. out[1] = max;
  13403. };
  13404. return OrientedBoundingRect;
  13405. }();
  13406. var m = [];
  13407. var IncrementalDisplayable = function (_super) {
  13408. __extends(IncrementalDisplayable, _super);
  13409. function IncrementalDisplayable() {
  13410. var _this = _super !== null && _super.apply(this, arguments) || this;
  13411. _this.notClear = true;
  13412. _this.incremental = true;
  13413. _this._displayables = [];
  13414. _this._temporaryDisplayables = [];
  13415. _this._cursor = 0;
  13416. return _this;
  13417. }
  13418. IncrementalDisplayable.prototype.traverse = function (cb, context) {
  13419. cb.call(context, this);
  13420. };
  13421. IncrementalDisplayable.prototype.useStyle = function () {
  13422. this.style = {};
  13423. };
  13424. IncrementalDisplayable.prototype.getCursor = function () {
  13425. return this._cursor;
  13426. };
  13427. IncrementalDisplayable.prototype.innerAfterBrush = function () {
  13428. this._cursor = this._displayables.length;
  13429. };
  13430. IncrementalDisplayable.prototype.clearDisplaybles = function () {
  13431. this._displayables = [];
  13432. this._temporaryDisplayables = [];
  13433. this._cursor = 0;
  13434. this.markRedraw();
  13435. this.notClear = false;
  13436. };
  13437. IncrementalDisplayable.prototype.clearTemporalDisplayables = function () {
  13438. this._temporaryDisplayables = [];
  13439. };
  13440. IncrementalDisplayable.prototype.addDisplayable = function (displayable, notPersistent) {
  13441. if (notPersistent) {
  13442. this._temporaryDisplayables.push(displayable);
  13443. } else {
  13444. this._displayables.push(displayable);
  13445. }
  13446. this.markRedraw();
  13447. };
  13448. IncrementalDisplayable.prototype.addDisplayables = function (displayables, notPersistent) {
  13449. notPersistent = notPersistent || false;
  13450. for (var i = 0; i < displayables.length; i++) {
  13451. this.addDisplayable(displayables[i], notPersistent);
  13452. }
  13453. };
  13454. IncrementalDisplayable.prototype.getDisplayables = function () {
  13455. return this._displayables;
  13456. };
  13457. IncrementalDisplayable.prototype.getTemporalDisplayables = function () {
  13458. return this._temporaryDisplayables;
  13459. };
  13460. IncrementalDisplayable.prototype.eachPendingDisplayable = function (cb) {
  13461. for (var i = this._cursor; i < this._displayables.length; i++) {
  13462. cb && cb(this._displayables[i]);
  13463. }
  13464. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  13465. cb && cb(this._temporaryDisplayables[i]);
  13466. }
  13467. };
  13468. IncrementalDisplayable.prototype.update = function () {
  13469. this.updateTransform();
  13470. for (var i = this._cursor; i < this._displayables.length; i++) {
  13471. var displayable = this._displayables[i];
  13472. displayable.parent = this;
  13473. displayable.update();
  13474. displayable.parent = null;
  13475. }
  13476. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  13477. var displayable = this._temporaryDisplayables[i];
  13478. displayable.parent = this;
  13479. displayable.update();
  13480. displayable.parent = null;
  13481. }
  13482. };
  13483. IncrementalDisplayable.prototype.getBoundingRect = function () {
  13484. if (!this._rect) {
  13485. var rect = new BoundingRect(Infinity, Infinity, -Infinity, -Infinity);
  13486. for (var i = 0; i < this._displayables.length; i++) {
  13487. var displayable = this._displayables[i];
  13488. var childRect = displayable.getBoundingRect().clone();
  13489. if (displayable.needLocalTransform()) {
  13490. childRect.applyTransform(displayable.getLocalTransform(m));
  13491. }
  13492. rect.union(childRect);
  13493. }
  13494. this._rect = rect;
  13495. }
  13496. return this._rect;
  13497. };
  13498. IncrementalDisplayable.prototype.contain = function (x, y) {
  13499. var localPos = this.transformCoordToLocal(x, y);
  13500. var rect = this.getBoundingRect();
  13501. if (rect.contain(localPos[0], localPos[1])) {
  13502. for (var i = 0; i < this._displayables.length; i++) {
  13503. var displayable = this._displayables[i];
  13504. if (displayable.contain(x, y)) {
  13505. return true;
  13506. }
  13507. }
  13508. }
  13509. return false;
  13510. };
  13511. return IncrementalDisplayable;
  13512. }(Displayable);
  13513. /*
  13514. * Licensed to the Apache Software Foundation (ASF) under one
  13515. * or more contributor license agreements. See the NOTICE file
  13516. * distributed with this work for additional information
  13517. * regarding copyright ownership. The ASF licenses this file
  13518. * to you under the Apache License, Version 2.0 (the
  13519. * "License"); you may not use this file except in compliance
  13520. * with the License. You may obtain a copy of the License at
  13521. *
  13522. * http://www.apache.org/licenses/LICENSE-2.0
  13523. *
  13524. * Unless required by applicable law or agreed to in writing,
  13525. * software distributed under the License is distributed on an
  13526. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13527. * KIND, either express or implied. See the License for the
  13528. * specific language governing permissions and limitations
  13529. * under the License.
  13530. */
  13531. /**
  13532. * AUTO-GENERATED FILE. DO NOT MODIFY.
  13533. */
  13534. /*
  13535. * Licensed to the Apache Software Foundation (ASF) under one
  13536. * or more contributor license agreements. See the NOTICE file
  13537. * distributed with this work for additional information
  13538. * regarding copyright ownership. The ASF licenses this file
  13539. * to you under the Apache License, Version 2.0 (the
  13540. * "License"); you may not use this file except in compliance
  13541. * with the License. You may obtain a copy of the License at
  13542. *
  13543. * http://www.apache.org/licenses/LICENSE-2.0
  13544. *
  13545. * Unless required by applicable law or agreed to in writing,
  13546. * software distributed under the License is distributed on an
  13547. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13548. * KIND, either express or implied. See the License for the
  13549. * specific language governing permissions and limitations
  13550. * under the License.
  13551. */
  13552. var mathMax$3 = Math.max;
  13553. var mathMin$3 = Math.min;
  13554. var _customShapeMap = {};
  13555. /**
  13556. * Extend shape with parameters
  13557. */
  13558. function extendShape(opts) {
  13559. return Path.extend(opts);
  13560. }
  13561. var extendPathFromString = extendFromString;
  13562. /**
  13563. * Extend path
  13564. */
  13565. function extendPath(pathData, opts) {
  13566. return extendPathFromString(pathData, opts);
  13567. }
  13568. /**
  13569. * Register a user defined shape.
  13570. * The shape class can be fetched by `getShapeClass`
  13571. * This method will overwrite the registered shapes, including
  13572. * the registered built-in shapes, if using the same `name`.
  13573. * The shape can be used in `custom series` and
  13574. * `graphic component` by declaring `{type: name}`.
  13575. *
  13576. * @param name
  13577. * @param ShapeClass Can be generated by `extendShape`.
  13578. */
  13579. function registerShape(name, ShapeClass) {
  13580. _customShapeMap[name] = ShapeClass;
  13581. }
  13582. /**
  13583. * Find shape class registered by `registerShape`. Usually used in
  13584. * fetching user defined shape.
  13585. *
  13586. * [Caution]:
  13587. * (1) This method **MUST NOT be used inside echarts !!!**, unless it is prepared
  13588. * to use user registered shapes.
  13589. * Because the built-in shape (see `getBuiltInShape`) will be registered by
  13590. * `registerShape` by default. That enables users to get both built-in
  13591. * shapes as well as the shapes belonging to themsleves. But users can overwrite
  13592. * the built-in shapes by using names like 'circle', 'rect' via calling
  13593. * `registerShape`. So the echarts inner featrues should not fetch shapes from here
  13594. * in case that it is overwritten by users, except that some features, like
  13595. * `custom series`, `graphic component`, do it deliberately.
  13596. *
  13597. * (2) In the features like `custom series`, `graphic component`, the user input
  13598. * `{tpye: 'xxx'}` does not only specify shapes but also specify other graphic
  13599. * elements like `'group'`, `'text'`, `'image'` or event `'path'`. Those names
  13600. * are reserved names, that is, if some user register a shape named `'image'`,
  13601. * the shape will not be used. If we intending to add some more reserved names
  13602. * in feature, that might bring break changes (disable some existing user shape
  13603. * names). But that case probably rearly happen. So we dont make more mechanism
  13604. * to resolve this issue here.
  13605. *
  13606. * @param name
  13607. * @return The shape class. If not found, return nothing.
  13608. */
  13609. function getShapeClass(name) {
  13610. if (_customShapeMap.hasOwnProperty(name)) {
  13611. return _customShapeMap[name];
  13612. }
  13613. }
  13614. /**
  13615. * Create a path element from path data string
  13616. * @param pathData
  13617. * @param opts
  13618. * @param rect
  13619. * @param layout 'center' or 'cover' default to be cover
  13620. */
  13621. function makePath(pathData, opts, rect, layout) {
  13622. var path = createFromString(pathData, opts);
  13623. if (rect) {
  13624. if (layout === 'center') {
  13625. rect = centerGraphic(rect, path.getBoundingRect());
  13626. }
  13627. resizePath(path, rect);
  13628. }
  13629. return path;
  13630. }
  13631. /**
  13632. * Create a image element from image url
  13633. * @param imageUrl image url
  13634. * @param opts options
  13635. * @param rect constrain rect
  13636. * @param layout 'center' or 'cover'. Default to be 'cover'
  13637. */
  13638. function makeImage(imageUrl, rect, layout) {
  13639. var zrImg = new ZRImage({
  13640. style: {
  13641. image: imageUrl,
  13642. x: rect.x,
  13643. y: rect.y,
  13644. width: rect.width,
  13645. height: rect.height
  13646. },
  13647. onload: function (img) {
  13648. if (layout === 'center') {
  13649. var boundingRect = {
  13650. width: img.width,
  13651. height: img.height
  13652. };
  13653. zrImg.setStyle(centerGraphic(rect, boundingRect));
  13654. }
  13655. }
  13656. });
  13657. return zrImg;
  13658. }
  13659. /**
  13660. * Get position of centered element in bounding box.
  13661. *
  13662. * @param rect element local bounding box
  13663. * @param boundingRect constraint bounding box
  13664. * @return element position containing x, y, width, and height
  13665. */
  13666. function centerGraphic(rect, boundingRect) {
  13667. // Set rect to center, keep width / height ratio.
  13668. var aspect = boundingRect.width / boundingRect.height;
  13669. var width = rect.height * aspect;
  13670. var height;
  13671. if (width <= rect.width) {
  13672. height = rect.height;
  13673. } else {
  13674. width = rect.width;
  13675. height = width / aspect;
  13676. }
  13677. var cx = rect.x + rect.width / 2;
  13678. var cy = rect.y + rect.height / 2;
  13679. return {
  13680. x: cx - width / 2,
  13681. y: cy - height / 2,
  13682. width: width,
  13683. height: height
  13684. };
  13685. }
  13686. var mergePath = mergePath$1;
  13687. /**
  13688. * Resize a path to fit the rect
  13689. * @param path
  13690. * @param rect
  13691. */
  13692. function resizePath(path, rect) {
  13693. if (!path.applyTransform) {
  13694. return;
  13695. }
  13696. var pathRect = path.getBoundingRect();
  13697. var m = pathRect.calculateTransform(rect);
  13698. path.applyTransform(m);
  13699. }
  13700. /**
  13701. * Sub pixel optimize line for canvas
  13702. */
  13703. function subPixelOptimizeLine$1(param) {
  13704. subPixelOptimizeLine(param.shape, param.shape, param.style);
  13705. return param;
  13706. }
  13707. /**
  13708. * Sub pixel optimize rect for canvas
  13709. */
  13710. function subPixelOptimizeRect$1(param) {
  13711. subPixelOptimizeRect(param.shape, param.shape, param.style);
  13712. return param;
  13713. }
  13714. /**
  13715. * Sub pixel optimize for canvas
  13716. *
  13717. * @param position Coordinate, such as x, y
  13718. * @param lineWidth Should be nonnegative integer.
  13719. * @param positiveOrNegative Default false (negative).
  13720. * @return Optimized position.
  13721. */
  13722. var subPixelOptimize$1 = subPixelOptimize;
  13723. function animateOrSetProps(animationType, el, props, animatableModel, dataIndex, cb, during) {
  13724. var isFrom = false;
  13725. var removeOpt;
  13726. if (typeof dataIndex === 'function') {
  13727. during = cb;
  13728. cb = dataIndex;
  13729. dataIndex = null;
  13730. } else if (isObject$1(dataIndex)) {
  13731. cb = dataIndex.cb;
  13732. during = dataIndex.during;
  13733. isFrom = dataIndex.isFrom;
  13734. removeOpt = dataIndex.removeOpt;
  13735. dataIndex = dataIndex.dataIndex;
  13736. }
  13737. var isUpdate = animationType === 'update';
  13738. var isRemove = animationType === 'remove';
  13739. var animationPayload; // Check if there is global animation configuration from dataZoom/resize can override the config in option.
  13740. // If animation is enabled. Will use this animation config in payload.
  13741. // If animation is disabled. Just ignore it.
  13742. if (animatableModel && animatableModel.ecModel) {
  13743. var updatePayload = animatableModel.ecModel.getUpdatePayload();
  13744. animationPayload = updatePayload && updatePayload.animation;
  13745. }
  13746. var animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
  13747. if (!isRemove) {
  13748. // Must stop the remove animation.
  13749. el.stopAnimation('remove');
  13750. }
  13751. if (animationEnabled) {
  13752. var duration = void 0;
  13753. var animationEasing = void 0;
  13754. var animationDelay = void 0;
  13755. if (animationPayload) {
  13756. duration = animationPayload.duration || 0;
  13757. animationEasing = animationPayload.easing || 'cubicOut';
  13758. animationDelay = animationPayload.delay || 0;
  13759. } else if (isRemove) {
  13760. removeOpt = removeOpt || {};
  13761. duration = retrieve2(removeOpt.duration, 200);
  13762. animationEasing = retrieve2(removeOpt.easing, 'cubicOut');
  13763. animationDelay = 0;
  13764. } else {
  13765. duration = animatableModel.getShallow(isUpdate ? 'animationDurationUpdate' : 'animationDuration');
  13766. animationEasing = animatableModel.getShallow(isUpdate ? 'animationEasingUpdate' : 'animationEasing');
  13767. animationDelay = animatableModel.getShallow(isUpdate ? 'animationDelayUpdate' : 'animationDelay');
  13768. }
  13769. if (typeof animationDelay === 'function') {
  13770. animationDelay = animationDelay(dataIndex, animatableModel.getAnimationDelayParams ? animatableModel.getAnimationDelayParams(el, dataIndex) : null);
  13771. }
  13772. if (typeof duration === 'function') {
  13773. duration = duration(dataIndex);
  13774. }
  13775. duration > 0 ? isFrom ? el.animateFrom(props, {
  13776. duration: duration,
  13777. delay: animationDelay || 0,
  13778. easing: animationEasing,
  13779. done: cb,
  13780. force: !!cb || !!during,
  13781. scope: animationType,
  13782. during: during
  13783. }) : el.animateTo(props, {
  13784. duration: duration,
  13785. delay: animationDelay || 0,
  13786. easing: animationEasing,
  13787. done: cb,
  13788. force: !!cb || !!during,
  13789. setToFinal: true,
  13790. scope: animationType,
  13791. during: during
  13792. }) : ( // FIXME:
  13793. // If `duration` is 0, only the animation on props
  13794. // can be stoped, other animation should be continued?
  13795. // But at present using duration 0 in `animateTo`, `animateFrom`
  13796. // might cause unexpected behavior.
  13797. el.stopAnimation(), // If `isFrom`, the props is the "from" props.
  13798. !isFrom && el.attr(props), cb && cb());
  13799. } else {
  13800. el.stopAnimation();
  13801. !isFrom && el.attr(props); // Call during once.
  13802. during && during(1);
  13803. cb && cb();
  13804. }
  13805. }
  13806. /**
  13807. * Update graphic element properties with or without animation according to the
  13808. * configuration in series.
  13809. *
  13810. * Caution: this method will stop previous animation.
  13811. * So do not use this method to one element twice before
  13812. * animation starts, unless you know what you are doing.
  13813. * @example
  13814. * graphic.updateProps(el, {
  13815. * position: [100, 100]
  13816. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  13817. * // Or
  13818. * graphic.updateProps(el, {
  13819. * position: [100, 100]
  13820. * }, seriesModel, function () { console.log('Animation done!'); });
  13821. */
  13822. function updateProps(el, props, // TODO: TYPE AnimatableModel
  13823. animatableModel, dataIndex, cb, during) {
  13824. animateOrSetProps('update', el, props, animatableModel, dataIndex, cb, during);
  13825. }
  13826. /**
  13827. * Init graphic element properties with or without animation according to the
  13828. * configuration in series.
  13829. *
  13830. * Caution: this method will stop previous animation.
  13831. * So do not use this method to one element twice before
  13832. * animation starts, unless you know what you are doing.
  13833. */
  13834. function initProps(el, props, animatableModel, dataIndex, cb, during) {
  13835. animateOrSetProps('init', el, props, animatableModel, dataIndex, cb, during);
  13836. }
  13837. /**
  13838. * Remove graphic element
  13839. */
  13840. function removeElement(el, props, animatableModel, dataIndex, cb, during) {
  13841. // Don't do remove animation twice.
  13842. if (isElementRemoved(el)) {
  13843. return;
  13844. }
  13845. animateOrSetProps('remove', el, props, animatableModel, dataIndex, cb, during);
  13846. }
  13847. function fadeOutDisplayable(el, animatableModel, dataIndex, done) {
  13848. el.removeTextContent();
  13849. el.removeTextGuideLine();
  13850. removeElement(el, {
  13851. style: {
  13852. opacity: 0
  13853. }
  13854. }, animatableModel, dataIndex, done);
  13855. }
  13856. function removeElementWithFadeOut(el, animatableModel, dataIndex) {
  13857. function doRemove() {
  13858. el.parent && el.parent.remove(el);
  13859. } // Hide label and labelLine first
  13860. // TODO Also use fade out animation?
  13861. if (!el.isGroup) {
  13862. fadeOutDisplayable(el, animatableModel, dataIndex, doRemove);
  13863. } else {
  13864. el.traverse(function (disp) {
  13865. if (!disp.isGroup) {
  13866. // Can invoke doRemove multiple times.
  13867. fadeOutDisplayable(disp, animatableModel, dataIndex, doRemove);
  13868. }
  13869. });
  13870. }
  13871. }
  13872. /**
  13873. * If element is removed.
  13874. * It can determine if element is having remove animation.
  13875. */
  13876. function isElementRemoved(el) {
  13877. if (!el.__zr) {
  13878. return true;
  13879. }
  13880. for (var i = 0; i < el.animators.length; i++) {
  13881. var animator = el.animators[i];
  13882. if (animator.scope === 'remove') {
  13883. return true;
  13884. }
  13885. }
  13886. return false;
  13887. }
  13888. /**
  13889. * Get transform matrix of target (param target),
  13890. * in coordinate of its ancestor (param ancestor)
  13891. *
  13892. * @param target
  13893. * @param [ancestor]
  13894. */
  13895. function getTransform(target, ancestor) {
  13896. var mat = identity([]);
  13897. while (target && target !== ancestor) {
  13898. mul$1(mat, target.getLocalTransform(), mat);
  13899. target = target.parent;
  13900. }
  13901. return mat;
  13902. }
  13903. /**
  13904. * Apply transform to an vertex.
  13905. * @param target [x, y]
  13906. * @param transform Can be:
  13907. * + Transform matrix: like [1, 0, 0, 1, 0, 0]
  13908. * + {position, rotation, scale}, the same as `zrender/Transformable`.
  13909. * @param invert Whether use invert matrix.
  13910. * @return [x, y]
  13911. */
  13912. function applyTransform$1(target, transform, invert$$1) {
  13913. if (transform && !isArrayLike(transform)) {
  13914. transform = Transformable.getLocalTransform(transform);
  13915. }
  13916. if (invert$$1) {
  13917. transform = invert([], transform);
  13918. }
  13919. return applyTransform([], target, transform);
  13920. }
  13921. /**
  13922. * @param direction 'left' 'right' 'top' 'bottom'
  13923. * @param transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  13924. * @param invert Whether use invert matrix.
  13925. * @return Transformed direction. 'left' 'right' 'top' 'bottom'
  13926. */
  13927. function transformDirection(direction, transform, invert$$1) {
  13928. // Pick a base, ensure that transform result will not be (0, 0).
  13929. var hBase = transform[4] === 0 || transform[5] === 0 || transform[0] === 0 ? 1 : Math.abs(2 * transform[4] / transform[0]);
  13930. var vBase = transform[4] === 0 || transform[5] === 0 || transform[2] === 0 ? 1 : Math.abs(2 * transform[4] / transform[2]);
  13931. var vertex = [direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0];
  13932. vertex = applyTransform$1(vertex, transform, invert$$1);
  13933. return Math.abs(vertex[0]) > Math.abs(vertex[1]) ? vertex[0] > 0 ? 'right' : 'left' : vertex[1] > 0 ? 'bottom' : 'top';
  13934. }
  13935. function isNotGroup(el) {
  13936. return !el.isGroup;
  13937. }
  13938. function isPath(el) {
  13939. return el.shape != null;
  13940. }
  13941. /**
  13942. * Apply group transition animation from g1 to g2.
  13943. * If no animatableModel, no animation.
  13944. */
  13945. function groupTransition(g1, g2, animatableModel) {
  13946. if (!g1 || !g2) {
  13947. return;
  13948. }
  13949. function getElMap(g) {
  13950. var elMap = {};
  13951. g.traverse(function (el) {
  13952. if (isNotGroup(el) && el.anid) {
  13953. elMap[el.anid] = el;
  13954. }
  13955. });
  13956. return elMap;
  13957. }
  13958. function getAnimatableProps(el) {
  13959. var obj = {
  13960. x: el.x,
  13961. y: el.y,
  13962. rotation: el.rotation
  13963. };
  13964. if (isPath(el)) {
  13965. obj.shape = extend({}, el.shape);
  13966. }
  13967. return obj;
  13968. }
  13969. var elMap1 = getElMap(g1);
  13970. g2.traverse(function (el) {
  13971. if (isNotGroup(el) && el.anid) {
  13972. var oldEl = elMap1[el.anid];
  13973. if (oldEl) {
  13974. var newProp = getAnimatableProps(el);
  13975. el.attr(getAnimatableProps(oldEl));
  13976. updateProps(el, newProp, animatableModel, getECData(el).dataIndex);
  13977. }
  13978. }
  13979. });
  13980. }
  13981. function clipPointsByRect(points, rect) {
  13982. // FIXME: this way migth be incorrect when grpahic clipped by a corner.
  13983. // and when element have border.
  13984. return map(points, function (point) {
  13985. var x = point[0];
  13986. x = mathMax$3(x, rect.x);
  13987. x = mathMin$3(x, rect.x + rect.width);
  13988. var y = point[1];
  13989. y = mathMax$3(y, rect.y);
  13990. y = mathMin$3(y, rect.y + rect.height);
  13991. return [x, y];
  13992. });
  13993. }
  13994. /**
  13995. * Return a new clipped rect. If rect size are negative, return undefined.
  13996. */
  13997. function clipRectByRect(targetRect, rect) {
  13998. var x = mathMax$3(targetRect.x, rect.x);
  13999. var x2 = mathMin$3(targetRect.x + targetRect.width, rect.x + rect.width);
  14000. var y = mathMax$3(targetRect.y, rect.y);
  14001. var y2 = mathMin$3(targetRect.y + targetRect.height, rect.y + rect.height); // If the total rect is cliped, nothing, including the border,
  14002. // should be painted. So return undefined.
  14003. if (x2 >= x && y2 >= y) {
  14004. return {
  14005. x: x,
  14006. y: y,
  14007. width: x2 - x,
  14008. height: y2 - y
  14009. };
  14010. }
  14011. }
  14012. function createIcon(iconStr, // Support 'image://' or 'path://' or direct svg path.
  14013. opt, rect) {
  14014. var innerOpts = extend({
  14015. rectHover: true
  14016. }, opt);
  14017. var style = innerOpts.style = {
  14018. strokeNoScale: true
  14019. };
  14020. rect = rect || {
  14021. x: -1,
  14022. y: -1,
  14023. width: 2,
  14024. height: 2
  14025. };
  14026. if (iconStr) {
  14027. return iconStr.indexOf('image://') === 0 ? (style.image = iconStr.slice(8), defaults(style, rect), new ZRImage(innerOpts)) : makePath(iconStr.replace('path://', ''), innerOpts, rect, 'center');
  14028. }
  14029. }
  14030. /**
  14031. * Return `true` if the given line (line `a`) and the given polygon
  14032. * are intersect.
  14033. * Note that we do not count colinear as intersect here because no
  14034. * requirement for that. We could do that if required in future.
  14035. */
  14036. function linePolygonIntersect(a1x, a1y, a2x, a2y, points) {
  14037. for (var i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
  14038. var p = points[i];
  14039. if (lineLineIntersect(a1x, a1y, a2x, a2y, p[0], p[1], p2[0], p2[1])) {
  14040. return true;
  14041. }
  14042. p2 = p;
  14043. }
  14044. }
  14045. /**
  14046. * Return `true` if the given two lines (line `a` and line `b`)
  14047. * are intersect.
  14048. * Note that we do not count colinear as intersect here because no
  14049. * requirement for that. We could do that if required in future.
  14050. */
  14051. function lineLineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  14052. // let `vec_m` to be `vec_a2 - vec_a1` and `vec_n` to be `vec_b2 - vec_b1`.
  14053. var mx = a2x - a1x;
  14054. var my = a2y - a1y;
  14055. var nx = b2x - b1x;
  14056. var ny = b2y - b1y; // `vec_m` and `vec_n` are parallel iff
  14057. // exising `k` such that `vec_m = k · vec_n`, equivalent to `vec_m X vec_n = 0`.
  14058. var nmCrossProduct = crossProduct2d(nx, ny, mx, my);
  14059. if (nearZero(nmCrossProduct)) {
  14060. return false;
  14061. } // `vec_m` and `vec_n` are intersect iff
  14062. // existing `p` and `q` in [0, 1] such that `vec_a1 + p * vec_m = vec_b1 + q * vec_n`,
  14063. // such that `q = ((vec_a1 - vec_b1) X vec_m) / (vec_n X vec_m)`
  14064. // and `p = ((vec_a1 - vec_b1) X vec_n) / (vec_n X vec_m)`.
  14065. var b1a1x = a1x - b1x;
  14066. var b1a1y = a1y - b1y;
  14067. var q = crossProduct2d(b1a1x, b1a1y, mx, my) / nmCrossProduct;
  14068. if (q < 0 || q > 1) {
  14069. return false;
  14070. }
  14071. var p = crossProduct2d(b1a1x, b1a1y, nx, ny) / nmCrossProduct;
  14072. if (p < 0 || p > 1) {
  14073. return false;
  14074. }
  14075. return true;
  14076. }
  14077. /**
  14078. * Cross product of 2-dimension vector.
  14079. */
  14080. function crossProduct2d(x1, y1, x2, y2) {
  14081. return x1 * y2 - x2 * y1;
  14082. }
  14083. function nearZero(val) {
  14084. return val <= 1e-6 && val >= -1e-6;
  14085. }
  14086. function setTooltipConfig(opt) {
  14087. var itemTooltipOption = opt.itemTooltipOption;
  14088. var componentModel = opt.componentModel;
  14089. var itemName = opt.itemName;
  14090. var itemTooltipOptionObj = isString(itemTooltipOption) ? {
  14091. formatter: itemTooltipOption
  14092. } : itemTooltipOption;
  14093. var mainType = componentModel.mainType;
  14094. var componentIndex = componentModel.componentIndex;
  14095. var formatterParams = {
  14096. componentType: mainType,
  14097. name: itemName,
  14098. $vars: ['name']
  14099. };
  14100. formatterParams[mainType + 'Index'] = componentIndex;
  14101. var formatterParamsExtra = opt.formatterParamsExtra;
  14102. if (formatterParamsExtra) {
  14103. each$1(keys(formatterParamsExtra), function (key) {
  14104. if (!hasOwn(formatterParams, key)) {
  14105. formatterParams[key] = formatterParamsExtra[key];
  14106. formatterParams.$vars.push(key);
  14107. }
  14108. });
  14109. }
  14110. var ecData = getECData(opt.el);
  14111. ecData.componentMainType = mainType;
  14112. ecData.componentIndex = componentIndex;
  14113. ecData.tooltipConfig = {
  14114. name: itemName,
  14115. option: defaults({
  14116. content: itemName,
  14117. formatterParams: formatterParams
  14118. }, itemTooltipOptionObj)
  14119. };
  14120. } // Register built-in shapes. These shapes might be overwirtten
  14121. // by users, although we do not recommend that.
  14122. registerShape('circle', Circle);
  14123. registerShape('ellipse', Ellipse);
  14124. registerShape('sector', Sector);
  14125. registerShape('ring', Ring);
  14126. registerShape('polygon', Polygon);
  14127. registerShape('polyline', Polyline);
  14128. registerShape('rect', Rect);
  14129. registerShape('line', Line);
  14130. registerShape('bezierCurve', BezierCurve);
  14131. registerShape('arc', Arc);
  14132. var graphic = (Object.freeze || Object)({
  14133. extendShape: extendShape,
  14134. extendPath: extendPath,
  14135. registerShape: registerShape,
  14136. getShapeClass: getShapeClass,
  14137. makePath: makePath,
  14138. makeImage: makeImage,
  14139. mergePath: mergePath,
  14140. resizePath: resizePath,
  14141. subPixelOptimizeLine: subPixelOptimizeLine$1,
  14142. subPixelOptimizeRect: subPixelOptimizeRect$1,
  14143. subPixelOptimize: subPixelOptimize$1,
  14144. updateProps: updateProps,
  14145. initProps: initProps,
  14146. removeElement: removeElement,
  14147. removeElementWithFadeOut: removeElementWithFadeOut,
  14148. isElementRemoved: isElementRemoved,
  14149. getTransform: getTransform,
  14150. applyTransform: applyTransform$1,
  14151. transformDirection: transformDirection,
  14152. groupTransition: groupTransition,
  14153. clipPointsByRect: clipPointsByRect,
  14154. clipRectByRect: clipRectByRect,
  14155. createIcon: createIcon,
  14156. linePolygonIntersect: linePolygonIntersect,
  14157. lineLineIntersect: lineLineIntersect,
  14158. setTooltipConfig: setTooltipConfig,
  14159. Group: Group,
  14160. Image: ZRImage,
  14161. Text: ZRText,
  14162. Circle: Circle,
  14163. Ellipse: Ellipse,
  14164. Sector: Sector,
  14165. Ring: Ring,
  14166. Polygon: Polygon,
  14167. Polyline: Polyline,
  14168. Rect: Rect,
  14169. Line: Line,
  14170. BezierCurve: BezierCurve,
  14171. Arc: Arc,
  14172. IncrementalDisplayable: IncrementalDisplayable,
  14173. CompoundPath: CompoundPath,
  14174. LinearGradient: LinearGradient,
  14175. RadialGradient: RadialGradient,
  14176. BoundingRect: BoundingRect,
  14177. OrientedBoundingRect: OrientedBoundingRect,
  14178. Point: Point,
  14179. Path: Path
  14180. });
  14181. /*
  14182. * Licensed to the Apache Software Foundation (ASF) under one
  14183. * or more contributor license agreements. See the NOTICE file
  14184. * distributed with this work for additional information
  14185. * regarding copyright ownership. The ASF licenses this file
  14186. * to you under the Apache License, Version 2.0 (the
  14187. * "License"); you may not use this file except in compliance
  14188. * with the License. You may obtain a copy of the License at
  14189. *
  14190. * http://www.apache.org/licenses/LICENSE-2.0
  14191. *
  14192. * Unless required by applicable law or agreed to in writing,
  14193. * software distributed under the License is distributed on an
  14194. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14195. * KIND, either express or implied. See the License for the
  14196. * specific language governing permissions and limitations
  14197. * under the License.
  14198. */
  14199. /**
  14200. * AUTO-GENERATED FILE. DO NOT MODIFY.
  14201. */
  14202. /*
  14203. * Licensed to the Apache Software Foundation (ASF) under one
  14204. * or more contributor license agreements. See the NOTICE file
  14205. * distributed with this work for additional information
  14206. * regarding copyright ownership. The ASF licenses this file
  14207. * to you under the Apache License, Version 2.0 (the
  14208. * "License"); you may not use this file except in compliance
  14209. * with the License. You may obtain a copy of the License at
  14210. *
  14211. * http://www.apache.org/licenses/LICENSE-2.0
  14212. *
  14213. * Unless required by applicable law or agreed to in writing,
  14214. * software distributed under the License is distributed on an
  14215. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14216. * KIND, either express or implied. See the License for the
  14217. * specific language governing permissions and limitations
  14218. * under the License.
  14219. */
  14220. var EMPTY_OBJ = {};
  14221. function setLabelText(label, labelTexts) {
  14222. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  14223. var stateName = SPECIAL_STATES[i];
  14224. var text = labelTexts[stateName];
  14225. var state = label.ensureState(stateName);
  14226. state.style = state.style || {};
  14227. state.style.text = text;
  14228. }
  14229. var oldStates = label.currentStates.slice();
  14230. label.clearStates(true);
  14231. label.setStyle({
  14232. text: labelTexts.normal
  14233. });
  14234. label.useStates(oldStates, true);
  14235. }
  14236. function getLabelText(opt, stateModels, interpolatedValue) {
  14237. var labelFetcher = opt.labelFetcher;
  14238. var labelDataIndex = opt.labelDataIndex;
  14239. var labelDimIndex = opt.labelDimIndex;
  14240. var normalModel = stateModels.normal;
  14241. var baseText;
  14242. if (labelFetcher) {
  14243. baseText = labelFetcher.getFormattedLabel(labelDataIndex, 'normal', null, labelDimIndex, normalModel && normalModel.get('formatter'), interpolatedValue != null ? {
  14244. interpolatedValue: interpolatedValue
  14245. } : null);
  14246. }
  14247. if (baseText == null) {
  14248. baseText = isFunction$1(opt.defaultText) ? opt.defaultText(labelDataIndex, opt, interpolatedValue) : opt.defaultText;
  14249. }
  14250. var statesText = {
  14251. normal: baseText
  14252. };
  14253. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  14254. var stateName = SPECIAL_STATES[i];
  14255. var stateModel = stateModels[stateName];
  14256. statesText[stateName] = retrieve2(labelFetcher ? labelFetcher.getFormattedLabel(labelDataIndex, stateName, null, labelDimIndex, stateModel && stateModel.get('formatter')) : null, baseText);
  14257. }
  14258. return statesText;
  14259. }
  14260. function setLabelStyle(targetEl, labelStatesModels, opt, stateSpecified // TODO specified position?
  14261. ) {
  14262. opt = opt || EMPTY_OBJ;
  14263. var isSetOnText = targetEl instanceof ZRText;
  14264. var needsCreateText = false;
  14265. for (var i = 0; i < DISPLAY_STATES.length; i++) {
  14266. var stateModel = labelStatesModels[DISPLAY_STATES[i]];
  14267. if (stateModel && stateModel.getShallow('show')) {
  14268. needsCreateText = true;
  14269. break;
  14270. }
  14271. }
  14272. var textContent = isSetOnText ? targetEl : targetEl.getTextContent();
  14273. if (needsCreateText) {
  14274. if (!isSetOnText) {
  14275. // Reuse the previous
  14276. if (!textContent) {
  14277. textContent = new ZRText();
  14278. targetEl.setTextContent(textContent);
  14279. } // Use same state proxy
  14280. if (targetEl.stateProxy) {
  14281. textContent.stateProxy = targetEl.stateProxy;
  14282. }
  14283. }
  14284. var labelStatesTexts = getLabelText(opt, labelStatesModels);
  14285. var normalModel = labelStatesModels.normal;
  14286. var showNormal = !!normalModel.getShallow('show');
  14287. var normalStyle = createTextStyle(normalModel, stateSpecified && stateSpecified.normal, opt, false, !isSetOnText);
  14288. normalStyle.text = labelStatesTexts.normal;
  14289. if (!isSetOnText) {
  14290. // Always create new
  14291. targetEl.setTextConfig(createTextConfig(normalModel, opt, false));
  14292. }
  14293. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  14294. var stateName = SPECIAL_STATES[i];
  14295. var stateModel = labelStatesModels[stateName];
  14296. if (stateModel) {
  14297. var stateObj = textContent.ensureState(stateName);
  14298. var stateShow = !!retrieve2(stateModel.getShallow('show'), showNormal);
  14299. if (stateShow !== showNormal) {
  14300. stateObj.ignore = !stateShow;
  14301. }
  14302. stateObj.style = createTextStyle(stateModel, stateSpecified && stateSpecified[stateName], opt, true, !isSetOnText);
  14303. stateObj.style.text = labelStatesTexts[stateName];
  14304. if (!isSetOnText) {
  14305. var targetElEmphasisState = targetEl.ensureState(stateName);
  14306. targetElEmphasisState.textConfig = createTextConfig(stateModel, opt, true);
  14307. }
  14308. }
  14309. } // PENDING: if there is many requirements that emphasis position
  14310. // need to be different from normal position, we might consider
  14311. // auto slient is those cases.
  14312. textContent.silent = !!normalModel.getShallow('silent'); // Keep x and y
  14313. if (textContent.style.x != null) {
  14314. normalStyle.x = textContent.style.x;
  14315. }
  14316. if (textContent.style.y != null) {
  14317. normalStyle.y = textContent.style.y;
  14318. }
  14319. textContent.ignore = !showNormal; // Always create new style.
  14320. textContent.useStyle(normalStyle);
  14321. textContent.dirty();
  14322. if (opt.enableTextSetter) {
  14323. labelInner(textContent).setLabelText = function (interpolatedValue) {
  14324. var labelStatesTexts = getLabelText(opt, labelStatesModels, interpolatedValue);
  14325. setLabelText(textContent, labelStatesTexts);
  14326. };
  14327. }
  14328. } else if (textContent) {
  14329. // Not display rich text.
  14330. textContent.ignore = true;
  14331. }
  14332. targetEl.dirty();
  14333. }
  14334. function getLabelStatesModels(itemModel, labelName) {
  14335. labelName = labelName || 'label';
  14336. var statesModels = {
  14337. normal: itemModel.getModel(labelName)
  14338. };
  14339. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  14340. var stateName = SPECIAL_STATES[i];
  14341. statesModels[stateName] = itemModel.getModel([stateName, labelName]);
  14342. }
  14343. return statesModels;
  14344. }
  14345. /**
  14346. * Set basic textStyle properties.
  14347. */
  14348. function createTextStyle(textStyleModel, specifiedTextStyle, // Fixed style in the code. Can't be set by model.
  14349. opt, isNotNormal, isAttached // If text is attached on an element. If so, auto color will handling in zrender.
  14350. ) {
  14351. var textStyle = {};
  14352. setTextStyleCommon(textStyle, textStyleModel, opt, isNotNormal, isAttached);
  14353. specifiedTextStyle && extend(textStyle, specifiedTextStyle); // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
  14354. return textStyle;
  14355. }
  14356. function createTextConfig(textStyleModel, opt, isNotNormal) {
  14357. opt = opt || {};
  14358. var textConfig = {};
  14359. var labelPosition;
  14360. var labelRotate = textStyleModel.getShallow('rotate');
  14361. var labelDistance = retrieve2(textStyleModel.getShallow('distance'), isNotNormal ? null : 5);
  14362. var labelOffset = textStyleModel.getShallow('offset');
  14363. labelPosition = textStyleModel.getShallow('position') || (isNotNormal ? null : 'inside'); // 'outside' is not a valid zr textPostion value, but used
  14364. // in bar series, and magric type should be considered.
  14365. labelPosition === 'outside' && (labelPosition = opt.defaultOutsidePosition || 'top');
  14366. if (labelPosition != null) {
  14367. textConfig.position = labelPosition;
  14368. }
  14369. if (labelOffset != null) {
  14370. textConfig.offset = labelOffset;
  14371. }
  14372. if (labelRotate != null) {
  14373. labelRotate *= Math.PI / 180;
  14374. textConfig.rotation = labelRotate;
  14375. }
  14376. if (labelDistance != null) {
  14377. textConfig.distance = labelDistance;
  14378. } // fill and auto is determined by the color of path fill if it's not specified by developers.
  14379. textConfig.outsideFill = textStyleModel.get('color') === 'inherit' ? opt.inheritColor || null : 'auto';
  14380. return textConfig;
  14381. }
  14382. /**
  14383. * The uniform entry of set text style, that is, retrieve style definitions
  14384. * from `model` and set to `textStyle` object.
  14385. *
  14386. * Never in merge mode, but in overwrite mode, that is, all of the text style
  14387. * properties will be set. (Consider the states of normal and emphasis and
  14388. * default value can be adopted, merge would make the logic too complicated
  14389. * to manage.)
  14390. */
  14391. function setTextStyleCommon(textStyle, textStyleModel, opt, isNotNormal, isAttached) {
  14392. // Consider there will be abnormal when merge hover style to normal style if given default value.
  14393. opt = opt || EMPTY_OBJ;
  14394. var ecModel = textStyleModel.ecModel;
  14395. var globalTextStyle = ecModel && ecModel.option.textStyle; // Consider case:
  14396. // {
  14397. // data: [{
  14398. // value: 12,
  14399. // label: {
  14400. // rich: {
  14401. // // no 'a' here but using parent 'a'.
  14402. // }
  14403. // }
  14404. // }],
  14405. // rich: {
  14406. // a: { ... }
  14407. // }
  14408. // }
  14409. var richItemNames = getRichItemNames(textStyleModel);
  14410. var richResult;
  14411. if (richItemNames) {
  14412. richResult = {};
  14413. for (var name_1 in richItemNames) {
  14414. if (richItemNames.hasOwnProperty(name_1)) {
  14415. // Cascade is supported in rich.
  14416. var richTextStyle = textStyleModel.getModel(['rich', name_1]); // In rich, never `disableBox`.
  14417. // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
  14418. // the default color `'blue'` will not be adopted if no color declared in `rich`.
  14419. // That might confuses users. So probably we should put `textStyleModel` as the
  14420. // root ancestor of the `richTextStyle`. But that would be a break change.
  14421. setTokenTextStyle(richResult[name_1] = {}, richTextStyle, globalTextStyle, opt, isNotNormal, isAttached, false, true);
  14422. }
  14423. }
  14424. }
  14425. if (richResult) {
  14426. textStyle.rich = richResult;
  14427. }
  14428. var overflow = textStyleModel.get('overflow');
  14429. if (overflow) {
  14430. textStyle.overflow = overflow;
  14431. }
  14432. var margin = textStyleModel.get('minMargin');
  14433. if (margin != null) {
  14434. textStyle.margin = margin;
  14435. }
  14436. setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isNotNormal, isAttached, true, false);
  14437. } // Consider case:
  14438. // {
  14439. // data: [{
  14440. // value: 12,
  14441. // label: {
  14442. // rich: {
  14443. // // no 'a' here but using parent 'a'.
  14444. // }
  14445. // }
  14446. // }],
  14447. // rich: {
  14448. // a: { ... }
  14449. // }
  14450. // }
  14451. // TODO TextStyleModel
  14452. function getRichItemNames(textStyleModel) {
  14453. // Use object to remove duplicated names.
  14454. var richItemNameMap;
  14455. while (textStyleModel && textStyleModel !== textStyleModel.ecModel) {
  14456. var rich = (textStyleModel.option || EMPTY_OBJ).rich;
  14457. if (rich) {
  14458. richItemNameMap = richItemNameMap || {};
  14459. var richKeys = keys(rich);
  14460. for (var i = 0; i < richKeys.length; i++) {
  14461. var richKey = richKeys[i];
  14462. richItemNameMap[richKey] = 1;
  14463. }
  14464. }
  14465. textStyleModel = textStyleModel.parentModel;
  14466. }
  14467. return richItemNameMap;
  14468. }
  14469. var TEXT_PROPS_WITH_GLOBAL = ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'textShadowColor', 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY'];
  14470. var TEXT_PROPS_SELF = ['align', 'lineHeight', 'width', 'height', 'tag', 'verticalAlign'];
  14471. var TEXT_PROPS_BOX = ['padding', 'borderWidth', 'borderRadius', 'borderDashOffset', 'backgroundColor', 'borderColor', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'];
  14472. function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isNotNormal, isAttached, isBlock, inRich) {
  14473. // In merge mode, default value should not be given.
  14474. globalTextStyle = !isNotNormal && globalTextStyle || EMPTY_OBJ;
  14475. var inheritColor = opt && opt.inheritColor;
  14476. var fillColor = textStyleModel.getShallow('color');
  14477. var strokeColor = textStyleModel.getShallow('textBorderColor');
  14478. var opacity = retrieve2(textStyleModel.getShallow('opacity'), globalTextStyle.opacity);
  14479. if (fillColor === 'inherit' || fillColor === 'auto') {
  14480. {
  14481. if (fillColor === 'auto') {
  14482. deprecateReplaceLog('color: \'auto\'', 'color: \'inherit\'');
  14483. }
  14484. }
  14485. if (inheritColor) {
  14486. fillColor = inheritColor;
  14487. } else {
  14488. fillColor = null;
  14489. }
  14490. }
  14491. if (strokeColor === 'inherit' || strokeColor === 'auto') {
  14492. {
  14493. if (strokeColor === 'auto') {
  14494. deprecateReplaceLog('color: \'auto\'', 'color: \'inherit\'');
  14495. }
  14496. }
  14497. if (inheritColor) {
  14498. strokeColor = inheritColor;
  14499. } else {
  14500. strokeColor = null;
  14501. }
  14502. }
  14503. if (!isAttached) {
  14504. // Only use default global textStyle.color if text is individual.
  14505. // Otherwise it will use the strategy of attached text color because text may be on a path.
  14506. fillColor = fillColor || globalTextStyle.color;
  14507. strokeColor = strokeColor || globalTextStyle.textBorderColor;
  14508. }
  14509. if (fillColor != null) {
  14510. textStyle.fill = fillColor;
  14511. }
  14512. if (strokeColor != null) {
  14513. textStyle.stroke = strokeColor;
  14514. }
  14515. var textBorderWidth = retrieve2(textStyleModel.getShallow('textBorderWidth'), globalTextStyle.textBorderWidth);
  14516. if (textBorderWidth != null) {
  14517. textStyle.lineWidth = textBorderWidth;
  14518. }
  14519. var textBorderType = retrieve2(textStyleModel.getShallow('textBorderType'), globalTextStyle.textBorderType);
  14520. if (textBorderType != null) {
  14521. textStyle.lineDash = textBorderType;
  14522. }
  14523. var textBorderDashOffset = retrieve2(textStyleModel.getShallow('textBorderDashOffset'), globalTextStyle.textBorderDashOffset);
  14524. if (textBorderDashOffset != null) {
  14525. textStyle.lineDashOffset = textBorderDashOffset;
  14526. }
  14527. if (!isNotNormal && opacity == null && !inRich) {
  14528. opacity = opt && opt.defaultOpacity;
  14529. }
  14530. if (opacity != null) {
  14531. textStyle.opacity = opacity;
  14532. } // TODO
  14533. if (!isNotNormal && !isAttached) {
  14534. // Set default finally.
  14535. if (textStyle.fill == null && opt.inheritColor) {
  14536. textStyle.fill = opt.inheritColor;
  14537. }
  14538. } // Do not use `getFont` here, because merge should be supported, where
  14539. // part of these properties may be changed in emphasis style, and the
  14540. // others should remain their original value got from normal style.
  14541. for (var i = 0; i < TEXT_PROPS_WITH_GLOBAL.length; i++) {
  14542. var key = TEXT_PROPS_WITH_GLOBAL[i];
  14543. var val = retrieve2(textStyleModel.getShallow(key), globalTextStyle[key]);
  14544. if (val != null) {
  14545. textStyle[key] = val;
  14546. }
  14547. }
  14548. for (var i = 0; i < TEXT_PROPS_SELF.length; i++) {
  14549. var key = TEXT_PROPS_SELF[i];
  14550. var val = textStyleModel.getShallow(key);
  14551. if (val != null) {
  14552. textStyle[key] = val;
  14553. }
  14554. }
  14555. if (textStyle.verticalAlign == null) {
  14556. var baseline = textStyleModel.getShallow('baseline');
  14557. if (baseline != null) {
  14558. textStyle.verticalAlign = baseline;
  14559. }
  14560. }
  14561. if (!isBlock || !opt.disableBox) {
  14562. for (var i = 0; i < TEXT_PROPS_BOX.length; i++) {
  14563. var key = TEXT_PROPS_BOX[i];
  14564. var val = textStyleModel.getShallow(key);
  14565. if (val != null) {
  14566. textStyle[key] = val;
  14567. }
  14568. }
  14569. var borderType = textStyleModel.getShallow('borderType');
  14570. if (borderType != null) {
  14571. textStyle.borderDash = borderType;
  14572. }
  14573. if ((textStyle.backgroundColor === 'auto' || textStyle.backgroundColor === 'inherit') && inheritColor) {
  14574. {
  14575. if (textStyle.backgroundColor === 'auto') {
  14576. deprecateReplaceLog('backgroundColor: \'auto\'', 'backgroundColor: \'inherit\'');
  14577. }
  14578. }
  14579. textStyle.backgroundColor = inheritColor;
  14580. }
  14581. if ((textStyle.borderColor === 'auto' || textStyle.borderColor === 'inherit') && inheritColor) {
  14582. {
  14583. if (textStyle.borderColor === 'auto') {
  14584. deprecateReplaceLog('borderColor: \'auto\'', 'borderColor: \'inherit\'');
  14585. }
  14586. }
  14587. textStyle.borderColor = inheritColor;
  14588. }
  14589. }
  14590. }
  14591. function getFont(opt, ecModel) {
  14592. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  14593. return trim([// FIXME in node-canvas fontWeight is before fontStyle
  14594. opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '', opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '', (opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px', opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'].join(' '));
  14595. }
  14596. var labelInner = makeInner();
  14597. function setLabelValueAnimation(label, labelStatesModels, value, getDefaultText) {
  14598. if (!label) {
  14599. return;
  14600. }
  14601. var obj = labelInner(label);
  14602. obj.prevValue = obj.value;
  14603. obj.value = value;
  14604. var normalLabelModel = labelStatesModels.normal;
  14605. obj.valueAnimation = normalLabelModel.get('valueAnimation');
  14606. if (obj.valueAnimation) {
  14607. obj.precision = normalLabelModel.get('precision');
  14608. obj.defaultInterpolatedText = getDefaultText;
  14609. obj.statesModels = labelStatesModels;
  14610. }
  14611. }
  14612. function animateLabelValue(textEl, dataIndex, data, animatableModel, labelFetcher) {
  14613. var labelInnerStore = labelInner(textEl);
  14614. if (!labelInnerStore.valueAnimation) {
  14615. return;
  14616. }
  14617. var defaultInterpolatedText = labelInnerStore.defaultInterpolatedText; // Consider the case that being animating, do not use the `obj.value`,
  14618. // Otherwise it will jump to the `obj.value` when this new animation started.
  14619. var currValue = retrieve2(labelInnerStore.interpolatedValue, labelInnerStore.prevValue);
  14620. var targetValue = labelInnerStore.value;
  14621. function during(percent) {
  14622. var interpolated = interpolateRawValues(data, labelInnerStore.precision, currValue, targetValue, percent);
  14623. labelInnerStore.interpolatedValue = percent === 1 ? null : interpolated;
  14624. var labelText = getLabelText({
  14625. labelDataIndex: dataIndex,
  14626. labelFetcher: labelFetcher,
  14627. defaultText: defaultInterpolatedText ? defaultInterpolatedText(interpolated) : interpolated + ''
  14628. }, labelInnerStore.statesModels, interpolated);
  14629. setLabelText(textEl, labelText);
  14630. }
  14631. (currValue == null ? initProps : updateProps)(textEl, {}, animatableModel, dataIndex, null, during);
  14632. }
  14633. function enableLayoutLayoutFeatures(el, dataIndex, dataType) {
  14634. getECData(el).dataIndex = dataIndex;
  14635. getECData(el).dataType = dataType;
  14636. }
  14637. /*
  14638. * Licensed to the Apache Software Foundation (ASF) under one
  14639. * or more contributor license agreements. See the NOTICE file
  14640. * distributed with this work for additional information
  14641. * regarding copyright ownership. The ASF licenses this file
  14642. * to you under the Apache License, Version 2.0 (the
  14643. * "License"); you may not use this file except in compliance
  14644. * with the License. You may obtain a copy of the License at
  14645. *
  14646. * http://www.apache.org/licenses/LICENSE-2.0
  14647. *
  14648. * Unless required by applicable law or agreed to in writing,
  14649. * software distributed under the License is distributed on an
  14650. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14651. * KIND, either express or implied. See the License for the
  14652. * specific language governing permissions and limitations
  14653. * under the License.
  14654. */
  14655. /**
  14656. * AUTO-GENERATED FILE. DO NOT MODIFY.
  14657. */
  14658. /*
  14659. * Licensed to the Apache Software Foundation (ASF) under one
  14660. * or more contributor license agreements. See the NOTICE file
  14661. * distributed with this work for additional information
  14662. * regarding copyright ownership. The ASF licenses this file
  14663. * to you under the Apache License, Version 2.0 (the
  14664. * "License"); you may not use this file except in compliance
  14665. * with the License. You may obtain a copy of the License at
  14666. *
  14667. * http://www.apache.org/licenses/LICENSE-2.0
  14668. *
  14669. * Unless required by applicable law or agreed to in writing,
  14670. * software distributed under the License is distributed on an
  14671. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14672. * KIND, either express or implied. See the License for the
  14673. * specific language governing permissions and limitations
  14674. * under the License.
  14675. */
  14676. var PATH_COLOR = ['textStyle', 'color']; // TODO Performance improvement?
  14677. var tmpRichText = new ZRText();
  14678. var TextStyleMixin =
  14679. /** @class */
  14680. function () {
  14681. function TextStyleMixin() {}
  14682. /**
  14683. * Get color property or get color from option.textStyle.color
  14684. */
  14685. // TODO Callback
  14686. TextStyleMixin.prototype.getTextColor = function (isEmphasis) {
  14687. var ecModel = this.ecModel;
  14688. return this.getShallow('color') || (!isEmphasis && ecModel ? ecModel.get(PATH_COLOR) : null);
  14689. };
  14690. /**
  14691. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  14692. * @return {string}
  14693. */
  14694. TextStyleMixin.prototype.getFont = function () {
  14695. return getFont({
  14696. fontStyle: this.getShallow('fontStyle'),
  14697. fontWeight: this.getShallow('fontWeight'),
  14698. fontSize: this.getShallow('fontSize'),
  14699. fontFamily: this.getShallow('fontFamily')
  14700. }, this.ecModel);
  14701. };
  14702. TextStyleMixin.prototype.getTextRect = function (text) {
  14703. tmpRichText.useStyle({
  14704. text: text,
  14705. fontStyle: this.getShallow('fontStyle'),
  14706. fontWeight: this.getShallow('fontWeight'),
  14707. fontSize: this.getShallow('fontSize'),
  14708. fontFamily: this.getShallow('fontFamily'),
  14709. verticalAlign: this.getShallow('verticalAlign') || this.getShallow('baseline'),
  14710. padding: this.getShallow('padding'),
  14711. lineHeight: this.getShallow('lineHeight'),
  14712. rich: this.getShallow('rich')
  14713. });
  14714. tmpRichText.update();
  14715. return tmpRichText.getBoundingRect();
  14716. };
  14717. return TextStyleMixin;
  14718. }();
  14719. /*
  14720. * Licensed to the Apache Software Foundation (ASF) under one
  14721. * or more contributor license agreements. See the NOTICE file
  14722. * distributed with this work for additional information
  14723. * regarding copyright ownership. The ASF licenses this file
  14724. * to you under the Apache License, Version 2.0 (the
  14725. * "License"); you may not use this file except in compliance
  14726. * with the License. You may obtain a copy of the License at
  14727. *
  14728. * http://www.apache.org/licenses/LICENSE-2.0
  14729. *
  14730. * Unless required by applicable law or agreed to in writing,
  14731. * software distributed under the License is distributed on an
  14732. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14733. * KIND, either express or implied. See the License for the
  14734. * specific language governing permissions and limitations
  14735. * under the License.
  14736. */
  14737. /**
  14738. * AUTO-GENERATED FILE. DO NOT MODIFY.
  14739. */
  14740. /*
  14741. * Licensed to the Apache Software Foundation (ASF) under one
  14742. * or more contributor license agreements. See the NOTICE file
  14743. * distributed with this work for additional information
  14744. * regarding copyright ownership. The ASF licenses this file
  14745. * to you under the Apache License, Version 2.0 (the
  14746. * "License"); you may not use this file except in compliance
  14747. * with the License. You may obtain a copy of the License at
  14748. *
  14749. * http://www.apache.org/licenses/LICENSE-2.0
  14750. *
  14751. * Unless required by applicable law or agreed to in writing,
  14752. * software distributed under the License is distributed on an
  14753. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14754. * KIND, either express or implied. See the License for the
  14755. * specific language governing permissions and limitations
  14756. * under the License.
  14757. */
  14758. var LINE_STYLE_KEY_MAP = [['lineWidth', 'width'], ['stroke', 'color'], ['opacity'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor'], ['lineDash', 'type'], ['lineDashOffset', 'dashOffset'], ['lineCap', 'cap'], ['lineJoin', 'join'], ['miterLimit'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  14759. // So do not transfer decal directly.
  14760. ];
  14761. var getLineStyle = makeStyleMapper(LINE_STYLE_KEY_MAP);
  14762. var LineStyleMixin =
  14763. /** @class */
  14764. function () {
  14765. function LineStyleMixin() {}
  14766. LineStyleMixin.prototype.getLineStyle = function (excludes) {
  14767. return getLineStyle(this, excludes);
  14768. };
  14769. return LineStyleMixin;
  14770. }();
  14771. /*
  14772. * Licensed to the Apache Software Foundation (ASF) under one
  14773. * or more contributor license agreements. See the NOTICE file
  14774. * distributed with this work for additional information
  14775. * regarding copyright ownership. The ASF licenses this file
  14776. * to you under the Apache License, Version 2.0 (the
  14777. * "License"); you may not use this file except in compliance
  14778. * with the License. You may obtain a copy of the License at
  14779. *
  14780. * http://www.apache.org/licenses/LICENSE-2.0
  14781. *
  14782. * Unless required by applicable law or agreed to in writing,
  14783. * software distributed under the License is distributed on an
  14784. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14785. * KIND, either express or implied. See the License for the
  14786. * specific language governing permissions and limitations
  14787. * under the License.
  14788. */
  14789. /**
  14790. * AUTO-GENERATED FILE. DO NOT MODIFY.
  14791. */
  14792. /*
  14793. * Licensed to the Apache Software Foundation (ASF) under one
  14794. * or more contributor license agreements. See the NOTICE file
  14795. * distributed with this work for additional information
  14796. * regarding copyright ownership. The ASF licenses this file
  14797. * to you under the Apache License, Version 2.0 (the
  14798. * "License"); you may not use this file except in compliance
  14799. * with the License. You may obtain a copy of the License at
  14800. *
  14801. * http://www.apache.org/licenses/LICENSE-2.0
  14802. *
  14803. * Unless required by applicable law or agreed to in writing,
  14804. * software distributed under the License is distributed on an
  14805. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14806. * KIND, either express or implied. See the License for the
  14807. * specific language governing permissions and limitations
  14808. * under the License.
  14809. */
  14810. var ITEM_STYLE_KEY_MAP = [['fill', 'color'], ['stroke', 'borderColor'], ['lineWidth', 'borderWidth'], ['opacity'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor'], ['lineDash', 'borderType'], ['lineDashOffset', 'borderDashOffset'], ['lineCap', 'borderCap'], ['lineJoin', 'borderJoin'], ['miterLimit', 'borderMiterLimit'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  14811. // So do not transfer decal directly.
  14812. ];
  14813. var getItemStyle = makeStyleMapper(ITEM_STYLE_KEY_MAP);
  14814. var ItemStyleMixin =
  14815. /** @class */
  14816. function () {
  14817. function ItemStyleMixin() {}
  14818. ItemStyleMixin.prototype.getItemStyle = function (excludes, includes) {
  14819. return getItemStyle(this, excludes, includes);
  14820. };
  14821. return ItemStyleMixin;
  14822. }();
  14823. /*
  14824. * Licensed to the Apache Software Foundation (ASF) under one
  14825. * or more contributor license agreements. See the NOTICE file
  14826. * distributed with this work for additional information
  14827. * regarding copyright ownership. The ASF licenses this file
  14828. * to you under the Apache License, Version 2.0 (the
  14829. * "License"); you may not use this file except in compliance
  14830. * with the License. You may obtain a copy of the License at
  14831. *
  14832. * http://www.apache.org/licenses/LICENSE-2.0
  14833. *
  14834. * Unless required by applicable law or agreed to in writing,
  14835. * software distributed under the License is distributed on an
  14836. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14837. * KIND, either express or implied. See the License for the
  14838. * specific language governing permissions and limitations
  14839. * under the License.
  14840. */
  14841. /**
  14842. * AUTO-GENERATED FILE. DO NOT MODIFY.
  14843. */
  14844. /*
  14845. * Licensed to the Apache Software Foundation (ASF) under one
  14846. * or more contributor license agreements. See the NOTICE file
  14847. * distributed with this work for additional information
  14848. * regarding copyright ownership. The ASF licenses this file
  14849. * to you under the Apache License, Version 2.0 (the
  14850. * "License"); you may not use this file except in compliance
  14851. * with the License. You may obtain a copy of the License at
  14852. *
  14853. * http://www.apache.org/licenses/LICENSE-2.0
  14854. *
  14855. * Unless required by applicable law or agreed to in writing,
  14856. * software distributed under the License is distributed on an
  14857. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  14858. * KIND, either express or implied. See the License for the
  14859. * specific language governing permissions and limitations
  14860. * under the License.
  14861. */
  14862. var Model =
  14863. /** @class */
  14864. function () {
  14865. function Model(option, parentModel, ecModel) {
  14866. this.parentModel = parentModel;
  14867. this.ecModel = ecModel;
  14868. this.option = option; // Simple optimization
  14869. // if (this.init) {
  14870. // if (arguments.length <= 4) {
  14871. // this.init(option, parentModel, ecModel, extraOpt);
  14872. // }
  14873. // else {
  14874. // this.init.apply(this, arguments);
  14875. // }
  14876. // }
  14877. }
  14878. Model.prototype.init = function (option, parentModel, ecModel) {
  14879. var rest = [];
  14880. for (var _i = 3; _i < arguments.length; _i++) {
  14881. rest[_i - 3] = arguments[_i];
  14882. }
  14883. };
  14884. /**
  14885. * Merge the input option to me.
  14886. */
  14887. Model.prototype.mergeOption = function (option, ecModel) {
  14888. merge(this.option, option, true);
  14889. }; // `path` can be 'xxx.yyy.zzz', so the return value type have to be `ModelOption`
  14890. // TODO: TYPE strict key check?
  14891. // get(path: string | string[], ignoreParent?: boolean): ModelOption;
  14892. Model.prototype.get = function (path, ignoreParent) {
  14893. if (path == null) {
  14894. return this.option;
  14895. }
  14896. return this._doGet(this.parsePath(path), !ignoreParent && this.parentModel);
  14897. };
  14898. Model.prototype.getShallow = function (key, ignoreParent) {
  14899. var option = this.option;
  14900. var val = option == null ? option : option[key];
  14901. if (val == null && !ignoreParent) {
  14902. var parentModel = this.parentModel;
  14903. if (parentModel) {
  14904. // FIXME:TS do not know how to make it works
  14905. val = parentModel.getShallow(key);
  14906. }
  14907. }
  14908. return val;
  14909. }; // `path` can be 'xxx.yyy.zzz', so the return value type have to be `Model<ModelOption>`
  14910. // getModel(path: string | string[], parentModel?: Model): Model;
  14911. // TODO 'xxx.yyy.zzz' is deprecated
  14912. Model.prototype.getModel = function (path, parentModel) {
  14913. var hasPath = path != null;
  14914. var pathFinal = hasPath ? this.parsePath(path) : null;
  14915. var obj = hasPath ? this._doGet(pathFinal) : this.option;
  14916. parentModel = parentModel || this.parentModel && this.parentModel.getModel(this.resolveParentPath(pathFinal));
  14917. return new Model(obj, parentModel, this.ecModel);
  14918. };
  14919. /**
  14920. * Squash option stack into one.
  14921. * parentModel will be removed after squashed.
  14922. *
  14923. * NOTE: resolveParentPath will not be applied here for simplicity. DON'T use this function
  14924. * if resolveParentPath is modified.
  14925. *
  14926. * @param deepMerge If do deep merge. Default to be false.
  14927. */
  14928. // squash(
  14929. // deepMerge?: boolean,
  14930. // handleCallback?: (func: () => object) => object
  14931. // ) {
  14932. // const optionStack = [];
  14933. // let model: Model = this;
  14934. // while (model) {
  14935. // if (model.option) {
  14936. // optionStack.push(model.option);
  14937. // }
  14938. // model = model.parentModel;
  14939. // }
  14940. // const newOption = {} as Opt;
  14941. // let option;
  14942. // while (option = optionStack.pop()) { // Top down merge
  14943. // if (isFunction(option) && handleCallback) {
  14944. // option = handleCallback(option);
  14945. // }
  14946. // if (deepMerge) {
  14947. // merge(newOption, option);
  14948. // }
  14949. // else {
  14950. // extend(newOption, option);
  14951. // }
  14952. // }
  14953. // // Remove parentModel
  14954. // this.option = newOption;
  14955. // this.parentModel = null;
  14956. // }
  14957. /**
  14958. * If model has option
  14959. */
  14960. Model.prototype.isEmpty = function () {
  14961. return this.option == null;
  14962. };
  14963. Model.prototype.restoreData = function () {}; // Pending
  14964. Model.prototype.clone = function () {
  14965. var Ctor = this.constructor;
  14966. return new Ctor(clone(this.option));
  14967. }; // setReadOnly(properties): void {
  14968. // clazzUtil.setReadOnly(this, properties);
  14969. // }
  14970. // If path is null/undefined, return null/undefined.
  14971. Model.prototype.parsePath = function (path) {
  14972. if (typeof path === 'string') {
  14973. return path.split('.');
  14974. }
  14975. return path;
  14976. }; // Resolve path for parent. Perhaps useful when parent use a different property.
  14977. // Default to be a identity resolver.
  14978. // Can be modified to a different resolver.
  14979. Model.prototype.resolveParentPath = function (path) {
  14980. return path;
  14981. }; // FIXME:TS check whether put this method here
  14982. Model.prototype.isAnimationEnabled = function () {
  14983. if (!env.node && this.option) {
  14984. if (this.option.animation != null) {
  14985. return !!this.option.animation;
  14986. } else if (this.parentModel) {
  14987. return this.parentModel.isAnimationEnabled();
  14988. }
  14989. }
  14990. };
  14991. Model.prototype._doGet = function (pathArr, parentModel) {
  14992. var obj = this.option;
  14993. if (!pathArr) {
  14994. return obj;
  14995. }
  14996. for (var i = 0; i < pathArr.length; i++) {
  14997. // Ignore empty
  14998. if (!pathArr[i]) {
  14999. continue;
  15000. } // obj could be number/string/... (like 0)
  15001. obj = obj && typeof obj === 'object' ? obj[pathArr[i]] : null;
  15002. if (obj == null) {
  15003. break;
  15004. }
  15005. }
  15006. if (obj == null && parentModel) {
  15007. obj = parentModel._doGet(this.resolveParentPath(pathArr), parentModel.parentModel);
  15008. }
  15009. return obj;
  15010. };
  15011. return Model;
  15012. }(); // Enable Model.extend.
  15013. enableClassExtend(Model);
  15014. enableClassCheck(Model);
  15015. mixin(Model, LineStyleMixin);
  15016. mixin(Model, ItemStyleMixin);
  15017. mixin(Model, AreaStyleMixin);
  15018. mixin(Model, TextStyleMixin);
  15019. /*
  15020. * Licensed to the Apache Software Foundation (ASF) under one
  15021. * or more contributor license agreements. See the NOTICE file
  15022. * distributed with this work for additional information
  15023. * regarding copyright ownership. The ASF licenses this file
  15024. * to you under the Apache License, Version 2.0 (the
  15025. * "License"); you may not use this file except in compliance
  15026. * with the License. You may obtain a copy of the License at
  15027. *
  15028. * http://www.apache.org/licenses/LICENSE-2.0
  15029. *
  15030. * Unless required by applicable law or agreed to in writing,
  15031. * software distributed under the License is distributed on an
  15032. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15033. * KIND, either express or implied. See the License for the
  15034. * specific language governing permissions and limitations
  15035. * under the License.
  15036. */
  15037. /**
  15038. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15039. */
  15040. /*
  15041. * Licensed to the Apache Software Foundation (ASF) under one
  15042. * or more contributor license agreements. See the NOTICE file
  15043. * distributed with this work for additional information
  15044. * regarding copyright ownership. The ASF licenses this file
  15045. * to you under the Apache License, Version 2.0 (the
  15046. * "License"); you may not use this file except in compliance
  15047. * with the License. You may obtain a copy of the License at
  15048. *
  15049. * http://www.apache.org/licenses/LICENSE-2.0
  15050. *
  15051. * Unless required by applicable law or agreed to in writing,
  15052. * software distributed under the License is distributed on an
  15053. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15054. * KIND, either express or implied. See the License for the
  15055. * specific language governing permissions and limitations
  15056. * under the License.
  15057. */
  15058. var base = Math.round(Math.random() * 10);
  15059. /**
  15060. * @public
  15061. * @param {string} type
  15062. * @return {string}
  15063. */
  15064. function getUID(type) {
  15065. // Considering the case of crossing js context,
  15066. // use Math.random to make id as unique as possible.
  15067. return [type || '', base++].join('_');
  15068. }
  15069. /**
  15070. * Implements `SubTypeDefaulterManager` for `target`.
  15071. */
  15072. function enableSubTypeDefaulter(target) {
  15073. var subTypeDefaulters = {};
  15074. target.registerSubTypeDefaulter = function (componentType, defaulter) {
  15075. var componentTypeInfo = parseClassType(componentType);
  15076. subTypeDefaulters[componentTypeInfo.main] = defaulter;
  15077. };
  15078. target.determineSubType = function (componentType, option) {
  15079. var type = option.type;
  15080. if (!type) {
  15081. var componentTypeMain = parseClassType(componentType).main;
  15082. if (target.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  15083. type = subTypeDefaulters[componentTypeMain](option);
  15084. }
  15085. }
  15086. return type;
  15087. };
  15088. }
  15089. /**
  15090. * Implements `TopologicalTravelable<any>` for `entity`.
  15091. *
  15092. * Topological travel on Activity Network (Activity On Vertices).
  15093. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  15094. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  15095. * If there is circular dependencey, Error will be thrown.
  15096. */
  15097. function enableTopologicalTravel(entity, dependencyGetter) {
  15098. /**
  15099. * @param targetNameList Target Component type list.
  15100. * Can be ['aa', 'bb', 'aa.xx']
  15101. * @param fullNameList By which we can build dependency graph.
  15102. * @param callback Params: componentType, dependencies.
  15103. * @param context Scope of callback.
  15104. */
  15105. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  15106. if (!targetNameList.length) {
  15107. return;
  15108. }
  15109. var result = makeDepndencyGraph(fullNameList);
  15110. var graph = result.graph;
  15111. var noEntryList = result.noEntryList;
  15112. var targetNameSet = {};
  15113. each$1(targetNameList, function (name) {
  15114. targetNameSet[name] = true;
  15115. });
  15116. while (noEntryList.length) {
  15117. var currComponentType = noEntryList.pop();
  15118. var currVertex = graph[currComponentType];
  15119. var isInTargetNameSet = !!targetNameSet[currComponentType];
  15120. if (isInTargetNameSet) {
  15121. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  15122. delete targetNameSet[currComponentType];
  15123. }
  15124. each$1(currVertex.successor, isInTargetNameSet ? removeEdgeAndAdd : removeEdge);
  15125. }
  15126. each$1(targetNameSet, function () {
  15127. var errMsg = '';
  15128. {
  15129. errMsg = makePrintable('Circular dependency may exists: ', targetNameSet, targetNameList, fullNameList);
  15130. }
  15131. throw new Error(errMsg);
  15132. });
  15133. function removeEdge(succComponentType) {
  15134. graph[succComponentType].entryCount--;
  15135. if (graph[succComponentType].entryCount === 0) {
  15136. noEntryList.push(succComponentType);
  15137. }
  15138. } // Consider this case: legend depends on series, and we call
  15139. // chart.setOption({series: [...]}), where only series is in option.
  15140. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  15141. // not be called, but only sereis.mergeOption is called. Thus legend
  15142. // have no chance to update its local record about series (like which
  15143. // name of series is available in legend).
  15144. function removeEdgeAndAdd(succComponentType) {
  15145. targetNameSet[succComponentType] = true;
  15146. removeEdge(succComponentType);
  15147. }
  15148. };
  15149. function makeDepndencyGraph(fullNameList) {
  15150. var graph = {};
  15151. var noEntryList = [];
  15152. each$1(fullNameList, function (name) {
  15153. var thisItem = createDependencyGraphItem(graph, name);
  15154. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  15155. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  15156. thisItem.entryCount = availableDeps.length;
  15157. if (thisItem.entryCount === 0) {
  15158. noEntryList.push(name);
  15159. }
  15160. each$1(availableDeps, function (dependentName) {
  15161. if (indexOf$1(thisItem.predecessor, dependentName) < 0) {
  15162. thisItem.predecessor.push(dependentName);
  15163. }
  15164. var thatItem = createDependencyGraphItem(graph, dependentName);
  15165. if (indexOf$1(thatItem.successor, dependentName) < 0) {
  15166. thatItem.successor.push(name);
  15167. }
  15168. });
  15169. });
  15170. return {
  15171. graph: graph,
  15172. noEntryList: noEntryList
  15173. };
  15174. }
  15175. function createDependencyGraphItem(graph, name) {
  15176. if (!graph[name]) {
  15177. graph[name] = {
  15178. predecessor: [],
  15179. successor: []
  15180. };
  15181. }
  15182. return graph[name];
  15183. }
  15184. function getAvailableDependencies(originalDeps, fullNameList) {
  15185. var availableDeps = [];
  15186. each$1(originalDeps, function (dep) {
  15187. indexOf$1(fullNameList, dep) >= 0 && availableDeps.push(dep);
  15188. });
  15189. return availableDeps;
  15190. }
  15191. }
  15192. function inheritDefaultOption(superOption, subOption) {
  15193. // See also `model/Component.ts#getDefaultOption`
  15194. return merge(merge({}, superOption, true), subOption, true);
  15195. }
  15196. /*
  15197. * Licensed to the Apache Software Foundation (ASF) under one
  15198. * or more contributor license agreements. See the NOTICE file
  15199. * distributed with this work for additional information
  15200. * regarding copyright ownership. The ASF licenses this file
  15201. * to you under the Apache License, Version 2.0 (the
  15202. * "License"); you may not use this file except in compliance
  15203. * with the License. You may obtain a copy of the License at
  15204. *
  15205. * http://www.apache.org/licenses/LICENSE-2.0
  15206. *
  15207. * Unless required by applicable law or agreed to in writing,
  15208. * software distributed under the License is distributed on an
  15209. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15210. * KIND, either express or implied. See the License for the
  15211. * specific language governing permissions and limitations
  15212. * under the License.
  15213. */
  15214. /**
  15215. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15216. */
  15217. /*
  15218. * Licensed to the Apache Software Foundation (ASF) under one
  15219. * or more contributor license agreements. See the NOTICE file
  15220. * distributed with this work for additional information
  15221. * regarding copyright ownership. The ASF licenses this file
  15222. * to you under the Apache License, Version 2.0 (the
  15223. * "License"); you may not use this file except in compliance
  15224. * with the License. You may obtain a copy of the License at
  15225. *
  15226. * http://www.apache.org/licenses/LICENSE-2.0
  15227. *
  15228. * Unless required by applicable law or agreed to in writing,
  15229. * software distributed under the License is distributed on an
  15230. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15231. * KIND, either express or implied. See the License for the
  15232. * specific language governing permissions and limitations
  15233. * under the License.
  15234. */
  15235. /**
  15236. * Language: English.
  15237. */
  15238. var langEN = {
  15239. time: {
  15240. month: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
  15241. monthAbbr: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  15242. dayOfWeek: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
  15243. dayOfWeekAbbr: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
  15244. },
  15245. legend: {
  15246. selector: {
  15247. all: 'All',
  15248. inverse: 'Inv'
  15249. }
  15250. },
  15251. toolbox: {
  15252. brush: {
  15253. title: {
  15254. rect: 'Box Select',
  15255. polygon: 'Lasso Select',
  15256. lineX: 'Horizontally Select',
  15257. lineY: 'Vertically Select',
  15258. keep: 'Keep Selections',
  15259. clear: 'Clear Selections'
  15260. }
  15261. },
  15262. dataView: {
  15263. title: 'Data View',
  15264. lang: ['Data View', 'Close', 'Refresh']
  15265. },
  15266. dataZoom: {
  15267. title: {
  15268. zoom: 'Zoom',
  15269. back: 'Zoom Reset'
  15270. }
  15271. },
  15272. magicType: {
  15273. title: {
  15274. line: 'Switch to Line Chart',
  15275. bar: 'Switch to Bar Chart',
  15276. stack: 'Stack',
  15277. tiled: 'Tile'
  15278. }
  15279. },
  15280. restore: {
  15281. title: 'Restore'
  15282. },
  15283. saveAsImage: {
  15284. title: 'Save as Image',
  15285. lang: ['Right Click to Save Image']
  15286. }
  15287. },
  15288. series: {
  15289. typeNames: {
  15290. pie: 'Pie chart',
  15291. bar: 'Bar chart',
  15292. line: 'Line chart',
  15293. scatter: 'Scatter plot',
  15294. effectScatter: 'Ripple scatter plot',
  15295. radar: 'Radar chart',
  15296. tree: 'Tree',
  15297. treemap: 'Treemap',
  15298. boxplot: 'Boxplot',
  15299. candlestick: 'Candlestick',
  15300. k: 'K line chart',
  15301. heatmap: 'Heat map',
  15302. map: 'Map',
  15303. parallel: 'Parallel coordinate map',
  15304. lines: 'Line graph',
  15305. graph: 'Relationship graph',
  15306. sankey: 'Sankey diagram',
  15307. funnel: 'Funnel chart',
  15308. gauge: 'Guage',
  15309. pictorialBar: 'Pictorial bar',
  15310. themeRiver: 'Theme River Map',
  15311. sunburst: 'Sunburst'
  15312. }
  15313. },
  15314. aria: {
  15315. general: {
  15316. withTitle: 'This is a chart about "{title}"',
  15317. withoutTitle: 'This is a chart'
  15318. },
  15319. series: {
  15320. single: {
  15321. prefix: '',
  15322. withName: ' with type {seriesType} named {seriesName}.',
  15323. withoutName: ' with type {seriesType}.'
  15324. },
  15325. multiple: {
  15326. prefix: '. It consists of {seriesCount} series count.',
  15327. withName: ' The {seriesId} series is a {seriesType} representing {seriesName}.',
  15328. withoutName: ' The {seriesId} series is a {seriesType}.',
  15329. separator: {
  15330. middle: '',
  15331. end: ''
  15332. }
  15333. }
  15334. },
  15335. data: {
  15336. allData: 'The data is as follows: ',
  15337. partialData: 'The first {displayCnt} items are: ',
  15338. withName: 'the data for {name} is {value}',
  15339. withoutName: '{value}',
  15340. separator: {
  15341. middle: ', ',
  15342. end: '. '
  15343. }
  15344. }
  15345. }
  15346. };
  15347. /*
  15348. * Licensed to the Apache Software Foundation (ASF) under one
  15349. * or more contributor license agreements. See the NOTICE file
  15350. * distributed with this work for additional information
  15351. * regarding copyright ownership. The ASF licenses this file
  15352. * to you under the Apache License, Version 2.0 (the
  15353. * "License"); you may not use this file except in compliance
  15354. * with the License. You may obtain a copy of the License at
  15355. *
  15356. * http://www.apache.org/licenses/LICENSE-2.0
  15357. *
  15358. * Unless required by applicable law or agreed to in writing,
  15359. * software distributed under the License is distributed on an
  15360. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15361. * KIND, either express or implied. See the License for the
  15362. * specific language governing permissions and limitations
  15363. * under the License.
  15364. */
  15365. /**
  15366. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15367. */
  15368. /*
  15369. * Licensed to the Apache Software Foundation (ASF) under one
  15370. * or more contributor license agreements. See the NOTICE file
  15371. * distributed with this work for additional information
  15372. * regarding copyright ownership. The ASF licenses this file
  15373. * to you under the Apache License, Version 2.0 (the
  15374. * "License"); you may not use this file except in compliance
  15375. * with the License. You may obtain a copy of the License at
  15376. *
  15377. * http://www.apache.org/licenses/LICENSE-2.0
  15378. *
  15379. * Unless required by applicable law or agreed to in writing,
  15380. * software distributed under the License is distributed on an
  15381. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15382. * KIND, either express or implied. See the License for the
  15383. * specific language governing permissions and limitations
  15384. * under the License.
  15385. */
  15386. var langZH = {
  15387. time: {
  15388. month: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
  15389. monthAbbr: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
  15390. dayOfWeek: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'],
  15391. dayOfWeekAbbr: ['日', '一', '二', '三', '四', '五', '六']
  15392. },
  15393. legend: {
  15394. selector: {
  15395. all: '全选',
  15396. inverse: '反选'
  15397. }
  15398. },
  15399. toolbox: {
  15400. brush: {
  15401. title: {
  15402. rect: '矩形选择',
  15403. polygon: '圈选',
  15404. lineX: '横向选择',
  15405. lineY: '纵向选择',
  15406. keep: '保持选择',
  15407. clear: '清除选择'
  15408. }
  15409. },
  15410. dataView: {
  15411. title: '数据视图',
  15412. lang: ['数据视图', '关闭', '刷新']
  15413. },
  15414. dataZoom: {
  15415. title: {
  15416. zoom: '区域缩放',
  15417. back: '区域缩放还原'
  15418. }
  15419. },
  15420. magicType: {
  15421. title: {
  15422. line: '切换为折线图',
  15423. bar: '切换为柱状图',
  15424. stack: '切换为堆叠',
  15425. tiled: '切换为平铺'
  15426. }
  15427. },
  15428. restore: {
  15429. title: '还原'
  15430. },
  15431. saveAsImage: {
  15432. title: '保存为图片',
  15433. lang: ['右键另存为图片']
  15434. }
  15435. },
  15436. series: {
  15437. typeNames: {
  15438. pie: '饼图',
  15439. bar: '柱状图',
  15440. line: '折线图',
  15441. scatter: '散点图',
  15442. effectScatter: '涟漪散点图',
  15443. radar: '雷达图',
  15444. tree: '树图',
  15445. treemap: '矩形树图',
  15446. boxplot: '箱型图',
  15447. candlestick: 'K线图',
  15448. k: 'K线图',
  15449. heatmap: '热力图',
  15450. map: '地图',
  15451. parallel: '平行坐标图',
  15452. lines: '线图',
  15453. graph: '关系图',
  15454. sankey: '桑基图',
  15455. funnel: '漏斗图',
  15456. gauge: '仪表盘图',
  15457. pictorialBar: '象形柱图',
  15458. themeRiver: '主题河流图',
  15459. sunburst: '旭日图'
  15460. }
  15461. },
  15462. aria: {
  15463. general: {
  15464. withTitle: '这是一个关于“{title}”的图表。',
  15465. withoutTitle: '这是一个图表,'
  15466. },
  15467. series: {
  15468. single: {
  15469. prefix: '',
  15470. withName: '图表类型是{seriesType},表示{seriesName}。',
  15471. withoutName: '图表类型是{seriesType}。'
  15472. },
  15473. multiple: {
  15474. prefix: '它由{seriesCount}个图表系列组成。',
  15475. withName: '第{seriesId}个系列是一个表示{seriesName}的{seriesType},',
  15476. withoutName: '第{seriesId}个系列是一个{seriesType},',
  15477. separator: {
  15478. middle: ';',
  15479. end: '。'
  15480. }
  15481. }
  15482. },
  15483. data: {
  15484. allData: '其数据是——',
  15485. partialData: '其中,前{displayCnt}项是——',
  15486. withName: '{name}的数据是{value}',
  15487. withoutName: '{value}',
  15488. separator: {
  15489. middle: ',',
  15490. end: ''
  15491. }
  15492. }
  15493. }
  15494. };
  15495. /*
  15496. * Licensed to the Apache Software Foundation (ASF) under one
  15497. * or more contributor license agreements. See the NOTICE file
  15498. * distributed with this work for additional information
  15499. * regarding copyright ownership. The ASF licenses this file
  15500. * to you under the Apache License, Version 2.0 (the
  15501. * "License"); you may not use this file except in compliance
  15502. * with the License. You may obtain a copy of the License at
  15503. *
  15504. * http://www.apache.org/licenses/LICENSE-2.0
  15505. *
  15506. * Unless required by applicable law or agreed to in writing,
  15507. * software distributed under the License is distributed on an
  15508. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15509. * KIND, either express or implied. See the License for the
  15510. * specific language governing permissions and limitations
  15511. * under the License.
  15512. */
  15513. /**
  15514. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15515. */
  15516. /*
  15517. * Licensed to the Apache Software Foundation (ASF) under one
  15518. * or more contributor license agreements. See the NOTICE file
  15519. * distributed with this work for additional information
  15520. * regarding copyright ownership. The ASF licenses this file
  15521. * to you under the Apache License, Version 2.0 (the
  15522. * "License"); you may not use this file except in compliance
  15523. * with the License. You may obtain a copy of the License at
  15524. *
  15525. * http://www.apache.org/licenses/LICENSE-2.0
  15526. *
  15527. * Unless required by applicable law or agreed to in writing,
  15528. * software distributed under the License is distributed on an
  15529. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15530. * KIND, either express or implied. See the License for the
  15531. * specific language governing permissions and limitations
  15532. * under the License.
  15533. */
  15534. var LOCALE_ZH = 'ZH';
  15535. var LOCALE_EN = 'EN';
  15536. var DEFAULT_LOCALE = LOCALE_EN;
  15537. var localeStorage = {};
  15538. var localeModels = {};
  15539. var SYSTEM_LANG = !env.domSupported ? DEFAULT_LOCALE : function () {
  15540. var langStr = (
  15541. /* eslint-disable-next-line */
  15542. document.documentElement.lang || navigator.language || navigator.browserLanguage).toUpperCase();
  15543. return langStr.indexOf(LOCALE_ZH) > -1 ? LOCALE_ZH : DEFAULT_LOCALE;
  15544. }();
  15545. function registerLocale(locale, localeObj) {
  15546. locale = locale.toUpperCase();
  15547. localeModels[locale] = new Model(localeObj);
  15548. localeStorage[locale] = localeObj;
  15549. } // export function getLocale(locale: string) {
  15550. // return localeStorage[locale];
  15551. // }
  15552. function createLocaleObject(locale) {
  15553. if (isString(locale)) {
  15554. var localeObj = localeStorage[locale.toUpperCase()] || {};
  15555. if (locale === LOCALE_ZH || locale === LOCALE_EN) {
  15556. return clone(localeObj);
  15557. } else {
  15558. return merge(clone(localeObj), clone(localeStorage[DEFAULT_LOCALE]), false);
  15559. }
  15560. } else {
  15561. return merge(clone(locale), clone(localeStorage[DEFAULT_LOCALE]), false);
  15562. }
  15563. }
  15564. function getLocaleModel(lang) {
  15565. return localeModels[lang];
  15566. }
  15567. function getDefaultLocaleModel() {
  15568. return localeModels[DEFAULT_LOCALE];
  15569. } // Default locale
  15570. registerLocale(LOCALE_EN, langEN);
  15571. registerLocale(LOCALE_ZH, langZH);
  15572. /*
  15573. * Licensed to the Apache Software Foundation (ASF) under one
  15574. * or more contributor license agreements. See the NOTICE file
  15575. * distributed with this work for additional information
  15576. * regarding copyright ownership. The ASF licenses this file
  15577. * to you under the Apache License, Version 2.0 (the
  15578. * "License"); you may not use this file except in compliance
  15579. * with the License. You may obtain a copy of the License at
  15580. *
  15581. * http://www.apache.org/licenses/LICENSE-2.0
  15582. *
  15583. * Unless required by applicable law or agreed to in writing,
  15584. * software distributed under the License is distributed on an
  15585. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15586. * KIND, either express or implied. See the License for the
  15587. * specific language governing permissions and limitations
  15588. * under the License.
  15589. */
  15590. /**
  15591. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15592. */
  15593. /*
  15594. * Licensed to the Apache Software Foundation (ASF) under one
  15595. * or more contributor license agreements. See the NOTICE file
  15596. * distributed with this work for additional information
  15597. * regarding copyright ownership. The ASF licenses this file
  15598. * to you under the Apache License, Version 2.0 (the
  15599. * "License"); you may not use this file except in compliance
  15600. * with the License. You may obtain a copy of the License at
  15601. *
  15602. * http://www.apache.org/licenses/LICENSE-2.0
  15603. *
  15604. * Unless required by applicable law or agreed to in writing,
  15605. * software distributed under the License is distributed on an
  15606. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15607. * KIND, either express or implied. See the License for the
  15608. * specific language governing permissions and limitations
  15609. * under the License.
  15610. */
  15611. var ONE_SECOND = 1000;
  15612. var ONE_MINUTE = ONE_SECOND * 60;
  15613. var ONE_HOUR = ONE_MINUTE * 60;
  15614. var ONE_DAY = ONE_HOUR * 24;
  15615. var ONE_YEAR = ONE_DAY * 365;
  15616. var defaultLeveledFormatter = {
  15617. year: '{yyyy}',
  15618. month: '{MMM}',
  15619. day: '{d}',
  15620. hour: '{HH}:{mm}',
  15621. minute: '{HH}:{mm}',
  15622. second: '{HH}:{mm}:{ss}',
  15623. millisecond: '{hh}:{mm}:{ss} {SSS}',
  15624. none: '{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}'
  15625. };
  15626. var fullDayFormatter = '{yyyy}-{MM}-{dd}';
  15627. var fullLeveledFormatter = {
  15628. year: '{yyyy}',
  15629. month: '{yyyy}-{MM}',
  15630. day: fullDayFormatter,
  15631. hour: fullDayFormatter + ' ' + defaultLeveledFormatter.hour,
  15632. minute: fullDayFormatter + ' ' + defaultLeveledFormatter.minute,
  15633. second: fullDayFormatter + ' ' + defaultLeveledFormatter.second,
  15634. millisecond: defaultLeveledFormatter.none
  15635. };
  15636. var primaryTimeUnits = ['year', 'month', 'day', 'hour', 'minute', 'second', 'millisecond'];
  15637. var timeUnits = ['year', 'half-year', 'quarter', 'month', 'week', 'half-week', 'day', 'half-day', 'quarter-day', 'hour', 'minute', 'second', 'millisecond'];
  15638. function pad(str, len) {
  15639. str += '';
  15640. return '0000'.substr(0, len - str.length) + str;
  15641. }
  15642. function getPrimaryTimeUnit(timeUnit) {
  15643. switch (timeUnit) {
  15644. case 'half-year':
  15645. case 'quarter':
  15646. return 'month';
  15647. case 'week':
  15648. case 'half-week':
  15649. return 'day';
  15650. case 'half-day':
  15651. case 'quarter-day':
  15652. return 'hour';
  15653. default:
  15654. // year, minutes, second, milliseconds
  15655. return timeUnit;
  15656. }
  15657. }
  15658. function isPrimaryTimeUnit(timeUnit) {
  15659. return timeUnit === getPrimaryTimeUnit(timeUnit);
  15660. }
  15661. function getDefaultFormatPrecisionOfInterval(timeUnit) {
  15662. switch (timeUnit) {
  15663. case 'year':
  15664. case 'month':
  15665. return 'day';
  15666. case 'millisecond':
  15667. return 'millisecond';
  15668. default:
  15669. // Also for day, hour, minute, second
  15670. return 'second';
  15671. }
  15672. }
  15673. function format( // Note: The result based on `isUTC` are totally different, which can not be just simply
  15674. // substituted by the result without `isUTC`. So we make the param `isUTC` mandatory.
  15675. time, template, isUTC, lang) {
  15676. var date = parseDate(time);
  15677. var y = date[fullYearGetterName(isUTC)]();
  15678. var M = date[monthGetterName(isUTC)]() + 1;
  15679. var q = Math.floor((M - 1) / 4) + 1;
  15680. var d = date[dateGetterName(isUTC)]();
  15681. var e = date['get' + (isUTC ? 'UTC' : '') + 'Day']();
  15682. var H = date[hoursGetterName(isUTC)]();
  15683. var h = (H - 1) % 12 + 1;
  15684. var m = date[minutesGetterName(isUTC)]();
  15685. var s = date[secondsGetterName(isUTC)]();
  15686. var S = date[millisecondsGetterName(isUTC)]();
  15687. var localeModel = lang instanceof Model ? lang : getLocaleModel(lang || SYSTEM_LANG) || getDefaultLocaleModel();
  15688. var timeModel = localeModel.getModel('time');
  15689. var month = timeModel.get('month');
  15690. var monthAbbr = timeModel.get('monthAbbr');
  15691. var dayOfWeek = timeModel.get('dayOfWeek');
  15692. var dayOfWeekAbbr = timeModel.get('dayOfWeekAbbr');
  15693. return (template || '').replace(/{yyyy}/g, y + '').replace(/{yy}/g, y % 100 + '').replace(/{Q}/g, q + '').replace(/{MMMM}/g, month[M - 1]).replace(/{MMM}/g, monthAbbr[M - 1]).replace(/{MM}/g, pad(M, 2)).replace(/{M}/g, M + '').replace(/{dd}/g, pad(d, 2)).replace(/{d}/g, d + '').replace(/{eeee}/g, dayOfWeek[e]).replace(/{ee}/g, dayOfWeekAbbr[e]).replace(/{e}/g, e + '').replace(/{HH}/g, pad(H, 2)).replace(/{H}/g, H + '').replace(/{hh}/g, pad(h + '', 2)).replace(/{h}/g, h + '').replace(/{mm}/g, pad(m, 2)).replace(/{m}/g, m + '').replace(/{ss}/g, pad(s, 2)).replace(/{s}/g, s + '').replace(/{SSS}/g, pad(S, 3)).replace(/{S}/g, S + '');
  15694. }
  15695. function leveledFormat(tick, idx, formatter, lang, isUTC) {
  15696. var template = null;
  15697. if (typeof formatter === 'string') {
  15698. // Single formatter for all units at all levels
  15699. template = formatter;
  15700. } else if (typeof formatter === 'function') {
  15701. // Callback formatter
  15702. template = formatter(tick.value, idx, {
  15703. level: tick.level
  15704. });
  15705. } else {
  15706. var defaults$$1 = extend({}, defaultLeveledFormatter);
  15707. if (tick.level > 0) {
  15708. for (var i = 0; i < primaryTimeUnits.length; ++i) {
  15709. defaults$$1[primaryTimeUnits[i]] = "{primary|" + defaults$$1[primaryTimeUnits[i]] + "}";
  15710. }
  15711. }
  15712. var mergedFormatter = formatter ? formatter.inherit === false ? formatter // Use formatter with bigger units
  15713. : defaults(formatter, defaults$$1) : defaults$$1;
  15714. var unit = getUnitFromValue(tick.value, isUTC);
  15715. if (mergedFormatter[unit]) {
  15716. template = mergedFormatter[unit];
  15717. } else if (mergedFormatter.inherit) {
  15718. // Unit formatter is not defined and should inherit from bigger units
  15719. var targetId = timeUnits.indexOf(unit);
  15720. for (var i = targetId - 1; i >= 0; --i) {
  15721. if (mergedFormatter[unit]) {
  15722. template = mergedFormatter[unit];
  15723. break;
  15724. }
  15725. }
  15726. template = template || defaults$$1.none;
  15727. }
  15728. if (isArray(template)) {
  15729. var levelId = tick.level == null ? 0 : tick.level >= 0 ? tick.level : template.length + tick.level;
  15730. levelId = Math.min(levelId, template.length - 1);
  15731. template = template[levelId];
  15732. }
  15733. }
  15734. return format(new Date(tick.value), template, isUTC, lang);
  15735. }
  15736. function getUnitFromValue(value, isUTC) {
  15737. var date = parseDate(value);
  15738. var M = date[monthGetterName(isUTC)]() + 1;
  15739. var d = date[dateGetterName(isUTC)]();
  15740. var h = date[hoursGetterName(isUTC)]();
  15741. var m = date[minutesGetterName(isUTC)]();
  15742. var s = date[secondsGetterName(isUTC)]();
  15743. var S = date[millisecondsGetterName(isUTC)]();
  15744. var isSecond = S === 0;
  15745. var isMinute = isSecond && s === 0;
  15746. var isHour = isMinute && m === 0;
  15747. var isDay = isHour && h === 0;
  15748. var isMonth = isDay && d === 1;
  15749. var isYear = isMonth && M === 1;
  15750. if (isYear) {
  15751. return 'year';
  15752. } else if (isMonth) {
  15753. return 'month';
  15754. } else if (isDay) {
  15755. return 'day';
  15756. } else if (isHour) {
  15757. return 'hour';
  15758. } else if (isMinute) {
  15759. return 'minute';
  15760. } else if (isSecond) {
  15761. return 'second';
  15762. } else {
  15763. return 'millisecond';
  15764. }
  15765. }
  15766. function getUnitValue(value, unit, isUTC) {
  15767. var date = typeof value === 'number' ? parseDate(value) : value;
  15768. unit = unit || getUnitFromValue(value, isUTC);
  15769. switch (unit) {
  15770. case 'year':
  15771. return date[fullYearGetterName(isUTC)]();
  15772. case 'half-year':
  15773. return date[monthGetterName(isUTC)]() >= 6 ? 1 : 0;
  15774. case 'quarter':
  15775. return Math.floor((date[monthGetterName(isUTC)]() + 1) / 4);
  15776. case 'month':
  15777. return date[monthGetterName(isUTC)]();
  15778. case 'day':
  15779. return date[dateGetterName(isUTC)]();
  15780. case 'half-day':
  15781. return date[hoursGetterName(isUTC)]() / 24;
  15782. case 'hour':
  15783. return date[hoursGetterName(isUTC)]();
  15784. case 'minute':
  15785. return date[minutesGetterName(isUTC)]();
  15786. case 'second':
  15787. return date[secondsGetterName(isUTC)]();
  15788. case 'millisecond':
  15789. return date[millisecondsGetterName(isUTC)]();
  15790. }
  15791. }
  15792. function fullYearGetterName(isUTC) {
  15793. return isUTC ? 'getUTCFullYear' : 'getFullYear';
  15794. }
  15795. function monthGetterName(isUTC) {
  15796. return isUTC ? 'getUTCMonth' : 'getMonth';
  15797. }
  15798. function dateGetterName(isUTC) {
  15799. return isUTC ? 'getUTCDate' : 'getDate';
  15800. }
  15801. function hoursGetterName(isUTC) {
  15802. return isUTC ? 'getUTCHours' : 'getHours';
  15803. }
  15804. function minutesGetterName(isUTC) {
  15805. return isUTC ? 'getUTCMinutes' : 'getMinutes';
  15806. }
  15807. function secondsGetterName(isUTC) {
  15808. return isUTC ? 'getUTCSeconds' : 'getSeconds';
  15809. }
  15810. function millisecondsGetterName(isUTC) {
  15811. return isUTC ? 'getUTCSeconds' : 'getSeconds';
  15812. }
  15813. function fullYearSetterName(isUTC) {
  15814. return isUTC ? 'setUTCFullYear' : 'setFullYear';
  15815. }
  15816. function monthSetterName(isUTC) {
  15817. return isUTC ? 'setUTCMonth' : 'setMonth';
  15818. }
  15819. function dateSetterName(isUTC) {
  15820. return isUTC ? 'setUTCDate' : 'setDate';
  15821. }
  15822. function hoursSetterName(isUTC) {
  15823. return isUTC ? 'setUTCHours' : 'setHours';
  15824. }
  15825. function minutesSetterName(isUTC) {
  15826. return isUTC ? 'setUTCMinutes' : 'setMinutes';
  15827. }
  15828. function secondsSetterName(isUTC) {
  15829. return isUTC ? 'setUTCSeconds' : 'setSeconds';
  15830. }
  15831. function millisecondsSetterName(isUTC) {
  15832. return isUTC ? 'setUTCSeconds' : 'setSeconds';
  15833. }
  15834. /*
  15835. * Licensed to the Apache Software Foundation (ASF) under one
  15836. * or more contributor license agreements. See the NOTICE file
  15837. * distributed with this work for additional information
  15838. * regarding copyright ownership. The ASF licenses this file
  15839. * to you under the Apache License, Version 2.0 (the
  15840. * "License"); you may not use this file except in compliance
  15841. * with the License. You may obtain a copy of the License at
  15842. *
  15843. * http://www.apache.org/licenses/LICENSE-2.0
  15844. *
  15845. * Unless required by applicable law or agreed to in writing,
  15846. * software distributed under the License is distributed on an
  15847. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15848. * KIND, either express or implied. See the License for the
  15849. * specific language governing permissions and limitations
  15850. * under the License.
  15851. */
  15852. /**
  15853. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15854. */
  15855. /*
  15856. * Licensed to the Apache Software Foundation (ASF) under one
  15857. * or more contributor license agreements. See the NOTICE file
  15858. * distributed with this work for additional information
  15859. * regarding copyright ownership. The ASF licenses this file
  15860. * to you under the Apache License, Version 2.0 (the
  15861. * "License"); you may not use this file except in compliance
  15862. * with the License. You may obtain a copy of the License at
  15863. *
  15864. * http://www.apache.org/licenses/LICENSE-2.0
  15865. *
  15866. * Unless required by applicable law or agreed to in writing,
  15867. * software distributed under the License is distributed on an
  15868. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15869. * KIND, either express or implied. See the License for the
  15870. * specific language governing permissions and limitations
  15871. * under the License.
  15872. */
  15873. function getTextRect(text, font, align, verticalAlign, padding, rich, truncate, lineHeight) {
  15874. deprecateLog('getTextRect is deprecated.');
  15875. var textEl = new ZRText({
  15876. style: {
  15877. text: text,
  15878. font: font,
  15879. align: align,
  15880. verticalAlign: verticalAlign,
  15881. padding: padding,
  15882. rich: rich,
  15883. overflow: truncate ? 'truncate' : null,
  15884. lineHeight: lineHeight
  15885. }
  15886. });
  15887. return textEl.getBoundingRect();
  15888. }
  15889. /*
  15890. * Licensed to the Apache Software Foundation (ASF) under one
  15891. * or more contributor license agreements. See the NOTICE file
  15892. * distributed with this work for additional information
  15893. * regarding copyright ownership. The ASF licenses this file
  15894. * to you under the Apache License, Version 2.0 (the
  15895. * "License"); you may not use this file except in compliance
  15896. * with the License. You may obtain a copy of the License at
  15897. *
  15898. * http://www.apache.org/licenses/LICENSE-2.0
  15899. *
  15900. * Unless required by applicable law or agreed to in writing,
  15901. * software distributed under the License is distributed on an
  15902. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15903. * KIND, either express or implied. See the License for the
  15904. * specific language governing permissions and limitations
  15905. * under the License.
  15906. */
  15907. /**
  15908. * AUTO-GENERATED FILE. DO NOT MODIFY.
  15909. */
  15910. /*
  15911. * Licensed to the Apache Software Foundation (ASF) under one
  15912. * or more contributor license agreements. See the NOTICE file
  15913. * distributed with this work for additional information
  15914. * regarding copyright ownership. The ASF licenses this file
  15915. * to you under the Apache License, Version 2.0 (the
  15916. * "License"); you may not use this file except in compliance
  15917. * with the License. You may obtain a copy of the License at
  15918. *
  15919. * http://www.apache.org/licenses/LICENSE-2.0
  15920. *
  15921. * Unless required by applicable law or agreed to in writing,
  15922. * software distributed under the License is distributed on an
  15923. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15924. * KIND, either express or implied. See the License for the
  15925. * specific language governing permissions and limitations
  15926. * under the License.
  15927. */
  15928. /**
  15929. * Add a comma each three digit.
  15930. */
  15931. function addCommas(x) {
  15932. if (!isNumeric(x)) {
  15933. return isString(x) ? x : '-';
  15934. }
  15935. var parts = (x + '').split('.');
  15936. return parts[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,') + (parts.length > 1 ? '.' + parts[1] : '');
  15937. }
  15938. function toCamelCase(str, upperCaseFirst) {
  15939. str = (str || '').toLowerCase().replace(/-(.)/g, function (match, group1) {
  15940. return group1.toUpperCase();
  15941. });
  15942. if (upperCaseFirst && str) {
  15943. str = str.charAt(0).toUpperCase() + str.slice(1);
  15944. }
  15945. return str;
  15946. }
  15947. var normalizeCssArray$1 = normalizeCssArray;
  15948. var replaceReg = /([&<>"'])/g;
  15949. var replaceMap = {
  15950. '&': '&amp;',
  15951. '<': '&lt;',
  15952. '>': '&gt;',
  15953. '"': '&quot;',
  15954. '\'': '&#39;'
  15955. };
  15956. function encodeHTML(source) {
  15957. return source == null ? '' : (source + '').replace(replaceReg, function (str, c) {
  15958. return replaceMap[c];
  15959. });
  15960. }
  15961. /**
  15962. * Make value user readable for tooltip and label.
  15963. * "User readable":
  15964. * Try to not print programmer-specific text like NaN, Infinity, null, undefined.
  15965. * Avoid to display an empty string, which users can not recognize there is
  15966. * a value and it might look like a bug.
  15967. */
  15968. function makeValueReadable(value, valueType, useUTC) {
  15969. var USER_READABLE_DEFUALT_TIME_PATTERN = '{yyyy}-{MM}-{dd} {hh}:{mm}:{ss}';
  15970. function stringToUserReadable(str) {
  15971. return str && trim(str) ? str : '-';
  15972. }
  15973. function isNumberUserReadable(num) {
  15974. return !!(num != null && !isNaN(num) && isFinite(num));
  15975. }
  15976. var isTypeTime = valueType === 'time';
  15977. var isValueDate = value instanceof Date;
  15978. if (isTypeTime || isValueDate) {
  15979. var date = isTypeTime ? parseDate(value) : value;
  15980. if (!isNaN(+date)) {
  15981. return format(date, USER_READABLE_DEFUALT_TIME_PATTERN, useUTC);
  15982. } else if (isValueDate) {
  15983. return '-';
  15984. } // In other cases, continue to try to display the value in the following code.
  15985. }
  15986. if (valueType === 'ordinal') {
  15987. return isStringSafe(value) ? stringToUserReadable(value) : isNumber(value) ? isNumberUserReadable(value) ? value + '' : '-' : '-';
  15988. } // By default.
  15989. var numericResult = numericToNumber(value);
  15990. return isNumberUserReadable(numericResult) ? addCommas(numericResult) : isStringSafe(value) ? stringToUserReadable(value) : '-';
  15991. }
  15992. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  15993. var wrapVar = function (varName, seriesIdx) {
  15994. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  15995. };
  15996. /**
  15997. * Template formatter
  15998. * @param {Array.<Object>|Object} paramsList
  15999. */
  16000. function formatTpl(tpl, paramsList, encode) {
  16001. if (!isArray(paramsList)) {
  16002. paramsList = [paramsList];
  16003. }
  16004. var seriesLen = paramsList.length;
  16005. if (!seriesLen) {
  16006. return '';
  16007. }
  16008. var $vars = paramsList[0].$vars || [];
  16009. for (var i = 0; i < $vars.length; i++) {
  16010. var alias = TPL_VAR_ALIAS[i];
  16011. tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
  16012. }
  16013. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  16014. for (var k = 0; k < $vars.length; k++) {
  16015. var val = paramsList[seriesIdx][$vars[k]];
  16016. tpl = tpl.replace(wrapVar(TPL_VAR_ALIAS[k], seriesIdx), encode ? encodeHTML(val) : val);
  16017. }
  16018. }
  16019. return tpl;
  16020. }
  16021. /**
  16022. * simple Template formatter
  16023. */
  16024. function formatTplSimple(tpl, param, encode) {
  16025. each$1(param, function (value, key) {
  16026. tpl = tpl.replace('{' + key + '}', encode ? encodeHTML(value) : value);
  16027. });
  16028. return tpl;
  16029. }
  16030. function getTooltipMarker(inOpt, extraCssText) {
  16031. var opt = isString(inOpt) ? {
  16032. color: inOpt,
  16033. extraCssText: extraCssText
  16034. } : inOpt || {};
  16035. var color = opt.color;
  16036. var type = opt.type;
  16037. extraCssText = opt.extraCssText;
  16038. var renderMode = opt.renderMode || 'html';
  16039. if (!color) {
  16040. return '';
  16041. }
  16042. if (renderMode === 'html') {
  16043. return type === 'subItem' ? '<span style="display:inline-block;vertical-align:middle;margin-right:8px;margin-left:3px;' + 'border-radius:4px;width:4px;height:4px;background-color:' // Only support string
  16044. + encodeHTML(color) + ';' + (extraCssText || '') + '"></span>' : '<span style="display:inline-block;margin-right:4px;' + 'border-radius:10px;width:10px;height:10px;background-color:' + encodeHTML(color) + ';' + (extraCssText || '') + '"></span>';
  16045. } else {
  16046. // Should better not to auto generate style name by auto-increment number here.
  16047. // Because this util is usually called in tooltip formatter, which is probably
  16048. // called repeatly when mouse move and the auto-increment number increases fast.
  16049. // Users can make their own style name by theirselves, make it unique and readable.
  16050. var markerId = opt.markerId || 'markerX';
  16051. return {
  16052. renderMode: renderMode,
  16053. content: '{' + markerId + '|} ',
  16054. style: type === 'subItem' ? {
  16055. width: 4,
  16056. height: 4,
  16057. borderRadius: 2,
  16058. backgroundColor: color
  16059. } : {
  16060. width: 10,
  16061. height: 10,
  16062. borderRadius: 5,
  16063. backgroundColor: color
  16064. }
  16065. };
  16066. }
  16067. }
  16068. /**
  16069. * @deprecated Use `time/format` instead.
  16070. * ISO Date format
  16071. * @param {string} tpl
  16072. * @param {number} value
  16073. * @param {boolean} [isUTC=false] Default in local time.
  16074. * see `module:echarts/scale/Time`
  16075. * and `module:echarts/util/number#parseDate`.
  16076. * @inner
  16077. */
  16078. function formatTime(tpl, value, isUTC) {
  16079. {
  16080. deprecateReplaceLog('echarts.format.formatTime', 'echarts.time.format');
  16081. }
  16082. if (tpl === 'week' || tpl === 'month' || tpl === 'quarter' || tpl === 'half-year' || tpl === 'year') {
  16083. tpl = 'MM-dd\nyyyy';
  16084. }
  16085. var date = parseDate(value);
  16086. var utc = isUTC ? 'UTC' : '';
  16087. var y = date['get' + utc + 'FullYear']();
  16088. var M = date['get' + utc + 'Month']() + 1;
  16089. var d = date['get' + utc + 'Date']();
  16090. var h = date['get' + utc + 'Hours']();
  16091. var m = date['get' + utc + 'Minutes']();
  16092. var s = date['get' + utc + 'Seconds']();
  16093. var S = date['get' + utc + 'Milliseconds']();
  16094. tpl = tpl.replace('MM', pad(M, 2)).replace('M', M).replace('yyyy', y).replace('yy', y % 100 + '').replace('dd', pad(d, 2)).replace('d', d).replace('hh', pad(h, 2)).replace('h', h).replace('mm', pad(m, 2)).replace('m', m).replace('ss', pad(s, 2)).replace('s', s).replace('SSS', pad(S, 3));
  16095. return tpl;
  16096. }
  16097. /**
  16098. * Capital first
  16099. * @param {string} str
  16100. * @return {string}
  16101. */
  16102. function capitalFirst(str) {
  16103. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  16104. }
  16105. /**
  16106. * @return Never be null/undefined.
  16107. */
  16108. function convertToColorString(color, defaultColor) {
  16109. defaultColor = defaultColor || 'transparent';
  16110. return isString(color) ? color : isObject$1(color) ? color.colorStops && (color.colorStops[0] || {}).color || defaultColor : defaultColor;
  16111. }
  16112. /**
  16113. * open new tab
  16114. * @param link url
  16115. * @param target blank or self
  16116. */
  16117. function windowOpen(link, target) {
  16118. /* global window */
  16119. if (target === '_blank' || target === 'blank') {
  16120. var blank = window.open();
  16121. blank.opener = null;
  16122. blank.location.href = link;
  16123. } else {
  16124. window.open(link, target);
  16125. }
  16126. }
  16127. /*
  16128. * Licensed to the Apache Software Foundation (ASF) under one
  16129. * or more contributor license agreements. See the NOTICE file
  16130. * distributed with this work for additional information
  16131. * regarding copyright ownership. The ASF licenses this file
  16132. * to you under the Apache License, Version 2.0 (the
  16133. * "License"); you may not use this file except in compliance
  16134. * with the License. You may obtain a copy of the License at
  16135. *
  16136. * http://www.apache.org/licenses/LICENSE-2.0
  16137. *
  16138. * Unless required by applicable law or agreed to in writing,
  16139. * software distributed under the License is distributed on an
  16140. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16141. * KIND, either express or implied. See the License for the
  16142. * specific language governing permissions and limitations
  16143. * under the License.
  16144. */
  16145. /**
  16146. * AUTO-GENERATED FILE. DO NOT MODIFY.
  16147. */
  16148. /*
  16149. * Licensed to the Apache Software Foundation (ASF) under one
  16150. * or more contributor license agreements. See the NOTICE file
  16151. * distributed with this work for additional information
  16152. * regarding copyright ownership. The ASF licenses this file
  16153. * to you under the Apache License, Version 2.0 (the
  16154. * "License"); you may not use this file except in compliance
  16155. * with the License. You may obtain a copy of the License at
  16156. *
  16157. * http://www.apache.org/licenses/LICENSE-2.0
  16158. *
  16159. * Unless required by applicable law or agreed to in writing,
  16160. * software distributed under the License is distributed on an
  16161. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16162. * KIND, either express or implied. See the License for the
  16163. * specific language governing permissions and limitations
  16164. * under the License.
  16165. */
  16166. // Layout helpers for each component positioning
  16167. var each$2 = each$1;
  16168. /**
  16169. * @public
  16170. */
  16171. var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height'];
  16172. /**
  16173. * @public
  16174. */
  16175. var HV_NAMES = [['width', 'left', 'right'], ['height', 'top', 'bottom']];
  16176. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  16177. var x = 0;
  16178. var y = 0;
  16179. if (maxWidth == null) {
  16180. maxWidth = Infinity;
  16181. }
  16182. if (maxHeight == null) {
  16183. maxHeight = Infinity;
  16184. }
  16185. var currentLineMaxSize = 0;
  16186. group.eachChild(function (child, idx) {
  16187. var rect = child.getBoundingRect();
  16188. var nextChild = group.childAt(idx + 1);
  16189. var nextChildRect = nextChild && nextChild.getBoundingRect();
  16190. var nextX;
  16191. var nextY;
  16192. if (orient === 'horizontal') {
  16193. var moveX = rect.width + (nextChildRect ? -nextChildRect.x + rect.x : 0);
  16194. nextX = x + moveX; // Wrap when width exceeds maxWidth or meet a `newline` group
  16195. // FIXME compare before adding gap?
  16196. if (nextX > maxWidth || child.newline) {
  16197. x = 0;
  16198. nextX = moveX;
  16199. y += currentLineMaxSize + gap;
  16200. currentLineMaxSize = rect.height;
  16201. } else {
  16202. // FIXME: consider rect.y is not `0`?
  16203. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  16204. }
  16205. } else {
  16206. var moveY = rect.height + (nextChildRect ? -nextChildRect.y + rect.y : 0);
  16207. nextY = y + moveY; // Wrap when width exceeds maxHeight or meet a `newline` group
  16208. if (nextY > maxHeight || child.newline) {
  16209. x += currentLineMaxSize + gap;
  16210. y = 0;
  16211. nextY = moveY;
  16212. currentLineMaxSize = rect.width;
  16213. } else {
  16214. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  16215. }
  16216. }
  16217. if (child.newline) {
  16218. return;
  16219. }
  16220. child.x = x;
  16221. child.y = y;
  16222. child.markRedraw();
  16223. orient === 'horizontal' ? x = nextX + gap : y = nextY + gap;
  16224. });
  16225. }
  16226. /**
  16227. * VBox or HBox layouting
  16228. * @param {string} orient
  16229. * @param {module:zrender/graphic/Group} group
  16230. * @param {number} gap
  16231. * @param {number} [width=Infinity]
  16232. * @param {number} [height=Infinity]
  16233. */
  16234. var box = boxLayout;
  16235. /**
  16236. * VBox layouting
  16237. * @param {module:zrender/graphic/Group} group
  16238. * @param {number} gap
  16239. * @param {number} [width=Infinity]
  16240. * @param {number} [height=Infinity]
  16241. */
  16242. var vbox = curry(boxLayout, 'vertical');
  16243. /**
  16244. * HBox layouting
  16245. * @param {module:zrender/graphic/Group} group
  16246. * @param {number} gap
  16247. * @param {number} [width=Infinity]
  16248. * @param {number} [height=Infinity]
  16249. */
  16250. var hbox = curry(boxLayout, 'horizontal');
  16251. /**
  16252. * If x or x2 is not specified or 'center' 'left' 'right',
  16253. * the width would be as long as possible.
  16254. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  16255. * the height would be as long as possible.
  16256. */
  16257. function getAvailableSize(positionInfo, containerRect, margin) {
  16258. var containerWidth = containerRect.width;
  16259. var containerHeight = containerRect.height;
  16260. var x = parsePercent$1(positionInfo.left, containerWidth);
  16261. var y = parsePercent$1(positionInfo.top, containerHeight);
  16262. var x2 = parsePercent$1(positionInfo.right, containerWidth);
  16263. var y2 = parsePercent$1(positionInfo.bottom, containerHeight);
  16264. (isNaN(x) || isNaN(parseFloat(positionInfo.left))) && (x = 0);
  16265. (isNaN(x2) || isNaN(parseFloat(positionInfo.right))) && (x2 = containerWidth);
  16266. (isNaN(y) || isNaN(parseFloat(positionInfo.top))) && (y = 0);
  16267. (isNaN(y2) || isNaN(parseFloat(positionInfo.bottom))) && (y2 = containerHeight);
  16268. margin = normalizeCssArray$1(margin || 0);
  16269. return {
  16270. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  16271. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  16272. };
  16273. }
  16274. /**
  16275. * Parse position info.
  16276. */
  16277. function getLayoutRect(positionInfo, containerRect, margin) {
  16278. margin = normalizeCssArray$1(margin || 0);
  16279. var containerWidth = containerRect.width;
  16280. var containerHeight = containerRect.height;
  16281. var left = parsePercent$1(positionInfo.left, containerWidth);
  16282. var top = parsePercent$1(positionInfo.top, containerHeight);
  16283. var right = parsePercent$1(positionInfo.right, containerWidth);
  16284. var bottom = parsePercent$1(positionInfo.bottom, containerHeight);
  16285. var width = parsePercent$1(positionInfo.width, containerWidth);
  16286. var height = parsePercent$1(positionInfo.height, containerHeight);
  16287. var verticalMargin = margin[2] + margin[0];
  16288. var horizontalMargin = margin[1] + margin[3];
  16289. var aspect = positionInfo.aspect; // If width is not specified, calculate width from left and right
  16290. if (isNaN(width)) {
  16291. width = containerWidth - right - horizontalMargin - left;
  16292. }
  16293. if (isNaN(height)) {
  16294. height = containerHeight - bottom - verticalMargin - top;
  16295. }
  16296. if (aspect != null) {
  16297. // If width and height are not given
  16298. // 1. Graph should not exceeds the container
  16299. // 2. Aspect must be keeped
  16300. // 3. Graph should take the space as more as possible
  16301. // FIXME
  16302. // Margin is not considered, because there is no case that both
  16303. // using margin and aspect so far.
  16304. if (isNaN(width) && isNaN(height)) {
  16305. if (aspect > containerWidth / containerHeight) {
  16306. width = containerWidth * 0.8;
  16307. } else {
  16308. height = containerHeight * 0.8;
  16309. }
  16310. } // Calculate width or height with given aspect
  16311. if (isNaN(width)) {
  16312. width = aspect * height;
  16313. }
  16314. if (isNaN(height)) {
  16315. height = width / aspect;
  16316. }
  16317. } // If left is not specified, calculate left from right and width
  16318. if (isNaN(left)) {
  16319. left = containerWidth - right - width - horizontalMargin;
  16320. }
  16321. if (isNaN(top)) {
  16322. top = containerHeight - bottom - height - verticalMargin;
  16323. } // Align left and top
  16324. switch (positionInfo.left || positionInfo.right) {
  16325. case 'center':
  16326. left = containerWidth / 2 - width / 2 - margin[3];
  16327. break;
  16328. case 'right':
  16329. left = containerWidth - width - horizontalMargin;
  16330. break;
  16331. }
  16332. switch (positionInfo.top || positionInfo.bottom) {
  16333. case 'middle':
  16334. case 'center':
  16335. top = containerHeight / 2 - height / 2 - margin[0];
  16336. break;
  16337. case 'bottom':
  16338. top = containerHeight - height - verticalMargin;
  16339. break;
  16340. } // If something is wrong and left, top, width, height are calculated as NaN
  16341. left = left || 0;
  16342. top = top || 0;
  16343. if (isNaN(width)) {
  16344. // Width may be NaN if only one value is given except width
  16345. width = containerWidth - horizontalMargin - left - (right || 0);
  16346. }
  16347. if (isNaN(height)) {
  16348. // Height may be NaN if only one value is given except height
  16349. height = containerHeight - verticalMargin - top - (bottom || 0);
  16350. }
  16351. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  16352. rect.margin = margin;
  16353. return rect;
  16354. }
  16355. /**
  16356. * Position a zr element in viewport
  16357. * Group position is specified by either
  16358. * {left, top}, {right, bottom}
  16359. * If all properties exists, right and bottom will be igonred.
  16360. *
  16361. * Logic:
  16362. * 1. Scale (against origin point in parent coord)
  16363. * 2. Rotate (against origin point in parent coord)
  16364. * 3. Traslate (with el.position by this method)
  16365. * So this method only fixes the last step 'Traslate', which does not affect
  16366. * scaling and rotating.
  16367. *
  16368. * If be called repeatly with the same input el, the same result will be gotten.
  16369. *
  16370. * @param el Should have `getBoundingRect` method.
  16371. * @param positionInfo
  16372. * @param positionInfo.left
  16373. * @param positionInfo.top
  16374. * @param positionInfo.right
  16375. * @param positionInfo.bottom
  16376. * @param positionInfo.width Only for opt.boundingModel: 'raw'
  16377. * @param positionInfo.height Only for opt.boundingModel: 'raw'
  16378. * @param containerRect
  16379. * @param margin
  16380. * @param opt
  16381. * @param opt.hv Only horizontal or only vertical. Default to be [1, 1]
  16382. * @param opt.boundingMode
  16383. * Specify how to calculate boundingRect when locating.
  16384. * 'all': Position the boundingRect that is transformed and uioned
  16385. * both itself and its descendants.
  16386. * This mode simplies confine the elements in the bounding
  16387. * of their container (e.g., using 'right: 0').
  16388. * 'raw': Position the boundingRect that is not transformed and only itself.
  16389. * This mode is useful when you want a element can overflow its
  16390. * container. (Consider a rotated circle needs to be located in a corner.)
  16391. * In this mode positionInfo.width/height can only be number.
  16392. */
  16393. function positionElement(el, positionInfo, containerRect, margin, opt) {
  16394. var h = !opt || !opt.hv || opt.hv[0];
  16395. var v = !opt || !opt.hv || opt.hv[1];
  16396. var boundingMode = opt && opt.boundingMode || 'all';
  16397. if (!h && !v) {
  16398. return;
  16399. }
  16400. var rect;
  16401. if (boundingMode === 'raw') {
  16402. rect = el.type === 'group' ? new BoundingRect(0, 0, +positionInfo.width || 0, +positionInfo.height || 0) : el.getBoundingRect();
  16403. } else {
  16404. rect = el.getBoundingRect();
  16405. if (el.needLocalTransform()) {
  16406. var transform = el.getLocalTransform(); // Notice: raw rect may be inner object of el,
  16407. // which should not be modified.
  16408. rect = rect.clone();
  16409. rect.applyTransform(transform);
  16410. }
  16411. } // The real width and height can not be specified but calculated by the given el.
  16412. var layoutRect = getLayoutRect(defaults({
  16413. width: rect.width,
  16414. height: rect.height
  16415. }, positionInfo), containerRect, margin); // Because 'tranlate' is the last step in transform
  16416. // (see zrender/core/Transformable#getLocalTransform),
  16417. // we can just only modify el.position to get final result.
  16418. var dx = h ? layoutRect.x - rect.x : 0;
  16419. var dy = v ? layoutRect.y - rect.y : 0;
  16420. if (boundingMode === 'raw') {
  16421. el.x = dx;
  16422. el.y = dy;
  16423. } else {
  16424. el.x += dx;
  16425. el.y += dy;
  16426. }
  16427. el.markRedraw();
  16428. }
  16429. /**
  16430. * @param option Contains some of the properties in HV_NAMES.
  16431. * @param hvIdx 0: horizontal; 1: vertical.
  16432. */
  16433. function sizeCalculable(option, hvIdx) {
  16434. return option[HV_NAMES[hvIdx][0]] != null || option[HV_NAMES[hvIdx][1]] != null && option[HV_NAMES[hvIdx][2]] != null;
  16435. }
  16436. function fetchLayoutMode(ins) {
  16437. var layoutMode = ins.layoutMode || ins.constructor.layoutMode;
  16438. return isObject$1(layoutMode) ? layoutMode : layoutMode ? {
  16439. type: layoutMode
  16440. } : null;
  16441. }
  16442. /**
  16443. * Consider Case:
  16444. * When default option has {left: 0, width: 100}, and we set {right: 0}
  16445. * through setOption or media query, using normal zrUtil.merge will cause
  16446. * {right: 0} does not take effect.
  16447. *
  16448. * @example
  16449. * ComponentModel.extend({
  16450. * init: function () {
  16451. * ...
  16452. * let inputPositionParams = layout.getLayoutParams(option);
  16453. * this.mergeOption(inputPositionParams);
  16454. * },
  16455. * mergeOption: function (newOption) {
  16456. * newOption && zrUtil.merge(thisOption, newOption, true);
  16457. * layout.mergeLayoutParam(thisOption, newOption);
  16458. * }
  16459. * });
  16460. *
  16461. * @param targetOption
  16462. * @param newOption
  16463. * @param opt
  16464. */
  16465. function mergeLayoutParam(targetOption, newOption, opt) {
  16466. var ignoreSize = opt && opt.ignoreSize;
  16467. !isArray(ignoreSize) && (ignoreSize = [ignoreSize, ignoreSize]);
  16468. var hResult = merge$$1(HV_NAMES[0], 0);
  16469. var vResult = merge$$1(HV_NAMES[1], 1);
  16470. copy(HV_NAMES[0], targetOption, hResult);
  16471. copy(HV_NAMES[1], targetOption, vResult);
  16472. function merge$$1(names, hvIdx) {
  16473. var newParams = {};
  16474. var newValueCount = 0;
  16475. var merged = {};
  16476. var mergedValueCount = 0;
  16477. var enoughParamNumber = 2;
  16478. each$2(names, function (name) {
  16479. merged[name] = targetOption[name];
  16480. });
  16481. each$2(names, function (name) {
  16482. // Consider case: newOption.width is null, which is
  16483. // set by user for removing width setting.
  16484. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  16485. hasValue(newParams, name) && newValueCount++;
  16486. hasValue(merged, name) && mergedValueCount++;
  16487. });
  16488. if (ignoreSize[hvIdx]) {
  16489. // Only one of left/right is premitted to exist.
  16490. if (hasValue(newOption, names[1])) {
  16491. merged[names[2]] = null;
  16492. } else if (hasValue(newOption, names[2])) {
  16493. merged[names[1]] = null;
  16494. }
  16495. return merged;
  16496. } // Case: newOption: {width: ..., right: ...},
  16497. // or targetOption: {right: ...} and newOption: {width: ...},
  16498. // There is no conflict when merged only has params count
  16499. // little than enoughParamNumber.
  16500. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  16501. return merged;
  16502. } // Case: newOption: {width: ..., right: ...},
  16503. // Than we can make sure user only want those two, and ignore
  16504. // all origin params in targetOption.
  16505. else if (newValueCount >= enoughParamNumber) {
  16506. return newParams;
  16507. } else {
  16508. // Chose another param from targetOption by priority.
  16509. for (var i = 0; i < names.length; i++) {
  16510. var name_1 = names[i];
  16511. if (!hasProp(newParams, name_1) && hasProp(targetOption, name_1)) {
  16512. newParams[name_1] = targetOption[name_1];
  16513. break;
  16514. }
  16515. }
  16516. return newParams;
  16517. }
  16518. }
  16519. function hasProp(obj, name) {
  16520. return obj.hasOwnProperty(name);
  16521. }
  16522. function hasValue(obj, name) {
  16523. return obj[name] != null && obj[name] !== 'auto';
  16524. }
  16525. function copy(names, target, source) {
  16526. each$2(names, function (name) {
  16527. target[name] = source[name];
  16528. });
  16529. }
  16530. }
  16531. /**
  16532. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  16533. */
  16534. function getLayoutParams(source) {
  16535. return copyLayoutParams({}, source);
  16536. }
  16537. /**
  16538. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  16539. * @param {Object} source
  16540. * @return {Object} Result contains those props.
  16541. */
  16542. function copyLayoutParams(target, source) {
  16543. source && target && each$2(LOCATION_PARAMS, function (name) {
  16544. source.hasOwnProperty(name) && (target[name] = source[name]);
  16545. });
  16546. return target;
  16547. }
  16548. /*
  16549. * Licensed to the Apache Software Foundation (ASF) under one
  16550. * or more contributor license agreements. See the NOTICE file
  16551. * distributed with this work for additional information
  16552. * regarding copyright ownership. The ASF licenses this file
  16553. * to you under the Apache License, Version 2.0 (the
  16554. * "License"); you may not use this file except in compliance
  16555. * with the License. You may obtain a copy of the License at
  16556. *
  16557. * http://www.apache.org/licenses/LICENSE-2.0
  16558. *
  16559. * Unless required by applicable law or agreed to in writing,
  16560. * software distributed under the License is distributed on an
  16561. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16562. * KIND, either express or implied. See the License for the
  16563. * specific language governing permissions and limitations
  16564. * under the License.
  16565. */
  16566. /**
  16567. * AUTO-GENERATED FILE. DO NOT MODIFY.
  16568. */
  16569. /*
  16570. * Licensed to the Apache Software Foundation (ASF) under one
  16571. * or more contributor license agreements. See the NOTICE file
  16572. * distributed with this work for additional information
  16573. * regarding copyright ownership. The ASF licenses this file
  16574. * to you under the Apache License, Version 2.0 (the
  16575. * "License"); you may not use this file except in compliance
  16576. * with the License. You may obtain a copy of the License at
  16577. *
  16578. * http://www.apache.org/licenses/LICENSE-2.0
  16579. *
  16580. * Unless required by applicable law or agreed to in writing,
  16581. * software distributed under the License is distributed on an
  16582. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16583. * KIND, either express or implied. See the License for the
  16584. * specific language governing permissions and limitations
  16585. * under the License.
  16586. */
  16587. var inner = makeInner();
  16588. var ComponentModel =
  16589. /** @class */
  16590. function (_super) {
  16591. __extends(ComponentModel, _super);
  16592. function ComponentModel(option, parentModel, ecModel) {
  16593. var _this = _super.call(this, option, parentModel, ecModel) || this;
  16594. _this.uid = getUID('ec_cpt_model');
  16595. return _this;
  16596. }
  16597. ComponentModel.prototype.init = function (option, parentModel, ecModel) {
  16598. this.mergeDefaultAndTheme(option, ecModel);
  16599. };
  16600. ComponentModel.prototype.mergeDefaultAndTheme = function (option, ecModel) {
  16601. var layoutMode = fetchLayoutMode(this);
  16602. var inputPositionParams = layoutMode ? getLayoutParams(option) : {};
  16603. var themeModel = ecModel.getTheme();
  16604. merge(option, themeModel.get(this.mainType));
  16605. merge(option, this.getDefaultOption());
  16606. if (layoutMode) {
  16607. mergeLayoutParam(option, inputPositionParams, layoutMode);
  16608. }
  16609. };
  16610. ComponentModel.prototype.mergeOption = function (option, ecModel) {
  16611. merge(this.option, option, true);
  16612. var layoutMode = fetchLayoutMode(this);
  16613. if (layoutMode) {
  16614. mergeLayoutParam(this.option, option, layoutMode);
  16615. }
  16616. };
  16617. /**
  16618. * Called immediately after `init` or `mergeOption` of this instance called.
  16619. */
  16620. ComponentModel.prototype.optionUpdated = function (newCptOption, isInit) {};
  16621. /**
  16622. * [How to declare defaultOption]:
  16623. *
  16624. * (A) If using class declaration in typescript (since echarts 5):
  16625. * ```ts
  16626. * import {ComponentOption} from '../model/option';
  16627. * export interface XxxOption extends ComponentOption {
  16628. * aaa: number
  16629. * }
  16630. * export class XxxModel extends Component {
  16631. * static type = 'xxx';
  16632. * static defaultOption: XxxOption = {
  16633. * aaa: 123
  16634. * }
  16635. * }
  16636. * Component.registerClass(XxxModel);
  16637. * ```
  16638. * ```ts
  16639. * import {inheritDefaultOption} from '../util/component';
  16640. * import {XxxModel, XxxOption} from './XxxModel';
  16641. * export interface XxxSubOption extends XxxOption {
  16642. * bbb: number
  16643. * }
  16644. * class XxxSubModel extends XxxModel {
  16645. * static defaultOption: XxxSubOption = inheritDefaultOption(XxxModel.defaultOption, {
  16646. * bbb: 456
  16647. * })
  16648. * fn() {
  16649. * let opt = this.getDefaultOption();
  16650. * // opt is {aaa: 123, bbb: 456}
  16651. * }
  16652. * }
  16653. * ```
  16654. *
  16655. * (B) If using class extend (previous approach in echarts 3 & 4):
  16656. * ```js
  16657. * let XxxComponent = Component.extend({
  16658. * defaultOption: {
  16659. * xx: 123
  16660. * }
  16661. * })
  16662. * ```
  16663. * ```js
  16664. * let XxxSubComponent = XxxComponent.extend({
  16665. * defaultOption: {
  16666. * yy: 456
  16667. * },
  16668. * fn: function () {
  16669. * let opt = this.getDefaultOption();
  16670. * // opt is {xx: 123, yy: 456}
  16671. * }
  16672. * })
  16673. * ```
  16674. */
  16675. ComponentModel.prototype.getDefaultOption = function () {
  16676. var ctor = this.constructor; // If using class declaration, it is different to travel super class
  16677. // in legacy env and auto merge defaultOption. So if using class
  16678. // declaration, defaultOption should be merged manually.
  16679. if (!isExtendedClass(ctor)) {
  16680. // When using ts class, defaultOption must be declared as static.
  16681. return ctor.defaultOption;
  16682. } // FIXME: remove this approach?
  16683. var fields = inner(this);
  16684. if (!fields.defaultOption) {
  16685. var optList = [];
  16686. var clz = ctor;
  16687. while (clz) {
  16688. var opt = clz.prototype.defaultOption;
  16689. opt && optList.push(opt);
  16690. clz = clz.superClass;
  16691. }
  16692. var defaultOption = {};
  16693. for (var i = optList.length - 1; i >= 0; i--) {
  16694. defaultOption = merge(defaultOption, optList[i], true);
  16695. }
  16696. fields.defaultOption = defaultOption;
  16697. }
  16698. return fields.defaultOption;
  16699. };
  16700. /**
  16701. * Notice: always force to input param `useDefault` in case that forget to consider it.
  16702. * The same behavior as `modelUtil.parseFinder`.
  16703. *
  16704. * @param useDefault In many cases like series refer axis and axis refer grid,
  16705. * If axis index / axis id not specified, use the first target as default.
  16706. * In other cases like dataZoom refer axis, if not specified, measn no refer.
  16707. */
  16708. ComponentModel.prototype.getReferringComponents = function (mainType, opt) {
  16709. var indexKey = mainType + 'Index';
  16710. var idKey = mainType + 'Id';
  16711. return queryReferringComponents(this.ecModel, mainType, {
  16712. index: this.get(indexKey, true),
  16713. id: this.get(idKey, true)
  16714. }, opt);
  16715. };
  16716. ComponentModel.prototype.getBoxLayoutParams = function () {
  16717. // Consider itself having box layout configs.
  16718. var boxLayoutModel = this;
  16719. return {
  16720. left: boxLayoutModel.get('left'),
  16721. top: boxLayoutModel.get('top'),
  16722. right: boxLayoutModel.get('right'),
  16723. bottom: boxLayoutModel.get('bottom'),
  16724. width: boxLayoutModel.get('width'),
  16725. height: boxLayoutModel.get('height')
  16726. };
  16727. };
  16728. ComponentModel.protoInitialize = function () {
  16729. var proto = ComponentModel.prototype;
  16730. proto.type = 'component';
  16731. proto.id = '';
  16732. proto.name = '';
  16733. proto.mainType = '';
  16734. proto.subType = '';
  16735. proto.componentIndex = 0;
  16736. }();
  16737. return ComponentModel;
  16738. }(Model);
  16739. mountExtend(ComponentModel, Model);
  16740. enableClassManagement(ComponentModel);
  16741. enableSubTypeDefaulter(ComponentModel);
  16742. enableTopologicalTravel(ComponentModel, getDependencies);
  16743. function getDependencies(componentType) {
  16744. var deps = [];
  16745. each$1(ComponentModel.getClassesByMainType(componentType), function (clz) {
  16746. deps = deps.concat(clz.dependencies || clz.prototype.dependencies || []);
  16747. }); // Ensure main type.
  16748. deps = map(deps, function (type) {
  16749. return parseClassType(type).main;
  16750. }); // Hack dataset for convenience.
  16751. if (componentType !== 'dataset' && indexOf$1(deps, 'dataset') <= 0) {
  16752. deps.unshift('dataset');
  16753. }
  16754. return deps;
  16755. }
  16756. /*
  16757. * Licensed to the Apache Software Foundation (ASF) under one
  16758. * or more contributor license agreements. See the NOTICE file
  16759. * distributed with this work for additional information
  16760. * regarding copyright ownership. The ASF licenses this file
  16761. * to you under the Apache License, Version 2.0 (the
  16762. * "License"); you may not use this file except in compliance
  16763. * with the License. You may obtain a copy of the License at
  16764. *
  16765. * http://www.apache.org/licenses/LICENSE-2.0
  16766. *
  16767. * Unless required by applicable law or agreed to in writing,
  16768. * software distributed under the License is distributed on an
  16769. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16770. * KIND, either express or implied. See the License for the
  16771. * specific language governing permissions and limitations
  16772. * under the License.
  16773. */
  16774. /**
  16775. * AUTO-GENERATED FILE. DO NOT MODIFY.
  16776. */
  16777. /*
  16778. * Licensed to the Apache Software Foundation (ASF) under one
  16779. * or more contributor license agreements. See the NOTICE file
  16780. * distributed with this work for additional information
  16781. * regarding copyright ownership. The ASF licenses this file
  16782. * to you under the Apache License, Version 2.0 (the
  16783. * "License"); you may not use this file except in compliance
  16784. * with the License. You may obtain a copy of the License at
  16785. *
  16786. * http://www.apache.org/licenses/LICENSE-2.0
  16787. *
  16788. * Unless required by applicable law or agreed to in writing,
  16789. * software distributed under the License is distributed on an
  16790. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16791. * KIND, either express or implied. See the License for the
  16792. * specific language governing permissions and limitations
  16793. * under the License.
  16794. */
  16795. var platform = ''; // Navigator not exists in node
  16796. if (typeof navigator !== 'undefined') {
  16797. /* global navigator */
  16798. platform = navigator.platform || '';
  16799. }
  16800. var decalColor = 'rgba(0, 0, 0, 0.2)';
  16801. var globalDefault = {
  16802. darkMode: 'auto',
  16803. // backgroundColor: 'rgba(0,0,0,0)',
  16804. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  16805. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  16806. // Light colors:
  16807. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  16808. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  16809. // Dark colors:
  16810. // color: [
  16811. // '#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae', '#749f83',
  16812. // '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'
  16813. // ],
  16814. color: [// '#51689b', '#ce5c5c', '#fbc357', '#8fbf8f', '#659d84', '#fb8e6a', '#c77288', '#786090', '#91c4c5', '#6890ba'
  16815. '#5470c6', '#91cc75', '#fac858', '#ee6666', '#73c0de', '#3ba272', '#fc8452', '#9a60b4', '#ea7ccc'],
  16816. gradientColor: ['#f6efa6', '#d88273', '#bf444c'],
  16817. aria: {
  16818. decal: {
  16819. decals: [{
  16820. color: decalColor,
  16821. dashArrayX: [1, 0],
  16822. dashArrayY: [2, 5],
  16823. symbolSize: 1,
  16824. rotation: Math.PI / 6
  16825. }, {
  16826. color: decalColor,
  16827. symbol: 'circle',
  16828. dashArrayX: [[8, 8], [0, 8, 8, 0]],
  16829. dashArrayY: [6, 0],
  16830. symbolSize: 0.8
  16831. }, {
  16832. color: decalColor,
  16833. dashArrayX: [1, 0],
  16834. dashArrayY: [4, 3],
  16835. rotation: -Math.PI / 4
  16836. }, {
  16837. color: decalColor,
  16838. dashArrayX: [[6, 6], [0, 6, 6, 0]],
  16839. dashArrayY: [6, 0]
  16840. }, {
  16841. color: decalColor,
  16842. dashArrayX: [[1, 0], [1, 6]],
  16843. dashArrayY: [1, 0, 6, 0],
  16844. rotation: Math.PI / 4
  16845. }, {
  16846. color: decalColor,
  16847. symbol: 'triangle',
  16848. dashArrayX: [[9, 9], [0, 9, 9, 0]],
  16849. dashArrayY: [7, 2],
  16850. symbolSize: 0.75
  16851. }]
  16852. }
  16853. },
  16854. // If xAxis and yAxis declared, grid is created by default.
  16855. // grid: {},
  16856. textStyle: {
  16857. // color: '#000',
  16858. // decoration: 'none',
  16859. // PENDING
  16860. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  16861. // fontFamily: 'Arial, Verdana, sans-serif',
  16862. fontSize: 12,
  16863. fontStyle: 'normal',
  16864. fontWeight: 'normal'
  16865. },
  16866. // http://blogs.adobe.com/webplatform/2014/02/24/using-blend-modes-in-html-canvas/
  16867. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  16868. // Default is source-over
  16869. blendMode: null,
  16870. stateAnimation: {
  16871. duration: 300,
  16872. easing: 'cubicOut'
  16873. },
  16874. animation: 'auto',
  16875. animationDuration: 1000,
  16876. animationDurationUpdate: 500,
  16877. animationEasing: 'cubicInOut',
  16878. animationEasingUpdate: 'cubicInOut',
  16879. animationThreshold: 2000,
  16880. // Configuration for progressive/incremental rendering
  16881. progressiveThreshold: 3000,
  16882. progressive: 400,
  16883. // Threshold of if use single hover layer to optimize.
  16884. // It is recommended that `hoverLayerThreshold` is equivalent to or less than
  16885. // `progressiveThreshold`, otherwise hover will cause restart of progressive,
  16886. // which is unexpected.
  16887. // see example <echarts/test/heatmap-large.html>.
  16888. hoverLayerThreshold: 3000,
  16889. // See: module:echarts/scale/Time
  16890. useUTC: false
  16891. };
  16892. /*
  16893. * Licensed to the Apache Software Foundation (ASF) under one
  16894. * or more contributor license agreements. See the NOTICE file
  16895. * distributed with this work for additional information
  16896. * regarding copyright ownership. The ASF licenses this file
  16897. * to you under the Apache License, Version 2.0 (the
  16898. * "License"); you may not use this file except in compliance
  16899. * with the License. You may obtain a copy of the License at
  16900. *
  16901. * http://www.apache.org/licenses/LICENSE-2.0
  16902. *
  16903. * Unless required by applicable law or agreed to in writing,
  16904. * software distributed under the License is distributed on an
  16905. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16906. * KIND, either express or implied. See the License for the
  16907. * specific language governing permissions and limitations
  16908. * under the License.
  16909. */
  16910. /**
  16911. * AUTO-GENERATED FILE. DO NOT MODIFY.
  16912. */
  16913. /*
  16914. * Licensed to the Apache Software Foundation (ASF) under one
  16915. * or more contributor license agreements. See the NOTICE file
  16916. * distributed with this work for additional information
  16917. * regarding copyright ownership. The ASF licenses this file
  16918. * to you under the Apache License, Version 2.0 (the
  16919. * "License"); you may not use this file except in compliance
  16920. * with the License. You may obtain a copy of the License at
  16921. *
  16922. * http://www.apache.org/licenses/LICENSE-2.0
  16923. *
  16924. * Unless required by applicable law or agreed to in writing,
  16925. * software distributed under the License is distributed on an
  16926. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16927. * KIND, either express or implied. See the License for the
  16928. * specific language governing permissions and limitations
  16929. * under the License.
  16930. */
  16931. var VISUAL_DIMENSIONS = createHashMap(['tooltip', 'label', 'itemName', 'itemId', 'seriesName']);
  16932. var SOURCE_FORMAT_ORIGINAL = 'original';
  16933. var SOURCE_FORMAT_ARRAY_ROWS = 'arrayRows';
  16934. var SOURCE_FORMAT_OBJECT_ROWS = 'objectRows';
  16935. var SOURCE_FORMAT_KEYED_COLUMNS = 'keyedColumns';
  16936. var SOURCE_FORMAT_TYPED_ARRAY = 'typedArray';
  16937. var SOURCE_FORMAT_UNKNOWN = 'unknown';
  16938. var SERIES_LAYOUT_BY_COLUMN = 'column';
  16939. var SERIES_LAYOUT_BY_ROW = 'row';
  16940. /*
  16941. * Licensed to the Apache Software Foundation (ASF) under one
  16942. * or more contributor license agreements. See the NOTICE file
  16943. * distributed with this work for additional information
  16944. * regarding copyright ownership. The ASF licenses this file
  16945. * to you under the Apache License, Version 2.0 (the
  16946. * "License"); you may not use this file except in compliance
  16947. * with the License. You may obtain a copy of the License at
  16948. *
  16949. * http://www.apache.org/licenses/LICENSE-2.0
  16950. *
  16951. * Unless required by applicable law or agreed to in writing,
  16952. * software distributed under the License is distributed on an
  16953. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16954. * KIND, either express or implied. See the License for the
  16955. * specific language governing permissions and limitations
  16956. * under the License.
  16957. */
  16958. /**
  16959. * AUTO-GENERATED FILE. DO NOT MODIFY.
  16960. */
  16961. /*
  16962. * Licensed to the Apache Software Foundation (ASF) under one
  16963. * or more contributor license agreements. See the NOTICE file
  16964. * distributed with this work for additional information
  16965. * regarding copyright ownership. The ASF licenses this file
  16966. * to you under the Apache License, Version 2.0 (the
  16967. * "License"); you may not use this file except in compliance
  16968. * with the License. You may obtain a copy of the License at
  16969. *
  16970. * http://www.apache.org/licenses/LICENSE-2.0
  16971. *
  16972. * Unless required by applicable law or agreed to in writing,
  16973. * software distributed under the License is distributed on an
  16974. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16975. * KIND, either express or implied. See the License for the
  16976. * specific language governing permissions and limitations
  16977. * under the License.
  16978. */
  16979. var BE_ORDINAL = {
  16980. Must: 1,
  16981. Might: 2,
  16982. Not: 3 // Other cases
  16983. };
  16984. var innerGlobalModel = makeInner();
  16985. /**
  16986. * MUST be called before mergeOption of all series.
  16987. */
  16988. function resetSourceDefaulter(ecModel) {
  16989. // `datasetMap` is used to make default encode.
  16990. innerGlobalModel(ecModel).datasetMap = createHashMap();
  16991. }
  16992. /**
  16993. * [The strategy of the arrengment of data dimensions for dataset]:
  16994. * "value way": all axes are non-category axes. So series one by one take
  16995. * several (the number is coordSysDims.length) dimensions from dataset.
  16996. * The result of data arrengment of data dimensions like:
  16997. * | ser0_x | ser0_y | ser1_x | ser1_y | ser2_x | ser2_y |
  16998. * "category way": at least one axis is category axis. So the the first data
  16999. * dimension is always mapped to the first category axis and shared by
  17000. * all of the series. The other data dimensions are taken by series like
  17001. * "value way" does.
  17002. * The result of data arrengment of data dimensions like:
  17003. * | ser_shared_x | ser0_y | ser1_y | ser2_y |
  17004. *
  17005. * @return encode Never be `null/undefined`.
  17006. */
  17007. function makeSeriesEncodeForAxisCoordSys(coordDimensions, seriesModel, source) {
  17008. var encode = {};
  17009. var datasetModel = querySeriesUpstreamDatasetModel(seriesModel); // Currently only make default when using dataset, util more reqirements occur.
  17010. if (!datasetModel || !coordDimensions) {
  17011. return encode;
  17012. }
  17013. var encodeItemName = [];
  17014. var encodeSeriesName = [];
  17015. var ecModel = seriesModel.ecModel;
  17016. var datasetMap = innerGlobalModel(ecModel).datasetMap;
  17017. var key = datasetModel.uid + '_' + source.seriesLayoutBy;
  17018. var baseCategoryDimIndex;
  17019. var categoryWayValueDimStart;
  17020. coordDimensions = coordDimensions.slice();
  17021. each$1(coordDimensions, function (coordDimInfoLoose, coordDimIdx) {
  17022. var coordDimInfo = isObject$1(coordDimInfoLoose) ? coordDimInfoLoose : coordDimensions[coordDimIdx] = {
  17023. name: coordDimInfoLoose
  17024. };
  17025. if (coordDimInfo.type === 'ordinal' && baseCategoryDimIndex == null) {
  17026. baseCategoryDimIndex = coordDimIdx;
  17027. categoryWayValueDimStart = getDataDimCountOnCoordDim(coordDimInfo);
  17028. }
  17029. encode[coordDimInfo.name] = [];
  17030. });
  17031. var datasetRecord = datasetMap.get(key) || datasetMap.set(key, {
  17032. categoryWayDim: categoryWayValueDimStart,
  17033. valueWayDim: 0
  17034. }); // TODO
  17035. // Auto detect first time axis and do arrangement.
  17036. each$1(coordDimensions, function (coordDimInfo, coordDimIdx) {
  17037. var coordDimName = coordDimInfo.name;
  17038. var count = getDataDimCountOnCoordDim(coordDimInfo); // In value way.
  17039. if (baseCategoryDimIndex == null) {
  17040. var start = datasetRecord.valueWayDim;
  17041. pushDim(encode[coordDimName], start, count);
  17042. pushDim(encodeSeriesName, start, count);
  17043. datasetRecord.valueWayDim += count; // ??? TODO give a better default series name rule?
  17044. // especially when encode x y specified.
  17045. // consider: when mutiple series share one dimension
  17046. // category axis, series name should better use
  17047. // the other dimsion name. On the other hand, use
  17048. // both dimensions name.
  17049. } // In category way, the first category axis.
  17050. else if (baseCategoryDimIndex === coordDimIdx) {
  17051. pushDim(encode[coordDimName], 0, count);
  17052. pushDim(encodeItemName, 0, count);
  17053. } // In category way, the other axis.
  17054. else {
  17055. var start = datasetRecord.categoryWayDim;
  17056. pushDim(encode[coordDimName], start, count);
  17057. pushDim(encodeSeriesName, start, count);
  17058. datasetRecord.categoryWayDim += count;
  17059. }
  17060. });
  17061. function pushDim(dimIdxArr, idxFrom, idxCount) {
  17062. for (var i = 0; i < idxCount; i++) {
  17063. dimIdxArr.push(idxFrom + i);
  17064. }
  17065. }
  17066. function getDataDimCountOnCoordDim(coordDimInfo) {
  17067. var dimsDef = coordDimInfo.dimsDef;
  17068. return dimsDef ? dimsDef.length : 1;
  17069. }
  17070. encodeItemName.length && (encode.itemName = encodeItemName);
  17071. encodeSeriesName.length && (encode.seriesName = encodeSeriesName);
  17072. return encode;
  17073. }
  17074. /**
  17075. * Work for data like [{name: ..., value: ...}, ...].
  17076. *
  17077. * @return encode Never be `null/undefined`.
  17078. */
  17079. function makeSeriesEncodeForNameBased(seriesModel, source, dimCount) {
  17080. var encode = {};
  17081. var datasetModel = querySeriesUpstreamDatasetModel(seriesModel); // Currently only make default when using dataset, util more reqirements occur.
  17082. if (!datasetModel) {
  17083. return encode;
  17084. }
  17085. var sourceFormat = source.sourceFormat;
  17086. var dimensionsDefine = source.dimensionsDefine;
  17087. var potentialNameDimIndex;
  17088. if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS || sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  17089. each$1(dimensionsDefine, function (dim, idx) {
  17090. if ((isObject$1(dim) ? dim.name : dim) === 'name') {
  17091. potentialNameDimIndex = idx;
  17092. }
  17093. });
  17094. }
  17095. var idxResult = function () {
  17096. var idxRes0 = {};
  17097. var idxRes1 = {};
  17098. var guessRecords = []; // 5 is an experience value.
  17099. for (var i = 0, len = Math.min(5, dimCount); i < len; i++) {
  17100. var guessResult = doGuessOrdinal(source.data, sourceFormat, source.seriesLayoutBy, dimensionsDefine, source.startIndex, i);
  17101. guessRecords.push(guessResult);
  17102. var isPureNumber = guessResult === BE_ORDINAL.Not; // [Strategy of idxRes0]: find the first BE_ORDINAL.Not as the value dim,
  17103. // and then find a name dim with the priority:
  17104. // "BE_ORDINAL.Might|BE_ORDINAL.Must" > "other dim" > "the value dim itself".
  17105. if (isPureNumber && idxRes0.v == null && i !== potentialNameDimIndex) {
  17106. idxRes0.v = i;
  17107. }
  17108. if (idxRes0.n == null || idxRes0.n === idxRes0.v || !isPureNumber && guessRecords[idxRes0.n] === BE_ORDINAL.Not) {
  17109. idxRes0.n = i;
  17110. }
  17111. if (fulfilled(idxRes0) && guessRecords[idxRes0.n] !== BE_ORDINAL.Not) {
  17112. return idxRes0;
  17113. } // [Strategy of idxRes1]: if idxRes0 not satisfied (that is, no BE_ORDINAL.Not),
  17114. // find the first BE_ORDINAL.Might as the value dim,
  17115. // and then find a name dim with the priority:
  17116. // "other dim" > "the value dim itself".
  17117. // That is for backward compat: number-like (e.g., `'3'`, `'55'`) can be
  17118. // treated as number.
  17119. if (!isPureNumber) {
  17120. if (guessResult === BE_ORDINAL.Might && idxRes1.v == null && i !== potentialNameDimIndex) {
  17121. idxRes1.v = i;
  17122. }
  17123. if (idxRes1.n == null || idxRes1.n === idxRes1.v) {
  17124. idxRes1.n = i;
  17125. }
  17126. }
  17127. }
  17128. function fulfilled(idxResult) {
  17129. return idxResult.v != null && idxResult.n != null;
  17130. }
  17131. return fulfilled(idxRes0) ? idxRes0 : fulfilled(idxRes1) ? idxRes1 : null;
  17132. }();
  17133. if (idxResult) {
  17134. encode.value = [idxResult.v]; // `potentialNameDimIndex` has highest priority.
  17135. var nameDimIndex = potentialNameDimIndex != null ? potentialNameDimIndex : idxResult.n; // By default, label use itemName in charts.
  17136. // So we dont set encodeLabel here.
  17137. encode.itemName = [nameDimIndex];
  17138. encode.seriesName = [nameDimIndex];
  17139. }
  17140. return encode;
  17141. }
  17142. /**
  17143. * @return If return null/undefined, indicate that should not use datasetModel.
  17144. */
  17145. function querySeriesUpstreamDatasetModel(seriesModel) {
  17146. // Caution: consider the scenario:
  17147. // A dataset is declared and a series is not expected to use the dataset,
  17148. // and at the beginning `setOption({series: { noData })` (just prepare other
  17149. // option but no data), then `setOption({series: {data: [...]}); In this case,
  17150. // the user should set an empty array to avoid that dataset is used by default.
  17151. var thisData = seriesModel.get('data', true);
  17152. if (!thisData) {
  17153. return queryReferringComponents(seriesModel.ecModel, 'dataset', {
  17154. index: seriesModel.get('datasetIndex', true),
  17155. id: seriesModel.get('datasetId', true)
  17156. }, SINGLE_REFERRING).models[0];
  17157. }
  17158. }
  17159. /**
  17160. * @return Always return an array event empty.
  17161. */
  17162. function queryDatasetUpstreamDatasetModels(datasetModel) {
  17163. // Only these attributes declared, we by defualt reference to `datasetIndex: 0`.
  17164. // Otherwise, no reference.
  17165. if (!datasetModel.get('transform', true) && !datasetModel.get('fromTransformResult', true)) {
  17166. return [];
  17167. }
  17168. return queryReferringComponents(datasetModel.ecModel, 'dataset', {
  17169. index: datasetModel.get('fromDatasetIndex', true),
  17170. id: datasetModel.get('fromDatasetId', true)
  17171. }, SINGLE_REFERRING).models;
  17172. }
  17173. /**
  17174. * The rule should not be complex, otherwise user might not
  17175. * be able to known where the data is wrong.
  17176. * The code is ugly, but how to make it neat?
  17177. */
  17178. function guessOrdinal(source, dimIndex) {
  17179. return doGuessOrdinal(source.data, source.sourceFormat, source.seriesLayoutBy, source.dimensionsDefine, source.startIndex, dimIndex);
  17180. } // dimIndex may be overflow source data.
  17181. // return {BE_ORDINAL}
  17182. function doGuessOrdinal(data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex) {
  17183. var result; // Experience value.
  17184. var maxLoop = 5;
  17185. if (isTypedArray(data)) {
  17186. return BE_ORDINAL.Not;
  17187. } // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
  17188. // always exists in source.
  17189. var dimName;
  17190. var dimType;
  17191. if (dimensionsDefine) {
  17192. var dimDefItem = dimensionsDefine[dimIndex];
  17193. if (isObject$1(dimDefItem)) {
  17194. dimName = dimDefItem.name;
  17195. dimType = dimDefItem.type;
  17196. } else if (isString(dimDefItem)) {
  17197. dimName = dimDefItem;
  17198. }
  17199. }
  17200. if (dimType != null) {
  17201. return dimType === 'ordinal' ? BE_ORDINAL.Must : BE_ORDINAL.Not;
  17202. }
  17203. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  17204. var dataArrayRows = data;
  17205. if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
  17206. var sample = dataArrayRows[dimIndex];
  17207. for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
  17208. if ((result = detectValue(sample[startIndex + i])) != null) {
  17209. return result;
  17210. }
  17211. }
  17212. } else {
  17213. for (var i = 0; i < dataArrayRows.length && i < maxLoop; i++) {
  17214. var row = dataArrayRows[startIndex + i];
  17215. if (row && (result = detectValue(row[dimIndex])) != null) {
  17216. return result;
  17217. }
  17218. }
  17219. }
  17220. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  17221. var dataObjectRows = data;
  17222. if (!dimName) {
  17223. return BE_ORDINAL.Not;
  17224. }
  17225. for (var i = 0; i < dataObjectRows.length && i < maxLoop; i++) {
  17226. var item = dataObjectRows[i];
  17227. if (item && (result = detectValue(item[dimName])) != null) {
  17228. return result;
  17229. }
  17230. }
  17231. } else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  17232. var dataKeyedColumns = data;
  17233. if (!dimName) {
  17234. return BE_ORDINAL.Not;
  17235. }
  17236. var sample = dataKeyedColumns[dimName];
  17237. if (!sample || isTypedArray(sample)) {
  17238. return BE_ORDINAL.Not;
  17239. }
  17240. for (var i = 0; i < sample.length && i < maxLoop; i++) {
  17241. if ((result = detectValue(sample[i])) != null) {
  17242. return result;
  17243. }
  17244. }
  17245. } else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  17246. var dataOriginal = data;
  17247. for (var i = 0; i < dataOriginal.length && i < maxLoop; i++) {
  17248. var item = dataOriginal[i];
  17249. var val = getDataItemValue(item);
  17250. if (!isArray(val)) {
  17251. return BE_ORDINAL.Not;
  17252. }
  17253. if ((result = detectValue(val[dimIndex])) != null) {
  17254. return result;
  17255. }
  17256. }
  17257. }
  17258. function detectValue(val) {
  17259. var beStr = isString(val); // Consider usage convenience, '1', '2' will be treated as "number".
  17260. // `isFinit('')` get `true`.
  17261. if (val != null && isFinite(val) && val !== '') {
  17262. return beStr ? BE_ORDINAL.Might : BE_ORDINAL.Not;
  17263. } else if (beStr && val !== '-') {
  17264. return BE_ORDINAL.Must;
  17265. }
  17266. }
  17267. return BE_ORDINAL.Not;
  17268. }
  17269. /*
  17270. * Licensed to the Apache Software Foundation (ASF) under one
  17271. * or more contributor license agreements. See the NOTICE file
  17272. * distributed with this work for additional information
  17273. * regarding copyright ownership. The ASF licenses this file
  17274. * to you under the Apache License, Version 2.0 (the
  17275. * "License"); you may not use this file except in compliance
  17276. * with the License. You may obtain a copy of the License at
  17277. *
  17278. * http://www.apache.org/licenses/LICENSE-2.0
  17279. *
  17280. * Unless required by applicable law or agreed to in writing,
  17281. * software distributed under the License is distributed on an
  17282. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17283. * KIND, either express or implied. See the License for the
  17284. * specific language governing permissions and limitations
  17285. * under the License.
  17286. */
  17287. /**
  17288. * AUTO-GENERATED FILE. DO NOT MODIFY.
  17289. */
  17290. /*
  17291. * Licensed to the Apache Software Foundation (ASF) under one
  17292. * or more contributor license agreements. See the NOTICE file
  17293. * distributed with this work for additional information
  17294. * regarding copyright ownership. The ASF licenses this file
  17295. * to you under the Apache License, Version 2.0 (the
  17296. * "License"); you may not use this file except in compliance
  17297. * with the License. You may obtain a copy of the License at
  17298. *
  17299. * http://www.apache.org/licenses/LICENSE-2.0
  17300. *
  17301. * Unless required by applicable law or agreed to in writing,
  17302. * software distributed under the License is distributed on an
  17303. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17304. * KIND, either express or implied. See the License for the
  17305. * specific language governing permissions and limitations
  17306. * under the License.
  17307. */
  17308. var internalOptionCreatorMap = createHashMap();
  17309. function registerInternalOptionCreator(mainType, creator) {
  17310. assert$1(internalOptionCreatorMap.get(mainType) == null && creator);
  17311. internalOptionCreatorMap.set(mainType, creator);
  17312. }
  17313. function concatInternalOptions(ecModel, mainType, newCmptOptionList) {
  17314. var internalOptionCreator = internalOptionCreatorMap.get(mainType);
  17315. if (!internalOptionCreator) {
  17316. return newCmptOptionList;
  17317. }
  17318. var internalOptions = internalOptionCreator(ecModel);
  17319. if (!internalOptions) {
  17320. return newCmptOptionList;
  17321. }
  17322. {
  17323. for (var i = 0; i < internalOptions.length; i++) {
  17324. assert$1(isComponentIdInternal(internalOptions[i]));
  17325. }
  17326. }
  17327. return newCmptOptionList.concat(internalOptions);
  17328. }
  17329. /*
  17330. * Licensed to the Apache Software Foundation (ASF) under one
  17331. * or more contributor license agreements. See the NOTICE file
  17332. * distributed with this work for additional information
  17333. * regarding copyright ownership. The ASF licenses this file
  17334. * to you under the Apache License, Version 2.0 (the
  17335. * "License"); you may not use this file except in compliance
  17336. * with the License. You may obtain a copy of the License at
  17337. *
  17338. * http://www.apache.org/licenses/LICENSE-2.0
  17339. *
  17340. * Unless required by applicable law or agreed to in writing,
  17341. * software distributed under the License is distributed on an
  17342. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17343. * KIND, either express or implied. See the License for the
  17344. * specific language governing permissions and limitations
  17345. * under the License.
  17346. */
  17347. /**
  17348. * AUTO-GENERATED FILE. DO NOT MODIFY.
  17349. */
  17350. /*
  17351. * Licensed to the Apache Software Foundation (ASF) under one
  17352. * or more contributor license agreements. See the NOTICE file
  17353. * distributed with this work for additional information
  17354. * regarding copyright ownership. The ASF licenses this file
  17355. * to you under the Apache License, Version 2.0 (the
  17356. * "License"); you may not use this file except in compliance
  17357. * with the License. You may obtain a copy of the License at
  17358. *
  17359. * http://www.apache.org/licenses/LICENSE-2.0
  17360. *
  17361. * Unless required by applicable law or agreed to in writing,
  17362. * software distributed under the License is distributed on an
  17363. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17364. * KIND, either express or implied. See the License for the
  17365. * specific language governing permissions and limitations
  17366. * under the License.
  17367. */
  17368. var innerColor = makeInner();
  17369. var innerDecal = makeInner();
  17370. var PaletteMixin =
  17371. /** @class */
  17372. function () {
  17373. function PaletteMixin() {}
  17374. PaletteMixin.prototype.getColorFromPalette = function (name, scope, requestNum) {
  17375. var defaultPalette = normalizeToArray(this.get('color', true));
  17376. var layeredPalette = this.get('colorLayer', true);
  17377. return getFromPalette(this, innerColor, defaultPalette, layeredPalette, name, scope, requestNum);
  17378. };
  17379. PaletteMixin.prototype.clearColorPalette = function () {
  17380. clearPalette(this, innerColor);
  17381. };
  17382. return PaletteMixin;
  17383. }();
  17384. function getDecalFromPalette(ecModel, name, scope, requestNum) {
  17385. var defaultDecals = normalizeToArray(ecModel.get(['aria', 'decal', 'decals']));
  17386. return getFromPalette(ecModel, innerDecal, defaultDecals, null, name, scope, requestNum);
  17387. }
  17388. function getNearestPalette(palettes, requestColorNum) {
  17389. var paletteNum = palettes.length; // TODO palettes must be in order
  17390. for (var i = 0; i < paletteNum; i++) {
  17391. if (palettes[i].length > requestColorNum) {
  17392. return palettes[i];
  17393. }
  17394. }
  17395. return palettes[paletteNum - 1];
  17396. }
  17397. /**
  17398. * @param name MUST NOT be null/undefined. Otherwise call this function
  17399. * twise with the same parameters will get different result.
  17400. * @param scope default this.
  17401. * @return Can be null/undefined
  17402. */
  17403. function getFromPalette(that, inner, defaultPalette, layeredPalette, name, scope, requestNum) {
  17404. scope = scope || that;
  17405. var scopeFields = inner(scope);
  17406. var paletteIdx = scopeFields.paletteIdx || 0;
  17407. var paletteNameMap = scopeFields.paletteNameMap = scopeFields.paletteNameMap || {}; // Use `hasOwnProperty` to avoid conflict with Object.prototype.
  17408. if (paletteNameMap.hasOwnProperty(name)) {
  17409. return paletteNameMap[name];
  17410. }
  17411. var palette = requestNum == null || !layeredPalette ? defaultPalette : getNearestPalette(layeredPalette, requestNum); // In case can't find in layered color palette.
  17412. palette = palette || defaultPalette;
  17413. if (!palette || !palette.length) {
  17414. return;
  17415. }
  17416. var pickedPaletteItem = palette[paletteIdx];
  17417. if (name) {
  17418. paletteNameMap[name] = pickedPaletteItem;
  17419. }
  17420. scopeFields.paletteIdx = (paletteIdx + 1) % palette.length;
  17421. return pickedPaletteItem;
  17422. }
  17423. function clearPalette(that, inner) {
  17424. inner(that).paletteIdx = 0;
  17425. inner(that).paletteNameMap = {};
  17426. }
  17427. /*
  17428. * Licensed to the Apache Software Foundation (ASF) under one
  17429. * or more contributor license agreements. See the NOTICE file
  17430. * distributed with this work for additional information
  17431. * regarding copyright ownership. The ASF licenses this file
  17432. * to you under the Apache License, Version 2.0 (the
  17433. * "License"); you may not use this file except in compliance
  17434. * with the License. You may obtain a copy of the License at
  17435. *
  17436. * http://www.apache.org/licenses/LICENSE-2.0
  17437. *
  17438. * Unless required by applicable law or agreed to in writing,
  17439. * software distributed under the License is distributed on an
  17440. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17441. * KIND, either express or implied. See the License for the
  17442. * specific language governing permissions and limitations
  17443. * under the License.
  17444. */
  17445. /**
  17446. * AUTO-GENERATED FILE. DO NOT MODIFY.
  17447. */
  17448. /*
  17449. * Licensed to the Apache Software Foundation (ASF) under one
  17450. * or more contributor license agreements. See the NOTICE file
  17451. * distributed with this work for additional information
  17452. * regarding copyright ownership. The ASF licenses this file
  17453. * to you under the Apache License, Version 2.0 (the
  17454. * "License"); you may not use this file except in compliance
  17455. * with the License. You may obtain a copy of the License at
  17456. *
  17457. * http://www.apache.org/licenses/LICENSE-2.0
  17458. *
  17459. * Unless required by applicable law or agreed to in writing,
  17460. * software distributed under the License is distributed on an
  17461. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17462. * KIND, either express or implied. See the License for the
  17463. * specific language governing permissions and limitations
  17464. * under the License.
  17465. */
  17466. /**
  17467. * Caution: If the mechanism should be changed some day, these cases
  17468. * should be considered:
  17469. *
  17470. * (1) In `merge option` mode, if using the same option to call `setOption`
  17471. * many times, the result should be the same (try our best to ensure that).
  17472. * (2) In `merge option` mode, if a component has no id/name specified, it
  17473. * will be merged by index, and the result sequence of the components is
  17474. * consistent to the original sequence.
  17475. * (3) In `replaceMerge` mode, keep the result sequence of the components is
  17476. * consistent to the original sequence, even though there might result in "hole".
  17477. * (4) `reset` feature (in toolbox). Find detailed info in comments about
  17478. * `mergeOption` in module:echarts/model/OptionManager.
  17479. */
  17480. // Internal method names:
  17481. // -----------------------
  17482. var reCreateSeriesIndices;
  17483. var assertSeriesInitialized;
  17484. var initBase;
  17485. var OPTION_INNER_KEY = '\0_ec_inner';
  17486. var OPTION_INNER_VALUE = 1;
  17487. var BUITIN_COMPONENTS_MAP = {
  17488. grid: 'GridComponent',
  17489. polar: 'PolarComponent',
  17490. geo: 'GeoComponent',
  17491. singleAxis: 'SingleAxisComponent',
  17492. parallel: 'ParallelComponent',
  17493. calendar: 'CalendarComponent',
  17494. graphic: 'GraphicComponent',
  17495. toolbox: 'ToolboxComponent',
  17496. tooltip: 'TooltipComponent',
  17497. axisPointer: 'AxisPointerComponent',
  17498. brush: 'BrushComponent',
  17499. title: 'TitleComponent',
  17500. timeline: 'TimelineComponent',
  17501. markPoint: 'MarkPointComponent',
  17502. markLine: 'MarkLineComponent',
  17503. markArea: 'MarkAreaComponent',
  17504. legend: 'LegendComponent',
  17505. dataZoom: 'DataZoomComponent',
  17506. visualMap: 'VisualMapComponent',
  17507. // aria: 'AriaComponent',
  17508. // dataset: 'DatasetComponent',
  17509. // Dependencies
  17510. xAxis: 'GridComponent',
  17511. yAxis: 'GridComponent',
  17512. angleAxis: 'PolarComponent',
  17513. radiusAxis: 'PolarComponent'
  17514. };
  17515. var BUILTIN_CHARTS_MAP = {
  17516. line: 'LineChart',
  17517. bar: 'BarChart',
  17518. pie: 'PieChart',
  17519. scatter: 'ScatterChart',
  17520. radar: 'RadarChart',
  17521. map: 'MapChart',
  17522. tree: 'TreeChart',
  17523. treemap: 'TreemapChart',
  17524. graph: 'GraphChart',
  17525. gauge: 'GaugeChart',
  17526. funnel: 'FunnelChart',
  17527. parallel: 'ParallelChart',
  17528. sankey: 'SankeyChart',
  17529. boxplot: 'BoxplotChart',
  17530. candlestick: 'CandlestickChart',
  17531. effectScatter: 'EffectScatterChart',
  17532. lines: 'LinesChart',
  17533. heatmap: 'HeatmapChart',
  17534. pictorialBar: 'PictorialBarChart',
  17535. themeRiver: 'ThemeRiverChart',
  17536. sunburst: 'SunburstChart',
  17537. custom: 'CustomChart'
  17538. };
  17539. var componetsMissingLogPrinted = {};
  17540. var GlobalModel =
  17541. /** @class */
  17542. function (_super) {
  17543. __extends(GlobalModel, _super);
  17544. function GlobalModel() {
  17545. return _super !== null && _super.apply(this, arguments) || this;
  17546. }
  17547. GlobalModel.prototype.init = function (option, parentModel, ecModel, theme, locale, optionManager) {
  17548. theme = theme || {};
  17549. this.option = null; // Mark as not initialized.
  17550. this._theme = new Model(theme);
  17551. this._locale = new Model(locale);
  17552. this._optionManager = optionManager;
  17553. };
  17554. GlobalModel.prototype.setOption = function (option, opts, optionPreprocessorFuncs) {
  17555. {
  17556. assert$1(option != null, 'option is null/undefined');
  17557. assert$1(option[OPTION_INNER_KEY] !== OPTION_INNER_VALUE, 'please use chart.getOption()');
  17558. }
  17559. var innerOpt = normalizeSetOptionInput(opts);
  17560. this._optionManager.setOption(option, optionPreprocessorFuncs, innerOpt);
  17561. this._resetOption(null, innerOpt);
  17562. };
  17563. /**
  17564. * @param type null/undefined: reset all.
  17565. * 'recreate': force recreate all.
  17566. * 'timeline': only reset timeline option
  17567. * 'media': only reset media query option
  17568. * @return Whether option changed.
  17569. */
  17570. GlobalModel.prototype.resetOption = function (type, opt) {
  17571. return this._resetOption(type, normalizeSetOptionInput(opt));
  17572. };
  17573. GlobalModel.prototype._resetOption = function (type, opt) {
  17574. var optionChanged = false;
  17575. var optionManager = this._optionManager;
  17576. if (!type || type === 'recreate') {
  17577. var baseOption = optionManager.mountOption(type === 'recreate');
  17578. if (!this.option || type === 'recreate') {
  17579. initBase(this, baseOption);
  17580. } else {
  17581. this.restoreData();
  17582. this._mergeOption(baseOption, opt);
  17583. }
  17584. optionChanged = true;
  17585. }
  17586. if (type === 'timeline' || type === 'media') {
  17587. this.restoreData();
  17588. } // By design, if `setOption(option2)` at the second time, and `option2` is a `ECUnitOption`,
  17589. // it should better not have the same props with `MediaUnit['option']`.
  17590. // Becuase either `option2` or `MediaUnit['option']` will be always merged to "current option"
  17591. // rather than original "baseOption". If they both override a prop, the result might be
  17592. // unexpected when media state changed after `setOption` called.
  17593. // If we really need to modify a props in each `MediaUnit['option']`, use the full version
  17594. // (`{baseOption, media}`) in `setOption`.
  17595. // For `timeline`, the case is the same.
  17596. if (!type || type === 'recreate' || type === 'timeline') {
  17597. var timelineOption = optionManager.getTimelineOption(this);
  17598. if (timelineOption) {
  17599. optionChanged = true;
  17600. this._mergeOption(timelineOption, opt);
  17601. }
  17602. }
  17603. if (!type || type === 'recreate' || type === 'media') {
  17604. var mediaOptions = optionManager.getMediaOption(this);
  17605. if (mediaOptions.length) {
  17606. each$1(mediaOptions, function (mediaOption) {
  17607. optionChanged = true;
  17608. this._mergeOption(mediaOption, opt);
  17609. }, this);
  17610. }
  17611. }
  17612. return optionChanged;
  17613. };
  17614. GlobalModel.prototype.mergeOption = function (option) {
  17615. this._mergeOption(option, null);
  17616. };
  17617. GlobalModel.prototype._mergeOption = function (newOption, opt) {
  17618. var option = this.option;
  17619. var componentsMap = this._componentsMap;
  17620. var componentsCount = this._componentsCount;
  17621. var newCmptTypes = [];
  17622. var newCmptTypeMap = createHashMap();
  17623. var replaceMergeMainTypeMap = opt && opt.replaceMergeMainTypeMap;
  17624. resetSourceDefaulter(this); // If no component class, merge directly.
  17625. // For example: color, animaiton options, etc.
  17626. each$1(newOption, function (componentOption, mainType) {
  17627. if (componentOption == null) {
  17628. return;
  17629. }
  17630. if (!ComponentModel.hasClass(mainType)) {
  17631. {
  17632. var componentImportName = BUITIN_COMPONENTS_MAP[mainType];
  17633. if (componentImportName && !componetsMissingLogPrinted[componentImportName]) {
  17634. error("Component " + mainType + " is used but not imported.\nimport { " + componentImportName + " } from 'echarts/components';\necharts.use([" + componentImportName + "]);");
  17635. componetsMissingLogPrinted[componentImportName] = true;
  17636. }
  17637. } // globalSettingTask.dirty();
  17638. option[mainType] = option[mainType] == null ? clone(componentOption) : merge(option[mainType], componentOption, true);
  17639. } else if (mainType) {
  17640. newCmptTypes.push(mainType);
  17641. newCmptTypeMap.set(mainType, true);
  17642. }
  17643. });
  17644. if (replaceMergeMainTypeMap) {
  17645. // If there is a mainType `xxx` in `replaceMerge` but not declared in option,
  17646. // we trade it as it is declared in option as `{xxx: []}`. Because:
  17647. // (1) for normal merge, `{xxx: null/undefined}` are the same meaning as `{xxx: []}`.
  17648. // (2) some preprocessor may convert some of `{xxx: null/undefined}` to `{xxx: []}`.
  17649. replaceMergeMainTypeMap.each(function (val, mainTypeInReplaceMerge) {
  17650. if (ComponentModel.hasClass(mainTypeInReplaceMerge) && !newCmptTypeMap.get(mainTypeInReplaceMerge)) {
  17651. newCmptTypes.push(mainTypeInReplaceMerge);
  17652. newCmptTypeMap.set(mainTypeInReplaceMerge, true);
  17653. }
  17654. });
  17655. }
  17656. ComponentModel.topologicalTravel(newCmptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this);
  17657. function visitComponent(mainType) {
  17658. var newCmptOptionList = concatInternalOptions(this, mainType, normalizeToArray(newOption[mainType]));
  17659. var oldCmptList = componentsMap.get(mainType);
  17660. var mergeMode = // `!oldCmptList` means init. See the comment in `mappingToExists`
  17661. !oldCmptList ? 'replaceAll' : replaceMergeMainTypeMap && replaceMergeMainTypeMap.get(mainType) ? 'replaceMerge' : 'normalMerge';
  17662. var mappingResult = mappingToExists(oldCmptList, newCmptOptionList, mergeMode); // Set mainType and complete subType.
  17663. setComponentTypeToKeyInfo(mappingResult, mainType, ComponentModel); // Empty it before the travel, in order to prevent `this._componentsMap`
  17664. // from being used in the `init`/`mergeOption`/`optionUpdated` of some
  17665. // components, which is probably incorrect logic.
  17666. option[mainType] = null;
  17667. componentsMap.set(mainType, null);
  17668. componentsCount.set(mainType, 0);
  17669. var optionsByMainType = [];
  17670. var cmptsByMainType = [];
  17671. var cmptsCountByMainType = 0;
  17672. each$1(mappingResult, function (resultItem, index) {
  17673. var componentModel = resultItem.existing;
  17674. var newCmptOption = resultItem.newOption;
  17675. if (!newCmptOption) {
  17676. if (componentModel) {
  17677. // Consider where is no new option and should be merged using {},
  17678. // see removeEdgeAndAdd in topologicalTravel and
  17679. // ComponentModel.getAllClassMainTypes.
  17680. componentModel.mergeOption({}, this);
  17681. componentModel.optionUpdated({}, false);
  17682. } // If no both `resultItem.exist` and `resultItem.option`,
  17683. // either it is in `replaceMerge` and not matched by any id,
  17684. // or it has been removed in previous `replaceMerge` and left a "hole" in this component index.
  17685. } else {
  17686. var isSeriesType = mainType === 'series';
  17687. var ComponentModelClass = ComponentModel.getClass(mainType, resultItem.keyInfo.subType, !isSeriesType // Give a more detailed warn later if series don't exists
  17688. );
  17689. if (!ComponentModelClass) {
  17690. {
  17691. var subType = resultItem.keyInfo.subType;
  17692. var seriesImportName = BUILTIN_CHARTS_MAP[subType];
  17693. if (!componetsMissingLogPrinted[subType]) {
  17694. componetsMissingLogPrinted[subType] = true;
  17695. if (seriesImportName) {
  17696. error("Series " + subType + " is used but not imported.\nimport { " + seriesImportName + " } from 'echarts/charts';\necharts.use([" + seriesImportName + "]);");
  17697. } else {
  17698. error("Unkown series " + subType);
  17699. }
  17700. }
  17701. }
  17702. return;
  17703. }
  17704. if (componentModel && componentModel.constructor === ComponentModelClass) {
  17705. componentModel.name = resultItem.keyInfo.name; // componentModel.settingTask && componentModel.settingTask.dirty();
  17706. componentModel.mergeOption(newCmptOption, this);
  17707. componentModel.optionUpdated(newCmptOption, false);
  17708. } else {
  17709. // PENDING Global as parent ?
  17710. var extraOpt = extend({
  17711. componentIndex: index
  17712. }, resultItem.keyInfo);
  17713. componentModel = new ComponentModelClass(newCmptOption, this, this, extraOpt); // Assign `keyInfo`
  17714. extend(componentModel, extraOpt);
  17715. if (resultItem.brandNew) {
  17716. componentModel.__requireNewView = true;
  17717. }
  17718. componentModel.init(newCmptOption, this, this); // Call optionUpdated after init.
  17719. // newCmptOption has been used as componentModel.option
  17720. // and may be merged with theme and default, so pass null
  17721. // to avoid confusion.
  17722. componentModel.optionUpdated(null, true);
  17723. }
  17724. }
  17725. if (componentModel) {
  17726. optionsByMainType.push(componentModel.option);
  17727. cmptsByMainType.push(componentModel);
  17728. cmptsCountByMainType++;
  17729. } else {
  17730. // Always do assign to avoid elided item in array.
  17731. optionsByMainType.push(void 0);
  17732. cmptsByMainType.push(void 0);
  17733. }
  17734. }, this);
  17735. option[mainType] = optionsByMainType;
  17736. componentsMap.set(mainType, cmptsByMainType);
  17737. componentsCount.set(mainType, cmptsCountByMainType); // Backup series for filtering.
  17738. if (mainType === 'series') {
  17739. reCreateSeriesIndices(this);
  17740. }
  17741. } // If no series declared, ensure `_seriesIndices` initialized.
  17742. if (!this._seriesIndices) {
  17743. reCreateSeriesIndices(this);
  17744. }
  17745. };
  17746. /**
  17747. * Get option for output (cloned option and inner info removed)
  17748. */
  17749. GlobalModel.prototype.getOption = function () {
  17750. var option = clone(this.option);
  17751. each$1(option, function (optInMainType, mainType) {
  17752. if (ComponentModel.hasClass(mainType)) {
  17753. var opts = normalizeToArray(optInMainType); // Inner cmpts need to be removed.
  17754. // Inner cmpts might not be at last since ec5.0, but still
  17755. // compatible for users: if inner cmpt at last, splice the returned array.
  17756. var realLen = opts.length;
  17757. var metNonInner = false;
  17758. for (var i = realLen - 1; i >= 0; i--) {
  17759. // Remove options with inner id.
  17760. if (opts[i] && !isComponentIdInternal(opts[i])) {
  17761. metNonInner = true;
  17762. } else {
  17763. opts[i] = null;
  17764. !metNonInner && realLen--;
  17765. }
  17766. }
  17767. opts.length = realLen;
  17768. option[mainType] = opts;
  17769. }
  17770. });
  17771. delete option[OPTION_INNER_KEY];
  17772. return option;
  17773. };
  17774. GlobalModel.prototype.getTheme = function () {
  17775. return this._theme;
  17776. };
  17777. GlobalModel.prototype.getLocaleModel = function () {
  17778. return this._locale;
  17779. };
  17780. GlobalModel.prototype.getLocale = function (localePosition) {
  17781. var locale = this.getLocaleModel();
  17782. return locale.get(localePosition);
  17783. };
  17784. GlobalModel.prototype.setUpdatePayload = function (payload) {
  17785. this._payload = payload;
  17786. };
  17787. GlobalModel.prototype.getUpdatePayload = function () {
  17788. return this._payload;
  17789. };
  17790. /**
  17791. * @param idx If not specified, return the first one.
  17792. */
  17793. GlobalModel.prototype.getComponent = function (mainType, idx) {
  17794. var list = this._componentsMap.get(mainType);
  17795. if (list) {
  17796. var cmpt = list[idx || 0];
  17797. if (cmpt) {
  17798. return cmpt;
  17799. } else if (idx == null) {
  17800. for (var i = 0; i < list.length; i++) {
  17801. if (list[i]) {
  17802. return list[i];
  17803. }
  17804. }
  17805. }
  17806. }
  17807. };
  17808. /**
  17809. * @return Never be null/undefined.
  17810. */
  17811. GlobalModel.prototype.queryComponents = function (condition) {
  17812. var mainType = condition.mainType;
  17813. if (!mainType) {
  17814. return [];
  17815. }
  17816. var index = condition.index;
  17817. var id = condition.id;
  17818. var name = condition.name;
  17819. var cmpts = this._componentsMap.get(mainType);
  17820. if (!cmpts || !cmpts.length) {
  17821. return [];
  17822. }
  17823. var result;
  17824. if (index != null) {
  17825. result = [];
  17826. each$1(normalizeToArray(index), function (idx) {
  17827. cmpts[idx] && result.push(cmpts[idx]);
  17828. });
  17829. } else if (id != null) {
  17830. result = queryByIdOrName('id', id, cmpts);
  17831. } else if (name != null) {
  17832. result = queryByIdOrName('name', name, cmpts);
  17833. } else {
  17834. // Return all non-empty components in that mainType
  17835. result = filter(cmpts, function (cmpt) {
  17836. return !!cmpt;
  17837. });
  17838. }
  17839. return filterBySubType(result, condition);
  17840. };
  17841. /**
  17842. * The interface is different from queryComponents,
  17843. * which is convenient for inner usage.
  17844. *
  17845. * @usage
  17846. * let result = findComponents(
  17847. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  17848. * );
  17849. * let result = findComponents(
  17850. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  17851. * );
  17852. * let result = findComponents(
  17853. * {mainType: 'series',
  17854. * filter: function (model, index) {...}}
  17855. * );
  17856. * // result like [component0, componnet1, ...]
  17857. */
  17858. GlobalModel.prototype.findComponents = function (condition) {
  17859. var query = condition.query;
  17860. var mainType = condition.mainType;
  17861. var queryCond = getQueryCond(query);
  17862. var result = queryCond ? this.queryComponents(queryCond) // Retrieve all non-empty components.
  17863. : filter(this._componentsMap.get(mainType), function (cmpt) {
  17864. return !!cmpt;
  17865. });
  17866. return doFilter(filterBySubType(result, condition));
  17867. function getQueryCond(q) {
  17868. var indexAttr = mainType + 'Index';
  17869. var idAttr = mainType + 'Id';
  17870. var nameAttr = mainType + 'Name';
  17871. return q && (q[indexAttr] != null || q[idAttr] != null || q[nameAttr] != null) ? {
  17872. mainType: mainType,
  17873. // subType will be filtered finally.
  17874. index: q[indexAttr],
  17875. id: q[idAttr],
  17876. name: q[nameAttr]
  17877. } : null;
  17878. }
  17879. function doFilter(res) {
  17880. return condition.filter ? filter(res, condition.filter) : res;
  17881. }
  17882. };
  17883. GlobalModel.prototype.eachComponent = function (mainType, cb, context) {
  17884. var componentsMap = this._componentsMap;
  17885. if (isFunction$1(mainType)) {
  17886. var ctxForAll_1 = cb;
  17887. var cbForAll_1 = mainType;
  17888. componentsMap.each(function (cmpts, componentType) {
  17889. for (var i = 0; cmpts && i < cmpts.length; i++) {
  17890. var cmpt = cmpts[i];
  17891. cmpt && cbForAll_1.call(ctxForAll_1, componentType, cmpt, cmpt.componentIndex);
  17892. }
  17893. });
  17894. } else {
  17895. var cmpts = isString(mainType) ? componentsMap.get(mainType) : isObject$1(mainType) ? this.findComponents(mainType) : null;
  17896. for (var i = 0; cmpts && i < cmpts.length; i++) {
  17897. var cmpt = cmpts[i];
  17898. cmpt && cb.call(context, cmpt, cmpt.componentIndex);
  17899. }
  17900. }
  17901. };
  17902. /**
  17903. * Get series list before filtered by name.
  17904. */
  17905. GlobalModel.prototype.getSeriesByName = function (name) {
  17906. var nameStr = convertOptionIdName(name, null);
  17907. return filter(this._componentsMap.get('series'), function (oneSeries) {
  17908. return !!oneSeries && nameStr != null && oneSeries.name === nameStr;
  17909. });
  17910. };
  17911. /**
  17912. * Get series list before filtered by index.
  17913. */
  17914. GlobalModel.prototype.getSeriesByIndex = function (seriesIndex) {
  17915. return this._componentsMap.get('series')[seriesIndex];
  17916. };
  17917. /**
  17918. * Get series list before filtered by type.
  17919. * FIXME: rename to getRawSeriesByType?
  17920. */
  17921. GlobalModel.prototype.getSeriesByType = function (subType) {
  17922. return filter(this._componentsMap.get('series'), function (oneSeries) {
  17923. return !!oneSeries && oneSeries.subType === subType;
  17924. });
  17925. };
  17926. /**
  17927. * Get all series before filtered.
  17928. */
  17929. GlobalModel.prototype.getSeries = function () {
  17930. return filter(this._componentsMap.get('series').slice(), function (oneSeries) {
  17931. return !!oneSeries;
  17932. });
  17933. };
  17934. /**
  17935. * Count series before filtered.
  17936. */
  17937. GlobalModel.prototype.getSeriesCount = function () {
  17938. return this._componentsCount.get('series');
  17939. };
  17940. /**
  17941. * After filtering, series may be different
  17942. * frome raw series.
  17943. */
  17944. GlobalModel.prototype.eachSeries = function (cb, context) {
  17945. assertSeriesInitialized(this);
  17946. each$1(this._seriesIndices, function (rawSeriesIndex) {
  17947. var series = this._componentsMap.get('series')[rawSeriesIndex];
  17948. cb.call(context, series, rawSeriesIndex);
  17949. }, this);
  17950. };
  17951. /**
  17952. * Iterate raw series before filtered.
  17953. *
  17954. * @param {Function} cb
  17955. * @param {*} context
  17956. */
  17957. GlobalModel.prototype.eachRawSeries = function (cb, context) {
  17958. each$1(this._componentsMap.get('series'), function (series) {
  17959. series && cb.call(context, series, series.componentIndex);
  17960. });
  17961. };
  17962. /**
  17963. * After filtering, series may be different.
  17964. * frome raw series.
  17965. */
  17966. GlobalModel.prototype.eachSeriesByType = function (subType, cb, context) {
  17967. assertSeriesInitialized(this);
  17968. each$1(this._seriesIndices, function (rawSeriesIndex) {
  17969. var series = this._componentsMap.get('series')[rawSeriesIndex];
  17970. if (series.subType === subType) {
  17971. cb.call(context, series, rawSeriesIndex);
  17972. }
  17973. }, this);
  17974. };
  17975. /**
  17976. * Iterate raw series before filtered of given type.
  17977. */
  17978. GlobalModel.prototype.eachRawSeriesByType = function (subType, cb, context) {
  17979. return each$1(this.getSeriesByType(subType), cb, context);
  17980. };
  17981. GlobalModel.prototype.isSeriesFiltered = function (seriesModel) {
  17982. assertSeriesInitialized(this);
  17983. return this._seriesIndicesMap.get(seriesModel.componentIndex) == null;
  17984. };
  17985. GlobalModel.prototype.getCurrentSeriesIndices = function () {
  17986. return (this._seriesIndices || []).slice();
  17987. };
  17988. GlobalModel.prototype.filterSeries = function (cb, context) {
  17989. assertSeriesInitialized(this);
  17990. var newSeriesIndices = [];
  17991. each$1(this._seriesIndices, function (seriesRawIdx) {
  17992. var series = this._componentsMap.get('series')[seriesRawIdx];
  17993. cb.call(context, series, seriesRawIdx) && newSeriesIndices.push(seriesRawIdx);
  17994. }, this);
  17995. this._seriesIndices = newSeriesIndices;
  17996. this._seriesIndicesMap = createHashMap(newSeriesIndices);
  17997. };
  17998. GlobalModel.prototype.restoreData = function (payload) {
  17999. reCreateSeriesIndices(this);
  18000. var componentsMap = this._componentsMap;
  18001. var componentTypes = [];
  18002. componentsMap.each(function (components, componentType) {
  18003. if (ComponentModel.hasClass(componentType)) {
  18004. componentTypes.push(componentType);
  18005. }
  18006. });
  18007. ComponentModel.topologicalTravel(componentTypes, ComponentModel.getAllClassMainTypes(), function (componentType) {
  18008. each$1(componentsMap.get(componentType), function (component) {
  18009. if (component && (componentType !== 'series' || !isNotTargetSeries(component, payload))) {
  18010. component.restoreData();
  18011. }
  18012. });
  18013. });
  18014. };
  18015. GlobalModel.internalField = function () {
  18016. reCreateSeriesIndices = function (ecModel) {
  18017. var seriesIndices = ecModel._seriesIndices = [];
  18018. each$1(ecModel._componentsMap.get('series'), function (series) {
  18019. // series may have been removed by `replaceMerge`.
  18020. series && seriesIndices.push(series.componentIndex);
  18021. });
  18022. ecModel._seriesIndicesMap = createHashMap(seriesIndices);
  18023. };
  18024. assertSeriesInitialized = function (ecModel) {
  18025. // Components that use _seriesIndices should depends on series component,
  18026. // which make sure that their initialization is after series.
  18027. {
  18028. if (!ecModel._seriesIndices) {
  18029. throw new Error('Option should contains series.');
  18030. }
  18031. }
  18032. };
  18033. initBase = function (ecModel, baseOption) {
  18034. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  18035. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  18036. ecModel.option = {};
  18037. ecModel.option[OPTION_INNER_KEY] = OPTION_INNER_VALUE; // Init with series: [], in case of calling findSeries method
  18038. // before series initialized.
  18039. ecModel._componentsMap = createHashMap({
  18040. series: []
  18041. });
  18042. ecModel._componentsCount = createHashMap(); // If user spefied `option.aria`, aria will be enable. This detection should be
  18043. // performed before theme and globalDefault merge.
  18044. var airaOption = baseOption.aria;
  18045. if (isObject$1(airaOption) && airaOption.enabled == null) {
  18046. airaOption.enabled = true;
  18047. }
  18048. mergeTheme(baseOption, ecModel._theme.option); // TODO Needs clone when merging to the unexisted property
  18049. merge(baseOption, globalDefault, false);
  18050. ecModel._mergeOption(baseOption, null);
  18051. };
  18052. }();
  18053. return GlobalModel;
  18054. }(Model);
  18055. function isNotTargetSeries(seriesModel, payload) {
  18056. if (payload) {
  18057. var index = payload.seriesIndex;
  18058. var id = payload.seriesId;
  18059. var name_1 = payload.seriesName;
  18060. return index != null && seriesModel.componentIndex !== index || id != null && seriesModel.id !== id || name_1 != null && seriesModel.name !== name_1;
  18061. }
  18062. }
  18063. function mergeTheme(option, theme) {
  18064. // PENDING
  18065. // NOT use `colorLayer` in theme if option has `color`
  18066. var notMergeColorLayer = option.color && !option.colorLayer;
  18067. each$1(theme, function (themeItem, name) {
  18068. if (name === 'colorLayer' && notMergeColorLayer) {
  18069. return;
  18070. } // If it is component model mainType, the model handles that merge later.
  18071. // otherwise, merge them here.
  18072. if (!ComponentModel.hasClass(name)) {
  18073. if (typeof themeItem === 'object') {
  18074. option[name] = !option[name] ? clone(themeItem) : merge(option[name], themeItem, false);
  18075. } else {
  18076. if (option[name] == null) {
  18077. option[name] = themeItem;
  18078. }
  18079. }
  18080. }
  18081. });
  18082. }
  18083. function queryByIdOrName(attr, idOrName, cmpts) {
  18084. // Here is a break from echarts4: string and number are
  18085. // treated as equal.
  18086. if (isArray(idOrName)) {
  18087. var keyMap_1 = createHashMap();
  18088. each$1(idOrName, function (idOrNameItem) {
  18089. if (idOrNameItem != null) {
  18090. var idName = convertOptionIdName(idOrNameItem, null);
  18091. idName != null && keyMap_1.set(idOrNameItem, true);
  18092. }
  18093. });
  18094. return filter(cmpts, function (cmpt) {
  18095. return cmpt && keyMap_1.get(cmpt[attr]);
  18096. });
  18097. } else {
  18098. var idName_1 = convertOptionIdName(idOrName, null);
  18099. return filter(cmpts, function (cmpt) {
  18100. return cmpt && idName_1 != null && cmpt[attr] === idName_1;
  18101. });
  18102. }
  18103. }
  18104. function filterBySubType(components, condition) {
  18105. // Using hasOwnProperty for restrict. Consider
  18106. // subType is undefined in user payload.
  18107. return condition.hasOwnProperty('subType') ? filter(components, function (cmpt) {
  18108. return cmpt && cmpt.subType === condition.subType;
  18109. }) : components;
  18110. }
  18111. function normalizeSetOptionInput(opts) {
  18112. var replaceMergeMainTypeMap = createHashMap();
  18113. opts && each$1(normalizeToArray(opts.replaceMerge), function (mainType) {
  18114. {
  18115. assert$1(ComponentModel.hasClass(mainType), '"' + mainType + '" is not valid component main type in "replaceMerge"');
  18116. }
  18117. replaceMergeMainTypeMap.set(mainType, true);
  18118. });
  18119. return {
  18120. replaceMergeMainTypeMap: replaceMergeMainTypeMap
  18121. };
  18122. }
  18123. mixin(GlobalModel, PaletteMixin);
  18124. /*
  18125. * Licensed to the Apache Software Foundation (ASF) under one
  18126. * or more contributor license agreements. See the NOTICE file
  18127. * distributed with this work for additional information
  18128. * regarding copyright ownership. The ASF licenses this file
  18129. * to you under the Apache License, Version 2.0 (the
  18130. * "License"); you may not use this file except in compliance
  18131. * with the License. You may obtain a copy of the License at
  18132. *
  18133. * http://www.apache.org/licenses/LICENSE-2.0
  18134. *
  18135. * Unless required by applicable law or agreed to in writing,
  18136. * software distributed under the License is distributed on an
  18137. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18138. * KIND, either express or implied. See the License for the
  18139. * specific language governing permissions and limitations
  18140. * under the License.
  18141. */
  18142. /**
  18143. * AUTO-GENERATED FILE. DO NOT MODIFY.
  18144. */
  18145. /*
  18146. * Licensed to the Apache Software Foundation (ASF) under one
  18147. * or more contributor license agreements. See the NOTICE file
  18148. * distributed with this work for additional information
  18149. * regarding copyright ownership. The ASF licenses this file
  18150. * to you under the Apache License, Version 2.0 (the
  18151. * "License"); you may not use this file except in compliance
  18152. * with the License. You may obtain a copy of the License at
  18153. *
  18154. * http://www.apache.org/licenses/LICENSE-2.0
  18155. *
  18156. * Unless required by applicable law or agreed to in writing,
  18157. * software distributed under the License is distributed on an
  18158. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18159. * KIND, either express or implied. See the License for the
  18160. * specific language governing permissions and limitations
  18161. * under the License.
  18162. */
  18163. var availableMethods = ['getDom', 'getZr', 'getWidth', 'getHeight', 'getDevicePixelRatio', 'dispatchAction', 'isDisposed', 'on', 'off', 'getDataURL', 'getConnectedDataURL', // 'getModel',
  18164. 'getOption', // 'getViewOfComponentModel',
  18165. // 'getViewOfSeriesModel',
  18166. 'getId', 'updateLabelLayout'];
  18167. var ExtensionAPI =
  18168. /** @class */
  18169. function () {
  18170. function ExtensionAPI(ecInstance) {
  18171. each$1(availableMethods, function (methodName) {
  18172. this[methodName] = bind(ecInstance[methodName], ecInstance);
  18173. }, this);
  18174. }
  18175. return ExtensionAPI;
  18176. }();
  18177. /*
  18178. * Licensed to the Apache Software Foundation (ASF) under one
  18179. * or more contributor license agreements. See the NOTICE file
  18180. * distributed with this work for additional information
  18181. * regarding copyright ownership. The ASF licenses this file
  18182. * to you under the Apache License, Version 2.0 (the
  18183. * "License"); you may not use this file except in compliance
  18184. * with the License. You may obtain a copy of the License at
  18185. *
  18186. * http://www.apache.org/licenses/LICENSE-2.0
  18187. *
  18188. * Unless required by applicable law or agreed to in writing,
  18189. * software distributed under the License is distributed on an
  18190. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18191. * KIND, either express or implied. See the License for the
  18192. * specific language governing permissions and limitations
  18193. * under the License.
  18194. */
  18195. /**
  18196. * AUTO-GENERATED FILE. DO NOT MODIFY.
  18197. */
  18198. /*
  18199. * Licensed to the Apache Software Foundation (ASF) under one
  18200. * or more contributor license agreements. See the NOTICE file
  18201. * distributed with this work for additional information
  18202. * regarding copyright ownership. The ASF licenses this file
  18203. * to you under the Apache License, Version 2.0 (the
  18204. * "License"); you may not use this file except in compliance
  18205. * with the License. You may obtain a copy of the License at
  18206. *
  18207. * http://www.apache.org/licenses/LICENSE-2.0
  18208. *
  18209. * Unless required by applicable law or agreed to in writing,
  18210. * software distributed under the License is distributed on an
  18211. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18212. * KIND, either express or implied. See the License for the
  18213. * specific language governing permissions and limitations
  18214. * under the License.
  18215. */
  18216. var coordinateSystemCreators = {};
  18217. var CoordinateSystemManager =
  18218. /** @class */
  18219. function () {
  18220. function CoordinateSystemManager() {
  18221. this._coordinateSystems = [];
  18222. }
  18223. CoordinateSystemManager.prototype.create = function (ecModel, api) {
  18224. var coordinateSystems = [];
  18225. each$1(coordinateSystemCreators, function (creater, type) {
  18226. var list = creater.create(ecModel, api);
  18227. coordinateSystems = coordinateSystems.concat(list || []);
  18228. });
  18229. this._coordinateSystems = coordinateSystems;
  18230. };
  18231. CoordinateSystemManager.prototype.update = function (ecModel, api) {
  18232. each$1(this._coordinateSystems, function (coordSys) {
  18233. coordSys.update && coordSys.update(ecModel, api);
  18234. });
  18235. };
  18236. CoordinateSystemManager.prototype.getCoordinateSystems = function () {
  18237. return this._coordinateSystems.slice();
  18238. };
  18239. CoordinateSystemManager.register = function (type, creator) {
  18240. coordinateSystemCreators[type] = creator;
  18241. };
  18242. CoordinateSystemManager.get = function (type) {
  18243. return coordinateSystemCreators[type];
  18244. };
  18245. return CoordinateSystemManager;
  18246. }();
  18247. /*
  18248. * Licensed to the Apache Software Foundation (ASF) under one
  18249. * or more contributor license agreements. See the NOTICE file
  18250. * distributed with this work for additional information
  18251. * regarding copyright ownership. The ASF licenses this file
  18252. * to you under the Apache License, Version 2.0 (the
  18253. * "License"); you may not use this file except in compliance
  18254. * with the License. You may obtain a copy of the License at
  18255. *
  18256. * http://www.apache.org/licenses/LICENSE-2.0
  18257. *
  18258. * Unless required by applicable law or agreed to in writing,
  18259. * software distributed under the License is distributed on an
  18260. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18261. * KIND, either express or implied. See the License for the
  18262. * specific language governing permissions and limitations
  18263. * under the License.
  18264. */
  18265. /**
  18266. * AUTO-GENERATED FILE. DO NOT MODIFY.
  18267. */
  18268. /*
  18269. * Licensed to the Apache Software Foundation (ASF) under one
  18270. * or more contributor license agreements. See the NOTICE file
  18271. * distributed with this work for additional information
  18272. * regarding copyright ownership. The ASF licenses this file
  18273. * to you under the Apache License, Version 2.0 (the
  18274. * "License"); you may not use this file except in compliance
  18275. * with the License. You may obtain a copy of the License at
  18276. *
  18277. * http://www.apache.org/licenses/LICENSE-2.0
  18278. *
  18279. * Unless required by applicable law or agreed to in writing,
  18280. * software distributed under the License is distributed on an
  18281. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18282. * KIND, either express or implied. See the License for the
  18283. * specific language governing permissions and limitations
  18284. * under the License.
  18285. */
  18286. var QUERY_REG = /^(min|max)?(.+)$/; // Key: mainType
  18287. // type FakeComponentsMap = HashMap<(MappingExistingItem & { subType: string })[]>;
  18288. /**
  18289. * TERM EXPLANATIONS:
  18290. * See `ECOption` and `ECUnitOption` in `src/util/types.ts`.
  18291. */
  18292. var OptionManager =
  18293. /** @class */
  18294. function () {
  18295. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  18296. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  18297. // rawOption cloned and backuped when timeline changed, which does no
  18298. // good to performance. What's more, that both timeline and setOption
  18299. // method supply 'notMerge' brings complex and some problems.
  18300. // Consider this case:
  18301. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  18302. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  18303. function OptionManager(api) {
  18304. this._timelineOptions = [];
  18305. this._mediaList = [];
  18306. /**
  18307. * -1, means default.
  18308. * empty means no media.
  18309. */
  18310. this._currentMediaIndices = [];
  18311. this._api = api;
  18312. }
  18313. OptionManager.prototype.setOption = function (rawOption, optionPreprocessorFuncs, opt) {
  18314. if (rawOption) {
  18315. // That set dat primitive is dangerous if user reuse the data when setOption again.
  18316. each$1(normalizeToArray(rawOption.series), function (series) {
  18317. series && series.data && isTypedArray(series.data) && setAsPrimitive(series.data);
  18318. });
  18319. each$1(normalizeToArray(rawOption.dataset), function (dataset) {
  18320. dataset && dataset.source && isTypedArray(dataset.source) && setAsPrimitive(dataset.source);
  18321. });
  18322. } // Caution: some series modify option data, if do not clone,
  18323. // it should ensure that the repeat modify correctly
  18324. // (create a new object when modify itself).
  18325. rawOption = clone(rawOption); // FIXME
  18326. // If some property is set in timeline options or media option but
  18327. // not set in baseOption, a warning should be given.
  18328. var optionBackup = this._optionBackup;
  18329. var newParsedOption = parseRawOption(rawOption, optionPreprocessorFuncs, !optionBackup);
  18330. this._newBaseOption = newParsedOption.baseOption; // For setOption at second time (using merge mode);
  18331. if (optionBackup) {
  18332. // FIXME
  18333. // the restore merge solution is essentially incorrect.
  18334. // the mapping can not be 100% consistent with ecModel, which probably brings
  18335. // potential bug!
  18336. // The first merge is delayed, becuase in most cases, users do not call `setOption` twice.
  18337. // let fakeCmptsMap = this._fakeCmptsMap;
  18338. // if (!fakeCmptsMap) {
  18339. // fakeCmptsMap = this._fakeCmptsMap = createHashMap();
  18340. // mergeToBackupOption(fakeCmptsMap, null, optionBackup.baseOption, null);
  18341. // }
  18342. // mergeToBackupOption(
  18343. // fakeCmptsMap, optionBackup.baseOption, newParsedOption.baseOption, opt
  18344. // );
  18345. // For simplicity, timeline options and media options do not support merge,
  18346. // that is, if you `setOption` twice and both has timeline options, the latter
  18347. // timeline opitons will not be merged to the formers, but just substitude them.
  18348. if (newParsedOption.timelineOptions.length) {
  18349. optionBackup.timelineOptions = newParsedOption.timelineOptions;
  18350. }
  18351. if (newParsedOption.mediaList.length) {
  18352. optionBackup.mediaList = newParsedOption.mediaList;
  18353. }
  18354. if (newParsedOption.mediaDefault) {
  18355. optionBackup.mediaDefault = newParsedOption.mediaDefault;
  18356. }
  18357. } else {
  18358. this._optionBackup = newParsedOption;
  18359. }
  18360. };
  18361. OptionManager.prototype.mountOption = function (isRecreate) {
  18362. var optionBackup = this._optionBackup;
  18363. this._timelineOptions = optionBackup.timelineOptions;
  18364. this._mediaList = optionBackup.mediaList;
  18365. this._mediaDefault = optionBackup.mediaDefault;
  18366. this._currentMediaIndices = [];
  18367. return clone(isRecreate // this._optionBackup.baseOption, which is created at the first `setOption`
  18368. // called, and is merged into every new option by inner method `mergeToBackupOption`
  18369. // each time `setOption` called, can be only used in `isRecreate`, because
  18370. // its reliability is under suspicion. In other cases option merge is
  18371. // performed by `model.mergeOption`.
  18372. ? optionBackup.baseOption : this._newBaseOption);
  18373. };
  18374. OptionManager.prototype.getTimelineOption = function (ecModel) {
  18375. var option;
  18376. var timelineOptions = this._timelineOptions;
  18377. if (timelineOptions.length) {
  18378. // getTimelineOption can only be called after ecModel inited,
  18379. // so we can get currentIndex from timelineModel.
  18380. var timelineModel = ecModel.getComponent('timeline');
  18381. if (timelineModel) {
  18382. option = clone( // FIXME:TS as TimelineModel or quivlant interface
  18383. timelineOptions[timelineModel.getCurrentIndex()]);
  18384. }
  18385. }
  18386. return option;
  18387. };
  18388. OptionManager.prototype.getMediaOption = function (ecModel) {
  18389. var ecWidth = this._api.getWidth();
  18390. var ecHeight = this._api.getHeight();
  18391. var mediaList = this._mediaList;
  18392. var mediaDefault = this._mediaDefault;
  18393. var indices = [];
  18394. var result = []; // No media defined.
  18395. if (!mediaList.length && !mediaDefault) {
  18396. return result;
  18397. } // Multi media may be applied, the latter defined media has higher priority.
  18398. for (var i = 0, len = mediaList.length; i < len; i++) {
  18399. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  18400. indices.push(i);
  18401. }
  18402. } // FIXME
  18403. // Whether mediaDefault should force users to provide? Otherwise
  18404. // the change by media query can not be recorvered.
  18405. if (!indices.length && mediaDefault) {
  18406. indices = [-1];
  18407. }
  18408. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  18409. result = map(indices, function (index) {
  18410. return clone(index === -1 ? mediaDefault.option : mediaList[index].option);
  18411. });
  18412. } // Otherwise return nothing.
  18413. this._currentMediaIndices = indices;
  18414. return result;
  18415. };
  18416. return OptionManager;
  18417. }();
  18418. /**
  18419. * [RAW_OPTION_PATTERNS]
  18420. * (Note: "series: []" represents all other props in `ECUnitOption`)
  18421. *
  18422. * (1) No prop "baseOption" declared:
  18423. * Root option is used as "baseOption" (except prop "options" and "media").
  18424. * ```js
  18425. * option = {
  18426. * series: [],
  18427. * timeline: {},
  18428. * options: [],
  18429. * };
  18430. * option = {
  18431. * series: [],
  18432. * media: {},
  18433. * };
  18434. * option = {
  18435. * series: [],
  18436. * timeline: {},
  18437. * options: [],
  18438. * media: {},
  18439. * }
  18440. * ```
  18441. *
  18442. * (2) Prop "baseOption" declared:
  18443. * If "baseOption" declared, `ECUnitOption` props can only be declared
  18444. * inside "baseOption" except prop "timeline" (compat ec2).
  18445. * ```js
  18446. * option = {
  18447. * baseOption: {
  18448. * timeline: {},
  18449. * series: [],
  18450. * },
  18451. * options: []
  18452. * };
  18453. * option = {
  18454. * baseOption: {
  18455. * series: [],
  18456. * },
  18457. * media: []
  18458. * };
  18459. * option = {
  18460. * baseOption: {
  18461. * timeline: {},
  18462. * series: [],
  18463. * },
  18464. * options: []
  18465. * media: []
  18466. * };
  18467. * option = {
  18468. * // ec3 compat ec2: allow (only) `timeline` declared
  18469. * // outside baseOption. Keep this setting for compat.
  18470. * timeline: {},
  18471. * baseOption: {
  18472. * series: [],
  18473. * },
  18474. * options: [],
  18475. * media: []
  18476. * };
  18477. * ```
  18478. */
  18479. function parseRawOption( // `rawOption` May be modified
  18480. rawOption, optionPreprocessorFuncs, isNew) {
  18481. var mediaList = [];
  18482. var mediaDefault;
  18483. var baseOption;
  18484. var declaredBaseOption = rawOption.baseOption; // Compatible with ec2, [RAW_OPTION_PATTERNS] above.
  18485. var timelineOnRoot = rawOption.timeline;
  18486. var timelineOptionsOnRoot = rawOption.options;
  18487. var mediaOnRoot = rawOption.media;
  18488. var hasMedia = !!rawOption.media;
  18489. var hasTimeline = !!(timelineOptionsOnRoot || timelineOnRoot || declaredBaseOption && declaredBaseOption.timeline);
  18490. if (declaredBaseOption) {
  18491. baseOption = declaredBaseOption; // For merge option.
  18492. if (!baseOption.timeline) {
  18493. baseOption.timeline = timelineOnRoot;
  18494. }
  18495. } // For convenience, enable to use the root option as the `baseOption`:
  18496. // `{ ...normalOptionProps, media: [{ ... }, { ... }] }`
  18497. else {
  18498. if (hasTimeline || hasMedia) {
  18499. rawOption.options = rawOption.media = null;
  18500. }
  18501. baseOption = rawOption;
  18502. }
  18503. if (hasMedia) {
  18504. if (isArray(mediaOnRoot)) {
  18505. each$1(mediaOnRoot, function (singleMedia) {
  18506. {
  18507. // Real case of wrong config.
  18508. if (singleMedia && !singleMedia.option && isObject$1(singleMedia.query) && isObject$1(singleMedia.query.option)) {
  18509. error('Illegal media option. Must be like { media: [ { query: {}, option: {} } ] }');
  18510. }
  18511. }
  18512. if (singleMedia && singleMedia.option) {
  18513. if (singleMedia.query) {
  18514. mediaList.push(singleMedia);
  18515. } else if (!mediaDefault) {
  18516. // Use the first media default.
  18517. mediaDefault = singleMedia;
  18518. }
  18519. }
  18520. });
  18521. } else {
  18522. {
  18523. // Real case of wrong config.
  18524. error('Illegal media option. Must be an array. Like { media: [ {...}, {...} ] }');
  18525. }
  18526. }
  18527. }
  18528. doPreprocess(baseOption);
  18529. each$1(timelineOptionsOnRoot, function (option) {
  18530. return doPreprocess(option);
  18531. });
  18532. each$1(mediaList, function (media) {
  18533. return doPreprocess(media.option);
  18534. });
  18535. function doPreprocess(option) {
  18536. each$1(optionPreprocessorFuncs, function (preProcess) {
  18537. preProcess(option, isNew);
  18538. });
  18539. }
  18540. return {
  18541. baseOption: baseOption,
  18542. timelineOptions: timelineOptionsOnRoot || [],
  18543. mediaDefault: mediaDefault,
  18544. mediaList: mediaList
  18545. };
  18546. }
  18547. /**
  18548. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  18549. * Support: width, height, aspectRatio
  18550. * Can use max or min as prefix.
  18551. */
  18552. function applyMediaQuery(query, ecWidth, ecHeight) {
  18553. var realMap = {
  18554. width: ecWidth,
  18555. height: ecHeight,
  18556. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  18557. };
  18558. var applicatable = true;
  18559. each$1(query, function (value, attr) {
  18560. var matched = attr.match(QUERY_REG);
  18561. if (!matched || !matched[1] || !matched[2]) {
  18562. return;
  18563. }
  18564. var operator = matched[1];
  18565. var realAttr = matched[2].toLowerCase();
  18566. if (!compare(realMap[realAttr], value, operator)) {
  18567. applicatable = false;
  18568. }
  18569. });
  18570. return applicatable;
  18571. }
  18572. function compare(real, expect, operator) {
  18573. if (operator === 'min') {
  18574. return real >= expect;
  18575. } else if (operator === 'max') {
  18576. return real <= expect;
  18577. } else {
  18578. // Equals
  18579. return real === expect;
  18580. }
  18581. }
  18582. function indicesEquals(indices1, indices2) {
  18583. // indices is always order by asc and has only finite number.
  18584. return indices1.join(',') === indices2.join(',');
  18585. }
  18586. /*
  18587. * Licensed to the Apache Software Foundation (ASF) under one
  18588. * or more contributor license agreements. See the NOTICE file
  18589. * distributed with this work for additional information
  18590. * regarding copyright ownership. The ASF licenses this file
  18591. * to you under the Apache License, Version 2.0 (the
  18592. * "License"); you may not use this file except in compliance
  18593. * with the License. You may obtain a copy of the License at
  18594. *
  18595. * http://www.apache.org/licenses/LICENSE-2.0
  18596. *
  18597. * Unless required by applicable law or agreed to in writing,
  18598. * software distributed under the License is distributed on an
  18599. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18600. * KIND, either express or implied. See the License for the
  18601. * specific language governing permissions and limitations
  18602. * under the License.
  18603. */
  18604. /**
  18605. * AUTO-GENERATED FILE. DO NOT MODIFY.
  18606. */
  18607. /*
  18608. * Licensed to the Apache Software Foundation (ASF) under one
  18609. * or more contributor license agreements. See the NOTICE file
  18610. * distributed with this work for additional information
  18611. * regarding copyright ownership. The ASF licenses this file
  18612. * to you under the Apache License, Version 2.0 (the
  18613. * "License"); you may not use this file except in compliance
  18614. * with the License. You may obtain a copy of the License at
  18615. *
  18616. * http://www.apache.org/licenses/LICENSE-2.0
  18617. *
  18618. * Unless required by applicable law or agreed to in writing,
  18619. * software distributed under the License is distributed on an
  18620. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18621. * KIND, either express or implied. See the License for the
  18622. * specific language governing permissions and limitations
  18623. * under the License.
  18624. */
  18625. var each$3 = each$1;
  18626. var isObject$2 = isObject$1;
  18627. var POSSIBLE_STYLES = ['areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle', 'chordStyle', 'label', 'labelLine'];
  18628. function compatEC2ItemStyle(opt) {
  18629. var itemStyleOpt = opt && opt.itemStyle;
  18630. if (!itemStyleOpt) {
  18631. return;
  18632. }
  18633. for (var i = 0, len = POSSIBLE_STYLES.length; i < len; i++) {
  18634. var styleName = POSSIBLE_STYLES[i];
  18635. var normalItemStyleOpt = itemStyleOpt.normal;
  18636. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  18637. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  18638. {
  18639. deprecateReplaceLog("itemStyle.normal." + styleName, styleName);
  18640. }
  18641. opt[styleName] = opt[styleName] || {};
  18642. if (!opt[styleName].normal) {
  18643. opt[styleName].normal = normalItemStyleOpt[styleName];
  18644. } else {
  18645. merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  18646. }
  18647. normalItemStyleOpt[styleName] = null;
  18648. }
  18649. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  18650. {
  18651. deprecateReplaceLog("itemStyle.emphasis." + styleName, "emphasis." + styleName);
  18652. }
  18653. opt[styleName] = opt[styleName] || {};
  18654. if (!opt[styleName].emphasis) {
  18655. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  18656. } else {
  18657. merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  18658. }
  18659. emphasisItemStyleOpt[styleName] = null;
  18660. }
  18661. }
  18662. }
  18663. function convertNormalEmphasis(opt, optType, useExtend) {
  18664. if (opt && opt[optType] && (opt[optType].normal || opt[optType].emphasis)) {
  18665. var normalOpt = opt[optType].normal;
  18666. var emphasisOpt = opt[optType].emphasis;
  18667. if (normalOpt) {
  18668. {
  18669. // eslint-disable-next-line max-len
  18670. deprecateLog("'normal' hierarchy in " + optType + " has been removed since 4.0. All style properties are configured in " + optType + " directly now.");
  18671. } // Timeline controlStyle has other properties besides normal and emphasis
  18672. if (useExtend) {
  18673. opt[optType].normal = opt[optType].emphasis = null;
  18674. defaults(opt[optType], normalOpt);
  18675. } else {
  18676. opt[optType] = normalOpt;
  18677. }
  18678. }
  18679. if (emphasisOpt) {
  18680. {
  18681. deprecateLog(optType + ".emphasis has been changed to emphasis." + optType + " since 4.0");
  18682. }
  18683. opt.emphasis = opt.emphasis || {};
  18684. opt.emphasis[optType] = emphasisOpt; // Also compat the case user mix the style and focus together in ec3 style
  18685. // for example: { itemStyle: { normal: {}, emphasis: {focus, shadowBlur} } }
  18686. if (emphasisOpt.focus) {
  18687. opt.emphasis.focus = emphasisOpt.focus;
  18688. }
  18689. if (emphasisOpt.blurScope) {
  18690. opt.emphasis.blurScope = emphasisOpt.blurScope;
  18691. }
  18692. }
  18693. }
  18694. }
  18695. function removeEC3NormalStatus(opt) {
  18696. convertNormalEmphasis(opt, 'itemStyle');
  18697. convertNormalEmphasis(opt, 'lineStyle');
  18698. convertNormalEmphasis(opt, 'areaStyle');
  18699. convertNormalEmphasis(opt, 'label');
  18700. convertNormalEmphasis(opt, 'labelLine'); // treemap
  18701. convertNormalEmphasis(opt, 'upperLabel'); // graph
  18702. convertNormalEmphasis(opt, 'edgeLabel');
  18703. }
  18704. function compatTextStyle(opt, propName) {
  18705. // Check whether is not object (string\null\undefined ...)
  18706. var labelOptSingle = isObject$2(opt) && opt[propName];
  18707. var textStyle = isObject$2(labelOptSingle) && labelOptSingle.textStyle;
  18708. if (textStyle) {
  18709. {
  18710. // eslint-disable-next-line max-len
  18711. deprecateLog("textStyle hierarchy in " + propName + " has been removed since 4.0. All textStyle properties are configured in " + propName + " directly now.");
  18712. }
  18713. for (var i = 0, len = TEXT_STYLE_OPTIONS.length; i < len; i++) {
  18714. var textPropName = TEXT_STYLE_OPTIONS[i];
  18715. if (textStyle.hasOwnProperty(textPropName)) {
  18716. labelOptSingle[textPropName] = textStyle[textPropName];
  18717. }
  18718. }
  18719. }
  18720. }
  18721. function compatEC3CommonStyles(opt) {
  18722. if (opt) {
  18723. removeEC3NormalStatus(opt);
  18724. compatTextStyle(opt, 'label');
  18725. opt.emphasis && compatTextStyle(opt.emphasis, 'label');
  18726. }
  18727. }
  18728. function processSeries(seriesOpt) {
  18729. if (!isObject$2(seriesOpt)) {
  18730. return;
  18731. }
  18732. compatEC2ItemStyle(seriesOpt);
  18733. removeEC3NormalStatus(seriesOpt);
  18734. compatTextStyle(seriesOpt, 'label'); // treemap
  18735. compatTextStyle(seriesOpt, 'upperLabel'); // graph
  18736. compatTextStyle(seriesOpt, 'edgeLabel');
  18737. if (seriesOpt.emphasis) {
  18738. compatTextStyle(seriesOpt.emphasis, 'label'); // treemap
  18739. compatTextStyle(seriesOpt.emphasis, 'upperLabel'); // graph
  18740. compatTextStyle(seriesOpt.emphasis, 'edgeLabel');
  18741. }
  18742. var markPoint = seriesOpt.markPoint;
  18743. if (markPoint) {
  18744. compatEC2ItemStyle(markPoint);
  18745. compatEC3CommonStyles(markPoint);
  18746. }
  18747. var markLine = seriesOpt.markLine;
  18748. if (markLine) {
  18749. compatEC2ItemStyle(markLine);
  18750. compatEC3CommonStyles(markLine);
  18751. }
  18752. var markArea = seriesOpt.markArea;
  18753. if (markArea) {
  18754. compatEC3CommonStyles(markArea);
  18755. }
  18756. var data = seriesOpt.data; // Break with ec3: if `setOption` again, there may be no `type` in option,
  18757. // then the backward compat based on option type will not be performed.
  18758. if (seriesOpt.type === 'graph') {
  18759. data = data || seriesOpt.nodes;
  18760. var edgeData = seriesOpt.links || seriesOpt.edges;
  18761. if (edgeData && !isTypedArray(edgeData)) {
  18762. for (var i = 0; i < edgeData.length; i++) {
  18763. compatEC3CommonStyles(edgeData[i]);
  18764. }
  18765. }
  18766. each$1(seriesOpt.categories, function (opt) {
  18767. removeEC3NormalStatus(opt);
  18768. });
  18769. }
  18770. if (data && !isTypedArray(data)) {
  18771. for (var i = 0; i < data.length; i++) {
  18772. compatEC3CommonStyles(data[i]);
  18773. }
  18774. } // mark point data
  18775. markPoint = seriesOpt.markPoint;
  18776. if (markPoint && markPoint.data) {
  18777. var mpData = markPoint.data;
  18778. for (var i = 0; i < mpData.length; i++) {
  18779. compatEC3CommonStyles(mpData[i]);
  18780. }
  18781. } // mark line data
  18782. markLine = seriesOpt.markLine;
  18783. if (markLine && markLine.data) {
  18784. var mlData = markLine.data;
  18785. for (var i = 0; i < mlData.length; i++) {
  18786. if (isArray(mlData[i])) {
  18787. compatEC3CommonStyles(mlData[i][0]);
  18788. compatEC3CommonStyles(mlData[i][1]);
  18789. } else {
  18790. compatEC3CommonStyles(mlData[i]);
  18791. }
  18792. }
  18793. } // Series
  18794. if (seriesOpt.type === 'gauge') {
  18795. compatTextStyle(seriesOpt, 'axisLabel');
  18796. compatTextStyle(seriesOpt, 'title');
  18797. compatTextStyle(seriesOpt, 'detail');
  18798. } else if (seriesOpt.type === 'treemap') {
  18799. convertNormalEmphasis(seriesOpt.breadcrumb, 'itemStyle');
  18800. each$1(seriesOpt.levels, function (opt) {
  18801. removeEC3NormalStatus(opt);
  18802. });
  18803. } else if (seriesOpt.type === 'tree') {
  18804. removeEC3NormalStatus(seriesOpt.leaves);
  18805. } // sunburst starts from ec4, so it does not need to compat levels.
  18806. }
  18807. function toArr(o) {
  18808. return isArray(o) ? o : o ? [o] : [];
  18809. }
  18810. function toObj(o) {
  18811. return (isArray(o) ? o[0] : o) || {};
  18812. }
  18813. function globalCompatStyle(option, isTheme) {
  18814. each$3(toArr(option.series), function (seriesOpt) {
  18815. isObject$2(seriesOpt) && processSeries(seriesOpt);
  18816. });
  18817. var axes = ['xAxis', 'yAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'parallelAxis', 'radar'];
  18818. isTheme && axes.push('valueAxis', 'categoryAxis', 'logAxis', 'timeAxis');
  18819. each$3(axes, function (axisName) {
  18820. each$3(toArr(option[axisName]), function (axisOpt) {
  18821. if (axisOpt) {
  18822. compatTextStyle(axisOpt, 'axisLabel');
  18823. compatTextStyle(axisOpt.axisPointer, 'label');
  18824. }
  18825. });
  18826. });
  18827. each$3(toArr(option.parallel), function (parallelOpt) {
  18828. var parallelAxisDefault = parallelOpt && parallelOpt.parallelAxisDefault;
  18829. compatTextStyle(parallelAxisDefault, 'axisLabel');
  18830. compatTextStyle(parallelAxisDefault && parallelAxisDefault.axisPointer, 'label');
  18831. });
  18832. each$3(toArr(option.calendar), function (calendarOpt) {
  18833. convertNormalEmphasis(calendarOpt, 'itemStyle');
  18834. compatTextStyle(calendarOpt, 'dayLabel');
  18835. compatTextStyle(calendarOpt, 'monthLabel');
  18836. compatTextStyle(calendarOpt, 'yearLabel');
  18837. }); // radar.name.textStyle
  18838. each$3(toArr(option.radar), function (radarOpt) {
  18839. compatTextStyle(radarOpt, 'name'); // Use axisName instead of name because component has name property
  18840. if (radarOpt.name && radarOpt.axisName == null) {
  18841. radarOpt.axisName = radarOpt.name;
  18842. delete radarOpt.name;
  18843. {
  18844. deprecateLog('name property in radar component has been changed to axisName');
  18845. }
  18846. }
  18847. if (radarOpt.nameGap != null && radarOpt.axisNameGap == null) {
  18848. radarOpt.axisNameGap = radarOpt.nameGap;
  18849. delete radarOpt.nameGap;
  18850. {
  18851. deprecateLog('nameGap property in radar component has been changed to axisNameGap');
  18852. }
  18853. }
  18854. });
  18855. each$3(toArr(option.geo), function (geoOpt) {
  18856. if (isObject$2(geoOpt)) {
  18857. compatEC3CommonStyles(geoOpt);
  18858. each$3(toArr(geoOpt.regions), function (regionObj) {
  18859. compatEC3CommonStyles(regionObj);
  18860. });
  18861. }
  18862. });
  18863. each$3(toArr(option.timeline), function (timelineOpt) {
  18864. compatEC3CommonStyles(timelineOpt);
  18865. convertNormalEmphasis(timelineOpt, 'label');
  18866. convertNormalEmphasis(timelineOpt, 'itemStyle');
  18867. convertNormalEmphasis(timelineOpt, 'controlStyle', true);
  18868. var data = timelineOpt.data;
  18869. isArray(data) && each$1(data, function (item) {
  18870. if (isObject$1(item)) {
  18871. convertNormalEmphasis(item, 'label');
  18872. convertNormalEmphasis(item, 'itemStyle');
  18873. }
  18874. });
  18875. });
  18876. each$3(toArr(option.toolbox), function (toolboxOpt) {
  18877. convertNormalEmphasis(toolboxOpt, 'iconStyle');
  18878. each$3(toolboxOpt.feature, function (featureOpt) {
  18879. convertNormalEmphasis(featureOpt, 'iconStyle');
  18880. });
  18881. });
  18882. compatTextStyle(toObj(option.axisPointer), 'label');
  18883. compatTextStyle(toObj(option.tooltip).axisPointer, 'label'); // Clean logs
  18884. // storedLogs = {};
  18885. }
  18886. /*
  18887. * Licensed to the Apache Software Foundation (ASF) under one
  18888. * or more contributor license agreements. See the NOTICE file
  18889. * distributed with this work for additional information
  18890. * regarding copyright ownership. The ASF licenses this file
  18891. * to you under the Apache License, Version 2.0 (the
  18892. * "License"); you may not use this file except in compliance
  18893. * with the License. You may obtain a copy of the License at
  18894. *
  18895. * http://www.apache.org/licenses/LICENSE-2.0
  18896. *
  18897. * Unless required by applicable law or agreed to in writing,
  18898. * software distributed under the License is distributed on an
  18899. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18900. * KIND, either express or implied. See the License for the
  18901. * specific language governing permissions and limitations
  18902. * under the License.
  18903. */
  18904. /**
  18905. * AUTO-GENERATED FILE. DO NOT MODIFY.
  18906. */
  18907. /*
  18908. * Licensed to the Apache Software Foundation (ASF) under one
  18909. * or more contributor license agreements. See the NOTICE file
  18910. * distributed with this work for additional information
  18911. * regarding copyright ownership. The ASF licenses this file
  18912. * to you under the Apache License, Version 2.0 (the
  18913. * "License"); you may not use this file except in compliance
  18914. * with the License. You may obtain a copy of the License at
  18915. *
  18916. * http://www.apache.org/licenses/LICENSE-2.0
  18917. *
  18918. * Unless required by applicable law or agreed to in writing,
  18919. * software distributed under the License is distributed on an
  18920. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18921. * KIND, either express or implied. See the License for the
  18922. * specific language governing permissions and limitations
  18923. * under the License.
  18924. */
  18925. function get(opt, path) {
  18926. var pathArr = path.split(',');
  18927. var obj = opt;
  18928. for (var i = 0; i < pathArr.length; i++) {
  18929. obj = obj && obj[pathArr[i]];
  18930. if (obj == null) {
  18931. break;
  18932. }
  18933. }
  18934. return obj;
  18935. }
  18936. function set$1(opt, path, val, overwrite) {
  18937. var pathArr = path.split(',');
  18938. var obj = opt;
  18939. var key;
  18940. var i = 0;
  18941. for (; i < pathArr.length - 1; i++) {
  18942. key = pathArr[i];
  18943. if (obj[key] == null) {
  18944. obj[key] = {};
  18945. }
  18946. obj = obj[key];
  18947. }
  18948. if (overwrite || obj[pathArr[i]] == null) {
  18949. obj[pathArr[i]] = val;
  18950. }
  18951. }
  18952. function compatLayoutProperties(option) {
  18953. option && each$1(LAYOUT_PROPERTIES, function (prop) {
  18954. if (prop[0] in option && !(prop[1] in option)) {
  18955. option[prop[1]] = option[prop[0]];
  18956. }
  18957. });
  18958. }
  18959. var LAYOUT_PROPERTIES = [['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']];
  18960. var COMPATITABLE_COMPONENTS = ['grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'];
  18961. var BAR_ITEM_STYLE_MAP = [['borderRadius', 'barBorderRadius'], ['borderColor', 'barBorderColor'], ['borderWidth', 'barBorderWidth']];
  18962. function compatBarItemStyle(option) {
  18963. var itemStyle = option && option.itemStyle;
  18964. if (itemStyle) {
  18965. for (var i = 0; i < BAR_ITEM_STYLE_MAP.length; i++) {
  18966. var oldName = BAR_ITEM_STYLE_MAP[i][1];
  18967. var newName = BAR_ITEM_STYLE_MAP[i][0];
  18968. if (itemStyle[oldName] != null) {
  18969. itemStyle[newName] = itemStyle[oldName];
  18970. {
  18971. deprecateReplaceLog(oldName, newName);
  18972. }
  18973. }
  18974. }
  18975. }
  18976. }
  18977. function compatPieLabel(option) {
  18978. if (!option) {
  18979. return;
  18980. }
  18981. if (option.alignTo === 'edge' && option.margin != null && option.edgeDistance == null) {
  18982. {
  18983. deprecateReplaceLog('label.margin', 'label.edgeDistance', 'pie');
  18984. }
  18985. option.edgeDistance = option.margin;
  18986. }
  18987. }
  18988. function compatSunburstState(option) {
  18989. if (!option) {
  18990. return;
  18991. }
  18992. if (option.downplay && !option.blur) {
  18993. option.blur = option.downplay;
  18994. {
  18995. deprecateReplaceLog('downplay', 'blur', 'sunburst');
  18996. }
  18997. }
  18998. }
  18999. function compatGraphFocus(option) {
  19000. if (!option) {
  19001. return;
  19002. }
  19003. if (option.focusNodeAdjacency != null) {
  19004. option.emphasis = option.emphasis || {};
  19005. if (option.emphasis.focus == null) {
  19006. {
  19007. deprecateReplaceLog('focusNodeAdjacency', 'emphasis: { focus: \'adjacency\'}', 'graph/sankey');
  19008. }
  19009. option.emphasis.focus = 'adjacency';
  19010. }
  19011. }
  19012. }
  19013. function traverseTree(data, cb) {
  19014. if (data) {
  19015. for (var i = 0; i < data.length; i++) {
  19016. cb(data[i]);
  19017. data[i] && traverseTree(data[i].children, cb);
  19018. }
  19019. }
  19020. }
  19021. function globalBackwardCompat(option, isTheme) {
  19022. globalCompatStyle(option, isTheme); // Make sure series array for model initialization.
  19023. option.series = normalizeToArray(option.series);
  19024. each$1(option.series, function (seriesOpt) {
  19025. if (!isObject$1(seriesOpt)) {
  19026. return;
  19027. }
  19028. var seriesType = seriesOpt.type;
  19029. if (seriesType === 'line') {
  19030. if (seriesOpt.clipOverflow != null) {
  19031. seriesOpt.clip = seriesOpt.clipOverflow;
  19032. {
  19033. deprecateReplaceLog('clipOverflow', 'clip', 'line');
  19034. }
  19035. }
  19036. } else if (seriesType === 'pie' || seriesType === 'gauge') {
  19037. if (seriesOpt.clockWise != null) {
  19038. seriesOpt.clockwise = seriesOpt.clockWise;
  19039. {
  19040. deprecateReplaceLog('clockWise', 'clockwise');
  19041. }
  19042. }
  19043. compatPieLabel(seriesOpt.label);
  19044. var data = seriesOpt.data;
  19045. if (data && !isTypedArray(data)) {
  19046. for (var i = 0; i < data.length; i++) {
  19047. compatPieLabel(data[i]);
  19048. }
  19049. }
  19050. if (seriesOpt.hoverOffset != null) {
  19051. seriesOpt.emphasis = seriesOpt.emphasis || {};
  19052. if (seriesOpt.emphasis.scaleSize = null) {
  19053. {
  19054. deprecateReplaceLog('hoverOffset', 'emphasis.scaleSize');
  19055. }
  19056. seriesOpt.emphasis.scaleSize = seriesOpt.hoverOffset;
  19057. }
  19058. }
  19059. } else if (seriesType === 'gauge') {
  19060. var pointerColor = get(seriesOpt, 'pointer.color');
  19061. pointerColor != null && set$1(seriesOpt, 'itemStyle.color', pointerColor);
  19062. } else if (seriesType === 'bar') {
  19063. compatBarItemStyle(seriesOpt);
  19064. compatBarItemStyle(seriesOpt.backgroundStyle);
  19065. compatBarItemStyle(seriesOpt.emphasis);
  19066. var data = seriesOpt.data;
  19067. if (data && !isTypedArray(data)) {
  19068. for (var i = 0; i < data.length; i++) {
  19069. if (typeof data[i] === 'object') {
  19070. compatBarItemStyle(data[i]);
  19071. compatBarItemStyle(data[i] && data[i].emphasis);
  19072. }
  19073. }
  19074. }
  19075. } else if (seriesType === 'sunburst') {
  19076. var highlightPolicy = seriesOpt.highlightPolicy;
  19077. if (highlightPolicy) {
  19078. seriesOpt.emphasis = seriesOpt.emphasis || {};
  19079. if (!seriesOpt.emphasis.focus) {
  19080. seriesOpt.emphasis.focus = highlightPolicy;
  19081. {
  19082. deprecateReplaceLog('highlightPolicy', 'emphasis.focus', 'sunburst');
  19083. }
  19084. }
  19085. }
  19086. compatSunburstState(seriesOpt);
  19087. traverseTree(seriesOpt.data, compatSunburstState);
  19088. } else if (seriesType === 'graph' || seriesType === 'sankey') {
  19089. compatGraphFocus(seriesOpt); // TODO nodes, edges?
  19090. } else if (seriesType === 'map') {
  19091. if (seriesOpt.mapType && !seriesOpt.map) {
  19092. {
  19093. deprecateReplaceLog('mapType', 'map', 'map');
  19094. }
  19095. seriesOpt.map = seriesOpt.mapType;
  19096. }
  19097. if (seriesOpt.mapLocation) {
  19098. {
  19099. deprecateLog('`mapLocation` is not used anymore.');
  19100. }
  19101. defaults(seriesOpt, seriesOpt.mapLocation);
  19102. }
  19103. }
  19104. if (seriesOpt.hoverAnimation != null) {
  19105. seriesOpt.emphasis = seriesOpt.emphasis || {};
  19106. if (seriesOpt.emphasis && seriesOpt.emphasis.scale == null) {
  19107. {
  19108. deprecateReplaceLog('hoverAnimation', 'emphasis.scale');
  19109. }
  19110. seriesOpt.emphasis.scale = seriesOpt.hoverAnimation;
  19111. }
  19112. }
  19113. compatLayoutProperties(seriesOpt);
  19114. }); // dataRange has changed to visualMap
  19115. if (option.dataRange) {
  19116. option.visualMap = option.dataRange;
  19117. }
  19118. each$1(COMPATITABLE_COMPONENTS, function (componentName) {
  19119. var options = option[componentName];
  19120. if (options) {
  19121. if (!isArray(options)) {
  19122. options = [options];
  19123. }
  19124. each$1(options, function (option) {
  19125. compatLayoutProperties(option);
  19126. });
  19127. }
  19128. });
  19129. }
  19130. /*
  19131. * Licensed to the Apache Software Foundation (ASF) under one
  19132. * or more contributor license agreements. See the NOTICE file
  19133. * distributed with this work for additional information
  19134. * regarding copyright ownership. The ASF licenses this file
  19135. * to you under the Apache License, Version 2.0 (the
  19136. * "License"); you may not use this file except in compliance
  19137. * with the License. You may obtain a copy of the License at
  19138. *
  19139. * http://www.apache.org/licenses/LICENSE-2.0
  19140. *
  19141. * Unless required by applicable law or agreed to in writing,
  19142. * software distributed under the License is distributed on an
  19143. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19144. * KIND, either express or implied. See the License for the
  19145. * specific language governing permissions and limitations
  19146. * under the License.
  19147. */
  19148. /**
  19149. * AUTO-GENERATED FILE. DO NOT MODIFY.
  19150. */
  19151. /*
  19152. * Licensed to the Apache Software Foundation (ASF) under one
  19153. * or more contributor license agreements. See the NOTICE file
  19154. * distributed with this work for additional information
  19155. * regarding copyright ownership. The ASF licenses this file
  19156. * to you under the Apache License, Version 2.0 (the
  19157. * "License"); you may not use this file except in compliance
  19158. * with the License. You may obtain a copy of the License at
  19159. *
  19160. * http://www.apache.org/licenses/LICENSE-2.0
  19161. *
  19162. * Unless required by applicable law or agreed to in writing,
  19163. * software distributed under the License is distributed on an
  19164. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19165. * KIND, either express or implied. See the License for the
  19166. * specific language governing permissions and limitations
  19167. * under the License.
  19168. */
  19169. // data processing stage is blocked in stream.
  19170. // See <module:echarts/stream/Scheduler#performDataProcessorTasks>
  19171. // (2) Only register once when import repeatly.
  19172. // Should be executed after series filtered and before stack calculation.
  19173. function dataStack(ecModel) {
  19174. var stackInfoMap = createHashMap();
  19175. ecModel.eachSeries(function (seriesModel) {
  19176. var stack = seriesModel.get('stack'); // Compatibal: when `stack` is set as '', do not stack.
  19177. if (stack) {
  19178. var stackInfoList = stackInfoMap.get(stack) || stackInfoMap.set(stack, []);
  19179. var data = seriesModel.getData();
  19180. var stackInfo = {
  19181. // Used for calculate axis extent automatically.
  19182. // TODO: Type getCalculationInfo return more specific type?
  19183. stackResultDimension: data.getCalculationInfo('stackResultDimension'),
  19184. stackedOverDimension: data.getCalculationInfo('stackedOverDimension'),
  19185. stackedDimension: data.getCalculationInfo('stackedDimension'),
  19186. stackedByDimension: data.getCalculationInfo('stackedByDimension'),
  19187. isStackedByIndex: data.getCalculationInfo('isStackedByIndex'),
  19188. data: data,
  19189. seriesModel: seriesModel
  19190. }; // If stacked on axis that do not support data stack.
  19191. if (!stackInfo.stackedDimension || !(stackInfo.isStackedByIndex || stackInfo.stackedByDimension)) {
  19192. return;
  19193. }
  19194. stackInfoList.length && data.setCalculationInfo('stackedOnSeries', stackInfoList[stackInfoList.length - 1].seriesModel);
  19195. stackInfoList.push(stackInfo);
  19196. }
  19197. });
  19198. stackInfoMap.each(calculateStack);
  19199. }
  19200. function calculateStack(stackInfoList) {
  19201. each$1(stackInfoList, function (targetStackInfo, idxInStack) {
  19202. var resultVal = [];
  19203. var resultNaN = [NaN, NaN];
  19204. var dims = [targetStackInfo.stackResultDimension, targetStackInfo.stackedOverDimension];
  19205. var targetData = targetStackInfo.data;
  19206. var isStackedByIndex = targetStackInfo.isStackedByIndex; // Should not write on raw data, because stack series model list changes
  19207. // depending on legend selection.
  19208. var newData = targetData.map(dims, function (v0, v1, dataIndex) {
  19209. var sum = targetData.get(targetStackInfo.stackedDimension, dataIndex); // Consider `connectNulls` of line area, if value is NaN, stackedOver
  19210. // should also be NaN, to draw a appropriate belt area.
  19211. if (isNaN(sum)) {
  19212. return resultNaN;
  19213. }
  19214. var byValue;
  19215. var stackedDataRawIndex;
  19216. if (isStackedByIndex) {
  19217. stackedDataRawIndex = targetData.getRawIndex(dataIndex);
  19218. } else {
  19219. byValue = targetData.get(targetStackInfo.stackedByDimension, dataIndex);
  19220. } // If stackOver is NaN, chart view will render point on value start.
  19221. var stackedOver = NaN;
  19222. for (var j = idxInStack - 1; j >= 0; j--) {
  19223. var stackInfo = stackInfoList[j]; // Has been optimized by inverted indices on `stackedByDimension`.
  19224. if (!isStackedByIndex) {
  19225. stackedDataRawIndex = stackInfo.data.rawIndexOf(stackInfo.stackedByDimension, byValue);
  19226. }
  19227. if (stackedDataRawIndex >= 0) {
  19228. var val = stackInfo.data.getByRawIndex(stackInfo.stackResultDimension, stackedDataRawIndex); // Considering positive stack, negative stack and empty data
  19229. if (sum >= 0 && val > 0 || // Positive stack
  19230. sum <= 0 && val < 0 // Negative stack
  19231. ) {
  19232. sum += val;
  19233. stackedOver = val;
  19234. break;
  19235. }
  19236. }
  19237. }
  19238. resultVal[0] = sum;
  19239. resultVal[1] = stackedOver;
  19240. return resultVal;
  19241. });
  19242. targetData.hostModel.setData(newData); // Update for consequent calculation
  19243. targetStackInfo.data = newData;
  19244. });
  19245. }
  19246. /*
  19247. * Licensed to the Apache Software Foundation (ASF) under one
  19248. * or more contributor license agreements. See the NOTICE file
  19249. * distributed with this work for additional information
  19250. * regarding copyright ownership. The ASF licenses this file
  19251. * to you under the Apache License, Version 2.0 (the
  19252. * "License"); you may not use this file except in compliance
  19253. * with the License. You may obtain a copy of the License at
  19254. *
  19255. * http://www.apache.org/licenses/LICENSE-2.0
  19256. *
  19257. * Unless required by applicable law or agreed to in writing,
  19258. * software distributed under the License is distributed on an
  19259. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19260. * KIND, either express or implied. See the License for the
  19261. * specific language governing permissions and limitations
  19262. * under the License.
  19263. */
  19264. /**
  19265. * AUTO-GENERATED FILE. DO NOT MODIFY.
  19266. */
  19267. /*
  19268. * Licensed to the Apache Software Foundation (ASF) under one
  19269. * or more contributor license agreements. See the NOTICE file
  19270. * distributed with this work for additional information
  19271. * regarding copyright ownership. The ASF licenses this file
  19272. * to you under the Apache License, Version 2.0 (the
  19273. * "License"); you may not use this file except in compliance
  19274. * with the License. You may obtain a copy of the License at
  19275. *
  19276. * http://www.apache.org/licenses/LICENSE-2.0
  19277. *
  19278. * Unless required by applicable law or agreed to in writing,
  19279. * software distributed under the License is distributed on an
  19280. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19281. * KIND, either express or implied. See the License for the
  19282. * specific language governing permissions and limitations
  19283. * under the License.
  19284. */
  19285. // @inner
  19286. var SourceImpl =
  19287. /** @class */
  19288. function () {
  19289. // readonly frozen: boolean;
  19290. function SourceImpl(fields) {
  19291. this.data = fields.data || (fields.sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS ? {} : []);
  19292. this.sourceFormat = fields.sourceFormat || SOURCE_FORMAT_UNKNOWN; // Visit config
  19293. this.seriesLayoutBy = fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN;
  19294. this.startIndex = fields.startIndex || 0;
  19295. this.dimensionsDefine = fields.dimensionsDefine;
  19296. this.dimensionsDetectedCount = fields.dimensionsDetectedCount;
  19297. this.encodeDefine = fields.encodeDefine;
  19298. this.metaRawOption = fields.metaRawOption;
  19299. }
  19300. return SourceImpl;
  19301. }();
  19302. function isSourceInstance(val) {
  19303. return val instanceof SourceImpl;
  19304. }
  19305. function createSource(sourceData, thisMetaRawOption, // can be null. If not provided, auto detect it from `sourceData`.
  19306. sourceFormat, encodeDefine // can be null
  19307. ) {
  19308. sourceFormat = sourceFormat || detectSourceFormat(sourceData);
  19309. var seriesLayoutBy = thisMetaRawOption.seriesLayoutBy;
  19310. var determined = determineSourceDimensions(sourceData, sourceFormat, seriesLayoutBy, thisMetaRawOption.sourceHeader, thisMetaRawOption.dimensions);
  19311. var source = new SourceImpl({
  19312. data: sourceData,
  19313. sourceFormat: sourceFormat,
  19314. seriesLayoutBy: seriesLayoutBy,
  19315. dimensionsDefine: determined.dimensionsDefine,
  19316. startIndex: determined.startIndex,
  19317. dimensionsDetectedCount: determined.dimensionsDetectedCount,
  19318. encodeDefine: makeEncodeDefine(encodeDefine),
  19319. metaRawOption: clone(thisMetaRawOption)
  19320. });
  19321. return source;
  19322. }
  19323. /**
  19324. * Wrap original series data for some compatibility cases.
  19325. */
  19326. function createSourceFromSeriesDataOption(data) {
  19327. return new SourceImpl({
  19328. data: data,
  19329. sourceFormat: isTypedArray(data) ? SOURCE_FORMAT_TYPED_ARRAY : SOURCE_FORMAT_ORIGINAL
  19330. });
  19331. }
  19332. /**
  19333. * Clone source but excludes source data.
  19334. */
  19335. function cloneSourceShallow(source) {
  19336. return new SourceImpl({
  19337. data: source.data,
  19338. sourceFormat: source.sourceFormat,
  19339. seriesLayoutBy: source.seriesLayoutBy,
  19340. dimensionsDefine: clone(source.dimensionsDefine),
  19341. startIndex: source.startIndex,
  19342. dimensionsDetectedCount: source.dimensionsDetectedCount,
  19343. encodeDefine: makeEncodeDefine(source.encodeDefine)
  19344. });
  19345. }
  19346. function makeEncodeDefine(encodeDefine) {
  19347. // null means user not specify `series.encode`.
  19348. return encodeDefine ? createHashMap(encodeDefine) : null;
  19349. }
  19350. /**
  19351. * Note: An empty array will be detected as `SOURCE_FORMAT_ARRAY_ROWS`.
  19352. */
  19353. function detectSourceFormat(data) {
  19354. var sourceFormat = SOURCE_FORMAT_UNKNOWN;
  19355. if (isTypedArray(data)) {
  19356. sourceFormat = SOURCE_FORMAT_TYPED_ARRAY;
  19357. } else if (isArray(data)) {
  19358. // FIXME Whether tolerate null in top level array?
  19359. if (data.length === 0) {
  19360. sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
  19361. }
  19362. for (var i = 0, len = data.length; i < len; i++) {
  19363. var item = data[i];
  19364. if (item == null) {
  19365. continue;
  19366. } else if (isArray(item)) {
  19367. sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
  19368. break;
  19369. } else if (isObject$1(item)) {
  19370. sourceFormat = SOURCE_FORMAT_OBJECT_ROWS;
  19371. break;
  19372. }
  19373. }
  19374. } else if (isObject$1(data)) {
  19375. for (var key in data) {
  19376. if (hasOwn(data, key) && isArrayLike(data[key])) {
  19377. sourceFormat = SOURCE_FORMAT_KEYED_COLUMNS;
  19378. break;
  19379. }
  19380. }
  19381. }
  19382. return sourceFormat;
  19383. }
  19384. /**
  19385. * Determine the source definitions from data standalone dimensions definitions
  19386. * are not specified.
  19387. */
  19388. function determineSourceDimensions(data, sourceFormat, seriesLayoutBy, sourceHeader, // standalone raw dimensions definition, like:
  19389. // {
  19390. // dimensions: ['aa', 'bb', { name: 'cc', type: 'time' }]
  19391. // }
  19392. // in `dataset` or `series`
  19393. dimensionsDefine) {
  19394. var dimensionsDetectedCount;
  19395. var startIndex; // PEDING: could data be null/undefined here?
  19396. // currently, if `dataset.source` not specified, error thrown.
  19397. // if `series.data` not specified, nothing rendered without error thrown.
  19398. // Should test these cases.
  19399. if (!data) {
  19400. return {
  19401. dimensionsDefine: normalizeDimensionsOption(dimensionsDefine),
  19402. startIndex: startIndex,
  19403. dimensionsDetectedCount: dimensionsDetectedCount
  19404. };
  19405. }
  19406. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  19407. var dataArrayRows = data; // Rule: Most of the first line are string: it is header.
  19408. // Caution: consider a line with 5 string and 1 number,
  19409. // it still can not be sure it is a head, because the
  19410. // 5 string may be 5 values of category columns.
  19411. if (sourceHeader === 'auto' || sourceHeader == null) {
  19412. arrayRowsTravelFirst(function (val) {
  19413. // '-' is regarded as null/undefined.
  19414. if (val != null && val !== '-') {
  19415. if (isString(val)) {
  19416. startIndex == null && (startIndex = 1);
  19417. } else {
  19418. startIndex = 0;
  19419. }
  19420. } // 10 is an experience number, avoid long loop.
  19421. }, seriesLayoutBy, dataArrayRows, 10);
  19422. } else {
  19423. startIndex = isNumber(sourceHeader) ? sourceHeader : sourceHeader ? 1 : 0;
  19424. }
  19425. if (!dimensionsDefine && startIndex === 1) {
  19426. dimensionsDefine = [];
  19427. arrayRowsTravelFirst(function (val, index) {
  19428. dimensionsDefine[index] = val != null ? val + '' : '';
  19429. }, seriesLayoutBy, dataArrayRows, Infinity);
  19430. }
  19431. dimensionsDetectedCount = dimensionsDefine ? dimensionsDefine.length : seriesLayoutBy === SERIES_LAYOUT_BY_ROW ? dataArrayRows.length : dataArrayRows[0] ? dataArrayRows[0].length : null;
  19432. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  19433. if (!dimensionsDefine) {
  19434. dimensionsDefine = objectRowsCollectDimensions(data);
  19435. }
  19436. } else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  19437. if (!dimensionsDefine) {
  19438. dimensionsDefine = [];
  19439. each$1(data, function (colArr, key) {
  19440. dimensionsDefine.push(key);
  19441. });
  19442. }
  19443. } else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  19444. var value0 = getDataItemValue(data[0]);
  19445. dimensionsDetectedCount = isArray(value0) && value0.length || 1;
  19446. } else if (sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) {
  19447. {
  19448. assert$1(!!dimensionsDefine, 'dimensions must be given if data is TypedArray.');
  19449. }
  19450. }
  19451. return {
  19452. startIndex: startIndex,
  19453. dimensionsDefine: normalizeDimensionsOption(dimensionsDefine),
  19454. dimensionsDetectedCount: dimensionsDetectedCount
  19455. };
  19456. }
  19457. function objectRowsCollectDimensions(data) {
  19458. var firstIndex = 0;
  19459. var obj;
  19460. while (firstIndex < data.length && !(obj = data[firstIndex++])) {} // jshint ignore: line
  19461. if (obj) {
  19462. var dimensions_1 = [];
  19463. each$1(obj, function (value, key) {
  19464. dimensions_1.push(key);
  19465. });
  19466. return dimensions_1;
  19467. }
  19468. } // Consider dimensions defined like ['A', 'price', 'B', 'price', 'C', 'price'],
  19469. // which is reasonable. But dimension name is duplicated.
  19470. // Returns undefined or an array contains only object without null/undefiend or string.
  19471. function normalizeDimensionsOption(dimensionsDefine) {
  19472. if (!dimensionsDefine) {
  19473. // The meaning of null/undefined is different from empty array.
  19474. return;
  19475. }
  19476. var nameMap = createHashMap();
  19477. return map(dimensionsDefine, function (rawItem, index) {
  19478. rawItem = isObject$1(rawItem) ? rawItem : {
  19479. name: rawItem
  19480. }; // Other fields will be discarded.
  19481. var item = {
  19482. name: rawItem.name,
  19483. displayName: rawItem.displayName,
  19484. type: rawItem.type
  19485. }; // User can set null in dimensions.
  19486. // We dont auto specify name, othewise a given name may
  19487. // cause it be refered unexpectedly.
  19488. if (item.name == null) {
  19489. return item;
  19490. } // Also consider number form like 2012.
  19491. item.name += ''; // User may also specify displayName.
  19492. // displayName will always exists except user not
  19493. // specified or dim name is not specified or detected.
  19494. // (A auto generated dim name will not be used as
  19495. // displayName).
  19496. if (item.displayName == null) {
  19497. item.displayName = item.name;
  19498. }
  19499. var exist = nameMap.get(item.name);
  19500. if (!exist) {
  19501. nameMap.set(item.name, {
  19502. count: 1
  19503. });
  19504. } else {
  19505. item.name += '-' + exist.count++;
  19506. }
  19507. return item;
  19508. });
  19509. }
  19510. function arrayRowsTravelFirst(cb, seriesLayoutBy, data, maxLoop) {
  19511. if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
  19512. for (var i = 0; i < data.length && i < maxLoop; i++) {
  19513. cb(data[i] ? data[i][0] : null, i);
  19514. }
  19515. } else {
  19516. var value0 = data[0] || [];
  19517. for (var i = 0; i < value0.length && i < maxLoop; i++) {
  19518. cb(value0[i], i);
  19519. }
  19520. }
  19521. }
  19522. /*
  19523. * Licensed to the Apache Software Foundation (ASF) under one
  19524. * or more contributor license agreements. See the NOTICE file
  19525. * distributed with this work for additional information
  19526. * regarding copyright ownership. The ASF licenses this file
  19527. * to you under the Apache License, Version 2.0 (the
  19528. * "License"); you may not use this file except in compliance
  19529. * with the License. You may obtain a copy of the License at
  19530. *
  19531. * http://www.apache.org/licenses/LICENSE-2.0
  19532. *
  19533. * Unless required by applicable law or agreed to in writing,
  19534. * software distributed under the License is distributed on an
  19535. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19536. * KIND, either express or implied. See the License for the
  19537. * specific language governing permissions and limitations
  19538. * under the License.
  19539. */
  19540. /**
  19541. * AUTO-GENERATED FILE. DO NOT MODIFY.
  19542. */
  19543. /*
  19544. * Licensed to the Apache Software Foundation (ASF) under one
  19545. * or more contributor license agreements. See the NOTICE file
  19546. * distributed with this work for additional information
  19547. * regarding copyright ownership. The ASF licenses this file
  19548. * to you under the Apache License, Version 2.0 (the
  19549. * "License"); you may not use this file except in compliance
  19550. * with the License. You may obtain a copy of the License at
  19551. *
  19552. * http://www.apache.org/licenses/LICENSE-2.0
  19553. *
  19554. * Unless required by applicable law or agreed to in writing,
  19555. * software distributed under the License is distributed on an
  19556. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19557. * KIND, either express or implied. See the License for the
  19558. * specific language governing permissions and limitations
  19559. * under the License.
  19560. */
  19561. var _a;
  19562. var _b;
  19563. var _c; // TODO
  19564. // ??? refactor? check the outer usage of data provider.
  19565. // merge with defaultDimValueGetter?
  19566. var providerMethods;
  19567. var mountMethods;
  19568. /**
  19569. * If normal array used, mutable chunk size is supported.
  19570. * If typed array used, chunk size must be fixed.
  19571. */
  19572. var DefaultDataProvider =
  19573. /** @class */
  19574. function () {
  19575. function DefaultDataProvider(sourceParam, dimSize) {
  19576. // let source: Source;
  19577. var source = !isSourceInstance(sourceParam) ? createSourceFromSeriesDataOption(sourceParam) : sourceParam; // declare source is Source;
  19578. this._source = source;
  19579. var data = this._data = source.data; // Typed array. TODO IE10+?
  19580. if (source.sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) {
  19581. {
  19582. if (dimSize == null) {
  19583. throw new Error('Typed array data must specify dimension size');
  19584. }
  19585. }
  19586. this._offset = 0;
  19587. this._dimSize = dimSize;
  19588. this._data = data;
  19589. }
  19590. mountMethods(this, data, source);
  19591. }
  19592. DefaultDataProvider.prototype.getSource = function () {
  19593. return this._source;
  19594. };
  19595. DefaultDataProvider.prototype.count = function () {
  19596. return 0;
  19597. };
  19598. DefaultDataProvider.prototype.getItem = function (idx, out) {
  19599. return;
  19600. };
  19601. DefaultDataProvider.prototype.appendData = function (newData) {};
  19602. DefaultDataProvider.prototype.clean = function () {};
  19603. DefaultDataProvider.protoInitialize = function () {
  19604. // PENDING: To avoid potential incompat (e.g., prototype
  19605. // is visited somewhere), still init them on prototype.
  19606. var proto = DefaultDataProvider.prototype;
  19607. proto.pure = false;
  19608. proto.persistent = true;
  19609. }();
  19610. DefaultDataProvider.internalField = function () {
  19611. var _a;
  19612. mountMethods = function (provider, data, source) {
  19613. var sourceFormat = source.sourceFormat;
  19614. var seriesLayoutBy = source.seriesLayoutBy;
  19615. var startIndex = source.startIndex;
  19616. var dimsDef = source.dimensionsDefine;
  19617. var methods = providerMethods[getMethodMapKey(sourceFormat, seriesLayoutBy)];
  19618. {
  19619. assert$1(methods, 'Invalide sourceFormat: ' + sourceFormat);
  19620. }
  19621. extend(provider, methods);
  19622. if (sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) {
  19623. provider.getItem = getItemForTypedArray;
  19624. provider.count = countForTypedArray;
  19625. provider.fillStorage = fillStorageForTypedArray;
  19626. } else {
  19627. var rawItemGetter = getRawSourceItemGetter(sourceFormat, seriesLayoutBy);
  19628. provider.getItem = bind(rawItemGetter, null, data, startIndex, dimsDef);
  19629. var rawCounter = getRawSourceDataCounter(sourceFormat, seriesLayoutBy);
  19630. provider.count = bind(rawCounter, null, data, startIndex, dimsDef);
  19631. }
  19632. };
  19633. var getItemForTypedArray = function (idx, out) {
  19634. idx = idx - this._offset;
  19635. out = out || [];
  19636. var data = this._data;
  19637. var dimSize = this._dimSize;
  19638. var offset = dimSize * idx;
  19639. for (var i = 0; i < dimSize; i++) {
  19640. out[i] = data[offset + i];
  19641. }
  19642. return out;
  19643. };
  19644. var fillStorageForTypedArray = function (start, end, storage, extent) {
  19645. var data = this._data;
  19646. var dimSize = this._dimSize;
  19647. for (var dim = 0; dim < dimSize; dim++) {
  19648. var dimExtent = extent[dim];
  19649. var min = dimExtent[0] == null ? Infinity : dimExtent[0];
  19650. var max = dimExtent[1] == null ? -Infinity : dimExtent[1];
  19651. var count = end - start;
  19652. var arr = storage[dim];
  19653. for (var i = 0; i < count; i++) {
  19654. // appendData with TypedArray will always do replace in provider.
  19655. var val = data[i * dimSize + dim];
  19656. arr[start + i] = val;
  19657. val < min && (min = val);
  19658. val > max && (max = val);
  19659. }
  19660. dimExtent[0] = min;
  19661. dimExtent[1] = max;
  19662. }
  19663. };
  19664. var countForTypedArray = function () {
  19665. return this._data ? this._data.length / this._dimSize : 0;
  19666. };
  19667. providerMethods = (_a = {}, _a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN] = {
  19668. pure: true,
  19669. appendData: appendDataSimply
  19670. }, _a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW] = {
  19671. pure: true,
  19672. appendData: function () {
  19673. throw new Error('Do not support appendData when set seriesLayoutBy: "row".');
  19674. }
  19675. }, _a[SOURCE_FORMAT_OBJECT_ROWS] = {
  19676. pure: true,
  19677. appendData: appendDataSimply
  19678. }, _a[SOURCE_FORMAT_KEYED_COLUMNS] = {
  19679. pure: true,
  19680. appendData: function (newData) {
  19681. var data = this._data;
  19682. each$1(newData, function (newCol, key) {
  19683. var oldCol = data[key] || (data[key] = []);
  19684. for (var i = 0; i < (newCol || []).length; i++) {
  19685. oldCol.push(newCol[i]);
  19686. }
  19687. });
  19688. }
  19689. }, _a[SOURCE_FORMAT_ORIGINAL] = {
  19690. appendData: appendDataSimply
  19691. }, _a[SOURCE_FORMAT_TYPED_ARRAY] = {
  19692. persistent: false,
  19693. pure: true,
  19694. appendData: function (newData) {
  19695. {
  19696. assert$1(isTypedArray(newData), 'Added data must be TypedArray if data in initialization is TypedArray');
  19697. }
  19698. this._data = newData;
  19699. },
  19700. // Clean self if data is already used.
  19701. clean: function () {
  19702. // PENDING
  19703. this._offset += this.count();
  19704. this._data = null;
  19705. }
  19706. }, _a);
  19707. function appendDataSimply(newData) {
  19708. for (var i = 0; i < newData.length; i++) {
  19709. this._data.push(newData[i]);
  19710. }
  19711. }
  19712. }();
  19713. return DefaultDataProvider;
  19714. }();
  19715. var getItemSimply = function (rawData, startIndex, dimsDef, idx) {
  19716. return rawData[idx];
  19717. };
  19718. var rawSourceItemGetterMap = (_a = {}, _a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN] = function (rawData, startIndex, dimsDef, idx) {
  19719. return rawData[idx + startIndex];
  19720. }, _a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW] = function (rawData, startIndex, dimsDef, idx) {
  19721. idx += startIndex;
  19722. var item = [];
  19723. var data = rawData;
  19724. for (var i = 0; i < data.length; i++) {
  19725. var row = data[i];
  19726. item.push(row ? row[idx] : null);
  19727. }
  19728. return item;
  19729. }, _a[SOURCE_FORMAT_OBJECT_ROWS] = getItemSimply, _a[SOURCE_FORMAT_KEYED_COLUMNS] = function (rawData, startIndex, dimsDef, idx) {
  19730. var item = [];
  19731. for (var i = 0; i < dimsDef.length; i++) {
  19732. var dimName = dimsDef[i].name;
  19733. {
  19734. if (dimName == null) {
  19735. throw new Error();
  19736. }
  19737. }
  19738. var col = rawData[dimName];
  19739. item.push(col ? col[idx] : null);
  19740. }
  19741. return item;
  19742. }, _a[SOURCE_FORMAT_ORIGINAL] = getItemSimply, _a);
  19743. function getRawSourceItemGetter(sourceFormat, seriesLayoutBy) {
  19744. var method = rawSourceItemGetterMap[getMethodMapKey(sourceFormat, seriesLayoutBy)];
  19745. {
  19746. assert$1(method, 'Do not suppport get item on "' + sourceFormat + '", "' + seriesLayoutBy + '".');
  19747. }
  19748. return method;
  19749. }
  19750. var countSimply = function (rawData, startIndex, dimsDef) {
  19751. return rawData.length;
  19752. };
  19753. var rawSourceDataCounterMap = (_b = {}, _b[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN] = function (rawData, startIndex, dimsDef) {
  19754. return Math.max(0, rawData.length - startIndex);
  19755. }, _b[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW] = function (rawData, startIndex, dimsDef) {
  19756. var row = rawData[0];
  19757. return row ? Math.max(0, row.length - startIndex) : 0;
  19758. }, _b[SOURCE_FORMAT_OBJECT_ROWS] = countSimply, _b[SOURCE_FORMAT_KEYED_COLUMNS] = function (rawData, startIndex, dimsDef) {
  19759. var dimName = dimsDef[0].name;
  19760. {
  19761. if (dimName == null) {
  19762. throw new Error();
  19763. }
  19764. }
  19765. var col = rawData[dimName];
  19766. return col ? col.length : 0;
  19767. }, _b[SOURCE_FORMAT_ORIGINAL] = countSimply, _b);
  19768. function getRawSourceDataCounter(sourceFormat, seriesLayoutBy) {
  19769. var method = rawSourceDataCounterMap[getMethodMapKey(sourceFormat, seriesLayoutBy)];
  19770. {
  19771. assert$1(method, 'Do not suppport count on "' + sourceFormat + '", "' + seriesLayoutBy + '".');
  19772. }
  19773. return method;
  19774. }
  19775. var getRawValueSimply = function (dataItem, dimIndex, dimName) {
  19776. return dimIndex != null ? dataItem[dimIndex] : dataItem;
  19777. };
  19778. var rawSourceValueGetterMap = (_c = {}, _c[SOURCE_FORMAT_ARRAY_ROWS] = getRawValueSimply, _c[SOURCE_FORMAT_OBJECT_ROWS] = function (dataItem, dimIndex, dimName) {
  19779. return dimIndex != null ? dataItem[dimName] : dataItem;
  19780. }, _c[SOURCE_FORMAT_KEYED_COLUMNS] = getRawValueSimply, _c[SOURCE_FORMAT_ORIGINAL] = function (dataItem, dimIndex, dimName) {
  19781. // FIXME: In some case (markpoint in geo (geo-map.html)),
  19782. // dataItem is {coord: [...]}
  19783. var value = getDataItemValue(dataItem);
  19784. return dimIndex == null || !(value instanceof Array) ? value : value[dimIndex];
  19785. }, _c[SOURCE_FORMAT_TYPED_ARRAY] = getRawValueSimply, _c);
  19786. function getRawSourceValueGetter(sourceFormat) {
  19787. var method = rawSourceValueGetterMap[sourceFormat];
  19788. {
  19789. assert$1(method, 'Do not suppport get value on "' + sourceFormat + '".');
  19790. }
  19791. return method;
  19792. }
  19793. function getMethodMapKey(sourceFormat, seriesLayoutBy) {
  19794. return sourceFormat === SOURCE_FORMAT_ARRAY_ROWS ? sourceFormat + '_' + seriesLayoutBy : sourceFormat;
  19795. } // ??? FIXME can these logic be more neat: getRawValue, getRawDataItem,
  19796. // Consider persistent.
  19797. // Caution: why use raw value to display on label or tooltip?
  19798. // A reason is to avoid format. For example time value we do not know
  19799. // how to format is expected. More over, if stack is used, calculated
  19800. // value may be 0.91000000001, which have brings trouble to display.
  19801. // TODO: consider how to treat null/undefined/NaN when display?
  19802. function retrieveRawValue(data, dataIndex, dim // If dimIndex is null/undefined, return OptionDataItem.
  19803. // Otherwise, return OptionDataValue.
  19804. ) {
  19805. if (!data) {
  19806. return;
  19807. } // Consider data may be not persistent.
  19808. var dataItem = data.getRawDataItem(dataIndex);
  19809. if (dataItem == null) {
  19810. return;
  19811. }
  19812. var sourceFormat = data.getProvider().getSource().sourceFormat;
  19813. var dimName;
  19814. var dimIndex;
  19815. var dimInfo = data.getDimensionInfo(dim);
  19816. if (dimInfo) {
  19817. dimName = dimInfo.name;
  19818. dimIndex = dimInfo.index;
  19819. }
  19820. return getRawSourceValueGetter(sourceFormat)(dataItem, dimIndex, dimName);
  19821. }
  19822. /**
  19823. * Compatible with some cases (in pie, map) like:
  19824. * data: [{name: 'xx', value: 5, selected: true}, ...]
  19825. * where only sourceFormat is 'original' and 'objectRows' supported.
  19826. *
  19827. * // TODO
  19828. * Supported detail options in data item when using 'arrayRows'.
  19829. *
  19830. * @param data
  19831. * @param dataIndex
  19832. * @param attr like 'selected'
  19833. */
  19834. /*
  19835. * Licensed to the Apache Software Foundation (ASF) under one
  19836. * or more contributor license agreements. See the NOTICE file
  19837. * distributed with this work for additional information
  19838. * regarding copyright ownership. The ASF licenses this file
  19839. * to you under the Apache License, Version 2.0 (the
  19840. * "License"); you may not use this file except in compliance
  19841. * with the License. You may obtain a copy of the License at
  19842. *
  19843. * http://www.apache.org/licenses/LICENSE-2.0
  19844. *
  19845. * Unless required by applicable law or agreed to in writing,
  19846. * software distributed under the License is distributed on an
  19847. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19848. * KIND, either express or implied. See the License for the
  19849. * specific language governing permissions and limitations
  19850. * under the License.
  19851. */
  19852. /**
  19853. * AUTO-GENERATED FILE. DO NOT MODIFY.
  19854. */
  19855. /*
  19856. * Licensed to the Apache Software Foundation (ASF) under one
  19857. * or more contributor license agreements. See the NOTICE file
  19858. * distributed with this work for additional information
  19859. * regarding copyright ownership. The ASF licenses this file
  19860. * to you under the Apache License, Version 2.0 (the
  19861. * "License"); you may not use this file except in compliance
  19862. * with the License. You may obtain a copy of the License at
  19863. *
  19864. * http://www.apache.org/licenses/LICENSE-2.0
  19865. *
  19866. * Unless required by applicable law or agreed to in writing,
  19867. * software distributed under the License is distributed on an
  19868. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19869. * KIND, either express or implied. See the License for the
  19870. * specific language governing permissions and limitations
  19871. * under the License.
  19872. */
  19873. var DIMENSION_LABEL_REG = /\{@(.+?)\}/g;
  19874. var DataFormatMixin =
  19875. /** @class */
  19876. function () {
  19877. function DataFormatMixin() {}
  19878. /**
  19879. * Get params for formatter
  19880. */
  19881. DataFormatMixin.prototype.getDataParams = function (dataIndex, dataType) {
  19882. var data = this.getData(dataType);
  19883. var rawValue = this.getRawValue(dataIndex, dataType);
  19884. var rawDataIndex = data.getRawIndex(dataIndex);
  19885. var name = data.getName(dataIndex);
  19886. var itemOpt = data.getRawDataItem(dataIndex);
  19887. var style = data.getItemVisual(dataIndex, 'style');
  19888. var color = style && style[data.getItemVisual(dataIndex, 'drawType') || 'fill'];
  19889. var borderColor = style && style.stroke;
  19890. var mainType = this.mainType;
  19891. var isSeries = mainType === 'series';
  19892. var userOutput = data.userOutput;
  19893. return {
  19894. componentType: mainType,
  19895. componentSubType: this.subType,
  19896. componentIndex: this.componentIndex,
  19897. seriesType: isSeries ? this.subType : null,
  19898. seriesIndex: this.seriesIndex,
  19899. seriesId: isSeries ? this.id : null,
  19900. seriesName: isSeries ? this.name : null,
  19901. name: name,
  19902. dataIndex: rawDataIndex,
  19903. data: itemOpt,
  19904. dataType: dataType,
  19905. value: rawValue,
  19906. color: color,
  19907. borderColor: borderColor,
  19908. dimensionNames: userOutput ? userOutput.dimensionNames : null,
  19909. encode: userOutput ? userOutput.encode : null,
  19910. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  19911. $vars: ['seriesName', 'name', 'value']
  19912. };
  19913. };
  19914. /**
  19915. * Format label
  19916. * @param dataIndex
  19917. * @param status 'normal' by default
  19918. * @param dataType
  19919. * @param labelDimIndex Only used in some chart that
  19920. * use formatter in different dimensions, like radar.
  19921. * @param formatter Formatter given outside.
  19922. * @return return null/undefined if no formatter
  19923. */
  19924. DataFormatMixin.prototype.getFormattedLabel = function (dataIndex, status, dataType, labelDimIndex, formatter, extendParams) {
  19925. status = status || 'normal';
  19926. var data = this.getData(dataType);
  19927. var params = this.getDataParams(dataIndex, dataType);
  19928. if (extendParams) {
  19929. params.value = extendParams.interpolatedValue;
  19930. }
  19931. if (labelDimIndex != null && isArray(params.value)) {
  19932. params.value = params.value[labelDimIndex];
  19933. }
  19934. if (!formatter) {
  19935. var itemModel = data.getItemModel(dataIndex); // @ts-ignore
  19936. formatter = itemModel.get(status === 'normal' ? ['label', 'formatter'] : [status, 'label', 'formatter']);
  19937. }
  19938. if (typeof formatter === 'function') {
  19939. params.status = status;
  19940. params.dimensionIndex = labelDimIndex;
  19941. return formatter(params);
  19942. } else if (typeof formatter === 'string') {
  19943. var str = formatTpl(formatter, params); // Support 'aaa{@[3]}bbb{@product}ccc'.
  19944. // Do not support '}' in dim name util have to.
  19945. return str.replace(DIMENSION_LABEL_REG, function (origin, dimStr) {
  19946. var len = dimStr.length;
  19947. var dimLoose = dimStr.charAt(0) === '[' && dimStr.charAt(len - 1) === ']' ? +dimStr.slice(1, len - 1) // Also support: '[]' => 0
  19948. : dimStr;
  19949. var val = retrieveRawValue(data, dataIndex, dimLoose);
  19950. if (extendParams && isArray(extendParams.interpolatedValue)) {
  19951. var dimInfo = data.getDimensionInfo(dimLoose);
  19952. if (dimInfo) {
  19953. val = extendParams.interpolatedValue[dimInfo.index];
  19954. }
  19955. }
  19956. return val != null ? val + '' : '';
  19957. });
  19958. }
  19959. };
  19960. /**
  19961. * Get raw value in option
  19962. */
  19963. DataFormatMixin.prototype.getRawValue = function (idx, dataType) {
  19964. return retrieveRawValue(this.getData(dataType), idx);
  19965. };
  19966. /**
  19967. * Should be implemented.
  19968. * @param {number} dataIndex
  19969. * @param {boolean} [multipleSeries=false]
  19970. * @param {string} [dataType]
  19971. */
  19972. DataFormatMixin.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  19973. // Empty function
  19974. return;
  19975. };
  19976. return DataFormatMixin;
  19977. }(); // PENDING: previously we accept this type when calling `formatTooltip`,
  19978. // but guess little chance has been used outside. Do we need to backward
  19979. // compat it?
  19980. // type TooltipFormatResultLegacyObject = {
  19981. // // `html` means the markup language text, either in 'html' or 'richText'.
  19982. // // The name `html` is not appropriate becuase in 'richText' it is not a HTML
  19983. // // string. But still support it for backward compat.
  19984. // html: string;
  19985. // markers: Dictionary<ColorString>;
  19986. // };
  19987. /**
  19988. * For backward compat, normalize the return from `formatTooltip`.
  19989. */
  19990. function normalizeTooltipFormatResult(result // markersExisting: Dictionary<ColorString>
  19991. ) {
  19992. var markupText; // let markers: Dictionary<ColorString>;
  19993. var markupFragment;
  19994. if (isObject$1(result)) {
  19995. if (result.type) {
  19996. markupFragment = result;
  19997. } else {
  19998. {
  19999. console.warn('The return type of `formatTooltip` is not supported: ' + makePrintable(result));
  20000. }
  20001. } // else {
  20002. // markupText = (result as TooltipFormatResultLegacyObject).html;
  20003. // markers = (result as TooltipFormatResultLegacyObject).markers;
  20004. // if (markersExisting) {
  20005. // markers = zrUtil.merge(markersExisting, markers);
  20006. // }
  20007. // }
  20008. } else {
  20009. markupText = result;
  20010. }
  20011. return {
  20012. markupText: markupText,
  20013. // markers: markers || markersExisting,
  20014. markupFragment: markupFragment
  20015. };
  20016. }
  20017. /*
  20018. * Licensed to the Apache Software Foundation (ASF) under one
  20019. * or more contributor license agreements. See the NOTICE file
  20020. * distributed with this work for additional information
  20021. * regarding copyright ownership. The ASF licenses this file
  20022. * to you under the Apache License, Version 2.0 (the
  20023. * "License"); you may not use this file except in compliance
  20024. * with the License. You may obtain a copy of the License at
  20025. *
  20026. * http://www.apache.org/licenses/LICENSE-2.0
  20027. *
  20028. * Unless required by applicable law or agreed to in writing,
  20029. * software distributed under the License is distributed on an
  20030. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20031. * KIND, either express or implied. See the License for the
  20032. * specific language governing permissions and limitations
  20033. * under the License.
  20034. */
  20035. /**
  20036. * AUTO-GENERATED FILE. DO NOT MODIFY.
  20037. */
  20038. /*
  20039. * Licensed to the Apache Software Foundation (ASF) under one
  20040. * or more contributor license agreements. See the NOTICE file
  20041. * distributed with this work for additional information
  20042. * regarding copyright ownership. The ASF licenses this file
  20043. * to you under the Apache License, Version 2.0 (the
  20044. * "License"); you may not use this file except in compliance
  20045. * with the License. You may obtain a copy of the License at
  20046. *
  20047. * http://www.apache.org/licenses/LICENSE-2.0
  20048. *
  20049. * Unless required by applicable law or agreed to in writing,
  20050. * software distributed under the License is distributed on an
  20051. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20052. * KIND, either express or implied. See the License for the
  20053. * specific language governing permissions and limitations
  20054. * under the License.
  20055. */
  20056. /**
  20057. * @param {Object} define
  20058. * @return See the return of `createTask`.
  20059. */
  20060. function createTask(define) {
  20061. return new Task(define);
  20062. }
  20063. var Task =
  20064. /** @class */
  20065. function () {
  20066. function Task(define) {
  20067. define = define || {};
  20068. this._reset = define.reset;
  20069. this._plan = define.plan;
  20070. this._count = define.count;
  20071. this._onDirty = define.onDirty;
  20072. this._dirty = true;
  20073. }
  20074. /**
  20075. * @param step Specified step.
  20076. * @param skip Skip customer perform call.
  20077. * @param modBy Sampling window size.
  20078. * @param modDataCount Sampling count.
  20079. * @return whether unfinished.
  20080. */
  20081. Task.prototype.perform = function (performArgs) {
  20082. var upTask = this._upstream;
  20083. var skip = performArgs && performArgs.skip; // TODO some refactor.
  20084. // Pull data. Must pull data each time, because context.data
  20085. // may be updated by Series.setData.
  20086. if (this._dirty && upTask) {
  20087. var context = this.context;
  20088. context.data = context.outputData = upTask.context.outputData;
  20089. }
  20090. if (this.__pipeline) {
  20091. this.__pipeline.currentTask = this;
  20092. }
  20093. var planResult;
  20094. if (this._plan && !skip) {
  20095. planResult = this._plan(this.context);
  20096. } // Support sharding by mod, which changes the render sequence and makes the rendered graphic
  20097. // elements uniformed distributed when progress, especially when moving or zooming.
  20098. var lastModBy = normalizeModBy(this._modBy);
  20099. var lastModDataCount = this._modDataCount || 0;
  20100. var modBy = normalizeModBy(performArgs && performArgs.modBy);
  20101. var modDataCount = performArgs && performArgs.modDataCount || 0;
  20102. if (lastModBy !== modBy || lastModDataCount !== modDataCount) {
  20103. planResult = 'reset';
  20104. }
  20105. function normalizeModBy(val) {
  20106. !(val >= 1) && (val = 1); // jshint ignore:line
  20107. return val;
  20108. }
  20109. var forceFirstProgress;
  20110. if (this._dirty || planResult === 'reset') {
  20111. this._dirty = false;
  20112. forceFirstProgress = this._doReset(skip);
  20113. }
  20114. this._modBy = modBy;
  20115. this._modDataCount = modDataCount;
  20116. var step = performArgs && performArgs.step;
  20117. if (upTask) {
  20118. {
  20119. assert$1(upTask._outputDueEnd != null);
  20120. }
  20121. this._dueEnd = upTask._outputDueEnd;
  20122. } // DataTask or overallTask
  20123. else {
  20124. {
  20125. assert$1(!this._progress || this._count);
  20126. }
  20127. this._dueEnd = this._count ? this._count(this.context) : Infinity;
  20128. } // Note: Stubs, that its host overall task let it has progress, has progress.
  20129. // If no progress, pass index from upstream to downstream each time plan called.
  20130. if (this._progress) {
  20131. var start = this._dueIndex;
  20132. var end = Math.min(step != null ? this._dueIndex + step : Infinity, this._dueEnd);
  20133. if (!skip && (forceFirstProgress || start < end)) {
  20134. var progress = this._progress;
  20135. if (isArray(progress)) {
  20136. for (var i = 0; i < progress.length; i++) {
  20137. this._doProgress(progress[i], start, end, modBy, modDataCount);
  20138. }
  20139. } else {
  20140. this._doProgress(progress, start, end, modBy, modDataCount);
  20141. }
  20142. }
  20143. this._dueIndex = end; // If no `outputDueEnd`, assume that output data and
  20144. // input data is the same, so use `dueIndex` as `outputDueEnd`.
  20145. var outputDueEnd = this._settedOutputEnd != null ? this._settedOutputEnd : end;
  20146. {
  20147. // ??? Can not rollback.
  20148. assert$1(outputDueEnd >= this._outputDueEnd);
  20149. }
  20150. this._outputDueEnd = outputDueEnd;
  20151. } else {
  20152. // (1) Some overall task has no progress.
  20153. // (2) Stubs, that its host overall task do not let it has progress, has no progress.
  20154. // This should always be performed so it can be passed to downstream.
  20155. this._dueIndex = this._outputDueEnd = this._settedOutputEnd != null ? this._settedOutputEnd : this._dueEnd;
  20156. }
  20157. return this.unfinished();
  20158. };
  20159. Task.prototype.dirty = function () {
  20160. this._dirty = true;
  20161. this._onDirty && this._onDirty(this.context);
  20162. };
  20163. Task.prototype._doProgress = function (progress, start, end, modBy, modDataCount) {
  20164. iterator.reset(start, end, modBy, modDataCount);
  20165. this._callingProgress = progress;
  20166. this._callingProgress({
  20167. start: start,
  20168. end: end,
  20169. count: end - start,
  20170. next: iterator.next
  20171. }, this.context);
  20172. };
  20173. Task.prototype._doReset = function (skip) {
  20174. this._dueIndex = this._outputDueEnd = this._dueEnd = 0;
  20175. this._settedOutputEnd = null;
  20176. var progress;
  20177. var forceFirstProgress;
  20178. if (!skip && this._reset) {
  20179. progress = this._reset(this.context);
  20180. if (progress && progress.progress) {
  20181. forceFirstProgress = progress.forceFirstProgress;
  20182. progress = progress.progress;
  20183. } // To simplify no progress checking, array must has item.
  20184. if (isArray(progress) && !progress.length) {
  20185. progress = null;
  20186. }
  20187. }
  20188. this._progress = progress;
  20189. this._modBy = this._modDataCount = null;
  20190. var downstream = this._downstream;
  20191. downstream && downstream.dirty();
  20192. return forceFirstProgress;
  20193. };
  20194. Task.prototype.unfinished = function () {
  20195. return this._progress && this._dueIndex < this._dueEnd;
  20196. };
  20197. /**
  20198. * @param downTask The downstream task.
  20199. * @return The downstream task.
  20200. */
  20201. Task.prototype.pipe = function (downTask) {
  20202. {
  20203. assert$1(downTask && !downTask._disposed && downTask !== this);
  20204. } // If already downstream, do not dirty downTask.
  20205. if (this._downstream !== downTask || this._dirty) {
  20206. this._downstream = downTask;
  20207. downTask._upstream = this;
  20208. downTask.dirty();
  20209. }
  20210. };
  20211. Task.prototype.dispose = function () {
  20212. if (this._disposed) {
  20213. return;
  20214. }
  20215. this._upstream && (this._upstream._downstream = null);
  20216. this._downstream && (this._downstream._upstream = null);
  20217. this._dirty = false;
  20218. this._disposed = true;
  20219. };
  20220. Task.prototype.getUpstream = function () {
  20221. return this._upstream;
  20222. };
  20223. Task.prototype.getDownstream = function () {
  20224. return this._downstream;
  20225. };
  20226. Task.prototype.setOutputEnd = function (end) {
  20227. // This only happend in dataTask, dataZoom, map, currently.
  20228. // where dataZoom do not set end each time, but only set
  20229. // when reset. So we should record the setted end, in case
  20230. // that the stub of dataZoom perform again and earse the
  20231. // setted end by upstream.
  20232. this._outputDueEnd = this._settedOutputEnd = end;
  20233. };
  20234. return Task;
  20235. }();
  20236. var iterator = function () {
  20237. var end;
  20238. var current;
  20239. var modBy;
  20240. var modDataCount;
  20241. var winCount;
  20242. var it = {
  20243. reset: function (s, e, sStep, sCount) {
  20244. current = s;
  20245. end = e;
  20246. modBy = sStep;
  20247. modDataCount = sCount;
  20248. winCount = Math.ceil(modDataCount / modBy);
  20249. it.next = modBy > 1 && modDataCount > 0 ? modNext : sequentialNext;
  20250. }
  20251. };
  20252. return it;
  20253. function sequentialNext() {
  20254. return current < end ? current++ : null;
  20255. }
  20256. function modNext() {
  20257. var dataIndex = current % winCount * modBy + Math.ceil(current / winCount);
  20258. var result = current >= end ? null : dataIndex < modDataCount ? dataIndex // If modDataCount is smaller than data.count() (consider `appendData` case),
  20259. // Use normal linear rendering mode.
  20260. : current;
  20261. current++;
  20262. return result;
  20263. }
  20264. }(); ///////////////////////////////////////////////////////////
  20265. // For stream debug (Should be commented out after used!)
  20266. // @usage: printTask(this, 'begin');
  20267. // @usage: printTask(this, null, {someExtraProp});
  20268. // @usage: Use `__idxInPipeline` as conditional breakpiont.
  20269. //
  20270. // window.printTask = function (task: any, prefix: string, extra: { [key: string]: unknown }): void {
  20271. // window.ecTaskUID == null && (window.ecTaskUID = 0);
  20272. // task.uidDebug == null && (task.uidDebug = `task_${window.ecTaskUID++}`);
  20273. // task.agent && task.agent.uidDebug == null && (task.agent.uidDebug = `task_${window.ecTaskUID++}`);
  20274. // let props = [];
  20275. // if (task.__pipeline) {
  20276. // let val = `${task.__idxInPipeline}/${task.__pipeline.tail.__idxInPipeline} ${task.agent ? '(stub)' : ''}`;
  20277. // props.push({text: '__idxInPipeline/total', value: val});
  20278. // } else {
  20279. // let stubCount = 0;
  20280. // task.agentStubMap.each(() => stubCount++);
  20281. // props.push({text: 'idx', value: `overall (stubs: ${stubCount})`});
  20282. // }
  20283. // props.push({text: 'uid', value: task.uidDebug});
  20284. // if (task.__pipeline) {
  20285. // props.push({text: 'pipelineId', value: task.__pipeline.id});
  20286. // task.agent && props.push(
  20287. // {text: 'stubFor', value: task.agent.uidDebug}
  20288. // );
  20289. // }
  20290. // props.push(
  20291. // {text: 'dirty', value: task._dirty},
  20292. // {text: 'dueIndex', value: task._dueIndex},
  20293. // {text: 'dueEnd', value: task._dueEnd},
  20294. // {text: 'outputDueEnd', value: task._outputDueEnd}
  20295. // );
  20296. // if (extra) {
  20297. // Object.keys(extra).forEach(key => {
  20298. // props.push({text: key, value: extra[key]});
  20299. // });
  20300. // }
  20301. // let args = ['color: blue'];
  20302. // let msg = `%c[${prefix || 'T'}] %c` + props.map(item => (
  20303. // args.push('color: green', 'color: red'),
  20304. // `${item.text}: %c${item.value}`
  20305. // )).join('%c, ');
  20306. // console.log.apply(console, [msg].concat(args));
  20307. // // console.log(this);
  20308. // };
  20309. // window.printPipeline = function (task: any, prefix: string) {
  20310. // const pipeline = task.__pipeline;
  20311. // let currTask = pipeline.head;
  20312. // while (currTask) {
  20313. // window.printTask(currTask, prefix);
  20314. // currTask = currTask._downstream;
  20315. // }
  20316. // };
  20317. // window.showChain = function (chainHeadTask) {
  20318. // var chain = [];
  20319. // var task = chainHeadTask;
  20320. // while (task) {
  20321. // chain.push({
  20322. // task: task,
  20323. // up: task._upstream,
  20324. // down: task._downstream,
  20325. // idxInPipeline: task.__idxInPipeline
  20326. // });
  20327. // task = task._downstream;
  20328. // }
  20329. // return chain;
  20330. // };
  20331. // window.findTaskInChain = function (task, chainHeadTask) {
  20332. // let chain = window.showChain(chainHeadTask);
  20333. // let result = [];
  20334. // for (let i = 0; i < chain.length; i++) {
  20335. // let chainItem = chain[i];
  20336. // if (chainItem.task === task) {
  20337. // result.push(i);
  20338. // }
  20339. // }
  20340. // return result;
  20341. // };
  20342. // window.printChainAEachInChainB = function (chainHeadTaskA, chainHeadTaskB) {
  20343. // let chainA = window.showChain(chainHeadTaskA);
  20344. // for (let i = 0; i < chainA.length; i++) {
  20345. // console.log('chainAIdx:', i, 'inChainB:', window.findTaskInChain(chainA[i].task, chainHeadTaskB));
  20346. // }
  20347. // };
  20348. /*
  20349. * Licensed to the Apache Software Foundation (ASF) under one
  20350. * or more contributor license agreements. See the NOTICE file
  20351. * distributed with this work for additional information
  20352. * regarding copyright ownership. The ASF licenses this file
  20353. * to you under the Apache License, Version 2.0 (the
  20354. * "License"); you may not use this file except in compliance
  20355. * with the License. You may obtain a copy of the License at
  20356. *
  20357. * http://www.apache.org/licenses/LICENSE-2.0
  20358. *
  20359. * Unless required by applicable law or agreed to in writing,
  20360. * software distributed under the License is distributed on an
  20361. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20362. * KIND, either express or implied. See the License for the
  20363. * specific language governing permissions and limitations
  20364. * under the License.
  20365. */
  20366. /**
  20367. * AUTO-GENERATED FILE. DO NOT MODIFY.
  20368. */
  20369. /*
  20370. * Licensed to the Apache Software Foundation (ASF) under one
  20371. * or more contributor license agreements. See the NOTICE file
  20372. * distributed with this work for additional information
  20373. * regarding copyright ownership. The ASF licenses this file
  20374. * to you under the Apache License, Version 2.0 (the
  20375. * "License"); you may not use this file except in compliance
  20376. * with the License. You may obtain a copy of the License at
  20377. *
  20378. * http://www.apache.org/licenses/LICENSE-2.0
  20379. *
  20380. * Unless required by applicable law or agreed to in writing,
  20381. * software distributed under the License is distributed on an
  20382. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20383. * KIND, either express or implied. See the License for the
  20384. * specific language governing permissions and limitations
  20385. * under the License.
  20386. */
  20387. /**
  20388. * Convert raw the value in to inner value in List.
  20389. *
  20390. * [Performance sensitive]
  20391. *
  20392. * [Caution]: this is the key logic of user value parser.
  20393. * For backward compatibiliy, do not modify it until have to!
  20394. */
  20395. function parseDataValue(value, // For high performance, do not omit the second param.
  20396. opt) {
  20397. // Performance sensitive.
  20398. var dimType = opt && opt.type;
  20399. if (dimType === 'ordinal') {
  20400. // If given value is a category string
  20401. var ordinalMeta = opt && opt.ordinalMeta;
  20402. return ordinalMeta ? ordinalMeta.parseAndCollect(value) : value;
  20403. }
  20404. if (dimType === 'time' // spead up when using timestamp
  20405. && typeof value !== 'number' && value != null && value !== '-') {
  20406. value = +parseDate(value);
  20407. } // dimType defaults 'number'.
  20408. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  20409. // parse to NaN.
  20410. // number-like string (like ' 123 ') can be converted to a number.
  20411. // where null/undefined or other string will be converted to NaN.
  20412. return value == null || value === '' ? NaN // If string (like '-'), using '+' parse to NaN
  20413. // If object, also parse to NaN
  20414. : +value;
  20415. }
  20416. var valueParserMap = createHashMap({
  20417. 'number': function (val) {
  20418. // Do not use `numericToNumber` here. We have by defualt `numericToNumber`.
  20419. // Here the number parser can have loose rule:
  20420. // enable to cut suffix: "120px" => 120, "14%" => 14.
  20421. return parseFloat(val);
  20422. },
  20423. 'time': function (val) {
  20424. // return timestamp.
  20425. return +parseDate(val);
  20426. },
  20427. 'trim': function (val) {
  20428. return typeof val === 'string' ? trim(val) : val;
  20429. }
  20430. });
  20431. var ORDER_COMPARISON_OP_MAP = {
  20432. lt: function (lval, rval) {
  20433. return lval < rval;
  20434. },
  20435. lte: function (lval, rval) {
  20436. return lval <= rval;
  20437. },
  20438. gt: function (lval, rval) {
  20439. return lval > rval;
  20440. },
  20441. gte: function (lval, rval) {
  20442. return lval >= rval;
  20443. }
  20444. };
  20445. var FilterOrderComparator =
  20446. /** @class */
  20447. function () {
  20448. function FilterOrderComparator(op, rval) {
  20449. if (typeof rval !== 'number') {
  20450. var errMsg = '';
  20451. {
  20452. errMsg = 'rvalue of "<", ">", "<=", ">=" can only be number in filter.';
  20453. }
  20454. throwError(errMsg);
  20455. }
  20456. this._opFn = ORDER_COMPARISON_OP_MAP[op];
  20457. this._rvalFloat = numericToNumber(rval);
  20458. } // Performance sensitive.
  20459. FilterOrderComparator.prototype.evaluate = function (lval) {
  20460. // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.
  20461. return typeof lval === 'number' ? this._opFn(lval, this._rvalFloat) : this._opFn(numericToNumber(lval), this._rvalFloat);
  20462. };
  20463. return FilterOrderComparator;
  20464. }();
  20465. var SortOrderComparator =
  20466. /** @class */
  20467. function () {
  20468. /**
  20469. * @param order by defualt: 'asc'
  20470. * @param incomparable by defualt: Always on the tail.
  20471. * That is, if 'asc' => 'max', if 'desc' => 'min'
  20472. * See the definition of "incomparable" in [SORT_COMPARISON_RULE]
  20473. */
  20474. function SortOrderComparator(order, incomparable) {
  20475. var isDesc = order === 'desc';
  20476. this._resultLT = isDesc ? 1 : -1;
  20477. if (incomparable == null) {
  20478. incomparable = isDesc ? 'min' : 'max';
  20479. }
  20480. this._incomparable = incomparable === 'min' ? -Infinity : Infinity;
  20481. } // See [SORT_COMPARISON_RULE].
  20482. // Performance sensitive.
  20483. SortOrderComparator.prototype.evaluate = function (lval, rval) {
  20484. // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.
  20485. var lvalTypeof = typeof lval;
  20486. var rvalTypeof = typeof rval;
  20487. var lvalFloat = lvalTypeof === 'number' ? lval : numericToNumber(lval);
  20488. var rvalFloat = rvalTypeof === 'number' ? rval : numericToNumber(rval);
  20489. var lvalNotNumeric = isNaN(lvalFloat);
  20490. var rvalNotNumeric = isNaN(rvalFloat);
  20491. if (lvalNotNumeric) {
  20492. lvalFloat = this._incomparable;
  20493. }
  20494. if (rvalNotNumeric) {
  20495. rvalFloat = this._incomparable;
  20496. }
  20497. if (lvalNotNumeric && rvalNotNumeric) {
  20498. var lvalIsStr = lvalTypeof === 'string';
  20499. var rvalIsStr = rvalTypeof === 'string';
  20500. if (lvalIsStr) {
  20501. lvalFloat = rvalIsStr ? lval : 0;
  20502. }
  20503. if (rvalIsStr) {
  20504. rvalFloat = lvalIsStr ? rval : 0;
  20505. }
  20506. }
  20507. return lvalFloat < rvalFloat ? this._resultLT : lvalFloat > rvalFloat ? -this._resultLT : 0;
  20508. };
  20509. return SortOrderComparator;
  20510. }();
  20511. var FilterEqualityComparator =
  20512. /** @class */
  20513. function () {
  20514. function FilterEqualityComparator(isEq, rval) {
  20515. this._rval = rval;
  20516. this._isEQ = isEq;
  20517. this._rvalTypeof = typeof rval;
  20518. this._rvalFloat = numericToNumber(rval);
  20519. } // Performance sensitive.
  20520. FilterEqualityComparator.prototype.evaluate = function (lval) {
  20521. var eqResult = lval === this._rval;
  20522. if (!eqResult) {
  20523. var lvalTypeof = typeof lval;
  20524. if (lvalTypeof !== this._rvalTypeof && (lvalTypeof === 'number' || this._rvalTypeof === 'number')) {
  20525. eqResult = numericToNumber(lval) === this._rvalFloat;
  20526. }
  20527. }
  20528. return this._isEQ ? eqResult : !eqResult;
  20529. };
  20530. return FilterEqualityComparator;
  20531. }();
  20532. /**
  20533. * [FILTER_COMPARISON_RULE]
  20534. * `lt`|`lte`|`gt`|`gte`:
  20535. * + rval must be a number. And lval will be converted to number (`numericToNumber`) to compare.
  20536. * `eq`:
  20537. * + If same type, compare with `===`.
  20538. * + If there is one number, convert to number (`numericToNumber`) to compare.
  20539. * + Else return `false`.
  20540. * `ne`:
  20541. * + Not `eq`.
  20542. *
  20543. *
  20544. * [SORT_COMPARISON_RULE]
  20545. * All the values are grouped into three categories:
  20546. * + "numeric" (number and numeric string)
  20547. * + "non-numeric-string" (string that excluding numeric string)
  20548. * + "others"
  20549. * "numeric" vs "numeric": values are ordered by number order.
  20550. * "non-numeric-string" vs "non-numeric-string": values are ordered by ES spec (#sec-abstract-relational-comparison).
  20551. * "others" vs "others": do not change order (always return 0).
  20552. * "numeric" vs "non-numeric-string": "non-numeric-string" is treated as "incomparable".
  20553. * "number" vs "others": "others" is treated as "incomparable".
  20554. * "non-numeric-string" vs "others": "others" is treated as "incomparable".
  20555. * "incomparable" will be seen as -Infinity or Infinity (depends on the settings).
  20556. * MEMO:
  20557. * non-numeric string sort make sence when need to put the items with the same tag together.
  20558. * But if we support string sort, we still need to avoid the misleading like `'2' > '12'`,
  20559. * So we treat "numeric-string" sorted by number order rather than string comparison.
  20560. *
  20561. *
  20562. * [CHECK_LIST_OF_THE_RULE_DESIGN]
  20563. * + Do not support string comparison until required. And also need to
  20564. * void the misleading of "2" > "12".
  20565. * + Should avoid the misleading case:
  20566. * `" 22 " gte "22"` is `true` but `" 22 " eq "22"` is `false`.
  20567. * + JS bad case should be avoided: null <= 0, [] <= 0, ' ' <= 0, ...
  20568. * + Only "numeric" can be converted to comparable number, otherwise converted to NaN.
  20569. * See `util/number.ts#numericToNumber`.
  20570. *
  20571. * @return If `op` is not `RelationalOperator`, return null;
  20572. */
  20573. /*
  20574. * Licensed to the Apache Software Foundation (ASF) under one
  20575. * or more contributor license agreements. See the NOTICE file
  20576. * distributed with this work for additional information
  20577. * regarding copyright ownership. The ASF licenses this file
  20578. * to you under the Apache License, Version 2.0 (the
  20579. * "License"); you may not use this file except in compliance
  20580. * with the License. You may obtain a copy of the License at
  20581. *
  20582. * http://www.apache.org/licenses/LICENSE-2.0
  20583. *
  20584. * Unless required by applicable law or agreed to in writing,
  20585. * software distributed under the License is distributed on an
  20586. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20587. * KIND, either express or implied. See the License for the
  20588. * specific language governing permissions and limitations
  20589. * under the License.
  20590. */
  20591. /**
  20592. * AUTO-GENERATED FILE. DO NOT MODIFY.
  20593. */
  20594. /*
  20595. * Licensed to the Apache Software Foundation (ASF) under one
  20596. * or more contributor license agreements. See the NOTICE file
  20597. * distributed with this work for additional information
  20598. * regarding copyright ownership. The ASF licenses this file
  20599. * to you under the Apache License, Version 2.0 (the
  20600. * "License"); you may not use this file except in compliance
  20601. * with the License. You may obtain a copy of the License at
  20602. *
  20603. * http://www.apache.org/licenses/LICENSE-2.0
  20604. *
  20605. * Unless required by applicable law or agreed to in writing,
  20606. * software distributed under the License is distributed on an
  20607. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20608. * KIND, either express or implied. See the License for the
  20609. * specific language governing permissions and limitations
  20610. * under the License.
  20611. */
  20612. /**
  20613. * TODO: disable writable.
  20614. * This structure will be exposed to users.
  20615. */
  20616. var ExternalSource =
  20617. /** @class */
  20618. function () {
  20619. function ExternalSource() {}
  20620. ExternalSource.prototype.getRawData = function () {
  20621. // Only built-in transform available.
  20622. throw new Error('not supported');
  20623. };
  20624. ExternalSource.prototype.getRawDataItem = function (dataIndex) {
  20625. // Only built-in transform available.
  20626. throw new Error('not supported');
  20627. };
  20628. ExternalSource.prototype.cloneRawData = function () {
  20629. return;
  20630. };
  20631. /**
  20632. * @return If dimension not found, return null/undefined.
  20633. */
  20634. ExternalSource.prototype.getDimensionInfo = function (dim) {
  20635. return;
  20636. };
  20637. /**
  20638. * dimensions defined if and only if either:
  20639. * (a) dataset.dimensions are declared.
  20640. * (b) dataset data include dimensions definitions in data (detected or via specified `sourceHeader`).
  20641. * If dimensions are defined, `dimensionInfoAll` is corresponding to
  20642. * the defined dimensions.
  20643. * Otherwise, `dimensionInfoAll` is determined by data columns.
  20644. * @return Always return an array (even empty array).
  20645. */
  20646. ExternalSource.prototype.cloneAllDimensionInfo = function () {
  20647. return;
  20648. };
  20649. ExternalSource.prototype.count = function () {
  20650. return;
  20651. };
  20652. /**
  20653. * Only support by dimension index.
  20654. * No need to support by dimension name in transform function,
  20655. * becuase transform function is not case-specific, no need to use name literally.
  20656. */
  20657. ExternalSource.prototype.retrieveValue = function (dataIndex, dimIndex) {
  20658. return;
  20659. };
  20660. ExternalSource.prototype.retrieveValueFromItem = function (dataItem, dimIndex) {
  20661. return;
  20662. };
  20663. ExternalSource.prototype.convertValue = function (rawVal, dimInfo) {
  20664. return parseDataValue(rawVal, dimInfo);
  20665. };
  20666. return ExternalSource;
  20667. }();
  20668. function createExternalSource(internalSource, externalTransform) {
  20669. var extSource = new ExternalSource();
  20670. var data = internalSource.data;
  20671. var sourceFormat = extSource.sourceFormat = internalSource.sourceFormat;
  20672. var sourceHeaderCount = internalSource.startIndex;
  20673. var errMsg = '';
  20674. if (internalSource.seriesLayoutBy !== SERIES_LAYOUT_BY_COLUMN) {
  20675. // For the logic simplicity in transformer, only 'culumn' is
  20676. // supported in data transform. Otherwise, the `dimensionsDefine`
  20677. // might be detected by 'row', which probably confuses users.
  20678. {
  20679. errMsg = '`seriesLayoutBy` of upstream dataset can only be "column" in data transform.';
  20680. }
  20681. throwError(errMsg);
  20682. } // [MEMO]
  20683. // Create a new dimensions structure for exposing.
  20684. // Do not expose all dimension info to users directly.
  20685. // Becuase the dimension is probably auto detected from data and not might reliable.
  20686. // Should not lead the transformers to think that is relialbe and return it.
  20687. // See [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.
  20688. var dimensions = [];
  20689. var dimsByName = {};
  20690. var dimsDef = internalSource.dimensionsDefine;
  20691. if (dimsDef) {
  20692. each$1(dimsDef, function (dimDef, idx) {
  20693. var name = dimDef.name;
  20694. var dimDefExt = {
  20695. index: idx,
  20696. name: name,
  20697. displayName: dimDef.displayName
  20698. };
  20699. dimensions.push(dimDefExt); // Users probably not sepcify dimension name. For simplicity, data transform
  20700. // do not generate dimension name.
  20701. if (name != null) {
  20702. // Dimension name should not be duplicated.
  20703. // For simplicity, data transform forbid name duplication, do not generate
  20704. // new name like module `completeDimensions.ts` did, but just tell users.
  20705. var errMsg_1 = '';
  20706. if (hasOwn(dimsByName, name)) {
  20707. {
  20708. errMsg_1 = 'dimension name "' + name + '" duplicated.';
  20709. }
  20710. throwError(errMsg_1);
  20711. }
  20712. dimsByName[name] = dimDefExt;
  20713. }
  20714. });
  20715. } // If dimension definitions are not defined and can not be detected.
  20716. // e.g., pure data `[[11, 22], ...]`.
  20717. else {
  20718. for (var i = 0; i < internalSource.dimensionsDetectedCount || 0; i++) {
  20719. // Do not generete name or anything others. The consequence process in
  20720. // `transform` or `series` probably have there own name generation strategry.
  20721. dimensions.push({
  20722. index: i
  20723. });
  20724. }
  20725. } // Implement public methods:
  20726. var rawItemGetter = getRawSourceItemGetter(sourceFormat, SERIES_LAYOUT_BY_COLUMN);
  20727. if (externalTransform.__isBuiltIn) {
  20728. extSource.getRawDataItem = function (dataIndex) {
  20729. return rawItemGetter(data, sourceHeaderCount, dimensions, dataIndex);
  20730. };
  20731. extSource.getRawData = bind(getRawData, null, internalSource);
  20732. }
  20733. extSource.cloneRawData = bind(cloneRawData, null, internalSource);
  20734. var rawCounter = getRawSourceDataCounter(sourceFormat, SERIES_LAYOUT_BY_COLUMN);
  20735. extSource.count = bind(rawCounter, null, data, sourceHeaderCount, dimensions);
  20736. var rawValueGetter = getRawSourceValueGetter(sourceFormat);
  20737. extSource.retrieveValue = function (dataIndex, dimIndex) {
  20738. var rawItem = rawItemGetter(data, sourceHeaderCount, dimensions, dataIndex);
  20739. return retrieveValueFromItem(rawItem, dimIndex);
  20740. };
  20741. var retrieveValueFromItem = extSource.retrieveValueFromItem = function (dataItem, dimIndex) {
  20742. if (dataItem == null) {
  20743. return;
  20744. }
  20745. var dimDef = dimensions[dimIndex]; // When `dimIndex` is `null`, `rawValueGetter` return the whole item.
  20746. if (dimDef) {
  20747. return rawValueGetter(dataItem, dimIndex, dimDef.name);
  20748. }
  20749. };
  20750. extSource.getDimensionInfo = bind(getDimensionInfo, null, dimensions, dimsByName);
  20751. extSource.cloneAllDimensionInfo = bind(cloneAllDimensionInfo, null, dimensions);
  20752. return extSource;
  20753. }
  20754. function getRawData(upstream) {
  20755. var sourceFormat = upstream.sourceFormat;
  20756. if (!isSupportedSourceFormat(sourceFormat)) {
  20757. var errMsg = '';
  20758. {
  20759. errMsg = '`getRawData` is not supported in source format ' + sourceFormat;
  20760. }
  20761. throwError(errMsg);
  20762. }
  20763. return upstream.data;
  20764. }
  20765. function cloneRawData(upstream) {
  20766. var sourceFormat = upstream.sourceFormat;
  20767. var data = upstream.data;
  20768. if (!isSupportedSourceFormat(sourceFormat)) {
  20769. var errMsg = '';
  20770. {
  20771. errMsg = '`cloneRawData` is not supported in source format ' + sourceFormat;
  20772. }
  20773. throwError(errMsg);
  20774. }
  20775. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  20776. var result = [];
  20777. for (var i = 0, len = data.length; i < len; i++) {
  20778. // Not strictly clone for performance
  20779. result.push(data[i].slice());
  20780. }
  20781. return result;
  20782. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  20783. var result = [];
  20784. for (var i = 0, len = data.length; i < len; i++) {
  20785. // Not strictly clone for performance
  20786. result.push(extend({}, data[i]));
  20787. }
  20788. return result;
  20789. }
  20790. }
  20791. function getDimensionInfo(dimensions, dimsByName, dim) {
  20792. if (dim == null) {
  20793. return;
  20794. } // Keep the same logic as `List::getDimension` did.
  20795. if (typeof dim === 'number' // If being a number-like string but not being defined a dimension name.
  20796. || !isNaN(dim) && !hasOwn(dimsByName, dim)) {
  20797. return dimensions[dim];
  20798. } else if (hasOwn(dimsByName, dim)) {
  20799. return dimsByName[dim];
  20800. }
  20801. }
  20802. function cloneAllDimensionInfo(dimensions) {
  20803. return clone(dimensions);
  20804. }
  20805. var externalTransformMap = createHashMap();
  20806. function registerExternalTransform(externalTransform) {
  20807. externalTransform = clone(externalTransform);
  20808. var type = externalTransform.type;
  20809. var errMsg = '';
  20810. if (!type) {
  20811. {
  20812. errMsg = 'Must have a `type` when `registerTransform`.';
  20813. }
  20814. throwError(errMsg);
  20815. }
  20816. var typeParsed = type.split(':');
  20817. if (typeParsed.length !== 2) {
  20818. {
  20819. errMsg = 'Name must include namespace like "ns:regression".';
  20820. }
  20821. throwError(errMsg);
  20822. } // Namespace 'echarts:xxx' is official namespace, where the transforms should
  20823. // be called directly via 'xxx' rather than 'echarts:xxx'.
  20824. var isBuiltIn = false;
  20825. if (typeParsed[0] === 'echarts') {
  20826. type = typeParsed[1];
  20827. isBuiltIn = true;
  20828. }
  20829. externalTransform.__isBuiltIn = isBuiltIn;
  20830. externalTransformMap.set(type, externalTransform);
  20831. }
  20832. function applyDataTransform(rawTransOption, sourceList, infoForPrint) {
  20833. var pipedTransOption = normalizeToArray(rawTransOption);
  20834. var pipeLen = pipedTransOption.length;
  20835. var errMsg = '';
  20836. if (!pipeLen) {
  20837. {
  20838. errMsg = 'If `transform` declared, it should at least contain one transform.';
  20839. }
  20840. throwError(errMsg);
  20841. }
  20842. for (var i = 0, len = pipeLen; i < len; i++) {
  20843. var transOption = pipedTransOption[i];
  20844. sourceList = applySingleDataTransform(transOption, sourceList, infoForPrint, pipeLen === 1 ? null : i); // piped transform only support single input, except the fist one.
  20845. // piped transform only support single output, except the last one.
  20846. if (i !== len - 1) {
  20847. sourceList.length = Math.max(sourceList.length, 1);
  20848. }
  20849. }
  20850. return sourceList;
  20851. }
  20852. function applySingleDataTransform(transOption, upSourceList, infoForPrint, // If `pipeIndex` is null/undefined, no piped transform.
  20853. pipeIndex) {
  20854. var errMsg = '';
  20855. if (!upSourceList.length) {
  20856. {
  20857. errMsg = 'Must have at least one upstream dataset.';
  20858. }
  20859. throwError(errMsg);
  20860. }
  20861. if (!isObject$1(transOption)) {
  20862. {
  20863. errMsg = 'transform declaration must be an object rather than ' + typeof transOption + '.';
  20864. }
  20865. throwError(errMsg);
  20866. }
  20867. var transType = transOption.type;
  20868. var externalTransform = externalTransformMap.get(transType);
  20869. if (!externalTransform) {
  20870. {
  20871. errMsg = 'Can not find transform on type "' + transType + '".';
  20872. }
  20873. throwError(errMsg);
  20874. } // Prepare source
  20875. var extUpSourceList = map(upSourceList, function (upSource) {
  20876. return createExternalSource(upSource, externalTransform);
  20877. });
  20878. var resultList = normalizeToArray(externalTransform.transform({
  20879. upstream: extUpSourceList[0],
  20880. upstreamList: extUpSourceList,
  20881. config: clone(transOption.config)
  20882. }));
  20883. {
  20884. if (transOption.print) {
  20885. var printStrArr = map(resultList, function (extSource) {
  20886. var pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : '';
  20887. return ['=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===', '- transform result data:', makePrintable(extSource.data), '- transform result dimensions:', makePrintable(extSource.dimensions)].join('\n');
  20888. }).join('\n');
  20889. consoleLog(printStrArr);
  20890. }
  20891. }
  20892. return map(resultList, function (result, resultIndex) {
  20893. var errMsg = '';
  20894. if (!isObject$1(result)) {
  20895. {
  20896. errMsg = 'A transform should not return some empty results.';
  20897. }
  20898. throwError(errMsg);
  20899. }
  20900. if (!result.data) {
  20901. {
  20902. errMsg = 'Transform result data should be not be null or undefined';
  20903. }
  20904. throwError(errMsg);
  20905. }
  20906. var sourceFormat = detectSourceFormat(result.data);
  20907. if (!isSupportedSourceFormat(sourceFormat)) {
  20908. {
  20909. errMsg = 'Transform result data should be array rows or object rows.';
  20910. }
  20911. throwError(errMsg);
  20912. }
  20913. var resultMetaRawOption;
  20914. var firstUpSource = upSourceList[0];
  20915. /**
  20916. * Intuitively, the end users known the content of the original `dataset.source`,
  20917. * calucating the transform result in mind.
  20918. * Suppose the original `dataset.source` is:
  20919. * ```js
  20920. * [
  20921. * ['product', '2012', '2013', '2014', '2015'],
  20922. * ['AAA', 41.1, 30.4, 65.1, 53.3],
  20923. * ['BBB', 86.5, 92.1, 85.7, 83.1],
  20924. * ['CCC', 24.1, 67.2, 79.5, 86.4]
  20925. * ]
  20926. * ```
  20927. * The dimension info have to be detected from the source data.
  20928. * Some of the transformers (like filter, sort) will follow the dimension info
  20929. * of upstream, while others use new dimensions (like aggregate).
  20930. * Transformer can output a field `dimensions` to define the its own output dimensions.
  20931. * We also allow transformers to ignore the output `dimensions` field, and
  20932. * inherit the upstream dimensions definition. It can reduce the burden of handling
  20933. * dimensions in transformers.
  20934. *
  20935. * See also [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.
  20936. */
  20937. if (firstUpSource && resultIndex === 0 // If transformer returns `dimensions`, it means that the transformer has different
  20938. // dimensions definitions. We do not inherit anything from upstream.
  20939. && !result.dimensions) {
  20940. var startIndex = firstUpSource.startIndex; // We copy the header of upstream to the result becuase:
  20941. // (1) The returned data always does not contain header line and can not be used
  20942. // as dimension-detection. In this case we can not use "detected dimensions" of
  20943. // upstream directly, because it might be detected based on different `seriesLayoutBy`.
  20944. // (2) We should support that the series read the upstream source in `seriesLayoutBy: 'row'`.
  20945. // So the original detected header should be add to the result, otherwise they can not be read.
  20946. if (startIndex) {
  20947. result.data = firstUpSource.data.slice(0, startIndex).concat(result.data);
  20948. }
  20949. resultMetaRawOption = {
  20950. seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,
  20951. sourceHeader: startIndex,
  20952. dimensions: firstUpSource.metaRawOption.dimensions
  20953. };
  20954. } else {
  20955. resultMetaRawOption = {
  20956. seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,
  20957. sourceHeader: 0,
  20958. dimensions: result.dimensions
  20959. };
  20960. }
  20961. return createSource(result.data, resultMetaRawOption, null, null);
  20962. });
  20963. }
  20964. function isSupportedSourceFormat(sourceFormat) {
  20965. return sourceFormat === SOURCE_FORMAT_ARRAY_ROWS || sourceFormat === SOURCE_FORMAT_OBJECT_ROWS;
  20966. }
  20967. /*
  20968. * Licensed to the Apache Software Foundation (ASF) under one
  20969. * or more contributor license agreements. See the NOTICE file
  20970. * distributed with this work for additional information
  20971. * regarding copyright ownership. The ASF licenses this file
  20972. * to you under the Apache License, Version 2.0 (the
  20973. * "License"); you may not use this file except in compliance
  20974. * with the License. You may obtain a copy of the License at
  20975. *
  20976. * http://www.apache.org/licenses/LICENSE-2.0
  20977. *
  20978. * Unless required by applicable law or agreed to in writing,
  20979. * software distributed under the License is distributed on an
  20980. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  20981. * KIND, either express or implied. See the License for the
  20982. * specific language governing permissions and limitations
  20983. * under the License.
  20984. */
  20985. /**
  20986. * AUTO-GENERATED FILE. DO NOT MODIFY.
  20987. */
  20988. /*
  20989. * Licensed to the Apache Software Foundation (ASF) under one
  20990. * or more contributor license agreements. See the NOTICE file
  20991. * distributed with this work for additional information
  20992. * regarding copyright ownership. The ASF licenses this file
  20993. * to you under the Apache License, Version 2.0 (the
  20994. * "License"); you may not use this file except in compliance
  20995. * with the License. You may obtain a copy of the License at
  20996. *
  20997. * http://www.apache.org/licenses/LICENSE-2.0
  20998. *
  20999. * Unless required by applicable law or agreed to in writing,
  21000. * software distributed under the License is distributed on an
  21001. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21002. * KIND, either express or implied. See the License for the
  21003. * specific language governing permissions and limitations
  21004. * under the License.
  21005. */
  21006. /**
  21007. * [REQUIREMENT_MEMO]:
  21008. * (0) `metaRawOption` means `dimensions`/`sourceHeader`/`seriesLayoutBy` in raw option.
  21009. * (1) Keep support the feature: `metaRawOption` can be specified both on `series` and
  21010. * `root-dataset`. Them on `series` has higher priority.
  21011. * (2) Do not support to set `metaRawOption` on a `non-root-dataset`, because it might
  21012. * confuse users: whether those props indicate how to visit the upstream source or visit
  21013. * the transform result source, and some transforms has nothing to do with these props,
  21014. * and some transforms might have multiple upstream.
  21015. * (3) Transforms should specify `metaRawOption` in each output, just like they can be
  21016. * declared in `root-dataset`.
  21017. * (4) At present only support visit source in `SERIES_LAYOUT_BY_COLUMN` in transforms.
  21018. * That is for reducing complexity in transfroms.
  21019. * PENDING: Whether to provide transposition transform?
  21020. *
  21021. * [IMPLEMENTAION_MEMO]:
  21022. * "sourceVisitConfig" are calculated from `metaRawOption` and `data`.
  21023. * They will not be calculated until `source` is about to be visited (to prevent from
  21024. * duplicate calcuation). `source` is visited only in series and input to transforms.
  21025. *
  21026. * [DIMENSION_INHERIT_RULE]:
  21027. * By default the dimensions are inherited from ancestors, unless a transform return
  21028. * a new dimensions definition.
  21029. * Consider the case:
  21030. * ```js
  21031. * dataset: [{
  21032. * source: [ ['Product', 'Sales', 'Prise'], ['Cookies', 321, 44.21], ...]
  21033. * }, {
  21034. * transform: { type: 'filter', ... }
  21035. * }]
  21036. * dataset: [{
  21037. * dimension: ['Product', 'Sales', 'Prise'],
  21038. * source: [ ['Cookies', 321, 44.21], ...]
  21039. * }, {
  21040. * transform: { type: 'filter', ... }
  21041. * }]
  21042. * ```
  21043. * The two types of option should have the same behavior after transform.
  21044. *
  21045. *
  21046. * [SCENARIO]:
  21047. * (1) Provide source data directly:
  21048. * ```js
  21049. * series: {
  21050. * encode: {...},
  21051. * dimensions: [...]
  21052. * seriesLayoutBy: 'row',
  21053. * data: [[...]]
  21054. * }
  21055. * ```
  21056. * (2) Series refer to dataset.
  21057. * ```js
  21058. * series: [{
  21059. * encode: {...}
  21060. * // Ignore datasetIndex means `datasetIndex: 0`
  21061. * // and the dimensions defination in dataset is used
  21062. * }, {
  21063. * encode: {...},
  21064. * seriesLayoutBy: 'column',
  21065. * datasetIndex: 1
  21066. * }]
  21067. * ```
  21068. * (3) dataset transform
  21069. * ```js
  21070. * dataset: [{
  21071. * source: [...]
  21072. * }, {
  21073. * source: [...]
  21074. * }, {
  21075. * // By default from 0.
  21076. * transform: { type: 'filter', config: {...} }
  21077. * }, {
  21078. * // Piped.
  21079. * transform: [
  21080. * { type: 'filter', config: {...} },
  21081. * { type: 'sort', config: {...} }
  21082. * ]
  21083. * }, {
  21084. * id: 'regressionData',
  21085. * fromDatasetIndex: 1,
  21086. * // Third-party transform
  21087. * transform: { type: 'ecStat:regression', config: {...} }
  21088. * }, {
  21089. * // retrieve the extra result.
  21090. * id: 'regressionFormula',
  21091. * fromDatasetId: 'regressionData',
  21092. * fromTransformResult: 1
  21093. * }]
  21094. * ```
  21095. */
  21096. var SourceManager =
  21097. /** @class */
  21098. function () {
  21099. function SourceManager(sourceHost) {
  21100. // Cached source. Do not repeat calculating if not dirty.
  21101. this._sourceList = []; // version sign of each upstream source manager.
  21102. this._upstreamSignList = [];
  21103. this._versionSignBase = 0;
  21104. this._sourceHost = sourceHost;
  21105. }
  21106. /**
  21107. * Mark dirty.
  21108. */
  21109. SourceManager.prototype.dirty = function () {
  21110. this._setLocalSource([], []);
  21111. };
  21112. SourceManager.prototype._setLocalSource = function (sourceList, upstreamSignList) {
  21113. this._sourceList = sourceList;
  21114. this._upstreamSignList = upstreamSignList;
  21115. this._versionSignBase++;
  21116. if (this._versionSignBase > 9e10) {
  21117. this._versionSignBase = 0;
  21118. }
  21119. };
  21120. /**
  21121. * For detecting whether the upstream source is dirty, so that
  21122. * the local cached source (in `_sourceList`) should be discarded.
  21123. */
  21124. SourceManager.prototype._getVersionSign = function () {
  21125. return this._sourceHost.uid + '_' + this._versionSignBase;
  21126. };
  21127. /**
  21128. * Always return a source instance. Otherwise throw error.
  21129. */
  21130. SourceManager.prototype.prepareSource = function () {
  21131. // For the case that call `setOption` multiple time but no data changed,
  21132. // cache the result source to prevent from repeating transform.
  21133. if (this._isDirty()) {
  21134. this._createSource();
  21135. }
  21136. };
  21137. SourceManager.prototype._createSource = function () {
  21138. this._setLocalSource([], []);
  21139. var sourceHost = this._sourceHost;
  21140. var upSourceMgrList = this._getUpstreamSourceManagers();
  21141. var hasUpstream = !!upSourceMgrList.length;
  21142. var resultSourceList;
  21143. var upstreamSignList;
  21144. if (isSeries(sourceHost)) {
  21145. var seriesModel = sourceHost;
  21146. var data = void 0;
  21147. var sourceFormat = void 0;
  21148. var upSource = void 0; // Has upstream dataset
  21149. if (hasUpstream) {
  21150. var upSourceMgr = upSourceMgrList[0];
  21151. upSourceMgr.prepareSource();
  21152. upSource = upSourceMgr.getSource();
  21153. data = upSource.data;
  21154. sourceFormat = upSource.sourceFormat;
  21155. upstreamSignList = [upSourceMgr._getVersionSign()];
  21156. } // Series data is from own.
  21157. else {
  21158. data = seriesModel.get('data', true);
  21159. sourceFormat = isTypedArray(data) ? SOURCE_FORMAT_TYPED_ARRAY : SOURCE_FORMAT_ORIGINAL;
  21160. upstreamSignList = [];
  21161. } // See [REQUIREMENT_MEMO], merge settings on series and parent dataset if it is root.
  21162. var newMetaRawOption = this._getSourceMetaRawOption();
  21163. var upMetaRawOption = upSource ? upSource.metaRawOption : null;
  21164. var seriesLayoutBy = retrieve2(newMetaRawOption.seriesLayoutBy, upMetaRawOption ? upMetaRawOption.seriesLayoutBy : null);
  21165. var sourceHeader = retrieve2(newMetaRawOption.sourceHeader, upMetaRawOption ? upMetaRawOption.sourceHeader : null); // Note here we should not use `upSource.dimensionsDefine`. Consider the case:
  21166. // `upSource.dimensionsDefine` is detected by `seriesLayoutBy: 'column'`,
  21167. // but series need `seriesLayoutBy: 'row'`.
  21168. var dimensions = retrieve2(newMetaRawOption.dimensions, upMetaRawOption ? upMetaRawOption.dimensions : null);
  21169. resultSourceList = [createSource(data, {
  21170. seriesLayoutBy: seriesLayoutBy,
  21171. sourceHeader: sourceHeader,
  21172. dimensions: dimensions
  21173. }, sourceFormat, seriesModel.get('encode', true))];
  21174. } else {
  21175. var datasetModel = sourceHost; // Has upstream dataset.
  21176. if (hasUpstream) {
  21177. var result = this._applyTransform(upSourceMgrList);
  21178. resultSourceList = result.sourceList;
  21179. upstreamSignList = result.upstreamSignList;
  21180. } // Is root dataset.
  21181. else {
  21182. var sourceData = datasetModel.get('source', true);
  21183. resultSourceList = [createSource(sourceData, this._getSourceMetaRawOption(), null, // Note: dataset option does not have `encode`.
  21184. null)];
  21185. upstreamSignList = [];
  21186. }
  21187. }
  21188. {
  21189. assert$1(resultSourceList && upstreamSignList);
  21190. }
  21191. this._setLocalSource(resultSourceList, upstreamSignList);
  21192. };
  21193. SourceManager.prototype._applyTransform = function (upMgrList) {
  21194. var datasetModel = this._sourceHost;
  21195. var transformOption = datasetModel.get('transform', true);
  21196. var fromTransformResult = datasetModel.get('fromTransformResult', true);
  21197. {
  21198. assert$1(fromTransformResult != null || transformOption != null);
  21199. }
  21200. if (fromTransformResult != null) {
  21201. var errMsg = '';
  21202. if (upMgrList.length !== 1) {
  21203. {
  21204. errMsg = 'When using `fromTransformResult`, there should be only one upstream dataset';
  21205. }
  21206. doThrow(errMsg);
  21207. }
  21208. }
  21209. var sourceList;
  21210. var upSourceList = [];
  21211. var upstreamSignList = [];
  21212. each$1(upMgrList, function (upMgr) {
  21213. upMgr.prepareSource();
  21214. var upSource = upMgr.getSource(fromTransformResult || 0);
  21215. var errMsg = '';
  21216. if (fromTransformResult != null && !upSource) {
  21217. {
  21218. errMsg = 'Can not retrieve result by `fromTransformResult`: ' + fromTransformResult;
  21219. }
  21220. doThrow(errMsg);
  21221. }
  21222. upSourceList.push(upSource);
  21223. upstreamSignList.push(upMgr._getVersionSign());
  21224. });
  21225. if (transformOption) {
  21226. sourceList = applyDataTransform(transformOption, upSourceList, {
  21227. datasetIndex: datasetModel.componentIndex
  21228. });
  21229. } else if (fromTransformResult != null) {
  21230. sourceList = [cloneSourceShallow(upSourceList[0])];
  21231. }
  21232. return {
  21233. sourceList: sourceList,
  21234. upstreamSignList: upstreamSignList
  21235. };
  21236. };
  21237. SourceManager.prototype._isDirty = function () {
  21238. var sourceList = this._sourceList;
  21239. if (!sourceList.length) {
  21240. return true;
  21241. } // All sourceList is from the some upsteam.
  21242. var upSourceMgrList = this._getUpstreamSourceManagers();
  21243. for (var i = 0; i < upSourceMgrList.length; i++) {
  21244. var upSrcMgr = upSourceMgrList[i];
  21245. if ( // Consider the case that there is ancestor diry, call it recursively.
  21246. // The performance is probably not an issue because usually the chain is not long.
  21247. upSrcMgr._isDirty() || this._upstreamSignList[i] !== upSrcMgr._getVersionSign()) {
  21248. return true;
  21249. }
  21250. }
  21251. };
  21252. /**
  21253. * @param sourceIndex By defualt 0, means "main source".
  21254. * Most cases there is only one source.
  21255. */
  21256. SourceManager.prototype.getSource = function (sourceIndex) {
  21257. return this._sourceList[sourceIndex || 0];
  21258. };
  21259. /**
  21260. * PEDING: Is it fast enough?
  21261. * If no upstream, return empty array.
  21262. */
  21263. SourceManager.prototype._getUpstreamSourceManagers = function () {
  21264. // Always get the relationship from the raw option.
  21265. // Do not cache the link of the dependency graph, so that
  21266. // no need to update them when change happen.
  21267. var sourceHost = this._sourceHost;
  21268. if (isSeries(sourceHost)) {
  21269. var datasetModel = querySeriesUpstreamDatasetModel(sourceHost);
  21270. return !datasetModel ? [] : [datasetModel.getSourceManager()];
  21271. } else {
  21272. return map(queryDatasetUpstreamDatasetModels(sourceHost), function (datasetModel) {
  21273. return datasetModel.getSourceManager();
  21274. });
  21275. }
  21276. };
  21277. SourceManager.prototype._getSourceMetaRawOption = function () {
  21278. var sourceHost = this._sourceHost;
  21279. var seriesLayoutBy;
  21280. var sourceHeader;
  21281. var dimensions;
  21282. if (isSeries(sourceHost)) {
  21283. seriesLayoutBy = sourceHost.get('seriesLayoutBy', true);
  21284. sourceHeader = sourceHost.get('sourceHeader', true);
  21285. dimensions = sourceHost.get('dimensions', true);
  21286. } // See [REQUIREMENT_MEMO], `non-root-dataset` do not support them.
  21287. else if (!this._getUpstreamSourceManagers().length) {
  21288. var model = sourceHost;
  21289. seriesLayoutBy = model.get('seriesLayoutBy', true);
  21290. sourceHeader = model.get('sourceHeader', true);
  21291. dimensions = model.get('dimensions', true);
  21292. }
  21293. return {
  21294. seriesLayoutBy: seriesLayoutBy,
  21295. sourceHeader: sourceHeader,
  21296. dimensions: dimensions
  21297. };
  21298. };
  21299. return SourceManager;
  21300. }(); // disable the transform merge, but do not disable transfrom clone from rawOption.
  21301. function disableTransformOptionMerge(datasetModel) {
  21302. var transformOption = datasetModel.option.transform;
  21303. transformOption && setAsPrimitive(datasetModel.option.transform);
  21304. }
  21305. function isSeries(sourceHost) {
  21306. // Avoid circular dependency with Series.ts
  21307. return sourceHost.mainType === 'series';
  21308. }
  21309. function doThrow(errMsg) {
  21310. throw new Error(errMsg);
  21311. }
  21312. /*
  21313. * Licensed to the Apache Software Foundation (ASF) under one
  21314. * or more contributor license agreements. See the NOTICE file
  21315. * distributed with this work for additional information
  21316. * regarding copyright ownership. The ASF licenses this file
  21317. * to you under the Apache License, Version 2.0 (the
  21318. * "License"); you may not use this file except in compliance
  21319. * with the License. You may obtain a copy of the License at
  21320. *
  21321. * http://www.apache.org/licenses/LICENSE-2.0
  21322. *
  21323. * Unless required by applicable law or agreed to in writing,
  21324. * software distributed under the License is distributed on an
  21325. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21326. * KIND, either express or implied. See the License for the
  21327. * specific language governing permissions and limitations
  21328. * under the License.
  21329. */
  21330. /**
  21331. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21332. */
  21333. /*
  21334. * Licensed to the Apache Software Foundation (ASF) under one
  21335. * or more contributor license agreements. See the NOTICE file
  21336. * distributed with this work for additional information
  21337. * regarding copyright ownership. The ASF licenses this file
  21338. * to you under the Apache License, Version 2.0 (the
  21339. * "License"); you may not use this file except in compliance
  21340. * with the License. You may obtain a copy of the License at
  21341. *
  21342. * http://www.apache.org/licenses/LICENSE-2.0
  21343. *
  21344. * Unless required by applicable law or agreed to in writing,
  21345. * software distributed under the License is distributed on an
  21346. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21347. * KIND, either express or implied. See the License for the
  21348. * specific language governing permissions and limitations
  21349. * under the License.
  21350. */
  21351. var TOOLTIP_LINE_HEIGHT_CSS = 'line-height:1'; // TODO: more textStyle option
  21352. function getTooltipTextStyle(textStyle, renderMode) {
  21353. var nameFontColor = textStyle.color || '#6e7079';
  21354. var nameFontSize = textStyle.fontSize || 12;
  21355. var nameFontWeight = textStyle.fontWeight || '400';
  21356. var valueFontColor = textStyle.color || '#464646';
  21357. var valueFontSize = textStyle.fontSize || 14;
  21358. var valueFontWeight = textStyle.fontWeight || '900';
  21359. if (renderMode === 'html') {
  21360. // `textStyle` is probably from user input, should be encoded to reduce security risk.
  21361. return {
  21362. // eslint-disable-next-line max-len
  21363. nameStyle: "font-size:" + encodeHTML(nameFontSize + '') + "px;color:" + encodeHTML(nameFontColor) + ";font-weight:" + encodeHTML(nameFontWeight + ''),
  21364. // eslint-disable-next-line max-len
  21365. valueStyle: "font-size:" + encodeHTML(valueFontSize + '') + "px;color:" + encodeHTML(valueFontColor) + ";font-weight:" + encodeHTML(valueFontWeight + '')
  21366. };
  21367. } else {
  21368. return {
  21369. nameStyle: {
  21370. fontSize: nameFontSize,
  21371. fill: nameFontColor,
  21372. fontWeight: nameFontWeight
  21373. },
  21374. valueStyle: {
  21375. fontSize: valueFontSize,
  21376. fill: valueFontColor,
  21377. fontWeight: valueFontWeight
  21378. }
  21379. };
  21380. }
  21381. } // See `TooltipMarkupLayoutIntent['innerGapLevel']`.
  21382. // (value from UI design)
  21383. var HTML_GAPS = [0, 10, 20, 30];
  21384. var RICH_TEXT_GAPS = ['', '\n', '\n\n', '\n\n\n']; // eslint-disable-next-line max-len
  21385. function createTooltipMarkup(type, option) {
  21386. option.type = type;
  21387. return option;
  21388. }
  21389. function getBuilder(fragment) {
  21390. return hasOwn(builderMap, fragment.type) && builderMap[fragment.type];
  21391. }
  21392. var builderMap = {
  21393. /**
  21394. * A `section` block is like:
  21395. * ```
  21396. * header
  21397. * subBlock
  21398. * subBlock
  21399. * ...
  21400. * ```
  21401. */
  21402. section: {
  21403. planLayout: function (fragment) {
  21404. var subBlockLen = fragment.blocks.length;
  21405. var thisBlockHasInnerGap = subBlockLen > 1 || subBlockLen > 0 && !fragment.noHeader;
  21406. var thisGapLevelBetweenSubBlocks = 0;
  21407. each$1(fragment.blocks, function (subBlock) {
  21408. getBuilder(subBlock).planLayout(subBlock);
  21409. var subGapLevel = subBlock.__gapLevelBetweenSubBlocks; // If the some of the sub-blocks have some gaps (like 10px) inside, this block
  21410. // should use a larger gap (like 20px) to distinguish those sub-blocks.
  21411. if (subGapLevel >= thisGapLevelBetweenSubBlocks) {
  21412. thisGapLevelBetweenSubBlocks = subGapLevel + (thisBlockHasInnerGap && ( // 0 always can not be readable gap level.
  21413. !subGapLevel // If no header, always keep the sub gap level. Otherwise
  21414. // look weird in case `multipleSeries`.
  21415. || subBlock.type === 'section' && !subBlock.noHeader) ? 1 : 0);
  21416. }
  21417. });
  21418. fragment.__gapLevelBetweenSubBlocks = thisGapLevelBetweenSubBlocks;
  21419. },
  21420. build: function (ctx, fragment, topMarginForOuterGap, toolTipTextStyle) {
  21421. var noHeader = fragment.noHeader;
  21422. var gaps = getGap(fragment);
  21423. var subMarkupText = buildSubBlocks(ctx, fragment, noHeader ? topMarginForOuterGap : gaps.html, toolTipTextStyle);
  21424. if (noHeader) {
  21425. return subMarkupText;
  21426. }
  21427. var displayableHeader = makeValueReadable(fragment.header, 'ordinal', ctx.useUTC);
  21428. var nameStyle = getTooltipTextStyle(toolTipTextStyle, ctx.renderMode).nameStyle;
  21429. if (ctx.renderMode === 'richText') {
  21430. return wrapInlineNameRichText(ctx, displayableHeader, nameStyle) + gaps.richText + subMarkupText;
  21431. } else {
  21432. return wrapBlockHTML("<div style=\"" + nameStyle + ";" + TOOLTIP_LINE_HEIGHT_CSS + ";\">" + encodeHTML(displayableHeader) + '</div>' + subMarkupText, topMarginForOuterGap);
  21433. }
  21434. }
  21435. },
  21436. /**
  21437. * A `nameValue` block is like:
  21438. * ```
  21439. * marker name value
  21440. * ```
  21441. */
  21442. nameValue: {
  21443. planLayout: function (fragment) {
  21444. fragment.__gapLevelBetweenSubBlocks = 0;
  21445. },
  21446. build: function (ctx, fragment, topMarginForOuterGap, toolTipTextStyle) {
  21447. var renderMode = ctx.renderMode;
  21448. var noName = fragment.noName;
  21449. var noValue = fragment.noValue;
  21450. var noMarker = !fragment.markerType;
  21451. var name = fragment.name;
  21452. var value = fragment.value;
  21453. var useUTC = ctx.useUTC;
  21454. if (noName && noValue) {
  21455. return;
  21456. }
  21457. var markerStr = noMarker ? '' : ctx.markupStyleCreator.makeTooltipMarker(fragment.markerType, fragment.markerColor || '#333', renderMode);
  21458. var readableName = noName ? '' : makeValueReadable(name, 'ordinal', useUTC);
  21459. var valueTypeOption = fragment.valueType;
  21460. var readableValueList = noValue ? [] : isArray(value) ? map(value, function (val, idx) {
  21461. return makeValueReadable(val, isArray(valueTypeOption) ? valueTypeOption[idx] : valueTypeOption, useUTC);
  21462. }) : [makeValueReadable(value, isArray(valueTypeOption) ? valueTypeOption[0] : valueTypeOption, useUTC)];
  21463. var valueAlignRight = !noMarker || !noName; // It little weird if only value next to marker but far from marker.
  21464. var valueCloseToMarker = !noMarker && noName;
  21465. var _a = getTooltipTextStyle(toolTipTextStyle, renderMode),
  21466. nameStyle = _a.nameStyle,
  21467. valueStyle = _a.valueStyle;
  21468. return renderMode === 'richText' ? (noMarker ? '' : markerStr) + (noName ? '' : wrapInlineNameRichText(ctx, readableName, nameStyle)) // Value has commas inside, so use ' ' as delimiter for multiple values.
  21469. + (noValue ? '' : wrapInlineValueRichText(ctx, readableValueList, valueAlignRight, valueCloseToMarker, valueStyle)) : wrapBlockHTML((noMarker ? '' : markerStr) + (noName ? '' : wrapInlineNameHTML(readableName, !noMarker, nameStyle)) + (noValue ? '' : wrapInlineValueHTML(readableValueList, valueAlignRight, valueCloseToMarker, valueStyle)), topMarginForOuterGap);
  21470. }
  21471. }
  21472. };
  21473. function buildSubBlocks(ctx, fragment, topMarginForOuterGap, tooltipTextStyle) {
  21474. var subMarkupTextList = [];
  21475. var subBlocks = fragment.blocks || [];
  21476. assert$1(!subBlocks || isArray(subBlocks));
  21477. subBlocks = subBlocks || [];
  21478. var orderMode = ctx.orderMode;
  21479. if (fragment.sortBlocks && orderMode) {
  21480. subBlocks = subBlocks.slice();
  21481. var orderMap = {
  21482. valueAsc: 'asc',
  21483. valueDesc: 'desc'
  21484. };
  21485. if (hasOwn(orderMap, orderMode)) {
  21486. var comparator_1 = new SortOrderComparator(orderMap[orderMode], null);
  21487. subBlocks.sort(function (a, b) {
  21488. return comparator_1.evaluate(a.sortParam, b.sortParam);
  21489. });
  21490. } // FIXME 'seriesDesc' necessary?
  21491. else if (orderMode === 'seriesDesc') {
  21492. subBlocks.reverse();
  21493. }
  21494. }
  21495. var gaps = getGap(fragment);
  21496. each$1(subBlocks, function (subBlock, idx) {
  21497. var subMarkupText = getBuilder(subBlock).build(ctx, subBlock, idx > 0 ? gaps.html : 0, tooltipTextStyle);
  21498. subMarkupText != null && subMarkupTextList.push(subMarkupText);
  21499. });
  21500. if (!subMarkupTextList.length) {
  21501. return;
  21502. }
  21503. return ctx.renderMode === 'richText' ? subMarkupTextList.join(gaps.richText) : wrapBlockHTML(subMarkupTextList.join(''), topMarginForOuterGap);
  21504. }
  21505. /**
  21506. * @return markupText. null/undefined means no content.
  21507. */
  21508. function buildTooltipMarkup(fragment, markupStyleCreator, renderMode, orderMode, useUTC, toolTipTextStyle) {
  21509. if (!fragment) {
  21510. return;
  21511. }
  21512. var builder = getBuilder(fragment);
  21513. builder.planLayout(fragment);
  21514. var ctx = {
  21515. useUTC: useUTC,
  21516. renderMode: renderMode,
  21517. orderMode: orderMode,
  21518. markupStyleCreator: markupStyleCreator
  21519. };
  21520. return builder.build(ctx, fragment, 0, toolTipTextStyle);
  21521. }
  21522. function getGap(fragment) {
  21523. var gapLevelBetweenSubBlocks = fragment.__gapLevelBetweenSubBlocks;
  21524. return {
  21525. html: HTML_GAPS[gapLevelBetweenSubBlocks],
  21526. richText: RICH_TEXT_GAPS[gapLevelBetweenSubBlocks]
  21527. };
  21528. }
  21529. function wrapBlockHTML(encodedContent, topGap) {
  21530. var clearfix = '<div style="clear:both"></div>';
  21531. var marginCSS = "margin: " + topGap + "px 0 0";
  21532. return "<div style=\"" + marginCSS + ";" + TOOLTIP_LINE_HEIGHT_CSS + ";\">" + encodedContent + clearfix + '</div>';
  21533. }
  21534. function wrapInlineNameHTML(name, leftHasMarker, style) {
  21535. var marginCss = leftHasMarker ? 'margin-left:2px' : '';
  21536. return "<span style=\"" + style + ";" + marginCss + "\">" + encodeHTML(name) + '</span>';
  21537. }
  21538. function wrapInlineValueHTML(valueList, alignRight, valueCloseToMarker, style) {
  21539. // Do not too close to marker, considering there are multiple values separated by spaces.
  21540. var paddingStr = valueCloseToMarker ? '10px' : '20px';
  21541. var alignCSS = alignRight ? "float:right;margin-left:" + paddingStr : '';
  21542. return "<span style=\"" + alignCSS + ";" + style + "\">" // Value has commas inside, so use ' ' as delimiter for multiple values.
  21543. + map(valueList, function (value) {
  21544. return encodeHTML(value);
  21545. }).join('&nbsp;&nbsp;') + '</span>';
  21546. }
  21547. function wrapInlineNameRichText(ctx, name, style) {
  21548. return ctx.markupStyleCreator.wrapRichTextStyle(name, style);
  21549. }
  21550. function wrapInlineValueRichText(ctx, valueList, alignRight, valueCloseToMarker, style) {
  21551. var styles = [style];
  21552. var paddingLeft = valueCloseToMarker ? 10 : 20;
  21553. alignRight && styles.push({
  21554. padding: [0, 0, 0, paddingLeft],
  21555. align: 'right'
  21556. }); // Value has commas inside, so use ' ' as delimiter for multiple values.
  21557. return ctx.markupStyleCreator.wrapRichTextStyle(valueList.join(' '), styles);
  21558. }
  21559. function retrieveVisualColorForTooltipMarker(series, dataIndex) {
  21560. var style = series.getData().getItemVisual(dataIndex, 'style');
  21561. var color = style[series.visualDrawType];
  21562. return convertToColorString(color);
  21563. }
  21564. function getPaddingFromTooltipModel(model, renderMode) {
  21565. var padding = model.get('padding');
  21566. return padding != null ? padding // We give slightly different to look pretty.
  21567. : renderMode === 'richText' ? [8, 10] : 10;
  21568. }
  21569. /**
  21570. * The major feature is generate styles for `renderMode: 'richText'`.
  21571. * But it also serves `renderMode: 'html'` to provide
  21572. * "renderMode-independent" API.
  21573. */
  21574. var TooltipMarkupStyleCreator =
  21575. /** @class */
  21576. function () {
  21577. function TooltipMarkupStyleCreator() {
  21578. this.richTextStyles = {}; // Notice that "generate a style name" usuall happens repeatly when mouse moving and
  21579. // displaying a tooltip. So we put the `_nextStyleNameId` as a member of each creator
  21580. // rather than static shared by all creators (which will cause it increase to fast).
  21581. this._nextStyleNameId = getRandomIdBase();
  21582. }
  21583. TooltipMarkupStyleCreator.prototype._generateStyleName = function () {
  21584. return '__EC_aUTo_' + this._nextStyleNameId++;
  21585. };
  21586. TooltipMarkupStyleCreator.prototype.makeTooltipMarker = function (markerType, colorStr, renderMode) {
  21587. var markerId = renderMode === 'richText' ? this._generateStyleName() : null;
  21588. var marker = getTooltipMarker({
  21589. color: colorStr,
  21590. type: markerType,
  21591. renderMode: renderMode,
  21592. markerId: markerId
  21593. });
  21594. if (isString(marker)) {
  21595. return marker;
  21596. } else {
  21597. {
  21598. assert$1(markerId);
  21599. }
  21600. this.richTextStyles[markerId] = marker.style;
  21601. return marker.content;
  21602. }
  21603. };
  21604. /**
  21605. * @usage
  21606. * ```ts
  21607. * const styledText = markupStyleCreator.wrapRichTextStyle([
  21608. * // The styles will be auto merged.
  21609. * {
  21610. * fontSize: 12,
  21611. * color: 'blue'
  21612. * },
  21613. * {
  21614. * padding: 20
  21615. * }
  21616. * ]);
  21617. * ```
  21618. */
  21619. TooltipMarkupStyleCreator.prototype.wrapRichTextStyle = function (text, styles) {
  21620. var finalStl = {};
  21621. if (isArray(styles)) {
  21622. each$1(styles, function (stl) {
  21623. return extend(finalStl, stl);
  21624. });
  21625. } else {
  21626. extend(finalStl, styles);
  21627. }
  21628. var styleName = this._generateStyleName();
  21629. this.richTextStyles[styleName] = finalStl;
  21630. return "{" + styleName + "|" + text + "}";
  21631. };
  21632. return TooltipMarkupStyleCreator;
  21633. }();
  21634. /*
  21635. * Licensed to the Apache Software Foundation (ASF) under one
  21636. * or more contributor license agreements. See the NOTICE file
  21637. * distributed with this work for additional information
  21638. * regarding copyright ownership. The ASF licenses this file
  21639. * to you under the Apache License, Version 2.0 (the
  21640. * "License"); you may not use this file except in compliance
  21641. * with the License. You may obtain a copy of the License at
  21642. *
  21643. * http://www.apache.org/licenses/LICENSE-2.0
  21644. *
  21645. * Unless required by applicable law or agreed to in writing,
  21646. * software distributed under the License is distributed on an
  21647. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21648. * KIND, either express or implied. See the License for the
  21649. * specific language governing permissions and limitations
  21650. * under the License.
  21651. */
  21652. /**
  21653. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21654. */
  21655. /*
  21656. * Licensed to the Apache Software Foundation (ASF) under one
  21657. * or more contributor license agreements. See the NOTICE file
  21658. * distributed with this work for additional information
  21659. * regarding copyright ownership. The ASF licenses this file
  21660. * to you under the Apache License, Version 2.0 (the
  21661. * "License"); you may not use this file except in compliance
  21662. * with the License. You may obtain a copy of the License at
  21663. *
  21664. * http://www.apache.org/licenses/LICENSE-2.0
  21665. *
  21666. * Unless required by applicable law or agreed to in writing,
  21667. * software distributed under the License is distributed on an
  21668. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21669. * KIND, either express or implied. See the License for the
  21670. * specific language governing permissions and limitations
  21671. * under the License.
  21672. */
  21673. function defaultSeriesFormatTooltip(opt) {
  21674. var series = opt.series;
  21675. var dataIndex = opt.dataIndex;
  21676. var multipleSeries = opt.multipleSeries;
  21677. var data = series.getData();
  21678. var tooltipDims = data.mapDimensionsAll('defaultedTooltip');
  21679. var tooltipDimLen = tooltipDims.length;
  21680. var value = series.getRawValue(dataIndex);
  21681. var isValueArr = isArray(value);
  21682. var markerColor = retrieveVisualColorForTooltipMarker(series, dataIndex); // Complicated rule for pretty tooltip.
  21683. var inlineValue;
  21684. var inlineValueType;
  21685. var subBlocks;
  21686. var sortParam;
  21687. if (tooltipDimLen > 1 || isValueArr && !tooltipDimLen) {
  21688. var formatArrResult = formatTooltipArrayValue(value, series, dataIndex, tooltipDims, markerColor);
  21689. inlineValue = formatArrResult.inlineValues;
  21690. inlineValueType = formatArrResult.inlineValueTypes;
  21691. subBlocks = formatArrResult.blocks; // Only support tooltip sort by the first inline value. It's enough in most cases.
  21692. sortParam = formatArrResult.inlineValues[0];
  21693. } else if (tooltipDimLen) {
  21694. var dimInfo = data.getDimensionInfo(tooltipDims[0]);
  21695. sortParam = inlineValue = retrieveRawValue(data, dataIndex, tooltipDims[0]);
  21696. inlineValueType = dimInfo.type;
  21697. } else {
  21698. sortParam = inlineValue = isValueArr ? value[0] : value;
  21699. } // Do not show generated series name. It might not be readable.
  21700. var seriesNameSpecified = isNameSpecified(series);
  21701. var seriesName = seriesNameSpecified && series.name || '';
  21702. var itemName = data.getName(dataIndex);
  21703. var inlineName = multipleSeries ? seriesName : itemName;
  21704. return createTooltipMarkup('section', {
  21705. header: seriesName,
  21706. // When series name not specified, do not show a header line with only '-'.
  21707. // This case alway happen in tooltip.trigger: 'item'.
  21708. noHeader: multipleSeries || !seriesNameSpecified,
  21709. sortParam: sortParam,
  21710. blocks: [createTooltipMarkup('nameValue', {
  21711. markerType: 'item',
  21712. markerColor: markerColor,
  21713. // Do not mix display seriesName and itemName in one tooltip,
  21714. // which might confuses users.
  21715. name: inlineName,
  21716. // name dimension might be auto assigned, where the name might
  21717. // be not readable. So we check trim here.
  21718. noName: !trim(inlineName),
  21719. value: inlineValue,
  21720. valueType: inlineValueType
  21721. })].concat(subBlocks || [])
  21722. });
  21723. }
  21724. function formatTooltipArrayValue(value, series, dataIndex, tooltipDims, colorStr) {
  21725. // check: category-no-encode-has-axis-data in dataset.html
  21726. var data = series.getData();
  21727. var isValueMultipleLine = reduce(value, function (isValueMultipleLine, val, idx) {
  21728. var dimItem = data.getDimensionInfo(idx);
  21729. return isValueMultipleLine = isValueMultipleLine || dimItem && dimItem.tooltip !== false && dimItem.displayName != null;
  21730. }, false);
  21731. var inlineValues = [];
  21732. var inlineValueTypes = [];
  21733. var blocks = [];
  21734. tooltipDims.length ? each$1(tooltipDims, function (dim) {
  21735. setEachItem(retrieveRawValue(data, dataIndex, dim), dim);
  21736. }) // By default, all dims is used on tooltip.
  21737. : each$1(value, setEachItem);
  21738. function setEachItem(val, dim) {
  21739. var dimInfo = data.getDimensionInfo(dim); // If `dimInfo.tooltip` is not set, show tooltip.
  21740. if (!dimInfo || dimInfo.otherDims.tooltip === false) {
  21741. return;
  21742. }
  21743. if (isValueMultipleLine) {
  21744. blocks.push(createTooltipMarkup('nameValue', {
  21745. markerType: 'subItem',
  21746. markerColor: colorStr,
  21747. name: dimInfo.displayName,
  21748. value: val,
  21749. valueType: dimInfo.type
  21750. }));
  21751. } else {
  21752. inlineValues.push(val);
  21753. inlineValueTypes.push(dimInfo.type);
  21754. }
  21755. }
  21756. return {
  21757. inlineValues: inlineValues,
  21758. inlineValueTypes: inlineValueTypes,
  21759. blocks: blocks
  21760. };
  21761. }
  21762. /*
  21763. * Licensed to the Apache Software Foundation (ASF) under one
  21764. * or more contributor license agreements. See the NOTICE file
  21765. * distributed with this work for additional information
  21766. * regarding copyright ownership. The ASF licenses this file
  21767. * to you under the Apache License, Version 2.0 (the
  21768. * "License"); you may not use this file except in compliance
  21769. * with the License. You may obtain a copy of the License at
  21770. *
  21771. * http://www.apache.org/licenses/LICENSE-2.0
  21772. *
  21773. * Unless required by applicable law or agreed to in writing,
  21774. * software distributed under the License is distributed on an
  21775. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21776. * KIND, either express or implied. See the License for the
  21777. * specific language governing permissions and limitations
  21778. * under the License.
  21779. */
  21780. /**
  21781. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21782. */
  21783. /*
  21784. * Licensed to the Apache Software Foundation (ASF) under one
  21785. * or more contributor license agreements. See the NOTICE file
  21786. * distributed with this work for additional information
  21787. * regarding copyright ownership. The ASF licenses this file
  21788. * to you under the Apache License, Version 2.0 (the
  21789. * "License"); you may not use this file except in compliance
  21790. * with the License. You may obtain a copy of the License at
  21791. *
  21792. * http://www.apache.org/licenses/LICENSE-2.0
  21793. *
  21794. * Unless required by applicable law or agreed to in writing,
  21795. * software distributed under the License is distributed on an
  21796. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21797. * KIND, either express or implied. See the License for the
  21798. * specific language governing permissions and limitations
  21799. * under the License.
  21800. */
  21801. var inner$1 = makeInner();
  21802. function getSelectionKey(data, dataIndex) {
  21803. return data.getName(dataIndex) || data.getId(dataIndex);
  21804. }
  21805. var SeriesModel =
  21806. /** @class */
  21807. function (_super) {
  21808. __extends(SeriesModel, _super);
  21809. function SeriesModel() {
  21810. // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
  21811. // the class members must not be initialized in constructor or declaration place.
  21812. // Otherwise there is bad case:
  21813. // class A {xxx = 1;}
  21814. // enableClassExtend(A);
  21815. // class B extends A {}
  21816. // var C = B.extend({xxx: 5});
  21817. // var c = new C();
  21818. // console.log(c.xxx); // expect 5 but always 1.
  21819. var _this = _super !== null && _super.apply(this, arguments) || this; // ---------------------------------------
  21820. // Props about data selection
  21821. // ---------------------------------------
  21822. _this._selectedDataIndicesMap = {};
  21823. return _this;
  21824. }
  21825. SeriesModel.prototype.init = function (option, parentModel, ecModel) {
  21826. this.seriesIndex = this.componentIndex;
  21827. this.dataTask = createTask({
  21828. count: dataTaskCount,
  21829. reset: dataTaskReset
  21830. });
  21831. this.dataTask.context = {
  21832. model: this
  21833. };
  21834. this.mergeDefaultAndTheme(option, ecModel);
  21835. var sourceManager = inner$1(this).sourceManager = new SourceManager(this);
  21836. sourceManager.prepareSource();
  21837. var data = this.getInitialData(option, ecModel);
  21838. wrapData(data, this);
  21839. this.dataTask.context.data = data;
  21840. {
  21841. assert$1(data, 'getInitialData returned invalid data.');
  21842. }
  21843. inner$1(this).dataBeforeProcessed = data; // If we reverse the order (make data firstly, and then make
  21844. // dataBeforeProcessed by cloneShallow), cloneShallow will
  21845. // cause data.graph.data !== data when using
  21846. // module:echarts/data/Graph or module:echarts/data/Tree.
  21847. // See module:echarts/data/helper/linkList
  21848. // Theoretically, it is unreasonable to call `seriesModel.getData()` in the model
  21849. // init or merge stage, because the data can be restored. So we do not `restoreData`
  21850. // and `setData` here, which forbids calling `seriesModel.getData()` in this stage.
  21851. // Call `seriesModel.getRawData()` instead.
  21852. // this.restoreData();
  21853. autoSeriesName(this);
  21854. this._initSelectedMapFromData(data);
  21855. };
  21856. /**
  21857. * Util for merge default and theme to option
  21858. */
  21859. SeriesModel.prototype.mergeDefaultAndTheme = function (option, ecModel) {
  21860. var layoutMode = fetchLayoutMode(this);
  21861. var inputPositionParams = layoutMode ? getLayoutParams(option) : {}; // Backward compat: using subType on theme.
  21862. // But if name duplicate between series subType
  21863. // (for example: parallel) add component mainType,
  21864. // add suffix 'Series'.
  21865. var themeSubType = this.subType;
  21866. if (ComponentModel.hasClass(themeSubType)) {
  21867. themeSubType += 'Series';
  21868. }
  21869. merge(option, ecModel.getTheme().get(this.subType));
  21870. merge(option, this.getDefaultOption()); // Default label emphasis `show`
  21871. defaultEmphasis(option, 'label', ['show']);
  21872. this.fillDataTextStyle(option.data);
  21873. if (layoutMode) {
  21874. mergeLayoutParam(option, inputPositionParams, layoutMode);
  21875. }
  21876. };
  21877. SeriesModel.prototype.mergeOption = function (newSeriesOption, ecModel) {
  21878. // this.settingTask.dirty();
  21879. newSeriesOption = merge(this.option, newSeriesOption, true);
  21880. this.fillDataTextStyle(newSeriesOption.data);
  21881. var layoutMode = fetchLayoutMode(this);
  21882. if (layoutMode) {
  21883. mergeLayoutParam(this.option, newSeriesOption, layoutMode);
  21884. }
  21885. var sourceManager = inner$1(this).sourceManager;
  21886. sourceManager.dirty();
  21887. sourceManager.prepareSource();
  21888. var data = this.getInitialData(newSeriesOption, ecModel);
  21889. wrapData(data, this);
  21890. this.dataTask.dirty();
  21891. this.dataTask.context.data = data;
  21892. inner$1(this).dataBeforeProcessed = data;
  21893. autoSeriesName(this);
  21894. this._initSelectedMapFromData(data);
  21895. };
  21896. SeriesModel.prototype.fillDataTextStyle = function (data) {
  21897. // Default data label emphasis `show`
  21898. // FIXME Tree structure data ?
  21899. // FIXME Performance ?
  21900. if (data && !isTypedArray(data)) {
  21901. var props = ['show'];
  21902. for (var i = 0; i < data.length; i++) {
  21903. if (data[i] && data[i].label) {
  21904. defaultEmphasis(data[i], 'label', props);
  21905. }
  21906. }
  21907. }
  21908. };
  21909. /**
  21910. * Init a data structure from data related option in series
  21911. * Must be overriden.
  21912. */
  21913. SeriesModel.prototype.getInitialData = function (option, ecModel) {
  21914. return;
  21915. };
  21916. /**
  21917. * Append data to list
  21918. */
  21919. SeriesModel.prototype.appendData = function (params) {
  21920. // FIXME ???
  21921. // (1) If data from dataset, forbidden append.
  21922. // (2) support append data of dataset.
  21923. var data = this.getRawData();
  21924. data.appendData(params.data);
  21925. };
  21926. /**
  21927. * Consider some method like `filter`, `map` need make new data,
  21928. * We should make sure that `seriesModel.getData()` get correct
  21929. * data in the stream procedure. So we fetch data from upstream
  21930. * each time `task.perform` called.
  21931. */
  21932. SeriesModel.prototype.getData = function (dataType) {
  21933. var task = getCurrentTask(this);
  21934. if (task) {
  21935. var data = task.context.data;
  21936. return dataType == null ? data : data.getLinkedData(dataType);
  21937. } else {
  21938. // When series is not alive (that may happen when click toolbox
  21939. // restore or setOption with not merge mode), series data may
  21940. // be still need to judge animation or something when graphic
  21941. // elements want to know whether fade out.
  21942. return inner$1(this).data;
  21943. }
  21944. };
  21945. SeriesModel.prototype.getAllData = function () {
  21946. var mainData = this.getData();
  21947. return mainData && mainData.getLinkedDataAll ? mainData.getLinkedDataAll() : [{
  21948. data: mainData
  21949. }];
  21950. };
  21951. SeriesModel.prototype.setData = function (data) {
  21952. var task = getCurrentTask(this);
  21953. if (task) {
  21954. var context = task.context; // Consider case: filter, data sample.
  21955. // FIXME:TS never used, so comment it
  21956. // if (context.data !== data && task.modifyOutputEnd) {
  21957. // task.setOutputEnd(data.count());
  21958. // }
  21959. context.outputData = data; // Caution: setData should update context.data,
  21960. // Because getData may be called multiply in a
  21961. // single stage and expect to get the data just
  21962. // set. (For example, AxisProxy, x y both call
  21963. // getData and setDate sequentially).
  21964. // So the context.data should be fetched from
  21965. // upstream each time when a stage starts to be
  21966. // performed.
  21967. if (task !== this.dataTask) {
  21968. context.data = data;
  21969. }
  21970. }
  21971. inner$1(this).data = data;
  21972. };
  21973. SeriesModel.prototype.getSource = function () {
  21974. return inner$1(this).sourceManager.getSource();
  21975. };
  21976. /**
  21977. * Get data before processed
  21978. */
  21979. SeriesModel.prototype.getRawData = function () {
  21980. return inner$1(this).dataBeforeProcessed;
  21981. };
  21982. /**
  21983. * Get base axis if has coordinate system and has axis.
  21984. * By default use coordSys.getBaseAxis();
  21985. * Can be overrided for some chart.
  21986. * @return {type} description
  21987. */
  21988. SeriesModel.prototype.getBaseAxis = function () {
  21989. var coordSys = this.coordinateSystem; // @ts-ignore
  21990. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  21991. };
  21992. /**
  21993. * Default tooltip formatter
  21994. *
  21995. * @param dataIndex
  21996. * @param multipleSeries
  21997. * @param dataType
  21998. * @param renderMode valid values: 'html'(by default) and 'richText'.
  21999. * 'html' is used for rendering tooltip in extra DOM form, and the result
  22000. * string is used as DOM HTML content.
  22001. * 'richText' is used for rendering tooltip in rich text form, for those where
  22002. * DOM operation is not supported.
  22003. * @return formatted tooltip with `html` and `markers`
  22004. * Notice: The override method can also return string
  22005. */
  22006. SeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  22007. return defaultSeriesFormatTooltip({
  22008. series: this,
  22009. dataIndex: dataIndex,
  22010. multipleSeries: multipleSeries
  22011. });
  22012. };
  22013. SeriesModel.prototype.isAnimationEnabled = function () {
  22014. if (env.node) {
  22015. return false;
  22016. }
  22017. var animationEnabled = this.getShallow('animation');
  22018. if (animationEnabled) {
  22019. if (this.getData().count() > this.getShallow('animationThreshold')) {
  22020. animationEnabled = false;
  22021. }
  22022. }
  22023. return !!animationEnabled;
  22024. };
  22025. SeriesModel.prototype.restoreData = function () {
  22026. this.dataTask.dirty();
  22027. };
  22028. SeriesModel.prototype.getColorFromPalette = function (name, scope, requestColorNum) {
  22029. var ecModel = this.ecModel; // PENDING
  22030. var color = PaletteMixin.prototype.getColorFromPalette.call(this, name, scope, requestColorNum);
  22031. if (!color) {
  22032. color = ecModel.getColorFromPalette(name, scope, requestColorNum);
  22033. }
  22034. return color;
  22035. };
  22036. /**
  22037. * Use `data.mapDimensionsAll(coordDim)` instead.
  22038. * @deprecated
  22039. */
  22040. SeriesModel.prototype.coordDimToDataDim = function (coordDim) {
  22041. return this.getRawData().mapDimensionsAll(coordDim);
  22042. };
  22043. /**
  22044. * Get progressive rendering count each step
  22045. */
  22046. SeriesModel.prototype.getProgressive = function () {
  22047. return this.get('progressive');
  22048. };
  22049. /**
  22050. * Get progressive rendering count each step
  22051. */
  22052. SeriesModel.prototype.getProgressiveThreshold = function () {
  22053. return this.get('progressiveThreshold');
  22054. }; // PENGING If selectedMode is null ?
  22055. SeriesModel.prototype.select = function (innerDataIndices, dataType) {
  22056. this._innerSelect(this.getData(dataType), innerDataIndices);
  22057. };
  22058. SeriesModel.prototype.unselect = function (innerDataIndices, dataType) {
  22059. var selectedMap = this.option.selectedMap;
  22060. if (!selectedMap) {
  22061. return;
  22062. }
  22063. var data = this.getData(dataType);
  22064. for (var i = 0; i < innerDataIndices.length; i++) {
  22065. var dataIndex = innerDataIndices[i];
  22066. var nameOrId = getSelectionKey(data, dataIndex);
  22067. selectedMap[nameOrId] = false;
  22068. this._selectedDataIndicesMap[nameOrId] = -1;
  22069. }
  22070. };
  22071. SeriesModel.prototype.toggleSelect = function (innerDataIndices, dataType) {
  22072. var tmpArr = [];
  22073. for (var i = 0; i < innerDataIndices.length; i++) {
  22074. tmpArr[0] = innerDataIndices[i];
  22075. this.isSelected(innerDataIndices[i], dataType) ? this.unselect(tmpArr, dataType) : this.select(tmpArr, dataType);
  22076. }
  22077. };
  22078. SeriesModel.prototype.getSelectedDataIndices = function () {
  22079. var selectedDataIndicesMap = this._selectedDataIndicesMap;
  22080. var nameOrIds = keys(selectedDataIndicesMap);
  22081. var dataIndices = [];
  22082. for (var i = 0; i < nameOrIds.length; i++) {
  22083. var dataIndex = selectedDataIndicesMap[nameOrIds[i]];
  22084. if (dataIndex >= 0) {
  22085. dataIndices.push(dataIndex);
  22086. }
  22087. }
  22088. return dataIndices;
  22089. };
  22090. SeriesModel.prototype.isSelected = function (dataIndex, dataType) {
  22091. var selectedMap = this.option.selectedMap;
  22092. if (!selectedMap) {
  22093. return false;
  22094. }
  22095. var data = this.getData(dataType);
  22096. var nameOrId = getSelectionKey(data, dataIndex);
  22097. return selectedMap[nameOrId] || false;
  22098. };
  22099. SeriesModel.prototype._innerSelect = function (data, innerDataIndices) {
  22100. var _a, _b;
  22101. var selectedMode = this.option.selectedMode;
  22102. var len = innerDataIndices.length;
  22103. if (!selectedMode || !len) {
  22104. return;
  22105. }
  22106. if (selectedMode === 'multiple') {
  22107. var selectedMap = this.option.selectedMap || (this.option.selectedMap = {});
  22108. for (var i = 0; i < len; i++) {
  22109. var dataIndex = innerDataIndices[i]; // TODO diffrent types of data share same object.
  22110. var nameOrId = getSelectionKey(data, dataIndex);
  22111. selectedMap[nameOrId] = true;
  22112. this._selectedDataIndicesMap[nameOrId] = data.getRawIndex(dataIndex);
  22113. }
  22114. } else if (selectedMode === 'single' || selectedMode === true) {
  22115. var lastDataIndex = innerDataIndices[len - 1];
  22116. var nameOrId = getSelectionKey(data, lastDataIndex);
  22117. this.option.selectedMap = (_a = {}, _a[nameOrId] = true, _a);
  22118. this._selectedDataIndicesMap = (_b = {}, _b[nameOrId] = data.getRawIndex(lastDataIndex), _b);
  22119. }
  22120. };
  22121. SeriesModel.prototype._initSelectedMapFromData = function (data) {
  22122. // Ignore select info in data if selectedMap exists.
  22123. // NOTE It's only for legacy usage. edge data is not supported.
  22124. if (this.option.selectedMap) {
  22125. return;
  22126. }
  22127. var dataIndices = [];
  22128. if (data.hasItemOption) {
  22129. data.each(function (idx) {
  22130. var rawItem = data.getRawDataItem(idx);
  22131. if (rawItem && rawItem.selected) {
  22132. dataIndices.push(idx);
  22133. }
  22134. });
  22135. }
  22136. if (dataIndices.length > 0) {
  22137. this._innerSelect(data, dataIndices);
  22138. }
  22139. }; // /**
  22140. // * @see {module:echarts/stream/Scheduler}
  22141. // */
  22142. // abstract pipeTask: null
  22143. SeriesModel.registerClass = function (clz) {
  22144. return ComponentModel.registerClass(clz);
  22145. };
  22146. SeriesModel.protoInitialize = function () {
  22147. var proto = SeriesModel.prototype;
  22148. proto.type = 'series.__base__';
  22149. proto.seriesIndex = 0;
  22150. proto.useColorPaletteOnData = false;
  22151. proto.ignoreStyleOnData = false;
  22152. proto.hasSymbolVisual = false;
  22153. proto.defaultSymbol = 'circle'; // Make sure the values can be accessed!
  22154. proto.visualStyleAccessPath = 'itemStyle';
  22155. proto.visualDrawType = 'fill';
  22156. }();
  22157. return SeriesModel;
  22158. }(ComponentModel);
  22159. mixin(SeriesModel, DataFormatMixin);
  22160. mixin(SeriesModel, PaletteMixin);
  22161. mountExtend(SeriesModel, ComponentModel);
  22162. /**
  22163. * MUST be called after `prepareSource` called
  22164. * Here we need to make auto series, especially for auto legend. But we
  22165. * do not modify series.name in option to avoid side effects.
  22166. */
  22167. function autoSeriesName(seriesModel) {
  22168. // User specified name has higher priority, otherwise it may cause
  22169. // series can not be queried unexpectedly.
  22170. var name = seriesModel.name;
  22171. if (!isNameSpecified(seriesModel)) {
  22172. seriesModel.name = getSeriesAutoName(seriesModel) || name;
  22173. }
  22174. }
  22175. function getSeriesAutoName(seriesModel) {
  22176. var data = seriesModel.getRawData();
  22177. var dataDims = data.mapDimensionsAll('seriesName');
  22178. var nameArr = [];
  22179. each$1(dataDims, function (dataDim) {
  22180. var dimInfo = data.getDimensionInfo(dataDim);
  22181. dimInfo.displayName && nameArr.push(dimInfo.displayName);
  22182. });
  22183. return nameArr.join(' ');
  22184. }
  22185. function dataTaskCount(context) {
  22186. return context.model.getRawData().count();
  22187. }
  22188. function dataTaskReset(context) {
  22189. var seriesModel = context.model;
  22190. seriesModel.setData(seriesModel.getRawData().cloneShallow());
  22191. return dataTaskProgress;
  22192. }
  22193. function dataTaskProgress(param, context) {
  22194. // Avoid repead cloneShallow when data just created in reset.
  22195. if (context.outputData && param.end > context.outputData.count()) {
  22196. context.model.getRawData().cloneShallow(context.outputData);
  22197. }
  22198. } // TODO refactor
  22199. function wrapData(data, seriesModel) {
  22200. each$1(__spreadArrays(data.CHANGABLE_METHODS, data.DOWNSAMPLE_METHODS), function (methodName) {
  22201. data.wrapMethod(methodName, curry(onDataChange, seriesModel));
  22202. });
  22203. }
  22204. function onDataChange(seriesModel, newList) {
  22205. var task = getCurrentTask(seriesModel);
  22206. if (task) {
  22207. // Consider case: filter, selectRange
  22208. task.setOutputEnd((newList || this).count());
  22209. }
  22210. return newList;
  22211. }
  22212. function getCurrentTask(seriesModel) {
  22213. var scheduler = (seriesModel.ecModel || {}).scheduler;
  22214. var pipeline = scheduler && scheduler.getPipeline(seriesModel.uid);
  22215. if (pipeline) {
  22216. // When pipline finished, the currrentTask keep the last
  22217. // task (renderTask).
  22218. var task = pipeline.currentTask;
  22219. if (task) {
  22220. var agentStubMap = task.agentStubMap;
  22221. if (agentStubMap) {
  22222. task = agentStubMap.get(seriesModel.uid);
  22223. }
  22224. }
  22225. return task;
  22226. }
  22227. }
  22228. /*
  22229. * Licensed to the Apache Software Foundation (ASF) under one
  22230. * or more contributor license agreements. See the NOTICE file
  22231. * distributed with this work for additional information
  22232. * regarding copyright ownership. The ASF licenses this file
  22233. * to you under the Apache License, Version 2.0 (the
  22234. * "License"); you may not use this file except in compliance
  22235. * with the License. You may obtain a copy of the License at
  22236. *
  22237. * http://www.apache.org/licenses/LICENSE-2.0
  22238. *
  22239. * Unless required by applicable law or agreed to in writing,
  22240. * software distributed under the License is distributed on an
  22241. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22242. * KIND, either express or implied. See the License for the
  22243. * specific language governing permissions and limitations
  22244. * under the License.
  22245. */
  22246. /**
  22247. * AUTO-GENERATED FILE. DO NOT MODIFY.
  22248. */
  22249. /*
  22250. * Licensed to the Apache Software Foundation (ASF) under one
  22251. * or more contributor license agreements. See the NOTICE file
  22252. * distributed with this work for additional information
  22253. * regarding copyright ownership. The ASF licenses this file
  22254. * to you under the Apache License, Version 2.0 (the
  22255. * "License"); you may not use this file except in compliance
  22256. * with the License. You may obtain a copy of the License at
  22257. *
  22258. * http://www.apache.org/licenses/LICENSE-2.0
  22259. *
  22260. * Unless required by applicable law or agreed to in writing,
  22261. * software distributed under the License is distributed on an
  22262. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22263. * KIND, either express or implied. See the License for the
  22264. * specific language governing permissions and limitations
  22265. * under the License.
  22266. */
  22267. var ComponentView =
  22268. /** @class */
  22269. function () {
  22270. function ComponentView() {
  22271. this.group = new Group();
  22272. this.uid = getUID('viewComponent');
  22273. }
  22274. ComponentView.prototype.init = function (ecModel, api) {};
  22275. ComponentView.prototype.render = function (model, ecModel, api, payload) {};
  22276. ComponentView.prototype.dispose = function (ecModel, api) {};
  22277. ComponentView.prototype.updateView = function (model, ecModel, api, payload) {// Do nothing;
  22278. };
  22279. ComponentView.prototype.updateLayout = function (model, ecModel, api, payload) {// Do nothing;
  22280. };
  22281. ComponentView.prototype.updateVisual = function (model, ecModel, api, payload) {// Do nothing;
  22282. };
  22283. /**
  22284. * Hook for blur target series.
  22285. * Can be used in marker for blur the markers
  22286. */
  22287. ComponentView.prototype.blurSeries = function (seriesModels, ecModel) {// Do nothing;
  22288. };
  22289. return ComponentView;
  22290. }();
  22291. enableClassExtend(ComponentView);
  22292. enableClassManagement(ComponentView);
  22293. /*
  22294. * Licensed to the Apache Software Foundation (ASF) under one
  22295. * or more contributor license agreements. See the NOTICE file
  22296. * distributed with this work for additional information
  22297. * regarding copyright ownership. The ASF licenses this file
  22298. * to you under the Apache License, Version 2.0 (the
  22299. * "License"); you may not use this file except in compliance
  22300. * with the License. You may obtain a copy of the License at
  22301. *
  22302. * http://www.apache.org/licenses/LICENSE-2.0
  22303. *
  22304. * Unless required by applicable law or agreed to in writing,
  22305. * software distributed under the License is distributed on an
  22306. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22307. * KIND, either express or implied. See the License for the
  22308. * specific language governing permissions and limitations
  22309. * under the License.
  22310. */
  22311. /**
  22312. * AUTO-GENERATED FILE. DO NOT MODIFY.
  22313. */
  22314. /*
  22315. * Licensed to the Apache Software Foundation (ASF) under one
  22316. * or more contributor license agreements. See the NOTICE file
  22317. * distributed with this work for additional information
  22318. * regarding copyright ownership. The ASF licenses this file
  22319. * to you under the Apache License, Version 2.0 (the
  22320. * "License"); you may not use this file except in compliance
  22321. * with the License. You may obtain a copy of the License at
  22322. *
  22323. * http://www.apache.org/licenses/LICENSE-2.0
  22324. *
  22325. * Unless required by applicable law or agreed to in writing,
  22326. * software distributed under the License is distributed on an
  22327. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22328. * KIND, either express or implied. See the License for the
  22329. * specific language governing permissions and limitations
  22330. * under the License.
  22331. */
  22332. /**
  22333. * @return {string} If large mode changed, return string 'reset';
  22334. */
  22335. function createRenderPlanner() {
  22336. var inner = makeInner();
  22337. return function (seriesModel) {
  22338. var fields = inner(seriesModel);
  22339. var pipelineContext = seriesModel.pipelineContext;
  22340. var originalLarge = !!fields.large;
  22341. var originalProgressive = !!fields.progressiveRender; // FIXME: if the planner works on a filtered series, `pipelineContext` does not
  22342. // exists. See #11611 . Probably we need to modify this structure, see the comment
  22343. // on `performRawSeries` in `Schedular.js`.
  22344. var large = fields.large = !!(pipelineContext && pipelineContext.large);
  22345. var progressive = fields.progressiveRender = !!(pipelineContext && pipelineContext.progressiveRender);
  22346. return !!(originalLarge !== large || originalProgressive !== progressive) && 'reset';
  22347. };
  22348. }
  22349. /*
  22350. * Licensed to the Apache Software Foundation (ASF) under one
  22351. * or more contributor license agreements. See the NOTICE file
  22352. * distributed with this work for additional information
  22353. * regarding copyright ownership. The ASF licenses this file
  22354. * to you under the Apache License, Version 2.0 (the
  22355. * "License"); you may not use this file except in compliance
  22356. * with the License. You may obtain a copy of the License at
  22357. *
  22358. * http://www.apache.org/licenses/LICENSE-2.0
  22359. *
  22360. * Unless required by applicable law or agreed to in writing,
  22361. * software distributed under the License is distributed on an
  22362. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22363. * KIND, either express or implied. See the License for the
  22364. * specific language governing permissions and limitations
  22365. * under the License.
  22366. */
  22367. /**
  22368. * AUTO-GENERATED FILE. DO NOT MODIFY.
  22369. */
  22370. /*
  22371. * Licensed to the Apache Software Foundation (ASF) under one
  22372. * or more contributor license agreements. See the NOTICE file
  22373. * distributed with this work for additional information
  22374. * regarding copyright ownership. The ASF licenses this file
  22375. * to you under the Apache License, Version 2.0 (the
  22376. * "License"); you may not use this file except in compliance
  22377. * with the License. You may obtain a copy of the License at
  22378. *
  22379. * http://www.apache.org/licenses/LICENSE-2.0
  22380. *
  22381. * Unless required by applicable law or agreed to in writing,
  22382. * software distributed under the License is distributed on an
  22383. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22384. * KIND, either express or implied. See the License for the
  22385. * specific language governing permissions and limitations
  22386. * under the License.
  22387. */
  22388. var inner$2 = makeInner();
  22389. var renderPlanner = createRenderPlanner();
  22390. var ChartView =
  22391. /** @class */
  22392. function () {
  22393. function ChartView() {
  22394. this.group = new Group();
  22395. this.uid = getUID('viewChart');
  22396. this.renderTask = createTask({
  22397. plan: renderTaskPlan,
  22398. reset: renderTaskReset
  22399. });
  22400. this.renderTask.context = {
  22401. view: this
  22402. };
  22403. }
  22404. ChartView.prototype.init = function (ecModel, api) {};
  22405. ChartView.prototype.render = function (seriesModel, ecModel, api, payload) {};
  22406. /**
  22407. * Highlight series or specified data item.
  22408. */
  22409. ChartView.prototype.highlight = function (seriesModel, ecModel, api, payload) {
  22410. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  22411. };
  22412. /**
  22413. * Downplay series or specified data item.
  22414. */
  22415. ChartView.prototype.downplay = function (seriesModel, ecModel, api, payload) {
  22416. toggleHighlight(seriesModel.getData(), payload, 'normal');
  22417. };
  22418. /**
  22419. * Remove self.
  22420. */
  22421. ChartView.prototype.remove = function (ecModel, api) {
  22422. this.group.removeAll();
  22423. };
  22424. /**
  22425. * Dispose self.
  22426. */
  22427. ChartView.prototype.dispose = function (ecModel, api) {};
  22428. ChartView.prototype.updateView = function (seriesModel, ecModel, api, payload) {
  22429. this.render(seriesModel, ecModel, api, payload);
  22430. }; // FIXME never used?
  22431. ChartView.prototype.updateLayout = function (seriesModel, ecModel, api, payload) {
  22432. this.render(seriesModel, ecModel, api, payload);
  22433. }; // FIXME never used?
  22434. ChartView.prototype.updateVisual = function (seriesModel, ecModel, api, payload) {
  22435. this.render(seriesModel, ecModel, api, payload);
  22436. };
  22437. ChartView.markUpdateMethod = function (payload, methodName) {
  22438. inner$2(payload).updateMethod = methodName;
  22439. };
  22440. ChartView.protoInitialize = function () {
  22441. var proto = ChartView.prototype;
  22442. proto.type = 'chart';
  22443. }();
  22444. return ChartView;
  22445. }();
  22446. /**
  22447. * Set state of single element
  22448. */
  22449. function elSetState(el, state, highlightDigit) {
  22450. if (el) {
  22451. (state === 'emphasis' ? enterEmphasis : leaveEmphasis)(el, highlightDigit);
  22452. }
  22453. }
  22454. function toggleHighlight(data, payload, state) {
  22455. var dataIndex = queryDataIndex(data, payload);
  22456. var highlightDigit = payload && payload.highlightKey != null ? getHighlightDigit(payload.highlightKey) : null;
  22457. if (dataIndex != null) {
  22458. each$1(normalizeToArray(dataIndex), function (dataIdx) {
  22459. elSetState(data.getItemGraphicEl(dataIdx), state, highlightDigit);
  22460. });
  22461. } else {
  22462. data.eachItemGraphicEl(function (el) {
  22463. elSetState(el, state, highlightDigit);
  22464. });
  22465. }
  22466. }
  22467. enableClassExtend(ChartView, ['dispose']);
  22468. enableClassManagement(ChartView);
  22469. function renderTaskPlan(context) {
  22470. return renderPlanner(context.model);
  22471. }
  22472. function renderTaskReset(context) {
  22473. var seriesModel = context.model;
  22474. var ecModel = context.ecModel;
  22475. var api = context.api;
  22476. var payload = context.payload; // FIXME: remove updateView updateVisual
  22477. var progressiveRender = seriesModel.pipelineContext.progressiveRender;
  22478. var view = context.view;
  22479. var updateMethod = payload && inner$2(payload).updateMethod;
  22480. var methodName = progressiveRender ? 'incrementalPrepareRender' : updateMethod && view[updateMethod] ? updateMethod // `appendData` is also supported when data amount
  22481. // is less than progressive threshold.
  22482. : 'render';
  22483. if (methodName !== 'render') {
  22484. view[methodName](seriesModel, ecModel, api, payload);
  22485. }
  22486. return progressMethodMap[methodName];
  22487. }
  22488. var progressMethodMap = {
  22489. incrementalPrepareRender: {
  22490. progress: function (params, context) {
  22491. context.view.incrementalRender(params, context.model, context.ecModel, context.api, context.payload);
  22492. }
  22493. },
  22494. render: {
  22495. // Put view.render in `progress` to support appendData. But in this case
  22496. // view.render should not be called in reset, otherwise it will be called
  22497. // twise. Use `forceFirstProgress` to make sure that view.render is called
  22498. // in any cases.
  22499. forceFirstProgress: true,
  22500. progress: function (params, context) {
  22501. context.view.render(context.model, context.ecModel, context.api, context.payload);
  22502. }
  22503. }
  22504. };
  22505. /*
  22506. * Licensed to the Apache Software Foundation (ASF) under one
  22507. * or more contributor license agreements. See the NOTICE file
  22508. * distributed with this work for additional information
  22509. * regarding copyright ownership. The ASF licenses this file
  22510. * to you under the Apache License, Version 2.0 (the
  22511. * "License"); you may not use this file except in compliance
  22512. * with the License. You may obtain a copy of the License at
  22513. *
  22514. * http://www.apache.org/licenses/LICENSE-2.0
  22515. *
  22516. * Unless required by applicable law or agreed to in writing,
  22517. * software distributed under the License is distributed on an
  22518. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22519. * KIND, either express or implied. See the License for the
  22520. * specific language governing permissions and limitations
  22521. * under the License.
  22522. */
  22523. /**
  22524. * AUTO-GENERATED FILE. DO NOT MODIFY.
  22525. */
  22526. /*
  22527. * Licensed to the Apache Software Foundation (ASF) under one
  22528. * or more contributor license agreements. See the NOTICE file
  22529. * distributed with this work for additional information
  22530. * regarding copyright ownership. The ASF licenses this file
  22531. * to you under the Apache License, Version 2.0 (the
  22532. * "License"); you may not use this file except in compliance
  22533. * with the License. You may obtain a copy of the License at
  22534. *
  22535. * http://www.apache.org/licenses/LICENSE-2.0
  22536. *
  22537. * Unless required by applicable law or agreed to in writing,
  22538. * software distributed under the License is distributed on an
  22539. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22540. * KIND, either express or implied. See the License for the
  22541. * specific language governing permissions and limitations
  22542. * under the License.
  22543. */
  22544. var ORIGIN_METHOD = '\0__throttleOriginMethod';
  22545. var RATE = '\0__throttleRate';
  22546. var THROTTLE_TYPE = '\0__throttleType';
  22547. /**
  22548. * @public
  22549. * @param {(Function)} fn
  22550. * @param {number} [delay=0] Unit: ms.
  22551. * @param {boolean} [debounce=false]
  22552. * true: If call interval less than `delay`, only the last call works.
  22553. * false: If call interval less than `delay, call works on fixed rate.
  22554. * @return {(Function)} throttled fn.
  22555. */
  22556. function throttle(fn, delay, debounce) {
  22557. var currCall;
  22558. var lastCall = 0;
  22559. var lastExec = 0;
  22560. var timer = null;
  22561. var diff;
  22562. var scope;
  22563. var args;
  22564. var debounceNextCall;
  22565. delay = delay || 0;
  22566. function exec() {
  22567. lastExec = new Date().getTime();
  22568. timer = null;
  22569. fn.apply(scope, args || []);
  22570. }
  22571. var cb = function () {
  22572. var cbArgs = [];
  22573. for (var _i = 0; _i < arguments.length; _i++) {
  22574. cbArgs[_i] = arguments[_i];
  22575. }
  22576. currCall = new Date().getTime();
  22577. scope = this;
  22578. args = cbArgs;
  22579. var thisDelay = debounceNextCall || delay;
  22580. var thisDebounce = debounceNextCall || debounce;
  22581. debounceNextCall = null;
  22582. diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay;
  22583. clearTimeout(timer); // Here we should make sure that: the `exec` SHOULD NOT be called later
  22584. // than a new call of `cb`, that is, preserving the command order. Consider
  22585. // calculating "scale rate" when roaming as an example. When a call of `cb`
  22586. // happens, either the `exec` is called dierectly, or the call is delayed.
  22587. // But the delayed call should never be later than next call of `cb`. Under
  22588. // this assurance, we can simply update view state each time `dispatchAction`
  22589. // triggered by user roaming, but not need to add extra code to avoid the
  22590. // state being "rolled-back".
  22591. if (thisDebounce) {
  22592. timer = setTimeout(exec, thisDelay);
  22593. } else {
  22594. if (diff >= 0) {
  22595. exec();
  22596. } else {
  22597. timer = setTimeout(exec, -diff);
  22598. }
  22599. }
  22600. lastCall = currCall;
  22601. };
  22602. /**
  22603. * Clear throttle.
  22604. * @public
  22605. */
  22606. cb.clear = function () {
  22607. if (timer) {
  22608. clearTimeout(timer);
  22609. timer = null;
  22610. }
  22611. };
  22612. /**
  22613. * Enable debounce once.
  22614. */
  22615. cb.debounceNextCall = function (debounceDelay) {
  22616. debounceNextCall = debounceDelay;
  22617. };
  22618. return cb;
  22619. }
  22620. /**
  22621. * Create throttle method or update throttle rate.
  22622. *
  22623. * @example
  22624. * ComponentView.prototype.render = function () {
  22625. * ...
  22626. * throttle.createOrUpdate(
  22627. * this,
  22628. * '_dispatchAction',
  22629. * this.model.get('throttle'),
  22630. * 'fixRate'
  22631. * );
  22632. * };
  22633. * ComponentView.prototype.remove = function () {
  22634. * throttle.clear(this, '_dispatchAction');
  22635. * };
  22636. * ComponentView.prototype.dispose = function () {
  22637. * throttle.clear(this, '_dispatchAction');
  22638. * };
  22639. *
  22640. */
  22641. function createOrUpdate(obj, fnAttr, rate, throttleType) {
  22642. var fn = obj[fnAttr];
  22643. if (!fn) {
  22644. return;
  22645. }
  22646. var originFn = fn[ORIGIN_METHOD] || fn;
  22647. var lastThrottleType = fn[THROTTLE_TYPE];
  22648. var lastRate = fn[RATE];
  22649. if (lastRate !== rate || lastThrottleType !== throttleType) {
  22650. if (rate == null || !throttleType) {
  22651. return obj[fnAttr] = originFn;
  22652. }
  22653. fn = obj[fnAttr] = throttle(originFn, rate, throttleType === 'debounce');
  22654. fn[ORIGIN_METHOD] = originFn;
  22655. fn[THROTTLE_TYPE] = throttleType;
  22656. fn[RATE] = rate;
  22657. }
  22658. return fn;
  22659. }
  22660. /**
  22661. * Clear throttle. Example see throttle.createOrUpdate.
  22662. */
  22663. function clear(obj, fnAttr) {
  22664. var fn = obj[fnAttr];
  22665. if (fn && fn[ORIGIN_METHOD]) {
  22666. obj[fnAttr] = fn[ORIGIN_METHOD];
  22667. }
  22668. }
  22669. /*
  22670. * Licensed to the Apache Software Foundation (ASF) under one
  22671. * or more contributor license agreements. See the NOTICE file
  22672. * distributed with this work for additional information
  22673. * regarding copyright ownership. The ASF licenses this file
  22674. * to you under the Apache License, Version 2.0 (the
  22675. * "License"); you may not use this file except in compliance
  22676. * with the License. You may obtain a copy of the License at
  22677. *
  22678. * http://www.apache.org/licenses/LICENSE-2.0
  22679. *
  22680. * Unless required by applicable law or agreed to in writing,
  22681. * software distributed under the License is distributed on an
  22682. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22683. * KIND, either express or implied. See the License for the
  22684. * specific language governing permissions and limitations
  22685. * under the License.
  22686. */
  22687. /**
  22688. * AUTO-GENERATED FILE. DO NOT MODIFY.
  22689. */
  22690. /*
  22691. * Licensed to the Apache Software Foundation (ASF) under one
  22692. * or more contributor license agreements. See the NOTICE file
  22693. * distributed with this work for additional information
  22694. * regarding copyright ownership. The ASF licenses this file
  22695. * to you under the Apache License, Version 2.0 (the
  22696. * "License"); you may not use this file except in compliance
  22697. * with the License. You may obtain a copy of the License at
  22698. *
  22699. * http://www.apache.org/licenses/LICENSE-2.0
  22700. *
  22701. * Unless required by applicable law or agreed to in writing,
  22702. * software distributed under the License is distributed on an
  22703. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22704. * KIND, either express or implied. See the License for the
  22705. * specific language governing permissions and limitations
  22706. * under the License.
  22707. */
  22708. var inner$3 = makeInner();
  22709. var defaultStyleMappers = {
  22710. itemStyle: makeStyleMapper(ITEM_STYLE_KEY_MAP, true),
  22711. lineStyle: makeStyleMapper(LINE_STYLE_KEY_MAP, true)
  22712. };
  22713. var defaultColorKey = {
  22714. lineStyle: 'stroke',
  22715. itemStyle: 'fill'
  22716. };
  22717. function getStyleMapper(seriesModel, stylePath) {
  22718. var styleMapper = seriesModel.visualStyleMapper || defaultStyleMappers[stylePath];
  22719. if (!styleMapper) {
  22720. console.warn("Unkown style type '" + stylePath + "'.");
  22721. return defaultStyleMappers.itemStyle;
  22722. }
  22723. return styleMapper;
  22724. }
  22725. function getDefaultColorKey(seriesModel, stylePath) {
  22726. // return defaultColorKey[stylePath] ||
  22727. var colorKey = seriesModel.visualDrawType || defaultColorKey[stylePath];
  22728. if (!colorKey) {
  22729. console.warn("Unkown style type '" + stylePath + "'.");
  22730. return 'fill';
  22731. }
  22732. return colorKey;
  22733. }
  22734. var seriesStyleTask = {
  22735. createOnAllSeries: true,
  22736. performRawSeries: true,
  22737. reset: function (seriesModel, ecModel) {
  22738. var data = seriesModel.getData();
  22739. var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle'; // Set in itemStyle
  22740. var styleModel = seriesModel.getModel(stylePath);
  22741. var getStyle = getStyleMapper(seriesModel, stylePath);
  22742. var globalStyle = getStyle(styleModel);
  22743. var decalOption = styleModel.getShallow('decal');
  22744. if (decalOption) {
  22745. data.setVisual('decal', decalOption);
  22746. decalOption.dirty = true;
  22747. } // TODO
  22748. var colorKey = getDefaultColorKey(seriesModel, stylePath);
  22749. var color = globalStyle[colorKey]; // TODO style callback
  22750. var colorCallback = isFunction$1(color) ? color : null;
  22751. var hasAutoColor = globalStyle.fill === 'auto' || globalStyle.stroke === 'auto'; // Get from color palette by default.
  22752. if (!globalStyle[colorKey] || colorCallback || hasAutoColor) {
  22753. // Note: if some series has color specified (e.g., by itemStyle.color), we DO NOT
  22754. // make it effect palette. Bacause some scenarios users need to make some series
  22755. // transparent or as background, which should better not effect the palette.
  22756. var colorPalette = seriesModel.getColorFromPalette( // TODO series count changed.
  22757. seriesModel.name, null, ecModel.getSeriesCount());
  22758. if (!globalStyle[colorKey]) {
  22759. globalStyle[colorKey] = colorPalette;
  22760. data.setVisual('colorFromPalette', true);
  22761. }
  22762. globalStyle.fill = globalStyle.fill === 'auto' || typeof globalStyle.fill === 'function' ? colorPalette : globalStyle.fill;
  22763. globalStyle.stroke = globalStyle.stroke === 'auto' || typeof globalStyle.stroke === 'function' ? colorPalette : globalStyle.stroke;
  22764. }
  22765. data.setVisual('style', globalStyle);
  22766. data.setVisual('drawType', colorKey); // Only visible series has each data be visual encoded
  22767. if (!ecModel.isSeriesFiltered(seriesModel) && colorCallback) {
  22768. data.setVisual('colorFromPalette', false);
  22769. return {
  22770. dataEach: function (data, idx) {
  22771. var dataParams = seriesModel.getDataParams(idx);
  22772. var itemStyle = extend({}, globalStyle);
  22773. itemStyle[colorKey] = colorCallback(dataParams);
  22774. data.setItemVisual(idx, 'style', itemStyle);
  22775. }
  22776. };
  22777. }
  22778. }
  22779. };
  22780. var sharedModel = new Model();
  22781. var dataStyleTask = {
  22782. createOnAllSeries: true,
  22783. performRawSeries: true,
  22784. reset: function (seriesModel, ecModel) {
  22785. if (seriesModel.ignoreStyleOnData || ecModel.isSeriesFiltered(seriesModel)) {
  22786. return;
  22787. }
  22788. var data = seriesModel.getData();
  22789. var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle'; // Set in itemStyle
  22790. var getStyle = getStyleMapper(seriesModel, stylePath);
  22791. var colorKey = data.getVisual('drawType');
  22792. return {
  22793. dataEach: data.hasItemOption ? function (data, idx) {
  22794. // Not use getItemModel for performance considuration
  22795. var rawItem = data.getRawDataItem(idx);
  22796. if (rawItem && rawItem[stylePath]) {
  22797. sharedModel.option = rawItem[stylePath];
  22798. var style = getStyle(sharedModel);
  22799. var existsStyle = data.ensureUniqueItemVisual(idx, 'style');
  22800. extend(existsStyle, style);
  22801. if (sharedModel.option.decal) {
  22802. data.setItemVisual(idx, 'decal', sharedModel.option.decal);
  22803. sharedModel.option.decal.dirty = true;
  22804. }
  22805. if (colorKey in style) {
  22806. data.setItemVisual(idx, 'colorFromPalette', false);
  22807. }
  22808. }
  22809. } : null
  22810. };
  22811. }
  22812. }; // Pick color from palette for the data which has not been set with color yet.
  22813. // Note: do not support stream rendering. No such cases yet.
  22814. var dataColorPaletteTask = {
  22815. performRawSeries: true,
  22816. overallReset: function (ecModel) {
  22817. // Each type of series use one scope.
  22818. // Pie and funnel are using diferrent scopes
  22819. var paletteScopeGroupByType = createHashMap();
  22820. ecModel.eachSeries(function (seriesModel) {
  22821. if (!seriesModel.useColorPaletteOnData) {
  22822. return;
  22823. }
  22824. var colorScope = paletteScopeGroupByType.get(seriesModel.type);
  22825. if (!colorScope) {
  22826. colorScope = {};
  22827. paletteScopeGroupByType.set(seriesModel.type, colorScope);
  22828. }
  22829. inner$3(seriesModel).scope = colorScope;
  22830. });
  22831. ecModel.eachSeries(function (seriesModel) {
  22832. if (!seriesModel.useColorPaletteOnData || ecModel.isSeriesFiltered(seriesModel)) {
  22833. return;
  22834. }
  22835. var dataAll = seriesModel.getRawData();
  22836. var idxMap = {};
  22837. var data = seriesModel.getData();
  22838. var colorScope = inner$3(seriesModel).scope;
  22839. var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle';
  22840. var colorKey = getDefaultColorKey(seriesModel, stylePath);
  22841. data.each(function (idx) {
  22842. var rawIdx = data.getRawIndex(idx);
  22843. idxMap[rawIdx] = idx;
  22844. }); // Iterate on data before filtered. To make sure color from palette can be
  22845. // Consistent when toggling legend.
  22846. dataAll.each(function (rawIdx) {
  22847. var idx = idxMap[rawIdx];
  22848. var fromPalette = data.getItemVisual(idx, 'colorFromPalette'); // Get color from palette for each data only when the color is inherited from series color, which is
  22849. // also picked from color palette. So following situation is not in the case:
  22850. // 1. series.itemStyle.color is set
  22851. // 2. color is encoded by visualMap
  22852. if (fromPalette) {
  22853. var itemStyle = data.ensureUniqueItemVisual(idx, 'style');
  22854. var name_1 = dataAll.getName(rawIdx) || rawIdx + '';
  22855. var dataCount = dataAll.count();
  22856. itemStyle[colorKey] = seriesModel.getColorFromPalette(name_1, colorScope, dataCount);
  22857. }
  22858. });
  22859. });
  22860. }
  22861. };
  22862. /*
  22863. * Licensed to the Apache Software Foundation (ASF) under one
  22864. * or more contributor license agreements. See the NOTICE file
  22865. * distributed with this work for additional information
  22866. * regarding copyright ownership. The ASF licenses this file
  22867. * to you under the Apache License, Version 2.0 (the
  22868. * "License"); you may not use this file except in compliance
  22869. * with the License. You may obtain a copy of the License at
  22870. *
  22871. * http://www.apache.org/licenses/LICENSE-2.0
  22872. *
  22873. * Unless required by applicable law or agreed to in writing,
  22874. * software distributed under the License is distributed on an
  22875. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22876. * KIND, either express or implied. See the License for the
  22877. * specific language governing permissions and limitations
  22878. * under the License.
  22879. */
  22880. /**
  22881. * AUTO-GENERATED FILE. DO NOT MODIFY.
  22882. */
  22883. /*
  22884. * Licensed to the Apache Software Foundation (ASF) under one
  22885. * or more contributor license agreements. See the NOTICE file
  22886. * distributed with this work for additional information
  22887. * regarding copyright ownership. The ASF licenses this file
  22888. * to you under the Apache License, Version 2.0 (the
  22889. * "License"); you may not use this file except in compliance
  22890. * with the License. You may obtain a copy of the License at
  22891. *
  22892. * http://www.apache.org/licenses/LICENSE-2.0
  22893. *
  22894. * Unless required by applicable law or agreed to in writing,
  22895. * software distributed under the License is distributed on an
  22896. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  22897. * KIND, either express or implied. See the License for the
  22898. * specific language governing permissions and limitations
  22899. * under the License.
  22900. */
  22901. var PI$3 = Math.PI;
  22902. /**
  22903. * @param {module:echarts/ExtensionAPI} api
  22904. * @param {Object} [opts]
  22905. * @param {string} [opts.text]
  22906. * @param {string} [opts.color]
  22907. * @param {string} [opts.textColor]
  22908. * @return {module:zrender/Element}
  22909. */
  22910. function defaultLoading(api, opts) {
  22911. opts = opts || {};
  22912. defaults(opts, {
  22913. text: 'loading',
  22914. textColor: '#000',
  22915. fontSize: 12,
  22916. fontWeight: 'normal',
  22917. fontStyle: 'normal',
  22918. fontFamily: 'sans-serif',
  22919. maskColor: 'rgba(255, 255, 255, 0.8)',
  22920. showSpinner: true,
  22921. color: '#5470c6',
  22922. spinnerRadius: 10,
  22923. lineWidth: 5,
  22924. zlevel: 0
  22925. });
  22926. var group = new Group();
  22927. var mask = new Rect({
  22928. style: {
  22929. fill: opts.maskColor
  22930. },
  22931. zlevel: opts.zlevel,
  22932. z: 10000
  22933. });
  22934. group.add(mask);
  22935. var textContent = new ZRText({
  22936. style: {
  22937. text: opts.text,
  22938. fill: opts.textColor,
  22939. fontSize: opts.fontSize,
  22940. fontWeight: opts.fontWeight,
  22941. fontStyle: opts.fontStyle,
  22942. fontFamily: opts.fontFamily
  22943. },
  22944. zlevel: opts.zlevel,
  22945. z: 10001
  22946. });
  22947. var labelRect = new Rect({
  22948. style: {
  22949. fill: 'none'
  22950. },
  22951. textContent: textContent,
  22952. textConfig: {
  22953. position: 'right',
  22954. distance: 10
  22955. },
  22956. zlevel: opts.zlevel,
  22957. z: 10001
  22958. });
  22959. group.add(labelRect);
  22960. var arc;
  22961. if (opts.showSpinner) {
  22962. arc = new Arc({
  22963. shape: {
  22964. startAngle: -PI$3 / 2,
  22965. endAngle: -PI$3 / 2 + 0.1,
  22966. r: opts.spinnerRadius
  22967. },
  22968. style: {
  22969. stroke: opts.color,
  22970. lineCap: 'round',
  22971. lineWidth: opts.lineWidth
  22972. },
  22973. zlevel: opts.zlevel,
  22974. z: 10001
  22975. });
  22976. arc.animateShape(true).when(1000, {
  22977. endAngle: PI$3 * 3 / 2
  22978. }).start('circularInOut');
  22979. arc.animateShape(true).when(1000, {
  22980. startAngle: PI$3 * 3 / 2
  22981. }).delay(300).start('circularInOut');
  22982. group.add(arc);
  22983. } // Inject resize
  22984. group.resize = function () {
  22985. var textWidth = textContent.getBoundingRect().width;
  22986. var r = opts.showSpinner ? opts.spinnerRadius : 0; // cx = (containerWidth - arcDiameter - textDistance - textWidth) / 2
  22987. // textDistance needs to be calculated when both animation and text exist
  22988. var cx = (api.getWidth() - r * 2 - (opts.showSpinner && textWidth ? 10 : 0) - textWidth) / 2 - (opts.showSpinner && textWidth ? 0 : 5 + textWidth / 2) // only show the text
  22989. + (opts.showSpinner ? 0 : textWidth / 2) // only show the spinner
  22990. + (textWidth ? 0 : r);
  22991. var cy = api.getHeight() / 2;
  22992. opts.showSpinner && arc.setShape({
  22993. cx: cx,
  22994. cy: cy
  22995. });
  22996. labelRect.setShape({
  22997. x: cx - r,
  22998. y: cy - r,
  22999. width: r * 2,
  23000. height: r * 2
  23001. });
  23002. mask.setShape({
  23003. x: 0,
  23004. y: 0,
  23005. width: api.getWidth(),
  23006. height: api.getHeight()
  23007. });
  23008. };
  23009. group.resize();
  23010. return group;
  23011. }
  23012. /*
  23013. * Licensed to the Apache Software Foundation (ASF) under one
  23014. * or more contributor license agreements. See the NOTICE file
  23015. * distributed with this work for additional information
  23016. * regarding copyright ownership. The ASF licenses this file
  23017. * to you under the Apache License, Version 2.0 (the
  23018. * "License"); you may not use this file except in compliance
  23019. * with the License. You may obtain a copy of the License at
  23020. *
  23021. * http://www.apache.org/licenses/LICENSE-2.0
  23022. *
  23023. * Unless required by applicable law or agreed to in writing,
  23024. * software distributed under the License is distributed on an
  23025. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23026. * KIND, either express or implied. See the License for the
  23027. * specific language governing permissions and limitations
  23028. * under the License.
  23029. */
  23030. /**
  23031. * AUTO-GENERATED FILE. DO NOT MODIFY.
  23032. */
  23033. /*
  23034. * Licensed to the Apache Software Foundation (ASF) under one
  23035. * or more contributor license agreements. See the NOTICE file
  23036. * distributed with this work for additional information
  23037. * regarding copyright ownership. The ASF licenses this file
  23038. * to you under the Apache License, Version 2.0 (the
  23039. * "License"); you may not use this file except in compliance
  23040. * with the License. You may obtain a copy of the License at
  23041. *
  23042. * http://www.apache.org/licenses/LICENSE-2.0
  23043. *
  23044. * Unless required by applicable law or agreed to in writing,
  23045. * software distributed under the License is distributed on an
  23046. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23047. * KIND, either express or implied. See the License for the
  23048. * specific language governing permissions and limitations
  23049. * under the License.
  23050. */
  23051. var Scheduler =
  23052. /** @class */
  23053. function () {
  23054. function Scheduler(ecInstance, api, dataProcessorHandlers, visualHandlers) {
  23055. // key: handlerUID
  23056. this._stageTaskMap = createHashMap();
  23057. this.ecInstance = ecInstance;
  23058. this.api = api; // Fix current processors in case that in some rear cases that
  23059. // processors might be registered after echarts instance created.
  23060. // Register processors incrementally for a echarts instance is
  23061. // not supported by this stream architecture.
  23062. dataProcessorHandlers = this._dataProcessorHandlers = dataProcessorHandlers.slice();
  23063. visualHandlers = this._visualHandlers = visualHandlers.slice();
  23064. this._allHandlers = dataProcessorHandlers.concat(visualHandlers);
  23065. }
  23066. Scheduler.prototype.restoreData = function (ecModel, payload) {
  23067. // TODO: Only restore needed series and components, but not all components.
  23068. // Currently `restoreData` of all of the series and component will be called.
  23069. // But some independent components like `title`, `legend`, `graphic`, `toolbox`,
  23070. // `tooltip`, `axisPointer`, etc, do not need series refresh when `setOption`,
  23071. // and some components like coordinate system, axes, dataZoom, visualMap only
  23072. // need their target series refresh.
  23073. // (1) If we are implementing this feature some day, we should consider these cases:
  23074. // if a data processor depends on a component (e.g., dataZoomProcessor depends
  23075. // on the settings of `dataZoom`), it should be re-performed if the component
  23076. // is modified by `setOption`.
  23077. // (2) If a processor depends on sevral series, speicified by its `getTargetSeries`,
  23078. // it should be re-performed when the result array of `getTargetSeries` changed.
  23079. // We use `dependencies` to cover these issues.
  23080. // (3) How to update target series when coordinate system related components modified.
  23081. // TODO: simply the dirty mechanism? Check whether only the case here can set tasks dirty,
  23082. // and this case all of the tasks will be set as dirty.
  23083. ecModel.restoreData(payload); // Theoretically an overall task not only depends on each of its target series, but also
  23084. // depends on all of the series.
  23085. // The overall task is not in pipeline, and `ecModel.restoreData` only set pipeline tasks
  23086. // dirty. If `getTargetSeries` of an overall task returns nothing, we should also ensure
  23087. // that the overall task is set as dirty and to be performed, otherwise it probably cause
  23088. // state chaos. So we have to set dirty of all of the overall tasks manually, otherwise it
  23089. // probably cause state chaos (consider `dataZoomProcessor`).
  23090. this._stageTaskMap.each(function (taskRecord) {
  23091. var overallTask = taskRecord.overallTask;
  23092. overallTask && overallTask.dirty();
  23093. });
  23094. }; // If seriesModel provided, incremental threshold is check by series data.
  23095. Scheduler.prototype.getPerformArgs = function (task, isBlock) {
  23096. // For overall task
  23097. if (!task.__pipeline) {
  23098. return;
  23099. }
  23100. var pipeline = this._pipelineMap.get(task.__pipeline.id);
  23101. var pCtx = pipeline.context;
  23102. var incremental = !isBlock && pipeline.progressiveEnabled && (!pCtx || pCtx.progressiveRender) && task.__idxInPipeline > pipeline.blockIndex;
  23103. var step = incremental ? pipeline.step : null;
  23104. var modDataCount = pCtx && pCtx.modDataCount;
  23105. var modBy = modDataCount != null ? Math.ceil(modDataCount / step) : null;
  23106. return {
  23107. step: step,
  23108. modBy: modBy,
  23109. modDataCount: modDataCount
  23110. };
  23111. };
  23112. Scheduler.prototype.getPipeline = function (pipelineId) {
  23113. return this._pipelineMap.get(pipelineId);
  23114. };
  23115. /**
  23116. * Current, progressive rendering starts from visual and layout.
  23117. * Always detect render mode in the same stage, avoiding that incorrect
  23118. * detection caused by data filtering.
  23119. * Caution:
  23120. * `updateStreamModes` use `seriesModel.getData()`.
  23121. */
  23122. Scheduler.prototype.updateStreamModes = function (seriesModel, view) {
  23123. var pipeline = this._pipelineMap.get(seriesModel.uid);
  23124. var data = seriesModel.getData();
  23125. var dataLen = data.count(); // `progressiveRender` means that can render progressively in each
  23126. // animation frame. Note that some types of series do not provide
  23127. // `view.incrementalPrepareRender` but support `chart.appendData`. We
  23128. // use the term `incremental` but not `progressive` to describe the
  23129. // case that `chart.appendData`.
  23130. var progressiveRender = pipeline.progressiveEnabled && view.incrementalPrepareRender && dataLen >= pipeline.threshold;
  23131. var large = seriesModel.get('large') && dataLen >= seriesModel.get('largeThreshold'); // TODO: modDataCount should not updated if `appendData`, otherwise cause whole repaint.
  23132. // see `test/candlestick-large3.html`
  23133. var modDataCount = seriesModel.get('progressiveChunkMode') === 'mod' ? dataLen : null;
  23134. seriesModel.pipelineContext = pipeline.context = {
  23135. progressiveRender: progressiveRender,
  23136. modDataCount: modDataCount,
  23137. large: large
  23138. };
  23139. };
  23140. Scheduler.prototype.restorePipelines = function (ecModel) {
  23141. var scheduler = this;
  23142. var pipelineMap = scheduler._pipelineMap = createHashMap();
  23143. ecModel.eachSeries(function (seriesModel) {
  23144. var progressive = seriesModel.getProgressive();
  23145. var pipelineId = seriesModel.uid;
  23146. pipelineMap.set(pipelineId, {
  23147. id: pipelineId,
  23148. head: null,
  23149. tail: null,
  23150. threshold: seriesModel.getProgressiveThreshold(),
  23151. progressiveEnabled: progressive && !(seriesModel.preventIncremental && seriesModel.preventIncremental()),
  23152. blockIndex: -1,
  23153. step: Math.round(progressive || 700),
  23154. count: 0
  23155. });
  23156. scheduler._pipe(seriesModel, seriesModel.dataTask);
  23157. });
  23158. };
  23159. Scheduler.prototype.prepareStageTasks = function () {
  23160. var stageTaskMap = this._stageTaskMap;
  23161. var ecModel = this.api.getModel();
  23162. var api = this.api;
  23163. each$1(this._allHandlers, function (handler) {
  23164. var record = stageTaskMap.get(handler.uid) || stageTaskMap.set(handler.uid, {});
  23165. var errMsg = '';
  23166. {
  23167. // Currently do not need to support to sepecify them both.
  23168. errMsg = '"reset" and "overallReset" must not be both specified.';
  23169. }
  23170. assert$1(!(handler.reset && handler.overallReset), errMsg);
  23171. handler.reset && this._createSeriesStageTask(handler, record, ecModel, api);
  23172. handler.overallReset && this._createOverallStageTask(handler, record, ecModel, api);
  23173. }, this);
  23174. };
  23175. Scheduler.prototype.prepareView = function (view, model, ecModel, api) {
  23176. var renderTask = view.renderTask;
  23177. var context = renderTask.context;
  23178. context.model = model;
  23179. context.ecModel = ecModel;
  23180. context.api = api;
  23181. renderTask.__block = !view.incrementalPrepareRender;
  23182. this._pipe(model, renderTask);
  23183. };
  23184. Scheduler.prototype.performDataProcessorTasks = function (ecModel, payload) {
  23185. // If we do not use `block` here, it should be considered when to update modes.
  23186. this._performStageTasks(this._dataProcessorHandlers, ecModel, payload, {
  23187. block: true
  23188. });
  23189. };
  23190. Scheduler.prototype.performVisualTasks = function (ecModel, payload, opt) {
  23191. this._performStageTasks(this._visualHandlers, ecModel, payload, opt);
  23192. };
  23193. Scheduler.prototype._performStageTasks = function (stageHandlers, ecModel, payload, opt) {
  23194. opt = opt || {};
  23195. var unfinished = false;
  23196. var scheduler = this;
  23197. each$1(stageHandlers, function (stageHandler, idx) {
  23198. if (opt.visualType && opt.visualType !== stageHandler.visualType) {
  23199. return;
  23200. }
  23201. var stageHandlerRecord = scheduler._stageTaskMap.get(stageHandler.uid);
  23202. var seriesTaskMap = stageHandlerRecord.seriesTaskMap;
  23203. var overallTask = stageHandlerRecord.overallTask;
  23204. if (overallTask) {
  23205. var overallNeedDirty_1;
  23206. var agentStubMap = overallTask.agentStubMap;
  23207. agentStubMap.each(function (stub) {
  23208. if (needSetDirty(opt, stub)) {
  23209. stub.dirty();
  23210. overallNeedDirty_1 = true;
  23211. }
  23212. });
  23213. overallNeedDirty_1 && overallTask.dirty();
  23214. scheduler.updatePayload(overallTask, payload);
  23215. var performArgs_1 = scheduler.getPerformArgs(overallTask, opt.block); // Execute stubs firstly, which may set the overall task dirty,
  23216. // then execute the overall task. And stub will call seriesModel.setData,
  23217. // which ensures that in the overallTask seriesModel.getData() will not
  23218. // return incorrect data.
  23219. agentStubMap.each(function (stub) {
  23220. stub.perform(performArgs_1);
  23221. });
  23222. if (overallTask.perform(performArgs_1)) {
  23223. unfinished = true;
  23224. }
  23225. } else if (seriesTaskMap) {
  23226. seriesTaskMap.each(function (task, pipelineId) {
  23227. if (needSetDirty(opt, task)) {
  23228. task.dirty();
  23229. }
  23230. var performArgs = scheduler.getPerformArgs(task, opt.block); // FIXME
  23231. // if intending to decalare `performRawSeries` in handlers, only
  23232. // stream-independent (specifically, data item independent) operations can be
  23233. // performed. Because is a series is filtered, most of the tasks will not
  23234. // be performed. A stream-dependent operation probably cause wrong biz logic.
  23235. // Perhaps we should not provide a separate callback for this case instead
  23236. // of providing the config `performRawSeries`. The stream-dependent operaions
  23237. // and stream-independent operations should better not be mixed.
  23238. performArgs.skip = !stageHandler.performRawSeries && ecModel.isSeriesFiltered(task.context.model);
  23239. scheduler.updatePayload(task, payload);
  23240. if (task.perform(performArgs)) {
  23241. unfinished = true;
  23242. }
  23243. });
  23244. }
  23245. });
  23246. function needSetDirty(opt, task) {
  23247. return opt.setDirty && (!opt.dirtyMap || opt.dirtyMap.get(task.__pipeline.id));
  23248. }
  23249. this.unfinished = unfinished || this.unfinished;
  23250. };
  23251. Scheduler.prototype.performSeriesTasks = function (ecModel) {
  23252. var unfinished;
  23253. ecModel.eachSeries(function (seriesModel) {
  23254. // Progress to the end for dataInit and dataRestore.
  23255. unfinished = seriesModel.dataTask.perform() || unfinished;
  23256. });
  23257. this.unfinished = unfinished || this.unfinished;
  23258. };
  23259. Scheduler.prototype.plan = function () {
  23260. // Travel pipelines, check block.
  23261. this._pipelineMap.each(function (pipeline) {
  23262. var task = pipeline.tail;
  23263. do {
  23264. if (task.__block) {
  23265. pipeline.blockIndex = task.__idxInPipeline;
  23266. break;
  23267. }
  23268. task = task.getUpstream();
  23269. } while (task);
  23270. });
  23271. };
  23272. Scheduler.prototype.updatePayload = function (task, payload) {
  23273. payload !== 'remain' && (task.context.payload = payload);
  23274. };
  23275. Scheduler.prototype._createSeriesStageTask = function (stageHandler, stageHandlerRecord, ecModel, api) {
  23276. var scheduler = this;
  23277. var oldSeriesTaskMap = stageHandlerRecord.seriesTaskMap; // The count of stages are totally about only several dozen, so
  23278. // do not need to reuse the map.
  23279. var newSeriesTaskMap = stageHandlerRecord.seriesTaskMap = createHashMap();
  23280. var seriesType = stageHandler.seriesType;
  23281. var getTargetSeries = stageHandler.getTargetSeries; // If a stageHandler should cover all series, `createOnAllSeries` should be declared mandatorily,
  23282. // to avoid some typo or abuse. Otherwise if an extension do not specify a `seriesType`,
  23283. // it works but it may cause other irrelevant charts blocked.
  23284. if (stageHandler.createOnAllSeries) {
  23285. ecModel.eachRawSeries(create);
  23286. } else if (seriesType) {
  23287. ecModel.eachRawSeriesByType(seriesType, create);
  23288. } else if (getTargetSeries) {
  23289. getTargetSeries(ecModel, api).each(create);
  23290. }
  23291. function create(seriesModel) {
  23292. var pipelineId = seriesModel.uid; // Init tasks for each seriesModel only once.
  23293. // Reuse original task instance.
  23294. var task = newSeriesTaskMap.set(pipelineId, oldSeriesTaskMap && oldSeriesTaskMap.get(pipelineId) || createTask({
  23295. plan: seriesTaskPlan,
  23296. reset: seriesTaskReset,
  23297. count: seriesTaskCount
  23298. }));
  23299. task.context = {
  23300. model: seriesModel,
  23301. ecModel: ecModel,
  23302. api: api,
  23303. // PENDING: `useClearVisual` not used?
  23304. useClearVisual: stageHandler.isVisual && !stageHandler.isLayout,
  23305. plan: stageHandler.plan,
  23306. reset: stageHandler.reset,
  23307. scheduler: scheduler
  23308. };
  23309. scheduler._pipe(seriesModel, task);
  23310. }
  23311. };
  23312. Scheduler.prototype._createOverallStageTask = function (stageHandler, stageHandlerRecord, ecModel, api) {
  23313. var scheduler = this;
  23314. var overallTask = stageHandlerRecord.overallTask = stageHandlerRecord.overallTask // For overall task, the function only be called on reset stage.
  23315. || createTask({
  23316. reset: overallTaskReset
  23317. });
  23318. overallTask.context = {
  23319. ecModel: ecModel,
  23320. api: api,
  23321. overallReset: stageHandler.overallReset,
  23322. scheduler: scheduler
  23323. };
  23324. var oldAgentStubMap = overallTask.agentStubMap; // The count of stages are totally about only several dozen, so
  23325. // do not need to reuse the map.
  23326. var newAgentStubMap = overallTask.agentStubMap = createHashMap();
  23327. var seriesType = stageHandler.seriesType;
  23328. var getTargetSeries = stageHandler.getTargetSeries;
  23329. var overallProgress = true;
  23330. var shouldOverallTaskDirty = false; // FIXME:TS never used, so comment it
  23331. // let modifyOutputEnd = stageHandler.modifyOutputEnd;
  23332. // An overall task with seriesType detected or has `getTargetSeries`, we add
  23333. // stub in each pipelines, it will set the overall task dirty when the pipeline
  23334. // progress. Moreover, to avoid call the overall task each frame (too frequent),
  23335. // we set the pipeline block.
  23336. var errMsg = '';
  23337. {
  23338. errMsg = '"createOnAllSeries" do not supported for "overallReset", ' + 'becuase it will block all streams.';
  23339. }
  23340. assert$1(!stageHandler.createOnAllSeries, errMsg);
  23341. if (seriesType) {
  23342. ecModel.eachRawSeriesByType(seriesType, createStub);
  23343. } else if (getTargetSeries) {
  23344. getTargetSeries(ecModel, api).each(createStub);
  23345. } // Otherwise, (usually it is legancy case), the overall task will only be
  23346. // executed when upstream dirty. Otherwise the progressive rendering of all
  23347. // pipelines will be disabled unexpectedly. But it still needs stubs to receive
  23348. // dirty info from upsteam.
  23349. else {
  23350. overallProgress = false;
  23351. each$1(ecModel.getSeries(), createStub);
  23352. }
  23353. function createStub(seriesModel) {
  23354. var pipelineId = seriesModel.uid;
  23355. var stub = newAgentStubMap.set(pipelineId, oldAgentStubMap && oldAgentStubMap.get(pipelineId) || ( // When the result of `getTargetSeries` changed, the overallTask
  23356. // should be set as dirty and re-performed.
  23357. shouldOverallTaskDirty = true, createTask({
  23358. reset: stubReset,
  23359. onDirty: stubOnDirty
  23360. })));
  23361. stub.context = {
  23362. model: seriesModel,
  23363. overallProgress: overallProgress // FIXME:TS never used, so comment it
  23364. // modifyOutputEnd: modifyOutputEnd
  23365. };
  23366. stub.agent = overallTask;
  23367. stub.__block = overallProgress;
  23368. scheduler._pipe(seriesModel, stub);
  23369. }
  23370. if (shouldOverallTaskDirty) {
  23371. overallTask.dirty();
  23372. }
  23373. };
  23374. Scheduler.prototype._pipe = function (seriesModel, task) {
  23375. var pipelineId = seriesModel.uid;
  23376. var pipeline = this._pipelineMap.get(pipelineId);
  23377. !pipeline.head && (pipeline.head = task);
  23378. pipeline.tail && pipeline.tail.pipe(task);
  23379. pipeline.tail = task;
  23380. task.__idxInPipeline = pipeline.count++;
  23381. task.__pipeline = pipeline;
  23382. };
  23383. Scheduler.wrapStageHandler = function (stageHandler, visualType) {
  23384. if (isFunction$1(stageHandler)) {
  23385. stageHandler = {
  23386. overallReset: stageHandler,
  23387. seriesType: detectSeriseType(stageHandler)
  23388. };
  23389. }
  23390. stageHandler.uid = getUID('stageHandler');
  23391. visualType && (stageHandler.visualType = visualType);
  23392. return stageHandler;
  23393. };
  23394. return Scheduler;
  23395. }();
  23396. function overallTaskReset(context) {
  23397. context.overallReset(context.ecModel, context.api, context.payload);
  23398. }
  23399. function stubReset(context) {
  23400. return context.overallProgress && stubProgress;
  23401. }
  23402. function stubProgress() {
  23403. this.agent.dirty();
  23404. this.getDownstream().dirty();
  23405. }
  23406. function stubOnDirty() {
  23407. this.agent && this.agent.dirty();
  23408. }
  23409. function seriesTaskPlan(context) {
  23410. return context.plan ? context.plan(context.model, context.ecModel, context.api, context.payload) : null;
  23411. }
  23412. function seriesTaskReset(context) {
  23413. if (context.useClearVisual) {
  23414. context.data.clearAllVisual();
  23415. }
  23416. var resetDefines = context.resetDefines = normalizeToArray(context.reset(context.model, context.ecModel, context.api, context.payload));
  23417. return resetDefines.length > 1 ? map(resetDefines, function (v, idx) {
  23418. return makeSeriesTaskProgress(idx);
  23419. }) : singleSeriesTaskProgress;
  23420. }
  23421. var singleSeriesTaskProgress = makeSeriesTaskProgress(0);
  23422. function makeSeriesTaskProgress(resetDefineIdx) {
  23423. return function (params, context) {
  23424. var data = context.data;
  23425. var resetDefine = context.resetDefines[resetDefineIdx];
  23426. if (resetDefine && resetDefine.dataEach) {
  23427. for (var i = params.start; i < params.end; i++) {
  23428. resetDefine.dataEach(data, i);
  23429. }
  23430. } else if (resetDefine && resetDefine.progress) {
  23431. resetDefine.progress(params, data);
  23432. }
  23433. };
  23434. }
  23435. function seriesTaskCount(context) {
  23436. return context.data.count();
  23437. }
  23438. /**
  23439. * Only some legacy stage handlers (usually in echarts extensions) are pure function.
  23440. * To ensure that they can work normally, they should work in block mode, that is,
  23441. * they should not be started util the previous tasks finished. So they cause the
  23442. * progressive rendering disabled. We try to detect the series type, to narrow down
  23443. * the block range to only the series type they concern, but not all series.
  23444. */
  23445. function detectSeriseType(legacyFunc) {
  23446. seriesType = null;
  23447. try {
  23448. // Assume there is no async when calling `eachSeriesByType`.
  23449. legacyFunc(ecModelMock, apiMock);
  23450. } catch (e) {}
  23451. return seriesType;
  23452. }
  23453. var ecModelMock = {};
  23454. var apiMock = {};
  23455. var seriesType;
  23456. mockMethods(ecModelMock, GlobalModel);
  23457. mockMethods(apiMock, ExtensionAPI);
  23458. ecModelMock.eachSeriesByType = ecModelMock.eachRawSeriesByType = function (type) {
  23459. seriesType = type;
  23460. };
  23461. ecModelMock.eachComponent = function (cond) {
  23462. if (cond.mainType === 'series' && cond.subType) {
  23463. seriesType = cond.subType;
  23464. }
  23465. };
  23466. function mockMethods(target, Clz) {
  23467. /* eslint-disable */
  23468. for (var name_1 in Clz.prototype) {
  23469. // Do not use hasOwnProperty
  23470. target[name_1] = noop;
  23471. }
  23472. /* eslint-enable */
  23473. }
  23474. /*
  23475. * Licensed to the Apache Software Foundation (ASF) under one
  23476. * or more contributor license agreements. See the NOTICE file
  23477. * distributed with this work for additional information
  23478. * regarding copyright ownership. The ASF licenses this file
  23479. * to you under the Apache License, Version 2.0 (the
  23480. * "License"); you may not use this file except in compliance
  23481. * with the License. You may obtain a copy of the License at
  23482. *
  23483. * http://www.apache.org/licenses/LICENSE-2.0
  23484. *
  23485. * Unless required by applicable law or agreed to in writing,
  23486. * software distributed under the License is distributed on an
  23487. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23488. * KIND, either express or implied. See the License for the
  23489. * specific language governing permissions and limitations
  23490. * under the License.
  23491. */
  23492. /**
  23493. * AUTO-GENERATED FILE. DO NOT MODIFY.
  23494. */
  23495. /*
  23496. * Licensed to the Apache Software Foundation (ASF) under one
  23497. * or more contributor license agreements. See the NOTICE file
  23498. * distributed with this work for additional information
  23499. * regarding copyright ownership. The ASF licenses this file
  23500. * to you under the Apache License, Version 2.0 (the
  23501. * "License"); you may not use this file except in compliance
  23502. * with the License. You may obtain a copy of the License at
  23503. *
  23504. * http://www.apache.org/licenses/LICENSE-2.0
  23505. *
  23506. * Unless required by applicable law or agreed to in writing,
  23507. * software distributed under the License is distributed on an
  23508. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23509. * KIND, either express or implied. See the License for the
  23510. * specific language governing permissions and limitations
  23511. * under the License.
  23512. */
  23513. var colorAll = ['#37A2DA', '#32C5E9', '#67E0E3', '#9FE6B8', '#FFDB5C', '#ff9f7f', '#fb7293', '#E062AE', '#E690D1', '#e7bcf3', '#9d96f5', '#8378EA', '#96BFFF'];
  23514. var lightTheme = {
  23515. color: colorAll,
  23516. colorLayer: [['#37A2DA', '#ffd85c', '#fd7b5f'], ['#37A2DA', '#67E0E3', '#FFDB5C', '#ff9f7f', '#E062AE', '#9d96f5'], ['#37A2DA', '#32C5E9', '#9FE6B8', '#FFDB5C', '#ff9f7f', '#fb7293', '#e7bcf3', '#8378EA', '#96BFFF'], colorAll]
  23517. };
  23518. /*
  23519. * Licensed to the Apache Software Foundation (ASF) under one
  23520. * or more contributor license agreements. See the NOTICE file
  23521. * distributed with this work for additional information
  23522. * regarding copyright ownership. The ASF licenses this file
  23523. * to you under the Apache License, Version 2.0 (the
  23524. * "License"); you may not use this file except in compliance
  23525. * with the License. You may obtain a copy of the License at
  23526. *
  23527. * http://www.apache.org/licenses/LICENSE-2.0
  23528. *
  23529. * Unless required by applicable law or agreed to in writing,
  23530. * software distributed under the License is distributed on an
  23531. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23532. * KIND, either express or implied. See the License for the
  23533. * specific language governing permissions and limitations
  23534. * under the License.
  23535. */
  23536. /**
  23537. * AUTO-GENERATED FILE. DO NOT MODIFY.
  23538. */
  23539. /*
  23540. * Licensed to the Apache Software Foundation (ASF) under one
  23541. * or more contributor license agreements. See the NOTICE file
  23542. * distributed with this work for additional information
  23543. * regarding copyright ownership. The ASF licenses this file
  23544. * to you under the Apache License, Version 2.0 (the
  23545. * "License"); you may not use this file except in compliance
  23546. * with the License. You may obtain a copy of the License at
  23547. *
  23548. * http://www.apache.org/licenses/LICENSE-2.0
  23549. *
  23550. * Unless required by applicable law or agreed to in writing,
  23551. * software distributed under the License is distributed on an
  23552. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23553. * KIND, either express or implied. See the License for the
  23554. * specific language governing permissions and limitations
  23555. * under the License.
  23556. */
  23557. var contrastColor = '#B9B8CE';
  23558. var backgroundColor = '#100C2A';
  23559. var axisCommon = function () {
  23560. return {
  23561. axisLine: {
  23562. lineStyle: {
  23563. color: contrastColor
  23564. }
  23565. },
  23566. splitLine: {
  23567. lineStyle: {
  23568. color: '#484753'
  23569. }
  23570. },
  23571. splitArea: {
  23572. areaStyle: {
  23573. color: ['rgba(255,255,255,0.02)', 'rgba(255,255,255,0.05)']
  23574. }
  23575. },
  23576. minorSplitLine: {
  23577. lineStyle: {
  23578. color: '#20203B'
  23579. }
  23580. }
  23581. };
  23582. };
  23583. var colorPalette = ['#4992ff', '#7cffb2', '#fddd60', '#ff6e76', '#58d9f9', '#05c091', '#ff8a45', '#8d48e3', '#dd79ff'];
  23584. var theme = {
  23585. darkMode: true,
  23586. color: colorPalette,
  23587. backgroundColor: backgroundColor,
  23588. axisPointer: {
  23589. lineStyle: {
  23590. color: '#817f91'
  23591. },
  23592. crossStyle: {
  23593. color: '#817f91'
  23594. },
  23595. label: {
  23596. // TODO Contrast of label backgorundColor
  23597. color: '#fff'
  23598. }
  23599. },
  23600. legend: {
  23601. textStyle: {
  23602. color: contrastColor
  23603. }
  23604. },
  23605. textStyle: {
  23606. color: contrastColor
  23607. },
  23608. title: {
  23609. textStyle: {
  23610. color: '#EEF1FA'
  23611. },
  23612. subtextStyle: {
  23613. color: '#B9B8CE'
  23614. }
  23615. },
  23616. toolbox: {
  23617. iconStyle: {
  23618. borderColor: contrastColor
  23619. }
  23620. },
  23621. dataZoom: {
  23622. borderColor: '#71708A',
  23623. textStyle: {
  23624. color: contrastColor
  23625. },
  23626. brushStyle: {
  23627. color: 'rgba(135,163,206,0.3)'
  23628. },
  23629. handleStyle: {
  23630. color: '#353450',
  23631. borderColor: '#C5CBE3'
  23632. },
  23633. moveHandleStyle: {
  23634. color: '#B0B6C3',
  23635. opacity: 0.3
  23636. },
  23637. fillerColor: 'rgba(135,163,206,0.2)',
  23638. emphasis: {
  23639. handleStyle: {
  23640. borderColor: '#91B7F2',
  23641. color: '#4D587D'
  23642. },
  23643. moveHandleStyle: {
  23644. color: '#636D9A',
  23645. opacity: 0.7
  23646. }
  23647. },
  23648. dataBackground: {
  23649. lineStyle: {
  23650. color: '#71708A',
  23651. width: 1
  23652. },
  23653. areaStyle: {
  23654. color: '#71708A'
  23655. }
  23656. },
  23657. selectedDataBackground: {
  23658. lineStyle: {
  23659. color: '#87A3CE'
  23660. },
  23661. areaStyle: {
  23662. color: '#87A3CE'
  23663. }
  23664. }
  23665. },
  23666. visualMap: {
  23667. textStyle: {
  23668. color: contrastColor
  23669. }
  23670. },
  23671. timeline: {
  23672. lineStyle: {
  23673. color: contrastColor
  23674. },
  23675. label: {
  23676. color: contrastColor
  23677. },
  23678. controlStyle: {
  23679. color: contrastColor,
  23680. borderColor: contrastColor
  23681. }
  23682. },
  23683. calendar: {
  23684. itemStyle: {
  23685. color: backgroundColor
  23686. },
  23687. dayLabel: {
  23688. color: contrastColor
  23689. },
  23690. monthLabel: {
  23691. color: contrastColor
  23692. },
  23693. yearLabel: {
  23694. color: contrastColor
  23695. }
  23696. },
  23697. timeAxis: axisCommon(),
  23698. logAxis: axisCommon(),
  23699. valueAxis: axisCommon(),
  23700. categoryAxis: axisCommon(),
  23701. line: {
  23702. symbol: 'circle'
  23703. },
  23704. graph: {
  23705. color: colorPalette
  23706. },
  23707. gauge: {
  23708. title: {
  23709. color: contrastColor
  23710. },
  23711. axisLine: {
  23712. lineStyle: {
  23713. color: [[1, 'rgba(207,212,219,0.2)']]
  23714. }
  23715. },
  23716. axisLabel: {
  23717. color: contrastColor
  23718. },
  23719. detail: {
  23720. color: '#EEF1FA'
  23721. }
  23722. },
  23723. candlestick: {
  23724. itemStyle: {
  23725. color: '#f64e56',
  23726. color0: '#54ea92',
  23727. borderColor: '#f64e56',
  23728. borderColor0: '#54ea92' // borderColor: '#ca2824',
  23729. // borderColor0: '#09a443'
  23730. }
  23731. }
  23732. };
  23733. theme.categoryAxis.splitLine.show = false;
  23734. /*
  23735. * Licensed to the Apache Software Foundation (ASF) under one
  23736. * or more contributor license agreements. See the NOTICE file
  23737. * distributed with this work for additional information
  23738. * regarding copyright ownership. The ASF licenses this file
  23739. * to you under the Apache License, Version 2.0 (the
  23740. * "License"); you may not use this file except in compliance
  23741. * with the License. You may obtain a copy of the License at
  23742. *
  23743. * http://www.apache.org/licenses/LICENSE-2.0
  23744. *
  23745. * Unless required by applicable law or agreed to in writing,
  23746. * software distributed under the License is distributed on an
  23747. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23748. * KIND, either express or implied. See the License for the
  23749. * specific language governing permissions and limitations
  23750. * under the License.
  23751. */
  23752. /**
  23753. * AUTO-GENERATED FILE. DO NOT MODIFY.
  23754. */
  23755. /*
  23756. * Licensed to the Apache Software Foundation (ASF) under one
  23757. * or more contributor license agreements. See the NOTICE file
  23758. * distributed with this work for additional information
  23759. * regarding copyright ownership. The ASF licenses this file
  23760. * to you under the Apache License, Version 2.0 (the
  23761. * "License"); you may not use this file except in compliance
  23762. * with the License. You may obtain a copy of the License at
  23763. *
  23764. * http://www.apache.org/licenses/LICENSE-2.0
  23765. *
  23766. * Unless required by applicable law or agreed to in writing,
  23767. * software distributed under the License is distributed on an
  23768. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23769. * KIND, either express or implied. See the License for the
  23770. * specific language governing permissions and limitations
  23771. * under the License.
  23772. */
  23773. /**
  23774. * Usage of query:
  23775. * `chart.on('click', query, handler);`
  23776. * The `query` can be:
  23777. * + The component type query string, only `mainType` or `mainType.subType`,
  23778. * like: 'xAxis', 'series', 'xAxis.category' or 'series.line'.
  23779. * + The component query object, like:
  23780. * `{seriesIndex: 2}`, `{seriesName: 'xx'}`, `{seriesId: 'some'}`,
  23781. * `{xAxisIndex: 2}`, `{xAxisName: 'xx'}`, `{xAxisId: 'some'}`.
  23782. * + The data query object, like:
  23783. * `{dataIndex: 123}`, `{dataType: 'link'}`, `{name: 'some'}`.
  23784. * + The other query object (cmponent customized query), like:
  23785. * `{element: 'some'}` (only available in custom series).
  23786. *
  23787. * Caveat: If a prop in the `query` object is `null/undefined`, it is the
  23788. * same as there is no such prop in the `query` object.
  23789. */
  23790. var ECEventProcessor =
  23791. /** @class */
  23792. function () {
  23793. function ECEventProcessor() {}
  23794. ECEventProcessor.prototype.normalizeQuery = function (query) {
  23795. var cptQuery = {};
  23796. var dataQuery = {};
  23797. var otherQuery = {}; // `query` is `mainType` or `mainType.subType` of component.
  23798. if (isString(query)) {
  23799. var condCptType = parseClassType(query); // `.main` and `.sub` may be ''.
  23800. cptQuery.mainType = condCptType.main || null;
  23801. cptQuery.subType = condCptType.sub || null;
  23802. } // `query` is an object, convert to {mainType, index, name, id}.
  23803. else {
  23804. // `xxxIndex`, `xxxName`, `xxxId`, `name`, `dataIndex`, `dataType` is reserved,
  23805. // can not be used in `compomentModel.filterForExposedEvent`.
  23806. var suffixes_1 = ['Index', 'Name', 'Id'];
  23807. var dataKeys_1 = {
  23808. name: 1,
  23809. dataIndex: 1,
  23810. dataType: 1
  23811. };
  23812. each$1(query, function (val, key) {
  23813. var reserved = false;
  23814. for (var i = 0; i < suffixes_1.length; i++) {
  23815. var propSuffix = suffixes_1[i];
  23816. var suffixPos = key.lastIndexOf(propSuffix);
  23817. if (suffixPos > 0 && suffixPos === key.length - propSuffix.length) {
  23818. var mainType = key.slice(0, suffixPos); // Consider `dataIndex`.
  23819. if (mainType !== 'data') {
  23820. cptQuery.mainType = mainType;
  23821. cptQuery[propSuffix.toLowerCase()] = val;
  23822. reserved = true;
  23823. }
  23824. }
  23825. }
  23826. if (dataKeys_1.hasOwnProperty(key)) {
  23827. dataQuery[key] = val;
  23828. reserved = true;
  23829. }
  23830. if (!reserved) {
  23831. otherQuery[key] = val;
  23832. }
  23833. });
  23834. }
  23835. return {
  23836. cptQuery: cptQuery,
  23837. dataQuery: dataQuery,
  23838. otherQuery: otherQuery
  23839. };
  23840. };
  23841. ECEventProcessor.prototype.filter = function (eventType, query) {
  23842. // They should be assigned before each trigger call.
  23843. var eventInfo = this.eventInfo;
  23844. if (!eventInfo) {
  23845. return true;
  23846. }
  23847. var targetEl = eventInfo.targetEl;
  23848. var packedEvent = eventInfo.packedEvent;
  23849. var model = eventInfo.model;
  23850. var view = eventInfo.view; // For event like 'globalout'.
  23851. if (!model || !view) {
  23852. return true;
  23853. }
  23854. var cptQuery = query.cptQuery;
  23855. var dataQuery = query.dataQuery;
  23856. return check(cptQuery, model, 'mainType') && check(cptQuery, model, 'subType') && check(cptQuery, model, 'index', 'componentIndex') && check(cptQuery, model, 'name') && check(cptQuery, model, 'id') && check(dataQuery, packedEvent, 'name') && check(dataQuery, packedEvent, 'dataIndex') && check(dataQuery, packedEvent, 'dataType') && (!view.filterForExposedEvent || view.filterForExposedEvent(eventType, query.otherQuery, targetEl, packedEvent));
  23857. function check(query, host, prop, propOnHost) {
  23858. return query[prop] == null || host[propOnHost || prop] === query[prop];
  23859. }
  23860. };
  23861. ECEventProcessor.prototype.afterTrigger = function () {
  23862. // Make sure the eventInfo wont be used in next trigger.
  23863. this.eventInfo = null;
  23864. };
  23865. return ECEventProcessor;
  23866. }();
  23867. /*
  23868. * Licensed to the Apache Software Foundation (ASF) under one
  23869. * or more contributor license agreements. See the NOTICE file
  23870. * distributed with this work for additional information
  23871. * regarding copyright ownership. The ASF licenses this file
  23872. * to you under the Apache License, Version 2.0 (the
  23873. * "License"); you may not use this file except in compliance
  23874. * with the License. You may obtain a copy of the License at
  23875. *
  23876. * http://www.apache.org/licenses/LICENSE-2.0
  23877. *
  23878. * Unless required by applicable law or agreed to in writing,
  23879. * software distributed under the License is distributed on an
  23880. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23881. * KIND, either express or implied. See the License for the
  23882. * specific language governing permissions and limitations
  23883. * under the License.
  23884. */
  23885. /**
  23886. * AUTO-GENERATED FILE. DO NOT MODIFY.
  23887. */
  23888. /*
  23889. * Licensed to the Apache Software Foundation (ASF) under one
  23890. * or more contributor license agreements. See the NOTICE file
  23891. * distributed with this work for additional information
  23892. * regarding copyright ownership. The ASF licenses this file
  23893. * to you under the Apache License, Version 2.0 (the
  23894. * "License"); you may not use this file except in compliance
  23895. * with the License. You may obtain a copy of the License at
  23896. *
  23897. * http://www.apache.org/licenses/LICENSE-2.0
  23898. *
  23899. * Unless required by applicable law or agreed to in writing,
  23900. * software distributed under the License is distributed on an
  23901. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  23902. * KIND, either express or implied. See the License for the
  23903. * specific language governing permissions and limitations
  23904. * under the License.
  23905. */
  23906. var seriesSymbolTask = {
  23907. createOnAllSeries: true,
  23908. // For legend.
  23909. performRawSeries: true,
  23910. reset: function (seriesModel, ecModel) {
  23911. var data = seriesModel.getData();
  23912. if (seriesModel.legendSymbol) {
  23913. data.setVisual('legendSymbol', seriesModel.legendSymbol);
  23914. }
  23915. if (!seriesModel.hasSymbolVisual) {
  23916. return;
  23917. }
  23918. var symbolType = seriesModel.get('symbol');
  23919. var symbolSize = seriesModel.get('symbolSize');
  23920. var keepAspect = seriesModel.get('symbolKeepAspect');
  23921. var symbolRotate = seriesModel.get('symbolRotate');
  23922. var symbolOffset = seriesModel.get('symbolOffset');
  23923. var hasSymbolTypeCallback = isFunction$1(symbolType);
  23924. var hasSymbolSizeCallback = isFunction$1(symbolSize);
  23925. var hasSymbolRotateCallback = isFunction$1(symbolRotate);
  23926. var hasSymbolOffsetCallback = isFunction$1(symbolOffset);
  23927. var hasCallback = hasSymbolTypeCallback || hasSymbolSizeCallback || hasSymbolRotateCallback || hasSymbolOffsetCallback;
  23928. var seriesSymbol = !hasSymbolTypeCallback && symbolType ? symbolType : seriesModel.defaultSymbol;
  23929. var seriesSymbolSize = !hasSymbolSizeCallback ? symbolSize : null;
  23930. var seriesSymbolRotate = !hasSymbolRotateCallback ? symbolRotate : null;
  23931. var seriesSymbolOffset = !hasSymbolOffsetCallback ? symbolOffset : null;
  23932. data.setVisual({
  23933. legendSymbol: seriesModel.legendSymbol || seriesSymbol,
  23934. // If seting callback functions on `symbol` or `symbolSize`, for simplicity and avoiding
  23935. // to bring trouble, we do not pick a reuslt from one of its calling on data item here,
  23936. // but just use the default value. Callback on `symbol` or `symbolSize` is convenient in
  23937. // some cases but generally it is not recommanded.
  23938. symbol: seriesSymbol,
  23939. symbolSize: seriesSymbolSize,
  23940. symbolKeepAspect: keepAspect,
  23941. symbolRotate: seriesSymbolRotate,
  23942. symbolOffset: seriesSymbolOffset
  23943. }); // Only visible series has each data be visual encoded
  23944. if (ecModel.isSeriesFiltered(seriesModel)) {
  23945. return;
  23946. }
  23947. function dataEach(data, idx) {
  23948. var rawValue = seriesModel.getRawValue(idx);
  23949. var params = seriesModel.getDataParams(idx);
  23950. hasSymbolTypeCallback && data.setItemVisual(idx, 'symbol', symbolType(rawValue, params));
  23951. hasSymbolSizeCallback && data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  23952. hasSymbolRotateCallback && data.setItemVisual(idx, 'symbolRotate', symbolRotate(rawValue, params));
  23953. hasSymbolOffsetCallback && data.setItemVisual(idx, 'symbolOffset', symbolOffset(rawValue, params));
  23954. }
  23955. return {
  23956. dataEach: hasCallback ? dataEach : null
  23957. };
  23958. }
  23959. };
  23960. var dataSymbolTask = {
  23961. createOnAllSeries: true,
  23962. // For legend.
  23963. performRawSeries: true,
  23964. reset: function (seriesModel, ecModel) {
  23965. if (!seriesModel.hasSymbolVisual) {
  23966. return;
  23967. } // Only visible series has each data be visual encoded
  23968. if (ecModel.isSeriesFiltered(seriesModel)) {
  23969. return;
  23970. }
  23971. var data = seriesModel.getData();
  23972. function dataEach(data, idx) {
  23973. var itemModel = data.getItemModel(idx);
  23974. var itemSymbolType = itemModel.getShallow('symbol', true);
  23975. var itemSymbolSize = itemModel.getShallow('symbolSize', true);
  23976. var itemSymbolRotate = itemModel.getShallow('symbolRotate', true);
  23977. var itemSymbolOffset = itemModel.getShallow('symbolOffset', true);
  23978. var itemSymbolKeepAspect = itemModel.getShallow('symbolKeepAspect', true); // If has item symbol
  23979. if (itemSymbolType != null) {
  23980. data.setItemVisual(idx, 'symbol', itemSymbolType);
  23981. }
  23982. if (itemSymbolSize != null) {
  23983. // PENDING Transform symbolSize ?
  23984. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  23985. }
  23986. if (itemSymbolRotate != null) {
  23987. data.setItemVisual(idx, 'symbolRotate', itemSymbolRotate);
  23988. }
  23989. if (itemSymbolOffset != null) {
  23990. data.setItemVisual(idx, 'symbolOffset', itemSymbolOffset);
  23991. }
  23992. if (itemSymbolKeepAspect != null) {
  23993. data.setItemVisual(idx, 'symbolKeepAspect', itemSymbolKeepAspect);
  23994. }
  23995. }
  23996. return {
  23997. dataEach: data.hasItemOption ? dataEach : null
  23998. };
  23999. }
  24000. };
  24001. /*
  24002. * Licensed to the Apache Software Foundation (ASF) under one
  24003. * or more contributor license agreements. See the NOTICE file
  24004. * distributed with this work for additional information
  24005. * regarding copyright ownership. The ASF licenses this file
  24006. * to you under the Apache License, Version 2.0 (the
  24007. * "License"); you may not use this file except in compliance
  24008. * with the License. You may obtain a copy of the License at
  24009. *
  24010. * http://www.apache.org/licenses/LICENSE-2.0
  24011. *
  24012. * Unless required by applicable law or agreed to in writing,
  24013. * software distributed under the License is distributed on an
  24014. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24015. * KIND, either express or implied. See the License for the
  24016. * specific language governing permissions and limitations
  24017. * under the License.
  24018. */
  24019. /**
  24020. * AUTO-GENERATED FILE. DO NOT MODIFY.
  24021. */
  24022. /*
  24023. * Licensed to the Apache Software Foundation (ASF) under one
  24024. * or more contributor license agreements. See the NOTICE file
  24025. * distributed with this work for additional information
  24026. * regarding copyright ownership. The ASF licenses this file
  24027. * to you under the Apache License, Version 2.0 (the
  24028. * "License"); you may not use this file except in compliance
  24029. * with the License. You may obtain a copy of the License at
  24030. *
  24031. * http://www.apache.org/licenses/LICENSE-2.0
  24032. *
  24033. * Unless required by applicable law or agreed to in writing,
  24034. * software distributed under the License is distributed on an
  24035. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24036. * KIND, either express or implied. See the License for the
  24037. * specific language governing permissions and limitations
  24038. * under the License.
  24039. */
  24040. function getItemVisualFromData(data, dataIndex, key) {
  24041. switch (key) {
  24042. case 'color':
  24043. var style = data.getItemVisual(dataIndex, 'style');
  24044. return style[data.getVisual('drawType')];
  24045. case 'opacity':
  24046. return data.getItemVisual(dataIndex, 'style').opacity;
  24047. case 'symbol':
  24048. case 'symbolSize':
  24049. case 'liftZ':
  24050. return data.getItemVisual(dataIndex, key);
  24051. default:
  24052. {
  24053. console.warn("Unknown visual type " + key);
  24054. }
  24055. }
  24056. }
  24057. function getVisualFromData(data, key) {
  24058. switch (key) {
  24059. case 'color':
  24060. var style = data.getVisual('style');
  24061. return style[data.getVisual('drawType')];
  24062. case 'opacity':
  24063. return data.getVisual('style').opacity;
  24064. case 'symbol':
  24065. case 'symbolSize':
  24066. case 'liftZ':
  24067. return data.getVisual(key);
  24068. default:
  24069. {
  24070. console.warn("Unknown visual type " + key);
  24071. }
  24072. }
  24073. }
  24074. function setItemVisualFromData(data, dataIndex, key, value) {
  24075. switch (key) {
  24076. case 'color':
  24077. // Make sure not sharing style object.
  24078. var style = data.ensureUniqueItemVisual(dataIndex, 'style');
  24079. style[data.getVisual('drawType')] = value; // Mark the color has been changed, not from palette anymore
  24080. data.setItemVisual(dataIndex, 'colorFromPalette', false);
  24081. break;
  24082. case 'opacity':
  24083. data.ensureUniqueItemVisual(dataIndex, 'style').opacity = value;
  24084. break;
  24085. case 'symbol':
  24086. case 'symbolSize':
  24087. case 'liftZ':
  24088. data.setItemVisual(dataIndex, key, value);
  24089. break;
  24090. default:
  24091. {
  24092. console.warn("Unknown visual type " + key);
  24093. }
  24094. }
  24095. }
  24096. /*
  24097. * Licensed to the Apache Software Foundation (ASF) under one
  24098. * or more contributor license agreements. See the NOTICE file
  24099. * distributed with this work for additional information
  24100. * regarding copyright ownership. The ASF licenses this file
  24101. * to you under the Apache License, Version 2.0 (the
  24102. * "License"); you may not use this file except in compliance
  24103. * with the License. You may obtain a copy of the License at
  24104. *
  24105. * http://www.apache.org/licenses/LICENSE-2.0
  24106. *
  24107. * Unless required by applicable law or agreed to in writing,
  24108. * software distributed under the License is distributed on an
  24109. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24110. * KIND, either express or implied. See the License for the
  24111. * specific language governing permissions and limitations
  24112. * under the License.
  24113. */
  24114. /**
  24115. * AUTO-GENERATED FILE. DO NOT MODIFY.
  24116. */
  24117. /*
  24118. * Licensed to the Apache Software Foundation (ASF) under one
  24119. * or more contributor license agreements. See the NOTICE file
  24120. * distributed with this work for additional information
  24121. * regarding copyright ownership. The ASF licenses this file
  24122. * to you under the Apache License, Version 2.0 (the
  24123. * "License"); you may not use this file except in compliance
  24124. * with the License. You may obtain a copy of the License at
  24125. *
  24126. * http://www.apache.org/licenses/LICENSE-2.0
  24127. *
  24128. * Unless required by applicable law or agreed to in writing,
  24129. * software distributed under the License is distributed on an
  24130. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24131. * KIND, either express or implied. See the License for the
  24132. * specific language governing permissions and limitations
  24133. * under the License.
  24134. */
  24135. var PI2$6 = Math.PI * 2;
  24136. var CMD$3 = PathProxy.CMD;
  24137. var DEFAULT_SEARCH_SPACE = ['top', 'right', 'bottom', 'left'];
  24138. function getCandidateAnchor(pos, distance$$1, rect, outPt, outDir) {
  24139. var width = rect.width;
  24140. var height = rect.height;
  24141. switch (pos) {
  24142. case 'top':
  24143. outPt.set(rect.x + width / 2, rect.y - distance$$1);
  24144. outDir.set(0, -1);
  24145. break;
  24146. case 'bottom':
  24147. outPt.set(rect.x + width / 2, rect.y + height + distance$$1);
  24148. outDir.set(0, 1);
  24149. break;
  24150. case 'left':
  24151. outPt.set(rect.x - distance$$1, rect.y + height / 2);
  24152. outDir.set(-1, 0);
  24153. break;
  24154. case 'right':
  24155. outPt.set(rect.x + width + distance$$1, rect.y + height / 2);
  24156. outDir.set(1, 0);
  24157. break;
  24158. }
  24159. }
  24160. function projectPointToArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y, out) {
  24161. x -= cx;
  24162. y -= cy;
  24163. var d = Math.sqrt(x * x + y * y);
  24164. x /= d;
  24165. y /= d; // Intersect point.
  24166. var ox = x * r + cx;
  24167. var oy = y * r + cy;
  24168. if (Math.abs(startAngle - endAngle) % PI2$6 < 1e-4) {
  24169. // Is a circle
  24170. out[0] = ox;
  24171. out[1] = oy;
  24172. return d - r;
  24173. }
  24174. if (anticlockwise) {
  24175. var tmp = startAngle;
  24176. startAngle = normalizeRadian(endAngle);
  24177. endAngle = normalizeRadian(tmp);
  24178. } else {
  24179. startAngle = normalizeRadian(startAngle);
  24180. endAngle = normalizeRadian(endAngle);
  24181. }
  24182. if (startAngle > endAngle) {
  24183. endAngle += PI2$6;
  24184. }
  24185. var angle = Math.atan2(y, x);
  24186. if (angle < 0) {
  24187. angle += PI2$6;
  24188. }
  24189. if (angle >= startAngle && angle <= endAngle || angle + PI2$6 >= startAngle && angle + PI2$6 <= endAngle) {
  24190. // Project point is on the arc.
  24191. out[0] = ox;
  24192. out[1] = oy;
  24193. return d - r;
  24194. }
  24195. var x1 = r * Math.cos(startAngle) + cx;
  24196. var y1 = r * Math.sin(startAngle) + cy;
  24197. var x2 = r * Math.cos(endAngle) + cx;
  24198. var y2 = r * Math.sin(endAngle) + cy;
  24199. var d1 = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y);
  24200. var d2 = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y);
  24201. if (d1 < d2) {
  24202. out[0] = x1;
  24203. out[1] = y1;
  24204. return Math.sqrt(d1);
  24205. } else {
  24206. out[0] = x2;
  24207. out[1] = y2;
  24208. return Math.sqrt(d2);
  24209. }
  24210. }
  24211. function projectPointToLine(x1, y1, x2, y2, x, y, out, limitToEnds) {
  24212. var dx = x - x1;
  24213. var dy = y - y1;
  24214. var dx1 = x2 - x1;
  24215. var dy1 = y2 - y1;
  24216. var lineLen = Math.sqrt(dx1 * dx1 + dy1 * dy1);
  24217. dx1 /= lineLen;
  24218. dy1 /= lineLen; // dot product
  24219. var projectedLen = dx * dx1 + dy * dy1;
  24220. var t = projectedLen / lineLen;
  24221. if (limitToEnds) {
  24222. t = Math.min(Math.max(t, 0), 1);
  24223. }
  24224. t *= lineLen;
  24225. var ox = out[0] = x1 + t * dx1;
  24226. var oy = out[1] = y1 + t * dy1;
  24227. return Math.sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y));
  24228. }
  24229. function projectPointToRect(x1, y1, width, height, x, y, out) {
  24230. if (width < 0) {
  24231. x1 = x1 + width;
  24232. width = -width;
  24233. }
  24234. if (height < 0) {
  24235. y1 = y1 + height;
  24236. height = -height;
  24237. }
  24238. var x2 = x1 + width;
  24239. var y2 = y1 + height;
  24240. var ox = out[0] = Math.min(Math.max(x, x1), x2);
  24241. var oy = out[1] = Math.min(Math.max(y, y1), y2);
  24242. return Math.sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y));
  24243. }
  24244. var tmpPt = [];
  24245. function nearestPointOnRect(pt, rect, out) {
  24246. var dist$$1 = projectPointToRect(rect.x, rect.y, rect.width, rect.height, pt.x, pt.y, tmpPt);
  24247. out.set(tmpPt[0], tmpPt[1]);
  24248. return dist$$1;
  24249. }
  24250. /**
  24251. * Calculate min distance corresponding point.
  24252. * This method won't evaluate if point is in the path.
  24253. */
  24254. function nearestPointOnPath(pt, path, out) {
  24255. var xi = 0;
  24256. var yi = 0;
  24257. var x0 = 0;
  24258. var y0 = 0;
  24259. var x1;
  24260. var y1;
  24261. var minDist = Infinity;
  24262. var data = path.data;
  24263. var x = pt.x;
  24264. var y = pt.y;
  24265. for (var i = 0; i < data.length;) {
  24266. var cmd = data[i++];
  24267. if (i === 1) {
  24268. xi = data[i];
  24269. yi = data[i + 1];
  24270. x0 = xi;
  24271. y0 = yi;
  24272. }
  24273. var d = minDist;
  24274. switch (cmd) {
  24275. case CMD$3.M:
  24276. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  24277. // 在 closePath 的时候使用
  24278. x0 = data[i++];
  24279. y0 = data[i++];
  24280. xi = x0;
  24281. yi = y0;
  24282. break;
  24283. case CMD$3.L:
  24284. d = projectPointToLine(xi, yi, data[i], data[i + 1], x, y, tmpPt, true);
  24285. xi = data[i++];
  24286. yi = data[i++];
  24287. break;
  24288. case CMD$3.C:
  24289. d = cubicProjectPoint(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], x, y, tmpPt);
  24290. xi = data[i++];
  24291. yi = data[i++];
  24292. break;
  24293. case CMD$3.Q:
  24294. d = quadraticProjectPoint(xi, yi, data[i++], data[i++], data[i], data[i + 1], x, y, tmpPt);
  24295. xi = data[i++];
  24296. yi = data[i++];
  24297. break;
  24298. case CMD$3.A:
  24299. // TODO Arc 判断的开销比较大
  24300. var cx = data[i++];
  24301. var cy = data[i++];
  24302. var rx = data[i++];
  24303. var ry = data[i++];
  24304. var theta = data[i++];
  24305. var dTheta = data[i++]; // TODO Arc 旋转
  24306. i += 1;
  24307. var anticlockwise = !!(1 - data[i++]);
  24308. x1 = Math.cos(theta) * rx + cx;
  24309. y1 = Math.sin(theta) * ry + cy; // 不是直接使用 arc 命令
  24310. if (i <= 1) {
  24311. // 第一个命令起点还未定义
  24312. x0 = x1;
  24313. y0 = y1;
  24314. } // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  24315. var _x = (x - cx) * ry / rx + cx;
  24316. d = projectPointToArc(cx, cy, ry, theta, theta + dTheta, anticlockwise, _x, y, tmpPt);
  24317. xi = Math.cos(theta + dTheta) * rx + cx;
  24318. yi = Math.sin(theta + dTheta) * ry + cy;
  24319. break;
  24320. case CMD$3.R:
  24321. x0 = xi = data[i++];
  24322. y0 = yi = data[i++];
  24323. var width = data[i++];
  24324. var height = data[i++];
  24325. d = projectPointToRect(x0, y0, width, height, x, y, tmpPt);
  24326. break;
  24327. case CMD$3.Z:
  24328. d = projectPointToLine(xi, yi, x0, y0, x, y, tmpPt, true);
  24329. xi = x0;
  24330. yi = y0;
  24331. break;
  24332. }
  24333. if (d < minDist) {
  24334. minDist = d;
  24335. out.set(tmpPt[0], tmpPt[1]);
  24336. }
  24337. }
  24338. return minDist;
  24339. } // Temporal varible for intermediate usage.
  24340. var pt0 = new Point();
  24341. var pt1 = new Point();
  24342. var pt2 = new Point();
  24343. var dir = new Point();
  24344. var dir2 = new Point();
  24345. /**
  24346. * Calculate a proper guide line based on the label position and graphic element definition
  24347. * @param label
  24348. * @param labelRect
  24349. * @param target
  24350. * @param targetRect
  24351. */
  24352. function updateLabelLinePoints(target, labelLineModel) {
  24353. if (!target) {
  24354. return;
  24355. }
  24356. var labelLine = target.getTextGuideLine();
  24357. var label = target.getTextContent(); // Needs to create text guide in each charts.
  24358. if (!(label && labelLine)) {
  24359. return;
  24360. }
  24361. var labelGuideConfig = target.textGuideLineConfig || {};
  24362. var points = [[0, 0], [0, 0], [0, 0]];
  24363. var searchSpace = labelGuideConfig.candidates || DEFAULT_SEARCH_SPACE;
  24364. var labelRect = label.getBoundingRect().clone();
  24365. labelRect.applyTransform(label.getComputedTransform());
  24366. var minDist = Infinity;
  24367. var anchorPoint = labelGuideConfig.anchor;
  24368. var targetTransform = target.getComputedTransform();
  24369. var targetInversedTransform = targetTransform && invert([], targetTransform);
  24370. var len$$1 = labelLineModel.get('length2') || 0;
  24371. if (anchorPoint) {
  24372. pt2.copy(anchorPoint);
  24373. }
  24374. for (var i = 0; i < searchSpace.length; i++) {
  24375. var candidate = searchSpace[i];
  24376. getCandidateAnchor(candidate, 0, labelRect, pt0, dir);
  24377. Point.scaleAndAdd(pt1, pt0, dir, len$$1); // Transform to target coord space.
  24378. pt1.transform(targetInversedTransform); // Note: getBoundingRect will ensure the `path` being created.
  24379. var boundingRect = target.getBoundingRect();
  24380. var dist$$1 = anchorPoint ? anchorPoint.distance(pt1) : target instanceof Path ? nearestPointOnPath(pt1, target.path, pt2) : nearestPointOnRect(pt1, boundingRect, pt2); // TODO pt2 is in the path
  24381. if (dist$$1 < minDist) {
  24382. minDist = dist$$1; // Transform back to global space.
  24383. pt1.transform(targetTransform);
  24384. pt2.transform(targetTransform);
  24385. pt2.toArray(points[0]);
  24386. pt1.toArray(points[1]);
  24387. pt0.toArray(points[2]);
  24388. }
  24389. }
  24390. limitTurnAngle(points, labelLineModel.get('minTurnAngle'));
  24391. labelLine.setShape({
  24392. points: points
  24393. });
  24394. } // Temporal variable for the limitTurnAngle function
  24395. var tmpArr = [];
  24396. var tmpProjPoint = new Point();
  24397. /**
  24398. * Reduce the line segment attached to the label to limit the turn angle between two segments.
  24399. * @param linePoints
  24400. * @param minTurnAngle Radian of minimum turn angle. 0 - 180
  24401. */
  24402. function limitTurnAngle(linePoints, minTurnAngle) {
  24403. if (!(minTurnAngle <= 180 && minTurnAngle > 0)) {
  24404. return;
  24405. }
  24406. minTurnAngle = minTurnAngle / 180 * Math.PI; // The line points can be
  24407. // /pt1----pt2 (label)
  24408. // /
  24409. // pt0/
  24410. pt0.fromArray(linePoints[0]);
  24411. pt1.fromArray(linePoints[1]);
  24412. pt2.fromArray(linePoints[2]);
  24413. Point.sub(dir, pt0, pt1);
  24414. Point.sub(dir2, pt2, pt1);
  24415. var len1 = dir.len();
  24416. var len2 = dir2.len();
  24417. if (len1 < 1e-3 || len2 < 1e-3) {
  24418. return;
  24419. }
  24420. dir.scale(1 / len1);
  24421. dir2.scale(1 / len2);
  24422. var angleCos = dir.dot(dir2);
  24423. var minTurnAngleCos = Math.cos(minTurnAngle);
  24424. if (minTurnAngleCos < angleCos) {
  24425. // Smaller than minTurnAngle
  24426. // Calculate project point of pt0 on pt1-pt2
  24427. var d = projectPointToLine(pt1.x, pt1.y, pt2.x, pt2.y, pt0.x, pt0.y, tmpArr, false);
  24428. tmpProjPoint.fromArray(tmpArr); // Calculate new projected length with limited minTurnAngle and get the new connect point
  24429. tmpProjPoint.scaleAndAdd(dir2, d / Math.tan(Math.PI - minTurnAngle)); // Limit the new calculated connect point between pt1 and pt2.
  24430. var t = pt2.x !== pt1.x ? (tmpProjPoint.x - pt1.x) / (pt2.x - pt1.x) : (tmpProjPoint.y - pt1.y) / (pt2.y - pt1.y);
  24431. if (isNaN(t)) {
  24432. return;
  24433. }
  24434. if (t < 0) {
  24435. Point.copy(tmpProjPoint, pt1);
  24436. } else if (t > 1) {
  24437. Point.copy(tmpProjPoint, pt2);
  24438. }
  24439. tmpProjPoint.toArray(linePoints[1]);
  24440. }
  24441. }
  24442. /**
  24443. * Limit the angle of line and the surface
  24444. * @param maxSurfaceAngle Radian of minimum turn angle. 0 - 180. 0 is same direction to normal. 180 is opposite
  24445. */
  24446. function limitSurfaceAngle(linePoints, surfaceNormal, maxSurfaceAngle) {
  24447. if (!(maxSurfaceAngle <= 180 && maxSurfaceAngle > 0)) {
  24448. return;
  24449. }
  24450. maxSurfaceAngle = maxSurfaceAngle / 180 * Math.PI;
  24451. pt0.fromArray(linePoints[0]);
  24452. pt1.fromArray(linePoints[1]);
  24453. pt2.fromArray(linePoints[2]);
  24454. Point.sub(dir, pt1, pt0);
  24455. Point.sub(dir2, pt2, pt1);
  24456. var len1 = dir.len();
  24457. var len2 = dir2.len();
  24458. if (len1 < 1e-3 || len2 < 1e-3) {
  24459. return;
  24460. }
  24461. dir.scale(1 / len1);
  24462. dir2.scale(1 / len2);
  24463. var angleCos = dir.dot(surfaceNormal);
  24464. var maxSurfaceAngleCos = Math.cos(maxSurfaceAngle);
  24465. if (angleCos < maxSurfaceAngleCos) {
  24466. // Calculate project point of pt0 on pt1-pt2
  24467. var d = projectPointToLine(pt1.x, pt1.y, pt2.x, pt2.y, pt0.x, pt0.y, tmpArr, false);
  24468. tmpProjPoint.fromArray(tmpArr);
  24469. var HALF_PI = Math.PI / 2;
  24470. var angle2 = Math.acos(dir2.dot(surfaceNormal));
  24471. var newAngle = HALF_PI + angle2 - maxSurfaceAngle;
  24472. if (newAngle >= HALF_PI) {
  24473. // parallel
  24474. Point.copy(tmpProjPoint, pt2);
  24475. } else {
  24476. // Calculate new projected length with limited minTurnAngle and get the new connect point
  24477. tmpProjPoint.scaleAndAdd(dir2, d / Math.tan(Math.PI / 2 - newAngle)); // Limit the new calculated connect point between pt1 and pt2.
  24478. var t = pt2.x !== pt1.x ? (tmpProjPoint.x - pt1.x) / (pt2.x - pt1.x) : (tmpProjPoint.y - pt1.y) / (pt2.y - pt1.y);
  24479. if (isNaN(t)) {
  24480. return;
  24481. }
  24482. if (t < 0) {
  24483. Point.copy(tmpProjPoint, pt1);
  24484. } else if (t > 1) {
  24485. Point.copy(tmpProjPoint, pt2);
  24486. }
  24487. }
  24488. tmpProjPoint.toArray(linePoints[1]);
  24489. }
  24490. }
  24491. function setLabelLineState(labelLine, ignore, stateName, stateModel) {
  24492. var isNormal = stateName === 'normal';
  24493. var stateObj = isNormal ? labelLine : labelLine.ensureState(stateName); // Make sure display.
  24494. stateObj.ignore = ignore; // Set smooth
  24495. var smooth = stateModel.get('smooth');
  24496. if (smooth && smooth === true) {
  24497. smooth = 0.3;
  24498. }
  24499. stateObj.shape = stateObj.shape || {};
  24500. if (smooth > 0) {
  24501. stateObj.shape.smooth = smooth;
  24502. }
  24503. var styleObj = stateModel.getModel('lineStyle').getLineStyle();
  24504. isNormal ? labelLine.useStyle(styleObj) : stateObj.style = styleObj;
  24505. }
  24506. function buildLabelLinePath(path, shape) {
  24507. var smooth = shape.smooth;
  24508. var points = shape.points;
  24509. if (!points) {
  24510. return;
  24511. }
  24512. path.moveTo(points[0][0], points[0][1]);
  24513. if (smooth > 0 && points.length >= 3) {
  24514. var len1 = dist(points[0], points[1]);
  24515. var len2 = dist(points[1], points[2]);
  24516. if (!len1 || !len2) {
  24517. path.lineTo(points[1][0], points[1][1]);
  24518. path.lineTo(points[2][0], points[2][1]);
  24519. return;
  24520. }
  24521. var moveLen = Math.min(len1, len2) * smooth;
  24522. var midPoint0 = lerp([], points[1], points[0], moveLen / len1);
  24523. var midPoint2 = lerp([], points[1], points[2], moveLen / len2);
  24524. var midPoint1 = lerp([], midPoint0, midPoint2, 0.5);
  24525. path.bezierCurveTo(midPoint0[0], midPoint0[1], midPoint0[0], midPoint0[1], midPoint1[0], midPoint1[1]);
  24526. path.bezierCurveTo(midPoint2[0], midPoint2[1], midPoint2[0], midPoint2[1], points[2][0], points[2][1]);
  24527. } else {
  24528. for (var i = 1; i < points.length; i++) {
  24529. path.lineTo(points[i][0], points[i][1]);
  24530. }
  24531. }
  24532. }
  24533. /**
  24534. * Create a label line if necessary and set it's style.
  24535. */
  24536. function setLabelLineStyle(targetEl, statesModels, defaultStyle) {
  24537. var labelLine = targetEl.getTextGuideLine();
  24538. var label = targetEl.getTextContent();
  24539. if (!label) {
  24540. // Not show label line if there is no label.
  24541. if (labelLine) {
  24542. targetEl.removeTextGuideLine();
  24543. }
  24544. return;
  24545. }
  24546. var normalModel = statesModels.normal;
  24547. var showNormal = normalModel.get('show');
  24548. var labelIgnoreNormal = label.ignore;
  24549. for (var i = 0; i < DISPLAY_STATES.length; i++) {
  24550. var stateName = DISPLAY_STATES[i];
  24551. var stateModel = statesModels[stateName];
  24552. var isNormal = stateName === 'normal';
  24553. if (stateModel) {
  24554. var stateShow = stateModel.get('show');
  24555. var isLabelIgnored = isNormal ? labelIgnoreNormal : retrieve2(label.states[stateName] && label.states[stateName].ignore, labelIgnoreNormal);
  24556. if (isLabelIgnored // Not show when label is not shown in this state.
  24557. || !retrieve2(stateShow, showNormal) // Use normal state by default if not set.
  24558. ) {
  24559. var stateObj = isNormal ? labelLine : labelLine && labelLine.states.normal;
  24560. if (stateObj) {
  24561. stateObj.ignore = true;
  24562. }
  24563. continue;
  24564. } // Create labelLine if not exists
  24565. if (!labelLine) {
  24566. labelLine = new Polyline();
  24567. targetEl.setTextGuideLine(labelLine); // Reset state of normal because it's new created.
  24568. // NOTE: NORMAL should always been the first!
  24569. if (!isNormal && (labelIgnoreNormal || !showNormal)) {
  24570. setLabelLineState(labelLine, true, 'normal', statesModels.normal);
  24571. } // Use same state proxy.
  24572. if (targetEl.stateProxy) {
  24573. labelLine.stateProxy = targetEl.stateProxy;
  24574. }
  24575. }
  24576. setLabelLineState(labelLine, false, stateName, stateModel);
  24577. }
  24578. }
  24579. if (labelLine) {
  24580. defaults(labelLine.style, defaultStyle); // Not fill.
  24581. labelLine.style.fill = null;
  24582. var showAbove = normalModel.get('showAbove');
  24583. var labelLineConfig = targetEl.textGuideLineConfig = targetEl.textGuideLineConfig || {};
  24584. labelLineConfig.showAbove = showAbove || false; // Custom the buildPath.
  24585. labelLine.buildPath = buildLabelLinePath;
  24586. }
  24587. }
  24588. function getLabelLineStatesModels(itemModel, labelLineName) {
  24589. labelLineName = labelLineName || 'labelLine';
  24590. var statesModels = {
  24591. normal: itemModel.getModel(labelLineName)
  24592. };
  24593. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  24594. var stateName = SPECIAL_STATES[i];
  24595. statesModels[stateName] = itemModel.getModel([stateName, labelLineName]);
  24596. }
  24597. return statesModels;
  24598. }
  24599. /*
  24600. * Licensed to the Apache Software Foundation (ASF) under one
  24601. * or more contributor license agreements. See the NOTICE file
  24602. * distributed with this work for additional information
  24603. * regarding copyright ownership. The ASF licenses this file
  24604. * to you under the Apache License, Version 2.0 (the
  24605. * "License"); you may not use this file except in compliance
  24606. * with the License. You may obtain a copy of the License at
  24607. *
  24608. * http://www.apache.org/licenses/LICENSE-2.0
  24609. *
  24610. * Unless required by applicable law or agreed to in writing,
  24611. * software distributed under the License is distributed on an
  24612. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24613. * KIND, either express or implied. See the License for the
  24614. * specific language governing permissions and limitations
  24615. * under the License.
  24616. */
  24617. /**
  24618. * AUTO-GENERATED FILE. DO NOT MODIFY.
  24619. */
  24620. /*
  24621. * Licensed to the Apache Software Foundation (ASF) under one
  24622. * or more contributor license agreements. See the NOTICE file
  24623. * distributed with this work for additional information
  24624. * regarding copyright ownership. The ASF licenses this file
  24625. * to you under the Apache License, Version 2.0 (the
  24626. * "License"); you may not use this file except in compliance
  24627. * with the License. You may obtain a copy of the License at
  24628. *
  24629. * http://www.apache.org/licenses/LICENSE-2.0
  24630. *
  24631. * Unless required by applicable law or agreed to in writing,
  24632. * software distributed under the License is distributed on an
  24633. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24634. * KIND, either express or implied. See the License for the
  24635. * specific language governing permissions and limitations
  24636. * under the License.
  24637. */
  24638. function prepareLayoutList(input) {
  24639. var list = [];
  24640. for (var i = 0; i < input.length; i++) {
  24641. var rawItem = input[i];
  24642. if (rawItem.defaultAttr.ignore) {
  24643. continue;
  24644. }
  24645. var label = rawItem.label;
  24646. var transform = label.getComputedTransform(); // NOTE: Get bounding rect after getComputedTransform, or label may not been updated by the host el.
  24647. var localRect = label.getBoundingRect();
  24648. var isAxisAligned = !transform || transform[1] < 1e-5 && transform[2] < 1e-5;
  24649. var minMargin = label.style.margin || 0;
  24650. var globalRect = localRect.clone();
  24651. globalRect.applyTransform(transform);
  24652. globalRect.x -= minMargin / 2;
  24653. globalRect.y -= minMargin / 2;
  24654. globalRect.width += minMargin;
  24655. globalRect.height += minMargin;
  24656. var obb = isAxisAligned ? new OrientedBoundingRect(localRect, transform) : null;
  24657. list.push({
  24658. label: label,
  24659. labelLine: rawItem.labelLine,
  24660. rect: globalRect,
  24661. localRect: localRect,
  24662. obb: obb,
  24663. priority: rawItem.priority,
  24664. defaultAttr: rawItem.defaultAttr,
  24665. layoutOption: rawItem.computedLayoutOption,
  24666. axisAligned: isAxisAligned,
  24667. transform: transform
  24668. });
  24669. }
  24670. return list;
  24671. }
  24672. function shiftLayout(list, xyDim, sizeDim, minBound, maxBound, balanceShift) {
  24673. var len = list.length;
  24674. if (len < 2) {
  24675. return;
  24676. }
  24677. list.sort(function (a, b) {
  24678. return a.rect[xyDim] - b.rect[xyDim];
  24679. });
  24680. var lastPos = 0;
  24681. var delta;
  24682. var adjusted = false;
  24683. var shifts = [];
  24684. var totalShifts = 0;
  24685. for (var i = 0; i < len; i++) {
  24686. var item = list[i];
  24687. var rect = item.rect;
  24688. delta = rect[xyDim] - lastPos;
  24689. if (delta < 0) {
  24690. // shiftForward(i, len, -delta);
  24691. rect[xyDim] -= delta;
  24692. item.label[xyDim] -= delta;
  24693. adjusted = true;
  24694. }
  24695. var shift = Math.max(-delta, 0);
  24696. shifts.push(shift);
  24697. totalShifts += shift;
  24698. lastPos = rect[xyDim] + rect[sizeDim];
  24699. }
  24700. if (totalShifts > 0 && balanceShift) {
  24701. // Shift back to make the distribution more equally.
  24702. shiftList(-totalShifts / len, 0, len);
  24703. } // TODO bleedMargin?
  24704. var first = list[0];
  24705. var last = list[len - 1];
  24706. var minGap;
  24707. var maxGap;
  24708. updateMinMaxGap(); // If ends exceed two bounds, squeeze at most 80%, then take the gap of two bounds.
  24709. minGap < 0 && squeezeGaps(-minGap, 0.8);
  24710. maxGap < 0 && squeezeGaps(maxGap, 0.8);
  24711. updateMinMaxGap();
  24712. takeBoundsGap(minGap, maxGap, 1);
  24713. takeBoundsGap(maxGap, minGap, -1); // Handle bailout when there is not enough space.
  24714. updateMinMaxGap();
  24715. if (minGap < 0) {
  24716. squeezeWhenBailout(-minGap);
  24717. }
  24718. if (maxGap < 0) {
  24719. squeezeWhenBailout(maxGap);
  24720. }
  24721. function updateMinMaxGap() {
  24722. minGap = first.rect[xyDim] - minBound;
  24723. maxGap = maxBound - last.rect[xyDim] - last.rect[sizeDim];
  24724. }
  24725. function takeBoundsGap(gapThisBound, gapOtherBound, moveDir) {
  24726. if (gapThisBound < 0) {
  24727. // Move from other gap if can.
  24728. var moveFromMaxGap = Math.min(gapOtherBound, -gapThisBound);
  24729. if (moveFromMaxGap > 0) {
  24730. shiftList(moveFromMaxGap * moveDir, 0, len);
  24731. var remained = moveFromMaxGap + gapThisBound;
  24732. if (remained < 0) {
  24733. squeezeGaps(-remained * moveDir, 1);
  24734. }
  24735. } else {
  24736. squeezeGaps(-gapThisBound * moveDir, 1);
  24737. }
  24738. }
  24739. }
  24740. function shiftList(delta, start, end) {
  24741. if (delta !== 0) {
  24742. adjusted = true;
  24743. }
  24744. for (var i = start; i < end; i++) {
  24745. var item = list[i];
  24746. var rect = item.rect;
  24747. rect[xyDim] += delta;
  24748. item.label[xyDim] += delta;
  24749. }
  24750. } // Squeeze gaps if the labels exceed margin.
  24751. function squeezeGaps(delta, maxSqeezePercent) {
  24752. var gaps = [];
  24753. var totalGaps = 0;
  24754. for (var i = 1; i < len; i++) {
  24755. var prevItemRect = list[i - 1].rect;
  24756. var gap = Math.max(list[i].rect[xyDim] - prevItemRect[xyDim] - prevItemRect[sizeDim], 0);
  24757. gaps.push(gap);
  24758. totalGaps += gap;
  24759. }
  24760. if (!totalGaps) {
  24761. return;
  24762. }
  24763. var squeezePercent = Math.min(Math.abs(delta) / totalGaps, maxSqeezePercent);
  24764. if (delta > 0) {
  24765. for (var i = 0; i < len - 1; i++) {
  24766. // Distribute the shift delta to all gaps.
  24767. var movement = gaps[i] * squeezePercent; // Forward
  24768. shiftList(movement, 0, i + 1);
  24769. }
  24770. } else {
  24771. // Backward
  24772. for (var i = len - 1; i > 0; i--) {
  24773. // Distribute the shift delta to all gaps.
  24774. var movement = gaps[i - 1] * squeezePercent;
  24775. shiftList(-movement, i, len);
  24776. }
  24777. }
  24778. }
  24779. /**
  24780. * Squeeze to allow overlap if there is no more space available.
  24781. * Let other overlapping strategy like hideOverlap do the job instead of keep exceeding the bounds.
  24782. */
  24783. function squeezeWhenBailout(delta) {
  24784. var dir = delta < 0 ? -1 : 1;
  24785. delta = Math.abs(delta);
  24786. var moveForEachLabel = Math.ceil(delta / (len - 1));
  24787. for (var i = 0; i < len - 1; i++) {
  24788. if (dir > 0) {
  24789. // Forward
  24790. shiftList(moveForEachLabel, 0, i + 1);
  24791. } else {
  24792. // Backward
  24793. shiftList(-moveForEachLabel, len - i - 1, len);
  24794. }
  24795. delta -= moveForEachLabel;
  24796. if (delta <= 0) {
  24797. return;
  24798. }
  24799. }
  24800. }
  24801. return adjusted;
  24802. }
  24803. /**
  24804. * Adjust labels on x direction to avoid overlap.
  24805. */
  24806. function shiftLayoutOnX(list, leftBound, rightBound, // If average the shifts on all labels and add them to 0
  24807. // TODO: Not sure if should enable it.
  24808. // Pros: The angle of lines will distribute more equally
  24809. // Cons: In some layout. It may not what user wanted. like in pie. the label of last sector is usually changed unexpectedly.
  24810. balanceShift) {
  24811. return shiftLayout(list, 'x', 'width', leftBound, rightBound, balanceShift);
  24812. }
  24813. /**
  24814. * Adjust labels on y direction to avoid overlap.
  24815. */
  24816. function shiftLayoutOnY(list, topBound, bottomBound, // If average the shifts on all labels and add them to 0
  24817. balanceShift) {
  24818. return shiftLayout(list, 'y', 'height', topBound, bottomBound, balanceShift);
  24819. }
  24820. function hideOverlap(labelList) {
  24821. var displayedLabels = []; // TODO, render overflow visible first, put in the displayedLabels.
  24822. labelList.sort(function (a, b) {
  24823. return b.priority - a.priority;
  24824. });
  24825. var globalRect = new BoundingRect(0, 0, 0, 0);
  24826. function hideEl(el) {
  24827. if (!el.ignore) {
  24828. // Show on emphasis.
  24829. var emphasisState = el.ensureState('emphasis');
  24830. if (emphasisState.ignore == null) {
  24831. emphasisState.ignore = false;
  24832. }
  24833. }
  24834. el.ignore = true;
  24835. }
  24836. for (var i = 0; i < labelList.length; i++) {
  24837. var labelItem = labelList[i];
  24838. var isAxisAligned = labelItem.axisAligned;
  24839. var localRect = labelItem.localRect;
  24840. var transform = labelItem.transform;
  24841. var label = labelItem.label;
  24842. var labelLine = labelItem.labelLine;
  24843. globalRect.copy(labelItem.rect); // Add a threshold because layout may be aligned precisely.
  24844. globalRect.width -= 0.1;
  24845. globalRect.height -= 0.1;
  24846. globalRect.x += 0.05;
  24847. globalRect.y += 0.05;
  24848. var obb = labelItem.obb;
  24849. var overlapped = false;
  24850. for (var j = 0; j < displayedLabels.length; j++) {
  24851. var existsTextCfg = displayedLabels[j]; // Fast rejection.
  24852. if (!globalRect.intersect(existsTextCfg.rect)) {
  24853. continue;
  24854. }
  24855. if (isAxisAligned && existsTextCfg.axisAligned) {
  24856. // Is overlapped
  24857. overlapped = true;
  24858. break;
  24859. }
  24860. if (!existsTextCfg.obb) {
  24861. // If self is not axis aligned. But other is.
  24862. existsTextCfg.obb = new OrientedBoundingRect(existsTextCfg.localRect, existsTextCfg.transform);
  24863. }
  24864. if (!obb) {
  24865. // If self is axis aligned. But other is not.
  24866. obb = new OrientedBoundingRect(localRect, transform);
  24867. }
  24868. if (obb.intersect(existsTextCfg.obb)) {
  24869. overlapped = true;
  24870. break;
  24871. }
  24872. } // TODO Callback to determine if this overlap should be handled?
  24873. if (overlapped) {
  24874. hideEl(label);
  24875. labelLine && hideEl(labelLine);
  24876. } else {
  24877. label.attr('ignore', labelItem.defaultAttr.ignore);
  24878. labelLine && labelLine.attr('ignore', labelItem.defaultAttr.labelGuideIgnore);
  24879. displayedLabels.push(labelItem);
  24880. }
  24881. }
  24882. }
  24883. /*
  24884. * Licensed to the Apache Software Foundation (ASF) under one
  24885. * or more contributor license agreements. See the NOTICE file
  24886. * distributed with this work for additional information
  24887. * regarding copyright ownership. The ASF licenses this file
  24888. * to you under the Apache License, Version 2.0 (the
  24889. * "License"); you may not use this file except in compliance
  24890. * with the License. You may obtain a copy of the License at
  24891. *
  24892. * http://www.apache.org/licenses/LICENSE-2.0
  24893. *
  24894. * Unless required by applicable law or agreed to in writing,
  24895. * software distributed under the License is distributed on an
  24896. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24897. * KIND, either express or implied. See the License for the
  24898. * specific language governing permissions and limitations
  24899. * under the License.
  24900. */
  24901. /**
  24902. * AUTO-GENERATED FILE. DO NOT MODIFY.
  24903. */
  24904. /*
  24905. * Licensed to the Apache Software Foundation (ASF) under one
  24906. * or more contributor license agreements. See the NOTICE file
  24907. * distributed with this work for additional information
  24908. * regarding copyright ownership. The ASF licenses this file
  24909. * to you under the Apache License, Version 2.0 (the
  24910. * "License"); you may not use this file except in compliance
  24911. * with the License. You may obtain a copy of the License at
  24912. *
  24913. * http://www.apache.org/licenses/LICENSE-2.0
  24914. *
  24915. * Unless required by applicable law or agreed to in writing,
  24916. * software distributed under the License is distributed on an
  24917. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  24918. * KIND, either express or implied. See the License for the
  24919. * specific language governing permissions and limitations
  24920. * under the License.
  24921. */
  24922. // TODO: move labels out of viewport.
  24923. function cloneArr(points) {
  24924. if (points) {
  24925. var newPoints = [];
  24926. for (var i = 0; i < points.length; i++) {
  24927. newPoints.push(points[i].slice());
  24928. }
  24929. return newPoints;
  24930. }
  24931. }
  24932. function prepareLayoutCallbackParams(labelItem, hostEl) {
  24933. var label = labelItem.label;
  24934. var labelLine = hostEl && hostEl.getTextGuideLine();
  24935. return {
  24936. dataIndex: labelItem.dataIndex,
  24937. dataType: labelItem.dataType,
  24938. seriesIndex: labelItem.seriesModel.seriesIndex,
  24939. text: labelItem.label.style.text,
  24940. rect: labelItem.hostRect,
  24941. labelRect: labelItem.rect,
  24942. // x: labelAttr.x,
  24943. // y: labelAttr.y,
  24944. align: label.style.align,
  24945. verticalAlign: label.style.verticalAlign,
  24946. labelLinePoints: cloneArr(labelLine && labelLine.shape.points)
  24947. };
  24948. }
  24949. var LABEL_OPTION_TO_STYLE_KEYS = ['align', 'verticalAlign', 'width', 'height', 'fontSize'];
  24950. var dummyTransformable = new Transformable();
  24951. var labelLayoutInnerStore = makeInner();
  24952. var labelLineAnimationStore = makeInner();
  24953. function extendWithKeys(target, source, keys$$1) {
  24954. for (var i = 0; i < keys$$1.length; i++) {
  24955. var key = keys$$1[i];
  24956. if (source[key] != null) {
  24957. target[key] = source[key];
  24958. }
  24959. }
  24960. }
  24961. var LABEL_LAYOUT_PROPS = ['x', 'y', 'rotation'];
  24962. var LabelManager =
  24963. /** @class */
  24964. function () {
  24965. function LabelManager() {
  24966. this._labelList = [];
  24967. this._chartViewList = [];
  24968. }
  24969. LabelManager.prototype.clearLabels = function () {
  24970. this._labelList = [];
  24971. this._chartViewList = [];
  24972. };
  24973. /**
  24974. * Add label to manager
  24975. */
  24976. LabelManager.prototype._addLabel = function (dataIndex, dataType, seriesModel, label, layoutOption) {
  24977. var labelStyle = label.style;
  24978. var hostEl = label.__hostTarget;
  24979. var textConfig = hostEl.textConfig || {}; // TODO: If label is in other state.
  24980. var labelTransform = label.getComputedTransform();
  24981. var labelRect = label.getBoundingRect().plain();
  24982. BoundingRect.applyTransform(labelRect, labelRect, labelTransform);
  24983. if (labelTransform) {
  24984. dummyTransformable.setLocalTransform(labelTransform);
  24985. } else {
  24986. // Identity transform.
  24987. dummyTransformable.x = dummyTransformable.y = dummyTransformable.rotation = dummyTransformable.originX = dummyTransformable.originY = 0;
  24988. dummyTransformable.scaleX = dummyTransformable.scaleY = 1;
  24989. }
  24990. var host = label.__hostTarget;
  24991. var hostRect;
  24992. if (host) {
  24993. hostRect = host.getBoundingRect().plain();
  24994. var transform = host.getComputedTransform();
  24995. BoundingRect.applyTransform(hostRect, hostRect, transform);
  24996. }
  24997. var labelGuide = hostRect && host.getTextGuideLine();
  24998. this._labelList.push({
  24999. label: label,
  25000. labelLine: labelGuide,
  25001. seriesModel: seriesModel,
  25002. dataIndex: dataIndex,
  25003. dataType: dataType,
  25004. layoutOption: layoutOption,
  25005. computedLayoutOption: null,
  25006. rect: labelRect,
  25007. hostRect: hostRect,
  25008. // Label with lower priority will be hidden when overlapped
  25009. // Use rect size as default priority
  25010. priority: hostRect ? hostRect.width * hostRect.height : 0,
  25011. // Save default label attributes.
  25012. // For restore if developers want get back to default value in callback.
  25013. defaultAttr: {
  25014. ignore: label.ignore,
  25015. labelGuideIgnore: labelGuide && labelGuide.ignore,
  25016. x: dummyTransformable.x,
  25017. y: dummyTransformable.y,
  25018. scaleX: dummyTransformable.scaleX,
  25019. scaleY: dummyTransformable.scaleY,
  25020. rotation: dummyTransformable.rotation,
  25021. style: {
  25022. x: labelStyle.x,
  25023. y: labelStyle.y,
  25024. align: labelStyle.align,
  25025. verticalAlign: labelStyle.verticalAlign,
  25026. width: labelStyle.width,
  25027. height: labelStyle.height,
  25028. fontSize: labelStyle.fontSize
  25029. },
  25030. cursor: label.cursor,
  25031. attachedPos: textConfig.position,
  25032. attachedRot: textConfig.rotation
  25033. }
  25034. });
  25035. };
  25036. LabelManager.prototype.addLabelsOfSeries = function (chartView) {
  25037. var _this = this;
  25038. this._chartViewList.push(chartView);
  25039. var seriesModel = chartView.__model;
  25040. var layoutOption = seriesModel.get('labelLayout');
  25041. /**
  25042. * Ignore layouting if it's not specified anything.
  25043. */
  25044. if (!(isFunction$1(layoutOption) || keys(layoutOption).length)) {
  25045. return;
  25046. }
  25047. chartView.group.traverse(function (child) {
  25048. if (child.ignore) {
  25049. return true; // Stop traverse descendants.
  25050. } // Only support label being hosted on graphic elements.
  25051. var textEl = child.getTextContent();
  25052. var ecData = getECData(child); // Can only attach the text on the element with dataIndex
  25053. if (textEl && !textEl.disableLabelLayout) {
  25054. _this._addLabel(ecData.dataIndex, ecData.dataType, seriesModel, textEl, layoutOption);
  25055. }
  25056. });
  25057. };
  25058. LabelManager.prototype.updateLayoutConfig = function (api) {
  25059. var width = api.getWidth();
  25060. var height = api.getHeight();
  25061. function createDragHandler(el, labelLineModel) {
  25062. return function () {
  25063. updateLabelLinePoints(el, labelLineModel);
  25064. };
  25065. }
  25066. for (var i = 0; i < this._labelList.length; i++) {
  25067. var labelItem = this._labelList[i];
  25068. var label = labelItem.label;
  25069. var hostEl = label.__hostTarget;
  25070. var defaultLabelAttr = labelItem.defaultAttr;
  25071. var layoutOption = void 0; // TODO A global layout option?
  25072. if (typeof labelItem.layoutOption === 'function') {
  25073. layoutOption = labelItem.layoutOption(prepareLayoutCallbackParams(labelItem, hostEl));
  25074. } else {
  25075. layoutOption = labelItem.layoutOption;
  25076. }
  25077. layoutOption = layoutOption || {};
  25078. labelItem.computedLayoutOption = layoutOption;
  25079. var degreeToRadian = Math.PI / 180; // TODO hostEl should always exists.
  25080. // Or label should not have parent because the x, y is all in global space.
  25081. if (hostEl) {
  25082. hostEl.setTextConfig({
  25083. // Force to set local false.
  25084. local: false,
  25085. // Ignore position and rotation config on the host el if x or y is changed.
  25086. position: layoutOption.x != null || layoutOption.y != null ? null : defaultLabelAttr.attachedPos,
  25087. // Ignore rotation config on the host el if rotation is changed.
  25088. rotation: layoutOption.rotate != null ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.attachedRot,
  25089. offset: [layoutOption.dx || 0, layoutOption.dy || 0]
  25090. });
  25091. }
  25092. var needsUpdateLabelLine = false;
  25093. if (layoutOption.x != null) {
  25094. // TODO width of chart view.
  25095. label.x = parsePercent$1(layoutOption.x, width);
  25096. label.setStyle('x', 0); // Ignore movement in style. TODO: origin.
  25097. needsUpdateLabelLine = true;
  25098. } else {
  25099. label.x = defaultLabelAttr.x;
  25100. label.setStyle('x', defaultLabelAttr.style.x);
  25101. }
  25102. if (layoutOption.y != null) {
  25103. // TODO height of chart view.
  25104. label.y = parsePercent$1(layoutOption.y, height);
  25105. label.setStyle('y', 0); // Ignore movement in style.
  25106. needsUpdateLabelLine = true;
  25107. } else {
  25108. label.y = defaultLabelAttr.y;
  25109. label.setStyle('y', defaultLabelAttr.style.y);
  25110. }
  25111. if (layoutOption.labelLinePoints) {
  25112. var guideLine = hostEl.getTextGuideLine();
  25113. if (guideLine) {
  25114. guideLine.setShape({
  25115. points: layoutOption.labelLinePoints
  25116. }); // Not update
  25117. needsUpdateLabelLine = false;
  25118. }
  25119. }
  25120. var labelLayoutStore = labelLayoutInnerStore(label);
  25121. labelLayoutStore.needsUpdateLabelLine = needsUpdateLabelLine;
  25122. label.rotation = layoutOption.rotate != null ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.rotation;
  25123. label.scaleX = defaultLabelAttr.scaleX;
  25124. label.scaleY = defaultLabelAttr.scaleY;
  25125. for (var k = 0; k < LABEL_OPTION_TO_STYLE_KEYS.length; k++) {
  25126. var key = LABEL_OPTION_TO_STYLE_KEYS[k];
  25127. label.setStyle(key, layoutOption[key] != null ? layoutOption[key] : defaultLabelAttr.style[key]);
  25128. }
  25129. if (layoutOption.draggable) {
  25130. label.draggable = true;
  25131. label.cursor = 'move';
  25132. if (hostEl) {
  25133. var hostModel = labelItem.seriesModel;
  25134. if (labelItem.dataIndex != null) {
  25135. var data = labelItem.seriesModel.getData(labelItem.dataType);
  25136. hostModel = data.getItemModel(labelItem.dataIndex);
  25137. }
  25138. label.on('drag', createDragHandler(hostEl, hostModel.getModel('labelLine')));
  25139. }
  25140. } else {
  25141. // TODO Other drag functions?
  25142. label.off('drag');
  25143. label.cursor = defaultLabelAttr.cursor;
  25144. }
  25145. }
  25146. };
  25147. LabelManager.prototype.layout = function (api) {
  25148. var width = api.getWidth();
  25149. var height = api.getHeight();
  25150. var labelList = prepareLayoutList(this._labelList);
  25151. var labelsNeedsAdjustOnX = filter(labelList, function (item) {
  25152. return item.layoutOption.moveOverlap === 'shiftX';
  25153. });
  25154. var labelsNeedsAdjustOnY = filter(labelList, function (item) {
  25155. return item.layoutOption.moveOverlap === 'shiftY';
  25156. });
  25157. shiftLayoutOnX(labelsNeedsAdjustOnX, 0, width);
  25158. shiftLayoutOnY(labelsNeedsAdjustOnY, 0, height);
  25159. var labelsNeedsHideOverlap = filter(labelList, function (item) {
  25160. return item.layoutOption.hideOverlap;
  25161. });
  25162. hideOverlap(labelsNeedsHideOverlap);
  25163. };
  25164. /**
  25165. * Process all labels. Not only labels with layoutOption.
  25166. */
  25167. LabelManager.prototype.processLabelsOverall = function () {
  25168. var _this = this;
  25169. each$1(this._chartViewList, function (chartView) {
  25170. var seriesModel = chartView.__model;
  25171. var ignoreLabelLineUpdate = chartView.ignoreLabelLineUpdate;
  25172. var animationEnabled = seriesModel.isAnimationEnabled();
  25173. chartView.group.traverse(function (child) {
  25174. if (child.ignore) {
  25175. return true; // Stop traverse descendants.
  25176. }
  25177. var needsUpdateLabelLine = !ignoreLabelLineUpdate;
  25178. var label = child.getTextContent();
  25179. if (!needsUpdateLabelLine && label) {
  25180. needsUpdateLabelLine = labelLayoutInnerStore(label).needsUpdateLabelLine;
  25181. }
  25182. if (needsUpdateLabelLine) {
  25183. _this._updateLabelLine(child, seriesModel);
  25184. }
  25185. if (animationEnabled) {
  25186. _this._animateLabels(child, seriesModel);
  25187. }
  25188. });
  25189. });
  25190. };
  25191. LabelManager.prototype._updateLabelLine = function (el, seriesModel) {
  25192. // Only support label being hosted on graphic elements.
  25193. var textEl = el.getTextContent(); // Update label line style.
  25194. var ecData = getECData(el);
  25195. var dataIndex = ecData.dataIndex; // Only support labelLine on the labels represent data.
  25196. if (textEl && dataIndex != null) {
  25197. var data = seriesModel.getData(ecData.dataType);
  25198. var itemModel = data.getItemModel(dataIndex);
  25199. var defaultStyle = {};
  25200. var visualStyle = data.getItemVisual(dataIndex, 'style');
  25201. var visualType = data.getVisual('drawType'); // Default to be same with main color
  25202. defaultStyle.stroke = visualStyle[visualType];
  25203. var labelLineModel = itemModel.getModel('labelLine');
  25204. setLabelLineStyle(el, getLabelLineStatesModels(itemModel), defaultStyle);
  25205. updateLabelLinePoints(el, labelLineModel);
  25206. }
  25207. };
  25208. LabelManager.prototype._animateLabels = function (el, seriesModel) {
  25209. var textEl = el.getTextContent();
  25210. var guideLine = el.getTextGuideLine(); // Animate
  25211. if (textEl && !textEl.ignore && !textEl.invisible && !el.disableLabelAnimation && !isElementRemoved(el)) {
  25212. var layoutStore = labelLayoutInnerStore(textEl);
  25213. var oldLayout = layoutStore.oldLayout;
  25214. var ecData = getECData(el);
  25215. var dataIndex = ecData.dataIndex;
  25216. var newProps = {
  25217. x: textEl.x,
  25218. y: textEl.y,
  25219. rotation: textEl.rotation
  25220. };
  25221. var data = seriesModel.getData(ecData.dataType);
  25222. if (!oldLayout) {
  25223. textEl.attr(newProps); // Disable fade in animation if value animation is enabled.
  25224. if (!labelInner(textEl).valueAnimation) {
  25225. var oldOpacity = retrieve2(textEl.style.opacity, 1); // Fade in animation
  25226. textEl.style.opacity = 0;
  25227. initProps(textEl, {
  25228. style: {
  25229. opacity: oldOpacity
  25230. }
  25231. }, seriesModel, dataIndex);
  25232. }
  25233. } else {
  25234. textEl.attr(oldLayout); // Make sure the animation from is in the right status.
  25235. var prevStates = el.prevStates;
  25236. if (prevStates) {
  25237. if (indexOf$1(prevStates, 'select') >= 0) {
  25238. textEl.attr(layoutStore.oldLayoutSelect);
  25239. }
  25240. if (indexOf$1(prevStates, 'emphasis') >= 0) {
  25241. textEl.attr(layoutStore.oldLayoutEmphasis);
  25242. }
  25243. }
  25244. updateProps(textEl, newProps, seriesModel, dataIndex);
  25245. }
  25246. layoutStore.oldLayout = newProps;
  25247. if (textEl.states.select) {
  25248. var layoutSelect = layoutStore.oldLayoutSelect = {};
  25249. extendWithKeys(layoutSelect, newProps, LABEL_LAYOUT_PROPS);
  25250. extendWithKeys(layoutSelect, textEl.states.select, LABEL_LAYOUT_PROPS);
  25251. }
  25252. if (textEl.states.emphasis) {
  25253. var layoutEmphasis = layoutStore.oldLayoutEmphasis = {};
  25254. extendWithKeys(layoutEmphasis, newProps, LABEL_LAYOUT_PROPS);
  25255. extendWithKeys(layoutEmphasis, textEl.states.emphasis, LABEL_LAYOUT_PROPS);
  25256. }
  25257. animateLabelValue(textEl, dataIndex, data, seriesModel, seriesModel);
  25258. }
  25259. if (guideLine && !guideLine.ignore && !guideLine.invisible) {
  25260. var layoutStore = labelLineAnimationStore(guideLine);
  25261. var oldLayout = layoutStore.oldLayout;
  25262. var newLayout = {
  25263. points: guideLine.shape.points
  25264. };
  25265. if (!oldLayout) {
  25266. guideLine.setShape(newLayout);
  25267. guideLine.style.strokePercent = 0;
  25268. initProps(guideLine, {
  25269. style: {
  25270. strokePercent: 1
  25271. }
  25272. }, seriesModel);
  25273. } else {
  25274. guideLine.attr({
  25275. shape: oldLayout
  25276. });
  25277. updateProps(guideLine, {
  25278. shape: newLayout
  25279. }, seriesModel);
  25280. }
  25281. layoutStore.oldLayout = newLayout;
  25282. }
  25283. };
  25284. return LabelManager;
  25285. }();
  25286. /*
  25287. * Licensed to the Apache Software Foundation (ASF) under one
  25288. * or more contributor license agreements. See the NOTICE file
  25289. * distributed with this work for additional information
  25290. * regarding copyright ownership. The ASF licenses this file
  25291. * to you under the Apache License, Version 2.0 (the
  25292. * "License"); you may not use this file except in compliance
  25293. * with the License. You may obtain a copy of the License at
  25294. *
  25295. * http://www.apache.org/licenses/LICENSE-2.0
  25296. *
  25297. * Unless required by applicable law or agreed to in writing,
  25298. * software distributed under the License is distributed on an
  25299. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25300. * KIND, either express or implied. See the License for the
  25301. * specific language governing permissions and limitations
  25302. * under the License.
  25303. */
  25304. /**
  25305. * AUTO-GENERATED FILE. DO NOT MODIFY.
  25306. */
  25307. /*
  25308. * Licensed to the Apache Software Foundation (ASF) under one
  25309. * or more contributor license agreements. See the NOTICE file
  25310. * distributed with this work for additional information
  25311. * regarding copyright ownership. The ASF licenses this file
  25312. * to you under the Apache License, Version 2.0 (the
  25313. * "License"); you may not use this file except in compliance
  25314. * with the License. You may obtain a copy of the License at
  25315. *
  25316. * http://www.apache.org/licenses/LICENSE-2.0
  25317. *
  25318. * Unless required by applicable law or agreed to in writing,
  25319. * software distributed under the License is distributed on an
  25320. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25321. * KIND, either express or implied. See the License for the
  25322. * specific language governing permissions and limitations
  25323. * under the License.
  25324. */
  25325. // Inlucdes: pieSelect, pieUnSelect, pieToggleSelect, mapSelect, mapUnSelect, mapToggleSelect
  25326. function createLegacyDataSelectAction(seriesType, ecRegisterAction) {
  25327. function getSeriesIndices(ecModel, payload) {
  25328. var seriesIndices = [];
  25329. ecModel.eachComponent({
  25330. mainType: 'series',
  25331. subType: seriesType,
  25332. query: payload
  25333. }, function (seriesModel) {
  25334. seriesIndices.push(seriesModel.seriesIndex);
  25335. });
  25336. return seriesIndices;
  25337. }
  25338. each$1([[seriesType + 'ToggleSelect', 'toggleSelect'], [seriesType + 'Select', 'select'], [seriesType + 'UnSelect', 'unselect']], function (eventsMap) {
  25339. ecRegisterAction(eventsMap[0], function (payload, ecModel, api) {
  25340. payload = extend({}, payload);
  25341. {
  25342. deprecateReplaceLog(payload.type, eventsMap[1]);
  25343. }
  25344. api.dispatchAction(extend(payload, {
  25345. type: eventsMap[1],
  25346. seriesIndex: getSeriesIndices(ecModel, payload)
  25347. }));
  25348. });
  25349. });
  25350. }
  25351. function handleSeriesLegacySelectEvents(type, eventPostfix, ecIns, ecModel, payload) {
  25352. var legacyEventName = type + eventPostfix;
  25353. if (!ecIns.isSilent(legacyEventName)) {
  25354. {
  25355. deprecateLog("event " + legacyEventName + " is deprecated.");
  25356. }
  25357. ecModel.eachComponent({
  25358. mainType: 'series',
  25359. subType: 'pie'
  25360. }, function (seriesModel) {
  25361. var seriesIndex = seriesModel.seriesIndex;
  25362. var selected = payload.selected;
  25363. for (var i = 0; i < selected.length; i++) {
  25364. if (selected[i].seriesIndex === seriesIndex) {
  25365. var data = seriesModel.getData();
  25366. var dataIndex = queryDataIndex(data, payload.fromActionPayload);
  25367. ecIns.trigger(legacyEventName, {
  25368. type: legacyEventName,
  25369. seriesId: seriesModel.id,
  25370. name: isArray(dataIndex) ? data.getName(dataIndex[0]) : data.getName(dataIndex),
  25371. selected: extend({}, seriesModel.option.selectedMap)
  25372. });
  25373. }
  25374. }
  25375. });
  25376. }
  25377. }
  25378. function handleLegacySelectEvents(messageCenter, ecIns, api) {
  25379. messageCenter.on('selectchanged', function (params) {
  25380. var ecModel = api.getModel();
  25381. if (params.isFromClick) {
  25382. handleSeriesLegacySelectEvents('map', 'selectchanged', ecIns, ecModel, params);
  25383. handleSeriesLegacySelectEvents('pie', 'selectchanged', ecIns, ecModel, params);
  25384. } else if (params.fromAction === 'select') {
  25385. handleSeriesLegacySelectEvents('map', 'selected', ecIns, ecModel, params);
  25386. handleSeriesLegacySelectEvents('pie', 'selected', ecIns, ecModel, params);
  25387. } else if (params.fromAction === 'unselect') {
  25388. handleSeriesLegacySelectEvents('map', 'unselected', ecIns, ecModel, params);
  25389. handleSeriesLegacySelectEvents('pie', 'unselected', ecIns, ecModel, params);
  25390. }
  25391. });
  25392. }
  25393. /*
  25394. * Licensed to the Apache Software Foundation (ASF) under one
  25395. * or more contributor license agreements. See the NOTICE file
  25396. * distributed with this work for additional information
  25397. * regarding copyright ownership. The ASF licenses this file
  25398. * to you under the Apache License, Version 2.0 (the
  25399. * "License"); you may not use this file except in compliance
  25400. * with the License. You may obtain a copy of the License at
  25401. *
  25402. * http://www.apache.org/licenses/LICENSE-2.0
  25403. *
  25404. * Unless required by applicable law or agreed to in writing,
  25405. * software distributed under the License is distributed on an
  25406. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25407. * KIND, either express or implied. See the License for the
  25408. * specific language governing permissions and limitations
  25409. * under the License.
  25410. */
  25411. /**
  25412. * AUTO-GENERATED FILE. DO NOT MODIFY.
  25413. */
  25414. /*
  25415. * Licensed to the Apache Software Foundation (ASF) under one
  25416. * or more contributor license agreements. See the NOTICE file
  25417. * distributed with this work for additional information
  25418. * regarding copyright ownership. The ASF licenses this file
  25419. * to you under the Apache License, Version 2.0 (the
  25420. * "License"); you may not use this file except in compliance
  25421. * with the License. You may obtain a copy of the License at
  25422. *
  25423. * http://www.apache.org/licenses/LICENSE-2.0
  25424. *
  25425. * Unless required by applicable law or agreed to in writing,
  25426. * software distributed under the License is distributed on an
  25427. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25428. * KIND, either express or implied. See the License for the
  25429. * specific language governing permissions and limitations
  25430. * under the License.
  25431. */
  25432. function findEventDispatcher(target, det, returnFirstMatch) {
  25433. var found;
  25434. while (target) {
  25435. if (det(target)) {
  25436. found = target;
  25437. if (returnFirstMatch) {
  25438. break;
  25439. }
  25440. }
  25441. target = target.__hostTarget || target.parent;
  25442. }
  25443. return found;
  25444. }
  25445. var wmUniqueIndex = Math.round(Math.random() * 9);
  25446. var WeakMap = function () {
  25447. function WeakMap() {
  25448. this._id = '__ec_inner_' + wmUniqueIndex++;
  25449. }
  25450. WeakMap.prototype.get = function (key) {
  25451. return this._guard(key)[this._id];
  25452. };
  25453. WeakMap.prototype.set = function (key, value) {
  25454. var target = this._guard(key);
  25455. if (typeof Object.defineProperty === 'function') {
  25456. Object.defineProperty(target, this._id, {
  25457. value: value,
  25458. enumerable: false,
  25459. configurable: true
  25460. });
  25461. } else {
  25462. target[this._id] = value;
  25463. }
  25464. return this;
  25465. };
  25466. WeakMap.prototype["delete"] = function (key) {
  25467. if (this.has(key)) {
  25468. delete this._guard(key)[this._id];
  25469. return true;
  25470. }
  25471. return false;
  25472. };
  25473. WeakMap.prototype.has = function (key) {
  25474. return !!this._guard(key)[this._id];
  25475. };
  25476. WeakMap.prototype._guard = function (key) {
  25477. if (key !== Object(key)) {
  25478. throw TypeError('Value of WeakMap is not a non-null object.');
  25479. }
  25480. return key;
  25481. };
  25482. return WeakMap;
  25483. }();
  25484. /*
  25485. * Licensed to the Apache Software Foundation (ASF) under one
  25486. * or more contributor license agreements. See the NOTICE file
  25487. * distributed with this work for additional information
  25488. * regarding copyright ownership. The ASF licenses this file
  25489. * to you under the Apache License, Version 2.0 (the
  25490. * "License"); you may not use this file except in compliance
  25491. * with the License. You may obtain a copy of the License at
  25492. *
  25493. * http://www.apache.org/licenses/LICENSE-2.0
  25494. *
  25495. * Unless required by applicable law or agreed to in writing,
  25496. * software distributed under the License is distributed on an
  25497. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25498. * KIND, either express or implied. See the License for the
  25499. * specific language governing permissions and limitations
  25500. * under the License.
  25501. */
  25502. /**
  25503. * AUTO-GENERATED FILE. DO NOT MODIFY.
  25504. */
  25505. /*
  25506. * Licensed to the Apache Software Foundation (ASF) under one
  25507. * or more contributor license agreements. See the NOTICE file
  25508. * distributed with this work for additional information
  25509. * regarding copyright ownership. The ASF licenses this file
  25510. * to you under the Apache License, Version 2.0 (the
  25511. * "License"); you may not use this file except in compliance
  25512. * with the License. You may obtain a copy of the License at
  25513. *
  25514. * http://www.apache.org/licenses/LICENSE-2.0
  25515. *
  25516. * Unless required by applicable law or agreed to in writing,
  25517. * software distributed under the License is distributed on an
  25518. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25519. * KIND, either express or implied. See the License for the
  25520. * specific language governing permissions and limitations
  25521. * under the License.
  25522. */
  25523. // Symbol factory
  25524. /**
  25525. * Triangle shape
  25526. * @inner
  25527. */
  25528. var Triangle = Path.extend({
  25529. type: 'triangle',
  25530. shape: {
  25531. cx: 0,
  25532. cy: 0,
  25533. width: 0,
  25534. height: 0
  25535. },
  25536. buildPath: function (path, shape) {
  25537. var cx = shape.cx;
  25538. var cy = shape.cy;
  25539. var width = shape.width / 2;
  25540. var height = shape.height / 2;
  25541. path.moveTo(cx, cy - height);
  25542. path.lineTo(cx + width, cy + height);
  25543. path.lineTo(cx - width, cy + height);
  25544. path.closePath();
  25545. }
  25546. });
  25547. /**
  25548. * Diamond shape
  25549. * @inner
  25550. */
  25551. var Diamond = Path.extend({
  25552. type: 'diamond',
  25553. shape: {
  25554. cx: 0,
  25555. cy: 0,
  25556. width: 0,
  25557. height: 0
  25558. },
  25559. buildPath: function (path, shape) {
  25560. var cx = shape.cx;
  25561. var cy = shape.cy;
  25562. var width = shape.width / 2;
  25563. var height = shape.height / 2;
  25564. path.moveTo(cx, cy - height);
  25565. path.lineTo(cx + width, cy);
  25566. path.lineTo(cx, cy + height);
  25567. path.lineTo(cx - width, cy);
  25568. path.closePath();
  25569. }
  25570. });
  25571. /**
  25572. * Pin shape
  25573. * @inner
  25574. */
  25575. var Pin = Path.extend({
  25576. type: 'pin',
  25577. shape: {
  25578. // x, y on the cusp
  25579. x: 0,
  25580. y: 0,
  25581. width: 0,
  25582. height: 0
  25583. },
  25584. buildPath: function (path, shape) {
  25585. var x = shape.x;
  25586. var y = shape.y;
  25587. var w = shape.width / 5 * 3; // Height must be larger than width
  25588. var h = Math.max(w, shape.height);
  25589. var r = w / 2; // Dist on y with tangent point and circle center
  25590. var dy = r * r / (h - r);
  25591. var cy = y - h + r + dy;
  25592. var angle = Math.asin(dy / r); // Dist on x with tangent point and circle center
  25593. var dx = Math.cos(angle) * r;
  25594. var tanX = Math.sin(angle);
  25595. var tanY = Math.cos(angle);
  25596. var cpLen = r * 0.6;
  25597. var cpLen2 = r * 0.7;
  25598. path.moveTo(x - dx, cy + dy);
  25599. path.arc(x, cy, r, Math.PI - angle, Math.PI * 2 + angle);
  25600. path.bezierCurveTo(x + dx - tanX * cpLen, cy + dy + tanY * cpLen, x, y - cpLen2, x, y);
  25601. path.bezierCurveTo(x, y - cpLen2, x - dx + tanX * cpLen, cy + dy + tanY * cpLen, x - dx, cy + dy);
  25602. path.closePath();
  25603. }
  25604. });
  25605. /**
  25606. * Arrow shape
  25607. * @inner
  25608. */
  25609. var Arrow = Path.extend({
  25610. type: 'arrow',
  25611. shape: {
  25612. x: 0,
  25613. y: 0,
  25614. width: 0,
  25615. height: 0
  25616. },
  25617. buildPath: function (ctx, shape) {
  25618. var height = shape.height;
  25619. var width = shape.width;
  25620. var x = shape.x;
  25621. var y = shape.y;
  25622. var dx = width / 3 * 2;
  25623. ctx.moveTo(x, y);
  25624. ctx.lineTo(x + dx, y + height);
  25625. ctx.lineTo(x, y + height / 4 * 3);
  25626. ctx.lineTo(x - dx, y + height);
  25627. ctx.lineTo(x, y);
  25628. ctx.closePath();
  25629. }
  25630. });
  25631. /**
  25632. * Map of path contructors
  25633. */
  25634. // TODO Use function to build symbol path.
  25635. var symbolCtors = {
  25636. line: Line,
  25637. rect: Rect,
  25638. roundRect: Rect,
  25639. square: Rect,
  25640. circle: Circle,
  25641. diamond: Diamond,
  25642. pin: Pin,
  25643. arrow: Arrow,
  25644. triangle: Triangle
  25645. };
  25646. var symbolShapeMakers = {
  25647. line: function (x, y, w, h, shape) {
  25648. shape.x1 = x;
  25649. shape.y1 = y + h / 2;
  25650. shape.x2 = x + w;
  25651. shape.y2 = y + h / 2;
  25652. },
  25653. rect: function (x, y, w, h, shape) {
  25654. shape.x = x;
  25655. shape.y = y;
  25656. shape.width = w;
  25657. shape.height = h;
  25658. },
  25659. roundRect: function (x, y, w, h, shape) {
  25660. shape.x = x;
  25661. shape.y = y;
  25662. shape.width = w;
  25663. shape.height = h;
  25664. shape.r = Math.min(w, h) / 4;
  25665. },
  25666. square: function (x, y, w, h, shape) {
  25667. var size = Math.min(w, h);
  25668. shape.x = x;
  25669. shape.y = y;
  25670. shape.width = size;
  25671. shape.height = size;
  25672. },
  25673. circle: function (x, y, w, h, shape) {
  25674. // Put circle in the center of square
  25675. shape.cx = x + w / 2;
  25676. shape.cy = y + h / 2;
  25677. shape.r = Math.min(w, h) / 2;
  25678. },
  25679. diamond: function (x, y, w, h, shape) {
  25680. shape.cx = x + w / 2;
  25681. shape.cy = y + h / 2;
  25682. shape.width = w;
  25683. shape.height = h;
  25684. },
  25685. pin: function (x, y, w, h, shape) {
  25686. shape.x = x + w / 2;
  25687. shape.y = y + h / 2;
  25688. shape.width = w;
  25689. shape.height = h;
  25690. },
  25691. arrow: function (x, y, w, h, shape) {
  25692. shape.x = x + w / 2;
  25693. shape.y = y + h / 2;
  25694. shape.width = w;
  25695. shape.height = h;
  25696. },
  25697. triangle: function (x, y, w, h, shape) {
  25698. shape.cx = x + w / 2;
  25699. shape.cy = y + h / 2;
  25700. shape.width = w;
  25701. shape.height = h;
  25702. }
  25703. };
  25704. var symbolBuildProxies = {};
  25705. each$1(symbolCtors, function (Ctor, name) {
  25706. symbolBuildProxies[name] = new Ctor();
  25707. });
  25708. var SymbolClz = Path.extend({
  25709. type: 'symbol',
  25710. shape: {
  25711. symbolType: '',
  25712. x: 0,
  25713. y: 0,
  25714. width: 0,
  25715. height: 0
  25716. },
  25717. calculateTextPosition: function (out, config, rect) {
  25718. var res = calculateTextPosition(out, config, rect);
  25719. var shape = this.shape;
  25720. if (shape && shape.symbolType === 'pin' && config.position === 'inside') {
  25721. res.y = rect.y + rect.height * 0.4;
  25722. }
  25723. return res;
  25724. },
  25725. buildPath: function (ctx, shape, inBundle) {
  25726. var symbolType = shape.symbolType;
  25727. if (symbolType !== 'none') {
  25728. var proxySymbol = symbolBuildProxies[symbolType];
  25729. if (!proxySymbol) {
  25730. // Default rect
  25731. symbolType = 'rect';
  25732. proxySymbol = symbolBuildProxies[symbolType];
  25733. }
  25734. symbolShapeMakers[symbolType](shape.x, shape.y, shape.width, shape.height, proxySymbol.shape);
  25735. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);
  25736. }
  25737. }
  25738. }); // Provide setColor helper method to avoid determine if set the fill or stroke outside
  25739. function symbolPathSetColor(color, innerColor) {
  25740. if (this.type !== 'image') {
  25741. var symbolStyle = this.style;
  25742. if (this.__isEmptyBrush) {
  25743. symbolStyle.stroke = color;
  25744. symbolStyle.fill = innerColor || '#fff'; // TODO Same width with lineStyle in LineView
  25745. symbolStyle.lineWidth = 2;
  25746. } else if (this.shape.symbolType === 'line') {
  25747. symbolStyle.stroke = color;
  25748. } else {
  25749. symbolStyle.fill = color;
  25750. }
  25751. this.markRedraw();
  25752. }
  25753. }
  25754. /**
  25755. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  25756. */
  25757. function createSymbol(symbolType, x, y, w, h, color, // whether to keep the ratio of w/h,
  25758. keepAspect) {
  25759. // TODO Support image object, DynamicImage.
  25760. var isEmpty = symbolType.indexOf('empty') === 0;
  25761. if (isEmpty) {
  25762. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  25763. }
  25764. var symbolPath;
  25765. if (symbolType.indexOf('image://') === 0) {
  25766. symbolPath = makeImage(symbolType.slice(8), new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');
  25767. } else if (symbolType.indexOf('path://') === 0) {
  25768. symbolPath = makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');
  25769. } else {
  25770. symbolPath = new SymbolClz({
  25771. shape: {
  25772. symbolType: symbolType,
  25773. x: x,
  25774. y: y,
  25775. width: w,
  25776. height: h
  25777. }
  25778. });
  25779. }
  25780. symbolPath.__isEmptyBrush = isEmpty; // TODO Should deprecate setColor
  25781. symbolPath.setColor = symbolPathSetColor;
  25782. if (color) {
  25783. symbolPath.setColor(color);
  25784. }
  25785. return symbolPath;
  25786. }
  25787. function createLinearGradient(ctx, obj, rect) {
  25788. var x = obj.x == null ? 0 : obj.x;
  25789. var x2 = obj.x2 == null ? 1 : obj.x2;
  25790. var y = obj.y == null ? 0 : obj.y;
  25791. var y2 = obj.y2 == null ? 0 : obj.y2;
  25792. if (!obj.global) {
  25793. x = x * rect.width + rect.x;
  25794. x2 = x2 * rect.width + rect.x;
  25795. y = y * rect.height + rect.y;
  25796. y2 = y2 * rect.height + rect.y;
  25797. }
  25798. x = isNaN(x) ? 0 : x;
  25799. x2 = isNaN(x2) ? 1 : x2;
  25800. y = isNaN(y) ? 0 : y;
  25801. y2 = isNaN(y2) ? 0 : y2;
  25802. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  25803. return canvasGradient;
  25804. }
  25805. function createRadialGradient(ctx, obj, rect) {
  25806. var width = rect.width;
  25807. var height = rect.height;
  25808. var min = Math.min(width, height);
  25809. var x = obj.x == null ? 0.5 : obj.x;
  25810. var y = obj.y == null ? 0.5 : obj.y;
  25811. var r = obj.r == null ? 0.5 : obj.r;
  25812. if (!obj.global) {
  25813. x = x * width + rect.x;
  25814. y = y * height + rect.y;
  25815. r = r * min;
  25816. }
  25817. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  25818. return canvasGradient;
  25819. }
  25820. function getCanvasGradient(ctx, obj, rect) {
  25821. var canvasGradient = obj.type === 'radial' ? createRadialGradient(ctx, obj, rect) : createLinearGradient(ctx, obj, rect);
  25822. var colorStops = obj.colorStops;
  25823. for (var i = 0; i < colorStops.length; i++) {
  25824. canvasGradient.addColorStop(colorStops[i].offset, colorStops[i].color);
  25825. }
  25826. return canvasGradient;
  25827. }
  25828. function isClipPathChanged(clipPaths, prevClipPaths) {
  25829. if (clipPaths === prevClipPaths || !clipPaths && !prevClipPaths) {
  25830. return false;
  25831. }
  25832. if (!clipPaths || !prevClipPaths || clipPaths.length !== prevClipPaths.length) {
  25833. return true;
  25834. }
  25835. for (var i = 0; i < clipPaths.length; i++) {
  25836. if (clipPaths[i] !== prevClipPaths[i]) {
  25837. return true;
  25838. }
  25839. }
  25840. return false;
  25841. }
  25842. function normalizeLineDash(lineType, lineWidth) {
  25843. if (!lineType || lineType === 'solid' || !(lineWidth > 0)) {
  25844. return null;
  25845. }
  25846. lineWidth = lineWidth || 1;
  25847. return lineType === 'dashed' ? [4 * lineWidth, 2 * lineWidth] : lineType === 'dotted' ? [lineWidth] : isNumber(lineType) ? [lineType] : isArray(lineType) ? lineType : null;
  25848. }
  25849. var pathProxyForDraw = new PathProxy(true);
  25850. function styleHasStroke(style) {
  25851. var stroke = style.stroke;
  25852. return !(stroke == null || stroke === 'none' || !(style.lineWidth > 0));
  25853. }
  25854. function styleHasFill(style) {
  25855. var fill = style.fill;
  25856. return fill != null && fill !== 'none';
  25857. }
  25858. function doFillPath(ctx, style) {
  25859. if (style.fillOpacity != null && style.fillOpacity !== 1) {
  25860. var originalGlobalAlpha = ctx.globalAlpha;
  25861. ctx.globalAlpha = style.fillOpacity * style.opacity;
  25862. ctx.fill();
  25863. ctx.globalAlpha = originalGlobalAlpha;
  25864. } else {
  25865. ctx.fill();
  25866. }
  25867. }
  25868. function doStrokePath(ctx, style) {
  25869. if (style.strokeOpacity != null && style.strokeOpacity !== 1) {
  25870. var originalGlobalAlpha = ctx.globalAlpha;
  25871. ctx.globalAlpha = style.strokeOpacity * style.opacity;
  25872. ctx.stroke();
  25873. ctx.globalAlpha = originalGlobalAlpha;
  25874. } else {
  25875. ctx.stroke();
  25876. }
  25877. }
  25878. function createCanvasPattern(ctx, pattern, el) {
  25879. var image = createOrUpdateImage(pattern.image, pattern.__image, el);
  25880. if (isImageReady(image)) {
  25881. var canvasPattern = ctx.createPattern(image, pattern.repeat || 'repeat');
  25882. if (typeof DOMMatrix === 'function' && canvasPattern.setTransform) {
  25883. var matrix = new DOMMatrix();
  25884. matrix.rotateSelf(0, 0, (pattern.rotation || 0) / Math.PI * 180);
  25885. matrix.scaleSelf(pattern.scaleX || 1, pattern.scaleY || 1);
  25886. matrix.translateSelf(pattern.x || 0, pattern.y || 0);
  25887. canvasPattern.setTransform(matrix);
  25888. }
  25889. return canvasPattern;
  25890. }
  25891. }
  25892. function brushPath(ctx, el, style, inBatch) {
  25893. var hasStroke = styleHasStroke(style);
  25894. var hasFill = styleHasFill(style);
  25895. var strokePercent = style.strokePercent;
  25896. var strokePart = strokePercent < 1;
  25897. var firstDraw = !el.path;
  25898. if ((!el.silent || strokePart) && firstDraw) {
  25899. el.createPathProxy();
  25900. }
  25901. var path = el.path || pathProxyForDraw;
  25902. if (!inBatch) {
  25903. var fill = style.fill;
  25904. var stroke = style.stroke;
  25905. var hasFillGradient = hasFill && !!fill.colorStops;
  25906. var hasStrokeGradient = hasStroke && !!stroke.colorStops;
  25907. var hasFillPattern = hasFill && !!fill.image;
  25908. var hasStrokePattern = hasStroke && !!stroke.image;
  25909. var fillGradient = void 0;
  25910. var strokeGradient = void 0;
  25911. var fillPattern = void 0;
  25912. var strokePattern = void 0;
  25913. var rect = void 0;
  25914. if (hasFillGradient || hasStrokeGradient) {
  25915. rect = el.getBoundingRect();
  25916. }
  25917. if (hasFillGradient) {
  25918. fillGradient = el.__dirty ? getCanvasGradient(ctx, fill, rect) : el.__canvasFillGradient;
  25919. el.__canvasFillGradient = fillGradient;
  25920. }
  25921. if (hasStrokeGradient) {
  25922. strokeGradient = el.__dirty ? getCanvasGradient(ctx, stroke, rect) : el.__canvasStrokeGradient;
  25923. el.__canvasStrokeGradient = strokeGradient;
  25924. }
  25925. if (hasFillPattern) {
  25926. fillPattern = el.__dirty || !el.__canvasFillPattern ? createCanvasPattern(ctx, fill, el) : el.__canvasFillPattern;
  25927. el.__canvasFillPattern = fillPattern;
  25928. }
  25929. if (hasStrokePattern) {
  25930. strokePattern = el.__dirty || !el.__canvasStrokePattern ? createCanvasPattern(ctx, stroke, el) : el.__canvasStrokePattern;
  25931. el.__canvasStrokePattern = fillPattern;
  25932. }
  25933. if (hasFillGradient) {
  25934. ctx.fillStyle = fillGradient;
  25935. } else if (hasFillPattern) {
  25936. if (fillPattern) {
  25937. ctx.fillStyle = fillPattern;
  25938. } else {
  25939. hasFill = false;
  25940. }
  25941. }
  25942. if (hasStrokeGradient) {
  25943. ctx.strokeStyle = strokeGradient;
  25944. } else if (hasStrokePattern) {
  25945. if (strokePattern) {
  25946. ctx.strokeStyle = strokePattern;
  25947. } else {
  25948. hasStroke = false;
  25949. }
  25950. }
  25951. }
  25952. var lineDash = style.lineDash && style.lineWidth > 0 && normalizeLineDash(style.lineDash, style.lineWidth);
  25953. var lineDashOffset = style.lineDashOffset;
  25954. var ctxLineDash = !!ctx.setLineDash;
  25955. var scale = el.getGlobalScale();
  25956. path.setScale(scale[0], scale[1], el.segmentIgnoreThreshold);
  25957. if (lineDash) {
  25958. var lineScale_1 = style.strokeNoScale && el.getLineScale ? el.getLineScale() : 1;
  25959. if (lineScale_1 && lineScale_1 !== 1) {
  25960. lineDash = map(lineDash, function (rawVal) {
  25961. return rawVal / lineScale_1;
  25962. });
  25963. lineDashOffset /= lineScale_1;
  25964. }
  25965. }
  25966. var needsRebuild = true;
  25967. if (firstDraw || el.__dirty & Path.SHAPE_CHANGED_BIT || lineDash && !ctxLineDash && hasStroke) {
  25968. path.setDPR(ctx.dpr);
  25969. if (strokePart) {
  25970. path.setContext(null);
  25971. } else {
  25972. path.setContext(ctx);
  25973. needsRebuild = false;
  25974. }
  25975. path.reset();
  25976. if (lineDash && !ctxLineDash) {
  25977. path.setLineDash(lineDash);
  25978. path.setLineDashOffset(lineDashOffset);
  25979. }
  25980. el.buildPath(path, el.shape, inBatch);
  25981. path.toStatic();
  25982. el.pathUpdated();
  25983. }
  25984. if (needsRebuild) {
  25985. path.rebuildPath(ctx, strokePart ? strokePercent : 1);
  25986. }
  25987. if (lineDash && ctxLineDash) {
  25988. ctx.setLineDash(lineDash);
  25989. ctx.lineDashOffset = lineDashOffset;
  25990. }
  25991. if (!inBatch) {
  25992. if (style.strokeFirst) {
  25993. if (hasStroke) {
  25994. doStrokePath(ctx, style);
  25995. }
  25996. if (hasFill) {
  25997. doFillPath(ctx, style);
  25998. }
  25999. } else {
  26000. if (hasFill) {
  26001. doFillPath(ctx, style);
  26002. }
  26003. if (hasStroke) {
  26004. doStrokePath(ctx, style);
  26005. }
  26006. }
  26007. }
  26008. if (lineDash && ctxLineDash) {
  26009. ctx.setLineDash([]);
  26010. }
  26011. }
  26012. function brushImage(ctx, el, style) {
  26013. var image = el.__image = createOrUpdateImage(style.image, el.__image, el, el.onload);
  26014. if (!image || !isImageReady(image)) {
  26015. return;
  26016. }
  26017. var x = style.x || 0;
  26018. var y = style.y || 0;
  26019. var width = el.getWidth();
  26020. var height = el.getHeight();
  26021. var aspect = image.width / image.height;
  26022. if (width == null && height != null) {
  26023. width = height * aspect;
  26024. } else if (height == null && width != null) {
  26025. height = width / aspect;
  26026. } else if (width == null && height == null) {
  26027. width = image.width;
  26028. height = image.height;
  26029. }
  26030. if (style.sWidth && style.sHeight) {
  26031. var sx = style.sx || 0;
  26032. var sy = style.sy || 0;
  26033. ctx.drawImage(image, sx, sy, style.sWidth, style.sHeight, x, y, width, height);
  26034. } else if (style.sx && style.sy) {
  26035. var sx = style.sx;
  26036. var sy = style.sy;
  26037. var sWidth = width - sx;
  26038. var sHeight = height - sy;
  26039. ctx.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
  26040. } else {
  26041. ctx.drawImage(image, x, y, width, height);
  26042. }
  26043. }
  26044. function brushText(ctx, el, style) {
  26045. var text = style.text;
  26046. text != null && (text += '');
  26047. if (text) {
  26048. ctx.font = style.font || DEFAULT_FONT;
  26049. ctx.textAlign = style.textAlign;
  26050. ctx.textBaseline = style.textBaseline;
  26051. var hasLineDash = void 0;
  26052. if (ctx.setLineDash) {
  26053. var lineDash = style.lineDash && style.lineWidth > 0 && normalizeLineDash(style.lineDash, style.lineWidth);
  26054. var lineDashOffset = style.lineDashOffset;
  26055. if (lineDash) {
  26056. var lineScale_2 = style.strokeNoScale && el.getLineScale ? el.getLineScale() : 1;
  26057. if (lineScale_2 && lineScale_2 !== 1) {
  26058. lineDash = map(lineDash, function (rawVal) {
  26059. return rawVal / lineScale_2;
  26060. });
  26061. lineDashOffset /= lineScale_2;
  26062. }
  26063. ctx.setLineDash(lineDash);
  26064. ctx.lineDashOffset = lineDashOffset;
  26065. hasLineDash = true;
  26066. }
  26067. }
  26068. if (style.strokeFirst) {
  26069. if (styleHasStroke(style)) {
  26070. ctx.strokeText(text, style.x, style.y);
  26071. }
  26072. if (styleHasFill(style)) {
  26073. ctx.fillText(text, style.x, style.y);
  26074. }
  26075. } else {
  26076. if (styleHasFill(style)) {
  26077. ctx.fillText(text, style.x, style.y);
  26078. }
  26079. if (styleHasStroke(style)) {
  26080. ctx.strokeText(text, style.x, style.y);
  26081. }
  26082. }
  26083. if (hasLineDash) {
  26084. ctx.setLineDash([]);
  26085. }
  26086. }
  26087. }
  26088. var SHADOW_NUMBER_PROPS = ['shadowBlur', 'shadowOffsetX', 'shadowOffsetY'];
  26089. var STROKE_PROPS = [['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]];
  26090. function bindCommonProps(ctx, style, prevStyle, forceSetAll, scope) {
  26091. var styleChanged = false;
  26092. if (!forceSetAll) {
  26093. prevStyle = prevStyle || {};
  26094. if (style === prevStyle) {
  26095. return false;
  26096. }
  26097. }
  26098. if (forceSetAll || style.opacity !== prevStyle.opacity) {
  26099. if (!styleChanged) {
  26100. flushPathDrawn(ctx, scope);
  26101. styleChanged = true;
  26102. }
  26103. var opacity = Math.max(Math.min(style.opacity, 1), 0);
  26104. ctx.globalAlpha = isNaN(opacity) ? DEFAULT_COMMON_STYLE.opacity : opacity;
  26105. }
  26106. if (forceSetAll || style.blend !== prevStyle.blend) {
  26107. if (!styleChanged) {
  26108. flushPathDrawn(ctx, scope);
  26109. styleChanged = true;
  26110. }
  26111. ctx.globalCompositeOperation = style.blend || DEFAULT_COMMON_STYLE.blend;
  26112. }
  26113. for (var i = 0; i < SHADOW_NUMBER_PROPS.length; i++) {
  26114. var propName = SHADOW_NUMBER_PROPS[i];
  26115. if (forceSetAll || style[propName] !== prevStyle[propName]) {
  26116. if (!styleChanged) {
  26117. flushPathDrawn(ctx, scope);
  26118. styleChanged = true;
  26119. }
  26120. ctx[propName] = ctx.dpr * (style[propName] || 0);
  26121. }
  26122. }
  26123. if (forceSetAll || style.shadowColor !== prevStyle.shadowColor) {
  26124. if (!styleChanged) {
  26125. flushPathDrawn(ctx, scope);
  26126. styleChanged = true;
  26127. }
  26128. ctx.shadowColor = style.shadowColor || DEFAULT_COMMON_STYLE.shadowColor;
  26129. }
  26130. return styleChanged;
  26131. }
  26132. function bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetAll, scope) {
  26133. var style = getStyle(el, scope.inHover);
  26134. var prevStyle = forceSetAll ? null : prevEl && getStyle(prevEl, scope.inHover) || {};
  26135. if (style === prevStyle) {
  26136. return false;
  26137. }
  26138. var styleChanged = bindCommonProps(ctx, style, prevStyle, forceSetAll, scope);
  26139. if (forceSetAll || style.fill !== prevStyle.fill) {
  26140. if (!styleChanged) {
  26141. flushPathDrawn(ctx, scope);
  26142. styleChanged = true;
  26143. }
  26144. ctx.fillStyle = style.fill;
  26145. }
  26146. if (forceSetAll || style.stroke !== prevStyle.stroke) {
  26147. if (!styleChanged) {
  26148. flushPathDrawn(ctx, scope);
  26149. styleChanged = true;
  26150. }
  26151. ctx.strokeStyle = style.stroke;
  26152. }
  26153. if (forceSetAll || style.opacity !== prevStyle.opacity) {
  26154. if (!styleChanged) {
  26155. flushPathDrawn(ctx, scope);
  26156. styleChanged = true;
  26157. }
  26158. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;
  26159. }
  26160. if (el.hasStroke()) {
  26161. var lineWidth = style.lineWidth;
  26162. var newLineWidth = lineWidth / (style.strokeNoScale && el && el.getLineScale ? el.getLineScale() : 1);
  26163. if (ctx.lineWidth !== newLineWidth) {
  26164. if (!styleChanged) {
  26165. flushPathDrawn(ctx, scope);
  26166. styleChanged = true;
  26167. }
  26168. ctx.lineWidth = newLineWidth;
  26169. }
  26170. }
  26171. for (var i = 0; i < STROKE_PROPS.length; i++) {
  26172. var prop = STROKE_PROPS[i];
  26173. var propName = prop[0];
  26174. if (forceSetAll || style[propName] !== prevStyle[propName]) {
  26175. if (!styleChanged) {
  26176. flushPathDrawn(ctx, scope);
  26177. styleChanged = true;
  26178. }
  26179. ctx[propName] = style[propName] || prop[1];
  26180. }
  26181. }
  26182. return styleChanged;
  26183. }
  26184. function bindImageStyle(ctx, el, prevEl, forceSetAll, scope) {
  26185. return bindCommonProps(ctx, getStyle(el, scope.inHover), prevEl && getStyle(prevEl, scope.inHover), forceSetAll, scope);
  26186. }
  26187. function setContextTransform(ctx, el) {
  26188. var m = el.transform;
  26189. var dpr = ctx.dpr || 1;
  26190. if (m) {
  26191. ctx.setTransform(dpr * m[0], dpr * m[1], dpr * m[2], dpr * m[3], dpr * m[4], dpr * m[5]);
  26192. } else {
  26193. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  26194. }
  26195. }
  26196. function updateClipStatus(clipPaths, ctx, scope) {
  26197. var allClipped = false;
  26198. for (var i = 0; i < clipPaths.length; i++) {
  26199. var clipPath = clipPaths[i];
  26200. allClipped = allClipped || clipPath.isZeroArea();
  26201. setContextTransform(ctx, clipPath);
  26202. ctx.beginPath();
  26203. clipPath.buildPath(ctx, clipPath.shape);
  26204. ctx.clip();
  26205. }
  26206. scope.allClipped = allClipped;
  26207. }
  26208. function isTransformChanged(m0, m1) {
  26209. if (m0 && m1) {
  26210. return m0[0] !== m1[0] || m0[1] !== m1[1] || m0[2] !== m1[2] || m0[3] !== m1[3] || m0[4] !== m1[4] || m0[5] !== m1[5];
  26211. } else if (!m0 && !m1) {
  26212. return false;
  26213. }
  26214. return true;
  26215. }
  26216. var DRAW_TYPE_PATH = 1;
  26217. var DRAW_TYPE_IMAGE = 2;
  26218. var DRAW_TYPE_TEXT = 3;
  26219. var DRAW_TYPE_INCREMENTAL = 4;
  26220. function canPathBatch(style) {
  26221. var hasFill = styleHasFill(style);
  26222. var hasStroke = styleHasStroke(style);
  26223. return !(style.lineDash || !(+hasFill ^ +hasStroke) || hasFill && typeof style.fill !== 'string' || hasStroke && typeof style.stroke !== 'string' || style.strokePercent < 1 || style.strokeOpacity < 1 || style.fillOpacity < 1);
  26224. }
  26225. function flushPathDrawn(ctx, scope) {
  26226. scope.batchFill && ctx.fill();
  26227. scope.batchStroke && ctx.stroke();
  26228. scope.batchFill = '';
  26229. scope.batchStroke = '';
  26230. }
  26231. function getStyle(el, inHover) {
  26232. return inHover ? el.__hoverStyle || el.style : el.style;
  26233. }
  26234. function brushSingle(ctx, el) {
  26235. brush(ctx, el, {
  26236. inHover: false,
  26237. viewWidth: 0,
  26238. viewHeight: 0
  26239. }, true);
  26240. }
  26241. function brush(ctx, el, scope, isLast) {
  26242. var m = el.transform;
  26243. if (!el.shouldBePainted(scope.viewWidth, scope.viewHeight, false, false)) {
  26244. el.__dirty &= ~Element.REDARAW_BIT;
  26245. el.__isRendered = false;
  26246. return;
  26247. }
  26248. var clipPaths = el.__clipPaths;
  26249. var prevElClipPaths = scope.prevElClipPaths;
  26250. var forceSetTransform = false;
  26251. var forceSetStyle = false;
  26252. if (!prevElClipPaths || isClipPathChanged(clipPaths, prevElClipPaths)) {
  26253. if (prevElClipPaths && prevElClipPaths.length) {
  26254. flushPathDrawn(ctx, scope);
  26255. ctx.restore();
  26256. forceSetStyle = forceSetTransform = true;
  26257. scope.prevElClipPaths = null;
  26258. scope.allClipped = false;
  26259. scope.prevEl = null;
  26260. }
  26261. if (clipPaths && clipPaths.length) {
  26262. flushPathDrawn(ctx, scope);
  26263. ctx.save();
  26264. updateClipStatus(clipPaths, ctx, scope);
  26265. forceSetTransform = true;
  26266. }
  26267. scope.prevElClipPaths = clipPaths;
  26268. }
  26269. if (scope.allClipped) {
  26270. el.__isRendered = false;
  26271. return;
  26272. }
  26273. el.beforeBrush && el.beforeBrush();
  26274. el.innerBeforeBrush();
  26275. var prevEl = scope.prevEl;
  26276. if (!prevEl) {
  26277. forceSetStyle = forceSetTransform = true;
  26278. }
  26279. var canBatchPath = el instanceof Path && el.autoBatch && canPathBatch(el.style);
  26280. if (forceSetTransform || isTransformChanged(m, prevEl.transform)) {
  26281. flushPathDrawn(ctx, scope);
  26282. setContextTransform(ctx, el);
  26283. } else if (!canBatchPath) {
  26284. flushPathDrawn(ctx, scope);
  26285. }
  26286. var style = getStyle(el, scope.inHover);
  26287. if (el instanceof Path) {
  26288. if (scope.lastDrawType !== DRAW_TYPE_PATH) {
  26289. forceSetStyle = true;
  26290. scope.lastDrawType = DRAW_TYPE_PATH;
  26291. }
  26292. bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetStyle, scope);
  26293. if (!canBatchPath || !scope.batchFill && !scope.batchStroke) {
  26294. ctx.beginPath();
  26295. }
  26296. brushPath(ctx, el, style, canBatchPath);
  26297. if (canBatchPath) {
  26298. scope.batchFill = style.fill || '';
  26299. scope.batchStroke = style.stroke || '';
  26300. }
  26301. } else {
  26302. if (el instanceof TSpan) {
  26303. if (scope.lastDrawType !== DRAW_TYPE_TEXT) {
  26304. forceSetStyle = true;
  26305. scope.lastDrawType = DRAW_TYPE_TEXT;
  26306. }
  26307. bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetStyle, scope);
  26308. brushText(ctx, el, style);
  26309. } else if (el instanceof ZRImage) {
  26310. if (scope.lastDrawType !== DRAW_TYPE_IMAGE) {
  26311. forceSetStyle = true;
  26312. scope.lastDrawType = DRAW_TYPE_IMAGE;
  26313. }
  26314. bindImageStyle(ctx, el, prevEl, forceSetStyle, scope);
  26315. brushImage(ctx, el, style);
  26316. } else if (el instanceof IncrementalDisplayable) {
  26317. if (scope.lastDrawType !== DRAW_TYPE_INCREMENTAL) {
  26318. forceSetStyle = true;
  26319. scope.lastDrawType = DRAW_TYPE_INCREMENTAL;
  26320. }
  26321. brushIncremental(ctx, el, scope);
  26322. }
  26323. }
  26324. if (canBatchPath && isLast) {
  26325. flushPathDrawn(ctx, scope);
  26326. }
  26327. el.innerAfterBrush();
  26328. el.afterBrush && el.afterBrush();
  26329. scope.prevEl = el;
  26330. el.__dirty = 0;
  26331. el.__isRendered = true;
  26332. }
  26333. function brushIncremental(ctx, el, scope) {
  26334. var displayables = el.getDisplayables();
  26335. var temporalDisplayables = el.getTemporalDisplayables();
  26336. ctx.save();
  26337. var innerScope = {
  26338. prevElClipPaths: null,
  26339. prevEl: null,
  26340. allClipped: false,
  26341. viewWidth: scope.viewWidth,
  26342. viewHeight: scope.viewHeight,
  26343. inHover: scope.inHover
  26344. };
  26345. var i;
  26346. var len;
  26347. for (i = el.getCursor(), len = displayables.length; i < len; i++) {
  26348. var displayable = displayables[i];
  26349. displayable.beforeBrush && displayable.beforeBrush();
  26350. displayable.innerBeforeBrush();
  26351. brush(ctx, displayable, innerScope, i === len - 1);
  26352. displayable.innerAfterBrush();
  26353. displayable.afterBrush && displayable.afterBrush();
  26354. innerScope.prevEl = displayable;
  26355. }
  26356. for (var i_1 = 0, len_1 = temporalDisplayables.length; i_1 < len_1; i_1++) {
  26357. var displayable = temporalDisplayables[i_1];
  26358. displayable.beforeBrush && displayable.beforeBrush();
  26359. displayable.innerBeforeBrush();
  26360. brush(ctx, displayable, innerScope, i_1 === len_1 - 1);
  26361. displayable.innerAfterBrush();
  26362. displayable.afterBrush && displayable.afterBrush();
  26363. innerScope.prevEl = displayable;
  26364. }
  26365. el.clearTemporalDisplayables();
  26366. el.notClear = true;
  26367. ctx.restore();
  26368. }
  26369. /*
  26370. * Licensed to the Apache Software Foundation (ASF) under one
  26371. * or more contributor license agreements. See the NOTICE file
  26372. * distributed with this work for additional information
  26373. * regarding copyright ownership. The ASF licenses this file
  26374. * to you under the Apache License, Version 2.0 (the
  26375. * "License"); you may not use this file except in compliance
  26376. * with the License. You may obtain a copy of the License at
  26377. *
  26378. * http://www.apache.org/licenses/LICENSE-2.0
  26379. *
  26380. * Unless required by applicable law or agreed to in writing,
  26381. * software distributed under the License is distributed on an
  26382. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26383. * KIND, either express or implied. See the License for the
  26384. * specific language governing permissions and limitations
  26385. * under the License.
  26386. */
  26387. /**
  26388. * AUTO-GENERATED FILE. DO NOT MODIFY.
  26389. */
  26390. /*
  26391. * Licensed to the Apache Software Foundation (ASF) under one
  26392. * or more contributor license agreements. See the NOTICE file
  26393. * distributed with this work for additional information
  26394. * regarding copyright ownership. The ASF licenses this file
  26395. * to you under the Apache License, Version 2.0 (the
  26396. * "License"); you may not use this file except in compliance
  26397. * with the License. You may obtain a copy of the License at
  26398. *
  26399. * http://www.apache.org/licenses/LICENSE-2.0
  26400. *
  26401. * Unless required by applicable law or agreed to in writing,
  26402. * software distributed under the License is distributed on an
  26403. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26404. * KIND, either express or implied. See the License for the
  26405. * specific language governing permissions and limitations
  26406. * under the License.
  26407. */
  26408. var decalMap = new WeakMap();
  26409. var decalCache = new LRU(100);
  26410. var decalKeys = ['symbol', 'symbolSize', 'symbolKeepAspect', 'color', 'backgroundColor', 'dashArrayX', 'dashArrayY', 'maxTileWidth', 'maxTileHeight'];
  26411. /**
  26412. * Create or update pattern image from decal options
  26413. *
  26414. * @param {InnerDecalObject | 'none'} decalObject decal options, 'none' if no decal
  26415. * @return {Pattern} pattern with generated image, null if no decal
  26416. */
  26417. function createOrUpdatePatternFromDecal(decalObject, api) {
  26418. if (decalObject === 'none') {
  26419. return null;
  26420. }
  26421. var dpr = api.getDevicePixelRatio();
  26422. var zr = api.getZr();
  26423. var isSVG = zr.painter.type === 'svg';
  26424. if (decalObject.dirty) {
  26425. decalMap["delete"](decalObject);
  26426. }
  26427. var oldPattern = decalMap.get(decalObject);
  26428. if (oldPattern) {
  26429. return oldPattern;
  26430. }
  26431. var decalOpt = defaults(decalObject, {
  26432. symbol: 'rect',
  26433. symbolSize: 1,
  26434. symbolKeepAspect: true,
  26435. color: 'rgba(0, 0, 0, 0.2)',
  26436. backgroundColor: null,
  26437. dashArrayX: 5,
  26438. dashArrayY: 5,
  26439. rotation: 0,
  26440. maxTileWidth: 512,
  26441. maxTileHeight: 512
  26442. });
  26443. if (decalOpt.backgroundColor === 'none') {
  26444. decalOpt.backgroundColor = null;
  26445. }
  26446. var pattern = {
  26447. repeat: 'repeat'
  26448. };
  26449. setPatternnSource(pattern);
  26450. pattern.rotation = decalOpt.rotation;
  26451. pattern.scaleX = pattern.scaleY = isSVG ? 1 : 1 / dpr;
  26452. decalMap.set(decalObject, pattern);
  26453. decalObject.dirty = false;
  26454. return pattern;
  26455. function setPatternnSource(pattern) {
  26456. var keys$$1 = [dpr];
  26457. var isValidKey = true;
  26458. for (var i = 0; i < decalKeys.length; ++i) {
  26459. var value = decalOpt[decalKeys[i]];
  26460. var valueType = typeof value;
  26461. if (value != null && !isArray(value) && valueType !== 'string' && valueType !== 'number' && valueType !== 'boolean') {
  26462. isValidKey = false;
  26463. break;
  26464. }
  26465. keys$$1.push(value);
  26466. }
  26467. var cacheKey;
  26468. if (isValidKey) {
  26469. cacheKey = keys$$1.join(',') + (isSVG ? '-svg' : '');
  26470. var cache = decalCache.get(cacheKey);
  26471. if (cache) {
  26472. isSVG ? pattern.svgElement = cache : pattern.image = cache;
  26473. }
  26474. }
  26475. var dashArrayX = normalizeDashArrayX(decalOpt.dashArrayX);
  26476. var dashArrayY = normalizeDashArrayY(decalOpt.dashArrayY);
  26477. var symbolArray = normalizeSymbolArray(decalOpt.symbol);
  26478. var lineBlockLengthsX = getLineBlockLengthX(dashArrayX);
  26479. var lineBlockLengthY = getLineBlockLengthY(dashArrayY);
  26480. var canvas = !isSVG && createCanvas();
  26481. var svgRoot = isSVG && zr.painter.createSVGElement('g');
  26482. var pSize = getPatternSize();
  26483. var ctx;
  26484. if (canvas) {
  26485. canvas.width = pSize.width * dpr;
  26486. canvas.height = pSize.height * dpr;
  26487. ctx = canvas.getContext('2d');
  26488. }
  26489. brushDecal();
  26490. if (isValidKey) {
  26491. decalCache.put(cacheKey, canvas || svgRoot);
  26492. }
  26493. pattern.image = canvas;
  26494. pattern.svgElement = svgRoot;
  26495. pattern.svgWidth = pSize.width;
  26496. pattern.svgHeight = pSize.height;
  26497. /**
  26498. * Get minumum length that can make a repeatable pattern.
  26499. *
  26500. * @return {Object} pattern width and height
  26501. */
  26502. function getPatternSize() {
  26503. /**
  26504. * For example, if dash is [[3, 2], [2, 1]] for X, it looks like
  26505. * |--- --- --- --- --- ...
  26506. * |-- -- -- -- -- -- -- -- ...
  26507. * |--- --- --- --- --- ...
  26508. * |-- -- -- -- -- -- -- -- ...
  26509. * So the minumum length of X is 15,
  26510. * which is the least common multiple of `3 + 2` and `2 + 1`
  26511. * |--- --- --- |--- --- ...
  26512. * |-- -- -- -- -- |-- -- -- ...
  26513. */
  26514. var width = 1;
  26515. for (var i = 0, xlen = lineBlockLengthsX.length; i < xlen; ++i) {
  26516. width = getLeastCommonMultiple(width, lineBlockLengthsX[i]);
  26517. }
  26518. var symbolRepeats = 1;
  26519. for (var i = 0, xlen = symbolArray.length; i < xlen; ++i) {
  26520. symbolRepeats = getLeastCommonMultiple(symbolRepeats, symbolArray[i].length);
  26521. }
  26522. width *= symbolRepeats;
  26523. var height = lineBlockLengthY * lineBlockLengthsX.length * symbolArray.length;
  26524. {
  26525. var warn = function (attrName) {
  26526. /* eslint-disable-next-line */
  26527. console.warn("Calculated decal size is greater than " + attrName + " due to decal option settings so " + attrName + " is used for the decal size. Please consider changing the decal option to make a smaller decal or set " + attrName + " to be larger to avoid incontinuity.");
  26528. };
  26529. if (width > decalOpt.maxTileWidth) {
  26530. warn('maxTileWidth');
  26531. }
  26532. if (height > decalOpt.maxTileHeight) {
  26533. warn('maxTileHeight');
  26534. }
  26535. }
  26536. return {
  26537. width: Math.max(1, Math.min(width, decalOpt.maxTileWidth)),
  26538. height: Math.max(1, Math.min(height, decalOpt.maxTileHeight))
  26539. };
  26540. }
  26541. function brushDecal() {
  26542. if (ctx) {
  26543. ctx.clearRect(0, 0, canvas.width, canvas.height);
  26544. if (decalOpt.backgroundColor) {
  26545. ctx.fillStyle = decalOpt.backgroundColor;
  26546. ctx.fillRect(0, 0, canvas.width, canvas.height);
  26547. }
  26548. }
  26549. var ySum = 0;
  26550. for (var i = 0; i < dashArrayY.length; ++i) {
  26551. ySum += dashArrayY[i];
  26552. }
  26553. if (ySum <= 0) {
  26554. // dashArrayY is 0, draw nothing
  26555. return;
  26556. }
  26557. var y = -lineBlockLengthY;
  26558. var yId = 0;
  26559. var yIdTotal = 0;
  26560. var xId0 = 0;
  26561. while (y < pSize.height) {
  26562. if (yId % 2 === 0) {
  26563. var symbolYId = yIdTotal / 2 % symbolArray.length;
  26564. var x = 0;
  26565. var xId1 = 0;
  26566. var xId1Total = 0;
  26567. while (x < pSize.width * 2) {
  26568. var xSum = 0;
  26569. for (var i = 0; i < dashArrayX[xId0].length; ++i) {
  26570. xSum += dashArrayX[xId0][i];
  26571. }
  26572. if (xSum <= 0) {
  26573. // Skip empty line
  26574. break;
  26575. } // E.g., [15, 5, 20, 5] draws only for 15 and 20
  26576. if (xId1 % 2 === 0) {
  26577. var size = (1 - decalOpt.symbolSize) * 0.5;
  26578. var left = x + dashArrayX[xId0][xId1] * size;
  26579. var top_1 = y + dashArrayY[yId] * size;
  26580. var width = dashArrayX[xId0][xId1] * decalOpt.symbolSize;
  26581. var height = dashArrayY[yId] * decalOpt.symbolSize;
  26582. var symbolXId = xId1Total / 2 % symbolArray[symbolYId].length;
  26583. brushSymbol(left, top_1, width, height, symbolArray[symbolYId][symbolXId]);
  26584. }
  26585. x += dashArrayX[xId0][xId1];
  26586. ++xId1Total;
  26587. ++xId1;
  26588. if (xId1 === dashArrayX[xId0].length) {
  26589. xId1 = 0;
  26590. }
  26591. }
  26592. ++xId0;
  26593. if (xId0 === dashArrayX.length) {
  26594. xId0 = 0;
  26595. }
  26596. }
  26597. y += dashArrayY[yId];
  26598. ++yIdTotal;
  26599. ++yId;
  26600. if (yId === dashArrayY.length) {
  26601. yId = 0;
  26602. }
  26603. }
  26604. function brushSymbol(x, y, width, height, symbolType) {
  26605. var scale = isSVG ? 1 : dpr;
  26606. var symbol = createSymbol(symbolType, x * scale, y * scale, width * scale, height * scale, decalOpt.color, decalOpt.symbolKeepAspect);
  26607. if (isSVG) {
  26608. svgRoot.appendChild(zr.painter.paintOne(symbol));
  26609. } else {
  26610. // Paint to canvas for all other renderers.
  26611. brushSingle(ctx, symbol);
  26612. }
  26613. }
  26614. }
  26615. }
  26616. }
  26617. /**
  26618. * Convert symbol array into normalized array
  26619. *
  26620. * @param {string | (string | string[])[]} symbol symbol input
  26621. * @return {string[][]} normolized symbol array
  26622. */
  26623. function normalizeSymbolArray(symbol) {
  26624. if (!symbol || symbol.length === 0) {
  26625. return [['rect']];
  26626. }
  26627. if (typeof symbol === 'string') {
  26628. return [[symbol]];
  26629. }
  26630. var isAllString = true;
  26631. for (var i = 0; i < symbol.length; ++i) {
  26632. if (typeof symbol[i] !== 'string') {
  26633. isAllString = false;
  26634. break;
  26635. }
  26636. }
  26637. if (isAllString) {
  26638. return normalizeSymbolArray([symbol]);
  26639. }
  26640. var result = [];
  26641. for (var i = 0; i < symbol.length; ++i) {
  26642. if (typeof symbol[i] === 'string') {
  26643. result.push([symbol[i]]);
  26644. } else {
  26645. result.push(symbol[i]);
  26646. }
  26647. }
  26648. return result;
  26649. }
  26650. /**
  26651. * Convert dash input into dashArray
  26652. *
  26653. * @param {DecalDashArrayX} dash dash input
  26654. * @return {number[][]} normolized dash array
  26655. */
  26656. function normalizeDashArrayX(dash) {
  26657. if (!dash || dash.length === 0) {
  26658. return [[0, 0]];
  26659. }
  26660. if (typeof dash === 'number') {
  26661. var dashValue = Math.ceil(dash);
  26662. return [[dashValue, dashValue]];
  26663. }
  26664. /**
  26665. * [20, 5] should be normalized into [[20, 5]],
  26666. * while [20, [5, 10]] should be normalized into [[20, 20], [5, 10]]
  26667. */
  26668. var isAllNumber = true;
  26669. for (var i = 0; i < dash.length; ++i) {
  26670. if (typeof dash[i] !== 'number') {
  26671. isAllNumber = false;
  26672. break;
  26673. }
  26674. }
  26675. if (isAllNumber) {
  26676. return normalizeDashArrayX([dash]);
  26677. }
  26678. var result = [];
  26679. for (var i = 0; i < dash.length; ++i) {
  26680. if (typeof dash[i] === 'number') {
  26681. var dashValue = Math.ceil(dash[i]);
  26682. result.push([dashValue, dashValue]);
  26683. } else {
  26684. var dashValue = map(dash[i], function (n) {
  26685. return Math.ceil(n);
  26686. });
  26687. if (dashValue.length % 2 === 1) {
  26688. // [4, 2, 1] means |---- - -- |---- - -- |
  26689. // so normalize it to be [4, 2, 1, 4, 2, 1]
  26690. result.push(dashValue.concat(dashValue));
  26691. } else {
  26692. result.push(dashValue);
  26693. }
  26694. }
  26695. }
  26696. return result;
  26697. }
  26698. /**
  26699. * Convert dash input into dashArray
  26700. *
  26701. * @param {DecalDashArrayY} dash dash input
  26702. * @return {number[]} normolized dash array
  26703. */
  26704. function normalizeDashArrayY(dash) {
  26705. if (!dash || typeof dash === 'object' && dash.length === 0) {
  26706. return [0, 0];
  26707. }
  26708. if (typeof dash === 'number') {
  26709. var dashValue_1 = Math.ceil(dash);
  26710. return [dashValue_1, dashValue_1];
  26711. }
  26712. var dashValue = map(dash, function (n) {
  26713. return Math.ceil(n);
  26714. });
  26715. return dash.length % 2 ? dashValue.concat(dashValue) : dashValue;
  26716. }
  26717. /**
  26718. * Get block length of each line. A block is the length of dash line and space.
  26719. * For example, a line with [4, 1] has a dash line of 4 and a space of 1 after
  26720. * that, so the block length of this line is 5.
  26721. *
  26722. * @param {number[][]} dash dash arrary of X or Y
  26723. * @return {number[]} block length of each line
  26724. */
  26725. function getLineBlockLengthX(dash) {
  26726. return map(dash, function (line) {
  26727. return getLineBlockLengthY(line);
  26728. });
  26729. }
  26730. function getLineBlockLengthY(dash) {
  26731. var blockLength = 0;
  26732. for (var i = 0; i < dash.length; ++i) {
  26733. blockLength += dash[i];
  26734. }
  26735. if (dash.length % 2 === 1) {
  26736. // [4, 2, 1] means |---- - -- |---- - -- |
  26737. // So total length is (4 + 2 + 1) * 2
  26738. return blockLength * 2;
  26739. }
  26740. return blockLength;
  26741. }
  26742. /*
  26743. * Licensed to the Apache Software Foundation (ASF) under one
  26744. * or more contributor license agreements. See the NOTICE file
  26745. * distributed with this work for additional information
  26746. * regarding copyright ownership. The ASF licenses this file
  26747. * to you under the Apache License, Version 2.0 (the
  26748. * "License"); you may not use this file except in compliance
  26749. * with the License. You may obtain a copy of the License at
  26750. *
  26751. * http://www.apache.org/licenses/LICENSE-2.0
  26752. *
  26753. * Unless required by applicable law or agreed to in writing,
  26754. * software distributed under the License is distributed on an
  26755. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26756. * KIND, either express or implied. See the License for the
  26757. * specific language governing permissions and limitations
  26758. * under the License.
  26759. */
  26760. /**
  26761. * AUTO-GENERATED FILE. DO NOT MODIFY.
  26762. */
  26763. /*
  26764. * Licensed to the Apache Software Foundation (ASF) under one
  26765. * or more contributor license agreements. See the NOTICE file
  26766. * distributed with this work for additional information
  26767. * regarding copyright ownership. The ASF licenses this file
  26768. * to you under the Apache License, Version 2.0 (the
  26769. * "License"); you may not use this file except in compliance
  26770. * with the License. You may obtain a copy of the License at
  26771. *
  26772. * http://www.apache.org/licenses/LICENSE-2.0
  26773. *
  26774. * Unless required by applicable law or agreed to in writing,
  26775. * software distributed under the License is distributed on an
  26776. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26777. * KIND, either express or implied. See the License for the
  26778. * specific language governing permissions and limitations
  26779. * under the License.
  26780. */
  26781. function decalVisual(ecModel, api) {
  26782. ecModel.eachRawSeries(function (seriesModel) {
  26783. if (ecModel.isSeriesFiltered(seriesModel)) {
  26784. return;
  26785. }
  26786. var data = seriesModel.getData();
  26787. if (data.hasItemVisual()) {
  26788. data.each(function (idx) {
  26789. var decal = data.getItemVisual(idx, 'decal');
  26790. if (decal) {
  26791. var itemStyle = data.ensureUniqueItemVisual(idx, 'style');
  26792. itemStyle.decal = createOrUpdatePatternFromDecal(decal, api);
  26793. }
  26794. });
  26795. }
  26796. var decal = data.getVisual('decal');
  26797. if (decal) {
  26798. var style = data.getVisual('style');
  26799. style.decal = createOrUpdatePatternFromDecal(decal, api);
  26800. }
  26801. });
  26802. }
  26803. function parseXML(svg) {
  26804. if (isString(svg)) {
  26805. var parser = new DOMParser();
  26806. svg = parser.parseFromString(svg, 'text/xml');
  26807. }
  26808. var svgNode = svg;
  26809. if (svgNode.nodeType === 9) {
  26810. svgNode = svgNode.firstChild;
  26811. }
  26812. while (svgNode.nodeName.toLowerCase() !== 'svg' || svgNode.nodeType !== 1) {
  26813. svgNode = svgNode.nextSibling;
  26814. }
  26815. return svgNode;
  26816. }
  26817. var nodeParsers;
  26818. var INHERITABLE_STYLE_ATTRIBUTES_MAP = {
  26819. 'fill': 'fill',
  26820. 'stroke': 'stroke',
  26821. 'stroke-width': 'lineWidth',
  26822. 'opacity': 'opacity',
  26823. 'fill-opacity': 'fillOpacity',
  26824. 'stroke-opacity': 'strokeOpacity',
  26825. 'stroke-dasharray': 'lineDash',
  26826. 'stroke-dashoffset': 'lineDashOffset',
  26827. 'stroke-linecap': 'lineCap',
  26828. 'stroke-linejoin': 'lineJoin',
  26829. 'stroke-miterlimit': 'miterLimit',
  26830. 'font-family': 'fontFamily',
  26831. 'font-size': 'fontSize',
  26832. 'font-style': 'fontStyle',
  26833. 'font-weight': 'fontWeight',
  26834. 'text-anchor': 'textAlign',
  26835. 'visibility': 'visibility',
  26836. 'display': 'display'
  26837. };
  26838. var INHERITABLE_STYLE_ATTRIBUTES_MAP_KEYS = keys(INHERITABLE_STYLE_ATTRIBUTES_MAP);
  26839. var SELF_STYLE_ATTRIBUTES_MAP = {
  26840. 'alignment-baseline': 'textBaseline',
  26841. 'stop-color': 'stopColor'
  26842. };
  26843. var SELF_STYLE_ATTRIBUTES_MAP_KEYS = keys(SELF_STYLE_ATTRIBUTES_MAP);
  26844. var SVGParser = function () {
  26845. function SVGParser() {
  26846. this._defs = {};
  26847. this._root = null;
  26848. }
  26849. SVGParser.prototype.parse = function (xml, opt) {
  26850. opt = opt || {};
  26851. var svg = parseXML(xml);
  26852. if (!svg) {
  26853. throw new Error('Illegal svg');
  26854. }
  26855. this._defsUsePending = [];
  26856. var root = new Group();
  26857. this._root = root;
  26858. var named = [];
  26859. var viewBox = svg.getAttribute('viewBox') || '';
  26860. var width = parseFloat(svg.getAttribute('width') || opt.width);
  26861. var height = parseFloat(svg.getAttribute('height') || opt.height);
  26862. isNaN(width) && (width = null);
  26863. isNaN(height) && (height = null);
  26864. parseAttributes(svg, root, null, true, false);
  26865. var child = svg.firstChild;
  26866. while (child) {
  26867. this._parseNode(child, root, named, null, false, false);
  26868. child = child.nextSibling;
  26869. }
  26870. applyDefs(this._defs, this._defsUsePending);
  26871. this._defsUsePending = [];
  26872. var viewBoxRect;
  26873. var viewBoxTransform;
  26874. if (viewBox) {
  26875. var viewBoxArr = splitNumberSequence(viewBox);
  26876. if (viewBoxArr.length >= 4) {
  26877. viewBoxRect = {
  26878. x: parseFloat(viewBoxArr[0] || 0),
  26879. y: parseFloat(viewBoxArr[1] || 0),
  26880. width: parseFloat(viewBoxArr[2]),
  26881. height: parseFloat(viewBoxArr[3])
  26882. };
  26883. }
  26884. }
  26885. if (viewBoxRect && width != null && height != null) {
  26886. viewBoxTransform = makeViewBoxTransform(viewBoxRect, {
  26887. x: 0,
  26888. y: 0,
  26889. width: width,
  26890. height: height
  26891. });
  26892. if (!opt.ignoreViewBox) {
  26893. var elRoot = root;
  26894. root = new Group();
  26895. root.add(elRoot);
  26896. elRoot.scaleX = elRoot.scaleY = viewBoxTransform.scale;
  26897. elRoot.x = viewBoxTransform.x;
  26898. elRoot.y = viewBoxTransform.y;
  26899. }
  26900. }
  26901. if (!opt.ignoreRootClip && width != null && height != null) {
  26902. root.setClipPath(new Rect({
  26903. shape: {
  26904. x: 0,
  26905. y: 0,
  26906. width: width,
  26907. height: height
  26908. }
  26909. }));
  26910. }
  26911. return {
  26912. root: root,
  26913. width: width,
  26914. height: height,
  26915. viewBoxRect: viewBoxRect,
  26916. viewBoxTransform: viewBoxTransform,
  26917. named: named
  26918. };
  26919. };
  26920. SVGParser.prototype._parseNode = function (xmlNode, parentGroup, named, namedFrom, isInDefs, isInText) {
  26921. var nodeName = xmlNode.nodeName.toLowerCase();
  26922. var el;
  26923. var namedFromForSub = namedFrom;
  26924. if (nodeName === 'defs') {
  26925. isInDefs = true;
  26926. }
  26927. if (nodeName === 'text') {
  26928. isInText = true;
  26929. }
  26930. if (nodeName === 'defs' || nodeName === 'switch') {
  26931. el = parentGroup;
  26932. } else {
  26933. if (!isInDefs) {
  26934. var parser_1 = nodeParsers[nodeName];
  26935. if (parser_1 && hasOwn(nodeParsers, nodeName)) {
  26936. el = parser_1.call(this, xmlNode, parentGroup);
  26937. var nameAttr = xmlNode.getAttribute('name');
  26938. if (nameAttr) {
  26939. var newNamed = {
  26940. name: nameAttr,
  26941. namedFrom: null,
  26942. svgNodeTagLower: nodeName,
  26943. el: el
  26944. };
  26945. named.push(newNamed);
  26946. if (nodeName === 'g') {
  26947. namedFromForSub = newNamed;
  26948. }
  26949. } else if (namedFrom) {
  26950. named.push({
  26951. name: namedFrom.name,
  26952. namedFrom: namedFrom,
  26953. svgNodeTagLower: nodeName,
  26954. el: el
  26955. });
  26956. }
  26957. parentGroup.add(el);
  26958. }
  26959. }
  26960. var parser = paintServerParsers[nodeName];
  26961. if (parser && hasOwn(paintServerParsers, nodeName)) {
  26962. var def = parser.call(this, xmlNode);
  26963. var id = xmlNode.getAttribute('id');
  26964. if (id) {
  26965. this._defs[id] = def;
  26966. }
  26967. }
  26968. }
  26969. if (el && el.isGroup) {
  26970. var child = xmlNode.firstChild;
  26971. while (child) {
  26972. if (child.nodeType === 1) {
  26973. this._parseNode(child, el, named, namedFromForSub, isInDefs, isInText);
  26974. } else if (child.nodeType === 3 && isInText) {
  26975. this._parseText(child, el);
  26976. }
  26977. child = child.nextSibling;
  26978. }
  26979. }
  26980. };
  26981. SVGParser.prototype._parseText = function (xmlNode, parentGroup) {
  26982. var text = new TSpan({
  26983. style: {
  26984. text: xmlNode.textContent
  26985. },
  26986. silent: true,
  26987. x: this._textX || 0,
  26988. y: this._textY || 0
  26989. });
  26990. inheritStyle(parentGroup, text);
  26991. parseAttributes(xmlNode, text, this._defsUsePending, false, false);
  26992. applyTextAlignment(text, parentGroup);
  26993. var textStyle = text.style;
  26994. var fontSize = textStyle.fontSize;
  26995. if (fontSize && fontSize < 9) {
  26996. textStyle.fontSize = 9;
  26997. text.scaleX *= fontSize / 9;
  26998. text.scaleY *= fontSize / 9;
  26999. }
  27000. var font = (textStyle.fontSize || textStyle.fontFamily) && [textStyle.fontStyle, textStyle.fontWeight, (textStyle.fontSize || 12) + 'px', textStyle.fontFamily || 'sans-serif'].join(' ');
  27001. textStyle.font = font;
  27002. var rect = text.getBoundingRect();
  27003. this._textX += rect.width;
  27004. parentGroup.add(text);
  27005. return text;
  27006. };
  27007. SVGParser.internalField = function () {
  27008. nodeParsers = {
  27009. 'g': function (xmlNode, parentGroup) {
  27010. var g = new Group();
  27011. inheritStyle(parentGroup, g);
  27012. parseAttributes(xmlNode, g, this._defsUsePending, false, false);
  27013. return g;
  27014. },
  27015. 'rect': function (xmlNode, parentGroup) {
  27016. var rect = new Rect();
  27017. inheritStyle(parentGroup, rect);
  27018. parseAttributes(xmlNode, rect, this._defsUsePending, false, false);
  27019. rect.setShape({
  27020. x: parseFloat(xmlNode.getAttribute('x') || '0'),
  27021. y: parseFloat(xmlNode.getAttribute('y') || '0'),
  27022. width: parseFloat(xmlNode.getAttribute('width') || '0'),
  27023. height: parseFloat(xmlNode.getAttribute('height') || '0')
  27024. });
  27025. rect.silent = true;
  27026. return rect;
  27027. },
  27028. 'circle': function (xmlNode, parentGroup) {
  27029. var circle = new Circle();
  27030. inheritStyle(parentGroup, circle);
  27031. parseAttributes(xmlNode, circle, this._defsUsePending, false, false);
  27032. circle.setShape({
  27033. cx: parseFloat(xmlNode.getAttribute('cx') || '0'),
  27034. cy: parseFloat(xmlNode.getAttribute('cy') || '0'),
  27035. r: parseFloat(xmlNode.getAttribute('r') || '0')
  27036. });
  27037. circle.silent = true;
  27038. return circle;
  27039. },
  27040. 'line': function (xmlNode, parentGroup) {
  27041. var line = new Line();
  27042. inheritStyle(parentGroup, line);
  27043. parseAttributes(xmlNode, line, this._defsUsePending, false, false);
  27044. line.setShape({
  27045. x1: parseFloat(xmlNode.getAttribute('x1') || '0'),
  27046. y1: parseFloat(xmlNode.getAttribute('y1') || '0'),
  27047. x2: parseFloat(xmlNode.getAttribute('x2') || '0'),
  27048. y2: parseFloat(xmlNode.getAttribute('y2') || '0')
  27049. });
  27050. line.silent = true;
  27051. return line;
  27052. },
  27053. 'ellipse': function (xmlNode, parentGroup) {
  27054. var ellipse = new Ellipse();
  27055. inheritStyle(parentGroup, ellipse);
  27056. parseAttributes(xmlNode, ellipse, this._defsUsePending, false, false);
  27057. ellipse.setShape({
  27058. cx: parseFloat(xmlNode.getAttribute('cx') || '0'),
  27059. cy: parseFloat(xmlNode.getAttribute('cy') || '0'),
  27060. rx: parseFloat(xmlNode.getAttribute('rx') || '0'),
  27061. ry: parseFloat(xmlNode.getAttribute('ry') || '0')
  27062. });
  27063. ellipse.silent = true;
  27064. return ellipse;
  27065. },
  27066. 'polygon': function (xmlNode, parentGroup) {
  27067. var pointsStr = xmlNode.getAttribute('points');
  27068. var pointsArr;
  27069. if (pointsStr) {
  27070. pointsArr = parsePoints(pointsStr);
  27071. }
  27072. var polygon = new Polygon({
  27073. shape: {
  27074. points: pointsArr || []
  27075. },
  27076. silent: true
  27077. });
  27078. inheritStyle(parentGroup, polygon);
  27079. parseAttributes(xmlNode, polygon, this._defsUsePending, false, false);
  27080. return polygon;
  27081. },
  27082. 'polyline': function (xmlNode, parentGroup) {
  27083. var pointsStr = xmlNode.getAttribute('points');
  27084. var pointsArr;
  27085. if (pointsStr) {
  27086. pointsArr = parsePoints(pointsStr);
  27087. }
  27088. var polyline = new Polyline({
  27089. shape: {
  27090. points: pointsArr || []
  27091. },
  27092. silent: true
  27093. });
  27094. inheritStyle(parentGroup, polyline);
  27095. parseAttributes(xmlNode, polyline, this._defsUsePending, false, false);
  27096. return polyline;
  27097. },
  27098. 'image': function (xmlNode, parentGroup) {
  27099. var img = new ZRImage();
  27100. inheritStyle(parentGroup, img);
  27101. parseAttributes(xmlNode, img, this._defsUsePending, false, false);
  27102. img.setStyle({
  27103. image: xmlNode.getAttribute('xlink:href'),
  27104. x: +xmlNode.getAttribute('x'),
  27105. y: +xmlNode.getAttribute('y'),
  27106. width: +xmlNode.getAttribute('width'),
  27107. height: +xmlNode.getAttribute('height')
  27108. });
  27109. img.silent = true;
  27110. return img;
  27111. },
  27112. 'text': function (xmlNode, parentGroup) {
  27113. var x = xmlNode.getAttribute('x') || '0';
  27114. var y = xmlNode.getAttribute('y') || '0';
  27115. var dx = xmlNode.getAttribute('dx') || '0';
  27116. var dy = xmlNode.getAttribute('dy') || '0';
  27117. this._textX = parseFloat(x) + parseFloat(dx);
  27118. this._textY = parseFloat(y) + parseFloat(dy);
  27119. var g = new Group();
  27120. inheritStyle(parentGroup, g);
  27121. parseAttributes(xmlNode, g, this._defsUsePending, false, true);
  27122. return g;
  27123. },
  27124. 'tspan': function (xmlNode, parentGroup) {
  27125. var x = xmlNode.getAttribute('x');
  27126. var y = xmlNode.getAttribute('y');
  27127. if (x != null) {
  27128. this._textX = parseFloat(x);
  27129. }
  27130. if (y != null) {
  27131. this._textY = parseFloat(y);
  27132. }
  27133. var dx = xmlNode.getAttribute('dx') || '0';
  27134. var dy = xmlNode.getAttribute('dy') || '0';
  27135. var g = new Group();
  27136. inheritStyle(parentGroup, g);
  27137. parseAttributes(xmlNode, g, this._defsUsePending, false, true);
  27138. this._textX += parseFloat(dx);
  27139. this._textY += parseFloat(dy);
  27140. return g;
  27141. },
  27142. 'path': function (xmlNode, parentGroup) {
  27143. var d = xmlNode.getAttribute('d') || '';
  27144. var path = createFromString(d);
  27145. inheritStyle(parentGroup, path);
  27146. parseAttributes(xmlNode, path, this._defsUsePending, false, false);
  27147. path.silent = true;
  27148. return path;
  27149. }
  27150. };
  27151. }();
  27152. return SVGParser;
  27153. }();
  27154. var paintServerParsers = {
  27155. 'lineargradient': function (xmlNode) {
  27156. var x1 = parseInt(xmlNode.getAttribute('x1') || '0', 10);
  27157. var y1 = parseInt(xmlNode.getAttribute('y1') || '0', 10);
  27158. var x2 = parseInt(xmlNode.getAttribute('x2') || '10', 10);
  27159. var y2 = parseInt(xmlNode.getAttribute('y2') || '0', 10);
  27160. var gradient = new LinearGradient(x1, y1, x2, y2);
  27161. parsePaintServerUnit(xmlNode, gradient);
  27162. parseGradientColorStops(xmlNode, gradient);
  27163. return gradient;
  27164. },
  27165. 'radialgradient': function (xmlNode) {
  27166. var cx = parseInt(xmlNode.getAttribute('cx') || '0', 10);
  27167. var cy = parseInt(xmlNode.getAttribute('cy') || '0', 10);
  27168. var r = parseInt(xmlNode.getAttribute('r') || '0', 10);
  27169. var gradient = new RadialGradient(cx, cy, r);
  27170. parsePaintServerUnit(xmlNode, gradient);
  27171. parseGradientColorStops(xmlNode, gradient);
  27172. return gradient;
  27173. }
  27174. };
  27175. function parsePaintServerUnit(xmlNode, gradient) {
  27176. var gradientUnits = xmlNode.getAttribute('gradientUnits');
  27177. if (gradientUnits === 'userSpaceOnUse') {
  27178. gradient.global = true;
  27179. }
  27180. }
  27181. function parseGradientColorStops(xmlNode, gradient) {
  27182. var stop = xmlNode.firstChild;
  27183. while (stop) {
  27184. if (stop.nodeType === 1 && stop.nodeName.toLocaleLowerCase() === 'stop') {
  27185. var offsetStr = stop.getAttribute('offset');
  27186. var offset = void 0;
  27187. if (offsetStr && offsetStr.indexOf('%') > 0) {
  27188. offset = parseInt(offsetStr, 10) / 100;
  27189. } else if (offsetStr) {
  27190. offset = parseFloat(offsetStr);
  27191. } else {
  27192. offset = 0;
  27193. }
  27194. var styleVals = {};
  27195. parseInlineStyle(stop, styleVals, styleVals);
  27196. var stopColor = styleVals.stopColor || stop.getAttribute('stop-color') || '#000000';
  27197. gradient.colorStops.push({
  27198. offset: offset,
  27199. color: stopColor
  27200. });
  27201. }
  27202. stop = stop.nextSibling;
  27203. }
  27204. }
  27205. function inheritStyle(parent, child) {
  27206. if (parent && parent.__inheritedStyle) {
  27207. if (!child.__inheritedStyle) {
  27208. child.__inheritedStyle = {};
  27209. }
  27210. defaults(child.__inheritedStyle, parent.__inheritedStyle);
  27211. }
  27212. }
  27213. function parsePoints(pointsString) {
  27214. var list = splitNumberSequence(pointsString);
  27215. var points = [];
  27216. for (var i = 0; i < list.length; i += 2) {
  27217. var x = parseFloat(list[i]);
  27218. var y = parseFloat(list[i + 1]);
  27219. points.push([x, y]);
  27220. }
  27221. return points;
  27222. }
  27223. function parseAttributes(xmlNode, el, defsUsePending, onlyInlineStyle, isTextGroup) {
  27224. var disp = el;
  27225. var inheritedStyle = disp.__inheritedStyle = disp.__inheritedStyle || {};
  27226. var selfStyle = {};
  27227. if (xmlNode.nodeType === 1) {
  27228. parseTransformAttribute(xmlNode, el);
  27229. parseInlineStyle(xmlNode, inheritedStyle, selfStyle);
  27230. if (!onlyInlineStyle) {
  27231. parseAttributeStyle(xmlNode, inheritedStyle, selfStyle);
  27232. }
  27233. }
  27234. disp.style = disp.style || {};
  27235. if (inheritedStyle.fill != null) {
  27236. disp.style.fill = getFillStrokeStyle(disp, 'fill', inheritedStyle.fill, defsUsePending);
  27237. }
  27238. if (inheritedStyle.stroke != null) {
  27239. disp.style.stroke = getFillStrokeStyle(disp, 'stroke', inheritedStyle.stroke, defsUsePending);
  27240. }
  27241. each$1(['lineWidth', 'opacity', 'fillOpacity', 'strokeOpacity', 'miterLimit', 'fontSize'], function (propName) {
  27242. if (inheritedStyle[propName] != null) {
  27243. disp.style[propName] = parseFloat(inheritedStyle[propName]);
  27244. }
  27245. });
  27246. each$1(['lineDashOffset', 'lineCap', 'lineJoin', 'fontWeight', 'fontFamily', 'fontStyle', 'textAlign'], function (propName) {
  27247. if (inheritedStyle[propName] != null) {
  27248. disp.style[propName] = inheritedStyle[propName];
  27249. }
  27250. });
  27251. if (isTextGroup) {
  27252. disp.__selfStyle = selfStyle;
  27253. }
  27254. if (inheritedStyle.lineDash) {
  27255. disp.style.lineDash = map(splitNumberSequence(inheritedStyle.lineDash), function (str) {
  27256. return parseFloat(str);
  27257. });
  27258. }
  27259. if (inheritedStyle.visibility === 'hidden' || inheritedStyle.visibility === 'collapse') {
  27260. disp.invisible = true;
  27261. }
  27262. if (inheritedStyle.display === 'none') {
  27263. disp.ignore = true;
  27264. }
  27265. disp.z = -10000;
  27266. disp.z2 = -1000;
  27267. }
  27268. function applyTextAlignment(text, parentGroup) {
  27269. var parentSelfStyle = parentGroup.__selfStyle;
  27270. if (parentSelfStyle) {
  27271. var textBaseline = parentSelfStyle.textBaseline;
  27272. var zrTextBaseline = textBaseline;
  27273. if (!textBaseline || textBaseline === 'auto') {
  27274. zrTextBaseline = 'alphabetic';
  27275. } else if (textBaseline === 'baseline') {
  27276. zrTextBaseline = 'alphabetic';
  27277. } else if (textBaseline === 'before-edge' || textBaseline === 'text-before-edge') {
  27278. zrTextBaseline = 'top';
  27279. } else if (textBaseline === 'after-edge' || textBaseline === 'text-after-edge') {
  27280. zrTextBaseline = 'bottom';
  27281. } else if (textBaseline === 'central' || textBaseline === 'mathematical') {
  27282. zrTextBaseline = 'middle';
  27283. }
  27284. text.style.textBaseline = zrTextBaseline;
  27285. }
  27286. var parentInheritedStyle = parentGroup.__inheritedStyle;
  27287. if (parentInheritedStyle) {
  27288. var textAlign = parentInheritedStyle.textAlign;
  27289. var zrTextAlign = textAlign;
  27290. if (textAlign) {
  27291. if (textAlign === 'middle') {
  27292. zrTextAlign = 'center';
  27293. }
  27294. text.style.textAlign = zrTextAlign;
  27295. }
  27296. }
  27297. }
  27298. var urlRegex = /^url\(\s*#(.*?)\)/;
  27299. function getFillStrokeStyle(el, method, str, defsUsePending) {
  27300. var urlMatch = str && str.match(urlRegex);
  27301. if (urlMatch) {
  27302. var url = trim(urlMatch[1]);
  27303. defsUsePending.push([el, method, url]);
  27304. return;
  27305. }
  27306. if (str === 'none') {
  27307. str = null;
  27308. }
  27309. return str;
  27310. }
  27311. function applyDefs(defs, defsUsePending) {
  27312. for (var i = 0; i < defsUsePending.length; i++) {
  27313. var item = defsUsePending[i];
  27314. item[0].style[item[1]] = defs[item[2]];
  27315. }
  27316. }
  27317. var numberReg$1 = /-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g;
  27318. function splitNumberSequence(rawStr) {
  27319. return rawStr.match(numberReg$1) || [];
  27320. }
  27321. var transformRegex = /(translate|scale|rotate|skewX|skewY|matrix)\(([\-\s0-9\.eE,]*)\)/g;
  27322. function parseTransformAttribute(xmlNode, node) {
  27323. var transform = xmlNode.getAttribute('transform');
  27324. if (transform) {
  27325. transform = transform.replace(/,/g, ' ');
  27326. var transformOps_1 = [];
  27327. var mt = null;
  27328. transform.replace(transformRegex, function (str, type, value) {
  27329. transformOps_1.push(type, value);
  27330. return '';
  27331. });
  27332. for (var i = transformOps_1.length - 1; i > 0; i -= 2) {
  27333. var value = transformOps_1[i];
  27334. var type = transformOps_1[i - 1];
  27335. var valueArr = void 0;
  27336. mt = mt || create$1();
  27337. switch (type) {
  27338. case 'translate':
  27339. valueArr = splitNumberSequence(value);
  27340. translate(mt, mt, [parseFloat(valueArr[0]), parseFloat(valueArr[1] || '0')]);
  27341. break;
  27342. case 'scale':
  27343. valueArr = splitNumberSequence(value);
  27344. scale$1(mt, mt, [parseFloat(valueArr[0]), parseFloat(valueArr[1] || valueArr[0])]);
  27345. break;
  27346. case 'rotate':
  27347. valueArr = splitNumberSequence(value);
  27348. rotate(mt, mt, -parseFloat(valueArr[0]) / 180 * Math.PI);
  27349. break;
  27350. case 'skew':
  27351. valueArr = splitNumberSequence(value);
  27352. console.warn('Skew transform is not supported yet');
  27353. break;
  27354. case 'matrix':
  27355. valueArr = splitNumberSequence(value);
  27356. mt[0] = parseFloat(valueArr[0]);
  27357. mt[1] = parseFloat(valueArr[1]);
  27358. mt[2] = parseFloat(valueArr[2]);
  27359. mt[3] = parseFloat(valueArr[3]);
  27360. mt[4] = parseFloat(valueArr[4]);
  27361. mt[5] = parseFloat(valueArr[5]);
  27362. break;
  27363. }
  27364. }
  27365. node.setLocalTransform(mt);
  27366. }
  27367. }
  27368. var styleRegex = /([^\s:;]+)\s*:\s*([^:;]+)/g;
  27369. function parseInlineStyle(xmlNode, inheritableStyleResult, selfStyleResult) {
  27370. var style = xmlNode.getAttribute('style');
  27371. if (!style) {
  27372. return;
  27373. }
  27374. styleRegex.lastIndex = 0;
  27375. var styleRegResult;
  27376. while ((styleRegResult = styleRegex.exec(style)) != null) {
  27377. var svgStlAttr = styleRegResult[1];
  27378. var zrInheritableStlAttr = hasOwn(INHERITABLE_STYLE_ATTRIBUTES_MAP, svgStlAttr) ? INHERITABLE_STYLE_ATTRIBUTES_MAP[svgStlAttr] : null;
  27379. if (zrInheritableStlAttr) {
  27380. inheritableStyleResult[zrInheritableStlAttr] = styleRegResult[2];
  27381. }
  27382. var zrSelfStlAttr = hasOwn(SELF_STYLE_ATTRIBUTES_MAP, svgStlAttr) ? SELF_STYLE_ATTRIBUTES_MAP[svgStlAttr] : null;
  27383. if (zrSelfStlAttr) {
  27384. selfStyleResult[zrSelfStlAttr] = styleRegResult[2];
  27385. }
  27386. }
  27387. }
  27388. function parseAttributeStyle(xmlNode, inheritableStyleResult, selfStyleResult) {
  27389. for (var i = 0; i < INHERITABLE_STYLE_ATTRIBUTES_MAP_KEYS.length; i++) {
  27390. var svgAttrName = INHERITABLE_STYLE_ATTRIBUTES_MAP_KEYS[i];
  27391. var attrValue = xmlNode.getAttribute(svgAttrName);
  27392. if (attrValue != null) {
  27393. inheritableStyleResult[INHERITABLE_STYLE_ATTRIBUTES_MAP[svgAttrName]] = attrValue;
  27394. }
  27395. }
  27396. for (var i = 0; i < SELF_STYLE_ATTRIBUTES_MAP_KEYS.length; i++) {
  27397. var svgAttrName = SELF_STYLE_ATTRIBUTES_MAP_KEYS[i];
  27398. var attrValue = xmlNode.getAttribute(svgAttrName);
  27399. if (attrValue != null) {
  27400. selfStyleResult[SELF_STYLE_ATTRIBUTES_MAP[svgAttrName]] = attrValue;
  27401. }
  27402. }
  27403. }
  27404. function makeViewBoxTransform(viewBoxRect, boundingRect) {
  27405. var scaleX = boundingRect.width / viewBoxRect.width;
  27406. var scaleY = boundingRect.height / viewBoxRect.height;
  27407. var scale = Math.min(scaleX, scaleY);
  27408. return {
  27409. scale: scale,
  27410. x: -(viewBoxRect.x + viewBoxRect.width / 2) * scale + (boundingRect.x + boundingRect.width / 2),
  27411. y: -(viewBoxRect.y + viewBoxRect.height / 2) * scale + (boundingRect.y + boundingRect.height / 2)
  27412. };
  27413. }
  27414. function parseSVG(xml, opt) {
  27415. var parser = new SVGParser();
  27416. return parser.parse(xml, opt);
  27417. }
  27418. var EPSILON$3 = 1e-8;
  27419. function isAroundEqual$1(a, b) {
  27420. return Math.abs(a - b) < EPSILON$3;
  27421. }
  27422. function contain$1(points, x, y) {
  27423. var w = 0;
  27424. var p = points[0];
  27425. if (!p) {
  27426. return false;
  27427. }
  27428. for (var i = 1; i < points.length; i++) {
  27429. var p2 = points[i];
  27430. w += windingLine(p[0], p[1], p2[0], p2[1], x, y);
  27431. p = p2;
  27432. }
  27433. var p0 = points[0];
  27434. if (!isAroundEqual$1(p[0], p0[0]) || !isAroundEqual$1(p[1], p0[1])) {
  27435. w += windingLine(p[0], p[1], p0[0], p0[1], x, y);
  27436. }
  27437. return w !== 0;
  27438. }
  27439. /*
  27440. * Licensed to the Apache Software Foundation (ASF) under one
  27441. * or more contributor license agreements. See the NOTICE file
  27442. * distributed with this work for additional information
  27443. * regarding copyright ownership. The ASF licenses this file
  27444. * to you under the Apache License, Version 2.0 (the
  27445. * "License"); you may not use this file except in compliance
  27446. * with the License. You may obtain a copy of the License at
  27447. *
  27448. * http://www.apache.org/licenses/LICENSE-2.0
  27449. *
  27450. * Unless required by applicable law or agreed to in writing,
  27451. * software distributed under the License is distributed on an
  27452. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  27453. * KIND, either express or implied. See the License for the
  27454. * specific language governing permissions and limitations
  27455. * under the License.
  27456. */
  27457. /**
  27458. * AUTO-GENERATED FILE. DO NOT MODIFY.
  27459. */
  27460. /*
  27461. * Licensed to the Apache Software Foundation (ASF) under one
  27462. * or more contributor license agreements. See the NOTICE file
  27463. * distributed with this work for additional information
  27464. * regarding copyright ownership. The ASF licenses this file
  27465. * to you under the Apache License, Version 2.0 (the
  27466. * "License"); you may not use this file except in compliance
  27467. * with the License. You may obtain a copy of the License at
  27468. *
  27469. * http://www.apache.org/licenses/LICENSE-2.0
  27470. *
  27471. * Unless required by applicable law or agreed to in writing,
  27472. * software distributed under the License is distributed on an
  27473. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  27474. * KIND, either express or implied. See the License for the
  27475. * specific language governing permissions and limitations
  27476. * under the License.
  27477. */
  27478. var TMP_TRANSFORM = [];
  27479. var Region =
  27480. /** @class */
  27481. function () {
  27482. function Region(name) {
  27483. this.name = name;
  27484. }
  27485. /**
  27486. * Get center point in data unit. That is,
  27487. * for GeoJSONRegion, the unit is lat/lng,
  27488. * for GeoSVGRegion, the unit is SVG local coord.
  27489. */
  27490. Region.prototype.getCenter = function () {
  27491. return;
  27492. };
  27493. return Region;
  27494. }();
  27495. var GeoJSONRegion =
  27496. /** @class */
  27497. function (_super) {
  27498. __extends(GeoJSONRegion, _super);
  27499. function GeoJSONRegion(name, geometries, cp) {
  27500. var _this = _super.call(this, name) || this;
  27501. _this.type = 'geoJSON';
  27502. _this.geometries = geometries;
  27503. if (!cp) {
  27504. var rect = _this.getBoundingRect();
  27505. cp = [rect.x + rect.width / 2, rect.y + rect.height / 2];
  27506. } else {
  27507. cp = [cp[0], cp[1]];
  27508. }
  27509. _this._center = cp;
  27510. return _this;
  27511. }
  27512. GeoJSONRegion.prototype.getBoundingRect = function () {
  27513. var rect = this._rect;
  27514. if (rect) {
  27515. return rect;
  27516. }
  27517. var MAX_NUMBER = Number.MAX_VALUE;
  27518. var min$$1 = [MAX_NUMBER, MAX_NUMBER];
  27519. var max$$1 = [-MAX_NUMBER, -MAX_NUMBER];
  27520. var min2 = [];
  27521. var max2 = [];
  27522. var geometries = this.geometries;
  27523. var i = 0;
  27524. for (; i < geometries.length; i++) {
  27525. // Only support polygon
  27526. if (geometries[i].type !== 'polygon') {
  27527. continue;
  27528. } // Doesn't consider hole
  27529. var exterior = geometries[i].exterior;
  27530. fromPoints(exterior, min2, max2);
  27531. min(min$$1, min$$1, min2);
  27532. max(max$$1, max$$1, max2);
  27533. } // No data
  27534. if (i === 0) {
  27535. min$$1[0] = min$$1[1] = max$$1[0] = max$$1[1] = 0;
  27536. }
  27537. return this._rect = new BoundingRect(min$$1[0], min$$1[1], max$$1[0] - min$$1[0], max$$1[1] - min$$1[1]);
  27538. };
  27539. GeoJSONRegion.prototype.contain = function (coord) {
  27540. var rect = this.getBoundingRect();
  27541. var geometries = this.geometries;
  27542. if (!rect.contain(coord[0], coord[1])) {
  27543. return false;
  27544. }
  27545. loopGeo: for (var i = 0, len$$1 = geometries.length; i < len$$1; i++) {
  27546. // Only support polygon.
  27547. if (geometries[i].type !== 'polygon') {
  27548. continue;
  27549. }
  27550. var exterior = geometries[i].exterior;
  27551. var interiors = geometries[i].interiors;
  27552. if (contain$1(exterior, coord[0], coord[1])) {
  27553. // Not in the region if point is in the hole.
  27554. for (var k = 0; k < (interiors ? interiors.length : 0); k++) {
  27555. if (contain$1(interiors[k], coord[0], coord[1])) {
  27556. continue loopGeo;
  27557. }
  27558. }
  27559. return true;
  27560. }
  27561. }
  27562. return false;
  27563. };
  27564. GeoJSONRegion.prototype.transformTo = function (x, y, width, height) {
  27565. var rect = this.getBoundingRect();
  27566. var aspect = rect.width / rect.height;
  27567. if (!width) {
  27568. width = aspect * height;
  27569. } else if (!height) {
  27570. height = width / aspect;
  27571. }
  27572. var target = new BoundingRect(x, y, width, height);
  27573. var transform = rect.calculateTransform(target);
  27574. var geometries = this.geometries;
  27575. for (var i = 0; i < geometries.length; i++) {
  27576. // Only support polygon.
  27577. if (geometries[i].type !== 'polygon') {
  27578. continue;
  27579. }
  27580. var exterior = geometries[i].exterior;
  27581. var interiors = geometries[i].interiors;
  27582. for (var p = 0; p < exterior.length; p++) {
  27583. applyTransform(exterior[p], exterior[p], transform);
  27584. }
  27585. for (var h = 0; h < (interiors ? interiors.length : 0); h++) {
  27586. for (var p = 0; p < interiors[h].length; p++) {
  27587. applyTransform(interiors[h][p], interiors[h][p], transform);
  27588. }
  27589. }
  27590. }
  27591. rect = this._rect;
  27592. rect.copy(target); // Update center
  27593. this._center = [rect.x + rect.width / 2, rect.y + rect.height / 2];
  27594. };
  27595. GeoJSONRegion.prototype.cloneShallow = function (name) {
  27596. name == null && (name = this.name);
  27597. var newRegion = new GeoJSONRegion(name, this.geometries, this._center);
  27598. newRegion._rect = this._rect;
  27599. newRegion.transformTo = null; // Simply avoid to be called.
  27600. return newRegion;
  27601. };
  27602. GeoJSONRegion.prototype.getCenter = function () {
  27603. return this._center;
  27604. };
  27605. GeoJSONRegion.prototype.setCenter = function (center) {
  27606. this._center = center;
  27607. };
  27608. return GeoJSONRegion;
  27609. }(Region);
  27610. var GeoSVGRegion =
  27611. /** @class */
  27612. function (_super) {
  27613. __extends(GeoSVGRegion, _super);
  27614. function GeoSVGRegion(name, elOnlyForCalculate) {
  27615. var _this = _super.call(this, name) || this;
  27616. _this.type = 'geoSVG';
  27617. _this._elOnlyForCalculate = elOnlyForCalculate;
  27618. return _this;
  27619. }
  27620. GeoSVGRegion.prototype.getCenter = function () {
  27621. var center = this._center;
  27622. if (!center) {
  27623. // In most cases there are no need to calculate this center.
  27624. // So calculate only when called.
  27625. center = this._center = this._calculateCenter();
  27626. }
  27627. return center;
  27628. };
  27629. GeoSVGRegion.prototype._calculateCenter = function () {
  27630. var el = this._elOnlyForCalculate;
  27631. var rect = el.getBoundingRect();
  27632. var center = [rect.x + rect.width / 2, rect.y + rect.height / 2];
  27633. var mat = identity(TMP_TRANSFORM);
  27634. var target = el;
  27635. while (target && !target.isGeoSVGGraphicRoot) {
  27636. mul$1(mat, target.getLocalTransform(), mat);
  27637. target = target.parent;
  27638. }
  27639. invert(mat, mat);
  27640. applyTransform(center, center, mat);
  27641. return center;
  27642. };
  27643. return GeoSVGRegion;
  27644. }(Region);
  27645. /*
  27646. * Licensed to the Apache Software Foundation (ASF) under one
  27647. * or more contributor license agreements. See the NOTICE file
  27648. * distributed with this work for additional information
  27649. * regarding copyright ownership. The ASF licenses this file
  27650. * to you under the Apache License, Version 2.0 (the
  27651. * "License"); you may not use this file except in compliance
  27652. * with the License. You may obtain a copy of the License at
  27653. *
  27654. * http://www.apache.org/licenses/LICENSE-2.0
  27655. *
  27656. * Unless required by applicable law or agreed to in writing,
  27657. * software distributed under the License is distributed on an
  27658. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  27659. * KIND, either express or implied. See the License for the
  27660. * specific language governing permissions and limitations
  27661. * under the License.
  27662. */
  27663. /**
  27664. * AUTO-GENERATED FILE. DO NOT MODIFY.
  27665. */
  27666. /*
  27667. * Licensed to the Apache Software Foundation (ASF) under one
  27668. * or more contributor license agreements. See the NOTICE file
  27669. * distributed with this work for additional information
  27670. * regarding copyright ownership. The ASF licenses this file
  27671. * to you under the Apache License, Version 2.0 (the
  27672. * "License"); you may not use this file except in compliance
  27673. * with the License. You may obtain a copy of the License at
  27674. *
  27675. * http://www.apache.org/licenses/LICENSE-2.0
  27676. *
  27677. * Unless required by applicable law or agreed to in writing,
  27678. * software distributed under the License is distributed on an
  27679. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  27680. * KIND, either express or implied. See the License for the
  27681. * specific language governing permissions and limitations
  27682. * under the License.
  27683. */
  27684. /**
  27685. * "region available" means that: enable users to set attribute `name="xxx"` on those tags
  27686. * to make it be a region.
  27687. * 1. region styles and its label styles can be defined in echarts opton:
  27688. * ```js
  27689. * geo: {
  27690. * regions: [{
  27691. * name: 'xxx',
  27692. * itemStyle: { ... },
  27693. * label: { ... }
  27694. * }, {
  27695. * ...
  27696. * },
  27697. * ...]
  27698. * };
  27699. * ```
  27700. * 2. name can be duplicated in different SVG tag. All of the tags with the same name share
  27701. * a region option. For exampel if there are two <path> representing two lung lobes. They have
  27702. * no common parents but both of them need to display label "lung" inside.
  27703. */
  27704. var REGION_AVAILABLE_SVG_TAG_MAP = createHashMap(['rect', 'circle', 'line', 'ellipse', 'polygon', 'polyline', 'path', // <text> <tspan> are also enabled becuase some SVG might paint text itself,
  27705. // but still need to trigger events or tooltip.
  27706. 'text', 'tspan', // <g> is also enabled because this case: if multiple tags share one name
  27707. // and need label displayed, every tags will display the name, which is not
  27708. // expected. So we can put them into a <g name="xxx">. Thereby only one label
  27709. // displayed and located based on the bounding rect of the <g>.
  27710. 'g']);
  27711. var GeoSVGResource =
  27712. /** @class */
  27713. function () {
  27714. function GeoSVGResource(mapName, svg) {
  27715. this.type = 'geoSVG'; // All used graphics. key: hostKey, value: root
  27716. this._usedGraphicMap = createHashMap(); // All unused graphics.
  27717. this._freedGraphics = [];
  27718. this._mapName = mapName; // Only perform parse to XML object here, which might be time
  27719. // consiming for large SVG.
  27720. // Although convert XML to zrender element is also time consiming,
  27721. // if we do it here, the clone of zrender elements has to be
  27722. // required. So we do it once for each geo instance, util real
  27723. // performance issues call for optimizing it.
  27724. this._parsedXML = parseXML(svg);
  27725. }
  27726. GeoSVGResource.prototype.load = function ()
  27727. /* nameMap: NameMap */
  27728. {
  27729. // In the "load" stage, graphic need to be built to
  27730. // get boundingRect for geo coordinate system.
  27731. var firstGraphic = this._firstGraphic; // Create the return data structure only when first graphic created.
  27732. // Because they will be used in geo coordinate system update stage,
  27733. // and `regions` will be mounted at `geo` coordinate system,
  27734. // in which there is no "view" info, so that it should better not to
  27735. // make references to graphic elements.
  27736. if (!firstGraphic) {
  27737. firstGraphic = this._firstGraphic = this._buildGraphic(this._parsedXML);
  27738. this._freedGraphics.push(firstGraphic);
  27739. this._boundingRect = this._firstGraphic.boundingRect.clone(); // PENDING: `nameMap` will not be supported until some real requirement come.
  27740. // if (nameMap) {
  27741. // named = applyNameMap(named, nameMap);
  27742. // }
  27743. var _a = createRegions(firstGraphic.named),
  27744. regions = _a.regions,
  27745. regionsMap = _a.regionsMap;
  27746. this._regions = regions;
  27747. this._regionsMap = regionsMap;
  27748. }
  27749. return {
  27750. boundingRect: this._boundingRect,
  27751. regions: this._regions,
  27752. regionsMap: this._regionsMap
  27753. };
  27754. };
  27755. GeoSVGResource.prototype._buildGraphic = function (svgXML) {
  27756. var result;
  27757. var rootFromParse;
  27758. try {
  27759. result = svgXML && parseSVG(svgXML, {
  27760. ignoreViewBox: true,
  27761. ignoreRootClip: true
  27762. }) || {};
  27763. rootFromParse = result.root;
  27764. assert$1(rootFromParse != null);
  27765. } catch (e) {
  27766. throw new Error('Invalid svg format\n' + e.message);
  27767. } // Note: we keep the covenant that the root has no transform. So always add an extra root.
  27768. var root = new Group();
  27769. root.add(rootFromParse);
  27770. root.isGeoSVGGraphicRoot = true; // [THE_RULE_OF_VIEWPORT_AND_VIEWBOX]
  27771. //
  27772. // Consider: `<svg width="..." height="..." viewBox="...">`
  27773. // - the `width/height` we call it `svgWidth/svgHeight` for short.
  27774. // - `(0, 0, svgWidth, svgHeight)` defines the viewport of the SVG, or say,
  27775. // "viewport boundingRect", or `boundingRect` for short.
  27776. // - `viewBox` defines the transform from the real content ot the viewport.
  27777. // `viewBox` has the same unit as the content of SVG.
  27778. // If `viewBox` exists, a transform is defined, so the unit of `svgWidth/svgHeight` become
  27779. // different from the content of SVG. Otherwise, they are the same.
  27780. //
  27781. // If both `svgWidth/svgHeight/viewBox` are specified in a SVG file, the transform rule will be:
  27782. // 0. `boundingRect` is `(0, 0, svgWidth, svgHeight)`. Set it to Geo['_rect'] (View['_rect']).
  27783. // 1. Make a transform from `viewBox` to `boundingRect`.
  27784. // Note: only suport `preserveAspectRatio 'xMidYMid'` here. That is, this transform will preserve
  27785. // the aspect ratio.
  27786. // 2. Make a transform from boundingRect to Geo['_viewRect'] (View['_viewRect'])
  27787. // (`Geo`/`View` will do this job).
  27788. // Note: this transform might not preserve aspect radio, which depending on how users specify
  27789. // viewRect in echarts option (e.g., `geo.left/top/width/height` will not preserve aspect ratio,
  27790. // but `geo.layoutCenter/layoutSize` will preserve aspect ratio).
  27791. //
  27792. // If `svgWidth/svgHeight` not specified, we use `viewBox` as the `boundingRect` to make the SVG
  27793. // layout look good.
  27794. //
  27795. // If neither `svgWidth/svgHeight` nor `viewBox` are not specified, we calculate the boundingRect
  27796. // of the SVG content and use them to make SVG layout look good.
  27797. var svgWidth = result.width;
  27798. var svgHeight = result.height;
  27799. var viewBoxRect = result.viewBoxRect;
  27800. var boundingRect = this._boundingRect;
  27801. if (!boundingRect) {
  27802. var bRectX = void 0;
  27803. var bRectY = void 0;
  27804. var bRectWidth = void 0;
  27805. var bRectHeight = void 0;
  27806. if (svgWidth != null) {
  27807. bRectX = 0;
  27808. bRectWidth = svgWidth;
  27809. } else if (viewBoxRect) {
  27810. bRectX = viewBoxRect.x;
  27811. bRectWidth = viewBoxRect.width;
  27812. }
  27813. if (svgHeight != null) {
  27814. bRectY = 0;
  27815. bRectHeight = svgHeight;
  27816. } else if (viewBoxRect) {
  27817. bRectY = viewBoxRect.y;
  27818. bRectHeight = viewBoxRect.height;
  27819. } // If both viewBox and svgWidth/svgHeight not specified,
  27820. // we have to determine how to layout those element to make them look good.
  27821. if (bRectX == null || bRectY == null) {
  27822. var calculatedBoundingRect = rootFromParse.getBoundingRect();
  27823. if (bRectX == null) {
  27824. bRectX = calculatedBoundingRect.x;
  27825. bRectWidth = calculatedBoundingRect.width;
  27826. }
  27827. if (bRectY == null) {
  27828. bRectY = calculatedBoundingRect.y;
  27829. bRectHeight = calculatedBoundingRect.height;
  27830. }
  27831. }
  27832. boundingRect = this._boundingRect = new BoundingRect(bRectX, bRectY, bRectWidth, bRectHeight);
  27833. }
  27834. if (viewBoxRect) {
  27835. var viewBoxTransform = makeViewBoxTransform(viewBoxRect, boundingRect); // Only support `preserveAspectRatio 'xMidYMid'`
  27836. rootFromParse.scaleX = rootFromParse.scaleY = viewBoxTransform.scale;
  27837. rootFromParse.x = viewBoxTransform.x;
  27838. rootFromParse.y = viewBoxTransform.y;
  27839. } // SVG needs to clip based on `viewBox`. And some SVG files really rely on this feature.
  27840. // They do not strictly confine all of the content inside a display rect, but deliberately
  27841. // use a `viewBox` to define a displayable rect.
  27842. // PENDING:
  27843. // The drawback of the `setClipPath` here is: the region label (genereted by echarts) near the
  27844. // edge might also be clipped, because region labels are put as `textContent` of the SVG path.
  27845. root.setClipPath(new Rect({
  27846. shape: boundingRect.plain()
  27847. }));
  27848. var named = [];
  27849. each$1(result.named, function (namedItem) {
  27850. if (REGION_AVAILABLE_SVG_TAG_MAP.get(namedItem.svgNodeTagLower) != null) {
  27851. named.push(namedItem);
  27852. setSilent(namedItem.el);
  27853. }
  27854. });
  27855. return {
  27856. root: root,
  27857. boundingRect: boundingRect,
  27858. named: named
  27859. };
  27860. };
  27861. /**
  27862. * Consider:
  27863. * (1) One graphic element can not be shared by different `geoView` running simultaneously.
  27864. * Notice, also need to consider multiple echarts instances share a `mapRecord`.
  27865. * (2) Converting SVG to graphic elements is time consuming.
  27866. * (3) In the current architecture, `load` should be called frequently to get boundingRect,
  27867. * and it is called without view info.
  27868. * So we maintain graphic elements in this module, and enables `view` to use/return these
  27869. * graphics from/to the pool with it's uid.
  27870. */
  27871. GeoSVGResource.prototype.useGraphic = function (hostKey
  27872. /*, nameMap: NameMap */
  27873. ) {
  27874. var usedRootMap = this._usedGraphicMap;
  27875. var svgGraphic = usedRootMap.get(hostKey);
  27876. if (svgGraphic) {
  27877. return svgGraphic;
  27878. }
  27879. svgGraphic = this._freedGraphics.pop() // use the first boundingRect to avoid duplicated boundingRect calculation.
  27880. || this._buildGraphic(this._parsedXML);
  27881. usedRootMap.set(hostKey, svgGraphic); // PENDING: `nameMap` will not be supported until some real requirement come.
  27882. // `nameMap` can only be obtained from echarts option.
  27883. // The original `named` must not be modified.
  27884. // if (nameMap) {
  27885. // svgGraphic = extend({}, svgGraphic);
  27886. // svgGraphic.named = applyNameMap(svgGraphic.named, nameMap);
  27887. // }
  27888. return svgGraphic;
  27889. };
  27890. GeoSVGResource.prototype.freeGraphic = function (hostKey) {
  27891. var usedRootMap = this._usedGraphicMap;
  27892. var svgGraphic = usedRootMap.get(hostKey);
  27893. if (svgGraphic) {
  27894. usedRootMap.removeKey(hostKey);
  27895. this._freedGraphics.push(svgGraphic);
  27896. }
  27897. };
  27898. return GeoSVGResource;
  27899. }();
  27900. function setSilent(el) {
  27901. // Only named element has silent: false, other elements should
  27902. // act as background and has no user interaction.
  27903. el.silent = false; // text|tspan will be converted to group.
  27904. if (el.isGroup) {
  27905. el.traverse(function (child) {
  27906. child.silent = false;
  27907. });
  27908. }
  27909. }
  27910. function createRegions(named) {
  27911. var regions = [];
  27912. var regionsMap = createHashMap(); // Create resions only for the first graphic.
  27913. each$1(named, function (namedItem) {
  27914. // Region has feature to calculate center for tooltip or other features.
  27915. // If there is a <g name="xxx">, the center should be the center of the
  27916. // bounding rect of the g.
  27917. if (namedItem.namedFrom != null) {
  27918. return;
  27919. }
  27920. var region = new GeoSVGRegion(namedItem.name, namedItem.el); // PENDING: if `nameMap` supported, this region can not be mounted on
  27921. // `this`, but can only be created each time `load()` called.
  27922. regions.push(region); // PENDING: if multiple tag named with the same name, only one will be
  27923. // found by `_regionsMap`. `_regionsMap` is used to find a coordinate
  27924. // by name. We use `region.getCenter()` as the coordinate.
  27925. regionsMap.set(namedItem.name, region);
  27926. });
  27927. return {
  27928. regions: regions,
  27929. regionsMap: regionsMap
  27930. };
  27931. } // PENDING: `nameMap` will not be supported until some real requirement come.
  27932. // /**
  27933. // * Use the alias in geoNameMap.
  27934. // * The input `named` must not be modified.
  27935. // */
  27936. // function applyNameMap(
  27937. // named: GeoSVGGraphicRecord['named'],
  27938. // nameMap: NameMap
  27939. // ): GeoSVGGraphicRecord['named'] {
  27940. // const result = [] as GeoSVGGraphicRecord['named'];
  27941. // for (let i = 0; i < named.length; i++) {
  27942. // let regionGraphic = named[i];
  27943. // const name = regionGraphic.name;
  27944. // if (nameMap && nameMap.hasOwnProperty(name)) {
  27945. // regionGraphic = extend({}, regionGraphic);
  27946. // regionGraphic.name = name;
  27947. // }
  27948. // result.push(regionGraphic);
  27949. // }
  27950. // return result;
  27951. // }
  27952. /*
  27953. * Licensed to the Apache Software Foundation (ASF) under one
  27954. * or more contributor license agreements. See the NOTICE file
  27955. * distributed with this work for additional information
  27956. * regarding copyright ownership. The ASF licenses this file
  27957. * to you under the Apache License, Version 2.0 (the
  27958. * "License"); you may not use this file except in compliance
  27959. * with the License. You may obtain a copy of the License at
  27960. *
  27961. * http://www.apache.org/licenses/LICENSE-2.0
  27962. *
  27963. * Unless required by applicable law or agreed to in writing,
  27964. * software distributed under the License is distributed on an
  27965. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  27966. * KIND, either express or implied. See the License for the
  27967. * specific language governing permissions and limitations
  27968. * under the License.
  27969. */
  27970. /**
  27971. * AUTO-GENERATED FILE. DO NOT MODIFY.
  27972. */
  27973. /*
  27974. * Licensed to the Apache Software Foundation (ASF) under one
  27975. * or more contributor license agreements. See the NOTICE file
  27976. * distributed with this work for additional information
  27977. * regarding copyright ownership. The ASF licenses this file
  27978. * to you under the Apache License, Version 2.0 (the
  27979. * "License"); you may not use this file except in compliance
  27980. * with the License. You may obtain a copy of the License at
  27981. *
  27982. * http://www.apache.org/licenses/LICENSE-2.0
  27983. *
  27984. * Unless required by applicable law or agreed to in writing,
  27985. * software distributed under the License is distributed on an
  27986. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  27987. * KIND, either express or implied. See the License for the
  27988. * specific language governing permissions and limitations
  27989. * under the License.
  27990. */
  27991. /**
  27992. * Parse and decode geo json
  27993. */
  27994. function decode(json) {
  27995. if (!json.UTF8Encoding) {
  27996. return json;
  27997. }
  27998. var jsonCompressed = json;
  27999. var encodeScale = jsonCompressed.UTF8Scale;
  28000. if (encodeScale == null) {
  28001. encodeScale = 1024;
  28002. }
  28003. var features = jsonCompressed.features;
  28004. for (var f = 0; f < features.length; f++) {
  28005. var feature = features[f];
  28006. var geometry = feature.geometry;
  28007. if (geometry.type === 'Polygon') {
  28008. var coordinates = geometry.coordinates;
  28009. for (var c = 0; c < coordinates.length; c++) {
  28010. coordinates[c] = decodePolygon(coordinates[c], geometry.encodeOffsets[c], encodeScale);
  28011. }
  28012. } else if (geometry.type === 'MultiPolygon') {
  28013. var coordinates = geometry.coordinates;
  28014. for (var c = 0; c < coordinates.length; c++) {
  28015. var coordinate = coordinates[c];
  28016. for (var c2 = 0; c2 < coordinate.length; c2++) {
  28017. coordinate[c2] = decodePolygon(coordinate[c2], geometry.encodeOffsets[c][c2], encodeScale);
  28018. }
  28019. }
  28020. }
  28021. } // Has been decoded
  28022. jsonCompressed.UTF8Encoding = false;
  28023. return jsonCompressed;
  28024. }
  28025. function decodePolygon(coordinate, encodeOffsets, encodeScale) {
  28026. var result = [];
  28027. var prevX = encodeOffsets[0];
  28028. var prevY = encodeOffsets[1];
  28029. for (var i = 0; i < coordinate.length; i += 2) {
  28030. var x = coordinate.charCodeAt(i) - 64;
  28031. var y = coordinate.charCodeAt(i + 1) - 64; // ZigZag decoding
  28032. x = x >> 1 ^ -(x & 1);
  28033. y = y >> 1 ^ -(y & 1); // Delta deocding
  28034. x += prevX;
  28035. y += prevY;
  28036. prevX = x;
  28037. prevY = y; // Dequantize
  28038. result.push([x / encodeScale, y / encodeScale]);
  28039. }
  28040. return result;
  28041. }
  28042. function parseGeoJSON(geoJson, nameProperty) {
  28043. geoJson = decode(geoJson);
  28044. return map(filter(geoJson.features, function (featureObj) {
  28045. // Output of mapshaper may have geometry null
  28046. return featureObj.geometry && featureObj.properties && featureObj.geometry.coordinates.length > 0;
  28047. }), function (featureObj) {
  28048. var properties = featureObj.properties;
  28049. var geo = featureObj.geometry;
  28050. var geometries = [];
  28051. if (geo.type === 'Polygon') {
  28052. var coordinates = geo.coordinates;
  28053. geometries.push({
  28054. type: 'polygon',
  28055. // According to the GeoJSON specification.
  28056. // First must be exterior, and the rest are all interior(holes).
  28057. exterior: coordinates[0],
  28058. interiors: coordinates.slice(1)
  28059. });
  28060. }
  28061. if (geo.type === 'MultiPolygon') {
  28062. var coordinates = geo.coordinates;
  28063. each$1(coordinates, function (item) {
  28064. if (item[0]) {
  28065. geometries.push({
  28066. type: 'polygon',
  28067. exterior: item[0],
  28068. interiors: item.slice(1)
  28069. });
  28070. }
  28071. });
  28072. }
  28073. var region = new GeoJSONRegion(properties[nameProperty || 'name'], geometries, properties.cp);
  28074. region.properties = properties;
  28075. return region;
  28076. });
  28077. }
  28078. /*
  28079. * Licensed to the Apache Software Foundation (ASF) under one
  28080. * or more contributor license agreements. See the NOTICE file
  28081. * distributed with this work for additional information
  28082. * regarding copyright ownership. The ASF licenses this file
  28083. * to you under the Apache License, Version 2.0 (the
  28084. * "License"); you may not use this file except in compliance
  28085. * with the License. You may obtain a copy of the License at
  28086. *
  28087. * http://www.apache.org/licenses/LICENSE-2.0
  28088. *
  28089. * Unless required by applicable law or agreed to in writing,
  28090. * software distributed under the License is distributed on an
  28091. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28092. * KIND, either express or implied. See the License for the
  28093. * specific language governing permissions and limitations
  28094. * under the License.
  28095. */
  28096. /**
  28097. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28098. */
  28099. /*
  28100. * Licensed to the Apache Software Foundation (ASF) under one
  28101. * or more contributor license agreements. See the NOTICE file
  28102. * distributed with this work for additional information
  28103. * regarding copyright ownership. The ASF licenses this file
  28104. * to you under the Apache License, Version 2.0 (the
  28105. * "License"); you may not use this file except in compliance
  28106. * with the License. You may obtain a copy of the License at
  28107. *
  28108. * http://www.apache.org/licenses/LICENSE-2.0
  28109. *
  28110. * Unless required by applicable law or agreed to in writing,
  28111. * software distributed under the License is distributed on an
  28112. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28113. * KIND, either express or implied. See the License for the
  28114. * specific language governing permissions and limitations
  28115. * under the License.
  28116. */
  28117. // Fix for 南海诸岛
  28118. var geoCoord = [126, 25];
  28119. var points$1 = [[[0, 3.5], [7, 11.2], [15, 11.9], [30, 7], [42, 0.7], [52, 0.7], [56, 7.7], [59, 0.7], [64, 0.7], [64, 0], [5, 0], [0, 3.5]], [[13, 16.1], [19, 14.7], [16, 21.7], [11, 23.1], [13, 16.1]], [[12, 32.2], [14, 38.5], [15, 38.5], [13, 32.2], [12, 32.2]], [[16, 47.6], [12, 53.2], [13, 53.2], [18, 47.6], [16, 47.6]], [[6, 64.4], [8, 70], [9, 70], [8, 64.4], [6, 64.4]], [[23, 82.6], [29, 79.8], [30, 79.8], [25, 82.6], [23, 82.6]], [[37, 70.7], [43, 62.3], [44, 62.3], [39, 70.7], [37, 70.7]], [[48, 51.1], [51, 45.5], [53, 45.5], [50, 51.1], [48, 51.1]], [[51, 35], [51, 28.7], [53, 28.7], [53, 35], [51, 35]], [[52, 22.4], [55, 17.5], [56, 17.5], [53, 22.4], [52, 22.4]], [[58, 12.6], [62, 7], [63, 7], [60, 12.6], [58, 12.6]], [[0, 3.5], [0, 93.1], [64, 93.1], [64, 0], [63, 0], [63, 92.4], [1, 92.4], [1, 3.5], [0, 3.5]]];
  28120. for (var i = 0; i < points$1.length; i++) {
  28121. for (var k = 0; k < points$1[i].length; k++) {
  28122. points$1[i][k][0] /= 10.5;
  28123. points$1[i][k][1] /= -10.5 / 0.75;
  28124. points$1[i][k][0] += geoCoord[0];
  28125. points$1[i][k][1] += geoCoord[1];
  28126. }
  28127. }
  28128. function fixNanhai(mapType, regions) {
  28129. if (mapType === 'china') {
  28130. regions.push(new GeoJSONRegion('南海诸岛', map(points$1, function (exterior) {
  28131. return {
  28132. type: 'polygon',
  28133. exterior: exterior
  28134. };
  28135. }), geoCoord));
  28136. }
  28137. }
  28138. /*
  28139. * Licensed to the Apache Software Foundation (ASF) under one
  28140. * or more contributor license agreements. See the NOTICE file
  28141. * distributed with this work for additional information
  28142. * regarding copyright ownership. The ASF licenses this file
  28143. * to you under the Apache License, Version 2.0 (the
  28144. * "License"); you may not use this file except in compliance
  28145. * with the License. You may obtain a copy of the License at
  28146. *
  28147. * http://www.apache.org/licenses/LICENSE-2.0
  28148. *
  28149. * Unless required by applicable law or agreed to in writing,
  28150. * software distributed under the License is distributed on an
  28151. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28152. * KIND, either express or implied. See the License for the
  28153. * specific language governing permissions and limitations
  28154. * under the License.
  28155. */
  28156. /**
  28157. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28158. */
  28159. /*
  28160. * Licensed to the Apache Software Foundation (ASF) under one
  28161. * or more contributor license agreements. See the NOTICE file
  28162. * distributed with this work for additional information
  28163. * regarding copyright ownership. The ASF licenses this file
  28164. * to you under the Apache License, Version 2.0 (the
  28165. * "License"); you may not use this file except in compliance
  28166. * with the License. You may obtain a copy of the License at
  28167. *
  28168. * http://www.apache.org/licenses/LICENSE-2.0
  28169. *
  28170. * Unless required by applicable law or agreed to in writing,
  28171. * software distributed under the License is distributed on an
  28172. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28173. * KIND, either express or implied. See the License for the
  28174. * specific language governing permissions and limitations
  28175. * under the License.
  28176. */
  28177. var coordsOffsetMap = {
  28178. '南海诸岛': [32, 80],
  28179. // 全国
  28180. '广东': [0, -10],
  28181. '香港': [10, 5],
  28182. '澳门': [-10, 10],
  28183. //'北京': [-10, 0],
  28184. '天津': [5, 5]
  28185. };
  28186. function fixTextCoords(mapType, region) {
  28187. if (mapType === 'china') {
  28188. var coordFix = coordsOffsetMap[region.name];
  28189. if (coordFix) {
  28190. var cp = region.getCenter();
  28191. cp[0] += coordFix[0] / 10.5;
  28192. cp[1] += -coordFix[1] / (10.5 / 0.75);
  28193. region.setCenter(cp);
  28194. }
  28195. }
  28196. }
  28197. /*
  28198. * Licensed to the Apache Software Foundation (ASF) under one
  28199. * or more contributor license agreements. See the NOTICE file
  28200. * distributed with this work for additional information
  28201. * regarding copyright ownership. The ASF licenses this file
  28202. * to you under the Apache License, Version 2.0 (the
  28203. * "License"); you may not use this file except in compliance
  28204. * with the License. You may obtain a copy of the License at
  28205. *
  28206. * http://www.apache.org/licenses/LICENSE-2.0
  28207. *
  28208. * Unless required by applicable law or agreed to in writing,
  28209. * software distributed under the License is distributed on an
  28210. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28211. * KIND, either express or implied. See the License for the
  28212. * specific language governing permissions and limitations
  28213. * under the License.
  28214. */
  28215. /**
  28216. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28217. */
  28218. /*
  28219. * Licensed to the Apache Software Foundation (ASF) under one
  28220. * or more contributor license agreements. See the NOTICE file
  28221. * distributed with this work for additional information
  28222. * regarding copyright ownership. The ASF licenses this file
  28223. * to you under the Apache License, Version 2.0 (the
  28224. * "License"); you may not use this file except in compliance
  28225. * with the License. You may obtain a copy of the License at
  28226. *
  28227. * http://www.apache.org/licenses/LICENSE-2.0
  28228. *
  28229. * Unless required by applicable law or agreed to in writing,
  28230. * software distributed under the License is distributed on an
  28231. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28232. * KIND, either express or implied. See the License for the
  28233. * specific language governing permissions and limitations
  28234. * under the License.
  28235. */
  28236. var geoCoordMap = {
  28237. 'Russia': [100, 60],
  28238. 'United States': [-99, 38],
  28239. 'United States of America': [-99, 38]
  28240. };
  28241. function fixGeoCoords(mapType, region) {
  28242. if (mapType === 'world') {
  28243. var geoCoord = geoCoordMap[region.name];
  28244. if (geoCoord) {
  28245. var cp = [geoCoord[0], geoCoord[1]];
  28246. region.setCenter(cp);
  28247. }
  28248. }
  28249. }
  28250. /*
  28251. * Licensed to the Apache Software Foundation (ASF) under one
  28252. * or more contributor license agreements. See the NOTICE file
  28253. * distributed with this work for additional information
  28254. * regarding copyright ownership. The ASF licenses this file
  28255. * to you under the Apache License, Version 2.0 (the
  28256. * "License"); you may not use this file except in compliance
  28257. * with the License. You may obtain a copy of the License at
  28258. *
  28259. * http://www.apache.org/licenses/LICENSE-2.0
  28260. *
  28261. * Unless required by applicable law or agreed to in writing,
  28262. * software distributed under the License is distributed on an
  28263. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28264. * KIND, either express or implied. See the License for the
  28265. * specific language governing permissions and limitations
  28266. * under the License.
  28267. */
  28268. /**
  28269. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28270. */
  28271. /*
  28272. * Licensed to the Apache Software Foundation (ASF) under one
  28273. * or more contributor license agreements. See the NOTICE file
  28274. * distributed with this work for additional information
  28275. * regarding copyright ownership. The ASF licenses this file
  28276. * to you under the Apache License, Version 2.0 (the
  28277. * "License"); you may not use this file except in compliance
  28278. * with the License. You may obtain a copy of the License at
  28279. *
  28280. * http://www.apache.org/licenses/LICENSE-2.0
  28281. *
  28282. * Unless required by applicable law or agreed to in writing,
  28283. * software distributed under the License is distributed on an
  28284. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28285. * KIND, either express or implied. See the License for the
  28286. * specific language governing permissions and limitations
  28287. * under the License.
  28288. */
  28289. // Fix for 钓鱼岛
  28290. // let Region = require('../Region');
  28291. // let zrUtil = require('zrender/lib/core/util');
  28292. // let geoCoord = [126, 25];
  28293. var points$2 = [[[123.45165252685547, 25.73527164402261], [123.49731445312499, 25.73527164402261], [123.49731445312499, 25.750734064600884], [123.45165252685547, 25.750734064600884], [123.45165252685547, 25.73527164402261]]];
  28294. function fixDiaoyuIsland(mapType, region) {
  28295. if (mapType === 'china' && region.name === '台湾') {
  28296. region.geometries.push({
  28297. type: 'polygon',
  28298. exterior: points$2[0]
  28299. });
  28300. }
  28301. }
  28302. /*
  28303. * Licensed to the Apache Software Foundation (ASF) under one
  28304. * or more contributor license agreements. See the NOTICE file
  28305. * distributed with this work for additional information
  28306. * regarding copyright ownership. The ASF licenses this file
  28307. * to you under the Apache License, Version 2.0 (the
  28308. * "License"); you may not use this file except in compliance
  28309. * with the License. You may obtain a copy of the License at
  28310. *
  28311. * http://www.apache.org/licenses/LICENSE-2.0
  28312. *
  28313. * Unless required by applicable law or agreed to in writing,
  28314. * software distributed under the License is distributed on an
  28315. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28316. * KIND, either express or implied. See the License for the
  28317. * specific language governing permissions and limitations
  28318. * under the License.
  28319. */
  28320. /**
  28321. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28322. */
  28323. /*
  28324. * Licensed to the Apache Software Foundation (ASF) under one
  28325. * or more contributor license agreements. See the NOTICE file
  28326. * distributed with this work for additional information
  28327. * regarding copyright ownership. The ASF licenses this file
  28328. * to you under the Apache License, Version 2.0 (the
  28329. * "License"); you may not use this file except in compliance
  28330. * with the License. You may obtain a copy of the License at
  28331. *
  28332. * http://www.apache.org/licenses/LICENSE-2.0
  28333. *
  28334. * Unless required by applicable law or agreed to in writing,
  28335. * software distributed under the License is distributed on an
  28336. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28337. * KIND, either express or implied. See the License for the
  28338. * specific language governing permissions and limitations
  28339. * under the License.
  28340. */
  28341. var DEFAULT_NAME_PROPERTY = 'name';
  28342. var GeoJSONResource =
  28343. /** @class */
  28344. function () {
  28345. function GeoJSONResource(mapName, geoJSON, specialAreas) {
  28346. this.type = 'geoJSON';
  28347. this._parsedMap = createHashMap();
  28348. this._mapName = mapName;
  28349. this._specialAreas = specialAreas; // PENDING: delay the parse to the first usage to rapid up the FMP?
  28350. this._geoJSON = parseInput(geoJSON);
  28351. }
  28352. /**
  28353. * @param nameMap can be null/undefined
  28354. * @param nameProperty can be null/undefined
  28355. */
  28356. GeoJSONResource.prototype.load = function (nameMap, nameProperty) {
  28357. nameProperty = nameProperty || DEFAULT_NAME_PROPERTY;
  28358. var parsed = this._parsedMap.get(nameProperty);
  28359. if (!parsed) {
  28360. var rawRegions = this._parseToRegions(nameProperty);
  28361. parsed = this._parsedMap.set(nameProperty, {
  28362. regions: rawRegions,
  28363. boundingRect: calculateBoundingRect(rawRegions)
  28364. });
  28365. }
  28366. var regionsMap = createHashMap();
  28367. var finalRegions = [];
  28368. each$1(parsed.regions, function (region) {
  28369. var regionName = region.name; // Try use the alias in geoNameMap
  28370. if (nameMap && nameMap.hasOwnProperty(regionName)) {
  28371. region = region.cloneShallow(regionName = nameMap[regionName]);
  28372. }
  28373. finalRegions.push(region);
  28374. regionsMap.set(regionName, region);
  28375. });
  28376. return {
  28377. regions: finalRegions,
  28378. boundingRect: parsed.boundingRect || new BoundingRect(0, 0, 0, 0),
  28379. regionsMap: regionsMap
  28380. };
  28381. };
  28382. GeoJSONResource.prototype._parseToRegions = function (nameProperty) {
  28383. var mapName = this._mapName;
  28384. var geoJSON = this._geoJSON;
  28385. var rawRegions; // https://jsperf.com/try-catch-performance-overhead
  28386. try {
  28387. rawRegions = geoJSON ? parseGeoJSON(geoJSON, nameProperty) : [];
  28388. } catch (e) {
  28389. throw new Error('Invalid geoJson format\n' + e.message);
  28390. }
  28391. fixNanhai(mapName, rawRegions);
  28392. each$1(rawRegions, function (region) {
  28393. var regionName = region.name;
  28394. fixTextCoords(mapName, region);
  28395. fixGeoCoords(mapName, region);
  28396. fixDiaoyuIsland(mapName, region); // Some area like Alaska in USA map needs to be tansformed
  28397. // to look better
  28398. var specialArea = this._specialAreas && this._specialAreas[regionName];
  28399. if (specialArea) {
  28400. region.transformTo(specialArea.left, specialArea.top, specialArea.width, specialArea.height);
  28401. }
  28402. }, this);
  28403. return rawRegions;
  28404. };
  28405. /**
  28406. * Only for exporting to users.
  28407. * **MUST NOT** used internally.
  28408. */
  28409. GeoJSONResource.prototype.getMapForUser = function () {
  28410. return {
  28411. // For backward compatibility, use geoJson
  28412. // PENDING: it has been returning them without clone.
  28413. // do we need to avoid outsite modification?
  28414. geoJson: this._geoJSON,
  28415. geoJSON: this._geoJSON,
  28416. specialAreas: this._specialAreas
  28417. };
  28418. };
  28419. return GeoJSONResource;
  28420. }();
  28421. function calculateBoundingRect(regions) {
  28422. var rect;
  28423. for (var i = 0; i < regions.length; i++) {
  28424. var regionRect = regions[i].getBoundingRect();
  28425. rect = rect || regionRect.clone();
  28426. rect.union(regionRect);
  28427. }
  28428. return rect;
  28429. }
  28430. function parseInput(source) {
  28431. return !isString(source) ? source : typeof JSON !== 'undefined' && JSON.parse ? JSON.parse(source) : new Function('return (' + source + ');')();
  28432. }
  28433. /*
  28434. * Licensed to the Apache Software Foundation (ASF) under one
  28435. * or more contributor license agreements. See the NOTICE file
  28436. * distributed with this work for additional information
  28437. * regarding copyright ownership. The ASF licenses this file
  28438. * to you under the Apache License, Version 2.0 (the
  28439. * "License"); you may not use this file except in compliance
  28440. * with the License. You may obtain a copy of the License at
  28441. *
  28442. * http://www.apache.org/licenses/LICENSE-2.0
  28443. *
  28444. * Unless required by applicable law or agreed to in writing,
  28445. * software distributed under the License is distributed on an
  28446. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28447. * KIND, either express or implied. See the License for the
  28448. * specific language governing permissions and limitations
  28449. * under the License.
  28450. */
  28451. /**
  28452. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28453. */
  28454. /*
  28455. * Licensed to the Apache Software Foundation (ASF) under one
  28456. * or more contributor license agreements. See the NOTICE file
  28457. * distributed with this work for additional information
  28458. * regarding copyright ownership. The ASF licenses this file
  28459. * to you under the Apache License, Version 2.0 (the
  28460. * "License"); you may not use this file except in compliance
  28461. * with the License. You may obtain a copy of the License at
  28462. *
  28463. * http://www.apache.org/licenses/LICENSE-2.0
  28464. *
  28465. * Unless required by applicable law or agreed to in writing,
  28466. * software distributed under the License is distributed on an
  28467. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28468. * KIND, either express or implied. See the License for the
  28469. * specific language governing permissions and limitations
  28470. * under the License.
  28471. */
  28472. var storage = createHashMap();
  28473. var geoSourceManager = {
  28474. /**
  28475. * Compatible with previous `echarts.registerMap`.
  28476. *
  28477. * @usage
  28478. * ```js
  28479. *
  28480. * echarts.registerMap('USA', geoJson, specialAreas);
  28481. *
  28482. * echarts.registerMap('USA', {
  28483. * geoJson: geoJson,
  28484. * specialAreas: {...}
  28485. * });
  28486. * echarts.registerMap('USA', {
  28487. * geoJSON: geoJson,
  28488. * specialAreas: {...}
  28489. * });
  28490. *
  28491. * echarts.registerMap('airport', {
  28492. * svg: svg
  28493. * }
  28494. * ```
  28495. *
  28496. * Note:
  28497. * Do not support that register multiple geoJSON or SVG
  28498. * one map name. Because different geoJSON and SVG have
  28499. * different unit. It's not easy to make sure how those
  28500. * units are mapping/normalize.
  28501. * If intending to use multiple geoJSON or SVG, we can
  28502. * use multiple geo coordinate system.
  28503. */
  28504. registerMap: function (mapName, rawDef, rawSpecialAreas) {
  28505. if (rawDef.svg) {
  28506. var resource = new GeoSVGResource(mapName, rawDef.svg);
  28507. storage.set(mapName, resource);
  28508. } else {
  28509. // Recommend:
  28510. // echarts.registerMap('eu', { geoJSON: xxx, specialAreas: xxx });
  28511. // Backward compatibility:
  28512. // echarts.registerMap('eu', geoJSON, specialAreas);
  28513. // echarts.registerMap('eu', { geoJson: xxx, specialAreas: xxx });
  28514. var geoJSON = rawDef.geoJson || rawDef.geoJSON;
  28515. if (geoJSON && !rawDef.features) {
  28516. rawSpecialAreas = rawDef.specialAreas;
  28517. } else {
  28518. geoJSON = rawDef;
  28519. }
  28520. var resource = new GeoJSONResource(mapName, geoJSON, rawSpecialAreas);
  28521. storage.set(mapName, resource);
  28522. }
  28523. },
  28524. getGeoResource: function (mapName) {
  28525. return storage.get(mapName);
  28526. },
  28527. /**
  28528. * Only for exporting to users.
  28529. * **MUST NOT** used internally.
  28530. */
  28531. getMapForUser: function (mapName) {
  28532. var resource = storage.get(mapName); // Do not support return SVG until some real requirement come.
  28533. return resource && resource.type === 'geoJSON' && resource.getMapForUser();
  28534. },
  28535. load: function (mapName, nameMap, nameProperty) {
  28536. var resource = storage.get(mapName);
  28537. if (!resource) {
  28538. {
  28539. console.error('Map ' + mapName + ' not exists. The GeoJSON of the map must be provided.');
  28540. }
  28541. return;
  28542. }
  28543. return resource.load(nameMap, nameProperty);
  28544. }
  28545. };
  28546. /*
  28547. * Licensed to the Apache Software Foundation (ASF) under one
  28548. * or more contributor license agreements. See the NOTICE file
  28549. * distributed with this work for additional information
  28550. * regarding copyright ownership. The ASF licenses this file
  28551. * to you under the Apache License, Version 2.0 (the
  28552. * "License"); you may not use this file except in compliance
  28553. * with the License. You may obtain a copy of the License at
  28554. *
  28555. * http://www.apache.org/licenses/LICENSE-2.0
  28556. *
  28557. * Unless required by applicable law or agreed to in writing,
  28558. * software distributed under the License is distributed on an
  28559. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28560. * KIND, either express or implied. See the License for the
  28561. * specific language governing permissions and limitations
  28562. * under the License.
  28563. */
  28564. /**
  28565. * AUTO-GENERATED FILE. DO NOT MODIFY.
  28566. */
  28567. /*
  28568. * Licensed to the Apache Software Foundation (ASF) under one
  28569. * or more contributor license agreements. See the NOTICE file
  28570. * distributed with this work for additional information
  28571. * regarding copyright ownership. The ASF licenses this file
  28572. * to you under the Apache License, Version 2.0 (the
  28573. * "License"); you may not use this file except in compliance
  28574. * with the License. You may obtain a copy of the License at
  28575. *
  28576. * http://www.apache.org/licenses/LICENSE-2.0
  28577. *
  28578. * Unless required by applicable law or agreed to in writing,
  28579. * software distributed under the License is distributed on an
  28580. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  28581. * KIND, either express or implied. See the License for the
  28582. * specific language governing permissions and limitations
  28583. * under the License.
  28584. */
  28585. var assert = assert$1;
  28586. var each = each$1;
  28587. var isFunction = isFunction$1;
  28588. var isObject = isObject$1;
  28589. var indexOf = indexOf$1;
  28590. var hasWindow = typeof window !== 'undefined';
  28591. var version = '5.1.0';
  28592. var dependencies = {
  28593. zrender: '5.1.0'
  28594. };
  28595. var TEST_FRAME_REMAIN_TIME = 1;
  28596. var PRIORITY_PROCESSOR_SERIES_FILTER = 800; // Some data processors depends on the stack result dimension (to calculate data extent).
  28597. // So data stack stage should be in front of data processing stage.
  28598. var PRIORITY_PROCESSOR_DATASTACK = 900; // "Data filter" will block the stream, so it should be
  28599. // put at the begining of data processing.
  28600. var PRIORITY_PROCESSOR_FILTER = 1000;
  28601. var PRIORITY_PROCESSOR_DEFAULT = 2000;
  28602. var PRIORITY_PROCESSOR_STATISTIC = 5000;
  28603. var PRIORITY_VISUAL_LAYOUT = 1000;
  28604. var PRIORITY_VISUAL_PROGRESSIVE_LAYOUT = 1100;
  28605. var PRIORITY_VISUAL_GLOBAL = 2000;
  28606. var PRIORITY_VISUAL_CHART = 3000;
  28607. var PRIORITY_VISUAL_COMPONENT = 4000; // Visual property in data. Greater than `PRIORITY_VISUAL_COMPONENT` to enable to
  28608. // overwrite the viusal result of component (like `visualMap`)
  28609. // using data item specific setting (like itemStyle.xxx on data item)
  28610. var PRIORITY_VISUAL_CHART_DATA_CUSTOM = 4500; // Greater than `PRIORITY_VISUAL_CHART_DATA_CUSTOM` to enable to layout based on
  28611. // visual result like `symbolSize`.
  28612. var PRIORITY_VISUAL_POST_CHART_LAYOUT = 4600;
  28613. var PRIORITY_VISUAL_BRUSH = 5000;
  28614. var PRIORITY_VISUAL_ARIA = 6000;
  28615. var PRIORITY_VISUAL_DECAL = 7000;
  28616. var PRIORITY = {
  28617. PROCESSOR: {
  28618. FILTER: PRIORITY_PROCESSOR_FILTER,
  28619. SERIES_FILTER: PRIORITY_PROCESSOR_SERIES_FILTER,
  28620. STATISTIC: PRIORITY_PROCESSOR_STATISTIC
  28621. },
  28622. VISUAL: {
  28623. LAYOUT: PRIORITY_VISUAL_LAYOUT,
  28624. PROGRESSIVE_LAYOUT: PRIORITY_VISUAL_PROGRESSIVE_LAYOUT,
  28625. GLOBAL: PRIORITY_VISUAL_GLOBAL,
  28626. CHART: PRIORITY_VISUAL_CHART,
  28627. POST_CHART_LAYOUT: PRIORITY_VISUAL_POST_CHART_LAYOUT,
  28628. COMPONENT: PRIORITY_VISUAL_COMPONENT,
  28629. BRUSH: PRIORITY_VISUAL_BRUSH,
  28630. CHART_ITEM: PRIORITY_VISUAL_CHART_DATA_CUSTOM,
  28631. ARIA: PRIORITY_VISUAL_ARIA,
  28632. DECAL: PRIORITY_VISUAL_DECAL
  28633. }
  28634. }; // Main process have three entries: `setOption`, `dispatchAction` and `resize`,
  28635. // where they must not be invoked nestedly, except the only case: invoke
  28636. // dispatchAction with updateMethod "none" in main process.
  28637. // This flag is used to carry out this rule.
  28638. // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).
  28639. var IN_MAIN_PROCESS_KEY = '__flagInMainProcess';
  28640. var OPTION_UPDATED_KEY = '__optionUpdated';
  28641. var STATUS_NEEDS_UPDATE_KEY = '__needsUpdateStatus';
  28642. var ACTION_REG = /^[a-zA-Z0-9_]+$/;
  28643. var CONNECT_STATUS_KEY = '__connectUpdateStatus';
  28644. var CONNECT_STATUS_PENDING = 0;
  28645. var CONNECT_STATUS_UPDATING = 1;
  28646. var CONNECT_STATUS_UPDATED = 2;
  28647. function createRegisterEventWithLowercaseECharts(method) {
  28648. return function () {
  28649. var args = [];
  28650. for (var _i = 0; _i < arguments.length; _i++) {
  28651. args[_i] = arguments[_i];
  28652. }
  28653. if (this.isDisposed()) {
  28654. disposedWarning(this.id);
  28655. return;
  28656. }
  28657. return toLowercaseNameAndCallEventful(this, method, args);
  28658. };
  28659. }
  28660. function createRegisterEventWithLowercaseMessageCenter(method) {
  28661. return function () {
  28662. var args = [];
  28663. for (var _i = 0; _i < arguments.length; _i++) {
  28664. args[_i] = arguments[_i];
  28665. }
  28666. return toLowercaseNameAndCallEventful(this, method, args);
  28667. };
  28668. }
  28669. function toLowercaseNameAndCallEventful(host, method, args) {
  28670. // `args[0]` is event name. Event name is all lowercase.
  28671. args[0] = args[0] && args[0].toLowerCase();
  28672. return Eventful.prototype[method].apply(host, args);
  28673. }
  28674. var MessageCenter =
  28675. /** @class */
  28676. function (_super) {
  28677. __extends(MessageCenter, _super);
  28678. function MessageCenter() {
  28679. return _super !== null && _super.apply(this, arguments) || this;
  28680. }
  28681. return MessageCenter;
  28682. }(Eventful);
  28683. var messageCenterProto = MessageCenter.prototype;
  28684. messageCenterProto.on = createRegisterEventWithLowercaseMessageCenter('on');
  28685. messageCenterProto.off = createRegisterEventWithLowercaseMessageCenter('off'); // ---------------------------------------
  28686. // Internal method names for class ECharts
  28687. // ---------------------------------------
  28688. var prepare;
  28689. var prepareView;
  28690. var updateDirectly;
  28691. var updateMethods;
  28692. var doConvertPixel;
  28693. var updateStreamModes;
  28694. var doDispatchAction;
  28695. var flushPendingActions;
  28696. var triggerUpdatedEvent;
  28697. var bindRenderedEvent;
  28698. var bindMouseEvent;
  28699. var clearColorPalette;
  28700. var render;
  28701. var renderComponents;
  28702. var renderSeries;
  28703. var performPostUpdateFuncs;
  28704. var createExtensionAPI;
  28705. var enableConnect;
  28706. var setTransitionOpt;
  28707. var markStatusToUpdate;
  28708. var applyChangedStates;
  28709. var ECharts =
  28710. /** @class */
  28711. function (_super) {
  28712. __extends(ECharts, _super);
  28713. function ECharts(dom, // Theme name or themeOption.
  28714. theme$$1, opts) {
  28715. var _this = _super.call(this, new ECEventProcessor()) || this;
  28716. _this._chartsViews = [];
  28717. _this._chartsMap = {};
  28718. _this._componentsViews = [];
  28719. _this._componentsMap = {}; // Can't dispatch action during rendering procedure
  28720. _this._pendingActions = [];
  28721. opts = opts || {}; // Get theme by name
  28722. if (typeof theme$$1 === 'string') {
  28723. theme$$1 = themeStorage[theme$$1];
  28724. }
  28725. _this._dom = dom;
  28726. var defaultRenderer = 'canvas';
  28727. var defaultUseDirtyRect = false;
  28728. {
  28729. var root =
  28730. /* eslint-disable-next-line */
  28731. hasWindow ? window : global;
  28732. defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
  28733. var devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__;
  28734. defaultUseDirtyRect = devUseDirtyRect == null ? defaultUseDirtyRect : devUseDirtyRect;
  28735. }
  28736. var zr = _this._zr = init$1(dom, {
  28737. renderer: opts.renderer || defaultRenderer,
  28738. devicePixelRatio: opts.devicePixelRatio,
  28739. width: opts.width,
  28740. height: opts.height,
  28741. useDirtyRect: opts.useDirtyRect == null ? defaultUseDirtyRect : opts.useDirtyRect
  28742. }); // Expect 60 fps.
  28743. _this._throttledZrFlush = throttle(bind(zr.flush, zr), 17);
  28744. theme$$1 = clone(theme$$1);
  28745. theme$$1 && globalBackwardCompat(theme$$1, true);
  28746. _this._theme = theme$$1;
  28747. _this._locale = createLocaleObject(opts.locale || SYSTEM_LANG);
  28748. _this._coordSysMgr = new CoordinateSystemManager();
  28749. var api = _this._api = createExtensionAPI(_this); // Sort on demand
  28750. function prioritySortFunc(a, b) {
  28751. return a.__prio - b.__prio;
  28752. }
  28753. sort(visualFuncs, prioritySortFunc);
  28754. sort(dataProcessorFuncs, prioritySortFunc);
  28755. _this._scheduler = new Scheduler(_this, api, dataProcessorFuncs, visualFuncs);
  28756. _this._messageCenter = new MessageCenter();
  28757. _this._labelManager = new LabelManager(); // Init mouse events
  28758. _this._initEvents(); // In case some people write `window.onresize = chart.resize`
  28759. _this.resize = bind(_this.resize, _this);
  28760. zr.animation.on('frame', _this._onframe, _this);
  28761. bindRenderedEvent(zr, _this);
  28762. bindMouseEvent(zr, _this); // ECharts instance can be used as value.
  28763. setAsPrimitive(_this);
  28764. return _this;
  28765. }
  28766. ECharts.prototype._onframe = function () {
  28767. if (this._disposed) {
  28768. return;
  28769. }
  28770. applyChangedStates(this);
  28771. var scheduler = this._scheduler; // Lazy update
  28772. if (this[OPTION_UPDATED_KEY]) {
  28773. var silent = this[OPTION_UPDATED_KEY].silent;
  28774. this[IN_MAIN_PROCESS_KEY] = true;
  28775. prepare(this);
  28776. updateMethods.update.call(this); // At present, in each frame, zrender performs:
  28777. // (1) animation step forward.
  28778. // (2) trigger('frame') (where this `_onframe` is called)
  28779. // (3) zrender flush (render).
  28780. // If we do nothing here, since we use `setToFinal: true`, the step (3) above
  28781. // will render the final state of the elements before the real animation started.
  28782. this._zr.flush();
  28783. this[IN_MAIN_PROCESS_KEY] = false;
  28784. this[OPTION_UPDATED_KEY] = false;
  28785. flushPendingActions.call(this, silent);
  28786. triggerUpdatedEvent.call(this, silent);
  28787. } // Avoid do both lazy update and progress in one frame.
  28788. else if (scheduler.unfinished) {
  28789. // Stream progress.
  28790. var remainTime = TEST_FRAME_REMAIN_TIME;
  28791. var ecModel = this._model;
  28792. var api = this._api;
  28793. scheduler.unfinished = false;
  28794. do {
  28795. var startTime = +new Date();
  28796. scheduler.performSeriesTasks(ecModel); // Currently dataProcessorFuncs do not check threshold.
  28797. scheduler.performDataProcessorTasks(ecModel);
  28798. updateStreamModes(this, ecModel); // Do not update coordinate system here. Because that coord system update in
  28799. // each frame is not a good user experience. So we follow the rule that
  28800. // the extent of the coordinate system is determin in the first frame (the
  28801. // frame is executed immedietely after task reset.
  28802. // this._coordSysMgr.update(ecModel, api);
  28803. // console.log('--- ec frame visual ---', remainTime);
  28804. scheduler.performVisualTasks(ecModel);
  28805. renderSeries(this, this._model, api, 'remain');
  28806. remainTime -= +new Date() - startTime;
  28807. } while (remainTime > 0 && scheduler.unfinished); // Call flush explicitly for trigger finished event.
  28808. if (!scheduler.unfinished) {
  28809. this._zr.flush();
  28810. } // Else, zr flushing be ensue within the same frame,
  28811. // because zr flushing is after onframe event.
  28812. }
  28813. };
  28814. ECharts.prototype.getDom = function () {
  28815. return this._dom;
  28816. };
  28817. ECharts.prototype.getId = function () {
  28818. return this.id;
  28819. };
  28820. ECharts.prototype.getZr = function () {
  28821. return this._zr;
  28822. };
  28823. /* eslint-disable-next-line */
  28824. ECharts.prototype.setOption = function (option, notMerge, lazyUpdate) {
  28825. {
  28826. assert(!this[IN_MAIN_PROCESS_KEY], '`setOption` should not be called during main process.');
  28827. }
  28828. if (this._disposed) {
  28829. disposedWarning(this.id);
  28830. return;
  28831. }
  28832. var silent;
  28833. var replaceMerge;
  28834. var transitionOpt;
  28835. if (isObject(notMerge)) {
  28836. lazyUpdate = notMerge.lazyUpdate;
  28837. silent = notMerge.silent;
  28838. replaceMerge = notMerge.replaceMerge;
  28839. transitionOpt = notMerge.transition;
  28840. notMerge = notMerge.notMerge;
  28841. }
  28842. this[IN_MAIN_PROCESS_KEY] = true;
  28843. if (!this._model || notMerge) {
  28844. var optionManager = new OptionManager(this._api);
  28845. var theme$$1 = this._theme;
  28846. var ecModel = this._model = new GlobalModel();
  28847. ecModel.scheduler = this._scheduler;
  28848. ecModel.init(null, null, null, theme$$1, this._locale, optionManager);
  28849. }
  28850. this._model.setOption(option, {
  28851. replaceMerge: replaceMerge
  28852. }, optionPreprocessorFuncs);
  28853. setTransitionOpt(this, transitionOpt);
  28854. if (lazyUpdate) {
  28855. this[OPTION_UPDATED_KEY] = {
  28856. silent: silent
  28857. };
  28858. this[IN_MAIN_PROCESS_KEY] = false; // `setOption(option, {lazyMode: true})` may be called when zrender has been slept.
  28859. // It should wake it up to make sure zrender start to render at the next frame.
  28860. this.getZr().wakeUp();
  28861. } else {
  28862. prepare(this);
  28863. updateMethods.update.call(this); // Ensure zr refresh sychronously, and then pixel in canvas can be
  28864. // fetched after `setOption`.
  28865. this._zr.flush();
  28866. this[OPTION_UPDATED_KEY] = false;
  28867. this[IN_MAIN_PROCESS_KEY] = false;
  28868. flushPendingActions.call(this, silent);
  28869. triggerUpdatedEvent.call(this, silent);
  28870. }
  28871. };
  28872. /**
  28873. * @DEPRECATED
  28874. */
  28875. ECharts.prototype.setTheme = function () {
  28876. console.error('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  28877. }; // We don't want developers to use getModel directly.
  28878. ECharts.prototype.getModel = function () {
  28879. return this._model;
  28880. };
  28881. ECharts.prototype.getOption = function () {
  28882. return this._model && this._model.getOption();
  28883. };
  28884. ECharts.prototype.getWidth = function () {
  28885. return this._zr.getWidth();
  28886. };
  28887. ECharts.prototype.getHeight = function () {
  28888. return this._zr.getHeight();
  28889. };
  28890. ECharts.prototype.getDevicePixelRatio = function () {
  28891. return this._zr.painter.dpr
  28892. /* eslint-disable-next-line */
  28893. || hasWindow && window.devicePixelRatio || 1;
  28894. };
  28895. /**
  28896. * Get canvas which has all thing rendered
  28897. */
  28898. ECharts.prototype.getRenderedCanvas = function (opts) {
  28899. if (!env.canvasSupported) {
  28900. return;
  28901. }
  28902. opts = extend({}, opts || {});
  28903. opts.pixelRatio = opts.pixelRatio || this.getDevicePixelRatio();
  28904. opts.backgroundColor = opts.backgroundColor || this._model.get('backgroundColor');
  28905. var zr = this._zr; // let list = zr.storage.getDisplayList();
  28906. // Stop animations
  28907. // Never works before in init animation, so remove it.
  28908. // zrUtil.each(list, function (el) {
  28909. // el.stopAnimation(true);
  28910. // });
  28911. return zr.painter.getRenderedCanvas(opts);
  28912. };
  28913. /**
  28914. * Get svg data url
  28915. */
  28916. ECharts.prototype.getSvgDataURL = function () {
  28917. if (!env.svgSupported) {
  28918. return;
  28919. }
  28920. var zr = this._zr;
  28921. var list = zr.storage.getDisplayList(); // Stop animations
  28922. each$1(list, function (el) {
  28923. el.stopAnimation(null, true);
  28924. });
  28925. return zr.painter.toDataURL();
  28926. };
  28927. ECharts.prototype.getDataURL = function (opts) {
  28928. if (this._disposed) {
  28929. disposedWarning(this.id);
  28930. return;
  28931. }
  28932. opts = opts || {};
  28933. var excludeComponents = opts.excludeComponents;
  28934. var ecModel = this._model;
  28935. var excludesComponentViews = [];
  28936. var self = this;
  28937. each(excludeComponents, function (componentType) {
  28938. ecModel.eachComponent({
  28939. mainType: componentType
  28940. }, function (component) {
  28941. var view = self._componentsMap[component.__viewId];
  28942. if (!view.group.ignore) {
  28943. excludesComponentViews.push(view);
  28944. view.group.ignore = true;
  28945. }
  28946. });
  28947. });
  28948. var url = this._zr.painter.getType() === 'svg' ? this.getSvgDataURL() : this.getRenderedCanvas(opts).toDataURL('image/' + (opts && opts.type || 'png'));
  28949. each(excludesComponentViews, function (view) {
  28950. view.group.ignore = false;
  28951. });
  28952. return url;
  28953. };
  28954. ECharts.prototype.getConnectedDataURL = function (opts) {
  28955. if (this._disposed) {
  28956. disposedWarning(this.id);
  28957. return;
  28958. }
  28959. if (!env.canvasSupported) {
  28960. return;
  28961. }
  28962. var isSvg = opts.type === 'svg';
  28963. var groupId = this.group;
  28964. var mathMin = Math.min;
  28965. var mathMax = Math.max;
  28966. var MAX_NUMBER = Infinity;
  28967. if (connectedGroups[groupId]) {
  28968. var left_1 = MAX_NUMBER;
  28969. var top_1 = MAX_NUMBER;
  28970. var right_1 = -MAX_NUMBER;
  28971. var bottom_1 = -MAX_NUMBER;
  28972. var canvasList_1 = [];
  28973. var dpr_1 = opts && opts.pixelRatio || this.getDevicePixelRatio();
  28974. each$1(instances, function (chart, id) {
  28975. if (chart.group === groupId) {
  28976. var canvas = isSvg ? chart.getZr().painter.getSvgDom().innerHTML : chart.getRenderedCanvas(clone(opts));
  28977. var boundingRect = chart.getDom().getBoundingClientRect();
  28978. left_1 = mathMin(boundingRect.left, left_1);
  28979. top_1 = mathMin(boundingRect.top, top_1);
  28980. right_1 = mathMax(boundingRect.right, right_1);
  28981. bottom_1 = mathMax(boundingRect.bottom, bottom_1);
  28982. canvasList_1.push({
  28983. dom: canvas,
  28984. left: boundingRect.left,
  28985. top: boundingRect.top
  28986. });
  28987. }
  28988. });
  28989. left_1 *= dpr_1;
  28990. top_1 *= dpr_1;
  28991. right_1 *= dpr_1;
  28992. bottom_1 *= dpr_1;
  28993. var width = right_1 - left_1;
  28994. var height = bottom_1 - top_1;
  28995. var targetCanvas = createCanvas();
  28996. var zr_1 = init$1(targetCanvas, {
  28997. renderer: isSvg ? 'svg' : 'canvas'
  28998. });
  28999. zr_1.resize({
  29000. width: width,
  29001. height: height
  29002. });
  29003. if (isSvg) {
  29004. var content_1 = '';
  29005. each(canvasList_1, function (item) {
  29006. var x = item.left - left_1;
  29007. var y = item.top - top_1;
  29008. content_1 += '<g transform="translate(' + x + ',' + y + ')">' + item.dom + '</g>';
  29009. });
  29010. zr_1.painter.getSvgRoot().innerHTML = content_1;
  29011. if (opts.connectedBackgroundColor) {
  29012. zr_1.painter.setBackgroundColor(opts.connectedBackgroundColor);
  29013. }
  29014. zr_1.refreshImmediately();
  29015. return zr_1.painter.toDataURL();
  29016. } else {
  29017. // Background between the charts
  29018. if (opts.connectedBackgroundColor) {
  29019. zr_1.add(new Rect({
  29020. shape: {
  29021. x: 0,
  29022. y: 0,
  29023. width: width,
  29024. height: height
  29025. },
  29026. style: {
  29027. fill: opts.connectedBackgroundColor
  29028. }
  29029. }));
  29030. }
  29031. each(canvasList_1, function (item) {
  29032. var img = new ZRImage({
  29033. style: {
  29034. x: item.left * dpr_1 - left_1,
  29035. y: item.top * dpr_1 - top_1,
  29036. image: item.dom
  29037. }
  29038. });
  29039. zr_1.add(img);
  29040. });
  29041. zr_1.refreshImmediately();
  29042. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  29043. }
  29044. } else {
  29045. return this.getDataURL(opts);
  29046. }
  29047. };
  29048. ECharts.prototype.convertToPixel = function (finder, value) {
  29049. return doConvertPixel(this, 'convertToPixel', finder, value);
  29050. };
  29051. ECharts.prototype.convertFromPixel = function (finder, value) {
  29052. return doConvertPixel(this, 'convertFromPixel', finder, value);
  29053. };
  29054. /**
  29055. * Is the specified coordinate systems or components contain the given pixel point.
  29056. * @param {Array|number} value
  29057. * @return {boolean} result
  29058. */
  29059. ECharts.prototype.containPixel = function (finder, value) {
  29060. if (this._disposed) {
  29061. disposedWarning(this.id);
  29062. return;
  29063. }
  29064. var ecModel = this._model;
  29065. var result;
  29066. var findResult = parseFinder(ecModel, finder);
  29067. each$1(findResult, function (models, key) {
  29068. key.indexOf('Models') >= 0 && each$1(models, function (model) {
  29069. var coordSys = model.coordinateSystem;
  29070. if (coordSys && coordSys.containPoint) {
  29071. result = result || !!coordSys.containPoint(value);
  29072. } else if (key === 'seriesModels') {
  29073. var view = this._chartsMap[model.__viewId];
  29074. if (view && view.containPoint) {
  29075. result = result || view.containPoint(value, model);
  29076. } else {
  29077. {
  29078. console.warn(key + ': ' + (view ? 'The found component do not support containPoint.' : 'No view mapping to the found component.'));
  29079. }
  29080. }
  29081. } else {
  29082. {
  29083. console.warn(key + ': containPoint is not supported');
  29084. }
  29085. }
  29086. }, this);
  29087. }, this);
  29088. return !!result;
  29089. };
  29090. /**
  29091. * Get visual from series or data.
  29092. * @param finder
  29093. * If string, e.g., 'series', means {seriesIndex: 0}.
  29094. * If Object, could contain some of these properties below:
  29095. * {
  29096. * seriesIndex / seriesId / seriesName,
  29097. * dataIndex / dataIndexInside
  29098. * }
  29099. * If dataIndex is not specified, series visual will be fetched,
  29100. * but not data item visual.
  29101. * If all of seriesIndex, seriesId, seriesName are not specified,
  29102. * visual will be fetched from first series.
  29103. * @param visualType 'color', 'symbol', 'symbolSize'
  29104. */
  29105. ECharts.prototype.getVisual = function (finder, visualType) {
  29106. var ecModel = this._model;
  29107. var parsedFinder = parseFinder(ecModel, finder, {
  29108. defaultMainType: 'series'
  29109. });
  29110. var seriesModel = parsedFinder.seriesModel;
  29111. {
  29112. if (!seriesModel) {
  29113. console.warn('There is no specified seires model');
  29114. }
  29115. }
  29116. var data = seriesModel.getData();
  29117. var dataIndexInside = parsedFinder.hasOwnProperty('dataIndexInside') ? parsedFinder.dataIndexInside : parsedFinder.hasOwnProperty('dataIndex') ? data.indexOfRawIndex(parsedFinder.dataIndex) : null;
  29118. return dataIndexInside != null ? getItemVisualFromData(data, dataIndexInside, visualType) : getVisualFromData(data, visualType);
  29119. };
  29120. /**
  29121. * Get view of corresponding component model
  29122. */
  29123. ECharts.prototype.getViewOfComponentModel = function (componentModel) {
  29124. return this._componentsMap[componentModel.__viewId];
  29125. };
  29126. /**
  29127. * Get view of corresponding series model
  29128. */
  29129. ECharts.prototype.getViewOfSeriesModel = function (seriesModel) {
  29130. return this._chartsMap[seriesModel.__viewId];
  29131. };
  29132. ECharts.prototype._initEvents = function () {
  29133. var _this = this;
  29134. each(MOUSE_EVENT_NAMES, function (eveName) {
  29135. var handler = function (e) {
  29136. var ecModel = _this.getModel();
  29137. var el = e.target;
  29138. var params;
  29139. var isGlobalOut = eveName === 'globalout'; // no e.target when 'globalout'.
  29140. if (isGlobalOut) {
  29141. params = {};
  29142. } else {
  29143. el && findEventDispatcher(el, function (parent) {
  29144. var ecData = getECData(parent);
  29145. if (ecData && ecData.dataIndex != null) {
  29146. var dataModel = ecData.dataModel || ecModel.getSeriesByIndex(ecData.seriesIndex);
  29147. params = dataModel && dataModel.getDataParams(ecData.dataIndex, ecData.dataType) || {};
  29148. return true;
  29149. } // If element has custom eventData of components
  29150. else if (ecData.eventData) {
  29151. params = extend({}, ecData.eventData);
  29152. return true;
  29153. }
  29154. }, true);
  29155. } // Contract: if params prepared in mouse event,
  29156. // these properties must be specified:
  29157. // {
  29158. // componentType: string (component main type)
  29159. // componentIndex: number
  29160. // }
  29161. // Otherwise event query can not work.
  29162. if (params) {
  29163. var componentType = params.componentType;
  29164. var componentIndex = params.componentIndex; // Special handling for historic reason: when trigger by
  29165. // markLine/markPoint/markArea, the componentType is
  29166. // 'markLine'/'markPoint'/'markArea', but we should better
  29167. // enable them to be queried by seriesIndex, since their
  29168. // option is set in each series.
  29169. if (componentType === 'markLine' || componentType === 'markPoint' || componentType === 'markArea') {
  29170. componentType = 'series';
  29171. componentIndex = params.seriesIndex;
  29172. }
  29173. var model = componentType && componentIndex != null && ecModel.getComponent(componentType, componentIndex);
  29174. var view = model && _this[model.mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId];
  29175. {
  29176. // `event.componentType` and `event[componentTpype + 'Index']` must not
  29177. // be missed, otherwise there is no way to distinguish source component.
  29178. // See `dataFormat.getDataParams`.
  29179. if (!isGlobalOut && !(model && view)) {
  29180. console.warn('model or view can not be found by params');
  29181. }
  29182. }
  29183. params.event = e;
  29184. params.type = eveName;
  29185. _this._$eventProcessor.eventInfo = {
  29186. targetEl: el,
  29187. packedEvent: params,
  29188. model: model,
  29189. view: view
  29190. };
  29191. _this.trigger(eveName, params);
  29192. }
  29193. }; // Consider that some component (like tooltip, brush, ...)
  29194. // register zr event handler, but user event handler might
  29195. // do anything, such as call `setOption` or `dispatchAction`,
  29196. // which probably update any of the content and probably
  29197. // cause problem if it is called previous other inner handlers.
  29198. handler.zrEventfulCallAtLast = true;
  29199. _this._zr.on(eveName, handler, _this);
  29200. });
  29201. each(eventActionMap, function (actionType, eventType) {
  29202. _this._messageCenter.on(eventType, function (event) {
  29203. this.trigger(eventType, event);
  29204. }, _this);
  29205. }); // Extra events
  29206. // TODO register?
  29207. each(['selectchanged'], function (eventType) {
  29208. _this._messageCenter.on(eventType, function (event) {
  29209. this.trigger(eventType, event);
  29210. }, _this);
  29211. });
  29212. handleLegacySelectEvents(this._messageCenter, this, this._api);
  29213. };
  29214. ECharts.prototype.isDisposed = function () {
  29215. return this._disposed;
  29216. };
  29217. ECharts.prototype.clear = function () {
  29218. if (this._disposed) {
  29219. disposedWarning(this.id);
  29220. return;
  29221. }
  29222. this.setOption({
  29223. series: []
  29224. }, true);
  29225. };
  29226. ECharts.prototype.dispose = function () {
  29227. if (this._disposed) {
  29228. disposedWarning(this.id);
  29229. return;
  29230. }
  29231. this._disposed = true;
  29232. setAttribute(this.getDom(), DOM_ATTRIBUTE_KEY, '');
  29233. var api = this._api;
  29234. var ecModel = this._model;
  29235. each(this._componentsViews, function (component) {
  29236. component.dispose(ecModel, api);
  29237. });
  29238. each(this._chartsViews, function (chart) {
  29239. chart.dispose(ecModel, api);
  29240. }); // Dispose after all views disposed
  29241. this._zr.dispose();
  29242. delete instances[this.id];
  29243. };
  29244. /**
  29245. * Resize the chart
  29246. */
  29247. ECharts.prototype.resize = function (opts) {
  29248. {
  29249. assert(!this[IN_MAIN_PROCESS_KEY], '`resize` should not be called during main process.');
  29250. }
  29251. if (this._disposed) {
  29252. disposedWarning(this.id);
  29253. return;
  29254. }
  29255. this._zr.resize(opts);
  29256. var ecModel = this._model; // Resize loading effect
  29257. this._loadingFX && this._loadingFX.resize();
  29258. if (!ecModel) {
  29259. return;
  29260. }
  29261. var optionChanged = ecModel.resetOption('media');
  29262. var silent = opts && opts.silent;
  29263. this[IN_MAIN_PROCESS_KEY] = true;
  29264. optionChanged && prepare(this);
  29265. updateMethods.update.call(this, {
  29266. type: 'resize',
  29267. animation: extend({
  29268. // Disable animation
  29269. duration: 0
  29270. }, opts && opts.animation)
  29271. });
  29272. this[IN_MAIN_PROCESS_KEY] = false;
  29273. flushPendingActions.call(this, silent);
  29274. triggerUpdatedEvent.call(this, silent);
  29275. };
  29276. ECharts.prototype.showLoading = function (name, cfg) {
  29277. if (this._disposed) {
  29278. disposedWarning(this.id);
  29279. return;
  29280. }
  29281. if (isObject(name)) {
  29282. cfg = name;
  29283. name = '';
  29284. }
  29285. name = name || 'default';
  29286. this.hideLoading();
  29287. if (!loadingEffects[name]) {
  29288. {
  29289. console.warn('Loading effects ' + name + ' not exists.');
  29290. }
  29291. return;
  29292. }
  29293. var el = loadingEffects[name](this._api, cfg);
  29294. var zr = this._zr;
  29295. this._loadingFX = el;
  29296. zr.add(el);
  29297. };
  29298. /**
  29299. * Hide loading effect
  29300. */
  29301. ECharts.prototype.hideLoading = function () {
  29302. if (this._disposed) {
  29303. disposedWarning(this.id);
  29304. return;
  29305. }
  29306. this._loadingFX && this._zr.remove(this._loadingFX);
  29307. this._loadingFX = null;
  29308. };
  29309. ECharts.prototype.makeActionFromEvent = function (eventObj) {
  29310. var payload = extend({}, eventObj);
  29311. payload.type = eventActionMap[eventObj.type];
  29312. return payload;
  29313. };
  29314. /**
  29315. * @param opt If pass boolean, means opt.silent
  29316. * @param opt.silent Default `false`. Whether trigger events.
  29317. * @param opt.flush Default `undefined`.
  29318. * true: Flush immediately, and then pixel in canvas can be fetched
  29319. * immediately. Caution: it might affect performance.
  29320. * false: Not flush.
  29321. * undefined: Auto decide whether perform flush.
  29322. */
  29323. ECharts.prototype.dispatchAction = function (payload, opt) {
  29324. if (this._disposed) {
  29325. disposedWarning(this.id);
  29326. return;
  29327. }
  29328. if (!isObject(opt)) {
  29329. opt = {
  29330. silent: !!opt
  29331. };
  29332. }
  29333. if (!actions[payload.type]) {
  29334. return;
  29335. } // Avoid dispatch action before setOption. Especially in `connect`.
  29336. if (!this._model) {
  29337. return;
  29338. } // May dispatchAction in rendering procedure
  29339. if (this[IN_MAIN_PROCESS_KEY]) {
  29340. this._pendingActions.push(payload);
  29341. return;
  29342. }
  29343. var silent = opt.silent;
  29344. doDispatchAction.call(this, payload, silent);
  29345. var flush = opt.flush;
  29346. if (flush) {
  29347. this._zr.flush();
  29348. } else if (flush !== false && env.browser.weChat) {
  29349. // In WeChat embeded browser, `requestAnimationFrame` and `setInterval`
  29350. // hang when sliding page (on touch event), which cause that zr does not
  29351. // refresh util user interaction finished, which is not expected.
  29352. // But `dispatchAction` may be called too frequently when pan on touch
  29353. // screen, which impacts performance if do not throttle them.
  29354. this._throttledZrFlush();
  29355. }
  29356. flushPendingActions.call(this, silent);
  29357. triggerUpdatedEvent.call(this, silent);
  29358. };
  29359. ECharts.prototype.updateLabelLayout = function () {
  29360. var labelManager = this._labelManager;
  29361. labelManager.updateLayoutConfig(this._api);
  29362. labelManager.layout(this._api);
  29363. labelManager.processLabelsOverall();
  29364. };
  29365. ECharts.prototype.appendData = function (params) {
  29366. if (this._disposed) {
  29367. disposedWarning(this.id);
  29368. return;
  29369. }
  29370. var seriesIndex = params.seriesIndex;
  29371. var ecModel = this.getModel();
  29372. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  29373. {
  29374. assert(params.data && seriesModel);
  29375. }
  29376. seriesModel.appendData(params); // Note: `appendData` does not support that update extent of coordinate
  29377. // system, util some scenario require that. In the expected usage of
  29378. // `appendData`, the initial extent of coordinate system should better
  29379. // be fixed by axis `min`/`max` setting or initial data, otherwise if
  29380. // the extent changed while `appendData`, the location of the painted
  29381. // graphic elements have to be changed, which make the usage of
  29382. // `appendData` meaningless.
  29383. this._scheduler.unfinished = true;
  29384. this.getZr().wakeUp();
  29385. }; // A work around for no `internal` modifier in ts yet but
  29386. // need to strictly hide private methods to JS users.
  29387. ECharts.internalField = function () {
  29388. prepare = function (ecIns) {
  29389. var scheduler = ecIns._scheduler;
  29390. scheduler.restorePipelines(ecIns._model);
  29391. scheduler.prepareStageTasks();
  29392. prepareView(ecIns, true);
  29393. prepareView(ecIns, false);
  29394. scheduler.plan();
  29395. };
  29396. /**
  29397. * Prepare view instances of charts and components
  29398. */
  29399. prepareView = function (ecIns, isComponent) {
  29400. var ecModel = ecIns._model;
  29401. var scheduler = ecIns._scheduler;
  29402. var viewList = isComponent ? ecIns._componentsViews : ecIns._chartsViews;
  29403. var viewMap = isComponent ? ecIns._componentsMap : ecIns._chartsMap;
  29404. var zr = ecIns._zr;
  29405. var api = ecIns._api;
  29406. for (var i = 0; i < viewList.length; i++) {
  29407. viewList[i].__alive = false;
  29408. }
  29409. isComponent ? ecModel.eachComponent(function (componentType, model) {
  29410. componentType !== 'series' && doPrepare(model);
  29411. }) : ecModel.eachSeries(doPrepare);
  29412. function doPrepare(model) {
  29413. // By defaut view will be reused if possible for the case that `setOption` with "notMerge"
  29414. // mode and need to enable transition animation. (Usually, when they have the same id, or
  29415. // especially no id but have the same type & name & index. See the `model.id` generation
  29416. // rule in `makeIdAndName` and `viewId` generation rule here).
  29417. // But in `replaceMerge` mode, this feature should be able to disabled when it is clear that
  29418. // the new model has nothing to do with the old model.
  29419. var requireNewView = model.__requireNewView; // This command should not work twice.
  29420. model.__requireNewView = false; // Consider: id same and type changed.
  29421. var viewId = '_ec_' + model.id + '_' + model.type;
  29422. var view = !requireNewView && viewMap[viewId];
  29423. if (!view) {
  29424. var classType = parseClassType(model.type);
  29425. var Clazz = isComponent ? ComponentView.getClass(classType.main, classType.sub) : // FIXME:TS
  29426. // (ChartView as ChartViewConstructor).getClass('series', classType.sub)
  29427. // For backward compat, still support a chart type declared as only subType
  29428. // like "liquidfill", but recommend "series.liquidfill"
  29429. // But need a base class to make a type series.
  29430. ChartView.getClass(classType.sub);
  29431. {
  29432. assert(Clazz, classType.sub + ' does not exist.');
  29433. }
  29434. view = new Clazz();
  29435. view.init(ecModel, api);
  29436. viewMap[viewId] = view;
  29437. viewList.push(view);
  29438. zr.add(view.group);
  29439. }
  29440. model.__viewId = view.__id = viewId;
  29441. view.__alive = true;
  29442. view.__model = model;
  29443. view.group.__ecComponentInfo = {
  29444. mainType: model.mainType,
  29445. index: model.componentIndex
  29446. };
  29447. !isComponent && scheduler.prepareView(view, model, ecModel, api);
  29448. }
  29449. for (var i = 0; i < viewList.length;) {
  29450. var view = viewList[i];
  29451. if (!view.__alive) {
  29452. !isComponent && view.renderTask.dispose();
  29453. zr.remove(view.group);
  29454. view.dispose(ecModel, api);
  29455. viewList.splice(i, 1);
  29456. if (viewMap[view.__id] === view) {
  29457. delete viewMap[view.__id];
  29458. }
  29459. view.__id = view.group.__ecComponentInfo = null;
  29460. } else {
  29461. i++;
  29462. }
  29463. }
  29464. };
  29465. updateDirectly = function (ecIns, method, payload, mainType, subType) {
  29466. var ecModel = ecIns._model;
  29467. ecModel.setUpdatePayload(payload); // broadcast
  29468. if (!mainType) {
  29469. // FIXME
  29470. // Chart will not be update directly here, except set dirty.
  29471. // But there is no such scenario now.
  29472. each([].concat(ecIns._componentsViews).concat(ecIns._chartsViews), callView);
  29473. return;
  29474. }
  29475. var query = {};
  29476. query[mainType + 'Id'] = payload[mainType + 'Id'];
  29477. query[mainType + 'Index'] = payload[mainType + 'Index'];
  29478. query[mainType + 'Name'] = payload[mainType + 'Name'];
  29479. var condition = {
  29480. mainType: mainType,
  29481. query: query
  29482. };
  29483. subType && (condition.subType = subType); // subType may be '' by parseClassType;
  29484. var excludeSeriesId = payload.excludeSeriesId;
  29485. var excludeSeriesIdMap;
  29486. if (excludeSeriesId != null) {
  29487. excludeSeriesIdMap = createHashMap();
  29488. each(normalizeToArray(excludeSeriesId), function (id) {
  29489. var modelId = convertOptionIdName(id, null);
  29490. if (modelId != null) {
  29491. excludeSeriesIdMap.set(modelId, true);
  29492. }
  29493. });
  29494. }
  29495. if (isHighDownPayload(payload)) {
  29496. allLeaveBlur(ecIns._api);
  29497. } // If dispatchAction before setOption, do nothing.
  29498. ecModel && ecModel.eachComponent(condition, function (model) {
  29499. if (!excludeSeriesIdMap || excludeSeriesIdMap.get(model.id) == null) {
  29500. if (isHighDownPayload(payload)) {
  29501. if (model instanceof SeriesModel) {
  29502. if (payload.type === HIGHLIGHT_ACTION_TYPE && !payload.notBlur) {
  29503. blurSeriesFromHighlightPayload(model, payload, ecIns._api);
  29504. }
  29505. } else {
  29506. var _a = findComponentHighDownDispatchers(model.mainType, model.componentIndex, payload.name, ecIns._api),
  29507. focusSelf = _a.focusSelf,
  29508. dispatchers = _a.dispatchers;
  29509. if (payload.type === HIGHLIGHT_ACTION_TYPE && focusSelf && !payload.notBlur) {
  29510. blurComponent(model.mainType, model.componentIndex, ecIns._api);
  29511. } // PENDING:
  29512. // Whether to put this "enter emphasis" code in `ComponentView`,
  29513. // which will be the same as `ChartView` but might be not necessary
  29514. // and will be far from this logic.
  29515. if (dispatchers) {
  29516. each(dispatchers, function (dispatcher) {
  29517. payload.type === HIGHLIGHT_ACTION_TYPE ? enterEmphasis(dispatcher) : leaveEmphasis(dispatcher);
  29518. });
  29519. }
  29520. }
  29521. } else if (isSelectChangePayload(payload)) {
  29522. // TODO geo
  29523. if (model instanceof SeriesModel) {
  29524. toggleSelectionFromPayload(model, payload, ecIns._api);
  29525. updateSeriesElementSelection(model);
  29526. markStatusToUpdate(ecIns);
  29527. }
  29528. }
  29529. callView(ecIns[mainType === 'series' ? '_chartsMap' : '_componentsMap'][model.__viewId]);
  29530. }
  29531. }, ecIns);
  29532. function callView(view) {
  29533. view && view.__alive && view[method] && view[method](view.__model, ecModel, ecIns._api, payload);
  29534. }
  29535. };
  29536. updateMethods = {
  29537. prepareAndUpdate: function (payload) {
  29538. prepare(this);
  29539. updateMethods.update.call(this, payload);
  29540. },
  29541. update: function (payload) {
  29542. // console.profile && console.profile('update');
  29543. var ecModel = this._model;
  29544. var api = this._api;
  29545. var zr = this._zr;
  29546. var coordSysMgr = this._coordSysMgr;
  29547. var scheduler = this._scheduler; // update before setOption
  29548. if (!ecModel) {
  29549. return;
  29550. }
  29551. ecModel.setUpdatePayload(payload);
  29552. scheduler.restoreData(ecModel, payload);
  29553. scheduler.performSeriesTasks(ecModel); // TODO
  29554. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  29555. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  29556. // Create new coordinate system each update
  29557. // In LineView may save the old coordinate system and use it to get the orignal point
  29558. coordSysMgr.create(ecModel, api);
  29559. scheduler.performDataProcessorTasks(ecModel, payload); // Current stream render is not supported in data process. So we can update
  29560. // stream modes after data processing, where the filtered data is used to
  29561. // deteming whether use progressive rendering.
  29562. updateStreamModes(this, ecModel); // We update stream modes before coordinate system updated, then the modes info
  29563. // can be fetched when coord sys updating (consider the barGrid extent fix). But
  29564. // the drawback is the full coord info can not be fetched. Fortunately this full
  29565. // coord is not requied in stream mode updater currently.
  29566. coordSysMgr.update(ecModel, api);
  29567. clearColorPalette(ecModel);
  29568. scheduler.performVisualTasks(ecModel, payload);
  29569. render(this, ecModel, api, payload); // Set background
  29570. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  29571. var darkMode = ecModel.get('darkMode'); // In IE8
  29572. if (!env.canvasSupported) {
  29573. var colorArr = parse(backgroundColor);
  29574. backgroundColor = stringify(colorArr, 'rgb');
  29575. if (colorArr[3] === 0) {
  29576. backgroundColor = 'transparent';
  29577. }
  29578. } else {
  29579. zr.setBackgroundColor(backgroundColor); // Force set dark mode.
  29580. if (darkMode != null && darkMode !== 'auto') {
  29581. zr.setDarkMode(darkMode);
  29582. }
  29583. }
  29584. performPostUpdateFuncs(ecModel, api); // console.profile && console.profileEnd('update');
  29585. },
  29586. updateTransform: function (payload) {
  29587. var _this = this;
  29588. var ecModel = this._model;
  29589. var api = this._api; // update before setOption
  29590. if (!ecModel) {
  29591. return;
  29592. }
  29593. ecModel.setUpdatePayload(payload); // ChartView.markUpdateMethod(payload, 'updateTransform');
  29594. var componentDirtyList = [];
  29595. ecModel.eachComponent(function (componentType, componentModel) {
  29596. if (componentType === 'series') {
  29597. return;
  29598. }
  29599. var componentView = _this.getViewOfComponentModel(componentModel);
  29600. if (componentView && componentView.__alive) {
  29601. if (componentView.updateTransform) {
  29602. var result = componentView.updateTransform(componentModel, ecModel, api, payload);
  29603. result && result.update && componentDirtyList.push(componentView);
  29604. } else {
  29605. componentDirtyList.push(componentView);
  29606. }
  29607. }
  29608. });
  29609. var seriesDirtyMap = createHashMap();
  29610. ecModel.eachSeries(function (seriesModel) {
  29611. var chartView = _this._chartsMap[seriesModel.__viewId];
  29612. if (chartView.updateTransform) {
  29613. var result = chartView.updateTransform(seriesModel, ecModel, api, payload);
  29614. result && result.update && seriesDirtyMap.set(seriesModel.uid, 1);
  29615. } else {
  29616. seriesDirtyMap.set(seriesModel.uid, 1);
  29617. }
  29618. });
  29619. clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.
  29620. // this._scheduler.performVisualTasks(ecModel, payload, 'layout', true);
  29621. this._scheduler.performVisualTasks(ecModel, payload, {
  29622. setDirty: true,
  29623. dirtyMap: seriesDirtyMap
  29624. }); // Currently, not call render of components. Geo render cost a lot.
  29625. // renderComponents(ecIns, ecModel, api, payload, componentDirtyList);
  29626. renderSeries(this, ecModel, api, payload, seriesDirtyMap);
  29627. performPostUpdateFuncs(ecModel, this._api);
  29628. },
  29629. updateView: function (payload) {
  29630. var ecModel = this._model; // update before setOption
  29631. if (!ecModel) {
  29632. return;
  29633. }
  29634. ecModel.setUpdatePayload(payload);
  29635. ChartView.markUpdateMethod(payload, 'updateView');
  29636. clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.
  29637. this._scheduler.performVisualTasks(ecModel, payload, {
  29638. setDirty: true
  29639. });
  29640. render(this, this._model, this._api, payload);
  29641. performPostUpdateFuncs(ecModel, this._api);
  29642. },
  29643. updateVisual: function (payload) {
  29644. // updateMethods.update.call(this, payload);
  29645. var _this = this;
  29646. var ecModel = this._model; // update before setOption
  29647. if (!ecModel) {
  29648. return;
  29649. }
  29650. ecModel.setUpdatePayload(payload); // clear all visual
  29651. ecModel.eachSeries(function (seriesModel) {
  29652. seriesModel.getData().clearAllVisual();
  29653. }); // Perform visual
  29654. ChartView.markUpdateMethod(payload, 'updateVisual');
  29655. clearColorPalette(ecModel); // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.
  29656. this._scheduler.performVisualTasks(ecModel, payload, {
  29657. visualType: 'visual',
  29658. setDirty: true
  29659. });
  29660. ecModel.eachComponent(function (componentType, componentModel) {
  29661. if (componentType !== 'series') {
  29662. var componentView = _this.getViewOfComponentModel(componentModel);
  29663. componentView && componentView.__alive && componentView.updateVisual(componentModel, ecModel, _this._api, payload);
  29664. }
  29665. });
  29666. ecModel.eachSeries(function (seriesModel) {
  29667. var chartView = _this._chartsMap[seriesModel.__viewId];
  29668. chartView.updateVisual(seriesModel, ecModel, _this._api, payload);
  29669. });
  29670. performPostUpdateFuncs(ecModel, this._api);
  29671. },
  29672. updateLayout: function (payload) {
  29673. updateMethods.update.call(this, payload);
  29674. }
  29675. };
  29676. doConvertPixel = function (ecIns, methodName, finder, value) {
  29677. if (ecIns._disposed) {
  29678. disposedWarning(ecIns.id);
  29679. return;
  29680. }
  29681. var ecModel = ecIns._model;
  29682. var coordSysList = ecIns._coordSysMgr.getCoordinateSystems();
  29683. var result;
  29684. var parsedFinder = parseFinder(ecModel, finder);
  29685. for (var i = 0; i < coordSysList.length; i++) {
  29686. var coordSys = coordSysList[i];
  29687. if (coordSys[methodName] && (result = coordSys[methodName](ecModel, parsedFinder, value)) != null) {
  29688. return result;
  29689. }
  29690. }
  29691. {
  29692. console.warn('No coordinate system that supports ' + methodName + ' found by the given finder.');
  29693. }
  29694. };
  29695. updateStreamModes = function (ecIns, ecModel) {
  29696. var chartsMap = ecIns._chartsMap;
  29697. var scheduler = ecIns._scheduler;
  29698. ecModel.eachSeries(function (seriesModel) {
  29699. scheduler.updateStreamModes(seriesModel, chartsMap[seriesModel.__viewId]);
  29700. });
  29701. };
  29702. doDispatchAction = function (payload, silent) {
  29703. var _this = this;
  29704. var ecModel = this.getModel();
  29705. var payloadType = payload.type;
  29706. var escapeConnect = payload.escapeConnect;
  29707. var actionWrap = actions[payloadType];
  29708. var actionInfo = actionWrap.actionInfo;
  29709. var cptTypeTmp = (actionInfo.update || 'update').split(':');
  29710. var updateMethod = cptTypeTmp.pop();
  29711. var cptType = cptTypeTmp[0] != null && parseClassType(cptTypeTmp[0]);
  29712. this[IN_MAIN_PROCESS_KEY] = true;
  29713. var payloads = [payload];
  29714. var batched = false; // Batch action
  29715. if (payload.batch) {
  29716. batched = true;
  29717. payloads = map(payload.batch, function (item) {
  29718. item = defaults(extend({}, item), payload);
  29719. item.batch = null;
  29720. return item;
  29721. });
  29722. }
  29723. var eventObjBatch = [];
  29724. var eventObj;
  29725. var isSelectChange = isSelectChangePayload(payload);
  29726. var isHighDown = isHighDownPayload(payload);
  29727. each(payloads, function (batchItem) {
  29728. // Action can specify the event by return it.
  29729. eventObj = actionWrap.action(batchItem, _this._model, _this._api); // Emit event outside
  29730. eventObj = eventObj || extend({}, batchItem); // Convert type to eventType
  29731. eventObj.type = actionInfo.event || eventObj.type;
  29732. eventObjBatch.push(eventObj); // light update does not perform data process, layout and visual.
  29733. if (isHighDown) {
  29734. var _a = preParseFinder(payload),
  29735. queryOptionMap = _a.queryOptionMap,
  29736. mainTypeSpecified = _a.mainTypeSpecified;
  29737. var componentMainType = mainTypeSpecified ? queryOptionMap.keys()[0] : 'series';
  29738. updateDirectly(_this, updateMethod, batchItem, componentMainType);
  29739. markStatusToUpdate(_this);
  29740. } else if (isSelectChange) {
  29741. // At present `dispatchAction({ type: 'select', ... })` is not supported on components.
  29742. // geo still use 'geoselect'.
  29743. updateDirectly(_this, updateMethod, batchItem, 'series');
  29744. markStatusToUpdate(_this);
  29745. } else if (cptType) {
  29746. updateDirectly(_this, updateMethod, batchItem, cptType.main, cptType.sub);
  29747. }
  29748. });
  29749. if (updateMethod !== 'none' && !isHighDown && !isSelectChange && !cptType) {
  29750. // Still dirty
  29751. if (this[OPTION_UPDATED_KEY]) {
  29752. prepare(this);
  29753. updateMethods.update.call(this, payload);
  29754. this[OPTION_UPDATED_KEY] = false;
  29755. } else {
  29756. updateMethods[updateMethod].call(this, payload);
  29757. }
  29758. } // Follow the rule of action batch
  29759. if (batched) {
  29760. eventObj = {
  29761. type: actionInfo.event || payloadType,
  29762. escapeConnect: escapeConnect,
  29763. batch: eventObjBatch
  29764. };
  29765. } else {
  29766. eventObj = eventObjBatch[0];
  29767. }
  29768. this[IN_MAIN_PROCESS_KEY] = false;
  29769. if (!silent) {
  29770. var messageCenter = this._messageCenter;
  29771. messageCenter.trigger(eventObj.type, eventObj); // Extra triggered 'selectchanged' event
  29772. if (isSelectChange) {
  29773. var newObj = {
  29774. type: 'selectchanged',
  29775. escapeConnect: escapeConnect,
  29776. selected: getAllSelectedIndices(ecModel),
  29777. isFromClick: payload.isFromClick || false,
  29778. fromAction: payload.type,
  29779. fromActionPayload: payload
  29780. };
  29781. messageCenter.trigger(newObj.type, newObj);
  29782. }
  29783. }
  29784. };
  29785. flushPendingActions = function (silent) {
  29786. var pendingActions = this._pendingActions;
  29787. while (pendingActions.length) {
  29788. var payload = pendingActions.shift();
  29789. doDispatchAction.call(this, payload, silent);
  29790. }
  29791. };
  29792. triggerUpdatedEvent = function (silent) {
  29793. !silent && this.trigger('updated');
  29794. };
  29795. /**
  29796. * Event `rendered` is triggered when zr
  29797. * rendered. It is useful for realtime
  29798. * snapshot (reflect animation).
  29799. *
  29800. * Event `finished` is triggered when:
  29801. * (1) zrender rendering finished.
  29802. * (2) initial animation finished.
  29803. * (3) progressive rendering finished.
  29804. * (4) no pending action.
  29805. * (5) no delayed setOption needs to be processed.
  29806. */
  29807. bindRenderedEvent = function (zr, ecIns) {
  29808. zr.on('rendered', function (params) {
  29809. ecIns.trigger('rendered', params); // The `finished` event should not be triggered repeatly,
  29810. // so it should only be triggered when rendering indeed happend
  29811. // in zrender. (Consider the case that dipatchAction is keep
  29812. // triggering when mouse move).
  29813. if ( // Although zr is dirty if initial animation is not finished
  29814. // and this checking is called on frame, we also check
  29815. // animation finished for robustness.
  29816. zr.animation.isFinished() && !ecIns[OPTION_UPDATED_KEY] && !ecIns._scheduler.unfinished && !ecIns._pendingActions.length) {
  29817. ecIns.trigger('finished');
  29818. }
  29819. });
  29820. };
  29821. bindMouseEvent = function (zr, ecIns) {
  29822. zr.on('mouseover', function (e) {
  29823. var el = e.target;
  29824. var dispatcher = findEventDispatcher(el, isHighDownDispatcher);
  29825. if (dispatcher) {
  29826. handleGlobalMouseOverForHighDown(dispatcher, e, ecIns._api);
  29827. markStatusToUpdate(ecIns);
  29828. }
  29829. }).on('mouseout', function (e) {
  29830. var el = e.target;
  29831. var dispatcher = findEventDispatcher(el, isHighDownDispatcher);
  29832. if (dispatcher) {
  29833. handleGlboalMouseOutForHighDown(dispatcher, e, ecIns._api);
  29834. markStatusToUpdate(ecIns);
  29835. }
  29836. }).on('click', function (e) {
  29837. var el = e.target;
  29838. var dispatcher = findEventDispatcher(el, function (target) {
  29839. return getECData(target).dataIndex != null;
  29840. }, true);
  29841. if (dispatcher) {
  29842. var actionType = dispatcher.selected ? 'unselect' : 'select';
  29843. var ecData = getECData(dispatcher);
  29844. ecIns._api.dispatchAction({
  29845. type: actionType,
  29846. dataType: ecData.dataType,
  29847. dataIndexInside: ecData.dataIndex,
  29848. seriesIndex: ecData.seriesIndex,
  29849. isFromClick: true
  29850. });
  29851. }
  29852. });
  29853. };
  29854. clearColorPalette = function (ecModel) {
  29855. ecModel.clearColorPalette();
  29856. ecModel.eachSeries(function (seriesModel) {
  29857. seriesModel.clearColorPalette();
  29858. });
  29859. };
  29860. render = function (ecIns, ecModel, api, payload) {
  29861. renderComponents(ecIns, ecModel, api, payload);
  29862. each(ecIns._chartsViews, function (chart) {
  29863. chart.__alive = false;
  29864. });
  29865. renderSeries(ecIns, ecModel, api, payload); // Remove groups of unrendered charts
  29866. each(ecIns._chartsViews, function (chart) {
  29867. if (!chart.__alive) {
  29868. chart.remove(ecModel, api);
  29869. }
  29870. });
  29871. };
  29872. renderComponents = function (ecIns, ecModel, api, payload, dirtyList) {
  29873. each(dirtyList || ecIns._componentsViews, function (componentView) {
  29874. var componentModel = componentView.__model;
  29875. clearStates$$1(componentModel, componentView);
  29876. componentView.render(componentModel, ecModel, api, payload);
  29877. updateZ(componentModel, componentView);
  29878. updateStates(componentModel, componentView);
  29879. });
  29880. };
  29881. /**
  29882. * Render each chart and component
  29883. */
  29884. renderSeries = function (ecIns, ecModel, api, payload, dirtyMap) {
  29885. // Render all charts
  29886. var scheduler = ecIns._scheduler;
  29887. var labelManager = ecIns._labelManager;
  29888. labelManager.clearLabels();
  29889. var unfinished = false;
  29890. ecModel.eachSeries(function (seriesModel) {
  29891. var chartView = ecIns._chartsMap[seriesModel.__viewId];
  29892. chartView.__alive = true;
  29893. var renderTask = chartView.renderTask;
  29894. scheduler.updatePayload(renderTask, payload); // TODO states on marker.
  29895. clearStates$$1(seriesModel, chartView);
  29896. if (dirtyMap && dirtyMap.get(seriesModel.uid)) {
  29897. renderTask.dirty();
  29898. }
  29899. if (renderTask.perform(scheduler.getPerformArgs(renderTask))) {
  29900. unfinished = true;
  29901. }
  29902. seriesModel.__transientTransitionOpt = null;
  29903. chartView.group.silent = !!seriesModel.get('silent'); // Should not call markRedraw on group, because it will disable zrender
  29904. // increamental render (alway render from the __startIndex each frame)
  29905. // chartView.group.markRedraw();
  29906. updateBlend(seriesModel, chartView);
  29907. updateSeriesElementSelection(seriesModel); // Add labels.
  29908. labelManager.addLabelsOfSeries(chartView);
  29909. });
  29910. scheduler.unfinished = unfinished || scheduler.unfinished;
  29911. labelManager.updateLayoutConfig(api);
  29912. labelManager.layout(api);
  29913. labelManager.processLabelsOverall();
  29914. ecModel.eachSeries(function (seriesModel) {
  29915. var chartView = ecIns._chartsMap[seriesModel.__viewId]; // Update Z after labels updated. Before applying states.
  29916. updateZ(seriesModel, chartView); // NOTE: Update states after label is updated.
  29917. // label should be in normal status when layouting.
  29918. updateStates(seriesModel, chartView);
  29919. }); // If use hover layer
  29920. updateHoverLayerStatus(ecIns, ecModel);
  29921. };
  29922. performPostUpdateFuncs = function (ecModel, api) {
  29923. each(postUpdateFuncs, function (func) {
  29924. func(ecModel, api);
  29925. });
  29926. };
  29927. markStatusToUpdate = function (ecIns) {
  29928. ecIns[STATUS_NEEDS_UPDATE_KEY] = true; // Wake up zrender if it's sleep. Let it update states in the next frame.
  29929. ecIns.getZr().wakeUp();
  29930. };
  29931. applyChangedStates = function (ecIns) {
  29932. if (!ecIns[STATUS_NEEDS_UPDATE_KEY]) {
  29933. return;
  29934. }
  29935. ecIns.getZr().storage.traverse(function (el) {
  29936. // Not applied on removed elements, it may still in fading.
  29937. if (isElementRemoved(el)) {
  29938. return;
  29939. }
  29940. applyElementStates(el);
  29941. });
  29942. ecIns[STATUS_NEEDS_UPDATE_KEY] = false;
  29943. };
  29944. function applyElementStates(el) {
  29945. var newStates = [];
  29946. var oldStates = el.currentStates; // Keep other states.
  29947. for (var i = 0; i < oldStates.length; i++) {
  29948. var stateName = oldStates[i];
  29949. if (!(stateName === 'emphasis' || stateName === 'blur' || stateName === 'select')) {
  29950. newStates.push(stateName);
  29951. }
  29952. } // Only use states when it's exists.
  29953. if (el.selected && el.states.select) {
  29954. newStates.push('select');
  29955. }
  29956. if (el.hoverState === HOVER_STATE_EMPHASIS && el.states.emphasis) {
  29957. newStates.push('emphasis');
  29958. } else if (el.hoverState === HOVER_STATE_BLUR && el.states.blur) {
  29959. newStates.push('blur');
  29960. }
  29961. el.useStates(newStates);
  29962. }
  29963. function updateHoverLayerStatus(ecIns, ecModel) {
  29964. var zr = ecIns._zr;
  29965. var storage = zr.storage;
  29966. var elCount = 0;
  29967. storage.traverse(function (el) {
  29968. if (!el.isGroup) {
  29969. elCount++;
  29970. }
  29971. });
  29972. if (elCount > ecModel.get('hoverLayerThreshold') && !env.node && !env.worker) {
  29973. ecModel.eachSeries(function (seriesModel) {
  29974. if (seriesModel.preventUsingHoverLayer) {
  29975. return;
  29976. }
  29977. var chartView = ecIns._chartsMap[seriesModel.__viewId];
  29978. if (chartView.__alive) {
  29979. chartView.group.traverse(function (el) {
  29980. if (el.states.emphasis) {
  29981. el.states.emphasis.hoverLayer = true;
  29982. }
  29983. });
  29984. }
  29985. });
  29986. }
  29987. }
  29988. /**
  29989. * Update chart and blend.
  29990. */
  29991. function updateBlend(seriesModel, chartView) {
  29992. var blendMode = seriesModel.get('blendMode') || null;
  29993. {
  29994. if (!env.canvasSupported && blendMode && blendMode !== 'source-over') {
  29995. console.warn('Only canvas support blendMode');
  29996. }
  29997. }
  29998. chartView.group.traverse(function (el) {
  29999. // FIXME marker and other components
  30000. if (!el.isGroup) {
  30001. // DONT mark the element dirty. In case element is incremental and don't wan't to rerender.
  30002. el.style.blend = blendMode;
  30003. }
  30004. if (el.eachPendingDisplayable) {
  30005. el.eachPendingDisplayable(function (displayable) {
  30006. displayable.style.blend = blendMode;
  30007. });
  30008. }
  30009. });
  30010. }
  30011. function updateZ(model, view) {
  30012. if (model.preventAutoZ) {
  30013. return;
  30014. } // Set z and zlevel
  30015. _updateZ(view.group, model.get('z') || 0, model.get('zlevel') || 0, -Infinity);
  30016. }
  30017. function _updateZ(el, z, zlevel, maxZ2) {
  30018. // Group may also have textContent
  30019. var label = el.getTextContent();
  30020. var labelLine = el.getTextGuideLine();
  30021. var isGroup = el.isGroup;
  30022. if (isGroup) {
  30023. // set z & zlevel of children elements of Group
  30024. // el.traverse((childEl: Element) => _updateZ(childEl, z, zlevel));
  30025. var children = el.childrenRef();
  30026. for (var i = 0; i < children.length; i++) {
  30027. maxZ2 = Math.max(_updateZ(children[i], z, zlevel, maxZ2), maxZ2);
  30028. }
  30029. } else {
  30030. // not Group
  30031. el.z = z;
  30032. el.zlevel = zlevel;
  30033. maxZ2 = Math.max(el.z2, maxZ2);
  30034. } // always set z and zlevel if label/labelLine exists
  30035. if (label) {
  30036. label.z = z;
  30037. label.zlevel = zlevel; // lift z2 of text content
  30038. // TODO if el.emphasis.z2 is spcefied, what about textContent.
  30039. isFinite(maxZ2) && (label.z2 = maxZ2 + 2);
  30040. }
  30041. if (labelLine) {
  30042. var textGuideLineConfig = el.textGuideLineConfig;
  30043. labelLine.z = z;
  30044. labelLine.zlevel = zlevel;
  30045. isFinite(maxZ2) && (labelLine.z2 = maxZ2 + (textGuideLineConfig && textGuideLineConfig.showAbove ? 1 : -1));
  30046. }
  30047. return maxZ2;
  30048. } // Clear states without animation.
  30049. // TODO States on component.
  30050. function clearStates$$1(model, view) {
  30051. view.group.traverse(function (el) {
  30052. // Not applied on removed elements, it may still in fading.
  30053. if (isElementRemoved(el)) {
  30054. return;
  30055. }
  30056. var textContent = el.getTextContent();
  30057. var textGuide = el.getTextGuideLine();
  30058. if (el.stateTransition) {
  30059. el.stateTransition = null;
  30060. }
  30061. if (textContent && textContent.stateTransition) {
  30062. textContent.stateTransition = null;
  30063. }
  30064. if (textGuide && textGuide.stateTransition) {
  30065. textGuide.stateTransition = null;
  30066. } // TODO If el is incremental.
  30067. if (el.hasState()) {
  30068. el.prevStates = el.currentStates;
  30069. el.clearStates();
  30070. } else if (el.prevStates) {
  30071. el.prevStates = null;
  30072. }
  30073. });
  30074. }
  30075. function updateStates(model, view) {
  30076. var stateAnimationModel = model.getModel('stateAnimation');
  30077. var enableAnimation = model.isAnimationEnabled();
  30078. var duration = stateAnimationModel.get('duration');
  30079. var stateTransition = duration > 0 ? {
  30080. duration: duration,
  30081. delay: stateAnimationModel.get('delay'),
  30082. easing: stateAnimationModel.get('easing') // additive: stateAnimationModel.get('additive')
  30083. } : null;
  30084. view.group.traverse(function (el) {
  30085. if (el.states && el.states.emphasis) {
  30086. // Not applied on removed elements, it may still in fading.
  30087. if (isElementRemoved(el)) {
  30088. return;
  30089. }
  30090. if (el instanceof Path) {
  30091. savePathStates(el);
  30092. } // Only updated on changed element. In case element is incremental and don't wan't to rerender.
  30093. // TODO, a more proper way?
  30094. if (el.__dirty) {
  30095. var prevStates = el.prevStates; // Restore states without animation
  30096. if (prevStates) {
  30097. el.useStates(prevStates);
  30098. }
  30099. } // Update state transition and enable animation again.
  30100. if (enableAnimation) {
  30101. el.stateTransition = stateTransition;
  30102. var textContent = el.getTextContent();
  30103. var textGuide = el.getTextGuideLine(); // TODO Is it necessary to animate label?
  30104. if (textContent) {
  30105. textContent.stateTransition = stateTransition;
  30106. }
  30107. if (textGuide) {
  30108. textGuide.stateTransition = stateTransition;
  30109. }
  30110. } // The use higlighted and selected flag to toggle states.
  30111. if (el.__dirty) {
  30112. applyElementStates(el);
  30113. }
  30114. }
  30115. });
  30116. }
  30117. createExtensionAPI = function (ecIns) {
  30118. return new (
  30119. /** @class */
  30120. function (_super) {
  30121. __extends(class_1, _super);
  30122. function class_1() {
  30123. return _super !== null && _super.apply(this, arguments) || this;
  30124. }
  30125. class_1.prototype.getCoordinateSystems = function () {
  30126. return ecIns._coordSysMgr.getCoordinateSystems();
  30127. };
  30128. class_1.prototype.getComponentByElement = function (el) {
  30129. while (el) {
  30130. var modelInfo = el.__ecComponentInfo;
  30131. if (modelInfo != null) {
  30132. return ecIns._model.getComponent(modelInfo.mainType, modelInfo.index);
  30133. }
  30134. el = el.parent;
  30135. }
  30136. };
  30137. class_1.prototype.enterEmphasis = function (el, highlightDigit) {
  30138. enterEmphasis(el, highlightDigit);
  30139. markStatusToUpdate(ecIns);
  30140. };
  30141. class_1.prototype.leaveEmphasis = function (el, highlightDigit) {
  30142. leaveEmphasis(el, highlightDigit);
  30143. markStatusToUpdate(ecIns);
  30144. };
  30145. class_1.prototype.enterBlur = function (el) {
  30146. enterBlur(el);
  30147. markStatusToUpdate(ecIns);
  30148. };
  30149. class_1.prototype.leaveBlur = function (el) {
  30150. leaveBlur(el);
  30151. markStatusToUpdate(ecIns);
  30152. };
  30153. class_1.prototype.enterSelect = function (el) {
  30154. enterSelect(el);
  30155. markStatusToUpdate(ecIns);
  30156. };
  30157. class_1.prototype.leaveSelect = function (el) {
  30158. leaveSelect(el);
  30159. markStatusToUpdate(ecIns);
  30160. };
  30161. class_1.prototype.getModel = function () {
  30162. return ecIns.getModel();
  30163. };
  30164. class_1.prototype.getViewOfComponentModel = function (componentModel) {
  30165. return ecIns.getViewOfComponentModel(componentModel);
  30166. };
  30167. class_1.prototype.getViewOfSeriesModel = function (seriesModel) {
  30168. return ecIns.getViewOfSeriesModel(seriesModel);
  30169. };
  30170. return class_1;
  30171. }(ExtensionAPI))(ecIns);
  30172. };
  30173. enableConnect = function (chart) {
  30174. function updateConnectedChartsStatus(charts, status) {
  30175. for (var i = 0; i < charts.length; i++) {
  30176. var otherChart = charts[i];
  30177. otherChart[CONNECT_STATUS_KEY] = status;
  30178. }
  30179. }
  30180. each(eventActionMap, function (actionType, eventType) {
  30181. chart._messageCenter.on(eventType, function (event) {
  30182. if (connectedGroups[chart.group] && chart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_PENDING) {
  30183. if (event && event.escapeConnect) {
  30184. return;
  30185. }
  30186. var action_1 = chart.makeActionFromEvent(event);
  30187. var otherCharts_1 = [];
  30188. each(instances, function (otherChart) {
  30189. if (otherChart !== chart && otherChart.group === chart.group) {
  30190. otherCharts_1.push(otherChart);
  30191. }
  30192. });
  30193. updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_PENDING);
  30194. each(otherCharts_1, function (otherChart) {
  30195. if (otherChart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_UPDATING) {
  30196. otherChart.dispatchAction(action_1);
  30197. }
  30198. });
  30199. updateConnectedChartsStatus(otherCharts_1, CONNECT_STATUS_UPDATED);
  30200. }
  30201. });
  30202. });
  30203. };
  30204. setTransitionOpt = function (chart, transitionOpt) {
  30205. var ecModel = chart._model;
  30206. each$1(normalizeToArray(transitionOpt), function (transOpt) {
  30207. var errMsg;
  30208. var fromOpt = transOpt.from;
  30209. var toOpt = transOpt.to;
  30210. if (toOpt == null) {
  30211. {
  30212. errMsg = '`transition.to` must be specified.';
  30213. }
  30214. throwError(errMsg);
  30215. }
  30216. var finderOpt = {
  30217. includeMainTypes: ['series'],
  30218. enableAll: false,
  30219. enableNone: false
  30220. };
  30221. var fromResult = fromOpt ? parseFinder(ecModel, fromOpt, finderOpt) : null;
  30222. var toResult = parseFinder(ecModel, toOpt, finderOpt);
  30223. var toSeries = toResult.seriesModel;
  30224. if (toSeries == null) {
  30225. errMsg = '';
  30226. {
  30227. errMsg = '`transition` is only supported on series.';
  30228. }
  30229. }
  30230. if (fromResult && fromResult.seriesModel !== toSeries) {
  30231. errMsg = '';
  30232. {
  30233. errMsg = '`transition.from` and `transition.to` must be specified to the same series.';
  30234. }
  30235. }
  30236. if (errMsg != null) {
  30237. throwError(errMsg);
  30238. } // Just a temp solution: mount them on series.
  30239. toSeries.__transientTransitionOpt = {
  30240. from: fromOpt ? fromOpt.dimension : null,
  30241. to: toOpt.dimension,
  30242. dividingMethod: transOpt.dividingMethod
  30243. };
  30244. });
  30245. };
  30246. }();
  30247. return ECharts;
  30248. }(Eventful);
  30249. var echartsProto = ECharts.prototype;
  30250. echartsProto.on = createRegisterEventWithLowercaseECharts('on');
  30251. echartsProto.off = createRegisterEventWithLowercaseECharts('off');
  30252. /**
  30253. * @deprecated
  30254. */
  30255. // @ts-ignore
  30256. echartsProto.one = function (eventName, cb, ctx) {
  30257. var self = this;
  30258. deprecateLog('ECharts#one is deprecated.');
  30259. function wrapped() {
  30260. var args2 = [];
  30261. for (var _i = 0; _i < arguments.length; _i++) {
  30262. args2[_i] = arguments[_i];
  30263. }
  30264. cb && cb.apply && cb.apply(this, args2); // @ts-ignore
  30265. self.off(eventName, wrapped);
  30266. } // @ts-ignore
  30267. this.on.call(this, eventName, wrapped, ctx);
  30268. }; // /**
  30269. // * Encode visual infomation from data after data processing
  30270. // *
  30271. // * @param {module:echarts/model/Global} ecModel
  30272. // * @param {object} layout
  30273. // * @param {boolean} [layoutFilter] `true`: only layout,
  30274. // * `false`: only not layout,
  30275. // * `null`/`undefined`: all.
  30276. // * @param {string} taskBaseTag
  30277. // * @private
  30278. // */
  30279. // function startVisualEncoding(ecIns, ecModel, api, payload, layoutFilter) {
  30280. // each(visualFuncs, function (visual, index) {
  30281. // let isLayout = visual.isLayout;
  30282. // if (layoutFilter == null
  30283. // || (layoutFilter === false && !isLayout)
  30284. // || (layoutFilter === true && isLayout)
  30285. // ) {
  30286. // visual.func(ecModel, api, payload);
  30287. // }
  30288. // });
  30289. // }
  30290. var MOUSE_EVENT_NAMES = ['click', 'dblclick', 'mouseover', 'mouseout', 'mousemove', 'mousedown', 'mouseup', 'globalout', 'contextmenu'];
  30291. function disposedWarning(id) {
  30292. {
  30293. console.warn('Instance ' + id + ' has been disposed');
  30294. }
  30295. }
  30296. var actions = {};
  30297. /**
  30298. * Map eventType to actionType
  30299. */
  30300. var eventActionMap = {};
  30301. var dataProcessorFuncs = [];
  30302. var optionPreprocessorFuncs = [];
  30303. var postInitFuncs = [];
  30304. var postUpdateFuncs = [];
  30305. var visualFuncs = [];
  30306. var themeStorage = {};
  30307. var loadingEffects = {};
  30308. var instances = {};
  30309. var connectedGroups = {};
  30310. var idBase = +new Date() - 0;
  30311. var groupIdBase = +new Date() - 0;
  30312. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  30313. /**
  30314. * @param opts.devicePixelRatio Use window.devicePixelRatio by default
  30315. * @param opts.renderer Can choose 'canvas' or 'svg' to render the chart.
  30316. * @param opts.width Use clientWidth of the input `dom` by default.
  30317. * Can be 'auto' (the same as null/undefined)
  30318. * @param opts.height Use clientHeight of the input `dom` by default.
  30319. * Can be 'auto' (the same as null/undefined)
  30320. */
  30321. function init(dom, theme$$1, opts) {
  30322. {
  30323. if (!dom) {
  30324. throw new Error('Initialize failed: invalid dom.');
  30325. }
  30326. }
  30327. var existInstance = getInstanceByDom(dom);
  30328. if (existInstance) {
  30329. {
  30330. console.warn('There is a chart instance already initialized on the dom.');
  30331. }
  30332. return existInstance;
  30333. }
  30334. {
  30335. if (isDom(dom) && dom.nodeName.toUpperCase() !== 'CANVAS' && (!dom.clientWidth && (!opts || opts.width == null) || !dom.clientHeight && (!opts || opts.height == null))) {
  30336. console.warn('Can\'t get DOM width or height. Please check ' + 'dom.clientWidth and dom.clientHeight. They should not be 0.' + 'For example, you may need to call this in the callback ' + 'of window.onload.');
  30337. }
  30338. }
  30339. var chart = new ECharts(dom, theme$$1, opts);
  30340. chart.id = 'ec_' + idBase++;
  30341. instances[chart.id] = chart;
  30342. setAttribute(dom, DOM_ATTRIBUTE_KEY, chart.id);
  30343. enableConnect(chart);
  30344. each(postInitFuncs, function (postInitFunc) {
  30345. postInitFunc(chart);
  30346. });
  30347. return chart;
  30348. }
  30349. /**
  30350. * @usage
  30351. * (A)
  30352. * ```js
  30353. * let chart1 = echarts.init(dom1);
  30354. * let chart2 = echarts.init(dom2);
  30355. * chart1.group = 'xxx';
  30356. * chart2.group = 'xxx';
  30357. * echarts.connect('xxx');
  30358. * ```
  30359. * (B)
  30360. * ```js
  30361. * let chart1 = echarts.init(dom1);
  30362. * let chart2 = echarts.init(dom2);
  30363. * echarts.connect('xxx', [chart1, chart2]);
  30364. * ```
  30365. */
  30366. function connect(groupId) {
  30367. // Is array of charts
  30368. if (isArray(groupId)) {
  30369. var charts = groupId;
  30370. groupId = null; // If any chart has group
  30371. each(charts, function (chart) {
  30372. if (chart.group != null) {
  30373. groupId = chart.group;
  30374. }
  30375. });
  30376. groupId = groupId || 'g_' + groupIdBase++;
  30377. each(charts, function (chart) {
  30378. chart.group = groupId;
  30379. });
  30380. }
  30381. connectedGroups[groupId] = true;
  30382. return groupId;
  30383. }
  30384. /**
  30385. * @deprecated
  30386. */
  30387. function disConnect(groupId) {
  30388. connectedGroups[groupId] = false;
  30389. }
  30390. /**
  30391. * Alias and backword compat
  30392. */
  30393. var disconnect = disConnect;
  30394. /**
  30395. * Dispose a chart instance
  30396. */
  30397. function dispose(chart) {
  30398. if (typeof chart === 'string') {
  30399. chart = instances[chart];
  30400. } else if (!(chart instanceof ECharts)) {
  30401. // Try to treat as dom
  30402. chart = getInstanceByDom(chart);
  30403. }
  30404. if (chart instanceof ECharts && !chart.isDisposed()) {
  30405. chart.dispose();
  30406. }
  30407. }
  30408. function getInstanceByDom(dom) {
  30409. return instances[getAttribute(dom, DOM_ATTRIBUTE_KEY)];
  30410. }
  30411. function getInstanceById(key) {
  30412. return instances[key];
  30413. }
  30414. /**
  30415. * Register theme
  30416. */
  30417. function registerTheme(name, theme$$1) {
  30418. themeStorage[name] = theme$$1;
  30419. }
  30420. /**
  30421. * Register option preprocessor
  30422. */
  30423. function registerPreprocessor(preprocessorFunc) {
  30424. if (indexOf(optionPreprocessorFuncs, preprocessorFunc) < 0) {
  30425. optionPreprocessorFuncs.push(preprocessorFunc);
  30426. }
  30427. }
  30428. function registerProcessor(priority, processor) {
  30429. normalizeRegister(dataProcessorFuncs, priority, processor, PRIORITY_PROCESSOR_DEFAULT);
  30430. }
  30431. /**
  30432. * Register postIniter
  30433. * @param {Function} postInitFunc
  30434. */
  30435. function registerPostInit(postInitFunc) {
  30436. if (indexOf(postInitFuncs, postInitFunc) < 0) {
  30437. postInitFunc && postInitFuncs.push(postInitFunc);
  30438. }
  30439. }
  30440. /**
  30441. * Register postUpdater
  30442. * @param {Function} postUpdateFunc
  30443. */
  30444. function registerPostUpdate(postUpdateFunc) {
  30445. if (indexOf(postUpdateFuncs, postUpdateFunc) < 0) {
  30446. postUpdateFunc && postUpdateFuncs.push(postUpdateFunc);
  30447. }
  30448. }
  30449. function registerAction(actionInfo, eventName, action) {
  30450. if (typeof eventName === 'function') {
  30451. action = eventName;
  30452. eventName = '';
  30453. }
  30454. var actionType = isObject(actionInfo) ? actionInfo.type : [actionInfo, actionInfo = {
  30455. event: eventName
  30456. }][0]; // Event name is all lowercase
  30457. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  30458. eventName = actionInfo.event;
  30459. if (eventActionMap[eventName]) {
  30460. // Already registered.
  30461. return;
  30462. } // Validate action type and event name.
  30463. assert(ACTION_REG.test(actionType) && ACTION_REG.test(eventName));
  30464. if (!actions[actionType]) {
  30465. actions[actionType] = {
  30466. action: action,
  30467. actionInfo: actionInfo
  30468. };
  30469. }
  30470. eventActionMap[eventName] = actionType;
  30471. }
  30472. function registerCoordinateSystem(type, coordSysCreator) {
  30473. CoordinateSystemManager.register(type, coordSysCreator);
  30474. }
  30475. /**
  30476. * Get dimensions of specified coordinate system.
  30477. * @param {string} type
  30478. * @return {Array.<string|Object>}
  30479. */
  30480. function getCoordinateSystemDimensions(type) {
  30481. var coordSysCreator = CoordinateSystemManager.get(type);
  30482. if (coordSysCreator) {
  30483. return coordSysCreator.getDimensionsInfo ? coordSysCreator.getDimensionsInfo() : coordSysCreator.dimensions.slice();
  30484. }
  30485. }
  30486. function registerLayout(priority, layoutTask) {
  30487. normalizeRegister(visualFuncs, priority, layoutTask, PRIORITY_VISUAL_LAYOUT, 'layout');
  30488. }
  30489. function registerVisual(priority, visualTask) {
  30490. normalizeRegister(visualFuncs, priority, visualTask, PRIORITY_VISUAL_CHART, 'visual');
  30491. }
  30492. var registeredTasks = [];
  30493. function normalizeRegister(targetList, priority, fn, defaultPriority, visualType) {
  30494. if (isFunction(priority) || isObject(priority)) {
  30495. fn = priority;
  30496. priority = defaultPriority;
  30497. }
  30498. {
  30499. if (isNaN(priority) || priority == null) {
  30500. throw new Error('Illegal priority');
  30501. } // Check duplicate
  30502. each(targetList, function (wrap) {
  30503. assert(wrap.__raw !== fn);
  30504. });
  30505. } // Already registered
  30506. if (indexOf(registeredTasks, fn) >= 0) {
  30507. return;
  30508. }
  30509. registeredTasks.push(fn);
  30510. var stageHandler = Scheduler.wrapStageHandler(fn, visualType);
  30511. stageHandler.__prio = priority;
  30512. stageHandler.__raw = fn;
  30513. targetList.push(stageHandler);
  30514. }
  30515. function registerLoading(name, loadingFx) {
  30516. loadingEffects[name] = loadingFx;
  30517. }
  30518. /**
  30519. * ZRender need a canvas context to do measureText.
  30520. * But in node environment canvas may be created by node-canvas.
  30521. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  30522. *
  30523. * Be careful of using it in the browser.
  30524. *
  30525. * @example
  30526. * let Canvas = require('canvas');
  30527. * let echarts = require('echarts');
  30528. * echarts.setCanvasCreator(function () {
  30529. * // Small size is enough.
  30530. * return new Canvas(32, 32);
  30531. * });
  30532. */
  30533. function setCanvasCreator(creator) {
  30534. $override('createCanvas', creator);
  30535. }
  30536. /**
  30537. * The parameters and usage: see `geoSourceManager.registerMap`.
  30538. * Compatible with previous `echarts.registerMap`.
  30539. */
  30540. function registerMap(mapName, geoJson, specialAreas) {
  30541. geoSourceManager.registerMap(mapName, geoJson, specialAreas);
  30542. }
  30543. function getMap(mapName) {
  30544. return geoSourceManager.getMapForUser(mapName);
  30545. }
  30546. var registerTransform = registerExternalTransform;
  30547. /**
  30548. * Globa dispatchAction to a specified chart instance.
  30549. */
  30550. // export function dispatchAction(payload: { chartId: string } & Payload, opt?: Parameters<ECharts['dispatchAction']>[1]) {
  30551. // if (!payload || !payload.chartId) {
  30552. // // Must have chartId to find chart
  30553. // return;
  30554. // }
  30555. // const chart = instances[payload.chartId];
  30556. // if (chart) {
  30557. // chart.dispatchAction(payload, opt);
  30558. // }
  30559. // }
  30560. // Buitlin global visual
  30561. registerVisual(PRIORITY_VISUAL_GLOBAL, seriesStyleTask);
  30562. registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataStyleTask);
  30563. registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataColorPaletteTask);
  30564. registerVisual(PRIORITY_VISUAL_GLOBAL, seriesSymbolTask);
  30565. registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataSymbolTask);
  30566. registerVisual(PRIORITY_VISUAL_DECAL, decalVisual);
  30567. registerPreprocessor(globalBackwardCompat);
  30568. registerProcessor(PRIORITY_PROCESSOR_DATASTACK, dataStack);
  30569. registerLoading('default', defaultLoading); // Default actions
  30570. registerAction({
  30571. type: HIGHLIGHT_ACTION_TYPE,
  30572. event: HIGHLIGHT_ACTION_TYPE,
  30573. update: HIGHLIGHT_ACTION_TYPE
  30574. }, noop);
  30575. registerAction({
  30576. type: DOWNPLAY_ACTION_TYPE,
  30577. event: DOWNPLAY_ACTION_TYPE,
  30578. update: DOWNPLAY_ACTION_TYPE
  30579. }, noop);
  30580. registerAction({
  30581. type: SELECT_ACTION_TYPE,
  30582. event: SELECT_ACTION_TYPE,
  30583. update: SELECT_ACTION_TYPE
  30584. }, noop);
  30585. registerAction({
  30586. type: UNSELECT_ACTION_TYPE,
  30587. event: UNSELECT_ACTION_TYPE,
  30588. update: UNSELECT_ACTION_TYPE
  30589. }, noop);
  30590. registerAction({
  30591. type: TOGGLE_SELECT_ACTION_TYPE,
  30592. event: TOGGLE_SELECT_ACTION_TYPE,
  30593. update: TOGGLE_SELECT_ACTION_TYPE
  30594. }, noop); // Default theme
  30595. registerTheme('light', lightTheme);
  30596. registerTheme('dark', theme); // For backward compatibility, where the namespace `dataTool` will
  30597. // be mounted on `echarts` is the extension `dataTool` is imported.
  30598. var dataTool = {};
  30599. /*
  30600. * Licensed to the Apache Software Foundation (ASF) under one
  30601. * or more contributor license agreements. See the NOTICE file
  30602. * distributed with this work for additional information
  30603. * regarding copyright ownership. The ASF licenses this file
  30604. * to you under the Apache License, Version 2.0 (the
  30605. * "License"); you may not use this file except in compliance
  30606. * with the License. You may obtain a copy of the License at
  30607. *
  30608. * http://www.apache.org/licenses/LICENSE-2.0
  30609. *
  30610. * Unless required by applicable law or agreed to in writing,
  30611. * software distributed under the License is distributed on an
  30612. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30613. * KIND, either express or implied. See the License for the
  30614. * specific language governing permissions and limitations
  30615. * under the License.
  30616. */
  30617. /**
  30618. * AUTO-GENERATED FILE. DO NOT MODIFY.
  30619. */
  30620. /*
  30621. * Licensed to the Apache Software Foundation (ASF) under one
  30622. * or more contributor license agreements. See the NOTICE file
  30623. * distributed with this work for additional information
  30624. * regarding copyright ownership. The ASF licenses this file
  30625. * to you under the Apache License, Version 2.0 (the
  30626. * "License"); you may not use this file except in compliance
  30627. * with the License. You may obtain a copy of the License at
  30628. *
  30629. * http://www.apache.org/licenses/LICENSE-2.0
  30630. *
  30631. * Unless required by applicable law or agreed to in writing,
  30632. * software distributed under the License is distributed on an
  30633. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30634. * KIND, either express or implied. See the License for the
  30635. * specific language governing permissions and limitations
  30636. * under the License.
  30637. */
  30638. function dataIndexMapValueLength(valNumOrArrLengthMoreThan2) {
  30639. return valNumOrArrLengthMoreThan2 == null ? 0 : valNumOrArrLengthMoreThan2.length || 1;
  30640. }
  30641. function defaultKeyGetter(item) {
  30642. return item;
  30643. }
  30644. var DataDiffer =
  30645. /** @class */
  30646. function () {
  30647. /**
  30648. * @param context Can be visited by this.context in callback.
  30649. */
  30650. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter, context, // By default: 'oneToOne'.
  30651. diffMode) {
  30652. this._old = oldArr;
  30653. this._new = newArr;
  30654. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  30655. this._newKeyGetter = newKeyGetter || defaultKeyGetter; // Visible in callback via `this.context`;
  30656. this.context = context;
  30657. this._diffModeMultiple = diffMode === 'multiple';
  30658. }
  30659. /**
  30660. * Callback function when add a data
  30661. */
  30662. DataDiffer.prototype.add = function (func) {
  30663. this._add = func;
  30664. return this;
  30665. };
  30666. /**
  30667. * Callback function when update a data
  30668. */
  30669. DataDiffer.prototype.update = function (func) {
  30670. this._update = func;
  30671. return this;
  30672. };
  30673. /**
  30674. * Callback function when update a data and only work in `cbMode: 'byKey'`.
  30675. */
  30676. DataDiffer.prototype.updateManyToOne = function (func) {
  30677. this._updateManyToOne = func;
  30678. return this;
  30679. };
  30680. /**
  30681. * Callback function when update a data and only work in `cbMode: 'byKey'`.
  30682. */
  30683. DataDiffer.prototype.updateOneToMany = function (func) {
  30684. this._updateOneToMany = func;
  30685. return this;
  30686. };
  30687. /**
  30688. * Callback function when remove a data
  30689. */
  30690. DataDiffer.prototype.remove = function (func) {
  30691. this._remove = func;
  30692. return this;
  30693. };
  30694. DataDiffer.prototype.execute = function () {
  30695. this[this._diffModeMultiple ? '_executeMultiple' : '_executeOneToOne']();
  30696. };
  30697. DataDiffer.prototype._executeOneToOne = function () {
  30698. var oldArr = this._old;
  30699. var newArr = this._new;
  30700. var newDataIndexMap = {};
  30701. var oldDataKeyArr = new Array(oldArr.length);
  30702. var newDataKeyArr = new Array(newArr.length);
  30703. this._initIndexMap(oldArr, null, oldDataKeyArr, '_oldKeyGetter');
  30704. this._initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter');
  30705. for (var i = 0; i < oldArr.length; i++) {
  30706. var oldKey = oldDataKeyArr[i];
  30707. var newIdxMapVal = newDataIndexMap[oldKey];
  30708. var newIdxMapValLen = dataIndexMapValueLength(newIdxMapVal); // idx can never be empty array here. see 'set null' logic below.
  30709. if (newIdxMapValLen > 1) {
  30710. // Consider there is duplicate key (for example, use dataItem.name as key).
  30711. // We should make sure every item in newArr and oldArr can be visited.
  30712. var newIdx = newIdxMapVal.shift();
  30713. if (newIdxMapVal.length === 1) {
  30714. newDataIndexMap[oldKey] = newIdxMapVal[0];
  30715. }
  30716. this._update && this._update(newIdx, i);
  30717. } else if (newIdxMapValLen === 1) {
  30718. newDataIndexMap[oldKey] = null;
  30719. this._update && this._update(newIdxMapVal, i);
  30720. } else {
  30721. this._remove && this._remove(i);
  30722. }
  30723. }
  30724. this._performRestAdd(newDataKeyArr, newDataIndexMap);
  30725. };
  30726. /**
  30727. * For example, consider the case:
  30728. * oldData: [o0, o1, o2, o3, o4, o5, o6, o7],
  30729. * newData: [n0, n1, n2, n3, n4, n5, n6, n7, n8],
  30730. * Where:
  30731. * o0, o1, n0 has key 'a' (many to one)
  30732. * o5, n4, n5, n6 has key 'b' (one to many)
  30733. * o2, n1 has key 'c' (one to one)
  30734. * n2, n3 has key 'd' (add)
  30735. * o3, o4 has key 'e' (remove)
  30736. * o6, o7, n7, n8 has key 'f' (many to many, treated as add and remove)
  30737. * Then:
  30738. * (The order of the following directives are not ensured.)
  30739. * this._updateManyToOne(n0, [o0, o1]);
  30740. * this._updateOneToMany([n4, n5, n6], o5);
  30741. * this._update(n1, o2);
  30742. * this._remove(o3);
  30743. * this._remove(o4);
  30744. * this._remove(o6);
  30745. * this._remove(o7);
  30746. * this._add(n2);
  30747. * this._add(n3);
  30748. * this._add(n7);
  30749. * this._add(n8);
  30750. */
  30751. DataDiffer.prototype._executeMultiple = function () {
  30752. var oldArr = this._old;
  30753. var newArr = this._new;
  30754. var oldDataIndexMap = {};
  30755. var newDataIndexMap = {};
  30756. var oldDataKeyArr = [];
  30757. var newDataKeyArr = [];
  30758. this._initIndexMap(oldArr, oldDataIndexMap, oldDataKeyArr, '_oldKeyGetter');
  30759. this._initIndexMap(newArr, newDataIndexMap, newDataKeyArr, '_newKeyGetter');
  30760. for (var i = 0; i < oldDataKeyArr.length; i++) {
  30761. var oldKey = oldDataKeyArr[i];
  30762. var oldIdxMapVal = oldDataIndexMap[oldKey];
  30763. var newIdxMapVal = newDataIndexMap[oldKey];
  30764. var oldIdxMapValLen = dataIndexMapValueLength(oldIdxMapVal);
  30765. var newIdxMapValLen = dataIndexMapValueLength(newIdxMapVal);
  30766. if (oldIdxMapValLen > 1 && newIdxMapValLen === 1) {
  30767. this._updateManyToOne && this._updateManyToOne(newIdxMapVal, oldIdxMapVal);
  30768. newDataIndexMap[oldKey] = null;
  30769. } else if (oldIdxMapValLen === 1 && newIdxMapValLen > 1) {
  30770. this._updateOneToMany && this._updateOneToMany(newIdxMapVal, oldIdxMapVal);
  30771. newDataIndexMap[oldKey] = null;
  30772. } else if (oldIdxMapValLen === 1 && newIdxMapValLen === 1) {
  30773. this._update && this._update(newIdxMapVal, oldIdxMapVal);
  30774. newDataIndexMap[oldKey] = null;
  30775. } else if (oldIdxMapValLen > 1) {
  30776. for (var i_1 = 0; i_1 < oldIdxMapValLen; i_1++) {
  30777. this._remove && this._remove(oldIdxMapVal[i_1]);
  30778. }
  30779. } else {
  30780. this._remove && this._remove(oldIdxMapVal);
  30781. }
  30782. }
  30783. this._performRestAdd(newDataKeyArr, newDataIndexMap);
  30784. };
  30785. DataDiffer.prototype._performRestAdd = function (newDataKeyArr, newDataIndexMap) {
  30786. for (var i = 0; i < newDataKeyArr.length; i++) {
  30787. var newKey = newDataKeyArr[i];
  30788. var newIdxMapVal = newDataIndexMap[newKey];
  30789. var idxMapValLen = dataIndexMapValueLength(newIdxMapVal);
  30790. if (idxMapValLen > 1) {
  30791. for (var j = 0; j < idxMapValLen; j++) {
  30792. this._add && this._add(newIdxMapVal[j]);
  30793. }
  30794. } else if (idxMapValLen === 1) {
  30795. this._add && this._add(newIdxMapVal);
  30796. } // Support both `newDataKeyArr` are duplication removed or not removed.
  30797. newDataIndexMap[newKey] = null;
  30798. }
  30799. };
  30800. DataDiffer.prototype._initIndexMap = function (arr, // Can be null.
  30801. map, // In 'byKey', the output `keyArr` is duplication removed.
  30802. // In 'byIndex', the output `keyArr` is not duplication removed and
  30803. // its indices are accurately corresponding to `arr`.
  30804. keyArr, keyGetterName) {
  30805. var cbModeMultiple = this._diffModeMultiple;
  30806. for (var i = 0; i < arr.length; i++) {
  30807. // Add prefix to avoid conflict with Object.prototype.
  30808. var key = '_ec_' + this[keyGetterName](arr[i], i);
  30809. if (!cbModeMultiple) {
  30810. keyArr[i] = key;
  30811. }
  30812. if (!map) {
  30813. continue;
  30814. }
  30815. var idxMapVal = map[key];
  30816. var idxMapValLen = dataIndexMapValueLength(idxMapVal);
  30817. if (idxMapValLen === 0) {
  30818. // Simple optimize: in most cases, one index has one key,
  30819. // do not need array.
  30820. map[key] = i;
  30821. if (cbModeMultiple) {
  30822. keyArr.push(key);
  30823. }
  30824. } else if (idxMapValLen === 1) {
  30825. map[key] = [idxMapVal, i];
  30826. } else {
  30827. idxMapVal.push(i);
  30828. }
  30829. }
  30830. };
  30831. return DataDiffer;
  30832. }();
  30833. /*
  30834. * Licensed to the Apache Software Foundation (ASF) under one
  30835. * or more contributor license agreements. See the NOTICE file
  30836. * distributed with this work for additional information
  30837. * regarding copyright ownership. The ASF licenses this file
  30838. * to you under the Apache License, Version 2.0 (the
  30839. * "License"); you may not use this file except in compliance
  30840. * with the License. You may obtain a copy of the License at
  30841. *
  30842. * http://www.apache.org/licenses/LICENSE-2.0
  30843. *
  30844. * Unless required by applicable law or agreed to in writing,
  30845. * software distributed under the License is distributed on an
  30846. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30847. * KIND, either express or implied. See the License for the
  30848. * specific language governing permissions and limitations
  30849. * under the License.
  30850. */
  30851. /**
  30852. * AUTO-GENERATED FILE. DO NOT MODIFY.
  30853. */
  30854. /*
  30855. * Licensed to the Apache Software Foundation (ASF) under one
  30856. * or more contributor license agreements. See the NOTICE file
  30857. * distributed with this work for additional information
  30858. * regarding copyright ownership. The ASF licenses this file
  30859. * to you under the Apache License, Version 2.0 (the
  30860. * "License"); you may not use this file except in compliance
  30861. * with the License. You may obtain a copy of the License at
  30862. *
  30863. * http://www.apache.org/licenses/LICENSE-2.0
  30864. *
  30865. * Unless required by applicable law or agreed to in writing,
  30866. * software distributed under the License is distributed on an
  30867. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30868. * KIND, either express or implied. See the License for the
  30869. * specific language governing permissions and limitations
  30870. * under the License.
  30871. */
  30872. function summarizeDimensions(data) {
  30873. var summary = {};
  30874. var encode = summary.encode = {};
  30875. var notExtraCoordDimMap = createHashMap();
  30876. var defaultedLabel = [];
  30877. var defaultedTooltip = []; // See the comment of `List.js#userOutput`.
  30878. var userOutput = summary.userOutput = {
  30879. dimensionNames: data.dimensions.slice(),
  30880. encode: {}
  30881. };
  30882. each$1(data.dimensions, function (dimName) {
  30883. var dimItem = data.getDimensionInfo(dimName);
  30884. var coordDim = dimItem.coordDim;
  30885. if (coordDim) {
  30886. {
  30887. assert$1(VISUAL_DIMENSIONS.get(coordDim) == null);
  30888. }
  30889. var coordDimIndex = dimItem.coordDimIndex;
  30890. getOrCreateEncodeArr(encode, coordDim)[coordDimIndex] = dimName;
  30891. if (!dimItem.isExtraCoord) {
  30892. notExtraCoordDimMap.set(coordDim, 1); // Use the last coord dim (and label friendly) as default label,
  30893. // because when dataset is used, it is hard to guess which dimension
  30894. // can be value dimension. If both show x, y on label is not look good,
  30895. // and conventionally y axis is focused more.
  30896. if (mayLabelDimType(dimItem.type)) {
  30897. defaultedLabel[0] = dimName;
  30898. } // User output encode do not contain generated coords.
  30899. // And it only has index. User can use index to retrieve value from the raw item array.
  30900. getOrCreateEncodeArr(userOutput.encode, coordDim)[coordDimIndex] = dimItem.index;
  30901. }
  30902. if (dimItem.defaultTooltip) {
  30903. defaultedTooltip.push(dimName);
  30904. }
  30905. }
  30906. VISUAL_DIMENSIONS.each(function (v, otherDim) {
  30907. var encodeArr = getOrCreateEncodeArr(encode, otherDim);
  30908. var dimIndex = dimItem.otherDims[otherDim];
  30909. if (dimIndex != null && dimIndex !== false) {
  30910. encodeArr[dimIndex] = dimItem.name;
  30911. }
  30912. });
  30913. });
  30914. var dataDimsOnCoord = [];
  30915. var encodeFirstDimNotExtra = {};
  30916. notExtraCoordDimMap.each(function (v, coordDim) {
  30917. var dimArr = encode[coordDim];
  30918. encodeFirstDimNotExtra[coordDim] = dimArr[0]; // Not necessary to remove duplicate, because a data
  30919. // dim canot on more than one coordDim.
  30920. dataDimsOnCoord = dataDimsOnCoord.concat(dimArr);
  30921. });
  30922. summary.dataDimsOnCoord = dataDimsOnCoord;
  30923. summary.encodeFirstDimNotExtra = encodeFirstDimNotExtra;
  30924. var encodeLabel = encode.label; // FIXME `encode.label` is not recommanded, because formatter can not be set
  30925. // in this way. Use label.formatter instead. May be remove this approach someday.
  30926. if (encodeLabel && encodeLabel.length) {
  30927. defaultedLabel = encodeLabel.slice();
  30928. }
  30929. var encodeTooltip = encode.tooltip;
  30930. if (encodeTooltip && encodeTooltip.length) {
  30931. defaultedTooltip = encodeTooltip.slice();
  30932. } else if (!defaultedTooltip.length) {
  30933. defaultedTooltip = defaultedLabel.slice();
  30934. }
  30935. encode.defaultedLabel = defaultedLabel;
  30936. encode.defaultedTooltip = defaultedTooltip;
  30937. return summary;
  30938. }
  30939. function getOrCreateEncodeArr(encode, dim) {
  30940. if (!encode.hasOwnProperty(dim)) {
  30941. encode[dim] = [];
  30942. }
  30943. return encode[dim];
  30944. } // FIXME:TS should be type `AxisType`
  30945. function getDimensionTypeByAxis(axisType) {
  30946. return axisType === 'category' ? 'ordinal' : axisType === 'time' ? 'time' : 'float';
  30947. }
  30948. function mayLabelDimType(dimType) {
  30949. // In most cases, ordinal and time do not suitable for label.
  30950. // Ordinal info can be displayed on axis. Time is too long.
  30951. return !(dimType === 'ordinal' || dimType === 'time');
  30952. } // function findTheLastDimMayLabel(data) {
  30953. // // Get last value dim
  30954. // let dimensions = data.dimensions.slice();
  30955. // let valueType;
  30956. // let valueDim;
  30957. // while (dimensions.length && (
  30958. // valueDim = dimensions.pop(),
  30959. // valueType = data.getDimensionInfo(valueDim).type,
  30960. // valueType === 'ordinal' || valueType === 'time'
  30961. // )) {} // jshint ignore:line
  30962. // return valueDim;
  30963. // }
  30964. /*
  30965. * Licensed to the Apache Software Foundation (ASF) under one
  30966. * or more contributor license agreements. See the NOTICE file
  30967. * distributed with this work for additional information
  30968. * regarding copyright ownership. The ASF licenses this file
  30969. * to you under the Apache License, Version 2.0 (the
  30970. * "License"); you may not use this file except in compliance
  30971. * with the License. You may obtain a copy of the License at
  30972. *
  30973. * http://www.apache.org/licenses/LICENSE-2.0
  30974. *
  30975. * Unless required by applicable law or agreed to in writing,
  30976. * software distributed under the License is distributed on an
  30977. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30978. * KIND, either express or implied. See the License for the
  30979. * specific language governing permissions and limitations
  30980. * under the License.
  30981. */
  30982. /**
  30983. * AUTO-GENERATED FILE. DO NOT MODIFY.
  30984. */
  30985. /*
  30986. * Licensed to the Apache Software Foundation (ASF) under one
  30987. * or more contributor license agreements. See the NOTICE file
  30988. * distributed with this work for additional information
  30989. * regarding copyright ownership. The ASF licenses this file
  30990. * to you under the Apache License, Version 2.0 (the
  30991. * "License"); you may not use this file except in compliance
  30992. * with the License. You may obtain a copy of the License at
  30993. *
  30994. * http://www.apache.org/licenses/LICENSE-2.0
  30995. *
  30996. * Unless required by applicable law or agreed to in writing,
  30997. * software distributed under the License is distributed on an
  30998. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30999. * KIND, either express or implied. See the License for the
  31000. * specific language governing permissions and limitations
  31001. * under the License.
  31002. */
  31003. var DataDimensionInfo =
  31004. /** @class */
  31005. function () {
  31006. /**
  31007. * @param opt All of the fields will be shallow copied.
  31008. */
  31009. function DataDimensionInfo(opt) {
  31010. /**
  31011. * The format of `otherDims` is:
  31012. * ```js
  31013. * {
  31014. * tooltip: number optional,
  31015. * label: number optional,
  31016. * itemName: number optional,
  31017. * seriesName: number optional,
  31018. * }
  31019. * ```
  31020. *
  31021. * A `series.encode` can specified these fields:
  31022. * ```js
  31023. * encode: {
  31024. * // "3, 1, 5" is the index of data dimension.
  31025. * tooltip: [3, 1, 5],
  31026. * label: [0, 3],
  31027. * ...
  31028. * }
  31029. * ```
  31030. * `otherDims` is the parse result of the `series.encode` above, like:
  31031. * ```js
  31032. * // Suppose the index of this data dimension is `3`.
  31033. * this.otherDims = {
  31034. * // `3` is at the index `0` of the `encode.tooltip`
  31035. * tooltip: 0,
  31036. * // `3` is at the index `1` of the `encode.tooltip`
  31037. * label: 1
  31038. * };
  31039. * ```
  31040. *
  31041. * This prop should never be `null`/`undefined` after initialized.
  31042. */
  31043. this.otherDims = {};
  31044. if (opt != null) {
  31045. extend(this, opt);
  31046. }
  31047. }
  31048. return DataDimensionInfo;
  31049. }();
  31050. /*
  31051. * Licensed to the Apache Software Foundation (ASF) under one
  31052. * or more contributor license agreements. See the NOTICE file
  31053. * distributed with this work for additional information
  31054. * regarding copyright ownership. The ASF licenses this file
  31055. * to you under the Apache License, Version 2.0 (the
  31056. * "License"); you may not use this file except in compliance
  31057. * with the License. You may obtain a copy of the License at
  31058. *
  31059. * http://www.apache.org/licenses/LICENSE-2.0
  31060. *
  31061. * Unless required by applicable law or agreed to in writing,
  31062. * software distributed under the License is distributed on an
  31063. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  31064. * KIND, either express or implied. See the License for the
  31065. * specific language governing permissions and limitations
  31066. * under the License.
  31067. */
  31068. /**
  31069. * AUTO-GENERATED FILE. DO NOT MODIFY.
  31070. */
  31071. /*
  31072. * Licensed to the Apache Software Foundation (ASF) under one
  31073. * or more contributor license agreements. See the NOTICE file
  31074. * distributed with this work for additional information
  31075. * regarding copyright ownership. The ASF licenses this file
  31076. * to you under the Apache License, Version 2.0 (the
  31077. * "License"); you may not use this file except in compliance
  31078. * with the License. You may obtain a copy of the License at
  31079. *
  31080. * http://www.apache.org/licenses/LICENSE-2.0
  31081. *
  31082. * Unless required by applicable law or agreed to in writing,
  31083. * software distributed under the License is distributed on an
  31084. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  31085. * KIND, either express or implied. See the License for the
  31086. * specific language governing permissions and limitations
  31087. * under the License.
  31088. */
  31089. /* global Float64Array, Int32Array, Uint32Array, Uint16Array */
  31090. /**
  31091. * List for data storage
  31092. */
  31093. var mathFloor = Math.floor;
  31094. var isObject$3 = isObject$1;
  31095. var map$1 = map;
  31096. var UNDEFINED = 'undefined';
  31097. var INDEX_NOT_FOUND = -1; // Use prefix to avoid index to be the same as otherIdList[idx],
  31098. // which will cause weird udpate animation.
  31099. var ID_PREFIX = 'e\0\0';
  31100. var dataCtors = {
  31101. 'float': typeof Float64Array === UNDEFINED ? Array : Float64Array,
  31102. 'int': typeof Int32Array === UNDEFINED ? Array : Int32Array,
  31103. // Ordinal data type can be string or int
  31104. 'ordinal': Array,
  31105. 'number': Array,
  31106. 'time': Array
  31107. }; // Caution: MUST not use `new CtorUint32Array(arr, 0, len)`, because the Ctor of array is
  31108. // different from the Ctor of typed array.
  31109. var CtorUint32Array = typeof Uint32Array === UNDEFINED ? Array : Uint32Array;
  31110. var CtorInt32Array = typeof Int32Array === UNDEFINED ? Array : Int32Array;
  31111. var CtorUint16Array = typeof Uint16Array === UNDEFINED ? Array : Uint16Array;
  31112. var TRANSFERABLE_PROPERTIES = ['hasItemOption', '_nameList', '_idList', '_invertedIndicesMap', '_rawData', '_dimValueGetter', '_count', '_rawCount', '_nameDimIdx', '_idDimIdx', '_nameRepeatCount'];
  31113. var CLONE_PROPERTIES = ['_extent', '_approximateExtent', '_rawExtent']; // -----------------------------
  31114. // Internal method declarations:
  31115. // -----------------------------
  31116. var defaultDimValueGetters;
  31117. var prepareInvertedIndex;
  31118. var getIndicesCtor;
  31119. var prepareStorage;
  31120. var getRawIndexWithoutIndices;
  31121. var getRawIndexWithIndices;
  31122. var getId;
  31123. var getIdNameFromStore;
  31124. var makeIdFromName;
  31125. var normalizeDimensions;
  31126. var validateDimensions;
  31127. var cloneListForMapAndSample;
  31128. var getInitialExtent;
  31129. var setItemDataAndSeriesIndex;
  31130. var transferProperties;
  31131. var List =
  31132. /** @class */
  31133. function () {
  31134. /**
  31135. * @param dimensions
  31136. * For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
  31137. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  31138. */
  31139. function List(dimensions, hostModel) {
  31140. this.type = 'list';
  31141. this._count = 0;
  31142. this._rawCount = 0;
  31143. this._storage = {}; // We have an extra array store here. It's faster to be acessed than KV structured `_storage`.
  31144. // We profile the code `storage[dim]` and it seems to be KeyedLoadIC_Megamorphic instead of fast property access.
  31145. // Not sure why this happens. But using an extra array seems leads to faster `initData`
  31146. // See https://github.com/apache/incubator-echarts/pull/13314 for more explanation.
  31147. this._storageArr = [];
  31148. this._nameList = [];
  31149. this._idList = []; // Models of data option is stored sparse for optimizing memory cost
  31150. // Never used yet (not used yet).
  31151. // private _optionModels: Model[] = [];
  31152. // Global visual properties after visual coding
  31153. this._visual = {}; // Globel layout properties.
  31154. this._layout = {}; // Item visual properties after visual coding
  31155. this._itemVisuals = []; // Item layout properties after layout
  31156. this._itemLayouts = []; // Graphic elemnents
  31157. this._graphicEls = []; // Raw extent will not be cloned, but only transfered.
  31158. // It will not be calculated util needed.
  31159. this._rawExtent = {};
  31160. this._extent = {}; // key: dim, value: extent
  31161. this._approximateExtent = {};
  31162. this._calculationInfo = {}; // Having detected that there is data item is non primitive type
  31163. // (in type `OptionDataItemObject`).
  31164. // Like `data: [ { value: xx, itemStyle: {...} }, ...]`
  31165. // At present it only happen in `SOURCE_FORMAT_ORIGINAL`.
  31166. this.hasItemOption = true; // Methods that create a new list based on this list should be listed here.
  31167. // Notice that those method should `RETURN` the new list.
  31168. this.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'lttbDownSample', 'map']; // Methods that change indices of this list should be listed here.
  31169. this.CHANGABLE_METHODS = ['filterSelf', 'selectRange'];
  31170. this.DOWNSAMPLE_METHODS = ['downSample', 'lttbDownSample'];
  31171. /**
  31172. * Get raw data index.
  31173. * Do not initialize.
  31174. * Default `getRawIndex`. And it can be changed.
  31175. */
  31176. this.getRawIndex = getRawIndexWithoutIndices;
  31177. dimensions = dimensions || ['x', 'y'];
  31178. var dimensionInfos = {};
  31179. var dimensionNames = [];
  31180. var invertedIndicesMap = {};
  31181. for (var i = 0; i < dimensions.length; i++) {
  31182. // Use the original dimensions[i], where other flag props may exists.
  31183. var dimInfoInput = dimensions[i];
  31184. var dimensionInfo = isString(dimInfoInput) ? new DataDimensionInfo({
  31185. name: dimInfoInput
  31186. }) : !(dimInfoInput instanceof DataDimensionInfo) ? new DataDimensionInfo(dimInfoInput) : dimInfoInput;
  31187. var dimensionName = dimensionInfo.name;
  31188. dimensionInfo.type = dimensionInfo.type || 'float';
  31189. if (!dimensionInfo.coordDim) {
  31190. dimensionInfo.coordDim = dimensionName;
  31191. dimensionInfo.coordDimIndex = 0;
  31192. }
  31193. var otherDims = dimensionInfo.otherDims = dimensionInfo.otherDims || {};
  31194. dimensionNames.push(dimensionName);
  31195. dimensionInfos[dimensionName] = dimensionInfo;
  31196. dimensionInfo.index = i;
  31197. if (dimensionInfo.createInvertedIndices) {
  31198. invertedIndicesMap[dimensionName] = [];
  31199. }
  31200. if (otherDims.itemName === 0) {
  31201. this._nameDimIdx = i;
  31202. this._nameOrdinalMeta = dimensionInfo.ordinalMeta;
  31203. }
  31204. if (otherDims.itemId === 0) {
  31205. this._idDimIdx = i;
  31206. this._idOrdinalMeta = dimensionInfo.ordinalMeta;
  31207. }
  31208. }
  31209. this.dimensions = dimensionNames;
  31210. this._dimensionInfos = dimensionInfos;
  31211. this.hostModel = hostModel; // Cache summary info for fast visit. See "dimensionHelper".
  31212. this._dimensionsSummary = summarizeDimensions(this);
  31213. this._invertedIndicesMap = invertedIndicesMap;
  31214. this.userOutput = this._dimensionsSummary.userOutput;
  31215. }
  31216. /**
  31217. * The meanings of the input parameter `dim`:
  31218. *
  31219. * + If dim is a number (e.g., `1`), it means the index of the dimension.
  31220. * For example, `getDimension(0)` will return 'x' or 'lng' or 'radius'.
  31221. * + If dim is a number-like string (e.g., `"1"`):
  31222. * + If there is the same concrete dim name defined in `this.dimensions`, it means that concrete name.
  31223. * + If not, it will be converted to a number, which means the index of the dimension.
  31224. * (why? because of the backward compatbility. We have been tolerating number-like string in
  31225. * dimension setting, although now it seems that it is not a good idea.)
  31226. * For example, `visualMap[i].dimension: "1"` is the same meaning as `visualMap[i].dimension: 1`,
  31227. * if no dimension name is defined as `"1"`.
  31228. * + If dim is a not-number-like string, it means the concrete dim name.
  31229. * For example, it can be be default name `"x"`, `"y"`, `"z"`, `"lng"`, `"lat"`, `"angle"`, `"radius"`,
  31230. * or customized in `dimensions` property of option like `"age"`.
  31231. *
  31232. * Get dimension name
  31233. * @param dim See above.
  31234. * @return Concrete dim name.
  31235. */
  31236. List.prototype.getDimension = function (dim) {
  31237. if (typeof dim === 'number' // If being a number-like string but not being defined a dimension name.
  31238. || !isNaN(dim) && !this._dimensionInfos.hasOwnProperty(dim)) {
  31239. dim = this.dimensions[dim];
  31240. }
  31241. return dim;
  31242. };
  31243. /**
  31244. * Get type and calculation info of particular dimension
  31245. * @param dim
  31246. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  31247. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  31248. */
  31249. List.prototype.getDimensionInfo = function (dim) {
  31250. // Do not clone, because there may be categories in dimInfo.
  31251. return this._dimensionInfos[this.getDimension(dim)];
  31252. };
  31253. /**
  31254. * concrete dimension name list on coord.
  31255. */
  31256. List.prototype.getDimensionsOnCoord = function () {
  31257. return this._dimensionsSummary.dataDimsOnCoord.slice();
  31258. };
  31259. List.prototype.mapDimension = function (coordDim, idx) {
  31260. var dimensionsSummary = this._dimensionsSummary;
  31261. if (idx == null) {
  31262. return dimensionsSummary.encodeFirstDimNotExtra[coordDim];
  31263. }
  31264. var dims = dimensionsSummary.encode[coordDim];
  31265. return dims ? dims[idx] : null;
  31266. };
  31267. List.prototype.mapDimensionsAll = function (coordDim) {
  31268. var dimensionsSummary = this._dimensionsSummary;
  31269. var dims = dimensionsSummary.encode[coordDim];
  31270. return (dims || []).slice();
  31271. };
  31272. /**
  31273. * Initialize from data
  31274. * @param data source or data or data provider.
  31275. * @param nameList The name of a datum is used on data diff and
  31276. * default label/tooltip.
  31277. * A name can be specified in encode.itemName,
  31278. * or dataItem.name (only for series option data),
  31279. * or provided in nameList from outside.
  31280. */
  31281. List.prototype.initData = function (data, nameList, dimValueGetter) {
  31282. var notProvider = isSourceInstance(data) || isArrayLike(data);
  31283. var provider = notProvider ? new DefaultDataProvider(data, this.dimensions.length) : data;
  31284. {
  31285. assert$1(notProvider || isFunction$1(provider.getItem) && isFunction$1(provider.count), 'Inavlid data provider.');
  31286. }
  31287. this._rawData = provider;
  31288. var sourceFormat = provider.getSource().sourceFormat; // Clear
  31289. this._storage = {};
  31290. this._indices = null;
  31291. this._dontMakeIdFromName = this._idDimIdx != null || sourceFormat === SOURCE_FORMAT_TYPED_ARRAY // Cosndier performance.
  31292. || !!provider.fillStorage;
  31293. this._nameList = (nameList || []).slice();
  31294. this._idList = [];
  31295. this._nameRepeatCount = {};
  31296. if (!dimValueGetter) {
  31297. this.hasItemOption = false;
  31298. }
  31299. this.defaultDimValueGetter = defaultDimValueGetters[sourceFormat]; // Default dim value getter
  31300. this._dimValueGetter = dimValueGetter = dimValueGetter || this.defaultDimValueGetter;
  31301. this._dimValueGetterArrayRows = defaultDimValueGetters.arrayRows; // Reset raw extent.
  31302. this._rawExtent = {};
  31303. this._initDataFromProvider(0, provider.count()); // If data has no item option.
  31304. if (provider.pure) {
  31305. this.hasItemOption = false;
  31306. }
  31307. };
  31308. List.prototype.getProvider = function () {
  31309. return this._rawData;
  31310. };
  31311. /**
  31312. * Caution: Can be only called on raw data (before `this._indices` created).
  31313. */
  31314. List.prototype.appendData = function (data) {
  31315. {
  31316. assert$1(!this._indices, 'appendData can only be called on raw data.');
  31317. }
  31318. var rawData = this._rawData;
  31319. var start = this.count();
  31320. rawData.appendData(data);
  31321. var end = rawData.count();
  31322. if (!rawData.persistent) {
  31323. end += start;
  31324. }
  31325. this._initDataFromProvider(start, end, true);
  31326. };
  31327. /**
  31328. * Caution: Can be only called on raw data (before `this._indices` created).
  31329. * This method does not modify `rawData` (`dataProvider`), but only
  31330. * add values to storage.
  31331. *
  31332. * The final count will be increased by `Math.max(values.length, names.length)`.
  31333. *
  31334. * @param values That is the SourceType: 'arrayRows', like
  31335. * [
  31336. * [12, 33, 44],
  31337. * [NaN, 43, 1],
  31338. * ['-', 'asdf', 0]
  31339. * ]
  31340. * Each item is exaclty cooresponding to a dimension.
  31341. */
  31342. List.prototype.appendValues = function (values, names) {
  31343. var storage = this._storage;
  31344. var dimensions = this.dimensions;
  31345. var dimLen = dimensions.length;
  31346. var rawExtent = this._rawExtent;
  31347. var start = this.count();
  31348. var end = start + Math.max(values.length, names ? names.length : 0);
  31349. for (var i = 0; i < dimLen; i++) {
  31350. var dim = dimensions[i];
  31351. if (!rawExtent[dim]) {
  31352. rawExtent[dim] = getInitialExtent();
  31353. }
  31354. prepareStorage(storage, this._dimensionInfos[dim], end, true);
  31355. }
  31356. var rawExtentArr = map$1(dimensions, function (dim) {
  31357. return rawExtent[dim];
  31358. });
  31359. var storageArr = this._storageArr = map$1(dimensions, function (dim) {
  31360. return storage[dim];
  31361. });
  31362. var emptyDataItem = [];
  31363. for (var idx = start; idx < end; idx++) {
  31364. var sourceIdx = idx - start; // Store the data by dimensions
  31365. for (var dimIdx = 0; dimIdx < dimLen; dimIdx++) {
  31366. var dim = dimensions[dimIdx];
  31367. var val = this._dimValueGetterArrayRows(values[sourceIdx] || emptyDataItem, dim, sourceIdx, dimIdx);
  31368. storageArr[dimIdx][idx] = val;
  31369. var dimRawExtent = rawExtentArr[dimIdx];
  31370. val < dimRawExtent[0] && (dimRawExtent[0] = val);
  31371. val > dimRawExtent[1] && (dimRawExtent[1] = val);
  31372. }
  31373. if (names) {
  31374. this._nameList[idx] = names[sourceIdx];
  31375. if (!this._dontMakeIdFromName) {
  31376. makeIdFromName(this, idx);
  31377. }
  31378. }
  31379. }
  31380. this._rawCount = this._count = end; // Reset data extent
  31381. this._extent = {};
  31382. prepareInvertedIndex(this);
  31383. };
  31384. List.prototype._initDataFromProvider = function (start, end, append) {
  31385. if (start >= end) {
  31386. return;
  31387. }
  31388. var rawData = this._rawData;
  31389. var storage = this._storage;
  31390. var dimensions = this.dimensions;
  31391. var dimLen = dimensions.length;
  31392. var dimensionInfoMap = this._dimensionInfos;
  31393. var nameList = this._nameList;
  31394. var idList = this._idList;
  31395. var rawExtent = this._rawExtent;
  31396. var sourceFormat = rawData.getSource().sourceFormat;
  31397. var isFormatOriginal = sourceFormat === SOURCE_FORMAT_ORIGINAL;
  31398. for (var i = 0; i < dimLen; i++) {
  31399. var dim = dimensions[i];
  31400. if (!rawExtent[dim]) {
  31401. rawExtent[dim] = getInitialExtent();
  31402. }
  31403. prepareStorage(storage, dimensionInfoMap[dim], end, append);
  31404. }
  31405. var storageArr = this._storageArr = map$1(dimensions, function (dim) {
  31406. return storage[dim];
  31407. });
  31408. var rawExtentArr = map$1(dimensions, function (dim) {
  31409. return rawExtent[dim];
  31410. });
  31411. if (rawData.fillStorage) {
  31412. rawData.fillStorage(start, end, storageArr, rawExtentArr);
  31413. } else {
  31414. var dataItem = [];
  31415. for (var idx = start; idx < end; idx++) {
  31416. // NOTICE: Try not to write things into dataItem
  31417. dataItem = rawData.getItem(idx, dataItem); // Each data item is value
  31418. // [1, 2]
  31419. // 2
  31420. // Bar chart, line chart which uses category axis
  31421. // only gives the 'y' value. 'x' value is the indices of category
  31422. // Use a tempValue to normalize the value to be a (x, y) value
  31423. // Store the data by dimensions
  31424. for (var dimIdx = 0; dimIdx < dimLen; dimIdx++) {
  31425. var dim = dimensions[dimIdx];
  31426. var dimStorage = storageArr[dimIdx]; // PENDING NULL is empty or zero
  31427. var val = this._dimValueGetter(dataItem, dim, idx, dimIdx);
  31428. dimStorage[idx] = val;
  31429. var dimRawExtent = rawExtentArr[dimIdx];
  31430. val < dimRawExtent[0] && (dimRawExtent[0] = val);
  31431. val > dimRawExtent[1] && (dimRawExtent[1] = val);
  31432. } // If dataItem is {name: ...} or {id: ...}, it has highest priority.
  31433. // This kind of ids and names are always stored `_nameList` and `_idList`.
  31434. if (isFormatOriginal && !rawData.pure && dataItem) {
  31435. var itemName = dataItem.name;
  31436. if (nameList[idx] == null && itemName != null) {
  31437. nameList[idx] = convertOptionIdName(itemName, null);
  31438. }
  31439. var itemId = dataItem.id;
  31440. if (idList[idx] == null && itemId != null) {
  31441. idList[idx] = convertOptionIdName(itemId, null);
  31442. }
  31443. }
  31444. if (!this._dontMakeIdFromName) {
  31445. makeIdFromName(this, idx);
  31446. }
  31447. }
  31448. }
  31449. if (!rawData.persistent && rawData.clean) {
  31450. // Clean unused data if data source is typed array.
  31451. rawData.clean();
  31452. }
  31453. this._rawCount = this._count = end; // Reset data extent
  31454. this._extent = {};
  31455. prepareInvertedIndex(this);
  31456. };
  31457. List.prototype.count = function () {
  31458. return this._count;
  31459. };
  31460. List.prototype.getIndices = function () {
  31461. var newIndices;
  31462. var indices = this._indices;
  31463. if (indices) {
  31464. var Ctor = indices.constructor;
  31465. var thisCount = this._count; // `new Array(a, b, c)` is different from `new Uint32Array(a, b, c)`.
  31466. if (Ctor === Array) {
  31467. newIndices = new Ctor(thisCount);
  31468. for (var i = 0; i < thisCount; i++) {
  31469. newIndices[i] = indices[i];
  31470. }
  31471. } else {
  31472. newIndices = new Ctor(indices.buffer, 0, thisCount);
  31473. }
  31474. } else {
  31475. var Ctor = getIndicesCtor(this);
  31476. newIndices = new Ctor(this.count());
  31477. for (var i = 0; i < newIndices.length; i++) {
  31478. newIndices[i] = i;
  31479. }
  31480. }
  31481. return newIndices;
  31482. }; // Get data by index of dimension.
  31483. // Because in v8 access array by number variable is faster than access object by string variable
  31484. // Not sure why but the optimization just works.
  31485. List.prototype.getByDimIdx = function (dimIdx, idx) {
  31486. if (!(idx >= 0 && idx < this._count)) {
  31487. return NaN;
  31488. }
  31489. var dimStore = this._storageArr[dimIdx];
  31490. return dimStore ? dimStore[this.getRawIndex(idx)] : NaN;
  31491. };
  31492. /**
  31493. * Get value. Return NaN if idx is out of range.
  31494. * @param dim Dim must be concrete name.
  31495. */
  31496. List.prototype.get = function (dim, idx) {
  31497. if (!(idx >= 0 && idx < this._count)) {
  31498. return NaN;
  31499. }
  31500. var dimStore = this._storage[dim];
  31501. return dimStore ? dimStore[this.getRawIndex(idx)] : NaN;
  31502. };
  31503. /**
  31504. * @param dim concrete dim
  31505. */
  31506. List.prototype.getByRawIndex = function (dim, rawIdx) {
  31507. if (!(rawIdx >= 0 && rawIdx < this._rawCount)) {
  31508. return NaN;
  31509. }
  31510. var dimStore = this._storage[dim];
  31511. return dimStore ? dimStore[rawIdx] : NaN;
  31512. };
  31513. List.prototype.getValues = function (dimensions, idx) {
  31514. var values = [];
  31515. if (!isArray(dimensions)) {
  31516. // stack = idx;
  31517. idx = dimensions;
  31518. dimensions = this.dimensions;
  31519. }
  31520. for (var i = 0, len = dimensions.length; i < len; i++) {
  31521. values.push(this.get(dimensions[i], idx
  31522. /*, stack */
  31523. ));
  31524. }
  31525. return values;
  31526. };
  31527. /**
  31528. * If value is NaN. Inlcuding '-'
  31529. * Only check the coord dimensions.
  31530. */
  31531. List.prototype.hasValue = function (idx) {
  31532. var dataDimsOnCoord = this._dimensionsSummary.dataDimsOnCoord;
  31533. for (var i = 0, len = dataDimsOnCoord.length; i < len; i++) {
  31534. // Ordinal type originally can be string or number.
  31535. // But when an ordinal type is used on coord, it can
  31536. // not be string but only number. So we can also use isNaN.
  31537. if (isNaN(this.get(dataDimsOnCoord[i], idx))) {
  31538. return false;
  31539. }
  31540. }
  31541. return true;
  31542. };
  31543. /**
  31544. * Get extent of data in one dimension
  31545. */
  31546. List.prototype.getDataExtent = function (dim) {
  31547. // Make sure use concrete dim as cache name.
  31548. dim = this.getDimension(dim);
  31549. var dimData = this._storage[dim];
  31550. var initialExtent = getInitialExtent(); // stack = !!((stack || false) && this.getCalculationInfo(dim));
  31551. if (!dimData) {
  31552. return initialExtent;
  31553. } // Make more strict checkings to ensure hitting cache.
  31554. var currEnd = this.count(); // let cacheName = [dim, !!stack].join('_');
  31555. // let cacheName = dim;
  31556. // Consider the most cases when using data zoom, `getDataExtent`
  31557. // happened before filtering. We cache raw extent, which is not
  31558. // necessary to be cleared and recalculated when restore data.
  31559. var useRaw = !this._indices; // && !stack;
  31560. var dimExtent;
  31561. if (useRaw) {
  31562. return this._rawExtent[dim].slice();
  31563. }
  31564. dimExtent = this._extent[dim];
  31565. if (dimExtent) {
  31566. return dimExtent.slice();
  31567. }
  31568. dimExtent = initialExtent;
  31569. var min = dimExtent[0];
  31570. var max = dimExtent[1];
  31571. for (var i = 0; i < currEnd; i++) {
  31572. var rawIdx = this.getRawIndex(i);
  31573. var value = dimData[rawIdx];
  31574. value < min && (min = value);
  31575. value > max && (max = value);
  31576. }
  31577. dimExtent = [min, max];
  31578. this._extent[dim] = dimExtent;
  31579. return dimExtent;
  31580. };
  31581. /**
  31582. * PENDING: In fact currently this function is only used to short-circuit
  31583. * the calling of `scale.unionExtentFromData` when data have been filtered by modules
  31584. * like "dataZoom". `scale.unionExtentFromData` is used to calculate data extent for series on
  31585. * an axis, but if a "axis related data filter module" is used, the extent of the axis have
  31586. * been fixed and no need to calling `scale.unionExtentFromData` actually.
  31587. * But if we add "custom data filter" in future, which is not "axis related", this method may
  31588. * be still needed.
  31589. *
  31590. * Optimize for the scenario that data is filtered by a given extent.
  31591. * Consider that if data amount is more than hundreds of thousand,
  31592. * extent calculation will cost more than 10ms and the cache will
  31593. * be erased because of the filtering.
  31594. */
  31595. List.prototype.getApproximateExtent = function (dim) {
  31596. dim = this.getDimension(dim);
  31597. return this._approximateExtent[dim] || this.getDataExtent(dim);
  31598. };
  31599. /**
  31600. * Calculate extent on a filtered data might be time consuming.
  31601. * Approximate extent is only used for: calculte extent of filtered data outside.
  31602. */
  31603. List.prototype.setApproximateExtent = function (extent, dim) {
  31604. dim = this.getDimension(dim);
  31605. this._approximateExtent[dim] = extent.slice();
  31606. };
  31607. List.prototype.getCalculationInfo = function (key) {
  31608. return this._calculationInfo[key];
  31609. };
  31610. List.prototype.setCalculationInfo = function (key, value) {
  31611. isObject$3(key) ? extend(this._calculationInfo, key) : this._calculationInfo[key] = value;
  31612. };
  31613. /**
  31614. * Get sum of data in one dimension
  31615. */
  31616. List.prototype.getSum = function (dim) {
  31617. var dimData = this._storage[dim];
  31618. var sum = 0;
  31619. if (dimData) {
  31620. for (var i = 0, len = this.count(); i < len; i++) {
  31621. var value = this.get(dim, i);
  31622. if (!isNaN(value)) {
  31623. sum += value;
  31624. }
  31625. }
  31626. }
  31627. return sum;
  31628. };
  31629. /**
  31630. * Get median of data in one dimension
  31631. */
  31632. List.prototype.getMedian = function (dim) {
  31633. var dimDataArray = []; // map all data of one dimension
  31634. this.each(dim, function (val) {
  31635. if (!isNaN(val)) {
  31636. dimDataArray.push(val);
  31637. }
  31638. }); // TODO
  31639. // Use quick select?
  31640. var sortedDimDataArray = dimDataArray.sort(function (a, b) {
  31641. return a - b;
  31642. });
  31643. var len = this.count(); // calculate median
  31644. return len === 0 ? 0 : len % 2 === 1 ? sortedDimDataArray[(len - 1) / 2] : (sortedDimDataArray[len / 2] + sortedDimDataArray[len / 2 - 1]) / 2;
  31645. }; // /**
  31646. // * Retreive the index with given value
  31647. // * @param {string} dim Concrete dimension.
  31648. // * @param {number} value
  31649. // * @return {number}
  31650. // */
  31651. // Currently incorrect: should return dataIndex but not rawIndex.
  31652. // Do not fix it until this method is to be used somewhere.
  31653. // FIXME Precision of float value
  31654. // indexOf(dim, value) {
  31655. // let storage = this._storage;
  31656. // let dimData = storage[dim];
  31657. // let chunkSize = this._chunkSize;
  31658. // if (dimData) {
  31659. // for (let i = 0, len = this.count(); i < len; i++) {
  31660. // let chunkIndex = mathFloor(i / chunkSize);
  31661. // let chunkOffset = i % chunkSize;
  31662. // if (dimData[chunkIndex][chunkOffset] === value) {
  31663. // return i;
  31664. // }
  31665. // }
  31666. // }
  31667. // return -1;
  31668. // }
  31669. /**
  31670. * Only support the dimension which inverted index created.
  31671. * Do not support other cases until required.
  31672. * @param dim concrete dim
  31673. * @param value ordinal index
  31674. * @return rawIndex
  31675. */
  31676. List.prototype.rawIndexOf = function (dim, value) {
  31677. var invertedIndices = dim && this._invertedIndicesMap[dim];
  31678. {
  31679. if (!invertedIndices) {
  31680. throw new Error('Do not supported yet');
  31681. }
  31682. }
  31683. var rawIndex = invertedIndices[value];
  31684. if (rawIndex == null || isNaN(rawIndex)) {
  31685. return INDEX_NOT_FOUND;
  31686. }
  31687. return rawIndex;
  31688. };
  31689. /**
  31690. * Retreive the index with given name
  31691. */
  31692. List.prototype.indexOfName = function (name) {
  31693. for (var i = 0, len = this.count(); i < len; i++) {
  31694. if (this.getName(i) === name) {
  31695. return i;
  31696. }
  31697. }
  31698. return -1;
  31699. };
  31700. /**
  31701. * Retreive the index with given raw data index
  31702. */
  31703. List.prototype.indexOfRawIndex = function (rawIndex) {
  31704. if (rawIndex >= this._rawCount || rawIndex < 0) {
  31705. return -1;
  31706. }
  31707. if (!this._indices) {
  31708. return rawIndex;
  31709. } // Indices are ascending
  31710. var indices = this._indices; // If rawIndex === dataIndex
  31711. var rawDataIndex = indices[rawIndex];
  31712. if (rawDataIndex != null && rawDataIndex < this._count && rawDataIndex === rawIndex) {
  31713. return rawIndex;
  31714. }
  31715. var left = 0;
  31716. var right = this._count - 1;
  31717. while (left <= right) {
  31718. var mid = (left + right) / 2 | 0;
  31719. if (indices[mid] < rawIndex) {
  31720. left = mid + 1;
  31721. } else if (indices[mid] > rawIndex) {
  31722. right = mid - 1;
  31723. } else {
  31724. return mid;
  31725. }
  31726. }
  31727. return -1;
  31728. };
  31729. /**
  31730. * Retreive the index of nearest value
  31731. * @param dim
  31732. * @param value
  31733. * @param [maxDistance=Infinity]
  31734. * @return If and only if multiple indices has
  31735. * the same value, they are put to the result.
  31736. */
  31737. List.prototype.indicesOfNearest = function (dim, value, maxDistance) {
  31738. var storage = this._storage;
  31739. var dimData = storage[dim];
  31740. var nearestIndices = [];
  31741. if (!dimData) {
  31742. return nearestIndices;
  31743. }
  31744. if (maxDistance == null) {
  31745. maxDistance = Infinity;
  31746. }
  31747. var minDist = Infinity;
  31748. var minDiff = -1;
  31749. var nearestIndicesLen = 0; // Check the test case of `test/ut/spec/data/List.js`.
  31750. for (var i = 0, len = this.count(); i < len; i++) {
  31751. var dataIndex = this.getRawIndex(i);
  31752. var diff = value - dimData[dataIndex];
  31753. var dist = Math.abs(diff);
  31754. if (dist <= maxDistance) {
  31755. // When the `value` is at the middle of `this.get(dim, i)` and `this.get(dim, i+1)`,
  31756. // we'd better not push both of them to `nearestIndices`, otherwise it is easy to
  31757. // get more than one item in `nearestIndices` (more specifically, in `tooltip`).
  31758. // So we chose the one that `diff >= 0` in this csae.
  31759. // But if `this.get(dim, i)` and `this.get(dim, j)` get the same value, both of them
  31760. // should be push to `nearestIndices`.
  31761. if (dist < minDist || dist === minDist && diff >= 0 && minDiff < 0) {
  31762. minDist = dist;
  31763. minDiff = diff;
  31764. nearestIndicesLen = 0;
  31765. }
  31766. if (diff === minDiff) {
  31767. nearestIndices[nearestIndicesLen++] = i;
  31768. }
  31769. }
  31770. }
  31771. nearestIndices.length = nearestIndicesLen;
  31772. return nearestIndices;
  31773. };
  31774. /**
  31775. * Get raw data item
  31776. */
  31777. List.prototype.getRawDataItem = function (idx) {
  31778. if (!this._rawData.persistent) {
  31779. var val = [];
  31780. for (var i = 0; i < this.dimensions.length; i++) {
  31781. var dim = this.dimensions[i];
  31782. val.push(this.get(dim, idx));
  31783. }
  31784. return val;
  31785. } else {
  31786. return this._rawData.getItem(this.getRawIndex(idx));
  31787. }
  31788. };
  31789. /**
  31790. * @return Never be null/undefined. `number` will be converted to string. Becuase:
  31791. * In most cases, name is used in display, where returning a string is more convenient.
  31792. * In other cases, name is used in query (see `indexOfName`), where we can keep the
  31793. * rule that name `2` equals to name `'2'`.
  31794. */
  31795. List.prototype.getName = function (idx) {
  31796. var rawIndex = this.getRawIndex(idx);
  31797. var name = this._nameList[rawIndex];
  31798. if (name == null && this._nameDimIdx != null) {
  31799. name = getIdNameFromStore(this, this._nameDimIdx, this._nameOrdinalMeta, rawIndex);
  31800. }
  31801. if (name == null) {
  31802. name = '';
  31803. }
  31804. return name;
  31805. };
  31806. /**
  31807. * @return Never null/undefined. `number` will be converted to string. Becuase:
  31808. * In all cases having encountered at present, id is used in making diff comparison, which
  31809. * are usually based on hash map. We can keep the rule that the internal id are always string
  31810. * (treat `2` is the same as `'2'`) to make the related logic simple.
  31811. */
  31812. List.prototype.getId = function (idx) {
  31813. return getId(this, this.getRawIndex(idx));
  31814. };
  31815. List.prototype.each = function (dims, cb, ctx, ctxCompat) {
  31816. 'use strict';
  31817. var _this = this;
  31818. if (!this._count) {
  31819. return;
  31820. }
  31821. if (typeof dims === 'function') {
  31822. ctxCompat = ctx;
  31823. ctx = cb;
  31824. cb = dims;
  31825. dims = [];
  31826. } // ctxCompat just for compat echarts3
  31827. var fCtx = ctx || ctxCompat || this;
  31828. var dimNames = map$1(normalizeDimensions(dims), this.getDimension, this);
  31829. {
  31830. validateDimensions(this, dimNames);
  31831. }
  31832. var dimSize = dimNames.length;
  31833. var dimIndices = map$1(dimNames, function (dimName) {
  31834. return _this._dimensionInfos[dimName].index;
  31835. });
  31836. var storageArr = this._storageArr;
  31837. for (var i = 0, len = this.count(); i < len; i++) {
  31838. var rawIdx = this.getRawIndex(i); // Simple optimization
  31839. switch (dimSize) {
  31840. case 0:
  31841. cb.call(fCtx, i);
  31842. break;
  31843. case 1:
  31844. cb.call(fCtx, storageArr[dimIndices[0]][rawIdx], i);
  31845. break;
  31846. case 2:
  31847. cb.call(fCtx, storageArr[dimIndices[0]][rawIdx], storageArr[dimIndices[1]][rawIdx], i);
  31848. break;
  31849. default:
  31850. var k = 0;
  31851. var value = [];
  31852. for (; k < dimSize; k++) {
  31853. value[k] = storageArr[dimIndices[k]][rawIdx];
  31854. } // Index
  31855. value[k] = i;
  31856. cb.apply(fCtx, value);
  31857. }
  31858. }
  31859. };
  31860. List.prototype.filterSelf = function (dims, cb, ctx, ctxCompat) {
  31861. 'use strict';
  31862. var _this = this;
  31863. if (!this._count) {
  31864. return;
  31865. }
  31866. if (typeof dims === 'function') {
  31867. ctxCompat = ctx;
  31868. ctx = cb;
  31869. cb = dims;
  31870. dims = [];
  31871. } // ctxCompat just for compat echarts3
  31872. var fCtx = ctx || ctxCompat || this;
  31873. var dimNames = map$1(normalizeDimensions(dims), this.getDimension, this);
  31874. {
  31875. validateDimensions(this, dimNames);
  31876. }
  31877. var count = this.count();
  31878. var Ctor = getIndicesCtor(this);
  31879. var newIndices = new Ctor(count);
  31880. var value = [];
  31881. var dimSize = dimNames.length;
  31882. var offset = 0;
  31883. var dimIndices = map$1(dimNames, function (dimName) {
  31884. return _this._dimensionInfos[dimName].index;
  31885. });
  31886. var dim0 = dimIndices[0];
  31887. var storageArr = this._storageArr;
  31888. for (var i = 0; i < count; i++) {
  31889. var keep = void 0;
  31890. var rawIdx = this.getRawIndex(i); // Simple optimization
  31891. if (dimSize === 0) {
  31892. keep = cb.call(fCtx, i);
  31893. } else if (dimSize === 1) {
  31894. var val = storageArr[dim0][rawIdx];
  31895. keep = cb.call(fCtx, val, i);
  31896. } else {
  31897. var k = 0;
  31898. for (; k < dimSize; k++) {
  31899. value[k] = storageArr[dimIndices[k]][rawIdx];
  31900. }
  31901. value[k] = i;
  31902. keep = cb.apply(fCtx, value);
  31903. }
  31904. if (keep) {
  31905. newIndices[offset++] = rawIdx;
  31906. }
  31907. } // Set indices after filtered.
  31908. if (offset < count) {
  31909. this._indices = newIndices;
  31910. }
  31911. this._count = offset; // Reset data extent
  31912. this._extent = {};
  31913. this.getRawIndex = this._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;
  31914. return this;
  31915. };
  31916. /**
  31917. * Select data in range. (For optimization of filter)
  31918. * (Manually inline code, support 5 million data filtering in data zoom.)
  31919. */
  31920. List.prototype.selectRange = function (range) {
  31921. 'use strict';
  31922. var _this = this;
  31923. var len = this._count;
  31924. if (!len) {
  31925. return;
  31926. }
  31927. var dimensions = [];
  31928. for (var dim in range) {
  31929. if (range.hasOwnProperty(dim)) {
  31930. dimensions.push(dim);
  31931. }
  31932. }
  31933. {
  31934. validateDimensions(this, dimensions);
  31935. }
  31936. var dimSize = dimensions.length;
  31937. if (!dimSize) {
  31938. return;
  31939. }
  31940. var originalCount = this.count();
  31941. var Ctor = getIndicesCtor(this);
  31942. var newIndices = new Ctor(originalCount);
  31943. var offset = 0;
  31944. var dim0 = dimensions[0];
  31945. var dimIndices = map$1(dimensions, function (dimName) {
  31946. return _this._dimensionInfos[dimName].index;
  31947. });
  31948. var min = range[dim0][0];
  31949. var max = range[dim0][1];
  31950. var storageArr = this._storageArr;
  31951. var quickFinished = false;
  31952. if (!this._indices) {
  31953. // Extreme optimization for common case. About 2x faster in chrome.
  31954. var idx = 0;
  31955. if (dimSize === 1) {
  31956. var dimStorage = storageArr[dimIndices[0]];
  31957. for (var i = 0; i < len; i++) {
  31958. var val = dimStorage[i]; // NaN will not be filtered. Consider the case, in line chart, empty
  31959. // value indicates the line should be broken. But for the case like
  31960. // scatter plot, a data item with empty value will not be rendered,
  31961. // but the axis extent may be effected if some other dim of the data
  31962. // item has value. Fortunately it is not a significant negative effect.
  31963. if (val >= min && val <= max || isNaN(val)) {
  31964. newIndices[offset++] = idx;
  31965. }
  31966. idx++;
  31967. }
  31968. quickFinished = true;
  31969. } else if (dimSize === 2) {
  31970. var dimStorage = storageArr[dimIndices[0]];
  31971. var dimStorage2 = storageArr[dimIndices[1]];
  31972. var min2 = range[dimensions[1]][0];
  31973. var max2 = range[dimensions[1]][1];
  31974. for (var i = 0; i < len; i++) {
  31975. var val = dimStorage[i];
  31976. var val2 = dimStorage2[i]; // Do not filter NaN, see comment above.
  31977. if ((val >= min && val <= max || isNaN(val)) && (val2 >= min2 && val2 <= max2 || isNaN(val2))) {
  31978. newIndices[offset++] = idx;
  31979. }
  31980. idx++;
  31981. }
  31982. quickFinished = true;
  31983. }
  31984. }
  31985. if (!quickFinished) {
  31986. if (dimSize === 1) {
  31987. for (var i = 0; i < originalCount; i++) {
  31988. var rawIndex = this.getRawIndex(i);
  31989. var val = storageArr[dimIndices[0]][rawIndex]; // Do not filter NaN, see comment above.
  31990. if (val >= min && val <= max || isNaN(val)) {
  31991. newIndices[offset++] = rawIndex;
  31992. }
  31993. }
  31994. } else {
  31995. for (var i = 0; i < originalCount; i++) {
  31996. var keep = true;
  31997. var rawIndex = this.getRawIndex(i);
  31998. for (var k = 0; k < dimSize; k++) {
  31999. var dimk = dimensions[k];
  32000. var val = storageArr[dimIndices[k]][rawIndex]; // Do not filter NaN, see comment above.
  32001. if (val < range[dimk][0] || val > range[dimk][1]) {
  32002. keep = false;
  32003. }
  32004. }
  32005. if (keep) {
  32006. newIndices[offset++] = this.getRawIndex(i);
  32007. }
  32008. }
  32009. }
  32010. } // Set indices after filtered.
  32011. if (offset < originalCount) {
  32012. this._indices = newIndices;
  32013. }
  32014. this._count = offset; // Reset data extent
  32015. this._extent = {};
  32016. this.getRawIndex = this._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;
  32017. return this;
  32018. };
  32019. /* eslint-enable */
  32020. List.prototype.mapArray = function (dims, cb, ctx, ctxCompat) {
  32021. 'use strict';
  32022. if (typeof dims === 'function') {
  32023. ctxCompat = ctx;
  32024. ctx = cb;
  32025. cb = dims;
  32026. dims = [];
  32027. } // ctxCompat just for compat echarts3
  32028. ctx = ctx || ctxCompat || this;
  32029. var result = [];
  32030. this.each(dims, function () {
  32031. result.push(cb && cb.apply(this, arguments));
  32032. }, ctx);
  32033. return result;
  32034. };
  32035. List.prototype.map = function (dims, cb, ctx, ctxCompat) {
  32036. 'use strict'; // ctxCompat just for compat echarts3
  32037. var fCtx = ctx || ctxCompat || this;
  32038. var dimNames = map$1(normalizeDimensions(dims), this.getDimension, this);
  32039. {
  32040. validateDimensions(this, dimNames);
  32041. }
  32042. var list = cloneListForMapAndSample(this, dimNames);
  32043. var storage = list._storage; // Following properties are all immutable.
  32044. // So we can reference to the same value
  32045. list._indices = this._indices;
  32046. list.getRawIndex = list._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;
  32047. var tmpRetValue = [];
  32048. var dimSize = dimNames.length;
  32049. var dataCount = this.count();
  32050. var values = [];
  32051. var rawExtent = list._rawExtent;
  32052. for (var dataIndex = 0; dataIndex < dataCount; dataIndex++) {
  32053. for (var dimIndex = 0; dimIndex < dimSize; dimIndex++) {
  32054. values[dimIndex] = this.get(dimNames[dimIndex], dataIndex);
  32055. }
  32056. values[dimSize] = dataIndex;
  32057. var retValue = cb && cb.apply(fCtx, values);
  32058. if (retValue != null) {
  32059. // a number or string (in oridinal dimension)?
  32060. if (typeof retValue !== 'object') {
  32061. tmpRetValue[0] = retValue;
  32062. retValue = tmpRetValue;
  32063. }
  32064. var rawIndex = this.getRawIndex(dataIndex);
  32065. for (var i = 0; i < retValue.length; i++) {
  32066. var dim = dimNames[i];
  32067. var val = retValue[i];
  32068. var rawExtentOnDim = rawExtent[dim];
  32069. var dimStore = storage[dim];
  32070. if (dimStore) {
  32071. dimStore[rawIndex] = val;
  32072. }
  32073. if (val < rawExtentOnDim[0]) {
  32074. rawExtentOnDim[0] = val;
  32075. }
  32076. if (val > rawExtentOnDim[1]) {
  32077. rawExtentOnDim[1] = val;
  32078. }
  32079. }
  32080. }
  32081. }
  32082. return list;
  32083. };
  32084. /**
  32085. * Large data down sampling on given dimension
  32086. * @param sampleIndex Sample index for name and id
  32087. */
  32088. List.prototype.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  32089. var list = cloneListForMapAndSample(this, [dimension]);
  32090. var targetStorage = list._storage;
  32091. var frameValues = [];
  32092. var frameSize = mathFloor(1 / rate);
  32093. var dimStore = targetStorage[dimension];
  32094. var len = this.count();
  32095. var rawExtentOnDim = list._rawExtent[dimension];
  32096. var newIndices = new (getIndicesCtor(this))(len);
  32097. var offset = 0;
  32098. for (var i = 0; i < len; i += frameSize) {
  32099. // Last frame
  32100. if (frameSize > len - i) {
  32101. frameSize = len - i;
  32102. frameValues.length = frameSize;
  32103. }
  32104. for (var k = 0; k < frameSize; k++) {
  32105. var dataIdx = this.getRawIndex(i + k);
  32106. frameValues[k] = dimStore[dataIdx];
  32107. }
  32108. var value = sampleValue(frameValues);
  32109. var sampleFrameIdx = this.getRawIndex(Math.min(i + sampleIndex(frameValues, value) || 0, len - 1)); // Only write value on the filtered data
  32110. dimStore[sampleFrameIdx] = value;
  32111. if (value < rawExtentOnDim[0]) {
  32112. rawExtentOnDim[0] = value;
  32113. }
  32114. if (value > rawExtentOnDim[1]) {
  32115. rawExtentOnDim[1] = value;
  32116. }
  32117. newIndices[offset++] = sampleFrameIdx;
  32118. }
  32119. list._count = offset;
  32120. list._indices = newIndices;
  32121. list.getRawIndex = getRawIndexWithIndices;
  32122. return list;
  32123. };
  32124. /**
  32125. * Large data down sampling using largest-triangle-three-buckets
  32126. * @param {string} valueDimension
  32127. * @param {number} targetCount
  32128. */
  32129. List.prototype.lttbDownSample = function (valueDimension, rate) {
  32130. var list = cloneListForMapAndSample(this, []);
  32131. var targetStorage = list._storage;
  32132. var dimStore = targetStorage[valueDimension];
  32133. var len = this.count();
  32134. var newIndices = new (getIndicesCtor(this))(len);
  32135. var sampledIndex = 0;
  32136. var frameSize = mathFloor(1 / rate);
  32137. var currentRawIndex = this.getRawIndex(0);
  32138. var maxArea;
  32139. var area;
  32140. var nextRawIndex; // First frame use the first data.
  32141. newIndices[sampledIndex++] = currentRawIndex;
  32142. for (var i = 1; i < len - 1; i += frameSize) {
  32143. var nextFrameStart = Math.min(i + frameSize, len - 1);
  32144. var nextFrameEnd = Math.min(i + frameSize * 2, len);
  32145. var avgX = (nextFrameEnd + nextFrameStart) / 2;
  32146. var avgY = 0;
  32147. for (var idx = nextFrameStart; idx < nextFrameEnd; idx++) {
  32148. var rawIndex = this.getRawIndex(idx);
  32149. var y = dimStore[rawIndex];
  32150. if (isNaN(y)) {
  32151. continue;
  32152. }
  32153. avgY += y;
  32154. }
  32155. avgY /= nextFrameEnd - nextFrameStart;
  32156. var frameStart = i;
  32157. var frameEnd = Math.min(i + frameSize, len);
  32158. var pointAX = i - 1;
  32159. var pointAY = dimStore[currentRawIndex];
  32160. maxArea = -1;
  32161. nextRawIndex = frameStart; // Find a point from current frame that construct a triangel with largest area with previous selected point
  32162. // And the average of next frame.
  32163. for (var idx = frameStart; idx < frameEnd; idx++) {
  32164. var rawIndex = this.getRawIndex(idx);
  32165. var y = dimStore[rawIndex];
  32166. if (isNaN(y)) {
  32167. continue;
  32168. } // Calculate triangle area over three buckets
  32169. area = Math.abs((pointAX - avgX) * (y - pointAY) - (pointAX - idx) * (avgY - pointAY));
  32170. if (area > maxArea) {
  32171. maxArea = area;
  32172. nextRawIndex = rawIndex; // Next a is this b
  32173. }
  32174. }
  32175. newIndices[sampledIndex++] = nextRawIndex;
  32176. currentRawIndex = nextRawIndex; // This a is the next a (chosen b)
  32177. } // First frame use the last data.
  32178. newIndices[sampledIndex++] = this.getRawIndex(len - 1);
  32179. list._count = sampledIndex;
  32180. list._indices = newIndices;
  32181. list.getRawIndex = getRawIndexWithIndices;
  32182. return list;
  32183. };
  32184. /**
  32185. * Get model of one data item.
  32186. */
  32187. // TODO: Type of data item
  32188. List.prototype.getItemModel = function (idx) {
  32189. var hostModel = this.hostModel;
  32190. var dataItem = this.getRawDataItem(idx);
  32191. return new Model(dataItem, hostModel, hostModel && hostModel.ecModel);
  32192. };
  32193. /**
  32194. * Create a data differ
  32195. */
  32196. List.prototype.diff = function (otherList) {
  32197. var thisList = this;
  32198. return new DataDiffer(otherList ? otherList.getIndices() : [], this.getIndices(), function (idx) {
  32199. return getId(otherList, idx);
  32200. }, function (idx) {
  32201. return getId(thisList, idx);
  32202. });
  32203. };
  32204. /**
  32205. * Get visual property.
  32206. */
  32207. List.prototype.getVisual = function (key) {
  32208. var visual = this._visual;
  32209. return visual && visual[key];
  32210. };
  32211. List.prototype.setVisual = function (kvObj, val) {
  32212. this._visual = this._visual || {};
  32213. if (isObject$3(kvObj)) {
  32214. extend(this._visual, kvObj);
  32215. } else {
  32216. this._visual[kvObj] = val;
  32217. }
  32218. };
  32219. /**
  32220. * Get visual property of single data item
  32221. */
  32222. // eslint-disable-next-line
  32223. List.prototype.getItemVisual = function (idx, key) {
  32224. var itemVisual = this._itemVisuals[idx];
  32225. var val = itemVisual && itemVisual[key];
  32226. if (val == null) {
  32227. // Use global visual property
  32228. return this.getVisual(key);
  32229. }
  32230. return val;
  32231. };
  32232. /**
  32233. * If exists visual property of single data item
  32234. */
  32235. List.prototype.hasItemVisual = function () {
  32236. return this._itemVisuals.length > 0;
  32237. };
  32238. /**
  32239. * Make sure itemVisual property is unique
  32240. */
  32241. // TODO: use key to save visual to reduce memory.
  32242. List.prototype.ensureUniqueItemVisual = function (idx, key) {
  32243. var itemVisuals = this._itemVisuals;
  32244. var itemVisual = itemVisuals[idx];
  32245. if (!itemVisual) {
  32246. itemVisual = itemVisuals[idx] = {};
  32247. }
  32248. var val = itemVisual[key];
  32249. if (val == null) {
  32250. val = this.getVisual(key); // TODO Performance?
  32251. if (isArray(val)) {
  32252. val = val.slice();
  32253. } else if (isObject$3(val)) {
  32254. val = extend({}, val);
  32255. }
  32256. itemVisual[key] = val;
  32257. }
  32258. return val;
  32259. }; // eslint-disable-next-line
  32260. List.prototype.setItemVisual = function (idx, key, value) {
  32261. var itemVisual = this._itemVisuals[idx] || {};
  32262. this._itemVisuals[idx] = itemVisual;
  32263. if (isObject$3(key)) {
  32264. extend(itemVisual, key);
  32265. } else {
  32266. itemVisual[key] = value;
  32267. }
  32268. };
  32269. /**
  32270. * Clear itemVisuals and list visual.
  32271. */
  32272. List.prototype.clearAllVisual = function () {
  32273. this._visual = {};
  32274. this._itemVisuals = [];
  32275. };
  32276. List.prototype.setLayout = function (key, val) {
  32277. if (isObject$3(key)) {
  32278. for (var name_1 in key) {
  32279. if (key.hasOwnProperty(name_1)) {
  32280. this.setLayout(name_1, key[name_1]);
  32281. }
  32282. }
  32283. return;
  32284. }
  32285. this._layout[key] = val;
  32286. };
  32287. /**
  32288. * Get layout property.
  32289. */
  32290. List.prototype.getLayout = function (key) {
  32291. return this._layout[key];
  32292. };
  32293. /**
  32294. * Get layout of single data item
  32295. */
  32296. List.prototype.getItemLayout = function (idx) {
  32297. return this._itemLayouts[idx];
  32298. };
  32299. /**
  32300. * Set layout of single data item
  32301. */
  32302. List.prototype.setItemLayout = function (idx, layout, merge$$1) {
  32303. this._itemLayouts[idx] = merge$$1 ? extend(this._itemLayouts[idx] || {}, layout) : layout;
  32304. };
  32305. /**
  32306. * Clear all layout of single data item
  32307. */
  32308. List.prototype.clearItemLayouts = function () {
  32309. this._itemLayouts.length = 0;
  32310. };
  32311. /**
  32312. * Set graphic element relative to data. It can be set as null
  32313. */
  32314. List.prototype.setItemGraphicEl = function (idx, el) {
  32315. var hostModel = this.hostModel;
  32316. if (el) {
  32317. var ecData = getECData(el); // Add data index and series index for indexing the data by element
  32318. // Useful in tooltip
  32319. ecData.dataIndex = idx;
  32320. ecData.dataType = this.dataType;
  32321. ecData.seriesIndex = hostModel && hostModel.seriesIndex; // TODO: not store dataIndex on children.
  32322. if (el.type === 'group') {
  32323. el.traverse(setItemDataAndSeriesIndex, el);
  32324. }
  32325. }
  32326. this._graphicEls[idx] = el;
  32327. };
  32328. List.prototype.getItemGraphicEl = function (idx) {
  32329. return this._graphicEls[idx];
  32330. };
  32331. List.prototype.eachItemGraphicEl = function (cb, context) {
  32332. each$1(this._graphicEls, function (el, idx) {
  32333. if (el) {
  32334. cb && cb.call(context, el, idx);
  32335. }
  32336. });
  32337. };
  32338. /**
  32339. * Shallow clone a new list except visual and layout properties, and graph elements.
  32340. * New list only change the indices.
  32341. */
  32342. List.prototype.cloneShallow = function (list) {
  32343. if (!list) {
  32344. var dimensionInfoList = map$1(this.dimensions, this.getDimensionInfo, this);
  32345. list = new List(dimensionInfoList, this.hostModel);
  32346. } // FIXME
  32347. list._storage = this._storage;
  32348. list._storageArr = this._storageArr;
  32349. transferProperties(list, this); // Clone will not change the data extent and indices
  32350. if (this._indices) {
  32351. var Ctor = this._indices.constructor;
  32352. if (Ctor === Array) {
  32353. var thisCount = this._indices.length;
  32354. list._indices = new Ctor(thisCount);
  32355. for (var i = 0; i < thisCount; i++) {
  32356. list._indices[i] = this._indices[i];
  32357. }
  32358. } else {
  32359. list._indices = new Ctor(this._indices);
  32360. }
  32361. } else {
  32362. list._indices = null;
  32363. }
  32364. list.getRawIndex = list._indices ? getRawIndexWithIndices : getRawIndexWithoutIndices;
  32365. return list;
  32366. };
  32367. /**
  32368. * Wrap some method to add more feature
  32369. */
  32370. List.prototype.wrapMethod = function (methodName, injectFunction) {
  32371. var originalMethod = this[methodName];
  32372. if (typeof originalMethod !== 'function') {
  32373. return;
  32374. }
  32375. this.__wrappedMethods = this.__wrappedMethods || [];
  32376. this.__wrappedMethods.push(methodName);
  32377. this[methodName] = function () {
  32378. var res = originalMethod.apply(this, arguments);
  32379. return injectFunction.apply(this, [res].concat(slice(arguments)));
  32380. };
  32381. }; // ----------------------------------------------------------
  32382. // A work around for internal method visiting private member.
  32383. // ----------------------------------------------------------
  32384. List.internalField = function () {
  32385. defaultDimValueGetters = {
  32386. arrayRows: getDimValueSimply,
  32387. objectRows: function (dataItem, dimName, dataIndex, dimIndex) {
  32388. return parseDataValue(dataItem[dimName], this._dimensionInfos[dimName]);
  32389. },
  32390. keyedColumns: getDimValueSimply,
  32391. original: function (dataItem, dimName, dataIndex, dimIndex) {
  32392. // Performance sensitive, do not use modelUtil.getDataItemValue.
  32393. // If dataItem is an plain object with no value field, the let `value`
  32394. // will be assigned with the object, but it will be tread correctly
  32395. // in the `convertValue`.
  32396. var value = dataItem && (dataItem.value == null ? dataItem : dataItem.value); // If any dataItem is like { value: 10 }
  32397. if (!this._rawData.pure && isDataItemOption(dataItem)) {
  32398. this.hasItemOption = true;
  32399. }
  32400. return parseDataValue(value instanceof Array ? value[dimIndex] // If value is a single number or something else not array.
  32401. : value, this._dimensionInfos[dimName]);
  32402. },
  32403. typedArray: function (dataItem, dimName, dataIndex, dimIndex) {
  32404. return dataItem[dimIndex];
  32405. }
  32406. };
  32407. function getDimValueSimply(dataItem, dimName, dataIndex, dimIndex) {
  32408. return parseDataValue(dataItem[dimIndex], this._dimensionInfos[dimName]);
  32409. }
  32410. prepareInvertedIndex = function (list) {
  32411. var invertedIndicesMap = list._invertedIndicesMap;
  32412. each$1(invertedIndicesMap, function (invertedIndices, dim) {
  32413. var dimInfo = list._dimensionInfos[dim]; // Currently, only dimensions that has ordinalMeta can create inverted indices.
  32414. var ordinalMeta = dimInfo.ordinalMeta;
  32415. if (ordinalMeta) {
  32416. invertedIndices = invertedIndicesMap[dim] = new CtorInt32Array(ordinalMeta.categories.length); // The default value of TypedArray is 0. To avoid miss
  32417. // mapping to 0, we should set it as INDEX_NOT_FOUND.
  32418. for (var i = 0; i < invertedIndices.length; i++) {
  32419. invertedIndices[i] = INDEX_NOT_FOUND;
  32420. }
  32421. for (var i = 0; i < list._count; i++) {
  32422. // Only support the case that all values are distinct.
  32423. invertedIndices[list.get(dim, i)] = i;
  32424. }
  32425. }
  32426. });
  32427. };
  32428. getIdNameFromStore = function (list, dimIdx, ordinalMeta, rawIndex) {
  32429. var val;
  32430. var chunk = list._storageArr[dimIdx];
  32431. if (chunk) {
  32432. val = chunk[rawIndex];
  32433. if (ordinalMeta && ordinalMeta.categories.length) {
  32434. val = ordinalMeta.categories[val];
  32435. }
  32436. }
  32437. return convertOptionIdName(val, null);
  32438. };
  32439. getIndicesCtor = function (list) {
  32440. // The possible max value in this._indicies is always this._rawCount despite of filtering.
  32441. return list._rawCount > 65535 ? CtorUint32Array : CtorUint16Array;
  32442. };
  32443. prepareStorage = function (storage, dimInfo, end, append) {
  32444. var DataCtor = dataCtors[dimInfo.type];
  32445. var dim = dimInfo.name;
  32446. if (append) {
  32447. var oldStore = storage[dim];
  32448. var oldLen = oldStore && oldStore.length;
  32449. if (!(oldLen === end)) {
  32450. var newStore = new DataCtor(end); // The cost of the copy is probably inconsiderable
  32451. // within the initial chunkSize.
  32452. for (var j = 0; j < oldLen; j++) {
  32453. newStore[j] = oldStore[j];
  32454. }
  32455. storage[dim] = newStore;
  32456. }
  32457. } else {
  32458. storage[dim] = new DataCtor(end);
  32459. }
  32460. };
  32461. getRawIndexWithoutIndices = function (idx) {
  32462. return idx;
  32463. };
  32464. getRawIndexWithIndices = function (idx) {
  32465. if (idx < this._count && idx >= 0) {
  32466. return this._indices[idx];
  32467. }
  32468. return -1;
  32469. };
  32470. /**
  32471. * @see the comment of `List['getId']`.
  32472. */
  32473. getId = function (list, rawIndex) {
  32474. var id = list._idList[rawIndex];
  32475. if (id == null && list._idDimIdx != null) {
  32476. id = getIdNameFromStore(list, list._idDimIdx, list._idOrdinalMeta, rawIndex);
  32477. }
  32478. if (id == null) {
  32479. id = ID_PREFIX + rawIndex;
  32480. }
  32481. return id;
  32482. };
  32483. normalizeDimensions = function (dimensions) {
  32484. if (!isArray(dimensions)) {
  32485. dimensions = dimensions != null ? [dimensions] : [];
  32486. }
  32487. return dimensions;
  32488. };
  32489. validateDimensions = function (list, dims) {
  32490. for (var i = 0; i < dims.length; i++) {
  32491. // stroage may be empty when no data, so use
  32492. // dimensionInfos to check.
  32493. if (!list._dimensionInfos[dims[i]]) {
  32494. console.error('Unkown dimension ' + dims[i]);
  32495. }
  32496. }
  32497. }; // Data in excludeDimensions is copied, otherwise transfered.
  32498. cloneListForMapAndSample = function (original, excludeDimensions) {
  32499. var allDimensions = original.dimensions;
  32500. var list = new List(map$1(allDimensions, original.getDimensionInfo, original), original.hostModel); // FIXME If needs stackedOn, value may already been stacked
  32501. transferProperties(list, original);
  32502. var storage = list._storage = {};
  32503. var originalStorage = original._storage;
  32504. var storageArr = list._storageArr = []; // Init storage
  32505. for (var i = 0; i < allDimensions.length; i++) {
  32506. var dim = allDimensions[i];
  32507. if (originalStorage[dim]) {
  32508. // Notice that we do not reset invertedIndicesMap here, becuase
  32509. // there is no scenario of mapping or sampling ordinal dimension.
  32510. if (indexOf$1(excludeDimensions, dim) >= 0) {
  32511. storage[dim] = cloneChunk(originalStorage[dim]);
  32512. list._rawExtent[dim] = getInitialExtent();
  32513. list._extent[dim] = null;
  32514. } else {
  32515. // Direct reference for other dimensions
  32516. storage[dim] = originalStorage[dim];
  32517. }
  32518. storageArr.push(storage[dim]);
  32519. }
  32520. }
  32521. return list;
  32522. };
  32523. function cloneChunk(originalChunk) {
  32524. var Ctor = originalChunk.constructor; // Only shallow clone is enough when Array.
  32525. return Ctor === Array ? originalChunk.slice() : new Ctor(originalChunk);
  32526. }
  32527. getInitialExtent = function () {
  32528. return [Infinity, -Infinity];
  32529. };
  32530. setItemDataAndSeriesIndex = function (child) {
  32531. var childECData = getECData(child);
  32532. var thisECData = getECData(this);
  32533. childECData.seriesIndex = thisECData.seriesIndex;
  32534. childECData.dataIndex = thisECData.dataIndex;
  32535. childECData.dataType = thisECData.dataType;
  32536. };
  32537. transferProperties = function (target, source) {
  32538. each$1(TRANSFERABLE_PROPERTIES.concat(source.__wrappedMethods || []), function (propName) {
  32539. if (source.hasOwnProperty(propName)) {
  32540. target[propName] = source[propName];
  32541. }
  32542. });
  32543. target.__wrappedMethods = source.__wrappedMethods;
  32544. each$1(CLONE_PROPERTIES, function (propName) {
  32545. target[propName] = clone(source[propName]);
  32546. });
  32547. target._calculationInfo = extend({}, source._calculationInfo);
  32548. };
  32549. makeIdFromName = function (list, idx) {
  32550. var nameList = list._nameList;
  32551. var idList = list._idList;
  32552. var nameDimIdx = list._nameDimIdx;
  32553. var idDimIdx = list._idDimIdx;
  32554. var name = nameList[idx];
  32555. var id = idList[idx];
  32556. if (name == null && nameDimIdx != null) {
  32557. nameList[idx] = name = getIdNameFromStore(list, nameDimIdx, list._nameOrdinalMeta, idx);
  32558. }
  32559. if (id == null && idDimIdx != null) {
  32560. idList[idx] = id = getIdNameFromStore(list, idDimIdx, list._idOrdinalMeta, idx);
  32561. }
  32562. if (id == null && name != null) {
  32563. var nameRepeatCount = list._nameRepeatCount;
  32564. var nmCnt = nameRepeatCount[name] = (nameRepeatCount[name] || 0) + 1;
  32565. id = name;
  32566. if (nmCnt > 1) {
  32567. id += '__ec__' + nmCnt;
  32568. }
  32569. idList[idx] = id;
  32570. }
  32571. };
  32572. }();
  32573. return List;
  32574. }();
  32575. /*
  32576. * Licensed to the Apache Software Foundation (ASF) under one
  32577. * or more contributor license agreements. See the NOTICE file
  32578. * distributed with this work for additional information
  32579. * regarding copyright ownership. The ASF licenses this file
  32580. * to you under the Apache License, Version 2.0 (the
  32581. * "License"); you may not use this file except in compliance
  32582. * with the License. You may obtain a copy of the License at
  32583. *
  32584. * http://www.apache.org/licenses/LICENSE-2.0
  32585. *
  32586. * Unless required by applicable law or agreed to in writing,
  32587. * software distributed under the License is distributed on an
  32588. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  32589. * KIND, either express or implied. See the License for the
  32590. * specific language governing permissions and limitations
  32591. * under the License.
  32592. */
  32593. /**
  32594. * AUTO-GENERATED FILE. DO NOT MODIFY.
  32595. */
  32596. /*
  32597. * Licensed to the Apache Software Foundation (ASF) under one
  32598. * or more contributor license agreements. See the NOTICE file
  32599. * distributed with this work for additional information
  32600. * regarding copyright ownership. The ASF licenses this file
  32601. * to you under the Apache License, Version 2.0 (the
  32602. * "License"); you may not use this file except in compliance
  32603. * with the License. You may obtain a copy of the License at
  32604. *
  32605. * http://www.apache.org/licenses/LICENSE-2.0
  32606. *
  32607. * Unless required by applicable law or agreed to in writing,
  32608. * software distributed under the License is distributed on an
  32609. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  32610. * KIND, either express or implied. See the License for the
  32611. * specific language governing permissions and limitations
  32612. * under the License.
  32613. */
  32614. /**
  32615. * @deprecated
  32616. * Use `echarts/data/helper/createDimensions` instead.
  32617. */
  32618. /**
  32619. * @see {module:echarts/test/ut/spec/data/completeDimensions}
  32620. *
  32621. * This method builds the relationship between:
  32622. * + "what the coord sys or series requires (see `sysDims`)",
  32623. * + "what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)"
  32624. * + "what the data source provids (see `source`)".
  32625. *
  32626. * Some guess strategy will be adapted if user does not define something.
  32627. * If no 'value' dimension specified, the first no-named dimension will be
  32628. * named as 'value'.
  32629. *
  32630. * @param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
  32631. * provides not only dim template, but also default order.
  32632. * properties: 'name', 'type', 'displayName'.
  32633. * `name` of each item provides default coord name.
  32634. * [{dimsDef: [string|Object, ...]}, ...] dimsDef of sysDim item provides default dim name, and
  32635. * provide dims count that the sysDim required.
  32636. * [{ordinalMeta}] can be specified.
  32637. * @param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)
  32638. * @param {Object} [opt]
  32639. * @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
  32640. * For example: ['asdf', {name, type}, ...].
  32641. * @param {Object|HashMap} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
  32642. * @param {Function} [opt.encodeDefaulter] Called if no `opt.encodeDef` exists.
  32643. * If not specified, auto find the next available data dim.
  32644. * param source {module:data/Source}
  32645. * param dimCount {number}
  32646. * return {Object} encode Never be `null/undefined`.
  32647. * @param {string} [opt.generateCoord] Generate coord dim with the given name.
  32648. * If not specified, extra dim names will be:
  32649. * 'value', 'value0', 'value1', ...
  32650. * @param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
  32651. * If `generateCoordCount` specified, the generated dim names will be:
  32652. * `generateCoord` + 0, `generateCoord` + 1, ...
  32653. * can be Infinity, indicate that use all of the remain columns.
  32654. * @param {number} [opt.dimCount] If not specified, guess by the first data item.
  32655. * @return {Array.<module:data/DataDimensionInfo>}
  32656. */
  32657. function completeDimensions(sysDims, source, opt) {
  32658. if (!isSourceInstance(source)) {
  32659. source = createSourceFromSeriesDataOption(source);
  32660. }
  32661. opt = opt || {};
  32662. sysDims = (sysDims || []).slice();
  32663. var dimsDef = (opt.dimsDef || []).slice();
  32664. var dataDimNameMap = createHashMap();
  32665. var coordDimNameMap = createHashMap(); // let valueCandidate;
  32666. var result = [];
  32667. var dimCount = getDimCount(source, sysDims, dimsDef, opt.dimCount); // Apply user defined dims (`name` and `type`) and init result.
  32668. for (var i = 0; i < dimCount; i++) {
  32669. var dimDefItemRaw = dimsDef[i];
  32670. var dimDefItem = dimsDef[i] = extend({}, isObject$1(dimDefItemRaw) ? dimDefItemRaw : {
  32671. name: dimDefItemRaw
  32672. });
  32673. var userDimName = dimDefItem.name;
  32674. var resultItem = result[i] = new DataDimensionInfo(); // Name will be applied later for avoiding duplication.
  32675. if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
  32676. // Only if `series.dimensions` is defined in option
  32677. // displayName, will be set, and dimension will be diplayed vertically in
  32678. // tooltip by default.
  32679. resultItem.name = resultItem.displayName = userDimName;
  32680. dataDimNameMap.set(userDimName, i);
  32681. }
  32682. dimDefItem.type != null && (resultItem.type = dimDefItem.type);
  32683. dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
  32684. }
  32685. var encodeDef = opt.encodeDef;
  32686. if (!encodeDef && opt.encodeDefaulter) {
  32687. encodeDef = opt.encodeDefaulter(source, dimCount);
  32688. }
  32689. var encodeDefMap = createHashMap(encodeDef); // Set `coordDim` and `coordDimIndex` by `encodeDefMap` and normalize `encodeDefMap`.
  32690. encodeDefMap.each(function (dataDimsRaw, coordDim) {
  32691. var dataDims = normalizeToArray(dataDimsRaw).slice(); // Note: It is allowed that `dataDims.length` is `0`, e.g., options is
  32692. // `{encode: {x: -1, y: 1}}`. Should not filter anything in
  32693. // this case.
  32694. if (dataDims.length === 1 && !isString(dataDims[0]) && dataDims[0] < 0) {
  32695. encodeDefMap.set(coordDim, false);
  32696. return;
  32697. }
  32698. var validDataDims = encodeDefMap.set(coordDim, []);
  32699. each$1(dataDims, function (resultDimIdxOrName, idx) {
  32700. // The input resultDimIdx can be dim name or index.
  32701. var resultDimIdx = isString(resultDimIdxOrName) ? dataDimNameMap.get(resultDimIdxOrName) : resultDimIdxOrName;
  32702. if (resultDimIdx != null && resultDimIdx < dimCount) {
  32703. validDataDims[idx] = resultDimIdx;
  32704. applyDim(result[resultDimIdx], coordDim, idx);
  32705. }
  32706. });
  32707. }); // Apply templetes and default order from `sysDims`.
  32708. var availDimIdx = 0;
  32709. each$1(sysDims, function (sysDimItemRaw) {
  32710. var coordDim;
  32711. var sysDimItemDimsDef;
  32712. var sysDimItemOtherDims;
  32713. var sysDimItem;
  32714. if (isString(sysDimItemRaw)) {
  32715. coordDim = sysDimItemRaw;
  32716. sysDimItem = {};
  32717. } else {
  32718. sysDimItem = sysDimItemRaw;
  32719. coordDim = sysDimItem.name;
  32720. var ordinalMeta = sysDimItem.ordinalMeta;
  32721. sysDimItem.ordinalMeta = null;
  32722. sysDimItem = clone(sysDimItem);
  32723. sysDimItem.ordinalMeta = ordinalMeta; // `coordDimIndex` should not be set directly.
  32724. sysDimItemDimsDef = sysDimItem.dimsDef;
  32725. sysDimItemOtherDims = sysDimItem.otherDims;
  32726. sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex = sysDimItem.dimsDef = sysDimItem.otherDims = null;
  32727. }
  32728. var dataDims = encodeDefMap.get(coordDim); // negative resultDimIdx means no need to mapping.
  32729. if (dataDims === false) {
  32730. return;
  32731. }
  32732. dataDims = normalizeToArray(dataDims); // dimensions provides default dim sequences.
  32733. if (!dataDims.length) {
  32734. for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
  32735. while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
  32736. availDimIdx++;
  32737. }
  32738. availDimIdx < result.length && dataDims.push(availDimIdx++);
  32739. }
  32740. } // Apply templates.
  32741. each$1(dataDims, function (resultDimIdx, coordDimIndex) {
  32742. var resultItem = result[resultDimIdx];
  32743. applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
  32744. if (resultItem.name == null && sysDimItemDimsDef) {
  32745. var sysDimItemDimsDefItem = sysDimItemDimsDef[coordDimIndex];
  32746. !isObject$1(sysDimItemDimsDefItem) && (sysDimItemDimsDefItem = {
  32747. name: sysDimItemDimsDefItem
  32748. });
  32749. resultItem.name = resultItem.displayName = sysDimItemDimsDefItem.name;
  32750. resultItem.defaultTooltip = sysDimItemDimsDefItem.defaultTooltip;
  32751. } // FIXME refactor, currently only used in case: {otherDims: {tooltip: false}}
  32752. sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
  32753. });
  32754. });
  32755. function applyDim(resultItem, coordDim, coordDimIndex) {
  32756. if (VISUAL_DIMENSIONS.get(coordDim) != null) {
  32757. resultItem.otherDims[coordDim] = coordDimIndex;
  32758. } else {
  32759. resultItem.coordDim = coordDim;
  32760. resultItem.coordDimIndex = coordDimIndex;
  32761. coordDimNameMap.set(coordDim, true);
  32762. }
  32763. } // Make sure the first extra dim is 'value'.
  32764. var generateCoord = opt.generateCoord;
  32765. var generateCoordCount = opt.generateCoordCount;
  32766. var fromZero = generateCoordCount != null;
  32767. generateCoordCount = generateCoord ? generateCoordCount || 1 : 0;
  32768. var extra = generateCoord || 'value'; // Set dim `name` and other `coordDim` and other props.
  32769. for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
  32770. var resultItem = result[resultDimIdx] = result[resultDimIdx] || new DataDimensionInfo();
  32771. var coordDim = resultItem.coordDim;
  32772. if (coordDim == null) {
  32773. resultItem.coordDim = genName(extra, coordDimNameMap, fromZero);
  32774. resultItem.coordDimIndex = 0;
  32775. if (!generateCoord || generateCoordCount <= 0) {
  32776. resultItem.isExtraCoord = true;
  32777. }
  32778. generateCoordCount--;
  32779. }
  32780. resultItem.name == null && (resultItem.name = genName(resultItem.coordDim, dataDimNameMap, false));
  32781. if (resultItem.type == null && (guessOrdinal(source, resultDimIdx) === BE_ORDINAL.Must // Consider the case:
  32782. // {
  32783. // dataset: {source: [
  32784. // ['2001', 123],
  32785. // ['2002', 456],
  32786. // ...
  32787. // ['The others', 987],
  32788. // ]},
  32789. // series: {type: 'pie'}
  32790. // }
  32791. // The first colum should better be treated as a "ordinal" although it
  32792. // might not able to be detected as an "ordinal" by `guessOrdinal`.
  32793. || resultItem.isExtraCoord && (resultItem.otherDims.itemName != null || resultItem.otherDims.seriesName != null))) {
  32794. resultItem.type = 'ordinal';
  32795. }
  32796. }
  32797. return result;
  32798. } // ??? TODO
  32799. // Originally detect dimCount by data[0]. Should we
  32800. // optimize it to only by sysDims and dimensions and encode.
  32801. // So only necessary dims will be initialized.
  32802. // But
  32803. // (1) custom series should be considered. where other dims
  32804. // may be visited.
  32805. // (2) sometimes user need to calcualte bubble size or use visualMap
  32806. // on other dimensions besides coordSys needed.
  32807. // So, dims that is not used by system, should be shared in storage?
  32808. function getDimCount(source, sysDims, dimsDef, optDimCount) {
  32809. // Note that the result dimCount should not small than columns count
  32810. // of data, otherwise `dataDimNameMap` checking will be incorrect.
  32811. var dimCount = Math.max(source.dimensionsDetectedCount || 1, sysDims.length, dimsDef.length, optDimCount || 0);
  32812. each$1(sysDims, function (sysDimItem) {
  32813. var sysDimItemDimsDef;
  32814. if (isObject$1(sysDimItem) && (sysDimItemDimsDef = sysDimItem.dimsDef)) {
  32815. dimCount = Math.max(dimCount, sysDimItemDimsDef.length);
  32816. }
  32817. });
  32818. return dimCount;
  32819. }
  32820. function genName(name, map$$1, fromZero) {
  32821. if (fromZero || map$$1.get(name) != null) {
  32822. var i = 0;
  32823. while (map$$1.get(name + i) != null) {
  32824. i++;
  32825. }
  32826. name += i;
  32827. }
  32828. map$$1.set(name, true);
  32829. return name;
  32830. }
  32831. /*
  32832. * Licensed to the Apache Software Foundation (ASF) under one
  32833. * or more contributor license agreements. See the NOTICE file
  32834. * distributed with this work for additional information
  32835. * regarding copyright ownership. The ASF licenses this file
  32836. * to you under the Apache License, Version 2.0 (the
  32837. * "License"); you may not use this file except in compliance
  32838. * with the License. You may obtain a copy of the License at
  32839. *
  32840. * http://www.apache.org/licenses/LICENSE-2.0
  32841. *
  32842. * Unless required by applicable law or agreed to in writing,
  32843. * software distributed under the License is distributed on an
  32844. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  32845. * KIND, either express or implied. See the License for the
  32846. * specific language governing permissions and limitations
  32847. * under the License.
  32848. */
  32849. /**
  32850. * AUTO-GENERATED FILE. DO NOT MODIFY.
  32851. */
  32852. /*
  32853. * Licensed to the Apache Software Foundation (ASF) under one
  32854. * or more contributor license agreements. See the NOTICE file
  32855. * distributed with this work for additional information
  32856. * regarding copyright ownership. The ASF licenses this file
  32857. * to you under the Apache License, Version 2.0 (the
  32858. * "License"); you may not use this file except in compliance
  32859. * with the License. You may obtain a copy of the License at
  32860. *
  32861. * http://www.apache.org/licenses/LICENSE-2.0
  32862. *
  32863. * Unless required by applicable law or agreed to in writing,
  32864. * software distributed under the License is distributed on an
  32865. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  32866. * KIND, either express or implied. See the License for the
  32867. * specific language governing permissions and limitations
  32868. * under the License.
  32869. */
  32870. /**
  32871. * Substitute `completeDimensions`.
  32872. * `completeDimensions` is to be deprecated.
  32873. */
  32874. /**
  32875. * @param opt.coordDimensions
  32876. * @param opt.dimensionsDefine By default `source.dimensionsDefine` Overwrite source define.
  32877. * @param opt.encodeDefine By default `source.encodeDefine` Overwrite source define.
  32878. * @param opt.encodeDefaulter Make default encode if user not specified.
  32879. */
  32880. function createDimensions( // TODO: TYPE completeDimensions type
  32881. source, opt) {
  32882. opt = opt || {};
  32883. return completeDimensions(opt.coordDimensions || [], source, {
  32884. // FIXME:TS detect whether source then call `.dimensionsDefine` and `.encodeDefine`?
  32885. dimsDef: opt.dimensionsDefine || source.dimensionsDefine,
  32886. encodeDef: opt.encodeDefine || source.encodeDefine,
  32887. dimCount: opt.dimensionsCount,
  32888. encodeDefaulter: opt.encodeDefaulter,
  32889. generateCoord: opt.generateCoord,
  32890. generateCoordCount: opt.generateCoordCount
  32891. });
  32892. }
  32893. /*
  32894. * Licensed to the Apache Software Foundation (ASF) under one
  32895. * or more contributor license agreements. See the NOTICE file
  32896. * distributed with this work for additional information
  32897. * regarding copyright ownership. The ASF licenses this file
  32898. * to you under the Apache License, Version 2.0 (the
  32899. * "License"); you may not use this file except in compliance
  32900. * with the License. You may obtain a copy of the License at
  32901. *
  32902. * http://www.apache.org/licenses/LICENSE-2.0
  32903. *
  32904. * Unless required by applicable law or agreed to in writing,
  32905. * software distributed under the License is distributed on an
  32906. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  32907. * KIND, either express or implied. See the License for the
  32908. * specific language governing permissions and limitations
  32909. * under the License.
  32910. */
  32911. /**
  32912. * AUTO-GENERATED FILE. DO NOT MODIFY.
  32913. */
  32914. /*
  32915. * Licensed to the Apache Software Foundation (ASF) under one
  32916. * or more contributor license agreements. See the NOTICE file
  32917. * distributed with this work for additional information
  32918. * regarding copyright ownership. The ASF licenses this file
  32919. * to you under the Apache License, Version 2.0 (the
  32920. * "License"); you may not use this file except in compliance
  32921. * with the License. You may obtain a copy of the License at
  32922. *
  32923. * http://www.apache.org/licenses/LICENSE-2.0
  32924. *
  32925. * Unless required by applicable law or agreed to in writing,
  32926. * software distributed under the License is distributed on an
  32927. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  32928. * KIND, either express or implied. See the License for the
  32929. * specific language governing permissions and limitations
  32930. * under the License.
  32931. */
  32932. /**
  32933. * Helper for model references.
  32934. * There are many manners to refer axis/coordSys.
  32935. */
  32936. // TODO
  32937. // merge relevant logic to this file?
  32938. // check: "modelHelper" of tooltip and "BrushTargetManager".
  32939. /**
  32940. * @class
  32941. * For example:
  32942. * {
  32943. * coordSysName: 'cartesian2d',
  32944. * coordSysDims: ['x', 'y', ...],
  32945. * axisMap: HashMap({
  32946. * x: xAxisModel,
  32947. * y: yAxisModel
  32948. * }),
  32949. * categoryAxisMap: HashMap({
  32950. * x: xAxisModel,
  32951. * y: undefined
  32952. * }),
  32953. * // The index of the first category axis in `coordSysDims`.
  32954. * // `null/undefined` means no category axis exists.
  32955. * firstCategoryDimIndex: 1,
  32956. * // To replace user specified encode.
  32957. * }
  32958. */
  32959. var CoordSysInfo =
  32960. /** @class */
  32961. function () {
  32962. function CoordSysInfo(coordSysName) {
  32963. this.coordSysDims = [];
  32964. this.axisMap = createHashMap();
  32965. this.categoryAxisMap = createHashMap();
  32966. this.coordSysName = coordSysName;
  32967. }
  32968. return CoordSysInfo;
  32969. }();
  32970. function getCoordSysInfoBySeries(seriesModel) {
  32971. var coordSysName = seriesModel.get('coordinateSystem');
  32972. var result = new CoordSysInfo(coordSysName);
  32973. var fetch = fetchers[coordSysName];
  32974. if (fetch) {
  32975. fetch(seriesModel, result, result.axisMap, result.categoryAxisMap);
  32976. return result;
  32977. }
  32978. }
  32979. var fetchers = {
  32980. cartesian2d: function (seriesModel, result, axisMap, categoryAxisMap) {
  32981. var xAxisModel = seriesModel.getReferringComponents('xAxis', SINGLE_REFERRING).models[0];
  32982. var yAxisModel = seriesModel.getReferringComponents('yAxis', SINGLE_REFERRING).models[0];
  32983. {
  32984. if (!xAxisModel) {
  32985. throw new Error('xAxis "' + retrieve(seriesModel.get('xAxisIndex'), seriesModel.get('xAxisId'), 0) + '" not found');
  32986. }
  32987. if (!yAxisModel) {
  32988. throw new Error('yAxis "' + retrieve(seriesModel.get('xAxisIndex'), seriesModel.get('yAxisId'), 0) + '" not found');
  32989. }
  32990. }
  32991. result.coordSysDims = ['x', 'y'];
  32992. axisMap.set('x', xAxisModel);
  32993. axisMap.set('y', yAxisModel);
  32994. if (isCategory(xAxisModel)) {
  32995. categoryAxisMap.set('x', xAxisModel);
  32996. result.firstCategoryDimIndex = 0;
  32997. }
  32998. if (isCategory(yAxisModel)) {
  32999. categoryAxisMap.set('y', yAxisModel);
  33000. result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
  33001. }
  33002. },
  33003. singleAxis: function (seriesModel, result, axisMap, categoryAxisMap) {
  33004. var singleAxisModel = seriesModel.getReferringComponents('singleAxis', SINGLE_REFERRING).models[0];
  33005. {
  33006. if (!singleAxisModel) {
  33007. throw new Error('singleAxis should be specified.');
  33008. }
  33009. }
  33010. result.coordSysDims = ['single'];
  33011. axisMap.set('single', singleAxisModel);
  33012. if (isCategory(singleAxisModel)) {
  33013. categoryAxisMap.set('single', singleAxisModel);
  33014. result.firstCategoryDimIndex = 0;
  33015. }
  33016. },
  33017. polar: function (seriesModel, result, axisMap, categoryAxisMap) {
  33018. var polarModel = seriesModel.getReferringComponents('polar', SINGLE_REFERRING).models[0];
  33019. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  33020. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  33021. {
  33022. if (!angleAxisModel) {
  33023. throw new Error('angleAxis option not found');
  33024. }
  33025. if (!radiusAxisModel) {
  33026. throw new Error('radiusAxis option not found');
  33027. }
  33028. }
  33029. result.coordSysDims = ['radius', 'angle'];
  33030. axisMap.set('radius', radiusAxisModel);
  33031. axisMap.set('angle', angleAxisModel);
  33032. if (isCategory(radiusAxisModel)) {
  33033. categoryAxisMap.set('radius', radiusAxisModel);
  33034. result.firstCategoryDimIndex = 0;
  33035. }
  33036. if (isCategory(angleAxisModel)) {
  33037. categoryAxisMap.set('angle', angleAxisModel);
  33038. result.firstCategoryDimIndex == null && (result.firstCategoryDimIndex = 1);
  33039. }
  33040. },
  33041. geo: function (seriesModel, result, axisMap, categoryAxisMap) {
  33042. result.coordSysDims = ['lng', 'lat'];
  33043. },
  33044. parallel: function (seriesModel, result, axisMap, categoryAxisMap) {
  33045. var ecModel = seriesModel.ecModel;
  33046. var parallelModel = ecModel.getComponent('parallel', seriesModel.get('parallelIndex'));
  33047. var coordSysDims = result.coordSysDims = parallelModel.dimensions.slice();
  33048. each$1(parallelModel.parallelAxisIndex, function (axisIndex, index) {
  33049. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  33050. var axisDim = coordSysDims[index];
  33051. axisMap.set(axisDim, axisModel);
  33052. if (isCategory(axisModel)) {
  33053. categoryAxisMap.set(axisDim, axisModel);
  33054. if (result.firstCategoryDimIndex == null) {
  33055. result.firstCategoryDimIndex = index;
  33056. }
  33057. }
  33058. });
  33059. }
  33060. };
  33061. function isCategory(axisModel) {
  33062. return axisModel.get('type') === 'category';
  33063. }
  33064. /*
  33065. * Licensed to the Apache Software Foundation (ASF) under one
  33066. * or more contributor license agreements. See the NOTICE file
  33067. * distributed with this work for additional information
  33068. * regarding copyright ownership. The ASF licenses this file
  33069. * to you under the Apache License, Version 2.0 (the
  33070. * "License"); you may not use this file except in compliance
  33071. * with the License. You may obtain a copy of the License at
  33072. *
  33073. * http://www.apache.org/licenses/LICENSE-2.0
  33074. *
  33075. * Unless required by applicable law or agreed to in writing,
  33076. * software distributed under the License is distributed on an
  33077. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33078. * KIND, either express or implied. See the License for the
  33079. * specific language governing permissions and limitations
  33080. * under the License.
  33081. */
  33082. /**
  33083. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33084. */
  33085. /*
  33086. * Licensed to the Apache Software Foundation (ASF) under one
  33087. * or more contributor license agreements. See the NOTICE file
  33088. * distributed with this work for additional information
  33089. * regarding copyright ownership. The ASF licenses this file
  33090. * to you under the Apache License, Version 2.0 (the
  33091. * "License"); you may not use this file except in compliance
  33092. * with the License. You may obtain a copy of the License at
  33093. *
  33094. * http://www.apache.org/licenses/LICENSE-2.0
  33095. *
  33096. * Unless required by applicable law or agreed to in writing,
  33097. * software distributed under the License is distributed on an
  33098. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33099. * KIND, either express or implied. See the License for the
  33100. * specific language governing permissions and limitations
  33101. * under the License.
  33102. */
  33103. /**
  33104. * Note that it is too complicated to support 3d stack by value
  33105. * (have to create two-dimension inverted index), so in 3d case
  33106. * we just support that stacked by index.
  33107. *
  33108. * @param seriesModel
  33109. * @param dimensionInfoList The same as the input of <module:echarts/data/List>.
  33110. * The input dimensionInfoList will be modified.
  33111. * @param opt
  33112. * @param opt.stackedCoordDimension Specify a coord dimension if needed.
  33113. * @param opt.byIndex=false
  33114. * @return calculationInfo
  33115. * {
  33116. * stackedDimension: string
  33117. * stackedByDimension: string
  33118. * isStackedByIndex: boolean
  33119. * stackedOverDimension: string
  33120. * stackResultDimension: string
  33121. * }
  33122. */
  33123. function enableDataStack(seriesModel, dimensionInfoList, opt) {
  33124. opt = opt || {};
  33125. var byIndex = opt.byIndex;
  33126. var stackedCoordDimension = opt.stackedCoordDimension; // Compatibal: when `stack` is set as '', do not stack.
  33127. var mayStack = !!(seriesModel && seriesModel.get('stack'));
  33128. var stackedByDimInfo;
  33129. var stackedDimInfo;
  33130. var stackResultDimension;
  33131. var stackedOverDimension;
  33132. each$1(dimensionInfoList, function (dimensionInfo, index) {
  33133. if (isString(dimensionInfo)) {
  33134. dimensionInfoList[index] = dimensionInfo = {
  33135. name: dimensionInfo
  33136. };
  33137. }
  33138. if (mayStack && !dimensionInfo.isExtraCoord) {
  33139. // Find the first ordinal dimension as the stackedByDimInfo.
  33140. if (!byIndex && !stackedByDimInfo && dimensionInfo.ordinalMeta) {
  33141. stackedByDimInfo = dimensionInfo;
  33142. } // Find the first stackable dimension as the stackedDimInfo.
  33143. if (!stackedDimInfo && dimensionInfo.type !== 'ordinal' && dimensionInfo.type !== 'time' && (!stackedCoordDimension || stackedCoordDimension === dimensionInfo.coordDim)) {
  33144. stackedDimInfo = dimensionInfo;
  33145. }
  33146. }
  33147. });
  33148. if (stackedDimInfo && !byIndex && !stackedByDimInfo) {
  33149. // Compatible with previous design, value axis (time axis) only stack by index.
  33150. // It may make sense if the user provides elaborately constructed data.
  33151. byIndex = true;
  33152. } // Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
  33153. // That put stack logic in List is for using conveniently in echarts extensions, but it
  33154. // might not be a good way.
  33155. if (stackedDimInfo) {
  33156. // Use a weird name that not duplicated with other names.
  33157. stackResultDimension = '__\0ecstackresult';
  33158. stackedOverDimension = '__\0ecstackedover'; // Create inverted index to fast query index by value.
  33159. if (stackedByDimInfo) {
  33160. stackedByDimInfo.createInvertedIndices = true;
  33161. }
  33162. var stackedDimCoordDim_1 = stackedDimInfo.coordDim;
  33163. var stackedDimType = stackedDimInfo.type;
  33164. var stackedDimCoordIndex_1 = 0;
  33165. each$1(dimensionInfoList, function (dimensionInfo) {
  33166. if (dimensionInfo.coordDim === stackedDimCoordDim_1) {
  33167. stackedDimCoordIndex_1++;
  33168. }
  33169. });
  33170. dimensionInfoList.push({
  33171. name: stackResultDimension,
  33172. coordDim: stackedDimCoordDim_1,
  33173. coordDimIndex: stackedDimCoordIndex_1,
  33174. type: stackedDimType,
  33175. isExtraCoord: true,
  33176. isCalculationCoord: true
  33177. });
  33178. stackedDimCoordIndex_1++;
  33179. dimensionInfoList.push({
  33180. name: stackedOverDimension,
  33181. // This dimension contains stack base (generally, 0), so do not set it as
  33182. // `stackedDimCoordDim` to avoid extent calculation, consider log scale.
  33183. coordDim: stackedOverDimension,
  33184. coordDimIndex: stackedDimCoordIndex_1,
  33185. type: stackedDimType,
  33186. isExtraCoord: true,
  33187. isCalculationCoord: true
  33188. });
  33189. }
  33190. return {
  33191. stackedDimension: stackedDimInfo && stackedDimInfo.name,
  33192. stackedByDimension: stackedByDimInfo && stackedByDimInfo.name,
  33193. isStackedByIndex: byIndex,
  33194. stackedOverDimension: stackedOverDimension,
  33195. stackResultDimension: stackResultDimension
  33196. };
  33197. }
  33198. function isDimensionStacked(data, stackedDim
  33199. /*, stackedByDim*/
  33200. ) {
  33201. // Each single series only maps to one pair of axis. So we do not need to
  33202. // check stackByDim, whatever stacked by a dimension or stacked by index.
  33203. return !!stackedDim && stackedDim === data.getCalculationInfo('stackedDimension'); // && (
  33204. // stackedByDim != null
  33205. // ? stackedByDim === data.getCalculationInfo('stackedByDimension')
  33206. // : data.getCalculationInfo('isStackedByIndex')
  33207. // );
  33208. }
  33209. function getStackedDimension(data, targetDim) {
  33210. return isDimensionStacked(data, targetDim) ? data.getCalculationInfo('stackResultDimension') : targetDim;
  33211. }
  33212. /*
  33213. * Licensed to the Apache Software Foundation (ASF) under one
  33214. * or more contributor license agreements. See the NOTICE file
  33215. * distributed with this work for additional information
  33216. * regarding copyright ownership. The ASF licenses this file
  33217. * to you under the Apache License, Version 2.0 (the
  33218. * "License"); you may not use this file except in compliance
  33219. * with the License. You may obtain a copy of the License at
  33220. *
  33221. * http://www.apache.org/licenses/LICENSE-2.0
  33222. *
  33223. * Unless required by applicable law or agreed to in writing,
  33224. * software distributed under the License is distributed on an
  33225. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33226. * KIND, either express or implied. See the License for the
  33227. * specific language governing permissions and limitations
  33228. * under the License.
  33229. */
  33230. /**
  33231. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33232. */
  33233. /*
  33234. * Licensed to the Apache Software Foundation (ASF) under one
  33235. * or more contributor license agreements. See the NOTICE file
  33236. * distributed with this work for additional information
  33237. * regarding copyright ownership. The ASF licenses this file
  33238. * to you under the Apache License, Version 2.0 (the
  33239. * "License"); you may not use this file except in compliance
  33240. * with the License. You may obtain a copy of the License at
  33241. *
  33242. * http://www.apache.org/licenses/LICENSE-2.0
  33243. *
  33244. * Unless required by applicable law or agreed to in writing,
  33245. * software distributed under the License is distributed on an
  33246. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33247. * KIND, either express or implied. See the License for the
  33248. * specific language governing permissions and limitations
  33249. * under the License.
  33250. */
  33251. function createListFromArray(source, seriesModel, opt) {
  33252. opt = opt || {};
  33253. if (!isSourceInstance(source)) {
  33254. source = createSourceFromSeriesDataOption(source);
  33255. }
  33256. var coordSysName = seriesModel.get('coordinateSystem');
  33257. var registeredCoordSys = CoordinateSystemManager.get(coordSysName);
  33258. var coordSysInfo = getCoordSysInfoBySeries(seriesModel);
  33259. var coordSysDimDefs;
  33260. if (coordSysInfo && coordSysInfo.coordSysDims) {
  33261. coordSysDimDefs = map(coordSysInfo.coordSysDims, function (dim) {
  33262. var dimInfo = {
  33263. name: dim
  33264. };
  33265. var axisModel = coordSysInfo.axisMap.get(dim);
  33266. if (axisModel) {
  33267. var axisType = axisModel.get('type');
  33268. dimInfo.type = getDimensionTypeByAxis(axisType); // dimInfo.stackable = isStackable(axisType);
  33269. }
  33270. return dimInfo;
  33271. });
  33272. }
  33273. if (!coordSysDimDefs) {
  33274. // Get dimensions from registered coordinate system
  33275. coordSysDimDefs = registeredCoordSys && (registeredCoordSys.getDimensionsInfo ? registeredCoordSys.getDimensionsInfo() : registeredCoordSys.dimensions.slice()) || ['x', 'y'];
  33276. }
  33277. var useEncodeDefaulter = opt.useEncodeDefaulter;
  33278. var dimInfoList = createDimensions(source, {
  33279. coordDimensions: coordSysDimDefs,
  33280. generateCoord: opt.generateCoord,
  33281. encodeDefaulter: isFunction$1(useEncodeDefaulter) ? useEncodeDefaulter : useEncodeDefaulter ? curry(makeSeriesEncodeForAxisCoordSys, coordSysDimDefs, seriesModel) : null
  33282. });
  33283. var firstCategoryDimIndex;
  33284. var hasNameEncode;
  33285. coordSysInfo && each$1(dimInfoList, function (dimInfo, dimIndex) {
  33286. var coordDim = dimInfo.coordDim;
  33287. var categoryAxisModel = coordSysInfo.categoryAxisMap.get(coordDim);
  33288. if (categoryAxisModel) {
  33289. if (firstCategoryDimIndex == null) {
  33290. firstCategoryDimIndex = dimIndex;
  33291. }
  33292. dimInfo.ordinalMeta = categoryAxisModel.getOrdinalMeta();
  33293. if (opt.createInvertedIndices) {
  33294. dimInfo.createInvertedIndices = true;
  33295. }
  33296. }
  33297. if (dimInfo.otherDims.itemName != null) {
  33298. hasNameEncode = true;
  33299. }
  33300. });
  33301. if (!hasNameEncode && firstCategoryDimIndex != null) {
  33302. dimInfoList[firstCategoryDimIndex].otherDims.itemName = 0;
  33303. }
  33304. var stackCalculationInfo = enableDataStack(seriesModel, dimInfoList);
  33305. var list = new List(dimInfoList, seriesModel);
  33306. list.setCalculationInfo(stackCalculationInfo);
  33307. var dimValueGetter = firstCategoryDimIndex != null && isNeedCompleteOrdinalData(source) ? function (itemOpt, dimName, dataIndex, dimIndex) {
  33308. // Use dataIndex as ordinal value in categoryAxis
  33309. return dimIndex === firstCategoryDimIndex ? dataIndex : this.defaultDimValueGetter(itemOpt, dimName, dataIndex, dimIndex);
  33310. } : null;
  33311. list.hasItemOption = false;
  33312. list.initData(source, null, dimValueGetter);
  33313. return list;
  33314. }
  33315. function isNeedCompleteOrdinalData(source) {
  33316. if (source.sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  33317. var sampleItem = firstDataNotNull(source.data || []);
  33318. return sampleItem != null && !isArray(getDataItemValue(sampleItem));
  33319. }
  33320. }
  33321. function firstDataNotNull(data) {
  33322. var i = 0;
  33323. while (i < data.length && data[i] == null) {
  33324. i++;
  33325. }
  33326. return data[i];
  33327. }
  33328. /*
  33329. * Licensed to the Apache Software Foundation (ASF) under one
  33330. * or more contributor license agreements. See the NOTICE file
  33331. * distributed with this work for additional information
  33332. * regarding copyright ownership. The ASF licenses this file
  33333. * to you under the Apache License, Version 2.0 (the
  33334. * "License"); you may not use this file except in compliance
  33335. * with the License. You may obtain a copy of the License at
  33336. *
  33337. * http://www.apache.org/licenses/LICENSE-2.0
  33338. *
  33339. * Unless required by applicable law or agreed to in writing,
  33340. * software distributed under the License is distributed on an
  33341. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33342. * KIND, either express or implied. See the License for the
  33343. * specific language governing permissions and limitations
  33344. * under the License.
  33345. */
  33346. /**
  33347. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33348. */
  33349. /*
  33350. * Licensed to the Apache Software Foundation (ASF) under one
  33351. * or more contributor license agreements. See the NOTICE file
  33352. * distributed with this work for additional information
  33353. * regarding copyright ownership. The ASF licenses this file
  33354. * to you under the Apache License, Version 2.0 (the
  33355. * "License"); you may not use this file except in compliance
  33356. * with the License. You may obtain a copy of the License at
  33357. *
  33358. * http://www.apache.org/licenses/LICENSE-2.0
  33359. *
  33360. * Unless required by applicable law or agreed to in writing,
  33361. * software distributed under the License is distributed on an
  33362. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33363. * KIND, either express or implied. See the License for the
  33364. * specific language governing permissions and limitations
  33365. * under the License.
  33366. */
  33367. var Scale =
  33368. /** @class */
  33369. function () {
  33370. function Scale(setting) {
  33371. this._setting = setting || {};
  33372. this._extent = [Infinity, -Infinity];
  33373. }
  33374. Scale.prototype.getSetting = function (name) {
  33375. return this._setting[name];
  33376. };
  33377. /**
  33378. * Set extent from data
  33379. */
  33380. Scale.prototype.unionExtent = function (other) {
  33381. var extent = this._extent;
  33382. other[0] < extent[0] && (extent[0] = other[0]);
  33383. other[1] > extent[1] && (extent[1] = other[1]); // not setExtent because in log axis it may transformed to power
  33384. // this.setExtent(extent[0], extent[1]);
  33385. };
  33386. /**
  33387. * Set extent from data
  33388. */
  33389. Scale.prototype.unionExtentFromData = function (data, dim) {
  33390. this.unionExtent(data.getApproximateExtent(dim));
  33391. };
  33392. /**
  33393. * Get extent
  33394. *
  33395. * Extent is always in increase order.
  33396. */
  33397. Scale.prototype.getExtent = function () {
  33398. return this._extent.slice();
  33399. };
  33400. /**
  33401. * Set extent
  33402. */
  33403. Scale.prototype.setExtent = function (start, end) {
  33404. var thisExtent = this._extent;
  33405. if (!isNaN(start)) {
  33406. thisExtent[0] = start;
  33407. }
  33408. if (!isNaN(end)) {
  33409. thisExtent[1] = end;
  33410. }
  33411. };
  33412. /**
  33413. * If value is in extent range
  33414. */
  33415. Scale.prototype.isInExtentRange = function (value) {
  33416. return this._extent[0] <= value && this._extent[1] >= value;
  33417. };
  33418. /**
  33419. * When axis extent depends on data and no data exists,
  33420. * axis ticks should not be drawn, which is named 'blank'.
  33421. */
  33422. Scale.prototype.isBlank = function () {
  33423. return this._isBlank;
  33424. };
  33425. /**
  33426. * When axis extent depends on data and no data exists,
  33427. * axis ticks should not be drawn, which is named 'blank'.
  33428. */
  33429. Scale.prototype.setBlank = function (isBlank) {
  33430. this._isBlank = isBlank;
  33431. };
  33432. return Scale;
  33433. }();
  33434. enableClassManagement(Scale);
  33435. /*
  33436. * Licensed to the Apache Software Foundation (ASF) under one
  33437. * or more contributor license agreements. See the NOTICE file
  33438. * distributed with this work for additional information
  33439. * regarding copyright ownership. The ASF licenses this file
  33440. * to you under the Apache License, Version 2.0 (the
  33441. * "License"); you may not use this file except in compliance
  33442. * with the License. You may obtain a copy of the License at
  33443. *
  33444. * http://www.apache.org/licenses/LICENSE-2.0
  33445. *
  33446. * Unless required by applicable law or agreed to in writing,
  33447. * software distributed under the License is distributed on an
  33448. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33449. * KIND, either express or implied. See the License for the
  33450. * specific language governing permissions and limitations
  33451. * under the License.
  33452. */
  33453. /**
  33454. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33455. */
  33456. /*
  33457. * Licensed to the Apache Software Foundation (ASF) under one
  33458. * or more contributor license agreements. See the NOTICE file
  33459. * distributed with this work for additional information
  33460. * regarding copyright ownership. The ASF licenses this file
  33461. * to you under the Apache License, Version 2.0 (the
  33462. * "License"); you may not use this file except in compliance
  33463. * with the License. You may obtain a copy of the License at
  33464. *
  33465. * http://www.apache.org/licenses/LICENSE-2.0
  33466. *
  33467. * Unless required by applicable law or agreed to in writing,
  33468. * software distributed under the License is distributed on an
  33469. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33470. * KIND, either express or implied. See the License for the
  33471. * specific language governing permissions and limitations
  33472. * under the License.
  33473. */
  33474. var OrdinalMeta =
  33475. /** @class */
  33476. function () {
  33477. function OrdinalMeta(opt) {
  33478. this.categories = opt.categories || [];
  33479. this._needCollect = opt.needCollect;
  33480. this._deduplication = opt.deduplication;
  33481. }
  33482. OrdinalMeta.createByAxisModel = function (axisModel) {
  33483. var option = axisModel.option;
  33484. var data = option.data;
  33485. var categories = data && map(data, getName);
  33486. return new OrdinalMeta({
  33487. categories: categories,
  33488. needCollect: !categories,
  33489. // deduplication is default in axis.
  33490. deduplication: option.dedplication !== false
  33491. });
  33492. };
  33493. OrdinalMeta.prototype.getOrdinal = function (category) {
  33494. // @ts-ignore
  33495. return this._getOrCreateMap().get(category);
  33496. };
  33497. /**
  33498. * @return The ordinal. If not found, return NaN.
  33499. */
  33500. OrdinalMeta.prototype.parseAndCollect = function (category) {
  33501. var index;
  33502. var needCollect = this._needCollect; // The value of category dim can be the index of the given category set.
  33503. // This feature is only supported when !needCollect, because we should
  33504. // consider a common case: a value is 2017, which is a number but is
  33505. // expected to be tread as a category. This case usually happen in dataset,
  33506. // where it happent to be no need of the index feature.
  33507. if (typeof category !== 'string' && !needCollect) {
  33508. return category;
  33509. } // Optimize for the scenario:
  33510. // category is ['2012-01-01', '2012-01-02', ...], where the input
  33511. // data has been ensured not duplicate and is large data.
  33512. // Notice, if a dataset dimension provide categroies, usually echarts
  33513. // should remove duplication except user tell echarts dont do that
  33514. // (set axis.deduplication = false), because echarts do not know whether
  33515. // the values in the category dimension has duplication (consider the
  33516. // parallel-aqi example)
  33517. if (needCollect && !this._deduplication) {
  33518. index = this.categories.length;
  33519. this.categories[index] = category;
  33520. return index;
  33521. }
  33522. var map$$1 = this._getOrCreateMap(); // @ts-ignore
  33523. index = map$$1.get(category);
  33524. if (index == null) {
  33525. if (needCollect) {
  33526. index = this.categories.length;
  33527. this.categories[index] = category; // @ts-ignore
  33528. map$$1.set(category, index);
  33529. } else {
  33530. index = NaN;
  33531. }
  33532. }
  33533. return index;
  33534. }; // Consider big data, do not create map until needed.
  33535. OrdinalMeta.prototype._getOrCreateMap = function () {
  33536. return this._map || (this._map = createHashMap(this.categories));
  33537. };
  33538. return OrdinalMeta;
  33539. }();
  33540. function getName(obj) {
  33541. if (isObject$1(obj) && obj.value != null) {
  33542. return obj.value;
  33543. } else {
  33544. return obj + '';
  33545. }
  33546. }
  33547. /*
  33548. * Licensed to the Apache Software Foundation (ASF) under one
  33549. * or more contributor license agreements. See the NOTICE file
  33550. * distributed with this work for additional information
  33551. * regarding copyright ownership. The ASF licenses this file
  33552. * to you under the Apache License, Version 2.0 (the
  33553. * "License"); you may not use this file except in compliance
  33554. * with the License. You may obtain a copy of the License at
  33555. *
  33556. * http://www.apache.org/licenses/LICENSE-2.0
  33557. *
  33558. * Unless required by applicable law or agreed to in writing,
  33559. * software distributed under the License is distributed on an
  33560. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33561. * KIND, either express or implied. See the License for the
  33562. * specific language governing permissions and limitations
  33563. * under the License.
  33564. */
  33565. /**
  33566. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33567. */
  33568. /*
  33569. * Licensed to the Apache Software Foundation (ASF) under one
  33570. * or more contributor license agreements. See the NOTICE file
  33571. * distributed with this work for additional information
  33572. * regarding copyright ownership. The ASF licenses this file
  33573. * to you under the Apache License, Version 2.0 (the
  33574. * "License"); you may not use this file except in compliance
  33575. * with the License. You may obtain a copy of the License at
  33576. *
  33577. * http://www.apache.org/licenses/LICENSE-2.0
  33578. *
  33579. * Unless required by applicable law or agreed to in writing,
  33580. * software distributed under the License is distributed on an
  33581. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33582. * KIND, either express or implied. See the License for the
  33583. * specific language governing permissions and limitations
  33584. * under the License.
  33585. */
  33586. var roundNumber = round;
  33587. /**
  33588. * @param extent Both extent[0] and extent[1] should be valid number.
  33589. * Should be extent[0] < extent[1].
  33590. * @param splitNumber splitNumber should be >= 1.
  33591. */
  33592. function intervalScaleNiceTicks(extent, splitNumber, minInterval, maxInterval) {
  33593. var result = {};
  33594. var span = extent[1] - extent[0];
  33595. var interval = result.interval = nice(span / splitNumber, true);
  33596. if (minInterval != null && interval < minInterval) {
  33597. interval = result.interval = minInterval;
  33598. }
  33599. if (maxInterval != null && interval > maxInterval) {
  33600. interval = result.interval = maxInterval;
  33601. } // Tow more digital for tick.
  33602. var precision = result.intervalPrecision = getIntervalPrecision(interval); // Niced extent inside original extent
  33603. var niceTickExtent = result.niceTickExtent = [roundNumber(Math.ceil(extent[0] / interval) * interval, precision), roundNumber(Math.floor(extent[1] / interval) * interval, precision)];
  33604. fixExtent(niceTickExtent, extent);
  33605. return result;
  33606. }
  33607. /**
  33608. * @return interval precision
  33609. */
  33610. function getIntervalPrecision(interval) {
  33611. // Tow more digital for tick.
  33612. return getPrecisionSafe(interval) + 2;
  33613. }
  33614. function clamp(niceTickExtent, idx, extent) {
  33615. niceTickExtent[idx] = Math.max(Math.min(niceTickExtent[idx], extent[1]), extent[0]);
  33616. } // In some cases (e.g., splitNumber is 1), niceTickExtent may be out of extent.
  33617. function fixExtent(niceTickExtent, extent) {
  33618. !isFinite(niceTickExtent[0]) && (niceTickExtent[0] = extent[0]);
  33619. !isFinite(niceTickExtent[1]) && (niceTickExtent[1] = extent[1]);
  33620. clamp(niceTickExtent, 0, extent);
  33621. clamp(niceTickExtent, 1, extent);
  33622. if (niceTickExtent[0] > niceTickExtent[1]) {
  33623. niceTickExtent[0] = niceTickExtent[1];
  33624. }
  33625. }
  33626. function contain$2(val, extent) {
  33627. return val >= extent[0] && val <= extent[1];
  33628. }
  33629. function normalize$1(val, extent) {
  33630. if (extent[1] === extent[0]) {
  33631. return 0.5;
  33632. }
  33633. return (val - extent[0]) / (extent[1] - extent[0]);
  33634. }
  33635. function scale$2(val, extent) {
  33636. return val * (extent[1] - extent[0]) + extent[0];
  33637. }
  33638. /*
  33639. * Licensed to the Apache Software Foundation (ASF) under one
  33640. * or more contributor license agreements. See the NOTICE file
  33641. * distributed with this work for additional information
  33642. * regarding copyright ownership. The ASF licenses this file
  33643. * to you under the Apache License, Version 2.0 (the
  33644. * "License"); you may not use this file except in compliance
  33645. * with the License. You may obtain a copy of the License at
  33646. *
  33647. * http://www.apache.org/licenses/LICENSE-2.0
  33648. *
  33649. * Unless required by applicable law or agreed to in writing,
  33650. * software distributed under the License is distributed on an
  33651. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33652. * KIND, either express or implied. See the License for the
  33653. * specific language governing permissions and limitations
  33654. * under the License.
  33655. */
  33656. /**
  33657. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33658. */
  33659. /*
  33660. * Licensed to the Apache Software Foundation (ASF) under one
  33661. * or more contributor license agreements. See the NOTICE file
  33662. * distributed with this work for additional information
  33663. * regarding copyright ownership. The ASF licenses this file
  33664. * to you under the Apache License, Version 2.0 (the
  33665. * "License"); you may not use this file except in compliance
  33666. * with the License. You may obtain a copy of the License at
  33667. *
  33668. * http://www.apache.org/licenses/LICENSE-2.0
  33669. *
  33670. * Unless required by applicable law or agreed to in writing,
  33671. * software distributed under the License is distributed on an
  33672. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33673. * KIND, either express or implied. See the License for the
  33674. * specific language governing permissions and limitations
  33675. * under the License.
  33676. */
  33677. /**
  33678. * Linear continuous scale
  33679. * http://en.wikipedia.org/wiki/Level_of_measurement
  33680. */
  33681. // FIXME only one data
  33682. var OrdinalScale =
  33683. /** @class */
  33684. function (_super) {
  33685. __extends(OrdinalScale, _super);
  33686. function OrdinalScale(setting) {
  33687. var _this = _super.call(this, setting) || this;
  33688. _this.type = 'ordinal';
  33689. var ordinalMeta = _this.getSetting('ordinalMeta'); // Caution: Should not use instanceof, consider ec-extensions using
  33690. // import approach to get OrdinalMeta class.
  33691. if (!ordinalMeta) {
  33692. ordinalMeta = new OrdinalMeta({});
  33693. }
  33694. if (isArray(ordinalMeta)) {
  33695. ordinalMeta = new OrdinalMeta({
  33696. categories: map(ordinalMeta, function (item) {
  33697. return isObject$1(item) ? item.value : item;
  33698. })
  33699. });
  33700. }
  33701. _this._ordinalMeta = ordinalMeta;
  33702. _this._extent = _this.getSetting('extent') || [0, ordinalMeta.categories.length - 1];
  33703. return _this;
  33704. }
  33705. OrdinalScale.prototype.parse = function (val) {
  33706. return typeof val === 'string' ? this._ordinalMeta.getOrdinal(val) // val might be float.
  33707. : Math.round(val);
  33708. };
  33709. OrdinalScale.prototype.contain = function (rank) {
  33710. rank = this.parse(rank);
  33711. return contain$2(rank, this._extent) && this._ordinalMeta.categories[rank] != null;
  33712. };
  33713. /**
  33714. * Normalize given rank or name to linear [0, 1]
  33715. * @param val raw ordinal number.
  33716. * @return normalized value in [0, 1].
  33717. */
  33718. OrdinalScale.prototype.normalize = function (val) {
  33719. val = this._getTickNumber(this.parse(val));
  33720. return normalize$1(val, this._extent);
  33721. };
  33722. /**
  33723. * @param val normalized value in [0, 1].
  33724. * @return raw ordinal number.
  33725. */
  33726. OrdinalScale.prototype.scale = function (val) {
  33727. val = Math.round(scale$2(val, this._extent));
  33728. return this.getRawOrdinalNumber(val);
  33729. };
  33730. OrdinalScale.prototype.getTicks = function () {
  33731. var ticks = [];
  33732. var extent = this._extent;
  33733. var rank = extent[0];
  33734. while (rank <= extent[1]) {
  33735. ticks.push({
  33736. value: rank
  33737. });
  33738. rank++;
  33739. }
  33740. return ticks;
  33741. };
  33742. OrdinalScale.prototype.getMinorTicks = function (splitNumber) {
  33743. // Not support.
  33744. return;
  33745. };
  33746. /**
  33747. * @see `Ordinal['_ordinalNumbersByTick']`
  33748. */
  33749. OrdinalScale.prototype.setSortInfo = function (info) {
  33750. if (info == null) {
  33751. this._ordinalNumbersByTick = this._ticksByOrdinalNumber = null;
  33752. return;
  33753. }
  33754. var infoOrdinalNumbers = info.ordinalNumbers;
  33755. var ordinalsByTick = this._ordinalNumbersByTick = [];
  33756. var ticksByOrdinal = this._ticksByOrdinalNumber = []; // Unnecessary support negative tick in `realtimeSort`.
  33757. var tickNum = 0;
  33758. var allCategoryLen = this._ordinalMeta.categories.length;
  33759. for (var len = Math.min(allCategoryLen, infoOrdinalNumbers.length); tickNum < len; ++tickNum) {
  33760. var ordinalNumber = infoOrdinalNumbers[tickNum];
  33761. ordinalsByTick[tickNum] = ordinalNumber;
  33762. ticksByOrdinal[ordinalNumber] = tickNum;
  33763. } // Handle that `series.data` only covers part of the `axis.category.data`.
  33764. var unusedOrdinal = 0;
  33765. for (; tickNum < allCategoryLen; ++tickNum) {
  33766. while (ticksByOrdinal[unusedOrdinal] != null) {
  33767. unusedOrdinal++;
  33768. }
  33769. ordinalsByTick.push(unusedOrdinal);
  33770. ticksByOrdinal[unusedOrdinal] = tickNum;
  33771. }
  33772. };
  33773. OrdinalScale.prototype._getTickNumber = function (ordinal) {
  33774. var ticksByOrdinalNumber = this._ticksByOrdinalNumber; // also support ordinal out of range of `ordinalMeta.categories.length`,
  33775. // where ordinal numbers are used as tick value directly.
  33776. return ticksByOrdinalNumber && ordinal >= 0 && ordinal < ticksByOrdinalNumber.length ? ticksByOrdinalNumber[ordinal] : ordinal;
  33777. };
  33778. /**
  33779. * @usage
  33780. * ```js
  33781. * const ordinalNumber = ordinalScale.getRawOrdinalNumber(tickVal);
  33782. *
  33783. * // case0
  33784. * const rawOrdinalValue = axisModel.getCategories()[ordinalNumber];
  33785. * // case1
  33786. * const rawOrdinalValue = this._ordinalMeta.categories[ordinalNumber];
  33787. * // case2
  33788. * const coord = axis.dataToCoord(ordinalNumber);
  33789. * ```
  33790. *
  33791. * @param {OrdinalNumber} tickNumber index of display
  33792. */
  33793. OrdinalScale.prototype.getRawOrdinalNumber = function (tickNumber) {
  33794. var ordinalNumbersByTick = this._ordinalNumbersByTick; // tickNumber may be out of range, e.g., when axis max is larger than `ordinalMeta.categories.length`.,
  33795. // where ordinal numbers are used as tick value directly.
  33796. return ordinalNumbersByTick && tickNumber >= 0 && tickNumber < ordinalNumbersByTick.length ? ordinalNumbersByTick[tickNumber] : tickNumber;
  33797. };
  33798. /**
  33799. * Get item on tick
  33800. */
  33801. OrdinalScale.prototype.getLabel = function (tick) {
  33802. if (!this.isBlank()) {
  33803. var ordinalNumber = this.getRawOrdinalNumber(tick.value);
  33804. var cateogry = this._ordinalMeta.categories[ordinalNumber]; // Note that if no data, ordinalMeta.categories is an empty array.
  33805. // Return empty if it's not exist.
  33806. return cateogry == null ? '' : cateogry + '';
  33807. }
  33808. };
  33809. OrdinalScale.prototype.count = function () {
  33810. return this._extent[1] - this._extent[0] + 1;
  33811. };
  33812. OrdinalScale.prototype.unionExtentFromData = function (data, dim) {
  33813. this.unionExtent(data.getApproximateExtent(dim));
  33814. };
  33815. /**
  33816. * @override
  33817. * If value is in extent range
  33818. */
  33819. OrdinalScale.prototype.isInExtentRange = function (value) {
  33820. value = this._getTickNumber(value);
  33821. return this._extent[0] <= value && this._extent[1] >= value;
  33822. };
  33823. OrdinalScale.prototype.getOrdinalMeta = function () {
  33824. return this._ordinalMeta;
  33825. };
  33826. OrdinalScale.prototype.niceTicks = function () {};
  33827. OrdinalScale.prototype.niceExtent = function () {};
  33828. OrdinalScale.type = 'ordinal';
  33829. return OrdinalScale;
  33830. }(Scale);
  33831. Scale.registerClass(OrdinalScale);
  33832. /*
  33833. * Licensed to the Apache Software Foundation (ASF) under one
  33834. * or more contributor license agreements. See the NOTICE file
  33835. * distributed with this work for additional information
  33836. * regarding copyright ownership. The ASF licenses this file
  33837. * to you under the Apache License, Version 2.0 (the
  33838. * "License"); you may not use this file except in compliance
  33839. * with the License. You may obtain a copy of the License at
  33840. *
  33841. * http://www.apache.org/licenses/LICENSE-2.0
  33842. *
  33843. * Unless required by applicable law or agreed to in writing,
  33844. * software distributed under the License is distributed on an
  33845. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33846. * KIND, either express or implied. See the License for the
  33847. * specific language governing permissions and limitations
  33848. * under the License.
  33849. */
  33850. /**
  33851. * AUTO-GENERATED FILE. DO NOT MODIFY.
  33852. */
  33853. /*
  33854. * Licensed to the Apache Software Foundation (ASF) under one
  33855. * or more contributor license agreements. See the NOTICE file
  33856. * distributed with this work for additional information
  33857. * regarding copyright ownership. The ASF licenses this file
  33858. * to you under the Apache License, Version 2.0 (the
  33859. * "License"); you may not use this file except in compliance
  33860. * with the License. You may obtain a copy of the License at
  33861. *
  33862. * http://www.apache.org/licenses/LICENSE-2.0
  33863. *
  33864. * Unless required by applicable law or agreed to in writing,
  33865. * software distributed under the License is distributed on an
  33866. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  33867. * KIND, either express or implied. See the License for the
  33868. * specific language governing permissions and limitations
  33869. * under the License.
  33870. */
  33871. var roundNumber$1 = round;
  33872. var IntervalScale =
  33873. /** @class */
  33874. function (_super) {
  33875. __extends(IntervalScale, _super);
  33876. function IntervalScale() {
  33877. var _this = _super !== null && _super.apply(this, arguments) || this;
  33878. _this.type = 'interval'; // Step is calculated in adjustExtent.
  33879. _this._interval = 0;
  33880. _this._intervalPrecision = 2;
  33881. return _this;
  33882. }
  33883. IntervalScale.prototype.parse = function (val) {
  33884. return val;
  33885. };
  33886. IntervalScale.prototype.contain = function (val) {
  33887. return contain$2(val, this._extent);
  33888. };
  33889. IntervalScale.prototype.normalize = function (val) {
  33890. return normalize$1(val, this._extent);
  33891. };
  33892. IntervalScale.prototype.scale = function (val) {
  33893. return scale$2(val, this._extent);
  33894. };
  33895. IntervalScale.prototype.setExtent = function (start, end) {
  33896. var thisExtent = this._extent; // start,end may be a Number like '25',so...
  33897. if (!isNaN(start)) {
  33898. thisExtent[0] = parseFloat(start);
  33899. }
  33900. if (!isNaN(end)) {
  33901. thisExtent[1] = parseFloat(end);
  33902. }
  33903. };
  33904. IntervalScale.prototype.unionExtent = function (other) {
  33905. var extent = this._extent;
  33906. other[0] < extent[0] && (extent[0] = other[0]);
  33907. other[1] > extent[1] && (extent[1] = other[1]); // unionExtent may called by it's sub classes
  33908. this.setExtent(extent[0], extent[1]);
  33909. };
  33910. IntervalScale.prototype.getInterval = function () {
  33911. return this._interval;
  33912. };
  33913. IntervalScale.prototype.setInterval = function (interval) {
  33914. this._interval = interval; // Dropped auto calculated niceExtent and use user setted extent
  33915. // We assume user wan't to set both interval, min, max to get a better result
  33916. this._niceExtent = this._extent.slice();
  33917. this._intervalPrecision = getIntervalPrecision(interval);
  33918. };
  33919. /**
  33920. * @param expandToNicedExtent Whether expand the ticks to niced extent.
  33921. */
  33922. IntervalScale.prototype.getTicks = function (expandToNicedExtent) {
  33923. var interval = this._interval;
  33924. var extent = this._extent;
  33925. var niceTickExtent = this._niceExtent;
  33926. var intervalPrecision = this._intervalPrecision;
  33927. var ticks = []; // If interval is 0, return [];
  33928. if (!interval) {
  33929. return ticks;
  33930. } // Consider this case: using dataZoom toolbox, zoom and zoom.
  33931. var safeLimit = 10000;
  33932. if (extent[0] < niceTickExtent[0]) {
  33933. if (expandToNicedExtent) {
  33934. ticks.push({
  33935. value: roundNumber$1(niceTickExtent[0] - interval, intervalPrecision)
  33936. });
  33937. } else {
  33938. ticks.push({
  33939. value: extent[0]
  33940. });
  33941. }
  33942. }
  33943. var tick = niceTickExtent[0];
  33944. while (tick <= niceTickExtent[1]) {
  33945. ticks.push({
  33946. value: tick
  33947. }); // Avoid rounding error
  33948. tick = roundNumber$1(tick + interval, intervalPrecision);
  33949. if (tick === ticks[ticks.length - 1].value) {
  33950. // Consider out of safe float point, e.g.,
  33951. // -3711126.9907707 + 2e-10 === -3711126.9907707
  33952. break;
  33953. }
  33954. if (ticks.length > safeLimit) {
  33955. return [];
  33956. }
  33957. } // Consider this case: the last item of ticks is smaller
  33958. // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
  33959. var lastNiceTick = ticks.length ? ticks[ticks.length - 1].value : niceTickExtent[1];
  33960. if (extent[1] > lastNiceTick) {
  33961. if (expandToNicedExtent) {
  33962. ticks.push({
  33963. value: roundNumber$1(lastNiceTick + interval, intervalPrecision)
  33964. });
  33965. } else {
  33966. ticks.push({
  33967. value: extent[1]
  33968. });
  33969. }
  33970. }
  33971. return ticks;
  33972. };
  33973. IntervalScale.prototype.getMinorTicks = function (splitNumber) {
  33974. var ticks = this.getTicks(true);
  33975. var minorTicks = [];
  33976. var extent = this.getExtent();
  33977. for (var i = 1; i < ticks.length; i++) {
  33978. var nextTick = ticks[i];
  33979. var prevTick = ticks[i - 1];
  33980. var count = 0;
  33981. var minorTicksGroup = [];
  33982. var interval = nextTick.value - prevTick.value;
  33983. var minorInterval = interval / splitNumber;
  33984. while (count < splitNumber - 1) {
  33985. var minorTick = roundNumber$1(prevTick.value + (count + 1) * minorInterval); // For the first and last interval. The count may be less than splitNumber.
  33986. if (minorTick > extent[0] && minorTick < extent[1]) {
  33987. minorTicksGroup.push(minorTick);
  33988. }
  33989. count++;
  33990. }
  33991. minorTicks.push(minorTicksGroup);
  33992. }
  33993. return minorTicks;
  33994. };
  33995. /**
  33996. * @param opt.precision If 'auto', use nice presision.
  33997. * @param opt.pad returns 1.50 but not 1.5 if precision is 2.
  33998. */
  33999. IntervalScale.prototype.getLabel = function (data, opt) {
  34000. if (data == null) {
  34001. return '';
  34002. }
  34003. var precision = opt && opt.precision;
  34004. if (precision == null) {
  34005. precision = getPrecisionSafe(data.value) || 0;
  34006. } else if (precision === 'auto') {
  34007. // Should be more precise then tick.
  34008. precision = this._intervalPrecision;
  34009. } // (1) If `precision` is set, 12.005 should be display as '12.00500'.
  34010. // (2) Use roundNumber (toFixed) to avoid scientific notation like '3.5e-7'.
  34011. var dataNum = roundNumber$1(data.value, precision, true);
  34012. return addCommas(dataNum);
  34013. };
  34014. /**
  34015. * @param splitNumber By default `5`.
  34016. */
  34017. IntervalScale.prototype.niceTicks = function (splitNumber, minInterval, maxInterval) {
  34018. splitNumber = splitNumber || 5;
  34019. var extent = this._extent;
  34020. var span = extent[1] - extent[0];
  34021. if (!isFinite(span)) {
  34022. return;
  34023. } // User may set axis min 0 and data are all negative
  34024. // FIXME If it needs to reverse ?
  34025. if (span < 0) {
  34026. span = -span;
  34027. extent.reverse();
  34028. }
  34029. var result = intervalScaleNiceTicks(extent, splitNumber, minInterval, maxInterval);
  34030. this._intervalPrecision = result.intervalPrecision;
  34031. this._interval = result.interval;
  34032. this._niceExtent = result.niceTickExtent;
  34033. };
  34034. IntervalScale.prototype.niceExtent = function (opt) {
  34035. var extent = this._extent; // If extent start and end are same, expand them
  34036. if (extent[0] === extent[1]) {
  34037. if (extent[0] !== 0) {
  34038. // Expand extent
  34039. var expandSize = extent[0]; // In the fowllowing case
  34040. // Axis has been fixed max 100
  34041. // Plus data are all 100 and axis extent are [100, 100].
  34042. // Extend to the both side will cause expanded max is larger than fixed max.
  34043. // So only expand to the smaller side.
  34044. if (!opt.fixMax) {
  34045. extent[1] += expandSize / 2;
  34046. extent[0] -= expandSize / 2;
  34047. } else {
  34048. extent[0] -= expandSize / 2;
  34049. }
  34050. } else {
  34051. extent[1] = 1;
  34052. }
  34053. }
  34054. var span = extent[1] - extent[0]; // If there are no data and extent are [Infinity, -Infinity]
  34055. if (!isFinite(span)) {
  34056. extent[0] = 0;
  34057. extent[1] = 1;
  34058. }
  34059. this.niceTicks(opt.splitNumber, opt.minInterval, opt.maxInterval); // let extent = this._extent;
  34060. var interval = this._interval;
  34061. if (!opt.fixMin) {
  34062. extent[0] = roundNumber$1(Math.floor(extent[0] / interval) * interval);
  34063. }
  34064. if (!opt.fixMax) {
  34065. extent[1] = roundNumber$1(Math.ceil(extent[1] / interval) * interval);
  34066. }
  34067. };
  34068. IntervalScale.type = 'interval';
  34069. return IntervalScale;
  34070. }(Scale);
  34071. Scale.registerClass(IntervalScale);
  34072. /*
  34073. * Licensed to the Apache Software Foundation (ASF) under one
  34074. * or more contributor license agreements. See the NOTICE file
  34075. * distributed with this work for additional information
  34076. * regarding copyright ownership. The ASF licenses this file
  34077. * to you under the Apache License, Version 2.0 (the
  34078. * "License"); you may not use this file except in compliance
  34079. * with the License. You may obtain a copy of the License at
  34080. *
  34081. * http://www.apache.org/licenses/LICENSE-2.0
  34082. *
  34083. * Unless required by applicable law or agreed to in writing,
  34084. * software distributed under the License is distributed on an
  34085. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  34086. * KIND, either express or implied. See the License for the
  34087. * specific language governing permissions and limitations
  34088. * under the License.
  34089. */
  34090. /**
  34091. * AUTO-GENERATED FILE. DO NOT MODIFY.
  34092. */
  34093. /*
  34094. * Licensed to the Apache Software Foundation (ASF) under one
  34095. * or more contributor license agreements. See the NOTICE file
  34096. * distributed with this work for additional information
  34097. * regarding copyright ownership. The ASF licenses this file
  34098. * to you under the Apache License, Version 2.0 (the
  34099. * "License"); you may not use this file except in compliance
  34100. * with the License. You may obtain a copy of the License at
  34101. *
  34102. * http://www.apache.org/licenses/LICENSE-2.0
  34103. *
  34104. * Unless required by applicable law or agreed to in writing,
  34105. * software distributed under the License is distributed on an
  34106. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  34107. * KIND, either express or implied. See the License for the
  34108. * specific language governing permissions and limitations
  34109. * under the License.
  34110. */
  34111. /* global Float32Array */
  34112. var STACK_PREFIX = '__ec_stack_';
  34113. var LARGE_BAR_MIN_WIDTH = 0.5;
  34114. var LargeArr = typeof Float32Array !== 'undefined' ? Float32Array : Array;
  34115. function getSeriesStackId(seriesModel) {
  34116. return seriesModel.get('stack') || STACK_PREFIX + seriesModel.seriesIndex;
  34117. }
  34118. function getAxisKey(axis) {
  34119. return axis.dim + axis.index;
  34120. }
  34121. /**
  34122. * @return {Object} {width, offset, offsetCenter} If axis.type is not 'category', return undefined.
  34123. */
  34124. function getLayoutOnAxis(opt) {
  34125. var params = [];
  34126. var baseAxis = opt.axis;
  34127. var axisKey = 'axis0';
  34128. if (baseAxis.type !== 'category') {
  34129. return;
  34130. }
  34131. var bandWidth = baseAxis.getBandWidth();
  34132. for (var i = 0; i < opt.count || 0; i++) {
  34133. params.push(defaults({
  34134. bandWidth: bandWidth,
  34135. axisKey: axisKey,
  34136. stackId: STACK_PREFIX + i
  34137. }, opt));
  34138. }
  34139. var widthAndOffsets = doCalBarWidthAndOffset(params);
  34140. var result = [];
  34141. for (var i = 0; i < opt.count; i++) {
  34142. var item = widthAndOffsets[axisKey][STACK_PREFIX + i];
  34143. item.offsetCenter = item.offset + item.width / 2;
  34144. result.push(item);
  34145. }
  34146. return result;
  34147. }
  34148. function prepareLayoutBarSeries(seriesType, ecModel) {
  34149. var seriesModels = [];
  34150. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  34151. // Check series coordinate, do layout for cartesian2d only
  34152. if (isOnCartesian(seriesModel) && !isInLargeMode(seriesModel)) {
  34153. seriesModels.push(seriesModel);
  34154. }
  34155. });
  34156. return seriesModels;
  34157. }
  34158. /**
  34159. * Map from (baseAxis.dim + '_' + baseAxis.index) to min gap of two adjacent
  34160. * values.
  34161. * This works for time axes, value axes, and log axes.
  34162. * For a single time axis, return value is in the form like
  34163. * {'x_0': [1000000]}.
  34164. * The value of 1000000 is in milliseconds.
  34165. */
  34166. function getValueAxesMinGaps(barSeries) {
  34167. /**
  34168. * Map from axis.index to values.
  34169. * For a single time axis, axisValues is in the form like
  34170. * {'x_0': [1495555200000, 1495641600000, 1495728000000]}.
  34171. * Items in axisValues[x], e.g. 1495555200000, are time values of all
  34172. * series.
  34173. */
  34174. var axisValues = {};
  34175. each$1(barSeries, function (seriesModel) {
  34176. var cartesian = seriesModel.coordinateSystem;
  34177. var baseAxis = cartesian.getBaseAxis();
  34178. if (baseAxis.type !== 'time' && baseAxis.type !== 'value') {
  34179. return;
  34180. }
  34181. var data = seriesModel.getData();
  34182. var key = baseAxis.dim + '_' + baseAxis.index;
  34183. var dim = data.mapDimension(baseAxis.dim);
  34184. for (var i = 0, cnt = data.count(); i < cnt; ++i) {
  34185. var value = data.get(dim, i);
  34186. if (!axisValues[key]) {
  34187. // No previous data for the axis
  34188. axisValues[key] = [value];
  34189. } else {
  34190. // No value in previous series
  34191. axisValues[key].push(value);
  34192. } // Ignore duplicated time values in the same axis
  34193. }
  34194. });
  34195. var axisMinGaps = {};
  34196. for (var key in axisValues) {
  34197. if (axisValues.hasOwnProperty(key)) {
  34198. var valuesInAxis = axisValues[key];
  34199. if (valuesInAxis) {
  34200. // Sort axis values into ascending order to calculate gaps
  34201. valuesInAxis.sort(function (a, b) {
  34202. return a - b;
  34203. });
  34204. var min = null;
  34205. for (var j = 1; j < valuesInAxis.length; ++j) {
  34206. var delta = valuesInAxis[j] - valuesInAxis[j - 1];
  34207. if (delta > 0) {
  34208. // Ignore 0 delta because they are of the same axis value
  34209. min = min === null ? delta : Math.min(min, delta);
  34210. }
  34211. } // Set to null if only have one data
  34212. axisMinGaps[key] = min;
  34213. }
  34214. }
  34215. }
  34216. return axisMinGaps;
  34217. }
  34218. function makeColumnLayout(barSeries) {
  34219. var axisMinGaps = getValueAxesMinGaps(barSeries);
  34220. var seriesInfoList = [];
  34221. each$1(barSeries, function (seriesModel) {
  34222. var cartesian = seriesModel.coordinateSystem;
  34223. var baseAxis = cartesian.getBaseAxis();
  34224. var axisExtent = baseAxis.getExtent();
  34225. var bandWidth;
  34226. if (baseAxis.type === 'category') {
  34227. bandWidth = baseAxis.getBandWidth();
  34228. } else if (baseAxis.type === 'value' || baseAxis.type === 'time') {
  34229. var key = baseAxis.dim + '_' + baseAxis.index;
  34230. var minGap = axisMinGaps[key];
  34231. var extentSpan = Math.abs(axisExtent[1] - axisExtent[0]);
  34232. var scale = baseAxis.scale.getExtent();
  34233. var scaleSpan = Math.abs(scale[1] - scale[0]);
  34234. bandWidth = minGap ? extentSpan / scaleSpan * minGap : extentSpan; // When there is only one data value
  34235. } else {
  34236. var data = seriesModel.getData();
  34237. bandWidth = Math.abs(axisExtent[1] - axisExtent[0]) / data.count();
  34238. }
  34239. var barWidth = parsePercent$1(seriesModel.get('barWidth'), bandWidth);
  34240. var barMaxWidth = parsePercent$1(seriesModel.get('barMaxWidth'), bandWidth);
  34241. var barMinWidth = parsePercent$1( // barMinWidth by default is 1 in cartesian. Because in value axis,
  34242. // the auto-calculated bar width might be less than 1.
  34243. seriesModel.get('barMinWidth') || 1, bandWidth);
  34244. var barGap = seriesModel.get('barGap');
  34245. var barCategoryGap = seriesModel.get('barCategoryGap');
  34246. seriesInfoList.push({
  34247. bandWidth: bandWidth,
  34248. barWidth: barWidth,
  34249. barMaxWidth: barMaxWidth,
  34250. barMinWidth: barMinWidth,
  34251. barGap: barGap,
  34252. barCategoryGap: barCategoryGap,
  34253. axisKey: getAxisKey(baseAxis),
  34254. stackId: getSeriesStackId(seriesModel)
  34255. });
  34256. });
  34257. return doCalBarWidthAndOffset(seriesInfoList);
  34258. }
  34259. function doCalBarWidthAndOffset(seriesInfoList) {
  34260. // Columns info on each category axis. Key is cartesian name
  34261. var columnsMap = {};
  34262. each$1(seriesInfoList, function (seriesInfo, idx) {
  34263. var axisKey = seriesInfo.axisKey;
  34264. var bandWidth = seriesInfo.bandWidth;
  34265. var columnsOnAxis = columnsMap[axisKey] || {
  34266. bandWidth: bandWidth,
  34267. remainedWidth: bandWidth,
  34268. autoWidthCount: 0,
  34269. categoryGap: null,
  34270. gap: '20%',
  34271. stacks: {}
  34272. };
  34273. var stacks = columnsOnAxis.stacks;
  34274. columnsMap[axisKey] = columnsOnAxis;
  34275. var stackId = seriesInfo.stackId;
  34276. if (!stacks[stackId]) {
  34277. columnsOnAxis.autoWidthCount++;
  34278. }
  34279. stacks[stackId] = stacks[stackId] || {
  34280. width: 0,
  34281. maxWidth: 0
  34282. }; // Caution: In a single coordinate system, these barGrid attributes
  34283. // will be shared by series. Consider that they have default values,
  34284. // only the attributes set on the last series will work.
  34285. // Do not change this fact unless there will be a break change.
  34286. var barWidth = seriesInfo.barWidth;
  34287. if (barWidth && !stacks[stackId].width) {
  34288. // See #6312, do not restrict width.
  34289. stacks[stackId].width = barWidth;
  34290. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  34291. columnsOnAxis.remainedWidth -= barWidth;
  34292. }
  34293. var barMaxWidth = seriesInfo.barMaxWidth;
  34294. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  34295. var barMinWidth = seriesInfo.barMinWidth;
  34296. barMinWidth && (stacks[stackId].minWidth = barMinWidth);
  34297. var barGap = seriesInfo.barGap;
  34298. barGap != null && (columnsOnAxis.gap = barGap);
  34299. var barCategoryGap = seriesInfo.barCategoryGap;
  34300. barCategoryGap != null && (columnsOnAxis.categoryGap = barCategoryGap);
  34301. });
  34302. var result = {};
  34303. each$1(columnsMap, function (columnsOnAxis, coordSysName) {
  34304. result[coordSysName] = {};
  34305. var stacks = columnsOnAxis.stacks;
  34306. var bandWidth = columnsOnAxis.bandWidth;
  34307. var categoryGapPercent = columnsOnAxis.categoryGap;
  34308. if (categoryGapPercent == null) {
  34309. var columnCount = keys(stacks).length; // More columns in one group
  34310. // the spaces between group is smaller. Or the column will be too thin.
  34311. categoryGapPercent = Math.max(35 - columnCount * 4, 15) + '%';
  34312. }
  34313. var categoryGap = parsePercent$1(categoryGapPercent, bandWidth);
  34314. var barGapPercent = parsePercent$1(columnsOnAxis.gap, 1);
  34315. var remainedWidth = columnsOnAxis.remainedWidth;
  34316. var autoWidthCount = columnsOnAxis.autoWidthCount;
  34317. var autoWidth = (remainedWidth - categoryGap) / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  34318. autoWidth = Math.max(autoWidth, 0); // Find if any auto calculated bar exceeded maxBarWidth
  34319. each$1(stacks, function (column) {
  34320. var maxWidth = column.maxWidth;
  34321. var minWidth = column.minWidth;
  34322. if (!column.width) {
  34323. var finalWidth = autoWidth;
  34324. if (maxWidth && maxWidth < finalWidth) {
  34325. finalWidth = Math.min(maxWidth, remainedWidth);
  34326. } // `minWidth` has higher priority. `minWidth` decide that wheter the
  34327. // bar is able to be visible. So `minWidth` should not be restricted
  34328. // by `maxWidth` or `remainedWidth` (which is from `bandWidth`). In
  34329. // the extreme cases for `value` axis, bars are allowed to overlap
  34330. // with each other if `minWidth` specified.
  34331. if (minWidth && minWidth > finalWidth) {
  34332. finalWidth = minWidth;
  34333. }
  34334. if (finalWidth !== autoWidth) {
  34335. column.width = finalWidth;
  34336. remainedWidth -= finalWidth + barGapPercent * finalWidth;
  34337. autoWidthCount--;
  34338. }
  34339. } else {
  34340. // `barMinWidth/barMaxWidth` has higher priority than `barWidth`, as
  34341. // CSS does. Becuase barWidth can be a percent value, where
  34342. // `barMaxWidth` can be used to restrict the final width.
  34343. var finalWidth = column.width;
  34344. if (maxWidth) {
  34345. finalWidth = Math.min(finalWidth, maxWidth);
  34346. } // `minWidth` has higher priority, as described above
  34347. if (minWidth) {
  34348. finalWidth = Math.max(finalWidth, minWidth);
  34349. }
  34350. column.width = finalWidth;
  34351. remainedWidth -= finalWidth + barGapPercent * finalWidth;
  34352. autoWidthCount--;
  34353. }
  34354. }); // Recalculate width again
  34355. autoWidth = (remainedWidth - categoryGap) / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  34356. autoWidth = Math.max(autoWidth, 0);
  34357. var widthSum = 0;
  34358. var lastColumn;
  34359. each$1(stacks, function (column, idx) {
  34360. if (!column.width) {
  34361. column.width = autoWidth;
  34362. }
  34363. lastColumn = column;
  34364. widthSum += column.width * (1 + barGapPercent);
  34365. });
  34366. if (lastColumn) {
  34367. widthSum -= lastColumn.width * barGapPercent;
  34368. }
  34369. var offset = -widthSum / 2;
  34370. each$1(stacks, function (column, stackId) {
  34371. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  34372. bandWidth: bandWidth,
  34373. offset: offset,
  34374. width: column.width
  34375. };
  34376. offset += column.width * (1 + barGapPercent);
  34377. });
  34378. });
  34379. return result;
  34380. }
  34381. function retrieveColumnLayout(barWidthAndOffset, axis, seriesModel) {
  34382. if (barWidthAndOffset && axis) {
  34383. var result = barWidthAndOffset[getAxisKey(axis)];
  34384. if (result != null && seriesModel != null) {
  34385. return result[getSeriesStackId(seriesModel)];
  34386. }
  34387. return result;
  34388. }
  34389. }
  34390. function layout(seriesType, ecModel) {
  34391. var seriesModels = prepareLayoutBarSeries(seriesType, ecModel);
  34392. var barWidthAndOffset = makeColumnLayout(seriesModels);
  34393. var lastStackCoords = {};
  34394. each$1(seriesModels, function (seriesModel) {
  34395. var data = seriesModel.getData();
  34396. var cartesian = seriesModel.coordinateSystem;
  34397. var baseAxis = cartesian.getBaseAxis();
  34398. var stackId = getSeriesStackId(seriesModel);
  34399. var columnLayoutInfo = barWidthAndOffset[getAxisKey(baseAxis)][stackId];
  34400. var columnOffset = columnLayoutInfo.offset;
  34401. var columnWidth = columnLayoutInfo.width;
  34402. var valueAxis = cartesian.getOtherAxis(baseAxis);
  34403. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  34404. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  34405. data.setLayout({
  34406. bandWidth: columnLayoutInfo.bandWidth,
  34407. offset: columnOffset,
  34408. size: columnWidth
  34409. });
  34410. var valueDim = data.mapDimension(valueAxis.dim);
  34411. var baseDim = data.mapDimension(baseAxis.dim);
  34412. var stacked = isDimensionStacked(data, valueDim
  34413. /*, baseDim*/
  34414. );
  34415. var isValueAxisH = valueAxis.isHorizontal();
  34416. var valueAxisStart = getValueAxisStart(baseAxis, valueAxis, stacked);
  34417. for (var idx = 0, len = data.count(); idx < len; idx++) {
  34418. var value = data.get(valueDim, idx);
  34419. var baseValue = data.get(baseDim, idx);
  34420. var sign = value >= 0 ? 'p' : 'n';
  34421. var baseCoord = valueAxisStart; // Because of the barMinHeight, we can not use the value in
  34422. // stackResultDimension directly.
  34423. if (stacked) {
  34424. // Only ordinal axis can be stacked.
  34425. if (!lastStackCoords[stackId][baseValue]) {
  34426. lastStackCoords[stackId][baseValue] = {
  34427. p: valueAxisStart,
  34428. n: valueAxisStart // Negative stack
  34429. };
  34430. } // Should also consider #4243
  34431. baseCoord = lastStackCoords[stackId][baseValue][sign];
  34432. }
  34433. var x = void 0;
  34434. var y = void 0;
  34435. var width = void 0;
  34436. var height = void 0;
  34437. if (isValueAxisH) {
  34438. var coord = cartesian.dataToPoint([value, baseValue]);
  34439. x = baseCoord;
  34440. y = coord[1] + columnOffset;
  34441. width = coord[0] - valueAxisStart;
  34442. height = columnWidth;
  34443. if (Math.abs(width) < barMinHeight) {
  34444. width = (width < 0 ? -1 : 1) * barMinHeight;
  34445. } // Ignore stack from NaN value
  34446. if (!isNaN(width)) {
  34447. stacked && (lastStackCoords[stackId][baseValue][sign] += width);
  34448. }
  34449. } else {
  34450. var coord = cartesian.dataToPoint([baseValue, value]);
  34451. x = coord[0] + columnOffset;
  34452. y = baseCoord;
  34453. width = columnWidth;
  34454. height = coord[1] - valueAxisStart;
  34455. if (Math.abs(height) < barMinHeight) {
  34456. // Include zero to has a positive bar
  34457. height = (height <= 0 ? -1 : 1) * barMinHeight;
  34458. } // Ignore stack from NaN value
  34459. if (!isNaN(height)) {
  34460. stacked && (lastStackCoords[stackId][baseValue][sign] += height);
  34461. }
  34462. }
  34463. data.setItemLayout(idx, {
  34464. x: x,
  34465. y: y,
  34466. width: width,
  34467. height: height
  34468. });
  34469. }
  34470. });
  34471. } // TODO: Do not support stack in large mode yet.
  34472. var largeLayout = {
  34473. seriesType: 'bar',
  34474. plan: createRenderPlanner(),
  34475. reset: function (seriesModel) {
  34476. if (!isOnCartesian(seriesModel) || !isInLargeMode(seriesModel)) {
  34477. return;
  34478. }
  34479. var data = seriesModel.getData();
  34480. var cartesian = seriesModel.coordinateSystem;
  34481. var coordLayout = cartesian.master.getRect();
  34482. var baseAxis = cartesian.getBaseAxis();
  34483. var valueAxis = cartesian.getOtherAxis(baseAxis);
  34484. var valueDim = data.mapDimension(valueAxis.dim);
  34485. var baseDim = data.mapDimension(baseAxis.dim);
  34486. var valueAxisHorizontal = valueAxis.isHorizontal();
  34487. var valueDimIdx = valueAxisHorizontal ? 0 : 1;
  34488. var barWidth = retrieveColumnLayout(makeColumnLayout([seriesModel]), baseAxis, seriesModel).width;
  34489. if (!(barWidth > LARGE_BAR_MIN_WIDTH)) {
  34490. // jshint ignore:line
  34491. barWidth = LARGE_BAR_MIN_WIDTH;
  34492. }
  34493. return {
  34494. progress: function (params, data) {
  34495. var count = params.count;
  34496. var largePoints = new LargeArr(count * 2);
  34497. var largeBackgroundPoints = new LargeArr(count * 2);
  34498. var largeDataIndices = new LargeArr(count);
  34499. var dataIndex;
  34500. var coord = [];
  34501. var valuePair = [];
  34502. var pointsOffset = 0;
  34503. var idxOffset = 0;
  34504. while ((dataIndex = params.next()) != null) {
  34505. valuePair[valueDimIdx] = data.get(valueDim, dataIndex);
  34506. valuePair[1 - valueDimIdx] = data.get(baseDim, dataIndex);
  34507. coord = cartesian.dataToPoint(valuePair, null, coord); // Data index might not be in order, depends on `progressiveChunkMode`.
  34508. largeBackgroundPoints[pointsOffset] = valueAxisHorizontal ? coordLayout.x + coordLayout.width : coord[0];
  34509. largePoints[pointsOffset++] = coord[0];
  34510. largeBackgroundPoints[pointsOffset] = valueAxisHorizontal ? coord[1] : coordLayout.y + coordLayout.height;
  34511. largePoints[pointsOffset++] = coord[1];
  34512. largeDataIndices[idxOffset++] = dataIndex;
  34513. }
  34514. data.setLayout({
  34515. largePoints: largePoints,
  34516. largeDataIndices: largeDataIndices,
  34517. largeBackgroundPoints: largeBackgroundPoints,
  34518. barWidth: barWidth,
  34519. valueAxisStart: getValueAxisStart(baseAxis, valueAxis, false),
  34520. backgroundStart: valueAxisHorizontal ? coordLayout.x : coordLayout.y,
  34521. valueAxisHorizontal: valueAxisHorizontal
  34522. });
  34523. }
  34524. };
  34525. }
  34526. };
  34527. function isOnCartesian(seriesModel) {
  34528. return seriesModel.coordinateSystem && seriesModel.coordinateSystem.type === 'cartesian2d';
  34529. }
  34530. function isInLargeMode(seriesModel) {
  34531. return seriesModel.pipelineContext && seriesModel.pipelineContext.large;
  34532. } // See cases in `test/bar-start.html` and `#7412`, `#8747`.
  34533. function getValueAxisStart(baseAxis, valueAxis, stacked) {
  34534. return valueAxis.toGlobalCoord(valueAxis.dataToCoord(valueAxis.type === 'log' ? 1 : 0));
  34535. }
  34536. /*
  34537. * Licensed to the Apache Software Foundation (ASF) under one
  34538. * or more contributor license agreements. See the NOTICE file
  34539. * distributed with this work for additional information
  34540. * regarding copyright ownership. The ASF licenses this file
  34541. * to you under the Apache License, Version 2.0 (the
  34542. * "License"); you may not use this file except in compliance
  34543. * with the License. You may obtain a copy of the License at
  34544. *
  34545. * http://www.apache.org/licenses/LICENSE-2.0
  34546. *
  34547. * Unless required by applicable law or agreed to in writing,
  34548. * software distributed under the License is distributed on an
  34549. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  34550. * KIND, either express or implied. See the License for the
  34551. * specific language governing permissions and limitations
  34552. * under the License.
  34553. */
  34554. /**
  34555. * AUTO-GENERATED FILE. DO NOT MODIFY.
  34556. */
  34557. /*
  34558. * Licensed to the Apache Software Foundation (ASF) under one
  34559. * or more contributor license agreements. See the NOTICE file
  34560. * distributed with this work for additional information
  34561. * regarding copyright ownership. The ASF licenses this file
  34562. * to you under the Apache License, Version 2.0 (the
  34563. * "License"); you may not use this file except in compliance
  34564. * with the License. You may obtain a copy of the License at
  34565. *
  34566. * http://www.apache.org/licenses/LICENSE-2.0
  34567. *
  34568. * Unless required by applicable law or agreed to in writing,
  34569. * software distributed under the License is distributed on an
  34570. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  34571. * KIND, either express or implied. See the License for the
  34572. * specific language governing permissions and limitations
  34573. * under the License.
  34574. */
  34575. /*
  34576. * A third-party license is embeded for some of the code in this file:
  34577. * The "scaleLevels" was originally copied from "d3.js" with some
  34578. * modifications made for this project.
  34579. * (See more details in the comment on the definition of "scaleLevels" below.)
  34580. * The use of the source code of this file is also subject to the terms
  34581. * and consitions of the license of "d3.js" (BSD-3Clause, see
  34582. * </licenses/LICENSE-d3>).
  34583. */
  34584. // [About UTC and local time zone]:
  34585. // In most cases, `number.parseDate` will treat input data string as local time
  34586. // (except time zone is specified in time string). And `format.formateTime` returns
  34587. // local time by default. option.useUTC is false by default. This design have
  34588. // concidered these common case:
  34589. // (1) Time that is persistent in server is in UTC, but it is needed to be diplayed
  34590. // in local time by default.
  34591. // (2) By default, the input data string (e.g., '2011-01-02') should be displayed
  34592. // as its original time, without any time difference.
  34593. var bisect = function (a, x, lo, hi) {
  34594. while (lo < hi) {
  34595. var mid = lo + hi >>> 1;
  34596. if (a[mid][1] < x) {
  34597. lo = mid + 1;
  34598. } else {
  34599. hi = mid;
  34600. }
  34601. }
  34602. return lo;
  34603. };
  34604. var TimeScale =
  34605. /** @class */
  34606. function (_super) {
  34607. __extends(TimeScale, _super);
  34608. function TimeScale(settings) {
  34609. var _this = _super.call(this, settings) || this;
  34610. _this.type = 'time';
  34611. return _this;
  34612. }
  34613. /**
  34614. * Get label is mainly for other components like dataZoom, tooltip.
  34615. */
  34616. TimeScale.prototype.getLabel = function (tick) {
  34617. var useUTC = this.getSetting('useUTC');
  34618. return format(tick.value, fullLeveledFormatter[getDefaultFormatPrecisionOfInterval(getPrimaryTimeUnit(this._minLevelUnit))] || fullLeveledFormatter.second, useUTC, this.getSetting('locale'));
  34619. };
  34620. TimeScale.prototype.getFormattedLabel = function (tick, idx, labelFormatter) {
  34621. var isUTC = this.getSetting('useUTC');
  34622. var lang = this.getSetting('locale');
  34623. return leveledFormat(tick, idx, labelFormatter, lang, isUTC);
  34624. };
  34625. /**
  34626. * @override
  34627. * @param expandToNicedExtent Whether expand the ticks to niced extent.
  34628. */
  34629. TimeScale.prototype.getTicks = function (expandToNicedExtent) {
  34630. var interval = this._interval;
  34631. var extent = this._extent;
  34632. var ticks = []; // If interval is 0, return [];
  34633. if (!interval) {
  34634. return ticks;
  34635. }
  34636. ticks.push({
  34637. value: extent[0],
  34638. level: 0
  34639. });
  34640. var useUTC = this.getSetting('useUTC');
  34641. var innerTicks = getIntervalTicks(this._minLevelUnit, this._approxInterval, useUTC, extent);
  34642. ticks = ticks.concat(innerTicks);
  34643. ticks.push({
  34644. value: extent[1],
  34645. level: 0
  34646. });
  34647. return ticks;
  34648. };
  34649. TimeScale.prototype.niceExtent = function (opt) {
  34650. var extent = this._extent; // If extent start and end are same, expand them
  34651. if (extent[0] === extent[1]) {
  34652. // Expand extent
  34653. extent[0] -= ONE_DAY;
  34654. extent[1] += ONE_DAY;
  34655. } // If there are no data and extent are [Infinity, -Infinity]
  34656. if (extent[1] === -Infinity && extent[0] === Infinity) {
  34657. var d = new Date();
  34658. extent[1] = +new Date(d.getFullYear(), d.getMonth(), d.getDate());
  34659. extent[0] = extent[1] - ONE_DAY;
  34660. }
  34661. this.niceTicks(opt.splitNumber, opt.minInterval, opt.maxInterval);
  34662. };
  34663. TimeScale.prototype.niceTicks = function (approxTickNum, minInterval, maxInterval) {
  34664. approxTickNum = approxTickNum || 10;
  34665. var extent = this._extent;
  34666. var span = extent[1] - extent[0];
  34667. this._approxInterval = span / approxTickNum;
  34668. if (minInterval != null && this._approxInterval < minInterval) {
  34669. this._approxInterval = minInterval;
  34670. }
  34671. if (maxInterval != null && this._approxInterval > maxInterval) {
  34672. this._approxInterval = maxInterval;
  34673. }
  34674. var scaleIntervalsLen = scaleIntervals.length;
  34675. var idx = Math.min(bisect(scaleIntervals, this._approxInterval, 0, scaleIntervalsLen), scaleIntervalsLen - 1); // Interval that can be used to calculate ticks
  34676. this._interval = scaleIntervals[idx][1]; // Min level used when picking ticks from top down.
  34677. // We check one more level to avoid the ticks are to sparse in some case.
  34678. this._minLevelUnit = scaleIntervals[Math.max(idx - 1, 0)][0];
  34679. };
  34680. TimeScale.prototype.parse = function (val) {
  34681. // val might be float.
  34682. return typeof val === 'number' ? val : +parseDate(val);
  34683. };
  34684. TimeScale.prototype.contain = function (val) {
  34685. return contain$2(this.parse(val), this._extent);
  34686. };
  34687. TimeScale.prototype.normalize = function (val) {
  34688. return normalize$1(this.parse(val), this._extent);
  34689. };
  34690. TimeScale.prototype.scale = function (val) {
  34691. return scale$2(val, this._extent);
  34692. };
  34693. TimeScale.type = 'time';
  34694. return TimeScale;
  34695. }(IntervalScale);
  34696. /**
  34697. * This implementation was originally copied from "d3.js"
  34698. * <https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/time/scale.js>
  34699. * with some modifications made for this program.
  34700. * See the license statement at the head of this file.
  34701. */
  34702. var scaleIntervals = [// Format interval
  34703. ['second', ONE_SECOND], ['minute', ONE_MINUTE], ['hour', ONE_HOUR], ['quarter-day', ONE_HOUR * 6], ['half-day', ONE_HOUR * 12], ['day', ONE_DAY * 1.2], ['half-week', ONE_DAY * 3.5], ['week', ONE_DAY * 7], ['month', ONE_DAY * 31], ['quarter', ONE_DAY * 95], ['half-year', ONE_YEAR / 2], ['year', ONE_YEAR] // 1Y
  34704. ];
  34705. function isUnitValueSame(unit, valueA, valueB, isUTC) {
  34706. var dateA = parseDate(valueA);
  34707. var dateB = parseDate(valueB);
  34708. var isSame = function (unit) {
  34709. return getUnitValue(dateA, unit, isUTC) === getUnitValue(dateB, unit, isUTC);
  34710. };
  34711. var isSameYear = function () {
  34712. return isSame('year');
  34713. }; // const isSameHalfYear = () => isSameYear() && isSame('half-year');
  34714. // const isSameQuater = () => isSameYear() && isSame('quarter');
  34715. var isSameMonth = function () {
  34716. return isSameYear() && isSame('month');
  34717. };
  34718. var isSameDay = function () {
  34719. return isSameMonth() && isSame('day');
  34720. }; // const isSameHalfDay = () => isSameDay() && isSame('half-day');
  34721. var isSameHour = function () {
  34722. return isSameDay() && isSame('hour');
  34723. };
  34724. var isSameMinute = function () {
  34725. return isSameHour() && isSame('minute');
  34726. };
  34727. var isSameSecond = function () {
  34728. return isSameMinute() && isSame('second');
  34729. };
  34730. var isSameMilliSecond = function () {
  34731. return isSameSecond() && isSame('millisecond');
  34732. };
  34733. switch (unit) {
  34734. case 'year':
  34735. return isSameYear();
  34736. case 'month':
  34737. return isSameMonth();
  34738. case 'day':
  34739. return isSameDay();
  34740. case 'hour':
  34741. return isSameHour();
  34742. case 'minute':
  34743. return isSameMinute();
  34744. case 'second':
  34745. return isSameSecond();
  34746. case 'millisecond':
  34747. return isSameMilliSecond();
  34748. }
  34749. } // const primaryUnitGetters = {
  34750. // year: fullYearGetterName(),
  34751. // month: monthGetterName(),
  34752. // day: dateGetterName(),
  34753. // hour: hoursGetterName(),
  34754. // minute: minutesGetterName(),
  34755. // second: secondsGetterName(),
  34756. // millisecond: millisecondsGetterName()
  34757. // };
  34758. // const primaryUnitUTCGetters = {
  34759. // year: fullYearGetterName(true),
  34760. // month: monthGetterName(true),
  34761. // day: dateGetterName(true),
  34762. // hour: hoursGetterName(true),
  34763. // minute: minutesGetterName(true),
  34764. // second: secondsGetterName(true),
  34765. // millisecond: millisecondsGetterName(true)
  34766. // };
  34767. // function moveTick(date: Date, unitName: TimeUnit, step: number, isUTC: boolean) {
  34768. // step = step || 1;
  34769. // switch (getPrimaryTimeUnit(unitName)) {
  34770. // case 'year':
  34771. // date[fullYearSetterName(isUTC)](date[fullYearGetterName(isUTC)]() + step);
  34772. // break;
  34773. // case 'month':
  34774. // date[monthSetterName(isUTC)](date[monthGetterName(isUTC)]() + step);
  34775. // break;
  34776. // case 'day':
  34777. // date[dateSetterName(isUTC)](date[dateGetterName(isUTC)]() + step);
  34778. // break;
  34779. // case 'hour':
  34780. // date[hoursSetterName(isUTC)](date[hoursGetterName(isUTC)]() + step);
  34781. // break;
  34782. // case 'minute':
  34783. // date[minutesSetterName(isUTC)](date[minutesGetterName(isUTC)]() + step);
  34784. // break;
  34785. // case 'second':
  34786. // date[secondsSetterName(isUTC)](date[secondsGetterName(isUTC)]() + step);
  34787. // break;
  34788. // case 'millisecond':
  34789. // date[millisecondsSetterName(isUTC)](date[millisecondsGetterName(isUTC)]() + step);
  34790. // break;
  34791. // }
  34792. // return date.getTime();
  34793. // }
  34794. // const DATE_INTERVALS = [[8, 7.5], [4, 3.5], [2, 1.5]];
  34795. // const MONTH_INTERVALS = [[6, 5.5], [3, 2.5], [2, 1.5]];
  34796. // const MINUTES_SECONDS_INTERVALS = [[30, 30], [20, 20], [15, 15], [10, 10], [5, 5], [2, 2]];
  34797. function getDateInterval(approxInterval, daysInMonth) {
  34798. approxInterval /= ONE_DAY;
  34799. return approxInterval > 16 ? 16 // Math.floor(daysInMonth / 2) + 1 // In this case we only want one tick betwen two month.
  34800. : approxInterval > 7.5 ? 7 // TODO week 7 or day 8?
  34801. : approxInterval > 3.5 ? 4 : approxInterval > 1.5 ? 2 : 1;
  34802. }
  34803. function getMonthInterval(approxInterval) {
  34804. var APPROX_ONE_MONTH = 30 * ONE_DAY;
  34805. approxInterval /= APPROX_ONE_MONTH;
  34806. return approxInterval > 6 ? 6 : approxInterval > 3 ? 3 : approxInterval > 2 ? 2 : 1;
  34807. }
  34808. function getHourInterval(approxInterval) {
  34809. approxInterval /= ONE_HOUR;
  34810. return approxInterval > 12 ? 12 : approxInterval > 6 ? 6 : approxInterval > 3.5 ? 4 : approxInterval > 2 ? 2 : 1;
  34811. }
  34812. function getMinutesAndSecondsInterval(approxInterval, isMinutes) {
  34813. approxInterval /= isMinutes ? ONE_MINUTE : ONE_SECOND;
  34814. return approxInterval > 30 ? 30 : approxInterval > 20 ? 20 : approxInterval > 15 ? 15 : approxInterval > 10 ? 10 : approxInterval > 5 ? 5 : approxInterval > 2 ? 2 : 1;
  34815. }
  34816. function getMillisecondsInterval(approxInterval) {
  34817. return nice(approxInterval, true);
  34818. }
  34819. function getFirstTimestampOfUnit(date, unitName, isUTC) {
  34820. var outDate = new Date(date);
  34821. switch (getPrimaryTimeUnit(unitName)) {
  34822. case 'year':
  34823. case 'month':
  34824. outDate[monthSetterName(isUTC)](0);
  34825. case 'day':
  34826. outDate[dateSetterName(isUTC)](1);
  34827. case 'hour':
  34828. outDate[hoursSetterName(isUTC)](0);
  34829. case 'minute':
  34830. outDate[minutesSetterName(isUTC)](0);
  34831. case 'second':
  34832. outDate[secondsSetterName(isUTC)](0);
  34833. outDate[millisecondsSetterName(isUTC)](0);
  34834. }
  34835. return outDate.getTime();
  34836. }
  34837. function getIntervalTicks(bottomUnitName, approxInterval, isUTC, extent) {
  34838. var safeLimit = 10000;
  34839. var unitNames = timeUnits;
  34840. var iter = 0;
  34841. function addTicksInSpan(interval, minTimestamp, maxTimestamp, getMethodName, setMethodName, isDate, out) {
  34842. var date = new Date(minTimestamp);
  34843. var dateTime = minTimestamp;
  34844. var d = date[getMethodName](); // if (isDate) {
  34845. // d -= 1; // Starts with 0; PENDING
  34846. // }
  34847. while (dateTime < maxTimestamp && dateTime <= extent[1]) {
  34848. out.push({
  34849. value: dateTime
  34850. });
  34851. d += interval;
  34852. date[setMethodName](d);
  34853. dateTime = date.getTime();
  34854. } // This extra tick is for calcuating ticks of next level. Will not been added to the final result
  34855. out.push({
  34856. value: dateTime,
  34857. notAdd: true
  34858. });
  34859. }
  34860. function addLevelTicks(unitName, lastLevelTicks, levelTicks) {
  34861. var newAddedTicks = [];
  34862. var isFirstLevel = !lastLevelTicks.length;
  34863. if (isUnitValueSame(getPrimaryTimeUnit(unitName), extent[0], extent[1], isUTC)) {
  34864. return;
  34865. }
  34866. if (isFirstLevel) {
  34867. lastLevelTicks = [{
  34868. // TODO Optimize. Not include so may ticks.
  34869. value: getFirstTimestampOfUnit(new Date(extent[0]), unitName, isUTC)
  34870. }, {
  34871. value: extent[1]
  34872. }];
  34873. }
  34874. for (var i = 0; i < lastLevelTicks.length - 1; i++) {
  34875. var startTick = lastLevelTicks[i].value;
  34876. var endTick = lastLevelTicks[i + 1].value;
  34877. if (startTick === endTick) {
  34878. continue;
  34879. }
  34880. var interval = void 0;
  34881. var getterName = void 0;
  34882. var setterName = void 0;
  34883. var isDate = false;
  34884. switch (unitName) {
  34885. case 'year':
  34886. interval = Math.max(1, Math.round(approxInterval / ONE_DAY / 365));
  34887. getterName = fullYearGetterName(isUTC);
  34888. setterName = fullYearSetterName(isUTC);
  34889. break;
  34890. case 'half-year':
  34891. case 'quarter':
  34892. case 'month':
  34893. interval = getMonthInterval(approxInterval);
  34894. getterName = monthGetterName(isUTC);
  34895. setterName = monthSetterName(isUTC);
  34896. break;
  34897. case 'week': // PENDING If week is added. Ignore day.
  34898. case 'half-week':
  34899. case 'day':
  34900. interval = getDateInterval(approxInterval, 31); // Use 32 days and let interval been 16
  34901. getterName = dateGetterName(isUTC);
  34902. setterName = dateSetterName(isUTC);
  34903. isDate = true;
  34904. break;
  34905. case 'half-day':
  34906. case 'quarter-day':
  34907. case 'hour':
  34908. interval = getHourInterval(approxInterval);
  34909. getterName = hoursGetterName(isUTC);
  34910. setterName = hoursSetterName(isUTC);
  34911. break;
  34912. case 'minute':
  34913. interval = getMinutesAndSecondsInterval(approxInterval, true);
  34914. getterName = minutesGetterName(isUTC);
  34915. setterName = minutesSetterName(isUTC);
  34916. break;
  34917. case 'second':
  34918. interval = getMinutesAndSecondsInterval(approxInterval, false);
  34919. getterName = secondsGetterName(isUTC);
  34920. setterName = secondsSetterName(isUTC);
  34921. break;
  34922. case 'millisecond':
  34923. interval = getMillisecondsInterval(approxInterval);
  34924. getterName = millisecondsGetterName(isUTC);
  34925. setterName = millisecondsSetterName(isUTC);
  34926. break;
  34927. }
  34928. addTicksInSpan(interval, startTick, endTick, getterName, setterName, isDate, newAddedTicks);
  34929. if (unitName === 'year' && levelTicks.length > 1 && i === 0) {
  34930. // Add nearest years to the left extent.
  34931. levelTicks.unshift({
  34932. value: levelTicks[0].value - interval
  34933. });
  34934. }
  34935. }
  34936. for (var i = 0; i < newAddedTicks.length; i++) {
  34937. levelTicks.push(newAddedTicks[i]);
  34938. } // newAddedTicks.length && console.log(unitName, newAddedTicks);
  34939. return newAddedTicks;
  34940. }
  34941. var levelsTicks = [];
  34942. var currentLevelTicks = [];
  34943. var tickCount = 0;
  34944. var lastLevelTickCount = 0;
  34945. for (var i = 0; i < unitNames.length && iter++ < safeLimit; ++i) {
  34946. var primaryTimeUnit = getPrimaryTimeUnit(unitNames[i]);
  34947. if (!isPrimaryTimeUnit(unitNames[i])) {
  34948. // TODO
  34949. continue;
  34950. }
  34951. addLevelTicks(unitNames[i], levelsTicks[levelsTicks.length - 1] || [], currentLevelTicks);
  34952. var nextPrimaryTimeUnit = unitNames[i + 1] ? getPrimaryTimeUnit(unitNames[i + 1]) : null;
  34953. if (primaryTimeUnit !== nextPrimaryTimeUnit) {
  34954. if (currentLevelTicks.length) {
  34955. lastLevelTickCount = tickCount; // Remove the duplicate so the tick count can be precisely.
  34956. currentLevelTicks.sort(function (a, b) {
  34957. return a.value - b.value;
  34958. });
  34959. var levelTicksRemoveDuplicated = [];
  34960. for (var i_1 = 0; i_1 < currentLevelTicks.length; ++i_1) {
  34961. var tickValue = currentLevelTicks[i_1].value;
  34962. if (i_1 === 0 || currentLevelTicks[i_1 - 1].value !== tickValue) {
  34963. levelTicksRemoveDuplicated.push(currentLevelTicks[i_1]);
  34964. if (tickValue >= extent[0] && tickValue <= extent[1]) {
  34965. tickCount++;
  34966. }
  34967. }
  34968. }
  34969. var targetTickNum = (extent[1] - extent[0]) / approxInterval; // Added too much in this level and not too less in last level
  34970. if (tickCount > targetTickNum * 1.5 && lastLevelTickCount > targetTickNum / 1.5) {
  34971. break;
  34972. } // Only treat primary time unit as one level.
  34973. levelsTicks.push(levelTicksRemoveDuplicated);
  34974. if (tickCount > targetTickNum || bottomUnitName === unitNames[i]) {
  34975. break;
  34976. }
  34977. } // Reset if next unitName is primary
  34978. currentLevelTicks = [];
  34979. }
  34980. }
  34981. {
  34982. if (iter >= safeLimit) {
  34983. warn('Exceed safe limit.');
  34984. }
  34985. }
  34986. var levelsTicksInExtent = filter(map(levelsTicks, function (levelTicks) {
  34987. return filter(levelTicks, function (tick) {
  34988. return tick.value >= extent[0] && tick.value <= extent[1] && !tick.notAdd;
  34989. });
  34990. }), function (levelTicks) {
  34991. return levelTicks.length > 0;
  34992. });
  34993. var ticks = [];
  34994. var maxLevel = levelsTicksInExtent.length - 1;
  34995. for (var i = 0; i < levelsTicksInExtent.length; ++i) {
  34996. var levelTicks = levelsTicksInExtent[i];
  34997. for (var k = 0; k < levelTicks.length; ++k) {
  34998. ticks.push({
  34999. value: levelTicks[k].value,
  35000. level: maxLevel - i
  35001. });
  35002. }
  35003. }
  35004. ticks.sort(function (a, b) {
  35005. return a.value - b.value;
  35006. }); // Remove duplicates
  35007. var result = [];
  35008. for (var i = 0; i < ticks.length; ++i) {
  35009. if (i === 0 || ticks[i].value !== ticks[i - 1].value) {
  35010. result.push(ticks[i]);
  35011. }
  35012. }
  35013. return result;
  35014. }
  35015. Scale.registerClass(TimeScale);
  35016. /*
  35017. * Licensed to the Apache Software Foundation (ASF) under one
  35018. * or more contributor license agreements. See the NOTICE file
  35019. * distributed with this work for additional information
  35020. * regarding copyright ownership. The ASF licenses this file
  35021. * to you under the Apache License, Version 2.0 (the
  35022. * "License"); you may not use this file except in compliance
  35023. * with the License. You may obtain a copy of the License at
  35024. *
  35025. * http://www.apache.org/licenses/LICENSE-2.0
  35026. *
  35027. * Unless required by applicable law or agreed to in writing,
  35028. * software distributed under the License is distributed on an
  35029. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35030. * KIND, either express or implied. See the License for the
  35031. * specific language governing permissions and limitations
  35032. * under the License.
  35033. */
  35034. /**
  35035. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35036. */
  35037. /*
  35038. * Licensed to the Apache Software Foundation (ASF) under one
  35039. * or more contributor license agreements. See the NOTICE file
  35040. * distributed with this work for additional information
  35041. * regarding copyright ownership. The ASF licenses this file
  35042. * to you under the Apache License, Version 2.0 (the
  35043. * "License"); you may not use this file except in compliance
  35044. * with the License. You may obtain a copy of the License at
  35045. *
  35046. * http://www.apache.org/licenses/LICENSE-2.0
  35047. *
  35048. * Unless required by applicable law or agreed to in writing,
  35049. * software distributed under the License is distributed on an
  35050. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35051. * KIND, either express or implied. See the License for the
  35052. * specific language governing permissions and limitations
  35053. * under the License.
  35054. */
  35055. var scaleProto = Scale.prototype; // FIXME:TS refactor: not good to call it directly with `this`?
  35056. var intervalScaleProto = IntervalScale.prototype;
  35057. var getPrecisionSafe$1 = getPrecisionSafe;
  35058. var roundingErrorFix = round;
  35059. var mathFloor$1 = Math.floor;
  35060. var mathCeil = Math.ceil;
  35061. var mathPow$1 = Math.pow;
  35062. var mathLog = Math.log;
  35063. var LogScale =
  35064. /** @class */
  35065. function (_super) {
  35066. __extends(LogScale, _super);
  35067. function LogScale() {
  35068. var _this = _super !== null && _super.apply(this, arguments) || this;
  35069. _this.type = 'log';
  35070. _this.base = 10;
  35071. _this._originalScale = new IntervalScale(); // FIXME:TS actually used by `IntervalScale`
  35072. _this._interval = 0;
  35073. return _this;
  35074. }
  35075. /**
  35076. * @param Whether expand the ticks to niced extent.
  35077. */
  35078. LogScale.prototype.getTicks = function (expandToNicedExtent) {
  35079. var originalScale = this._originalScale;
  35080. var extent = this._extent;
  35081. var originalExtent = originalScale.getExtent();
  35082. var ticks = intervalScaleProto.getTicks.call(this, expandToNicedExtent);
  35083. return map(ticks, function (tick) {
  35084. var val = tick.value;
  35085. var powVal = round(mathPow$1(this.base, val)); // Fix #4158
  35086. powVal = val === extent[0] && this._fixMin ? fixRoundingError(powVal, originalExtent[0]) : powVal;
  35087. powVal = val === extent[1] && this._fixMax ? fixRoundingError(powVal, originalExtent[1]) : powVal;
  35088. return {
  35089. value: powVal
  35090. };
  35091. }, this);
  35092. };
  35093. LogScale.prototype.setExtent = function (start, end) {
  35094. var base = this.base;
  35095. start = mathLog(start) / mathLog(base);
  35096. end = mathLog(end) / mathLog(base);
  35097. intervalScaleProto.setExtent.call(this, start, end);
  35098. };
  35099. /**
  35100. * @return {number} end
  35101. */
  35102. LogScale.prototype.getExtent = function () {
  35103. var base = this.base;
  35104. var extent = scaleProto.getExtent.call(this);
  35105. extent[0] = mathPow$1(base, extent[0]);
  35106. extent[1] = mathPow$1(base, extent[1]); // Fix #4158
  35107. var originalScale = this._originalScale;
  35108. var originalExtent = originalScale.getExtent();
  35109. this._fixMin && (extent[0] = fixRoundingError(extent[0], originalExtent[0]));
  35110. this._fixMax && (extent[1] = fixRoundingError(extent[1], originalExtent[1]));
  35111. return extent;
  35112. };
  35113. LogScale.prototype.unionExtent = function (extent) {
  35114. this._originalScale.unionExtent(extent);
  35115. var base = this.base;
  35116. extent[0] = mathLog(extent[0]) / mathLog(base);
  35117. extent[1] = mathLog(extent[1]) / mathLog(base);
  35118. scaleProto.unionExtent.call(this, extent);
  35119. };
  35120. LogScale.prototype.unionExtentFromData = function (data, dim) {
  35121. // TODO
  35122. // filter value that <= 0
  35123. this.unionExtent(data.getApproximateExtent(dim));
  35124. };
  35125. /**
  35126. * Update interval and extent of intervals for nice ticks
  35127. * @param approxTickNum default 10 Given approx tick number
  35128. */
  35129. LogScale.prototype.niceTicks = function (approxTickNum) {
  35130. approxTickNum = approxTickNum || 10;
  35131. var extent = this._extent;
  35132. var span = extent[1] - extent[0];
  35133. if (span === Infinity || span <= 0) {
  35134. return;
  35135. }
  35136. var interval = quantity(span);
  35137. var err = approxTickNum / span * interval; // Filter ticks to get closer to the desired count.
  35138. if (err <= 0.5) {
  35139. interval *= 10;
  35140. } // Interval should be integer
  35141. while (!isNaN(interval) && Math.abs(interval) < 1 && Math.abs(interval) > 0) {
  35142. interval *= 10;
  35143. }
  35144. var niceExtent = [round(mathCeil(extent[0] / interval) * interval), round(mathFloor$1(extent[1] / interval) * interval)];
  35145. this._interval = interval;
  35146. this._niceExtent = niceExtent;
  35147. };
  35148. LogScale.prototype.niceExtent = function (opt) {
  35149. intervalScaleProto.niceExtent.call(this, opt);
  35150. this._fixMin = opt.fixMin;
  35151. this._fixMax = opt.fixMax;
  35152. };
  35153. LogScale.prototype.parse = function (val) {
  35154. return val;
  35155. };
  35156. LogScale.prototype.contain = function (val) {
  35157. val = mathLog(val) / mathLog(this.base);
  35158. return contain$2(val, this._extent);
  35159. };
  35160. LogScale.prototype.normalize = function (val) {
  35161. val = mathLog(val) / mathLog(this.base);
  35162. return normalize$1(val, this._extent);
  35163. };
  35164. LogScale.prototype.scale = function (val) {
  35165. val = scale$2(val, this._extent);
  35166. return mathPow$1(this.base, val);
  35167. };
  35168. LogScale.type = 'log';
  35169. return LogScale;
  35170. }(Scale);
  35171. var proto = LogScale.prototype;
  35172. proto.getMinorTicks = intervalScaleProto.getMinorTicks;
  35173. proto.getLabel = intervalScaleProto.getLabel;
  35174. function fixRoundingError(val, originalVal) {
  35175. return roundingErrorFix(val, getPrecisionSafe$1(originalVal));
  35176. }
  35177. Scale.registerClass(LogScale);
  35178. /*
  35179. * Licensed to the Apache Software Foundation (ASF) under one
  35180. * or more contributor license agreements. See the NOTICE file
  35181. * distributed with this work for additional information
  35182. * regarding copyright ownership. The ASF licenses this file
  35183. * to you under the Apache License, Version 2.0 (the
  35184. * "License"); you may not use this file except in compliance
  35185. * with the License. You may obtain a copy of the License at
  35186. *
  35187. * http://www.apache.org/licenses/LICENSE-2.0
  35188. *
  35189. * Unless required by applicable law or agreed to in writing,
  35190. * software distributed under the License is distributed on an
  35191. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35192. * KIND, either express or implied. See the License for the
  35193. * specific language governing permissions and limitations
  35194. * under the License.
  35195. */
  35196. /**
  35197. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35198. */
  35199. /*
  35200. * Licensed to the Apache Software Foundation (ASF) under one
  35201. * or more contributor license agreements. See the NOTICE file
  35202. * distributed with this work for additional information
  35203. * regarding copyright ownership. The ASF licenses this file
  35204. * to you under the Apache License, Version 2.0 (the
  35205. * "License"); you may not use this file except in compliance
  35206. * with the License. You may obtain a copy of the License at
  35207. *
  35208. * http://www.apache.org/licenses/LICENSE-2.0
  35209. *
  35210. * Unless required by applicable law or agreed to in writing,
  35211. * software distributed under the License is distributed on an
  35212. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35213. * KIND, either express or implied. See the License for the
  35214. * specific language governing permissions and limitations
  35215. * under the License.
  35216. */
  35217. var ScaleRawExtentInfo =
  35218. /** @class */
  35219. function () {
  35220. function ScaleRawExtentInfo(scale, model, // Usually: data extent from all series on this axis.
  35221. originalExtent) {
  35222. this._prepareParams(scale, model, originalExtent);
  35223. }
  35224. /**
  35225. * Parameters depending on ouside (like model, user callback)
  35226. * are prepared and fixed here.
  35227. */
  35228. ScaleRawExtentInfo.prototype._prepareParams = function (scale, model, // Usually: data extent from all series on this axis.
  35229. dataExtent) {
  35230. if (dataExtent[1] < dataExtent[0]) {
  35231. dataExtent = [NaN, NaN];
  35232. }
  35233. this._dataMin = dataExtent[0];
  35234. this._dataMax = dataExtent[1];
  35235. var isOrdinal = this._isOrdinal = scale.type === 'ordinal';
  35236. this._needCrossZero = model.getNeedCrossZero && model.getNeedCrossZero();
  35237. var modelMinRaw = this._modelMinRaw = model.get('min', true);
  35238. if (isFunction$1(modelMinRaw)) {
  35239. // This callback alway provide users the full data extent (before data filtered).
  35240. this._modelMinNum = parseAxisModelMinMax(scale, modelMinRaw({
  35241. min: dataExtent[0],
  35242. max: dataExtent[1]
  35243. }));
  35244. } else if (modelMinRaw !== 'dataMin') {
  35245. this._modelMinNum = parseAxisModelMinMax(scale, modelMinRaw);
  35246. }
  35247. var modelMaxRaw = this._modelMaxRaw = model.get('max', true);
  35248. if (isFunction$1(modelMaxRaw)) {
  35249. // This callback alway provide users the full data extent (before data filtered).
  35250. this._modelMaxNum = parseAxisModelMinMax(scale, modelMaxRaw({
  35251. min: dataExtent[0],
  35252. max: dataExtent[1]
  35253. }));
  35254. } else if (modelMaxRaw !== 'dataMax') {
  35255. this._modelMaxNum = parseAxisModelMinMax(scale, modelMaxRaw);
  35256. }
  35257. if (isOrdinal) {
  35258. // FIXME: there is a flaw here: if there is no "block" data processor like `dataZoom`,
  35259. // and progressive rendering is using, here the category result might just only contain
  35260. // the processed chunk rather than the entire result.
  35261. this._axisDataLen = model.getCategories().length;
  35262. } else {
  35263. var boundaryGap = model.get('boundaryGap');
  35264. var boundaryGapArr = isArray(boundaryGap) ? boundaryGap : [boundaryGap || 0, boundaryGap || 0];
  35265. if (typeof boundaryGapArr[0] === 'boolean' || typeof boundaryGapArr[1] === 'boolean') {
  35266. {
  35267. console.warn('Boolean type for boundaryGap is only ' + 'allowed for ordinal axis. Please use string in ' + 'percentage instead, e.g., "20%". Currently, ' + 'boundaryGap is set to be 0.');
  35268. }
  35269. this._boundaryGapInner = [0, 0];
  35270. } else {
  35271. this._boundaryGapInner = [parsePercent(boundaryGapArr[0], 1), parsePercent(boundaryGapArr[1], 1)];
  35272. }
  35273. }
  35274. };
  35275. /**
  35276. * Calculate extent by prepared parameters.
  35277. * This method has no external dependency and can be called duplicatedly,
  35278. * getting the same result.
  35279. * If parameters changed, should call this method to recalcuate.
  35280. */
  35281. ScaleRawExtentInfo.prototype.calculate = function () {
  35282. // Notice: When min/max is not set (that is, when there are null/undefined,
  35283. // which is the most common case), these cases should be ensured:
  35284. // (1) For 'ordinal', show all axis.data.
  35285. // (2) For others:
  35286. // + `boundaryGap` is applied (if min/max set, boundaryGap is
  35287. // disabled).
  35288. // + If `needCrossZero`, min/max should be zero, otherwise, min/max should
  35289. // be the result that originalExtent enlarged by boundaryGap.
  35290. // (3) If no data, it should be ensured that `scale.setBlank` is set.
  35291. var isOrdinal = this._isOrdinal;
  35292. var dataMin = this._dataMin;
  35293. var dataMax = this._dataMax;
  35294. var axisDataLen = this._axisDataLen;
  35295. var boundaryGapInner = this._boundaryGapInner;
  35296. var span = !isOrdinal ? dataMax - dataMin || Math.abs(dataMin) : null; // Currently if a `'value'` axis model min is specified as 'dataMin'/'dataMax',
  35297. // `boundaryGap` will not be used. It's the different from specifying as `null`/`undefined`.
  35298. var min = this._modelMinRaw === 'dataMin' ? dataMin : this._modelMinNum;
  35299. var max = this._modelMaxRaw === 'dataMax' ? dataMax : this._modelMaxNum; // If `_modelMinNum`/`_modelMaxNum` is `null`/`undefined`, should not be fixed.
  35300. var minFixed = min != null;
  35301. var maxFixed = max != null;
  35302. if (min == null) {
  35303. min = isOrdinal ? axisDataLen ? 0 : NaN : dataMin - boundaryGapInner[0] * span;
  35304. }
  35305. if (max == null) {
  35306. max = isOrdinal ? axisDataLen ? axisDataLen - 1 : NaN : dataMax + boundaryGapInner[1] * span;
  35307. }
  35308. (min == null || !isFinite(min)) && (min = NaN);
  35309. (max == null || !isFinite(max)) && (max = NaN);
  35310. if (min > max) {
  35311. min = NaN;
  35312. max = NaN;
  35313. }
  35314. var isBlank = eqNaN(min) || eqNaN(max) || isOrdinal && !axisDataLen; // If data extent modified, need to recalculated to ensure cross zero.
  35315. if (this._needCrossZero) {
  35316. // Axis is over zero and min is not set
  35317. if (min > 0 && max > 0 && !minFixed) {
  35318. min = 0; // minFixed = true;
  35319. } // Axis is under zero and max is not set
  35320. if (min < 0 && max < 0 && !maxFixed) {
  35321. max = 0; // maxFixed = true;
  35322. } // PENDING:
  35323. // When `needCrossZero` and all data is positive/negative, should it be ensured
  35324. // that the results processed by boundaryGap are positive/negative?
  35325. // If so, here `minFixed`/`maxFixed` need to be set.
  35326. }
  35327. var determinedMin = this._determinedMin;
  35328. var determinedMax = this._determinedMax;
  35329. if (determinedMin != null) {
  35330. min = determinedMin;
  35331. minFixed = true;
  35332. }
  35333. if (determinedMax != null) {
  35334. max = determinedMax;
  35335. maxFixed = true;
  35336. } // Ensure min/max be finite number or NaN here. (not to be null/undefined)
  35337. // `NaN` means min/max axis is blank.
  35338. return {
  35339. min: min,
  35340. max: max,
  35341. minFixed: minFixed,
  35342. maxFixed: maxFixed,
  35343. isBlank: isBlank
  35344. };
  35345. };
  35346. ScaleRawExtentInfo.prototype.modifyDataMinMax = function (minMaxName, val) {
  35347. {
  35348. assert$1(!this.frozen);
  35349. }
  35350. this[DATA_MIN_MAX_ATTR[minMaxName]] = val;
  35351. };
  35352. ScaleRawExtentInfo.prototype.setDeterminedMinMax = function (minMaxName, val) {
  35353. var attr = DETERMINED_MIN_MAX_ATTR[minMaxName];
  35354. {
  35355. assert$1(!this.frozen // Earse them usually means logic flaw.
  35356. && this[attr] == null);
  35357. }
  35358. this[attr] = val;
  35359. };
  35360. ScaleRawExtentInfo.prototype.freeze = function () {
  35361. // @ts-ignore
  35362. this.frozen = true;
  35363. };
  35364. return ScaleRawExtentInfo;
  35365. }();
  35366. var DETERMINED_MIN_MAX_ATTR = {
  35367. min: '_determinedMin',
  35368. max: '_determinedMax'
  35369. };
  35370. var DATA_MIN_MAX_ATTR = {
  35371. min: '_dataMin',
  35372. max: '_dataMax'
  35373. };
  35374. /**
  35375. * Get scale min max and related info only depends on model settings.
  35376. * This method can be called after coordinate system created.
  35377. * For example, in data processing stage.
  35378. *
  35379. * Scale extent info probably be required multiple times during a workflow.
  35380. * For example:
  35381. * (1) `dataZoom` depends it to get the axis extent in "100%" state.
  35382. * (2) `processor/extentCalculator` depends it to make sure whether axis extent is specified.
  35383. * (3) `coordSys.update` use it to finally decide the scale extent.
  35384. * But the callback of `min`/`max` should not be called multiple times.
  35385. * The code below should not be implemented repeatedly either.
  35386. * So we cache the result in the scale instance, which will be recreated at the begining
  35387. * of the workflow (because `scale` instance will be recreated each round of the workflow).
  35388. */
  35389. function ensureScaleRawExtentInfo(scale, model, // Usually: data extent from all series on this axis.
  35390. originalExtent) {
  35391. // Do not permit to recreate.
  35392. var rawExtentInfo = scale.rawExtentInfo;
  35393. if (rawExtentInfo) {
  35394. return rawExtentInfo;
  35395. }
  35396. rawExtentInfo = new ScaleRawExtentInfo(scale, model, originalExtent); // @ts-ignore
  35397. scale.rawExtentInfo = rawExtentInfo;
  35398. return rawExtentInfo;
  35399. }
  35400. function parseAxisModelMinMax(scale, minMax) {
  35401. return minMax == null ? null : eqNaN(minMax) ? NaN : scale.parse(minMax);
  35402. }
  35403. /*
  35404. * Licensed to the Apache Software Foundation (ASF) under one
  35405. * or more contributor license agreements. See the NOTICE file
  35406. * distributed with this work for additional information
  35407. * regarding copyright ownership. The ASF licenses this file
  35408. * to you under the Apache License, Version 2.0 (the
  35409. * "License"); you may not use this file except in compliance
  35410. * with the License. You may obtain a copy of the License at
  35411. *
  35412. * http://www.apache.org/licenses/LICENSE-2.0
  35413. *
  35414. * Unless required by applicable law or agreed to in writing,
  35415. * software distributed under the License is distributed on an
  35416. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35417. * KIND, either express or implied. See the License for the
  35418. * specific language governing permissions and limitations
  35419. * under the License.
  35420. */
  35421. /**
  35422. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35423. */
  35424. /*
  35425. * Licensed to the Apache Software Foundation (ASF) under one
  35426. * or more contributor license agreements. See the NOTICE file
  35427. * distributed with this work for additional information
  35428. * regarding copyright ownership. The ASF licenses this file
  35429. * to you under the Apache License, Version 2.0 (the
  35430. * "License"); you may not use this file except in compliance
  35431. * with the License. You may obtain a copy of the License at
  35432. *
  35433. * http://www.apache.org/licenses/LICENSE-2.0
  35434. *
  35435. * Unless required by applicable law or agreed to in writing,
  35436. * software distributed under the License is distributed on an
  35437. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35438. * KIND, either express or implied. See the License for the
  35439. * specific language governing permissions and limitations
  35440. * under the License.
  35441. */
  35442. /**
  35443. * Get axis scale extent before niced.
  35444. * Item of returned array can only be number (including Infinity and NaN).
  35445. *
  35446. * Caution:
  35447. * Precondition of calling this method:
  35448. * The scale extent has been initialized using series data extent via
  35449. * `scale.setExtent` or `scale.unionExtentFromData`;
  35450. */
  35451. function getScaleExtent(scale, model) {
  35452. var scaleType = scale.type;
  35453. var rawExtentResult = ensureScaleRawExtentInfo(scale, model, scale.getExtent()).calculate();
  35454. scale.setBlank(rawExtentResult.isBlank);
  35455. var min = rawExtentResult.min;
  35456. var max = rawExtentResult.max; // If bars are placed on a base axis of type time or interval account for axis boundary overflow and current axis
  35457. // is base axis
  35458. // FIXME
  35459. // (1) Consider support value axis, where below zero and axis `onZero` should be handled properly.
  35460. // (2) Refactor the logic with `barGrid`. Is it not need to `makeBarWidthAndOffsetInfo` twice with different extent?
  35461. // Should not depend on series type `bar`?
  35462. // (3) Fix that might overlap when using dataZoom.
  35463. // (4) Consider other chart types using `barGrid`?
  35464. // See #6728, #4862, `test/bar-overflow-time-plot.html`
  35465. var ecModel = model.ecModel;
  35466. if (ecModel && scaleType === 'time'
  35467. /*|| scaleType === 'interval' */
  35468. ) {
  35469. var barSeriesModels = prepareLayoutBarSeries('bar', ecModel);
  35470. var isBaseAxisAndHasBarSeries_1 = false;
  35471. each$1(barSeriesModels, function (seriesModel) {
  35472. isBaseAxisAndHasBarSeries_1 = isBaseAxisAndHasBarSeries_1 || seriesModel.getBaseAxis() === model.axis;
  35473. });
  35474. if (isBaseAxisAndHasBarSeries_1) {
  35475. // Calculate placement of bars on axis. TODO should be decoupled
  35476. // with barLayout
  35477. var barWidthAndOffset = makeColumnLayout(barSeriesModels); // Adjust axis min and max to account for overflow
  35478. var adjustedScale = adjustScaleForOverflow(min, max, model, barWidthAndOffset);
  35479. min = adjustedScale.min;
  35480. max = adjustedScale.max;
  35481. }
  35482. }
  35483. return {
  35484. extent: [min, max],
  35485. // "fix" means "fixed", the value should not be
  35486. // changed in the subsequent steps.
  35487. fixMin: rawExtentResult.minFixed,
  35488. fixMax: rawExtentResult.maxFixed
  35489. };
  35490. }
  35491. function adjustScaleForOverflow(min, max, model, // Only support cartesian coord yet.
  35492. barWidthAndOffset) {
  35493. // Get Axis Length
  35494. var axisExtent = model.axis.getExtent();
  35495. var axisLength = axisExtent[1] - axisExtent[0]; // Get bars on current base axis and calculate min and max overflow
  35496. var barsOnCurrentAxis = retrieveColumnLayout(barWidthAndOffset, model.axis);
  35497. if (barsOnCurrentAxis === undefined) {
  35498. return {
  35499. min: min,
  35500. max: max
  35501. };
  35502. }
  35503. var minOverflow = Infinity;
  35504. each$1(barsOnCurrentAxis, function (item) {
  35505. minOverflow = Math.min(item.offset, minOverflow);
  35506. });
  35507. var maxOverflow = -Infinity;
  35508. each$1(barsOnCurrentAxis, function (item) {
  35509. maxOverflow = Math.max(item.offset + item.width, maxOverflow);
  35510. });
  35511. minOverflow = Math.abs(minOverflow);
  35512. maxOverflow = Math.abs(maxOverflow);
  35513. var totalOverFlow = minOverflow + maxOverflow; // Calculate required buffer based on old range and overflow
  35514. var oldRange = max - min;
  35515. var oldRangePercentOfNew = 1 - (minOverflow + maxOverflow) / axisLength;
  35516. var overflowBuffer = oldRange / oldRangePercentOfNew - oldRange;
  35517. max += overflowBuffer * (maxOverflow / totalOverFlow);
  35518. min -= overflowBuffer * (minOverflow / totalOverFlow);
  35519. return {
  35520. min: min,
  35521. max: max
  35522. };
  35523. } // Precondition of calling this method:
  35524. // The scale extent has been initailized using series data extent via
  35525. // `scale.setExtent` or `scale.unionExtentFromData`;
  35526. function niceScaleExtent(scale, model) {
  35527. var extentInfo = getScaleExtent(scale, model);
  35528. var extent = extentInfo.extent;
  35529. var splitNumber = model.get('splitNumber');
  35530. if (scale instanceof LogScale) {
  35531. scale.base = model.get('logBase');
  35532. }
  35533. var scaleType = scale.type;
  35534. scale.setExtent(extent[0], extent[1]);
  35535. scale.niceExtent({
  35536. splitNumber: splitNumber,
  35537. fixMin: extentInfo.fixMin,
  35538. fixMax: extentInfo.fixMax,
  35539. minInterval: scaleType === 'interval' || scaleType === 'time' ? model.get('minInterval') : null,
  35540. maxInterval: scaleType === 'interval' || scaleType === 'time' ? model.get('maxInterval') : null
  35541. }); // If some one specified the min, max. And the default calculated interval
  35542. // is not good enough. He can specify the interval. It is often appeared
  35543. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  35544. // to be 60.
  35545. // FIXME
  35546. var interval = model.get('interval');
  35547. if (interval != null) {
  35548. scale.setInterval && scale.setInterval(interval);
  35549. }
  35550. }
  35551. /**
  35552. * @param axisType Default retrieve from model.type
  35553. */
  35554. function createScaleByModel(model, axisType) {
  35555. axisType = axisType || model.get('type');
  35556. if (axisType) {
  35557. switch (axisType) {
  35558. // Buildin scale
  35559. case 'category':
  35560. return new OrdinalScale({
  35561. ordinalMeta: model.getOrdinalMeta ? model.getOrdinalMeta() : model.getCategories(),
  35562. extent: [Infinity, -Infinity]
  35563. });
  35564. case 'time':
  35565. return new TimeScale({
  35566. locale: model.ecModel.getLocaleModel(),
  35567. useUTC: model.ecModel.get('useUTC')
  35568. });
  35569. default:
  35570. // case 'value'/'interval', 'log', or others.
  35571. return new (Scale.getClass(axisType) || IntervalScale)();
  35572. }
  35573. }
  35574. }
  35575. /**
  35576. * Check if the axis cross 0
  35577. */
  35578. function ifAxisCrossZero(axis) {
  35579. var dataExtent = axis.scale.getExtent();
  35580. var min = dataExtent[0];
  35581. var max = dataExtent[1];
  35582. return !(min > 0 && max > 0 || min < 0 && max < 0);
  35583. }
  35584. /**
  35585. * @param axis
  35586. * @return Label formatter function.
  35587. * param: {number} tickValue,
  35588. * param: {number} idx, the index in all ticks.
  35589. * If category axis, this param is not required.
  35590. * return: {string} label string.
  35591. */
  35592. function makeLabelFormatter(axis) {
  35593. var labelFormatter = axis.getLabelModel().get('formatter');
  35594. var categoryTickStart = axis.type === 'category' ? axis.scale.getExtent()[0] : null;
  35595. if (axis.scale.type === 'time') {
  35596. return function (tpl) {
  35597. return function (tick, idx) {
  35598. return axis.scale.getFormattedLabel(tick, idx, tpl);
  35599. };
  35600. }(labelFormatter);
  35601. } else if (typeof labelFormatter === 'string') {
  35602. return function (tpl) {
  35603. return function (tick) {
  35604. // For category axis, get raw value; for numeric axis,
  35605. // get formatted label like '1,333,444'.
  35606. var label = axis.scale.getLabel(tick);
  35607. var text = tpl.replace('{value}', label != null ? label : '');
  35608. return text;
  35609. };
  35610. }(labelFormatter);
  35611. } else if (typeof labelFormatter === 'function') {
  35612. return function (cb) {
  35613. return function (tick, idx) {
  35614. // The original intention of `idx` is "the index of the tick in all ticks".
  35615. // But the previous implementation of category axis do not consider the
  35616. // `axisLabel.interval`, which cause that, for example, the `interval` is
  35617. // `1`, then the ticks "name5", "name7", "name9" are displayed, where the
  35618. // corresponding `idx` are `0`, `2`, `4`, but not `0`, `1`, `2`. So we keep
  35619. // the definition here for back compatibility.
  35620. if (categoryTickStart != null) {
  35621. idx = tick.value - categoryTickStart;
  35622. }
  35623. return cb(getAxisRawValue(axis, tick), idx, tick.level != null ? {
  35624. level: tick.level
  35625. } : null);
  35626. };
  35627. }(labelFormatter);
  35628. } else {
  35629. return function (tick) {
  35630. return axis.scale.getLabel(tick);
  35631. };
  35632. }
  35633. }
  35634. function getAxisRawValue(axis, tick) {
  35635. // In category axis with data zoom, tick is not the original
  35636. // index of axis.data. So tick should not be exposed to user
  35637. // in category axis.
  35638. return axis.type === 'category' ? axis.scale.getLabel(tick) : tick.value;
  35639. }
  35640. /**
  35641. * @param axis
  35642. * @return Be null/undefined if no labels.
  35643. */
  35644. function estimateLabelUnionRect(axis) {
  35645. var axisModel = axis.model;
  35646. var scale = axis.scale;
  35647. if (!axisModel.get(['axisLabel', 'show']) || scale.isBlank()) {
  35648. return;
  35649. }
  35650. var realNumberScaleTicks;
  35651. var tickCount;
  35652. var categoryScaleExtent = scale.getExtent(); // Optimize for large category data, avoid call `getTicks()`.
  35653. if (scale instanceof OrdinalScale) {
  35654. tickCount = scale.count();
  35655. } else {
  35656. realNumberScaleTicks = scale.getTicks();
  35657. tickCount = realNumberScaleTicks.length;
  35658. }
  35659. var axisLabelModel = axis.getLabelModel();
  35660. var labelFormatter = makeLabelFormatter(axis);
  35661. var rect;
  35662. var step = 1; // Simple optimization for large amount of labels
  35663. if (tickCount > 40) {
  35664. step = Math.ceil(tickCount / 40);
  35665. }
  35666. for (var i = 0; i < tickCount; i += step) {
  35667. var tick = realNumberScaleTicks ? realNumberScaleTicks[i] : {
  35668. value: categoryScaleExtent[0] + i
  35669. };
  35670. var label = labelFormatter(tick, i);
  35671. var unrotatedSingleRect = axisLabelModel.getTextRect(label);
  35672. var singleRect = rotateTextRect(unrotatedSingleRect, axisLabelModel.get('rotate') || 0);
  35673. rect ? rect.union(singleRect) : rect = singleRect;
  35674. }
  35675. return rect;
  35676. }
  35677. function rotateTextRect(textRect, rotate) {
  35678. var rotateRadians = rotate * Math.PI / 180;
  35679. var beforeWidth = textRect.width;
  35680. var beforeHeight = textRect.height;
  35681. var afterWidth = beforeWidth * Math.abs(Math.cos(rotateRadians)) + Math.abs(beforeHeight * Math.sin(rotateRadians));
  35682. var afterHeight = beforeWidth * Math.abs(Math.sin(rotateRadians)) + Math.abs(beforeHeight * Math.cos(rotateRadians));
  35683. var rotatedRect = new BoundingRect(textRect.x, textRect.y, afterWidth, afterHeight);
  35684. return rotatedRect;
  35685. }
  35686. /**
  35687. * @param model axisLabelModel or axisTickModel
  35688. * @return {number|String} Can be null|'auto'|number|function
  35689. */
  35690. function getOptionCategoryInterval(model) {
  35691. var interval = model.get('interval');
  35692. return interval == null ? 'auto' : interval;
  35693. }
  35694. /**
  35695. * Set `categoryInterval` as 0 implicitly indicates that
  35696. * show all labels reguardless of overlap.
  35697. * @param {Object} axis axisModel.axis
  35698. */
  35699. function shouldShowAllLabels(axis) {
  35700. return axis.type === 'category' && getOptionCategoryInterval(axis.getLabelModel()) === 0;
  35701. }
  35702. function getDataDimensionsOnAxis(data, axisDim) {
  35703. // Remove duplicated dat dimensions caused by `getStackedDimension`.
  35704. var dataDimMap = {}; // Currently `mapDimensionsAll` will contain stack result dimension ('__\0ecstackresult').
  35705. // PENDING: is it reasonable? Do we need to remove the original dim from "coord dim" since
  35706. // there has been stacked result dim?
  35707. each$1(data.mapDimensionsAll(axisDim), function (dataDim) {
  35708. // For example, the extent of the original dimension
  35709. // is [0.1, 0.5], the extent of the `stackResultDimension`
  35710. // is [7, 9], the final extent should NOT include [0.1, 0.5],
  35711. // because there is no graphic corresponding to [0.1, 0.5].
  35712. // See the case in `test/area-stack.html` `main1`, where area line
  35713. // stack needs `yAxis` not start from 0.
  35714. dataDimMap[getStackedDimension(data, dataDim)] = true;
  35715. });
  35716. return keys(dataDimMap);
  35717. }
  35718. function unionAxisExtentFromData(dataExtent, data, axisDim) {
  35719. if (data) {
  35720. each$1(getDataDimensionsOnAxis(data, axisDim), function (dim) {
  35721. var seriesExtent = data.getApproximateExtent(dim);
  35722. seriesExtent[0] < dataExtent[0] && (dataExtent[0] = seriesExtent[0]);
  35723. seriesExtent[1] > dataExtent[1] && (dataExtent[1] = seriesExtent[1]);
  35724. });
  35725. }
  35726. }
  35727. /*
  35728. * Licensed to the Apache Software Foundation (ASF) under one
  35729. * or more contributor license agreements. See the NOTICE file
  35730. * distributed with this work for additional information
  35731. * regarding copyright ownership. The ASF licenses this file
  35732. * to you under the Apache License, Version 2.0 (the
  35733. * "License"); you may not use this file except in compliance
  35734. * with the License. You may obtain a copy of the License at
  35735. *
  35736. * http://www.apache.org/licenses/LICENSE-2.0
  35737. *
  35738. * Unless required by applicable law or agreed to in writing,
  35739. * software distributed under the License is distributed on an
  35740. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35741. * KIND, either express or implied. See the License for the
  35742. * specific language governing permissions and limitations
  35743. * under the License.
  35744. */
  35745. /**
  35746. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35747. */
  35748. /*
  35749. * Licensed to the Apache Software Foundation (ASF) under one
  35750. * or more contributor license agreements. See the NOTICE file
  35751. * distributed with this work for additional information
  35752. * regarding copyright ownership. The ASF licenses this file
  35753. * to you under the Apache License, Version 2.0 (the
  35754. * "License"); you may not use this file except in compliance
  35755. * with the License. You may obtain a copy of the License at
  35756. *
  35757. * http://www.apache.org/licenses/LICENSE-2.0
  35758. *
  35759. * Unless required by applicable law or agreed to in writing,
  35760. * software distributed under the License is distributed on an
  35761. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35762. * KIND, either express or implied. See the License for the
  35763. * specific language governing permissions and limitations
  35764. * under the License.
  35765. */
  35766. var AxisModelCommonMixin =
  35767. /** @class */
  35768. function () {
  35769. function AxisModelCommonMixin() {}
  35770. AxisModelCommonMixin.prototype.getNeedCrossZero = function () {
  35771. var option = this.option;
  35772. return !option.scale;
  35773. };
  35774. /**
  35775. * Should be implemented by each axis model if necessary.
  35776. * @return coordinate system model
  35777. */
  35778. AxisModelCommonMixin.prototype.getCoordSysModel = function () {
  35779. return;
  35780. };
  35781. return AxisModelCommonMixin;
  35782. }();
  35783. /*
  35784. * Licensed to the Apache Software Foundation (ASF) under one
  35785. * or more contributor license agreements. See the NOTICE file
  35786. * distributed with this work for additional information
  35787. * regarding copyright ownership. The ASF licenses this file
  35788. * to you under the Apache License, Version 2.0 (the
  35789. * "License"); you may not use this file except in compliance
  35790. * with the License. You may obtain a copy of the License at
  35791. *
  35792. * http://www.apache.org/licenses/LICENSE-2.0
  35793. *
  35794. * Unless required by applicable law or agreed to in writing,
  35795. * software distributed under the License is distributed on an
  35796. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35797. * KIND, either express or implied. See the License for the
  35798. * specific language governing permissions and limitations
  35799. * under the License.
  35800. */
  35801. /**
  35802. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35803. */
  35804. /*
  35805. * Licensed to the Apache Software Foundation (ASF) under one
  35806. * or more contributor license agreements. See the NOTICE file
  35807. * distributed with this work for additional information
  35808. * regarding copyright ownership. The ASF licenses this file
  35809. * to you under the Apache License, Version 2.0 (the
  35810. * "License"); you may not use this file except in compliance
  35811. * with the License. You may obtain a copy of the License at
  35812. *
  35813. * http://www.apache.org/licenses/LICENSE-2.0
  35814. *
  35815. * Unless required by applicable law or agreed to in writing,
  35816. * software distributed under the License is distributed on an
  35817. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35818. * KIND, either express or implied. See the License for the
  35819. * specific language governing permissions and limitations
  35820. * under the License.
  35821. */
  35822. /**
  35823. * This module exposes helper functions for developing extensions.
  35824. */
  35825. /**
  35826. * Create a muti dimension List structure from seriesModel.
  35827. */
  35828. function createList(seriesModel) {
  35829. return createListFromArray(seriesModel.getSource(), seriesModel);
  35830. } // export function createGraph(seriesModel) {
  35831. var dataStack$1 = {
  35832. isDimensionStacked: isDimensionStacked,
  35833. enableDataStack: enableDataStack,
  35834. getStackedDimension: getStackedDimension
  35835. };
  35836. /**
  35837. * Create scale
  35838. * @param {Array.<number>} dataExtent
  35839. * @param {Object|module:echarts/Model} option If `optoin.type`
  35840. * is secified, it can only be `'value'` currently.
  35841. */
  35842. function createScale(dataExtent, option) {
  35843. var axisModel = option;
  35844. if (!(option instanceof Model)) {
  35845. axisModel = new Model(option); // FIXME
  35846. // Currently AxisModelCommonMixin has nothing to do with the
  35847. // the requirements of `axisHelper.createScaleByModel`. For
  35848. // example the method `getCategories` and `getOrdinalMeta`
  35849. // are required for `'category'` axis, and ecModel are required
  35850. // for `'time'` axis. But occationally echarts-gl happened
  35851. // to only use `'value'` axis.
  35852. // zrUtil.mixin(axisModel, AxisModelCommonMixin);
  35853. }
  35854. var scale = createScaleByModel(axisModel);
  35855. scale.setExtent(dataExtent[0], dataExtent[1]);
  35856. niceScaleExtent(scale, axisModel);
  35857. return scale;
  35858. }
  35859. /**
  35860. * Mixin common methods to axis model,
  35861. *
  35862. * Inlcude methods
  35863. * `getFormattedLabels() => Array.<string>`
  35864. * `getCategories() => Array.<string>`
  35865. * `getMin(origin: boolean) => number`
  35866. * `getMax(origin: boolean) => number`
  35867. * `getNeedCrossZero() => boolean`
  35868. */
  35869. function mixinAxisModelCommonMethods(Model$$1) {
  35870. mixin(Model$$1, AxisModelCommonMixin);
  35871. }
  35872. function createTextStyle$1(textStyleModel, opts) {
  35873. opts = opts || {};
  35874. return createTextStyle(textStyleModel, null, null, opts.state !== 'normal');
  35875. }
  35876. var helper = (Object.freeze || Object)({
  35877. createList: createList,
  35878. getLayoutRect: getLayoutRect,
  35879. dataStack: dataStack$1,
  35880. createScale: createScale,
  35881. mixinAxisModelCommonMethods: mixinAxisModelCommonMethods,
  35882. getECData: getECData,
  35883. createTextStyle: createTextStyle$1,
  35884. createDimensions: createDimensions,
  35885. createSymbol: createSymbol,
  35886. enableHoverEmphasis: enableHoverEmphasis
  35887. });
  35888. /*
  35889. * Licensed to the Apache Software Foundation (ASF) under one
  35890. * or more contributor license agreements. See the NOTICE file
  35891. * distributed with this work for additional information
  35892. * regarding copyright ownership. The ASF licenses this file
  35893. * to you under the Apache License, Version 2.0 (the
  35894. * "License"); you may not use this file except in compliance
  35895. * with the License. You may obtain a copy of the License at
  35896. *
  35897. * http://www.apache.org/licenses/LICENSE-2.0
  35898. *
  35899. * Unless required by applicable law or agreed to in writing,
  35900. * software distributed under the License is distributed on an
  35901. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35902. * KIND, either express or implied. See the License for the
  35903. * specific language governing permissions and limitations
  35904. * under the License.
  35905. */
  35906. /**
  35907. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35908. */
  35909. /*
  35910. * Licensed to the Apache Software Foundation (ASF) under one
  35911. * or more contributor license agreements. See the NOTICE file
  35912. * distributed with this work for additional information
  35913. * regarding copyright ownership. The ASF licenses this file
  35914. * to you under the Apache License, Version 2.0 (the
  35915. * "License"); you may not use this file except in compliance
  35916. * with the License. You may obtain a copy of the License at
  35917. *
  35918. * http://www.apache.org/licenses/LICENSE-2.0
  35919. *
  35920. * Unless required by applicable law or agreed to in writing,
  35921. * software distributed under the License is distributed on an
  35922. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35923. * KIND, either express or implied. See the License for the
  35924. * specific language governing permissions and limitations
  35925. * under the License.
  35926. */
  35927. var extensions = [];
  35928. var extensionRegisters = {
  35929. registerPreprocessor: registerPreprocessor,
  35930. registerProcessor: registerProcessor,
  35931. registerPostInit: registerPostInit,
  35932. registerPostUpdate: registerPostUpdate,
  35933. registerAction: registerAction,
  35934. registerCoordinateSystem: registerCoordinateSystem,
  35935. registerLayout: registerLayout,
  35936. registerVisual: registerVisual,
  35937. registerTransform: registerTransform,
  35938. registerLoading: registerLoading,
  35939. registerMap: registerMap,
  35940. PRIORITY: PRIORITY,
  35941. ComponentModel: ComponentModel,
  35942. ComponentView: ComponentView,
  35943. SeriesModel: SeriesModel,
  35944. ChartView: ChartView,
  35945. // TODO Use ComponentModel and SeriesModel instead of Constructor
  35946. registerComponentModel: function (ComponentModelClass) {
  35947. ComponentModel.registerClass(ComponentModelClass);
  35948. },
  35949. registerComponentView: function (ComponentViewClass) {
  35950. ComponentView.registerClass(ComponentViewClass);
  35951. },
  35952. registerSeriesModel: function (SeriesModelClass) {
  35953. SeriesModel.registerClass(SeriesModelClass);
  35954. },
  35955. registerChartView: function (ChartViewClass) {
  35956. ChartView.registerClass(ChartViewClass);
  35957. },
  35958. registerSubTypeDefaulter: function (componentType, defaulter) {
  35959. ComponentModel.registerSubTypeDefaulter(componentType, defaulter);
  35960. },
  35961. registerPainter: function (painterType, PainterCtor) {
  35962. registerPainter(painterType, PainterCtor);
  35963. }
  35964. };
  35965. function use(ext) {
  35966. if (isArray(ext)) {
  35967. // use([ChartLine, ChartBar]);
  35968. each$1(ext, function (singleExt) {
  35969. use(singleExt);
  35970. });
  35971. return;
  35972. }
  35973. if (indexOf$1(extensions, ext) >= 0) {
  35974. return;
  35975. }
  35976. extensions.push(ext);
  35977. if (isFunction$1(ext)) {
  35978. ext = {
  35979. install: ext
  35980. };
  35981. }
  35982. ext.install(extensionRegisters);
  35983. }
  35984. var number = (Object.freeze || Object)({
  35985. linearMap: linearMap,
  35986. round: round,
  35987. asc: asc,
  35988. getPrecision: getPrecision,
  35989. getPrecisionSafe: getPrecisionSafe,
  35990. getPixelPrecision: getPixelPrecision,
  35991. getPercentWithPrecision: getPercentWithPrecision,
  35992. MAX_SAFE_INTEGER: MAX_SAFE_INTEGER,
  35993. remRadian: remRadian,
  35994. isRadianAroundZero: isRadianAroundZero,
  35995. parseDate: parseDate,
  35996. quantity: quantity,
  35997. quantityExponent: quantityExponent,
  35998. nice: nice,
  35999. quantile: quantile,
  36000. reformIntervals: reformIntervals,
  36001. isNumeric: isNumeric,
  36002. numericToNumber: numericToNumber
  36003. });
  36004. var time = (Object.freeze || Object)({
  36005. parse: parseDate,
  36006. format: format
  36007. });
  36008. var graphic$1 = (Object.freeze || Object)({
  36009. extendShape: extendShape,
  36010. extendPath: extendPath,
  36011. makePath: makePath,
  36012. makeImage: makeImage,
  36013. mergePath: mergePath,
  36014. resizePath: resizePath,
  36015. createIcon: createIcon,
  36016. updateProps: updateProps,
  36017. initProps: initProps,
  36018. getTransform: getTransform,
  36019. clipPointsByRect: clipPointsByRect,
  36020. clipRectByRect: clipRectByRect,
  36021. registerShape: registerShape,
  36022. getShapeClass: getShapeClass,
  36023. Group: Group,
  36024. Image: ZRImage,
  36025. Text: ZRText,
  36026. Circle: Circle,
  36027. Ellipse: Ellipse,
  36028. Sector: Sector,
  36029. Ring: Ring,
  36030. Polygon: Polygon,
  36031. Polyline: Polyline,
  36032. Rect: Rect,
  36033. Line: Line,
  36034. BezierCurve: BezierCurve,
  36035. Arc: Arc,
  36036. IncrementalDisplayable: IncrementalDisplayable,
  36037. CompoundPath: CompoundPath,
  36038. LinearGradient: LinearGradient,
  36039. RadialGradient: RadialGradient,
  36040. BoundingRect: BoundingRect
  36041. });
  36042. var format$1 = (Object.freeze || Object)({
  36043. addCommas: addCommas,
  36044. toCamelCase: toCamelCase,
  36045. normalizeCssArray: normalizeCssArray$1,
  36046. encodeHTML: encodeHTML,
  36047. formatTpl: formatTpl,
  36048. getTooltipMarker: getTooltipMarker,
  36049. formatTime: formatTime,
  36050. capitalFirst: capitalFirst,
  36051. truncateText: truncateText,
  36052. getTextRect: getTextRect
  36053. });
  36054. var util$1 = (Object.freeze || Object)({
  36055. map: map,
  36056. each: each$1,
  36057. indexOf: indexOf$1,
  36058. inherits: inherits,
  36059. reduce: reduce,
  36060. filter: filter,
  36061. bind: bind,
  36062. curry: curry,
  36063. isArray: isArray,
  36064. isString: isString,
  36065. isObject: isObject$1,
  36066. isFunction: isFunction$1,
  36067. extend: extend,
  36068. defaults: defaults,
  36069. clone: clone,
  36070. merge: merge
  36071. });
  36072. /*
  36073. * Licensed to the Apache Software Foundation (ASF) under one
  36074. * or more contributor license agreements. See the NOTICE file
  36075. * distributed with this work for additional information
  36076. * regarding copyright ownership. The ASF licenses this file
  36077. * to you under the Apache License, Version 2.0 (the
  36078. * "License"); you may not use this file except in compliance
  36079. * with the License. You may obtain a copy of the License at
  36080. *
  36081. * http://www.apache.org/licenses/LICENSE-2.0
  36082. *
  36083. * Unless required by applicable law or agreed to in writing,
  36084. * software distributed under the License is distributed on an
  36085. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36086. * KIND, either express or implied. See the License for the
  36087. * specific language governing permissions and limitations
  36088. * under the License.
  36089. */
  36090. /**
  36091. * AUTO-GENERATED FILE. DO NOT MODIFY.
  36092. */
  36093. /*
  36094. * Licensed to the Apache Software Foundation (ASF) under one
  36095. * or more contributor license agreements. See the NOTICE file
  36096. * distributed with this work for additional information
  36097. * regarding copyright ownership. The ASF licenses this file
  36098. * to you under the Apache License, Version 2.0 (the
  36099. * "License"); you may not use this file except in compliance
  36100. * with the License. You may obtain a copy of the License at
  36101. *
  36102. * http://www.apache.org/licenses/LICENSE-2.0
  36103. *
  36104. * Unless required by applicable law or agreed to in writing,
  36105. * software distributed under the License is distributed on an
  36106. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36107. * KIND, either express or implied. See the License for the
  36108. * specific language governing permissions and limitations
  36109. * under the License.
  36110. */
  36111. var inner$4 = makeInner();
  36112. function createAxisLabels(axis) {
  36113. // Only ordinal scale support tick interval
  36114. return axis.type === 'category' ? makeCategoryLabels(axis) : makeRealNumberLabels(axis);
  36115. }
  36116. /**
  36117. * @param {module:echats/coord/Axis} axis
  36118. * @param {module:echarts/model/Model} tickModel For example, can be axisTick, splitLine, splitArea.
  36119. * @return {Object} {
  36120. * ticks: Array.<number>
  36121. * tickCategoryInterval: number
  36122. * }
  36123. */
  36124. function createAxisTicks(axis, tickModel) {
  36125. // Only ordinal scale support tick interval
  36126. return axis.type === 'category' ? makeCategoryTicks(axis, tickModel) : {
  36127. ticks: map(axis.scale.getTicks(), function (tick) {
  36128. return tick.value;
  36129. })
  36130. };
  36131. }
  36132. function makeCategoryLabels(axis) {
  36133. var labelModel = axis.getLabelModel();
  36134. var result = makeCategoryLabelsActually(axis, labelModel);
  36135. return !labelModel.get('show') || axis.scale.isBlank() ? {
  36136. labels: [],
  36137. labelCategoryInterval: result.labelCategoryInterval
  36138. } : result;
  36139. }
  36140. function makeCategoryLabelsActually(axis, labelModel) {
  36141. var labelsCache = getListCache(axis, 'labels');
  36142. var optionLabelInterval = getOptionCategoryInterval(labelModel);
  36143. var result = listCacheGet(labelsCache, optionLabelInterval);
  36144. if (result) {
  36145. return result;
  36146. }
  36147. var labels;
  36148. var numericLabelInterval;
  36149. if (isFunction$1(optionLabelInterval)) {
  36150. labels = makeLabelsByCustomizedCategoryInterval(axis, optionLabelInterval);
  36151. } else {
  36152. numericLabelInterval = optionLabelInterval === 'auto' ? makeAutoCategoryInterval(axis) : optionLabelInterval;
  36153. labels = makeLabelsByNumericCategoryInterval(axis, numericLabelInterval);
  36154. } // Cache to avoid calling interval function repeatly.
  36155. return listCacheSet(labelsCache, optionLabelInterval, {
  36156. labels: labels,
  36157. labelCategoryInterval: numericLabelInterval
  36158. });
  36159. }
  36160. function makeCategoryTicks(axis, tickModel) {
  36161. var ticksCache = getListCache(axis, 'ticks');
  36162. var optionTickInterval = getOptionCategoryInterval(tickModel);
  36163. var result = listCacheGet(ticksCache, optionTickInterval);
  36164. if (result) {
  36165. return result;
  36166. }
  36167. var ticks;
  36168. var tickCategoryInterval; // Optimize for the case that large category data and no label displayed,
  36169. // we should not return all ticks.
  36170. if (!tickModel.get('show') || axis.scale.isBlank()) {
  36171. ticks = [];
  36172. }
  36173. if (isFunction$1(optionTickInterval)) {
  36174. ticks = makeLabelsByCustomizedCategoryInterval(axis, optionTickInterval, true);
  36175. } // Always use label interval by default despite label show. Consider this
  36176. // scenario, Use multiple grid with the xAxis sync, and only one xAxis shows
  36177. // labels. `splitLine` and `axisTick` should be consistent in this case.
  36178. else if (optionTickInterval === 'auto') {
  36179. var labelsResult = makeCategoryLabelsActually(axis, axis.getLabelModel());
  36180. tickCategoryInterval = labelsResult.labelCategoryInterval;
  36181. ticks = map(labelsResult.labels, function (labelItem) {
  36182. return labelItem.tickValue;
  36183. });
  36184. } else {
  36185. tickCategoryInterval = optionTickInterval;
  36186. ticks = makeLabelsByNumericCategoryInterval(axis, tickCategoryInterval, true);
  36187. } // Cache to avoid calling interval function repeatly.
  36188. return listCacheSet(ticksCache, optionTickInterval, {
  36189. ticks: ticks,
  36190. tickCategoryInterval: tickCategoryInterval
  36191. });
  36192. }
  36193. function makeRealNumberLabels(axis) {
  36194. var ticks = axis.scale.getTicks();
  36195. var labelFormatter = makeLabelFormatter(axis);
  36196. return {
  36197. labels: map(ticks, function (tick, idx) {
  36198. return {
  36199. formattedLabel: labelFormatter(tick, idx),
  36200. rawLabel: axis.scale.getLabel(tick),
  36201. tickValue: tick.value
  36202. };
  36203. })
  36204. };
  36205. }
  36206. function getListCache(axis, prop) {
  36207. // Because key can be funciton, and cache size always be small, we use array cache.
  36208. return inner$4(axis)[prop] || (inner$4(axis)[prop] = []);
  36209. }
  36210. function listCacheGet(cache, key) {
  36211. for (var i = 0; i < cache.length; i++) {
  36212. if (cache[i].key === key) {
  36213. return cache[i].value;
  36214. }
  36215. }
  36216. }
  36217. function listCacheSet(cache, key, value) {
  36218. cache.push({
  36219. key: key,
  36220. value: value
  36221. });
  36222. return value;
  36223. }
  36224. function makeAutoCategoryInterval(axis) {
  36225. var result = inner$4(axis).autoInterval;
  36226. return result != null ? result : inner$4(axis).autoInterval = axis.calculateCategoryInterval();
  36227. }
  36228. /**
  36229. * Calculate interval for category axis ticks and labels.
  36230. * To get precise result, at least one of `getRotate` and `isHorizontal`
  36231. * should be implemented in axis.
  36232. */
  36233. function calculateCategoryInterval(axis) {
  36234. var params = fetchAutoCategoryIntervalCalculationParams(axis);
  36235. var labelFormatter = makeLabelFormatter(axis);
  36236. var rotation = (params.axisRotate - params.labelRotate) / 180 * Math.PI;
  36237. var ordinalScale = axis.scale;
  36238. var ordinalExtent = ordinalScale.getExtent(); // Providing this method is for optimization:
  36239. // avoid generating a long array by `getTicks`
  36240. // in large category data case.
  36241. var tickCount = ordinalScale.count();
  36242. if (ordinalExtent[1] - ordinalExtent[0] < 1) {
  36243. return 0;
  36244. }
  36245. var step = 1; // Simple optimization. Empirical value: tick count should less than 40.
  36246. if (tickCount > 40) {
  36247. step = Math.max(1, Math.floor(tickCount / 40));
  36248. }
  36249. var tickValue = ordinalExtent[0];
  36250. var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
  36251. var unitW = Math.abs(unitSpan * Math.cos(rotation));
  36252. var unitH = Math.abs(unitSpan * Math.sin(rotation));
  36253. var maxW = 0;
  36254. var maxH = 0; // Caution: Performance sensitive for large category data.
  36255. // Consider dataZoom, we should make appropriate step to avoid O(n) loop.
  36256. for (; tickValue <= ordinalExtent[1]; tickValue += step) {
  36257. var width = 0;
  36258. var height = 0; // Not precise, do not consider align and vertical align
  36259. // and each distance from axis line yet.
  36260. var rect = getBoundingRect(labelFormatter({
  36261. value: tickValue
  36262. }), params.font, 'center', 'top'); // Magic number
  36263. width = rect.width * 1.3;
  36264. height = rect.height * 1.3; // Min size, void long loop.
  36265. maxW = Math.max(maxW, width, 7);
  36266. maxH = Math.max(maxH, height, 7);
  36267. }
  36268. var dw = maxW / unitW;
  36269. var dh = maxH / unitH; // 0/0 is NaN, 1/0 is Infinity.
  36270. isNaN(dw) && (dw = Infinity);
  36271. isNaN(dh) && (dh = Infinity);
  36272. var interval = Math.max(0, Math.floor(Math.min(dw, dh)));
  36273. var cache = inner$4(axis.model);
  36274. var axisExtent = axis.getExtent();
  36275. var lastAutoInterval = cache.lastAutoInterval;
  36276. var lastTickCount = cache.lastTickCount; // Use cache to keep interval stable while moving zoom window,
  36277. // otherwise the calculated interval might jitter when the zoom
  36278. // window size is close to the interval-changing size.
  36279. // For example, if all of the axis labels are `a, b, c, d, e, f, g`.
  36280. // The jitter will cause that sometimes the displayed labels are
  36281. // `a, d, g` (interval: 2) sometimes `a, c, e`(interval: 1).
  36282. if (lastAutoInterval != null && lastTickCount != null && Math.abs(lastAutoInterval - interval) <= 1 && Math.abs(lastTickCount - tickCount) <= 1 // Always choose the bigger one, otherwise the critical
  36283. // point is not the same when zooming in or zooming out.
  36284. && lastAutoInterval > interval // If the axis change is caused by chart resize, the cache should not
  36285. // be used. Otherwise some hiden labels might not be shown again.
  36286. && cache.axisExtent0 === axisExtent[0] && cache.axisExtent1 === axisExtent[1]) {
  36287. interval = lastAutoInterval;
  36288. } // Only update cache if cache not used, otherwise the
  36289. // changing of interval is too insensitive.
  36290. else {
  36291. cache.lastTickCount = tickCount;
  36292. cache.lastAutoInterval = interval;
  36293. cache.axisExtent0 = axisExtent[0];
  36294. cache.axisExtent1 = axisExtent[1];
  36295. }
  36296. return interval;
  36297. }
  36298. function fetchAutoCategoryIntervalCalculationParams(axis) {
  36299. var labelModel = axis.getLabelModel();
  36300. return {
  36301. axisRotate: axis.getRotate ? axis.getRotate() : axis.isHorizontal && !axis.isHorizontal() ? 90 : 0,
  36302. labelRotate: labelModel.get('rotate') || 0,
  36303. font: labelModel.getFont()
  36304. };
  36305. }
  36306. function makeLabelsByNumericCategoryInterval(axis, categoryInterval, onlyTick) {
  36307. var labelFormatter = makeLabelFormatter(axis);
  36308. var ordinalScale = axis.scale;
  36309. var ordinalExtent = ordinalScale.getExtent();
  36310. var labelModel = axis.getLabelModel();
  36311. var result = []; // TODO: axisType: ordinalTime, pick the tick from each month/day/year/...
  36312. var step = Math.max((categoryInterval || 0) + 1, 1);
  36313. var startTick = ordinalExtent[0];
  36314. var tickCount = ordinalScale.count(); // Calculate start tick based on zero if possible to keep label consistent
  36315. // while zooming and moving while interval > 0. Otherwise the selection
  36316. // of displayable ticks and symbols probably keep changing.
  36317. // 3 is empirical value.
  36318. if (startTick !== 0 && step > 1 && tickCount / step > 2) {
  36319. startTick = Math.round(Math.ceil(startTick / step) * step);
  36320. } // (1) Only add min max label here but leave overlap checking
  36321. // to render stage, which also ensure the returned list
  36322. // suitable for splitLine and splitArea rendering.
  36323. // (2) Scales except category always contain min max label so
  36324. // do not need to perform this process.
  36325. var showAllLabel = shouldShowAllLabels(axis);
  36326. var includeMinLabel = labelModel.get('showMinLabel') || showAllLabel;
  36327. var includeMaxLabel = labelModel.get('showMaxLabel') || showAllLabel;
  36328. if (includeMinLabel && startTick !== ordinalExtent[0]) {
  36329. addItem(ordinalExtent[0]);
  36330. } // Optimize: avoid generating large array by `ordinalScale.getTicks()`.
  36331. var tickValue = startTick;
  36332. for (; tickValue <= ordinalExtent[1]; tickValue += step) {
  36333. addItem(tickValue);
  36334. }
  36335. if (includeMaxLabel && tickValue - step !== ordinalExtent[1]) {
  36336. addItem(ordinalExtent[1]);
  36337. }
  36338. function addItem(tickValue) {
  36339. var tickObj = {
  36340. value: tickValue
  36341. };
  36342. result.push(onlyTick ? tickValue : {
  36343. formattedLabel: labelFormatter(tickObj),
  36344. rawLabel: ordinalScale.getLabel(tickObj),
  36345. tickValue: tickValue
  36346. });
  36347. }
  36348. return result;
  36349. }
  36350. function makeLabelsByCustomizedCategoryInterval(axis, categoryInterval, onlyTick) {
  36351. var ordinalScale = axis.scale;
  36352. var labelFormatter = makeLabelFormatter(axis);
  36353. var result = [];
  36354. each$1(ordinalScale.getTicks(), function (tick) {
  36355. var rawLabel = ordinalScale.getLabel(tick);
  36356. var tickValue = tick.value;
  36357. if (categoryInterval(tick.value, rawLabel)) {
  36358. result.push(onlyTick ? tickValue : {
  36359. formattedLabel: labelFormatter(tick),
  36360. rawLabel: rawLabel,
  36361. tickValue: tickValue
  36362. });
  36363. }
  36364. });
  36365. return result;
  36366. }
  36367. /*
  36368. * Licensed to the Apache Software Foundation (ASF) under one
  36369. * or more contributor license agreements. See the NOTICE file
  36370. * distributed with this work for additional information
  36371. * regarding copyright ownership. The ASF licenses this file
  36372. * to you under the Apache License, Version 2.0 (the
  36373. * "License"); you may not use this file except in compliance
  36374. * with the License. You may obtain a copy of the License at
  36375. *
  36376. * http://www.apache.org/licenses/LICENSE-2.0
  36377. *
  36378. * Unless required by applicable law or agreed to in writing,
  36379. * software distributed under the License is distributed on an
  36380. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36381. * KIND, either express or implied. See the License for the
  36382. * specific language governing permissions and limitations
  36383. * under the License.
  36384. */
  36385. /**
  36386. * AUTO-GENERATED FILE. DO NOT MODIFY.
  36387. */
  36388. /*
  36389. * Licensed to the Apache Software Foundation (ASF) under one
  36390. * or more contributor license agreements. See the NOTICE file
  36391. * distributed with this work for additional information
  36392. * regarding copyright ownership. The ASF licenses this file
  36393. * to you under the Apache License, Version 2.0 (the
  36394. * "License"); you may not use this file except in compliance
  36395. * with the License. You may obtain a copy of the License at
  36396. *
  36397. * http://www.apache.org/licenses/LICENSE-2.0
  36398. *
  36399. * Unless required by applicable law or agreed to in writing,
  36400. * software distributed under the License is distributed on an
  36401. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36402. * KIND, either express or implied. See the License for the
  36403. * specific language governing permissions and limitations
  36404. * under the License.
  36405. */
  36406. var NORMALIZED_EXTENT = [0, 1];
  36407. /**
  36408. * Base class of Axis.
  36409. */
  36410. var Axis =
  36411. /** @class */
  36412. function () {
  36413. function Axis(dim, scale, extent) {
  36414. this.onBand = false;
  36415. this.inverse = false;
  36416. this.dim = dim;
  36417. this.scale = scale;
  36418. this._extent = extent || [0, 0];
  36419. }
  36420. /**
  36421. * If axis extent contain given coord
  36422. */
  36423. Axis.prototype.contain = function (coord) {
  36424. var extent = this._extent;
  36425. var min = Math.min(extent[0], extent[1]);
  36426. var max = Math.max(extent[0], extent[1]);
  36427. return coord >= min && coord <= max;
  36428. };
  36429. /**
  36430. * If axis extent contain given data
  36431. */
  36432. Axis.prototype.containData = function (data) {
  36433. return this.scale.contain(data);
  36434. };
  36435. /**
  36436. * Get coord extent.
  36437. */
  36438. Axis.prototype.getExtent = function () {
  36439. return this._extent.slice();
  36440. };
  36441. /**
  36442. * Get precision used for formatting
  36443. */
  36444. Axis.prototype.getPixelPrecision = function (dataExtent) {
  36445. return getPixelPrecision(dataExtent || this.scale.getExtent(), this._extent);
  36446. };
  36447. /**
  36448. * Set coord extent
  36449. */
  36450. Axis.prototype.setExtent = function (start, end) {
  36451. var extent = this._extent;
  36452. extent[0] = start;
  36453. extent[1] = end;
  36454. };
  36455. /**
  36456. * Convert data to coord. Data is the rank if it has an ordinal scale
  36457. */
  36458. Axis.prototype.dataToCoord = function (data, clamp) {
  36459. var extent = this._extent;
  36460. var scale = this.scale;
  36461. data = scale.normalize(data);
  36462. if (this.onBand && scale.type === 'ordinal') {
  36463. extent = extent.slice();
  36464. fixExtentWithBands(extent, scale.count());
  36465. }
  36466. return linearMap(data, NORMALIZED_EXTENT, extent, clamp);
  36467. };
  36468. /**
  36469. * Convert coord to data. Data is the rank if it has an ordinal scale
  36470. */
  36471. Axis.prototype.coordToData = function (coord, clamp) {
  36472. var extent = this._extent;
  36473. var scale = this.scale;
  36474. if (this.onBand && scale.type === 'ordinal') {
  36475. extent = extent.slice();
  36476. fixExtentWithBands(extent, scale.count());
  36477. }
  36478. var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp);
  36479. return this.scale.scale(t);
  36480. };
  36481. /**
  36482. * Convert pixel point to data in axis
  36483. */
  36484. Axis.prototype.pointToData = function (point, clamp) {
  36485. // Should be implemented in derived class if necessary.
  36486. return;
  36487. };
  36488. /**
  36489. * Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
  36490. * `axis.getTicksCoords` considers `onBand`, which is used by
  36491. * `boundaryGap:true` of category axis and splitLine and splitArea.
  36492. * @param opt.tickModel default: axis.model.getModel('axisTick')
  36493. * @param opt.clamp If `true`, the first and the last
  36494. * tick must be at the axis end points. Otherwise, clip ticks
  36495. * that outside the axis extent.
  36496. */
  36497. Axis.prototype.getTicksCoords = function (opt) {
  36498. opt = opt || {};
  36499. var tickModel = opt.tickModel || this.getTickModel();
  36500. var result = createAxisTicks(this, tickModel);
  36501. var ticks = result.ticks;
  36502. var ticksCoords = map(ticks, function (tickVal) {
  36503. return {
  36504. coord: this.dataToCoord(this.scale.type === 'ordinal' ? this.scale.getRawOrdinalNumber(tickVal) : tickVal),
  36505. tickValue: tickVal
  36506. };
  36507. }, this);
  36508. var alignWithLabel = tickModel.get('alignWithLabel');
  36509. fixOnBandTicksCoords(this, ticksCoords, alignWithLabel, opt.clamp);
  36510. return ticksCoords;
  36511. };
  36512. Axis.prototype.getMinorTicksCoords = function () {
  36513. if (this.scale.type === 'ordinal') {
  36514. // Category axis doesn't support minor ticks
  36515. return [];
  36516. }
  36517. var minorTickModel = this.model.getModel('minorTick');
  36518. var splitNumber = minorTickModel.get('splitNumber'); // Protection.
  36519. if (!(splitNumber > 0 && splitNumber < 100)) {
  36520. splitNumber = 5;
  36521. }
  36522. var minorTicks = this.scale.getMinorTicks(splitNumber);
  36523. var minorTicksCoords = map(minorTicks, function (minorTicksGroup) {
  36524. return map(minorTicksGroup, function (minorTick) {
  36525. return {
  36526. coord: this.dataToCoord(minorTick),
  36527. tickValue: minorTick
  36528. };
  36529. }, this);
  36530. }, this);
  36531. return minorTicksCoords;
  36532. };
  36533. Axis.prototype.getViewLabels = function () {
  36534. return createAxisLabels(this).labels;
  36535. };
  36536. Axis.prototype.getLabelModel = function () {
  36537. return this.model.getModel('axisLabel');
  36538. };
  36539. /**
  36540. * Notice here we only get the default tick model. For splitLine
  36541. * or splitArea, we should pass the splitLineModel or splitAreaModel
  36542. * manually when calling `getTicksCoords`.
  36543. * In GL, this method may be overrided to:
  36544. * `axisModel.getModel('axisTick', grid3DModel.getModel('axisTick'));`
  36545. */
  36546. Axis.prototype.getTickModel = function () {
  36547. return this.model.getModel('axisTick');
  36548. };
  36549. /**
  36550. * Get width of band
  36551. */
  36552. Axis.prototype.getBandWidth = function () {
  36553. var axisExtent = this._extent;
  36554. var dataExtent = this.scale.getExtent();
  36555. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0); // Fix #2728, avoid NaN when only one data.
  36556. len === 0 && (len = 1);
  36557. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  36558. return Math.abs(size) / len;
  36559. };
  36560. /**
  36561. * Only be called in category axis.
  36562. * Can be overrided, consider other axes like in 3D.
  36563. * @return Auto interval for cateogry axis tick and label
  36564. */
  36565. Axis.prototype.calculateCategoryInterval = function () {
  36566. return calculateCategoryInterval(this);
  36567. };
  36568. return Axis;
  36569. }();
  36570. function fixExtentWithBands(extent, nTick) {
  36571. var size = extent[1] - extent[0];
  36572. var len = nTick;
  36573. var margin = size / len / 2;
  36574. extent[0] += margin;
  36575. extent[1] -= margin;
  36576. } // If axis has labels [1, 2, 3, 4]. Bands on the axis are
  36577. // |---1---|---2---|---3---|---4---|.
  36578. // So the displayed ticks and splitLine/splitArea should between
  36579. // each data item, otherwise cause misleading (e.g., split tow bars
  36580. // of a single data item when there are two bar series).
  36581. // Also consider if tickCategoryInterval > 0 and onBand, ticks and
  36582. // splitLine/spliteArea should layout appropriately corresponding
  36583. // to displayed labels. (So we should not use `getBandWidth` in this
  36584. // case).
  36585. function fixOnBandTicksCoords(axis, ticksCoords, alignWithLabel, clamp) {
  36586. var ticksLen = ticksCoords.length;
  36587. if (!axis.onBand || alignWithLabel || !ticksLen) {
  36588. return;
  36589. }
  36590. var axisExtent = axis.getExtent();
  36591. var last;
  36592. var diffSize;
  36593. if (ticksLen === 1) {
  36594. ticksCoords[0].coord = axisExtent[0];
  36595. last = ticksCoords[1] = {
  36596. coord: axisExtent[0]
  36597. };
  36598. } else {
  36599. var crossLen = ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue;
  36600. var shift_1 = (ticksCoords[ticksLen - 1].coord - ticksCoords[0].coord) / crossLen;
  36601. each$1(ticksCoords, function (ticksItem) {
  36602. ticksItem.coord -= shift_1 / 2;
  36603. });
  36604. var dataExtent = axis.scale.getExtent();
  36605. diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue;
  36606. last = {
  36607. coord: ticksCoords[ticksLen - 1].coord + shift_1 * diffSize
  36608. };
  36609. ticksCoords.push(last);
  36610. }
  36611. var inverse = axisExtent[0] > axisExtent[1]; // Handling clamp.
  36612. if (littleThan(ticksCoords[0].coord, axisExtent[0])) {
  36613. clamp ? ticksCoords[0].coord = axisExtent[0] : ticksCoords.shift();
  36614. }
  36615. if (clamp && littleThan(axisExtent[0], ticksCoords[0].coord)) {
  36616. ticksCoords.unshift({
  36617. coord: axisExtent[0]
  36618. });
  36619. }
  36620. if (littleThan(axisExtent[1], last.coord)) {
  36621. clamp ? last.coord = axisExtent[1] : ticksCoords.pop();
  36622. }
  36623. if (clamp && littleThan(last.coord, axisExtent[1])) {
  36624. ticksCoords.push({
  36625. coord: axisExtent[1]
  36626. });
  36627. }
  36628. function littleThan(a, b) {
  36629. // Avoid rounding error cause calculated tick coord different with extent.
  36630. // It may cause an extra unecessary tick added.
  36631. a = round(a);
  36632. b = round(b);
  36633. return inverse ? a > b : a < b;
  36634. }
  36635. }
  36636. /*
  36637. * Licensed to the Apache Software Foundation (ASF) under one
  36638. * or more contributor license agreements. See the NOTICE file
  36639. * distributed with this work for additional information
  36640. * regarding copyright ownership. The ASF licenses this file
  36641. * to you under the Apache License, Version 2.0 (the
  36642. * "License"); you may not use this file except in compliance
  36643. * with the License. You may obtain a copy of the License at
  36644. *
  36645. * http://www.apache.org/licenses/LICENSE-2.0
  36646. *
  36647. * Unless required by applicable law or agreed to in writing,
  36648. * software distributed under the License is distributed on an
  36649. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36650. * KIND, either express or implied. See the License for the
  36651. * specific language governing permissions and limitations
  36652. * under the License.
  36653. */
  36654. /**
  36655. * AUTO-GENERATED FILE. DO NOT MODIFY.
  36656. */
  36657. /*
  36658. * Licensed to the Apache Software Foundation (ASF) under one
  36659. * or more contributor license agreements. See the NOTICE file
  36660. * distributed with this work for additional information
  36661. * regarding copyright ownership. The ASF licenses this file
  36662. * to you under the Apache License, Version 2.0 (the
  36663. * "License"); you may not use this file except in compliance
  36664. * with the License. You may obtain a copy of the License at
  36665. *
  36666. * http://www.apache.org/licenses/LICENSE-2.0
  36667. *
  36668. * Unless required by applicable law or agreed to in writing,
  36669. * software distributed under the License is distributed on an
  36670. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  36671. * KIND, either express or implied. See the License for the
  36672. * specific language governing permissions and limitations
  36673. * under the License.
  36674. */
  36675. // These APIs are for more advanced usages
  36676. // For example extend charts and components, creating graphic elements, formatting.
  36677. // Should use `ComponentModel.extend` or `class XXXX extend ComponentModel` to create class.
  36678. // Then use `registerComponentModel` in `install` parameter when `use` this extension. For example:
  36679. // class Bar3DModel extends ComponentModel {}
  36680. // export function install(registers) { regsiters.registerComponentModel(Bar3DModel); }
  36681. // echarts.use(install);
  36682. function extendComponentModel(proto) {
  36683. var Model = ComponentModel.extend(proto);
  36684. ComponentModel.registerClass(Model);
  36685. return Model;
  36686. }
  36687. function extendComponentView(proto) {
  36688. var View = ComponentView.extend(proto);
  36689. ComponentView.registerClass(View);
  36690. return View;
  36691. }
  36692. function extendSeriesModel(proto) {
  36693. var Model = SeriesModel.extend(proto);
  36694. SeriesModel.registerClass(Model);
  36695. return Model;
  36696. }
  36697. function extendChartView(proto) {
  36698. var View = ChartView.extend(proto);
  36699. ChartView.registerClass(View);
  36700. return View;
  36701. }
  36702. function returnFalse() {
  36703. return false;
  36704. }
  36705. function createDom(id, painter, dpr) {
  36706. var newDom = createCanvas();
  36707. var width = painter.getWidth();
  36708. var height = painter.getHeight();
  36709. var newDomStyle = newDom.style;
  36710. if (newDomStyle) {
  36711. newDomStyle.position = 'absolute';
  36712. newDomStyle.left = '0';
  36713. newDomStyle.top = '0';
  36714. newDomStyle.width = width + 'px';
  36715. newDomStyle.height = height + 'px';
  36716. newDom.setAttribute('data-zr-dom-id', id);
  36717. }
  36718. newDom.width = width * dpr;
  36719. newDom.height = height * dpr;
  36720. return newDom;
  36721. }
  36722. var Layer = function (_super) {
  36723. __extends(Layer, _super);
  36724. function Layer(id, painter, dpr) {
  36725. var _this = _super.call(this) || this;
  36726. _this.motionBlur = false;
  36727. _this.lastFrameAlpha = 0.7;
  36728. _this.dpr = 1;
  36729. _this.virtual = false;
  36730. _this.config = {};
  36731. _this.incremental = false;
  36732. _this.zlevel = 0;
  36733. _this.maxRepaintRectCount = 5;
  36734. _this.__dirty = true;
  36735. _this.__firstTimePaint = true;
  36736. _this.__used = false;
  36737. _this.__drawIndex = 0;
  36738. _this.__startIndex = 0;
  36739. _this.__endIndex = 0;
  36740. _this.__prevStartIndex = null;
  36741. _this.__prevEndIndex = null;
  36742. var dom;
  36743. dpr = dpr || devicePixelRatio;
  36744. if (typeof id === 'string') {
  36745. dom = createDom(id, painter, dpr);
  36746. } else if (isObject$1(id)) {
  36747. dom = id;
  36748. id = dom.id;
  36749. }
  36750. _this.id = id;
  36751. _this.dom = dom;
  36752. var domStyle = dom.style;
  36753. if (domStyle) {
  36754. dom.onselectstart = returnFalse;
  36755. domStyle.webkitUserSelect = 'none';
  36756. domStyle.userSelect = 'none';
  36757. domStyle.webkitTapHighlightColor = 'rgba(0,0,0,0)';
  36758. domStyle['-webkit-touch-callout'] = 'none';
  36759. domStyle.padding = '0';
  36760. domStyle.margin = '0';
  36761. domStyle.borderWidth = '0';
  36762. }
  36763. _this.domBack = null;
  36764. _this.ctxBack = null;
  36765. _this.painter = painter;
  36766. _this.config = null;
  36767. _this.dpr = dpr;
  36768. return _this;
  36769. }
  36770. Layer.prototype.getElementCount = function () {
  36771. return this.__endIndex - this.__startIndex;
  36772. };
  36773. Layer.prototype.afterBrush = function () {
  36774. this.__prevStartIndex = this.__startIndex;
  36775. this.__prevEndIndex = this.__endIndex;
  36776. };
  36777. Layer.prototype.initContext = function () {
  36778. this.ctx = this.dom.getContext('2d');
  36779. this.ctx.dpr = this.dpr;
  36780. };
  36781. Layer.prototype.setUnpainted = function () {
  36782. this.__firstTimePaint = true;
  36783. };
  36784. Layer.prototype.createBackBuffer = function () {
  36785. var dpr = this.dpr;
  36786. this.domBack = createDom('back-' + this.id, this.painter, dpr);
  36787. this.ctxBack = this.domBack.getContext('2d');
  36788. if (dpr !== 1) {
  36789. this.ctxBack.scale(dpr, dpr);
  36790. }
  36791. };
  36792. Layer.prototype.createRepaintRects = function (displayList, prevList, viewWidth, viewHeight) {
  36793. if (this.__firstTimePaint) {
  36794. this.__firstTimePaint = false;
  36795. return null;
  36796. }
  36797. var mergedRepaintRects = [];
  36798. var maxRepaintRectCount = this.maxRepaintRectCount;
  36799. var full = false;
  36800. var pendingRect = new BoundingRect(0, 0, 0, 0);
  36801. function addRectToMergePool(rect) {
  36802. if (!rect.isFinite() || rect.isZero()) {
  36803. return;
  36804. }
  36805. if (mergedRepaintRects.length === 0) {
  36806. var boundingRect = new BoundingRect(0, 0, 0, 0);
  36807. boundingRect.copy(rect);
  36808. mergedRepaintRects.push(boundingRect);
  36809. } else {
  36810. var isMerged = false;
  36811. var minDeltaArea = Infinity;
  36812. var bestRectToMergeIdx = 0;
  36813. for (var i = 0; i < mergedRepaintRects.length; ++i) {
  36814. var mergedRect = mergedRepaintRects[i];
  36815. if (mergedRect.intersect(rect)) {
  36816. var pendingRect_1 = new BoundingRect(0, 0, 0, 0);
  36817. pendingRect_1.copy(mergedRect);
  36818. pendingRect_1.union(rect);
  36819. mergedRepaintRects[i] = pendingRect_1;
  36820. isMerged = true;
  36821. break;
  36822. } else if (full) {
  36823. pendingRect.copy(rect);
  36824. pendingRect.union(mergedRect);
  36825. var aArea = rect.width * rect.height;
  36826. var bArea = mergedRect.width * mergedRect.height;
  36827. var pendingArea = pendingRect.width * pendingRect.height;
  36828. var deltaArea = pendingArea - aArea - bArea;
  36829. if (deltaArea < minDeltaArea) {
  36830. minDeltaArea = deltaArea;
  36831. bestRectToMergeIdx = i;
  36832. }
  36833. }
  36834. }
  36835. if (full) {
  36836. mergedRepaintRects[bestRectToMergeIdx].union(rect);
  36837. isMerged = true;
  36838. }
  36839. if (!isMerged) {
  36840. var boundingRect = new BoundingRect(0, 0, 0, 0);
  36841. boundingRect.copy(rect);
  36842. mergedRepaintRects.push(boundingRect);
  36843. }
  36844. if (!full) {
  36845. full = mergedRepaintRects.length >= maxRepaintRectCount;
  36846. }
  36847. }
  36848. }
  36849. for (var i = this.__startIndex; i < this.__endIndex; ++i) {
  36850. var el = displayList[i];
  36851. if (el) {
  36852. var shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
  36853. var prevRect = el.__isRendered && (el.__dirty & Element.REDARAW_BIT || !shouldPaint) ? el.getPrevPaintRect() : null;
  36854. if (prevRect) {
  36855. addRectToMergePool(prevRect);
  36856. }
  36857. var curRect = shouldPaint && (el.__dirty & Element.REDARAW_BIT || !el.__isRendered) ? el.getPaintRect() : null;
  36858. if (curRect) {
  36859. addRectToMergePool(curRect);
  36860. }
  36861. }
  36862. }
  36863. for (var i = this.__prevStartIndex; i < this.__prevEndIndex; ++i) {
  36864. var el = prevList[i];
  36865. var shouldPaint = el.shouldBePainted(viewWidth, viewHeight, true, true);
  36866. if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
  36867. var prevRect = el.getPrevPaintRect();
  36868. if (prevRect) {
  36869. addRectToMergePool(prevRect);
  36870. }
  36871. }
  36872. }
  36873. var hasIntersections;
  36874. do {
  36875. hasIntersections = false;
  36876. for (var i = 0; i < mergedRepaintRects.length;) {
  36877. if (mergedRepaintRects[i].isZero()) {
  36878. mergedRepaintRects.splice(i, 1);
  36879. continue;
  36880. }
  36881. for (var j = i + 1; j < mergedRepaintRects.length;) {
  36882. if (mergedRepaintRects[i].intersect(mergedRepaintRects[j])) {
  36883. hasIntersections = true;
  36884. mergedRepaintRects[i].union(mergedRepaintRects[j]);
  36885. mergedRepaintRects.splice(j, 1);
  36886. } else {
  36887. j++;
  36888. }
  36889. }
  36890. i++;
  36891. }
  36892. } while (hasIntersections);
  36893. this._paintRects = mergedRepaintRects;
  36894. return mergedRepaintRects;
  36895. };
  36896. Layer.prototype.debugGetPaintRects = function () {
  36897. return (this._paintRects || []).slice();
  36898. };
  36899. Layer.prototype.resize = function (width, height) {
  36900. var dpr = this.dpr;
  36901. var dom = this.dom;
  36902. var domStyle = dom.style;
  36903. var domBack = this.domBack;
  36904. if (domStyle) {
  36905. domStyle.width = width + 'px';
  36906. domStyle.height = height + 'px';
  36907. }
  36908. dom.width = width * dpr;
  36909. dom.height = height * dpr;
  36910. if (domBack) {
  36911. domBack.width = width * dpr;
  36912. domBack.height = height * dpr;
  36913. if (dpr !== 1) {
  36914. this.ctxBack.scale(dpr, dpr);
  36915. }
  36916. }
  36917. };
  36918. Layer.prototype.clear = function (clearAll, clearColor, repaintRects) {
  36919. var dom = this.dom;
  36920. var ctx = this.ctx;
  36921. var width = dom.width;
  36922. var height = dom.height;
  36923. clearColor = clearColor || this.clearColor;
  36924. var haveMotionBLur = this.motionBlur && !clearAll;
  36925. var lastFrameAlpha = this.lastFrameAlpha;
  36926. var dpr = this.dpr;
  36927. var self = this;
  36928. if (haveMotionBLur) {
  36929. if (!this.domBack) {
  36930. this.createBackBuffer();
  36931. }
  36932. this.ctxBack.globalCompositeOperation = 'copy';
  36933. this.ctxBack.drawImage(dom, 0, 0, width / dpr, height / dpr);
  36934. }
  36935. var domBack = this.domBack;
  36936. function doClear(x, y, width, height) {
  36937. ctx.clearRect(x, y, width, height);
  36938. if (clearColor && clearColor !== 'transparent') {
  36939. var clearColorGradientOrPattern = void 0;
  36940. if (isGradientObject(clearColor)) {
  36941. clearColorGradientOrPattern = clearColor.__canvasGradient || getCanvasGradient(ctx, clearColor, {
  36942. x: 0,
  36943. y: 0,
  36944. width: width,
  36945. height: height
  36946. });
  36947. clearColor.__canvasGradient = clearColorGradientOrPattern;
  36948. } else if (isPatternObject(clearColor)) {
  36949. clearColorGradientOrPattern = createCanvasPattern(ctx, clearColor, {
  36950. dirty: function () {
  36951. self.setUnpainted();
  36952. self.__painter.refresh();
  36953. }
  36954. });
  36955. }
  36956. ctx.save();
  36957. ctx.fillStyle = clearColorGradientOrPattern || clearColor;
  36958. ctx.fillRect(x, y, width, height);
  36959. ctx.restore();
  36960. }
  36961. if (haveMotionBLur) {
  36962. ctx.save();
  36963. ctx.globalAlpha = lastFrameAlpha;
  36964. ctx.drawImage(domBack, x, y, width, height);
  36965. ctx.restore();
  36966. }
  36967. }
  36968. if (!repaintRects || haveMotionBLur) {
  36969. doClear(0, 0, width, height);
  36970. } else if (repaintRects.length) {
  36971. each$1(repaintRects, function (rect) {
  36972. doClear(rect.x * dpr, rect.y * dpr, rect.width * dpr, rect.height * dpr);
  36973. });
  36974. }
  36975. };
  36976. return Layer;
  36977. }(Eventful);
  36978. var HOVER_LAYER_ZLEVEL = 1e5;
  36979. var CANVAS_ZLEVEL = 314159;
  36980. var EL_AFTER_INCREMENTAL_INC = 0.01;
  36981. var INCREMENTAL_INC = 0.001;
  36982. function parseInt10(val) {
  36983. return parseInt(val, 10);
  36984. }
  36985. function isLayerValid(layer) {
  36986. if (!layer) {
  36987. return false;
  36988. }
  36989. if (layer.__builtin__) {
  36990. return true;
  36991. }
  36992. if (typeof layer.resize !== 'function' || typeof layer.refresh !== 'function') {
  36993. return false;
  36994. }
  36995. return true;
  36996. }
  36997. function createRoot(width, height) {
  36998. var domRoot = document.createElement('div');
  36999. domRoot.style.cssText = ['position:relative', 'width:' + width + 'px', 'height:' + height + 'px', 'padding:0', 'margin:0', 'border-width:0'].join(';') + ';';
  37000. return domRoot;
  37001. }
  37002. var CanvasPainter = function () {
  37003. function CanvasPainter(root, storage, opts, id) {
  37004. this.type = 'canvas';
  37005. this._zlevelList = [];
  37006. this._prevDisplayList = [];
  37007. this._layers = {};
  37008. this._layerConfig = {};
  37009. this._needsManuallyCompositing = false;
  37010. this.type = 'canvas';
  37011. var singleCanvas = !root.nodeName || root.nodeName.toUpperCase() === 'CANVAS';
  37012. this._opts = opts = extend({}, opts || {});
  37013. this.dpr = opts.devicePixelRatio || devicePixelRatio;
  37014. this._singleCanvas = singleCanvas;
  37015. this.root = root;
  37016. var rootStyle = root.style;
  37017. if (rootStyle) {
  37018. rootStyle.webkitTapHighlightColor = 'transparent';
  37019. rootStyle.webkitUserSelect = 'none';
  37020. rootStyle.userSelect = 'none';
  37021. rootStyle['-webkit-touch-callout'] = 'none';
  37022. root.innerHTML = '';
  37023. }
  37024. this.storage = storage;
  37025. var zlevelList = this._zlevelList;
  37026. this._prevDisplayList = [];
  37027. var layers = this._layers;
  37028. if (!singleCanvas) {
  37029. this._width = this._getSize(0);
  37030. this._height = this._getSize(1);
  37031. var domRoot = this._domRoot = createRoot(this._width, this._height);
  37032. root.appendChild(domRoot);
  37033. } else {
  37034. var rootCanvas = root;
  37035. var width = rootCanvas.width;
  37036. var height = rootCanvas.height;
  37037. if (opts.width != null) {
  37038. width = opts.width;
  37039. }
  37040. if (opts.height != null) {
  37041. height = opts.height;
  37042. }
  37043. this.dpr = opts.devicePixelRatio || 1;
  37044. rootCanvas.width = width * this.dpr;
  37045. rootCanvas.height = height * this.dpr;
  37046. this._width = width;
  37047. this._height = height;
  37048. var mainLayer = new Layer(rootCanvas, this, this.dpr);
  37049. mainLayer.__builtin__ = true;
  37050. mainLayer.initContext();
  37051. layers[CANVAS_ZLEVEL] = mainLayer;
  37052. mainLayer.zlevel = CANVAS_ZLEVEL;
  37053. zlevelList.push(CANVAS_ZLEVEL);
  37054. this._domRoot = root;
  37055. }
  37056. }
  37057. CanvasPainter.prototype.getType = function () {
  37058. return 'canvas';
  37059. };
  37060. CanvasPainter.prototype.isSingleCanvas = function () {
  37061. return this._singleCanvas;
  37062. };
  37063. CanvasPainter.prototype.getViewportRoot = function () {
  37064. return this._domRoot;
  37065. };
  37066. CanvasPainter.prototype.getViewportRootOffset = function () {
  37067. var viewportRoot = this.getViewportRoot();
  37068. if (viewportRoot) {
  37069. return {
  37070. offsetLeft: viewportRoot.offsetLeft || 0,
  37071. offsetTop: viewportRoot.offsetTop || 0
  37072. };
  37073. }
  37074. };
  37075. CanvasPainter.prototype.refresh = function (paintAll) {
  37076. var list = this.storage.getDisplayList(true);
  37077. var prevList = this._prevDisplayList;
  37078. var zlevelList = this._zlevelList;
  37079. this._redrawId = Math.random();
  37080. this._paintList(list, prevList, paintAll, this._redrawId);
  37081. for (var i = 0; i < zlevelList.length; i++) {
  37082. var z = zlevelList[i];
  37083. var layer = this._layers[z];
  37084. if (!layer.__builtin__ && layer.refresh) {
  37085. var clearColor = i === 0 ? this._backgroundColor : null;
  37086. layer.refresh(clearColor);
  37087. }
  37088. }
  37089. if (this._opts.useDirtyRect) {
  37090. this._prevDisplayList = list.slice();
  37091. }
  37092. return this;
  37093. };
  37094. CanvasPainter.prototype.refreshHover = function () {
  37095. this._paintHoverList(this.storage.getDisplayList(false));
  37096. };
  37097. CanvasPainter.prototype._paintHoverList = function (list) {
  37098. var len = list.length;
  37099. var hoverLayer = this._hoverlayer;
  37100. hoverLayer && hoverLayer.clear();
  37101. if (!len) {
  37102. return;
  37103. }
  37104. var scope = {
  37105. inHover: true,
  37106. viewWidth: this._width,
  37107. viewHeight: this._height
  37108. };
  37109. var ctx;
  37110. for (var i = 0; i < len; i++) {
  37111. var el = list[i];
  37112. if (el.__inHover) {
  37113. if (!hoverLayer) {
  37114. hoverLayer = this._hoverlayer = this.getLayer(HOVER_LAYER_ZLEVEL);
  37115. }
  37116. if (!ctx) {
  37117. ctx = hoverLayer.ctx;
  37118. ctx.save();
  37119. }
  37120. brush(ctx, el, scope, i === len - 1);
  37121. }
  37122. }
  37123. if (ctx) {
  37124. ctx.restore();
  37125. }
  37126. };
  37127. CanvasPainter.prototype.getHoverLayer = function () {
  37128. return this.getLayer(HOVER_LAYER_ZLEVEL);
  37129. };
  37130. CanvasPainter.prototype.paintOne = function (ctx, el) {
  37131. brushSingle(ctx, el);
  37132. };
  37133. CanvasPainter.prototype._paintList = function (list, prevList, paintAll, redrawId) {
  37134. if (this._redrawId !== redrawId) {
  37135. return;
  37136. }
  37137. paintAll = paintAll || false;
  37138. this._updateLayerStatus(list);
  37139. var _a = this._doPaintList(list, prevList, paintAll),
  37140. finished = _a.finished,
  37141. needsRefreshHover = _a.needsRefreshHover;
  37142. if (this._needsManuallyCompositing) {
  37143. this._compositeManually();
  37144. }
  37145. if (needsRefreshHover) {
  37146. this._paintHoverList(list);
  37147. }
  37148. if (!finished) {
  37149. var self_1 = this;
  37150. requestAnimationFrame$1(function () {
  37151. self_1._paintList(list, prevList, paintAll, redrawId);
  37152. });
  37153. } else {
  37154. this.eachLayer(function (layer) {
  37155. layer.afterBrush && layer.afterBrush();
  37156. });
  37157. }
  37158. };
  37159. CanvasPainter.prototype._compositeManually = function () {
  37160. var ctx = this.getLayer(CANVAS_ZLEVEL).ctx;
  37161. var width = this._domRoot.width;
  37162. var height = this._domRoot.height;
  37163. ctx.clearRect(0, 0, width, height);
  37164. this.eachBuiltinLayer(function (layer) {
  37165. if (layer.virtual) {
  37166. ctx.drawImage(layer.dom, 0, 0, width, height);
  37167. }
  37168. });
  37169. };
  37170. CanvasPainter.prototype._doPaintList = function (list, prevList, paintAll) {
  37171. var _this = this;
  37172. var layerList = [];
  37173. var useDirtyRect = this._opts.useDirtyRect;
  37174. for (var zi = 0; zi < this._zlevelList.length; zi++) {
  37175. var zlevel = this._zlevelList[zi];
  37176. var layer = this._layers[zlevel];
  37177. if (layer.__builtin__ && layer !== this._hoverlayer && (layer.__dirty || paintAll)) {
  37178. layerList.push(layer);
  37179. }
  37180. }
  37181. var finished = true;
  37182. var needsRefreshHover = false;
  37183. var _loop_1 = function (k) {
  37184. var layer = layerList[k];
  37185. var ctx = layer.ctx;
  37186. var repaintRects = useDirtyRect && layer.createRepaintRects(list, prevList, this_1._width, this_1._height);
  37187. ctx.save();
  37188. var start = paintAll ? layer.__startIndex : layer.__drawIndex;
  37189. var useTimer = !paintAll && layer.incremental && Date.now;
  37190. var startTime = useTimer && Date.now();
  37191. var clearColor = layer.zlevel === this_1._zlevelList[0] ? this_1._backgroundColor : null;
  37192. if (layer.__startIndex === layer.__endIndex) {
  37193. layer.clear(false, clearColor, repaintRects);
  37194. } else if (start === layer.__startIndex) {
  37195. var firstEl = list[start];
  37196. if (!firstEl.incremental || !firstEl.notClear || paintAll) {
  37197. layer.clear(false, clearColor, repaintRects);
  37198. }
  37199. }
  37200. if (start === -1) {
  37201. console.error('For some unknown reason. drawIndex is -1');
  37202. start = layer.__startIndex;
  37203. }
  37204. var i;
  37205. var repaint = function (repaintRect) {
  37206. var scope = {
  37207. inHover: false,
  37208. allClipped: false,
  37209. prevEl: null,
  37210. viewWidth: _this._width,
  37211. viewHeight: _this._height
  37212. };
  37213. for (i = start; i < layer.__endIndex; i++) {
  37214. var el = list[i];
  37215. if (el.__inHover) {
  37216. needsRefreshHover = true;
  37217. }
  37218. _this._doPaintEl(el, layer, useDirtyRect, repaintRect, scope, i === layer.__endIndex - 1);
  37219. if (useTimer) {
  37220. var dTime = Date.now() - startTime;
  37221. if (dTime > 15) {
  37222. break;
  37223. }
  37224. }
  37225. }
  37226. if (scope.prevElClipPaths) {
  37227. ctx.restore();
  37228. }
  37229. };
  37230. if (repaintRects) {
  37231. if (repaintRects.length === 0) {
  37232. i = layer.__endIndex;
  37233. } else {
  37234. var dpr = this_1.dpr;
  37235. for (var r = 0; r < repaintRects.length; ++r) {
  37236. var rect = repaintRects[r];
  37237. ctx.save();
  37238. ctx.beginPath();
  37239. ctx.rect(rect.x * dpr, rect.y * dpr, rect.width * dpr, rect.height * dpr);
  37240. ctx.clip();
  37241. repaint(rect);
  37242. ctx.restore();
  37243. }
  37244. }
  37245. } else {
  37246. ctx.save();
  37247. repaint();
  37248. ctx.restore();
  37249. }
  37250. layer.__drawIndex = i;
  37251. if (layer.__drawIndex < layer.__endIndex) {
  37252. finished = false;
  37253. }
  37254. };
  37255. var this_1 = this;
  37256. for (var k = 0; k < layerList.length; k++) {
  37257. _loop_1(k);
  37258. }
  37259. if (env.wxa) {
  37260. each$1(this._layers, function (layer) {
  37261. if (layer && layer.ctx && layer.ctx.draw) {
  37262. layer.ctx.draw();
  37263. }
  37264. });
  37265. }
  37266. return {
  37267. finished: finished,
  37268. needsRefreshHover: needsRefreshHover
  37269. };
  37270. };
  37271. CanvasPainter.prototype._doPaintEl = function (el, currentLayer, useDirtyRect, repaintRect, scope, isLast) {
  37272. var ctx = currentLayer.ctx;
  37273. if (useDirtyRect) {
  37274. var paintRect = el.getPaintRect();
  37275. if (!repaintRect || paintRect && paintRect.intersect(repaintRect)) {
  37276. brush(ctx, el, scope, isLast);
  37277. el.setPrevPaintRect(paintRect);
  37278. }
  37279. } else {
  37280. brush(ctx, el, scope, isLast);
  37281. }
  37282. };
  37283. CanvasPainter.prototype.getLayer = function (zlevel, virtual) {
  37284. if (this._singleCanvas && !this._needsManuallyCompositing) {
  37285. zlevel = CANVAS_ZLEVEL;
  37286. }
  37287. var layer = this._layers[zlevel];
  37288. if (!layer) {
  37289. layer = new Layer('zr_' + zlevel, this, this.dpr);
  37290. layer.zlevel = zlevel;
  37291. layer.__builtin__ = true;
  37292. if (this._layerConfig[zlevel]) {
  37293. merge(layer, this._layerConfig[zlevel], true);
  37294. } else if (this._layerConfig[zlevel - EL_AFTER_INCREMENTAL_INC]) {
  37295. merge(layer, this._layerConfig[zlevel - EL_AFTER_INCREMENTAL_INC], true);
  37296. }
  37297. if (virtual) {
  37298. layer.virtual = virtual;
  37299. }
  37300. this.insertLayer(zlevel, layer);
  37301. layer.initContext();
  37302. }
  37303. return layer;
  37304. };
  37305. CanvasPainter.prototype.insertLayer = function (zlevel, layer) {
  37306. var layersMap = this._layers;
  37307. var zlevelList = this._zlevelList;
  37308. var len = zlevelList.length;
  37309. var domRoot = this._domRoot;
  37310. var prevLayer = null;
  37311. var i = -1;
  37312. if (layersMap[zlevel]) {
  37313. logError('ZLevel ' + zlevel + ' has been used already');
  37314. return;
  37315. }
  37316. if (!isLayerValid(layer)) {
  37317. logError('Layer of zlevel ' + zlevel + ' is not valid');
  37318. return;
  37319. }
  37320. if (len > 0 && zlevel > zlevelList[0]) {
  37321. for (i = 0; i < len - 1; i++) {
  37322. if (zlevelList[i] < zlevel && zlevelList[i + 1] > zlevel) {
  37323. break;
  37324. }
  37325. }
  37326. prevLayer = layersMap[zlevelList[i]];
  37327. }
  37328. zlevelList.splice(i + 1, 0, zlevel);
  37329. layersMap[zlevel] = layer;
  37330. if (!layer.virtual) {
  37331. if (prevLayer) {
  37332. var prevDom = prevLayer.dom;
  37333. if (prevDom.nextSibling) {
  37334. domRoot.insertBefore(layer.dom, prevDom.nextSibling);
  37335. } else {
  37336. domRoot.appendChild(layer.dom);
  37337. }
  37338. } else {
  37339. if (domRoot.firstChild) {
  37340. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  37341. } else {
  37342. domRoot.appendChild(layer.dom);
  37343. }
  37344. }
  37345. }
  37346. layer.__painter = this;
  37347. };
  37348. CanvasPainter.prototype.eachLayer = function (cb, context) {
  37349. var zlevelList = this._zlevelList;
  37350. for (var i = 0; i < zlevelList.length; i++) {
  37351. var z = zlevelList[i];
  37352. cb.call(context, this._layers[z], z);
  37353. }
  37354. };
  37355. CanvasPainter.prototype.eachBuiltinLayer = function (cb, context) {
  37356. var zlevelList = this._zlevelList;
  37357. for (var i = 0; i < zlevelList.length; i++) {
  37358. var z = zlevelList[i];
  37359. var layer = this._layers[z];
  37360. if (layer.__builtin__) {
  37361. cb.call(context, layer, z);
  37362. }
  37363. }
  37364. };
  37365. CanvasPainter.prototype.eachOtherLayer = function (cb, context) {
  37366. var zlevelList = this._zlevelList;
  37367. for (var i = 0; i < zlevelList.length; i++) {
  37368. var z = zlevelList[i];
  37369. var layer = this._layers[z];
  37370. if (!layer.__builtin__) {
  37371. cb.call(context, layer, z);
  37372. }
  37373. }
  37374. };
  37375. CanvasPainter.prototype.getLayers = function () {
  37376. return this._layers;
  37377. };
  37378. CanvasPainter.prototype._updateLayerStatus = function (list) {
  37379. this.eachBuiltinLayer(function (layer, z) {
  37380. layer.__dirty = layer.__used = false;
  37381. });
  37382. function updatePrevLayer(idx) {
  37383. if (prevLayer) {
  37384. if (prevLayer.__endIndex !== idx) {
  37385. prevLayer.__dirty = true;
  37386. }
  37387. prevLayer.__endIndex = idx;
  37388. }
  37389. }
  37390. if (this._singleCanvas) {
  37391. for (var i_1 = 1; i_1 < list.length; i_1++) {
  37392. var el = list[i_1];
  37393. if (el.zlevel !== list[i_1 - 1].zlevel || el.incremental) {
  37394. this._needsManuallyCompositing = true;
  37395. break;
  37396. }
  37397. }
  37398. }
  37399. var prevLayer = null;
  37400. var incrementalLayerCount = 0;
  37401. var prevZlevel;
  37402. var i;
  37403. for (i = 0; i < list.length; i++) {
  37404. var el = list[i];
  37405. var zlevel = el.zlevel;
  37406. var layer = void 0;
  37407. if (prevZlevel !== zlevel) {
  37408. prevZlevel = zlevel;
  37409. incrementalLayerCount = 0;
  37410. }
  37411. if (el.incremental) {
  37412. layer = this.getLayer(zlevel + INCREMENTAL_INC, this._needsManuallyCompositing);
  37413. layer.incremental = true;
  37414. incrementalLayerCount = 1;
  37415. } else {
  37416. layer = this.getLayer(zlevel + (incrementalLayerCount > 0 ? EL_AFTER_INCREMENTAL_INC : 0), this._needsManuallyCompositing);
  37417. }
  37418. if (!layer.__builtin__) {
  37419. logError('ZLevel ' + zlevel + ' has been used by unkown layer ' + layer.id);
  37420. }
  37421. if (layer !== prevLayer) {
  37422. layer.__used = true;
  37423. if (layer.__startIndex !== i) {
  37424. layer.__dirty = true;
  37425. }
  37426. layer.__startIndex = i;
  37427. if (!layer.incremental) {
  37428. layer.__drawIndex = i;
  37429. } else {
  37430. layer.__drawIndex = -1;
  37431. }
  37432. updatePrevLayer(i);
  37433. prevLayer = layer;
  37434. }
  37435. if (el.__dirty & Element.REDARAW_BIT && !el.__inHover) {
  37436. layer.__dirty = true;
  37437. if (layer.incremental && layer.__drawIndex < 0) {
  37438. layer.__drawIndex = i;
  37439. }
  37440. }
  37441. }
  37442. updatePrevLayer(i);
  37443. this.eachBuiltinLayer(function (layer, z) {
  37444. if (!layer.__used && layer.getElementCount() > 0) {
  37445. layer.__dirty = true;
  37446. layer.__startIndex = layer.__endIndex = layer.__drawIndex = 0;
  37447. }
  37448. if (layer.__dirty && layer.__drawIndex < 0) {
  37449. layer.__drawIndex = layer.__startIndex;
  37450. }
  37451. });
  37452. };
  37453. CanvasPainter.prototype.clear = function () {
  37454. this.eachBuiltinLayer(this._clearLayer);
  37455. return this;
  37456. };
  37457. CanvasPainter.prototype._clearLayer = function (layer) {
  37458. layer.clear();
  37459. };
  37460. CanvasPainter.prototype.setBackgroundColor = function (backgroundColor) {
  37461. this._backgroundColor = backgroundColor;
  37462. each$1(this._layers, function (layer) {
  37463. layer.setUnpainted();
  37464. });
  37465. };
  37466. CanvasPainter.prototype.configLayer = function (zlevel, config) {
  37467. if (config) {
  37468. var layerConfig = this._layerConfig;
  37469. if (!layerConfig[zlevel]) {
  37470. layerConfig[zlevel] = config;
  37471. } else {
  37472. merge(layerConfig[zlevel], config, true);
  37473. }
  37474. for (var i = 0; i < this._zlevelList.length; i++) {
  37475. var _zlevel = this._zlevelList[i];
  37476. if (_zlevel === zlevel || _zlevel === zlevel + EL_AFTER_INCREMENTAL_INC) {
  37477. var layer = this._layers[_zlevel];
  37478. merge(layer, layerConfig[zlevel], true);
  37479. }
  37480. }
  37481. }
  37482. };
  37483. CanvasPainter.prototype.delLayer = function (zlevel) {
  37484. var layers = this._layers;
  37485. var zlevelList = this._zlevelList;
  37486. var layer = layers[zlevel];
  37487. if (!layer) {
  37488. return;
  37489. }
  37490. layer.dom.parentNode.removeChild(layer.dom);
  37491. delete layers[zlevel];
  37492. zlevelList.splice(indexOf$1(zlevelList, zlevel), 1);
  37493. };
  37494. CanvasPainter.prototype.resize = function (width, height) {
  37495. if (!this._domRoot.style) {
  37496. if (width == null || height == null) {
  37497. return;
  37498. }
  37499. this._width = width;
  37500. this._height = height;
  37501. this.getLayer(CANVAS_ZLEVEL).resize(width, height);
  37502. } else {
  37503. var domRoot = this._domRoot;
  37504. domRoot.style.display = 'none';
  37505. var opts = this._opts;
  37506. width != null && (opts.width = width);
  37507. height != null && (opts.height = height);
  37508. width = this._getSize(0);
  37509. height = this._getSize(1);
  37510. domRoot.style.display = '';
  37511. if (this._width !== width || height !== this._height) {
  37512. domRoot.style.width = width + 'px';
  37513. domRoot.style.height = height + 'px';
  37514. for (var id in this._layers) {
  37515. if (this._layers.hasOwnProperty(id)) {
  37516. this._layers[id].resize(width, height);
  37517. }
  37518. }
  37519. this.refresh(true);
  37520. }
  37521. this._width = width;
  37522. this._height = height;
  37523. }
  37524. return this;
  37525. };
  37526. CanvasPainter.prototype.clearLayer = function (zlevel) {
  37527. var layer = this._layers[zlevel];
  37528. if (layer) {
  37529. layer.clear();
  37530. }
  37531. };
  37532. CanvasPainter.prototype.dispose = function () {
  37533. this.root.innerHTML = '';
  37534. this.root = this.storage = this._domRoot = this._layers = null;
  37535. };
  37536. CanvasPainter.prototype.getRenderedCanvas = function (opts) {
  37537. opts = opts || {};
  37538. if (this._singleCanvas && !this._compositeManually) {
  37539. return this._layers[CANVAS_ZLEVEL].dom;
  37540. }
  37541. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  37542. imageLayer.initContext();
  37543. imageLayer.clear(false, opts.backgroundColor || this._backgroundColor);
  37544. var ctx = imageLayer.ctx;
  37545. if (opts.pixelRatio <= this.dpr) {
  37546. this.refresh();
  37547. var width_1 = imageLayer.dom.width;
  37548. var height_1 = imageLayer.dom.height;
  37549. this.eachLayer(function (layer) {
  37550. if (layer.__builtin__) {
  37551. ctx.drawImage(layer.dom, 0, 0, width_1, height_1);
  37552. } else if (layer.renderToCanvas) {
  37553. ctx.save();
  37554. layer.renderToCanvas(ctx);
  37555. ctx.restore();
  37556. }
  37557. });
  37558. } else {
  37559. var scope = {
  37560. inHover: false,
  37561. viewWidth: this._width,
  37562. viewHeight: this._height
  37563. };
  37564. var displayList = this.storage.getDisplayList(true);
  37565. for (var i = 0, len = displayList.length; i < len; i++) {
  37566. var el = displayList[i];
  37567. brush(ctx, el, scope, i === len - 1);
  37568. }
  37569. }
  37570. return imageLayer.dom;
  37571. };
  37572. CanvasPainter.prototype.getWidth = function () {
  37573. return this._width;
  37574. };
  37575. CanvasPainter.prototype.getHeight = function () {
  37576. return this._height;
  37577. };
  37578. CanvasPainter.prototype._getSize = function (whIdx) {
  37579. var opts = this._opts;
  37580. var wh = ['width', 'height'][whIdx];
  37581. var cwh = ['clientWidth', 'clientHeight'][whIdx];
  37582. var plt = ['paddingLeft', 'paddingTop'][whIdx];
  37583. var prb = ['paddingRight', 'paddingBottom'][whIdx];
  37584. if (opts[wh] != null && opts[wh] !== 'auto') {
  37585. return parseFloat(opts[wh]);
  37586. }
  37587. var root = this.root;
  37588. var stl = document.defaultView.getComputedStyle(root);
  37589. return (root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh])) - (parseInt10(stl[plt]) || 0) - (parseInt10(stl[prb]) || 0) | 0;
  37590. };
  37591. CanvasPainter.prototype.pathToImage = function (path, dpr) {
  37592. dpr = dpr || this.dpr;
  37593. var canvas = document.createElement('canvas');
  37594. var ctx = canvas.getContext('2d');
  37595. var rect = path.getBoundingRect();
  37596. var style = path.style;
  37597. var shadowBlurSize = style.shadowBlur * dpr;
  37598. var shadowOffsetX = style.shadowOffsetX * dpr;
  37599. var shadowOffsetY = style.shadowOffsetY * dpr;
  37600. var lineWidth = path.hasStroke() ? style.lineWidth : 0;
  37601. var leftMargin = Math.max(lineWidth / 2, -shadowOffsetX + shadowBlurSize);
  37602. var rightMargin = Math.max(lineWidth / 2, shadowOffsetX + shadowBlurSize);
  37603. var topMargin = Math.max(lineWidth / 2, -shadowOffsetY + shadowBlurSize);
  37604. var bottomMargin = Math.max(lineWidth / 2, shadowOffsetY + shadowBlurSize);
  37605. var width = rect.width + leftMargin + rightMargin;
  37606. var height = rect.height + topMargin + bottomMargin;
  37607. canvas.width = width * dpr;
  37608. canvas.height = height * dpr;
  37609. ctx.scale(dpr, dpr);
  37610. ctx.clearRect(0, 0, width, height);
  37611. ctx.dpr = dpr;
  37612. var pathTransform = {
  37613. x: path.x,
  37614. y: path.y,
  37615. scaleX: path.scaleX,
  37616. scaleY: path.scaleY,
  37617. rotation: path.rotation,
  37618. originX: path.originX,
  37619. originY: path.originY
  37620. };
  37621. path.x = leftMargin - rect.x;
  37622. path.y = topMargin - rect.y;
  37623. path.rotation = 0;
  37624. path.scaleX = 1;
  37625. path.scaleY = 1;
  37626. path.updateTransform();
  37627. if (path) {
  37628. brush(ctx, path, {
  37629. inHover: false,
  37630. viewWidth: this._width,
  37631. viewHeight: this._height
  37632. }, true);
  37633. }
  37634. var imgShape = new ZRImage({
  37635. style: {
  37636. x: 0,
  37637. y: 0,
  37638. image: canvas
  37639. }
  37640. });
  37641. extend(path, pathTransform);
  37642. return imgShape;
  37643. };
  37644. return CanvasPainter;
  37645. }();
  37646. /*
  37647. * Licensed to the Apache Software Foundation (ASF) under one
  37648. * or more contributor license agreements. See the NOTICE file
  37649. * distributed with this work for additional information
  37650. * regarding copyright ownership. The ASF licenses this file
  37651. * to you under the Apache License, Version 2.0 (the
  37652. * "License"); you may not use this file except in compliance
  37653. * with the License. You may obtain a copy of the License at
  37654. *
  37655. * http://www.apache.org/licenses/LICENSE-2.0
  37656. *
  37657. * Unless required by applicable law or agreed to in writing,
  37658. * software distributed under the License is distributed on an
  37659. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37660. * KIND, either express or implied. See the License for the
  37661. * specific language governing permissions and limitations
  37662. * under the License.
  37663. */
  37664. /**
  37665. * AUTO-GENERATED FILE. DO NOT MODIFY.
  37666. */
  37667. /*
  37668. * Licensed to the Apache Software Foundation (ASF) under one
  37669. * or more contributor license agreements. See the NOTICE file
  37670. * distributed with this work for additional information
  37671. * regarding copyright ownership. The ASF licenses this file
  37672. * to you under the Apache License, Version 2.0 (the
  37673. * "License"); you may not use this file except in compliance
  37674. * with the License. You may obtain a copy of the License at
  37675. *
  37676. * http://www.apache.org/licenses/LICENSE-2.0
  37677. *
  37678. * Unless required by applicable law or agreed to in writing,
  37679. * software distributed under the License is distributed on an
  37680. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37681. * KIND, either express or implied. See the License for the
  37682. * specific language governing permissions and limitations
  37683. * under the License.
  37684. */
  37685. function install(registers) {
  37686. registers.registerPainter('canvas', CanvasPainter);
  37687. }
  37688. /*
  37689. * Licensed to the Apache Software Foundation (ASF) under one
  37690. * or more contributor license agreements. See the NOTICE file
  37691. * distributed with this work for additional information
  37692. * regarding copyright ownership. The ASF licenses this file
  37693. * to you under the Apache License, Version 2.0 (the
  37694. * "License"); you may not use this file except in compliance
  37695. * with the License. You may obtain a copy of the License at
  37696. *
  37697. * http://www.apache.org/licenses/LICENSE-2.0
  37698. *
  37699. * Unless required by applicable law or agreed to in writing,
  37700. * software distributed under the License is distributed on an
  37701. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37702. * KIND, either express or implied. See the License for the
  37703. * specific language governing permissions and limitations
  37704. * under the License.
  37705. */
  37706. /**
  37707. * AUTO-GENERATED FILE. DO NOT MODIFY.
  37708. */
  37709. /*
  37710. * Licensed to the Apache Software Foundation (ASF) under one
  37711. * or more contributor license agreements. See the NOTICE file
  37712. * distributed with this work for additional information
  37713. * regarding copyright ownership. The ASF licenses this file
  37714. * to you under the Apache License, Version 2.0 (the
  37715. * "License"); you may not use this file except in compliance
  37716. * with the License. You may obtain a copy of the License at
  37717. *
  37718. * http://www.apache.org/licenses/LICENSE-2.0
  37719. *
  37720. * Unless required by applicable law or agreed to in writing,
  37721. * software distributed under the License is distributed on an
  37722. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37723. * KIND, either express or implied. See the License for the
  37724. * specific language governing permissions and limitations
  37725. * under the License.
  37726. */
  37727. /**
  37728. * This module is imported by echarts directly.
  37729. *
  37730. * Notice:
  37731. * Always keep this file exists for backward compatibility.
  37732. * Because before 4.1.0, dataset is an optional component,
  37733. * some users may import this module manually.
  37734. */
  37735. var DatasetModel =
  37736. /** @class */
  37737. function (_super) {
  37738. __extends(DatasetModel, _super);
  37739. function DatasetModel() {
  37740. var _this = _super !== null && _super.apply(this, arguments) || this;
  37741. _this.type = 'dataset';
  37742. return _this;
  37743. }
  37744. DatasetModel.prototype.init = function (option, parentModel, ecModel) {
  37745. _super.prototype.init.call(this, option, parentModel, ecModel);
  37746. this._sourceManager = new SourceManager(this);
  37747. disableTransformOptionMerge(this);
  37748. };
  37749. DatasetModel.prototype.mergeOption = function (newOption, ecModel) {
  37750. _super.prototype.mergeOption.call(this, newOption, ecModel);
  37751. disableTransformOptionMerge(this);
  37752. };
  37753. DatasetModel.prototype.optionUpdated = function () {
  37754. this._sourceManager.dirty();
  37755. };
  37756. DatasetModel.prototype.getSourceManager = function () {
  37757. return this._sourceManager;
  37758. };
  37759. DatasetModel.type = 'dataset';
  37760. DatasetModel.defaultOption = {
  37761. seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN
  37762. };
  37763. return DatasetModel;
  37764. }(ComponentModel);
  37765. var DatasetView =
  37766. /** @class */
  37767. function (_super) {
  37768. __extends(DatasetView, _super);
  37769. function DatasetView() {
  37770. var _this = _super !== null && _super.apply(this, arguments) || this;
  37771. _this.type = 'dataset';
  37772. return _this;
  37773. }
  37774. DatasetView.type = 'dataset';
  37775. return DatasetView;
  37776. }(ComponentView);
  37777. function install$1(registers) {
  37778. registers.registerComponentModel(DatasetModel);
  37779. registers.registerComponentView(DatasetView);
  37780. }
  37781. use([install, install$1]); // Compatitable with the following code
  37782. // import echarts from 'echarts/lib/echarts'
  37783. /*
  37784. * Licensed to the Apache Software Foundation (ASF) under one
  37785. * or more contributor license agreements. See the NOTICE file
  37786. * distributed with this work for additional information
  37787. * regarding copyright ownership. The ASF licenses this file
  37788. * to you under the Apache License, Version 2.0 (the
  37789. * "License"); you may not use this file except in compliance
  37790. * with the License. You may obtain a copy of the License at
  37791. *
  37792. * http://www.apache.org/licenses/LICENSE-2.0
  37793. *
  37794. * Unless required by applicable law or agreed to in writing,
  37795. * software distributed under the License is distributed on an
  37796. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37797. * KIND, either express or implied. See the License for the
  37798. * specific language governing permissions and limitations
  37799. * under the License.
  37800. */
  37801. /**
  37802. * AUTO-GENERATED FILE. DO NOT MODIFY.
  37803. */
  37804. /*
  37805. * Licensed to the Apache Software Foundation (ASF) under one
  37806. * or more contributor license agreements. See the NOTICE file
  37807. * distributed with this work for additional information
  37808. * regarding copyright ownership. The ASF licenses this file
  37809. * to you under the Apache License, Version 2.0 (the
  37810. * "License"); you may not use this file except in compliance
  37811. * with the License. You may obtain a copy of the License at
  37812. *
  37813. * http://www.apache.org/licenses/LICENSE-2.0
  37814. *
  37815. * Unless required by applicable law or agreed to in writing,
  37816. * software distributed under the License is distributed on an
  37817. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37818. * KIND, either express or implied. See the License for the
  37819. * specific language governing permissions and limitations
  37820. * under the License.
  37821. */
  37822. var samplers = {
  37823. average: function (frame) {
  37824. var sum = 0;
  37825. var count = 0;
  37826. for (var i = 0; i < frame.length; i++) {
  37827. if (!isNaN(frame[i])) {
  37828. sum += frame[i];
  37829. count++;
  37830. }
  37831. } // Return NaN if count is 0
  37832. return count === 0 ? NaN : sum / count;
  37833. },
  37834. sum: function (frame) {
  37835. var sum = 0;
  37836. for (var i = 0; i < frame.length; i++) {
  37837. // Ignore NaN
  37838. sum += frame[i] || 0;
  37839. }
  37840. return sum;
  37841. },
  37842. max: function (frame) {
  37843. var max = -Infinity;
  37844. for (var i = 0; i < frame.length; i++) {
  37845. frame[i] > max && (max = frame[i]);
  37846. } // NaN will cause illegal axis extent.
  37847. return isFinite(max) ? max : NaN;
  37848. },
  37849. min: function (frame) {
  37850. var min = Infinity;
  37851. for (var i = 0; i < frame.length; i++) {
  37852. frame[i] < min && (min = frame[i]);
  37853. } // NaN will cause illegal axis extent.
  37854. return isFinite(min) ? min : NaN;
  37855. },
  37856. // TODO
  37857. // Median
  37858. nearest: function (frame) {
  37859. return frame[0];
  37860. }
  37861. };
  37862. var indexSampler = function (frame) {
  37863. return Math.round(frame.length / 2);
  37864. };
  37865. function dataSample(seriesType) {
  37866. return {
  37867. seriesType: seriesType,
  37868. // FIXME:TS never used, so comment it
  37869. // modifyOutputEnd: true,
  37870. reset: function (seriesModel, ecModel, api) {
  37871. var data = seriesModel.getData();
  37872. var sampling = seriesModel.get('sampling');
  37873. var coordSys = seriesModel.coordinateSystem;
  37874. var count = data.count(); // Only cartesian2d support down sampling. Disable it when there is few data.
  37875. if (count > 10 && coordSys.type === 'cartesian2d' && sampling) {
  37876. var baseAxis = coordSys.getBaseAxis();
  37877. var valueAxis = coordSys.getOtherAxis(baseAxis);
  37878. var extent = baseAxis.getExtent();
  37879. var dpr = api.getDevicePixelRatio(); // Coordinste system has been resized
  37880. var size = Math.abs(extent[1] - extent[0]) * (dpr || 1);
  37881. var rate = Math.round(count / size);
  37882. if (rate > 1) {
  37883. if (sampling === 'lttb') {
  37884. seriesModel.setData(data.lttbDownSample(data.mapDimension(valueAxis.dim), 1 / rate));
  37885. }
  37886. var sampler = void 0;
  37887. if (typeof sampling === 'string') {
  37888. sampler = samplers[sampling];
  37889. } else if (typeof sampling === 'function') {
  37890. sampler = sampling;
  37891. }
  37892. if (sampler) {
  37893. // Only support sample the first dim mapped from value axis.
  37894. seriesModel.setData(data.downSample(data.mapDimension(valueAxis.dim), 1 / rate, sampler, indexSampler));
  37895. }
  37896. }
  37897. }
  37898. }
  37899. };
  37900. }
  37901. /*
  37902. * Licensed to the Apache Software Foundation (ASF) under one
  37903. * or more contributor license agreements. See the NOTICE file
  37904. * distributed with this work for additional information
  37905. * regarding copyright ownership. The ASF licenses this file
  37906. * to you under the Apache License, Version 2.0 (the
  37907. * "License"); you may not use this file except in compliance
  37908. * with the License. You may obtain a copy of the License at
  37909. *
  37910. * http://www.apache.org/licenses/LICENSE-2.0
  37911. *
  37912. * Unless required by applicable law or agreed to in writing,
  37913. * software distributed under the License is distributed on an
  37914. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37915. * KIND, either express or implied. See the License for the
  37916. * specific language governing permissions and limitations
  37917. * under the License.
  37918. */
  37919. /**
  37920. * AUTO-GENERATED FILE. DO NOT MODIFY.
  37921. */
  37922. /*
  37923. * Licensed to the Apache Software Foundation (ASF) under one
  37924. * or more contributor license agreements. See the NOTICE file
  37925. * distributed with this work for additional information
  37926. * regarding copyright ownership. The ASF licenses this file
  37927. * to you under the Apache License, Version 2.0 (the
  37928. * "License"); you may not use this file except in compliance
  37929. * with the License. You may obtain a copy of the License at
  37930. *
  37931. * http://www.apache.org/licenses/LICENSE-2.0
  37932. *
  37933. * Unless required by applicable law or agreed to in writing,
  37934. * software distributed under the License is distributed on an
  37935. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  37936. * KIND, either express or implied. See the License for the
  37937. * specific language governing permissions and limitations
  37938. * under the License.
  37939. */
  37940. var BaseBarSeriesModel =
  37941. /** @class */
  37942. function (_super) {
  37943. __extends(BaseBarSeriesModel, _super);
  37944. function BaseBarSeriesModel() {
  37945. var _this = _super !== null && _super.apply(this, arguments) || this;
  37946. _this.type = BaseBarSeriesModel.type;
  37947. return _this;
  37948. }
  37949. BaseBarSeriesModel.prototype.getInitialData = function (option, ecModel) {
  37950. return createListFromArray(this.getSource(), this, {
  37951. useEncodeDefaulter: true
  37952. });
  37953. };
  37954. BaseBarSeriesModel.prototype.getMarkerPosition = function (value) {
  37955. var coordSys = this.coordinateSystem;
  37956. if (coordSys) {
  37957. // PENDING if clamp ?
  37958. var pt = coordSys.dataToPoint(coordSys.clampData(value));
  37959. var data = this.getData();
  37960. var offset = data.getLayout('offset');
  37961. var size = data.getLayout('size');
  37962. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  37963. pt[offsetIndex] += offset + size / 2;
  37964. return pt;
  37965. }
  37966. return [NaN, NaN];
  37967. };
  37968. BaseBarSeriesModel.type = 'series.__base_bar__';
  37969. BaseBarSeriesModel.defaultOption = {
  37970. zlevel: 0,
  37971. z: 2,
  37972. coordinateSystem: 'cartesian2d',
  37973. legendHoverLink: true,
  37974. // stack: null
  37975. // Cartesian coordinate system
  37976. // xAxisIndex: 0,
  37977. // yAxisIndex: 0,
  37978. barMinHeight: 0,
  37979. barMinAngle: 0,
  37980. // cursor: null,
  37981. large: false,
  37982. largeThreshold: 400,
  37983. progressive: 3e3,
  37984. progressiveChunkMode: 'mod'
  37985. };
  37986. return BaseBarSeriesModel;
  37987. }(SeriesModel);
  37988. SeriesModel.registerClass(BaseBarSeriesModel);
  37989. /*
  37990. * Licensed to the Apache Software Foundation (ASF) under one
  37991. * or more contributor license agreements. See the NOTICE file
  37992. * distributed with this work for additional information
  37993. * regarding copyright ownership. The ASF licenses this file
  37994. * to you under the Apache License, Version 2.0 (the
  37995. * "License"); you may not use this file except in compliance
  37996. * with the License. You may obtain a copy of the License at
  37997. *
  37998. * http://www.apache.org/licenses/LICENSE-2.0
  37999. *
  38000. * Unless required by applicable law or agreed to in writing,
  38001. * software distributed under the License is distributed on an
  38002. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38003. * KIND, either express or implied. See the License for the
  38004. * specific language governing permissions and limitations
  38005. * under the License.
  38006. */
  38007. /**
  38008. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38009. */
  38010. /*
  38011. * Licensed to the Apache Software Foundation (ASF) under one
  38012. * or more contributor license agreements. See the NOTICE file
  38013. * distributed with this work for additional information
  38014. * regarding copyright ownership. The ASF licenses this file
  38015. * to you under the Apache License, Version 2.0 (the
  38016. * "License"); you may not use this file except in compliance
  38017. * with the License. You may obtain a copy of the License at
  38018. *
  38019. * http://www.apache.org/licenses/LICENSE-2.0
  38020. *
  38021. * Unless required by applicable law or agreed to in writing,
  38022. * software distributed under the License is distributed on an
  38023. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38024. * KIND, either express or implied. See the License for the
  38025. * specific language governing permissions and limitations
  38026. * under the License.
  38027. */
  38028. var BarSeriesModel =
  38029. /** @class */
  38030. function (_super) {
  38031. __extends(BarSeriesModel, _super);
  38032. function BarSeriesModel() {
  38033. var _this = _super !== null && _super.apply(this, arguments) || this;
  38034. _this.type = BarSeriesModel.type;
  38035. return _this;
  38036. }
  38037. BarSeriesModel.prototype.getInitialData = function () {
  38038. return createListFromArray(this.getSource(), this, {
  38039. useEncodeDefaulter: true,
  38040. createInvertedIndices: !!this.get('realtimeSort', true) || null
  38041. });
  38042. };
  38043. /**
  38044. * @override
  38045. */
  38046. BarSeriesModel.prototype.getProgressive = function () {
  38047. // Do not support progressive in normal mode.
  38048. return this.get('large') ? this.get('progressive') : false;
  38049. };
  38050. /**
  38051. * @override
  38052. */
  38053. BarSeriesModel.prototype.getProgressiveThreshold = function () {
  38054. // Do not support progressive in normal mode.
  38055. var progressiveThreshold = this.get('progressiveThreshold');
  38056. var largeThreshold = this.get('largeThreshold');
  38057. if (largeThreshold > progressiveThreshold) {
  38058. progressiveThreshold = largeThreshold;
  38059. }
  38060. return progressiveThreshold;
  38061. };
  38062. BarSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
  38063. return selectors.rect(data.getItemLayout(dataIndex));
  38064. };
  38065. BarSeriesModel.type = 'series.bar';
  38066. BarSeriesModel.dependencies = ['grid', 'polar'];
  38067. BarSeriesModel.defaultOption = inheritDefaultOption(BaseBarSeriesModel.defaultOption, {
  38068. // If clipped
  38069. // Only available on cartesian2d
  38070. clip: true,
  38071. roundCap: false,
  38072. showBackground: false,
  38073. backgroundStyle: {
  38074. color: 'rgba(180, 180, 180, 0.2)',
  38075. borderColor: null,
  38076. borderWidth: 0,
  38077. borderType: 'solid',
  38078. borderRadius: 0,
  38079. shadowBlur: 0,
  38080. shadowColor: null,
  38081. shadowOffsetX: 0,
  38082. shadowOffsetY: 0,
  38083. opacity: 1
  38084. },
  38085. select: {
  38086. itemStyle: {
  38087. borderColor: '#212121'
  38088. }
  38089. },
  38090. realtimeSort: false
  38091. });
  38092. return BarSeriesModel;
  38093. }(BaseBarSeriesModel);
  38094. /*
  38095. * Licensed to the Apache Software Foundation (ASF) under one
  38096. * or more contributor license agreements. See the NOTICE file
  38097. * distributed with this work for additional information
  38098. * regarding copyright ownership. The ASF licenses this file
  38099. * to you under the Apache License, Version 2.0 (the
  38100. * "License"); you may not use this file except in compliance
  38101. * with the License. You may obtain a copy of the License at
  38102. *
  38103. * http://www.apache.org/licenses/LICENSE-2.0
  38104. *
  38105. * Unless required by applicable law or agreed to in writing,
  38106. * software distributed under the License is distributed on an
  38107. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38108. * KIND, either express or implied. See the License for the
  38109. * specific language governing permissions and limitations
  38110. * under the License.
  38111. */
  38112. /**
  38113. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38114. */
  38115. /*
  38116. * Licensed to the Apache Software Foundation (ASF) under one
  38117. * or more contributor license agreements. See the NOTICE file
  38118. * distributed with this work for additional information
  38119. * regarding copyright ownership. The ASF licenses this file
  38120. * to you under the Apache License, Version 2.0 (the
  38121. * "License"); you may not use this file except in compliance
  38122. * with the License. You may obtain a copy of the License at
  38123. *
  38124. * http://www.apache.org/licenses/LICENSE-2.0
  38125. *
  38126. * Unless required by applicable law or agreed to in writing,
  38127. * software distributed under the License is distributed on an
  38128. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38129. * KIND, either express or implied. See the License for the
  38130. * specific language governing permissions and limitations
  38131. * under the License.
  38132. */
  38133. function createGridClipPath(cartesian, hasAnimation, seriesModel, done, during) {
  38134. var rect = cartesian.getArea();
  38135. var x = rect.x;
  38136. var y = rect.y;
  38137. var width = rect.width;
  38138. var height = rect.height;
  38139. var lineWidth = seriesModel.get(['lineStyle', 'width']) || 2; // Expand the clip path a bit to avoid the border is clipped and looks thinner
  38140. x -= lineWidth / 2;
  38141. y -= lineWidth / 2;
  38142. width += lineWidth;
  38143. height += lineWidth; // fix: https://github.com/apache/incubator-echarts/issues/11369
  38144. x = Math.floor(x);
  38145. width = Math.round(width);
  38146. var clipPath = new Rect({
  38147. shape: {
  38148. x: x,
  38149. y: y,
  38150. width: width,
  38151. height: height
  38152. }
  38153. });
  38154. if (hasAnimation) {
  38155. var baseAxis = cartesian.getBaseAxis();
  38156. var isHorizontal = baseAxis.isHorizontal();
  38157. var isAxisInversed = baseAxis.inverse;
  38158. if (isHorizontal) {
  38159. if (isAxisInversed) {
  38160. clipPath.shape.x += width;
  38161. }
  38162. clipPath.shape.width = 0;
  38163. } else {
  38164. if (!isAxisInversed) {
  38165. clipPath.shape.y += height;
  38166. }
  38167. clipPath.shape.height = 0;
  38168. }
  38169. var duringCb = typeof during === 'function' ? function (percent) {
  38170. during(percent, clipPath);
  38171. } : null;
  38172. initProps(clipPath, {
  38173. shape: {
  38174. width: width,
  38175. height: height,
  38176. x: x,
  38177. y: y
  38178. }
  38179. }, seriesModel, null, done, duringCb);
  38180. }
  38181. return clipPath;
  38182. }
  38183. function createPolarClipPath(polar, hasAnimation, seriesModel) {
  38184. var sectorArea = polar.getArea(); // Avoid float number rounding error for symbol on the edge of axis extent.
  38185. var r0 = round(sectorArea.r0, 1);
  38186. var r = round(sectorArea.r, 1);
  38187. var clipPath = new Sector({
  38188. shape: {
  38189. cx: round(polar.cx, 1),
  38190. cy: round(polar.cy, 1),
  38191. r0: r0,
  38192. r: r,
  38193. startAngle: sectorArea.startAngle,
  38194. endAngle: sectorArea.endAngle,
  38195. clockwise: sectorArea.clockwise
  38196. }
  38197. });
  38198. if (hasAnimation) {
  38199. var isRadial = polar.getBaseAxis().dim === 'angle';
  38200. if (isRadial) {
  38201. clipPath.shape.endAngle = sectorArea.startAngle;
  38202. } else {
  38203. clipPath.shape.r = r0;
  38204. }
  38205. initProps(clipPath, {
  38206. shape: {
  38207. endAngle: sectorArea.endAngle,
  38208. r: r
  38209. }
  38210. }, seriesModel);
  38211. }
  38212. return clipPath;
  38213. }
  38214. function createClipPath(coordSys, hasAnimation, seriesModel, done, during) {
  38215. if (!coordSys) {
  38216. return null;
  38217. } else if (coordSys.type === 'polar') {
  38218. return createPolarClipPath(coordSys, hasAnimation, seriesModel);
  38219. } else if (coordSys.type === 'cartesian2d') {
  38220. return createGridClipPath(coordSys, hasAnimation, seriesModel, done, during);
  38221. }
  38222. return null;
  38223. }
  38224. /*
  38225. * Licensed to the Apache Software Foundation (ASF) under one
  38226. * or more contributor license agreements. See the NOTICE file
  38227. * distributed with this work for additional information
  38228. * regarding copyright ownership. The ASF licenses this file
  38229. * to you under the Apache License, Version 2.0 (the
  38230. * "License"); you may not use this file except in compliance
  38231. * with the License. You may obtain a copy of the License at
  38232. *
  38233. * http://www.apache.org/licenses/LICENSE-2.0
  38234. *
  38235. * Unless required by applicable law or agreed to in writing,
  38236. * software distributed under the License is distributed on an
  38237. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38238. * KIND, either express or implied. See the License for the
  38239. * specific language governing permissions and limitations
  38240. * under the License.
  38241. */
  38242. /**
  38243. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38244. */
  38245. /*
  38246. * Licensed to the Apache Software Foundation (ASF) under one
  38247. * or more contributor license agreements. See the NOTICE file
  38248. * distributed with this work for additional information
  38249. * regarding copyright ownership. The ASF licenses this file
  38250. * to you under the Apache License, Version 2.0 (the
  38251. * "License"); you may not use this file except in compliance
  38252. * with the License. You may obtain a copy of the License at
  38253. *
  38254. * http://www.apache.org/licenses/LICENSE-2.0
  38255. *
  38256. * Unless required by applicable law or agreed to in writing,
  38257. * software distributed under the License is distributed on an
  38258. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38259. * KIND, either express or implied. See the License for the
  38260. * specific language governing permissions and limitations
  38261. * under the License.
  38262. */
  38263. /**
  38264. * Sausage: similar to sector, but have half circle on both sides
  38265. */
  38266. var SausageShape =
  38267. /** @class */
  38268. function () {
  38269. function SausageShape() {
  38270. this.cx = 0;
  38271. this.cy = 0;
  38272. this.r0 = 0;
  38273. this.r = 0;
  38274. this.startAngle = 0;
  38275. this.endAngle = Math.PI * 2;
  38276. this.clockwise = true;
  38277. }
  38278. return SausageShape;
  38279. }();
  38280. var SausagePath =
  38281. /** @class */
  38282. function (_super) {
  38283. __extends(SausagePath, _super);
  38284. function SausagePath(opts) {
  38285. var _this = _super.call(this, opts) || this;
  38286. _this.type = 'sausage';
  38287. return _this;
  38288. }
  38289. SausagePath.prototype.getDefaultShape = function () {
  38290. return new SausageShape();
  38291. };
  38292. SausagePath.prototype.buildPath = function (ctx, shape) {
  38293. var x = shape.cx;
  38294. var y = shape.cy;
  38295. var r0 = Math.max(shape.r0 || 0, 0);
  38296. var r = Math.max(shape.r, 0);
  38297. var dr = (r - r0) * 0.5;
  38298. var rCenter = r0 + dr;
  38299. var startAngle = shape.startAngle;
  38300. var endAngle = shape.endAngle;
  38301. var clockwise = shape.clockwise;
  38302. var unitStartX = Math.cos(startAngle);
  38303. var unitStartY = Math.sin(startAngle);
  38304. var unitEndX = Math.cos(endAngle);
  38305. var unitEndY = Math.sin(endAngle);
  38306. var lessThanCircle = clockwise ? endAngle - startAngle < Math.PI * 2 : startAngle - endAngle < Math.PI * 2;
  38307. if (lessThanCircle) {
  38308. ctx.moveTo(unitStartX * r0 + x, unitStartY * r0 + y);
  38309. ctx.arc(unitStartX * rCenter + x, unitStartY * rCenter + y, dr, -Math.PI + startAngle, startAngle, !clockwise);
  38310. }
  38311. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  38312. ctx.moveTo(unitEndX * r + x, unitEndY * r + y);
  38313. ctx.arc(unitEndX * rCenter + x, unitEndY * rCenter + y, dr, endAngle - Math.PI * 2, endAngle - Math.PI, !clockwise);
  38314. if (r0 !== 0) {
  38315. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  38316. ctx.moveTo(unitStartX * r0 + x, unitEndY * r0 + y);
  38317. }
  38318. ctx.closePath();
  38319. };
  38320. return SausagePath;
  38321. }(Path);
  38322. /*
  38323. * Licensed to the Apache Software Foundation (ASF) under one
  38324. * or more contributor license agreements. See the NOTICE file
  38325. * distributed with this work for additional information
  38326. * regarding copyright ownership. The ASF licenses this file
  38327. * to you under the Apache License, Version 2.0 (the
  38328. * "License"); you may not use this file except in compliance
  38329. * with the License. You may obtain a copy of the License at
  38330. *
  38331. * http://www.apache.org/licenses/LICENSE-2.0
  38332. *
  38333. * Unless required by applicable law or agreed to in writing,
  38334. * software distributed under the License is distributed on an
  38335. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38336. * KIND, either express or implied. See the License for the
  38337. * specific language governing permissions and limitations
  38338. * under the License.
  38339. */
  38340. /**
  38341. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38342. */
  38343. /*
  38344. * Licensed to the Apache Software Foundation (ASF) under one
  38345. * or more contributor license agreements. See the NOTICE file
  38346. * distributed with this work for additional information
  38347. * regarding copyright ownership. The ASF licenses this file
  38348. * to you under the Apache License, Version 2.0 (the
  38349. * "License"); you may not use this file except in compliance
  38350. * with the License. You may obtain a copy of the License at
  38351. *
  38352. * http://www.apache.org/licenses/LICENSE-2.0
  38353. *
  38354. * Unless required by applicable law or agreed to in writing,
  38355. * software distributed under the License is distributed on an
  38356. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38357. * KIND, either express or implied. See the License for the
  38358. * specific language governing permissions and limitations
  38359. * under the License.
  38360. */
  38361. function isCoordinateSystemType(coordSys, type) {
  38362. return coordSys.type === type;
  38363. }
  38364. /*
  38365. * Licensed to the Apache Software Foundation (ASF) under one
  38366. * or more contributor license agreements. See the NOTICE file
  38367. * distributed with this work for additional information
  38368. * regarding copyright ownership. The ASF licenses this file
  38369. * to you under the Apache License, Version 2.0 (the
  38370. * "License"); you may not use this file except in compliance
  38371. * with the License. You may obtain a copy of the License at
  38372. *
  38373. * http://www.apache.org/licenses/LICENSE-2.0
  38374. *
  38375. * Unless required by applicable law or agreed to in writing,
  38376. * software distributed under the License is distributed on an
  38377. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38378. * KIND, either express or implied. See the License for the
  38379. * specific language governing permissions and limitations
  38380. * under the License.
  38381. */
  38382. /**
  38383. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38384. */
  38385. /*
  38386. * Licensed to the Apache Software Foundation (ASF) under one
  38387. * or more contributor license agreements. See the NOTICE file
  38388. * distributed with this work for additional information
  38389. * regarding copyright ownership. The ASF licenses this file
  38390. * to you under the Apache License, Version 2.0 (the
  38391. * "License"); you may not use this file except in compliance
  38392. * with the License. You may obtain a copy of the License at
  38393. *
  38394. * http://www.apache.org/licenses/LICENSE-2.0
  38395. *
  38396. * Unless required by applicable law or agreed to in writing,
  38397. * software distributed under the License is distributed on an
  38398. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38399. * KIND, either express or implied. See the License for the
  38400. * specific language governing permissions and limitations
  38401. * under the License.
  38402. */
  38403. /**
  38404. * @return label string. Not null/undefined
  38405. */
  38406. function getDefaultLabel(data, dataIndex) {
  38407. var labelDims = data.mapDimensionsAll('defaultedLabel');
  38408. var len = labelDims.length; // Simple optimization (in lots of cases, label dims length is 1)
  38409. if (len === 1) {
  38410. var rawVal = retrieveRawValue(data, dataIndex, labelDims[0]);
  38411. return rawVal != null ? rawVal + '' : null;
  38412. } else if (len) {
  38413. var vals = [];
  38414. for (var i = 0; i < labelDims.length; i++) {
  38415. vals.push(retrieveRawValue(data, dataIndex, labelDims[i]));
  38416. }
  38417. return vals.join(' ');
  38418. }
  38419. }
  38420. function getDefaultInterpolatedLabel(data, interpolatedValue) {
  38421. var labelDims = data.mapDimensionsAll('defaultedLabel');
  38422. if (!isArray(interpolatedValue)) {
  38423. return interpolatedValue + '';
  38424. }
  38425. var vals = [];
  38426. for (var i = 0; i < labelDims.length; i++) {
  38427. var dimInfo = data.getDimensionInfo(labelDims[i]);
  38428. if (dimInfo) {
  38429. vals.push(interpolatedValue[dimInfo.index]);
  38430. }
  38431. }
  38432. return vals.join(' ');
  38433. }
  38434. /*
  38435. * Licensed to the Apache Software Foundation (ASF) under one
  38436. * or more contributor license agreements. See the NOTICE file
  38437. * distributed with this work for additional information
  38438. * regarding copyright ownership. The ASF licenses this file
  38439. * to you under the Apache License, Version 2.0 (the
  38440. * "License"); you may not use this file except in compliance
  38441. * with the License. You may obtain a copy of the License at
  38442. *
  38443. * http://www.apache.org/licenses/LICENSE-2.0
  38444. *
  38445. * Unless required by applicable law or agreed to in writing,
  38446. * software distributed under the License is distributed on an
  38447. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38448. * KIND, either express or implied. See the License for the
  38449. * specific language governing permissions and limitations
  38450. * under the License.
  38451. */
  38452. /**
  38453. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38454. */
  38455. /*
  38456. * Licensed to the Apache Software Foundation (ASF) under one
  38457. * or more contributor license agreements. See the NOTICE file
  38458. * distributed with this work for additional information
  38459. * regarding copyright ownership. The ASF licenses this file
  38460. * to you under the Apache License, Version 2.0 (the
  38461. * "License"); you may not use this file except in compliance
  38462. * with the License. You may obtain a copy of the License at
  38463. *
  38464. * http://www.apache.org/licenses/LICENSE-2.0
  38465. *
  38466. * Unless required by applicable law or agreed to in writing,
  38467. * software distributed under the License is distributed on an
  38468. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38469. * KIND, either express or implied. See the License for the
  38470. * specific language governing permissions and limitations
  38471. * under the License.
  38472. */
  38473. var _eventPos = [0, 0];
  38474. var mathMax$5 = Math.max;
  38475. var mathMin$5 = Math.min;
  38476. function getClipArea(coord, data) {
  38477. var coordSysClipArea = coord.getArea && coord.getArea();
  38478. if (isCoordinateSystemType(coord, 'cartesian2d')) {
  38479. var baseAxis = coord.getBaseAxis(); // When boundaryGap is false or using time axis. bar may exceed the grid.
  38480. // We should not clip this part.
  38481. // See test/bar2.html
  38482. if (baseAxis.type !== 'category' || !baseAxis.onBand) {
  38483. var expandWidth = data.getLayout('bandWidth');
  38484. if (baseAxis.isHorizontal()) {
  38485. coordSysClipArea.x -= expandWidth;
  38486. coordSysClipArea.width += expandWidth * 2;
  38487. } else {
  38488. coordSysClipArea.y -= expandWidth;
  38489. coordSysClipArea.height += expandWidth * 2;
  38490. }
  38491. }
  38492. }
  38493. return coordSysClipArea;
  38494. }
  38495. var BarView =
  38496. /** @class */
  38497. function (_super) {
  38498. __extends(BarView, _super);
  38499. function BarView() {
  38500. var _this = _super.call(this) || this;
  38501. _this.type = BarView.type;
  38502. _this._isFirstFrame = true;
  38503. return _this;
  38504. }
  38505. BarView.prototype.render = function (seriesModel, ecModel, api, payload) {
  38506. this._model = seriesModel;
  38507. this._removeOnRenderedListener(api);
  38508. this._updateDrawMode(seriesModel);
  38509. var coordinateSystemType = seriesModel.get('coordinateSystem');
  38510. if (coordinateSystemType === 'cartesian2d' || coordinateSystemType === 'polar') {
  38511. this._isLargeDraw ? this._renderLarge(seriesModel, ecModel, api) : this._renderNormal(seriesModel, ecModel, api, payload);
  38512. } else {
  38513. warn('Only cartesian2d and polar supported for bar.');
  38514. }
  38515. };
  38516. BarView.prototype.incrementalPrepareRender = function (seriesModel) {
  38517. this._clear();
  38518. this._updateDrawMode(seriesModel); // incremental also need to clip, otherwise might be overlow.
  38519. // But must not set clip in each frame, otherwise all of the children will be marked redraw.
  38520. this._updateLargeClip(seriesModel);
  38521. };
  38522. BarView.prototype.incrementalRender = function (params, seriesModel) {
  38523. // Do not support progressive in normal mode.
  38524. this._incrementalRenderLarge(params, seriesModel);
  38525. };
  38526. BarView.prototype._updateDrawMode = function (seriesModel) {
  38527. var isLargeDraw = seriesModel.pipelineContext.large;
  38528. if (this._isLargeDraw == null || isLargeDraw !== this._isLargeDraw) {
  38529. this._isLargeDraw = isLargeDraw;
  38530. this._clear();
  38531. }
  38532. };
  38533. BarView.prototype._renderNormal = function (seriesModel, ecModel, api, payload) {
  38534. var group = this.group;
  38535. var data = seriesModel.getData();
  38536. var oldData = this._data;
  38537. var coord = seriesModel.coordinateSystem;
  38538. var baseAxis = coord.getBaseAxis();
  38539. var isHorizontalOrRadial;
  38540. if (coord.type === 'cartesian2d') {
  38541. isHorizontalOrRadial = baseAxis.isHorizontal();
  38542. } else if (coord.type === 'polar') {
  38543. isHorizontalOrRadial = baseAxis.dim === 'angle';
  38544. }
  38545. var animationModel = seriesModel.isAnimationEnabled() ? seriesModel : null;
  38546. var realtimeSortCfg = shouldRealtimeSort(seriesModel, coord);
  38547. if (realtimeSortCfg) {
  38548. this._enableRealtimeSort(realtimeSortCfg, data, api);
  38549. }
  38550. var needsClip = seriesModel.get('clip', true) || realtimeSortCfg;
  38551. var coordSysClipArea = getClipArea(coord, data); // If there is clipPath created in large mode. Remove it.
  38552. group.removeClipPath(); // We don't use clipPath in normal mode because we needs a perfect animation
  38553. // And don't want the label are clipped.
  38554. var roundCap = seriesModel.get('roundCap', true);
  38555. var drawBackground = seriesModel.get('showBackground', true);
  38556. var backgroundModel = seriesModel.getModel('backgroundStyle');
  38557. var barBorderRadius = backgroundModel.get('borderRadius') || 0;
  38558. var bgEls = [];
  38559. var oldBgEls = this._backgroundEls;
  38560. var isInitSort = payload && payload.isInitSort;
  38561. var isChangeOrder = payload && payload.type === 'changeAxisOrder';
  38562. function createBackground(dataIndex) {
  38563. var bgLayout = getLayout[coord.type](data, dataIndex);
  38564. var bgEl = createBackgroundEl(coord, isHorizontalOrRadial, bgLayout);
  38565. bgEl.useStyle(backgroundModel.getItemStyle()); // Only cartesian2d support borderRadius.
  38566. if (coord.type === 'cartesian2d') {
  38567. bgEl.setShape('r', barBorderRadius);
  38568. }
  38569. bgEls[dataIndex] = bgEl;
  38570. return bgEl;
  38571. }
  38572. data.diff(oldData).add(function (dataIndex) {
  38573. var itemModel = data.getItemModel(dataIndex);
  38574. var layout = getLayout[coord.type](data, dataIndex, itemModel);
  38575. if (drawBackground) {
  38576. createBackground(dataIndex);
  38577. } // If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
  38578. if (!data.hasValue(dataIndex)) {
  38579. return;
  38580. }
  38581. var isClipped = false;
  38582. if (needsClip) {
  38583. // Clip will modify the layout params.
  38584. // And return a boolean to determine if the shape are fully clipped.
  38585. isClipped = clip[coord.type](coordSysClipArea, layout);
  38586. }
  38587. var el = elementCreator[coord.type](seriesModel, data, dataIndex, layout, isHorizontalOrRadial, animationModel, baseAxis.model, false, roundCap);
  38588. updateStyle(el, data, dataIndex, itemModel, layout, seriesModel, isHorizontalOrRadial, coord.type === 'polar');
  38589. if (isInitSort) {
  38590. el.attr({
  38591. shape: layout
  38592. });
  38593. } else if (realtimeSortCfg) {
  38594. updateRealtimeAnimation(realtimeSortCfg, animationModel, el, layout, dataIndex, isHorizontalOrRadial, false, false);
  38595. } else {
  38596. initProps(el, {
  38597. shape: layout
  38598. }, seriesModel, dataIndex);
  38599. }
  38600. data.setItemGraphicEl(dataIndex, el);
  38601. group.add(el);
  38602. el.ignore = isClipped;
  38603. }).update(function (newIndex, oldIndex) {
  38604. var itemModel = data.getItemModel(newIndex);
  38605. var layout = getLayout[coord.type](data, newIndex, itemModel);
  38606. if (drawBackground) {
  38607. var bgEl = void 0;
  38608. if (oldBgEls.length === 0) {
  38609. bgEl = createBackground(oldIndex);
  38610. } else {
  38611. bgEl = oldBgEls[oldIndex];
  38612. bgEl.useStyle(backgroundModel.getItemStyle()); // Only cartesian2d support borderRadius.
  38613. if (coord.type === 'cartesian2d') {
  38614. bgEl.setShape('r', barBorderRadius);
  38615. }
  38616. bgEls[newIndex] = bgEl;
  38617. }
  38618. var bgLayout = getLayout[coord.type](data, newIndex);
  38619. var shape = createBackgroundShape(isHorizontalOrRadial, bgLayout, coord);
  38620. updateProps(bgEl, {
  38621. shape: shape
  38622. }, animationModel, newIndex);
  38623. }
  38624. var el = oldData.getItemGraphicEl(oldIndex);
  38625. if (!data.hasValue(newIndex)) {
  38626. group.remove(el);
  38627. el = null;
  38628. return;
  38629. }
  38630. var isClipped = false;
  38631. if (needsClip) {
  38632. isClipped = clip[coord.type](coordSysClipArea, layout);
  38633. if (isClipped) {
  38634. group.remove(el);
  38635. }
  38636. }
  38637. if (!el) {
  38638. el = elementCreator[coord.type](seriesModel, data, newIndex, layout, isHorizontalOrRadial, animationModel, baseAxis.model, !!el, roundCap);
  38639. } // Not change anything if only order changed.
  38640. // Especially not change label.
  38641. if (!isChangeOrder) {
  38642. updateStyle(el, data, newIndex, itemModel, layout, seriesModel, isHorizontalOrRadial, coord.type === 'polar');
  38643. }
  38644. if (isInitSort) {
  38645. el.attr({
  38646. shape: layout
  38647. });
  38648. } else if (realtimeSortCfg) {
  38649. updateRealtimeAnimation(realtimeSortCfg, animationModel, el, layout, newIndex, isHorizontalOrRadial, true, isChangeOrder);
  38650. } else {
  38651. updateProps(el, {
  38652. shape: layout
  38653. }, seriesModel, newIndex, null);
  38654. }
  38655. data.setItemGraphicEl(newIndex, el);
  38656. el.ignore = isClipped;
  38657. group.add(el);
  38658. }).remove(function (dataIndex) {
  38659. var el = oldData.getItemGraphicEl(dataIndex);
  38660. el && removeElementWithFadeOut(el, seriesModel, dataIndex);
  38661. }).execute();
  38662. var bgGroup = this._backgroundGroup || (this._backgroundGroup = new Group());
  38663. bgGroup.removeAll();
  38664. for (var i = 0; i < bgEls.length; ++i) {
  38665. bgGroup.add(bgEls[i]);
  38666. }
  38667. group.add(bgGroup);
  38668. this._backgroundEls = bgEls;
  38669. this._data = data;
  38670. };
  38671. BarView.prototype._renderLarge = function (seriesModel, ecModel, api) {
  38672. this._clear();
  38673. createLarge(seriesModel, this.group);
  38674. this._updateLargeClip(seriesModel);
  38675. };
  38676. BarView.prototype._incrementalRenderLarge = function (params, seriesModel) {
  38677. this._removeBackground();
  38678. createLarge(seriesModel, this.group, true);
  38679. };
  38680. BarView.prototype._updateLargeClip = function (seriesModel) {
  38681. // Use clipPath in large mode.
  38682. var clipPath = seriesModel.get('clip', true) ? createClipPath(seriesModel.coordinateSystem, false, seriesModel) : null;
  38683. if (clipPath) {
  38684. this.group.setClipPath(clipPath);
  38685. } else {
  38686. this.group.removeClipPath();
  38687. }
  38688. };
  38689. BarView.prototype._enableRealtimeSort = function (realtimeSortCfg, data, api) {
  38690. var _this = this; // If no data in the first frame, wait for data to initSort
  38691. if (!data.count()) {
  38692. return;
  38693. }
  38694. var baseAxis = realtimeSortCfg.baseAxis;
  38695. if (this._isFirstFrame) {
  38696. this._dispatchInitSort(data, realtimeSortCfg, api);
  38697. this._isFirstFrame = false;
  38698. } else {
  38699. var orderMapping_1 = function (idx) {
  38700. var el = data.getItemGraphicEl(idx);
  38701. if (el) {
  38702. var shape = el.shape; // If data is NaN, shape.xxx may be NaN, so use || 0 here in case
  38703. return (baseAxis.isHorizontal() // The result should be consistent with the initial sort by data value.
  38704. // Do not support the case that both positive and negative exist.
  38705. ? Math.abs(shape.height) : Math.abs(shape.width)) || 0;
  38706. } else {
  38707. return 0;
  38708. }
  38709. };
  38710. this._onRendered = function () {
  38711. _this._updateSortWithinSameData(data, orderMapping_1, baseAxis, api);
  38712. };
  38713. api.getZr().on('rendered', this._onRendered);
  38714. }
  38715. };
  38716. BarView.prototype._dataSort = function (data, baseAxis, orderMapping) {
  38717. var info = [];
  38718. data.each(data.mapDimension(baseAxis.dim), function (ordinalNumber, dataIdx) {
  38719. var mappedValue = orderMapping(dataIdx);
  38720. mappedValue = mappedValue == null ? NaN : mappedValue;
  38721. info.push({
  38722. dataIndex: dataIdx,
  38723. mappedValue: mappedValue,
  38724. ordinalNumber: ordinalNumber
  38725. });
  38726. });
  38727. info.sort(function (a, b) {
  38728. // If NaN, it will be treated as min val.
  38729. return b.mappedValue - a.mappedValue;
  38730. });
  38731. return {
  38732. ordinalNumbers: map(info, function (item) {
  38733. return item.ordinalNumber;
  38734. })
  38735. };
  38736. };
  38737. BarView.prototype._isOrderChangedWithinSameData = function (data, orderMapping, baseAxis) {
  38738. var scale = baseAxis.scale;
  38739. var ordinalDataDim = data.mapDimension(baseAxis.dim);
  38740. var lastValue = Number.MAX_VALUE;
  38741. for (var tickNum = 0, len = scale.getOrdinalMeta().categories.length; tickNum < len; ++tickNum) {
  38742. var rawIdx = data.rawIndexOf(ordinalDataDim, scale.getRawOrdinalNumber(tickNum));
  38743. var value = rawIdx < 0 // If some tick have no bar, the tick will be treated as min.
  38744. ? Number.MIN_VALUE // PENDING: if dataZoom on baseAxis exits, is it a performance issue?
  38745. : orderMapping(data.indexOfRawIndex(rawIdx));
  38746. if (value > lastValue) {
  38747. return true;
  38748. }
  38749. lastValue = value;
  38750. }
  38751. return false;
  38752. };
  38753. /*
  38754. * Consider the case when A and B changed order, whose representing
  38755. * bars are both out of sight, we don't wish to trigger reorder action
  38756. * as long as the order in the view doesn't change.
  38757. */
  38758. BarView.prototype._isOrderDifferentInView = function (orderInfo, baseAxis) {
  38759. var scale = baseAxis.scale;
  38760. var extent = scale.getExtent();
  38761. var tickNum = Math.max(0, extent[0]);
  38762. var tickMax = Math.min(extent[1], scale.getOrdinalMeta().categories.length - 1);
  38763. for (; tickNum <= tickMax; ++tickNum) {
  38764. if (orderInfo.ordinalNumbers[tickNum] !== scale.getRawOrdinalNumber(tickNum)) {
  38765. return true;
  38766. }
  38767. }
  38768. };
  38769. BarView.prototype._updateSortWithinSameData = function (data, orderMapping, baseAxis, api) {
  38770. if (!this._isOrderChangedWithinSameData(data, orderMapping, baseAxis)) {
  38771. return;
  38772. }
  38773. var sortInfo = this._dataSort(data, baseAxis, orderMapping);
  38774. if (this._isOrderDifferentInView(sortInfo, baseAxis)) {
  38775. this._removeOnRenderedListener(api);
  38776. api.dispatchAction({
  38777. type: 'changeAxisOrder',
  38778. componentType: baseAxis.dim + 'Axis',
  38779. axisId: baseAxis.index,
  38780. sortInfo: sortInfo
  38781. });
  38782. }
  38783. };
  38784. BarView.prototype._dispatchInitSort = function (data, realtimeSortCfg, api) {
  38785. var baseAxis = realtimeSortCfg.baseAxis;
  38786. var sortResult = this._dataSort(data, baseAxis, function (dataIdx) {
  38787. return data.get(data.mapDimension(realtimeSortCfg.otherAxis.dim), dataIdx);
  38788. });
  38789. api.dispatchAction({
  38790. type: 'changeAxisOrder',
  38791. componentType: baseAxis.dim + 'Axis',
  38792. isInitSort: true,
  38793. axisId: baseAxis.index,
  38794. sortInfo: sortResult,
  38795. animation: {
  38796. // Update the axis label from the natural initial layout to
  38797. // sorted layout should has no animation.
  38798. duration: 0
  38799. }
  38800. });
  38801. };
  38802. BarView.prototype.remove = function (ecModel, api) {
  38803. this._clear(this._model);
  38804. this._removeOnRenderedListener(api);
  38805. };
  38806. BarView.prototype.dispose = function (ecModel, api) {
  38807. this._removeOnRenderedListener(api);
  38808. };
  38809. BarView.prototype._removeOnRenderedListener = function (api) {
  38810. if (this._onRendered) {
  38811. api.getZr().off('rendered', this._onRendered);
  38812. this._onRendered = null;
  38813. }
  38814. };
  38815. BarView.prototype._clear = function (model) {
  38816. var group = this.group;
  38817. var data = this._data;
  38818. if (model && model.isAnimationEnabled() && data && !this._isLargeDraw) {
  38819. this._removeBackground();
  38820. this._backgroundEls = [];
  38821. data.eachItemGraphicEl(function (el) {
  38822. removeElementWithFadeOut(el, model, getECData(el).dataIndex);
  38823. });
  38824. } else {
  38825. group.removeAll();
  38826. }
  38827. this._data = null;
  38828. this._isFirstFrame = true;
  38829. };
  38830. BarView.prototype._removeBackground = function () {
  38831. this.group.remove(this._backgroundGroup);
  38832. this._backgroundGroup = null;
  38833. };
  38834. BarView.type = 'bar';
  38835. return BarView;
  38836. }(ChartView);
  38837. var clip = {
  38838. cartesian2d: function (coordSysBoundingRect, layout) {
  38839. var signWidth = layout.width < 0 ? -1 : 1;
  38840. var signHeight = layout.height < 0 ? -1 : 1; // Needs positive width and height
  38841. if (signWidth < 0) {
  38842. layout.x += layout.width;
  38843. layout.width = -layout.width;
  38844. }
  38845. if (signHeight < 0) {
  38846. layout.y += layout.height;
  38847. layout.height = -layout.height;
  38848. }
  38849. var coordSysX2 = coordSysBoundingRect.x + coordSysBoundingRect.width;
  38850. var coordSysY2 = coordSysBoundingRect.y + coordSysBoundingRect.height;
  38851. var x = mathMax$5(layout.x, coordSysBoundingRect.x);
  38852. var x2 = mathMin$5(layout.x + layout.width, coordSysX2);
  38853. var y = mathMax$5(layout.y, coordSysBoundingRect.y);
  38854. var y2 = mathMin$5(layout.y + layout.height, coordSysY2);
  38855. var xClipped = x2 < x;
  38856. var yClipped = y2 < y; // When xClipped or yClipped, the element will be marked as `ignore`.
  38857. // But we should also place the element at the edge of the coord sys bounding rect.
  38858. // Beause if data changed and the bar show again, its transition animaiton
  38859. // will begin at this place.
  38860. layout.x = xClipped && x > coordSysX2 ? x2 : x;
  38861. layout.y = yClipped && y > coordSysY2 ? y2 : y;
  38862. layout.width = xClipped ? 0 : x2 - x;
  38863. layout.height = yClipped ? 0 : y2 - y; // Reverse back
  38864. if (signWidth < 0) {
  38865. layout.x += layout.width;
  38866. layout.width = -layout.width;
  38867. }
  38868. if (signHeight < 0) {
  38869. layout.y += layout.height;
  38870. layout.height = -layout.height;
  38871. }
  38872. return xClipped || yClipped;
  38873. },
  38874. polar: function (coordSysClipArea, layout) {
  38875. var signR = layout.r0 <= layout.r ? 1 : -1; // Make sure r is larger than r0
  38876. if (signR < 0) {
  38877. var tmp = layout.r;
  38878. layout.r = layout.r0;
  38879. layout.r0 = tmp;
  38880. }
  38881. var r = mathMin$5(layout.r, coordSysClipArea.r);
  38882. var r0 = mathMax$5(layout.r0, coordSysClipArea.r0);
  38883. layout.r = r;
  38884. layout.r0 = r0;
  38885. var clipped = r - r0 < 0; // Reverse back
  38886. if (signR < 0) {
  38887. var tmp = layout.r;
  38888. layout.r = layout.r0;
  38889. layout.r0 = tmp;
  38890. }
  38891. return clipped;
  38892. }
  38893. };
  38894. var elementCreator = {
  38895. cartesian2d: function (seriesModel, data, newIndex, layout, isHorizontal, animationModel, axisModel, isUpdate, roundCap) {
  38896. var rect = new Rect({
  38897. shape: extend({}, layout),
  38898. z2: 1
  38899. });
  38900. rect.__dataIndex = newIndex;
  38901. rect.name = 'item';
  38902. if (animationModel) {
  38903. var rectShape = rect.shape;
  38904. var animateProperty = isHorizontal ? 'height' : 'width';
  38905. rectShape[animateProperty] = 0;
  38906. }
  38907. return rect;
  38908. },
  38909. polar: function (seriesModel, data, newIndex, layout, isRadial, animationModel, axisModel, isUpdate, roundCap) {
  38910. // Keep the same logic with bar in catesion: use end value to control
  38911. // direction. Notice that if clockwise is true (by default), the sector
  38912. // will always draw clockwisely, no matter whether endAngle is greater
  38913. // or less than startAngle.
  38914. var clockwise = layout.startAngle < layout.endAngle;
  38915. var ShapeClass = !isRadial && roundCap ? SausagePath : Sector;
  38916. var sector = new ShapeClass({
  38917. shape: defaults({
  38918. clockwise: clockwise
  38919. }, layout),
  38920. z2: 1
  38921. });
  38922. sector.name = 'item'; // Animation
  38923. if (animationModel) {
  38924. var sectorShape = sector.shape;
  38925. var animateProperty = isRadial ? 'r' : 'endAngle';
  38926. var animateTarget = {};
  38927. sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle;
  38928. animateTarget[animateProperty] = layout[animateProperty];
  38929. (isUpdate ? updateProps : initProps)(sector, {
  38930. shape: animateTarget // __value: typeof dataValue === 'string' ? parseInt(dataValue, 10) : dataValue
  38931. }, animationModel);
  38932. }
  38933. return sector;
  38934. }
  38935. };
  38936. function shouldRealtimeSort(seriesModel, coordSys) {
  38937. var realtimeSortOption = seriesModel.get('realtimeSort', true);
  38938. var baseAxis = coordSys.getBaseAxis();
  38939. {
  38940. if (realtimeSortOption) {
  38941. if (baseAxis.type !== 'category') {
  38942. warn('`realtimeSort` will not work because this bar series is not based on a category axis.');
  38943. }
  38944. if (coordSys.type !== 'cartesian2d') {
  38945. warn('`realtimeSort` will not work because this bar series is not on cartesian2d.');
  38946. }
  38947. }
  38948. }
  38949. if (realtimeSortOption && baseAxis.type === 'category' && coordSys.type === 'cartesian2d') {
  38950. return {
  38951. baseAxis: baseAxis,
  38952. otherAxis: coordSys.getOtherAxis(baseAxis)
  38953. };
  38954. }
  38955. }
  38956. function updateRealtimeAnimation(realtimeSortCfg, seriesAnimationModel, el, layout, newIndex, isHorizontal, isUpdate, isChangeOrder) {
  38957. var seriesTarget;
  38958. var axisTarget;
  38959. if (isHorizontal) {
  38960. axisTarget = {
  38961. x: layout.x,
  38962. width: layout.width
  38963. };
  38964. seriesTarget = {
  38965. y: layout.y,
  38966. height: layout.height
  38967. };
  38968. } else {
  38969. axisTarget = {
  38970. y: layout.y,
  38971. height: layout.height
  38972. };
  38973. seriesTarget = {
  38974. x: layout.x,
  38975. width: layout.width
  38976. };
  38977. }
  38978. if (!isChangeOrder) {
  38979. // Keep the original growth animation if only axis order changed.
  38980. // Not start a new animation.
  38981. (isUpdate ? updateProps : initProps)(el, {
  38982. shape: seriesTarget
  38983. }, seriesAnimationModel, newIndex, null);
  38984. }
  38985. var axisAnimationModel = seriesAnimationModel ? realtimeSortCfg.baseAxis.model : null;
  38986. (isUpdate ? updateProps : initProps)(el, {
  38987. shape: axisTarget
  38988. }, axisAnimationModel, newIndex);
  38989. }
  38990. var getLayout = {
  38991. // itemModel is only used to get borderWidth, which is not needed
  38992. // when calculating bar background layout.
  38993. cartesian2d: function (data, dataIndex, itemModel) {
  38994. var layout = data.getItemLayout(dataIndex);
  38995. var fixedLineWidth = itemModel ? getLineWidth(itemModel, layout) : 0; // fix layout with lineWidth
  38996. var signX = layout.width > 0 ? 1 : -1;
  38997. var signY = layout.height > 0 ? 1 : -1;
  38998. return {
  38999. x: layout.x + signX * fixedLineWidth / 2,
  39000. y: layout.y + signY * fixedLineWidth / 2,
  39001. width: layout.width - signX * fixedLineWidth,
  39002. height: layout.height - signY * fixedLineWidth
  39003. };
  39004. },
  39005. polar: function (data, dataIndex, itemModel) {
  39006. var layout = data.getItemLayout(dataIndex);
  39007. return {
  39008. cx: layout.cx,
  39009. cy: layout.cy,
  39010. r0: layout.r0,
  39011. r: layout.r,
  39012. startAngle: layout.startAngle,
  39013. endAngle: layout.endAngle
  39014. };
  39015. }
  39016. };
  39017. function isZeroOnPolar(layout) {
  39018. return layout.startAngle != null && layout.endAngle != null && layout.startAngle === layout.endAngle;
  39019. }
  39020. function updateStyle(el, data, dataIndex, itemModel, layout, seriesModel, isHorizontal, isPolar) {
  39021. var style = data.getItemVisual(dataIndex, 'style');
  39022. if (!isPolar) {
  39023. el.setShape('r', itemModel.get(['itemStyle', 'borderRadius']) || 0);
  39024. }
  39025. el.useStyle(style);
  39026. var cursorStyle = itemModel.getShallow('cursor');
  39027. cursorStyle && el.attr('cursor', cursorStyle);
  39028. if (!isPolar) {
  39029. var labelPositionOutside = isHorizontal ? layout.height > 0 ? 'bottom' : 'top' : layout.width > 0 ? 'left' : 'right';
  39030. var labelStatesModels = getLabelStatesModels(itemModel);
  39031. setLabelStyle(el, labelStatesModels, {
  39032. labelFetcher: seriesModel,
  39033. labelDataIndex: dataIndex,
  39034. defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
  39035. inheritColor: style.fill,
  39036. defaultOpacity: style.opacity,
  39037. defaultOutsidePosition: labelPositionOutside
  39038. });
  39039. var label = el.getTextContent();
  39040. setLabelValueAnimation(label, labelStatesModels, seriesModel.getRawValue(dataIndex), function (value) {
  39041. return getDefaultInterpolatedLabel(data, value);
  39042. });
  39043. }
  39044. var emphasisModel = itemModel.getModel(['emphasis']);
  39045. enableHoverEmphasis(el, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  39046. setStatesStylesFromModel(el, itemModel);
  39047. if (isZeroOnPolar(layout)) {
  39048. el.style.fill = 'none';
  39049. el.style.stroke = 'none';
  39050. each$1(el.states, function (state) {
  39051. if (state.style) {
  39052. state.style.fill = state.style.stroke = 'none';
  39053. }
  39054. });
  39055. }
  39056. } // In case width or height are too small.
  39057. function getLineWidth(itemModel, rawLayout) {
  39058. // Has no border.
  39059. var borderColor = itemModel.get(['itemStyle', 'borderColor']);
  39060. if (!borderColor || borderColor === 'none') {
  39061. return 0;
  39062. }
  39063. var lineWidth = itemModel.get(['itemStyle', 'borderWidth']) || 0; // width or height may be NaN for empty data
  39064. var width = isNaN(rawLayout.width) ? Number.MAX_VALUE : Math.abs(rawLayout.width);
  39065. var height = isNaN(rawLayout.height) ? Number.MAX_VALUE : Math.abs(rawLayout.height);
  39066. return Math.min(lineWidth, width, height);
  39067. }
  39068. var LagePathShape =
  39069. /** @class */
  39070. function () {
  39071. function LagePathShape() {}
  39072. return LagePathShape;
  39073. }();
  39074. var LargePath =
  39075. /** @class */
  39076. function (_super) {
  39077. __extends(LargePath, _super);
  39078. function LargePath(opts) {
  39079. var _this = _super.call(this, opts) || this;
  39080. _this.type = 'largeBar';
  39081. return _this;
  39082. }
  39083. LargePath.prototype.getDefaultShape = function () {
  39084. return new LagePathShape();
  39085. };
  39086. LargePath.prototype.buildPath = function (ctx, shape) {
  39087. // Drawing lines is more efficient than drawing
  39088. // a whole line or drawing rects.
  39089. var points = shape.points;
  39090. var startPoint = this.__startPoint;
  39091. var baseDimIdx = this.__baseDimIdx;
  39092. for (var i = 0; i < points.length; i += 2) {
  39093. startPoint[baseDimIdx] = points[i + baseDimIdx];
  39094. ctx.moveTo(startPoint[0], startPoint[1]);
  39095. ctx.lineTo(points[i], points[i + 1]);
  39096. }
  39097. };
  39098. return LargePath;
  39099. }(Path);
  39100. function createLarge(seriesModel, group, incremental) {
  39101. // TODO support polar
  39102. var data = seriesModel.getData();
  39103. var startPoint = [];
  39104. var baseDimIdx = data.getLayout('valueAxisHorizontal') ? 1 : 0;
  39105. startPoint[1 - baseDimIdx] = data.getLayout('valueAxisStart');
  39106. var largeDataIndices = data.getLayout('largeDataIndices');
  39107. var barWidth = data.getLayout('barWidth');
  39108. var backgroundModel = seriesModel.getModel('backgroundStyle');
  39109. var drawBackground = seriesModel.get('showBackground', true);
  39110. if (drawBackground) {
  39111. var points = data.getLayout('largeBackgroundPoints');
  39112. var backgroundStartPoint = [];
  39113. backgroundStartPoint[1 - baseDimIdx] = data.getLayout('backgroundStart');
  39114. var bgEl = new LargePath({
  39115. shape: {
  39116. points: points
  39117. },
  39118. incremental: !!incremental,
  39119. silent: true,
  39120. z2: 0
  39121. });
  39122. bgEl.__startPoint = backgroundStartPoint;
  39123. bgEl.__baseDimIdx = baseDimIdx;
  39124. bgEl.__largeDataIndices = largeDataIndices;
  39125. bgEl.__barWidth = barWidth;
  39126. setLargeBackgroundStyle(bgEl, backgroundModel, data);
  39127. group.add(bgEl);
  39128. }
  39129. var el = new LargePath({
  39130. shape: {
  39131. points: data.getLayout('largePoints')
  39132. },
  39133. incremental: !!incremental
  39134. });
  39135. el.__startPoint = startPoint;
  39136. el.__baseDimIdx = baseDimIdx;
  39137. el.__largeDataIndices = largeDataIndices;
  39138. el.__barWidth = barWidth;
  39139. group.add(el);
  39140. setLargeStyle(el, seriesModel, data); // Enable tooltip and user mouse/touch event handlers.
  39141. getECData(el).seriesIndex = seriesModel.seriesIndex;
  39142. if (!seriesModel.get('silent')) {
  39143. el.on('mousedown', largePathUpdateDataIndex);
  39144. el.on('mousemove', largePathUpdateDataIndex);
  39145. }
  39146. } // Use throttle to avoid frequently traverse to find dataIndex.
  39147. var largePathUpdateDataIndex = throttle(function (event) {
  39148. var largePath = this;
  39149. var dataIndex = largePathFindDataIndex(largePath, event.offsetX, event.offsetY);
  39150. getECData(largePath).dataIndex = dataIndex >= 0 ? dataIndex : null;
  39151. }, 30, false);
  39152. function largePathFindDataIndex(largePath, x, y) {
  39153. var baseDimIdx = largePath.__baseDimIdx;
  39154. var valueDimIdx = 1 - baseDimIdx;
  39155. var points = largePath.shape.points;
  39156. var largeDataIndices = largePath.__largeDataIndices;
  39157. var barWidthHalf = Math.abs(largePath.__barWidth / 2);
  39158. var startValueVal = largePath.__startPoint[valueDimIdx];
  39159. _eventPos[0] = x;
  39160. _eventPos[1] = y;
  39161. var pointerBaseVal = _eventPos[baseDimIdx];
  39162. var pointerValueVal = _eventPos[1 - baseDimIdx];
  39163. var baseLowerBound = pointerBaseVal - barWidthHalf;
  39164. var baseUpperBound = pointerBaseVal + barWidthHalf;
  39165. for (var i = 0, len = points.length / 2; i < len; i++) {
  39166. var ii = i * 2;
  39167. var barBaseVal = points[ii + baseDimIdx];
  39168. var barValueVal = points[ii + valueDimIdx];
  39169. if (barBaseVal >= baseLowerBound && barBaseVal <= baseUpperBound && (startValueVal <= barValueVal ? pointerValueVal >= startValueVal && pointerValueVal <= barValueVal : pointerValueVal >= barValueVal && pointerValueVal <= startValueVal)) {
  39170. return largeDataIndices[i];
  39171. }
  39172. }
  39173. return -1;
  39174. }
  39175. function setLargeStyle(el, seriesModel, data) {
  39176. var globalStyle = data.getVisual('style');
  39177. el.useStyle(extend({}, globalStyle)); // Use stroke instead of fill.
  39178. el.style.fill = null;
  39179. el.style.stroke = globalStyle.fill;
  39180. el.style.lineWidth = data.getLayout('barWidth');
  39181. }
  39182. function setLargeBackgroundStyle(el, backgroundModel, data) {
  39183. var borderColor = backgroundModel.get('borderColor') || backgroundModel.get('color');
  39184. var itemStyle = backgroundModel.getItemStyle();
  39185. el.useStyle(itemStyle);
  39186. el.style.fill = null;
  39187. el.style.stroke = borderColor;
  39188. el.style.lineWidth = data.getLayout('barWidth');
  39189. }
  39190. function createBackgroundShape(isHorizontalOrRadial, layout, coord) {
  39191. if (isCoordinateSystemType(coord, 'cartesian2d')) {
  39192. var rectShape = layout;
  39193. var coordLayout = coord.getArea();
  39194. return {
  39195. x: isHorizontalOrRadial ? rectShape.x : coordLayout.x,
  39196. y: isHorizontalOrRadial ? coordLayout.y : rectShape.y,
  39197. width: isHorizontalOrRadial ? rectShape.width : coordLayout.width,
  39198. height: isHorizontalOrRadial ? coordLayout.height : rectShape.height
  39199. };
  39200. } else {
  39201. var coordLayout = coord.getArea();
  39202. var sectorShape = layout;
  39203. return {
  39204. cx: coordLayout.cx,
  39205. cy: coordLayout.cy,
  39206. r0: isHorizontalOrRadial ? coordLayout.r0 : sectorShape.r0,
  39207. r: isHorizontalOrRadial ? coordLayout.r : sectorShape.r,
  39208. startAngle: isHorizontalOrRadial ? sectorShape.startAngle : 0,
  39209. endAngle: isHorizontalOrRadial ? sectorShape.endAngle : Math.PI * 2
  39210. };
  39211. }
  39212. }
  39213. function createBackgroundEl(coord, isHorizontalOrRadial, layout) {
  39214. var ElementClz = coord.type === 'polar' ? Sector : Rect;
  39215. return new ElementClz({
  39216. shape: createBackgroundShape(isHorizontalOrRadial, layout, coord),
  39217. silent: true,
  39218. z2: 0
  39219. });
  39220. }
  39221. /*
  39222. * Licensed to the Apache Software Foundation (ASF) under one
  39223. * or more contributor license agreements. See the NOTICE file
  39224. * distributed with this work for additional information
  39225. * regarding copyright ownership. The ASF licenses this file
  39226. * to you under the Apache License, Version 2.0 (the
  39227. * "License"); you may not use this file except in compliance
  39228. * with the License. You may obtain a copy of the License at
  39229. *
  39230. * http://www.apache.org/licenses/LICENSE-2.0
  39231. *
  39232. * Unless required by applicable law or agreed to in writing,
  39233. * software distributed under the License is distributed on an
  39234. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39235. * KIND, either express or implied. See the License for the
  39236. * specific language governing permissions and limitations
  39237. * under the License.
  39238. */
  39239. /**
  39240. * AUTO-GENERATED FILE. DO NOT MODIFY.
  39241. */
  39242. /*
  39243. * Licensed to the Apache Software Foundation (ASF) under one
  39244. * or more contributor license agreements. See the NOTICE file
  39245. * distributed with this work for additional information
  39246. * regarding copyright ownership. The ASF licenses this file
  39247. * to you under the Apache License, Version 2.0 (the
  39248. * "License"); you may not use this file except in compliance
  39249. * with the License. You may obtain a copy of the License at
  39250. *
  39251. * http://www.apache.org/licenses/LICENSE-2.0
  39252. *
  39253. * Unless required by applicable law or agreed to in writing,
  39254. * software distributed under the License is distributed on an
  39255. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39256. * KIND, either express or implied. See the License for the
  39257. * specific language governing permissions and limitations
  39258. * under the License.
  39259. */
  39260. function install$2(registers) {
  39261. registers.registerChartView(BarView);
  39262. registers.registerSeriesModel(BarSeriesModel);
  39263. registers.registerLayout(registers.PRIORITY.VISUAL.LAYOUT, curry(layout, 'bar')); // Use higher prority to avoid to be blocked by other overall layout, which do not
  39264. // only exist in this module, but probably also exist in other modules, like `barPolar`.
  39265. registers.registerLayout(registers.PRIORITY.VISUAL.PROGRESSIVE_LAYOUT, largeLayout); // Down sample after filter
  39266. registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, dataSample('bar'));
  39267. /**
  39268. * @payload
  39269. * @property {string} [componentType=series]
  39270. * @property {number} [dx]
  39271. * @property {number} [dy]
  39272. * @property {number} [zoom]
  39273. * @property {number} [originX]
  39274. * @property {number} [originY]
  39275. */
  39276. registers.registerAction({
  39277. type: 'changeAxisOrder',
  39278. event: 'changeAxisOrder',
  39279. update: 'update'
  39280. }, function (payload, ecModel) {
  39281. var componentType = payload.componentType || 'series';
  39282. ecModel.eachComponent({
  39283. mainType: componentType,
  39284. query: payload
  39285. }, function (componentModel) {
  39286. if (payload.sortInfo) {
  39287. componentModel.axis.setCategorySortInfo(payload.sortInfo);
  39288. }
  39289. });
  39290. });
  39291. }
  39292. /*
  39293. * Licensed to the Apache Software Foundation (ASF) under one
  39294. * or more contributor license agreements. See the NOTICE file
  39295. * distributed with this work for additional information
  39296. * regarding copyright ownership. The ASF licenses this file
  39297. * to you under the Apache License, Version 2.0 (the
  39298. * "License"); you may not use this file except in compliance
  39299. * with the License. You may obtain a copy of the License at
  39300. *
  39301. * http://www.apache.org/licenses/LICENSE-2.0
  39302. *
  39303. * Unless required by applicable law or agreed to in writing,
  39304. * software distributed under the License is distributed on an
  39305. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39306. * KIND, either express or implied. See the License for the
  39307. * specific language governing permissions and limitations
  39308. * under the License.
  39309. */
  39310. /**
  39311. * AUTO-GENERATED FILE. DO NOT MODIFY.
  39312. */
  39313. /*
  39314. * Licensed to the Apache Software Foundation (ASF) under one
  39315. * or more contributor license agreements. See the NOTICE file
  39316. * distributed with this work for additional information
  39317. * regarding copyright ownership. The ASF licenses this file
  39318. * to you under the Apache License, Version 2.0 (the
  39319. * "License"); you may not use this file except in compliance
  39320. * with the License. You may obtain a copy of the License at
  39321. *
  39322. * http://www.apache.org/licenses/LICENSE-2.0
  39323. *
  39324. * Unless required by applicable law or agreed to in writing,
  39325. * software distributed under the License is distributed on an
  39326. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39327. * KIND, either express or implied. See the License for the
  39328. * specific language governing permissions and limitations
  39329. * under the License.
  39330. */
  39331. use(install$2);
  39332. /*
  39333. * Licensed to the Apache Software Foundation (ASF) under one
  39334. * or more contributor license agreements. See the NOTICE file
  39335. * distributed with this work for additional information
  39336. * regarding copyright ownership. The ASF licenses this file
  39337. * to you under the Apache License, Version 2.0 (the
  39338. * "License"); you may not use this file except in compliance
  39339. * with the License. You may obtain a copy of the License at
  39340. *
  39341. * http://www.apache.org/licenses/LICENSE-2.0
  39342. *
  39343. * Unless required by applicable law or agreed to in writing,
  39344. * software distributed under the License is distributed on an
  39345. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39346. * KIND, either express or implied. See the License for the
  39347. * specific language governing permissions and limitations
  39348. * under the License.
  39349. */
  39350. /**
  39351. * AUTO-GENERATED FILE. DO NOT MODIFY.
  39352. */
  39353. /*
  39354. * Licensed to the Apache Software Foundation (ASF) under one
  39355. * or more contributor license agreements. See the NOTICE file
  39356. * distributed with this work for additional information
  39357. * regarding copyright ownership. The ASF licenses this file
  39358. * to you under the Apache License, Version 2.0 (the
  39359. * "License"); you may not use this file except in compliance
  39360. * with the License. You may obtain a copy of the License at
  39361. *
  39362. * http://www.apache.org/licenses/LICENSE-2.0
  39363. *
  39364. * Unless required by applicable law or agreed to in writing,
  39365. * software distributed under the License is distributed on an
  39366. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39367. * KIND, either express or implied. See the License for the
  39368. * specific language governing permissions and limitations
  39369. * under the License.
  39370. */
  39371. var LineSeriesModel =
  39372. /** @class */
  39373. function (_super) {
  39374. __extends(LineSeriesModel, _super);
  39375. function LineSeriesModel() {
  39376. var _this = _super !== null && _super.apply(this, arguments) || this;
  39377. _this.type = LineSeriesModel.type;
  39378. _this.hasSymbolVisual = true;
  39379. return _this;
  39380. }
  39381. LineSeriesModel.prototype.getInitialData = function (option) {
  39382. {
  39383. var coordSys = option.coordinateSystem;
  39384. if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
  39385. throw new Error('Line not support coordinateSystem besides cartesian and polar');
  39386. }
  39387. }
  39388. return createListFromArray(this.getSource(), this, {
  39389. useEncodeDefaulter: true
  39390. });
  39391. };
  39392. LineSeriesModel.prototype.getLegendIcon = function (opt) {
  39393. var group = new Group();
  39394. var line = createSymbol('line', 0, opt.itemHeight / 2, opt.itemWidth, 0, opt.lineStyle.stroke, false);
  39395. group.add(line);
  39396. line.setStyle(opt.lineStyle);
  39397. var visualType = this.getData().getVisual('symbol');
  39398. var symbolType = visualType === 'none' ? 'circle' : visualType; // Symbol size is 80% when there is a line
  39399. var size = opt.itemHeight * 0.8;
  39400. var symbol = createSymbol(symbolType, (opt.itemWidth - size) / 2, (opt.itemHeight - size) / 2, size, size, opt.itemStyle.fill, opt.symbolKeepAspect);
  39401. group.add(symbol);
  39402. symbol.setStyle(opt.itemStyle);
  39403. if (symbolType.indexOf('empty') > -1) {
  39404. symbol.style.stroke = symbol.style.fill;
  39405. symbol.style.fill = '#fff';
  39406. symbol.style.lineWidth = 2;
  39407. }
  39408. return group;
  39409. };
  39410. LineSeriesModel.type = 'series.line';
  39411. LineSeriesModel.dependencies = ['grid', 'polar'];
  39412. LineSeriesModel.defaultOption = {
  39413. zlevel: 0,
  39414. z: 3,
  39415. coordinateSystem: 'cartesian2d',
  39416. legendHoverLink: true,
  39417. clip: true,
  39418. label: {
  39419. position: 'top'
  39420. },
  39421. // itemStyle: {
  39422. // },
  39423. endLabel: {
  39424. show: false,
  39425. valueAnimation: true,
  39426. distance: 8
  39427. },
  39428. lineStyle: {
  39429. width: 2,
  39430. type: 'solid'
  39431. },
  39432. emphasis: {
  39433. scale: true,
  39434. lineStyle: {
  39435. width: 'bolder'
  39436. }
  39437. },
  39438. // areaStyle: {
  39439. // origin of areaStyle. Valid values:
  39440. // `'auto'/null/undefined`: from axisLine to data
  39441. // `'start'`: from min to data
  39442. // `'end'`: from data to max
  39443. // origin: 'auto'
  39444. // },
  39445. // false, 'start', 'end', 'middle'
  39446. step: false,
  39447. // Disabled if step is true
  39448. smooth: false,
  39449. smoothMonotone: null,
  39450. symbol: 'emptyCircle',
  39451. symbolSize: 4,
  39452. symbolRotate: null,
  39453. showSymbol: true,
  39454. // `false`: follow the label interval strategy.
  39455. // `true`: show all symbols.
  39456. // `'auto'`: If possible, show all symbols, otherwise
  39457. // follow the label interval strategy.
  39458. showAllSymbol: 'auto',
  39459. // Whether to connect break point.
  39460. connectNulls: false,
  39461. // Sampling for large data. Can be: 'average', 'max', 'min', 'sum', 'lttb'.
  39462. sampling: 'none',
  39463. animationEasing: 'linear',
  39464. // Disable progressive
  39465. progressive: 0,
  39466. hoverLayerThreshold: Infinity
  39467. };
  39468. return LineSeriesModel;
  39469. }(SeriesModel);
  39470. /*
  39471. * Licensed to the Apache Software Foundation (ASF) under one
  39472. * or more contributor license agreements. See the NOTICE file
  39473. * distributed with this work for additional information
  39474. * regarding copyright ownership. The ASF licenses this file
  39475. * to you under the Apache License, Version 2.0 (the
  39476. * "License"); you may not use this file except in compliance
  39477. * with the License. You may obtain a copy of the License at
  39478. *
  39479. * http://www.apache.org/licenses/LICENSE-2.0
  39480. *
  39481. * Unless required by applicable law or agreed to in writing,
  39482. * software distributed under the License is distributed on an
  39483. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39484. * KIND, either express or implied. See the License for the
  39485. * specific language governing permissions and limitations
  39486. * under the License.
  39487. */
  39488. /**
  39489. * AUTO-GENERATED FILE. DO NOT MODIFY.
  39490. */
  39491. /*
  39492. * Licensed to the Apache Software Foundation (ASF) under one
  39493. * or more contributor license agreements. See the NOTICE file
  39494. * distributed with this work for additional information
  39495. * regarding copyright ownership. The ASF licenses this file
  39496. * to you under the Apache License, Version 2.0 (the
  39497. * "License"); you may not use this file except in compliance
  39498. * with the License. You may obtain a copy of the License at
  39499. *
  39500. * http://www.apache.org/licenses/LICENSE-2.0
  39501. *
  39502. * Unless required by applicable law or agreed to in writing,
  39503. * software distributed under the License is distributed on an
  39504. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39505. * KIND, either express or implied. See the License for the
  39506. * specific language governing permissions and limitations
  39507. * under the License.
  39508. */
  39509. var Symbol$1 =
  39510. /** @class */
  39511. function (_super) {
  39512. __extends(Symbol, _super);
  39513. function Symbol(data, idx, seriesScope, opts) {
  39514. var _this = _super.call(this) || this;
  39515. _this.updateData(data, idx, seriesScope, opts);
  39516. return _this;
  39517. }
  39518. Symbol.prototype._createSymbol = function (symbolType, data, idx, symbolSize, keepAspect) {
  39519. // Remove paths created before
  39520. this.removeAll(); // let symbolPath = createSymbol(
  39521. // symbolType, -0.5, -0.5, 1, 1, color
  39522. // );
  39523. // If width/height are set too small (e.g., set to 1) on ios10
  39524. // and macOS Sierra, a circle stroke become a rect, no matter what
  39525. // the scale is set. So we set width/height as 2. See #4150.
  39526. var symbolPath = createSymbol(symbolType, -1, -1, 2, 2, null, keepAspect);
  39527. symbolPath.attr({
  39528. z2: 100,
  39529. culling: true,
  39530. scaleX: symbolSize[0] / 2,
  39531. scaleY: symbolSize[1] / 2
  39532. }); // Rewrite drift method
  39533. symbolPath.drift = driftSymbol;
  39534. this._symbolType = symbolType;
  39535. this.add(symbolPath);
  39536. };
  39537. /**
  39538. * Stop animation
  39539. * @param {boolean} toLastFrame
  39540. */
  39541. Symbol.prototype.stopSymbolAnimation = function (toLastFrame) {
  39542. this.childAt(0).stopAnimation(null, toLastFrame);
  39543. };
  39544. /**
  39545. * FIXME:
  39546. * Caution: This method breaks the encapsulation of this module,
  39547. * but it indeed brings convenience. So do not use the method
  39548. * unless you detailedly know all the implements of `Symbol`,
  39549. * especially animation.
  39550. *
  39551. * Get symbol path element.
  39552. */
  39553. Symbol.prototype.getSymbolPath = function () {
  39554. return this.childAt(0);
  39555. };
  39556. /**
  39557. * Highlight symbol
  39558. */
  39559. Symbol.prototype.highlight = function () {
  39560. enterEmphasis(this.childAt(0));
  39561. };
  39562. /**
  39563. * Downplay symbol
  39564. */
  39565. Symbol.prototype.downplay = function () {
  39566. leaveEmphasis(this.childAt(0));
  39567. };
  39568. /**
  39569. * @param {number} zlevel
  39570. * @param {number} z
  39571. */
  39572. Symbol.prototype.setZ = function (zlevel, z) {
  39573. var symbolPath = this.childAt(0);
  39574. symbolPath.zlevel = zlevel;
  39575. symbolPath.z = z;
  39576. };
  39577. Symbol.prototype.setDraggable = function (draggable) {
  39578. var symbolPath = this.childAt(0);
  39579. symbolPath.draggable = draggable;
  39580. symbolPath.cursor = draggable ? 'move' : symbolPath.cursor;
  39581. };
  39582. /**
  39583. * Update symbol properties
  39584. */
  39585. Symbol.prototype.updateData = function (data, idx, seriesScope, opts) {
  39586. this.silent = false;
  39587. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  39588. var seriesModel = data.hostModel;
  39589. var symbolSize = Symbol.getSymbolSize(data, idx);
  39590. var isInit = symbolType !== this._symbolType;
  39591. var disableAnimation = opts && opts.disableAnimation;
  39592. if (isInit) {
  39593. var keepAspect = data.getItemVisual(idx, 'symbolKeepAspect');
  39594. this._createSymbol(symbolType, data, idx, symbolSize, keepAspect);
  39595. } else {
  39596. var symbolPath = this.childAt(0);
  39597. symbolPath.silent = false;
  39598. var target = {
  39599. scaleX: symbolSize[0] / 2,
  39600. scaleY: symbolSize[1] / 2
  39601. };
  39602. disableAnimation ? symbolPath.attr(target) : updateProps(symbolPath, target, seriesModel, idx);
  39603. }
  39604. this._updateCommon(data, idx, symbolSize, seriesScope, opts);
  39605. if (isInit) {
  39606. var symbolPath = this.childAt(0);
  39607. if (!disableAnimation) {
  39608. var target = {
  39609. scaleX: this._sizeX,
  39610. scaleY: this._sizeY,
  39611. style: {
  39612. // Always fadeIn. Because it has fadeOut animation when symbol is removed..
  39613. opacity: symbolPath.style.opacity
  39614. }
  39615. };
  39616. symbolPath.scaleX = symbolPath.scaleY = 0;
  39617. symbolPath.style.opacity = 0;
  39618. initProps(symbolPath, target, seriesModel, idx);
  39619. }
  39620. }
  39621. if (disableAnimation) {
  39622. // Must stop remove animation manually if don't call initProps or updateProps.
  39623. this.childAt(0).stopAnimation('remove');
  39624. }
  39625. this._seriesModel = seriesModel;
  39626. };
  39627. Symbol.prototype._updateCommon = function (data, idx, symbolSize, seriesScope, opts) {
  39628. var symbolPath = this.childAt(0);
  39629. var seriesModel = data.hostModel;
  39630. var emphasisItemStyle;
  39631. var blurItemStyle;
  39632. var selectItemStyle;
  39633. var focus;
  39634. var blurScope;
  39635. var labelStatesModels;
  39636. var hoverScale;
  39637. var cursorStyle;
  39638. if (seriesScope) {
  39639. emphasisItemStyle = seriesScope.emphasisItemStyle;
  39640. blurItemStyle = seriesScope.blurItemStyle;
  39641. selectItemStyle = seriesScope.selectItemStyle;
  39642. focus = seriesScope.focus;
  39643. blurScope = seriesScope.blurScope;
  39644. labelStatesModels = seriesScope.labelStatesModels;
  39645. hoverScale = seriesScope.hoverScale;
  39646. cursorStyle = seriesScope.cursorStyle;
  39647. }
  39648. if (!seriesScope || data.hasItemOption) {
  39649. var itemModel = seriesScope && seriesScope.itemModel ? seriesScope.itemModel : data.getItemModel(idx);
  39650. var emphasisModel = itemModel.getModel('emphasis');
  39651. emphasisItemStyle = emphasisModel.getModel('itemStyle').getItemStyle();
  39652. selectItemStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();
  39653. blurItemStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
  39654. focus = emphasisModel.get('focus');
  39655. blurScope = emphasisModel.get('blurScope');
  39656. labelStatesModels = getLabelStatesModels(itemModel);
  39657. hoverScale = emphasisModel.getShallow('scale');
  39658. cursorStyle = itemModel.getShallow('cursor');
  39659. }
  39660. var symbolRotate = data.getItemVisual(idx, 'symbolRotate');
  39661. symbolPath.attr('rotation', (symbolRotate || 0) * Math.PI / 180 || 0);
  39662. var symbolOffset = data.getItemVisual(idx, 'symbolOffset') || 0;
  39663. if (symbolOffset) {
  39664. if (!isArray(symbolOffset)) {
  39665. symbolOffset = [symbolOffset, symbolOffset];
  39666. }
  39667. symbolPath.x = parsePercent$1(symbolOffset[0], symbolSize[0]);
  39668. symbolPath.y = parsePercent$1(retrieve2(symbolOffset[1], symbolOffset[0]) || 0, symbolSize[1]);
  39669. }
  39670. cursorStyle && symbolPath.attr('cursor', cursorStyle);
  39671. var symbolStyle = data.getItemVisual(idx, 'style');
  39672. var visualColor = symbolStyle.fill;
  39673. if (symbolPath instanceof ZRImage) {
  39674. var pathStyle = symbolPath.style;
  39675. symbolPath.useStyle(extend({
  39676. // TODO other properties like x, y ?
  39677. image: pathStyle.image,
  39678. x: pathStyle.x,
  39679. y: pathStyle.y,
  39680. width: pathStyle.width,
  39681. height: pathStyle.height
  39682. }, symbolStyle));
  39683. } else {
  39684. if (symbolPath.__isEmptyBrush) {
  39685. // fill and stroke will be swapped if it's empty.
  39686. // So we cloned a new style to avoid it affecting the original style in visual storage.
  39687. // TODO Better implementation. No empty logic!
  39688. symbolPath.useStyle(extend({}, symbolStyle));
  39689. } else {
  39690. symbolPath.useStyle(symbolStyle);
  39691. } // Disable decal because symbol scale will been applied on the decal.
  39692. symbolPath.style.decal = null;
  39693. symbolPath.setColor(visualColor, opts && opts.symbolInnerColor);
  39694. symbolPath.style.strokeNoScale = true;
  39695. }
  39696. var liftZ = data.getItemVisual(idx, 'liftZ');
  39697. var z2Origin = this._z2;
  39698. if (liftZ != null) {
  39699. if (z2Origin == null) {
  39700. this._z2 = symbolPath.z2;
  39701. symbolPath.z2 += liftZ;
  39702. }
  39703. } else if (z2Origin != null) {
  39704. symbolPath.z2 = z2Origin;
  39705. this._z2 = null;
  39706. }
  39707. var useNameLabel = opts && opts.useNameLabel;
  39708. setLabelStyle(symbolPath, labelStatesModels, {
  39709. labelFetcher: seriesModel,
  39710. labelDataIndex: idx,
  39711. defaultText: getLabelDefaultText,
  39712. inheritColor: visualColor,
  39713. defaultOpacity: symbolStyle.opacity
  39714. }); // Do not execute util needed.
  39715. function getLabelDefaultText(idx) {
  39716. return useNameLabel ? data.getName(idx) : getDefaultLabel(data, idx);
  39717. }
  39718. this._sizeX = symbolSize[0] / 2;
  39719. this._sizeY = symbolSize[1] / 2;
  39720. var emphasisState = symbolPath.ensureState('emphasis');
  39721. emphasisState.style = emphasisItemStyle;
  39722. symbolPath.ensureState('select').style = selectItemStyle;
  39723. symbolPath.ensureState('blur').style = blurItemStyle;
  39724. if (hoverScale) {
  39725. var scaleRatio = Math.max(1.1, 3 / this._sizeY);
  39726. emphasisState.scaleX = this._sizeX * scaleRatio;
  39727. emphasisState.scaleY = this._sizeY * scaleRatio;
  39728. }
  39729. this.setSymbolScale(1);
  39730. enableHoverEmphasis(this, focus, blurScope);
  39731. };
  39732. Symbol.prototype.setSymbolScale = function (scale) {
  39733. this.scaleX = this.scaleY = scale;
  39734. };
  39735. Symbol.prototype.fadeOut = function (cb, opt) {
  39736. var symbolPath = this.childAt(0);
  39737. var seriesModel = this._seriesModel;
  39738. var dataIndex = getECData(this).dataIndex;
  39739. var animationOpt = opt && opt.animation; // Avoid mistaken hover when fading out
  39740. this.silent = symbolPath.silent = true; // Not show text when animating
  39741. if (opt && opt.fadeLabel) {
  39742. var textContent = symbolPath.getTextContent();
  39743. if (textContent) {
  39744. removeElement(textContent, {
  39745. style: {
  39746. opacity: 0
  39747. }
  39748. }, seriesModel, {
  39749. dataIndex: dataIndex,
  39750. removeOpt: animationOpt,
  39751. cb: function () {
  39752. symbolPath.removeTextContent();
  39753. }
  39754. });
  39755. }
  39756. } else {
  39757. symbolPath.removeTextContent();
  39758. }
  39759. removeElement(symbolPath, {
  39760. style: {
  39761. opacity: 0
  39762. },
  39763. scaleX: 0,
  39764. scaleY: 0
  39765. }, seriesModel, {
  39766. dataIndex: dataIndex,
  39767. cb: cb,
  39768. removeOpt: animationOpt
  39769. });
  39770. };
  39771. Symbol.getSymbolSize = function (data, idx) {
  39772. var symbolSize = data.getItemVisual(idx, 'symbolSize');
  39773. return isArray(symbolSize) ? symbolSize.slice() : [+symbolSize, +symbolSize];
  39774. };
  39775. return Symbol;
  39776. }(Group);
  39777. function driftSymbol(dx, dy) {
  39778. this.parent.drift(dx, dy);
  39779. }
  39780. /*
  39781. * Licensed to the Apache Software Foundation (ASF) under one
  39782. * or more contributor license agreements. See the NOTICE file
  39783. * distributed with this work for additional information
  39784. * regarding copyright ownership. The ASF licenses this file
  39785. * to you under the Apache License, Version 2.0 (the
  39786. * "License"); you may not use this file except in compliance
  39787. * with the License. You may obtain a copy of the License at
  39788. *
  39789. * http://www.apache.org/licenses/LICENSE-2.0
  39790. *
  39791. * Unless required by applicable law or agreed to in writing,
  39792. * software distributed under the License is distributed on an
  39793. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39794. * KIND, either express or implied. See the License for the
  39795. * specific language governing permissions and limitations
  39796. * under the License.
  39797. */
  39798. /**
  39799. * AUTO-GENERATED FILE. DO NOT MODIFY.
  39800. */
  39801. /*
  39802. * Licensed to the Apache Software Foundation (ASF) under one
  39803. * or more contributor license agreements. See the NOTICE file
  39804. * distributed with this work for additional information
  39805. * regarding copyright ownership. The ASF licenses this file
  39806. * to you under the Apache License, Version 2.0 (the
  39807. * "License"); you may not use this file except in compliance
  39808. * with the License. You may obtain a copy of the License at
  39809. *
  39810. * http://www.apache.org/licenses/LICENSE-2.0
  39811. *
  39812. * Unless required by applicable law or agreed to in writing,
  39813. * software distributed under the License is distributed on an
  39814. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39815. * KIND, either express or implied. See the License for the
  39816. * specific language governing permissions and limitations
  39817. * under the License.
  39818. */
  39819. function symbolNeedsDraw(data, point, idx, opt) {
  39820. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(opt.isIgnore && opt.isIgnore(idx)) // We do not set clipShape on group, because it will cut part of
  39821. // the symbol element shape. We use the same clip shape here as
  39822. // the line clip.
  39823. && !(opt.clipShape && !opt.clipShape.contain(point[0], point[1])) && data.getItemVisual(idx, 'symbol') !== 'none';
  39824. }
  39825. function normalizeUpdateOpt(opt) {
  39826. if (opt != null && !isObject$1(opt)) {
  39827. opt = {
  39828. isIgnore: opt
  39829. };
  39830. }
  39831. return opt || {};
  39832. }
  39833. function makeSeriesScope(data) {
  39834. var seriesModel = data.hostModel;
  39835. var emphasisModel = seriesModel.getModel('emphasis');
  39836. return {
  39837. emphasisItemStyle: emphasisModel.getModel('itemStyle').getItemStyle(),
  39838. blurItemStyle: seriesModel.getModel(['blur', 'itemStyle']).getItemStyle(),
  39839. selectItemStyle: seriesModel.getModel(['select', 'itemStyle']).getItemStyle(),
  39840. focus: emphasisModel.get('focus'),
  39841. blurScope: emphasisModel.get('blurScope'),
  39842. hoverScale: emphasisModel.get('scale'),
  39843. labelStatesModels: getLabelStatesModels(seriesModel),
  39844. cursorStyle: seriesModel.get('cursor')
  39845. };
  39846. }
  39847. var SymbolDraw =
  39848. /** @class */
  39849. function () {
  39850. function SymbolDraw(SymbolCtor) {
  39851. this.group = new Group();
  39852. this._SymbolCtor = SymbolCtor || Symbol$1;
  39853. }
  39854. /**
  39855. * Update symbols draw by new data
  39856. */
  39857. SymbolDraw.prototype.updateData = function (data, opt) {
  39858. opt = normalizeUpdateOpt(opt);
  39859. var group = this.group;
  39860. var seriesModel = data.hostModel;
  39861. var oldData = this._data;
  39862. var SymbolCtor = this._SymbolCtor;
  39863. var disableAnimation = opt.disableAnimation;
  39864. var seriesScope = makeSeriesScope(data);
  39865. var symbolUpdateOpt = {
  39866. disableAnimation: disableAnimation
  39867. };
  39868. var getSymbolPoint = opt.getSymbolPoint || function (idx) {
  39869. return data.getItemLayout(idx);
  39870. }; // There is no oldLineData only when first rendering or switching from
  39871. // stream mode to normal mode, where previous elements should be removed.
  39872. if (!oldData) {
  39873. group.removeAll();
  39874. }
  39875. data.diff(oldData).add(function (newIdx) {
  39876. var point = getSymbolPoint(newIdx);
  39877. if (symbolNeedsDraw(data, point, newIdx, opt)) {
  39878. var symbolEl = new SymbolCtor(data, newIdx, seriesScope, symbolUpdateOpt);
  39879. symbolEl.setPosition(point);
  39880. data.setItemGraphicEl(newIdx, symbolEl);
  39881. group.add(symbolEl);
  39882. }
  39883. }).update(function (newIdx, oldIdx) {
  39884. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  39885. var point = getSymbolPoint(newIdx);
  39886. if (!symbolNeedsDraw(data, point, newIdx, opt)) {
  39887. group.remove(symbolEl);
  39888. return;
  39889. }
  39890. if (!symbolEl) {
  39891. symbolEl = new SymbolCtor(data, newIdx);
  39892. symbolEl.setPosition(point);
  39893. } else {
  39894. symbolEl.updateData(data, newIdx, seriesScope, symbolUpdateOpt);
  39895. var target = {
  39896. x: point[0],
  39897. y: point[1]
  39898. };
  39899. disableAnimation ? symbolEl.attr(target) : updateProps(symbolEl, target, seriesModel);
  39900. } // Add back
  39901. group.add(symbolEl);
  39902. data.setItemGraphicEl(newIdx, symbolEl);
  39903. }).remove(function (oldIdx) {
  39904. var el = oldData.getItemGraphicEl(oldIdx);
  39905. el && el.fadeOut(function () {
  39906. group.remove(el);
  39907. });
  39908. }).execute();
  39909. this._getSymbolPoint = getSymbolPoint;
  39910. this._data = data;
  39911. };
  39912. SymbolDraw.prototype.isPersistent = function () {
  39913. return true;
  39914. };
  39915. SymbolDraw.prototype.updateLayout = function () {
  39916. var _this = this;
  39917. var data = this._data;
  39918. if (data) {
  39919. // Not use animation
  39920. data.eachItemGraphicEl(function (el, idx) {
  39921. var point = _this._getSymbolPoint(idx);
  39922. el.setPosition(point);
  39923. el.markRedraw();
  39924. });
  39925. }
  39926. };
  39927. SymbolDraw.prototype.incrementalPrepareUpdate = function (data) {
  39928. this._seriesScope = makeSeriesScope(data);
  39929. this._data = null;
  39930. this.group.removeAll();
  39931. };
  39932. /**
  39933. * Update symbols draw by new data
  39934. */
  39935. SymbolDraw.prototype.incrementalUpdate = function (taskParams, data, opt) {
  39936. opt = normalizeUpdateOpt(opt);
  39937. function updateIncrementalAndHover(el) {
  39938. if (!el.isGroup) {
  39939. el.incremental = true;
  39940. el.ensureState('emphasis').hoverLayer = true;
  39941. }
  39942. }
  39943. for (var idx = taskParams.start; idx < taskParams.end; idx++) {
  39944. var point = data.getItemLayout(idx);
  39945. if (symbolNeedsDraw(data, point, idx, opt)) {
  39946. var el = new this._SymbolCtor(data, idx, this._seriesScope);
  39947. el.traverse(updateIncrementalAndHover);
  39948. el.setPosition(point);
  39949. this.group.add(el);
  39950. data.setItemGraphicEl(idx, el);
  39951. }
  39952. }
  39953. };
  39954. SymbolDraw.prototype.remove = function (enableAnimation) {
  39955. var group = this.group;
  39956. var data = this._data; // Incremental model do not have this._data.
  39957. if (data && enableAnimation) {
  39958. data.eachItemGraphicEl(function (el) {
  39959. el.fadeOut(function () {
  39960. group.remove(el);
  39961. });
  39962. });
  39963. } else {
  39964. group.removeAll();
  39965. }
  39966. };
  39967. return SymbolDraw;
  39968. }();
  39969. /*
  39970. * Licensed to the Apache Software Foundation (ASF) under one
  39971. * or more contributor license agreements. See the NOTICE file
  39972. * distributed with this work for additional information
  39973. * regarding copyright ownership. The ASF licenses this file
  39974. * to you under the Apache License, Version 2.0 (the
  39975. * "License"); you may not use this file except in compliance
  39976. * with the License. You may obtain a copy of the License at
  39977. *
  39978. * http://www.apache.org/licenses/LICENSE-2.0
  39979. *
  39980. * Unless required by applicable law or agreed to in writing,
  39981. * software distributed under the License is distributed on an
  39982. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  39983. * KIND, either express or implied. See the License for the
  39984. * specific language governing permissions and limitations
  39985. * under the License.
  39986. */
  39987. /**
  39988. * AUTO-GENERATED FILE. DO NOT MODIFY.
  39989. */
  39990. /*
  39991. * Licensed to the Apache Software Foundation (ASF) under one
  39992. * or more contributor license agreements. See the NOTICE file
  39993. * distributed with this work for additional information
  39994. * regarding copyright ownership. The ASF licenses this file
  39995. * to you under the Apache License, Version 2.0 (the
  39996. * "License"); you may not use this file except in compliance
  39997. * with the License. You may obtain a copy of the License at
  39998. *
  39999. * http://www.apache.org/licenses/LICENSE-2.0
  40000. *
  40001. * Unless required by applicable law or agreed to in writing,
  40002. * software distributed under the License is distributed on an
  40003. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40004. * KIND, either express or implied. See the License for the
  40005. * specific language governing permissions and limitations
  40006. * under the License.
  40007. */
  40008. function prepareDataCoordInfo(coordSys, data, valueOrigin) {
  40009. var baseAxis = coordSys.getBaseAxis();
  40010. var valueAxis = coordSys.getOtherAxis(baseAxis);
  40011. var valueStart = getValueStart(valueAxis, valueOrigin);
  40012. var baseAxisDim = baseAxis.dim;
  40013. var valueAxisDim = valueAxis.dim;
  40014. var valueDim = data.mapDimension(valueAxisDim);
  40015. var baseDim = data.mapDimension(baseAxisDim);
  40016. var baseDataOffset = valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0;
  40017. var dims = map(coordSys.dimensions, function (coordDim) {
  40018. return data.mapDimension(coordDim);
  40019. });
  40020. var stacked = false;
  40021. var stackResultDim = data.getCalculationInfo('stackResultDimension');
  40022. if (isDimensionStacked(data, dims[0]
  40023. /*, dims[1]*/
  40024. )) {
  40025. // jshint ignore:line
  40026. stacked = true;
  40027. dims[0] = stackResultDim;
  40028. }
  40029. if (isDimensionStacked(data, dims[1]
  40030. /*, dims[0]*/
  40031. )) {
  40032. // jshint ignore:line
  40033. stacked = true;
  40034. dims[1] = stackResultDim;
  40035. }
  40036. return {
  40037. dataDimsForPoint: dims,
  40038. valueStart: valueStart,
  40039. valueAxisDim: valueAxisDim,
  40040. baseAxisDim: baseAxisDim,
  40041. stacked: !!stacked,
  40042. valueDim: valueDim,
  40043. baseDim: baseDim,
  40044. baseDataOffset: baseDataOffset,
  40045. stackedOverDimension: data.getCalculationInfo('stackedOverDimension')
  40046. };
  40047. }
  40048. function getValueStart(valueAxis, valueOrigin) {
  40049. var valueStart = 0;
  40050. var extent = valueAxis.scale.getExtent();
  40051. if (valueOrigin === 'start') {
  40052. valueStart = extent[0];
  40053. } else if (valueOrigin === 'end') {
  40054. valueStart = extent[1];
  40055. } // auto
  40056. else {
  40057. // Both positive
  40058. if (extent[0] > 0) {
  40059. valueStart = extent[0];
  40060. } // Both negative
  40061. else if (extent[1] < 0) {
  40062. valueStart = extent[1];
  40063. } // If is one positive, and one negative, onZero shall be true
  40064. }
  40065. return valueStart;
  40066. }
  40067. function getStackedOnPoint(dataCoordInfo, coordSys, data, idx) {
  40068. var value = NaN;
  40069. if (dataCoordInfo.stacked) {
  40070. value = data.get(data.getCalculationInfo('stackedOverDimension'), idx);
  40071. }
  40072. if (isNaN(value)) {
  40073. value = dataCoordInfo.valueStart;
  40074. }
  40075. var baseDataOffset = dataCoordInfo.baseDataOffset;
  40076. var stackedData = [];
  40077. stackedData[baseDataOffset] = data.get(dataCoordInfo.baseDim, idx);
  40078. stackedData[1 - baseDataOffset] = value;
  40079. return coordSys.dataToPoint(stackedData);
  40080. }
  40081. /*
  40082. * Licensed to the Apache Software Foundation (ASF) under one
  40083. * or more contributor license agreements. See the NOTICE file
  40084. * distributed with this work for additional information
  40085. * regarding copyright ownership. The ASF licenses this file
  40086. * to you under the Apache License, Version 2.0 (the
  40087. * "License"); you may not use this file except in compliance
  40088. * with the License. You may obtain a copy of the License at
  40089. *
  40090. * http://www.apache.org/licenses/LICENSE-2.0
  40091. *
  40092. * Unless required by applicable law or agreed to in writing,
  40093. * software distributed under the License is distributed on an
  40094. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40095. * KIND, either express or implied. See the License for the
  40096. * specific language governing permissions and limitations
  40097. * under the License.
  40098. */
  40099. /**
  40100. * AUTO-GENERATED FILE. DO NOT MODIFY.
  40101. */
  40102. /*
  40103. * Licensed to the Apache Software Foundation (ASF) under one
  40104. * or more contributor license agreements. See the NOTICE file
  40105. * distributed with this work for additional information
  40106. * regarding copyright ownership. The ASF licenses this file
  40107. * to you under the Apache License, Version 2.0 (the
  40108. * "License"); you may not use this file except in compliance
  40109. * with the License. You may obtain a copy of the License at
  40110. *
  40111. * http://www.apache.org/licenses/LICENSE-2.0
  40112. *
  40113. * Unless required by applicable law or agreed to in writing,
  40114. * software distributed under the License is distributed on an
  40115. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40116. * KIND, either express or implied. See the License for the
  40117. * specific language governing permissions and limitations
  40118. * under the License.
  40119. */
  40120. /* global Float32Array */
  40121. var supportFloat32Array = typeof Float32Array !== 'undefined';
  40122. var Float32ArrayCtor = !supportFloat32Array ? Array : Float32Array;
  40123. function createFloat32Array(arg) {
  40124. if (isArray(arg)) {
  40125. // Return self directly if don't support TypedArray.
  40126. return supportFloat32Array ? new Float32Array(arg) : arg;
  40127. } // Else is number
  40128. return new Float32ArrayCtor(arg);
  40129. }
  40130. /*
  40131. * Licensed to the Apache Software Foundation (ASF) under one
  40132. * or more contributor license agreements. See the NOTICE file
  40133. * distributed with this work for additional information
  40134. * regarding copyright ownership. The ASF licenses this file
  40135. * to you under the Apache License, Version 2.0 (the
  40136. * "License"); you may not use this file except in compliance
  40137. * with the License. You may obtain a copy of the License at
  40138. *
  40139. * http://www.apache.org/licenses/LICENSE-2.0
  40140. *
  40141. * Unless required by applicable law or agreed to in writing,
  40142. * software distributed under the License is distributed on an
  40143. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40144. * KIND, either express or implied. See the License for the
  40145. * specific language governing permissions and limitations
  40146. * under the License.
  40147. */
  40148. /**
  40149. * AUTO-GENERATED FILE. DO NOT MODIFY.
  40150. */
  40151. /*
  40152. * Licensed to the Apache Software Foundation (ASF) under one
  40153. * or more contributor license agreements. See the NOTICE file
  40154. * distributed with this work for additional information
  40155. * regarding copyright ownership. The ASF licenses this file
  40156. * to you under the Apache License, Version 2.0 (the
  40157. * "License"); you may not use this file except in compliance
  40158. * with the License. You may obtain a copy of the License at
  40159. *
  40160. * http://www.apache.org/licenses/LICENSE-2.0
  40161. *
  40162. * Unless required by applicable law or agreed to in writing,
  40163. * software distributed under the License is distributed on an
  40164. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40165. * KIND, either express or implied. See the License for the
  40166. * specific language governing permissions and limitations
  40167. * under the License.
  40168. */
  40169. function diffData(oldData, newData) {
  40170. var diffResult = [];
  40171. newData.diff(oldData).add(function (idx) {
  40172. diffResult.push({
  40173. cmd: '+',
  40174. idx: idx
  40175. });
  40176. }).update(function (newIdx, oldIdx) {
  40177. diffResult.push({
  40178. cmd: '=',
  40179. idx: oldIdx,
  40180. idx1: newIdx
  40181. });
  40182. }).remove(function (idx) {
  40183. diffResult.push({
  40184. cmd: '-',
  40185. idx: idx
  40186. });
  40187. }).execute();
  40188. return diffResult;
  40189. }
  40190. function lineAnimationDiff(oldData, newData, oldStackedOnPoints, newStackedOnPoints, oldCoordSys, newCoordSys, oldValueOrigin, newValueOrigin) {
  40191. var diff = diffData(oldData, newData); // let newIdList = newData.mapArray(newData.getId);
  40192. // let oldIdList = oldData.mapArray(oldData.getId);
  40193. // convertToIntId(newIdList, oldIdList);
  40194. // // FIXME One data ?
  40195. // diff = arrayDiff(oldIdList, newIdList);
  40196. var currPoints = [];
  40197. var nextPoints = []; // Points for stacking base line
  40198. var currStackedPoints = [];
  40199. var nextStackedPoints = [];
  40200. var status = [];
  40201. var sortedIndices = [];
  40202. var rawIndices = [];
  40203. var newDataOldCoordInfo = prepareDataCoordInfo(oldCoordSys, newData, oldValueOrigin);
  40204. var oldDataNewCoordInfo = prepareDataCoordInfo(newCoordSys, oldData, newValueOrigin);
  40205. var oldPoints = oldData.getLayout('points') || [];
  40206. var newPoints = newData.getLayout('points') || [];
  40207. for (var i = 0; i < diff.length; i++) {
  40208. var diffItem = diff[i];
  40209. var pointAdded = true;
  40210. var oldIdx2 = void 0;
  40211. var newIdx2 = void 0; // FIXME, animation is not so perfect when dataZoom window moves fast
  40212. // Which is in case remvoing or add more than one data in the tail or head
  40213. switch (diffItem.cmd) {
  40214. case '=':
  40215. oldIdx2 = diffItem.idx * 2;
  40216. newIdx2 = diffItem.idx1 * 2;
  40217. var currentX = oldPoints[oldIdx2];
  40218. var currentY = oldPoints[oldIdx2 + 1];
  40219. var nextX = newPoints[newIdx2];
  40220. var nextY = newPoints[newIdx2 + 1]; // If previous data is NaN, use next point directly
  40221. if (isNaN(currentX) || isNaN(currentY)) {
  40222. currentX = nextX;
  40223. currentY = nextY;
  40224. }
  40225. currPoints.push(currentX, currentY);
  40226. nextPoints.push(nextX, nextY);
  40227. currStackedPoints.push(oldStackedOnPoints[oldIdx2], oldStackedOnPoints[oldIdx2 + 1]);
  40228. nextStackedPoints.push(newStackedOnPoints[newIdx2], newStackedOnPoints[newIdx2 + 1]);
  40229. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  40230. break;
  40231. case '+':
  40232. var newIdx = diffItem.idx;
  40233. var newDataDimsForPoint = newDataOldCoordInfo.dataDimsForPoint;
  40234. var oldPt = oldCoordSys.dataToPoint([newData.get(newDataDimsForPoint[0], newIdx), newData.get(newDataDimsForPoint[1], newIdx)]);
  40235. newIdx2 = newIdx * 2;
  40236. currPoints.push(oldPt[0], oldPt[1]);
  40237. nextPoints.push(newPoints[newIdx2], newPoints[newIdx2 + 1]);
  40238. var stackedOnPoint = getStackedOnPoint(newDataOldCoordInfo, oldCoordSys, newData, newIdx);
  40239. currStackedPoints.push(stackedOnPoint[0], stackedOnPoint[1]);
  40240. nextStackedPoints.push(newStackedOnPoints[newIdx2], newStackedOnPoints[newIdx2 + 1]);
  40241. rawIndices.push(newData.getRawIndex(newIdx));
  40242. break;
  40243. case '-':
  40244. pointAdded = false;
  40245. } // Original indices
  40246. if (pointAdded) {
  40247. status.push(diffItem);
  40248. sortedIndices.push(sortedIndices.length);
  40249. }
  40250. } // Diff result may be crossed if all items are changed
  40251. // Sort by data index
  40252. sortedIndices.sort(function (a, b) {
  40253. return rawIndices[a] - rawIndices[b];
  40254. });
  40255. var len = currPoints.length;
  40256. var sortedCurrPoints = createFloat32Array(len);
  40257. var sortedNextPoints = createFloat32Array(len);
  40258. var sortedCurrStackedPoints = createFloat32Array(len);
  40259. var sortedNextStackedPoints = createFloat32Array(len);
  40260. var sortedStatus = [];
  40261. for (var i = 0; i < sortedIndices.length; i++) {
  40262. var idx = sortedIndices[i];
  40263. var i2 = i * 2;
  40264. var idx2 = idx * 2;
  40265. sortedCurrPoints[i2] = currPoints[idx2];
  40266. sortedCurrPoints[i2 + 1] = currPoints[idx2 + 1];
  40267. sortedNextPoints[i2] = nextPoints[idx2];
  40268. sortedNextPoints[i2 + 1] = nextPoints[idx2 + 1];
  40269. sortedCurrStackedPoints[i2] = currStackedPoints[idx2];
  40270. sortedCurrStackedPoints[i2 + 1] = currStackedPoints[idx2 + 1];
  40271. sortedNextStackedPoints[i2] = nextStackedPoints[idx2];
  40272. sortedNextStackedPoints[i2 + 1] = nextStackedPoints[idx2 + 1];
  40273. sortedStatus[i] = status[idx];
  40274. }
  40275. return {
  40276. current: sortedCurrPoints,
  40277. next: sortedNextPoints,
  40278. stackedOnCurrent: sortedCurrStackedPoints,
  40279. stackedOnNext: sortedNextStackedPoints,
  40280. status: sortedStatus
  40281. };
  40282. }
  40283. /*
  40284. * Licensed to the Apache Software Foundation (ASF) under one
  40285. * or more contributor license agreements. See the NOTICE file
  40286. * distributed with this work for additional information
  40287. * regarding copyright ownership. The ASF licenses this file
  40288. * to you under the Apache License, Version 2.0 (the
  40289. * "License"); you may not use this file except in compliance
  40290. * with the License. You may obtain a copy of the License at
  40291. *
  40292. * http://www.apache.org/licenses/LICENSE-2.0
  40293. *
  40294. * Unless required by applicable law or agreed to in writing,
  40295. * software distributed under the License is distributed on an
  40296. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40297. * KIND, either express or implied. See the License for the
  40298. * specific language governing permissions and limitations
  40299. * under the License.
  40300. */
  40301. /**
  40302. * AUTO-GENERATED FILE. DO NOT MODIFY.
  40303. */
  40304. /*
  40305. * Licensed to the Apache Software Foundation (ASF) under one
  40306. * or more contributor license agreements. See the NOTICE file
  40307. * distributed with this work for additional information
  40308. * regarding copyright ownership. The ASF licenses this file
  40309. * to you under the Apache License, Version 2.0 (the
  40310. * "License"); you may not use this file except in compliance
  40311. * with the License. You may obtain a copy of the License at
  40312. *
  40313. * http://www.apache.org/licenses/LICENSE-2.0
  40314. *
  40315. * Unless required by applicable law or agreed to in writing,
  40316. * software distributed under the License is distributed on an
  40317. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40318. * KIND, either express or implied. See the License for the
  40319. * specific language governing permissions and limitations
  40320. * under the License.
  40321. */
  40322. var mathMin$6 = Math.min;
  40323. var mathMax$6 = Math.max;
  40324. function isPointNull$1(x, y) {
  40325. return isNaN(x) || isNaN(y);
  40326. }
  40327. /**
  40328. * Draw smoothed line in non-monotone, in may cause undesired curve in extreme
  40329. * situations. This should be used when points are non-monotone neither in x or
  40330. * y dimension.
  40331. */
  40332. function drawSegment(ctx, points, start, segLen, allLen, dir, smooth, smoothMonotone, connectNulls) {
  40333. var prevX;
  40334. var prevY;
  40335. var cpx0;
  40336. var cpy0;
  40337. var cpx1;
  40338. var cpy1;
  40339. var idx = start;
  40340. var k = 0;
  40341. for (; k < segLen; k++) {
  40342. var x = points[idx * 2];
  40343. var y = points[idx * 2 + 1];
  40344. if (idx >= allLen || idx < 0) {
  40345. break;
  40346. }
  40347. if (isPointNull$1(x, y)) {
  40348. if (connectNulls) {
  40349. idx += dir;
  40350. continue;
  40351. }
  40352. break;
  40353. }
  40354. if (idx === start) {
  40355. ctx[dir > 0 ? 'moveTo' : 'lineTo'](x, y);
  40356. cpx0 = x;
  40357. cpy0 = y;
  40358. } else {
  40359. var dx = x - prevX;
  40360. var dy = y - prevY; // Ignore tiny segment.
  40361. if (dx * dx + dy * dy < 0.5) {
  40362. idx += dir;
  40363. continue;
  40364. }
  40365. if (smooth > 0) {
  40366. var nextIdx = idx + dir;
  40367. var nextX = points[nextIdx * 2];
  40368. var nextY = points[nextIdx * 2 + 1];
  40369. var tmpK = k + 1;
  40370. if (connectNulls) {
  40371. // Find next point not null
  40372. while (isPointNull$1(nextX, nextY) && tmpK < segLen) {
  40373. tmpK++;
  40374. nextIdx += dir;
  40375. nextX = points[nextIdx * 2];
  40376. nextY = points[nextIdx * 2 + 1];
  40377. }
  40378. }
  40379. var ratioNextSeg = 0.5;
  40380. var vx = 0;
  40381. var vy = 0;
  40382. var nextCpx0 = void 0;
  40383. var nextCpy0 = void 0; // Is last point
  40384. if (tmpK >= segLen || isPointNull$1(nextX, nextY)) {
  40385. cpx1 = x;
  40386. cpy1 = y;
  40387. } else {
  40388. vx = nextX - prevX;
  40389. vy = nextY - prevY;
  40390. var dx0 = x - prevX;
  40391. var dx1 = nextX - x;
  40392. var dy0 = y - prevY;
  40393. var dy1 = nextY - y;
  40394. var lenPrevSeg = void 0;
  40395. var lenNextSeg = void 0;
  40396. if (smoothMonotone === 'x') {
  40397. lenPrevSeg = Math.abs(dx0);
  40398. lenNextSeg = Math.abs(dx1);
  40399. cpx1 = x - lenPrevSeg * smooth;
  40400. cpy1 = y;
  40401. nextCpx0 = x + lenPrevSeg * smooth;
  40402. nextCpy0 = y;
  40403. } else if (smoothMonotone === 'y') {
  40404. lenPrevSeg = Math.abs(dy0);
  40405. lenNextSeg = Math.abs(dy1);
  40406. cpx1 = x;
  40407. cpy1 = y - lenPrevSeg * smooth;
  40408. nextCpx0 = x;
  40409. nextCpy0 = y + lenPrevSeg * smooth;
  40410. } else {
  40411. lenPrevSeg = Math.sqrt(dx0 * dx0 + dy0 * dy0);
  40412. lenNextSeg = Math.sqrt(dx1 * dx1 + dy1 * dy1); // Use ratio of seg length
  40413. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  40414. cpx1 = x - vx * smooth * (1 - ratioNextSeg);
  40415. cpy1 = y - vy * smooth * (1 - ratioNextSeg); // cp0 of next segment
  40416. nextCpx0 = x + vx * smooth * ratioNextSeg;
  40417. nextCpy0 = y + vy * smooth * ratioNextSeg; // Smooth constraint between point and next point.
  40418. // Avoid exceeding extreme after smoothing.
  40419. nextCpx0 = mathMin$6(nextCpx0, mathMax$6(nextX, x));
  40420. nextCpy0 = mathMin$6(nextCpy0, mathMax$6(nextY, y));
  40421. nextCpx0 = mathMax$6(nextCpx0, mathMin$6(nextX, x));
  40422. nextCpy0 = mathMax$6(nextCpy0, mathMin$6(nextY, y)); // Reclaculate cp1 based on the adjusted cp0 of next seg.
  40423. vx = nextCpx0 - x;
  40424. vy = nextCpy0 - y;
  40425. cpx1 = x - vx * lenPrevSeg / lenNextSeg;
  40426. cpy1 = y - vy * lenPrevSeg / lenNextSeg; // Smooth constraint between point and prev point.
  40427. // Avoid exceeding extreme after smoothing.
  40428. cpx1 = mathMin$6(cpx1, mathMax$6(prevX, x));
  40429. cpy1 = mathMin$6(cpy1, mathMax$6(prevY, y));
  40430. cpx1 = mathMax$6(cpx1, mathMin$6(prevX, x));
  40431. cpy1 = mathMax$6(cpy1, mathMin$6(prevY, y)); // Adjust next cp0 again.
  40432. vx = x - cpx1;
  40433. vy = y - cpy1;
  40434. nextCpx0 = x + vx * lenNextSeg / lenPrevSeg;
  40435. nextCpy0 = y + vy * lenNextSeg / lenPrevSeg;
  40436. }
  40437. }
  40438. ctx.bezierCurveTo(cpx0, cpy0, cpx1, cpy1, x, y);
  40439. cpx0 = nextCpx0;
  40440. cpy0 = nextCpy0;
  40441. } else {
  40442. ctx.lineTo(x, y);
  40443. }
  40444. }
  40445. prevX = x;
  40446. prevY = y;
  40447. idx += dir;
  40448. }
  40449. return k;
  40450. }
  40451. var ECPolylineShape =
  40452. /** @class */
  40453. function () {
  40454. function ECPolylineShape() {
  40455. this.smooth = 0;
  40456. this.smoothConstraint = true;
  40457. }
  40458. return ECPolylineShape;
  40459. }();
  40460. var ECPolyline =
  40461. /** @class */
  40462. function (_super) {
  40463. __extends(ECPolyline, _super);
  40464. function ECPolyline(opts) {
  40465. var _this = _super.call(this, opts) || this;
  40466. _this.type = 'ec-polyline';
  40467. return _this;
  40468. }
  40469. ECPolyline.prototype.getDefaultStyle = function () {
  40470. return {
  40471. stroke: '#000',
  40472. fill: null
  40473. };
  40474. };
  40475. ECPolyline.prototype.getDefaultShape = function () {
  40476. return new ECPolylineShape();
  40477. };
  40478. ECPolyline.prototype.buildPath = function (ctx, shape) {
  40479. var points = shape.points;
  40480. var i = 0;
  40481. var len = points.length / 2; // const result = getBoundingBox(points, shape.smoothConstraint);
  40482. if (shape.connectNulls) {
  40483. // Must remove first and last null values avoid draw error in polygon
  40484. for (; len > 0; len--) {
  40485. if (!isPointNull$1(points[len * 2 - 2], points[len * 2 - 1])) {
  40486. break;
  40487. }
  40488. }
  40489. for (; i < len; i++) {
  40490. if (!isPointNull$1(points[i * 2], points[i * 2 + 1])) {
  40491. break;
  40492. }
  40493. }
  40494. }
  40495. while (i < len) {
  40496. i += drawSegment(ctx, points, i, len, len, 1, shape.smooth, shape.smoothMonotone, shape.connectNulls) + 1;
  40497. }
  40498. };
  40499. ECPolyline.prototype.getPointOn = function (xOrY, dim) {
  40500. if (!this.path) {
  40501. this.createPathProxy();
  40502. this.buildPath(this.path, this.shape);
  40503. }
  40504. var path = this.path;
  40505. var data = path.data;
  40506. var CMD = PathProxy.CMD;
  40507. var x0;
  40508. var y0;
  40509. var isDimX = dim === 'x';
  40510. var roots = [];
  40511. for (var i = 0; i < data.length;) {
  40512. var cmd = data[i++];
  40513. var x = void 0;
  40514. var y = void 0;
  40515. var x2 = void 0;
  40516. var y2 = void 0;
  40517. var x3 = void 0;
  40518. var y3 = void 0;
  40519. var t = void 0;
  40520. switch (cmd) {
  40521. case CMD.M:
  40522. x0 = data[i++];
  40523. y0 = data[i++];
  40524. break;
  40525. case CMD.L:
  40526. x = data[i++];
  40527. y = data[i++];
  40528. t = isDimX ? (xOrY - x0) / (x - x0) : (xOrY - y0) / (y - y0);
  40529. if (t <= 1 && t >= 0) {
  40530. var val = isDimX ? (y - y0) * t + y0 : (x - x0) * t + x0;
  40531. return isDimX ? [xOrY, val] : [val, xOrY];
  40532. }
  40533. x0 = x;
  40534. y0 = y;
  40535. break;
  40536. case CMD.C:
  40537. x = data[i++];
  40538. y = data[i++];
  40539. x2 = data[i++];
  40540. y2 = data[i++];
  40541. x3 = data[i++];
  40542. y3 = data[i++];
  40543. var nRoot = isDimX ? cubicRootAt(x0, x, x2, x3, xOrY, roots) : cubicRootAt(y0, y, y2, y3, xOrY, roots);
  40544. if (nRoot > 0) {
  40545. for (var i_1 = 0; i_1 < nRoot; i_1++) {
  40546. var t_1 = roots[i_1];
  40547. if (t_1 <= 1 && t_1 >= 0) {
  40548. var val = isDimX ? cubicAt(y0, y, y2, y3, t_1) : cubicAt(x0, x, x2, x3, t_1);
  40549. return isDimX ? [xOrY, val] : [val, xOrY];
  40550. }
  40551. }
  40552. }
  40553. x0 = x3;
  40554. y0 = y3;
  40555. break;
  40556. }
  40557. }
  40558. };
  40559. return ECPolyline;
  40560. }(Path);
  40561. var ECPolygonShape =
  40562. /** @class */
  40563. function (_super) {
  40564. __extends(ECPolygonShape, _super);
  40565. function ECPolygonShape() {
  40566. return _super !== null && _super.apply(this, arguments) || this;
  40567. }
  40568. return ECPolygonShape;
  40569. }(ECPolylineShape);
  40570. var ECPolygon =
  40571. /** @class */
  40572. function (_super) {
  40573. __extends(ECPolygon, _super);
  40574. function ECPolygon(opts) {
  40575. var _this = _super.call(this, opts) || this;
  40576. _this.type = 'ec-polygon';
  40577. return _this;
  40578. }
  40579. ECPolygon.prototype.getDefaultShape = function () {
  40580. return new ECPolygonShape();
  40581. };
  40582. ECPolygon.prototype.buildPath = function (ctx, shape) {
  40583. var points = shape.points;
  40584. var stackedOnPoints = shape.stackedOnPoints;
  40585. var i = 0;
  40586. var len = points.length / 2;
  40587. var smoothMonotone = shape.smoothMonotone;
  40588. if (shape.connectNulls) {
  40589. // Must remove first and last null values avoid draw error in polygon
  40590. for (; len > 0; len--) {
  40591. if (!isPointNull$1(points[len * 2 - 2], points[len * 2 - 1])) {
  40592. break;
  40593. }
  40594. }
  40595. for (; i < len; i++) {
  40596. if (!isPointNull$1(points[i * 2], points[i * 2 + 1])) {
  40597. break;
  40598. }
  40599. }
  40600. }
  40601. while (i < len) {
  40602. var k = drawSegment(ctx, points, i, len, len, 1, shape.smooth, smoothMonotone, shape.connectNulls);
  40603. drawSegment(ctx, stackedOnPoints, i + k - 1, k, len, -1, shape.stackedOnSmooth, smoothMonotone, shape.connectNulls);
  40604. i += k + 1;
  40605. ctx.closePath();
  40606. }
  40607. };
  40608. return ECPolygon;
  40609. }(Path);
  40610. /*
  40611. * Licensed to the Apache Software Foundation (ASF) under one
  40612. * or more contributor license agreements. See the NOTICE file
  40613. * distributed with this work for additional information
  40614. * regarding copyright ownership. The ASF licenses this file
  40615. * to you under the Apache License, Version 2.0 (the
  40616. * "License"); you may not use this file except in compliance
  40617. * with the License. You may obtain a copy of the License at
  40618. *
  40619. * http://www.apache.org/licenses/LICENSE-2.0
  40620. *
  40621. * Unless required by applicable law or agreed to in writing,
  40622. * software distributed under the License is distributed on an
  40623. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40624. * KIND, either express or implied. See the License for the
  40625. * specific language governing permissions and limitations
  40626. * under the License.
  40627. */
  40628. /**
  40629. * AUTO-GENERATED FILE. DO NOT MODIFY.
  40630. */
  40631. /*
  40632. * Licensed to the Apache Software Foundation (ASF) under one
  40633. * or more contributor license agreements. See the NOTICE file
  40634. * distributed with this work for additional information
  40635. * regarding copyright ownership. The ASF licenses this file
  40636. * to you under the Apache License, Version 2.0 (the
  40637. * "License"); you may not use this file except in compliance
  40638. * with the License. You may obtain a copy of the License at
  40639. *
  40640. * http://www.apache.org/licenses/LICENSE-2.0
  40641. *
  40642. * Unless required by applicable law or agreed to in writing,
  40643. * software distributed under the License is distributed on an
  40644. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  40645. * KIND, either express or implied. See the License for the
  40646. * specific language governing permissions and limitations
  40647. * under the License.
  40648. */
  40649. function isPointsSame(points1, points2) {
  40650. if (points1.length !== points2.length) {
  40651. return;
  40652. }
  40653. for (var i = 0; i < points1.length; i++) {
  40654. if (points1[i] !== points2[i]) {
  40655. return;
  40656. }
  40657. }
  40658. return true;
  40659. }
  40660. function bboxFromPoints(points) {
  40661. var minX = Infinity;
  40662. var minY = Infinity;
  40663. var maxX = -Infinity;
  40664. var maxY = -Infinity;
  40665. for (var i = 0; i < points.length;) {
  40666. var x = points[i++];
  40667. var y = points[i++];
  40668. if (!isNaN(x)) {
  40669. minX = Math.min(x, minX);
  40670. maxX = Math.max(x, maxX);
  40671. }
  40672. if (!isNaN(y)) {
  40673. minY = Math.min(y, minY);
  40674. maxY = Math.max(y, maxY);
  40675. }
  40676. }
  40677. return [[minX, minY], [maxX, maxY]];
  40678. }
  40679. function getBoundingDiff(points1, points2) {
  40680. var _a = bboxFromPoints(points1),
  40681. min1 = _a[0],
  40682. max1 = _a[1];
  40683. var _b = bboxFromPoints(points2),
  40684. min2 = _b[0],
  40685. max2 = _b[1]; // Get a max value from each corner of two boundings.
  40686. return Math.max(Math.abs(min1[0] - min2[0]), Math.abs(min1[1] - min2[1]), Math.abs(max1[0] - max2[0]), Math.abs(max1[1] - max2[1]));
  40687. }
  40688. function getSmooth(smooth) {
  40689. return typeof smooth === 'number' ? smooth : smooth ? 0.5 : 0;
  40690. }
  40691. function getStackedOnPoints(coordSys, data, dataCoordInfo) {
  40692. if (!dataCoordInfo.valueDim) {
  40693. return [];
  40694. }
  40695. var len = data.count();
  40696. var points = createFloat32Array(len * 2);
  40697. for (var idx = 0; idx < len; idx++) {
  40698. var pt = getStackedOnPoint(dataCoordInfo, coordSys, data, idx);
  40699. points[idx * 2] = pt[0];
  40700. points[idx * 2 + 1] = pt[1];
  40701. }
  40702. return points;
  40703. }
  40704. function turnPointsIntoStep(points, coordSys, stepTurnAt) {
  40705. var baseAxis = coordSys.getBaseAxis();
  40706. var baseIndex = baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1;
  40707. var stepPoints = [];
  40708. var i = 0;
  40709. var stepPt = [];
  40710. var pt = [];
  40711. var nextPt = [];
  40712. for (; i < points.length - 2; i += 2) {
  40713. nextPt[0] = points[i + 2];
  40714. nextPt[1] = points[i + 3];
  40715. pt[0] = points[i];
  40716. pt[1] = points[i + 1];
  40717. stepPoints.push(pt[0], pt[1]);
  40718. switch (stepTurnAt) {
  40719. case 'end':
  40720. stepPt[baseIndex] = nextPt[baseIndex];
  40721. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  40722. stepPoints.push(stepPt[0], stepPt[1]);
  40723. break;
  40724. case 'middle':
  40725. var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2;
  40726. var stepPt2 = [];
  40727. stepPt[baseIndex] = stepPt2[baseIndex] = middle;
  40728. stepPt[1 - baseIndex] = pt[1 - baseIndex];
  40729. stepPt2[1 - baseIndex] = nextPt[1 - baseIndex];
  40730. stepPoints.push(stepPt[0], stepPt[1]);
  40731. stepPoints.push(stepPt2[0], stepPt2[1]);
  40732. break;
  40733. default:
  40734. // default is start
  40735. stepPt[baseIndex] = pt[baseIndex];
  40736. stepPt[1 - baseIndex] = nextPt[1 - baseIndex];
  40737. stepPoints.push(stepPt[0], stepPt[1]);
  40738. }
  40739. } // Last points
  40740. stepPoints.push(points[i++], points[i++]);
  40741. return stepPoints;
  40742. }
  40743. function getVisualGradient(data, coordSys) {
  40744. var visualMetaList = data.getVisual('visualMeta');
  40745. if (!visualMetaList || !visualMetaList.length || !data.count()) {
  40746. // When data.count() is 0, gradient range can not be calculated.
  40747. return;
  40748. }
  40749. if (coordSys.type !== 'cartesian2d') {
  40750. {
  40751. console.warn('Visual map on line style is only supported on cartesian2d.');
  40752. }
  40753. return;
  40754. }
  40755. var coordDim;
  40756. var visualMeta;
  40757. for (var i = visualMetaList.length - 1; i >= 0; i--) {
  40758. var dimIndex = visualMetaList[i].dimension;
  40759. var dimName = data.dimensions[dimIndex];
  40760. var dimInfo = data.getDimensionInfo(dimName);
  40761. coordDim = dimInfo && dimInfo.coordDim; // Can only be x or y
  40762. if (coordDim === 'x' || coordDim === 'y') {
  40763. visualMeta = visualMetaList[i];
  40764. break;
  40765. }
  40766. }
  40767. if (!visualMeta) {
  40768. {
  40769. console.warn('Visual map on line style only support x or y dimension.');
  40770. }
  40771. return;
  40772. } // If the area to be rendered is bigger than area defined by LinearGradient,
  40773. // the canvas spec prescribes that the color of the first stop and the last
  40774. // stop should be used. But if two stops are added at offset 0, in effect
  40775. // browsers use the color of the second stop to render area outside
  40776. // LinearGradient. So we can only infinitesimally extend area defined in
  40777. // LinearGradient to render `outerColors`.
  40778. var axis = coordSys.getAxis(coordDim); // dataToCoor mapping may not be linear, but must be monotonic.
  40779. var colorStops = map(visualMeta.stops, function (stop) {
  40780. return {
  40781. offset: 0,
  40782. coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)),
  40783. color: stop.color
  40784. };
  40785. });
  40786. var stopLen = colorStops.length;
  40787. var outerColors = visualMeta.outerColors.slice();
  40788. if (stopLen && colorStops[0].coord > colorStops[stopLen - 1].coord) {
  40789. colorStops.reverse();
  40790. outerColors.reverse();
  40791. }
  40792. var tinyExtent = 10; // Arbitrary value: 10px
  40793. var minCoord = colorStops[0].coord - tinyExtent;
  40794. var maxCoord = colorStops[stopLen - 1].coord + tinyExtent;
  40795. var coordSpan = maxCoord - minCoord;
  40796. if (coordSpan < 1e-3) {
  40797. return 'transparent';
  40798. }
  40799. each$1(colorStops, function (stop) {
  40800. stop.offset = (stop.coord - minCoord) / coordSpan;
  40801. });
  40802. colorStops.push({
  40803. offset: stopLen ? colorStops[stopLen - 1].offset : 0.5,
  40804. color: outerColors[1] || 'transparent'
  40805. });
  40806. colorStops.unshift({
  40807. offset: stopLen ? colorStops[0].offset : 0.5,
  40808. color: outerColors[0] || 'transparent'
  40809. }); // zrUtil.each(colorStops, function (colorStop) {
  40810. // // Make sure each offset has rounded px to avoid not sharp edge
  40811. // colorStop.offset = (Math.round(colorStop.offset * (end - start) + start) - start) / (end - start);
  40812. // });
  40813. var gradient = new LinearGradient(0, 0, 0, 0, colorStops, true);
  40814. gradient[coordDim] = minCoord;
  40815. gradient[coordDim + '2'] = maxCoord;
  40816. return gradient;
  40817. }
  40818. function getIsIgnoreFunc(seriesModel, data, coordSys) {
  40819. var showAllSymbol = seriesModel.get('showAllSymbol');
  40820. var isAuto = showAllSymbol === 'auto';
  40821. if (showAllSymbol && !isAuto) {
  40822. return;
  40823. }
  40824. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  40825. if (!categoryAxis) {
  40826. return;
  40827. } // Note that category label interval strategy might bring some weird effect
  40828. // in some scenario: users may wonder why some of the symbols are not
  40829. // displayed. So we show all symbols as possible as we can.
  40830. if (isAuto // Simplify the logic, do not determine label overlap here.
  40831. && canShowAllSymbolForCategory(categoryAxis, data)) {
  40832. return;
  40833. } // Otherwise follow the label interval strategy on category axis.
  40834. var categoryDataDim = data.mapDimension(categoryAxis.dim);
  40835. var labelMap = {};
  40836. each$1(categoryAxis.getViewLabels(), function (labelItem) {
  40837. var ordinalNumber = categoryAxis.scale.getRawOrdinalNumber(labelItem.tickValue);
  40838. labelMap[ordinalNumber] = 1;
  40839. });
  40840. return function (dataIndex) {
  40841. return !labelMap.hasOwnProperty(data.get(categoryDataDim, dataIndex));
  40842. };
  40843. }
  40844. function canShowAllSymbolForCategory(categoryAxis, data) {
  40845. // In mose cases, line is monotonous on category axis, and the label size
  40846. // is close with each other. So we check the symbol size and some of the
  40847. // label size alone with the category axis to estimate whether all symbol
  40848. // can be shown without overlap.
  40849. var axisExtent = categoryAxis.getExtent();
  40850. var availSize = Math.abs(axisExtent[1] - axisExtent[0]) / categoryAxis.scale.count();
  40851. isNaN(availSize) && (availSize = 0); // 0/0 is NaN.
  40852. // Sampling some points, max 5.
  40853. var dataLen = data.count();
  40854. var step = Math.max(1, Math.round(dataLen / 5));
  40855. for (var dataIndex = 0; dataIndex < dataLen; dataIndex += step) {
  40856. if (Symbol$1.getSymbolSize(data, dataIndex // Only for cartesian, where `isHorizontal` exists.
  40857. )[categoryAxis.isHorizontal() ? 1 : 0] // Empirical number
  40858. * 1.5 > availSize) {
  40859. return false;
  40860. }
  40861. }
  40862. return true;
  40863. }
  40864. function isPointNull(x, y) {
  40865. return isNaN(x) || isNaN(y);
  40866. }
  40867. function getLastIndexNotNull(points) {
  40868. var len = points.length / 2;
  40869. for (; len > 0; len--) {
  40870. if (!isPointNull(points[len * 2 - 2], points[len * 2 - 1])) {
  40871. break;
  40872. }
  40873. }
  40874. return len - 1;
  40875. }
  40876. function getPointAtIndex(points, idx) {
  40877. return [points[idx * 2], points[idx * 2 + 1]];
  40878. }
  40879. function getIndexRange(points, xOrY, dim) {
  40880. var len = points.length / 2;
  40881. var dimIdx = dim === 'x' ? 0 : 1;
  40882. var a;
  40883. var b;
  40884. var prevIndex = 0;
  40885. var nextIndex = -1;
  40886. for (var i = 0; i < len; i++) {
  40887. b = points[i * 2 + dimIdx];
  40888. if (isNaN(b) || isNaN(points[i * 2 + 1 - dimIdx])) {
  40889. continue;
  40890. }
  40891. if (i === 0) {
  40892. a = b;
  40893. continue;
  40894. }
  40895. if (a <= xOrY && b >= xOrY || a >= xOrY && b <= xOrY) {
  40896. nextIndex = i;
  40897. break;
  40898. }
  40899. prevIndex = i;
  40900. a = b;
  40901. }
  40902. return {
  40903. range: [prevIndex, nextIndex],
  40904. t: (xOrY - a) / (b - a)
  40905. };
  40906. }
  40907. function createLineClipPath(lineView, coordSys, hasAnimation, seriesModel) {
  40908. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  40909. var endLabelModel_1 = seriesModel.getModel('endLabel');
  40910. var showEndLabel = endLabelModel_1.get('show');
  40911. var valueAnimation_1 = endLabelModel_1.get('valueAnimation');
  40912. var data_1 = seriesModel.getData();
  40913. var labelAnimationRecord_1 = {
  40914. lastFrameIndex: 0
  40915. };
  40916. var during = showEndLabel ? function (percent, clipRect) {
  40917. lineView._endLabelOnDuring(percent, clipRect, data_1, labelAnimationRecord_1, valueAnimation_1, endLabelModel_1, coordSys);
  40918. } : null;
  40919. var isHorizontal = coordSys.getBaseAxis().isHorizontal();
  40920. var clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel, function () {
  40921. var endLabel = lineView._endLabel;
  40922. if (endLabel && hasAnimation) {
  40923. if (labelAnimationRecord_1.originalX != null) {
  40924. endLabel.attr({
  40925. x: labelAnimationRecord_1.originalX,
  40926. y: labelAnimationRecord_1.originalY
  40927. });
  40928. }
  40929. }
  40930. }, during); // Expand clip shape to avoid clipping when line value exceeds axis
  40931. if (!seriesModel.get('clip', true)) {
  40932. var rectShape = clipPath.shape;
  40933. var expandSize = Math.max(rectShape.width, rectShape.height);
  40934. if (isHorizontal) {
  40935. rectShape.y -= expandSize;
  40936. rectShape.height += expandSize * 2;
  40937. } else {
  40938. rectShape.x -= expandSize;
  40939. rectShape.width += expandSize * 2;
  40940. }
  40941. } // Set to the final frame. To make sure label layout is right.
  40942. if (during) {
  40943. during(1, clipPath);
  40944. }
  40945. return clipPath;
  40946. } else {
  40947. {
  40948. if (seriesModel.get(['endLabel', 'show'])) {
  40949. console.warn('endLabel is not supported for lines in polar systems.');
  40950. }
  40951. }
  40952. return createPolarClipPath(coordSys, hasAnimation, seriesModel);
  40953. }
  40954. }
  40955. function getEndLabelStateSpecified(endLabelModel, coordSys) {
  40956. var baseAxis = coordSys.getBaseAxis();
  40957. var isHorizontal = baseAxis.isHorizontal();
  40958. var isBaseInversed = baseAxis.inverse;
  40959. var align = isHorizontal ? isBaseInversed ? 'right' : 'left' : 'center';
  40960. var verticalAlign = isHorizontal ? 'middle' : isBaseInversed ? 'top' : 'bottom';
  40961. return {
  40962. normal: {
  40963. align: endLabelModel.get('align') || align,
  40964. verticalAlign: endLabelModel.get('verticalAlign') || verticalAlign
  40965. }
  40966. };
  40967. }
  40968. var LineView =
  40969. /** @class */
  40970. function (_super) {
  40971. __extends(LineView, _super);
  40972. function LineView() {
  40973. return _super !== null && _super.apply(this, arguments) || this;
  40974. }
  40975. LineView.prototype.init = function () {
  40976. var lineGroup = new Group();
  40977. var symbolDraw = new SymbolDraw();
  40978. this.group.add(symbolDraw.group);
  40979. this._symbolDraw = symbolDraw;
  40980. this._lineGroup = lineGroup;
  40981. };
  40982. LineView.prototype.render = function (seriesModel, ecModel, api) {
  40983. var _this = this;
  40984. var coordSys = seriesModel.coordinateSystem;
  40985. var group = this.group;
  40986. var data = seriesModel.getData();
  40987. var lineStyleModel = seriesModel.getModel('lineStyle');
  40988. var areaStyleModel = seriesModel.getModel('areaStyle');
  40989. var points = data.getLayout('points') || [];
  40990. var isCoordSysPolar = coordSys.type === 'polar';
  40991. var prevCoordSys = this._coordSys;
  40992. var symbolDraw = this._symbolDraw;
  40993. var polyline = this._polyline;
  40994. var polygon = this._polygon;
  40995. var lineGroup = this._lineGroup;
  40996. var hasAnimation = seriesModel.get('animation');
  40997. var isAreaChart = !areaStyleModel.isEmpty();
  40998. var valueOrigin = areaStyleModel.get('origin');
  40999. var dataCoordInfo = prepareDataCoordInfo(coordSys, data, valueOrigin);
  41000. var stackedOnPoints = isAreaChart && getStackedOnPoints(coordSys, data, dataCoordInfo);
  41001. var showSymbol = seriesModel.get('showSymbol');
  41002. var isIgnoreFunc = showSymbol && !isCoordSysPolar && getIsIgnoreFunc(seriesModel, data, coordSys); // Remove temporary symbols
  41003. var oldData = this._data;
  41004. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  41005. if (el.__temp) {
  41006. group.remove(el);
  41007. oldData.setItemGraphicEl(idx, null);
  41008. }
  41009. }); // Remove previous created symbols if showSymbol changed to false
  41010. if (!showSymbol) {
  41011. symbolDraw.remove();
  41012. }
  41013. group.add(lineGroup); // FIXME step not support polar
  41014. var step = !isCoordSysPolar ? seriesModel.get('step') : false;
  41015. var clipShapeForSymbol;
  41016. if (coordSys && coordSys.getArea && seriesModel.get('clip', true)) {
  41017. clipShapeForSymbol = coordSys.getArea(); // Avoid float number rounding error for symbol on the edge of axis extent.
  41018. // See #7913 and `test/dataZoom-clip.html`.
  41019. if (clipShapeForSymbol.width != null) {
  41020. clipShapeForSymbol.x -= 0.1;
  41021. clipShapeForSymbol.y -= 0.1;
  41022. clipShapeForSymbol.width += 0.2;
  41023. clipShapeForSymbol.height += 0.2;
  41024. } else if (clipShapeForSymbol.r0) {
  41025. clipShapeForSymbol.r0 -= 0.5;
  41026. clipShapeForSymbol.r += 0.5;
  41027. }
  41028. }
  41029. this._clipShapeForSymbol = clipShapeForSymbol;
  41030. var visualColor = getVisualGradient(data, coordSys) || data.getVisual('style')[data.getVisual('drawType')]; // Initialization animation or coordinate system changed
  41031. if (!(polyline && prevCoordSys.type === coordSys.type && step === this._step)) {
  41032. showSymbol && symbolDraw.updateData(data, {
  41033. isIgnore: isIgnoreFunc,
  41034. clipShape: clipShapeForSymbol,
  41035. disableAnimation: true,
  41036. getSymbolPoint: function (idx) {
  41037. return [points[idx * 2], points[idx * 2 + 1]];
  41038. }
  41039. });
  41040. hasAnimation && this._initSymbolLabelAnimation(data, coordSys, clipShapeForSymbol);
  41041. if (step) {
  41042. // TODO If stacked series is not step
  41043. points = turnPointsIntoStep(points, coordSys, step);
  41044. if (stackedOnPoints) {
  41045. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  41046. }
  41047. }
  41048. polyline = this._newPolyline(points);
  41049. if (isAreaChart) {
  41050. polygon = this._newPolygon(points, stackedOnPoints);
  41051. } // NOTE: Must update _endLabel before setClipPath.
  41052. if (!isCoordSysPolar) {
  41053. this._initOrUpdateEndLabel(seriesModel, coordSys, convertToColorString(visualColor));
  41054. }
  41055. lineGroup.setClipPath(createLineClipPath(this, coordSys, true, seriesModel));
  41056. } else {
  41057. if (isAreaChart && !polygon) {
  41058. // If areaStyle is added
  41059. polygon = this._newPolygon(points, stackedOnPoints);
  41060. } else if (polygon && !isAreaChart) {
  41061. // If areaStyle is removed
  41062. lineGroup.remove(polygon);
  41063. polygon = this._polygon = null;
  41064. } // NOTE: Must update _endLabel before setClipPath.
  41065. if (!isCoordSysPolar) {
  41066. this._initOrUpdateEndLabel(seriesModel, coordSys, convertToColorString(visualColor));
  41067. } // Update clipPath
  41068. lineGroup.setClipPath(createLineClipPath(this, coordSys, false, seriesModel)); // Always update, or it is wrong in the case turning on legend
  41069. // because points are not changed
  41070. showSymbol && symbolDraw.updateData(data, {
  41071. isIgnore: isIgnoreFunc,
  41072. clipShape: clipShapeForSymbol,
  41073. disableAnimation: true,
  41074. getSymbolPoint: function (idx) {
  41075. return [points[idx * 2], points[idx * 2 + 1]];
  41076. }
  41077. }); // In the case data zoom triggerred refreshing frequently
  41078. // Data may not change if line has a category axis. So it should animate nothing
  41079. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints) || !isPointsSame(this._points, points)) {
  41080. if (hasAnimation) {
  41081. this._doUpdateAnimation(data, stackedOnPoints, coordSys, api, step, valueOrigin);
  41082. } else {
  41083. // Not do it in update with animation
  41084. if (step) {
  41085. // TODO If stacked series is not step
  41086. points = turnPointsIntoStep(points, coordSys, step);
  41087. if (stackedOnPoints) {
  41088. stackedOnPoints = turnPointsIntoStep(stackedOnPoints, coordSys, step);
  41089. }
  41090. }
  41091. polyline.setShape({
  41092. points: points
  41093. });
  41094. polygon && polygon.setShape({
  41095. points: points,
  41096. stackedOnPoints: stackedOnPoints
  41097. });
  41098. }
  41099. }
  41100. }
  41101. var focus = seriesModel.get(['emphasis', 'focus']);
  41102. var blurScope = seriesModel.get(['emphasis', 'blurScope']);
  41103. polyline.useStyle(defaults( // Use color in lineStyle first
  41104. lineStyleModel.getLineStyle(), {
  41105. fill: 'none',
  41106. stroke: visualColor,
  41107. lineJoin: 'bevel'
  41108. }));
  41109. setStatesStylesFromModel(polyline, seriesModel, 'lineStyle');
  41110. if (polyline.style.lineWidth > 0 && seriesModel.get(['emphasis', 'lineStyle', 'width']) === 'bolder') {
  41111. var emphasisLineStyle = polyline.getState('emphasis').style;
  41112. emphasisLineStyle.lineWidth = +polyline.style.lineWidth + 1;
  41113. } // Needs seriesIndex for focus
  41114. getECData(polyline).seriesIndex = seriesModel.seriesIndex;
  41115. enableHoverEmphasis(polyline, focus, blurScope);
  41116. var smooth = getSmooth(seriesModel.get('smooth'));
  41117. var smoothMonotone = seriesModel.get('smoothMonotone');
  41118. var connectNulls = seriesModel.get('connectNulls');
  41119. polyline.setShape({
  41120. smooth: smooth,
  41121. smoothMonotone: smoothMonotone,
  41122. connectNulls: connectNulls
  41123. });
  41124. if (polygon) {
  41125. var stackedOnSeries = data.getCalculationInfo('stackedOnSeries');
  41126. var stackedOnSmooth = 0;
  41127. polygon.useStyle(defaults(areaStyleModel.getAreaStyle(), {
  41128. fill: visualColor,
  41129. opacity: 0.7,
  41130. lineJoin: 'bevel',
  41131. decal: data.getVisual('style').decal
  41132. }));
  41133. if (stackedOnSeries) {
  41134. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  41135. }
  41136. polygon.setShape({
  41137. smooth: smooth,
  41138. stackedOnSmooth: stackedOnSmooth,
  41139. smoothMonotone: smoothMonotone,
  41140. connectNulls: connectNulls
  41141. });
  41142. setStatesStylesFromModel(polygon, seriesModel, 'areaStyle'); // Needs seriesIndex for focus
  41143. getECData(polygon).seriesIndex = seriesModel.seriesIndex;
  41144. enableHoverEmphasis(polygon, focus, blurScope);
  41145. }
  41146. var changePolyState = function (toState) {
  41147. _this._changePolyState(toState);
  41148. };
  41149. data.eachItemGraphicEl(function (el) {
  41150. // Switch polyline / polygon state if element changed its state.
  41151. el && (el.onHoverStateChange = changePolyState);
  41152. });
  41153. this._polyline.onHoverStateChange = changePolyState;
  41154. this._data = data; // Save the coordinate system for transition animation when data changed
  41155. this._coordSys = coordSys;
  41156. this._stackedOnPoints = stackedOnPoints;
  41157. this._points = points;
  41158. this._step = step;
  41159. this._valueOrigin = valueOrigin;
  41160. };
  41161. LineView.prototype.dispose = function () {};
  41162. LineView.prototype.highlight = function (seriesModel, ecModel, api, payload) {
  41163. var data = seriesModel.getData();
  41164. var dataIndex = queryDataIndex(data, payload);
  41165. this._changePolyState('emphasis');
  41166. if (!(dataIndex instanceof Array) && dataIndex != null && dataIndex >= 0) {
  41167. var points = data.getLayout('points');
  41168. var symbol = data.getItemGraphicEl(dataIndex);
  41169. if (!symbol) {
  41170. // Create a temporary symbol if it is not exists
  41171. var x = points[dataIndex * 2];
  41172. var y = points[dataIndex * 2 + 1];
  41173. if (isNaN(x) || isNaN(y)) {
  41174. // Null data
  41175. return;
  41176. } // fix #11360: should't draw symbol outside clipShapeForSymbol
  41177. if (this._clipShapeForSymbol && !this._clipShapeForSymbol.contain(x, y)) {
  41178. return;
  41179. }
  41180. symbol = new Symbol$1(data, dataIndex);
  41181. symbol.x = x;
  41182. symbol.y = y;
  41183. symbol.setZ(seriesModel.get('zlevel'), seriesModel.get('z')); // ensure label text of the temporal symbol is on the top of line and area polygon
  41184. var symbolLabel = symbol.getSymbolPath().getTextContent();
  41185. symbolLabel && (symbolLabel.z2 = this._polyline.z2 + 1);
  41186. symbol.__temp = true;
  41187. data.setItemGraphicEl(dataIndex, symbol); // Stop scale animation
  41188. symbol.stopSymbolAnimation(true);
  41189. this.group.add(symbol);
  41190. }
  41191. symbol.highlight();
  41192. } else {
  41193. // Highlight whole series
  41194. ChartView.prototype.highlight.call(this, seriesModel, ecModel, api, payload);
  41195. }
  41196. };
  41197. LineView.prototype.downplay = function (seriesModel, ecModel, api, payload) {
  41198. var data = seriesModel.getData();
  41199. var dataIndex = queryDataIndex(data, payload);
  41200. this._changePolyState('normal');
  41201. if (dataIndex != null && dataIndex >= 0) {
  41202. var symbol = data.getItemGraphicEl(dataIndex);
  41203. if (symbol) {
  41204. if (symbol.__temp) {
  41205. data.setItemGraphicEl(dataIndex, null);
  41206. this.group.remove(symbol);
  41207. } else {
  41208. symbol.downplay();
  41209. }
  41210. }
  41211. } else {
  41212. // FIXME
  41213. // can not downplay completely.
  41214. // Downplay whole series
  41215. ChartView.prototype.downplay.call(this, seriesModel, ecModel, api, payload);
  41216. }
  41217. };
  41218. LineView.prototype._changePolyState = function (toState) {
  41219. var polygon = this._polygon;
  41220. setStatesFlag(this._polyline, toState);
  41221. polygon && setStatesFlag(polygon, toState);
  41222. };
  41223. LineView.prototype._newPolyline = function (points) {
  41224. var polyline = this._polyline; // Remove previous created polyline
  41225. if (polyline) {
  41226. this._lineGroup.remove(polyline);
  41227. }
  41228. polyline = new ECPolyline({
  41229. shape: {
  41230. points: points
  41231. },
  41232. segmentIgnoreThreshold: 2,
  41233. z2: 10
  41234. });
  41235. this._lineGroup.add(polyline);
  41236. this._polyline = polyline;
  41237. return polyline;
  41238. };
  41239. LineView.prototype._newPolygon = function (points, stackedOnPoints) {
  41240. var polygon = this._polygon; // Remove previous created polygon
  41241. if (polygon) {
  41242. this._lineGroup.remove(polygon);
  41243. }
  41244. polygon = new ECPolygon({
  41245. shape: {
  41246. points: points,
  41247. stackedOnPoints: stackedOnPoints
  41248. },
  41249. segmentIgnoreThreshold: 2
  41250. });
  41251. this._lineGroup.add(polygon);
  41252. this._polygon = polygon;
  41253. return polygon;
  41254. };
  41255. LineView.prototype._initSymbolLabelAnimation = function (data, coordSys, clipShape) {
  41256. var isHorizontalOrRadial;
  41257. var isCoordSysPolar;
  41258. var baseAxis = coordSys.getBaseAxis();
  41259. var isAxisInverse = baseAxis.inverse;
  41260. if (coordSys.type === 'cartesian2d') {
  41261. isHorizontalOrRadial = baseAxis.isHorizontal();
  41262. isCoordSysPolar = false;
  41263. } else if (coordSys.type === 'polar') {
  41264. isHorizontalOrRadial = baseAxis.dim === 'angle';
  41265. isCoordSysPolar = true;
  41266. }
  41267. var seriesModel = data.hostModel;
  41268. var seriesDuration = seriesModel.get('animationDuration');
  41269. if (typeof seriesDuration === 'function') {
  41270. seriesDuration = seriesDuration(null);
  41271. }
  41272. var seriesDalay = seriesModel.get('animationDelay') || 0;
  41273. var seriesDalayValue = typeof seriesDalay === 'function' ? seriesDalay(null) : seriesDalay;
  41274. data.eachItemGraphicEl(function (symbol, idx) {
  41275. var el = symbol;
  41276. if (el) {
  41277. var point = [symbol.x, symbol.y];
  41278. var start = void 0;
  41279. var end = void 0;
  41280. var current = void 0;
  41281. if (isCoordSysPolar) {
  41282. var polarClip = clipShape;
  41283. var coord = coordSys.pointToCoord(point);
  41284. if (isHorizontalOrRadial) {
  41285. start = polarClip.startAngle;
  41286. end = polarClip.endAngle;
  41287. current = -coord[1] / 180 * Math.PI;
  41288. } else {
  41289. start = polarClip.r0;
  41290. end = polarClip.r;
  41291. current = coord[0];
  41292. }
  41293. } else {
  41294. var gridClip = clipShape;
  41295. if (isHorizontalOrRadial) {
  41296. start = gridClip.x;
  41297. end = gridClip.x + gridClip.width;
  41298. current = symbol.x;
  41299. } else {
  41300. start = gridClip.y + gridClip.height;
  41301. end = gridClip.y;
  41302. current = symbol.y;
  41303. }
  41304. }
  41305. var ratio = end === start ? 0 : (current - start) / (end - start);
  41306. if (isAxisInverse) {
  41307. ratio = 1 - ratio;
  41308. }
  41309. var delay = typeof seriesDalay === 'function' ? seriesDalay(idx) : seriesDuration * ratio + seriesDalayValue;
  41310. var symbolPath = el.getSymbolPath();
  41311. var text = symbolPath.getTextContent();
  41312. el.attr({
  41313. scaleX: 0,
  41314. scaleY: 0
  41315. });
  41316. el.animateTo({
  41317. scaleX: 1,
  41318. scaleY: 1
  41319. }, {
  41320. duration: 200,
  41321. delay: delay
  41322. });
  41323. if (text) {
  41324. text.animateFrom({
  41325. style: {
  41326. opacity: 0
  41327. }
  41328. }, {
  41329. duration: 300,
  41330. delay: delay
  41331. });
  41332. }
  41333. symbolPath.disableLabelAnimation = true;
  41334. }
  41335. });
  41336. };
  41337. LineView.prototype._initOrUpdateEndLabel = function (seriesModel, coordSys, inheritColor) {
  41338. var endLabelModel = seriesModel.getModel('endLabel');
  41339. if (endLabelModel.get('show')) {
  41340. var data_2 = seriesModel.getData();
  41341. var polyline = this._polyline;
  41342. var endLabel = this._endLabel;
  41343. if (!endLabel) {
  41344. endLabel = this._endLabel = new ZRText({
  41345. z2: 200 // should be higher than item symbol
  41346. });
  41347. endLabel.ignoreClip = true;
  41348. polyline.setTextContent(this._endLabel);
  41349. polyline.disableLabelAnimation = true;
  41350. } // Find last non-NaN data to display data
  41351. var dataIndex = getLastIndexNotNull(data_2.getLayout('points'));
  41352. if (dataIndex >= 0) {
  41353. setLabelStyle(polyline, getLabelStatesModels(seriesModel, 'endLabel'), {
  41354. inheritColor: inheritColor,
  41355. labelFetcher: seriesModel,
  41356. labelDataIndex: dataIndex,
  41357. defaultText: function (dataIndex, opt, interpolatedValue) {
  41358. return interpolatedValue != null ? getDefaultInterpolatedLabel(data_2, interpolatedValue) : getDefaultLabel(data_2, dataIndex);
  41359. },
  41360. enableTextSetter: true
  41361. }, getEndLabelStateSpecified(endLabelModel, coordSys));
  41362. polyline.textConfig.position = null;
  41363. }
  41364. } else if (this._endLabel) {
  41365. this._polyline.removeTextContent();
  41366. this._endLabel = null;
  41367. }
  41368. };
  41369. LineView.prototype._endLabelOnDuring = function (percent, clipRect, data, animationRecord, valueAnimation, endLabelModel, coordSys) {
  41370. var endLabel = this._endLabel;
  41371. var polyline = this._polyline;
  41372. if (endLabel) {
  41373. // NOTE: Don't remove percent < 1. percent === 1 means the first frame during render.
  41374. // The label is not prepared at this time.
  41375. if (percent < 1 && animationRecord.originalX == null) {
  41376. animationRecord.originalX = endLabel.x;
  41377. animationRecord.originalY = endLabel.y;
  41378. }
  41379. var points = data.getLayout('points');
  41380. var seriesModel = data.hostModel;
  41381. var connectNulls = seriesModel.get('connectNulls');
  41382. var precision = endLabelModel.get('precision');
  41383. var distance = endLabelModel.get('distance') || 0;
  41384. var baseAxis = coordSys.getBaseAxis();
  41385. var isHorizontal = baseAxis.isHorizontal();
  41386. var isBaseInversed = baseAxis.inverse;
  41387. var clipShape = clipRect.shape;
  41388. var xOrY = isBaseInversed ? isHorizontal ? clipShape.x : clipShape.y + clipShape.height : isHorizontal ? clipShape.x + clipShape.width : clipShape.y;
  41389. var distanceX = (isHorizontal ? distance : 0) * (isBaseInversed ? -1 : 1);
  41390. var distanceY = (isHorizontal ? 0 : -distance) * (isBaseInversed ? -1 : 1);
  41391. var dim = isHorizontal ? 'x' : 'y';
  41392. var dataIndexRange = getIndexRange(points, xOrY, dim);
  41393. var indices = dataIndexRange.range;
  41394. var diff = indices[1] - indices[0];
  41395. var value = void 0;
  41396. if (diff >= 1) {
  41397. // diff > 1 && connectNulls, which is on the null data.
  41398. if (diff > 1 && !connectNulls) {
  41399. var pt = getPointAtIndex(points, indices[0]);
  41400. endLabel.attr({
  41401. x: pt[0] + distanceX,
  41402. y: pt[1] + distanceY
  41403. });
  41404. valueAnimation && (value = seriesModel.getRawValue(indices[0]));
  41405. } else {
  41406. var pt = polyline.getPointOn(xOrY, dim);
  41407. pt && endLabel.attr({
  41408. x: pt[0] + distanceX,
  41409. y: pt[1] + distanceY
  41410. });
  41411. var startValue = seriesModel.getRawValue(indices[0]);
  41412. var endValue = seriesModel.getRawValue(indices[1]);
  41413. valueAnimation && (value = interpolateRawValues(data, precision, startValue, endValue, dataIndexRange.t));
  41414. }
  41415. animationRecord.lastFrameIndex = indices[0];
  41416. } else {
  41417. // If diff <= 0, which is the range is not found(Include NaN)
  41418. // Choose the first point or last point.
  41419. var idx = percent === 1 || animationRecord.lastFrameIndex > 0 ? indices[0] : 0;
  41420. var pt = getPointAtIndex(points, idx);
  41421. valueAnimation && (value = seriesModel.getRawValue(idx));
  41422. endLabel.attr({
  41423. x: pt[0] + distanceX,
  41424. y: pt[1] + distanceY
  41425. });
  41426. }
  41427. if (valueAnimation) {
  41428. labelInner(endLabel).setLabelText(value);
  41429. }
  41430. }
  41431. };
  41432. /**
  41433. * @private
  41434. */
  41435. // FIXME Two value axis
  41436. LineView.prototype._doUpdateAnimation = function (data, stackedOnPoints, coordSys, api, step, valueOrigin) {
  41437. var polyline = this._polyline;
  41438. var polygon = this._polygon;
  41439. var seriesModel = data.hostModel;
  41440. var diff = lineAnimationDiff(this._data, data, this._stackedOnPoints, stackedOnPoints, this._coordSys, coordSys, this._valueOrigin, valueOrigin);
  41441. var current = diff.current;
  41442. var stackedOnCurrent = diff.stackedOnCurrent;
  41443. var next = diff.next;
  41444. var stackedOnNext = diff.stackedOnNext;
  41445. if (step) {
  41446. // TODO If stacked series is not step
  41447. current = turnPointsIntoStep(diff.current, coordSys, step);
  41448. stackedOnCurrent = turnPointsIntoStep(diff.stackedOnCurrent, coordSys, step);
  41449. next = turnPointsIntoStep(diff.next, coordSys, step);
  41450. stackedOnNext = turnPointsIntoStep(diff.stackedOnNext, coordSys, step);
  41451. } // Don't apply animation if diff is large.
  41452. // For better result and avoid memory explosion problems like
  41453. // https://github.com/apache/incubator-echarts/issues/12229
  41454. if (getBoundingDiff(current, next) > 3000 || polygon && getBoundingDiff(stackedOnCurrent, stackedOnNext) > 3000) {
  41455. polyline.setShape({
  41456. points: next
  41457. });
  41458. if (polygon) {
  41459. polygon.setShape({
  41460. points: next,
  41461. stackedOnPoints: stackedOnNext
  41462. });
  41463. }
  41464. return;
  41465. }
  41466. polyline.shape.__points = diff.current;
  41467. polyline.shape.points = current;
  41468. var target = {
  41469. shape: {
  41470. points: next
  41471. }
  41472. }; // Also animate the original points.
  41473. // If points reference is changed when turning into step line.
  41474. if (diff.current !== current) {
  41475. target.shape.__points = diff.next;
  41476. } // Stop previous animation.
  41477. polyline.stopAnimation();
  41478. updateProps(polyline, target, seriesModel);
  41479. if (polygon) {
  41480. polygon.setShape({
  41481. // Reuse the points with polyline.
  41482. points: current,
  41483. stackedOnPoints: stackedOnCurrent
  41484. });
  41485. polygon.stopAnimation();
  41486. updateProps(polygon, {
  41487. shape: {
  41488. stackedOnPoints: stackedOnNext
  41489. }
  41490. }, seriesModel); // If use attr directly in updateProps.
  41491. if (polyline.shape.points !== polygon.shape.points) {
  41492. polygon.shape.points = polyline.shape.points;
  41493. }
  41494. }
  41495. var updatedDataInfo = [];
  41496. var diffStatus = diff.status;
  41497. for (var i = 0; i < diffStatus.length; i++) {
  41498. var cmd = diffStatus[i].cmd;
  41499. if (cmd === '=') {
  41500. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  41501. if (el) {
  41502. updatedDataInfo.push({
  41503. el: el,
  41504. ptIdx: i // Index of points
  41505. });
  41506. }
  41507. }
  41508. }
  41509. if (polyline.animators && polyline.animators.length) {
  41510. polyline.animators[0].during(function () {
  41511. polygon && polygon.dirtyShape();
  41512. var points = polyline.shape.__points;
  41513. for (var i = 0; i < updatedDataInfo.length; i++) {
  41514. var el = updatedDataInfo[i].el;
  41515. var offset = updatedDataInfo[i].ptIdx * 2;
  41516. el.x = points[offset];
  41517. el.y = points[offset + 1];
  41518. el.markRedraw();
  41519. }
  41520. });
  41521. }
  41522. };
  41523. LineView.prototype.remove = function (ecModel) {
  41524. var group = this.group;
  41525. var oldData = this._data;
  41526. this._lineGroup.removeAll();
  41527. this._symbolDraw.remove(true); // Remove temporary created elements when highlighting
  41528. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  41529. if (el.__temp) {
  41530. group.remove(el);
  41531. oldData.setItemGraphicEl(idx, null);
  41532. }
  41533. });
  41534. this._polyline = this._polygon = this._coordSys = this._points = this._stackedOnPoints = this._endLabel = this._data = null;
  41535. };
  41536. LineView.type = 'line';
  41537. return LineView;
  41538. }(ChartView);
  41539. /*
  41540. * Licensed to the Apache Software Foundation (ASF) under one
  41541. * or more contributor license agreements. See the NOTICE file
  41542. * distributed with this work for additional information
  41543. * regarding copyright ownership. The ASF licenses this file
  41544. * to you under the Apache License, Version 2.0 (the
  41545. * "License"); you may not use this file except in compliance
  41546. * with the License. You may obtain a copy of the License at
  41547. *
  41548. * http://www.apache.org/licenses/LICENSE-2.0
  41549. *
  41550. * Unless required by applicable law or agreed to in writing,
  41551. * software distributed under the License is distributed on an
  41552. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41553. * KIND, either express or implied. See the License for the
  41554. * specific language governing permissions and limitations
  41555. * under the License.
  41556. */
  41557. /**
  41558. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41559. */
  41560. /*
  41561. * Licensed to the Apache Software Foundation (ASF) under one
  41562. * or more contributor license agreements. See the NOTICE file
  41563. * distributed with this work for additional information
  41564. * regarding copyright ownership. The ASF licenses this file
  41565. * to you under the Apache License, Version 2.0 (the
  41566. * "License"); you may not use this file except in compliance
  41567. * with the License. You may obtain a copy of the License at
  41568. *
  41569. * http://www.apache.org/licenses/LICENSE-2.0
  41570. *
  41571. * Unless required by applicable law or agreed to in writing,
  41572. * software distributed under the License is distributed on an
  41573. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41574. * KIND, either express or implied. See the License for the
  41575. * specific language governing permissions and limitations
  41576. * under the License.
  41577. */
  41578. /* global Float32Array */
  41579. function pointsLayout(seriesType, forceStoreInTypedArray) {
  41580. return {
  41581. seriesType: seriesType,
  41582. plan: createRenderPlanner(),
  41583. reset: function (seriesModel) {
  41584. var data = seriesModel.getData();
  41585. var coordSys = seriesModel.coordinateSystem;
  41586. var pipelineContext = seriesModel.pipelineContext;
  41587. var useTypedArray = forceStoreInTypedArray || pipelineContext.large;
  41588. if (!coordSys) {
  41589. return;
  41590. }
  41591. var dims = map(coordSys.dimensions, function (dim) {
  41592. return data.mapDimension(dim);
  41593. }).slice(0, 2);
  41594. var dimLen = dims.length;
  41595. var stackResultDim = data.getCalculationInfo('stackResultDimension');
  41596. if (isDimensionStacked(data, dims[0]
  41597. /*, dims[1]*/
  41598. )) {
  41599. dims[0] = stackResultDim;
  41600. }
  41601. if (isDimensionStacked(data, dims[1]
  41602. /*, dims[0]*/
  41603. )) {
  41604. dims[1] = stackResultDim;
  41605. }
  41606. var dimInfo0 = data.getDimensionInfo(dims[0]);
  41607. var dimInfo1 = data.getDimensionInfo(dims[1]);
  41608. var dimIdx0 = dimInfo0 && dimInfo0.index;
  41609. var dimIdx1 = dimInfo1 && dimInfo1.index;
  41610. return dimLen && {
  41611. progress: function (params, data) {
  41612. var segCount = params.end - params.start;
  41613. var points = useTypedArray && createFloat32Array(segCount * dimLen);
  41614. var tmpIn = [];
  41615. var tmpOut = [];
  41616. for (var i = params.start, offset = 0; i < params.end; i++) {
  41617. var point = void 0;
  41618. if (dimLen === 1) {
  41619. var x = data.getByDimIdx(dimIdx0, i); // NOTE: Make sure the second parameter is null to use default strategy.
  41620. point = coordSys.dataToPoint(x, null, tmpOut);
  41621. } else {
  41622. tmpIn[0] = data.getByDimIdx(dimIdx0, i);
  41623. tmpIn[1] = data.getByDimIdx(dimIdx1, i); // Let coordinate system to handle the NaN data.
  41624. point = coordSys.dataToPoint(tmpIn, null, tmpOut);
  41625. }
  41626. if (useTypedArray) {
  41627. points[offset++] = point[0];
  41628. points[offset++] = point[1];
  41629. } else {
  41630. data.setItemLayout(i, point.slice());
  41631. }
  41632. }
  41633. useTypedArray && data.setLayout('points', points);
  41634. }
  41635. };
  41636. }
  41637. };
  41638. }
  41639. /*
  41640. * Licensed to the Apache Software Foundation (ASF) under one
  41641. * or more contributor license agreements. See the NOTICE file
  41642. * distributed with this work for additional information
  41643. * regarding copyright ownership. The ASF licenses this file
  41644. * to you under the Apache License, Version 2.0 (the
  41645. * "License"); you may not use this file except in compliance
  41646. * with the License. You may obtain a copy of the License at
  41647. *
  41648. * http://www.apache.org/licenses/LICENSE-2.0
  41649. *
  41650. * Unless required by applicable law or agreed to in writing,
  41651. * software distributed under the License is distributed on an
  41652. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41653. * KIND, either express or implied. See the License for the
  41654. * specific language governing permissions and limitations
  41655. * under the License.
  41656. */
  41657. /**
  41658. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41659. */
  41660. /*
  41661. * Licensed to the Apache Software Foundation (ASF) under one
  41662. * or more contributor license agreements. See the NOTICE file
  41663. * distributed with this work for additional information
  41664. * regarding copyright ownership. The ASF licenses this file
  41665. * to you under the Apache License, Version 2.0 (the
  41666. * "License"); you may not use this file except in compliance
  41667. * with the License. You may obtain a copy of the License at
  41668. *
  41669. * http://www.apache.org/licenses/LICENSE-2.0
  41670. *
  41671. * Unless required by applicable law or agreed to in writing,
  41672. * software distributed under the License is distributed on an
  41673. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41674. * KIND, either express or implied. See the License for the
  41675. * specific language governing permissions and limitations
  41676. * under the License.
  41677. */
  41678. function install$3(registers) {
  41679. registers.registerChartView(LineView);
  41680. registers.registerSeriesModel(LineSeriesModel);
  41681. registers.registerLayout(pointsLayout('line', true));
  41682. registers.registerVisual({
  41683. seriesType: 'line',
  41684. reset: function (seriesModel) {
  41685. var data = seriesModel.getData(); // Visual coding for legend
  41686. var lineStyle = seriesModel.getModel('lineStyle').getLineStyle();
  41687. if (lineStyle && !lineStyle.stroke) {
  41688. // Fill in visual should be palette color if
  41689. // has color callback
  41690. lineStyle.stroke = data.getVisual('style').fill;
  41691. }
  41692. data.setVisual('legendLineStyle', lineStyle);
  41693. }
  41694. }); // Down sample after filter
  41695. registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, dataSample('line'));
  41696. }
  41697. /*
  41698. * Licensed to the Apache Software Foundation (ASF) under one
  41699. * or more contributor license agreements. See the NOTICE file
  41700. * distributed with this work for additional information
  41701. * regarding copyright ownership. The ASF licenses this file
  41702. * to you under the Apache License, Version 2.0 (the
  41703. * "License"); you may not use this file except in compliance
  41704. * with the License. You may obtain a copy of the License at
  41705. *
  41706. * http://www.apache.org/licenses/LICENSE-2.0
  41707. *
  41708. * Unless required by applicable law or agreed to in writing,
  41709. * software distributed under the License is distributed on an
  41710. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41711. * KIND, either express or implied. See the License for the
  41712. * specific language governing permissions and limitations
  41713. * under the License.
  41714. */
  41715. /**
  41716. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41717. */
  41718. /*
  41719. * Licensed to the Apache Software Foundation (ASF) under one
  41720. * or more contributor license agreements. See the NOTICE file
  41721. * distributed with this work for additional information
  41722. * regarding copyright ownership. The ASF licenses this file
  41723. * to you under the Apache License, Version 2.0 (the
  41724. * "License"); you may not use this file except in compliance
  41725. * with the License. You may obtain a copy of the License at
  41726. *
  41727. * http://www.apache.org/licenses/LICENSE-2.0
  41728. *
  41729. * Unless required by applicable law or agreed to in writing,
  41730. * software distributed under the License is distributed on an
  41731. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41732. * KIND, either express or implied. See the License for the
  41733. * specific language governing permissions and limitations
  41734. * under the License.
  41735. */
  41736. use(install$3);
  41737. /*
  41738. * Licensed to the Apache Software Foundation (ASF) under one
  41739. * or more contributor license agreements. See the NOTICE file
  41740. * distributed with this work for additional information
  41741. * regarding copyright ownership. The ASF licenses this file
  41742. * to you under the Apache License, Version 2.0 (the
  41743. * "License"); you may not use this file except in compliance
  41744. * with the License. You may obtain a copy of the License at
  41745. *
  41746. * http://www.apache.org/licenses/LICENSE-2.0
  41747. *
  41748. * Unless required by applicable law or agreed to in writing,
  41749. * software distributed under the License is distributed on an
  41750. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41751. * KIND, either express or implied. See the License for the
  41752. * specific language governing permissions and limitations
  41753. * under the License.
  41754. */
  41755. /**
  41756. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41757. */
  41758. /*
  41759. * Licensed to the Apache Software Foundation (ASF) under one
  41760. * or more contributor license agreements. See the NOTICE file
  41761. * distributed with this work for additional information
  41762. * regarding copyright ownership. The ASF licenses this file
  41763. * to you under the Apache License, Version 2.0 (the
  41764. * "License"); you may not use this file except in compliance
  41765. * with the License. You may obtain a copy of the License at
  41766. *
  41767. * http://www.apache.org/licenses/LICENSE-2.0
  41768. *
  41769. * Unless required by applicable law or agreed to in writing,
  41770. * software distributed under the License is distributed on an
  41771. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41772. * KIND, either express or implied. See the License for the
  41773. * specific language governing permissions and limitations
  41774. * under the License.
  41775. */
  41776. var PI2$7 = Math.PI * 2;
  41777. var RADIAN = Math.PI / 180;
  41778. function getViewRect(seriesModel, api) {
  41779. return getLayoutRect(seriesModel.getBoxLayoutParams(), {
  41780. width: api.getWidth(),
  41781. height: api.getHeight()
  41782. });
  41783. }
  41784. function pieLayout(seriesType, ecModel, api) {
  41785. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  41786. var data = seriesModel.getData();
  41787. var valueDim = data.mapDimension('value');
  41788. var viewRect = getViewRect(seriesModel, api);
  41789. var center = seriesModel.get('center');
  41790. var radius = seriesModel.get('radius');
  41791. if (!isArray(radius)) {
  41792. radius = [0, radius];
  41793. }
  41794. if (!isArray(center)) {
  41795. center = [center, center];
  41796. }
  41797. var width = parsePercent$1(viewRect.width, api.getWidth());
  41798. var height = parsePercent$1(viewRect.height, api.getHeight());
  41799. var size = Math.min(width, height);
  41800. var cx = parsePercent$1(center[0], width) + viewRect.x;
  41801. var cy = parsePercent$1(center[1], height) + viewRect.y;
  41802. var r0 = parsePercent$1(radius[0], size / 2);
  41803. var r = parsePercent$1(radius[1], size / 2);
  41804. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  41805. var minAngle = seriesModel.get('minAngle') * RADIAN;
  41806. var validDataCount = 0;
  41807. data.each(valueDim, function (value) {
  41808. !isNaN(value) && validDataCount++;
  41809. });
  41810. var sum = data.getSum(valueDim); // Sum may be 0
  41811. var unitRadian = Math.PI / (sum || validDataCount) * 2;
  41812. var clockwise = seriesModel.get('clockwise');
  41813. var roseType = seriesModel.get('roseType');
  41814. var stillShowZeroSum = seriesModel.get('stillShowZeroSum'); // [0...max]
  41815. var extent = data.getDataExtent(valueDim);
  41816. extent[0] = 0; // In the case some sector angle is smaller than minAngle
  41817. var restAngle = PI2$7;
  41818. var valueSumLargerThanMinAngle = 0;
  41819. var currentAngle = startAngle;
  41820. var dir = clockwise ? 1 : -1;
  41821. data.setLayout({
  41822. viewRect: viewRect,
  41823. r: r
  41824. });
  41825. data.each(valueDim, function (value, idx) {
  41826. var angle;
  41827. if (isNaN(value)) {
  41828. data.setItemLayout(idx, {
  41829. angle: NaN,
  41830. startAngle: NaN,
  41831. endAngle: NaN,
  41832. clockwise: clockwise,
  41833. cx: cx,
  41834. cy: cy,
  41835. r0: r0,
  41836. r: roseType ? NaN : r
  41837. });
  41838. return;
  41839. } // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  41840. if (roseType !== 'area') {
  41841. angle = sum === 0 && stillShowZeroSum ? unitRadian : value * unitRadian;
  41842. } else {
  41843. angle = PI2$7 / validDataCount;
  41844. }
  41845. if (angle < minAngle) {
  41846. angle = minAngle;
  41847. restAngle -= minAngle;
  41848. } else {
  41849. valueSumLargerThanMinAngle += value;
  41850. }
  41851. var endAngle = currentAngle + dir * angle;
  41852. data.setItemLayout(idx, {
  41853. angle: angle,
  41854. startAngle: currentAngle,
  41855. endAngle: endAngle,
  41856. clockwise: clockwise,
  41857. cx: cx,
  41858. cy: cy,
  41859. r0: r0,
  41860. r: roseType ? linearMap(value, extent, [r0, r]) : r
  41861. });
  41862. currentAngle = endAngle;
  41863. }); // Some sector is constrained by minAngle
  41864. // Rest sectors needs recalculate angle
  41865. if (restAngle < PI2$7 && validDataCount) {
  41866. // Average the angle if rest angle is not enough after all angles is
  41867. // Constrained by minAngle
  41868. if (restAngle <= 1e-3) {
  41869. var angle_1 = PI2$7 / validDataCount;
  41870. data.each(valueDim, function (value, idx) {
  41871. if (!isNaN(value)) {
  41872. var layout_1 = data.getItemLayout(idx);
  41873. layout_1.angle = angle_1;
  41874. layout_1.startAngle = startAngle + dir * idx * angle_1;
  41875. layout_1.endAngle = startAngle + dir * (idx + 1) * angle_1;
  41876. }
  41877. });
  41878. } else {
  41879. unitRadian = restAngle / valueSumLargerThanMinAngle;
  41880. currentAngle = startAngle;
  41881. data.each(valueDim, function (value, idx) {
  41882. if (!isNaN(value)) {
  41883. var layout_2 = data.getItemLayout(idx);
  41884. var angle = layout_2.angle === minAngle ? minAngle : value * unitRadian;
  41885. layout_2.startAngle = currentAngle;
  41886. layout_2.endAngle = currentAngle + dir * angle;
  41887. currentAngle += dir * angle;
  41888. }
  41889. });
  41890. }
  41891. }
  41892. });
  41893. }
  41894. /*
  41895. * Licensed to the Apache Software Foundation (ASF) under one
  41896. * or more contributor license agreements. See the NOTICE file
  41897. * distributed with this work for additional information
  41898. * regarding copyright ownership. The ASF licenses this file
  41899. * to you under the Apache License, Version 2.0 (the
  41900. * "License"); you may not use this file except in compliance
  41901. * with the License. You may obtain a copy of the License at
  41902. *
  41903. * http://www.apache.org/licenses/LICENSE-2.0
  41904. *
  41905. * Unless required by applicable law or agreed to in writing,
  41906. * software distributed under the License is distributed on an
  41907. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41908. * KIND, either express or implied. See the License for the
  41909. * specific language governing permissions and limitations
  41910. * under the License.
  41911. */
  41912. /**
  41913. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41914. */
  41915. /*
  41916. * Licensed to the Apache Software Foundation (ASF) under one
  41917. * or more contributor license agreements. See the NOTICE file
  41918. * distributed with this work for additional information
  41919. * regarding copyright ownership. The ASF licenses this file
  41920. * to you under the Apache License, Version 2.0 (the
  41921. * "License"); you may not use this file except in compliance
  41922. * with the License. You may obtain a copy of the License at
  41923. *
  41924. * http://www.apache.org/licenses/LICENSE-2.0
  41925. *
  41926. * Unless required by applicable law or agreed to in writing,
  41927. * software distributed under the License is distributed on an
  41928. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41929. * KIND, either express or implied. See the License for the
  41930. * specific language governing permissions and limitations
  41931. * under the License.
  41932. */
  41933. function dataFilter(seriesType) {
  41934. return {
  41935. seriesType: seriesType,
  41936. reset: function (seriesModel, ecModel) {
  41937. var legendModels = ecModel.findComponents({
  41938. mainType: 'legend'
  41939. });
  41940. if (!legendModels || !legendModels.length) {
  41941. return;
  41942. }
  41943. var data = seriesModel.getData();
  41944. data.filterSelf(function (idx) {
  41945. var name = data.getName(idx); // If in any legend component the status is not selected.
  41946. for (var i = 0; i < legendModels.length; i++) {
  41947. // @ts-ignore FIXME: LegendModel
  41948. if (!legendModels[i].isSelected(name)) {
  41949. return false;
  41950. }
  41951. }
  41952. return true;
  41953. });
  41954. }
  41955. };
  41956. }
  41957. /*
  41958. * Licensed to the Apache Software Foundation (ASF) under one
  41959. * or more contributor license agreements. See the NOTICE file
  41960. * distributed with this work for additional information
  41961. * regarding copyright ownership. The ASF licenses this file
  41962. * to you under the Apache License, Version 2.0 (the
  41963. * "License"); you may not use this file except in compliance
  41964. * with the License. You may obtain a copy of the License at
  41965. *
  41966. * http://www.apache.org/licenses/LICENSE-2.0
  41967. *
  41968. * Unless required by applicable law or agreed to in writing,
  41969. * software distributed under the License is distributed on an
  41970. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41971. * KIND, either express or implied. See the License for the
  41972. * specific language governing permissions and limitations
  41973. * under the License.
  41974. */
  41975. /**
  41976. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41977. */
  41978. /*
  41979. * Licensed to the Apache Software Foundation (ASF) under one
  41980. * or more contributor license agreements. See the NOTICE file
  41981. * distributed with this work for additional information
  41982. * regarding copyright ownership. The ASF licenses this file
  41983. * to you under the Apache License, Version 2.0 (the
  41984. * "License"); you may not use this file except in compliance
  41985. * with the License. You may obtain a copy of the License at
  41986. *
  41987. * http://www.apache.org/licenses/LICENSE-2.0
  41988. *
  41989. * Unless required by applicable law or agreed to in writing,
  41990. * software distributed under the License is distributed on an
  41991. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41992. * KIND, either express or implied. See the License for the
  41993. * specific language governing permissions and limitations
  41994. * under the License.
  41995. */
  41996. // FIXME emphasis label position is not same with normal label position
  41997. var RADIAN$1 = Math.PI / 180;
  41998. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight, viewLeft, viewTop, farthestX) {
  41999. if (list.length < 2) {
  42000. return;
  42001. }
  42002. function recalculateXOnSemiToAlignOnEllipseCurve(semi) {
  42003. var rB = semi.rB;
  42004. var rB2 = rB * rB;
  42005. for (var i = 0; i < semi.list.length; i++) {
  42006. var item = semi.list[i];
  42007. var dy = Math.abs(item.label.y - cy); // horizontal r is always same with original r because x is not changed.
  42008. var rA = r + item.len;
  42009. var rA2 = rA * rA; // Use ellipse implicit function to calculate x
  42010. var dx = Math.sqrt((1 - Math.abs(dy * dy / rB2)) * rA2);
  42011. item.label.x = cx + (dx + item.len2) * dir;
  42012. }
  42013. } // Adjust X based on the shifted y. Make tight labels aligned on an ellipse curve.
  42014. function recalculateX(items) {
  42015. // Extremes of
  42016. var topSemi = {
  42017. list: [],
  42018. maxY: 0
  42019. };
  42020. var bottomSemi = {
  42021. list: [],
  42022. maxY: 0
  42023. };
  42024. for (var i = 0; i < items.length; i++) {
  42025. if (items[i].labelAlignTo !== 'none') {
  42026. continue;
  42027. }
  42028. var item = items[i];
  42029. var semi = item.label.y > cy ? bottomSemi : topSemi;
  42030. var dy = Math.abs(item.label.y - cy);
  42031. if (dy > semi.maxY) {
  42032. var dx = item.label.x - cx - item.len2 * dir; // horizontal r is always same with original r because x is not changed.
  42033. var rA = r + item.len; // Canculate rB based on the topest / bottemest label.
  42034. var rB = Math.abs(dx) < rA ? Math.sqrt(dy * dy / (1 - dx * dx / rA / rA)) : rA;
  42035. semi.rB = rB;
  42036. semi.maxY = dy;
  42037. }
  42038. semi.list.push(item);
  42039. }
  42040. recalculateXOnSemiToAlignOnEllipseCurve(topSemi);
  42041. recalculateXOnSemiToAlignOnEllipseCurve(bottomSemi);
  42042. }
  42043. var len = list.length;
  42044. for (var i = 0; i < len; i++) {
  42045. if (list[i].position === 'outer' && list[i].labelAlignTo === 'labelLine') {
  42046. var dx = list[i].label.x - farthestX;
  42047. list[i].linePoints[1][0] += dx;
  42048. list[i].label.x = farthestX;
  42049. }
  42050. }
  42051. if (shiftLayoutOnY(list, viewTop, viewTop + viewHeight)) {
  42052. recalculateX(list);
  42053. }
  42054. }
  42055. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop) {
  42056. var leftList = [];
  42057. var rightList = [];
  42058. var leftmostX = Number.MAX_VALUE;
  42059. var rightmostX = -Number.MAX_VALUE;
  42060. for (var i = 0; i < labelLayoutList.length; i++) {
  42061. var label = labelLayoutList[i].label;
  42062. if (isPositionCenter(labelLayoutList[i])) {
  42063. continue;
  42064. }
  42065. if (label.x < cx) {
  42066. leftmostX = Math.min(leftmostX, label.x);
  42067. leftList.push(labelLayoutList[i]);
  42068. } else {
  42069. rightmostX = Math.max(rightmostX, label.x);
  42070. rightList.push(labelLayoutList[i]);
  42071. }
  42072. }
  42073. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight, viewLeft, viewTop, rightmostX);
  42074. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight, viewLeft, viewTop, leftmostX);
  42075. for (var i = 0; i < labelLayoutList.length; i++) {
  42076. var layout = labelLayoutList[i];
  42077. var label = layout.label;
  42078. if (isPositionCenter(layout)) {
  42079. continue;
  42080. }
  42081. var linePoints = layout.linePoints;
  42082. if (linePoints) {
  42083. var isAlignToEdge = layout.labelAlignTo === 'edge';
  42084. var realTextWidth = layout.rect.width;
  42085. var targetTextWidth = void 0;
  42086. if (isAlignToEdge) {
  42087. if (label.x < cx) {
  42088. targetTextWidth = linePoints[2][0] - layout.labelDistance - viewLeft - layout.edgeDistance;
  42089. } else {
  42090. targetTextWidth = viewLeft + viewWidth - layout.edgeDistance - linePoints[2][0] - layout.labelDistance;
  42091. }
  42092. } else {
  42093. if (label.x < cx) {
  42094. targetTextWidth = label.x - viewLeft - layout.bleedMargin;
  42095. } else {
  42096. targetTextWidth = viewLeft + viewWidth - label.x - layout.bleedMargin;
  42097. }
  42098. }
  42099. if (targetTextWidth < layout.rect.width) {
  42100. // TODOTODO
  42101. // layout.text = textContain.truncateText(layout.text, targetTextWidth, layout.font);
  42102. layout.label.style.width = targetTextWidth;
  42103. if (layout.labelAlignTo === 'edge') {
  42104. realTextWidth = targetTextWidth; // realTextWidth = textContain.getWidth(layout.text, layout.font);
  42105. }
  42106. }
  42107. var dist = linePoints[1][0] - linePoints[2][0];
  42108. if (isAlignToEdge) {
  42109. if (label.x < cx) {
  42110. linePoints[2][0] = viewLeft + layout.edgeDistance + realTextWidth + layout.labelDistance;
  42111. } else {
  42112. linePoints[2][0] = viewLeft + viewWidth - layout.edgeDistance - realTextWidth - layout.labelDistance;
  42113. }
  42114. } else {
  42115. if (label.x < cx) {
  42116. linePoints[2][0] = label.x + layout.labelDistance;
  42117. } else {
  42118. linePoints[2][0] = label.x - layout.labelDistance;
  42119. }
  42120. linePoints[1][0] = linePoints[2][0] + dist;
  42121. }
  42122. linePoints[1][1] = linePoints[2][1] = label.y;
  42123. }
  42124. }
  42125. }
  42126. function isPositionCenter(sectorShape) {
  42127. // Not change x for center label
  42128. return sectorShape.position === 'center';
  42129. }
  42130. function pieLabelLayout(seriesModel) {
  42131. var data = seriesModel.getData();
  42132. var labelLayoutList = [];
  42133. var cx;
  42134. var cy;
  42135. var hasLabelRotate = false;
  42136. var minShowLabelRadian = (seriesModel.get('minShowLabelAngle') || 0) * RADIAN$1;
  42137. var viewRect = data.getLayout('viewRect');
  42138. var r = data.getLayout('r');
  42139. var viewWidth = viewRect.width;
  42140. var viewLeft = viewRect.x;
  42141. var viewTop = viewRect.y;
  42142. var viewHeight = viewRect.height;
  42143. function setNotShow(el) {
  42144. el.ignore = true;
  42145. }
  42146. function isLabelShown(label) {
  42147. if (!label.ignore) {
  42148. return true;
  42149. }
  42150. for (var key in label.states) {
  42151. if (label.states[key].ignore === false) {
  42152. return true;
  42153. }
  42154. }
  42155. return false;
  42156. }
  42157. data.each(function (idx) {
  42158. var sector = data.getItemGraphicEl(idx);
  42159. var sectorShape = sector.shape;
  42160. var label = sector.getTextContent();
  42161. var labelLine = sector.getTextGuideLine();
  42162. var itemModel = data.getItemModel(idx);
  42163. var labelModel = itemModel.getModel('label'); // Use position in normal or emphasis
  42164. var labelPosition = labelModel.get('position') || itemModel.get(['emphasis', 'label', 'position']);
  42165. var labelDistance = labelModel.get('distanceToLabelLine');
  42166. var labelAlignTo = labelModel.get('alignTo');
  42167. var edgeDistance = parsePercent$1(labelModel.get('edgeDistance'), viewWidth);
  42168. var bleedMargin = labelModel.get('bleedMargin');
  42169. var labelLineModel = itemModel.getModel('labelLine');
  42170. var labelLineLen = labelLineModel.get('length');
  42171. labelLineLen = parsePercent$1(labelLineLen, viewWidth);
  42172. var labelLineLen2 = labelLineModel.get('length2');
  42173. labelLineLen2 = parsePercent$1(labelLineLen2, viewWidth);
  42174. if (Math.abs(sectorShape.endAngle - sectorShape.startAngle) < minShowLabelRadian) {
  42175. each$1(label.states, setNotShow);
  42176. label.ignore = true;
  42177. return;
  42178. }
  42179. if (!isLabelShown(label)) {
  42180. return;
  42181. }
  42182. var midAngle = (sectorShape.startAngle + sectorShape.endAngle) / 2;
  42183. var nx = Math.cos(midAngle);
  42184. var ny = Math.sin(midAngle);
  42185. var textX;
  42186. var textY;
  42187. var linePoints;
  42188. var textAlign;
  42189. cx = sectorShape.cx;
  42190. cy = sectorShape.cy;
  42191. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  42192. if (labelPosition === 'center') {
  42193. textX = sectorShape.cx;
  42194. textY = sectorShape.cy;
  42195. textAlign = 'center';
  42196. } else {
  42197. var x1 = (isLabelInside ? (sectorShape.r + sectorShape.r0) / 2 * nx : sectorShape.r * nx) + cx;
  42198. var y1 = (isLabelInside ? (sectorShape.r + sectorShape.r0) / 2 * ny : sectorShape.r * ny) + cy;
  42199. textX = x1 + nx * 3;
  42200. textY = y1 + ny * 3;
  42201. if (!isLabelInside) {
  42202. // For roseType
  42203. var x2 = x1 + nx * (labelLineLen + r - sectorShape.r);
  42204. var y2 = y1 + ny * (labelLineLen + r - sectorShape.r);
  42205. var x3 = x2 + (nx < 0 ? -1 : 1) * labelLineLen2;
  42206. var y3 = y2;
  42207. if (labelAlignTo === 'edge') {
  42208. // Adjust textX because text align of edge is opposite
  42209. textX = nx < 0 ? viewLeft + edgeDistance : viewLeft + viewWidth - edgeDistance;
  42210. } else {
  42211. textX = x3 + (nx < 0 ? -labelDistance : labelDistance);
  42212. }
  42213. textY = y3;
  42214. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  42215. }
  42216. textAlign = isLabelInside ? 'center' : labelAlignTo === 'edge' ? nx > 0 ? 'right' : 'left' : nx > 0 ? 'left' : 'right';
  42217. }
  42218. var labelRotate;
  42219. var rotate = labelModel.get('rotate');
  42220. if (typeof rotate === 'number') {
  42221. labelRotate = rotate * (Math.PI / 180);
  42222. } else {
  42223. labelRotate = rotate ? nx < 0 ? -midAngle + Math.PI : -midAngle : 0;
  42224. }
  42225. hasLabelRotate = !!labelRotate;
  42226. label.x = textX;
  42227. label.y = textY;
  42228. label.rotation = labelRotate;
  42229. label.setStyle({
  42230. verticalAlign: 'middle'
  42231. }); // Not sectorShape the inside label
  42232. if (!isLabelInside) {
  42233. var textRect = label.getBoundingRect().clone();
  42234. textRect.applyTransform(label.getComputedTransform()); // Text has a default 1px stroke. Exclude this.
  42235. var margin = (label.style.margin || 0) + 2.1;
  42236. textRect.y -= margin / 2;
  42237. textRect.height += margin;
  42238. labelLayoutList.push({
  42239. label: label,
  42240. labelLine: labelLine,
  42241. position: labelPosition,
  42242. len: labelLineLen,
  42243. len2: labelLineLen2,
  42244. minTurnAngle: labelLineModel.get('minTurnAngle'),
  42245. maxSurfaceAngle: labelLineModel.get('maxSurfaceAngle'),
  42246. surfaceNormal: new Point(nx, ny),
  42247. linePoints: linePoints,
  42248. textAlign: textAlign,
  42249. labelDistance: labelDistance,
  42250. labelAlignTo: labelAlignTo,
  42251. edgeDistance: edgeDistance,
  42252. bleedMargin: bleedMargin,
  42253. rect: textRect
  42254. });
  42255. } else {
  42256. label.setStyle({
  42257. align: textAlign
  42258. });
  42259. var selectState = label.states.select;
  42260. if (selectState) {
  42261. selectState.x += label.x;
  42262. selectState.y += label.y;
  42263. }
  42264. }
  42265. sector.setTextConfig({
  42266. inside: isLabelInside
  42267. });
  42268. });
  42269. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  42270. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight, viewLeft, viewTop);
  42271. }
  42272. for (var i = 0; i < labelLayoutList.length; i++) {
  42273. var layout = labelLayoutList[i];
  42274. var label = layout.label;
  42275. var labelLine = layout.labelLine;
  42276. var notShowLabel = isNaN(label.x) || isNaN(label.y);
  42277. if (label) {
  42278. label.setStyle({
  42279. align: layout.textAlign
  42280. });
  42281. if (notShowLabel) {
  42282. each$1(label.states, setNotShow);
  42283. label.ignore = true;
  42284. }
  42285. var selectState = label.states.select;
  42286. if (selectState) {
  42287. selectState.x += label.x;
  42288. selectState.y += label.y;
  42289. }
  42290. }
  42291. if (labelLine) {
  42292. var linePoints = layout.linePoints;
  42293. if (notShowLabel || !linePoints) {
  42294. each$1(labelLine.states, setNotShow);
  42295. labelLine.ignore = true;
  42296. } else {
  42297. limitTurnAngle(linePoints, layout.minTurnAngle);
  42298. limitSurfaceAngle(linePoints, layout.surfaceNormal, layout.maxSurfaceAngle);
  42299. labelLine.setShape({
  42300. points: linePoints
  42301. }); // Set the anchor to the midpoint of sector
  42302. label.__hostTarget.textGuideLineConfig = {
  42303. anchor: new Point(linePoints[0][0], linePoints[0][1])
  42304. };
  42305. }
  42306. }
  42307. }
  42308. }
  42309. /*
  42310. * Licensed to the Apache Software Foundation (ASF) under one
  42311. * or more contributor license agreements. See the NOTICE file
  42312. * distributed with this work for additional information
  42313. * regarding copyright ownership. The ASF licenses this file
  42314. * to you under the Apache License, Version 2.0 (the
  42315. * "License"); you may not use this file except in compliance
  42316. * with the License. You may obtain a copy of the License at
  42317. *
  42318. * http://www.apache.org/licenses/LICENSE-2.0
  42319. *
  42320. * Unless required by applicable law or agreed to in writing,
  42321. * software distributed under the License is distributed on an
  42322. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42323. * KIND, either express or implied. See the License for the
  42324. * specific language governing permissions and limitations
  42325. * under the License.
  42326. */
  42327. /**
  42328. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42329. */
  42330. /*
  42331. * Licensed to the Apache Software Foundation (ASF) under one
  42332. * or more contributor license agreements. See the NOTICE file
  42333. * distributed with this work for additional information
  42334. * regarding copyright ownership. The ASF licenses this file
  42335. * to you under the Apache License, Version 2.0 (the
  42336. * "License"); you may not use this file except in compliance
  42337. * with the License. You may obtain a copy of the License at
  42338. *
  42339. * http://www.apache.org/licenses/LICENSE-2.0
  42340. *
  42341. * Unless required by applicable law or agreed to in writing,
  42342. * software distributed under the License is distributed on an
  42343. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42344. * KIND, either express or implied. See the License for the
  42345. * specific language governing permissions and limitations
  42346. * under the License.
  42347. */
  42348. function getSectorCornerRadius(model, shape) {
  42349. var cornerRadius = model.get('borderRadius');
  42350. if (cornerRadius == null) {
  42351. return null;
  42352. }
  42353. if (!isArray(cornerRadius)) {
  42354. cornerRadius = [cornerRadius, cornerRadius];
  42355. }
  42356. return {
  42357. innerCornerRadius: parsePercent(cornerRadius[0], shape.r0),
  42358. cornerRadius: parsePercent(cornerRadius[1], shape.r)
  42359. };
  42360. }
  42361. /*
  42362. * Licensed to the Apache Software Foundation (ASF) under one
  42363. * or more contributor license agreements. See the NOTICE file
  42364. * distributed with this work for additional information
  42365. * regarding copyright ownership. The ASF licenses this file
  42366. * to you under the Apache License, Version 2.0 (the
  42367. * "License"); you may not use this file except in compliance
  42368. * with the License. You may obtain a copy of the License at
  42369. *
  42370. * http://www.apache.org/licenses/LICENSE-2.0
  42371. *
  42372. * Unless required by applicable law or agreed to in writing,
  42373. * software distributed under the License is distributed on an
  42374. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42375. * KIND, either express or implied. See the License for the
  42376. * specific language governing permissions and limitations
  42377. * under the License.
  42378. */
  42379. /**
  42380. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42381. */
  42382. /*
  42383. * Licensed to the Apache Software Foundation (ASF) under one
  42384. * or more contributor license agreements. See the NOTICE file
  42385. * distributed with this work for additional information
  42386. * regarding copyright ownership. The ASF licenses this file
  42387. * to you under the Apache License, Version 2.0 (the
  42388. * "License"); you may not use this file except in compliance
  42389. * with the License. You may obtain a copy of the License at
  42390. *
  42391. * http://www.apache.org/licenses/LICENSE-2.0
  42392. *
  42393. * Unless required by applicable law or agreed to in writing,
  42394. * software distributed under the License is distributed on an
  42395. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42396. * KIND, either express or implied. See the License for the
  42397. * specific language governing permissions and limitations
  42398. * under the License.
  42399. */
  42400. /**
  42401. * Piece of pie including Sector, Label, LabelLine
  42402. */
  42403. var PiePiece =
  42404. /** @class */
  42405. function (_super) {
  42406. __extends(PiePiece, _super);
  42407. function PiePiece(data, idx, startAngle) {
  42408. var _this = _super.call(this) || this;
  42409. _this.z2 = 2;
  42410. var polyline = new Polyline();
  42411. var text = new ZRText();
  42412. _this.setTextGuideLine(polyline);
  42413. _this.setTextContent(text);
  42414. _this.updateData(data, idx, startAngle, true);
  42415. return _this;
  42416. }
  42417. PiePiece.prototype.updateData = function (data, idx, startAngle, firstCreate) {
  42418. var sector = this;
  42419. var seriesModel = data.hostModel;
  42420. var itemModel = data.getItemModel(idx);
  42421. var emphasisModel = itemModel.getModel('emphasis');
  42422. var layout = data.getItemLayout(idx);
  42423. var sectorShape = extend(getSectorCornerRadius(itemModel.getModel('itemStyle'), layout) || {}, layout); // Ignore NaN data.
  42424. if (isNaN(sectorShape.startAngle)) {
  42425. // Use NaN shape to avoid drawing shape.
  42426. sector.setShape(sectorShape);
  42427. return;
  42428. }
  42429. if (firstCreate) {
  42430. sector.setShape(sectorShape);
  42431. var animationType = seriesModel.getShallow('animationType');
  42432. if (animationType === 'scale') {
  42433. sector.shape.r = layout.r0;
  42434. initProps(sector, {
  42435. shape: {
  42436. r: layout.r
  42437. }
  42438. }, seriesModel, idx);
  42439. } // Expansion
  42440. else {
  42441. if (startAngle != null) {
  42442. sector.setShape({
  42443. startAngle: startAngle,
  42444. endAngle: startAngle
  42445. });
  42446. initProps(sector, {
  42447. shape: {
  42448. startAngle: layout.startAngle,
  42449. endAngle: layout.endAngle
  42450. }
  42451. }, seriesModel, idx);
  42452. } else {
  42453. sector.shape.endAngle = layout.startAngle;
  42454. updateProps(sector, {
  42455. shape: {
  42456. endAngle: layout.endAngle
  42457. }
  42458. }, seriesModel, idx);
  42459. }
  42460. }
  42461. } else {
  42462. // Transition animation from the old shape
  42463. updateProps(sector, {
  42464. shape: sectorShape
  42465. }, seriesModel, idx);
  42466. }
  42467. sector.useStyle(data.getItemVisual(idx, 'style'));
  42468. setStatesStylesFromModel(sector, itemModel);
  42469. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  42470. var offset = seriesModel.get('selectedOffset');
  42471. var dx = Math.cos(midAngle) * offset;
  42472. var dy = Math.sin(midAngle) * offset;
  42473. var cursorStyle = itemModel.getShallow('cursor');
  42474. cursorStyle && sector.attr('cursor', cursorStyle);
  42475. this._updateLabel(seriesModel, data, idx);
  42476. sector.ensureState('emphasis').shape = __assign({
  42477. r: layout.r + (emphasisModel.get('scale') ? emphasisModel.get('scaleSize') || 0 : 0)
  42478. }, getSectorCornerRadius(emphasisModel.getModel('itemStyle'), layout));
  42479. extend(sector.ensureState('select'), {
  42480. x: dx,
  42481. y: dy,
  42482. shape: getSectorCornerRadius(itemModel.getModel(['select', 'itemStyle']), layout)
  42483. });
  42484. extend(sector.ensureState('blur'), {
  42485. shape: getSectorCornerRadius(itemModel.getModel(['blur', 'itemStyle']), layout)
  42486. });
  42487. var labelLine = sector.getTextGuideLine();
  42488. var labelText = sector.getTextContent();
  42489. labelLine && extend(labelLine.ensureState('select'), {
  42490. x: dx,
  42491. y: dy
  42492. }); // TODO: needs dx, dy in zrender?
  42493. extend(labelText.ensureState('select'), {
  42494. x: dx,
  42495. y: dy
  42496. });
  42497. enableHoverEmphasis(this, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  42498. };
  42499. PiePiece.prototype._updateLabel = function (seriesModel, data, idx) {
  42500. var _a;
  42501. var sector = this;
  42502. var itemModel = data.getItemModel(idx);
  42503. var labelLineModel = itemModel.getModel('labelLine');
  42504. var style = data.getItemVisual(idx, 'style');
  42505. var visualColor = style && style.fill;
  42506. var visualOpacity = style && style.opacity;
  42507. setLabelStyle(sector, getLabelStatesModels(itemModel), {
  42508. labelFetcher: data.hostModel,
  42509. labelDataIndex: idx,
  42510. inheritColor: visualColor,
  42511. defaultOpacity: visualOpacity,
  42512. defaultText: seriesModel.getFormattedLabel(idx, 'normal') || data.getName(idx)
  42513. });
  42514. var labelText = sector.getTextContent(); // Set textConfig on sector.
  42515. sector.setTextConfig({
  42516. // reset position, rotation
  42517. position: null,
  42518. rotation: null
  42519. }); // Make sure update style on labelText after setLabelStyle.
  42520. // Because setLabelStyle will replace a new style on it.
  42521. labelText.attr({
  42522. z2: 10
  42523. });
  42524. var labelPosition = seriesModel.get(['label', 'position']);
  42525. if (labelPosition !== 'outside' && labelPosition !== 'outer') {
  42526. (_a = sector.getTextGuideLine()) === null || _a === void 0 ? void 0 : _a.hide();
  42527. return;
  42528. } // Default use item visual color
  42529. setLabelLineStyle(this, getLabelLineStatesModels(itemModel), {
  42530. stroke: visualColor,
  42531. opacity: retrieve3(labelLineModel.get(['lineStyle', 'opacity']), visualOpacity, 1)
  42532. });
  42533. };
  42534. return PiePiece;
  42535. }(Sector); // Pie view
  42536. var PieView =
  42537. /** @class */
  42538. function (_super) {
  42539. __extends(PieView, _super);
  42540. function PieView() {
  42541. var _this = _super !== null && _super.apply(this, arguments) || this;
  42542. _this.ignoreLabelLineUpdate = true;
  42543. return _this;
  42544. }
  42545. PieView.prototype.init = function () {
  42546. var sectorGroup = new Group();
  42547. this._sectorGroup = sectorGroup;
  42548. };
  42549. PieView.prototype.render = function (seriesModel, ecModel, api, payload) {
  42550. var data = seriesModel.getData();
  42551. var oldData = this._data;
  42552. var group = this.group;
  42553. var startAngle; // First render
  42554. if (!oldData && data.count() > 0) {
  42555. var shape = data.getItemLayout(0);
  42556. for (var s = 1; isNaN(shape && shape.startAngle) && s < data.count(); ++s) {
  42557. shape = data.getItemLayout(s);
  42558. }
  42559. if (shape) {
  42560. startAngle = shape.startAngle;
  42561. }
  42562. }
  42563. data.diff(oldData).add(function (idx) {
  42564. var piePiece = new PiePiece(data, idx, startAngle);
  42565. data.setItemGraphicEl(idx, piePiece);
  42566. group.add(piePiece);
  42567. }).update(function (newIdx, oldIdx) {
  42568. var piePiece = oldData.getItemGraphicEl(oldIdx);
  42569. piePiece.updateData(data, newIdx, startAngle);
  42570. piePiece.off('click');
  42571. group.add(piePiece);
  42572. data.setItemGraphicEl(newIdx, piePiece);
  42573. }).remove(function (idx) {
  42574. var piePiece = oldData.getItemGraphicEl(idx);
  42575. removeElementWithFadeOut(piePiece, seriesModel, idx);
  42576. }).execute();
  42577. pieLabelLayout(seriesModel); // Always use initial animation.
  42578. if (seriesModel.get('animationTypeUpdate') !== 'expansion') {
  42579. this._data = data;
  42580. }
  42581. };
  42582. PieView.prototype.dispose = function () {};
  42583. PieView.prototype.containPoint = function (point, seriesModel) {
  42584. var data = seriesModel.getData();
  42585. var itemLayout = data.getItemLayout(0);
  42586. if (itemLayout) {
  42587. var dx = point[0] - itemLayout.cx;
  42588. var dy = point[1] - itemLayout.cy;
  42589. var radius = Math.sqrt(dx * dx + dy * dy);
  42590. return radius <= itemLayout.r && radius >= itemLayout.r0;
  42591. }
  42592. };
  42593. PieView.type = 'pie';
  42594. return PieView;
  42595. }(ChartView);
  42596. /*
  42597. * Licensed to the Apache Software Foundation (ASF) under one
  42598. * or more contributor license agreements. See the NOTICE file
  42599. * distributed with this work for additional information
  42600. * regarding copyright ownership. The ASF licenses this file
  42601. * to you under the Apache License, Version 2.0 (the
  42602. * "License"); you may not use this file except in compliance
  42603. * with the License. You may obtain a copy of the License at
  42604. *
  42605. * http://www.apache.org/licenses/LICENSE-2.0
  42606. *
  42607. * Unless required by applicable law or agreed to in writing,
  42608. * software distributed under the License is distributed on an
  42609. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42610. * KIND, either express or implied. See the License for the
  42611. * specific language governing permissions and limitations
  42612. * under the License.
  42613. */
  42614. /**
  42615. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42616. */
  42617. /*
  42618. * Licensed to the Apache Software Foundation (ASF) under one
  42619. * or more contributor license agreements. See the NOTICE file
  42620. * distributed with this work for additional information
  42621. * regarding copyright ownership. The ASF licenses this file
  42622. * to you under the Apache License, Version 2.0 (the
  42623. * "License"); you may not use this file except in compliance
  42624. * with the License. You may obtain a copy of the License at
  42625. *
  42626. * http://www.apache.org/licenses/LICENSE-2.0
  42627. *
  42628. * Unless required by applicable law or agreed to in writing,
  42629. * software distributed under the License is distributed on an
  42630. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42631. * KIND, either express or implied. See the License for the
  42632. * specific language governing permissions and limitations
  42633. * under the License.
  42634. */
  42635. /**
  42636. * [Usage]:
  42637. * (1)
  42638. * createListSimply(seriesModel, ['value']);
  42639. * (2)
  42640. * createListSimply(seriesModel, {
  42641. * coordDimensions: ['value'],
  42642. * dimensionsCount: 5
  42643. * });
  42644. */
  42645. function createListSimply(seriesModel, opt, nameList) {
  42646. opt = isArray(opt) && {
  42647. coordDimensions: opt
  42648. } || extend({}, opt);
  42649. var source = seriesModel.getSource();
  42650. var dimensionsInfo = createDimensions(source, opt);
  42651. var list = new List(dimensionsInfo, seriesModel);
  42652. list.initData(source, nameList);
  42653. return list;
  42654. }
  42655. /*
  42656. * Licensed to the Apache Software Foundation (ASF) under one
  42657. * or more contributor license agreements. See the NOTICE file
  42658. * distributed with this work for additional information
  42659. * regarding copyright ownership. The ASF licenses this file
  42660. * to you under the Apache License, Version 2.0 (the
  42661. * "License"); you may not use this file except in compliance
  42662. * with the License. You may obtain a copy of the License at
  42663. *
  42664. * http://www.apache.org/licenses/LICENSE-2.0
  42665. *
  42666. * Unless required by applicable law or agreed to in writing,
  42667. * software distributed under the License is distributed on an
  42668. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42669. * KIND, either express or implied. See the License for the
  42670. * specific language governing permissions and limitations
  42671. * under the License.
  42672. */
  42673. /**
  42674. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42675. */
  42676. /*
  42677. * Licensed to the Apache Software Foundation (ASF) under one
  42678. * or more contributor license agreements. See the NOTICE file
  42679. * distributed with this work for additional information
  42680. * regarding copyright ownership. The ASF licenses this file
  42681. * to you under the Apache License, Version 2.0 (the
  42682. * "License"); you may not use this file except in compliance
  42683. * with the License. You may obtain a copy of the License at
  42684. *
  42685. * http://www.apache.org/licenses/LICENSE-2.0
  42686. *
  42687. * Unless required by applicable law or agreed to in writing,
  42688. * software distributed under the License is distributed on an
  42689. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42690. * KIND, either express or implied. See the License for the
  42691. * specific language governing permissions and limitations
  42692. * under the License.
  42693. */
  42694. /**
  42695. * LegendVisualProvider is an bridge that pick encoded color from data and
  42696. * provide to the legend component.
  42697. */
  42698. var LegendVisualProvider =
  42699. /** @class */
  42700. function () {
  42701. function LegendVisualProvider( // Function to get data after filtered. It stores all the encoding info
  42702. getDataWithEncodedVisual, // Function to get raw data before filtered.
  42703. getRawData) {
  42704. this._getDataWithEncodedVisual = getDataWithEncodedVisual;
  42705. this._getRawData = getRawData;
  42706. }
  42707. LegendVisualProvider.prototype.getAllNames = function () {
  42708. var rawData = this._getRawData(); // We find the name from the raw data. In case it's filtered by the legend component.
  42709. // Normally, the name can be found in rawData, but can't be found in filtered data will display as gray.
  42710. return rawData.mapArray(rawData.getName);
  42711. };
  42712. LegendVisualProvider.prototype.containName = function (name) {
  42713. var rawData = this._getRawData();
  42714. return rawData.indexOfName(name) >= 0;
  42715. };
  42716. LegendVisualProvider.prototype.indexOfName = function (name) {
  42717. // Only get data when necessary.
  42718. // Because LegendVisualProvider constructor may be new in the stage that data is not prepared yet.
  42719. // Invoking Series#getData immediately will throw an error.
  42720. var dataWithEncodedVisual = this._getDataWithEncodedVisual();
  42721. return dataWithEncodedVisual.indexOfName(name);
  42722. };
  42723. LegendVisualProvider.prototype.getItemVisual = function (dataIndex, key) {
  42724. // Get encoded visual properties from final filtered data.
  42725. var dataWithEncodedVisual = this._getDataWithEncodedVisual();
  42726. return dataWithEncodedVisual.getItemVisual(dataIndex, key);
  42727. };
  42728. return LegendVisualProvider;
  42729. }();
  42730. /*
  42731. * Licensed to the Apache Software Foundation (ASF) under one
  42732. * or more contributor license agreements. See the NOTICE file
  42733. * distributed with this work for additional information
  42734. * regarding copyright ownership. The ASF licenses this file
  42735. * to you under the Apache License, Version 2.0 (the
  42736. * "License"); you may not use this file except in compliance
  42737. * with the License. You may obtain a copy of the License at
  42738. *
  42739. * http://www.apache.org/licenses/LICENSE-2.0
  42740. *
  42741. * Unless required by applicable law or agreed to in writing,
  42742. * software distributed under the License is distributed on an
  42743. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42744. * KIND, either express or implied. See the License for the
  42745. * specific language governing permissions and limitations
  42746. * under the License.
  42747. */
  42748. /**
  42749. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42750. */
  42751. /*
  42752. * Licensed to the Apache Software Foundation (ASF) under one
  42753. * or more contributor license agreements. See the NOTICE file
  42754. * distributed with this work for additional information
  42755. * regarding copyright ownership. The ASF licenses this file
  42756. * to you under the Apache License, Version 2.0 (the
  42757. * "License"); you may not use this file except in compliance
  42758. * with the License. You may obtain a copy of the License at
  42759. *
  42760. * http://www.apache.org/licenses/LICENSE-2.0
  42761. *
  42762. * Unless required by applicable law or agreed to in writing,
  42763. * software distributed under the License is distributed on an
  42764. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42765. * KIND, either express or implied. See the License for the
  42766. * specific language governing permissions and limitations
  42767. * under the License.
  42768. */
  42769. var PieSeriesModel =
  42770. /** @class */
  42771. function (_super) {
  42772. __extends(PieSeriesModel, _super);
  42773. function PieSeriesModel() {
  42774. var _this = _super !== null && _super.apply(this, arguments) || this;
  42775. _this.useColorPaletteOnData = true;
  42776. return _this;
  42777. }
  42778. /**
  42779. * @overwrite
  42780. */
  42781. PieSeriesModel.prototype.init = function (option) {
  42782. _super.prototype.init.apply(this, arguments); // Enable legend selection for each data item
  42783. // Use a function instead of direct access because data reference may changed
  42784. this.legendVisualProvider = new LegendVisualProvider(bind(this.getData, this), bind(this.getRawData, this));
  42785. this._defaultLabelLine(option);
  42786. };
  42787. /**
  42788. * @overwrite
  42789. */
  42790. PieSeriesModel.prototype.mergeOption = function () {
  42791. _super.prototype.mergeOption.apply(this, arguments);
  42792. };
  42793. /**
  42794. * @overwrite
  42795. */
  42796. PieSeriesModel.prototype.getInitialData = function () {
  42797. return createListSimply(this, {
  42798. coordDimensions: ['value'],
  42799. encodeDefaulter: curry(makeSeriesEncodeForNameBased, this)
  42800. });
  42801. };
  42802. /**
  42803. * @overwrite
  42804. */
  42805. PieSeriesModel.prototype.getDataParams = function (dataIndex) {
  42806. var data = this.getData();
  42807. var params = _super.prototype.getDataParams.call(this, dataIndex); // FIXME toFixed?
  42808. var valueList = [];
  42809. data.each(data.mapDimension('value'), function (value) {
  42810. valueList.push(value);
  42811. });
  42812. params.percent = getPercentWithPrecision(valueList, dataIndex, data.hostModel.get('percentPrecision'));
  42813. params.$vars.push('percent');
  42814. return params;
  42815. };
  42816. PieSeriesModel.prototype._defaultLabelLine = function (option) {
  42817. // Extend labelLine emphasis
  42818. defaultEmphasis(option, 'labelLine', ['show']);
  42819. var labelLineNormalOpt = option.labelLine;
  42820. var labelLineEmphasisOpt = option.emphasis.labelLine; // Not show label line if `label.normal.show = false`
  42821. labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
  42822. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
  42823. };
  42824. PieSeriesModel.type = 'series.pie';
  42825. PieSeriesModel.defaultOption = {
  42826. zlevel: 0,
  42827. z: 2,
  42828. legendHoverLink: true,
  42829. // 默认全局居中
  42830. center: ['50%', '50%'],
  42831. radius: [0, '75%'],
  42832. // 默认顺时针
  42833. clockwise: true,
  42834. startAngle: 90,
  42835. // 最小角度改为0
  42836. minAngle: 0,
  42837. // If the angle of a sector less than `minShowLabelAngle`,
  42838. // the label will not be displayed.
  42839. minShowLabelAngle: 0,
  42840. // 选中时扇区偏移量
  42841. selectedOffset: 10,
  42842. // 选择模式,默认关闭,可选single,multiple
  42843. // selectedMode: false,
  42844. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  42845. // roseType: null,
  42846. percentPrecision: 2,
  42847. // If still show when all data zero.
  42848. stillShowZeroSum: true,
  42849. // cursor: null,
  42850. left: 0,
  42851. top: 0,
  42852. right: 0,
  42853. bottom: 0,
  42854. width: null,
  42855. height: null,
  42856. label: {
  42857. // color: 'inherit',
  42858. // If rotate around circle
  42859. rotate: 0,
  42860. show: true,
  42861. overflow: 'truncate',
  42862. // 'outer', 'inside', 'center'
  42863. position: 'outer',
  42864. // 'none', 'labelLine', 'edge'. Works only when position is 'outer'
  42865. alignTo: 'none',
  42866. // Closest distance between label and chart edge.
  42867. // Works only position is 'outer' and alignTo is 'edge'.
  42868. edgeDistance: '25%',
  42869. // Works only position is 'outer' and alignTo is not 'edge'.
  42870. bleedMargin: 10,
  42871. // Distance between text and label line.
  42872. distanceToLabelLine: 5 // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  42873. // 默认使用全局文本样式,详见TEXTSTYLE
  42874. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  42875. },
  42876. // Enabled when label.normal.position is 'outer'
  42877. labelLine: {
  42878. show: true,
  42879. // 引导线两段中的第一段长度
  42880. length: 15,
  42881. // 引导线两段中的第二段长度
  42882. length2: 15,
  42883. smooth: false,
  42884. minTurnAngle: 90,
  42885. maxSurfaceAngle: 90,
  42886. lineStyle: {
  42887. // color: 各异,
  42888. width: 1,
  42889. type: 'solid'
  42890. }
  42891. },
  42892. itemStyle: {
  42893. borderWidth: 1
  42894. },
  42895. labelLayout: {
  42896. // Hide the overlapped label.
  42897. hideOverlap: true
  42898. },
  42899. emphasis: {
  42900. scale: true,
  42901. scaleSize: 5
  42902. },
  42903. // If use strategy to avoid label overlapping
  42904. avoidLabelOverlap: true,
  42905. // Animation type. Valid values: expansion, scale
  42906. animationType: 'expansion',
  42907. animationDuration: 1000,
  42908. // Animation type when update. Valid values: transition, expansion
  42909. animationTypeUpdate: 'transition',
  42910. animationEasingUpdate: 'cubicInOut',
  42911. animationDurationUpdate: 500,
  42912. animationEasing: 'cubicInOut'
  42913. };
  42914. return PieSeriesModel;
  42915. }(SeriesModel);
  42916. /*
  42917. * Licensed to the Apache Software Foundation (ASF) under one
  42918. * or more contributor license agreements. See the NOTICE file
  42919. * distributed with this work for additional information
  42920. * regarding copyright ownership. The ASF licenses this file
  42921. * to you under the Apache License, Version 2.0 (the
  42922. * "License"); you may not use this file except in compliance
  42923. * with the License. You may obtain a copy of the License at
  42924. *
  42925. * http://www.apache.org/licenses/LICENSE-2.0
  42926. *
  42927. * Unless required by applicable law or agreed to in writing,
  42928. * software distributed under the License is distributed on an
  42929. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42930. * KIND, either express or implied. See the License for the
  42931. * specific language governing permissions and limitations
  42932. * under the License.
  42933. */
  42934. /**
  42935. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42936. */
  42937. /*
  42938. * Licensed to the Apache Software Foundation (ASF) under one
  42939. * or more contributor license agreements. See the NOTICE file
  42940. * distributed with this work for additional information
  42941. * regarding copyright ownership. The ASF licenses this file
  42942. * to you under the Apache License, Version 2.0 (the
  42943. * "License"); you may not use this file except in compliance
  42944. * with the License. You may obtain a copy of the License at
  42945. *
  42946. * http://www.apache.org/licenses/LICENSE-2.0
  42947. *
  42948. * Unless required by applicable law or agreed to in writing,
  42949. * software distributed under the License is distributed on an
  42950. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42951. * KIND, either express or implied. See the License for the
  42952. * specific language governing permissions and limitations
  42953. * under the License.
  42954. */
  42955. function install$4(registers) {
  42956. registers.registerChartView(PieView);
  42957. registers.registerSeriesModel(PieSeriesModel);
  42958. createLegacyDataSelectAction('pie', registers.registerAction);
  42959. registers.registerLayout(curry(pieLayout, 'pie'));
  42960. registers.registerProcessor(dataFilter('pie'));
  42961. }
  42962. /*
  42963. * Licensed to the Apache Software Foundation (ASF) under one
  42964. * or more contributor license agreements. See the NOTICE file
  42965. * distributed with this work for additional information
  42966. * regarding copyright ownership. The ASF licenses this file
  42967. * to you under the Apache License, Version 2.0 (the
  42968. * "License"); you may not use this file except in compliance
  42969. * with the License. You may obtain a copy of the License at
  42970. *
  42971. * http://www.apache.org/licenses/LICENSE-2.0
  42972. *
  42973. * Unless required by applicable law or agreed to in writing,
  42974. * software distributed under the License is distributed on an
  42975. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42976. * KIND, either express or implied. See the License for the
  42977. * specific language governing permissions and limitations
  42978. * under the License.
  42979. */
  42980. /**
  42981. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42982. */
  42983. /*
  42984. * Licensed to the Apache Software Foundation (ASF) under one
  42985. * or more contributor license agreements. See the NOTICE file
  42986. * distributed with this work for additional information
  42987. * regarding copyright ownership. The ASF licenses this file
  42988. * to you under the Apache License, Version 2.0 (the
  42989. * "License"); you may not use this file except in compliance
  42990. * with the License. You may obtain a copy of the License at
  42991. *
  42992. * http://www.apache.org/licenses/LICENSE-2.0
  42993. *
  42994. * Unless required by applicable law or agreed to in writing,
  42995. * software distributed under the License is distributed on an
  42996. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42997. * KIND, either express or implied. See the License for the
  42998. * specific language governing permissions and limitations
  42999. * under the License.
  43000. */
  43001. use(install$4);
  43002. /*
  43003. * Licensed to the Apache Software Foundation (ASF) under one
  43004. * or more contributor license agreements. See the NOTICE file
  43005. * distributed with this work for additional information
  43006. * regarding copyright ownership. The ASF licenses this file
  43007. * to you under the Apache License, Version 2.0 (the
  43008. * "License"); you may not use this file except in compliance
  43009. * with the License. You may obtain a copy of the License at
  43010. *
  43011. * http://www.apache.org/licenses/LICENSE-2.0
  43012. *
  43013. * Unless required by applicable law or agreed to in writing,
  43014. * software distributed under the License is distributed on an
  43015. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43016. * KIND, either express or implied. See the License for the
  43017. * specific language governing permissions and limitations
  43018. * under the License.
  43019. */
  43020. /**
  43021. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43022. */
  43023. /*
  43024. * Licensed to the Apache Software Foundation (ASF) under one
  43025. * or more contributor license agreements. See the NOTICE file
  43026. * distributed with this work for additional information
  43027. * regarding copyright ownership. The ASF licenses this file
  43028. * to you under the Apache License, Version 2.0 (the
  43029. * "License"); you may not use this file except in compliance
  43030. * with the License. You may obtain a copy of the License at
  43031. *
  43032. * http://www.apache.org/licenses/LICENSE-2.0
  43033. *
  43034. * Unless required by applicable law or agreed to in writing,
  43035. * software distributed under the License is distributed on an
  43036. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43037. * KIND, either express or implied. See the License for the
  43038. * specific language governing permissions and limitations
  43039. * under the License.
  43040. */
  43041. var ScatterSeriesModel =
  43042. /** @class */
  43043. function (_super) {
  43044. __extends(ScatterSeriesModel, _super);
  43045. function ScatterSeriesModel() {
  43046. var _this = _super !== null && _super.apply(this, arguments) || this;
  43047. _this.type = ScatterSeriesModel.type;
  43048. _this.hasSymbolVisual = true;
  43049. return _this;
  43050. }
  43051. ScatterSeriesModel.prototype.getInitialData = function (option, ecModel) {
  43052. return createListFromArray(this.getSource(), this, {
  43053. useEncodeDefaulter: true
  43054. });
  43055. };
  43056. ScatterSeriesModel.prototype.getProgressive = function () {
  43057. var progressive = this.option.progressive;
  43058. if (progressive == null) {
  43059. // PENDING
  43060. return this.option.large ? 5e3 : this.get('progressive');
  43061. }
  43062. return progressive;
  43063. };
  43064. ScatterSeriesModel.prototype.getProgressiveThreshold = function () {
  43065. var progressiveThreshold = this.option.progressiveThreshold;
  43066. if (progressiveThreshold == null) {
  43067. // PENDING
  43068. return this.option.large ? 1e4 : this.get('progressiveThreshold');
  43069. }
  43070. return progressiveThreshold;
  43071. };
  43072. ScatterSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
  43073. return selectors.point(data.getItemLayout(dataIndex));
  43074. };
  43075. ScatterSeriesModel.type = 'series.scatter';
  43076. ScatterSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar'];
  43077. ScatterSeriesModel.defaultOption = {
  43078. coordinateSystem: 'cartesian2d',
  43079. zlevel: 0,
  43080. z: 2,
  43081. legendHoverLink: true,
  43082. symbolSize: 10,
  43083. // symbolRotate: null, // 图形旋转控制
  43084. large: false,
  43085. // Available when large is true
  43086. largeThreshold: 2000,
  43087. // cursor: null,
  43088. itemStyle: {
  43089. opacity: 0.8 // color: 各异
  43090. },
  43091. emphasis: {
  43092. scale: true
  43093. },
  43094. // If clip the overflow graphics
  43095. // Works on cartesian / polar series
  43096. clip: true,
  43097. select: {
  43098. itemStyle: {
  43099. borderColor: '#212121'
  43100. }
  43101. } // progressive: null
  43102. };
  43103. return ScatterSeriesModel;
  43104. }(SeriesModel);
  43105. /*
  43106. * Licensed to the Apache Software Foundation (ASF) under one
  43107. * or more contributor license agreements. See the NOTICE file
  43108. * distributed with this work for additional information
  43109. * regarding copyright ownership. The ASF licenses this file
  43110. * to you under the Apache License, Version 2.0 (the
  43111. * "License"); you may not use this file except in compliance
  43112. * with the License. You may obtain a copy of the License at
  43113. *
  43114. * http://www.apache.org/licenses/LICENSE-2.0
  43115. *
  43116. * Unless required by applicable law or agreed to in writing,
  43117. * software distributed under the License is distributed on an
  43118. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43119. * KIND, either express or implied. See the License for the
  43120. * specific language governing permissions and limitations
  43121. * under the License.
  43122. */
  43123. /**
  43124. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43125. */
  43126. /*
  43127. * Licensed to the Apache Software Foundation (ASF) under one
  43128. * or more contributor license agreements. See the NOTICE file
  43129. * distributed with this work for additional information
  43130. * regarding copyright ownership. The ASF licenses this file
  43131. * to you under the Apache License, Version 2.0 (the
  43132. * "License"); you may not use this file except in compliance
  43133. * with the License. You may obtain a copy of the License at
  43134. *
  43135. * http://www.apache.org/licenses/LICENSE-2.0
  43136. *
  43137. * Unless required by applicable law or agreed to in writing,
  43138. * software distributed under the License is distributed on an
  43139. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43140. * KIND, either express or implied. See the License for the
  43141. * specific language governing permissions and limitations
  43142. * under the License.
  43143. */
  43144. /* global Float32Array */
  43145. // TODO Batch by color
  43146. var BOOST_SIZE_THRESHOLD = 4;
  43147. var LargeSymbolPathShape =
  43148. /** @class */
  43149. function () {
  43150. function LargeSymbolPathShape() {}
  43151. return LargeSymbolPathShape;
  43152. }();
  43153. var LargeSymbolPath =
  43154. /** @class */
  43155. function (_super) {
  43156. __extends(LargeSymbolPath, _super);
  43157. function LargeSymbolPath(opts) {
  43158. return _super.call(this, opts) || this;
  43159. }
  43160. LargeSymbolPath.prototype.getDefaultShape = function () {
  43161. return new LargeSymbolPathShape();
  43162. };
  43163. LargeSymbolPath.prototype.buildPath = function (path, shape) {
  43164. var points = shape.points;
  43165. var size = shape.size;
  43166. var symbolProxy = this.symbolProxy;
  43167. var symbolProxyShape = symbolProxy.shape;
  43168. var ctx = path.getContext ? path.getContext() : path;
  43169. var canBoost = ctx && size[0] < BOOST_SIZE_THRESHOLD; // Do draw in afterBrush.
  43170. if (canBoost) {
  43171. this._ctx = ctx;
  43172. return;
  43173. }
  43174. this._ctx = null;
  43175. for (var i = 0; i < points.length;) {
  43176. var x = points[i++];
  43177. var y = points[i++];
  43178. if (isNaN(x) || isNaN(y)) {
  43179. continue;
  43180. }
  43181. if (this.softClipShape && !this.softClipShape.contain(x, y)) {
  43182. continue;
  43183. }
  43184. symbolProxyShape.x = x - size[0] / 2;
  43185. symbolProxyShape.y = y - size[1] / 2;
  43186. symbolProxyShape.width = size[0];
  43187. symbolProxyShape.height = size[1];
  43188. symbolProxy.buildPath(path, symbolProxyShape, true);
  43189. }
  43190. };
  43191. LargeSymbolPath.prototype.afterBrush = function () {
  43192. var shape = this.shape;
  43193. var points = shape.points;
  43194. var size = shape.size;
  43195. var ctx = this._ctx;
  43196. if (!ctx) {
  43197. return;
  43198. } // PENDING If style or other canvas status changed?
  43199. for (var i = 0; i < points.length;) {
  43200. var x = points[i++];
  43201. var y = points[i++];
  43202. if (isNaN(x) || isNaN(y)) {
  43203. continue;
  43204. }
  43205. if (this.softClipShape && !this.softClipShape.contain(x, y)) {
  43206. continue;
  43207. } // fillRect is faster than building a rect path and draw.
  43208. // And it support light globalCompositeOperation.
  43209. ctx.fillRect(x - size[0] / 2, y - size[1] / 2, size[0], size[1]);
  43210. }
  43211. };
  43212. LargeSymbolPath.prototype.findDataIndex = function (x, y) {
  43213. // TODO ???
  43214. // Consider transform
  43215. var shape = this.shape;
  43216. var points = shape.points;
  43217. var size = shape.size;
  43218. var w = Math.max(size[0], 4);
  43219. var h = Math.max(size[1], 4); // Not consider transform
  43220. // Treat each element as a rect
  43221. // top down traverse
  43222. for (var idx = points.length / 2 - 1; idx >= 0; idx--) {
  43223. var i = idx * 2;
  43224. var x0 = points[i] - w / 2;
  43225. var y0 = points[i + 1] - h / 2;
  43226. if (x >= x0 && y >= y0 && x <= x0 + w && y <= y0 + h) {
  43227. return idx;
  43228. }
  43229. }
  43230. return -1;
  43231. };
  43232. return LargeSymbolPath;
  43233. }(Path);
  43234. var LargeSymbolDraw =
  43235. /** @class */
  43236. function () {
  43237. function LargeSymbolDraw() {
  43238. this.group = new Group();
  43239. }
  43240. LargeSymbolDraw.prototype.isPersistent = function () {
  43241. return !this._incremental;
  43242. };
  43243. /**
  43244. * Update symbols draw by new data
  43245. */
  43246. LargeSymbolDraw.prototype.updateData = function (data, opt) {
  43247. this.group.removeAll();
  43248. var symbolEl = new LargeSymbolPath({
  43249. rectHover: true,
  43250. cursor: 'default'
  43251. });
  43252. symbolEl.setShape({
  43253. points: data.getLayout('points')
  43254. });
  43255. this._setCommon(symbolEl, data, false, opt);
  43256. this.group.add(symbolEl);
  43257. this._incremental = null;
  43258. };
  43259. LargeSymbolDraw.prototype.updateLayout = function (data) {
  43260. if (this._incremental) {
  43261. return;
  43262. }
  43263. var points = data.getLayout('points');
  43264. this.group.eachChild(function (child) {
  43265. if (child.startIndex != null) {
  43266. var len = (child.endIndex - child.startIndex) * 2;
  43267. var byteOffset = child.startIndex * 4 * 2;
  43268. points = new Float32Array(points.buffer, byteOffset, len);
  43269. }
  43270. child.setShape('points', points);
  43271. });
  43272. };
  43273. LargeSymbolDraw.prototype.incrementalPrepareUpdate = function (data) {
  43274. this.group.removeAll();
  43275. this._clearIncremental(); // Only use incremental displayables when data amount is larger than 2 million.
  43276. // PENDING Incremental data?
  43277. if (data.count() > 2e6) {
  43278. if (!this._incremental) {
  43279. this._incremental = new IncrementalDisplayable({
  43280. silent: true
  43281. });
  43282. }
  43283. this.group.add(this._incremental);
  43284. } else {
  43285. this._incremental = null;
  43286. }
  43287. };
  43288. LargeSymbolDraw.prototype.incrementalUpdate = function (taskParams, data, opt) {
  43289. var symbolEl;
  43290. if (this._incremental) {
  43291. symbolEl = new LargeSymbolPath();
  43292. this._incremental.addDisplayable(symbolEl, true);
  43293. } else {
  43294. symbolEl = new LargeSymbolPath({
  43295. rectHover: true,
  43296. cursor: 'default',
  43297. startIndex: taskParams.start,
  43298. endIndex: taskParams.end
  43299. });
  43300. symbolEl.incremental = true;
  43301. this.group.add(symbolEl);
  43302. }
  43303. symbolEl.setShape({
  43304. points: data.getLayout('points')
  43305. });
  43306. this._setCommon(symbolEl, data, !!this._incremental, opt);
  43307. };
  43308. LargeSymbolDraw.prototype._setCommon = function (symbolEl, data, isIncremental, opt) {
  43309. var hostModel = data.hostModel;
  43310. opt = opt || {};
  43311. var size = data.getVisual('symbolSize');
  43312. symbolEl.setShape('size', size instanceof Array ? size : [size, size]);
  43313. symbolEl.softClipShape = opt.clipShape || null; // Create symbolProxy to build path for each data
  43314. symbolEl.symbolProxy = createSymbol(data.getVisual('symbol'), 0, 0, 0, 0); // Use symbolProxy setColor method
  43315. symbolEl.setColor = symbolEl.symbolProxy.setColor;
  43316. var extrudeShadow = symbolEl.shape.size[0] < BOOST_SIZE_THRESHOLD;
  43317. symbolEl.useStyle( // Draw shadow when doing fillRect is extremely slow.
  43318. hostModel.getModel('itemStyle').getItemStyle(extrudeShadow ? ['color', 'shadowBlur', 'shadowColor'] : ['color']));
  43319. var globalStyle = data.getVisual('style');
  43320. var visualColor = globalStyle && globalStyle.fill;
  43321. if (visualColor) {
  43322. symbolEl.setColor(visualColor);
  43323. }
  43324. if (!isIncremental) {
  43325. var ecData_1 = getECData(symbolEl); // Enable tooltip
  43326. // PENDING May have performance issue when path is extremely large
  43327. ecData_1.seriesIndex = hostModel.seriesIndex;
  43328. symbolEl.on('mousemove', function (e) {
  43329. ecData_1.dataIndex = null;
  43330. var dataIndex = symbolEl.findDataIndex(e.offsetX, e.offsetY);
  43331. if (dataIndex >= 0) {
  43332. // Provide dataIndex for tooltip
  43333. ecData_1.dataIndex = dataIndex + (symbolEl.startIndex || 0);
  43334. }
  43335. });
  43336. }
  43337. };
  43338. LargeSymbolDraw.prototype.remove = function () {
  43339. this._clearIncremental();
  43340. this._incremental = null;
  43341. this.group.removeAll();
  43342. };
  43343. LargeSymbolDraw.prototype._clearIncremental = function () {
  43344. var incremental = this._incremental;
  43345. if (incremental) {
  43346. incremental.clearDisplaybles();
  43347. }
  43348. };
  43349. return LargeSymbolDraw;
  43350. }();
  43351. /*
  43352. * Licensed to the Apache Software Foundation (ASF) under one
  43353. * or more contributor license agreements. See the NOTICE file
  43354. * distributed with this work for additional information
  43355. * regarding copyright ownership. The ASF licenses this file
  43356. * to you under the Apache License, Version 2.0 (the
  43357. * "License"); you may not use this file except in compliance
  43358. * with the License. You may obtain a copy of the License at
  43359. *
  43360. * http://www.apache.org/licenses/LICENSE-2.0
  43361. *
  43362. * Unless required by applicable law or agreed to in writing,
  43363. * software distributed under the License is distributed on an
  43364. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43365. * KIND, either express or implied. See the License for the
  43366. * specific language governing permissions and limitations
  43367. * under the License.
  43368. */
  43369. /**
  43370. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43371. */
  43372. /*
  43373. * Licensed to the Apache Software Foundation (ASF) under one
  43374. * or more contributor license agreements. See the NOTICE file
  43375. * distributed with this work for additional information
  43376. * regarding copyright ownership. The ASF licenses this file
  43377. * to you under the Apache License, Version 2.0 (the
  43378. * "License"); you may not use this file except in compliance
  43379. * with the License. You may obtain a copy of the License at
  43380. *
  43381. * http://www.apache.org/licenses/LICENSE-2.0
  43382. *
  43383. * Unless required by applicable law or agreed to in writing,
  43384. * software distributed under the License is distributed on an
  43385. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43386. * KIND, either express or implied. See the License for the
  43387. * specific language governing permissions and limitations
  43388. * under the License.
  43389. */
  43390. var ScatterView =
  43391. /** @class */
  43392. function (_super) {
  43393. __extends(ScatterView, _super);
  43394. function ScatterView() {
  43395. var _this = _super !== null && _super.apply(this, arguments) || this;
  43396. _this.type = ScatterView.type;
  43397. return _this;
  43398. }
  43399. ScatterView.prototype.render = function (seriesModel, ecModel, api) {
  43400. var data = seriesModel.getData();
  43401. var symbolDraw = this._updateSymbolDraw(data, seriesModel);
  43402. symbolDraw.updateData(data, {
  43403. // TODO
  43404. // If this parameter should be a shape or a bounding volume
  43405. // shape will be more general.
  43406. // But bounding volume like bounding rect will be much faster in the contain calculation
  43407. clipShape: this._getClipShape(seriesModel)
  43408. });
  43409. this._finished = true;
  43410. };
  43411. ScatterView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
  43412. var data = seriesModel.getData();
  43413. var symbolDraw = this._updateSymbolDraw(data, seriesModel);
  43414. symbolDraw.incrementalPrepareUpdate(data);
  43415. this._finished = false;
  43416. };
  43417. ScatterView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
  43418. this._symbolDraw.incrementalUpdate(taskParams, seriesModel.getData(), {
  43419. clipShape: this._getClipShape(seriesModel)
  43420. });
  43421. this._finished = taskParams.end === seriesModel.getData().count();
  43422. };
  43423. ScatterView.prototype.updateTransform = function (seriesModel, ecModel, api) {
  43424. var data = seriesModel.getData(); // Must mark group dirty and make sure the incremental layer will be cleared
  43425. // PENDING
  43426. this.group.dirty();
  43427. if (!this._finished || data.count() > 1e4 || !this._symbolDraw.isPersistent()) {
  43428. return {
  43429. update: true
  43430. };
  43431. } else {
  43432. var res = pointsLayout('').reset(seriesModel, ecModel, api);
  43433. if (res.progress) {
  43434. res.progress({
  43435. start: 0,
  43436. end: data.count(),
  43437. count: data.count()
  43438. }, data);
  43439. }
  43440. this._symbolDraw.updateLayout(data);
  43441. }
  43442. };
  43443. ScatterView.prototype._getClipShape = function (seriesModel) {
  43444. var coordSys = seriesModel.coordinateSystem;
  43445. var clipArea = coordSys && coordSys.getArea && coordSys.getArea();
  43446. return seriesModel.get('clip', true) ? clipArea : null;
  43447. };
  43448. ScatterView.prototype._updateSymbolDraw = function (data, seriesModel) {
  43449. var symbolDraw = this._symbolDraw;
  43450. var pipelineContext = seriesModel.pipelineContext;
  43451. var isLargeDraw = pipelineContext.large;
  43452. if (!symbolDraw || isLargeDraw !== this._isLargeDraw) {
  43453. symbolDraw && symbolDraw.remove();
  43454. symbolDraw = this._symbolDraw = isLargeDraw ? new LargeSymbolDraw() : new SymbolDraw();
  43455. this._isLargeDraw = isLargeDraw;
  43456. this.group.removeAll();
  43457. }
  43458. this.group.add(symbolDraw.group);
  43459. return symbolDraw;
  43460. };
  43461. ScatterView.prototype.remove = function (ecModel, api) {
  43462. this._symbolDraw && this._symbolDraw.remove(true);
  43463. this._symbolDraw = null;
  43464. };
  43465. ScatterView.prototype.dispose = function () {};
  43466. ScatterView.type = 'scatter';
  43467. return ScatterView;
  43468. }(ChartView);
  43469. /*
  43470. * Licensed to the Apache Software Foundation (ASF) under one
  43471. * or more contributor license agreements. See the NOTICE file
  43472. * distributed with this work for additional information
  43473. * regarding copyright ownership. The ASF licenses this file
  43474. * to you under the Apache License, Version 2.0 (the
  43475. * "License"); you may not use this file except in compliance
  43476. * with the License. You may obtain a copy of the License at
  43477. *
  43478. * http://www.apache.org/licenses/LICENSE-2.0
  43479. *
  43480. * Unless required by applicable law or agreed to in writing,
  43481. * software distributed under the License is distributed on an
  43482. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43483. * KIND, either express or implied. See the License for the
  43484. * specific language governing permissions and limitations
  43485. * under the License.
  43486. */
  43487. /**
  43488. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43489. */
  43490. /*
  43491. * Licensed to the Apache Software Foundation (ASF) under one
  43492. * or more contributor license agreements. See the NOTICE file
  43493. * distributed with this work for additional information
  43494. * regarding copyright ownership. The ASF licenses this file
  43495. * to you under the Apache License, Version 2.0 (the
  43496. * "License"); you may not use this file except in compliance
  43497. * with the License. You may obtain a copy of the License at
  43498. *
  43499. * http://www.apache.org/licenses/LICENSE-2.0
  43500. *
  43501. * Unless required by applicable law or agreed to in writing,
  43502. * software distributed under the License is distributed on an
  43503. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43504. * KIND, either express or implied. See the License for the
  43505. * specific language governing permissions and limitations
  43506. * under the License.
  43507. */
  43508. var GridModel =
  43509. /** @class */
  43510. function (_super) {
  43511. __extends(GridModel, _super);
  43512. function GridModel() {
  43513. return _super !== null && _super.apply(this, arguments) || this;
  43514. }
  43515. GridModel.type = 'grid';
  43516. GridModel.dependencies = ['xAxis', 'yAxis'];
  43517. GridModel.layoutMode = 'box';
  43518. GridModel.defaultOption = {
  43519. show: false,
  43520. zlevel: 0,
  43521. z: 0,
  43522. left: '10%',
  43523. top: 60,
  43524. right: '10%',
  43525. bottom: 70,
  43526. // If grid size contain label
  43527. containLabel: false,
  43528. // width: {totalWidth} - left - right,
  43529. // height: {totalHeight} - top - bottom,
  43530. backgroundColor: 'rgba(0,0,0,0)',
  43531. borderWidth: 1,
  43532. borderColor: '#ccc'
  43533. };
  43534. return GridModel;
  43535. }(ComponentModel);
  43536. /*
  43537. * Licensed to the Apache Software Foundation (ASF) under one
  43538. * or more contributor license agreements. See the NOTICE file
  43539. * distributed with this work for additional information
  43540. * regarding copyright ownership. The ASF licenses this file
  43541. * to you under the Apache License, Version 2.0 (the
  43542. * "License"); you may not use this file except in compliance
  43543. * with the License. You may obtain a copy of the License at
  43544. *
  43545. * http://www.apache.org/licenses/LICENSE-2.0
  43546. *
  43547. * Unless required by applicable law or agreed to in writing,
  43548. * software distributed under the License is distributed on an
  43549. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43550. * KIND, either express or implied. See the License for the
  43551. * specific language governing permissions and limitations
  43552. * under the License.
  43553. */
  43554. /**
  43555. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43556. */
  43557. /*
  43558. * Licensed to the Apache Software Foundation (ASF) under one
  43559. * or more contributor license agreements. See the NOTICE file
  43560. * distributed with this work for additional information
  43561. * regarding copyright ownership. The ASF licenses this file
  43562. * to you under the Apache License, Version 2.0 (the
  43563. * "License"); you may not use this file except in compliance
  43564. * with the License. You may obtain a copy of the License at
  43565. *
  43566. * http://www.apache.org/licenses/LICENSE-2.0
  43567. *
  43568. * Unless required by applicable law or agreed to in writing,
  43569. * software distributed under the License is distributed on an
  43570. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43571. * KIND, either express or implied. See the License for the
  43572. * specific language governing permissions and limitations
  43573. * under the License.
  43574. */
  43575. var CartesianAxisModel =
  43576. /** @class */
  43577. function (_super) {
  43578. __extends(CartesianAxisModel, _super);
  43579. function CartesianAxisModel() {
  43580. return _super !== null && _super.apply(this, arguments) || this;
  43581. }
  43582. CartesianAxisModel.prototype.getCoordSysModel = function () {
  43583. return this.getReferringComponents('grid', SINGLE_REFERRING).models[0];
  43584. };
  43585. CartesianAxisModel.type = 'cartesian2dAxis';
  43586. return CartesianAxisModel;
  43587. }(ComponentModel);
  43588. mixin(CartesianAxisModel, AxisModelCommonMixin);
  43589. /*
  43590. * Licensed to the Apache Software Foundation (ASF) under one
  43591. * or more contributor license agreements. See the NOTICE file
  43592. * distributed with this work for additional information
  43593. * regarding copyright ownership. The ASF licenses this file
  43594. * to you under the Apache License, Version 2.0 (the
  43595. * "License"); you may not use this file except in compliance
  43596. * with the License. You may obtain a copy of the License at
  43597. *
  43598. * http://www.apache.org/licenses/LICENSE-2.0
  43599. *
  43600. * Unless required by applicable law or agreed to in writing,
  43601. * software distributed under the License is distributed on an
  43602. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43603. * KIND, either express or implied. See the License for the
  43604. * specific language governing permissions and limitations
  43605. * under the License.
  43606. */
  43607. /**
  43608. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43609. */
  43610. /*
  43611. * Licensed to the Apache Software Foundation (ASF) under one
  43612. * or more contributor license agreements. See the NOTICE file
  43613. * distributed with this work for additional information
  43614. * regarding copyright ownership. The ASF licenses this file
  43615. * to you under the Apache License, Version 2.0 (the
  43616. * "License"); you may not use this file except in compliance
  43617. * with the License. You may obtain a copy of the License at
  43618. *
  43619. * http://www.apache.org/licenses/LICENSE-2.0
  43620. *
  43621. * Unless required by applicable law or agreed to in writing,
  43622. * software distributed under the License is distributed on an
  43623. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43624. * KIND, either express or implied. See the License for the
  43625. * specific language governing permissions and limitations
  43626. * under the License.
  43627. */
  43628. var defaultOption = {
  43629. show: true,
  43630. zlevel: 0,
  43631. z: 0,
  43632. // Inverse the axis.
  43633. inverse: false,
  43634. // Axis name displayed.
  43635. name: '',
  43636. // 'start' | 'middle' | 'end'
  43637. nameLocation: 'end',
  43638. // By degree. By default auto rotate by nameLocation.
  43639. nameRotate: null,
  43640. nameTruncate: {
  43641. maxWidth: null,
  43642. ellipsis: '...',
  43643. placeholder: '.'
  43644. },
  43645. // Use global text style by default.
  43646. nameTextStyle: {},
  43647. // The gap between axisName and axisLine.
  43648. nameGap: 15,
  43649. // Default `false` to support tooltip.
  43650. silent: false,
  43651. // Default `false` to avoid legacy user event listener fail.
  43652. triggerEvent: false,
  43653. tooltip: {
  43654. show: false
  43655. },
  43656. axisPointer: {},
  43657. axisLine: {
  43658. show: true,
  43659. onZero: true,
  43660. onZeroAxisIndex: null,
  43661. lineStyle: {
  43662. color: '#6E7079',
  43663. width: 1,
  43664. type: 'solid'
  43665. },
  43666. // The arrow at both ends the the axis.
  43667. symbol: ['none', 'none'],
  43668. symbolSize: [10, 15]
  43669. },
  43670. axisTick: {
  43671. show: true,
  43672. // Whether axisTick is inside the grid or outside the grid.
  43673. inside: false,
  43674. // The length of axisTick.
  43675. length: 5,
  43676. lineStyle: {
  43677. width: 1
  43678. }
  43679. },
  43680. axisLabel: {
  43681. show: true,
  43682. // Whether axisLabel is inside the grid or outside the grid.
  43683. inside: false,
  43684. rotate: 0,
  43685. // true | false | null/undefined (auto)
  43686. showMinLabel: null,
  43687. // true | false | null/undefined (auto)
  43688. showMaxLabel: null,
  43689. margin: 8,
  43690. // formatter: null,
  43691. fontSize: 12
  43692. },
  43693. splitLine: {
  43694. show: true,
  43695. lineStyle: {
  43696. color: ['#E0E6F1'],
  43697. width: 1,
  43698. type: 'solid'
  43699. }
  43700. },
  43701. splitArea: {
  43702. show: false,
  43703. areaStyle: {
  43704. color: ['rgba(250,250,250,0.2)', 'rgba(210,219,238,0.2)']
  43705. }
  43706. }
  43707. };
  43708. var categoryAxis = merge({
  43709. // The gap at both ends of the axis. For categoryAxis, boolean.
  43710. boundaryGap: true,
  43711. // Set false to faster category collection.
  43712. deduplication: null,
  43713. // splitArea: {
  43714. // show: false
  43715. // },
  43716. splitLine: {
  43717. show: false
  43718. },
  43719. axisTick: {
  43720. // If tick is align with label when boundaryGap is true
  43721. alignWithLabel: false,
  43722. interval: 'auto'
  43723. },
  43724. axisLabel: {
  43725. interval: 'auto'
  43726. }
  43727. }, defaultOption);
  43728. var valueAxis = merge({
  43729. boundaryGap: [0, 0],
  43730. axisLine: {
  43731. // Not shown when other axis is categoryAxis in cartesian
  43732. show: 'auto'
  43733. },
  43734. axisTick: {
  43735. // Not shown when other axis is categoryAxis in cartesian
  43736. show: 'auto'
  43737. },
  43738. // TODO
  43739. // min/max: [30, datamin, 60] or [20, datamin] or [datamin, 60]
  43740. splitNumber: 5,
  43741. minorTick: {
  43742. // Minor tick, not available for cateogry axis.
  43743. show: false,
  43744. // Split number of minor ticks. The value should be in range of (0, 100)
  43745. splitNumber: 5,
  43746. // Lenght of minor tick
  43747. length: 3,
  43748. // Line style
  43749. lineStyle: {// Default to be same with axisTick
  43750. }
  43751. },
  43752. minorSplitLine: {
  43753. show: false,
  43754. lineStyle: {
  43755. color: '#F4F7FD',
  43756. width: 1
  43757. }
  43758. }
  43759. }, defaultOption);
  43760. var timeAxis = merge({
  43761. scale: true,
  43762. splitNumber: 6,
  43763. axisLabel: {
  43764. // To eliminate labels that are not nice
  43765. showMinLabel: false,
  43766. showMaxLabel: false,
  43767. rich: {
  43768. primary: {
  43769. fontWeight: 'bold'
  43770. }
  43771. }
  43772. },
  43773. splitLine: {
  43774. show: false
  43775. }
  43776. }, valueAxis);
  43777. var logAxis = defaults({
  43778. scale: true,
  43779. logBase: 10
  43780. }, valueAxis);
  43781. var axisDefault = {
  43782. category: categoryAxis,
  43783. value: valueAxis,
  43784. time: timeAxis,
  43785. log: logAxis
  43786. };
  43787. /*
  43788. * Licensed to the Apache Software Foundation (ASF) under one
  43789. * or more contributor license agreements. See the NOTICE file
  43790. * distributed with this work for additional information
  43791. * regarding copyright ownership. The ASF licenses this file
  43792. * to you under the Apache License, Version 2.0 (the
  43793. * "License"); you may not use this file except in compliance
  43794. * with the License. You may obtain a copy of the License at
  43795. *
  43796. * http://www.apache.org/licenses/LICENSE-2.0
  43797. *
  43798. * Unless required by applicable law or agreed to in writing,
  43799. * software distributed under the License is distributed on an
  43800. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43801. * KIND, either express or implied. See the License for the
  43802. * specific language governing permissions and limitations
  43803. * under the License.
  43804. */
  43805. /**
  43806. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43807. */
  43808. /*
  43809. * Licensed to the Apache Software Foundation (ASF) under one
  43810. * or more contributor license agreements. See the NOTICE file
  43811. * distributed with this work for additional information
  43812. * regarding copyright ownership. The ASF licenses this file
  43813. * to you under the Apache License, Version 2.0 (the
  43814. * "License"); you may not use this file except in compliance
  43815. * with the License. You may obtain a copy of the License at
  43816. *
  43817. * http://www.apache.org/licenses/LICENSE-2.0
  43818. *
  43819. * Unless required by applicable law or agreed to in writing,
  43820. * software distributed under the License is distributed on an
  43821. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43822. * KIND, either express or implied. See the License for the
  43823. * specific language governing permissions and limitations
  43824. * under the License.
  43825. */
  43826. var AXIS_TYPES = {
  43827. value: 1,
  43828. category: 1,
  43829. time: 1,
  43830. log: 1
  43831. };
  43832. /*
  43833. * Licensed to the Apache Software Foundation (ASF) under one
  43834. * or more contributor license agreements. See the NOTICE file
  43835. * distributed with this work for additional information
  43836. * regarding copyright ownership. The ASF licenses this file
  43837. * to you under the Apache License, Version 2.0 (the
  43838. * "License"); you may not use this file except in compliance
  43839. * with the License. You may obtain a copy of the License at
  43840. *
  43841. * http://www.apache.org/licenses/LICENSE-2.0
  43842. *
  43843. * Unless required by applicable law or agreed to in writing,
  43844. * software distributed under the License is distributed on an
  43845. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43846. * KIND, either express or implied. See the License for the
  43847. * specific language governing permissions and limitations
  43848. * under the License.
  43849. */
  43850. /**
  43851. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43852. */
  43853. /*
  43854. * Licensed to the Apache Software Foundation (ASF) under one
  43855. * or more contributor license agreements. See the NOTICE file
  43856. * distributed with this work for additional information
  43857. * regarding copyright ownership. The ASF licenses this file
  43858. * to you under the Apache License, Version 2.0 (the
  43859. * "License"); you may not use this file except in compliance
  43860. * with the License. You may obtain a copy of the License at
  43861. *
  43862. * http://www.apache.org/licenses/LICENSE-2.0
  43863. *
  43864. * Unless required by applicable law or agreed to in writing,
  43865. * software distributed under the License is distributed on an
  43866. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43867. * KIND, either express or implied. See the License for the
  43868. * specific language governing permissions and limitations
  43869. * under the License.
  43870. */
  43871. /**
  43872. * Generate sub axis model class
  43873. * @param axisName 'x' 'y' 'radius' 'angle' 'parallel' ...
  43874. */
  43875. function axisModelCreator(registers, axisName, BaseAxisModelClass, extraDefaultOption) {
  43876. each$1(AXIS_TYPES, function (v, axisType) {
  43877. var defaultOption = merge(merge({}, axisDefault[axisType], true), extraDefaultOption, true);
  43878. var AxisModel =
  43879. /** @class */
  43880. function (_super) {
  43881. __extends(AxisModel, _super);
  43882. function AxisModel() {
  43883. var args = [];
  43884. for (var _i = 0; _i < arguments.length; _i++) {
  43885. args[_i] = arguments[_i];
  43886. }
  43887. var _this = _super.apply(this, args) || this;
  43888. _this.type = axisName + 'Axis.' + axisType;
  43889. return _this;
  43890. }
  43891. AxisModel.prototype.mergeDefaultAndTheme = function (option, ecModel) {
  43892. var layoutMode = fetchLayoutMode(this);
  43893. var inputPositionParams = layoutMode ? getLayoutParams(option) : {};
  43894. var themeModel = ecModel.getTheme();
  43895. merge(option, themeModel.get(axisType + 'Axis'));
  43896. merge(option, this.getDefaultOption());
  43897. option.type = getAxisType(option);
  43898. if (layoutMode) {
  43899. mergeLayoutParam(option, inputPositionParams, layoutMode);
  43900. }
  43901. };
  43902. AxisModel.prototype.optionUpdated = function () {
  43903. var thisOption = this.option;
  43904. if (thisOption.type === 'category') {
  43905. this.__ordinalMeta = OrdinalMeta.createByAxisModel(this);
  43906. }
  43907. };
  43908. /**
  43909. * Should not be called before all of 'getInitailData' finished.
  43910. * Because categories are collected during initializing data.
  43911. */
  43912. AxisModel.prototype.getCategories = function (rawData) {
  43913. var option = this.option; // FIXME
  43914. // warning if called before all of 'getInitailData' finished.
  43915. if (option.type === 'category') {
  43916. if (rawData) {
  43917. return option.data;
  43918. }
  43919. return this.__ordinalMeta.categories;
  43920. }
  43921. };
  43922. AxisModel.prototype.getOrdinalMeta = function () {
  43923. return this.__ordinalMeta;
  43924. };
  43925. AxisModel.type = axisName + 'Axis.' + axisType;
  43926. AxisModel.defaultOption = defaultOption;
  43927. return AxisModel;
  43928. }(BaseAxisModelClass);
  43929. registers.registerComponentModel(AxisModel);
  43930. });
  43931. registers.registerSubTypeDefaulter(axisName + 'Axis', getAxisType);
  43932. }
  43933. function getAxisType(option) {
  43934. // Default axis with data is category axis
  43935. return option.type || (option.data ? 'category' : 'value');
  43936. }
  43937. /*
  43938. * Licensed to the Apache Software Foundation (ASF) under one
  43939. * or more contributor license agreements. See the NOTICE file
  43940. * distributed with this work for additional information
  43941. * regarding copyright ownership. The ASF licenses this file
  43942. * to you under the Apache License, Version 2.0 (the
  43943. * "License"); you may not use this file except in compliance
  43944. * with the License. You may obtain a copy of the License at
  43945. *
  43946. * http://www.apache.org/licenses/LICENSE-2.0
  43947. *
  43948. * Unless required by applicable law or agreed to in writing,
  43949. * software distributed under the License is distributed on an
  43950. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43951. * KIND, either express or implied. See the License for the
  43952. * specific language governing permissions and limitations
  43953. * under the License.
  43954. */
  43955. /**
  43956. * AUTO-GENERATED FILE. DO NOT MODIFY.
  43957. */
  43958. /*
  43959. * Licensed to the Apache Software Foundation (ASF) under one
  43960. * or more contributor license agreements. See the NOTICE file
  43961. * distributed with this work for additional information
  43962. * regarding copyright ownership. The ASF licenses this file
  43963. * to you under the Apache License, Version 2.0 (the
  43964. * "License"); you may not use this file except in compliance
  43965. * with the License. You may obtain a copy of the License at
  43966. *
  43967. * http://www.apache.org/licenses/LICENSE-2.0
  43968. *
  43969. * Unless required by applicable law or agreed to in writing,
  43970. * software distributed under the License is distributed on an
  43971. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  43972. * KIND, either express or implied. See the License for the
  43973. * specific language governing permissions and limitations
  43974. * under the License.
  43975. */
  43976. var Cartesian =
  43977. /** @class */
  43978. function () {
  43979. function Cartesian(name) {
  43980. this.type = 'cartesian';
  43981. this._dimList = [];
  43982. this._axes = {};
  43983. this.name = name || '';
  43984. }
  43985. Cartesian.prototype.getAxis = function (dim) {
  43986. return this._axes[dim];
  43987. };
  43988. Cartesian.prototype.getAxes = function () {
  43989. return map(this._dimList, function (dim) {
  43990. return this._axes[dim];
  43991. }, this);
  43992. };
  43993. Cartesian.prototype.getAxesByScale = function (scaleType) {
  43994. scaleType = scaleType.toLowerCase();
  43995. return filter(this.getAxes(), function (axis) {
  43996. return axis.scale.type === scaleType;
  43997. });
  43998. };
  43999. Cartesian.prototype.addAxis = function (axis) {
  44000. var dim = axis.dim;
  44001. this._axes[dim] = axis;
  44002. this._dimList.push(dim);
  44003. };
  44004. return Cartesian;
  44005. }();
  44006. /*
  44007. * Licensed to the Apache Software Foundation (ASF) under one
  44008. * or more contributor license agreements. See the NOTICE file
  44009. * distributed with this work for additional information
  44010. * regarding copyright ownership. The ASF licenses this file
  44011. * to you under the Apache License, Version 2.0 (the
  44012. * "License"); you may not use this file except in compliance
  44013. * with the License. You may obtain a copy of the License at
  44014. *
  44015. * http://www.apache.org/licenses/LICENSE-2.0
  44016. *
  44017. * Unless required by applicable law or agreed to in writing,
  44018. * software distributed under the License is distributed on an
  44019. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44020. * KIND, either express or implied. See the License for the
  44021. * specific language governing permissions and limitations
  44022. * under the License.
  44023. */
  44024. /**
  44025. * AUTO-GENERATED FILE. DO NOT MODIFY.
  44026. */
  44027. /*
  44028. * Licensed to the Apache Software Foundation (ASF) under one
  44029. * or more contributor license agreements. See the NOTICE file
  44030. * distributed with this work for additional information
  44031. * regarding copyright ownership. The ASF licenses this file
  44032. * to you under the Apache License, Version 2.0 (the
  44033. * "License"); you may not use this file except in compliance
  44034. * with the License. You may obtain a copy of the License at
  44035. *
  44036. * http://www.apache.org/licenses/LICENSE-2.0
  44037. *
  44038. * Unless required by applicable law or agreed to in writing,
  44039. * software distributed under the License is distributed on an
  44040. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44041. * KIND, either express or implied. See the License for the
  44042. * specific language governing permissions and limitations
  44043. * under the License.
  44044. */
  44045. var cartesian2DDimensions = ['x', 'y'];
  44046. function canCalculateAffineTransform(scale$$1) {
  44047. return scale$$1.type === 'interval' || scale$$1.type === 'time';
  44048. }
  44049. var Cartesian2D =
  44050. /** @class */
  44051. function (_super) {
  44052. __extends(Cartesian2D, _super);
  44053. function Cartesian2D() {
  44054. var _this = _super !== null && _super.apply(this, arguments) || this;
  44055. _this.type = 'cartesian2d';
  44056. _this.dimensions = cartesian2DDimensions;
  44057. return _this;
  44058. }
  44059. /**
  44060. * Calculate an affine transform matrix if two axes are time or value.
  44061. * It's mainly for accelartion on the large time series data.
  44062. */
  44063. Cartesian2D.prototype.calcAffineTransform = function () {
  44064. this._transform = this._invTransform = null;
  44065. var xAxisScale = this.getAxis('x').scale;
  44066. var yAxisScale = this.getAxis('y').scale;
  44067. if (!canCalculateAffineTransform(xAxisScale) || !canCalculateAffineTransform(yAxisScale)) {
  44068. return;
  44069. }
  44070. var xScaleExtent = xAxisScale.getExtent();
  44071. var yScaleExtent = yAxisScale.getExtent();
  44072. var start = this.dataToPoint([xScaleExtent[0], yScaleExtent[0]]);
  44073. var end = this.dataToPoint([xScaleExtent[1], yScaleExtent[1]]);
  44074. var xScaleSpan = xScaleExtent[1] - xScaleExtent[0];
  44075. var yScaleSpan = yScaleExtent[1] - yScaleExtent[0];
  44076. if (!xScaleSpan || !yScaleSpan) {
  44077. return;
  44078. } // Accelerate data to point calculation on the special large time series data.
  44079. var scaleX = (end[0] - start[0]) / xScaleSpan;
  44080. var scaleY = (end[1] - start[1]) / yScaleSpan;
  44081. var translateX = start[0] - xScaleExtent[0] * scaleX;
  44082. var translateY = start[1] - yScaleExtent[0] * scaleY;
  44083. var m = this._transform = [scaleX, 0, 0, scaleY, translateX, translateY];
  44084. this._invTransform = invert([], m);
  44085. };
  44086. /**
  44087. * Base axis will be used on stacking.
  44088. */
  44089. Cartesian2D.prototype.getBaseAxis = function () {
  44090. return this.getAxesByScale('ordinal')[0] || this.getAxesByScale('time')[0] || this.getAxis('x');
  44091. };
  44092. Cartesian2D.prototype.containPoint = function (point) {
  44093. var axisX = this.getAxis('x');
  44094. var axisY = this.getAxis('y');
  44095. return axisX.contain(axisX.toLocalCoord(point[0])) && axisY.contain(axisY.toLocalCoord(point[1]));
  44096. };
  44097. Cartesian2D.prototype.containData = function (data) {
  44098. return this.getAxis('x').containData(data[0]) && this.getAxis('y').containData(data[1]);
  44099. };
  44100. Cartesian2D.prototype.dataToPoint = function (data, reserved, out) {
  44101. out = out || [];
  44102. var xVal = data[0];
  44103. var yVal = data[1]; // Fast path
  44104. if (this._transform // It's supported that if data is like `[Inifity, 123]`, where only Y pixel calculated.
  44105. && xVal != null && isFinite(xVal) && yVal != null && isFinite(yVal)) {
  44106. return applyTransform(out, data, this._transform);
  44107. }
  44108. var xAxis = this.getAxis('x');
  44109. var yAxis = this.getAxis('y');
  44110. out[0] = xAxis.toGlobalCoord(xAxis.dataToCoord(xVal));
  44111. out[1] = yAxis.toGlobalCoord(yAxis.dataToCoord(yVal));
  44112. return out;
  44113. };
  44114. Cartesian2D.prototype.clampData = function (data, out) {
  44115. var xScale = this.getAxis('x').scale;
  44116. var yScale = this.getAxis('y').scale;
  44117. var xAxisExtent = xScale.getExtent();
  44118. var yAxisExtent = yScale.getExtent();
  44119. var x = xScale.parse(data[0]);
  44120. var y = yScale.parse(data[1]);
  44121. out = out || [];
  44122. out[0] = Math.min(Math.max(Math.min(xAxisExtent[0], xAxisExtent[1]), x), Math.max(xAxisExtent[0], xAxisExtent[1]));
  44123. out[1] = Math.min(Math.max(Math.min(yAxisExtent[0], yAxisExtent[1]), y), Math.max(yAxisExtent[0], yAxisExtent[1]));
  44124. return out;
  44125. };
  44126. Cartesian2D.prototype.pointToData = function (point, out) {
  44127. out = out || [];
  44128. if (this._invTransform) {
  44129. return applyTransform(out, point, this._invTransform);
  44130. }
  44131. var xAxis = this.getAxis('x');
  44132. var yAxis = this.getAxis('y');
  44133. out[0] = xAxis.coordToData(xAxis.toLocalCoord(point[0]));
  44134. out[1] = yAxis.coordToData(yAxis.toLocalCoord(point[1]));
  44135. return out;
  44136. };
  44137. Cartesian2D.prototype.getOtherAxis = function (axis) {
  44138. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  44139. };
  44140. /**
  44141. * Get rect area of cartesian.
  44142. * Area will have a contain function to determine if a point is in the coordinate system.
  44143. */
  44144. Cartesian2D.prototype.getArea = function () {
  44145. var xExtent = this.getAxis('x').getGlobalExtent();
  44146. var yExtent = this.getAxis('y').getGlobalExtent();
  44147. var x = Math.min(xExtent[0], xExtent[1]);
  44148. var y = Math.min(yExtent[0], yExtent[1]);
  44149. var width = Math.max(xExtent[0], xExtent[1]) - x;
  44150. var height = Math.max(yExtent[0], yExtent[1]) - y;
  44151. return new BoundingRect(x, y, width, height);
  44152. };
  44153. return Cartesian2D;
  44154. }(Cartesian);
  44155. /*
  44156. * Licensed to the Apache Software Foundation (ASF) under one
  44157. * or more contributor license agreements. See the NOTICE file
  44158. * distributed with this work for additional information
  44159. * regarding copyright ownership. The ASF licenses this file
  44160. * to you under the Apache License, Version 2.0 (the
  44161. * "License"); you may not use this file except in compliance
  44162. * with the License. You may obtain a copy of the License at
  44163. *
  44164. * http://www.apache.org/licenses/LICENSE-2.0
  44165. *
  44166. * Unless required by applicable law or agreed to in writing,
  44167. * software distributed under the License is distributed on an
  44168. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44169. * KIND, either express or implied. See the License for the
  44170. * specific language governing permissions and limitations
  44171. * under the License.
  44172. */
  44173. /**
  44174. * AUTO-GENERATED FILE. DO NOT MODIFY.
  44175. */
  44176. /*
  44177. * Licensed to the Apache Software Foundation (ASF) under one
  44178. * or more contributor license agreements. See the NOTICE file
  44179. * distributed with this work for additional information
  44180. * regarding copyright ownership. The ASF licenses this file
  44181. * to you under the Apache License, Version 2.0 (the
  44182. * "License"); you may not use this file except in compliance
  44183. * with the License. You may obtain a copy of the License at
  44184. *
  44185. * http://www.apache.org/licenses/LICENSE-2.0
  44186. *
  44187. * Unless required by applicable law or agreed to in writing,
  44188. * software distributed under the License is distributed on an
  44189. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44190. * KIND, either express or implied. See the License for the
  44191. * specific language governing permissions and limitations
  44192. * under the License.
  44193. */
  44194. var Axis2D =
  44195. /** @class */
  44196. function (_super) {
  44197. __extends(Axis2D, _super);
  44198. function Axis2D(dim, scale, coordExtent, axisType, position) {
  44199. var _this = _super.call(this, dim, scale, coordExtent) || this;
  44200. /**
  44201. * Index of axis, can be used as key
  44202. * Injected outside.
  44203. */
  44204. _this.index = 0;
  44205. _this.type = axisType || 'value';
  44206. _this.position = position || 'bottom';
  44207. return _this;
  44208. }
  44209. Axis2D.prototype.isHorizontal = function () {
  44210. var position = this.position;
  44211. return position === 'top' || position === 'bottom';
  44212. };
  44213. /**
  44214. * Each item cooresponds to this.getExtent(), which
  44215. * means globalExtent[0] may greater than globalExtent[1],
  44216. * unless `asc` is input.
  44217. *
  44218. * @param {boolean} [asc]
  44219. * @return {Array.<number>}
  44220. */
  44221. Axis2D.prototype.getGlobalExtent = function (asc) {
  44222. var ret = this.getExtent();
  44223. ret[0] = this.toGlobalCoord(ret[0]);
  44224. ret[1] = this.toGlobalCoord(ret[1]);
  44225. asc && ret[0] > ret[1] && ret.reverse();
  44226. return ret;
  44227. };
  44228. Axis2D.prototype.pointToData = function (point, clamp) {
  44229. return this.coordToData(this.toLocalCoord(point[this.dim === 'x' ? 0 : 1]), clamp);
  44230. };
  44231. /**
  44232. * Set ordinalSortInfo
  44233. * @param info new OrdinalSortInfo
  44234. */
  44235. Axis2D.prototype.setCategorySortInfo = function (info) {
  44236. if (this.type !== 'category') {
  44237. return false;
  44238. }
  44239. this.model.option.categorySortInfo = info;
  44240. this.scale.setSortInfo(info);
  44241. };
  44242. return Axis2D;
  44243. }(Axis);
  44244. /*
  44245. * Licensed to the Apache Software Foundation (ASF) under one
  44246. * or more contributor license agreements. See the NOTICE file
  44247. * distributed with this work for additional information
  44248. * regarding copyright ownership. The ASF licenses this file
  44249. * to you under the Apache License, Version 2.0 (the
  44250. * "License"); you may not use this file except in compliance
  44251. * with the License. You may obtain a copy of the License at
  44252. *
  44253. * http://www.apache.org/licenses/LICENSE-2.0
  44254. *
  44255. * Unless required by applicable law or agreed to in writing,
  44256. * software distributed under the License is distributed on an
  44257. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44258. * KIND, either express or implied. See the License for the
  44259. * specific language governing permissions and limitations
  44260. * under the License.
  44261. */
  44262. /**
  44263. * AUTO-GENERATED FILE. DO NOT MODIFY.
  44264. */
  44265. /*
  44266. * Licensed to the Apache Software Foundation (ASF) under one
  44267. * or more contributor license agreements. See the NOTICE file
  44268. * distributed with this work for additional information
  44269. * regarding copyright ownership. The ASF licenses this file
  44270. * to you under the Apache License, Version 2.0 (the
  44271. * "License"); you may not use this file except in compliance
  44272. * with the License. You may obtain a copy of the License at
  44273. *
  44274. * http://www.apache.org/licenses/LICENSE-2.0
  44275. *
  44276. * Unless required by applicable law or agreed to in writing,
  44277. * software distributed under the License is distributed on an
  44278. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44279. * KIND, either express or implied. See the License for the
  44280. * specific language governing permissions and limitations
  44281. * under the License.
  44282. */
  44283. /**
  44284. * Can only be called after coordinate system creation stage.
  44285. * (Can be called before coordinate system update stage).
  44286. */
  44287. function layout$1(gridModel, axisModel, opt) {
  44288. opt = opt || {};
  44289. var grid = gridModel.coordinateSystem;
  44290. var axis = axisModel.axis;
  44291. var layout = {};
  44292. var otherAxisOnZeroOf = axis.getAxesOnZeroOf()[0];
  44293. var rawAxisPosition = axis.position;
  44294. var axisPosition = otherAxisOnZeroOf ? 'onZero' : rawAxisPosition;
  44295. var axisDim = axis.dim;
  44296. var rect = grid.getRect();
  44297. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  44298. var idx = {
  44299. left: 0,
  44300. right: 1,
  44301. top: 0,
  44302. bottom: 1,
  44303. onZero: 2
  44304. };
  44305. var axisOffset = axisModel.get('offset') || 0;
  44306. var posBound = axisDim === 'x' ? [rectBound[2] - axisOffset, rectBound[3] + axisOffset] : [rectBound[0] - axisOffset, rectBound[1] + axisOffset];
  44307. if (otherAxisOnZeroOf) {
  44308. var onZeroCoord = otherAxisOnZeroOf.toGlobalCoord(otherAxisOnZeroOf.dataToCoord(0));
  44309. posBound[idx.onZero] = Math.max(Math.min(onZeroCoord, posBound[1]), posBound[0]);
  44310. } // Axis position
  44311. layout.position = [axisDim === 'y' ? posBound[idx[axisPosition]] : rectBound[0], axisDim === 'x' ? posBound[idx[axisPosition]] : rectBound[3]]; // Axis rotation
  44312. layout.rotation = Math.PI / 2 * (axisDim === 'x' ? 0 : 1); // Tick and label direction, x y is axisDim
  44313. var dirMap = {
  44314. top: -1,
  44315. bottom: 1,
  44316. left: -1,
  44317. right: 1
  44318. };
  44319. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  44320. layout.labelOffset = otherAxisOnZeroOf ? posBound[idx[rawAxisPosition]] - posBound[idx.onZero] : 0;
  44321. if (axisModel.get(['axisTick', 'inside'])) {
  44322. layout.tickDirection = -layout.tickDirection;
  44323. }
  44324. if (retrieve(opt.labelInside, axisModel.get(['axisLabel', 'inside']))) {
  44325. layout.labelDirection = -layout.labelDirection;
  44326. } // Special label rotation
  44327. var labelRotate = axisModel.get(['axisLabel', 'rotate']);
  44328. layout.labelRotate = axisPosition === 'top' ? -labelRotate : labelRotate; // Over splitLine and splitArea
  44329. layout.z2 = 1;
  44330. return layout;
  44331. }
  44332. function isCartesian2DSeries(seriesModel) {
  44333. return seriesModel.get('coordinateSystem') === 'cartesian2d';
  44334. }
  44335. function findAxisModels(seriesModel) {
  44336. var axisModelMap = {
  44337. xAxisModel: null,
  44338. yAxisModel: null
  44339. };
  44340. each$1(axisModelMap, function (v, key) {
  44341. var axisType = key.replace(/Model$/, '');
  44342. var axisModel = seriesModel.getReferringComponents(axisType, SINGLE_REFERRING).models[0];
  44343. {
  44344. if (!axisModel) {
  44345. throw new Error(axisType + ' "' + retrieve3(seriesModel.get(axisType + 'Index'), seriesModel.get(axisType + 'Id'), 0) + '" not found');
  44346. }
  44347. }
  44348. axisModelMap[key] = axisModel;
  44349. });
  44350. return axisModelMap;
  44351. }
  44352. /*
  44353. * Licensed to the Apache Software Foundation (ASF) under one
  44354. * or more contributor license agreements. See the NOTICE file
  44355. * distributed with this work for additional information
  44356. * regarding copyright ownership. The ASF licenses this file
  44357. * to you under the Apache License, Version 2.0 (the
  44358. * "License"); you may not use this file except in compliance
  44359. * with the License. You may obtain a copy of the License at
  44360. *
  44361. * http://www.apache.org/licenses/LICENSE-2.0
  44362. *
  44363. * Unless required by applicable law or agreed to in writing,
  44364. * software distributed under the License is distributed on an
  44365. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44366. * KIND, either express or implied. See the License for the
  44367. * specific language governing permissions and limitations
  44368. * under the License.
  44369. */
  44370. /**
  44371. * AUTO-GENERATED FILE. DO NOT MODIFY.
  44372. */
  44373. /*
  44374. * Licensed to the Apache Software Foundation (ASF) under one
  44375. * or more contributor license agreements. See the NOTICE file
  44376. * distributed with this work for additional information
  44377. * regarding copyright ownership. The ASF licenses this file
  44378. * to you under the Apache License, Version 2.0 (the
  44379. * "License"); you may not use this file except in compliance
  44380. * with the License. You may obtain a copy of the License at
  44381. *
  44382. * http://www.apache.org/licenses/LICENSE-2.0
  44383. *
  44384. * Unless required by applicable law or agreed to in writing,
  44385. * software distributed under the License is distributed on an
  44386. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44387. * KIND, either express or implied. See the License for the
  44388. * specific language governing permissions and limitations
  44389. * under the License.
  44390. */
  44391. /**
  44392. * Grid is a region which contains at most 4 cartesian systems
  44393. *
  44394. * TODO Default cartesian
  44395. */
  44396. var Grid =
  44397. /** @class */
  44398. function () {
  44399. function Grid(gridModel, ecModel, api) {
  44400. // FIXME:TS where used (different from registered type 'cartesian2d')?
  44401. this.type = 'grid';
  44402. this._coordsMap = {};
  44403. this._coordsList = [];
  44404. this._axesMap = {};
  44405. this._axesList = [];
  44406. this.axisPointerEnabled = true;
  44407. this.dimensions = cartesian2DDimensions;
  44408. this._initCartesian(gridModel, ecModel, api);
  44409. this.model = gridModel;
  44410. }
  44411. Grid.prototype.getRect = function () {
  44412. return this._rect;
  44413. };
  44414. Grid.prototype.update = function (ecModel, api) {
  44415. var axesMap = this._axesMap;
  44416. this._updateScale(ecModel, this.model);
  44417. each$1(axesMap.x, function (xAxis) {
  44418. niceScaleExtent(xAxis.scale, xAxis.model);
  44419. });
  44420. each$1(axesMap.y, function (yAxis) {
  44421. niceScaleExtent(yAxis.scale, yAxis.model);
  44422. }); // Key: axisDim_axisIndex, value: boolean, whether onZero target.
  44423. var onZeroRecords = {};
  44424. each$1(axesMap.x, function (xAxis) {
  44425. fixAxisOnZero(axesMap, 'y', xAxis, onZeroRecords);
  44426. });
  44427. each$1(axesMap.y, function (yAxis) {
  44428. fixAxisOnZero(axesMap, 'x', yAxis, onZeroRecords);
  44429. }); // Resize again if containLabel is enabled
  44430. // FIXME It may cause getting wrong grid size in data processing stage
  44431. this.resize(this.model, api);
  44432. };
  44433. /**
  44434. * Resize the grid
  44435. */
  44436. Grid.prototype.resize = function (gridModel, api, ignoreContainLabel) {
  44437. var boxLayoutParams = gridModel.getBoxLayoutParams();
  44438. var isContainLabel = !ignoreContainLabel && gridModel.get('containLabel');
  44439. var gridRect = getLayoutRect(boxLayoutParams, {
  44440. width: api.getWidth(),
  44441. height: api.getHeight()
  44442. });
  44443. this._rect = gridRect;
  44444. var axesList = this._axesList;
  44445. adjustAxes(); // Minus label size
  44446. if (isContainLabel) {
  44447. each$1(axesList, function (axis) {
  44448. if (!axis.model.get(['axisLabel', 'inside'])) {
  44449. var labelUnionRect = estimateLabelUnionRect(axis);
  44450. if (labelUnionRect) {
  44451. var dim = axis.isHorizontal() ? 'height' : 'width';
  44452. var margin = axis.model.get(['axisLabel', 'margin']);
  44453. gridRect[dim] -= labelUnionRect[dim] + margin;
  44454. if (axis.position === 'top') {
  44455. gridRect.y += labelUnionRect.height + margin;
  44456. } else if (axis.position === 'left') {
  44457. gridRect.x += labelUnionRect.width + margin;
  44458. }
  44459. }
  44460. }
  44461. });
  44462. adjustAxes();
  44463. }
  44464. each$1(this._coordsList, function (coord) {
  44465. // Calculate affine matrix to accelerate the data to point transform.
  44466. // If all the axes scales are time or value.
  44467. coord.calcAffineTransform();
  44468. });
  44469. function adjustAxes() {
  44470. each$1(axesList, function (axis) {
  44471. var isHorizontal = axis.isHorizontal();
  44472. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  44473. var idx = axis.inverse ? 1 : 0;
  44474. axis.setExtent(extent[idx], extent[1 - idx]);
  44475. updateAxisTransform(axis, isHorizontal ? gridRect.x : gridRect.y);
  44476. });
  44477. }
  44478. };
  44479. Grid.prototype.getAxis = function (dim, axisIndex) {
  44480. var axesMapOnDim = this._axesMap[dim];
  44481. if (axesMapOnDim != null) {
  44482. return axesMapOnDim[axisIndex || 0]; // if (axisIndex == null) {
  44483. // Find first axis
  44484. // for (let name in axesMapOnDim) {
  44485. // if (axesMapOnDim.hasOwnProperty(name)) {
  44486. // return axesMapOnDim[name];
  44487. // }
  44488. // }
  44489. // }
  44490. // return axesMapOnDim[axisIndex];
  44491. }
  44492. };
  44493. Grid.prototype.getAxes = function () {
  44494. return this._axesList.slice();
  44495. };
  44496. Grid.prototype.getCartesian = function (xAxisIndex, yAxisIndex) {
  44497. if (xAxisIndex != null && yAxisIndex != null) {
  44498. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  44499. return this._coordsMap[key];
  44500. }
  44501. if (isObject$1(xAxisIndex)) {
  44502. yAxisIndex = xAxisIndex.yAxisIndex;
  44503. xAxisIndex = xAxisIndex.xAxisIndex;
  44504. }
  44505. for (var i = 0, coordList = this._coordsList; i < coordList.length; i++) {
  44506. if (coordList[i].getAxis('x').index === xAxisIndex || coordList[i].getAxis('y').index === yAxisIndex) {
  44507. return coordList[i];
  44508. }
  44509. }
  44510. };
  44511. Grid.prototype.getCartesians = function () {
  44512. return this._coordsList.slice();
  44513. };
  44514. /**
  44515. * @implements
  44516. */
  44517. Grid.prototype.convertToPixel = function (ecModel, finder, value) {
  44518. var target = this._findConvertTarget(finder);
  44519. return target.cartesian ? target.cartesian.dataToPoint(value) : target.axis ? target.axis.toGlobalCoord(target.axis.dataToCoord(value)) : null;
  44520. };
  44521. /**
  44522. * @implements
  44523. */
  44524. Grid.prototype.convertFromPixel = function (ecModel, finder, value) {
  44525. var target = this._findConvertTarget(finder);
  44526. return target.cartesian ? target.cartesian.pointToData(value) : target.axis ? target.axis.coordToData(target.axis.toLocalCoord(value)) : null;
  44527. };
  44528. Grid.prototype._findConvertTarget = function (finder) {
  44529. var seriesModel = finder.seriesModel;
  44530. var xAxisModel = finder.xAxisModel || seriesModel && seriesModel.getReferringComponents('xAxis', SINGLE_REFERRING).models[0];
  44531. var yAxisModel = finder.yAxisModel || seriesModel && seriesModel.getReferringComponents('yAxis', SINGLE_REFERRING).models[0];
  44532. var gridModel = finder.gridModel;
  44533. var coordsList = this._coordsList;
  44534. var cartesian;
  44535. var axis;
  44536. if (seriesModel) {
  44537. cartesian = seriesModel.coordinateSystem;
  44538. indexOf$1(coordsList, cartesian) < 0 && (cartesian = null);
  44539. } else if (xAxisModel && yAxisModel) {
  44540. cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
  44541. } else if (xAxisModel) {
  44542. axis = this.getAxis('x', xAxisModel.componentIndex);
  44543. } else if (yAxisModel) {
  44544. axis = this.getAxis('y', yAxisModel.componentIndex);
  44545. } // Lowest priority.
  44546. else if (gridModel) {
  44547. var grid = gridModel.coordinateSystem;
  44548. if (grid === this) {
  44549. cartesian = this._coordsList[0];
  44550. }
  44551. }
  44552. return {
  44553. cartesian: cartesian,
  44554. axis: axis
  44555. };
  44556. };
  44557. /**
  44558. * @implements
  44559. */
  44560. Grid.prototype.containPoint = function (point) {
  44561. var coord = this._coordsList[0];
  44562. if (coord) {
  44563. return coord.containPoint(point);
  44564. }
  44565. };
  44566. /**
  44567. * Initialize cartesian coordinate systems
  44568. */
  44569. Grid.prototype._initCartesian = function (gridModel, ecModel, api) {
  44570. var _this = this;
  44571. var grid = this;
  44572. var axisPositionUsed = {
  44573. left: false,
  44574. right: false,
  44575. top: false,
  44576. bottom: false
  44577. };
  44578. var axesMap = {
  44579. x: {},
  44580. y: {}
  44581. };
  44582. var axesCount = {
  44583. x: 0,
  44584. y: 0
  44585. }; /// Create axis
  44586. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  44587. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  44588. if (!axesCount.x || !axesCount.y) {
  44589. // Roll back when there no either x or y axis
  44590. this._axesMap = {};
  44591. this._axesList = [];
  44592. return;
  44593. }
  44594. this._axesMap = axesMap; /// Create cartesian2d
  44595. each$1(axesMap.x, function (xAxis, xAxisIndex) {
  44596. each$1(axesMap.y, function (yAxis, yAxisIndex) {
  44597. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  44598. var cartesian = new Cartesian2D(key);
  44599. cartesian.master = _this;
  44600. cartesian.model = gridModel;
  44601. _this._coordsMap[key] = cartesian;
  44602. _this._coordsList.push(cartesian);
  44603. cartesian.addAxis(xAxis);
  44604. cartesian.addAxis(yAxis);
  44605. });
  44606. });
  44607. function createAxisCreator(dimName) {
  44608. return function (axisModel, idx) {
  44609. if (!isAxisUsedInTheGrid(axisModel, gridModel)) {
  44610. return;
  44611. }
  44612. var axisPosition = axisModel.get('position');
  44613. if (dimName === 'x') {
  44614. // Fix position
  44615. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  44616. // Default bottom of X
  44617. axisPosition = axisPositionUsed.bottom ? 'top' : 'bottom';
  44618. }
  44619. } else {
  44620. // Fix position
  44621. if (axisPosition !== 'left' && axisPosition !== 'right') {
  44622. // Default left of Y
  44623. axisPosition = axisPositionUsed.left ? 'right' : 'left';
  44624. }
  44625. }
  44626. axisPositionUsed[axisPosition] = true;
  44627. var axis = new Axis2D(dimName, createScaleByModel(axisModel), [0, 0], axisModel.get('type'), axisPosition);
  44628. var isCategory = axis.type === 'category';
  44629. axis.onBand = isCategory && axisModel.get('boundaryGap');
  44630. axis.inverse = axisModel.get('inverse'); // Inject axis into axisModel
  44631. axisModel.axis = axis; // Inject axisModel into axis
  44632. axis.model = axisModel; // Inject grid info axis
  44633. axis.grid = grid; // Index of axis, can be used as key
  44634. axis.index = idx;
  44635. grid._axesList.push(axis);
  44636. axesMap[dimName][idx] = axis;
  44637. axesCount[dimName]++;
  44638. };
  44639. }
  44640. };
  44641. /**
  44642. * Update cartesian properties from series.
  44643. */
  44644. Grid.prototype._updateScale = function (ecModel, gridModel) {
  44645. // Reset scale
  44646. each$1(this._axesList, function (axis) {
  44647. axis.scale.setExtent(Infinity, -Infinity);
  44648. if (axis.type === 'category') {
  44649. var categorySortInfo = axis.model.get('categorySortInfo');
  44650. axis.scale.setSortInfo(categorySortInfo);
  44651. }
  44652. });
  44653. ecModel.eachSeries(function (seriesModel) {
  44654. if (isCartesian2DSeries(seriesModel)) {
  44655. var axesModelMap = findAxisModels(seriesModel);
  44656. var xAxisModel = axesModelMap.xAxisModel;
  44657. var yAxisModel = axesModelMap.yAxisModel;
  44658. if (!isAxisUsedInTheGrid(xAxisModel, gridModel) || !isAxisUsedInTheGrid(yAxisModel, gridModel)) {
  44659. return;
  44660. }
  44661. var cartesian = this.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
  44662. var data = seriesModel.getData();
  44663. var xAxis = cartesian.getAxis('x');
  44664. var yAxis = cartesian.getAxis('y');
  44665. if (data.type === 'list') {
  44666. unionExtent(data, xAxis);
  44667. unionExtent(data, yAxis);
  44668. }
  44669. }
  44670. }, this);
  44671. function unionExtent(data, axis) {
  44672. each$1(getDataDimensionsOnAxis(data, axis.dim), function (dim) {
  44673. axis.scale.unionExtentFromData(data, dim);
  44674. });
  44675. }
  44676. };
  44677. /**
  44678. * @param dim 'x' or 'y' or 'auto' or null/undefined
  44679. */
  44680. Grid.prototype.getTooltipAxes = function (dim) {
  44681. var baseAxes = [];
  44682. var otherAxes = [];
  44683. each$1(this.getCartesians(), function (cartesian) {
  44684. var baseAxis = dim != null && dim !== 'auto' ? cartesian.getAxis(dim) : cartesian.getBaseAxis();
  44685. var otherAxis = cartesian.getOtherAxis(baseAxis);
  44686. indexOf$1(baseAxes, baseAxis) < 0 && baseAxes.push(baseAxis);
  44687. indexOf$1(otherAxes, otherAxis) < 0 && otherAxes.push(otherAxis);
  44688. });
  44689. return {
  44690. baseAxes: baseAxes,
  44691. otherAxes: otherAxes
  44692. };
  44693. };
  44694. Grid.create = function (ecModel, api) {
  44695. var grids = [];
  44696. ecModel.eachComponent('grid', function (gridModel, idx) {
  44697. var grid = new Grid(gridModel, ecModel, api);
  44698. grid.name = 'grid_' + idx; // dataSampling requires axis extent, so resize
  44699. // should be performed in create stage.
  44700. grid.resize(gridModel, api, true);
  44701. gridModel.coordinateSystem = grid;
  44702. grids.push(grid);
  44703. }); // Inject the coordinateSystems into seriesModel
  44704. ecModel.eachSeries(function (seriesModel) {
  44705. if (!isCartesian2DSeries(seriesModel)) {
  44706. return;
  44707. }
  44708. var axesModelMap = findAxisModels(seriesModel);
  44709. var xAxisModel = axesModelMap.xAxisModel;
  44710. var yAxisModel = axesModelMap.yAxisModel;
  44711. var gridModel = xAxisModel.getCoordSysModel();
  44712. {
  44713. if (!gridModel) {
  44714. throw new Error('Grid "' + retrieve3(xAxisModel.get('gridIndex'), xAxisModel.get('gridId'), 0) + '" not found');
  44715. }
  44716. if (xAxisModel.getCoordSysModel() !== yAxisModel.getCoordSysModel()) {
  44717. throw new Error('xAxis and yAxis must use the same grid');
  44718. }
  44719. }
  44720. var grid = gridModel.coordinateSystem;
  44721. seriesModel.coordinateSystem = grid.getCartesian(xAxisModel.componentIndex, yAxisModel.componentIndex);
  44722. });
  44723. return grids;
  44724. }; // For deciding which dimensions to use when creating list data
  44725. Grid.dimensions = cartesian2DDimensions;
  44726. return Grid;
  44727. }();
  44728. /**
  44729. * Check if the axis is used in the specified grid.
  44730. */
  44731. function isAxisUsedInTheGrid(axisModel, gridModel) {
  44732. return axisModel.getCoordSysModel() === gridModel;
  44733. }
  44734. function fixAxisOnZero(axesMap, otherAxisDim, axis, // Key: see `getOnZeroRecordKey`
  44735. onZeroRecords) {
  44736. axis.getAxesOnZeroOf = function () {
  44737. // TODO: onZero of multiple axes.
  44738. return otherAxisOnZeroOf ? [otherAxisOnZeroOf] : [];
  44739. }; // onZero can not be enabled in these two situations:
  44740. // 1. When any other axis is a category axis.
  44741. // 2. When no axis is cross 0 point.
  44742. var otherAxes = axesMap[otherAxisDim];
  44743. var otherAxisOnZeroOf;
  44744. var axisModel = axis.model;
  44745. var onZero = axisModel.get(['axisLine', 'onZero']);
  44746. var onZeroAxisIndex = axisModel.get(['axisLine', 'onZeroAxisIndex']);
  44747. if (!onZero) {
  44748. return;
  44749. } // If target axis is specified.
  44750. if (onZeroAxisIndex != null) {
  44751. if (canOnZeroToAxis(otherAxes[onZeroAxisIndex])) {
  44752. otherAxisOnZeroOf = otherAxes[onZeroAxisIndex];
  44753. }
  44754. } else {
  44755. // Find the first available other axis.
  44756. for (var idx in otherAxes) {
  44757. if (otherAxes.hasOwnProperty(idx) && canOnZeroToAxis(otherAxes[idx]) // Consider that two Y axes on one value axis,
  44758. // if both onZero, the two Y axes overlap.
  44759. && !onZeroRecords[getOnZeroRecordKey(otherAxes[idx])]) {
  44760. otherAxisOnZeroOf = otherAxes[idx];
  44761. break;
  44762. }
  44763. }
  44764. }
  44765. if (otherAxisOnZeroOf) {
  44766. onZeroRecords[getOnZeroRecordKey(otherAxisOnZeroOf)] = true;
  44767. }
  44768. function getOnZeroRecordKey(axis) {
  44769. return axis.dim + '_' + axis.index;
  44770. }
  44771. }
  44772. function canOnZeroToAxis(axis) {
  44773. return axis && axis.type !== 'category' && axis.type !== 'time' && ifAxisCrossZero(axis);
  44774. }
  44775. function updateAxisTransform(axis, coordBase) {
  44776. var axisExtent = axis.getExtent();
  44777. var axisExtentSum = axisExtent[0] + axisExtent[1]; // Fast transform
  44778. axis.toGlobalCoord = axis.dim === 'x' ? function (coord) {
  44779. return coord + coordBase;
  44780. } : function (coord) {
  44781. return axisExtentSum - coord + coordBase;
  44782. };
  44783. axis.toLocalCoord = axis.dim === 'x' ? function (coord) {
  44784. return coord - coordBase;
  44785. } : function (coord) {
  44786. return axisExtentSum - coord + coordBase;
  44787. };
  44788. }
  44789. /*
  44790. * Licensed to the Apache Software Foundation (ASF) under one
  44791. * or more contributor license agreements. See the NOTICE file
  44792. * distributed with this work for additional information
  44793. * regarding copyright ownership. The ASF licenses this file
  44794. * to you under the Apache License, Version 2.0 (the
  44795. * "License"); you may not use this file except in compliance
  44796. * with the License. You may obtain a copy of the License at
  44797. *
  44798. * http://www.apache.org/licenses/LICENSE-2.0
  44799. *
  44800. * Unless required by applicable law or agreed to in writing,
  44801. * software distributed under the License is distributed on an
  44802. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44803. * KIND, either express or implied. See the License for the
  44804. * specific language governing permissions and limitations
  44805. * under the License.
  44806. */
  44807. /**
  44808. * AUTO-GENERATED FILE. DO NOT MODIFY.
  44809. */
  44810. /*
  44811. * Licensed to the Apache Software Foundation (ASF) under one
  44812. * or more contributor license agreements. See the NOTICE file
  44813. * distributed with this work for additional information
  44814. * regarding copyright ownership. The ASF licenses this file
  44815. * to you under the Apache License, Version 2.0 (the
  44816. * "License"); you may not use this file except in compliance
  44817. * with the License. You may obtain a copy of the License at
  44818. *
  44819. * http://www.apache.org/licenses/LICENSE-2.0
  44820. *
  44821. * Unless required by applicable law or agreed to in writing,
  44822. * software distributed under the License is distributed on an
  44823. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  44824. * KIND, either express or implied. See the License for the
  44825. * specific language governing permissions and limitations
  44826. * under the License.
  44827. */
  44828. var PI$4 = Math.PI;
  44829. /**
  44830. * A final axis is translated and rotated from a "standard axis".
  44831. * So opt.position and opt.rotation is required.
  44832. *
  44833. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  44834. * for example: (0, 0) ------------> (0, 50)
  44835. *
  44836. * nameDirection or tickDirection or labelDirection is 1 means tick
  44837. * or label is below the standard axis, whereas is -1 means above
  44838. * the standard axis. labelOffset means offset between label and axis,
  44839. * which is useful when 'onZero', where axisLabel is in the grid and
  44840. * label in outside grid.
  44841. *
  44842. * Tips: like always,
  44843. * positive rotation represents anticlockwise, and negative rotation
  44844. * represents clockwise.
  44845. * The direction of position coordinate is the same as the direction
  44846. * of screen coordinate.
  44847. *
  44848. * Do not need to consider axis 'inverse', which is auto processed by
  44849. * axis extent.
  44850. */
  44851. var AxisBuilder =
  44852. /** @class */
  44853. function () {
  44854. function AxisBuilder(axisModel, opt) {
  44855. this.group = new Group();
  44856. this.opt = opt;
  44857. this.axisModel = axisModel; // Default value
  44858. defaults(opt, {
  44859. labelOffset: 0,
  44860. nameDirection: 1,
  44861. tickDirection: 1,
  44862. labelDirection: 1,
  44863. silent: true,
  44864. handleAutoShown: function () {
  44865. return true;
  44866. }
  44867. }); // FIXME Not use a seperate text group?
  44868. var transformGroup = new Group({
  44869. x: opt.position[0],
  44870. y: opt.position[1],
  44871. rotation: opt.rotation
  44872. }); // this.group.add(transformGroup);
  44873. // this._transformGroup = transformGroup;
  44874. transformGroup.updateTransform();
  44875. this._transformGroup = transformGroup;
  44876. }
  44877. AxisBuilder.prototype.hasBuilder = function (name) {
  44878. return !!builders[name];
  44879. };
  44880. AxisBuilder.prototype.add = function (name) {
  44881. builders[name](this.opt, this.axisModel, this.group, this._transformGroup);
  44882. };
  44883. AxisBuilder.prototype.getGroup = function () {
  44884. return this.group;
  44885. };
  44886. AxisBuilder.innerTextLayout = function (axisRotation, textRotation, direction) {
  44887. var rotationDiff = remRadian(textRotation - axisRotation);
  44888. var textAlign;
  44889. var textVerticalAlign;
  44890. if (isRadianAroundZero(rotationDiff)) {
  44891. // Label is parallel with axis line.
  44892. textVerticalAlign = direction > 0 ? 'top' : 'bottom';
  44893. textAlign = 'center';
  44894. } else if (isRadianAroundZero(rotationDiff - PI$4)) {
  44895. // Label is inverse parallel with axis line.
  44896. textVerticalAlign = direction > 0 ? 'bottom' : 'top';
  44897. textAlign = 'center';
  44898. } else {
  44899. textVerticalAlign = 'middle';
  44900. if (rotationDiff > 0 && rotationDiff < PI$4) {
  44901. textAlign = direction > 0 ? 'right' : 'left';
  44902. } else {
  44903. textAlign = direction > 0 ? 'left' : 'right';
  44904. }
  44905. }
  44906. return {
  44907. rotation: rotationDiff,
  44908. textAlign: textAlign,
  44909. textVerticalAlign: textVerticalAlign
  44910. };
  44911. };
  44912. AxisBuilder.makeAxisEventDataBase = function (axisModel) {
  44913. var eventData = {
  44914. componentType: axisModel.mainType,
  44915. componentIndex: axisModel.componentIndex
  44916. };
  44917. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  44918. return eventData;
  44919. };
  44920. AxisBuilder.isLabelSilent = function (axisModel) {
  44921. var tooltipOpt = axisModel.get('tooltip');
  44922. return axisModel.get('silent') // Consider mouse cursor, add these restrictions.
  44923. || !(axisModel.get('triggerEvent') || tooltipOpt && tooltipOpt.show);
  44924. };
  44925. return AxisBuilder;
  44926. }();
  44927. var builders = {
  44928. axisLine: function (opt, axisModel, group, transformGroup) {
  44929. var shown = axisModel.get(['axisLine', 'show']);
  44930. if (shown === 'auto' && opt.handleAutoShown) {
  44931. shown = opt.handleAutoShown('axisLine');
  44932. }
  44933. if (!shown) {
  44934. return;
  44935. }
  44936. var extent = axisModel.axis.getExtent();
  44937. var matrix = transformGroup.transform;
  44938. var pt1 = [extent[0], 0];
  44939. var pt2 = [extent[1], 0];
  44940. if (matrix) {
  44941. applyTransform(pt1, pt1, matrix);
  44942. applyTransform(pt2, pt2, matrix);
  44943. }
  44944. var lineStyle = extend({
  44945. lineCap: 'round'
  44946. }, axisModel.getModel(['axisLine', 'lineStyle']).getLineStyle());
  44947. var line = new Line({
  44948. // Id for animation
  44949. subPixelOptimize: true,
  44950. shape: {
  44951. x1: pt1[0],
  44952. y1: pt1[1],
  44953. x2: pt2[0],
  44954. y2: pt2[1]
  44955. },
  44956. style: lineStyle,
  44957. strokeContainThreshold: opt.strokeContainThreshold || 5,
  44958. silent: true,
  44959. z2: 1
  44960. });
  44961. line.anid = 'line';
  44962. group.add(line);
  44963. var arrows = axisModel.get(['axisLine', 'symbol']);
  44964. var arrowSize = axisModel.get(['axisLine', 'symbolSize']);
  44965. var arrowOffset = axisModel.get(['axisLine', 'symbolOffset']) || 0;
  44966. if (typeof arrowOffset === 'number') {
  44967. arrowOffset = [arrowOffset, arrowOffset];
  44968. }
  44969. if (arrows != null) {
  44970. if (typeof arrows === 'string') {
  44971. // Use the same arrow for start and end point
  44972. arrows = [arrows, arrows];
  44973. }
  44974. if (typeof arrowSize === 'string' || typeof arrowSize === 'number') {
  44975. // Use the same size for width and height
  44976. arrowSize = [arrowSize, arrowSize];
  44977. }
  44978. var symbolWidth_1 = arrowSize[0];
  44979. var symbolHeight_1 = arrowSize[1];
  44980. each$1([{
  44981. rotate: opt.rotation + Math.PI / 2,
  44982. offset: arrowOffset[0],
  44983. r: 0
  44984. }, {
  44985. rotate: opt.rotation - Math.PI / 2,
  44986. offset: arrowOffset[1],
  44987. r: Math.sqrt((pt1[0] - pt2[0]) * (pt1[0] - pt2[0]) + (pt1[1] - pt2[1]) * (pt1[1] - pt2[1]))
  44988. }], function (point, index) {
  44989. if (arrows[index] !== 'none' && arrows[index] != null) {
  44990. var symbol = createSymbol(arrows[index], -symbolWidth_1 / 2, -symbolHeight_1 / 2, symbolWidth_1, symbolHeight_1, lineStyle.stroke, true); // Calculate arrow position with offset
  44991. var r = point.r + point.offset;
  44992. symbol.attr({
  44993. rotation: point.rotate,
  44994. x: pt1[0] + r * Math.cos(opt.rotation),
  44995. y: pt1[1] - r * Math.sin(opt.rotation),
  44996. silent: true,
  44997. z2: 11
  44998. });
  44999. group.add(symbol);
  45000. }
  45001. });
  45002. }
  45003. },
  45004. axisTickLabel: function (opt, axisModel, group, transformGroup) {
  45005. var ticksEls = buildAxisMajorTicks(group, transformGroup, axisModel, opt);
  45006. var labelEls = buildAxisLabel(group, transformGroup, axisModel, opt);
  45007. fixMinMaxLabelShow(axisModel, labelEls, ticksEls);
  45008. buildAxisMinorTicks(group, transformGroup, axisModel, opt.tickDirection);
  45009. },
  45010. axisName: function (opt, axisModel, group, transformGroup) {
  45011. var name = retrieve(opt.axisName, axisModel.get('name'));
  45012. if (!name) {
  45013. return;
  45014. }
  45015. var nameLocation = axisModel.get('nameLocation');
  45016. var nameDirection = opt.nameDirection;
  45017. var textStyleModel = axisModel.getModel('nameTextStyle');
  45018. var gap = axisModel.get('nameGap') || 0;
  45019. var extent = axisModel.axis.getExtent();
  45020. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  45021. var pos = [nameLocation === 'start' ? extent[0] - gapSignal * gap : nameLocation === 'end' ? extent[1] + gapSignal * gap : (extent[0] + extent[1]) / 2, // Reuse labelOffset.
  45022. isNameLocationCenter(nameLocation) ? opt.labelOffset + nameDirection * gap : 0];
  45023. var labelLayout;
  45024. var nameRotation = axisModel.get('nameRotate');
  45025. if (nameRotation != null) {
  45026. nameRotation = nameRotation * PI$4 / 180; // To radian.
  45027. }
  45028. var axisNameAvailableWidth;
  45029. if (isNameLocationCenter(nameLocation)) {
  45030. labelLayout = AxisBuilder.innerTextLayout(opt.rotation, nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
  45031. nameDirection);
  45032. } else {
  45033. labelLayout = endTextLayout(opt.rotation, nameLocation, nameRotation || 0, extent);
  45034. axisNameAvailableWidth = opt.axisNameAvailableWidth;
  45035. if (axisNameAvailableWidth != null) {
  45036. axisNameAvailableWidth = Math.abs(axisNameAvailableWidth / Math.sin(labelLayout.rotation));
  45037. !isFinite(axisNameAvailableWidth) && (axisNameAvailableWidth = null);
  45038. }
  45039. }
  45040. var textFont = textStyleModel.getFont();
  45041. var truncateOpt = axisModel.get('nameTruncate', true) || {};
  45042. var ellipsis = truncateOpt.ellipsis;
  45043. var maxWidth = retrieve(opt.nameTruncateMaxWidth, truncateOpt.maxWidth, axisNameAvailableWidth);
  45044. var textEl = new ZRText({
  45045. x: pos[0],
  45046. y: pos[1],
  45047. rotation: labelLayout.rotation,
  45048. silent: AxisBuilder.isLabelSilent(axisModel),
  45049. style: createTextStyle(textStyleModel, {
  45050. text: name,
  45051. font: textFont,
  45052. overflow: 'truncate',
  45053. width: maxWidth,
  45054. ellipsis: ellipsis,
  45055. fill: textStyleModel.getTextColor() || axisModel.get(['axisLine', 'lineStyle', 'color']),
  45056. align: textStyleModel.get('align') || labelLayout.textAlign,
  45057. verticalAlign: textStyleModel.get('verticalAlign') || labelLayout.textVerticalAlign
  45058. }),
  45059. z2: 1
  45060. });
  45061. setTooltipConfig({
  45062. el: textEl,
  45063. componentModel: axisModel,
  45064. itemName: name
  45065. });
  45066. textEl.__fullText = name; // Id for animation
  45067. textEl.anid = 'name';
  45068. if (axisModel.get('triggerEvent')) {
  45069. var eventData = AxisBuilder.makeAxisEventDataBase(axisModel);
  45070. eventData.targetType = 'axisName';
  45071. eventData.name = name;
  45072. getECData(textEl).eventData = eventData;
  45073. } // FIXME
  45074. transformGroup.add(textEl);
  45075. textEl.updateTransform();
  45076. group.add(textEl);
  45077. textEl.decomposeTransform();
  45078. }
  45079. };
  45080. function endTextLayout(rotation, textPosition, textRotate, extent) {
  45081. var rotationDiff = remRadian(textRotate - rotation);
  45082. var textAlign;
  45083. var textVerticalAlign;
  45084. var inverse = extent[0] > extent[1];
  45085. var onLeft = textPosition === 'start' && !inverse || textPosition !== 'start' && inverse;
  45086. if (isRadianAroundZero(rotationDiff - PI$4 / 2)) {
  45087. textVerticalAlign = onLeft ? 'bottom' : 'top';
  45088. textAlign = 'center';
  45089. } else if (isRadianAroundZero(rotationDiff - PI$4 * 1.5)) {
  45090. textVerticalAlign = onLeft ? 'top' : 'bottom';
  45091. textAlign = 'center';
  45092. } else {
  45093. textVerticalAlign = 'middle';
  45094. if (rotationDiff < PI$4 * 1.5 && rotationDiff > PI$4 / 2) {
  45095. textAlign = onLeft ? 'left' : 'right';
  45096. } else {
  45097. textAlign = onLeft ? 'right' : 'left';
  45098. }
  45099. }
  45100. return {
  45101. rotation: rotationDiff,
  45102. textAlign: textAlign,
  45103. textVerticalAlign: textVerticalAlign
  45104. };
  45105. }
  45106. function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
  45107. if (shouldShowAllLabels(axisModel.axis)) {
  45108. return;
  45109. } // If min or max are user set, we need to check
  45110. // If the tick on min(max) are overlap on their neighbour tick
  45111. // If they are overlapped, we need to hide the min(max) tick label
  45112. var showMinLabel = axisModel.get(['axisLabel', 'showMinLabel']);
  45113. var showMaxLabel = axisModel.get(['axisLabel', 'showMaxLabel']); // FIXME
  45114. // Have not consider onBand yet, where tick els is more than label els.
  45115. labelEls = labelEls || [];
  45116. tickEls = tickEls || [];
  45117. var firstLabel = labelEls[0];
  45118. var nextLabel = labelEls[1];
  45119. var lastLabel = labelEls[labelEls.length - 1];
  45120. var prevLabel = labelEls[labelEls.length - 2];
  45121. var firstTick = tickEls[0];
  45122. var nextTick = tickEls[1];
  45123. var lastTick = tickEls[tickEls.length - 1];
  45124. var prevTick = tickEls[tickEls.length - 2];
  45125. if (showMinLabel === false) {
  45126. ignoreEl(firstLabel);
  45127. ignoreEl(firstTick);
  45128. } else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  45129. if (showMinLabel) {
  45130. ignoreEl(nextLabel);
  45131. ignoreEl(nextTick);
  45132. } else {
  45133. ignoreEl(firstLabel);
  45134. ignoreEl(firstTick);
  45135. }
  45136. }
  45137. if (showMaxLabel === false) {
  45138. ignoreEl(lastLabel);
  45139. ignoreEl(lastTick);
  45140. } else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  45141. if (showMaxLabel) {
  45142. ignoreEl(prevLabel);
  45143. ignoreEl(prevTick);
  45144. } else {
  45145. ignoreEl(lastLabel);
  45146. ignoreEl(lastTick);
  45147. }
  45148. }
  45149. }
  45150. function ignoreEl(el) {
  45151. el && (el.ignore = true);
  45152. }
  45153. function isTwoLabelOverlapped(current, next) {
  45154. // current and next has the same rotation.
  45155. var firstRect = current && current.getBoundingRect().clone();
  45156. var nextRect = next && next.getBoundingRect().clone();
  45157. if (!firstRect || !nextRect) {
  45158. return;
  45159. } // When checking intersect of two rotated labels, we use mRotationBack
  45160. // to avoid that boundingRect is enlarge when using `boundingRect.applyTransform`.
  45161. var mRotationBack = identity([]);
  45162. rotate(mRotationBack, mRotationBack, -current.rotation);
  45163. firstRect.applyTransform(mul$1([], mRotationBack, current.getLocalTransform()));
  45164. nextRect.applyTransform(mul$1([], mRotationBack, next.getLocalTransform()));
  45165. return firstRect.intersect(nextRect);
  45166. }
  45167. function isNameLocationCenter(nameLocation) {
  45168. return nameLocation === 'middle' || nameLocation === 'center';
  45169. }
  45170. function createTicks(ticksCoords, tickTransform, tickEndCoord, tickLineStyle, anidPrefix) {
  45171. var tickEls = [];
  45172. var pt1 = [];
  45173. var pt2 = [];
  45174. for (var i = 0; i < ticksCoords.length; i++) {
  45175. var tickCoord = ticksCoords[i].coord;
  45176. pt1[0] = tickCoord;
  45177. pt1[1] = 0;
  45178. pt2[0] = tickCoord;
  45179. pt2[1] = tickEndCoord;
  45180. if (tickTransform) {
  45181. applyTransform(pt1, pt1, tickTransform);
  45182. applyTransform(pt2, pt2, tickTransform);
  45183. } // Tick line, Not use group transform to have better line draw
  45184. var tickEl = new Line({
  45185. subPixelOptimize: true,
  45186. shape: {
  45187. x1: pt1[0],
  45188. y1: pt1[1],
  45189. x2: pt2[0],
  45190. y2: pt2[1]
  45191. },
  45192. style: tickLineStyle,
  45193. z2: 2,
  45194. autoBatch: true,
  45195. silent: true
  45196. });
  45197. tickEl.anid = anidPrefix + '_' + ticksCoords[i].tickValue;
  45198. tickEls.push(tickEl);
  45199. }
  45200. return tickEls;
  45201. }
  45202. function buildAxisMajorTicks(group, transformGroup, axisModel, opt) {
  45203. var axis = axisModel.axis;
  45204. var tickModel = axisModel.getModel('axisTick');
  45205. var shown = tickModel.get('show');
  45206. if (shown === 'auto' && opt.handleAutoShown) {
  45207. shown = opt.handleAutoShown('axisTick');
  45208. }
  45209. if (!shown || axis.scale.isBlank()) {
  45210. return;
  45211. }
  45212. var lineStyleModel = tickModel.getModel('lineStyle');
  45213. var tickEndCoord = opt.tickDirection * tickModel.get('length');
  45214. var ticksCoords = axis.getTicksCoords();
  45215. var ticksEls = createTicks(ticksCoords, transformGroup.transform, tickEndCoord, defaults(lineStyleModel.getLineStyle(), {
  45216. stroke: axisModel.get(['axisLine', 'lineStyle', 'color'])
  45217. }), 'ticks');
  45218. for (var i = 0; i < ticksEls.length; i++) {
  45219. group.add(ticksEls[i]);
  45220. }
  45221. return ticksEls;
  45222. }
  45223. function buildAxisMinorTicks(group, transformGroup, axisModel, tickDirection) {
  45224. var axis = axisModel.axis;
  45225. var minorTickModel = axisModel.getModel('minorTick');
  45226. if (!minorTickModel.get('show') || axis.scale.isBlank()) {
  45227. return;
  45228. }
  45229. var minorTicksCoords = axis.getMinorTicksCoords();
  45230. if (!minorTicksCoords.length) {
  45231. return;
  45232. }
  45233. var lineStyleModel = minorTickModel.getModel('lineStyle');
  45234. var tickEndCoord = tickDirection * minorTickModel.get('length');
  45235. var minorTickLineStyle = defaults(lineStyleModel.getLineStyle(), defaults(axisModel.getModel('axisTick').getLineStyle(), {
  45236. stroke: axisModel.get(['axisLine', 'lineStyle', 'color'])
  45237. }));
  45238. for (var i = 0; i < minorTicksCoords.length; i++) {
  45239. var minorTicksEls = createTicks(minorTicksCoords[i], transformGroup.transform, tickEndCoord, minorTickLineStyle, 'minorticks_' + i);
  45240. for (var k = 0; k < minorTicksEls.length; k++) {
  45241. group.add(minorTicksEls[k]);
  45242. }
  45243. }
  45244. }
  45245. function buildAxisLabel(group, transformGroup, axisModel, opt) {
  45246. var axis = axisModel.axis;
  45247. var show = retrieve(opt.axisLabelShow, axisModel.get(['axisLabel', 'show']));
  45248. if (!show || axis.scale.isBlank()) {
  45249. return;
  45250. }
  45251. var labelModel = axisModel.getModel('axisLabel');
  45252. var labelMargin = labelModel.get('margin');
  45253. var labels = axis.getViewLabels(); // Special label rotate.
  45254. var labelRotation = (retrieve(opt.labelRotate, labelModel.get('rotate')) || 0) * PI$4 / 180;
  45255. var labelLayout = AxisBuilder.innerTextLayout(opt.rotation, labelRotation, opt.labelDirection);
  45256. var rawCategoryData = axisModel.getCategories && axisModel.getCategories(true);
  45257. var labelEls = [];
  45258. var silent = AxisBuilder.isLabelSilent(axisModel);
  45259. var triggerEvent = axisModel.get('triggerEvent');
  45260. each$1(labels, function (labelItem, index) {
  45261. var tickValue = axis.scale.type === 'ordinal' ? axis.scale.getRawOrdinalNumber(labelItem.tickValue) : labelItem.tickValue;
  45262. var formattedLabel = labelItem.formattedLabel;
  45263. var rawLabel = labelItem.rawLabel;
  45264. var itemLabelModel = labelModel;
  45265. if (rawCategoryData && rawCategoryData[tickValue]) {
  45266. var rawCategoryItem = rawCategoryData[tickValue];
  45267. if (isObject$1(rawCategoryItem) && rawCategoryItem.textStyle) {
  45268. itemLabelModel = new Model(rawCategoryItem.textStyle, labelModel, axisModel.ecModel);
  45269. }
  45270. }
  45271. var textColor = itemLabelModel.getTextColor() || axisModel.get(['axisLine', 'lineStyle', 'color']);
  45272. var tickCoord = axis.dataToCoord(tickValue);
  45273. var textEl = new ZRText({
  45274. x: tickCoord,
  45275. y: opt.labelOffset + opt.labelDirection * labelMargin,
  45276. rotation: labelLayout.rotation,
  45277. silent: silent,
  45278. z2: 10,
  45279. style: createTextStyle(itemLabelModel, {
  45280. text: formattedLabel,
  45281. align: itemLabelModel.getShallow('align', true) || labelLayout.textAlign,
  45282. verticalAlign: itemLabelModel.getShallow('verticalAlign', true) || itemLabelModel.getShallow('baseline', true) || labelLayout.textVerticalAlign,
  45283. fill: typeof textColor === 'function' ? textColor( // (1) In category axis with data zoom, tick is not the original
  45284. // index of axis.data. So tick should not be exposed to user
  45285. // in category axis.
  45286. // (2) Compatible with previous version, which always use formatted label as
  45287. // input. But in interval scale the formatted label is like '223,445', which
  45288. // maked user repalce ','. So we modify it to return original val but remain
  45289. // it as 'string' to avoid error in replacing.
  45290. axis.type === 'category' ? rawLabel : axis.type === 'value' ? tickValue + '' : tickValue, index) : textColor
  45291. })
  45292. });
  45293. textEl.anid = 'label_' + tickValue; // Pack data for mouse event
  45294. if (triggerEvent) {
  45295. var eventData = AxisBuilder.makeAxisEventDataBase(axisModel);
  45296. eventData.targetType = 'axisLabel';
  45297. eventData.value = rawLabel;
  45298. getECData(textEl).eventData = eventData;
  45299. } // FIXME
  45300. transformGroup.add(textEl);
  45301. textEl.updateTransform();
  45302. labelEls.push(textEl);
  45303. group.add(textEl);
  45304. textEl.decomposeTransform();
  45305. });
  45306. return labelEls;
  45307. }
  45308. /*
  45309. * Licensed to the Apache Software Foundation (ASF) under one
  45310. * or more contributor license agreements. See the NOTICE file
  45311. * distributed with this work for additional information
  45312. * regarding copyright ownership. The ASF licenses this file
  45313. * to you under the Apache License, Version 2.0 (the
  45314. * "License"); you may not use this file except in compliance
  45315. * with the License. You may obtain a copy of the License at
  45316. *
  45317. * http://www.apache.org/licenses/LICENSE-2.0
  45318. *
  45319. * Unless required by applicable law or agreed to in writing,
  45320. * software distributed under the License is distributed on an
  45321. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45322. * KIND, either express or implied. See the License for the
  45323. * specific language governing permissions and limitations
  45324. * under the License.
  45325. */
  45326. /**
  45327. * AUTO-GENERATED FILE. DO NOT MODIFY.
  45328. */
  45329. /*
  45330. * Licensed to the Apache Software Foundation (ASF) under one
  45331. * or more contributor license agreements. See the NOTICE file
  45332. * distributed with this work for additional information
  45333. * regarding copyright ownership. The ASF licenses this file
  45334. * to you under the Apache License, Version 2.0 (the
  45335. * "License"); you may not use this file except in compliance
  45336. * with the License. You may obtain a copy of the License at
  45337. *
  45338. * http://www.apache.org/licenses/LICENSE-2.0
  45339. *
  45340. * Unless required by applicable law or agreed to in writing,
  45341. * software distributed under the License is distributed on an
  45342. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45343. * KIND, either express or implied. See the License for the
  45344. * specific language governing permissions and limitations
  45345. * under the License.
  45346. */
  45347. // allAxesInfo should be updated when setOption performed.
  45348. function collect(ecModel, api) {
  45349. var result = {
  45350. /**
  45351. * key: makeKey(axis.model)
  45352. * value: {
  45353. * axis,
  45354. * coordSys,
  45355. * axisPointerModel,
  45356. * triggerTooltip,
  45357. * involveSeries,
  45358. * snap,
  45359. * seriesModels,
  45360. * seriesDataCount
  45361. * }
  45362. */
  45363. axesInfo: {},
  45364. seriesInvolved: false,
  45365. /**
  45366. * key: makeKey(coordSys.model)
  45367. * value: Object: key makeKey(axis.model), value: axisInfo
  45368. */
  45369. coordSysAxesInfo: {},
  45370. coordSysMap: {}
  45371. };
  45372. collectAxesInfo(result, ecModel, api); // Check seriesInvolved for performance, in case too many series in some chart.
  45373. result.seriesInvolved && collectSeriesInfo(result, ecModel);
  45374. return result;
  45375. }
  45376. function collectAxesInfo(result, ecModel, api) {
  45377. var globalTooltipModel = ecModel.getComponent('tooltip');
  45378. var globalAxisPointerModel = ecModel.getComponent('axisPointer'); // links can only be set on global.
  45379. var linksOption = globalAxisPointerModel.get('link', true) || [];
  45380. var linkGroups = []; // Collect axes info.
  45381. each$1(api.getCoordinateSystems(), function (coordSys) {
  45382. // Some coordinate system do not support axes, like geo.
  45383. if (!coordSys.axisPointerEnabled) {
  45384. return;
  45385. }
  45386. var coordSysKey = makeKey(coordSys.model);
  45387. var axesInfoInCoordSys = result.coordSysAxesInfo[coordSysKey] = {};
  45388. result.coordSysMap[coordSysKey] = coordSys; // Set tooltip (like 'cross') is a convienent way to show axisPointer
  45389. // for user. So we enable seting tooltip on coordSys model.
  45390. var coordSysModel = coordSys.model;
  45391. var baseTooltipModel = coordSysModel.getModel('tooltip', globalTooltipModel);
  45392. each$1(coordSys.getAxes(), curry(saveTooltipAxisInfo, false, null)); // If axis tooltip used, choose tooltip axis for each coordSys.
  45393. // Notice this case: coordSys is `grid` but not `cartesian2D` here.
  45394. if (coordSys.getTooltipAxes && globalTooltipModel // If tooltip.showContent is set as false, tooltip will not
  45395. // show but axisPointer will show as normal.
  45396. && baseTooltipModel.get('show')) {
  45397. // Compatible with previous logic. But series.tooltip.trigger: 'axis'
  45398. // or series.data[n].tooltip.trigger: 'axis' are not support any more.
  45399. var triggerAxis = baseTooltipModel.get('trigger') === 'axis';
  45400. var cross = baseTooltipModel.get(['axisPointer', 'type']) === 'cross';
  45401. var tooltipAxes = coordSys.getTooltipAxes(baseTooltipModel.get(['axisPointer', 'axis']));
  45402. if (triggerAxis || cross) {
  45403. each$1(tooltipAxes.baseAxes, curry(saveTooltipAxisInfo, cross ? 'cross' : true, triggerAxis));
  45404. }
  45405. if (cross) {
  45406. each$1(tooltipAxes.otherAxes, curry(saveTooltipAxisInfo, 'cross', false));
  45407. }
  45408. } // fromTooltip: true | false | 'cross'
  45409. // triggerTooltip: true | false | null
  45410. function saveTooltipAxisInfo(fromTooltip, triggerTooltip, axis) {
  45411. var axisPointerModel = axis.model.getModel('axisPointer', globalAxisPointerModel);
  45412. var axisPointerShow = axisPointerModel.get('show');
  45413. if (!axisPointerShow || axisPointerShow === 'auto' && !fromTooltip && !isHandleTrigger(axisPointerModel)) {
  45414. return;
  45415. }
  45416. if (triggerTooltip == null) {
  45417. triggerTooltip = axisPointerModel.get('triggerTooltip');
  45418. }
  45419. axisPointerModel = fromTooltip ? makeAxisPointerModel(axis, baseTooltipModel, globalAxisPointerModel, ecModel, fromTooltip, triggerTooltip) : axisPointerModel;
  45420. var snap = axisPointerModel.get('snap');
  45421. var axisKey = makeKey(axis.model);
  45422. var involveSeries = triggerTooltip || snap || axis.type === 'category'; // If result.axesInfo[key] exist, override it (tooltip has higher priority).
  45423. var axisInfo = result.axesInfo[axisKey] = {
  45424. key: axisKey,
  45425. axis: axis,
  45426. coordSys: coordSys,
  45427. axisPointerModel: axisPointerModel,
  45428. triggerTooltip: triggerTooltip,
  45429. involveSeries: involveSeries,
  45430. snap: snap,
  45431. useHandle: isHandleTrigger(axisPointerModel),
  45432. seriesModels: [],
  45433. linkGroup: null
  45434. };
  45435. axesInfoInCoordSys[axisKey] = axisInfo;
  45436. result.seriesInvolved = result.seriesInvolved || involveSeries;
  45437. var groupIndex = getLinkGroupIndex(linksOption, axis);
  45438. if (groupIndex != null) {
  45439. var linkGroup = linkGroups[groupIndex] || (linkGroups[groupIndex] = {
  45440. axesInfo: {}
  45441. });
  45442. linkGroup.axesInfo[axisKey] = axisInfo;
  45443. linkGroup.mapper = linksOption[groupIndex].mapper;
  45444. axisInfo.linkGroup = linkGroup;
  45445. }
  45446. }
  45447. });
  45448. }
  45449. function makeAxisPointerModel(axis, baseTooltipModel, globalAxisPointerModel, ecModel, fromTooltip, triggerTooltip) {
  45450. var tooltipAxisPointerModel = baseTooltipModel.getModel('axisPointer');
  45451. var fields = ['type', 'snap', 'lineStyle', 'shadowStyle', 'label', 'animation', 'animationDurationUpdate', 'animationEasingUpdate', 'z'];
  45452. var volatileOption = {};
  45453. each$1(fields, function (field) {
  45454. volatileOption[field] = clone(tooltipAxisPointerModel.get(field));
  45455. }); // category axis do not auto snap, otherwise some tick that do not
  45456. // has value can not be hovered. value/time/log axis default snap if
  45457. // triggered from tooltip and trigger tooltip.
  45458. volatileOption.snap = axis.type !== 'category' && !!triggerTooltip; // Compatibel with previous behavior, tooltip axis do not show label by default.
  45459. // Only these properties can be overrided from tooltip to axisPointer.
  45460. if (tooltipAxisPointerModel.get('type') === 'cross') {
  45461. volatileOption.type = 'line';
  45462. }
  45463. var labelOption = volatileOption.label || (volatileOption.label = {}); // Follow the convention, do not show label when triggered by tooltip by default.
  45464. labelOption.show == null && (labelOption.show = false);
  45465. if (fromTooltip === 'cross') {
  45466. // When 'cross', both axes show labels.
  45467. var tooltipAxisPointerLabelShow = tooltipAxisPointerModel.get(['label', 'show']);
  45468. labelOption.show = tooltipAxisPointerLabelShow != null ? tooltipAxisPointerLabelShow : true; // If triggerTooltip, this is a base axis, which should better not use cross style
  45469. // (cross style is dashed by default)
  45470. if (!triggerTooltip) {
  45471. var crossStyle = volatileOption.lineStyle = tooltipAxisPointerModel.get('crossStyle');
  45472. crossStyle && defaults(labelOption, crossStyle.textStyle);
  45473. }
  45474. }
  45475. return axis.model.getModel('axisPointer', new Model(volatileOption, globalAxisPointerModel, ecModel));
  45476. }
  45477. function collectSeriesInfo(result, ecModel) {
  45478. // Prepare data for axis trigger
  45479. ecModel.eachSeries(function (seriesModel) {
  45480. // Notice this case: this coordSys is `cartesian2D` but not `grid`.
  45481. var coordSys = seriesModel.coordinateSystem;
  45482. var seriesTooltipTrigger = seriesModel.get(['tooltip', 'trigger'], true);
  45483. var seriesTooltipShow = seriesModel.get(['tooltip', 'show'], true);
  45484. if (!coordSys || seriesTooltipTrigger === 'none' || seriesTooltipTrigger === false || seriesTooltipTrigger === 'item' || seriesTooltipShow === false || seriesModel.get(['axisPointer', 'show'], true) === false) {
  45485. return;
  45486. }
  45487. each$1(result.coordSysAxesInfo[makeKey(coordSys.model)], function (axisInfo) {
  45488. var axis = axisInfo.axis;
  45489. if (coordSys.getAxis(axis.dim) === axis) {
  45490. axisInfo.seriesModels.push(seriesModel);
  45491. axisInfo.seriesDataCount == null && (axisInfo.seriesDataCount = 0);
  45492. axisInfo.seriesDataCount += seriesModel.getData().count();
  45493. }
  45494. });
  45495. });
  45496. }
  45497. /**
  45498. * For example:
  45499. * {
  45500. * axisPointer: {
  45501. * links: [{
  45502. * xAxisIndex: [2, 4],
  45503. * yAxisIndex: 'all'
  45504. * }, {
  45505. * xAxisId: ['a5', 'a7'],
  45506. * xAxisName: 'xxx'
  45507. * }]
  45508. * }
  45509. * }
  45510. */
  45511. function getLinkGroupIndex(linksOption, axis) {
  45512. var axisModel = axis.model;
  45513. var dim = axis.dim;
  45514. for (var i = 0; i < linksOption.length; i++) {
  45515. var linkOption = linksOption[i] || {};
  45516. if (checkPropInLink(linkOption[dim + 'AxisId'], axisModel.id) || checkPropInLink(linkOption[dim + 'AxisIndex'], axisModel.componentIndex) || checkPropInLink(linkOption[dim + 'AxisName'], axisModel.name)) {
  45517. return i;
  45518. }
  45519. }
  45520. }
  45521. function checkPropInLink(linkPropValue, axisPropValue) {
  45522. return linkPropValue === 'all' || isArray(linkPropValue) && indexOf$1(linkPropValue, axisPropValue) >= 0 || linkPropValue === axisPropValue;
  45523. }
  45524. function fixValue(axisModel) {
  45525. var axisInfo = getAxisInfo(axisModel);
  45526. if (!axisInfo) {
  45527. return;
  45528. }
  45529. var axisPointerModel = axisInfo.axisPointerModel;
  45530. var scale = axisInfo.axis.scale;
  45531. var option = axisPointerModel.option;
  45532. var status = axisPointerModel.get('status');
  45533. var value = axisPointerModel.get('value'); // Parse init value for category and time axis.
  45534. if (value != null) {
  45535. value = scale.parse(value);
  45536. }
  45537. var useHandle = isHandleTrigger(axisPointerModel); // If `handle` used, `axisPointer` will always be displayed, so value
  45538. // and status should be initialized.
  45539. if (status == null) {
  45540. option.status = useHandle ? 'show' : 'hide';
  45541. }
  45542. var extent = scale.getExtent().slice();
  45543. extent[0] > extent[1] && extent.reverse();
  45544. if ( // Pick a value on axis when initializing.
  45545. value == null // If both `handle` and `dataZoom` are used, value may be out of axis extent,
  45546. // where we should re-pick a value to keep `handle` displaying normally.
  45547. || value > extent[1]) {
  45548. // Make handle displayed on the end of the axis when init, which looks better.
  45549. value = extent[1];
  45550. }
  45551. if (value < extent[0]) {
  45552. value = extent[0];
  45553. }
  45554. option.value = value;
  45555. if (useHandle) {
  45556. option.status = axisInfo.axis.scale.isBlank() ? 'hide' : 'show';
  45557. }
  45558. }
  45559. function getAxisInfo(axisModel) {
  45560. var coordSysAxesInfo = (axisModel.ecModel.getComponent('axisPointer') || {}).coordSysAxesInfo;
  45561. return coordSysAxesInfo && coordSysAxesInfo.axesInfo[makeKey(axisModel)];
  45562. }
  45563. function getAxisPointerModel(axisModel) {
  45564. var axisInfo = getAxisInfo(axisModel);
  45565. return axisInfo && axisInfo.axisPointerModel;
  45566. }
  45567. function isHandleTrigger(axisPointerModel) {
  45568. return !!axisPointerModel.get(['handle', 'show']);
  45569. }
  45570. /**
  45571. * @param {module:echarts/model/Model} model
  45572. * @return {string} unique key
  45573. */
  45574. function makeKey(model) {
  45575. return model.type + '||' + model.id;
  45576. }
  45577. /*
  45578. * Licensed to the Apache Software Foundation (ASF) under one
  45579. * or more contributor license agreements. See the NOTICE file
  45580. * distributed with this work for additional information
  45581. * regarding copyright ownership. The ASF licenses this file
  45582. * to you under the Apache License, Version 2.0 (the
  45583. * "License"); you may not use this file except in compliance
  45584. * with the License. You may obtain a copy of the License at
  45585. *
  45586. * http://www.apache.org/licenses/LICENSE-2.0
  45587. *
  45588. * Unless required by applicable law or agreed to in writing,
  45589. * software distributed under the License is distributed on an
  45590. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45591. * KIND, either express or implied. See the License for the
  45592. * specific language governing permissions and limitations
  45593. * under the License.
  45594. */
  45595. /**
  45596. * AUTO-GENERATED FILE. DO NOT MODIFY.
  45597. */
  45598. /*
  45599. * Licensed to the Apache Software Foundation (ASF) under one
  45600. * or more contributor license agreements. See the NOTICE file
  45601. * distributed with this work for additional information
  45602. * regarding copyright ownership. The ASF licenses this file
  45603. * to you under the Apache License, Version 2.0 (the
  45604. * "License"); you may not use this file except in compliance
  45605. * with the License. You may obtain a copy of the License at
  45606. *
  45607. * http://www.apache.org/licenses/LICENSE-2.0
  45608. *
  45609. * Unless required by applicable law or agreed to in writing,
  45610. * software distributed under the License is distributed on an
  45611. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45612. * KIND, either express or implied. See the License for the
  45613. * specific language governing permissions and limitations
  45614. * under the License.
  45615. */
  45616. var axisPointerClazz = {};
  45617. /**
  45618. * Base class of AxisView.
  45619. */
  45620. var AxisView =
  45621. /** @class */
  45622. function (_super) {
  45623. __extends(AxisView, _super);
  45624. function AxisView() {
  45625. var _this = _super !== null && _super.apply(this, arguments) || this;
  45626. _this.type = AxisView.type;
  45627. return _this;
  45628. }
  45629. /**
  45630. * @override
  45631. */
  45632. AxisView.prototype.render = function (axisModel, ecModel, api, payload) {
  45633. // FIXME
  45634. // This process should proformed after coordinate systems updated
  45635. // (axis scale updated), and should be performed each time update.
  45636. // So put it here temporarily, although it is not appropriate to
  45637. // put a model-writing procedure in `view`.
  45638. this.axisPointerClass && fixValue(axisModel);
  45639. _super.prototype.render.apply(this, arguments);
  45640. this._doUpdateAxisPointerClass(axisModel, api, true);
  45641. };
  45642. /**
  45643. * Action handler.
  45644. */
  45645. AxisView.prototype.updateAxisPointer = function (axisModel, ecModel, api, payload) {
  45646. this._doUpdateAxisPointerClass(axisModel, api, false);
  45647. };
  45648. /**
  45649. * @override
  45650. */
  45651. AxisView.prototype.remove = function (ecModel, api) {
  45652. var axisPointer = this._axisPointer;
  45653. axisPointer && axisPointer.remove(api);
  45654. };
  45655. /**
  45656. * @override
  45657. */
  45658. AxisView.prototype.dispose = function (ecModel, api) {
  45659. this._disposeAxisPointer(api);
  45660. _super.prototype.dispose.apply(this, arguments);
  45661. };
  45662. AxisView.prototype._doUpdateAxisPointerClass = function (axisModel, api, forceRender) {
  45663. var Clazz = AxisView.getAxisPointerClass(this.axisPointerClass);
  45664. if (!Clazz) {
  45665. return;
  45666. }
  45667. var axisPointerModel = getAxisPointerModel(axisModel);
  45668. axisPointerModel ? (this._axisPointer || (this._axisPointer = new Clazz())).render(axisModel, axisPointerModel, api, forceRender) : this._disposeAxisPointer(api);
  45669. };
  45670. AxisView.prototype._disposeAxisPointer = function (api) {
  45671. this._axisPointer && this._axisPointer.dispose(api);
  45672. this._axisPointer = null;
  45673. };
  45674. AxisView.registerAxisPointerClass = function (type, clazz) {
  45675. {
  45676. if (axisPointerClazz[type]) {
  45677. throw new Error('axisPointer ' + type + ' exists');
  45678. }
  45679. }
  45680. axisPointerClazz[type] = clazz;
  45681. };
  45682. AxisView.getAxisPointerClass = function (type) {
  45683. return type && axisPointerClazz[type];
  45684. };
  45685. AxisView.type = 'axis';
  45686. return AxisView;
  45687. }(ComponentView);
  45688. /*
  45689. * Licensed to the Apache Software Foundation (ASF) under one
  45690. * or more contributor license agreements. See the NOTICE file
  45691. * distributed with this work for additional information
  45692. * regarding copyright ownership. The ASF licenses this file
  45693. * to you under the Apache License, Version 2.0 (the
  45694. * "License"); you may not use this file except in compliance
  45695. * with the License. You may obtain a copy of the License at
  45696. *
  45697. * http://www.apache.org/licenses/LICENSE-2.0
  45698. *
  45699. * Unless required by applicable law or agreed to in writing,
  45700. * software distributed under the License is distributed on an
  45701. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45702. * KIND, either express or implied. See the License for the
  45703. * specific language governing permissions and limitations
  45704. * under the License.
  45705. */
  45706. /**
  45707. * AUTO-GENERATED FILE. DO NOT MODIFY.
  45708. */
  45709. /*
  45710. * Licensed to the Apache Software Foundation (ASF) under one
  45711. * or more contributor license agreements. See the NOTICE file
  45712. * distributed with this work for additional information
  45713. * regarding copyright ownership. The ASF licenses this file
  45714. * to you under the Apache License, Version 2.0 (the
  45715. * "License"); you may not use this file except in compliance
  45716. * with the License. You may obtain a copy of the License at
  45717. *
  45718. * http://www.apache.org/licenses/LICENSE-2.0
  45719. *
  45720. * Unless required by applicable law or agreed to in writing,
  45721. * software distributed under the License is distributed on an
  45722. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45723. * KIND, either express or implied. See the License for the
  45724. * specific language governing permissions and limitations
  45725. * under the License.
  45726. */
  45727. var inner$5 = makeInner();
  45728. function rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel) {
  45729. var axis = axisModel.axis;
  45730. if (axis.scale.isBlank()) {
  45731. return;
  45732. } // TODO: TYPE
  45733. var splitAreaModel = axisModel.getModel('splitArea');
  45734. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  45735. var areaColors = areaStyleModel.get('color');
  45736. var gridRect = gridModel.coordinateSystem.getRect();
  45737. var ticksCoords = axis.getTicksCoords({
  45738. tickModel: splitAreaModel,
  45739. clamp: true
  45740. });
  45741. if (!ticksCoords.length) {
  45742. return;
  45743. } // For Making appropriate splitArea animation, the color and anid
  45744. // should be corresponding to previous one if possible.
  45745. var areaColorsLen = areaColors.length;
  45746. var lastSplitAreaColors = inner$5(axisView).splitAreaColors;
  45747. var newSplitAreaColors = createHashMap();
  45748. var colorIndex = 0;
  45749. if (lastSplitAreaColors) {
  45750. for (var i = 0; i < ticksCoords.length; i++) {
  45751. var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue);
  45752. if (cIndex != null) {
  45753. colorIndex = (cIndex + (areaColorsLen - 1) * i) % areaColorsLen;
  45754. break;
  45755. }
  45756. }
  45757. }
  45758. var prev = axis.toGlobalCoord(ticksCoords[0].coord);
  45759. var areaStyle = areaStyleModel.getAreaStyle();
  45760. areaColors = isArray(areaColors) ? areaColors : [areaColors];
  45761. for (var i = 1; i < ticksCoords.length; i++) {
  45762. var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
  45763. var x = void 0;
  45764. var y = void 0;
  45765. var width = void 0;
  45766. var height = void 0;
  45767. if (axis.isHorizontal()) {
  45768. x = prev;
  45769. y = gridRect.y;
  45770. width = tickCoord - x;
  45771. height = gridRect.height;
  45772. prev = x + width;
  45773. } else {
  45774. x = gridRect.x;
  45775. y = prev;
  45776. width = gridRect.width;
  45777. height = tickCoord - y;
  45778. prev = y + height;
  45779. }
  45780. var tickValue = ticksCoords[i - 1].tickValue;
  45781. tickValue != null && newSplitAreaColors.set(tickValue, colorIndex);
  45782. axisGroup.add(new Rect({
  45783. anid: tickValue != null ? 'area_' + tickValue : null,
  45784. shape: {
  45785. x: x,
  45786. y: y,
  45787. width: width,
  45788. height: height
  45789. },
  45790. style: defaults({
  45791. fill: areaColors[colorIndex]
  45792. }, areaStyle),
  45793. autoBatch: true,
  45794. silent: true
  45795. }));
  45796. colorIndex = (colorIndex + 1) % areaColorsLen;
  45797. }
  45798. inner$5(axisView).splitAreaColors = newSplitAreaColors;
  45799. }
  45800. function rectCoordAxisHandleRemove(axisView) {
  45801. inner$5(axisView).splitAreaColors = null;
  45802. }
  45803. /*
  45804. * Licensed to the Apache Software Foundation (ASF) under one
  45805. * or more contributor license agreements. See the NOTICE file
  45806. * distributed with this work for additional information
  45807. * regarding copyright ownership. The ASF licenses this file
  45808. * to you under the Apache License, Version 2.0 (the
  45809. * "License"); you may not use this file except in compliance
  45810. * with the License. You may obtain a copy of the License at
  45811. *
  45812. * http://www.apache.org/licenses/LICENSE-2.0
  45813. *
  45814. * Unless required by applicable law or agreed to in writing,
  45815. * software distributed under the License is distributed on an
  45816. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45817. * KIND, either express or implied. See the License for the
  45818. * specific language governing permissions and limitations
  45819. * under the License.
  45820. */
  45821. /**
  45822. * AUTO-GENERATED FILE. DO NOT MODIFY.
  45823. */
  45824. /*
  45825. * Licensed to the Apache Software Foundation (ASF) under one
  45826. * or more contributor license agreements. See the NOTICE file
  45827. * distributed with this work for additional information
  45828. * regarding copyright ownership. The ASF licenses this file
  45829. * to you under the Apache License, Version 2.0 (the
  45830. * "License"); you may not use this file except in compliance
  45831. * with the License. You may obtain a copy of the License at
  45832. *
  45833. * http://www.apache.org/licenses/LICENSE-2.0
  45834. *
  45835. * Unless required by applicable law or agreed to in writing,
  45836. * software distributed under the License is distributed on an
  45837. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45838. * KIND, either express or implied. See the License for the
  45839. * specific language governing permissions and limitations
  45840. * under the License.
  45841. */
  45842. var axisBuilderAttrs = ['axisLine', 'axisTickLabel', 'axisName'];
  45843. var selfBuilderAttrs = ['splitArea', 'splitLine', 'minorSplitLine'];
  45844. var CartesianAxisView =
  45845. /** @class */
  45846. function (_super) {
  45847. __extends(CartesianAxisView, _super);
  45848. function CartesianAxisView() {
  45849. var _this = _super !== null && _super.apply(this, arguments) || this;
  45850. _this.type = CartesianAxisView.type;
  45851. _this.axisPointerClass = 'CartesianAxisPointer';
  45852. return _this;
  45853. }
  45854. /**
  45855. * @override
  45856. */
  45857. CartesianAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
  45858. this.group.removeAll();
  45859. var oldAxisGroup = this._axisGroup;
  45860. this._axisGroup = new Group();
  45861. this.group.add(this._axisGroup);
  45862. if (!axisModel.get('show')) {
  45863. return;
  45864. }
  45865. var gridModel = axisModel.getCoordSysModel();
  45866. var layout = layout$1(gridModel, axisModel);
  45867. var axisBuilder = new AxisBuilder(axisModel, extend({
  45868. handleAutoShown: function (elementType) {
  45869. var cartesians = gridModel.coordinateSystem.getCartesians();
  45870. for (var i = 0; i < cartesians.length; i++) {
  45871. var otherAxisType = cartesians[i].getOtherAxis(axisModel.axis).type;
  45872. if (otherAxisType === 'value' || otherAxisType === 'log') {
  45873. // Still show axis tick or axisLine if other axis is value / log
  45874. return true;
  45875. }
  45876. } // Not show axisTick or axisLine if other axis is category / time
  45877. return false;
  45878. }
  45879. }, layout));
  45880. each$1(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  45881. this._axisGroup.add(axisBuilder.getGroup());
  45882. each$1(selfBuilderAttrs, function (name) {
  45883. if (axisModel.get([name, 'show'])) {
  45884. axisElementBuilders[name](this, this._axisGroup, axisModel, gridModel);
  45885. }
  45886. }, this);
  45887. groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  45888. _super.prototype.render.call(this, axisModel, ecModel, api, payload);
  45889. };
  45890. CartesianAxisView.prototype.remove = function () {
  45891. rectCoordAxisHandleRemove(this);
  45892. };
  45893. CartesianAxisView.type = 'cartesianAxis';
  45894. return CartesianAxisView;
  45895. }(AxisView);
  45896. var axisElementBuilders = {
  45897. splitLine: function (axisView, axisGroup, axisModel, gridModel) {
  45898. var axis = axisModel.axis;
  45899. if (axis.scale.isBlank()) {
  45900. return;
  45901. }
  45902. var splitLineModel = axisModel.getModel('splitLine');
  45903. var lineStyleModel = splitLineModel.getModel('lineStyle');
  45904. var lineColors = lineStyleModel.get('color');
  45905. lineColors = isArray(lineColors) ? lineColors : [lineColors];
  45906. var gridRect = gridModel.coordinateSystem.getRect();
  45907. var isHorizontal = axis.isHorizontal();
  45908. var lineCount = 0;
  45909. var ticksCoords = axis.getTicksCoords({
  45910. tickModel: splitLineModel
  45911. });
  45912. var p1 = [];
  45913. var p2 = [];
  45914. var lineStyle = lineStyleModel.getLineStyle();
  45915. for (var i = 0; i < ticksCoords.length; i++) {
  45916. var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
  45917. if (isHorizontal) {
  45918. p1[0] = tickCoord;
  45919. p1[1] = gridRect.y;
  45920. p2[0] = tickCoord;
  45921. p2[1] = gridRect.y + gridRect.height;
  45922. } else {
  45923. p1[0] = gridRect.x;
  45924. p1[1] = tickCoord;
  45925. p2[0] = gridRect.x + gridRect.width;
  45926. p2[1] = tickCoord;
  45927. }
  45928. var colorIndex = lineCount++ % lineColors.length;
  45929. var tickValue = ticksCoords[i].tickValue;
  45930. axisGroup.add(new Line({
  45931. anid: tickValue != null ? 'line_' + ticksCoords[i].tickValue : null,
  45932. subPixelOptimize: true,
  45933. autoBatch: true,
  45934. shape: {
  45935. x1: p1[0],
  45936. y1: p1[1],
  45937. x2: p2[0],
  45938. y2: p2[1]
  45939. },
  45940. style: defaults({
  45941. stroke: lineColors[colorIndex]
  45942. }, lineStyle),
  45943. silent: true
  45944. }));
  45945. }
  45946. },
  45947. minorSplitLine: function (axisView, axisGroup, axisModel, gridModel) {
  45948. var axis = axisModel.axis;
  45949. var minorSplitLineModel = axisModel.getModel('minorSplitLine');
  45950. var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
  45951. var gridRect = gridModel.coordinateSystem.getRect();
  45952. var isHorizontal = axis.isHorizontal();
  45953. var minorTicksCoords = axis.getMinorTicksCoords();
  45954. if (!minorTicksCoords.length) {
  45955. return;
  45956. }
  45957. var p1 = [];
  45958. var p2 = [];
  45959. var lineStyle = lineStyleModel.getLineStyle();
  45960. for (var i = 0; i < minorTicksCoords.length; i++) {
  45961. for (var k = 0; k < minorTicksCoords[i].length; k++) {
  45962. var tickCoord = axis.toGlobalCoord(minorTicksCoords[i][k].coord);
  45963. if (isHorizontal) {
  45964. p1[0] = tickCoord;
  45965. p1[1] = gridRect.y;
  45966. p2[0] = tickCoord;
  45967. p2[1] = gridRect.y + gridRect.height;
  45968. } else {
  45969. p1[0] = gridRect.x;
  45970. p1[1] = tickCoord;
  45971. p2[0] = gridRect.x + gridRect.width;
  45972. p2[1] = tickCoord;
  45973. }
  45974. axisGroup.add(new Line({
  45975. anid: 'minor_line_' + minorTicksCoords[i][k].tickValue,
  45976. subPixelOptimize: true,
  45977. autoBatch: true,
  45978. shape: {
  45979. x1: p1[0],
  45980. y1: p1[1],
  45981. x2: p2[0],
  45982. y2: p2[1]
  45983. },
  45984. style: lineStyle,
  45985. silent: true
  45986. }));
  45987. }
  45988. }
  45989. },
  45990. splitArea: function (axisView, axisGroup, axisModel, gridModel) {
  45991. rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, gridModel);
  45992. }
  45993. };
  45994. var CartesianXAxisView =
  45995. /** @class */
  45996. function (_super) {
  45997. __extends(CartesianXAxisView, _super);
  45998. function CartesianXAxisView() {
  45999. var _this = _super !== null && _super.apply(this, arguments) || this;
  46000. _this.type = CartesianXAxisView.type;
  46001. return _this;
  46002. }
  46003. CartesianXAxisView.type = 'xAxis';
  46004. return CartesianXAxisView;
  46005. }(CartesianAxisView);
  46006. var CartesianYAxisView =
  46007. /** @class */
  46008. function (_super) {
  46009. __extends(CartesianYAxisView, _super);
  46010. function CartesianYAxisView() {
  46011. var _this = _super !== null && _super.apply(this, arguments) || this;
  46012. _this.type = CartesianXAxisView.type;
  46013. return _this;
  46014. }
  46015. CartesianYAxisView.type = 'yAxis';
  46016. return CartesianYAxisView;
  46017. }(CartesianAxisView);
  46018. /*
  46019. * Licensed to the Apache Software Foundation (ASF) under one
  46020. * or more contributor license agreements. See the NOTICE file
  46021. * distributed with this work for additional information
  46022. * regarding copyright ownership. The ASF licenses this file
  46023. * to you under the Apache License, Version 2.0 (the
  46024. * "License"); you may not use this file except in compliance
  46025. * with the License. You may obtain a copy of the License at
  46026. *
  46027. * http://www.apache.org/licenses/LICENSE-2.0
  46028. *
  46029. * Unless required by applicable law or agreed to in writing,
  46030. * software distributed under the License is distributed on an
  46031. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46032. * KIND, either express or implied. See the License for the
  46033. * specific language governing permissions and limitations
  46034. * under the License.
  46035. */
  46036. /**
  46037. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46038. */
  46039. /*
  46040. * Licensed to the Apache Software Foundation (ASF) under one
  46041. * or more contributor license agreements. See the NOTICE file
  46042. * distributed with this work for additional information
  46043. * regarding copyright ownership. The ASF licenses this file
  46044. * to you under the Apache License, Version 2.0 (the
  46045. * "License"); you may not use this file except in compliance
  46046. * with the License. You may obtain a copy of the License at
  46047. *
  46048. * http://www.apache.org/licenses/LICENSE-2.0
  46049. *
  46050. * Unless required by applicable law or agreed to in writing,
  46051. * software distributed under the License is distributed on an
  46052. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46053. * KIND, either express or implied. See the License for the
  46054. * specific language governing permissions and limitations
  46055. * under the License.
  46056. */
  46057. var GridView =
  46058. /** @class */
  46059. function (_super) {
  46060. __extends(GridView, _super);
  46061. function GridView() {
  46062. var _this = _super !== null && _super.apply(this, arguments) || this;
  46063. _this.type = 'grid';
  46064. return _this;
  46065. }
  46066. GridView.prototype.render = function (gridModel, ecModel) {
  46067. this.group.removeAll();
  46068. if (gridModel.get('show')) {
  46069. this.group.add(new Rect({
  46070. shape: gridModel.coordinateSystem.getRect(),
  46071. style: defaults({
  46072. fill: gridModel.get('backgroundColor')
  46073. }, gridModel.getItemStyle()),
  46074. silent: true,
  46075. z2: -1
  46076. }));
  46077. }
  46078. };
  46079. GridView.type = 'grid';
  46080. return GridView;
  46081. }(ComponentView);
  46082. var extraOption = {
  46083. // gridIndex: 0,
  46084. // gridId: '',
  46085. offset: 0
  46086. };
  46087. function install$6(registers) {
  46088. registers.registerComponentView(GridView);
  46089. registers.registerComponentModel(GridModel);
  46090. registers.registerCoordinateSystem('cartesian2d', Grid);
  46091. axisModelCreator(registers, 'x', CartesianAxisModel, extraOption);
  46092. axisModelCreator(registers, 'y', CartesianAxisModel, extraOption);
  46093. registers.registerComponentView(CartesianXAxisView);
  46094. registers.registerComponentView(CartesianYAxisView);
  46095. registers.registerPreprocessor(function (option) {
  46096. // Only create grid when need
  46097. if (option.xAxis && option.yAxis && !option.grid) {
  46098. option.grid = {};
  46099. }
  46100. });
  46101. }
  46102. /*
  46103. * Licensed to the Apache Software Foundation (ASF) under one
  46104. * or more contributor license agreements. See the NOTICE file
  46105. * distributed with this work for additional information
  46106. * regarding copyright ownership. The ASF licenses this file
  46107. * to you under the Apache License, Version 2.0 (the
  46108. * "License"); you may not use this file except in compliance
  46109. * with the License. You may obtain a copy of the License at
  46110. *
  46111. * http://www.apache.org/licenses/LICENSE-2.0
  46112. *
  46113. * Unless required by applicable law or agreed to in writing,
  46114. * software distributed under the License is distributed on an
  46115. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46116. * KIND, either express or implied. See the License for the
  46117. * specific language governing permissions and limitations
  46118. * under the License.
  46119. */
  46120. /**
  46121. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46122. */
  46123. /*
  46124. * Licensed to the Apache Software Foundation (ASF) under one
  46125. * or more contributor license agreements. See the NOTICE file
  46126. * distributed with this work for additional information
  46127. * regarding copyright ownership. The ASF licenses this file
  46128. * to you under the Apache License, Version 2.0 (the
  46129. * "License"); you may not use this file except in compliance
  46130. * with the License. You may obtain a copy of the License at
  46131. *
  46132. * http://www.apache.org/licenses/LICENSE-2.0
  46133. *
  46134. * Unless required by applicable law or agreed to in writing,
  46135. * software distributed under the License is distributed on an
  46136. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46137. * KIND, either express or implied. See the License for the
  46138. * specific language governing permissions and limitations
  46139. * under the License.
  46140. */
  46141. function install$5(registers) {
  46142. // In case developer forget to include grid component
  46143. use(install$6);
  46144. registers.registerSeriesModel(ScatterSeriesModel);
  46145. registers.registerChartView(ScatterView);
  46146. registers.registerLayout(pointsLayout('scatter'));
  46147. }
  46148. /*
  46149. * Licensed to the Apache Software Foundation (ASF) under one
  46150. * or more contributor license agreements. See the NOTICE file
  46151. * distributed with this work for additional information
  46152. * regarding copyright ownership. The ASF licenses this file
  46153. * to you under the Apache License, Version 2.0 (the
  46154. * "License"); you may not use this file except in compliance
  46155. * with the License. You may obtain a copy of the License at
  46156. *
  46157. * http://www.apache.org/licenses/LICENSE-2.0
  46158. *
  46159. * Unless required by applicable law or agreed to in writing,
  46160. * software distributed under the License is distributed on an
  46161. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46162. * KIND, either express or implied. See the License for the
  46163. * specific language governing permissions and limitations
  46164. * under the License.
  46165. */
  46166. /**
  46167. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46168. */
  46169. /*
  46170. * Licensed to the Apache Software Foundation (ASF) under one
  46171. * or more contributor license agreements. See the NOTICE file
  46172. * distributed with this work for additional information
  46173. * regarding copyright ownership. The ASF licenses this file
  46174. * to you under the Apache License, Version 2.0 (the
  46175. * "License"); you may not use this file except in compliance
  46176. * with the License. You may obtain a copy of the License at
  46177. *
  46178. * http://www.apache.org/licenses/LICENSE-2.0
  46179. *
  46180. * Unless required by applicable law or agreed to in writing,
  46181. * software distributed under the License is distributed on an
  46182. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46183. * KIND, either express or implied. See the License for the
  46184. * specific language governing permissions and limitations
  46185. * under the License.
  46186. */
  46187. use(install$5);
  46188. /*
  46189. * Licensed to the Apache Software Foundation (ASF) under one
  46190. * or more contributor license agreements. See the NOTICE file
  46191. * distributed with this work for additional information
  46192. * regarding copyright ownership. The ASF licenses this file
  46193. * to you under the Apache License, Version 2.0 (the
  46194. * "License"); you may not use this file except in compliance
  46195. * with the License. You may obtain a copy of the License at
  46196. *
  46197. * http://www.apache.org/licenses/LICENSE-2.0
  46198. *
  46199. * Unless required by applicable law or agreed to in writing,
  46200. * software distributed under the License is distributed on an
  46201. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46202. * KIND, either express or implied. See the License for the
  46203. * specific language governing permissions and limitations
  46204. * under the License.
  46205. */
  46206. /**
  46207. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46208. */
  46209. /*
  46210. * Licensed to the Apache Software Foundation (ASF) under one
  46211. * or more contributor license agreements. See the NOTICE file
  46212. * distributed with this work for additional information
  46213. * regarding copyright ownership. The ASF licenses this file
  46214. * to you under the Apache License, Version 2.0 (the
  46215. * "License"); you may not use this file except in compliance
  46216. * with the License. You may obtain a copy of the License at
  46217. *
  46218. * http://www.apache.org/licenses/LICENSE-2.0
  46219. *
  46220. * Unless required by applicable law or agreed to in writing,
  46221. * software distributed under the License is distributed on an
  46222. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46223. * KIND, either express or implied. See the License for the
  46224. * specific language governing permissions and limitations
  46225. * under the License.
  46226. */
  46227. var EFFECT_RIPPLE_NUMBER = 3;
  46228. function normalizeSymbolSize(symbolSize) {
  46229. if (!isArray(symbolSize)) {
  46230. symbolSize = [+symbolSize, +symbolSize];
  46231. }
  46232. return symbolSize;
  46233. }
  46234. function updateRipplePath(rippleGroup, effectCfg) {
  46235. var color = effectCfg.rippleEffectColor || effectCfg.color;
  46236. rippleGroup.eachChild(function (ripplePath) {
  46237. ripplePath.attr({
  46238. z: effectCfg.z,
  46239. zlevel: effectCfg.zlevel,
  46240. style: {
  46241. stroke: effectCfg.brushType === 'stroke' ? color : null,
  46242. fill: effectCfg.brushType === 'fill' ? color : null
  46243. }
  46244. });
  46245. });
  46246. }
  46247. var EffectSymbol =
  46248. /** @class */
  46249. function (_super) {
  46250. __extends(EffectSymbol, _super);
  46251. function EffectSymbol(data, idx) {
  46252. var _this = _super.call(this) || this;
  46253. var symbol = new Symbol$1(data, idx);
  46254. var rippleGroup = new Group();
  46255. _this.add(symbol);
  46256. _this.add(rippleGroup);
  46257. _this.updateData(data, idx);
  46258. return _this;
  46259. }
  46260. EffectSymbol.prototype.stopEffectAnimation = function () {
  46261. this.childAt(1).removeAll();
  46262. };
  46263. EffectSymbol.prototype.startEffectAnimation = function (effectCfg) {
  46264. var symbolType = effectCfg.symbolType;
  46265. var color = effectCfg.color;
  46266. var rippleGroup = this.childAt(1);
  46267. for (var i = 0; i < EFFECT_RIPPLE_NUMBER; i++) {
  46268. // If width/height are set too small (e.g., set to 1) on ios10
  46269. // and macOS Sierra, a circle stroke become a rect, no matter what
  46270. // the scale is set. So we set width/height as 2. See #4136.
  46271. var ripplePath = createSymbol(symbolType, -1, -1, 2, 2, color);
  46272. ripplePath.attr({
  46273. style: {
  46274. strokeNoScale: true
  46275. },
  46276. z2: 99,
  46277. silent: true,
  46278. scaleX: 0.5,
  46279. scaleY: 0.5
  46280. });
  46281. var delay = -i / EFFECT_RIPPLE_NUMBER * effectCfg.period + effectCfg.effectOffset; // TODO Configurable effectCfg.period
  46282. ripplePath.animate('', true).when(effectCfg.period, {
  46283. scaleX: effectCfg.rippleScale / 2,
  46284. scaleY: effectCfg.rippleScale / 2
  46285. }).delay(delay).start();
  46286. ripplePath.animateStyle(true).when(effectCfg.period, {
  46287. opacity: 0
  46288. }).delay(delay).start();
  46289. rippleGroup.add(ripplePath);
  46290. }
  46291. updateRipplePath(rippleGroup, effectCfg);
  46292. };
  46293. /**
  46294. * Update effect symbol
  46295. */
  46296. EffectSymbol.prototype.updateEffectAnimation = function (effectCfg) {
  46297. var oldEffectCfg = this._effectCfg;
  46298. var rippleGroup = this.childAt(1); // Must reinitialize effect if following configuration changed
  46299. var DIFFICULT_PROPS = ['symbolType', 'period', 'rippleScale'];
  46300. for (var i = 0; i < DIFFICULT_PROPS.length; i++) {
  46301. var propName = DIFFICULT_PROPS[i];
  46302. if (oldEffectCfg[propName] !== effectCfg[propName]) {
  46303. this.stopEffectAnimation();
  46304. this.startEffectAnimation(effectCfg);
  46305. return;
  46306. }
  46307. }
  46308. updateRipplePath(rippleGroup, effectCfg);
  46309. };
  46310. /**
  46311. * Highlight symbol
  46312. */
  46313. EffectSymbol.prototype.highlight = function () {
  46314. enterEmphasis(this);
  46315. };
  46316. /**
  46317. * Downplay symbol
  46318. */
  46319. EffectSymbol.prototype.downplay = function () {
  46320. leaveEmphasis(this);
  46321. };
  46322. /**
  46323. * Update symbol properties
  46324. */
  46325. EffectSymbol.prototype.updateData = function (data, idx) {
  46326. var _this = this;
  46327. var seriesModel = data.hostModel;
  46328. this.childAt(0).updateData(data, idx);
  46329. var rippleGroup = this.childAt(1);
  46330. var itemModel = data.getItemModel(idx);
  46331. var symbolType = data.getItemVisual(idx, 'symbol');
  46332. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  46333. var symbolStyle = data.getItemVisual(idx, 'style');
  46334. var color = symbolStyle && symbolStyle.fill;
  46335. rippleGroup.setScale(symbolSize);
  46336. rippleGroup.traverse(function (ripplePath) {
  46337. ripplePath.setStyle('fill', color);
  46338. });
  46339. var symbolOffset = data.getItemVisual(idx, 'symbolOffset');
  46340. if (symbolOffset) {
  46341. if (!isArray(symbolOffset)) {
  46342. symbolOffset = [symbolOffset, symbolOffset];
  46343. }
  46344. rippleGroup.x = parsePercent$1(symbolOffset[0], symbolSize[0]);
  46345. rippleGroup.y = parsePercent$1(retrieve2(symbolOffset[1], symbolOffset[0]) || 0, symbolSize[1]);
  46346. }
  46347. var symbolRotate = data.getItemVisual(idx, 'symbolRotate');
  46348. rippleGroup.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  46349. var effectCfg = {};
  46350. effectCfg.showEffectOn = seriesModel.get('showEffectOn');
  46351. effectCfg.rippleScale = itemModel.get(['rippleEffect', 'scale']);
  46352. effectCfg.brushType = itemModel.get(['rippleEffect', 'brushType']);
  46353. effectCfg.period = itemModel.get(['rippleEffect', 'period']) * 1000;
  46354. effectCfg.effectOffset = idx / data.count();
  46355. effectCfg.z = seriesModel.getShallow('z') || 0;
  46356. effectCfg.zlevel = seriesModel.getShallow('zlevel') || 0;
  46357. effectCfg.symbolType = symbolType;
  46358. effectCfg.color = color;
  46359. effectCfg.rippleEffectColor = itemModel.get(['rippleEffect', 'color']);
  46360. this.off('mouseover').off('mouseout').off('emphasis').off('normal');
  46361. if (effectCfg.showEffectOn === 'render') {
  46362. this._effectCfg ? this.updateEffectAnimation(effectCfg) : this.startEffectAnimation(effectCfg);
  46363. this._effectCfg = effectCfg;
  46364. } else {
  46365. // Not keep old effect config
  46366. this._effectCfg = null;
  46367. this.stopEffectAnimation();
  46368. this.onHoverStateChange = function (toState) {
  46369. if (toState === 'emphasis') {
  46370. if (effectCfg.showEffectOn !== 'render') {
  46371. _this.startEffectAnimation(effectCfg);
  46372. }
  46373. } else if (toState === 'normal') {
  46374. if (effectCfg.showEffectOn !== 'render') {
  46375. _this.stopEffectAnimation();
  46376. }
  46377. }
  46378. };
  46379. }
  46380. this._effectCfg = effectCfg;
  46381. enableHoverEmphasis(this);
  46382. };
  46383. EffectSymbol.prototype.fadeOut = function (cb) {
  46384. this.off('mouseover').off('mouseout');
  46385. cb && cb();
  46386. };
  46387. return EffectSymbol;
  46388. }(Group);
  46389. inherits(EffectSymbol, Group);
  46390. /*
  46391. * Licensed to the Apache Software Foundation (ASF) under one
  46392. * or more contributor license agreements. See the NOTICE file
  46393. * distributed with this work for additional information
  46394. * regarding copyright ownership. The ASF licenses this file
  46395. * to you under the Apache License, Version 2.0 (the
  46396. * "License"); you may not use this file except in compliance
  46397. * with the License. You may obtain a copy of the License at
  46398. *
  46399. * http://www.apache.org/licenses/LICENSE-2.0
  46400. *
  46401. * Unless required by applicable law or agreed to in writing,
  46402. * software distributed under the License is distributed on an
  46403. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46404. * KIND, either express or implied. See the License for the
  46405. * specific language governing permissions and limitations
  46406. * under the License.
  46407. */
  46408. /**
  46409. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46410. */
  46411. /*
  46412. * Licensed to the Apache Software Foundation (ASF) under one
  46413. * or more contributor license agreements. See the NOTICE file
  46414. * distributed with this work for additional information
  46415. * regarding copyright ownership. The ASF licenses this file
  46416. * to you under the Apache License, Version 2.0 (the
  46417. * "License"); you may not use this file except in compliance
  46418. * with the License. You may obtain a copy of the License at
  46419. *
  46420. * http://www.apache.org/licenses/LICENSE-2.0
  46421. *
  46422. * Unless required by applicable law or agreed to in writing,
  46423. * software distributed under the License is distributed on an
  46424. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46425. * KIND, either express or implied. See the License for the
  46426. * specific language governing permissions and limitations
  46427. * under the License.
  46428. */
  46429. var EffectScatterView =
  46430. /** @class */
  46431. function (_super) {
  46432. __extends(EffectScatterView, _super);
  46433. function EffectScatterView() {
  46434. var _this = _super !== null && _super.apply(this, arguments) || this;
  46435. _this.type = EffectScatterView.type;
  46436. return _this;
  46437. }
  46438. EffectScatterView.prototype.init = function () {
  46439. this._symbolDraw = new SymbolDraw(EffectSymbol);
  46440. };
  46441. EffectScatterView.prototype.render = function (seriesModel, ecModel, api) {
  46442. var data = seriesModel.getData();
  46443. var effectSymbolDraw = this._symbolDraw;
  46444. effectSymbolDraw.updateData(data, {
  46445. clipShape: this._getClipShape(seriesModel)
  46446. });
  46447. this.group.add(effectSymbolDraw.group);
  46448. };
  46449. EffectScatterView.prototype._getClipShape = function (seriesModel) {
  46450. var coordSys = seriesModel.coordinateSystem;
  46451. var clipArea = coordSys && coordSys.getArea && coordSys.getArea();
  46452. return seriesModel.get('clip', true) ? clipArea : null;
  46453. };
  46454. EffectScatterView.prototype.updateTransform = function (seriesModel, ecModel, api) {
  46455. var data = seriesModel.getData();
  46456. this.group.dirty();
  46457. var res = pointsLayout('').reset(seriesModel, ecModel, api);
  46458. if (res.progress) {
  46459. res.progress({
  46460. start: 0,
  46461. end: data.count(),
  46462. count: data.count()
  46463. }, data);
  46464. }
  46465. this._symbolDraw.updateLayout();
  46466. };
  46467. EffectScatterView.prototype._updateGroupTransform = function (seriesModel) {
  46468. var coordSys = seriesModel.coordinateSystem;
  46469. if (coordSys && coordSys.getRoamTransform) {
  46470. this.group.transform = clone$2(coordSys.getRoamTransform());
  46471. this.group.decomposeTransform();
  46472. }
  46473. };
  46474. EffectScatterView.prototype.remove = function (ecModel, api) {
  46475. this._symbolDraw && this._symbolDraw.remove(true);
  46476. };
  46477. EffectScatterView.type = 'effectScatter';
  46478. return EffectScatterView;
  46479. }(ChartView);
  46480. /*
  46481. * Licensed to the Apache Software Foundation (ASF) under one
  46482. * or more contributor license agreements. See the NOTICE file
  46483. * distributed with this work for additional information
  46484. * regarding copyright ownership. The ASF licenses this file
  46485. * to you under the Apache License, Version 2.0 (the
  46486. * "License"); you may not use this file except in compliance
  46487. * with the License. You may obtain a copy of the License at
  46488. *
  46489. * http://www.apache.org/licenses/LICENSE-2.0
  46490. *
  46491. * Unless required by applicable law or agreed to in writing,
  46492. * software distributed under the License is distributed on an
  46493. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46494. * KIND, either express or implied. See the License for the
  46495. * specific language governing permissions and limitations
  46496. * under the License.
  46497. */
  46498. /**
  46499. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46500. */
  46501. /*
  46502. * Licensed to the Apache Software Foundation (ASF) under one
  46503. * or more contributor license agreements. See the NOTICE file
  46504. * distributed with this work for additional information
  46505. * regarding copyright ownership. The ASF licenses this file
  46506. * to you under the Apache License, Version 2.0 (the
  46507. * "License"); you may not use this file except in compliance
  46508. * with the License. You may obtain a copy of the License at
  46509. *
  46510. * http://www.apache.org/licenses/LICENSE-2.0
  46511. *
  46512. * Unless required by applicable law or agreed to in writing,
  46513. * software distributed under the License is distributed on an
  46514. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46515. * KIND, either express or implied. See the License for the
  46516. * specific language governing permissions and limitations
  46517. * under the License.
  46518. */
  46519. var EffectScatterSeriesModel =
  46520. /** @class */
  46521. function (_super) {
  46522. __extends(EffectScatterSeriesModel, _super);
  46523. function EffectScatterSeriesModel() {
  46524. var _this = _super !== null && _super.apply(this, arguments) || this;
  46525. _this.type = EffectScatterSeriesModel.type;
  46526. _this.hasSymbolVisual = true;
  46527. return _this;
  46528. }
  46529. EffectScatterSeriesModel.prototype.getInitialData = function (option, ecModel) {
  46530. return createListFromArray(this.getSource(), this, {
  46531. useEncodeDefaulter: true
  46532. });
  46533. };
  46534. EffectScatterSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
  46535. return selectors.point(data.getItemLayout(dataIndex));
  46536. };
  46537. EffectScatterSeriesModel.type = 'series.effectScatter';
  46538. EffectScatterSeriesModel.dependencies = ['grid', 'polar'];
  46539. EffectScatterSeriesModel.defaultOption = {
  46540. coordinateSystem: 'cartesian2d',
  46541. zlevel: 0,
  46542. z: 2,
  46543. legendHoverLink: true,
  46544. effectType: 'ripple',
  46545. progressive: 0,
  46546. // When to show the effect, option: 'render'|'emphasis'
  46547. showEffectOn: 'render',
  46548. clip: true,
  46549. // Ripple effect config
  46550. rippleEffect: {
  46551. period: 4,
  46552. // Scale of ripple
  46553. scale: 2.5,
  46554. // Brush type can be fill or stroke
  46555. brushType: 'fill'
  46556. },
  46557. // Cartesian coordinate system
  46558. // xAxisIndex: 0,
  46559. // yAxisIndex: 0,
  46560. // Polar coordinate system
  46561. // polarIndex: 0,
  46562. // Geo coordinate system
  46563. // geoIndex: 0,
  46564. // symbol: null, // 图形类型
  46565. symbolSize: 10 // 图形大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
  46566. // symbolRotate: null, // 图形旋转控制
  46567. // itemStyle: {
  46568. // opacity: 1
  46569. // }
  46570. };
  46571. return EffectScatterSeriesModel;
  46572. }(SeriesModel);
  46573. /*
  46574. * Licensed to the Apache Software Foundation (ASF) under one
  46575. * or more contributor license agreements. See the NOTICE file
  46576. * distributed with this work for additional information
  46577. * regarding copyright ownership. The ASF licenses this file
  46578. * to you under the Apache License, Version 2.0 (the
  46579. * "License"); you may not use this file except in compliance
  46580. * with the License. You may obtain a copy of the License at
  46581. *
  46582. * http://www.apache.org/licenses/LICENSE-2.0
  46583. *
  46584. * Unless required by applicable law or agreed to in writing,
  46585. * software distributed under the License is distributed on an
  46586. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46587. * KIND, either express or implied. See the License for the
  46588. * specific language governing permissions and limitations
  46589. * under the License.
  46590. */
  46591. /**
  46592. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46593. */
  46594. /*
  46595. * Licensed to the Apache Software Foundation (ASF) under one
  46596. * or more contributor license agreements. See the NOTICE file
  46597. * distributed with this work for additional information
  46598. * regarding copyright ownership. The ASF licenses this file
  46599. * to you under the Apache License, Version 2.0 (the
  46600. * "License"); you may not use this file except in compliance
  46601. * with the License. You may obtain a copy of the License at
  46602. *
  46603. * http://www.apache.org/licenses/LICENSE-2.0
  46604. *
  46605. * Unless required by applicable law or agreed to in writing,
  46606. * software distributed under the License is distributed on an
  46607. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46608. * KIND, either express or implied. See the License for the
  46609. * specific language governing permissions and limitations
  46610. * under the License.
  46611. */
  46612. function install$7(registers) {
  46613. registers.registerChartView(EffectScatterView);
  46614. registers.registerSeriesModel(EffectScatterSeriesModel);
  46615. registers.registerLayout(pointsLayout('effectScatter'));
  46616. }
  46617. /*
  46618. * Licensed to the Apache Software Foundation (ASF) under one
  46619. * or more contributor license agreements. See the NOTICE file
  46620. * distributed with this work for additional information
  46621. * regarding copyright ownership. The ASF licenses this file
  46622. * to you under the Apache License, Version 2.0 (the
  46623. * "License"); you may not use this file except in compliance
  46624. * with the License. You may obtain a copy of the License at
  46625. *
  46626. * http://www.apache.org/licenses/LICENSE-2.0
  46627. *
  46628. * Unless required by applicable law or agreed to in writing,
  46629. * software distributed under the License is distributed on an
  46630. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46631. * KIND, either express or implied. See the License for the
  46632. * specific language governing permissions and limitations
  46633. * under the License.
  46634. */
  46635. /**
  46636. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46637. */
  46638. /*
  46639. * Licensed to the Apache Software Foundation (ASF) under one
  46640. * or more contributor license agreements. See the NOTICE file
  46641. * distributed with this work for additional information
  46642. * regarding copyright ownership. The ASF licenses this file
  46643. * to you under the Apache License, Version 2.0 (the
  46644. * "License"); you may not use this file except in compliance
  46645. * with the License. You may obtain a copy of the License at
  46646. *
  46647. * http://www.apache.org/licenses/LICENSE-2.0
  46648. *
  46649. * Unless required by applicable law or agreed to in writing,
  46650. * software distributed under the License is distributed on an
  46651. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46652. * KIND, either express or implied. See the License for the
  46653. * specific language governing permissions and limitations
  46654. * under the License.
  46655. */
  46656. use(install$7);
  46657. /*
  46658. * Licensed to the Apache Software Foundation (ASF) under one
  46659. * or more contributor license agreements. See the NOTICE file
  46660. * distributed with this work for additional information
  46661. * regarding copyright ownership. The ASF licenses this file
  46662. * to you under the Apache License, Version 2.0 (the
  46663. * "License"); you may not use this file except in compliance
  46664. * with the License. You may obtain a copy of the License at
  46665. *
  46666. * http://www.apache.org/licenses/LICENSE-2.0
  46667. *
  46668. * Unless required by applicable law or agreed to in writing,
  46669. * software distributed under the License is distributed on an
  46670. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46671. * KIND, either express or implied. See the License for the
  46672. * specific language governing permissions and limitations
  46673. * under the License.
  46674. */
  46675. /**
  46676. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46677. */
  46678. /*
  46679. * Licensed to the Apache Software Foundation (ASF) under one
  46680. * or more contributor license agreements. See the NOTICE file
  46681. * distributed with this work for additional information
  46682. * regarding copyright ownership. The ASF licenses this file
  46683. * to you under the Apache License, Version 2.0 (the
  46684. * "License"); you may not use this file except in compliance
  46685. * with the License. You may obtain a copy of the License at
  46686. *
  46687. * http://www.apache.org/licenses/LICENSE-2.0
  46688. *
  46689. * Unless required by applicable law or agreed to in writing,
  46690. * software distributed under the License is distributed on an
  46691. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46692. * KIND, either express or implied. See the License for the
  46693. * specific language governing permissions and limitations
  46694. * under the License.
  46695. */
  46696. var SKIP_PROPS = ['color', 'borderColor'];
  46697. var CandlestickView =
  46698. /** @class */
  46699. function (_super) {
  46700. __extends(CandlestickView, _super);
  46701. function CandlestickView() {
  46702. var _this = _super !== null && _super.apply(this, arguments) || this;
  46703. _this.type = CandlestickView.type;
  46704. return _this;
  46705. }
  46706. CandlestickView.prototype.render = function (seriesModel, ecModel, api) {
  46707. // If there is clipPath created in large mode. Remove it.
  46708. this.group.removeClipPath();
  46709. this._updateDrawMode(seriesModel);
  46710. this._isLargeDraw ? this._renderLarge(seriesModel) : this._renderNormal(seriesModel);
  46711. };
  46712. CandlestickView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
  46713. this._clear();
  46714. this._updateDrawMode(seriesModel);
  46715. };
  46716. CandlestickView.prototype.incrementalRender = function (params, seriesModel, ecModel, api) {
  46717. this._isLargeDraw ? this._incrementalRenderLarge(params, seriesModel) : this._incrementalRenderNormal(params, seriesModel);
  46718. };
  46719. CandlestickView.prototype._updateDrawMode = function (seriesModel) {
  46720. var isLargeDraw = seriesModel.pipelineContext.large;
  46721. if (this._isLargeDraw == null || isLargeDraw !== this._isLargeDraw) {
  46722. this._isLargeDraw = isLargeDraw;
  46723. this._clear();
  46724. }
  46725. };
  46726. CandlestickView.prototype._renderNormal = function (seriesModel) {
  46727. var data = seriesModel.getData();
  46728. var oldData = this._data;
  46729. var group = this.group;
  46730. var isSimpleBox = data.getLayout('isSimpleBox');
  46731. var needsClip = seriesModel.get('clip', true);
  46732. var coord = seriesModel.coordinateSystem;
  46733. var clipArea = coord.getArea && coord.getArea(); // There is no old data only when first rendering or switching from
  46734. // stream mode to normal mode, where previous elements should be removed.
  46735. if (!this._data) {
  46736. group.removeAll();
  46737. }
  46738. data.diff(oldData).add(function (newIdx) {
  46739. if (data.hasValue(newIdx)) {
  46740. var itemLayout = data.getItemLayout(newIdx);
  46741. if (needsClip && isNormalBoxClipped(clipArea, itemLayout)) {
  46742. return;
  46743. }
  46744. var el = createNormalBox(itemLayout, newIdx, true);
  46745. initProps(el, {
  46746. shape: {
  46747. points: itemLayout.ends
  46748. }
  46749. }, seriesModel, newIdx);
  46750. setBoxCommon(el, data, newIdx, isSimpleBox);
  46751. group.add(el);
  46752. data.setItemGraphicEl(newIdx, el);
  46753. }
  46754. }).update(function (newIdx, oldIdx) {
  46755. var el = oldData.getItemGraphicEl(oldIdx); // Empty data
  46756. if (!data.hasValue(newIdx)) {
  46757. group.remove(el);
  46758. return;
  46759. }
  46760. var itemLayout = data.getItemLayout(newIdx);
  46761. if (needsClip && isNormalBoxClipped(clipArea, itemLayout)) {
  46762. group.remove(el);
  46763. return;
  46764. }
  46765. if (!el) {
  46766. el = createNormalBox(itemLayout, newIdx);
  46767. } else {
  46768. updateProps(el, {
  46769. shape: {
  46770. points: itemLayout.ends
  46771. }
  46772. }, seriesModel, newIdx);
  46773. }
  46774. setBoxCommon(el, data, newIdx, isSimpleBox);
  46775. group.add(el);
  46776. data.setItemGraphicEl(newIdx, el);
  46777. }).remove(function (oldIdx) {
  46778. var el = oldData.getItemGraphicEl(oldIdx);
  46779. el && group.remove(el);
  46780. }).execute();
  46781. this._data = data;
  46782. };
  46783. CandlestickView.prototype._renderLarge = function (seriesModel) {
  46784. this._clear();
  46785. createLarge$1(seriesModel, this.group);
  46786. var clipPath = seriesModel.get('clip', true) ? createClipPath(seriesModel.coordinateSystem, false, seriesModel) : null;
  46787. if (clipPath) {
  46788. this.group.setClipPath(clipPath);
  46789. } else {
  46790. this.group.removeClipPath();
  46791. }
  46792. };
  46793. CandlestickView.prototype._incrementalRenderNormal = function (params, seriesModel) {
  46794. var data = seriesModel.getData();
  46795. var isSimpleBox = data.getLayout('isSimpleBox');
  46796. var dataIndex;
  46797. while ((dataIndex = params.next()) != null) {
  46798. var itemLayout = data.getItemLayout(dataIndex);
  46799. var el = createNormalBox(itemLayout, dataIndex);
  46800. setBoxCommon(el, data, dataIndex, isSimpleBox);
  46801. el.incremental = true;
  46802. this.group.add(el);
  46803. }
  46804. };
  46805. CandlestickView.prototype._incrementalRenderLarge = function (params, seriesModel) {
  46806. createLarge$1(seriesModel, this.group, true);
  46807. };
  46808. CandlestickView.prototype.remove = function (ecModel) {
  46809. this._clear();
  46810. };
  46811. CandlestickView.prototype._clear = function () {
  46812. this.group.removeAll();
  46813. this._data = null;
  46814. };
  46815. CandlestickView.type = 'candlestick';
  46816. return CandlestickView;
  46817. }(ChartView);
  46818. var NormalBoxPathShape =
  46819. /** @class */
  46820. function () {
  46821. function NormalBoxPathShape() {}
  46822. return NormalBoxPathShape;
  46823. }();
  46824. var NormalBoxPath =
  46825. /** @class */
  46826. function (_super) {
  46827. __extends(NormalBoxPath, _super);
  46828. function NormalBoxPath(opts) {
  46829. var _this = _super.call(this, opts) || this;
  46830. _this.type = 'normalCandlestickBox';
  46831. return _this;
  46832. }
  46833. NormalBoxPath.prototype.getDefaultShape = function () {
  46834. return new NormalBoxPathShape();
  46835. };
  46836. NormalBoxPath.prototype.buildPath = function (ctx, shape) {
  46837. var ends = shape.points;
  46838. if (this.__simpleBox) {
  46839. ctx.moveTo(ends[4][0], ends[4][1]);
  46840. ctx.lineTo(ends[6][0], ends[6][1]);
  46841. } else {
  46842. ctx.moveTo(ends[0][0], ends[0][1]);
  46843. ctx.lineTo(ends[1][0], ends[1][1]);
  46844. ctx.lineTo(ends[2][0], ends[2][1]);
  46845. ctx.lineTo(ends[3][0], ends[3][1]);
  46846. ctx.closePath();
  46847. ctx.moveTo(ends[4][0], ends[4][1]);
  46848. ctx.lineTo(ends[5][0], ends[5][1]);
  46849. ctx.moveTo(ends[6][0], ends[6][1]);
  46850. ctx.lineTo(ends[7][0], ends[7][1]);
  46851. }
  46852. };
  46853. return NormalBoxPath;
  46854. }(Path);
  46855. function createNormalBox(itemLayout, dataIndex, isInit) {
  46856. var ends = itemLayout.ends;
  46857. return new NormalBoxPath({
  46858. shape: {
  46859. points: isInit ? transInit(ends, itemLayout) : ends
  46860. },
  46861. z2: 100
  46862. });
  46863. }
  46864. function isNormalBoxClipped(clipArea, itemLayout) {
  46865. var clipped = true;
  46866. for (var i = 0; i < itemLayout.ends.length; i++) {
  46867. // If any point are in the region.
  46868. if (clipArea.contain(itemLayout.ends[i][0], itemLayout.ends[i][1])) {
  46869. clipped = false;
  46870. break;
  46871. }
  46872. }
  46873. return clipped;
  46874. }
  46875. function setBoxCommon(el, data, dataIndex, isSimpleBox) {
  46876. var itemModel = data.getItemModel(dataIndex);
  46877. el.useStyle(data.getItemVisual(dataIndex, 'style'));
  46878. el.style.strokeNoScale = true;
  46879. el.__simpleBox = isSimpleBox;
  46880. setStatesStylesFromModel(el, itemModel);
  46881. }
  46882. function transInit(points, itemLayout) {
  46883. return map(points, function (point) {
  46884. point = point.slice();
  46885. point[1] = itemLayout.initBaseline;
  46886. return point;
  46887. });
  46888. }
  46889. var LargeBoxPathShape =
  46890. /** @class */
  46891. function () {
  46892. function LargeBoxPathShape() {}
  46893. return LargeBoxPathShape;
  46894. }();
  46895. var LargeBoxPath =
  46896. /** @class */
  46897. function (_super) {
  46898. __extends(LargeBoxPath, _super);
  46899. function LargeBoxPath(opts) {
  46900. var _this = _super.call(this, opts) || this;
  46901. _this.type = 'largeCandlestickBox';
  46902. return _this;
  46903. }
  46904. LargeBoxPath.prototype.getDefaultShape = function () {
  46905. return new LargeBoxPathShape();
  46906. };
  46907. LargeBoxPath.prototype.buildPath = function (ctx, shape) {
  46908. // Drawing lines is more efficient than drawing
  46909. // a whole line or drawing rects.
  46910. var points = shape.points;
  46911. for (var i = 0; i < points.length;) {
  46912. if (this.__sign === points[i++]) {
  46913. var x = points[i++];
  46914. ctx.moveTo(x, points[i++]);
  46915. ctx.lineTo(x, points[i++]);
  46916. } else {
  46917. i += 3;
  46918. }
  46919. }
  46920. };
  46921. return LargeBoxPath;
  46922. }(Path);
  46923. function createLarge$1(seriesModel, group, incremental) {
  46924. var data = seriesModel.getData();
  46925. var largePoints = data.getLayout('largePoints');
  46926. var elP = new LargeBoxPath({
  46927. shape: {
  46928. points: largePoints
  46929. },
  46930. __sign: 1
  46931. });
  46932. group.add(elP);
  46933. var elN = new LargeBoxPath({
  46934. shape: {
  46935. points: largePoints
  46936. },
  46937. __sign: -1
  46938. });
  46939. group.add(elN);
  46940. setLargeStyle$1(1, elP, seriesModel, data);
  46941. setLargeStyle$1(-1, elN, seriesModel, data);
  46942. if (incremental) {
  46943. elP.incremental = true;
  46944. elN.incremental = true;
  46945. }
  46946. }
  46947. function setLargeStyle$1(sign, el, seriesModel, data) {
  46948. // TODO put in visual?
  46949. var borderColor = seriesModel.get(['itemStyle', sign > 0 ? 'borderColor' : 'borderColor0']) || seriesModel.get(['itemStyle', sign > 0 ? 'color' : 'color0']); // Color must be excluded.
  46950. // Because symbol provide setColor individually to set fill and stroke
  46951. var itemStyle = seriesModel.getModel('itemStyle').getItemStyle(SKIP_PROPS);
  46952. el.useStyle(itemStyle);
  46953. el.style.fill = null;
  46954. el.style.stroke = borderColor;
  46955. }
  46956. /*
  46957. * Licensed to the Apache Software Foundation (ASF) under one
  46958. * or more contributor license agreements. See the NOTICE file
  46959. * distributed with this work for additional information
  46960. * regarding copyright ownership. The ASF licenses this file
  46961. * to you under the Apache License, Version 2.0 (the
  46962. * "License"); you may not use this file except in compliance
  46963. * with the License. You may obtain a copy of the License at
  46964. *
  46965. * http://www.apache.org/licenses/LICENSE-2.0
  46966. *
  46967. * Unless required by applicable law or agreed to in writing,
  46968. * software distributed under the License is distributed on an
  46969. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46970. * KIND, either express or implied. See the License for the
  46971. * specific language governing permissions and limitations
  46972. * under the License.
  46973. */
  46974. /**
  46975. * AUTO-GENERATED FILE. DO NOT MODIFY.
  46976. */
  46977. /*
  46978. * Licensed to the Apache Software Foundation (ASF) under one
  46979. * or more contributor license agreements. See the NOTICE file
  46980. * distributed with this work for additional information
  46981. * regarding copyright ownership. The ASF licenses this file
  46982. * to you under the Apache License, Version 2.0 (the
  46983. * "License"); you may not use this file except in compliance
  46984. * with the License. You may obtain a copy of the License at
  46985. *
  46986. * http://www.apache.org/licenses/LICENSE-2.0
  46987. *
  46988. * Unless required by applicable law or agreed to in writing,
  46989. * software distributed under the License is distributed on an
  46990. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  46991. * KIND, either express or implied. See the License for the
  46992. * specific language governing permissions and limitations
  46993. * under the License.
  46994. */
  46995. var WhiskerBoxCommonMixin =
  46996. /** @class */
  46997. function () {
  46998. function WhiskerBoxCommonMixin() {}
  46999. /**
  47000. * @override
  47001. */
  47002. WhiskerBoxCommonMixin.prototype.getInitialData = function (option, ecModel) {
  47003. // When both types of xAxis and yAxis are 'value', layout is
  47004. // needed to be specified by user. Otherwise, layout can be
  47005. // judged by which axis is category.
  47006. var ordinalMeta;
  47007. var xAxisModel = ecModel.getComponent('xAxis', this.get('xAxisIndex'));
  47008. var yAxisModel = ecModel.getComponent('yAxis', this.get('yAxisIndex'));
  47009. var xAxisType = xAxisModel.get('type');
  47010. var yAxisType = yAxisModel.get('type');
  47011. var addOrdinal; // FIXME
  47012. // Consider time axis.
  47013. if (xAxisType === 'category') {
  47014. option.layout = 'horizontal';
  47015. ordinalMeta = xAxisModel.getOrdinalMeta();
  47016. addOrdinal = true;
  47017. } else if (yAxisType === 'category') {
  47018. option.layout = 'vertical';
  47019. ordinalMeta = yAxisModel.getOrdinalMeta();
  47020. addOrdinal = true;
  47021. } else {
  47022. option.layout = option.layout || 'horizontal';
  47023. }
  47024. var coordDims = ['x', 'y'];
  47025. var baseAxisDimIndex = option.layout === 'horizontal' ? 0 : 1;
  47026. var baseAxisDim = this._baseAxisDim = coordDims[baseAxisDimIndex];
  47027. var otherAxisDim = coordDims[1 - baseAxisDimIndex];
  47028. var axisModels = [xAxisModel, yAxisModel];
  47029. var baseAxisType = axisModels[baseAxisDimIndex].get('type');
  47030. var otherAxisType = axisModels[1 - baseAxisDimIndex].get('type');
  47031. var data = option.data; // ??? FIXME make a stage to perform data transfrom.
  47032. // MUST create a new data, consider setOption({}) again.
  47033. if (data && addOrdinal) {
  47034. var newOptionData_1 = [];
  47035. each$1(data, function (item, index) {
  47036. var newItem;
  47037. if (isArray(item)) {
  47038. newItem = item.slice();
  47039. item.unshift(index);
  47040. } else if (isArray(item.value)) {
  47041. newItem = item.value.slice();
  47042. item.value.unshift(index);
  47043. } else {
  47044. newItem = item;
  47045. }
  47046. newOptionData_1.push(newItem);
  47047. });
  47048. option.data = newOptionData_1;
  47049. }
  47050. var defaultValueDimensions = this.defaultValueDimensions;
  47051. var coordDimensions = [{
  47052. name: baseAxisDim,
  47053. type: getDimensionTypeByAxis(baseAxisType),
  47054. ordinalMeta: ordinalMeta,
  47055. otherDims: {
  47056. tooltip: false,
  47057. itemName: 0
  47058. },
  47059. dimsDef: ['base']
  47060. }, {
  47061. name: otherAxisDim,
  47062. type: getDimensionTypeByAxis(otherAxisType),
  47063. dimsDef: defaultValueDimensions.slice()
  47064. }];
  47065. return createListSimply(this, {
  47066. coordDimensions: coordDimensions,
  47067. dimensionsCount: defaultValueDimensions.length + 1,
  47068. encodeDefaulter: curry(makeSeriesEncodeForAxisCoordSys, coordDimensions, this)
  47069. });
  47070. };
  47071. /**
  47072. * If horizontal, base axis is x, otherwise y.
  47073. * @override
  47074. */
  47075. WhiskerBoxCommonMixin.prototype.getBaseAxis = function () {
  47076. var dim = this._baseAxisDim;
  47077. return this.ecModel.getComponent(dim + 'Axis', this.get(dim + 'AxisIndex')).axis;
  47078. };
  47079. return WhiskerBoxCommonMixin;
  47080. }();
  47081. /*
  47082. * Licensed to the Apache Software Foundation (ASF) under one
  47083. * or more contributor license agreements. See the NOTICE file
  47084. * distributed with this work for additional information
  47085. * regarding copyright ownership. The ASF licenses this file
  47086. * to you under the Apache License, Version 2.0 (the
  47087. * "License"); you may not use this file except in compliance
  47088. * with the License. You may obtain a copy of the License at
  47089. *
  47090. * http://www.apache.org/licenses/LICENSE-2.0
  47091. *
  47092. * Unless required by applicable law or agreed to in writing,
  47093. * software distributed under the License is distributed on an
  47094. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47095. * KIND, either express or implied. See the License for the
  47096. * specific language governing permissions and limitations
  47097. * under the License.
  47098. */
  47099. /**
  47100. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47101. */
  47102. /*
  47103. * Licensed to the Apache Software Foundation (ASF) under one
  47104. * or more contributor license agreements. See the NOTICE file
  47105. * distributed with this work for additional information
  47106. * regarding copyright ownership. The ASF licenses this file
  47107. * to you under the Apache License, Version 2.0 (the
  47108. * "License"); you may not use this file except in compliance
  47109. * with the License. You may obtain a copy of the License at
  47110. *
  47111. * http://www.apache.org/licenses/LICENSE-2.0
  47112. *
  47113. * Unless required by applicable law or agreed to in writing,
  47114. * software distributed under the License is distributed on an
  47115. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47116. * KIND, either express or implied. See the License for the
  47117. * specific language governing permissions and limitations
  47118. * under the License.
  47119. */
  47120. var CandlestickSeriesModel =
  47121. /** @class */
  47122. function (_super) {
  47123. __extends(CandlestickSeriesModel, _super);
  47124. function CandlestickSeriesModel() {
  47125. var _this = _super !== null && _super.apply(this, arguments) || this;
  47126. _this.type = CandlestickSeriesModel.type;
  47127. _this.defaultValueDimensions = [{
  47128. name: 'open',
  47129. defaultTooltip: true
  47130. }, {
  47131. name: 'close',
  47132. defaultTooltip: true
  47133. }, {
  47134. name: 'lowest',
  47135. defaultTooltip: true
  47136. }, {
  47137. name: 'highest',
  47138. defaultTooltip: true
  47139. }];
  47140. return _this;
  47141. }
  47142. /**
  47143. * Get dimension for shadow in dataZoom
  47144. * @return dimension name
  47145. */
  47146. CandlestickSeriesModel.prototype.getShadowDim = function () {
  47147. return 'open';
  47148. };
  47149. CandlestickSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
  47150. var itemLayout = data.getItemLayout(dataIndex);
  47151. return itemLayout && selectors.rect(itemLayout.brushRect);
  47152. };
  47153. CandlestickSeriesModel.type = 'series.candlestick';
  47154. CandlestickSeriesModel.dependencies = ['xAxis', 'yAxis', 'grid'];
  47155. CandlestickSeriesModel.defaultOption = {
  47156. zlevel: 0,
  47157. z: 2,
  47158. coordinateSystem: 'cartesian2d',
  47159. legendHoverLink: true,
  47160. // xAxisIndex: 0,
  47161. // yAxisIndex: 0,
  47162. layout: null,
  47163. clip: true,
  47164. itemStyle: {
  47165. color: '#eb5454',
  47166. color0: '#47b262',
  47167. borderColor: '#eb5454',
  47168. borderColor0: '#47b262',
  47169. // borderColor: '#d24040',
  47170. // borderColor0: '#398f4f',
  47171. borderWidth: 1
  47172. },
  47173. emphasis: {
  47174. scale: true,
  47175. itemStyle: {
  47176. borderWidth: 2
  47177. }
  47178. },
  47179. barMaxWidth: null,
  47180. barMinWidth: null,
  47181. barWidth: null,
  47182. large: true,
  47183. largeThreshold: 600,
  47184. progressive: 3e3,
  47185. progressiveThreshold: 1e4,
  47186. progressiveChunkMode: 'mod',
  47187. animationEasing: 'linear',
  47188. animationDuration: 300
  47189. };
  47190. return CandlestickSeriesModel;
  47191. }(SeriesModel);
  47192. mixin(CandlestickSeriesModel, WhiskerBoxCommonMixin, true);
  47193. /*
  47194. * Licensed to the Apache Software Foundation (ASF) under one
  47195. * or more contributor license agreements. See the NOTICE file
  47196. * distributed with this work for additional information
  47197. * regarding copyright ownership. The ASF licenses this file
  47198. * to you under the Apache License, Version 2.0 (the
  47199. * "License"); you may not use this file except in compliance
  47200. * with the License. You may obtain a copy of the License at
  47201. *
  47202. * http://www.apache.org/licenses/LICENSE-2.0
  47203. *
  47204. * Unless required by applicable law or agreed to in writing,
  47205. * software distributed under the License is distributed on an
  47206. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47207. * KIND, either express or implied. See the License for the
  47208. * specific language governing permissions and limitations
  47209. * under the License.
  47210. */
  47211. /**
  47212. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47213. */
  47214. /*
  47215. * Licensed to the Apache Software Foundation (ASF) under one
  47216. * or more contributor license agreements. See the NOTICE file
  47217. * distributed with this work for additional information
  47218. * regarding copyright ownership. The ASF licenses this file
  47219. * to you under the Apache License, Version 2.0 (the
  47220. * "License"); you may not use this file except in compliance
  47221. * with the License. You may obtain a copy of the License at
  47222. *
  47223. * http://www.apache.org/licenses/LICENSE-2.0
  47224. *
  47225. * Unless required by applicable law or agreed to in writing,
  47226. * software distributed under the License is distributed on an
  47227. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47228. * KIND, either express or implied. See the License for the
  47229. * specific language governing permissions and limitations
  47230. * under the License.
  47231. */
  47232. function candlestickPreprocessor(option) {
  47233. if (!option || !isArray(option.series)) {
  47234. return;
  47235. } // Translate 'k' to 'candlestick'.
  47236. each$1(option.series, function (seriesItem) {
  47237. if (isObject$1(seriesItem) && seriesItem.type === 'k') {
  47238. seriesItem.type = 'candlestick';
  47239. }
  47240. });
  47241. }
  47242. /*
  47243. * Licensed to the Apache Software Foundation (ASF) under one
  47244. * or more contributor license agreements. See the NOTICE file
  47245. * distributed with this work for additional information
  47246. * regarding copyright ownership. The ASF licenses this file
  47247. * to you under the Apache License, Version 2.0 (the
  47248. * "License"); you may not use this file except in compliance
  47249. * with the License. You may obtain a copy of the License at
  47250. *
  47251. * http://www.apache.org/licenses/LICENSE-2.0
  47252. *
  47253. * Unless required by applicable law or agreed to in writing,
  47254. * software distributed under the License is distributed on an
  47255. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47256. * KIND, either express or implied. See the License for the
  47257. * specific language governing permissions and limitations
  47258. * under the License.
  47259. */
  47260. /**
  47261. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47262. */
  47263. /*
  47264. * Licensed to the Apache Software Foundation (ASF) under one
  47265. * or more contributor license agreements. See the NOTICE file
  47266. * distributed with this work for additional information
  47267. * regarding copyright ownership. The ASF licenses this file
  47268. * to you under the Apache License, Version 2.0 (the
  47269. * "License"); you may not use this file except in compliance
  47270. * with the License. You may obtain a copy of the License at
  47271. *
  47272. * http://www.apache.org/licenses/LICENSE-2.0
  47273. *
  47274. * Unless required by applicable law or agreed to in writing,
  47275. * software distributed under the License is distributed on an
  47276. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47277. * KIND, either express or implied. See the License for the
  47278. * specific language governing permissions and limitations
  47279. * under the License.
  47280. */
  47281. var positiveBorderColorQuery = ['itemStyle', 'borderColor'];
  47282. var negativeBorderColorQuery = ['itemStyle', 'borderColor0'];
  47283. var positiveColorQuery = ['itemStyle', 'color'];
  47284. var negativeColorQuery = ['itemStyle', 'color0'];
  47285. var candlestickVisual = {
  47286. seriesType: 'candlestick',
  47287. plan: createRenderPlanner(),
  47288. // For legend.
  47289. performRawSeries: true,
  47290. reset: function (seriesModel, ecModel) {
  47291. function getColor(sign, model) {
  47292. return model.get(sign > 0 ? positiveColorQuery : negativeColorQuery);
  47293. }
  47294. function getBorderColor(sign, model) {
  47295. return model.get(sign > 0 ? positiveBorderColorQuery : negativeBorderColorQuery);
  47296. }
  47297. var data = seriesModel.getData(); // Only visible series has each data be visual encoded
  47298. if (ecModel.isSeriesFiltered(seriesModel)) {
  47299. return;
  47300. }
  47301. var isLargeRender = seriesModel.pipelineContext.large;
  47302. return !isLargeRender && {
  47303. progress: function (params, data) {
  47304. var dataIndex;
  47305. while ((dataIndex = params.next()) != null) {
  47306. var itemModel = data.getItemModel(dataIndex);
  47307. var sign = data.getItemLayout(dataIndex).sign;
  47308. var style = itemModel.getItemStyle();
  47309. style.fill = getColor(sign, itemModel);
  47310. style.stroke = getBorderColor(sign, itemModel) || style.fill;
  47311. var existsStyle = data.ensureUniqueItemVisual(dataIndex, 'style');
  47312. extend(existsStyle, style);
  47313. }
  47314. }
  47315. };
  47316. }
  47317. };
  47318. /*
  47319. * Licensed to the Apache Software Foundation (ASF) under one
  47320. * or more contributor license agreements. See the NOTICE file
  47321. * distributed with this work for additional information
  47322. * regarding copyright ownership. The ASF licenses this file
  47323. * to you under the Apache License, Version 2.0 (the
  47324. * "License"); you may not use this file except in compliance
  47325. * with the License. You may obtain a copy of the License at
  47326. *
  47327. * http://www.apache.org/licenses/LICENSE-2.0
  47328. *
  47329. * Unless required by applicable law or agreed to in writing,
  47330. * software distributed under the License is distributed on an
  47331. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47332. * KIND, either express or implied. See the License for the
  47333. * specific language governing permissions and limitations
  47334. * under the License.
  47335. */
  47336. /**
  47337. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47338. */
  47339. /*
  47340. * Licensed to the Apache Software Foundation (ASF) under one
  47341. * or more contributor license agreements. See the NOTICE file
  47342. * distributed with this work for additional information
  47343. * regarding copyright ownership. The ASF licenses this file
  47344. * to you under the Apache License, Version 2.0 (the
  47345. * "License"); you may not use this file except in compliance
  47346. * with the License. You may obtain a copy of the License at
  47347. *
  47348. * http://www.apache.org/licenses/LICENSE-2.0
  47349. *
  47350. * Unless required by applicable law or agreed to in writing,
  47351. * software distributed under the License is distributed on an
  47352. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47353. * KIND, either express or implied. See the License for the
  47354. * specific language governing permissions and limitations
  47355. * under the License.
  47356. */
  47357. /* global Float32Array */
  47358. var LargeArr$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array;
  47359. var candlestickLayout = {
  47360. seriesType: 'candlestick',
  47361. plan: createRenderPlanner(),
  47362. reset: function (seriesModel) {
  47363. var coordSys = seriesModel.coordinateSystem;
  47364. var data = seriesModel.getData();
  47365. var candleWidth = calculateCandleWidth(seriesModel, data);
  47366. var cDimIdx = 0;
  47367. var vDimIdx = 1;
  47368. var coordDims = ['x', 'y'];
  47369. var cDim = data.mapDimension(coordDims[cDimIdx]);
  47370. var vDims = data.mapDimensionsAll(coordDims[vDimIdx]);
  47371. var openDim = vDims[0];
  47372. var closeDim = vDims[1];
  47373. var lowestDim = vDims[2];
  47374. var highestDim = vDims[3];
  47375. data.setLayout({
  47376. candleWidth: candleWidth,
  47377. // The value is experimented visually.
  47378. isSimpleBox: candleWidth <= 1.3
  47379. });
  47380. if (cDim == null || vDims.length < 4) {
  47381. return;
  47382. }
  47383. return {
  47384. progress: seriesModel.pipelineContext.large ? largeProgress : normalProgress
  47385. };
  47386. function normalProgress(params, data) {
  47387. var dataIndex;
  47388. while ((dataIndex = params.next()) != null) {
  47389. var axisDimVal = data.get(cDim, dataIndex);
  47390. var openVal = data.get(openDim, dataIndex);
  47391. var closeVal = data.get(closeDim, dataIndex);
  47392. var lowestVal = data.get(lowestDim, dataIndex);
  47393. var highestVal = data.get(highestDim, dataIndex);
  47394. var ocLow = Math.min(openVal, closeVal);
  47395. var ocHigh = Math.max(openVal, closeVal);
  47396. var ocLowPoint = getPoint(ocLow, axisDimVal);
  47397. var ocHighPoint = getPoint(ocHigh, axisDimVal);
  47398. var lowestPoint = getPoint(lowestVal, axisDimVal);
  47399. var highestPoint = getPoint(highestVal, axisDimVal);
  47400. var ends = [];
  47401. addBodyEnd(ends, ocHighPoint, 0);
  47402. addBodyEnd(ends, ocLowPoint, 1);
  47403. ends.push(subPixelOptimizePoint(highestPoint), subPixelOptimizePoint(ocHighPoint), subPixelOptimizePoint(lowestPoint), subPixelOptimizePoint(ocLowPoint));
  47404. data.setItemLayout(dataIndex, {
  47405. sign: getSign(data, dataIndex, openVal, closeVal, closeDim),
  47406. initBaseline: openVal > closeVal ? ocHighPoint[vDimIdx] : ocLowPoint[vDimIdx],
  47407. ends: ends,
  47408. brushRect: makeBrushRect(lowestVal, highestVal, axisDimVal)
  47409. });
  47410. }
  47411. function getPoint(val, axisDimVal) {
  47412. var p = [];
  47413. p[cDimIdx] = axisDimVal;
  47414. p[vDimIdx] = val;
  47415. return isNaN(axisDimVal) || isNaN(val) ? [NaN, NaN] : coordSys.dataToPoint(p);
  47416. }
  47417. function addBodyEnd(ends, point, start) {
  47418. var point1 = point.slice();
  47419. var point2 = point.slice();
  47420. point1[cDimIdx] = subPixelOptimize$1(point1[cDimIdx] + candleWidth / 2, 1, false);
  47421. point2[cDimIdx] = subPixelOptimize$1(point2[cDimIdx] - candleWidth / 2, 1, true);
  47422. start ? ends.push(point1, point2) : ends.push(point2, point1);
  47423. }
  47424. function makeBrushRect(lowestVal, highestVal, axisDimVal) {
  47425. var pmin = getPoint(lowestVal, axisDimVal);
  47426. var pmax = getPoint(highestVal, axisDimVal);
  47427. pmin[cDimIdx] -= candleWidth / 2;
  47428. pmax[cDimIdx] -= candleWidth / 2;
  47429. return {
  47430. x: pmin[0],
  47431. y: pmin[1],
  47432. width: vDimIdx ? candleWidth : pmax[0] - pmin[0],
  47433. height: vDimIdx ? pmax[1] - pmin[1] : candleWidth
  47434. };
  47435. }
  47436. function subPixelOptimizePoint(point) {
  47437. point[cDimIdx] = subPixelOptimize$1(point[cDimIdx], 1);
  47438. return point;
  47439. }
  47440. }
  47441. function largeProgress(params, data) {
  47442. // Structure: [sign, x, yhigh, ylow, sign, x, yhigh, ylow, ...]
  47443. var points = new LargeArr$1(params.count * 4);
  47444. var offset = 0;
  47445. var point;
  47446. var tmpIn = [];
  47447. var tmpOut = [];
  47448. var dataIndex;
  47449. while ((dataIndex = params.next()) != null) {
  47450. var axisDimVal = data.get(cDim, dataIndex);
  47451. var openVal = data.get(openDim, dataIndex);
  47452. var closeVal = data.get(closeDim, dataIndex);
  47453. var lowestVal = data.get(lowestDim, dataIndex);
  47454. var highestVal = data.get(highestDim, dataIndex);
  47455. if (isNaN(axisDimVal) || isNaN(lowestVal) || isNaN(highestVal)) {
  47456. points[offset++] = NaN;
  47457. offset += 3;
  47458. continue;
  47459. }
  47460. points[offset++] = getSign(data, dataIndex, openVal, closeVal, closeDim);
  47461. tmpIn[cDimIdx] = axisDimVal;
  47462. tmpIn[vDimIdx] = lowestVal;
  47463. point = coordSys.dataToPoint(tmpIn, null, tmpOut);
  47464. points[offset++] = point ? point[0] : NaN;
  47465. points[offset++] = point ? point[1] : NaN;
  47466. tmpIn[vDimIdx] = highestVal;
  47467. point = coordSys.dataToPoint(tmpIn, null, tmpOut);
  47468. points[offset++] = point ? point[1] : NaN;
  47469. }
  47470. data.setLayout('largePoints', points);
  47471. }
  47472. }
  47473. };
  47474. function getSign(data, dataIndex, openVal, closeVal, closeDim) {
  47475. var sign;
  47476. if (openVal > closeVal) {
  47477. sign = -1;
  47478. } else if (openVal < closeVal) {
  47479. sign = 1;
  47480. } else {
  47481. sign = dataIndex > 0 // If close === open, compare with close of last record
  47482. ? data.get(closeDim, dataIndex - 1) <= closeVal ? 1 : -1 : // No record of previous, set to be positive
  47483. 1;
  47484. }
  47485. return sign;
  47486. }
  47487. function calculateCandleWidth(seriesModel, data) {
  47488. var baseAxis = seriesModel.getBaseAxis();
  47489. var extent;
  47490. var bandWidth = baseAxis.type === 'category' ? baseAxis.getBandWidth() : (extent = baseAxis.getExtent(), Math.abs(extent[1] - extent[0]) / data.count());
  47491. var barMaxWidth = parsePercent$1(retrieve2(seriesModel.get('barMaxWidth'), bandWidth), bandWidth);
  47492. var barMinWidth = parsePercent$1(retrieve2(seriesModel.get('barMinWidth'), 1), bandWidth);
  47493. var barWidth = seriesModel.get('barWidth');
  47494. return barWidth != null ? parsePercent$1(barWidth, bandWidth) // Put max outer to ensure bar visible in spite of overlap.
  47495. : Math.max(Math.min(bandWidth / 2, barMaxWidth), barMinWidth);
  47496. }
  47497. /*
  47498. * Licensed to the Apache Software Foundation (ASF) under one
  47499. * or more contributor license agreements. See the NOTICE file
  47500. * distributed with this work for additional information
  47501. * regarding copyright ownership. The ASF licenses this file
  47502. * to you under the Apache License, Version 2.0 (the
  47503. * "License"); you may not use this file except in compliance
  47504. * with the License. You may obtain a copy of the License at
  47505. *
  47506. * http://www.apache.org/licenses/LICENSE-2.0
  47507. *
  47508. * Unless required by applicable law or agreed to in writing,
  47509. * software distributed under the License is distributed on an
  47510. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47511. * KIND, either express or implied. See the License for the
  47512. * specific language governing permissions and limitations
  47513. * under the License.
  47514. */
  47515. /**
  47516. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47517. */
  47518. /*
  47519. * Licensed to the Apache Software Foundation (ASF) under one
  47520. * or more contributor license agreements. See the NOTICE file
  47521. * distributed with this work for additional information
  47522. * regarding copyright ownership. The ASF licenses this file
  47523. * to you under the Apache License, Version 2.0 (the
  47524. * "License"); you may not use this file except in compliance
  47525. * with the License. You may obtain a copy of the License at
  47526. *
  47527. * http://www.apache.org/licenses/LICENSE-2.0
  47528. *
  47529. * Unless required by applicable law or agreed to in writing,
  47530. * software distributed under the License is distributed on an
  47531. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47532. * KIND, either express or implied. See the License for the
  47533. * specific language governing permissions and limitations
  47534. * under the License.
  47535. */
  47536. function install$8(registers) {
  47537. registers.registerChartView(CandlestickView);
  47538. registers.registerSeriesModel(CandlestickSeriesModel);
  47539. registers.registerPreprocessor(candlestickPreprocessor);
  47540. registers.registerVisual(candlestickVisual);
  47541. registers.registerLayout(candlestickLayout);
  47542. }
  47543. /*
  47544. * Licensed to the Apache Software Foundation (ASF) under one
  47545. * or more contributor license agreements. See the NOTICE file
  47546. * distributed with this work for additional information
  47547. * regarding copyright ownership. The ASF licenses this file
  47548. * to you under the Apache License, Version 2.0 (the
  47549. * "License"); you may not use this file except in compliance
  47550. * with the License. You may obtain a copy of the License at
  47551. *
  47552. * http://www.apache.org/licenses/LICENSE-2.0
  47553. *
  47554. * Unless required by applicable law or agreed to in writing,
  47555. * software distributed under the License is distributed on an
  47556. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47557. * KIND, either express or implied. See the License for the
  47558. * specific language governing permissions and limitations
  47559. * under the License.
  47560. */
  47561. /**
  47562. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47563. */
  47564. /*
  47565. * Licensed to the Apache Software Foundation (ASF) under one
  47566. * or more contributor license agreements. See the NOTICE file
  47567. * distributed with this work for additional information
  47568. * regarding copyright ownership. The ASF licenses this file
  47569. * to you under the Apache License, Version 2.0 (the
  47570. * "License"); you may not use this file except in compliance
  47571. * with the License. You may obtain a copy of the License at
  47572. *
  47573. * http://www.apache.org/licenses/LICENSE-2.0
  47574. *
  47575. * Unless required by applicable law or agreed to in writing,
  47576. * software distributed under the License is distributed on an
  47577. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47578. * KIND, either express or implied. See the License for the
  47579. * specific language governing permissions and limitations
  47580. * under the License.
  47581. */
  47582. use(install$8);
  47583. /*
  47584. * Licensed to the Apache Software Foundation (ASF) under one
  47585. * or more contributor license agreements. See the NOTICE file
  47586. * distributed with this work for additional information
  47587. * regarding copyright ownership. The ASF licenses this file
  47588. * to you under the Apache License, Version 2.0 (the
  47589. * "License"); you may not use this file except in compliance
  47590. * with the License. You may obtain a copy of the License at
  47591. *
  47592. * http://www.apache.org/licenses/LICENSE-2.0
  47593. *
  47594. * Unless required by applicable law or agreed to in writing,
  47595. * software distributed under the License is distributed on an
  47596. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47597. * KIND, either express or implied. See the License for the
  47598. * specific language governing permissions and limitations
  47599. * under the License.
  47600. */
  47601. /**
  47602. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47603. */
  47604. /*
  47605. * Licensed to the Apache Software Foundation (ASF) under one
  47606. * or more contributor license agreements. See the NOTICE file
  47607. * distributed with this work for additional information
  47608. * regarding copyright ownership. The ASF licenses this file
  47609. * to you under the Apache License, Version 2.0 (the
  47610. * "License"); you may not use this file except in compliance
  47611. * with the License. You may obtain a copy of the License at
  47612. *
  47613. * http://www.apache.org/licenses/LICENSE-2.0
  47614. *
  47615. * Unless required by applicable law or agreed to in writing,
  47616. * software distributed under the License is distributed on an
  47617. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47618. * KIND, either express or implied. See the License for the
  47619. * specific language governing permissions and limitations
  47620. * under the License.
  47621. */
  47622. function radarLayout(ecModel) {
  47623. ecModel.eachSeriesByType('radar', function (seriesModel) {
  47624. var data = seriesModel.getData();
  47625. var points = [];
  47626. var coordSys = seriesModel.coordinateSystem;
  47627. if (!coordSys) {
  47628. return;
  47629. }
  47630. var axes = coordSys.getIndicatorAxes();
  47631. each$1(axes, function (axis, axisIndex) {
  47632. data.each(data.mapDimension(axes[axisIndex].dim), function (val, dataIndex) {
  47633. points[dataIndex] = points[dataIndex] || [];
  47634. var point = coordSys.dataToPoint(val, axisIndex);
  47635. points[dataIndex][axisIndex] = isValidPoint(point) ? point : getValueMissingPoint(coordSys);
  47636. });
  47637. }); // Close polygon
  47638. data.each(function (idx) {
  47639. // TODO
  47640. // Is it appropriate to connect to the next data when some data is missing?
  47641. // Or, should trade it like `connectNull` in line chart?
  47642. var firstPoint = find(points[idx], function (point) {
  47643. return isValidPoint(point);
  47644. }) || getValueMissingPoint(coordSys); // Copy the first actual point to the end of the array
  47645. points[idx].push(firstPoint.slice());
  47646. data.setItemLayout(idx, points[idx]);
  47647. });
  47648. });
  47649. }
  47650. function isValidPoint(point) {
  47651. return !isNaN(point[0]) && !isNaN(point[1]);
  47652. }
  47653. function getValueMissingPoint(coordSys) {
  47654. // It is error-prone to input [NaN, NaN] into polygon, polygon.
  47655. // (probably cause problem when refreshing or animating)
  47656. return [coordSys.cx, coordSys.cy];
  47657. }
  47658. /*
  47659. * Licensed to the Apache Software Foundation (ASF) under one
  47660. * or more contributor license agreements. See the NOTICE file
  47661. * distributed with this work for additional information
  47662. * regarding copyright ownership. The ASF licenses this file
  47663. * to you under the Apache License, Version 2.0 (the
  47664. * "License"); you may not use this file except in compliance
  47665. * with the License. You may obtain a copy of the License at
  47666. *
  47667. * http://www.apache.org/licenses/LICENSE-2.0
  47668. *
  47669. * Unless required by applicable law or agreed to in writing,
  47670. * software distributed under the License is distributed on an
  47671. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47672. * KIND, either express or implied. See the License for the
  47673. * specific language governing permissions and limitations
  47674. * under the License.
  47675. */
  47676. /**
  47677. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47678. */
  47679. /*
  47680. * Licensed to the Apache Software Foundation (ASF) under one
  47681. * or more contributor license agreements. See the NOTICE file
  47682. * distributed with this work for additional information
  47683. * regarding copyright ownership. The ASF licenses this file
  47684. * to you under the Apache License, Version 2.0 (the
  47685. * "License"); you may not use this file except in compliance
  47686. * with the License. You may obtain a copy of the License at
  47687. *
  47688. * http://www.apache.org/licenses/LICENSE-2.0
  47689. *
  47690. * Unless required by applicable law or agreed to in writing,
  47691. * software distributed under the License is distributed on an
  47692. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47693. * KIND, either express or implied. See the License for the
  47694. * specific language governing permissions and limitations
  47695. * under the License.
  47696. */
  47697. // @ts-nocheck
  47698. // Backward compat for radar chart in 2
  47699. function radarBackwardCompat(option) {
  47700. var polarOptArr = option.polar;
  47701. if (polarOptArr) {
  47702. if (!isArray(polarOptArr)) {
  47703. polarOptArr = [polarOptArr];
  47704. }
  47705. var polarNotRadar_1 = [];
  47706. each$1(polarOptArr, function (polarOpt, idx) {
  47707. if (polarOpt.indicator) {
  47708. if (polarOpt.type && !polarOpt.shape) {
  47709. polarOpt.shape = polarOpt.type;
  47710. }
  47711. option.radar = option.radar || [];
  47712. if (!isArray(option.radar)) {
  47713. option.radar = [option.radar];
  47714. }
  47715. option.radar.push(polarOpt);
  47716. } else {
  47717. polarNotRadar_1.push(polarOpt);
  47718. }
  47719. });
  47720. option.polar = polarNotRadar_1;
  47721. }
  47722. each$1(option.series, function (seriesOpt) {
  47723. if (seriesOpt && seriesOpt.type === 'radar' && seriesOpt.polarIndex) {
  47724. seriesOpt.radarIndex = seriesOpt.polarIndex;
  47725. }
  47726. });
  47727. }
  47728. /*
  47729. * Licensed to the Apache Software Foundation (ASF) under one
  47730. * or more contributor license agreements. See the NOTICE file
  47731. * distributed with this work for additional information
  47732. * regarding copyright ownership. The ASF licenses this file
  47733. * to you under the Apache License, Version 2.0 (the
  47734. * "License"); you may not use this file except in compliance
  47735. * with the License. You may obtain a copy of the License at
  47736. *
  47737. * http://www.apache.org/licenses/LICENSE-2.0
  47738. *
  47739. * Unless required by applicable law or agreed to in writing,
  47740. * software distributed under the License is distributed on an
  47741. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47742. * KIND, either express or implied. See the License for the
  47743. * specific language governing permissions and limitations
  47744. * under the License.
  47745. */
  47746. /**
  47747. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47748. */
  47749. /*
  47750. * Licensed to the Apache Software Foundation (ASF) under one
  47751. * or more contributor license agreements. See the NOTICE file
  47752. * distributed with this work for additional information
  47753. * regarding copyright ownership. The ASF licenses this file
  47754. * to you under the Apache License, Version 2.0 (the
  47755. * "License"); you may not use this file except in compliance
  47756. * with the License. You may obtain a copy of the License at
  47757. *
  47758. * http://www.apache.org/licenses/LICENSE-2.0
  47759. *
  47760. * Unless required by applicable law or agreed to in writing,
  47761. * software distributed under the License is distributed on an
  47762. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47763. * KIND, either express or implied. See the License for the
  47764. * specific language governing permissions and limitations
  47765. * under the License.
  47766. */
  47767. function normalizeSymbolSize$1(symbolSize) {
  47768. if (!isArray(symbolSize)) {
  47769. symbolSize = [+symbolSize, +symbolSize];
  47770. }
  47771. return symbolSize;
  47772. }
  47773. var RadarView =
  47774. /** @class */
  47775. function (_super) {
  47776. __extends(RadarView, _super);
  47777. function RadarView() {
  47778. var _this = _super !== null && _super.apply(this, arguments) || this;
  47779. _this.type = RadarView.type;
  47780. return _this;
  47781. }
  47782. RadarView.prototype.render = function (seriesModel, ecModel, api) {
  47783. var polar = seriesModel.coordinateSystem;
  47784. var group = this.group;
  47785. var data = seriesModel.getData();
  47786. var oldData = this._data;
  47787. function createSymbol$$1(data, idx) {
  47788. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  47789. if (symbolType === 'none') {
  47790. return;
  47791. }
  47792. var symbolSize = normalizeSymbolSize$1(data.getItemVisual(idx, 'symbolSize'));
  47793. var symbolPath = createSymbol(symbolType, -1, -1, 2, 2);
  47794. var symbolRotate = data.getItemVisual(idx, 'symbolRotate') || 0;
  47795. symbolPath.attr({
  47796. style: {
  47797. strokeNoScale: true
  47798. },
  47799. z2: 100,
  47800. scaleX: symbolSize[0] / 2,
  47801. scaleY: symbolSize[1] / 2,
  47802. rotation: symbolRotate * Math.PI / 180 || 0
  47803. });
  47804. return symbolPath;
  47805. }
  47806. function updateSymbols(oldPoints, newPoints, symbolGroup, data, idx, isInit) {
  47807. // Simply rerender all
  47808. symbolGroup.removeAll();
  47809. for (var i = 0; i < newPoints.length - 1; i++) {
  47810. var symbolPath = createSymbol$$1(data, idx);
  47811. if (symbolPath) {
  47812. symbolPath.__dimIdx = i;
  47813. if (oldPoints[i]) {
  47814. symbolPath.setPosition(oldPoints[i]);
  47815. graphic[isInit ? 'initProps' : 'updateProps'](symbolPath, {
  47816. x: newPoints[i][0],
  47817. y: newPoints[i][1]
  47818. }, seriesModel, idx);
  47819. } else {
  47820. symbolPath.setPosition(newPoints[i]);
  47821. }
  47822. symbolGroup.add(symbolPath);
  47823. }
  47824. }
  47825. }
  47826. function getInitialPoints(points) {
  47827. return map(points, function (pt) {
  47828. return [polar.cx, polar.cy];
  47829. });
  47830. }
  47831. data.diff(oldData).add(function (idx) {
  47832. var points = data.getItemLayout(idx);
  47833. if (!points) {
  47834. return;
  47835. }
  47836. var polygon = new Polygon();
  47837. var polyline = new Polyline();
  47838. var target = {
  47839. shape: {
  47840. points: points
  47841. }
  47842. };
  47843. polygon.shape.points = getInitialPoints(points);
  47844. polyline.shape.points = getInitialPoints(points);
  47845. initProps(polygon, target, seriesModel, idx);
  47846. initProps(polyline, target, seriesModel, idx);
  47847. var itemGroup = new Group();
  47848. var symbolGroup = new Group();
  47849. itemGroup.add(polyline);
  47850. itemGroup.add(polygon);
  47851. itemGroup.add(symbolGroup);
  47852. updateSymbols(polyline.shape.points, points, symbolGroup, data, idx, true);
  47853. data.setItemGraphicEl(idx, itemGroup);
  47854. }).update(function (newIdx, oldIdx) {
  47855. var itemGroup = oldData.getItemGraphicEl(oldIdx);
  47856. var polyline = itemGroup.childAt(0);
  47857. var polygon = itemGroup.childAt(1);
  47858. var symbolGroup = itemGroup.childAt(2);
  47859. var target = {
  47860. shape: {
  47861. points: data.getItemLayout(newIdx)
  47862. }
  47863. };
  47864. if (!target.shape.points) {
  47865. return;
  47866. }
  47867. updateSymbols(polyline.shape.points, target.shape.points, symbolGroup, data, newIdx, false);
  47868. updateProps(polyline, target, seriesModel);
  47869. updateProps(polygon, target, seriesModel);
  47870. data.setItemGraphicEl(newIdx, itemGroup);
  47871. }).remove(function (idx) {
  47872. group.remove(oldData.getItemGraphicEl(idx));
  47873. }).execute();
  47874. data.eachItemGraphicEl(function (itemGroup, idx) {
  47875. var itemModel = data.getItemModel(idx);
  47876. var polyline = itemGroup.childAt(0);
  47877. var polygon = itemGroup.childAt(1);
  47878. var symbolGroup = itemGroup.childAt(2); // Radar uses the visual encoded from itemStyle.
  47879. var itemStyle = data.getItemVisual(idx, 'style');
  47880. var color = itemStyle.fill;
  47881. group.add(itemGroup);
  47882. polyline.useStyle(defaults(itemModel.getModel('lineStyle').getLineStyle(), {
  47883. fill: 'none',
  47884. stroke: color
  47885. }));
  47886. setStatesStylesFromModel(polyline, itemModel, 'lineStyle');
  47887. setStatesStylesFromModel(polygon, itemModel, 'areaStyle');
  47888. var areaStyleModel = itemModel.getModel('areaStyle');
  47889. var polygonIgnore = areaStyleModel.isEmpty() && areaStyleModel.parentModel.isEmpty();
  47890. polygon.ignore = polygonIgnore;
  47891. each$1(['emphasis', 'select', 'blur'], function (stateName) {
  47892. var stateModel = itemModel.getModel([stateName, 'areaStyle']);
  47893. var stateIgnore = stateModel.isEmpty() && stateModel.parentModel.isEmpty(); // Won't be ignore if normal state is not ignore.
  47894. polygon.ensureState(stateName).ignore = stateIgnore && polygonIgnore;
  47895. });
  47896. polygon.useStyle(defaults(areaStyleModel.getAreaStyle(), {
  47897. fill: color,
  47898. opacity: 0.7,
  47899. decal: itemStyle.decal
  47900. }));
  47901. var emphasisModel = itemModel.getModel('emphasis');
  47902. var itemHoverStyle = emphasisModel.getModel('itemStyle').getItemStyle();
  47903. symbolGroup.eachChild(function (symbolPath) {
  47904. if (symbolPath instanceof ZRImage) {
  47905. var pathStyle = symbolPath.style;
  47906. symbolPath.useStyle(extend({
  47907. // TODO other properties like x, y ?
  47908. image: pathStyle.image,
  47909. x: pathStyle.x,
  47910. y: pathStyle.y,
  47911. width: pathStyle.width,
  47912. height: pathStyle.height
  47913. }, itemStyle));
  47914. } else {
  47915. symbolPath.useStyle(itemStyle);
  47916. symbolPath.setColor(color);
  47917. }
  47918. var pathEmphasisState = symbolPath.ensureState('emphasis');
  47919. pathEmphasisState.style = clone(itemHoverStyle);
  47920. var defaultText = data.get(data.dimensions[symbolPath.__dimIdx], idx);
  47921. (defaultText == null || isNaN(defaultText)) && (defaultText = '');
  47922. setLabelStyle(symbolPath, getLabelStatesModels(itemModel), {
  47923. labelFetcher: data.hostModel,
  47924. labelDataIndex: idx,
  47925. labelDimIndex: symbolPath.__dimIdx,
  47926. defaultText: defaultText,
  47927. inheritColor: color,
  47928. defaultOpacity: itemStyle.opacity
  47929. });
  47930. });
  47931. enableHoverEmphasis(itemGroup, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  47932. });
  47933. this._data = data;
  47934. };
  47935. RadarView.prototype.remove = function () {
  47936. this.group.removeAll();
  47937. this._data = null;
  47938. };
  47939. RadarView.type = 'radar';
  47940. return RadarView;
  47941. }(ChartView);
  47942. /*
  47943. * Licensed to the Apache Software Foundation (ASF) under one
  47944. * or more contributor license agreements. See the NOTICE file
  47945. * distributed with this work for additional information
  47946. * regarding copyright ownership. The ASF licenses this file
  47947. * to you under the Apache License, Version 2.0 (the
  47948. * "License"); you may not use this file except in compliance
  47949. * with the License. You may obtain a copy of the License at
  47950. *
  47951. * http://www.apache.org/licenses/LICENSE-2.0
  47952. *
  47953. * Unless required by applicable law or agreed to in writing,
  47954. * software distributed under the License is distributed on an
  47955. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47956. * KIND, either express or implied. See the License for the
  47957. * specific language governing permissions and limitations
  47958. * under the License.
  47959. */
  47960. /**
  47961. * AUTO-GENERATED FILE. DO NOT MODIFY.
  47962. */
  47963. /*
  47964. * Licensed to the Apache Software Foundation (ASF) under one
  47965. * or more contributor license agreements. See the NOTICE file
  47966. * distributed with this work for additional information
  47967. * regarding copyright ownership. The ASF licenses this file
  47968. * to you under the Apache License, Version 2.0 (the
  47969. * "License"); you may not use this file except in compliance
  47970. * with the License. You may obtain a copy of the License at
  47971. *
  47972. * http://www.apache.org/licenses/LICENSE-2.0
  47973. *
  47974. * Unless required by applicable law or agreed to in writing,
  47975. * software distributed under the License is distributed on an
  47976. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  47977. * KIND, either express or implied. See the License for the
  47978. * specific language governing permissions and limitations
  47979. * under the License.
  47980. */
  47981. var RadarSeriesModel =
  47982. /** @class */
  47983. function (_super) {
  47984. __extends(RadarSeriesModel, _super);
  47985. function RadarSeriesModel() {
  47986. var _this = _super !== null && _super.apply(this, arguments) || this;
  47987. _this.type = RadarSeriesModel.type;
  47988. _this.useColorPaletteOnData = true;
  47989. _this.hasSymbolVisual = true;
  47990. return _this;
  47991. } // Overwrite
  47992. RadarSeriesModel.prototype.init = function (option) {
  47993. _super.prototype.init.apply(this, arguments); // Enable legend selection for each data item
  47994. // Use a function instead of direct access because data reference may changed
  47995. this.legendVisualProvider = new LegendVisualProvider(bind(this.getData, this), bind(this.getRawData, this));
  47996. };
  47997. RadarSeriesModel.prototype.getInitialData = function (option, ecModel) {
  47998. return createListSimply(this, {
  47999. generateCoord: 'indicator_',
  48000. generateCoordCount: Infinity
  48001. });
  48002. };
  48003. RadarSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  48004. var data = this.getData();
  48005. var coordSys = this.coordinateSystem;
  48006. var indicatorAxes = coordSys.getIndicatorAxes();
  48007. var name = this.getData().getName(dataIndex);
  48008. var nameToDisplay = name === '' ? this.name : name;
  48009. var markerColor = retrieveVisualColorForTooltipMarker(this, dataIndex);
  48010. return createTooltipMarkup('section', {
  48011. header: nameToDisplay,
  48012. sortBlocks: true,
  48013. blocks: map(indicatorAxes, function (axis) {
  48014. var val = data.get(data.mapDimension(axis.dim), dataIndex);
  48015. return createTooltipMarkup('nameValue', {
  48016. markerType: 'subItem',
  48017. markerColor: markerColor,
  48018. name: axis.name,
  48019. value: val,
  48020. sortParam: val
  48021. });
  48022. })
  48023. });
  48024. };
  48025. RadarSeriesModel.prototype.getTooltipPosition = function (dataIndex) {
  48026. if (dataIndex != null) {
  48027. var data_1 = this.getData();
  48028. var coordSys = this.coordinateSystem;
  48029. var values = data_1.getValues(map(coordSys.dimensions, function (dim) {
  48030. return data_1.mapDimension(dim);
  48031. }), dataIndex);
  48032. for (var i = 0, len = values.length; i < len; i++) {
  48033. if (!isNaN(values[i])) {
  48034. var indicatorAxes = coordSys.getIndicatorAxes();
  48035. return coordSys.coordToPoint(indicatorAxes[i].dataToCoord(values[i]), i);
  48036. }
  48037. }
  48038. }
  48039. };
  48040. RadarSeriesModel.type = 'series.radar';
  48041. RadarSeriesModel.dependencies = ['radar'];
  48042. RadarSeriesModel.defaultOption = {
  48043. zlevel: 0,
  48044. z: 2,
  48045. coordinateSystem: 'radar',
  48046. legendHoverLink: true,
  48047. radarIndex: 0,
  48048. lineStyle: {
  48049. width: 2,
  48050. type: 'solid'
  48051. },
  48052. label: {
  48053. position: 'top'
  48054. },
  48055. // areaStyle: {
  48056. // },
  48057. // itemStyle: {}
  48058. symbolSize: 8 // symbolRotate: null
  48059. };
  48060. return RadarSeriesModel;
  48061. }(SeriesModel);
  48062. /*
  48063. * Licensed to the Apache Software Foundation (ASF) under one
  48064. * or more contributor license agreements. See the NOTICE file
  48065. * distributed with this work for additional information
  48066. * regarding copyright ownership. The ASF licenses this file
  48067. * to you under the Apache License, Version 2.0 (the
  48068. * "License"); you may not use this file except in compliance
  48069. * with the License. You may obtain a copy of the License at
  48070. *
  48071. * http://www.apache.org/licenses/LICENSE-2.0
  48072. *
  48073. * Unless required by applicable law or agreed to in writing,
  48074. * software distributed under the License is distributed on an
  48075. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48076. * KIND, either express or implied. See the License for the
  48077. * specific language governing permissions and limitations
  48078. * under the License.
  48079. */
  48080. /**
  48081. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48082. */
  48083. /*
  48084. * Licensed to the Apache Software Foundation (ASF) under one
  48085. * or more contributor license agreements. See the NOTICE file
  48086. * distributed with this work for additional information
  48087. * regarding copyright ownership. The ASF licenses this file
  48088. * to you under the Apache License, Version 2.0 (the
  48089. * "License"); you may not use this file except in compliance
  48090. * with the License. You may obtain a copy of the License at
  48091. *
  48092. * http://www.apache.org/licenses/LICENSE-2.0
  48093. *
  48094. * Unless required by applicable law or agreed to in writing,
  48095. * software distributed under the License is distributed on an
  48096. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48097. * KIND, either express or implied. See the License for the
  48098. * specific language governing permissions and limitations
  48099. * under the License.
  48100. */
  48101. var valueAxisDefault = axisDefault.value;
  48102. function defaultsShow(opt, show) {
  48103. return defaults({
  48104. show: show
  48105. }, opt);
  48106. }
  48107. var RadarModel =
  48108. /** @class */
  48109. function (_super) {
  48110. __extends(RadarModel, _super);
  48111. function RadarModel() {
  48112. var _this = _super !== null && _super.apply(this, arguments) || this;
  48113. _this.type = RadarModel.type;
  48114. return _this;
  48115. }
  48116. RadarModel.prototype.optionUpdated = function () {
  48117. var boundaryGap = this.get('boundaryGap');
  48118. var splitNumber = this.get('splitNumber');
  48119. var scale = this.get('scale');
  48120. var axisLine = this.get('axisLine');
  48121. var axisTick = this.get('axisTick'); // let axisType = this.get('axisType');
  48122. var axisLabel = this.get('axisLabel');
  48123. var nameTextStyle = this.get('axisName');
  48124. var showName = this.get(['axisName', 'show']);
  48125. var nameFormatter = this.get(['axisName', 'formatter']);
  48126. var nameGap = this.get('axisNameGap');
  48127. var triggerEvent = this.get('triggerEvent');
  48128. var indicatorModels = map(this.get('indicator') || [], function (indicatorOpt) {
  48129. // PENDING
  48130. if (indicatorOpt.max != null && indicatorOpt.max > 0 && !indicatorOpt.min) {
  48131. indicatorOpt.min = 0;
  48132. } else if (indicatorOpt.min != null && indicatorOpt.min < 0 && !indicatorOpt.max) {
  48133. indicatorOpt.max = 0;
  48134. }
  48135. var iNameTextStyle = nameTextStyle;
  48136. if (indicatorOpt.color != null) {
  48137. iNameTextStyle = defaults({
  48138. color: indicatorOpt.color
  48139. }, nameTextStyle);
  48140. } // Use same configuration
  48141. var innerIndicatorOpt = merge(clone(indicatorOpt), {
  48142. boundaryGap: boundaryGap,
  48143. splitNumber: splitNumber,
  48144. scale: scale,
  48145. axisLine: axisLine,
  48146. axisTick: axisTick,
  48147. // axisType: axisType,
  48148. axisLabel: axisLabel,
  48149. // Compatible with 2 and use text
  48150. name: indicatorOpt.text,
  48151. nameLocation: 'end',
  48152. nameGap: nameGap,
  48153. // min: 0,
  48154. nameTextStyle: iNameTextStyle,
  48155. triggerEvent: triggerEvent
  48156. }, false);
  48157. if (!showName) {
  48158. innerIndicatorOpt.name = '';
  48159. }
  48160. if (typeof nameFormatter === 'string') {
  48161. var indName = innerIndicatorOpt.name;
  48162. innerIndicatorOpt.name = nameFormatter.replace('{value}', indName != null ? indName : '');
  48163. } else if (typeof nameFormatter === 'function') {
  48164. innerIndicatorOpt.name = nameFormatter(innerIndicatorOpt.name, innerIndicatorOpt);
  48165. }
  48166. var model = new Model(innerIndicatorOpt, null, this.ecModel);
  48167. mixin(model, AxisModelCommonMixin.prototype); // For triggerEvent.
  48168. model.mainType = 'radar';
  48169. model.componentIndex = this.componentIndex;
  48170. return model;
  48171. }, this);
  48172. this._indicatorModels = indicatorModels;
  48173. };
  48174. RadarModel.prototype.getIndicatorModels = function () {
  48175. return this._indicatorModels;
  48176. };
  48177. RadarModel.type = 'radar';
  48178. RadarModel.defaultOption = {
  48179. zlevel: 0,
  48180. z: 0,
  48181. center: ['50%', '50%'],
  48182. radius: '75%',
  48183. startAngle: 90,
  48184. axisName: {
  48185. show: true // formatter: null
  48186. // textStyle: {}
  48187. },
  48188. boundaryGap: [0, 0],
  48189. splitNumber: 5,
  48190. axisNameGap: 15,
  48191. scale: false,
  48192. // Polygon or circle
  48193. shape: 'polygon',
  48194. axisLine: merge({
  48195. lineStyle: {
  48196. color: '#bbb'
  48197. }
  48198. }, valueAxisDefault.axisLine),
  48199. axisLabel: defaultsShow(valueAxisDefault.axisLabel, false),
  48200. axisTick: defaultsShow(valueAxisDefault.axisTick, false),
  48201. // axisType: 'value',
  48202. splitLine: defaultsShow(valueAxisDefault.splitLine, true),
  48203. splitArea: defaultsShow(valueAxisDefault.splitArea, true),
  48204. // {text, min, max}
  48205. indicator: []
  48206. };
  48207. return RadarModel;
  48208. }(ComponentModel);
  48209. /*
  48210. * Licensed to the Apache Software Foundation (ASF) under one
  48211. * or more contributor license agreements. See the NOTICE file
  48212. * distributed with this work for additional information
  48213. * regarding copyright ownership. The ASF licenses this file
  48214. * to you under the Apache License, Version 2.0 (the
  48215. * "License"); you may not use this file except in compliance
  48216. * with the License. You may obtain a copy of the License at
  48217. *
  48218. * http://www.apache.org/licenses/LICENSE-2.0
  48219. *
  48220. * Unless required by applicable law or agreed to in writing,
  48221. * software distributed under the License is distributed on an
  48222. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48223. * KIND, either express or implied. See the License for the
  48224. * specific language governing permissions and limitations
  48225. * under the License.
  48226. */
  48227. /**
  48228. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48229. */
  48230. /*
  48231. * Licensed to the Apache Software Foundation (ASF) under one
  48232. * or more contributor license agreements. See the NOTICE file
  48233. * distributed with this work for additional information
  48234. * regarding copyright ownership. The ASF licenses this file
  48235. * to you under the Apache License, Version 2.0 (the
  48236. * "License"); you may not use this file except in compliance
  48237. * with the License. You may obtain a copy of the License at
  48238. *
  48239. * http://www.apache.org/licenses/LICENSE-2.0
  48240. *
  48241. * Unless required by applicable law or agreed to in writing,
  48242. * software distributed under the License is distributed on an
  48243. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48244. * KIND, either express or implied. See the License for the
  48245. * specific language governing permissions and limitations
  48246. * under the License.
  48247. */
  48248. var axisBuilderAttrs$1 = ['axisLine', 'axisTickLabel', 'axisName'];
  48249. var RadarView$2 =
  48250. /** @class */
  48251. function (_super) {
  48252. __extends(RadarView, _super);
  48253. function RadarView() {
  48254. var _this = _super !== null && _super.apply(this, arguments) || this;
  48255. _this.type = RadarView.type;
  48256. return _this;
  48257. }
  48258. RadarView.prototype.render = function (radarModel, ecModel, api) {
  48259. var group = this.group;
  48260. group.removeAll();
  48261. this._buildAxes(radarModel);
  48262. this._buildSplitLineAndArea(radarModel);
  48263. };
  48264. RadarView.prototype._buildAxes = function (radarModel) {
  48265. var radar = radarModel.coordinateSystem;
  48266. var indicatorAxes = radar.getIndicatorAxes();
  48267. var axisBuilders = map(indicatorAxes, function (indicatorAxis) {
  48268. var axisBuilder = new AxisBuilder(indicatorAxis.model, {
  48269. position: [radar.cx, radar.cy],
  48270. rotation: indicatorAxis.angle,
  48271. labelDirection: -1,
  48272. tickDirection: -1,
  48273. nameDirection: 1
  48274. });
  48275. return axisBuilder;
  48276. });
  48277. each$1(axisBuilders, function (axisBuilder) {
  48278. each$1(axisBuilderAttrs$1, axisBuilder.add, axisBuilder);
  48279. this.group.add(axisBuilder.getGroup());
  48280. }, this);
  48281. };
  48282. RadarView.prototype._buildSplitLineAndArea = function (radarModel) {
  48283. var radar = radarModel.coordinateSystem;
  48284. var indicatorAxes = radar.getIndicatorAxes();
  48285. if (!indicatorAxes.length) {
  48286. return;
  48287. }
  48288. var shape = radarModel.get('shape');
  48289. var splitLineModel = radarModel.getModel('splitLine');
  48290. var splitAreaModel = radarModel.getModel('splitArea');
  48291. var lineStyleModel = splitLineModel.getModel('lineStyle');
  48292. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  48293. var showSplitLine = splitLineModel.get('show');
  48294. var showSplitArea = splitAreaModel.get('show');
  48295. var splitLineColors = lineStyleModel.get('color');
  48296. var splitAreaColors = areaStyleModel.get('color');
  48297. var splitLineColorsArr = isArray(splitLineColors) ? splitLineColors : [splitLineColors];
  48298. var splitAreaColorsArr = isArray(splitAreaColors) ? splitAreaColors : [splitAreaColors];
  48299. var splitLines = [];
  48300. var splitAreas = [];
  48301. function getColorIndex(areaOrLine, areaOrLineColorList, idx) {
  48302. var colorIndex = idx % areaOrLineColorList.length;
  48303. areaOrLine[colorIndex] = areaOrLine[colorIndex] || [];
  48304. return colorIndex;
  48305. }
  48306. if (shape === 'circle') {
  48307. var ticksRadius = indicatorAxes[0].getTicksCoords();
  48308. var cx = radar.cx;
  48309. var cy = radar.cy;
  48310. for (var i = 0; i < ticksRadius.length; i++) {
  48311. if (showSplitLine) {
  48312. var colorIndex = getColorIndex(splitLines, splitLineColorsArr, i);
  48313. splitLines[colorIndex].push(new Circle({
  48314. shape: {
  48315. cx: cx,
  48316. cy: cy,
  48317. r: ticksRadius[i].coord
  48318. }
  48319. }));
  48320. }
  48321. if (showSplitArea && i < ticksRadius.length - 1) {
  48322. var colorIndex = getColorIndex(splitAreas, splitAreaColorsArr, i);
  48323. splitAreas[colorIndex].push(new Ring({
  48324. shape: {
  48325. cx: cx,
  48326. cy: cy,
  48327. r0: ticksRadius[i].coord,
  48328. r: ticksRadius[i + 1].coord
  48329. }
  48330. }));
  48331. }
  48332. }
  48333. } // Polyyon
  48334. else {
  48335. var realSplitNumber_1;
  48336. var axesTicksPoints = map(indicatorAxes, function (indicatorAxis, idx) {
  48337. var ticksCoords = indicatorAxis.getTicksCoords();
  48338. realSplitNumber_1 = realSplitNumber_1 == null ? ticksCoords.length - 1 : Math.min(ticksCoords.length - 1, realSplitNumber_1);
  48339. return map(ticksCoords, function (tickCoord) {
  48340. return radar.coordToPoint(tickCoord.coord, idx);
  48341. });
  48342. });
  48343. var prevPoints = [];
  48344. for (var i = 0; i <= realSplitNumber_1; i++) {
  48345. var points = [];
  48346. for (var j = 0; j < indicatorAxes.length; j++) {
  48347. points.push(axesTicksPoints[j][i]);
  48348. } // Close
  48349. if (points[0]) {
  48350. points.push(points[0].slice());
  48351. } else {
  48352. {
  48353. console.error('Can\'t draw value axis ' + i);
  48354. }
  48355. }
  48356. if (showSplitLine) {
  48357. var colorIndex = getColorIndex(splitLines, splitLineColorsArr, i);
  48358. splitLines[colorIndex].push(new Polyline({
  48359. shape: {
  48360. points: points
  48361. }
  48362. }));
  48363. }
  48364. if (showSplitArea && prevPoints) {
  48365. var colorIndex = getColorIndex(splitAreas, splitAreaColorsArr, i - 1);
  48366. splitAreas[colorIndex].push(new Polygon({
  48367. shape: {
  48368. points: points.concat(prevPoints)
  48369. }
  48370. }));
  48371. }
  48372. prevPoints = points.slice().reverse();
  48373. }
  48374. }
  48375. var lineStyle = lineStyleModel.getLineStyle();
  48376. var areaStyle = areaStyleModel.getAreaStyle(); // Add splitArea before splitLine
  48377. each$1(splitAreas, function (splitAreas, idx) {
  48378. this.group.add(mergePath(splitAreas, {
  48379. style: defaults({
  48380. stroke: 'none',
  48381. fill: splitAreaColorsArr[idx % splitAreaColorsArr.length]
  48382. }, areaStyle),
  48383. silent: true
  48384. }));
  48385. }, this);
  48386. each$1(splitLines, function (splitLines, idx) {
  48387. this.group.add(mergePath(splitLines, {
  48388. style: defaults({
  48389. fill: 'none',
  48390. stroke: splitLineColorsArr[idx % splitLineColorsArr.length]
  48391. }, lineStyle),
  48392. silent: true
  48393. }));
  48394. }, this);
  48395. };
  48396. RadarView.type = 'radar';
  48397. return RadarView;
  48398. }(ComponentView);
  48399. /*
  48400. * Licensed to the Apache Software Foundation (ASF) under one
  48401. * or more contributor license agreements. See the NOTICE file
  48402. * distributed with this work for additional information
  48403. * regarding copyright ownership. The ASF licenses this file
  48404. * to you under the Apache License, Version 2.0 (the
  48405. * "License"); you may not use this file except in compliance
  48406. * with the License. You may obtain a copy of the License at
  48407. *
  48408. * http://www.apache.org/licenses/LICENSE-2.0
  48409. *
  48410. * Unless required by applicable law or agreed to in writing,
  48411. * software distributed under the License is distributed on an
  48412. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48413. * KIND, either express or implied. See the License for the
  48414. * specific language governing permissions and limitations
  48415. * under the License.
  48416. */
  48417. /**
  48418. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48419. */
  48420. /*
  48421. * Licensed to the Apache Software Foundation (ASF) under one
  48422. * or more contributor license agreements. See the NOTICE file
  48423. * distributed with this work for additional information
  48424. * regarding copyright ownership. The ASF licenses this file
  48425. * to you under the Apache License, Version 2.0 (the
  48426. * "License"); you may not use this file except in compliance
  48427. * with the License. You may obtain a copy of the License at
  48428. *
  48429. * http://www.apache.org/licenses/LICENSE-2.0
  48430. *
  48431. * Unless required by applicable law or agreed to in writing,
  48432. * software distributed under the License is distributed on an
  48433. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48434. * KIND, either express or implied. See the License for the
  48435. * specific language governing permissions and limitations
  48436. * under the License.
  48437. */
  48438. var IndicatorAxis =
  48439. /** @class */
  48440. function (_super) {
  48441. __extends(IndicatorAxis, _super);
  48442. function IndicatorAxis(dim, scale, radiusExtent) {
  48443. var _this = _super.call(this, dim, scale, radiusExtent) || this;
  48444. _this.type = 'value';
  48445. _this.angle = 0;
  48446. _this.name = '';
  48447. return _this;
  48448. }
  48449. return IndicatorAxis;
  48450. }(Axis);
  48451. /*
  48452. * Licensed to the Apache Software Foundation (ASF) under one
  48453. * or more contributor license agreements. See the NOTICE file
  48454. * distributed with this work for additional information
  48455. * regarding copyright ownership. The ASF licenses this file
  48456. * to you under the Apache License, Version 2.0 (the
  48457. * "License"); you may not use this file except in compliance
  48458. * with the License. You may obtain a copy of the License at
  48459. *
  48460. * http://www.apache.org/licenses/LICENSE-2.0
  48461. *
  48462. * Unless required by applicable law or agreed to in writing,
  48463. * software distributed under the License is distributed on an
  48464. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48465. * KIND, either express or implied. See the License for the
  48466. * specific language governing permissions and limitations
  48467. * under the License.
  48468. */
  48469. /**
  48470. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48471. */
  48472. /*
  48473. * Licensed to the Apache Software Foundation (ASF) under one
  48474. * or more contributor license agreements. See the NOTICE file
  48475. * distributed with this work for additional information
  48476. * regarding copyright ownership. The ASF licenses this file
  48477. * to you under the Apache License, Version 2.0 (the
  48478. * "License"); you may not use this file except in compliance
  48479. * with the License. You may obtain a copy of the License at
  48480. *
  48481. * http://www.apache.org/licenses/LICENSE-2.0
  48482. *
  48483. * Unless required by applicable law or agreed to in writing,
  48484. * software distributed under the License is distributed on an
  48485. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48486. * KIND, either express or implied. See the License for the
  48487. * specific language governing permissions and limitations
  48488. * under the License.
  48489. */
  48490. // TODO clockwise
  48491. var Radar =
  48492. /** @class */
  48493. function () {
  48494. function Radar(radarModel, ecModel, api) {
  48495. /**
  48496. *
  48497. * Radar dimensions
  48498. */
  48499. this.dimensions = [];
  48500. this._model = radarModel;
  48501. this._indicatorAxes = map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {
  48502. var dim = 'indicator_' + idx;
  48503. var indicatorAxis = new IndicatorAxis(dim, new IntervalScale() // (indicatorModel.get('axisType') === 'log') ? new LogScale() : new IntervalScale()
  48504. );
  48505. indicatorAxis.name = indicatorModel.get('name'); // Inject model and axis
  48506. indicatorAxis.model = indicatorModel;
  48507. indicatorModel.axis = indicatorAxis;
  48508. this.dimensions.push(dim);
  48509. return indicatorAxis;
  48510. }, this);
  48511. this.resize(radarModel, api);
  48512. }
  48513. Radar.prototype.getIndicatorAxes = function () {
  48514. return this._indicatorAxes;
  48515. };
  48516. Radar.prototype.dataToPoint = function (value, indicatorIndex) {
  48517. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  48518. return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);
  48519. }; // TODO: API should be coordToPoint([coord, indicatorIndex])
  48520. Radar.prototype.coordToPoint = function (coord, indicatorIndex) {
  48521. var indicatorAxis = this._indicatorAxes[indicatorIndex];
  48522. var angle = indicatorAxis.angle;
  48523. var x = this.cx + coord * Math.cos(angle);
  48524. var y = this.cy - coord * Math.sin(angle);
  48525. return [x, y];
  48526. };
  48527. Radar.prototype.pointToData = function (pt) {
  48528. var dx = pt[0] - this.cx;
  48529. var dy = pt[1] - this.cy;
  48530. var radius = Math.sqrt(dx * dx + dy * dy);
  48531. dx /= radius;
  48532. dy /= radius;
  48533. var radian = Math.atan2(-dy, dx); // Find the closest angle
  48534. // FIXME index can calculated directly
  48535. var minRadianDiff = Infinity;
  48536. var closestAxis;
  48537. var closestAxisIdx = -1;
  48538. for (var i = 0; i < this._indicatorAxes.length; i++) {
  48539. var indicatorAxis = this._indicatorAxes[i];
  48540. var diff = Math.abs(radian - indicatorAxis.angle);
  48541. if (diff < minRadianDiff) {
  48542. closestAxis = indicatorAxis;
  48543. closestAxisIdx = i;
  48544. minRadianDiff = diff;
  48545. }
  48546. }
  48547. return [closestAxisIdx, +(closestAxis && closestAxis.coordToData(radius))];
  48548. };
  48549. Radar.prototype.resize = function (radarModel, api) {
  48550. var center = radarModel.get('center');
  48551. var viewWidth = api.getWidth();
  48552. var viewHeight = api.getHeight();
  48553. var viewSize = Math.min(viewWidth, viewHeight) / 2;
  48554. this.cx = parsePercent$1(center[0], viewWidth);
  48555. this.cy = parsePercent$1(center[1], viewHeight);
  48556. this.startAngle = radarModel.get('startAngle') * Math.PI / 180; // radius may be single value like `20`, `'80%'`, or array like `[10, '80%']`
  48557. var radius = radarModel.get('radius');
  48558. if (typeof radius === 'string' || typeof radius === 'number') {
  48559. radius = [0, radius];
  48560. }
  48561. this.r0 = parsePercent$1(radius[0], viewSize);
  48562. this.r = parsePercent$1(radius[1], viewSize);
  48563. each$1(this._indicatorAxes, function (indicatorAxis, idx) {
  48564. indicatorAxis.setExtent(this.r0, this.r);
  48565. var angle = this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length; // Normalize to [-PI, PI]
  48566. angle = Math.atan2(Math.sin(angle), Math.cos(angle));
  48567. indicatorAxis.angle = angle;
  48568. }, this);
  48569. };
  48570. Radar.prototype.update = function (ecModel, api) {
  48571. var indicatorAxes = this._indicatorAxes;
  48572. var radarModel = this._model;
  48573. each$1(indicatorAxes, function (indicatorAxis) {
  48574. indicatorAxis.scale.setExtent(Infinity, -Infinity);
  48575. });
  48576. ecModel.eachSeriesByType('radar', function (radarSeries, idx) {
  48577. if (radarSeries.get('coordinateSystem') !== 'radar' // @ts-ignore
  48578. || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel) {
  48579. return;
  48580. }
  48581. var data = radarSeries.getData();
  48582. each$1(indicatorAxes, function (indicatorAxis) {
  48583. indicatorAxis.scale.unionExtentFromData(data, data.mapDimension(indicatorAxis.dim));
  48584. });
  48585. }, this);
  48586. var splitNumber = radarModel.get('splitNumber');
  48587. function increaseInterval(interval) {
  48588. var exp10 = Math.pow(10, Math.floor(Math.log(interval) / Math.LN10)); // Increase interval
  48589. var f = interval / exp10;
  48590. if (f === 2) {
  48591. f = 5;
  48592. } else {
  48593. // f is 2 or 5
  48594. f *= 2;
  48595. }
  48596. return f * exp10;
  48597. } // Force all the axis fixing the maxSplitNumber.
  48598. each$1(indicatorAxes, function (indicatorAxis, idx) {
  48599. var rawExtent = getScaleExtent(indicatorAxis.scale, indicatorAxis.model).extent;
  48600. niceScaleExtent(indicatorAxis.scale, indicatorAxis.model);
  48601. var axisModel = indicatorAxis.model;
  48602. var scale = indicatorAxis.scale;
  48603. var fixedMin = parseAxisModelMinMax(scale, axisModel.get('min', true));
  48604. var fixedMax = parseAxisModelMinMax(scale, axisModel.get('max', true));
  48605. var interval = scale.getInterval();
  48606. if (fixedMin != null && fixedMax != null) {
  48607. // User set min, max, divide to get new interval
  48608. scale.setExtent(+fixedMin, +fixedMax);
  48609. scale.setInterval((fixedMax - fixedMin) / splitNumber);
  48610. } else if (fixedMin != null) {
  48611. var max = void 0; // User set min, expand extent on the other side
  48612. do {
  48613. max = fixedMin + interval * splitNumber;
  48614. scale.setExtent(+fixedMin, max); // Interval must been set after extent
  48615. // FIXME
  48616. scale.setInterval(interval);
  48617. interval = increaseInterval(interval);
  48618. } while (max < rawExtent[1] && isFinite(max) && isFinite(rawExtent[1]));
  48619. } else if (fixedMax != null) {
  48620. var min = void 0; // User set min, expand extent on the other side
  48621. do {
  48622. min = fixedMax - interval * splitNumber;
  48623. scale.setExtent(min, +fixedMax);
  48624. scale.setInterval(interval);
  48625. interval = increaseInterval(interval);
  48626. } while (min > rawExtent[0] && isFinite(min) && isFinite(rawExtent[0]));
  48627. } else {
  48628. var nicedSplitNumber = scale.getTicks().length - 1;
  48629. if (nicedSplitNumber > splitNumber) {
  48630. interval = increaseInterval(interval);
  48631. } // TODO
  48632. var max = Math.ceil(rawExtent[1] / interval) * interval;
  48633. var min = round(max - interval * splitNumber);
  48634. scale.setExtent(min, max);
  48635. scale.setInterval(interval);
  48636. }
  48637. });
  48638. };
  48639. Radar.prototype.convertToPixel = function (ecModel, finder, value) {
  48640. console.warn('Not implemented.');
  48641. return null;
  48642. };
  48643. Radar.prototype.convertFromPixel = function (ecModel, finder, pixel) {
  48644. console.warn('Not implemented.');
  48645. return null;
  48646. };
  48647. Radar.prototype.containPoint = function (point) {
  48648. console.warn('Not implemented.');
  48649. return false;
  48650. };
  48651. Radar.create = function (ecModel, api) {
  48652. var radarList = [];
  48653. ecModel.eachComponent('radar', function (radarModel) {
  48654. var radar = new Radar(radarModel, ecModel, api);
  48655. radarList.push(radar);
  48656. radarModel.coordinateSystem = radar;
  48657. });
  48658. ecModel.eachSeriesByType('radar', function (radarSeries) {
  48659. if (radarSeries.get('coordinateSystem') === 'radar') {
  48660. // Inject coordinate system
  48661. // @ts-ignore
  48662. radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];
  48663. }
  48664. });
  48665. return radarList;
  48666. };
  48667. /**
  48668. * Radar dimensions is based on the data
  48669. */
  48670. Radar.dimensions = [];
  48671. return Radar;
  48672. }();
  48673. /*
  48674. * Licensed to the Apache Software Foundation (ASF) under one
  48675. * or more contributor license agreements. See the NOTICE file
  48676. * distributed with this work for additional information
  48677. * regarding copyright ownership. The ASF licenses this file
  48678. * to you under the Apache License, Version 2.0 (the
  48679. * "License"); you may not use this file except in compliance
  48680. * with the License. You may obtain a copy of the License at
  48681. *
  48682. * http://www.apache.org/licenses/LICENSE-2.0
  48683. *
  48684. * Unless required by applicable law or agreed to in writing,
  48685. * software distributed under the License is distributed on an
  48686. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48687. * KIND, either express or implied. See the License for the
  48688. * specific language governing permissions and limitations
  48689. * under the License.
  48690. */
  48691. /**
  48692. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48693. */
  48694. /*
  48695. * Licensed to the Apache Software Foundation (ASF) under one
  48696. * or more contributor license agreements. See the NOTICE file
  48697. * distributed with this work for additional information
  48698. * regarding copyright ownership. The ASF licenses this file
  48699. * to you under the Apache License, Version 2.0 (the
  48700. * "License"); you may not use this file except in compliance
  48701. * with the License. You may obtain a copy of the License at
  48702. *
  48703. * http://www.apache.org/licenses/LICENSE-2.0
  48704. *
  48705. * Unless required by applicable law or agreed to in writing,
  48706. * software distributed under the License is distributed on an
  48707. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48708. * KIND, either express or implied. See the License for the
  48709. * specific language governing permissions and limitations
  48710. * under the License.
  48711. */
  48712. function install$10(registers) {
  48713. registers.registerCoordinateSystem('radar', Radar);
  48714. registers.registerComponentModel(RadarModel);
  48715. registers.registerComponentView(RadarView$2);
  48716. registers.registerVisual({
  48717. seriesType: 'radar',
  48718. reset: function (seriesModel) {
  48719. var data = seriesModel.getData(); // itemVisual symbol is for selected data
  48720. data.each(function (idx) {
  48721. data.setItemVisual(idx, 'legendSymbol', 'roundRect');
  48722. }); // visual is for unselected data
  48723. data.setVisual('legendSymbol', 'roundRect');
  48724. }
  48725. });
  48726. }
  48727. /*
  48728. * Licensed to the Apache Software Foundation (ASF) under one
  48729. * or more contributor license agreements. See the NOTICE file
  48730. * distributed with this work for additional information
  48731. * regarding copyright ownership. The ASF licenses this file
  48732. * to you under the Apache License, Version 2.0 (the
  48733. * "License"); you may not use this file except in compliance
  48734. * with the License. You may obtain a copy of the License at
  48735. *
  48736. * http://www.apache.org/licenses/LICENSE-2.0
  48737. *
  48738. * Unless required by applicable law or agreed to in writing,
  48739. * software distributed under the License is distributed on an
  48740. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48741. * KIND, either express or implied. See the License for the
  48742. * specific language governing permissions and limitations
  48743. * under the License.
  48744. */
  48745. /**
  48746. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48747. */
  48748. /*
  48749. * Licensed to the Apache Software Foundation (ASF) under one
  48750. * or more contributor license agreements. See the NOTICE file
  48751. * distributed with this work for additional information
  48752. * regarding copyright ownership. The ASF licenses this file
  48753. * to you under the Apache License, Version 2.0 (the
  48754. * "License"); you may not use this file except in compliance
  48755. * with the License. You may obtain a copy of the License at
  48756. *
  48757. * http://www.apache.org/licenses/LICENSE-2.0
  48758. *
  48759. * Unless required by applicable law or agreed to in writing,
  48760. * software distributed under the License is distributed on an
  48761. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48762. * KIND, either express or implied. See the License for the
  48763. * specific language governing permissions and limitations
  48764. * under the License.
  48765. */
  48766. function install$9(registers) {
  48767. use(install$10);
  48768. registers.registerChartView(RadarView);
  48769. registers.registerSeriesModel(RadarSeriesModel);
  48770. registers.registerLayout(radarLayout);
  48771. registers.registerProcessor(dataFilter('radar'));
  48772. registers.registerPreprocessor(radarBackwardCompat);
  48773. }
  48774. /*
  48775. * Licensed to the Apache Software Foundation (ASF) under one
  48776. * or more contributor license agreements. See the NOTICE file
  48777. * distributed with this work for additional information
  48778. * regarding copyright ownership. The ASF licenses this file
  48779. * to you under the Apache License, Version 2.0 (the
  48780. * "License"); you may not use this file except in compliance
  48781. * with the License. You may obtain a copy of the License at
  48782. *
  48783. * http://www.apache.org/licenses/LICENSE-2.0
  48784. *
  48785. * Unless required by applicable law or agreed to in writing,
  48786. * software distributed under the License is distributed on an
  48787. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48788. * KIND, either express or implied. See the License for the
  48789. * specific language governing permissions and limitations
  48790. * under the License.
  48791. */
  48792. /**
  48793. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48794. */
  48795. /*
  48796. * Licensed to the Apache Software Foundation (ASF) under one
  48797. * or more contributor license agreements. See the NOTICE file
  48798. * distributed with this work for additional information
  48799. * regarding copyright ownership. The ASF licenses this file
  48800. * to you under the Apache License, Version 2.0 (the
  48801. * "License"); you may not use this file except in compliance
  48802. * with the License. You may obtain a copy of the License at
  48803. *
  48804. * http://www.apache.org/licenses/LICENSE-2.0
  48805. *
  48806. * Unless required by applicable law or agreed to in writing,
  48807. * software distributed under the License is distributed on an
  48808. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48809. * KIND, either express or implied. See the License for the
  48810. * specific language governing permissions and limitations
  48811. * under the License.
  48812. */
  48813. use(install$9);
  48814. /*
  48815. * Licensed to the Apache Software Foundation (ASF) under one
  48816. * or more contributor license agreements. See the NOTICE file
  48817. * distributed with this work for additional information
  48818. * regarding copyright ownership. The ASF licenses this file
  48819. * to you under the Apache License, Version 2.0 (the
  48820. * "License"); you may not use this file except in compliance
  48821. * with the License. You may obtain a copy of the License at
  48822. *
  48823. * http://www.apache.org/licenses/LICENSE-2.0
  48824. *
  48825. * Unless required by applicable law or agreed to in writing,
  48826. * software distributed under the License is distributed on an
  48827. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48828. * KIND, either express or implied. See the License for the
  48829. * specific language governing permissions and limitations
  48830. * under the License.
  48831. */
  48832. /**
  48833. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48834. */
  48835. /*
  48836. * Licensed to the Apache Software Foundation (ASF) under one
  48837. * or more contributor license agreements. See the NOTICE file
  48838. * distributed with this work for additional information
  48839. * regarding copyright ownership. The ASF licenses this file
  48840. * to you under the Apache License, Version 2.0 (the
  48841. * "License"); you may not use this file except in compliance
  48842. * with the License. You may obtain a copy of the License at
  48843. *
  48844. * http://www.apache.org/licenses/LICENSE-2.0
  48845. *
  48846. * Unless required by applicable law or agreed to in writing,
  48847. * software distributed under the License is distributed on an
  48848. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48849. * KIND, either express or implied. See the License for the
  48850. * specific language governing permissions and limitations
  48851. * under the License.
  48852. */
  48853. /* global Uint8ClampedArray */
  48854. var GRADIENT_LEVELS = 256;
  48855. var HeatmapLayer =
  48856. /** @class */
  48857. function () {
  48858. function HeatmapLayer() {
  48859. this.blurSize = 30;
  48860. this.pointSize = 20;
  48861. this.maxOpacity = 1;
  48862. this.minOpacity = 0;
  48863. this._gradientPixels = {
  48864. inRange: null,
  48865. outOfRange: null
  48866. };
  48867. var canvas = createCanvas();
  48868. this.canvas = canvas;
  48869. }
  48870. /**
  48871. * Renders Heatmap and returns the rendered canvas
  48872. * @param data array of data, each has x, y, value
  48873. * @param width canvas width
  48874. * @param height canvas height
  48875. */
  48876. HeatmapLayer.prototype.update = function (data, width, height, normalize, colorFunc, isInRange) {
  48877. var brush = this._getBrush();
  48878. var gradientInRange = this._getGradient(colorFunc, 'inRange');
  48879. var gradientOutOfRange = this._getGradient(colorFunc, 'outOfRange');
  48880. var r = this.pointSize + this.blurSize;
  48881. var canvas = this.canvas;
  48882. var ctx = canvas.getContext('2d');
  48883. var len = data.length;
  48884. canvas.width = width;
  48885. canvas.height = height;
  48886. for (var i = 0; i < len; ++i) {
  48887. var p = data[i];
  48888. var x = p[0];
  48889. var y = p[1];
  48890. var value = p[2]; // calculate alpha using value
  48891. var alpha = normalize(value); // draw with the circle brush with alpha
  48892. ctx.globalAlpha = alpha;
  48893. ctx.drawImage(brush, x - r, y - r);
  48894. }
  48895. if (!canvas.width || !canvas.height) {
  48896. // Avoid "Uncaught DOMException: Failed to execute 'getImageData' on
  48897. // 'CanvasRenderingContext2D': The source height is 0."
  48898. return canvas;
  48899. } // colorize the canvas using alpha value and set with gradient
  48900. var imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
  48901. var pixels = imageData.data;
  48902. var offset = 0;
  48903. var pixelLen = pixels.length;
  48904. var minOpacity = this.minOpacity;
  48905. var maxOpacity = this.maxOpacity;
  48906. var diffOpacity = maxOpacity - minOpacity;
  48907. while (offset < pixelLen) {
  48908. var alpha = pixels[offset + 3] / 256;
  48909. var gradientOffset = Math.floor(alpha * (GRADIENT_LEVELS - 1)) * 4; // Simple optimize to ignore the empty data
  48910. if (alpha > 0) {
  48911. var gradient = isInRange(alpha) ? gradientInRange : gradientOutOfRange; // Any alpha > 0 will be mapped to [minOpacity, maxOpacity]
  48912. alpha > 0 && (alpha = alpha * diffOpacity + minOpacity);
  48913. pixels[offset++] = gradient[gradientOffset];
  48914. pixels[offset++] = gradient[gradientOffset + 1];
  48915. pixels[offset++] = gradient[gradientOffset + 2];
  48916. pixels[offset++] = gradient[gradientOffset + 3] * alpha * 256;
  48917. } else {
  48918. offset += 4;
  48919. }
  48920. }
  48921. ctx.putImageData(imageData, 0, 0);
  48922. return canvas;
  48923. };
  48924. /**
  48925. * get canvas of a black circle brush used for canvas to draw later
  48926. */
  48927. HeatmapLayer.prototype._getBrush = function () {
  48928. var brushCanvas = this._brushCanvas || (this._brushCanvas = createCanvas()); // set brush size
  48929. var r = this.pointSize + this.blurSize;
  48930. var d = r * 2;
  48931. brushCanvas.width = d;
  48932. brushCanvas.height = d;
  48933. var ctx = brushCanvas.getContext('2d');
  48934. ctx.clearRect(0, 0, d, d); // in order to render shadow without the distinct circle,
  48935. // draw the distinct circle in an invisible place,
  48936. // and use shadowOffset to draw shadow in the center of the canvas
  48937. ctx.shadowOffsetX = d;
  48938. ctx.shadowBlur = this.blurSize; // draw the shadow in black, and use alpha and shadow blur to generate
  48939. // color in color map
  48940. ctx.shadowColor = '#000'; // draw circle in the left to the canvas
  48941. ctx.beginPath();
  48942. ctx.arc(-r, r, this.pointSize, 0, Math.PI * 2, true);
  48943. ctx.closePath();
  48944. ctx.fill();
  48945. return brushCanvas;
  48946. };
  48947. /**
  48948. * get gradient color map
  48949. * @private
  48950. */
  48951. HeatmapLayer.prototype._getGradient = function (colorFunc, state) {
  48952. var gradientPixels = this._gradientPixels;
  48953. var pixelsSingleState = gradientPixels[state] || (gradientPixels[state] = new Uint8ClampedArray(256 * 4));
  48954. var color = [0, 0, 0, 0];
  48955. var off = 0;
  48956. for (var i = 0; i < 256; i++) {
  48957. colorFunc[state](i / 255, true, color);
  48958. pixelsSingleState[off++] = color[0];
  48959. pixelsSingleState[off++] = color[1];
  48960. pixelsSingleState[off++] = color[2];
  48961. pixelsSingleState[off++] = color[3];
  48962. }
  48963. return pixelsSingleState;
  48964. };
  48965. return HeatmapLayer;
  48966. }();
  48967. /*
  48968. * Licensed to the Apache Software Foundation (ASF) under one
  48969. * or more contributor license agreements. See the NOTICE file
  48970. * distributed with this work for additional information
  48971. * regarding copyright ownership. The ASF licenses this file
  48972. * to you under the Apache License, Version 2.0 (the
  48973. * "License"); you may not use this file except in compliance
  48974. * with the License. You may obtain a copy of the License at
  48975. *
  48976. * http://www.apache.org/licenses/LICENSE-2.0
  48977. *
  48978. * Unless required by applicable law or agreed to in writing,
  48979. * software distributed under the License is distributed on an
  48980. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  48981. * KIND, either express or implied. See the License for the
  48982. * specific language governing permissions and limitations
  48983. * under the License.
  48984. */
  48985. /**
  48986. * AUTO-GENERATED FILE. DO NOT MODIFY.
  48987. */
  48988. /*
  48989. * Licensed to the Apache Software Foundation (ASF) under one
  48990. * or more contributor license agreements. See the NOTICE file
  48991. * distributed with this work for additional information
  48992. * regarding copyright ownership. The ASF licenses this file
  48993. * to you under the Apache License, Version 2.0 (the
  48994. * "License"); you may not use this file except in compliance
  48995. * with the License. You may obtain a copy of the License at
  48996. *
  48997. * http://www.apache.org/licenses/LICENSE-2.0
  48998. *
  48999. * Unless required by applicable law or agreed to in writing,
  49000. * software distributed under the License is distributed on an
  49001. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49002. * KIND, either express or implied. See the License for the
  49003. * specific language governing permissions and limitations
  49004. * under the License.
  49005. */
  49006. function getIsInPiecewiseRange(dataExtent, pieceList, selected) {
  49007. var dataSpan = dataExtent[1] - dataExtent[0];
  49008. pieceList = map(pieceList, function (piece) {
  49009. return {
  49010. interval: [(piece.interval[0] - dataExtent[0]) / dataSpan, (piece.interval[1] - dataExtent[0]) / dataSpan]
  49011. };
  49012. });
  49013. var len = pieceList.length;
  49014. var lastIndex = 0;
  49015. return function (val) {
  49016. var i; // Try to find in the location of the last found
  49017. for (i = lastIndex; i < len; i++) {
  49018. var interval = pieceList[i].interval;
  49019. if (interval[0] <= val && val <= interval[1]) {
  49020. lastIndex = i;
  49021. break;
  49022. }
  49023. }
  49024. if (i === len) {
  49025. // Not found, back interation
  49026. for (i = lastIndex - 1; i >= 0; i--) {
  49027. var interval = pieceList[i].interval;
  49028. if (interval[0] <= val && val <= interval[1]) {
  49029. lastIndex = i;
  49030. break;
  49031. }
  49032. }
  49033. }
  49034. return i >= 0 && i < len && selected[i];
  49035. };
  49036. }
  49037. function getIsInContinuousRange(dataExtent, range) {
  49038. var dataSpan = dataExtent[1] - dataExtent[0];
  49039. range = [(range[0] - dataExtent[0]) / dataSpan, (range[1] - dataExtent[0]) / dataSpan];
  49040. return function (val) {
  49041. return val >= range[0] && val <= range[1];
  49042. };
  49043. }
  49044. function isGeoCoordSys(coordSys) {
  49045. var dimensions = coordSys.dimensions; // Not use coorSys.type === 'geo' because coordSys maybe extended
  49046. return dimensions[0] === 'lng' && dimensions[1] === 'lat';
  49047. }
  49048. var HeatmapView =
  49049. /** @class */
  49050. function (_super) {
  49051. __extends(HeatmapView, _super);
  49052. function HeatmapView() {
  49053. var _this = _super !== null && _super.apply(this, arguments) || this;
  49054. _this.type = HeatmapView.type;
  49055. return _this;
  49056. }
  49057. HeatmapView.prototype.render = function (seriesModel, ecModel, api) {
  49058. var visualMapOfThisSeries;
  49059. ecModel.eachComponent('visualMap', function (visualMap) {
  49060. visualMap.eachTargetSeries(function (targetSeries) {
  49061. if (targetSeries === seriesModel) {
  49062. visualMapOfThisSeries = visualMap;
  49063. }
  49064. });
  49065. });
  49066. {
  49067. if (!visualMapOfThisSeries) {
  49068. throw new Error('Heatmap must use with visualMap');
  49069. }
  49070. }
  49071. this.group.removeAll();
  49072. this._incrementalDisplayable = null;
  49073. var coordSys = seriesModel.coordinateSystem;
  49074. if (coordSys.type === 'cartesian2d' || coordSys.type === 'calendar') {
  49075. this._renderOnCartesianAndCalendar(seriesModel, api, 0, seriesModel.getData().count());
  49076. } else if (isGeoCoordSys(coordSys)) {
  49077. this._renderOnGeo(coordSys, seriesModel, visualMapOfThisSeries, api);
  49078. }
  49079. };
  49080. HeatmapView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
  49081. this.group.removeAll();
  49082. };
  49083. HeatmapView.prototype.incrementalRender = function (params, seriesModel, ecModel, api) {
  49084. var coordSys = seriesModel.coordinateSystem;
  49085. if (coordSys) {
  49086. // geo does not support incremental rendering?
  49087. if (isGeoCoordSys(coordSys)) {
  49088. this.render(seriesModel, ecModel, api);
  49089. } else {
  49090. this._renderOnCartesianAndCalendar(seriesModel, api, params.start, params.end, true);
  49091. }
  49092. }
  49093. };
  49094. HeatmapView.prototype._renderOnCartesianAndCalendar = function (seriesModel, api, start, end, incremental) {
  49095. var coordSys = seriesModel.coordinateSystem;
  49096. var width;
  49097. var height;
  49098. var xAxisExtent;
  49099. var yAxisExtent;
  49100. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  49101. var xAxis = coordSys.getAxis('x');
  49102. var yAxis = coordSys.getAxis('y');
  49103. {
  49104. if (!(xAxis.type === 'category' && yAxis.type === 'category')) {
  49105. throw new Error('Heatmap on cartesian must have two category axes');
  49106. }
  49107. if (!(xAxis.onBand && yAxis.onBand)) {
  49108. throw new Error('Heatmap on cartesian must have two axes with boundaryGap true');
  49109. }
  49110. }
  49111. width = xAxis.getBandWidth();
  49112. height = yAxis.getBandWidth();
  49113. xAxisExtent = xAxis.scale.getExtent();
  49114. yAxisExtent = yAxis.scale.getExtent();
  49115. }
  49116. var group = this.group;
  49117. var data = seriesModel.getData();
  49118. var emphasisStyle = seriesModel.getModel(['emphasis', 'itemStyle']).getItemStyle();
  49119. var blurStyle = seriesModel.getModel(['blur', 'itemStyle']).getItemStyle();
  49120. var selectStyle = seriesModel.getModel(['select', 'itemStyle']).getItemStyle();
  49121. var labelStatesModels = getLabelStatesModels(seriesModel);
  49122. var focus = seriesModel.get(['emphasis', 'focus']);
  49123. var blurScope = seriesModel.get(['emphasis', 'blurScope']);
  49124. var dataDims = isCoordinateSystemType(coordSys, 'cartesian2d') ? [data.mapDimension('x'), data.mapDimension('y'), data.mapDimension('value')] : [data.mapDimension('time'), data.mapDimension('value')];
  49125. for (var idx = start; idx < end; idx++) {
  49126. var rect = void 0;
  49127. var style = data.getItemVisual(idx, 'style');
  49128. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  49129. var dataDimX = data.get(dataDims[0], idx);
  49130. var dataDimY = data.get(dataDims[1], idx); // Ignore empty data and out of extent data
  49131. if (isNaN(data.get(dataDims[2], idx)) || dataDimX < xAxisExtent[0] || dataDimX > xAxisExtent[1] || dataDimY < yAxisExtent[0] || dataDimY > yAxisExtent[1]) {
  49132. continue;
  49133. }
  49134. var point = coordSys.dataToPoint([dataDimX, dataDimY]);
  49135. rect = new Rect({
  49136. shape: {
  49137. x: Math.floor(Math.round(point[0]) - width / 2),
  49138. y: Math.floor(Math.round(point[1]) - height / 2),
  49139. width: Math.ceil(width),
  49140. height: Math.ceil(height)
  49141. },
  49142. style: style
  49143. });
  49144. } else {
  49145. // Ignore empty data
  49146. if (isNaN(data.get(dataDims[1], idx))) {
  49147. continue;
  49148. }
  49149. rect = new Rect({
  49150. z2: 1,
  49151. shape: coordSys.dataToRect([data.get(dataDims[0], idx)]).contentShape,
  49152. style: style
  49153. });
  49154. }
  49155. var itemModel = data.getItemModel(idx); // Optimization for large datset
  49156. if (data.hasItemOption) {
  49157. var emphasisModel = itemModel.getModel('emphasis');
  49158. emphasisStyle = emphasisModel.getModel('itemStyle').getItemStyle();
  49159. blurStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
  49160. selectStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();
  49161. focus = emphasisModel.get('focus');
  49162. blurScope = emphasisModel.get('blurScope');
  49163. labelStatesModels = getLabelStatesModels(itemModel);
  49164. }
  49165. var rawValue = seriesModel.getRawValue(idx);
  49166. var defaultText = '-';
  49167. if (rawValue && rawValue[2] != null) {
  49168. defaultText = rawValue[2] + '';
  49169. }
  49170. setLabelStyle(rect, labelStatesModels, {
  49171. labelFetcher: seriesModel,
  49172. labelDataIndex: idx,
  49173. defaultOpacity: style.opacity,
  49174. defaultText: defaultText
  49175. });
  49176. rect.ensureState('emphasis').style = emphasisStyle;
  49177. rect.ensureState('blur').style = blurStyle;
  49178. rect.ensureState('select').style = selectStyle;
  49179. enableHoverEmphasis(rect, focus, blurScope);
  49180. rect.incremental = incremental; // PENDING
  49181. if (incremental) {
  49182. // Rect must use hover layer if it's incremental.
  49183. rect.states.emphasis.hoverLayer = true;
  49184. }
  49185. group.add(rect);
  49186. data.setItemGraphicEl(idx, rect);
  49187. }
  49188. };
  49189. HeatmapView.prototype._renderOnGeo = function (geo, seriesModel, visualMapModel, api) {
  49190. var inRangeVisuals = visualMapModel.targetVisuals.inRange;
  49191. var outOfRangeVisuals = visualMapModel.targetVisuals.outOfRange; // if (!visualMapping) {
  49192. // throw new Error('Data range must have color visuals');
  49193. // }
  49194. var data = seriesModel.getData();
  49195. var hmLayer = this._hmLayer || this._hmLayer || new HeatmapLayer();
  49196. hmLayer.blurSize = seriesModel.get('blurSize');
  49197. hmLayer.pointSize = seriesModel.get('pointSize');
  49198. hmLayer.minOpacity = seriesModel.get('minOpacity');
  49199. hmLayer.maxOpacity = seriesModel.get('maxOpacity');
  49200. var rect = geo.getViewRect().clone();
  49201. var roamTransform = geo.getRoamTransform();
  49202. rect.applyTransform(roamTransform); // Clamp on viewport
  49203. var x = Math.max(rect.x, 0);
  49204. var y = Math.max(rect.y, 0);
  49205. var x2 = Math.min(rect.width + rect.x, api.getWidth());
  49206. var y2 = Math.min(rect.height + rect.y, api.getHeight());
  49207. var width = x2 - x;
  49208. var height = y2 - y;
  49209. var dims = [data.mapDimension('lng'), data.mapDimension('lat'), data.mapDimension('value')];
  49210. var points = data.mapArray(dims, function (lng, lat, value) {
  49211. var pt = geo.dataToPoint([lng, lat]);
  49212. pt[0] -= x;
  49213. pt[1] -= y;
  49214. pt.push(value);
  49215. return pt;
  49216. });
  49217. var dataExtent = visualMapModel.getExtent();
  49218. var isInRange = visualMapModel.type === 'visualMap.continuous' ? getIsInContinuousRange(dataExtent, visualMapModel.option.range) : getIsInPiecewiseRange(dataExtent, visualMapModel.getPieceList(), visualMapModel.option.selected);
  49219. hmLayer.update(points, width, height, inRangeVisuals.color.getNormalizer(), {
  49220. inRange: inRangeVisuals.color.getColorMapper(),
  49221. outOfRange: outOfRangeVisuals.color.getColorMapper()
  49222. }, isInRange);
  49223. var img = new ZRImage({
  49224. style: {
  49225. width: width,
  49226. height: height,
  49227. x: x,
  49228. y: y,
  49229. image: hmLayer.canvas
  49230. },
  49231. silent: true
  49232. });
  49233. this.group.add(img);
  49234. };
  49235. HeatmapView.type = 'heatmap';
  49236. return HeatmapView;
  49237. }(ChartView);
  49238. /*
  49239. * Licensed to the Apache Software Foundation (ASF) under one
  49240. * or more contributor license agreements. See the NOTICE file
  49241. * distributed with this work for additional information
  49242. * regarding copyright ownership. The ASF licenses this file
  49243. * to you under the Apache License, Version 2.0 (the
  49244. * "License"); you may not use this file except in compliance
  49245. * with the License. You may obtain a copy of the License at
  49246. *
  49247. * http://www.apache.org/licenses/LICENSE-2.0
  49248. *
  49249. * Unless required by applicable law or agreed to in writing,
  49250. * software distributed under the License is distributed on an
  49251. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49252. * KIND, either express or implied. See the License for the
  49253. * specific language governing permissions and limitations
  49254. * under the License.
  49255. */
  49256. /**
  49257. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49258. */
  49259. /*
  49260. * Licensed to the Apache Software Foundation (ASF) under one
  49261. * or more contributor license agreements. See the NOTICE file
  49262. * distributed with this work for additional information
  49263. * regarding copyright ownership. The ASF licenses this file
  49264. * to you under the Apache License, Version 2.0 (the
  49265. * "License"); you may not use this file except in compliance
  49266. * with the License. You may obtain a copy of the License at
  49267. *
  49268. * http://www.apache.org/licenses/LICENSE-2.0
  49269. *
  49270. * Unless required by applicable law or agreed to in writing,
  49271. * software distributed under the License is distributed on an
  49272. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49273. * KIND, either express or implied. See the License for the
  49274. * specific language governing permissions and limitations
  49275. * under the License.
  49276. */
  49277. var HeatmapSeriesModel =
  49278. /** @class */
  49279. function (_super) {
  49280. __extends(HeatmapSeriesModel, _super);
  49281. function HeatmapSeriesModel() {
  49282. var _this = _super !== null && _super.apply(this, arguments) || this;
  49283. _this.type = HeatmapSeriesModel.type;
  49284. return _this;
  49285. }
  49286. HeatmapSeriesModel.prototype.getInitialData = function (option, ecModel) {
  49287. return createListFromArray(this.getSource(), this, {
  49288. generateCoord: 'value'
  49289. });
  49290. };
  49291. HeatmapSeriesModel.prototype.preventIncremental = function () {
  49292. var coordSysCreator = CoordinateSystemManager.get(this.get('coordinateSystem'));
  49293. if (coordSysCreator && coordSysCreator.dimensions) {
  49294. return coordSysCreator.dimensions[0] === 'lng' && coordSysCreator.dimensions[1] === 'lat';
  49295. }
  49296. };
  49297. HeatmapSeriesModel.type = 'series.heatmap';
  49298. HeatmapSeriesModel.dependencies = ['grid', 'geo', 'calendar'];
  49299. HeatmapSeriesModel.defaultOption = {
  49300. coordinateSystem: 'cartesian2d',
  49301. zlevel: 0,
  49302. z: 2,
  49303. // Cartesian coordinate system
  49304. // xAxisIndex: 0,
  49305. // yAxisIndex: 0,
  49306. // Geo coordinate system
  49307. geoIndex: 0,
  49308. blurSize: 30,
  49309. pointSize: 20,
  49310. maxOpacity: 1,
  49311. minOpacity: 0,
  49312. select: {
  49313. itemStyle: {
  49314. borderColor: '#212121'
  49315. }
  49316. }
  49317. };
  49318. return HeatmapSeriesModel;
  49319. }(SeriesModel);
  49320. /*
  49321. * Licensed to the Apache Software Foundation (ASF) under one
  49322. * or more contributor license agreements. See the NOTICE file
  49323. * distributed with this work for additional information
  49324. * regarding copyright ownership. The ASF licenses this file
  49325. * to you under the Apache License, Version 2.0 (the
  49326. * "License"); you may not use this file except in compliance
  49327. * with the License. You may obtain a copy of the License at
  49328. *
  49329. * http://www.apache.org/licenses/LICENSE-2.0
  49330. *
  49331. * Unless required by applicable law or agreed to in writing,
  49332. * software distributed under the License is distributed on an
  49333. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49334. * KIND, either express or implied. See the License for the
  49335. * specific language governing permissions and limitations
  49336. * under the License.
  49337. */
  49338. /**
  49339. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49340. */
  49341. /*
  49342. * Licensed to the Apache Software Foundation (ASF) under one
  49343. * or more contributor license agreements. See the NOTICE file
  49344. * distributed with this work for additional information
  49345. * regarding copyright ownership. The ASF licenses this file
  49346. * to you under the Apache License, Version 2.0 (the
  49347. * "License"); you may not use this file except in compliance
  49348. * with the License. You may obtain a copy of the License at
  49349. *
  49350. * http://www.apache.org/licenses/LICENSE-2.0
  49351. *
  49352. * Unless required by applicable law or agreed to in writing,
  49353. * software distributed under the License is distributed on an
  49354. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49355. * KIND, either express or implied. See the License for the
  49356. * specific language governing permissions and limitations
  49357. * under the License.
  49358. */
  49359. function install$11(registers) {
  49360. registers.registerChartView(HeatmapView);
  49361. registers.registerSeriesModel(HeatmapSeriesModel);
  49362. }
  49363. /*
  49364. * Licensed to the Apache Software Foundation (ASF) under one
  49365. * or more contributor license agreements. See the NOTICE file
  49366. * distributed with this work for additional information
  49367. * regarding copyright ownership. The ASF licenses this file
  49368. * to you under the Apache License, Version 2.0 (the
  49369. * "License"); you may not use this file except in compliance
  49370. * with the License. You may obtain a copy of the License at
  49371. *
  49372. * http://www.apache.org/licenses/LICENSE-2.0
  49373. *
  49374. * Unless required by applicable law or agreed to in writing,
  49375. * software distributed under the License is distributed on an
  49376. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49377. * KIND, either express or implied. See the License for the
  49378. * specific language governing permissions and limitations
  49379. * under the License.
  49380. */
  49381. /**
  49382. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49383. */
  49384. /*
  49385. * Licensed to the Apache Software Foundation (ASF) under one
  49386. * or more contributor license agreements. See the NOTICE file
  49387. * distributed with this work for additional information
  49388. * regarding copyright ownership. The ASF licenses this file
  49389. * to you under the Apache License, Version 2.0 (the
  49390. * "License"); you may not use this file except in compliance
  49391. * with the License. You may obtain a copy of the License at
  49392. *
  49393. * http://www.apache.org/licenses/LICENSE-2.0
  49394. *
  49395. * Unless required by applicable law or agreed to in writing,
  49396. * software distributed under the License is distributed on an
  49397. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49398. * KIND, either express or implied. See the License for the
  49399. * specific language governing permissions and limitations
  49400. * under the License.
  49401. */
  49402. use(install$11);
  49403. /*
  49404. * Licensed to the Apache Software Foundation (ASF) under one
  49405. * or more contributor license agreements. See the NOTICE file
  49406. * distributed with this work for additional information
  49407. * regarding copyright ownership. The ASF licenses this file
  49408. * to you under the Apache License, Version 2.0 (the
  49409. * "License"); you may not use this file except in compliance
  49410. * with the License. You may obtain a copy of the License at
  49411. *
  49412. * http://www.apache.org/licenses/LICENSE-2.0
  49413. *
  49414. * Unless required by applicable law or agreed to in writing,
  49415. * software distributed under the License is distributed on an
  49416. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49417. * KIND, either express or implied. See the License for the
  49418. * specific language governing permissions and limitations
  49419. * under the License.
  49420. */
  49421. /**
  49422. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49423. */
  49424. /*
  49425. * Licensed to the Apache Software Foundation (ASF) under one
  49426. * or more contributor license agreements. See the NOTICE file
  49427. * distributed with this work for additional information
  49428. * regarding copyright ownership. The ASF licenses this file
  49429. * to you under the Apache License, Version 2.0 (the
  49430. * "License"); you may not use this file except in compliance
  49431. * with the License. You may obtain a copy of the License at
  49432. *
  49433. * http://www.apache.org/licenses/LICENSE-2.0
  49434. *
  49435. * Unless required by applicable law or agreed to in writing,
  49436. * software distributed under the License is distributed on an
  49437. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49438. * KIND, either express or implied. See the License for the
  49439. * specific language governing permissions and limitations
  49440. * under the License.
  49441. */
  49442. /*
  49443. * A third-party license is embeded for some of the code in this file:
  49444. * The tree layoutHelper implementation was originally copied from
  49445. * "d3.js"(https://github.com/d3/d3-hierarchy) with
  49446. * some modifications made for this project.
  49447. * (see more details in the comment of the specific method below.)
  49448. * The use of the source code of this file is also subject to the terms
  49449. * and consitions of the licence of "d3.js" (BSD-3Clause, see
  49450. * </licenses/LICENSE-d3>).
  49451. */
  49452. /**
  49453. * @file The layout algorithm of node-link tree diagrams. Here we using Reingold-Tilford algorithm to drawing
  49454. * the tree.
  49455. */
  49456. /**
  49457. * Initialize all computational message for following algorithm.
  49458. */
  49459. function init$2(inRoot) {
  49460. var root = inRoot;
  49461. root.hierNode = {
  49462. defaultAncestor: null,
  49463. ancestor: root,
  49464. prelim: 0,
  49465. modifier: 0,
  49466. change: 0,
  49467. shift: 0,
  49468. i: 0,
  49469. thread: null
  49470. };
  49471. var nodes = [root];
  49472. var node;
  49473. var children;
  49474. while (node = nodes.pop()) {
  49475. // jshint ignore:line
  49476. children = node.children;
  49477. if (node.isExpand && children.length) {
  49478. var n = children.length;
  49479. for (var i = n - 1; i >= 0; i--) {
  49480. var child = children[i];
  49481. child.hierNode = {
  49482. defaultAncestor: null,
  49483. ancestor: child,
  49484. prelim: 0,
  49485. modifier: 0,
  49486. change: 0,
  49487. shift: 0,
  49488. i: i,
  49489. thread: null
  49490. };
  49491. nodes.push(child);
  49492. }
  49493. }
  49494. }
  49495. }
  49496. /**
  49497. * The implementation of this function was originally copied from "d3.js"
  49498. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  49499. * with some modifications made for this program.
  49500. * See the license statement at the head of this file.
  49501. *
  49502. * Computes a preliminary x coordinate for node. Before that, this function is
  49503. * applied recursively to the children of node, as well as the function
  49504. * apportion(). After spacing out the children by calling executeShifts(), the
  49505. * node is placed to the midpoint of its outermost children.
  49506. */
  49507. function firstWalk(node, separation) {
  49508. var children = node.isExpand ? node.children : [];
  49509. var siblings = node.parentNode.children;
  49510. var subtreeW = node.hierNode.i ? siblings[node.hierNode.i - 1] : null;
  49511. if (children.length) {
  49512. executeShifts(node);
  49513. var midPoint = (children[0].hierNode.prelim + children[children.length - 1].hierNode.prelim) / 2;
  49514. if (subtreeW) {
  49515. node.hierNode.prelim = subtreeW.hierNode.prelim + separation(node, subtreeW);
  49516. node.hierNode.modifier = node.hierNode.prelim - midPoint;
  49517. } else {
  49518. node.hierNode.prelim = midPoint;
  49519. }
  49520. } else if (subtreeW) {
  49521. node.hierNode.prelim = subtreeW.hierNode.prelim + separation(node, subtreeW);
  49522. }
  49523. node.parentNode.hierNode.defaultAncestor = apportion(node, subtreeW, node.parentNode.hierNode.defaultAncestor || siblings[0], separation);
  49524. }
  49525. /**
  49526. * The implementation of this function was originally copied from "d3.js"
  49527. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  49528. * with some modifications made for this program.
  49529. * See the license statement at the head of this file.
  49530. *
  49531. * Computes all real x-coordinates by summing up the modifiers recursively.
  49532. */
  49533. function secondWalk(node) {
  49534. var nodeX = node.hierNode.prelim + node.parentNode.hierNode.modifier;
  49535. node.setLayout({
  49536. x: nodeX
  49537. }, true);
  49538. node.hierNode.modifier += node.parentNode.hierNode.modifier;
  49539. }
  49540. function separation(cb) {
  49541. return arguments.length ? cb : defaultSeparation;
  49542. }
  49543. /**
  49544. * Transform the common coordinate to radial coordinate.
  49545. */
  49546. function radialCoordinate(rad, r) {
  49547. rad -= Math.PI / 2;
  49548. return {
  49549. x: r * Math.cos(rad),
  49550. y: r * Math.sin(rad)
  49551. };
  49552. }
  49553. /**
  49554. * Get the layout position of the whole view.
  49555. */
  49556. function getViewRect$1(seriesModel, api) {
  49557. return getLayoutRect(seriesModel.getBoxLayoutParams(), {
  49558. width: api.getWidth(),
  49559. height: api.getHeight()
  49560. });
  49561. }
  49562. /**
  49563. * All other shifts, applied to the smaller subtrees between w- and w+, are
  49564. * performed by this function.
  49565. *
  49566. * The implementation of this function was originally copied from "d3.js"
  49567. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  49568. * with some modifications made for this program.
  49569. * See the license statement at the head of this file.
  49570. */
  49571. function executeShifts(node) {
  49572. var children = node.children;
  49573. var n = children.length;
  49574. var shift = 0;
  49575. var change = 0;
  49576. while (--n >= 0) {
  49577. var child = children[n];
  49578. child.hierNode.prelim += shift;
  49579. child.hierNode.modifier += shift;
  49580. change += child.hierNode.change;
  49581. shift += child.hierNode.shift + change;
  49582. }
  49583. }
  49584. /**
  49585. * The implementation of this function was originally copied from "d3.js"
  49586. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  49587. * with some modifications made for this program.
  49588. * See the license statement at the head of this file.
  49589. *
  49590. * The core of the algorithm. Here, a new subtree is combined with the
  49591. * previous subtrees. Threads are used to traverse the inside and outside
  49592. * contours of the left and right subtree up to the highest common level.
  49593. * Whenever two nodes of the inside contours conflict, we compute the left
  49594. * one of the greatest uncommon ancestors using the function nextAncestor()
  49595. * and call moveSubtree() to shift the subtree and prepare the shifts of
  49596. * smaller subtrees. Finally, we add a new thread (if necessary).
  49597. */
  49598. function apportion(subtreeV, subtreeW, ancestor, separation) {
  49599. if (subtreeW) {
  49600. var nodeOutRight = subtreeV;
  49601. var nodeInRight = subtreeV;
  49602. var nodeOutLeft = nodeInRight.parentNode.children[0];
  49603. var nodeInLeft = subtreeW;
  49604. var sumOutRight = nodeOutRight.hierNode.modifier;
  49605. var sumInRight = nodeInRight.hierNode.modifier;
  49606. var sumOutLeft = nodeOutLeft.hierNode.modifier;
  49607. var sumInLeft = nodeInLeft.hierNode.modifier;
  49608. while (nodeInLeft = nextRight(nodeInLeft), nodeInRight = nextLeft(nodeInRight), nodeInLeft && nodeInRight) {
  49609. nodeOutRight = nextRight(nodeOutRight);
  49610. nodeOutLeft = nextLeft(nodeOutLeft);
  49611. nodeOutRight.hierNode.ancestor = subtreeV;
  49612. var shift = nodeInLeft.hierNode.prelim + sumInLeft - nodeInRight.hierNode.prelim - sumInRight + separation(nodeInLeft, nodeInRight);
  49613. if (shift > 0) {
  49614. moveSubtree(nextAncestor(nodeInLeft, subtreeV, ancestor), subtreeV, shift);
  49615. sumInRight += shift;
  49616. sumOutRight += shift;
  49617. }
  49618. sumInLeft += nodeInLeft.hierNode.modifier;
  49619. sumInRight += nodeInRight.hierNode.modifier;
  49620. sumOutRight += nodeOutRight.hierNode.modifier;
  49621. sumOutLeft += nodeOutLeft.hierNode.modifier;
  49622. }
  49623. if (nodeInLeft && !nextRight(nodeOutRight)) {
  49624. nodeOutRight.hierNode.thread = nodeInLeft;
  49625. nodeOutRight.hierNode.modifier += sumInLeft - sumOutRight;
  49626. }
  49627. if (nodeInRight && !nextLeft(nodeOutLeft)) {
  49628. nodeOutLeft.hierNode.thread = nodeInRight;
  49629. nodeOutLeft.hierNode.modifier += sumInRight - sumOutLeft;
  49630. ancestor = subtreeV;
  49631. }
  49632. }
  49633. return ancestor;
  49634. }
  49635. /**
  49636. * This function is used to traverse the right contour of a subtree.
  49637. * It returns the rightmost child of node or the thread of node. The function
  49638. * returns null if and only if node is on the highest depth of its subtree.
  49639. */
  49640. function nextRight(node) {
  49641. var children = node.children;
  49642. return children.length && node.isExpand ? children[children.length - 1] : node.hierNode.thread;
  49643. }
  49644. /**
  49645. * This function is used to traverse the left contour of a subtree (or a subforest).
  49646. * It returns the leftmost child of node or the thread of node. The function
  49647. * returns null if and only if node is on the highest depth of its subtree.
  49648. */
  49649. function nextLeft(node) {
  49650. var children = node.children;
  49651. return children.length && node.isExpand ? children[0] : node.hierNode.thread;
  49652. }
  49653. /**
  49654. * If nodeInLeft’s ancestor is a sibling of node, returns nodeInLeft’s ancestor.
  49655. * Otherwise, returns the specified ancestor.
  49656. */
  49657. function nextAncestor(nodeInLeft, node, ancestor) {
  49658. return nodeInLeft.hierNode.ancestor.parentNode === node.parentNode ? nodeInLeft.hierNode.ancestor : ancestor;
  49659. }
  49660. /**
  49661. * The implementation of this function was originally copied from "d3.js"
  49662. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  49663. * with some modifications made for this program.
  49664. * See the license statement at the head of this file.
  49665. *
  49666. * Shifts the current subtree rooted at wr.
  49667. * This is done by increasing prelim(w+) and modifier(w+) by shift.
  49668. */
  49669. function moveSubtree(wl, wr, shift) {
  49670. var change = shift / (wr.hierNode.i - wl.hierNode.i);
  49671. wr.hierNode.change -= change;
  49672. wr.hierNode.shift += shift;
  49673. wr.hierNode.modifier += shift;
  49674. wr.hierNode.prelim += shift;
  49675. wl.hierNode.change += change;
  49676. }
  49677. /**
  49678. * The implementation of this function was originally copied from "d3.js"
  49679. * <https://github.com/d3/d3-hierarchy/blob/4c1f038f2725d6eae2e49b61d01456400694bac4/src/tree.js>
  49680. * with some modifications made for this program.
  49681. * See the license statement at the head of this file.
  49682. */
  49683. function defaultSeparation(node1, node2) {
  49684. return node1.parentNode === node2.parentNode ? 1 : 2;
  49685. }
  49686. /*
  49687. * Licensed to the Apache Software Foundation (ASF) under one
  49688. * or more contributor license agreements. See the NOTICE file
  49689. * distributed with this work for additional information
  49690. * regarding copyright ownership. The ASF licenses this file
  49691. * to you under the Apache License, Version 2.0 (the
  49692. * "License"); you may not use this file except in compliance
  49693. * with the License. You may obtain a copy of the License at
  49694. *
  49695. * http://www.apache.org/licenses/LICENSE-2.0
  49696. *
  49697. * Unless required by applicable law or agreed to in writing,
  49698. * software distributed under the License is distributed on an
  49699. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49700. * KIND, either express or implied. See the License for the
  49701. * specific language governing permissions and limitations
  49702. * under the License.
  49703. */
  49704. /**
  49705. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49706. */
  49707. /*
  49708. * Licensed to the Apache Software Foundation (ASF) under one
  49709. * or more contributor license agreements. See the NOTICE file
  49710. * distributed with this work for additional information
  49711. * regarding copyright ownership. The ASF licenses this file
  49712. * to you under the Apache License, Version 2.0 (the
  49713. * "License"); you may not use this file except in compliance
  49714. * with the License. You may obtain a copy of the License at
  49715. *
  49716. * http://www.apache.org/licenses/LICENSE-2.0
  49717. *
  49718. * Unless required by applicable law or agreed to in writing,
  49719. * software distributed under the License is distributed on an
  49720. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49721. * KIND, either express or implied. See the License for the
  49722. * specific language governing permissions and limitations
  49723. * under the License.
  49724. */
  49725. /**
  49726. * Simple view coordinate system
  49727. * Mapping given x, y to transformd view x, y
  49728. */
  49729. var v2ApplyTransform = applyTransform;
  49730. var View =
  49731. /** @class */
  49732. function (_super) {
  49733. __extends(View, _super);
  49734. function View(name) {
  49735. var _this = _super.call(this) || this;
  49736. _this.type = 'view';
  49737. _this.dimensions = ['x', 'y'];
  49738. /**
  49739. * Represents the transform brought by roam/zoom.
  49740. * If `View['_viewRect']` applies roam transform,
  49741. * we can get the final displayed rect.
  49742. */
  49743. _this._roamTransformable = new Transformable();
  49744. /**
  49745. * Represents the transform from `View['_rect']` to `View['_viewRect']`.
  49746. */
  49747. _this._rawTransformable = new Transformable();
  49748. _this.name = name;
  49749. return _this;
  49750. }
  49751. View.prototype.setBoundingRect = function (x, y, width, height) {
  49752. this._rect = new BoundingRect(x, y, width, height);
  49753. return this._rect;
  49754. };
  49755. /**
  49756. * @return {module:zrender/core/BoundingRect}
  49757. */
  49758. View.prototype.getBoundingRect = function () {
  49759. return this._rect;
  49760. };
  49761. View.prototype.setViewRect = function (x, y, width, height) {
  49762. this._transformTo(x, y, width, height);
  49763. this._viewRect = new BoundingRect(x, y, width, height);
  49764. };
  49765. /**
  49766. * Transformed to particular position and size
  49767. */
  49768. View.prototype._transformTo = function (x, y, width, height) {
  49769. var rect = this.getBoundingRect();
  49770. var rawTransform = this._rawTransformable;
  49771. rawTransform.transform = rect.calculateTransform(new BoundingRect(x, y, width, height));
  49772. var rawParent = rawTransform.parent;
  49773. rawTransform.parent = null;
  49774. rawTransform.decomposeTransform();
  49775. rawTransform.parent = rawParent;
  49776. this._updateTransform();
  49777. };
  49778. /**
  49779. * Set center of view
  49780. */
  49781. View.prototype.setCenter = function (centerCoord) {
  49782. if (!centerCoord) {
  49783. return;
  49784. }
  49785. this._center = centerCoord;
  49786. this._updateCenterAndZoom();
  49787. };
  49788. View.prototype.setZoom = function (zoom) {
  49789. zoom = zoom || 1;
  49790. var zoomLimit = this.zoomLimit;
  49791. if (zoomLimit) {
  49792. if (zoomLimit.max != null) {
  49793. zoom = Math.min(zoomLimit.max, zoom);
  49794. }
  49795. if (zoomLimit.min != null) {
  49796. zoom = Math.max(zoomLimit.min, zoom);
  49797. }
  49798. }
  49799. this._zoom = zoom;
  49800. this._updateCenterAndZoom();
  49801. };
  49802. /**
  49803. * Get default center without roam
  49804. */
  49805. View.prototype.getDefaultCenter = function () {
  49806. // Rect before any transform
  49807. var rawRect = this.getBoundingRect();
  49808. var cx = rawRect.x + rawRect.width / 2;
  49809. var cy = rawRect.y + rawRect.height / 2;
  49810. return [cx, cy];
  49811. };
  49812. View.prototype.getCenter = function () {
  49813. return this._center || this.getDefaultCenter();
  49814. };
  49815. View.prototype.getZoom = function () {
  49816. return this._zoom || 1;
  49817. };
  49818. View.prototype.getRoamTransform = function () {
  49819. return this._roamTransformable.getLocalTransform();
  49820. };
  49821. /**
  49822. * Remove roam
  49823. */
  49824. View.prototype._updateCenterAndZoom = function () {
  49825. // Must update after view transform updated
  49826. var rawTransformMatrix = this._rawTransformable.getLocalTransform();
  49827. var roamTransform = this._roamTransformable;
  49828. var defaultCenter = this.getDefaultCenter();
  49829. var center = this.getCenter();
  49830. var zoom = this.getZoom();
  49831. center = applyTransform([], center, rawTransformMatrix);
  49832. defaultCenter = applyTransform([], defaultCenter, rawTransformMatrix);
  49833. roamTransform.originX = center[0];
  49834. roamTransform.originY = center[1];
  49835. roamTransform.x = defaultCenter[0] - center[0];
  49836. roamTransform.y = defaultCenter[1] - center[1];
  49837. roamTransform.scaleX = roamTransform.scaleY = zoom;
  49838. this._updateTransform();
  49839. };
  49840. /**
  49841. * Update transform props on `this` based on the current
  49842. * `this._roamTransformable` and `this._rawTransformable`.
  49843. */
  49844. View.prototype._updateTransform = function () {
  49845. var roamTransformable = this._roamTransformable;
  49846. var rawTransformable = this._rawTransformable;
  49847. rawTransformable.parent = roamTransformable;
  49848. roamTransformable.updateTransform();
  49849. rawTransformable.updateTransform();
  49850. copy$1(this.transform || (this.transform = []), rawTransformable.transform || create$1());
  49851. this._rawTransform = rawTransformable.getLocalTransform();
  49852. this.invTransform = this.invTransform || [];
  49853. invert(this.invTransform, this.transform);
  49854. this.decomposeTransform();
  49855. };
  49856. View.prototype.getTransformInfo = function () {
  49857. var rawTransformable = this._rawTransformable;
  49858. var roamTransformable = this._roamTransformable; // Becuase roamTransformabel has `originX/originY` modified,
  49859. // but the caller of `getTransformInfo` can not handle `originX/originY`,
  49860. // so need to recalcualte them.
  49861. var dummyTransformable = new Transformable();
  49862. dummyTransformable.transform = roamTransformable.transform;
  49863. dummyTransformable.decomposeTransform();
  49864. return {
  49865. roam: {
  49866. x: dummyTransformable.x,
  49867. y: dummyTransformable.y,
  49868. scaleX: dummyTransformable.scaleX,
  49869. scaleY: dummyTransformable.scaleY
  49870. },
  49871. raw: {
  49872. x: rawTransformable.x,
  49873. y: rawTransformable.y,
  49874. scaleX: rawTransformable.scaleX,
  49875. scaleY: rawTransformable.scaleY
  49876. }
  49877. };
  49878. };
  49879. View.prototype.getViewRect = function () {
  49880. return this._viewRect;
  49881. };
  49882. /**
  49883. * Get view rect after roam transform
  49884. */
  49885. View.prototype.getViewRectAfterRoam = function () {
  49886. var rect = this.getBoundingRect().clone();
  49887. rect.applyTransform(this.transform);
  49888. return rect;
  49889. };
  49890. /**
  49891. * Convert a single (lon, lat) data item to (x, y) point.
  49892. */
  49893. View.prototype.dataToPoint = function (data, noRoam, out) {
  49894. var transform = noRoam ? this._rawTransform : this.transform;
  49895. out = out || [];
  49896. return transform ? v2ApplyTransform(out, data, transform) : copy(out, data);
  49897. };
  49898. /**
  49899. * Convert a (x, y) point to (lon, lat) data
  49900. */
  49901. View.prototype.pointToData = function (point) {
  49902. var invTransform = this.invTransform;
  49903. return invTransform ? v2ApplyTransform([], point, invTransform) : [point[0], point[1]];
  49904. };
  49905. View.prototype.convertToPixel = function (ecModel, finder, value) {
  49906. var coordSys = getCoordSys(finder);
  49907. return coordSys === this ? coordSys.dataToPoint(value) : null;
  49908. };
  49909. View.prototype.convertFromPixel = function (ecModel, finder, pixel) {
  49910. var coordSys = getCoordSys(finder);
  49911. return coordSys === this ? coordSys.pointToData(pixel) : null;
  49912. };
  49913. /**
  49914. * @implements
  49915. */
  49916. View.prototype.containPoint = function (point) {
  49917. return this.getViewRectAfterRoam().contain(point[0], point[1]);
  49918. };
  49919. View.dimensions = ['x', 'y'];
  49920. return View;
  49921. }(Transformable);
  49922. function getCoordSys(finder) {
  49923. var seriesModel = finder.seriesModel;
  49924. return seriesModel ? seriesModel.coordinateSystem : null; // e.g., graph.
  49925. }
  49926. /*
  49927. * Licensed to the Apache Software Foundation (ASF) under one
  49928. * or more contributor license agreements. See the NOTICE file
  49929. * distributed with this work for additional information
  49930. * regarding copyright ownership. The ASF licenses this file
  49931. * to you under the Apache License, Version 2.0 (the
  49932. * "License"); you may not use this file except in compliance
  49933. * with the License. You may obtain a copy of the License at
  49934. *
  49935. * http://www.apache.org/licenses/LICENSE-2.0
  49936. *
  49937. * Unless required by applicable law or agreed to in writing,
  49938. * software distributed under the License is distributed on an
  49939. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49940. * KIND, either express or implied. See the License for the
  49941. * specific language governing permissions and limitations
  49942. * under the License.
  49943. */
  49944. /**
  49945. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49946. */
  49947. /*
  49948. * Licensed to the Apache Software Foundation (ASF) under one
  49949. * or more contributor license agreements. See the NOTICE file
  49950. * distributed with this work for additional information
  49951. * regarding copyright ownership. The ASF licenses this file
  49952. * to you under the Apache License, Version 2.0 (the
  49953. * "License"); you may not use this file except in compliance
  49954. * with the License. You may obtain a copy of the License at
  49955. *
  49956. * http://www.apache.org/licenses/LICENSE-2.0
  49957. *
  49958. * Unless required by applicable law or agreed to in writing,
  49959. * software distributed under the License is distributed on an
  49960. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49961. * KIND, either express or implied. See the License for the
  49962. * specific language governing permissions and limitations
  49963. * under the License.
  49964. */
  49965. /**
  49966. * For geo and graph.
  49967. */
  49968. function updateViewOnPan(controllerHost, dx, dy) {
  49969. var target = controllerHost.target;
  49970. target.x += dx;
  49971. target.y += dy;
  49972. target.dirty();
  49973. }
  49974. /**
  49975. * For geo and graph.
  49976. */
  49977. function updateViewOnZoom(controllerHost, zoomDelta, zoomX, zoomY) {
  49978. var target = controllerHost.target;
  49979. var zoomLimit = controllerHost.zoomLimit;
  49980. var newZoom = controllerHost.zoom = controllerHost.zoom || 1;
  49981. newZoom *= zoomDelta;
  49982. if (zoomLimit) {
  49983. var zoomMin = zoomLimit.min || 0;
  49984. var zoomMax = zoomLimit.max || Infinity;
  49985. newZoom = Math.max(Math.min(zoomMax, newZoom), zoomMin);
  49986. }
  49987. var zoomScale = newZoom / controllerHost.zoom;
  49988. controllerHost.zoom = newZoom; // Keep the mouse center when scaling
  49989. target.x -= (zoomX - target.x) * (zoomScale - 1);
  49990. target.y -= (zoomY - target.y) * (zoomScale - 1);
  49991. target.scaleX *= zoomScale;
  49992. target.scaleY *= zoomScale;
  49993. target.dirty();
  49994. }
  49995. /*
  49996. * Licensed to the Apache Software Foundation (ASF) under one
  49997. * or more contributor license agreements. See the NOTICE file
  49998. * distributed with this work for additional information
  49999. * regarding copyright ownership. The ASF licenses this file
  50000. * to you under the Apache License, Version 2.0 (the
  50001. * "License"); you may not use this file except in compliance
  50002. * with the License. You may obtain a copy of the License at
  50003. *
  50004. * http://www.apache.org/licenses/LICENSE-2.0
  50005. *
  50006. * Unless required by applicable law or agreed to in writing,
  50007. * software distributed under the License is distributed on an
  50008. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50009. * KIND, either express or implied. See the License for the
  50010. * specific language governing permissions and limitations
  50011. * under the License.
  50012. */
  50013. /**
  50014. * AUTO-GENERATED FILE. DO NOT MODIFY.
  50015. */
  50016. /*
  50017. * Licensed to the Apache Software Foundation (ASF) under one
  50018. * or more contributor license agreements. See the NOTICE file
  50019. * distributed with this work for additional information
  50020. * regarding copyright ownership. The ASF licenses this file
  50021. * to you under the Apache License, Version 2.0 (the
  50022. * "License"); you may not use this file except in compliance
  50023. * with the License. You may obtain a copy of the License at
  50024. *
  50025. * http://www.apache.org/licenses/LICENSE-2.0
  50026. *
  50027. * Unless required by applicable law or agreed to in writing,
  50028. * software distributed under the License is distributed on an
  50029. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50030. * KIND, either express or implied. See the License for the
  50031. * specific language governing permissions and limitations
  50032. * under the License.
  50033. */
  50034. // @ts-nocheck
  50035. var ATTR = '\0_ec_interaction_mutex';
  50036. function take(zr, resourceKey, userKey) {
  50037. var store = getStore(zr);
  50038. store[resourceKey] = userKey;
  50039. }
  50040. function release(zr, resourceKey, userKey) {
  50041. var store = getStore(zr);
  50042. var uKey = store[resourceKey];
  50043. if (uKey === userKey) {
  50044. store[resourceKey] = null;
  50045. }
  50046. }
  50047. function isTaken(zr, resourceKey) {
  50048. return !!getStore(zr)[resourceKey];
  50049. }
  50050. function getStore(zr) {
  50051. return zr[ATTR] || (zr[ATTR] = {});
  50052. }
  50053. /**
  50054. * payload: {
  50055. * type: 'takeGlobalCursor',
  50056. * key: 'dataZoomSelect', or 'brush', or ...,
  50057. * If no userKey, release global cursor.
  50058. * }
  50059. */
  50060. // TODO: SELF REGISTERED.
  50061. registerAction({
  50062. type: 'takeGlobalCursor',
  50063. event: 'globalCursorTaken',
  50064. update: 'update'
  50065. }, function () {});
  50066. /*
  50067. * Licensed to the Apache Software Foundation (ASF) under one
  50068. * or more contributor license agreements. See the NOTICE file
  50069. * distributed with this work for additional information
  50070. * regarding copyright ownership. The ASF licenses this file
  50071. * to you under the Apache License, Version 2.0 (the
  50072. * "License"); you may not use this file except in compliance
  50073. * with the License. You may obtain a copy of the License at
  50074. *
  50075. * http://www.apache.org/licenses/LICENSE-2.0
  50076. *
  50077. * Unless required by applicable law or agreed to in writing,
  50078. * software distributed under the License is distributed on an
  50079. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50080. * KIND, either express or implied. See the License for the
  50081. * specific language governing permissions and limitations
  50082. * under the License.
  50083. */
  50084. /**
  50085. * AUTO-GENERATED FILE. DO NOT MODIFY.
  50086. */
  50087. /*
  50088. * Licensed to the Apache Software Foundation (ASF) under one
  50089. * or more contributor license agreements. See the NOTICE file
  50090. * distributed with this work for additional information
  50091. * regarding copyright ownership. The ASF licenses this file
  50092. * to you under the Apache License, Version 2.0 (the
  50093. * "License"); you may not use this file except in compliance
  50094. * with the License. You may obtain a copy of the License at
  50095. *
  50096. * http://www.apache.org/licenses/LICENSE-2.0
  50097. *
  50098. * Unless required by applicable law or agreed to in writing,
  50099. * software distributed under the License is distributed on an
  50100. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50101. * KIND, either express or implied. See the License for the
  50102. * specific language governing permissions and limitations
  50103. * under the License.
  50104. */
  50105. var RoamController =
  50106. /** @class */
  50107. function (_super) {
  50108. __extends(RoamController, _super);
  50109. function RoamController(zr) {
  50110. var _this = _super.call(this) || this;
  50111. _this._zr = zr; // Avoid two roamController bind the same handler
  50112. var mousedownHandler = bind(_this._mousedownHandler, _this);
  50113. var mousemoveHandler = bind(_this._mousemoveHandler, _this);
  50114. var mouseupHandler = bind(_this._mouseupHandler, _this);
  50115. var mousewheelHandler = bind(_this._mousewheelHandler, _this);
  50116. var pinchHandler = bind(_this._pinchHandler, _this);
  50117. /**
  50118. * Notice: only enable needed types. For example, if 'zoom'
  50119. * is not needed, 'zoom' should not be enabled, otherwise
  50120. * default mousewheel behaviour (scroll page) will be disabled.
  50121. */
  50122. _this.enable = function (controlType, opt) {
  50123. // Disable previous first
  50124. this.disable();
  50125. this._opt = defaults(clone(opt) || {}, {
  50126. zoomOnMouseWheel: true,
  50127. moveOnMouseMove: true,
  50128. // By default, wheel do not trigger move.
  50129. moveOnMouseWheel: false,
  50130. preventDefaultMouseMove: true
  50131. });
  50132. if (controlType == null) {
  50133. controlType = true;
  50134. }
  50135. if (controlType === true || controlType === 'move' || controlType === 'pan') {
  50136. zr.on('mousedown', mousedownHandler);
  50137. zr.on('mousemove', mousemoveHandler);
  50138. zr.on('mouseup', mouseupHandler);
  50139. }
  50140. if (controlType === true || controlType === 'scale' || controlType === 'zoom') {
  50141. zr.on('mousewheel', mousewheelHandler);
  50142. zr.on('pinch', pinchHandler);
  50143. }
  50144. };
  50145. _this.disable = function () {
  50146. zr.off('mousedown', mousedownHandler);
  50147. zr.off('mousemove', mousemoveHandler);
  50148. zr.off('mouseup', mouseupHandler);
  50149. zr.off('mousewheel', mousewheelHandler);
  50150. zr.off('pinch', pinchHandler);
  50151. };
  50152. return _this;
  50153. }
  50154. RoamController.prototype.isDragging = function () {
  50155. return this._dragging;
  50156. };
  50157. RoamController.prototype.isPinching = function () {
  50158. return this._pinching;
  50159. };
  50160. RoamController.prototype.setPointerChecker = function (pointerChecker) {
  50161. this.pointerChecker = pointerChecker;
  50162. };
  50163. RoamController.prototype.dispose = function () {
  50164. this.disable();
  50165. };
  50166. RoamController.prototype._mousedownHandler = function (e) {
  50167. if (isMiddleOrRightButtonOnMouseUpDown(e) || e.target && e.target.draggable) {
  50168. return;
  50169. }
  50170. var x = e.offsetX;
  50171. var y = e.offsetY; // Only check on mosedown, but not mousemove.
  50172. // Mouse can be out of target when mouse moving.
  50173. if (this.pointerChecker && this.pointerChecker(e, x, y)) {
  50174. this._x = x;
  50175. this._y = y;
  50176. this._dragging = true;
  50177. }
  50178. };
  50179. RoamController.prototype._mousemoveHandler = function (e) {
  50180. if (!this._dragging || !isAvailableBehavior('moveOnMouseMove', e, this._opt) || e.gestureEvent === 'pinch' || isTaken(this._zr, 'globalPan')) {
  50181. return;
  50182. }
  50183. var x = e.offsetX;
  50184. var y = e.offsetY;
  50185. var oldX = this._x;
  50186. var oldY = this._y;
  50187. var dx = x - oldX;
  50188. var dy = y - oldY;
  50189. this._x = x;
  50190. this._y = y;
  50191. this._opt.preventDefaultMouseMove && stop(e.event);
  50192. trigger(this, 'pan', 'moveOnMouseMove', e, {
  50193. dx: dx,
  50194. dy: dy,
  50195. oldX: oldX,
  50196. oldY: oldY,
  50197. newX: x,
  50198. newY: y,
  50199. isAvailableBehavior: null
  50200. });
  50201. };
  50202. RoamController.prototype._mouseupHandler = function (e) {
  50203. if (!isMiddleOrRightButtonOnMouseUpDown(e)) {
  50204. this._dragging = false;
  50205. }
  50206. };
  50207. RoamController.prototype._mousewheelHandler = function (e) {
  50208. var shouldZoom = isAvailableBehavior('zoomOnMouseWheel', e, this._opt);
  50209. var shouldMove = isAvailableBehavior('moveOnMouseWheel', e, this._opt);
  50210. var wheelDelta = e.wheelDelta;
  50211. var absWheelDeltaDelta = Math.abs(wheelDelta);
  50212. var originX = e.offsetX;
  50213. var originY = e.offsetY; // wheelDelta maybe -0 in chrome mac.
  50214. if (wheelDelta === 0 || !shouldZoom && !shouldMove) {
  50215. return;
  50216. } // If both `shouldZoom` and `shouldMove` is true, trigger
  50217. // their event both, and the final behavior is determined
  50218. // by event listener themselves.
  50219. if (shouldZoom) {
  50220. // Convenience:
  50221. // Mac and VM Windows on Mac: scroll up: zoom out.
  50222. // Windows: scroll up: zoom in.
  50223. // FIXME: Should do more test in different environment.
  50224. // wheelDelta is too complicated in difference nvironment
  50225. // (https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel),
  50226. // although it has been normallized by zrender.
  50227. // wheelDelta of mouse wheel is bigger than touch pad.
  50228. var factor = absWheelDeltaDelta > 3 ? 1.4 : absWheelDeltaDelta > 1 ? 1.2 : 1.1;
  50229. var scale = wheelDelta > 0 ? factor : 1 / factor;
  50230. checkPointerAndTrigger(this, 'zoom', 'zoomOnMouseWheel', e, {
  50231. scale: scale,
  50232. originX: originX,
  50233. originY: originY,
  50234. isAvailableBehavior: null
  50235. });
  50236. }
  50237. if (shouldMove) {
  50238. // FIXME: Should do more test in different environment.
  50239. var absDelta = Math.abs(wheelDelta); // wheelDelta of mouse wheel is bigger than touch pad.
  50240. var scrollDelta = (wheelDelta > 0 ? 1 : -1) * (absDelta > 3 ? 0.4 : absDelta > 1 ? 0.15 : 0.05);
  50241. checkPointerAndTrigger(this, 'scrollMove', 'moveOnMouseWheel', e, {
  50242. scrollDelta: scrollDelta,
  50243. originX: originX,
  50244. originY: originY,
  50245. isAvailableBehavior: null
  50246. });
  50247. }
  50248. };
  50249. RoamController.prototype._pinchHandler = function (e) {
  50250. if (isTaken(this._zr, 'globalPan')) {
  50251. return;
  50252. }
  50253. var scale = e.pinchScale > 1 ? 1.1 : 1 / 1.1;
  50254. checkPointerAndTrigger(this, 'zoom', null, e, {
  50255. scale: scale,
  50256. originX: e.pinchX,
  50257. originY: e.pinchY,
  50258. isAvailableBehavior: null
  50259. });
  50260. };
  50261. return RoamController;
  50262. }(Eventful);
  50263. function checkPointerAndTrigger(controller, eventName, behaviorToCheck, e, contollerEvent) {
  50264. if (controller.pointerChecker && controller.pointerChecker(e, contollerEvent.originX, contollerEvent.originY)) {
  50265. // When mouse is out of roamController rect,
  50266. // default befavoius should not be be disabled, otherwise
  50267. // page sliding is disabled, contrary to expectation.
  50268. stop(e.event);
  50269. trigger(controller, eventName, behaviorToCheck, e, contollerEvent);
  50270. }
  50271. }
  50272. function trigger(controller, eventName, behaviorToCheck, e, contollerEvent) {
  50273. // Also provide behavior checker for event listener, for some case that
  50274. // multiple components share one listener.
  50275. contollerEvent.isAvailableBehavior = bind(isAvailableBehavior, null, behaviorToCheck, e);
  50276. controller.trigger(eventName, contollerEvent);
  50277. } // settings: {
  50278. // zoomOnMouseWheel
  50279. // moveOnMouseMove
  50280. // moveOnMouseWheel
  50281. // }
  50282. // The value can be: true / false / 'shift' / 'ctrl' / 'alt'.
  50283. function isAvailableBehavior(behaviorToCheck, e, settings) {
  50284. var setting = settings[behaviorToCheck];
  50285. return !behaviorToCheck || setting && (!isString(setting) || e.event[setting + 'Key']);
  50286. }
  50287. /*
  50288. * Licensed to the Apache Software Foundation (ASF) under one
  50289. * or more contributor license agreements. See the NOTICE file
  50290. * distributed with this work for additional information
  50291. * regarding copyright ownership. The ASF licenses this file
  50292. * to you under the Apache License, Version 2.0 (the
  50293. * "License"); you may not use this file except in compliance
  50294. * with the License. You may obtain a copy of the License at
  50295. *
  50296. * http://www.apache.org/licenses/LICENSE-2.0
  50297. *
  50298. * Unless required by applicable law or agreed to in writing,
  50299. * software distributed under the License is distributed on an
  50300. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50301. * KIND, either express or implied. See the License for the
  50302. * specific language governing permissions and limitations
  50303. * under the License.
  50304. */
  50305. /**
  50306. * AUTO-GENERATED FILE. DO NOT MODIFY.
  50307. */
  50308. /*
  50309. * Licensed to the Apache Software Foundation (ASF) under one
  50310. * or more contributor license agreements. See the NOTICE file
  50311. * distributed with this work for additional information
  50312. * regarding copyright ownership. The ASF licenses this file
  50313. * to you under the Apache License, Version 2.0 (the
  50314. * "License"); you may not use this file except in compliance
  50315. * with the License. You may obtain a copy of the License at
  50316. *
  50317. * http://www.apache.org/licenses/LICENSE-2.0
  50318. *
  50319. * Unless required by applicable law or agreed to in writing,
  50320. * software distributed under the License is distributed on an
  50321. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50322. * KIND, either express or implied. See the License for the
  50323. * specific language governing permissions and limitations
  50324. * under the License.
  50325. */
  50326. var IRRELEVANT_EXCLUDES = {
  50327. 'axisPointer': 1,
  50328. 'tooltip': 1,
  50329. 'brush': 1
  50330. };
  50331. /**
  50332. * Avoid that: mouse click on a elements that is over geo or graph,
  50333. * but roam is triggered.
  50334. */
  50335. function onIrrelevantElement(e, api, targetCoordSysModel) {
  50336. var model = api.getComponentByElement(e.topTarget); // If model is axisModel, it works only if it is injected with coordinateSystem.
  50337. var coordSys = model && model.coordinateSystem;
  50338. return model && model !== targetCoordSysModel && !IRRELEVANT_EXCLUDES.hasOwnProperty(model.mainType) && coordSys && coordSys.model !== targetCoordSysModel;
  50339. }
  50340. /*
  50341. * Licensed to the Apache Software Foundation (ASF) under one
  50342. * or more contributor license agreements. See the NOTICE file
  50343. * distributed with this work for additional information
  50344. * regarding copyright ownership. The ASF licenses this file
  50345. * to you under the Apache License, Version 2.0 (the
  50346. * "License"); you may not use this file except in compliance
  50347. * with the License. You may obtain a copy of the License at
  50348. *
  50349. * http://www.apache.org/licenses/LICENSE-2.0
  50350. *
  50351. * Unless required by applicable law or agreed to in writing,
  50352. * software distributed under the License is distributed on an
  50353. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50354. * KIND, either express or implied. See the License for the
  50355. * specific language governing permissions and limitations
  50356. * under the License.
  50357. */
  50358. /**
  50359. * AUTO-GENERATED FILE. DO NOT MODIFY.
  50360. */
  50361. /*
  50362. * Licensed to the Apache Software Foundation (ASF) under one
  50363. * or more contributor license agreements. See the NOTICE file
  50364. * distributed with this work for additional information
  50365. * regarding copyright ownership. The ASF licenses this file
  50366. * to you under the Apache License, Version 2.0 (the
  50367. * "License"); you may not use this file except in compliance
  50368. * with the License. You may obtain a copy of the License at
  50369. *
  50370. * http://www.apache.org/licenses/LICENSE-2.0
  50371. *
  50372. * Unless required by applicable law or agreed to in writing,
  50373. * software distributed under the License is distributed on an
  50374. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50375. * KIND, either express or implied. See the License for the
  50376. * specific language governing permissions and limitations
  50377. * under the License.
  50378. */
  50379. var TreeEdgeShape =
  50380. /** @class */
  50381. function () {
  50382. function TreeEdgeShape() {
  50383. this.parentPoint = [];
  50384. this.childPoints = [];
  50385. }
  50386. return TreeEdgeShape;
  50387. }();
  50388. var TreePath =
  50389. /** @class */
  50390. function (_super) {
  50391. __extends(TreePath, _super);
  50392. function TreePath(opts) {
  50393. return _super.call(this, opts) || this;
  50394. }
  50395. TreePath.prototype.getDefaultStyle = function () {
  50396. return {
  50397. stroke: '#000',
  50398. fill: null
  50399. };
  50400. };
  50401. TreePath.prototype.getDefaultShape = function () {
  50402. return new TreeEdgeShape();
  50403. };
  50404. TreePath.prototype.buildPath = function (ctx, shape) {
  50405. var childPoints = shape.childPoints;
  50406. var childLen = childPoints.length;
  50407. var parentPoint = shape.parentPoint;
  50408. var firstChildPos = childPoints[0];
  50409. var lastChildPos = childPoints[childLen - 1];
  50410. if (childLen === 1) {
  50411. ctx.moveTo(parentPoint[0], parentPoint[1]);
  50412. ctx.lineTo(firstChildPos[0], firstChildPos[1]);
  50413. return;
  50414. }
  50415. var orient = shape.orient;
  50416. var forkDim = orient === 'TB' || orient === 'BT' ? 0 : 1;
  50417. var otherDim = 1 - forkDim;
  50418. var forkPosition = parsePercent$1(shape.forkPosition, 1);
  50419. var tmpPoint = [];
  50420. tmpPoint[forkDim] = parentPoint[forkDim];
  50421. tmpPoint[otherDim] = parentPoint[otherDim] + (lastChildPos[otherDim] - parentPoint[otherDim]) * forkPosition;
  50422. ctx.moveTo(parentPoint[0], parentPoint[1]);
  50423. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  50424. ctx.moveTo(firstChildPos[0], firstChildPos[1]);
  50425. tmpPoint[forkDim] = firstChildPos[forkDim];
  50426. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  50427. tmpPoint[forkDim] = lastChildPos[forkDim];
  50428. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  50429. ctx.lineTo(lastChildPos[0], lastChildPos[1]);
  50430. for (var i = 1; i < childLen - 1; i++) {
  50431. var point = childPoints[i];
  50432. ctx.moveTo(point[0], point[1]);
  50433. tmpPoint[forkDim] = point[forkDim];
  50434. ctx.lineTo(tmpPoint[0], tmpPoint[1]);
  50435. }
  50436. };
  50437. return TreePath;
  50438. }(Path);
  50439. var TreeView =
  50440. /** @class */
  50441. function (_super) {
  50442. __extends(TreeView, _super);
  50443. function TreeView() {
  50444. var _this = _super !== null && _super.apply(this, arguments) || this;
  50445. _this.type = TreeView.type;
  50446. _this._mainGroup = new Group();
  50447. return _this;
  50448. }
  50449. TreeView.prototype.init = function (ecModel, api) {
  50450. this._controller = new RoamController(api.getZr());
  50451. this._controllerHost = {
  50452. target: this.group
  50453. };
  50454. this.group.add(this._mainGroup);
  50455. };
  50456. TreeView.prototype.render = function (seriesModel, ecModel, api) {
  50457. var data = seriesModel.getData();
  50458. var layoutInfo = seriesModel.layoutInfo;
  50459. var group = this._mainGroup;
  50460. var layout = seriesModel.get('layout');
  50461. if (layout === 'radial') {
  50462. group.x = layoutInfo.x + layoutInfo.width / 2;
  50463. group.y = layoutInfo.y + layoutInfo.height / 2;
  50464. } else {
  50465. group.x = layoutInfo.x;
  50466. group.y = layoutInfo.y;
  50467. }
  50468. this._updateViewCoordSys(seriesModel);
  50469. this._updateController(seriesModel, ecModel, api);
  50470. var oldData = this._data;
  50471. data.diff(oldData).add(function (newIdx) {
  50472. if (symbolNeedsDraw$1(data, newIdx)) {
  50473. // Create node and edge
  50474. updateNode(data, newIdx, null, group, seriesModel);
  50475. }
  50476. }).update(function (newIdx, oldIdx) {
  50477. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  50478. if (!symbolNeedsDraw$1(data, newIdx)) {
  50479. symbolEl && removeNode(oldData, oldIdx, symbolEl, group, seriesModel);
  50480. return;
  50481. } // Update node and edge
  50482. updateNode(data, newIdx, symbolEl, group, seriesModel);
  50483. }).remove(function (oldIdx) {
  50484. var symbolEl = oldData.getItemGraphicEl(oldIdx); // When remove a collapsed node of subtree, since the collapsed
  50485. // node haven't been initialized with a symbol element,
  50486. // you can't found it's symbol element through index.
  50487. // so if we want to remove the symbol element we should insure
  50488. // that the symbol element is not null.
  50489. if (symbolEl) {
  50490. removeNode(oldData, oldIdx, symbolEl, group, seriesModel);
  50491. }
  50492. }).execute();
  50493. this._nodeScaleRatio = seriesModel.get('nodeScaleRatio');
  50494. this._updateNodeAndLinkScale(seriesModel);
  50495. if (seriesModel.get('expandAndCollapse') === true) {
  50496. data.eachItemGraphicEl(function (el, dataIndex) {
  50497. el.off('click').on('click', function () {
  50498. api.dispatchAction({
  50499. type: 'treeExpandAndCollapse',
  50500. seriesId: seriesModel.id,
  50501. dataIndex: dataIndex
  50502. });
  50503. });
  50504. });
  50505. }
  50506. this._data = data;
  50507. };
  50508. TreeView.prototype._updateViewCoordSys = function (seriesModel) {
  50509. var data = seriesModel.getData();
  50510. var points = [];
  50511. data.each(function (idx) {
  50512. var layout = data.getItemLayout(idx);
  50513. if (layout && !isNaN(layout.x) && !isNaN(layout.y)) {
  50514. points.push([+layout.x, +layout.y]);
  50515. }
  50516. });
  50517. var min = [];
  50518. var max = [];
  50519. fromPoints(points, min, max); // If don't Store min max when collapse the root node after roam,
  50520. // the root node will disappear.
  50521. var oldMin = this._min;
  50522. var oldMax = this._max; // If width or height is 0
  50523. if (max[0] - min[0] === 0) {
  50524. min[0] = oldMin ? oldMin[0] : min[0] - 1;
  50525. max[0] = oldMax ? oldMax[0] : max[0] + 1;
  50526. }
  50527. if (max[1] - min[1] === 0) {
  50528. min[1] = oldMin ? oldMin[1] : min[1] - 1;
  50529. max[1] = oldMax ? oldMax[1] : max[1] + 1;
  50530. }
  50531. var viewCoordSys = seriesModel.coordinateSystem = new View();
  50532. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  50533. viewCoordSys.setBoundingRect(min[0], min[1], max[0] - min[0], max[1] - min[1]);
  50534. viewCoordSys.setCenter(seriesModel.get('center'));
  50535. viewCoordSys.setZoom(seriesModel.get('zoom')); // Here we use viewCoordSys just for computing the 'position' and 'scale' of the group
  50536. this.group.attr({
  50537. x: viewCoordSys.x,
  50538. y: viewCoordSys.y,
  50539. scaleX: viewCoordSys.scaleX,
  50540. scaleY: viewCoordSys.scaleY
  50541. });
  50542. this._min = min;
  50543. this._max = max;
  50544. };
  50545. TreeView.prototype._updateController = function (seriesModel, ecModel, api) {
  50546. var _this = this;
  50547. var controller = this._controller;
  50548. var controllerHost = this._controllerHost;
  50549. var group = this.group;
  50550. controller.setPointerChecker(function (e, x, y) {
  50551. var rect = group.getBoundingRect();
  50552. rect.applyTransform(group.transform);
  50553. return rect.contain(x, y) && !onIrrelevantElement(e, api, seriesModel);
  50554. });
  50555. controller.enable(seriesModel.get('roam'));
  50556. controllerHost.zoomLimit = seriesModel.get('scaleLimit');
  50557. controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
  50558. controller.off('pan').off('zoom').on('pan', function (e) {
  50559. updateViewOnPan(controllerHost, e.dx, e.dy);
  50560. api.dispatchAction({
  50561. seriesId: seriesModel.id,
  50562. type: 'treeRoam',
  50563. dx: e.dx,
  50564. dy: e.dy
  50565. });
  50566. }).on('zoom', function (e) {
  50567. updateViewOnZoom(controllerHost, e.scale, e.originX, e.originY);
  50568. api.dispatchAction({
  50569. seriesId: seriesModel.id,
  50570. type: 'treeRoam',
  50571. zoom: e.scale,
  50572. originX: e.originX,
  50573. originY: e.originY
  50574. });
  50575. _this._updateNodeAndLinkScale(seriesModel); // Only update label layout on zoom
  50576. api.updateLabelLayout();
  50577. });
  50578. };
  50579. TreeView.prototype._updateNodeAndLinkScale = function (seriesModel) {
  50580. var data = seriesModel.getData();
  50581. var nodeScale = this._getNodeGlobalScale(seriesModel);
  50582. data.eachItemGraphicEl(function (el, idx) {
  50583. el.setSymbolScale(nodeScale);
  50584. });
  50585. };
  50586. TreeView.prototype._getNodeGlobalScale = function (seriesModel) {
  50587. var coordSys = seriesModel.coordinateSystem;
  50588. if (coordSys.type !== 'view') {
  50589. return 1;
  50590. }
  50591. var nodeScaleRatio = this._nodeScaleRatio;
  50592. var groupZoom = coordSys.scaleX || 1; // Scale node when zoom changes
  50593. var roamZoom = coordSys.getZoom();
  50594. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  50595. return nodeScale / groupZoom;
  50596. };
  50597. TreeView.prototype.dispose = function () {
  50598. this._controller && this._controller.dispose();
  50599. this._controllerHost = null;
  50600. };
  50601. TreeView.prototype.remove = function () {
  50602. this._mainGroup.removeAll();
  50603. this._data = null;
  50604. };
  50605. TreeView.type = 'tree';
  50606. return TreeView;
  50607. }(ChartView);
  50608. function symbolNeedsDraw$1(data, dataIndex) {
  50609. var layout = data.getItemLayout(dataIndex);
  50610. return layout && !isNaN(layout.x) && !isNaN(layout.y);
  50611. }
  50612. function updateNode(data, dataIndex, symbolEl, group, seriesModel) {
  50613. var isInit = !symbolEl;
  50614. var node = data.tree.getNodeByDataIndex(dataIndex);
  50615. var itemModel = node.getModel();
  50616. var visualColor = node.getVisual('style').fill;
  50617. var symbolInnerColor = node.isExpand === false && node.children.length !== 0 ? visualColor : '#fff';
  50618. var virtualRoot = data.tree.root;
  50619. var source = node.parentNode === virtualRoot ? node : node.parentNode || node;
  50620. var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
  50621. var sourceLayout = source.getLayout();
  50622. var sourceOldLayout = sourceSymbolEl ? {
  50623. x: sourceSymbolEl.__oldX,
  50624. y: sourceSymbolEl.__oldY,
  50625. rawX: sourceSymbolEl.__radialOldRawX,
  50626. rawY: sourceSymbolEl.__radialOldRawY
  50627. } : sourceLayout;
  50628. var targetLayout = node.getLayout();
  50629. if (isInit) {
  50630. symbolEl = new Symbol$1(data, dataIndex, null, {
  50631. symbolInnerColor: symbolInnerColor,
  50632. useNameLabel: true
  50633. });
  50634. symbolEl.x = sourceOldLayout.x;
  50635. symbolEl.y = sourceOldLayout.y;
  50636. } else {
  50637. symbolEl.updateData(data, dataIndex, null, {
  50638. symbolInnerColor: symbolInnerColor,
  50639. useNameLabel: true
  50640. });
  50641. }
  50642. symbolEl.__radialOldRawX = symbolEl.__radialRawX;
  50643. symbolEl.__radialOldRawY = symbolEl.__radialRawY;
  50644. symbolEl.__radialRawX = targetLayout.rawX;
  50645. symbolEl.__radialRawY = targetLayout.rawY;
  50646. group.add(symbolEl);
  50647. data.setItemGraphicEl(dataIndex, symbolEl);
  50648. symbolEl.__oldX = symbolEl.x;
  50649. symbolEl.__oldY = symbolEl.y;
  50650. updateProps(symbolEl, {
  50651. x: targetLayout.x,
  50652. y: targetLayout.y
  50653. }, seriesModel);
  50654. var symbolPath = symbolEl.getSymbolPath();
  50655. if (seriesModel.get('layout') === 'radial') {
  50656. var realRoot = virtualRoot.children[0];
  50657. var rootLayout = realRoot.getLayout();
  50658. var length_1 = realRoot.children.length;
  50659. var rad = void 0;
  50660. var isLeft = void 0;
  50661. if (targetLayout.x === rootLayout.x && node.isExpand === true) {
  50662. var center = {
  50663. x: (realRoot.children[0].getLayout().x + realRoot.children[length_1 - 1].getLayout().x) / 2,
  50664. y: (realRoot.children[0].getLayout().y + realRoot.children[length_1 - 1].getLayout().y) / 2
  50665. };
  50666. rad = Math.atan2(center.y - rootLayout.y, center.x - rootLayout.x);
  50667. if (rad < 0) {
  50668. rad = Math.PI * 2 + rad;
  50669. }
  50670. isLeft = center.x < rootLayout.x;
  50671. if (isLeft) {
  50672. rad = rad - Math.PI;
  50673. }
  50674. } else {
  50675. rad = Math.atan2(targetLayout.y - rootLayout.y, targetLayout.x - rootLayout.x);
  50676. if (rad < 0) {
  50677. rad = Math.PI * 2 + rad;
  50678. }
  50679. if (node.children.length === 0 || node.children.length !== 0 && node.isExpand === false) {
  50680. isLeft = targetLayout.x < rootLayout.x;
  50681. if (isLeft) {
  50682. rad = rad - Math.PI;
  50683. }
  50684. } else {
  50685. isLeft = targetLayout.x > rootLayout.x;
  50686. if (!isLeft) {
  50687. rad = rad - Math.PI;
  50688. }
  50689. }
  50690. }
  50691. var textPosition = isLeft ? 'left' : 'right';
  50692. var normalLabelModel = itemModel.getModel('label');
  50693. var rotate = normalLabelModel.get('rotate');
  50694. var labelRotateRadian = rotate * (Math.PI / 180);
  50695. var textContent = symbolPath.getTextContent();
  50696. if (textContent) {
  50697. symbolPath.setTextConfig({
  50698. position: normalLabelModel.get('position') || textPosition,
  50699. rotation: rotate == null ? -rad : labelRotateRadian,
  50700. origin: 'center'
  50701. });
  50702. textContent.setStyle('verticalAlign', 'middle');
  50703. }
  50704. } // Handle status
  50705. var focus = itemModel.get(['emphasis', 'focus']);
  50706. var focusDataIndices = focus === 'ancestor' ? node.getAncestorsIndices() : focus === 'descendant' ? node.getDescendantIndices() : null;
  50707. if (focusDataIndices) {
  50708. // Modify the focus to data indices.
  50709. getECData(symbolEl).focus = focusDataIndices;
  50710. }
  50711. drawEdge(seriesModel, node, virtualRoot, symbolEl, sourceOldLayout, sourceLayout, targetLayout, group);
  50712. if (symbolEl.__edge) {
  50713. symbolEl.onHoverStateChange = function (toState) {
  50714. if (toState !== 'blur') {
  50715. // NOTE: Ensure the parent elements will been blurred firstly.
  50716. // According to the return of getAncestorsIndices and getDescendantIndices
  50717. // TODO: A bit tricky.
  50718. var parentEl = node.parentNode && data.getItemGraphicEl(node.parentNode.dataIndex);
  50719. if (!(parentEl && parentEl.hoverState === HOVER_STATE_BLUR)) {
  50720. setStatesFlag(symbolEl.__edge, toState);
  50721. }
  50722. }
  50723. };
  50724. }
  50725. }
  50726. function drawEdge(seriesModel, node, virtualRoot, symbolEl, sourceOldLayout, sourceLayout, targetLayout, group) {
  50727. var itemModel = node.getModel();
  50728. var edgeShape = seriesModel.get('edgeShape');
  50729. var layout = seriesModel.get('layout');
  50730. var orient = seriesModel.getOrient();
  50731. var curvature = seriesModel.get(['lineStyle', 'curveness']);
  50732. var edgeForkPosition = seriesModel.get('edgeForkPosition');
  50733. var lineStyle = itemModel.getModel('lineStyle').getLineStyle();
  50734. var edge = symbolEl.__edge;
  50735. if (edgeShape === 'curve') {
  50736. if (node.parentNode && node.parentNode !== virtualRoot) {
  50737. if (!edge) {
  50738. edge = symbolEl.__edge = new BezierCurve({
  50739. shape: getEdgeShape(layout, orient, curvature, sourceOldLayout, sourceOldLayout)
  50740. });
  50741. }
  50742. updateProps(edge, {
  50743. shape: getEdgeShape(layout, orient, curvature, sourceLayout, targetLayout)
  50744. }, seriesModel);
  50745. }
  50746. } else if (edgeShape === 'polyline') {
  50747. if (layout === 'orthogonal') {
  50748. if (node !== virtualRoot && node.children && node.children.length !== 0 && node.isExpand === true) {
  50749. var children = node.children;
  50750. var childPoints = [];
  50751. for (var i = 0; i < children.length; i++) {
  50752. var childLayout = children[i].getLayout();
  50753. childPoints.push([childLayout.x, childLayout.y]);
  50754. }
  50755. if (!edge) {
  50756. edge = symbolEl.__edge = new TreePath({
  50757. shape: {
  50758. parentPoint: [targetLayout.x, targetLayout.y],
  50759. childPoints: [[targetLayout.x, targetLayout.y]],
  50760. orient: orient,
  50761. forkPosition: edgeForkPosition
  50762. }
  50763. });
  50764. }
  50765. updateProps(edge, {
  50766. shape: {
  50767. parentPoint: [targetLayout.x, targetLayout.y],
  50768. childPoints: childPoints
  50769. }
  50770. }, seriesModel);
  50771. }
  50772. } else {
  50773. {
  50774. throw new Error('The polyline edgeShape can only be used in orthogonal layout');
  50775. }
  50776. }
  50777. }
  50778. if (edge) {
  50779. edge.useStyle(defaults({
  50780. strokeNoScale: true,
  50781. fill: null
  50782. }, lineStyle));
  50783. setStatesStylesFromModel(edge, itemModel, 'lineStyle');
  50784. setDefaultStateProxy(edge);
  50785. group.add(edge);
  50786. }
  50787. }
  50788. function removeNode(data, dataIndex, symbolEl, group, seriesModel) {
  50789. var node = data.tree.getNodeByDataIndex(dataIndex);
  50790. var virtualRoot = data.tree.root;
  50791. var source = node.parentNode === virtualRoot ? node : node.parentNode || node; // let edgeShape = seriesScope.edgeShape;
  50792. var sourceLayout;
  50793. while (sourceLayout = source.getLayout(), sourceLayout == null) {
  50794. source = source.parentNode === virtualRoot ? source : source.parentNode || source;
  50795. } // Use same duration and easing with update to have more consistent animation.
  50796. var removeAnimationOpt = {
  50797. duration: seriesModel.get('animationDurationUpdate'),
  50798. easing: seriesModel.get('animationEasingUpdate')
  50799. };
  50800. removeElement(symbolEl, {
  50801. x: sourceLayout.x + 1,
  50802. y: sourceLayout.y + 1
  50803. }, seriesModel, {
  50804. cb: function () {
  50805. group.remove(symbolEl);
  50806. data.setItemGraphicEl(dataIndex, null);
  50807. },
  50808. removeOpt: removeAnimationOpt
  50809. });
  50810. symbolEl.fadeOut(null, {
  50811. fadeLabel: true,
  50812. animation: removeAnimationOpt
  50813. });
  50814. var sourceSymbolEl = data.getItemGraphicEl(source.dataIndex);
  50815. var sourceEdge = sourceSymbolEl.__edge; // 1. when expand the sub tree, delete the children node should delete the edge of
  50816. // the source at the same time. because the polyline edge shape is only owned by the source.
  50817. // 2.when the node is the only children of the source, delete the node should delete the edge of
  50818. // the source at the same time. the same reason as above.
  50819. var edge = symbolEl.__edge || (source.isExpand === false || source.children.length === 1 ? sourceEdge : undefined);
  50820. var edgeShape = seriesModel.get('edgeShape');
  50821. var layoutOpt = seriesModel.get('layout');
  50822. var orient = seriesModel.get('orient');
  50823. var curvature = seriesModel.get(['lineStyle', 'curveness']);
  50824. if (edge) {
  50825. if (edgeShape === 'curve') {
  50826. removeElement(edge, {
  50827. shape: getEdgeShape(layoutOpt, orient, curvature, sourceLayout, sourceLayout),
  50828. style: {
  50829. opacity: 0
  50830. }
  50831. }, seriesModel, {
  50832. cb: function () {
  50833. group.remove(edge);
  50834. },
  50835. removeOpt: removeAnimationOpt
  50836. });
  50837. } else if (edgeShape === 'polyline' && seriesModel.get('layout') === 'orthogonal') {
  50838. removeElement(edge, {
  50839. shape: {
  50840. parentPoint: [sourceLayout.x, sourceLayout.y],
  50841. childPoints: [[sourceLayout.x, sourceLayout.y]]
  50842. },
  50843. style: {
  50844. opacity: 0
  50845. }
  50846. }, seriesModel, {
  50847. cb: function () {
  50848. group.remove(edge);
  50849. },
  50850. removeOpt: removeAnimationOpt
  50851. });
  50852. }
  50853. }
  50854. }
  50855. function getEdgeShape(layoutOpt, orient, curvature, sourceLayout, targetLayout) {
  50856. var cpx1;
  50857. var cpy1;
  50858. var cpx2;
  50859. var cpy2;
  50860. var x1;
  50861. var x2;
  50862. var y1;
  50863. var y2;
  50864. if (layoutOpt === 'radial') {
  50865. x1 = sourceLayout.rawX;
  50866. y1 = sourceLayout.rawY;
  50867. x2 = targetLayout.rawX;
  50868. y2 = targetLayout.rawY;
  50869. var radialCoor1 = radialCoordinate(x1, y1);
  50870. var radialCoor2 = radialCoordinate(x1, y1 + (y2 - y1) * curvature);
  50871. var radialCoor3 = radialCoordinate(x2, y2 + (y1 - y2) * curvature);
  50872. var radialCoor4 = radialCoordinate(x2, y2);
  50873. return {
  50874. x1: radialCoor1.x || 0,
  50875. y1: radialCoor1.y || 0,
  50876. x2: radialCoor4.x || 0,
  50877. y2: radialCoor4.y || 0,
  50878. cpx1: radialCoor2.x || 0,
  50879. cpy1: radialCoor2.y || 0,
  50880. cpx2: radialCoor3.x || 0,
  50881. cpy2: radialCoor3.y || 0
  50882. };
  50883. } else {
  50884. x1 = sourceLayout.x;
  50885. y1 = sourceLayout.y;
  50886. x2 = targetLayout.x;
  50887. y2 = targetLayout.y;
  50888. if (orient === 'LR' || orient === 'RL') {
  50889. cpx1 = x1 + (x2 - x1) * curvature;
  50890. cpy1 = y1;
  50891. cpx2 = x2 + (x1 - x2) * curvature;
  50892. cpy2 = y2;
  50893. }
  50894. if (orient === 'TB' || orient === 'BT') {
  50895. cpx1 = x1;
  50896. cpy1 = y1 + (y2 - y1) * curvature;
  50897. cpx2 = x2;
  50898. cpy2 = y2 + (y1 - y2) * curvature;
  50899. }
  50900. }
  50901. return {
  50902. x1: x1,
  50903. y1: y1,
  50904. x2: x2,
  50905. y2: y2,
  50906. cpx1: cpx1,
  50907. cpy1: cpy1,
  50908. cpx2: cpx2,
  50909. cpy2: cpy2
  50910. };
  50911. }
  50912. /*
  50913. * Licensed to the Apache Software Foundation (ASF) under one
  50914. * or more contributor license agreements. See the NOTICE file
  50915. * distributed with this work for additional information
  50916. * regarding copyright ownership. The ASF licenses this file
  50917. * to you under the Apache License, Version 2.0 (the
  50918. * "License"); you may not use this file except in compliance
  50919. * with the License. You may obtain a copy of the License at
  50920. *
  50921. * http://www.apache.org/licenses/LICENSE-2.0
  50922. *
  50923. * Unless required by applicable law or agreed to in writing,
  50924. * software distributed under the License is distributed on an
  50925. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50926. * KIND, either express or implied. See the License for the
  50927. * specific language governing permissions and limitations
  50928. * under the License.
  50929. */
  50930. /**
  50931. * AUTO-GENERATED FILE. DO NOT MODIFY.
  50932. */
  50933. /*
  50934. * Licensed to the Apache Software Foundation (ASF) under one
  50935. * or more contributor license agreements. See the NOTICE file
  50936. * distributed with this work for additional information
  50937. * regarding copyright ownership. The ASF licenses this file
  50938. * to you under the Apache License, Version 2.0 (the
  50939. * "License"); you may not use this file except in compliance
  50940. * with the License. You may obtain a copy of the License at
  50941. *
  50942. * http://www.apache.org/licenses/LICENSE-2.0
  50943. *
  50944. * Unless required by applicable law or agreed to in writing,
  50945. * software distributed under the License is distributed on an
  50946. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  50947. * KIND, either express or implied. See the License for the
  50948. * specific language governing permissions and limitations
  50949. * under the License.
  50950. */
  50951. /**
  50952. * Link lists and struct (graph or tree)
  50953. */
  50954. var inner$6 = makeInner();
  50955. function linkList(opt) {
  50956. var mainData = opt.mainData;
  50957. var datas = opt.datas;
  50958. if (!datas) {
  50959. datas = {
  50960. main: mainData
  50961. };
  50962. opt.datasAttr = {
  50963. main: 'data'
  50964. };
  50965. }
  50966. opt.datas = opt.mainData = null;
  50967. linkAll(mainData, datas, opt); // Porxy data original methods.
  50968. each$1(datas, function (data) {
  50969. each$1(mainData.TRANSFERABLE_METHODS, function (methodName) {
  50970. data.wrapMethod(methodName, curry(transferInjection, opt));
  50971. });
  50972. }); // Beyond transfer, additional features should be added to `cloneShallow`.
  50973. mainData.wrapMethod('cloneShallow', curry(cloneShallowInjection, opt)); // Only mainData trigger change, because struct.update may trigger
  50974. // another changable methods, which may bring about dead lock.
  50975. each$1(mainData.CHANGABLE_METHODS, function (methodName) {
  50976. mainData.wrapMethod(methodName, curry(changeInjection, opt));
  50977. }); // Make sure datas contains mainData.
  50978. assert$1(datas[mainData.dataType] === mainData);
  50979. }
  50980. function transferInjection(opt, res) {
  50981. if (isMainData(this)) {
  50982. // Transfer datas to new main data.
  50983. var datas = extend({}, inner$6(this).datas);
  50984. datas[this.dataType] = res;
  50985. linkAll(res, datas, opt);
  50986. } else {
  50987. // Modify the reference in main data to point newData.
  50988. linkSingle(res, this.dataType, inner$6(this).mainData, opt);
  50989. }
  50990. return res;
  50991. }
  50992. function changeInjection(opt, res) {
  50993. opt.struct && opt.struct.update();
  50994. return res;
  50995. }
  50996. function cloneShallowInjection(opt, res) {
  50997. // cloneShallow, which brings about some fragilities, may be inappropriate
  50998. // to be exposed as an API. So for implementation simplicity we can make
  50999. // the restriction that cloneShallow of not-mainData should not be invoked
  51000. // outside, but only be invoked here.
  51001. each$1(inner$6(res).datas, function (data, dataType) {
  51002. data !== res && linkSingle(data.cloneShallow(), dataType, res, opt);
  51003. });
  51004. return res;
  51005. }
  51006. /**
  51007. * Supplement method to List.
  51008. *
  51009. * @public
  51010. * @param [dataType] If not specified, return mainData.
  51011. */
  51012. function getLinkedData(dataType) {
  51013. var mainData = inner$6(this).mainData;
  51014. return dataType == null || mainData == null ? mainData : inner$6(mainData).datas[dataType];
  51015. }
  51016. /**
  51017. * Get list of all linked data
  51018. */
  51019. function getLinkedDataAll() {
  51020. var mainData = inner$6(this).mainData;
  51021. return mainData == null ? [{
  51022. data: mainData
  51023. }] : map(keys(inner$6(mainData).datas), function (type) {
  51024. return {
  51025. type: type,
  51026. data: inner$6(mainData).datas[type]
  51027. };
  51028. });
  51029. }
  51030. function isMainData(data) {
  51031. return inner$6(data).mainData === data;
  51032. }
  51033. function linkAll(mainData, datas, opt) {
  51034. inner$6(mainData).datas = {};
  51035. each$1(datas, function (data, dataType) {
  51036. linkSingle(data, dataType, mainData, opt);
  51037. });
  51038. }
  51039. function linkSingle(data, dataType, mainData, opt) {
  51040. inner$6(mainData).datas[dataType] = data;
  51041. inner$6(data).mainData = mainData;
  51042. data.dataType = dataType;
  51043. if (opt.struct) {
  51044. data[opt.structAttr] = opt.struct;
  51045. opt.struct[opt.datasAttr[dataType]] = data;
  51046. } // Supplement method.
  51047. data.getLinkedData = getLinkedData;
  51048. data.getLinkedDataAll = getLinkedDataAll;
  51049. }
  51050. /*
  51051. * Licensed to the Apache Software Foundation (ASF) under one
  51052. * or more contributor license agreements. See the NOTICE file
  51053. * distributed with this work for additional information
  51054. * regarding copyright ownership. The ASF licenses this file
  51055. * to you under the Apache License, Version 2.0 (the
  51056. * "License"); you may not use this file except in compliance
  51057. * with the License. You may obtain a copy of the License at
  51058. *
  51059. * http://www.apache.org/licenses/LICENSE-2.0
  51060. *
  51061. * Unless required by applicable law or agreed to in writing,
  51062. * software distributed under the License is distributed on an
  51063. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51064. * KIND, either express or implied. See the License for the
  51065. * specific language governing permissions and limitations
  51066. * under the License.
  51067. */
  51068. /**
  51069. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51070. */
  51071. /*
  51072. * Licensed to the Apache Software Foundation (ASF) under one
  51073. * or more contributor license agreements. See the NOTICE file
  51074. * distributed with this work for additional information
  51075. * regarding copyright ownership. The ASF licenses this file
  51076. * to you under the Apache License, Version 2.0 (the
  51077. * "License"); you may not use this file except in compliance
  51078. * with the License. You may obtain a copy of the License at
  51079. *
  51080. * http://www.apache.org/licenses/LICENSE-2.0
  51081. *
  51082. * Unless required by applicable law or agreed to in writing,
  51083. * software distributed under the License is distributed on an
  51084. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51085. * KIND, either express or implied. See the License for the
  51086. * specific language governing permissions and limitations
  51087. * under the License.
  51088. */
  51089. /**
  51090. * Tree data structure
  51091. */
  51092. var TreeNode =
  51093. /** @class */
  51094. function () {
  51095. function TreeNode(name, hostTree) {
  51096. this.depth = 0;
  51097. this.height = 0;
  51098. /**
  51099. * Reference to list item.
  51100. * Do not persistent dataIndex outside,
  51101. * besause it may be changed by list.
  51102. * If dataIndex -1,
  51103. * this node is logical deleted (filtered) in list.
  51104. */
  51105. this.dataIndex = -1;
  51106. this.children = [];
  51107. this.viewChildren = [];
  51108. this.isExpand = false;
  51109. this.name = name || '';
  51110. this.hostTree = hostTree;
  51111. }
  51112. /**
  51113. * The node is removed.
  51114. */
  51115. TreeNode.prototype.isRemoved = function () {
  51116. return this.dataIndex < 0;
  51117. };
  51118. TreeNode.prototype.eachNode = function (options, cb, context) {
  51119. if (typeof options === 'function') {
  51120. context = cb;
  51121. cb = options;
  51122. options = null;
  51123. }
  51124. options = options || {};
  51125. if (isString(options)) {
  51126. options = {
  51127. order: options
  51128. };
  51129. }
  51130. var order = options.order || 'preorder';
  51131. var children = this[options.attr || 'children'];
  51132. var suppressVisitSub;
  51133. order === 'preorder' && (suppressVisitSub = cb.call(context, this));
  51134. for (var i = 0; !suppressVisitSub && i < children.length; i++) {
  51135. children[i].eachNode(options, cb, context);
  51136. }
  51137. order === 'postorder' && cb.call(context, this);
  51138. };
  51139. /**
  51140. * Update depth and height of this subtree.
  51141. */
  51142. TreeNode.prototype.updateDepthAndHeight = function (depth) {
  51143. var height = 0;
  51144. this.depth = depth;
  51145. for (var i = 0; i < this.children.length; i++) {
  51146. var child = this.children[i];
  51147. child.updateDepthAndHeight(depth + 1);
  51148. if (child.height > height) {
  51149. height = child.height;
  51150. }
  51151. }
  51152. this.height = height + 1;
  51153. };
  51154. TreeNode.prototype.getNodeById = function (id) {
  51155. if (this.getId() === id) {
  51156. return this;
  51157. }
  51158. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  51159. var res = children[i].getNodeById(id);
  51160. if (res) {
  51161. return res;
  51162. }
  51163. }
  51164. };
  51165. TreeNode.prototype.contains = function (node) {
  51166. if (node === this) {
  51167. return true;
  51168. }
  51169. for (var i = 0, children = this.children, len = children.length; i < len; i++) {
  51170. var res = children[i].contains(node);
  51171. if (res) {
  51172. return res;
  51173. }
  51174. }
  51175. };
  51176. /**
  51177. * @param includeSelf Default false.
  51178. * @return order: [root, child, grandchild, ...]
  51179. */
  51180. TreeNode.prototype.getAncestors = function (includeSelf) {
  51181. var ancestors = [];
  51182. var node = includeSelf ? this : this.parentNode;
  51183. while (node) {
  51184. ancestors.push(node);
  51185. node = node.parentNode;
  51186. }
  51187. ancestors.reverse();
  51188. return ancestors;
  51189. };
  51190. TreeNode.prototype.getAncestorsIndices = function () {
  51191. var indices = [];
  51192. var currNode = this;
  51193. while (currNode) {
  51194. indices.push(currNode.dataIndex);
  51195. currNode = currNode.parentNode;
  51196. }
  51197. indices.reverse();
  51198. return indices;
  51199. };
  51200. TreeNode.prototype.getDescendantIndices = function () {
  51201. var indices = [];
  51202. this.eachNode(function (childNode) {
  51203. indices.push(childNode.dataIndex);
  51204. });
  51205. return indices;
  51206. };
  51207. TreeNode.prototype.getValue = function (dimension) {
  51208. var data = this.hostTree.data;
  51209. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  51210. };
  51211. TreeNode.prototype.setLayout = function (layout, merge$$1) {
  51212. this.dataIndex >= 0 && this.hostTree.data.setItemLayout(this.dataIndex, layout, merge$$1);
  51213. };
  51214. /**
  51215. * @return {Object} layout
  51216. */
  51217. TreeNode.prototype.getLayout = function () {
  51218. return this.hostTree.data.getItemLayout(this.dataIndex);
  51219. }; // @depcrecated
  51220. // getModel<T = unknown, S extends keyof T = keyof T>(path: S): Model<T[S]>
  51221. TreeNode.prototype.getModel = function (path) {
  51222. if (this.dataIndex < 0) {
  51223. return;
  51224. }
  51225. var hostTree = this.hostTree;
  51226. var itemModel = hostTree.data.getItemModel(this.dataIndex);
  51227. return itemModel.getModel(path);
  51228. }; // TODO: TYPE More specific model
  51229. TreeNode.prototype.getLevelModel = function () {
  51230. return (this.hostTree.levelModels || [])[this.depth];
  51231. };
  51232. TreeNode.prototype.setVisual = function (key, value) {
  51233. this.dataIndex >= 0 && this.hostTree.data.setItemVisual(this.dataIndex, key, value);
  51234. };
  51235. /**
  51236. * Get item visual
  51237. * FIXME: make return type better
  51238. */
  51239. TreeNode.prototype.getVisual = function (key) {
  51240. return this.hostTree.data.getItemVisual(this.dataIndex, key);
  51241. };
  51242. TreeNode.prototype.getRawIndex = function () {
  51243. return this.hostTree.data.getRawIndex(this.dataIndex);
  51244. };
  51245. TreeNode.prototype.getId = function () {
  51246. return this.hostTree.data.getId(this.dataIndex);
  51247. };
  51248. /**
  51249. * if this is an ancestor of another node
  51250. *
  51251. * @param node another node
  51252. * @return if is ancestor
  51253. */
  51254. TreeNode.prototype.isAncestorOf = function (node) {
  51255. var parent = node.parentNode;
  51256. while (parent) {
  51257. if (parent === this) {
  51258. return true;
  51259. }
  51260. parent = parent.parentNode;
  51261. }
  51262. return false;
  51263. };
  51264. /**
  51265. * if this is an descendant of another node
  51266. *
  51267. * @param node another node
  51268. * @return if is descendant
  51269. */
  51270. TreeNode.prototype.isDescendantOf = function (node) {
  51271. return node !== this && node.isAncestorOf(this);
  51272. };
  51273. return TreeNode;
  51274. }();
  51275. var Tree =
  51276. /** @class */
  51277. function () {
  51278. function Tree(hostModel) {
  51279. this.type = 'tree';
  51280. this._nodes = [];
  51281. this.hostModel = hostModel;
  51282. }
  51283. Tree.prototype.eachNode = function (options, cb, context) {
  51284. this.root.eachNode(options, cb, context);
  51285. };
  51286. Tree.prototype.getNodeByDataIndex = function (dataIndex) {
  51287. var rawIndex = this.data.getRawIndex(dataIndex);
  51288. return this._nodes[rawIndex];
  51289. };
  51290. Tree.prototype.getNodeById = function (name) {
  51291. return this.root.getNodeById(name);
  51292. };
  51293. /**
  51294. * Update item available by list,
  51295. * when list has been performed options like 'filterSelf' or 'map'.
  51296. */
  51297. Tree.prototype.update = function () {
  51298. var data = this.data;
  51299. var nodes = this._nodes;
  51300. for (var i = 0, len = nodes.length; i < len; i++) {
  51301. nodes[i].dataIndex = -1;
  51302. }
  51303. for (var i = 0, len = data.count(); i < len; i++) {
  51304. nodes[data.getRawIndex(i)].dataIndex = i;
  51305. }
  51306. };
  51307. /**
  51308. * Clear all layouts
  51309. */
  51310. Tree.prototype.clearLayouts = function () {
  51311. this.data.clearItemLayouts();
  51312. };
  51313. /**
  51314. * data node format:
  51315. * {
  51316. * name: ...
  51317. * value: ...
  51318. * children: [
  51319. * {
  51320. * name: ...
  51321. * value: ...
  51322. * children: ...
  51323. * },
  51324. * ...
  51325. * ]
  51326. * }
  51327. */
  51328. Tree.createTree = function (dataRoot, hostModel, beforeLink) {
  51329. var tree = new Tree(hostModel);
  51330. var listData = [];
  51331. var dimMax = 1;
  51332. buildHierarchy(dataRoot);
  51333. function buildHierarchy(dataNode, parentNode) {
  51334. var value = dataNode.value;
  51335. dimMax = Math.max(dimMax, isArray(value) ? value.length : 1);
  51336. listData.push(dataNode);
  51337. var node = new TreeNode(convertOptionIdName(dataNode.name, ''), tree);
  51338. parentNode ? addChild(node, parentNode) : tree.root = node;
  51339. tree._nodes.push(node);
  51340. var children = dataNode.children;
  51341. if (children) {
  51342. for (var i = 0; i < children.length; i++) {
  51343. buildHierarchy(children[i], node);
  51344. }
  51345. }
  51346. }
  51347. tree.root.updateDepthAndHeight(0);
  51348. var dimensionsInfo = createDimensions(listData, {
  51349. coordDimensions: ['value'],
  51350. dimensionsCount: dimMax
  51351. });
  51352. var list = new List(dimensionsInfo, hostModel);
  51353. list.initData(listData);
  51354. beforeLink && beforeLink(list);
  51355. linkList({
  51356. mainData: list,
  51357. struct: tree,
  51358. structAttr: 'tree'
  51359. });
  51360. tree.update();
  51361. return tree;
  51362. };
  51363. return Tree;
  51364. }();
  51365. /**
  51366. * It is needed to consider the mess of 'list', 'hostModel' when creating a TreeNote,
  51367. * so this function is not ready and not necessary to be public.
  51368. */
  51369. function addChild(child, node) {
  51370. var children = node.children;
  51371. if (child.parentNode === node) {
  51372. return;
  51373. }
  51374. children.push(child);
  51375. child.parentNode = node;
  51376. }
  51377. /*
  51378. * Licensed to the Apache Software Foundation (ASF) under one
  51379. * or more contributor license agreements. See the NOTICE file
  51380. * distributed with this work for additional information
  51381. * regarding copyright ownership. The ASF licenses this file
  51382. * to you under the Apache License, Version 2.0 (the
  51383. * "License"); you may not use this file except in compliance
  51384. * with the License. You may obtain a copy of the License at
  51385. *
  51386. * http://www.apache.org/licenses/LICENSE-2.0
  51387. *
  51388. * Unless required by applicable law or agreed to in writing,
  51389. * software distributed under the License is distributed on an
  51390. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51391. * KIND, either express or implied. See the License for the
  51392. * specific language governing permissions and limitations
  51393. * under the License.
  51394. */
  51395. /**
  51396. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51397. */
  51398. /*
  51399. * Licensed to the Apache Software Foundation (ASF) under one
  51400. * or more contributor license agreements. See the NOTICE file
  51401. * distributed with this work for additional information
  51402. * regarding copyright ownership. The ASF licenses this file
  51403. * to you under the Apache License, Version 2.0 (the
  51404. * "License"); you may not use this file except in compliance
  51405. * with the License. You may obtain a copy of the License at
  51406. *
  51407. * http://www.apache.org/licenses/LICENSE-2.0
  51408. *
  51409. * Unless required by applicable law or agreed to in writing,
  51410. * software distributed under the License is distributed on an
  51411. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51412. * KIND, either express or implied. See the License for the
  51413. * specific language governing permissions and limitations
  51414. * under the License.
  51415. */
  51416. var TreeSeriesModel =
  51417. /** @class */
  51418. function (_super) {
  51419. __extends(TreeSeriesModel, _super);
  51420. function TreeSeriesModel() {
  51421. var _this = _super !== null && _super.apply(this, arguments) || this;
  51422. _this.hasSymbolVisual = true; // Do it self.
  51423. _this.ignoreStyleOnData = true;
  51424. return _this;
  51425. }
  51426. /**
  51427. * Init a tree data structure from data in option series
  51428. * @param option the object used to config echarts view
  51429. * @return storage initial data
  51430. */
  51431. TreeSeriesModel.prototype.getInitialData = function (option) {
  51432. //create an virtual root
  51433. var root = {
  51434. name: option.name,
  51435. children: option.data
  51436. };
  51437. var leaves = option.leaves || {};
  51438. var leavesModel = new Model(leaves, this, this.ecModel);
  51439. var tree = Tree.createTree(root, this, beforeLink);
  51440. function beforeLink(nodeData) {
  51441. nodeData.wrapMethod('getItemModel', function (model, idx) {
  51442. var node = tree.getNodeByDataIndex(idx);
  51443. if (!node.children.length || !node.isExpand) {
  51444. model.parentModel = leavesModel;
  51445. }
  51446. return model;
  51447. });
  51448. }
  51449. var treeDepth = 0;
  51450. tree.eachNode('preorder', function (node) {
  51451. if (node.depth > treeDepth) {
  51452. treeDepth = node.depth;
  51453. }
  51454. });
  51455. var expandAndCollapse = option.expandAndCollapse;
  51456. var expandTreeDepth = expandAndCollapse && option.initialTreeDepth >= 0 ? option.initialTreeDepth : treeDepth;
  51457. tree.root.eachNode('preorder', function (node) {
  51458. var item = node.hostTree.data.getRawDataItem(node.dataIndex); // Add item.collapsed != null, because users can collapse node original in the series.data.
  51459. node.isExpand = item && item.collapsed != null ? !item.collapsed : node.depth <= expandTreeDepth;
  51460. });
  51461. return tree.data;
  51462. };
  51463. /**
  51464. * Make the configuration 'orient' backward compatibly, with 'horizontal = LR', 'vertical = TB'.
  51465. * @returns {string} orient
  51466. */
  51467. TreeSeriesModel.prototype.getOrient = function () {
  51468. var orient = this.get('orient');
  51469. if (orient === 'horizontal') {
  51470. orient = 'LR';
  51471. } else if (orient === 'vertical') {
  51472. orient = 'TB';
  51473. }
  51474. return orient;
  51475. };
  51476. TreeSeriesModel.prototype.setZoom = function (zoom) {
  51477. this.option.zoom = zoom;
  51478. };
  51479. TreeSeriesModel.prototype.setCenter = function (center) {
  51480. this.option.center = center;
  51481. };
  51482. TreeSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  51483. var tree = this.getData().tree;
  51484. var realRoot = tree.root.children[0];
  51485. var node = tree.getNodeByDataIndex(dataIndex);
  51486. var value = node.getValue();
  51487. var name = node.name;
  51488. while (node && node !== realRoot) {
  51489. name = node.parentNode.name + '.' + name;
  51490. node = node.parentNode;
  51491. }
  51492. return createTooltipMarkup('nameValue', {
  51493. name: name,
  51494. value: value,
  51495. noValue: isNaN(value) || value == null
  51496. });
  51497. };
  51498. TreeSeriesModel.type = 'series.tree'; // can support the position parameters 'left', 'top','right','bottom', 'width',
  51499. // 'height' in the setOption() with 'merge' mode normal.
  51500. TreeSeriesModel.layoutMode = 'box';
  51501. TreeSeriesModel.defaultOption = {
  51502. zlevel: 0,
  51503. z: 2,
  51504. coordinateSystem: 'view',
  51505. // the position of the whole view
  51506. left: '12%',
  51507. top: '12%',
  51508. right: '12%',
  51509. bottom: '12%',
  51510. // the layout of the tree, two value can be selected, 'orthogonal' or 'radial'
  51511. layout: 'orthogonal',
  51512. // value can be 'polyline'
  51513. edgeShape: 'curve',
  51514. edgeForkPosition: '50%',
  51515. // true | false | 'move' | 'scale', see module:component/helper/RoamController.
  51516. roam: false,
  51517. // Symbol size scale ratio in roam
  51518. nodeScaleRatio: 0.4,
  51519. // Default on center of graph
  51520. center: null,
  51521. zoom: 1,
  51522. orient: 'LR',
  51523. symbol: 'emptyCircle',
  51524. symbolSize: 7,
  51525. expandAndCollapse: true,
  51526. initialTreeDepth: 2,
  51527. lineStyle: {
  51528. color: '#ccc',
  51529. width: 1.5,
  51530. curveness: 0.5
  51531. },
  51532. itemStyle: {
  51533. color: 'lightsteelblue',
  51534. // borderColor: '#c23531',
  51535. borderWidth: 1.5
  51536. },
  51537. label: {
  51538. show: true
  51539. },
  51540. animationEasing: 'linear',
  51541. animationDuration: 700,
  51542. animationDurationUpdate: 500
  51543. };
  51544. return TreeSeriesModel;
  51545. }(SeriesModel);
  51546. /*
  51547. * Licensed to the Apache Software Foundation (ASF) under one
  51548. * or more contributor license agreements. See the NOTICE file
  51549. * distributed with this work for additional information
  51550. * regarding copyright ownership. The ASF licenses this file
  51551. * to you under the Apache License, Version 2.0 (the
  51552. * "License"); you may not use this file except in compliance
  51553. * with the License. You may obtain a copy of the License at
  51554. *
  51555. * http://www.apache.org/licenses/LICENSE-2.0
  51556. *
  51557. * Unless required by applicable law or agreed to in writing,
  51558. * software distributed under the License is distributed on an
  51559. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51560. * KIND, either express or implied. See the License for the
  51561. * specific language governing permissions and limitations
  51562. * under the License.
  51563. */
  51564. /**
  51565. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51566. */
  51567. /*
  51568. * Licensed to the Apache Software Foundation (ASF) under one
  51569. * or more contributor license agreements. See the NOTICE file
  51570. * distributed with this work for additional information
  51571. * regarding copyright ownership. The ASF licenses this file
  51572. * to you under the Apache License, Version 2.0 (the
  51573. * "License"); you may not use this file except in compliance
  51574. * with the License. You may obtain a copy of the License at
  51575. *
  51576. * http://www.apache.org/licenses/LICENSE-2.0
  51577. *
  51578. * Unless required by applicable law or agreed to in writing,
  51579. * software distributed under the License is distributed on an
  51580. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51581. * KIND, either express or implied. See the License for the
  51582. * specific language governing permissions and limitations
  51583. * under the License.
  51584. */
  51585. /**
  51586. * Traverse the tree from bottom to top and do something
  51587. */
  51588. function eachAfter(root, callback, separation) {
  51589. var nodes = [root];
  51590. var next = [];
  51591. var node;
  51592. while (node = nodes.pop()) {
  51593. // jshint ignore:line
  51594. next.push(node);
  51595. if (node.isExpand) {
  51596. var children = node.children;
  51597. if (children.length) {
  51598. for (var i = 0; i < children.length; i++) {
  51599. nodes.push(children[i]);
  51600. }
  51601. }
  51602. }
  51603. }
  51604. while (node = next.pop()) {
  51605. // jshint ignore:line
  51606. callback(node, separation);
  51607. }
  51608. }
  51609. /**
  51610. * Traverse the tree from top to bottom and do something
  51611. */
  51612. function eachBefore(root, callback) {
  51613. var nodes = [root];
  51614. var node;
  51615. while (node = nodes.pop()) {
  51616. // jshint ignore:line
  51617. callback(node);
  51618. if (node.isExpand) {
  51619. var children = node.children;
  51620. if (children.length) {
  51621. for (var i = children.length - 1; i >= 0; i--) {
  51622. nodes.push(children[i]);
  51623. }
  51624. }
  51625. }
  51626. }
  51627. }
  51628. /*
  51629. * Licensed to the Apache Software Foundation (ASF) under one
  51630. * or more contributor license agreements. See the NOTICE file
  51631. * distributed with this work for additional information
  51632. * regarding copyright ownership. The ASF licenses this file
  51633. * to you under the Apache License, Version 2.0 (the
  51634. * "License"); you may not use this file except in compliance
  51635. * with the License. You may obtain a copy of the License at
  51636. *
  51637. * http://www.apache.org/licenses/LICENSE-2.0
  51638. *
  51639. * Unless required by applicable law or agreed to in writing,
  51640. * software distributed under the License is distributed on an
  51641. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51642. * KIND, either express or implied. See the License for the
  51643. * specific language governing permissions and limitations
  51644. * under the License.
  51645. */
  51646. /**
  51647. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51648. */
  51649. /*
  51650. * Licensed to the Apache Software Foundation (ASF) under one
  51651. * or more contributor license agreements. See the NOTICE file
  51652. * distributed with this work for additional information
  51653. * regarding copyright ownership. The ASF licenses this file
  51654. * to you under the Apache License, Version 2.0 (the
  51655. * "License"); you may not use this file except in compliance
  51656. * with the License. You may obtain a copy of the License at
  51657. *
  51658. * http://www.apache.org/licenses/LICENSE-2.0
  51659. *
  51660. * Unless required by applicable law or agreed to in writing,
  51661. * software distributed under the License is distributed on an
  51662. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51663. * KIND, either express or implied. See the License for the
  51664. * specific language governing permissions and limitations
  51665. * under the License.
  51666. */
  51667. function treeLayout(ecModel, api) {
  51668. ecModel.eachSeriesByType('tree', function (seriesModel) {
  51669. commonLayout(seriesModel, api);
  51670. });
  51671. }
  51672. function commonLayout(seriesModel, api) {
  51673. var layoutInfo = getViewRect$1(seriesModel, api);
  51674. seriesModel.layoutInfo = layoutInfo;
  51675. var layout = seriesModel.get('layout');
  51676. var width = 0;
  51677. var height = 0;
  51678. var separation$$1 = null;
  51679. if (layout === 'radial') {
  51680. width = 2 * Math.PI;
  51681. height = Math.min(layoutInfo.height, layoutInfo.width) / 2;
  51682. separation$$1 = separation(function (node1, node2) {
  51683. return (node1.parentNode === node2.parentNode ? 1 : 2) / node1.depth;
  51684. });
  51685. } else {
  51686. width = layoutInfo.width;
  51687. height = layoutInfo.height;
  51688. separation$$1 = separation();
  51689. }
  51690. var virtualRoot = seriesModel.getData().tree.root;
  51691. var realRoot = virtualRoot.children[0];
  51692. if (realRoot) {
  51693. init$2(virtualRoot);
  51694. eachAfter(realRoot, firstWalk, separation$$1);
  51695. virtualRoot.hierNode.modifier = -realRoot.hierNode.prelim;
  51696. eachBefore(realRoot, secondWalk);
  51697. var left_1 = realRoot;
  51698. var right_1 = realRoot;
  51699. var bottom_1 = realRoot;
  51700. eachBefore(realRoot, function (node) {
  51701. var x = node.getLayout().x;
  51702. if (x < left_1.getLayout().x) {
  51703. left_1 = node;
  51704. }
  51705. if (x > right_1.getLayout().x) {
  51706. right_1 = node;
  51707. }
  51708. if (node.depth > bottom_1.depth) {
  51709. bottom_1 = node;
  51710. }
  51711. });
  51712. var delta = left_1 === right_1 ? 1 : separation$$1(left_1, right_1) / 2;
  51713. var tx_1 = delta - left_1.getLayout().x;
  51714. var kx_1 = 0;
  51715. var ky_1 = 0;
  51716. var coorX_1 = 0;
  51717. var coorY_1 = 0;
  51718. if (layout === 'radial') {
  51719. kx_1 = width / (right_1.getLayout().x + delta + tx_1); // here we use (node.depth - 1), bucause the real root's depth is 1
  51720. ky_1 = height / (bottom_1.depth - 1 || 1);
  51721. eachBefore(realRoot, function (node) {
  51722. coorX_1 = (node.getLayout().x + tx_1) * kx_1;
  51723. coorY_1 = (node.depth - 1) * ky_1;
  51724. var finalCoor = radialCoordinate(coorX_1, coorY_1);
  51725. node.setLayout({
  51726. x: finalCoor.x,
  51727. y: finalCoor.y,
  51728. rawX: coorX_1,
  51729. rawY: coorY_1
  51730. }, true);
  51731. });
  51732. } else {
  51733. var orient_1 = seriesModel.getOrient();
  51734. if (orient_1 === 'RL' || orient_1 === 'LR') {
  51735. ky_1 = height / (right_1.getLayout().x + delta + tx_1);
  51736. kx_1 = width / (bottom_1.depth - 1 || 1);
  51737. eachBefore(realRoot, function (node) {
  51738. coorY_1 = (node.getLayout().x + tx_1) * ky_1;
  51739. coorX_1 = orient_1 === 'LR' ? (node.depth - 1) * kx_1 : width - (node.depth - 1) * kx_1;
  51740. node.setLayout({
  51741. x: coorX_1,
  51742. y: coorY_1
  51743. }, true);
  51744. });
  51745. } else if (orient_1 === 'TB' || orient_1 === 'BT') {
  51746. kx_1 = width / (right_1.getLayout().x + delta + tx_1);
  51747. ky_1 = height / (bottom_1.depth - 1 || 1);
  51748. eachBefore(realRoot, function (node) {
  51749. coorX_1 = (node.getLayout().x + tx_1) * kx_1;
  51750. coorY_1 = orient_1 === 'TB' ? (node.depth - 1) * ky_1 : height - (node.depth - 1) * ky_1;
  51751. node.setLayout({
  51752. x: coorX_1,
  51753. y: coorY_1
  51754. }, true);
  51755. });
  51756. }
  51757. }
  51758. }
  51759. }
  51760. /*
  51761. * Licensed to the Apache Software Foundation (ASF) under one
  51762. * or more contributor license agreements. See the NOTICE file
  51763. * distributed with this work for additional information
  51764. * regarding copyright ownership. The ASF licenses this file
  51765. * to you under the Apache License, Version 2.0 (the
  51766. * "License"); you may not use this file except in compliance
  51767. * with the License. You may obtain a copy of the License at
  51768. *
  51769. * http://www.apache.org/licenses/LICENSE-2.0
  51770. *
  51771. * Unless required by applicable law or agreed to in writing,
  51772. * software distributed under the License is distributed on an
  51773. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51774. * KIND, either express or implied. See the License for the
  51775. * specific language governing permissions and limitations
  51776. * under the License.
  51777. */
  51778. /**
  51779. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51780. */
  51781. /*
  51782. * Licensed to the Apache Software Foundation (ASF) under one
  51783. * or more contributor license agreements. See the NOTICE file
  51784. * distributed with this work for additional information
  51785. * regarding copyright ownership. The ASF licenses this file
  51786. * to you under the Apache License, Version 2.0 (the
  51787. * "License"); you may not use this file except in compliance
  51788. * with the License. You may obtain a copy of the License at
  51789. *
  51790. * http://www.apache.org/licenses/LICENSE-2.0
  51791. *
  51792. * Unless required by applicable law or agreed to in writing,
  51793. * software distributed under the License is distributed on an
  51794. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51795. * KIND, either express or implied. See the License for the
  51796. * specific language governing permissions and limitations
  51797. * under the License.
  51798. */
  51799. function treeVisual(ecModel) {
  51800. ecModel.eachSeriesByType('tree', function (seriesModel) {
  51801. var data = seriesModel.getData();
  51802. var tree = data.tree;
  51803. tree.eachNode(function (node) {
  51804. var model = node.getModel(); // TODO Optimize
  51805. var style = model.getModel('itemStyle').getItemStyle();
  51806. var existsStyle = data.ensureUniqueItemVisual(node.dataIndex, 'style');
  51807. extend(existsStyle, style);
  51808. });
  51809. });
  51810. }
  51811. /*
  51812. * Licensed to the Apache Software Foundation (ASF) under one
  51813. * or more contributor license agreements. See the NOTICE file
  51814. * distributed with this work for additional information
  51815. * regarding copyright ownership. The ASF licenses this file
  51816. * to you under the Apache License, Version 2.0 (the
  51817. * "License"); you may not use this file except in compliance
  51818. * with the License. You may obtain a copy of the License at
  51819. *
  51820. * http://www.apache.org/licenses/LICENSE-2.0
  51821. *
  51822. * Unless required by applicable law or agreed to in writing,
  51823. * software distributed under the License is distributed on an
  51824. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51825. * KIND, either express or implied. See the License for the
  51826. * specific language governing permissions and limitations
  51827. * under the License.
  51828. */
  51829. /**
  51830. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51831. */
  51832. /*
  51833. * Licensed to the Apache Software Foundation (ASF) under one
  51834. * or more contributor license agreements. See the NOTICE file
  51835. * distributed with this work for additional information
  51836. * regarding copyright ownership. The ASF licenses this file
  51837. * to you under the Apache License, Version 2.0 (the
  51838. * "License"); you may not use this file except in compliance
  51839. * with the License. You may obtain a copy of the License at
  51840. *
  51841. * http://www.apache.org/licenses/LICENSE-2.0
  51842. *
  51843. * Unless required by applicable law or agreed to in writing,
  51844. * software distributed under the License is distributed on an
  51845. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51846. * KIND, either express or implied. See the License for the
  51847. * specific language governing permissions and limitations
  51848. * under the License.
  51849. */
  51850. function updateCenterAndZoom(view, payload, zoomLimit) {
  51851. var previousZoom = view.getZoom();
  51852. var center = view.getCenter();
  51853. var zoom = payload.zoom;
  51854. var point = view.dataToPoint(center);
  51855. if (payload.dx != null && payload.dy != null) {
  51856. point[0] -= payload.dx;
  51857. point[1] -= payload.dy;
  51858. view.setCenter(view.pointToData(point));
  51859. }
  51860. if (zoom != null) {
  51861. if (zoomLimit) {
  51862. var zoomMin = zoomLimit.min || 0;
  51863. var zoomMax = zoomLimit.max || Infinity;
  51864. zoom = Math.max(Math.min(previousZoom * zoom, zoomMax), zoomMin) / previousZoom;
  51865. } // Zoom on given point(originX, originY)
  51866. view.scaleX *= zoom;
  51867. view.scaleY *= zoom;
  51868. var fixX = (payload.originX - view.x) * (zoom - 1);
  51869. var fixY = (payload.originY - view.y) * (zoom - 1);
  51870. view.x -= fixX;
  51871. view.y -= fixY;
  51872. view.updateTransform(); // Get the new center
  51873. view.setCenter(view.pointToData(point));
  51874. view.setZoom(zoom * previousZoom);
  51875. }
  51876. return {
  51877. center: view.getCenter(),
  51878. zoom: view.getZoom()
  51879. };
  51880. }
  51881. /*
  51882. * Licensed to the Apache Software Foundation (ASF) under one
  51883. * or more contributor license agreements. See the NOTICE file
  51884. * distributed with this work for additional information
  51885. * regarding copyright ownership. The ASF licenses this file
  51886. * to you under the Apache License, Version 2.0 (the
  51887. * "License"); you may not use this file except in compliance
  51888. * with the License. You may obtain a copy of the License at
  51889. *
  51890. * http://www.apache.org/licenses/LICENSE-2.0
  51891. *
  51892. * Unless required by applicable law or agreed to in writing,
  51893. * software distributed under the License is distributed on an
  51894. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51895. * KIND, either express or implied. See the License for the
  51896. * specific language governing permissions and limitations
  51897. * under the License.
  51898. */
  51899. /**
  51900. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51901. */
  51902. /*
  51903. * Licensed to the Apache Software Foundation (ASF) under one
  51904. * or more contributor license agreements. See the NOTICE file
  51905. * distributed with this work for additional information
  51906. * regarding copyright ownership. The ASF licenses this file
  51907. * to you under the Apache License, Version 2.0 (the
  51908. * "License"); you may not use this file except in compliance
  51909. * with the License. You may obtain a copy of the License at
  51910. *
  51911. * http://www.apache.org/licenses/LICENSE-2.0
  51912. *
  51913. * Unless required by applicable law or agreed to in writing,
  51914. * software distributed under the License is distributed on an
  51915. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51916. * KIND, either express or implied. See the License for the
  51917. * specific language governing permissions and limitations
  51918. * under the License.
  51919. */
  51920. function installTreeAction(registers) {
  51921. registers.registerAction({
  51922. type: 'treeExpandAndCollapse',
  51923. event: 'treeExpandAndCollapse',
  51924. update: 'update'
  51925. }, function (payload, ecModel) {
  51926. ecModel.eachComponent({
  51927. mainType: 'series',
  51928. subType: 'tree',
  51929. query: payload
  51930. }, function (seriesModel) {
  51931. var dataIndex = payload.dataIndex;
  51932. var tree = seriesModel.getData().tree;
  51933. var node = tree.getNodeByDataIndex(dataIndex);
  51934. node.isExpand = !node.isExpand;
  51935. });
  51936. });
  51937. registers.registerAction({
  51938. type: 'treeRoam',
  51939. event: 'treeRoam',
  51940. // Here we set 'none' instead of 'update', because roam action
  51941. // just need to update the transform matrix without having to recalculate
  51942. // the layout. So don't need to go through the whole update process, such
  51943. // as 'dataPrcocess', 'coordSystemUpdate', 'layout' and so on.
  51944. update: 'none'
  51945. }, function (payload, ecModel) {
  51946. ecModel.eachComponent({
  51947. mainType: 'series',
  51948. subType: 'tree',
  51949. query: payload
  51950. }, function (seriesModel) {
  51951. var coordSys = seriesModel.coordinateSystem;
  51952. var res = updateCenterAndZoom(coordSys, payload);
  51953. seriesModel.setCenter && seriesModel.setCenter(res.center);
  51954. seriesModel.setZoom && seriesModel.setZoom(res.zoom);
  51955. });
  51956. });
  51957. }
  51958. /*
  51959. * Licensed to the Apache Software Foundation (ASF) under one
  51960. * or more contributor license agreements. See the NOTICE file
  51961. * distributed with this work for additional information
  51962. * regarding copyright ownership. The ASF licenses this file
  51963. * to you under the Apache License, Version 2.0 (the
  51964. * "License"); you may not use this file except in compliance
  51965. * with the License. You may obtain a copy of the License at
  51966. *
  51967. * http://www.apache.org/licenses/LICENSE-2.0
  51968. *
  51969. * Unless required by applicable law or agreed to in writing,
  51970. * software distributed under the License is distributed on an
  51971. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51972. * KIND, either express or implied. See the License for the
  51973. * specific language governing permissions and limitations
  51974. * under the License.
  51975. */
  51976. /**
  51977. * AUTO-GENERATED FILE. DO NOT MODIFY.
  51978. */
  51979. /*
  51980. * Licensed to the Apache Software Foundation (ASF) under one
  51981. * or more contributor license agreements. See the NOTICE file
  51982. * distributed with this work for additional information
  51983. * regarding copyright ownership. The ASF licenses this file
  51984. * to you under the Apache License, Version 2.0 (the
  51985. * "License"); you may not use this file except in compliance
  51986. * with the License. You may obtain a copy of the License at
  51987. *
  51988. * http://www.apache.org/licenses/LICENSE-2.0
  51989. *
  51990. * Unless required by applicable law or agreed to in writing,
  51991. * software distributed under the License is distributed on an
  51992. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  51993. * KIND, either express or implied. See the License for the
  51994. * specific language governing permissions and limitations
  51995. * under the License.
  51996. */
  51997. function install$12(registers) {
  51998. registers.registerChartView(TreeView);
  51999. registers.registerSeriesModel(TreeSeriesModel);
  52000. registers.registerLayout(treeLayout);
  52001. registers.registerVisual(treeVisual);
  52002. installTreeAction(registers);
  52003. }
  52004. /*
  52005. * Licensed to the Apache Software Foundation (ASF) under one
  52006. * or more contributor license agreements. See the NOTICE file
  52007. * distributed with this work for additional information
  52008. * regarding copyright ownership. The ASF licenses this file
  52009. * to you under the Apache License, Version 2.0 (the
  52010. * "License"); you may not use this file except in compliance
  52011. * with the License. You may obtain a copy of the License at
  52012. *
  52013. * http://www.apache.org/licenses/LICENSE-2.0
  52014. *
  52015. * Unless required by applicable law or agreed to in writing,
  52016. * software distributed under the License is distributed on an
  52017. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52018. * KIND, either express or implied. See the License for the
  52019. * specific language governing permissions and limitations
  52020. * under the License.
  52021. */
  52022. /**
  52023. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52024. */
  52025. /*
  52026. * Licensed to the Apache Software Foundation (ASF) under one
  52027. * or more contributor license agreements. See the NOTICE file
  52028. * distributed with this work for additional information
  52029. * regarding copyright ownership. The ASF licenses this file
  52030. * to you under the Apache License, Version 2.0 (the
  52031. * "License"); you may not use this file except in compliance
  52032. * with the License. You may obtain a copy of the License at
  52033. *
  52034. * http://www.apache.org/licenses/LICENSE-2.0
  52035. *
  52036. * Unless required by applicable law or agreed to in writing,
  52037. * software distributed under the License is distributed on an
  52038. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52039. * KIND, either express or implied. See the License for the
  52040. * specific language governing permissions and limitations
  52041. * under the License.
  52042. */
  52043. use(install$12);
  52044. /*
  52045. * Licensed to the Apache Software Foundation (ASF) under one
  52046. * or more contributor license agreements. See the NOTICE file
  52047. * distributed with this work for additional information
  52048. * regarding copyright ownership. The ASF licenses this file
  52049. * to you under the Apache License, Version 2.0 (the
  52050. * "License"); you may not use this file except in compliance
  52051. * with the License. You may obtain a copy of the License at
  52052. *
  52053. * http://www.apache.org/licenses/LICENSE-2.0
  52054. *
  52055. * Unless required by applicable law or agreed to in writing,
  52056. * software distributed under the License is distributed on an
  52057. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52058. * KIND, either express or implied. See the License for the
  52059. * specific language governing permissions and limitations
  52060. * under the License.
  52061. */
  52062. /**
  52063. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52064. */
  52065. /*
  52066. * Licensed to the Apache Software Foundation (ASF) under one
  52067. * or more contributor license agreements. See the NOTICE file
  52068. * distributed with this work for additional information
  52069. * regarding copyright ownership. The ASF licenses this file
  52070. * to you under the Apache License, Version 2.0 (the
  52071. * "License"); you may not use this file except in compliance
  52072. * with the License. You may obtain a copy of the License at
  52073. *
  52074. * http://www.apache.org/licenses/LICENSE-2.0
  52075. *
  52076. * Unless required by applicable law or agreed to in writing,
  52077. * software distributed under the License is distributed on an
  52078. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52079. * KIND, either express or implied. See the License for the
  52080. * specific language governing permissions and limitations
  52081. * under the License.
  52082. */
  52083. function retrieveTargetInfo(payload, validPayloadTypes, seriesModel) {
  52084. if (payload && indexOf$1(validPayloadTypes, payload.type) >= 0) {
  52085. var root = seriesModel.getData().tree.root;
  52086. var targetNode = payload.targetNode;
  52087. if (typeof targetNode === 'string') {
  52088. targetNode = root.getNodeById(targetNode);
  52089. }
  52090. if (targetNode && root.contains(targetNode)) {
  52091. return {
  52092. node: targetNode
  52093. };
  52094. }
  52095. var targetNodeId = payload.targetNodeId;
  52096. if (targetNodeId != null && (targetNode = root.getNodeById(targetNodeId))) {
  52097. return {
  52098. node: targetNode
  52099. };
  52100. }
  52101. }
  52102. } // Not includes the given node at the last item.
  52103. function getPathToRoot(node) {
  52104. var path = [];
  52105. while (node) {
  52106. node = node.parentNode;
  52107. node && path.push(node);
  52108. }
  52109. return path.reverse();
  52110. }
  52111. function aboveViewRoot(viewRoot, node) {
  52112. var viewPath = getPathToRoot(viewRoot);
  52113. return indexOf$1(viewPath, node) >= 0;
  52114. } // From root to the input node (the input node will be included).
  52115. function wrapTreePathInfo(node, seriesModel) {
  52116. var treePathInfo = [];
  52117. while (node) {
  52118. var nodeDataIndex = node.dataIndex;
  52119. treePathInfo.push({
  52120. name: node.name,
  52121. dataIndex: nodeDataIndex,
  52122. value: seriesModel.getRawValue(nodeDataIndex)
  52123. });
  52124. node = node.parentNode;
  52125. }
  52126. treePathInfo.reverse();
  52127. return treePathInfo;
  52128. }
  52129. /*
  52130. * Licensed to the Apache Software Foundation (ASF) under one
  52131. * or more contributor license agreements. See the NOTICE file
  52132. * distributed with this work for additional information
  52133. * regarding copyright ownership. The ASF licenses this file
  52134. * to you under the Apache License, Version 2.0 (the
  52135. * "License"); you may not use this file except in compliance
  52136. * with the License. You may obtain a copy of the License at
  52137. *
  52138. * http://www.apache.org/licenses/LICENSE-2.0
  52139. *
  52140. * Unless required by applicable law or agreed to in writing,
  52141. * software distributed under the License is distributed on an
  52142. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52143. * KIND, either express or implied. See the License for the
  52144. * specific language governing permissions and limitations
  52145. * under the License.
  52146. */
  52147. /**
  52148. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52149. */
  52150. /*
  52151. * Licensed to the Apache Software Foundation (ASF) under one
  52152. * or more contributor license agreements. See the NOTICE file
  52153. * distributed with this work for additional information
  52154. * regarding copyright ownership. The ASF licenses this file
  52155. * to you under the Apache License, Version 2.0 (the
  52156. * "License"); you may not use this file except in compliance
  52157. * with the License. You may obtain a copy of the License at
  52158. *
  52159. * http://www.apache.org/licenses/LICENSE-2.0
  52160. *
  52161. * Unless required by applicable law or agreed to in writing,
  52162. * software distributed under the License is distributed on an
  52163. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52164. * KIND, either express or implied. See the License for the
  52165. * specific language governing permissions and limitations
  52166. * under the License.
  52167. */
  52168. var noop$1 = function () {};
  52169. var actionTypes = ['treemapZoomToNode', 'treemapRender', 'treemapMove'];
  52170. function installTreemapAction(registers) {
  52171. for (var i = 0; i < actionTypes.length; i++) {
  52172. registers.registerAction({
  52173. type: actionTypes[i],
  52174. update: 'updateView'
  52175. }, noop$1);
  52176. }
  52177. registers.registerAction({
  52178. type: 'treemapRootToNode',
  52179. update: 'updateView'
  52180. }, function (payload, ecModel) {
  52181. ecModel.eachComponent({
  52182. mainType: 'series',
  52183. subType: 'treemap',
  52184. query: payload
  52185. }, handleRootToNode);
  52186. function handleRootToNode(model, index) {
  52187. var types = ['treemapZoomToNode', 'treemapRootToNode'];
  52188. var targetInfo = retrieveTargetInfo(payload, types, model);
  52189. if (targetInfo) {
  52190. var originViewRoot = model.getViewRoot();
  52191. if (originViewRoot) {
  52192. payload.direction = aboveViewRoot(originViewRoot, targetInfo.node) ? 'rollUp' : 'drillDown';
  52193. }
  52194. model.resetViewRoot(targetInfo.node);
  52195. }
  52196. }
  52197. });
  52198. }
  52199. /*
  52200. * Licensed to the Apache Software Foundation (ASF) under one
  52201. * or more contributor license agreements. See the NOTICE file
  52202. * distributed with this work for additional information
  52203. * regarding copyright ownership. The ASF licenses this file
  52204. * to you under the Apache License, Version 2.0 (the
  52205. * "License"); you may not use this file except in compliance
  52206. * with the License. You may obtain a copy of the License at
  52207. *
  52208. * http://www.apache.org/licenses/LICENSE-2.0
  52209. *
  52210. * Unless required by applicable law or agreed to in writing,
  52211. * software distributed under the License is distributed on an
  52212. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52213. * KIND, either express or implied. See the License for the
  52214. * specific language governing permissions and limitations
  52215. * under the License.
  52216. */
  52217. /**
  52218. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52219. */
  52220. /*
  52221. * Licensed to the Apache Software Foundation (ASF) under one
  52222. * or more contributor license agreements. See the NOTICE file
  52223. * distributed with this work for additional information
  52224. * regarding copyright ownership. The ASF licenses this file
  52225. * to you under the Apache License, Version 2.0 (the
  52226. * "License"); you may not use this file except in compliance
  52227. * with the License. You may obtain a copy of the License at
  52228. *
  52229. * http://www.apache.org/licenses/LICENSE-2.0
  52230. *
  52231. * Unless required by applicable law or agreed to in writing,
  52232. * software distributed under the License is distributed on an
  52233. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52234. * KIND, either express or implied. See the License for the
  52235. * specific language governing permissions and limitations
  52236. * under the License.
  52237. */
  52238. function enableAriaDecalForTree(seriesModel) {
  52239. var data = seriesModel.getData();
  52240. var tree = data.tree;
  52241. var decalPaletteScope = {};
  52242. tree.eachNode(function (node) {
  52243. // Use decal of level 1 node
  52244. var current = node;
  52245. while (current && current.depth > 1) {
  52246. current = current.parentNode;
  52247. }
  52248. var decal = getDecalFromPalette(seriesModel.ecModel, current.name || current.dataIndex + '', decalPaletteScope);
  52249. node.setVisual('decal', decal);
  52250. });
  52251. }
  52252. /*
  52253. * Licensed to the Apache Software Foundation (ASF) under one
  52254. * or more contributor license agreements. See the NOTICE file
  52255. * distributed with this work for additional information
  52256. * regarding copyright ownership. The ASF licenses this file
  52257. * to you under the Apache License, Version 2.0 (the
  52258. * "License"); you may not use this file except in compliance
  52259. * with the License. You may obtain a copy of the License at
  52260. *
  52261. * http://www.apache.org/licenses/LICENSE-2.0
  52262. *
  52263. * Unless required by applicable law or agreed to in writing,
  52264. * software distributed under the License is distributed on an
  52265. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52266. * KIND, either express or implied. See the License for the
  52267. * specific language governing permissions and limitations
  52268. * under the License.
  52269. */
  52270. /**
  52271. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52272. */
  52273. /*
  52274. * Licensed to the Apache Software Foundation (ASF) under one
  52275. * or more contributor license agreements. See the NOTICE file
  52276. * distributed with this work for additional information
  52277. * regarding copyright ownership. The ASF licenses this file
  52278. * to you under the Apache License, Version 2.0 (the
  52279. * "License"); you may not use this file except in compliance
  52280. * with the License. You may obtain a copy of the License at
  52281. *
  52282. * http://www.apache.org/licenses/LICENSE-2.0
  52283. *
  52284. * Unless required by applicable law or agreed to in writing,
  52285. * software distributed under the License is distributed on an
  52286. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52287. * KIND, either express or implied. See the License for the
  52288. * specific language governing permissions and limitations
  52289. * under the License.
  52290. */
  52291. var TreemapSeriesModel =
  52292. /** @class */
  52293. function (_super) {
  52294. __extends(TreemapSeriesModel, _super);
  52295. function TreemapSeriesModel() {
  52296. var _this = _super !== null && _super.apply(this, arguments) || this;
  52297. _this.type = TreemapSeriesModel.type;
  52298. _this.preventUsingHoverLayer = true;
  52299. return _this;
  52300. }
  52301. /**
  52302. * @override
  52303. */
  52304. TreemapSeriesModel.prototype.getInitialData = function (option, ecModel) {
  52305. // Create a virtual root.
  52306. var root = {
  52307. name: option.name,
  52308. children: option.data
  52309. };
  52310. completeTreeValue(root);
  52311. var levels = option.levels || []; // Used in "visual priority" in `treemapVisual.js`.
  52312. // This way is a little tricky, must satisfy the precondition:
  52313. // 1. There is no `treeNode.getModel('itemStyle.xxx')` used.
  52314. // 2. The `Model.prototype.getModel()` will not use any clone-like way.
  52315. var designatedVisualItemStyle = this.designatedVisualItemStyle = {};
  52316. var designatedVisualModel = new Model({
  52317. itemStyle: designatedVisualItemStyle
  52318. }, this, ecModel);
  52319. levels = option.levels = setDefault(levels, ecModel);
  52320. var levelModels = map(levels || [], function (levelDefine) {
  52321. return new Model(levelDefine, designatedVisualModel, ecModel);
  52322. }, this); // Make sure always a new tree is created when setOption,
  52323. // in TreemapView, we check whether oldTree === newTree
  52324. // to choose mappings approach among old shapes and new shapes.
  52325. var tree = Tree.createTree(root, this, beforeLink);
  52326. function beforeLink(nodeData) {
  52327. nodeData.wrapMethod('getItemModel', function (model, idx) {
  52328. var node = tree.getNodeByDataIndex(idx);
  52329. var levelModel = levelModels[node.depth]; // If no levelModel, we also need `designatedVisualModel`.
  52330. model.parentModel = levelModel || designatedVisualModel;
  52331. return model;
  52332. });
  52333. }
  52334. return tree.data;
  52335. };
  52336. TreemapSeriesModel.prototype.optionUpdated = function () {
  52337. this.resetViewRoot();
  52338. };
  52339. /**
  52340. * @override
  52341. * @param {number} dataIndex
  52342. * @param {boolean} [mutipleSeries=false]
  52343. */
  52344. TreemapSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  52345. var data = this.getData();
  52346. var value = this.getRawValue(dataIndex);
  52347. var name = data.getName(dataIndex);
  52348. return createTooltipMarkup('nameValue', {
  52349. name: name,
  52350. value: value
  52351. });
  52352. };
  52353. /**
  52354. * Add tree path to tooltip param
  52355. *
  52356. * @override
  52357. * @param {number} dataIndex
  52358. * @return {Object}
  52359. */
  52360. TreemapSeriesModel.prototype.getDataParams = function (dataIndex) {
  52361. var params = _super.prototype.getDataParams.apply(this, arguments);
  52362. var node = this.getData().tree.getNodeByDataIndex(dataIndex);
  52363. params.treePathInfo = wrapTreePathInfo(node, this);
  52364. return params;
  52365. };
  52366. /**
  52367. * @public
  52368. * @param {Object} layoutInfo {
  52369. * x: containerGroup x
  52370. * y: containerGroup y
  52371. * width: containerGroup width
  52372. * height: containerGroup height
  52373. * }
  52374. */
  52375. TreemapSeriesModel.prototype.setLayoutInfo = function (layoutInfo) {
  52376. /**
  52377. * @readOnly
  52378. * @type {Object}
  52379. */
  52380. this.layoutInfo = this.layoutInfo || {};
  52381. extend(this.layoutInfo, layoutInfo);
  52382. };
  52383. /**
  52384. * @param {string} id
  52385. * @return {number} index
  52386. */
  52387. TreemapSeriesModel.prototype.mapIdToIndex = function (id) {
  52388. // A feature is implemented:
  52389. // index is monotone increasing with the sequence of
  52390. // input id at the first time.
  52391. // This feature can make sure that each data item and its
  52392. // mapped color have the same index between data list and
  52393. // color list at the beginning, which is useful for user
  52394. // to adjust data-color mapping.
  52395. /**
  52396. * @private
  52397. * @type {Object}
  52398. */
  52399. var idIndexMap = this._idIndexMap;
  52400. if (!idIndexMap) {
  52401. idIndexMap = this._idIndexMap = createHashMap();
  52402. /**
  52403. * @private
  52404. * @type {number}
  52405. */
  52406. this._idIndexMapCount = 0;
  52407. }
  52408. var index = idIndexMap.get(id);
  52409. if (index == null) {
  52410. idIndexMap.set(id, index = this._idIndexMapCount++);
  52411. }
  52412. return index;
  52413. };
  52414. TreemapSeriesModel.prototype.getViewRoot = function () {
  52415. return this._viewRoot;
  52416. };
  52417. TreemapSeriesModel.prototype.resetViewRoot = function (viewRoot) {
  52418. viewRoot ? this._viewRoot = viewRoot : viewRoot = this._viewRoot;
  52419. var root = this.getRawData().tree.root;
  52420. if (!viewRoot || viewRoot !== root && !root.contains(viewRoot)) {
  52421. this._viewRoot = root;
  52422. }
  52423. };
  52424. TreemapSeriesModel.prototype.enableAriaDecal = function () {
  52425. enableAriaDecalForTree(this);
  52426. };
  52427. TreemapSeriesModel.type = 'series.treemap';
  52428. TreemapSeriesModel.layoutMode = 'box';
  52429. TreemapSeriesModel.defaultOption = {
  52430. // Disable progressive rendering
  52431. progressive: 0,
  52432. // size: ['80%', '80%'], // deprecated, compatible with ec2.
  52433. left: 'center',
  52434. top: 'middle',
  52435. width: '80%',
  52436. height: '80%',
  52437. sort: true,
  52438. clipWindow: 'origin',
  52439. squareRatio: 0.5 * (1 + Math.sqrt(5)),
  52440. leafDepth: null,
  52441. drillDownIcon: '▶',
  52442. // to align specialized icon. ▷▶❒❐▼✚
  52443. zoomToNodeRatio: 0.32 * 0.32,
  52444. roam: true,
  52445. nodeClick: 'zoomToNode',
  52446. animation: true,
  52447. animationDurationUpdate: 900,
  52448. animationEasing: 'quinticInOut',
  52449. breadcrumb: {
  52450. show: true,
  52451. height: 22,
  52452. left: 'center',
  52453. top: 'bottom',
  52454. // right
  52455. // bottom
  52456. emptyItemWidth: 25,
  52457. itemStyle: {
  52458. color: 'rgba(0,0,0,0.7)',
  52459. textStyle: {
  52460. color: '#fff'
  52461. }
  52462. }
  52463. },
  52464. label: {
  52465. show: true,
  52466. // Do not use textDistance, for ellipsis rect just the same as treemap node rect.
  52467. distance: 0,
  52468. padding: 5,
  52469. position: 'inside',
  52470. // formatter: null,
  52471. color: '#fff',
  52472. overflow: 'truncate' // align
  52473. // verticalAlign
  52474. },
  52475. upperLabel: {
  52476. show: false,
  52477. position: [0, '50%'],
  52478. height: 20,
  52479. // formatter: null,
  52480. // color: '#fff',
  52481. overflow: 'truncate',
  52482. // align: null,
  52483. verticalAlign: 'middle'
  52484. },
  52485. itemStyle: {
  52486. color: null,
  52487. colorAlpha: null,
  52488. colorSaturation: null,
  52489. borderWidth: 0,
  52490. gapWidth: 0,
  52491. borderColor: '#fff',
  52492. borderColorSaturation: null // If specified, borderColor will be ineffective, and the
  52493. // border color is evaluated by color of current node and
  52494. // borderColorSaturation.
  52495. },
  52496. emphasis: {
  52497. upperLabel: {
  52498. show: true,
  52499. position: [0, '50%'],
  52500. ellipsis: true,
  52501. verticalAlign: 'middle'
  52502. }
  52503. },
  52504. visualDimension: 0,
  52505. visualMin: null,
  52506. visualMax: null,
  52507. color: [],
  52508. // level[n].color (if necessary).
  52509. // + Specify color list of each level. level[0].color would be global
  52510. // color list if not specified. (see method `setDefault`).
  52511. // + But set as a empty array to forbid fetch color from global palette
  52512. // when using nodeModel.get('color'), otherwise nodes on deep level
  52513. // will always has color palette set and are not able to inherit color
  52514. // from parent node.
  52515. // + TreemapSeries.color can not be set as 'none', otherwise effect
  52516. // legend color fetching (see seriesColor.js).
  52517. colorAlpha: null,
  52518. colorSaturation: null,
  52519. colorMappingBy: 'index',
  52520. visibleMin: 10,
  52521. // be rendered. Only works when sort is 'asc' or 'desc'.
  52522. childrenVisibleMin: null,
  52523. // grandchildren will not show.
  52524. // Why grandchildren? If not grandchildren but children,
  52525. // some siblings show children and some not,
  52526. // the appearance may be mess and not consistent,
  52527. levels: [] // Each item: {
  52528. // visibleMin, itemStyle, visualDimension, label
  52529. // }
  52530. // data: {
  52531. // value: [],
  52532. // children: [],
  52533. // link: 'http://xxx.xxx.xxx',
  52534. // target: 'blank' or 'self'
  52535. // }
  52536. };
  52537. return TreemapSeriesModel;
  52538. }(SeriesModel);
  52539. /**
  52540. * @param {Object} dataNode
  52541. */
  52542. function completeTreeValue(dataNode) {
  52543. // Postorder travel tree.
  52544. // If value of none-leaf node is not set,
  52545. // calculate it by suming up the value of all children.
  52546. var sum = 0;
  52547. each$1(dataNode.children, function (child) {
  52548. completeTreeValue(child);
  52549. var childValue = child.value;
  52550. isArray(childValue) && (childValue = childValue[0]);
  52551. sum += childValue;
  52552. });
  52553. var thisValue = dataNode.value;
  52554. if (isArray(thisValue)) {
  52555. thisValue = thisValue[0];
  52556. }
  52557. if (thisValue == null || isNaN(thisValue)) {
  52558. thisValue = sum;
  52559. } // Value should not less than 0.
  52560. if (thisValue < 0) {
  52561. thisValue = 0;
  52562. }
  52563. isArray(dataNode.value) ? dataNode.value[0] = thisValue : dataNode.value = thisValue;
  52564. }
  52565. /**
  52566. * set default to level configuration
  52567. */
  52568. function setDefault(levels, ecModel) {
  52569. var globalColorList = normalizeToArray(ecModel.get('color'));
  52570. var globalDecalList = normalizeToArray(ecModel.get(['aria', 'decal', 'decals']));
  52571. if (!globalColorList) {
  52572. return;
  52573. }
  52574. levels = levels || [];
  52575. var hasColorDefine;
  52576. var hasDecalDefine;
  52577. each$1(levels, function (levelDefine) {
  52578. var model = new Model(levelDefine);
  52579. var modelColor = model.get('color');
  52580. var modelDecal = model.get('decal');
  52581. if (model.get(['itemStyle', 'color']) || modelColor && modelColor !== 'none') {
  52582. hasColorDefine = true;
  52583. }
  52584. if (model.get(['itemStyle', 'decal']) || modelDecal && modelDecal !== 'none') {
  52585. hasDecalDefine = true;
  52586. }
  52587. });
  52588. var level0 = levels[0] || (levels[0] = {});
  52589. if (!hasColorDefine) {
  52590. level0.color = globalColorList.slice();
  52591. }
  52592. if (!hasDecalDefine && globalDecalList) {
  52593. level0.decal = globalDecalList.slice();
  52594. }
  52595. return levels;
  52596. }
  52597. /*
  52598. * Licensed to the Apache Software Foundation (ASF) under one
  52599. * or more contributor license agreements. See the NOTICE file
  52600. * distributed with this work for additional information
  52601. * regarding copyright ownership. The ASF licenses this file
  52602. * to you under the Apache License, Version 2.0 (the
  52603. * "License"); you may not use this file except in compliance
  52604. * with the License. You may obtain a copy of the License at
  52605. *
  52606. * http://www.apache.org/licenses/LICENSE-2.0
  52607. *
  52608. * Unless required by applicable law or agreed to in writing,
  52609. * software distributed under the License is distributed on an
  52610. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52611. * KIND, either express or implied. See the License for the
  52612. * specific language governing permissions and limitations
  52613. * under the License.
  52614. */
  52615. /**
  52616. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52617. */
  52618. /*
  52619. * Licensed to the Apache Software Foundation (ASF) under one
  52620. * or more contributor license agreements. See the NOTICE file
  52621. * distributed with this work for additional information
  52622. * regarding copyright ownership. The ASF licenses this file
  52623. * to you under the Apache License, Version 2.0 (the
  52624. * "License"); you may not use this file except in compliance
  52625. * with the License. You may obtain a copy of the License at
  52626. *
  52627. * http://www.apache.org/licenses/LICENSE-2.0
  52628. *
  52629. * Unless required by applicable law or agreed to in writing,
  52630. * software distributed under the License is distributed on an
  52631. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52632. * KIND, either express or implied. See the License for the
  52633. * specific language governing permissions and limitations
  52634. * under the License.
  52635. */
  52636. var TEXT_PADDING = 8;
  52637. var ITEM_GAP = 8;
  52638. var ARRAY_LENGTH = 5;
  52639. var Breadcrumb =
  52640. /** @class */
  52641. function () {
  52642. function Breadcrumb(containerGroup) {
  52643. this.group = new Group();
  52644. containerGroup.add(this.group);
  52645. }
  52646. Breadcrumb.prototype.render = function (seriesModel, api, targetNode, onSelect) {
  52647. var model = seriesModel.getModel('breadcrumb');
  52648. var thisGroup = this.group;
  52649. thisGroup.removeAll();
  52650. if (!model.get('show') || !targetNode) {
  52651. return;
  52652. }
  52653. var normalStyleModel = model.getModel('itemStyle'); // let emphasisStyleModel = model.getModel('emphasis.itemStyle');
  52654. var textStyleModel = normalStyleModel.getModel('textStyle');
  52655. var layoutParam = {
  52656. pos: {
  52657. left: model.get('left'),
  52658. right: model.get('right'),
  52659. top: model.get('top'),
  52660. bottom: model.get('bottom')
  52661. },
  52662. box: {
  52663. width: api.getWidth(),
  52664. height: api.getHeight()
  52665. },
  52666. emptyItemWidth: model.get('emptyItemWidth'),
  52667. totalWidth: 0,
  52668. renderList: []
  52669. };
  52670. this._prepare(targetNode, layoutParam, textStyleModel);
  52671. this._renderContent(seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect);
  52672. positionElement(thisGroup, layoutParam.pos, layoutParam.box);
  52673. };
  52674. /**
  52675. * Prepare render list and total width
  52676. * @private
  52677. */
  52678. Breadcrumb.prototype._prepare = function (targetNode, layoutParam, textStyleModel) {
  52679. for (var node = targetNode; node; node = node.parentNode) {
  52680. var text = convertOptionIdName(node.getModel().get('name'), '');
  52681. var textRect = textStyleModel.getTextRect(text);
  52682. var itemWidth = Math.max(textRect.width + TEXT_PADDING * 2, layoutParam.emptyItemWidth);
  52683. layoutParam.totalWidth += itemWidth + ITEM_GAP;
  52684. layoutParam.renderList.push({
  52685. node: node,
  52686. text: text,
  52687. width: itemWidth
  52688. });
  52689. }
  52690. };
  52691. /**
  52692. * @private
  52693. */
  52694. Breadcrumb.prototype._renderContent = function (seriesModel, layoutParam, normalStyleModel, textStyleModel, onSelect) {
  52695. // Start rendering.
  52696. var lastX = 0;
  52697. var emptyItemWidth = layoutParam.emptyItemWidth;
  52698. var height = seriesModel.get(['breadcrumb', 'height']);
  52699. var availableSize = getAvailableSize(layoutParam.pos, layoutParam.box);
  52700. var totalWidth = layoutParam.totalWidth;
  52701. var renderList = layoutParam.renderList;
  52702. for (var i = renderList.length - 1; i >= 0; i--) {
  52703. var item = renderList[i];
  52704. var itemNode = item.node;
  52705. var itemWidth = item.width;
  52706. var text = item.text; // Hdie text and shorten width if necessary.
  52707. if (totalWidth > availableSize.width) {
  52708. totalWidth -= itemWidth - emptyItemWidth;
  52709. itemWidth = emptyItemWidth;
  52710. text = null;
  52711. }
  52712. var el = new Polygon({
  52713. shape: {
  52714. points: makeItemPoints(lastX, 0, itemWidth, height, i === renderList.length - 1, i === 0)
  52715. },
  52716. style: defaults(normalStyleModel.getItemStyle(), {
  52717. lineJoin: 'bevel'
  52718. }),
  52719. textContent: new ZRText({
  52720. style: {
  52721. text: text,
  52722. fill: textStyleModel.getTextColor(),
  52723. font: textStyleModel.getFont()
  52724. }
  52725. }),
  52726. textConfig: {
  52727. position: 'inside'
  52728. },
  52729. z2: Z2_EMPHASIS_LIFT * 1e4,
  52730. onclick: curry(onSelect, itemNode)
  52731. });
  52732. el.disableLabelAnimation = true;
  52733. this.group.add(el);
  52734. packEventData(el, seriesModel, itemNode);
  52735. lastX += itemWidth + ITEM_GAP;
  52736. }
  52737. };
  52738. Breadcrumb.prototype.remove = function () {
  52739. this.group.removeAll();
  52740. };
  52741. return Breadcrumb;
  52742. }();
  52743. function makeItemPoints(x, y, itemWidth, itemHeight, head, tail) {
  52744. var points = [[head ? x : x - ARRAY_LENGTH, y], [x + itemWidth, y], [x + itemWidth, y + itemHeight], [head ? x : x - ARRAY_LENGTH, y + itemHeight]];
  52745. !tail && points.splice(2, 0, [x + itemWidth + ARRAY_LENGTH, y + itemHeight / 2]);
  52746. !head && points.push([x, y + itemHeight / 2]);
  52747. return points;
  52748. } // Package custom mouse event.
  52749. function packEventData(el, seriesModel, itemNode) {
  52750. getECData(el).eventData = {
  52751. componentType: 'series',
  52752. componentSubType: 'treemap',
  52753. componentIndex: seriesModel.componentIndex,
  52754. seriesIndex: seriesModel.componentIndex,
  52755. seriesName: seriesModel.name,
  52756. seriesType: 'treemap',
  52757. selfType: 'breadcrumb',
  52758. nodeData: {
  52759. dataIndex: itemNode && itemNode.dataIndex,
  52760. name: itemNode && itemNode.name
  52761. },
  52762. treePathInfo: itemNode && wrapTreePathInfo(itemNode, seriesModel)
  52763. };
  52764. }
  52765. /*
  52766. * Licensed to the Apache Software Foundation (ASF) under one
  52767. * or more contributor license agreements. See the NOTICE file
  52768. * distributed with this work for additional information
  52769. * regarding copyright ownership. The ASF licenses this file
  52770. * to you under the Apache License, Version 2.0 (the
  52771. * "License"); you may not use this file except in compliance
  52772. * with the License. You may obtain a copy of the License at
  52773. *
  52774. * http://www.apache.org/licenses/LICENSE-2.0
  52775. *
  52776. * Unless required by applicable law or agreed to in writing,
  52777. * software distributed under the License is distributed on an
  52778. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52779. * KIND, either express or implied. See the License for the
  52780. * specific language governing permissions and limitations
  52781. * under the License.
  52782. */
  52783. /**
  52784. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52785. */
  52786. /*
  52787. * Licensed to the Apache Software Foundation (ASF) under one
  52788. * or more contributor license agreements. See the NOTICE file
  52789. * distributed with this work for additional information
  52790. * regarding copyright ownership. The ASF licenses this file
  52791. * to you under the Apache License, Version 2.0 (the
  52792. * "License"); you may not use this file except in compliance
  52793. * with the License. You may obtain a copy of the License at
  52794. *
  52795. * http://www.apache.org/licenses/LICENSE-2.0
  52796. *
  52797. * Unless required by applicable law or agreed to in writing,
  52798. * software distributed under the License is distributed on an
  52799. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52800. * KIND, either express or implied. See the License for the
  52801. * specific language governing permissions and limitations
  52802. * under the License.
  52803. */
  52804. /**
  52805. * Animate multiple elements with a single done-callback.
  52806. *
  52807. * @example
  52808. * animation
  52809. * .createWrap()
  52810. * .add(el1, {x: 10, y: 10})
  52811. * .add(el2, {shape: {width: 500}, style: {fill: 'red'}}, 400)
  52812. * .done(function () { // done })
  52813. * .start('cubicOut');
  52814. */
  52815. var AnimationWrap =
  52816. /** @class */
  52817. function () {
  52818. function AnimationWrap() {
  52819. this._storage = [];
  52820. this._elExistsMap = {};
  52821. }
  52822. /**
  52823. * Caution: a el can only be added once, otherwise 'done'
  52824. * might not be called. This method checks this (by el.id),
  52825. * suppresses adding and returns false when existing el found.
  52826. *
  52827. * @return Whether adding succeeded.
  52828. */
  52829. AnimationWrap.prototype.add = function (el, target, duration, delay, easing) {
  52830. if (this._elExistsMap[el.id]) {
  52831. return false;
  52832. }
  52833. this._elExistsMap[el.id] = true;
  52834. this._storage.push({
  52835. el: el,
  52836. target: target,
  52837. duration: duration,
  52838. delay: delay,
  52839. easing: easing
  52840. });
  52841. return true;
  52842. };
  52843. /**
  52844. * Only execute when animation done/aborted.
  52845. */
  52846. AnimationWrap.prototype.finished = function (callback) {
  52847. this._finishedCallback = callback;
  52848. return this;
  52849. };
  52850. /**
  52851. * Will stop exist animation firstly.
  52852. */
  52853. AnimationWrap.prototype.start = function () {
  52854. var _this = this;
  52855. var count = this._storage.length;
  52856. var checkTerminate = function () {
  52857. count--;
  52858. if (count <= 0) {
  52859. // Guard.
  52860. _this._storage.length = 0;
  52861. _this._elExistsMap = {};
  52862. _this._finishedCallback && _this._finishedCallback();
  52863. }
  52864. };
  52865. for (var i = 0, len = this._storage.length; i < len; i++) {
  52866. var item = this._storage[i];
  52867. item.el.animateTo(item.target, {
  52868. duration: item.duration,
  52869. delay: item.delay,
  52870. easing: item.easing,
  52871. setToFinal: true,
  52872. done: checkTerminate,
  52873. aborted: checkTerminate
  52874. });
  52875. }
  52876. return this;
  52877. };
  52878. return AnimationWrap;
  52879. }();
  52880. function createWrap() {
  52881. return new AnimationWrap();
  52882. }
  52883. /*
  52884. * Licensed to the Apache Software Foundation (ASF) under one
  52885. * or more contributor license agreements. See the NOTICE file
  52886. * distributed with this work for additional information
  52887. * regarding copyright ownership. The ASF licenses this file
  52888. * to you under the Apache License, Version 2.0 (the
  52889. * "License"); you may not use this file except in compliance
  52890. * with the License. You may obtain a copy of the License at
  52891. *
  52892. * http://www.apache.org/licenses/LICENSE-2.0
  52893. *
  52894. * Unless required by applicable law or agreed to in writing,
  52895. * software distributed under the License is distributed on an
  52896. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52897. * KIND, either express or implied. See the License for the
  52898. * specific language governing permissions and limitations
  52899. * under the License.
  52900. */
  52901. /**
  52902. * AUTO-GENERATED FILE. DO NOT MODIFY.
  52903. */
  52904. /*
  52905. * Licensed to the Apache Software Foundation (ASF) under one
  52906. * or more contributor license agreements. See the NOTICE file
  52907. * distributed with this work for additional information
  52908. * regarding copyright ownership. The ASF licenses this file
  52909. * to you under the Apache License, Version 2.0 (the
  52910. * "License"); you may not use this file except in compliance
  52911. * with the License. You may obtain a copy of the License at
  52912. *
  52913. * http://www.apache.org/licenses/LICENSE-2.0
  52914. *
  52915. * Unless required by applicable law or agreed to in writing,
  52916. * software distributed under the License is distributed on an
  52917. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  52918. * KIND, either express or implied. See the License for the
  52919. * specific language governing permissions and limitations
  52920. * under the License.
  52921. */
  52922. var Group$2 = Group;
  52923. var Rect$2 = Rect;
  52924. var DRAG_THRESHOLD = 3;
  52925. var PATH_LABEL_NOAMAL = 'label';
  52926. var PATH_UPPERLABEL_NORMAL = 'upperLabel'; // Should larger than emphasis states lift z
  52927. var Z2_BASE = Z2_EMPHASIS_LIFT * 10; // Should bigger than every z2.
  52928. var Z2_BG = Z2_EMPHASIS_LIFT * 2;
  52929. var Z2_CONTENT = Z2_EMPHASIS_LIFT * 3;
  52930. var getStateItemStyle = makeStyleMapper([['fill', 'color'], // `borderColor` and `borderWidth` has been occupied,
  52931. // so use `stroke` to indicate the stroke of the rect.
  52932. ['stroke', 'strokeColor'], ['lineWidth', 'strokeWidth'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  52933. // So do not transfer decal directly.
  52934. ]);
  52935. var getItemStyleNormal = function (model) {
  52936. // Normal style props should include emphasis style props.
  52937. var itemStyle = getStateItemStyle(model); // Clear styles set by emphasis.
  52938. itemStyle.stroke = itemStyle.fill = itemStyle.lineWidth = null;
  52939. return itemStyle;
  52940. };
  52941. var inner$7 = makeInner();
  52942. var TreemapView =
  52943. /** @class */
  52944. function (_super) {
  52945. __extends(TreemapView, _super);
  52946. function TreemapView() {
  52947. var _this = _super !== null && _super.apply(this, arguments) || this;
  52948. _this.type = TreemapView.type;
  52949. _this._state = 'ready';
  52950. _this._storage = createStorage();
  52951. return _this;
  52952. }
  52953. /**
  52954. * @override
  52955. */
  52956. TreemapView.prototype.render = function (seriesModel, ecModel, api, payload) {
  52957. var models = ecModel.findComponents({
  52958. mainType: 'series',
  52959. subType: 'treemap',
  52960. query: payload
  52961. });
  52962. if (indexOf$1(models, seriesModel) < 0) {
  52963. return;
  52964. }
  52965. this.seriesModel = seriesModel;
  52966. this.api = api;
  52967. this.ecModel = ecModel;
  52968. var types = ['treemapZoomToNode', 'treemapRootToNode'];
  52969. var targetInfo = retrieveTargetInfo(payload, types, seriesModel);
  52970. var payloadType = payload && payload.type;
  52971. var layoutInfo = seriesModel.layoutInfo;
  52972. var isInit = !this._oldTree;
  52973. var thisStorage = this._storage; // Mark new root when action is treemapRootToNode.
  52974. var reRoot = payloadType === 'treemapRootToNode' && targetInfo && thisStorage ? {
  52975. rootNodeGroup: thisStorage.nodeGroup[targetInfo.node.getRawIndex()],
  52976. direction: payload.direction
  52977. } : null;
  52978. var containerGroup = this._giveContainerGroup(layoutInfo);
  52979. var renderResult = this._doRender(containerGroup, seriesModel, reRoot);
  52980. !isInit && (!payloadType || payloadType === 'treemapZoomToNode' || payloadType === 'treemapRootToNode') ? this._doAnimation(containerGroup, renderResult, seriesModel, reRoot) : renderResult.renderFinally();
  52981. this._resetController(api);
  52982. this._renderBreadcrumb(seriesModel, api, targetInfo);
  52983. };
  52984. TreemapView.prototype._giveContainerGroup = function (layoutInfo) {
  52985. var containerGroup = this._containerGroup;
  52986. if (!containerGroup) {
  52987. // FIXME
  52988. // 加一层containerGroup是为了clip,但是现在clip功能并没有实现。
  52989. containerGroup = this._containerGroup = new Group$2();
  52990. this._initEvents(containerGroup);
  52991. this.group.add(containerGroup);
  52992. }
  52993. containerGroup.x = layoutInfo.x;
  52994. containerGroup.y = layoutInfo.y;
  52995. return containerGroup;
  52996. };
  52997. TreemapView.prototype._doRender = function (containerGroup, seriesModel, reRoot) {
  52998. var thisTree = seriesModel.getData().tree;
  52999. var oldTree = this._oldTree; // Clear last shape records.
  53000. var lastsForAnimation = createStorage();
  53001. var thisStorage = createStorage();
  53002. var oldStorage = this._storage;
  53003. var willInvisibleEls = [];
  53004. function doRenderNode(thisNode, oldNode, parentGroup, depth) {
  53005. return renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimation, willInvisibleEls, thisNode, oldNode, parentGroup, depth);
  53006. } // Notice: when thisTree and oldTree are the same tree (see list.cloneShallow),
  53007. // the oldTree is actually losted, so we can not find all of the old graphic
  53008. // elements from tree. So we use this stragegy: make element storage, move
  53009. // from old storage to new storage, clear old storage.
  53010. dualTravel(thisTree.root ? [thisTree.root] : [], oldTree && oldTree.root ? [oldTree.root] : [], containerGroup, thisTree === oldTree || !oldTree, 0); // Process all removing.
  53011. var willDeleteEls = clearStorage(oldStorage);
  53012. this._oldTree = thisTree;
  53013. this._storage = thisStorage;
  53014. return {
  53015. lastsForAnimation: lastsForAnimation,
  53016. willDeleteEls: willDeleteEls,
  53017. renderFinally: renderFinally
  53018. };
  53019. function dualTravel(thisViewChildren, oldViewChildren, parentGroup, sameTree, depth) {
  53020. // When 'render' is triggered by action,
  53021. // 'this' and 'old' may be the same tree,
  53022. // we use rawIndex in that case.
  53023. if (sameTree) {
  53024. oldViewChildren = thisViewChildren;
  53025. each$1(thisViewChildren, function (child, index) {
  53026. !child.isRemoved() && processNode(index, index);
  53027. });
  53028. } // Diff hierarchically (diff only in each subtree, but not whole).
  53029. // because, consistency of view is important.
  53030. else {
  53031. new DataDiffer(oldViewChildren, thisViewChildren, getKey, getKey).add(processNode).update(processNode).remove(curry(processNode, null)).execute();
  53032. }
  53033. function getKey(node) {
  53034. // Identify by name or raw index.
  53035. return node.getId();
  53036. }
  53037. function processNode(newIndex, oldIndex) {
  53038. var thisNode = newIndex != null ? thisViewChildren[newIndex] : null;
  53039. var oldNode = oldIndex != null ? oldViewChildren[oldIndex] : null;
  53040. var group = doRenderNode(thisNode, oldNode, parentGroup, depth);
  53041. group && dualTravel(thisNode && thisNode.viewChildren || [], oldNode && oldNode.viewChildren || [], group, sameTree, depth + 1);
  53042. }
  53043. }
  53044. function clearStorage(storage) {
  53045. var willDeleteEls = createStorage();
  53046. storage && each$1(storage, function (store, storageName) {
  53047. var delEls = willDeleteEls[storageName];
  53048. each$1(store, function (el) {
  53049. el && (delEls.push(el), inner$7(el).willDelete = true);
  53050. });
  53051. });
  53052. return willDeleteEls;
  53053. }
  53054. function renderFinally() {
  53055. each$1(willDeleteEls, function (els) {
  53056. each$1(els, function (el) {
  53057. el.parent && el.parent.remove(el);
  53058. });
  53059. });
  53060. each$1(willInvisibleEls, function (el) {
  53061. el.invisible = true; // Setting invisible is for optimizing, so no need to set dirty,
  53062. // just mark as invisible.
  53063. el.dirty();
  53064. });
  53065. }
  53066. };
  53067. TreemapView.prototype._doAnimation = function (containerGroup, renderResult, seriesModel, reRoot) {
  53068. if (!seriesModel.get('animation')) {
  53069. return;
  53070. }
  53071. var durationOption = seriesModel.get('animationDurationUpdate');
  53072. var easingOption = seriesModel.get('animationEasing'); // TODO: do not support function until necessary.
  53073. var duration = (isFunction$1(durationOption) ? 0 : durationOption) || 0;
  53074. var easing = (isFunction$1(easingOption) ? null : easingOption) || 'cubicOut';
  53075. var animationWrap = createWrap(); // Make delete animations.
  53076. each$1(renderResult.willDeleteEls, function (store, storageName) {
  53077. each$1(store, function (el, rawIndex) {
  53078. if (el.invisible) {
  53079. return;
  53080. }
  53081. var parent = el.parent; // Always has parent, and parent is nodeGroup.
  53082. var target;
  53083. var innerStore = inner$7(parent);
  53084. if (reRoot && reRoot.direction === 'drillDown') {
  53085. target = parent === reRoot.rootNodeGroup // This is the content element of view root.
  53086. // Only `content` will enter this branch, because
  53087. // `background` and `nodeGroup` will not be deleted.
  53088. ? {
  53089. shape: {
  53090. x: 0,
  53091. y: 0,
  53092. width: innerStore.nodeWidth,
  53093. height: innerStore.nodeHeight
  53094. },
  53095. style: {
  53096. opacity: 0
  53097. }
  53098. } // Others.
  53099. : {
  53100. style: {
  53101. opacity: 0
  53102. }
  53103. };
  53104. } else {
  53105. var targetX = 0;
  53106. var targetY = 0;
  53107. if (!innerStore.willDelete) {
  53108. // Let node animate to right-bottom corner, cooperating with fadeout,
  53109. // which is appropriate for user understanding.
  53110. // Divided by 2 for reRoot rolling up effect.
  53111. targetX = innerStore.nodeWidth / 2;
  53112. targetY = innerStore.nodeHeight / 2;
  53113. }
  53114. target = storageName === 'nodeGroup' ? {
  53115. x: targetX,
  53116. y: targetY,
  53117. style: {
  53118. opacity: 0
  53119. }
  53120. } : {
  53121. shape: {
  53122. x: targetX,
  53123. y: targetY,
  53124. width: 0,
  53125. height: 0
  53126. },
  53127. style: {
  53128. opacity: 0
  53129. }
  53130. };
  53131. } // TODO: do not support delay until necessary.
  53132. target && animationWrap.add(el, target, duration, 0, easing);
  53133. });
  53134. }); // Make other animations
  53135. each$1(this._storage, function (store, storageName) {
  53136. each$1(store, function (el, rawIndex) {
  53137. var last = renderResult.lastsForAnimation[storageName][rawIndex];
  53138. var target = {};
  53139. if (!last) {
  53140. return;
  53141. }
  53142. if (el instanceof Group) {
  53143. if (last.oldX != null) {
  53144. target.x = el.x;
  53145. target.y = el.y;
  53146. el.x = last.oldX;
  53147. el.y = last.oldY;
  53148. }
  53149. } else {
  53150. if (last.oldShape) {
  53151. target.shape = extend({}, el.shape);
  53152. el.setShape(last.oldShape);
  53153. }
  53154. if (last.fadein) {
  53155. el.setStyle('opacity', 0);
  53156. target.style = {
  53157. opacity: 1
  53158. };
  53159. } // When animation is stopped for succedent animation starting,
  53160. // el.style.opacity might not be 1
  53161. else if (el.style.opacity !== 1) {
  53162. target.style = {
  53163. opacity: 1
  53164. };
  53165. }
  53166. }
  53167. animationWrap.add(el, target, duration, 0, easing);
  53168. });
  53169. }, this);
  53170. this._state = 'animating';
  53171. animationWrap.finished(bind(function () {
  53172. this._state = 'ready';
  53173. renderResult.renderFinally();
  53174. }, this)).start();
  53175. };
  53176. TreemapView.prototype._resetController = function (api) {
  53177. var controller = this._controller; // Init controller.
  53178. if (!controller) {
  53179. controller = this._controller = new RoamController(api.getZr());
  53180. controller.enable(this.seriesModel.get('roam'));
  53181. controller.on('pan', bind(this._onPan, this));
  53182. controller.on('zoom', bind(this._onZoom, this));
  53183. }
  53184. var rect = new BoundingRect(0, 0, api.getWidth(), api.getHeight());
  53185. controller.setPointerChecker(function (e, x, y) {
  53186. return rect.contain(x, y);
  53187. });
  53188. };
  53189. TreemapView.prototype._clearController = function () {
  53190. var controller = this._controller;
  53191. if (controller) {
  53192. controller.dispose();
  53193. controller = null;
  53194. }
  53195. };
  53196. TreemapView.prototype._onPan = function (e) {
  53197. if (this._state !== 'animating' && (Math.abs(e.dx) > DRAG_THRESHOLD || Math.abs(e.dy) > DRAG_THRESHOLD)) {
  53198. // These param must not be cached.
  53199. var root = this.seriesModel.getData().tree.root;
  53200. if (!root) {
  53201. return;
  53202. }
  53203. var rootLayout = root.getLayout();
  53204. if (!rootLayout) {
  53205. return;
  53206. }
  53207. this.api.dispatchAction({
  53208. type: 'treemapMove',
  53209. from: this.uid,
  53210. seriesId: this.seriesModel.id,
  53211. rootRect: {
  53212. x: rootLayout.x + e.dx,
  53213. y: rootLayout.y + e.dy,
  53214. width: rootLayout.width,
  53215. height: rootLayout.height
  53216. }
  53217. });
  53218. }
  53219. };
  53220. TreemapView.prototype._onZoom = function (e) {
  53221. var mouseX = e.originX;
  53222. var mouseY = e.originY;
  53223. if (this._state !== 'animating') {
  53224. // These param must not be cached.
  53225. var root = this.seriesModel.getData().tree.root;
  53226. if (!root) {
  53227. return;
  53228. }
  53229. var rootLayout = root.getLayout();
  53230. if (!rootLayout) {
  53231. return;
  53232. }
  53233. var rect = new BoundingRect(rootLayout.x, rootLayout.y, rootLayout.width, rootLayout.height);
  53234. var layoutInfo = this.seriesModel.layoutInfo; // Transform mouse coord from global to containerGroup.
  53235. mouseX -= layoutInfo.x;
  53236. mouseY -= layoutInfo.y; // Scale root bounding rect.
  53237. var m = create$1();
  53238. translate(m, m, [-mouseX, -mouseY]);
  53239. scale$1(m, m, [e.scale, e.scale]);
  53240. translate(m, m, [mouseX, mouseY]);
  53241. rect.applyTransform(m);
  53242. this.api.dispatchAction({
  53243. type: 'treemapRender',
  53244. from: this.uid,
  53245. seriesId: this.seriesModel.id,
  53246. rootRect: {
  53247. x: rect.x,
  53248. y: rect.y,
  53249. width: rect.width,
  53250. height: rect.height
  53251. }
  53252. });
  53253. }
  53254. };
  53255. TreemapView.prototype._initEvents = function (containerGroup) {
  53256. var _this = this;
  53257. containerGroup.on('click', function (e) {
  53258. if (_this._state !== 'ready') {
  53259. return;
  53260. }
  53261. var nodeClick = _this.seriesModel.get('nodeClick', true);
  53262. if (!nodeClick) {
  53263. return;
  53264. }
  53265. var targetInfo = _this.findTarget(e.offsetX, e.offsetY);
  53266. if (!targetInfo) {
  53267. return;
  53268. }
  53269. var node = targetInfo.node;
  53270. if (node.getLayout().isLeafRoot) {
  53271. _this._rootToNode(targetInfo);
  53272. } else {
  53273. if (nodeClick === 'zoomToNode') {
  53274. _this._zoomToNode(targetInfo);
  53275. } else if (nodeClick === 'link') {
  53276. var itemModel = node.hostTree.data.getItemModel(node.dataIndex);
  53277. var link = itemModel.get('link', true);
  53278. var linkTarget = itemModel.get('target', true) || 'blank';
  53279. link && windowOpen(link, linkTarget);
  53280. }
  53281. }
  53282. }, this);
  53283. };
  53284. TreemapView.prototype._renderBreadcrumb = function (seriesModel, api, targetInfo) {
  53285. var _this = this;
  53286. if (!targetInfo) {
  53287. targetInfo = seriesModel.get('leafDepth', true) != null ? {
  53288. node: seriesModel.getViewRoot()
  53289. } // FIXME
  53290. // better way?
  53291. // Find breadcrumb tail on center of containerGroup.
  53292. : this.findTarget(api.getWidth() / 2, api.getHeight() / 2);
  53293. if (!targetInfo) {
  53294. targetInfo = {
  53295. node: seriesModel.getData().tree.root
  53296. };
  53297. }
  53298. }
  53299. (this._breadcrumb || (this._breadcrumb = new Breadcrumb(this.group))).render(seriesModel, api, targetInfo.node, function (node) {
  53300. if (_this._state !== 'animating') {
  53301. aboveViewRoot(seriesModel.getViewRoot(), node) ? _this._rootToNode({
  53302. node: node
  53303. }) : _this._zoomToNode({
  53304. node: node
  53305. });
  53306. }
  53307. });
  53308. };
  53309. /**
  53310. * @override
  53311. */
  53312. TreemapView.prototype.remove = function () {
  53313. this._clearController();
  53314. this._containerGroup && this._containerGroup.removeAll();
  53315. this._storage = createStorage();
  53316. this._state = 'ready';
  53317. this._breadcrumb && this._breadcrumb.remove();
  53318. };
  53319. TreemapView.prototype.dispose = function () {
  53320. this._clearController();
  53321. };
  53322. TreemapView.prototype._zoomToNode = function (targetInfo) {
  53323. this.api.dispatchAction({
  53324. type: 'treemapZoomToNode',
  53325. from: this.uid,
  53326. seriesId: this.seriesModel.id,
  53327. targetNode: targetInfo.node
  53328. });
  53329. };
  53330. TreemapView.prototype._rootToNode = function (targetInfo) {
  53331. this.api.dispatchAction({
  53332. type: 'treemapRootToNode',
  53333. from: this.uid,
  53334. seriesId: this.seriesModel.id,
  53335. targetNode: targetInfo.node
  53336. });
  53337. };
  53338. /**
  53339. * @public
  53340. * @param {number} x Global coord x.
  53341. * @param {number} y Global coord y.
  53342. * @return {Object} info If not found, return undefined;
  53343. * @return {number} info.node Target node.
  53344. * @return {number} info.offsetX x refer to target node.
  53345. * @return {number} info.offsetY y refer to target node.
  53346. */
  53347. TreemapView.prototype.findTarget = function (x, y) {
  53348. var targetInfo;
  53349. var viewRoot = this.seriesModel.getViewRoot();
  53350. viewRoot.eachNode({
  53351. attr: 'viewChildren',
  53352. order: 'preorder'
  53353. }, function (node) {
  53354. var bgEl = this._storage.background[node.getRawIndex()]; // If invisible, there might be no element.
  53355. if (bgEl) {
  53356. var point = bgEl.transformCoordToLocal(x, y);
  53357. var shape = bgEl.shape; // For performance consideration, dont use 'getBoundingRect'.
  53358. if (shape.x <= point[0] && point[0] <= shape.x + shape.width && shape.y <= point[1] && point[1] <= shape.y + shape.height) {
  53359. targetInfo = {
  53360. node: node,
  53361. offsetX: point[0],
  53362. offsetY: point[1]
  53363. };
  53364. } else {
  53365. return false; // Suppress visit subtree.
  53366. }
  53367. }
  53368. }, this);
  53369. return targetInfo;
  53370. };
  53371. TreemapView.type = 'treemap';
  53372. return TreemapView;
  53373. }(ChartView);
  53374. /**
  53375. * @inner
  53376. */
  53377. function createStorage() {
  53378. return {
  53379. nodeGroup: [],
  53380. background: [],
  53381. content: []
  53382. };
  53383. }
  53384. /**
  53385. * @inner
  53386. * @return Return undefined means do not travel further.
  53387. */
  53388. function renderNode(seriesModel, thisStorage, oldStorage, reRoot, lastsForAnimation, willInvisibleEls, thisNode, oldNode, parentGroup, depth) {
  53389. // Whether under viewRoot.
  53390. if (!thisNode) {
  53391. // Deleting nodes will be performed finally. This method just find
  53392. // element from old storage, or create new element, set them to new
  53393. // storage, and set styles.
  53394. return;
  53395. } // -------------------------------------------------------------------
  53396. // Start of closure variables available in "Procedures in renderNode".
  53397. var thisLayout = thisNode.getLayout();
  53398. var data = seriesModel.getData();
  53399. var nodeModel = thisNode.getModel(); // Only for enabling highlight/downplay. Clear firstly.
  53400. // Because some node will not be rendered.
  53401. data.setItemGraphicEl(thisNode.dataIndex, null);
  53402. if (!thisLayout || !thisLayout.isInView) {
  53403. return;
  53404. }
  53405. var thisWidth = thisLayout.width;
  53406. var thisHeight = thisLayout.height;
  53407. var borderWidth = thisLayout.borderWidth;
  53408. var thisInvisible = thisLayout.invisible;
  53409. var thisRawIndex = thisNode.getRawIndex();
  53410. var oldRawIndex = oldNode && oldNode.getRawIndex();
  53411. var thisViewChildren = thisNode.viewChildren;
  53412. var upperHeight = thisLayout.upperHeight;
  53413. var isParent = thisViewChildren && thisViewChildren.length;
  53414. var itemStyleNormalModel = nodeModel.getModel('itemStyle');
  53415. var itemStyleEmphasisModel = nodeModel.getModel(['emphasis', 'itemStyle']);
  53416. var itemStyleBlurModel = nodeModel.getModel(['blur', 'itemStyle']);
  53417. var itemStyleSelectModel = nodeModel.getModel(['select', 'itemStyle']);
  53418. var borderRadius = itemStyleNormalModel.get('borderRadius') || 0; // End of closure ariables available in "Procedures in renderNode".
  53419. // -----------------------------------------------------------------
  53420. // Node group
  53421. var group = giveGraphic('nodeGroup', Group$2);
  53422. if (!group) {
  53423. return;
  53424. }
  53425. parentGroup.add(group); // x,y are not set when el is above view root.
  53426. group.x = thisLayout.x || 0;
  53427. group.y = thisLayout.y || 0;
  53428. group.markRedraw();
  53429. inner$7(group).nodeWidth = thisWidth;
  53430. inner$7(group).nodeHeight = thisHeight;
  53431. if (thisLayout.isAboveViewRoot) {
  53432. return group;
  53433. } // Background
  53434. var bg = giveGraphic('background', Rect$2, depth, Z2_BG);
  53435. bg && renderBackground(group, bg, isParent && thisLayout.upperLabelHeight);
  53436. var focus = nodeModel.get(['emphasis', 'focus']);
  53437. var blurScope = nodeModel.get(['emphasis', 'blurScope']);
  53438. var focusOrIndices = focus === 'ancestor' ? thisNode.getAncestorsIndices() : focus === 'descendant' ? thisNode.getDescendantIndices() : focus; // No children, render content.
  53439. if (isParent) {
  53440. // Because of the implementation about "traverse" in graphic hover style, we
  53441. // can not set hover listener on the "group" of non-leaf node. Otherwise the
  53442. // hover event from the descendents will be listenered.
  53443. if (isHighDownDispatcher(group)) {
  53444. setAsHighDownDispatcher(group, false);
  53445. }
  53446. if (bg) {
  53447. setAsHighDownDispatcher(bg, true); // Only for enabling highlight/downplay.
  53448. data.setItemGraphicEl(thisNode.dataIndex, bg);
  53449. enableHoverFocus(bg, focusOrIndices, blurScope);
  53450. }
  53451. } else {
  53452. var content = giveGraphic('content', Rect$2, depth, Z2_CONTENT);
  53453. content && renderContent(group, content);
  53454. if (bg && isHighDownDispatcher(bg)) {
  53455. setAsHighDownDispatcher(bg, false);
  53456. }
  53457. setAsHighDownDispatcher(group, true); // Only for enabling highlight/downplay.
  53458. data.setItemGraphicEl(thisNode.dataIndex, group);
  53459. enableHoverFocus(group, focusOrIndices, blurScope);
  53460. }
  53461. return group; // ----------------------------
  53462. // | Procedures in renderNode |
  53463. // ----------------------------
  53464. function renderBackground(group, bg, useUpperLabel) {
  53465. var ecData = getECData(bg); // For tooltip.
  53466. ecData.dataIndex = thisNode.dataIndex;
  53467. ecData.seriesIndex = seriesModel.seriesIndex;
  53468. bg.setShape({
  53469. x: 0,
  53470. y: 0,
  53471. width: thisWidth,
  53472. height: thisHeight,
  53473. r: borderRadius
  53474. });
  53475. if (thisInvisible) {
  53476. // If invisible, do not set visual, otherwise the element will
  53477. // change immediately before animation. We think it is OK to
  53478. // remain its origin color when moving out of the view window.
  53479. processInvisible(bg);
  53480. } else {
  53481. bg.invisible = false;
  53482. var style = thisNode.getVisual('style');
  53483. var visualBorderColor = style.stroke;
  53484. var normalStyle = getItemStyleNormal(itemStyleNormalModel);
  53485. normalStyle.fill = visualBorderColor;
  53486. var emphasisStyle = getStateItemStyle(itemStyleEmphasisModel);
  53487. emphasisStyle.fill = itemStyleEmphasisModel.get('borderColor');
  53488. var blurStyle = getStateItemStyle(itemStyleBlurModel);
  53489. blurStyle.fill = itemStyleBlurModel.get('borderColor');
  53490. var selectStyle = getStateItemStyle(itemStyleSelectModel);
  53491. selectStyle.fill = itemStyleSelectModel.get('borderColor');
  53492. if (useUpperLabel) {
  53493. var upperLabelWidth = thisWidth - 2 * borderWidth;
  53494. prepareText( // PENDING: convert ZRColor to ColorString for text.
  53495. bg, visualBorderColor, style.opacity, {
  53496. x: borderWidth,
  53497. y: 0,
  53498. width: upperLabelWidth,
  53499. height: upperHeight
  53500. });
  53501. } // For old bg.
  53502. else {
  53503. bg.removeTextContent();
  53504. }
  53505. bg.setStyle(normalStyle);
  53506. bg.ensureState('emphasis').style = emphasisStyle;
  53507. bg.ensureState('blur').style = blurStyle;
  53508. bg.ensureState('select').style = selectStyle;
  53509. setDefaultStateProxy(bg);
  53510. }
  53511. group.add(bg);
  53512. }
  53513. function renderContent(group, content) {
  53514. var ecData = getECData(content); // For tooltip.
  53515. ecData.dataIndex = thisNode.dataIndex;
  53516. ecData.seriesIndex = seriesModel.seriesIndex;
  53517. var contentWidth = Math.max(thisWidth - 2 * borderWidth, 0);
  53518. var contentHeight = Math.max(thisHeight - 2 * borderWidth, 0);
  53519. content.culling = true;
  53520. content.setShape({
  53521. x: borderWidth,
  53522. y: borderWidth,
  53523. width: contentWidth,
  53524. height: contentHeight,
  53525. r: borderRadius
  53526. });
  53527. if (thisInvisible) {
  53528. // If invisible, do not set visual, otherwise the element will
  53529. // change immediately before animation. We think it is OK to
  53530. // remain its origin color when moving out of the view window.
  53531. processInvisible(content);
  53532. } else {
  53533. content.invisible = false;
  53534. var nodeStyle = thisNode.getVisual('style');
  53535. var visualColor = nodeStyle.fill;
  53536. var normalStyle = getItemStyleNormal(itemStyleNormalModel);
  53537. normalStyle.fill = visualColor;
  53538. normalStyle.decal = nodeStyle.decal;
  53539. var emphasisStyle = getStateItemStyle(itemStyleEmphasisModel);
  53540. var blurStyle = getStateItemStyle(itemStyleBlurModel);
  53541. var selectStyle = getStateItemStyle(itemStyleSelectModel); // PENDING: convert ZRColor to ColorString for text.
  53542. prepareText(content, visualColor, nodeStyle.opacity, null);
  53543. content.setStyle(normalStyle);
  53544. content.ensureState('emphasis').style = emphasisStyle;
  53545. content.ensureState('blur').style = blurStyle;
  53546. content.ensureState('select').style = selectStyle;
  53547. setDefaultStateProxy(content);
  53548. }
  53549. group.add(content);
  53550. }
  53551. function processInvisible(element) {
  53552. // Delay invisible setting utill animation finished,
  53553. // avoid element vanish suddenly before animation.
  53554. !element.invisible && willInvisibleEls.push(element);
  53555. }
  53556. function prepareText(rectEl, visualColor, visualOpacity, // Can be null/undefined
  53557. upperLabelRect) {
  53558. var normalLabelModel = nodeModel.getModel(upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL);
  53559. var defaultText = convertOptionIdName(nodeModel.get('name'), null);
  53560. var isShow = normalLabelModel.getShallow('show');
  53561. setLabelStyle(rectEl, getLabelStatesModels(nodeModel, upperLabelRect ? PATH_UPPERLABEL_NORMAL : PATH_LABEL_NOAMAL), {
  53562. defaultText: isShow ? defaultText : null,
  53563. inheritColor: visualColor,
  53564. defaultOpacity: visualOpacity,
  53565. labelFetcher: seriesModel,
  53566. labelDataIndex: thisNode.dataIndex
  53567. });
  53568. var textEl = rectEl.getTextContent();
  53569. var textStyle = textEl.style;
  53570. var textPadding = normalizeCssArray(textStyle.padding || 0);
  53571. if (upperLabelRect) {
  53572. rectEl.setTextConfig({
  53573. layoutRect: upperLabelRect
  53574. });
  53575. textEl.disableLabelLayout = true;
  53576. }
  53577. textEl.beforeUpdate = function () {
  53578. var width = Math.max((upperLabelRect ? upperLabelRect.width : rectEl.shape.width) - textPadding[1] - textPadding[3], 0);
  53579. var height = Math.max((upperLabelRect ? upperLabelRect.height : rectEl.shape.height) - textPadding[0] - textPadding[2], 0);
  53580. if (textStyle.width !== width || textStyle.height !== height) {
  53581. textEl.setStyle({
  53582. width: width,
  53583. height: height
  53584. });
  53585. }
  53586. };
  53587. textStyle.truncateMinChar = 2;
  53588. textStyle.lineOverflow = 'truncate';
  53589. addDrillDownIcon(textStyle, upperLabelRect, thisLayout);
  53590. var textEmphasisState = textEl.getState('emphasis');
  53591. addDrillDownIcon(textEmphasisState ? textEmphasisState.style : null, upperLabelRect, thisLayout);
  53592. }
  53593. function addDrillDownIcon(style, upperLabelRect, thisLayout) {
  53594. var text = style ? style.text : null;
  53595. if (!upperLabelRect && thisLayout.isLeafRoot && text != null) {
  53596. var iconChar = seriesModel.get('drillDownIcon', true);
  53597. style.text = iconChar ? iconChar + ' ' + text : text;
  53598. }
  53599. }
  53600. function giveGraphic(storageName, Ctor, depth, z) {
  53601. var element = oldRawIndex != null && oldStorage[storageName][oldRawIndex];
  53602. var lasts = lastsForAnimation[storageName];
  53603. if (element) {
  53604. // Remove from oldStorage
  53605. oldStorage[storageName][oldRawIndex] = null;
  53606. prepareAnimationWhenHasOld(lasts, element);
  53607. } // If invisible and no old element, do not create new element (for optimizing).
  53608. else if (!thisInvisible) {
  53609. element = new Ctor();
  53610. if (element instanceof Displayable) {
  53611. element.z2 = calculateZ2(depth, z);
  53612. }
  53613. prepareAnimationWhenNoOld(lasts, element);
  53614. } // Set to thisStorage
  53615. return thisStorage[storageName][thisRawIndex] = element;
  53616. }
  53617. function prepareAnimationWhenHasOld(lasts, element) {
  53618. var lastCfg = lasts[thisRawIndex] = {};
  53619. if (element instanceof Group$2) {
  53620. lastCfg.oldX = element.x;
  53621. lastCfg.oldY = element.y;
  53622. } else {
  53623. lastCfg.oldShape = extend({}, element.shape);
  53624. }
  53625. } // If a element is new, we need to find the animation start point carefully,
  53626. // otherwise it will looks strange when 'zoomToNode'.
  53627. function prepareAnimationWhenNoOld(lasts, element) {
  53628. var lastCfg = lasts[thisRawIndex] = {};
  53629. var parentNode = thisNode.parentNode;
  53630. var isGroup = element instanceof Group;
  53631. if (parentNode && (!reRoot || reRoot.direction === 'drillDown')) {
  53632. var parentOldX = 0;
  53633. var parentOldY = 0; // New nodes appear from right-bottom corner in 'zoomToNode' animation.
  53634. // For convenience, get old bounding rect from background.
  53635. var parentOldBg = lastsForAnimation.background[parentNode.getRawIndex()];
  53636. if (!reRoot && parentOldBg && parentOldBg.oldShape) {
  53637. parentOldX = parentOldBg.oldShape.width;
  53638. parentOldY = parentOldBg.oldShape.height;
  53639. } // When no parent old shape found, its parent is new too,
  53640. // so we can just use {x:0, y:0}.
  53641. if (isGroup) {
  53642. lastCfg.oldX = 0;
  53643. lastCfg.oldY = parentOldY;
  53644. } else {
  53645. lastCfg.oldShape = {
  53646. x: parentOldX,
  53647. y: parentOldY,
  53648. width: 0,
  53649. height: 0
  53650. };
  53651. }
  53652. } // Fade in, user can be aware that these nodes are new.
  53653. lastCfg.fadein = !isGroup;
  53654. }
  53655. } // We can not set all backgroud with the same z, Because the behaviour of
  53656. // drill down and roll up differ background creation sequence from tree
  53657. // hierarchy sequence, which cause that lowser background element overlap
  53658. // upper ones. So we calculate z based on depth.
  53659. // Moreover, we try to shrink down z interval to [0, 1] to avoid that
  53660. // treemap with large z overlaps other components.
  53661. function calculateZ2(depth, z2InLevel) {
  53662. return depth * Z2_BASE + z2InLevel;
  53663. }
  53664. /*
  53665. * Licensed to the Apache Software Foundation (ASF) under one
  53666. * or more contributor license agreements. See the NOTICE file
  53667. * distributed with this work for additional information
  53668. * regarding copyright ownership. The ASF licenses this file
  53669. * to you under the Apache License, Version 2.0 (the
  53670. * "License"); you may not use this file except in compliance
  53671. * with the License. You may obtain a copy of the License at
  53672. *
  53673. * http://www.apache.org/licenses/LICENSE-2.0
  53674. *
  53675. * Unless required by applicable law or agreed to in writing,
  53676. * software distributed under the License is distributed on an
  53677. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  53678. * KIND, either express or implied. See the License for the
  53679. * specific language governing permissions and limitations
  53680. * under the License.
  53681. */
  53682. /**
  53683. * AUTO-GENERATED FILE. DO NOT MODIFY.
  53684. */
  53685. /*
  53686. * Licensed to the Apache Software Foundation (ASF) under one
  53687. * or more contributor license agreements. See the NOTICE file
  53688. * distributed with this work for additional information
  53689. * regarding copyright ownership. The ASF licenses this file
  53690. * to you under the Apache License, Version 2.0 (the
  53691. * "License"); you may not use this file except in compliance
  53692. * with the License. You may obtain a copy of the License at
  53693. *
  53694. * http://www.apache.org/licenses/LICENSE-2.0
  53695. *
  53696. * Unless required by applicable law or agreed to in writing,
  53697. * software distributed under the License is distributed on an
  53698. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  53699. * KIND, either express or implied. See the License for the
  53700. * specific language governing permissions and limitations
  53701. * under the License.
  53702. */
  53703. var each$4 = each$1;
  53704. var isObject$4 = isObject$1;
  53705. var CATEGORY_DEFAULT_VISUAL_INDEX = -1;
  53706. var VisualMapping =
  53707. /** @class */
  53708. function () {
  53709. function VisualMapping(option) {
  53710. var mappingMethod = option.mappingMethod;
  53711. var visualType = option.type;
  53712. var thisOption = this.option = clone(option);
  53713. this.type = visualType;
  53714. this.mappingMethod = mappingMethod;
  53715. this._normalizeData = normalizers[mappingMethod];
  53716. var visualHandler = VisualMapping.visualHandlers[visualType];
  53717. this.applyVisual = visualHandler.applyVisual;
  53718. this.getColorMapper = visualHandler.getColorMapper;
  53719. this._normalizedToVisual = visualHandler._normalizedToVisual[mappingMethod];
  53720. if (mappingMethod === 'piecewise') {
  53721. normalizeVisualRange(thisOption);
  53722. preprocessForPiecewise(thisOption);
  53723. } else if (mappingMethod === 'category') {
  53724. thisOption.categories ? preprocessForSpecifiedCategory(thisOption) // categories is ordinal when thisOption.categories not specified,
  53725. // which need no more preprocess except normalize visual.
  53726. : normalizeVisualRange(thisOption, true);
  53727. } else {
  53728. // mappingMethod === 'linear' or 'fixed'
  53729. assert$1(mappingMethod !== 'linear' || thisOption.dataExtent);
  53730. normalizeVisualRange(thisOption);
  53731. }
  53732. }
  53733. VisualMapping.prototype.mapValueToVisual = function (value) {
  53734. var normalized = this._normalizeData(value);
  53735. return this._normalizedToVisual(normalized, value);
  53736. };
  53737. VisualMapping.prototype.getNormalizer = function () {
  53738. return bind(this._normalizeData, this);
  53739. };
  53740. /**
  53741. * List available visual types.
  53742. *
  53743. * @public
  53744. * @return {Array.<string>}
  53745. */
  53746. VisualMapping.listVisualTypes = function () {
  53747. return keys(VisualMapping.visualHandlers);
  53748. }; // /**
  53749. // * @public
  53750. // */
  53751. // static addVisualHandler(name, handler) {
  53752. // visualHandlers[name] = handler;
  53753. // }
  53754. /**
  53755. * @public
  53756. */
  53757. VisualMapping.isValidType = function (visualType) {
  53758. return VisualMapping.visualHandlers.hasOwnProperty(visualType);
  53759. };
  53760. /**
  53761. * Convinent method.
  53762. * Visual can be Object or Array or primary type.
  53763. */
  53764. VisualMapping.eachVisual = function (visual, callback, context) {
  53765. if (isObject$1(visual)) {
  53766. each$1(visual, callback, context);
  53767. } else {
  53768. callback.call(context, visual);
  53769. }
  53770. };
  53771. VisualMapping.mapVisual = function (visual, callback, context) {
  53772. var isPrimary;
  53773. var newVisual = isArray(visual) ? [] : isObject$1(visual) ? {} : (isPrimary = true, null);
  53774. VisualMapping.eachVisual(visual, function (v, key) {
  53775. var newVal = callback.call(context, v, key);
  53776. isPrimary ? newVisual = newVal : newVisual[key] = newVal;
  53777. });
  53778. return newVisual;
  53779. };
  53780. /**
  53781. * Retrieve visual properties from given object.
  53782. */
  53783. VisualMapping.retrieveVisuals = function (obj) {
  53784. var ret = {};
  53785. var hasVisual;
  53786. obj && each$4(VisualMapping.visualHandlers, function (h, visualType) {
  53787. if (obj.hasOwnProperty(visualType)) {
  53788. ret[visualType] = obj[visualType];
  53789. hasVisual = true;
  53790. }
  53791. });
  53792. return hasVisual ? ret : null;
  53793. };
  53794. /**
  53795. * Give order to visual types, considering colorSaturation, colorAlpha depends on color.
  53796. *
  53797. * @public
  53798. * @param {(Object|Array)} visualTypes If Object, like: {color: ..., colorSaturation: ...}
  53799. * IF Array, like: ['color', 'symbol', 'colorSaturation']
  53800. * @return {Array.<string>} Sorted visual types.
  53801. */
  53802. VisualMapping.prepareVisualTypes = function (visualTypes) {
  53803. if (isArray(visualTypes)) {
  53804. visualTypes = visualTypes.slice();
  53805. } else if (isObject$4(visualTypes)) {
  53806. var types_1 = [];
  53807. each$4(visualTypes, function (item, type) {
  53808. types_1.push(type);
  53809. });
  53810. visualTypes = types_1;
  53811. } else {
  53812. return [];
  53813. }
  53814. visualTypes.sort(function (type1, type2) {
  53815. // color should be front of colorSaturation, colorAlpha, ...
  53816. // symbol and symbolSize do not matter.
  53817. return type2 === 'color' && type1 !== 'color' && type1.indexOf('color') === 0 ? 1 : -1;
  53818. });
  53819. return visualTypes;
  53820. };
  53821. /**
  53822. * 'color', 'colorSaturation', 'colorAlpha', ... are depends on 'color'.
  53823. * Other visuals are only depends on themself.
  53824. */
  53825. VisualMapping.dependsOn = function (visualType1, visualType2) {
  53826. return visualType2 === 'color' ? !!(visualType1 && visualType1.indexOf(visualType2) === 0) : visualType1 === visualType2;
  53827. };
  53828. /**
  53829. * @param value
  53830. * @param pieceList [{value: ..., interval: [min, max]}, ...]
  53831. * Always from small to big.
  53832. * @param findClosestWhenOutside Default to be false
  53833. * @return index
  53834. */
  53835. VisualMapping.findPieceIndex = function (value, pieceList, findClosestWhenOutside) {
  53836. var possibleI;
  53837. var abs = Infinity; // value has the higher priority.
  53838. for (var i = 0, len = pieceList.length; i < len; i++) {
  53839. var pieceValue = pieceList[i].value;
  53840. if (pieceValue != null) {
  53841. if (pieceValue === value // FIXME
  53842. // It is supposed to compare value according to value type of dimension,
  53843. // but currently value type can exactly be string or number.
  53844. // Compromise for numeric-like string (like '12'), especially
  53845. // in the case that visualMap.categories is ['22', '33'].
  53846. || typeof pieceValue === 'string' && pieceValue === value + '') {
  53847. return i;
  53848. }
  53849. findClosestWhenOutside && updatePossible(pieceValue, i);
  53850. }
  53851. }
  53852. for (var i = 0, len = pieceList.length; i < len; i++) {
  53853. var piece = pieceList[i];
  53854. var interval = piece.interval;
  53855. var close_1 = piece.close;
  53856. if (interval) {
  53857. if (interval[0] === -Infinity) {
  53858. if (littleThan(close_1[1], value, interval[1])) {
  53859. return i;
  53860. }
  53861. } else if (interval[1] === Infinity) {
  53862. if (littleThan(close_1[0], interval[0], value)) {
  53863. return i;
  53864. }
  53865. } else if (littleThan(close_1[0], interval[0], value) && littleThan(close_1[1], value, interval[1])) {
  53866. return i;
  53867. }
  53868. findClosestWhenOutside && updatePossible(interval[0], i);
  53869. findClosestWhenOutside && updatePossible(interval[1], i);
  53870. }
  53871. }
  53872. if (findClosestWhenOutside) {
  53873. return value === Infinity ? pieceList.length - 1 : value === -Infinity ? 0 : possibleI;
  53874. }
  53875. function updatePossible(val, index) {
  53876. var newAbs = Math.abs(val - value);
  53877. if (newAbs < abs) {
  53878. abs = newAbs;
  53879. possibleI = index;
  53880. }
  53881. }
  53882. };
  53883. VisualMapping.visualHandlers = {
  53884. color: {
  53885. applyVisual: makeApplyVisual('color'),
  53886. getColorMapper: function () {
  53887. var thisOption = this.option;
  53888. return bind(thisOption.mappingMethod === 'category' ? function (value, isNormalized) {
  53889. !isNormalized && (value = this._normalizeData(value));
  53890. return doMapCategory.call(this, value);
  53891. } : function (value, isNormalized, out) {
  53892. // If output rgb array
  53893. // which will be much faster and useful in pixel manipulation
  53894. var returnRGBArray = !!out;
  53895. !isNormalized && (value = this._normalizeData(value));
  53896. out = fastLerp(value, thisOption.parsedVisual, out);
  53897. return returnRGBArray ? out : stringify(out, 'rgba');
  53898. }, this);
  53899. },
  53900. _normalizedToVisual: {
  53901. linear: function (normalized) {
  53902. return stringify(fastLerp(normalized, this.option.parsedVisual), 'rgba');
  53903. },
  53904. category: doMapCategory,
  53905. piecewise: function (normalized, value) {
  53906. var result = getSpecifiedVisual.call(this, value);
  53907. if (result == null) {
  53908. result = stringify(fastLerp(normalized, this.option.parsedVisual), 'rgba');
  53909. }
  53910. return result;
  53911. },
  53912. fixed: doMapFixed
  53913. }
  53914. },
  53915. colorHue: makePartialColorVisualHandler(function (color, value) {
  53916. return modifyHSL(color, value);
  53917. }),
  53918. colorSaturation: makePartialColorVisualHandler(function (color, value) {
  53919. return modifyHSL(color, null, value);
  53920. }),
  53921. colorLightness: makePartialColorVisualHandler(function (color, value) {
  53922. return modifyHSL(color, null, null, value);
  53923. }),
  53924. colorAlpha: makePartialColorVisualHandler(function (color, value) {
  53925. return modifyAlpha(color, value);
  53926. }),
  53927. decal: {
  53928. applyVisual: makeApplyVisual('decal'),
  53929. _normalizedToVisual: {
  53930. linear: null,
  53931. category: doMapCategory,
  53932. piecewise: null,
  53933. fixed: null
  53934. }
  53935. },
  53936. opacity: {
  53937. applyVisual: makeApplyVisual('opacity'),
  53938. _normalizedToVisual: createNormalizedToNumericVisual([0, 1])
  53939. },
  53940. liftZ: {
  53941. applyVisual: makeApplyVisual('liftZ'),
  53942. _normalizedToVisual: {
  53943. linear: doMapFixed,
  53944. category: doMapFixed,
  53945. piecewise: doMapFixed,
  53946. fixed: doMapFixed
  53947. }
  53948. },
  53949. symbol: {
  53950. applyVisual: function (value, getter, setter) {
  53951. var symbolCfg = this.mapValueToVisual(value);
  53952. setter('symbol', symbolCfg);
  53953. },
  53954. _normalizedToVisual: {
  53955. linear: doMapToArray,
  53956. category: doMapCategory,
  53957. piecewise: function (normalized, value) {
  53958. var result = getSpecifiedVisual.call(this, value);
  53959. if (result == null) {
  53960. result = doMapToArray.call(this, normalized);
  53961. }
  53962. return result;
  53963. },
  53964. fixed: doMapFixed
  53965. }
  53966. },
  53967. symbolSize: {
  53968. applyVisual: makeApplyVisual('symbolSize'),
  53969. _normalizedToVisual: createNormalizedToNumericVisual([0, 1])
  53970. }
  53971. };
  53972. return VisualMapping;
  53973. }();
  53974. function preprocessForPiecewise(thisOption) {
  53975. var pieceList = thisOption.pieceList;
  53976. thisOption.hasSpecialVisual = false;
  53977. each$1(pieceList, function (piece, index) {
  53978. piece.originIndex = index; // piece.visual is "result visual value" but not
  53979. // a visual range, so it does not need to be normalized.
  53980. if (piece.visual != null) {
  53981. thisOption.hasSpecialVisual = true;
  53982. }
  53983. });
  53984. }
  53985. function preprocessForSpecifiedCategory(thisOption) {
  53986. // Hash categories.
  53987. var categories = thisOption.categories;
  53988. var categoryMap = thisOption.categoryMap = {};
  53989. var visual = thisOption.visual;
  53990. each$4(categories, function (cate, index) {
  53991. categoryMap[cate] = index;
  53992. }); // Process visual map input.
  53993. if (!isArray(visual)) {
  53994. var visualArr_1 = [];
  53995. if (isObject$1(visual)) {
  53996. each$4(visual, function (v, cate) {
  53997. var index = categoryMap[cate];
  53998. visualArr_1[index != null ? index : CATEGORY_DEFAULT_VISUAL_INDEX] = v;
  53999. });
  54000. } else {
  54001. // Is primary type, represents default visual.
  54002. visualArr_1[CATEGORY_DEFAULT_VISUAL_INDEX] = visual;
  54003. }
  54004. visual = setVisualToOption(thisOption, visualArr_1);
  54005. } // Remove categories that has no visual,
  54006. // then we can mapping them to CATEGORY_DEFAULT_VISUAL_INDEX.
  54007. for (var i = categories.length - 1; i >= 0; i--) {
  54008. if (visual[i] == null) {
  54009. delete categoryMap[categories[i]];
  54010. categories.pop();
  54011. }
  54012. }
  54013. }
  54014. function normalizeVisualRange(thisOption, isCategory) {
  54015. var visual = thisOption.visual;
  54016. var visualArr = [];
  54017. if (isObject$1(visual)) {
  54018. each$4(visual, function (v) {
  54019. visualArr.push(v);
  54020. });
  54021. } else if (visual != null) {
  54022. visualArr.push(visual);
  54023. }
  54024. var doNotNeedPair = {
  54025. color: 1,
  54026. symbol: 1
  54027. };
  54028. if (!isCategory && visualArr.length === 1 && !doNotNeedPair.hasOwnProperty(thisOption.type)) {
  54029. // Do not care visualArr.length === 0, which is illegal.
  54030. visualArr[1] = visualArr[0];
  54031. }
  54032. setVisualToOption(thisOption, visualArr);
  54033. }
  54034. function makePartialColorVisualHandler(applyValue) {
  54035. return {
  54036. applyVisual: function (value, getter, setter) {
  54037. // Only used in HSL
  54038. var colorChannel = this.mapValueToVisual(value); // Must not be array value
  54039. setter('color', applyValue(getter('color'), colorChannel));
  54040. },
  54041. _normalizedToVisual: createNormalizedToNumericVisual([0, 1])
  54042. };
  54043. }
  54044. function doMapToArray(normalized) {
  54045. var visual = this.option.visual;
  54046. return visual[Math.round(linearMap(normalized, [0, 1], [0, visual.length - 1], true))] || {}; // TODO {}?
  54047. }
  54048. function makeApplyVisual(visualType) {
  54049. return function (value, getter, setter) {
  54050. setter(visualType, this.mapValueToVisual(value));
  54051. };
  54052. }
  54053. function doMapCategory(normalized) {
  54054. var visual = this.option.visual;
  54055. return visual[this.option.loop && normalized !== CATEGORY_DEFAULT_VISUAL_INDEX ? normalized % visual.length : normalized];
  54056. }
  54057. function doMapFixed() {
  54058. // visual will be convert to array.
  54059. return this.option.visual[0];
  54060. }
  54061. /**
  54062. * Create mapped to numeric visual
  54063. */
  54064. function createNormalizedToNumericVisual(sourceExtent) {
  54065. return {
  54066. linear: function (normalized) {
  54067. return linearMap(normalized, sourceExtent, this.option.visual, true);
  54068. },
  54069. category: doMapCategory,
  54070. piecewise: function (normalized, value) {
  54071. var result = getSpecifiedVisual.call(this, value);
  54072. if (result == null) {
  54073. result = linearMap(normalized, sourceExtent, this.option.visual, true);
  54074. }
  54075. return result;
  54076. },
  54077. fixed: doMapFixed
  54078. };
  54079. }
  54080. function getSpecifiedVisual(value) {
  54081. var thisOption = this.option;
  54082. var pieceList = thisOption.pieceList;
  54083. if (thisOption.hasSpecialVisual) {
  54084. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList);
  54085. var piece = pieceList[pieceIndex];
  54086. if (piece && piece.visual) {
  54087. return piece.visual[this.type];
  54088. }
  54089. }
  54090. }
  54091. function setVisualToOption(thisOption, visualArr) {
  54092. thisOption.visual = visualArr;
  54093. if (thisOption.type === 'color') {
  54094. thisOption.parsedVisual = map(visualArr, function (item) {
  54095. return parse(item);
  54096. });
  54097. }
  54098. return visualArr;
  54099. }
  54100. /**
  54101. * Normalizers by mapping methods.
  54102. */
  54103. var normalizers = {
  54104. linear: function (value) {
  54105. return linearMap(value, this.option.dataExtent, [0, 1], true);
  54106. },
  54107. piecewise: function (value) {
  54108. var pieceList = this.option.pieceList;
  54109. var pieceIndex = VisualMapping.findPieceIndex(value, pieceList, true);
  54110. if (pieceIndex != null) {
  54111. return linearMap(pieceIndex, [0, pieceList.length - 1], [0, 1], true);
  54112. }
  54113. },
  54114. category: function (value) {
  54115. var index = this.option.categories ? this.option.categoryMap[value] : value; // ordinal value
  54116. return index == null ? CATEGORY_DEFAULT_VISUAL_INDEX : index;
  54117. },
  54118. fixed: noop
  54119. };
  54120. function littleThan(close, a, b) {
  54121. return close ? a <= b : a < b;
  54122. }
  54123. /*
  54124. * Licensed to the Apache Software Foundation (ASF) under one
  54125. * or more contributor license agreements. See the NOTICE file
  54126. * distributed with this work for additional information
  54127. * regarding copyright ownership. The ASF licenses this file
  54128. * to you under the Apache License, Version 2.0 (the
  54129. * "License"); you may not use this file except in compliance
  54130. * with the License. You may obtain a copy of the License at
  54131. *
  54132. * http://www.apache.org/licenses/LICENSE-2.0
  54133. *
  54134. * Unless required by applicable law or agreed to in writing,
  54135. * software distributed under the License is distributed on an
  54136. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54137. * KIND, either express or implied. See the License for the
  54138. * specific language governing permissions and limitations
  54139. * under the License.
  54140. */
  54141. /**
  54142. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54143. */
  54144. /*
  54145. * Licensed to the Apache Software Foundation (ASF) under one
  54146. * or more contributor license agreements. See the NOTICE file
  54147. * distributed with this work for additional information
  54148. * regarding copyright ownership. The ASF licenses this file
  54149. * to you under the Apache License, Version 2.0 (the
  54150. * "License"); you may not use this file except in compliance
  54151. * with the License. You may obtain a copy of the License at
  54152. *
  54153. * http://www.apache.org/licenses/LICENSE-2.0
  54154. *
  54155. * Unless required by applicable law or agreed to in writing,
  54156. * software distributed under the License is distributed on an
  54157. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54158. * KIND, either express or implied. See the License for the
  54159. * specific language governing permissions and limitations
  54160. * under the License.
  54161. */
  54162. var ITEM_STYLE_NORMAL = 'itemStyle';
  54163. var inner$8 = makeInner();
  54164. var treemapVisual = {
  54165. seriesType: 'treemap',
  54166. reset: function (seriesModel) {
  54167. var tree = seriesModel.getData().tree;
  54168. var root = tree.root;
  54169. if (root.isRemoved()) {
  54170. return;
  54171. }
  54172. travelTree(root, // Visual should calculate from tree root but not view root.
  54173. {}, seriesModel.getViewRoot().getAncestors(), seriesModel);
  54174. }
  54175. };
  54176. function travelTree(node, designatedVisual, viewRootAncestors, seriesModel) {
  54177. var nodeModel = node.getModel();
  54178. var nodeLayout = node.getLayout();
  54179. var data = node.hostTree.data; // Optimize
  54180. if (!nodeLayout || nodeLayout.invisible || !nodeLayout.isInView) {
  54181. return;
  54182. }
  54183. var nodeItemStyleModel = nodeModel.getModel(ITEM_STYLE_NORMAL);
  54184. var visuals = buildVisuals(nodeItemStyleModel, designatedVisual, seriesModel);
  54185. var existsStyle = data.ensureUniqueItemVisual(node.dataIndex, 'style'); // calculate border color
  54186. var borderColor = nodeItemStyleModel.get('borderColor');
  54187. var borderColorSaturation = nodeItemStyleModel.get('borderColorSaturation');
  54188. var thisNodeColor;
  54189. if (borderColorSaturation != null) {
  54190. // For performance, do not always execute 'calculateColor'.
  54191. thisNodeColor = calculateColor(visuals);
  54192. borderColor = calculateBorderColor(borderColorSaturation, thisNodeColor);
  54193. }
  54194. existsStyle.stroke = borderColor;
  54195. var viewChildren = node.viewChildren;
  54196. if (!viewChildren || !viewChildren.length) {
  54197. thisNodeColor = calculateColor(visuals); // Apply visual to this node.
  54198. existsStyle.fill = thisNodeColor;
  54199. } else {
  54200. var mapping_1 = buildVisualMapping(node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren); // Designate visual to children.
  54201. each$1(viewChildren, function (child, index) {
  54202. // If higher than viewRoot, only ancestors of viewRoot is needed to visit.
  54203. if (child.depth >= viewRootAncestors.length || child === viewRootAncestors[child.depth]) {
  54204. var childVisual = mapVisual(nodeModel, visuals, child, index, mapping_1, seriesModel);
  54205. travelTree(child, childVisual, viewRootAncestors, seriesModel);
  54206. }
  54207. });
  54208. }
  54209. }
  54210. function buildVisuals(nodeItemStyleModel, designatedVisual, seriesModel) {
  54211. var visuals = extend({}, designatedVisual);
  54212. var designatedVisualItemStyle = seriesModel.designatedVisualItemStyle;
  54213. each$1(['color', 'colorAlpha', 'colorSaturation'], function (visualName) {
  54214. // Priority: thisNode > thisLevel > parentNodeDesignated > seriesModel
  54215. designatedVisualItemStyle[visualName] = designatedVisual[visualName];
  54216. var val = nodeItemStyleModel.get(visualName);
  54217. designatedVisualItemStyle[visualName] = null;
  54218. val != null && (visuals[visualName] = val);
  54219. });
  54220. return visuals;
  54221. }
  54222. function calculateColor(visuals) {
  54223. var color = getValueVisualDefine(visuals, 'color');
  54224. if (color) {
  54225. var colorAlpha = getValueVisualDefine(visuals, 'colorAlpha');
  54226. var colorSaturation = getValueVisualDefine(visuals, 'colorSaturation');
  54227. if (colorSaturation) {
  54228. color = modifyHSL(color, null, null, colorSaturation);
  54229. }
  54230. if (colorAlpha) {
  54231. color = modifyAlpha(color, colorAlpha);
  54232. }
  54233. return color;
  54234. }
  54235. }
  54236. function calculateBorderColor(borderColorSaturation, thisNodeColor) {
  54237. return thisNodeColor != null // Can only be string
  54238. ? modifyHSL(thisNodeColor, null, null, borderColorSaturation) : null;
  54239. }
  54240. function getValueVisualDefine(visuals, name) {
  54241. var value = visuals[name];
  54242. if (value != null && value !== 'none') {
  54243. return value;
  54244. }
  54245. }
  54246. function buildVisualMapping(node, nodeModel, nodeLayout, nodeItemStyleModel, visuals, viewChildren) {
  54247. if (!viewChildren || !viewChildren.length) {
  54248. return;
  54249. }
  54250. var rangeVisual = getRangeVisual(nodeModel, 'color') || visuals.color != null && visuals.color !== 'none' && (getRangeVisual(nodeModel, 'colorAlpha') || getRangeVisual(nodeModel, 'colorSaturation'));
  54251. if (!rangeVisual) {
  54252. return;
  54253. }
  54254. var visualMin = nodeModel.get('visualMin');
  54255. var visualMax = nodeModel.get('visualMax');
  54256. var dataExtent = nodeLayout.dataExtent.slice();
  54257. visualMin != null && visualMin < dataExtent[0] && (dataExtent[0] = visualMin);
  54258. visualMax != null && visualMax > dataExtent[1] && (dataExtent[1] = visualMax);
  54259. var colorMappingBy = nodeModel.get('colorMappingBy');
  54260. var opt = {
  54261. type: rangeVisual.name,
  54262. dataExtent: dataExtent,
  54263. visual: rangeVisual.range
  54264. };
  54265. if (opt.type === 'color' && (colorMappingBy === 'index' || colorMappingBy === 'id')) {
  54266. opt.mappingMethod = 'category';
  54267. opt.loop = true; // categories is ordinal, so do not set opt.categories.
  54268. } else {
  54269. opt.mappingMethod = 'linear';
  54270. }
  54271. var mapping = new VisualMapping(opt);
  54272. inner$8(mapping).drColorMappingBy = colorMappingBy;
  54273. return mapping;
  54274. } // Notice: If we dont have the attribute 'colorRange', but only use
  54275. // attribute 'color' to represent both concepts of 'colorRange' and 'color',
  54276. // (It means 'colorRange' when 'color' is Array, means 'color' when not array),
  54277. // this problem will be encountered:
  54278. // If a level-1 node dont have children, and its siblings has children,
  54279. // and colorRange is set on level-1, then the node can not be colored.
  54280. // So we separate 'colorRange' and 'color' to different attributes.
  54281. function getRangeVisual(nodeModel, name) {
  54282. // 'colorRange', 'colorARange', 'colorSRange'.
  54283. // If not exsits on this node, fetch from levels and series.
  54284. var range = nodeModel.get(name);
  54285. return isArray(range) && range.length ? {
  54286. name: name,
  54287. range: range
  54288. } : null;
  54289. }
  54290. function mapVisual(nodeModel, visuals, child, index, mapping, seriesModel) {
  54291. var childVisuals = extend({}, visuals);
  54292. if (mapping) {
  54293. // Only support color, colorAlpha, colorSaturation.
  54294. var mappingType = mapping.type;
  54295. var colorMappingBy = mappingType === 'color' && inner$8(mapping).drColorMappingBy;
  54296. var value = colorMappingBy === 'index' ? index : colorMappingBy === 'id' ? seriesModel.mapIdToIndex(child.getId()) : child.getValue(nodeModel.get('visualDimension'));
  54297. childVisuals[mappingType] = mapping.mapValueToVisual(value);
  54298. }
  54299. return childVisuals;
  54300. }
  54301. /*
  54302. * Licensed to the Apache Software Foundation (ASF) under one
  54303. * or more contributor license agreements. See the NOTICE file
  54304. * distributed with this work for additional information
  54305. * regarding copyright ownership. The ASF licenses this file
  54306. * to you under the Apache License, Version 2.0 (the
  54307. * "License"); you may not use this file except in compliance
  54308. * with the License. You may obtain a copy of the License at
  54309. *
  54310. * http://www.apache.org/licenses/LICENSE-2.0
  54311. *
  54312. * Unless required by applicable law or agreed to in writing,
  54313. * software distributed under the License is distributed on an
  54314. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54315. * KIND, either express or implied. See the License for the
  54316. * specific language governing permissions and limitations
  54317. * under the License.
  54318. */
  54319. /**
  54320. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54321. */
  54322. /*
  54323. * Licensed to the Apache Software Foundation (ASF) under one
  54324. * or more contributor license agreements. See the NOTICE file
  54325. * distributed with this work for additional information
  54326. * regarding copyright ownership. The ASF licenses this file
  54327. * to you under the Apache License, Version 2.0 (the
  54328. * "License"); you may not use this file except in compliance
  54329. * with the License. You may obtain a copy of the License at
  54330. *
  54331. * http://www.apache.org/licenses/LICENSE-2.0
  54332. *
  54333. * Unless required by applicable law or agreed to in writing,
  54334. * software distributed under the License is distributed on an
  54335. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54336. * KIND, either express or implied. See the License for the
  54337. * specific language governing permissions and limitations
  54338. * under the License.
  54339. */
  54340. /*
  54341. * A third-party license is embeded for some of the code in this file:
  54342. * The treemap layout implementation was originally copied from
  54343. * "d3.js" with some modifications made for this project.
  54344. * (See more details in the comment of the method "squarify" below.)
  54345. * The use of the source code of this file is also subject to the terms
  54346. * and consitions of the license of "d3.js" (BSD-3Clause, see
  54347. * </licenses/LICENSE-d3>).
  54348. */
  54349. var mathMax$7 = Math.max;
  54350. var mathMin$7 = Math.min;
  54351. var retrieveValue = retrieve;
  54352. var each$5 = each$1;
  54353. var PATH_BORDER_WIDTH = ['itemStyle', 'borderWidth'];
  54354. var PATH_GAP_WIDTH = ['itemStyle', 'gapWidth'];
  54355. var PATH_UPPER_LABEL_SHOW = ['upperLabel', 'show'];
  54356. var PATH_UPPER_LABEL_HEIGHT = ['upperLabel', 'height'];
  54357. /**
  54358. * @public
  54359. */
  54360. var treemapLayout = {
  54361. seriesType: 'treemap',
  54362. reset: function (seriesModel, ecModel, api, payload) {
  54363. // Layout result in each node:
  54364. // {x, y, width, height, area, borderWidth}
  54365. var ecWidth = api.getWidth();
  54366. var ecHeight = api.getHeight();
  54367. var seriesOption = seriesModel.option;
  54368. var layoutInfo = getLayoutRect(seriesModel.getBoxLayoutParams(), {
  54369. width: api.getWidth(),
  54370. height: api.getHeight()
  54371. });
  54372. var size = seriesOption.size || []; // Compatible with ec2.
  54373. var containerWidth = parsePercent$1(retrieveValue(layoutInfo.width, size[0]), ecWidth);
  54374. var containerHeight = parsePercent$1(retrieveValue(layoutInfo.height, size[1]), ecHeight); // Fetch payload info.
  54375. var payloadType = payload && payload.type;
  54376. var types = ['treemapZoomToNode', 'treemapRootToNode'];
  54377. var targetInfo = retrieveTargetInfo(payload, types, seriesModel);
  54378. var rootRect = payloadType === 'treemapRender' || payloadType === 'treemapMove' ? payload.rootRect : null;
  54379. var viewRoot = seriesModel.getViewRoot();
  54380. var viewAbovePath = getPathToRoot(viewRoot);
  54381. if (payloadType !== 'treemapMove') {
  54382. var rootSize = payloadType === 'treemapZoomToNode' ? estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) : rootRect ? [rootRect.width, rootRect.height] : [containerWidth, containerHeight];
  54383. var sort_1 = seriesOption.sort;
  54384. if (sort_1 && sort_1 !== 'asc' && sort_1 !== 'desc') {
  54385. // Default to be desc order.
  54386. sort_1 = 'desc';
  54387. }
  54388. var options = {
  54389. squareRatio: seriesOption.squareRatio,
  54390. sort: sort_1,
  54391. leafDepth: seriesOption.leafDepth
  54392. }; // layout should be cleared because using updateView but not update.
  54393. viewRoot.hostTree.clearLayouts(); // TODO
  54394. // optimize: if out of view clip, do not layout.
  54395. // But take care that if do not render node out of view clip,
  54396. // how to calculate start po
  54397. var viewRootLayout_1 = {
  54398. x: 0,
  54399. y: 0,
  54400. width: rootSize[0],
  54401. height: rootSize[1],
  54402. area: rootSize[0] * rootSize[1]
  54403. };
  54404. viewRoot.setLayout(viewRootLayout_1);
  54405. squarify(viewRoot, options, false, 0); // Supplement layout.
  54406. viewRootLayout_1 = viewRoot.getLayout();
  54407. each$5(viewAbovePath, function (node, index) {
  54408. var childValue = (viewAbovePath[index + 1] || viewRoot).getValue();
  54409. node.setLayout(extend({
  54410. dataExtent: [childValue, childValue],
  54411. borderWidth: 0,
  54412. upperHeight: 0
  54413. }, viewRootLayout_1));
  54414. });
  54415. }
  54416. var treeRoot = seriesModel.getData().tree.root;
  54417. treeRoot.setLayout(calculateRootPosition(layoutInfo, rootRect, targetInfo), true);
  54418. seriesModel.setLayoutInfo(layoutInfo); // FIXME
  54419. // 现在没有clip功能,暂时取ec高宽。
  54420. prunning(treeRoot, // Transform to base element coordinate system.
  54421. new BoundingRect(-layoutInfo.x, -layoutInfo.y, ecWidth, ecHeight), viewAbovePath, viewRoot, 0);
  54422. }
  54423. };
  54424. /**
  54425. * Layout treemap with squarify algorithm.
  54426. * The original presentation of this algorithm
  54427. * was made by Mark Bruls, Kees Huizing, and Jarke J. van Wijk
  54428. * <https://graphics.ethz.ch/teaching/scivis_common/Literature/squarifiedTreeMaps.pdf>.
  54429. * The implementation of this algorithm was originally copied from "d3.js"
  54430. * <https://github.com/d3/d3/blob/9cc9a875e636a1dcf36cc1e07bdf77e1ad6e2c74/src/layout/treemap.js>
  54431. * with some modifications made for this program.
  54432. * See the license statement at the head of this file.
  54433. *
  54434. * @protected
  54435. * @param {module:echarts/data/Tree~TreeNode} node
  54436. * @param {Object} options
  54437. * @param {string} options.sort 'asc' or 'desc'
  54438. * @param {number} options.squareRatio
  54439. * @param {boolean} hideChildren
  54440. * @param {number} depth
  54441. */
  54442. function squarify(node, options, hideChildren, depth) {
  54443. var width;
  54444. var height;
  54445. if (node.isRemoved()) {
  54446. return;
  54447. }
  54448. var thisLayout = node.getLayout();
  54449. width = thisLayout.width;
  54450. height = thisLayout.height; // Considering border and gap
  54451. var nodeModel = node.getModel();
  54452. var borderWidth = nodeModel.get(PATH_BORDER_WIDTH);
  54453. var halfGapWidth = nodeModel.get(PATH_GAP_WIDTH) / 2;
  54454. var upperLabelHeight = getUpperLabelHeight(nodeModel);
  54455. var upperHeight = Math.max(borderWidth, upperLabelHeight);
  54456. var layoutOffset = borderWidth - halfGapWidth;
  54457. var layoutOffsetUpper = upperHeight - halfGapWidth;
  54458. node.setLayout({
  54459. borderWidth: borderWidth,
  54460. upperHeight: upperHeight,
  54461. upperLabelHeight: upperLabelHeight
  54462. }, true);
  54463. width = mathMax$7(width - 2 * layoutOffset, 0);
  54464. height = mathMax$7(height - layoutOffset - layoutOffsetUpper, 0);
  54465. var totalArea = width * height;
  54466. var viewChildren = initChildren(node, nodeModel, totalArea, options, hideChildren, depth);
  54467. if (!viewChildren.length) {
  54468. return;
  54469. }
  54470. var rect = {
  54471. x: layoutOffset,
  54472. y: layoutOffsetUpper,
  54473. width: width,
  54474. height: height
  54475. };
  54476. var rowFixedLength = mathMin$7(width, height);
  54477. var best = Infinity; // the best row score so far
  54478. var row = [];
  54479. row.area = 0;
  54480. for (var i = 0, len = viewChildren.length; i < len;) {
  54481. var child = viewChildren[i];
  54482. row.push(child);
  54483. row.area += child.getLayout().area;
  54484. var score = worst(row, rowFixedLength, options.squareRatio); // continue with this orientation
  54485. if (score <= best) {
  54486. i++;
  54487. best = score;
  54488. } // abort, and try a different orientation
  54489. else {
  54490. row.area -= row.pop().getLayout().area;
  54491. position(row, rowFixedLength, rect, halfGapWidth, false);
  54492. rowFixedLength = mathMin$7(rect.width, rect.height);
  54493. row.length = row.area = 0;
  54494. best = Infinity;
  54495. }
  54496. }
  54497. if (row.length) {
  54498. position(row, rowFixedLength, rect, halfGapWidth, true);
  54499. }
  54500. if (!hideChildren) {
  54501. var childrenVisibleMin = nodeModel.get('childrenVisibleMin');
  54502. if (childrenVisibleMin != null && totalArea < childrenVisibleMin) {
  54503. hideChildren = true;
  54504. }
  54505. }
  54506. for (var i = 0, len = viewChildren.length; i < len; i++) {
  54507. squarify(viewChildren[i], options, hideChildren, depth + 1);
  54508. }
  54509. }
  54510. /**
  54511. * Set area to each child, and calculate data extent for visual coding.
  54512. */
  54513. function initChildren(node, nodeModel, totalArea, options, hideChildren, depth) {
  54514. var viewChildren = node.children || [];
  54515. var orderBy = options.sort;
  54516. orderBy !== 'asc' && orderBy !== 'desc' && (orderBy = null);
  54517. var overLeafDepth = options.leafDepth != null && options.leafDepth <= depth; // leafDepth has higher priority.
  54518. if (hideChildren && !overLeafDepth) {
  54519. return node.viewChildren = [];
  54520. } // Sort children, order by desc.
  54521. viewChildren = filter(viewChildren, function (child) {
  54522. return !child.isRemoved();
  54523. });
  54524. sort$1(viewChildren, orderBy);
  54525. var info = statistic(nodeModel, viewChildren, orderBy);
  54526. if (info.sum === 0) {
  54527. return node.viewChildren = [];
  54528. }
  54529. info.sum = filterByThreshold(nodeModel, totalArea, info.sum, orderBy, viewChildren);
  54530. if (info.sum === 0) {
  54531. return node.viewChildren = [];
  54532. } // Set area to each child.
  54533. for (var i = 0, len = viewChildren.length; i < len; i++) {
  54534. var area = viewChildren[i].getValue() / info.sum * totalArea; // Do not use setLayout({...}, true), because it is needed to clear last layout.
  54535. viewChildren[i].setLayout({
  54536. area: area
  54537. });
  54538. }
  54539. if (overLeafDepth) {
  54540. viewChildren.length && node.setLayout({
  54541. isLeafRoot: true
  54542. }, true);
  54543. viewChildren.length = 0;
  54544. }
  54545. node.viewChildren = viewChildren;
  54546. node.setLayout({
  54547. dataExtent: info.dataExtent
  54548. }, true);
  54549. return viewChildren;
  54550. }
  54551. /**
  54552. * Consider 'visibleMin'. Modify viewChildren and get new sum.
  54553. */
  54554. function filterByThreshold(nodeModel, totalArea, sum, orderBy, orderedChildren) {
  54555. // visibleMin is not supported yet when no option.sort.
  54556. if (!orderBy) {
  54557. return sum;
  54558. }
  54559. var visibleMin = nodeModel.get('visibleMin');
  54560. var len = orderedChildren.length;
  54561. var deletePoint = len; // Always travel from little value to big value.
  54562. for (var i = len - 1; i >= 0; i--) {
  54563. var value = orderedChildren[orderBy === 'asc' ? len - i - 1 : i].getValue();
  54564. if (value / sum * totalArea < visibleMin) {
  54565. deletePoint = i;
  54566. sum -= value;
  54567. }
  54568. }
  54569. orderBy === 'asc' ? orderedChildren.splice(0, len - deletePoint) : orderedChildren.splice(deletePoint, len - deletePoint);
  54570. return sum;
  54571. }
  54572. /**
  54573. * Sort
  54574. */
  54575. function sort$1(viewChildren, orderBy) {
  54576. if (orderBy) {
  54577. viewChildren.sort(function (a, b) {
  54578. var diff = orderBy === 'asc' ? a.getValue() - b.getValue() : b.getValue() - a.getValue();
  54579. return diff === 0 ? orderBy === 'asc' ? a.dataIndex - b.dataIndex : b.dataIndex - a.dataIndex : diff;
  54580. });
  54581. }
  54582. return viewChildren;
  54583. }
  54584. /**
  54585. * Statistic
  54586. */
  54587. function statistic(nodeModel, children, orderBy) {
  54588. // Calculate sum.
  54589. var sum = 0;
  54590. for (var i = 0, len = children.length; i < len; i++) {
  54591. sum += children[i].getValue();
  54592. } // Statistic data extent for latter visual coding.
  54593. // Notice: data extent should be calculate based on raw children
  54594. // but not filtered view children, otherwise visual mapping will not
  54595. // be stable when zoom (where children is filtered by visibleMin).
  54596. var dimension = nodeModel.get('visualDimension');
  54597. var dataExtent; // The same as area dimension.
  54598. if (!children || !children.length) {
  54599. dataExtent = [NaN, NaN];
  54600. } else if (dimension === 'value' && orderBy) {
  54601. dataExtent = [children[children.length - 1].getValue(), children[0].getValue()];
  54602. orderBy === 'asc' && dataExtent.reverse();
  54603. } // Other dimension.
  54604. else {
  54605. dataExtent = [Infinity, -Infinity];
  54606. each$5(children, function (child) {
  54607. var value = child.getValue(dimension);
  54608. value < dataExtent[0] && (dataExtent[0] = value);
  54609. value > dataExtent[1] && (dataExtent[1] = value);
  54610. });
  54611. }
  54612. return {
  54613. sum: sum,
  54614. dataExtent: dataExtent
  54615. };
  54616. }
  54617. /**
  54618. * Computes the score for the specified row,
  54619. * as the worst aspect ratio.
  54620. */
  54621. function worst(row, rowFixedLength, ratio) {
  54622. var areaMax = 0;
  54623. var areaMin = Infinity;
  54624. for (var i = 0, area = void 0, len = row.length; i < len; i++) {
  54625. area = row[i].getLayout().area;
  54626. if (area) {
  54627. area < areaMin && (areaMin = area);
  54628. area > areaMax && (areaMax = area);
  54629. }
  54630. }
  54631. var squareArea = row.area * row.area;
  54632. var f = rowFixedLength * rowFixedLength * ratio;
  54633. return squareArea ? mathMax$7(f * areaMax / squareArea, squareArea / (f * areaMin)) : Infinity;
  54634. }
  54635. /**
  54636. * Positions the specified row of nodes. Modifies `rect`.
  54637. */
  54638. function position(row, rowFixedLength, rect, halfGapWidth, flush) {
  54639. // When rowFixedLength === rect.width,
  54640. // it is horizontal subdivision,
  54641. // rowFixedLength is the width of the subdivision,
  54642. // rowOtherLength is the height of the subdivision,
  54643. // and nodes will be positioned from left to right.
  54644. // wh[idx0WhenH] means: when horizontal,
  54645. // wh[idx0WhenH] => wh[0] => 'width'.
  54646. // xy[idx1WhenH] => xy[1] => 'y'.
  54647. var idx0WhenH = rowFixedLength === rect.width ? 0 : 1;
  54648. var idx1WhenH = 1 - idx0WhenH;
  54649. var xy = ['x', 'y'];
  54650. var wh = ['width', 'height'];
  54651. var last = rect[xy[idx0WhenH]];
  54652. var rowOtherLength = rowFixedLength ? row.area / rowFixedLength : 0;
  54653. if (flush || rowOtherLength > rect[wh[idx1WhenH]]) {
  54654. rowOtherLength = rect[wh[idx1WhenH]]; // over+underflow
  54655. }
  54656. for (var i = 0, rowLen = row.length; i < rowLen; i++) {
  54657. var node = row[i];
  54658. var nodeLayout = {};
  54659. var step = rowOtherLength ? node.getLayout().area / rowOtherLength : 0;
  54660. var wh1 = nodeLayout[wh[idx1WhenH]] = mathMax$7(rowOtherLength - 2 * halfGapWidth, 0); // We use Math.max/min to avoid negative width/height when considering gap width.
  54661. var remain = rect[xy[idx0WhenH]] + rect[wh[idx0WhenH]] - last;
  54662. var modWH = i === rowLen - 1 || remain < step ? remain : step;
  54663. var wh0 = nodeLayout[wh[idx0WhenH]] = mathMax$7(modWH - 2 * halfGapWidth, 0);
  54664. nodeLayout[xy[idx1WhenH]] = rect[xy[idx1WhenH]] + mathMin$7(halfGapWidth, wh1 / 2);
  54665. nodeLayout[xy[idx0WhenH]] = last + mathMin$7(halfGapWidth, wh0 / 2);
  54666. last += modWH;
  54667. node.setLayout(nodeLayout, true);
  54668. }
  54669. rect[xy[idx1WhenH]] += rowOtherLength;
  54670. rect[wh[idx1WhenH]] -= rowOtherLength;
  54671. } // Return [containerWidth, containerHeight] as default.
  54672. function estimateRootSize(seriesModel, targetInfo, viewRoot, containerWidth, containerHeight) {
  54673. // If targetInfo.node exists, we zoom to the node,
  54674. // so estimate whold width and heigth by target node.
  54675. var currNode = (targetInfo || {}).node;
  54676. var defaultSize = [containerWidth, containerHeight];
  54677. if (!currNode || currNode === viewRoot) {
  54678. return defaultSize;
  54679. }
  54680. var parent;
  54681. var viewArea = containerWidth * containerHeight;
  54682. var area = viewArea * seriesModel.option.zoomToNodeRatio;
  54683. while (parent = currNode.parentNode) {
  54684. // jshint ignore:line
  54685. var sum = 0;
  54686. var siblings = parent.children;
  54687. for (var i = 0, len = siblings.length; i < len; i++) {
  54688. sum += siblings[i].getValue();
  54689. }
  54690. var currNodeValue = currNode.getValue();
  54691. if (currNodeValue === 0) {
  54692. return defaultSize;
  54693. }
  54694. area *= sum / currNodeValue; // Considering border, suppose aspect ratio is 1.
  54695. var parentModel = parent.getModel();
  54696. var borderWidth = parentModel.get(PATH_BORDER_WIDTH);
  54697. var upperHeight = Math.max(borderWidth, getUpperLabelHeight(parentModel));
  54698. area += 4 * borderWidth * borderWidth + (3 * borderWidth + upperHeight) * Math.pow(area, 0.5);
  54699. area > MAX_SAFE_INTEGER && (area = MAX_SAFE_INTEGER);
  54700. currNode = parent;
  54701. }
  54702. area < viewArea && (area = viewArea);
  54703. var scale = Math.pow(area / viewArea, 0.5);
  54704. return [containerWidth * scale, containerHeight * scale];
  54705. } // Root postion base on coord of containerGroup
  54706. function calculateRootPosition(layoutInfo, rootRect, targetInfo) {
  54707. if (rootRect) {
  54708. return {
  54709. x: rootRect.x,
  54710. y: rootRect.y
  54711. };
  54712. }
  54713. var defaultPosition = {
  54714. x: 0,
  54715. y: 0
  54716. };
  54717. if (!targetInfo) {
  54718. return defaultPosition;
  54719. } // If targetInfo is fetched by 'retrieveTargetInfo',
  54720. // old tree and new tree are the same tree,
  54721. // so the node still exists and we can visit it.
  54722. var targetNode = targetInfo.node;
  54723. var layout = targetNode.getLayout();
  54724. if (!layout) {
  54725. return defaultPosition;
  54726. } // Transform coord from local to container.
  54727. var targetCenter = [layout.width / 2, layout.height / 2];
  54728. var node = targetNode;
  54729. while (node) {
  54730. var nodeLayout = node.getLayout();
  54731. targetCenter[0] += nodeLayout.x;
  54732. targetCenter[1] += nodeLayout.y;
  54733. node = node.parentNode;
  54734. }
  54735. return {
  54736. x: layoutInfo.width / 2 - targetCenter[0],
  54737. y: layoutInfo.height / 2 - targetCenter[1]
  54738. };
  54739. } // Mark nodes visible for prunning when visual coding and rendering.
  54740. // Prunning depends on layout and root position, so we have to do it after layout.
  54741. function prunning(node, clipRect, viewAbovePath, viewRoot, depth) {
  54742. var nodeLayout = node.getLayout();
  54743. var nodeInViewAbovePath = viewAbovePath[depth];
  54744. var isAboveViewRoot = nodeInViewAbovePath && nodeInViewAbovePath === node;
  54745. if (nodeInViewAbovePath && !isAboveViewRoot || depth === viewAbovePath.length && node !== viewRoot) {
  54746. return;
  54747. }
  54748. node.setLayout({
  54749. // isInView means: viewRoot sub tree + viewAbovePath
  54750. isInView: true,
  54751. // invisible only means: outside view clip so that the node can not
  54752. // see but still layout for animation preparation but not render.
  54753. invisible: !isAboveViewRoot && !clipRect.intersect(nodeLayout),
  54754. isAboveViewRoot: isAboveViewRoot
  54755. }, true); // Transform to child coordinate.
  54756. var childClipRect = new BoundingRect(clipRect.x - nodeLayout.x, clipRect.y - nodeLayout.y, clipRect.width, clipRect.height);
  54757. each$5(node.viewChildren || [], function (child) {
  54758. prunning(child, childClipRect, viewAbovePath, viewRoot, depth + 1);
  54759. });
  54760. }
  54761. function getUpperLabelHeight(model) {
  54762. return model.get(PATH_UPPER_LABEL_SHOW) ? model.get(PATH_UPPER_LABEL_HEIGHT) : 0;
  54763. }
  54764. /*
  54765. * Licensed to the Apache Software Foundation (ASF) under one
  54766. * or more contributor license agreements. See the NOTICE file
  54767. * distributed with this work for additional information
  54768. * regarding copyright ownership. The ASF licenses this file
  54769. * to you under the Apache License, Version 2.0 (the
  54770. * "License"); you may not use this file except in compliance
  54771. * with the License. You may obtain a copy of the License at
  54772. *
  54773. * http://www.apache.org/licenses/LICENSE-2.0
  54774. *
  54775. * Unless required by applicable law or agreed to in writing,
  54776. * software distributed under the License is distributed on an
  54777. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54778. * KIND, either express or implied. See the License for the
  54779. * specific language governing permissions and limitations
  54780. * under the License.
  54781. */
  54782. /**
  54783. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54784. */
  54785. /*
  54786. * Licensed to the Apache Software Foundation (ASF) under one
  54787. * or more contributor license agreements. See the NOTICE file
  54788. * distributed with this work for additional information
  54789. * regarding copyright ownership. The ASF licenses this file
  54790. * to you under the Apache License, Version 2.0 (the
  54791. * "License"); you may not use this file except in compliance
  54792. * with the License. You may obtain a copy of the License at
  54793. *
  54794. * http://www.apache.org/licenses/LICENSE-2.0
  54795. *
  54796. * Unless required by applicable law or agreed to in writing,
  54797. * software distributed under the License is distributed on an
  54798. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54799. * KIND, either express or implied. See the License for the
  54800. * specific language governing permissions and limitations
  54801. * under the License.
  54802. */
  54803. function install$13(registers) {
  54804. registers.registerSeriesModel(TreemapSeriesModel);
  54805. registers.registerChartView(TreemapView);
  54806. registers.registerVisual(treemapVisual);
  54807. registers.registerLayout(treemapLayout);
  54808. installTreemapAction(registers);
  54809. }
  54810. /*
  54811. * Licensed to the Apache Software Foundation (ASF) under one
  54812. * or more contributor license agreements. See the NOTICE file
  54813. * distributed with this work for additional information
  54814. * regarding copyright ownership. The ASF licenses this file
  54815. * to you under the Apache License, Version 2.0 (the
  54816. * "License"); you may not use this file except in compliance
  54817. * with the License. You may obtain a copy of the License at
  54818. *
  54819. * http://www.apache.org/licenses/LICENSE-2.0
  54820. *
  54821. * Unless required by applicable law or agreed to in writing,
  54822. * software distributed under the License is distributed on an
  54823. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54824. * KIND, either express or implied. See the License for the
  54825. * specific language governing permissions and limitations
  54826. * under the License.
  54827. */
  54828. /**
  54829. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54830. */
  54831. /*
  54832. * Licensed to the Apache Software Foundation (ASF) under one
  54833. * or more contributor license agreements. See the NOTICE file
  54834. * distributed with this work for additional information
  54835. * regarding copyright ownership. The ASF licenses this file
  54836. * to you under the Apache License, Version 2.0 (the
  54837. * "License"); you may not use this file except in compliance
  54838. * with the License. You may obtain a copy of the License at
  54839. *
  54840. * http://www.apache.org/licenses/LICENSE-2.0
  54841. *
  54842. * Unless required by applicable law or agreed to in writing,
  54843. * software distributed under the License is distributed on an
  54844. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54845. * KIND, either express or implied. See the License for the
  54846. * specific language governing permissions and limitations
  54847. * under the License.
  54848. */
  54849. use(install$13);
  54850. /*
  54851. * Licensed to the Apache Software Foundation (ASF) under one
  54852. * or more contributor license agreements. See the NOTICE file
  54853. * distributed with this work for additional information
  54854. * regarding copyright ownership. The ASF licenses this file
  54855. * to you under the Apache License, Version 2.0 (the
  54856. * "License"); you may not use this file except in compliance
  54857. * with the License. You may obtain a copy of the License at
  54858. *
  54859. * http://www.apache.org/licenses/LICENSE-2.0
  54860. *
  54861. * Unless required by applicable law or agreed to in writing,
  54862. * software distributed under the License is distributed on an
  54863. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54864. * KIND, either express or implied. See the License for the
  54865. * specific language governing permissions and limitations
  54866. * under the License.
  54867. */
  54868. /**
  54869. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54870. */
  54871. /*
  54872. * Licensed to the Apache Software Foundation (ASF) under one
  54873. * or more contributor license agreements. See the NOTICE file
  54874. * distributed with this work for additional information
  54875. * regarding copyright ownership. The ASF licenses this file
  54876. * to you under the Apache License, Version 2.0 (the
  54877. * "License"); you may not use this file except in compliance
  54878. * with the License. You may obtain a copy of the License at
  54879. *
  54880. * http://www.apache.org/licenses/LICENSE-2.0
  54881. *
  54882. * Unless required by applicable law or agreed to in writing,
  54883. * software distributed under the License is distributed on an
  54884. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54885. * KIND, either express or implied. See the License for the
  54886. * specific language governing permissions and limitations
  54887. * under the License.
  54888. */
  54889. var DEFAULT_SECTOR_Z = 2;
  54890. var DEFAULT_TEXT_Z = 4;
  54891. /**
  54892. * Sunburstce of Sunburst including Sector, Label, LabelLine
  54893. */
  54894. var SunburstPiece =
  54895. /** @class */
  54896. function (_super) {
  54897. __extends(SunburstPiece, _super);
  54898. function SunburstPiece(node, seriesModel, ecModel, api) {
  54899. var _this = _super.call(this) || this;
  54900. _this.z2 = DEFAULT_SECTOR_Z;
  54901. _this.textConfig = {
  54902. inside: true
  54903. };
  54904. getECData(_this).seriesIndex = seriesModel.seriesIndex;
  54905. var text = new ZRText({
  54906. z2: DEFAULT_TEXT_Z,
  54907. silent: node.getModel().get(['label', 'silent'])
  54908. });
  54909. _this.setTextContent(text);
  54910. _this.updateData(true, node, seriesModel, ecModel, api);
  54911. return _this;
  54912. }
  54913. SunburstPiece.prototype.updateData = function (firstCreate, node, // state: 'emphasis' | 'normal' | 'highlight' | 'downplay',
  54914. seriesModel, ecModel, api) {
  54915. this.node = node;
  54916. node.piece = this;
  54917. seriesModel = seriesModel || this._seriesModel;
  54918. ecModel = ecModel || this._ecModel;
  54919. var sector = this;
  54920. getECData(sector).dataIndex = node.dataIndex;
  54921. var itemModel = node.getModel();
  54922. var emphasisModel = itemModel.getModel('emphasis');
  54923. var layout = node.getLayout();
  54924. var sectorShape = extend({}, layout);
  54925. sectorShape.label = null;
  54926. var normalStyle = node.getVisual('style');
  54927. normalStyle.lineJoin = 'bevel';
  54928. var decal = node.getVisual('decal');
  54929. if (decal) {
  54930. normalStyle.decal = createOrUpdatePatternFromDecal(decal, api);
  54931. }
  54932. var cornerRadius = getSectorCornerRadius(itemModel.getModel('itemStyle'), sectorShape);
  54933. extend(sectorShape, cornerRadius);
  54934. each$1(SPECIAL_STATES, function (stateName) {
  54935. var state = sector.ensureState(stateName);
  54936. var itemStyleModel = itemModel.getModel([stateName, 'itemStyle']);
  54937. state.style = itemStyleModel.getItemStyle(); // border radius
  54938. var cornerRadius = getSectorCornerRadius(itemStyleModel, sectorShape);
  54939. if (cornerRadius) {
  54940. state.shape = cornerRadius;
  54941. }
  54942. });
  54943. if (firstCreate) {
  54944. sector.setShape(sectorShape);
  54945. sector.shape.r = layout.r0;
  54946. updateProps(sector, {
  54947. shape: {
  54948. r: layout.r
  54949. }
  54950. }, seriesModel, node.dataIndex);
  54951. } else {
  54952. // Disable animation for gradient since no interpolation method
  54953. // is supported for gradient
  54954. updateProps(sector, {
  54955. shape: sectorShape
  54956. }, seriesModel);
  54957. }
  54958. sector.useStyle(normalStyle);
  54959. this._updateLabel(seriesModel);
  54960. var cursorStyle = itemModel.getShallow('cursor');
  54961. cursorStyle && sector.attr('cursor', cursorStyle);
  54962. this._seriesModel = seriesModel || this._seriesModel;
  54963. this._ecModel = ecModel || this._ecModel;
  54964. var focus = emphasisModel.get('focus');
  54965. var focusOrIndices = focus === 'ancestor' ? node.getAncestorsIndices() : focus === 'descendant' ? node.getDescendantIndices() : focus;
  54966. enableHoverEmphasis(this, focusOrIndices, emphasisModel.get('blurScope'));
  54967. };
  54968. SunburstPiece.prototype._updateLabel = function (seriesModel) {
  54969. var _this = this;
  54970. var itemModel = this.node.getModel();
  54971. var normalLabelModel = itemModel.getModel('label');
  54972. var layout = this.node.getLayout();
  54973. var angle = layout.endAngle - layout.startAngle;
  54974. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  54975. var dx = Math.cos(midAngle);
  54976. var dy = Math.sin(midAngle);
  54977. var sector = this;
  54978. var label = sector.getTextContent();
  54979. var dataIndex = this.node.dataIndex;
  54980. var labelMinAngle = normalLabelModel.get('minAngle') / 180 * Math.PI;
  54981. var isNormalShown = normalLabelModel.get('show') && !(labelMinAngle != null && Math.abs(angle) < labelMinAngle);
  54982. label.ignore = !isNormalShown; // TODO use setLabelStyle
  54983. each$1(DISPLAY_STATES, function (stateName) {
  54984. var labelStateModel = stateName === 'normal' ? itemModel.getModel('label') : itemModel.getModel([stateName, 'label']);
  54985. var isNormal = stateName === 'normal';
  54986. var state = isNormal ? label : label.ensureState(stateName);
  54987. var text = seriesModel.getFormattedLabel(dataIndex, stateName);
  54988. if (isNormal) {
  54989. text = text || _this.node.name;
  54990. }
  54991. state.style = createTextStyle(labelStateModel, {}, null, stateName !== 'normal', true);
  54992. if (text) {
  54993. state.style.text = text;
  54994. } // Not displaying text when angle is too small
  54995. var isShown = labelStateModel.get('show');
  54996. if (isShown != null && !isNormal) {
  54997. state.ignore = !isShown;
  54998. }
  54999. var labelPosition = getLabelAttr(labelStateModel, 'position');
  55000. var sectorState = isNormal ? sector : sector.states[stateName];
  55001. var labelColor = sectorState.style.fill;
  55002. sectorState.textConfig = {
  55003. outsideFill: labelStateModel.get('color') === 'inherit' ? labelColor : null,
  55004. inside: labelPosition !== 'outside'
  55005. };
  55006. var r;
  55007. var labelPadding = getLabelAttr(labelStateModel, 'distance') || 0;
  55008. var textAlign = getLabelAttr(labelStateModel, 'align');
  55009. if (labelPosition === 'outside') {
  55010. r = layout.r + labelPadding;
  55011. textAlign = midAngle > Math.PI / 2 ? 'right' : 'left';
  55012. } else {
  55013. if (!textAlign || textAlign === 'center') {
  55014. r = (layout.r + layout.r0) / 2;
  55015. textAlign = 'center';
  55016. } else if (textAlign === 'left') {
  55017. r = layout.r0 + labelPadding;
  55018. if (midAngle > Math.PI / 2) {
  55019. textAlign = 'right';
  55020. }
  55021. } else if (textAlign === 'right') {
  55022. r = layout.r - labelPadding;
  55023. if (midAngle > Math.PI / 2) {
  55024. textAlign = 'left';
  55025. }
  55026. }
  55027. }
  55028. state.style.align = textAlign;
  55029. state.style.verticalAlign = getLabelAttr(labelStateModel, 'verticalAlign') || 'middle';
  55030. state.x = r * dx + layout.cx;
  55031. state.y = r * dy + layout.cy;
  55032. var rotateType = getLabelAttr(labelStateModel, 'rotate');
  55033. var rotate = 0;
  55034. if (rotateType === 'radial') {
  55035. rotate = -midAngle;
  55036. if (rotate < -Math.PI / 2) {
  55037. rotate += Math.PI;
  55038. }
  55039. } else if (rotateType === 'tangential') {
  55040. rotate = Math.PI / 2 - midAngle;
  55041. if (rotate > Math.PI / 2) {
  55042. rotate -= Math.PI;
  55043. } else if (rotate < -Math.PI / 2) {
  55044. rotate += Math.PI;
  55045. }
  55046. } else if (typeof rotateType === 'number') {
  55047. rotate = rotateType * Math.PI / 180;
  55048. }
  55049. state.rotation = rotate;
  55050. });
  55051. function getLabelAttr(model, name) {
  55052. var stateAttr = model.get(name);
  55053. if (stateAttr == null) {
  55054. return normalLabelModel.get(name);
  55055. }
  55056. return stateAttr;
  55057. }
  55058. label.dirtyStyle();
  55059. };
  55060. return SunburstPiece;
  55061. }(Sector);
  55062. /*
  55063. * Licensed to the Apache Software Foundation (ASF) under one
  55064. * or more contributor license agreements. See the NOTICE file
  55065. * distributed with this work for additional information
  55066. * regarding copyright ownership. The ASF licenses this file
  55067. * to you under the Apache License, Version 2.0 (the
  55068. * "License"); you may not use this file except in compliance
  55069. * with the License. You may obtain a copy of the License at
  55070. *
  55071. * http://www.apache.org/licenses/LICENSE-2.0
  55072. *
  55073. * Unless required by applicable law or agreed to in writing,
  55074. * software distributed under the License is distributed on an
  55075. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55076. * KIND, either express or implied. See the License for the
  55077. * specific language governing permissions and limitations
  55078. * under the License.
  55079. */
  55080. /**
  55081. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55082. */
  55083. /*
  55084. * Licensed to the Apache Software Foundation (ASF) under one
  55085. * or more contributor license agreements. See the NOTICE file
  55086. * distributed with this work for additional information
  55087. * regarding copyright ownership. The ASF licenses this file
  55088. * to you under the Apache License, Version 2.0 (the
  55089. * "License"); you may not use this file except in compliance
  55090. * with the License. You may obtain a copy of the License at
  55091. *
  55092. * http://www.apache.org/licenses/LICENSE-2.0
  55093. *
  55094. * Unless required by applicable law or agreed to in writing,
  55095. * software distributed under the License is distributed on an
  55096. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55097. * KIND, either express or implied. See the License for the
  55098. * specific language governing permissions and limitations
  55099. * under the License.
  55100. */
  55101. var ROOT_TO_NODE_ACTION = 'sunburstRootToNode';
  55102. var HIGHLIGHT_ACTION = 'sunburstHighlight';
  55103. var UNHIGHLIGHT_ACTION = 'sunburstUnhighlight';
  55104. function installSunburstAction(registers) {
  55105. registers.registerAction({
  55106. type: ROOT_TO_NODE_ACTION,
  55107. update: 'updateView'
  55108. }, function (payload, ecModel) {
  55109. ecModel.eachComponent({
  55110. mainType: 'series',
  55111. subType: 'sunburst',
  55112. query: payload
  55113. }, handleRootToNode);
  55114. function handleRootToNode(model, index) {
  55115. var targetInfo = retrieveTargetInfo(payload, [ROOT_TO_NODE_ACTION], model);
  55116. if (targetInfo) {
  55117. var originViewRoot = model.getViewRoot();
  55118. if (originViewRoot) {
  55119. payload.direction = aboveViewRoot(originViewRoot, targetInfo.node) ? 'rollUp' : 'drillDown';
  55120. }
  55121. model.resetViewRoot(targetInfo.node);
  55122. }
  55123. }
  55124. });
  55125. registers.registerAction({
  55126. type: HIGHLIGHT_ACTION,
  55127. update: 'none'
  55128. }, function (payload, ecModel, api) {
  55129. // Clone
  55130. payload = extend({}, payload);
  55131. ecModel.eachComponent({
  55132. mainType: 'series',
  55133. subType: 'sunburst',
  55134. query: payload
  55135. }, handleHighlight);
  55136. function handleHighlight(model) {
  55137. var targetInfo = retrieveTargetInfo(payload, [HIGHLIGHT_ACTION], model);
  55138. if (targetInfo) {
  55139. payload.dataIndex = targetInfo.node.dataIndex;
  55140. }
  55141. }
  55142. {
  55143. deprecateReplaceLog('highlight', 'sunburstHighlight');
  55144. } // Fast forward action
  55145. api.dispatchAction(extend(payload, {
  55146. type: 'highlight'
  55147. }));
  55148. });
  55149. registers.registerAction({
  55150. type: UNHIGHLIGHT_ACTION,
  55151. update: 'updateView'
  55152. }, function (payload, ecModel, api) {
  55153. payload = extend({}, payload);
  55154. {
  55155. deprecateReplaceLog('downplay', 'sunburstUnhighlight');
  55156. }
  55157. api.dispatchAction(extend(payload, {
  55158. type: 'downplay'
  55159. }));
  55160. });
  55161. }
  55162. /*
  55163. * Licensed to the Apache Software Foundation (ASF) under one
  55164. * or more contributor license agreements. See the NOTICE file
  55165. * distributed with this work for additional information
  55166. * regarding copyright ownership. The ASF licenses this file
  55167. * to you under the Apache License, Version 2.0 (the
  55168. * "License"); you may not use this file except in compliance
  55169. * with the License. You may obtain a copy of the License at
  55170. *
  55171. * http://www.apache.org/licenses/LICENSE-2.0
  55172. *
  55173. * Unless required by applicable law or agreed to in writing,
  55174. * software distributed under the License is distributed on an
  55175. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55176. * KIND, either express or implied. See the License for the
  55177. * specific language governing permissions and limitations
  55178. * under the License.
  55179. */
  55180. /**
  55181. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55182. */
  55183. /*
  55184. * Licensed to the Apache Software Foundation (ASF) under one
  55185. * or more contributor license agreements. See the NOTICE file
  55186. * distributed with this work for additional information
  55187. * regarding copyright ownership. The ASF licenses this file
  55188. * to you under the Apache License, Version 2.0 (the
  55189. * "License"); you may not use this file except in compliance
  55190. * with the License. You may obtain a copy of the License at
  55191. *
  55192. * http://www.apache.org/licenses/LICENSE-2.0
  55193. *
  55194. * Unless required by applicable law or agreed to in writing,
  55195. * software distributed under the License is distributed on an
  55196. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55197. * KIND, either express or implied. See the License for the
  55198. * specific language governing permissions and limitations
  55199. * under the License.
  55200. */
  55201. var SunburstView =
  55202. /** @class */
  55203. function (_super) {
  55204. __extends(SunburstView, _super);
  55205. function SunburstView() {
  55206. var _this = _super !== null && _super.apply(this, arguments) || this;
  55207. _this.type = SunburstView.type;
  55208. return _this;
  55209. }
  55210. SunburstView.prototype.render = function (seriesModel, ecModel, api, // @ts-ignore
  55211. payload) {
  55212. var self = this;
  55213. this.seriesModel = seriesModel;
  55214. this.api = api;
  55215. this.ecModel = ecModel;
  55216. var data = seriesModel.getData();
  55217. var virtualRoot = data.tree.root;
  55218. var newRoot = seriesModel.getViewRoot();
  55219. var group = this.group;
  55220. var renderLabelForZeroData = seriesModel.get('renderLabelForZeroData');
  55221. var newChildren = [];
  55222. newRoot.eachNode(function (node) {
  55223. newChildren.push(node);
  55224. });
  55225. var oldChildren = this._oldChildren || [];
  55226. dualTravel(newChildren, oldChildren);
  55227. renderRollUp(virtualRoot, newRoot);
  55228. this._initEvents();
  55229. this._oldChildren = newChildren;
  55230. function dualTravel(newChildren, oldChildren) {
  55231. if (newChildren.length === 0 && oldChildren.length === 0) {
  55232. return;
  55233. }
  55234. new DataDiffer(oldChildren, newChildren, getKey, getKey).add(processNode).update(processNode).remove(curry(processNode, null)).execute();
  55235. function getKey(node) {
  55236. return node.getId();
  55237. }
  55238. function processNode(newIdx, oldIdx) {
  55239. var newNode = newIdx == null ? null : newChildren[newIdx];
  55240. var oldNode = oldIdx == null ? null : oldChildren[oldIdx];
  55241. doRenderNode(newNode, oldNode);
  55242. }
  55243. }
  55244. function doRenderNode(newNode, oldNode) {
  55245. if (!renderLabelForZeroData && newNode && !newNode.getValue()) {
  55246. // Not render data with value 0
  55247. newNode = null;
  55248. }
  55249. if (newNode !== virtualRoot && oldNode !== virtualRoot) {
  55250. if (oldNode && oldNode.piece) {
  55251. if (newNode) {
  55252. // Update
  55253. oldNode.piece.updateData(false, newNode, seriesModel, ecModel, api); // For tooltip
  55254. data.setItemGraphicEl(newNode.dataIndex, oldNode.piece);
  55255. } else {
  55256. // Remove
  55257. removeNode(oldNode);
  55258. }
  55259. } else if (newNode) {
  55260. // Add
  55261. var piece = new SunburstPiece(newNode, seriesModel, ecModel, api);
  55262. group.add(piece); // For tooltip
  55263. data.setItemGraphicEl(newNode.dataIndex, piece);
  55264. }
  55265. }
  55266. }
  55267. function removeNode(node) {
  55268. if (!node) {
  55269. return;
  55270. }
  55271. if (node.piece) {
  55272. group.remove(node.piece);
  55273. node.piece = null;
  55274. }
  55275. }
  55276. function renderRollUp(virtualRoot, viewRoot) {
  55277. if (viewRoot.depth > 0) {
  55278. // Render
  55279. if (self.virtualPiece) {
  55280. // Update
  55281. self.virtualPiece.updateData(false, virtualRoot, seriesModel, ecModel, api);
  55282. } else {
  55283. // Add
  55284. self.virtualPiece = new SunburstPiece(virtualRoot, seriesModel, ecModel, api);
  55285. group.add(self.virtualPiece);
  55286. } // TODO event scope
  55287. viewRoot.piece.off('click');
  55288. self.virtualPiece.on('click', function (e) {
  55289. self._rootToNode(viewRoot.parentNode);
  55290. });
  55291. } else if (self.virtualPiece) {
  55292. // Remove
  55293. group.remove(self.virtualPiece);
  55294. self.virtualPiece = null;
  55295. }
  55296. }
  55297. };
  55298. /**
  55299. * @private
  55300. */
  55301. SunburstView.prototype._initEvents = function () {
  55302. var _this = this;
  55303. this.group.off('click');
  55304. this.group.on('click', function (e) {
  55305. var targetFound = false;
  55306. var viewRoot = _this.seriesModel.getViewRoot();
  55307. viewRoot.eachNode(function (node) {
  55308. if (!targetFound && node.piece && node.piece === e.target) {
  55309. var nodeClick = node.getModel().get('nodeClick');
  55310. if (nodeClick === 'rootToNode') {
  55311. _this._rootToNode(node);
  55312. } else if (nodeClick === 'link') {
  55313. var itemModel = node.getModel();
  55314. var link = itemModel.get('link');
  55315. if (link) {
  55316. var linkTarget = itemModel.get('target', true) || '_blank';
  55317. windowOpen(link, linkTarget);
  55318. }
  55319. }
  55320. targetFound = true;
  55321. }
  55322. });
  55323. });
  55324. };
  55325. /**
  55326. * @private
  55327. */
  55328. SunburstView.prototype._rootToNode = function (node) {
  55329. if (node !== this.seriesModel.getViewRoot()) {
  55330. this.api.dispatchAction({
  55331. type: ROOT_TO_NODE_ACTION,
  55332. from: this.uid,
  55333. seriesId: this.seriesModel.id,
  55334. targetNode: node
  55335. });
  55336. }
  55337. };
  55338. /**
  55339. * @implement
  55340. */
  55341. SunburstView.prototype.containPoint = function (point, seriesModel) {
  55342. var treeRoot = seriesModel.getData();
  55343. var itemLayout = treeRoot.getItemLayout(0);
  55344. if (itemLayout) {
  55345. var dx = point[0] - itemLayout.cx;
  55346. var dy = point[1] - itemLayout.cy;
  55347. var radius = Math.sqrt(dx * dx + dy * dy);
  55348. return radius <= itemLayout.r && radius >= itemLayout.r0;
  55349. }
  55350. };
  55351. SunburstView.type = 'sunburst';
  55352. return SunburstView;
  55353. }(ChartView);
  55354. /*
  55355. * Licensed to the Apache Software Foundation (ASF) under one
  55356. * or more contributor license agreements. See the NOTICE file
  55357. * distributed with this work for additional information
  55358. * regarding copyright ownership. The ASF licenses this file
  55359. * to you under the Apache License, Version 2.0 (the
  55360. * "License"); you may not use this file except in compliance
  55361. * with the License. You may obtain a copy of the License at
  55362. *
  55363. * http://www.apache.org/licenses/LICENSE-2.0
  55364. *
  55365. * Unless required by applicable law or agreed to in writing,
  55366. * software distributed under the License is distributed on an
  55367. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55368. * KIND, either express or implied. See the License for the
  55369. * specific language governing permissions and limitations
  55370. * under the License.
  55371. */
  55372. /**
  55373. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55374. */
  55375. /*
  55376. * Licensed to the Apache Software Foundation (ASF) under one
  55377. * or more contributor license agreements. See the NOTICE file
  55378. * distributed with this work for additional information
  55379. * regarding copyright ownership. The ASF licenses this file
  55380. * to you under the Apache License, Version 2.0 (the
  55381. * "License"); you may not use this file except in compliance
  55382. * with the License. You may obtain a copy of the License at
  55383. *
  55384. * http://www.apache.org/licenses/LICENSE-2.0
  55385. *
  55386. * Unless required by applicable law or agreed to in writing,
  55387. * software distributed under the License is distributed on an
  55388. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55389. * KIND, either express or implied. See the License for the
  55390. * specific language governing permissions and limitations
  55391. * under the License.
  55392. */
  55393. var SunburstSeriesModel =
  55394. /** @class */
  55395. function (_super) {
  55396. __extends(SunburstSeriesModel, _super);
  55397. function SunburstSeriesModel() {
  55398. var _this = _super !== null && _super.apply(this, arguments) || this;
  55399. _this.type = SunburstSeriesModel.type;
  55400. _this.ignoreStyleOnData = true;
  55401. return _this;
  55402. }
  55403. SunburstSeriesModel.prototype.getInitialData = function (option, ecModel) {
  55404. // Create a virtual root.
  55405. var root = {
  55406. name: option.name,
  55407. children: option.data
  55408. };
  55409. completeTreeValue$1(root);
  55410. var levelModels = map(option.levels || [], function (levelDefine) {
  55411. return new Model(levelDefine, this, ecModel);
  55412. }, this); // Make sure always a new tree is created when setOption,
  55413. // in TreemapView, we check whether oldTree === newTree
  55414. // to choose mappings approach among old shapes and new shapes.
  55415. var tree = Tree.createTree(root, this, beforeLink);
  55416. function beforeLink(nodeData) {
  55417. nodeData.wrapMethod('getItemModel', function (model, idx) {
  55418. var node = tree.getNodeByDataIndex(idx);
  55419. var levelModel = levelModels[node.depth];
  55420. levelModel && (model.parentModel = levelModel);
  55421. return model;
  55422. });
  55423. }
  55424. return tree.data;
  55425. };
  55426. SunburstSeriesModel.prototype.optionUpdated = function () {
  55427. this.resetViewRoot();
  55428. };
  55429. /*
  55430. * @override
  55431. */
  55432. SunburstSeriesModel.prototype.getDataParams = function (dataIndex) {
  55433. var params = _super.prototype.getDataParams.apply(this, arguments);
  55434. var node = this.getData().tree.getNodeByDataIndex(dataIndex);
  55435. params.treePathInfo = wrapTreePathInfo(node, this);
  55436. return params;
  55437. };
  55438. SunburstSeriesModel.prototype.getViewRoot = function () {
  55439. return this._viewRoot;
  55440. };
  55441. SunburstSeriesModel.prototype.resetViewRoot = function (viewRoot) {
  55442. viewRoot ? this._viewRoot = viewRoot : viewRoot = this._viewRoot;
  55443. var root = this.getRawData().tree.root;
  55444. if (!viewRoot || viewRoot !== root && !root.contains(viewRoot)) {
  55445. this._viewRoot = root;
  55446. }
  55447. };
  55448. SunburstSeriesModel.prototype.enableAriaDecal = function () {
  55449. enableAriaDecalForTree(this);
  55450. };
  55451. SunburstSeriesModel.type = 'series.sunburst';
  55452. SunburstSeriesModel.defaultOption = {
  55453. zlevel: 0,
  55454. z: 2,
  55455. // 默认全局居中
  55456. center: ['50%', '50%'],
  55457. radius: [0, '75%'],
  55458. // 默认顺时针
  55459. clockwise: true,
  55460. startAngle: 90,
  55461. // 最小角度改为0
  55462. minAngle: 0,
  55463. // If still show when all data zero.
  55464. stillShowZeroSum: true,
  55465. // 'rootToNode', 'link', or false
  55466. nodeClick: 'rootToNode',
  55467. renderLabelForZeroData: false,
  55468. label: {
  55469. // could be: 'radial', 'tangential', or 'none'
  55470. rotate: 'radial',
  55471. show: true,
  55472. opacity: 1,
  55473. // 'left' is for inner side of inside, and 'right' is for outter
  55474. // side for inside
  55475. align: 'center',
  55476. position: 'inside',
  55477. distance: 5,
  55478. silent: true
  55479. },
  55480. itemStyle: {
  55481. borderWidth: 1,
  55482. borderColor: 'white',
  55483. borderType: 'solid',
  55484. shadowBlur: 0,
  55485. shadowColor: 'rgba(0, 0, 0, 0.2)',
  55486. shadowOffsetX: 0,
  55487. shadowOffsetY: 0,
  55488. opacity: 1
  55489. },
  55490. emphasis: {
  55491. focus: 'descendant'
  55492. },
  55493. blur: {
  55494. itemStyle: {
  55495. opacity: 0.2
  55496. },
  55497. label: {
  55498. opacity: 0.1
  55499. }
  55500. },
  55501. // Animation type canbe expansion, scale
  55502. animationType: 'expansion',
  55503. animationDuration: 1000,
  55504. animationDurationUpdate: 500,
  55505. data: [],
  55506. levels: [],
  55507. /**
  55508. * Sort order.
  55509. *
  55510. * Valid values: 'desc', 'asc', null, or callback function.
  55511. * 'desc' and 'asc' for descend and ascendant order;
  55512. * null for not sorting;
  55513. * example of callback function:
  55514. * function(nodeA, nodeB) {
  55515. * return nodeA.getValue() - nodeB.getValue();
  55516. * }
  55517. */
  55518. sort: 'desc'
  55519. };
  55520. return SunburstSeriesModel;
  55521. }(SeriesModel);
  55522. function completeTreeValue$1(dataNode) {
  55523. // Postorder travel tree.
  55524. // If value of none-leaf node is not set,
  55525. // calculate it by suming up the value of all children.
  55526. var sum = 0;
  55527. each$1(dataNode.children, function (child) {
  55528. completeTreeValue$1(child);
  55529. var childValue = child.value; // TODO First value of array must be a number
  55530. isArray(childValue) && (childValue = childValue[0]);
  55531. sum += childValue;
  55532. });
  55533. var thisValue = dataNode.value;
  55534. if (isArray(thisValue)) {
  55535. thisValue = thisValue[0];
  55536. }
  55537. if (thisValue == null || isNaN(thisValue)) {
  55538. thisValue = sum;
  55539. } // Value should not less than 0.
  55540. if (thisValue < 0) {
  55541. thisValue = 0;
  55542. }
  55543. isArray(dataNode.value) ? dataNode.value[0] = thisValue : dataNode.value = thisValue;
  55544. }
  55545. /*
  55546. * Licensed to the Apache Software Foundation (ASF) under one
  55547. * or more contributor license agreements. See the NOTICE file
  55548. * distributed with this work for additional information
  55549. * regarding copyright ownership. The ASF licenses this file
  55550. * to you under the Apache License, Version 2.0 (the
  55551. * "License"); you may not use this file except in compliance
  55552. * with the License. You may obtain a copy of the License at
  55553. *
  55554. * http://www.apache.org/licenses/LICENSE-2.0
  55555. *
  55556. * Unless required by applicable law or agreed to in writing,
  55557. * software distributed under the License is distributed on an
  55558. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55559. * KIND, either express or implied. See the License for the
  55560. * specific language governing permissions and limitations
  55561. * under the License.
  55562. */
  55563. /**
  55564. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55565. */
  55566. /*
  55567. * Licensed to the Apache Software Foundation (ASF) under one
  55568. * or more contributor license agreements. See the NOTICE file
  55569. * distributed with this work for additional information
  55570. * regarding copyright ownership. The ASF licenses this file
  55571. * to you under the Apache License, Version 2.0 (the
  55572. * "License"); you may not use this file except in compliance
  55573. * with the License. You may obtain a copy of the License at
  55574. *
  55575. * http://www.apache.org/licenses/LICENSE-2.0
  55576. *
  55577. * Unless required by applicable law or agreed to in writing,
  55578. * software distributed under the License is distributed on an
  55579. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55580. * KIND, either express or implied. See the License for the
  55581. * specific language governing permissions and limitations
  55582. * under the License.
  55583. */
  55584. var RADIAN$2 = Math.PI / 180;
  55585. function sunburstLayout(seriesType, ecModel, api) {
  55586. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  55587. var center = seriesModel.get('center');
  55588. var radius = seriesModel.get('radius');
  55589. if (!isArray(radius)) {
  55590. radius = [0, radius];
  55591. }
  55592. if (!isArray(center)) {
  55593. center = [center, center];
  55594. }
  55595. var width = api.getWidth();
  55596. var height = api.getHeight();
  55597. var size = Math.min(width, height);
  55598. var cx = parsePercent$1(center[0], width);
  55599. var cy = parsePercent$1(center[1], height);
  55600. var r0 = parsePercent$1(radius[0], size / 2);
  55601. var r = parsePercent$1(radius[1], size / 2);
  55602. var startAngle = -seriesModel.get('startAngle') * RADIAN$2;
  55603. var minAngle = seriesModel.get('minAngle') * RADIAN$2;
  55604. var virtualRoot = seriesModel.getData().tree.root;
  55605. var treeRoot = seriesModel.getViewRoot();
  55606. var rootDepth = treeRoot.depth;
  55607. var sort = seriesModel.get('sort');
  55608. if (sort != null) {
  55609. initChildren$1(treeRoot, sort);
  55610. }
  55611. var validDataCount = 0;
  55612. each$1(treeRoot.children, function (child) {
  55613. !isNaN(child.getValue()) && validDataCount++;
  55614. });
  55615. var sum = treeRoot.getValue(); // Sum may be 0
  55616. var unitRadian = Math.PI / (sum || validDataCount) * 2;
  55617. var renderRollupNode = treeRoot.depth > 0;
  55618. var levels = treeRoot.height - (renderRollupNode ? -1 : 1);
  55619. var rPerLevel = (r - r0) / (levels || 1);
  55620. var clockwise = seriesModel.get('clockwise');
  55621. var stillShowZeroSum = seriesModel.get('stillShowZeroSum'); // In the case some sector angle is smaller than minAngle
  55622. // let restAngle = PI2;
  55623. // let valueSumLargerThanMinAngle = 0;
  55624. var dir = clockwise ? 1 : -1;
  55625. /**
  55626. * Render a tree
  55627. * @return increased angle
  55628. */
  55629. var renderNode = function (node, startAngle) {
  55630. if (!node) {
  55631. return;
  55632. }
  55633. var endAngle = startAngle; // Render self
  55634. if (node !== virtualRoot) {
  55635. // Tree node is virtual, so it doesn't need to be drawn
  55636. var value = node.getValue();
  55637. var angle = sum === 0 && stillShowZeroSum ? unitRadian : value * unitRadian;
  55638. if (angle < minAngle) {
  55639. angle = minAngle; // restAngle -= minAngle;
  55640. } // else {
  55641. // valueSumLargerThanMinAngle += value;
  55642. // }
  55643. endAngle = startAngle + dir * angle;
  55644. var depth = node.depth - rootDepth - (renderRollupNode ? -1 : 1);
  55645. var rStart = r0 + rPerLevel * depth;
  55646. var rEnd = r0 + rPerLevel * (depth + 1);
  55647. var itemModel = node.getModel(); // @ts-ignore. TODO this is not provided to developer yet. Rename it.
  55648. if (itemModel.get('r0') != null) {
  55649. // @ts-ignore
  55650. rStart = parsePercent$1(itemModel.get('r0'), size / 2);
  55651. } // @ts-ignore
  55652. if (itemModel.get('r') != null) {
  55653. // @ts-ignore
  55654. rEnd = parsePercent$1(itemModel.get('r'), size / 2);
  55655. }
  55656. node.setLayout({
  55657. angle: angle,
  55658. startAngle: startAngle,
  55659. endAngle: endAngle,
  55660. clockwise: clockwise,
  55661. cx: cx,
  55662. cy: cy,
  55663. r0: rStart,
  55664. r: rEnd
  55665. });
  55666. } // Render children
  55667. if (node.children && node.children.length) {
  55668. // currentAngle = startAngle;
  55669. var siblingAngle_1 = 0;
  55670. each$1(node.children, function (node) {
  55671. siblingAngle_1 += renderNode(node, startAngle + siblingAngle_1);
  55672. });
  55673. }
  55674. return endAngle - startAngle;
  55675. }; // Virtual root node for roll up
  55676. if (renderRollupNode) {
  55677. var rStart = r0;
  55678. var rEnd = r0 + rPerLevel;
  55679. var angle = Math.PI * 2;
  55680. virtualRoot.setLayout({
  55681. angle: angle,
  55682. startAngle: startAngle,
  55683. endAngle: startAngle + angle,
  55684. clockwise: clockwise,
  55685. cx: cx,
  55686. cy: cy,
  55687. r0: rStart,
  55688. r: rEnd
  55689. });
  55690. }
  55691. renderNode(treeRoot, startAngle);
  55692. });
  55693. }
  55694. /**
  55695. * Init node children by order and update visual
  55696. */
  55697. function initChildren$1(node, sortOrder) {
  55698. var children = node.children || [];
  55699. node.children = sort$2(children, sortOrder); // Init children recursively
  55700. if (children.length) {
  55701. each$1(node.children, function (child) {
  55702. initChildren$1(child, sortOrder);
  55703. });
  55704. }
  55705. }
  55706. /**
  55707. * Sort children nodes
  55708. *
  55709. * @param {TreeNode[]} children children of node to be sorted
  55710. * @param {string | function | null} sort sort method
  55711. * See SunburstSeries.js for details.
  55712. */
  55713. function sort$2(children, sortOrder) {
  55714. if (typeof sortOrder === 'function') {
  55715. var sortTargets = map(children, function (child, idx) {
  55716. var value = child.getValue();
  55717. return {
  55718. params: {
  55719. depth: child.depth,
  55720. height: child.height,
  55721. dataIndex: child.dataIndex,
  55722. getValue: function () {
  55723. return value;
  55724. }
  55725. },
  55726. index: idx
  55727. };
  55728. });
  55729. sortTargets.sort(function (a, b) {
  55730. return sortOrder(a.params, b.params);
  55731. });
  55732. return map(sortTargets, function (target) {
  55733. return children[target.index];
  55734. });
  55735. } else {
  55736. var isAsc_1 = sortOrder === 'asc';
  55737. return children.sort(function (a, b) {
  55738. var diff = (a.getValue() - b.getValue()) * (isAsc_1 ? 1 : -1);
  55739. return diff === 0 ? (a.dataIndex - b.dataIndex) * (isAsc_1 ? -1 : 1) : diff;
  55740. });
  55741. }
  55742. }
  55743. /*
  55744. * Licensed to the Apache Software Foundation (ASF) under one
  55745. * or more contributor license agreements. See the NOTICE file
  55746. * distributed with this work for additional information
  55747. * regarding copyright ownership. The ASF licenses this file
  55748. * to you under the Apache License, Version 2.0 (the
  55749. * "License"); you may not use this file except in compliance
  55750. * with the License. You may obtain a copy of the License at
  55751. *
  55752. * http://www.apache.org/licenses/LICENSE-2.0
  55753. *
  55754. * Unless required by applicable law or agreed to in writing,
  55755. * software distributed under the License is distributed on an
  55756. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55757. * KIND, either express or implied. See the License for the
  55758. * specific language governing permissions and limitations
  55759. * under the License.
  55760. */
  55761. /**
  55762. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55763. */
  55764. /*
  55765. * Licensed to the Apache Software Foundation (ASF) under one
  55766. * or more contributor license agreements. See the NOTICE file
  55767. * distributed with this work for additional information
  55768. * regarding copyright ownership. The ASF licenses this file
  55769. * to you under the Apache License, Version 2.0 (the
  55770. * "License"); you may not use this file except in compliance
  55771. * with the License. You may obtain a copy of the License at
  55772. *
  55773. * http://www.apache.org/licenses/LICENSE-2.0
  55774. *
  55775. * Unless required by applicable law or agreed to in writing,
  55776. * software distributed under the License is distributed on an
  55777. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55778. * KIND, either express or implied. See the License for the
  55779. * specific language governing permissions and limitations
  55780. * under the License.
  55781. */
  55782. function sunburstVisual(ecModel) {
  55783. var paletteScope = {}; // Default color strategy
  55784. function pickColor(node, seriesModel, treeHeight) {
  55785. // Choose color from palette based on the first level.
  55786. var current = node;
  55787. while (current && current.depth > 1) {
  55788. current = current.parentNode;
  55789. }
  55790. var color = seriesModel.getColorFromPalette(current.name || current.dataIndex + '', paletteScope);
  55791. if (node.depth > 1 && typeof color === 'string') {
  55792. // Lighter on the deeper level.
  55793. color = lift(color, (node.depth - 1) / (treeHeight - 1) * 0.5);
  55794. }
  55795. return color;
  55796. }
  55797. ecModel.eachSeriesByType('sunburst', function (seriesModel) {
  55798. var data = seriesModel.getData();
  55799. var tree = data.tree;
  55800. tree.eachNode(function (node) {
  55801. var model = node.getModel();
  55802. var style = model.getModel('itemStyle').getItemStyle();
  55803. if (!style.fill) {
  55804. style.fill = pickColor(node, seriesModel, tree.root.height);
  55805. }
  55806. var existsStyle = data.ensureUniqueItemVisual(node.dataIndex, 'style');
  55807. extend(existsStyle, style);
  55808. });
  55809. });
  55810. }
  55811. /*
  55812. * Licensed to the Apache Software Foundation (ASF) under one
  55813. * or more contributor license agreements. See the NOTICE file
  55814. * distributed with this work for additional information
  55815. * regarding copyright ownership. The ASF licenses this file
  55816. * to you under the Apache License, Version 2.0 (the
  55817. * "License"); you may not use this file except in compliance
  55818. * with the License. You may obtain a copy of the License at
  55819. *
  55820. * http://www.apache.org/licenses/LICENSE-2.0
  55821. *
  55822. * Unless required by applicable law or agreed to in writing,
  55823. * software distributed under the License is distributed on an
  55824. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55825. * KIND, either express or implied. See the License for the
  55826. * specific language governing permissions and limitations
  55827. * under the License.
  55828. */
  55829. /**
  55830. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55831. */
  55832. /*
  55833. * Licensed to the Apache Software Foundation (ASF) under one
  55834. * or more contributor license agreements. See the NOTICE file
  55835. * distributed with this work for additional information
  55836. * regarding copyright ownership. The ASF licenses this file
  55837. * to you under the Apache License, Version 2.0 (the
  55838. * "License"); you may not use this file except in compliance
  55839. * with the License. You may obtain a copy of the License at
  55840. *
  55841. * http://www.apache.org/licenses/LICENSE-2.0
  55842. *
  55843. * Unless required by applicable law or agreed to in writing,
  55844. * software distributed under the License is distributed on an
  55845. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55846. * KIND, either express or implied. See the License for the
  55847. * specific language governing permissions and limitations
  55848. * under the License.
  55849. */
  55850. function install$14(registers) {
  55851. registers.registerChartView(SunburstView);
  55852. registers.registerSeriesModel(SunburstSeriesModel);
  55853. registers.registerLayout(curry(sunburstLayout, 'sunburst'));
  55854. registers.registerProcessor(curry(dataFilter, 'sunburst'));
  55855. registers.registerVisual(sunburstVisual);
  55856. installSunburstAction(registers);
  55857. }
  55858. /*
  55859. * Licensed to the Apache Software Foundation (ASF) under one
  55860. * or more contributor license agreements. See the NOTICE file
  55861. * distributed with this work for additional information
  55862. * regarding copyright ownership. The ASF licenses this file
  55863. * to you under the Apache License, Version 2.0 (the
  55864. * "License"); you may not use this file except in compliance
  55865. * with the License. You may obtain a copy of the License at
  55866. *
  55867. * http://www.apache.org/licenses/LICENSE-2.0
  55868. *
  55869. * Unless required by applicable law or agreed to in writing,
  55870. * software distributed under the License is distributed on an
  55871. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55872. * KIND, either express or implied. See the License for the
  55873. * specific language governing permissions and limitations
  55874. * under the License.
  55875. */
  55876. /**
  55877. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55878. */
  55879. /*
  55880. * Licensed to the Apache Software Foundation (ASF) under one
  55881. * or more contributor license agreements. See the NOTICE file
  55882. * distributed with this work for additional information
  55883. * regarding copyright ownership. The ASF licenses this file
  55884. * to you under the Apache License, Version 2.0 (the
  55885. * "License"); you may not use this file except in compliance
  55886. * with the License. You may obtain a copy of the License at
  55887. *
  55888. * http://www.apache.org/licenses/LICENSE-2.0
  55889. *
  55890. * Unless required by applicable law or agreed to in writing,
  55891. * software distributed under the License is distributed on an
  55892. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55893. * KIND, either express or implied. See the License for the
  55894. * specific language governing permissions and limitations
  55895. * under the License.
  55896. */
  55897. use(install$14);
  55898. /*
  55899. * Licensed to the Apache Software Foundation (ASF) under one
  55900. * or more contributor license agreements. See the NOTICE file
  55901. * distributed with this work for additional information
  55902. * regarding copyright ownership. The ASF licenses this file
  55903. * to you under the Apache License, Version 2.0 (the
  55904. * "License"); you may not use this file except in compliance
  55905. * with the License. You may obtain a copy of the License at
  55906. *
  55907. * http://www.apache.org/licenses/LICENSE-2.0
  55908. *
  55909. * Unless required by applicable law or agreed to in writing,
  55910. * software distributed under the License is distributed on an
  55911. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55912. * KIND, either express or implied. See the License for the
  55913. * specific language governing permissions and limitations
  55914. * under the License.
  55915. */
  55916. /**
  55917. * AUTO-GENERATED FILE. DO NOT MODIFY.
  55918. */
  55919. /*
  55920. * Licensed to the Apache Software Foundation (ASF) under one
  55921. * or more contributor license agreements. See the NOTICE file
  55922. * distributed with this work for additional information
  55923. * regarding copyright ownership. The ASF licenses this file
  55924. * to you under the Apache License, Version 2.0 (the
  55925. * "License"); you may not use this file except in compliance
  55926. * with the License. You may obtain a copy of the License at
  55927. *
  55928. * http://www.apache.org/licenses/LICENSE-2.0
  55929. *
  55930. * Unless required by applicable law or agreed to in writing,
  55931. * software distributed under the License is distributed on an
  55932. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  55933. * KIND, either express or implied. See the License for the
  55934. * specific language governing permissions and limitations
  55935. * under the License.
  55936. */
  55937. /**
  55938. * Only these tags enable use `itemStyle` if they are named in SVG.
  55939. * Other tags like <text> <tspan> <image> might not suitable for `itemStyle`.
  55940. * They will not be considered to be styled until some requirements come.
  55941. */
  55942. var OPTION_STYLE_ENABLED_TAGS = ['rect', 'circle', 'line', 'ellipse', 'polygon', 'polyline', 'path'];
  55943. var OPTION_STYLE_ENABLED_TAG_MAP = createHashMap(OPTION_STYLE_ENABLED_TAGS);
  55944. var STATE_TRIGGER_TAG_MAP = createHashMap(OPTION_STYLE_ENABLED_TAGS.concat(['g']));
  55945. var LABEL_HOST_MAP = createHashMap(OPTION_STYLE_ENABLED_TAGS.concat(['g']));
  55946. var mapLabelRaw = makeInner();
  55947. function getFixedItemStyle(model) {
  55948. var itemStyle = model.getItemStyle();
  55949. var areaColor = model.get('areaColor'); // If user want the color not to be changed when hover,
  55950. // they should both set areaColor and color to be null.
  55951. if (areaColor != null) {
  55952. itemStyle.fill = areaColor;
  55953. }
  55954. return itemStyle;
  55955. }
  55956. var MapDraw =
  55957. /** @class */
  55958. function () {
  55959. function MapDraw(api) {
  55960. var group = new Group();
  55961. this.uid = getUID('ec_map_draw');
  55962. this._controller = new RoamController(api.getZr());
  55963. this._controllerHost = {
  55964. target: group
  55965. };
  55966. this.group = group;
  55967. group.add(this._regionsGroup = new Group());
  55968. group.add(this._svgGroup = new Group());
  55969. }
  55970. MapDraw.prototype.draw = function (mapOrGeoModel, ecModel, api, fromView, payload) {
  55971. var isGeo = mapOrGeoModel.mainType === 'geo'; // Map series has data. GEO model that controlled by map series
  55972. // will be assigned with map data. Other GEO model has no data.
  55973. var data = mapOrGeoModel.getData && mapOrGeoModel.getData();
  55974. isGeo && ecModel.eachComponent({
  55975. mainType: 'series',
  55976. subType: 'map'
  55977. }, function (mapSeries) {
  55978. if (!data && mapSeries.getHostGeoModel() === mapOrGeoModel) {
  55979. data = mapSeries.getData();
  55980. }
  55981. });
  55982. var geo = mapOrGeoModel.coordinateSystem;
  55983. var regionsGroup = this._regionsGroup;
  55984. var group = this.group;
  55985. var transformInfo = geo.getTransformInfo();
  55986. var transformInfoRaw = transformInfo.raw;
  55987. var transformInfoRoam = transformInfo.roam; // No animation when first draw or in action
  55988. var isFirstDraw = !regionsGroup.childAt(0) || payload;
  55989. if (isFirstDraw) {
  55990. group.x = transformInfoRoam.x;
  55991. group.y = transformInfoRoam.y;
  55992. group.scaleX = transformInfoRoam.scaleX;
  55993. group.scaleY = transformInfoRoam.scaleY;
  55994. group.dirty();
  55995. } else {
  55996. updateProps(group, transformInfoRoam, mapOrGeoModel);
  55997. }
  55998. var isVisualEncodedByVisualMap = data && data.getVisual('visualMeta') && data.getVisual('visualMeta').length > 0;
  55999. var viewBuildCtx = {
  56000. api: api,
  56001. geo: geo,
  56002. mapOrGeoModel: mapOrGeoModel,
  56003. data: data,
  56004. isVisualEncodedByVisualMap: isVisualEncodedByVisualMap,
  56005. isGeo: isGeo,
  56006. transformInfoRaw: transformInfoRaw
  56007. };
  56008. if (geo.resourceType === 'geoJSON') {
  56009. this._buildGeoJSON(viewBuildCtx);
  56010. } else if (geo.resourceType === 'geoSVG') {
  56011. this._buildSVG(viewBuildCtx);
  56012. }
  56013. this._updateController(mapOrGeoModel, ecModel, api);
  56014. this._updateMapSelectHandler(mapOrGeoModel, regionsGroup, api, fromView);
  56015. };
  56016. MapDraw.prototype._buildGeoJSON = function (viewBuildCtx) {
  56017. var nameMap = this._regionsGroupByName = createHashMap();
  56018. var regionsGroup = this._regionsGroup;
  56019. var transformInfoRaw = viewBuildCtx.transformInfoRaw;
  56020. var mapOrGeoModel = viewBuildCtx.mapOrGeoModel;
  56021. var data = viewBuildCtx.data;
  56022. var transformPoint = function (point) {
  56023. return [point[0] * transformInfoRaw.scaleX + transformInfoRaw.x, point[1] * transformInfoRaw.scaleY + transformInfoRaw.y];
  56024. };
  56025. regionsGroup.removeAll(); // Only when the resource is GeoJSON, there is `geo.regions`.
  56026. each$1(viewBuildCtx.geo.regions, function (region) {
  56027. var regionName = region.name;
  56028. var regionModel = mapOrGeoModel.getRegionModel(regionName);
  56029. var dataIdx = data ? data.indexOfName(regionName) : null; // Consider in GeoJson properties.name may be duplicated, for example,
  56030. // there is multiple region named "United Kindom" or "France" (so many
  56031. // colonies). And it is not appropriate to merge them in geo, which
  56032. // will make them share the same label and bring trouble in label
  56033. // location calculation.
  56034. var regionGroup = nameMap.get(regionName);
  56035. if (!regionGroup) {
  56036. regionGroup = nameMap.set(regionName, new Group());
  56037. regionsGroup.add(regionGroup);
  56038. resetEventTriggerForRegion(viewBuildCtx, regionGroup, regionName, regionModel, mapOrGeoModel, dataIdx);
  56039. resetTooltipForRegion(viewBuildCtx, regionGroup, regionName, regionModel, mapOrGeoModel);
  56040. resetStateTriggerForRegion(viewBuildCtx, regionGroup, regionName, regionModel, mapOrGeoModel);
  56041. }
  56042. var compoundPath = new CompoundPath({
  56043. segmentIgnoreThreshold: 1,
  56044. shape: {
  56045. paths: []
  56046. }
  56047. });
  56048. regionGroup.add(compoundPath);
  56049. each$1(region.geometries, function (geometry) {
  56050. if (geometry.type !== 'polygon') {
  56051. return;
  56052. }
  56053. var points = [];
  56054. for (var i = 0; i < geometry.exterior.length; ++i) {
  56055. points.push(transformPoint(geometry.exterior[i]));
  56056. }
  56057. compoundPath.shape.paths.push(new Polygon({
  56058. segmentIgnoreThreshold: 1,
  56059. shape: {
  56060. points: points
  56061. }
  56062. }));
  56063. for (var i = 0; i < (geometry.interiors ? geometry.interiors.length : 0); ++i) {
  56064. var interior = geometry.interiors[i];
  56065. var points_1 = [];
  56066. for (var j = 0; j < interior.length; ++j) {
  56067. points_1.push(transformPoint(interior[j]));
  56068. }
  56069. compoundPath.shape.paths.push(new Polygon({
  56070. segmentIgnoreThreshold: 1,
  56071. shape: {
  56072. points: points_1
  56073. }
  56074. }));
  56075. }
  56076. });
  56077. applyOptionStyleForRegion(viewBuildCtx, compoundPath, dataIdx, regionModel);
  56078. if (compoundPath instanceof Displayable) {
  56079. compoundPath.culling = true;
  56080. }
  56081. var centerPt = transformPoint(region.getCenter());
  56082. resetLabelForRegion(viewBuildCtx, compoundPath, regionName, regionModel, mapOrGeoModel, dataIdx, centerPt);
  56083. }, this);
  56084. };
  56085. MapDraw.prototype._buildSVG = function (viewBuildCtx) {
  56086. var mapName = viewBuildCtx.geo.map;
  56087. var transformInfoRaw = viewBuildCtx.transformInfoRaw;
  56088. this._svgGroup.x = transformInfoRaw.x;
  56089. this._svgGroup.y = transformInfoRaw.y;
  56090. this._svgGroup.scaleX = transformInfoRaw.scaleX;
  56091. this._svgGroup.scaleY = transformInfoRaw.scaleY;
  56092. if (this._svgResourceChanged(mapName)) {
  56093. this._freeSVG();
  56094. this._useSVG(mapName);
  56095. }
  56096. var svgDispatcherMap = this._svgDispatcherMap = createHashMap();
  56097. var focusSelf = false;
  56098. each$1(this._svgGraphicRecord.named, function (namedItem) {
  56099. // Note that we also allow different elements have the same name.
  56100. // For example, a glyph of a city and the label of the city have
  56101. // the same name and their tooltip info can be defined in a single
  56102. // region option.
  56103. var regionName = namedItem.name;
  56104. var mapOrGeoModel = viewBuildCtx.mapOrGeoModel;
  56105. var data = viewBuildCtx.data;
  56106. var svgNodeTagLower = namedItem.svgNodeTagLower;
  56107. var el = namedItem.el;
  56108. var dataIdx = data ? data.indexOfName(regionName) : null;
  56109. var regionModel = mapOrGeoModel.getRegionModel(regionName);
  56110. if (OPTION_STYLE_ENABLED_TAG_MAP.get(svgNodeTagLower) != null && el instanceof Displayable) {
  56111. applyOptionStyleForRegion(viewBuildCtx, el, dataIdx, regionModel);
  56112. }
  56113. if (el instanceof Displayable) {
  56114. el.culling = true;
  56115. } // We do not know how the SVG like so we'd better not to change z2.
  56116. // Otherwise it might bring some unexpected result. For example,
  56117. // an area hovered that make some inner city can not be clicked.
  56118. el.z2EmphasisLift = 0; // If self named, that is, if tag is inside a named <g> (where `namedFrom` does not exists):
  56119. if (!namedItem.namedFrom) {
  56120. // label should batter to be displayed based on the center of <g>
  56121. // if it is named rather than displayed on each child.
  56122. if (LABEL_HOST_MAP.get(svgNodeTagLower) != null) {
  56123. resetLabelForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel, dataIdx, null);
  56124. }
  56125. resetEventTriggerForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel, dataIdx);
  56126. resetTooltipForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel);
  56127. if (STATE_TRIGGER_TAG_MAP.get(svgNodeTagLower) != null) {
  56128. var focus_1 = resetStateTriggerForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel);
  56129. if (focus_1 === 'self') {
  56130. focusSelf = true;
  56131. }
  56132. var els = svgDispatcherMap.get(regionName) || svgDispatcherMap.set(regionName, []);
  56133. els.push(el);
  56134. }
  56135. }
  56136. }, this);
  56137. this._enableBlurEntireSVG(focusSelf, viewBuildCtx);
  56138. };
  56139. MapDraw.prototype._enableBlurEntireSVG = function (focusSelf, viewBuildCtx) {
  56140. // It's a little complicated to support blurring the entire geoSVG in series-map.
  56141. // So do not suport it until some requirements come.
  56142. // At present, in series-map, only regions can be blurred.
  56143. if (focusSelf && viewBuildCtx.isGeo) {
  56144. var blurStyle = viewBuildCtx.mapOrGeoModel.getModel(['blur', 'itemStyle']).getItemStyle(); // Only suport `opacity` here. Because not sure that other props are suitable for
  56145. // all of the elements generated by SVG (especially for Text/TSpan/Image/... ).
  56146. var opacity_1 = blurStyle.opacity;
  56147. this._svgGraphicRecord.root.traverse(function (el) {
  56148. if (!el.isGroup) {
  56149. // PENDING: clear those settings to SVG elements when `_freeSVG`.
  56150. // (Currently it happen not to be needed.)
  56151. setDefaultStateProxy(el);
  56152. var style = el.ensureState('blur').style || {}; // Do not overwrite the region style that already set from region option.
  56153. if (style.opacity == null && opacity_1 != null) {
  56154. style.opacity = opacity_1;
  56155. } // If `ensureState('blur').style = {}`, there will be default opacity.
  56156. // Enable `stateTransition` (animation).
  56157. el.ensureState('emphasis');
  56158. }
  56159. });
  56160. }
  56161. };
  56162. MapDraw.prototype.remove = function () {
  56163. this._regionsGroup.removeAll();
  56164. this._regionsGroupByName = null;
  56165. this._svgGroup.removeAll();
  56166. this._freeSVG();
  56167. this._controller.dispose();
  56168. this._controllerHost = null;
  56169. };
  56170. MapDraw.prototype.findHighDownDispatchers = function (name, geoModel) {
  56171. if (name == null) {
  56172. return [];
  56173. }
  56174. var geo = geoModel.coordinateSystem;
  56175. if (geo.resourceType === 'geoJSON') {
  56176. var regionsGroupByName = this._regionsGroupByName;
  56177. if (regionsGroupByName) {
  56178. var regionGroup = regionsGroupByName.get(name);
  56179. return regionGroup ? [regionGroup] : [];
  56180. }
  56181. } else if (geo.resourceType === 'geoSVG') {
  56182. return this._svgDispatcherMap && this._svgDispatcherMap.get(name) || [];
  56183. }
  56184. };
  56185. MapDraw.prototype._svgResourceChanged = function (mapName) {
  56186. return this._svgMapName !== mapName;
  56187. };
  56188. MapDraw.prototype._useSVG = function (mapName) {
  56189. var resource = geoSourceManager.getGeoResource(mapName);
  56190. if (resource && resource.type === 'geoSVG') {
  56191. var svgGraphic = resource.useGraphic(this.uid);
  56192. this._svgGroup.add(svgGraphic.root);
  56193. this._svgGraphicRecord = svgGraphic;
  56194. this._svgMapName = mapName;
  56195. }
  56196. };
  56197. MapDraw.prototype._freeSVG = function () {
  56198. var mapName = this._svgMapName;
  56199. if (mapName == null) {
  56200. return;
  56201. }
  56202. var resource = geoSourceManager.getGeoResource(mapName);
  56203. if (resource && resource.type === 'geoSVG') {
  56204. resource.freeGraphic(this.uid);
  56205. }
  56206. this._svgGraphicRecord = null;
  56207. this._svgDispatcherMap = null;
  56208. this._svgGroup.removeAll();
  56209. this._svgMapName = null;
  56210. };
  56211. MapDraw.prototype._updateController = function (mapOrGeoModel, ecModel, api) {
  56212. var geo = mapOrGeoModel.coordinateSystem;
  56213. var controller = this._controller;
  56214. var controllerHost = this._controllerHost; // @ts-ignore FIXME:TS
  56215. controllerHost.zoomLimit = mapOrGeoModel.get('scaleLimit');
  56216. controllerHost.zoom = geo.getZoom(); // roamType is will be set default true if it is null
  56217. // @ts-ignore FIXME:TS
  56218. controller.enable(mapOrGeoModel.get('roam') || false);
  56219. var mainType = mapOrGeoModel.mainType;
  56220. function makeActionBase() {
  56221. var action = {
  56222. type: 'geoRoam',
  56223. componentType: mainType
  56224. };
  56225. action[mainType + 'Id'] = mapOrGeoModel.id;
  56226. return action;
  56227. }
  56228. controller.off('pan').on('pan', function (e) {
  56229. this._mouseDownFlag = false;
  56230. updateViewOnPan(controllerHost, e.dx, e.dy);
  56231. api.dispatchAction(extend(makeActionBase(), {
  56232. dx: e.dx,
  56233. dy: e.dy
  56234. }));
  56235. }, this);
  56236. controller.off('zoom').on('zoom', function (e) {
  56237. this._mouseDownFlag = false;
  56238. updateViewOnZoom(controllerHost, e.scale, e.originX, e.originY);
  56239. api.dispatchAction(extend(makeActionBase(), {
  56240. zoom: e.scale,
  56241. originX: e.originX,
  56242. originY: e.originY
  56243. }));
  56244. }, this);
  56245. controller.setPointerChecker(function (e, x, y) {
  56246. return geo.containPoint([x, y]) && !onIrrelevantElement(e, api, mapOrGeoModel);
  56247. });
  56248. };
  56249. /**
  56250. * FIXME: this is a temporarily workaround.
  56251. * When `geoRoam` the elements need to be reset in `MapView['render']`, because the props like
  56252. * `ignore` might have been modified by `LabelManager`, and `LabelManager#addLabelsOfSeries`
  56253. * will subsequently cache `defaultAttr` like `ignore`. If do not do this reset, the modified
  56254. * props will have no chance to be restored.
  56255. * Note: this reset should be after `clearStates` in `renderSeries` becuase `useStates` in
  56256. * `renderSeries` will cache the modified `ignore` to `el._normalState`.
  56257. * TODO:
  56258. * Use clone/immutable in `LabelManager`?
  56259. */
  56260. MapDraw.prototype.resetForLabelLayout = function () {
  56261. this.group.traverse(function (el) {
  56262. var label = el.getTextContent();
  56263. if (label) {
  56264. label.ignore = mapLabelRaw(label).ignore;
  56265. }
  56266. });
  56267. };
  56268. MapDraw.prototype._updateMapSelectHandler = function (mapOrGeoModel, regionsGroup, api, fromView) {
  56269. var mapDraw = this;
  56270. regionsGroup.off('mousedown');
  56271. regionsGroup.off('click'); // @ts-ignore FIXME:TS resolve type conflict
  56272. if (mapOrGeoModel.get('selectedMode')) {
  56273. regionsGroup.on('mousedown', function () {
  56274. mapDraw._mouseDownFlag = true;
  56275. });
  56276. regionsGroup.on('click', function (e) {
  56277. if (!mapDraw._mouseDownFlag) {
  56278. return;
  56279. }
  56280. mapDraw._mouseDownFlag = false;
  56281. });
  56282. }
  56283. };
  56284. return MapDraw;
  56285. }();
  56286. function applyOptionStyleForRegion(viewBuildCtx, el, dataIndex, regionModel) {
  56287. // All of the path are using `itemStyle`, becuase
  56288. // (1) Some SVG also use fill on polyline (The different between
  56289. // polyline and polygon is "open" or "close" but not fill or not).
  56290. // (2) For the common props like opacity, if some use itemStyle
  56291. // and some use `lineStyle`, it might confuse users.
  56292. // (3) Most SVG use <path>, where can not detect wether draw a "line"
  56293. // or a filled shape, so use `itemStyle` for <path>.
  56294. var normalStyleModel = regionModel.getModel('itemStyle');
  56295. var emphasisStyleModel = regionModel.getModel(['emphasis', 'itemStyle']);
  56296. var blurStyleModel = regionModel.getModel(['blur', 'itemStyle']);
  56297. var selectStyleModel = regionModel.getModel(['select', 'itemStyle']); // NOTE: DONT use 'style' in visual when drawing map.
  56298. // This component is used for drawing underlying map for both geo component and map series.
  56299. var normalStyle = getFixedItemStyle(normalStyleModel);
  56300. var emphasisStyle = getFixedItemStyle(emphasisStyleModel);
  56301. var selectStyle = getFixedItemStyle(selectStyleModel);
  56302. var blurStyle = getFixedItemStyle(blurStyleModel); // Update the itemStyle if has data visual
  56303. var data = viewBuildCtx.data;
  56304. if (data) {
  56305. // Only visual color of each item will be used. It can be encoded by visualMap
  56306. // But visual color of series is used in symbol drawing
  56307. // Visual color for each series is for the symbol draw
  56308. var style = data.getItemVisual(dataIndex, 'style');
  56309. var decal = data.getItemVisual(dataIndex, 'decal');
  56310. if (viewBuildCtx.isVisualEncodedByVisualMap && style.fill) {
  56311. normalStyle.fill = style.fill;
  56312. }
  56313. if (decal) {
  56314. normalStyle.decal = createOrUpdatePatternFromDecal(decal, viewBuildCtx.api);
  56315. }
  56316. } // SVG text, tspan and image can be named but not supporeted
  56317. // to be styled by region option yet.
  56318. el.setStyle(normalStyle);
  56319. el.style.strokeNoScale = true;
  56320. el.ensureState('emphasis').style = emphasisStyle;
  56321. el.ensureState('select').style = selectStyle;
  56322. el.ensureState('blur').style = blurStyle; // Enable blur
  56323. setDefaultStateProxy(el);
  56324. }
  56325. function resetLabelForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel, // Exist only if `viewBuildCtx.data` exists.
  56326. dataIdx, // If labelXY not provided, use `textConfig.position: 'inside'`
  56327. labelXY) {
  56328. var data = viewBuildCtx.data;
  56329. var isGeo = viewBuildCtx.isGeo;
  56330. var isDataNaN = data && isNaN(data.get(data.mapDimension('value'), dataIdx));
  56331. var itemLayout = data && data.getItemLayout(dataIdx); // In the following cases label will be drawn
  56332. // 1. In map series and data value is NaN
  56333. // 2. In geo component
  56334. // 3. Region has no series legendSymbol, which will be add a showLabel flag in mapSymbolLayout
  56335. if (isGeo || isDataNaN || itemLayout && itemLayout.showLabel) {
  56336. var query = !isGeo ? dataIdx : regionName;
  56337. var labelFetcher = void 0; // Consider dataIdx not found.
  56338. if (!data || dataIdx >= 0) {
  56339. labelFetcher = mapOrGeoModel;
  56340. }
  56341. var specifiedTextOpt = labelXY ? {
  56342. normal: {
  56343. align: 'center',
  56344. verticalAlign: 'middle'
  56345. }
  56346. } : null; // Caveat: must be called after `setDefaultStateProxy(el);` called.
  56347. // because textContent will be assign with `el.stateProxy` inside.
  56348. setLabelStyle(el, getLabelStatesModels(regionModel), {
  56349. labelFetcher: labelFetcher,
  56350. labelDataIndex: query,
  56351. defaultText: regionName
  56352. }, specifiedTextOpt);
  56353. var textEl = el.getTextContent();
  56354. if (textEl) {
  56355. mapLabelRaw(textEl).ignore = textEl.ignore;
  56356. if (el.textConfig) {
  56357. if (labelXY) {
  56358. // Compute a relative offset based on the el bounding rect.
  56359. var rect = el.getBoundingRect().clone();
  56360. el.textConfig.position = [(labelXY[0] - rect.x) / rect.width * 100 + '%', (labelXY[1] - rect.y) / rect.height * 100 + '%'];
  56361. }
  56362. }
  56363. }
  56364. enableLayoutLayoutFeatures(el, dataIdx, null);
  56365. el.disableLabelAnimation = true;
  56366. } else {
  56367. el.removeTextContent();
  56368. el.removeTextConfig();
  56369. el.disableLabelAnimation = null;
  56370. }
  56371. }
  56372. function resetEventTriggerForRegion(viewBuildCtx, eventTrigger, regionName, regionModel, mapOrGeoModel, // Exist only if `viewBuildCtx.data` exists.
  56373. dataIdx) {
  56374. // setItemGraphicEl, setHoverStyle after all polygons and labels
  56375. // are added to the rigionGroup
  56376. if (viewBuildCtx.data) {
  56377. // FIXME: when series-map use a SVG map, and there are duplicated name specified
  56378. // on different SVG elements, after `data.setItemGraphicEl(...)`:
  56379. // (1) all of them will be mounted with `dataIndex`, `seriesIndex`, so that tooltip
  56380. // can be triggered only mouse hover. That's correct.
  56381. // (2) only the last element will be kept in `data`, so that if trigger tooltip
  56382. // by `dispatchAction`, only the last one can be found and triggered. That might be
  56383. // not correct. We will fix it in future if anyone demanding that.
  56384. viewBuildCtx.data.setItemGraphicEl(dataIdx, eventTrigger);
  56385. } // series-map will not trigger "geoselectchange" no matter it is
  56386. // based on a declared geo component. Becuause series-map will
  56387. // trigger "selectchange". If it trigger both the two events,
  56388. // If users call `chart.dispatchAction({type: 'toggleSelect'})`,
  56389. // it not easy to also fire event "geoselectchanged".
  56390. else {
  56391. // Package custom mouse event for geo component
  56392. getECData(eventTrigger).eventData = {
  56393. componentType: 'geo',
  56394. componentIndex: mapOrGeoModel.componentIndex,
  56395. geoIndex: mapOrGeoModel.componentIndex,
  56396. name: regionName,
  56397. region: regionModel && regionModel.option || {}
  56398. };
  56399. }
  56400. }
  56401. function resetTooltipForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel) {
  56402. if (!viewBuildCtx.data) {
  56403. setTooltipConfig({
  56404. el: el,
  56405. componentModel: mapOrGeoModel,
  56406. itemName: regionName,
  56407. // @ts-ignore FIXME:TS fix the "compatible with each other"?
  56408. itemTooltipOption: regionModel.get('tooltip')
  56409. });
  56410. }
  56411. }
  56412. function resetStateTriggerForRegion(viewBuildCtx, el, regionName, regionModel, mapOrGeoModel) {
  56413. // @ts-ignore FIXME:TS fix the "compatible with each other"?
  56414. el.highDownSilentOnTouch = !!mapOrGeoModel.get('selectedMode'); // @ts-ignore FIXME:TS fix the "compatible with each other"?
  56415. var emphasisModel = regionModel.getModel('emphasis');
  56416. var focus = emphasisModel.get('focus');
  56417. enableHoverEmphasis(el, focus, emphasisModel.get('blurScope'));
  56418. if (viewBuildCtx.isGeo) {
  56419. enableComponentHighDownFeatures(el, mapOrGeoModel, regionName);
  56420. }
  56421. return focus;
  56422. } // @ts-ignore FIXME:TS fix the "compatible with each other"?
  56423. /*
  56424. * Licensed to the Apache Software Foundation (ASF) under one
  56425. * or more contributor license agreements. See the NOTICE file
  56426. * distributed with this work for additional information
  56427. * regarding copyright ownership. The ASF licenses this file
  56428. * to you under the Apache License, Version 2.0 (the
  56429. * "License"); you may not use this file except in compliance
  56430. * with the License. You may obtain a copy of the License at
  56431. *
  56432. * http://www.apache.org/licenses/LICENSE-2.0
  56433. *
  56434. * Unless required by applicable law or agreed to in writing,
  56435. * software distributed under the License is distributed on an
  56436. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56437. * KIND, either express or implied. See the License for the
  56438. * specific language governing permissions and limitations
  56439. * under the License.
  56440. */
  56441. /**
  56442. * AUTO-GENERATED FILE. DO NOT MODIFY.
  56443. */
  56444. /*
  56445. * Licensed to the Apache Software Foundation (ASF) under one
  56446. * or more contributor license agreements. See the NOTICE file
  56447. * distributed with this work for additional information
  56448. * regarding copyright ownership. The ASF licenses this file
  56449. * to you under the Apache License, Version 2.0 (the
  56450. * "License"); you may not use this file except in compliance
  56451. * with the License. You may obtain a copy of the License at
  56452. *
  56453. * http://www.apache.org/licenses/LICENSE-2.0
  56454. *
  56455. * Unless required by applicable law or agreed to in writing,
  56456. * software distributed under the License is distributed on an
  56457. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56458. * KIND, either express or implied. See the License for the
  56459. * specific language governing permissions and limitations
  56460. * under the License.
  56461. */
  56462. var MapView =
  56463. /** @class */
  56464. function (_super) {
  56465. __extends(MapView, _super);
  56466. function MapView() {
  56467. var _this = _super !== null && _super.apply(this, arguments) || this;
  56468. _this.type = MapView.type;
  56469. return _this;
  56470. }
  56471. MapView.prototype.render = function (mapModel, ecModel, api, payload) {
  56472. // Not render if it is an toggleSelect action from self
  56473. if (payload && payload.type === 'mapToggleSelect' && payload.from === this.uid) {
  56474. return;
  56475. }
  56476. var group = this.group;
  56477. group.removeAll();
  56478. if (mapModel.getHostGeoModel()) {
  56479. return;
  56480. }
  56481. if (this._mapDraw && payload && payload.type === 'geoRoam') {
  56482. this._mapDraw.resetForLabelLayout();
  56483. } // Not update map if it is an roam action from self
  56484. if (!(payload && payload.type === 'geoRoam' && payload.componentType === 'series' && payload.seriesId === mapModel.id)) {
  56485. if (mapModel.needsDrawMap) {
  56486. var mapDraw = this._mapDraw || new MapDraw(api);
  56487. group.add(mapDraw.group);
  56488. mapDraw.draw(mapModel, ecModel, api, this, payload);
  56489. this._mapDraw = mapDraw;
  56490. } else {
  56491. // Remove drawed map
  56492. this._mapDraw && this._mapDraw.remove();
  56493. this._mapDraw = null;
  56494. }
  56495. } else {
  56496. var mapDraw = this._mapDraw;
  56497. mapDraw && group.add(mapDraw.group);
  56498. }
  56499. mapModel.get('showLegendSymbol') && ecModel.getComponent('legend') && this._renderSymbols(mapModel, ecModel, api);
  56500. };
  56501. MapView.prototype.remove = function () {
  56502. this._mapDraw && this._mapDraw.remove();
  56503. this._mapDraw = null;
  56504. this.group.removeAll();
  56505. };
  56506. MapView.prototype.dispose = function () {
  56507. this._mapDraw && this._mapDraw.remove();
  56508. this._mapDraw = null;
  56509. };
  56510. MapView.prototype._renderSymbols = function (mapModel, ecModel, api) {
  56511. var originalData = mapModel.originalData;
  56512. var group = this.group;
  56513. originalData.each(originalData.mapDimension('value'), function (value, originalDataIndex) {
  56514. if (isNaN(value)) {
  56515. return;
  56516. }
  56517. var layout = originalData.getItemLayout(originalDataIndex);
  56518. if (!layout || !layout.point) {
  56519. // Not exists in map
  56520. return;
  56521. }
  56522. var point = layout.point;
  56523. var offset = layout.offset;
  56524. var circle = new Circle({
  56525. style: {
  56526. // Because the special of map draw.
  56527. // Which needs statistic of multiple series and draw on one map.
  56528. // And each series also need a symbol with legend color
  56529. //
  56530. // Layout and visual are put one the different data
  56531. // TODO
  56532. fill: mapModel.getData().getVisual('style').fill
  56533. },
  56534. shape: {
  56535. cx: point[0] + offset * 9,
  56536. cy: point[1],
  56537. r: 3
  56538. },
  56539. silent: true,
  56540. // Do not overlap the first series, on which labels are displayed.
  56541. z2: 8 + (!offset ? Z2_EMPHASIS_LIFT + 1 : 0)
  56542. }); // Only the series that has the first value on the same region is in charge of rendering the label.
  56543. // But consider the case:
  56544. // series: [
  56545. // {id: 'X', type: 'map', map: 'm', {data: [{name: 'A', value: 11}, {name: 'B', {value: 22}]},
  56546. // {id: 'Y', type: 'map', map: 'm', {data: [{name: 'A', value: 21}, {name: 'C', {value: 33}]}
  56547. // ]
  56548. // The offset `0` of item `A` is at series `X`, but of item `C` is at series `Y`.
  56549. // For backward compatibility, we follow the rule that render label `A` by the
  56550. // settings on series `X` but render label `C` by the settings on series `Y`.
  56551. if (!offset) {
  56552. var fullData = mapModel.mainSeries.getData();
  56553. var name_1 = originalData.getName(originalDataIndex);
  56554. var fullIndex_1 = fullData.indexOfName(name_1);
  56555. var itemModel = originalData.getItemModel(originalDataIndex);
  56556. var labelModel = itemModel.getModel('label');
  56557. var regionGroup = fullData.getItemGraphicEl(fullIndex_1); // `getFormattedLabel` needs to use `getData` inside. Here
  56558. // `mapModel.getData()` is shallow cloned from `mainSeries.getData()`.
  56559. // FIXME
  56560. // If this is not the `mainSeries`, the item model (like label formatter)
  56561. // set on original data item will never get. But it has been working
  56562. // like that from the begining, and this scenario is rarely encountered.
  56563. // So it won't be fixed until have to.
  56564. setLabelStyle(circle, getLabelStatesModels(itemModel), {
  56565. labelFetcher: {
  56566. getFormattedLabel: function (idx, state) {
  56567. return mapModel.getFormattedLabel(fullIndex_1, state);
  56568. }
  56569. }
  56570. });
  56571. circle.disableLabelAnimation = true;
  56572. if (!labelModel.get('position')) {
  56573. circle.setTextConfig({
  56574. position: 'bottom'
  56575. });
  56576. }
  56577. regionGroup.onHoverStateChange = function (toState) {
  56578. circle.useState(toState);
  56579. };
  56580. }
  56581. group.add(circle);
  56582. });
  56583. };
  56584. MapView.type = 'map';
  56585. return MapView;
  56586. }(ChartView);
  56587. /*
  56588. * Licensed to the Apache Software Foundation (ASF) under one
  56589. * or more contributor license agreements. See the NOTICE file
  56590. * distributed with this work for additional information
  56591. * regarding copyright ownership. The ASF licenses this file
  56592. * to you under the Apache License, Version 2.0 (the
  56593. * "License"); you may not use this file except in compliance
  56594. * with the License. You may obtain a copy of the License at
  56595. *
  56596. * http://www.apache.org/licenses/LICENSE-2.0
  56597. *
  56598. * Unless required by applicable law or agreed to in writing,
  56599. * software distributed under the License is distributed on an
  56600. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56601. * KIND, either express or implied. See the License for the
  56602. * specific language governing permissions and limitations
  56603. * under the License.
  56604. */
  56605. /**
  56606. * AUTO-GENERATED FILE. DO NOT MODIFY.
  56607. */
  56608. /*
  56609. * Licensed to the Apache Software Foundation (ASF) under one
  56610. * or more contributor license agreements. See the NOTICE file
  56611. * distributed with this work for additional information
  56612. * regarding copyright ownership. The ASF licenses this file
  56613. * to you under the Apache License, Version 2.0 (the
  56614. * "License"); you may not use this file except in compliance
  56615. * with the License. You may obtain a copy of the License at
  56616. *
  56617. * http://www.apache.org/licenses/LICENSE-2.0
  56618. *
  56619. * Unless required by applicable law or agreed to in writing,
  56620. * software distributed under the License is distributed on an
  56621. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56622. * KIND, either express or implied. See the License for the
  56623. * specific language governing permissions and limitations
  56624. * under the License.
  56625. */
  56626. var MapSeries =
  56627. /** @class */
  56628. function (_super) {
  56629. __extends(MapSeries, _super);
  56630. function MapSeries() {
  56631. var _this = _super !== null && _super.apply(this, arguments) || this;
  56632. _this.type = MapSeries.type; // Only first map series of same mapType will drawMap.
  56633. _this.needsDrawMap = false; // Group of all map series with same mapType
  56634. _this.seriesGroup = [];
  56635. _this.getTooltipPosition = function (dataIndex) {
  56636. if (dataIndex != null) {
  56637. var name_1 = this.getData().getName(dataIndex);
  56638. var geo = this.coordinateSystem;
  56639. var region = geo.getRegion(name_1);
  56640. return region && geo.dataToPoint(region.getCenter());
  56641. }
  56642. };
  56643. return _this;
  56644. }
  56645. MapSeries.prototype.getInitialData = function (option) {
  56646. var data = createListSimply(this, {
  56647. coordDimensions: ['value'],
  56648. encodeDefaulter: curry(makeSeriesEncodeForNameBased, this)
  56649. });
  56650. var dataNameMap = createHashMap();
  56651. var toAppendNames = [];
  56652. for (var i = 0, len = data.count(); i < len; i++) {
  56653. var name_2 = data.getName(i);
  56654. dataNameMap.set(name_2, true);
  56655. }
  56656. var geoSource = geoSourceManager.load(this.getMapType(), this.option.nameMap, this.option.nameProperty);
  56657. each$1(geoSource.regions, function (region) {
  56658. var name = region.name;
  56659. if (!dataNameMap.get(name)) {
  56660. toAppendNames.push(name);
  56661. }
  56662. }); // Complete data with missing regions. The consequent processes (like visual
  56663. // map and render) can not be performed without a "full data". For example,
  56664. // find `dataIndex` by name.
  56665. data.appendValues([], toAppendNames);
  56666. return data;
  56667. };
  56668. /**
  56669. * If no host geo model, return null, which means using a
  56670. * inner exclusive geo model.
  56671. */
  56672. MapSeries.prototype.getHostGeoModel = function () {
  56673. var geoIndex = this.option.geoIndex;
  56674. return geoIndex != null ? this.ecModel.getComponent('geo', geoIndex) : null;
  56675. };
  56676. MapSeries.prototype.getMapType = function () {
  56677. return (this.getHostGeoModel() || this).option.map;
  56678. }; // _fillOption(option, mapName) {
  56679. // Shallow clone
  56680. // option = zrUtil.extend({}, option);
  56681. // option.data = geoCreator.getFilledRegions(option.data, mapName, option.nameMap);
  56682. // return option;
  56683. // }
  56684. MapSeries.prototype.getRawValue = function (dataIndex) {
  56685. // Use value stored in data instead because it is calculated from multiple series
  56686. // FIXME Provide all value of multiple series ?
  56687. var data = this.getData();
  56688. return data.get(data.mapDimension('value'), dataIndex);
  56689. };
  56690. /**
  56691. * Get model of region
  56692. */
  56693. MapSeries.prototype.getRegionModel = function (regionName) {
  56694. var data = this.getData();
  56695. return data.getItemModel(data.indexOfName(regionName));
  56696. };
  56697. /**
  56698. * Map tooltip formatter
  56699. */
  56700. MapSeries.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  56701. // FIXME orignalData and data is a bit confusing
  56702. var data = this.getData();
  56703. var value = this.getRawValue(dataIndex);
  56704. var name = data.getName(dataIndex);
  56705. var seriesGroup = this.seriesGroup;
  56706. var seriesNames = [];
  56707. for (var i = 0; i < seriesGroup.length; i++) {
  56708. var otherIndex = seriesGroup[i].originalData.indexOfName(name);
  56709. var valueDim = data.mapDimension('value');
  56710. if (!isNaN(seriesGroup[i].originalData.get(valueDim, otherIndex))) {
  56711. seriesNames.push(seriesGroup[i].name);
  56712. }
  56713. }
  56714. return createTooltipMarkup('section', {
  56715. header: seriesNames.join(', '),
  56716. noHeader: !seriesNames.length,
  56717. blocks: [createTooltipMarkup('nameValue', {
  56718. name: name,
  56719. value: value
  56720. })]
  56721. });
  56722. };
  56723. MapSeries.prototype.setZoom = function (zoom) {
  56724. this.option.zoom = zoom;
  56725. };
  56726. MapSeries.prototype.setCenter = function (center) {
  56727. this.option.center = center;
  56728. };
  56729. MapSeries.prototype.getLegendIcon = function (opt) {
  56730. var symbolType = opt.symbolType || 'roundRect';
  56731. var symbol = createSymbol(symbolType, 0, 0, opt.itemWidth, opt.itemHeight, opt.itemStyle.fill, opt.symbolKeepAspect);
  56732. symbol.setStyle(opt.itemStyle); // Map do not use itemStyle.borderWidth as border width
  56733. symbol.style.stroke = 'none';
  56734. if (symbolType.indexOf('empty') > -1) {
  56735. symbol.style.stroke = symbol.style.fill;
  56736. symbol.style.fill = '#fff';
  56737. symbol.style.lineWidth = 2;
  56738. }
  56739. return symbol;
  56740. };
  56741. MapSeries.type = 'series.map';
  56742. MapSeries.dependencies = ['geo'];
  56743. MapSeries.layoutMode = 'box';
  56744. MapSeries.defaultOption = {
  56745. // 一级层叠
  56746. zlevel: 0,
  56747. // 二级层叠
  56748. z: 2,
  56749. coordinateSystem: 'geo',
  56750. // map should be explicitly specified since ec3.
  56751. map: '',
  56752. // If `geoIndex` is not specified, a exclusive geo will be
  56753. // created. Otherwise use the specified geo component, and
  56754. // `map` and `mapType` are ignored.
  56755. // geoIndex: 0,
  56756. // 'center' | 'left' | 'right' | 'x%' | {number}
  56757. left: 'center',
  56758. // 'center' | 'top' | 'bottom' | 'x%' | {number}
  56759. top: 'center',
  56760. // right
  56761. // bottom
  56762. // width:
  56763. // height
  56764. // Aspect is width / height. Inited to be geoJson bbox aspect
  56765. // This parameter is used for scale this aspect
  56766. // Default value:
  56767. // for geoSVG source: 1,
  56768. // for geoJSON source: 0.75.
  56769. aspectScale: null,
  56770. ///// Layout with center and size
  56771. // If you wan't to put map in a fixed size box with right aspect ratio
  56772. // This two properties may more conveninet
  56773. // layoutCenter: [50%, 50%]
  56774. // layoutSize: 100
  56775. showLegendSymbol: true,
  56776. // Define left-top, right-bottom coords to control view
  56777. // For example, [ [180, 90], [-180, -90] ],
  56778. // higher priority than center and zoom
  56779. boundingCoords: null,
  56780. // Default on center of map
  56781. center: null,
  56782. zoom: 1,
  56783. scaleLimit: null,
  56784. selectedMode: true,
  56785. label: {
  56786. show: false,
  56787. color: '#000'
  56788. },
  56789. // scaleLimit: null,
  56790. itemStyle: {
  56791. borderWidth: 0.5,
  56792. borderColor: '#444',
  56793. areaColor: '#eee'
  56794. },
  56795. emphasis: {
  56796. label: {
  56797. show: true,
  56798. color: 'rgb(100,0,0)'
  56799. },
  56800. itemStyle: {
  56801. areaColor: 'rgba(255,215,0,0.8)'
  56802. }
  56803. },
  56804. select: {
  56805. label: {
  56806. show: true,
  56807. color: 'rgb(100,0,0)'
  56808. },
  56809. itemStyle: {
  56810. color: 'rgba(255,215,0,0.8)'
  56811. }
  56812. },
  56813. nameProperty: 'name'
  56814. };
  56815. return MapSeries;
  56816. }(SeriesModel);
  56817. /*
  56818. * Licensed to the Apache Software Foundation (ASF) under one
  56819. * or more contributor license agreements. See the NOTICE file
  56820. * distributed with this work for additional information
  56821. * regarding copyright ownership. The ASF licenses this file
  56822. * to you under the Apache License, Version 2.0 (the
  56823. * "License"); you may not use this file except in compliance
  56824. * with the License. You may obtain a copy of the License at
  56825. *
  56826. * http://www.apache.org/licenses/LICENSE-2.0
  56827. *
  56828. * Unless required by applicable law or agreed to in writing,
  56829. * software distributed under the License is distributed on an
  56830. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56831. * KIND, either express or implied. See the License for the
  56832. * specific language governing permissions and limitations
  56833. * under the License.
  56834. */
  56835. /**
  56836. * AUTO-GENERATED FILE. DO NOT MODIFY.
  56837. */
  56838. /*
  56839. * Licensed to the Apache Software Foundation (ASF) under one
  56840. * or more contributor license agreements. See the NOTICE file
  56841. * distributed with this work for additional information
  56842. * regarding copyright ownership. The ASF licenses this file
  56843. * to you under the Apache License, Version 2.0 (the
  56844. * "License"); you may not use this file except in compliance
  56845. * with the License. You may obtain a copy of the License at
  56846. *
  56847. * http://www.apache.org/licenses/LICENSE-2.0
  56848. *
  56849. * Unless required by applicable law or agreed to in writing,
  56850. * software distributed under the License is distributed on an
  56851. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56852. * KIND, either express or implied. See the License for the
  56853. * specific language governing permissions and limitations
  56854. * under the License.
  56855. */
  56856. function dataStatistics(datas, statisticType) {
  56857. var dataNameMap = {};
  56858. each$1(datas, function (data) {
  56859. data.each(data.mapDimension('value'), function (value, idx) {
  56860. // Add prefix to avoid conflict with Object.prototype.
  56861. var mapKey = 'ec-' + data.getName(idx);
  56862. dataNameMap[mapKey] = dataNameMap[mapKey] || [];
  56863. if (!isNaN(value)) {
  56864. dataNameMap[mapKey].push(value);
  56865. }
  56866. });
  56867. });
  56868. return datas[0].map(datas[0].mapDimension('value'), function (value, idx) {
  56869. var mapKey = 'ec-' + datas[0].getName(idx);
  56870. var sum = 0;
  56871. var min = Infinity;
  56872. var max = -Infinity;
  56873. var len = dataNameMap[mapKey].length;
  56874. for (var i = 0; i < len; i++) {
  56875. min = Math.min(min, dataNameMap[mapKey][i]);
  56876. max = Math.max(max, dataNameMap[mapKey][i]);
  56877. sum += dataNameMap[mapKey][i];
  56878. }
  56879. var result;
  56880. if (statisticType === 'min') {
  56881. result = min;
  56882. } else if (statisticType === 'max') {
  56883. result = max;
  56884. } else if (statisticType === 'average') {
  56885. result = sum / len;
  56886. } else {
  56887. result = sum;
  56888. }
  56889. return len === 0 ? NaN : result;
  56890. });
  56891. }
  56892. function mapDataStatistic(ecModel) {
  56893. var seriesGroups = {};
  56894. ecModel.eachSeriesByType('map', function (seriesModel) {
  56895. var hostGeoModel = seriesModel.getHostGeoModel();
  56896. var key = hostGeoModel ? 'o' + hostGeoModel.id : 'i' + seriesModel.getMapType();
  56897. (seriesGroups[key] = seriesGroups[key] || []).push(seriesModel);
  56898. });
  56899. each$1(seriesGroups, function (seriesList, key) {
  56900. var data = dataStatistics(map(seriesList, function (seriesModel) {
  56901. return seriesModel.getData();
  56902. }), seriesList[0].get('mapValueCalculation'));
  56903. for (var i = 0; i < seriesList.length; i++) {
  56904. seriesList[i].originalData = seriesList[i].getData();
  56905. } // FIXME Put where?
  56906. for (var i = 0; i < seriesList.length; i++) {
  56907. seriesList[i].seriesGroup = seriesList;
  56908. seriesList[i].needsDrawMap = i === 0 && !seriesList[i].getHostGeoModel();
  56909. seriesList[i].setData(data.cloneShallow());
  56910. seriesList[i].mainSeries = seriesList[0];
  56911. }
  56912. });
  56913. }
  56914. /*
  56915. * Licensed to the Apache Software Foundation (ASF) under one
  56916. * or more contributor license agreements. See the NOTICE file
  56917. * distributed with this work for additional information
  56918. * regarding copyright ownership. The ASF licenses this file
  56919. * to you under the Apache License, Version 2.0 (the
  56920. * "License"); you may not use this file except in compliance
  56921. * with the License. You may obtain a copy of the License at
  56922. *
  56923. * http://www.apache.org/licenses/LICENSE-2.0
  56924. *
  56925. * Unless required by applicable law or agreed to in writing,
  56926. * software distributed under the License is distributed on an
  56927. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56928. * KIND, either express or implied. See the License for the
  56929. * specific language governing permissions and limitations
  56930. * under the License.
  56931. */
  56932. /**
  56933. * AUTO-GENERATED FILE. DO NOT MODIFY.
  56934. */
  56935. /*
  56936. * Licensed to the Apache Software Foundation (ASF) under one
  56937. * or more contributor license agreements. See the NOTICE file
  56938. * distributed with this work for additional information
  56939. * regarding copyright ownership. The ASF licenses this file
  56940. * to you under the Apache License, Version 2.0 (the
  56941. * "License"); you may not use this file except in compliance
  56942. * with the License. You may obtain a copy of the License at
  56943. *
  56944. * http://www.apache.org/licenses/LICENSE-2.0
  56945. *
  56946. * Unless required by applicable law or agreed to in writing,
  56947. * software distributed under the License is distributed on an
  56948. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  56949. * KIND, either express or implied. See the License for the
  56950. * specific language governing permissions and limitations
  56951. * under the License.
  56952. */
  56953. function mapSymbolLayout(ecModel) {
  56954. var processedMapType = {};
  56955. ecModel.eachSeriesByType('map', function (mapSeries) {
  56956. var mapType = mapSeries.getMapType();
  56957. if (mapSeries.getHostGeoModel() || processedMapType[mapType]) {
  56958. return;
  56959. }
  56960. var mapSymbolOffsets = {};
  56961. each$1(mapSeries.seriesGroup, function (subMapSeries) {
  56962. var geo = subMapSeries.coordinateSystem;
  56963. var data = subMapSeries.originalData;
  56964. if (subMapSeries.get('showLegendSymbol') && ecModel.getComponent('legend')) {
  56965. data.each(data.mapDimension('value'), function (value, idx) {
  56966. var name = data.getName(idx);
  56967. var region = geo.getRegion(name); // If input series.data is [11, 22, '-'/null/undefined, 44],
  56968. // it will be filled with NaN: [11, 22, NaN, 44] and NaN will
  56969. // not be drawn. So here must validate if value is NaN.
  56970. if (!region || isNaN(value)) {
  56971. return;
  56972. }
  56973. var offset = mapSymbolOffsets[name] || 0;
  56974. var point = geo.dataToPoint(region.getCenter());
  56975. mapSymbolOffsets[name] = offset + 1;
  56976. data.setItemLayout(idx, {
  56977. point: point,
  56978. offset: offset
  56979. });
  56980. });
  56981. }
  56982. }); // Show label of those region not has legendSymbol(which is offset 0)
  56983. var data = mapSeries.getData();
  56984. data.each(function (idx) {
  56985. var name = data.getName(idx);
  56986. var layout = data.getItemLayout(idx) || {};
  56987. layout.showLabel = !mapSymbolOffsets[name];
  56988. data.setItemLayout(idx, layout);
  56989. });
  56990. processedMapType[mapType] = true;
  56991. });
  56992. }
  56993. /*
  56994. * Licensed to the Apache Software Foundation (ASF) under one
  56995. * or more contributor license agreements. See the NOTICE file
  56996. * distributed with this work for additional information
  56997. * regarding copyright ownership. The ASF licenses this file
  56998. * to you under the Apache License, Version 2.0 (the
  56999. * "License"); you may not use this file except in compliance
  57000. * with the License. You may obtain a copy of the License at
  57001. *
  57002. * http://www.apache.org/licenses/LICENSE-2.0
  57003. *
  57004. * Unless required by applicable law or agreed to in writing,
  57005. * software distributed under the License is distributed on an
  57006. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57007. * KIND, either express or implied. See the License for the
  57008. * specific language governing permissions and limitations
  57009. * under the License.
  57010. */
  57011. /**
  57012. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57013. */
  57014. /*
  57015. * Licensed to the Apache Software Foundation (ASF) under one
  57016. * or more contributor license agreements. See the NOTICE file
  57017. * distributed with this work for additional information
  57018. * regarding copyright ownership. The ASF licenses this file
  57019. * to you under the Apache License, Version 2.0 (the
  57020. * "License"); you may not use this file except in compliance
  57021. * with the License. You may obtain a copy of the License at
  57022. *
  57023. * http://www.apache.org/licenses/LICENSE-2.0
  57024. *
  57025. * Unless required by applicable law or agreed to in writing,
  57026. * software distributed under the License is distributed on an
  57027. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57028. * KIND, either express or implied. See the License for the
  57029. * specific language governing permissions and limitations
  57030. * under the License.
  57031. */
  57032. var GEO_DEFAULT_PARAMS = {
  57033. 'geoJSON': {
  57034. aspectScale: 0.75,
  57035. invertLongitute: true
  57036. },
  57037. 'geoSVG': {
  57038. aspectScale: 1,
  57039. invertLongitute: false
  57040. }
  57041. };
  57042. var Geo =
  57043. /** @class */
  57044. function (_super) {
  57045. __extends(Geo, _super);
  57046. function Geo(name, map$$1, opt) {
  57047. var _this = _super.call(this, name) || this;
  57048. _this.dimensions = ['lng', 'lat'];
  57049. _this.type = 'geo'; // Only store specified name coord via `addGeoCoord`.
  57050. _this._nameCoordMap = createHashMap();
  57051. _this.map = map$$1;
  57052. var source = geoSourceManager.load(map$$1, opt.nameMap, opt.nameProperty);
  57053. var resource = geoSourceManager.getGeoResource(map$$1);
  57054. _this.resourceType = resource ? resource.type : null;
  57055. var defaultParmas = GEO_DEFAULT_PARAMS[resource.type];
  57056. _this._regionsMap = source.regionsMap;
  57057. _this._invertLongitute = defaultParmas.invertLongitute;
  57058. _this.regions = source.regions;
  57059. _this.aspectScale = retrieve2(opt.aspectScale, defaultParmas.aspectScale);
  57060. var boundingRect = source.boundingRect;
  57061. _this.setBoundingRect(boundingRect.x, boundingRect.y, boundingRect.width, boundingRect.height);
  57062. return _this;
  57063. }
  57064. /**
  57065. * Whether contain the given [lng, lat] coord.
  57066. */
  57067. // Never used yet.
  57068. // containCoord(coord: number[]) {
  57069. // const regions = this.regions;
  57070. // for (let i = 0; i < regions.length; i++) {
  57071. // const region = regions[i];
  57072. // if (region.type === 'geoJSON' && (region as GeoJSONRegion).contain(coord)) {
  57073. // return true;
  57074. // }
  57075. // }
  57076. // return false;
  57077. // }
  57078. Geo.prototype._transformTo = function (x, y, width, height) {
  57079. var rect = this.getBoundingRect();
  57080. var invertLongitute = this._invertLongitute;
  57081. rect = rect.clone();
  57082. if (invertLongitute) {
  57083. // Longitute is inverted
  57084. rect.y = -rect.y - rect.height;
  57085. }
  57086. var rawTransformable = this._rawTransformable;
  57087. rawTransformable.transform = rect.calculateTransform(new BoundingRect(x, y, width, height));
  57088. var rawParent = rawTransformable.parent;
  57089. rawTransformable.parent = null;
  57090. rawTransformable.decomposeTransform();
  57091. rawTransformable.parent = rawParent;
  57092. if (invertLongitute) {
  57093. rawTransformable.scaleY = -rawTransformable.scaleY;
  57094. }
  57095. this._updateTransform();
  57096. };
  57097. Geo.prototype.getRegion = function (name) {
  57098. return this._regionsMap.get(name);
  57099. };
  57100. Geo.prototype.getRegionByCoord = function (coord) {
  57101. var regions = this.regions;
  57102. for (var i = 0; i < regions.length; i++) {
  57103. var region = regions[i];
  57104. if (region.type === 'geoJSON' && region.contain(coord)) {
  57105. return regions[i];
  57106. }
  57107. }
  57108. };
  57109. /**
  57110. * Add geoCoord for indexing by name
  57111. */
  57112. Geo.prototype.addGeoCoord = function (name, geoCoord) {
  57113. this._nameCoordMap.set(name, geoCoord);
  57114. };
  57115. /**
  57116. * Get geoCoord by name
  57117. */
  57118. Geo.prototype.getGeoCoord = function (name) {
  57119. var region = this._regionsMap.get(name); // calcualte center only on demand.
  57120. return this._nameCoordMap.get(name) || region && region.getCenter();
  57121. };
  57122. Geo.prototype.dataToPoint = function (data, noRoam, out) {
  57123. if (typeof data === 'string') {
  57124. // Map area name to geoCoord
  57125. data = this.getGeoCoord(data);
  57126. }
  57127. if (data) {
  57128. return View.prototype.dataToPoint.call(this, data, noRoam, out);
  57129. }
  57130. };
  57131. Geo.prototype.convertToPixel = function (ecModel, finder, value) {
  57132. var coordSys = getCoordSys$1(finder);
  57133. return coordSys === this ? coordSys.dataToPoint(value) : null;
  57134. };
  57135. Geo.prototype.convertFromPixel = function (ecModel, finder, pixel) {
  57136. var coordSys = getCoordSys$1(finder);
  57137. return coordSys === this ? coordSys.pointToData(pixel) : null;
  57138. };
  57139. return Geo;
  57140. }(View);
  57141. mixin(Geo, View);
  57142. function getCoordSys$1(finder) {
  57143. var geoModel = finder.geoModel;
  57144. var seriesModel = finder.seriesModel;
  57145. return geoModel ? geoModel.coordinateSystem : seriesModel ? seriesModel.coordinateSystem // For map series.
  57146. || (seriesModel.getReferringComponents('geo', SINGLE_REFERRING).models[0] || {}).coordinateSystem : null;
  57147. }
  57148. /*
  57149. * Licensed to the Apache Software Foundation (ASF) under one
  57150. * or more contributor license agreements. See the NOTICE file
  57151. * distributed with this work for additional information
  57152. * regarding copyright ownership. The ASF licenses this file
  57153. * to you under the Apache License, Version 2.0 (the
  57154. * "License"); you may not use this file except in compliance
  57155. * with the License. You may obtain a copy of the License at
  57156. *
  57157. * http://www.apache.org/licenses/LICENSE-2.0
  57158. *
  57159. * Unless required by applicable law or agreed to in writing,
  57160. * software distributed under the License is distributed on an
  57161. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57162. * KIND, either express or implied. See the License for the
  57163. * specific language governing permissions and limitations
  57164. * under the License.
  57165. */
  57166. /**
  57167. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57168. */
  57169. /*
  57170. * Licensed to the Apache Software Foundation (ASF) under one
  57171. * or more contributor license agreements. See the NOTICE file
  57172. * distributed with this work for additional information
  57173. * regarding copyright ownership. The ASF licenses this file
  57174. * to you under the Apache License, Version 2.0 (the
  57175. * "License"); you may not use this file except in compliance
  57176. * with the License. You may obtain a copy of the License at
  57177. *
  57178. * http://www.apache.org/licenses/LICENSE-2.0
  57179. *
  57180. * Unless required by applicable law or agreed to in writing,
  57181. * software distributed under the License is distributed on an
  57182. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57183. * KIND, either express or implied. See the License for the
  57184. * specific language governing permissions and limitations
  57185. * under the License.
  57186. */
  57187. /**
  57188. * Resize method bound to the geo
  57189. */
  57190. function resizeGeo(geoModel, api) {
  57191. var boundingCoords = geoModel.get('boundingCoords');
  57192. if (boundingCoords != null) {
  57193. var leftTop = boundingCoords[0];
  57194. var rightBottom = boundingCoords[1];
  57195. if (isNaN(leftTop[0]) || isNaN(leftTop[1]) || isNaN(rightBottom[0]) || isNaN(rightBottom[1])) {
  57196. {
  57197. console.error('Invalid boundingCoords');
  57198. }
  57199. } else {
  57200. this.setBoundingRect(leftTop[0], leftTop[1], rightBottom[0] - leftTop[0], rightBottom[1] - leftTop[1]);
  57201. }
  57202. }
  57203. var rect = this.getBoundingRect();
  57204. var centerOption = geoModel.get('layoutCenter');
  57205. var sizeOption = geoModel.get('layoutSize');
  57206. var viewWidth = api.getWidth();
  57207. var viewHeight = api.getHeight();
  57208. var aspect = rect.width / rect.height * this.aspectScale;
  57209. var useCenterAndSize = false;
  57210. var center;
  57211. var size;
  57212. if (centerOption && sizeOption) {
  57213. center = [parsePercent$1(centerOption[0], viewWidth), parsePercent$1(centerOption[1], viewHeight)];
  57214. size = parsePercent$1(sizeOption, Math.min(viewWidth, viewHeight));
  57215. if (!isNaN(center[0]) && !isNaN(center[1]) && !isNaN(size)) {
  57216. useCenterAndSize = true;
  57217. } else {
  57218. {
  57219. console.warn('Given layoutCenter or layoutSize data are invalid. Use left/top/width/height instead.');
  57220. }
  57221. }
  57222. }
  57223. var viewRect;
  57224. if (useCenterAndSize) {
  57225. viewRect = {};
  57226. if (aspect > 1) {
  57227. // Width is same with size
  57228. viewRect.width = size;
  57229. viewRect.height = size / aspect;
  57230. } else {
  57231. viewRect.height = size;
  57232. viewRect.width = size * aspect;
  57233. }
  57234. viewRect.y = center[1] - viewRect.height / 2;
  57235. viewRect.x = center[0] - viewRect.width / 2;
  57236. } else {
  57237. // Use left/top/width/height
  57238. var boxLayoutOption = geoModel.getBoxLayoutParams();
  57239. boxLayoutOption.aspect = aspect;
  57240. viewRect = getLayoutRect(boxLayoutOption, {
  57241. width: viewWidth,
  57242. height: viewHeight
  57243. });
  57244. }
  57245. this.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
  57246. this.setCenter(geoModel.get('center'));
  57247. this.setZoom(geoModel.get('zoom'));
  57248. } // Back compat for ECharts2, where the coord map is set on map series:
  57249. // {type: 'map', geoCoord: {'cityA': [116.46,39.92], 'cityA': [119.12,24.61]}},
  57250. function setGeoCoords(geo, model) {
  57251. each$1(model.get('geoCoord'), function (geoCoord, name) {
  57252. geo.addGeoCoord(name, geoCoord);
  57253. });
  57254. }
  57255. var GeoCreator =
  57256. /** @class */
  57257. function () {
  57258. function GeoCreator() {
  57259. // For deciding which dimensions to use when creating list data
  57260. this.dimensions = Geo.prototype.dimensions;
  57261. }
  57262. GeoCreator.prototype.create = function (ecModel, api) {
  57263. var geoList = []; // FIXME Create each time may be slow
  57264. ecModel.eachComponent('geo', function (geoModel, idx) {
  57265. var name = geoModel.get('map');
  57266. var geo = new Geo(name + idx, name, {
  57267. nameMap: geoModel.get('nameMap'),
  57268. nameProperty: geoModel.get('nameProperty'),
  57269. aspectScale: geoModel.get('aspectScale')
  57270. });
  57271. geo.zoomLimit = geoModel.get('scaleLimit');
  57272. geoList.push(geo); // setGeoCoords(geo, geoModel);
  57273. geoModel.coordinateSystem = geo;
  57274. geo.model = geoModel; // Inject resize method
  57275. geo.resize = resizeGeo;
  57276. geo.resize(geoModel, api);
  57277. });
  57278. ecModel.eachSeries(function (seriesModel) {
  57279. var coordSys = seriesModel.get('coordinateSystem');
  57280. if (coordSys === 'geo') {
  57281. var geoIndex = seriesModel.get('geoIndex') || 0;
  57282. seriesModel.coordinateSystem = geoList[geoIndex];
  57283. }
  57284. }); // If has map series
  57285. var mapModelGroupBySeries = {};
  57286. ecModel.eachSeriesByType('map', function (seriesModel) {
  57287. if (!seriesModel.getHostGeoModel()) {
  57288. var mapType = seriesModel.getMapType();
  57289. mapModelGroupBySeries[mapType] = mapModelGroupBySeries[mapType] || [];
  57290. mapModelGroupBySeries[mapType].push(seriesModel);
  57291. }
  57292. });
  57293. each$1(mapModelGroupBySeries, function (mapSeries, mapType) {
  57294. var nameMapList = map(mapSeries, function (singleMapSeries) {
  57295. return singleMapSeries.get('nameMap');
  57296. });
  57297. var geo = new Geo(mapType, mapType, {
  57298. nameMap: mergeAll(nameMapList),
  57299. nameProperty: mapSeries[0].get('nameProperty'),
  57300. aspectScale: mapSeries[0].get('aspectScale')
  57301. });
  57302. geo.zoomLimit = retrieve.apply(null, map(mapSeries, function (singleMapSeries) {
  57303. return singleMapSeries.get('scaleLimit');
  57304. }));
  57305. geoList.push(geo); // Inject resize method
  57306. geo.resize = resizeGeo;
  57307. geo.resize(mapSeries[0], api);
  57308. each$1(mapSeries, function (singleMapSeries) {
  57309. singleMapSeries.coordinateSystem = geo;
  57310. setGeoCoords(geo, singleMapSeries);
  57311. });
  57312. });
  57313. return geoList;
  57314. };
  57315. /**
  57316. * Fill given regions array
  57317. */
  57318. GeoCreator.prototype.getFilledRegions = function (originRegionArr, mapName, nameMap, nameProperty) {
  57319. // Not use the original
  57320. var regionsArr = (originRegionArr || []).slice();
  57321. var dataNameMap = createHashMap();
  57322. for (var i = 0; i < regionsArr.length; i++) {
  57323. dataNameMap.set(regionsArr[i].name, regionsArr[i]);
  57324. }
  57325. var source = geoSourceManager.load(mapName, nameMap, nameProperty);
  57326. each$1(source.regions, function (region) {
  57327. var name = region.name;
  57328. !dataNameMap.get(name) && regionsArr.push({
  57329. name: name
  57330. });
  57331. });
  57332. return regionsArr;
  57333. };
  57334. return GeoCreator;
  57335. }();
  57336. var geoCreator = new GeoCreator();
  57337. /*
  57338. * Licensed to the Apache Software Foundation (ASF) under one
  57339. * or more contributor license agreements. See the NOTICE file
  57340. * distributed with this work for additional information
  57341. * regarding copyright ownership. The ASF licenses this file
  57342. * to you under the Apache License, Version 2.0 (the
  57343. * "License"); you may not use this file except in compliance
  57344. * with the License. You may obtain a copy of the License at
  57345. *
  57346. * http://www.apache.org/licenses/LICENSE-2.0
  57347. *
  57348. * Unless required by applicable law or agreed to in writing,
  57349. * software distributed under the License is distributed on an
  57350. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57351. * KIND, either express or implied. See the License for the
  57352. * specific language governing permissions and limitations
  57353. * under the License.
  57354. */
  57355. /**
  57356. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57357. */
  57358. /*
  57359. * Licensed to the Apache Software Foundation (ASF) under one
  57360. * or more contributor license agreements. See the NOTICE file
  57361. * distributed with this work for additional information
  57362. * regarding copyright ownership. The ASF licenses this file
  57363. * to you under the Apache License, Version 2.0 (the
  57364. * "License"); you may not use this file except in compliance
  57365. * with the License. You may obtain a copy of the License at
  57366. *
  57367. * http://www.apache.org/licenses/LICENSE-2.0
  57368. *
  57369. * Unless required by applicable law or agreed to in writing,
  57370. * software distributed under the License is distributed on an
  57371. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57372. * KIND, either express or implied. See the License for the
  57373. * specific language governing permissions and limitations
  57374. * under the License.
  57375. */
  57376. var GeoModel =
  57377. /** @class */
  57378. function (_super) {
  57379. __extends(GeoModel, _super);
  57380. function GeoModel() {
  57381. var _this = _super !== null && _super.apply(this, arguments) || this;
  57382. _this.type = GeoModel.type;
  57383. return _this;
  57384. }
  57385. GeoModel.prototype.init = function (option, parentModel, ecModel) {
  57386. var source = geoSourceManager.getGeoResource(option.map);
  57387. if (source && source.type === 'geoJSON') {
  57388. var itemStyle = option.itemStyle = option.itemStyle || {};
  57389. if (!('color' in itemStyle)) {
  57390. itemStyle.color = '#eee';
  57391. }
  57392. }
  57393. this.mergeDefaultAndTheme(option, ecModel); // Default label emphasis `show`
  57394. defaultEmphasis(option, 'label', ['show']);
  57395. };
  57396. GeoModel.prototype.optionUpdated = function () {
  57397. var _this = this;
  57398. var option = this.option;
  57399. option.regions = geoCreator.getFilledRegions(option.regions, option.map, option.nameMap, option.nameProperty);
  57400. var selectedMap = {};
  57401. this._optionModelMap = reduce(option.regions || [], function (optionModelMap, regionOpt) {
  57402. var regionName = regionOpt.name;
  57403. if (regionName) {
  57404. optionModelMap.set(regionName, new Model(regionOpt, _this, _this.ecModel));
  57405. if (regionOpt.selected) {
  57406. selectedMap[regionName] = true;
  57407. }
  57408. }
  57409. return optionModelMap;
  57410. }, createHashMap());
  57411. if (!option.selectedMap) {
  57412. option.selectedMap = selectedMap;
  57413. }
  57414. };
  57415. /**
  57416. * Get model of region.
  57417. */
  57418. GeoModel.prototype.getRegionModel = function (name) {
  57419. return this._optionModelMap.get(name) || new Model(null, this, this.ecModel);
  57420. };
  57421. /**
  57422. * Format label
  57423. * @param name Region name
  57424. */
  57425. GeoModel.prototype.getFormattedLabel = function (name, status) {
  57426. var regionModel = this.getRegionModel(name);
  57427. var formatter = status === 'normal' ? regionModel.get(['label', 'formatter']) : regionModel.get(['emphasis', 'label', 'formatter']);
  57428. var params = {
  57429. name: name
  57430. };
  57431. if (typeof formatter === 'function') {
  57432. params.status = status;
  57433. return formatter(params);
  57434. } else if (typeof formatter === 'string') {
  57435. return formatter.replace('{a}', name != null ? name : '');
  57436. }
  57437. };
  57438. GeoModel.prototype.setZoom = function (zoom) {
  57439. this.option.zoom = zoom;
  57440. };
  57441. GeoModel.prototype.setCenter = function (center) {
  57442. this.option.center = center;
  57443. }; // PENGING If selectedMode is null ?
  57444. GeoModel.prototype.select = function (name) {
  57445. var option = this.option;
  57446. var selectedMode = option.selectedMode;
  57447. if (!selectedMode) {
  57448. return;
  57449. }
  57450. if (selectedMode !== 'multiple') {
  57451. option.selectedMap = null;
  57452. }
  57453. var selectedMap = option.selectedMap || (option.selectedMap = {});
  57454. selectedMap[name] = true;
  57455. };
  57456. GeoModel.prototype.unSelect = function (name) {
  57457. var selectedMap = this.option.selectedMap;
  57458. if (selectedMap) {
  57459. selectedMap[name] = false;
  57460. }
  57461. };
  57462. GeoModel.prototype.toggleSelected = function (name) {
  57463. this[this.isSelected(name) ? 'unSelect' : 'select'](name);
  57464. };
  57465. GeoModel.prototype.isSelected = function (name) {
  57466. var selectedMap = this.option.selectedMap;
  57467. return !!(selectedMap && selectedMap[name]);
  57468. };
  57469. GeoModel.type = 'geo';
  57470. GeoModel.layoutMode = 'box';
  57471. GeoModel.defaultOption = {
  57472. zlevel: 0,
  57473. z: 0,
  57474. show: true,
  57475. left: 'center',
  57476. top: 'center',
  57477. // Default value:
  57478. // for geoSVG source: 1,
  57479. // for geoJSON source: 0.75.
  57480. aspectScale: null,
  57481. ///// Layout with center and size
  57482. // If you wan't to put map in a fixed size box with right aspect ratio
  57483. // This two properties may more conveninet
  57484. // layoutCenter: [50%, 50%]
  57485. // layoutSize: 100
  57486. silent: false,
  57487. // Map type
  57488. map: '',
  57489. // Define left-top, right-bottom coords to control view
  57490. // For example, [ [180, 90], [-180, -90] ]
  57491. boundingCoords: null,
  57492. // Default on center of map
  57493. center: null,
  57494. zoom: 1,
  57495. scaleLimit: null,
  57496. // selectedMode: false
  57497. label: {
  57498. show: false,
  57499. color: '#000'
  57500. },
  57501. itemStyle: {
  57502. borderWidth: 0.5,
  57503. borderColor: '#444' // Default color:
  57504. // + geoJSON: #eee
  57505. // + geoSVG: null (use SVG original `fill`)
  57506. // color: '#eee'
  57507. },
  57508. emphasis: {
  57509. label: {
  57510. show: true,
  57511. color: 'rgb(100,0,0)'
  57512. },
  57513. itemStyle: {
  57514. color: 'rgba(255,215,0,0.8)'
  57515. }
  57516. },
  57517. select: {
  57518. label: {
  57519. show: true,
  57520. color: 'rgb(100,0,0)'
  57521. },
  57522. itemStyle: {
  57523. color: 'rgba(255,215,0,0.8)'
  57524. }
  57525. },
  57526. regions: [],
  57527. tooltip: {
  57528. show: false
  57529. }
  57530. };
  57531. return GeoModel;
  57532. }(ComponentModel);
  57533. /*
  57534. * Licensed to the Apache Software Foundation (ASF) under one
  57535. * or more contributor license agreements. See the NOTICE file
  57536. * distributed with this work for additional information
  57537. * regarding copyright ownership. The ASF licenses this file
  57538. * to you under the Apache License, Version 2.0 (the
  57539. * "License"); you may not use this file except in compliance
  57540. * with the License. You may obtain a copy of the License at
  57541. *
  57542. * http://www.apache.org/licenses/LICENSE-2.0
  57543. *
  57544. * Unless required by applicable law or agreed to in writing,
  57545. * software distributed under the License is distributed on an
  57546. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57547. * KIND, either express or implied. See the License for the
  57548. * specific language governing permissions and limitations
  57549. * under the License.
  57550. */
  57551. /**
  57552. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57553. */
  57554. /*
  57555. * Licensed to the Apache Software Foundation (ASF) under one
  57556. * or more contributor license agreements. See the NOTICE file
  57557. * distributed with this work for additional information
  57558. * regarding copyright ownership. The ASF licenses this file
  57559. * to you under the Apache License, Version 2.0 (the
  57560. * "License"); you may not use this file except in compliance
  57561. * with the License. You may obtain a copy of the License at
  57562. *
  57563. * http://www.apache.org/licenses/LICENSE-2.0
  57564. *
  57565. * Unless required by applicable law or agreed to in writing,
  57566. * software distributed under the License is distributed on an
  57567. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57568. * KIND, either express or implied. See the License for the
  57569. * specific language governing permissions and limitations
  57570. * under the License.
  57571. */
  57572. var GeoView =
  57573. /** @class */
  57574. function (_super) {
  57575. __extends(GeoView, _super);
  57576. function GeoView() {
  57577. var _this = _super !== null && _super.apply(this, arguments) || this;
  57578. _this.type = GeoView.type;
  57579. _this.focusBlurEnabled = true;
  57580. return _this;
  57581. }
  57582. GeoView.prototype.init = function (ecModel, api) {
  57583. var mapDraw = new MapDraw(api);
  57584. this._mapDraw = mapDraw;
  57585. this.group.add(mapDraw.group);
  57586. this._api = api;
  57587. };
  57588. GeoView.prototype.render = function (geoModel, ecModel, api, payload) {
  57589. var mapDraw = this._mapDraw;
  57590. if (geoModel.get('show')) {
  57591. mapDraw.draw(geoModel, ecModel, api, this, payload);
  57592. } else {
  57593. this._mapDraw.group.removeAll();
  57594. }
  57595. mapDraw.group.on('click', this._handleRegionClick, this);
  57596. mapDraw.group.silent = geoModel.get('silent');
  57597. this._model = geoModel;
  57598. this.updateSelectStatus(geoModel, ecModel, api);
  57599. };
  57600. GeoView.prototype._handleRegionClick = function (e) {
  57601. var eventData;
  57602. findEventDispatcher(e.target, function (current) {
  57603. return (eventData = getECData(current).eventData) != null;
  57604. }, true);
  57605. if (eventData) {
  57606. this._api.dispatchAction({
  57607. type: 'geoToggleSelect',
  57608. geoId: this._model.id,
  57609. name: eventData.name
  57610. });
  57611. }
  57612. };
  57613. GeoView.prototype.updateSelectStatus = function (model, ecModel, api) {
  57614. var _this = this;
  57615. this._mapDraw.group.traverse(function (node) {
  57616. var eventData = getECData(node).eventData;
  57617. if (eventData) {
  57618. _this._model.isSelected(eventData.name) ? api.enterSelect(node) : api.leaveSelect(node); // No need to traverse children.
  57619. return true;
  57620. }
  57621. });
  57622. };
  57623. GeoView.prototype.findHighDownDispatchers = function (name) {
  57624. return this._mapDraw && this._mapDraw.findHighDownDispatchers(name, this._model);
  57625. };
  57626. GeoView.prototype.dispose = function () {
  57627. this._mapDraw && this._mapDraw.remove();
  57628. };
  57629. GeoView.type = 'geo';
  57630. return GeoView;
  57631. }(ComponentView);
  57632. /*
  57633. * Licensed to the Apache Software Foundation (ASF) under one
  57634. * or more contributor license agreements. See the NOTICE file
  57635. * distributed with this work for additional information
  57636. * regarding copyright ownership. The ASF licenses this file
  57637. * to you under the Apache License, Version 2.0 (the
  57638. * "License"); you may not use this file except in compliance
  57639. * with the License. You may obtain a copy of the License at
  57640. *
  57641. * http://www.apache.org/licenses/LICENSE-2.0
  57642. *
  57643. * Unless required by applicable law or agreed to in writing,
  57644. * software distributed under the License is distributed on an
  57645. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57646. * KIND, either express or implied. See the License for the
  57647. * specific language governing permissions and limitations
  57648. * under the License.
  57649. */
  57650. /**
  57651. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57652. */
  57653. /*
  57654. * Licensed to the Apache Software Foundation (ASF) under one
  57655. * or more contributor license agreements. See the NOTICE file
  57656. * distributed with this work for additional information
  57657. * regarding copyright ownership. The ASF licenses this file
  57658. * to you under the Apache License, Version 2.0 (the
  57659. * "License"); you may not use this file except in compliance
  57660. * with the License. You may obtain a copy of the License at
  57661. *
  57662. * http://www.apache.org/licenses/LICENSE-2.0
  57663. *
  57664. * Unless required by applicable law or agreed to in writing,
  57665. * software distributed under the License is distributed on an
  57666. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57667. * KIND, either express or implied. See the License for the
  57668. * specific language governing permissions and limitations
  57669. * under the License.
  57670. */
  57671. function install$16(registers) {
  57672. registers.registerCoordinateSystem('geo', geoCreator);
  57673. registers.registerComponentModel(GeoModel);
  57674. registers.registerComponentView(GeoView);
  57675. function makeAction(method, actionInfo) {
  57676. actionInfo.update = 'geo:updateSelectStatus';
  57677. registers.registerAction(actionInfo, function (payload, ecModel) {
  57678. var selected = {};
  57679. var allSelected = [];
  57680. ecModel.eachComponent({
  57681. mainType: 'geo',
  57682. query: payload
  57683. }, function (geoModel) {
  57684. geoModel[method](payload.name);
  57685. var geo = geoModel.coordinateSystem;
  57686. each$1(geo.regions, function (region) {
  57687. selected[region.name] = geoModel.isSelected(region.name) || false;
  57688. }); // Notice: there might be duplicated name in different regions.
  57689. var names = [];
  57690. each$1(selected, function (v, name) {
  57691. selected[name] && names.push(name);
  57692. });
  57693. allSelected.push({
  57694. geoIndex: geoModel.componentIndex,
  57695. // Use singular, the same naming convention as the event `selectchanged`.
  57696. name: names
  57697. });
  57698. });
  57699. return {
  57700. selected: selected,
  57701. allSelected: allSelected,
  57702. name: payload.name
  57703. };
  57704. });
  57705. }
  57706. makeAction('toggleSelected', {
  57707. type: 'geoToggleSelect',
  57708. event: 'geoselectchanged'
  57709. });
  57710. makeAction('select', {
  57711. type: 'geoSelect',
  57712. event: 'geoselected'
  57713. });
  57714. makeAction('unSelect', {
  57715. type: 'geoUnSelect',
  57716. event: 'geounselected'
  57717. });
  57718. /**
  57719. * @payload
  57720. * @property {string} [componentType=series]
  57721. * @property {number} [dx]
  57722. * @property {number} [dy]
  57723. * @property {number} [zoom]
  57724. * @property {number} [originX]
  57725. * @property {number} [originY]
  57726. */
  57727. registers.registerAction({
  57728. type: 'geoRoam',
  57729. event: 'geoRoam',
  57730. update: 'updateTransform'
  57731. }, function (payload, ecModel) {
  57732. var componentType = payload.componentType || 'series';
  57733. ecModel.eachComponent({
  57734. mainType: componentType,
  57735. query: payload
  57736. }, function (componentModel) {
  57737. var geo = componentModel.coordinateSystem;
  57738. if (geo.type !== 'geo') {
  57739. return;
  57740. }
  57741. var res = updateCenterAndZoom(geo, payload, componentModel.get('scaleLimit'));
  57742. componentModel.setCenter && componentModel.setCenter(res.center);
  57743. componentModel.setZoom && componentModel.setZoom(res.zoom); // All map series with same `map` use the same geo coordinate system
  57744. // So the center and zoom must be in sync. Include the series not selected by legend
  57745. if (componentType === 'series') {
  57746. each$1(componentModel.seriesGroup, function (seriesModel) {
  57747. seriesModel.setCenter(res.center);
  57748. seriesModel.setZoom(res.zoom);
  57749. });
  57750. }
  57751. });
  57752. });
  57753. }
  57754. /*
  57755. * Licensed to the Apache Software Foundation (ASF) under one
  57756. * or more contributor license agreements. See the NOTICE file
  57757. * distributed with this work for additional information
  57758. * regarding copyright ownership. The ASF licenses this file
  57759. * to you under the Apache License, Version 2.0 (the
  57760. * "License"); you may not use this file except in compliance
  57761. * with the License. You may obtain a copy of the License at
  57762. *
  57763. * http://www.apache.org/licenses/LICENSE-2.0
  57764. *
  57765. * Unless required by applicable law or agreed to in writing,
  57766. * software distributed under the License is distributed on an
  57767. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57768. * KIND, either express or implied. See the License for the
  57769. * specific language governing permissions and limitations
  57770. * under the License.
  57771. */
  57772. /**
  57773. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57774. */
  57775. /*
  57776. * Licensed to the Apache Software Foundation (ASF) under one
  57777. * or more contributor license agreements. See the NOTICE file
  57778. * distributed with this work for additional information
  57779. * regarding copyright ownership. The ASF licenses this file
  57780. * to you under the Apache License, Version 2.0 (the
  57781. * "License"); you may not use this file except in compliance
  57782. * with the License. You may obtain a copy of the License at
  57783. *
  57784. * http://www.apache.org/licenses/LICENSE-2.0
  57785. *
  57786. * Unless required by applicable law or agreed to in writing,
  57787. * software distributed under the License is distributed on an
  57788. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57789. * KIND, either express or implied. See the License for the
  57790. * specific language governing permissions and limitations
  57791. * under the License.
  57792. */
  57793. function install$15(registers) {
  57794. use(install$16);
  57795. registers.registerChartView(MapView);
  57796. registers.registerSeriesModel(MapSeries);
  57797. registers.registerLayout(mapSymbolLayout);
  57798. registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, mapDataStatistic);
  57799. createLegacyDataSelectAction('map', registers.registerAction);
  57800. }
  57801. /*
  57802. * Licensed to the Apache Software Foundation (ASF) under one
  57803. * or more contributor license agreements. See the NOTICE file
  57804. * distributed with this work for additional information
  57805. * regarding copyright ownership. The ASF licenses this file
  57806. * to you under the Apache License, Version 2.0 (the
  57807. * "License"); you may not use this file except in compliance
  57808. * with the License. You may obtain a copy of the License at
  57809. *
  57810. * http://www.apache.org/licenses/LICENSE-2.0
  57811. *
  57812. * Unless required by applicable law or agreed to in writing,
  57813. * software distributed under the License is distributed on an
  57814. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57815. * KIND, either express or implied. See the License for the
  57816. * specific language governing permissions and limitations
  57817. * under the License.
  57818. */
  57819. /**
  57820. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57821. */
  57822. /*
  57823. * Licensed to the Apache Software Foundation (ASF) under one
  57824. * or more contributor license agreements. See the NOTICE file
  57825. * distributed with this work for additional information
  57826. * regarding copyright ownership. The ASF licenses this file
  57827. * to you under the Apache License, Version 2.0 (the
  57828. * "License"); you may not use this file except in compliance
  57829. * with the License. You may obtain a copy of the License at
  57830. *
  57831. * http://www.apache.org/licenses/LICENSE-2.0
  57832. *
  57833. * Unless required by applicable law or agreed to in writing,
  57834. * software distributed under the License is distributed on an
  57835. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57836. * KIND, either express or implied. See the License for the
  57837. * specific language governing permissions and limitations
  57838. * under the License.
  57839. */
  57840. use(install$15);
  57841. /*
  57842. * Licensed to the Apache Software Foundation (ASF) under one
  57843. * or more contributor license agreements. See the NOTICE file
  57844. * distributed with this work for additional information
  57845. * regarding copyright ownership. The ASF licenses this file
  57846. * to you under the Apache License, Version 2.0 (the
  57847. * "License"); you may not use this file except in compliance
  57848. * with the License. You may obtain a copy of the License at
  57849. *
  57850. * http://www.apache.org/licenses/LICENSE-2.0
  57851. *
  57852. * Unless required by applicable law or agreed to in writing,
  57853. * software distributed under the License is distributed on an
  57854. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57855. * KIND, either express or implied. See the License for the
  57856. * specific language governing permissions and limitations
  57857. * under the License.
  57858. */
  57859. /**
  57860. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57861. */
  57862. /*
  57863. * Licensed to the Apache Software Foundation (ASF) under one
  57864. * or more contributor license agreements. See the NOTICE file
  57865. * distributed with this work for additional information
  57866. * regarding copyright ownership. The ASF licenses this file
  57867. * to you under the Apache License, Version 2.0 (the
  57868. * "License"); you may not use this file except in compliance
  57869. * with the License. You may obtain a copy of the License at
  57870. *
  57871. * http://www.apache.org/licenses/LICENSE-2.0
  57872. *
  57873. * Unless required by applicable law or agreed to in writing,
  57874. * software distributed under the License is distributed on an
  57875. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57876. * KIND, either express or implied. See the License for the
  57877. * specific language governing permissions and limitations
  57878. * under the License.
  57879. */
  57880. /**
  57881. * Line path for bezier and straight line draw
  57882. */
  57883. var straightLineProto = Line.prototype;
  57884. var bezierCurveProto = BezierCurve.prototype;
  57885. var StraightLineShape =
  57886. /** @class */
  57887. function () {
  57888. function StraightLineShape() {
  57889. // Start point
  57890. this.x1 = 0;
  57891. this.y1 = 0; // End point
  57892. this.x2 = 0;
  57893. this.y2 = 0;
  57894. this.percent = 1;
  57895. }
  57896. return StraightLineShape;
  57897. }();
  57898. var CurveShape =
  57899. /** @class */
  57900. function (_super) {
  57901. __extends(CurveShape, _super);
  57902. function CurveShape() {
  57903. return _super !== null && _super.apply(this, arguments) || this;
  57904. }
  57905. return CurveShape;
  57906. }(StraightLineShape);
  57907. function isStraightLine(shape) {
  57908. return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
  57909. }
  57910. var ECLinePath =
  57911. /** @class */
  57912. function (_super) {
  57913. __extends(ECLinePath, _super);
  57914. function ECLinePath(opts) {
  57915. var _this = _super.call(this, opts) || this;
  57916. _this.type = 'ec-line';
  57917. return _this;
  57918. }
  57919. ECLinePath.prototype.getDefaultStyle = function () {
  57920. return {
  57921. stroke: '#000',
  57922. fill: null
  57923. };
  57924. };
  57925. ECLinePath.prototype.getDefaultShape = function () {
  57926. return new StraightLineShape();
  57927. };
  57928. ECLinePath.prototype.buildPath = function (ctx, shape) {
  57929. if (isStraightLine(shape)) {
  57930. straightLineProto.buildPath.call(this, ctx, shape);
  57931. } else {
  57932. bezierCurveProto.buildPath.call(this, ctx, shape);
  57933. }
  57934. };
  57935. ECLinePath.prototype.pointAt = function (t) {
  57936. if (isStraightLine(this.shape)) {
  57937. return straightLineProto.pointAt.call(this, t);
  57938. } else {
  57939. return bezierCurveProto.pointAt.call(this, t);
  57940. }
  57941. };
  57942. ECLinePath.prototype.tangentAt = function (t) {
  57943. var shape = this.shape;
  57944. var p = isStraightLine(shape) ? [shape.x2 - shape.x1, shape.y2 - shape.y1] : bezierCurveProto.tangentAt.call(this, t);
  57945. return normalize(p, p);
  57946. };
  57947. return ECLinePath;
  57948. }(Path);
  57949. /*
  57950. * Licensed to the Apache Software Foundation (ASF) under one
  57951. * or more contributor license agreements. See the NOTICE file
  57952. * distributed with this work for additional information
  57953. * regarding copyright ownership. The ASF licenses this file
  57954. * to you under the Apache License, Version 2.0 (the
  57955. * "License"); you may not use this file except in compliance
  57956. * with the License. You may obtain a copy of the License at
  57957. *
  57958. * http://www.apache.org/licenses/LICENSE-2.0
  57959. *
  57960. * Unless required by applicable law or agreed to in writing,
  57961. * software distributed under the License is distributed on an
  57962. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57963. * KIND, either express or implied. See the License for the
  57964. * specific language governing permissions and limitations
  57965. * under the License.
  57966. */
  57967. /**
  57968. * AUTO-GENERATED FILE. DO NOT MODIFY.
  57969. */
  57970. /*
  57971. * Licensed to the Apache Software Foundation (ASF) under one
  57972. * or more contributor license agreements. See the NOTICE file
  57973. * distributed with this work for additional information
  57974. * regarding copyright ownership. The ASF licenses this file
  57975. * to you under the Apache License, Version 2.0 (the
  57976. * "License"); you may not use this file except in compliance
  57977. * with the License. You may obtain a copy of the License at
  57978. *
  57979. * http://www.apache.org/licenses/LICENSE-2.0
  57980. *
  57981. * Unless required by applicable law or agreed to in writing,
  57982. * software distributed under the License is distributed on an
  57983. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  57984. * KIND, either express or implied. See the License for the
  57985. * specific language governing permissions and limitations
  57986. * under the License.
  57987. */
  57988. var SYMBOL_CATEGORIES = ['fromSymbol', 'toSymbol'];
  57989. function makeSymbolTypeKey(symbolCategory) {
  57990. return '_' + symbolCategory + 'Type';
  57991. }
  57992. /**
  57993. * @inner
  57994. */
  57995. function createSymbol$1(name, lineData, idx) {
  57996. var symbolType = lineData.getItemVisual(idx, name);
  57997. if (!symbolType || symbolType === 'none') {
  57998. return;
  57999. }
  58000. var symbolSize = lineData.getItemVisual(idx, name + 'Size');
  58001. var symbolRotate = lineData.getItemVisual(idx, name + 'Rotate');
  58002. var symbolOffset = lineData.getItemVisual(idx, name + 'Offset') || 0;
  58003. var symbolKeepAspect = lineData.getItemVisual(idx, name + 'KeepAspect');
  58004. var symbolSizeArr = isArray(symbolSize) ? symbolSize : [symbolSize, symbolSize];
  58005. var symbolOffsetArr = isArray(symbolOffset) ? symbolOffset : [symbolOffset, symbolOffset];
  58006. symbolOffsetArr[0] = parsePercent$1(symbolOffsetArr[0], symbolSizeArr[0]);
  58007. symbolOffsetArr[1] = parsePercent$1(retrieve2(symbolOffsetArr[1], symbolOffsetArr[0]), symbolSizeArr[1]);
  58008. var symbolPath = createSymbol(symbolType, -symbolSizeArr[0] / 2 + symbolOffsetArr[0], -symbolSizeArr[1] / 2 + symbolOffsetArr[1], symbolSizeArr[0], symbolSizeArr[1], null, symbolKeepAspect);
  58009. symbolPath.__specifiedRotation = symbolRotate == null || isNaN(symbolRotate) ? void 0 : +symbolRotate * Math.PI / 180 || 0;
  58010. symbolPath.name = name;
  58011. return symbolPath;
  58012. }
  58013. function createLine(points) {
  58014. var line = new ECLinePath({
  58015. name: 'line',
  58016. subPixelOptimize: true
  58017. });
  58018. setLinePoints(line.shape, points);
  58019. return line;
  58020. }
  58021. function setLinePoints(targetShape, points) {
  58022. targetShape.x1 = points[0][0];
  58023. targetShape.y1 = points[0][1];
  58024. targetShape.x2 = points[1][0];
  58025. targetShape.y2 = points[1][1];
  58026. targetShape.percent = 1;
  58027. var cp1 = points[2];
  58028. if (cp1) {
  58029. targetShape.cpx1 = cp1[0];
  58030. targetShape.cpy1 = cp1[1];
  58031. } else {
  58032. targetShape.cpx1 = NaN;
  58033. targetShape.cpy1 = NaN;
  58034. }
  58035. }
  58036. var Line$2 =
  58037. /** @class */
  58038. function (_super) {
  58039. __extends(Line$$1, _super);
  58040. function Line$$1(lineData, idx, seriesScope) {
  58041. var _this = _super.call(this) || this;
  58042. _this._createLine(lineData, idx, seriesScope);
  58043. return _this;
  58044. }
  58045. Line$$1.prototype._createLine = function (lineData, idx, seriesScope) {
  58046. var seriesModel = lineData.hostModel;
  58047. var linePoints = lineData.getItemLayout(idx);
  58048. var line = createLine(linePoints);
  58049. line.shape.percent = 0;
  58050. initProps(line, {
  58051. shape: {
  58052. percent: 1
  58053. }
  58054. }, seriesModel, idx);
  58055. this.add(line);
  58056. each$1(SYMBOL_CATEGORIES, function (symbolCategory) {
  58057. var symbol = createSymbol$1(symbolCategory, lineData, idx); // symbols must added after line to make sure
  58058. // it will be updated after line#update.
  58059. // Or symbol position and rotation update in line#beforeUpdate will be one frame slow
  58060. this.add(symbol);
  58061. this[makeSymbolTypeKey(symbolCategory)] = lineData.getItemVisual(idx, symbolCategory);
  58062. }, this);
  58063. this._updateCommonStl(lineData, idx, seriesScope);
  58064. }; // TODO More strict on the List type in parameters?
  58065. Line$$1.prototype.updateData = function (lineData, idx, seriesScope) {
  58066. var seriesModel = lineData.hostModel;
  58067. var line = this.childOfName('line');
  58068. var linePoints = lineData.getItemLayout(idx);
  58069. var target = {
  58070. shape: {}
  58071. };
  58072. setLinePoints(target.shape, linePoints);
  58073. updateProps(line, target, seriesModel, idx);
  58074. each$1(SYMBOL_CATEGORIES, function (symbolCategory) {
  58075. var symbolType = lineData.getItemVisual(idx, symbolCategory);
  58076. var key = makeSymbolTypeKey(symbolCategory); // Symbol changed
  58077. if (this[key] !== symbolType) {
  58078. this.remove(this.childOfName(symbolCategory));
  58079. var symbol = createSymbol$1(symbolCategory, lineData, idx);
  58080. this.add(symbol);
  58081. }
  58082. this[key] = symbolType;
  58083. }, this);
  58084. this._updateCommonStl(lineData, idx, seriesScope);
  58085. };
  58086. Line$$1.prototype.getLinePath = function () {
  58087. return this.childAt(0);
  58088. };
  58089. Line$$1.prototype._updateCommonStl = function (lineData, idx, seriesScope) {
  58090. var seriesModel = lineData.hostModel;
  58091. var line = this.childOfName('line');
  58092. var emphasisLineStyle = seriesScope && seriesScope.emphasisLineStyle;
  58093. var blurLineStyle = seriesScope && seriesScope.blurLineStyle;
  58094. var selectLineStyle = seriesScope && seriesScope.selectLineStyle;
  58095. var labelStatesModels = seriesScope && seriesScope.labelStatesModels; // Optimization for large dataset
  58096. if (!seriesScope || lineData.hasItemOption) {
  58097. var itemModel = lineData.getItemModel(idx);
  58098. emphasisLineStyle = itemModel.getModel(['emphasis', 'lineStyle']).getLineStyle();
  58099. blurLineStyle = itemModel.getModel(['blur', 'lineStyle']).getLineStyle();
  58100. selectLineStyle = itemModel.getModel(['select', 'lineStyle']).getLineStyle();
  58101. labelStatesModels = getLabelStatesModels(itemModel);
  58102. }
  58103. var lineStyle = lineData.getItemVisual(idx, 'style');
  58104. var visualColor = lineStyle.stroke;
  58105. line.useStyle(lineStyle);
  58106. line.style.fill = null;
  58107. line.style.strokeNoScale = true;
  58108. line.ensureState('emphasis').style = emphasisLineStyle;
  58109. line.ensureState('blur').style = blurLineStyle;
  58110. line.ensureState('select').style = selectLineStyle; // Update symbol
  58111. each$1(SYMBOL_CATEGORIES, function (symbolCategory) {
  58112. var symbol = this.childOfName(symbolCategory);
  58113. if (symbol) {
  58114. // Share opacity and color with line.
  58115. symbol.setColor(visualColor);
  58116. symbol.style.opacity = lineStyle.opacity;
  58117. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  58118. var stateName = SPECIAL_STATES[i];
  58119. var lineState = line.getState(stateName);
  58120. if (lineState) {
  58121. var lineStateStyle = lineState.style || {};
  58122. var state = symbol.ensureState(stateName);
  58123. var stateStyle = state.style || (state.style = {});
  58124. if (lineStateStyle.stroke != null) {
  58125. stateStyle[symbol.__isEmptyBrush ? 'stroke' : 'fill'] = lineStateStyle.stroke;
  58126. }
  58127. if (lineStateStyle.opacity != null) {
  58128. stateStyle.opacity = lineStateStyle.opacity;
  58129. }
  58130. }
  58131. }
  58132. symbol.markRedraw();
  58133. }
  58134. }, this);
  58135. var rawVal = seriesModel.getRawValue(idx);
  58136. setLabelStyle(this, labelStatesModels, {
  58137. labelDataIndex: idx,
  58138. labelFetcher: {
  58139. getFormattedLabel: function (dataIndex, stateName) {
  58140. return seriesModel.getFormattedLabel(dataIndex, stateName, lineData.dataType);
  58141. }
  58142. },
  58143. inheritColor: visualColor || '#000',
  58144. defaultOpacity: lineStyle.opacity,
  58145. defaultText: (rawVal == null ? lineData.getName(idx) : isFinite(rawVal) ? round(rawVal) : rawVal) + ''
  58146. });
  58147. var label = this.getTextContent(); // Always set `textStyle` even if `normalStyle.text` is null, because default
  58148. // values have to be set on `normalStyle`.
  58149. if (label) {
  58150. var labelNormalModel = labelStatesModels.normal;
  58151. label.__align = label.style.align;
  58152. label.__verticalAlign = label.style.verticalAlign; // 'start', 'middle', 'end'
  58153. label.__position = labelNormalModel.get('position') || 'middle';
  58154. var distance$$1 = labelNormalModel.get('distance');
  58155. if (!isArray(distance$$1)) {
  58156. distance$$1 = [distance$$1, distance$$1];
  58157. }
  58158. label.__labelDistance = distance$$1;
  58159. }
  58160. this.setTextConfig({
  58161. position: null,
  58162. local: true,
  58163. inside: false // Can't be inside for stroke element.
  58164. });
  58165. enableHoverEmphasis(this);
  58166. };
  58167. Line$$1.prototype.highlight = function () {
  58168. enterEmphasis(this);
  58169. };
  58170. Line$$1.prototype.downplay = function () {
  58171. leaveEmphasis(this);
  58172. };
  58173. Line$$1.prototype.updateLayout = function (lineData, idx) {
  58174. this.setLinePoints(lineData.getItemLayout(idx));
  58175. };
  58176. Line$$1.prototype.setLinePoints = function (points) {
  58177. var linePath = this.childOfName('line');
  58178. setLinePoints(linePath.shape, points);
  58179. linePath.dirty();
  58180. };
  58181. Line$$1.prototype.beforeUpdate = function () {
  58182. var lineGroup = this;
  58183. var symbolFrom = lineGroup.childOfName('fromSymbol');
  58184. var symbolTo = lineGroup.childOfName('toSymbol');
  58185. var label = lineGroup.getTextContent(); // Quick reject
  58186. if (!symbolFrom && !symbolTo && (!label || label.ignore)) {
  58187. return;
  58188. }
  58189. var invScale = 1;
  58190. var parentNode = this.parent;
  58191. while (parentNode) {
  58192. if (parentNode.scaleX) {
  58193. invScale /= parentNode.scaleX;
  58194. }
  58195. parentNode = parentNode.parent;
  58196. }
  58197. var line = lineGroup.childOfName('line'); // If line not changed
  58198. // FIXME Parent scale changed
  58199. if (!this.__dirty && !line.__dirty) {
  58200. return;
  58201. }
  58202. var percent = line.shape.percent;
  58203. var fromPos = line.pointAt(0);
  58204. var toPos = line.pointAt(percent);
  58205. var d = sub([], toPos, fromPos);
  58206. normalize(d, d);
  58207. function setSymbolRotation(symbol, percent) {
  58208. // Fix #12388
  58209. // when symbol is set to be 'arrow' in markLine,
  58210. // symbolRotate value will be ignored, and compulsively use tangent angle.
  58211. // rotate by default if symbol rotation is not specified
  58212. var specifiedRotation = symbol.__specifiedRotation;
  58213. if (specifiedRotation == null) {
  58214. var tangent = line.tangentAt(percent);
  58215. symbol.attr('rotation', (percent === 1 ? -1 : 1) * Math.PI / 2 - Math.atan2(tangent[1], tangent[0]));
  58216. } else {
  58217. symbol.attr('rotation', specifiedRotation);
  58218. }
  58219. }
  58220. if (symbolFrom) {
  58221. symbolFrom.setPosition(fromPos);
  58222. setSymbolRotation(symbolFrom, 0);
  58223. symbolFrom.scaleX = symbolFrom.scaleY = invScale * percent;
  58224. symbolFrom.markRedraw();
  58225. }
  58226. if (symbolTo) {
  58227. symbolTo.setPosition(toPos);
  58228. setSymbolRotation(symbolTo, 1);
  58229. symbolTo.scaleX = symbolTo.scaleY = invScale * percent;
  58230. symbolTo.markRedraw();
  58231. }
  58232. if (label && !label.ignore) {
  58233. label.x = label.y = 0;
  58234. label.originX = label.originY = 0;
  58235. var textAlign = void 0;
  58236. var textVerticalAlign = void 0;
  58237. var distance$$1 = label.__labelDistance;
  58238. var distanceX = distance$$1[0] * invScale;
  58239. var distanceY = distance$$1[1] * invScale;
  58240. var halfPercent = percent / 2;
  58241. var tangent = line.tangentAt(halfPercent);
  58242. var n = [tangent[1], -tangent[0]];
  58243. var cp = line.pointAt(halfPercent);
  58244. if (n[1] > 0) {
  58245. n[0] = -n[0];
  58246. n[1] = -n[1];
  58247. }
  58248. var dir = tangent[0] < 0 ? -1 : 1;
  58249. if (label.__position !== 'start' && label.__position !== 'end') {
  58250. var rotation = -Math.atan2(tangent[1], tangent[0]);
  58251. if (toPos[0] < fromPos[0]) {
  58252. rotation = Math.PI + rotation;
  58253. }
  58254. label.rotation = rotation;
  58255. }
  58256. var dy = void 0;
  58257. switch (label.__position) {
  58258. case 'insideStartTop':
  58259. case 'insideMiddleTop':
  58260. case 'insideEndTop':
  58261. case 'middle':
  58262. dy = -distanceY;
  58263. textVerticalAlign = 'bottom';
  58264. break;
  58265. case 'insideStartBottom':
  58266. case 'insideMiddleBottom':
  58267. case 'insideEndBottom':
  58268. dy = distanceY;
  58269. textVerticalAlign = 'top';
  58270. break;
  58271. default:
  58272. dy = 0;
  58273. textVerticalAlign = 'middle';
  58274. }
  58275. switch (label.__position) {
  58276. case 'end':
  58277. label.x = d[0] * distanceX + toPos[0];
  58278. label.y = d[1] * distanceY + toPos[1];
  58279. textAlign = d[0] > 0.8 ? 'left' : d[0] < -0.8 ? 'right' : 'center';
  58280. textVerticalAlign = d[1] > 0.8 ? 'top' : d[1] < -0.8 ? 'bottom' : 'middle';
  58281. break;
  58282. case 'start':
  58283. label.x = -d[0] * distanceX + fromPos[0];
  58284. label.y = -d[1] * distanceY + fromPos[1];
  58285. textAlign = d[0] > 0.8 ? 'right' : d[0] < -0.8 ? 'left' : 'center';
  58286. textVerticalAlign = d[1] > 0.8 ? 'bottom' : d[1] < -0.8 ? 'top' : 'middle';
  58287. break;
  58288. case 'insideStartTop':
  58289. case 'insideStart':
  58290. case 'insideStartBottom':
  58291. label.x = distanceX * dir + fromPos[0];
  58292. label.y = fromPos[1] + dy;
  58293. textAlign = tangent[0] < 0 ? 'right' : 'left';
  58294. label.originX = -distanceX * dir;
  58295. label.originY = -dy;
  58296. break;
  58297. case 'insideMiddleTop':
  58298. case 'insideMiddle':
  58299. case 'insideMiddleBottom':
  58300. case 'middle':
  58301. label.x = cp[0];
  58302. label.y = cp[1] + dy;
  58303. textAlign = 'center';
  58304. label.originY = -dy;
  58305. break;
  58306. case 'insideEndTop':
  58307. case 'insideEnd':
  58308. case 'insideEndBottom':
  58309. label.x = -distanceX * dir + toPos[0];
  58310. label.y = toPos[1] + dy;
  58311. textAlign = tangent[0] >= 0 ? 'right' : 'left';
  58312. label.originX = distanceX * dir;
  58313. label.originY = -dy;
  58314. break;
  58315. }
  58316. label.scaleX = label.scaleY = invScale;
  58317. label.setStyle({
  58318. // Use the user specified text align and baseline first
  58319. verticalAlign: label.__verticalAlign || textVerticalAlign,
  58320. align: label.__align || textAlign
  58321. });
  58322. }
  58323. };
  58324. return Line$$1;
  58325. }(Group);
  58326. /*
  58327. * Licensed to the Apache Software Foundation (ASF) under one
  58328. * or more contributor license agreements. See the NOTICE file
  58329. * distributed with this work for additional information
  58330. * regarding copyright ownership. The ASF licenses this file
  58331. * to you under the Apache License, Version 2.0 (the
  58332. * "License"); you may not use this file except in compliance
  58333. * with the License. You may obtain a copy of the License at
  58334. *
  58335. * http://www.apache.org/licenses/LICENSE-2.0
  58336. *
  58337. * Unless required by applicable law or agreed to in writing,
  58338. * software distributed under the License is distributed on an
  58339. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58340. * KIND, either express or implied. See the License for the
  58341. * specific language governing permissions and limitations
  58342. * under the License.
  58343. */
  58344. /**
  58345. * AUTO-GENERATED FILE. DO NOT MODIFY.
  58346. */
  58347. /*
  58348. * Licensed to the Apache Software Foundation (ASF) under one
  58349. * or more contributor license agreements. See the NOTICE file
  58350. * distributed with this work for additional information
  58351. * regarding copyright ownership. The ASF licenses this file
  58352. * to you under the Apache License, Version 2.0 (the
  58353. * "License"); you may not use this file except in compliance
  58354. * with the License. You may obtain a copy of the License at
  58355. *
  58356. * http://www.apache.org/licenses/LICENSE-2.0
  58357. *
  58358. * Unless required by applicable law or agreed to in writing,
  58359. * software distributed under the License is distributed on an
  58360. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58361. * KIND, either express or implied. See the License for the
  58362. * specific language governing permissions and limitations
  58363. * under the License.
  58364. */
  58365. var LineDraw =
  58366. /** @class */
  58367. function () {
  58368. function LineDraw(LineCtor) {
  58369. this.group = new Group();
  58370. this._LineCtor = LineCtor || Line$2;
  58371. }
  58372. LineDraw.prototype.isPersistent = function () {
  58373. return true;
  58374. };
  58375. LineDraw.prototype.updateData = function (lineData) {
  58376. var _this = this;
  58377. var lineDraw = this;
  58378. var group = lineDraw.group;
  58379. var oldLineData = lineDraw._lineData;
  58380. lineDraw._lineData = lineData; // There is no oldLineData only when first rendering or switching from
  58381. // stream mode to normal mode, where previous elements should be removed.
  58382. if (!oldLineData) {
  58383. group.removeAll();
  58384. }
  58385. var seriesScope = makeSeriesScope$1(lineData);
  58386. lineData.diff(oldLineData).add(function (idx) {
  58387. _this._doAdd(lineData, idx, seriesScope);
  58388. }).update(function (newIdx, oldIdx) {
  58389. _this._doUpdate(oldLineData, lineData, oldIdx, newIdx, seriesScope);
  58390. }).remove(function (idx) {
  58391. group.remove(oldLineData.getItemGraphicEl(idx));
  58392. }).execute();
  58393. };
  58394. LineDraw.prototype.updateLayout = function () {
  58395. var lineData = this._lineData; // Do not support update layout in incremental mode.
  58396. if (!lineData) {
  58397. return;
  58398. }
  58399. lineData.eachItemGraphicEl(function (el, idx) {
  58400. el.updateLayout(lineData, idx);
  58401. }, this);
  58402. };
  58403. LineDraw.prototype.incrementalPrepareUpdate = function (lineData) {
  58404. this._seriesScope = makeSeriesScope$1(lineData);
  58405. this._lineData = null;
  58406. this.group.removeAll();
  58407. };
  58408. LineDraw.prototype.incrementalUpdate = function (taskParams, lineData) {
  58409. function updateIncrementalAndHover(el) {
  58410. if (!el.isGroup && !isEffectObject(el)) {
  58411. el.incremental = true;
  58412. el.ensureState('emphasis').hoverLayer = true;
  58413. }
  58414. }
  58415. for (var idx = taskParams.start; idx < taskParams.end; idx++) {
  58416. var itemLayout = lineData.getItemLayout(idx);
  58417. if (lineNeedsDraw(itemLayout)) {
  58418. var el = new this._LineCtor(lineData, idx, this._seriesScope);
  58419. el.traverse(updateIncrementalAndHover);
  58420. this.group.add(el);
  58421. lineData.setItemGraphicEl(idx, el);
  58422. }
  58423. }
  58424. };
  58425. LineDraw.prototype.remove = function () {
  58426. this.group.removeAll();
  58427. };
  58428. LineDraw.prototype._doAdd = function (lineData, idx, seriesScope) {
  58429. var itemLayout = lineData.getItemLayout(idx);
  58430. if (!lineNeedsDraw(itemLayout)) {
  58431. return;
  58432. }
  58433. var el = new this._LineCtor(lineData, idx, seriesScope);
  58434. lineData.setItemGraphicEl(idx, el);
  58435. this.group.add(el);
  58436. };
  58437. LineDraw.prototype._doUpdate = function (oldLineData, newLineData, oldIdx, newIdx, seriesScope) {
  58438. var itemEl = oldLineData.getItemGraphicEl(oldIdx);
  58439. if (!lineNeedsDraw(newLineData.getItemLayout(newIdx))) {
  58440. this.group.remove(itemEl);
  58441. return;
  58442. }
  58443. if (!itemEl) {
  58444. itemEl = new this._LineCtor(newLineData, newIdx, seriesScope);
  58445. } else {
  58446. itemEl.updateData(newLineData, newIdx, seriesScope);
  58447. }
  58448. newLineData.setItemGraphicEl(newIdx, itemEl);
  58449. this.group.add(itemEl);
  58450. };
  58451. return LineDraw;
  58452. }();
  58453. function isEffectObject(el) {
  58454. return el.animators && el.animators.length > 0;
  58455. }
  58456. function makeSeriesScope$1(lineData) {
  58457. var hostModel = lineData.hostModel;
  58458. return {
  58459. lineStyle: hostModel.getModel('lineStyle').getLineStyle(),
  58460. emphasisLineStyle: hostModel.getModel(['emphasis', 'lineStyle']).getLineStyle(),
  58461. blurLineStyle: hostModel.getModel(['blur', 'lineStyle']).getLineStyle(),
  58462. selectLineStyle: hostModel.getModel(['select', 'lineStyle']).getLineStyle(),
  58463. labelStatesModels: getLabelStatesModels(hostModel)
  58464. };
  58465. }
  58466. function isPointNaN(pt) {
  58467. return isNaN(pt[0]) || isNaN(pt[1]);
  58468. }
  58469. function lineNeedsDraw(pts) {
  58470. return !isPointNaN(pts[0]) && !isPointNaN(pts[1]);
  58471. }
  58472. /*
  58473. * Licensed to the Apache Software Foundation (ASF) under one
  58474. * or more contributor license agreements. See the NOTICE file
  58475. * distributed with this work for additional information
  58476. * regarding copyright ownership. The ASF licenses this file
  58477. * to you under the Apache License, Version 2.0 (the
  58478. * "License"); you may not use this file except in compliance
  58479. * with the License. You may obtain a copy of the License at
  58480. *
  58481. * http://www.apache.org/licenses/LICENSE-2.0
  58482. *
  58483. * Unless required by applicable law or agreed to in writing,
  58484. * software distributed under the License is distributed on an
  58485. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58486. * KIND, either express or implied. See the License for the
  58487. * specific language governing permissions and limitations
  58488. * under the License.
  58489. */
  58490. /**
  58491. * AUTO-GENERATED FILE. DO NOT MODIFY.
  58492. */
  58493. /*
  58494. * Licensed to the Apache Software Foundation (ASF) under one
  58495. * or more contributor license agreements. See the NOTICE file
  58496. * distributed with this work for additional information
  58497. * regarding copyright ownership. The ASF licenses this file
  58498. * to you under the Apache License, Version 2.0 (the
  58499. * "License"); you may not use this file except in compliance
  58500. * with the License. You may obtain a copy of the License at
  58501. *
  58502. * http://www.apache.org/licenses/LICENSE-2.0
  58503. *
  58504. * Unless required by applicable law or agreed to in writing,
  58505. * software distributed under the License is distributed on an
  58506. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58507. * KIND, either express or implied. See the License for the
  58508. * specific language governing permissions and limitations
  58509. * under the License.
  58510. */
  58511. /**
  58512. * Provide effect for line
  58513. */
  58514. var EffectLine =
  58515. /** @class */
  58516. function (_super) {
  58517. __extends(EffectLine, _super);
  58518. function EffectLine(lineData, idx, seriesScope) {
  58519. var _this = _super.call(this) || this;
  58520. _this.add(_this.createLine(lineData, idx, seriesScope));
  58521. _this._updateEffectSymbol(lineData, idx);
  58522. return _this;
  58523. }
  58524. EffectLine.prototype.createLine = function (lineData, idx, seriesScope) {
  58525. return new Line$2(lineData, idx, seriesScope);
  58526. };
  58527. EffectLine.prototype._updateEffectSymbol = function (lineData, idx) {
  58528. var itemModel = lineData.getItemModel(idx);
  58529. var effectModel = itemModel.getModel('effect');
  58530. var size = effectModel.get('symbolSize');
  58531. var symbolType = effectModel.get('symbol');
  58532. if (!isArray(size)) {
  58533. size = [size, size];
  58534. }
  58535. var lineStyle = lineData.getItemVisual(idx, 'style');
  58536. var color = effectModel.get('color') || lineStyle && lineStyle.stroke;
  58537. var symbol = this.childAt(1);
  58538. if (this._symbolType !== symbolType) {
  58539. // Remove previous
  58540. this.remove(symbol);
  58541. symbol = createSymbol(symbolType, -0.5, -0.5, 1, 1, color);
  58542. symbol.z2 = 100;
  58543. symbol.culling = true;
  58544. this.add(symbol);
  58545. } // Symbol may be removed if loop is false
  58546. if (!symbol) {
  58547. return;
  58548. } // Shadow color is same with color in default
  58549. symbol.setStyle('shadowColor', color);
  58550. symbol.setStyle(effectModel.getItemStyle(['color']));
  58551. symbol.scaleX = size[0];
  58552. symbol.scaleY = size[1];
  58553. symbol.setColor(color);
  58554. this._symbolType = symbolType;
  58555. this._symbolScale = size;
  58556. this._updateEffectAnimation(lineData, effectModel, idx);
  58557. };
  58558. EffectLine.prototype._updateEffectAnimation = function (lineData, effectModel, idx) {
  58559. var symbol = this.childAt(1);
  58560. if (!symbol) {
  58561. return;
  58562. }
  58563. var self = this;
  58564. var points = lineData.getItemLayout(idx);
  58565. var period = effectModel.get('period') * 1000;
  58566. var loop = effectModel.get('loop');
  58567. var constantSpeed = effectModel.get('constantSpeed');
  58568. var delayExpr = retrieve(effectModel.get('delay'), function (idx) {
  58569. return idx / lineData.count() * period / 3;
  58570. }); // Ignore when updating
  58571. symbol.ignore = true;
  58572. this._updateAnimationPoints(symbol, points);
  58573. if (constantSpeed > 0) {
  58574. period = this._getLineLength(symbol) / constantSpeed * 1000;
  58575. }
  58576. if (period !== this._period || loop !== this._loop) {
  58577. symbol.stopAnimation();
  58578. if (period > 0) {
  58579. var delayNum = void 0;
  58580. if (typeof delayExpr === 'function') {
  58581. delayNum = delayExpr(idx);
  58582. } else {
  58583. delayNum = delayExpr;
  58584. }
  58585. if (symbol.__t > 0) {
  58586. delayNum = -period * symbol.__t;
  58587. }
  58588. symbol.__t = 0;
  58589. var animator = symbol.animate('', loop).when(period, {
  58590. __t: 1
  58591. }).delay(delayNum).during(function () {
  58592. self._updateSymbolPosition(symbol);
  58593. });
  58594. if (!loop) {
  58595. animator.done(function () {
  58596. self.remove(symbol);
  58597. });
  58598. }
  58599. animator.start();
  58600. }
  58601. }
  58602. this._period = period;
  58603. this._loop = loop;
  58604. };
  58605. EffectLine.prototype._getLineLength = function (symbol) {
  58606. // Not so accurate
  58607. return dist(symbol.__p1, symbol.__cp1) + dist(symbol.__cp1, symbol.__p2);
  58608. };
  58609. EffectLine.prototype._updateAnimationPoints = function (symbol, points) {
  58610. symbol.__p1 = points[0];
  58611. symbol.__p2 = points[1];
  58612. symbol.__cp1 = points[2] || [(points[0][0] + points[1][0]) / 2, (points[0][1] + points[1][1]) / 2];
  58613. };
  58614. EffectLine.prototype.updateData = function (lineData, idx, seriesScope) {
  58615. this.childAt(0).updateData(lineData, idx, seriesScope);
  58616. this._updateEffectSymbol(lineData, idx);
  58617. };
  58618. EffectLine.prototype._updateSymbolPosition = function (symbol) {
  58619. var p1 = symbol.__p1;
  58620. var p2 = symbol.__p2;
  58621. var cp1 = symbol.__cp1;
  58622. var t = symbol.__t;
  58623. var pos = [symbol.x, symbol.y];
  58624. var lastPos = pos.slice();
  58625. var quadraticAt$$1 = quadraticAt;
  58626. var quadraticDerivativeAt$$1 = quadraticDerivativeAt;
  58627. pos[0] = quadraticAt$$1(p1[0], cp1[0], p2[0], t);
  58628. pos[1] = quadraticAt$$1(p1[1], cp1[1], p2[1], t); // Tangent
  58629. var tx = quadraticDerivativeAt$$1(p1[0], cp1[0], p2[0], t);
  58630. var ty = quadraticDerivativeAt$$1(p1[1], cp1[1], p2[1], t);
  58631. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2; // enable continuity trail for 'line', 'rect', 'roundRect' symbolType
  58632. if (this._symbolType === 'line' || this._symbolType === 'rect' || this._symbolType === 'roundRect') {
  58633. if (symbol.__lastT !== undefined && symbol.__lastT < symbol.__t) {
  58634. symbol.scaleY = dist(lastPos, pos) * 1.05; // make sure the last segment render within endPoint
  58635. if (t === 1) {
  58636. pos[0] = lastPos[0] + (pos[0] - lastPos[0]) / 2;
  58637. pos[1] = lastPos[1] + (pos[1] - lastPos[1]) / 2;
  58638. }
  58639. } else if (symbol.__lastT === 1) {
  58640. // After first loop, symbol.__t does NOT start with 0, so connect p1 to pos directly.
  58641. symbol.scaleY = 2 * dist(p1, pos);
  58642. } else {
  58643. symbol.scaleY = this._symbolScale[1];
  58644. }
  58645. }
  58646. symbol.__lastT = symbol.__t;
  58647. symbol.ignore = false;
  58648. symbol.x = pos[0];
  58649. symbol.y = pos[1];
  58650. };
  58651. EffectLine.prototype.updateLayout = function (lineData, idx) {
  58652. this.childAt(0).updateLayout(lineData, idx);
  58653. var effectModel = lineData.getItemModel(idx).getModel('effect');
  58654. this._updateEffectAnimation(lineData, effectModel, idx);
  58655. };
  58656. return EffectLine;
  58657. }(Group);
  58658. /*
  58659. * Licensed to the Apache Software Foundation (ASF) under one
  58660. * or more contributor license agreements. See the NOTICE file
  58661. * distributed with this work for additional information
  58662. * regarding copyright ownership. The ASF licenses this file
  58663. * to you under the Apache License, Version 2.0 (the
  58664. * "License"); you may not use this file except in compliance
  58665. * with the License. You may obtain a copy of the License at
  58666. *
  58667. * http://www.apache.org/licenses/LICENSE-2.0
  58668. *
  58669. * Unless required by applicable law or agreed to in writing,
  58670. * software distributed under the License is distributed on an
  58671. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58672. * KIND, either express or implied. See the License for the
  58673. * specific language governing permissions and limitations
  58674. * under the License.
  58675. */
  58676. /**
  58677. * AUTO-GENERATED FILE. DO NOT MODIFY.
  58678. */
  58679. /*
  58680. * Licensed to the Apache Software Foundation (ASF) under one
  58681. * or more contributor license agreements. See the NOTICE file
  58682. * distributed with this work for additional information
  58683. * regarding copyright ownership. The ASF licenses this file
  58684. * to you under the Apache License, Version 2.0 (the
  58685. * "License"); you may not use this file except in compliance
  58686. * with the License. You may obtain a copy of the License at
  58687. *
  58688. * http://www.apache.org/licenses/LICENSE-2.0
  58689. *
  58690. * Unless required by applicable law or agreed to in writing,
  58691. * software distributed under the License is distributed on an
  58692. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58693. * KIND, either express or implied. See the License for the
  58694. * specific language governing permissions and limitations
  58695. * under the License.
  58696. */
  58697. var Polyline$2 =
  58698. /** @class */
  58699. function (_super) {
  58700. __extends(Polyline$$1, _super);
  58701. function Polyline$$1(lineData, idx, seriesScope) {
  58702. var _this = _super.call(this) || this;
  58703. _this._createPolyline(lineData, idx, seriesScope);
  58704. return _this;
  58705. }
  58706. Polyline$$1.prototype._createPolyline = function (lineData, idx, seriesScope) {
  58707. // let seriesModel = lineData.hostModel;
  58708. var points = lineData.getItemLayout(idx);
  58709. var line = new Polyline({
  58710. shape: {
  58711. points: points
  58712. }
  58713. });
  58714. this.add(line);
  58715. this._updateCommonStl(lineData, idx, seriesScope);
  58716. };
  58717. Polyline$$1.prototype.updateData = function (lineData, idx, seriesScope) {
  58718. var seriesModel = lineData.hostModel;
  58719. var line = this.childAt(0);
  58720. var target = {
  58721. shape: {
  58722. points: lineData.getItemLayout(idx)
  58723. }
  58724. };
  58725. updateProps(line, target, seriesModel, idx);
  58726. this._updateCommonStl(lineData, idx, seriesScope);
  58727. };
  58728. Polyline$$1.prototype._updateCommonStl = function (lineData, idx, seriesScope) {
  58729. var line = this.childAt(0);
  58730. var itemModel = lineData.getItemModel(idx);
  58731. var hoverLineStyle = seriesScope && seriesScope.emphasisLineStyle;
  58732. if (!seriesScope || lineData.hasItemOption) {
  58733. hoverLineStyle = itemModel.getModel(['emphasis', 'lineStyle']).getLineStyle();
  58734. }
  58735. line.useStyle(lineData.getItemVisual(idx, 'style'));
  58736. line.style.fill = null;
  58737. line.style.strokeNoScale = true;
  58738. var lineEmphasisState = line.ensureState('emphasis');
  58739. lineEmphasisState.style = hoverLineStyle;
  58740. enableHoverEmphasis(this);
  58741. };
  58742. Polyline$$1.prototype.updateLayout = function (lineData, idx) {
  58743. var polyline = this.childAt(0);
  58744. polyline.setShape('points', lineData.getItemLayout(idx));
  58745. };
  58746. return Polyline$$1;
  58747. }(Group);
  58748. /*
  58749. * Licensed to the Apache Software Foundation (ASF) under one
  58750. * or more contributor license agreements. See the NOTICE file
  58751. * distributed with this work for additional information
  58752. * regarding copyright ownership. The ASF licenses this file
  58753. * to you under the Apache License, Version 2.0 (the
  58754. * "License"); you may not use this file except in compliance
  58755. * with the License. You may obtain a copy of the License at
  58756. *
  58757. * http://www.apache.org/licenses/LICENSE-2.0
  58758. *
  58759. * Unless required by applicable law or agreed to in writing,
  58760. * software distributed under the License is distributed on an
  58761. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58762. * KIND, either express or implied. See the License for the
  58763. * specific language governing permissions and limitations
  58764. * under the License.
  58765. */
  58766. /**
  58767. * AUTO-GENERATED FILE. DO NOT MODIFY.
  58768. */
  58769. /*
  58770. * Licensed to the Apache Software Foundation (ASF) under one
  58771. * or more contributor license agreements. See the NOTICE file
  58772. * distributed with this work for additional information
  58773. * regarding copyright ownership. The ASF licenses this file
  58774. * to you under the Apache License, Version 2.0 (the
  58775. * "License"); you may not use this file except in compliance
  58776. * with the License. You may obtain a copy of the License at
  58777. *
  58778. * http://www.apache.org/licenses/LICENSE-2.0
  58779. *
  58780. * Unless required by applicable law or agreed to in writing,
  58781. * software distributed under the License is distributed on an
  58782. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58783. * KIND, either express or implied. See the License for the
  58784. * specific language governing permissions and limitations
  58785. * under the License.
  58786. */
  58787. var EffectPolyline =
  58788. /** @class */
  58789. function (_super) {
  58790. __extends(EffectPolyline, _super);
  58791. function EffectPolyline() {
  58792. var _this = _super !== null && _super.apply(this, arguments) || this;
  58793. _this._lastFrame = 0;
  58794. _this._lastFramePercent = 0;
  58795. return _this;
  58796. } // Override
  58797. EffectPolyline.prototype.createLine = function (lineData, idx, seriesScope) {
  58798. return new Polyline$2(lineData, idx, seriesScope);
  58799. }; // Override
  58800. EffectPolyline.prototype._updateAnimationPoints = function (symbol, points) {
  58801. this._points = points;
  58802. var accLenArr = [0];
  58803. var len$$1 = 0;
  58804. for (var i = 1; i < points.length; i++) {
  58805. var p1 = points[i - 1];
  58806. var p2 = points[i];
  58807. len$$1 += dist(p1, p2);
  58808. accLenArr.push(len$$1);
  58809. }
  58810. if (len$$1 === 0) {
  58811. this._length = 0;
  58812. return;
  58813. }
  58814. for (var i = 0; i < accLenArr.length; i++) {
  58815. accLenArr[i] /= len$$1;
  58816. }
  58817. this._offsets = accLenArr;
  58818. this._length = len$$1;
  58819. }; // Override
  58820. EffectPolyline.prototype._getLineLength = function () {
  58821. return this._length;
  58822. }; // Override
  58823. EffectPolyline.prototype._updateSymbolPosition = function (symbol) {
  58824. var t = symbol.__t;
  58825. var points = this._points;
  58826. var offsets = this._offsets;
  58827. var len$$1 = points.length;
  58828. if (!offsets) {
  58829. // Has length 0
  58830. return;
  58831. }
  58832. var lastFrame = this._lastFrame;
  58833. var frame;
  58834. if (t < this._lastFramePercent) {
  58835. // Start from the next frame
  58836. // PENDING start from lastFrame ?
  58837. var start = Math.min(lastFrame + 1, len$$1 - 1);
  58838. for (frame = start; frame >= 0; frame--) {
  58839. if (offsets[frame] <= t) {
  58840. break;
  58841. }
  58842. } // PENDING really need to do this ?
  58843. frame = Math.min(frame, len$$1 - 2);
  58844. } else {
  58845. for (frame = lastFrame; frame < len$$1; frame++) {
  58846. if (offsets[frame] > t) {
  58847. break;
  58848. }
  58849. }
  58850. frame = Math.min(frame - 1, len$$1 - 2);
  58851. }
  58852. var p = (t - offsets[frame]) / (offsets[frame + 1] - offsets[frame]);
  58853. var p0 = points[frame];
  58854. var p1 = points[frame + 1];
  58855. symbol.x = p0[0] * (1 - p) + p * p1[0];
  58856. symbol.y = p0[1] * (1 - p) + p * p1[1];
  58857. var tx = p1[0] - p0[0];
  58858. var ty = p1[1] - p0[1];
  58859. symbol.rotation = -Math.atan2(ty, tx) - Math.PI / 2;
  58860. this._lastFrame = frame;
  58861. this._lastFramePercent = t;
  58862. symbol.ignore = false;
  58863. };
  58864. return EffectPolyline;
  58865. }(EffectLine);
  58866. /*
  58867. * Licensed to the Apache Software Foundation (ASF) under one
  58868. * or more contributor license agreements. See the NOTICE file
  58869. * distributed with this work for additional information
  58870. * regarding copyright ownership. The ASF licenses this file
  58871. * to you under the Apache License, Version 2.0 (the
  58872. * "License"); you may not use this file except in compliance
  58873. * with the License. You may obtain a copy of the License at
  58874. *
  58875. * http://www.apache.org/licenses/LICENSE-2.0
  58876. *
  58877. * Unless required by applicable law or agreed to in writing,
  58878. * software distributed under the License is distributed on an
  58879. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58880. * KIND, either express or implied. See the License for the
  58881. * specific language governing permissions and limitations
  58882. * under the License.
  58883. */
  58884. /**
  58885. * AUTO-GENERATED FILE. DO NOT MODIFY.
  58886. */
  58887. /*
  58888. * Licensed to the Apache Software Foundation (ASF) under one
  58889. * or more contributor license agreements. See the NOTICE file
  58890. * distributed with this work for additional information
  58891. * regarding copyright ownership. The ASF licenses this file
  58892. * to you under the Apache License, Version 2.0 (the
  58893. * "License"); you may not use this file except in compliance
  58894. * with the License. You may obtain a copy of the License at
  58895. *
  58896. * http://www.apache.org/licenses/LICENSE-2.0
  58897. *
  58898. * Unless required by applicable law or agreed to in writing,
  58899. * software distributed under the License is distributed on an
  58900. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  58901. * KIND, either express or implied. See the License for the
  58902. * specific language governing permissions and limitations
  58903. * under the License.
  58904. */
  58905. var LargeLinesPathShape =
  58906. /** @class */
  58907. function () {
  58908. function LargeLinesPathShape() {
  58909. this.polyline = false;
  58910. this.curveness = 0;
  58911. this.segs = [];
  58912. }
  58913. return LargeLinesPathShape;
  58914. }();
  58915. var LargeLinesPath =
  58916. /** @class */
  58917. function (_super) {
  58918. __extends(LargeLinesPath, _super);
  58919. function LargeLinesPath(opts) {
  58920. return _super.call(this, opts) || this;
  58921. }
  58922. LargeLinesPath.prototype.getDefaultStyle = function () {
  58923. return {
  58924. stroke: '#000',
  58925. fill: null
  58926. };
  58927. };
  58928. LargeLinesPath.prototype.getDefaultShape = function () {
  58929. return new LargeLinesPathShape();
  58930. };
  58931. LargeLinesPath.prototype.buildPath = function (ctx, shape) {
  58932. var segs = shape.segs;
  58933. var curveness = shape.curveness;
  58934. if (shape.polyline) {
  58935. for (var i = 0; i < segs.length;) {
  58936. var count = segs[i++];
  58937. if (count > 0) {
  58938. ctx.moveTo(segs[i++], segs[i++]);
  58939. for (var k = 1; k < count; k++) {
  58940. ctx.lineTo(segs[i++], segs[i++]);
  58941. }
  58942. }
  58943. }
  58944. } else {
  58945. for (var i = 0; i < segs.length;) {
  58946. var x0 = segs[i++];
  58947. var y0 = segs[i++];
  58948. var x1 = segs[i++];
  58949. var y1 = segs[i++];
  58950. ctx.moveTo(x0, y0);
  58951. if (curveness > 0) {
  58952. var x2 = (x0 + x1) / 2 - (y0 - y1) * curveness;
  58953. var y2 = (y0 + y1) / 2 - (x1 - x0) * curveness;
  58954. ctx.quadraticCurveTo(x2, y2, x1, y1);
  58955. } else {
  58956. ctx.lineTo(x1, y1);
  58957. }
  58958. }
  58959. }
  58960. };
  58961. LargeLinesPath.prototype.findDataIndex = function (x, y) {
  58962. var shape = this.shape;
  58963. var segs = shape.segs;
  58964. var curveness = shape.curveness;
  58965. var lineWidth = this.style.lineWidth;
  58966. if (shape.polyline) {
  58967. var dataIndex = 0;
  58968. for (var i = 0; i < segs.length;) {
  58969. var count = segs[i++];
  58970. if (count > 0) {
  58971. var x0 = segs[i++];
  58972. var y0 = segs[i++];
  58973. for (var k = 1; k < count; k++) {
  58974. var x1 = segs[i++];
  58975. var y1 = segs[i++];
  58976. if (containStroke$1(x0, y0, x1, y1, lineWidth, x, y)) {
  58977. return dataIndex;
  58978. }
  58979. }
  58980. }
  58981. dataIndex++;
  58982. }
  58983. } else {
  58984. var dataIndex = 0;
  58985. for (var i = 0; i < segs.length;) {
  58986. var x0 = segs[i++];
  58987. var y0 = segs[i++];
  58988. var x1 = segs[i++];
  58989. var y1 = segs[i++];
  58990. if (curveness > 0) {
  58991. var x2 = (x0 + x1) / 2 - (y0 - y1) * curveness;
  58992. var y2 = (y0 + y1) / 2 - (x1 - x0) * curveness;
  58993. if (containStroke$3(x0, y0, x2, y2, x1, y1, lineWidth, x, y)) {
  58994. return dataIndex;
  58995. }
  58996. } else {
  58997. if (containStroke$1(x0, y0, x1, y1, lineWidth, x, y)) {
  58998. return dataIndex;
  58999. }
  59000. }
  59001. dataIndex++;
  59002. }
  59003. }
  59004. return -1;
  59005. };
  59006. return LargeLinesPath;
  59007. }(Path);
  59008. var LargeLineDraw =
  59009. /** @class */
  59010. function () {
  59011. function LargeLineDraw() {
  59012. this.group = new Group();
  59013. }
  59014. LargeLineDraw.prototype.isPersistent = function () {
  59015. return !this._incremental;
  59016. };
  59017. /**
  59018. * Update symbols draw by new data
  59019. */
  59020. LargeLineDraw.prototype.updateData = function (data) {
  59021. this.group.removeAll();
  59022. var lineEl = new LargeLinesPath({
  59023. rectHover: true,
  59024. cursor: 'default'
  59025. });
  59026. lineEl.setShape({
  59027. segs: data.getLayout('linesPoints')
  59028. });
  59029. this._setCommon(lineEl, data); // Add back
  59030. this.group.add(lineEl);
  59031. this._incremental = null;
  59032. };
  59033. /**
  59034. * @override
  59035. */
  59036. LargeLineDraw.prototype.incrementalPrepareUpdate = function (data) {
  59037. this.group.removeAll();
  59038. this._clearIncremental();
  59039. if (data.count() > 5e5) {
  59040. if (!this._incremental) {
  59041. this._incremental = new IncrementalDisplayable({
  59042. silent: true
  59043. });
  59044. }
  59045. this.group.add(this._incremental);
  59046. } else {
  59047. this._incremental = null;
  59048. }
  59049. };
  59050. /**
  59051. * @override
  59052. */
  59053. LargeLineDraw.prototype.incrementalUpdate = function (taskParams, data) {
  59054. var lineEl = new LargeLinesPath();
  59055. lineEl.setShape({
  59056. segs: data.getLayout('linesPoints')
  59057. });
  59058. this._setCommon(lineEl, data, !!this._incremental);
  59059. if (!this._incremental) {
  59060. lineEl.rectHover = true;
  59061. lineEl.cursor = 'default';
  59062. lineEl.__startIndex = taskParams.start;
  59063. this.group.add(lineEl);
  59064. } else {
  59065. this._incremental.addDisplayable(lineEl, true);
  59066. }
  59067. };
  59068. /**
  59069. * @override
  59070. */
  59071. LargeLineDraw.prototype.remove = function () {
  59072. this._clearIncremental();
  59073. this._incremental = null;
  59074. this.group.removeAll();
  59075. };
  59076. LargeLineDraw.prototype._setCommon = function (lineEl, data, isIncremental) {
  59077. var hostModel = data.hostModel;
  59078. lineEl.setShape({
  59079. polyline: hostModel.get('polyline'),
  59080. curveness: hostModel.get(['lineStyle', 'curveness'])
  59081. });
  59082. lineEl.useStyle(hostModel.getModel('lineStyle').getLineStyle());
  59083. lineEl.style.strokeNoScale = true;
  59084. var style = data.getVisual('style');
  59085. if (style && style.stroke) {
  59086. lineEl.setStyle('stroke', style.stroke);
  59087. }
  59088. lineEl.setStyle('fill', null);
  59089. if (!isIncremental) {
  59090. var ecData_1 = getECData(lineEl); // Enable tooltip
  59091. // PENDING May have performance issue when path is extremely large
  59092. ecData_1.seriesIndex = hostModel.seriesIndex;
  59093. lineEl.on('mousemove', function (e) {
  59094. ecData_1.dataIndex = null;
  59095. var dataIndex = lineEl.findDataIndex(e.offsetX, e.offsetY);
  59096. if (dataIndex > 0) {
  59097. // Provide dataIndex for tooltip
  59098. ecData_1.dataIndex = dataIndex + lineEl.__startIndex;
  59099. }
  59100. });
  59101. }
  59102. };
  59103. LargeLineDraw.prototype._clearIncremental = function () {
  59104. var incremental = this._incremental;
  59105. if (incremental) {
  59106. incremental.clearDisplaybles();
  59107. }
  59108. };
  59109. return LargeLineDraw;
  59110. }();
  59111. /*
  59112. * Licensed to the Apache Software Foundation (ASF) under one
  59113. * or more contributor license agreements. See the NOTICE file
  59114. * distributed with this work for additional information
  59115. * regarding copyright ownership. The ASF licenses this file
  59116. * to you under the Apache License, Version 2.0 (the
  59117. * "License"); you may not use this file except in compliance
  59118. * with the License. You may obtain a copy of the License at
  59119. *
  59120. * http://www.apache.org/licenses/LICENSE-2.0
  59121. *
  59122. * Unless required by applicable law or agreed to in writing,
  59123. * software distributed under the License is distributed on an
  59124. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59125. * KIND, either express or implied. See the License for the
  59126. * specific language governing permissions and limitations
  59127. * under the License.
  59128. */
  59129. /**
  59130. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59131. */
  59132. /*
  59133. * Licensed to the Apache Software Foundation (ASF) under one
  59134. * or more contributor license agreements. See the NOTICE file
  59135. * distributed with this work for additional information
  59136. * regarding copyright ownership. The ASF licenses this file
  59137. * to you under the Apache License, Version 2.0 (the
  59138. * "License"); you may not use this file except in compliance
  59139. * with the License. You may obtain a copy of the License at
  59140. *
  59141. * http://www.apache.org/licenses/LICENSE-2.0
  59142. *
  59143. * Unless required by applicable law or agreed to in writing,
  59144. * software distributed under the License is distributed on an
  59145. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59146. * KIND, either express or implied. See the License for the
  59147. * specific language governing permissions and limitations
  59148. * under the License.
  59149. */
  59150. /* global Float32Array */
  59151. var linesLayout = {
  59152. seriesType: 'lines',
  59153. plan: createRenderPlanner(),
  59154. reset: function (seriesModel) {
  59155. var coordSys = seriesModel.coordinateSystem;
  59156. var isPolyline = seriesModel.get('polyline');
  59157. var isLarge = seriesModel.pipelineContext.large;
  59158. return {
  59159. progress: function (params, lineData) {
  59160. var lineCoords = [];
  59161. if (isLarge) {
  59162. var points = void 0;
  59163. var segCount = params.end - params.start;
  59164. if (isPolyline) {
  59165. var totalCoordsCount = 0;
  59166. for (var i = params.start; i < params.end; i++) {
  59167. totalCoordsCount += seriesModel.getLineCoordsCount(i);
  59168. }
  59169. points = new Float32Array(segCount + totalCoordsCount * 2);
  59170. } else {
  59171. points = new Float32Array(segCount * 4);
  59172. }
  59173. var offset = 0;
  59174. var pt = [];
  59175. for (var i = params.start; i < params.end; i++) {
  59176. var len = seriesModel.getLineCoords(i, lineCoords);
  59177. if (isPolyline) {
  59178. points[offset++] = len;
  59179. }
  59180. for (var k = 0; k < len; k++) {
  59181. pt = coordSys.dataToPoint(lineCoords[k], false, pt);
  59182. points[offset++] = pt[0];
  59183. points[offset++] = pt[1];
  59184. }
  59185. }
  59186. lineData.setLayout('linesPoints', points);
  59187. } else {
  59188. for (var i = params.start; i < params.end; i++) {
  59189. var itemModel = lineData.getItemModel(i);
  59190. var len = seriesModel.getLineCoords(i, lineCoords);
  59191. var pts = [];
  59192. if (isPolyline) {
  59193. for (var j = 0; j < len; j++) {
  59194. pts.push(coordSys.dataToPoint(lineCoords[j]));
  59195. }
  59196. } else {
  59197. pts[0] = coordSys.dataToPoint(lineCoords[0]);
  59198. pts[1] = coordSys.dataToPoint(lineCoords[1]);
  59199. var curveness = itemModel.get(['lineStyle', 'curveness']);
  59200. if (+curveness) {
  59201. pts[2] = [(pts[0][0] + pts[1][0]) / 2 - (pts[0][1] - pts[1][1]) * curveness, (pts[0][1] + pts[1][1]) / 2 - (pts[1][0] - pts[0][0]) * curveness];
  59202. }
  59203. }
  59204. lineData.setItemLayout(i, pts);
  59205. }
  59206. }
  59207. }
  59208. };
  59209. }
  59210. };
  59211. /*
  59212. * Licensed to the Apache Software Foundation (ASF) under one
  59213. * or more contributor license agreements. See the NOTICE file
  59214. * distributed with this work for additional information
  59215. * regarding copyright ownership. The ASF licenses this file
  59216. * to you under the Apache License, Version 2.0 (the
  59217. * "License"); you may not use this file except in compliance
  59218. * with the License. You may obtain a copy of the License at
  59219. *
  59220. * http://www.apache.org/licenses/LICENSE-2.0
  59221. *
  59222. * Unless required by applicable law or agreed to in writing,
  59223. * software distributed under the License is distributed on an
  59224. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59225. * KIND, either express or implied. See the License for the
  59226. * specific language governing permissions and limitations
  59227. * under the License.
  59228. */
  59229. /**
  59230. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59231. */
  59232. /*
  59233. * Licensed to the Apache Software Foundation (ASF) under one
  59234. * or more contributor license agreements. See the NOTICE file
  59235. * distributed with this work for additional information
  59236. * regarding copyright ownership. The ASF licenses this file
  59237. * to you under the Apache License, Version 2.0 (the
  59238. * "License"); you may not use this file except in compliance
  59239. * with the License. You may obtain a copy of the License at
  59240. *
  59241. * http://www.apache.org/licenses/LICENSE-2.0
  59242. *
  59243. * Unless required by applicable law or agreed to in writing,
  59244. * software distributed under the License is distributed on an
  59245. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59246. * KIND, either express or implied. See the License for the
  59247. * specific language governing permissions and limitations
  59248. * under the License.
  59249. */
  59250. var LinesView =
  59251. /** @class */
  59252. function (_super) {
  59253. __extends(LinesView, _super);
  59254. function LinesView() {
  59255. var _this = _super !== null && _super.apply(this, arguments) || this;
  59256. _this.type = LinesView.type;
  59257. return _this;
  59258. }
  59259. LinesView.prototype.render = function (seriesModel, ecModel, api) {
  59260. var data = seriesModel.getData();
  59261. var lineDraw = this._updateLineDraw(data, seriesModel);
  59262. var zlevel = seriesModel.get('zlevel');
  59263. var trailLength = seriesModel.get(['effect', 'trailLength']);
  59264. var zr = api.getZr(); // Avoid the drag cause ghost shadow
  59265. // FIXME Better way ?
  59266. // SVG doesn't support
  59267. var isSvg = zr.painter.getType() === 'svg';
  59268. if (!isSvg) {
  59269. zr.painter.getLayer(zlevel).clear(true);
  59270. } // Config layer with motion blur
  59271. if (this._lastZlevel != null && !isSvg) {
  59272. zr.configLayer(this._lastZlevel, {
  59273. motionBlur: false
  59274. });
  59275. }
  59276. if (this._showEffect(seriesModel) && trailLength) {
  59277. {
  59278. var notInIndividual_1 = false;
  59279. ecModel.eachSeries(function (otherSeriesModel) {
  59280. if (otherSeriesModel !== seriesModel && otherSeriesModel.get('zlevel') === zlevel) {
  59281. notInIndividual_1 = true;
  59282. }
  59283. });
  59284. notInIndividual_1 && console.warn('Lines with trail effect should have an individual zlevel');
  59285. }
  59286. if (!isSvg) {
  59287. zr.configLayer(zlevel, {
  59288. motionBlur: true,
  59289. lastFrameAlpha: Math.max(Math.min(trailLength / 10 + 0.9, 1), 0)
  59290. });
  59291. }
  59292. }
  59293. lineDraw.updateData(data);
  59294. var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
  59295. if (clipPath) {
  59296. this.group.setClipPath(clipPath);
  59297. } else {
  59298. this.group.removeClipPath();
  59299. }
  59300. this._lastZlevel = zlevel;
  59301. this._finished = true;
  59302. };
  59303. LinesView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
  59304. var data = seriesModel.getData();
  59305. var lineDraw = this._updateLineDraw(data, seriesModel);
  59306. lineDraw.incrementalPrepareUpdate(data);
  59307. this._clearLayer(api);
  59308. this._finished = false;
  59309. };
  59310. LinesView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
  59311. this._lineDraw.incrementalUpdate(taskParams, seriesModel.getData());
  59312. this._finished = taskParams.end === seriesModel.getData().count();
  59313. };
  59314. LinesView.prototype.updateTransform = function (seriesModel, ecModel, api) {
  59315. var data = seriesModel.getData();
  59316. var pipelineContext = seriesModel.pipelineContext;
  59317. if (!this._finished || pipelineContext.large || pipelineContext.progressiveRender) {
  59318. // TODO Don't have to do update in large mode. Only do it when there are millions of data.
  59319. return {
  59320. update: true
  59321. };
  59322. } else {
  59323. // TODO Use same logic with ScatterView.
  59324. // Manually update layout
  59325. var res = linesLayout.reset(seriesModel, ecModel, api);
  59326. if (res.progress) {
  59327. res.progress({
  59328. start: 0,
  59329. end: data.count(),
  59330. count: data.count()
  59331. }, data);
  59332. } // Not in large mode
  59333. this._lineDraw.updateLayout();
  59334. this._clearLayer(api);
  59335. }
  59336. };
  59337. LinesView.prototype._updateLineDraw = function (data, seriesModel) {
  59338. var lineDraw = this._lineDraw;
  59339. var hasEffect = this._showEffect(seriesModel);
  59340. var isPolyline = !!seriesModel.get('polyline');
  59341. var pipelineContext = seriesModel.pipelineContext;
  59342. var isLargeDraw = pipelineContext.large;
  59343. {
  59344. if (hasEffect && isLargeDraw) {
  59345. console.warn('Large lines not support effect');
  59346. }
  59347. }
  59348. if (!lineDraw || hasEffect !== this._hasEffet || isPolyline !== this._isPolyline || isLargeDraw !== this._isLargeDraw) {
  59349. if (lineDraw) {
  59350. lineDraw.remove();
  59351. }
  59352. lineDraw = this._lineDraw = isLargeDraw ? new LargeLineDraw() : new LineDraw(isPolyline ? hasEffect ? EffectPolyline : Polyline$2 : hasEffect ? EffectLine : Line$2);
  59353. this._hasEffet = hasEffect;
  59354. this._isPolyline = isPolyline;
  59355. this._isLargeDraw = isLargeDraw;
  59356. this.group.removeAll();
  59357. }
  59358. this.group.add(lineDraw.group);
  59359. return lineDraw;
  59360. };
  59361. LinesView.prototype._showEffect = function (seriesModel) {
  59362. return !!seriesModel.get(['effect', 'show']);
  59363. };
  59364. LinesView.prototype._clearLayer = function (api) {
  59365. // Not use motion when dragging or zooming
  59366. var zr = api.getZr();
  59367. var isSvg = zr.painter.getType() === 'svg';
  59368. if (!isSvg && this._lastZlevel != null) {
  59369. zr.painter.getLayer(this._lastZlevel).clear(true);
  59370. }
  59371. };
  59372. LinesView.prototype.remove = function (ecModel, api) {
  59373. this._lineDraw && this._lineDraw.remove();
  59374. this._lineDraw = null; // Clear motion when lineDraw is removed
  59375. this._clearLayer(api);
  59376. };
  59377. LinesView.type = 'lines';
  59378. return LinesView;
  59379. }(ChartView);
  59380. /*
  59381. * Licensed to the Apache Software Foundation (ASF) under one
  59382. * or more contributor license agreements. See the NOTICE file
  59383. * distributed with this work for additional information
  59384. * regarding copyright ownership. The ASF licenses this file
  59385. * to you under the Apache License, Version 2.0 (the
  59386. * "License"); you may not use this file except in compliance
  59387. * with the License. You may obtain a copy of the License at
  59388. *
  59389. * http://www.apache.org/licenses/LICENSE-2.0
  59390. *
  59391. * Unless required by applicable law or agreed to in writing,
  59392. * software distributed under the License is distributed on an
  59393. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59394. * KIND, either express or implied. See the License for the
  59395. * specific language governing permissions and limitations
  59396. * under the License.
  59397. */
  59398. /**
  59399. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59400. */
  59401. /*
  59402. * Licensed to the Apache Software Foundation (ASF) under one
  59403. * or more contributor license agreements. See the NOTICE file
  59404. * distributed with this work for additional information
  59405. * regarding copyright ownership. The ASF licenses this file
  59406. * to you under the Apache License, Version 2.0 (the
  59407. * "License"); you may not use this file except in compliance
  59408. * with the License. You may obtain a copy of the License at
  59409. *
  59410. * http://www.apache.org/licenses/LICENSE-2.0
  59411. *
  59412. * Unless required by applicable law or agreed to in writing,
  59413. * software distributed under the License is distributed on an
  59414. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59415. * KIND, either express or implied. See the License for the
  59416. * specific language governing permissions and limitations
  59417. * under the License.
  59418. */
  59419. /* global Uint32Array, Float64Array, Float32Array */
  59420. var Uint32Arr = typeof Uint32Array === 'undefined' ? Array : Uint32Array;
  59421. var Float64Arr = typeof Float64Array === 'undefined' ? Array : Float64Array;
  59422. function compatEc2(seriesOpt) {
  59423. var data = seriesOpt.data;
  59424. if (data && data[0] && data[0][0] && data[0][0].coord) {
  59425. {
  59426. console.warn('Lines data configuration has been changed to' + ' { coords:[[1,2],[2,3]] }');
  59427. }
  59428. seriesOpt.data = map(data, function (itemOpt) {
  59429. var coords = [itemOpt[0].coord, itemOpt[1].coord];
  59430. var target = {
  59431. coords: coords
  59432. };
  59433. if (itemOpt[0].name) {
  59434. target.fromName = itemOpt[0].name;
  59435. }
  59436. if (itemOpt[1].name) {
  59437. target.toName = itemOpt[1].name;
  59438. }
  59439. return mergeAll([target, itemOpt[0], itemOpt[1]]);
  59440. });
  59441. }
  59442. }
  59443. var LinesSeriesModel =
  59444. /** @class */
  59445. function (_super) {
  59446. __extends(LinesSeriesModel, _super);
  59447. function LinesSeriesModel() {
  59448. var _this = _super !== null && _super.apply(this, arguments) || this;
  59449. _this.type = LinesSeriesModel.type;
  59450. _this.visualStyleAccessPath = 'lineStyle';
  59451. _this.visualDrawType = 'stroke';
  59452. return _this;
  59453. }
  59454. LinesSeriesModel.prototype.init = function (option) {
  59455. // The input data may be null/undefined.
  59456. option.data = option.data || []; // Not using preprocessor because mergeOption may not have series.type
  59457. compatEc2(option);
  59458. var result = this._processFlatCoordsArray(option.data);
  59459. this._flatCoords = result.flatCoords;
  59460. this._flatCoordsOffset = result.flatCoordsOffset;
  59461. if (result.flatCoords) {
  59462. option.data = new Float32Array(result.count);
  59463. }
  59464. _super.prototype.init.apply(this, arguments);
  59465. };
  59466. LinesSeriesModel.prototype.mergeOption = function (option) {
  59467. compatEc2(option);
  59468. if (option.data) {
  59469. // Only update when have option data to merge.
  59470. var result = this._processFlatCoordsArray(option.data);
  59471. this._flatCoords = result.flatCoords;
  59472. this._flatCoordsOffset = result.flatCoordsOffset;
  59473. if (result.flatCoords) {
  59474. option.data = new Float32Array(result.count);
  59475. }
  59476. }
  59477. _super.prototype.mergeOption.apply(this, arguments);
  59478. };
  59479. LinesSeriesModel.prototype.appendData = function (params) {
  59480. var result = this._processFlatCoordsArray(params.data);
  59481. if (result.flatCoords) {
  59482. if (!this._flatCoords) {
  59483. this._flatCoords = result.flatCoords;
  59484. this._flatCoordsOffset = result.flatCoordsOffset;
  59485. } else {
  59486. this._flatCoords = concatArray(this._flatCoords, result.flatCoords);
  59487. this._flatCoordsOffset = concatArray(this._flatCoordsOffset, result.flatCoordsOffset);
  59488. }
  59489. params.data = new Float32Array(result.count);
  59490. }
  59491. this.getRawData().appendData(params.data);
  59492. };
  59493. LinesSeriesModel.prototype._getCoordsFromItemModel = function (idx) {
  59494. var itemModel = this.getData().getItemModel(idx);
  59495. var coords = itemModel.option instanceof Array ? itemModel.option : itemModel.getShallow('coords');
  59496. {
  59497. if (!(coords instanceof Array && coords.length > 0 && coords[0] instanceof Array)) {
  59498. throw new Error('Invalid coords ' + JSON.stringify(coords) + '. Lines must have 2d coords array in data item.');
  59499. }
  59500. }
  59501. return coords;
  59502. };
  59503. LinesSeriesModel.prototype.getLineCoordsCount = function (idx) {
  59504. if (this._flatCoordsOffset) {
  59505. return this._flatCoordsOffset[idx * 2 + 1];
  59506. } else {
  59507. return this._getCoordsFromItemModel(idx).length;
  59508. }
  59509. };
  59510. LinesSeriesModel.prototype.getLineCoords = function (idx, out) {
  59511. if (this._flatCoordsOffset) {
  59512. var offset = this._flatCoordsOffset[idx * 2];
  59513. var len = this._flatCoordsOffset[idx * 2 + 1];
  59514. for (var i = 0; i < len; i++) {
  59515. out[i] = out[i] || [];
  59516. out[i][0] = this._flatCoords[offset + i * 2];
  59517. out[i][1] = this._flatCoords[offset + i * 2 + 1];
  59518. }
  59519. return len;
  59520. } else {
  59521. var coords = this._getCoordsFromItemModel(idx);
  59522. for (var i = 0; i < coords.length; i++) {
  59523. out[i] = out[i] || [];
  59524. out[i][0] = coords[i][0];
  59525. out[i][1] = coords[i][1];
  59526. }
  59527. return coords.length;
  59528. }
  59529. };
  59530. LinesSeriesModel.prototype._processFlatCoordsArray = function (data) {
  59531. var startOffset = 0;
  59532. if (this._flatCoords) {
  59533. startOffset = this._flatCoords.length;
  59534. } // Stored as a typed array. In format
  59535. // Points Count(2) | x | y | x | y | Points Count(3) | x | y | x | y | x | y |
  59536. if (typeof data[0] === 'number') {
  59537. var len = data.length; // Store offset and len of each segment
  59538. var coordsOffsetAndLenStorage = new Uint32Arr(len);
  59539. var coordsStorage = new Float64Arr(len);
  59540. var coordsCursor = 0;
  59541. var offsetCursor = 0;
  59542. var dataCount = 0;
  59543. for (var i = 0; i < len;) {
  59544. dataCount++;
  59545. var count = data[i++]; // Offset
  59546. coordsOffsetAndLenStorage[offsetCursor++] = coordsCursor + startOffset; // Len
  59547. coordsOffsetAndLenStorage[offsetCursor++] = count;
  59548. for (var k = 0; k < count; k++) {
  59549. var x = data[i++];
  59550. var y = data[i++];
  59551. coordsStorage[coordsCursor++] = x;
  59552. coordsStorage[coordsCursor++] = y;
  59553. if (i > len) {
  59554. {
  59555. throw new Error('Invalid data format.');
  59556. }
  59557. }
  59558. }
  59559. }
  59560. return {
  59561. flatCoordsOffset: new Uint32Array(coordsOffsetAndLenStorage.buffer, 0, offsetCursor),
  59562. flatCoords: coordsStorage,
  59563. count: dataCount
  59564. };
  59565. }
  59566. return {
  59567. flatCoordsOffset: null,
  59568. flatCoords: null,
  59569. count: data.length
  59570. };
  59571. };
  59572. LinesSeriesModel.prototype.getInitialData = function (option, ecModel) {
  59573. {
  59574. var CoordSys = CoordinateSystemManager.get(option.coordinateSystem);
  59575. if (!CoordSys) {
  59576. throw new Error('Unkown coordinate system ' + option.coordinateSystem);
  59577. }
  59578. }
  59579. var lineData = new List(['value'], this);
  59580. lineData.hasItemOption = false;
  59581. lineData.initData(option.data, [], function (dataItem, dimName, dataIndex, dimIndex) {
  59582. // dataItem is simply coords
  59583. if (dataItem instanceof Array) {
  59584. return NaN;
  59585. } else {
  59586. lineData.hasItemOption = true;
  59587. var value = dataItem.value;
  59588. if (value != null) {
  59589. return value instanceof Array ? value[dimIndex] : value;
  59590. }
  59591. }
  59592. });
  59593. return lineData;
  59594. };
  59595. LinesSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  59596. var data = this.getData();
  59597. var itemModel = data.getItemModel(dataIndex);
  59598. var name = itemModel.get('name');
  59599. if (name) {
  59600. return name;
  59601. }
  59602. var fromName = itemModel.get('fromName');
  59603. var toName = itemModel.get('toName');
  59604. var nameArr = [];
  59605. fromName != null && nameArr.push(fromName);
  59606. toName != null && nameArr.push(toName);
  59607. return createTooltipMarkup('nameValue', {
  59608. name: nameArr.join(' > ')
  59609. });
  59610. };
  59611. LinesSeriesModel.prototype.preventIncremental = function () {
  59612. return !!this.get(['effect', 'show']);
  59613. };
  59614. LinesSeriesModel.prototype.getProgressive = function () {
  59615. var progressive = this.option.progressive;
  59616. if (progressive == null) {
  59617. return this.option.large ? 1e4 : this.get('progressive');
  59618. }
  59619. return progressive;
  59620. };
  59621. LinesSeriesModel.prototype.getProgressiveThreshold = function () {
  59622. var progressiveThreshold = this.option.progressiveThreshold;
  59623. if (progressiveThreshold == null) {
  59624. return this.option.large ? 2e4 : this.get('progressiveThreshold');
  59625. }
  59626. return progressiveThreshold;
  59627. };
  59628. LinesSeriesModel.type = 'series.lines';
  59629. LinesSeriesModel.dependencies = ['grid', 'polar', 'geo', 'calendar'];
  59630. LinesSeriesModel.defaultOption = {
  59631. coordinateSystem: 'geo',
  59632. zlevel: 0,
  59633. z: 2,
  59634. legendHoverLink: true,
  59635. // Cartesian coordinate system
  59636. xAxisIndex: 0,
  59637. yAxisIndex: 0,
  59638. symbol: ['none', 'none'],
  59639. symbolSize: [10, 10],
  59640. // Geo coordinate system
  59641. geoIndex: 0,
  59642. effect: {
  59643. show: false,
  59644. period: 4,
  59645. constantSpeed: 0,
  59646. symbol: 'circle',
  59647. symbolSize: 3,
  59648. loop: true,
  59649. trailLength: 0.2
  59650. },
  59651. large: false,
  59652. // Available when large is true
  59653. largeThreshold: 2000,
  59654. polyline: false,
  59655. clip: true,
  59656. label: {
  59657. show: false,
  59658. position: 'end' // distance: 5,
  59659. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  59660. },
  59661. lineStyle: {
  59662. opacity: 0.5
  59663. }
  59664. };
  59665. return LinesSeriesModel;
  59666. }(SeriesModel);
  59667. /*
  59668. * Licensed to the Apache Software Foundation (ASF) under one
  59669. * or more contributor license agreements. See the NOTICE file
  59670. * distributed with this work for additional information
  59671. * regarding copyright ownership. The ASF licenses this file
  59672. * to you under the Apache License, Version 2.0 (the
  59673. * "License"); you may not use this file except in compliance
  59674. * with the License. You may obtain a copy of the License at
  59675. *
  59676. * http://www.apache.org/licenses/LICENSE-2.0
  59677. *
  59678. * Unless required by applicable law or agreed to in writing,
  59679. * software distributed under the License is distributed on an
  59680. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59681. * KIND, either express or implied. See the License for the
  59682. * specific language governing permissions and limitations
  59683. * under the License.
  59684. */
  59685. /**
  59686. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59687. */
  59688. /*
  59689. * Licensed to the Apache Software Foundation (ASF) under one
  59690. * or more contributor license agreements. See the NOTICE file
  59691. * distributed with this work for additional information
  59692. * regarding copyright ownership. The ASF licenses this file
  59693. * to you under the Apache License, Version 2.0 (the
  59694. * "License"); you may not use this file except in compliance
  59695. * with the License. You may obtain a copy of the License at
  59696. *
  59697. * http://www.apache.org/licenses/LICENSE-2.0
  59698. *
  59699. * Unless required by applicable law or agreed to in writing,
  59700. * software distributed under the License is distributed on an
  59701. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59702. * KIND, either express or implied. See the License for the
  59703. * specific language governing permissions and limitations
  59704. * under the License.
  59705. */
  59706. function normalize$2(a) {
  59707. if (!(a instanceof Array)) {
  59708. a = [a, a];
  59709. }
  59710. return a;
  59711. }
  59712. var linesVisual = {
  59713. seriesType: 'lines',
  59714. reset: function (seriesModel) {
  59715. var symbolType = normalize$2(seriesModel.get('symbol'));
  59716. var symbolSize = normalize$2(seriesModel.get('symbolSize'));
  59717. var data = seriesModel.getData();
  59718. data.setVisual('fromSymbol', symbolType && symbolType[0]);
  59719. data.setVisual('toSymbol', symbolType && symbolType[1]);
  59720. data.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  59721. data.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  59722. function dataEach(data, idx) {
  59723. var itemModel = data.getItemModel(idx);
  59724. var symbolType = normalize$2(itemModel.getShallow('symbol', true));
  59725. var symbolSize = normalize$2(itemModel.getShallow('symbolSize', true));
  59726. symbolType[0] && data.setItemVisual(idx, 'fromSymbol', symbolType[0]);
  59727. symbolType[1] && data.setItemVisual(idx, 'toSymbol', symbolType[1]);
  59728. symbolSize[0] && data.setItemVisual(idx, 'fromSymbolSize', symbolSize[0]);
  59729. symbolSize[1] && data.setItemVisual(idx, 'toSymbolSize', symbolSize[1]);
  59730. }
  59731. return {
  59732. dataEach: data.hasItemOption ? dataEach : null
  59733. };
  59734. }
  59735. };
  59736. /*
  59737. * Licensed to the Apache Software Foundation (ASF) under one
  59738. * or more contributor license agreements. See the NOTICE file
  59739. * distributed with this work for additional information
  59740. * regarding copyright ownership. The ASF licenses this file
  59741. * to you under the Apache License, Version 2.0 (the
  59742. * "License"); you may not use this file except in compliance
  59743. * with the License. You may obtain a copy of the License at
  59744. *
  59745. * http://www.apache.org/licenses/LICENSE-2.0
  59746. *
  59747. * Unless required by applicable law or agreed to in writing,
  59748. * software distributed under the License is distributed on an
  59749. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59750. * KIND, either express or implied. See the License for the
  59751. * specific language governing permissions and limitations
  59752. * under the License.
  59753. */
  59754. /**
  59755. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59756. */
  59757. /*
  59758. * Licensed to the Apache Software Foundation (ASF) under one
  59759. * or more contributor license agreements. See the NOTICE file
  59760. * distributed with this work for additional information
  59761. * regarding copyright ownership. The ASF licenses this file
  59762. * to you under the Apache License, Version 2.0 (the
  59763. * "License"); you may not use this file except in compliance
  59764. * with the License. You may obtain a copy of the License at
  59765. *
  59766. * http://www.apache.org/licenses/LICENSE-2.0
  59767. *
  59768. * Unless required by applicable law or agreed to in writing,
  59769. * software distributed under the License is distributed on an
  59770. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59771. * KIND, either express or implied. See the License for the
  59772. * specific language governing permissions and limitations
  59773. * under the License.
  59774. */
  59775. function install$17(registers) {
  59776. registers.registerChartView(LinesView);
  59777. registers.registerSeriesModel(LinesSeriesModel);
  59778. registers.registerLayout(linesLayout);
  59779. registers.registerVisual(linesVisual);
  59780. }
  59781. /*
  59782. * Licensed to the Apache Software Foundation (ASF) under one
  59783. * or more contributor license agreements. See the NOTICE file
  59784. * distributed with this work for additional information
  59785. * regarding copyright ownership. The ASF licenses this file
  59786. * to you under the Apache License, Version 2.0 (the
  59787. * "License"); you may not use this file except in compliance
  59788. * with the License. You may obtain a copy of the License at
  59789. *
  59790. * http://www.apache.org/licenses/LICENSE-2.0
  59791. *
  59792. * Unless required by applicable law or agreed to in writing,
  59793. * software distributed under the License is distributed on an
  59794. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59795. * KIND, either express or implied. See the License for the
  59796. * specific language governing permissions and limitations
  59797. * under the License.
  59798. */
  59799. /**
  59800. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59801. */
  59802. /*
  59803. * Licensed to the Apache Software Foundation (ASF) under one
  59804. * or more contributor license agreements. See the NOTICE file
  59805. * distributed with this work for additional information
  59806. * regarding copyright ownership. The ASF licenses this file
  59807. * to you under the Apache License, Version 2.0 (the
  59808. * "License"); you may not use this file except in compliance
  59809. * with the License. You may obtain a copy of the License at
  59810. *
  59811. * http://www.apache.org/licenses/LICENSE-2.0
  59812. *
  59813. * Unless required by applicable law or agreed to in writing,
  59814. * software distributed under the License is distributed on an
  59815. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59816. * KIND, either express or implied. See the License for the
  59817. * specific language governing permissions and limitations
  59818. * under the License.
  59819. */
  59820. use(install$17);
  59821. /*
  59822. * Licensed to the Apache Software Foundation (ASF) under one
  59823. * or more contributor license agreements. See the NOTICE file
  59824. * distributed with this work for additional information
  59825. * regarding copyright ownership. The ASF licenses this file
  59826. * to you under the Apache License, Version 2.0 (the
  59827. * "License"); you may not use this file except in compliance
  59828. * with the License. You may obtain a copy of the License at
  59829. *
  59830. * http://www.apache.org/licenses/LICENSE-2.0
  59831. *
  59832. * Unless required by applicable law or agreed to in writing,
  59833. * software distributed under the License is distributed on an
  59834. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59835. * KIND, either express or implied. See the License for the
  59836. * specific language governing permissions and limitations
  59837. * under the License.
  59838. */
  59839. /**
  59840. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59841. */
  59842. /*
  59843. * Licensed to the Apache Software Foundation (ASF) under one
  59844. * or more contributor license agreements. See the NOTICE file
  59845. * distributed with this work for additional information
  59846. * regarding copyright ownership. The ASF licenses this file
  59847. * to you under the Apache License, Version 2.0 (the
  59848. * "License"); you may not use this file except in compliance
  59849. * with the License. You may obtain a copy of the License at
  59850. *
  59851. * http://www.apache.org/licenses/LICENSE-2.0
  59852. *
  59853. * Unless required by applicable law or agreed to in writing,
  59854. * software distributed under the License is distributed on an
  59855. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59856. * KIND, either express or implied. See the License for the
  59857. * specific language governing permissions and limitations
  59858. * under the License.
  59859. */
  59860. function categoryFilter(ecModel) {
  59861. var legendModels = ecModel.findComponents({
  59862. mainType: 'legend'
  59863. });
  59864. if (!legendModels || !legendModels.length) {
  59865. return;
  59866. }
  59867. ecModel.eachSeriesByType('graph', function (graphSeries) {
  59868. var categoriesData = graphSeries.getCategoriesData();
  59869. var graph = graphSeries.getGraph();
  59870. var data = graph.data;
  59871. var categoryNames = categoriesData.mapArray(categoriesData.getName);
  59872. data.filterSelf(function (idx) {
  59873. var model = data.getItemModel(idx);
  59874. var category = model.getShallow('category');
  59875. if (category != null) {
  59876. if (typeof category === 'number') {
  59877. category = categoryNames[category];
  59878. } // If in any legend component the status is not selected.
  59879. for (var i = 0; i < legendModels.length; i++) {
  59880. if (!legendModels[i].isSelected(category)) {
  59881. return false;
  59882. }
  59883. }
  59884. }
  59885. return true;
  59886. });
  59887. });
  59888. }
  59889. /*
  59890. * Licensed to the Apache Software Foundation (ASF) under one
  59891. * or more contributor license agreements. See the NOTICE file
  59892. * distributed with this work for additional information
  59893. * regarding copyright ownership. The ASF licenses this file
  59894. * to you under the Apache License, Version 2.0 (the
  59895. * "License"); you may not use this file except in compliance
  59896. * with the License. You may obtain a copy of the License at
  59897. *
  59898. * http://www.apache.org/licenses/LICENSE-2.0
  59899. *
  59900. * Unless required by applicable law or agreed to in writing,
  59901. * software distributed under the License is distributed on an
  59902. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59903. * KIND, either express or implied. See the License for the
  59904. * specific language governing permissions and limitations
  59905. * under the License.
  59906. */
  59907. /**
  59908. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59909. */
  59910. /*
  59911. * Licensed to the Apache Software Foundation (ASF) under one
  59912. * or more contributor license agreements. See the NOTICE file
  59913. * distributed with this work for additional information
  59914. * regarding copyright ownership. The ASF licenses this file
  59915. * to you under the Apache License, Version 2.0 (the
  59916. * "License"); you may not use this file except in compliance
  59917. * with the License. You may obtain a copy of the License at
  59918. *
  59919. * http://www.apache.org/licenses/LICENSE-2.0
  59920. *
  59921. * Unless required by applicable law or agreed to in writing,
  59922. * software distributed under the License is distributed on an
  59923. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59924. * KIND, either express or implied. See the License for the
  59925. * specific language governing permissions and limitations
  59926. * under the License.
  59927. */
  59928. function categoryVisual(ecModel) {
  59929. var paletteScope = {};
  59930. ecModel.eachSeriesByType('graph', function (seriesModel) {
  59931. var categoriesData = seriesModel.getCategoriesData();
  59932. var data = seriesModel.getData();
  59933. var categoryNameIdxMap = {};
  59934. categoriesData.each(function (idx) {
  59935. var name = categoriesData.getName(idx); // Add prefix to avoid conflict with Object.prototype.
  59936. categoryNameIdxMap['ec-' + name] = idx;
  59937. var itemModel = categoriesData.getItemModel(idx);
  59938. var style = itemModel.getModel('itemStyle').getItemStyle();
  59939. if (!style.fill) {
  59940. // Get color from palette.
  59941. style.fill = seriesModel.getColorFromPalette(name, paletteScope);
  59942. }
  59943. categoriesData.setItemVisual(idx, 'style', style);
  59944. var symbolVisualList = ['symbol', 'symbolSize', 'symbolKeepAspect'];
  59945. for (var i = 0; i < symbolVisualList.length; i++) {
  59946. var symbolVisual = itemModel.getShallow(symbolVisualList[i], true);
  59947. if (symbolVisual != null) {
  59948. categoriesData.setItemVisual(idx, symbolVisualList[i], symbolVisual);
  59949. }
  59950. }
  59951. }); // Assign category color to visual
  59952. if (categoriesData.count()) {
  59953. data.each(function (idx) {
  59954. var model = data.getItemModel(idx);
  59955. var categoryIdx = model.getShallow('category');
  59956. if (categoryIdx != null) {
  59957. if (typeof categoryIdx === 'string') {
  59958. categoryIdx = categoryNameIdxMap['ec-' + categoryIdx];
  59959. }
  59960. var categoryStyle = categoriesData.getItemVisual(categoryIdx, 'style');
  59961. var style = data.ensureUniqueItemVisual(idx, 'style');
  59962. extend(style, categoryStyle);
  59963. var visualList = ['symbol', 'symbolSize', 'symbolKeepAspect'];
  59964. for (var i = 0; i < visualList.length; i++) {
  59965. data.setItemVisual(idx, visualList[i], categoriesData.getItemVisual(categoryIdx, visualList[i]));
  59966. }
  59967. }
  59968. });
  59969. }
  59970. });
  59971. }
  59972. /*
  59973. * Licensed to the Apache Software Foundation (ASF) under one
  59974. * or more contributor license agreements. See the NOTICE file
  59975. * distributed with this work for additional information
  59976. * regarding copyright ownership. The ASF licenses this file
  59977. * to you under the Apache License, Version 2.0 (the
  59978. * "License"); you may not use this file except in compliance
  59979. * with the License. You may obtain a copy of the License at
  59980. *
  59981. * http://www.apache.org/licenses/LICENSE-2.0
  59982. *
  59983. * Unless required by applicable law or agreed to in writing,
  59984. * software distributed under the License is distributed on an
  59985. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  59986. * KIND, either express or implied. See the License for the
  59987. * specific language governing permissions and limitations
  59988. * under the License.
  59989. */
  59990. /**
  59991. * AUTO-GENERATED FILE. DO NOT MODIFY.
  59992. */
  59993. /*
  59994. * Licensed to the Apache Software Foundation (ASF) under one
  59995. * or more contributor license agreements. See the NOTICE file
  59996. * distributed with this work for additional information
  59997. * regarding copyright ownership. The ASF licenses this file
  59998. * to you under the Apache License, Version 2.0 (the
  59999. * "License"); you may not use this file except in compliance
  60000. * with the License. You may obtain a copy of the License at
  60001. *
  60002. * http://www.apache.org/licenses/LICENSE-2.0
  60003. *
  60004. * Unless required by applicable law or agreed to in writing,
  60005. * software distributed under the License is distributed on an
  60006. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60007. * KIND, either express or implied. See the License for the
  60008. * specific language governing permissions and limitations
  60009. * under the License.
  60010. */
  60011. function normalize$3(a) {
  60012. if (!(a instanceof Array)) {
  60013. a = [a, a];
  60014. }
  60015. return a;
  60016. }
  60017. function graphEdgeVisual(ecModel) {
  60018. ecModel.eachSeriesByType('graph', function (seriesModel) {
  60019. var graph = seriesModel.getGraph();
  60020. var edgeData = seriesModel.getEdgeData();
  60021. var symbolType = normalize$3(seriesModel.get('edgeSymbol'));
  60022. var symbolSize = normalize$3(seriesModel.get('edgeSymbolSize')); // const colorQuery = ['lineStyle', 'color'] as const;
  60023. // const opacityQuery = ['lineStyle', 'opacity'] as const;
  60024. edgeData.setVisual('fromSymbol', symbolType && symbolType[0]);
  60025. edgeData.setVisual('toSymbol', symbolType && symbolType[1]);
  60026. edgeData.setVisual('fromSymbolSize', symbolSize && symbolSize[0]);
  60027. edgeData.setVisual('toSymbolSize', symbolSize && symbolSize[1]);
  60028. edgeData.setVisual('style', seriesModel.getModel('lineStyle').getLineStyle());
  60029. edgeData.each(function (idx) {
  60030. var itemModel = edgeData.getItemModel(idx);
  60031. var edge = graph.getEdgeByIndex(idx);
  60032. var symbolType = normalize$3(itemModel.getShallow('symbol', true));
  60033. var symbolSize = normalize$3(itemModel.getShallow('symbolSize', true)); // Edge visual must after node visual
  60034. var style = itemModel.getModel('lineStyle').getLineStyle();
  60035. var existsStyle = edgeData.ensureUniqueItemVisual(idx, 'style');
  60036. extend(existsStyle, style);
  60037. switch (existsStyle.stroke) {
  60038. case 'source':
  60039. {
  60040. var nodeStyle = edge.node1.getVisual('style');
  60041. existsStyle.stroke = nodeStyle && nodeStyle.fill;
  60042. break;
  60043. }
  60044. case 'target':
  60045. {
  60046. var nodeStyle = edge.node2.getVisual('style');
  60047. existsStyle.stroke = nodeStyle && nodeStyle.fill;
  60048. break;
  60049. }
  60050. }
  60051. symbolType[0] && edge.setVisual('fromSymbol', symbolType[0]);
  60052. symbolType[1] && edge.setVisual('toSymbol', symbolType[1]);
  60053. symbolSize[0] && edge.setVisual('fromSymbolSize', symbolSize[0]);
  60054. symbolSize[1] && edge.setVisual('toSymbolSize', symbolSize[1]);
  60055. });
  60056. });
  60057. }
  60058. /*
  60059. * Licensed to the Apache Software Foundation (ASF) under one
  60060. * or more contributor license agreements. See the NOTICE file
  60061. * distributed with this work for additional information
  60062. * regarding copyright ownership. The ASF licenses this file
  60063. * to you under the Apache License, Version 2.0 (the
  60064. * "License"); you may not use this file except in compliance
  60065. * with the License. You may obtain a copy of the License at
  60066. *
  60067. * http://www.apache.org/licenses/LICENSE-2.0
  60068. *
  60069. * Unless required by applicable law or agreed to in writing,
  60070. * software distributed under the License is distributed on an
  60071. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60072. * KIND, either express or implied. See the License for the
  60073. * specific language governing permissions and limitations
  60074. * under the License.
  60075. */
  60076. /**
  60077. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60078. */
  60079. /*
  60080. * Licensed to the Apache Software Foundation (ASF) under one
  60081. * or more contributor license agreements. See the NOTICE file
  60082. * distributed with this work for additional information
  60083. * regarding copyright ownership. The ASF licenses this file
  60084. * to you under the Apache License, Version 2.0 (the
  60085. * "License"); you may not use this file except in compliance
  60086. * with the License. You may obtain a copy of the License at
  60087. *
  60088. * http://www.apache.org/licenses/LICENSE-2.0
  60089. *
  60090. * Unless required by applicable law or agreed to in writing,
  60091. * software distributed under the License is distributed on an
  60092. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60093. * KIND, either express or implied. See the License for the
  60094. * specific language governing permissions and limitations
  60095. * under the License.
  60096. */
  60097. // @ts-nocheck
  60098. var KEY_DELIMITER = '-->';
  60099. /**
  60100. * params handler
  60101. * @param {module:echarts/model/SeriesModel} seriesModel
  60102. * @returns {*}
  60103. */
  60104. var getAutoCurvenessParams = function (seriesModel) {
  60105. return seriesModel.get('autoCurveness') || null;
  60106. };
  60107. /**
  60108. * Generate a list of edge curvatures, 20 is the default
  60109. * @param {module:echarts/model/SeriesModel} seriesModel
  60110. * @param {number} appendLength
  60111. * @return 20 => [0, -0.2, 0.2, -0.4, 0.4, -0.6, 0.6, -0.8, 0.8, -1, 1, -1.2, 1.2, -1.4, 1.4, -1.6, 1.6, -1.8, 1.8, -2]
  60112. */
  60113. var createCurveness = function (seriesModel, appendLength) {
  60114. var autoCurvenessParmas = getAutoCurvenessParams(seriesModel);
  60115. var length = 20;
  60116. var curvenessList = []; // handler the function set
  60117. if (typeof autoCurvenessParmas === 'number') {
  60118. length = autoCurvenessParmas;
  60119. } else if (isArray(autoCurvenessParmas)) {
  60120. seriesModel.__curvenessList = autoCurvenessParmas;
  60121. return;
  60122. } // append length
  60123. if (appendLength > length) {
  60124. length = appendLength;
  60125. } // make sure the length is even
  60126. var len = length % 2 ? length + 2 : length + 3;
  60127. curvenessList = [];
  60128. for (var i = 0; i < len; i++) {
  60129. curvenessList.push((i % 2 ? i + 1 : i) / 10 * (i % 2 ? -1 : 1));
  60130. }
  60131. seriesModel.__curvenessList = curvenessList;
  60132. };
  60133. /**
  60134. * Create different cache key data in the positive and negative directions, in order to set the curvature later
  60135. * @param {number|string|module:echarts/data/Graph.Node} n1
  60136. * @param {number|string|module:echarts/data/Graph.Node} n2
  60137. * @param {module:echarts/model/SeriesModel} seriesModel
  60138. * @returns {string} key
  60139. */
  60140. var getKeyOfEdges = function (n1, n2, seriesModel) {
  60141. var source = [n1.id, n1.dataIndex].join('.');
  60142. var target = [n2.id, n2.dataIndex].join('.');
  60143. return [seriesModel.uid, source, target].join(KEY_DELIMITER);
  60144. };
  60145. /**
  60146. * get opposite key
  60147. * @param {string} key
  60148. * @returns {string}
  60149. */
  60150. var getOppositeKey = function (key) {
  60151. var keys$$1 = key.split(KEY_DELIMITER);
  60152. return [keys$$1[0], keys$$1[2], keys$$1[1]].join(KEY_DELIMITER);
  60153. };
  60154. /**
  60155. * get edgeMap with key
  60156. * @param edge
  60157. * @param {module:echarts/model/SeriesModel} seriesModel
  60158. */
  60159. var getEdgeFromMap = function (edge, seriesModel) {
  60160. var key = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
  60161. return seriesModel.__edgeMap[key];
  60162. };
  60163. /**
  60164. * calculate all cases total length
  60165. * @param edge
  60166. * @param seriesModel
  60167. * @returns {number}
  60168. */
  60169. var getTotalLengthBetweenNodes = function (edge, seriesModel) {
  60170. var len = getEdgeMapLengthWithKey(getKeyOfEdges(edge.node1, edge.node2, seriesModel), seriesModel);
  60171. var lenV = getEdgeMapLengthWithKey(getKeyOfEdges(edge.node2, edge.node1, seriesModel), seriesModel);
  60172. return len + lenV;
  60173. };
  60174. /**
  60175. *
  60176. * @param key
  60177. */
  60178. var getEdgeMapLengthWithKey = function (key, seriesModel) {
  60179. var edgeMap = seriesModel.__edgeMap;
  60180. return edgeMap[key] ? edgeMap[key].length : 0;
  60181. };
  60182. /**
  60183. * Count the number of edges between the same two points, used to obtain the curvature table and the parity of the edge
  60184. * @see /graph/GraphSeries.js@getInitialData
  60185. * @param {module:echarts/model/SeriesModel} seriesModel
  60186. */
  60187. function initCurvenessList(seriesModel) {
  60188. if (!getAutoCurvenessParams(seriesModel)) {
  60189. return;
  60190. }
  60191. seriesModel.__curvenessList = [];
  60192. seriesModel.__edgeMap = {}; // calc the array of curveness List
  60193. createCurveness(seriesModel);
  60194. }
  60195. /**
  60196. * set edgeMap with key
  60197. * @param {number|string|module:echarts/data/Graph.Node} n1
  60198. * @param {number|string|module:echarts/data/Graph.Node} n2
  60199. * @param {module:echarts/model/SeriesModel} seriesModel
  60200. * @param {number} index
  60201. */
  60202. function createEdgeMapForCurveness(n1, n2, seriesModel, index) {
  60203. if (!getAutoCurvenessParams(seriesModel)) {
  60204. return;
  60205. }
  60206. var key = getKeyOfEdges(n1, n2, seriesModel);
  60207. var edgeMap = seriesModel.__edgeMap;
  60208. var oppositeEdges = edgeMap[getOppositeKey(key)]; // set direction
  60209. if (edgeMap[key] && !oppositeEdges) {
  60210. edgeMap[key].isForward = true;
  60211. } else if (oppositeEdges && edgeMap[key]) {
  60212. oppositeEdges.isForward = true;
  60213. edgeMap[key].isForward = false;
  60214. }
  60215. edgeMap[key] = edgeMap[key] || [];
  60216. edgeMap[key].push(index);
  60217. }
  60218. /**
  60219. * get curvature for edge
  60220. * @param edge
  60221. * @param {module:echarts/model/SeriesModel} seriesModel
  60222. * @param index
  60223. */
  60224. function getCurvenessForEdge(edge, seriesModel, index, needReverse) {
  60225. var autoCurvenessParams = getAutoCurvenessParams(seriesModel);
  60226. var isArrayParam = isArray(autoCurvenessParams);
  60227. if (!autoCurvenessParams) {
  60228. return null;
  60229. }
  60230. var edgeArray = getEdgeFromMap(edge, seriesModel);
  60231. if (!edgeArray) {
  60232. return null;
  60233. }
  60234. var edgeIndex = -1;
  60235. for (var i = 0; i < edgeArray.length; i++) {
  60236. if (edgeArray[i] === index) {
  60237. edgeIndex = i;
  60238. break;
  60239. }
  60240. } // if totalLen is Longer createCurveness
  60241. var totalLen = getTotalLengthBetweenNodes(edge, seriesModel);
  60242. createCurveness(seriesModel, totalLen);
  60243. edge.lineStyle = edge.lineStyle || {}; // if is opposite edge, must set curvenss to opposite number
  60244. var curKey = getKeyOfEdges(edge.node1, edge.node2, seriesModel);
  60245. var curvenessList = seriesModel.__curvenessList; // if pass array no need parity
  60246. var parityCorrection = isArrayParam ? 0 : totalLen % 2 ? 0 : 1;
  60247. if (!edgeArray.isForward) {
  60248. // the opposite edge show outside
  60249. var oppositeKey = getOppositeKey(curKey);
  60250. var len = getEdgeMapLengthWithKey(oppositeKey, seriesModel);
  60251. var resValue = curvenessList[edgeIndex + len + parityCorrection]; // isNeedReverse, simple, force type need reverse the curveness in the junction of the forword and the opposite
  60252. if (needReverse) {
  60253. // set as array may make the parity handle with the len of opposite
  60254. if (isArrayParam) {
  60255. if (autoCurvenessParams && autoCurvenessParams[0] === 0) {
  60256. return (len + parityCorrection) % 2 ? resValue : -resValue;
  60257. } else {
  60258. return ((len % 2 ? 0 : 1) + parityCorrection) % 2 ? resValue : -resValue;
  60259. }
  60260. } else {
  60261. return (len + parityCorrection) % 2 ? resValue : -resValue;
  60262. }
  60263. } else {
  60264. return curvenessList[edgeIndex + len + parityCorrection];
  60265. }
  60266. } else {
  60267. return curvenessList[parityCorrection + edgeIndex];
  60268. }
  60269. }
  60270. /*
  60271. * Licensed to the Apache Software Foundation (ASF) under one
  60272. * or more contributor license agreements. See the NOTICE file
  60273. * distributed with this work for additional information
  60274. * regarding copyright ownership. The ASF licenses this file
  60275. * to you under the Apache License, Version 2.0 (the
  60276. * "License"); you may not use this file except in compliance
  60277. * with the License. You may obtain a copy of the License at
  60278. *
  60279. * http://www.apache.org/licenses/LICENSE-2.0
  60280. *
  60281. * Unless required by applicable law or agreed to in writing,
  60282. * software distributed under the License is distributed on an
  60283. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60284. * KIND, either express or implied. See the License for the
  60285. * specific language governing permissions and limitations
  60286. * under the License.
  60287. */
  60288. /**
  60289. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60290. */
  60291. /*
  60292. * Licensed to the Apache Software Foundation (ASF) under one
  60293. * or more contributor license agreements. See the NOTICE file
  60294. * distributed with this work for additional information
  60295. * regarding copyright ownership. The ASF licenses this file
  60296. * to you under the Apache License, Version 2.0 (the
  60297. * "License"); you may not use this file except in compliance
  60298. * with the License. You may obtain a copy of the License at
  60299. *
  60300. * http://www.apache.org/licenses/LICENSE-2.0
  60301. *
  60302. * Unless required by applicable law or agreed to in writing,
  60303. * software distributed under the License is distributed on an
  60304. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60305. * KIND, either express or implied. See the License for the
  60306. * specific language governing permissions and limitations
  60307. * under the License.
  60308. */
  60309. function simpleLayout(seriesModel) {
  60310. var coordSys = seriesModel.coordinateSystem;
  60311. if (coordSys && coordSys.type !== 'view') {
  60312. return;
  60313. }
  60314. var graph = seriesModel.getGraph();
  60315. graph.eachNode(function (node) {
  60316. var model = node.getModel();
  60317. node.setLayout([+model.get('x'), +model.get('y')]);
  60318. });
  60319. simpleLayoutEdge(graph, seriesModel);
  60320. }
  60321. function simpleLayoutEdge(graph, seriesModel) {
  60322. graph.eachEdge(function (edge, index) {
  60323. var curveness = retrieve3(edge.getModel().get(['lineStyle', 'curveness']), -getCurvenessForEdge(edge, seriesModel, index, true), 0);
  60324. var p1 = clone$1(edge.node1.getLayout());
  60325. var p2 = clone$1(edge.node2.getLayout());
  60326. var points = [p1, p2];
  60327. if (+curveness) {
  60328. points.push([(p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * curveness, (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * curveness]);
  60329. }
  60330. edge.setLayout(points);
  60331. });
  60332. }
  60333. /*
  60334. * Licensed to the Apache Software Foundation (ASF) under one
  60335. * or more contributor license agreements. See the NOTICE file
  60336. * distributed with this work for additional information
  60337. * regarding copyright ownership. The ASF licenses this file
  60338. * to you under the Apache License, Version 2.0 (the
  60339. * "License"); you may not use this file except in compliance
  60340. * with the License. You may obtain a copy of the License at
  60341. *
  60342. * http://www.apache.org/licenses/LICENSE-2.0
  60343. *
  60344. * Unless required by applicable law or agreed to in writing,
  60345. * software distributed under the License is distributed on an
  60346. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60347. * KIND, either express or implied. See the License for the
  60348. * specific language governing permissions and limitations
  60349. * under the License.
  60350. */
  60351. /**
  60352. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60353. */
  60354. /*
  60355. * Licensed to the Apache Software Foundation (ASF) under one
  60356. * or more contributor license agreements. See the NOTICE file
  60357. * distributed with this work for additional information
  60358. * regarding copyright ownership. The ASF licenses this file
  60359. * to you under the Apache License, Version 2.0 (the
  60360. * "License"); you may not use this file except in compliance
  60361. * with the License. You may obtain a copy of the License at
  60362. *
  60363. * http://www.apache.org/licenses/LICENSE-2.0
  60364. *
  60365. * Unless required by applicable law or agreed to in writing,
  60366. * software distributed under the License is distributed on an
  60367. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60368. * KIND, either express or implied. See the License for the
  60369. * specific language governing permissions and limitations
  60370. * under the License.
  60371. */
  60372. function graphSimpleLayout(ecModel, api) {
  60373. ecModel.eachSeriesByType('graph', function (seriesModel) {
  60374. var layout = seriesModel.get('layout');
  60375. var coordSys = seriesModel.coordinateSystem;
  60376. if (coordSys && coordSys.type !== 'view') {
  60377. var data_1 = seriesModel.getData();
  60378. var dimensions_1 = [];
  60379. each$1(coordSys.dimensions, function (coordDim) {
  60380. dimensions_1 = dimensions_1.concat(data_1.mapDimensionsAll(coordDim));
  60381. });
  60382. for (var dataIndex = 0; dataIndex < data_1.count(); dataIndex++) {
  60383. var value = [];
  60384. var hasValue = false;
  60385. for (var i = 0; i < dimensions_1.length; i++) {
  60386. var val = data_1.get(dimensions_1[i], dataIndex);
  60387. if (!isNaN(val)) {
  60388. hasValue = true;
  60389. }
  60390. value.push(val);
  60391. }
  60392. if (hasValue) {
  60393. data_1.setItemLayout(dataIndex, coordSys.dataToPoint(value));
  60394. } else {
  60395. // Also {Array.<number>}, not undefined to avoid if...else... statement
  60396. data_1.setItemLayout(dataIndex, [NaN, NaN]);
  60397. }
  60398. }
  60399. simpleLayoutEdge(data_1.graph, seriesModel);
  60400. } else if (!layout || layout === 'none') {
  60401. simpleLayout(seriesModel);
  60402. }
  60403. });
  60404. }
  60405. /*
  60406. * Licensed to the Apache Software Foundation (ASF) under one
  60407. * or more contributor license agreements. See the NOTICE file
  60408. * distributed with this work for additional information
  60409. * regarding copyright ownership. The ASF licenses this file
  60410. * to you under the Apache License, Version 2.0 (the
  60411. * "License"); you may not use this file except in compliance
  60412. * with the License. You may obtain a copy of the License at
  60413. *
  60414. * http://www.apache.org/licenses/LICENSE-2.0
  60415. *
  60416. * Unless required by applicable law or agreed to in writing,
  60417. * software distributed under the License is distributed on an
  60418. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60419. * KIND, either express or implied. See the License for the
  60420. * specific language governing permissions and limitations
  60421. * under the License.
  60422. */
  60423. /**
  60424. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60425. */
  60426. /*
  60427. * Licensed to the Apache Software Foundation (ASF) under one
  60428. * or more contributor license agreements. See the NOTICE file
  60429. * distributed with this work for additional information
  60430. * regarding copyright ownership. The ASF licenses this file
  60431. * to you under the Apache License, Version 2.0 (the
  60432. * "License"); you may not use this file except in compliance
  60433. * with the License. You may obtain a copy of the License at
  60434. *
  60435. * http://www.apache.org/licenses/LICENSE-2.0
  60436. *
  60437. * Unless required by applicable law or agreed to in writing,
  60438. * software distributed under the License is distributed on an
  60439. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60440. * KIND, either express or implied. See the License for the
  60441. * specific language governing permissions and limitations
  60442. * under the License.
  60443. */
  60444. function getNodeGlobalScale(seriesModel) {
  60445. var coordSys = seriesModel.coordinateSystem;
  60446. if (coordSys.type !== 'view') {
  60447. return 1;
  60448. }
  60449. var nodeScaleRatio = seriesModel.option.nodeScaleRatio;
  60450. var groupZoom = coordSys.scaleX; // Scale node when zoom changes
  60451. var roamZoom = coordSys.getZoom();
  60452. var nodeScale = (roamZoom - 1) * nodeScaleRatio + 1;
  60453. return nodeScale / groupZoom;
  60454. }
  60455. function getSymbolSize(node) {
  60456. var symbolSize = node.getVisual('symbolSize');
  60457. if (symbolSize instanceof Array) {
  60458. symbolSize = (symbolSize[0] + symbolSize[1]) / 2;
  60459. }
  60460. return +symbolSize;
  60461. }
  60462. /*
  60463. * Licensed to the Apache Software Foundation (ASF) under one
  60464. * or more contributor license agreements. See the NOTICE file
  60465. * distributed with this work for additional information
  60466. * regarding copyright ownership. The ASF licenses this file
  60467. * to you under the Apache License, Version 2.0 (the
  60468. * "License"); you may not use this file except in compliance
  60469. * with the License. You may obtain a copy of the License at
  60470. *
  60471. * http://www.apache.org/licenses/LICENSE-2.0
  60472. *
  60473. * Unless required by applicable law or agreed to in writing,
  60474. * software distributed under the License is distributed on an
  60475. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60476. * KIND, either express or implied. See the License for the
  60477. * specific language governing permissions and limitations
  60478. * under the License.
  60479. */
  60480. /**
  60481. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60482. */
  60483. /*
  60484. * Licensed to the Apache Software Foundation (ASF) under one
  60485. * or more contributor license agreements. See the NOTICE file
  60486. * distributed with this work for additional information
  60487. * regarding copyright ownership. The ASF licenses this file
  60488. * to you under the Apache License, Version 2.0 (the
  60489. * "License"); you may not use this file except in compliance
  60490. * with the License. You may obtain a copy of the License at
  60491. *
  60492. * http://www.apache.org/licenses/LICENSE-2.0
  60493. *
  60494. * Unless required by applicable law or agreed to in writing,
  60495. * software distributed under the License is distributed on an
  60496. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60497. * KIND, either express or implied. See the License for the
  60498. * specific language governing permissions and limitations
  60499. * under the License.
  60500. */
  60501. var PI$5 = Math.PI;
  60502. var _symbolRadiansHalf = [];
  60503. /**
  60504. * `basedOn` can be:
  60505. * 'value':
  60506. * This layout is not accurate and have same bad case. For example,
  60507. * if the min value is very smaller than the max value, the nodes
  60508. * with the min value probably overlap even though there is enough
  60509. * space to layout them. So we only use this approach in the as the
  60510. * init layout of the force layout.
  60511. * FIXME
  60512. * Probably we do not need this method any more but use
  60513. * `basedOn: 'symbolSize'` in force layout if
  60514. * delay its init operations to GraphView.
  60515. * 'symbolSize':
  60516. * This approach work only if all of the symbol size calculated.
  60517. * That is, the progressive rendering is not applied to graph.
  60518. * FIXME
  60519. * If progressive rendering is applied to graph some day,
  60520. * probably we have to use `basedOn: 'value'`.
  60521. */
  60522. function circularLayout(seriesModel, basedOn) {
  60523. var coordSys = seriesModel.coordinateSystem;
  60524. if (coordSys && coordSys.type !== 'view') {
  60525. return;
  60526. }
  60527. var rect = coordSys.getBoundingRect();
  60528. var nodeData = seriesModel.getData();
  60529. var graph = nodeData.graph;
  60530. var cx = rect.width / 2 + rect.x;
  60531. var cy = rect.height / 2 + rect.y;
  60532. var r = Math.min(rect.width, rect.height) / 2;
  60533. var count = nodeData.count();
  60534. nodeData.setLayout({
  60535. cx: cx,
  60536. cy: cy
  60537. });
  60538. if (!count) {
  60539. return;
  60540. }
  60541. _layoutNodesBasedOn[basedOn](seriesModel, graph, nodeData, r, cx, cy, count);
  60542. graph.eachEdge(function (edge, index) {
  60543. var curveness = retrieve3(edge.getModel().get(['lineStyle', 'curveness']), getCurvenessForEdge(edge, seriesModel, index), 0);
  60544. var p1 = clone$1(edge.node1.getLayout());
  60545. var p2 = clone$1(edge.node2.getLayout());
  60546. var cp1;
  60547. var x12 = (p1[0] + p2[0]) / 2;
  60548. var y12 = (p1[1] + p2[1]) / 2;
  60549. if (+curveness) {
  60550. curveness *= 3;
  60551. cp1 = [cx * curveness + x12 * (1 - curveness), cy * curveness + y12 * (1 - curveness)];
  60552. }
  60553. edge.setLayout([p1, p2, cp1]);
  60554. });
  60555. }
  60556. var _layoutNodesBasedOn = {
  60557. value: function (seriesModel, graph, nodeData, r, cx, cy, count) {
  60558. var angle = 0;
  60559. var sum = nodeData.getSum('value');
  60560. var unitAngle = Math.PI * 2 / (sum || count);
  60561. graph.eachNode(function (node) {
  60562. var value = node.getValue('value');
  60563. var radianHalf = unitAngle * (sum ? value : 1) / 2;
  60564. angle += radianHalf;
  60565. node.setLayout([r * Math.cos(angle) + cx, r * Math.sin(angle) + cy]);
  60566. angle += radianHalf;
  60567. });
  60568. },
  60569. symbolSize: function (seriesModel, graph, nodeData, r, cx, cy, count) {
  60570. var sumRadian = 0;
  60571. _symbolRadiansHalf.length = count;
  60572. var nodeScale = getNodeGlobalScale(seriesModel);
  60573. graph.eachNode(function (node) {
  60574. var symbolSize = getSymbolSize(node); // Normally this case will not happen, but we still add
  60575. // some the defensive code (2px is an arbitrary value).
  60576. isNaN(symbolSize) && (symbolSize = 2);
  60577. symbolSize < 0 && (symbolSize = 0);
  60578. symbolSize *= nodeScale;
  60579. var symbolRadianHalf = Math.asin(symbolSize / 2 / r); // when `symbolSize / 2` is bigger than `r`.
  60580. isNaN(symbolRadianHalf) && (symbolRadianHalf = PI$5 / 2);
  60581. _symbolRadiansHalf[node.dataIndex] = symbolRadianHalf;
  60582. sumRadian += symbolRadianHalf * 2;
  60583. });
  60584. var halfRemainRadian = (2 * PI$5 - sumRadian) / count / 2;
  60585. var angle = 0;
  60586. graph.eachNode(function (node) {
  60587. var radianHalf = halfRemainRadian + _symbolRadiansHalf[node.dataIndex];
  60588. angle += radianHalf;
  60589. node.setLayout([r * Math.cos(angle) + cx, r * Math.sin(angle) + cy]);
  60590. angle += radianHalf;
  60591. });
  60592. }
  60593. };
  60594. /*
  60595. * Licensed to the Apache Software Foundation (ASF) under one
  60596. * or more contributor license agreements. See the NOTICE file
  60597. * distributed with this work for additional information
  60598. * regarding copyright ownership. The ASF licenses this file
  60599. * to you under the Apache License, Version 2.0 (the
  60600. * "License"); you may not use this file except in compliance
  60601. * with the License. You may obtain a copy of the License at
  60602. *
  60603. * http://www.apache.org/licenses/LICENSE-2.0
  60604. *
  60605. * Unless required by applicable law or agreed to in writing,
  60606. * software distributed under the License is distributed on an
  60607. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60608. * KIND, either express or implied. See the License for the
  60609. * specific language governing permissions and limitations
  60610. * under the License.
  60611. */
  60612. /**
  60613. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60614. */
  60615. /*
  60616. * Licensed to the Apache Software Foundation (ASF) under one
  60617. * or more contributor license agreements. See the NOTICE file
  60618. * distributed with this work for additional information
  60619. * regarding copyright ownership. The ASF licenses this file
  60620. * to you under the Apache License, Version 2.0 (the
  60621. * "License"); you may not use this file except in compliance
  60622. * with the License. You may obtain a copy of the License at
  60623. *
  60624. * http://www.apache.org/licenses/LICENSE-2.0
  60625. *
  60626. * Unless required by applicable law or agreed to in writing,
  60627. * software distributed under the License is distributed on an
  60628. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60629. * KIND, either express or implied. See the License for the
  60630. * specific language governing permissions and limitations
  60631. * under the License.
  60632. */
  60633. function graphCircularLayout(ecModel) {
  60634. ecModel.eachSeriesByType('graph', function (seriesModel) {
  60635. if (seriesModel.get('layout') === 'circular') {
  60636. circularLayout(seriesModel, 'symbolSize');
  60637. }
  60638. });
  60639. }
  60640. /*
  60641. * Licensed to the Apache Software Foundation (ASF) under one
  60642. * or more contributor license agreements. See the NOTICE file
  60643. * distributed with this work for additional information
  60644. * regarding copyright ownership. The ASF licenses this file
  60645. * to you under the Apache License, Version 2.0 (the
  60646. * "License"); you may not use this file except in compliance
  60647. * with the License. You may obtain a copy of the License at
  60648. *
  60649. * http://www.apache.org/licenses/LICENSE-2.0
  60650. *
  60651. * Unless required by applicable law or agreed to in writing,
  60652. * software distributed under the License is distributed on an
  60653. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60654. * KIND, either express or implied. See the License for the
  60655. * specific language governing permissions and limitations
  60656. * under the License.
  60657. */
  60658. /**
  60659. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60660. */
  60661. /*
  60662. * Licensed to the Apache Software Foundation (ASF) under one
  60663. * or more contributor license agreements. See the NOTICE file
  60664. * distributed with this work for additional information
  60665. * regarding copyright ownership. The ASF licenses this file
  60666. * to you under the Apache License, Version 2.0 (the
  60667. * "License"); you may not use this file except in compliance
  60668. * with the License. You may obtain a copy of the License at
  60669. *
  60670. * http://www.apache.org/licenses/LICENSE-2.0
  60671. *
  60672. * Unless required by applicable law or agreed to in writing,
  60673. * software distributed under the License is distributed on an
  60674. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60675. * KIND, either express or implied. See the License for the
  60676. * specific language governing permissions and limitations
  60677. * under the License.
  60678. */
  60679. /*
  60680. * A third-party license is embeded for some of the code in this file:
  60681. * Some formulas were originally copied from "d3.js" with some
  60682. * modifications made for this project.
  60683. * (See more details in the comment of the method "step" below.)
  60684. * The use of the source code of this file is also subject to the terms
  60685. * and consitions of the license of "d3.js" (BSD-3Clause, see
  60686. * </licenses/LICENSE-d3>).
  60687. */
  60688. var scaleAndAdd$1 = scaleAndAdd; // function adjacentNode(n, e) {
  60689. // return e.n1 === n ? e.n2 : e.n1;
  60690. // }
  60691. function forceLayout(inNodes, inEdges, opts) {
  60692. var nodes = inNodes;
  60693. var edges = inEdges;
  60694. var rect = opts.rect;
  60695. var width = rect.width;
  60696. var height = rect.height;
  60697. var center = [rect.x + width / 2, rect.y + height / 2]; // let scale = opts.scale || 1;
  60698. var gravity = opts.gravity == null ? 0.1 : opts.gravity; // for (let i = 0; i < edges.length; i++) {
  60699. // let e = edges[i];
  60700. // let n1 = e.n1;
  60701. // let n2 = e.n2;
  60702. // n1.edges = n1.edges || [];
  60703. // n2.edges = n2.edges || [];
  60704. // n1.edges.push(e);
  60705. // n2.edges.push(e);
  60706. // }
  60707. // Init position
  60708. for (var i = 0; i < nodes.length; i++) {
  60709. var n = nodes[i];
  60710. if (!n.p) {
  60711. n.p = create(width * (Math.random() - 0.5) + center[0], height * (Math.random() - 0.5) + center[1]);
  60712. }
  60713. n.pp = clone$1(n.p);
  60714. n.edges = null;
  60715. } // Formula in 'Graph Drawing by Force-directed Placement'
  60716. // let k = scale * Math.sqrt(width * height / nodes.length);
  60717. // let k2 = k * k;
  60718. var initialFriction = opts.friction == null ? 0.6 : opts.friction;
  60719. var friction = initialFriction;
  60720. var beforeStepCallback;
  60721. var afterStepCallback;
  60722. return {
  60723. warmUp: function () {
  60724. friction = initialFriction * 0.8;
  60725. },
  60726. setFixed: function (idx) {
  60727. nodes[idx].fixed = true;
  60728. },
  60729. setUnfixed: function (idx) {
  60730. nodes[idx].fixed = false;
  60731. },
  60732. /**
  60733. * Before step hook
  60734. */
  60735. beforeStep: function (cb) {
  60736. beforeStepCallback = cb;
  60737. },
  60738. /**
  60739. * After step hook
  60740. */
  60741. afterStep: function (cb) {
  60742. afterStepCallback = cb;
  60743. },
  60744. /**
  60745. * Some formulas were originally copied from "d3.js"
  60746. * https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/layout/force.js
  60747. * with some modifications made for this project.
  60748. * See the license statement at the head of this file.
  60749. */
  60750. step: function (cb) {
  60751. beforeStepCallback && beforeStepCallback(nodes, edges);
  60752. var v12 = [];
  60753. var nLen = nodes.length;
  60754. for (var i = 0; i < edges.length; i++) {
  60755. var e = edges[i];
  60756. if (e.ignoreForceLayout) {
  60757. continue;
  60758. }
  60759. var n1 = e.n1;
  60760. var n2 = e.n2;
  60761. sub(v12, n2.p, n1.p);
  60762. var d = len(v12) - e.d;
  60763. var w = n2.w / (n1.w + n2.w);
  60764. if (isNaN(w)) {
  60765. w = 0;
  60766. }
  60767. normalize(v12, v12);
  60768. !n1.fixed && scaleAndAdd$1(n1.p, n1.p, v12, w * d * friction);
  60769. !n2.fixed && scaleAndAdd$1(n2.p, n2.p, v12, -(1 - w) * d * friction);
  60770. } // Gravity
  60771. for (var i = 0; i < nLen; i++) {
  60772. var n = nodes[i];
  60773. if (!n.fixed) {
  60774. sub(v12, center, n.p); // let d = vec2.len(v12);
  60775. // vec2.scale(v12, v12, 1 / d);
  60776. // let gravityFactor = gravity;
  60777. scaleAndAdd$1(n.p, n.p, v12, gravity * friction);
  60778. }
  60779. } // Repulsive
  60780. // PENDING
  60781. for (var i = 0; i < nLen; i++) {
  60782. var n1 = nodes[i];
  60783. for (var j = i + 1; j < nLen; j++) {
  60784. var n2 = nodes[j];
  60785. sub(v12, n2.p, n1.p);
  60786. var d = len(v12);
  60787. if (d === 0) {
  60788. // Random repulse
  60789. set(v12, Math.random() - 0.5, Math.random() - 0.5);
  60790. d = 1;
  60791. }
  60792. var repFact = (n1.rep + n2.rep) / d / d;
  60793. !n1.fixed && scaleAndAdd$1(n1.pp, n1.pp, v12, repFact);
  60794. !n2.fixed && scaleAndAdd$1(n2.pp, n2.pp, v12, -repFact);
  60795. }
  60796. }
  60797. var v = [];
  60798. for (var i = 0; i < nLen; i++) {
  60799. var n = nodes[i];
  60800. if (!n.fixed) {
  60801. sub(v, n.p, n.pp);
  60802. scaleAndAdd$1(n.p, n.p, v, friction);
  60803. copy(n.pp, n.p);
  60804. }
  60805. }
  60806. friction = friction * 0.992;
  60807. var finished = friction < 0.01;
  60808. afterStepCallback && afterStepCallback(nodes, edges, finished);
  60809. cb && cb(finished);
  60810. }
  60811. };
  60812. }
  60813. /*
  60814. * Licensed to the Apache Software Foundation (ASF) under one
  60815. * or more contributor license agreements. See the NOTICE file
  60816. * distributed with this work for additional information
  60817. * regarding copyright ownership. The ASF licenses this file
  60818. * to you under the Apache License, Version 2.0 (the
  60819. * "License"); you may not use this file except in compliance
  60820. * with the License. You may obtain a copy of the License at
  60821. *
  60822. * http://www.apache.org/licenses/LICENSE-2.0
  60823. *
  60824. * Unless required by applicable law or agreed to in writing,
  60825. * software distributed under the License is distributed on an
  60826. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60827. * KIND, either express or implied. See the License for the
  60828. * specific language governing permissions and limitations
  60829. * under the License.
  60830. */
  60831. /**
  60832. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60833. */
  60834. /*
  60835. * Licensed to the Apache Software Foundation (ASF) under one
  60836. * or more contributor license agreements. See the NOTICE file
  60837. * distributed with this work for additional information
  60838. * regarding copyright ownership. The ASF licenses this file
  60839. * to you under the Apache License, Version 2.0 (the
  60840. * "License"); you may not use this file except in compliance
  60841. * with the License. You may obtain a copy of the License at
  60842. *
  60843. * http://www.apache.org/licenses/LICENSE-2.0
  60844. *
  60845. * Unless required by applicable law or agreed to in writing,
  60846. * software distributed under the License is distributed on an
  60847. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60848. * KIND, either express or implied. See the License for the
  60849. * specific language governing permissions and limitations
  60850. * under the License.
  60851. */
  60852. function graphForceLayout(ecModel) {
  60853. ecModel.eachSeriesByType('graph', function (graphSeries) {
  60854. var coordSys = graphSeries.coordinateSystem;
  60855. if (coordSys && coordSys.type !== 'view') {
  60856. return;
  60857. }
  60858. if (graphSeries.get('layout') === 'force') {
  60859. var preservedPoints_1 = graphSeries.preservedPoints || {};
  60860. var graph_1 = graphSeries.getGraph();
  60861. var nodeData_1 = graph_1.data;
  60862. var edgeData = graph_1.edgeData;
  60863. var forceModel = graphSeries.getModel('force');
  60864. var initLayout = forceModel.get('initLayout');
  60865. if (graphSeries.preservedPoints) {
  60866. nodeData_1.each(function (idx) {
  60867. var id = nodeData_1.getId(idx);
  60868. nodeData_1.setItemLayout(idx, preservedPoints_1[id] || [NaN, NaN]);
  60869. });
  60870. } else if (!initLayout || initLayout === 'none') {
  60871. simpleLayout(graphSeries);
  60872. } else if (initLayout === 'circular') {
  60873. circularLayout(graphSeries, 'value');
  60874. }
  60875. var nodeDataExtent_1 = nodeData_1.getDataExtent('value');
  60876. var edgeDataExtent_1 = edgeData.getDataExtent('value'); // let edgeDataExtent = edgeData.getDataExtent('value');
  60877. var repulsion = forceModel.get('repulsion');
  60878. var edgeLength = forceModel.get('edgeLength');
  60879. var repulsionArr_1 = isArray(repulsion) ? repulsion : [repulsion, repulsion];
  60880. var edgeLengthArr_1 = isArray(edgeLength) ? edgeLength : [edgeLength, edgeLength]; // Larger value has smaller length
  60881. edgeLengthArr_1 = [edgeLengthArr_1[1], edgeLengthArr_1[0]];
  60882. var nodes_1 = nodeData_1.mapArray('value', function (value, idx) {
  60883. var point = nodeData_1.getItemLayout(idx);
  60884. var rep = linearMap(value, nodeDataExtent_1, repulsionArr_1);
  60885. if (isNaN(rep)) {
  60886. rep = (repulsionArr_1[0] + repulsionArr_1[1]) / 2;
  60887. }
  60888. return {
  60889. w: rep,
  60890. rep: rep,
  60891. fixed: nodeData_1.getItemModel(idx).get('fixed'),
  60892. p: !point || isNaN(point[0]) || isNaN(point[1]) ? null : point
  60893. };
  60894. });
  60895. var edges = edgeData.mapArray('value', function (value, idx) {
  60896. var edge = graph_1.getEdgeByIndex(idx);
  60897. var d = linearMap(value, edgeDataExtent_1, edgeLengthArr_1);
  60898. if (isNaN(d)) {
  60899. d = (edgeLengthArr_1[0] + edgeLengthArr_1[1]) / 2;
  60900. }
  60901. var edgeModel = edge.getModel();
  60902. var curveness = retrieve3(edge.getModel().get(['lineStyle', 'curveness']), -getCurvenessForEdge(edge, graphSeries, idx, true), 0);
  60903. return {
  60904. n1: nodes_1[edge.node1.dataIndex],
  60905. n2: nodes_1[edge.node2.dataIndex],
  60906. d: d,
  60907. curveness: curveness,
  60908. ignoreForceLayout: edgeModel.get('ignoreForceLayout')
  60909. };
  60910. }); // let coordSys = graphSeries.coordinateSystem;
  60911. var rect = coordSys.getBoundingRect();
  60912. var forceInstance = forceLayout(nodes_1, edges, {
  60913. rect: rect,
  60914. gravity: forceModel.get('gravity'),
  60915. friction: forceModel.get('friction')
  60916. });
  60917. forceInstance.beforeStep(function (nodes, edges) {
  60918. for (var i = 0, l = nodes.length; i < l; i++) {
  60919. if (nodes[i].fixed) {
  60920. // Write back to layout instance
  60921. copy(nodes[i].p, graph_1.getNodeByIndex(i).getLayout());
  60922. }
  60923. }
  60924. });
  60925. forceInstance.afterStep(function (nodes, edges, stopped) {
  60926. for (var i = 0, l = nodes.length; i < l; i++) {
  60927. if (!nodes[i].fixed) {
  60928. graph_1.getNodeByIndex(i).setLayout(nodes[i].p);
  60929. }
  60930. preservedPoints_1[nodeData_1.getId(i)] = nodes[i].p;
  60931. }
  60932. for (var i = 0, l = edges.length; i < l; i++) {
  60933. var e = edges[i];
  60934. var edge = graph_1.getEdgeByIndex(i);
  60935. var p1 = e.n1.p;
  60936. var p2 = e.n2.p;
  60937. var points = edge.getLayout();
  60938. points = points ? points.slice() : [];
  60939. points[0] = points[0] || [];
  60940. points[1] = points[1] || [];
  60941. copy(points[0], p1);
  60942. copy(points[1], p2);
  60943. if (+e.curveness) {
  60944. points[2] = [(p1[0] + p2[0]) / 2 - (p1[1] - p2[1]) * e.curveness, (p1[1] + p2[1]) / 2 - (p2[0] - p1[0]) * e.curveness];
  60945. }
  60946. edge.setLayout(points);
  60947. }
  60948. });
  60949. graphSeries.forceLayout = forceInstance;
  60950. graphSeries.preservedPoints = preservedPoints_1; // Step to get the layout
  60951. forceInstance.step();
  60952. } else {
  60953. // Remove prev injected forceLayout instance
  60954. graphSeries.forceLayout = null;
  60955. }
  60956. });
  60957. }
  60958. /*
  60959. * Licensed to the Apache Software Foundation (ASF) under one
  60960. * or more contributor license agreements. See the NOTICE file
  60961. * distributed with this work for additional information
  60962. * regarding copyright ownership. The ASF licenses this file
  60963. * to you under the Apache License, Version 2.0 (the
  60964. * "License"); you may not use this file except in compliance
  60965. * with the License. You may obtain a copy of the License at
  60966. *
  60967. * http://www.apache.org/licenses/LICENSE-2.0
  60968. *
  60969. * Unless required by applicable law or agreed to in writing,
  60970. * software distributed under the License is distributed on an
  60971. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60972. * KIND, either express or implied. See the License for the
  60973. * specific language governing permissions and limitations
  60974. * under the License.
  60975. */
  60976. /**
  60977. * AUTO-GENERATED FILE. DO NOT MODIFY.
  60978. */
  60979. /*
  60980. * Licensed to the Apache Software Foundation (ASF) under one
  60981. * or more contributor license agreements. See the NOTICE file
  60982. * distributed with this work for additional information
  60983. * regarding copyright ownership. The ASF licenses this file
  60984. * to you under the Apache License, Version 2.0 (the
  60985. * "License"); you may not use this file except in compliance
  60986. * with the License. You may obtain a copy of the License at
  60987. *
  60988. * http://www.apache.org/licenses/LICENSE-2.0
  60989. *
  60990. * Unless required by applicable law or agreed to in writing,
  60991. * software distributed under the License is distributed on an
  60992. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  60993. * KIND, either express or implied. See the License for the
  60994. * specific language governing permissions and limitations
  60995. * under the License.
  60996. */
  60997. // FIXME Where to create the simple view coordinate system
  60998. function getViewRect$2(seriesModel, api, aspect) {
  60999. var option = extend(seriesModel.getBoxLayoutParams(), {
  61000. aspect: aspect
  61001. });
  61002. return getLayoutRect(option, {
  61003. width: api.getWidth(),
  61004. height: api.getHeight()
  61005. });
  61006. }
  61007. function createViewCoordSys(ecModel, api) {
  61008. var viewList = [];
  61009. ecModel.eachSeriesByType('graph', function (seriesModel) {
  61010. var coordSysType = seriesModel.get('coordinateSystem');
  61011. if (!coordSysType || coordSysType === 'view') {
  61012. var data_1 = seriesModel.getData();
  61013. var positions = data_1.mapArray(function (idx) {
  61014. var itemModel = data_1.getItemModel(idx);
  61015. return [+itemModel.get('x'), +itemModel.get('y')];
  61016. });
  61017. var min = [];
  61018. var max = [];
  61019. fromPoints(positions, min, max); // If width or height is 0
  61020. if (max[0] - min[0] === 0) {
  61021. max[0] += 1;
  61022. min[0] -= 1;
  61023. }
  61024. if (max[1] - min[1] === 0) {
  61025. max[1] += 1;
  61026. min[1] -= 1;
  61027. }
  61028. var aspect = (max[0] - min[0]) / (max[1] - min[1]); // FIXME If get view rect after data processed?
  61029. var viewRect = getViewRect$2(seriesModel, api, aspect); // Position may be NaN, use view rect instead
  61030. if (isNaN(aspect)) {
  61031. min = [viewRect.x, viewRect.y];
  61032. max = [viewRect.x + viewRect.width, viewRect.y + viewRect.height];
  61033. }
  61034. var bbWidth = max[0] - min[0];
  61035. var bbHeight = max[1] - min[1];
  61036. var viewWidth = viewRect.width;
  61037. var viewHeight = viewRect.height;
  61038. var viewCoordSys = seriesModel.coordinateSystem = new View();
  61039. viewCoordSys.zoomLimit = seriesModel.get('scaleLimit');
  61040. viewCoordSys.setBoundingRect(min[0], min[1], bbWidth, bbHeight);
  61041. viewCoordSys.setViewRect(viewRect.x, viewRect.y, viewWidth, viewHeight); // Update roam info
  61042. viewCoordSys.setCenter(seriesModel.get('center'));
  61043. viewCoordSys.setZoom(seriesModel.get('zoom'));
  61044. viewList.push(viewCoordSys);
  61045. }
  61046. });
  61047. return viewList;
  61048. }
  61049. /*
  61050. * Licensed to the Apache Software Foundation (ASF) under one
  61051. * or more contributor license agreements. See the NOTICE file
  61052. * distributed with this work for additional information
  61053. * regarding copyright ownership. The ASF licenses this file
  61054. * to you under the Apache License, Version 2.0 (the
  61055. * "License"); you may not use this file except in compliance
  61056. * with the License. You may obtain a copy of the License at
  61057. *
  61058. * http://www.apache.org/licenses/LICENSE-2.0
  61059. *
  61060. * Unless required by applicable law or agreed to in writing,
  61061. * software distributed under the License is distributed on an
  61062. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61063. * KIND, either express or implied. See the License for the
  61064. * specific language governing permissions and limitations
  61065. * under the License.
  61066. */
  61067. /**
  61068. * AUTO-GENERATED FILE. DO NOT MODIFY.
  61069. */
  61070. /*
  61071. * Licensed to the Apache Software Foundation (ASF) under one
  61072. * or more contributor license agreements. See the NOTICE file
  61073. * distributed with this work for additional information
  61074. * regarding copyright ownership. The ASF licenses this file
  61075. * to you under the Apache License, Version 2.0 (the
  61076. * "License"); you may not use this file except in compliance
  61077. * with the License. You may obtain a copy of the License at
  61078. *
  61079. * http://www.apache.org/licenses/LICENSE-2.0
  61080. *
  61081. * Unless required by applicable law or agreed to in writing,
  61082. * software distributed under the License is distributed on an
  61083. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61084. * KIND, either express or implied. See the License for the
  61085. * specific language governing permissions and limitations
  61086. * under the License.
  61087. */
  61088. var v1 = [];
  61089. var v2 = [];
  61090. var v3 = [];
  61091. var quadraticAt$1 = quadraticAt;
  61092. var v2DistSquare = distSquare;
  61093. var mathAbs$2 = Math.abs;
  61094. function intersectCurveCircle(curvePoints, center, radius) {
  61095. var p0 = curvePoints[0];
  61096. var p1 = curvePoints[1];
  61097. var p2 = curvePoints[2];
  61098. var d = Infinity;
  61099. var t;
  61100. var radiusSquare = radius * radius;
  61101. var interval = 0.1;
  61102. for (var _t = 0.1; _t <= 0.9; _t += 0.1) {
  61103. v1[0] = quadraticAt$1(p0[0], p1[0], p2[0], _t);
  61104. v1[1] = quadraticAt$1(p0[1], p1[1], p2[1], _t);
  61105. var diff = mathAbs$2(v2DistSquare(v1, center) - radiusSquare);
  61106. if (diff < d) {
  61107. d = diff;
  61108. t = _t;
  61109. }
  61110. } // Assume the segment is monotone,Find root through Bisection method
  61111. // At most 32 iteration
  61112. for (var i = 0; i < 32; i++) {
  61113. // let prev = t - interval;
  61114. var next = t + interval; // v1[0] = quadraticAt(p0[0], p1[0], p2[0], prev);
  61115. // v1[1] = quadraticAt(p0[1], p1[1], p2[1], prev);
  61116. v2[0] = quadraticAt$1(p0[0], p1[0], p2[0], t);
  61117. v2[1] = quadraticAt$1(p0[1], p1[1], p2[1], t);
  61118. v3[0] = quadraticAt$1(p0[0], p1[0], p2[0], next);
  61119. v3[1] = quadraticAt$1(p0[1], p1[1], p2[1], next);
  61120. var diff = v2DistSquare(v2, center) - radiusSquare;
  61121. if (mathAbs$2(diff) < 1e-2) {
  61122. break;
  61123. } // let prevDiff = v2DistSquare(v1, center) - radiusSquare;
  61124. var nextDiff = v2DistSquare(v3, center) - radiusSquare;
  61125. interval /= 2;
  61126. if (diff < 0) {
  61127. if (nextDiff >= 0) {
  61128. t = t + interval;
  61129. } else {
  61130. t = t - interval;
  61131. }
  61132. } else {
  61133. if (nextDiff >= 0) {
  61134. t = t - interval;
  61135. } else {
  61136. t = t + interval;
  61137. }
  61138. }
  61139. }
  61140. return t;
  61141. } // Adjust edge to avoid
  61142. function adjustEdge(graph, scale$$1) {
  61143. var tmp0 = [];
  61144. var quadraticSubdivide$$1 = quadraticSubdivide;
  61145. var pts = [[], [], []];
  61146. var pts2 = [[], []];
  61147. var v = [];
  61148. scale$$1 /= 2;
  61149. graph.eachEdge(function (edge, idx) {
  61150. var linePoints = edge.getLayout();
  61151. var fromSymbol = edge.getVisual('fromSymbol');
  61152. var toSymbol = edge.getVisual('toSymbol');
  61153. if (!linePoints.__original) {
  61154. linePoints.__original = [clone$1(linePoints[0]), clone$1(linePoints[1])];
  61155. if (linePoints[2]) {
  61156. linePoints.__original.push(clone$1(linePoints[2]));
  61157. }
  61158. }
  61159. var originalPoints = linePoints.__original; // Quadratic curve
  61160. if (linePoints[2] != null) {
  61161. copy(pts[0], originalPoints[0]);
  61162. copy(pts[1], originalPoints[2]);
  61163. copy(pts[2], originalPoints[1]);
  61164. if (fromSymbol && fromSymbol !== 'none') {
  61165. var symbolSize = getSymbolSize(edge.node1);
  61166. var t = intersectCurveCircle(pts, originalPoints[0], symbolSize * scale$$1); // Subdivide and get the second
  61167. quadraticSubdivide$$1(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  61168. pts[0][0] = tmp0[3];
  61169. pts[1][0] = tmp0[4];
  61170. quadraticSubdivide$$1(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  61171. pts[0][1] = tmp0[3];
  61172. pts[1][1] = tmp0[4];
  61173. }
  61174. if (toSymbol && toSymbol !== 'none') {
  61175. var symbolSize = getSymbolSize(edge.node2);
  61176. var t = intersectCurveCircle(pts, originalPoints[1], symbolSize * scale$$1); // Subdivide and get the first
  61177. quadraticSubdivide$$1(pts[0][0], pts[1][0], pts[2][0], t, tmp0);
  61178. pts[1][0] = tmp0[1];
  61179. pts[2][0] = tmp0[2];
  61180. quadraticSubdivide$$1(pts[0][1], pts[1][1], pts[2][1], t, tmp0);
  61181. pts[1][1] = tmp0[1];
  61182. pts[2][1] = tmp0[2];
  61183. } // Copy back to layout
  61184. copy(linePoints[0], pts[0]);
  61185. copy(linePoints[1], pts[2]);
  61186. copy(linePoints[2], pts[1]);
  61187. } // Line
  61188. else {
  61189. copy(pts2[0], originalPoints[0]);
  61190. copy(pts2[1], originalPoints[1]);
  61191. sub(v, pts2[1], pts2[0]);
  61192. normalize(v, v);
  61193. if (fromSymbol && fromSymbol !== 'none') {
  61194. var symbolSize = getSymbolSize(edge.node1);
  61195. scaleAndAdd(pts2[0], pts2[0], v, symbolSize * scale$$1);
  61196. }
  61197. if (toSymbol && toSymbol !== 'none') {
  61198. var symbolSize = getSymbolSize(edge.node2);
  61199. scaleAndAdd(pts2[1], pts2[1], v, -symbolSize * scale$$1);
  61200. }
  61201. copy(linePoints[0], pts2[0]);
  61202. copy(linePoints[1], pts2[1]);
  61203. }
  61204. });
  61205. }
  61206. /*
  61207. * Licensed to the Apache Software Foundation (ASF) under one
  61208. * or more contributor license agreements. See the NOTICE file
  61209. * distributed with this work for additional information
  61210. * regarding copyright ownership. The ASF licenses this file
  61211. * to you under the Apache License, Version 2.0 (the
  61212. * "License"); you may not use this file except in compliance
  61213. * with the License. You may obtain a copy of the License at
  61214. *
  61215. * http://www.apache.org/licenses/LICENSE-2.0
  61216. *
  61217. * Unless required by applicable law or agreed to in writing,
  61218. * software distributed under the License is distributed on an
  61219. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61220. * KIND, either express or implied. See the License for the
  61221. * specific language governing permissions and limitations
  61222. * under the License.
  61223. */
  61224. /**
  61225. * AUTO-GENERATED FILE. DO NOT MODIFY.
  61226. */
  61227. /*
  61228. * Licensed to the Apache Software Foundation (ASF) under one
  61229. * or more contributor license agreements. See the NOTICE file
  61230. * distributed with this work for additional information
  61231. * regarding copyright ownership. The ASF licenses this file
  61232. * to you under the Apache License, Version 2.0 (the
  61233. * "License"); you may not use this file except in compliance
  61234. * with the License. You may obtain a copy of the License at
  61235. *
  61236. * http://www.apache.org/licenses/LICENSE-2.0
  61237. *
  61238. * Unless required by applicable law or agreed to in writing,
  61239. * software distributed under the License is distributed on an
  61240. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61241. * KIND, either express or implied. See the License for the
  61242. * specific language governing permissions and limitations
  61243. * under the License.
  61244. */
  61245. function isViewCoordSys(coordSys) {
  61246. return coordSys.type === 'view';
  61247. }
  61248. var GraphView =
  61249. /** @class */
  61250. function (_super) {
  61251. __extends(GraphView, _super);
  61252. function GraphView() {
  61253. var _this = _super !== null && _super.apply(this, arguments) || this;
  61254. _this.type = GraphView.type;
  61255. return _this;
  61256. }
  61257. GraphView.prototype.init = function (ecModel, api) {
  61258. var symbolDraw = new SymbolDraw();
  61259. var lineDraw = new LineDraw();
  61260. var group = this.group;
  61261. this._controller = new RoamController(api.getZr());
  61262. this._controllerHost = {
  61263. target: group
  61264. };
  61265. group.add(symbolDraw.group);
  61266. group.add(lineDraw.group);
  61267. this._symbolDraw = symbolDraw;
  61268. this._lineDraw = lineDraw;
  61269. this._firstRender = true;
  61270. };
  61271. GraphView.prototype.render = function (seriesModel, ecModel, api) {
  61272. var _this = this;
  61273. var coordSys = seriesModel.coordinateSystem;
  61274. this._model = seriesModel;
  61275. var symbolDraw = this._symbolDraw;
  61276. var lineDraw = this._lineDraw;
  61277. var group = this.group;
  61278. if (isViewCoordSys(coordSys)) {
  61279. var groupNewProp = {
  61280. x: coordSys.x,
  61281. y: coordSys.y,
  61282. scaleX: coordSys.scaleX,
  61283. scaleY: coordSys.scaleY
  61284. };
  61285. if (this._firstRender) {
  61286. group.attr(groupNewProp);
  61287. } else {
  61288. updateProps(group, groupNewProp, seriesModel);
  61289. }
  61290. } // Fix edge contact point with node
  61291. adjustEdge(seriesModel.getGraph(), getNodeGlobalScale(seriesModel));
  61292. var data = seriesModel.getData();
  61293. symbolDraw.updateData(data);
  61294. var edgeData = seriesModel.getEdgeData(); // TODO: TYPE
  61295. lineDraw.updateData(edgeData);
  61296. this._updateNodeAndLinkScale();
  61297. this._updateController(seriesModel, ecModel, api);
  61298. clearTimeout(this._layoutTimeout);
  61299. var forceLayout = seriesModel.forceLayout;
  61300. var layoutAnimation = seriesModel.get(['force', 'layoutAnimation']);
  61301. if (forceLayout) {
  61302. this._startForceLayoutIteration(forceLayout, layoutAnimation);
  61303. }
  61304. data.graph.eachNode(function (node) {
  61305. var idx = node.dataIndex;
  61306. var el = node.getGraphicEl();
  61307. var itemModel = node.getModel(); // Update draggable
  61308. el.off('drag').off('dragend');
  61309. var draggable = itemModel.get('draggable');
  61310. if (draggable) {
  61311. el.on('drag', function () {
  61312. if (forceLayout) {
  61313. forceLayout.warmUp();
  61314. !_this._layouting && _this._startForceLayoutIteration(forceLayout, layoutAnimation);
  61315. forceLayout.setFixed(idx); // Write position back to layout
  61316. data.setItemLayout(idx, [el.x, el.y]);
  61317. }
  61318. }).on('dragend', function () {
  61319. if (forceLayout) {
  61320. forceLayout.setUnfixed(idx);
  61321. }
  61322. });
  61323. }
  61324. el.setDraggable(draggable && !!forceLayout);
  61325. var focus = itemModel.get(['emphasis', 'focus']);
  61326. if (focus === 'adjacency') {
  61327. getECData(el).focus = node.getAdjacentDataIndices();
  61328. }
  61329. });
  61330. data.graph.eachEdge(function (edge) {
  61331. var el = edge.getGraphicEl();
  61332. var focus = edge.getModel().get(['emphasis', 'focus']);
  61333. if (focus === 'adjacency') {
  61334. getECData(el).focus = {
  61335. edge: [edge.dataIndex],
  61336. node: [edge.node1.dataIndex, edge.node2.dataIndex]
  61337. };
  61338. }
  61339. });
  61340. var circularRotateLabel = seriesModel.get('layout') === 'circular' && seriesModel.get(['circular', 'rotateLabel']);
  61341. var cx = data.getLayout('cx');
  61342. var cy = data.getLayout('cy');
  61343. data.eachItemGraphicEl(function (el, idx) {
  61344. var itemModel = data.getItemModel(idx);
  61345. var labelRotate = itemModel.get(['label', 'rotate']) || 0;
  61346. var symbolPath = el.getSymbolPath();
  61347. if (circularRotateLabel) {
  61348. var pos = data.getItemLayout(idx);
  61349. var rad = Math.atan2(pos[1] - cy, pos[0] - cx);
  61350. if (rad < 0) {
  61351. rad = Math.PI * 2 + rad;
  61352. }
  61353. var isLeft = pos[0] < cx;
  61354. if (isLeft) {
  61355. rad = rad - Math.PI;
  61356. }
  61357. var textPosition = isLeft ? 'left' : 'right';
  61358. symbolPath.setTextConfig({
  61359. rotation: -rad,
  61360. position: textPosition,
  61361. origin: 'center'
  61362. });
  61363. var emphasisState = symbolPath.ensureState('emphasis');
  61364. extend(emphasisState.textConfig || (emphasisState.textConfig = {}), {
  61365. position: textPosition
  61366. });
  61367. } else {
  61368. symbolPath.setTextConfig({
  61369. rotation: labelRotate *= Math.PI / 180
  61370. });
  61371. }
  61372. });
  61373. this._firstRender = false;
  61374. };
  61375. GraphView.prototype.dispose = function () {
  61376. this._controller && this._controller.dispose();
  61377. this._controllerHost = null;
  61378. };
  61379. GraphView.prototype._startForceLayoutIteration = function (forceLayout, layoutAnimation) {
  61380. var self = this;
  61381. (function step() {
  61382. forceLayout.step(function (stopped) {
  61383. self.updateLayout(self._model);
  61384. (self._layouting = !stopped) && (layoutAnimation ? self._layoutTimeout = setTimeout(step, 16) : step());
  61385. });
  61386. })();
  61387. };
  61388. GraphView.prototype._updateController = function (seriesModel, ecModel, api) {
  61389. var _this = this;
  61390. var controller = this._controller;
  61391. var controllerHost = this._controllerHost;
  61392. var group = this.group;
  61393. controller.setPointerChecker(function (e, x, y) {
  61394. var rect = group.getBoundingRect();
  61395. rect.applyTransform(group.transform);
  61396. return rect.contain(x, y) && !onIrrelevantElement(e, api, seriesModel);
  61397. });
  61398. if (!isViewCoordSys(seriesModel.coordinateSystem)) {
  61399. controller.disable();
  61400. return;
  61401. }
  61402. controller.enable(seriesModel.get('roam'));
  61403. controllerHost.zoomLimit = seriesModel.get('scaleLimit');
  61404. controllerHost.zoom = seriesModel.coordinateSystem.getZoom();
  61405. controller.off('pan').off('zoom').on('pan', function (e) {
  61406. updateViewOnPan(controllerHost, e.dx, e.dy);
  61407. api.dispatchAction({
  61408. seriesId: seriesModel.id,
  61409. type: 'graphRoam',
  61410. dx: e.dx,
  61411. dy: e.dy
  61412. });
  61413. }).on('zoom', function (e) {
  61414. updateViewOnZoom(controllerHost, e.scale, e.originX, e.originY);
  61415. api.dispatchAction({
  61416. seriesId: seriesModel.id,
  61417. type: 'graphRoam',
  61418. zoom: e.scale,
  61419. originX: e.originX,
  61420. originY: e.originY
  61421. });
  61422. _this._updateNodeAndLinkScale();
  61423. adjustEdge(seriesModel.getGraph(), getNodeGlobalScale(seriesModel));
  61424. _this._lineDraw.updateLayout(); // Only update label layout on zoom
  61425. api.updateLabelLayout();
  61426. });
  61427. };
  61428. GraphView.prototype._updateNodeAndLinkScale = function () {
  61429. var seriesModel = this._model;
  61430. var data = seriesModel.getData();
  61431. var nodeScale = getNodeGlobalScale(seriesModel);
  61432. data.eachItemGraphicEl(function (el, idx) {
  61433. el.setSymbolScale(nodeScale);
  61434. });
  61435. };
  61436. GraphView.prototype.updateLayout = function (seriesModel) {
  61437. adjustEdge(seriesModel.getGraph(), getNodeGlobalScale(seriesModel));
  61438. this._symbolDraw.updateLayout();
  61439. this._lineDraw.updateLayout();
  61440. };
  61441. GraphView.prototype.remove = function (ecModel, api) {
  61442. this._symbolDraw && this._symbolDraw.remove();
  61443. this._lineDraw && this._lineDraw.remove();
  61444. };
  61445. GraphView.type = 'graph';
  61446. return GraphView;
  61447. }(ChartView);
  61448. /*
  61449. * Licensed to the Apache Software Foundation (ASF) under one
  61450. * or more contributor license agreements. See the NOTICE file
  61451. * distributed with this work for additional information
  61452. * regarding copyright ownership. The ASF licenses this file
  61453. * to you under the Apache License, Version 2.0 (the
  61454. * "License"); you may not use this file except in compliance
  61455. * with the License. You may obtain a copy of the License at
  61456. *
  61457. * http://www.apache.org/licenses/LICENSE-2.0
  61458. *
  61459. * Unless required by applicable law or agreed to in writing,
  61460. * software distributed under the License is distributed on an
  61461. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61462. * KIND, either express or implied. See the License for the
  61463. * specific language governing permissions and limitations
  61464. * under the License.
  61465. */
  61466. /**
  61467. * AUTO-GENERATED FILE. DO NOT MODIFY.
  61468. */
  61469. /*
  61470. * Licensed to the Apache Software Foundation (ASF) under one
  61471. * or more contributor license agreements. See the NOTICE file
  61472. * distributed with this work for additional information
  61473. * regarding copyright ownership. The ASF licenses this file
  61474. * to you under the Apache License, Version 2.0 (the
  61475. * "License"); you may not use this file except in compliance
  61476. * with the License. You may obtain a copy of the License at
  61477. *
  61478. * http://www.apache.org/licenses/LICENSE-2.0
  61479. *
  61480. * Unless required by applicable law or agreed to in writing,
  61481. * software distributed under the License is distributed on an
  61482. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61483. * KIND, either express or implied. See the License for the
  61484. * specific language governing permissions and limitations
  61485. * under the License.
  61486. */
  61487. function generateNodeKey(id) {
  61488. return '_EC_' + id;
  61489. }
  61490. var Graph =
  61491. /** @class */
  61492. function () {
  61493. function Graph(directed) {
  61494. this.type = 'graph';
  61495. this.nodes = [];
  61496. this.edges = [];
  61497. this._nodesMap = {};
  61498. /**
  61499. * @type {Object.<string, module:echarts/data/Graph.Edge>}
  61500. * @private
  61501. */
  61502. this._edgesMap = {};
  61503. this._directed = directed || false;
  61504. }
  61505. /**
  61506. * If is directed graph
  61507. */
  61508. Graph.prototype.isDirected = function () {
  61509. return this._directed;
  61510. };
  61511. /**
  61512. * Add a new node
  61513. */
  61514. Graph.prototype.addNode = function (id, dataIndex) {
  61515. id = id == null ? '' + dataIndex : '' + id;
  61516. var nodesMap = this._nodesMap;
  61517. if (nodesMap[generateNodeKey(id)]) {
  61518. {
  61519. console.error('Graph nodes have duplicate name or id');
  61520. }
  61521. return;
  61522. }
  61523. var node = new GraphNode(id, dataIndex);
  61524. node.hostGraph = this;
  61525. this.nodes.push(node);
  61526. nodesMap[generateNodeKey(id)] = node;
  61527. return node;
  61528. };
  61529. /**
  61530. * Get node by data index
  61531. */
  61532. Graph.prototype.getNodeByIndex = function (dataIndex) {
  61533. var rawIdx = this.data.getRawIndex(dataIndex);
  61534. return this.nodes[rawIdx];
  61535. };
  61536. /**
  61537. * Get node by id
  61538. */
  61539. Graph.prototype.getNodeById = function (id) {
  61540. return this._nodesMap[generateNodeKey(id)];
  61541. };
  61542. /**
  61543. * Add a new edge
  61544. */
  61545. Graph.prototype.addEdge = function (n1, n2, dataIndex) {
  61546. var nodesMap = this._nodesMap;
  61547. var edgesMap = this._edgesMap; // PNEDING
  61548. if (typeof n1 === 'number') {
  61549. n1 = this.nodes[n1];
  61550. }
  61551. if (typeof n2 === 'number') {
  61552. n2 = this.nodes[n2];
  61553. }
  61554. if (!(n1 instanceof GraphNode)) {
  61555. n1 = nodesMap[generateNodeKey(n1)];
  61556. }
  61557. if (!(n2 instanceof GraphNode)) {
  61558. n2 = nodesMap[generateNodeKey(n2)];
  61559. }
  61560. if (!n1 || !n2) {
  61561. return;
  61562. }
  61563. var key = n1.id + '-' + n2.id;
  61564. var edge = new GraphEdge(n1, n2, dataIndex);
  61565. edge.hostGraph = this;
  61566. if (this._directed) {
  61567. n1.outEdges.push(edge);
  61568. n2.inEdges.push(edge);
  61569. }
  61570. n1.edges.push(edge);
  61571. if (n1 !== n2) {
  61572. n2.edges.push(edge);
  61573. }
  61574. this.edges.push(edge);
  61575. edgesMap[key] = edge;
  61576. return edge;
  61577. };
  61578. /**
  61579. * Get edge by data index
  61580. */
  61581. Graph.prototype.getEdgeByIndex = function (dataIndex) {
  61582. var rawIdx = this.edgeData.getRawIndex(dataIndex);
  61583. return this.edges[rawIdx];
  61584. };
  61585. /**
  61586. * Get edge by two linked nodes
  61587. */
  61588. Graph.prototype.getEdge = function (n1, n2) {
  61589. if (n1 instanceof GraphNode) {
  61590. n1 = n1.id;
  61591. }
  61592. if (n2 instanceof GraphNode) {
  61593. n2 = n2.id;
  61594. }
  61595. var edgesMap = this._edgesMap;
  61596. if (this._directed) {
  61597. return edgesMap[n1 + '-' + n2];
  61598. } else {
  61599. return edgesMap[n1 + '-' + n2] || edgesMap[n2 + '-' + n1];
  61600. }
  61601. };
  61602. /**
  61603. * Iterate all nodes
  61604. */
  61605. Graph.prototype.eachNode = function (cb, context) {
  61606. var nodes = this.nodes;
  61607. var len = nodes.length;
  61608. for (var i = 0; i < len; i++) {
  61609. if (nodes[i].dataIndex >= 0) {
  61610. cb.call(context, nodes[i], i);
  61611. }
  61612. }
  61613. };
  61614. /**
  61615. * Iterate all edges
  61616. */
  61617. Graph.prototype.eachEdge = function (cb, context) {
  61618. var edges = this.edges;
  61619. var len = edges.length;
  61620. for (var i = 0; i < len; i++) {
  61621. if (edges[i].dataIndex >= 0 && edges[i].node1.dataIndex >= 0 && edges[i].node2.dataIndex >= 0) {
  61622. cb.call(context, edges[i], i);
  61623. }
  61624. }
  61625. };
  61626. /**
  61627. * Breadth first traverse
  61628. * Return true to stop traversing
  61629. */
  61630. Graph.prototype.breadthFirstTraverse = function (cb, startNode, direction, context) {
  61631. if (!(startNode instanceof GraphNode)) {
  61632. startNode = this._nodesMap[generateNodeKey(startNode)];
  61633. }
  61634. if (!startNode) {
  61635. return;
  61636. }
  61637. var edgeType = direction === 'out' ? 'outEdges' : direction === 'in' ? 'inEdges' : 'edges';
  61638. for (var i = 0; i < this.nodes.length; i++) {
  61639. this.nodes[i].__visited = false;
  61640. }
  61641. if (cb.call(context, startNode, null)) {
  61642. return;
  61643. }
  61644. var queue = [startNode];
  61645. while (queue.length) {
  61646. var currentNode = queue.shift();
  61647. var edges = currentNode[edgeType];
  61648. for (var i = 0; i < edges.length; i++) {
  61649. var e = edges[i];
  61650. var otherNode = e.node1 === currentNode ? e.node2 : e.node1;
  61651. if (!otherNode.__visited) {
  61652. if (cb.call(context, otherNode, currentNode)) {
  61653. // Stop traversing
  61654. return;
  61655. }
  61656. queue.push(otherNode);
  61657. otherNode.__visited = true;
  61658. }
  61659. }
  61660. }
  61661. }; // TODO
  61662. // depthFirstTraverse(
  61663. // cb, startNode, direction, context
  61664. // ) {
  61665. // };
  61666. // Filter update
  61667. Graph.prototype.update = function () {
  61668. var data = this.data;
  61669. var edgeData = this.edgeData;
  61670. var nodes = this.nodes;
  61671. var edges = this.edges;
  61672. for (var i = 0, len = nodes.length; i < len; i++) {
  61673. nodes[i].dataIndex = -1;
  61674. }
  61675. for (var i = 0, len = data.count(); i < len; i++) {
  61676. nodes[data.getRawIndex(i)].dataIndex = i;
  61677. }
  61678. edgeData.filterSelf(function (idx) {
  61679. var edge = edges[edgeData.getRawIndex(idx)];
  61680. return edge.node1.dataIndex >= 0 && edge.node2.dataIndex >= 0;
  61681. }); // Update edge
  61682. for (var i = 0, len = edges.length; i < len; i++) {
  61683. edges[i].dataIndex = -1;
  61684. }
  61685. for (var i = 0, len = edgeData.count(); i < len; i++) {
  61686. edges[edgeData.getRawIndex(i)].dataIndex = i;
  61687. }
  61688. };
  61689. /**
  61690. * @return {module:echarts/data/Graph}
  61691. */
  61692. Graph.prototype.clone = function () {
  61693. var graph = new Graph(this._directed);
  61694. var nodes = this.nodes;
  61695. var edges = this.edges;
  61696. for (var i = 0; i < nodes.length; i++) {
  61697. graph.addNode(nodes[i].id, nodes[i].dataIndex);
  61698. }
  61699. for (var i = 0; i < edges.length; i++) {
  61700. var e = edges[i];
  61701. graph.addEdge(e.node1.id, e.node2.id, e.dataIndex);
  61702. }
  61703. return graph;
  61704. };
  61705. return Graph;
  61706. }();
  61707. var GraphNode =
  61708. /** @class */
  61709. function () {
  61710. function GraphNode(id, dataIndex) {
  61711. this.inEdges = [];
  61712. this.outEdges = [];
  61713. this.edges = [];
  61714. this.dataIndex = -1;
  61715. this.id = id == null ? '' : id;
  61716. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  61717. }
  61718. /**
  61719. * @return {number}
  61720. */
  61721. GraphNode.prototype.degree = function () {
  61722. return this.edges.length;
  61723. };
  61724. /**
  61725. * @return {number}
  61726. */
  61727. GraphNode.prototype.inDegree = function () {
  61728. return this.inEdges.length;
  61729. };
  61730. /**
  61731. * @return {number}
  61732. */
  61733. GraphNode.prototype.outDegree = function () {
  61734. return this.outEdges.length;
  61735. };
  61736. GraphNode.prototype.getModel = function (path) {
  61737. if (this.dataIndex < 0) {
  61738. return;
  61739. }
  61740. var graph = this.hostGraph;
  61741. var itemModel = graph.data.getItemModel(this.dataIndex);
  61742. return itemModel.getModel(path);
  61743. };
  61744. GraphNode.prototype.getAdjacentDataIndices = function () {
  61745. var dataIndices = {
  61746. edge: [],
  61747. node: []
  61748. };
  61749. for (var i = 0; i < this.edges.length; i++) {
  61750. var adjacentEdge = this.edges[i];
  61751. if (adjacentEdge.dataIndex < 0) {
  61752. continue;
  61753. }
  61754. dataIndices.edge.push(adjacentEdge.dataIndex);
  61755. dataIndices.node.push(adjacentEdge.node1.dataIndex, adjacentEdge.node2.dataIndex);
  61756. }
  61757. return dataIndices;
  61758. };
  61759. return GraphNode;
  61760. }();
  61761. var GraphEdge =
  61762. /** @class */
  61763. function () {
  61764. function GraphEdge(n1, n2, dataIndex) {
  61765. this.dataIndex = -1;
  61766. this.node1 = n1;
  61767. this.node2 = n2;
  61768. this.dataIndex = dataIndex == null ? -1 : dataIndex;
  61769. }
  61770. GraphEdge.prototype.getModel = function (path) {
  61771. if (this.dataIndex < 0) {
  61772. return;
  61773. }
  61774. var graph = this.hostGraph;
  61775. var itemModel = graph.edgeData.getItemModel(this.dataIndex);
  61776. return itemModel.getModel(path);
  61777. };
  61778. GraphEdge.prototype.getAdjacentDataIndices = function () {
  61779. return {
  61780. edge: [this.dataIndex],
  61781. node: [this.node1.dataIndex, this.node2.dataIndex]
  61782. };
  61783. };
  61784. return GraphEdge;
  61785. }();
  61786. function createGraphDataProxyMixin(hostName, dataName) {
  61787. return {
  61788. /**
  61789. * @param Default 'value'. can be 'a', 'b', 'c', 'd', 'e'.
  61790. */
  61791. getValue: function (dimension) {
  61792. var data = this[hostName][dataName];
  61793. return data.get(data.getDimension(dimension || 'value'), this.dataIndex);
  61794. },
  61795. // TODO: TYPE stricter type.
  61796. setVisual: function (key, value) {
  61797. this.dataIndex >= 0 && this[hostName][dataName].setItemVisual(this.dataIndex, key, value);
  61798. },
  61799. getVisual: function (key) {
  61800. return this[hostName][dataName].getItemVisual(this.dataIndex, key);
  61801. },
  61802. setLayout: function (layout, merge$$1) {
  61803. this.dataIndex >= 0 && this[hostName][dataName].setItemLayout(this.dataIndex, layout, merge$$1);
  61804. },
  61805. getLayout: function () {
  61806. return this[hostName][dataName].getItemLayout(this.dataIndex);
  61807. },
  61808. getGraphicEl: function () {
  61809. return this[hostName][dataName].getItemGraphicEl(this.dataIndex);
  61810. },
  61811. getRawIndex: function () {
  61812. return this[hostName][dataName].getRawIndex(this.dataIndex);
  61813. }
  61814. };
  61815. }
  61816. mixin(GraphNode, createGraphDataProxyMixin('hostGraph', 'data'));
  61817. mixin(GraphEdge, createGraphDataProxyMixin('hostGraph', 'edgeData'));
  61818. /*
  61819. * Licensed to the Apache Software Foundation (ASF) under one
  61820. * or more contributor license agreements. See the NOTICE file
  61821. * distributed with this work for additional information
  61822. * regarding copyright ownership. The ASF licenses this file
  61823. * to you under the Apache License, Version 2.0 (the
  61824. * "License"); you may not use this file except in compliance
  61825. * with the License. You may obtain a copy of the License at
  61826. *
  61827. * http://www.apache.org/licenses/LICENSE-2.0
  61828. *
  61829. * Unless required by applicable law or agreed to in writing,
  61830. * software distributed under the License is distributed on an
  61831. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61832. * KIND, either express or implied. See the License for the
  61833. * specific language governing permissions and limitations
  61834. * under the License.
  61835. */
  61836. /**
  61837. * AUTO-GENERATED FILE. DO NOT MODIFY.
  61838. */
  61839. /*
  61840. * Licensed to the Apache Software Foundation (ASF) under one
  61841. * or more contributor license agreements. See the NOTICE file
  61842. * distributed with this work for additional information
  61843. * regarding copyright ownership. The ASF licenses this file
  61844. * to you under the Apache License, Version 2.0 (the
  61845. * "License"); you may not use this file except in compliance
  61846. * with the License. You may obtain a copy of the License at
  61847. *
  61848. * http://www.apache.org/licenses/LICENSE-2.0
  61849. *
  61850. * Unless required by applicable law or agreed to in writing,
  61851. * software distributed under the License is distributed on an
  61852. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61853. * KIND, either express or implied. See the License for the
  61854. * specific language governing permissions and limitations
  61855. * under the License.
  61856. */
  61857. function createGraphFromNodeEdge(nodes, edges, seriesModel, directed, beforeLink) {
  61858. // ??? TODO
  61859. // support dataset?
  61860. var graph = new Graph(directed);
  61861. for (var i = 0; i < nodes.length; i++) {
  61862. graph.addNode(retrieve( // Id, name, dataIndex
  61863. nodes[i].id, nodes[i].name, i), i);
  61864. }
  61865. var linkNameList = [];
  61866. var validEdges = [];
  61867. var linkCount = 0;
  61868. for (var i = 0; i < edges.length; i++) {
  61869. var link = edges[i];
  61870. var source = link.source;
  61871. var target = link.target; // addEdge may fail when source or target not exists
  61872. if (graph.addEdge(source, target, linkCount)) {
  61873. validEdges.push(link);
  61874. linkNameList.push(retrieve(convertOptionIdName(link.id, null), source + ' > ' + target));
  61875. linkCount++;
  61876. }
  61877. }
  61878. var coordSys = seriesModel.get('coordinateSystem');
  61879. var nodeData;
  61880. if (coordSys === 'cartesian2d' || coordSys === 'polar') {
  61881. nodeData = createListFromArray(nodes, seriesModel);
  61882. } else {
  61883. var coordSysCtor = CoordinateSystemManager.get(coordSys);
  61884. var coordDimensions = coordSysCtor ? coordSysCtor.dimensions || [] : []; // FIXME: Some geo do not need `value` dimenson, whereas `calendar` needs
  61885. // `value` dimension, but graph need `value` dimension. It's better to
  61886. // uniform this behavior.
  61887. if (indexOf$1(coordDimensions, 'value') < 0) {
  61888. coordDimensions.concat(['value']);
  61889. }
  61890. var dimensionNames = createDimensions(nodes, {
  61891. coordDimensions: coordDimensions
  61892. });
  61893. nodeData = new List(dimensionNames, seriesModel);
  61894. nodeData.initData(nodes);
  61895. }
  61896. var edgeData = new List(['value'], seriesModel);
  61897. edgeData.initData(validEdges, linkNameList);
  61898. beforeLink && beforeLink(nodeData, edgeData);
  61899. linkList({
  61900. mainData: nodeData,
  61901. struct: graph,
  61902. structAttr: 'graph',
  61903. datas: {
  61904. node: nodeData,
  61905. edge: edgeData
  61906. },
  61907. datasAttr: {
  61908. node: 'data',
  61909. edge: 'edgeData'
  61910. }
  61911. }); // Update dataIndex of nodes and edges because invalid edge may be removed
  61912. graph.update();
  61913. return graph;
  61914. }
  61915. /*
  61916. * Licensed to the Apache Software Foundation (ASF) under one
  61917. * or more contributor license agreements. See the NOTICE file
  61918. * distributed with this work for additional information
  61919. * regarding copyright ownership. The ASF licenses this file
  61920. * to you under the Apache License, Version 2.0 (the
  61921. * "License"); you may not use this file except in compliance
  61922. * with the License. You may obtain a copy of the License at
  61923. *
  61924. * http://www.apache.org/licenses/LICENSE-2.0
  61925. *
  61926. * Unless required by applicable law or agreed to in writing,
  61927. * software distributed under the License is distributed on an
  61928. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61929. * KIND, either express or implied. See the License for the
  61930. * specific language governing permissions and limitations
  61931. * under the License.
  61932. */
  61933. /**
  61934. * AUTO-GENERATED FILE. DO NOT MODIFY.
  61935. */
  61936. /*
  61937. * Licensed to the Apache Software Foundation (ASF) under one
  61938. * or more contributor license agreements. See the NOTICE file
  61939. * distributed with this work for additional information
  61940. * regarding copyright ownership. The ASF licenses this file
  61941. * to you under the Apache License, Version 2.0 (the
  61942. * "License"); you may not use this file except in compliance
  61943. * with the License. You may obtain a copy of the License at
  61944. *
  61945. * http://www.apache.org/licenses/LICENSE-2.0
  61946. *
  61947. * Unless required by applicable law or agreed to in writing,
  61948. * software distributed under the License is distributed on an
  61949. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  61950. * KIND, either express or implied. See the License for the
  61951. * specific language governing permissions and limitations
  61952. * under the License.
  61953. */
  61954. var GraphSeriesModel =
  61955. /** @class */
  61956. function (_super) {
  61957. __extends(GraphSeriesModel, _super);
  61958. function GraphSeriesModel() {
  61959. var _this = _super !== null && _super.apply(this, arguments) || this;
  61960. _this.type = GraphSeriesModel.type;
  61961. _this.hasSymbolVisual = true;
  61962. return _this;
  61963. }
  61964. GraphSeriesModel.prototype.init = function (option) {
  61965. _super.prototype.init.apply(this, arguments);
  61966. var self = this;
  61967. function getCategoriesData() {
  61968. return self._categoriesData;
  61969. } // Provide data for legend select
  61970. this.legendVisualProvider = new LegendVisualProvider(getCategoriesData, getCategoriesData);
  61971. this.fillDataTextStyle(option.edges || option.links);
  61972. this._updateCategoriesData();
  61973. };
  61974. GraphSeriesModel.prototype.mergeOption = function (option) {
  61975. _super.prototype.mergeOption.apply(this, arguments);
  61976. this.fillDataTextStyle(option.edges || option.links);
  61977. this._updateCategoriesData();
  61978. };
  61979. GraphSeriesModel.prototype.mergeDefaultAndTheme = function (option) {
  61980. _super.prototype.mergeDefaultAndTheme.apply(this, arguments);
  61981. defaultEmphasis(option, 'edgeLabel', ['show']);
  61982. };
  61983. GraphSeriesModel.prototype.getInitialData = function (option, ecModel) {
  61984. var edges = option.edges || option.links || [];
  61985. var nodes = option.data || option.nodes || [];
  61986. var self = this;
  61987. if (nodes && edges) {
  61988. // auto curveness
  61989. initCurvenessList(this);
  61990. var graph = createGraphFromNodeEdge(nodes, edges, this, true, beforeLink);
  61991. each$1(graph.edges, function (edge) {
  61992. createEdgeMapForCurveness(edge.node1, edge.node2, this, edge.dataIndex);
  61993. }, this);
  61994. return graph.data;
  61995. }
  61996. function beforeLink(nodeData, edgeData) {
  61997. // Overwrite nodeData.getItemModel to
  61998. nodeData.wrapMethod('getItemModel', function (model) {
  61999. var categoriesModels = self._categoriesModels;
  62000. var categoryIdx = model.getShallow('category');
  62001. var categoryModel = categoriesModels[categoryIdx];
  62002. if (categoryModel) {
  62003. categoryModel.parentModel = model.parentModel;
  62004. model.parentModel = categoryModel;
  62005. }
  62006. return model;
  62007. }); // TODO Inherit resolveParentPath by default in Model#getModel?
  62008. var oldGetModel = Model.prototype.getModel;
  62009. function newGetModel(path, parentModel) {
  62010. var model = oldGetModel.call(this, path, parentModel);
  62011. model.resolveParentPath = resolveParentPath;
  62012. return model;
  62013. }
  62014. edgeData.wrapMethod('getItemModel', function (model) {
  62015. model.resolveParentPath = resolveParentPath;
  62016. model.getModel = newGetModel;
  62017. return model;
  62018. });
  62019. function resolveParentPath(pathArr) {
  62020. if (pathArr && (pathArr[0] === 'label' || pathArr[1] === 'label')) {
  62021. var newPathArr = pathArr.slice();
  62022. if (pathArr[0] === 'label') {
  62023. newPathArr[0] = 'edgeLabel';
  62024. } else if (pathArr[1] === 'label') {
  62025. newPathArr[1] = 'edgeLabel';
  62026. }
  62027. return newPathArr;
  62028. }
  62029. return pathArr;
  62030. }
  62031. }
  62032. };
  62033. GraphSeriesModel.prototype.getGraph = function () {
  62034. return this.getData().graph;
  62035. };
  62036. GraphSeriesModel.prototype.getEdgeData = function () {
  62037. return this.getGraph().edgeData;
  62038. };
  62039. GraphSeriesModel.prototype.getCategoriesData = function () {
  62040. return this._categoriesData;
  62041. };
  62042. GraphSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  62043. if (dataType === 'edge') {
  62044. var nodeData = this.getData();
  62045. var params = this.getDataParams(dataIndex, dataType);
  62046. var edge = nodeData.graph.getEdgeByIndex(dataIndex);
  62047. var sourceName = nodeData.getName(edge.node1.dataIndex);
  62048. var targetName = nodeData.getName(edge.node2.dataIndex);
  62049. var nameArr = [];
  62050. sourceName != null && nameArr.push(sourceName);
  62051. targetName != null && nameArr.push(targetName);
  62052. return createTooltipMarkup('nameValue', {
  62053. name: nameArr.join(' > '),
  62054. value: params.value,
  62055. noValue: params.value == null
  62056. });
  62057. } // dataType === 'node' or empty
  62058. var nodeMarkup = defaultSeriesFormatTooltip({
  62059. series: this,
  62060. dataIndex: dataIndex,
  62061. multipleSeries: multipleSeries
  62062. });
  62063. return nodeMarkup;
  62064. };
  62065. GraphSeriesModel.prototype._updateCategoriesData = function () {
  62066. var categories = map(this.option.categories || [], function (category) {
  62067. // Data must has value
  62068. return category.value != null ? category : extend({
  62069. value: 0
  62070. }, category);
  62071. });
  62072. var categoriesData = new List(['value'], this);
  62073. categoriesData.initData(categories);
  62074. this._categoriesData = categoriesData;
  62075. this._categoriesModels = categoriesData.mapArray(function (idx) {
  62076. return categoriesData.getItemModel(idx);
  62077. });
  62078. };
  62079. GraphSeriesModel.prototype.setZoom = function (zoom) {
  62080. this.option.zoom = zoom;
  62081. };
  62082. GraphSeriesModel.prototype.setCenter = function (center) {
  62083. this.option.center = center;
  62084. };
  62085. GraphSeriesModel.prototype.isAnimationEnabled = function () {
  62086. return _super.prototype.isAnimationEnabled.call(this) // Not enable animation when do force layout
  62087. && !(this.get('layout') === 'force' && this.get(['force', 'layoutAnimation']));
  62088. };
  62089. GraphSeriesModel.type = 'series.graph';
  62090. GraphSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar'];
  62091. GraphSeriesModel.defaultOption = {
  62092. zlevel: 0,
  62093. z: 2,
  62094. coordinateSystem: 'view',
  62095. // Default option for all coordinate systems
  62096. // xAxisIndex: 0,
  62097. // yAxisIndex: 0,
  62098. // polarIndex: 0,
  62099. // geoIndex: 0,
  62100. legendHoverLink: true,
  62101. layout: null,
  62102. // Configuration of circular layout
  62103. circular: {
  62104. rotateLabel: false
  62105. },
  62106. // Configuration of force directed layout
  62107. force: {
  62108. initLayout: null,
  62109. // Node repulsion. Can be an array to represent range.
  62110. repulsion: [0, 50],
  62111. gravity: 0.1,
  62112. // Initial friction
  62113. friction: 0.6,
  62114. // Edge length. Can be an array to represent range.
  62115. edgeLength: 30,
  62116. layoutAnimation: true
  62117. },
  62118. left: 'center',
  62119. top: 'center',
  62120. // right: null,
  62121. // bottom: null,
  62122. // width: '80%',
  62123. // height: '80%',
  62124. symbol: 'circle',
  62125. symbolSize: 10,
  62126. edgeSymbol: ['none', 'none'],
  62127. edgeSymbolSize: 10,
  62128. edgeLabel: {
  62129. position: 'middle',
  62130. distance: 5
  62131. },
  62132. draggable: false,
  62133. roam: false,
  62134. // Default on center of graph
  62135. center: null,
  62136. zoom: 1,
  62137. // Symbol size scale ratio in roam
  62138. nodeScaleRatio: 0.6,
  62139. // cursor: null,
  62140. // categories: [],
  62141. // data: []
  62142. // Or
  62143. // nodes: []
  62144. //
  62145. // links: []
  62146. // Or
  62147. // edges: []
  62148. label: {
  62149. show: false,
  62150. formatter: '{b}'
  62151. },
  62152. itemStyle: {},
  62153. lineStyle: {
  62154. color: '#aaa',
  62155. width: 1,
  62156. opacity: 0.5
  62157. },
  62158. emphasis: {
  62159. scale: true,
  62160. label: {
  62161. show: true
  62162. }
  62163. },
  62164. select: {
  62165. itemStyle: {
  62166. borderColor: '#212121'
  62167. }
  62168. }
  62169. };
  62170. return GraphSeriesModel;
  62171. }(SeriesModel);
  62172. /*
  62173. * Licensed to the Apache Software Foundation (ASF) under one
  62174. * or more contributor license agreements. See the NOTICE file
  62175. * distributed with this work for additional information
  62176. * regarding copyright ownership. The ASF licenses this file
  62177. * to you under the Apache License, Version 2.0 (the
  62178. * "License"); you may not use this file except in compliance
  62179. * with the License. You may obtain a copy of the License at
  62180. *
  62181. * http://www.apache.org/licenses/LICENSE-2.0
  62182. *
  62183. * Unless required by applicable law or agreed to in writing,
  62184. * software distributed under the License is distributed on an
  62185. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62186. * KIND, either express or implied. See the License for the
  62187. * specific language governing permissions and limitations
  62188. * under the License.
  62189. */
  62190. /**
  62191. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62192. */
  62193. /*
  62194. * Licensed to the Apache Software Foundation (ASF) under one
  62195. * or more contributor license agreements. See the NOTICE file
  62196. * distributed with this work for additional information
  62197. * regarding copyright ownership. The ASF licenses this file
  62198. * to you under the Apache License, Version 2.0 (the
  62199. * "License"); you may not use this file except in compliance
  62200. * with the License. You may obtain a copy of the License at
  62201. *
  62202. * http://www.apache.org/licenses/LICENSE-2.0
  62203. *
  62204. * Unless required by applicable law or agreed to in writing,
  62205. * software distributed under the License is distributed on an
  62206. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62207. * KIND, either express or implied. See the License for the
  62208. * specific language governing permissions and limitations
  62209. * under the License.
  62210. */
  62211. var actionInfo = {
  62212. type: 'graphRoam',
  62213. event: 'graphRoam',
  62214. update: 'none'
  62215. };
  62216. function install$18(registers) {
  62217. registers.registerChartView(GraphView);
  62218. registers.registerSeriesModel(GraphSeriesModel);
  62219. registers.registerProcessor(categoryFilter);
  62220. registers.registerVisual(categoryVisual);
  62221. registers.registerVisual(graphEdgeVisual);
  62222. registers.registerLayout(graphSimpleLayout);
  62223. registers.registerLayout(registers.PRIORITY.VISUAL.POST_CHART_LAYOUT, graphCircularLayout);
  62224. registers.registerLayout(graphForceLayout);
  62225. registers.registerCoordinateSystem('graphView', {
  62226. dimensions: View.dimensions,
  62227. create: createViewCoordSys
  62228. }); // Register legacy focus actions
  62229. registers.registerAction({
  62230. type: 'focusNodeAdjacency',
  62231. event: 'focusNodeAdjacency',
  62232. update: 'series:focusNodeAdjacency'
  62233. }, function () {});
  62234. registers.registerAction({
  62235. type: 'unfocusNodeAdjacency',
  62236. event: 'unfocusNodeAdjacency',
  62237. update: 'series:unfocusNodeAdjacency'
  62238. }, function () {}); // Register roam action.
  62239. registers.registerAction(actionInfo, function (payload, ecModel) {
  62240. ecModel.eachComponent({
  62241. mainType: 'series',
  62242. query: payload
  62243. }, function (seriesModel) {
  62244. var coordSys = seriesModel.coordinateSystem;
  62245. var res = updateCenterAndZoom(coordSys, payload);
  62246. seriesModel.setCenter && seriesModel.setCenter(res.center);
  62247. seriesModel.setZoom && seriesModel.setZoom(res.zoom);
  62248. });
  62249. });
  62250. }
  62251. /*
  62252. * Licensed to the Apache Software Foundation (ASF) under one
  62253. * or more contributor license agreements. See the NOTICE file
  62254. * distributed with this work for additional information
  62255. * regarding copyright ownership. The ASF licenses this file
  62256. * to you under the Apache License, Version 2.0 (the
  62257. * "License"); you may not use this file except in compliance
  62258. * with the License. You may obtain a copy of the License at
  62259. *
  62260. * http://www.apache.org/licenses/LICENSE-2.0
  62261. *
  62262. * Unless required by applicable law or agreed to in writing,
  62263. * software distributed under the License is distributed on an
  62264. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62265. * KIND, either express or implied. See the License for the
  62266. * specific language governing permissions and limitations
  62267. * under the License.
  62268. */
  62269. /**
  62270. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62271. */
  62272. /*
  62273. * Licensed to the Apache Software Foundation (ASF) under one
  62274. * or more contributor license agreements. See the NOTICE file
  62275. * distributed with this work for additional information
  62276. * regarding copyright ownership. The ASF licenses this file
  62277. * to you under the Apache License, Version 2.0 (the
  62278. * "License"); you may not use this file except in compliance
  62279. * with the License. You may obtain a copy of the License at
  62280. *
  62281. * http://www.apache.org/licenses/LICENSE-2.0
  62282. *
  62283. * Unless required by applicable law or agreed to in writing,
  62284. * software distributed under the License is distributed on an
  62285. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62286. * KIND, either express or implied. See the License for the
  62287. * specific language governing permissions and limitations
  62288. * under the License.
  62289. */
  62290. use(install$18);
  62291. /*
  62292. * Licensed to the Apache Software Foundation (ASF) under one
  62293. * or more contributor license agreements. See the NOTICE file
  62294. * distributed with this work for additional information
  62295. * regarding copyright ownership. The ASF licenses this file
  62296. * to you under the Apache License, Version 2.0 (the
  62297. * "License"); you may not use this file except in compliance
  62298. * with the License. You may obtain a copy of the License at
  62299. *
  62300. * http://www.apache.org/licenses/LICENSE-2.0
  62301. *
  62302. * Unless required by applicable law or agreed to in writing,
  62303. * software distributed under the License is distributed on an
  62304. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62305. * KIND, either express or implied. See the License for the
  62306. * specific language governing permissions and limitations
  62307. * under the License.
  62308. */
  62309. /**
  62310. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62311. */
  62312. /*
  62313. * Licensed to the Apache Software Foundation (ASF) under one
  62314. * or more contributor license agreements. See the NOTICE file
  62315. * distributed with this work for additional information
  62316. * regarding copyright ownership. The ASF licenses this file
  62317. * to you under the Apache License, Version 2.0 (the
  62318. * "License"); you may not use this file except in compliance
  62319. * with the License. You may obtain a copy of the License at
  62320. *
  62321. * http://www.apache.org/licenses/LICENSE-2.0
  62322. *
  62323. * Unless required by applicable law or agreed to in writing,
  62324. * software distributed under the License is distributed on an
  62325. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62326. * KIND, either express or implied. See the License for the
  62327. * specific language governing permissions and limitations
  62328. * under the License.
  62329. */
  62330. var BoxplotSeriesModel =
  62331. /** @class */
  62332. function (_super) {
  62333. __extends(BoxplotSeriesModel, _super);
  62334. function BoxplotSeriesModel() {
  62335. var _this = _super !== null && _super.apply(this, arguments) || this;
  62336. _this.type = BoxplotSeriesModel.type; // TODO
  62337. // box width represents group size, so dimension should have 'size'.
  62338. /**
  62339. * @see <https://en.wikipedia.org/wiki/Box_plot>
  62340. * The meanings of 'min' and 'max' depend on user,
  62341. * and echarts do not need to know it.
  62342. * @readOnly
  62343. */
  62344. _this.defaultValueDimensions = [{
  62345. name: 'min',
  62346. defaultTooltip: true
  62347. }, {
  62348. name: 'Q1',
  62349. defaultTooltip: true
  62350. }, {
  62351. name: 'median',
  62352. defaultTooltip: true
  62353. }, {
  62354. name: 'Q3',
  62355. defaultTooltip: true
  62356. }, {
  62357. name: 'max',
  62358. defaultTooltip: true
  62359. }];
  62360. _this.visualDrawType = 'stroke';
  62361. return _this;
  62362. }
  62363. BoxplotSeriesModel.type = 'series.boxplot';
  62364. BoxplotSeriesModel.dependencies = ['xAxis', 'yAxis', 'grid'];
  62365. BoxplotSeriesModel.defaultOption = {
  62366. zlevel: 0,
  62367. z: 2,
  62368. coordinateSystem: 'cartesian2d',
  62369. legendHoverLink: true,
  62370. layout: null,
  62371. boxWidth: [7, 50],
  62372. itemStyle: {
  62373. color: '#fff',
  62374. borderWidth: 1
  62375. },
  62376. emphasis: {
  62377. scale: true,
  62378. itemStyle: {
  62379. borderWidth: 2,
  62380. shadowBlur: 5,
  62381. shadowOffsetX: 1,
  62382. shadowOffsetY: 1,
  62383. shadowColor: 'rgba(0,0,0,0.2)'
  62384. }
  62385. },
  62386. animationDuration: 800
  62387. };
  62388. return BoxplotSeriesModel;
  62389. }(SeriesModel);
  62390. mixin(BoxplotSeriesModel, WhiskerBoxCommonMixin, true);
  62391. /*
  62392. * Licensed to the Apache Software Foundation (ASF) under one
  62393. * or more contributor license agreements. See the NOTICE file
  62394. * distributed with this work for additional information
  62395. * regarding copyright ownership. The ASF licenses this file
  62396. * to you under the Apache License, Version 2.0 (the
  62397. * "License"); you may not use this file except in compliance
  62398. * with the License. You may obtain a copy of the License at
  62399. *
  62400. * http://www.apache.org/licenses/LICENSE-2.0
  62401. *
  62402. * Unless required by applicable law or agreed to in writing,
  62403. * software distributed under the License is distributed on an
  62404. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62405. * KIND, either express or implied. See the License for the
  62406. * specific language governing permissions and limitations
  62407. * under the License.
  62408. */
  62409. /**
  62410. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62411. */
  62412. /*
  62413. * Licensed to the Apache Software Foundation (ASF) under one
  62414. * or more contributor license agreements. See the NOTICE file
  62415. * distributed with this work for additional information
  62416. * regarding copyright ownership. The ASF licenses this file
  62417. * to you under the Apache License, Version 2.0 (the
  62418. * "License"); you may not use this file except in compliance
  62419. * with the License. You may obtain a copy of the License at
  62420. *
  62421. * http://www.apache.org/licenses/LICENSE-2.0
  62422. *
  62423. * Unless required by applicable law or agreed to in writing,
  62424. * software distributed under the License is distributed on an
  62425. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62426. * KIND, either express or implied. See the License for the
  62427. * specific language governing permissions and limitations
  62428. * under the License.
  62429. */
  62430. var BoxplotView =
  62431. /** @class */
  62432. function (_super) {
  62433. __extends(BoxplotView, _super);
  62434. function BoxplotView() {
  62435. var _this = _super !== null && _super.apply(this, arguments) || this;
  62436. _this.type = BoxplotView.type;
  62437. return _this;
  62438. }
  62439. BoxplotView.prototype.render = function (seriesModel, ecModel, api) {
  62440. var data = seriesModel.getData();
  62441. var group = this.group;
  62442. var oldData = this._data; // There is no old data only when first rendering or switching from
  62443. // stream mode to normal mode, where previous elements should be removed.
  62444. if (!this._data) {
  62445. group.removeAll();
  62446. }
  62447. var constDim = seriesModel.get('layout') === 'horizontal' ? 1 : 0;
  62448. data.diff(oldData).add(function (newIdx) {
  62449. if (data.hasValue(newIdx)) {
  62450. var itemLayout = data.getItemLayout(newIdx);
  62451. var symbolEl = createNormalBox$1(itemLayout, data, newIdx, constDim, true);
  62452. data.setItemGraphicEl(newIdx, symbolEl);
  62453. group.add(symbolEl);
  62454. }
  62455. }).update(function (newIdx, oldIdx) {
  62456. var symbolEl = oldData.getItemGraphicEl(oldIdx); // Empty data
  62457. if (!data.hasValue(newIdx)) {
  62458. group.remove(symbolEl);
  62459. return;
  62460. }
  62461. var itemLayout = data.getItemLayout(newIdx);
  62462. if (!symbolEl) {
  62463. symbolEl = createNormalBox$1(itemLayout, data, newIdx, constDim);
  62464. } else {
  62465. updateNormalBoxData(itemLayout, symbolEl, data, newIdx);
  62466. }
  62467. group.add(symbolEl);
  62468. data.setItemGraphicEl(newIdx, symbolEl);
  62469. }).remove(function (oldIdx) {
  62470. var el = oldData.getItemGraphicEl(oldIdx);
  62471. el && group.remove(el);
  62472. }).execute();
  62473. this._data = data;
  62474. };
  62475. BoxplotView.prototype.remove = function (ecModel) {
  62476. var group = this.group;
  62477. var data = this._data;
  62478. this._data = null;
  62479. data && data.eachItemGraphicEl(function (el) {
  62480. el && group.remove(el);
  62481. });
  62482. };
  62483. BoxplotView.type = 'boxplot';
  62484. return BoxplotView;
  62485. }(ChartView);
  62486. var BoxPathShape =
  62487. /** @class */
  62488. function () {
  62489. function BoxPathShape() {}
  62490. return BoxPathShape;
  62491. }();
  62492. var BoxPath =
  62493. /** @class */
  62494. function (_super) {
  62495. __extends(BoxPath, _super);
  62496. function BoxPath(opts) {
  62497. var _this = _super.call(this, opts) || this;
  62498. _this.type = 'boxplotBoxPath';
  62499. return _this;
  62500. }
  62501. BoxPath.prototype.getDefaultShape = function () {
  62502. return new BoxPathShape();
  62503. };
  62504. BoxPath.prototype.buildPath = function (ctx, shape) {
  62505. var ends = shape.points;
  62506. var i = 0;
  62507. ctx.moveTo(ends[i][0], ends[i][1]);
  62508. i++;
  62509. for (; i < 4; i++) {
  62510. ctx.lineTo(ends[i][0], ends[i][1]);
  62511. }
  62512. ctx.closePath();
  62513. for (; i < ends.length; i++) {
  62514. ctx.moveTo(ends[i][0], ends[i][1]);
  62515. i++;
  62516. ctx.lineTo(ends[i][0], ends[i][1]);
  62517. }
  62518. };
  62519. return BoxPath;
  62520. }(Path);
  62521. function createNormalBox$1(itemLayout, data, dataIndex, constDim, isInit) {
  62522. var ends = itemLayout.ends;
  62523. var el = new BoxPath({
  62524. shape: {
  62525. points: isInit ? transInit$1(ends, constDim, itemLayout) : ends
  62526. }
  62527. });
  62528. updateNormalBoxData(itemLayout, el, data, dataIndex, isInit);
  62529. return el;
  62530. }
  62531. function updateNormalBoxData(itemLayout, el, data, dataIndex, isInit) {
  62532. var seriesModel = data.hostModel;
  62533. var updateMethod = graphic[isInit ? 'initProps' : 'updateProps'];
  62534. updateMethod(el, {
  62535. shape: {
  62536. points: itemLayout.ends
  62537. }
  62538. }, seriesModel, dataIndex);
  62539. el.useStyle(data.getItemVisual(dataIndex, 'style'));
  62540. el.style.strokeNoScale = true;
  62541. el.z2 = 100;
  62542. var itemModel = data.getItemModel(dataIndex);
  62543. setStatesStylesFromModel(el, itemModel);
  62544. enableHoverEmphasis(el, itemModel.get(['emphasis', 'focus']), itemModel.get(['emphasis', 'blurScope']));
  62545. }
  62546. function transInit$1(points, dim, itemLayout) {
  62547. return map(points, function (point) {
  62548. point = point.slice();
  62549. point[dim] = itemLayout.initBaseline;
  62550. return point;
  62551. });
  62552. }
  62553. /*
  62554. * Licensed to the Apache Software Foundation (ASF) under one
  62555. * or more contributor license agreements. See the NOTICE file
  62556. * distributed with this work for additional information
  62557. * regarding copyright ownership. The ASF licenses this file
  62558. * to you under the Apache License, Version 2.0 (the
  62559. * "License"); you may not use this file except in compliance
  62560. * with the License. You may obtain a copy of the License at
  62561. *
  62562. * http://www.apache.org/licenses/LICENSE-2.0
  62563. *
  62564. * Unless required by applicable law or agreed to in writing,
  62565. * software distributed under the License is distributed on an
  62566. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62567. * KIND, either express or implied. See the License for the
  62568. * specific language governing permissions and limitations
  62569. * under the License.
  62570. */
  62571. /**
  62572. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62573. */
  62574. /*
  62575. * Licensed to the Apache Software Foundation (ASF) under one
  62576. * or more contributor license agreements. See the NOTICE file
  62577. * distributed with this work for additional information
  62578. * regarding copyright ownership. The ASF licenses this file
  62579. * to you under the Apache License, Version 2.0 (the
  62580. * "License"); you may not use this file except in compliance
  62581. * with the License. You may obtain a copy of the License at
  62582. *
  62583. * http://www.apache.org/licenses/LICENSE-2.0
  62584. *
  62585. * Unless required by applicable law or agreed to in writing,
  62586. * software distributed under the License is distributed on an
  62587. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62588. * KIND, either express or implied. See the License for the
  62589. * specific language governing permissions and limitations
  62590. * under the License.
  62591. */
  62592. function boxplotVisual(ecModel, api) {}
  62593. /*
  62594. * Licensed to the Apache Software Foundation (ASF) under one
  62595. * or more contributor license agreements. See the NOTICE file
  62596. * distributed with this work for additional information
  62597. * regarding copyright ownership. The ASF licenses this file
  62598. * to you under the Apache License, Version 2.0 (the
  62599. * "License"); you may not use this file except in compliance
  62600. * with the License. You may obtain a copy of the License at
  62601. *
  62602. * http://www.apache.org/licenses/LICENSE-2.0
  62603. *
  62604. * Unless required by applicable law or agreed to in writing,
  62605. * software distributed under the License is distributed on an
  62606. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62607. * KIND, either express or implied. See the License for the
  62608. * specific language governing permissions and limitations
  62609. * under the License.
  62610. */
  62611. /**
  62612. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62613. */
  62614. /*
  62615. * Licensed to the Apache Software Foundation (ASF) under one
  62616. * or more contributor license agreements. See the NOTICE file
  62617. * distributed with this work for additional information
  62618. * regarding copyright ownership. The ASF licenses this file
  62619. * to you under the Apache License, Version 2.0 (the
  62620. * "License"); you may not use this file except in compliance
  62621. * with the License. You may obtain a copy of the License at
  62622. *
  62623. * http://www.apache.org/licenses/LICENSE-2.0
  62624. *
  62625. * Unless required by applicable law or agreed to in writing,
  62626. * software distributed under the License is distributed on an
  62627. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62628. * KIND, either express or implied. See the License for the
  62629. * specific language governing permissions and limitations
  62630. * under the License.
  62631. */
  62632. var each$6 = each$1;
  62633. function boxplotLayout(ecModel) {
  62634. var groupResult = groupSeriesByAxis(ecModel);
  62635. each$6(groupResult, function (groupItem) {
  62636. var seriesModels = groupItem.seriesModels;
  62637. if (!seriesModels.length) {
  62638. return;
  62639. }
  62640. calculateBase(groupItem);
  62641. each$6(seriesModels, function (seriesModel, idx) {
  62642. layoutSingleSeries(seriesModel, groupItem.boxOffsetList[idx], groupItem.boxWidthList[idx]);
  62643. });
  62644. });
  62645. }
  62646. /**
  62647. * Group series by axis.
  62648. */
  62649. function groupSeriesByAxis(ecModel) {
  62650. var result = [];
  62651. var axisList = [];
  62652. ecModel.eachSeriesByType('boxplot', function (seriesModel) {
  62653. var baseAxis = seriesModel.getBaseAxis();
  62654. var idx = indexOf$1(axisList, baseAxis);
  62655. if (idx < 0) {
  62656. idx = axisList.length;
  62657. axisList[idx] = baseAxis;
  62658. result[idx] = {
  62659. axis: baseAxis,
  62660. seriesModels: []
  62661. };
  62662. }
  62663. result[idx].seriesModels.push(seriesModel);
  62664. });
  62665. return result;
  62666. }
  62667. /**
  62668. * Calculate offset and box width for each series.
  62669. */
  62670. function calculateBase(groupItem) {
  62671. var extent;
  62672. var baseAxis = groupItem.axis;
  62673. var seriesModels = groupItem.seriesModels;
  62674. var seriesCount = seriesModels.length;
  62675. var boxWidthList = groupItem.boxWidthList = [];
  62676. var boxOffsetList = groupItem.boxOffsetList = [];
  62677. var boundList = [];
  62678. var bandWidth;
  62679. if (baseAxis.type === 'category') {
  62680. bandWidth = baseAxis.getBandWidth();
  62681. } else {
  62682. var maxDataCount_1 = 0;
  62683. each$6(seriesModels, function (seriesModel) {
  62684. maxDataCount_1 = Math.max(maxDataCount_1, seriesModel.getData().count());
  62685. });
  62686. extent = baseAxis.getExtent(), Math.abs(extent[1] - extent[0]) / maxDataCount_1;
  62687. }
  62688. each$6(seriesModels, function (seriesModel) {
  62689. var boxWidthBound = seriesModel.get('boxWidth');
  62690. if (!isArray(boxWidthBound)) {
  62691. boxWidthBound = [boxWidthBound, boxWidthBound];
  62692. }
  62693. boundList.push([parsePercent$1(boxWidthBound[0], bandWidth) || 0, parsePercent$1(boxWidthBound[1], bandWidth) || 0]);
  62694. });
  62695. var availableWidth = bandWidth * 0.8 - 2;
  62696. var boxGap = availableWidth / seriesCount * 0.3;
  62697. var boxWidth = (availableWidth - boxGap * (seriesCount - 1)) / seriesCount;
  62698. var base = boxWidth / 2 - availableWidth / 2;
  62699. each$6(seriesModels, function (seriesModel, idx) {
  62700. boxOffsetList.push(base);
  62701. base += boxGap + boxWidth;
  62702. boxWidthList.push(Math.min(Math.max(boxWidth, boundList[idx][0]), boundList[idx][1]));
  62703. });
  62704. }
  62705. /**
  62706. * Calculate points location for each series.
  62707. */
  62708. function layoutSingleSeries(seriesModel, offset, boxWidth) {
  62709. var coordSys = seriesModel.coordinateSystem;
  62710. var data = seriesModel.getData();
  62711. var halfWidth = boxWidth / 2;
  62712. var cDimIdx = seriesModel.get('layout') === 'horizontal' ? 0 : 1;
  62713. var vDimIdx = 1 - cDimIdx;
  62714. var coordDims = ['x', 'y'];
  62715. var cDim = data.mapDimension(coordDims[cDimIdx]);
  62716. var vDims = data.mapDimensionsAll(coordDims[vDimIdx]);
  62717. if (cDim == null || vDims.length < 5) {
  62718. return;
  62719. }
  62720. for (var dataIndex = 0; dataIndex < data.count(); dataIndex++) {
  62721. var axisDimVal = data.get(cDim, dataIndex);
  62722. var median = getPoint(axisDimVal, vDims[2], dataIndex);
  62723. var end1 = getPoint(axisDimVal, vDims[0], dataIndex);
  62724. var end2 = getPoint(axisDimVal, vDims[1], dataIndex);
  62725. var end4 = getPoint(axisDimVal, vDims[3], dataIndex);
  62726. var end5 = getPoint(axisDimVal, vDims[4], dataIndex);
  62727. var ends = [];
  62728. addBodyEnd(ends, end2, false);
  62729. addBodyEnd(ends, end4, true);
  62730. ends.push(end1, end2, end5, end4);
  62731. layEndLine(ends, end1);
  62732. layEndLine(ends, end5);
  62733. layEndLine(ends, median);
  62734. data.setItemLayout(dataIndex, {
  62735. initBaseline: median[vDimIdx],
  62736. ends: ends
  62737. });
  62738. }
  62739. function getPoint(axisDimVal, dim, dataIndex) {
  62740. var val = data.get(dim, dataIndex);
  62741. var p = [];
  62742. p[cDimIdx] = axisDimVal;
  62743. p[vDimIdx] = val;
  62744. var point;
  62745. if (isNaN(axisDimVal) || isNaN(val)) {
  62746. point = [NaN, NaN];
  62747. } else {
  62748. point = coordSys.dataToPoint(p);
  62749. point[cDimIdx] += offset;
  62750. }
  62751. return point;
  62752. }
  62753. function addBodyEnd(ends, point, start) {
  62754. var point1 = point.slice();
  62755. var point2 = point.slice();
  62756. point1[cDimIdx] += halfWidth;
  62757. point2[cDimIdx] -= halfWidth;
  62758. start ? ends.push(point1, point2) : ends.push(point2, point1);
  62759. }
  62760. function layEndLine(ends, endCenter) {
  62761. var from = endCenter.slice();
  62762. var to = endCenter.slice();
  62763. from[cDimIdx] -= halfWidth;
  62764. to[cDimIdx] += halfWidth;
  62765. ends.push(from, to);
  62766. }
  62767. }
  62768. /*
  62769. * Licensed to the Apache Software Foundation (ASF) under one
  62770. * or more contributor license agreements. See the NOTICE file
  62771. * distributed with this work for additional information
  62772. * regarding copyright ownership. The ASF licenses this file
  62773. * to you under the Apache License, Version 2.0 (the
  62774. * "License"); you may not use this file except in compliance
  62775. * with the License. You may obtain a copy of the License at
  62776. *
  62777. * http://www.apache.org/licenses/LICENSE-2.0
  62778. *
  62779. * Unless required by applicable law or agreed to in writing,
  62780. * software distributed under the License is distributed on an
  62781. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62782. * KIND, either express or implied. See the License for the
  62783. * specific language governing permissions and limitations
  62784. * under the License.
  62785. */
  62786. /**
  62787. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62788. */
  62789. /*
  62790. * Licensed to the Apache Software Foundation (ASF) under one
  62791. * or more contributor license agreements. See the NOTICE file
  62792. * distributed with this work for additional information
  62793. * regarding copyright ownership. The ASF licenses this file
  62794. * to you under the Apache License, Version 2.0 (the
  62795. * "License"); you may not use this file except in compliance
  62796. * with the License. You may obtain a copy of the License at
  62797. *
  62798. * http://www.apache.org/licenses/LICENSE-2.0
  62799. *
  62800. * Unless required by applicable law or agreed to in writing,
  62801. * software distributed under the License is distributed on an
  62802. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62803. * KIND, either express or implied. See the License for the
  62804. * specific language governing permissions and limitations
  62805. * under the License.
  62806. */
  62807. /**
  62808. * See:
  62809. * <https://en.wikipedia.org/wiki/Box_plot#cite_note-frigge_hoaglin_iglewicz-2>
  62810. * <http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/boxplot.stats.html>
  62811. *
  62812. * Helper method for preparing data.
  62813. *
  62814. * @param rawData like
  62815. * [
  62816. * [12,232,443], (raw data set for the first box)
  62817. * [3843,5545,1232], (raw data set for the second box)
  62818. * ...
  62819. * ]
  62820. * @param opt.boundIQR=1.5 Data less than min bound is outlier.
  62821. * default 1.5, means Q1 - 1.5 * (Q3 - Q1).
  62822. * If 'none'/0 passed, min bound will not be used.
  62823. */
  62824. function prepareBoxplotData(rawData, opt) {
  62825. opt = opt || {};
  62826. var boxData = [];
  62827. var outliers = [];
  62828. var boundIQR = opt.boundIQR;
  62829. var useExtreme = boundIQR === 'none' || boundIQR === 0;
  62830. for (var i = 0; i < rawData.length; i++) {
  62831. var ascList = asc(rawData[i].slice());
  62832. var Q1 = quantile(ascList, 0.25);
  62833. var Q2 = quantile(ascList, 0.5);
  62834. var Q3 = quantile(ascList, 0.75);
  62835. var min = ascList[0];
  62836. var max = ascList[ascList.length - 1];
  62837. var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1);
  62838. var low = useExtreme ? min : Math.max(min, Q1 - bound);
  62839. var high = useExtreme ? max : Math.min(max, Q3 + bound);
  62840. var itemNameFormatter = opt.itemNameFormatter;
  62841. var itemName = isFunction$1(itemNameFormatter) ? itemNameFormatter({
  62842. value: i
  62843. }) : isString(itemNameFormatter) ? itemNameFormatter.replace('{value}', i + '') : i + '';
  62844. boxData.push([itemName, low, Q1, Q2, Q3, high]);
  62845. for (var j = 0; j < ascList.length; j++) {
  62846. var dataItem = ascList[j];
  62847. if (dataItem < low || dataItem > high) {
  62848. var outlier = [itemName, dataItem];
  62849. outliers.push(outlier);
  62850. }
  62851. }
  62852. }
  62853. return {
  62854. boxData: boxData,
  62855. outliers: outliers
  62856. };
  62857. }
  62858. /*
  62859. * Licensed to the Apache Software Foundation (ASF) under one
  62860. * or more contributor license agreements. See the NOTICE file
  62861. * distributed with this work for additional information
  62862. * regarding copyright ownership. The ASF licenses this file
  62863. * to you under the Apache License, Version 2.0 (the
  62864. * "License"); you may not use this file except in compliance
  62865. * with the License. You may obtain a copy of the License at
  62866. *
  62867. * http://www.apache.org/licenses/LICENSE-2.0
  62868. *
  62869. * Unless required by applicable law or agreed to in writing,
  62870. * software distributed under the License is distributed on an
  62871. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62872. * KIND, either express or implied. See the License for the
  62873. * specific language governing permissions and limitations
  62874. * under the License.
  62875. */
  62876. /**
  62877. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62878. */
  62879. /*
  62880. * Licensed to the Apache Software Foundation (ASF) under one
  62881. * or more contributor license agreements. See the NOTICE file
  62882. * distributed with this work for additional information
  62883. * regarding copyright ownership. The ASF licenses this file
  62884. * to you under the Apache License, Version 2.0 (the
  62885. * "License"); you may not use this file except in compliance
  62886. * with the License. You may obtain a copy of the License at
  62887. *
  62888. * http://www.apache.org/licenses/LICENSE-2.0
  62889. *
  62890. * Unless required by applicable law or agreed to in writing,
  62891. * software distributed under the License is distributed on an
  62892. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62893. * KIND, either express or implied. See the License for the
  62894. * specific language governing permissions and limitations
  62895. * under the License.
  62896. */
  62897. var boxplotTransform = {
  62898. type: 'echarts:boxplot',
  62899. transform: function transform(params) {
  62900. var upstream = params.upstream;
  62901. if (upstream.sourceFormat !== SOURCE_FORMAT_ARRAY_ROWS) {
  62902. var errMsg = '';
  62903. {
  62904. errMsg = makePrintable('source data is not applicable for this boxplot transform. Expect number[][].');
  62905. }
  62906. throwError(errMsg);
  62907. }
  62908. var result = prepareBoxplotData(upstream.getRawData(), params.config);
  62909. return [{
  62910. dimensions: ['ItemName', 'Low', 'Q1', 'Q2', 'Q3', 'High'],
  62911. data: result.boxData
  62912. }, {
  62913. data: result.outliers
  62914. }];
  62915. }
  62916. };
  62917. /*
  62918. * Licensed to the Apache Software Foundation (ASF) under one
  62919. * or more contributor license agreements. See the NOTICE file
  62920. * distributed with this work for additional information
  62921. * regarding copyright ownership. The ASF licenses this file
  62922. * to you under the Apache License, Version 2.0 (the
  62923. * "License"); you may not use this file except in compliance
  62924. * with the License. You may obtain a copy of the License at
  62925. *
  62926. * http://www.apache.org/licenses/LICENSE-2.0
  62927. *
  62928. * Unless required by applicable law or agreed to in writing,
  62929. * software distributed under the License is distributed on an
  62930. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62931. * KIND, either express or implied. See the License for the
  62932. * specific language governing permissions and limitations
  62933. * under the License.
  62934. */
  62935. /**
  62936. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62937. */
  62938. /*
  62939. * Licensed to the Apache Software Foundation (ASF) under one
  62940. * or more contributor license agreements. See the NOTICE file
  62941. * distributed with this work for additional information
  62942. * regarding copyright ownership. The ASF licenses this file
  62943. * to you under the Apache License, Version 2.0 (the
  62944. * "License"); you may not use this file except in compliance
  62945. * with the License. You may obtain a copy of the License at
  62946. *
  62947. * http://www.apache.org/licenses/LICENSE-2.0
  62948. *
  62949. * Unless required by applicable law or agreed to in writing,
  62950. * software distributed under the License is distributed on an
  62951. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62952. * KIND, either express or implied. See the License for the
  62953. * specific language governing permissions and limitations
  62954. * under the License.
  62955. */
  62956. function install$19(registers) {
  62957. registers.registerSeriesModel(BoxplotSeriesModel);
  62958. registers.registerChartView(BoxplotView);
  62959. registers.registerVisual(boxplotVisual);
  62960. registers.registerLayout(boxplotLayout);
  62961. registers.registerTransform(boxplotTransform);
  62962. }
  62963. /*
  62964. * Licensed to the Apache Software Foundation (ASF) under one
  62965. * or more contributor license agreements. See the NOTICE file
  62966. * distributed with this work for additional information
  62967. * regarding copyright ownership. The ASF licenses this file
  62968. * to you under the Apache License, Version 2.0 (the
  62969. * "License"); you may not use this file except in compliance
  62970. * with the License. You may obtain a copy of the License at
  62971. *
  62972. * http://www.apache.org/licenses/LICENSE-2.0
  62973. *
  62974. * Unless required by applicable law or agreed to in writing,
  62975. * software distributed under the License is distributed on an
  62976. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62977. * KIND, either express or implied. See the License for the
  62978. * specific language governing permissions and limitations
  62979. * under the License.
  62980. */
  62981. /**
  62982. * AUTO-GENERATED FILE. DO NOT MODIFY.
  62983. */
  62984. /*
  62985. * Licensed to the Apache Software Foundation (ASF) under one
  62986. * or more contributor license agreements. See the NOTICE file
  62987. * distributed with this work for additional information
  62988. * regarding copyright ownership. The ASF licenses this file
  62989. * to you under the Apache License, Version 2.0 (the
  62990. * "License"); you may not use this file except in compliance
  62991. * with the License. You may obtain a copy of the License at
  62992. *
  62993. * http://www.apache.org/licenses/LICENSE-2.0
  62994. *
  62995. * Unless required by applicable law or agreed to in writing,
  62996. * software distributed under the License is distributed on an
  62997. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  62998. * KIND, either express or implied. See the License for the
  62999. * specific language governing permissions and limitations
  63000. * under the License.
  63001. */
  63002. use(install$19);
  63003. /*
  63004. * Licensed to the Apache Software Foundation (ASF) under one
  63005. * or more contributor license agreements. See the NOTICE file
  63006. * distributed with this work for additional information
  63007. * regarding copyright ownership. The ASF licenses this file
  63008. * to you under the Apache License, Version 2.0 (the
  63009. * "License"); you may not use this file except in compliance
  63010. * with the License. You may obtain a copy of the License at
  63011. *
  63012. * http://www.apache.org/licenses/LICENSE-2.0
  63013. *
  63014. * Unless required by applicable law or agreed to in writing,
  63015. * software distributed under the License is distributed on an
  63016. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63017. * KIND, either express or implied. See the License for the
  63018. * specific language governing permissions and limitations
  63019. * under the License.
  63020. */
  63021. /**
  63022. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63023. */
  63024. /*
  63025. * Licensed to the Apache Software Foundation (ASF) under one
  63026. * or more contributor license agreements. See the NOTICE file
  63027. * distributed with this work for additional information
  63028. * regarding copyright ownership. The ASF licenses this file
  63029. * to you under the Apache License, Version 2.0 (the
  63030. * "License"); you may not use this file except in compliance
  63031. * with the License. You may obtain a copy of the License at
  63032. *
  63033. * http://www.apache.org/licenses/LICENSE-2.0
  63034. *
  63035. * Unless required by applicable law or agreed to in writing,
  63036. * software distributed under the License is distributed on an
  63037. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63038. * KIND, either express or implied. See the License for the
  63039. * specific language governing permissions and limitations
  63040. * under the License.
  63041. */
  63042. var DEFAULT_SMOOTH = 0.3;
  63043. var ParallelView =
  63044. /** @class */
  63045. function (_super) {
  63046. __extends(ParallelView, _super);
  63047. function ParallelView() {
  63048. var _this = _super !== null && _super.apply(this, arguments) || this;
  63049. _this.type = ParallelView.type;
  63050. _this._dataGroup = new Group();
  63051. _this._initialized = false;
  63052. return _this;
  63053. }
  63054. ParallelView.prototype.init = function () {
  63055. this.group.add(this._dataGroup);
  63056. };
  63057. /**
  63058. * @override
  63059. */
  63060. ParallelView.prototype.render = function (seriesModel, ecModel, api, payload) {
  63061. var dataGroup = this._dataGroup;
  63062. var data = seriesModel.getData();
  63063. var oldData = this._data;
  63064. var coordSys = seriesModel.coordinateSystem;
  63065. var dimensions = coordSys.dimensions;
  63066. var seriesScope = makeSeriesScope$2(seriesModel);
  63067. data.diff(oldData).add(add).update(update).remove(remove).execute();
  63068. function add(newDataIndex) {
  63069. var line = addEl(data, dataGroup, newDataIndex, dimensions, coordSys);
  63070. updateElCommon(line, data, newDataIndex, seriesScope);
  63071. }
  63072. function update(newDataIndex, oldDataIndex) {
  63073. var line = oldData.getItemGraphicEl(oldDataIndex);
  63074. var points = createLinePoints(data, newDataIndex, dimensions, coordSys);
  63075. data.setItemGraphicEl(newDataIndex, line);
  63076. updateProps(line, {
  63077. shape: {
  63078. points: points
  63079. }
  63080. }, seriesModel, newDataIndex);
  63081. updateElCommon(line, data, newDataIndex, seriesScope);
  63082. }
  63083. function remove(oldDataIndex) {
  63084. var line = oldData.getItemGraphicEl(oldDataIndex);
  63085. dataGroup.remove(line);
  63086. } // First create
  63087. if (!this._initialized) {
  63088. this._initialized = true;
  63089. var clipPath = createGridClipShape(coordSys, seriesModel, function () {
  63090. // Callback will be invoked immediately if there is no animation
  63091. setTimeout(function () {
  63092. dataGroup.removeClipPath();
  63093. });
  63094. });
  63095. dataGroup.setClipPath(clipPath);
  63096. }
  63097. this._data = data;
  63098. };
  63099. ParallelView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
  63100. this._initialized = true;
  63101. this._data = null;
  63102. this._dataGroup.removeAll();
  63103. };
  63104. ParallelView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
  63105. var data = seriesModel.getData();
  63106. var coordSys = seriesModel.coordinateSystem;
  63107. var dimensions = coordSys.dimensions;
  63108. var seriesScope = makeSeriesScope$2(seriesModel);
  63109. for (var dataIndex = taskParams.start; dataIndex < taskParams.end; dataIndex++) {
  63110. var line = addEl(data, this._dataGroup, dataIndex, dimensions, coordSys);
  63111. line.incremental = true;
  63112. updateElCommon(line, data, dataIndex, seriesScope);
  63113. }
  63114. };
  63115. ParallelView.prototype.remove = function () {
  63116. this._dataGroup && this._dataGroup.removeAll();
  63117. this._data = null;
  63118. };
  63119. ParallelView.type = 'parallel';
  63120. return ParallelView;
  63121. }(ChartView);
  63122. function createGridClipShape(coordSys, seriesModel, cb) {
  63123. var parallelModel = coordSys.model;
  63124. var rect = coordSys.getRect();
  63125. var rectEl = new Rect({
  63126. shape: {
  63127. x: rect.x,
  63128. y: rect.y,
  63129. width: rect.width,
  63130. height: rect.height
  63131. }
  63132. });
  63133. var dim = parallelModel.get('layout') === 'horizontal' ? 'width' : 'height';
  63134. rectEl.setShape(dim, 0);
  63135. initProps(rectEl, {
  63136. shape: {
  63137. width: rect.width,
  63138. height: rect.height
  63139. }
  63140. }, seriesModel, cb);
  63141. return rectEl;
  63142. }
  63143. function createLinePoints(data, dataIndex, dimensions, coordSys) {
  63144. var points = [];
  63145. for (var i = 0; i < dimensions.length; i++) {
  63146. var dimName = dimensions[i];
  63147. var value = data.get(data.mapDimension(dimName), dataIndex);
  63148. if (!isEmptyValue(value, coordSys.getAxis(dimName).type)) {
  63149. points.push(coordSys.dataToPoint(value, dimName));
  63150. }
  63151. }
  63152. return points;
  63153. }
  63154. function addEl(data, dataGroup, dataIndex, dimensions, coordSys) {
  63155. var points = createLinePoints(data, dataIndex, dimensions, coordSys);
  63156. var line = new Polyline({
  63157. shape: {
  63158. points: points
  63159. },
  63160. // silent: true,
  63161. z2: 10
  63162. });
  63163. dataGroup.add(line);
  63164. data.setItemGraphicEl(dataIndex, line);
  63165. return line;
  63166. }
  63167. function makeSeriesScope$2(seriesModel) {
  63168. var smooth = seriesModel.get('smooth', true);
  63169. smooth === true && (smooth = DEFAULT_SMOOTH);
  63170. smooth = numericToNumber(smooth);
  63171. eqNaN(smooth) && (smooth = 0);
  63172. return {
  63173. smooth: smooth
  63174. };
  63175. }
  63176. function updateElCommon(el, data, dataIndex, seriesScope) {
  63177. el.useStyle(data.getItemVisual(dataIndex, 'style'));
  63178. el.style.fill = null;
  63179. el.setShape('smooth', seriesScope.smooth);
  63180. var itemModel = data.getItemModel(dataIndex);
  63181. var emphasisModel = itemModel.getModel('emphasis');
  63182. setStatesStylesFromModel(el, itemModel, 'lineStyle');
  63183. enableHoverEmphasis(el, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  63184. } // function simpleDiff(oldData, newData, dimensions) {
  63185. // let oldLen;
  63186. // if (!oldData
  63187. // || !oldData.__plProgressive
  63188. // || (oldLen = oldData.count()) !== newData.count()
  63189. // ) {
  63190. // return true;
  63191. // }
  63192. // let dimLen = dimensions.length;
  63193. // for (let i = 0; i < oldLen; i++) {
  63194. // for (let j = 0; j < dimLen; j++) {
  63195. // if (oldData.get(dimensions[j], i) !== newData.get(dimensions[j], i)) {
  63196. // return true;
  63197. // }
  63198. // }
  63199. // }
  63200. // return false;
  63201. // }
  63202. // FIXME put in common util?
  63203. function isEmptyValue(val, axisType) {
  63204. return axisType === 'category' ? val == null : val == null || isNaN(val); // axisType === 'value'
  63205. }
  63206. /*
  63207. * Licensed to the Apache Software Foundation (ASF) under one
  63208. * or more contributor license agreements. See the NOTICE file
  63209. * distributed with this work for additional information
  63210. * regarding copyright ownership. The ASF licenses this file
  63211. * to you under the Apache License, Version 2.0 (the
  63212. * "License"); you may not use this file except in compliance
  63213. * with the License. You may obtain a copy of the License at
  63214. *
  63215. * http://www.apache.org/licenses/LICENSE-2.0
  63216. *
  63217. * Unless required by applicable law or agreed to in writing,
  63218. * software distributed under the License is distributed on an
  63219. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63220. * KIND, either express or implied. See the License for the
  63221. * specific language governing permissions and limitations
  63222. * under the License.
  63223. */
  63224. /**
  63225. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63226. */
  63227. /*
  63228. * Licensed to the Apache Software Foundation (ASF) under one
  63229. * or more contributor license agreements. See the NOTICE file
  63230. * distributed with this work for additional information
  63231. * regarding copyright ownership. The ASF licenses this file
  63232. * to you under the Apache License, Version 2.0 (the
  63233. * "License"); you may not use this file except in compliance
  63234. * with the License. You may obtain a copy of the License at
  63235. *
  63236. * http://www.apache.org/licenses/LICENSE-2.0
  63237. *
  63238. * Unless required by applicable law or agreed to in writing,
  63239. * software distributed under the License is distributed on an
  63240. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63241. * KIND, either express or implied. See the License for the
  63242. * specific language governing permissions and limitations
  63243. * under the License.
  63244. */
  63245. var ParallelSeriesModel =
  63246. /** @class */
  63247. function (_super) {
  63248. __extends(ParallelSeriesModel, _super);
  63249. function ParallelSeriesModel() {
  63250. var _this = _super !== null && _super.apply(this, arguments) || this;
  63251. _this.type = ParallelSeriesModel.type;
  63252. _this.visualStyleAccessPath = 'lineStyle';
  63253. _this.visualDrawType = 'stroke';
  63254. return _this;
  63255. }
  63256. ParallelSeriesModel.prototype.getInitialData = function (option, ecModel) {
  63257. return createListFromArray(this.getSource(), this, {
  63258. useEncodeDefaulter: bind(makeDefaultEncode, null, this)
  63259. });
  63260. };
  63261. /**
  63262. * User can get data raw indices on 'axisAreaSelected' event received.
  63263. *
  63264. * @return Raw indices
  63265. */
  63266. ParallelSeriesModel.prototype.getRawIndicesByActiveState = function (activeState) {
  63267. var coordSys = this.coordinateSystem;
  63268. var data = this.getData();
  63269. var indices = [];
  63270. coordSys.eachActiveState(data, function (theActiveState, dataIndex) {
  63271. if (activeState === theActiveState) {
  63272. indices.push(data.getRawIndex(dataIndex));
  63273. }
  63274. });
  63275. return indices;
  63276. };
  63277. ParallelSeriesModel.type = 'series.parallel';
  63278. ParallelSeriesModel.dependencies = ['parallel'];
  63279. ParallelSeriesModel.defaultOption = {
  63280. zlevel: 0,
  63281. z: 2,
  63282. coordinateSystem: 'parallel',
  63283. parallelIndex: 0,
  63284. label: {
  63285. show: false
  63286. },
  63287. inactiveOpacity: 0.05,
  63288. activeOpacity: 1,
  63289. lineStyle: {
  63290. width: 1,
  63291. opacity: 0.45,
  63292. type: 'solid'
  63293. },
  63294. emphasis: {
  63295. label: {
  63296. show: false
  63297. }
  63298. },
  63299. progressive: 500,
  63300. smooth: false,
  63301. animationEasing: 'linear'
  63302. };
  63303. return ParallelSeriesModel;
  63304. }(SeriesModel);
  63305. function makeDefaultEncode(seriesModel) {
  63306. // The mapping of parallelAxis dimension to data dimension can
  63307. // be specified in parallelAxis.option.dim. For example, if
  63308. // parallelAxis.option.dim is 'dim3', it mapping to the third
  63309. // dimension of data. But `data.encode` has higher priority.
  63310. // Moreover, parallelModel.dimension should not be regarded as data
  63311. // dimensions. Consider dimensions = ['dim4', 'dim2', 'dim6'];
  63312. var parallelModel = seriesModel.ecModel.getComponent('parallel', seriesModel.get('parallelIndex'));
  63313. if (!parallelModel) {
  63314. return;
  63315. }
  63316. var encodeDefine = {};
  63317. each$1(parallelModel.dimensions, function (axisDim) {
  63318. var dataDimIndex = convertDimNameToNumber(axisDim);
  63319. encodeDefine[axisDim] = dataDimIndex;
  63320. });
  63321. return encodeDefine;
  63322. }
  63323. function convertDimNameToNumber(dimName) {
  63324. return +dimName.replace('dim', '');
  63325. }
  63326. /*
  63327. * Licensed to the Apache Software Foundation (ASF) under one
  63328. * or more contributor license agreements. See the NOTICE file
  63329. * distributed with this work for additional information
  63330. * regarding copyright ownership. The ASF licenses this file
  63331. * to you under the Apache License, Version 2.0 (the
  63332. * "License"); you may not use this file except in compliance
  63333. * with the License. You may obtain a copy of the License at
  63334. *
  63335. * http://www.apache.org/licenses/LICENSE-2.0
  63336. *
  63337. * Unless required by applicable law or agreed to in writing,
  63338. * software distributed under the License is distributed on an
  63339. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63340. * KIND, either express or implied. See the License for the
  63341. * specific language governing permissions and limitations
  63342. * under the License.
  63343. */
  63344. /**
  63345. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63346. */
  63347. /*
  63348. * Licensed to the Apache Software Foundation (ASF) under one
  63349. * or more contributor license agreements. See the NOTICE file
  63350. * distributed with this work for additional information
  63351. * regarding copyright ownership. The ASF licenses this file
  63352. * to you under the Apache License, Version 2.0 (the
  63353. * "License"); you may not use this file except in compliance
  63354. * with the License. You may obtain a copy of the License at
  63355. *
  63356. * http://www.apache.org/licenses/LICENSE-2.0
  63357. *
  63358. * Unless required by applicable law or agreed to in writing,
  63359. * software distributed under the License is distributed on an
  63360. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63361. * KIND, either express or implied. See the License for the
  63362. * specific language governing permissions and limitations
  63363. * under the License.
  63364. */
  63365. var opacityAccessPath = ['lineStyle', 'opacity'];
  63366. var parallelVisual = {
  63367. seriesType: 'parallel',
  63368. reset: function (seriesModel, ecModel) {
  63369. var coordSys = seriesModel.coordinateSystem;
  63370. var opacityMap = {
  63371. normal: seriesModel.get(['lineStyle', 'opacity']),
  63372. active: seriesModel.get('activeOpacity'),
  63373. inactive: seriesModel.get('inactiveOpacity')
  63374. };
  63375. return {
  63376. progress: function (params, data) {
  63377. coordSys.eachActiveState(data, function (activeState, dataIndex) {
  63378. var opacity = opacityMap[activeState];
  63379. if (activeState === 'normal' && data.hasItemOption) {
  63380. var itemOpacity = data.getItemModel(dataIndex).get(opacityAccessPath, true);
  63381. itemOpacity != null && (opacity = itemOpacity);
  63382. }
  63383. var existsStyle = data.ensureUniqueItemVisual(dataIndex, 'style');
  63384. existsStyle.opacity = opacity;
  63385. }, params.start, params.end);
  63386. }
  63387. };
  63388. }
  63389. };
  63390. /*
  63391. * Licensed to the Apache Software Foundation (ASF) under one
  63392. * or more contributor license agreements. See the NOTICE file
  63393. * distributed with this work for additional information
  63394. * regarding copyright ownership. The ASF licenses this file
  63395. * to you under the Apache License, Version 2.0 (the
  63396. * "License"); you may not use this file except in compliance
  63397. * with the License. You may obtain a copy of the License at
  63398. *
  63399. * http://www.apache.org/licenses/LICENSE-2.0
  63400. *
  63401. * Unless required by applicable law or agreed to in writing,
  63402. * software distributed under the License is distributed on an
  63403. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63404. * KIND, either express or implied. See the License for the
  63405. * specific language governing permissions and limitations
  63406. * under the License.
  63407. */
  63408. /**
  63409. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63410. */
  63411. /*
  63412. * Licensed to the Apache Software Foundation (ASF) under one
  63413. * or more contributor license agreements. See the NOTICE file
  63414. * distributed with this work for additional information
  63415. * regarding copyright ownership. The ASF licenses this file
  63416. * to you under the Apache License, Version 2.0 (the
  63417. * "License"); you may not use this file except in compliance
  63418. * with the License. You may obtain a copy of the License at
  63419. *
  63420. * http://www.apache.org/licenses/LICENSE-2.0
  63421. *
  63422. * Unless required by applicable law or agreed to in writing,
  63423. * software distributed under the License is distributed on an
  63424. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63425. * KIND, either express or implied. See the License for the
  63426. * specific language governing permissions and limitations
  63427. * under the License.
  63428. */
  63429. function parallelPreprocessor(option) {
  63430. createParallelIfNeeded(option);
  63431. mergeAxisOptionFromParallel(option);
  63432. }
  63433. /**
  63434. * Create a parallel coordinate if not exists.
  63435. * @inner
  63436. */
  63437. function createParallelIfNeeded(option) {
  63438. if (option.parallel) {
  63439. return;
  63440. }
  63441. var hasParallelSeries = false;
  63442. each$1(option.series, function (seriesOpt) {
  63443. if (seriesOpt && seriesOpt.type === 'parallel') {
  63444. hasParallelSeries = true;
  63445. }
  63446. });
  63447. if (hasParallelSeries) {
  63448. option.parallel = [{}];
  63449. }
  63450. }
  63451. /**
  63452. * Merge aixs definition from parallel option (if exists) to axis option.
  63453. * @inner
  63454. */
  63455. function mergeAxisOptionFromParallel(option) {
  63456. var axes = normalizeToArray(option.parallelAxis);
  63457. each$1(axes, function (axisOption) {
  63458. if (!isObject$1(axisOption)) {
  63459. return;
  63460. }
  63461. var parallelIndex = axisOption.parallelIndex || 0;
  63462. var parallelOption = normalizeToArray(option.parallel)[parallelIndex];
  63463. if (parallelOption && parallelOption.parallelAxisDefault) {
  63464. merge(axisOption, parallelOption.parallelAxisDefault, false);
  63465. }
  63466. });
  63467. }
  63468. /*
  63469. * Licensed to the Apache Software Foundation (ASF) under one
  63470. * or more contributor license agreements. See the NOTICE file
  63471. * distributed with this work for additional information
  63472. * regarding copyright ownership. The ASF licenses this file
  63473. * to you under the Apache License, Version 2.0 (the
  63474. * "License"); you may not use this file except in compliance
  63475. * with the License. You may obtain a copy of the License at
  63476. *
  63477. * http://www.apache.org/licenses/LICENSE-2.0
  63478. *
  63479. * Unless required by applicable law or agreed to in writing,
  63480. * software distributed under the License is distributed on an
  63481. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63482. * KIND, either express or implied. See the License for the
  63483. * specific language governing permissions and limitations
  63484. * under the License.
  63485. */
  63486. /**
  63487. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63488. */
  63489. /*
  63490. * Licensed to the Apache Software Foundation (ASF) under one
  63491. * or more contributor license agreements. See the NOTICE file
  63492. * distributed with this work for additional information
  63493. * regarding copyright ownership. The ASF licenses this file
  63494. * to you under the Apache License, Version 2.0 (the
  63495. * "License"); you may not use this file except in compliance
  63496. * with the License. You may obtain a copy of the License at
  63497. *
  63498. * http://www.apache.org/licenses/LICENSE-2.0
  63499. *
  63500. * Unless required by applicable law or agreed to in writing,
  63501. * software distributed under the License is distributed on an
  63502. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63503. * KIND, either express or implied. See the License for the
  63504. * specific language governing permissions and limitations
  63505. * under the License.
  63506. */
  63507. var CLICK_THRESHOLD = 5; // > 4
  63508. var ParallelView$2 =
  63509. /** @class */
  63510. function (_super) {
  63511. __extends(ParallelView, _super);
  63512. function ParallelView() {
  63513. var _this = _super !== null && _super.apply(this, arguments) || this;
  63514. _this.type = ParallelView.type;
  63515. return _this;
  63516. }
  63517. ParallelView.prototype.render = function (parallelModel, ecModel, api) {
  63518. this._model = parallelModel;
  63519. this._api = api;
  63520. if (!this._handlers) {
  63521. this._handlers = {};
  63522. each$1(handlers, function (handler, eventName) {
  63523. api.getZr().on(eventName, this._handlers[eventName] = bind(handler, this));
  63524. }, this);
  63525. }
  63526. createOrUpdate(this, '_throttledDispatchExpand', parallelModel.get('axisExpandRate'), 'fixRate');
  63527. };
  63528. ParallelView.prototype.dispose = function (ecModel, api) {
  63529. each$1(this._handlers, function (handler, eventName) {
  63530. api.getZr().off(eventName, handler);
  63531. });
  63532. this._handlers = null;
  63533. };
  63534. /**
  63535. * @internal
  63536. * @param {Object} [opt] If null, cancle the last action triggering for debounce.
  63537. */
  63538. ParallelView.prototype._throttledDispatchExpand = function (opt) {
  63539. this._dispatchExpand(opt);
  63540. };
  63541. /**
  63542. * @internal
  63543. */
  63544. ParallelView.prototype._dispatchExpand = function (opt) {
  63545. opt && this._api.dispatchAction(extend({
  63546. type: 'parallelAxisExpand'
  63547. }, opt));
  63548. };
  63549. ParallelView.type = 'parallel';
  63550. return ParallelView;
  63551. }(ComponentView);
  63552. var handlers = {
  63553. mousedown: function (e) {
  63554. if (checkTrigger(this, 'click')) {
  63555. this._mouseDownPoint = [e.offsetX, e.offsetY];
  63556. }
  63557. },
  63558. mouseup: function (e) {
  63559. var mouseDownPoint = this._mouseDownPoint;
  63560. if (checkTrigger(this, 'click') && mouseDownPoint) {
  63561. var point = [e.offsetX, e.offsetY];
  63562. var dist = Math.pow(mouseDownPoint[0] - point[0], 2) + Math.pow(mouseDownPoint[1] - point[1], 2);
  63563. if (dist > CLICK_THRESHOLD) {
  63564. return;
  63565. }
  63566. var result = this._model.coordinateSystem.getSlidedAxisExpandWindow([e.offsetX, e.offsetY]);
  63567. result.behavior !== 'none' && this._dispatchExpand({
  63568. axisExpandWindow: result.axisExpandWindow
  63569. });
  63570. }
  63571. this._mouseDownPoint = null;
  63572. },
  63573. mousemove: function (e) {
  63574. // Should do nothing when brushing.
  63575. if (this._mouseDownPoint || !checkTrigger(this, 'mousemove')) {
  63576. return;
  63577. }
  63578. var model = this._model;
  63579. var result = model.coordinateSystem.getSlidedAxisExpandWindow([e.offsetX, e.offsetY]);
  63580. var behavior = result.behavior;
  63581. behavior === 'jump' && this._throttledDispatchExpand.debounceNextCall(model.get('axisExpandDebounce'));
  63582. this._throttledDispatchExpand(behavior === 'none' ? null // Cancle the last trigger, in case that mouse slide out of the area quickly.
  63583. : {
  63584. axisExpandWindow: result.axisExpandWindow,
  63585. // Jumping uses animation, and sliding suppresses animation.
  63586. animation: behavior === 'jump' ? null : {
  63587. duration: 0 // Disable animation.
  63588. }
  63589. });
  63590. }
  63591. };
  63592. function checkTrigger(view, triggerOn) {
  63593. var model = view._model;
  63594. return model.get('axisExpandable') && model.get('axisExpandTriggerOn') === triggerOn;
  63595. }
  63596. /*
  63597. * Licensed to the Apache Software Foundation (ASF) under one
  63598. * or more contributor license agreements. See the NOTICE file
  63599. * distributed with this work for additional information
  63600. * regarding copyright ownership. The ASF licenses this file
  63601. * to you under the Apache License, Version 2.0 (the
  63602. * "License"); you may not use this file except in compliance
  63603. * with the License. You may obtain a copy of the License at
  63604. *
  63605. * http://www.apache.org/licenses/LICENSE-2.0
  63606. *
  63607. * Unless required by applicable law or agreed to in writing,
  63608. * software distributed under the License is distributed on an
  63609. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63610. * KIND, either express or implied. See the License for the
  63611. * specific language governing permissions and limitations
  63612. * under the License.
  63613. */
  63614. /**
  63615. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63616. */
  63617. /*
  63618. * Licensed to the Apache Software Foundation (ASF) under one
  63619. * or more contributor license agreements. See the NOTICE file
  63620. * distributed with this work for additional information
  63621. * regarding copyright ownership. The ASF licenses this file
  63622. * to you under the Apache License, Version 2.0 (the
  63623. * "License"); you may not use this file except in compliance
  63624. * with the License. You may obtain a copy of the License at
  63625. *
  63626. * http://www.apache.org/licenses/LICENSE-2.0
  63627. *
  63628. * Unless required by applicable law or agreed to in writing,
  63629. * software distributed under the License is distributed on an
  63630. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63631. * KIND, either express or implied. See the License for the
  63632. * specific language governing permissions and limitations
  63633. * under the License.
  63634. */
  63635. var ParallelModel =
  63636. /** @class */
  63637. function (_super) {
  63638. __extends(ParallelModel, _super);
  63639. function ParallelModel() {
  63640. var _this = _super !== null && _super.apply(this, arguments) || this;
  63641. _this.type = ParallelModel.type;
  63642. return _this;
  63643. }
  63644. ParallelModel.prototype.init = function () {
  63645. _super.prototype.init.apply(this, arguments);
  63646. this.mergeOption({});
  63647. };
  63648. ParallelModel.prototype.mergeOption = function (newOption) {
  63649. var thisOption = this.option;
  63650. newOption && merge(thisOption, newOption, true);
  63651. this._initDimensions();
  63652. };
  63653. /**
  63654. * Whether series or axis is in this coordinate system.
  63655. */
  63656. ParallelModel.prototype.contains = function (model, ecModel) {
  63657. var parallelIndex = model.get('parallelIndex');
  63658. return parallelIndex != null && ecModel.getComponent('parallel', parallelIndex) === this;
  63659. };
  63660. ParallelModel.prototype.setAxisExpand = function (opt) {
  63661. each$1(['axisExpandable', 'axisExpandCenter', 'axisExpandCount', 'axisExpandWidth', 'axisExpandWindow'], function (name) {
  63662. if (opt.hasOwnProperty(name)) {
  63663. // @ts-ignore FIXME: why "never" inferred in this.option[name]?
  63664. this.option[name] = opt[name];
  63665. }
  63666. }, this);
  63667. };
  63668. ParallelModel.prototype._initDimensions = function () {
  63669. var dimensions = this.dimensions = [];
  63670. var parallelAxisIndex = this.parallelAxisIndex = [];
  63671. var axisModels = filter(this.ecModel.queryComponents({
  63672. mainType: 'parallelAxis'
  63673. }), function (axisModel) {
  63674. // Can not use this.contains here, because
  63675. // initialization has not been completed yet.
  63676. return (axisModel.get('parallelIndex') || 0) === this.componentIndex;
  63677. }, this);
  63678. each$1(axisModels, function (axisModel) {
  63679. dimensions.push('dim' + axisModel.get('dim'));
  63680. parallelAxisIndex.push(axisModel.componentIndex);
  63681. });
  63682. };
  63683. ParallelModel.type = 'parallel';
  63684. ParallelModel.dependencies = ['parallelAxis'];
  63685. ParallelModel.layoutMode = 'box';
  63686. ParallelModel.defaultOption = {
  63687. zlevel: 0,
  63688. z: 0,
  63689. left: 80,
  63690. top: 60,
  63691. right: 80,
  63692. bottom: 60,
  63693. // width: {totalWidth} - left - right,
  63694. // height: {totalHeight} - top - bottom,
  63695. layout: 'horizontal',
  63696. // FIXME
  63697. // naming?
  63698. axisExpandable: false,
  63699. axisExpandCenter: null,
  63700. axisExpandCount: 0,
  63701. axisExpandWidth: 50,
  63702. axisExpandRate: 17,
  63703. axisExpandDebounce: 50,
  63704. // [out, in, jumpTarget]. In percentage. If use [null, 0.05], null means full.
  63705. // Do not doc to user until necessary.
  63706. axisExpandSlideTriggerArea: [-0.15, 0.05, 0.4],
  63707. axisExpandTriggerOn: 'click',
  63708. parallelAxisDefault: null
  63709. };
  63710. return ParallelModel;
  63711. }(ComponentModel);
  63712. /*
  63713. * Licensed to the Apache Software Foundation (ASF) under one
  63714. * or more contributor license agreements. See the NOTICE file
  63715. * distributed with this work for additional information
  63716. * regarding copyright ownership. The ASF licenses this file
  63717. * to you under the Apache License, Version 2.0 (the
  63718. * "License"); you may not use this file except in compliance
  63719. * with the License. You may obtain a copy of the License at
  63720. *
  63721. * http://www.apache.org/licenses/LICENSE-2.0
  63722. *
  63723. * Unless required by applicable law or agreed to in writing,
  63724. * software distributed under the License is distributed on an
  63725. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63726. * KIND, either express or implied. See the License for the
  63727. * specific language governing permissions and limitations
  63728. * under the License.
  63729. */
  63730. /**
  63731. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63732. */
  63733. /*
  63734. * Licensed to the Apache Software Foundation (ASF) under one
  63735. * or more contributor license agreements. See the NOTICE file
  63736. * distributed with this work for additional information
  63737. * regarding copyright ownership. The ASF licenses this file
  63738. * to you under the Apache License, Version 2.0 (the
  63739. * "License"); you may not use this file except in compliance
  63740. * with the License. You may obtain a copy of the License at
  63741. *
  63742. * http://www.apache.org/licenses/LICENSE-2.0
  63743. *
  63744. * Unless required by applicable law or agreed to in writing,
  63745. * software distributed under the License is distributed on an
  63746. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63747. * KIND, either express or implied. See the License for the
  63748. * specific language governing permissions and limitations
  63749. * under the License.
  63750. */
  63751. var ParallelAxis =
  63752. /** @class */
  63753. function (_super) {
  63754. __extends(ParallelAxis, _super);
  63755. function ParallelAxis(dim, scale, coordExtent, axisType, axisIndex) {
  63756. var _this = _super.call(this, dim, scale, coordExtent) || this;
  63757. _this.type = axisType || 'value';
  63758. _this.axisIndex = axisIndex;
  63759. return _this;
  63760. }
  63761. ParallelAxis.prototype.isHorizontal = function () {
  63762. return this.coordinateSystem.getModel().get('layout') !== 'horizontal';
  63763. };
  63764. return ParallelAxis;
  63765. }(Axis);
  63766. /*
  63767. * Licensed to the Apache Software Foundation (ASF) under one
  63768. * or more contributor license agreements. See the NOTICE file
  63769. * distributed with this work for additional information
  63770. * regarding copyright ownership. The ASF licenses this file
  63771. * to you under the Apache License, Version 2.0 (the
  63772. * "License"); you may not use this file except in compliance
  63773. * with the License. You may obtain a copy of the License at
  63774. *
  63775. * http://www.apache.org/licenses/LICENSE-2.0
  63776. *
  63777. * Unless required by applicable law or agreed to in writing,
  63778. * software distributed under the License is distributed on an
  63779. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63780. * KIND, either express or implied. See the License for the
  63781. * specific language governing permissions and limitations
  63782. * under the License.
  63783. */
  63784. /**
  63785. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63786. */
  63787. /*
  63788. * Licensed to the Apache Software Foundation (ASF) under one
  63789. * or more contributor license agreements. See the NOTICE file
  63790. * distributed with this work for additional information
  63791. * regarding copyright ownership. The ASF licenses this file
  63792. * to you under the Apache License, Version 2.0 (the
  63793. * "License"); you may not use this file except in compliance
  63794. * with the License. You may obtain a copy of the License at
  63795. *
  63796. * http://www.apache.org/licenses/LICENSE-2.0
  63797. *
  63798. * Unless required by applicable law or agreed to in writing,
  63799. * software distributed under the License is distributed on an
  63800. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63801. * KIND, either express or implied. See the License for the
  63802. * specific language governing permissions and limitations
  63803. * under the License.
  63804. */
  63805. /**
  63806. * Calculate slider move result.
  63807. * Usage:
  63808. * (1) If both handle0 and handle1 are needed to be moved, set minSpan the same as
  63809. * maxSpan and the same as `Math.abs(handleEnd[1] - handleEnds[0])`.
  63810. * (2) If handle0 is forbidden to cross handle1, set minSpan as `0`.
  63811. *
  63812. * @param delta Move length.
  63813. * @param handleEnds handleEnds[0] can be bigger then handleEnds[1].
  63814. * handleEnds will be modified in this method.
  63815. * @param extent handleEnds is restricted by extent.
  63816. * extent[0] should less or equals than extent[1].
  63817. * @param handleIndex Can be 'all', means that both move the two handleEnds.
  63818. * @param minSpan The range of dataZoom can not be smaller than that.
  63819. * If not set, handle0 and cross handle1. If set as a non-negative
  63820. * number (including `0`), handles will push each other when reaching
  63821. * the minSpan.
  63822. * @param maxSpan The range of dataZoom can not be larger than that.
  63823. * @return The input handleEnds.
  63824. */
  63825. function sliderMove(delta, handleEnds, extent, handleIndex, minSpan, maxSpan) {
  63826. delta = delta || 0;
  63827. var extentSpan = extent[1] - extent[0]; // Notice maxSpan and minSpan can be null/undefined.
  63828. if (minSpan != null) {
  63829. minSpan = restrict$1(minSpan, [0, extentSpan]);
  63830. }
  63831. if (maxSpan != null) {
  63832. maxSpan = Math.max(maxSpan, minSpan != null ? minSpan : 0);
  63833. }
  63834. if (handleIndex === 'all') {
  63835. var handleSpan = Math.abs(handleEnds[1] - handleEnds[0]);
  63836. handleSpan = restrict$1(handleSpan, [0, extentSpan]);
  63837. minSpan = maxSpan = restrict$1(handleSpan, [minSpan, maxSpan]);
  63838. handleIndex = 0;
  63839. }
  63840. handleEnds[0] = restrict$1(handleEnds[0], extent);
  63841. handleEnds[1] = restrict$1(handleEnds[1], extent);
  63842. var originalDistSign = getSpanSign(handleEnds, handleIndex);
  63843. handleEnds[handleIndex] += delta; // Restrict in extent.
  63844. var extentMinSpan = minSpan || 0;
  63845. var realExtent = extent.slice();
  63846. originalDistSign.sign < 0 ? realExtent[0] += extentMinSpan : realExtent[1] -= extentMinSpan;
  63847. handleEnds[handleIndex] = restrict$1(handleEnds[handleIndex], realExtent); // Expand span.
  63848. var currDistSign;
  63849. currDistSign = getSpanSign(handleEnds, handleIndex);
  63850. if (minSpan != null && (currDistSign.sign !== originalDistSign.sign || currDistSign.span < minSpan)) {
  63851. // If minSpan exists, 'cross' is forbidden.
  63852. handleEnds[1 - handleIndex] = handleEnds[handleIndex] + originalDistSign.sign * minSpan;
  63853. } // Shrink span.
  63854. currDistSign = getSpanSign(handleEnds, handleIndex);
  63855. if (maxSpan != null && currDistSign.span > maxSpan) {
  63856. handleEnds[1 - handleIndex] = handleEnds[handleIndex] + currDistSign.sign * maxSpan;
  63857. }
  63858. return handleEnds;
  63859. }
  63860. function getSpanSign(handleEnds, handleIndex) {
  63861. var dist = handleEnds[handleIndex] - handleEnds[1 - handleIndex]; // If `handleEnds[0] === handleEnds[1]`, always believe that handleEnd[0]
  63862. // is at left of handleEnds[1] for non-cross case.
  63863. return {
  63864. span: Math.abs(dist),
  63865. sign: dist > 0 ? -1 : dist < 0 ? 1 : handleIndex ? -1 : 1
  63866. };
  63867. }
  63868. function restrict$1(value, extend) {
  63869. return Math.min(extend[1] != null ? extend[1] : Infinity, Math.max(extend[0] != null ? extend[0] : -Infinity, value));
  63870. }
  63871. /*
  63872. * Licensed to the Apache Software Foundation (ASF) under one
  63873. * or more contributor license agreements. See the NOTICE file
  63874. * distributed with this work for additional information
  63875. * regarding copyright ownership. The ASF licenses this file
  63876. * to you under the Apache License, Version 2.0 (the
  63877. * "License"); you may not use this file except in compliance
  63878. * with the License. You may obtain a copy of the License at
  63879. *
  63880. * http://www.apache.org/licenses/LICENSE-2.0
  63881. *
  63882. * Unless required by applicable law or agreed to in writing,
  63883. * software distributed under the License is distributed on an
  63884. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63885. * KIND, either express or implied. See the License for the
  63886. * specific language governing permissions and limitations
  63887. * under the License.
  63888. */
  63889. /**
  63890. * AUTO-GENERATED FILE. DO NOT MODIFY.
  63891. */
  63892. /*
  63893. * Licensed to the Apache Software Foundation (ASF) under one
  63894. * or more contributor license agreements. See the NOTICE file
  63895. * distributed with this work for additional information
  63896. * regarding copyright ownership. The ASF licenses this file
  63897. * to you under the Apache License, Version 2.0 (the
  63898. * "License"); you may not use this file except in compliance
  63899. * with the License. You may obtain a copy of the License at
  63900. *
  63901. * http://www.apache.org/licenses/LICENSE-2.0
  63902. *
  63903. * Unless required by applicable law or agreed to in writing,
  63904. * software distributed under the License is distributed on an
  63905. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  63906. * KIND, either express or implied. See the License for the
  63907. * specific language governing permissions and limitations
  63908. * under the License.
  63909. */
  63910. /**
  63911. * Parallel Coordinates
  63912. * <https://en.wikipedia.org/wiki/Parallel_coordinates>
  63913. */
  63914. var each$7 = each$1;
  63915. var mathMin$8 = Math.min;
  63916. var mathMax$8 = Math.max;
  63917. var mathFloor$2 = Math.floor;
  63918. var mathCeil$1 = Math.ceil;
  63919. var round$2 = round;
  63920. var PI$6 = Math.PI;
  63921. var Parallel =
  63922. /** @class */
  63923. function () {
  63924. function Parallel(parallelModel, ecModel, api) {
  63925. this.type = 'parallel';
  63926. /**
  63927. * key: dimension
  63928. */
  63929. this._axesMap = createHashMap();
  63930. /**
  63931. * key: dimension
  63932. * value: {position: [], rotation, }
  63933. */
  63934. this._axesLayout = {};
  63935. this.dimensions = parallelModel.dimensions;
  63936. this._model = parallelModel;
  63937. this._init(parallelModel, ecModel, api);
  63938. }
  63939. Parallel.prototype._init = function (parallelModel, ecModel, api) {
  63940. var dimensions = parallelModel.dimensions;
  63941. var parallelAxisIndex = parallelModel.parallelAxisIndex;
  63942. each$7(dimensions, function (dim, idx) {
  63943. var axisIndex = parallelAxisIndex[idx];
  63944. var axisModel = ecModel.getComponent('parallelAxis', axisIndex);
  63945. var axis = this._axesMap.set(dim, new ParallelAxis(dim, createScaleByModel(axisModel), [0, 0], axisModel.get('type'), axisIndex));
  63946. var isCategory = axis.type === 'category';
  63947. axis.onBand = isCategory && axisModel.get('boundaryGap');
  63948. axis.inverse = axisModel.get('inverse'); // Injection
  63949. axisModel.axis = axis;
  63950. axis.model = axisModel;
  63951. axis.coordinateSystem = axisModel.coordinateSystem = this;
  63952. }, this);
  63953. };
  63954. /**
  63955. * Update axis scale after data processed
  63956. */
  63957. Parallel.prototype.update = function (ecModel, api) {
  63958. this._updateAxesFromSeries(this._model, ecModel);
  63959. };
  63960. Parallel.prototype.containPoint = function (point) {
  63961. var layoutInfo = this._makeLayoutInfo();
  63962. var axisBase = layoutInfo.axisBase;
  63963. var layoutBase = layoutInfo.layoutBase;
  63964. var pixelDimIndex = layoutInfo.pixelDimIndex;
  63965. var pAxis = point[1 - pixelDimIndex];
  63966. var pLayout = point[pixelDimIndex];
  63967. return pAxis >= axisBase && pAxis <= axisBase + layoutInfo.axisLength && pLayout >= layoutBase && pLayout <= layoutBase + layoutInfo.layoutLength;
  63968. };
  63969. Parallel.prototype.getModel = function () {
  63970. return this._model;
  63971. };
  63972. /**
  63973. * Update properties from series
  63974. */
  63975. Parallel.prototype._updateAxesFromSeries = function (parallelModel, ecModel) {
  63976. ecModel.eachSeries(function (seriesModel) {
  63977. if (!parallelModel.contains(seriesModel, ecModel)) {
  63978. return;
  63979. }
  63980. var data = seriesModel.getData();
  63981. each$7(this.dimensions, function (dim) {
  63982. var axis = this._axesMap.get(dim);
  63983. axis.scale.unionExtentFromData(data, data.mapDimension(dim));
  63984. niceScaleExtent(axis.scale, axis.model);
  63985. }, this);
  63986. }, this);
  63987. };
  63988. /**
  63989. * Resize the parallel coordinate system.
  63990. */
  63991. Parallel.prototype.resize = function (parallelModel, api) {
  63992. this._rect = getLayoutRect(parallelModel.getBoxLayoutParams(), {
  63993. width: api.getWidth(),
  63994. height: api.getHeight()
  63995. });
  63996. this._layoutAxes();
  63997. };
  63998. Parallel.prototype.getRect = function () {
  63999. return this._rect;
  64000. };
  64001. Parallel.prototype._makeLayoutInfo = function () {
  64002. var parallelModel = this._model;
  64003. var rect = this._rect;
  64004. var xy = ['x', 'y'];
  64005. var wh = ['width', 'height'];
  64006. var layout = parallelModel.get('layout');
  64007. var pixelDimIndex = layout === 'horizontal' ? 0 : 1;
  64008. var layoutLength = rect[wh[pixelDimIndex]];
  64009. var layoutExtent = [0, layoutLength];
  64010. var axisCount = this.dimensions.length;
  64011. var axisExpandWidth = restrict(parallelModel.get('axisExpandWidth'), layoutExtent);
  64012. var axisExpandCount = restrict(parallelModel.get('axisExpandCount') || 0, [0, axisCount]);
  64013. var axisExpandable = parallelModel.get('axisExpandable') && axisCount > 3 && axisCount > axisExpandCount && axisExpandCount > 1 && axisExpandWidth > 0 && layoutLength > 0; // `axisExpandWindow` is According to the coordinates of [0, axisExpandLength],
  64014. // for sake of consider the case that axisCollapseWidth is 0 (when screen is narrow),
  64015. // where collapsed axes should be overlapped.
  64016. var axisExpandWindow = parallelModel.get('axisExpandWindow');
  64017. var winSize;
  64018. if (!axisExpandWindow) {
  64019. winSize = restrict(axisExpandWidth * (axisExpandCount - 1), layoutExtent);
  64020. var axisExpandCenter = parallelModel.get('axisExpandCenter') || mathFloor$2(axisCount / 2);
  64021. axisExpandWindow = [axisExpandWidth * axisExpandCenter - winSize / 2];
  64022. axisExpandWindow[1] = axisExpandWindow[0] + winSize;
  64023. } else {
  64024. winSize = restrict(axisExpandWindow[1] - axisExpandWindow[0], layoutExtent);
  64025. axisExpandWindow[1] = axisExpandWindow[0] + winSize;
  64026. }
  64027. var axisCollapseWidth = (layoutLength - winSize) / (axisCount - axisExpandCount); // Avoid axisCollapseWidth is too small.
  64028. axisCollapseWidth < 3 && (axisCollapseWidth = 0); // Find the first and last indices > ewin[0] and < ewin[1].
  64029. var winInnerIndices = [mathFloor$2(round$2(axisExpandWindow[0] / axisExpandWidth, 1)) + 1, mathCeil$1(round$2(axisExpandWindow[1] / axisExpandWidth, 1)) - 1]; // Pos in ec coordinates.
  64030. var axisExpandWindow0Pos = axisCollapseWidth / axisExpandWidth * axisExpandWindow[0];
  64031. return {
  64032. layout: layout,
  64033. pixelDimIndex: pixelDimIndex,
  64034. layoutBase: rect[xy[pixelDimIndex]],
  64035. layoutLength: layoutLength,
  64036. axisBase: rect[xy[1 - pixelDimIndex]],
  64037. axisLength: rect[wh[1 - pixelDimIndex]],
  64038. axisExpandable: axisExpandable,
  64039. axisExpandWidth: axisExpandWidth,
  64040. axisCollapseWidth: axisCollapseWidth,
  64041. axisExpandWindow: axisExpandWindow,
  64042. axisCount: axisCount,
  64043. winInnerIndices: winInnerIndices,
  64044. axisExpandWindow0Pos: axisExpandWindow0Pos
  64045. };
  64046. };
  64047. Parallel.prototype._layoutAxes = function () {
  64048. var rect = this._rect;
  64049. var axes = this._axesMap;
  64050. var dimensions = this.dimensions;
  64051. var layoutInfo = this._makeLayoutInfo();
  64052. var layout = layoutInfo.layout;
  64053. axes.each(function (axis) {
  64054. var axisExtent = [0, layoutInfo.axisLength];
  64055. var idx = axis.inverse ? 1 : 0;
  64056. axis.setExtent(axisExtent[idx], axisExtent[1 - idx]);
  64057. });
  64058. each$7(dimensions, function (dim, idx) {
  64059. var posInfo = (layoutInfo.axisExpandable ? layoutAxisWithExpand : layoutAxisWithoutExpand)(idx, layoutInfo);
  64060. var positionTable = {
  64061. horizontal: {
  64062. x: posInfo.position,
  64063. y: layoutInfo.axisLength
  64064. },
  64065. vertical: {
  64066. x: 0,
  64067. y: posInfo.position
  64068. }
  64069. };
  64070. var rotationTable = {
  64071. horizontal: PI$6 / 2,
  64072. vertical: 0
  64073. };
  64074. var position = [positionTable[layout].x + rect.x, positionTable[layout].y + rect.y];
  64075. var rotation = rotationTable[layout];
  64076. var transform = create$1();
  64077. rotate(transform, transform, rotation);
  64078. translate(transform, transform, position); // TODO
  64079. // tick layout info
  64080. // TODO
  64081. // update dimensions info based on axis order.
  64082. this._axesLayout[dim] = {
  64083. position: position,
  64084. rotation: rotation,
  64085. transform: transform,
  64086. axisNameAvailableWidth: posInfo.axisNameAvailableWidth,
  64087. axisLabelShow: posInfo.axisLabelShow,
  64088. nameTruncateMaxWidth: posInfo.nameTruncateMaxWidth,
  64089. tickDirection: 1,
  64090. labelDirection: 1
  64091. };
  64092. }, this);
  64093. };
  64094. /**
  64095. * Get axis by dim.
  64096. */
  64097. Parallel.prototype.getAxis = function (dim) {
  64098. return this._axesMap.get(dim);
  64099. };
  64100. /**
  64101. * Convert a dim value of a single item of series data to Point.
  64102. */
  64103. Parallel.prototype.dataToPoint = function (value, dim) {
  64104. return this.axisCoordToPoint(this._axesMap.get(dim).dataToCoord(value), dim);
  64105. };
  64106. /**
  64107. * Travel data for one time, get activeState of each data item.
  64108. * @param start the start dataIndex that travel from.
  64109. * @param end the next dataIndex of the last dataIndex will be travel.
  64110. */
  64111. Parallel.prototype.eachActiveState = function (data, callback, start, end) {
  64112. start == null && (start = 0);
  64113. end == null && (end = data.count());
  64114. var axesMap = this._axesMap;
  64115. var dimensions = this.dimensions;
  64116. var dataDimensions = [];
  64117. var axisModels = [];
  64118. each$1(dimensions, function (axisDim) {
  64119. dataDimensions.push(data.mapDimension(axisDim));
  64120. axisModels.push(axesMap.get(axisDim).model);
  64121. });
  64122. var hasActiveSet = this.hasAxisBrushed();
  64123. for (var dataIndex = start; dataIndex < end; dataIndex++) {
  64124. var activeState = void 0;
  64125. if (!hasActiveSet) {
  64126. activeState = 'normal';
  64127. } else {
  64128. activeState = 'active';
  64129. var values = data.getValues(dataDimensions, dataIndex);
  64130. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  64131. var state = axisModels[j].getActiveState(values[j]);
  64132. if (state === 'inactive') {
  64133. activeState = 'inactive';
  64134. break;
  64135. }
  64136. }
  64137. }
  64138. callback(activeState, dataIndex);
  64139. }
  64140. };
  64141. /**
  64142. * Whether has any activeSet.
  64143. */
  64144. Parallel.prototype.hasAxisBrushed = function () {
  64145. var dimensions = this.dimensions;
  64146. var axesMap = this._axesMap;
  64147. var hasActiveSet = false;
  64148. for (var j = 0, lenj = dimensions.length; j < lenj; j++) {
  64149. if (axesMap.get(dimensions[j]).model.getActiveState() !== 'normal') {
  64150. hasActiveSet = true;
  64151. }
  64152. }
  64153. return hasActiveSet;
  64154. };
  64155. /**
  64156. * Convert coords of each axis to Point.
  64157. * Return point. For example: [10, 20]
  64158. */
  64159. Parallel.prototype.axisCoordToPoint = function (coord, dim) {
  64160. var axisLayout = this._axesLayout[dim];
  64161. return applyTransform$1([coord, 0], axisLayout.transform);
  64162. };
  64163. /**
  64164. * Get axis layout.
  64165. */
  64166. Parallel.prototype.getAxisLayout = function (dim) {
  64167. return clone(this._axesLayout[dim]);
  64168. };
  64169. /**
  64170. * @return {Object} {axisExpandWindow, delta, behavior: 'jump' | 'slide' | 'none'}.
  64171. */
  64172. Parallel.prototype.getSlidedAxisExpandWindow = function (point) {
  64173. var layoutInfo = this._makeLayoutInfo();
  64174. var pixelDimIndex = layoutInfo.pixelDimIndex;
  64175. var axisExpandWindow = layoutInfo.axisExpandWindow.slice();
  64176. var winSize = axisExpandWindow[1] - axisExpandWindow[0];
  64177. var extent = [0, layoutInfo.axisExpandWidth * (layoutInfo.axisCount - 1)]; // Out of the area of coordinate system.
  64178. if (!this.containPoint(point)) {
  64179. return {
  64180. behavior: 'none',
  64181. axisExpandWindow: axisExpandWindow
  64182. };
  64183. } // Conver the point from global to expand coordinates.
  64184. var pointCoord = point[pixelDimIndex] - layoutInfo.layoutBase - layoutInfo.axisExpandWindow0Pos; // For dragging operation convenience, the window should not be
  64185. // slided when mouse is the center area of the window.
  64186. var delta;
  64187. var behavior = 'slide';
  64188. var axisCollapseWidth = layoutInfo.axisCollapseWidth;
  64189. var triggerArea = this._model.get('axisExpandSlideTriggerArea'); // But consider touch device, jump is necessary.
  64190. var useJump = triggerArea[0] != null;
  64191. if (axisCollapseWidth) {
  64192. if (useJump && axisCollapseWidth && pointCoord < winSize * triggerArea[0]) {
  64193. behavior = 'jump';
  64194. delta = pointCoord - winSize * triggerArea[2];
  64195. } else if (useJump && axisCollapseWidth && pointCoord > winSize * (1 - triggerArea[0])) {
  64196. behavior = 'jump';
  64197. delta = pointCoord - winSize * (1 - triggerArea[2]);
  64198. } else {
  64199. (delta = pointCoord - winSize * triggerArea[1]) >= 0 && (delta = pointCoord - winSize * (1 - triggerArea[1])) <= 0 && (delta = 0);
  64200. }
  64201. delta *= layoutInfo.axisExpandWidth / axisCollapseWidth;
  64202. delta ? sliderMove(delta, axisExpandWindow, extent, 'all') // Avoid nonsense triger on mousemove.
  64203. : behavior = 'none';
  64204. } // When screen is too narrow, make it visible and slidable, although it is hard to interact.
  64205. else {
  64206. var winSize2 = axisExpandWindow[1] - axisExpandWindow[0];
  64207. var pos = extent[1] * pointCoord / winSize2;
  64208. axisExpandWindow = [mathMax$8(0, pos - winSize2 / 2)];
  64209. axisExpandWindow[1] = mathMin$8(extent[1], axisExpandWindow[0] + winSize2);
  64210. axisExpandWindow[0] = axisExpandWindow[1] - winSize2;
  64211. }
  64212. return {
  64213. axisExpandWindow: axisExpandWindow,
  64214. behavior: behavior
  64215. };
  64216. };
  64217. return Parallel;
  64218. }();
  64219. function restrict(len, extent) {
  64220. return mathMin$8(mathMax$8(len, extent[0]), extent[1]);
  64221. }
  64222. function layoutAxisWithoutExpand(axisIndex, layoutInfo) {
  64223. var step = layoutInfo.layoutLength / (layoutInfo.axisCount - 1);
  64224. return {
  64225. position: step * axisIndex,
  64226. axisNameAvailableWidth: step,
  64227. axisLabelShow: true
  64228. };
  64229. }
  64230. function layoutAxisWithExpand(axisIndex, layoutInfo) {
  64231. var layoutLength = layoutInfo.layoutLength;
  64232. var axisExpandWidth = layoutInfo.axisExpandWidth;
  64233. var axisCount = layoutInfo.axisCount;
  64234. var axisCollapseWidth = layoutInfo.axisCollapseWidth;
  64235. var winInnerIndices = layoutInfo.winInnerIndices;
  64236. var position;
  64237. var axisNameAvailableWidth = axisCollapseWidth;
  64238. var axisLabelShow = false;
  64239. var nameTruncateMaxWidth;
  64240. if (axisIndex < winInnerIndices[0]) {
  64241. position = axisIndex * axisCollapseWidth;
  64242. nameTruncateMaxWidth = axisCollapseWidth;
  64243. } else if (axisIndex <= winInnerIndices[1]) {
  64244. position = layoutInfo.axisExpandWindow0Pos + axisIndex * axisExpandWidth - layoutInfo.axisExpandWindow[0];
  64245. axisNameAvailableWidth = axisExpandWidth;
  64246. axisLabelShow = true;
  64247. } else {
  64248. position = layoutLength - (axisCount - 1 - axisIndex) * axisCollapseWidth;
  64249. nameTruncateMaxWidth = axisCollapseWidth;
  64250. }
  64251. return {
  64252. position: position,
  64253. axisNameAvailableWidth: axisNameAvailableWidth,
  64254. axisLabelShow: axisLabelShow,
  64255. nameTruncateMaxWidth: nameTruncateMaxWidth
  64256. };
  64257. }
  64258. /*
  64259. * Licensed to the Apache Software Foundation (ASF) under one
  64260. * or more contributor license agreements. See the NOTICE file
  64261. * distributed with this work for additional information
  64262. * regarding copyright ownership. The ASF licenses this file
  64263. * to you under the Apache License, Version 2.0 (the
  64264. * "License"); you may not use this file except in compliance
  64265. * with the License. You may obtain a copy of the License at
  64266. *
  64267. * http://www.apache.org/licenses/LICENSE-2.0
  64268. *
  64269. * Unless required by applicable law or agreed to in writing,
  64270. * software distributed under the License is distributed on an
  64271. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  64272. * KIND, either express or implied. See the License for the
  64273. * specific language governing permissions and limitations
  64274. * under the License.
  64275. */
  64276. /**
  64277. * AUTO-GENERATED FILE. DO NOT MODIFY.
  64278. */
  64279. /*
  64280. * Licensed to the Apache Software Foundation (ASF) under one
  64281. * or more contributor license agreements. See the NOTICE file
  64282. * distributed with this work for additional information
  64283. * regarding copyright ownership. The ASF licenses this file
  64284. * to you under the Apache License, Version 2.0 (the
  64285. * "License"); you may not use this file except in compliance
  64286. * with the License. You may obtain a copy of the License at
  64287. *
  64288. * http://www.apache.org/licenses/LICENSE-2.0
  64289. *
  64290. * Unless required by applicable law or agreed to in writing,
  64291. * software distributed under the License is distributed on an
  64292. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  64293. * KIND, either express or implied. See the License for the
  64294. * specific language governing permissions and limitations
  64295. * under the License.
  64296. */
  64297. /**
  64298. * Parallel coordinate system creater.
  64299. */
  64300. function createParallelCoordSys(ecModel, api) {
  64301. var coordSysList = [];
  64302. ecModel.eachComponent('parallel', function (parallelModel, idx) {
  64303. var coordSys = new Parallel(parallelModel, ecModel, api);
  64304. coordSys.name = 'parallel_' + idx;
  64305. coordSys.resize(parallelModel, api);
  64306. parallelModel.coordinateSystem = coordSys;
  64307. coordSys.model = parallelModel;
  64308. coordSysList.push(coordSys);
  64309. }); // Inject the coordinateSystems into seriesModel
  64310. ecModel.eachSeries(function (seriesModel) {
  64311. if (seriesModel.get('coordinateSystem') === 'parallel') {
  64312. var parallelModel = seriesModel.getReferringComponents('parallel', SINGLE_REFERRING).models[0];
  64313. seriesModel.coordinateSystem = parallelModel.coordinateSystem;
  64314. }
  64315. });
  64316. return coordSysList;
  64317. }
  64318. var parallelCoordSysCreator = {
  64319. create: createParallelCoordSys
  64320. };
  64321. /*
  64322. * Licensed to the Apache Software Foundation (ASF) under one
  64323. * or more contributor license agreements. See the NOTICE file
  64324. * distributed with this work for additional information
  64325. * regarding copyright ownership. The ASF licenses this file
  64326. * to you under the Apache License, Version 2.0 (the
  64327. * "License"); you may not use this file except in compliance
  64328. * with the License. You may obtain a copy of the License at
  64329. *
  64330. * http://www.apache.org/licenses/LICENSE-2.0
  64331. *
  64332. * Unless required by applicable law or agreed to in writing,
  64333. * software distributed under the License is distributed on an
  64334. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  64335. * KIND, either express or implied. See the License for the
  64336. * specific language governing permissions and limitations
  64337. * under the License.
  64338. */
  64339. /**
  64340. * AUTO-GENERATED FILE. DO NOT MODIFY.
  64341. */
  64342. /*
  64343. * Licensed to the Apache Software Foundation (ASF) under one
  64344. * or more contributor license agreements. See the NOTICE file
  64345. * distributed with this work for additional information
  64346. * regarding copyright ownership. The ASF licenses this file
  64347. * to you under the Apache License, Version 2.0 (the
  64348. * "License"); you may not use this file except in compliance
  64349. * with the License. You may obtain a copy of the License at
  64350. *
  64351. * http://www.apache.org/licenses/LICENSE-2.0
  64352. *
  64353. * Unless required by applicable law or agreed to in writing,
  64354. * software distributed under the License is distributed on an
  64355. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  64356. * KIND, either express or implied. See the License for the
  64357. * specific language governing permissions and limitations
  64358. * under the License.
  64359. */
  64360. var ParallelAxisModel =
  64361. /** @class */
  64362. function (_super) {
  64363. __extends(ParallelAxisModel, _super);
  64364. function ParallelAxisModel() {
  64365. var _this = _super !== null && _super.apply(this, arguments) || this;
  64366. _this.type = ParallelAxisModel.type;
  64367. /**
  64368. * @readOnly
  64369. */
  64370. _this.activeIntervals = [];
  64371. return _this;
  64372. }
  64373. ParallelAxisModel.prototype.getAreaSelectStyle = function () {
  64374. return makeStyleMapper([['fill', 'color'], ['lineWidth', 'borderWidth'], ['stroke', 'borderColor'], ['width', 'width'], ['opacity', 'opacity'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  64375. // So do not transfer decal directly.
  64376. ])(this.getModel('areaSelectStyle'));
  64377. };
  64378. /**
  64379. * The code of this feature is put on AxisModel but not ParallelAxis,
  64380. * because axisModel can be alive after echarts updating but instance of
  64381. * ParallelAxis having been disposed. this._activeInterval should be kept
  64382. * when action dispatched (i.e. legend click).
  64383. *
  64384. * @param intervals `interval.length === 0` means set all active.
  64385. */
  64386. ParallelAxisModel.prototype.setActiveIntervals = function (intervals) {
  64387. var activeIntervals = this.activeIntervals = clone(intervals); // Normalize
  64388. if (activeIntervals) {
  64389. for (var i = activeIntervals.length - 1; i >= 0; i--) {
  64390. asc(activeIntervals[i]);
  64391. }
  64392. }
  64393. };
  64394. /**
  64395. * @param value When only attempting detect whether 'no activeIntervals set',
  64396. * `value` is not needed to be input.
  64397. */
  64398. ParallelAxisModel.prototype.getActiveState = function (value) {
  64399. var activeIntervals = this.activeIntervals;
  64400. if (!activeIntervals.length) {
  64401. return 'normal';
  64402. }
  64403. if (value == null || isNaN(+value)) {
  64404. return 'inactive';
  64405. } // Simple optimization
  64406. if (activeIntervals.length === 1) {
  64407. var interval = activeIntervals[0];
  64408. if (interval[0] <= value && value <= interval[1]) {
  64409. return 'active';
  64410. }
  64411. } else {
  64412. for (var i = 0, len = activeIntervals.length; i < len; i++) {
  64413. if (activeIntervals[i][0] <= value && value <= activeIntervals[i][1]) {
  64414. return 'active';
  64415. }
  64416. }
  64417. }
  64418. return 'inactive';
  64419. };
  64420. return ParallelAxisModel;
  64421. }(ComponentModel);
  64422. mixin(ParallelAxisModel, AxisModelCommonMixin);
  64423. /*
  64424. * Licensed to the Apache Software Foundation (ASF) under one
  64425. * or more contributor license agreements. See the NOTICE file
  64426. * distributed with this work for additional information
  64427. * regarding copyright ownership. The ASF licenses this file
  64428. * to you under the Apache License, Version 2.0 (the
  64429. * "License"); you may not use this file except in compliance
  64430. * with the License. You may obtain a copy of the License at
  64431. *
  64432. * http://www.apache.org/licenses/LICENSE-2.0
  64433. *
  64434. * Unless required by applicable law or agreed to in writing,
  64435. * software distributed under the License is distributed on an
  64436. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  64437. * KIND, either express or implied. See the License for the
  64438. * specific language governing permissions and limitations
  64439. * under the License.
  64440. */
  64441. /**
  64442. * AUTO-GENERATED FILE. DO NOT MODIFY.
  64443. */
  64444. /*
  64445. * Licensed to the Apache Software Foundation (ASF) under one
  64446. * or more contributor license agreements. See the NOTICE file
  64447. * distributed with this work for additional information
  64448. * regarding copyright ownership. The ASF licenses this file
  64449. * to you under the Apache License, Version 2.0 (the
  64450. * "License"); you may not use this file except in compliance
  64451. * with the License. You may obtain a copy of the License at
  64452. *
  64453. * http://www.apache.org/licenses/LICENSE-2.0
  64454. *
  64455. * Unless required by applicable law or agreed to in writing,
  64456. * software distributed under the License is distributed on an
  64457. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  64458. * KIND, either express or implied. See the License for the
  64459. * specific language governing permissions and limitations
  64460. * under the License.
  64461. */
  64462. var BRUSH_PANEL_GLOBAL = true;
  64463. var mathMin$9 = Math.min;
  64464. var mathMax$9 = Math.max;
  64465. var mathPow$2 = Math.pow;
  64466. var COVER_Z = 10000;
  64467. var UNSELECT_THRESHOLD = 6;
  64468. var MIN_RESIZE_LINE_WIDTH = 6;
  64469. var MUTEX_RESOURCE_KEY = 'globalPan';
  64470. var DIRECTION_MAP = {
  64471. w: [0, 0],
  64472. e: [0, 1],
  64473. n: [1, 0],
  64474. s: [1, 1]
  64475. };
  64476. var CURSOR_MAP = {
  64477. w: 'ew',
  64478. e: 'ew',
  64479. n: 'ns',
  64480. s: 'ns',
  64481. ne: 'nesw',
  64482. sw: 'nesw',
  64483. nw: 'nwse',
  64484. se: 'nwse'
  64485. };
  64486. var DEFAULT_BRUSH_OPT = {
  64487. brushStyle: {
  64488. lineWidth: 2,
  64489. stroke: 'rgba(210,219,238,0.3)',
  64490. fill: '#D2DBEE'
  64491. },
  64492. transformable: true,
  64493. brushMode: 'single',
  64494. removeOnClick: false
  64495. };
  64496. var baseUID = 0;
  64497. /**
  64498. * params:
  64499. * areas: Array.<Array>, coord relates to container group,
  64500. * If no container specified, to global.
  64501. * opt {
  64502. * isEnd: boolean,
  64503. * removeOnClick: boolean
  64504. * }
  64505. */
  64506. var BrushController =
  64507. /** @class */
  64508. function (_super) {
  64509. __extends(BrushController, _super);
  64510. function BrushController(zr) {
  64511. var _this = _super.call(this) || this;
  64512. /**
  64513. * @internal
  64514. */
  64515. _this._track = [];
  64516. /**
  64517. * @internal
  64518. */
  64519. _this._covers = [];
  64520. _this._handlers = {};
  64521. {
  64522. assert$1(zr);
  64523. }
  64524. _this._zr = zr;
  64525. _this.group = new Group();
  64526. _this._uid = 'brushController_' + baseUID++;
  64527. each$1(pointerHandlers, function (handler, eventName) {
  64528. this._handlers[eventName] = bind(handler, this);
  64529. }, _this);
  64530. return _this;
  64531. }
  64532. /**
  64533. * If set to `false`, select disabled.
  64534. */
  64535. BrushController.prototype.enableBrush = function (brushOption) {
  64536. {
  64537. assert$1(this._mounted);
  64538. }
  64539. this._brushType && this._doDisableBrush();
  64540. brushOption.brushType && this._doEnableBrush(brushOption);
  64541. return this;
  64542. };
  64543. BrushController.prototype._doEnableBrush = function (brushOption) {
  64544. var zr = this._zr; // Consider roam, which takes globalPan too.
  64545. if (!this._enableGlobalPan) {
  64546. take(zr, MUTEX_RESOURCE_KEY, this._uid);
  64547. }
  64548. each$1(this._handlers, function (handler, eventName) {
  64549. zr.on(eventName, handler);
  64550. });
  64551. this._brushType = brushOption.brushType;
  64552. this._brushOption = merge(clone(DEFAULT_BRUSH_OPT), brushOption, true);
  64553. };
  64554. BrushController.prototype._doDisableBrush = function () {
  64555. var zr = this._zr;
  64556. release(zr, MUTEX_RESOURCE_KEY, this._uid);
  64557. each$1(this._handlers, function (handler, eventName) {
  64558. zr.off(eventName, handler);
  64559. });
  64560. this._brushType = this._brushOption = null;
  64561. };
  64562. /**
  64563. * @param panelOpts If not pass, it is global brush.
  64564. */
  64565. BrushController.prototype.setPanels = function (panelOpts) {
  64566. if (panelOpts && panelOpts.length) {
  64567. var panels_1 = this._panels = {};
  64568. each$1(panelOpts, function (panelOpts) {
  64569. panels_1[panelOpts.panelId] = clone(panelOpts);
  64570. });
  64571. } else {
  64572. this._panels = null;
  64573. }
  64574. return this;
  64575. };
  64576. BrushController.prototype.mount = function (opt) {
  64577. opt = opt || {};
  64578. {
  64579. this._mounted = true; // should be at first.
  64580. }
  64581. this._enableGlobalPan = opt.enableGlobalPan;
  64582. var thisGroup = this.group;
  64583. this._zr.add(thisGroup);
  64584. thisGroup.attr({
  64585. x: opt.x || 0,
  64586. y: opt.y || 0,
  64587. rotation: opt.rotation || 0,
  64588. scaleX: opt.scaleX || 1,
  64589. scaleY: opt.scaleY || 1
  64590. });
  64591. this._transform = thisGroup.getLocalTransform();
  64592. return this;
  64593. }; // eachCover(cb, context): void {
  64594. // each(this._covers, cb, context);
  64595. // }
  64596. /**
  64597. * Update covers.
  64598. * @param coverConfigList
  64599. * If coverConfigList is null/undefined, all covers removed.
  64600. */
  64601. BrushController.prototype.updateCovers = function (coverConfigList) {
  64602. {
  64603. assert$1(this._mounted);
  64604. }
  64605. coverConfigList = map(coverConfigList, function (coverConfig) {
  64606. return merge(clone(DEFAULT_BRUSH_OPT), coverConfig, true);
  64607. });
  64608. var tmpIdPrefix = '\0-brush-index-';
  64609. var oldCovers = this._covers;
  64610. var newCovers = this._covers = [];
  64611. var controller = this;
  64612. var creatingCover = this._creatingCover;
  64613. new DataDiffer(oldCovers, coverConfigList, oldGetKey, getKey).add(addOrUpdate).update(addOrUpdate).remove(remove).execute();
  64614. return this;
  64615. function getKey(brushOption, index) {
  64616. return (brushOption.id != null ? brushOption.id : tmpIdPrefix + index) + '-' + brushOption.brushType;
  64617. }
  64618. function oldGetKey(cover, index) {
  64619. return getKey(cover.__brushOption, index);
  64620. }
  64621. function addOrUpdate(newIndex, oldIndex) {
  64622. var newBrushInternal = coverConfigList[newIndex]; // Consider setOption in event listener of brushSelect,
  64623. // where updating cover when creating should be forbiden.
  64624. if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
  64625. newCovers[newIndex] = oldCovers[oldIndex];
  64626. } else {
  64627. var cover = newCovers[newIndex] = oldIndex != null ? (oldCovers[oldIndex].__brushOption = newBrushInternal, oldCovers[oldIndex]) : endCreating(controller, createCover(controller, newBrushInternal));
  64628. updateCoverAfterCreation(controller, cover);
  64629. }
  64630. }
  64631. function remove(oldIndex) {
  64632. if (oldCovers[oldIndex] !== creatingCover) {
  64633. controller.group.remove(oldCovers[oldIndex]);
  64634. }
  64635. }
  64636. };
  64637. BrushController.prototype.unmount = function () {
  64638. {
  64639. if (!this._mounted) {
  64640. return;
  64641. }
  64642. }
  64643. this.enableBrush(false); // container may 'removeAll' outside.
  64644. clearCovers(this);
  64645. this._zr.remove(this.group);
  64646. {
  64647. this._mounted = false; // should be at last.
  64648. }
  64649. return this;
  64650. };
  64651. BrushController.prototype.dispose = function () {
  64652. this.unmount();
  64653. this.off();
  64654. };
  64655. return BrushController;
  64656. }(Eventful);
  64657. function createCover(controller, brushOption) {
  64658. var cover = coverRenderers[brushOption.brushType].createCover(controller, brushOption);
  64659. cover.__brushOption = brushOption;
  64660. updateZ(cover, brushOption);
  64661. controller.group.add(cover);
  64662. return cover;
  64663. }
  64664. function endCreating(controller, creatingCover) {
  64665. var coverRenderer = getCoverRenderer(creatingCover);
  64666. if (coverRenderer.endCreating) {
  64667. coverRenderer.endCreating(controller, creatingCover);
  64668. updateZ(creatingCover, creatingCover.__brushOption);
  64669. }
  64670. return creatingCover;
  64671. }
  64672. function updateCoverShape(controller, cover) {
  64673. var brushOption = cover.__brushOption;
  64674. getCoverRenderer(cover).updateCoverShape(controller, cover, brushOption.range, brushOption);
  64675. }
  64676. function updateZ(cover, brushOption) {
  64677. var z = brushOption.z;
  64678. z == null && (z = COVER_Z);
  64679. cover.traverse(function (el) {
  64680. el.z = z;
  64681. el.z2 = z; // Consider in given container.
  64682. });
  64683. }
  64684. function updateCoverAfterCreation(controller, cover) {
  64685. getCoverRenderer(cover).updateCommon(controller, cover);
  64686. updateCoverShape(controller, cover);
  64687. }
  64688. function getCoverRenderer(cover) {
  64689. return coverRenderers[cover.__brushOption.brushType];
  64690. } // return target panel or `true` (means global panel)
  64691. function getPanelByPoint(controller, e, localCursorPoint) {
  64692. var panels = controller._panels;
  64693. if (!panels) {
  64694. return BRUSH_PANEL_GLOBAL; // Global panel
  64695. }
  64696. var panel;
  64697. var transform = controller._transform;
  64698. each$1(panels, function (pn) {
  64699. pn.isTargetByCursor(e, localCursorPoint, transform) && (panel = pn);
  64700. });
  64701. return panel;
  64702. } // Return a panel or true
  64703. function getPanelByCover(controller, cover) {
  64704. var panels = controller._panels;
  64705. if (!panels) {
  64706. return BRUSH_PANEL_GLOBAL; // Global panel
  64707. }
  64708. var panelId = cover.__brushOption.panelId; // User may give cover without coord sys info,
  64709. // which is then treated as global panel.
  64710. return panelId != null ? panels[panelId] : BRUSH_PANEL_GLOBAL;
  64711. }
  64712. function clearCovers(controller) {
  64713. var covers = controller._covers;
  64714. var originalLength = covers.length;
  64715. each$1(covers, function (cover) {
  64716. controller.group.remove(cover);
  64717. }, controller);
  64718. covers.length = 0;
  64719. return !!originalLength;
  64720. }
  64721. function trigger$1(controller, opt) {
  64722. var areas = map(controller._covers, function (cover) {
  64723. var brushOption = cover.__brushOption;
  64724. var range = clone(brushOption.range);
  64725. return {
  64726. brushType: brushOption.brushType,
  64727. panelId: brushOption.panelId,
  64728. range: range
  64729. };
  64730. });
  64731. controller.trigger('brush', {
  64732. areas: areas,
  64733. isEnd: !!opt.isEnd,
  64734. removeOnClick: !!opt.removeOnClick
  64735. });
  64736. }
  64737. function shouldShowCover(controller) {
  64738. var track = controller._track;
  64739. if (!track.length) {
  64740. return false;
  64741. }
  64742. var p2 = track[track.length - 1];
  64743. var p1 = track[0];
  64744. var dx = p2[0] - p1[0];
  64745. var dy = p2[1] - p1[1];
  64746. var dist = mathPow$2(dx * dx + dy * dy, 0.5);
  64747. return dist > UNSELECT_THRESHOLD;
  64748. }
  64749. function getTrackEnds(track) {
  64750. var tail = track.length - 1;
  64751. tail < 0 && (tail = 0);
  64752. return [track[0], track[tail]];
  64753. }
  64754. function createBaseRectCover(rectRangeConverter, controller, brushOption, edgeNameSequences) {
  64755. var cover = new Group();
  64756. cover.add(new Rect({
  64757. name: 'main',
  64758. style: makeStyle(brushOption),
  64759. silent: true,
  64760. draggable: true,
  64761. cursor: 'move',
  64762. drift: curry(driftRect, rectRangeConverter, controller, cover, ['n', 's', 'w', 'e']),
  64763. ondragend: curry(trigger$1, controller, {
  64764. isEnd: true
  64765. })
  64766. }));
  64767. each$1(edgeNameSequences, function (nameSequence) {
  64768. cover.add(new Rect({
  64769. name: nameSequence.join(''),
  64770. style: {
  64771. opacity: 0
  64772. },
  64773. draggable: true,
  64774. silent: true,
  64775. invisible: true,
  64776. drift: curry(driftRect, rectRangeConverter, controller, cover, nameSequence),
  64777. ondragend: curry(trigger$1, controller, {
  64778. isEnd: true
  64779. })
  64780. }));
  64781. });
  64782. return cover;
  64783. }
  64784. function updateBaseRect(controller, cover, localRange, brushOption) {
  64785. var lineWidth = brushOption.brushStyle.lineWidth || 0;
  64786. var handleSize = mathMax$9(lineWidth, MIN_RESIZE_LINE_WIDTH);
  64787. var x = localRange[0][0];
  64788. var y = localRange[1][0];
  64789. var xa = x - lineWidth / 2;
  64790. var ya = y - lineWidth / 2;
  64791. var x2 = localRange[0][1];
  64792. var y2 = localRange[1][1];
  64793. var x2a = x2 - handleSize + lineWidth / 2;
  64794. var y2a = y2 - handleSize + lineWidth / 2;
  64795. var width = x2 - x;
  64796. var height = y2 - y;
  64797. var widtha = width + lineWidth;
  64798. var heighta = height + lineWidth;
  64799. updateRectShape(controller, cover, 'main', x, y, width, height);
  64800. if (brushOption.transformable) {
  64801. updateRectShape(controller, cover, 'w', xa, ya, handleSize, heighta);
  64802. updateRectShape(controller, cover, 'e', x2a, ya, handleSize, heighta);
  64803. updateRectShape(controller, cover, 'n', xa, ya, widtha, handleSize);
  64804. updateRectShape(controller, cover, 's', xa, y2a, widtha, handleSize);
  64805. updateRectShape(controller, cover, 'nw', xa, ya, handleSize, handleSize);
  64806. updateRectShape(controller, cover, 'ne', x2a, ya, handleSize, handleSize);
  64807. updateRectShape(controller, cover, 'sw', xa, y2a, handleSize, handleSize);
  64808. updateRectShape(controller, cover, 'se', x2a, y2a, handleSize, handleSize);
  64809. }
  64810. }
  64811. function updateCommon(controller, cover) {
  64812. var brushOption = cover.__brushOption;
  64813. var transformable = brushOption.transformable;
  64814. var mainEl = cover.childAt(0);
  64815. mainEl.useStyle(makeStyle(brushOption));
  64816. mainEl.attr({
  64817. silent: !transformable,
  64818. cursor: transformable ? 'move' : 'default'
  64819. });
  64820. each$1([['w'], ['e'], ['n'], ['s'], ['s', 'e'], ['s', 'w'], ['n', 'e'], ['n', 'w']], function (nameSequence) {
  64821. var el = cover.childOfName(nameSequence.join(''));
  64822. var globalDir = nameSequence.length === 1 ? getGlobalDirection1(controller, nameSequence[0]) : getGlobalDirection2(controller, nameSequence);
  64823. el && el.attr({
  64824. silent: !transformable,
  64825. invisible: !transformable,
  64826. cursor: transformable ? CURSOR_MAP[globalDir] + '-resize' : null
  64827. });
  64828. });
  64829. }
  64830. function updateRectShape(controller, cover, name, x, y, w, h) {
  64831. var el = cover.childOfName(name);
  64832. el && el.setShape(pointsToRect(clipByPanel(controller, cover, [[x, y], [x + w, y + h]])));
  64833. }
  64834. function makeStyle(brushOption) {
  64835. return defaults({
  64836. strokeNoScale: true
  64837. }, brushOption.brushStyle);
  64838. }
  64839. function formatRectRange(x, y, x2, y2) {
  64840. var min = [mathMin$9(x, x2), mathMin$9(y, y2)];
  64841. var max = [mathMax$9(x, x2), mathMax$9(y, y2)];
  64842. return [[min[0], max[0]], [min[1], max[1]] // y range
  64843. ];
  64844. }
  64845. function getTransform$1(controller) {
  64846. return getTransform(controller.group);
  64847. }
  64848. function getGlobalDirection1(controller, localDirName) {
  64849. var map$$1 = {
  64850. w: 'left',
  64851. e: 'right',
  64852. n: 'top',
  64853. s: 'bottom'
  64854. };
  64855. var inverseMap = {
  64856. left: 'w',
  64857. right: 'e',
  64858. top: 'n',
  64859. bottom: 's'
  64860. };
  64861. var dir = transformDirection(map$$1[localDirName], getTransform$1(controller));
  64862. return inverseMap[dir];
  64863. }
  64864. function getGlobalDirection2(controller, localDirNameSeq) {
  64865. var globalDir = [getGlobalDirection1(controller, localDirNameSeq[0]), getGlobalDirection1(controller, localDirNameSeq[1])];
  64866. (globalDir[0] === 'e' || globalDir[0] === 'w') && globalDir.reverse();
  64867. return globalDir.join('');
  64868. }
  64869. function driftRect(rectRangeConverter, controller, cover, dirNameSequence, dx, dy) {
  64870. var brushOption = cover.__brushOption;
  64871. var rectRange = rectRangeConverter.toRectRange(brushOption.range);
  64872. var localDelta = toLocalDelta(controller, dx, dy);
  64873. each$1(dirNameSequence, function (dirName) {
  64874. var ind = DIRECTION_MAP[dirName];
  64875. rectRange[ind[0]][ind[1]] += localDelta[ind[0]];
  64876. });
  64877. brushOption.range = rectRangeConverter.fromRectRange(formatRectRange(rectRange[0][0], rectRange[1][0], rectRange[0][1], rectRange[1][1]));
  64878. updateCoverAfterCreation(controller, cover);
  64879. trigger$1(controller, {
  64880. isEnd: false
  64881. });
  64882. }
  64883. function driftPolygon(controller, cover, dx, dy) {
  64884. var range = cover.__brushOption.range;
  64885. var localDelta = toLocalDelta(controller, dx, dy);
  64886. each$1(range, function (point) {
  64887. point[0] += localDelta[0];
  64888. point[1] += localDelta[1];
  64889. });
  64890. updateCoverAfterCreation(controller, cover);
  64891. trigger$1(controller, {
  64892. isEnd: false
  64893. });
  64894. }
  64895. function toLocalDelta(controller, dx, dy) {
  64896. var thisGroup = controller.group;
  64897. var localD = thisGroup.transformCoordToLocal(dx, dy);
  64898. var localZero = thisGroup.transformCoordToLocal(0, 0);
  64899. return [localD[0] - localZero[0], localD[1] - localZero[1]];
  64900. }
  64901. function clipByPanel(controller, cover, data) {
  64902. var panel = getPanelByCover(controller, cover);
  64903. return panel && panel !== BRUSH_PANEL_GLOBAL ? panel.clipPath(data, controller._transform) : clone(data);
  64904. }
  64905. function pointsToRect(points) {
  64906. var xmin = mathMin$9(points[0][0], points[1][0]);
  64907. var ymin = mathMin$9(points[0][1], points[1][1]);
  64908. var xmax = mathMax$9(points[0][0], points[1][0]);
  64909. var ymax = mathMax$9(points[0][1], points[1][1]);
  64910. return {
  64911. x: xmin,
  64912. y: ymin,
  64913. width: xmax - xmin,
  64914. height: ymax - ymin
  64915. };
  64916. }
  64917. function resetCursor(controller, e, localCursorPoint) {
  64918. if ( // Check active
  64919. !controller._brushType // resetCursor should be always called when mouse is in zr area,
  64920. // but not called when mouse is out of zr area to avoid bad influence
  64921. // if `mousemove`, `mouseup` are triggered from `document` event.
  64922. || isOutsideZrArea(controller, e.offsetX, e.offsetY)) {
  64923. return;
  64924. }
  64925. var zr = controller._zr;
  64926. var covers = controller._covers;
  64927. var currPanel = getPanelByPoint(controller, e, localCursorPoint); // Check whether in covers.
  64928. if (!controller._dragging) {
  64929. for (var i = 0; i < covers.length; i++) {
  64930. var brushOption = covers[i].__brushOption;
  64931. if (currPanel && (currPanel === BRUSH_PANEL_GLOBAL || brushOption.panelId === currPanel.panelId) && coverRenderers[brushOption.brushType].contain(covers[i], localCursorPoint[0], localCursorPoint[1])) {
  64932. // Use cursor style set on cover.
  64933. return;
  64934. }
  64935. }
  64936. }
  64937. currPanel && zr.setCursorStyle('crosshair');
  64938. }
  64939. function preventDefault(e) {
  64940. var rawE = e.event;
  64941. rawE.preventDefault && rawE.preventDefault();
  64942. }
  64943. function mainShapeContain(cover, x, y) {
  64944. return cover.childOfName('main').contain(x, y);
  64945. }
  64946. function updateCoverByMouse(controller, e, localCursorPoint, isEnd) {
  64947. var creatingCover = controller._creatingCover;
  64948. var panel = controller._creatingPanel;
  64949. var thisBrushOption = controller._brushOption;
  64950. var eventParams;
  64951. controller._track.push(localCursorPoint.slice());
  64952. if (shouldShowCover(controller) || creatingCover) {
  64953. if (panel && !creatingCover) {
  64954. thisBrushOption.brushMode === 'single' && clearCovers(controller);
  64955. var brushOption = clone(thisBrushOption);
  64956. brushOption.brushType = determineBrushType(brushOption.brushType, panel);
  64957. brushOption.panelId = panel === BRUSH_PANEL_GLOBAL ? null : panel.panelId;
  64958. creatingCover = controller._creatingCover = createCover(controller, brushOption);
  64959. controller._covers.push(creatingCover);
  64960. }
  64961. if (creatingCover) {
  64962. var coverRenderer = coverRenderers[determineBrushType(controller._brushType, panel)];
  64963. var coverBrushOption = creatingCover.__brushOption;
  64964. coverBrushOption.range = coverRenderer.getCreatingRange(clipByPanel(controller, creatingCover, controller._track));
  64965. if (isEnd) {
  64966. endCreating(controller, creatingCover);
  64967. coverRenderer.updateCommon(controller, creatingCover);
  64968. }
  64969. updateCoverShape(controller, creatingCover);
  64970. eventParams = {
  64971. isEnd: isEnd
  64972. };
  64973. }
  64974. } else if (isEnd && thisBrushOption.brushMode === 'single' && thisBrushOption.removeOnClick) {
  64975. // Help user to remove covers easily, only by a tiny drag, in 'single' mode.
  64976. // But a single click do not clear covers, because user may have casual
  64977. // clicks (for example, click on other component and do not expect covers
  64978. // disappear).
  64979. // Only some cover removed, trigger action, but not every click trigger action.
  64980. if (getPanelByPoint(controller, e, localCursorPoint) && clearCovers(controller)) {
  64981. eventParams = {
  64982. isEnd: isEnd,
  64983. removeOnClick: true
  64984. };
  64985. }
  64986. }
  64987. return eventParams;
  64988. }
  64989. function determineBrushType(brushType, panel) {
  64990. if (brushType === 'auto') {
  64991. {
  64992. assert$1(panel && panel.defaultBrushType, 'MUST have defaultBrushType when brushType is "atuo"');
  64993. }
  64994. return panel.defaultBrushType;
  64995. }
  64996. return brushType;
  64997. }
  64998. var pointerHandlers = {
  64999. mousedown: function (e) {
  65000. if (this._dragging) {
  65001. // In case some browser do not support globalOut,
  65002. // and release mouse out side the browser.
  65003. handleDragEnd(this, e);
  65004. } else if (!e.target || !e.target.draggable) {
  65005. preventDefault(e);
  65006. var localCursorPoint = this.group.transformCoordToLocal(e.offsetX, e.offsetY);
  65007. this._creatingCover = null;
  65008. var panel = this._creatingPanel = getPanelByPoint(this, e, localCursorPoint);
  65009. if (panel) {
  65010. this._dragging = true;
  65011. this._track = [localCursorPoint.slice()];
  65012. }
  65013. }
  65014. },
  65015. mousemove: function (e) {
  65016. var x = e.offsetX;
  65017. var y = e.offsetY;
  65018. var localCursorPoint = this.group.transformCoordToLocal(x, y);
  65019. resetCursor(this, e, localCursorPoint);
  65020. if (this._dragging) {
  65021. preventDefault(e);
  65022. var eventParams = updateCoverByMouse(this, e, localCursorPoint, false);
  65023. eventParams && trigger$1(this, eventParams);
  65024. }
  65025. },
  65026. mouseup: function (e) {
  65027. handleDragEnd(this, e);
  65028. }
  65029. };
  65030. function handleDragEnd(controller, e) {
  65031. if (controller._dragging) {
  65032. preventDefault(e);
  65033. var x = e.offsetX;
  65034. var y = e.offsetY;
  65035. var localCursorPoint = controller.group.transformCoordToLocal(x, y);
  65036. var eventParams = updateCoverByMouse(controller, e, localCursorPoint, true);
  65037. controller._dragging = false;
  65038. controller._track = [];
  65039. controller._creatingCover = null; // trigger event shoule be at final, after procedure will be nested.
  65040. eventParams && trigger$1(controller, eventParams);
  65041. }
  65042. }
  65043. function isOutsideZrArea(controller, x, y) {
  65044. var zr = controller._zr;
  65045. return x < 0 || x > zr.getWidth() || y < 0 || y > zr.getHeight();
  65046. }
  65047. /**
  65048. * key: brushType
  65049. */
  65050. var coverRenderers = {
  65051. lineX: getLineRenderer(0),
  65052. lineY: getLineRenderer(1),
  65053. rect: {
  65054. createCover: function (controller, brushOption) {
  65055. function returnInput(range) {
  65056. return range;
  65057. }
  65058. return createBaseRectCover({
  65059. toRectRange: returnInput,
  65060. fromRectRange: returnInput
  65061. }, controller, brushOption, [['w'], ['e'], ['n'], ['s'], ['s', 'e'], ['s', 'w'], ['n', 'e'], ['n', 'w']]);
  65062. },
  65063. getCreatingRange: function (localTrack) {
  65064. var ends = getTrackEnds(localTrack);
  65065. return formatRectRange(ends[1][0], ends[1][1], ends[0][0], ends[0][1]);
  65066. },
  65067. updateCoverShape: function (controller, cover, localRange, brushOption) {
  65068. updateBaseRect(controller, cover, localRange, brushOption);
  65069. },
  65070. updateCommon: updateCommon,
  65071. contain: mainShapeContain
  65072. },
  65073. polygon: {
  65074. createCover: function (controller, brushOption) {
  65075. var cover = new Group(); // Do not use graphic.Polygon because graphic.Polyline do not close the
  65076. // border of the shape when drawing, which is a better experience for user.
  65077. cover.add(new Polyline({
  65078. name: 'main',
  65079. style: makeStyle(brushOption),
  65080. silent: true
  65081. }));
  65082. return cover;
  65083. },
  65084. getCreatingRange: function (localTrack) {
  65085. return localTrack;
  65086. },
  65087. endCreating: function (controller, cover) {
  65088. cover.remove(cover.childAt(0)); // Use graphic.Polygon close the shape.
  65089. cover.add(new Polygon({
  65090. name: 'main',
  65091. draggable: true,
  65092. drift: curry(driftPolygon, controller, cover),
  65093. ondragend: curry(trigger$1, controller, {
  65094. isEnd: true
  65095. })
  65096. }));
  65097. },
  65098. updateCoverShape: function (controller, cover, localRange, brushOption) {
  65099. cover.childAt(0).setShape({
  65100. points: clipByPanel(controller, cover, localRange)
  65101. });
  65102. },
  65103. updateCommon: updateCommon,
  65104. contain: mainShapeContain
  65105. }
  65106. };
  65107. function getLineRenderer(xyIndex) {
  65108. return {
  65109. createCover: function (controller, brushOption) {
  65110. return createBaseRectCover({
  65111. toRectRange: function (range) {
  65112. var rectRange = [range, [0, 100]];
  65113. xyIndex && rectRange.reverse();
  65114. return rectRange;
  65115. },
  65116. fromRectRange: function (rectRange) {
  65117. return rectRange[xyIndex];
  65118. }
  65119. }, controller, brushOption, [[['w'], ['e']], [['n'], ['s']]][xyIndex]);
  65120. },
  65121. getCreatingRange: function (localTrack) {
  65122. var ends = getTrackEnds(localTrack);
  65123. var min = mathMin$9(ends[0][xyIndex], ends[1][xyIndex]);
  65124. var max = mathMax$9(ends[0][xyIndex], ends[1][xyIndex]);
  65125. return [min, max];
  65126. },
  65127. updateCoverShape: function (controller, cover, localRange, brushOption) {
  65128. var otherExtent; // If brushWidth not specified, fit the panel.
  65129. var panel = getPanelByCover(controller, cover);
  65130. if (panel !== BRUSH_PANEL_GLOBAL && panel.getLinearBrushOtherExtent) {
  65131. otherExtent = panel.getLinearBrushOtherExtent(xyIndex);
  65132. } else {
  65133. var zr = controller._zr;
  65134. otherExtent = [0, [zr.getWidth(), zr.getHeight()][1 - xyIndex]];
  65135. }
  65136. var rectRange = [localRange, otherExtent];
  65137. xyIndex && rectRange.reverse();
  65138. updateBaseRect(controller, cover, rectRange, brushOption);
  65139. },
  65140. updateCommon: updateCommon,
  65141. contain: mainShapeContain
  65142. };
  65143. }
  65144. /*
  65145. * Licensed to the Apache Software Foundation (ASF) under one
  65146. * or more contributor license agreements. See the NOTICE file
  65147. * distributed with this work for additional information
  65148. * regarding copyright ownership. The ASF licenses this file
  65149. * to you under the Apache License, Version 2.0 (the
  65150. * "License"); you may not use this file except in compliance
  65151. * with the License. You may obtain a copy of the License at
  65152. *
  65153. * http://www.apache.org/licenses/LICENSE-2.0
  65154. *
  65155. * Unless required by applicable law or agreed to in writing,
  65156. * software distributed under the License is distributed on an
  65157. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65158. * KIND, either express or implied. See the License for the
  65159. * specific language governing permissions and limitations
  65160. * under the License.
  65161. */
  65162. /**
  65163. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65164. */
  65165. /*
  65166. * Licensed to the Apache Software Foundation (ASF) under one
  65167. * or more contributor license agreements. See the NOTICE file
  65168. * distributed with this work for additional information
  65169. * regarding copyright ownership. The ASF licenses this file
  65170. * to you under the Apache License, Version 2.0 (the
  65171. * "License"); you may not use this file except in compliance
  65172. * with the License. You may obtain a copy of the License at
  65173. *
  65174. * http://www.apache.org/licenses/LICENSE-2.0
  65175. *
  65176. * Unless required by applicable law or agreed to in writing,
  65177. * software distributed under the License is distributed on an
  65178. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65179. * KIND, either express or implied. See the License for the
  65180. * specific language governing permissions and limitations
  65181. * under the License.
  65182. */
  65183. function makeRectPanelClipPath(rect) {
  65184. rect = normalizeRect(rect);
  65185. return function (localPoints) {
  65186. return clipPointsByRect(localPoints, rect);
  65187. };
  65188. }
  65189. function makeLinearBrushOtherExtent(rect, specifiedXYIndex) {
  65190. rect = normalizeRect(rect);
  65191. return function (xyIndex) {
  65192. var idx = specifiedXYIndex != null ? specifiedXYIndex : xyIndex;
  65193. var brushWidth = idx ? rect.width : rect.height;
  65194. var base = idx ? rect.x : rect.y;
  65195. return [base, base + (brushWidth || 0)];
  65196. };
  65197. }
  65198. function makeRectIsTargetByCursor(rect, api, targetModel) {
  65199. var boundingRect = normalizeRect(rect);
  65200. return function (e, localCursorPoint) {
  65201. return boundingRect.contain(localCursorPoint[0], localCursorPoint[1]) && !onIrrelevantElement(e, api, targetModel);
  65202. };
  65203. } // Consider width/height is negative.
  65204. function normalizeRect(rect) {
  65205. return BoundingRect.create(rect);
  65206. }
  65207. /*
  65208. * Licensed to the Apache Software Foundation (ASF) under one
  65209. * or more contributor license agreements. See the NOTICE file
  65210. * distributed with this work for additional information
  65211. * regarding copyright ownership. The ASF licenses this file
  65212. * to you under the Apache License, Version 2.0 (the
  65213. * "License"); you may not use this file except in compliance
  65214. * with the License. You may obtain a copy of the License at
  65215. *
  65216. * http://www.apache.org/licenses/LICENSE-2.0
  65217. *
  65218. * Unless required by applicable law or agreed to in writing,
  65219. * software distributed under the License is distributed on an
  65220. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65221. * KIND, either express or implied. See the License for the
  65222. * specific language governing permissions and limitations
  65223. * under the License.
  65224. */
  65225. /**
  65226. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65227. */
  65228. /*
  65229. * Licensed to the Apache Software Foundation (ASF) under one
  65230. * or more contributor license agreements. See the NOTICE file
  65231. * distributed with this work for additional information
  65232. * regarding copyright ownership. The ASF licenses this file
  65233. * to you under the Apache License, Version 2.0 (the
  65234. * "License"); you may not use this file except in compliance
  65235. * with the License. You may obtain a copy of the License at
  65236. *
  65237. * http://www.apache.org/licenses/LICENSE-2.0
  65238. *
  65239. * Unless required by applicable law or agreed to in writing,
  65240. * software distributed under the License is distributed on an
  65241. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65242. * KIND, either express or implied. See the License for the
  65243. * specific language governing permissions and limitations
  65244. * under the License.
  65245. */
  65246. var elementList = ['axisLine', 'axisTickLabel', 'axisName'];
  65247. var ParallelAxisView =
  65248. /** @class */
  65249. function (_super) {
  65250. __extends(ParallelAxisView, _super);
  65251. function ParallelAxisView() {
  65252. var _this = _super !== null && _super.apply(this, arguments) || this;
  65253. _this.type = ParallelAxisView.type;
  65254. return _this;
  65255. }
  65256. ParallelAxisView.prototype.init = function (ecModel, api) {
  65257. _super.prototype.init.apply(this, arguments);
  65258. (this._brushController = new BrushController(api.getZr())).on('brush', bind(this._onBrush, this));
  65259. };
  65260. ParallelAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
  65261. if (fromAxisAreaSelect(axisModel, ecModel, payload)) {
  65262. return;
  65263. }
  65264. this.axisModel = axisModel;
  65265. this.api = api;
  65266. this.group.removeAll();
  65267. var oldAxisGroup = this._axisGroup;
  65268. this._axisGroup = new Group();
  65269. this.group.add(this._axisGroup);
  65270. if (!axisModel.get('show')) {
  65271. return;
  65272. }
  65273. var coordSysModel = getCoordSysModel(axisModel, ecModel);
  65274. var coordSys = coordSysModel.coordinateSystem;
  65275. var areaSelectStyle = axisModel.getAreaSelectStyle();
  65276. var areaWidth = areaSelectStyle.width;
  65277. var dim = axisModel.axis.dim;
  65278. var axisLayout = coordSys.getAxisLayout(dim);
  65279. var builderOpt = extend({
  65280. strokeContainThreshold: areaWidth
  65281. }, axisLayout);
  65282. var axisBuilder = new AxisBuilder(axisModel, builderOpt);
  65283. each$1(elementList, axisBuilder.add, axisBuilder);
  65284. this._axisGroup.add(axisBuilder.getGroup());
  65285. this._refreshBrushController(builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api);
  65286. groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  65287. }; // /**
  65288. // * @override
  65289. // */
  65290. // updateVisual(axisModel, ecModel, api, payload) {
  65291. // this._brushController && this._brushController
  65292. // .updateCovers(getCoverInfoList(axisModel));
  65293. // }
  65294. ParallelAxisView.prototype._refreshBrushController = function (builderOpt, areaSelectStyle, axisModel, coordSysModel, areaWidth, api) {
  65295. // After filtering, axis may change, select area needs to be update.
  65296. var extent = axisModel.axis.getExtent();
  65297. var extentLen = extent[1] - extent[0];
  65298. var extra = Math.min(30, Math.abs(extentLen) * 0.1); // Arbitrary value.
  65299. // width/height might be negative, which will be
  65300. // normalized in BoundingRect.
  65301. var rect = BoundingRect.create({
  65302. x: extent[0],
  65303. y: -areaWidth / 2,
  65304. width: extentLen,
  65305. height: areaWidth
  65306. });
  65307. rect.x -= extra;
  65308. rect.width += 2 * extra;
  65309. this._brushController.mount({
  65310. enableGlobalPan: true,
  65311. rotation: builderOpt.rotation,
  65312. x: builderOpt.position[0],
  65313. y: builderOpt.position[1]
  65314. }).setPanels([{
  65315. panelId: 'pl',
  65316. clipPath: makeRectPanelClipPath(rect),
  65317. isTargetByCursor: makeRectIsTargetByCursor(rect, api, coordSysModel),
  65318. getLinearBrushOtherExtent: makeLinearBrushOtherExtent(rect, 0)
  65319. }]).enableBrush({
  65320. brushType: 'lineX',
  65321. brushStyle: areaSelectStyle,
  65322. removeOnClick: true
  65323. }).updateCovers(getCoverInfoList(axisModel));
  65324. };
  65325. ParallelAxisView.prototype._onBrush = function (eventParam) {
  65326. var coverInfoList = eventParam.areas; // Do not cache these object, because the mey be changed.
  65327. var axisModel = this.axisModel;
  65328. var axis = axisModel.axis;
  65329. var intervals = map(coverInfoList, function (coverInfo) {
  65330. return [axis.coordToData(coverInfo.range[0], true), axis.coordToData(coverInfo.range[1], true)];
  65331. }); // If realtime is true, action is not dispatched on drag end, because
  65332. // the drag end emits the same params with the last drag move event,
  65333. // and may have some delay when using touch pad.
  65334. if (!axisModel.option.realtime === eventParam.isEnd || eventParam.removeOnClick) {
  65335. // jshint ignore:line
  65336. this.api.dispatchAction({
  65337. type: 'axisAreaSelect',
  65338. parallelAxisId: axisModel.id,
  65339. intervals: intervals
  65340. });
  65341. }
  65342. };
  65343. ParallelAxisView.prototype.dispose = function () {
  65344. this._brushController.dispose();
  65345. };
  65346. ParallelAxisView.type = 'parallelAxis';
  65347. return ParallelAxisView;
  65348. }(ComponentView);
  65349. function fromAxisAreaSelect(axisModel, ecModel, payload) {
  65350. return payload && payload.type === 'axisAreaSelect' && ecModel.findComponents({
  65351. mainType: 'parallelAxis',
  65352. query: payload
  65353. })[0] === axisModel;
  65354. }
  65355. function getCoverInfoList(axisModel) {
  65356. var axis = axisModel.axis;
  65357. return map(axisModel.activeIntervals, function (interval) {
  65358. return {
  65359. brushType: 'lineX',
  65360. panelId: 'pl',
  65361. range: [axis.dataToCoord(interval[0], true), axis.dataToCoord(interval[1], true)]
  65362. };
  65363. });
  65364. }
  65365. function getCoordSysModel(axisModel, ecModel) {
  65366. return ecModel.getComponent('parallel', axisModel.get('parallelIndex'));
  65367. }
  65368. /*
  65369. * Licensed to the Apache Software Foundation (ASF) under one
  65370. * or more contributor license agreements. See the NOTICE file
  65371. * distributed with this work for additional information
  65372. * regarding copyright ownership. The ASF licenses this file
  65373. * to you under the Apache License, Version 2.0 (the
  65374. * "License"); you may not use this file except in compliance
  65375. * with the License. You may obtain a copy of the License at
  65376. *
  65377. * http://www.apache.org/licenses/LICENSE-2.0
  65378. *
  65379. * Unless required by applicable law or agreed to in writing,
  65380. * software distributed under the License is distributed on an
  65381. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65382. * KIND, either express or implied. See the License for the
  65383. * specific language governing permissions and limitations
  65384. * under the License.
  65385. */
  65386. /**
  65387. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65388. */
  65389. /*
  65390. * Licensed to the Apache Software Foundation (ASF) under one
  65391. * or more contributor license agreements. See the NOTICE file
  65392. * distributed with this work for additional information
  65393. * regarding copyright ownership. The ASF licenses this file
  65394. * to you under the Apache License, Version 2.0 (the
  65395. * "License"); you may not use this file except in compliance
  65396. * with the License. You may obtain a copy of the License at
  65397. *
  65398. * http://www.apache.org/licenses/LICENSE-2.0
  65399. *
  65400. * Unless required by applicable law or agreed to in writing,
  65401. * software distributed under the License is distributed on an
  65402. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65403. * KIND, either express or implied. See the License for the
  65404. * specific language governing permissions and limitations
  65405. * under the License.
  65406. */
  65407. var actionInfo$1 = {
  65408. type: 'axisAreaSelect',
  65409. event: 'axisAreaSelected' // update: 'updateVisual'
  65410. };
  65411. function installParallelActions(registers) {
  65412. registers.registerAction(actionInfo$1, function (payload, ecModel) {
  65413. ecModel.eachComponent({
  65414. mainType: 'parallelAxis',
  65415. query: payload
  65416. }, function (parallelAxisModel) {
  65417. parallelAxisModel.axis.model.setActiveIntervals(payload.intervals);
  65418. });
  65419. });
  65420. /**
  65421. * @payload
  65422. */
  65423. registers.registerAction('parallelAxisExpand', function (payload, ecModel) {
  65424. ecModel.eachComponent({
  65425. mainType: 'parallel',
  65426. query: payload
  65427. }, function (parallelModel) {
  65428. parallelModel.setAxisExpand(payload);
  65429. });
  65430. });
  65431. }
  65432. /*
  65433. * Licensed to the Apache Software Foundation (ASF) under one
  65434. * or more contributor license agreements. See the NOTICE file
  65435. * distributed with this work for additional information
  65436. * regarding copyright ownership. The ASF licenses this file
  65437. * to you under the Apache License, Version 2.0 (the
  65438. * "License"); you may not use this file except in compliance
  65439. * with the License. You may obtain a copy of the License at
  65440. *
  65441. * http://www.apache.org/licenses/LICENSE-2.0
  65442. *
  65443. * Unless required by applicable law or agreed to in writing,
  65444. * software distributed under the License is distributed on an
  65445. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65446. * KIND, either express or implied. See the License for the
  65447. * specific language governing permissions and limitations
  65448. * under the License.
  65449. */
  65450. /**
  65451. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65452. */
  65453. /*
  65454. * Licensed to the Apache Software Foundation (ASF) under one
  65455. * or more contributor license agreements. See the NOTICE file
  65456. * distributed with this work for additional information
  65457. * regarding copyright ownership. The ASF licenses this file
  65458. * to you under the Apache License, Version 2.0 (the
  65459. * "License"); you may not use this file except in compliance
  65460. * with the License. You may obtain a copy of the License at
  65461. *
  65462. * http://www.apache.org/licenses/LICENSE-2.0
  65463. *
  65464. * Unless required by applicable law or agreed to in writing,
  65465. * software distributed under the License is distributed on an
  65466. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65467. * KIND, either express or implied. See the License for the
  65468. * specific language governing permissions and limitations
  65469. * under the License.
  65470. */
  65471. var defaultAxisOption = {
  65472. type: 'value',
  65473. areaSelectStyle: {
  65474. width: 20,
  65475. borderWidth: 1,
  65476. borderColor: 'rgba(160,197,232)',
  65477. color: 'rgba(160,197,232)',
  65478. opacity: 0.3
  65479. },
  65480. realtime: true,
  65481. z: 10
  65482. };
  65483. function install$21(registers) {
  65484. registers.registerComponentView(ParallelView$2);
  65485. registers.registerComponentModel(ParallelModel);
  65486. registers.registerCoordinateSystem('parallel', parallelCoordSysCreator);
  65487. registers.registerPreprocessor(parallelPreprocessor);
  65488. registers.registerComponentModel(ParallelAxisModel);
  65489. registers.registerComponentView(ParallelAxisView);
  65490. axisModelCreator(registers, 'parallel', ParallelAxisModel, defaultAxisOption);
  65491. installParallelActions(registers);
  65492. }
  65493. /*
  65494. * Licensed to the Apache Software Foundation (ASF) under one
  65495. * or more contributor license agreements. See the NOTICE file
  65496. * distributed with this work for additional information
  65497. * regarding copyright ownership. The ASF licenses this file
  65498. * to you under the Apache License, Version 2.0 (the
  65499. * "License"); you may not use this file except in compliance
  65500. * with the License. You may obtain a copy of the License at
  65501. *
  65502. * http://www.apache.org/licenses/LICENSE-2.0
  65503. *
  65504. * Unless required by applicable law or agreed to in writing,
  65505. * software distributed under the License is distributed on an
  65506. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65507. * KIND, either express or implied. See the License for the
  65508. * specific language governing permissions and limitations
  65509. * under the License.
  65510. */
  65511. /**
  65512. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65513. */
  65514. /*
  65515. * Licensed to the Apache Software Foundation (ASF) under one
  65516. * or more contributor license agreements. See the NOTICE file
  65517. * distributed with this work for additional information
  65518. * regarding copyright ownership. The ASF licenses this file
  65519. * to you under the Apache License, Version 2.0 (the
  65520. * "License"); you may not use this file except in compliance
  65521. * with the License. You may obtain a copy of the License at
  65522. *
  65523. * http://www.apache.org/licenses/LICENSE-2.0
  65524. *
  65525. * Unless required by applicable law or agreed to in writing,
  65526. * software distributed under the License is distributed on an
  65527. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65528. * KIND, either express or implied. See the License for the
  65529. * specific language governing permissions and limitations
  65530. * under the License.
  65531. */
  65532. function install$20(registers) {
  65533. use(install$21);
  65534. registers.registerChartView(ParallelView);
  65535. registers.registerSeriesModel(ParallelSeriesModel);
  65536. registers.registerVisual(registers.PRIORITY.VISUAL.BRUSH, parallelVisual);
  65537. }
  65538. /*
  65539. * Licensed to the Apache Software Foundation (ASF) under one
  65540. * or more contributor license agreements. See the NOTICE file
  65541. * distributed with this work for additional information
  65542. * regarding copyright ownership. The ASF licenses this file
  65543. * to you under the Apache License, Version 2.0 (the
  65544. * "License"); you may not use this file except in compliance
  65545. * with the License. You may obtain a copy of the License at
  65546. *
  65547. * http://www.apache.org/licenses/LICENSE-2.0
  65548. *
  65549. * Unless required by applicable law or agreed to in writing,
  65550. * software distributed under the License is distributed on an
  65551. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65552. * KIND, either express or implied. See the License for the
  65553. * specific language governing permissions and limitations
  65554. * under the License.
  65555. */
  65556. /**
  65557. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65558. */
  65559. /*
  65560. * Licensed to the Apache Software Foundation (ASF) under one
  65561. * or more contributor license agreements. See the NOTICE file
  65562. * distributed with this work for additional information
  65563. * regarding copyright ownership. The ASF licenses this file
  65564. * to you under the Apache License, Version 2.0 (the
  65565. * "License"); you may not use this file except in compliance
  65566. * with the License. You may obtain a copy of the License at
  65567. *
  65568. * http://www.apache.org/licenses/LICENSE-2.0
  65569. *
  65570. * Unless required by applicable law or agreed to in writing,
  65571. * software distributed under the License is distributed on an
  65572. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65573. * KIND, either express or implied. See the License for the
  65574. * specific language governing permissions and limitations
  65575. * under the License.
  65576. */
  65577. use(install$20);
  65578. /*
  65579. * Licensed to the Apache Software Foundation (ASF) under one
  65580. * or more contributor license agreements. See the NOTICE file
  65581. * distributed with this work for additional information
  65582. * regarding copyright ownership. The ASF licenses this file
  65583. * to you under the Apache License, Version 2.0 (the
  65584. * "License"); you may not use this file except in compliance
  65585. * with the License. You may obtain a copy of the License at
  65586. *
  65587. * http://www.apache.org/licenses/LICENSE-2.0
  65588. *
  65589. * Unless required by applicable law or agreed to in writing,
  65590. * software distributed under the License is distributed on an
  65591. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65592. * KIND, either express or implied. See the License for the
  65593. * specific language governing permissions and limitations
  65594. * under the License.
  65595. */
  65596. /**
  65597. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65598. */
  65599. /*
  65600. * Licensed to the Apache Software Foundation (ASF) under one
  65601. * or more contributor license agreements. See the NOTICE file
  65602. * distributed with this work for additional information
  65603. * regarding copyright ownership. The ASF licenses this file
  65604. * to you under the Apache License, Version 2.0 (the
  65605. * "License"); you may not use this file except in compliance
  65606. * with the License. You may obtain a copy of the License at
  65607. *
  65608. * http://www.apache.org/licenses/LICENSE-2.0
  65609. *
  65610. * Unless required by applicable law or agreed to in writing,
  65611. * software distributed under the License is distributed on an
  65612. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65613. * KIND, either express or implied. See the License for the
  65614. * specific language governing permissions and limitations
  65615. * under the License.
  65616. */
  65617. var PointerShape =
  65618. /** @class */
  65619. function () {
  65620. function PointerShape() {
  65621. this.angle = 0;
  65622. this.width = 10;
  65623. this.r = 10;
  65624. this.x = 0;
  65625. this.y = 0;
  65626. }
  65627. return PointerShape;
  65628. }();
  65629. var PointerPath =
  65630. /** @class */
  65631. function (_super) {
  65632. __extends(PointerPath, _super);
  65633. function PointerPath(opts) {
  65634. var _this = _super.call(this, opts) || this;
  65635. _this.type = 'pointer';
  65636. return _this;
  65637. }
  65638. PointerPath.prototype.getDefaultShape = function () {
  65639. return new PointerShape();
  65640. };
  65641. PointerPath.prototype.buildPath = function (ctx, shape) {
  65642. var mathCos = Math.cos;
  65643. var mathSin = Math.sin;
  65644. var r = shape.r;
  65645. var width = shape.width;
  65646. var angle = shape.angle;
  65647. var x = shape.x - mathCos(angle) * width * (width >= r / 3 ? 1 : 2);
  65648. var y = shape.y - mathSin(angle) * width * (width >= r / 3 ? 1 : 2);
  65649. angle = shape.angle - Math.PI / 2;
  65650. ctx.moveTo(x, y);
  65651. ctx.lineTo(shape.x + mathCos(angle) * width, shape.y + mathSin(angle) * width);
  65652. ctx.lineTo(shape.x + mathCos(shape.angle) * r, shape.y + mathSin(shape.angle) * r);
  65653. ctx.lineTo(shape.x - mathCos(angle) * width, shape.y - mathSin(angle) * width);
  65654. ctx.lineTo(x, y);
  65655. };
  65656. return PointerPath;
  65657. }(Path);
  65658. /*
  65659. * Licensed to the Apache Software Foundation (ASF) under one
  65660. * or more contributor license agreements. See the NOTICE file
  65661. * distributed with this work for additional information
  65662. * regarding copyright ownership. The ASF licenses this file
  65663. * to you under the Apache License, Version 2.0 (the
  65664. * "License"); you may not use this file except in compliance
  65665. * with the License. You may obtain a copy of the License at
  65666. *
  65667. * http://www.apache.org/licenses/LICENSE-2.0
  65668. *
  65669. * Unless required by applicable law or agreed to in writing,
  65670. * software distributed under the License is distributed on an
  65671. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65672. * KIND, either express or implied. See the License for the
  65673. * specific language governing permissions and limitations
  65674. * under the License.
  65675. */
  65676. /**
  65677. * AUTO-GENERATED FILE. DO NOT MODIFY.
  65678. */
  65679. /*
  65680. * Licensed to the Apache Software Foundation (ASF) under one
  65681. * or more contributor license agreements. See the NOTICE file
  65682. * distributed with this work for additional information
  65683. * regarding copyright ownership. The ASF licenses this file
  65684. * to you under the Apache License, Version 2.0 (the
  65685. * "License"); you may not use this file except in compliance
  65686. * with the License. You may obtain a copy of the License at
  65687. *
  65688. * http://www.apache.org/licenses/LICENSE-2.0
  65689. *
  65690. * Unless required by applicable law or agreed to in writing,
  65691. * software distributed under the License is distributed on an
  65692. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  65693. * KIND, either express or implied. See the License for the
  65694. * specific language governing permissions and limitations
  65695. * under the License.
  65696. */
  65697. function parsePosition(seriesModel, api) {
  65698. var center = seriesModel.get('center');
  65699. var width = api.getWidth();
  65700. var height = api.getHeight();
  65701. var size = Math.min(width, height);
  65702. var cx = parsePercent$1(center[0], api.getWidth());
  65703. var cy = parsePercent$1(center[1], api.getHeight());
  65704. var r = parsePercent$1(seriesModel.get('radius'), size / 2);
  65705. return {
  65706. cx: cx,
  65707. cy: cy,
  65708. r: r
  65709. };
  65710. }
  65711. function formatLabel(value, labelFormatter) {
  65712. var label = value == null ? '' : value + '';
  65713. if (labelFormatter) {
  65714. if (typeof labelFormatter === 'string') {
  65715. label = labelFormatter.replace('{value}', label);
  65716. } else if (typeof labelFormatter === 'function') {
  65717. label = labelFormatter(value);
  65718. }
  65719. }
  65720. return label;
  65721. }
  65722. var PI2$8 = Math.PI * 2;
  65723. var GaugeView =
  65724. /** @class */
  65725. function (_super) {
  65726. __extends(GaugeView, _super);
  65727. function GaugeView() {
  65728. var _this = _super !== null && _super.apply(this, arguments) || this;
  65729. _this.type = GaugeView.type;
  65730. return _this;
  65731. }
  65732. GaugeView.prototype.render = function (seriesModel, ecModel, api) {
  65733. this.group.removeAll();
  65734. var colorList = seriesModel.get(['axisLine', 'lineStyle', 'color']);
  65735. var posInfo = parsePosition(seriesModel, api);
  65736. this._renderMain(seriesModel, ecModel, api, colorList, posInfo);
  65737. this._data = seriesModel.getData();
  65738. };
  65739. GaugeView.prototype.dispose = function () {};
  65740. GaugeView.prototype._renderMain = function (seriesModel, ecModel, api, colorList, posInfo) {
  65741. var group = this.group;
  65742. var clockwise = seriesModel.get('clockwise');
  65743. var startAngle = -seriesModel.get('startAngle') / 180 * Math.PI;
  65744. var endAngle = -seriesModel.get('endAngle') / 180 * Math.PI;
  65745. var axisLineModel = seriesModel.getModel('axisLine');
  65746. var roundCap = axisLineModel.get('roundCap');
  65747. var MainPath = roundCap ? SausagePath : Sector;
  65748. var showAxis = axisLineModel.get('show');
  65749. var lineStyleModel = axisLineModel.getModel('lineStyle');
  65750. var axisLineWidth = lineStyleModel.get('width');
  65751. var angleRangeSpan = !((endAngle - startAngle) % PI2$8) && endAngle !== startAngle ? PI2$8 : (endAngle - startAngle) % PI2$8;
  65752. var prevEndAngle = startAngle;
  65753. for (var i = 0; showAxis && i < colorList.length; i++) {
  65754. // Clamp
  65755. var percent = Math.min(Math.max(colorList[i][0], 0), 1);
  65756. endAngle = startAngle + angleRangeSpan * percent;
  65757. var sector = new MainPath({
  65758. shape: {
  65759. startAngle: prevEndAngle,
  65760. endAngle: endAngle,
  65761. cx: posInfo.cx,
  65762. cy: posInfo.cy,
  65763. clockwise: clockwise,
  65764. r0: posInfo.r - axisLineWidth,
  65765. r: posInfo.r
  65766. },
  65767. silent: true
  65768. });
  65769. sector.setStyle({
  65770. fill: colorList[i][1]
  65771. });
  65772. sector.setStyle(lineStyleModel.getLineStyle( // Because we use sector to simulate arc
  65773. // so the properties for stroking are useless
  65774. ['color', 'width']));
  65775. group.add(sector);
  65776. prevEndAngle = endAngle;
  65777. }
  65778. var getColor = function (percent) {
  65779. // Less than 0
  65780. if (percent <= 0) {
  65781. return colorList[0][1];
  65782. }
  65783. var i;
  65784. for (i = 0; i < colorList.length; i++) {
  65785. if (colorList[i][0] >= percent && (i === 0 ? 0 : colorList[i - 1][0]) < percent) {
  65786. return colorList[i][1];
  65787. }
  65788. } // More than 1
  65789. return colorList[i - 1][1];
  65790. };
  65791. if (!clockwise) {
  65792. var tmp = startAngle;
  65793. startAngle = endAngle;
  65794. endAngle = tmp;
  65795. }
  65796. this._renderTicks(seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth);
  65797. this._renderTitleAndDetail(seriesModel, ecModel, api, getColor, posInfo);
  65798. this._renderAnchor(seriesModel, posInfo);
  65799. this._renderPointer(seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth);
  65800. };
  65801. GaugeView.prototype._renderTicks = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
  65802. var group = this.group;
  65803. var cx = posInfo.cx;
  65804. var cy = posInfo.cy;
  65805. var r = posInfo.r;
  65806. var minVal = +seriesModel.get('min');
  65807. var maxVal = +seriesModel.get('max');
  65808. var splitLineModel = seriesModel.getModel('splitLine');
  65809. var tickModel = seriesModel.getModel('axisTick');
  65810. var labelModel = seriesModel.getModel('axisLabel');
  65811. var splitNumber = seriesModel.get('splitNumber');
  65812. var subSplitNumber = tickModel.get('splitNumber');
  65813. var splitLineLen = parsePercent$1(splitLineModel.get('length'), r);
  65814. var tickLen = parsePercent$1(tickModel.get('length'), r);
  65815. var angle = startAngle;
  65816. var step = (endAngle - startAngle) / splitNumber;
  65817. var subStep = step / subSplitNumber;
  65818. var splitLineStyle = splitLineModel.getModel('lineStyle').getLineStyle();
  65819. var tickLineStyle = tickModel.getModel('lineStyle').getLineStyle();
  65820. var splitLineDistance = splitLineModel.get('distance');
  65821. var unitX;
  65822. var unitY;
  65823. for (var i = 0; i <= splitNumber; i++) {
  65824. unitX = Math.cos(angle);
  65825. unitY = Math.sin(angle); // Split line
  65826. if (splitLineModel.get('show')) {
  65827. var distance = splitLineDistance ? splitLineDistance + axisLineWidth : axisLineWidth;
  65828. var splitLine = new Line({
  65829. shape: {
  65830. x1: unitX * (r - distance) + cx,
  65831. y1: unitY * (r - distance) + cy,
  65832. x2: unitX * (r - splitLineLen - distance) + cx,
  65833. y2: unitY * (r - splitLineLen - distance) + cy
  65834. },
  65835. style: splitLineStyle,
  65836. silent: true
  65837. });
  65838. if (splitLineStyle.stroke === 'auto') {
  65839. splitLine.setStyle({
  65840. stroke: getColor(i / splitNumber)
  65841. });
  65842. }
  65843. group.add(splitLine);
  65844. } // Label
  65845. if (labelModel.get('show')) {
  65846. var distance = labelModel.get('distance') + splitLineDistance;
  65847. var label = formatLabel(round(i / splitNumber * (maxVal - minVal) + minVal), labelModel.get('formatter'));
  65848. var autoColor = getColor(i / splitNumber);
  65849. group.add(new ZRText({
  65850. style: createTextStyle(labelModel, {
  65851. text: label,
  65852. x: unitX * (r - splitLineLen - distance) + cx,
  65853. y: unitY * (r - splitLineLen - distance) + cy,
  65854. verticalAlign: unitY < -0.8 ? 'top' : unitY > 0.8 ? 'bottom' : 'middle',
  65855. align: unitX < -0.4 ? 'left' : unitX > 0.4 ? 'right' : 'center'
  65856. }, {
  65857. inheritColor: autoColor
  65858. }),
  65859. silent: true
  65860. }));
  65861. } // Axis tick
  65862. if (tickModel.get('show') && i !== splitNumber) {
  65863. var distance = tickModel.get('distance');
  65864. distance = distance ? distance + axisLineWidth : axisLineWidth;
  65865. for (var j = 0; j <= subSplitNumber; j++) {
  65866. unitX = Math.cos(angle);
  65867. unitY = Math.sin(angle);
  65868. var tickLine = new Line({
  65869. shape: {
  65870. x1: unitX * (r - distance) + cx,
  65871. y1: unitY * (r - distance) + cy,
  65872. x2: unitX * (r - tickLen - distance) + cx,
  65873. y2: unitY * (r - tickLen - distance) + cy
  65874. },
  65875. silent: true,
  65876. style: tickLineStyle
  65877. });
  65878. if (tickLineStyle.stroke === 'auto') {
  65879. tickLine.setStyle({
  65880. stroke: getColor((i + j / subSplitNumber) / splitNumber)
  65881. });
  65882. }
  65883. group.add(tickLine);
  65884. angle += subStep;
  65885. }
  65886. angle -= subStep;
  65887. } else {
  65888. angle += step;
  65889. }
  65890. }
  65891. };
  65892. GaugeView.prototype._renderPointer = function (seriesModel, ecModel, api, getColor, posInfo, startAngle, endAngle, clockwise, axisLineWidth) {
  65893. var group = this.group;
  65894. var oldData = this._data;
  65895. var oldProgressData = this._progressEls;
  65896. var progressList = [];
  65897. var showPointer = seriesModel.get(['pointer', 'show']);
  65898. var progressModel = seriesModel.getModel('progress');
  65899. var showProgress = progressModel.get('show');
  65900. var data = seriesModel.getData();
  65901. var valueDim = data.mapDimension('value');
  65902. var minVal = +seriesModel.get('min');
  65903. var maxVal = +seriesModel.get('max');
  65904. var valueExtent = [minVal, maxVal];
  65905. var angleExtent = [startAngle, endAngle];
  65906. function createPointer(idx, angle) {
  65907. var itemModel = data.getItemModel(idx);
  65908. var pointerModel = itemModel.getModel('pointer');
  65909. var pointerWidth = parsePercent$1(pointerModel.get('width'), posInfo.r);
  65910. var pointerLength = parsePercent$1(pointerModel.get('length'), posInfo.r);
  65911. var pointerStr = seriesModel.get(['pointer', 'icon']);
  65912. var pointerOffset = pointerModel.get('offsetCenter');
  65913. var pointerOffsetX = parsePercent$1(pointerOffset[0], posInfo.r);
  65914. var pointerOffsetY = parsePercent$1(pointerOffset[1], posInfo.r);
  65915. var pointerKeepAspect = pointerModel.get('keepAspect');
  65916. var pointer; // not exist icon type will be set 'rect'
  65917. if (pointerStr) {
  65918. pointer = createSymbol(pointerStr, pointerOffsetX - pointerWidth / 2, pointerOffsetY - pointerLength, pointerWidth, pointerLength, null, pointerKeepAspect);
  65919. } else {
  65920. pointer = new PointerPath({
  65921. shape: {
  65922. angle: -Math.PI / 2,
  65923. width: pointerWidth,
  65924. r: pointerLength,
  65925. x: pointerOffsetX,
  65926. y: pointerOffsetY
  65927. }
  65928. });
  65929. }
  65930. pointer.rotation = -(angle + Math.PI / 2);
  65931. pointer.x = posInfo.cx;
  65932. pointer.y = posInfo.cy;
  65933. return pointer;
  65934. }
  65935. function createProgress(idx, endAngle) {
  65936. var roundCap = progressModel.get('roundCap');
  65937. var ProgressPath = roundCap ? SausagePath : Sector;
  65938. var isOverlap = progressModel.get('overlap');
  65939. var progressWidth = isOverlap ? progressModel.get('width') : axisLineWidth / data.count();
  65940. var r0 = isOverlap ? posInfo.r - progressWidth : posInfo.r - (idx + 1) * progressWidth;
  65941. var r = isOverlap ? posInfo.r : posInfo.r - idx * progressWidth;
  65942. var progress = new ProgressPath({
  65943. shape: {
  65944. startAngle: startAngle,
  65945. endAngle: endAngle,
  65946. cx: posInfo.cx,
  65947. cy: posInfo.cy,
  65948. clockwise: clockwise,
  65949. r0: r0,
  65950. r: r
  65951. }
  65952. });
  65953. isOverlap && (progress.z2 = maxVal - data.get(valueDim, idx) % maxVal);
  65954. return progress;
  65955. }
  65956. if (showProgress || showPointer) {
  65957. data.diff(oldData).add(function (idx) {
  65958. if (showPointer) {
  65959. var pointer = createPointer(idx, startAngle);
  65960. initProps(pointer, {
  65961. rotation: -(linearMap(data.get(valueDim, idx), valueExtent, angleExtent, true) + Math.PI / 2)
  65962. }, seriesModel);
  65963. group.add(pointer);
  65964. data.setItemGraphicEl(idx, pointer);
  65965. }
  65966. if (showProgress) {
  65967. var progress = createProgress(idx, startAngle);
  65968. var isClip = progressModel.get('clip');
  65969. initProps(progress, {
  65970. shape: {
  65971. endAngle: linearMap(data.get(valueDim, idx), valueExtent, angleExtent, isClip)
  65972. }
  65973. }, seriesModel);
  65974. group.add(progress);
  65975. progressList[idx] = progress;
  65976. }
  65977. }).update(function (newIdx, oldIdx) {
  65978. if (showPointer) {
  65979. var previousPointer = oldData.getItemGraphicEl(oldIdx);
  65980. var previousRotate = previousPointer ? previousPointer.rotation : startAngle;
  65981. var pointer = createPointer(newIdx, previousRotate);
  65982. pointer.rotation = previousRotate;
  65983. updateProps(pointer, {
  65984. rotation: -(linearMap(data.get(valueDim, newIdx), valueExtent, angleExtent, true) + Math.PI / 2)
  65985. }, seriesModel);
  65986. group.add(pointer);
  65987. data.setItemGraphicEl(newIdx, pointer);
  65988. }
  65989. if (showProgress) {
  65990. var previousProgress = oldProgressData[oldIdx];
  65991. var previousEndAngle = previousProgress ? previousProgress.shape.endAngle : startAngle;
  65992. var progress = createProgress(newIdx, previousEndAngle);
  65993. var isClip = progressModel.get('clip');
  65994. updateProps(progress, {
  65995. shape: {
  65996. endAngle: linearMap(data.get(valueDim, newIdx), valueExtent, angleExtent, isClip)
  65997. }
  65998. }, seriesModel);
  65999. group.add(progress);
  66000. progressList[newIdx] = progress;
  66001. }
  66002. }).execute();
  66003. data.each(function (idx) {
  66004. var itemModel = data.getItemModel(idx);
  66005. var emphasisModel = itemModel.getModel('emphasis');
  66006. if (showPointer) {
  66007. var pointer = data.getItemGraphicEl(idx);
  66008. var symbolStyle = data.getItemVisual(idx, 'style');
  66009. var visualColor = symbolStyle.fill;
  66010. if (pointer instanceof ZRImage) {
  66011. var pathStyle = pointer.style;
  66012. pointer.useStyle(extend({
  66013. image: pathStyle.image,
  66014. x: pathStyle.x,
  66015. y: pathStyle.y,
  66016. width: pathStyle.width,
  66017. height: pathStyle.height
  66018. }, symbolStyle));
  66019. } else {
  66020. pointer.useStyle(symbolStyle);
  66021. pointer.type !== 'pointer' && pointer.setColor(visualColor);
  66022. }
  66023. pointer.setStyle(itemModel.getModel(['pointer', 'itemStyle']).getItemStyle());
  66024. if (pointer.style.fill === 'auto') {
  66025. pointer.setStyle('fill', getColor(linearMap(data.get(valueDim, idx), valueExtent, [0, 1], true)));
  66026. }
  66027. pointer.z2EmphasisLift = 0;
  66028. setStatesStylesFromModel(pointer, itemModel);
  66029. enableHoverEmphasis(pointer, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  66030. }
  66031. if (showProgress) {
  66032. var progress = progressList[idx];
  66033. progress.useStyle(data.getItemVisual(idx, 'style'));
  66034. progress.setStyle(itemModel.getModel(['progress', 'itemStyle']).getItemStyle());
  66035. progress.z2EmphasisLift = 0;
  66036. setStatesStylesFromModel(progress, itemModel);
  66037. enableHoverEmphasis(progress, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  66038. }
  66039. });
  66040. this._progressEls = progressList;
  66041. }
  66042. };
  66043. GaugeView.prototype._renderAnchor = function (seriesModel, posInfo) {
  66044. var anchorModel = seriesModel.getModel('anchor');
  66045. var showAnchor = anchorModel.get('show');
  66046. if (showAnchor) {
  66047. var anchorSize = anchorModel.get('size');
  66048. var anchorType = anchorModel.get('icon');
  66049. var offsetCenter = anchorModel.get('offsetCenter');
  66050. var anchorKeepAspect = anchorModel.get('keepAspect');
  66051. var anchor = createSymbol(anchorType, posInfo.cx - anchorSize / 2 + parsePercent$1(offsetCenter[0], posInfo.r), posInfo.cy - anchorSize / 2 + parsePercent$1(offsetCenter[1], posInfo.r), anchorSize, anchorSize, null, anchorKeepAspect);
  66052. anchor.z2 = anchorModel.get('showAbove') ? 1 : 0;
  66053. anchor.setStyle(anchorModel.getModel('itemStyle').getItemStyle());
  66054. this.group.add(anchor);
  66055. }
  66056. };
  66057. GaugeView.prototype._renderTitleAndDetail = function (seriesModel, ecModel, api, getColor, posInfo) {
  66058. var _this = this;
  66059. var data = seriesModel.getData();
  66060. var valueDim = data.mapDimension('value');
  66061. var minVal = +seriesModel.get('min');
  66062. var maxVal = +seriesModel.get('max');
  66063. var contentGroup = new Group();
  66064. var newTitleEls = [];
  66065. var newDetailEls = [];
  66066. var hasAnimation = seriesModel.isAnimationEnabled();
  66067. data.diff(this._data).add(function (idx) {
  66068. newTitleEls[idx] = new ZRText({
  66069. silent: true
  66070. });
  66071. newDetailEls[idx] = new ZRText({
  66072. silent: true
  66073. });
  66074. }).update(function (idx, oldIdx) {
  66075. newTitleEls[idx] = _this._titleEls[oldIdx];
  66076. newDetailEls[idx] = _this._detailEls[oldIdx];
  66077. }).execute();
  66078. data.each(function (idx) {
  66079. var itemModel = data.getItemModel(idx);
  66080. var value = data.get(valueDim, idx);
  66081. var itemGroup = new Group();
  66082. var autoColor = getColor(linearMap(value, [minVal, maxVal], [0, 1], true));
  66083. var itemTitleModel = itemModel.getModel('title');
  66084. if (itemTitleModel.get('show')) {
  66085. var titleOffsetCenter = itemTitleModel.get('offsetCenter');
  66086. var titleX = posInfo.cx + parsePercent$1(titleOffsetCenter[0], posInfo.r);
  66087. var titleY = posInfo.cy + parsePercent$1(titleOffsetCenter[1], posInfo.r);
  66088. var labelEl = newTitleEls[idx];
  66089. labelEl.attr({
  66090. style: createTextStyle(itemTitleModel, {
  66091. x: titleX,
  66092. y: titleY,
  66093. text: data.getName(idx),
  66094. align: 'center',
  66095. verticalAlign: 'middle'
  66096. }, {
  66097. inheritColor: autoColor
  66098. })
  66099. });
  66100. itemGroup.add(labelEl);
  66101. }
  66102. var itemDetailModel = itemModel.getModel('detail');
  66103. if (itemDetailModel.get('show')) {
  66104. var detailOffsetCenter = itemDetailModel.get('offsetCenter');
  66105. var detailX = posInfo.cx + parsePercent$1(detailOffsetCenter[0], posInfo.r);
  66106. var detailY = posInfo.cy + parsePercent$1(detailOffsetCenter[1], posInfo.r);
  66107. var width = parsePercent$1(itemDetailModel.get('width'), posInfo.r);
  66108. var height = parsePercent$1(itemDetailModel.get('height'), posInfo.r);
  66109. var detailColor = seriesModel.get(['progress', 'show']) ? data.getItemVisual(idx, 'style').fill : autoColor;
  66110. var labelEl = newDetailEls[idx];
  66111. var formatter_1 = itemDetailModel.get('formatter');
  66112. labelEl.attr({
  66113. style: createTextStyle(itemDetailModel, {
  66114. x: detailX,
  66115. y: detailY,
  66116. text: formatLabel(value, formatter_1),
  66117. width: isNaN(width) ? null : width,
  66118. height: isNaN(height) ? null : height,
  66119. align: 'center',
  66120. verticalAlign: 'middle'
  66121. }, {
  66122. inheritColor: detailColor
  66123. })
  66124. });
  66125. setLabelValueAnimation(labelEl, {
  66126. normal: itemDetailModel
  66127. }, value, function (value) {
  66128. return formatLabel(value, formatter_1);
  66129. });
  66130. hasAnimation && animateLabelValue(labelEl, idx, data, seriesModel, {
  66131. getFormattedLabel: function (labelDataIndex, status, dataType, labelDimIndex, fmt, extendParams) {
  66132. return formatLabel(extendParams ? extendParams.interpolatedValue : value, formatter_1);
  66133. }
  66134. });
  66135. itemGroup.add(labelEl);
  66136. }
  66137. contentGroup.add(itemGroup);
  66138. });
  66139. this.group.add(contentGroup);
  66140. this._titleEls = newTitleEls;
  66141. this._detailEls = newDetailEls;
  66142. };
  66143. GaugeView.type = 'gauge';
  66144. return GaugeView;
  66145. }(ChartView);
  66146. /*
  66147. * Licensed to the Apache Software Foundation (ASF) under one
  66148. * or more contributor license agreements. See the NOTICE file
  66149. * distributed with this work for additional information
  66150. * regarding copyright ownership. The ASF licenses this file
  66151. * to you under the Apache License, Version 2.0 (the
  66152. * "License"); you may not use this file except in compliance
  66153. * with the License. You may obtain a copy of the License at
  66154. *
  66155. * http://www.apache.org/licenses/LICENSE-2.0
  66156. *
  66157. * Unless required by applicable law or agreed to in writing,
  66158. * software distributed under the License is distributed on an
  66159. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66160. * KIND, either express or implied. See the License for the
  66161. * specific language governing permissions and limitations
  66162. * under the License.
  66163. */
  66164. /**
  66165. * AUTO-GENERATED FILE. DO NOT MODIFY.
  66166. */
  66167. /*
  66168. * Licensed to the Apache Software Foundation (ASF) under one
  66169. * or more contributor license agreements. See the NOTICE file
  66170. * distributed with this work for additional information
  66171. * regarding copyright ownership. The ASF licenses this file
  66172. * to you under the Apache License, Version 2.0 (the
  66173. * "License"); you may not use this file except in compliance
  66174. * with the License. You may obtain a copy of the License at
  66175. *
  66176. * http://www.apache.org/licenses/LICENSE-2.0
  66177. *
  66178. * Unless required by applicable law or agreed to in writing,
  66179. * software distributed under the License is distributed on an
  66180. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66181. * KIND, either express or implied. See the License for the
  66182. * specific language governing permissions and limitations
  66183. * under the License.
  66184. */
  66185. var GaugeSeriesModel =
  66186. /** @class */
  66187. function (_super) {
  66188. __extends(GaugeSeriesModel, _super);
  66189. function GaugeSeriesModel() {
  66190. var _this = _super !== null && _super.apply(this, arguments) || this;
  66191. _this.type = GaugeSeriesModel.type;
  66192. _this.visualStyleAccessPath = 'itemStyle';
  66193. _this.useColorPaletteOnData = true;
  66194. return _this;
  66195. }
  66196. GaugeSeriesModel.prototype.getInitialData = function (option, ecModel) {
  66197. return createListSimply(this, ['value']);
  66198. };
  66199. GaugeSeriesModel.type = 'series.gauge';
  66200. GaugeSeriesModel.defaultOption = {
  66201. zlevel: 0,
  66202. z: 2,
  66203. // 默认全局居中
  66204. center: ['50%', '50%'],
  66205. legendHoverLink: true,
  66206. radius: '75%',
  66207. startAngle: 225,
  66208. endAngle: -45,
  66209. clockwise: true,
  66210. // 最小值
  66211. min: 0,
  66212. // 最大值
  66213. max: 100,
  66214. // 分割段数,默认为10
  66215. splitNumber: 10,
  66216. // 坐标轴线
  66217. axisLine: {
  66218. // 默认显示,属性show控制显示与否
  66219. show: true,
  66220. roundCap: false,
  66221. lineStyle: {
  66222. color: [[1, '#E6EBF8']],
  66223. width: 10
  66224. }
  66225. },
  66226. // 坐标轴线
  66227. progress: {
  66228. // 默认显示,属性show控制显示与否
  66229. show: false,
  66230. overlap: true,
  66231. width: 10,
  66232. roundCap: false,
  66233. clip: true
  66234. },
  66235. // 分隔线
  66236. splitLine: {
  66237. // 默认显示,属性show控制显示与否
  66238. show: true,
  66239. // 属性length控制线长
  66240. length: 10,
  66241. distance: 10,
  66242. // 属性lineStyle(详见lineStyle)控制线条样式
  66243. lineStyle: {
  66244. color: '#63677A',
  66245. width: 3,
  66246. type: 'solid'
  66247. }
  66248. },
  66249. // 坐标轴小标记
  66250. axisTick: {
  66251. // 属性show控制显示与否,默认不显示
  66252. show: true,
  66253. // 每份split细分多少段
  66254. splitNumber: 5,
  66255. // 属性length控制线长
  66256. length: 6,
  66257. distance: 10,
  66258. // 属性lineStyle控制线条样式
  66259. lineStyle: {
  66260. color: '#63677A',
  66261. width: 1,
  66262. type: 'solid'
  66263. }
  66264. },
  66265. axisLabel: {
  66266. show: true,
  66267. distance: 15,
  66268. // formatter: null,
  66269. color: '#464646',
  66270. fontSize: 12
  66271. },
  66272. pointer: {
  66273. icon: null,
  66274. offsetCenter: [0, 0],
  66275. show: true,
  66276. length: '60%',
  66277. width: 6,
  66278. keepAspect: false
  66279. },
  66280. anchor: {
  66281. show: false,
  66282. showAbove: false,
  66283. size: 6,
  66284. icon: 'circle',
  66285. offsetCenter: [0, 0],
  66286. keepAspect: false,
  66287. itemStyle: {
  66288. color: '#fff',
  66289. borderWidth: 0,
  66290. borderColor: '#5470c6'
  66291. }
  66292. },
  66293. title: {
  66294. show: true,
  66295. // x, y,单位px
  66296. offsetCenter: [0, '20%'],
  66297. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  66298. color: '#464646',
  66299. fontSize: 16,
  66300. valueAnimation: false
  66301. },
  66302. detail: {
  66303. show: true,
  66304. backgroundColor: 'rgba(0,0,0,0)',
  66305. borderWidth: 0,
  66306. borderColor: '#ccc',
  66307. width: 100,
  66308. height: null,
  66309. padding: [5, 10],
  66310. // x, y,单位px
  66311. offsetCenter: [0, '40%'],
  66312. // formatter: null,
  66313. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  66314. color: '#464646',
  66315. fontSize: 30,
  66316. fontWeight: 'bold',
  66317. lineHeight: 30,
  66318. valueAnimation: false
  66319. }
  66320. };
  66321. return GaugeSeriesModel;
  66322. }(SeriesModel);
  66323. /*
  66324. * Licensed to the Apache Software Foundation (ASF) under one
  66325. * or more contributor license agreements. See the NOTICE file
  66326. * distributed with this work for additional information
  66327. * regarding copyright ownership. The ASF licenses this file
  66328. * to you under the Apache License, Version 2.0 (the
  66329. * "License"); you may not use this file except in compliance
  66330. * with the License. You may obtain a copy of the License at
  66331. *
  66332. * http://www.apache.org/licenses/LICENSE-2.0
  66333. *
  66334. * Unless required by applicable law or agreed to in writing,
  66335. * software distributed under the License is distributed on an
  66336. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66337. * KIND, either express or implied. See the License for the
  66338. * specific language governing permissions and limitations
  66339. * under the License.
  66340. */
  66341. /**
  66342. * AUTO-GENERATED FILE. DO NOT MODIFY.
  66343. */
  66344. /*
  66345. * Licensed to the Apache Software Foundation (ASF) under one
  66346. * or more contributor license agreements. See the NOTICE file
  66347. * distributed with this work for additional information
  66348. * regarding copyright ownership. The ASF licenses this file
  66349. * to you under the Apache License, Version 2.0 (the
  66350. * "License"); you may not use this file except in compliance
  66351. * with the License. You may obtain a copy of the License at
  66352. *
  66353. * http://www.apache.org/licenses/LICENSE-2.0
  66354. *
  66355. * Unless required by applicable law or agreed to in writing,
  66356. * software distributed under the License is distributed on an
  66357. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66358. * KIND, either express or implied. See the License for the
  66359. * specific language governing permissions and limitations
  66360. * under the License.
  66361. */
  66362. function install$22(registers) {
  66363. registers.registerChartView(GaugeView);
  66364. registers.registerSeriesModel(GaugeSeriesModel);
  66365. }
  66366. /*
  66367. * Licensed to the Apache Software Foundation (ASF) under one
  66368. * or more contributor license agreements. See the NOTICE file
  66369. * distributed with this work for additional information
  66370. * regarding copyright ownership. The ASF licenses this file
  66371. * to you under the Apache License, Version 2.0 (the
  66372. * "License"); you may not use this file except in compliance
  66373. * with the License. You may obtain a copy of the License at
  66374. *
  66375. * http://www.apache.org/licenses/LICENSE-2.0
  66376. *
  66377. * Unless required by applicable law or agreed to in writing,
  66378. * software distributed under the License is distributed on an
  66379. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66380. * KIND, either express or implied. See the License for the
  66381. * specific language governing permissions and limitations
  66382. * under the License.
  66383. */
  66384. /**
  66385. * AUTO-GENERATED FILE. DO NOT MODIFY.
  66386. */
  66387. /*
  66388. * Licensed to the Apache Software Foundation (ASF) under one
  66389. * or more contributor license agreements. See the NOTICE file
  66390. * distributed with this work for additional information
  66391. * regarding copyright ownership. The ASF licenses this file
  66392. * to you under the Apache License, Version 2.0 (the
  66393. * "License"); you may not use this file except in compliance
  66394. * with the License. You may obtain a copy of the License at
  66395. *
  66396. * http://www.apache.org/licenses/LICENSE-2.0
  66397. *
  66398. * Unless required by applicable law or agreed to in writing,
  66399. * software distributed under the License is distributed on an
  66400. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66401. * KIND, either express or implied. See the License for the
  66402. * specific language governing permissions and limitations
  66403. * under the License.
  66404. */
  66405. use(install$22);
  66406. /*
  66407. * Licensed to the Apache Software Foundation (ASF) under one
  66408. * or more contributor license agreements. See the NOTICE file
  66409. * distributed with this work for additional information
  66410. * regarding copyright ownership. The ASF licenses this file
  66411. * to you under the Apache License, Version 2.0 (the
  66412. * "License"); you may not use this file except in compliance
  66413. * with the License. You may obtain a copy of the License at
  66414. *
  66415. * http://www.apache.org/licenses/LICENSE-2.0
  66416. *
  66417. * Unless required by applicable law or agreed to in writing,
  66418. * software distributed under the License is distributed on an
  66419. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66420. * KIND, either express or implied. See the License for the
  66421. * specific language governing permissions and limitations
  66422. * under the License.
  66423. */
  66424. /**
  66425. * AUTO-GENERATED FILE. DO NOT MODIFY.
  66426. */
  66427. /*
  66428. * Licensed to the Apache Software Foundation (ASF) under one
  66429. * or more contributor license agreements. See the NOTICE file
  66430. * distributed with this work for additional information
  66431. * regarding copyright ownership. The ASF licenses this file
  66432. * to you under the Apache License, Version 2.0 (the
  66433. * "License"); you may not use this file except in compliance
  66434. * with the License. You may obtain a copy of the License at
  66435. *
  66436. * http://www.apache.org/licenses/LICENSE-2.0
  66437. *
  66438. * Unless required by applicable law or agreed to in writing,
  66439. * software distributed under the License is distributed on an
  66440. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66441. * KIND, either express or implied. See the License for the
  66442. * specific language governing permissions and limitations
  66443. * under the License.
  66444. */
  66445. var opacityAccessPath$1 = ['itemStyle', 'opacity'];
  66446. /**
  66447. * Piece of pie including Sector, Label, LabelLine
  66448. */
  66449. var FunnelPiece =
  66450. /** @class */
  66451. function (_super) {
  66452. __extends(FunnelPiece, _super);
  66453. function FunnelPiece(data, idx) {
  66454. var _this = _super.call(this) || this;
  66455. var polygon = _this;
  66456. var labelLine = new Polyline();
  66457. var text = new ZRText();
  66458. polygon.setTextContent(text);
  66459. _this.setTextGuideLine(labelLine);
  66460. _this.updateData(data, idx, true);
  66461. return _this;
  66462. }
  66463. FunnelPiece.prototype.updateData = function (data, idx, firstCreate) {
  66464. var polygon = this;
  66465. var seriesModel = data.hostModel;
  66466. var itemModel = data.getItemModel(idx);
  66467. var layout = data.getItemLayout(idx);
  66468. var emphasisModel = itemModel.getModel('emphasis');
  66469. var opacity = itemModel.get(opacityAccessPath$1);
  66470. opacity = opacity == null ? 1 : opacity; // Update common style
  66471. polygon.useStyle(data.getItemVisual(idx, 'style'));
  66472. polygon.style.lineJoin = 'round';
  66473. if (firstCreate) {
  66474. polygon.setShape({
  66475. points: layout.points
  66476. });
  66477. polygon.style.opacity = 0;
  66478. initProps(polygon, {
  66479. style: {
  66480. opacity: opacity
  66481. }
  66482. }, seriesModel, idx);
  66483. } else {
  66484. updateProps(polygon, {
  66485. style: {
  66486. opacity: opacity
  66487. },
  66488. shape: {
  66489. points: layout.points
  66490. }
  66491. }, seriesModel, idx);
  66492. }
  66493. setStatesStylesFromModel(polygon, itemModel);
  66494. this._updateLabel(data, idx);
  66495. enableHoverEmphasis(this, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  66496. };
  66497. FunnelPiece.prototype._updateLabel = function (data, idx) {
  66498. var polygon = this;
  66499. var labelLine = this.getTextGuideLine();
  66500. var labelText = polygon.getTextContent();
  66501. var seriesModel = data.hostModel;
  66502. var itemModel = data.getItemModel(idx);
  66503. var layout = data.getItemLayout(idx);
  66504. var labelLayout = layout.label;
  66505. var style = data.getItemVisual(idx, 'style');
  66506. var visualColor = style.fill;
  66507. setLabelStyle( // position will not be used in setLabelStyle
  66508. labelText, getLabelStatesModels(itemModel), {
  66509. labelFetcher: data.hostModel,
  66510. labelDataIndex: idx,
  66511. defaultOpacity: style.opacity,
  66512. defaultText: data.getName(idx)
  66513. }, {
  66514. normal: {
  66515. align: labelLayout.textAlign,
  66516. verticalAlign: labelLayout.verticalAlign
  66517. }
  66518. });
  66519. polygon.setTextConfig({
  66520. local: true,
  66521. inside: !!labelLayout.inside,
  66522. insideStroke: visualColor,
  66523. // insideFill: 'auto',
  66524. outsideFill: visualColor
  66525. });
  66526. var linePoints = labelLayout.linePoints;
  66527. labelLine.setShape({
  66528. points: linePoints
  66529. });
  66530. polygon.textGuideLineConfig = {
  66531. anchor: linePoints ? new Point(linePoints[0][0], linePoints[0][1]) : null
  66532. }; // Make sure update style on labelText after setLabelStyle.
  66533. // Because setLabelStyle will replace a new style on it.
  66534. updateProps(labelText, {
  66535. style: {
  66536. x: labelLayout.x,
  66537. y: labelLayout.y
  66538. }
  66539. }, seriesModel, idx);
  66540. labelText.attr({
  66541. rotation: labelLayout.rotation,
  66542. originX: labelLayout.x,
  66543. originY: labelLayout.y,
  66544. z2: 10
  66545. });
  66546. setLabelLineStyle(polygon, getLabelLineStatesModels(itemModel), {
  66547. // Default use item visual color
  66548. stroke: visualColor
  66549. });
  66550. };
  66551. return FunnelPiece;
  66552. }(Polygon);
  66553. var FunnelView =
  66554. /** @class */
  66555. function (_super) {
  66556. __extends(FunnelView, _super);
  66557. function FunnelView() {
  66558. var _this = _super !== null && _super.apply(this, arguments) || this;
  66559. _this.type = FunnelView.type;
  66560. _this.ignoreLabelLineUpdate = true;
  66561. return _this;
  66562. }
  66563. FunnelView.prototype.render = function (seriesModel, ecModel, api) {
  66564. var data = seriesModel.getData();
  66565. var oldData = this._data;
  66566. var group = this.group;
  66567. data.diff(oldData).add(function (idx) {
  66568. var funnelPiece = new FunnelPiece(data, idx);
  66569. data.setItemGraphicEl(idx, funnelPiece);
  66570. group.add(funnelPiece);
  66571. }).update(function (newIdx, oldIdx) {
  66572. var piece = oldData.getItemGraphicEl(oldIdx);
  66573. piece.updateData(data, newIdx);
  66574. group.add(piece);
  66575. data.setItemGraphicEl(newIdx, piece);
  66576. }).remove(function (idx) {
  66577. var piece = oldData.getItemGraphicEl(idx);
  66578. removeElementWithFadeOut(piece, seriesModel, idx);
  66579. }).execute();
  66580. this._data = data;
  66581. };
  66582. FunnelView.prototype.remove = function () {
  66583. this.group.removeAll();
  66584. this._data = null;
  66585. };
  66586. FunnelView.prototype.dispose = function () {};
  66587. FunnelView.type = 'funnel';
  66588. return FunnelView;
  66589. }(ChartView);
  66590. /*
  66591. * Licensed to the Apache Software Foundation (ASF) under one
  66592. * or more contributor license agreements. See the NOTICE file
  66593. * distributed with this work for additional information
  66594. * regarding copyright ownership. The ASF licenses this file
  66595. * to you under the Apache License, Version 2.0 (the
  66596. * "License"); you may not use this file except in compliance
  66597. * with the License. You may obtain a copy of the License at
  66598. *
  66599. * http://www.apache.org/licenses/LICENSE-2.0
  66600. *
  66601. * Unless required by applicable law or agreed to in writing,
  66602. * software distributed under the License is distributed on an
  66603. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66604. * KIND, either express or implied. See the License for the
  66605. * specific language governing permissions and limitations
  66606. * under the License.
  66607. */
  66608. /**
  66609. * AUTO-GENERATED FILE. DO NOT MODIFY.
  66610. */
  66611. /*
  66612. * Licensed to the Apache Software Foundation (ASF) under one
  66613. * or more contributor license agreements. See the NOTICE file
  66614. * distributed with this work for additional information
  66615. * regarding copyright ownership. The ASF licenses this file
  66616. * to you under the Apache License, Version 2.0 (the
  66617. * "License"); you may not use this file except in compliance
  66618. * with the License. You may obtain a copy of the License at
  66619. *
  66620. * http://www.apache.org/licenses/LICENSE-2.0
  66621. *
  66622. * Unless required by applicable law or agreed to in writing,
  66623. * software distributed under the License is distributed on an
  66624. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66625. * KIND, either express or implied. See the License for the
  66626. * specific language governing permissions and limitations
  66627. * under the License.
  66628. */
  66629. var FunnelSeriesModel =
  66630. /** @class */
  66631. function (_super) {
  66632. __extends(FunnelSeriesModel, _super);
  66633. function FunnelSeriesModel() {
  66634. var _this = _super !== null && _super.apply(this, arguments) || this;
  66635. _this.type = FunnelSeriesModel.type;
  66636. _this.useColorPaletteOnData = true;
  66637. return _this;
  66638. }
  66639. FunnelSeriesModel.prototype.init = function (option) {
  66640. _super.prototype.init.apply(this, arguments); // Enable legend selection for each data item
  66641. // Use a function instead of direct access because data reference may changed
  66642. this.legendVisualProvider = new LegendVisualProvider(bind(this.getData, this), bind(this.getRawData, this)); // Extend labelLine emphasis
  66643. this._defaultLabelLine(option);
  66644. };
  66645. FunnelSeriesModel.prototype.getInitialData = function (option, ecModel) {
  66646. return createListSimply(this, {
  66647. coordDimensions: ['value'],
  66648. encodeDefaulter: curry(makeSeriesEncodeForNameBased, this)
  66649. });
  66650. };
  66651. FunnelSeriesModel.prototype._defaultLabelLine = function (option) {
  66652. // Extend labelLine emphasis
  66653. defaultEmphasis(option, 'labelLine', ['show']);
  66654. var labelLineNormalOpt = option.labelLine;
  66655. var labelLineEmphasisOpt = option.emphasis.labelLine; // Not show label line if `label.normal.show = false`
  66656. labelLineNormalOpt.show = labelLineNormalOpt.show && option.label.show;
  66657. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show && option.emphasis.label.show;
  66658. }; // Overwrite
  66659. FunnelSeriesModel.prototype.getDataParams = function (dataIndex) {
  66660. var data = this.getData();
  66661. var params = _super.prototype.getDataParams.call(this, dataIndex);
  66662. var valueDim = data.mapDimension('value');
  66663. var sum = data.getSum(valueDim); // Percent is 0 if sum is 0
  66664. params.percent = !sum ? 0 : +(data.get(valueDim, dataIndex) / sum * 100).toFixed(2);
  66665. params.$vars.push('percent');
  66666. return params;
  66667. };
  66668. FunnelSeriesModel.type = 'series.funnel';
  66669. FunnelSeriesModel.defaultOption = {
  66670. zlevel: 0,
  66671. z: 2,
  66672. legendHoverLink: true,
  66673. left: 80,
  66674. top: 60,
  66675. right: 80,
  66676. bottom: 60,
  66677. // width: {totalWidth} - left - right,
  66678. // height: {totalHeight} - top - bottom,
  66679. // 默认取数据最小最大值
  66680. // min: 0,
  66681. // max: 100,
  66682. minSize: '0%',
  66683. maxSize: '100%',
  66684. sort: 'descending',
  66685. orient: 'vertical',
  66686. gap: 0,
  66687. funnelAlign: 'center',
  66688. label: {
  66689. show: true,
  66690. position: 'outer' // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  66691. },
  66692. labelLine: {
  66693. show: true,
  66694. length: 20,
  66695. lineStyle: {
  66696. // color: 各异,
  66697. width: 1
  66698. }
  66699. },
  66700. itemStyle: {
  66701. // color: 各异,
  66702. borderColor: '#fff',
  66703. borderWidth: 1
  66704. },
  66705. emphasis: {
  66706. label: {
  66707. show: true
  66708. }
  66709. },
  66710. select: {
  66711. itemStyle: {
  66712. borderColor: '#212121'
  66713. }
  66714. }
  66715. };
  66716. return FunnelSeriesModel;
  66717. }(SeriesModel);
  66718. /*
  66719. * Licensed to the Apache Software Foundation (ASF) under one
  66720. * or more contributor license agreements. See the NOTICE file
  66721. * distributed with this work for additional information
  66722. * regarding copyright ownership. The ASF licenses this file
  66723. * to you under the Apache License, Version 2.0 (the
  66724. * "License"); you may not use this file except in compliance
  66725. * with the License. You may obtain a copy of the License at
  66726. *
  66727. * http://www.apache.org/licenses/LICENSE-2.0
  66728. *
  66729. * Unless required by applicable law or agreed to in writing,
  66730. * software distributed under the License is distributed on an
  66731. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66732. * KIND, either express or implied. See the License for the
  66733. * specific language governing permissions and limitations
  66734. * under the License.
  66735. */
  66736. /**
  66737. * AUTO-GENERATED FILE. DO NOT MODIFY.
  66738. */
  66739. /*
  66740. * Licensed to the Apache Software Foundation (ASF) under one
  66741. * or more contributor license agreements. See the NOTICE file
  66742. * distributed with this work for additional information
  66743. * regarding copyright ownership. The ASF licenses this file
  66744. * to you under the Apache License, Version 2.0 (the
  66745. * "License"); you may not use this file except in compliance
  66746. * with the License. You may obtain a copy of the License at
  66747. *
  66748. * http://www.apache.org/licenses/LICENSE-2.0
  66749. *
  66750. * Unless required by applicable law or agreed to in writing,
  66751. * software distributed under the License is distributed on an
  66752. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  66753. * KIND, either express or implied. See the License for the
  66754. * specific language governing permissions and limitations
  66755. * under the License.
  66756. */
  66757. function getViewRect$3(seriesModel, api) {
  66758. return getLayoutRect(seriesModel.getBoxLayoutParams(), {
  66759. width: api.getWidth(),
  66760. height: api.getHeight()
  66761. });
  66762. }
  66763. function getSortedIndices(data, sort) {
  66764. var valueDim = data.mapDimension('value');
  66765. var valueArr = data.mapArray(valueDim, function (val) {
  66766. return val;
  66767. });
  66768. var indices = [];
  66769. var isAscending = sort === 'ascending';
  66770. for (var i = 0, len = data.count(); i < len; i++) {
  66771. indices[i] = i;
  66772. } // Add custom sortable function & none sortable opetion by "options.sort"
  66773. if (typeof sort === 'function') {
  66774. indices.sort(sort);
  66775. } else if (sort !== 'none') {
  66776. indices.sort(function (a, b) {
  66777. return isAscending ? valueArr[a] - valueArr[b] : valueArr[b] - valueArr[a];
  66778. });
  66779. }
  66780. return indices;
  66781. }
  66782. function labelLayout(data) {
  66783. var seriesModel = data.hostModel;
  66784. var orient = seriesModel.get('orient');
  66785. data.each(function (idx) {
  66786. var itemModel = data.getItemModel(idx);
  66787. var labelModel = itemModel.getModel('label');
  66788. var labelPosition = labelModel.get('position');
  66789. var labelLineModel = itemModel.getModel('labelLine');
  66790. var layout = data.getItemLayout(idx);
  66791. var points = layout.points;
  66792. var isLabelInside = labelPosition === 'inner' || labelPosition === 'inside' || labelPosition === 'center' || labelPosition === 'insideLeft' || labelPosition === 'insideRight';
  66793. var textAlign;
  66794. var textX;
  66795. var textY;
  66796. var linePoints;
  66797. if (isLabelInside) {
  66798. if (labelPosition === 'insideLeft') {
  66799. textX = (points[0][0] + points[3][0]) / 2 + 5;
  66800. textY = (points[0][1] + points[3][1]) / 2;
  66801. textAlign = 'left';
  66802. } else if (labelPosition === 'insideRight') {
  66803. textX = (points[1][0] + points[2][0]) / 2 - 5;
  66804. textY = (points[1][1] + points[2][1]) / 2;
  66805. textAlign = 'right';
  66806. } else {
  66807. textX = (points[0][0] + points[1][0] + points[2][0] + points[3][0]) / 4;
  66808. textY = (points[0][1] + points[1][1] + points[2][1] + points[3][1]) / 4;
  66809. textAlign = 'center';
  66810. }
  66811. linePoints = [[textX, textY], [textX, textY]];
  66812. } else {
  66813. var x1 = void 0;
  66814. var y1 = void 0;
  66815. var x2 = void 0;
  66816. var y2 = void 0;
  66817. var labelLineLen = labelLineModel.get('length');
  66818. {
  66819. if (orient === 'vertical' && ['top', 'bottom'].indexOf(labelPosition) > -1) {
  66820. labelPosition = 'left';
  66821. console.warn('Position error: Funnel chart on vertical orient dose not support top and bottom.');
  66822. }
  66823. if (orient === 'horizontal' && ['left', 'right'].indexOf(labelPosition) > -1) {
  66824. labelPosition = 'bottom';
  66825. console.warn('Position error: Funnel chart on horizontal orient dose not support left and right.');
  66826. }
  66827. }
  66828. if (labelPosition === 'left') {
  66829. // Left side
  66830. x1 = (points[3][0] + points[0][0]) / 2;
  66831. y1 = (points[3][1] + points[0][1]) / 2;
  66832. x2 = x1 - labelLineLen;
  66833. textX = x2 - 5;
  66834. textAlign = 'right';
  66835. } else if (labelPosition === 'right') {
  66836. // Right side
  66837. x1 = (points[1][0] + points[2][0]) / 2;
  66838. y1 = (points[1][1] + points[2][1]) / 2;
  66839. x2 = x1 + labelLineLen;
  66840. textX = x2 + 5;
  66841. textAlign = 'left';
  66842. } else if (labelPosition === 'top') {
  66843. // Top side
  66844. x1 = (points[3][0] + points[0][0]) / 2;
  66845. y1 = (points[3][1] + points[0][1]) / 2;
  66846. y2 = y1 - labelLineLen;
  66847. textY = y2 - 5;
  66848. textAlign = 'center';
  66849. } else if (labelPosition === 'bottom') {
  66850. // Bottom side
  66851. x1 = (points[1][0] + points[2][0]) / 2;
  66852. y1 = (points[1][1] + points[2][1]) / 2;
  66853. y2 = y1 + labelLineLen;
  66854. textY = y2 + 5;
  66855. textAlign = 'center';
  66856. } else if (labelPosition === 'rightTop') {
  66857. // RightTop side
  66858. x1 = orient === 'horizontal' ? points[3][0] : points[1][0];
  66859. y1 = orient === 'horizontal' ? points[3][1] : points[1][1];
  66860. if (orient === 'horizontal') {
  66861. y2 = y1 - labelLineLen;
  66862. textY = y2 - 5;
  66863. textAlign = 'center';
  66864. } else {
  66865. x2 = x1 + labelLineLen;
  66866. textX = x2 + 5;
  66867. textAlign = 'top';
  66868. }
  66869. } else if (labelPosition === 'rightBottom') {
  66870. // RightBottom side
  66871. x1 = points[2][0];
  66872. y1 = points[2][1];
  66873. if (orient === 'horizontal') {
  66874. y2 = y1 + labelLineLen;
  66875. textY = y2 + 5;
  66876. textAlign = 'center';
  66877. } else {
  66878. x2 = x1 + labelLineLen;
  66879. textX = x2 + 5;
  66880. textAlign = 'bottom';
  66881. }
  66882. } else if (labelPosition === 'leftTop') {
  66883. // LeftTop side
  66884. x1 = points[0][0];
  66885. y1 = orient === 'horizontal' ? points[0][1] : points[1][1];
  66886. if (orient === 'horizontal') {
  66887. y2 = y1 - labelLineLen;
  66888. textY = y2 - 5;
  66889. textAlign = 'center';
  66890. } else {
  66891. x2 = x1 - labelLineLen;
  66892. textX = x2 - 5;
  66893. textAlign = 'right';
  66894. }
  66895. } else if (labelPosition === 'leftBottom') {
  66896. // LeftBottom side
  66897. x1 = orient === 'horizontal' ? points[1][0] : points[3][0];
  66898. y1 = orient === 'horizontal' ? points[1][1] : points[2][1];
  66899. if (orient === 'horizontal') {
  66900. y2 = y1 + labelLineLen;
  66901. textY = y2 + 5;
  66902. textAlign = 'center';
  66903. } else {
  66904. x2 = x1 - labelLineLen;
  66905. textX = x2 - 5;
  66906. textAlign = 'right';
  66907. }
  66908. } else {
  66909. // Right side or Bottom side
  66910. x1 = (points[1][0] + points[2][0]) / 2;
  66911. y1 = (points[1][1] + points[2][1]) / 2;
  66912. if (orient === 'horizontal') {
  66913. y2 = y1 + labelLineLen;
  66914. textY = y2 + 5;
  66915. textAlign = 'center';
  66916. } else {
  66917. x2 = x1 + labelLineLen;
  66918. textX = x2 + 5;
  66919. textAlign = 'left';
  66920. }
  66921. }
  66922. if (orient === 'horizontal') {
  66923. x2 = x1;
  66924. textX = x2;
  66925. } else {
  66926. y2 = y1;
  66927. textY = y2;
  66928. }
  66929. linePoints = [[x1, y1], [x2, y2]];
  66930. }
  66931. layout.label = {
  66932. linePoints: linePoints,
  66933. x: textX,
  66934. y: textY,
  66935. verticalAlign: 'middle',
  66936. textAlign: textAlign,
  66937. inside: isLabelInside
  66938. };
  66939. });
  66940. }
  66941. function funnelLayout(ecModel, api) {
  66942. ecModel.eachSeriesByType('funnel', function (seriesModel) {
  66943. var data = seriesModel.getData();
  66944. var valueDim = data.mapDimension('value');
  66945. var sort = seriesModel.get('sort');
  66946. var viewRect = getViewRect$3(seriesModel, api);
  66947. var orient = seriesModel.get('orient');
  66948. var viewWidth = viewRect.width;
  66949. var viewHeight = viewRect.height;
  66950. var indices = getSortedIndices(data, sort);
  66951. var x = viewRect.x;
  66952. var y = viewRect.y;
  66953. var sizeExtent = orient === 'horizontal' ? [parsePercent$1(seriesModel.get('minSize'), viewHeight), parsePercent$1(seriesModel.get('maxSize'), viewHeight)] : [parsePercent$1(seriesModel.get('minSize'), viewWidth), parsePercent$1(seriesModel.get('maxSize'), viewWidth)];
  66954. var dataExtent = data.getDataExtent(valueDim);
  66955. var min = seriesModel.get('min');
  66956. var max = seriesModel.get('max');
  66957. if (min == null) {
  66958. min = Math.min(dataExtent[0], 0);
  66959. }
  66960. if (max == null) {
  66961. max = dataExtent[1];
  66962. }
  66963. var funnelAlign = seriesModel.get('funnelAlign');
  66964. var gap = seriesModel.get('gap');
  66965. var viewSize = orient === 'horizontal' ? viewWidth : viewHeight;
  66966. var itemSize = (viewSize - gap * (data.count() - 1)) / data.count();
  66967. var getLinePoints = function (idx, offset) {
  66968. // End point index is data.count() and we assign it 0
  66969. if (orient === 'horizontal') {
  66970. var val_1 = data.get(valueDim, idx) || 0;
  66971. var itemHeight = linearMap(val_1, [min, max], sizeExtent, true);
  66972. var y0 = void 0;
  66973. switch (funnelAlign) {
  66974. case 'top':
  66975. y0 = y;
  66976. break;
  66977. case 'center':
  66978. y0 = y + (viewHeight - itemHeight) / 2;
  66979. break;
  66980. case 'bottom':
  66981. y0 = y + (viewHeight - itemHeight);
  66982. break;
  66983. }
  66984. return [[offset, y0], [offset, y0 + itemHeight]];
  66985. }
  66986. var val = data.get(valueDim, idx) || 0;
  66987. var itemWidth = linearMap(val, [min, max], sizeExtent, true);
  66988. var x0;
  66989. switch (funnelAlign) {
  66990. case 'left':
  66991. x0 = x;
  66992. break;
  66993. case 'center':
  66994. x0 = x + (viewWidth - itemWidth) / 2;
  66995. break;
  66996. case 'right':
  66997. x0 = x + viewWidth - itemWidth;
  66998. break;
  66999. }
  67000. return [[x0, offset], [x0 + itemWidth, offset]];
  67001. };
  67002. if (sort === 'ascending') {
  67003. // From bottom to top
  67004. itemSize = -itemSize;
  67005. gap = -gap;
  67006. if (orient === 'horizontal') {
  67007. x += viewWidth;
  67008. } else {
  67009. y += viewHeight;
  67010. }
  67011. indices = indices.reverse();
  67012. }
  67013. for (var i = 0; i < indices.length; i++) {
  67014. var idx = indices[i];
  67015. var nextIdx = indices[i + 1];
  67016. var itemModel = data.getItemModel(idx);
  67017. if (orient === 'horizontal') {
  67018. var width = itemModel.get(['itemStyle', 'width']);
  67019. if (width == null) {
  67020. width = itemSize;
  67021. } else {
  67022. width = parsePercent$1(width, viewWidth);
  67023. if (sort === 'ascending') {
  67024. width = -width;
  67025. }
  67026. }
  67027. var start = getLinePoints(idx, x);
  67028. var end = getLinePoints(nextIdx, x + width);
  67029. x += width + gap;
  67030. data.setItemLayout(idx, {
  67031. points: start.concat(end.slice().reverse())
  67032. });
  67033. } else {
  67034. var height = itemModel.get(['itemStyle', 'height']);
  67035. if (height == null) {
  67036. height = itemSize;
  67037. } else {
  67038. height = parsePercent$1(height, viewHeight);
  67039. if (sort === 'ascending') {
  67040. height = -height;
  67041. }
  67042. }
  67043. var start = getLinePoints(idx, y);
  67044. var end = getLinePoints(nextIdx, y + height);
  67045. y += height + gap;
  67046. data.setItemLayout(idx, {
  67047. points: start.concat(end.slice().reverse())
  67048. });
  67049. }
  67050. }
  67051. labelLayout(data);
  67052. });
  67053. }
  67054. /*
  67055. * Licensed to the Apache Software Foundation (ASF) under one
  67056. * or more contributor license agreements. See the NOTICE file
  67057. * distributed with this work for additional information
  67058. * regarding copyright ownership. The ASF licenses this file
  67059. * to you under the Apache License, Version 2.0 (the
  67060. * "License"); you may not use this file except in compliance
  67061. * with the License. You may obtain a copy of the License at
  67062. *
  67063. * http://www.apache.org/licenses/LICENSE-2.0
  67064. *
  67065. * Unless required by applicable law or agreed to in writing,
  67066. * software distributed under the License is distributed on an
  67067. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67068. * KIND, either express or implied. See the License for the
  67069. * specific language governing permissions and limitations
  67070. * under the License.
  67071. */
  67072. /**
  67073. * AUTO-GENERATED FILE. DO NOT MODIFY.
  67074. */
  67075. /*
  67076. * Licensed to the Apache Software Foundation (ASF) under one
  67077. * or more contributor license agreements. See the NOTICE file
  67078. * distributed with this work for additional information
  67079. * regarding copyright ownership. The ASF licenses this file
  67080. * to you under the Apache License, Version 2.0 (the
  67081. * "License"); you may not use this file except in compliance
  67082. * with the License. You may obtain a copy of the License at
  67083. *
  67084. * http://www.apache.org/licenses/LICENSE-2.0
  67085. *
  67086. * Unless required by applicable law or agreed to in writing,
  67087. * software distributed under the License is distributed on an
  67088. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67089. * KIND, either express or implied. See the License for the
  67090. * specific language governing permissions and limitations
  67091. * under the License.
  67092. */
  67093. function install$23(registers) {
  67094. registers.registerChartView(FunnelView);
  67095. registers.registerSeriesModel(FunnelSeriesModel);
  67096. registers.registerLayout(funnelLayout);
  67097. registers.registerProcessor(dataFilter('funnel'));
  67098. }
  67099. /*
  67100. * Licensed to the Apache Software Foundation (ASF) under one
  67101. * or more contributor license agreements. See the NOTICE file
  67102. * distributed with this work for additional information
  67103. * regarding copyright ownership. The ASF licenses this file
  67104. * to you under the Apache License, Version 2.0 (the
  67105. * "License"); you may not use this file except in compliance
  67106. * with the License. You may obtain a copy of the License at
  67107. *
  67108. * http://www.apache.org/licenses/LICENSE-2.0
  67109. *
  67110. * Unless required by applicable law or agreed to in writing,
  67111. * software distributed under the License is distributed on an
  67112. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67113. * KIND, either express or implied. See the License for the
  67114. * specific language governing permissions and limitations
  67115. * under the License.
  67116. */
  67117. /**
  67118. * AUTO-GENERATED FILE. DO NOT MODIFY.
  67119. */
  67120. /*
  67121. * Licensed to the Apache Software Foundation (ASF) under one
  67122. * or more contributor license agreements. See the NOTICE file
  67123. * distributed with this work for additional information
  67124. * regarding copyright ownership. The ASF licenses this file
  67125. * to you under the Apache License, Version 2.0 (the
  67126. * "License"); you may not use this file except in compliance
  67127. * with the License. You may obtain a copy of the License at
  67128. *
  67129. * http://www.apache.org/licenses/LICENSE-2.0
  67130. *
  67131. * Unless required by applicable law or agreed to in writing,
  67132. * software distributed under the License is distributed on an
  67133. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67134. * KIND, either express or implied. See the License for the
  67135. * specific language governing permissions and limitations
  67136. * under the License.
  67137. */
  67138. use(install$23);
  67139. /*
  67140. * Licensed to the Apache Software Foundation (ASF) under one
  67141. * or more contributor license agreements. See the NOTICE file
  67142. * distributed with this work for additional information
  67143. * regarding copyright ownership. The ASF licenses this file
  67144. * to you under the Apache License, Version 2.0 (the
  67145. * "License"); you may not use this file except in compliance
  67146. * with the License. You may obtain a copy of the License at
  67147. *
  67148. * http://www.apache.org/licenses/LICENSE-2.0
  67149. *
  67150. * Unless required by applicable law or agreed to in writing,
  67151. * software distributed under the License is distributed on an
  67152. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67153. * KIND, either express or implied. See the License for the
  67154. * specific language governing permissions and limitations
  67155. * under the License.
  67156. */
  67157. /**
  67158. * AUTO-GENERATED FILE. DO NOT MODIFY.
  67159. */
  67160. /*
  67161. * Licensed to the Apache Software Foundation (ASF) under one
  67162. * or more contributor license agreements. See the NOTICE file
  67163. * distributed with this work for additional information
  67164. * regarding copyright ownership. The ASF licenses this file
  67165. * to you under the Apache License, Version 2.0 (the
  67166. * "License"); you may not use this file except in compliance
  67167. * with the License. You may obtain a copy of the License at
  67168. *
  67169. * http://www.apache.org/licenses/LICENSE-2.0
  67170. *
  67171. * Unless required by applicable law or agreed to in writing,
  67172. * software distributed under the License is distributed on an
  67173. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67174. * KIND, either express or implied. See the License for the
  67175. * specific language governing permissions and limitations
  67176. * under the License.
  67177. */
  67178. var SankeyPathShape =
  67179. /** @class */
  67180. function () {
  67181. function SankeyPathShape() {
  67182. this.x1 = 0;
  67183. this.y1 = 0;
  67184. this.x2 = 0;
  67185. this.y2 = 0;
  67186. this.cpx1 = 0;
  67187. this.cpy1 = 0;
  67188. this.cpx2 = 0;
  67189. this.cpy2 = 0;
  67190. this.extent = 0;
  67191. }
  67192. return SankeyPathShape;
  67193. }();
  67194. var SankeyPath =
  67195. /** @class */
  67196. function (_super) {
  67197. __extends(SankeyPath, _super);
  67198. function SankeyPath(opts) {
  67199. return _super.call(this, opts) || this;
  67200. }
  67201. SankeyPath.prototype.getDefaultShape = function () {
  67202. return new SankeyPathShape();
  67203. };
  67204. SankeyPath.prototype.buildPath = function (ctx, shape) {
  67205. var extent = shape.extent;
  67206. ctx.moveTo(shape.x1, shape.y1);
  67207. ctx.bezierCurveTo(shape.cpx1, shape.cpy1, shape.cpx2, shape.cpy2, shape.x2, shape.y2);
  67208. if (shape.orient === 'vertical') {
  67209. ctx.lineTo(shape.x2 + extent, shape.y2);
  67210. ctx.bezierCurveTo(shape.cpx2 + extent, shape.cpy2, shape.cpx1 + extent, shape.cpy1, shape.x1 + extent, shape.y1);
  67211. } else {
  67212. ctx.lineTo(shape.x2, shape.y2 + extent);
  67213. ctx.bezierCurveTo(shape.cpx2, shape.cpy2 + extent, shape.cpx1, shape.cpy1 + extent, shape.x1, shape.y1 + extent);
  67214. }
  67215. ctx.closePath();
  67216. };
  67217. SankeyPath.prototype.highlight = function () {
  67218. enterEmphasis(this);
  67219. };
  67220. SankeyPath.prototype.downplay = function () {
  67221. leaveEmphasis(this);
  67222. };
  67223. return SankeyPath;
  67224. }(Path);
  67225. var SankeyView =
  67226. /** @class */
  67227. function (_super) {
  67228. __extends(SankeyView, _super);
  67229. function SankeyView() {
  67230. var _this = _super !== null && _super.apply(this, arguments) || this;
  67231. _this.type = SankeyView.type;
  67232. _this._focusAdjacencyDisabled = false;
  67233. return _this;
  67234. }
  67235. SankeyView.prototype.render = function (seriesModel, ecModel, api) {
  67236. var sankeyView = this;
  67237. var graph = seriesModel.getGraph();
  67238. var group = this.group;
  67239. var layoutInfo = seriesModel.layoutInfo; // view width
  67240. var width = layoutInfo.width; // view height
  67241. var height = layoutInfo.height;
  67242. var nodeData = seriesModel.getData();
  67243. var edgeData = seriesModel.getData('edge');
  67244. var orient = seriesModel.get('orient');
  67245. this._model = seriesModel;
  67246. group.removeAll();
  67247. group.x = layoutInfo.x;
  67248. group.y = layoutInfo.y; // generate a bezire Curve for each edge
  67249. graph.eachEdge(function (edge) {
  67250. var curve = new SankeyPath();
  67251. var ecData = getECData(curve);
  67252. ecData.dataIndex = edge.dataIndex;
  67253. ecData.seriesIndex = seriesModel.seriesIndex;
  67254. ecData.dataType = 'edge';
  67255. var edgeModel = edge.getModel();
  67256. var lineStyleModel = edgeModel.getModel('lineStyle');
  67257. var curvature = lineStyleModel.get('curveness');
  67258. var n1Layout = edge.node1.getLayout();
  67259. var node1Model = edge.node1.getModel();
  67260. var dragX1 = node1Model.get('localX');
  67261. var dragY1 = node1Model.get('localY');
  67262. var n2Layout = edge.node2.getLayout();
  67263. var node2Model = edge.node2.getModel();
  67264. var dragX2 = node2Model.get('localX');
  67265. var dragY2 = node2Model.get('localY');
  67266. var edgeLayout = edge.getLayout();
  67267. var x1;
  67268. var y1;
  67269. var x2;
  67270. var y2;
  67271. var cpx1;
  67272. var cpy1;
  67273. var cpx2;
  67274. var cpy2;
  67275. curve.shape.extent = Math.max(1, edgeLayout.dy);
  67276. curve.shape.orient = orient;
  67277. if (orient === 'vertical') {
  67278. x1 = (dragX1 != null ? dragX1 * width : n1Layout.x) + edgeLayout.sy;
  67279. y1 = (dragY1 != null ? dragY1 * height : n1Layout.y) + n1Layout.dy;
  67280. x2 = (dragX2 != null ? dragX2 * width : n2Layout.x) + edgeLayout.ty;
  67281. y2 = dragY2 != null ? dragY2 * height : n2Layout.y;
  67282. cpx1 = x1;
  67283. cpy1 = y1 * (1 - curvature) + y2 * curvature;
  67284. cpx2 = x2;
  67285. cpy2 = y1 * curvature + y2 * (1 - curvature);
  67286. } else {
  67287. x1 = (dragX1 != null ? dragX1 * width : n1Layout.x) + n1Layout.dx;
  67288. y1 = (dragY1 != null ? dragY1 * height : n1Layout.y) + edgeLayout.sy;
  67289. x2 = dragX2 != null ? dragX2 * width : n2Layout.x;
  67290. y2 = (dragY2 != null ? dragY2 * height : n2Layout.y) + edgeLayout.ty;
  67291. cpx1 = x1 * (1 - curvature) + x2 * curvature;
  67292. cpy1 = y1;
  67293. cpx2 = x1 * curvature + x2 * (1 - curvature);
  67294. cpy2 = y2;
  67295. }
  67296. curve.setShape({
  67297. x1: x1,
  67298. y1: y1,
  67299. x2: x2,
  67300. y2: y2,
  67301. cpx1: cpx1,
  67302. cpy1: cpy1,
  67303. cpx2: cpx2,
  67304. cpy2: cpy2
  67305. });
  67306. curve.useStyle(lineStyleModel.getItemStyle()); // Special color, use source node color or target node color
  67307. switch (curve.style.fill) {
  67308. case 'source':
  67309. curve.style.fill = edge.node1.getVisual('color');
  67310. curve.style.decal = edge.node1.getVisual('style').decal;
  67311. break;
  67312. case 'target':
  67313. curve.style.fill = edge.node2.getVisual('color');
  67314. curve.style.decal = edge.node2.getVisual('style').decal;
  67315. break;
  67316. case 'gradient':
  67317. var sourceColor = edge.node1.getVisual('color');
  67318. var targetColor = edge.node2.getVisual('color');
  67319. if (typeof sourceColor === 'string' && typeof targetColor === 'string') {
  67320. curve.style.fill = new LinearGradient(0, 0, 1, 0, [{
  67321. color: sourceColor,
  67322. offset: 0
  67323. }, {
  67324. color: targetColor,
  67325. offset: 1
  67326. }]);
  67327. }
  67328. }
  67329. var emphasisModel = edgeModel.getModel('emphasis');
  67330. setStatesStylesFromModel(curve, edgeModel, 'lineStyle', function (model) {
  67331. return model.getItemStyle();
  67332. });
  67333. group.add(curve);
  67334. edgeData.setItemGraphicEl(edge.dataIndex, curve);
  67335. var focus = emphasisModel.get('focus');
  67336. enableHoverEmphasis(curve, focus === 'adjacency' ? edge.getAdjacentDataIndices() : focus, emphasisModel.get('blurScope'));
  67337. getECData(curve).dataType = 'edge';
  67338. }); // Generate a rect for each node
  67339. graph.eachNode(function (node) {
  67340. var layout = node.getLayout();
  67341. var itemModel = node.getModel();
  67342. var dragX = itemModel.get('localX');
  67343. var dragY = itemModel.get('localY');
  67344. var emphasisModel = itemModel.getModel('emphasis');
  67345. var rect = new Rect({
  67346. shape: {
  67347. x: dragX != null ? dragX * width : layout.x,
  67348. y: dragY != null ? dragY * height : layout.y,
  67349. width: layout.dx,
  67350. height: layout.dy
  67351. },
  67352. style: itemModel.getModel('itemStyle').getItemStyle(),
  67353. z2: 10
  67354. });
  67355. setLabelStyle(rect, getLabelStatesModels(itemModel), {
  67356. labelFetcher: seriesModel,
  67357. labelDataIndex: node.dataIndex,
  67358. defaultText: node.id
  67359. });
  67360. rect.disableLabelAnimation = true;
  67361. rect.setStyle('fill', node.getVisual('color'));
  67362. rect.setStyle('decal', node.getVisual('style').decal);
  67363. setStatesStylesFromModel(rect, itemModel);
  67364. group.add(rect);
  67365. nodeData.setItemGraphicEl(node.dataIndex, rect);
  67366. getECData(rect).dataType = 'node';
  67367. var focus = emphasisModel.get('focus');
  67368. enableHoverEmphasis(rect, focus === 'adjacency' ? node.getAdjacentDataIndices() : focus, emphasisModel.get('blurScope'));
  67369. });
  67370. nodeData.eachItemGraphicEl(function (el, dataIndex) {
  67371. var itemModel = nodeData.getItemModel(dataIndex);
  67372. if (itemModel.get('draggable')) {
  67373. el.drift = function (dx, dy) {
  67374. sankeyView._focusAdjacencyDisabled = true;
  67375. this.shape.x += dx;
  67376. this.shape.y += dy;
  67377. this.dirty();
  67378. api.dispatchAction({
  67379. type: 'dragNode',
  67380. seriesId: seriesModel.id,
  67381. dataIndex: nodeData.getRawIndex(dataIndex),
  67382. localX: this.shape.x / width,
  67383. localY: this.shape.y / height
  67384. });
  67385. };
  67386. el.ondragend = function () {
  67387. sankeyView._focusAdjacencyDisabled = false;
  67388. };
  67389. el.draggable = true;
  67390. el.cursor = 'move';
  67391. }
  67392. });
  67393. if (!this._data && seriesModel.isAnimationEnabled()) {
  67394. group.setClipPath(createGridClipShape$1(group.getBoundingRect(), seriesModel, function () {
  67395. group.removeClipPath();
  67396. }));
  67397. }
  67398. this._data = seriesModel.getData();
  67399. };
  67400. SankeyView.prototype.dispose = function () {};
  67401. SankeyView.type = 'sankey';
  67402. return SankeyView;
  67403. }(ChartView); // Add animation to the view
  67404. function createGridClipShape$1(rect, seriesModel, cb) {
  67405. var rectEl = new Rect({
  67406. shape: {
  67407. x: rect.x - 10,
  67408. y: rect.y - 10,
  67409. width: 0,
  67410. height: rect.height + 20
  67411. }
  67412. });
  67413. initProps(rectEl, {
  67414. shape: {
  67415. width: rect.width + 20
  67416. }
  67417. }, seriesModel, cb);
  67418. return rectEl;
  67419. }
  67420. /*
  67421. * Licensed to the Apache Software Foundation (ASF) under one
  67422. * or more contributor license agreements. See the NOTICE file
  67423. * distributed with this work for additional information
  67424. * regarding copyright ownership. The ASF licenses this file
  67425. * to you under the Apache License, Version 2.0 (the
  67426. * "License"); you may not use this file except in compliance
  67427. * with the License. You may obtain a copy of the License at
  67428. *
  67429. * http://www.apache.org/licenses/LICENSE-2.0
  67430. *
  67431. * Unless required by applicable law or agreed to in writing,
  67432. * software distributed under the License is distributed on an
  67433. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67434. * KIND, either express or implied. See the License for the
  67435. * specific language governing permissions and limitations
  67436. * under the License.
  67437. */
  67438. /**
  67439. * AUTO-GENERATED FILE. DO NOT MODIFY.
  67440. */
  67441. /*
  67442. * Licensed to the Apache Software Foundation (ASF) under one
  67443. * or more contributor license agreements. See the NOTICE file
  67444. * distributed with this work for additional information
  67445. * regarding copyright ownership. The ASF licenses this file
  67446. * to you under the Apache License, Version 2.0 (the
  67447. * "License"); you may not use this file except in compliance
  67448. * with the License. You may obtain a copy of the License at
  67449. *
  67450. * http://www.apache.org/licenses/LICENSE-2.0
  67451. *
  67452. * Unless required by applicable law or agreed to in writing,
  67453. * software distributed under the License is distributed on an
  67454. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67455. * KIND, either express or implied. See the License for the
  67456. * specific language governing permissions and limitations
  67457. * under the License.
  67458. */
  67459. var SankeySeriesModel =
  67460. /** @class */
  67461. function (_super) {
  67462. __extends(SankeySeriesModel, _super);
  67463. function SankeySeriesModel() {
  67464. var _this = _super !== null && _super.apply(this, arguments) || this;
  67465. _this.type = SankeySeriesModel.type;
  67466. return _this;
  67467. }
  67468. /**
  67469. * Init a graph data structure from data in option series
  67470. *
  67471. * @param {Object} option the object used to config echarts view
  67472. * @return {module:echarts/data/List} storage initial data
  67473. */
  67474. SankeySeriesModel.prototype.getInitialData = function (option, ecModel) {
  67475. var links = option.edges || option.links;
  67476. var nodes = option.data || option.nodes;
  67477. var levels = option.levels;
  67478. this.levelModels = [];
  67479. var levelModels = this.levelModels;
  67480. for (var i = 0; i < levels.length; i++) {
  67481. if (levels[i].depth != null && levels[i].depth >= 0) {
  67482. levelModels[levels[i].depth] = new Model(levels[i], this, ecModel);
  67483. } else {
  67484. {
  67485. throw new Error('levels[i].depth is mandatory and should be natural number');
  67486. }
  67487. }
  67488. }
  67489. if (nodes && links) {
  67490. var graph = createGraphFromNodeEdge(nodes, links, this, true, beforeLink);
  67491. return graph.data;
  67492. }
  67493. function beforeLink(nodeData, edgeData) {
  67494. nodeData.wrapMethod('getItemModel', function (model, idx) {
  67495. var seriesModel = model.parentModel;
  67496. var layout = seriesModel.getData().getItemLayout(idx);
  67497. if (layout) {
  67498. var nodeDepth = layout.depth;
  67499. var levelModel = seriesModel.levelModels[nodeDepth];
  67500. if (levelModel) {
  67501. model.parentModel = levelModel;
  67502. }
  67503. }
  67504. return model;
  67505. });
  67506. edgeData.wrapMethod('getItemModel', function (model, idx) {
  67507. var seriesModel = model.parentModel;
  67508. var edge = seriesModel.getGraph().getEdgeByIndex(idx);
  67509. var layout = edge.node1.getLayout();
  67510. if (layout) {
  67511. var depth = layout.depth;
  67512. var levelModel = seriesModel.levelModels[depth];
  67513. if (levelModel) {
  67514. model.parentModel = levelModel;
  67515. }
  67516. }
  67517. return model;
  67518. });
  67519. }
  67520. };
  67521. SankeySeriesModel.prototype.setNodePosition = function (dataIndex, localPosition) {
  67522. var dataItem = this.option.data[dataIndex];
  67523. dataItem.localX = localPosition[0];
  67524. dataItem.localY = localPosition[1];
  67525. };
  67526. /**
  67527. * Return the graphic data structure
  67528. *
  67529. * @return graphic data structure
  67530. */
  67531. SankeySeriesModel.prototype.getGraph = function () {
  67532. return this.getData().graph;
  67533. };
  67534. /**
  67535. * Get edge data of graphic data structure
  67536. *
  67537. * @return data structure of list
  67538. */
  67539. SankeySeriesModel.prototype.getEdgeData = function () {
  67540. return this.getGraph().edgeData;
  67541. };
  67542. SankeySeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  67543. function noValue(val) {
  67544. return isNaN(val) || val == null;
  67545. } // dataType === 'node' or empty do not show tooltip by default
  67546. if (dataType === 'edge') {
  67547. var params = this.getDataParams(dataIndex, dataType);
  67548. var rawDataOpt = params.data;
  67549. var edgeValue = params.value;
  67550. var edgeName = rawDataOpt.source + ' -- ' + rawDataOpt.target;
  67551. return createTooltipMarkup('nameValue', {
  67552. name: edgeName,
  67553. value: edgeValue,
  67554. noValue: noValue(edgeValue)
  67555. });
  67556. } // dataType === 'node'
  67557. else {
  67558. var node = this.getGraph().getNodeByIndex(dataIndex);
  67559. var value = node.getLayout().value;
  67560. var name_1 = this.getDataParams(dataIndex, dataType).data.name;
  67561. return createTooltipMarkup('nameValue', {
  67562. name: name_1 != null ? name_1 + '' : null,
  67563. value: value,
  67564. noValue: noValue(value)
  67565. });
  67566. }
  67567. };
  67568. SankeySeriesModel.prototype.optionUpdated = function () {}; // Override Series.getDataParams()
  67569. SankeySeriesModel.prototype.getDataParams = function (dataIndex, dataType) {
  67570. var params = _super.prototype.getDataParams.call(this, dataIndex, dataType);
  67571. if (params.value == null && dataType === 'node') {
  67572. var node = this.getGraph().getNodeByIndex(dataIndex);
  67573. var nodeValue = node.getLayout().value;
  67574. params.value = nodeValue;
  67575. }
  67576. return params;
  67577. };
  67578. SankeySeriesModel.type = 'series.sankey';
  67579. SankeySeriesModel.defaultOption = {
  67580. zlevel: 0,
  67581. z: 2,
  67582. coordinateSystem: 'view',
  67583. left: '5%',
  67584. top: '5%',
  67585. right: '20%',
  67586. bottom: '5%',
  67587. orient: 'horizontal',
  67588. nodeWidth: 20,
  67589. nodeGap: 8,
  67590. draggable: true,
  67591. layoutIterations: 32,
  67592. label: {
  67593. show: true,
  67594. position: 'right',
  67595. fontSize: 12
  67596. },
  67597. levels: [],
  67598. nodeAlign: 'justify',
  67599. lineStyle: {
  67600. color: '#314656',
  67601. opacity: 0.2,
  67602. curveness: 0.5
  67603. },
  67604. emphasis: {
  67605. label: {
  67606. show: true
  67607. },
  67608. lineStyle: {
  67609. opacity: 0.5
  67610. }
  67611. },
  67612. select: {
  67613. itemStyle: {
  67614. borderColor: '#212121'
  67615. }
  67616. },
  67617. animationEasing: 'linear',
  67618. animationDuration: 1000
  67619. };
  67620. return SankeySeriesModel;
  67621. }(SeriesModel);
  67622. /*
  67623. * Licensed to the Apache Software Foundation (ASF) under one
  67624. * or more contributor license agreements. See the NOTICE file
  67625. * distributed with this work for additional information
  67626. * regarding copyright ownership. The ASF licenses this file
  67627. * to you under the Apache License, Version 2.0 (the
  67628. * "License"); you may not use this file except in compliance
  67629. * with the License. You may obtain a copy of the License at
  67630. *
  67631. * http://www.apache.org/licenses/LICENSE-2.0
  67632. *
  67633. * Unless required by applicable law or agreed to in writing,
  67634. * software distributed under the License is distributed on an
  67635. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67636. * KIND, either express or implied. See the License for the
  67637. * specific language governing permissions and limitations
  67638. * under the License.
  67639. */
  67640. /**
  67641. * AUTO-GENERATED FILE. DO NOT MODIFY.
  67642. */
  67643. /*
  67644. * Licensed to the Apache Software Foundation (ASF) under one
  67645. * or more contributor license agreements. See the NOTICE file
  67646. * distributed with this work for additional information
  67647. * regarding copyright ownership. The ASF licenses this file
  67648. * to you under the Apache License, Version 2.0 (the
  67649. * "License"); you may not use this file except in compliance
  67650. * with the License. You may obtain a copy of the License at
  67651. *
  67652. * http://www.apache.org/licenses/LICENSE-2.0
  67653. *
  67654. * Unless required by applicable law or agreed to in writing,
  67655. * software distributed under the License is distributed on an
  67656. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  67657. * KIND, either express or implied. See the License for the
  67658. * specific language governing permissions and limitations
  67659. * under the License.
  67660. */
  67661. function sankeyLayout(ecModel, api) {
  67662. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  67663. var nodeWidth = seriesModel.get('nodeWidth');
  67664. var nodeGap = seriesModel.get('nodeGap');
  67665. var layoutInfo = getViewRect$4(seriesModel, api);
  67666. seriesModel.layoutInfo = layoutInfo;
  67667. var width = layoutInfo.width;
  67668. var height = layoutInfo.height;
  67669. var graph = seriesModel.getGraph();
  67670. var nodes = graph.nodes;
  67671. var edges = graph.edges;
  67672. computeNodeValues(nodes);
  67673. var filteredNodes = filter(nodes, function (node) {
  67674. return node.getLayout().value === 0;
  67675. });
  67676. var iterations = filteredNodes.length !== 0 ? 0 : seriesModel.get('layoutIterations');
  67677. var orient = seriesModel.get('orient');
  67678. var nodeAlign = seriesModel.get('nodeAlign');
  67679. layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations, orient, nodeAlign);
  67680. });
  67681. }
  67682. /**
  67683. * Get the layout position of the whole view
  67684. */
  67685. function getViewRect$4(seriesModel, api) {
  67686. return getLayoutRect(seriesModel.getBoxLayoutParams(), {
  67687. width: api.getWidth(),
  67688. height: api.getHeight()
  67689. });
  67690. }
  67691. function layoutSankey(nodes, edges, nodeWidth, nodeGap, width, height, iterations, orient, nodeAlign) {
  67692. computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nodeAlign);
  67693. computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, orient);
  67694. computeEdgeDepths(nodes, orient);
  67695. }
  67696. /**
  67697. * Compute the value of each node by summing the associated edge's value
  67698. */
  67699. function computeNodeValues(nodes) {
  67700. each$1(nodes, function (node) {
  67701. var value1 = sum(node.outEdges, getEdgeValue);
  67702. var value2 = sum(node.inEdges, getEdgeValue);
  67703. var nodeRawValue = node.getValue() || 0;
  67704. var value = Math.max(value1, value2, nodeRawValue);
  67705. node.setLayout({
  67706. value: value
  67707. }, true);
  67708. });
  67709. }
  67710. /**
  67711. * Compute the x-position for each node.
  67712. *
  67713. * Here we use Kahn algorithm to detect cycle when we traverse
  67714. * the node to computer the initial x position.
  67715. */
  67716. function computeNodeBreadths(nodes, edges, nodeWidth, width, height, orient, nodeAlign) {
  67717. // Used to mark whether the edge is deleted. if it is deleted,
  67718. // the value is 0, otherwise it is 1.
  67719. var remainEdges = []; // Storage each node's indegree.
  67720. var indegreeArr = []; //Used to storage the node with indegree is equal to 0.
  67721. var zeroIndegrees = [];
  67722. var nextTargetNode = [];
  67723. var x = 0; // let kx = 0;
  67724. for (var i = 0; i < edges.length; i++) {
  67725. remainEdges[i] = 1;
  67726. }
  67727. for (var i = 0; i < nodes.length; i++) {
  67728. indegreeArr[i] = nodes[i].inEdges.length;
  67729. if (indegreeArr[i] === 0) {
  67730. zeroIndegrees.push(nodes[i]);
  67731. }
  67732. }
  67733. var maxNodeDepth = -1; // Traversing nodes using topological sorting to calculate the
  67734. // horizontal(if orient === 'horizontal') or vertical(if orient === 'vertical')
  67735. // position of the nodes.
  67736. while (zeroIndegrees.length) {
  67737. for (var idx = 0; idx < zeroIndegrees.length; idx++) {
  67738. var node = zeroIndegrees[idx];
  67739. var item = node.hostGraph.data.getRawDataItem(node.dataIndex);
  67740. var isItemDepth = item.depth != null && item.depth >= 0;
  67741. if (isItemDepth && item.depth > maxNodeDepth) {
  67742. maxNodeDepth = item.depth;
  67743. }
  67744. node.setLayout({
  67745. depth: isItemDepth ? item.depth : x
  67746. }, true);
  67747. orient === 'vertical' ? node.setLayout({
  67748. dy: nodeWidth
  67749. }, true) : node.setLayout({
  67750. dx: nodeWidth
  67751. }, true);
  67752. for (var edgeIdx = 0; edgeIdx < node.outEdges.length; edgeIdx++) {
  67753. var edge = node.outEdges[edgeIdx];
  67754. var indexEdge = edges.indexOf(edge);
  67755. remainEdges[indexEdge] = 0;
  67756. var targetNode = edge.node2;
  67757. var nodeIndex = nodes.indexOf(targetNode);
  67758. if (--indegreeArr[nodeIndex] === 0 && nextTargetNode.indexOf(targetNode) < 0) {
  67759. nextTargetNode.push(targetNode);
  67760. }
  67761. }
  67762. }
  67763. ++x;
  67764. zeroIndegrees = nextTargetNode;
  67765. nextTargetNode = [];
  67766. }
  67767. for (var i = 0; i < remainEdges.length; i++) {
  67768. if (remainEdges[i] === 1) {
  67769. throw new Error('Sankey is a DAG, the original data has cycle!');
  67770. }
  67771. }
  67772. var maxDepth = maxNodeDepth > x - 1 ? maxNodeDepth : x - 1;
  67773. if (nodeAlign && nodeAlign !== 'left') {
  67774. adjustNodeWithNodeAlign(nodes, nodeAlign, orient, maxDepth);
  67775. }
  67776. var kx = orient === 'vertical' ? (height - nodeWidth) / maxDepth : (width - nodeWidth) / maxDepth;
  67777. scaleNodeBreadths(nodes, kx, orient);
  67778. }
  67779. function isNodeDepth(node) {
  67780. var item = node.hostGraph.data.getRawDataItem(node.dataIndex);
  67781. return item.depth != null && item.depth >= 0;
  67782. }
  67783. function adjustNodeWithNodeAlign(nodes, nodeAlign, orient, maxDepth) {
  67784. if (nodeAlign === 'right') {
  67785. var nextSourceNode = [];
  67786. var remainNodes = nodes;
  67787. var nodeHeight = 0;
  67788. while (remainNodes.length) {
  67789. for (var i = 0; i < remainNodes.length; i++) {
  67790. var node = remainNodes[i];
  67791. node.setLayout({
  67792. skNodeHeight: nodeHeight
  67793. }, true);
  67794. for (var j = 0; j < node.inEdges.length; j++) {
  67795. var edge = node.inEdges[j];
  67796. if (nextSourceNode.indexOf(edge.node1) < 0) {
  67797. nextSourceNode.push(edge.node1);
  67798. }
  67799. }
  67800. }
  67801. remainNodes = nextSourceNode;
  67802. nextSourceNode = [];
  67803. ++nodeHeight;
  67804. }
  67805. each$1(nodes, function (node) {
  67806. if (!isNodeDepth(node)) {
  67807. node.setLayout({
  67808. depth: Math.max(0, maxDepth - node.getLayout().skNodeHeight)
  67809. }, true);
  67810. }
  67811. });
  67812. } else if (nodeAlign === 'justify') {
  67813. moveSinksRight(nodes, maxDepth);
  67814. }
  67815. }
  67816. /**
  67817. * All the node without outEgdes are assigned maximum x-position and
  67818. * be aligned in the last column.
  67819. *
  67820. * @param nodes. node of sankey view.
  67821. * @param maxDepth. use to assign to node without outEdges as x-position.
  67822. */
  67823. function moveSinksRight(nodes, maxDepth) {
  67824. each$1(nodes, function (node) {
  67825. if (!isNodeDepth(node) && !node.outEdges.length) {
  67826. node.setLayout({
  67827. depth: maxDepth
  67828. }, true);
  67829. }
  67830. });
  67831. }
  67832. /**
  67833. * Scale node x-position to the width
  67834. *
  67835. * @param nodes node of sankey view
  67836. * @param kx multiple used to scale nodes
  67837. */
  67838. function scaleNodeBreadths(nodes, kx, orient) {
  67839. each$1(nodes, function (node) {
  67840. var nodeDepth = node.getLayout().depth * kx;
  67841. orient === 'vertical' ? node.setLayout({
  67842. y: nodeDepth
  67843. }, true) : node.setLayout({
  67844. x: nodeDepth
  67845. }, true);
  67846. });
  67847. }
  67848. /**
  67849. * Using Gauss-Seidel iterations method to compute the node depth(y-position)
  67850. *
  67851. * @param nodes node of sankey view
  67852. * @param edges edge of sankey view
  67853. * @param height the whole height of the area to draw the view
  67854. * @param nodeGap the vertical distance between two nodes
  67855. * in the same column.
  67856. * @param iterations the number of iterations for the algorithm
  67857. */
  67858. function computeNodeDepths(nodes, edges, height, width, nodeGap, iterations, orient) {
  67859. var nodesByBreadth = prepareNodesByBreadth(nodes, orient);
  67860. initializeNodeDepth(nodesByBreadth, edges, height, width, nodeGap, orient);
  67861. resolveCollisions(nodesByBreadth, nodeGap, height, width, orient);
  67862. for (var alpha = 1; iterations > 0; iterations--) {
  67863. // 0.99 is a experience parameter, ensure that each iterations of
  67864. // changes as small as possible.
  67865. alpha *= 0.99;
  67866. relaxRightToLeft(nodesByBreadth, alpha, orient);
  67867. resolveCollisions(nodesByBreadth, nodeGap, height, width, orient);
  67868. relaxLeftToRight(nodesByBreadth, alpha, orient);
  67869. resolveCollisions(nodesByBreadth, nodeGap, height, width, orient);
  67870. }
  67871. }
  67872. function prepareNodesByBreadth(nodes, orient) {
  67873. var nodesByBreadth = [];
  67874. var keyAttr = orient === 'vertical' ? 'y' : 'x';
  67875. var groupResult = groupData(nodes, function (node) {
  67876. return node.getLayout()[keyAttr];
  67877. });
  67878. groupResult.keys.sort(function (a, b) {
  67879. return a - b;
  67880. });
  67881. each$1(groupResult.keys, function (key) {
  67882. nodesByBreadth.push(groupResult.buckets.get(key));
  67883. });
  67884. return nodesByBreadth;
  67885. }
  67886. /**
  67887. * Compute the original y-position for each node
  67888. */
  67889. function initializeNodeDepth(nodesByBreadth, edges, height, width, nodeGap, orient) {
  67890. var minKy = Infinity;
  67891. each$1(nodesByBreadth, function (nodes) {
  67892. var n = nodes.length;
  67893. var sum = 0;
  67894. each$1(nodes, function (node) {
  67895. sum += node.getLayout().value;
  67896. });
  67897. var ky = orient === 'vertical' ? (width - (n - 1) * nodeGap) / sum : (height - (n - 1) * nodeGap) / sum;
  67898. if (ky < minKy) {
  67899. minKy = ky;
  67900. }
  67901. });
  67902. each$1(nodesByBreadth, function (nodes) {
  67903. each$1(nodes, function (node, i) {
  67904. var nodeDy = node.getLayout().value * minKy;
  67905. if (orient === 'vertical') {
  67906. node.setLayout({
  67907. x: i
  67908. }, true);
  67909. node.setLayout({
  67910. dx: nodeDy
  67911. }, true);
  67912. } else {
  67913. node.setLayout({
  67914. y: i
  67915. }, true);
  67916. node.setLayout({
  67917. dy: nodeDy
  67918. }, true);
  67919. }
  67920. });
  67921. });
  67922. each$1(edges, function (edge) {
  67923. var edgeDy = +edge.getValue() * minKy;
  67924. edge.setLayout({
  67925. dy: edgeDy
  67926. }, true);
  67927. });
  67928. }
  67929. /**
  67930. * Resolve the collision of initialized depth (y-position)
  67931. */
  67932. function resolveCollisions(nodesByBreadth, nodeGap, height, width, orient) {
  67933. var keyAttr = orient === 'vertical' ? 'x' : 'y';
  67934. each$1(nodesByBreadth, function (nodes) {
  67935. nodes.sort(function (a, b) {
  67936. return a.getLayout()[keyAttr] - b.getLayout()[keyAttr];
  67937. });
  67938. var nodeX;
  67939. var node;
  67940. var dy;
  67941. var y0 = 0;
  67942. var n = nodes.length;
  67943. var nodeDyAttr = orient === 'vertical' ? 'dx' : 'dy';
  67944. for (var i = 0; i < n; i++) {
  67945. node = nodes[i];
  67946. dy = y0 - node.getLayout()[keyAttr];
  67947. if (dy > 0) {
  67948. nodeX = node.getLayout()[keyAttr] + dy;
  67949. orient === 'vertical' ? node.setLayout({
  67950. x: nodeX
  67951. }, true) : node.setLayout({
  67952. y: nodeX
  67953. }, true);
  67954. }
  67955. y0 = node.getLayout()[keyAttr] + node.getLayout()[nodeDyAttr] + nodeGap;
  67956. }
  67957. var viewWidth = orient === 'vertical' ? width : height; // If the bottommost node goes outside the bounds, push it back up
  67958. dy = y0 - nodeGap - viewWidth;
  67959. if (dy > 0) {
  67960. nodeX = node.getLayout()[keyAttr] - dy;
  67961. orient === 'vertical' ? node.setLayout({
  67962. x: nodeX
  67963. }, true) : node.setLayout({
  67964. y: nodeX
  67965. }, true);
  67966. y0 = nodeX;
  67967. for (var i = n - 2; i >= 0; --i) {
  67968. node = nodes[i];
  67969. dy = node.getLayout()[keyAttr] + node.getLayout()[nodeDyAttr] + nodeGap - y0;
  67970. if (dy > 0) {
  67971. nodeX = node.getLayout()[keyAttr] - dy;
  67972. orient === 'vertical' ? node.setLayout({
  67973. x: nodeX
  67974. }, true) : node.setLayout({
  67975. y: nodeX
  67976. }, true);
  67977. }
  67978. y0 = node.getLayout()[keyAttr];
  67979. }
  67980. }
  67981. });
  67982. }
  67983. /**
  67984. * Change the y-position of the nodes, except most the right side nodes
  67985. * @param nodesByBreadth
  67986. * @param alpha parameter used to adjust the nodes y-position
  67987. */
  67988. function relaxRightToLeft(nodesByBreadth, alpha, orient) {
  67989. each$1(nodesByBreadth.slice().reverse(), function (nodes) {
  67990. each$1(nodes, function (node) {
  67991. if (node.outEdges.length) {
  67992. var y = sum(node.outEdges, weightedTarget, orient) / sum(node.outEdges, getEdgeValue);
  67993. if (isNaN(y)) {
  67994. var len = node.outEdges.length;
  67995. y = len ? sum(node.outEdges, centerTarget, orient) / len : 0;
  67996. }
  67997. if (orient === 'vertical') {
  67998. var nodeX = node.getLayout().x + (y - center$1(node, orient)) * alpha;
  67999. node.setLayout({
  68000. x: nodeX
  68001. }, true);
  68002. } else {
  68003. var nodeY = node.getLayout().y + (y - center$1(node, orient)) * alpha;
  68004. node.setLayout({
  68005. y: nodeY
  68006. }, true);
  68007. }
  68008. }
  68009. });
  68010. });
  68011. }
  68012. function weightedTarget(edge, orient) {
  68013. return center$1(edge.node2, orient) * edge.getValue();
  68014. }
  68015. function centerTarget(edge, orient) {
  68016. return center$1(edge.node2, orient);
  68017. }
  68018. function weightedSource(edge, orient) {
  68019. return center$1(edge.node1, orient) * edge.getValue();
  68020. }
  68021. function centerSource(edge, orient) {
  68022. return center$1(edge.node1, orient);
  68023. }
  68024. function center$1(node, orient) {
  68025. return orient === 'vertical' ? node.getLayout().x + node.getLayout().dx / 2 : node.getLayout().y + node.getLayout().dy / 2;
  68026. }
  68027. function getEdgeValue(edge) {
  68028. return edge.getValue();
  68029. }
  68030. function sum(array, cb, orient) {
  68031. var sum = 0;
  68032. var len = array.length;
  68033. var i = -1;
  68034. while (++i < len) {
  68035. var value = +cb(array[i], orient);
  68036. if (!isNaN(value)) {
  68037. sum += value;
  68038. }
  68039. }
  68040. return sum;
  68041. }
  68042. /**
  68043. * Change the y-position of the nodes, except most the left side nodes
  68044. */
  68045. function relaxLeftToRight(nodesByBreadth, alpha, orient) {
  68046. each$1(nodesByBreadth, function (nodes) {
  68047. each$1(nodes, function (node) {
  68048. if (node.inEdges.length) {
  68049. var y = sum(node.inEdges, weightedSource, orient) / sum(node.inEdges, getEdgeValue);
  68050. if (isNaN(y)) {
  68051. var len = node.inEdges.length;
  68052. y = len ? sum(node.inEdges, centerSource, orient) / len : 0;
  68053. }
  68054. if (orient === 'vertical') {
  68055. var nodeX = node.getLayout().x + (y - center$1(node, orient)) * alpha;
  68056. node.setLayout({
  68057. x: nodeX
  68058. }, true);
  68059. } else {
  68060. var nodeY = node.getLayout().y + (y - center$1(node, orient)) * alpha;
  68061. node.setLayout({
  68062. y: nodeY
  68063. }, true);
  68064. }
  68065. }
  68066. });
  68067. });
  68068. }
  68069. /**
  68070. * Compute the depth(y-position) of each edge
  68071. */
  68072. function computeEdgeDepths(nodes, orient) {
  68073. var keyAttr = orient === 'vertical' ? 'x' : 'y';
  68074. each$1(nodes, function (node) {
  68075. node.outEdges.sort(function (a, b) {
  68076. return a.node2.getLayout()[keyAttr] - b.node2.getLayout()[keyAttr];
  68077. });
  68078. node.inEdges.sort(function (a, b) {
  68079. return a.node1.getLayout()[keyAttr] - b.node1.getLayout()[keyAttr];
  68080. });
  68081. });
  68082. each$1(nodes, function (node) {
  68083. var sy = 0;
  68084. var ty = 0;
  68085. each$1(node.outEdges, function (edge) {
  68086. edge.setLayout({
  68087. sy: sy
  68088. }, true);
  68089. sy += edge.getLayout().dy;
  68090. });
  68091. each$1(node.inEdges, function (edge) {
  68092. edge.setLayout({
  68093. ty: ty
  68094. }, true);
  68095. ty += edge.getLayout().dy;
  68096. });
  68097. });
  68098. }
  68099. /*
  68100. * Licensed to the Apache Software Foundation (ASF) under one
  68101. * or more contributor license agreements. See the NOTICE file
  68102. * distributed with this work for additional information
  68103. * regarding copyright ownership. The ASF licenses this file
  68104. * to you under the Apache License, Version 2.0 (the
  68105. * "License"); you may not use this file except in compliance
  68106. * with the License. You may obtain a copy of the License at
  68107. *
  68108. * http://www.apache.org/licenses/LICENSE-2.0
  68109. *
  68110. * Unless required by applicable law or agreed to in writing,
  68111. * software distributed under the License is distributed on an
  68112. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68113. * KIND, either express or implied. See the License for the
  68114. * specific language governing permissions and limitations
  68115. * under the License.
  68116. */
  68117. /**
  68118. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68119. */
  68120. /*
  68121. * Licensed to the Apache Software Foundation (ASF) under one
  68122. * or more contributor license agreements. See the NOTICE file
  68123. * distributed with this work for additional information
  68124. * regarding copyright ownership. The ASF licenses this file
  68125. * to you under the Apache License, Version 2.0 (the
  68126. * "License"); you may not use this file except in compliance
  68127. * with the License. You may obtain a copy of the License at
  68128. *
  68129. * http://www.apache.org/licenses/LICENSE-2.0
  68130. *
  68131. * Unless required by applicable law or agreed to in writing,
  68132. * software distributed under the License is distributed on an
  68133. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68134. * KIND, either express or implied. See the License for the
  68135. * specific language governing permissions and limitations
  68136. * under the License.
  68137. */
  68138. function sankeyVisual(ecModel) {
  68139. ecModel.eachSeriesByType('sankey', function (seriesModel) {
  68140. var graph = seriesModel.getGraph();
  68141. var nodes = graph.nodes;
  68142. if (nodes.length) {
  68143. var minValue_1 = Infinity;
  68144. var maxValue_1 = -Infinity;
  68145. each$1(nodes, function (node) {
  68146. var nodeValue = node.getLayout().value;
  68147. if (nodeValue < minValue_1) {
  68148. minValue_1 = nodeValue;
  68149. }
  68150. if (nodeValue > maxValue_1) {
  68151. maxValue_1 = nodeValue;
  68152. }
  68153. });
  68154. each$1(nodes, function (node) {
  68155. var mapping = new VisualMapping({
  68156. type: 'color',
  68157. mappingMethod: 'linear',
  68158. dataExtent: [minValue_1, maxValue_1],
  68159. visual: seriesModel.get('color')
  68160. });
  68161. var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value);
  68162. var customColor = node.getModel().get(['itemStyle', 'color']);
  68163. if (customColor != null) {
  68164. node.setVisual('color', customColor);
  68165. node.setVisual('style', {
  68166. fill: customColor
  68167. });
  68168. } else {
  68169. node.setVisual('color', mapValueToColor);
  68170. node.setVisual('style', {
  68171. fill: mapValueToColor
  68172. });
  68173. }
  68174. });
  68175. }
  68176. });
  68177. }
  68178. /*
  68179. * Licensed to the Apache Software Foundation (ASF) under one
  68180. * or more contributor license agreements. See the NOTICE file
  68181. * distributed with this work for additional information
  68182. * regarding copyright ownership. The ASF licenses this file
  68183. * to you under the Apache License, Version 2.0 (the
  68184. * "License"); you may not use this file except in compliance
  68185. * with the License. You may obtain a copy of the License at
  68186. *
  68187. * http://www.apache.org/licenses/LICENSE-2.0
  68188. *
  68189. * Unless required by applicable law or agreed to in writing,
  68190. * software distributed under the License is distributed on an
  68191. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68192. * KIND, either express or implied. See the License for the
  68193. * specific language governing permissions and limitations
  68194. * under the License.
  68195. */
  68196. /**
  68197. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68198. */
  68199. /*
  68200. * Licensed to the Apache Software Foundation (ASF) under one
  68201. * or more contributor license agreements. See the NOTICE file
  68202. * distributed with this work for additional information
  68203. * regarding copyright ownership. The ASF licenses this file
  68204. * to you under the Apache License, Version 2.0 (the
  68205. * "License"); you may not use this file except in compliance
  68206. * with the License. You may obtain a copy of the License at
  68207. *
  68208. * http://www.apache.org/licenses/LICENSE-2.0
  68209. *
  68210. * Unless required by applicable law or agreed to in writing,
  68211. * software distributed under the License is distributed on an
  68212. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68213. * KIND, either express or implied. See the License for the
  68214. * specific language governing permissions and limitations
  68215. * under the License.
  68216. */
  68217. function install$24(registers) {
  68218. registers.registerChartView(SankeyView);
  68219. registers.registerSeriesModel(SankeySeriesModel);
  68220. registers.registerLayout(sankeyLayout);
  68221. registers.registerVisual(sankeyVisual);
  68222. registers.registerAction({
  68223. type: 'dragNode',
  68224. event: 'dragnode',
  68225. // here can only use 'update' now, other value is not support in echarts.
  68226. update: 'update'
  68227. }, function (payload, ecModel) {
  68228. ecModel.eachComponent({
  68229. mainType: 'series',
  68230. subType: 'sankey',
  68231. query: payload
  68232. }, function (seriesModel) {
  68233. seriesModel.setNodePosition(payload.dataIndex, [payload.localX, payload.localY]);
  68234. });
  68235. });
  68236. }
  68237. /*
  68238. * Licensed to the Apache Software Foundation (ASF) under one
  68239. * or more contributor license agreements. See the NOTICE file
  68240. * distributed with this work for additional information
  68241. * regarding copyright ownership. The ASF licenses this file
  68242. * to you under the Apache License, Version 2.0 (the
  68243. * "License"); you may not use this file except in compliance
  68244. * with the License. You may obtain a copy of the License at
  68245. *
  68246. * http://www.apache.org/licenses/LICENSE-2.0
  68247. *
  68248. * Unless required by applicable law or agreed to in writing,
  68249. * software distributed under the License is distributed on an
  68250. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68251. * KIND, either express or implied. See the License for the
  68252. * specific language governing permissions and limitations
  68253. * under the License.
  68254. */
  68255. /**
  68256. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68257. */
  68258. /*
  68259. * Licensed to the Apache Software Foundation (ASF) under one
  68260. * or more contributor license agreements. See the NOTICE file
  68261. * distributed with this work for additional information
  68262. * regarding copyright ownership. The ASF licenses this file
  68263. * to you under the Apache License, Version 2.0 (the
  68264. * "License"); you may not use this file except in compliance
  68265. * with the License. You may obtain a copy of the License at
  68266. *
  68267. * http://www.apache.org/licenses/LICENSE-2.0
  68268. *
  68269. * Unless required by applicable law or agreed to in writing,
  68270. * software distributed under the License is distributed on an
  68271. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68272. * KIND, either express or implied. See the License for the
  68273. * specific language governing permissions and limitations
  68274. * under the License.
  68275. */
  68276. use(install$24);
  68277. /*
  68278. * Licensed to the Apache Software Foundation (ASF) under one
  68279. * or more contributor license agreements. See the NOTICE file
  68280. * distributed with this work for additional information
  68281. * regarding copyright ownership. The ASF licenses this file
  68282. * to you under the Apache License, Version 2.0 (the
  68283. * "License"); you may not use this file except in compliance
  68284. * with the License. You may obtain a copy of the License at
  68285. *
  68286. * http://www.apache.org/licenses/LICENSE-2.0
  68287. *
  68288. * Unless required by applicable law or agreed to in writing,
  68289. * software distributed under the License is distributed on an
  68290. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68291. * KIND, either express or implied. See the License for the
  68292. * specific language governing permissions and limitations
  68293. * under the License.
  68294. */
  68295. /**
  68296. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68297. */
  68298. /*
  68299. * Licensed to the Apache Software Foundation (ASF) under one
  68300. * or more contributor license agreements. See the NOTICE file
  68301. * distributed with this work for additional information
  68302. * regarding copyright ownership. The ASF licenses this file
  68303. * to you under the Apache License, Version 2.0 (the
  68304. * "License"); you may not use this file except in compliance
  68305. * with the License. You may obtain a copy of the License at
  68306. *
  68307. * http://www.apache.org/licenses/LICENSE-2.0
  68308. *
  68309. * Unless required by applicable law or agreed to in writing,
  68310. * software distributed under the License is distributed on an
  68311. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68312. * KIND, either express or implied. See the License for the
  68313. * specific language governing permissions and limitations
  68314. * under the License.
  68315. */
  68316. var ThemeRiverView =
  68317. /** @class */
  68318. function (_super) {
  68319. __extends(ThemeRiverView, _super);
  68320. function ThemeRiverView() {
  68321. var _this = _super !== null && _super.apply(this, arguments) || this;
  68322. _this.type = ThemeRiverView.type;
  68323. _this._layers = [];
  68324. return _this;
  68325. }
  68326. ThemeRiverView.prototype.render = function (seriesModel, ecModel, api) {
  68327. var data = seriesModel.getData();
  68328. var self = this;
  68329. var group = this.group;
  68330. var layersSeries = seriesModel.getLayerSeries();
  68331. var layoutInfo = data.getLayout('layoutInfo');
  68332. var rect = layoutInfo.rect;
  68333. var boundaryGap = layoutInfo.boundaryGap;
  68334. group.x = 0;
  68335. group.y = rect.y + boundaryGap[0];
  68336. function keyGetter(item) {
  68337. return item.name;
  68338. }
  68339. var dataDiffer = new DataDiffer(this._layersSeries || [], layersSeries, keyGetter, keyGetter);
  68340. var newLayersGroups = [];
  68341. dataDiffer.add(bind(process, this, 'add')).update(bind(process, this, 'update')).remove(bind(process, this, 'remove')).execute();
  68342. function process(status, idx, oldIdx) {
  68343. var oldLayersGroups = self._layers;
  68344. if (status === 'remove') {
  68345. group.remove(oldLayersGroups[idx]);
  68346. return;
  68347. }
  68348. var points0 = [];
  68349. var points1 = [];
  68350. var style;
  68351. var indices = layersSeries[idx].indices;
  68352. var j = 0;
  68353. for (; j < indices.length; j++) {
  68354. var layout = data.getItemLayout(indices[j]);
  68355. var x = layout.x;
  68356. var y0 = layout.y0;
  68357. var y = layout.y;
  68358. points0.push(x, y0);
  68359. points1.push(x, y0 + y);
  68360. style = data.getItemVisual(indices[j], 'style');
  68361. }
  68362. var polygon;
  68363. var textLayout = data.getItemLayout(indices[0]);
  68364. var labelModel = seriesModel.getModel('label');
  68365. var margin = labelModel.get('margin');
  68366. var emphasisModel = seriesModel.getModel('emphasis');
  68367. if (status === 'add') {
  68368. var layerGroup = newLayersGroups[idx] = new Group();
  68369. polygon = new ECPolygon({
  68370. shape: {
  68371. points: points0,
  68372. stackedOnPoints: points1,
  68373. smooth: 0.4,
  68374. stackedOnSmooth: 0.4,
  68375. smoothConstraint: false
  68376. },
  68377. z2: 0
  68378. });
  68379. layerGroup.add(polygon);
  68380. group.add(layerGroup);
  68381. if (seriesModel.isAnimationEnabled()) {
  68382. polygon.setClipPath(createGridClipShape$2(polygon.getBoundingRect(), seriesModel, function () {
  68383. polygon.removeClipPath();
  68384. }));
  68385. }
  68386. } else {
  68387. var layerGroup = oldLayersGroups[oldIdx];
  68388. polygon = layerGroup.childAt(0);
  68389. group.add(layerGroup);
  68390. newLayersGroups[idx] = layerGroup;
  68391. updateProps(polygon, {
  68392. shape: {
  68393. points: points0,
  68394. stackedOnPoints: points1
  68395. }
  68396. }, seriesModel);
  68397. }
  68398. setLabelStyle(polygon, getLabelStatesModels(seriesModel), {
  68399. labelDataIndex: indices[j - 1],
  68400. defaultText: data.getName(indices[j - 1]),
  68401. inheritColor: style.fill
  68402. }, {
  68403. normal: {
  68404. verticalAlign: 'middle' // align: 'right'
  68405. }
  68406. });
  68407. polygon.setTextConfig({
  68408. position: null,
  68409. local: true
  68410. });
  68411. var labelEl = polygon.getTextContent(); // TODO More label position options.
  68412. if (labelEl) {
  68413. labelEl.x = textLayout.x - margin;
  68414. labelEl.y = textLayout.y0 + textLayout.y / 2;
  68415. }
  68416. polygon.useStyle(style);
  68417. data.setItemGraphicEl(idx, polygon);
  68418. setStatesStylesFromModel(polygon, seriesModel);
  68419. enableHoverEmphasis(polygon, emphasisModel.get('focus'), emphasisModel.get('blurScope'));
  68420. }
  68421. this._layersSeries = layersSeries;
  68422. this._layers = newLayersGroups;
  68423. };
  68424. ThemeRiverView.type = 'themeRiver';
  68425. return ThemeRiverView;
  68426. }(ChartView); // add animation to the view
  68427. function createGridClipShape$2(rect, seriesModel, cb) {
  68428. var rectEl = new Rect({
  68429. shape: {
  68430. x: rect.x - 10,
  68431. y: rect.y - 10,
  68432. width: 0,
  68433. height: rect.height + 20
  68434. }
  68435. });
  68436. initProps(rectEl, {
  68437. shape: {
  68438. x: rect.x - 50,
  68439. width: rect.width + 100,
  68440. height: rect.height + 20
  68441. }
  68442. }, seriesModel, cb);
  68443. return rectEl;
  68444. }
  68445. /*
  68446. * Licensed to the Apache Software Foundation (ASF) under one
  68447. * or more contributor license agreements. See the NOTICE file
  68448. * distributed with this work for additional information
  68449. * regarding copyright ownership. The ASF licenses this file
  68450. * to you under the Apache License, Version 2.0 (the
  68451. * "License"); you may not use this file except in compliance
  68452. * with the License. You may obtain a copy of the License at
  68453. *
  68454. * http://www.apache.org/licenses/LICENSE-2.0
  68455. *
  68456. * Unless required by applicable law or agreed to in writing,
  68457. * software distributed under the License is distributed on an
  68458. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68459. * KIND, either express or implied. See the License for the
  68460. * specific language governing permissions and limitations
  68461. * under the License.
  68462. */
  68463. /**
  68464. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68465. */
  68466. /*
  68467. * Licensed to the Apache Software Foundation (ASF) under one
  68468. * or more contributor license agreements. See the NOTICE file
  68469. * distributed with this work for additional information
  68470. * regarding copyright ownership. The ASF licenses this file
  68471. * to you under the Apache License, Version 2.0 (the
  68472. * "License"); you may not use this file except in compliance
  68473. * with the License. You may obtain a copy of the License at
  68474. *
  68475. * http://www.apache.org/licenses/LICENSE-2.0
  68476. *
  68477. * Unless required by applicable law or agreed to in writing,
  68478. * software distributed under the License is distributed on an
  68479. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68480. * KIND, either express or implied. See the License for the
  68481. * specific language governing permissions and limitations
  68482. * under the License.
  68483. */
  68484. var DATA_NAME_INDEX = 2;
  68485. var ThemeRiverSeriesModel =
  68486. /** @class */
  68487. function (_super) {
  68488. __extends(ThemeRiverSeriesModel, _super);
  68489. function ThemeRiverSeriesModel() {
  68490. var _this = _super !== null && _super.apply(this, arguments) || this;
  68491. _this.type = ThemeRiverSeriesModel.type;
  68492. _this.useColorPaletteOnData = true;
  68493. return _this;
  68494. }
  68495. /**
  68496. * @override
  68497. */
  68498. ThemeRiverSeriesModel.prototype.init = function (option) {
  68499. // eslint-disable-next-line
  68500. _super.prototype.init.apply(this, arguments); // Put this function here is for the sake of consistency of code style.
  68501. // Enable legend selection for each data item
  68502. // Use a function instead of direct access because data reference may changed
  68503. this.legendVisualProvider = new LegendVisualProvider(bind(this.getData, this), bind(this.getRawData, this));
  68504. };
  68505. /**
  68506. * If there is no value of a certain point in the time for some event,set it value to 0.
  68507. *
  68508. * @param {Array} data initial data in the option
  68509. * @return {Array}
  68510. */
  68511. ThemeRiverSeriesModel.prototype.fixData = function (data) {
  68512. var rawDataLength = data.length;
  68513. /**
  68514. * Make sure every layer data get the same keys.
  68515. * The value index tells which layer has visited.
  68516. * {
  68517. * 2014/01/01: -1
  68518. * }
  68519. */
  68520. var timeValueKeys = {}; // grouped data by name
  68521. var groupResult = groupData(data, function (item) {
  68522. if (!timeValueKeys.hasOwnProperty(item[0] + '')) {
  68523. timeValueKeys[item[0] + ''] = -1;
  68524. }
  68525. return item[2];
  68526. });
  68527. var layerData = [];
  68528. groupResult.buckets.each(function (items, key) {
  68529. layerData.push({
  68530. name: key,
  68531. dataList: items
  68532. });
  68533. });
  68534. var layerNum = layerData.length;
  68535. for (var k = 0; k < layerNum; ++k) {
  68536. var name_1 = layerData[k].name;
  68537. for (var j = 0; j < layerData[k].dataList.length; ++j) {
  68538. var timeValue = layerData[k].dataList[j][0] + '';
  68539. timeValueKeys[timeValue] = k;
  68540. }
  68541. for (var timeValue in timeValueKeys) {
  68542. if (timeValueKeys.hasOwnProperty(timeValue) && timeValueKeys[timeValue] !== k) {
  68543. timeValueKeys[timeValue] = k;
  68544. data[rawDataLength] = [timeValue, 0, name_1];
  68545. rawDataLength++;
  68546. }
  68547. }
  68548. }
  68549. return data;
  68550. };
  68551. /**
  68552. * @override
  68553. * @param option the initial option that user gived
  68554. * @param ecModel the model object for themeRiver option
  68555. */
  68556. ThemeRiverSeriesModel.prototype.getInitialData = function (option, ecModel) {
  68557. var singleAxisModel = this.getReferringComponents('singleAxis', SINGLE_REFERRING).models[0];
  68558. var axisType = singleAxisModel.get('type'); // filter the data item with the value of label is undefined
  68559. var filterData = filter(option.data, function (dataItem) {
  68560. return dataItem[2] !== undefined;
  68561. }); // ??? TODO design a stage to transfer data for themeRiver and lines?
  68562. var data = this.fixData(filterData || []);
  68563. var nameList = [];
  68564. var nameMap = this.nameMap = createHashMap();
  68565. var count = 0;
  68566. for (var i = 0; i < data.length; ++i) {
  68567. nameList.push(data[i][DATA_NAME_INDEX]);
  68568. if (!nameMap.get(data[i][DATA_NAME_INDEX])) {
  68569. nameMap.set(data[i][DATA_NAME_INDEX], count);
  68570. count++;
  68571. }
  68572. }
  68573. var dimensionsInfo = createDimensions(data, {
  68574. coordDimensions: ['single'],
  68575. dimensionsDefine: [{
  68576. name: 'time',
  68577. type: getDimensionTypeByAxis(axisType)
  68578. }, {
  68579. name: 'value',
  68580. type: 'float'
  68581. }, {
  68582. name: 'name',
  68583. type: 'ordinal'
  68584. }],
  68585. encodeDefine: {
  68586. single: 0,
  68587. value: 1,
  68588. itemName: 2
  68589. }
  68590. });
  68591. var list = new List(dimensionsInfo, this);
  68592. list.initData(data);
  68593. return list;
  68594. };
  68595. /**
  68596. * The raw data is divided into multiple layers and each layer
  68597. * has same name.
  68598. */
  68599. ThemeRiverSeriesModel.prototype.getLayerSeries = function () {
  68600. var data = this.getData();
  68601. var lenCount = data.count();
  68602. var indexArr = [];
  68603. for (var i = 0; i < lenCount; ++i) {
  68604. indexArr[i] = i;
  68605. }
  68606. var timeDim = data.mapDimension('single'); // data group by name
  68607. var groupResult = groupData(indexArr, function (index) {
  68608. return data.get('name', index);
  68609. });
  68610. var layerSeries = [];
  68611. groupResult.buckets.each(function (items, key) {
  68612. items.sort(function (index1, index2) {
  68613. return data.get(timeDim, index1) - data.get(timeDim, index2);
  68614. });
  68615. layerSeries.push({
  68616. name: key,
  68617. indices: items
  68618. });
  68619. });
  68620. return layerSeries;
  68621. };
  68622. /**
  68623. * Get data indices for show tooltip content
  68624. */
  68625. ThemeRiverSeriesModel.prototype.getAxisTooltipData = function (dim, value, baseAxis) {
  68626. if (!isArray(dim)) {
  68627. dim = dim ? [dim] : [];
  68628. }
  68629. var data = this.getData();
  68630. var layerSeries = this.getLayerSeries();
  68631. var indices = [];
  68632. var layerNum = layerSeries.length;
  68633. var nestestValue;
  68634. for (var i = 0; i < layerNum; ++i) {
  68635. var minDist = Number.MAX_VALUE;
  68636. var nearestIdx = -1;
  68637. var pointNum = layerSeries[i].indices.length;
  68638. for (var j = 0; j < pointNum; ++j) {
  68639. var theValue = data.get(dim[0], layerSeries[i].indices[j]);
  68640. var dist = Math.abs(theValue - value);
  68641. if (dist <= minDist) {
  68642. nestestValue = theValue;
  68643. minDist = dist;
  68644. nearestIdx = layerSeries[i].indices[j];
  68645. }
  68646. }
  68647. indices.push(nearestIdx);
  68648. }
  68649. return {
  68650. dataIndices: indices,
  68651. nestestValue: nestestValue
  68652. };
  68653. };
  68654. ThemeRiverSeriesModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  68655. var data = this.getData();
  68656. var name = data.getName(dataIndex);
  68657. var value = data.get(data.mapDimension('value'), dataIndex);
  68658. return createTooltipMarkup('nameValue', {
  68659. name: name,
  68660. value: value
  68661. });
  68662. };
  68663. ThemeRiverSeriesModel.type = 'series.themeRiver';
  68664. ThemeRiverSeriesModel.dependencies = ['singleAxis'];
  68665. ThemeRiverSeriesModel.defaultOption = {
  68666. zlevel: 0,
  68667. z: 2,
  68668. coordinateSystem: 'singleAxis',
  68669. // gap in axis's orthogonal orientation
  68670. boundaryGap: ['10%', '10%'],
  68671. // legendHoverLink: true,
  68672. singleAxisIndex: 0,
  68673. animationEasing: 'linear',
  68674. label: {
  68675. margin: 4,
  68676. show: true,
  68677. position: 'left',
  68678. fontSize: 11
  68679. },
  68680. emphasis: {
  68681. label: {
  68682. show: true
  68683. }
  68684. }
  68685. };
  68686. return ThemeRiverSeriesModel;
  68687. }(SeriesModel);
  68688. /*
  68689. * Licensed to the Apache Software Foundation (ASF) under one
  68690. * or more contributor license agreements. See the NOTICE file
  68691. * distributed with this work for additional information
  68692. * regarding copyright ownership. The ASF licenses this file
  68693. * to you under the Apache License, Version 2.0 (the
  68694. * "License"); you may not use this file except in compliance
  68695. * with the License. You may obtain a copy of the License at
  68696. *
  68697. * http://www.apache.org/licenses/LICENSE-2.0
  68698. *
  68699. * Unless required by applicable law or agreed to in writing,
  68700. * software distributed under the License is distributed on an
  68701. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68702. * KIND, either express or implied. See the License for the
  68703. * specific language governing permissions and limitations
  68704. * under the License.
  68705. */
  68706. /**
  68707. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68708. */
  68709. /*
  68710. * Licensed to the Apache Software Foundation (ASF) under one
  68711. * or more contributor license agreements. See the NOTICE file
  68712. * distributed with this work for additional information
  68713. * regarding copyright ownership. The ASF licenses this file
  68714. * to you under the Apache License, Version 2.0 (the
  68715. * "License"); you may not use this file except in compliance
  68716. * with the License. You may obtain a copy of the License at
  68717. *
  68718. * http://www.apache.org/licenses/LICENSE-2.0
  68719. *
  68720. * Unless required by applicable law or agreed to in writing,
  68721. * software distributed under the License is distributed on an
  68722. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68723. * KIND, either express or implied. See the License for the
  68724. * specific language governing permissions and limitations
  68725. * under the License.
  68726. */
  68727. function themeRiverLayout(ecModel, api) {
  68728. ecModel.eachSeriesByType('themeRiver', function (seriesModel) {
  68729. var data = seriesModel.getData();
  68730. var single = seriesModel.coordinateSystem;
  68731. var layoutInfo = {}; // use the axis boundingRect for view
  68732. var rect = single.getRect();
  68733. layoutInfo.rect = rect;
  68734. var boundaryGap = seriesModel.get('boundaryGap');
  68735. var axis = single.getAxis();
  68736. layoutInfo.boundaryGap = boundaryGap;
  68737. if (axis.orient === 'horizontal') {
  68738. boundaryGap[0] = parsePercent$1(boundaryGap[0], rect.height);
  68739. boundaryGap[1] = parsePercent$1(boundaryGap[1], rect.height);
  68740. var height = rect.height - boundaryGap[0] - boundaryGap[1];
  68741. doThemeRiverLayout(data, seriesModel, height);
  68742. } else {
  68743. boundaryGap[0] = parsePercent$1(boundaryGap[0], rect.width);
  68744. boundaryGap[1] = parsePercent$1(boundaryGap[1], rect.width);
  68745. var width = rect.width - boundaryGap[0] - boundaryGap[1];
  68746. doThemeRiverLayout(data, seriesModel, width);
  68747. }
  68748. data.setLayout('layoutInfo', layoutInfo);
  68749. });
  68750. }
  68751. /**
  68752. * The layout information about themeriver
  68753. *
  68754. * @param data data in the series
  68755. * @param seriesModel the model object of themeRiver series
  68756. * @param height value used to compute every series height
  68757. */
  68758. function doThemeRiverLayout(data, seriesModel, height) {
  68759. if (!data.count()) {
  68760. return;
  68761. }
  68762. var coordSys = seriesModel.coordinateSystem; // the data in each layer are organized into a series.
  68763. var layerSeries = seriesModel.getLayerSeries(); // the points in each layer.
  68764. var timeDim = data.mapDimension('single');
  68765. var valueDim = data.mapDimension('value');
  68766. var layerPoints = map(layerSeries, function (singleLayer) {
  68767. return map(singleLayer.indices, function (idx) {
  68768. var pt = coordSys.dataToPoint(data.get(timeDim, idx));
  68769. pt[1] = data.get(valueDim, idx);
  68770. return pt;
  68771. });
  68772. });
  68773. var base = computeBaseline(layerPoints);
  68774. var baseLine = base.y0;
  68775. var ky = height / base.max; // set layout information for each item.
  68776. var n = layerSeries.length;
  68777. var m = layerSeries[0].indices.length;
  68778. var baseY0;
  68779. for (var j = 0; j < m; ++j) {
  68780. baseY0 = baseLine[j] * ky;
  68781. data.setItemLayout(layerSeries[0].indices[j], {
  68782. layerIndex: 0,
  68783. x: layerPoints[0][j][0],
  68784. y0: baseY0,
  68785. y: layerPoints[0][j][1] * ky
  68786. });
  68787. for (var i = 1; i < n; ++i) {
  68788. baseY0 += layerPoints[i - 1][j][1] * ky;
  68789. data.setItemLayout(layerSeries[i].indices[j], {
  68790. layerIndex: i,
  68791. x: layerPoints[i][j][0],
  68792. y0: baseY0,
  68793. y: layerPoints[i][j][1] * ky
  68794. });
  68795. }
  68796. }
  68797. }
  68798. /**
  68799. * Compute the baseLine of the rawdata
  68800. * Inspired by Lee Byron's paper Stacked Graphs - Geometry & Aesthetics
  68801. *
  68802. * @param data the points in each layer
  68803. */
  68804. function computeBaseline(data) {
  68805. var layerNum = data.length;
  68806. var pointNum = data[0].length;
  68807. var sums = [];
  68808. var y0 = [];
  68809. var max = 0;
  68810. for (var i = 0; i < pointNum; ++i) {
  68811. var temp = 0;
  68812. for (var j = 0; j < layerNum; ++j) {
  68813. temp += data[j][i][1];
  68814. }
  68815. if (temp > max) {
  68816. max = temp;
  68817. }
  68818. sums.push(temp);
  68819. }
  68820. for (var k = 0; k < pointNum; ++k) {
  68821. y0[k] = (max - sums[k]) / 2;
  68822. }
  68823. max = 0;
  68824. for (var l = 0; l < pointNum; ++l) {
  68825. var sum = sums[l] + y0[l];
  68826. if (sum > max) {
  68827. max = sum;
  68828. }
  68829. }
  68830. return {
  68831. y0: y0,
  68832. max: max
  68833. };
  68834. }
  68835. /*
  68836. * Licensed to the Apache Software Foundation (ASF) under one
  68837. * or more contributor license agreements. See the NOTICE file
  68838. * distributed with this work for additional information
  68839. * regarding copyright ownership. The ASF licenses this file
  68840. * to you under the Apache License, Version 2.0 (the
  68841. * "License"); you may not use this file except in compliance
  68842. * with the License. You may obtain a copy of the License at
  68843. *
  68844. * http://www.apache.org/licenses/LICENSE-2.0
  68845. *
  68846. * Unless required by applicable law or agreed to in writing,
  68847. * software distributed under the License is distributed on an
  68848. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68849. * KIND, either express or implied. See the License for the
  68850. * specific language governing permissions and limitations
  68851. * under the License.
  68852. */
  68853. /**
  68854. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68855. */
  68856. function install$25(registers) {
  68857. registers.registerChartView(ThemeRiverView);
  68858. registers.registerSeriesModel(ThemeRiverSeriesModel);
  68859. registers.registerLayout(themeRiverLayout);
  68860. registers.registerProcessor(dataFilter('themeRiver'));
  68861. }
  68862. /*
  68863. * Licensed to the Apache Software Foundation (ASF) under one
  68864. * or more contributor license agreements. See the NOTICE file
  68865. * distributed with this work for additional information
  68866. * regarding copyright ownership. The ASF licenses this file
  68867. * to you under the Apache License, Version 2.0 (the
  68868. * "License"); you may not use this file except in compliance
  68869. * with the License. You may obtain a copy of the License at
  68870. *
  68871. * http://www.apache.org/licenses/LICENSE-2.0
  68872. *
  68873. * Unless required by applicable law or agreed to in writing,
  68874. * software distributed under the License is distributed on an
  68875. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68876. * KIND, either express or implied. See the License for the
  68877. * specific language governing permissions and limitations
  68878. * under the License.
  68879. */
  68880. /**
  68881. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68882. */
  68883. /*
  68884. * Licensed to the Apache Software Foundation (ASF) under one
  68885. * or more contributor license agreements. See the NOTICE file
  68886. * distributed with this work for additional information
  68887. * regarding copyright ownership. The ASF licenses this file
  68888. * to you under the Apache License, Version 2.0 (the
  68889. * "License"); you may not use this file except in compliance
  68890. * with the License. You may obtain a copy of the License at
  68891. *
  68892. * http://www.apache.org/licenses/LICENSE-2.0
  68893. *
  68894. * Unless required by applicable law or agreed to in writing,
  68895. * software distributed under the License is distributed on an
  68896. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68897. * KIND, either express or implied. See the License for the
  68898. * specific language governing permissions and limitations
  68899. * under the License.
  68900. */
  68901. use(install$25);
  68902. /*
  68903. * Licensed to the Apache Software Foundation (ASF) under one
  68904. * or more contributor license agreements. See the NOTICE file
  68905. * distributed with this work for additional information
  68906. * regarding copyright ownership. The ASF licenses this file
  68907. * to you under the Apache License, Version 2.0 (the
  68908. * "License"); you may not use this file except in compliance
  68909. * with the License. You may obtain a copy of the License at
  68910. *
  68911. * http://www.apache.org/licenses/LICENSE-2.0
  68912. *
  68913. * Unless required by applicable law or agreed to in writing,
  68914. * software distributed under the License is distributed on an
  68915. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68916. * KIND, either express or implied. See the License for the
  68917. * specific language governing permissions and limitations
  68918. * under the License.
  68919. */
  68920. /**
  68921. * AUTO-GENERATED FILE. DO NOT MODIFY.
  68922. */
  68923. /*
  68924. * Licensed to the Apache Software Foundation (ASF) under one
  68925. * or more contributor license agreements. See the NOTICE file
  68926. * distributed with this work for additional information
  68927. * regarding copyright ownership. The ASF licenses this file
  68928. * to you under the Apache License, Version 2.0 (the
  68929. * "License"); you may not use this file except in compliance
  68930. * with the License. You may obtain a copy of the License at
  68931. *
  68932. * http://www.apache.org/licenses/LICENSE-2.0
  68933. *
  68934. * Unless required by applicable law or agreed to in writing,
  68935. * software distributed under the License is distributed on an
  68936. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  68937. * KIND, either express or implied. See the License for the
  68938. * specific language governing permissions and limitations
  68939. * under the License.
  68940. */
  68941. var BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'borderWidth']; // index: +isHorizontal
  68942. var LAYOUT_ATTRS = [{
  68943. xy: 'x',
  68944. wh: 'width',
  68945. index: 0,
  68946. posDesc: ['left', 'right']
  68947. }, {
  68948. xy: 'y',
  68949. wh: 'height',
  68950. index: 1,
  68951. posDesc: ['top', 'bottom']
  68952. }];
  68953. var pathForLineWidth = new Circle();
  68954. var PictorialBarView =
  68955. /** @class */
  68956. function (_super) {
  68957. __extends(PictorialBarView, _super);
  68958. function PictorialBarView() {
  68959. var _this = _super !== null && _super.apply(this, arguments) || this;
  68960. _this.type = PictorialBarView.type;
  68961. return _this;
  68962. }
  68963. PictorialBarView.prototype.render = function (seriesModel, ecModel, api) {
  68964. var group = this.group;
  68965. var data = seriesModel.getData();
  68966. var oldData = this._data;
  68967. var cartesian = seriesModel.coordinateSystem;
  68968. var baseAxis = cartesian.getBaseAxis();
  68969. var isHorizontal = baseAxis.isHorizontal();
  68970. var coordSysRect = cartesian.master.getRect();
  68971. var opt = {
  68972. ecSize: {
  68973. width: api.getWidth(),
  68974. height: api.getHeight()
  68975. },
  68976. seriesModel: seriesModel,
  68977. coordSys: cartesian,
  68978. coordSysExtent: [[coordSysRect.x, coordSysRect.x + coordSysRect.width], [coordSysRect.y, coordSysRect.y + coordSysRect.height]],
  68979. isHorizontal: isHorizontal,
  68980. valueDim: LAYOUT_ATTRS[+isHorizontal],
  68981. categoryDim: LAYOUT_ATTRS[1 - +isHorizontal]
  68982. };
  68983. data.diff(oldData).add(function (dataIndex) {
  68984. if (!data.hasValue(dataIndex)) {
  68985. return;
  68986. }
  68987. var itemModel = getItemModel(data, dataIndex);
  68988. var symbolMeta = getSymbolMeta(data, dataIndex, itemModel, opt);
  68989. var bar = createBar(data, opt, symbolMeta);
  68990. data.setItemGraphicEl(dataIndex, bar);
  68991. group.add(bar);
  68992. updateCommon$1(bar, opt, symbolMeta);
  68993. }).update(function (newIndex, oldIndex) {
  68994. var bar = oldData.getItemGraphicEl(oldIndex);
  68995. if (!data.hasValue(newIndex)) {
  68996. group.remove(bar);
  68997. return;
  68998. }
  68999. var itemModel = getItemModel(data, newIndex);
  69000. var symbolMeta = getSymbolMeta(data, newIndex, itemModel, opt);
  69001. var pictorialShapeStr = getShapeStr(data, symbolMeta);
  69002. if (bar && pictorialShapeStr !== bar.__pictorialShapeStr) {
  69003. group.remove(bar);
  69004. data.setItemGraphicEl(newIndex, null);
  69005. bar = null;
  69006. }
  69007. if (bar) {
  69008. updateBar(bar, opt, symbolMeta);
  69009. } else {
  69010. bar = createBar(data, opt, symbolMeta, true);
  69011. }
  69012. data.setItemGraphicEl(newIndex, bar);
  69013. bar.__pictorialSymbolMeta = symbolMeta; // Add back
  69014. group.add(bar);
  69015. updateCommon$1(bar, opt, symbolMeta);
  69016. }).remove(function (dataIndex) {
  69017. var bar = oldData.getItemGraphicEl(dataIndex);
  69018. bar && removeBar(oldData, dataIndex, bar.__pictorialSymbolMeta.animationModel, bar);
  69019. }).execute();
  69020. this._data = data;
  69021. return this.group;
  69022. };
  69023. PictorialBarView.prototype.remove = function (ecModel, api) {
  69024. var group = this.group;
  69025. var data = this._data;
  69026. if (ecModel.get('animation')) {
  69027. if (data) {
  69028. data.eachItemGraphicEl(function (bar) {
  69029. removeBar(data, getECData(bar).dataIndex, ecModel, bar);
  69030. });
  69031. }
  69032. } else {
  69033. group.removeAll();
  69034. }
  69035. };
  69036. PictorialBarView.type = 'pictorialBar';
  69037. return PictorialBarView;
  69038. }(ChartView); // Set or calculate default value about symbol, and calculate layout info.
  69039. function getSymbolMeta(data, dataIndex, itemModel, opt) {
  69040. var layout = data.getItemLayout(dataIndex);
  69041. var symbolRepeat = itemModel.get('symbolRepeat');
  69042. var symbolClip = itemModel.get('symbolClip');
  69043. var symbolPosition = itemModel.get('symbolPosition') || 'start';
  69044. var symbolRotate = itemModel.get('symbolRotate');
  69045. var rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  69046. var symbolPatternSize = itemModel.get('symbolPatternSize') || 2;
  69047. var isAnimationEnabled = itemModel.isAnimationEnabled();
  69048. var symbolMeta = {
  69049. dataIndex: dataIndex,
  69050. layout: layout,
  69051. itemModel: itemModel,
  69052. symbolType: data.getItemVisual(dataIndex, 'symbol') || 'circle',
  69053. style: data.getItemVisual(dataIndex, 'style'),
  69054. symbolClip: symbolClip,
  69055. symbolRepeat: symbolRepeat,
  69056. symbolRepeatDirection: itemModel.get('symbolRepeatDirection'),
  69057. symbolPatternSize: symbolPatternSize,
  69058. rotation: rotation,
  69059. animationModel: isAnimationEnabled ? itemModel : null,
  69060. hoverScale: isAnimationEnabled && itemModel.get(['emphasis', 'scale']),
  69061. z2: itemModel.getShallow('z', true) || 0
  69062. };
  69063. prepareBarLength(itemModel, symbolRepeat, layout, opt, symbolMeta);
  69064. prepareSymbolSize(data, dataIndex, layout, symbolRepeat, symbolClip, symbolMeta.boundingLength, symbolMeta.pxSign, symbolPatternSize, opt, symbolMeta);
  69065. prepareLineWidth(itemModel, symbolMeta.symbolScale, rotation, opt, symbolMeta);
  69066. var symbolSize = symbolMeta.symbolSize;
  69067. var symbolOffset = itemModel.get('symbolOffset');
  69068. if (isArray(symbolOffset)) {
  69069. symbolOffset = [parsePercent$1(symbolOffset[0], symbolSize[0]), parsePercent$1(symbolOffset[1], symbolSize[1])];
  69070. }
  69071. prepareLayoutInfo(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, symbolMeta.valueLineWidth, symbolMeta.boundingLength, symbolMeta.repeatCutLength, opt, symbolMeta);
  69072. return symbolMeta;
  69073. } // bar length can be negative.
  69074. function prepareBarLength(itemModel, symbolRepeat, layout, opt, outputSymbolMeta) {
  69075. var valueDim = opt.valueDim;
  69076. var symbolBoundingData = itemModel.get('symbolBoundingData');
  69077. var valueAxis = opt.coordSys.getOtherAxis(opt.coordSys.getBaseAxis());
  69078. var zeroPx = valueAxis.toGlobalCoord(valueAxis.dataToCoord(0));
  69079. var pxSignIdx = 1 - +(layout[valueDim.wh] <= 0);
  69080. var boundingLength;
  69081. if (isArray(symbolBoundingData)) {
  69082. var symbolBoundingExtent = [convertToCoordOnAxis(valueAxis, symbolBoundingData[0]) - zeroPx, convertToCoordOnAxis(valueAxis, symbolBoundingData[1]) - zeroPx];
  69083. symbolBoundingExtent[1] < symbolBoundingExtent[0] && symbolBoundingExtent.reverse();
  69084. boundingLength = symbolBoundingExtent[pxSignIdx];
  69085. } else if (symbolBoundingData != null) {
  69086. boundingLength = convertToCoordOnAxis(valueAxis, symbolBoundingData) - zeroPx;
  69087. } else if (symbolRepeat) {
  69088. boundingLength = opt.coordSysExtent[valueDim.index][pxSignIdx] - zeroPx;
  69089. } else {
  69090. boundingLength = layout[valueDim.wh];
  69091. }
  69092. outputSymbolMeta.boundingLength = boundingLength;
  69093. if (symbolRepeat) {
  69094. outputSymbolMeta.repeatCutLength = layout[valueDim.wh];
  69095. }
  69096. outputSymbolMeta.pxSign = boundingLength > 0 ? 1 : boundingLength < 0 ? -1 : 0;
  69097. }
  69098. function convertToCoordOnAxis(axis, value) {
  69099. return axis.toGlobalCoord(axis.dataToCoord(axis.scale.parse(value)));
  69100. } // Support ['100%', '100%']
  69101. function prepareSymbolSize(data, dataIndex, layout, symbolRepeat, symbolClip, boundingLength, pxSign, symbolPatternSize, opt, outputSymbolMeta) {
  69102. var valueDim = opt.valueDim;
  69103. var categoryDim = opt.categoryDim;
  69104. var categorySize = Math.abs(layout[categoryDim.wh]);
  69105. var symbolSize = data.getItemVisual(dataIndex, 'symbolSize');
  69106. var parsedSymbolSize;
  69107. if (isArray(symbolSize)) {
  69108. parsedSymbolSize = symbolSize.slice();
  69109. } else {
  69110. if (symbolSize == null) {
  69111. // will parse to number below
  69112. parsedSymbolSize = ['100%', '100%'];
  69113. } else {
  69114. parsedSymbolSize = [symbolSize, symbolSize];
  69115. }
  69116. } // Note: percentage symbolSize (like '100%') do not consider lineWidth, because it is
  69117. // to complicated to calculate real percent value if considering scaled lineWidth.
  69118. // So the actual size will bigger than layout size if lineWidth is bigger than zero,
  69119. // which can be tolerated in pictorial chart.
  69120. parsedSymbolSize[categoryDim.index] = parsePercent$1(parsedSymbolSize[categoryDim.index], categorySize);
  69121. parsedSymbolSize[valueDim.index] = parsePercent$1(parsedSymbolSize[valueDim.index], symbolRepeat ? categorySize : Math.abs(boundingLength));
  69122. outputSymbolMeta.symbolSize = parsedSymbolSize; // If x or y is less than zero, show reversed shape.
  69123. var symbolScale = outputSymbolMeta.symbolScale = [parsedSymbolSize[0] / symbolPatternSize, parsedSymbolSize[1] / symbolPatternSize]; // Follow convention, 'right' and 'top' is the normal scale.
  69124. symbolScale[valueDim.index] *= (opt.isHorizontal ? -1 : 1) * pxSign;
  69125. }
  69126. function prepareLineWidth(itemModel, symbolScale, rotation, opt, outputSymbolMeta) {
  69127. // In symbols are drawn with scale, so do not need to care about the case that width
  69128. // or height are too small. But symbol use strokeNoScale, where acture lineWidth should
  69129. // be calculated.
  69130. var valueLineWidth = itemModel.get(BAR_BORDER_WIDTH_QUERY) || 0;
  69131. if (valueLineWidth) {
  69132. pathForLineWidth.attr({
  69133. scaleX: symbolScale[0],
  69134. scaleY: symbolScale[1],
  69135. rotation: rotation
  69136. });
  69137. pathForLineWidth.updateTransform();
  69138. valueLineWidth /= pathForLineWidth.getLineScale();
  69139. valueLineWidth *= symbolScale[opt.valueDim.index];
  69140. }
  69141. outputSymbolMeta.valueLineWidth = valueLineWidth;
  69142. }
  69143. function prepareLayoutInfo(itemModel, symbolSize, layout, symbolRepeat, symbolClip, symbolOffset, symbolPosition, valueLineWidth, boundingLength, repeatCutLength, opt, outputSymbolMeta) {
  69144. var categoryDim = opt.categoryDim;
  69145. var valueDim = opt.valueDim;
  69146. var pxSign = outputSymbolMeta.pxSign;
  69147. var unitLength = Math.max(symbolSize[valueDim.index] + valueLineWidth, 0);
  69148. var pathLen = unitLength; // Note: rotation will not effect the layout of symbols, because user may
  69149. // want symbols to rotate on its center, which should not be translated
  69150. // when rotating.
  69151. if (symbolRepeat) {
  69152. var absBoundingLength = Math.abs(boundingLength);
  69153. var symbolMargin = retrieve(itemModel.get('symbolMargin'), '15%') + '';
  69154. var hasEndGap = false;
  69155. if (symbolMargin.lastIndexOf('!') === symbolMargin.length - 1) {
  69156. hasEndGap = true;
  69157. symbolMargin = symbolMargin.slice(0, symbolMargin.length - 1);
  69158. }
  69159. var symbolMarginNumeric = parsePercent$1(symbolMargin, symbolSize[valueDim.index]);
  69160. var uLenWithMargin = Math.max(unitLength + symbolMarginNumeric * 2, 0); // When symbol margin is less than 0, margin at both ends will be subtracted
  69161. // to ensure that all of the symbols will not be overflow the given area.
  69162. var endFix = hasEndGap ? 0 : symbolMarginNumeric * 2; // Both final repeatTimes and final symbolMarginNumeric area calculated based on
  69163. // boundingLength.
  69164. var repeatSpecified = isNumeric(symbolRepeat);
  69165. var repeatTimes = repeatSpecified ? symbolRepeat : toIntTimes((absBoundingLength + endFix) / uLenWithMargin); // Adjust calculate margin, to ensure each symbol is displayed
  69166. // entirely in the given layout area.
  69167. var mDiff = absBoundingLength - repeatTimes * unitLength;
  69168. symbolMarginNumeric = mDiff / 2 / (hasEndGap ? repeatTimes : repeatTimes - 1);
  69169. uLenWithMargin = unitLength + symbolMarginNumeric * 2;
  69170. endFix = hasEndGap ? 0 : symbolMarginNumeric * 2; // Update repeatTimes when not all symbol will be shown.
  69171. if (!repeatSpecified && symbolRepeat !== 'fixed') {
  69172. repeatTimes = repeatCutLength ? toIntTimes((Math.abs(repeatCutLength) + endFix) / uLenWithMargin) : 0;
  69173. }
  69174. pathLen = repeatTimes * uLenWithMargin - endFix;
  69175. outputSymbolMeta.repeatTimes = repeatTimes;
  69176. outputSymbolMeta.symbolMargin = symbolMarginNumeric;
  69177. }
  69178. var sizeFix = pxSign * (pathLen / 2);
  69179. var pathPosition = outputSymbolMeta.pathPosition = [];
  69180. pathPosition[categoryDim.index] = layout[categoryDim.wh] / 2;
  69181. pathPosition[valueDim.index] = symbolPosition === 'start' ? sizeFix : symbolPosition === 'end' ? boundingLength - sizeFix : boundingLength / 2; // 'center'
  69182. if (symbolOffset) {
  69183. pathPosition[0] += symbolOffset[0];
  69184. pathPosition[1] += symbolOffset[1];
  69185. }
  69186. var bundlePosition = outputSymbolMeta.bundlePosition = [];
  69187. bundlePosition[categoryDim.index] = layout[categoryDim.xy];
  69188. bundlePosition[valueDim.index] = layout[valueDim.xy];
  69189. var barRectShape = outputSymbolMeta.barRectShape = extend({}, layout);
  69190. barRectShape[valueDim.wh] = pxSign * Math.max(Math.abs(layout[valueDim.wh]), Math.abs(pathPosition[valueDim.index] + sizeFix));
  69191. barRectShape[categoryDim.wh] = layout[categoryDim.wh];
  69192. var clipShape = outputSymbolMeta.clipShape = {}; // Consider that symbol may be overflow layout rect.
  69193. clipShape[categoryDim.xy] = -layout[categoryDim.xy];
  69194. clipShape[categoryDim.wh] = opt.ecSize[categoryDim.wh];
  69195. clipShape[valueDim.xy] = 0;
  69196. clipShape[valueDim.wh] = layout[valueDim.wh];
  69197. }
  69198. function createPath(symbolMeta) {
  69199. var symbolPatternSize = symbolMeta.symbolPatternSize;
  69200. var path = createSymbol( // Consider texture img, make a big size.
  69201. symbolMeta.symbolType, -symbolPatternSize / 2, -symbolPatternSize / 2, symbolPatternSize, symbolPatternSize);
  69202. path.attr({
  69203. culling: true
  69204. });
  69205. path.type !== 'image' && path.setStyle({
  69206. strokeNoScale: true
  69207. });
  69208. return path;
  69209. }
  69210. function createOrUpdateRepeatSymbols(bar, opt, symbolMeta, isUpdate) {
  69211. var bundle = bar.__pictorialBundle;
  69212. var symbolSize = symbolMeta.symbolSize;
  69213. var valueLineWidth = symbolMeta.valueLineWidth;
  69214. var pathPosition = symbolMeta.pathPosition;
  69215. var valueDim = opt.valueDim;
  69216. var repeatTimes = symbolMeta.repeatTimes || 0;
  69217. var index = 0;
  69218. var unit = symbolSize[opt.valueDim.index] + valueLineWidth + symbolMeta.symbolMargin * 2;
  69219. eachPath(bar, function (path) {
  69220. path.__pictorialAnimationIndex = index;
  69221. path.__pictorialRepeatTimes = repeatTimes;
  69222. if (index < repeatTimes) {
  69223. updateAttr(path, null, makeTarget(index), symbolMeta, isUpdate);
  69224. } else {
  69225. updateAttr(path, null, {
  69226. scaleX: 0,
  69227. scaleY: 0
  69228. }, symbolMeta, isUpdate, function () {
  69229. bundle.remove(path);
  69230. });
  69231. } // updateHoverAnimation(path, symbolMeta);
  69232. index++;
  69233. });
  69234. for (; index < repeatTimes; index++) {
  69235. var path = createPath(symbolMeta);
  69236. path.__pictorialAnimationIndex = index;
  69237. path.__pictorialRepeatTimes = repeatTimes;
  69238. bundle.add(path);
  69239. var target = makeTarget(index);
  69240. updateAttr(path, {
  69241. x: target.x,
  69242. y: target.y,
  69243. scaleX: 0,
  69244. scaleY: 0
  69245. }, {
  69246. scaleX: target.scaleX,
  69247. scaleY: target.scaleY,
  69248. rotation: target.rotation
  69249. }, symbolMeta, isUpdate);
  69250. }
  69251. function makeTarget(index) {
  69252. var position = pathPosition.slice(); // (start && pxSign > 0) || (end && pxSign < 0): i = repeatTimes - index
  69253. // Otherwise: i = index;
  69254. var pxSign = symbolMeta.pxSign;
  69255. var i = index;
  69256. if (symbolMeta.symbolRepeatDirection === 'start' ? pxSign > 0 : pxSign < 0) {
  69257. i = repeatTimes - 1 - index;
  69258. }
  69259. position[valueDim.index] = unit * (i - repeatTimes / 2 + 0.5) + pathPosition[valueDim.index];
  69260. return {
  69261. x: position[0],
  69262. y: position[1],
  69263. scaleX: symbolMeta.symbolScale[0],
  69264. scaleY: symbolMeta.symbolScale[1],
  69265. rotation: symbolMeta.rotation
  69266. };
  69267. }
  69268. }
  69269. function createOrUpdateSingleSymbol(bar, opt, symbolMeta, isUpdate) {
  69270. var bundle = bar.__pictorialBundle;
  69271. var mainPath = bar.__pictorialMainPath;
  69272. if (!mainPath) {
  69273. mainPath = bar.__pictorialMainPath = createPath(symbolMeta);
  69274. bundle.add(mainPath);
  69275. updateAttr(mainPath, {
  69276. x: symbolMeta.pathPosition[0],
  69277. y: symbolMeta.pathPosition[1],
  69278. scaleX: 0,
  69279. scaleY: 0,
  69280. rotation: symbolMeta.rotation
  69281. }, {
  69282. scaleX: symbolMeta.symbolScale[0],
  69283. scaleY: symbolMeta.symbolScale[1]
  69284. }, symbolMeta, isUpdate);
  69285. } else {
  69286. updateAttr(mainPath, null, {
  69287. x: symbolMeta.pathPosition[0],
  69288. y: symbolMeta.pathPosition[1],
  69289. scaleX: symbolMeta.symbolScale[0],
  69290. scaleY: symbolMeta.symbolScale[1],
  69291. rotation: symbolMeta.rotation
  69292. }, symbolMeta, isUpdate);
  69293. }
  69294. } // bar rect is used for label.
  69295. function createOrUpdateBarRect(bar, symbolMeta, isUpdate) {
  69296. var rectShape = extend({}, symbolMeta.barRectShape);
  69297. var barRect = bar.__pictorialBarRect;
  69298. if (!barRect) {
  69299. barRect = bar.__pictorialBarRect = new Rect({
  69300. z2: 2,
  69301. shape: rectShape,
  69302. silent: true,
  69303. style: {
  69304. stroke: 'transparent',
  69305. fill: 'transparent',
  69306. lineWidth: 0
  69307. }
  69308. });
  69309. bar.add(barRect);
  69310. } else {
  69311. updateAttr(barRect, null, {
  69312. shape: rectShape
  69313. }, symbolMeta, isUpdate);
  69314. }
  69315. }
  69316. function createOrUpdateClip(bar, opt, symbolMeta, isUpdate) {
  69317. // If not clip, symbol will be remove and rebuilt.
  69318. if (symbolMeta.symbolClip) {
  69319. var clipPath = bar.__pictorialClipPath;
  69320. var clipShape = extend({}, symbolMeta.clipShape);
  69321. var valueDim = opt.valueDim;
  69322. var animationModel = symbolMeta.animationModel;
  69323. var dataIndex = symbolMeta.dataIndex;
  69324. if (clipPath) {
  69325. updateProps(clipPath, {
  69326. shape: clipShape
  69327. }, animationModel, dataIndex);
  69328. } else {
  69329. clipShape[valueDim.wh] = 0;
  69330. clipPath = new Rect({
  69331. shape: clipShape
  69332. });
  69333. bar.__pictorialBundle.setClipPath(clipPath);
  69334. bar.__pictorialClipPath = clipPath;
  69335. var target = {};
  69336. target[valueDim.wh] = symbolMeta.clipShape[valueDim.wh];
  69337. graphic[isUpdate ? 'updateProps' : 'initProps'](clipPath, {
  69338. shape: target
  69339. }, animationModel, dataIndex);
  69340. }
  69341. }
  69342. }
  69343. function getItemModel(data, dataIndex) {
  69344. var itemModel = data.getItemModel(dataIndex);
  69345. itemModel.getAnimationDelayParams = getAnimationDelayParams;
  69346. itemModel.isAnimationEnabled = isAnimationEnabled;
  69347. return itemModel;
  69348. }
  69349. function getAnimationDelayParams(path) {
  69350. // The order is the same as the z-order, see `symbolRepeatDiretion`.
  69351. return {
  69352. index: path.__pictorialAnimationIndex,
  69353. count: path.__pictorialRepeatTimes
  69354. };
  69355. }
  69356. function isAnimationEnabled() {
  69357. // `animation` prop can be set on itemModel in pictorial bar chart.
  69358. return this.parentModel.isAnimationEnabled() && !!this.getShallow('animation');
  69359. }
  69360. function createBar(data, opt, symbolMeta, isUpdate) {
  69361. // bar is the main element for each data.
  69362. var bar = new Group(); // bundle is used for location and clip.
  69363. var bundle = new Group();
  69364. bar.add(bundle);
  69365. bar.__pictorialBundle = bundle;
  69366. bundle.x = symbolMeta.bundlePosition[0];
  69367. bundle.y = symbolMeta.bundlePosition[1];
  69368. if (symbolMeta.symbolRepeat) {
  69369. createOrUpdateRepeatSymbols(bar, opt, symbolMeta);
  69370. } else {
  69371. createOrUpdateSingleSymbol(bar, opt, symbolMeta);
  69372. }
  69373. createOrUpdateBarRect(bar, symbolMeta, isUpdate);
  69374. createOrUpdateClip(bar, opt, symbolMeta, isUpdate);
  69375. bar.__pictorialShapeStr = getShapeStr(data, symbolMeta);
  69376. bar.__pictorialSymbolMeta = symbolMeta;
  69377. return bar;
  69378. }
  69379. function updateBar(bar, opt, symbolMeta) {
  69380. var animationModel = symbolMeta.animationModel;
  69381. var dataIndex = symbolMeta.dataIndex;
  69382. var bundle = bar.__pictorialBundle;
  69383. updateProps(bundle, {
  69384. x: symbolMeta.bundlePosition[0],
  69385. y: symbolMeta.bundlePosition[1]
  69386. }, animationModel, dataIndex);
  69387. if (symbolMeta.symbolRepeat) {
  69388. createOrUpdateRepeatSymbols(bar, opt, symbolMeta, true);
  69389. } else {
  69390. createOrUpdateSingleSymbol(bar, opt, symbolMeta, true);
  69391. }
  69392. createOrUpdateBarRect(bar, symbolMeta, true);
  69393. createOrUpdateClip(bar, opt, symbolMeta, true);
  69394. }
  69395. function removeBar(data, dataIndex, animationModel, bar) {
  69396. // Not show text when animating
  69397. var labelRect = bar.__pictorialBarRect;
  69398. labelRect && labelRect.removeTextContent();
  69399. var pathes = [];
  69400. eachPath(bar, function (path) {
  69401. pathes.push(path);
  69402. });
  69403. bar.__pictorialMainPath && pathes.push(bar.__pictorialMainPath); // I do not find proper remove animation for clip yet.
  69404. bar.__pictorialClipPath && (animationModel = null);
  69405. each$1(pathes, function (path) {
  69406. removeElement(path, {
  69407. scaleX: 0,
  69408. scaleY: 0
  69409. }, animationModel, dataIndex, function () {
  69410. bar.parent && bar.parent.remove(bar);
  69411. });
  69412. });
  69413. data.setItemGraphicEl(dataIndex, null);
  69414. }
  69415. function getShapeStr(data, symbolMeta) {
  69416. return [data.getItemVisual(symbolMeta.dataIndex, 'symbol') || 'none', !!symbolMeta.symbolRepeat, !!symbolMeta.symbolClip].join(':');
  69417. }
  69418. function eachPath(bar, cb, context) {
  69419. // Do not use Group#eachChild, because it do not support remove.
  69420. each$1(bar.__pictorialBundle.children(), function (el) {
  69421. el !== bar.__pictorialBarRect && cb.call(context, el);
  69422. });
  69423. }
  69424. function updateAttr(el, immediateAttrs, animationAttrs, symbolMeta, isUpdate, cb) {
  69425. immediateAttrs && el.attr(immediateAttrs); // when symbolCip used, only clip path has init animation, otherwise it would be weird effect.
  69426. if (symbolMeta.symbolClip && !isUpdate) {
  69427. animationAttrs && el.attr(animationAttrs);
  69428. } else {
  69429. animationAttrs && graphic[isUpdate ? 'updateProps' : 'initProps'](el, animationAttrs, symbolMeta.animationModel, symbolMeta.dataIndex, cb);
  69430. }
  69431. }
  69432. function updateCommon$1(bar, opt, symbolMeta) {
  69433. var dataIndex = symbolMeta.dataIndex;
  69434. var itemModel = symbolMeta.itemModel; // Color must be excluded.
  69435. // Because symbol provide setColor individually to set fill and stroke
  69436. var emphasisModel = itemModel.getModel('emphasis');
  69437. var emphasisStyle = emphasisModel.getModel('itemStyle').getItemStyle();
  69438. var blurStyle = itemModel.getModel(['blur', 'itemStyle']).getItemStyle();
  69439. var selectStyle = itemModel.getModel(['select', 'itemStyle']).getItemStyle();
  69440. var cursorStyle = itemModel.getShallow('cursor');
  69441. var focus = emphasisModel.get('focus');
  69442. var blurScope = emphasisModel.get('blurScope');
  69443. var hoverScale = emphasisModel.get('scale');
  69444. eachPath(bar, function (path) {
  69445. if (path instanceof ZRImage) {
  69446. var pathStyle = path.style;
  69447. path.useStyle(extend({
  69448. // TODO other properties like dx, dy ?
  69449. image: pathStyle.image,
  69450. x: pathStyle.x,
  69451. y: pathStyle.y,
  69452. width: pathStyle.width,
  69453. height: pathStyle.height
  69454. }, symbolMeta.style));
  69455. } else {
  69456. path.useStyle(symbolMeta.style);
  69457. }
  69458. var emphasisState = path.ensureState('emphasis');
  69459. emphasisState.style = emphasisStyle;
  69460. if (hoverScale) {
  69461. // NOTE: Must after scale is set after updateAttr
  69462. emphasisState.scaleX = path.scaleX * 1.1;
  69463. emphasisState.scaleY = path.scaleY * 1.1;
  69464. }
  69465. path.ensureState('blur').style = blurStyle;
  69466. path.ensureState('select').style = selectStyle;
  69467. cursorStyle && (path.cursor = cursorStyle);
  69468. path.z2 = symbolMeta.z2;
  69469. });
  69470. var barPositionOutside = opt.valueDim.posDesc[+(symbolMeta.boundingLength > 0)];
  69471. var barRect = bar.__pictorialBarRect;
  69472. setLabelStyle(barRect, getLabelStatesModels(itemModel), {
  69473. labelFetcher: opt.seriesModel,
  69474. labelDataIndex: dataIndex,
  69475. defaultText: getDefaultLabel(opt.seriesModel.getData(), dataIndex),
  69476. inheritColor: symbolMeta.style.fill,
  69477. defaultOpacity: symbolMeta.style.opacity,
  69478. defaultOutsidePosition: barPositionOutside
  69479. });
  69480. enableHoverEmphasis(bar, focus, blurScope);
  69481. }
  69482. function toIntTimes(times) {
  69483. var roundedTimes = Math.round(times); // Escapse accurate error
  69484. return Math.abs(times - roundedTimes) < 1e-4 ? roundedTimes : Math.ceil(times);
  69485. }
  69486. /*
  69487. * Licensed to the Apache Software Foundation (ASF) under one
  69488. * or more contributor license agreements. See the NOTICE file
  69489. * distributed with this work for additional information
  69490. * regarding copyright ownership. The ASF licenses this file
  69491. * to you under the Apache License, Version 2.0 (the
  69492. * "License"); you may not use this file except in compliance
  69493. * with the License. You may obtain a copy of the License at
  69494. *
  69495. * http://www.apache.org/licenses/LICENSE-2.0
  69496. *
  69497. * Unless required by applicable law or agreed to in writing,
  69498. * software distributed under the License is distributed on an
  69499. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69500. * KIND, either express or implied. See the License for the
  69501. * specific language governing permissions and limitations
  69502. * under the License.
  69503. */
  69504. /**
  69505. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69506. */
  69507. /*
  69508. * Licensed to the Apache Software Foundation (ASF) under one
  69509. * or more contributor license agreements. See the NOTICE file
  69510. * distributed with this work for additional information
  69511. * regarding copyright ownership. The ASF licenses this file
  69512. * to you under the Apache License, Version 2.0 (the
  69513. * "License"); you may not use this file except in compliance
  69514. * with the License. You may obtain a copy of the License at
  69515. *
  69516. * http://www.apache.org/licenses/LICENSE-2.0
  69517. *
  69518. * Unless required by applicable law or agreed to in writing,
  69519. * software distributed under the License is distributed on an
  69520. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69521. * KIND, either express or implied. See the License for the
  69522. * specific language governing permissions and limitations
  69523. * under the License.
  69524. */
  69525. var PictorialBarSeriesModel =
  69526. /** @class */
  69527. function (_super) {
  69528. __extends(PictorialBarSeriesModel, _super);
  69529. function PictorialBarSeriesModel() {
  69530. var _this = _super !== null && _super.apply(this, arguments) || this;
  69531. _this.type = PictorialBarSeriesModel.type;
  69532. _this.hasSymbolVisual = true;
  69533. _this.defaultSymbol = 'roundRect';
  69534. return _this;
  69535. }
  69536. PictorialBarSeriesModel.prototype.getInitialData = function (option) {
  69537. // Disable stack.
  69538. option.stack = null;
  69539. return _super.prototype.getInitialData.apply(this, arguments);
  69540. };
  69541. PictorialBarSeriesModel.type = 'series.pictorialBar';
  69542. PictorialBarSeriesModel.dependencies = ['grid'];
  69543. PictorialBarSeriesModel.defaultOption = inheritDefaultOption(BaseBarSeriesModel.defaultOption, {
  69544. symbol: 'circle',
  69545. symbolSize: null,
  69546. symbolRotate: null,
  69547. symbolPosition: null,
  69548. symbolOffset: null,
  69549. symbolMargin: null,
  69550. symbolRepeat: false,
  69551. symbolRepeatDirection: 'end',
  69552. symbolClip: false,
  69553. symbolBoundingData: null,
  69554. symbolPatternSize: 400,
  69555. barGap: '-100%',
  69556. // z can be set in data item, which is z2 actually.
  69557. // Disable progressive
  69558. progressive: 0,
  69559. emphasis: {
  69560. // By default pictorialBar do not hover scale. Hover scale is not suitable
  69561. // for the case that both has foreground and background.
  69562. scale: false
  69563. },
  69564. select: {
  69565. itemStyle: {
  69566. borderColor: '#212121'
  69567. }
  69568. }
  69569. });
  69570. return PictorialBarSeriesModel;
  69571. }(BaseBarSeriesModel);
  69572. /*
  69573. * Licensed to the Apache Software Foundation (ASF) under one
  69574. * or more contributor license agreements. See the NOTICE file
  69575. * distributed with this work for additional information
  69576. * regarding copyright ownership. The ASF licenses this file
  69577. * to you under the Apache License, Version 2.0 (the
  69578. * "License"); you may not use this file except in compliance
  69579. * with the License. You may obtain a copy of the License at
  69580. *
  69581. * http://www.apache.org/licenses/LICENSE-2.0
  69582. *
  69583. * Unless required by applicable law or agreed to in writing,
  69584. * software distributed under the License is distributed on an
  69585. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69586. * KIND, either express or implied. See the License for the
  69587. * specific language governing permissions and limitations
  69588. * under the License.
  69589. */
  69590. /**
  69591. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69592. */
  69593. /*
  69594. * Licensed to the Apache Software Foundation (ASF) under one
  69595. * or more contributor license agreements. See the NOTICE file
  69596. * distributed with this work for additional information
  69597. * regarding copyright ownership. The ASF licenses this file
  69598. * to you under the Apache License, Version 2.0 (the
  69599. * "License"); you may not use this file except in compliance
  69600. * with the License. You may obtain a copy of the License at
  69601. *
  69602. * http://www.apache.org/licenses/LICENSE-2.0
  69603. *
  69604. * Unless required by applicable law or agreed to in writing,
  69605. * software distributed under the License is distributed on an
  69606. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69607. * KIND, either express or implied. See the License for the
  69608. * specific language governing permissions and limitations
  69609. * under the License.
  69610. */
  69611. function install$26(registers) {
  69612. registers.registerChartView(PictorialBarView);
  69613. registers.registerSeriesModel(PictorialBarSeriesModel);
  69614. registers.registerLayout(curry(layout, 'pictorialBar'));
  69615. }
  69616. /*
  69617. * Licensed to the Apache Software Foundation (ASF) under one
  69618. * or more contributor license agreements. See the NOTICE file
  69619. * distributed with this work for additional information
  69620. * regarding copyright ownership. The ASF licenses this file
  69621. * to you under the Apache License, Version 2.0 (the
  69622. * "License"); you may not use this file except in compliance
  69623. * with the License. You may obtain a copy of the License at
  69624. *
  69625. * http://www.apache.org/licenses/LICENSE-2.0
  69626. *
  69627. * Unless required by applicable law or agreed to in writing,
  69628. * software distributed under the License is distributed on an
  69629. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69630. * KIND, either express or implied. See the License for the
  69631. * specific language governing permissions and limitations
  69632. * under the License.
  69633. */
  69634. /**
  69635. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69636. */
  69637. /*
  69638. * Licensed to the Apache Software Foundation (ASF) under one
  69639. * or more contributor license agreements. See the NOTICE file
  69640. * distributed with this work for additional information
  69641. * regarding copyright ownership. The ASF licenses this file
  69642. * to you under the Apache License, Version 2.0 (the
  69643. * "License"); you may not use this file except in compliance
  69644. * with the License. You may obtain a copy of the License at
  69645. *
  69646. * http://www.apache.org/licenses/LICENSE-2.0
  69647. *
  69648. * Unless required by applicable law or agreed to in writing,
  69649. * software distributed under the License is distributed on an
  69650. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69651. * KIND, either express or implied. See the License for the
  69652. * specific language governing permissions and limitations
  69653. * under the License.
  69654. */
  69655. use(install$26);
  69656. /*
  69657. * Licensed to the Apache Software Foundation (ASF) under one
  69658. * or more contributor license agreements. See the NOTICE file
  69659. * distributed with this work for additional information
  69660. * regarding copyright ownership. The ASF licenses this file
  69661. * to you under the Apache License, Version 2.0 (the
  69662. * "License"); you may not use this file except in compliance
  69663. * with the License. You may obtain a copy of the License at
  69664. *
  69665. * http://www.apache.org/licenses/LICENSE-2.0
  69666. *
  69667. * Unless required by applicable law or agreed to in writing,
  69668. * software distributed under the License is distributed on an
  69669. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69670. * KIND, either express or implied. See the License for the
  69671. * specific language governing permissions and limitations
  69672. * under the License.
  69673. */
  69674. /**
  69675. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69676. */
  69677. /*
  69678. * Licensed to the Apache Software Foundation (ASF) under one
  69679. * or more contributor license agreements. See the NOTICE file
  69680. * distributed with this work for additional information
  69681. * regarding copyright ownership. The ASF licenses this file
  69682. * to you under the Apache License, Version 2.0 (the
  69683. * "License"); you may not use this file except in compliance
  69684. * with the License. You may obtain a copy of the License at
  69685. *
  69686. * http://www.apache.org/licenses/LICENSE-2.0
  69687. *
  69688. * Unless required by applicable law or agreed to in writing,
  69689. * software distributed under the License is distributed on an
  69690. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69691. * KIND, either express or implied. See the License for the
  69692. * specific language governing permissions and limitations
  69693. * under the License.
  69694. */
  69695. function dataToCoordSize(dataSize, dataItem) {
  69696. // dataItem is necessary in log axis.
  69697. dataItem = dataItem || [0, 0];
  69698. return map(['x', 'y'], function (dim, dimIdx) {
  69699. var axis = this.getAxis(dim);
  69700. var val = dataItem[dimIdx];
  69701. var halfSize = dataSize[dimIdx] / 2;
  69702. return axis.type === 'category' ? axis.getBandWidth() : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  69703. }, this);
  69704. }
  69705. function cartesianPrepareCustom(coordSys) {
  69706. var rect = coordSys.master.getRect();
  69707. return {
  69708. coordSys: {
  69709. // The name exposed to user is always 'cartesian2d' but not 'grid'.
  69710. type: 'cartesian2d',
  69711. x: rect.x,
  69712. y: rect.y,
  69713. width: rect.width,
  69714. height: rect.height
  69715. },
  69716. api: {
  69717. coord: function (data) {
  69718. // do not provide "out" param
  69719. return coordSys.dataToPoint(data);
  69720. },
  69721. size: bind(dataToCoordSize, coordSys)
  69722. }
  69723. };
  69724. }
  69725. /*
  69726. * Licensed to the Apache Software Foundation (ASF) under one
  69727. * or more contributor license agreements. See the NOTICE file
  69728. * distributed with this work for additional information
  69729. * regarding copyright ownership. The ASF licenses this file
  69730. * to you under the Apache License, Version 2.0 (the
  69731. * "License"); you may not use this file except in compliance
  69732. * with the License. You may obtain a copy of the License at
  69733. *
  69734. * http://www.apache.org/licenses/LICENSE-2.0
  69735. *
  69736. * Unless required by applicable law or agreed to in writing,
  69737. * software distributed under the License is distributed on an
  69738. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69739. * KIND, either express or implied. See the License for the
  69740. * specific language governing permissions and limitations
  69741. * under the License.
  69742. */
  69743. /**
  69744. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69745. */
  69746. /*
  69747. * Licensed to the Apache Software Foundation (ASF) under one
  69748. * or more contributor license agreements. See the NOTICE file
  69749. * distributed with this work for additional information
  69750. * regarding copyright ownership. The ASF licenses this file
  69751. * to you under the Apache License, Version 2.0 (the
  69752. * "License"); you may not use this file except in compliance
  69753. * with the License. You may obtain a copy of the License at
  69754. *
  69755. * http://www.apache.org/licenses/LICENSE-2.0
  69756. *
  69757. * Unless required by applicable law or agreed to in writing,
  69758. * software distributed under the License is distributed on an
  69759. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69760. * KIND, either express or implied. See the License for the
  69761. * specific language governing permissions and limitations
  69762. * under the License.
  69763. */
  69764. function dataToCoordSize$1(dataSize, dataItem) {
  69765. dataItem = dataItem || [0, 0];
  69766. return map([0, 1], function (dimIdx) {
  69767. var val = dataItem[dimIdx];
  69768. var halfSize = dataSize[dimIdx] / 2;
  69769. var p1 = [];
  69770. var p2 = [];
  69771. p1[dimIdx] = val - halfSize;
  69772. p2[dimIdx] = val + halfSize;
  69773. p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
  69774. return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
  69775. }, this);
  69776. }
  69777. function geoPrepareCustom(coordSys) {
  69778. var rect = coordSys.getBoundingRect();
  69779. return {
  69780. coordSys: {
  69781. type: 'geo',
  69782. x: rect.x,
  69783. y: rect.y,
  69784. width: rect.width,
  69785. height: rect.height,
  69786. zoom: coordSys.getZoom()
  69787. },
  69788. api: {
  69789. coord: function (data) {
  69790. // do not provide "out" and noRoam param,
  69791. // Compatible with this usage:
  69792. // echarts.util.map(item.points, api.coord)
  69793. return coordSys.dataToPoint(data);
  69794. },
  69795. size: bind(dataToCoordSize$1, coordSys)
  69796. }
  69797. };
  69798. }
  69799. /*
  69800. * Licensed to the Apache Software Foundation (ASF) under one
  69801. * or more contributor license agreements. See the NOTICE file
  69802. * distributed with this work for additional information
  69803. * regarding copyright ownership. The ASF licenses this file
  69804. * to you under the Apache License, Version 2.0 (the
  69805. * "License"); you may not use this file except in compliance
  69806. * with the License. You may obtain a copy of the License at
  69807. *
  69808. * http://www.apache.org/licenses/LICENSE-2.0
  69809. *
  69810. * Unless required by applicable law or agreed to in writing,
  69811. * software distributed under the License is distributed on an
  69812. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69813. * KIND, either express or implied. See the License for the
  69814. * specific language governing permissions and limitations
  69815. * under the License.
  69816. */
  69817. /**
  69818. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69819. */
  69820. /*
  69821. * Licensed to the Apache Software Foundation (ASF) under one
  69822. * or more contributor license agreements. See the NOTICE file
  69823. * distributed with this work for additional information
  69824. * regarding copyright ownership. The ASF licenses this file
  69825. * to you under the Apache License, Version 2.0 (the
  69826. * "License"); you may not use this file except in compliance
  69827. * with the License. You may obtain a copy of the License at
  69828. *
  69829. * http://www.apache.org/licenses/LICENSE-2.0
  69830. *
  69831. * Unless required by applicable law or agreed to in writing,
  69832. * software distributed under the License is distributed on an
  69833. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69834. * KIND, either express or implied. See the License for the
  69835. * specific language governing permissions and limitations
  69836. * under the License.
  69837. */
  69838. function dataToCoordSize$2(dataSize, dataItem) {
  69839. // dataItem is necessary in log axis.
  69840. var axis = this.getAxis();
  69841. var val = dataItem instanceof Array ? dataItem[0] : dataItem;
  69842. var halfSize = (dataSize instanceof Array ? dataSize[0] : dataSize) / 2;
  69843. return axis.type === 'category' ? axis.getBandWidth() : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  69844. }
  69845. function singlePrepareCustom(coordSys) {
  69846. var rect = coordSys.getRect();
  69847. return {
  69848. coordSys: {
  69849. type: 'singleAxis',
  69850. x: rect.x,
  69851. y: rect.y,
  69852. width: rect.width,
  69853. height: rect.height
  69854. },
  69855. api: {
  69856. coord: function (val) {
  69857. // do not provide "out" param
  69858. return coordSys.dataToPoint(val);
  69859. },
  69860. size: bind(dataToCoordSize$2, coordSys)
  69861. }
  69862. };
  69863. }
  69864. /*
  69865. * Licensed to the Apache Software Foundation (ASF) under one
  69866. * or more contributor license agreements. See the NOTICE file
  69867. * distributed with this work for additional information
  69868. * regarding copyright ownership. The ASF licenses this file
  69869. * to you under the Apache License, Version 2.0 (the
  69870. * "License"); you may not use this file except in compliance
  69871. * with the License. You may obtain a copy of the License at
  69872. *
  69873. * http://www.apache.org/licenses/LICENSE-2.0
  69874. *
  69875. * Unless required by applicable law or agreed to in writing,
  69876. * software distributed under the License is distributed on an
  69877. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69878. * KIND, either express or implied. See the License for the
  69879. * specific language governing permissions and limitations
  69880. * under the License.
  69881. */
  69882. /**
  69883. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69884. */
  69885. /*
  69886. * Licensed to the Apache Software Foundation (ASF) under one
  69887. * or more contributor license agreements. See the NOTICE file
  69888. * distributed with this work for additional information
  69889. * regarding copyright ownership. The ASF licenses this file
  69890. * to you under the Apache License, Version 2.0 (the
  69891. * "License"); you may not use this file except in compliance
  69892. * with the License. You may obtain a copy of the License at
  69893. *
  69894. * http://www.apache.org/licenses/LICENSE-2.0
  69895. *
  69896. * Unless required by applicable law or agreed to in writing,
  69897. * software distributed under the License is distributed on an
  69898. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69899. * KIND, either express or implied. See the License for the
  69900. * specific language governing permissions and limitations
  69901. * under the License.
  69902. */
  69903. function dataToCoordSize$3(dataSize, dataItem) {
  69904. // dataItem is necessary in log axis.
  69905. dataItem = dataItem || [0, 0];
  69906. return map(['Radius', 'Angle'], function (dim, dimIdx) {
  69907. var getterName = 'get' + dim + 'Axis'; // TODO: TYPE Check Angle Axis
  69908. var axis = this[getterName]();
  69909. var val = dataItem[dimIdx];
  69910. var halfSize = dataSize[dimIdx] / 2;
  69911. var result = axis.type === 'category' ? axis.getBandWidth() : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
  69912. if (dim === 'Angle') {
  69913. result = result * Math.PI / 180;
  69914. }
  69915. return result;
  69916. }, this);
  69917. }
  69918. function polarPrepareCustom(coordSys) {
  69919. var radiusAxis = coordSys.getRadiusAxis();
  69920. var angleAxis = coordSys.getAngleAxis();
  69921. var radius = radiusAxis.getExtent();
  69922. radius[0] > radius[1] && radius.reverse();
  69923. return {
  69924. coordSys: {
  69925. type: 'polar',
  69926. cx: coordSys.cx,
  69927. cy: coordSys.cy,
  69928. r: radius[1],
  69929. r0: radius[0]
  69930. },
  69931. api: {
  69932. coord: function (data) {
  69933. var radius = radiusAxis.dataToRadius(data[0]);
  69934. var angle = angleAxis.dataToAngle(data[1]);
  69935. var coord = coordSys.coordToPoint([radius, angle]);
  69936. coord.push(radius, angle * Math.PI / 180);
  69937. return coord;
  69938. },
  69939. size: bind(dataToCoordSize$3, coordSys)
  69940. }
  69941. };
  69942. }
  69943. /*
  69944. * Licensed to the Apache Software Foundation (ASF) under one
  69945. * or more contributor license agreements. See the NOTICE file
  69946. * distributed with this work for additional information
  69947. * regarding copyright ownership. The ASF licenses this file
  69948. * to you under the Apache License, Version 2.0 (the
  69949. * "License"); you may not use this file except in compliance
  69950. * with the License. You may obtain a copy of the License at
  69951. *
  69952. * http://www.apache.org/licenses/LICENSE-2.0
  69953. *
  69954. * Unless required by applicable law or agreed to in writing,
  69955. * software distributed under the License is distributed on an
  69956. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69957. * KIND, either express or implied. See the License for the
  69958. * specific language governing permissions and limitations
  69959. * under the License.
  69960. */
  69961. /**
  69962. * AUTO-GENERATED FILE. DO NOT MODIFY.
  69963. */
  69964. /*
  69965. * Licensed to the Apache Software Foundation (ASF) under one
  69966. * or more contributor license agreements. See the NOTICE file
  69967. * distributed with this work for additional information
  69968. * regarding copyright ownership. The ASF licenses this file
  69969. * to you under the Apache License, Version 2.0 (the
  69970. * "License"); you may not use this file except in compliance
  69971. * with the License. You may obtain a copy of the License at
  69972. *
  69973. * http://www.apache.org/licenses/LICENSE-2.0
  69974. *
  69975. * Unless required by applicable law or agreed to in writing,
  69976. * software distributed under the License is distributed on an
  69977. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  69978. * KIND, either express or implied. See the License for the
  69979. * specific language governing permissions and limitations
  69980. * under the License.
  69981. */
  69982. function calendarPrepareCustom(coordSys) {
  69983. var rect = coordSys.getRect();
  69984. var rangeInfo = coordSys.getRangeInfo();
  69985. return {
  69986. coordSys: {
  69987. type: 'calendar',
  69988. x: rect.x,
  69989. y: rect.y,
  69990. width: rect.width,
  69991. height: rect.height,
  69992. cellWidth: coordSys.getCellWidth(),
  69993. cellHeight: coordSys.getCellHeight(),
  69994. rangeInfo: {
  69995. start: rangeInfo.start,
  69996. end: rangeInfo.end,
  69997. weeks: rangeInfo.weeks,
  69998. dayCount: rangeInfo.allDay
  69999. }
  70000. },
  70001. api: {
  70002. coord: function (data, clamp) {
  70003. return coordSys.dataToPoint(data, clamp);
  70004. }
  70005. }
  70006. };
  70007. }
  70008. /*
  70009. * Licensed to the Apache Software Foundation (ASF) under one
  70010. * or more contributor license agreements. See the NOTICE file
  70011. * distributed with this work for additional information
  70012. * regarding copyright ownership. The ASF licenses this file
  70013. * to you under the Apache License, Version 2.0 (the
  70014. * "License"); you may not use this file except in compliance
  70015. * with the License. You may obtain a copy of the License at
  70016. *
  70017. * http://www.apache.org/licenses/LICENSE-2.0
  70018. *
  70019. * Unless required by applicable law or agreed to in writing,
  70020. * software distributed under the License is distributed on an
  70021. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  70022. * KIND, either express or implied. See the License for the
  70023. * specific language governing permissions and limitations
  70024. * under the License.
  70025. */
  70026. /**
  70027. * AUTO-GENERATED FILE. DO NOT MODIFY.
  70028. */
  70029. /*
  70030. * Licensed to the Apache Software Foundation (ASF) under one
  70031. * or more contributor license agreements. See the NOTICE file
  70032. * distributed with this work for additional information
  70033. * regarding copyright ownership. The ASF licenses this file
  70034. * to you under the Apache License, Version 2.0 (the
  70035. * "License"); you may not use this file except in compliance
  70036. * with the License. You may obtain a copy of the License at
  70037. *
  70038. * http://www.apache.org/licenses/LICENSE-2.0
  70039. *
  70040. * Unless required by applicable law or agreed to in writing,
  70041. * software distributed under the License is distributed on an
  70042. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  70043. * KIND, either express or implied. See the License for the
  70044. * specific language governing permissions and limitations
  70045. * under the License.
  70046. */
  70047. var deprecatedLogs = {};
  70048. /**
  70049. * Whether need to call `convertEC4CompatibleStyle`.
  70050. */
  70051. function isEC4CompatibleStyle(style, elType, hasOwnTextContentOption, hasOwnTextConfig) {
  70052. // Since echarts5, `RectText` is separated from its host element and style.text
  70053. // does not exist any more. The compat work brings some extra burden on performance.
  70054. // So we provide:
  70055. // `legacy: true` force make compat.
  70056. // `legacy: false`, force do not compat.
  70057. // `legacy` not set: auto detect wheter legacy.
  70058. // But in this case we do not compat (difficult to detect and rare case):
  70059. // Becuse custom series and graphic component support "merge", users may firstly
  70060. // only set `textStrokeWidth` style or secondly only set `text`.
  70061. return style && (style.legacy || style.legacy !== false && !hasOwnTextContentOption && !hasOwnTextConfig && elType !== 'tspan' // Difficult to detect whether legacy for a "text" el.
  70062. && (elType === 'text' || hasOwn(style, 'text')));
  70063. }
  70064. /**
  70065. * `EC4CompatibleStyle` is style that might be in echarts4 format or echarts5 format.
  70066. * @param hostStyle The properties might be modified.
  70067. * @return If be text el, `textContentStyle` and `textConfig` will not be retured.
  70068. * Otherwise a `textContentStyle` and `textConfig` will be created, whose props area
  70069. * retried from the `hostStyle`.
  70070. */
  70071. function convertFromEC4CompatibleStyle(hostStyle, elType, isNormal) {
  70072. var srcStyle = hostStyle;
  70073. var textConfig;
  70074. var textContent;
  70075. var textContentStyle;
  70076. if (elType === 'text') {
  70077. textContentStyle = srcStyle;
  70078. } else {
  70079. textContentStyle = {};
  70080. hasOwn(srcStyle, 'text') && (textContentStyle.text = srcStyle.text);
  70081. hasOwn(srcStyle, 'rich') && (textContentStyle.rich = srcStyle.rich);
  70082. hasOwn(srcStyle, 'textFill') && (textContentStyle.fill = srcStyle.textFill);
  70083. hasOwn(srcStyle, 'textStroke') && (textContentStyle.stroke = srcStyle.textStroke);
  70084. textContent = {
  70085. type: 'text',
  70086. style: textContentStyle,
  70087. // ec4 do not support rectText trigger.
  70088. // And when text postion is different in normal and emphasis
  70089. // => hover text trigger emphasis;
  70090. // => text position changed, leave mouse pointer immediately;
  70091. // That might cause state incorrect.
  70092. silent: true
  70093. };
  70094. textConfig = {};
  70095. var hasOwnPos = hasOwn(srcStyle, 'textPosition');
  70096. if (isNormal) {
  70097. textConfig.position = hasOwnPos ? srcStyle.textPosition : 'inside';
  70098. } else {
  70099. hasOwnPos && (textConfig.position = srcStyle.textPosition);
  70100. }
  70101. hasOwn(srcStyle, 'textPosition') && (textConfig.position = srcStyle.textPosition);
  70102. hasOwn(srcStyle, 'textOffset') && (textConfig.offset = srcStyle.textOffset);
  70103. hasOwn(srcStyle, 'textRotation') && (textConfig.rotation = srcStyle.textRotation);
  70104. hasOwn(srcStyle, 'textDistance') && (textConfig.distance = srcStyle.textDistance);
  70105. }
  70106. convertEC4CompatibleRichItem(textContentStyle, hostStyle);
  70107. each$1(textContentStyle.rich, function (richItem) {
  70108. convertEC4CompatibleRichItem(richItem, richItem);
  70109. });
  70110. return {
  70111. textConfig: textConfig,
  70112. textContent: textContent
  70113. };
  70114. }
  70115. /**
  70116. * The result will be set to `out`.
  70117. */
  70118. function convertEC4CompatibleRichItem(out, richItem) {
  70119. if (!richItem) {
  70120. return;
  70121. } // (1) For simplicity, make textXXX properties (deprecated since ec5) has
  70122. // higher priority. For example, consider in ec4 `borderColor: 5, textBorderColor: 10`
  70123. // on a rect means `borderColor: 4` on the rect and `borderColor: 10` on an attached
  70124. // richText in ec5.
  70125. // (2) `out === richItem` if and only if `out` is text el or rich item.
  70126. // So we can overwite existing props in `out` since textXXX has higher priority.
  70127. richItem.font = richItem.textFont || richItem.font;
  70128. hasOwn(richItem, 'textStrokeWidth') && (out.lineWidth = richItem.textStrokeWidth);
  70129. hasOwn(richItem, 'textAlign') && (out.align = richItem.textAlign);
  70130. hasOwn(richItem, 'textVerticalAlign') && (out.verticalAlign = richItem.textVerticalAlign);
  70131. hasOwn(richItem, 'textLineHeight') && (out.lineHeight = richItem.textLineHeight);
  70132. hasOwn(richItem, 'textWidth') && (out.width = richItem.textWidth);
  70133. hasOwn(richItem, 'textHeight') && (out.height = richItem.textHeight);
  70134. hasOwn(richItem, 'textBackgroundColor') && (out.backgroundColor = richItem.textBackgroundColor);
  70135. hasOwn(richItem, 'textPadding') && (out.padding = richItem.textPadding);
  70136. hasOwn(richItem, 'textBorderColor') && (out.borderColor = richItem.textBorderColor);
  70137. hasOwn(richItem, 'textBorderWidth') && (out.borderWidth = richItem.textBorderWidth);
  70138. hasOwn(richItem, 'textBorderRadius') && (out.borderRadius = richItem.textBorderRadius);
  70139. hasOwn(richItem, 'textBoxShadowColor') && (out.shadowColor = richItem.textBoxShadowColor);
  70140. hasOwn(richItem, 'textBoxShadowBlur') && (out.shadowBlur = richItem.textBoxShadowBlur);
  70141. hasOwn(richItem, 'textBoxShadowOffsetX') && (out.shadowOffsetX = richItem.textBoxShadowOffsetX);
  70142. hasOwn(richItem, 'textBoxShadowOffsetY') && (out.shadowOffsetY = richItem.textBoxShadowOffsetY);
  70143. }
  70144. /**
  70145. * Convert to pure echarts4 format style.
  70146. * `itemStyle` will be modified, added with ec4 style properties from
  70147. * `textStyle` and `textConfig`.
  70148. *
  70149. * [Caveat]: For simplicity, `insideRollback` in ec4 does not compat, where
  70150. * `styleEmphasis: {textFill: 'red'}` will remove the normal auto added stroke.
  70151. */
  70152. function convertToEC4StyleForCustomSerise(itemStl, txStl, txCfg) {
  70153. var out = itemStl; // See `custom.ts`, a trick to set extra `textPosition` firstly.
  70154. out.textPosition = out.textPosition || txCfg.position || 'inside';
  70155. txCfg.offset != null && (out.textOffset = txCfg.offset);
  70156. txCfg.rotation != null && (out.textRotation = txCfg.rotation);
  70157. txCfg.distance != null && (out.textDistance = txCfg.distance);
  70158. var isInside = out.textPosition.indexOf('inside') >= 0;
  70159. var hostFill = itemStl.fill || '#000';
  70160. convertToEC4RichItem(out, txStl);
  70161. var textFillNotSet = out.textFill == null;
  70162. if (isInside) {
  70163. if (textFillNotSet) {
  70164. out.textFill = txCfg.insideFill || '#fff';
  70165. !out.textStroke && txCfg.insideStroke && (out.textStroke = txCfg.insideStroke);
  70166. !out.textStroke && (out.textStroke = hostFill);
  70167. out.textStrokeWidth == null && (out.textStrokeWidth = 2);
  70168. }
  70169. } else {
  70170. if (textFillNotSet) {
  70171. out.textFill = itemStl.fill || txCfg.outsideFill || '#000';
  70172. }
  70173. !out.textStroke && txCfg.outsideStroke && (out.textStroke = txCfg.outsideStroke);
  70174. }
  70175. out.text = txStl.text;
  70176. out.rich = txStl.rich;
  70177. each$1(txStl.rich, function (richItem) {
  70178. convertToEC4RichItem(richItem, richItem);
  70179. });
  70180. return out;
  70181. }
  70182. function convertToEC4RichItem(out, richItem) {
  70183. if (!richItem) {
  70184. return;
  70185. }
  70186. hasOwn(richItem, 'fill') && (out.textFill = richItem.fill);
  70187. hasOwn(richItem, 'stroke') && (out.textStroke = richItem.fill);
  70188. hasOwn(richItem, 'lineWidth') && (out.textStrokeWidth = richItem.lineWidth);
  70189. hasOwn(richItem, 'font') && (out.font = richItem.font);
  70190. hasOwn(richItem, 'fontStyle') && (out.fontStyle = richItem.fontStyle);
  70191. hasOwn(richItem, 'fontWeight') && (out.fontWeight = richItem.fontWeight);
  70192. hasOwn(richItem, 'fontSize') && (out.fontSize = richItem.fontSize);
  70193. hasOwn(richItem, 'fontFamily') && (out.fontFamily = richItem.fontFamily);
  70194. hasOwn(richItem, 'align') && (out.textAlign = richItem.align);
  70195. hasOwn(richItem, 'verticalAlign') && (out.textVerticalAlign = richItem.verticalAlign);
  70196. hasOwn(richItem, 'lineHeight') && (out.textLineHeight = richItem.lineHeight);
  70197. hasOwn(richItem, 'width') && (out.textWidth = richItem.width);
  70198. hasOwn(richItem, 'height') && (out.textHeight = richItem.height);
  70199. hasOwn(richItem, 'backgroundColor') && (out.textBackgroundColor = richItem.backgroundColor);
  70200. hasOwn(richItem, 'padding') && (out.textPadding = richItem.padding);
  70201. hasOwn(richItem, 'borderColor') && (out.textBorderColor = richItem.borderColor);
  70202. hasOwn(richItem, 'borderWidth') && (out.textBorderWidth = richItem.borderWidth);
  70203. hasOwn(richItem, 'borderRadius') && (out.textBorderRadius = richItem.borderRadius);
  70204. hasOwn(richItem, 'shadowColor') && (out.textBoxShadowColor = richItem.shadowColor);
  70205. hasOwn(richItem, 'shadowBlur') && (out.textBoxShadowBlur = richItem.shadowBlur);
  70206. hasOwn(richItem, 'shadowOffsetX') && (out.textBoxShadowOffsetX = richItem.shadowOffsetX);
  70207. hasOwn(richItem, 'shadowOffsetY') && (out.textBoxShadowOffsetY = richItem.shadowOffsetY);
  70208. hasOwn(richItem, 'textShadowColor') && (out.textShadowColor = richItem.textShadowColor);
  70209. hasOwn(richItem, 'textShadowBlur') && (out.textShadowBlur = richItem.textShadowBlur);
  70210. hasOwn(richItem, 'textShadowOffsetX') && (out.textShadowOffsetX = richItem.textShadowOffsetX);
  70211. hasOwn(richItem, 'textShadowOffsetY') && (out.textShadowOffsetY = richItem.textShadowOffsetY);
  70212. }
  70213. function warnDeprecated(deprecated, insteadApproach) {
  70214. {
  70215. var key = deprecated + '^_^' + insteadApproach;
  70216. if (!deprecatedLogs[key]) {
  70217. console.warn("[ECharts] DEPRECATED: \"" + deprecated + "\" has been deprecated. " + insteadApproach);
  70218. deprecatedLogs[key] = true;
  70219. }
  70220. }
  70221. }
  70222. var CMD$4 = PathProxy.CMD;
  70223. var PI2$9 = Math.PI * 2;
  70224. var PROP_XY = ['x', 'y'];
  70225. var PROP_WH = ['width', 'height'];
  70226. var tmpArr$1 = [];
  70227. function aroundEqual(a, b) {
  70228. return Math.abs(a - b) < 1e-5;
  70229. }
  70230. function pathToBezierCurves(path) {
  70231. var data = path.data;
  70232. var len$$1 = path.len();
  70233. var bezierArray = [];
  70234. var currentSubpath;
  70235. var xi = 0;
  70236. var yi = 0;
  70237. var x0 = 0;
  70238. var y0 = 0;
  70239. function createNewSubpath(x, y) {
  70240. if (currentSubpath && currentSubpath.length > 2) {
  70241. bezierArray.push(currentSubpath);
  70242. }
  70243. currentSubpath = [x, y];
  70244. }
  70245. function addLine(x0, y0, x1, y1) {
  70246. if (!(aroundEqual(x0, x1) && aroundEqual(y0, y1))) {
  70247. currentSubpath.push(x0, y0, x1, y1, x1, y1);
  70248. }
  70249. }
  70250. function addArc(startAngle, endAngle, cx, cy, rx, ry) {
  70251. var delta = Math.abs(endAngle - startAngle);
  70252. var len$$1 = Math.tan(delta / 4) * 4 / 3;
  70253. var dir = endAngle < startAngle ? -1 : 1;
  70254. var c1 = Math.cos(startAngle);
  70255. var s1 = Math.sin(startAngle);
  70256. var c2 = Math.cos(endAngle);
  70257. var s2 = Math.sin(endAngle);
  70258. var x1 = c1 * rx + cx;
  70259. var y1 = s1 * ry + cy;
  70260. var x4 = c2 * rx + cx;
  70261. var y4 = s2 * ry + cy;
  70262. var hx = rx * len$$1 * dir;
  70263. var hy = ry * len$$1 * dir;
  70264. currentSubpath.push(x1 - hx * s1, y1 + hy * c1, x4 + hx * s2, y4 - hy * c2, x4, y4);
  70265. }
  70266. var x1;
  70267. var y1;
  70268. var x2;
  70269. var y2;
  70270. for (var i = 0; i < len$$1;) {
  70271. var cmd = data[i++];
  70272. var isFirst = i === 1;
  70273. if (isFirst) {
  70274. xi = data[i];
  70275. yi = data[i + 1];
  70276. x0 = xi;
  70277. y0 = yi;
  70278. if (cmd === CMD$4.L || cmd === CMD$4.C || cmd === CMD$4.Q) {
  70279. currentSubpath = [x0, y0];
  70280. }
  70281. }
  70282. switch (cmd) {
  70283. case CMD$4.M:
  70284. xi = x0 = data[i++];
  70285. yi = y0 = data[i++];
  70286. createNewSubpath(x0, y0);
  70287. break;
  70288. case CMD$4.L:
  70289. x1 = data[i++];
  70290. y1 = data[i++];
  70291. addLine(xi, yi, x1, y1);
  70292. xi = x1;
  70293. yi = y1;
  70294. break;
  70295. case CMD$4.C:
  70296. currentSubpath.push(data[i++], data[i++], data[i++], data[i++], xi = data[i++], yi = data[i++]);
  70297. break;
  70298. case CMD$4.Q:
  70299. x1 = data[i++];
  70300. y1 = data[i++];
  70301. x2 = data[i++];
  70302. y2 = data[i++];
  70303. currentSubpath.push(xi + 2 / 3 * (x1 - xi), yi + 2 / 3 * (y1 - yi), x2 + 2 / 3 * (x1 - x2), y2 + 2 / 3 * (y1 - y2), x2, y2);
  70304. xi = x2;
  70305. yi = y2;
  70306. break;
  70307. case CMD$4.A:
  70308. var cx = data[i++];
  70309. var cy = data[i++];
  70310. var rx = data[i++];
  70311. var ry = data[i++];
  70312. var startAngle = data[i++];
  70313. var endAngle = data[i++] + startAngle;
  70314. i += 1;
  70315. var anticlockwise = !data[i++];
  70316. x1 = Math.cos(startAngle) * rx + cx;
  70317. y1 = Math.sin(startAngle) * ry + cy;
  70318. if (isFirst) {
  70319. x0 = x1;
  70320. y0 = y1;
  70321. createNewSubpath(x0, y0);
  70322. } else {
  70323. addLine(xi, yi, x1, y1);
  70324. }
  70325. xi = Math.cos(endAngle) * rx + cx;
  70326. yi = Math.sin(endAngle) * ry + cy;
  70327. var step = (anticlockwise ? -1 : 1) * Math.PI / 2;
  70328. for (var angle = startAngle; anticlockwise ? angle > endAngle : angle < endAngle; angle += step) {
  70329. var nextAngle = anticlockwise ? Math.max(angle + step, endAngle) : Math.min(angle + step, endAngle);
  70330. addArc(angle, nextAngle, cx, cy, rx, ry);
  70331. }
  70332. break;
  70333. case CMD$4.R:
  70334. x0 = xi = data[i++];
  70335. y0 = yi = data[i++];
  70336. x1 = x0 + data[i++];
  70337. y1 = y0 + data[i++];
  70338. createNewSubpath(x1, y0);
  70339. addLine(x1, y0, x1, y1);
  70340. addLine(x1, y1, x0, y1);
  70341. addLine(x0, y1, x0, y0);
  70342. addLine(x0, y0, x1, y0);
  70343. break;
  70344. case CMD$4.Z:
  70345. currentSubpath && addLine(xi, yi, x0, y0);
  70346. xi = x0;
  70347. yi = y0;
  70348. break;
  70349. }
  70350. }
  70351. if (currentSubpath && currentSubpath.length > 2) {
  70352. bezierArray.push(currentSubpath);
  70353. }
  70354. return bezierArray;
  70355. }
  70356. function alignSubpath(subpath1, subpath2) {
  70357. var len1 = subpath1.length;
  70358. var len2 = subpath2.length;
  70359. if (len1 === len2) {
  70360. return [subpath1, subpath2];
  70361. }
  70362. var shorterPath = len1 < len2 ? subpath1 : subpath2;
  70363. var shorterLen = Math.min(len1, len2);
  70364. var diff = Math.abs(len2 - len1) / 6;
  70365. var shorterBezierCount = (shorterLen - 2) / 6;
  70366. var eachCurveSubDivCount = Math.ceil(diff / shorterBezierCount) + 1;
  70367. var newSubpath = [shorterPath[0], shorterPath[1]];
  70368. var remained = diff;
  70369. var tmpSegX = [];
  70370. var tmpSegY = [];
  70371. for (var i = 2; i < shorterLen;) {
  70372. var x0 = shorterPath[i - 2];
  70373. var y0 = shorterPath[i - 1];
  70374. var x1 = shorterPath[i++];
  70375. var y1 = shorterPath[i++];
  70376. var x2 = shorterPath[i++];
  70377. var y2 = shorterPath[i++];
  70378. var x3 = shorterPath[i++];
  70379. var y3 = shorterPath[i++];
  70380. if (remained <= 0) {
  70381. newSubpath.push(x1, y1, x2, y2, x3, y3);
  70382. continue;
  70383. }
  70384. var actualSubDivCount = Math.min(remained, eachCurveSubDivCount - 1) + 1;
  70385. for (var k = 1; k <= actualSubDivCount; k++) {
  70386. var p = k / actualSubDivCount;
  70387. cubicSubdivide(x0, x1, x2, x3, p, tmpSegX);
  70388. cubicSubdivide(y0, y1, y2, y3, p, tmpSegY);
  70389. x0 = tmpSegX[3];
  70390. y0 = tmpSegY[3];
  70391. newSubpath.push(tmpSegX[1], tmpSegY[1], tmpSegX[2], tmpSegY[2], x0, y0);
  70392. x1 = tmpSegX[5];
  70393. y1 = tmpSegY[5];
  70394. x2 = tmpSegX[6];
  70395. y2 = tmpSegY[6];
  70396. }
  70397. remained -= actualSubDivCount - 1;
  70398. }
  70399. return shorterPath === subpath1 ? [newSubpath, subpath2] : [subpath1, newSubpath];
  70400. }
  70401. function createSubpath(lastSubpathSubpath, otherSubpath) {
  70402. var len$$1 = lastSubpathSubpath.length;
  70403. var lastX = lastSubpathSubpath[len$$1 - 2];
  70404. var lastY = lastSubpathSubpath[len$$1 - 1];
  70405. var newSubpath = [];
  70406. for (var i = 0; i < otherSubpath.length;) {
  70407. newSubpath[i++] = lastX;
  70408. newSubpath[i++] = lastY;
  70409. }
  70410. return newSubpath;
  70411. }
  70412. function alignBezierCurves(array1, array2) {
  70413. var _a;
  70414. var lastSubpath1;
  70415. var lastSubpath2;
  70416. var newArray1 = [];
  70417. var newArray2 = [];
  70418. for (var i = 0; i < Math.max(array1.length, array2.length); i++) {
  70419. var subpath1 = array1[i];
  70420. var subpath2 = array2[i];
  70421. var newSubpath1 = void 0;
  70422. var newSubpath2 = void 0;
  70423. if (!subpath1) {
  70424. newSubpath1 = createSubpath(lastSubpath1 || subpath2, subpath2);
  70425. newSubpath2 = subpath2;
  70426. } else if (!subpath2) {
  70427. newSubpath2 = createSubpath(lastSubpath2 || subpath1, subpath1);
  70428. newSubpath1 = subpath1;
  70429. } else {
  70430. _a = alignSubpath(subpath1, subpath2), newSubpath1 = _a[0], newSubpath2 = _a[1];
  70431. lastSubpath1 = newSubpath1;
  70432. lastSubpath2 = newSubpath2;
  70433. }
  70434. newArray1.push(newSubpath1);
  70435. newArray2.push(newSubpath2);
  70436. }
  70437. return [newArray1, newArray2];
  70438. }
  70439. function centroid(array) {
  70440. var signedArea = 0;
  70441. var cx = 0;
  70442. var cy = 0;
  70443. var len$$1 = array.length;
  70444. for (var i = 0, j = len$$1 - 2; i < len$$1; j = i, i += 2) {
  70445. var x0 = array[j];
  70446. var y0 = array[j + 1];
  70447. var x1 = array[i];
  70448. var y1 = array[i + 1];
  70449. var a = x0 * y1 - x1 * y0;
  70450. signedArea += a;
  70451. cx += (x0 + x1) * a;
  70452. cy += (y0 + y1) * a;
  70453. }
  70454. if (signedArea === 0) {
  70455. return [array[0] || 0, array[1] || 0];
  70456. }
  70457. return [cx / signedArea / 3, cy / signedArea / 3, signedArea];
  70458. }
  70459. function findBestRingOffset(fromSubBeziers, toSubBeziers, fromCp, toCp) {
  70460. var bezierCount = (fromSubBeziers.length - 2) / 6;
  70461. var bestScore = Infinity;
  70462. var bestOffset = 0;
  70463. var len$$1 = fromSubBeziers.length;
  70464. var len2 = len$$1 - 2;
  70465. for (var offset = 0; offset < bezierCount; offset++) {
  70466. var cursorOffset = offset * 6;
  70467. var score = 0;
  70468. for (var k = 0; k < len$$1; k += 2) {
  70469. var idx = k === 0 ? cursorOffset : (cursorOffset + k - 2) % len2 + 2;
  70470. var x0 = fromSubBeziers[idx] - fromCp[0];
  70471. var y0 = fromSubBeziers[idx + 1] - fromCp[1];
  70472. var x1 = toSubBeziers[k] - toCp[0];
  70473. var y1 = toSubBeziers[k + 1] - toCp[1];
  70474. var dx = x1 - x0;
  70475. var dy = y1 - y0;
  70476. score += dx * dx + dy * dy;
  70477. }
  70478. if (score < bestScore) {
  70479. bestScore = score;
  70480. bestOffset = offset;
  70481. }
  70482. }
  70483. return bestOffset;
  70484. }
  70485. function reverse(array) {
  70486. var newArr = [];
  70487. var len$$1 = array.length;
  70488. for (var i = 0; i < len$$1; i += 2) {
  70489. newArr[i] = array[len$$1 - i - 2];
  70490. newArr[i + 1] = array[len$$1 - i - 1];
  70491. }
  70492. return newArr;
  70493. }
  70494. function findBestMorphingRotation(fromArr, toArr, searchAngleIteration, searchAngleRange) {
  70495. var result = [];
  70496. var fromNeedsReverse;
  70497. for (var i = 0; i < fromArr.length; i++) {
  70498. var fromSubpathBezier = fromArr[i];
  70499. var toSubpathBezier = toArr[i];
  70500. var fromCp = centroid(fromSubpathBezier);
  70501. var toCp = centroid(toSubpathBezier);
  70502. if (fromNeedsReverse == null) {
  70503. fromNeedsReverse = fromCp[2] < 0 !== toCp[2] < 0;
  70504. }
  70505. var newFromSubpathBezier = [];
  70506. var newToSubpathBezier = [];
  70507. var bestAngle = 0;
  70508. var bestScore = Infinity;
  70509. var tmpArr_1 = [];
  70510. var len$$1 = fromSubpathBezier.length;
  70511. if (fromNeedsReverse) {
  70512. fromSubpathBezier = reverse(fromSubpathBezier);
  70513. }
  70514. var offset = findBestRingOffset(fromSubpathBezier, toSubpathBezier, fromCp, toCp) * 6;
  70515. var len2 = len$$1 - 2;
  70516. for (var k = 0; k < len2; k += 2) {
  70517. var idx = (offset + k) % len2 + 2;
  70518. newFromSubpathBezier[k + 2] = fromSubpathBezier[idx] - fromCp[0];
  70519. newFromSubpathBezier[k + 3] = fromSubpathBezier[idx + 1] - fromCp[1];
  70520. }
  70521. newFromSubpathBezier[0] = fromSubpathBezier[offset] - fromCp[0];
  70522. newFromSubpathBezier[1] = fromSubpathBezier[offset + 1] - fromCp[1];
  70523. if (searchAngleIteration > 0) {
  70524. var step = searchAngleRange / searchAngleIteration;
  70525. for (var angle = -searchAngleRange / 2; angle <= searchAngleRange / 2; angle += step) {
  70526. var sa = Math.sin(angle);
  70527. var ca = Math.cos(angle);
  70528. var score = 0;
  70529. for (var k = 0; k < fromSubpathBezier.length; k += 2) {
  70530. var x0 = newFromSubpathBezier[k];
  70531. var y0 = newFromSubpathBezier[k + 1];
  70532. var x1 = toSubpathBezier[k] - toCp[0];
  70533. var y1 = toSubpathBezier[k + 1] - toCp[1];
  70534. var newX1 = x1 * ca - y1 * sa;
  70535. var newY1 = x1 * sa + y1 * ca;
  70536. tmpArr_1[k] = newX1;
  70537. tmpArr_1[k + 1] = newY1;
  70538. var dx = newX1 - x0;
  70539. var dy = newY1 - y0;
  70540. score += dx * dx + dy * dy;
  70541. }
  70542. if (score < bestScore) {
  70543. bestScore = score;
  70544. bestAngle = angle;
  70545. for (var m = 0; m < tmpArr_1.length; m++) {
  70546. newToSubpathBezier[m] = tmpArr_1[m];
  70547. }
  70548. }
  70549. }
  70550. } else {
  70551. for (var i_1 = 0; i_1 < len$$1; i_1 += 2) {
  70552. newToSubpathBezier[i_1] = toSubpathBezier[i_1] - toCp[0];
  70553. newToSubpathBezier[i_1 + 1] = toSubpathBezier[i_1 + 1] - toCp[1];
  70554. }
  70555. }
  70556. result.push({
  70557. from: newFromSubpathBezier,
  70558. to: newToSubpathBezier,
  70559. fromCp: fromCp,
  70560. toCp: toCp,
  70561. rotation: -bestAngle
  70562. });
  70563. }
  70564. return result;
  70565. }
  70566. function morphPath(fromPath, toPath, animationOpts) {
  70567. var fromPathProxy;
  70568. var toPathProxy;
  70569. if (!fromPath || !toPath) {
  70570. return toPath;
  70571. }
  70572. !fromPath.path && fromPath.createPathProxy();
  70573. fromPathProxy = fromPath.path;
  70574. fromPathProxy.beginPath();
  70575. fromPath.buildPath(fromPathProxy, fromPath.shape);
  70576. !toPath.path && toPath.createPathProxy();
  70577. toPathProxy = toPath.path;
  70578. toPathProxy === fromPathProxy && (toPathProxy = new PathProxy(false));
  70579. toPathProxy.beginPath();
  70580. if (isIndividualMorphingPath(toPath)) {
  70581. toPath.__oldBuildPath(toPathProxy, toPath.shape);
  70582. } else {
  70583. toPath.buildPath(toPathProxy, toPath.shape);
  70584. }
  70585. var _a = alignBezierCurves(pathToBezierCurves(fromPathProxy), pathToBezierCurves(toPathProxy)),
  70586. fromBezierCurves = _a[0],
  70587. toBezierCurves = _a[1];
  70588. var morphingData = findBestMorphingRotation(fromBezierCurves, toBezierCurves, 10, Math.PI);
  70589. becomeIndividualMorphingPath(toPath, morphingData, 0);
  70590. var oldDone = animationOpts && animationOpts.done;
  70591. var oldAborted = animationOpts && animationOpts.aborted;
  70592. var oldDuring = animationOpts && animationOpts.during;
  70593. toPath.animateTo({
  70594. __morphT: 1
  70595. }, defaults({
  70596. during: function (p) {
  70597. toPath.dirtyShape();
  70598. oldDuring && oldDuring(p);
  70599. },
  70600. done: function () {
  70601. restoreIndividualMorphingPath(toPath);
  70602. toPath.createPathProxy();
  70603. toPath.dirtyShape();
  70604. oldDone && oldDone();
  70605. },
  70606. aborted: function () {
  70607. oldAborted && oldAborted();
  70608. }
  70609. }, animationOpts));
  70610. return toPath;
  70611. }
  70612. function morphingPathBuildPath(path) {
  70613. var morphingData = this.__morphingData;
  70614. var t = this.__morphT;
  70615. var onet = 1 - t;
  70616. var newCp = [];
  70617. for (var i = 0; i < morphingData.length; i++) {
  70618. var item = morphingData[i];
  70619. var from = item.from;
  70620. var to = item.to;
  70621. var angle = item.rotation * t;
  70622. var fromCp = item.fromCp;
  70623. var toCp = item.toCp;
  70624. var sa = Math.sin(angle);
  70625. var ca = Math.cos(angle);
  70626. lerp(newCp, fromCp, toCp, t);
  70627. for (var m = 0; m < from.length; m += 2) {
  70628. var x0 = from[m];
  70629. var y0 = from[m + 1];
  70630. var x1 = to[m];
  70631. var y1 = to[m + 1];
  70632. var x = x0 * onet + x1 * t;
  70633. var y = y0 * onet + y1 * t;
  70634. tmpArr$1[m] = x * ca - y * sa + newCp[0];
  70635. tmpArr$1[m + 1] = x * sa + y * ca + newCp[1];
  70636. }
  70637. for (var m = 0; m < from.length;) {
  70638. if (m === 0) {
  70639. path.moveTo(tmpArr$1[m++], tmpArr$1[m++]);
  70640. }
  70641. path.bezierCurveTo(tmpArr$1[m++], tmpArr$1[m++], tmpArr$1[m++], tmpArr$1[m++], tmpArr$1[m++], tmpArr$1[m++]);
  70642. }
  70643. }
  70644. }
  70645. function becomeIndividualMorphingPath(path, morphingData, morphT) {
  70646. if (isIndividualMorphingPath(path)) {
  70647. updateIndividualMorphingPath(path, morphingData, morphT);
  70648. return;
  70649. }
  70650. var morphingPath = path;
  70651. morphingPath.__oldBuildPath = morphingPath.buildPath;
  70652. morphingPath.buildPath = morphingPathBuildPath;
  70653. updateIndividualMorphingPath(morphingPath, morphingData, morphT);
  70654. }
  70655. function updateIndividualMorphingPath(morphingPath, morphingData, morphT) {
  70656. morphingPath.__morphingData = morphingData;
  70657. morphingPath.__morphT = morphT;
  70658. }
  70659. function restoreIndividualMorphingPath(path) {
  70660. if (isIndividualMorphingPath(path)) {
  70661. path.buildPath = path.__oldBuildPath;
  70662. path.__oldBuildPath = path.__morphingData = null;
  70663. }
  70664. }
  70665. function isIndividualMorphingPath(path) {
  70666. return path.__oldBuildPath != null;
  70667. }
  70668. function isCombiningPath(path) {
  70669. return !!path.__combiningSubList;
  70670. }
  70671. function isInAnyMorphing(path) {
  70672. return isIndividualMorphingPath(path) || isCombiningPath(path);
  70673. }
  70674. function combine(fromPathList, toPath, animationOpts, copyPropsIfDivided) {
  70675. var fromIndividuals = [];
  70676. var separateCount = 0;
  70677. for (var i = 0; i < fromPathList.length; i++) {
  70678. var fromPath = fromPathList[i];
  70679. if (isCombiningPath(fromPath)) {
  70680. var fromCombiningSubList = fromPath.__combiningSubList;
  70681. for (var j = 0; j < fromCombiningSubList.length; j++) {
  70682. fromIndividuals.push(fromCombiningSubList[j]);
  70683. }
  70684. separateCount += fromCombiningSubList.length;
  70685. } else {
  70686. fromIndividuals.push(fromPath);
  70687. separateCount++;
  70688. }
  70689. }
  70690. if (!separateCount) {
  70691. return;
  70692. }
  70693. var dividingMethod = animationOpts ? animationOpts.dividingMethod : null;
  70694. var toPathSplittedList = divideShape(toPath, separateCount, dividingMethod);
  70695. assert$1(toPathSplittedList.length === separateCount);
  70696. var oldDone = animationOpts && animationOpts.done;
  70697. var oldAborted = animationOpts && animationOpts.aborted;
  70698. var oldDuring = animationOpts && animationOpts.during;
  70699. var doneCount = 0;
  70700. var abortedCalled = false;
  70701. var morphAnimationOpts = defaults({
  70702. during: function (p) {
  70703. oldDuring && oldDuring(p);
  70704. },
  70705. done: function () {
  70706. doneCount++;
  70707. if (doneCount === toPathSplittedList.length) {
  70708. restoreCombiningPath(toPath);
  70709. oldDone && oldDone();
  70710. }
  70711. },
  70712. aborted: function () {
  70713. if (!abortedCalled) {
  70714. abortedCalled = true;
  70715. oldAborted && oldAborted();
  70716. }
  70717. }
  70718. }, animationOpts);
  70719. for (var i = 0; i < separateCount; i++) {
  70720. var from = fromIndividuals[i];
  70721. var to = toPathSplittedList[i];
  70722. copyPropsIfDivided && copyPropsIfDivided(toPath, to, true);
  70723. morphPath(from, to, morphAnimationOpts);
  70724. }
  70725. becomeCombiningPath(toPath, toPathSplittedList);
  70726. return {
  70727. fromIndividuals: fromIndividuals,
  70728. toIndividuals: toPathSplittedList,
  70729. count: separateCount
  70730. };
  70731. }
  70732. function becomeCombiningPath(path, combiningSubList) {
  70733. if (isCombiningPath(path)) {
  70734. updateCombiningPathSubList(path, combiningSubList);
  70735. return;
  70736. }
  70737. var combiningPath = path;
  70738. updateCombiningPathSubList(combiningPath, combiningSubList);
  70739. combiningPath.__oldAddSelfToZr = path.addSelfToZr;
  70740. combiningPath.__oldRemoveSelfFromZr = path.removeSelfFromZr;
  70741. combiningPath.addSelfToZr = combiningAddSelfToZr;
  70742. combiningPath.removeSelfFromZr = combiningRemoveSelfFromZr;
  70743. combiningPath.__oldBuildPath = combiningPath.buildPath;
  70744. combiningPath.buildPath = noop;
  70745. combiningPath.childrenRef = combiningChildrenRef;
  70746. }
  70747. function restoreCombiningPath(path) {
  70748. if (!isCombiningPath(path)) {
  70749. return;
  70750. }
  70751. var combiningPath = path;
  70752. updateCombiningPathSubList(combiningPath, null);
  70753. combiningPath.addSelfToZr = combiningPath.__oldAddSelfToZr;
  70754. combiningPath.removeSelfFromZr = combiningPath.__oldRemoveSelfFromZr;
  70755. combiningPath.buildPath = combiningPath.__oldBuildPath;
  70756. combiningPath.childrenRef = combiningPath.__combiningSubList = combiningPath.__oldAddSelfToZr = combiningPath.__oldRemoveSelfFromZr = combiningPath.__oldBuildPath = null;
  70757. }
  70758. function updateCombiningPathSubList(combiningPath, combiningSubList) {
  70759. if (combiningPath.__combiningSubList !== combiningSubList) {
  70760. combiningPathSubListAddRemoveWithZr(combiningPath, 'removeSelfFromZr');
  70761. combiningPath.__combiningSubList = combiningSubList;
  70762. if (combiningSubList) {
  70763. for (var i = 0; i < combiningSubList.length; i++) {
  70764. combiningSubList[i].parent = combiningPath;
  70765. }
  70766. }
  70767. combiningPathSubListAddRemoveWithZr(combiningPath, 'addSelfToZr');
  70768. }
  70769. }
  70770. function combiningAddSelfToZr(zr) {
  70771. this.__oldAddSelfToZr(zr);
  70772. combiningPathSubListAddRemoveWithZr(this, 'addSelfToZr');
  70773. }
  70774. function combiningPathSubListAddRemoveWithZr(path, method) {
  70775. var combiningSubList = path.__combiningSubList;
  70776. var zr = path.__zr;
  70777. if (combiningSubList && zr) {
  70778. for (var i = 0; i < combiningSubList.length; i++) {
  70779. var child = combiningSubList[i];
  70780. child[method](zr);
  70781. }
  70782. }
  70783. }
  70784. function combiningRemoveSelfFromZr(zr) {
  70785. this.__oldRemoveSelfFromZr(zr);
  70786. var combiningSubList = this.__combiningSubList;
  70787. for (var i = 0; i < combiningSubList.length; i++) {
  70788. var child = combiningSubList[i];
  70789. child.removeSelfFromZr(zr);
  70790. }
  70791. }
  70792. function combiningChildrenRef() {
  70793. return this.__combiningSubList;
  70794. }
  70795. function separate(fromPath, toPathList, animationOpts, copyPropsIfDivided) {
  70796. var toPathListLen = toPathList.length;
  70797. var fromPathList;
  70798. var dividingMethod = animationOpts ? animationOpts.dividingMethod : null;
  70799. var copyProps = false;
  70800. if (isCombiningPath(fromPath)) {
  70801. var fromCombiningSubList = fromPath.__combiningSubList;
  70802. if (fromCombiningSubList.length === toPathListLen) {
  70803. fromPathList = fromCombiningSubList;
  70804. } else {
  70805. fromPathList = divideShape(fromPath, toPathListLen, dividingMethod);
  70806. copyProps = true;
  70807. }
  70808. } else {
  70809. fromPathList = divideShape(fromPath, toPathListLen, dividingMethod);
  70810. copyProps = true;
  70811. }
  70812. assert$1(fromPathList.length === toPathListLen);
  70813. for (var i = 0; i < toPathListLen; i++) {
  70814. if (copyProps && copyPropsIfDivided) {
  70815. copyPropsIfDivided(fromPath, fromPathList[i], false);
  70816. }
  70817. morphPath(fromPathList[i], toPathList[i], animationOpts);
  70818. }
  70819. return {
  70820. fromIndividuals: fromPathList,
  70821. toIndividuals: toPathList,
  70822. count: toPathListLen
  70823. };
  70824. }
  70825. function divideShape(path, separateCount, dividingMethod) {
  70826. return dividingMethod === 'duplicate' ? duplicateShape(path, separateCount) : splitShape(path, separateCount);
  70827. }
  70828. function splitShape(path, separateCount) {
  70829. var resultPaths = [];
  70830. if (separateCount <= 0) {
  70831. return resultPaths;
  70832. }
  70833. if (separateCount === 1) {
  70834. return duplicateShape(path, separateCount);
  70835. }
  70836. if (path instanceof Rect) {
  70837. var toPathShape = path.shape;
  70838. var splitPropIdx = toPathShape.height > toPathShape.width ? 1 : 0;
  70839. var propWH = PROP_WH[splitPropIdx];
  70840. var propXY = PROP_XY[splitPropIdx];
  70841. var subWH = toPathShape[propWH] / separateCount;
  70842. var xyCurr = toPathShape[propXY];
  70843. for (var i = 0; i < separateCount; i++, xyCurr += subWH) {
  70844. var subShape = {
  70845. x: toPathShape.x,
  70846. y: toPathShape.y,
  70847. width: toPathShape.width,
  70848. height: toPathShape.height
  70849. };
  70850. subShape[propXY] = xyCurr;
  70851. subShape[propWH] = i < separateCount - 1 ? subWH : toPathShape[propXY] + toPathShape[propWH] - xyCurr;
  70852. var splitted = new Rect({
  70853. shape: subShape
  70854. });
  70855. resultPaths.push(splitted);
  70856. }
  70857. } else if (path instanceof Sector) {
  70858. var toPathShape = path.shape;
  70859. var clockwise = toPathShape.clockwise;
  70860. var startAngle = toPathShape.startAngle;
  70861. var endAngle = toPathShape.endAngle;
  70862. var endAngleNormalized = normalizeRadian$1(startAngle, toPathShape.endAngle, clockwise);
  70863. var step = (endAngleNormalized - startAngle) / separateCount;
  70864. var angleCurr = startAngle;
  70865. for (var i = 0; i < separateCount; i++, angleCurr += step) {
  70866. var splitted = new Sector({
  70867. shape: {
  70868. cx: toPathShape.cx,
  70869. cy: toPathShape.cy,
  70870. r: toPathShape.r,
  70871. r0: toPathShape.r0,
  70872. clockwise: clockwise,
  70873. startAngle: angleCurr,
  70874. endAngle: i === separateCount - 1 ? endAngle : angleCurr + step
  70875. }
  70876. });
  70877. resultPaths.push(splitted);
  70878. }
  70879. } else {
  70880. return duplicateShape(path, separateCount);
  70881. }
  70882. return resultPaths;
  70883. }
  70884. function duplicateShape(path, separateCount) {
  70885. var resultPaths = [];
  70886. if (separateCount <= 0) {
  70887. return resultPaths;
  70888. }
  70889. var ctor = path.constructor;
  70890. for (var i = 0; i < separateCount; i++) {
  70891. var sub$$1 = new ctor({
  70892. shape: clone(path.shape)
  70893. });
  70894. resultPaths.push(sub$$1);
  70895. }
  70896. return resultPaths;
  70897. }
  70898. function normalizeRadian$1(start, end, clockwise) {
  70899. return end + PI2$9 * Math[clockwise ? 'ceil' : 'floor']((start - end) / PI2$9);
  70900. }
  70901. /*
  70902. * Licensed to the Apache Software Foundation (ASF) under one
  70903. * or more contributor license agreements. See the NOTICE file
  70904. * distributed with this work for additional information
  70905. * regarding copyright ownership. The ASF licenses this file
  70906. * to you under the Apache License, Version 2.0 (the
  70907. * "License"); you may not use this file except in compliance
  70908. * with the License. You may obtain a copy of the License at
  70909. *
  70910. * http://www.apache.org/licenses/LICENSE-2.0
  70911. *
  70912. * Unless required by applicable law or agreed to in writing,
  70913. * software distributed under the License is distributed on an
  70914. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  70915. * KIND, either express or implied. See the License for the
  70916. * specific language governing permissions and limitations
  70917. * under the License.
  70918. */
  70919. /**
  70920. * AUTO-GENERATED FILE. DO NOT MODIFY.
  70921. */
  70922. /*
  70923. * Licensed to the Apache Software Foundation (ASF) under one
  70924. * or more contributor license agreements. See the NOTICE file
  70925. * distributed with this work for additional information
  70926. * regarding copyright ownership. The ASF licenses this file
  70927. * to you under the Apache License, Version 2.0 (the
  70928. * "License"); you may not use this file except in compliance
  70929. * with the License. You may obtain a copy of the License at
  70930. *
  70931. * http://www.apache.org/licenses/LICENSE-2.0
  70932. *
  70933. * Unless required by applicable law or agreed to in writing,
  70934. * software distributed under the License is distributed on an
  70935. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  70936. * KIND, either express or implied. See the License for the
  70937. * specific language governing permissions and limitations
  70938. * under the License.
  70939. */
  70940. var inner$9 = makeInner();
  70941. var TRANSFORM_PROPS = {
  70942. x: 1,
  70943. y: 1,
  70944. scaleX: 1,
  70945. scaleY: 1,
  70946. originX: 1,
  70947. originY: 1,
  70948. rotation: 1
  70949. };
  70950. var transformPropNamesStr = keys(TRANSFORM_PROPS).join(', '); // Also compat with ec4, where
  70951. // `visual('color') visual('borderColor')` is supported.
  70952. var STYLE_VISUAL_TYPE = {
  70953. color: 'fill',
  70954. borderColor: 'stroke'
  70955. };
  70956. var NON_STYLE_VISUAL_PROPS = {
  70957. symbol: 1,
  70958. symbolSize: 1,
  70959. symbolKeepAspect: 1,
  70960. legendSymbol: 1,
  70961. visualMeta: 1,
  70962. liftZ: 1,
  70963. decal: 1
  70964. };
  70965. var EMPHASIS = 'emphasis';
  70966. var NORMAL = 'normal';
  70967. var BLUR = 'blur';
  70968. var SELECT = 'select';
  70969. var STATES = [NORMAL, EMPHASIS, BLUR, SELECT];
  70970. var PATH_ITEM_STYLE = {
  70971. normal: ['itemStyle'],
  70972. emphasis: [EMPHASIS, 'itemStyle'],
  70973. blur: [BLUR, 'itemStyle'],
  70974. select: [SELECT, 'itemStyle']
  70975. };
  70976. var PATH_LABEL = {
  70977. normal: ['label'],
  70978. emphasis: [EMPHASIS, 'label'],
  70979. blur: [BLUR, 'label'],
  70980. select: [SELECT, 'label']
  70981. }; // Use prefix to avoid index to be the same as el.name,
  70982. // which will cause weird update animation.
  70983. var GROUP_DIFF_PREFIX = 'e\0\0';
  70984. var attachedTxInfoTmp = {
  70985. normal: {},
  70986. emphasis: {},
  70987. blur: {},
  70988. select: {}
  70989. };
  70990. var LEGACY_TRANSFORM_PROPS = {
  70991. position: ['x', 'y'],
  70992. scale: ['scaleX', 'scaleY'],
  70993. origin: ['originX', 'originY']
  70994. };
  70995. var tmpTransformable = new Transformable();
  70996. /**
  70997. * To reduce total package size of each coordinate systems, the modules `prepareCustom`
  70998. * of each coordinate systems are not required by each coordinate systems directly, but
  70999. * required by the module `custom`.
  71000. *
  71001. * prepareInfoForCustomSeries {Function}: optional
  71002. * @return {Object} {coordSys: {...}, api: {
  71003. * coord: function (data, clamp) {}, // return point in global.
  71004. * size: function (dataSize, dataItem) {} // return size of each axis in coordSys.
  71005. * }}
  71006. */
  71007. var prepareCustoms = {
  71008. cartesian2d: cartesianPrepareCustom,
  71009. geo: geoPrepareCustom,
  71010. singleAxis: singlePrepareCustom,
  71011. polar: polarPrepareCustom,
  71012. calendar: calendarPrepareCustom
  71013. };
  71014. var CustomSeriesModel =
  71015. /** @class */
  71016. function (_super) {
  71017. __extends(CustomSeriesModel, _super);
  71018. function CustomSeriesModel() {
  71019. var _this = _super !== null && _super.apply(this, arguments) || this;
  71020. _this.type = CustomSeriesModel.type;
  71021. return _this;
  71022. }
  71023. CustomSeriesModel.prototype.optionUpdated = function () {
  71024. this.currentZLevel = this.get('zlevel', true);
  71025. this.currentZ = this.get('z', true);
  71026. };
  71027. CustomSeriesModel.prototype.getInitialData = function (option, ecModel) {
  71028. return createListFromArray(this.getSource(), this);
  71029. };
  71030. CustomSeriesModel.prototype.getDataParams = function (dataIndex, dataType, el) {
  71031. var params = _super.prototype.getDataParams.call(this, dataIndex, dataType);
  71032. el && (params.info = inner$9(el).info);
  71033. return params;
  71034. };
  71035. CustomSeriesModel.type = 'series.custom';
  71036. CustomSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar'];
  71037. CustomSeriesModel.defaultOption = {
  71038. coordinateSystem: 'cartesian2d',
  71039. zlevel: 0,
  71040. z: 2,
  71041. legendHoverLink: true,
  71042. // Custom series will not clip by default.
  71043. // Some case will use custom series to draw label
  71044. // For example https://echarts.apache.org/examples/en/editor.html?c=custom-gantt-flight
  71045. clip: false // Cartesian coordinate system
  71046. // xAxisIndex: 0,
  71047. // yAxisIndex: 0,
  71048. // Polar coordinate system
  71049. // polarIndex: 0,
  71050. // Geo coordinate system
  71051. // geoIndex: 0,
  71052. };
  71053. return CustomSeriesModel;
  71054. }(SeriesModel);
  71055. var CustomSeriesView =
  71056. /** @class */
  71057. function (_super) {
  71058. __extends(CustomSeriesView, _super);
  71059. function CustomSeriesView() {
  71060. var _this = _super !== null && _super.apply(this, arguments) || this;
  71061. _this.type = CustomSeriesView.type;
  71062. return _this;
  71063. }
  71064. CustomSeriesView.prototype.render = function (customSeries, ecModel, api, payload) {
  71065. var oldData = this._data;
  71066. var data = customSeries.getData();
  71067. var group = this.group;
  71068. var renderItem = makeRenderItem(customSeries, data, ecModel, api); // By default, merge mode is applied. In most cases, custom series is
  71069. // used in the scenario that data amount is not large but graphic elements
  71070. // is complicated, where merge mode is probably necessary for optimization.
  71071. // For example, reuse graphic elements and only update the transform when
  71072. // roam or data zoom according to `actionType`.
  71073. var transOpt = customSeries.__transientTransitionOpt; // Enable user to disable transition animation by both set
  71074. // `from` and `to` dimension as `null`/`undefined`.
  71075. if (transOpt && (transOpt.from == null || transOpt.to == null)) {
  71076. oldData && oldData.each(function (oldIdx) {
  71077. doRemoveEl(oldData.getItemGraphicEl(oldIdx), customSeries, group);
  71078. });
  71079. data.each(function (newIdx) {
  71080. createOrUpdateItem(api, null, newIdx, renderItem(newIdx, payload), customSeries, group, data, null);
  71081. });
  71082. } else {
  71083. var morphPreparation_1 = new MorphPreparation(customSeries, transOpt);
  71084. var diffMode = transOpt ? 'multiple' : 'oneToOne';
  71085. new DataDiffer(oldData ? oldData.getIndices() : [], data.getIndices(), createGetKey(oldData, diffMode, transOpt && transOpt.from), createGetKey(data, diffMode, transOpt && transOpt.to), null, diffMode).add(function (newIdx) {
  71086. createOrUpdateItem(api, null, newIdx, renderItem(newIdx, payload), customSeries, group, data, null);
  71087. }).remove(function (oldIdx) {
  71088. doRemoveEl(oldData.getItemGraphicEl(oldIdx), customSeries, group);
  71089. }).update(function (newIdx, oldIdx) {
  71090. morphPreparation_1.reset('oneToOne');
  71091. var oldEl = oldData.getItemGraphicEl(oldIdx);
  71092. morphPreparation_1.findAndAddFrom(oldEl); // PENDING:
  71093. // if may morph, currently we alway recreate the whole el.
  71094. // because if reuse some of the el in the group tree, the old el has to
  71095. // be removed from the group, and consequently we can not calculate
  71096. // the "global transition" of the old element.
  71097. // But is there performance issue?
  71098. if (morphPreparation_1.hasFrom()) {
  71099. removeElementDirectly(oldEl, group);
  71100. oldEl = null;
  71101. }
  71102. createOrUpdateItem(api, oldEl, newIdx, renderItem(newIdx, payload), customSeries, group, data, morphPreparation_1);
  71103. morphPreparation_1.applyMorphing();
  71104. }).updateManyToOne(function (newIdx, oldIndices) {
  71105. morphPreparation_1.reset('manyToOne');
  71106. for (var i = 0; i < oldIndices.length; i++) {
  71107. var oldEl = oldData.getItemGraphicEl(oldIndices[i]);
  71108. morphPreparation_1.findAndAddFrom(oldEl);
  71109. removeElementDirectly(oldEl, group);
  71110. }
  71111. createOrUpdateItem(api, null, newIdx, renderItem(newIdx, payload), customSeries, group, data, morphPreparation_1);
  71112. morphPreparation_1.applyMorphing();
  71113. }).updateOneToMany(function (newIndices, oldIdx) {
  71114. morphPreparation_1.reset('oneToMany');
  71115. var newLen = newIndices.length;
  71116. var oldEl = oldData.getItemGraphicEl(oldIdx);
  71117. morphPreparation_1.findAndAddFrom(oldEl);
  71118. removeElementDirectly(oldEl, group);
  71119. for (var i = 0; i < newLen; i++) {
  71120. createOrUpdateItem(api, null, newIndices[i], renderItem(newIndices[i], payload), customSeries, group, data, morphPreparation_1);
  71121. }
  71122. morphPreparation_1.applyMorphing();
  71123. }).execute();
  71124. } // Do clipping
  71125. var clipPath = customSeries.get('clip', true) ? createClipPath(customSeries.coordinateSystem, false, customSeries) : null;
  71126. if (clipPath) {
  71127. group.setClipPath(clipPath);
  71128. } else {
  71129. group.removeClipPath();
  71130. }
  71131. this._data = data;
  71132. };
  71133. CustomSeriesView.prototype.incrementalPrepareRender = function (customSeries, ecModel, api) {
  71134. this.group.removeAll();
  71135. this._data = null;
  71136. };
  71137. CustomSeriesView.prototype.incrementalRender = function (params, customSeries, ecModel, api, payload) {
  71138. var data = customSeries.getData();
  71139. var renderItem = makeRenderItem(customSeries, data, ecModel, api);
  71140. function setIncrementalAndHoverLayer(el) {
  71141. if (!el.isGroup) {
  71142. el.incremental = true;
  71143. el.ensureState('emphasis').hoverLayer = true;
  71144. }
  71145. }
  71146. for (var idx = params.start; idx < params.end; idx++) {
  71147. var el = createOrUpdateItem(null, null, idx, renderItem(idx, payload), customSeries, this.group, data, null);
  71148. el.traverse(setIncrementalAndHoverLayer);
  71149. }
  71150. };
  71151. CustomSeriesView.prototype.filterForExposedEvent = function (eventType, query, targetEl, packedEvent) {
  71152. var elementName = query.element;
  71153. if (elementName == null || targetEl.name === elementName) {
  71154. return true;
  71155. } // Enable to give a name on a group made by `renderItem`, and listen
  71156. // events that triggerd by its descendents.
  71157. while ((targetEl = targetEl.__hostTarget || targetEl.parent) && targetEl !== this.group) {
  71158. if (targetEl.name === elementName) {
  71159. return true;
  71160. }
  71161. }
  71162. return false;
  71163. };
  71164. CustomSeriesView.type = 'custom';
  71165. return CustomSeriesView;
  71166. }(ChartView);
  71167. function createGetKey(data, diffMode, dimension) {
  71168. if (!data) {
  71169. return;
  71170. }
  71171. if (diffMode === 'oneToOne') {
  71172. return function (rawIdx, dataIndex) {
  71173. return data.getId(dataIndex);
  71174. };
  71175. }
  71176. var diffByDimName = data.getDimension(dimension);
  71177. var dimInfo = data.getDimensionInfo(diffByDimName);
  71178. if (!dimInfo) {
  71179. var errMsg = '';
  71180. {
  71181. errMsg = dimension + " is not a valid dimension.";
  71182. }
  71183. throwError(errMsg);
  71184. }
  71185. var ordinalMeta = dimInfo.ordinalMeta;
  71186. return function (rawIdx, dataIndex) {
  71187. var key = data.get(diffByDimName, dataIndex);
  71188. if (ordinalMeta) {
  71189. key = ordinalMeta.categories[key];
  71190. }
  71191. return key == null || eqNaN(key) ? rawIdx + '' : '_ec_' + key;
  71192. };
  71193. }
  71194. function createEl(elOption) {
  71195. var graphicType = elOption.type;
  71196. var el; // Those graphic elements are not shapes. They should not be
  71197. // overwritten by users, so do them first.
  71198. if (graphicType === 'path') {
  71199. var shape = elOption.shape; // Using pathRect brings convenience to users sacle svg path.
  71200. var pathRect = shape.width != null && shape.height != null ? {
  71201. x: shape.x || 0,
  71202. y: shape.y || 0,
  71203. width: shape.width,
  71204. height: shape.height
  71205. } : null;
  71206. var pathData = getPathData(shape); // Path is also used for icon, so layout 'center' by default.
  71207. el = makePath(pathData, null, pathRect, shape.layout || 'center');
  71208. inner$9(el).customPathData = pathData;
  71209. } else if (graphicType === 'image') {
  71210. el = new ZRImage({});
  71211. inner$9(el).customImagePath = elOption.style.image;
  71212. } else if (graphicType === 'text') {
  71213. el = new ZRText({}); // inner(el).customText = (elOption.style as TextStyleProps).text;
  71214. } else if (graphicType === 'group') {
  71215. el = new Group();
  71216. } else if (graphicType === 'compoundPath') {
  71217. throw new Error('"compoundPath" is not supported yet.');
  71218. } else {
  71219. var Clz = getShapeClass(graphicType);
  71220. if (!Clz) {
  71221. var errMsg = '';
  71222. {
  71223. errMsg = 'graphic type "' + graphicType + '" can not be found.';
  71224. }
  71225. throwError(errMsg);
  71226. }
  71227. el = new Clz();
  71228. }
  71229. inner$9(el).customGraphicType = graphicType;
  71230. el.name = elOption.name; // Compat ec4: the default z2 lift is 1. If changing the number,
  71231. // some cases probably be broken: hierarchy layout along z, like circle packing,
  71232. // where emphasis only intending to modify color/border rather than lift z2.
  71233. el.z2EmphasisLift = 1;
  71234. el.z2SelectLift = 1;
  71235. return el;
  71236. }
  71237. /**
  71238. * ----------------------------------------------------------
  71239. * [STRATEGY_MERGE] Merge properties or erase all properties:
  71240. *
  71241. * Based on the fact that the existing zr element probably be reused, we now consider whether
  71242. * merge or erase all properties to the exsiting elements.
  71243. * That is, if a certain props is not specified in the lastest return of `renderItem`:
  71244. * + "Merge" means that do not modify the value on the existing element.
  71245. * + "Erase all" means that use a default value to the existing element.
  71246. *
  71247. * "Merge" might bring some unexpected state retaining for users and "erase all" seams to be
  71248. * more safe. "erase all" force users to specify all of the props each time, which is recommanded
  71249. * in most cases.
  71250. * But "erase all" theoretically disables the chance of performance optimization (e.g., just
  71251. * generete shape and style at the first time rather than always do that).
  71252. * So we still use "merge" rather than "erase all". If users need "erase all", they can
  71253. * simple always set all of the props each time.
  71254. * Some "object-like" config like `textConfig`, `textContent`, `style` which are not needed for
  71255. * every elment, so we replace them only when user specify them. And the that is a total replace.
  71256. *
  71257. * TODO: there is no hint of 'isFirst' to users. So the performance enhancement can not be
  71258. * performed yet. Consider the case:
  71259. * (1) setOption to "mergeChildren" with a smaller children count
  71260. * (2) Use dataZoom to make an item disappear.
  71261. * (3) User dataZoom to make the item display again. At that time, renderItem need to return the
  71262. * full option rather than partial option to recreate the element.
  71263. *
  71264. * ----------------------------------------------
  71265. * [STRATEGY_NULL] `hasOwnProperty` or `== null`:
  71266. *
  71267. * Ditinguishing "own property" probably bring little trouble to user when make el options.
  71268. * So we trade a {xx: null} or {xx: undefined} as "not specified" if possible rather than
  71269. * "set them to null/undefined". In most cases, props can not be cleared. Some typicall
  71270. * clearable props like `style`/`textConfig`/`textContent` we enable `false` to means
  71271. * "clear". In some othere special cases that the prop is able to set as null/undefined,
  71272. * but not suitable to use `false`, `hasOwnProperty` is checked.
  71273. *
  71274. * ---------------------------------------------
  71275. * [STRATEGY_TRANSITION] The rule of transition:
  71276. * + For props on the root level of a element:
  71277. * If there is no `transition` specified, tansform props will be transitioned by default,
  71278. * which is the same as the previous setting in echarts4 and suitable for the scenario
  71279. * of dataZoom change.
  71280. * If `transition` specified, only the specified props will be transitioned.
  71281. * + For props in `shape` and `style`:
  71282. * Only props specified in `transition` will be transitioned.
  71283. * + Break:
  71284. * Since ec5, do not make transition to shape by default, because it might result in
  71285. * performance issue (especially `points` of polygon) and do not necessary in most cases.
  71286. *
  71287. * @return if `isMorphTo`, return `allPropsFinal`.
  71288. */
  71289. function updateElNormal( // Can be null/undefined
  71290. api, el, // Whether be a morph target.
  71291. isMorphTo, dataIndex, elOption, styleOpt, attachedTxInfo, seriesModel, isInit, isTextContent) {
  71292. var transFromProps = {};
  71293. var allPropsFinal = {};
  71294. var elDisplayable = el.isGroup ? null : el; // If be "morph to", delay the `updateElNormal` when all of the els in
  71295. // this data item processed. Because at that time we can get all of the
  71296. // "morph from" and make correct separate/combine.
  71297. !isMorphTo && prepareShapeOrExtraTransitionFrom('shape', el, null, elOption, transFromProps, isInit);
  71298. prepareShapeOrExtraAllPropsFinal('shape', elOption, allPropsFinal);
  71299. !isMorphTo && prepareShapeOrExtraTransitionFrom('extra', el, null, elOption, transFromProps, isInit);
  71300. prepareShapeOrExtraAllPropsFinal('extra', elOption, allPropsFinal);
  71301. !isMorphTo && prepareTransformTransitionFrom(el, null, elOption, transFromProps, isInit);
  71302. prepareTransformAllPropsFinal(elOption, allPropsFinal);
  71303. var txCfgOpt = attachedTxInfo && attachedTxInfo.normal.cfg;
  71304. if (txCfgOpt) {
  71305. // PENDING: whether use user object directly rather than clone?
  71306. // TODO:5.0 textConfig transition animation?
  71307. el.setTextConfig(txCfgOpt);
  71308. }
  71309. if (el.type === 'text' && styleOpt) {
  71310. var textOptionStyle = styleOpt; // Compatible with ec4: if `textFill` or `textStroke` exists use them.
  71311. hasOwn(textOptionStyle, 'textFill') && (textOptionStyle.fill = textOptionStyle.textFill);
  71312. hasOwn(textOptionStyle, 'textStroke') && (textOptionStyle.stroke = textOptionStyle.textStroke);
  71313. }
  71314. if (styleOpt) {
  71315. var decalPattern = void 0;
  71316. var decalObj = isPath$1(el) ? styleOpt.decal : null;
  71317. if (api && decalObj) {
  71318. decalObj.dirty = true;
  71319. decalPattern = createOrUpdatePatternFromDecal(decalObj, api);
  71320. } // Always overwrite in case user specify this prop.
  71321. styleOpt.__decalPattern = decalPattern;
  71322. }
  71323. !isMorphTo && prepareStyleTransitionFrom(el, null, elOption, styleOpt, transFromProps, isInit);
  71324. if (elDisplayable) {
  71325. hasOwn(elOption, 'invisible') && (elDisplayable.invisible = elOption.invisible);
  71326. } // If `isMorphTo`, we should not update these props to el directly, otherwise,
  71327. // when applying morph finally, the original prop are missing for making "animation from".
  71328. if (!isMorphTo) {
  71329. applyPropsFinal(el, allPropsFinal, styleOpt);
  71330. applyTransitionFrom(el, dataIndex, elOption, seriesModel, transFromProps, isInit);
  71331. } // Merge by default.
  71332. hasOwn(elOption, 'silent') && (el.silent = elOption.silent);
  71333. hasOwn(elOption, 'ignore') && (el.ignore = elOption.ignore);
  71334. if (!isTextContent) {
  71335. // `elOption.info` enables user to mount some info on
  71336. // elements and use them in event handlers.
  71337. // Update them only when user specified, otherwise, remain.
  71338. hasOwn(elOption, 'info') && (inner$9(el).info = elOption.info);
  71339. }
  71340. styleOpt ? el.dirty() : el.markRedraw();
  71341. return isMorphTo ? allPropsFinal : null;
  71342. }
  71343. function applyPropsFinal(el, // Can be null/undefined
  71344. allPropsFinal, styleOpt) {
  71345. var elDisplayable = el.isGroup ? null : el;
  71346. if (elDisplayable && styleOpt) {
  71347. var decalPattern = styleOpt.__decalPattern;
  71348. var originalDecalObj = void 0;
  71349. if (decalPattern) {
  71350. originalDecalObj = styleOpt.decal;
  71351. styleOpt.decal = decalPattern;
  71352. } // PENDING: here the input style object is used directly.
  71353. // Good for performance but bad for compatibility control.
  71354. elDisplayable.useStyle(styleOpt);
  71355. if (decalPattern) {
  71356. styleOpt.decal = originalDecalObj;
  71357. } // When style object changed, how to trade the existing animation?
  71358. // It is probably conplicated and not needed to cover all the cases.
  71359. // But still need consider the case:
  71360. // (1) When using init animation on `style.opacity`, and before the animation
  71361. // ended users triggers an update by mousewhell. At that time the init
  71362. // animation should better be continued rather than terminated.
  71363. // So after `useStyle` called, we should change the animation target manually
  71364. // to continue the effect of the init animation.
  71365. // (2) PENDING: If the previous animation targeted at a `val1`, and currently we need
  71366. // to update the value to `val2` and no animation declared, should be terminate
  71367. // the previous animation or just modify the target of the animation?
  71368. // Therotically That will happen not only on `style` but also on `shape` and
  71369. // `transfrom` props. But we haven't handle this case at present yet.
  71370. // (3) PENDING: Is it proper to visit `animators` and `targetName`?
  71371. var animators = elDisplayable.animators;
  71372. for (var i = 0; i < animators.length; i++) {
  71373. var animator = animators[i]; // targetName is the "topKey".
  71374. if (animator.targetName === 'style') {
  71375. animator.changeTarget(elDisplayable.style);
  71376. }
  71377. }
  71378. } // Set el to the final state firstly.
  71379. allPropsFinal && el.attr(allPropsFinal);
  71380. }
  71381. function applyTransitionFrom(el, dataIndex, elOption, seriesModel, // Can be null/undefined
  71382. transFromProps, isInit) {
  71383. if (transFromProps) {
  71384. // Do not use `el.updateDuringAnimation` here becuase `el.updateDuringAnimation` will
  71385. // be called mutiple time in each animation frame. For example, if both "transform" props
  71386. // and shape props and style props changed, it will generate three animator and called
  71387. // one-by-one in each animation frame.
  71388. // We use the during in `animateTo/From` params.
  71389. var userDuring = elOption.during; // For simplicity, if during not specified, the previous during will not work any more.
  71390. inner$9(el).userDuring = userDuring;
  71391. var cfgDuringCall = userDuring ? bind(duringCall, {
  71392. el: el,
  71393. userDuring: userDuring
  71394. }) : null;
  71395. var cfg = {
  71396. dataIndex: dataIndex,
  71397. isFrom: true,
  71398. during: cfgDuringCall
  71399. };
  71400. isInit ? initProps(el, transFromProps, seriesModel, cfg) : updateProps(el, transFromProps, seriesModel, cfg);
  71401. }
  71402. } // See [STRATEGY_TRANSITION]
  71403. function prepareShapeOrExtraTransitionFrom(mainAttr, el, morphFromEl, elOption, transFromProps, isInit) {
  71404. var attrOpt = elOption[mainAttr];
  71405. if (!attrOpt) {
  71406. return;
  71407. }
  71408. var elPropsInAttr = el[mainAttr];
  71409. var transFromPropsInAttr;
  71410. var enterFrom = attrOpt.enterFrom;
  71411. if (isInit && enterFrom) {
  71412. !transFromPropsInAttr && (transFromPropsInAttr = transFromProps[mainAttr] = {});
  71413. var enterFromKeys = keys(enterFrom);
  71414. for (var i = 0; i < enterFromKeys.length; i++) {
  71415. // `enterFrom` props are not necessarily also declared in `shape`/`style`/...,
  71416. // for example, `opacity` can only declared in `enterFrom` but not in `style`.
  71417. var key = enterFromKeys[i]; // Do not clone, animator will perform that clone.
  71418. transFromPropsInAttr[key] = enterFrom[key];
  71419. }
  71420. }
  71421. if (!isInit && elPropsInAttr // Just ignore shape animation in morphing.
  71422. && !(morphFromEl != null && mainAttr === 'shape')) {
  71423. if (attrOpt.transition) {
  71424. !transFromPropsInAttr && (transFromPropsInAttr = transFromProps[mainAttr] = {});
  71425. var transitionKeys = normalizeToArray(attrOpt.transition);
  71426. for (var i = 0; i < transitionKeys.length; i++) {
  71427. var key = transitionKeys[i];
  71428. var elVal = elPropsInAttr[key];
  71429. {
  71430. checkNonStyleTansitionRefer(key, attrOpt[key], elVal);
  71431. } // Do not clone, see `checkNonStyleTansitionRefer`.
  71432. transFromPropsInAttr[key] = elVal;
  71433. }
  71434. } else if (indexOf$1(elOption.transition, mainAttr) >= 0) {
  71435. !transFromPropsInAttr && (transFromPropsInAttr = transFromProps[mainAttr] = {});
  71436. var elPropsInAttrKeys = keys(elPropsInAttr);
  71437. for (var i = 0; i < elPropsInAttrKeys.length; i++) {
  71438. var key = elPropsInAttrKeys[i];
  71439. var elVal = elPropsInAttr[key];
  71440. if (isNonStyleTransitionEnabled(attrOpt[key], elVal)) {
  71441. transFromPropsInAttr[key] = elVal;
  71442. }
  71443. }
  71444. }
  71445. }
  71446. var leaveTo = attrOpt.leaveTo;
  71447. if (leaveTo) {
  71448. var leaveToProps = getOrCreateLeaveToPropsFromEl(el);
  71449. var leaveToPropsInAttr = leaveToProps[mainAttr] || (leaveToProps[mainAttr] = {});
  71450. var leaveToKeys = keys(leaveTo);
  71451. for (var i = 0; i < leaveToKeys.length; i++) {
  71452. var key = leaveToKeys[i];
  71453. leaveToPropsInAttr[key] = leaveTo[key];
  71454. }
  71455. }
  71456. }
  71457. function prepareShapeOrExtraAllPropsFinal(mainAttr, elOption, allProps) {
  71458. var attrOpt = elOption[mainAttr];
  71459. if (!attrOpt) {
  71460. return;
  71461. }
  71462. var allPropsInAttr = allProps[mainAttr] = {};
  71463. var keysInAttr = keys(attrOpt);
  71464. for (var i = 0; i < keysInAttr.length; i++) {
  71465. var key = keysInAttr[i]; // To avoid share one object with different element, and
  71466. // to avoid user modify the object inexpectedly, have to clone.
  71467. allPropsInAttr[key] = cloneValue(attrOpt[key]);
  71468. }
  71469. } // See [STRATEGY_TRANSITION].
  71470. function prepareTransformTransitionFrom(el, morphFromEl, elOption, transFromProps, isInit) {
  71471. var enterFrom = elOption.enterFrom;
  71472. if (isInit && enterFrom) {
  71473. var enterFromKeys = keys(enterFrom);
  71474. for (var i = 0; i < enterFromKeys.length; i++) {
  71475. var key = enterFromKeys[i];
  71476. {
  71477. checkTransformPropRefer(key, 'el.enterFrom');
  71478. } // Do not clone, animator will perform that clone.
  71479. transFromProps[key] = enterFrom[key];
  71480. }
  71481. }
  71482. if (!isInit) {
  71483. // If morphing, force transition all transform props.
  71484. // otherwise might have incorrect morphing animation.
  71485. if (morphFromEl) {
  71486. var fromTransformable = calcOldElLocalTransformBasedOnNewElParent(morphFromEl, el);
  71487. setTransformPropToTransitionFrom(transFromProps, 'x', fromTransformable);
  71488. setTransformPropToTransitionFrom(transFromProps, 'y', fromTransformable);
  71489. setTransformPropToTransitionFrom(transFromProps, 'scaleX', fromTransformable);
  71490. setTransformPropToTransitionFrom(transFromProps, 'scaleY', fromTransformable);
  71491. setTransformPropToTransitionFrom(transFromProps, 'originX', fromTransformable);
  71492. setTransformPropToTransitionFrom(transFromProps, 'originY', fromTransformable);
  71493. setTransformPropToTransitionFrom(transFromProps, 'rotation', fromTransformable);
  71494. } else if (elOption.transition) {
  71495. var transitionKeys = normalizeToArray(elOption.transition);
  71496. for (var i = 0; i < transitionKeys.length; i++) {
  71497. var key = transitionKeys[i];
  71498. if (key === 'style' || key === 'shape' || key === 'extra') {
  71499. continue;
  71500. }
  71501. var elVal = el[key];
  71502. {
  71503. checkTransformPropRefer(key, 'el.transition');
  71504. checkNonStyleTansitionRefer(key, elOption[key], elVal);
  71505. } // Do not clone, see `checkNonStyleTansitionRefer`.
  71506. transFromProps[key] = elVal;
  71507. }
  71508. } // This default transition see [STRATEGY_TRANSITION]
  71509. else {
  71510. setTransformPropToTransitionFrom(transFromProps, 'x', el);
  71511. setTransformPropToTransitionFrom(transFromProps, 'y', el);
  71512. }
  71513. }
  71514. var leaveTo = elOption.leaveTo;
  71515. if (leaveTo) {
  71516. var leaveToProps = getOrCreateLeaveToPropsFromEl(el);
  71517. var leaveToKeys = keys(leaveTo);
  71518. for (var i = 0; i < leaveToKeys.length; i++) {
  71519. var key = leaveToKeys[i];
  71520. {
  71521. checkTransformPropRefer(key, 'el.leaveTo');
  71522. }
  71523. leaveToProps[key] = leaveTo[key];
  71524. }
  71525. }
  71526. }
  71527. function prepareTransformAllPropsFinal(elOption, allProps) {
  71528. setLagecyTransformProp(elOption, allProps, 'position');
  71529. setLagecyTransformProp(elOption, allProps, 'scale');
  71530. setLagecyTransformProp(elOption, allProps, 'origin');
  71531. setTransformProp(elOption, allProps, 'x');
  71532. setTransformProp(elOption, allProps, 'y');
  71533. setTransformProp(elOption, allProps, 'scaleX');
  71534. setTransformProp(elOption, allProps, 'scaleY');
  71535. setTransformProp(elOption, allProps, 'originX');
  71536. setTransformProp(elOption, allProps, 'originY');
  71537. setTransformProp(elOption, allProps, 'rotation');
  71538. } // See [STRATEGY_TRANSITION].
  71539. function prepareStyleTransitionFrom(el, morphFromEl, elOption, styleOpt, transFromProps, isInit) {
  71540. if (!styleOpt) {
  71541. return;
  71542. } // At present in "many-to-one"/"one-to-many" case, to not support "many" have
  71543. // different styles and make style transitions. That might be a rare case.
  71544. var fromEl = morphFromEl || el;
  71545. var fromElStyle = fromEl.style;
  71546. var transFromStyleProps;
  71547. var enterFrom = styleOpt.enterFrom;
  71548. if (isInit && enterFrom) {
  71549. var enterFromKeys = keys(enterFrom);
  71550. !transFromStyleProps && (transFromStyleProps = transFromProps.style = {});
  71551. for (var i = 0; i < enterFromKeys.length; i++) {
  71552. var key = enterFromKeys[i]; // Do not clone, animator will perform that clone.
  71553. transFromStyleProps[key] = enterFrom[key];
  71554. }
  71555. }
  71556. if (!isInit && fromElStyle) {
  71557. if (styleOpt.transition) {
  71558. var transitionKeys = normalizeToArray(styleOpt.transition);
  71559. !transFromStyleProps && (transFromStyleProps = transFromProps.style = {});
  71560. for (var i = 0; i < transitionKeys.length; i++) {
  71561. var key = transitionKeys[i];
  71562. var elVal = fromElStyle[key]; // Do not clone, see `checkNonStyleTansitionRefer`.
  71563. transFromStyleProps[key] = elVal;
  71564. }
  71565. } else if (el.getAnimationStyleProps && indexOf$1(elOption.transition, 'style') >= 0) {
  71566. var animationProps = el.getAnimationStyleProps();
  71567. var animationStyleProps = animationProps ? animationProps.style : null;
  71568. if (animationStyleProps) {
  71569. !transFromStyleProps && (transFromStyleProps = transFromProps.style = {});
  71570. var styleKeys = keys(styleOpt);
  71571. for (var i = 0; i < styleKeys.length; i++) {
  71572. var key = styleKeys[i];
  71573. if (animationStyleProps[key]) {
  71574. var elVal = fromElStyle[key];
  71575. transFromStyleProps[key] = elVal;
  71576. }
  71577. }
  71578. }
  71579. }
  71580. }
  71581. var leaveTo = styleOpt.leaveTo;
  71582. if (leaveTo) {
  71583. var leaveToKeys = keys(leaveTo);
  71584. var leaveToProps = getOrCreateLeaveToPropsFromEl(el);
  71585. var leaveToStyleProps = leaveToProps.style || (leaveToProps.style = {});
  71586. for (var i = 0; i < leaveToKeys.length; i++) {
  71587. var key = leaveToKeys[i];
  71588. leaveToStyleProps[key] = leaveTo[key];
  71589. }
  71590. }
  71591. }
  71592. /**
  71593. * If make "transform"(x/y/scaleX/scaleY/orient/originX/originY) transition between
  71594. * two path elements that have different hierarchy, before we retrieve the "from" props,
  71595. * we have to calculate the local transition of the "oldPath" based on the parent of
  71596. * the "newPath".
  71597. * At present, the case only happend in "morphing". Without morphing, the transform
  71598. * transition are all between elements in the same hierarchy, where this kind of process
  71599. * is not needed.
  71600. *
  71601. * [CAVEAT]:
  71602. * This method makes sense only if: (very tricky)
  71603. * (1) "newEl" has been added to its final parent.
  71604. * (2) Local transform props of "newPath.parent" are not at their final value but already
  71605. * have been at the "from value".
  71606. * This is currently ensured by:
  71607. * (2.1) "graphicUtil.animationFrom", which will set the element to the "from value"
  71608. * immediately.
  71609. * (2.2) "morph" option is not allowed to be set on Group, so all of the groups have
  71610. * been finished their "updateElNormal" when calling this method in morphing process.
  71611. */
  71612. function calcOldElLocalTransformBasedOnNewElParent(oldEl, newEl) {
  71613. if (!oldEl || oldEl === newEl || oldEl.parent === newEl.parent) {
  71614. return oldEl;
  71615. } // Not sure oldEl is rendered (may have "lazyUpdate"),
  71616. // so always call `getComputedTransform`.
  71617. var tmpM = tmpTransformable.transform || (tmpTransformable.transform = identity([]));
  71618. var oldGlobalTransform = oldEl.getComputedTransform();
  71619. oldGlobalTransform ? copy$1(tmpM, oldGlobalTransform) : identity(tmpM);
  71620. var newParent = newEl.parent;
  71621. if (newParent) {
  71622. newParent.getComputedTransform();
  71623. }
  71624. tmpTransformable.originX = oldEl.originX;
  71625. tmpTransformable.originY = oldEl.originY;
  71626. tmpTransformable.parent = newParent;
  71627. tmpTransformable.decomposeTransform();
  71628. return tmpTransformable;
  71629. }
  71630. var checkNonStyleTansitionRefer;
  71631. {
  71632. checkNonStyleTansitionRefer = function (propName, optVal, elVal) {
  71633. if (!isArrayLike(optVal)) {
  71634. assert$1(optVal != null && isFinite(optVal), 'Prop `' + propName + '` must refer to a finite number or ArrayLike for transition.');
  71635. } else {
  71636. // Try not to copy array for performance, but if user use the same object in different
  71637. // call of `renderItem`, it will casue animation transition fail.
  71638. assert$1(optVal !== elVal, 'Prop `' + propName + '` must use different Array object each time for transition.');
  71639. }
  71640. };
  71641. }
  71642. function isNonStyleTransitionEnabled(optVal, elVal) {
  71643. // The same as `checkNonStyleTansitionRefer`.
  71644. return !isArrayLike(optVal) ? optVal != null && isFinite(optVal) : optVal !== elVal;
  71645. }
  71646. var checkTransformPropRefer;
  71647. {
  71648. checkTransformPropRefer = function (key, usedIn) {
  71649. assert$1(hasOwn(TRANSFORM_PROPS, key), 'Prop `' + key + '` is not a permitted in `' + usedIn + '`. ' + 'Only `' + keys(TRANSFORM_PROPS).join('`, `') + '` are permitted.');
  71650. };
  71651. }
  71652. function getOrCreateLeaveToPropsFromEl(el) {
  71653. var innerEl = inner$9(el);
  71654. return innerEl.leaveToProps || (innerEl.leaveToProps = {});
  71655. } // Use it to avoid it be exposed to user.
  71656. var tmpDuringScope = {};
  71657. var customDuringAPI = {
  71658. // Usually other props do not need to be changed in animation during.
  71659. setTransform: function (key, val) {
  71660. {
  71661. assert$1(hasOwn(TRANSFORM_PROPS, key), 'Only ' + transformPropNamesStr + ' available in `setTransform`.');
  71662. }
  71663. tmpDuringScope.el[key] = val;
  71664. return this;
  71665. },
  71666. getTransform: function (key) {
  71667. {
  71668. assert$1(hasOwn(TRANSFORM_PROPS, key), 'Only ' + transformPropNamesStr + ' available in `getTransform`.');
  71669. }
  71670. return tmpDuringScope.el[key];
  71671. },
  71672. setShape: function (key, val) {
  71673. {
  71674. assertNotReserved(key);
  71675. }
  71676. var shape = tmpDuringScope.el.shape || (tmpDuringScope.el.shape = {});
  71677. shape[key] = val;
  71678. tmpDuringScope.isShapeDirty = true;
  71679. return this;
  71680. },
  71681. getShape: function (key) {
  71682. {
  71683. assertNotReserved(key);
  71684. }
  71685. var shape = tmpDuringScope.el.shape;
  71686. if (shape) {
  71687. return shape[key];
  71688. }
  71689. },
  71690. setStyle: function (key, val) {
  71691. {
  71692. assertNotReserved(key);
  71693. }
  71694. var style = tmpDuringScope.el.style;
  71695. if (style) {
  71696. {
  71697. if (eqNaN(val)) {
  71698. warn('style.' + key + ' must not be assigned with NaN.');
  71699. }
  71700. }
  71701. style[key] = val;
  71702. tmpDuringScope.isStyleDirty = true;
  71703. }
  71704. return this;
  71705. },
  71706. getStyle: function (key) {
  71707. {
  71708. assertNotReserved(key);
  71709. }
  71710. var style = tmpDuringScope.el.style;
  71711. if (style) {
  71712. return style[key];
  71713. }
  71714. },
  71715. setExtra: function (key, val) {
  71716. {
  71717. assertNotReserved(key);
  71718. }
  71719. var extra = tmpDuringScope.el.extra || (tmpDuringScope.el.extra = {});
  71720. extra[key] = val;
  71721. return this;
  71722. },
  71723. getExtra: function (key) {
  71724. {
  71725. assertNotReserved(key);
  71726. }
  71727. var extra = tmpDuringScope.el.extra;
  71728. if (extra) {
  71729. return extra[key];
  71730. }
  71731. }
  71732. };
  71733. function assertNotReserved(key) {
  71734. {
  71735. if (key === 'transition' || key === 'enterFrom' || key === 'leaveTo') {
  71736. throw new Error('key must not be "' + key + '"');
  71737. }
  71738. }
  71739. }
  71740. function duringCall() {
  71741. // Do not provide "percent" until some requirements come.
  71742. // Because consider thies case:
  71743. // enterFrom: {x: 100, y: 30}, transition: 'x'.
  71744. // And enter duration is different from update duration.
  71745. // Thus it might be confused about the meaning of "percent" in during callback.
  71746. var scope = this;
  71747. var el = scope.el;
  71748. if (!el) {
  71749. return;
  71750. } // If el is remove from zr by reason like legend, during still need to called,
  71751. // becuase el will be added back to zr and the prop value should not be incorrect.
  71752. var newstUserDuring = inner$9(el).userDuring;
  71753. var scopeUserDuring = scope.userDuring; // Ensured a during is only called once in each animation frame.
  71754. // If a during is called multiple times in one frame, maybe some users' calulation logic
  71755. // might be wrong (not sure whether this usage exists).
  71756. // The case of a during might be called twice can be: by default there is a animator for
  71757. // 'x', 'y' when init. Before the init animation finished, call `setOption` to start
  71758. // another animators for 'style'/'shape'/'extra'.
  71759. if (newstUserDuring !== scopeUserDuring) {
  71760. // release
  71761. scope.el = scope.userDuring = null;
  71762. return;
  71763. }
  71764. tmpDuringScope.el = el;
  71765. tmpDuringScope.isShapeDirty = false;
  71766. tmpDuringScope.isStyleDirty = false; // Give no `this` to user in "during" calling.
  71767. scopeUserDuring(customDuringAPI);
  71768. if (tmpDuringScope.isShapeDirty && el.dirtyShape) {
  71769. el.dirtyShape();
  71770. }
  71771. if (tmpDuringScope.isStyleDirty && el.dirtyStyle) {
  71772. el.dirtyStyle();
  71773. } // markRedraw() will be called by default in during.
  71774. // FIXME `this.markRedraw();` directly ?
  71775. // FIXME: if in future meet the case that some prop will be both modified in `during` and `state`,
  71776. // consider the issue that the prop might be incorrect when return to "normal" state.
  71777. }
  71778. function updateElOnState(state, el, elStateOpt, styleOpt, attachedTxInfo, isRoot, isTextContent) {
  71779. var elDisplayable = el.isGroup ? null : el;
  71780. var txCfgOpt = attachedTxInfo && attachedTxInfo[state].cfg; // PENDING:5.0 support customize scale change and transition animation?
  71781. if (elDisplayable) {
  71782. // By default support auto lift color when hover whether `emphasis` specified.
  71783. var stateObj = elDisplayable.ensureState(state);
  71784. if (styleOpt === false) {
  71785. var existingEmphasisState = elDisplayable.getState(state);
  71786. if (existingEmphasisState) {
  71787. existingEmphasisState.style = null;
  71788. }
  71789. } else {
  71790. // style is needed to enable defaut emphasis.
  71791. stateObj.style = styleOpt || null;
  71792. } // If `elOption.styleEmphasis` or `elOption.emphasis.style` is `false`,
  71793. // remove hover style.
  71794. // If `elOption.textConfig` or `elOption.emphasis.textConfig` is null/undefined, it does not
  71795. // make sense. So for simplicity, we do not ditinguish `hasOwnProperty` and null/undefined.
  71796. if (txCfgOpt) {
  71797. stateObj.textConfig = txCfgOpt;
  71798. }
  71799. setDefaultStateProxy(elDisplayable);
  71800. }
  71801. }
  71802. function updateZ$1(el, elOption, seriesModel, attachedTxInfo) {
  71803. // Group not support textContent and not support z yet.
  71804. if (el.isGroup) {
  71805. return;
  71806. }
  71807. var elDisplayable = el;
  71808. var currentZ = seriesModel.currentZ;
  71809. var currentZLevel = seriesModel.currentZLevel; // Always erase.
  71810. elDisplayable.z = currentZ;
  71811. elDisplayable.zlevel = currentZLevel; // z2 must not be null/undefined, otherwise sort error may occur.
  71812. var optZ2 = elOption.z2;
  71813. optZ2 != null && (elDisplayable.z2 = optZ2 || 0);
  71814. for (var i = 0; i < STATES.length; i++) {
  71815. updateZForEachState(elDisplayable, elOption, STATES[i]);
  71816. }
  71817. }
  71818. function updateZForEachState(elDisplayable, elOption, state) {
  71819. var isNormal = state === NORMAL;
  71820. var elStateOpt = isNormal ? elOption : retrieveStateOption(elOption, state);
  71821. var optZ2 = elStateOpt ? elStateOpt.z2 : null;
  71822. var stateObj;
  71823. if (optZ2 != null) {
  71824. // Do not `ensureState` until required.
  71825. stateObj = isNormal ? elDisplayable : elDisplayable.ensureState(state);
  71826. stateObj.z2 = optZ2 || 0;
  71827. }
  71828. }
  71829. function setLagecyTransformProp(elOption, targetProps, legacyName, fromTransformable // If provided, retrieve from the element.
  71830. ) {
  71831. var legacyArr = elOption[legacyName];
  71832. var xyName = LEGACY_TRANSFORM_PROPS[legacyName];
  71833. if (legacyArr) {
  71834. if (fromTransformable) {
  71835. targetProps[xyName[0]] = fromTransformable[xyName[0]];
  71836. targetProps[xyName[1]] = fromTransformable[xyName[1]];
  71837. } else {
  71838. targetProps[xyName[0]] = legacyArr[0];
  71839. targetProps[xyName[1]] = legacyArr[1];
  71840. }
  71841. }
  71842. }
  71843. function setTransformProp(elOption, allProps, name, fromTransformable // If provided, retrieve from the element.
  71844. ) {
  71845. if (elOption[name] != null) {
  71846. allProps[name] = fromTransformable ? fromTransformable[name] : elOption[name];
  71847. }
  71848. }
  71849. function setTransformPropToTransitionFrom(transitionFrom, name, fromTransformable // If provided, retrieve from the element.
  71850. ) {
  71851. if (fromTransformable) {
  71852. transitionFrom[name] = fromTransformable[name];
  71853. }
  71854. }
  71855. function makeRenderItem(customSeries, data, ecModel, api) {
  71856. var renderItem = customSeries.get('renderItem');
  71857. var coordSys = customSeries.coordinateSystem;
  71858. var prepareResult = {};
  71859. if (coordSys) {
  71860. {
  71861. assert$1(renderItem, 'series.render is required.');
  71862. assert$1(coordSys.prepareCustoms || prepareCustoms[coordSys.type], 'This coordSys does not support custom series.');
  71863. } // `coordSys.prepareCustoms` is used for external coord sys like bmap.
  71864. prepareResult = coordSys.prepareCustoms ? coordSys.prepareCustoms(coordSys) : prepareCustoms[coordSys.type](coordSys);
  71865. }
  71866. var userAPI = defaults({
  71867. getWidth: api.getWidth,
  71868. getHeight: api.getHeight,
  71869. getZr: api.getZr,
  71870. getDevicePixelRatio: api.getDevicePixelRatio,
  71871. value: value,
  71872. style: style,
  71873. ordinalRawValue: ordinalRawValue,
  71874. styleEmphasis: styleEmphasis,
  71875. visual: visual,
  71876. barLayout: barLayout,
  71877. currentSeriesIndices: currentSeriesIndices,
  71878. font: font
  71879. }, prepareResult.api || {});
  71880. var userParams = {
  71881. // The life cycle of context: current round of rendering.
  71882. // The global life cycle is probably not necessary, because
  71883. // user can store global status by themselves.
  71884. context: {},
  71885. seriesId: customSeries.id,
  71886. seriesName: customSeries.name,
  71887. seriesIndex: customSeries.seriesIndex,
  71888. coordSys: prepareResult.coordSys,
  71889. dataInsideLength: data.count(),
  71890. encode: wrapEncodeDef(customSeries.getData())
  71891. }; // If someday intending to refactor them to a class, should consider do not
  71892. // break change: currently these attribute member are encapsulated in a closure
  71893. // so that do not need to force user to call these method with a scope.
  71894. // Do not support call `api` asynchronously without dataIndexInside input.
  71895. var currDataIndexInside;
  71896. var currItemModel;
  71897. var currItemStyleModels = {};
  71898. var currLabelModels = {};
  71899. var seriesItemStyleModels = {};
  71900. var seriesLabelModels = {};
  71901. for (var i = 0; i < STATES.length; i++) {
  71902. var stateName = STATES[i];
  71903. seriesItemStyleModels[stateName] = customSeries.getModel(PATH_ITEM_STYLE[stateName]);
  71904. seriesLabelModels[stateName] = customSeries.getModel(PATH_LABEL[stateName]);
  71905. }
  71906. function getItemModel(dataIndexInside) {
  71907. return dataIndexInside === currDataIndexInside ? currItemModel || (currItemModel = data.getItemModel(dataIndexInside)) : data.getItemModel(dataIndexInside);
  71908. }
  71909. function getItemStyleModel(dataIndexInside, state) {
  71910. return !data.hasItemOption ? seriesItemStyleModels[state] : dataIndexInside === currDataIndexInside ? currItemStyleModels[state] || (currItemStyleModels[state] = getItemModel(dataIndexInside).getModel(PATH_ITEM_STYLE[state])) : getItemModel(dataIndexInside).getModel(PATH_ITEM_STYLE[state]);
  71911. }
  71912. function getLabelModel(dataIndexInside, state) {
  71913. return !data.hasItemOption ? seriesLabelModels[state] : dataIndexInside === currDataIndexInside ? currLabelModels[state] || (currLabelModels[state] = getItemModel(dataIndexInside).getModel(PATH_LABEL[state])) : getItemModel(dataIndexInside).getModel(PATH_LABEL[state]);
  71914. }
  71915. return function (dataIndexInside, payload) {
  71916. currDataIndexInside = dataIndexInside;
  71917. currItemModel = null;
  71918. currItemStyleModels = {};
  71919. currLabelModels = {};
  71920. return renderItem && renderItem(defaults({
  71921. dataIndexInside: dataIndexInside,
  71922. dataIndex: data.getRawIndex(dataIndexInside),
  71923. // Can be used for optimization when zoom or roam.
  71924. actionType: payload ? payload.type : null
  71925. }, userParams), userAPI);
  71926. };
  71927. /**
  71928. * @public
  71929. * @param dim by default 0.
  71930. * @param dataIndexInside by default `currDataIndexInside`.
  71931. */
  71932. function value(dim, dataIndexInside) {
  71933. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  71934. return data.get(data.getDimension(dim || 0), dataIndexInside);
  71935. }
  71936. /**
  71937. * @public
  71938. * @param dim by default 0.
  71939. * @param dataIndexInside by default `currDataIndexInside`.
  71940. */
  71941. function ordinalRawValue(dim, dataIndexInside) {
  71942. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  71943. var dimInfo = data.getDimensionInfo(dim || 0);
  71944. if (!dimInfo) {
  71945. return;
  71946. }
  71947. var val = data.get(dimInfo.name, dataIndexInside);
  71948. var ordinalMeta = dimInfo && dimInfo.ordinalMeta;
  71949. return ordinalMeta ? ordinalMeta.categories[val] : val;
  71950. }
  71951. /**
  71952. * @deprecated The orgininal intention of `api.style` is enable to set itemStyle
  71953. * like other series. But it not necessary and not easy to give a strict definition
  71954. * of what it return. And since echarts5 it needs to be make compat work. So
  71955. * deprecates it since echarts5.
  71956. *
  71957. * By default, `visual` is applied to style (to support visualMap).
  71958. * `visual.color` is applied at `fill`. If user want apply visual.color on `stroke`,
  71959. * it can be implemented as:
  71960. * `api.style({stroke: api.visual('color'), fill: null})`;
  71961. *
  71962. * [Compat]: since ec5, RectText has been separated from its hosts el.
  71963. * so `api.style()` will only return the style from `itemStyle` but not handle `label`
  71964. * any more. But `series.label` config is never published in doc.
  71965. * We still compat it in `api.style()`. But not encourage to use it and will still not
  71966. * to pulish it to doc.
  71967. * @public
  71968. * @param dataIndexInside by default `currDataIndexInside`.
  71969. */
  71970. function style(userProps, dataIndexInside) {
  71971. {
  71972. warnDeprecated('api.style', 'Please write literal style directly instead.');
  71973. }
  71974. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  71975. var style = data.getItemVisual(dataIndexInside, 'style');
  71976. var visualColor = style && style.fill;
  71977. var opacity = style && style.opacity;
  71978. var itemStyle = getItemStyleModel(dataIndexInside, NORMAL).getItemStyle();
  71979. visualColor != null && (itemStyle.fill = visualColor);
  71980. opacity != null && (itemStyle.opacity = opacity);
  71981. var opt = {
  71982. inheritColor: isString(visualColor) ? visualColor : '#000'
  71983. };
  71984. var labelModel = getLabelModel(dataIndexInside, NORMAL); // Now that the feture of "auto adjust text fill/stroke" has been migrated to zrender
  71985. // since ec5, we should set `isAttached` as `false` here and make compat in
  71986. // `convertToEC4StyleForCustomSerise`.
  71987. var textStyle = createTextStyle(labelModel, null, opt, false, true);
  71988. textStyle.text = labelModel.getShallow('show') ? retrieve2(customSeries.getFormattedLabel(dataIndexInside, NORMAL), getDefaultLabel(data, dataIndexInside)) : null;
  71989. var textConfig = createTextConfig(labelModel, opt, false);
  71990. preFetchFromExtra(userProps, itemStyle);
  71991. itemStyle = convertToEC4StyleForCustomSerise(itemStyle, textStyle, textConfig);
  71992. userProps && applyUserPropsAfter(itemStyle, userProps);
  71993. itemStyle.legacy = true;
  71994. return itemStyle;
  71995. }
  71996. /**
  71997. * @deprecated The reason see `api.style()`
  71998. * @public
  71999. * @param dataIndexInside by default `currDataIndexInside`.
  72000. */
  72001. function styleEmphasis(userProps, dataIndexInside) {
  72002. {
  72003. warnDeprecated('api.styleEmphasis', 'Please write literal style directly instead.');
  72004. }
  72005. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  72006. var itemStyle = getItemStyleModel(dataIndexInside, EMPHASIS).getItemStyle();
  72007. var labelModel = getLabelModel(dataIndexInside, EMPHASIS);
  72008. var textStyle = createTextStyle(labelModel, null, null, true, true);
  72009. textStyle.text = labelModel.getShallow('show') ? retrieve3(customSeries.getFormattedLabel(dataIndexInside, EMPHASIS), customSeries.getFormattedLabel(dataIndexInside, NORMAL), getDefaultLabel(data, dataIndexInside)) : null;
  72010. var textConfig = createTextConfig(labelModel, null, true);
  72011. preFetchFromExtra(userProps, itemStyle);
  72012. itemStyle = convertToEC4StyleForCustomSerise(itemStyle, textStyle, textConfig);
  72013. userProps && applyUserPropsAfter(itemStyle, userProps);
  72014. itemStyle.legacy = true;
  72015. return itemStyle;
  72016. }
  72017. function applyUserPropsAfter(itemStyle, extra) {
  72018. for (var key in extra) {
  72019. if (hasOwn(extra, key)) {
  72020. itemStyle[key] = extra[key];
  72021. }
  72022. }
  72023. }
  72024. function preFetchFromExtra(extra, itemStyle) {
  72025. // A trick to retrieve those props firstly, which are used to
  72026. // apply auto inside fill/stroke in `convertToEC4StyleForCustomSerise`.
  72027. // (It's not reasonable but only for a degree of compat)
  72028. if (extra) {
  72029. extra.textFill && (itemStyle.textFill = extra.textFill);
  72030. extra.textPosition && (itemStyle.textPosition = extra.textPosition);
  72031. }
  72032. }
  72033. /**
  72034. * @public
  72035. * @param dataIndexInside by default `currDataIndexInside`.
  72036. */
  72037. function visual(visualType, dataIndexInside) {
  72038. dataIndexInside == null && (dataIndexInside = currDataIndexInside);
  72039. if (hasOwn(STYLE_VISUAL_TYPE, visualType)) {
  72040. var style_1 = data.getItemVisual(dataIndexInside, 'style');
  72041. return style_1 ? style_1[STYLE_VISUAL_TYPE[visualType]] : null;
  72042. } // Only support these visuals. Other visual might be inner tricky
  72043. // for performance (like `style`), do not expose to users.
  72044. if (hasOwn(NON_STYLE_VISUAL_PROPS, visualType)) {
  72045. return data.getItemVisual(dataIndexInside, visualType);
  72046. }
  72047. }
  72048. /**
  72049. * @public
  72050. * @return If not support, return undefined.
  72051. */
  72052. function barLayout(opt) {
  72053. if (coordSys.type === 'cartesian2d') {
  72054. var baseAxis = coordSys.getBaseAxis();
  72055. return getLayoutOnAxis(defaults({
  72056. axis: baseAxis
  72057. }, opt));
  72058. }
  72059. }
  72060. /**
  72061. * @public
  72062. */
  72063. function currentSeriesIndices() {
  72064. return ecModel.getCurrentSeriesIndices();
  72065. }
  72066. /**
  72067. * @public
  72068. * @return font string
  72069. */
  72070. function font(opt) {
  72071. return getFont(opt, ecModel);
  72072. }
  72073. }
  72074. function wrapEncodeDef(data) {
  72075. var encodeDef = {};
  72076. each$1(data.dimensions, function (dimName, dataDimIndex) {
  72077. var dimInfo = data.getDimensionInfo(dimName);
  72078. if (!dimInfo.isExtraCoord) {
  72079. var coordDim = dimInfo.coordDim;
  72080. var dataDims = encodeDef[coordDim] = encodeDef[coordDim] || [];
  72081. dataDims[dimInfo.coordDimIndex] = dataDimIndex;
  72082. }
  72083. });
  72084. return encodeDef;
  72085. }
  72086. function createOrUpdateItem(api, el, dataIndex, elOption, seriesModel, group, data, morphPreparation) {
  72087. // [Rule]
  72088. // If `renderItem` returns `null`/`undefined`/`false`, remove the previous el if existing.
  72089. // (It seems that violate the "merge" principle, but most of users probably intuitively
  72090. // regard "return;" as "show nothing element whatever", so make a exception to meet the
  72091. // most cases.)
  72092. // The rule or "merge" see [STRATEGY_MERGE].
  72093. // If `elOption` is `null`/`undefined`/`false` (when `renderItem` returns nothing).
  72094. if (!elOption) {
  72095. removeElementDirectly(el, group);
  72096. return;
  72097. }
  72098. el = doCreateOrUpdateEl(api, el, dataIndex, elOption, seriesModel, group, true, morphPreparation);
  72099. el && data.setItemGraphicEl(dataIndex, el);
  72100. enableHoverEmphasis(el, elOption.focus, elOption.blurScope);
  72101. return el;
  72102. }
  72103. function doCreateOrUpdateEl(api, el, dataIndex, elOption, seriesModel, group, isRoot, morphPreparation) {
  72104. {
  72105. assert$1(elOption, 'should not have an null/undefined element setting');
  72106. }
  72107. var toBeReplacedIdx = -1;
  72108. if (el && doesElNeedRecreate(el, elOption) // || (
  72109. // // PENDING: even in one-to-one mapping case, if el is marked as morph,
  72110. // // do not sure whether the el will be mapped to another el with different
  72111. // // hierarchy in Group tree. So always recreate el rather than reuse the el.
  72112. // morphPreparation && morphPreparation.isOneToOneFrom(el)
  72113. // )
  72114. ) {
  72115. // Should keep at the original index, otherwise "merge by index" will be incorrect.
  72116. toBeReplacedIdx = group.childrenRef().indexOf(el);
  72117. el = null;
  72118. }
  72119. var elIsNewCreated = !el;
  72120. if (!el) {
  72121. el = createEl(elOption);
  72122. } else {
  72123. // FIMXE:NEXT unified clearState?
  72124. // If in some case the performance issue arised, consider
  72125. // do not clearState but update cached normal state directly.
  72126. el.clearStates();
  72127. }
  72128. var canMorph = inner$9(el).canMorph = elOption.morph && isPath$1(el);
  72129. var thisElIsMorphTo = canMorph && morphPreparation && morphPreparation.hasFrom(); // Use update animation when morph is enabled.
  72130. var isInit = elIsNewCreated && !thisElIsMorphTo;
  72131. attachedTxInfoTmp.normal.cfg = attachedTxInfoTmp.normal.conOpt = attachedTxInfoTmp.emphasis.cfg = attachedTxInfoTmp.emphasis.conOpt = attachedTxInfoTmp.blur.cfg = attachedTxInfoTmp.blur.conOpt = attachedTxInfoTmp.select.cfg = attachedTxInfoTmp.select.conOpt = null;
  72132. attachedTxInfoTmp.isLegacy = false;
  72133. doCreateOrUpdateAttachedTx(el, dataIndex, elOption, seriesModel, isInit, attachedTxInfoTmp);
  72134. doCreateOrUpdateClipPath(el, dataIndex, elOption, seriesModel, isInit);
  72135. var pendingAllPropsFinal = updateElNormal(api, el, thisElIsMorphTo, dataIndex, elOption, elOption.style, attachedTxInfoTmp, seriesModel, isInit, false);
  72136. if (thisElIsMorphTo) {
  72137. morphPreparation.addTo(el, elOption, dataIndex, pendingAllPropsFinal);
  72138. }
  72139. for (var i = 0; i < STATES.length; i++) {
  72140. var stateName = STATES[i];
  72141. if (stateName !== NORMAL) {
  72142. var otherStateOpt = retrieveStateOption(elOption, stateName);
  72143. var otherStyleOpt = retrieveStyleOptionOnState(elOption, otherStateOpt, stateName);
  72144. updateElOnState(stateName, el, otherStateOpt, otherStyleOpt, attachedTxInfoTmp, isRoot, false);
  72145. }
  72146. }
  72147. updateZ$1(el, elOption, seriesModel, attachedTxInfoTmp);
  72148. if (elOption.type === 'group') {
  72149. mergeChildren(api, el, dataIndex, elOption, seriesModel, morphPreparation);
  72150. }
  72151. if (toBeReplacedIdx >= 0) {
  72152. group.replaceAt(el, toBeReplacedIdx);
  72153. } else {
  72154. group.add(el);
  72155. }
  72156. return el;
  72157. } // `el` must not be null/undefined.
  72158. function doesElNeedRecreate(el, elOption) {
  72159. var elInner = inner$9(el);
  72160. var elOptionType = elOption.type;
  72161. var elOptionShape = elOption.shape;
  72162. var elOptionStyle = elOption.style;
  72163. return (// If `elOptionType` is `null`, follow the merge principle.
  72164. elOptionType != null && elOptionType !== elInner.customGraphicType || elOptionType === 'path' && hasOwnPathData(elOptionShape) && getPathData(elOptionShape) !== elInner.customPathData || elOptionType === 'image' && hasOwn(elOptionStyle, 'image') && elOptionStyle.image !== elInner.customImagePath // // FIXME test and remove this restriction?
  72165. // || (elOptionType === 'text'
  72166. // && hasOwn(elOptionStyle, 'text')
  72167. // && (elOptionStyle as TextStyleProps).text !== elInner.customText
  72168. // )
  72169. );
  72170. }
  72171. function doCreateOrUpdateClipPath(el, dataIndex, elOption, seriesModel, isInit) {
  72172. // Based on the "merge" principle, if no clipPath provided,
  72173. // do nothing. The exists clip will be totally removed only if
  72174. // `el.clipPath` is `false`. Otherwise it will be merged/replaced.
  72175. var clipPathOpt = elOption.clipPath;
  72176. if (clipPathOpt === false) {
  72177. if (el && el.getClipPath()) {
  72178. el.removeClipPath();
  72179. }
  72180. } else if (clipPathOpt) {
  72181. var clipPath = el.getClipPath();
  72182. if (clipPath && doesElNeedRecreate(clipPath, clipPathOpt)) {
  72183. clipPath = null;
  72184. }
  72185. if (!clipPath) {
  72186. clipPath = createEl(clipPathOpt);
  72187. {
  72188. assert$1(clipPath instanceof Path, 'Only any type of `path` can be used in `clipPath`, rather than ' + clipPath.type + '.');
  72189. }
  72190. el.setClipPath(clipPath);
  72191. }
  72192. updateElNormal(null, clipPath, null, dataIndex, clipPathOpt, null, null, seriesModel, isInit, false);
  72193. } // If not define `clipPath` in option, do nothing unnecessary.
  72194. }
  72195. function doCreateOrUpdateAttachedTx(el, dataIndex, elOption, seriesModel, isInit, attachedTxInfo) {
  72196. // group do not support textContent temporarily untill necessary.
  72197. if (el.isGroup) {
  72198. return;
  72199. } // Normal must be called before emphasis, for `isLegacy` detection.
  72200. processTxInfo(elOption, null, attachedTxInfo);
  72201. processTxInfo(elOption, EMPHASIS, attachedTxInfo); // If `elOption.textConfig` or `elOption.textContent` is null/undefined, it does not make sence.
  72202. // So for simplicity, if "elOption hasOwnProperty of them but be null/undefined", we do not
  72203. // trade them as set to null to el.
  72204. // Especially:
  72205. // `elOption.textContent: false` means remove textContent.
  72206. // `elOption.textContent.emphasis.style: false` means remove the style from emphasis state.
  72207. var txConOptNormal = attachedTxInfo.normal.conOpt;
  72208. var txConOptEmphasis = attachedTxInfo.emphasis.conOpt;
  72209. var txConOptBlur = attachedTxInfo.blur.conOpt;
  72210. var txConOptSelect = attachedTxInfo.select.conOpt;
  72211. if (txConOptNormal != null || txConOptEmphasis != null || txConOptSelect != null || txConOptBlur != null) {
  72212. var textContent = el.getTextContent();
  72213. if (txConOptNormal === false) {
  72214. textContent && el.removeTextContent();
  72215. } else {
  72216. txConOptNormal = attachedTxInfo.normal.conOpt = txConOptNormal || {
  72217. type: 'text'
  72218. };
  72219. if (!textContent) {
  72220. textContent = createEl(txConOptNormal);
  72221. el.setTextContent(textContent);
  72222. } else {
  72223. // If in some case the performance issue arised, consider
  72224. // do not clearState but update cached normal state directly.
  72225. textContent.clearStates();
  72226. }
  72227. var txConStlOptNormal = txConOptNormal && txConOptNormal.style;
  72228. updateElNormal(null, textContent, null, dataIndex, txConOptNormal, txConStlOptNormal, null, seriesModel, isInit, true);
  72229. for (var i = 0; i < STATES.length; i++) {
  72230. var stateName = STATES[i];
  72231. if (stateName !== NORMAL) {
  72232. var txConOptOtherState = attachedTxInfo[stateName].conOpt;
  72233. updateElOnState(stateName, textContent, txConOptOtherState, retrieveStyleOptionOnState(txConOptNormal, txConOptOtherState, stateName), null, false, true);
  72234. }
  72235. }
  72236. txConStlOptNormal ? textContent.dirty() : textContent.markRedraw();
  72237. }
  72238. }
  72239. }
  72240. function processTxInfo(elOption, state, attachedTxInfo) {
  72241. var stateOpt = !state ? elOption : retrieveStateOption(elOption, state);
  72242. var styleOpt = !state ? elOption.style : retrieveStyleOptionOnState(elOption, stateOpt, EMPHASIS);
  72243. var elType = elOption.type;
  72244. var txCfg = stateOpt ? stateOpt.textConfig : null;
  72245. var txConOptNormal = elOption.textContent;
  72246. var txConOpt = !txConOptNormal ? null : !state ? txConOptNormal : retrieveStateOption(txConOptNormal, state);
  72247. if (styleOpt && ( // Because emphasis style has little info to detect legacy,
  72248. // if normal is legacy, emphasis is trade as legacy.
  72249. attachedTxInfo.isLegacy || isEC4CompatibleStyle(styleOpt, elType, !!txCfg, !!txConOpt))) {
  72250. attachedTxInfo.isLegacy = true;
  72251. var convertResult = convertFromEC4CompatibleStyle(styleOpt, elType, !state); // Explicitly specified `textConfig` and `textContent` has higher priority than
  72252. // the ones generated by legacy style. Otherwise if users use them and `api.style`
  72253. // at the same time, they not both work and hardly to known why.
  72254. if (!txCfg && convertResult.textConfig) {
  72255. txCfg = convertResult.textConfig;
  72256. }
  72257. if (!txConOpt && convertResult.textContent) {
  72258. txConOpt = convertResult.textContent;
  72259. }
  72260. }
  72261. if (!state && txConOpt) {
  72262. var txConOptNormal_1 = txConOpt; // `textContent: {type: 'text'}`, the "type" is easy to be missing. So we tolerate it.
  72263. !txConOptNormal_1.type && (txConOptNormal_1.type = 'text');
  72264. {
  72265. // Do not tolerate incorret type for forward compat.
  72266. txConOptNormal_1.type !== 'text' && assert$1(txConOptNormal_1.type === 'text', 'textContent.type must be "text"');
  72267. }
  72268. }
  72269. var info = !state ? attachedTxInfo.normal : attachedTxInfo[state];
  72270. info.cfg = txCfg;
  72271. info.conOpt = txConOpt;
  72272. }
  72273. function retrieveStateOption(elOption, state) {
  72274. return !state ? elOption : elOption ? elOption[state] : null;
  72275. }
  72276. function retrieveStyleOptionOnState(stateOptionNormal, stateOption, state) {
  72277. var style = stateOption && stateOption.style;
  72278. if (style == null && state === EMPHASIS && stateOptionNormal) {
  72279. style = stateOptionNormal.styleEmphasis;
  72280. }
  72281. return style;
  72282. } // Usage:
  72283. // (1) By default, `elOption.$mergeChildren` is `'byIndex'`, which indicates that
  72284. // the existing children will not be removed, and enables the feature that
  72285. // update some of the props of some of the children simply by construct
  72286. // the returned children of `renderItem` like:
  72287. // `var children = group.children = []; children[3] = {opacity: 0.5};`
  72288. // (2) If `elOption.$mergeChildren` is `'byName'`, add/update/remove children
  72289. // by child.name. But that might be lower performance.
  72290. // (3) If `elOption.$mergeChildren` is `false`, the existing children will be
  72291. // replaced totally.
  72292. // (4) If `!elOption.children`, following the "merge" principle, nothing will happen.
  72293. //
  72294. // For implementation simpleness, do not provide a direct way to remove sinlge
  72295. // child (otherwise the total indicies of the children array have to be modified).
  72296. // User can remove a single child by set its `ignore` as `true`.
  72297. function mergeChildren(api, el, dataIndex, elOption, seriesModel, morphPreparation) {
  72298. var newChildren = elOption.children;
  72299. var newLen = newChildren ? newChildren.length : 0;
  72300. var mergeChildren = elOption.$mergeChildren; // `diffChildrenByName` has been deprecated.
  72301. var byName = mergeChildren === 'byName' || elOption.diffChildrenByName;
  72302. var notMerge = mergeChildren === false; // For better performance on roam update, only enter if necessary.
  72303. if (!newLen && !byName && !notMerge) {
  72304. return;
  72305. }
  72306. if (byName) {
  72307. diffGroupChildren({
  72308. api: api,
  72309. oldChildren: el.children() || [],
  72310. newChildren: newChildren || [],
  72311. dataIndex: dataIndex,
  72312. seriesModel: seriesModel,
  72313. group: el,
  72314. morphPreparation: morphPreparation
  72315. });
  72316. return;
  72317. }
  72318. notMerge && el.removeAll(); // Mapping children of a group simply by index, which
  72319. // might be better performance.
  72320. var index = 0;
  72321. for (; index < newLen; index++) {
  72322. newChildren[index] && doCreateOrUpdateEl(api, el.childAt(index), dataIndex, newChildren[index], seriesModel, el, false, morphPreparation);
  72323. }
  72324. for (var i = el.childCount() - 1; i >= index; i--) {
  72325. // Do not supprot leave elements that are not mentioned in the latest
  72326. // `renderItem` return. Otherwise users may not have a clear and simple
  72327. // concept that how to contorl all of the elements.
  72328. doRemoveEl(el.childAt(i), seriesModel, el);
  72329. }
  72330. }
  72331. function diffGroupChildren(context) {
  72332. new DataDiffer(context.oldChildren, context.newChildren, getKey, getKey, context).add(processAddUpdate).update(processAddUpdate).remove(processRemove).execute();
  72333. }
  72334. function getKey(item, idx) {
  72335. var name = item && item.name;
  72336. return name != null ? name : GROUP_DIFF_PREFIX + idx;
  72337. }
  72338. function processAddUpdate(newIndex, oldIndex) {
  72339. var context = this.context;
  72340. var childOption = newIndex != null ? context.newChildren[newIndex] : null;
  72341. var child = oldIndex != null ? context.oldChildren[oldIndex] : null;
  72342. doCreateOrUpdateEl(context.api, child, context.dataIndex, childOption, context.seriesModel, context.group, false, context.morphPreparation);
  72343. }
  72344. function processRemove(oldIndex) {
  72345. var context = this.context;
  72346. var child = context.oldChildren[oldIndex];
  72347. doRemoveEl(child, context.seriesModel, context.group);
  72348. }
  72349. function doRemoveEl(el, seriesModel, group) {
  72350. if (el) {
  72351. var leaveToProps = inner$9(el).leaveToProps;
  72352. leaveToProps ? updateProps(el, leaveToProps, seriesModel, {
  72353. cb: function () {
  72354. group.remove(el);
  72355. }
  72356. }) : group.remove(el);
  72357. }
  72358. }
  72359. /**
  72360. * @return SVG Path data.
  72361. */
  72362. function getPathData(shape) {
  72363. // "d" follows the SVG convention.
  72364. return shape && (shape.pathData || shape.d);
  72365. }
  72366. function hasOwnPathData(shape) {
  72367. return shape && (hasOwn(shape, 'pathData') || hasOwn(shape, 'd'));
  72368. }
  72369. function isPath$1(el) {
  72370. return el && el instanceof Path;
  72371. }
  72372. function removeElementDirectly(el, group) {
  72373. el && group.remove(el);
  72374. }
  72375. /**
  72376. * Any morph-potential el should added by `morphPreparation.addTo(el)`.
  72377. * And they may apply morph or not when `morphPreparation.applyMorphing()`.
  72378. * But at least, all of the "to" elements will apply all of the updates
  72379. * as `doCreateOrUpdateItem` did.
  72380. */
  72381. var MorphPreparation =
  72382. /** @class */
  72383. function () {
  72384. function MorphPreparation(seriesModel, transOpt) {
  72385. this._fromList = [];
  72386. this._toList = [];
  72387. this._toElOptionList = [];
  72388. this._allPropsFinalList = [];
  72389. this._toDataIndices = []; // Key: `toDataIndex`, not `toIdx`
  72390. this._morphConfigList = [];
  72391. this._seriesModel = seriesModel;
  72392. this._transOpt = transOpt;
  72393. }
  72394. MorphPreparation.prototype.hasFrom = function () {
  72395. return !!this._fromList.length;
  72396. }; // isOneToOneFrom(el: Element): boolean {
  72397. // if (el && inner(el).canMorph) {
  72398. // const fromList = this._fromList;
  72399. // for (let i = 0; i < fromList.length; i++) {
  72400. // if (fromList[i] === el) {
  72401. // return true;
  72402. // }
  72403. // }
  72404. // }
  72405. // }
  72406. MorphPreparation.prototype.findAndAddFrom = function (el) {
  72407. if (!el) {
  72408. return;
  72409. }
  72410. if (inner$9(el).canMorph) {
  72411. this._fromList.push(el);
  72412. }
  72413. if (el.isGroup) {
  72414. var children = el.childrenRef();
  72415. for (var i = 0; i < children.length; i++) {
  72416. this.findAndAddFrom(children[i]);
  72417. }
  72418. }
  72419. };
  72420. MorphPreparation.prototype.addTo = function (path, elOption, dataIndex, allPropsFinal) {
  72421. if (path) {
  72422. this._toList.push(path);
  72423. this._toElOptionList.push(elOption);
  72424. this._toDataIndices.push(dataIndex);
  72425. this._allPropsFinalList.push(allPropsFinal);
  72426. }
  72427. };
  72428. MorphPreparation.prototype.applyMorphing = function () {
  72429. // [MORPHING_LOGIC_HINT]
  72430. // Pay attention to the order:
  72431. // (A) Apply `allPropsFinal` and `styleOption` to "to".
  72432. // (Then "to" becomes to the final state.)
  72433. // (B) Apply `morphPath`/`combine`/`separate`.
  72434. // (Based on the current state of "from" and the final state of "to".)
  72435. // (Then we may get "from.subList" or "to.subList".)
  72436. // (C) Copy the related props from "from" to "from.subList", from "to" to "to.subList".
  72437. // (D) Collect `transitionFromProps` for "to" and "to.subList"
  72438. // (Based on "from" or "from.subList".)
  72439. // (E) Apply `transitionFromProps` to "to" and "to.subList"
  72440. // (It might change the prop values to the first frame value.)
  72441. // Case_I:
  72442. // If (D) should be after (C), we use sequence: A - B - C - D - E
  72443. // Case_II:
  72444. // If (A) should be after (D), we use sequence: D - A - B - C - E
  72445. // [MORPHING_LOGIC_HINT]
  72446. // zrender `morphPath`/`combine`/`separate` only manages the shape animation.
  72447. // Other props (like transfrom, style transition) will handled in echarts).
  72448. // [MORPHING_LOGIC_HINT]
  72449. // Make sure `applyPropsFinal` always be called for "to".
  72450. var type = this._type;
  72451. var fromList = this._fromList;
  72452. var toList = this._toList;
  72453. var toListLen = toList.length;
  72454. var fromListLen = fromList.length;
  72455. if (!fromListLen || !toListLen) {
  72456. return;
  72457. }
  72458. if (type === 'oneToOne') {
  72459. // In one-to-one case, we by default apply a simple rule:
  72460. // map "from" and "to" one by one.
  72461. // For this case: old_data_item_el and new_data_item_el
  72462. // has the same hierarchy of group tree but only some path type changed.
  72463. for (var toIdx = 0; toIdx < toListLen; toIdx++) {
  72464. this._oneToOneForSingleTo(toIdx, toIdx);
  72465. }
  72466. } else if (type === 'manyToOne') {
  72467. // A rough strategy: if there are more than one "to", we simply divide "fromList" equally.
  72468. var fromSingleSegLen = Math.max(1, Math.floor(fromListLen / toListLen));
  72469. for (var toIdx = 0, fromIdxStart = 0; toIdx < toListLen; toIdx++, fromIdxStart += fromSingleSegLen) {
  72470. var fromCount = toIdx + 1 >= toListLen ? fromListLen - fromIdxStart : fromSingleSegLen;
  72471. this._manyToOneForSingleTo(toIdx, fromIdxStart >= fromListLen ? null : fromIdxStart, fromCount);
  72472. }
  72473. } else if (type === 'oneToMany') {
  72474. // A rough strategy: if there are more than one "from", we simply divide "toList" equally.
  72475. var toSingleSegLen = Math.max(1, Math.floor(toListLen / fromListLen));
  72476. for (var toIdxStart = 0, fromIdx = 0; toIdxStart < toListLen; toIdxStart += toSingleSegLen, fromIdx++) {
  72477. var toCount = toIdxStart + toSingleSegLen >= toListLen ? toListLen - toIdxStart : toSingleSegLen;
  72478. this._oneToManyForSingleFrom(toIdxStart, toCount, fromIdx >= fromListLen ? null : fromIdx);
  72479. }
  72480. }
  72481. };
  72482. MorphPreparation.prototype._oneToOneForSingleTo = function ( // "to" must NOT be null/undefined.
  72483. toIdx, // May `fromIdx >= this._fromList.length`
  72484. fromIdx) {
  72485. var to = this._toList[toIdx];
  72486. var toElOption = this._toElOptionList[toIdx];
  72487. var toDataIndex = this._toDataIndices[toIdx];
  72488. var allPropsFinal = this._allPropsFinalList[toIdx];
  72489. var from = this._fromList[fromIdx];
  72490. var elAnimationConfig = this._getOrCreateMorphConfig(toDataIndex);
  72491. var morphDuration = elAnimationConfig.duration;
  72492. if (from && isCombiningPath(from)) {
  72493. applyPropsFinal(to, allPropsFinal, toElOption.style);
  72494. if (morphDuration) {
  72495. var combineResult = combine([from], to, elAnimationConfig, copyPropsWhenDivided);
  72496. this._processResultIndividuals(combineResult, toIdx, null);
  72497. } // The target el will not be displayed and transition from multiple path.
  72498. // transition on the target el does not make sense.
  72499. } else {
  72500. var morphFrom = morphDuration // from === to usually happen in scenarios where internal update like
  72501. // "dataZoom", "legendToggle" happen. If from is not in any morphing,
  72502. // we do not need to call `morphPath`.
  72503. && from && (from !== to || isInAnyMorphing(from)) ? from : null; // See [Case_II] above.
  72504. // In this case, there is probably `from === to`. And the `transitionFromProps` collecting
  72505. // does not depends on morphing. So we collect `transitionFromProps` first.
  72506. var transFromProps = {};
  72507. prepareShapeOrExtraTransitionFrom('shape', to, morphFrom, toElOption, transFromProps, false);
  72508. prepareShapeOrExtraTransitionFrom('extra', to, morphFrom, toElOption, transFromProps, false);
  72509. prepareTransformTransitionFrom(to, morphFrom, toElOption, transFromProps, false);
  72510. prepareStyleTransitionFrom(to, morphFrom, toElOption, toElOption.style, transFromProps, false);
  72511. applyPropsFinal(to, allPropsFinal, toElOption.style);
  72512. if (morphFrom) {
  72513. morphPath(morphFrom, to, elAnimationConfig);
  72514. }
  72515. applyTransitionFrom(to, toDataIndex, toElOption, this._seriesModel, transFromProps, false);
  72516. }
  72517. };
  72518. MorphPreparation.prototype._manyToOneForSingleTo = function ( // "to" must NOT be null/undefined.
  72519. toIdx, // May be null.
  72520. fromIdxStart, fromCount) {
  72521. var to = this._toList[toIdx];
  72522. var toElOption = this._toElOptionList[toIdx];
  72523. var allPropsFinal = this._allPropsFinalList[toIdx];
  72524. applyPropsFinal(to, allPropsFinal, toElOption.style);
  72525. var elAnimationConfig = this._getOrCreateMorphConfig(this._toDataIndices[toIdx]);
  72526. if (elAnimationConfig.duration && fromIdxStart != null) {
  72527. var combineFromList = [];
  72528. for (var fromIdx = fromIdxStart; fromIdx < fromCount; fromIdx++) {
  72529. combineFromList.push(this._fromList[fromIdx]);
  72530. }
  72531. var combineResult = combine(combineFromList, to, elAnimationConfig, copyPropsWhenDivided);
  72532. this._processResultIndividuals(combineResult, toIdx, null);
  72533. }
  72534. };
  72535. MorphPreparation.prototype._oneToManyForSingleFrom = function ( // "to" must NOT be null/undefined.
  72536. toIdxStart, toCount, // May be null
  72537. fromIdx) {
  72538. var from = fromIdx == null ? null : this._fromList[fromIdx];
  72539. var toList = this._toList;
  72540. var separateToList = [];
  72541. for (var toIdx = toIdxStart; toIdx < toCount; toIdx++) {
  72542. var to = toList[toIdx];
  72543. applyPropsFinal(to, this._allPropsFinalList[toIdx], this._toElOptionList[toIdx].style);
  72544. separateToList.push(to);
  72545. }
  72546. var elAnimationConfig = this._getOrCreateMorphConfig(this._toDataIndices[toIdxStart]);
  72547. if (elAnimationConfig.duration && from) {
  72548. var separateResult = separate(from, separateToList, elAnimationConfig, copyPropsWhenDivided);
  72549. this._processResultIndividuals(separateResult, toIdxStart, toCount);
  72550. }
  72551. };
  72552. MorphPreparation.prototype._processResultIndividuals = function (combineSeparateResult, toIdxStart, toCount) {
  72553. var isSeparate = toCount != null;
  72554. for (var i = 0; i < combineSeparateResult.count; i++) {
  72555. var fromIndividual = combineSeparateResult.fromIndividuals[i];
  72556. var toIndividual = combineSeparateResult.toIndividuals[i]; // Here it's a trick:
  72557. // For "combine" case, all of the `toIndividuals` map to the same `toIdx`.
  72558. // For "separate" case, the `toIndividuals` map to some certain segment of `_toList` accurately.
  72559. var toIdx = toIdxStart + (isSeparate ? i : 0);
  72560. var toElOption = this._toElOptionList[toIdx];
  72561. var dataIndex = this._toDataIndices[toIdx];
  72562. var transFromProps = {};
  72563. prepareTransformTransitionFrom(toIndividual, fromIndividual, toElOption, transFromProps, false);
  72564. prepareStyleTransitionFrom(toIndividual, fromIndividual, toElOption, toElOption.style, transFromProps, false);
  72565. applyTransitionFrom(toIndividual, dataIndex, toElOption, this._seriesModel, transFromProps, false);
  72566. }
  72567. };
  72568. MorphPreparation.prototype._getOrCreateMorphConfig = function (dataIndex) {
  72569. var morphConfigList = this._morphConfigList;
  72570. var config = morphConfigList[dataIndex];
  72571. if (config) {
  72572. return config;
  72573. }
  72574. var duration;
  72575. var easing;
  72576. var delay;
  72577. var seriesModel = this._seriesModel;
  72578. var transOpt = this._transOpt;
  72579. if (seriesModel.isAnimationEnabled()) {
  72580. // PENDING: refactor? this is the same logic as `src/util/graphic.ts#animateOrSetProps`.
  72581. var animationPayload = void 0;
  72582. if (seriesModel && seriesModel.ecModel) {
  72583. var updatePayload = seriesModel.ecModel.getUpdatePayload();
  72584. animationPayload = updatePayload && updatePayload.animation;
  72585. }
  72586. if (animationPayload) {
  72587. duration = animationPayload.duration || 0;
  72588. easing = animationPayload.easing || 'cubicOut';
  72589. delay = animationPayload.delay || 0;
  72590. } else {
  72591. easing = seriesModel.get('animationEasingUpdate');
  72592. var delayOption = seriesModel.get('animationDelayUpdate');
  72593. delay = isFunction$1(delayOption) ? delayOption(dataIndex) : delayOption;
  72594. var durationOption = seriesModel.get('animationDurationUpdate');
  72595. duration = isFunction$1(durationOption) ? durationOption(dataIndex) : durationOption;
  72596. }
  72597. }
  72598. config = {
  72599. duration: duration || 0,
  72600. delay: delay,
  72601. easing: easing,
  72602. dividingMethod: transOpt ? transOpt.dividingMethod : null
  72603. };
  72604. morphConfigList[dataIndex] = config;
  72605. return config;
  72606. };
  72607. MorphPreparation.prototype.reset = function (type) {
  72608. // `this._morphConfigList` can be kept. It only related to `dataIndex`.
  72609. this._type = type;
  72610. this._fromList.length = this._toList.length = this._toElOptionList.length = this._allPropsFinalList.length = this._toDataIndices.length = 0;
  72611. };
  72612. return MorphPreparation;
  72613. }();
  72614. function copyPropsWhenDivided(srcPath, tarPath, willClone) {
  72615. // Do not copy transform props.
  72616. // Sub paths are transfrom based on their host path.
  72617. // tarPath.x = srcPath.x;
  72618. // tarPath.y = srcPath.y;
  72619. // tarPath.scaleX = srcPath.scaleX;
  72620. // tarPath.scaleY = srcPath.scaleY;
  72621. // tarPath.originX = srcPath.originX;
  72622. // tarPath.originY = srcPath.originY;
  72623. // If just carry the style, will not be modifed, so do not copy.
  72624. tarPath.style = willClone ? clone(srcPath.style) : srcPath.style;
  72625. tarPath.zlevel = srcPath.zlevel;
  72626. tarPath.z = srcPath.z;
  72627. tarPath.z2 = srcPath.z2;
  72628. }
  72629. function install$27(registers) {
  72630. registers.registerChartView(CustomSeriesView);
  72631. registers.registerSeriesModel(CustomSeriesModel);
  72632. }
  72633. /*
  72634. * Licensed to the Apache Software Foundation (ASF) under one
  72635. * or more contributor license agreements. See the NOTICE file
  72636. * distributed with this work for additional information
  72637. * regarding copyright ownership. The ASF licenses this file
  72638. * to you under the Apache License, Version 2.0 (the
  72639. * "License"); you may not use this file except in compliance
  72640. * with the License. You may obtain a copy of the License at
  72641. *
  72642. * http://www.apache.org/licenses/LICENSE-2.0
  72643. *
  72644. * Unless required by applicable law or agreed to in writing,
  72645. * software distributed under the License is distributed on an
  72646. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  72647. * KIND, either express or implied. See the License for the
  72648. * specific language governing permissions and limitations
  72649. * under the License.
  72650. */
  72651. /**
  72652. * AUTO-GENERATED FILE. DO NOT MODIFY.
  72653. */
  72654. /*
  72655. * Licensed to the Apache Software Foundation (ASF) under one
  72656. * or more contributor license agreements. See the NOTICE file
  72657. * distributed with this work for additional information
  72658. * regarding copyright ownership. The ASF licenses this file
  72659. * to you under the Apache License, Version 2.0 (the
  72660. * "License"); you may not use this file except in compliance
  72661. * with the License. You may obtain a copy of the License at
  72662. *
  72663. * http://www.apache.org/licenses/LICENSE-2.0
  72664. *
  72665. * Unless required by applicable law or agreed to in writing,
  72666. * software distributed under the License is distributed on an
  72667. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  72668. * KIND, either express or implied. See the License for the
  72669. * specific language governing permissions and limitations
  72670. * under the License.
  72671. */
  72672. use(install$27);
  72673. /*
  72674. * Licensed to the Apache Software Foundation (ASF) under one
  72675. * or more contributor license agreements. See the NOTICE file
  72676. * distributed with this work for additional information
  72677. * regarding copyright ownership. The ASF licenses this file
  72678. * to you under the Apache License, Version 2.0 (the
  72679. * "License"); you may not use this file except in compliance
  72680. * with the License. You may obtain a copy of the License at
  72681. *
  72682. * http://www.apache.org/licenses/LICENSE-2.0
  72683. *
  72684. * Unless required by applicable law or agreed to in writing,
  72685. * software distributed under the License is distributed on an
  72686. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  72687. * KIND, either express or implied. See the License for the
  72688. * specific language governing permissions and limitations
  72689. * under the License.
  72690. */
  72691. /**
  72692. * AUTO-GENERATED FILE. DO NOT MODIFY.
  72693. */
  72694. /*
  72695. * Licensed to the Apache Software Foundation (ASF) under one
  72696. * or more contributor license agreements. See the NOTICE file
  72697. * distributed with this work for additional information
  72698. * regarding copyright ownership. The ASF licenses this file
  72699. * to you under the Apache License, Version 2.0 (the
  72700. * "License"); you may not use this file except in compliance
  72701. * with the License. You may obtain a copy of the License at
  72702. *
  72703. * http://www.apache.org/licenses/LICENSE-2.0
  72704. *
  72705. * Unless required by applicable law or agreed to in writing,
  72706. * software distributed under the License is distributed on an
  72707. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  72708. * KIND, either express or implied. See the License for the
  72709. * specific language governing permissions and limitations
  72710. * under the License.
  72711. */
  72712. use(install$6);
  72713. /*
  72714. * Licensed to the Apache Software Foundation (ASF) under one
  72715. * or more contributor license agreements. See the NOTICE file
  72716. * distributed with this work for additional information
  72717. * regarding copyright ownership. The ASF licenses this file
  72718. * to you under the Apache License, Version 2.0 (the
  72719. * "License"); you may not use this file except in compliance
  72720. * with the License. You may obtain a copy of the License at
  72721. *
  72722. * http://www.apache.org/licenses/LICENSE-2.0
  72723. *
  72724. * Unless required by applicable law or agreed to in writing,
  72725. * software distributed under the License is distributed on an
  72726. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  72727. * KIND, either express or implied. See the License for the
  72728. * specific language governing permissions and limitations
  72729. * under the License.
  72730. */
  72731. /**
  72732. * AUTO-GENERATED FILE. DO NOT MODIFY.
  72733. */
  72734. /*
  72735. * Licensed to the Apache Software Foundation (ASF) under one
  72736. * or more contributor license agreements. See the NOTICE file
  72737. * distributed with this work for additional information
  72738. * regarding copyright ownership. The ASF licenses this file
  72739. * to you under the Apache License, Version 2.0 (the
  72740. * "License"); you may not use this file except in compliance
  72741. * with the License. You may obtain a copy of the License at
  72742. *
  72743. * http://www.apache.org/licenses/LICENSE-2.0
  72744. *
  72745. * Unless required by applicable law or agreed to in writing,
  72746. * software distributed under the License is distributed on an
  72747. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  72748. * KIND, either express or implied. See the License for the
  72749. * specific language governing permissions and limitations
  72750. * under the License.
  72751. */
  72752. var inner$10 = makeInner();
  72753. var clone$3 = clone;
  72754. var bind$1 = bind;
  72755. /**
  72756. * Base axis pointer class in 2D.
  72757. */
  72758. var BaseAxisPointer =
  72759. /** @class */
  72760. function () {
  72761. function BaseAxisPointer() {
  72762. this._dragging = false;
  72763. /**
  72764. * In px, arbitrary value. Do not set too small,
  72765. * no animation is ok for most cases.
  72766. */
  72767. this.animationThreshold = 15;
  72768. }
  72769. /**
  72770. * @implement
  72771. */
  72772. BaseAxisPointer.prototype.render = function (axisModel, axisPointerModel, api, forceRender) {
  72773. var value = axisPointerModel.get('value');
  72774. var status = axisPointerModel.get('status'); // Bind them to `this`, not in closure, otherwise they will not
  72775. // be replaced when user calling setOption in not merge mode.
  72776. this._axisModel = axisModel;
  72777. this._axisPointerModel = axisPointerModel;
  72778. this._api = api; // Optimize: `render` will be called repeatly during mouse move.
  72779. // So it is power consuming if performing `render` each time,
  72780. // especially on mobile device.
  72781. if (!forceRender && this._lastValue === value && this._lastStatus === status) {
  72782. return;
  72783. }
  72784. this._lastValue = value;
  72785. this._lastStatus = status;
  72786. var group = this._group;
  72787. var handle = this._handle;
  72788. if (!status || status === 'hide') {
  72789. // Do not clear here, for animation better.
  72790. group && group.hide();
  72791. handle && handle.hide();
  72792. return;
  72793. }
  72794. group && group.show();
  72795. handle && handle.show(); // Otherwise status is 'show'
  72796. var elOption = {};
  72797. this.makeElOption(elOption, value, axisModel, axisPointerModel, api); // Enable change axis pointer type.
  72798. var graphicKey = elOption.graphicKey;
  72799. if (graphicKey !== this._lastGraphicKey) {
  72800. this.clear(api);
  72801. }
  72802. this._lastGraphicKey = graphicKey;
  72803. var moveAnimation = this._moveAnimation = this.determineAnimation(axisModel, axisPointerModel);
  72804. if (!group) {
  72805. group = this._group = new Group();
  72806. this.createPointerEl(group, elOption, axisModel, axisPointerModel);
  72807. this.createLabelEl(group, elOption, axisModel, axisPointerModel);
  72808. api.getZr().add(group);
  72809. } else {
  72810. var doUpdateProps = curry(updateProps$1, axisPointerModel, moveAnimation);
  72811. this.updatePointerEl(group, elOption, doUpdateProps);
  72812. this.updateLabelEl(group, elOption, doUpdateProps, axisPointerModel);
  72813. }
  72814. updateMandatoryProps(group, axisPointerModel, true);
  72815. this._renderHandle(value);
  72816. };
  72817. /**
  72818. * @implement
  72819. */
  72820. BaseAxisPointer.prototype.remove = function (api) {
  72821. this.clear(api);
  72822. };
  72823. /**
  72824. * @implement
  72825. */
  72826. BaseAxisPointer.prototype.dispose = function (api) {
  72827. this.clear(api);
  72828. };
  72829. /**
  72830. * @protected
  72831. */
  72832. BaseAxisPointer.prototype.determineAnimation = function (axisModel, axisPointerModel) {
  72833. var animation = axisPointerModel.get('animation');
  72834. var axis = axisModel.axis;
  72835. var isCategoryAxis = axis.type === 'category';
  72836. var useSnap = axisPointerModel.get('snap'); // Value axis without snap always do not snap.
  72837. if (!useSnap && !isCategoryAxis) {
  72838. return false;
  72839. }
  72840. if (animation === 'auto' || animation == null) {
  72841. var animationThreshold = this.animationThreshold;
  72842. if (isCategoryAxis && axis.getBandWidth() > animationThreshold) {
  72843. return true;
  72844. } // It is important to auto animation when snap used. Consider if there is
  72845. // a dataZoom, animation will be disabled when too many points exist, while
  72846. // it will be enabled for better visual effect when little points exist.
  72847. if (useSnap) {
  72848. var seriesDataCount = getAxisInfo(axisModel).seriesDataCount;
  72849. var axisExtent = axis.getExtent(); // Approximate band width
  72850. return Math.abs(axisExtent[0] - axisExtent[1]) / seriesDataCount > animationThreshold;
  72851. }
  72852. return false;
  72853. }
  72854. return animation === true;
  72855. };
  72856. /**
  72857. * add {pointer, label, graphicKey} to elOption
  72858. * @protected
  72859. */
  72860. BaseAxisPointer.prototype.makeElOption = function (elOption, value, axisModel, axisPointerModel, api) {// Shoule be implemenented by sub-class.
  72861. };
  72862. /**
  72863. * @protected
  72864. */
  72865. BaseAxisPointer.prototype.createPointerEl = function (group, elOption, axisModel, axisPointerModel) {
  72866. var pointerOption = elOption.pointer;
  72867. if (pointerOption) {
  72868. var pointerEl = inner$10(group).pointerEl = new graphic[pointerOption.type](clone$3(elOption.pointer));
  72869. group.add(pointerEl);
  72870. }
  72871. };
  72872. /**
  72873. * @protected
  72874. */
  72875. BaseAxisPointer.prototype.createLabelEl = function (group, elOption, axisModel, axisPointerModel) {
  72876. if (elOption.label) {
  72877. var labelEl = inner$10(group).labelEl = new ZRText(clone$3(elOption.label));
  72878. group.add(labelEl);
  72879. updateLabelShowHide(labelEl, axisPointerModel);
  72880. }
  72881. };
  72882. /**
  72883. * @protected
  72884. */
  72885. BaseAxisPointer.prototype.updatePointerEl = function (group, elOption, updateProps$$1) {
  72886. var pointerEl = inner$10(group).pointerEl;
  72887. if (pointerEl && elOption.pointer) {
  72888. pointerEl.setStyle(elOption.pointer.style);
  72889. updateProps$$1(pointerEl, {
  72890. shape: elOption.pointer.shape
  72891. });
  72892. }
  72893. };
  72894. /**
  72895. * @protected
  72896. */
  72897. BaseAxisPointer.prototype.updateLabelEl = function (group, elOption, updateProps$$1, axisPointerModel) {
  72898. var labelEl = inner$10(group).labelEl;
  72899. if (labelEl) {
  72900. labelEl.setStyle(elOption.label.style);
  72901. updateProps$$1(labelEl, {
  72902. // Consider text length change in vertical axis, animation should
  72903. // be used on shape, otherwise the effect will be weird.
  72904. // TODOTODO
  72905. // shape: elOption.label.shape,
  72906. x: elOption.label.x,
  72907. y: elOption.label.y
  72908. });
  72909. updateLabelShowHide(labelEl, axisPointerModel);
  72910. }
  72911. };
  72912. /**
  72913. * @private
  72914. */
  72915. BaseAxisPointer.prototype._renderHandle = function (value) {
  72916. if (this._dragging || !this.updateHandleTransform) {
  72917. return;
  72918. }
  72919. var axisPointerModel = this._axisPointerModel;
  72920. var zr = this._api.getZr();
  72921. var handle = this._handle;
  72922. var handleModel = axisPointerModel.getModel('handle');
  72923. var status = axisPointerModel.get('status');
  72924. if (!handleModel.get('show') || !status || status === 'hide') {
  72925. handle && zr.remove(handle);
  72926. this._handle = null;
  72927. return;
  72928. }
  72929. var isInit;
  72930. if (!this._handle) {
  72931. isInit = true;
  72932. handle = this._handle = createIcon(handleModel.get('icon'), {
  72933. cursor: 'move',
  72934. draggable: true,
  72935. onmousemove: function (e) {
  72936. // Fot mobile devicem, prevent screen slider on the button.
  72937. stop(e.event);
  72938. },
  72939. onmousedown: bind$1(this._onHandleDragMove, this, 0, 0),
  72940. drift: bind$1(this._onHandleDragMove, this),
  72941. ondragend: bind$1(this._onHandleDragEnd, this)
  72942. });
  72943. zr.add(handle);
  72944. }
  72945. updateMandatoryProps(handle, axisPointerModel, false); // update style
  72946. handle.setStyle(handleModel.getItemStyle(null, ['color', 'borderColor', 'borderWidth', 'opacity', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY'])); // update position
  72947. var handleSize = handleModel.get('size');
  72948. if (!isArray(handleSize)) {
  72949. handleSize = [handleSize, handleSize];
  72950. }
  72951. handle.scaleX = handleSize[0] / 2;
  72952. handle.scaleY = handleSize[1] / 2;
  72953. createOrUpdate(this, '_doDispatchAxisPointer', handleModel.get('throttle') || 0, 'fixRate');
  72954. this._moveHandleToValue(value, isInit);
  72955. };
  72956. BaseAxisPointer.prototype._moveHandleToValue = function (value, isInit) {
  72957. updateProps$1(this._axisPointerModel, !isInit && this._moveAnimation, this._handle, getHandleTransProps(this.getHandleTransform(value, this._axisModel, this._axisPointerModel)));
  72958. };
  72959. BaseAxisPointer.prototype._onHandleDragMove = function (dx, dy) {
  72960. var handle = this._handle;
  72961. if (!handle) {
  72962. return;
  72963. }
  72964. this._dragging = true; // Persistent for throttle.
  72965. var trans = this.updateHandleTransform(getHandleTransProps(handle), [dx, dy], this._axisModel, this._axisPointerModel);
  72966. this._payloadInfo = trans;
  72967. handle.stopAnimation();
  72968. handle.attr(getHandleTransProps(trans));
  72969. inner$10(handle).lastProp = null;
  72970. this._doDispatchAxisPointer();
  72971. };
  72972. /**
  72973. * Throttled method.
  72974. */
  72975. BaseAxisPointer.prototype._doDispatchAxisPointer = function () {
  72976. var handle = this._handle;
  72977. if (!handle) {
  72978. return;
  72979. }
  72980. var payloadInfo = this._payloadInfo;
  72981. var axisModel = this._axisModel;
  72982. this._api.dispatchAction({
  72983. type: 'updateAxisPointer',
  72984. x: payloadInfo.cursorPoint[0],
  72985. y: payloadInfo.cursorPoint[1],
  72986. tooltipOption: payloadInfo.tooltipOption,
  72987. axesInfo: [{
  72988. axisDim: axisModel.axis.dim,
  72989. axisIndex: axisModel.componentIndex
  72990. }]
  72991. });
  72992. };
  72993. BaseAxisPointer.prototype._onHandleDragEnd = function () {
  72994. this._dragging = false;
  72995. var handle = this._handle;
  72996. if (!handle) {
  72997. return;
  72998. }
  72999. var value = this._axisPointerModel.get('value'); // Consider snap or categroy axis, handle may be not consistent with
  73000. // axisPointer. So move handle to align the exact value position when
  73001. // drag ended.
  73002. this._moveHandleToValue(value); // For the effect: tooltip will be shown when finger holding on handle
  73003. // button, and will be hidden after finger left handle button.
  73004. this._api.dispatchAction({
  73005. type: 'hideTip'
  73006. });
  73007. };
  73008. /**
  73009. * @private
  73010. */
  73011. BaseAxisPointer.prototype.clear = function (api) {
  73012. this._lastValue = null;
  73013. this._lastStatus = null;
  73014. var zr = api.getZr();
  73015. var group = this._group;
  73016. var handle = this._handle;
  73017. if (zr && group) {
  73018. this._lastGraphicKey = null;
  73019. group && zr.remove(group);
  73020. handle && zr.remove(handle);
  73021. this._group = null;
  73022. this._handle = null;
  73023. this._payloadInfo = null;
  73024. }
  73025. };
  73026. /**
  73027. * @protected
  73028. */
  73029. BaseAxisPointer.prototype.doClear = function () {// Implemented by sub-class if necessary.
  73030. };
  73031. BaseAxisPointer.prototype.buildLabel = function (xy, wh, xDimIndex) {
  73032. xDimIndex = xDimIndex || 0;
  73033. return {
  73034. x: xy[xDimIndex],
  73035. y: xy[1 - xDimIndex],
  73036. width: wh[xDimIndex],
  73037. height: wh[1 - xDimIndex]
  73038. };
  73039. };
  73040. return BaseAxisPointer;
  73041. }();
  73042. function updateProps$1(animationModel, moveAnimation, el, props) {
  73043. // Animation optimize.
  73044. if (!propsEqual(inner$10(el).lastProp, props)) {
  73045. inner$10(el).lastProp = props;
  73046. moveAnimation ? updateProps(el, props, animationModel) : (el.stopAnimation(), el.attr(props));
  73047. }
  73048. }
  73049. function propsEqual(lastProps, newProps) {
  73050. if (isObject$1(lastProps) && isObject$1(newProps)) {
  73051. var equals_1 = true;
  73052. each$1(newProps, function (item, key) {
  73053. equals_1 = equals_1 && propsEqual(lastProps[key], item);
  73054. });
  73055. return !!equals_1;
  73056. } else {
  73057. return lastProps === newProps;
  73058. }
  73059. }
  73060. function updateLabelShowHide(labelEl, axisPointerModel) {
  73061. labelEl[axisPointerModel.get(['label', 'show']) ? 'show' : 'hide']();
  73062. }
  73063. function getHandleTransProps(trans) {
  73064. return {
  73065. x: trans.x || 0,
  73066. y: trans.y || 0,
  73067. rotation: trans.rotation || 0
  73068. };
  73069. }
  73070. function updateMandatoryProps(group, axisPointerModel, silent) {
  73071. var z = axisPointerModel.get('z');
  73072. var zlevel = axisPointerModel.get('zlevel');
  73073. group && group.traverse(function (el) {
  73074. if (el.type !== 'group') {
  73075. z != null && (el.z = z);
  73076. zlevel != null && (el.zlevel = zlevel);
  73077. el.silent = silent;
  73078. }
  73079. });
  73080. }
  73081. /*
  73082. * Licensed to the Apache Software Foundation (ASF) under one
  73083. * or more contributor license agreements. See the NOTICE file
  73084. * distributed with this work for additional information
  73085. * regarding copyright ownership. The ASF licenses this file
  73086. * to you under the Apache License, Version 2.0 (the
  73087. * "License"); you may not use this file except in compliance
  73088. * with the License. You may obtain a copy of the License at
  73089. *
  73090. * http://www.apache.org/licenses/LICENSE-2.0
  73091. *
  73092. * Unless required by applicable law or agreed to in writing,
  73093. * software distributed under the License is distributed on an
  73094. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73095. * KIND, either express or implied. See the License for the
  73096. * specific language governing permissions and limitations
  73097. * under the License.
  73098. */
  73099. /**
  73100. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73101. */
  73102. /*
  73103. * Licensed to the Apache Software Foundation (ASF) under one
  73104. * or more contributor license agreements. See the NOTICE file
  73105. * distributed with this work for additional information
  73106. * regarding copyright ownership. The ASF licenses this file
  73107. * to you under the Apache License, Version 2.0 (the
  73108. * "License"); you may not use this file except in compliance
  73109. * with the License. You may obtain a copy of the License at
  73110. *
  73111. * http://www.apache.org/licenses/LICENSE-2.0
  73112. *
  73113. * Unless required by applicable law or agreed to in writing,
  73114. * software distributed under the License is distributed on an
  73115. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73116. * KIND, either express or implied. See the License for the
  73117. * specific language governing permissions and limitations
  73118. * under the License.
  73119. */
  73120. function buildElStyle(axisPointerModel) {
  73121. var axisPointerType = axisPointerModel.get('type');
  73122. var styleModel = axisPointerModel.getModel(axisPointerType + 'Style');
  73123. var style;
  73124. if (axisPointerType === 'line') {
  73125. style = styleModel.getLineStyle();
  73126. style.fill = null;
  73127. } else if (axisPointerType === 'shadow') {
  73128. style = styleModel.getAreaStyle();
  73129. style.stroke = null;
  73130. }
  73131. return style;
  73132. }
  73133. /**
  73134. * @param {Function} labelPos {align, verticalAlign, position}
  73135. */
  73136. function buildLabelElOption(elOption, axisModel, axisPointerModel, api, labelPos) {
  73137. var value = axisPointerModel.get('value');
  73138. var text = getValueLabel(value, axisModel.axis, axisModel.ecModel, axisPointerModel.get('seriesDataIndices'), {
  73139. precision: axisPointerModel.get(['label', 'precision']),
  73140. formatter: axisPointerModel.get(['label', 'formatter'])
  73141. });
  73142. var labelModel = axisPointerModel.getModel('label');
  73143. var paddings = normalizeCssArray$1(labelModel.get('padding') || 0);
  73144. var font = labelModel.getFont();
  73145. var textRect = getBoundingRect(text, font);
  73146. var position = labelPos.position;
  73147. var width = textRect.width + paddings[1] + paddings[3];
  73148. var height = textRect.height + paddings[0] + paddings[2]; // Adjust by align.
  73149. var align = labelPos.align;
  73150. align === 'right' && (position[0] -= width);
  73151. align === 'center' && (position[0] -= width / 2);
  73152. var verticalAlign = labelPos.verticalAlign;
  73153. verticalAlign === 'bottom' && (position[1] -= height);
  73154. verticalAlign === 'middle' && (position[1] -= height / 2); // Not overflow ec container
  73155. confineInContainer(position, width, height, api);
  73156. var bgColor = labelModel.get('backgroundColor');
  73157. if (!bgColor || bgColor === 'auto') {
  73158. bgColor = axisModel.get(['axisLine', 'lineStyle', 'color']);
  73159. }
  73160. elOption.label = {
  73161. // shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
  73162. x: position[0],
  73163. y: position[1],
  73164. style: createTextStyle(labelModel, {
  73165. text: text,
  73166. font: font,
  73167. fill: labelModel.getTextColor(),
  73168. padding: paddings,
  73169. backgroundColor: bgColor
  73170. }),
  73171. // Lable should be over axisPointer.
  73172. z2: 10
  73173. };
  73174. } // Do not overflow ec container
  73175. function confineInContainer(position, width, height, api) {
  73176. var viewWidth = api.getWidth();
  73177. var viewHeight = api.getHeight();
  73178. position[0] = Math.min(position[0] + width, viewWidth) - width;
  73179. position[1] = Math.min(position[1] + height, viewHeight) - height;
  73180. position[0] = Math.max(position[0], 0);
  73181. position[1] = Math.max(position[1], 0);
  73182. }
  73183. function getValueLabel(value, axis, ecModel, seriesDataIndices, opt) {
  73184. value = axis.scale.parse(value);
  73185. var text = axis.scale.getLabel({
  73186. value: value
  73187. }, {
  73188. // If `precision` is set, width can be fixed (like '12.00500'), which
  73189. // helps to debounce when when moving label.
  73190. precision: opt.precision
  73191. });
  73192. var formatter = opt.formatter;
  73193. if (formatter) {
  73194. var params_1 = {
  73195. value: getAxisRawValue(axis, {
  73196. value: value
  73197. }),
  73198. axisDimension: axis.dim,
  73199. axisIndex: axis.index,
  73200. seriesData: []
  73201. };
  73202. each$1(seriesDataIndices, function (idxItem) {
  73203. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
  73204. var dataIndex = idxItem.dataIndexInside;
  73205. var dataParams = series && series.getDataParams(dataIndex);
  73206. dataParams && params_1.seriesData.push(dataParams);
  73207. });
  73208. if (isString(formatter)) {
  73209. text = formatter.replace('{value}', text);
  73210. } else if (isFunction$1(formatter)) {
  73211. text = formatter(params_1);
  73212. }
  73213. }
  73214. return text;
  73215. }
  73216. function getTransformedPosition(axis, value, layoutInfo) {
  73217. var transform = create$1();
  73218. rotate(transform, transform, layoutInfo.rotation);
  73219. translate(transform, transform, layoutInfo.position);
  73220. return applyTransform$1([axis.dataToCoord(value), (layoutInfo.labelOffset || 0) + (layoutInfo.labelDirection || 1) * (layoutInfo.labelMargin || 0)], transform);
  73221. }
  73222. function buildCartesianSingleLabelElOption(value, elOption, layoutInfo, axisModel, axisPointerModel, api) {
  73223. // @ts-ignore
  73224. var textLayout = AxisBuilder.innerTextLayout(layoutInfo.rotation, 0, layoutInfo.labelDirection);
  73225. layoutInfo.labelMargin = axisPointerModel.get(['label', 'margin']);
  73226. buildLabelElOption(elOption, axisModel, axisPointerModel, api, {
  73227. position: getTransformedPosition(axisModel.axis, value, layoutInfo),
  73228. align: textLayout.textAlign,
  73229. verticalAlign: textLayout.textVerticalAlign
  73230. });
  73231. }
  73232. function makeLineShape(p1, p2, xDimIndex) {
  73233. xDimIndex = xDimIndex || 0;
  73234. return {
  73235. x1: p1[xDimIndex],
  73236. y1: p1[1 - xDimIndex],
  73237. x2: p2[xDimIndex],
  73238. y2: p2[1 - xDimIndex]
  73239. };
  73240. }
  73241. function makeRectShape(xy, wh, xDimIndex) {
  73242. xDimIndex = xDimIndex || 0;
  73243. return {
  73244. x: xy[xDimIndex],
  73245. y: xy[1 - xDimIndex],
  73246. width: wh[xDimIndex],
  73247. height: wh[1 - xDimIndex]
  73248. };
  73249. }
  73250. function makeSectorShape(cx, cy, r0, r, startAngle, endAngle) {
  73251. return {
  73252. cx: cx,
  73253. cy: cy,
  73254. r0: r0,
  73255. r: r,
  73256. startAngle: startAngle,
  73257. endAngle: endAngle,
  73258. clockwise: true
  73259. };
  73260. }
  73261. /*
  73262. * Licensed to the Apache Software Foundation (ASF) under one
  73263. * or more contributor license agreements. See the NOTICE file
  73264. * distributed with this work for additional information
  73265. * regarding copyright ownership. The ASF licenses this file
  73266. * to you under the Apache License, Version 2.0 (the
  73267. * "License"); you may not use this file except in compliance
  73268. * with the License. You may obtain a copy of the License at
  73269. *
  73270. * http://www.apache.org/licenses/LICENSE-2.0
  73271. *
  73272. * Unless required by applicable law or agreed to in writing,
  73273. * software distributed under the License is distributed on an
  73274. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73275. * KIND, either express or implied. See the License for the
  73276. * specific language governing permissions and limitations
  73277. * under the License.
  73278. */
  73279. /**
  73280. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73281. */
  73282. /*
  73283. * Licensed to the Apache Software Foundation (ASF) under one
  73284. * or more contributor license agreements. See the NOTICE file
  73285. * distributed with this work for additional information
  73286. * regarding copyright ownership. The ASF licenses this file
  73287. * to you under the Apache License, Version 2.0 (the
  73288. * "License"); you may not use this file except in compliance
  73289. * with the License. You may obtain a copy of the License at
  73290. *
  73291. * http://www.apache.org/licenses/LICENSE-2.0
  73292. *
  73293. * Unless required by applicable law or agreed to in writing,
  73294. * software distributed under the License is distributed on an
  73295. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73296. * KIND, either express or implied. See the License for the
  73297. * specific language governing permissions and limitations
  73298. * under the License.
  73299. */
  73300. var PolarAxisPointer =
  73301. /** @class */
  73302. function (_super) {
  73303. __extends(PolarAxisPointer, _super);
  73304. function PolarAxisPointer() {
  73305. return _super !== null && _super.apply(this, arguments) || this;
  73306. }
  73307. /**
  73308. * @override
  73309. */
  73310. PolarAxisPointer.prototype.makeElOption = function (elOption, value, axisModel, axisPointerModel, api) {
  73311. var axis = axisModel.axis;
  73312. if (axis.dim === 'angle') {
  73313. this.animationThreshold = Math.PI / 18;
  73314. }
  73315. var polar = axis.polar;
  73316. var otherAxis = polar.getOtherAxis(axis);
  73317. var otherExtent = otherAxis.getExtent();
  73318. var coordValue = axis.dataToCoord(value);
  73319. var axisPointerType = axisPointerModel.get('type');
  73320. if (axisPointerType && axisPointerType !== 'none') {
  73321. var elStyle = buildElStyle(axisPointerModel);
  73322. var pointerOption = pointerShapeBuilder[axisPointerType](axis, polar, coordValue, otherExtent);
  73323. pointerOption.style = elStyle;
  73324. elOption.graphicKey = pointerOption.type;
  73325. elOption.pointer = pointerOption;
  73326. }
  73327. var labelMargin = axisPointerModel.get(['label', 'margin']);
  73328. var labelPos = getLabelPosition(value, axisModel, axisPointerModel, polar, labelMargin);
  73329. buildLabelElOption(elOption, axisModel, axisPointerModel, api, labelPos);
  73330. };
  73331. return PolarAxisPointer;
  73332. }(BaseAxisPointer);
  73333. function getLabelPosition(value, axisModel, axisPointerModel, polar, labelMargin) {
  73334. var axis = axisModel.axis;
  73335. var coord = axis.dataToCoord(value);
  73336. var axisAngle = polar.getAngleAxis().getExtent()[0];
  73337. axisAngle = axisAngle / 180 * Math.PI;
  73338. var radiusExtent = polar.getRadiusAxis().getExtent();
  73339. var position;
  73340. var align;
  73341. var verticalAlign;
  73342. if (axis.dim === 'radius') {
  73343. var transform = create$1();
  73344. rotate(transform, transform, axisAngle);
  73345. translate(transform, transform, [polar.cx, polar.cy]);
  73346. position = applyTransform$1([coord, -labelMargin], transform);
  73347. var labelRotation = axisModel.getModel('axisLabel').get('rotate') || 0; // @ts-ignore
  73348. var labelLayout = AxisBuilder.innerTextLayout(axisAngle, labelRotation * Math.PI / 180, -1);
  73349. align = labelLayout.textAlign;
  73350. verticalAlign = labelLayout.textVerticalAlign;
  73351. } else {
  73352. // angle axis
  73353. var r = radiusExtent[1];
  73354. position = polar.coordToPoint([r + labelMargin, coord]);
  73355. var cx = polar.cx;
  73356. var cy = polar.cy;
  73357. align = Math.abs(position[0] - cx) / r < 0.3 ? 'center' : position[0] > cx ? 'left' : 'right';
  73358. verticalAlign = Math.abs(position[1] - cy) / r < 0.3 ? 'middle' : position[1] > cy ? 'top' : 'bottom';
  73359. }
  73360. return {
  73361. position: position,
  73362. align: align,
  73363. verticalAlign: verticalAlign
  73364. };
  73365. }
  73366. var pointerShapeBuilder = {
  73367. line: function (axis, polar, coordValue, otherExtent) {
  73368. return axis.dim === 'angle' ? {
  73369. type: 'Line',
  73370. shape: makeLineShape(polar.coordToPoint([otherExtent[0], coordValue]), polar.coordToPoint([otherExtent[1], coordValue]))
  73371. } : {
  73372. type: 'Circle',
  73373. shape: {
  73374. cx: polar.cx,
  73375. cy: polar.cy,
  73376. r: coordValue
  73377. }
  73378. };
  73379. },
  73380. shadow: function (axis, polar, coordValue, otherExtent) {
  73381. var bandWidth = Math.max(1, axis.getBandWidth());
  73382. var radian = Math.PI / 180;
  73383. return axis.dim === 'angle' ? {
  73384. type: 'Sector',
  73385. shape: makeSectorShape(polar.cx, polar.cy, otherExtent[0], otherExtent[1], // In ECharts y is negative if angle is positive
  73386. (-coordValue - bandWidth / 2) * radian, (-coordValue + bandWidth / 2) * radian)
  73387. } : {
  73388. type: 'Sector',
  73389. shape: makeSectorShape(polar.cx, polar.cy, coordValue - bandWidth / 2, coordValue + bandWidth / 2, 0, Math.PI * 2)
  73390. };
  73391. }
  73392. };
  73393. /*
  73394. * Licensed to the Apache Software Foundation (ASF) under one
  73395. * or more contributor license agreements. See the NOTICE file
  73396. * distributed with this work for additional information
  73397. * regarding copyright ownership. The ASF licenses this file
  73398. * to you under the Apache License, Version 2.0 (the
  73399. * "License"); you may not use this file except in compliance
  73400. * with the License. You may obtain a copy of the License at
  73401. *
  73402. * http://www.apache.org/licenses/LICENSE-2.0
  73403. *
  73404. * Unless required by applicable law or agreed to in writing,
  73405. * software distributed under the License is distributed on an
  73406. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73407. * KIND, either express or implied. See the License for the
  73408. * specific language governing permissions and limitations
  73409. * under the License.
  73410. */
  73411. /**
  73412. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73413. */
  73414. /*
  73415. * Licensed to the Apache Software Foundation (ASF) under one
  73416. * or more contributor license agreements. See the NOTICE file
  73417. * distributed with this work for additional information
  73418. * regarding copyright ownership. The ASF licenses this file
  73419. * to you under the Apache License, Version 2.0 (the
  73420. * "License"); you may not use this file except in compliance
  73421. * with the License. You may obtain a copy of the License at
  73422. *
  73423. * http://www.apache.org/licenses/LICENSE-2.0
  73424. *
  73425. * Unless required by applicable law or agreed to in writing,
  73426. * software distributed under the License is distributed on an
  73427. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73428. * KIND, either express or implied. See the License for the
  73429. * specific language governing permissions and limitations
  73430. * under the License.
  73431. */
  73432. var CartesianAxisPointer =
  73433. /** @class */
  73434. function (_super) {
  73435. __extends(CartesianAxisPointer, _super);
  73436. function CartesianAxisPointer() {
  73437. return _super !== null && _super.apply(this, arguments) || this;
  73438. }
  73439. /**
  73440. * @override
  73441. */
  73442. CartesianAxisPointer.prototype.makeElOption = function (elOption, value, axisModel, axisPointerModel, api) {
  73443. var axis = axisModel.axis;
  73444. var grid = axis.grid;
  73445. var axisPointerType = axisPointerModel.get('type');
  73446. var otherExtent = getCartesian(grid, axis).getOtherAxis(axis).getGlobalExtent();
  73447. var pixelValue = axis.toGlobalCoord(axis.dataToCoord(value, true));
  73448. if (axisPointerType && axisPointerType !== 'none') {
  73449. var elStyle = buildElStyle(axisPointerModel);
  73450. var pointerOption = pointerShapeBuilder$1[axisPointerType](axis, pixelValue, otherExtent);
  73451. pointerOption.style = elStyle;
  73452. elOption.graphicKey = pointerOption.type;
  73453. elOption.pointer = pointerOption;
  73454. }
  73455. var layoutInfo = layout$1(grid.model, axisModel);
  73456. buildCartesianSingleLabelElOption( // @ts-ignore
  73457. value, elOption, layoutInfo, axisModel, axisPointerModel, api);
  73458. };
  73459. /**
  73460. * @override
  73461. */
  73462. CartesianAxisPointer.prototype.getHandleTransform = function (value, axisModel, axisPointerModel) {
  73463. var layoutInfo = layout$1(axisModel.axis.grid.model, axisModel, {
  73464. labelInside: false
  73465. }); // @ts-ignore
  73466. layoutInfo.labelMargin = axisPointerModel.get(['handle', 'margin']);
  73467. var pos = getTransformedPosition(axisModel.axis, value, layoutInfo);
  73468. return {
  73469. x: pos[0],
  73470. y: pos[1],
  73471. rotation: layoutInfo.rotation + (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  73472. };
  73473. };
  73474. /**
  73475. * @override
  73476. */
  73477. CartesianAxisPointer.prototype.updateHandleTransform = function (transform, delta, axisModel, axisPointerModel) {
  73478. var axis = axisModel.axis;
  73479. var grid = axis.grid;
  73480. var axisExtent = axis.getGlobalExtent(true);
  73481. var otherExtent = getCartesian(grid, axis).getOtherAxis(axis).getGlobalExtent();
  73482. var dimIndex = axis.dim === 'x' ? 0 : 1;
  73483. var currPosition = [transform.x, transform.y];
  73484. currPosition[dimIndex] += delta[dimIndex];
  73485. currPosition[dimIndex] = Math.min(axisExtent[1], currPosition[dimIndex]);
  73486. currPosition[dimIndex] = Math.max(axisExtent[0], currPosition[dimIndex]);
  73487. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2;
  73488. var cursorPoint = [cursorOtherValue, cursorOtherValue];
  73489. cursorPoint[dimIndex] = currPosition[dimIndex]; // Make tooltip do not overlap axisPointer and in the middle of the grid.
  73490. var tooltipOptions = [{
  73491. verticalAlign: 'middle'
  73492. }, {
  73493. align: 'center'
  73494. }];
  73495. return {
  73496. x: currPosition[0],
  73497. y: currPosition[1],
  73498. rotation: transform.rotation,
  73499. cursorPoint: cursorPoint,
  73500. tooltipOption: tooltipOptions[dimIndex]
  73501. };
  73502. };
  73503. return CartesianAxisPointer;
  73504. }(BaseAxisPointer);
  73505. function getCartesian(grid, axis) {
  73506. var opt = {};
  73507. opt[axis.dim + 'AxisIndex'] = axis.index;
  73508. return grid.getCartesian(opt);
  73509. }
  73510. var pointerShapeBuilder$1 = {
  73511. line: function (axis, pixelValue, otherExtent) {
  73512. var targetShape = makeLineShape([pixelValue, otherExtent[0]], [pixelValue, otherExtent[1]], getAxisDimIndex(axis));
  73513. return {
  73514. type: 'Line',
  73515. subPixelOptimize: true,
  73516. shape: targetShape
  73517. };
  73518. },
  73519. shadow: function (axis, pixelValue, otherExtent) {
  73520. var bandWidth = Math.max(1, axis.getBandWidth());
  73521. var span = otherExtent[1] - otherExtent[0];
  73522. return {
  73523. type: 'Rect',
  73524. shape: makeRectShape([pixelValue - bandWidth / 2, otherExtent[0]], [bandWidth, span], getAxisDimIndex(axis))
  73525. };
  73526. }
  73527. };
  73528. function getAxisDimIndex(axis) {
  73529. return axis.dim === 'x' ? 0 : 1;
  73530. }
  73531. /*
  73532. * Licensed to the Apache Software Foundation (ASF) under one
  73533. * or more contributor license agreements. See the NOTICE file
  73534. * distributed with this work for additional information
  73535. * regarding copyright ownership. The ASF licenses this file
  73536. * to you under the Apache License, Version 2.0 (the
  73537. * "License"); you may not use this file except in compliance
  73538. * with the License. You may obtain a copy of the License at
  73539. *
  73540. * http://www.apache.org/licenses/LICENSE-2.0
  73541. *
  73542. * Unless required by applicable law or agreed to in writing,
  73543. * software distributed under the License is distributed on an
  73544. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73545. * KIND, either express or implied. See the License for the
  73546. * specific language governing permissions and limitations
  73547. * under the License.
  73548. */
  73549. /**
  73550. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73551. */
  73552. /*
  73553. * Licensed to the Apache Software Foundation (ASF) under one
  73554. * or more contributor license agreements. See the NOTICE file
  73555. * distributed with this work for additional information
  73556. * regarding copyright ownership. The ASF licenses this file
  73557. * to you under the Apache License, Version 2.0 (the
  73558. * "License"); you may not use this file except in compliance
  73559. * with the License. You may obtain a copy of the License at
  73560. *
  73561. * http://www.apache.org/licenses/LICENSE-2.0
  73562. *
  73563. * Unless required by applicable law or agreed to in writing,
  73564. * software distributed under the License is distributed on an
  73565. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73566. * KIND, either express or implied. See the License for the
  73567. * specific language governing permissions and limitations
  73568. * under the License.
  73569. */
  73570. var AxisPointerModel =
  73571. /** @class */
  73572. function (_super) {
  73573. __extends(AxisPointerModel, _super);
  73574. function AxisPointerModel() {
  73575. var _this = _super !== null && _super.apply(this, arguments) || this;
  73576. _this.type = AxisPointerModel.type;
  73577. return _this;
  73578. }
  73579. AxisPointerModel.type = 'axisPointer';
  73580. AxisPointerModel.defaultOption = {
  73581. // 'auto' means that show when triggered by tooltip or handle.
  73582. show: 'auto',
  73583. zlevel: 0,
  73584. z: 50,
  73585. type: 'line',
  73586. // axispointer triggered by tootip determine snap automatically,
  73587. // see `modelHelper`.
  73588. snap: false,
  73589. triggerTooltip: true,
  73590. value: null,
  73591. status: null,
  73592. link: [],
  73593. // Do not set 'auto' here, otherwise global animation: false
  73594. // will not effect at this axispointer.
  73595. animation: null,
  73596. animationDurationUpdate: 200,
  73597. lineStyle: {
  73598. color: '#B9BEC9',
  73599. width: 1,
  73600. type: 'dashed'
  73601. },
  73602. shadowStyle: {
  73603. color: 'rgba(210,219,238,0.2)'
  73604. },
  73605. label: {
  73606. show: true,
  73607. formatter: null,
  73608. precision: 'auto',
  73609. margin: 3,
  73610. color: '#fff',
  73611. padding: [5, 7, 5, 7],
  73612. backgroundColor: 'auto',
  73613. borderColor: null,
  73614. borderWidth: 0,
  73615. borderRadius: 3
  73616. },
  73617. handle: {
  73618. show: false,
  73619. // eslint-disable-next-line
  73620. icon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z',
  73621. size: 45,
  73622. // handle margin is from symbol center to axis, which is stable when circular move.
  73623. margin: 50,
  73624. // color: '#1b8bbd'
  73625. // color: '#2f4554'
  73626. color: '#333',
  73627. shadowBlur: 3,
  73628. shadowColor: '#aaa',
  73629. shadowOffsetX: 0,
  73630. shadowOffsetY: 2,
  73631. // For mobile performance
  73632. throttle: 40
  73633. }
  73634. };
  73635. return AxisPointerModel;
  73636. }(ComponentModel);
  73637. /*
  73638. * Licensed to the Apache Software Foundation (ASF) under one
  73639. * or more contributor license agreements. See the NOTICE file
  73640. * distributed with this work for additional information
  73641. * regarding copyright ownership. The ASF licenses this file
  73642. * to you under the Apache License, Version 2.0 (the
  73643. * "License"); you may not use this file except in compliance
  73644. * with the License. You may obtain a copy of the License at
  73645. *
  73646. * http://www.apache.org/licenses/LICENSE-2.0
  73647. *
  73648. * Unless required by applicable law or agreed to in writing,
  73649. * software distributed under the License is distributed on an
  73650. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73651. * KIND, either express or implied. See the License for the
  73652. * specific language governing permissions and limitations
  73653. * under the License.
  73654. */
  73655. /**
  73656. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73657. */
  73658. /*
  73659. * Licensed to the Apache Software Foundation (ASF) under one
  73660. * or more contributor license agreements. See the NOTICE file
  73661. * distributed with this work for additional information
  73662. * regarding copyright ownership. The ASF licenses this file
  73663. * to you under the Apache License, Version 2.0 (the
  73664. * "License"); you may not use this file except in compliance
  73665. * with the License. You may obtain a copy of the License at
  73666. *
  73667. * http://www.apache.org/licenses/LICENSE-2.0
  73668. *
  73669. * Unless required by applicable law or agreed to in writing,
  73670. * software distributed under the License is distributed on an
  73671. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73672. * KIND, either express or implied. See the License for the
  73673. * specific language governing permissions and limitations
  73674. * under the License.
  73675. */
  73676. var inner$11 = makeInner();
  73677. var each$8 = each$1;
  73678. /**
  73679. * @param {string} key
  73680. * @param {module:echarts/ExtensionAPI} api
  73681. * @param {Function} handler
  73682. * param: {string} currTrigger
  73683. * param: {Array.<number>} point
  73684. */
  73685. function register(key, api, handler) {
  73686. if (env.node) {
  73687. return;
  73688. }
  73689. var zr = api.getZr();
  73690. inner$11(zr).records || (inner$11(zr).records = {});
  73691. initGlobalListeners(zr, api);
  73692. var record = inner$11(zr).records[key] || (inner$11(zr).records[key] = {});
  73693. record.handler = handler;
  73694. }
  73695. function initGlobalListeners(zr, api) {
  73696. if (inner$11(zr).initialized) {
  73697. return;
  73698. }
  73699. inner$11(zr).initialized = true;
  73700. useHandler('click', curry(doEnter, 'click'));
  73701. useHandler('mousemove', curry(doEnter, 'mousemove')); // useHandler('mouseout', onLeave);
  73702. useHandler('globalout', onLeave);
  73703. function useHandler(eventType, cb) {
  73704. zr.on(eventType, function (e) {
  73705. var dis = makeDispatchAction(api);
  73706. each$8(inner$11(zr).records, function (record) {
  73707. record && cb(record, e, dis.dispatchAction);
  73708. });
  73709. dispatchTooltipFinally(dis.pendings, api);
  73710. });
  73711. }
  73712. }
  73713. function dispatchTooltipFinally(pendings, api) {
  73714. var showLen = pendings.showTip.length;
  73715. var hideLen = pendings.hideTip.length;
  73716. var actuallyPayload;
  73717. if (showLen) {
  73718. actuallyPayload = pendings.showTip[showLen - 1];
  73719. } else if (hideLen) {
  73720. actuallyPayload = pendings.hideTip[hideLen - 1];
  73721. }
  73722. if (actuallyPayload) {
  73723. actuallyPayload.dispatchAction = null;
  73724. api.dispatchAction(actuallyPayload);
  73725. }
  73726. }
  73727. function onLeave(record, e, dispatchAction) {
  73728. record.handler('leave', null, dispatchAction);
  73729. }
  73730. function doEnter(currTrigger, record, e, dispatchAction) {
  73731. record.handler(currTrigger, e, dispatchAction);
  73732. }
  73733. function makeDispatchAction(api) {
  73734. var pendings = {
  73735. showTip: [],
  73736. hideTip: []
  73737. }; // FIXME
  73738. // better approach?
  73739. // 'showTip' and 'hideTip' can be triggered by axisPointer and tooltip,
  73740. // which may be conflict, (axisPointer call showTip but tooltip call hideTip);
  73741. // So we have to add "final stage" to merge those dispatched actions.
  73742. var dispatchAction = function (payload) {
  73743. var pendingList = pendings[payload.type];
  73744. if (pendingList) {
  73745. pendingList.push(payload);
  73746. } else {
  73747. payload.dispatchAction = dispatchAction;
  73748. api.dispatchAction(payload);
  73749. }
  73750. };
  73751. return {
  73752. dispatchAction: dispatchAction,
  73753. pendings: pendings
  73754. };
  73755. }
  73756. function unregister(key, api) {
  73757. if (env.node) {
  73758. return;
  73759. }
  73760. var zr = api.getZr();
  73761. var record = (inner$11(zr).records || {})[key];
  73762. if (record) {
  73763. inner$11(zr).records[key] = null;
  73764. }
  73765. }
  73766. /*
  73767. * Licensed to the Apache Software Foundation (ASF) under one
  73768. * or more contributor license agreements. See the NOTICE file
  73769. * distributed with this work for additional information
  73770. * regarding copyright ownership. The ASF licenses this file
  73771. * to you under the Apache License, Version 2.0 (the
  73772. * "License"); you may not use this file except in compliance
  73773. * with the License. You may obtain a copy of the License at
  73774. *
  73775. * http://www.apache.org/licenses/LICENSE-2.0
  73776. *
  73777. * Unless required by applicable law or agreed to in writing,
  73778. * software distributed under the License is distributed on an
  73779. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73780. * KIND, either express or implied. See the License for the
  73781. * specific language governing permissions and limitations
  73782. * under the License.
  73783. */
  73784. /**
  73785. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73786. */
  73787. /*
  73788. * Licensed to the Apache Software Foundation (ASF) under one
  73789. * or more contributor license agreements. See the NOTICE file
  73790. * distributed with this work for additional information
  73791. * regarding copyright ownership. The ASF licenses this file
  73792. * to you under the Apache License, Version 2.0 (the
  73793. * "License"); you may not use this file except in compliance
  73794. * with the License. You may obtain a copy of the License at
  73795. *
  73796. * http://www.apache.org/licenses/LICENSE-2.0
  73797. *
  73798. * Unless required by applicable law or agreed to in writing,
  73799. * software distributed under the License is distributed on an
  73800. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73801. * KIND, either express or implied. See the License for the
  73802. * specific language governing permissions and limitations
  73803. * under the License.
  73804. */
  73805. var AxisPointerView =
  73806. /** @class */
  73807. function (_super) {
  73808. __extends(AxisPointerView, _super);
  73809. function AxisPointerView() {
  73810. var _this = _super !== null && _super.apply(this, arguments) || this;
  73811. _this.type = AxisPointerView.type;
  73812. return _this;
  73813. }
  73814. AxisPointerView.prototype.render = function (globalAxisPointerModel, ecModel, api) {
  73815. var globalTooltipModel = ecModel.getComponent('tooltip');
  73816. var triggerOn = globalAxisPointerModel.get('triggerOn') || globalTooltipModel && globalTooltipModel.get('triggerOn') || 'mousemove|click'; // Register global listener in AxisPointerView to enable
  73817. // AxisPointerView to be independent to Tooltip.
  73818. register('axisPointer', api, function (currTrigger, e, dispatchAction) {
  73819. // If 'none', it is not controlled by mouse totally.
  73820. if (triggerOn !== 'none' && (currTrigger === 'leave' || triggerOn.indexOf(currTrigger) >= 0)) {
  73821. dispatchAction({
  73822. type: 'updateAxisPointer',
  73823. currTrigger: currTrigger,
  73824. x: e && e.offsetX,
  73825. y: e && e.offsetY
  73826. });
  73827. }
  73828. });
  73829. };
  73830. AxisPointerView.prototype.remove = function (ecModel, api) {
  73831. unregister('axisPointer', api);
  73832. };
  73833. AxisPointerView.prototype.dispose = function (ecModel, api) {
  73834. unregister('axisPointer', api);
  73835. };
  73836. AxisPointerView.type = 'axisPointer';
  73837. return AxisPointerView;
  73838. }(ComponentView);
  73839. /*
  73840. * Licensed to the Apache Software Foundation (ASF) under one
  73841. * or more contributor license agreements. See the NOTICE file
  73842. * distributed with this work for additional information
  73843. * regarding copyright ownership. The ASF licenses this file
  73844. * to you under the Apache License, Version 2.0 (the
  73845. * "License"); you may not use this file except in compliance
  73846. * with the License. You may obtain a copy of the License at
  73847. *
  73848. * http://www.apache.org/licenses/LICENSE-2.0
  73849. *
  73850. * Unless required by applicable law or agreed to in writing,
  73851. * software distributed under the License is distributed on an
  73852. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73853. * KIND, either express or implied. See the License for the
  73854. * specific language governing permissions and limitations
  73855. * under the License.
  73856. */
  73857. /**
  73858. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73859. */
  73860. /*
  73861. * Licensed to the Apache Software Foundation (ASF) under one
  73862. * or more contributor license agreements. See the NOTICE file
  73863. * distributed with this work for additional information
  73864. * regarding copyright ownership. The ASF licenses this file
  73865. * to you under the Apache License, Version 2.0 (the
  73866. * "License"); you may not use this file except in compliance
  73867. * with the License. You may obtain a copy of the License at
  73868. *
  73869. * http://www.apache.org/licenses/LICENSE-2.0
  73870. *
  73871. * Unless required by applicable law or agreed to in writing,
  73872. * software distributed under the License is distributed on an
  73873. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73874. * KIND, either express or implied. See the License for the
  73875. * specific language governing permissions and limitations
  73876. * under the License.
  73877. */
  73878. /**
  73879. * @param finder contains {seriesIndex, dataIndex, dataIndexInside}
  73880. * @param ecModel
  73881. * @return {point: [x, y], el: ...} point Will not be null.
  73882. */
  73883. function findPointFromSeries(finder, ecModel) {
  73884. var point = [];
  73885. var seriesIndex = finder.seriesIndex;
  73886. var seriesModel;
  73887. if (seriesIndex == null || !(seriesModel = ecModel.getSeriesByIndex(seriesIndex))) {
  73888. return {
  73889. point: []
  73890. };
  73891. }
  73892. var data = seriesModel.getData();
  73893. var dataIndex = queryDataIndex(data, finder);
  73894. if (dataIndex == null || dataIndex < 0 || isArray(dataIndex)) {
  73895. return {
  73896. point: []
  73897. };
  73898. }
  73899. var el = data.getItemGraphicEl(dataIndex);
  73900. var coordSys = seriesModel.coordinateSystem;
  73901. if (seriesModel.getTooltipPosition) {
  73902. point = seriesModel.getTooltipPosition(dataIndex) || [];
  73903. } else if (coordSys && coordSys.dataToPoint) {
  73904. if (finder.isStacked) {
  73905. var baseAxis = coordSys.getBaseAxis();
  73906. var valueAxis = coordSys.getOtherAxis(baseAxis);
  73907. var valueAxisDim = valueAxis.dim;
  73908. var baseAxisDim = baseAxis.dim;
  73909. var baseDataOffset = valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0;
  73910. var baseDim = data.mapDimension(baseAxisDim);
  73911. var stackedData = [];
  73912. stackedData[baseDataOffset] = data.get(baseDim, dataIndex);
  73913. stackedData[1 - baseDataOffset] = data.get(data.getCalculationInfo('stackResultDimension'), dataIndex);
  73914. point = coordSys.dataToPoint(stackedData) || [];
  73915. } else {
  73916. point = coordSys.dataToPoint(data.getValues(map(coordSys.dimensions, function (dim) {
  73917. return data.mapDimension(dim);
  73918. }), dataIndex)) || [];
  73919. }
  73920. } else if (el) {
  73921. // Use graphic bounding rect
  73922. var rect = el.getBoundingRect().clone();
  73923. rect.applyTransform(el.transform);
  73924. point = [rect.x + rect.width / 2, rect.y + rect.height / 2];
  73925. }
  73926. return {
  73927. point: point,
  73928. el: el
  73929. };
  73930. }
  73931. /*
  73932. * Licensed to the Apache Software Foundation (ASF) under one
  73933. * or more contributor license agreements. See the NOTICE file
  73934. * distributed with this work for additional information
  73935. * regarding copyright ownership. The ASF licenses this file
  73936. * to you under the Apache License, Version 2.0 (the
  73937. * "License"); you may not use this file except in compliance
  73938. * with the License. You may obtain a copy of the License at
  73939. *
  73940. * http://www.apache.org/licenses/LICENSE-2.0
  73941. *
  73942. * Unless required by applicable law or agreed to in writing,
  73943. * software distributed under the License is distributed on an
  73944. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73945. * KIND, either express or implied. See the License for the
  73946. * specific language governing permissions and limitations
  73947. * under the License.
  73948. */
  73949. /**
  73950. * AUTO-GENERATED FILE. DO NOT MODIFY.
  73951. */
  73952. /*
  73953. * Licensed to the Apache Software Foundation (ASF) under one
  73954. * or more contributor license agreements. See the NOTICE file
  73955. * distributed with this work for additional information
  73956. * regarding copyright ownership. The ASF licenses this file
  73957. * to you under the Apache License, Version 2.0 (the
  73958. * "License"); you may not use this file except in compliance
  73959. * with the License. You may obtain a copy of the License at
  73960. *
  73961. * http://www.apache.org/licenses/LICENSE-2.0
  73962. *
  73963. * Unless required by applicable law or agreed to in writing,
  73964. * software distributed under the License is distributed on an
  73965. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  73966. * KIND, either express or implied. See the License for the
  73967. * specific language governing permissions and limitations
  73968. * under the License.
  73969. */
  73970. var inner$12 = makeInner();
  73971. /**
  73972. * Basic logic: check all axis, if they do not demand show/highlight,
  73973. * then hide/downplay them.
  73974. *
  73975. * @return content of event obj for echarts.connect.
  73976. */
  73977. function axisTrigger(payload, ecModel, api) {
  73978. var currTrigger = payload.currTrigger;
  73979. var point = [payload.x, payload.y];
  73980. var finder = payload;
  73981. var dispatchAction = payload.dispatchAction || bind(api.dispatchAction, api);
  73982. var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo; // Pending
  73983. // See #6121. But we are not able to reproduce it yet.
  73984. if (!coordSysAxesInfo) {
  73985. return;
  73986. }
  73987. if (illegalPoint(point)) {
  73988. // Used in the default behavior of `connection`: use the sample seriesIndex
  73989. // and dataIndex. And also used in the tooltipView trigger.
  73990. point = findPointFromSeries({
  73991. seriesIndex: finder.seriesIndex,
  73992. // Do not use dataIndexInside from other ec instance.
  73993. // FIXME: auto detect it?
  73994. dataIndex: finder.dataIndex
  73995. }, ecModel).point;
  73996. }
  73997. var isIllegalPoint = illegalPoint(point); // Axis and value can be specified when calling dispatchAction({type: 'updateAxisPointer'}).
  73998. // Notice: In this case, it is difficult to get the `point` (which is necessary to show
  73999. // tooltip, so if point is not given, we just use the point found by sample seriesIndex
  74000. // and dataIndex.
  74001. var inputAxesInfo = finder.axesInfo;
  74002. var axesInfo = coordSysAxesInfo.axesInfo;
  74003. var shouldHide = currTrigger === 'leave' || illegalPoint(point);
  74004. var outputPayload = {};
  74005. var showValueMap = {};
  74006. var dataByCoordSys = {
  74007. list: [],
  74008. map: {}
  74009. };
  74010. var updaters = {
  74011. showPointer: curry(showPointer, showValueMap),
  74012. showTooltip: curry(showTooltip, dataByCoordSys)
  74013. }; // Process for triggered axes.
  74014. each$1(coordSysAxesInfo.coordSysMap, function (coordSys, coordSysKey) {
  74015. // If a point given, it must be contained by the coordinate system.
  74016. var coordSysContainsPoint = isIllegalPoint || coordSys.containPoint(point);
  74017. each$1(coordSysAxesInfo.coordSysAxesInfo[coordSysKey], function (axisInfo, key) {
  74018. var axis = axisInfo.axis;
  74019. var inputAxisInfo = findInputAxisInfo(inputAxesInfo, axisInfo); // If no inputAxesInfo, no axis is restricted.
  74020. if (!shouldHide && coordSysContainsPoint && (!inputAxesInfo || inputAxisInfo)) {
  74021. var val = inputAxisInfo && inputAxisInfo.value;
  74022. if (val == null && !isIllegalPoint) {
  74023. val = axis.pointToData(point);
  74024. }
  74025. val != null && processOnAxis(axisInfo, val, updaters, false, outputPayload);
  74026. }
  74027. });
  74028. }); // Process for linked axes.
  74029. var linkTriggers = {};
  74030. each$1(axesInfo, function (tarAxisInfo, tarKey) {
  74031. var linkGroup = tarAxisInfo.linkGroup; // If axis has been triggered in the previous stage, it should not be triggered by link.
  74032. if (linkGroup && !showValueMap[tarKey]) {
  74033. each$1(linkGroup.axesInfo, function (srcAxisInfo, srcKey) {
  74034. var srcValItem = showValueMap[srcKey]; // If srcValItem exist, source axis is triggered, so link to target axis.
  74035. if (srcAxisInfo !== tarAxisInfo && srcValItem) {
  74036. var val = srcValItem.value;
  74037. linkGroup.mapper && (val = tarAxisInfo.axis.scale.parse(linkGroup.mapper(val, makeMapperParam(srcAxisInfo), makeMapperParam(tarAxisInfo))));
  74038. linkTriggers[tarAxisInfo.key] = val;
  74039. }
  74040. });
  74041. }
  74042. });
  74043. each$1(linkTriggers, function (val, tarKey) {
  74044. processOnAxis(axesInfo[tarKey], val, updaters, true, outputPayload);
  74045. });
  74046. updateModelActually(showValueMap, axesInfo, outputPayload);
  74047. dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction);
  74048. dispatchHighDownActually(axesInfo, dispatchAction, api);
  74049. return outputPayload;
  74050. }
  74051. function processOnAxis(axisInfo, newValue, updaters, noSnap, outputFinder) {
  74052. var axis = axisInfo.axis;
  74053. if (axis.scale.isBlank() || !axis.containData(newValue)) {
  74054. return;
  74055. }
  74056. if (!axisInfo.involveSeries) {
  74057. updaters.showPointer(axisInfo, newValue);
  74058. return;
  74059. } // Heavy calculation. So put it after axis.containData checking.
  74060. var payloadInfo = buildPayloadsBySeries(newValue, axisInfo);
  74061. var payloadBatch = payloadInfo.payloadBatch;
  74062. var snapToValue = payloadInfo.snapToValue; // Fill content of event obj for echarts.connect.
  74063. // By default use the first involved series data as a sample to connect.
  74064. if (payloadBatch[0] && outputFinder.seriesIndex == null) {
  74065. extend(outputFinder, payloadBatch[0]);
  74066. } // If no linkSource input, this process is for collecting link
  74067. // target, where snap should not be accepted.
  74068. if (!noSnap && axisInfo.snap) {
  74069. if (axis.containData(snapToValue) && snapToValue != null) {
  74070. newValue = snapToValue;
  74071. }
  74072. }
  74073. updaters.showPointer(axisInfo, newValue, payloadBatch); // Tooltip should always be snapToValue, otherwise there will be
  74074. // incorrect "axis value ~ series value" mapping displayed in tooltip.
  74075. updaters.showTooltip(axisInfo, payloadInfo, snapToValue);
  74076. }
  74077. function buildPayloadsBySeries(value, axisInfo) {
  74078. var axis = axisInfo.axis;
  74079. var dim = axis.dim;
  74080. var snapToValue = value;
  74081. var payloadBatch = [];
  74082. var minDist = Number.MAX_VALUE;
  74083. var minDiff = -1;
  74084. each$1(axisInfo.seriesModels, function (series, idx) {
  74085. var dataDim = series.getData().mapDimensionsAll(dim);
  74086. var seriesNestestValue;
  74087. var dataIndices;
  74088. if (series.getAxisTooltipData) {
  74089. var result = series.getAxisTooltipData(dataDim, value, axis);
  74090. dataIndices = result.dataIndices;
  74091. seriesNestestValue = result.nestestValue;
  74092. } else {
  74093. dataIndices = series.getData().indicesOfNearest(dataDim[0], value, // Add a threshold to avoid find the wrong dataIndex
  74094. // when data length is not same.
  74095. // false,
  74096. axis.type === 'category' ? 0.5 : null);
  74097. if (!dataIndices.length) {
  74098. return;
  74099. }
  74100. seriesNestestValue = series.getData().get(dataDim[0], dataIndices[0]);
  74101. }
  74102. if (seriesNestestValue == null || !isFinite(seriesNestestValue)) {
  74103. return;
  74104. }
  74105. var diff = value - seriesNestestValue;
  74106. var dist = Math.abs(diff); // Consider category case
  74107. if (dist <= minDist) {
  74108. if (dist < minDist || diff >= 0 && minDiff < 0) {
  74109. minDist = dist;
  74110. minDiff = diff;
  74111. snapToValue = seriesNestestValue;
  74112. payloadBatch.length = 0;
  74113. }
  74114. each$1(dataIndices, function (dataIndex) {
  74115. payloadBatch.push({
  74116. seriesIndex: series.seriesIndex,
  74117. dataIndexInside: dataIndex,
  74118. dataIndex: series.getData().getRawIndex(dataIndex)
  74119. });
  74120. });
  74121. }
  74122. });
  74123. return {
  74124. payloadBatch: payloadBatch,
  74125. snapToValue: snapToValue
  74126. };
  74127. }
  74128. function showPointer(showValueMap, axisInfo, value, payloadBatch) {
  74129. showValueMap[axisInfo.key] = {
  74130. value: value,
  74131. payloadBatch: payloadBatch
  74132. };
  74133. }
  74134. function showTooltip(dataByCoordSys, axisInfo, payloadInfo, value) {
  74135. var payloadBatch = payloadInfo.payloadBatch;
  74136. var axis = axisInfo.axis;
  74137. var axisModel = axis.model;
  74138. var axisPointerModel = axisInfo.axisPointerModel; // If no data, do not create anything in dataByCoordSys,
  74139. // whose length will be used to judge whether dispatch action.
  74140. if (!axisInfo.triggerTooltip || !payloadBatch.length) {
  74141. return;
  74142. }
  74143. var coordSysModel = axisInfo.coordSys.model;
  74144. var coordSysKey = makeKey(coordSysModel);
  74145. var coordSysItem = dataByCoordSys.map[coordSysKey];
  74146. if (!coordSysItem) {
  74147. coordSysItem = dataByCoordSys.map[coordSysKey] = {
  74148. coordSysId: coordSysModel.id,
  74149. coordSysIndex: coordSysModel.componentIndex,
  74150. coordSysType: coordSysModel.type,
  74151. coordSysMainType: coordSysModel.mainType,
  74152. dataByAxis: []
  74153. };
  74154. dataByCoordSys.list.push(coordSysItem);
  74155. }
  74156. coordSysItem.dataByAxis.push({
  74157. axisDim: axis.dim,
  74158. axisIndex: axisModel.componentIndex,
  74159. axisType: axisModel.type,
  74160. axisId: axisModel.id,
  74161. value: value,
  74162. // Caustion: viewHelper.getValueLabel is actually on "view stage", which
  74163. // depends that all models have been updated. So it should not be performed
  74164. // here. Considering axisPointerModel used here is volatile, which is hard
  74165. // to be retrieve in TooltipView, we prepare parameters here.
  74166. valueLabelOpt: {
  74167. precision: axisPointerModel.get(['label', 'precision']),
  74168. formatter: axisPointerModel.get(['label', 'formatter'])
  74169. },
  74170. seriesDataIndices: payloadBatch.slice()
  74171. });
  74172. }
  74173. function updateModelActually(showValueMap, axesInfo, outputPayload) {
  74174. var outputAxesInfo = outputPayload.axesInfo = []; // Basic logic: If no 'show' required, 'hide' this axisPointer.
  74175. each$1(axesInfo, function (axisInfo, key) {
  74176. var option = axisInfo.axisPointerModel.option;
  74177. var valItem = showValueMap[key];
  74178. if (valItem) {
  74179. !axisInfo.useHandle && (option.status = 'show');
  74180. option.value = valItem.value; // For label formatter param and highlight.
  74181. option.seriesDataIndices = (valItem.payloadBatch || []).slice();
  74182. } // When always show (e.g., handle used), remain
  74183. // original value and status.
  74184. else {
  74185. // If hide, value still need to be set, consider
  74186. // click legend to toggle axis blank.
  74187. !axisInfo.useHandle && (option.status = 'hide');
  74188. } // If status is 'hide', should be no info in payload.
  74189. option.status === 'show' && outputAxesInfo.push({
  74190. axisDim: axisInfo.axis.dim,
  74191. axisIndex: axisInfo.axis.model.componentIndex,
  74192. value: option.value
  74193. });
  74194. });
  74195. }
  74196. function dispatchTooltipActually(dataByCoordSys, point, payload, dispatchAction) {
  74197. // Basic logic: If no showTip required, hideTip will be dispatched.
  74198. if (illegalPoint(point) || !dataByCoordSys.list.length) {
  74199. dispatchAction({
  74200. type: 'hideTip'
  74201. });
  74202. return;
  74203. } // In most case only one axis (or event one series is used). It is
  74204. // convinient to fetch payload.seriesIndex and payload.dataIndex
  74205. // dirtectly. So put the first seriesIndex and dataIndex of the first
  74206. // axis on the payload.
  74207. var sampleItem = ((dataByCoordSys.list[0].dataByAxis[0] || {}).seriesDataIndices || [])[0] || {};
  74208. dispatchAction({
  74209. type: 'showTip',
  74210. escapeConnect: true,
  74211. x: point[0],
  74212. y: point[1],
  74213. tooltipOption: payload.tooltipOption,
  74214. position: payload.position,
  74215. dataIndexInside: sampleItem.dataIndexInside,
  74216. dataIndex: sampleItem.dataIndex,
  74217. seriesIndex: sampleItem.seriesIndex,
  74218. dataByCoordSys: dataByCoordSys.list
  74219. });
  74220. }
  74221. function dispatchHighDownActually(axesInfo, dispatchAction, api) {
  74222. // FIXME
  74223. // highlight status modification shoule be a stage of main process?
  74224. // (Consider confilct (e.g., legend and axisPointer) and setOption)
  74225. var zr = api.getZr();
  74226. var highDownKey = 'axisPointerLastHighlights';
  74227. var lastHighlights = inner$12(zr)[highDownKey] || {};
  74228. var newHighlights = inner$12(zr)[highDownKey] = {}; // Update highlight/downplay status according to axisPointer model.
  74229. // Build hash map and remove duplicate incidentally.
  74230. each$1(axesInfo, function (axisInfo, key) {
  74231. var option = axisInfo.axisPointerModel.option;
  74232. option.status === 'show' && each$1(option.seriesDataIndices, function (batchItem) {
  74233. var key = batchItem.seriesIndex + ' | ' + batchItem.dataIndex;
  74234. newHighlights[key] = batchItem;
  74235. });
  74236. }); // Diff.
  74237. var toHighlight = [];
  74238. var toDownplay = [];
  74239. each$1(lastHighlights, function (batchItem, key) {
  74240. !newHighlights[key] && toDownplay.push(batchItem);
  74241. });
  74242. each$1(newHighlights, function (batchItem, key) {
  74243. !lastHighlights[key] && toHighlight.push(batchItem);
  74244. });
  74245. toDownplay.length && api.dispatchAction({
  74246. type: 'downplay',
  74247. escapeConnect: true,
  74248. // Not blur others when highlight in axisPointer.
  74249. notBlur: true,
  74250. batch: toDownplay
  74251. });
  74252. toHighlight.length && api.dispatchAction({
  74253. type: 'highlight',
  74254. escapeConnect: true,
  74255. // Not blur others when highlight in axisPointer.
  74256. notBlur: true,
  74257. batch: toHighlight
  74258. });
  74259. }
  74260. function findInputAxisInfo(inputAxesInfo, axisInfo) {
  74261. for (var i = 0; i < (inputAxesInfo || []).length; i++) {
  74262. var inputAxisInfo = inputAxesInfo[i];
  74263. if (axisInfo.axis.dim === inputAxisInfo.axisDim && axisInfo.axis.model.componentIndex === inputAxisInfo.axisIndex) {
  74264. return inputAxisInfo;
  74265. }
  74266. }
  74267. }
  74268. function makeMapperParam(axisInfo) {
  74269. var axisModel = axisInfo.axis.model;
  74270. var item = {};
  74271. var dim = item.axisDim = axisInfo.axis.dim;
  74272. item.axisIndex = item[dim + 'AxisIndex'] = axisModel.componentIndex;
  74273. item.axisName = item[dim + 'AxisName'] = axisModel.name;
  74274. item.axisId = item[dim + 'AxisId'] = axisModel.id;
  74275. return item;
  74276. }
  74277. function illegalPoint(point) {
  74278. return !point || point[0] == null || isNaN(point[0]) || point[1] == null || isNaN(point[1]);
  74279. }
  74280. /*
  74281. * Licensed to the Apache Software Foundation (ASF) under one
  74282. * or more contributor license agreements. See the NOTICE file
  74283. * distributed with this work for additional information
  74284. * regarding copyright ownership. The ASF licenses this file
  74285. * to you under the Apache License, Version 2.0 (the
  74286. * "License"); you may not use this file except in compliance
  74287. * with the License. You may obtain a copy of the License at
  74288. *
  74289. * http://www.apache.org/licenses/LICENSE-2.0
  74290. *
  74291. * Unless required by applicable law or agreed to in writing,
  74292. * software distributed under the License is distributed on an
  74293. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74294. * KIND, either express or implied. See the License for the
  74295. * specific language governing permissions and limitations
  74296. * under the License.
  74297. */
  74298. /**
  74299. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74300. */
  74301. /*
  74302. * Licensed to the Apache Software Foundation (ASF) under one
  74303. * or more contributor license agreements. See the NOTICE file
  74304. * distributed with this work for additional information
  74305. * regarding copyright ownership. The ASF licenses this file
  74306. * to you under the Apache License, Version 2.0 (the
  74307. * "License"); you may not use this file except in compliance
  74308. * with the License. You may obtain a copy of the License at
  74309. *
  74310. * http://www.apache.org/licenses/LICENSE-2.0
  74311. *
  74312. * Unless required by applicable law or agreed to in writing,
  74313. * software distributed under the License is distributed on an
  74314. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74315. * KIND, either express or implied. See the License for the
  74316. * specific language governing permissions and limitations
  74317. * under the License.
  74318. */
  74319. function install$29(registers) {
  74320. // CartesianAxisPointer is not supposed to be required here. But consider
  74321. // echarts.simple.js and online build tooltip, which only require gridSimple,
  74322. // CartesianAxisPointer should be able to required somewhere.
  74323. AxisView.registerAxisPointerClass('CartesianAxisPointer', CartesianAxisPointer);
  74324. registers.registerComponentModel(AxisPointerModel);
  74325. registers.registerComponentView(AxisPointerView);
  74326. registers.registerPreprocessor(function (option) {
  74327. // Always has a global axisPointerModel for default setting.
  74328. if (option) {
  74329. (!option.axisPointer || option.axisPointer.length === 0) && (option.axisPointer = {});
  74330. var link = option.axisPointer.link; // Normalize to array to avoid object mergin. But if link
  74331. // is not set, remain null/undefined, otherwise it will
  74332. // override existent link setting.
  74333. if (link && !isArray(link)) {
  74334. option.axisPointer.link = [link];
  74335. }
  74336. }
  74337. }); // This process should proformed after coordinate systems created
  74338. // and series data processed. So put it on statistic processing stage.
  74339. registers.registerProcessor(registers.PRIORITY.PROCESSOR.STATISTIC, function (ecModel, api) {
  74340. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  74341. // allAxesInfo should be updated when setOption performed.
  74342. ecModel.getComponent('axisPointer').coordSysAxesInfo = collect(ecModel, api);
  74343. }); // Broadcast to all views.
  74344. registers.registerAction({
  74345. type: 'updateAxisPointer',
  74346. event: 'updateAxisPointer',
  74347. update: ':updateAxisPointer'
  74348. }, axisTrigger);
  74349. }
  74350. /*
  74351. * Licensed to the Apache Software Foundation (ASF) under one
  74352. * or more contributor license agreements. See the NOTICE file
  74353. * distributed with this work for additional information
  74354. * regarding copyright ownership. The ASF licenses this file
  74355. * to you under the Apache License, Version 2.0 (the
  74356. * "License"); you may not use this file except in compliance
  74357. * with the License. You may obtain a copy of the License at
  74358. *
  74359. * http://www.apache.org/licenses/LICENSE-2.0
  74360. *
  74361. * Unless required by applicable law or agreed to in writing,
  74362. * software distributed under the License is distributed on an
  74363. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74364. * KIND, either express or implied. See the License for the
  74365. * specific language governing permissions and limitations
  74366. * under the License.
  74367. */
  74368. /**
  74369. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74370. */
  74371. /*
  74372. * Licensed to the Apache Software Foundation (ASF) under one
  74373. * or more contributor license agreements. See the NOTICE file
  74374. * distributed with this work for additional information
  74375. * regarding copyright ownership. The ASF licenses this file
  74376. * to you under the Apache License, Version 2.0 (the
  74377. * "License"); you may not use this file except in compliance
  74378. * with the License. You may obtain a copy of the License at
  74379. *
  74380. * http://www.apache.org/licenses/LICENSE-2.0
  74381. *
  74382. * Unless required by applicable law or agreed to in writing,
  74383. * software distributed under the License is distributed on an
  74384. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74385. * KIND, either express or implied. See the License for the
  74386. * specific language governing permissions and limitations
  74387. * under the License.
  74388. */
  74389. var PolarModel =
  74390. /** @class */
  74391. function (_super) {
  74392. __extends(PolarModel, _super);
  74393. function PolarModel() {
  74394. var _this = _super !== null && _super.apply(this, arguments) || this;
  74395. _this.type = PolarModel.type;
  74396. return _this;
  74397. }
  74398. PolarModel.prototype.findAxisModel = function (axisType) {
  74399. var foundAxisModel;
  74400. var ecModel = this.ecModel;
  74401. ecModel.eachComponent(axisType, function (axisModel) {
  74402. if (axisModel.getCoordSysModel() === this) {
  74403. foundAxisModel = axisModel;
  74404. }
  74405. }, this);
  74406. return foundAxisModel;
  74407. };
  74408. PolarModel.type = 'polar';
  74409. PolarModel.dependencies = ['radiusAxis', 'angleAxis'];
  74410. PolarModel.defaultOption = {
  74411. zlevel: 0,
  74412. z: 0,
  74413. center: ['50%', '50%'],
  74414. radius: '80%'
  74415. };
  74416. return PolarModel;
  74417. }(ComponentModel);
  74418. /*
  74419. * Licensed to the Apache Software Foundation (ASF) under one
  74420. * or more contributor license agreements. See the NOTICE file
  74421. * distributed with this work for additional information
  74422. * regarding copyright ownership. The ASF licenses this file
  74423. * to you under the Apache License, Version 2.0 (the
  74424. * "License"); you may not use this file except in compliance
  74425. * with the License. You may obtain a copy of the License at
  74426. *
  74427. * http://www.apache.org/licenses/LICENSE-2.0
  74428. *
  74429. * Unless required by applicable law or agreed to in writing,
  74430. * software distributed under the License is distributed on an
  74431. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74432. * KIND, either express or implied. See the License for the
  74433. * specific language governing permissions and limitations
  74434. * under the License.
  74435. */
  74436. /**
  74437. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74438. */
  74439. /*
  74440. * Licensed to the Apache Software Foundation (ASF) under one
  74441. * or more contributor license agreements. See the NOTICE file
  74442. * distributed with this work for additional information
  74443. * regarding copyright ownership. The ASF licenses this file
  74444. * to you under the Apache License, Version 2.0 (the
  74445. * "License"); you may not use this file except in compliance
  74446. * with the License. You may obtain a copy of the License at
  74447. *
  74448. * http://www.apache.org/licenses/LICENSE-2.0
  74449. *
  74450. * Unless required by applicable law or agreed to in writing,
  74451. * software distributed under the License is distributed on an
  74452. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74453. * KIND, either express or implied. See the License for the
  74454. * specific language governing permissions and limitations
  74455. * under the License.
  74456. */
  74457. var PolarAxisModel =
  74458. /** @class */
  74459. function (_super) {
  74460. __extends(PolarAxisModel, _super);
  74461. function PolarAxisModel() {
  74462. return _super !== null && _super.apply(this, arguments) || this;
  74463. }
  74464. PolarAxisModel.prototype.getCoordSysModel = function () {
  74465. return this.getReferringComponents('polar', SINGLE_REFERRING).models[0];
  74466. };
  74467. PolarAxisModel.type = 'polarAxis';
  74468. return PolarAxisModel;
  74469. }(ComponentModel);
  74470. mixin(PolarAxisModel, AxisModelCommonMixin);
  74471. var AngleAxisModel =
  74472. /** @class */
  74473. function (_super) {
  74474. __extends(AngleAxisModel, _super);
  74475. function AngleAxisModel() {
  74476. var _this = _super !== null && _super.apply(this, arguments) || this;
  74477. _this.type = AngleAxisModel.type;
  74478. return _this;
  74479. }
  74480. AngleAxisModel.type = 'angleAxis';
  74481. return AngleAxisModel;
  74482. }(PolarAxisModel);
  74483. var RadiusAxisModel =
  74484. /** @class */
  74485. function (_super) {
  74486. __extends(RadiusAxisModel, _super);
  74487. function RadiusAxisModel() {
  74488. var _this = _super !== null && _super.apply(this, arguments) || this;
  74489. _this.type = RadiusAxisModel.type;
  74490. return _this;
  74491. }
  74492. RadiusAxisModel.type = 'radiusAxis';
  74493. return RadiusAxisModel;
  74494. }(PolarAxisModel);
  74495. /*
  74496. * Licensed to the Apache Software Foundation (ASF) under one
  74497. * or more contributor license agreements. See the NOTICE file
  74498. * distributed with this work for additional information
  74499. * regarding copyright ownership. The ASF licenses this file
  74500. * to you under the Apache License, Version 2.0 (the
  74501. * "License"); you may not use this file except in compliance
  74502. * with the License. You may obtain a copy of the License at
  74503. *
  74504. * http://www.apache.org/licenses/LICENSE-2.0
  74505. *
  74506. * Unless required by applicable law or agreed to in writing,
  74507. * software distributed under the License is distributed on an
  74508. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74509. * KIND, either express or implied. See the License for the
  74510. * specific language governing permissions and limitations
  74511. * under the License.
  74512. */
  74513. /**
  74514. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74515. */
  74516. /*
  74517. * Licensed to the Apache Software Foundation (ASF) under one
  74518. * or more contributor license agreements. See the NOTICE file
  74519. * distributed with this work for additional information
  74520. * regarding copyright ownership. The ASF licenses this file
  74521. * to you under the Apache License, Version 2.0 (the
  74522. * "License"); you may not use this file except in compliance
  74523. * with the License. You may obtain a copy of the License at
  74524. *
  74525. * http://www.apache.org/licenses/LICENSE-2.0
  74526. *
  74527. * Unless required by applicable law or agreed to in writing,
  74528. * software distributed under the License is distributed on an
  74529. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74530. * KIND, either express or implied. See the License for the
  74531. * specific language governing permissions and limitations
  74532. * under the License.
  74533. */
  74534. var RadiusAxis =
  74535. /** @class */
  74536. function (_super) {
  74537. __extends(RadiusAxis, _super);
  74538. function RadiusAxis(scale, radiusExtent) {
  74539. return _super.call(this, 'radius', scale, radiusExtent) || this;
  74540. }
  74541. RadiusAxis.prototype.pointToData = function (point, clamp) {
  74542. return this.polar.pointToData(point, clamp)[this.dim === 'radius' ? 0 : 1];
  74543. };
  74544. return RadiusAxis;
  74545. }(Axis);
  74546. RadiusAxis.prototype.dataToRadius = Axis.prototype.dataToCoord;
  74547. RadiusAxis.prototype.radiusToData = Axis.prototype.coordToData;
  74548. /*
  74549. * Licensed to the Apache Software Foundation (ASF) under one
  74550. * or more contributor license agreements. See the NOTICE file
  74551. * distributed with this work for additional information
  74552. * regarding copyright ownership. The ASF licenses this file
  74553. * to you under the Apache License, Version 2.0 (the
  74554. * "License"); you may not use this file except in compliance
  74555. * with the License. You may obtain a copy of the License at
  74556. *
  74557. * http://www.apache.org/licenses/LICENSE-2.0
  74558. *
  74559. * Unless required by applicable law or agreed to in writing,
  74560. * software distributed under the License is distributed on an
  74561. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74562. * KIND, either express or implied. See the License for the
  74563. * specific language governing permissions and limitations
  74564. * under the License.
  74565. */
  74566. /**
  74567. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74568. */
  74569. /*
  74570. * Licensed to the Apache Software Foundation (ASF) under one
  74571. * or more contributor license agreements. See the NOTICE file
  74572. * distributed with this work for additional information
  74573. * regarding copyright ownership. The ASF licenses this file
  74574. * to you under the Apache License, Version 2.0 (the
  74575. * "License"); you may not use this file except in compliance
  74576. * with the License. You may obtain a copy of the License at
  74577. *
  74578. * http://www.apache.org/licenses/LICENSE-2.0
  74579. *
  74580. * Unless required by applicable law or agreed to in writing,
  74581. * software distributed under the License is distributed on an
  74582. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74583. * KIND, either express or implied. See the License for the
  74584. * specific language governing permissions and limitations
  74585. * under the License.
  74586. */
  74587. var inner$13 = makeInner();
  74588. var AngleAxis =
  74589. /** @class */
  74590. function (_super) {
  74591. __extends(AngleAxis, _super);
  74592. function AngleAxis(scale, angleExtent) {
  74593. return _super.call(this, 'angle', scale, angleExtent || [0, 360]) || this;
  74594. }
  74595. AngleAxis.prototype.pointToData = function (point, clamp) {
  74596. return this.polar.pointToData(point, clamp)[this.dim === 'radius' ? 0 : 1];
  74597. };
  74598. /**
  74599. * Only be called in category axis.
  74600. * Angle axis uses text height to decide interval
  74601. *
  74602. * @override
  74603. * @return {number} Auto interval for cateogry axis tick and label
  74604. */
  74605. AngleAxis.prototype.calculateCategoryInterval = function () {
  74606. var axis = this;
  74607. var labelModel = axis.getLabelModel();
  74608. var ordinalScale = axis.scale;
  74609. var ordinalExtent = ordinalScale.getExtent(); // Providing this method is for optimization:
  74610. // avoid generating a long array by `getTicks`
  74611. // in large category data case.
  74612. var tickCount = ordinalScale.count();
  74613. if (ordinalExtent[1] - ordinalExtent[0] < 1) {
  74614. return 0;
  74615. }
  74616. var tickValue = ordinalExtent[0];
  74617. var unitSpan = axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue);
  74618. var unitH = Math.abs(unitSpan); // Not precise, just use height as text width
  74619. // and each distance from axis line yet.
  74620. var rect = getBoundingRect(tickValue == null ? '' : tickValue + '', labelModel.getFont(), 'center', 'top');
  74621. var maxH = Math.max(rect.height, 7);
  74622. var dh = maxH / unitH; // 0/0 is NaN, 1/0 is Infinity.
  74623. isNaN(dh) && (dh = Infinity);
  74624. var interval = Math.max(0, Math.floor(dh));
  74625. var cache = inner$13(axis.model);
  74626. var lastAutoInterval = cache.lastAutoInterval;
  74627. var lastTickCount = cache.lastTickCount; // Use cache to keep interval stable while moving zoom window,
  74628. // otherwise the calculated interval might jitter when the zoom
  74629. // window size is close to the interval-changing size.
  74630. if (lastAutoInterval != null && lastTickCount != null && Math.abs(lastAutoInterval - interval) <= 1 && Math.abs(lastTickCount - tickCount) <= 1 // Always choose the bigger one, otherwise the critical
  74631. // point is not the same when zooming in or zooming out.
  74632. && lastAutoInterval > interval) {
  74633. interval = lastAutoInterval;
  74634. } // Only update cache if cache not used, otherwise the
  74635. // changing of interval is too insensitive.
  74636. else {
  74637. cache.lastTickCount = tickCount;
  74638. cache.lastAutoInterval = interval;
  74639. }
  74640. return interval;
  74641. };
  74642. return AngleAxis;
  74643. }(Axis);
  74644. AngleAxis.prototype.dataToAngle = Axis.prototype.dataToCoord;
  74645. AngleAxis.prototype.angleToData = Axis.prototype.coordToData;
  74646. /*
  74647. * Licensed to the Apache Software Foundation (ASF) under one
  74648. * or more contributor license agreements. See the NOTICE file
  74649. * distributed with this work for additional information
  74650. * regarding copyright ownership. The ASF licenses this file
  74651. * to you under the Apache License, Version 2.0 (the
  74652. * "License"); you may not use this file except in compliance
  74653. * with the License. You may obtain a copy of the License at
  74654. *
  74655. * http://www.apache.org/licenses/LICENSE-2.0
  74656. *
  74657. * Unless required by applicable law or agreed to in writing,
  74658. * software distributed under the License is distributed on an
  74659. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74660. * KIND, either express or implied. See the License for the
  74661. * specific language governing permissions and limitations
  74662. * under the License.
  74663. */
  74664. /**
  74665. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74666. */
  74667. /*
  74668. * Licensed to the Apache Software Foundation (ASF) under one
  74669. * or more contributor license agreements. See the NOTICE file
  74670. * distributed with this work for additional information
  74671. * regarding copyright ownership. The ASF licenses this file
  74672. * to you under the Apache License, Version 2.0 (the
  74673. * "License"); you may not use this file except in compliance
  74674. * with the License. You may obtain a copy of the License at
  74675. *
  74676. * http://www.apache.org/licenses/LICENSE-2.0
  74677. *
  74678. * Unless required by applicable law or agreed to in writing,
  74679. * software distributed under the License is distributed on an
  74680. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74681. * KIND, either express or implied. See the License for the
  74682. * specific language governing permissions and limitations
  74683. * under the License.
  74684. */
  74685. var Polar =
  74686. /** @class */
  74687. function () {
  74688. function Polar(name) {
  74689. this.dimensions = ['radius', 'angle'];
  74690. this.type = 'polar';
  74691. /**
  74692. * x of polar center
  74693. */
  74694. this.cx = 0;
  74695. /**
  74696. * y of polar center
  74697. */
  74698. this.cy = 0;
  74699. this._radiusAxis = new RadiusAxis();
  74700. this._angleAxis = new AngleAxis();
  74701. this.axisPointerEnabled = true;
  74702. this.name = name || '';
  74703. this._radiusAxis.polar = this._angleAxis.polar = this;
  74704. }
  74705. /**
  74706. * If contain coord
  74707. */
  74708. Polar.prototype.containPoint = function (point) {
  74709. var coord = this.pointToCoord(point);
  74710. return this._radiusAxis.contain(coord[0]) && this._angleAxis.contain(coord[1]);
  74711. };
  74712. /**
  74713. * If contain data
  74714. */
  74715. Polar.prototype.containData = function (data) {
  74716. return this._radiusAxis.containData(data[0]) && this._angleAxis.containData(data[1]);
  74717. };
  74718. Polar.prototype.getAxis = function (dim) {
  74719. var key = '_' + dim + 'Axis';
  74720. return this[key];
  74721. };
  74722. Polar.prototype.getAxes = function () {
  74723. return [this._radiusAxis, this._angleAxis];
  74724. };
  74725. /**
  74726. * Get axes by type of scale
  74727. */
  74728. Polar.prototype.getAxesByScale = function (scaleType) {
  74729. var axes = [];
  74730. var angleAxis = this._angleAxis;
  74731. var radiusAxis = this._radiusAxis;
  74732. angleAxis.scale.type === scaleType && axes.push(angleAxis);
  74733. radiusAxis.scale.type === scaleType && axes.push(radiusAxis);
  74734. return axes;
  74735. };
  74736. Polar.prototype.getAngleAxis = function () {
  74737. return this._angleAxis;
  74738. };
  74739. Polar.prototype.getRadiusAxis = function () {
  74740. return this._radiusAxis;
  74741. };
  74742. Polar.prototype.getOtherAxis = function (axis) {
  74743. var angleAxis = this._angleAxis;
  74744. return axis === angleAxis ? this._radiusAxis : angleAxis;
  74745. };
  74746. /**
  74747. * Base axis will be used on stacking.
  74748. *
  74749. */
  74750. Polar.prototype.getBaseAxis = function () {
  74751. return this.getAxesByScale('ordinal')[0] || this.getAxesByScale('time')[0] || this.getAngleAxis();
  74752. };
  74753. Polar.prototype.getTooltipAxes = function (dim) {
  74754. var baseAxis = dim != null && dim !== 'auto' ? this.getAxis(dim) : this.getBaseAxis();
  74755. return {
  74756. baseAxes: [baseAxis],
  74757. otherAxes: [this.getOtherAxis(baseAxis)]
  74758. };
  74759. };
  74760. /**
  74761. * Convert a single data item to (x, y) point.
  74762. * Parameter data is an array which the first element is radius and the second is angle
  74763. */
  74764. Polar.prototype.dataToPoint = function (data, clamp) {
  74765. return this.coordToPoint([this._radiusAxis.dataToRadius(data[0], clamp), this._angleAxis.dataToAngle(data[1], clamp)]);
  74766. };
  74767. /**
  74768. * Convert a (x, y) point to data
  74769. */
  74770. Polar.prototype.pointToData = function (point, clamp) {
  74771. var coord = this.pointToCoord(point);
  74772. return [this._radiusAxis.radiusToData(coord[0], clamp), this._angleAxis.angleToData(coord[1], clamp)];
  74773. };
  74774. /**
  74775. * Convert a (x, y) point to (radius, angle) coord
  74776. */
  74777. Polar.prototype.pointToCoord = function (point) {
  74778. var dx = point[0] - this.cx;
  74779. var dy = point[1] - this.cy;
  74780. var angleAxis = this.getAngleAxis();
  74781. var extent = angleAxis.getExtent();
  74782. var minAngle = Math.min(extent[0], extent[1]);
  74783. var maxAngle = Math.max(extent[0], extent[1]); // Fix fixed extent in polarCreator
  74784. // FIXME
  74785. angleAxis.inverse ? minAngle = maxAngle - 360 : maxAngle = minAngle + 360;
  74786. var radius = Math.sqrt(dx * dx + dy * dy);
  74787. dx /= radius;
  74788. dy /= radius;
  74789. var radian = Math.atan2(-dy, dx) / Math.PI * 180; // move to angleExtent
  74790. var dir = radian < minAngle ? 1 : -1;
  74791. while (radian < minAngle || radian > maxAngle) {
  74792. radian += dir * 360;
  74793. }
  74794. return [radius, radian];
  74795. };
  74796. /**
  74797. * Convert a (radius, angle) coord to (x, y) point
  74798. */
  74799. Polar.prototype.coordToPoint = function (coord) {
  74800. var radius = coord[0];
  74801. var radian = coord[1] / 180 * Math.PI;
  74802. var x = Math.cos(radian) * radius + this.cx; // Inverse the y
  74803. var y = -Math.sin(radian) * radius + this.cy;
  74804. return [x, y];
  74805. };
  74806. /**
  74807. * Get ring area of cartesian.
  74808. * Area will have a contain function to determine if a point is in the coordinate system.
  74809. */
  74810. Polar.prototype.getArea = function () {
  74811. var angleAxis = this.getAngleAxis();
  74812. var radiusAxis = this.getRadiusAxis();
  74813. var radiusExtent = radiusAxis.getExtent().slice();
  74814. radiusExtent[0] > radiusExtent[1] && radiusExtent.reverse();
  74815. var angleExtent = angleAxis.getExtent();
  74816. var RADIAN = Math.PI / 180;
  74817. return {
  74818. cx: this.cx,
  74819. cy: this.cy,
  74820. r0: radiusExtent[0],
  74821. r: radiusExtent[1],
  74822. startAngle: -angleExtent[0] * RADIAN,
  74823. endAngle: -angleExtent[1] * RADIAN,
  74824. clockwise: angleAxis.inverse,
  74825. contain: function (x, y) {
  74826. // It's a ring shape.
  74827. // Start angle and end angle don't matter
  74828. var dx = x - this.cx;
  74829. var dy = y - this.cy;
  74830. var d2 = dx * dx + dy * dy;
  74831. var r = this.r;
  74832. var r0 = this.r0;
  74833. return d2 <= r * r && d2 >= r0 * r0;
  74834. }
  74835. };
  74836. };
  74837. Polar.prototype.convertToPixel = function (ecModel, finder, value) {
  74838. var coordSys = getCoordSys$2(finder);
  74839. return coordSys === this ? this.dataToPoint(value) : null;
  74840. };
  74841. Polar.prototype.convertFromPixel = function (ecModel, finder, pixel) {
  74842. var coordSys = getCoordSys$2(finder);
  74843. return coordSys === this ? this.pointToData(pixel) : null;
  74844. };
  74845. return Polar;
  74846. }();
  74847. function getCoordSys$2(finder) {
  74848. var seriesModel = finder.seriesModel;
  74849. var polarModel = finder.polarModel;
  74850. return polarModel && polarModel.coordinateSystem || seriesModel && seriesModel.coordinateSystem;
  74851. }
  74852. /*
  74853. * Licensed to the Apache Software Foundation (ASF) under one
  74854. * or more contributor license agreements. See the NOTICE file
  74855. * distributed with this work for additional information
  74856. * regarding copyright ownership. The ASF licenses this file
  74857. * to you under the Apache License, Version 2.0 (the
  74858. * "License"); you may not use this file except in compliance
  74859. * with the License. You may obtain a copy of the License at
  74860. *
  74861. * http://www.apache.org/licenses/LICENSE-2.0
  74862. *
  74863. * Unless required by applicable law or agreed to in writing,
  74864. * software distributed under the License is distributed on an
  74865. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74866. * KIND, either express or implied. See the License for the
  74867. * specific language governing permissions and limitations
  74868. * under the License.
  74869. */
  74870. /**
  74871. * AUTO-GENERATED FILE. DO NOT MODIFY.
  74872. */
  74873. /*
  74874. * Licensed to the Apache Software Foundation (ASF) under one
  74875. * or more contributor license agreements. See the NOTICE file
  74876. * distributed with this work for additional information
  74877. * regarding copyright ownership. The ASF licenses this file
  74878. * to you under the Apache License, Version 2.0 (the
  74879. * "License"); you may not use this file except in compliance
  74880. * with the License. You may obtain a copy of the License at
  74881. *
  74882. * http://www.apache.org/licenses/LICENSE-2.0
  74883. *
  74884. * Unless required by applicable law or agreed to in writing,
  74885. * software distributed under the License is distributed on an
  74886. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  74887. * KIND, either express or implied. See the License for the
  74888. * specific language governing permissions and limitations
  74889. * under the License.
  74890. */
  74891. // TODO Axis scale
  74892. /**
  74893. * Resize method bound to the polar
  74894. */
  74895. function resizePolar(polar, polarModel, api) {
  74896. var center = polarModel.get('center');
  74897. var width = api.getWidth();
  74898. var height = api.getHeight();
  74899. polar.cx = parsePercent$1(center[0], width);
  74900. polar.cy = parsePercent$1(center[1], height);
  74901. var radiusAxis = polar.getRadiusAxis();
  74902. var size = Math.min(width, height) / 2;
  74903. var radius = polarModel.get('radius');
  74904. if (radius == null) {
  74905. radius = [0, '100%'];
  74906. } else if (!isArray(radius)) {
  74907. // r0 = 0
  74908. radius = [0, radius];
  74909. }
  74910. var parsedRadius = [parsePercent$1(radius[0], size), parsePercent$1(radius[1], size)];
  74911. radiusAxis.inverse ? radiusAxis.setExtent(parsedRadius[1], parsedRadius[0]) : radiusAxis.setExtent(parsedRadius[0], parsedRadius[1]);
  74912. }
  74913. /**
  74914. * Update polar
  74915. */
  74916. function updatePolarScale(ecModel, api) {
  74917. var polar = this;
  74918. var angleAxis = polar.getAngleAxis();
  74919. var radiusAxis = polar.getRadiusAxis(); // Reset scale
  74920. angleAxis.scale.setExtent(Infinity, -Infinity);
  74921. radiusAxis.scale.setExtent(Infinity, -Infinity);
  74922. ecModel.eachSeries(function (seriesModel) {
  74923. if (seriesModel.coordinateSystem === polar) {
  74924. var data_1 = seriesModel.getData();
  74925. each$1(getDataDimensionsOnAxis(data_1, 'radius'), function (dim) {
  74926. radiusAxis.scale.unionExtentFromData(data_1, dim);
  74927. });
  74928. each$1(getDataDimensionsOnAxis(data_1, 'angle'), function (dim) {
  74929. angleAxis.scale.unionExtentFromData(data_1, dim);
  74930. });
  74931. }
  74932. });
  74933. niceScaleExtent(angleAxis.scale, angleAxis.model);
  74934. niceScaleExtent(radiusAxis.scale, radiusAxis.model); // Fix extent of category angle axis
  74935. if (angleAxis.type === 'category' && !angleAxis.onBand) {
  74936. var extent = angleAxis.getExtent();
  74937. var diff = 360 / angleAxis.scale.count();
  74938. angleAxis.inverse ? extent[1] += diff : extent[1] -= diff;
  74939. angleAxis.setExtent(extent[0], extent[1]);
  74940. }
  74941. }
  74942. function isAngleAxisModel(axisModel) {
  74943. return axisModel.mainType === 'angleAxis';
  74944. }
  74945. /**
  74946. * Set common axis properties
  74947. */
  74948. function setAxis(axis, axisModel) {
  74949. axis.type = axisModel.get('type');
  74950. axis.scale = createScaleByModel(axisModel);
  74951. axis.onBand = axisModel.get('boundaryGap') && axis.type === 'category';
  74952. axis.inverse = axisModel.get('inverse');
  74953. if (isAngleAxisModel(axisModel)) {
  74954. axis.inverse = axis.inverse !== axisModel.get('clockwise');
  74955. var startAngle = axisModel.get('startAngle');
  74956. axis.setExtent(startAngle, startAngle + (axis.inverse ? -360 : 360));
  74957. } // Inject axis instance
  74958. axisModel.axis = axis;
  74959. axis.model = axisModel;
  74960. }
  74961. var polarCreator = {
  74962. dimensions: Polar.prototype.dimensions,
  74963. create: function (ecModel, api) {
  74964. var polarList = [];
  74965. ecModel.eachComponent('polar', function (polarModel, idx) {
  74966. var polar = new Polar(idx + ''); // Inject resize and update method
  74967. polar.update = updatePolarScale;
  74968. var radiusAxis = polar.getRadiusAxis();
  74969. var angleAxis = polar.getAngleAxis();
  74970. var radiusAxisModel = polarModel.findAxisModel('radiusAxis');
  74971. var angleAxisModel = polarModel.findAxisModel('angleAxis');
  74972. setAxis(radiusAxis, radiusAxisModel);
  74973. setAxis(angleAxis, angleAxisModel);
  74974. resizePolar(polar, polarModel, api);
  74975. polarList.push(polar);
  74976. polarModel.coordinateSystem = polar;
  74977. polar.model = polarModel;
  74978. }); // Inject coordinateSystem to series
  74979. ecModel.eachSeries(function (seriesModel) {
  74980. if (seriesModel.get('coordinateSystem') === 'polar') {
  74981. var polarModel = seriesModel.getReferringComponents('polar', SINGLE_REFERRING).models[0];
  74982. {
  74983. if (!polarModel) {
  74984. throw new Error('Polar "' + retrieve(seriesModel.get('polarIndex'), seriesModel.get('polarId'), 0) + '" not found');
  74985. }
  74986. }
  74987. seriesModel.coordinateSystem = polarModel.coordinateSystem;
  74988. }
  74989. });
  74990. return polarList;
  74991. }
  74992. };
  74993. /*
  74994. * Licensed to the Apache Software Foundation (ASF) under one
  74995. * or more contributor license agreements. See the NOTICE file
  74996. * distributed with this work for additional information
  74997. * regarding copyright ownership. The ASF licenses this file
  74998. * to you under the Apache License, Version 2.0 (the
  74999. * "License"); you may not use this file except in compliance
  75000. * with the License. You may obtain a copy of the License at
  75001. *
  75002. * http://www.apache.org/licenses/LICENSE-2.0
  75003. *
  75004. * Unless required by applicable law or agreed to in writing,
  75005. * software distributed under the License is distributed on an
  75006. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75007. * KIND, either express or implied. See the License for the
  75008. * specific language governing permissions and limitations
  75009. * under the License.
  75010. */
  75011. /**
  75012. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75013. */
  75014. /*
  75015. * Licensed to the Apache Software Foundation (ASF) under one
  75016. * or more contributor license agreements. See the NOTICE file
  75017. * distributed with this work for additional information
  75018. * regarding copyright ownership. The ASF licenses this file
  75019. * to you under the Apache License, Version 2.0 (the
  75020. * "License"); you may not use this file except in compliance
  75021. * with the License. You may obtain a copy of the License at
  75022. *
  75023. * http://www.apache.org/licenses/LICENSE-2.0
  75024. *
  75025. * Unless required by applicable law or agreed to in writing,
  75026. * software distributed under the License is distributed on an
  75027. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75028. * KIND, either express or implied. See the License for the
  75029. * specific language governing permissions and limitations
  75030. * under the License.
  75031. */
  75032. var elementList$1 = ['axisLine', 'axisLabel', 'axisTick', 'minorTick', 'splitLine', 'minorSplitLine', 'splitArea'];
  75033. function getAxisLineShape(polar, rExtent, angle) {
  75034. rExtent[1] > rExtent[0] && (rExtent = rExtent.slice().reverse());
  75035. var start = polar.coordToPoint([rExtent[0], angle]);
  75036. var end = polar.coordToPoint([rExtent[1], angle]);
  75037. return {
  75038. x1: start[0],
  75039. y1: start[1],
  75040. x2: end[0],
  75041. y2: end[1]
  75042. };
  75043. }
  75044. function getRadiusIdx(polar) {
  75045. var radiusAxis = polar.getRadiusAxis();
  75046. return radiusAxis.inverse ? 0 : 1;
  75047. } // Remove the last tick which will overlap the first tick
  75048. function fixAngleOverlap(list) {
  75049. var firstItem = list[0];
  75050. var lastItem = list[list.length - 1];
  75051. if (firstItem && lastItem && Math.abs(Math.abs(firstItem.coord - lastItem.coord) - 360) < 1e-4) {
  75052. list.pop();
  75053. }
  75054. }
  75055. var AngleAxisView =
  75056. /** @class */
  75057. function (_super) {
  75058. __extends(AngleAxisView, _super);
  75059. function AngleAxisView() {
  75060. var _this = _super !== null && _super.apply(this, arguments) || this;
  75061. _this.type = AngleAxisView.type;
  75062. _this.axisPointerClass = 'PolarAxisPointer';
  75063. return _this;
  75064. }
  75065. AngleAxisView.prototype.render = function (angleAxisModel, ecModel) {
  75066. this.group.removeAll();
  75067. if (!angleAxisModel.get('show')) {
  75068. return;
  75069. }
  75070. var angleAxis = angleAxisModel.axis;
  75071. var polar = angleAxis.polar;
  75072. var radiusExtent = polar.getRadiusAxis().getExtent();
  75073. var ticksAngles = angleAxis.getTicksCoords();
  75074. var minorTickAngles = angleAxis.getMinorTicksCoords();
  75075. var labels = map(angleAxis.getViewLabels(), function (labelItem) {
  75076. labelItem = clone(labelItem);
  75077. var scale = angleAxis.scale;
  75078. var tickValue = scale.type === 'ordinal' ? scale.getRawOrdinalNumber(labelItem.tickValue) : labelItem.tickValue;
  75079. labelItem.coord = angleAxis.dataToCoord(tickValue);
  75080. return labelItem;
  75081. });
  75082. fixAngleOverlap(labels);
  75083. fixAngleOverlap(ticksAngles);
  75084. each$1(elementList$1, function (name) {
  75085. if (angleAxisModel.get([name, 'show']) && (!angleAxis.scale.isBlank() || name === 'axisLine')) {
  75086. angelAxisElementsBuilders[name](this.group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent, labels);
  75087. }
  75088. }, this);
  75089. };
  75090. AngleAxisView.type = 'angleAxis';
  75091. return AngleAxisView;
  75092. }(AxisView);
  75093. var angelAxisElementsBuilders = {
  75094. axisLine: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
  75095. var lineStyleModel = angleAxisModel.getModel(['axisLine', 'lineStyle']); // extent id of the axis radius (r0 and r)
  75096. var rId = getRadiusIdx(polar);
  75097. var r0Id = rId ? 0 : 1;
  75098. var shape;
  75099. if (radiusExtent[r0Id] === 0) {
  75100. shape = new Circle({
  75101. shape: {
  75102. cx: polar.cx,
  75103. cy: polar.cy,
  75104. r: radiusExtent[rId]
  75105. },
  75106. style: lineStyleModel.getLineStyle(),
  75107. z2: 1,
  75108. silent: true
  75109. });
  75110. } else {
  75111. shape = new Ring({
  75112. shape: {
  75113. cx: polar.cx,
  75114. cy: polar.cy,
  75115. r: radiusExtent[rId],
  75116. r0: radiusExtent[r0Id]
  75117. },
  75118. style: lineStyleModel.getLineStyle(),
  75119. z2: 1,
  75120. silent: true
  75121. });
  75122. }
  75123. shape.style.fill = null;
  75124. group.add(shape);
  75125. },
  75126. axisTick: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
  75127. var tickModel = angleAxisModel.getModel('axisTick');
  75128. var tickLen = (tickModel.get('inside') ? -1 : 1) * tickModel.get('length');
  75129. var radius = radiusExtent[getRadiusIdx(polar)];
  75130. var lines = map(ticksAngles, function (tickAngleItem) {
  75131. return new Line({
  75132. shape: getAxisLineShape(polar, [radius, radius + tickLen], tickAngleItem.coord)
  75133. });
  75134. });
  75135. group.add(mergePath(lines, {
  75136. style: defaults(tickModel.getModel('lineStyle').getLineStyle(), {
  75137. stroke: angleAxisModel.get(['axisLine', 'lineStyle', 'color'])
  75138. })
  75139. }));
  75140. },
  75141. minorTick: function (group, angleAxisModel, polar, tickAngles, minorTickAngles, radiusExtent) {
  75142. if (!minorTickAngles.length) {
  75143. return;
  75144. }
  75145. var tickModel = angleAxisModel.getModel('axisTick');
  75146. var minorTickModel = angleAxisModel.getModel('minorTick');
  75147. var tickLen = (tickModel.get('inside') ? -1 : 1) * minorTickModel.get('length');
  75148. var radius = radiusExtent[getRadiusIdx(polar)];
  75149. var lines = [];
  75150. for (var i = 0; i < minorTickAngles.length; i++) {
  75151. for (var k = 0; k < minorTickAngles[i].length; k++) {
  75152. lines.push(new Line({
  75153. shape: getAxisLineShape(polar, [radius, radius + tickLen], minorTickAngles[i][k].coord)
  75154. }));
  75155. }
  75156. }
  75157. group.add(mergePath(lines, {
  75158. style: defaults(minorTickModel.getModel('lineStyle').getLineStyle(), defaults(tickModel.getLineStyle(), {
  75159. stroke: angleAxisModel.get(['axisLine', 'lineStyle', 'color'])
  75160. }))
  75161. }));
  75162. },
  75163. axisLabel: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent, labels) {
  75164. var rawCategoryData = angleAxisModel.getCategories(true);
  75165. var commonLabelModel = angleAxisModel.getModel('axisLabel');
  75166. var labelMargin = commonLabelModel.get('margin');
  75167. var triggerEvent = angleAxisModel.get('triggerEvent'); // Use length of ticksAngles because it may remove the last tick to avoid overlapping
  75168. each$1(labels, function (labelItem, idx) {
  75169. var labelModel = commonLabelModel;
  75170. var tickValue = labelItem.tickValue;
  75171. var r = radiusExtent[getRadiusIdx(polar)];
  75172. var p = polar.coordToPoint([r + labelMargin, labelItem.coord]);
  75173. var cx = polar.cx;
  75174. var cy = polar.cy;
  75175. var labelTextAlign = Math.abs(p[0] - cx) / r < 0.3 ? 'center' : p[0] > cx ? 'left' : 'right';
  75176. var labelTextVerticalAlign = Math.abs(p[1] - cy) / r < 0.3 ? 'middle' : p[1] > cy ? 'top' : 'bottom';
  75177. if (rawCategoryData && rawCategoryData[tickValue]) {
  75178. var rawCategoryItem = rawCategoryData[tickValue];
  75179. if (isObject$1(rawCategoryItem) && rawCategoryItem.textStyle) {
  75180. labelModel = new Model(rawCategoryItem.textStyle, commonLabelModel, commonLabelModel.ecModel);
  75181. }
  75182. }
  75183. var textEl = new ZRText({
  75184. silent: AxisBuilder.isLabelSilent(angleAxisModel),
  75185. style: createTextStyle(labelModel, {
  75186. x: p[0],
  75187. y: p[1],
  75188. fill: labelModel.getTextColor() || angleAxisModel.get(['axisLine', 'lineStyle', 'color']),
  75189. text: labelItem.formattedLabel,
  75190. align: labelTextAlign,
  75191. verticalAlign: labelTextVerticalAlign
  75192. })
  75193. });
  75194. group.add(textEl); // Pack data for mouse event
  75195. if (triggerEvent) {
  75196. var eventData = AxisBuilder.makeAxisEventDataBase(angleAxisModel);
  75197. eventData.targetType = 'axisLabel';
  75198. eventData.value = labelItem.rawLabel;
  75199. getECData(textEl).eventData = eventData;
  75200. }
  75201. }, this);
  75202. },
  75203. splitLine: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
  75204. var splitLineModel = angleAxisModel.getModel('splitLine');
  75205. var lineStyleModel = splitLineModel.getModel('lineStyle');
  75206. var lineColors = lineStyleModel.get('color');
  75207. var lineCount = 0;
  75208. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  75209. var splitLines = [];
  75210. for (var i = 0; i < ticksAngles.length; i++) {
  75211. var colorIndex = lineCount++ % lineColors.length;
  75212. splitLines[colorIndex] = splitLines[colorIndex] || [];
  75213. splitLines[colorIndex].push(new Line({
  75214. shape: getAxisLineShape(polar, radiusExtent, ticksAngles[i].coord)
  75215. }));
  75216. } // Simple optimization
  75217. // Batching the lines if color are the same
  75218. for (var i = 0; i < splitLines.length; i++) {
  75219. group.add(mergePath(splitLines[i], {
  75220. style: defaults({
  75221. stroke: lineColors[i % lineColors.length]
  75222. }, lineStyleModel.getLineStyle()),
  75223. silent: true,
  75224. z: angleAxisModel.get('z')
  75225. }));
  75226. }
  75227. },
  75228. minorSplitLine: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
  75229. if (!minorTickAngles.length) {
  75230. return;
  75231. }
  75232. var minorSplitLineModel = angleAxisModel.getModel('minorSplitLine');
  75233. var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
  75234. var lines = [];
  75235. for (var i = 0; i < minorTickAngles.length; i++) {
  75236. for (var k = 0; k < minorTickAngles[i].length; k++) {
  75237. lines.push(new Line({
  75238. shape: getAxisLineShape(polar, radiusExtent, minorTickAngles[i][k].coord)
  75239. }));
  75240. }
  75241. }
  75242. group.add(mergePath(lines, {
  75243. style: lineStyleModel.getLineStyle(),
  75244. silent: true,
  75245. z: angleAxisModel.get('z')
  75246. }));
  75247. },
  75248. splitArea: function (group, angleAxisModel, polar, ticksAngles, minorTickAngles, radiusExtent) {
  75249. if (!ticksAngles.length) {
  75250. return;
  75251. }
  75252. var splitAreaModel = angleAxisModel.getModel('splitArea');
  75253. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  75254. var areaColors = areaStyleModel.get('color');
  75255. var lineCount = 0;
  75256. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  75257. var splitAreas = [];
  75258. var RADIAN = Math.PI / 180;
  75259. var prevAngle = -ticksAngles[0].coord * RADIAN;
  75260. var r0 = Math.min(radiusExtent[0], radiusExtent[1]);
  75261. var r1 = Math.max(radiusExtent[0], radiusExtent[1]);
  75262. var clockwise = angleAxisModel.get('clockwise');
  75263. for (var i = 1, len = ticksAngles.length; i <= len; i++) {
  75264. var coord = i === len ? ticksAngles[0].coord : ticksAngles[i].coord;
  75265. var colorIndex = lineCount++ % areaColors.length;
  75266. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  75267. splitAreas[colorIndex].push(new Sector({
  75268. shape: {
  75269. cx: polar.cx,
  75270. cy: polar.cy,
  75271. r0: r0,
  75272. r: r1,
  75273. startAngle: prevAngle,
  75274. endAngle: -coord * RADIAN,
  75275. clockwise: clockwise
  75276. },
  75277. silent: true
  75278. }));
  75279. prevAngle = -coord * RADIAN;
  75280. } // Simple optimization
  75281. // Batching the lines if color are the same
  75282. for (var i = 0; i < splitAreas.length; i++) {
  75283. group.add(mergePath(splitAreas[i], {
  75284. style: defaults({
  75285. fill: areaColors[i % areaColors.length]
  75286. }, areaStyleModel.getAreaStyle()),
  75287. silent: true
  75288. }));
  75289. }
  75290. }
  75291. };
  75292. /*
  75293. * Licensed to the Apache Software Foundation (ASF) under one
  75294. * or more contributor license agreements. See the NOTICE file
  75295. * distributed with this work for additional information
  75296. * regarding copyright ownership. The ASF licenses this file
  75297. * to you under the Apache License, Version 2.0 (the
  75298. * "License"); you may not use this file except in compliance
  75299. * with the License. You may obtain a copy of the License at
  75300. *
  75301. * http://www.apache.org/licenses/LICENSE-2.0
  75302. *
  75303. * Unless required by applicable law or agreed to in writing,
  75304. * software distributed under the License is distributed on an
  75305. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75306. * KIND, either express or implied. See the License for the
  75307. * specific language governing permissions and limitations
  75308. * under the License.
  75309. */
  75310. /**
  75311. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75312. */
  75313. /*
  75314. * Licensed to the Apache Software Foundation (ASF) under one
  75315. * or more contributor license agreements. See the NOTICE file
  75316. * distributed with this work for additional information
  75317. * regarding copyright ownership. The ASF licenses this file
  75318. * to you under the Apache License, Version 2.0 (the
  75319. * "License"); you may not use this file except in compliance
  75320. * with the License. You may obtain a copy of the License at
  75321. *
  75322. * http://www.apache.org/licenses/LICENSE-2.0
  75323. *
  75324. * Unless required by applicable law or agreed to in writing,
  75325. * software distributed under the License is distributed on an
  75326. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75327. * KIND, either express or implied. See the License for the
  75328. * specific language governing permissions and limitations
  75329. * under the License.
  75330. */
  75331. var axisBuilderAttrs$2 = ['axisLine', 'axisTickLabel', 'axisName'];
  75332. var selfBuilderAttrs$1 = ['splitLine', 'splitArea', 'minorSplitLine'];
  75333. var RadiusAxisView =
  75334. /** @class */
  75335. function (_super) {
  75336. __extends(RadiusAxisView, _super);
  75337. function RadiusAxisView() {
  75338. var _this = _super !== null && _super.apply(this, arguments) || this;
  75339. _this.type = RadiusAxisView.type;
  75340. _this.axisPointerClass = 'PolarAxisPointer';
  75341. return _this;
  75342. }
  75343. RadiusAxisView.prototype.render = function (radiusAxisModel, ecModel) {
  75344. this.group.removeAll();
  75345. if (!radiusAxisModel.get('show')) {
  75346. return;
  75347. }
  75348. var oldAxisGroup = this._axisGroup;
  75349. var newAxisGroup = this._axisGroup = new Group();
  75350. this.group.add(newAxisGroup);
  75351. var radiusAxis = radiusAxisModel.axis;
  75352. var polar = radiusAxis.polar;
  75353. var angleAxis = polar.getAngleAxis();
  75354. var ticksCoords = radiusAxis.getTicksCoords();
  75355. var minorTicksCoords = radiusAxis.getMinorTicksCoords();
  75356. var axisAngle = angleAxis.getExtent()[0];
  75357. var radiusExtent = radiusAxis.getExtent();
  75358. var layout = layoutAxis(polar, radiusAxisModel, axisAngle);
  75359. var axisBuilder = new AxisBuilder(radiusAxisModel, layout);
  75360. each$1(axisBuilderAttrs$2, axisBuilder.add, axisBuilder);
  75361. newAxisGroup.add(axisBuilder.getGroup());
  75362. groupTransition(oldAxisGroup, newAxisGroup, radiusAxisModel);
  75363. each$1(selfBuilderAttrs$1, function (name) {
  75364. if (radiusAxisModel.get([name, 'show']) && !radiusAxis.scale.isBlank()) {
  75365. axisElementBuilders$1[name](this.group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords, minorTicksCoords);
  75366. }
  75367. }, this);
  75368. };
  75369. RadiusAxisView.type = 'radiusAxis';
  75370. return RadiusAxisView;
  75371. }(AxisView);
  75372. var axisElementBuilders$1 = {
  75373. splitLine: function (group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  75374. var splitLineModel = radiusAxisModel.getModel('splitLine');
  75375. var lineStyleModel = splitLineModel.getModel('lineStyle');
  75376. var lineColors = lineStyleModel.get('color');
  75377. var lineCount = 0;
  75378. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  75379. var splitLines = [];
  75380. for (var i = 0; i < ticksCoords.length; i++) {
  75381. var colorIndex = lineCount++ % lineColors.length;
  75382. splitLines[colorIndex] = splitLines[colorIndex] || [];
  75383. splitLines[colorIndex].push(new Circle({
  75384. shape: {
  75385. cx: polar.cx,
  75386. cy: polar.cy,
  75387. r: ticksCoords[i].coord
  75388. }
  75389. }));
  75390. } // Simple optimization
  75391. // Batching the lines if color are the same
  75392. for (var i = 0; i < splitLines.length; i++) {
  75393. group.add(mergePath(splitLines[i], {
  75394. style: defaults({
  75395. stroke: lineColors[i % lineColors.length],
  75396. fill: null
  75397. }, lineStyleModel.getLineStyle()),
  75398. silent: true
  75399. }));
  75400. }
  75401. },
  75402. minorSplitLine: function (group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords, minorTicksCoords) {
  75403. if (!minorTicksCoords.length) {
  75404. return;
  75405. }
  75406. var minorSplitLineModel = radiusAxisModel.getModel('minorSplitLine');
  75407. var lineStyleModel = minorSplitLineModel.getModel('lineStyle');
  75408. var lines = [];
  75409. for (var i = 0; i < minorTicksCoords.length; i++) {
  75410. for (var k = 0; k < minorTicksCoords[i].length; k++) {
  75411. lines.push(new Circle({
  75412. shape: {
  75413. cx: polar.cx,
  75414. cy: polar.cy,
  75415. r: minorTicksCoords[i][k].coord
  75416. }
  75417. }));
  75418. }
  75419. }
  75420. group.add(mergePath(lines, {
  75421. style: defaults({
  75422. fill: null
  75423. }, lineStyleModel.getLineStyle()),
  75424. silent: true
  75425. }));
  75426. },
  75427. splitArea: function (group, radiusAxisModel, polar, axisAngle, radiusExtent, ticksCoords) {
  75428. if (!ticksCoords.length) {
  75429. return;
  75430. }
  75431. var splitAreaModel = radiusAxisModel.getModel('splitArea');
  75432. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  75433. var areaColors = areaStyleModel.get('color');
  75434. var lineCount = 0;
  75435. areaColors = areaColors instanceof Array ? areaColors : [areaColors];
  75436. var splitAreas = [];
  75437. var prevRadius = ticksCoords[0].coord;
  75438. for (var i = 1; i < ticksCoords.length; i++) {
  75439. var colorIndex = lineCount++ % areaColors.length;
  75440. splitAreas[colorIndex] = splitAreas[colorIndex] || [];
  75441. splitAreas[colorIndex].push(new Sector({
  75442. shape: {
  75443. cx: polar.cx,
  75444. cy: polar.cy,
  75445. r0: prevRadius,
  75446. r: ticksCoords[i].coord,
  75447. startAngle: 0,
  75448. endAngle: Math.PI * 2
  75449. },
  75450. silent: true
  75451. }));
  75452. prevRadius = ticksCoords[i].coord;
  75453. } // Simple optimization
  75454. // Batching the lines if color are the same
  75455. for (var i = 0; i < splitAreas.length; i++) {
  75456. group.add(mergePath(splitAreas[i], {
  75457. style: defaults({
  75458. fill: areaColors[i % areaColors.length]
  75459. }, areaStyleModel.getAreaStyle()),
  75460. silent: true
  75461. }));
  75462. }
  75463. }
  75464. };
  75465. /**
  75466. * @inner
  75467. */
  75468. function layoutAxis(polar, radiusAxisModel, axisAngle) {
  75469. return {
  75470. position: [polar.cx, polar.cy],
  75471. rotation: axisAngle / 180 * Math.PI,
  75472. labelDirection: -1,
  75473. tickDirection: -1,
  75474. nameDirection: 1,
  75475. labelRotate: radiusAxisModel.getModel('axisLabel').get('rotate'),
  75476. // Over splitLine and splitArea
  75477. z2: 1
  75478. };
  75479. }
  75480. /*
  75481. * Licensed to the Apache Software Foundation (ASF) under one
  75482. * or more contributor license agreements. See the NOTICE file
  75483. * distributed with this work for additional information
  75484. * regarding copyright ownership. The ASF licenses this file
  75485. * to you under the Apache License, Version 2.0 (the
  75486. * "License"); you may not use this file except in compliance
  75487. * with the License. You may obtain a copy of the License at
  75488. *
  75489. * http://www.apache.org/licenses/LICENSE-2.0
  75490. *
  75491. * Unless required by applicable law or agreed to in writing,
  75492. * software distributed under the License is distributed on an
  75493. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75494. * KIND, either express or implied. See the License for the
  75495. * specific language governing permissions and limitations
  75496. * under the License.
  75497. */
  75498. /**
  75499. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75500. */
  75501. /*
  75502. * Licensed to the Apache Software Foundation (ASF) under one
  75503. * or more contributor license agreements. See the NOTICE file
  75504. * distributed with this work for additional information
  75505. * regarding copyright ownership. The ASF licenses this file
  75506. * to you under the Apache License, Version 2.0 (the
  75507. * "License"); you may not use this file except in compliance
  75508. * with the License. You may obtain a copy of the License at
  75509. *
  75510. * http://www.apache.org/licenses/LICENSE-2.0
  75511. *
  75512. * Unless required by applicable law or agreed to in writing,
  75513. * software distributed under the License is distributed on an
  75514. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75515. * KIND, either express or implied. See the License for the
  75516. * specific language governing permissions and limitations
  75517. * under the License.
  75518. */
  75519. function getSeriesStackId$1(seriesModel) {
  75520. return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex;
  75521. }
  75522. function getAxisKey$1(polar, axis) {
  75523. return axis.dim + polar.model.componentIndex;
  75524. }
  75525. function barLayoutPolar(seriesType, ecModel, api) {
  75526. var lastStackCoords = {};
  75527. var barWidthAndOffset = calRadialBar(filter(ecModel.getSeriesByType(seriesType), function (seriesModel) {
  75528. return !ecModel.isSeriesFiltered(seriesModel) && seriesModel.coordinateSystem && seriesModel.coordinateSystem.type === 'polar';
  75529. }));
  75530. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  75531. // Check series coordinate, do layout for polar only
  75532. if (seriesModel.coordinateSystem.type !== 'polar') {
  75533. return;
  75534. }
  75535. var data = seriesModel.getData();
  75536. var polar = seriesModel.coordinateSystem;
  75537. var baseAxis = polar.getBaseAxis();
  75538. var axisKey = getAxisKey$1(polar, baseAxis);
  75539. var stackId = getSeriesStackId$1(seriesModel);
  75540. var columnLayoutInfo = barWidthAndOffset[axisKey][stackId];
  75541. var columnOffset = columnLayoutInfo.offset;
  75542. var columnWidth = columnLayoutInfo.width;
  75543. var valueAxis = polar.getOtherAxis(baseAxis);
  75544. var cx = seriesModel.coordinateSystem.cx;
  75545. var cy = seriesModel.coordinateSystem.cy;
  75546. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  75547. var barMinAngle = seriesModel.get('barMinAngle') || 0;
  75548. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  75549. var valueDim = data.mapDimension(valueAxis.dim);
  75550. var baseDim = data.mapDimension(baseAxis.dim);
  75551. var stacked = isDimensionStacked(data, valueDim
  75552. /*, baseDim*/
  75553. );
  75554. var clampLayout = baseAxis.dim !== 'radius' || !seriesModel.get('roundCap', true);
  75555. var valueAxisStart = valueAxis.dataToCoord(0);
  75556. for (var idx = 0, len = data.count(); idx < len; idx++) {
  75557. var value = data.get(valueDim, idx);
  75558. var baseValue = data.get(baseDim, idx);
  75559. var sign = value >= 0 ? 'p' : 'n';
  75560. var baseCoord = valueAxisStart; // Because of the barMinHeight, we can not use the value in
  75561. // stackResultDimension directly.
  75562. // Only ordinal axis can be stacked.
  75563. if (stacked) {
  75564. if (!lastStackCoords[stackId][baseValue]) {
  75565. lastStackCoords[stackId][baseValue] = {
  75566. p: valueAxisStart,
  75567. n: valueAxisStart // Negative stack
  75568. };
  75569. } // Should also consider #4243
  75570. baseCoord = lastStackCoords[stackId][baseValue][sign];
  75571. }
  75572. var r0 = void 0;
  75573. var r = void 0;
  75574. var startAngle = void 0;
  75575. var endAngle = void 0; // radial sector
  75576. if (valueAxis.dim === 'radius') {
  75577. var radiusSpan = valueAxis.dataToCoord(value) - valueAxisStart;
  75578. var angle = baseAxis.dataToCoord(baseValue);
  75579. if (Math.abs(radiusSpan) < barMinHeight) {
  75580. radiusSpan = (radiusSpan < 0 ? -1 : 1) * barMinHeight;
  75581. }
  75582. r0 = baseCoord;
  75583. r = baseCoord + radiusSpan;
  75584. startAngle = angle - columnOffset;
  75585. endAngle = startAngle - columnWidth;
  75586. stacked && (lastStackCoords[stackId][baseValue][sign] = r);
  75587. } // tangential sector
  75588. else {
  75589. var angleSpan = valueAxis.dataToCoord(value, clampLayout) - valueAxisStart;
  75590. var radius = baseAxis.dataToCoord(baseValue);
  75591. if (Math.abs(angleSpan) < barMinAngle) {
  75592. angleSpan = (angleSpan < 0 ? -1 : 1) * barMinAngle;
  75593. }
  75594. r0 = radius + columnOffset;
  75595. r = r0 + columnWidth;
  75596. startAngle = baseCoord;
  75597. endAngle = baseCoord + angleSpan; // if the previous stack is at the end of the ring,
  75598. // add a round to differentiate it from origin
  75599. // let extent = angleAxis.getExtent();
  75600. // let stackCoord = angle;
  75601. // if (stackCoord === extent[0] && value > 0) {
  75602. // stackCoord = extent[1];
  75603. // }
  75604. // else if (stackCoord === extent[1] && value < 0) {
  75605. // stackCoord = extent[0];
  75606. // }
  75607. stacked && (lastStackCoords[stackId][baseValue][sign] = endAngle);
  75608. }
  75609. data.setItemLayout(idx, {
  75610. cx: cx,
  75611. cy: cy,
  75612. r0: r0,
  75613. r: r,
  75614. // Consider that positive angle is anti-clockwise,
  75615. // while positive radian of sector is clockwise
  75616. startAngle: -startAngle * Math.PI / 180,
  75617. endAngle: -endAngle * Math.PI / 180
  75618. });
  75619. }
  75620. });
  75621. }
  75622. /**
  75623. * Calculate bar width and offset for radial bar charts
  75624. */
  75625. function calRadialBar(barSeries) {
  75626. // Columns info on each category axis. Key is polar name
  75627. var columnsMap = {};
  75628. each$1(barSeries, function (seriesModel, idx) {
  75629. var data = seriesModel.getData();
  75630. var polar = seriesModel.coordinateSystem;
  75631. var baseAxis = polar.getBaseAxis();
  75632. var axisKey = getAxisKey$1(polar, baseAxis);
  75633. var axisExtent = baseAxis.getExtent();
  75634. var bandWidth = baseAxis.type === 'category' ? baseAxis.getBandWidth() : Math.abs(axisExtent[1] - axisExtent[0]) / data.count();
  75635. var columnsOnAxis = columnsMap[axisKey] || {
  75636. bandWidth: bandWidth,
  75637. remainedWidth: bandWidth,
  75638. autoWidthCount: 0,
  75639. categoryGap: '20%',
  75640. gap: '30%',
  75641. stacks: {}
  75642. };
  75643. var stacks = columnsOnAxis.stacks;
  75644. columnsMap[axisKey] = columnsOnAxis;
  75645. var stackId = getSeriesStackId$1(seriesModel);
  75646. if (!stacks[stackId]) {
  75647. columnsOnAxis.autoWidthCount++;
  75648. }
  75649. stacks[stackId] = stacks[stackId] || {
  75650. width: 0,
  75651. maxWidth: 0
  75652. };
  75653. var barWidth = parsePercent$1(seriesModel.get('barWidth'), bandWidth);
  75654. var barMaxWidth = parsePercent$1(seriesModel.get('barMaxWidth'), bandWidth);
  75655. var barGap = seriesModel.get('barGap');
  75656. var barCategoryGap = seriesModel.get('barCategoryGap');
  75657. if (barWidth && !stacks[stackId].width) {
  75658. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  75659. stacks[stackId].width = barWidth;
  75660. columnsOnAxis.remainedWidth -= barWidth;
  75661. }
  75662. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  75663. barGap != null && (columnsOnAxis.gap = barGap);
  75664. barCategoryGap != null && (columnsOnAxis.categoryGap = barCategoryGap);
  75665. });
  75666. var result = {};
  75667. each$1(columnsMap, function (columnsOnAxis, coordSysName) {
  75668. result[coordSysName] = {};
  75669. var stacks = columnsOnAxis.stacks;
  75670. var bandWidth = columnsOnAxis.bandWidth;
  75671. var categoryGap = parsePercent$1(columnsOnAxis.categoryGap, bandWidth);
  75672. var barGapPercent = parsePercent$1(columnsOnAxis.gap, 1);
  75673. var remainedWidth = columnsOnAxis.remainedWidth;
  75674. var autoWidthCount = columnsOnAxis.autoWidthCount;
  75675. var autoWidth = (remainedWidth - categoryGap) / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  75676. autoWidth = Math.max(autoWidth, 0); // Find if any auto calculated bar exceeded maxBarWidth
  75677. each$1(stacks, function (column, stack) {
  75678. var maxWidth = column.maxWidth;
  75679. if (maxWidth && maxWidth < autoWidth) {
  75680. maxWidth = Math.min(maxWidth, remainedWidth);
  75681. if (column.width) {
  75682. maxWidth = Math.min(maxWidth, column.width);
  75683. }
  75684. remainedWidth -= maxWidth;
  75685. column.width = maxWidth;
  75686. autoWidthCount--;
  75687. }
  75688. }); // Recalculate width again
  75689. autoWidth = (remainedWidth - categoryGap) / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  75690. autoWidth = Math.max(autoWidth, 0);
  75691. var widthSum = 0;
  75692. var lastColumn;
  75693. each$1(stacks, function (column, idx) {
  75694. if (!column.width) {
  75695. column.width = autoWidth;
  75696. }
  75697. lastColumn = column;
  75698. widthSum += column.width * (1 + barGapPercent);
  75699. });
  75700. if (lastColumn) {
  75701. widthSum -= lastColumn.width * barGapPercent;
  75702. }
  75703. var offset = -widthSum / 2;
  75704. each$1(stacks, function (column, stackId) {
  75705. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  75706. offset: offset,
  75707. width: column.width
  75708. };
  75709. offset += column.width * (1 + barGapPercent);
  75710. });
  75711. });
  75712. return result;
  75713. }
  75714. /*
  75715. * Licensed to the Apache Software Foundation (ASF) under one
  75716. * or more contributor license agreements. See the NOTICE file
  75717. * distributed with this work for additional information
  75718. * regarding copyright ownership. The ASF licenses this file
  75719. * to you under the Apache License, Version 2.0 (the
  75720. * "License"); you may not use this file except in compliance
  75721. * with the License. You may obtain a copy of the License at
  75722. *
  75723. * http://www.apache.org/licenses/LICENSE-2.0
  75724. *
  75725. * Unless required by applicable law or agreed to in writing,
  75726. * software distributed under the License is distributed on an
  75727. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75728. * KIND, either express or implied. See the License for the
  75729. * specific language governing permissions and limitations
  75730. * under the License.
  75731. */
  75732. /**
  75733. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75734. */
  75735. /*
  75736. * Licensed to the Apache Software Foundation (ASF) under one
  75737. * or more contributor license agreements. See the NOTICE file
  75738. * distributed with this work for additional information
  75739. * regarding copyright ownership. The ASF licenses this file
  75740. * to you under the Apache License, Version 2.0 (the
  75741. * "License"); you may not use this file except in compliance
  75742. * with the License. You may obtain a copy of the License at
  75743. *
  75744. * http://www.apache.org/licenses/LICENSE-2.0
  75745. *
  75746. * Unless required by applicable law or agreed to in writing,
  75747. * software distributed under the License is distributed on an
  75748. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75749. * KIND, either express or implied. See the License for the
  75750. * specific language governing permissions and limitations
  75751. * under the License.
  75752. */
  75753. var angleAxisExtraOption = {
  75754. startAngle: 90,
  75755. clockwise: true,
  75756. splitNumber: 12,
  75757. axisLabel: {
  75758. rotate: 0
  75759. }
  75760. };
  75761. var radiusAxisExtraOption = {
  75762. splitNumber: 5
  75763. };
  75764. var PolarView =
  75765. /** @class */
  75766. function (_super) {
  75767. __extends(PolarView, _super);
  75768. function PolarView() {
  75769. var _this = _super !== null && _super.apply(this, arguments) || this;
  75770. _this.type = PolarView.type;
  75771. return _this;
  75772. }
  75773. PolarView.type = 'polar';
  75774. return PolarView;
  75775. }(ComponentView);
  75776. function install$28(registers) {
  75777. use(install$29);
  75778. AxisView.registerAxisPointerClass('PolarAxisPointer', PolarAxisPointer);
  75779. registers.registerCoordinateSystem('polar', polarCreator);
  75780. registers.registerComponentModel(PolarModel);
  75781. registers.registerComponentView(PolarView); // Model and view for angleAxis and radiusAxis
  75782. axisModelCreator(registers, 'angle', AngleAxisModel, angleAxisExtraOption);
  75783. axisModelCreator(registers, 'radius', RadiusAxisModel, radiusAxisExtraOption);
  75784. registers.registerComponentView(AngleAxisView);
  75785. registers.registerComponentView(RadiusAxisView);
  75786. registers.registerLayout(curry(barLayoutPolar, 'bar'));
  75787. }
  75788. /*
  75789. * Licensed to the Apache Software Foundation (ASF) under one
  75790. * or more contributor license agreements. See the NOTICE file
  75791. * distributed with this work for additional information
  75792. * regarding copyright ownership. The ASF licenses this file
  75793. * to you under the Apache License, Version 2.0 (the
  75794. * "License"); you may not use this file except in compliance
  75795. * with the License. You may obtain a copy of the License at
  75796. *
  75797. * http://www.apache.org/licenses/LICENSE-2.0
  75798. *
  75799. * Unless required by applicable law or agreed to in writing,
  75800. * software distributed under the License is distributed on an
  75801. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75802. * KIND, either express or implied. See the License for the
  75803. * specific language governing permissions and limitations
  75804. * under the License.
  75805. */
  75806. /**
  75807. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75808. */
  75809. /*
  75810. * Licensed to the Apache Software Foundation (ASF) under one
  75811. * or more contributor license agreements. See the NOTICE file
  75812. * distributed with this work for additional information
  75813. * regarding copyright ownership. The ASF licenses this file
  75814. * to you under the Apache License, Version 2.0 (the
  75815. * "License"); you may not use this file except in compliance
  75816. * with the License. You may obtain a copy of the License at
  75817. *
  75818. * http://www.apache.org/licenses/LICENSE-2.0
  75819. *
  75820. * Unless required by applicable law or agreed to in writing,
  75821. * software distributed under the License is distributed on an
  75822. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75823. * KIND, either express or implied. See the License for the
  75824. * specific language governing permissions and limitations
  75825. * under the License.
  75826. */
  75827. use(install$28);
  75828. /*
  75829. * Licensed to the Apache Software Foundation (ASF) under one
  75830. * or more contributor license agreements. See the NOTICE file
  75831. * distributed with this work for additional information
  75832. * regarding copyright ownership. The ASF licenses this file
  75833. * to you under the Apache License, Version 2.0 (the
  75834. * "License"); you may not use this file except in compliance
  75835. * with the License. You may obtain a copy of the License at
  75836. *
  75837. * http://www.apache.org/licenses/LICENSE-2.0
  75838. *
  75839. * Unless required by applicable law or agreed to in writing,
  75840. * software distributed under the License is distributed on an
  75841. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75842. * KIND, either express or implied. See the License for the
  75843. * specific language governing permissions and limitations
  75844. * under the License.
  75845. */
  75846. /**
  75847. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75848. */
  75849. /*
  75850. * Licensed to the Apache Software Foundation (ASF) under one
  75851. * or more contributor license agreements. See the NOTICE file
  75852. * distributed with this work for additional information
  75853. * regarding copyright ownership. The ASF licenses this file
  75854. * to you under the Apache License, Version 2.0 (the
  75855. * "License"); you may not use this file except in compliance
  75856. * with the License. You may obtain a copy of the License at
  75857. *
  75858. * http://www.apache.org/licenses/LICENSE-2.0
  75859. *
  75860. * Unless required by applicable law or agreed to in writing,
  75861. * software distributed under the License is distributed on an
  75862. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75863. * KIND, either express or implied. See the License for the
  75864. * specific language governing permissions and limitations
  75865. * under the License.
  75866. */
  75867. use(install$16);
  75868. /*
  75869. * Licensed to the Apache Software Foundation (ASF) under one
  75870. * or more contributor license agreements. See the NOTICE file
  75871. * distributed with this work for additional information
  75872. * regarding copyright ownership. The ASF licenses this file
  75873. * to you under the Apache License, Version 2.0 (the
  75874. * "License"); you may not use this file except in compliance
  75875. * with the License. You may obtain a copy of the License at
  75876. *
  75877. * http://www.apache.org/licenses/LICENSE-2.0
  75878. *
  75879. * Unless required by applicable law or agreed to in writing,
  75880. * software distributed under the License is distributed on an
  75881. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75882. * KIND, either express or implied. See the License for the
  75883. * specific language governing permissions and limitations
  75884. * under the License.
  75885. */
  75886. /**
  75887. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75888. */
  75889. /*
  75890. * Licensed to the Apache Software Foundation (ASF) under one
  75891. * or more contributor license agreements. See the NOTICE file
  75892. * distributed with this work for additional information
  75893. * regarding copyright ownership. The ASF licenses this file
  75894. * to you under the Apache License, Version 2.0 (the
  75895. * "License"); you may not use this file except in compliance
  75896. * with the License. You may obtain a copy of the License at
  75897. *
  75898. * http://www.apache.org/licenses/LICENSE-2.0
  75899. *
  75900. * Unless required by applicable law or agreed to in writing,
  75901. * software distributed under the License is distributed on an
  75902. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75903. * KIND, either express or implied. See the License for the
  75904. * specific language governing permissions and limitations
  75905. * under the License.
  75906. */
  75907. function layout$2(axisModel, opt) {
  75908. opt = opt || {};
  75909. var single = axisModel.coordinateSystem;
  75910. var axis = axisModel.axis;
  75911. var layout = {};
  75912. var axisPosition = axis.position;
  75913. var orient = axis.orient;
  75914. var rect = single.getRect();
  75915. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  75916. var positionMap = {
  75917. horizontal: {
  75918. top: rectBound[2],
  75919. bottom: rectBound[3]
  75920. },
  75921. vertical: {
  75922. left: rectBound[0],
  75923. right: rectBound[1]
  75924. }
  75925. };
  75926. layout.position = [orient === 'vertical' ? positionMap.vertical[axisPosition] : rectBound[0], orient === 'horizontal' ? positionMap.horizontal[axisPosition] : rectBound[3]];
  75927. var r = {
  75928. horizontal: 0,
  75929. vertical: 1
  75930. };
  75931. layout.rotation = Math.PI / 2 * r[orient];
  75932. var directionMap = {
  75933. top: -1,
  75934. bottom: 1,
  75935. right: 1,
  75936. left: -1
  75937. };
  75938. layout.labelDirection = layout.tickDirection = layout.nameDirection = directionMap[axisPosition];
  75939. if (axisModel.get(['axisTick', 'inside'])) {
  75940. layout.tickDirection = -layout.tickDirection;
  75941. }
  75942. if (retrieve(opt.labelInside, axisModel.get(['axisLabel', 'inside']))) {
  75943. layout.labelDirection = -layout.labelDirection;
  75944. }
  75945. var labelRotation = opt.rotate;
  75946. labelRotation == null && (labelRotation = axisModel.get(['axisLabel', 'rotate']));
  75947. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  75948. layout.z2 = 1;
  75949. return layout;
  75950. }
  75951. /*
  75952. * Licensed to the Apache Software Foundation (ASF) under one
  75953. * or more contributor license agreements. See the NOTICE file
  75954. * distributed with this work for additional information
  75955. * regarding copyright ownership. The ASF licenses this file
  75956. * to you under the Apache License, Version 2.0 (the
  75957. * "License"); you may not use this file except in compliance
  75958. * with the License. You may obtain a copy of the License at
  75959. *
  75960. * http://www.apache.org/licenses/LICENSE-2.0
  75961. *
  75962. * Unless required by applicable law or agreed to in writing,
  75963. * software distributed under the License is distributed on an
  75964. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75965. * KIND, either express or implied. See the License for the
  75966. * specific language governing permissions and limitations
  75967. * under the License.
  75968. */
  75969. /**
  75970. * AUTO-GENERATED FILE. DO NOT MODIFY.
  75971. */
  75972. /*
  75973. * Licensed to the Apache Software Foundation (ASF) under one
  75974. * or more contributor license agreements. See the NOTICE file
  75975. * distributed with this work for additional information
  75976. * regarding copyright ownership. The ASF licenses this file
  75977. * to you under the Apache License, Version 2.0 (the
  75978. * "License"); you may not use this file except in compliance
  75979. * with the License. You may obtain a copy of the License at
  75980. *
  75981. * http://www.apache.org/licenses/LICENSE-2.0
  75982. *
  75983. * Unless required by applicable law or agreed to in writing,
  75984. * software distributed under the License is distributed on an
  75985. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  75986. * KIND, either express or implied. See the License for the
  75987. * specific language governing permissions and limitations
  75988. * under the License.
  75989. */
  75990. var axisBuilderAttrs$3 = ['axisLine', 'axisTickLabel', 'axisName'];
  75991. var selfBuilderAttrs$2 = ['splitArea', 'splitLine'];
  75992. var SingleAxisView =
  75993. /** @class */
  75994. function (_super) {
  75995. __extends(SingleAxisView, _super);
  75996. function SingleAxisView() {
  75997. var _this = _super !== null && _super.apply(this, arguments) || this;
  75998. _this.type = SingleAxisView.type;
  75999. _this.axisPointerClass = 'SingleAxisPointer';
  76000. return _this;
  76001. }
  76002. SingleAxisView.prototype.render = function (axisModel, ecModel, api, payload) {
  76003. var group = this.group;
  76004. group.removeAll();
  76005. var oldAxisGroup = this._axisGroup;
  76006. this._axisGroup = new Group();
  76007. var layout = layout$2(axisModel);
  76008. var axisBuilder = new AxisBuilder(axisModel, layout);
  76009. each$1(axisBuilderAttrs$3, axisBuilder.add, axisBuilder);
  76010. group.add(this._axisGroup);
  76011. group.add(axisBuilder.getGroup());
  76012. each$1(selfBuilderAttrs$2, function (name) {
  76013. if (axisModel.get([name, 'show'])) {
  76014. axisElementBuilders$2[name](this, this.group, this._axisGroup, axisModel);
  76015. }
  76016. }, this);
  76017. groupTransition(oldAxisGroup, this._axisGroup, axisModel);
  76018. _super.prototype.render.call(this, axisModel, ecModel, api, payload);
  76019. };
  76020. SingleAxisView.prototype.remove = function () {
  76021. rectCoordAxisHandleRemove(this);
  76022. };
  76023. SingleAxisView.type = 'singleAxis';
  76024. return SingleAxisView;
  76025. }(AxisView);
  76026. var axisElementBuilders$2 = {
  76027. splitLine: function (axisView, group, axisGroup, axisModel) {
  76028. var axis = axisModel.axis;
  76029. if (axis.scale.isBlank()) {
  76030. return;
  76031. }
  76032. var splitLineModel = axisModel.getModel('splitLine');
  76033. var lineStyleModel = splitLineModel.getModel('lineStyle');
  76034. var lineColors = lineStyleModel.get('color');
  76035. lineColors = lineColors instanceof Array ? lineColors : [lineColors];
  76036. var gridRect = axisModel.coordinateSystem.getRect();
  76037. var isHorizontal = axis.isHorizontal();
  76038. var splitLines = [];
  76039. var lineCount = 0;
  76040. var ticksCoords = axis.getTicksCoords({
  76041. tickModel: splitLineModel
  76042. });
  76043. var p1 = [];
  76044. var p2 = [];
  76045. for (var i = 0; i < ticksCoords.length; ++i) {
  76046. var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);
  76047. if (isHorizontal) {
  76048. p1[0] = tickCoord;
  76049. p1[1] = gridRect.y;
  76050. p2[0] = tickCoord;
  76051. p2[1] = gridRect.y + gridRect.height;
  76052. } else {
  76053. p1[0] = gridRect.x;
  76054. p1[1] = tickCoord;
  76055. p2[0] = gridRect.x + gridRect.width;
  76056. p2[1] = tickCoord;
  76057. }
  76058. var colorIndex = lineCount++ % lineColors.length;
  76059. splitLines[colorIndex] = splitLines[colorIndex] || [];
  76060. splitLines[colorIndex].push(new Line({
  76061. subPixelOptimize: true,
  76062. shape: {
  76063. x1: p1[0],
  76064. y1: p1[1],
  76065. x2: p2[0],
  76066. y2: p2[1]
  76067. },
  76068. silent: true
  76069. }));
  76070. }
  76071. var lineStyle = lineStyleModel.getLineStyle(['color']);
  76072. for (var i = 0; i < splitLines.length; ++i) {
  76073. group.add(mergePath(splitLines[i], {
  76074. style: defaults({
  76075. stroke: lineColors[i % lineColors.length]
  76076. }, lineStyle),
  76077. silent: true
  76078. }));
  76079. }
  76080. },
  76081. splitArea: function (axisView, group, axisGroup, axisModel) {
  76082. rectCoordAxisBuildSplitArea(axisView, axisGroup, axisModel, axisModel);
  76083. }
  76084. };
  76085. /*
  76086. * Licensed to the Apache Software Foundation (ASF) under one
  76087. * or more contributor license agreements. See the NOTICE file
  76088. * distributed with this work for additional information
  76089. * regarding copyright ownership. The ASF licenses this file
  76090. * to you under the Apache License, Version 2.0 (the
  76091. * "License"); you may not use this file except in compliance
  76092. * with the License. You may obtain a copy of the License at
  76093. *
  76094. * http://www.apache.org/licenses/LICENSE-2.0
  76095. *
  76096. * Unless required by applicable law or agreed to in writing,
  76097. * software distributed under the License is distributed on an
  76098. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76099. * KIND, either express or implied. See the License for the
  76100. * specific language governing permissions and limitations
  76101. * under the License.
  76102. */
  76103. /**
  76104. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76105. */
  76106. /*
  76107. * Licensed to the Apache Software Foundation (ASF) under one
  76108. * or more contributor license agreements. See the NOTICE file
  76109. * distributed with this work for additional information
  76110. * regarding copyright ownership. The ASF licenses this file
  76111. * to you under the Apache License, Version 2.0 (the
  76112. * "License"); you may not use this file except in compliance
  76113. * with the License. You may obtain a copy of the License at
  76114. *
  76115. * http://www.apache.org/licenses/LICENSE-2.0
  76116. *
  76117. * Unless required by applicable law or agreed to in writing,
  76118. * software distributed under the License is distributed on an
  76119. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76120. * KIND, either express or implied. See the License for the
  76121. * specific language governing permissions and limitations
  76122. * under the License.
  76123. */
  76124. var SingleAxisModel =
  76125. /** @class */
  76126. function (_super) {
  76127. __extends(SingleAxisModel, _super);
  76128. function SingleAxisModel() {
  76129. var _this = _super !== null && _super.apply(this, arguments) || this;
  76130. _this.type = SingleAxisModel.type;
  76131. return _this;
  76132. }
  76133. SingleAxisModel.prototype.getCoordSysModel = function () {
  76134. return this;
  76135. };
  76136. SingleAxisModel.type = 'singleAxis';
  76137. SingleAxisModel.layoutMode = 'box';
  76138. SingleAxisModel.defaultOption = {
  76139. left: '5%',
  76140. top: '5%',
  76141. right: '5%',
  76142. bottom: '5%',
  76143. type: 'value',
  76144. position: 'bottom',
  76145. orient: 'horizontal',
  76146. axisLine: {
  76147. show: true,
  76148. lineStyle: {
  76149. width: 1,
  76150. type: 'solid'
  76151. }
  76152. },
  76153. // Single coordinate system and single axis is the,
  76154. // which is used as the parent tooltip model.
  76155. // same model, so we set default tooltip show as true.
  76156. tooltip: {
  76157. show: true
  76158. },
  76159. axisTick: {
  76160. show: true,
  76161. length: 6,
  76162. lineStyle: {
  76163. width: 1
  76164. }
  76165. },
  76166. axisLabel: {
  76167. show: true,
  76168. interval: 'auto'
  76169. },
  76170. splitLine: {
  76171. show: true,
  76172. lineStyle: {
  76173. type: 'dashed',
  76174. opacity: 0.2
  76175. }
  76176. }
  76177. };
  76178. return SingleAxisModel;
  76179. }(ComponentModel);
  76180. mixin(SingleAxisModel, AxisModelCommonMixin.prototype);
  76181. /*
  76182. * Licensed to the Apache Software Foundation (ASF) under one
  76183. * or more contributor license agreements. See the NOTICE file
  76184. * distributed with this work for additional information
  76185. * regarding copyright ownership. The ASF licenses this file
  76186. * to you under the Apache License, Version 2.0 (the
  76187. * "License"); you may not use this file except in compliance
  76188. * with the License. You may obtain a copy of the License at
  76189. *
  76190. * http://www.apache.org/licenses/LICENSE-2.0
  76191. *
  76192. * Unless required by applicable law or agreed to in writing,
  76193. * software distributed under the License is distributed on an
  76194. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76195. * KIND, either express or implied. See the License for the
  76196. * specific language governing permissions and limitations
  76197. * under the License.
  76198. */
  76199. /**
  76200. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76201. */
  76202. /*
  76203. * Licensed to the Apache Software Foundation (ASF) under one
  76204. * or more contributor license agreements. See the NOTICE file
  76205. * distributed with this work for additional information
  76206. * regarding copyright ownership. The ASF licenses this file
  76207. * to you under the Apache License, Version 2.0 (the
  76208. * "License"); you may not use this file except in compliance
  76209. * with the License. You may obtain a copy of the License at
  76210. *
  76211. * http://www.apache.org/licenses/LICENSE-2.0
  76212. *
  76213. * Unless required by applicable law or agreed to in writing,
  76214. * software distributed under the License is distributed on an
  76215. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76216. * KIND, either express or implied. See the License for the
  76217. * specific language governing permissions and limitations
  76218. * under the License.
  76219. */
  76220. var SingleAxis =
  76221. /** @class */
  76222. function (_super) {
  76223. __extends(SingleAxis, _super);
  76224. function SingleAxis(dim, scale, coordExtent, axisType, position) {
  76225. var _this = _super.call(this, dim, scale, coordExtent) || this;
  76226. _this.type = axisType || 'value';
  76227. _this.position = position || 'bottom';
  76228. return _this;
  76229. }
  76230. /**
  76231. * Judge the orient of the axis.
  76232. */
  76233. SingleAxis.prototype.isHorizontal = function () {
  76234. var position = this.position;
  76235. return position === 'top' || position === 'bottom';
  76236. };
  76237. SingleAxis.prototype.pointToData = function (point, clamp) {
  76238. return this.coordinateSystem.pointToData(point)[0];
  76239. };
  76240. return SingleAxis;
  76241. }(Axis);
  76242. /*
  76243. * Licensed to the Apache Software Foundation (ASF) under one
  76244. * or more contributor license agreements. See the NOTICE file
  76245. * distributed with this work for additional information
  76246. * regarding copyright ownership. The ASF licenses this file
  76247. * to you under the Apache License, Version 2.0 (the
  76248. * "License"); you may not use this file except in compliance
  76249. * with the License. You may obtain a copy of the License at
  76250. *
  76251. * http://www.apache.org/licenses/LICENSE-2.0
  76252. *
  76253. * Unless required by applicable law or agreed to in writing,
  76254. * software distributed under the License is distributed on an
  76255. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76256. * KIND, either express or implied. See the License for the
  76257. * specific language governing permissions and limitations
  76258. * under the License.
  76259. */
  76260. /**
  76261. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76262. */
  76263. /*
  76264. * Licensed to the Apache Software Foundation (ASF) under one
  76265. * or more contributor license agreements. See the NOTICE file
  76266. * distributed with this work for additional information
  76267. * regarding copyright ownership. The ASF licenses this file
  76268. * to you under the Apache License, Version 2.0 (the
  76269. * "License"); you may not use this file except in compliance
  76270. * with the License. You may obtain a copy of the License at
  76271. *
  76272. * http://www.apache.org/licenses/LICENSE-2.0
  76273. *
  76274. * Unless required by applicable law or agreed to in writing,
  76275. * software distributed under the License is distributed on an
  76276. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76277. * KIND, either express or implied. See the License for the
  76278. * specific language governing permissions and limitations
  76279. * under the License.
  76280. */
  76281. /**
  76282. * Single coordinates system.
  76283. */
  76284. /**
  76285. * Create a single coordinates system.
  76286. */
  76287. var Single =
  76288. /** @class */
  76289. function () {
  76290. function Single(axisModel, ecModel, api) {
  76291. this.type = 'single';
  76292. this.dimension = 'single';
  76293. /**
  76294. * Add it just for draw tooltip.
  76295. */
  76296. this.dimensions = ['single'];
  76297. this.axisPointerEnabled = true;
  76298. this.model = axisModel;
  76299. this._init(axisModel, ecModel, api);
  76300. }
  76301. /**
  76302. * Initialize single coordinate system.
  76303. */
  76304. Single.prototype._init = function (axisModel, ecModel, api) {
  76305. var dim = this.dimension;
  76306. var axis = new SingleAxis(dim, createScaleByModel(axisModel), [0, 0], axisModel.get('type'), axisModel.get('position'));
  76307. var isCategory = axis.type === 'category';
  76308. axis.onBand = isCategory && axisModel.get('boundaryGap');
  76309. axis.inverse = axisModel.get('inverse');
  76310. axis.orient = axisModel.get('orient');
  76311. axisModel.axis = axis;
  76312. axis.model = axisModel;
  76313. axis.coordinateSystem = this;
  76314. this._axis = axis;
  76315. };
  76316. /**
  76317. * Update axis scale after data processed
  76318. */
  76319. Single.prototype.update = function (ecModel, api) {
  76320. ecModel.eachSeries(function (seriesModel) {
  76321. if (seriesModel.coordinateSystem === this) {
  76322. var data_1 = seriesModel.getData();
  76323. each$1(data_1.mapDimensionsAll(this.dimension), function (dim) {
  76324. this._axis.scale.unionExtentFromData(data_1, dim);
  76325. }, this);
  76326. niceScaleExtent(this._axis.scale, this._axis.model);
  76327. }
  76328. }, this);
  76329. };
  76330. /**
  76331. * Resize the single coordinate system.
  76332. */
  76333. Single.prototype.resize = function (axisModel, api) {
  76334. this._rect = getLayoutRect({
  76335. left: axisModel.get('left'),
  76336. top: axisModel.get('top'),
  76337. right: axisModel.get('right'),
  76338. bottom: axisModel.get('bottom'),
  76339. width: axisModel.get('width'),
  76340. height: axisModel.get('height')
  76341. }, {
  76342. width: api.getWidth(),
  76343. height: api.getHeight()
  76344. });
  76345. this._adjustAxis();
  76346. };
  76347. Single.prototype.getRect = function () {
  76348. return this._rect;
  76349. };
  76350. Single.prototype._adjustAxis = function () {
  76351. var rect = this._rect;
  76352. var axis = this._axis;
  76353. var isHorizontal = axis.isHorizontal();
  76354. var extent = isHorizontal ? [0, rect.width] : [0, rect.height];
  76355. var idx = axis.reverse ? 1 : 0;
  76356. axis.setExtent(extent[idx], extent[1 - idx]);
  76357. this._updateAxisTransform(axis, isHorizontal ? rect.x : rect.y);
  76358. };
  76359. Single.prototype._updateAxisTransform = function (axis, coordBase) {
  76360. var axisExtent = axis.getExtent();
  76361. var extentSum = axisExtent[0] + axisExtent[1];
  76362. var isHorizontal = axis.isHorizontal();
  76363. axis.toGlobalCoord = isHorizontal ? function (coord) {
  76364. return coord + coordBase;
  76365. } : function (coord) {
  76366. return extentSum - coord + coordBase;
  76367. };
  76368. axis.toLocalCoord = isHorizontal ? function (coord) {
  76369. return coord - coordBase;
  76370. } : function (coord) {
  76371. return extentSum - coord + coordBase;
  76372. };
  76373. };
  76374. /**
  76375. * Get axis.
  76376. */
  76377. Single.prototype.getAxis = function () {
  76378. return this._axis;
  76379. };
  76380. /**
  76381. * Get axis, add it just for draw tooltip.
  76382. */
  76383. Single.prototype.getBaseAxis = function () {
  76384. return this._axis;
  76385. };
  76386. Single.prototype.getAxes = function () {
  76387. return [this._axis];
  76388. };
  76389. Single.prototype.getTooltipAxes = function () {
  76390. return {
  76391. baseAxes: [this.getAxis()],
  76392. // Empty otherAxes
  76393. otherAxes: []
  76394. };
  76395. };
  76396. /**
  76397. * If contain point.
  76398. */
  76399. Single.prototype.containPoint = function (point) {
  76400. var rect = this.getRect();
  76401. var axis = this.getAxis();
  76402. var orient = axis.orient;
  76403. if (orient === 'horizontal') {
  76404. return axis.contain(axis.toLocalCoord(point[0])) && point[1] >= rect.y && point[1] <= rect.y + rect.height;
  76405. } else {
  76406. return axis.contain(axis.toLocalCoord(point[1])) && point[0] >= rect.y && point[0] <= rect.y + rect.height;
  76407. }
  76408. };
  76409. Single.prototype.pointToData = function (point) {
  76410. var axis = this.getAxis();
  76411. return [axis.coordToData(axis.toLocalCoord(point[axis.orient === 'horizontal' ? 0 : 1]))];
  76412. };
  76413. /**
  76414. * Convert the series data to concrete point.
  76415. * Can be [val] | val
  76416. */
  76417. Single.prototype.dataToPoint = function (val) {
  76418. var axis = this.getAxis();
  76419. var rect = this.getRect();
  76420. var pt = [];
  76421. var idx = axis.orient === 'horizontal' ? 0 : 1;
  76422. if (val instanceof Array) {
  76423. val = val[0];
  76424. }
  76425. pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
  76426. pt[1 - idx] = idx === 0 ? rect.y + rect.height / 2 : rect.x + rect.width / 2;
  76427. return pt;
  76428. };
  76429. Single.prototype.convertToPixel = function (ecModel, finder, value) {
  76430. var coordSys = getCoordSys$3(finder);
  76431. return coordSys === this ? this.dataToPoint(value) : null;
  76432. };
  76433. Single.prototype.convertFromPixel = function (ecModel, finder, pixel) {
  76434. var coordSys = getCoordSys$3(finder);
  76435. return coordSys === this ? this.pointToData(pixel) : null;
  76436. };
  76437. return Single;
  76438. }();
  76439. function getCoordSys$3(finder) {
  76440. var seriesModel = finder.seriesModel;
  76441. var singleModel = finder.singleAxisModel;
  76442. return singleModel && singleModel.coordinateSystem || seriesModel && seriesModel.coordinateSystem;
  76443. }
  76444. /*
  76445. * Licensed to the Apache Software Foundation (ASF) under one
  76446. * or more contributor license agreements. See the NOTICE file
  76447. * distributed with this work for additional information
  76448. * regarding copyright ownership. The ASF licenses this file
  76449. * to you under the Apache License, Version 2.0 (the
  76450. * "License"); you may not use this file except in compliance
  76451. * with the License. You may obtain a copy of the License at
  76452. *
  76453. * http://www.apache.org/licenses/LICENSE-2.0
  76454. *
  76455. * Unless required by applicable law or agreed to in writing,
  76456. * software distributed under the License is distributed on an
  76457. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76458. * KIND, either express or implied. See the License for the
  76459. * specific language governing permissions and limitations
  76460. * under the License.
  76461. */
  76462. /**
  76463. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76464. */
  76465. /*
  76466. * Licensed to the Apache Software Foundation (ASF) under one
  76467. * or more contributor license agreements. See the NOTICE file
  76468. * distributed with this work for additional information
  76469. * regarding copyright ownership. The ASF licenses this file
  76470. * to you under the Apache License, Version 2.0 (the
  76471. * "License"); you may not use this file except in compliance
  76472. * with the License. You may obtain a copy of the License at
  76473. *
  76474. * http://www.apache.org/licenses/LICENSE-2.0
  76475. *
  76476. * Unless required by applicable law or agreed to in writing,
  76477. * software distributed under the License is distributed on an
  76478. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76479. * KIND, either express or implied. See the License for the
  76480. * specific language governing permissions and limitations
  76481. * under the License.
  76482. */
  76483. /**
  76484. * Single coordinate system creator.
  76485. */
  76486. /**
  76487. * Create single coordinate system and inject it into seriesModel.
  76488. */
  76489. function create$2(ecModel, api) {
  76490. var singles = [];
  76491. ecModel.eachComponent('singleAxis', function (axisModel, idx) {
  76492. var single = new Single(axisModel, ecModel, api);
  76493. single.name = 'single_' + idx;
  76494. single.resize(axisModel, api);
  76495. axisModel.coordinateSystem = single;
  76496. singles.push(single);
  76497. });
  76498. ecModel.eachSeries(function (seriesModel) {
  76499. if (seriesModel.get('coordinateSystem') === 'singleAxis') {
  76500. var singleAxisModel = seriesModel.getReferringComponents('singleAxis', SINGLE_REFERRING).models[0];
  76501. seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
  76502. }
  76503. });
  76504. return singles;
  76505. }
  76506. var singleCreator = {
  76507. create: create$2,
  76508. dimensions: Single.prototype.dimensions
  76509. };
  76510. /*
  76511. * Licensed to the Apache Software Foundation (ASF) under one
  76512. * or more contributor license agreements. See the NOTICE file
  76513. * distributed with this work for additional information
  76514. * regarding copyright ownership. The ASF licenses this file
  76515. * to you under the Apache License, Version 2.0 (the
  76516. * "License"); you may not use this file except in compliance
  76517. * with the License. You may obtain a copy of the License at
  76518. *
  76519. * http://www.apache.org/licenses/LICENSE-2.0
  76520. *
  76521. * Unless required by applicable law or agreed to in writing,
  76522. * software distributed under the License is distributed on an
  76523. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76524. * KIND, either express or implied. See the License for the
  76525. * specific language governing permissions and limitations
  76526. * under the License.
  76527. */
  76528. /**
  76529. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76530. */
  76531. /*
  76532. * Licensed to the Apache Software Foundation (ASF) under one
  76533. * or more contributor license agreements. See the NOTICE file
  76534. * distributed with this work for additional information
  76535. * regarding copyright ownership. The ASF licenses this file
  76536. * to you under the Apache License, Version 2.0 (the
  76537. * "License"); you may not use this file except in compliance
  76538. * with the License. You may obtain a copy of the License at
  76539. *
  76540. * http://www.apache.org/licenses/LICENSE-2.0
  76541. *
  76542. * Unless required by applicable law or agreed to in writing,
  76543. * software distributed under the License is distributed on an
  76544. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76545. * KIND, either express or implied. See the License for the
  76546. * specific language governing permissions and limitations
  76547. * under the License.
  76548. */
  76549. var XY = ['x', 'y'];
  76550. var WH = ['width', 'height'];
  76551. var SingleAxisPointer =
  76552. /** @class */
  76553. function (_super) {
  76554. __extends(SingleAxisPointer, _super);
  76555. function SingleAxisPointer() {
  76556. return _super !== null && _super.apply(this, arguments) || this;
  76557. }
  76558. /**
  76559. * @override
  76560. */
  76561. SingleAxisPointer.prototype.makeElOption = function (elOption, value, axisModel, axisPointerModel, api) {
  76562. var axis = axisModel.axis;
  76563. var coordSys = axis.coordinateSystem;
  76564. var otherExtent = getGlobalExtent(coordSys, 1 - getPointDimIndex(axis));
  76565. var pixelValue = coordSys.dataToPoint(value)[0];
  76566. var axisPointerType = axisPointerModel.get('type');
  76567. if (axisPointerType && axisPointerType !== 'none') {
  76568. var elStyle = buildElStyle(axisPointerModel);
  76569. var pointerOption = pointerShapeBuilder$2[axisPointerType](axis, pixelValue, otherExtent);
  76570. pointerOption.style = elStyle;
  76571. elOption.graphicKey = pointerOption.type;
  76572. elOption.pointer = pointerOption;
  76573. }
  76574. var layoutInfo = layout$2(axisModel);
  76575. buildCartesianSingleLabelElOption( // @ts-ignore
  76576. value, elOption, layoutInfo, axisModel, axisPointerModel, api);
  76577. };
  76578. /**
  76579. * @override
  76580. */
  76581. SingleAxisPointer.prototype.getHandleTransform = function (value, axisModel, axisPointerModel) {
  76582. var layoutInfo = layout$2(axisModel, {
  76583. labelInside: false
  76584. }); // @ts-ignore
  76585. layoutInfo.labelMargin = axisPointerModel.get(['handle', 'margin']);
  76586. var position = getTransformedPosition(axisModel.axis, value, layoutInfo);
  76587. return {
  76588. x: position[0],
  76589. y: position[1],
  76590. rotation: layoutInfo.rotation + (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  76591. };
  76592. };
  76593. /**
  76594. * @override
  76595. */
  76596. SingleAxisPointer.prototype.updateHandleTransform = function (transform, delta, axisModel, axisPointerModel) {
  76597. var axis = axisModel.axis;
  76598. var coordSys = axis.coordinateSystem;
  76599. var dimIndex = getPointDimIndex(axis);
  76600. var axisExtent = getGlobalExtent(coordSys, dimIndex);
  76601. var currPosition = [transform.x, transform.y];
  76602. currPosition[dimIndex] += delta[dimIndex];
  76603. currPosition[dimIndex] = Math.min(axisExtent[1], currPosition[dimIndex]);
  76604. currPosition[dimIndex] = Math.max(axisExtent[0], currPosition[dimIndex]);
  76605. var otherExtent = getGlobalExtent(coordSys, 1 - dimIndex);
  76606. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2;
  76607. var cursorPoint = [cursorOtherValue, cursorOtherValue];
  76608. cursorPoint[dimIndex] = currPosition[dimIndex];
  76609. return {
  76610. x: currPosition[0],
  76611. y: currPosition[1],
  76612. rotation: transform.rotation,
  76613. cursorPoint: cursorPoint,
  76614. tooltipOption: {
  76615. verticalAlign: 'middle'
  76616. }
  76617. };
  76618. };
  76619. return SingleAxisPointer;
  76620. }(BaseAxisPointer);
  76621. var pointerShapeBuilder$2 = {
  76622. line: function (axis, pixelValue, otherExtent) {
  76623. var targetShape = makeLineShape([pixelValue, otherExtent[0]], [pixelValue, otherExtent[1]], getPointDimIndex(axis));
  76624. return {
  76625. type: 'Line',
  76626. subPixelOptimize: true,
  76627. shape: targetShape
  76628. };
  76629. },
  76630. shadow: function (axis, pixelValue, otherExtent) {
  76631. var bandWidth = axis.getBandWidth();
  76632. var span = otherExtent[1] - otherExtent[0];
  76633. return {
  76634. type: 'Rect',
  76635. shape: makeRectShape([pixelValue - bandWidth / 2, otherExtent[0]], [bandWidth, span], getPointDimIndex(axis))
  76636. };
  76637. }
  76638. };
  76639. function getPointDimIndex(axis) {
  76640. return axis.isHorizontal() ? 0 : 1;
  76641. }
  76642. function getGlobalExtent(coordSys, dimIndex) {
  76643. var rect = coordSys.getRect();
  76644. return [rect[XY[dimIndex]], rect[XY[dimIndex]] + rect[WH[dimIndex]]];
  76645. }
  76646. /*
  76647. * Licensed to the Apache Software Foundation (ASF) under one
  76648. * or more contributor license agreements. See the NOTICE file
  76649. * distributed with this work for additional information
  76650. * regarding copyright ownership. The ASF licenses this file
  76651. * to you under the Apache License, Version 2.0 (the
  76652. * "License"); you may not use this file except in compliance
  76653. * with the License. You may obtain a copy of the License at
  76654. *
  76655. * http://www.apache.org/licenses/LICENSE-2.0
  76656. *
  76657. * Unless required by applicable law or agreed to in writing,
  76658. * software distributed under the License is distributed on an
  76659. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76660. * KIND, either express or implied. See the License for the
  76661. * specific language governing permissions and limitations
  76662. * under the License.
  76663. */
  76664. /**
  76665. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76666. */
  76667. /*
  76668. * Licensed to the Apache Software Foundation (ASF) under one
  76669. * or more contributor license agreements. See the NOTICE file
  76670. * distributed with this work for additional information
  76671. * regarding copyright ownership. The ASF licenses this file
  76672. * to you under the Apache License, Version 2.0 (the
  76673. * "License"); you may not use this file except in compliance
  76674. * with the License. You may obtain a copy of the License at
  76675. *
  76676. * http://www.apache.org/licenses/LICENSE-2.0
  76677. *
  76678. * Unless required by applicable law or agreed to in writing,
  76679. * software distributed under the License is distributed on an
  76680. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76681. * KIND, either express or implied. See the License for the
  76682. * specific language governing permissions and limitations
  76683. * under the License.
  76684. */
  76685. var SingleView =
  76686. /** @class */
  76687. function (_super) {
  76688. __extends(SingleView, _super);
  76689. function SingleView() {
  76690. var _this = _super !== null && _super.apply(this, arguments) || this;
  76691. _this.type = SingleView.type;
  76692. return _this;
  76693. }
  76694. SingleView.type = 'single';
  76695. return SingleView;
  76696. }(ComponentView);
  76697. function install$30(registers) {
  76698. use(install$29);
  76699. AxisView.registerAxisPointerClass('SingleAxisPointer', SingleAxisPointer);
  76700. registers.registerComponentView(SingleView); // Axis
  76701. registers.registerComponentView(SingleAxisView);
  76702. registers.registerComponentModel(SingleAxisModel);
  76703. axisModelCreator(registers, 'single', SingleAxisModel, SingleAxisModel.defaultOption);
  76704. registers.registerCoordinateSystem('single', singleCreator);
  76705. }
  76706. /*
  76707. * Licensed to the Apache Software Foundation (ASF) under one
  76708. * or more contributor license agreements. See the NOTICE file
  76709. * distributed with this work for additional information
  76710. * regarding copyright ownership. The ASF licenses this file
  76711. * to you under the Apache License, Version 2.0 (the
  76712. * "License"); you may not use this file except in compliance
  76713. * with the License. You may obtain a copy of the License at
  76714. *
  76715. * http://www.apache.org/licenses/LICENSE-2.0
  76716. *
  76717. * Unless required by applicable law or agreed to in writing,
  76718. * software distributed under the License is distributed on an
  76719. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76720. * KIND, either express or implied. See the License for the
  76721. * specific language governing permissions and limitations
  76722. * under the License.
  76723. */
  76724. /**
  76725. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76726. */
  76727. /*
  76728. * Licensed to the Apache Software Foundation (ASF) under one
  76729. * or more contributor license agreements. See the NOTICE file
  76730. * distributed with this work for additional information
  76731. * regarding copyright ownership. The ASF licenses this file
  76732. * to you under the Apache License, Version 2.0 (the
  76733. * "License"); you may not use this file except in compliance
  76734. * with the License. You may obtain a copy of the License at
  76735. *
  76736. * http://www.apache.org/licenses/LICENSE-2.0
  76737. *
  76738. * Unless required by applicable law or agreed to in writing,
  76739. * software distributed under the License is distributed on an
  76740. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76741. * KIND, either express or implied. See the License for the
  76742. * specific language governing permissions and limitations
  76743. * under the License.
  76744. */
  76745. use(install$30);
  76746. /*
  76747. * Licensed to the Apache Software Foundation (ASF) under one
  76748. * or more contributor license agreements. See the NOTICE file
  76749. * distributed with this work for additional information
  76750. * regarding copyright ownership. The ASF licenses this file
  76751. * to you under the Apache License, Version 2.0 (the
  76752. * "License"); you may not use this file except in compliance
  76753. * with the License. You may obtain a copy of the License at
  76754. *
  76755. * http://www.apache.org/licenses/LICENSE-2.0
  76756. *
  76757. * Unless required by applicable law or agreed to in writing,
  76758. * software distributed under the License is distributed on an
  76759. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76760. * KIND, either express or implied. See the License for the
  76761. * specific language governing permissions and limitations
  76762. * under the License.
  76763. */
  76764. /**
  76765. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76766. */
  76767. /*
  76768. * Licensed to the Apache Software Foundation (ASF) under one
  76769. * or more contributor license agreements. See the NOTICE file
  76770. * distributed with this work for additional information
  76771. * regarding copyright ownership. The ASF licenses this file
  76772. * to you under the Apache License, Version 2.0 (the
  76773. * "License"); you may not use this file except in compliance
  76774. * with the License. You may obtain a copy of the License at
  76775. *
  76776. * http://www.apache.org/licenses/LICENSE-2.0
  76777. *
  76778. * Unless required by applicable law or agreed to in writing,
  76779. * software distributed under the License is distributed on an
  76780. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76781. * KIND, either express or implied. See the License for the
  76782. * specific language governing permissions and limitations
  76783. * under the License.
  76784. */
  76785. var CalendarModel =
  76786. /** @class */
  76787. function (_super) {
  76788. __extends(CalendarModel, _super);
  76789. function CalendarModel() {
  76790. var _this = _super !== null && _super.apply(this, arguments) || this;
  76791. _this.type = CalendarModel.type;
  76792. return _this;
  76793. }
  76794. /**
  76795. * @override
  76796. */
  76797. CalendarModel.prototype.init = function (option, parentModel, ecModel) {
  76798. var inputPositionParams = getLayoutParams(option);
  76799. _super.prototype.init.apply(this, arguments);
  76800. mergeAndNormalizeLayoutParams(option, inputPositionParams);
  76801. };
  76802. /**
  76803. * @override
  76804. */
  76805. CalendarModel.prototype.mergeOption = function (option) {
  76806. _super.prototype.mergeOption.apply(this, arguments);
  76807. mergeAndNormalizeLayoutParams(this.option, option);
  76808. };
  76809. CalendarModel.prototype.getCellSize = function () {
  76810. // Has been normalized
  76811. return this.option.cellSize;
  76812. };
  76813. CalendarModel.type = 'calendar';
  76814. CalendarModel.defaultOption = {
  76815. zlevel: 0,
  76816. z: 2,
  76817. left: 80,
  76818. top: 60,
  76819. cellSize: 20,
  76820. // horizontal vertical
  76821. orient: 'horizontal',
  76822. // month separate line style
  76823. splitLine: {
  76824. show: true,
  76825. lineStyle: {
  76826. color: '#000',
  76827. width: 1,
  76828. type: 'solid'
  76829. }
  76830. },
  76831. // rect style temporarily unused emphasis
  76832. itemStyle: {
  76833. color: '#fff',
  76834. borderWidth: 1,
  76835. borderColor: '#ccc'
  76836. },
  76837. // week text style
  76838. dayLabel: {
  76839. show: true,
  76840. firstDay: 0,
  76841. // start end
  76842. position: 'start',
  76843. margin: '50%',
  76844. nameMap: 'en',
  76845. color: '#000'
  76846. },
  76847. // month text style
  76848. monthLabel: {
  76849. show: true,
  76850. // start end
  76851. position: 'start',
  76852. margin: 5,
  76853. // center or left
  76854. align: 'center',
  76855. // cn en []
  76856. nameMap: 'en',
  76857. formatter: null,
  76858. color: '#000'
  76859. },
  76860. // year text style
  76861. yearLabel: {
  76862. show: true,
  76863. // top bottom left right
  76864. position: null,
  76865. margin: 30,
  76866. formatter: null,
  76867. color: '#ccc',
  76868. fontFamily: 'sans-serif',
  76869. fontWeight: 'bolder',
  76870. fontSize: 20
  76871. }
  76872. };
  76873. return CalendarModel;
  76874. }(ComponentModel);
  76875. function mergeAndNormalizeLayoutParams(target, raw) {
  76876. // Normalize cellSize
  76877. var cellSize = target.cellSize;
  76878. var cellSizeArr;
  76879. if (!isArray(cellSize)) {
  76880. cellSizeArr = target.cellSize = [cellSize, cellSize];
  76881. } else {
  76882. cellSizeArr = cellSize;
  76883. }
  76884. if (cellSizeArr.length === 1) {
  76885. cellSizeArr[1] = cellSizeArr[0];
  76886. }
  76887. var ignoreSize = map([0, 1], function (hvIdx) {
  76888. // If user have set `width` or both `left` and `right`, cellSizeArr
  76889. // will be automatically set to 'auto', otherwise the default
  76890. // setting of cellSizeArr will make `width` setting not work.
  76891. if (sizeCalculable(raw, hvIdx)) {
  76892. cellSizeArr[hvIdx] = 'auto';
  76893. }
  76894. return cellSizeArr[hvIdx] != null && cellSizeArr[hvIdx] !== 'auto';
  76895. });
  76896. mergeLayoutParam(target, raw, {
  76897. type: 'box',
  76898. ignoreSize: ignoreSize
  76899. });
  76900. }
  76901. /*
  76902. * Licensed to the Apache Software Foundation (ASF) under one
  76903. * or more contributor license agreements. See the NOTICE file
  76904. * distributed with this work for additional information
  76905. * regarding copyright ownership. The ASF licenses this file
  76906. * to you under the Apache License, Version 2.0 (the
  76907. * "License"); you may not use this file except in compliance
  76908. * with the License. You may obtain a copy of the License at
  76909. *
  76910. * http://www.apache.org/licenses/LICENSE-2.0
  76911. *
  76912. * Unless required by applicable law or agreed to in writing,
  76913. * software distributed under the License is distributed on an
  76914. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76915. * KIND, either express or implied. See the License for the
  76916. * specific language governing permissions and limitations
  76917. * under the License.
  76918. */
  76919. /**
  76920. * AUTO-GENERATED FILE. DO NOT MODIFY.
  76921. */
  76922. /*
  76923. * Licensed to the Apache Software Foundation (ASF) under one
  76924. * or more contributor license agreements. See the NOTICE file
  76925. * distributed with this work for additional information
  76926. * regarding copyright ownership. The ASF licenses this file
  76927. * to you under the Apache License, Version 2.0 (the
  76928. * "License"); you may not use this file except in compliance
  76929. * with the License. You may obtain a copy of the License at
  76930. *
  76931. * http://www.apache.org/licenses/LICENSE-2.0
  76932. *
  76933. * Unless required by applicable law or agreed to in writing,
  76934. * software distributed under the License is distributed on an
  76935. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  76936. * KIND, either express or implied. See the License for the
  76937. * specific language governing permissions and limitations
  76938. * under the License.
  76939. */
  76940. var MONTH_TEXT = {
  76941. EN: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  76942. CN: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月']
  76943. };
  76944. var WEEK_TEXT = {
  76945. EN: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
  76946. CN: ['日', '一', '二', '三', '四', '五', '六']
  76947. };
  76948. var CalendarView =
  76949. /** @class */
  76950. function (_super) {
  76951. __extends(CalendarView, _super);
  76952. function CalendarView() {
  76953. var _this = _super !== null && _super.apply(this, arguments) || this;
  76954. _this.type = CalendarView.type;
  76955. return _this;
  76956. }
  76957. CalendarView.prototype.render = function (calendarModel, ecModel, api) {
  76958. var group = this.group;
  76959. group.removeAll();
  76960. var coordSys = calendarModel.coordinateSystem; // range info
  76961. var rangeData = coordSys.getRangeInfo();
  76962. var orient = coordSys.getOrient();
  76963. this._renderDayRect(calendarModel, rangeData, group); // _renderLines must be called prior to following function
  76964. this._renderLines(calendarModel, rangeData, orient, group);
  76965. this._renderYearText(calendarModel, rangeData, orient, group);
  76966. this._renderMonthText(calendarModel, orient, group);
  76967. this._renderWeekText(calendarModel, rangeData, orient, group);
  76968. }; // render day rect
  76969. CalendarView.prototype._renderDayRect = function (calendarModel, rangeData, group) {
  76970. var coordSys = calendarModel.coordinateSystem;
  76971. var itemRectStyleModel = calendarModel.getModel('itemStyle').getItemStyle();
  76972. var sw = coordSys.getCellWidth();
  76973. var sh = coordSys.getCellHeight();
  76974. for (var i = rangeData.start.time; i <= rangeData.end.time; i = coordSys.getNextNDay(i, 1).time) {
  76975. var point = coordSys.dataToRect([i], false).tl; // every rect
  76976. var rect = new Rect({
  76977. shape: {
  76978. x: point[0],
  76979. y: point[1],
  76980. width: sw,
  76981. height: sh
  76982. },
  76983. cursor: 'default',
  76984. style: itemRectStyleModel
  76985. });
  76986. group.add(rect);
  76987. }
  76988. }; // render separate line
  76989. CalendarView.prototype._renderLines = function (calendarModel, rangeData, orient, group) {
  76990. var self = this;
  76991. var coordSys = calendarModel.coordinateSystem;
  76992. var lineStyleModel = calendarModel.getModel(['splitLine', 'lineStyle']).getLineStyle();
  76993. var show = calendarModel.get(['splitLine', 'show']);
  76994. var lineWidth = lineStyleModel.lineWidth;
  76995. this._tlpoints = [];
  76996. this._blpoints = [];
  76997. this._firstDayOfMonth = [];
  76998. this._firstDayPoints = [];
  76999. var firstDay = rangeData.start;
  77000. for (var i = 0; firstDay.time <= rangeData.end.time; i++) {
  77001. addPoints(firstDay.formatedDate);
  77002. if (i === 0) {
  77003. firstDay = coordSys.getDateInfo(rangeData.start.y + '-' + rangeData.start.m);
  77004. }
  77005. var date = firstDay.date;
  77006. date.setMonth(date.getMonth() + 1);
  77007. firstDay = coordSys.getDateInfo(date);
  77008. }
  77009. addPoints(coordSys.getNextNDay(rangeData.end.time, 1).formatedDate);
  77010. function addPoints(date) {
  77011. self._firstDayOfMonth.push(coordSys.getDateInfo(date));
  77012. self._firstDayPoints.push(coordSys.dataToRect([date], false).tl);
  77013. var points = self._getLinePointsOfOneWeek(calendarModel, date, orient);
  77014. self._tlpoints.push(points[0]);
  77015. self._blpoints.push(points[points.length - 1]);
  77016. show && self._drawSplitline(points, lineStyleModel, group);
  77017. } // render top/left line
  77018. show && this._drawSplitline(self._getEdgesPoints(self._tlpoints, lineWidth, orient), lineStyleModel, group); // render bottom/right line
  77019. show && this._drawSplitline(self._getEdgesPoints(self._blpoints, lineWidth, orient), lineStyleModel, group);
  77020. }; // get points at both ends
  77021. CalendarView.prototype._getEdgesPoints = function (points, lineWidth, orient) {
  77022. var rs = [points[0].slice(), points[points.length - 1].slice()];
  77023. var idx = orient === 'horizontal' ? 0 : 1; // both ends of the line are extend half lineWidth
  77024. rs[0][idx] = rs[0][idx] - lineWidth / 2;
  77025. rs[1][idx] = rs[1][idx] + lineWidth / 2;
  77026. return rs;
  77027. }; // render split line
  77028. CalendarView.prototype._drawSplitline = function (points, lineStyle, group) {
  77029. var poyline = new Polyline({
  77030. z2: 20,
  77031. shape: {
  77032. points: points
  77033. },
  77034. style: lineStyle
  77035. });
  77036. group.add(poyline);
  77037. }; // render month line of one week points
  77038. CalendarView.prototype._getLinePointsOfOneWeek = function (calendarModel, date, orient) {
  77039. var coordSys = calendarModel.coordinateSystem;
  77040. var parsedDate = coordSys.getDateInfo(date);
  77041. var points = [];
  77042. for (var i = 0; i < 7; i++) {
  77043. var tmpD = coordSys.getNextNDay(parsedDate.time, i);
  77044. var point = coordSys.dataToRect([tmpD.time], false);
  77045. points[2 * tmpD.day] = point.tl;
  77046. points[2 * tmpD.day + 1] = point[orient === 'horizontal' ? 'bl' : 'tr'];
  77047. }
  77048. return points;
  77049. };
  77050. CalendarView.prototype._formatterLabel = function (formatter, params) {
  77051. if (typeof formatter === 'string' && formatter) {
  77052. return formatTplSimple(formatter, params);
  77053. }
  77054. if (typeof formatter === 'function') {
  77055. return formatter(params);
  77056. }
  77057. return params.nameMap;
  77058. };
  77059. CalendarView.prototype._yearTextPositionControl = function (textEl, point, orient, position, margin) {
  77060. var x = point[0];
  77061. var y = point[1];
  77062. var aligns = ['center', 'bottom'];
  77063. if (position === 'bottom') {
  77064. y += margin;
  77065. aligns = ['center', 'top'];
  77066. } else if (position === 'left') {
  77067. x -= margin;
  77068. } else if (position === 'right') {
  77069. x += margin;
  77070. aligns = ['center', 'top'];
  77071. } else {
  77072. // top
  77073. y -= margin;
  77074. }
  77075. var rotate = 0;
  77076. if (position === 'left' || position === 'right') {
  77077. rotate = Math.PI / 2;
  77078. }
  77079. return {
  77080. rotation: rotate,
  77081. x: x,
  77082. y: y,
  77083. style: {
  77084. align: aligns[0],
  77085. verticalAlign: aligns[1]
  77086. }
  77087. };
  77088. }; // render year
  77089. CalendarView.prototype._renderYearText = function (calendarModel, rangeData, orient, group) {
  77090. var yearLabel = calendarModel.getModel('yearLabel');
  77091. if (!yearLabel.get('show')) {
  77092. return;
  77093. }
  77094. var margin = yearLabel.get('margin');
  77095. var pos = yearLabel.get('position');
  77096. if (!pos) {
  77097. pos = orient !== 'horizontal' ? 'top' : 'left';
  77098. }
  77099. var points = [this._tlpoints[this._tlpoints.length - 1], this._blpoints[0]];
  77100. var xc = (points[0][0] + points[1][0]) / 2;
  77101. var yc = (points[0][1] + points[1][1]) / 2;
  77102. var idx = orient === 'horizontal' ? 0 : 1;
  77103. var posPoints = {
  77104. top: [xc, points[idx][1]],
  77105. bottom: [xc, points[1 - idx][1]],
  77106. left: [points[1 - idx][0], yc],
  77107. right: [points[idx][0], yc]
  77108. };
  77109. var name = rangeData.start.y;
  77110. if (+rangeData.end.y > +rangeData.start.y) {
  77111. name = name + '-' + rangeData.end.y;
  77112. }
  77113. var formatter = yearLabel.get('formatter');
  77114. var params = {
  77115. start: rangeData.start.y,
  77116. end: rangeData.end.y,
  77117. nameMap: name
  77118. };
  77119. var content = this._formatterLabel(formatter, params);
  77120. var yearText = new ZRText({
  77121. z2: 30,
  77122. style: createTextStyle(yearLabel, {
  77123. text: content
  77124. })
  77125. });
  77126. yearText.attr(this._yearTextPositionControl(yearText, posPoints[pos], orient, pos, margin));
  77127. group.add(yearText);
  77128. };
  77129. CalendarView.prototype._monthTextPositionControl = function (point, isCenter, orient, position, margin) {
  77130. var align = 'left';
  77131. var vAlign = 'top';
  77132. var x = point[0];
  77133. var y = point[1];
  77134. if (orient === 'horizontal') {
  77135. y = y + margin;
  77136. if (isCenter) {
  77137. align = 'center';
  77138. }
  77139. if (position === 'start') {
  77140. vAlign = 'bottom';
  77141. }
  77142. } else {
  77143. x = x + margin;
  77144. if (isCenter) {
  77145. vAlign = 'middle';
  77146. }
  77147. if (position === 'start') {
  77148. align = 'right';
  77149. }
  77150. }
  77151. return {
  77152. x: x,
  77153. y: y,
  77154. align: align,
  77155. verticalAlign: vAlign
  77156. };
  77157. }; // render month and year text
  77158. CalendarView.prototype._renderMonthText = function (calendarModel, orient, group) {
  77159. var monthLabel = calendarModel.getModel('monthLabel');
  77160. if (!monthLabel.get('show')) {
  77161. return;
  77162. }
  77163. var nameMap = monthLabel.get('nameMap');
  77164. var margin = monthLabel.get('margin');
  77165. var pos = monthLabel.get('position');
  77166. var align = monthLabel.get('align');
  77167. var termPoints = [this._tlpoints, this._blpoints];
  77168. if (isString(nameMap)) {
  77169. nameMap = MONTH_TEXT[nameMap.toUpperCase()] || [];
  77170. }
  77171. var idx = pos === 'start' ? 0 : 1;
  77172. var axis = orient === 'horizontal' ? 0 : 1;
  77173. margin = pos === 'start' ? -margin : margin;
  77174. var isCenter = align === 'center';
  77175. for (var i = 0; i < termPoints[idx].length - 1; i++) {
  77176. var tmp = termPoints[idx][i].slice();
  77177. var firstDay = this._firstDayOfMonth[i];
  77178. if (isCenter) {
  77179. var firstDayPoints = this._firstDayPoints[i];
  77180. tmp[axis] = (firstDayPoints[axis] + termPoints[0][i + 1][axis]) / 2;
  77181. }
  77182. var formatter = monthLabel.get('formatter');
  77183. var name_1 = nameMap[+firstDay.m - 1];
  77184. var params = {
  77185. yyyy: firstDay.y,
  77186. yy: (firstDay.y + '').slice(2),
  77187. MM: firstDay.m,
  77188. M: +firstDay.m,
  77189. nameMap: name_1
  77190. };
  77191. var content = this._formatterLabel(formatter, params);
  77192. var monthText = new ZRText({
  77193. z2: 30,
  77194. style: extend(createTextStyle(monthLabel, {
  77195. text: content
  77196. }), this._monthTextPositionControl(tmp, isCenter, orient, pos, margin))
  77197. });
  77198. group.add(monthText);
  77199. }
  77200. };
  77201. CalendarView.prototype._weekTextPositionControl = function (point, orient, position, margin, cellSize) {
  77202. var align = 'center';
  77203. var vAlign = 'middle';
  77204. var x = point[0];
  77205. var y = point[1];
  77206. var isStart = position === 'start';
  77207. if (orient === 'horizontal') {
  77208. x = x + margin + (isStart ? 1 : -1) * cellSize[0] / 2;
  77209. align = isStart ? 'right' : 'left';
  77210. } else {
  77211. y = y + margin + (isStart ? 1 : -1) * cellSize[1] / 2;
  77212. vAlign = isStart ? 'bottom' : 'top';
  77213. }
  77214. return {
  77215. x: x,
  77216. y: y,
  77217. align: align,
  77218. verticalAlign: vAlign
  77219. };
  77220. }; // render weeks
  77221. CalendarView.prototype._renderWeekText = function (calendarModel, rangeData, orient, group) {
  77222. var dayLabel = calendarModel.getModel('dayLabel');
  77223. if (!dayLabel.get('show')) {
  77224. return;
  77225. }
  77226. var coordSys = calendarModel.coordinateSystem;
  77227. var pos = dayLabel.get('position');
  77228. var nameMap = dayLabel.get('nameMap');
  77229. var margin = dayLabel.get('margin');
  77230. var firstDayOfWeek = coordSys.getFirstDayOfWeek();
  77231. if (isString(nameMap)) {
  77232. nameMap = WEEK_TEXT[nameMap.toUpperCase()] || [];
  77233. }
  77234. var start = coordSys.getNextNDay(rangeData.end.time, 7 - rangeData.lweek).time;
  77235. var cellSize = [coordSys.getCellWidth(), coordSys.getCellHeight()];
  77236. margin = parsePercent$1(margin, Math.min(cellSize[1], cellSize[0]));
  77237. if (pos === 'start') {
  77238. start = coordSys.getNextNDay(rangeData.start.time, -(7 + rangeData.fweek)).time;
  77239. margin = -margin;
  77240. }
  77241. for (var i = 0; i < 7; i++) {
  77242. var tmpD = coordSys.getNextNDay(start, i);
  77243. var point = coordSys.dataToRect([tmpD.time], false).center;
  77244. var day = i;
  77245. day = Math.abs((i + firstDayOfWeek) % 7);
  77246. var weekText = new ZRText({
  77247. z2: 30,
  77248. style: extend(createTextStyle(dayLabel, {
  77249. text: nameMap[day]
  77250. }), this._weekTextPositionControl(point, orient, pos, margin, cellSize))
  77251. });
  77252. group.add(weekText);
  77253. }
  77254. };
  77255. CalendarView.type = 'calendar';
  77256. return CalendarView;
  77257. }(ComponentView);
  77258. /*
  77259. * Licensed to the Apache Software Foundation (ASF) under one
  77260. * or more contributor license agreements. See the NOTICE file
  77261. * distributed with this work for additional information
  77262. * regarding copyright ownership. The ASF licenses this file
  77263. * to you under the Apache License, Version 2.0 (the
  77264. * "License"); you may not use this file except in compliance
  77265. * with the License. You may obtain a copy of the License at
  77266. *
  77267. * http://www.apache.org/licenses/LICENSE-2.0
  77268. *
  77269. * Unless required by applicable law or agreed to in writing,
  77270. * software distributed under the License is distributed on an
  77271. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77272. * KIND, either express or implied. See the License for the
  77273. * specific language governing permissions and limitations
  77274. * under the License.
  77275. */
  77276. /**
  77277. * AUTO-GENERATED FILE. DO NOT MODIFY.
  77278. */
  77279. /*
  77280. * Licensed to the Apache Software Foundation (ASF) under one
  77281. * or more contributor license agreements. See the NOTICE file
  77282. * distributed with this work for additional information
  77283. * regarding copyright ownership. The ASF licenses this file
  77284. * to you under the Apache License, Version 2.0 (the
  77285. * "License"); you may not use this file except in compliance
  77286. * with the License. You may obtain a copy of the License at
  77287. *
  77288. * http://www.apache.org/licenses/LICENSE-2.0
  77289. *
  77290. * Unless required by applicable law or agreed to in writing,
  77291. * software distributed under the License is distributed on an
  77292. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77293. * KIND, either express or implied. See the License for the
  77294. * specific language governing permissions and limitations
  77295. * under the License.
  77296. */
  77297. var PROXIMATE_ONE_DAY = 86400000;
  77298. var Calendar =
  77299. /** @class */
  77300. function () {
  77301. function Calendar(calendarModel, ecModel, api) {
  77302. this.type = 'calendar';
  77303. this.dimensions = Calendar.dimensions; // Required in createListFromData
  77304. this.getDimensionsInfo = Calendar.getDimensionsInfo;
  77305. this._model = calendarModel;
  77306. }
  77307. Calendar.getDimensionsInfo = function () {
  77308. return [{
  77309. name: 'time',
  77310. type: 'time'
  77311. }, 'value'];
  77312. };
  77313. Calendar.prototype.getRangeInfo = function () {
  77314. return this._rangeInfo;
  77315. };
  77316. Calendar.prototype.getModel = function () {
  77317. return this._model;
  77318. };
  77319. Calendar.prototype.getRect = function () {
  77320. return this._rect;
  77321. };
  77322. Calendar.prototype.getCellWidth = function () {
  77323. return this._sw;
  77324. };
  77325. Calendar.prototype.getCellHeight = function () {
  77326. return this._sh;
  77327. };
  77328. Calendar.prototype.getOrient = function () {
  77329. return this._orient;
  77330. };
  77331. /**
  77332. * getFirstDayOfWeek
  77333. *
  77334. * @example
  77335. * 0 : start at Sunday
  77336. * 1 : start at Monday
  77337. *
  77338. * @return {number}
  77339. */
  77340. Calendar.prototype.getFirstDayOfWeek = function () {
  77341. return this._firstDayOfWeek;
  77342. };
  77343. /**
  77344. * get date info
  77345. * }
  77346. */
  77347. Calendar.prototype.getDateInfo = function (date) {
  77348. date = parseDate(date);
  77349. var y = date.getFullYear();
  77350. var m = date.getMonth() + 1;
  77351. var mStr = m < 10 ? '0' + m : '' + m;
  77352. var d = date.getDate();
  77353. var dStr = d < 10 ? '0' + d : '' + d;
  77354. var day = date.getDay();
  77355. day = Math.abs((day + 7 - this.getFirstDayOfWeek()) % 7);
  77356. return {
  77357. y: y + '',
  77358. m: mStr,
  77359. d: dStr,
  77360. day: day,
  77361. time: date.getTime(),
  77362. formatedDate: y + '-' + mStr + '-' + dStr,
  77363. date: date
  77364. };
  77365. };
  77366. Calendar.prototype.getNextNDay = function (date, n) {
  77367. n = n || 0;
  77368. if (n === 0) {
  77369. return this.getDateInfo(date);
  77370. }
  77371. date = new Date(this.getDateInfo(date).time);
  77372. date.setDate(date.getDate() + n);
  77373. return this.getDateInfo(date);
  77374. };
  77375. Calendar.prototype.update = function (ecModel, api) {
  77376. this._firstDayOfWeek = +this._model.getModel('dayLabel').get('firstDay');
  77377. this._orient = this._model.get('orient');
  77378. this._lineWidth = this._model.getModel('itemStyle').getItemStyle().lineWidth || 0;
  77379. this._rangeInfo = this._getRangeInfo(this._initRangeOption());
  77380. var weeks = this._rangeInfo.weeks || 1;
  77381. var whNames = ['width', 'height'];
  77382. var cellSize = this._model.getCellSize().slice();
  77383. var layoutParams = this._model.getBoxLayoutParams();
  77384. var cellNumbers = this._orient === 'horizontal' ? [weeks, 7] : [7, weeks];
  77385. each$1([0, 1], function (idx) {
  77386. if (cellSizeSpecified(cellSize, idx)) {
  77387. layoutParams[whNames[idx]] = cellSize[idx] * cellNumbers[idx];
  77388. }
  77389. });
  77390. var whGlobal = {
  77391. width: api.getWidth(),
  77392. height: api.getHeight()
  77393. };
  77394. var calendarRect = this._rect = getLayoutRect(layoutParams, whGlobal);
  77395. each$1([0, 1], function (idx) {
  77396. if (!cellSizeSpecified(cellSize, idx)) {
  77397. cellSize[idx] = calendarRect[whNames[idx]] / cellNumbers[idx];
  77398. }
  77399. });
  77400. function cellSizeSpecified(cellSize, idx) {
  77401. return cellSize[idx] != null && cellSize[idx] !== 'auto';
  77402. } // Has been calculated out number.
  77403. this._sw = cellSize[0];
  77404. this._sh = cellSize[1];
  77405. };
  77406. /**
  77407. * Convert a time data(time, value) item to (x, y) point.
  77408. */
  77409. // TODO Clamp of calendar is not same with cartesian coordinate systems.
  77410. // It will return NaN if data exceeds.
  77411. Calendar.prototype.dataToPoint = function (data, clamp) {
  77412. isArray(data) && (data = data[0]);
  77413. clamp == null && (clamp = true);
  77414. var dayInfo = this.getDateInfo(data);
  77415. var range = this._rangeInfo;
  77416. var date = dayInfo.formatedDate; // if not in range return [NaN, NaN]
  77417. if (clamp && !(dayInfo.time >= range.start.time && dayInfo.time < range.end.time + PROXIMATE_ONE_DAY)) {
  77418. return [NaN, NaN];
  77419. }
  77420. var week = dayInfo.day;
  77421. var nthWeek = this._getRangeInfo([range.start.time, date]).nthWeek;
  77422. if (this._orient === 'vertical') {
  77423. return [this._rect.x + week * this._sw + this._sw / 2, this._rect.y + nthWeek * this._sh + this._sh / 2];
  77424. }
  77425. return [this._rect.x + nthWeek * this._sw + this._sw / 2, this._rect.y + week * this._sh + this._sh / 2];
  77426. };
  77427. /**
  77428. * Convert a (x, y) point to time data
  77429. */
  77430. Calendar.prototype.pointToData = function (point) {
  77431. var date = this.pointToDate(point);
  77432. return date && date.time;
  77433. };
  77434. /**
  77435. * Convert a time date item to (x, y) four point.
  77436. */
  77437. Calendar.prototype.dataToRect = function (data, clamp) {
  77438. var point = this.dataToPoint(data, clamp);
  77439. return {
  77440. contentShape: {
  77441. x: point[0] - (this._sw - this._lineWidth) / 2,
  77442. y: point[1] - (this._sh - this._lineWidth) / 2,
  77443. width: this._sw - this._lineWidth,
  77444. height: this._sh - this._lineWidth
  77445. },
  77446. center: point,
  77447. tl: [point[0] - this._sw / 2, point[1] - this._sh / 2],
  77448. tr: [point[0] + this._sw / 2, point[1] - this._sh / 2],
  77449. br: [point[0] + this._sw / 2, point[1] + this._sh / 2],
  77450. bl: [point[0] - this._sw / 2, point[1] + this._sh / 2]
  77451. };
  77452. };
  77453. /**
  77454. * Convert a (x, y) point to time date
  77455. *
  77456. * @param {Array} point point
  77457. * @return {Object} date
  77458. */
  77459. Calendar.prototype.pointToDate = function (point) {
  77460. var nthX = Math.floor((point[0] - this._rect.x) / this._sw) + 1;
  77461. var nthY = Math.floor((point[1] - this._rect.y) / this._sh) + 1;
  77462. var range = this._rangeInfo.range;
  77463. if (this._orient === 'vertical') {
  77464. return this._getDateByWeeksAndDay(nthY, nthX - 1, range);
  77465. }
  77466. return this._getDateByWeeksAndDay(nthX, nthY - 1, range);
  77467. };
  77468. Calendar.prototype.convertToPixel = function (ecModel, finder, value) {
  77469. var coordSys = getCoordSys$4(finder);
  77470. return coordSys === this ? coordSys.dataToPoint(value) : null;
  77471. };
  77472. Calendar.prototype.convertFromPixel = function (ecModel, finder, pixel) {
  77473. var coordSys = getCoordSys$4(finder);
  77474. return coordSys === this ? coordSys.pointToData(pixel) : null;
  77475. };
  77476. Calendar.prototype.containPoint = function (point) {
  77477. console.warn('Not implemented.');
  77478. return false;
  77479. };
  77480. /**
  77481. * initRange
  77482. * Normalize to an [start, end] array
  77483. */
  77484. Calendar.prototype._initRangeOption = function () {
  77485. var range = this._model.get('range');
  77486. var normalizedRange; // Convert [1990] to 1990
  77487. if (isArray(range) && range.length === 1) {
  77488. range = range[0];
  77489. }
  77490. if (!isArray(range)) {
  77491. var rangeStr = range.toString(); // One year.
  77492. if (/^\d{4}$/.test(rangeStr)) {
  77493. normalizedRange = [rangeStr + '-01-01', rangeStr + '-12-31'];
  77494. } // One month
  77495. if (/^\d{4}[\/|-]\d{1,2}$/.test(rangeStr)) {
  77496. var start = this.getDateInfo(rangeStr);
  77497. var firstDay = start.date;
  77498. firstDay.setMonth(firstDay.getMonth() + 1);
  77499. var end = this.getNextNDay(firstDay, -1);
  77500. normalizedRange = [start.formatedDate, end.formatedDate];
  77501. } // One day
  77502. if (/^\d{4}[\/|-]\d{1,2}[\/|-]\d{1,2}$/.test(rangeStr)) {
  77503. normalizedRange = [rangeStr, rangeStr];
  77504. }
  77505. } else {
  77506. normalizedRange = range;
  77507. }
  77508. if (!normalizedRange) {
  77509. {
  77510. logError('Invalid date range.');
  77511. } // Not handling it.
  77512. return range;
  77513. }
  77514. var tmp = this._getRangeInfo(normalizedRange);
  77515. if (tmp.start.time > tmp.end.time) {
  77516. normalizedRange.reverse();
  77517. }
  77518. return normalizedRange;
  77519. };
  77520. /**
  77521. * range info
  77522. *
  77523. * @private
  77524. * @param {Array} range range ['2017-01-01', '2017-07-08']
  77525. * If range[0] > range[1], they will not be reversed.
  77526. * @return {Object} obj
  77527. */
  77528. Calendar.prototype._getRangeInfo = function (range) {
  77529. var parsedRange = [this.getDateInfo(range[0]), this.getDateInfo(range[1])];
  77530. var reversed;
  77531. if (parsedRange[0].time > parsedRange[1].time) {
  77532. reversed = true;
  77533. parsedRange.reverse();
  77534. }
  77535. var allDay = Math.floor(parsedRange[1].time / PROXIMATE_ONE_DAY) - Math.floor(parsedRange[0].time / PROXIMATE_ONE_DAY) + 1; // Consider case1 (#11677 #10430):
  77536. // Set the system timezone as "UK", set the range to `['2016-07-01', '2016-12-31']`
  77537. // Consider case2:
  77538. // Firstly set system timezone as "Time Zone: America/Toronto",
  77539. // ```
  77540. // let first = new Date(1478412000000 - 3600 * 1000 * 2.5);
  77541. // let second = new Date(1478412000000);
  77542. // let allDays = Math.floor(second / ONE_DAY) - Math.floor(first / ONE_DAY) + 1;
  77543. // ```
  77544. // will get wrong result because of DST. So we should fix it.
  77545. var date = new Date(parsedRange[0].time);
  77546. var startDateNum = date.getDate();
  77547. var endDateNum = parsedRange[1].date.getDate();
  77548. date.setDate(startDateNum + allDay - 1); // The bias can not over a month, so just compare date.
  77549. var dateNum = date.getDate();
  77550. if (dateNum !== endDateNum) {
  77551. var sign = date.getTime() - parsedRange[1].time > 0 ? 1 : -1;
  77552. while ((dateNum = date.getDate()) !== endDateNum && (date.getTime() - parsedRange[1].time) * sign > 0) {
  77553. allDay -= sign;
  77554. date.setDate(dateNum - sign);
  77555. }
  77556. }
  77557. var weeks = Math.floor((allDay + parsedRange[0].day + 6) / 7);
  77558. var nthWeek = reversed ? -weeks + 1 : weeks - 1;
  77559. reversed && parsedRange.reverse();
  77560. return {
  77561. range: [parsedRange[0].formatedDate, parsedRange[1].formatedDate],
  77562. start: parsedRange[0],
  77563. end: parsedRange[1],
  77564. allDay: allDay,
  77565. weeks: weeks,
  77566. // From 0.
  77567. nthWeek: nthWeek,
  77568. fweek: parsedRange[0].day,
  77569. lweek: parsedRange[1].day
  77570. };
  77571. };
  77572. /**
  77573. * get date by nthWeeks and week day in range
  77574. *
  77575. * @private
  77576. * @param {number} nthWeek the week
  77577. * @param {number} day the week day
  77578. * @param {Array} range [d1, d2]
  77579. * @return {Object}
  77580. */
  77581. Calendar.prototype._getDateByWeeksAndDay = function (nthWeek, day, range) {
  77582. var rangeInfo = this._getRangeInfo(range);
  77583. if (nthWeek > rangeInfo.weeks || nthWeek === 0 && day < rangeInfo.fweek || nthWeek === rangeInfo.weeks && day > rangeInfo.lweek) {
  77584. return null;
  77585. }
  77586. var nthDay = (nthWeek - 1) * 7 - rangeInfo.fweek + day;
  77587. var date = new Date(rangeInfo.start.time);
  77588. date.setDate(+rangeInfo.start.d + nthDay);
  77589. return this.getDateInfo(date);
  77590. };
  77591. Calendar.create = function (ecModel, api) {
  77592. var calendarList = [];
  77593. ecModel.eachComponent('calendar', function (calendarModel) {
  77594. var calendar = new Calendar(calendarModel, ecModel, api);
  77595. calendarList.push(calendar);
  77596. calendarModel.coordinateSystem = calendar;
  77597. });
  77598. ecModel.eachSeries(function (calendarSeries) {
  77599. if (calendarSeries.get('coordinateSystem') === 'calendar') {
  77600. // Inject coordinate system
  77601. calendarSeries.coordinateSystem = calendarList[calendarSeries.get('calendarIndex') || 0];
  77602. }
  77603. });
  77604. return calendarList;
  77605. };
  77606. Calendar.dimensions = ['time', 'value'];
  77607. return Calendar;
  77608. }();
  77609. function getCoordSys$4(finder) {
  77610. var calendarModel = finder.calendarModel;
  77611. var seriesModel = finder.seriesModel;
  77612. var coordSys = calendarModel ? calendarModel.coordinateSystem : seriesModel ? seriesModel.coordinateSystem : null;
  77613. return coordSys;
  77614. }
  77615. /*
  77616. * Licensed to the Apache Software Foundation (ASF) under one
  77617. * or more contributor license agreements. See the NOTICE file
  77618. * distributed with this work for additional information
  77619. * regarding copyright ownership. The ASF licenses this file
  77620. * to you under the Apache License, Version 2.0 (the
  77621. * "License"); you may not use this file except in compliance
  77622. * with the License. You may obtain a copy of the License at
  77623. *
  77624. * http://www.apache.org/licenses/LICENSE-2.0
  77625. *
  77626. * Unless required by applicable law or agreed to in writing,
  77627. * software distributed under the License is distributed on an
  77628. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77629. * KIND, either express or implied. See the License for the
  77630. * specific language governing permissions and limitations
  77631. * under the License.
  77632. */
  77633. /**
  77634. * AUTO-GENERATED FILE. DO NOT MODIFY.
  77635. */
  77636. /*
  77637. * Licensed to the Apache Software Foundation (ASF) under one
  77638. * or more contributor license agreements. See the NOTICE file
  77639. * distributed with this work for additional information
  77640. * regarding copyright ownership. The ASF licenses this file
  77641. * to you under the Apache License, Version 2.0 (the
  77642. * "License"); you may not use this file except in compliance
  77643. * with the License. You may obtain a copy of the License at
  77644. *
  77645. * http://www.apache.org/licenses/LICENSE-2.0
  77646. *
  77647. * Unless required by applicable law or agreed to in writing,
  77648. * software distributed under the License is distributed on an
  77649. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77650. * KIND, either express or implied. See the License for the
  77651. * specific language governing permissions and limitations
  77652. * under the License.
  77653. */
  77654. function install$31(registers) {
  77655. registers.registerComponentModel(CalendarModel);
  77656. registers.registerComponentView(CalendarView);
  77657. registers.registerCoordinateSystem('calendar', Calendar);
  77658. }
  77659. /*
  77660. * Licensed to the Apache Software Foundation (ASF) under one
  77661. * or more contributor license agreements. See the NOTICE file
  77662. * distributed with this work for additional information
  77663. * regarding copyright ownership. The ASF licenses this file
  77664. * to you under the Apache License, Version 2.0 (the
  77665. * "License"); you may not use this file except in compliance
  77666. * with the License. You may obtain a copy of the License at
  77667. *
  77668. * http://www.apache.org/licenses/LICENSE-2.0
  77669. *
  77670. * Unless required by applicable law or agreed to in writing,
  77671. * software distributed under the License is distributed on an
  77672. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77673. * KIND, either express or implied. See the License for the
  77674. * specific language governing permissions and limitations
  77675. * under the License.
  77676. */
  77677. /**
  77678. * AUTO-GENERATED FILE. DO NOT MODIFY.
  77679. */
  77680. /*
  77681. * Licensed to the Apache Software Foundation (ASF) under one
  77682. * or more contributor license agreements. See the NOTICE file
  77683. * distributed with this work for additional information
  77684. * regarding copyright ownership. The ASF licenses this file
  77685. * to you under the Apache License, Version 2.0 (the
  77686. * "License"); you may not use this file except in compliance
  77687. * with the License. You may obtain a copy of the License at
  77688. *
  77689. * http://www.apache.org/licenses/LICENSE-2.0
  77690. *
  77691. * Unless required by applicable law or agreed to in writing,
  77692. * software distributed under the License is distributed on an
  77693. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77694. * KIND, either express or implied. See the License for the
  77695. * specific language governing permissions and limitations
  77696. * under the License.
  77697. */
  77698. use(install$31);
  77699. /*
  77700. * Licensed to the Apache Software Foundation (ASF) under one
  77701. * or more contributor license agreements. See the NOTICE file
  77702. * distributed with this work for additional information
  77703. * regarding copyright ownership. The ASF licenses this file
  77704. * to you under the Apache License, Version 2.0 (the
  77705. * "License"); you may not use this file except in compliance
  77706. * with the License. You may obtain a copy of the License at
  77707. *
  77708. * http://www.apache.org/licenses/LICENSE-2.0
  77709. *
  77710. * Unless required by applicable law or agreed to in writing,
  77711. * software distributed under the License is distributed on an
  77712. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77713. * KIND, either express or implied. See the License for the
  77714. * specific language governing permissions and limitations
  77715. * under the License.
  77716. */
  77717. /**
  77718. * AUTO-GENERATED FILE. DO NOT MODIFY.
  77719. */
  77720. /*
  77721. * Licensed to the Apache Software Foundation (ASF) under one
  77722. * or more contributor license agreements. See the NOTICE file
  77723. * distributed with this work for additional information
  77724. * regarding copyright ownership. The ASF licenses this file
  77725. * to you under the Apache License, Version 2.0 (the
  77726. * "License"); you may not use this file except in compliance
  77727. * with the License. You may obtain a copy of the License at
  77728. *
  77729. * http://www.apache.org/licenses/LICENSE-2.0
  77730. *
  77731. * Unless required by applicable law or agreed to in writing,
  77732. * software distributed under the License is distributed on an
  77733. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77734. * KIND, either express or implied. See the License for the
  77735. * specific language governing permissions and limitations
  77736. * under the License.
  77737. */
  77738. var TitleModel =
  77739. /** @class */
  77740. function (_super) {
  77741. __extends(TitleModel, _super);
  77742. function TitleModel() {
  77743. var _this = _super !== null && _super.apply(this, arguments) || this;
  77744. _this.type = TitleModel.type;
  77745. _this.layoutMode = {
  77746. type: 'box',
  77747. ignoreSize: true
  77748. };
  77749. return _this;
  77750. }
  77751. TitleModel.type = 'title';
  77752. TitleModel.defaultOption = {
  77753. zlevel: 0,
  77754. z: 6,
  77755. show: true,
  77756. text: '',
  77757. target: 'blank',
  77758. subtext: '',
  77759. subtarget: 'blank',
  77760. left: 0,
  77761. top: 0,
  77762. backgroundColor: 'rgba(0,0,0,0)',
  77763. borderColor: '#ccc',
  77764. borderWidth: 0,
  77765. padding: 5,
  77766. itemGap: 10,
  77767. textStyle: {
  77768. fontSize: 18,
  77769. fontWeight: 'bold',
  77770. color: '#464646'
  77771. },
  77772. subtextStyle: {
  77773. fontSize: 12,
  77774. color: '#6E7079'
  77775. }
  77776. };
  77777. return TitleModel;
  77778. }(ComponentModel); // View
  77779. var TitleView =
  77780. /** @class */
  77781. function (_super) {
  77782. __extends(TitleView, _super);
  77783. function TitleView() {
  77784. var _this = _super !== null && _super.apply(this, arguments) || this;
  77785. _this.type = TitleView.type;
  77786. return _this;
  77787. }
  77788. TitleView.prototype.render = function (titleModel, ecModel, api) {
  77789. this.group.removeAll();
  77790. if (!titleModel.get('show')) {
  77791. return;
  77792. }
  77793. var group = this.group;
  77794. var textStyleModel = titleModel.getModel('textStyle');
  77795. var subtextStyleModel = titleModel.getModel('subtextStyle');
  77796. var textAlign = titleModel.get('textAlign');
  77797. var textVerticalAlign = retrieve2(titleModel.get('textBaseline'), titleModel.get('textVerticalAlign'));
  77798. var textEl = new ZRText({
  77799. style: createTextStyle(textStyleModel, {
  77800. text: titleModel.get('text'),
  77801. fill: textStyleModel.getTextColor()
  77802. }, {
  77803. disableBox: true
  77804. }),
  77805. z2: 10
  77806. });
  77807. var textRect = textEl.getBoundingRect();
  77808. var subText = titleModel.get('subtext');
  77809. var subTextEl = new ZRText({
  77810. style: createTextStyle(subtextStyleModel, {
  77811. text: subText,
  77812. fill: subtextStyleModel.getTextColor(),
  77813. y: textRect.height + titleModel.get('itemGap'),
  77814. verticalAlign: 'top'
  77815. }, {
  77816. disableBox: true
  77817. }),
  77818. z2: 10
  77819. });
  77820. var link = titleModel.get('link');
  77821. var sublink = titleModel.get('sublink');
  77822. var triggerEvent = titleModel.get('triggerEvent', true);
  77823. textEl.silent = !link && !triggerEvent;
  77824. subTextEl.silent = !sublink && !triggerEvent;
  77825. if (link) {
  77826. textEl.on('click', function () {
  77827. windowOpen(link, '_' + titleModel.get('target'));
  77828. });
  77829. }
  77830. if (sublink) {
  77831. subTextEl.on('click', function () {
  77832. windowOpen(sublink, '_' + titleModel.get('subtarget'));
  77833. });
  77834. }
  77835. getECData(textEl).eventData = getECData(subTextEl).eventData = triggerEvent ? {
  77836. componentType: 'title',
  77837. componentIndex: titleModel.componentIndex
  77838. } : null;
  77839. group.add(textEl);
  77840. subText && group.add(subTextEl); // If no subText, but add subTextEl, there will be an empty line.
  77841. var groupRect = group.getBoundingRect();
  77842. var layoutOption = titleModel.getBoxLayoutParams();
  77843. layoutOption.width = groupRect.width;
  77844. layoutOption.height = groupRect.height;
  77845. var layoutRect = getLayoutRect(layoutOption, {
  77846. width: api.getWidth(),
  77847. height: api.getHeight()
  77848. }, titleModel.get('padding')); // Adjust text align based on position
  77849. if (!textAlign) {
  77850. // Align left if title is on the left. center and right is same
  77851. textAlign = titleModel.get('left') || titleModel.get('right'); // @ts-ignore
  77852. if (textAlign === 'middle') {
  77853. textAlign = 'center';
  77854. } // Adjust layout by text align
  77855. if (textAlign === 'right') {
  77856. layoutRect.x += layoutRect.width;
  77857. } else if (textAlign === 'center') {
  77858. layoutRect.x += layoutRect.width / 2;
  77859. }
  77860. }
  77861. if (!textVerticalAlign) {
  77862. textVerticalAlign = titleModel.get('top') || titleModel.get('bottom'); // @ts-ignore
  77863. if (textVerticalAlign === 'center') {
  77864. textVerticalAlign = 'middle';
  77865. }
  77866. if (textVerticalAlign === 'bottom') {
  77867. layoutRect.y += layoutRect.height;
  77868. } else if (textVerticalAlign === 'middle') {
  77869. layoutRect.y += layoutRect.height / 2;
  77870. }
  77871. textVerticalAlign = textVerticalAlign || 'top';
  77872. }
  77873. group.x = layoutRect.x;
  77874. group.y = layoutRect.y;
  77875. group.markRedraw();
  77876. var alignStyle = {
  77877. align: textAlign,
  77878. verticalAlign: textVerticalAlign
  77879. };
  77880. textEl.setStyle(alignStyle);
  77881. subTextEl.setStyle(alignStyle); // Render background
  77882. // Get groupRect again because textAlign has been changed
  77883. groupRect = group.getBoundingRect();
  77884. var padding = layoutRect.margin;
  77885. var style = titleModel.getItemStyle(['color', 'opacity']);
  77886. style.fill = titleModel.get('backgroundColor');
  77887. var rect = new Rect({
  77888. shape: {
  77889. x: groupRect.x - padding[3],
  77890. y: groupRect.y - padding[0],
  77891. width: groupRect.width + padding[1] + padding[3],
  77892. height: groupRect.height + padding[0] + padding[2],
  77893. r: titleModel.get('borderRadius')
  77894. },
  77895. style: style,
  77896. subPixelOptimize: true,
  77897. silent: true
  77898. });
  77899. group.add(rect);
  77900. };
  77901. TitleView.type = 'title';
  77902. return TitleView;
  77903. }(ComponentView);
  77904. function install$32(registers) {
  77905. registers.registerComponentModel(TitleModel);
  77906. registers.registerComponentView(TitleView);
  77907. }
  77908. /*
  77909. * Licensed to the Apache Software Foundation (ASF) under one
  77910. * or more contributor license agreements. See the NOTICE file
  77911. * distributed with this work for additional information
  77912. * regarding copyright ownership. The ASF licenses this file
  77913. * to you under the Apache License, Version 2.0 (the
  77914. * "License"); you may not use this file except in compliance
  77915. * with the License. You may obtain a copy of the License at
  77916. *
  77917. * http://www.apache.org/licenses/LICENSE-2.0
  77918. *
  77919. * Unless required by applicable law or agreed to in writing,
  77920. * software distributed under the License is distributed on an
  77921. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77922. * KIND, either express or implied. See the License for the
  77923. * specific language governing permissions and limitations
  77924. * under the License.
  77925. */
  77926. /**
  77927. * AUTO-GENERATED FILE. DO NOT MODIFY.
  77928. */
  77929. /*
  77930. * Licensed to the Apache Software Foundation (ASF) under one
  77931. * or more contributor license agreements. See the NOTICE file
  77932. * distributed with this work for additional information
  77933. * regarding copyright ownership. The ASF licenses this file
  77934. * to you under the Apache License, Version 2.0 (the
  77935. * "License"); you may not use this file except in compliance
  77936. * with the License. You may obtain a copy of the License at
  77937. *
  77938. * http://www.apache.org/licenses/LICENSE-2.0
  77939. *
  77940. * Unless required by applicable law or agreed to in writing,
  77941. * software distributed under the License is distributed on an
  77942. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77943. * KIND, either express or implied. See the License for the
  77944. * specific language governing permissions and limitations
  77945. * under the License.
  77946. */
  77947. use(install$32);
  77948. /*
  77949. * Licensed to the Apache Software Foundation (ASF) under one
  77950. * or more contributor license agreements. See the NOTICE file
  77951. * distributed with this work for additional information
  77952. * regarding copyright ownership. The ASF licenses this file
  77953. * to you under the Apache License, Version 2.0 (the
  77954. * "License"); you may not use this file except in compliance
  77955. * with the License. You may obtain a copy of the License at
  77956. *
  77957. * http://www.apache.org/licenses/LICENSE-2.0
  77958. *
  77959. * Unless required by applicable law or agreed to in writing,
  77960. * software distributed under the License is distributed on an
  77961. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77962. * KIND, either express or implied. See the License for the
  77963. * specific language governing permissions and limitations
  77964. * under the License.
  77965. */
  77966. /**
  77967. * AUTO-GENERATED FILE. DO NOT MODIFY.
  77968. */
  77969. /*
  77970. * Licensed to the Apache Software Foundation (ASF) under one
  77971. * or more contributor license agreements. See the NOTICE file
  77972. * distributed with this work for additional information
  77973. * regarding copyright ownership. The ASF licenses this file
  77974. * to you under the Apache License, Version 2.0 (the
  77975. * "License"); you may not use this file except in compliance
  77976. * with the License. You may obtain a copy of the License at
  77977. *
  77978. * http://www.apache.org/licenses/LICENSE-2.0
  77979. *
  77980. * Unless required by applicable law or agreed to in writing,
  77981. * software distributed under the License is distributed on an
  77982. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  77983. * KIND, either express or implied. See the License for the
  77984. * specific language governing permissions and limitations
  77985. * under the License.
  77986. */
  77987. var getDefaultSelectorOptions = function (ecModel, type) {
  77988. if (type === 'all') {
  77989. return {
  77990. type: 'all',
  77991. title: ecModel.getLocale(['legend', 'selector', 'all'])
  77992. };
  77993. } else if (type === 'inverse') {
  77994. return {
  77995. type: 'inverse',
  77996. title: ecModel.getLocale(['legend', 'selector', 'inverse'])
  77997. };
  77998. }
  77999. };
  78000. var LegendModel =
  78001. /** @class */
  78002. function (_super) {
  78003. __extends(LegendModel, _super);
  78004. function LegendModel() {
  78005. var _this = _super !== null && _super.apply(this, arguments) || this;
  78006. _this.type = LegendModel.type;
  78007. _this.layoutMode = {
  78008. type: 'box',
  78009. // legend.width/height are maxWidth/maxHeight actually,
  78010. // whereas realy width/height is calculated by its content.
  78011. // (Setting {left: 10, right: 10} does not make sense).
  78012. // So consider the case:
  78013. // `setOption({legend: {left: 10});`
  78014. // then `setOption({legend: {right: 10});`
  78015. // The previous `left` should be cleared by setting `ignoreSize`.
  78016. ignoreSize: true
  78017. };
  78018. return _this;
  78019. }
  78020. LegendModel.prototype.init = function (option, parentModel, ecModel) {
  78021. this.mergeDefaultAndTheme(option, ecModel);
  78022. option.selected = option.selected || {};
  78023. this._updateSelector(option);
  78024. };
  78025. LegendModel.prototype.mergeOption = function (option, ecModel) {
  78026. _super.prototype.mergeOption.call(this, option, ecModel);
  78027. this._updateSelector(option);
  78028. };
  78029. LegendModel.prototype._updateSelector = function (option) {
  78030. var selector = option.selector;
  78031. var ecModel = this.ecModel;
  78032. if (selector === true) {
  78033. selector = option.selector = ['all', 'inverse'];
  78034. }
  78035. if (isArray(selector)) {
  78036. each$1(selector, function (item, index) {
  78037. isString(item) && (item = {
  78038. type: item
  78039. });
  78040. selector[index] = merge(item, getDefaultSelectorOptions(ecModel, item.type));
  78041. });
  78042. }
  78043. };
  78044. LegendModel.prototype.optionUpdated = function () {
  78045. this._updateData(this.ecModel);
  78046. var legendData = this._data; // If selectedMode is single, try to select one
  78047. if (legendData[0] && this.get('selectedMode') === 'single') {
  78048. var hasSelected = false; // If has any selected in option.selected
  78049. for (var i = 0; i < legendData.length; i++) {
  78050. var name_1 = legendData[i].get('name');
  78051. if (this.isSelected(name_1)) {
  78052. // Force to unselect others
  78053. this.select(name_1);
  78054. hasSelected = true;
  78055. break;
  78056. }
  78057. } // Try select the first if selectedMode is single
  78058. !hasSelected && this.select(legendData[0].get('name'));
  78059. }
  78060. };
  78061. LegendModel.prototype._updateData = function (ecModel) {
  78062. var potentialData = [];
  78063. var availableNames = [];
  78064. ecModel.eachRawSeries(function (seriesModel) {
  78065. var seriesName = seriesModel.name;
  78066. availableNames.push(seriesName);
  78067. var isPotential;
  78068. if (seriesModel.legendVisualProvider) {
  78069. var provider = seriesModel.legendVisualProvider;
  78070. var names = provider.getAllNames();
  78071. if (!ecModel.isSeriesFiltered(seriesModel)) {
  78072. availableNames = availableNames.concat(names);
  78073. }
  78074. if (names.length) {
  78075. potentialData = potentialData.concat(names);
  78076. } else {
  78077. isPotential = true;
  78078. }
  78079. } else {
  78080. isPotential = true;
  78081. }
  78082. if (isPotential && isNameSpecified(seriesModel)) {
  78083. potentialData.push(seriesModel.name);
  78084. }
  78085. });
  78086. /**
  78087. * @type {Array.<string>}
  78088. * @private
  78089. */
  78090. this._availableNames = availableNames; // If legend.data not specified in option, use availableNames as data,
  78091. // which is convinient for user preparing option.
  78092. var rawData = this.get('data') || potentialData;
  78093. var legendData = map(rawData, function (dataItem) {
  78094. // Can be string or number
  78095. if (typeof dataItem === 'string' || typeof dataItem === 'number') {
  78096. dataItem = {
  78097. name: dataItem
  78098. };
  78099. }
  78100. return new Model(dataItem, this, this.ecModel);
  78101. }, this);
  78102. /**
  78103. * @type {Array.<module:echarts/model/Model>}
  78104. * @private
  78105. */
  78106. this._data = legendData;
  78107. };
  78108. LegendModel.prototype.getData = function () {
  78109. return this._data;
  78110. };
  78111. LegendModel.prototype.select = function (name) {
  78112. var selected = this.option.selected;
  78113. var selectedMode = this.get('selectedMode');
  78114. if (selectedMode === 'single') {
  78115. var data = this._data;
  78116. each$1(data, function (dataItem) {
  78117. selected[dataItem.get('name')] = false;
  78118. });
  78119. }
  78120. selected[name] = true;
  78121. };
  78122. LegendModel.prototype.unSelect = function (name) {
  78123. if (this.get('selectedMode') !== 'single') {
  78124. this.option.selected[name] = false;
  78125. }
  78126. };
  78127. LegendModel.prototype.toggleSelected = function (name) {
  78128. var selected = this.option.selected; // Default is true
  78129. if (!selected.hasOwnProperty(name)) {
  78130. selected[name] = true;
  78131. }
  78132. this[selected[name] ? 'unSelect' : 'select'](name);
  78133. };
  78134. LegendModel.prototype.allSelect = function () {
  78135. var data = this._data;
  78136. var selected = this.option.selected;
  78137. each$1(data, function (dataItem) {
  78138. selected[dataItem.get('name', true)] = true;
  78139. });
  78140. };
  78141. LegendModel.prototype.inverseSelect = function () {
  78142. var data = this._data;
  78143. var selected = this.option.selected;
  78144. each$1(data, function (dataItem) {
  78145. var name = dataItem.get('name', true); // Initially, default value is true
  78146. if (!selected.hasOwnProperty(name)) {
  78147. selected[name] = true;
  78148. }
  78149. selected[name] = !selected[name];
  78150. });
  78151. };
  78152. LegendModel.prototype.isSelected = function (name) {
  78153. var selected = this.option.selected;
  78154. return !(selected.hasOwnProperty(name) && !selected[name]) && indexOf$1(this._availableNames, name) >= 0;
  78155. };
  78156. LegendModel.prototype.getOrient = function () {
  78157. return this.get('orient') === 'vertical' ? {
  78158. index: 1,
  78159. name: 'vertical'
  78160. } : {
  78161. index: 0,
  78162. name: 'horizontal'
  78163. };
  78164. };
  78165. LegendModel.type = 'legend.plain';
  78166. LegendModel.dependencies = ['series'];
  78167. LegendModel.defaultOption = {
  78168. zlevel: 0,
  78169. z: 4,
  78170. show: true,
  78171. orient: 'horizontal',
  78172. left: 'center',
  78173. // right: 'center',
  78174. top: 0,
  78175. // bottom: null,
  78176. align: 'auto',
  78177. backgroundColor: 'rgba(0,0,0,0)',
  78178. borderColor: '#ccc',
  78179. borderRadius: 0,
  78180. borderWidth: 0,
  78181. padding: 5,
  78182. itemGap: 10,
  78183. itemWidth: 25,
  78184. itemHeight: 14,
  78185. symbolSize: 'auto',
  78186. inactiveColor: '#ccc',
  78187. inactiveBorderColor: '#ccc',
  78188. inactiveBorderWidth: 'auto',
  78189. itemStyle: {
  78190. color: 'inherit',
  78191. opacity: 'inherit',
  78192. decal: 'inherit',
  78193. shadowBlur: 0,
  78194. shadowColor: null,
  78195. shadowOffsetX: 0,
  78196. shadowOffsetY: 0,
  78197. borderColor: 'inherit',
  78198. borderWidth: 'auto',
  78199. borderCap: 'inherit',
  78200. borderJoin: 'inherit',
  78201. borderDashOffset: 'inherit',
  78202. borderMiterLimit: 'inherit'
  78203. },
  78204. lineStyle: {
  78205. width: 'auto',
  78206. color: 'inherit',
  78207. inactiveColor: '#ccc',
  78208. inactiveWidth: 2,
  78209. opacity: 'inherit',
  78210. type: 'inherit',
  78211. cap: 'inherit',
  78212. join: 'inherit',
  78213. dashOffset: 'inherit',
  78214. miterLimit: 'inherit',
  78215. shadowBlur: 0,
  78216. shadowColor: null,
  78217. shadowOffsetX: 0,
  78218. shadowOffsetY: 0
  78219. },
  78220. textStyle: {
  78221. color: '#333'
  78222. },
  78223. selectedMode: true,
  78224. selector: false,
  78225. selectorLabel: {
  78226. show: true,
  78227. borderRadius: 10,
  78228. padding: [3, 5, 3, 5],
  78229. fontSize: 12,
  78230. fontFamily: ' sans-serif',
  78231. color: '#666',
  78232. borderWidth: 1,
  78233. borderColor: '#666'
  78234. },
  78235. emphasis: {
  78236. selectorLabel: {
  78237. show: true,
  78238. color: '#eee',
  78239. backgroundColor: '#666'
  78240. }
  78241. },
  78242. selectorPosition: 'auto',
  78243. selectorItemGap: 7,
  78244. selectorButtonGap: 10,
  78245. tooltip: {
  78246. show: false
  78247. }
  78248. };
  78249. return LegendModel;
  78250. }(ComponentModel);
  78251. /*
  78252. * Licensed to the Apache Software Foundation (ASF) under one
  78253. * or more contributor license agreements. See the NOTICE file
  78254. * distributed with this work for additional information
  78255. * regarding copyright ownership. The ASF licenses this file
  78256. * to you under the Apache License, Version 2.0 (the
  78257. * "License"); you may not use this file except in compliance
  78258. * with the License. You may obtain a copy of the License at
  78259. *
  78260. * http://www.apache.org/licenses/LICENSE-2.0
  78261. *
  78262. * Unless required by applicable law or agreed to in writing,
  78263. * software distributed under the License is distributed on an
  78264. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78265. * KIND, either express or implied. See the License for the
  78266. * specific language governing permissions and limitations
  78267. * under the License.
  78268. */
  78269. /**
  78270. * AUTO-GENERATED FILE. DO NOT MODIFY.
  78271. */
  78272. /*
  78273. * Licensed to the Apache Software Foundation (ASF) under one
  78274. * or more contributor license agreements. See the NOTICE file
  78275. * distributed with this work for additional information
  78276. * regarding copyright ownership. The ASF licenses this file
  78277. * to you under the Apache License, Version 2.0 (the
  78278. * "License"); you may not use this file except in compliance
  78279. * with the License. You may obtain a copy of the License at
  78280. *
  78281. * http://www.apache.org/licenses/LICENSE-2.0
  78282. *
  78283. * Unless required by applicable law or agreed to in writing,
  78284. * software distributed under the License is distributed on an
  78285. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78286. * KIND, either express or implied. See the License for the
  78287. * specific language governing permissions and limitations
  78288. * under the License.
  78289. */
  78290. // @ts-nocheck
  78291. /**
  78292. * Layout list like component.
  78293. * It will box layout each items in group of component and then position the whole group in the viewport
  78294. * @param {module:zrender/group/Group} group
  78295. * @param {module:echarts/model/Component} componentModel
  78296. * @param {module:echarts/ExtensionAPI}
  78297. */
  78298. function layout$3(group, componentModel, api) {
  78299. var boxLayoutParams = componentModel.getBoxLayoutParams();
  78300. var padding = componentModel.get('padding');
  78301. var viewportSize = {
  78302. width: api.getWidth(),
  78303. height: api.getHeight()
  78304. };
  78305. var rect = getLayoutRect(boxLayoutParams, viewportSize, padding);
  78306. box(componentModel.get('orient'), group, componentModel.get('itemGap'), rect.width, rect.height);
  78307. positionElement(group, boxLayoutParams, viewportSize, padding);
  78308. }
  78309. function makeBackground(rect, componentModel) {
  78310. var padding = normalizeCssArray$1(componentModel.get('padding'));
  78311. var style = componentModel.getItemStyle(['color', 'opacity']);
  78312. style.fill = componentModel.get('backgroundColor');
  78313. rect = new Rect({
  78314. shape: {
  78315. x: rect.x - padding[3],
  78316. y: rect.y - padding[0],
  78317. width: rect.width + padding[1] + padding[3],
  78318. height: rect.height + padding[0] + padding[2],
  78319. r: componentModel.get('borderRadius')
  78320. },
  78321. style: style,
  78322. silent: true,
  78323. z2: -1
  78324. }); // FIXME
  78325. // `subPixelOptimizeRect` may bring some gap between edge of viewpart
  78326. // and background rect when setting like `left: 0`, `top: 0`.
  78327. // graphic.subPixelOptimizeRect(rect);
  78328. return rect;
  78329. }
  78330. /*
  78331. * Licensed to the Apache Software Foundation (ASF) under one
  78332. * or more contributor license agreements. See the NOTICE file
  78333. * distributed with this work for additional information
  78334. * regarding copyright ownership. The ASF licenses this file
  78335. * to you under the Apache License, Version 2.0 (the
  78336. * "License"); you may not use this file except in compliance
  78337. * with the License. You may obtain a copy of the License at
  78338. *
  78339. * http://www.apache.org/licenses/LICENSE-2.0
  78340. *
  78341. * Unless required by applicable law or agreed to in writing,
  78342. * software distributed under the License is distributed on an
  78343. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78344. * KIND, either express or implied. See the License for the
  78345. * specific language governing permissions and limitations
  78346. * under the License.
  78347. */
  78348. /**
  78349. * AUTO-GENERATED FILE. DO NOT MODIFY.
  78350. */
  78351. /*
  78352. * Licensed to the Apache Software Foundation (ASF) under one
  78353. * or more contributor license agreements. See the NOTICE file
  78354. * distributed with this work for additional information
  78355. * regarding copyright ownership. The ASF licenses this file
  78356. * to you under the Apache License, Version 2.0 (the
  78357. * "License"); you may not use this file except in compliance
  78358. * with the License. You may obtain a copy of the License at
  78359. *
  78360. * http://www.apache.org/licenses/LICENSE-2.0
  78361. *
  78362. * Unless required by applicable law or agreed to in writing,
  78363. * software distributed under the License is distributed on an
  78364. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78365. * KIND, either express or implied. See the License for the
  78366. * specific language governing permissions and limitations
  78367. * under the License.
  78368. */
  78369. var curry$1 = curry;
  78370. var each$9 = each$1;
  78371. var Group$3 = Group;
  78372. var LegendView =
  78373. /** @class */
  78374. function (_super) {
  78375. __extends(LegendView, _super);
  78376. function LegendView() {
  78377. var _this = _super !== null && _super.apply(this, arguments) || this;
  78378. _this.type = LegendView.type;
  78379. _this.newlineDisabled = false;
  78380. return _this;
  78381. }
  78382. LegendView.prototype.init = function () {
  78383. this.group.add(this._contentGroup = new Group$3());
  78384. this.group.add(this._selectorGroup = new Group$3());
  78385. this._isFirstRender = true;
  78386. };
  78387. /**
  78388. * @protected
  78389. */
  78390. LegendView.prototype.getContentGroup = function () {
  78391. return this._contentGroup;
  78392. };
  78393. /**
  78394. * @protected
  78395. */
  78396. LegendView.prototype.getSelectorGroup = function () {
  78397. return this._selectorGroup;
  78398. };
  78399. /**
  78400. * @override
  78401. */
  78402. LegendView.prototype.render = function (legendModel, ecModel, api) {
  78403. var isFirstRender = this._isFirstRender;
  78404. this._isFirstRender = false;
  78405. this.resetInner();
  78406. if (!legendModel.get('show', true)) {
  78407. return;
  78408. }
  78409. var itemAlign = legendModel.get('align');
  78410. var orient = legendModel.get('orient');
  78411. if (!itemAlign || itemAlign === 'auto') {
  78412. itemAlign = legendModel.get('left') === 'right' && orient === 'vertical' ? 'right' : 'left';
  78413. } // selector has been normalized to an array in model
  78414. var selector = legendModel.get('selector', true);
  78415. var selectorPosition = legendModel.get('selectorPosition', true);
  78416. if (selector && (!selectorPosition || selectorPosition === 'auto')) {
  78417. selectorPosition = orient === 'horizontal' ? 'end' : 'start';
  78418. }
  78419. this.renderInner(itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition); // Perform layout.
  78420. var positionInfo = legendModel.getBoxLayoutParams();
  78421. var viewportSize = {
  78422. width: api.getWidth(),
  78423. height: api.getHeight()
  78424. };
  78425. var padding = legendModel.get('padding');
  78426. var maxSize = getLayoutRect(positionInfo, viewportSize, padding);
  78427. var mainRect = this.layoutInner(legendModel, itemAlign, maxSize, isFirstRender, selector, selectorPosition); // Place mainGroup, based on the calculated `mainRect`.
  78428. var layoutRect = getLayoutRect(defaults({
  78429. width: mainRect.width,
  78430. height: mainRect.height
  78431. }, positionInfo), viewportSize, padding);
  78432. this.group.x = layoutRect.x - mainRect.x;
  78433. this.group.y = layoutRect.y - mainRect.y;
  78434. this.group.markRedraw(); // Render background after group is layout.
  78435. this.group.add(this._backgroundEl = makeBackground(mainRect, legendModel));
  78436. };
  78437. LegendView.prototype.resetInner = function () {
  78438. this.getContentGroup().removeAll();
  78439. this._backgroundEl && this.group.remove(this._backgroundEl);
  78440. this.getSelectorGroup().removeAll();
  78441. };
  78442. LegendView.prototype.renderInner = function (itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition) {
  78443. var contentGroup = this.getContentGroup();
  78444. var legendDrawnMap = createHashMap();
  78445. var selectMode = legendModel.get('selectedMode');
  78446. var excludeSeriesId = [];
  78447. ecModel.eachRawSeries(function (seriesModel) {
  78448. !seriesModel.get('legendHoverLink') && excludeSeriesId.push(seriesModel.id);
  78449. });
  78450. each$9(legendModel.getData(), function (legendItemModel, dataIndex) {
  78451. var name = legendItemModel.get('name'); // Use empty string or \n as a newline string
  78452. if (!this.newlineDisabled && (name === '' || name === '\n')) {
  78453. var g = new Group$3(); // @ts-ignore
  78454. g.newline = true;
  78455. contentGroup.add(g);
  78456. return;
  78457. } // Representitive series.
  78458. var seriesModel = ecModel.getSeriesByName(name)[0];
  78459. if (legendDrawnMap.get(name)) {
  78460. // Have been drawed
  78461. return;
  78462. } // Legend to control series.
  78463. if (seriesModel) {
  78464. var data = seriesModel.getData();
  78465. var lineVisualStyle = data.getVisual('legendLineStyle') || {};
  78466. var symbolType = data.getVisual('legendSymbol');
  78467. /**
  78468. * `data.getVisual('style')` may be the color from the register
  78469. * in series. For example, for line series,
  78470. */
  78471. var style = data.getVisual('style');
  78472. data.getVisual('symbolSize');
  78473. var itemGroup = this._createItem(seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, lineVisualStyle, style, symbolType, selectMode);
  78474. itemGroup.on('click', curry$1(dispatchSelectAction, name, null, api, excludeSeriesId)).on('mouseover', curry$1(dispatchHighlightAction, seriesModel.name, null, api, excludeSeriesId)).on('mouseout', curry$1(dispatchDownplayAction, seriesModel.name, null, api, excludeSeriesId));
  78475. legendDrawnMap.set(name, true);
  78476. } else {
  78477. // Legend to control data. In pie and funnel.
  78478. ecModel.eachRawSeries(function (seriesModel) {
  78479. // In case multiple series has same data name
  78480. if (legendDrawnMap.get(name)) {
  78481. return;
  78482. }
  78483. if (seriesModel.legendVisualProvider) {
  78484. var provider = seriesModel.legendVisualProvider;
  78485. if (!provider.containName(name)) {
  78486. return;
  78487. }
  78488. var idx = provider.indexOfName(name);
  78489. var style = provider.getItemVisual(idx, 'style');
  78490. var symbolType = provider.getItemVisual(idx, 'legendSymbol');
  78491. var colorArr = parse(style.fill); // Color may be set to transparent in visualMap when data is out of range.
  78492. // Do not show nothing.
  78493. if (colorArr && colorArr[3] === 0) {
  78494. colorArr[3] = 0.2; // TODO color is set to 0, 0, 0, 0. Should show correct RGBA
  78495. style.fill = stringify(colorArr, 'rgba');
  78496. }
  78497. var itemGroup = this._createItem(seriesModel, name, dataIndex, legendItemModel, legendModel, itemAlign, {}, style, symbolType, selectMode); // FIXME: consider different series has items with the same name.
  78498. itemGroup.on('click', curry$1(dispatchSelectAction, null, name, api, excludeSeriesId)) // Should not specify the series name, consider legend controls
  78499. // more than one pie series.
  78500. .on('mouseover', curry$1(dispatchHighlightAction, null, name, api, excludeSeriesId)).on('mouseout', curry$1(dispatchDownplayAction, null, name, api, excludeSeriesId));
  78501. legendDrawnMap.set(name, true);
  78502. }
  78503. }, this);
  78504. }
  78505. {
  78506. if (!legendDrawnMap.get(name)) {
  78507. console.warn(name + ' series not exists. Legend data should be same with series name or data name.');
  78508. }
  78509. }
  78510. }, this);
  78511. if (selector) {
  78512. this._createSelector(selector, legendModel, api, orient, selectorPosition);
  78513. }
  78514. };
  78515. LegendView.prototype._createSelector = function (selector, legendModel, api, orient, selectorPosition) {
  78516. var selectorGroup = this.getSelectorGroup();
  78517. each$9(selector, function createSelectorButton(selectorItem) {
  78518. var type = selectorItem.type;
  78519. var labelText = new ZRText({
  78520. style: {
  78521. x: 0,
  78522. y: 0,
  78523. align: 'center',
  78524. verticalAlign: 'middle'
  78525. },
  78526. onclick: function () {
  78527. api.dispatchAction({
  78528. type: type === 'all' ? 'legendAllSelect' : 'legendInverseSelect'
  78529. });
  78530. }
  78531. });
  78532. selectorGroup.add(labelText);
  78533. var labelModel = legendModel.getModel('selectorLabel');
  78534. var emphasisLabelModel = legendModel.getModel(['emphasis', 'selectorLabel']);
  78535. setLabelStyle(labelText, {
  78536. normal: labelModel,
  78537. emphasis: emphasisLabelModel
  78538. }, {
  78539. defaultText: selectorItem.title
  78540. });
  78541. enableHoverEmphasis(labelText);
  78542. });
  78543. };
  78544. LegendView.prototype._createItem = function (seriesModel, name, dataIndex, itemModel, legendModel, itemAlign, lineVisualStyle, itemVisualStyle, symbolType, selectMode) {
  78545. var drawType = seriesModel.visualDrawType;
  78546. var itemWidth = legendModel.get('itemWidth');
  78547. var itemHeight = legendModel.get('itemHeight');
  78548. var isSelected = legendModel.isSelected(name);
  78549. var symbolKeepAspect = itemModel.get('symbolKeepAspect');
  78550. var legendIconType = itemModel.get('icon');
  78551. symbolType = legendIconType || symbolType || 'roundRect';
  78552. var legendLineStyle = legendModel.getModel('lineStyle');
  78553. var style = getLegendStyle(symbolType, itemModel, legendLineStyle, lineVisualStyle, itemVisualStyle, drawType, isSelected);
  78554. var itemGroup = new Group$3();
  78555. var textStyleModel = itemModel.getModel('textStyle');
  78556. if (typeof seriesModel.getLegendIcon === 'function' && !legendIconType) {
  78557. // Series has specific way to define legend icon
  78558. itemGroup.add(seriesModel.getLegendIcon({
  78559. itemWidth: itemWidth,
  78560. itemHeight: itemHeight,
  78561. symbolType: symbolType,
  78562. symbolKeepAspect: symbolKeepAspect,
  78563. itemStyle: style.itemStyle,
  78564. lineStyle: style.lineStyle
  78565. }));
  78566. } else {
  78567. // Use default legend icon policy for most series
  78568. itemGroup.add(getDefaultLegendIcon({
  78569. itemWidth: itemWidth,
  78570. itemHeight: itemHeight,
  78571. symbolType: symbolType,
  78572. symbolKeepAspect: symbolKeepAspect,
  78573. itemStyle: style.itemStyle,
  78574. lineStyle: style.lineStyle
  78575. }));
  78576. }
  78577. var textX = itemAlign === 'left' ? itemWidth + 5 : -5;
  78578. var textAlign = itemAlign;
  78579. var formatter = legendModel.get('formatter');
  78580. var content = name;
  78581. if (typeof formatter === 'string' && formatter) {
  78582. content = formatter.replace('{name}', name != null ? name : '');
  78583. } else if (typeof formatter === 'function') {
  78584. content = formatter(name);
  78585. }
  78586. var inactiveColor = itemModel.get('inactiveColor');
  78587. itemGroup.add(new ZRText({
  78588. style: createTextStyle(textStyleModel, {
  78589. text: content,
  78590. x: textX,
  78591. y: itemHeight / 2,
  78592. fill: isSelected ? textStyleModel.getTextColor() : inactiveColor,
  78593. align: textAlign,
  78594. verticalAlign: 'middle'
  78595. })
  78596. })); // Add a invisible rect to increase the area of mouse hover
  78597. var hitRect = new Rect({
  78598. shape: itemGroup.getBoundingRect(),
  78599. invisible: true
  78600. });
  78601. var tooltipModel = itemModel.getModel('tooltip');
  78602. if (tooltipModel.get('show')) {
  78603. setTooltipConfig({
  78604. el: hitRect,
  78605. componentModel: legendModel,
  78606. itemName: name,
  78607. itemTooltipOption: tooltipModel.option
  78608. });
  78609. }
  78610. itemGroup.add(hitRect);
  78611. itemGroup.eachChild(function (child) {
  78612. child.silent = true;
  78613. });
  78614. hitRect.silent = !selectMode;
  78615. this.getContentGroup().add(itemGroup);
  78616. enableHoverEmphasis(itemGroup); // @ts-ignore
  78617. itemGroup.__legendDataIndex = dataIndex;
  78618. return itemGroup;
  78619. };
  78620. LegendView.prototype.layoutInner = function (legendModel, itemAlign, maxSize, isFirstRender, selector, selectorPosition) {
  78621. var contentGroup = this.getContentGroup();
  78622. var selectorGroup = this.getSelectorGroup(); // Place items in contentGroup.
  78623. box(legendModel.get('orient'), contentGroup, legendModel.get('itemGap'), maxSize.width, maxSize.height);
  78624. var contentRect = contentGroup.getBoundingRect();
  78625. var contentPos = [-contentRect.x, -contentRect.y];
  78626. selectorGroup.markRedraw();
  78627. contentGroup.markRedraw();
  78628. if (selector) {
  78629. // Place buttons in selectorGroup
  78630. box( // Buttons in selectorGroup always layout horizontally
  78631. 'horizontal', selectorGroup, legendModel.get('selectorItemGap', true));
  78632. var selectorRect = selectorGroup.getBoundingRect();
  78633. var selectorPos = [-selectorRect.x, -selectorRect.y];
  78634. var selectorButtonGap = legendModel.get('selectorButtonGap', true);
  78635. var orientIdx = legendModel.getOrient().index;
  78636. var wh = orientIdx === 0 ? 'width' : 'height';
  78637. var hw = orientIdx === 0 ? 'height' : 'width';
  78638. var yx = orientIdx === 0 ? 'y' : 'x';
  78639. if (selectorPosition === 'end') {
  78640. selectorPos[orientIdx] += contentRect[wh] + selectorButtonGap;
  78641. } else {
  78642. contentPos[orientIdx] += selectorRect[wh] + selectorButtonGap;
  78643. } //Always align selector to content as 'middle'
  78644. selectorPos[1 - orientIdx] += contentRect[hw] / 2 - selectorRect[hw] / 2;
  78645. selectorGroup.x = selectorPos[0];
  78646. selectorGroup.y = selectorPos[1];
  78647. contentGroup.x = contentPos[0];
  78648. contentGroup.y = contentPos[1];
  78649. var mainRect = {
  78650. x: 0,
  78651. y: 0
  78652. };
  78653. mainRect[wh] = contentRect[wh] + selectorButtonGap + selectorRect[wh];
  78654. mainRect[hw] = Math.max(contentRect[hw], selectorRect[hw]);
  78655. mainRect[yx] = Math.min(0, selectorRect[yx] + selectorPos[1 - orientIdx]);
  78656. return mainRect;
  78657. } else {
  78658. contentGroup.x = contentPos[0];
  78659. contentGroup.y = contentPos[1];
  78660. return this.group.getBoundingRect();
  78661. }
  78662. };
  78663. /**
  78664. * @protected
  78665. */
  78666. LegendView.prototype.remove = function () {
  78667. this.getContentGroup().removeAll();
  78668. this._isFirstRender = true;
  78669. };
  78670. LegendView.type = 'legend.plain';
  78671. return LegendView;
  78672. }(ComponentView);
  78673. function getLegendStyle(symbolType, legendModel, legendLineStyle, lineVisualStyle, itemVisualStyle, drawType, isSelected) {
  78674. /**
  78675. * Use series style if is inherit;
  78676. * elsewise, use legend style
  78677. */
  78678. // itemStyle
  78679. var legendItemModel = legendModel.getModel('itemStyle');
  78680. var itemProperties = ITEM_STYLE_KEY_MAP.concat([['decal']]);
  78681. var itemStyle = {};
  78682. for (var i = 0; i < itemProperties.length; ++i) {
  78683. var propName = itemProperties[i][itemProperties[i].length - 1];
  78684. var visualName = itemProperties[i][0];
  78685. var value = legendItemModel.getShallow(propName);
  78686. if (value === 'inherit') {
  78687. switch (visualName) {
  78688. case 'fill':
  78689. /**
  78690. * Series with visualDrawType as 'stroke' should have
  78691. * series stroke as legend fill
  78692. */
  78693. itemStyle.fill = itemVisualStyle[drawType];
  78694. break;
  78695. case 'stroke':
  78696. /**
  78697. * symbol type with "emptyXXX" should use fill color
  78698. * in visual style
  78699. */
  78700. itemStyle.stroke = itemVisualStyle[symbolType.startsWith('empty') ? 'fill' : 'stroke'];
  78701. break;
  78702. case 'opacity':
  78703. /**
  78704. * Use lineStyle.opacity if drawType is stroke
  78705. */
  78706. itemStyle.opacity = (drawType === 'fill' ? itemVisualStyle : lineVisualStyle).opacity;
  78707. break;
  78708. default:
  78709. itemStyle[visualName] = itemVisualStyle[visualName];
  78710. }
  78711. } else if (value === 'auto' && visualName === 'lineWidth') {
  78712. // If lineStyle.width is 'auto', it is set to be 2 if series has border
  78713. itemStyle.lineWidth = itemVisualStyle.lineWidth > 0 ? 2 : 0;
  78714. } else {
  78715. itemStyle[visualName] = value;
  78716. }
  78717. } // lineStyle
  78718. var legendLineModel = legendModel.getModel('lineStyle');
  78719. var lineProperties = LINE_STYLE_KEY_MAP.concat([['inactiveColor'], ['inactiveWidth']]);
  78720. var lineStyle = {};
  78721. for (var i = 0; i < lineProperties.length; ++i) {
  78722. var propName = lineProperties[i][1];
  78723. var visualName = lineProperties[i][0];
  78724. var value = legendLineModel.getShallow(propName);
  78725. if (value === 'inherit') {
  78726. lineStyle[visualName] = lineVisualStyle[visualName];
  78727. } else if (value === 'auto' && visualName === 'lineWidth') {
  78728. // If lineStyle.width is 'auto', it is set to be 2 if series has border
  78729. lineStyle.lineWidth = lineVisualStyle.lineWidth > 0 ? 2 : 0;
  78730. } else {
  78731. lineStyle[visualName] = value;
  78732. }
  78733. } // Fix auto color to real color
  78734. itemStyle.fill === 'auto' && (itemStyle.fill = itemVisualStyle.fill);
  78735. itemStyle.stroke === 'auto' && (itemStyle.stroke = itemVisualStyle.fill);
  78736. lineStyle.stroke === 'auto' && (lineStyle.stroke = itemVisualStyle.fill);
  78737. if (!isSelected) {
  78738. var borderWidth = legendModel.get('inactiveBorderWidth');
  78739. /**
  78740. * Since stroke is set to be inactiveBorderColor, it may occur that
  78741. * there is no border in series but border in legend, so we need to
  78742. * use border only when series has border if is set to be auto
  78743. */
  78744. var visualHasBorder = itemStyle[symbolType.indexOf('empty') > -1 ? 'fill' : 'stroke'];
  78745. itemStyle.lineWidth = borderWidth === 'auto' ? itemVisualStyle.lineWidth > 0 && visualHasBorder ? 2 : 0 : itemStyle.lineWidth;
  78746. itemStyle.fill = legendModel.get('inactiveColor');
  78747. itemStyle.stroke = legendModel.get('inactiveBorderColor');
  78748. lineStyle.stroke = legendLineStyle.get('inactiveColor');
  78749. lineStyle.lineWidth = legendLineStyle.get('inactiveWidth');
  78750. }
  78751. return {
  78752. itemStyle: itemStyle,
  78753. lineStyle: lineStyle
  78754. };
  78755. }
  78756. function getDefaultLegendIcon(opt) {
  78757. var symboType = opt.symbolType || 'roundRect';
  78758. var symbol = createSymbol(symboType, 0, 0, opt.itemWidth, opt.itemHeight, opt.itemStyle.fill, opt.symbolKeepAspect);
  78759. symbol.setStyle(opt.itemStyle);
  78760. if (symboType.indexOf('empty') > -1) {
  78761. symbol.style.stroke = symbol.style.fill;
  78762. symbol.style.fill = '#fff';
  78763. symbol.style.lineWidth = 2;
  78764. }
  78765. return symbol;
  78766. }
  78767. function dispatchSelectAction(seriesName, dataName, api, excludeSeriesId) {
  78768. // downplay before unselect
  78769. dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId);
  78770. api.dispatchAction({
  78771. type: 'legendToggleSelect',
  78772. name: seriesName != null ? seriesName : dataName
  78773. }); // highlight after select
  78774. // TODO higlight immediately may cause animation loss.
  78775. dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId);
  78776. }
  78777. function isUseHoverLayer(api) {
  78778. var list = api.getZr().storage.getDisplayList();
  78779. var emphasisState;
  78780. var i = 0;
  78781. var len = list.length;
  78782. while (i < len && !(emphasisState = list[i].states.emphasis)) {
  78783. i++;
  78784. }
  78785. return emphasisState && emphasisState.hoverLayer;
  78786. }
  78787. function dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId) {
  78788. // If element hover will move to a hoverLayer.
  78789. if (!isUseHoverLayer(api)) {
  78790. api.dispatchAction({
  78791. type: 'highlight',
  78792. seriesName: seriesName,
  78793. name: dataName,
  78794. excludeSeriesId: excludeSeriesId
  78795. });
  78796. }
  78797. }
  78798. function dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId) {
  78799. // If element hover will move to a hoverLayer.
  78800. if (!isUseHoverLayer(api)) {
  78801. api.dispatchAction({
  78802. type: 'downplay',
  78803. seriesName: seriesName,
  78804. name: dataName,
  78805. excludeSeriesId: excludeSeriesId
  78806. });
  78807. }
  78808. }
  78809. /*
  78810. * Licensed to the Apache Software Foundation (ASF) under one
  78811. * or more contributor license agreements. See the NOTICE file
  78812. * distributed with this work for additional information
  78813. * regarding copyright ownership. The ASF licenses this file
  78814. * to you under the Apache License, Version 2.0 (the
  78815. * "License"); you may not use this file except in compliance
  78816. * with the License. You may obtain a copy of the License at
  78817. *
  78818. * http://www.apache.org/licenses/LICENSE-2.0
  78819. *
  78820. * Unless required by applicable law or agreed to in writing,
  78821. * software distributed under the License is distributed on an
  78822. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78823. * KIND, either express or implied. See the License for the
  78824. * specific language governing permissions and limitations
  78825. * under the License.
  78826. */
  78827. /**
  78828. * AUTO-GENERATED FILE. DO NOT MODIFY.
  78829. */
  78830. /*
  78831. * Licensed to the Apache Software Foundation (ASF) under one
  78832. * or more contributor license agreements. See the NOTICE file
  78833. * distributed with this work for additional information
  78834. * regarding copyright ownership. The ASF licenses this file
  78835. * to you under the Apache License, Version 2.0 (the
  78836. * "License"); you may not use this file except in compliance
  78837. * with the License. You may obtain a copy of the License at
  78838. *
  78839. * http://www.apache.org/licenses/LICENSE-2.0
  78840. *
  78841. * Unless required by applicable law or agreed to in writing,
  78842. * software distributed under the License is distributed on an
  78843. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78844. * KIND, either express or implied. See the License for the
  78845. * specific language governing permissions and limitations
  78846. * under the License.
  78847. */
  78848. function legendFilter(ecModel) {
  78849. var legendModels = ecModel.findComponents({
  78850. mainType: 'legend'
  78851. });
  78852. if (legendModels && legendModels.length) {
  78853. ecModel.filterSeries(function (series) {
  78854. // If in any legend component the status is not selected.
  78855. // Because in legend series is assumed selected when it is not in the legend data.
  78856. for (var i = 0; i < legendModels.length; i++) {
  78857. if (!legendModels[i].isSelected(series.name)) {
  78858. return false;
  78859. }
  78860. }
  78861. return true;
  78862. });
  78863. }
  78864. }
  78865. /*
  78866. * Licensed to the Apache Software Foundation (ASF) under one
  78867. * or more contributor license agreements. See the NOTICE file
  78868. * distributed with this work for additional information
  78869. * regarding copyright ownership. The ASF licenses this file
  78870. * to you under the Apache License, Version 2.0 (the
  78871. * "License"); you may not use this file except in compliance
  78872. * with the License. You may obtain a copy of the License at
  78873. *
  78874. * http://www.apache.org/licenses/LICENSE-2.0
  78875. *
  78876. * Unless required by applicable law or agreed to in writing,
  78877. * software distributed under the License is distributed on an
  78878. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78879. * KIND, either express or implied. See the License for the
  78880. * specific language governing permissions and limitations
  78881. * under the License.
  78882. */
  78883. /**
  78884. * AUTO-GENERATED FILE. DO NOT MODIFY.
  78885. */
  78886. /*
  78887. * Licensed to the Apache Software Foundation (ASF) under one
  78888. * or more contributor license agreements. See the NOTICE file
  78889. * distributed with this work for additional information
  78890. * regarding copyright ownership. The ASF licenses this file
  78891. * to you under the Apache License, Version 2.0 (the
  78892. * "License"); you may not use this file except in compliance
  78893. * with the License. You may obtain a copy of the License at
  78894. *
  78895. * http://www.apache.org/licenses/LICENSE-2.0
  78896. *
  78897. * Unless required by applicable law or agreed to in writing,
  78898. * software distributed under the License is distributed on an
  78899. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78900. * KIND, either express or implied. See the License for the
  78901. * specific language governing permissions and limitations
  78902. * under the License.
  78903. */
  78904. // @ts-nocheck
  78905. function legendSelectActionHandler(methodName, payload, ecModel) {
  78906. var selectedMap = {};
  78907. var isToggleSelect = methodName === 'toggleSelected';
  78908. var isSelected; // Update all legend components
  78909. ecModel.eachComponent('legend', function (legendModel) {
  78910. if (isToggleSelect && isSelected != null) {
  78911. // Force other legend has same selected status
  78912. // Or the first is toggled to true and other are toggled to false
  78913. // In the case one legend has some item unSelected in option. And if other legend
  78914. // doesn't has the item, they will assume it is selected.
  78915. legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
  78916. } else if (methodName === 'allSelect' || methodName === 'inverseSelect') {
  78917. legendModel[methodName]();
  78918. } else {
  78919. legendModel[methodName](payload.name);
  78920. isSelected = legendModel.isSelected(payload.name);
  78921. }
  78922. var legendData = legendModel.getData();
  78923. each$1(legendData, function (model) {
  78924. var name = model.get('name'); // Wrap element
  78925. if (name === '\n' || name === '') {
  78926. return;
  78927. }
  78928. var isItemSelected = legendModel.isSelected(name);
  78929. if (selectedMap.hasOwnProperty(name)) {
  78930. // Unselected if any legend is unselected
  78931. selectedMap[name] = selectedMap[name] && isItemSelected;
  78932. } else {
  78933. selectedMap[name] = isItemSelected;
  78934. }
  78935. });
  78936. }); // Return the event explicitly
  78937. return methodName === 'allSelect' || methodName === 'inverseSelect' ? {
  78938. selected: selectedMap
  78939. } : {
  78940. name: payload.name,
  78941. selected: selectedMap
  78942. };
  78943. }
  78944. function installLegendAction(registers) {
  78945. /**
  78946. * @event legendToggleSelect
  78947. * @type {Object}
  78948. * @property {string} type 'legendToggleSelect'
  78949. * @property {string} [from]
  78950. * @property {string} name Series name or data item name
  78951. */
  78952. registers.registerAction('legendToggleSelect', 'legendselectchanged', curry(legendSelectActionHandler, 'toggleSelected'));
  78953. registers.registerAction('legendAllSelect', 'legendselectall', curry(legendSelectActionHandler, 'allSelect'));
  78954. registers.registerAction('legendInverseSelect', 'legendinverseselect', curry(legendSelectActionHandler, 'inverseSelect'));
  78955. /**
  78956. * @event legendSelect
  78957. * @type {Object}
  78958. * @property {string} type 'legendSelect'
  78959. * @property {string} name Series name or data item name
  78960. */
  78961. registers.registerAction('legendSelect', 'legendselected', curry(legendSelectActionHandler, 'select'));
  78962. /**
  78963. * @event legendUnSelect
  78964. * @type {Object}
  78965. * @property {string} type 'legendUnSelect'
  78966. * @property {string} name Series name or data item name
  78967. */
  78968. registers.registerAction('legendUnSelect', 'legendunselected', curry(legendSelectActionHandler, 'unSelect'));
  78969. }
  78970. /*
  78971. * Licensed to the Apache Software Foundation (ASF) under one
  78972. * or more contributor license agreements. See the NOTICE file
  78973. * distributed with this work for additional information
  78974. * regarding copyright ownership. The ASF licenses this file
  78975. * to you under the Apache License, Version 2.0 (the
  78976. * "License"); you may not use this file except in compliance
  78977. * with the License. You may obtain a copy of the License at
  78978. *
  78979. * http://www.apache.org/licenses/LICENSE-2.0
  78980. *
  78981. * Unless required by applicable law or agreed to in writing,
  78982. * software distributed under the License is distributed on an
  78983. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  78984. * KIND, either express or implied. See the License for the
  78985. * specific language governing permissions and limitations
  78986. * under the License.
  78987. */
  78988. /**
  78989. * AUTO-GENERATED FILE. DO NOT MODIFY.
  78990. */
  78991. /*
  78992. * Licensed to the Apache Software Foundation (ASF) under one
  78993. * or more contributor license agreements. See the NOTICE file
  78994. * distributed with this work for additional information
  78995. * regarding copyright ownership. The ASF licenses this file
  78996. * to you under the Apache License, Version 2.0 (the
  78997. * "License"); you may not use this file except in compliance
  78998. * with the License. You may obtain a copy of the License at
  78999. *
  79000. * http://www.apache.org/licenses/LICENSE-2.0
  79001. *
  79002. * Unless required by applicable law or agreed to in writing,
  79003. * software distributed under the License is distributed on an
  79004. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79005. * KIND, either express or implied. See the License for the
  79006. * specific language governing permissions and limitations
  79007. * under the License.
  79008. */
  79009. function install$34(registers) {
  79010. registers.registerComponentModel(LegendModel);
  79011. registers.registerComponentView(LegendView);
  79012. registers.registerProcessor(registers.PRIORITY.PROCESSOR.SERIES_FILTER, legendFilter);
  79013. registers.registerSubTypeDefaulter('legend', function () {
  79014. return 'plain';
  79015. });
  79016. installLegendAction(registers);
  79017. }
  79018. /*
  79019. * Licensed to the Apache Software Foundation (ASF) under one
  79020. * or more contributor license agreements. See the NOTICE file
  79021. * distributed with this work for additional information
  79022. * regarding copyright ownership. The ASF licenses this file
  79023. * to you under the Apache License, Version 2.0 (the
  79024. * "License"); you may not use this file except in compliance
  79025. * with the License. You may obtain a copy of the License at
  79026. *
  79027. * http://www.apache.org/licenses/LICENSE-2.0
  79028. *
  79029. * Unless required by applicable law or agreed to in writing,
  79030. * software distributed under the License is distributed on an
  79031. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79032. * KIND, either express or implied. See the License for the
  79033. * specific language governing permissions and limitations
  79034. * under the License.
  79035. */
  79036. /**
  79037. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79038. */
  79039. /*
  79040. * Licensed to the Apache Software Foundation (ASF) under one
  79041. * or more contributor license agreements. See the NOTICE file
  79042. * distributed with this work for additional information
  79043. * regarding copyright ownership. The ASF licenses this file
  79044. * to you under the Apache License, Version 2.0 (the
  79045. * "License"); you may not use this file except in compliance
  79046. * with the License. You may obtain a copy of the License at
  79047. *
  79048. * http://www.apache.org/licenses/LICENSE-2.0
  79049. *
  79050. * Unless required by applicable law or agreed to in writing,
  79051. * software distributed under the License is distributed on an
  79052. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79053. * KIND, either express or implied. See the License for the
  79054. * specific language governing permissions and limitations
  79055. * under the License.
  79056. */
  79057. var ScrollableLegendModel =
  79058. /** @class */
  79059. function (_super) {
  79060. __extends(ScrollableLegendModel, _super);
  79061. function ScrollableLegendModel() {
  79062. var _this = _super !== null && _super.apply(this, arguments) || this;
  79063. _this.type = ScrollableLegendModel.type;
  79064. return _this;
  79065. }
  79066. /**
  79067. * @param {number} scrollDataIndex
  79068. */
  79069. ScrollableLegendModel.prototype.setScrollDataIndex = function (scrollDataIndex) {
  79070. this.option.scrollDataIndex = scrollDataIndex;
  79071. };
  79072. ScrollableLegendModel.prototype.init = function (option, parentModel, ecModel) {
  79073. var inputPositionParams = getLayoutParams(option);
  79074. _super.prototype.init.call(this, option, parentModel, ecModel);
  79075. mergeAndNormalizeLayoutParams$1(this, option, inputPositionParams);
  79076. };
  79077. /**
  79078. * @override
  79079. */
  79080. ScrollableLegendModel.prototype.mergeOption = function (option, ecModel) {
  79081. _super.prototype.mergeOption.call(this, option, ecModel);
  79082. mergeAndNormalizeLayoutParams$1(this, this.option, option);
  79083. };
  79084. ScrollableLegendModel.type = 'legend.scroll';
  79085. ScrollableLegendModel.defaultOption = inheritDefaultOption(LegendModel.defaultOption, {
  79086. scrollDataIndex: 0,
  79087. pageButtonItemGap: 5,
  79088. pageButtonGap: null,
  79089. pageButtonPosition: 'end',
  79090. pageFormatter: '{current}/{total}',
  79091. pageIcons: {
  79092. horizontal: ['M0,0L12,-10L12,10z', 'M0,0L-12,-10L-12,10z'],
  79093. vertical: ['M0,0L20,0L10,-20z', 'M0,0L20,0L10,20z']
  79094. },
  79095. pageIconColor: '#2f4554',
  79096. pageIconInactiveColor: '#aaa',
  79097. pageIconSize: 15,
  79098. pageTextStyle: {
  79099. color: '#333'
  79100. },
  79101. animationDurationUpdate: 800
  79102. });
  79103. return ScrollableLegendModel;
  79104. }(LegendModel); // Do not `ignoreSize` to enable setting {left: 10, right: 10}.
  79105. function mergeAndNormalizeLayoutParams$1(legendModel, target, raw) {
  79106. var orient = legendModel.getOrient();
  79107. var ignoreSize = [1, 1];
  79108. ignoreSize[orient.index] = 0;
  79109. mergeLayoutParam(target, raw, {
  79110. type: 'box',
  79111. ignoreSize: !!ignoreSize
  79112. });
  79113. }
  79114. /*
  79115. * Licensed to the Apache Software Foundation (ASF) under one
  79116. * or more contributor license agreements. See the NOTICE file
  79117. * distributed with this work for additional information
  79118. * regarding copyright ownership. The ASF licenses this file
  79119. * to you under the Apache License, Version 2.0 (the
  79120. * "License"); you may not use this file except in compliance
  79121. * with the License. You may obtain a copy of the License at
  79122. *
  79123. * http://www.apache.org/licenses/LICENSE-2.0
  79124. *
  79125. * Unless required by applicable law or agreed to in writing,
  79126. * software distributed under the License is distributed on an
  79127. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79128. * KIND, either express or implied. See the License for the
  79129. * specific language governing permissions and limitations
  79130. * under the License.
  79131. */
  79132. /**
  79133. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79134. */
  79135. /*
  79136. * Licensed to the Apache Software Foundation (ASF) under one
  79137. * or more contributor license agreements. See the NOTICE file
  79138. * distributed with this work for additional information
  79139. * regarding copyright ownership. The ASF licenses this file
  79140. * to you under the Apache License, Version 2.0 (the
  79141. * "License"); you may not use this file except in compliance
  79142. * with the License. You may obtain a copy of the License at
  79143. *
  79144. * http://www.apache.org/licenses/LICENSE-2.0
  79145. *
  79146. * Unless required by applicable law or agreed to in writing,
  79147. * software distributed under the License is distributed on an
  79148. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79149. * KIND, either express or implied. See the License for the
  79150. * specific language governing permissions and limitations
  79151. * under the License.
  79152. */
  79153. /**
  79154. * Separate legend and scrollable legend to reduce package size.
  79155. */
  79156. var Group$4 = Group;
  79157. var WH$1 = ['width', 'height'];
  79158. var XY$1 = ['x', 'y'];
  79159. var ScrollableLegendView =
  79160. /** @class */
  79161. function (_super) {
  79162. __extends(ScrollableLegendView, _super);
  79163. function ScrollableLegendView() {
  79164. var _this = _super !== null && _super.apply(this, arguments) || this;
  79165. _this.type = ScrollableLegendView.type;
  79166. _this.newlineDisabled = true;
  79167. _this._currentIndex = 0;
  79168. return _this;
  79169. }
  79170. ScrollableLegendView.prototype.init = function () {
  79171. _super.prototype.init.call(this);
  79172. this.group.add(this._containerGroup = new Group$4());
  79173. this._containerGroup.add(this.getContentGroup());
  79174. this.group.add(this._controllerGroup = new Group$4());
  79175. };
  79176. /**
  79177. * @override
  79178. */
  79179. ScrollableLegendView.prototype.resetInner = function () {
  79180. _super.prototype.resetInner.call(this);
  79181. this._controllerGroup.removeAll();
  79182. this._containerGroup.removeClipPath();
  79183. this._containerGroup.__rectSize = null;
  79184. };
  79185. /**
  79186. * @override
  79187. */
  79188. ScrollableLegendView.prototype.renderInner = function (itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition) {
  79189. var self = this; // Render content items.
  79190. _super.prototype.renderInner.call(this, itemAlign, legendModel, ecModel, api, selector, orient, selectorPosition);
  79191. var controllerGroup = this._controllerGroup; // FIXME: support be 'auto' adapt to size number text length,
  79192. // e.g., '3/12345' should not overlap with the control arrow button.
  79193. var pageIconSize = legendModel.get('pageIconSize', true);
  79194. var pageIconSizeArr = isArray(pageIconSize) ? pageIconSize : [pageIconSize, pageIconSize];
  79195. createPageButton('pagePrev', 0);
  79196. var pageTextStyleModel = legendModel.getModel('pageTextStyle');
  79197. controllerGroup.add(new ZRText({
  79198. name: 'pageText',
  79199. style: {
  79200. // Placeholder to calculate a proper layout.
  79201. text: 'xx/xx',
  79202. fill: pageTextStyleModel.getTextColor(),
  79203. font: pageTextStyleModel.getFont(),
  79204. verticalAlign: 'middle',
  79205. align: 'center'
  79206. },
  79207. silent: true
  79208. }));
  79209. createPageButton('pageNext', 1);
  79210. function createPageButton(name, iconIdx) {
  79211. var pageDataIndexName = name + 'DataIndex';
  79212. var icon = createIcon(legendModel.get('pageIcons', true)[legendModel.getOrient().name][iconIdx], {
  79213. // Buttons will be created in each render, so we do not need
  79214. // to worry about avoiding using legendModel kept in scope.
  79215. onclick: bind(self._pageGo, self, pageDataIndexName, legendModel, api)
  79216. }, {
  79217. x: -pageIconSizeArr[0] / 2,
  79218. y: -pageIconSizeArr[1] / 2,
  79219. width: pageIconSizeArr[0],
  79220. height: pageIconSizeArr[1]
  79221. });
  79222. icon.name = name;
  79223. controllerGroup.add(icon);
  79224. }
  79225. };
  79226. /**
  79227. * @override
  79228. */
  79229. ScrollableLegendView.prototype.layoutInner = function (legendModel, itemAlign, maxSize, isFirstRender, selector, selectorPosition) {
  79230. var selectorGroup = this.getSelectorGroup();
  79231. var orientIdx = legendModel.getOrient().index;
  79232. var wh = WH$1[orientIdx];
  79233. var xy = XY$1[orientIdx];
  79234. var hw = WH$1[1 - orientIdx];
  79235. var yx = XY$1[1 - orientIdx];
  79236. selector && box( // Buttons in selectorGroup always layout horizontally
  79237. 'horizontal', selectorGroup, legendModel.get('selectorItemGap', true));
  79238. var selectorButtonGap = legendModel.get('selectorButtonGap', true);
  79239. var selectorRect = selectorGroup.getBoundingRect();
  79240. var selectorPos = [-selectorRect.x, -selectorRect.y];
  79241. var processMaxSize = clone(maxSize);
  79242. selector && (processMaxSize[wh] = maxSize[wh] - selectorRect[wh] - selectorButtonGap);
  79243. var mainRect = this._layoutContentAndController(legendModel, isFirstRender, processMaxSize, orientIdx, wh, hw, yx, xy);
  79244. if (selector) {
  79245. if (selectorPosition === 'end') {
  79246. selectorPos[orientIdx] += mainRect[wh] + selectorButtonGap;
  79247. } else {
  79248. var offset = selectorRect[wh] + selectorButtonGap;
  79249. selectorPos[orientIdx] -= offset;
  79250. mainRect[xy] -= offset;
  79251. }
  79252. mainRect[wh] += selectorRect[wh] + selectorButtonGap;
  79253. selectorPos[1 - orientIdx] += mainRect[yx] + mainRect[hw] / 2 - selectorRect[hw] / 2;
  79254. mainRect[hw] = Math.max(mainRect[hw], selectorRect[hw]);
  79255. mainRect[yx] = Math.min(mainRect[yx], selectorRect[yx] + selectorPos[1 - orientIdx]);
  79256. selectorGroup.x = selectorPos[0];
  79257. selectorGroup.y = selectorPos[1];
  79258. selectorGroup.markRedraw();
  79259. }
  79260. return mainRect;
  79261. };
  79262. ScrollableLegendView.prototype._layoutContentAndController = function (legendModel, isFirstRender, maxSize, orientIdx, wh, hw, yx, xy) {
  79263. var contentGroup = this.getContentGroup();
  79264. var containerGroup = this._containerGroup;
  79265. var controllerGroup = this._controllerGroup; // Place items in contentGroup.
  79266. box(legendModel.get('orient'), contentGroup, legendModel.get('itemGap'), !orientIdx ? null : maxSize.width, orientIdx ? null : maxSize.height);
  79267. box( // Buttons in controller are layout always horizontally.
  79268. 'horizontal', controllerGroup, legendModel.get('pageButtonItemGap', true));
  79269. var contentRect = contentGroup.getBoundingRect();
  79270. var controllerRect = controllerGroup.getBoundingRect();
  79271. var showController = this._showController = contentRect[wh] > maxSize[wh]; // In case that the inner elements of contentGroup layout do not based on [0, 0]
  79272. var contentPos = [-contentRect.x, -contentRect.y]; // Remain contentPos when scroll animation perfroming.
  79273. // If first rendering, `contentGroup.position` is [0, 0], which
  79274. // does not make sense and may cause unexepcted animation if adopted.
  79275. if (!isFirstRender) {
  79276. contentPos[orientIdx] = contentGroup[xy];
  79277. } // Layout container group based on 0.
  79278. var containerPos = [0, 0];
  79279. var controllerPos = [-controllerRect.x, -controllerRect.y];
  79280. var pageButtonGap = retrieve2(legendModel.get('pageButtonGap', true), legendModel.get('itemGap', true)); // Place containerGroup and controllerGroup and contentGroup.
  79281. if (showController) {
  79282. var pageButtonPosition = legendModel.get('pageButtonPosition', true); // controller is on the right / bottom.
  79283. if (pageButtonPosition === 'end') {
  79284. controllerPos[orientIdx] += maxSize[wh] - controllerRect[wh];
  79285. } // controller is on the left / top.
  79286. else {
  79287. containerPos[orientIdx] += controllerRect[wh] + pageButtonGap;
  79288. }
  79289. } // Always align controller to content as 'middle'.
  79290. controllerPos[1 - orientIdx] += contentRect[hw] / 2 - controllerRect[hw] / 2;
  79291. contentGroup.setPosition(contentPos);
  79292. containerGroup.setPosition(containerPos);
  79293. controllerGroup.setPosition(controllerPos); // Calculate `mainRect` and set `clipPath`.
  79294. // mainRect should not be calculated by `this.group.getBoundingRect()`
  79295. // for sake of the overflow.
  79296. var mainRect = {
  79297. x: 0,
  79298. y: 0
  79299. }; // Consider content may be overflow (should be clipped).
  79300. mainRect[wh] = showController ? maxSize[wh] : contentRect[wh];
  79301. mainRect[hw] = Math.max(contentRect[hw], controllerRect[hw]); // `containerRect[yx] + containerPos[1 - orientIdx]` is 0.
  79302. mainRect[yx] = Math.min(0, controllerRect[yx] + controllerPos[1 - orientIdx]);
  79303. containerGroup.__rectSize = maxSize[wh];
  79304. if (showController) {
  79305. var clipShape = {
  79306. x: 0,
  79307. y: 0
  79308. };
  79309. clipShape[wh] = Math.max(maxSize[wh] - controllerRect[wh] - pageButtonGap, 0);
  79310. clipShape[hw] = mainRect[hw];
  79311. containerGroup.setClipPath(new Rect({
  79312. shape: clipShape
  79313. })); // Consider content may be larger than container, container rect
  79314. // can not be obtained from `containerGroup.getBoundingRect()`.
  79315. containerGroup.__rectSize = clipShape[wh];
  79316. } else {
  79317. // Do not remove or ignore controller. Keep them set as placeholders.
  79318. controllerGroup.eachChild(function (child) {
  79319. child.attr({
  79320. invisible: true,
  79321. silent: true
  79322. });
  79323. });
  79324. } // Content translate animation.
  79325. var pageInfo = this._getPageInfo(legendModel);
  79326. pageInfo.pageIndex != null && updateProps(contentGroup, {
  79327. x: pageInfo.contentPosition[0],
  79328. y: pageInfo.contentPosition[1]
  79329. }, // When switch from "show controller" to "not show controller", view should be
  79330. // updated immediately without animation, otherwise causes weird effect.
  79331. showController ? legendModel : null);
  79332. this._updatePageInfoView(legendModel, pageInfo);
  79333. return mainRect;
  79334. };
  79335. ScrollableLegendView.prototype._pageGo = function (to, legendModel, api) {
  79336. var scrollDataIndex = this._getPageInfo(legendModel)[to];
  79337. scrollDataIndex != null && api.dispatchAction({
  79338. type: 'legendScroll',
  79339. scrollDataIndex: scrollDataIndex,
  79340. legendId: legendModel.id
  79341. });
  79342. };
  79343. ScrollableLegendView.prototype._updatePageInfoView = function (legendModel, pageInfo) {
  79344. var controllerGroup = this._controllerGroup;
  79345. each$1(['pagePrev', 'pageNext'], function (name) {
  79346. var key = name + 'DataIndex';
  79347. var canJump = pageInfo[key] != null;
  79348. var icon = controllerGroup.childOfName(name);
  79349. if (icon) {
  79350. icon.setStyle('fill', canJump ? legendModel.get('pageIconColor', true) : legendModel.get('pageIconInactiveColor', true));
  79351. icon.cursor = canJump ? 'pointer' : 'default';
  79352. }
  79353. });
  79354. var pageText = controllerGroup.childOfName('pageText');
  79355. var pageFormatter = legendModel.get('pageFormatter');
  79356. var pageIndex = pageInfo.pageIndex;
  79357. var current = pageIndex != null ? pageIndex + 1 : 0;
  79358. var total = pageInfo.pageCount;
  79359. pageText && pageFormatter && pageText.setStyle('text', isString(pageFormatter) ? pageFormatter.replace('{current}', current == null ? '' : current + '').replace('{total}', total == null ? '' : total + '') : pageFormatter({
  79360. current: current,
  79361. total: total
  79362. }));
  79363. };
  79364. /**
  79365. * contentPosition: Array.<number>, null when data item not found.
  79366. * pageIndex: number, null when data item not found.
  79367. * pageCount: number, always be a number, can be 0.
  79368. * pagePrevDataIndex: number, null when no previous page.
  79369. * pageNextDataIndex: number, null when no next page.
  79370. * }
  79371. */
  79372. ScrollableLegendView.prototype._getPageInfo = function (legendModel) {
  79373. var scrollDataIndex = legendModel.get('scrollDataIndex', true);
  79374. var contentGroup = this.getContentGroup();
  79375. var containerRectSize = this._containerGroup.__rectSize;
  79376. var orientIdx = legendModel.getOrient().index;
  79377. var wh = WH$1[orientIdx];
  79378. var xy = XY$1[orientIdx];
  79379. var targetItemIndex = this._findTargetItemIndex(scrollDataIndex);
  79380. var children = contentGroup.children();
  79381. var targetItem = children[targetItemIndex];
  79382. var itemCount = children.length;
  79383. var pCount = !itemCount ? 0 : 1;
  79384. var result = {
  79385. contentPosition: [contentGroup.x, contentGroup.y],
  79386. pageCount: pCount,
  79387. pageIndex: pCount - 1,
  79388. pagePrevDataIndex: null,
  79389. pageNextDataIndex: null
  79390. };
  79391. if (!targetItem) {
  79392. return result;
  79393. }
  79394. var targetItemInfo = getItemInfo(targetItem);
  79395. result.contentPosition[orientIdx] = -targetItemInfo.s; // Strategy:
  79396. // (1) Always align based on the left/top most item.
  79397. // (2) It is user-friendly that the last item shown in the
  79398. // current window is shown at the begining of next window.
  79399. // Otherwise if half of the last item is cut by the window,
  79400. // it will have no chance to display entirely.
  79401. // (3) Consider that item size probably be different, we
  79402. // have calculate pageIndex by size rather than item index,
  79403. // and we can not get page index directly by division.
  79404. // (4) The window is to narrow to contain more than
  79405. // one item, we should make sure that the page can be fliped.
  79406. for (var i = targetItemIndex + 1, winStartItemInfo = targetItemInfo, winEndItemInfo = targetItemInfo, currItemInfo = null; i <= itemCount; ++i) {
  79407. currItemInfo = getItemInfo(children[i]);
  79408. if ( // Half of the last item is out of the window.
  79409. !currItemInfo && winEndItemInfo.e > winStartItemInfo.s + containerRectSize || // If the current item does not intersect with the window, the new page
  79410. // can be started at the current item or the last item.
  79411. currItemInfo && !intersect(currItemInfo, winStartItemInfo.s)) {
  79412. if (winEndItemInfo.i > winStartItemInfo.i) {
  79413. winStartItemInfo = winEndItemInfo;
  79414. } else {
  79415. // e.g., when page size is smaller than item size.
  79416. winStartItemInfo = currItemInfo;
  79417. }
  79418. if (winStartItemInfo) {
  79419. if (result.pageNextDataIndex == null) {
  79420. result.pageNextDataIndex = winStartItemInfo.i;
  79421. }
  79422. ++result.pageCount;
  79423. }
  79424. }
  79425. winEndItemInfo = currItemInfo;
  79426. }
  79427. for (var i = targetItemIndex - 1, winStartItemInfo = targetItemInfo, winEndItemInfo = targetItemInfo, currItemInfo = null; i >= -1; --i) {
  79428. currItemInfo = getItemInfo(children[i]);
  79429. if ( // If the the end item does not intersect with the window started
  79430. // from the current item, a page can be settled.
  79431. (!currItemInfo || !intersect(winEndItemInfo, currItemInfo.s)) && // e.g., when page size is smaller than item size.
  79432. winStartItemInfo.i < winEndItemInfo.i) {
  79433. winEndItemInfo = winStartItemInfo;
  79434. if (result.pagePrevDataIndex == null) {
  79435. result.pagePrevDataIndex = winStartItemInfo.i;
  79436. }
  79437. ++result.pageCount;
  79438. ++result.pageIndex;
  79439. }
  79440. winStartItemInfo = currItemInfo;
  79441. }
  79442. return result;
  79443. function getItemInfo(el) {
  79444. if (el) {
  79445. var itemRect = el.getBoundingRect();
  79446. var start = itemRect[xy] + el[xy];
  79447. return {
  79448. s: start,
  79449. e: start + itemRect[wh],
  79450. i: el.__legendDataIndex
  79451. };
  79452. }
  79453. }
  79454. function intersect(itemInfo, winStart) {
  79455. return itemInfo.e >= winStart && itemInfo.s <= winStart + containerRectSize;
  79456. }
  79457. };
  79458. ScrollableLegendView.prototype._findTargetItemIndex = function (targetDataIndex) {
  79459. if (!this._showController) {
  79460. return 0;
  79461. }
  79462. var index;
  79463. var contentGroup = this.getContentGroup();
  79464. var defaultIndex;
  79465. contentGroup.eachChild(function (child, idx) {
  79466. var legendDataIdx = child.__legendDataIndex; // FIXME
  79467. // If the given targetDataIndex (from model) is illegal,
  79468. // we use defaultIndex. But the index on the legend model and
  79469. // action payload is still illegal. That case will not be
  79470. // changed until some scenario requires.
  79471. if (defaultIndex == null && legendDataIdx != null) {
  79472. defaultIndex = idx;
  79473. }
  79474. if (legendDataIdx === targetDataIndex) {
  79475. index = idx;
  79476. }
  79477. });
  79478. return index != null ? index : defaultIndex;
  79479. };
  79480. ScrollableLegendView.type = 'legend.scroll';
  79481. return ScrollableLegendView;
  79482. }(LegendView);
  79483. /*
  79484. * Licensed to the Apache Software Foundation (ASF) under one
  79485. * or more contributor license agreements. See the NOTICE file
  79486. * distributed with this work for additional information
  79487. * regarding copyright ownership. The ASF licenses this file
  79488. * to you under the Apache License, Version 2.0 (the
  79489. * "License"); you may not use this file except in compliance
  79490. * with the License. You may obtain a copy of the License at
  79491. *
  79492. * http://www.apache.org/licenses/LICENSE-2.0
  79493. *
  79494. * Unless required by applicable law or agreed to in writing,
  79495. * software distributed under the License is distributed on an
  79496. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79497. * KIND, either express or implied. See the License for the
  79498. * specific language governing permissions and limitations
  79499. * under the License.
  79500. */
  79501. /**
  79502. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79503. */
  79504. /*
  79505. * Licensed to the Apache Software Foundation (ASF) under one
  79506. * or more contributor license agreements. See the NOTICE file
  79507. * distributed with this work for additional information
  79508. * regarding copyright ownership. The ASF licenses this file
  79509. * to you under the Apache License, Version 2.0 (the
  79510. * "License"); you may not use this file except in compliance
  79511. * with the License. You may obtain a copy of the License at
  79512. *
  79513. * http://www.apache.org/licenses/LICENSE-2.0
  79514. *
  79515. * Unless required by applicable law or agreed to in writing,
  79516. * software distributed under the License is distributed on an
  79517. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79518. * KIND, either express or implied. See the License for the
  79519. * specific language governing permissions and limitations
  79520. * under the License.
  79521. */
  79522. function installScrollableLegendAction(registers) {
  79523. /**
  79524. * @event legendScroll
  79525. * @type {Object}
  79526. * @property {string} type 'legendScroll'
  79527. * @property {string} scrollDataIndex
  79528. */
  79529. registers.registerAction('legendScroll', 'legendscroll', function (payload, ecModel) {
  79530. var scrollDataIndex = payload.scrollDataIndex;
  79531. scrollDataIndex != null && ecModel.eachComponent({
  79532. mainType: 'legend',
  79533. subType: 'scroll',
  79534. query: payload
  79535. }, function (legendModel) {
  79536. legendModel.setScrollDataIndex(scrollDataIndex);
  79537. });
  79538. });
  79539. }
  79540. /*
  79541. * Licensed to the Apache Software Foundation (ASF) under one
  79542. * or more contributor license agreements. See the NOTICE file
  79543. * distributed with this work for additional information
  79544. * regarding copyright ownership. The ASF licenses this file
  79545. * to you under the Apache License, Version 2.0 (the
  79546. * "License"); you may not use this file except in compliance
  79547. * with the License. You may obtain a copy of the License at
  79548. *
  79549. * http://www.apache.org/licenses/LICENSE-2.0
  79550. *
  79551. * Unless required by applicable law or agreed to in writing,
  79552. * software distributed under the License is distributed on an
  79553. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79554. * KIND, either express or implied. See the License for the
  79555. * specific language governing permissions and limitations
  79556. * under the License.
  79557. */
  79558. /**
  79559. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79560. */
  79561. /*
  79562. * Licensed to the Apache Software Foundation (ASF) under one
  79563. * or more contributor license agreements. See the NOTICE file
  79564. * distributed with this work for additional information
  79565. * regarding copyright ownership. The ASF licenses this file
  79566. * to you under the Apache License, Version 2.0 (the
  79567. * "License"); you may not use this file except in compliance
  79568. * with the License. You may obtain a copy of the License at
  79569. *
  79570. * http://www.apache.org/licenses/LICENSE-2.0
  79571. *
  79572. * Unless required by applicable law or agreed to in writing,
  79573. * software distributed under the License is distributed on an
  79574. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79575. * KIND, either express or implied. See the License for the
  79576. * specific language governing permissions and limitations
  79577. * under the License.
  79578. */
  79579. function install$33(registers) {
  79580. use(install$34);
  79581. registers.registerComponentModel(ScrollableLegendModel);
  79582. registers.registerComponentView(ScrollableLegendView);
  79583. installScrollableLegendAction(registers);
  79584. }
  79585. /*
  79586. * Licensed to the Apache Software Foundation (ASF) under one
  79587. * or more contributor license agreements. See the NOTICE file
  79588. * distributed with this work for additional information
  79589. * regarding copyright ownership. The ASF licenses this file
  79590. * to you under the Apache License, Version 2.0 (the
  79591. * "License"); you may not use this file except in compliance
  79592. * with the License. You may obtain a copy of the License at
  79593. *
  79594. * http://www.apache.org/licenses/LICENSE-2.0
  79595. *
  79596. * Unless required by applicable law or agreed to in writing,
  79597. * software distributed under the License is distributed on an
  79598. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79599. * KIND, either express or implied. See the License for the
  79600. * specific language governing permissions and limitations
  79601. * under the License.
  79602. */
  79603. /**
  79604. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79605. */
  79606. /*
  79607. * Licensed to the Apache Software Foundation (ASF) under one
  79608. * or more contributor license agreements. See the NOTICE file
  79609. * distributed with this work for additional information
  79610. * regarding copyright ownership. The ASF licenses this file
  79611. * to you under the Apache License, Version 2.0 (the
  79612. * "License"); you may not use this file except in compliance
  79613. * with the License. You may obtain a copy of the License at
  79614. *
  79615. * http://www.apache.org/licenses/LICENSE-2.0
  79616. *
  79617. * Unless required by applicable law or agreed to in writing,
  79618. * software distributed under the License is distributed on an
  79619. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79620. * KIND, either express or implied. See the License for the
  79621. * specific language governing permissions and limitations
  79622. * under the License.
  79623. */
  79624. /**
  79625. * Legend component entry file8
  79626. */
  79627. use(install$33);
  79628. /*
  79629. * Licensed to the Apache Software Foundation (ASF) under one
  79630. * or more contributor license agreements. See the NOTICE file
  79631. * distributed with this work for additional information
  79632. * regarding copyright ownership. The ASF licenses this file
  79633. * to you under the Apache License, Version 2.0 (the
  79634. * "License"); you may not use this file except in compliance
  79635. * with the License. You may obtain a copy of the License at
  79636. *
  79637. * http://www.apache.org/licenses/LICENSE-2.0
  79638. *
  79639. * Unless required by applicable law or agreed to in writing,
  79640. * software distributed under the License is distributed on an
  79641. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79642. * KIND, either express or implied. See the License for the
  79643. * specific language governing permissions and limitations
  79644. * under the License.
  79645. */
  79646. /**
  79647. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79648. */
  79649. /*
  79650. * Licensed to the Apache Software Foundation (ASF) under one
  79651. * or more contributor license agreements. See the NOTICE file
  79652. * distributed with this work for additional information
  79653. * regarding copyright ownership. The ASF licenses this file
  79654. * to you under the Apache License, Version 2.0 (the
  79655. * "License"); you may not use this file except in compliance
  79656. * with the License. You may obtain a copy of the License at
  79657. *
  79658. * http://www.apache.org/licenses/LICENSE-2.0
  79659. *
  79660. * Unless required by applicable law or agreed to in writing,
  79661. * software distributed under the License is distributed on an
  79662. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79663. * KIND, either express or implied. See the License for the
  79664. * specific language governing permissions and limitations
  79665. * under the License.
  79666. */
  79667. var TooltipModel =
  79668. /** @class */
  79669. function (_super) {
  79670. __extends(TooltipModel, _super);
  79671. function TooltipModel() {
  79672. var _this = _super !== null && _super.apply(this, arguments) || this;
  79673. _this.type = TooltipModel.type;
  79674. return _this;
  79675. }
  79676. TooltipModel.type = 'tooltip';
  79677. TooltipModel.dependencies = ['axisPointer'];
  79678. TooltipModel.defaultOption = {
  79679. zlevel: 0,
  79680. z: 60,
  79681. show: true,
  79682. // tooltip main content
  79683. showContent: true,
  79684. // 'trigger' only works on coordinate system.
  79685. // 'item' | 'axis' | 'none'
  79686. trigger: 'item',
  79687. // 'click' | 'mousemove' | 'none'
  79688. triggerOn: 'mousemove|click',
  79689. alwaysShowContent: false,
  79690. displayMode: 'single',
  79691. renderMode: 'auto',
  79692. // whether restraint content inside viewRect.
  79693. // If renderMode: 'richText', default true.
  79694. // If renderMode: 'html', defaut false (for backward compat).
  79695. confine: null,
  79696. showDelay: 0,
  79697. hideDelay: 100,
  79698. // Animation transition time, unit is second
  79699. transitionDuration: 0.4,
  79700. enterable: false,
  79701. backgroundColor: '#fff',
  79702. // box shadow
  79703. shadowBlur: 10,
  79704. shadowColor: 'rgba(0, 0, 0, .2)',
  79705. shadowOffsetX: 1,
  79706. shadowOffsetY: 2,
  79707. // tooltip border radius, unit is px, default is 4
  79708. borderRadius: 4,
  79709. // tooltip border width, unit is px, default is 0 (no border)
  79710. borderWidth: 1,
  79711. // Tooltip inside padding, default is 5 for all direction
  79712. // Array is allowed to set up, right, bottom, left, same with css
  79713. // The default value: See `tooltip/tooltipMarkup.ts#getPaddingFromTooltipModel`.
  79714. padding: null,
  79715. // Extra css text
  79716. extraCssText: '',
  79717. // axis indicator, trigger by axis
  79718. axisPointer: {
  79719. // default is line
  79720. // legal values: 'line' | 'shadow' | 'cross'
  79721. type: 'line',
  79722. // Valid when type is line, appoint tooltip line locate on which line. Optional
  79723. // legal values: 'x' | 'y' | 'angle' | 'radius' | 'auto'
  79724. // default is 'auto', chose the axis which type is category.
  79725. // for multiply y axis, cartesian coord chose x axis, polar chose angle axis
  79726. axis: 'auto',
  79727. animation: 'auto',
  79728. animationDurationUpdate: 200,
  79729. animationEasingUpdate: 'exponentialOut',
  79730. crossStyle: {
  79731. color: '#999',
  79732. width: 1,
  79733. type: 'dashed',
  79734. // TODO formatter
  79735. textStyle: {}
  79736. } // lineStyle and shadowStyle should not be specified here,
  79737. // otherwise it will always override those styles on option.axisPointer.
  79738. },
  79739. textStyle: {
  79740. color: '#666',
  79741. fontSize: 14
  79742. }
  79743. };
  79744. return TooltipModel;
  79745. }(ComponentModel);
  79746. /*
  79747. * Licensed to the Apache Software Foundation (ASF) under one
  79748. * or more contributor license agreements. See the NOTICE file
  79749. * distributed with this work for additional information
  79750. * regarding copyright ownership. The ASF licenses this file
  79751. * to you under the Apache License, Version 2.0 (the
  79752. * "License"); you may not use this file except in compliance
  79753. * with the License. You may obtain a copy of the License at
  79754. *
  79755. * http://www.apache.org/licenses/LICENSE-2.0
  79756. *
  79757. * Unless required by applicable law or agreed to in writing,
  79758. * software distributed under the License is distributed on an
  79759. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79760. * KIND, either express or implied. See the License for the
  79761. * specific language governing permissions and limitations
  79762. * under the License.
  79763. */
  79764. /**
  79765. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79766. */
  79767. /*
  79768. * Licensed to the Apache Software Foundation (ASF) under one
  79769. * or more contributor license agreements. See the NOTICE file
  79770. * distributed with this work for additional information
  79771. * regarding copyright ownership. The ASF licenses this file
  79772. * to you under the Apache License, Version 2.0 (the
  79773. * "License"); you may not use this file except in compliance
  79774. * with the License. You may obtain a copy of the License at
  79775. *
  79776. * http://www.apache.org/licenses/LICENSE-2.0
  79777. *
  79778. * Unless required by applicable law or agreed to in writing,
  79779. * software distributed under the License is distributed on an
  79780. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79781. * KIND, either express or implied. See the License for the
  79782. * specific language governing permissions and limitations
  79783. * under the License.
  79784. */
  79785. /* global document */
  79786. function shouldTooltipConfine(tooltipModel) {
  79787. var confineOption = tooltipModel.get('confine');
  79788. return confineOption != null ? !!confineOption // In richText mode, the outside part can not be visible.
  79789. : tooltipModel.get('renderMode') === 'richText';
  79790. }
  79791. function testStyle(styleProps) {
  79792. if (!env.domSupported) {
  79793. return;
  79794. }
  79795. var style = document.documentElement.style;
  79796. for (var i = 0, len = styleProps.length; i < len; i++) {
  79797. if (styleProps[i] in style) {
  79798. return styleProps[i];
  79799. }
  79800. }
  79801. }
  79802. var TRANSFORM_VENDOR = testStyle(['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
  79803. var TRANSITION_VENDOR = testStyle(['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);
  79804. function toCSSVendorPrefix(styleVendor, styleProp) {
  79805. if (!styleVendor) {
  79806. return styleProp;
  79807. }
  79808. styleProp = toCamelCase(styleProp, true);
  79809. var idx = styleVendor.indexOf(styleProp);
  79810. styleVendor = idx === -1 ? styleProp : "-" + styleVendor.slice(0, idx) + "-" + styleProp;
  79811. return styleVendor.toLowerCase();
  79812. }
  79813. function getComputedStyle(el, style) {
  79814. var stl = el.currentStyle || document.defaultView && document.defaultView.getComputedStyle(el);
  79815. return stl ? style ? stl[style] : stl : null;
  79816. }
  79817. /*
  79818. * Licensed to the Apache Software Foundation (ASF) under one
  79819. * or more contributor license agreements. See the NOTICE file
  79820. * distributed with this work for additional information
  79821. * regarding copyright ownership. The ASF licenses this file
  79822. * to you under the Apache License, Version 2.0 (the
  79823. * "License"); you may not use this file except in compliance
  79824. * with the License. You may obtain a copy of the License at
  79825. *
  79826. * http://www.apache.org/licenses/LICENSE-2.0
  79827. *
  79828. * Unless required by applicable law or agreed to in writing,
  79829. * software distributed under the License is distributed on an
  79830. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79831. * KIND, either express or implied. See the License for the
  79832. * specific language governing permissions and limitations
  79833. * under the License.
  79834. */
  79835. /**
  79836. * AUTO-GENERATED FILE. DO NOT MODIFY.
  79837. */
  79838. /*
  79839. * Licensed to the Apache Software Foundation (ASF) under one
  79840. * or more contributor license agreements. See the NOTICE file
  79841. * distributed with this work for additional information
  79842. * regarding copyright ownership. The ASF licenses this file
  79843. * to you under the Apache License, Version 2.0 (the
  79844. * "License"); you may not use this file except in compliance
  79845. * with the License. You may obtain a copy of the License at
  79846. *
  79847. * http://www.apache.org/licenses/LICENSE-2.0
  79848. *
  79849. * Unless required by applicable law or agreed to in writing,
  79850. * software distributed under the License is distributed on an
  79851. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  79852. * KIND, either express or implied. See the License for the
  79853. * specific language governing permissions and limitations
  79854. * under the License.
  79855. */
  79856. /* global document, window */
  79857. var CSS_TRANSITION_VENDOR = toCSSVendorPrefix(TRANSITION_VENDOR, 'transition');
  79858. var CSS_TRANSFORM_VENDOR = toCSSVendorPrefix(TRANSFORM_VENDOR, 'transform'); // eslint-disable-next-line
  79859. var gCssText = "position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;" + (env.transform3dSupported ? 'will-change:transform;' : '');
  79860. function mirrorPos(pos) {
  79861. pos = pos === 'left' ? 'right' : pos === 'right' ? 'left' : pos === 'top' ? 'bottom' : 'top';
  79862. return pos;
  79863. }
  79864. function assembleArrow(backgroundColor, borderColor, arrowPosition) {
  79865. if (!isString(arrowPosition) || arrowPosition === 'inside') {
  79866. return '';
  79867. }
  79868. borderColor = convertToColorString(borderColor);
  79869. var arrowPos = mirrorPos(arrowPosition);
  79870. var positionStyle = arrowPos + ":-6px;";
  79871. var transformStyle = CSS_TRANSFORM_VENDOR + ':';
  79872. if (indexOf$1(['left', 'right'], arrowPos) > -1) {
  79873. positionStyle += 'top:50%';
  79874. transformStyle += "translateY(-50%) rotate(" + (arrowPos === 'left' ? -225 : -45) + "deg)";
  79875. } else {
  79876. positionStyle += 'left:50%';
  79877. transformStyle += "translateX(-50%) rotate(" + (arrowPos === 'top' ? 225 : 45) + "deg)";
  79878. }
  79879. var borderStyle = borderColor + " solid 1px;";
  79880. var styleCss = ['position:absolute;width:10px;height:10px;', positionStyle + ";" + transformStyle + ";", "border-bottom:" + borderStyle, "border-right:" + borderStyle, "background-color:" + backgroundColor + ";", 'box-shadow:8px 8px 16px -3px #000;'];
  79881. return "<div style=\"" + styleCss.join('') + "\"></div>";
  79882. }
  79883. function assembleTransition(duration, onlyFade) {
  79884. var transitionCurve = 'cubic-bezier(0.23,1,0.32,1)';
  79885. var transitionOption = " " + duration / 2 + "s " + transitionCurve;
  79886. var transitionText = "opacity" + transitionOption + ",visibility" + transitionOption;
  79887. if (!onlyFade) {
  79888. transitionOption = " " + duration + "s " + transitionCurve;
  79889. transitionText += env.transformSupported ? "," + TRANSFORM_VENDOR + transitionOption : ",left" + transitionOption + ",top" + transitionOption;
  79890. }
  79891. return CSS_TRANSITION_VENDOR + ':' + transitionText;
  79892. }
  79893. function assembleTransform(el, x, y, toString) {
  79894. // If using float on style, the final width of the dom might
  79895. // keep changing slightly while mouse move. So `toFixed(0)` them.
  79896. var x0;
  79897. var y0; // not support transform, use `left` and `top` instead.
  79898. if (!env.transformSupported) {
  79899. x0 = x.toFixed(0);
  79900. y0 = y.toFixed(0);
  79901. return toString ? "top:" + y0 + "px;left:" + x0 + "px;" : [['top', y0 + "px"], ['left', x0 + "px"]];
  79902. } // support transform
  79903. // FIXME: the padding of parent element will affect the position of tooltip
  79904. var stl = getComputedStyle(el.parentElement);
  79905. x0 = (x - parseInt(stl.paddingLeft, 10)).toFixed(0);
  79906. y0 = (y - parseInt(stl.paddingTop, 10)).toFixed(0);
  79907. var is3d = env.transform3dSupported;
  79908. var translate = "translate" + (is3d ? '3d' : '') + "(" + x0 + "px," + y0 + "px" + (is3d ? ',0' : '') + ")";
  79909. return toString ? CSS_TRANSFORM_VENDOR + ':' + translate + ';' : [[TRANSFORM_VENDOR, translate]];
  79910. }
  79911. /**
  79912. * @param {Object} textStyle
  79913. * @return {string}
  79914. * @inner
  79915. */
  79916. function assembleFont(textStyleModel) {
  79917. var cssText = [];
  79918. var fontSize = textStyleModel.get('fontSize');
  79919. var color = textStyleModel.getTextColor();
  79920. color && cssText.push('color:' + color);
  79921. cssText.push('font:' + textStyleModel.getFont());
  79922. fontSize // @ts-ignore, leave it to the tooltip refactor.
  79923. && cssText.push('line-height:' + Math.round(fontSize * 3 / 2) + 'px');
  79924. var shadowColor = textStyleModel.get('textShadowColor');
  79925. var shadowBlur = textStyleModel.get('textShadowBlur') || 0;
  79926. var shadowOffsetX = textStyleModel.get('textShadowOffsetX') || 0;
  79927. var shadowOffsetY = textStyleModel.get('textShadowOffsetY') || 0;
  79928. shadowColor && shadowBlur && cssText.push('text-shadow:' + shadowOffsetX + 'px ' + shadowOffsetY + 'px ' + shadowBlur + 'px ' + shadowColor);
  79929. each$1(['decoration', 'align'], function (name) {
  79930. var val = textStyleModel.get(name);
  79931. val && cssText.push('text-' + name + ':' + val);
  79932. });
  79933. return cssText.join(';');
  79934. }
  79935. function assembleCssText(tooltipModel, enableTransition, onlyFade) {
  79936. var cssText = [];
  79937. var transitionDuration = tooltipModel.get('transitionDuration');
  79938. var backgroundColor = tooltipModel.get('backgroundColor');
  79939. var shadowBlur = tooltipModel.get('shadowBlur');
  79940. var shadowColor = tooltipModel.get('shadowColor');
  79941. var shadowOffsetX = tooltipModel.get('shadowOffsetX');
  79942. var shadowOffsetY = tooltipModel.get('shadowOffsetY');
  79943. var textStyleModel = tooltipModel.getModel('textStyle');
  79944. var padding = getPaddingFromTooltipModel(tooltipModel, 'html');
  79945. var boxShadow = shadowOffsetX + "px " + shadowOffsetY + "px " + shadowBlur + "px " + shadowColor;
  79946. cssText.push('box-shadow:' + boxShadow); // Animation transition. Do not animate when transitionDuration is 0.
  79947. enableTransition && transitionDuration && cssText.push(assembleTransition(transitionDuration, onlyFade));
  79948. if (backgroundColor) {
  79949. if (env.canvasSupported) {
  79950. cssText.push('background-color:' + backgroundColor);
  79951. } else {
  79952. // for ie
  79953. cssText.push('background-color:#' + toHex(backgroundColor));
  79954. cssText.push('filter:alpha(opacity=70)');
  79955. }
  79956. } // Border style
  79957. each$1(['width', 'color', 'radius'], function (name) {
  79958. var borderName = 'border-' + name;
  79959. var camelCase = toCamelCase(borderName);
  79960. var val = tooltipModel.get(camelCase);
  79961. val != null && cssText.push(borderName + ':' + val + (name === 'color' ? '' : 'px'));
  79962. }); // Text style
  79963. cssText.push(assembleFont(textStyleModel)); // Padding
  79964. if (padding != null) {
  79965. cssText.push('padding:' + normalizeCssArray$1(padding).join('px ') + 'px');
  79966. }
  79967. return cssText.join(';') + ';';
  79968. } // If not able to make, do not modify the input `out`.
  79969. function makeStyleCoord(out, zr, appendToBody, zrX, zrY) {
  79970. var zrPainter = zr && zr.painter;
  79971. if (appendToBody) {
  79972. var zrViewportRoot = zrPainter && zrPainter.getViewportRoot();
  79973. if (zrViewportRoot) {
  79974. // Some APPs might use scale on body, so we support CSS transform here.
  79975. transformLocalCoord(out, zrViewportRoot, document.body, zrX, zrY);
  79976. }
  79977. } else {
  79978. out[0] = zrX;
  79979. out[1] = zrY; // xy should be based on canvas root. But tooltipContent is
  79980. // the sibling of canvas root. So padding of ec container
  79981. // should be considered here.
  79982. var viewportRootOffset = zrPainter && zrPainter.getViewportRootOffset();
  79983. if (viewportRootOffset) {
  79984. out[0] += viewportRootOffset.offsetLeft;
  79985. out[1] += viewportRootOffset.offsetTop;
  79986. }
  79987. }
  79988. out[2] = out[0] / zr.getWidth();
  79989. out[3] = out[1] / zr.getHeight();
  79990. }
  79991. var TooltipHTMLContent =
  79992. /** @class */
  79993. function () {
  79994. function TooltipHTMLContent(container, api, opt) {
  79995. this._show = false;
  79996. this._styleCoord = [0, 0, 0, 0];
  79997. this._enterable = true;
  79998. this._firstShow = true;
  79999. this._longHide = true;
  80000. if (env.wxa) {
  80001. return null;
  80002. }
  80003. var el = document.createElement('div'); // TODO: TYPE
  80004. el.domBelongToZr = true;
  80005. this.el = el;
  80006. var zr = this._zr = api.getZr();
  80007. var appendToBody = this._appendToBody = opt && opt.appendToBody;
  80008. makeStyleCoord(this._styleCoord, zr, appendToBody, api.getWidth() / 2, api.getHeight() / 2);
  80009. if (appendToBody) {
  80010. document.body.appendChild(el);
  80011. } else {
  80012. // PENDING
  80013. container.prepend(el);
  80014. }
  80015. this._container = container; // FIXME
  80016. // Is it needed to trigger zr event manually if
  80017. // the browser do not support `pointer-events: none`.
  80018. var self = this;
  80019. el.onmouseenter = function () {
  80020. // clear the timeout in hideLater and keep showing tooltip
  80021. if (self._enterable) {
  80022. clearTimeout(self._hideTimeout);
  80023. self._show = true;
  80024. }
  80025. self._inContent = true;
  80026. };
  80027. el.onmousemove = function (e) {
  80028. e = e || window.event;
  80029. if (!self._enterable) {
  80030. // `pointer-events: none` is set to tooltip content div
  80031. // if `enterable` is set as `false`, and `el.onmousemove`
  80032. // can not be triggered. But in browser that do not
  80033. // support `pointer-events`, we need to do this:
  80034. // Try trigger zrender event to avoid mouse
  80035. // in and out shape too frequently
  80036. var handler = zr.handler;
  80037. var zrViewportRoot = zr.painter.getViewportRoot();
  80038. normalizeEvent(zrViewportRoot, e, true);
  80039. handler.dispatch('mousemove', e);
  80040. }
  80041. };
  80042. el.onmouseleave = function () {
  80043. // set `_inContent` to `false` before `hideLater`
  80044. self._inContent = false;
  80045. if (self._enterable) {
  80046. if (self._show) {
  80047. self.hideLater(self._hideDelay);
  80048. }
  80049. }
  80050. };
  80051. }
  80052. /**
  80053. * Update when tooltip is rendered
  80054. */
  80055. TooltipHTMLContent.prototype.update = function (tooltipModel) {
  80056. // FIXME
  80057. // Move this logic to ec main?
  80058. var container = this._container;
  80059. var position = getComputedStyle(container, 'position');
  80060. var domStyle = container.style;
  80061. if (domStyle.position !== 'absolute' && position !== 'absolute') {
  80062. domStyle.position = 'relative';
  80063. } // move tooltip if chart resized
  80064. var alwaysShowContent = tooltipModel.get('alwaysShowContent');
  80065. alwaysShowContent && this._moveIfResized(); // update className
  80066. this.el.className = tooltipModel.get('className') || ''; // Hide the tooltip
  80067. // PENDING
  80068. // this.hide();
  80069. };
  80070. TooltipHTMLContent.prototype.show = function (tooltipModel, nearPointColor) {
  80071. clearTimeout(this._hideTimeout);
  80072. clearTimeout(this._longHideTimeout);
  80073. var el = this.el;
  80074. var style = el.style;
  80075. var styleCoord = this._styleCoord;
  80076. if (!el.innerHTML) {
  80077. style.display = 'none';
  80078. } else {
  80079. style.cssText = gCssText + assembleCssText(tooltipModel, !this._firstShow, this._longHide) // initial transform
  80080. + assembleTransform(el, styleCoord[0], styleCoord[1], true) + ("border-color:" + convertToColorString(nearPointColor) + ";") + (tooltipModel.get('extraCssText') || '') // If mouse occasionally move over the tooltip, a mouseout event will be
  80081. // triggered by canvas, and cause some unexpectable result like dragging
  80082. // stop, "unfocusAdjacency". Here `pointer-events: none` is used to solve
  80083. // it. Although it is not supported by IE8~IE10, fortunately it is a rare
  80084. // scenario.
  80085. + (";pointer-event:" + (this._enterable ? 'auto' : 'none'));
  80086. }
  80087. this._show = true;
  80088. this._firstShow = false;
  80089. this._longHide = false;
  80090. };
  80091. TooltipHTMLContent.prototype.setContent = function (content, markers, tooltipModel, borderColor, arrowPosition) {
  80092. if (content == null) {
  80093. return;
  80094. }
  80095. var el = this.el;
  80096. if (isString(arrowPosition) && tooltipModel.get('trigger') === 'item' && !shouldTooltipConfine(tooltipModel)) {
  80097. content += assembleArrow(tooltipModel.get('backgroundColor'), borderColor, arrowPosition);
  80098. }
  80099. if (isString(content)) {
  80100. el.innerHTML = content;
  80101. } else if (content) {
  80102. // Clear previous
  80103. el.innerHTML = '';
  80104. if (!isArray(content)) {
  80105. content = [content];
  80106. }
  80107. for (var i = 0; i < content.length; i++) {
  80108. if (isDom(content[i]) && content[i].parentNode !== el) {
  80109. el.appendChild(content[i]);
  80110. }
  80111. }
  80112. }
  80113. };
  80114. TooltipHTMLContent.prototype.setEnterable = function (enterable) {
  80115. this._enterable = enterable;
  80116. };
  80117. TooltipHTMLContent.prototype.getSize = function () {
  80118. var el = this.el;
  80119. return [el.clientWidth, el.clientHeight];
  80120. };
  80121. TooltipHTMLContent.prototype.moveTo = function (zrX, zrY) {
  80122. var styleCoord = this._styleCoord;
  80123. makeStyleCoord(styleCoord, this._zr, this._appendToBody, zrX, zrY);
  80124. if (styleCoord[0] != null && styleCoord[1] != null) {
  80125. var style_1 = this.el.style;
  80126. var transforms = assembleTransform(this.el, styleCoord[0], styleCoord[1]);
  80127. each$1(transforms, function (transform) {
  80128. style_1[transform[0]] = transform[1];
  80129. });
  80130. }
  80131. };
  80132. /**
  80133. * when `alwaysShowContent` is true,
  80134. * move the tooltip after chart resized
  80135. */
  80136. TooltipHTMLContent.prototype._moveIfResized = function () {
  80137. // The ratio of left to width
  80138. var ratioX = this._styleCoord[2]; // The ratio of top to height
  80139. var ratioY = this._styleCoord[3];
  80140. this.moveTo(ratioX * this._zr.getWidth(), ratioY * this._zr.getHeight());
  80141. };
  80142. TooltipHTMLContent.prototype.hide = function () {
  80143. var _this = this;
  80144. var style = this.el.style;
  80145. style.visibility = 'hidden';
  80146. style.opacity = '0';
  80147. env.transform3dSupported && (style.willChange = '');
  80148. this._show = false;
  80149. this._longHideTimeout = setTimeout(function () {
  80150. return _this._longHide = true;
  80151. }, 500);
  80152. };
  80153. TooltipHTMLContent.prototype.hideLater = function (time) {
  80154. if (this._show && !(this._inContent && this._enterable)) {
  80155. if (time) {
  80156. this._hideDelay = time; // Set show false to avoid invoke hideLater multiple times
  80157. this._show = false;
  80158. this._hideTimeout = setTimeout(bind(this.hide, this), time);
  80159. } else {
  80160. this.hide();
  80161. }
  80162. }
  80163. };
  80164. TooltipHTMLContent.prototype.isShow = function () {
  80165. return this._show;
  80166. };
  80167. TooltipHTMLContent.prototype.dispose = function () {
  80168. this.el.parentNode.removeChild(this.el);
  80169. };
  80170. TooltipHTMLContent.prototype.getOuterSize = function () {
  80171. var width = this.el.clientWidth;
  80172. var height = this.el.clientHeight; // Consider browser compatibility.
  80173. // IE8 does not support getComputedStyle.
  80174. var stl = getComputedStyle(this.el);
  80175. if (stl) {
  80176. width += parseInt(stl.borderLeftWidth, 10) + parseInt(stl.borderRightWidth, 10);
  80177. height += parseInt(stl.borderTopWidth, 10) + parseInt(stl.borderBottomWidth, 10);
  80178. }
  80179. return {
  80180. width: width,
  80181. height: height
  80182. };
  80183. };
  80184. return TooltipHTMLContent;
  80185. }();
  80186. /*
  80187. * Licensed to the Apache Software Foundation (ASF) under one
  80188. * or more contributor license agreements. See the NOTICE file
  80189. * distributed with this work for additional information
  80190. * regarding copyright ownership. The ASF licenses this file
  80191. * to you under the Apache License, Version 2.0 (the
  80192. * "License"); you may not use this file except in compliance
  80193. * with the License. You may obtain a copy of the License at
  80194. *
  80195. * http://www.apache.org/licenses/LICENSE-2.0
  80196. *
  80197. * Unless required by applicable law or agreed to in writing,
  80198. * software distributed under the License is distributed on an
  80199. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  80200. * KIND, either express or implied. See the License for the
  80201. * specific language governing permissions and limitations
  80202. * under the License.
  80203. */
  80204. /**
  80205. * AUTO-GENERATED FILE. DO NOT MODIFY.
  80206. */
  80207. /*
  80208. * Licensed to the Apache Software Foundation (ASF) under one
  80209. * or more contributor license agreements. See the NOTICE file
  80210. * distributed with this work for additional information
  80211. * regarding copyright ownership. The ASF licenses this file
  80212. * to you under the Apache License, Version 2.0 (the
  80213. * "License"); you may not use this file except in compliance
  80214. * with the License. You may obtain a copy of the License at
  80215. *
  80216. * http://www.apache.org/licenses/LICENSE-2.0
  80217. *
  80218. * Unless required by applicable law or agreed to in writing,
  80219. * software distributed under the License is distributed on an
  80220. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  80221. * KIND, either express or implied. See the License for the
  80222. * specific language governing permissions and limitations
  80223. * under the License.
  80224. */
  80225. var TooltipRichContent =
  80226. /** @class */
  80227. function () {
  80228. function TooltipRichContent(api) {
  80229. this._show = false;
  80230. this._styleCoord = [0, 0, 0, 0];
  80231. this._enterable = true;
  80232. this._zr = api.getZr();
  80233. makeStyleCoord$1(this._styleCoord, this._zr, api.getWidth() / 2, api.getHeight() / 2);
  80234. }
  80235. /**
  80236. * Update when tooltip is rendered
  80237. */
  80238. TooltipRichContent.prototype.update = function (tooltipModel) {
  80239. var alwaysShowContent = tooltipModel.get('alwaysShowContent');
  80240. alwaysShowContent && this._moveIfResized();
  80241. };
  80242. TooltipRichContent.prototype.show = function () {
  80243. if (this._hideTimeout) {
  80244. clearTimeout(this._hideTimeout);
  80245. }
  80246. this.el.show();
  80247. this._show = true;
  80248. };
  80249. /**
  80250. * Set tooltip content
  80251. */
  80252. TooltipRichContent.prototype.setContent = function (content, markupStyleCreator, tooltipModel, borderColor, arrowPosition) {
  80253. if (isObject$1(content)) {
  80254. throwError('Passing DOM nodes as content is not supported in richText tooltip!');
  80255. }
  80256. if (this.el) {
  80257. this._zr.remove(this.el);
  80258. }
  80259. var textStyleModel = tooltipModel.getModel('textStyle');
  80260. this.el = new ZRText({
  80261. style: {
  80262. rich: markupStyleCreator.richTextStyles,
  80263. text: content,
  80264. lineHeight: 22,
  80265. backgroundColor: tooltipModel.get('backgroundColor'),
  80266. borderRadius: tooltipModel.get('borderRadius'),
  80267. borderWidth: 1,
  80268. borderColor: borderColor,
  80269. shadowColor: tooltipModel.get('shadowColor'),
  80270. shadowBlur: tooltipModel.get('shadowBlur'),
  80271. shadowOffsetX: tooltipModel.get('shadowOffsetX'),
  80272. shadowOffsetY: tooltipModel.get('shadowOffsetY'),
  80273. textShadowColor: textStyleModel.get('textShadowColor'),
  80274. textShadowBlur: textStyleModel.get('textShadowBlur') || 0,
  80275. textShadowOffsetX: textStyleModel.get('textShadowOffsetX') || 0,
  80276. textShadowOffsetY: textStyleModel.get('textShadowOffsetY') || 0,
  80277. fill: tooltipModel.get(['textStyle', 'color']),
  80278. padding: getPaddingFromTooltipModel(tooltipModel, 'richText'),
  80279. verticalAlign: 'top',
  80280. align: 'left'
  80281. },
  80282. z: tooltipModel.get('z')
  80283. });
  80284. this._zr.add(this.el);
  80285. var self = this;
  80286. this.el.on('mouseover', function () {
  80287. // clear the timeout in hideLater and keep showing tooltip
  80288. if (self._enterable) {
  80289. clearTimeout(self._hideTimeout);
  80290. self._show = true;
  80291. }
  80292. self._inContent = true;
  80293. });
  80294. this.el.on('mouseout', function () {
  80295. if (self._enterable) {
  80296. if (self._show) {
  80297. self.hideLater(self._hideDelay);
  80298. }
  80299. }
  80300. self._inContent = false;
  80301. });
  80302. };
  80303. TooltipRichContent.prototype.setEnterable = function (enterable) {
  80304. this._enterable = enterable;
  80305. };
  80306. TooltipRichContent.prototype.getSize = function () {
  80307. var el = this.el;
  80308. var bounding = this.el.getBoundingRect(); // bounding rect does not include shadow. For renderMode richText,
  80309. // if overflow, it will be cut. So calculate them accurately.
  80310. var shadowOuterSize = calcShadowOuterSize(el.style);
  80311. return [bounding.width + shadowOuterSize.left + shadowOuterSize.right, bounding.height + shadowOuterSize.top + shadowOuterSize.bottom];
  80312. };
  80313. TooltipRichContent.prototype.moveTo = function (x, y) {
  80314. var el = this.el;
  80315. if (el) {
  80316. var styleCoord = this._styleCoord;
  80317. makeStyleCoord$1(styleCoord, this._zr, x, y);
  80318. x = styleCoord[0];
  80319. y = styleCoord[1];
  80320. var style = el.style;
  80321. var borderWidth = mathMaxWith0(style.borderWidth || 0);
  80322. var shadowOuterSize = calcShadowOuterSize(style); // rich text x, y do not include border.
  80323. el.x = x + borderWidth + shadowOuterSize.left;
  80324. el.y = y + borderWidth + shadowOuterSize.top;
  80325. el.markRedraw();
  80326. }
  80327. };
  80328. /**
  80329. * when `alwaysShowContent` is true,
  80330. * move the tooltip after chart resized
  80331. */
  80332. TooltipRichContent.prototype._moveIfResized = function () {
  80333. // The ratio of left to width
  80334. var ratioX = this._styleCoord[2]; // The ratio of top to height
  80335. var ratioY = this._styleCoord[3];
  80336. this.moveTo(ratioX * this._zr.getWidth(), ratioY * this._zr.getHeight());
  80337. };
  80338. TooltipRichContent.prototype.hide = function () {
  80339. if (this.el) {
  80340. this.el.hide();
  80341. }
  80342. this._show = false;
  80343. };
  80344. TooltipRichContent.prototype.hideLater = function (time) {
  80345. if (this._show && !(this._inContent && this._enterable)) {
  80346. if (time) {
  80347. this._hideDelay = time; // Set show false to avoid invoke hideLater multiple times
  80348. this._show = false;
  80349. this._hideTimeout = setTimeout(bind(this.hide, this), time);
  80350. } else {
  80351. this.hide();
  80352. }
  80353. }
  80354. };
  80355. TooltipRichContent.prototype.isShow = function () {
  80356. return this._show;
  80357. };
  80358. TooltipRichContent.prototype.getOuterSize = function () {
  80359. var size = this.getSize();
  80360. return {
  80361. width: size[0],
  80362. height: size[1]
  80363. };
  80364. };
  80365. TooltipRichContent.prototype.dispose = function () {
  80366. this._zr.remove(this.el);
  80367. };
  80368. return TooltipRichContent;
  80369. }();
  80370. function mathMaxWith0(val) {
  80371. return Math.max(0, val);
  80372. }
  80373. function calcShadowOuterSize(style) {
  80374. var shadowBlur = mathMaxWith0(style.shadowBlur || 0);
  80375. var shadowOffsetX = mathMaxWith0(style.shadowOffsetX || 0);
  80376. var shadowOffsetY = mathMaxWith0(style.shadowOffsetY || 0);
  80377. return {
  80378. left: mathMaxWith0(shadowBlur - shadowOffsetX),
  80379. right: mathMaxWith0(shadowBlur + shadowOffsetX),
  80380. top: mathMaxWith0(shadowBlur - shadowOffsetY),
  80381. bottom: mathMaxWith0(shadowBlur + shadowOffsetY)
  80382. };
  80383. }
  80384. function makeStyleCoord$1(out, zr, zrX, zrY) {
  80385. out[0] = zrX;
  80386. out[1] = zrY;
  80387. out[2] = out[0] / zr.getWidth();
  80388. out[3] = out[1] / zr.getHeight();
  80389. }
  80390. /*
  80391. * Licensed to the Apache Software Foundation (ASF) under one
  80392. * or more contributor license agreements. See the NOTICE file
  80393. * distributed with this work for additional information
  80394. * regarding copyright ownership. The ASF licenses this file
  80395. * to you under the Apache License, Version 2.0 (the
  80396. * "License"); you may not use this file except in compliance
  80397. * with the License. You may obtain a copy of the License at
  80398. *
  80399. * http://www.apache.org/licenses/LICENSE-2.0
  80400. *
  80401. * Unless required by applicable law or agreed to in writing,
  80402. * software distributed under the License is distributed on an
  80403. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  80404. * KIND, either express or implied. See the License for the
  80405. * specific language governing permissions and limitations
  80406. * under the License.
  80407. */
  80408. /**
  80409. * AUTO-GENERATED FILE. DO NOT MODIFY.
  80410. */
  80411. /*
  80412. * Licensed to the Apache Software Foundation (ASF) under one
  80413. * or more contributor license agreements. See the NOTICE file
  80414. * distributed with this work for additional information
  80415. * regarding copyright ownership. The ASF licenses this file
  80416. * to you under the Apache License, Version 2.0 (the
  80417. * "License"); you may not use this file except in compliance
  80418. * with the License. You may obtain a copy of the License at
  80419. *
  80420. * http://www.apache.org/licenses/LICENSE-2.0
  80421. *
  80422. * Unless required by applicable law or agreed to in writing,
  80423. * software distributed under the License is distributed on an
  80424. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  80425. * KIND, either express or implied. See the License for the
  80426. * specific language governing permissions and limitations
  80427. * under the License.
  80428. */
  80429. var bind$2 = bind;
  80430. var each$10 = each$1;
  80431. var parsePercent$2 = parsePercent$1;
  80432. var proxyRect = new Rect({
  80433. shape: {
  80434. x: -1,
  80435. y: -1,
  80436. width: 2,
  80437. height: 2
  80438. }
  80439. });
  80440. var TooltipView =
  80441. /** @class */
  80442. function (_super) {
  80443. __extends(TooltipView, _super);
  80444. function TooltipView() {
  80445. var _this = _super !== null && _super.apply(this, arguments) || this;
  80446. _this.type = TooltipView.type;
  80447. return _this;
  80448. }
  80449. TooltipView.prototype.init = function (ecModel, api) {
  80450. if (env.node) {
  80451. return;
  80452. }
  80453. var tooltipModel = ecModel.getComponent('tooltip');
  80454. var renderMode = tooltipModel.get('renderMode');
  80455. this._renderMode = getTooltipRenderMode(renderMode);
  80456. this._tooltipContent = this._renderMode === 'richText' ? new TooltipRichContent(api) : new TooltipHTMLContent(api.getDom(), api, {
  80457. appendToBody: tooltipModel.get('appendToBody', true)
  80458. });
  80459. };
  80460. TooltipView.prototype.render = function (tooltipModel, ecModel, api) {
  80461. if (env.node) {
  80462. return;
  80463. } // Reset
  80464. this.group.removeAll();
  80465. this._tooltipModel = tooltipModel;
  80466. this._ecModel = ecModel;
  80467. this._api = api;
  80468. /**
  80469. * @private
  80470. * @type {boolean}
  80471. */
  80472. this._alwaysShowContent = tooltipModel.get('alwaysShowContent');
  80473. var tooltipContent = this._tooltipContent;
  80474. tooltipContent.update(tooltipModel);
  80475. tooltipContent.setEnterable(tooltipModel.get('enterable'));
  80476. this._initGlobalListener();
  80477. this._keepShow();
  80478. };
  80479. TooltipView.prototype._initGlobalListener = function () {
  80480. var tooltipModel = this._tooltipModel;
  80481. var triggerOn = tooltipModel.get('triggerOn');
  80482. register('itemTooltip', this._api, bind$2(function (currTrigger, e, dispatchAction) {
  80483. // If 'none', it is not controlled by mouse totally.
  80484. if (triggerOn !== 'none') {
  80485. if (triggerOn.indexOf(currTrigger) >= 0) {
  80486. this._tryShow(e, dispatchAction);
  80487. } else if (currTrigger === 'leave') {
  80488. this._hide(dispatchAction);
  80489. }
  80490. }
  80491. }, this));
  80492. };
  80493. TooltipView.prototype._keepShow = function () {
  80494. var tooltipModel = this._tooltipModel;
  80495. var ecModel = this._ecModel;
  80496. var api = this._api; // Try to keep the tooltip show when refreshing
  80497. if (this._lastX != null && this._lastY != null // When user is willing to control tooltip totally using API,
  80498. // self.manuallyShowTip({x, y}) might cause tooltip hide,
  80499. // which is not expected.
  80500. && tooltipModel.get('triggerOn') !== 'none') {
  80501. var self_1 = this;
  80502. clearTimeout(this._refreshUpdateTimeout);
  80503. this._refreshUpdateTimeout = setTimeout(function () {
  80504. // Show tip next tick after other charts are rendered
  80505. // In case highlight action has wrong result
  80506. // FIXME
  80507. !api.isDisposed() && self_1.manuallyShowTip(tooltipModel, ecModel, api, {
  80508. x: self_1._lastX,
  80509. y: self_1._lastY,
  80510. dataByCoordSys: self_1._lastDataByCoordSys
  80511. });
  80512. });
  80513. }
  80514. };
  80515. /**
  80516. * Show tip manually by
  80517. * dispatchAction({
  80518. * type: 'showTip',
  80519. * x: 10,
  80520. * y: 10
  80521. * });
  80522. * Or
  80523. * dispatchAction({
  80524. * type: 'showTip',
  80525. * seriesIndex: 0,
  80526. * dataIndex or dataIndexInside or name
  80527. * });
  80528. *
  80529. * TODO Batch
  80530. */
  80531. TooltipView.prototype.manuallyShowTip = function (tooltipModel, ecModel, api, payload) {
  80532. if (payload.from === this.uid || env.node) {
  80533. return;
  80534. }
  80535. var dispatchAction = makeDispatchAction$1(payload, api); // Reset ticket
  80536. this._ticket = ''; // When triggered from axisPointer.
  80537. var dataByCoordSys = payload.dataByCoordSys;
  80538. var cmptRef = findComponentReference(payload, ecModel, api);
  80539. if (cmptRef) {
  80540. var rect = cmptRef.el.getBoundingRect().clone();
  80541. rect.applyTransform(cmptRef.el.transform);
  80542. this._tryShow({
  80543. offsetX: rect.x + rect.width / 2,
  80544. offsetY: rect.y + rect.height / 2,
  80545. target: cmptRef.el,
  80546. position: payload.position,
  80547. // When manully trigger, the mouse is not on the el, so we'd better to
  80548. // position tooltip on the bottom of the el and display arrow is possible.
  80549. positionDefault: 'bottom'
  80550. }, dispatchAction);
  80551. } else if (payload.tooltip && payload.x != null && payload.y != null) {
  80552. var el = proxyRect;
  80553. el.x = payload.x;
  80554. el.y = payload.y;
  80555. el.update();
  80556. getECData(el).tooltipConfig = {
  80557. name: null,
  80558. option: payload.tooltip
  80559. }; // Manually show tooltip while view is not using zrender elements.
  80560. this._tryShow({
  80561. offsetX: payload.x,
  80562. offsetY: payload.y,
  80563. target: el
  80564. }, dispatchAction);
  80565. } else if (dataByCoordSys) {
  80566. this._tryShow({
  80567. offsetX: payload.x,
  80568. offsetY: payload.y,
  80569. position: payload.position,
  80570. dataByCoordSys: dataByCoordSys,
  80571. tooltipOption: payload.tooltipOption
  80572. }, dispatchAction);
  80573. } else if (payload.seriesIndex != null) {
  80574. if (this._manuallyAxisShowTip(tooltipModel, ecModel, api, payload)) {
  80575. return;
  80576. }
  80577. var pointInfo = findPointFromSeries(payload, ecModel);
  80578. var cx = pointInfo.point[0];
  80579. var cy = pointInfo.point[1];
  80580. if (cx != null && cy != null) {
  80581. this._tryShow({
  80582. offsetX: cx,
  80583. offsetY: cy,
  80584. target: pointInfo.el,
  80585. position: payload.position,
  80586. // When manully trigger, the mouse is not on the el, so we'd better to
  80587. // position tooltip on the bottom of the el and display arrow is possible.
  80588. positionDefault: 'bottom'
  80589. }, dispatchAction);
  80590. }
  80591. } else if (payload.x != null && payload.y != null) {
  80592. // FIXME
  80593. // should wrap dispatchAction like `axisPointer/globalListener` ?
  80594. api.dispatchAction({
  80595. type: 'updateAxisPointer',
  80596. x: payload.x,
  80597. y: payload.y
  80598. });
  80599. this._tryShow({
  80600. offsetX: payload.x,
  80601. offsetY: payload.y,
  80602. position: payload.position,
  80603. target: api.getZr().findHover(payload.x, payload.y).target
  80604. }, dispatchAction);
  80605. }
  80606. };
  80607. TooltipView.prototype.manuallyHideTip = function (tooltipModel, ecModel, api, payload) {
  80608. var tooltipContent = this._tooltipContent;
  80609. if (!this._alwaysShowContent && this._tooltipModel) {
  80610. tooltipContent.hideLater(this._tooltipModel.get('hideDelay'));
  80611. }
  80612. this._lastX = this._lastY = this._lastDataByCoordSys = null;
  80613. if (payload.from !== this.uid) {
  80614. this._hide(makeDispatchAction$1(payload, api));
  80615. }
  80616. }; // Be compatible with previous design, that is, when tooltip.type is 'axis' and
  80617. // dispatchAction 'showTip' with seriesIndex and dataIndex will trigger axis pointer
  80618. // and tooltip.
  80619. TooltipView.prototype._manuallyAxisShowTip = function (tooltipModel, ecModel, api, payload) {
  80620. var seriesIndex = payload.seriesIndex;
  80621. var dataIndex = payload.dataIndex; // @ts-ignore
  80622. var coordSysAxesInfo = ecModel.getComponent('axisPointer').coordSysAxesInfo;
  80623. if (seriesIndex == null || dataIndex == null || coordSysAxesInfo == null) {
  80624. return;
  80625. }
  80626. var seriesModel = ecModel.getSeriesByIndex(seriesIndex);
  80627. if (!seriesModel) {
  80628. return;
  80629. }
  80630. var data = seriesModel.getData();
  80631. var tooltipCascadedModel = buildTooltipModel([data.getItemModel(dataIndex), seriesModel, (seriesModel.coordinateSystem || {}).model], this._tooltipModel);
  80632. if (tooltipCascadedModel.get('trigger') !== 'axis') {
  80633. return;
  80634. }
  80635. api.dispatchAction({
  80636. type: 'updateAxisPointer',
  80637. seriesIndex: seriesIndex,
  80638. dataIndex: dataIndex,
  80639. position: payload.position
  80640. });
  80641. return true;
  80642. };
  80643. TooltipView.prototype._tryShow = function (e, dispatchAction) {
  80644. var el = e.target;
  80645. var tooltipModel = this._tooltipModel;
  80646. if (!tooltipModel) {
  80647. return;
  80648. } // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  80649. this._lastX = e.offsetX;
  80650. this._lastY = e.offsetY;
  80651. var dataByCoordSys = e.dataByCoordSys;
  80652. if (dataByCoordSys && dataByCoordSys.length) {
  80653. this._showAxisTooltip(dataByCoordSys, e);
  80654. } else if (el) {
  80655. this._lastDataByCoordSys = null;
  80656. var seriesDispatcher_1;
  80657. var cmptDispatcher_1;
  80658. findEventDispatcher(el, function (target) {
  80659. // Always show item tooltip if mouse is on the element with dataIndex
  80660. if (getECData(target).dataIndex != null) {
  80661. seriesDispatcher_1 = target;
  80662. return true;
  80663. } // Tooltip provided directly. Like legend.
  80664. if (getECData(target).tooltipConfig != null) {
  80665. cmptDispatcher_1 = target;
  80666. return true;
  80667. }
  80668. }, true);
  80669. if (seriesDispatcher_1) {
  80670. this._showSeriesItemTooltip(e, seriesDispatcher_1, dispatchAction);
  80671. } else if (cmptDispatcher_1) {
  80672. this._showComponentItemTooltip(e, cmptDispatcher_1, dispatchAction);
  80673. } else {
  80674. this._hide(dispatchAction);
  80675. }
  80676. } else {
  80677. this._lastDataByCoordSys = null;
  80678. this._hide(dispatchAction);
  80679. }
  80680. };
  80681. TooltipView.prototype._showOrMove = function (tooltipModel, cb) {
  80682. // showDelay is used in this case: tooltip.enterable is set
  80683. // as true. User intent to move mouse into tooltip and click
  80684. // something. `showDelay` makes it easier to enter the content
  80685. // but tooltip do not move immediately.
  80686. var delay = tooltipModel.get('showDelay');
  80687. cb = bind(cb, this);
  80688. clearTimeout(this._showTimout);
  80689. delay > 0 ? this._showTimout = setTimeout(cb, delay) : cb();
  80690. };
  80691. TooltipView.prototype._showAxisTooltip = function (dataByCoordSys, e) {
  80692. var ecModel = this._ecModel;
  80693. var globalTooltipModel = this._tooltipModel;
  80694. var point = [e.offsetX, e.offsetY];
  80695. var singleTooltipModel = buildTooltipModel([e.tooltipOption], globalTooltipModel);
  80696. var renderMode = this._renderMode;
  80697. var cbParamsList = [];
  80698. var articleMarkup = createTooltipMarkup('section', {
  80699. blocks: [],
  80700. noHeader: true
  80701. }); // Only for legacy: `Serise['formatTooltip']` returns a string.
  80702. var markupTextArrLegacy = [];
  80703. var markupStyleCreator = new TooltipMarkupStyleCreator();
  80704. each$10(dataByCoordSys, function (itemCoordSys) {
  80705. each$10(itemCoordSys.dataByAxis, function (axisItem) {
  80706. var axisModel = ecModel.getComponent(axisItem.axisDim + 'Axis', axisItem.axisIndex);
  80707. var axisValue = axisItem.value;
  80708. if (!axisModel || axisValue == null) {
  80709. return;
  80710. }
  80711. var axisValueLabel = getValueLabel(axisValue, axisModel.axis, ecModel, axisItem.seriesDataIndices, axisItem.valueLabelOpt);
  80712. var axisSectionMarkup = createTooltipMarkup('section', {
  80713. header: axisValueLabel,
  80714. noHeader: !trim(axisValueLabel),
  80715. sortBlocks: true,
  80716. blocks: []
  80717. });
  80718. articleMarkup.blocks.push(axisSectionMarkup);
  80719. each$1(axisItem.seriesDataIndices, function (idxItem) {
  80720. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex);
  80721. var dataIndex = idxItem.dataIndexInside;
  80722. var cbParams = series.getDataParams(dataIndex);
  80723. cbParams.axisDim = axisItem.axisDim;
  80724. cbParams.axisIndex = axisItem.axisIndex;
  80725. cbParams.axisType = axisItem.axisType;
  80726. cbParams.axisId = axisItem.axisId;
  80727. cbParams.axisValue = getAxisRawValue(axisModel.axis, {
  80728. value: axisValue
  80729. });
  80730. cbParams.axisValueLabel = axisValueLabel; // Pre-create marker style for makers. Users can assemble richText
  80731. // text in `formatter` callback and use those markers style.
  80732. cbParams.marker = markupStyleCreator.makeTooltipMarker('item', convertToColorString(cbParams.color), renderMode);
  80733. var seriesTooltipResult = normalizeTooltipFormatResult(series.formatTooltip(dataIndex, true, null));
  80734. if (seriesTooltipResult.markupFragment) {
  80735. axisSectionMarkup.blocks.push(seriesTooltipResult.markupFragment);
  80736. }
  80737. if (seriesTooltipResult.markupText) {
  80738. markupTextArrLegacy.push(seriesTooltipResult.markupText);
  80739. }
  80740. cbParamsList.push(cbParams);
  80741. });
  80742. });
  80743. }); // In most cases, the second axis is displays upper on the first one.
  80744. // So we reverse it to look better.
  80745. articleMarkup.blocks.reverse();
  80746. markupTextArrLegacy.reverse();
  80747. var positionExpr = e.position;
  80748. var orderMode = singleTooltipModel.get('order');
  80749. var builtMarkupText = buildTooltipMarkup(articleMarkup, markupStyleCreator, renderMode, orderMode, ecModel.get('useUTC'), singleTooltipModel.get('textStyle'));
  80750. builtMarkupText && markupTextArrLegacy.unshift(builtMarkupText);
  80751. var blockBreak = renderMode === 'richText' ? '\n\n' : '<br/>';
  80752. var allMarkupText = markupTextArrLegacy.join(blockBreak);
  80753. this._showOrMove(singleTooltipModel, function () {
  80754. if (this._updateContentNotChangedOnAxis(dataByCoordSys)) {
  80755. this._updatePosition(singleTooltipModel, positionExpr, point[0], point[1], this._tooltipContent, cbParamsList);
  80756. } else {
  80757. this._showTooltipContent(singleTooltipModel, allMarkupText, cbParamsList, Math.random() + '', point[0], point[1], positionExpr, null, markupStyleCreator);
  80758. }
  80759. }); // Do not trigger events here, because this branch only be entered
  80760. // from dispatchAction.
  80761. };
  80762. TooltipView.prototype._showSeriesItemTooltip = function (e, dispatcher, dispatchAction) {
  80763. var ecModel = this._ecModel;
  80764. var ecData = getECData(dispatcher); // Use dataModel in element if possible
  80765. // Used when mouseover on a element like markPoint or edge
  80766. // In which case, the data is not main data in series.
  80767. var seriesIndex = ecData.seriesIndex;
  80768. var seriesModel = ecModel.getSeriesByIndex(seriesIndex); // For example, graph link.
  80769. var dataModel = ecData.dataModel || seriesModel;
  80770. var dataIndex = ecData.dataIndex;
  80771. var dataType = ecData.dataType;
  80772. var data = dataModel.getData(dataType);
  80773. var renderMode = this._renderMode;
  80774. var positionDefault = e.positionDefault;
  80775. var tooltipModel = buildTooltipModel([data.getItemModel(dataIndex), dataModel, seriesModel && (seriesModel.coordinateSystem || {}).model], this._tooltipModel, positionDefault ? {
  80776. position: positionDefault
  80777. } : null);
  80778. var tooltipTrigger = tooltipModel.get('trigger');
  80779. if (tooltipTrigger != null && tooltipTrigger !== 'item') {
  80780. return;
  80781. }
  80782. var params = dataModel.getDataParams(dataIndex, dataType);
  80783. var markupStyleCreator = new TooltipMarkupStyleCreator(); // Pre-create marker style for makers. Users can assemble richText
  80784. // text in `formatter` callback and use those markers style.
  80785. params.marker = markupStyleCreator.makeTooltipMarker('item', convertToColorString(params.color), renderMode);
  80786. var seriesTooltipResult = normalizeTooltipFormatResult(dataModel.formatTooltip(dataIndex, false, dataType));
  80787. var orderMode = tooltipModel.get('order');
  80788. var markupText = seriesTooltipResult.markupFragment ? buildTooltipMarkup(seriesTooltipResult.markupFragment, markupStyleCreator, renderMode, orderMode, ecModel.get('useUTC'), tooltipModel.get('textStyle')) : seriesTooltipResult.markupText;
  80789. var asyncTicket = 'item_' + dataModel.name + '_' + dataIndex;
  80790. this._showOrMove(tooltipModel, function () {
  80791. this._showTooltipContent(tooltipModel, markupText, params, asyncTicket, e.offsetX, e.offsetY, e.position, e.target, markupStyleCreator);
  80792. }); // FIXME
  80793. // duplicated showtip if manuallyShowTip is called from dispatchAction.
  80794. dispatchAction({
  80795. type: 'showTip',
  80796. dataIndexInside: dataIndex,
  80797. dataIndex: data.getRawIndex(dataIndex),
  80798. seriesIndex: seriesIndex,
  80799. from: this.uid
  80800. });
  80801. };
  80802. TooltipView.prototype._showComponentItemTooltip = function (e, el, dispatchAction) {
  80803. var ecData = getECData(el);
  80804. var tooltipConfig = ecData.tooltipConfig;
  80805. var tooltipOpt = tooltipConfig.option;
  80806. if (isString(tooltipOpt)) {
  80807. var content = tooltipOpt;
  80808. tooltipOpt = {
  80809. content: content,
  80810. // Fixed formatter
  80811. formatter: content
  80812. };
  80813. }
  80814. var tooltipModelCascade = [tooltipOpt];
  80815. var cmpt = this._ecModel.getComponent(ecData.componentMainType, ecData.componentIndex);
  80816. if (cmpt) {
  80817. tooltipModelCascade.push(cmpt);
  80818. }
  80819. var positionDefault = e.positionDefault;
  80820. var subTooltipModel = buildTooltipModel(tooltipModelCascade, this._tooltipModel, positionDefault ? {
  80821. position: positionDefault
  80822. } : null);
  80823. var defaultHtml = subTooltipModel.get('content');
  80824. var asyncTicket = Math.random() + ''; // PENDING: this case do not support richText style yet.
  80825. var markupStyleCreator = new TooltipMarkupStyleCreator(); // Do not check whether `trigger` is 'none' here, because `trigger`
  80826. // only works on coordinate system. In fact, we have not found case
  80827. // that requires setting `trigger` nothing on component yet.
  80828. this._showOrMove(subTooltipModel, function () {
  80829. // Use formatterParams from element defined in component
  80830. // Avoid users modify it.
  80831. var formatterParams = clone(subTooltipModel.get('formatterParams') || {});
  80832. this._showTooltipContent(subTooltipModel, defaultHtml, formatterParams, asyncTicket, e.offsetX, e.offsetY, e.position, el, markupStyleCreator);
  80833. }); // If not dispatch showTip, tip may be hide triggered by axis.
  80834. dispatchAction({
  80835. type: 'showTip',
  80836. from: this.uid
  80837. });
  80838. };
  80839. TooltipView.prototype._showTooltipContent = function ( // Use Model<TooltipOption> insteadof TooltipModel because this model may be from series or other options.
  80840. // Instead of top level tooltip.
  80841. tooltipModel, defaultHtml, params, asyncTicket, x, y, positionExpr, el, markupStyleCreator) {
  80842. // Reset ticket
  80843. this._ticket = '';
  80844. if (!tooltipModel.get('showContent') || !tooltipModel.get('show')) {
  80845. return;
  80846. }
  80847. var tooltipContent = this._tooltipContent;
  80848. var formatter = tooltipModel.get('formatter');
  80849. positionExpr = positionExpr || tooltipModel.get('position');
  80850. var html = defaultHtml;
  80851. var nearPoint = this._getNearestPoint([x, y], params, tooltipModel.get('trigger'), tooltipModel.get('borderColor'));
  80852. var nearPointColor = nearPoint.color;
  80853. if (formatter && isString(formatter)) {
  80854. var useUTC = tooltipModel.ecModel.get('useUTC');
  80855. var params0 = isArray(params) ? params[0] : params;
  80856. var isTimeAxis = params0 && params0.axisType && params0.axisType.indexOf('time') >= 0;
  80857. html = formatter;
  80858. if (isTimeAxis) {
  80859. html = format(params0.axisValue, html, useUTC);
  80860. }
  80861. html = formatTpl(html, params, true);
  80862. } else if (isFunction$1(formatter)) {
  80863. var callback = bind$2(function (cbTicket, html) {
  80864. if (cbTicket === this._ticket) {
  80865. tooltipContent.setContent(html, markupStyleCreator, tooltipModel, nearPointColor, positionExpr);
  80866. this._updatePosition(tooltipModel, positionExpr, x, y, tooltipContent, params, el);
  80867. }
  80868. }, this);
  80869. this._ticket = asyncTicket;
  80870. html = formatter(params, asyncTicket, callback);
  80871. }
  80872. tooltipContent.setContent(html, markupStyleCreator, tooltipModel, nearPointColor, positionExpr);
  80873. tooltipContent.show(tooltipModel, nearPointColor);
  80874. this._updatePosition(tooltipModel, positionExpr, x, y, tooltipContent, params, el);
  80875. };
  80876. TooltipView.prototype._getNearestPoint = function (point, tooltipDataParams, trigger, borderColor) {
  80877. if (trigger === 'axis' || isArray(tooltipDataParams)) {
  80878. return {
  80879. color: borderColor || (this._renderMode === 'html' ? '#fff' : 'none')
  80880. };
  80881. }
  80882. if (!isArray(tooltipDataParams)) {
  80883. return {
  80884. color: borderColor || tooltipDataParams.color || tooltipDataParams.borderColor
  80885. };
  80886. }
  80887. };
  80888. TooltipView.prototype._updatePosition = function (tooltipModel, positionExpr, x, // Mouse x
  80889. y, // Mouse y
  80890. content, params, el) {
  80891. var viewWidth = this._api.getWidth();
  80892. var viewHeight = this._api.getHeight();
  80893. positionExpr = positionExpr || tooltipModel.get('position');
  80894. var contentSize = content.getSize();
  80895. var align = tooltipModel.get('align');
  80896. var vAlign = tooltipModel.get('verticalAlign');
  80897. var rect = el && el.getBoundingRect().clone();
  80898. el && rect.applyTransform(el.transform);
  80899. if (isFunction$1(positionExpr)) {
  80900. // Callback of position can be an array or a string specify the position
  80901. positionExpr = positionExpr([x, y], params, content.el, rect, {
  80902. viewSize: [viewWidth, viewHeight],
  80903. contentSize: contentSize.slice()
  80904. });
  80905. }
  80906. if (isArray(positionExpr)) {
  80907. x = parsePercent$2(positionExpr[0], viewWidth);
  80908. y = parsePercent$2(positionExpr[1], viewHeight);
  80909. } else if (isObject$1(positionExpr)) {
  80910. var boxLayoutPosition = positionExpr;
  80911. boxLayoutPosition.width = contentSize[0];
  80912. boxLayoutPosition.height = contentSize[1];
  80913. var layoutRect = getLayoutRect(boxLayoutPosition, {
  80914. width: viewWidth,
  80915. height: viewHeight
  80916. });
  80917. x = layoutRect.x;
  80918. y = layoutRect.y;
  80919. align = null; // When positionExpr is left/top/right/bottom,
  80920. // align and verticalAlign will not work.
  80921. vAlign = null;
  80922. } // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  80923. else if (isString(positionExpr) && el) {
  80924. var pos = calcTooltipPosition(positionExpr, rect, contentSize);
  80925. x = pos[0];
  80926. y = pos[1];
  80927. } else {
  80928. var pos = refixTooltipPosition(x, y, content, viewWidth, viewHeight, align ? null : 20, vAlign ? null : 20);
  80929. x = pos[0];
  80930. y = pos[1];
  80931. }
  80932. align && (x -= isCenterAlign(align) ? contentSize[0] / 2 : align === 'right' ? contentSize[0] : 0);
  80933. vAlign && (y -= isCenterAlign(vAlign) ? contentSize[1] / 2 : vAlign === 'bottom' ? contentSize[1] : 0);
  80934. if (shouldTooltipConfine(tooltipModel)) {
  80935. var pos = confineTooltipPosition(x, y, content, viewWidth, viewHeight);
  80936. x = pos[0];
  80937. y = pos[1];
  80938. }
  80939. content.moveTo(x, y);
  80940. }; // FIXME
  80941. // Should we remove this but leave this to user?
  80942. TooltipView.prototype._updateContentNotChangedOnAxis = function (dataByCoordSys) {
  80943. var lastCoordSys = this._lastDataByCoordSys;
  80944. var contentNotChanged = !!lastCoordSys && lastCoordSys.length === dataByCoordSys.length;
  80945. contentNotChanged && each$10(lastCoordSys, function (lastItemCoordSys, indexCoordSys) {
  80946. var lastDataByAxis = lastItemCoordSys.dataByAxis || [];
  80947. var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {};
  80948. var thisDataByAxis = thisItemCoordSys.dataByAxis || [];
  80949. contentNotChanged = contentNotChanged && lastDataByAxis.length === thisDataByAxis.length;
  80950. contentNotChanged && each$10(lastDataByAxis, function (lastItem, indexAxis) {
  80951. var thisItem = thisDataByAxis[indexAxis] || {};
  80952. var lastIndices = lastItem.seriesDataIndices || [];
  80953. var newIndices = thisItem.seriesDataIndices || [];
  80954. contentNotChanged = contentNotChanged && lastItem.value === thisItem.value && lastItem.axisType === thisItem.axisType && lastItem.axisId === thisItem.axisId && lastIndices.length === newIndices.length;
  80955. contentNotChanged && each$10(lastIndices, function (lastIdxItem, j) {
  80956. var newIdxItem = newIndices[j];
  80957. contentNotChanged = contentNotChanged && lastIdxItem.seriesIndex === newIdxItem.seriesIndex && lastIdxItem.dataIndex === newIdxItem.dataIndex;
  80958. });
  80959. });
  80960. });
  80961. this._lastDataByCoordSys = dataByCoordSys;
  80962. return !!contentNotChanged;
  80963. };
  80964. TooltipView.prototype._hide = function (dispatchAction) {
  80965. // Do not directly hideLater here, because this behavior may be prevented
  80966. // in dispatchAction when showTip is dispatched.
  80967. // FIXME
  80968. // duplicated hideTip if manuallyHideTip is called from dispatchAction.
  80969. this._lastDataByCoordSys = null;
  80970. dispatchAction({
  80971. type: 'hideTip',
  80972. from: this.uid
  80973. });
  80974. };
  80975. TooltipView.prototype.dispose = function (ecModel, api) {
  80976. if (env.node) {
  80977. return;
  80978. }
  80979. this._tooltipContent.dispose();
  80980. unregister('itemTooltip', api);
  80981. };
  80982. TooltipView.type = 'tooltip';
  80983. return TooltipView;
  80984. }(ComponentView);
  80985. /**
  80986. * From top to bottom. (the last one should be globalTooltipModel);
  80987. */
  80988. function buildTooltipModel(modelCascade, globalTooltipModel, defaultTooltipOption) {
  80989. // Last is always tooltip model.
  80990. var ecModel = globalTooltipModel.ecModel;
  80991. var resultModel;
  80992. if (defaultTooltipOption) {
  80993. resultModel = new Model(defaultTooltipOption, ecModel, ecModel);
  80994. resultModel = new Model(globalTooltipModel.option, resultModel, ecModel);
  80995. } else {
  80996. resultModel = globalTooltipModel;
  80997. }
  80998. for (var i = modelCascade.length - 1; i >= 0; i--) {
  80999. var tooltipOpt = modelCascade[i];
  81000. if (tooltipOpt) {
  81001. if (tooltipOpt instanceof Model) {
  81002. tooltipOpt = tooltipOpt.get('tooltip', true);
  81003. } // In each data item tooltip can be simply write:
  81004. // {
  81005. // value: 10,
  81006. // tooltip: 'Something you need to know'
  81007. // }
  81008. if (isString(tooltipOpt)) {
  81009. tooltipOpt = {
  81010. formatter: tooltipOpt
  81011. };
  81012. }
  81013. if (tooltipOpt) {
  81014. resultModel = new Model(tooltipOpt, resultModel, ecModel);
  81015. }
  81016. }
  81017. }
  81018. return resultModel;
  81019. }
  81020. function makeDispatchAction$1(payload, api) {
  81021. return payload.dispatchAction || bind(api.dispatchAction, api);
  81022. }
  81023. function refixTooltipPosition(x, y, content, viewWidth, viewHeight, gapH, gapV) {
  81024. var size = content.getOuterSize();
  81025. var width = size.width;
  81026. var height = size.height;
  81027. if (gapH != null) {
  81028. // Add extra 2 pixels for this case:
  81029. // At present the "values" in defaut tooltip are using CSS `float: right`.
  81030. // When the right edge of the tooltip box is on the right side of the
  81031. // viewport, the `float` layout might push the "values" to the second line.
  81032. if (x + width + gapH + 2 > viewWidth) {
  81033. x -= width + gapH;
  81034. } else {
  81035. x += gapH;
  81036. }
  81037. }
  81038. if (gapV != null) {
  81039. if (y + height + gapV > viewHeight) {
  81040. y -= height + gapV;
  81041. } else {
  81042. y += gapV;
  81043. }
  81044. }
  81045. return [x, y];
  81046. }
  81047. function confineTooltipPosition(x, y, content, viewWidth, viewHeight) {
  81048. var size = content.getOuterSize();
  81049. var width = size.width;
  81050. var height = size.height;
  81051. x = Math.min(x + width, viewWidth) - width;
  81052. y = Math.min(y + height, viewHeight) - height;
  81053. x = Math.max(x, 0);
  81054. y = Math.max(y, 0);
  81055. return [x, y];
  81056. }
  81057. function calcTooltipPosition(position, rect, contentSize) {
  81058. var domWidth = contentSize[0];
  81059. var domHeight = contentSize[1];
  81060. var gap = 10;
  81061. var offset = 5;
  81062. var x = 0;
  81063. var y = 0;
  81064. var rectWidth = rect.width;
  81065. var rectHeight = rect.height;
  81066. switch (position) {
  81067. case 'inside':
  81068. x = rect.x + rectWidth / 2 - domWidth / 2;
  81069. y = rect.y + rectHeight / 2 - domHeight / 2;
  81070. break;
  81071. case 'top':
  81072. x = rect.x + rectWidth / 2 - domWidth / 2;
  81073. y = rect.y - domHeight - gap;
  81074. break;
  81075. case 'bottom':
  81076. x = rect.x + rectWidth / 2 - domWidth / 2;
  81077. y = rect.y + rectHeight + gap;
  81078. break;
  81079. case 'left':
  81080. x = rect.x - domWidth - gap - offset;
  81081. y = rect.y + rectHeight / 2 - domHeight / 2;
  81082. break;
  81083. case 'right':
  81084. x = rect.x + rectWidth + gap + offset;
  81085. y = rect.y + rectHeight / 2 - domHeight / 2;
  81086. }
  81087. return [x, y];
  81088. }
  81089. function isCenterAlign(align) {
  81090. return align === 'center' || align === 'middle';
  81091. }
  81092. /**
  81093. * Find target component by payload like:
  81094. * ```js
  81095. * { legendId: 'some_id', name: 'xxx' }
  81096. * { toolboxIndex: 1, name: 'xxx' }
  81097. * { geoName: 'some_name', name: 'xxx' }
  81098. * ```
  81099. * PENDING: at present only
  81100. *
  81101. * If not found, return null/undefined.
  81102. */
  81103. function findComponentReference(payload, ecModel, api) {
  81104. var queryOptionMap = preParseFinder(payload).queryOptionMap;
  81105. var componentMainType = queryOptionMap.keys()[0];
  81106. if (!componentMainType || componentMainType === 'series') {
  81107. return;
  81108. }
  81109. var queryResult = queryReferringComponents(ecModel, componentMainType, queryOptionMap.get(componentMainType), {
  81110. useDefault: false,
  81111. enableAll: false,
  81112. enableNone: false
  81113. });
  81114. var model = queryResult.models[0];
  81115. if (!model) {
  81116. return;
  81117. }
  81118. var view = api.getViewOfComponentModel(model);
  81119. var el;
  81120. view.group.traverse(function (subEl) {
  81121. var tooltipConfig = getECData(subEl).tooltipConfig;
  81122. if (tooltipConfig && tooltipConfig.name === payload.name) {
  81123. el = subEl;
  81124. return true; // stop
  81125. }
  81126. });
  81127. if (el) {
  81128. return {
  81129. componentMainType: componentMainType,
  81130. componentIndex: model.componentIndex,
  81131. el: el
  81132. };
  81133. }
  81134. }
  81135. /*
  81136. * Licensed to the Apache Software Foundation (ASF) under one
  81137. * or more contributor license agreements. See the NOTICE file
  81138. * distributed with this work for additional information
  81139. * regarding copyright ownership. The ASF licenses this file
  81140. * to you under the Apache License, Version 2.0 (the
  81141. * "License"); you may not use this file except in compliance
  81142. * with the License. You may obtain a copy of the License at
  81143. *
  81144. * http://www.apache.org/licenses/LICENSE-2.0
  81145. *
  81146. * Unless required by applicable law or agreed to in writing,
  81147. * software distributed under the License is distributed on an
  81148. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81149. * KIND, either express or implied. See the License for the
  81150. * specific language governing permissions and limitations
  81151. * under the License.
  81152. */
  81153. /**
  81154. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81155. */
  81156. /*
  81157. * Licensed to the Apache Software Foundation (ASF) under one
  81158. * or more contributor license agreements. See the NOTICE file
  81159. * distributed with this work for additional information
  81160. * regarding copyright ownership. The ASF licenses this file
  81161. * to you under the Apache License, Version 2.0 (the
  81162. * "License"); you may not use this file except in compliance
  81163. * with the License. You may obtain a copy of the License at
  81164. *
  81165. * http://www.apache.org/licenses/LICENSE-2.0
  81166. *
  81167. * Unless required by applicable law or agreed to in writing,
  81168. * software distributed under the License is distributed on an
  81169. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81170. * KIND, either express or implied. See the License for the
  81171. * specific language governing permissions and limitations
  81172. * under the License.
  81173. */
  81174. function install$35(registers) {
  81175. use(install$29);
  81176. registers.registerComponentModel(TooltipModel);
  81177. registers.registerComponentView(TooltipView);
  81178. /**
  81179. * @action
  81180. * @property {string} type
  81181. * @property {number} seriesIndex
  81182. * @property {number} dataIndex
  81183. * @property {number} [x]
  81184. * @property {number} [y]
  81185. */
  81186. registers.registerAction({
  81187. type: 'showTip',
  81188. event: 'showTip',
  81189. update: 'tooltip:manuallyShowTip'
  81190. }, // noop
  81191. function () {});
  81192. registers.registerAction({
  81193. type: 'hideTip',
  81194. event: 'hideTip',
  81195. update: 'tooltip:manuallyHideTip'
  81196. }, // noop
  81197. function () {});
  81198. }
  81199. /*
  81200. * Licensed to the Apache Software Foundation (ASF) under one
  81201. * or more contributor license agreements. See the NOTICE file
  81202. * distributed with this work for additional information
  81203. * regarding copyright ownership. The ASF licenses this file
  81204. * to you under the Apache License, Version 2.0 (the
  81205. * "License"); you may not use this file except in compliance
  81206. * with the License. You may obtain a copy of the License at
  81207. *
  81208. * http://www.apache.org/licenses/LICENSE-2.0
  81209. *
  81210. * Unless required by applicable law or agreed to in writing,
  81211. * software distributed under the License is distributed on an
  81212. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81213. * KIND, either express or implied. See the License for the
  81214. * specific language governing permissions and limitations
  81215. * under the License.
  81216. */
  81217. /**
  81218. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81219. */
  81220. /*
  81221. * Licensed to the Apache Software Foundation (ASF) under one
  81222. * or more contributor license agreements. See the NOTICE file
  81223. * distributed with this work for additional information
  81224. * regarding copyright ownership. The ASF licenses this file
  81225. * to you under the Apache License, Version 2.0 (the
  81226. * "License"); you may not use this file except in compliance
  81227. * with the License. You may obtain a copy of the License at
  81228. *
  81229. * http://www.apache.org/licenses/LICENSE-2.0
  81230. *
  81231. * Unless required by applicable law or agreed to in writing,
  81232. * software distributed under the License is distributed on an
  81233. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81234. * KIND, either express or implied. See the License for the
  81235. * specific language governing permissions and limitations
  81236. * under the License.
  81237. */
  81238. use(install$35);
  81239. /*
  81240. * Licensed to the Apache Software Foundation (ASF) under one
  81241. * or more contributor license agreements. See the NOTICE file
  81242. * distributed with this work for additional information
  81243. * regarding copyright ownership. The ASF licenses this file
  81244. * to you under the Apache License, Version 2.0 (the
  81245. * "License"); you may not use this file except in compliance
  81246. * with the License. You may obtain a copy of the License at
  81247. *
  81248. * http://www.apache.org/licenses/LICENSE-2.0
  81249. *
  81250. * Unless required by applicable law or agreed to in writing,
  81251. * software distributed under the License is distributed on an
  81252. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81253. * KIND, either express or implied. See the License for the
  81254. * specific language governing permissions and limitations
  81255. * under the License.
  81256. */
  81257. /**
  81258. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81259. */
  81260. /*
  81261. * Licensed to the Apache Software Foundation (ASF) under one
  81262. * or more contributor license agreements. See the NOTICE file
  81263. * distributed with this work for additional information
  81264. * regarding copyright ownership. The ASF licenses this file
  81265. * to you under the Apache License, Version 2.0 (the
  81266. * "License"); you may not use this file except in compliance
  81267. * with the License. You may obtain a copy of the License at
  81268. *
  81269. * http://www.apache.org/licenses/LICENSE-2.0
  81270. *
  81271. * Unless required by applicable law or agreed to in writing,
  81272. * software distributed under the License is distributed on an
  81273. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81274. * KIND, either express or implied. See the License for the
  81275. * specific language governing permissions and limitations
  81276. * under the License.
  81277. */
  81278. function checkMarkerInSeries(seriesOpts, markerType) {
  81279. if (!seriesOpts) {
  81280. return false;
  81281. }
  81282. var seriesOptArr = isArray(seriesOpts) ? seriesOpts : [seriesOpts];
  81283. for (var idx = 0; idx < seriesOptArr.length; idx++) {
  81284. if (seriesOptArr[idx] && seriesOptArr[idx][markerType]) {
  81285. return true;
  81286. }
  81287. }
  81288. return false;
  81289. }
  81290. /*
  81291. * Licensed to the Apache Software Foundation (ASF) under one
  81292. * or more contributor license agreements. See the NOTICE file
  81293. * distributed with this work for additional information
  81294. * regarding copyright ownership. The ASF licenses this file
  81295. * to you under the Apache License, Version 2.0 (the
  81296. * "License"); you may not use this file except in compliance
  81297. * with the License. You may obtain a copy of the License at
  81298. *
  81299. * http://www.apache.org/licenses/LICENSE-2.0
  81300. *
  81301. * Unless required by applicable law or agreed to in writing,
  81302. * software distributed under the License is distributed on an
  81303. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81304. * KIND, either express or implied. See the License for the
  81305. * specific language governing permissions and limitations
  81306. * under the License.
  81307. */
  81308. /**
  81309. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81310. */
  81311. /*
  81312. * Licensed to the Apache Software Foundation (ASF) under one
  81313. * or more contributor license agreements. See the NOTICE file
  81314. * distributed with this work for additional information
  81315. * regarding copyright ownership. The ASF licenses this file
  81316. * to you under the Apache License, Version 2.0 (the
  81317. * "License"); you may not use this file except in compliance
  81318. * with the License. You may obtain a copy of the License at
  81319. *
  81320. * http://www.apache.org/licenses/LICENSE-2.0
  81321. *
  81322. * Unless required by applicable law or agreed to in writing,
  81323. * software distributed under the License is distributed on an
  81324. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81325. * KIND, either express or implied. See the License for the
  81326. * specific language governing permissions and limitations
  81327. * under the License.
  81328. */
  81329. function fillLabel(opt) {
  81330. defaultEmphasis(opt, 'label', ['show']);
  81331. } // { [componentType]: MarkerModel }
  81332. var inner$14 = makeInner();
  81333. var MarkerModel =
  81334. /** @class */
  81335. function (_super) {
  81336. __extends(MarkerModel, _super);
  81337. function MarkerModel() {
  81338. var _this = _super !== null && _super.apply(this, arguments) || this;
  81339. _this.type = MarkerModel.type;
  81340. /**
  81341. * If marker model is created by self from series
  81342. */
  81343. _this.createdBySelf = false;
  81344. return _this;
  81345. }
  81346. /**
  81347. * @overrite
  81348. */
  81349. MarkerModel.prototype.init = function (option, parentModel, ecModel) {
  81350. {
  81351. if (this.type === 'marker') {
  81352. throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
  81353. }
  81354. }
  81355. this.mergeDefaultAndTheme(option, ecModel);
  81356. this._mergeOption(option, ecModel, false, true);
  81357. };
  81358. MarkerModel.prototype.isAnimationEnabled = function () {
  81359. if (env.node) {
  81360. return false;
  81361. }
  81362. var hostSeries = this.__hostSeries;
  81363. return this.getShallow('animation') && hostSeries && hostSeries.isAnimationEnabled();
  81364. };
  81365. /**
  81366. * @overrite
  81367. */
  81368. MarkerModel.prototype.mergeOption = function (newOpt, ecModel) {
  81369. this._mergeOption(newOpt, ecModel, false, false);
  81370. };
  81371. MarkerModel.prototype._mergeOption = function (newOpt, ecModel, createdBySelf, isInit) {
  81372. var componentType = this.mainType;
  81373. if (!createdBySelf) {
  81374. ecModel.eachSeries(function (seriesModel) {
  81375. // mainType can be markPoint, markLine, markArea
  81376. var markerOpt = seriesModel.get(this.mainType, true);
  81377. var markerModel = inner$14(seriesModel)[componentType];
  81378. if (!markerOpt || !markerOpt.data) {
  81379. inner$14(seriesModel)[componentType] = null;
  81380. return;
  81381. }
  81382. if (!markerModel) {
  81383. if (isInit) {
  81384. // Default label emphasis `position` and `show`
  81385. fillLabel(markerOpt);
  81386. }
  81387. each$1(markerOpt.data, function (item) {
  81388. // FIXME Overwrite fillLabel method ?
  81389. if (item instanceof Array) {
  81390. fillLabel(item[0]);
  81391. fillLabel(item[1]);
  81392. } else {
  81393. fillLabel(item);
  81394. }
  81395. });
  81396. markerModel = this.createMarkerModelFromSeries(markerOpt, this, ecModel); // markerModel = new ImplementedMarkerModel(
  81397. // markerOpt, this, ecModel
  81398. // );
  81399. extend(markerModel, {
  81400. mainType: this.mainType,
  81401. // Use the same series index and name
  81402. seriesIndex: seriesModel.seriesIndex,
  81403. name: seriesModel.name,
  81404. createdBySelf: true
  81405. });
  81406. markerModel.__hostSeries = seriesModel;
  81407. } else {
  81408. markerModel._mergeOption(markerOpt, ecModel, true);
  81409. }
  81410. inner$14(seriesModel)[componentType] = markerModel;
  81411. }, this);
  81412. }
  81413. };
  81414. MarkerModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
  81415. var data = this.getData();
  81416. var value = this.getRawValue(dataIndex);
  81417. var itemName = data.getName(dataIndex);
  81418. return createTooltipMarkup('section', {
  81419. header: this.name,
  81420. blocks: [createTooltipMarkup('nameValue', {
  81421. name: itemName,
  81422. value: value,
  81423. noName: !itemName,
  81424. noValue: value == null
  81425. })]
  81426. });
  81427. };
  81428. MarkerModel.prototype.getData = function () {
  81429. return this._data;
  81430. };
  81431. MarkerModel.prototype.setData = function (data) {
  81432. this._data = data;
  81433. };
  81434. MarkerModel.getMarkerModelFromSeries = function (seriesModel, // Support three types of markers. Strict check.
  81435. componentType) {
  81436. return inner$14(seriesModel)[componentType];
  81437. };
  81438. MarkerModel.type = 'marker';
  81439. MarkerModel.dependencies = ['series', 'grid', 'polar', 'geo'];
  81440. return MarkerModel;
  81441. }(ComponentModel);
  81442. mixin(MarkerModel, DataFormatMixin.prototype);
  81443. /*
  81444. * Licensed to the Apache Software Foundation (ASF) under one
  81445. * or more contributor license agreements. See the NOTICE file
  81446. * distributed with this work for additional information
  81447. * regarding copyright ownership. The ASF licenses this file
  81448. * to you under the Apache License, Version 2.0 (the
  81449. * "License"); you may not use this file except in compliance
  81450. * with the License. You may obtain a copy of the License at
  81451. *
  81452. * http://www.apache.org/licenses/LICENSE-2.0
  81453. *
  81454. * Unless required by applicable law or agreed to in writing,
  81455. * software distributed under the License is distributed on an
  81456. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81457. * KIND, either express or implied. See the License for the
  81458. * specific language governing permissions and limitations
  81459. * under the License.
  81460. */
  81461. /**
  81462. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81463. */
  81464. /*
  81465. * Licensed to the Apache Software Foundation (ASF) under one
  81466. * or more contributor license agreements. See the NOTICE file
  81467. * distributed with this work for additional information
  81468. * regarding copyright ownership. The ASF licenses this file
  81469. * to you under the Apache License, Version 2.0 (the
  81470. * "License"); you may not use this file except in compliance
  81471. * with the License. You may obtain a copy of the License at
  81472. *
  81473. * http://www.apache.org/licenses/LICENSE-2.0
  81474. *
  81475. * Unless required by applicable law or agreed to in writing,
  81476. * software distributed under the License is distributed on an
  81477. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81478. * KIND, either express or implied. See the License for the
  81479. * specific language governing permissions and limitations
  81480. * under the License.
  81481. */
  81482. var MarkPointModel =
  81483. /** @class */
  81484. function (_super) {
  81485. __extends(MarkPointModel, _super);
  81486. function MarkPointModel() {
  81487. var _this = _super !== null && _super.apply(this, arguments) || this;
  81488. _this.type = MarkPointModel.type;
  81489. return _this;
  81490. }
  81491. MarkPointModel.prototype.createMarkerModelFromSeries = function (markerOpt, masterMarkerModel, ecModel) {
  81492. return new MarkPointModel(markerOpt, masterMarkerModel, ecModel);
  81493. };
  81494. MarkPointModel.type = 'markPoint';
  81495. MarkPointModel.defaultOption = {
  81496. zlevel: 0,
  81497. z: 5,
  81498. symbol: 'pin',
  81499. symbolSize: 50,
  81500. //symbolRotate: 0,
  81501. //symbolOffset: [0, 0]
  81502. tooltip: {
  81503. trigger: 'item'
  81504. },
  81505. label: {
  81506. show: true,
  81507. position: 'inside'
  81508. },
  81509. itemStyle: {
  81510. borderWidth: 2
  81511. },
  81512. emphasis: {
  81513. label: {
  81514. show: true
  81515. }
  81516. }
  81517. };
  81518. return MarkPointModel;
  81519. }(MarkerModel);
  81520. /*
  81521. * Licensed to the Apache Software Foundation (ASF) under one
  81522. * or more contributor license agreements. See the NOTICE file
  81523. * distributed with this work for additional information
  81524. * regarding copyright ownership. The ASF licenses this file
  81525. * to you under the Apache License, Version 2.0 (the
  81526. * "License"); you may not use this file except in compliance
  81527. * with the License. You may obtain a copy of the License at
  81528. *
  81529. * http://www.apache.org/licenses/LICENSE-2.0
  81530. *
  81531. * Unless required by applicable law or agreed to in writing,
  81532. * software distributed under the License is distributed on an
  81533. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81534. * KIND, either express or implied. See the License for the
  81535. * specific language governing permissions and limitations
  81536. * under the License.
  81537. */
  81538. /**
  81539. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81540. */
  81541. /*
  81542. * Licensed to the Apache Software Foundation (ASF) under one
  81543. * or more contributor license agreements. See the NOTICE file
  81544. * distributed with this work for additional information
  81545. * regarding copyright ownership. The ASF licenses this file
  81546. * to you under the Apache License, Version 2.0 (the
  81547. * "License"); you may not use this file except in compliance
  81548. * with the License. You may obtain a copy of the License at
  81549. *
  81550. * http://www.apache.org/licenses/LICENSE-2.0
  81551. *
  81552. * Unless required by applicable law or agreed to in writing,
  81553. * software distributed under the License is distributed on an
  81554. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81555. * KIND, either express or implied. See the License for the
  81556. * specific language governing permissions and limitations
  81557. * under the License.
  81558. */
  81559. function hasXOrY(item) {
  81560. return !(isNaN(parseFloat(item.x)) && isNaN(parseFloat(item.y)));
  81561. }
  81562. function hasXAndY(item) {
  81563. return !isNaN(parseFloat(item.x)) && !isNaN(parseFloat(item.y));
  81564. } // Make it simple, do not visit all stacked value to count precision.
  81565. // function getPrecision(data, valueAxisDim, dataIndex) {
  81566. // let precision = -1;
  81567. // let stackedDim = data.mapDimension(valueAxisDim);
  81568. // do {
  81569. // precision = Math.max(
  81570. // numberUtil.getPrecision(data.get(stackedDim, dataIndex)),
  81571. // precision
  81572. // );
  81573. // let stackedOnSeries = data.getCalculationInfo('stackedOnSeries');
  81574. // if (stackedOnSeries) {
  81575. // let byValue = data.get(data.getCalculationInfo('stackedByDimension'), dataIndex);
  81576. // data = stackedOnSeries.getData();
  81577. // dataIndex = data.indexOf(data.getCalculationInfo('stackedByDimension'), byValue);
  81578. // stackedDim = data.getCalculationInfo('stackedDimension');
  81579. // }
  81580. // else {
  81581. // data = null;
  81582. // }
  81583. // } while (data);
  81584. // return precision;
  81585. // }
  81586. function markerTypeCalculatorWithExtent(markerType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex) {
  81587. var coordArr = [];
  81588. var stacked = isDimensionStacked(data, targetDataDim
  81589. /*, otherDataDim*/
  81590. );
  81591. var calcDataDim = stacked ? data.getCalculationInfo('stackResultDimension') : targetDataDim;
  81592. var value = numCalculate(data, calcDataDim, markerType);
  81593. var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
  81594. coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
  81595. coordArr[targetCoordIndex] = data.get(calcDataDim, dataIndex);
  81596. var coordArrValue = data.get(targetDataDim, dataIndex); // Make it simple, do not visit all stacked value to count precision.
  81597. var precision = getPrecision(data.get(targetDataDim, dataIndex));
  81598. precision = Math.min(precision, 20);
  81599. if (precision >= 0) {
  81600. coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
  81601. }
  81602. return [coordArr, coordArrValue];
  81603. } // TODO Specified percent
  81604. var markerTypeCalculator = {
  81605. min: curry(markerTypeCalculatorWithExtent, 'min'),
  81606. max: curry(markerTypeCalculatorWithExtent, 'max'),
  81607. average: curry(markerTypeCalculatorWithExtent, 'average'),
  81608. median: curry(markerTypeCalculatorWithExtent, 'median')
  81609. };
  81610. /**
  81611. * Transform markPoint data item to format used in List by do the following
  81612. * 1. Calculate statistic like `max`, `min`, `average`
  81613. * 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
  81614. * @param {module:echarts/model/Series} seriesModel
  81615. * @param {module:echarts/coord/*} [coordSys]
  81616. * @param {Object} item
  81617. * @return {Object}
  81618. */
  81619. function dataTransform(seriesModel, item) {
  81620. var data = seriesModel.getData();
  81621. var coordSys = seriesModel.coordinateSystem; // 1. If not specify the position with pixel directly
  81622. // 2. If `coord` is not a data array. Which uses `xAxis`,
  81623. // `yAxis` to specify the coord on each dimension
  81624. // parseFloat first because item.x and item.y can be percent string like '20%'
  81625. if (item && !hasXAndY(item) && !isArray(item.coord) && coordSys) {
  81626. var dims = coordSys.dimensions;
  81627. var axisInfo = getAxisInfo$1(item, data, coordSys, seriesModel); // Clone the option
  81628. // Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
  81629. item = clone(item);
  81630. if (item.type && markerTypeCalculator[item.type] && axisInfo.baseAxis && axisInfo.valueAxis) {
  81631. var otherCoordIndex = indexOf$1(dims, axisInfo.baseAxis.dim);
  81632. var targetCoordIndex = indexOf$1(dims, axisInfo.valueAxis.dim);
  81633. var coordInfo = markerTypeCalculator[item.type](data, axisInfo.baseDataDim, axisInfo.valueDataDim, otherCoordIndex, targetCoordIndex);
  81634. item.coord = coordInfo[0]; // Force to use the value of calculated value.
  81635. // let item use the value without stack.
  81636. item.value = coordInfo[1];
  81637. } else {
  81638. // FIXME Only has one of xAxis and yAxis.
  81639. var coord = [item.xAxis != null ? item.xAxis : item.radiusAxis, item.yAxis != null ? item.yAxis : item.angleAxis]; // Each coord support max, min, average
  81640. for (var i = 0; i < 2; i++) {
  81641. if (markerTypeCalculator[coord[i]]) {
  81642. coord[i] = numCalculate(data, data.mapDimension(dims[i]), coord[i]);
  81643. }
  81644. }
  81645. item.coord = coord;
  81646. }
  81647. }
  81648. return item;
  81649. }
  81650. function getAxisInfo$1(item, data, coordSys, seriesModel) {
  81651. var ret = {};
  81652. if (item.valueIndex != null || item.valueDim != null) {
  81653. ret.valueDataDim = item.valueIndex != null ? data.getDimension(item.valueIndex) : item.valueDim;
  81654. ret.valueAxis = coordSys.getAxis(dataDimToCoordDim(seriesModel, ret.valueDataDim));
  81655. ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
  81656. ret.baseDataDim = data.mapDimension(ret.baseAxis.dim);
  81657. } else {
  81658. ret.baseAxis = seriesModel.getBaseAxis();
  81659. ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
  81660. ret.baseDataDim = data.mapDimension(ret.baseAxis.dim);
  81661. ret.valueDataDim = data.mapDimension(ret.valueAxis.dim);
  81662. }
  81663. return ret;
  81664. }
  81665. function dataDimToCoordDim(seriesModel, dataDim) {
  81666. var data = seriesModel.getData();
  81667. var dimensions = data.dimensions;
  81668. dataDim = data.getDimension(dataDim);
  81669. for (var i = 0; i < dimensions.length; i++) {
  81670. var dimItem = data.getDimensionInfo(dimensions[i]);
  81671. if (dimItem.name === dataDim) {
  81672. return dimItem.coordDim;
  81673. }
  81674. }
  81675. }
  81676. /**
  81677. * Filter data which is out of coordinateSystem range
  81678. * [dataFilter description]
  81679. */
  81680. function dataFilter$1( // Currently only polar and cartesian has containData.
  81681. coordSys, item) {
  81682. // Alwalys return true if there is no coordSys
  81683. return coordSys && coordSys.containData && item.coord && !hasXOrY(item) ? coordSys.containData(item.coord) : true;
  81684. }
  81685. function dimValueGetter(item, dimName, dataIndex, dimIndex) {
  81686. // x, y, radius, angle
  81687. if (dimIndex < 2) {
  81688. return item.coord && item.coord[dimIndex];
  81689. }
  81690. return item.value;
  81691. }
  81692. function numCalculate(data, valueDataDim, type) {
  81693. if (type === 'average') {
  81694. var sum_1 = 0;
  81695. var count_1 = 0;
  81696. data.each(valueDataDim, function (val, idx) {
  81697. if (!isNaN(val)) {
  81698. sum_1 += val;
  81699. count_1++;
  81700. }
  81701. });
  81702. return sum_1 / count_1;
  81703. } else if (type === 'median') {
  81704. return data.getMedian(valueDataDim);
  81705. } else {
  81706. // max & min
  81707. return data.getDataExtent(valueDataDim)[type === 'max' ? 1 : 0];
  81708. }
  81709. }
  81710. /*
  81711. * Licensed to the Apache Software Foundation (ASF) under one
  81712. * or more contributor license agreements. See the NOTICE file
  81713. * distributed with this work for additional information
  81714. * regarding copyright ownership. The ASF licenses this file
  81715. * to you under the Apache License, Version 2.0 (the
  81716. * "License"); you may not use this file except in compliance
  81717. * with the License. You may obtain a copy of the License at
  81718. *
  81719. * http://www.apache.org/licenses/LICENSE-2.0
  81720. *
  81721. * Unless required by applicable law or agreed to in writing,
  81722. * software distributed under the License is distributed on an
  81723. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81724. * KIND, either express or implied. See the License for the
  81725. * specific language governing permissions and limitations
  81726. * under the License.
  81727. */
  81728. /**
  81729. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81730. */
  81731. /*
  81732. * Licensed to the Apache Software Foundation (ASF) under one
  81733. * or more contributor license agreements. See the NOTICE file
  81734. * distributed with this work for additional information
  81735. * regarding copyright ownership. The ASF licenses this file
  81736. * to you under the Apache License, Version 2.0 (the
  81737. * "License"); you may not use this file except in compliance
  81738. * with the License. You may obtain a copy of the License at
  81739. *
  81740. * http://www.apache.org/licenses/LICENSE-2.0
  81741. *
  81742. * Unless required by applicable law or agreed to in writing,
  81743. * software distributed under the License is distributed on an
  81744. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81745. * KIND, either express or implied. See the License for the
  81746. * specific language governing permissions and limitations
  81747. * under the License.
  81748. */
  81749. var inner$15 = makeInner();
  81750. var MarkerView =
  81751. /** @class */
  81752. function (_super) {
  81753. __extends(MarkerView, _super);
  81754. function MarkerView() {
  81755. var _this = _super !== null && _super.apply(this, arguments) || this;
  81756. _this.type = MarkerView.type;
  81757. return _this;
  81758. }
  81759. MarkerView.prototype.init = function () {
  81760. this.markerGroupMap = createHashMap();
  81761. };
  81762. MarkerView.prototype.render = function (markerModel, ecModel, api) {
  81763. var _this = this;
  81764. var markerGroupMap = this.markerGroupMap;
  81765. markerGroupMap.each(function (item) {
  81766. inner$15(item).keep = false;
  81767. });
  81768. ecModel.eachSeries(function (seriesModel) {
  81769. var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, _this.type);
  81770. markerModel && _this.renderSeries(seriesModel, markerModel, ecModel, api);
  81771. });
  81772. markerGroupMap.each(function (item) {
  81773. !inner$15(item).keep && _this.group.remove(item.group);
  81774. });
  81775. };
  81776. MarkerView.prototype.markKeep = function (drawGroup) {
  81777. inner$15(drawGroup).keep = true;
  81778. };
  81779. MarkerView.prototype.blurSeries = function (seriesModelList) {
  81780. var _this = this;
  81781. each$1(seriesModelList, function (seriesModel) {
  81782. var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, _this.type);
  81783. if (markerModel) {
  81784. var data = markerModel.getData();
  81785. data.eachItemGraphicEl(function (el) {
  81786. if (el) {
  81787. enterBlur(el);
  81788. }
  81789. });
  81790. }
  81791. });
  81792. };
  81793. MarkerView.type = 'marker';
  81794. return MarkerView;
  81795. }(ComponentView);
  81796. /*
  81797. * Licensed to the Apache Software Foundation (ASF) under one
  81798. * or more contributor license agreements. See the NOTICE file
  81799. * distributed with this work for additional information
  81800. * regarding copyright ownership. The ASF licenses this file
  81801. * to you under the Apache License, Version 2.0 (the
  81802. * "License"); you may not use this file except in compliance
  81803. * with the License. You may obtain a copy of the License at
  81804. *
  81805. * http://www.apache.org/licenses/LICENSE-2.0
  81806. *
  81807. * Unless required by applicable law or agreed to in writing,
  81808. * software distributed under the License is distributed on an
  81809. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81810. * KIND, either express or implied. See the License for the
  81811. * specific language governing permissions and limitations
  81812. * under the License.
  81813. */
  81814. /**
  81815. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81816. */
  81817. /*
  81818. * Licensed to the Apache Software Foundation (ASF) under one
  81819. * or more contributor license agreements. See the NOTICE file
  81820. * distributed with this work for additional information
  81821. * regarding copyright ownership. The ASF licenses this file
  81822. * to you under the Apache License, Version 2.0 (the
  81823. * "License"); you may not use this file except in compliance
  81824. * with the License. You may obtain a copy of the License at
  81825. *
  81826. * http://www.apache.org/licenses/LICENSE-2.0
  81827. *
  81828. * Unless required by applicable law or agreed to in writing,
  81829. * software distributed under the License is distributed on an
  81830. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81831. * KIND, either express or implied. See the License for the
  81832. * specific language governing permissions and limitations
  81833. * under the License.
  81834. */
  81835. function updateMarkerLayout(mpData, seriesModel, api) {
  81836. var coordSys = seriesModel.coordinateSystem;
  81837. mpData.each(function (idx) {
  81838. var itemModel = mpData.getItemModel(idx);
  81839. var point;
  81840. var xPx = parsePercent$1(itemModel.get('x'), api.getWidth());
  81841. var yPx = parsePercent$1(itemModel.get('y'), api.getHeight());
  81842. if (!isNaN(xPx) && !isNaN(yPx)) {
  81843. point = [xPx, yPx];
  81844. } // Chart like bar may have there own marker positioning logic
  81845. else if (seriesModel.getMarkerPosition) {
  81846. // Use the getMarkerPoisition
  81847. point = seriesModel.getMarkerPosition(mpData.getValues(mpData.dimensions, idx));
  81848. } else if (coordSys) {
  81849. var x = mpData.get(coordSys.dimensions[0], idx);
  81850. var y = mpData.get(coordSys.dimensions[1], idx);
  81851. point = coordSys.dataToPoint([x, y]);
  81852. } // Use x, y if has any
  81853. if (!isNaN(xPx)) {
  81854. point[0] = xPx;
  81855. }
  81856. if (!isNaN(yPx)) {
  81857. point[1] = yPx;
  81858. }
  81859. mpData.setItemLayout(idx, point);
  81860. });
  81861. }
  81862. var MarkPointView =
  81863. /** @class */
  81864. function (_super) {
  81865. __extends(MarkPointView, _super);
  81866. function MarkPointView() {
  81867. var _this = _super !== null && _super.apply(this, arguments) || this;
  81868. _this.type = MarkPointView.type;
  81869. return _this;
  81870. }
  81871. MarkPointView.prototype.updateTransform = function (markPointModel, ecModel, api) {
  81872. ecModel.eachSeries(function (seriesModel) {
  81873. var mpModel = MarkerModel.getMarkerModelFromSeries(seriesModel, 'markPoint');
  81874. if (mpModel) {
  81875. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  81876. this.markerGroupMap.get(seriesModel.id).updateLayout();
  81877. }
  81878. }, this);
  81879. };
  81880. MarkPointView.prototype.renderSeries = function (seriesModel, mpModel, ecModel, api) {
  81881. var coordSys = seriesModel.coordinateSystem;
  81882. var seriesId = seriesModel.id;
  81883. var seriesData = seriesModel.getData();
  81884. var symbolDrawMap = this.markerGroupMap;
  81885. var symbolDraw = symbolDrawMap.get(seriesId) || symbolDrawMap.set(seriesId, new SymbolDraw());
  81886. var mpData = createList$1(coordSys, seriesModel, mpModel); // FIXME
  81887. mpModel.setData(mpData);
  81888. updateMarkerLayout(mpModel.getData(), seriesModel, api);
  81889. mpData.each(function (idx) {
  81890. var itemModel = mpData.getItemModel(idx);
  81891. var symbol = itemModel.getShallow('symbol');
  81892. var symbolSize = itemModel.getShallow('symbolSize');
  81893. var symbolRotate = itemModel.getShallow('symbolRotate');
  81894. if (isFunction$1(symbol) || isFunction$1(symbolSize) || isFunction$1(symbolRotate)) {
  81895. var rawIdx = mpModel.getRawValue(idx);
  81896. var dataParams = mpModel.getDataParams(idx);
  81897. if (isFunction$1(symbol)) {
  81898. symbol = symbol(rawIdx, dataParams);
  81899. }
  81900. if (isFunction$1(symbolSize)) {
  81901. // FIXME 这里不兼容 ECharts 2.x,2.x 貌似参数是整个数据?
  81902. symbolSize = symbolSize(rawIdx, dataParams);
  81903. }
  81904. if (isFunction$1(symbolRotate)) {
  81905. symbolRotate = symbolRotate(rawIdx, dataParams);
  81906. }
  81907. }
  81908. var style = itemModel.getModel('itemStyle').getItemStyle();
  81909. var color = getVisualFromData(seriesData, 'color');
  81910. if (!style.fill) {
  81911. style.fill = color;
  81912. }
  81913. mpData.setItemVisual(idx, {
  81914. symbol: symbol,
  81915. symbolSize: symbolSize,
  81916. symbolRotate: symbolRotate,
  81917. style: style
  81918. });
  81919. }); // TODO Text are wrong
  81920. symbolDraw.updateData(mpData);
  81921. this.group.add(symbolDraw.group); // Set host model for tooltip
  81922. // FIXME
  81923. mpData.eachItemGraphicEl(function (el) {
  81924. el.traverse(function (child) {
  81925. getECData(child).dataModel = mpModel;
  81926. });
  81927. });
  81928. this.markKeep(symbolDraw);
  81929. symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
  81930. };
  81931. MarkPointView.type = 'markPoint';
  81932. return MarkPointView;
  81933. }(MarkerView);
  81934. function createList$1(coordSys, seriesModel, mpModel) {
  81935. var coordDimsInfos;
  81936. if (coordSys) {
  81937. coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
  81938. var info = seriesModel.getData().getDimensionInfo(seriesModel.getData().mapDimension(coordDim)) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  81939. return defaults({
  81940. name: coordDim
  81941. }, info);
  81942. });
  81943. } else {
  81944. coordDimsInfos = [{
  81945. name: 'value',
  81946. type: 'float'
  81947. }];
  81948. }
  81949. var mpData = new List(coordDimsInfos, mpModel);
  81950. var dataOpt = map(mpModel.get('data'), curry(dataTransform, seriesModel));
  81951. if (coordSys) {
  81952. dataOpt = filter(dataOpt, curry(dataFilter$1, coordSys));
  81953. }
  81954. mpData.initData(dataOpt, null, coordSys ? dimValueGetter : function (item) {
  81955. return item.value;
  81956. });
  81957. return mpData;
  81958. }
  81959. /*
  81960. * Licensed to the Apache Software Foundation (ASF) under one
  81961. * or more contributor license agreements. See the NOTICE file
  81962. * distributed with this work for additional information
  81963. * regarding copyright ownership. The ASF licenses this file
  81964. * to you under the Apache License, Version 2.0 (the
  81965. * "License"); you may not use this file except in compliance
  81966. * with the License. You may obtain a copy of the License at
  81967. *
  81968. * http://www.apache.org/licenses/LICENSE-2.0
  81969. *
  81970. * Unless required by applicable law or agreed to in writing,
  81971. * software distributed under the License is distributed on an
  81972. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  81973. * KIND, either express or implied. See the License for the
  81974. * specific language governing permissions and limitations
  81975. * under the License.
  81976. */
  81977. /**
  81978. * AUTO-GENERATED FILE. DO NOT MODIFY.
  81979. */
  81980. function install$36(registers) {
  81981. registers.registerComponentModel(MarkPointModel);
  81982. registers.registerComponentView(MarkPointView);
  81983. registers.registerPreprocessor(function (opt) {
  81984. if (checkMarkerInSeries(opt.series, 'markPoint')) {
  81985. // Make sure markPoint component is enabled
  81986. opt.markPoint = opt.markPoint || {};
  81987. }
  81988. });
  81989. }
  81990. /*
  81991. * Licensed to the Apache Software Foundation (ASF) under one
  81992. * or more contributor license agreements. See the NOTICE file
  81993. * distributed with this work for additional information
  81994. * regarding copyright ownership. The ASF licenses this file
  81995. * to you under the Apache License, Version 2.0 (the
  81996. * "License"); you may not use this file except in compliance
  81997. * with the License. You may obtain a copy of the License at
  81998. *
  81999. * http://www.apache.org/licenses/LICENSE-2.0
  82000. *
  82001. * Unless required by applicable law or agreed to in writing,
  82002. * software distributed under the License is distributed on an
  82003. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82004. * KIND, either express or implied. See the License for the
  82005. * specific language governing permissions and limitations
  82006. * under the License.
  82007. */
  82008. /**
  82009. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82010. */
  82011. /*
  82012. * Licensed to the Apache Software Foundation (ASF) under one
  82013. * or more contributor license agreements. See the NOTICE file
  82014. * distributed with this work for additional information
  82015. * regarding copyright ownership. The ASF licenses this file
  82016. * to you under the Apache License, Version 2.0 (the
  82017. * "License"); you may not use this file except in compliance
  82018. * with the License. You may obtain a copy of the License at
  82019. *
  82020. * http://www.apache.org/licenses/LICENSE-2.0
  82021. *
  82022. * Unless required by applicable law or agreed to in writing,
  82023. * software distributed under the License is distributed on an
  82024. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82025. * KIND, either express or implied. See the License for the
  82026. * specific language governing permissions and limitations
  82027. * under the License.
  82028. */
  82029. // HINT Markpoint can't be used too much
  82030. use(install$36);
  82031. /*
  82032. * Licensed to the Apache Software Foundation (ASF) under one
  82033. * or more contributor license agreements. See the NOTICE file
  82034. * distributed with this work for additional information
  82035. * regarding copyright ownership. The ASF licenses this file
  82036. * to you under the Apache License, Version 2.0 (the
  82037. * "License"); you may not use this file except in compliance
  82038. * with the License. You may obtain a copy of the License at
  82039. *
  82040. * http://www.apache.org/licenses/LICENSE-2.0
  82041. *
  82042. * Unless required by applicable law or agreed to in writing,
  82043. * software distributed under the License is distributed on an
  82044. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82045. * KIND, either express or implied. See the License for the
  82046. * specific language governing permissions and limitations
  82047. * under the License.
  82048. */
  82049. /**
  82050. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82051. */
  82052. /*
  82053. * Licensed to the Apache Software Foundation (ASF) under one
  82054. * or more contributor license agreements. See the NOTICE file
  82055. * distributed with this work for additional information
  82056. * regarding copyright ownership. The ASF licenses this file
  82057. * to you under the Apache License, Version 2.0 (the
  82058. * "License"); you may not use this file except in compliance
  82059. * with the License. You may obtain a copy of the License at
  82060. *
  82061. * http://www.apache.org/licenses/LICENSE-2.0
  82062. *
  82063. * Unless required by applicable law or agreed to in writing,
  82064. * software distributed under the License is distributed on an
  82065. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82066. * KIND, either express or implied. See the License for the
  82067. * specific language governing permissions and limitations
  82068. * under the License.
  82069. */
  82070. var MarkLineModel =
  82071. /** @class */
  82072. function (_super) {
  82073. __extends(MarkLineModel, _super);
  82074. function MarkLineModel() {
  82075. var _this = _super !== null && _super.apply(this, arguments) || this;
  82076. _this.type = MarkLineModel.type;
  82077. return _this;
  82078. }
  82079. MarkLineModel.prototype.createMarkerModelFromSeries = function (markerOpt, masterMarkerModel, ecModel) {
  82080. return new MarkLineModel(markerOpt, masterMarkerModel, ecModel);
  82081. };
  82082. MarkLineModel.type = 'markLine';
  82083. MarkLineModel.defaultOption = {
  82084. zlevel: 0,
  82085. z: 5,
  82086. symbol: ['circle', 'arrow'],
  82087. symbolSize: [8, 16],
  82088. //symbolRotate: 0,
  82089. symbolOffset: 0,
  82090. precision: 2,
  82091. tooltip: {
  82092. trigger: 'item'
  82093. },
  82094. label: {
  82095. show: true,
  82096. position: 'end',
  82097. distance: 5
  82098. },
  82099. lineStyle: {
  82100. type: 'dashed'
  82101. },
  82102. emphasis: {
  82103. label: {
  82104. show: true
  82105. },
  82106. lineStyle: {
  82107. width: 3
  82108. }
  82109. },
  82110. animationEasing: 'linear'
  82111. };
  82112. return MarkLineModel;
  82113. }(MarkerModel);
  82114. /*
  82115. * Licensed to the Apache Software Foundation (ASF) under one
  82116. * or more contributor license agreements. See the NOTICE file
  82117. * distributed with this work for additional information
  82118. * regarding copyright ownership. The ASF licenses this file
  82119. * to you under the Apache License, Version 2.0 (the
  82120. * "License"); you may not use this file except in compliance
  82121. * with the License. You may obtain a copy of the License at
  82122. *
  82123. * http://www.apache.org/licenses/LICENSE-2.0
  82124. *
  82125. * Unless required by applicable law or agreed to in writing,
  82126. * software distributed under the License is distributed on an
  82127. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82128. * KIND, either express or implied. See the License for the
  82129. * specific language governing permissions and limitations
  82130. * under the License.
  82131. */
  82132. /**
  82133. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82134. */
  82135. /*
  82136. * Licensed to the Apache Software Foundation (ASF) under one
  82137. * or more contributor license agreements. See the NOTICE file
  82138. * distributed with this work for additional information
  82139. * regarding copyright ownership. The ASF licenses this file
  82140. * to you under the Apache License, Version 2.0 (the
  82141. * "License"); you may not use this file except in compliance
  82142. * with the License. You may obtain a copy of the License at
  82143. *
  82144. * http://www.apache.org/licenses/LICENSE-2.0
  82145. *
  82146. * Unless required by applicable law or agreed to in writing,
  82147. * software distributed under the License is distributed on an
  82148. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82149. * KIND, either express or implied. See the License for the
  82150. * specific language governing permissions and limitations
  82151. * under the License.
  82152. */
  82153. var inner$16 = makeInner();
  82154. var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
  82155. var data = seriesModel.getData();
  82156. var itemArray;
  82157. if (!isArray(item)) {
  82158. // Special type markLine like 'min', 'max', 'average', 'median'
  82159. var mlType = item.type;
  82160. if (mlType === 'min' || mlType === 'max' || mlType === 'average' || mlType === 'median' // In case
  82161. // data: [{
  82162. // yAxis: 10
  82163. // }]
  82164. || item.xAxis != null || item.yAxis != null) {
  82165. var valueAxis = void 0;
  82166. var value = void 0;
  82167. if (item.yAxis != null || item.xAxis != null) {
  82168. valueAxis = coordSys.getAxis(item.yAxis != null ? 'y' : 'x');
  82169. value = retrieve(item.yAxis, item.xAxis);
  82170. } else {
  82171. var axisInfo = getAxisInfo$1(item, data, coordSys, seriesModel);
  82172. valueAxis = axisInfo.valueAxis;
  82173. var valueDataDim = getStackedDimension(data, axisInfo.valueDataDim);
  82174. value = numCalculate(data, valueDataDim, mlType);
  82175. }
  82176. var valueIndex = valueAxis.dim === 'x' ? 0 : 1;
  82177. var baseIndex = 1 - valueIndex; // Normized to 2d data with start and end point
  82178. var mlFrom = clone(item);
  82179. var mlTo = {
  82180. coord: []
  82181. };
  82182. mlFrom.type = null;
  82183. mlFrom.coord = [];
  82184. mlFrom.coord[baseIndex] = -Infinity;
  82185. mlTo.coord[baseIndex] = Infinity;
  82186. var precision = mlModel.get('precision');
  82187. if (precision >= 0 && typeof value === 'number') {
  82188. value = +value.toFixed(Math.min(precision, 20));
  82189. }
  82190. mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
  82191. itemArray = [mlFrom, mlTo, {
  82192. type: mlType,
  82193. valueIndex: item.valueIndex,
  82194. // Force to use the value of calculated value.
  82195. value: value
  82196. }];
  82197. } else {
  82198. // Invalid data
  82199. {
  82200. logError('Invalid markLine data.');
  82201. }
  82202. itemArray = [];
  82203. }
  82204. } else {
  82205. itemArray = item;
  82206. }
  82207. var normalizedItem = [dataTransform(seriesModel, itemArray[0]), dataTransform(seriesModel, itemArray[1]), extend({}, itemArray[2])]; // Avoid line data type is extended by from(to) data type
  82208. normalizedItem[2].type = normalizedItem[2].type || null; // Merge from option and to option into line option
  82209. merge(normalizedItem[2], normalizedItem[0]);
  82210. merge(normalizedItem[2], normalizedItem[1]);
  82211. return normalizedItem;
  82212. };
  82213. function isInifinity(val) {
  82214. return !isNaN(val) && !isFinite(val);
  82215. } // If a markLine has one dim
  82216. function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  82217. var otherDimIndex = 1 - dimIndex;
  82218. var dimName = coordSys.dimensions[dimIndex];
  82219. return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]) && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
  82220. }
  82221. function markLineFilter(coordSys, item) {
  82222. if (coordSys.type === 'cartesian2d') {
  82223. var fromCoord = item[0].coord;
  82224. var toCoord = item[1].coord; // In case
  82225. // {
  82226. // markLine: {
  82227. // data: [{ yAxis: 2 }]
  82228. // }
  82229. // }
  82230. if (fromCoord && toCoord && (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys) || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))) {
  82231. return true;
  82232. }
  82233. }
  82234. return dataFilter$1(coordSys, item[0]) && dataFilter$1(coordSys, item[1]);
  82235. }
  82236. function updateSingleMarkerEndLayout(data, idx, isFrom, seriesModel, api) {
  82237. var coordSys = seriesModel.coordinateSystem;
  82238. var itemModel = data.getItemModel(idx);
  82239. var point;
  82240. var xPx = parsePercent$1(itemModel.get('x'), api.getWidth());
  82241. var yPx = parsePercent$1(itemModel.get('y'), api.getHeight());
  82242. if (!isNaN(xPx) && !isNaN(yPx)) {
  82243. point = [xPx, yPx];
  82244. } else {
  82245. // Chart like bar may have there own marker positioning logic
  82246. if (seriesModel.getMarkerPosition) {
  82247. // Use the getMarkerPoisition
  82248. point = seriesModel.getMarkerPosition(data.getValues(data.dimensions, idx));
  82249. } else {
  82250. var dims = coordSys.dimensions;
  82251. var x = data.get(dims[0], idx);
  82252. var y = data.get(dims[1], idx);
  82253. point = coordSys.dataToPoint([x, y]);
  82254. } // Expand line to the edge of grid if value on one axis is Inifnity
  82255. // In case
  82256. // markLine: {
  82257. // data: [{
  82258. // yAxis: 2
  82259. // // or
  82260. // type: 'average'
  82261. // }]
  82262. // }
  82263. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  82264. // TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
  82265. var xAxis = coordSys.getAxis('x');
  82266. var yAxis = coordSys.getAxis('y');
  82267. var dims = coordSys.dimensions;
  82268. if (isInifinity(data.get(dims[0], idx))) {
  82269. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
  82270. } else if (isInifinity(data.get(dims[1], idx))) {
  82271. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
  82272. }
  82273. } // Use x, y if has any
  82274. if (!isNaN(xPx)) {
  82275. point[0] = xPx;
  82276. }
  82277. if (!isNaN(yPx)) {
  82278. point[1] = yPx;
  82279. }
  82280. }
  82281. data.setItemLayout(idx, point);
  82282. }
  82283. var MarkLineView =
  82284. /** @class */
  82285. function (_super) {
  82286. __extends(MarkLineView, _super);
  82287. function MarkLineView() {
  82288. var _this = _super !== null && _super.apply(this, arguments) || this;
  82289. _this.type = MarkLineView.type;
  82290. return _this;
  82291. }
  82292. MarkLineView.prototype.updateTransform = function (markLineModel, ecModel, api) {
  82293. ecModel.eachSeries(function (seriesModel) {
  82294. var mlModel = MarkerModel.getMarkerModelFromSeries(seriesModel, 'markLine');
  82295. if (mlModel) {
  82296. var mlData_1 = mlModel.getData();
  82297. var fromData_1 = inner$16(mlModel).from;
  82298. var toData_1 = inner$16(mlModel).to; // Update visual and layout of from symbol and to symbol
  82299. fromData_1.each(function (idx) {
  82300. updateSingleMarkerEndLayout(fromData_1, idx, true, seriesModel, api);
  82301. updateSingleMarkerEndLayout(toData_1, idx, false, seriesModel, api);
  82302. }); // Update layout of line
  82303. mlData_1.each(function (idx) {
  82304. mlData_1.setItemLayout(idx, [fromData_1.getItemLayout(idx), toData_1.getItemLayout(idx)]);
  82305. });
  82306. this.markerGroupMap.get(seriesModel.id).updateLayout();
  82307. }
  82308. }, this);
  82309. };
  82310. MarkLineView.prototype.renderSeries = function (seriesModel, mlModel, ecModel, api) {
  82311. var coordSys = seriesModel.coordinateSystem;
  82312. var seriesId = seriesModel.id;
  82313. var seriesData = seriesModel.getData();
  82314. var lineDrawMap = this.markerGroupMap;
  82315. var lineDraw = lineDrawMap.get(seriesId) || lineDrawMap.set(seriesId, new LineDraw());
  82316. this.group.add(lineDraw.group);
  82317. var mlData = createList$2(coordSys, seriesModel, mlModel);
  82318. var fromData = mlData.from;
  82319. var toData = mlData.to;
  82320. var lineData = mlData.line;
  82321. inner$16(mlModel).from = fromData;
  82322. inner$16(mlModel).to = toData; // Line data for tooltip and formatter
  82323. mlModel.setData(lineData);
  82324. var symbolType = mlModel.get('symbol');
  82325. var symbolSize = mlModel.get('symbolSize');
  82326. var symbolRotate = mlModel.get('symbolRotate');
  82327. var symbolOffset = mlModel.get('symbolOffset');
  82328. if (!isArray(symbolType)) {
  82329. symbolType = [symbolType, symbolType];
  82330. }
  82331. if (!isArray(symbolSize)) {
  82332. symbolSize = [symbolSize, symbolSize];
  82333. }
  82334. if (!isArray(symbolRotate)) {
  82335. symbolRotate = [symbolRotate, symbolRotate];
  82336. }
  82337. if (!isArray(symbolOffset)) {
  82338. symbolOffset = [symbolOffset, symbolOffset];
  82339. } // Update visual and layout of from symbol and to symbol
  82340. mlData.from.each(function (idx) {
  82341. updateDataVisualAndLayout(fromData, idx, true);
  82342. updateDataVisualAndLayout(toData, idx, false);
  82343. }); // Update visual and layout of line
  82344. lineData.each(function (idx) {
  82345. var lineStyle = lineData.getItemModel(idx).getModel('lineStyle').getLineStyle(); // lineData.setItemVisual(idx, {
  82346. // color: lineColor || fromData.getItemVisual(idx, 'color')
  82347. // });
  82348. lineData.setItemLayout(idx, [fromData.getItemLayout(idx), toData.getItemLayout(idx)]);
  82349. if (lineStyle.stroke == null) {
  82350. lineStyle.stroke = fromData.getItemVisual(idx, 'style').fill;
  82351. }
  82352. lineData.setItemVisual(idx, {
  82353. fromSymbolKeepAspect: fromData.getItemVisual(idx, 'symbolKeepAspect'),
  82354. fromSymbolOffset: fromData.getItemVisual(idx, 'symbolOffset'),
  82355. fromSymbolRotate: fromData.getItemVisual(idx, 'symbolRotate'),
  82356. fromSymbolSize: fromData.getItemVisual(idx, 'symbolSize'),
  82357. fromSymbol: fromData.getItemVisual(idx, 'symbol'),
  82358. toSymbolKeepAspect: toData.getItemVisual(idx, 'symbolKeepAspect'),
  82359. toSymbolOffset: toData.getItemVisual(idx, 'symbolOffset'),
  82360. toSymbolRotate: toData.getItemVisual(idx, 'symbolRotate'),
  82361. toSymbolSize: toData.getItemVisual(idx, 'symbolSize'),
  82362. toSymbol: toData.getItemVisual(idx, 'symbol'),
  82363. style: lineStyle
  82364. });
  82365. });
  82366. lineDraw.updateData(lineData); // Set host model for tooltip
  82367. // FIXME
  82368. mlData.line.eachItemGraphicEl(function (el, idx) {
  82369. el.traverse(function (child) {
  82370. getECData(child).dataModel = mlModel;
  82371. });
  82372. });
  82373. function updateDataVisualAndLayout(data, idx, isFrom) {
  82374. var itemModel = data.getItemModel(idx);
  82375. updateSingleMarkerEndLayout(data, idx, isFrom, seriesModel, api);
  82376. var style = itemModel.getModel('itemStyle').getItemStyle();
  82377. if (style.fill == null) {
  82378. style.fill = getVisualFromData(seriesData, 'color');
  82379. }
  82380. data.setItemVisual(idx, {
  82381. symbolKeepAspect: itemModel.get('symbolKeepAspect'),
  82382. // `0` should be considered as a valid value, so use `retrieve2` instead of `||`
  82383. symbolOffset: retrieve2(itemModel.get('symbolOffset'), symbolOffset[isFrom ? 0 : 1]),
  82384. symbolRotate: retrieve2(itemModel.get('symbolRotate', true), symbolRotate[isFrom ? 0 : 1]),
  82385. symbolSize: retrieve2(itemModel.get('symbolSize'), symbolSize[isFrom ? 0 : 1]),
  82386. symbol: retrieve2(itemModel.get('symbol', true), symbolType[isFrom ? 0 : 1]),
  82387. style: style
  82388. });
  82389. }
  82390. this.markKeep(lineDraw);
  82391. lineDraw.group.silent = mlModel.get('silent') || seriesModel.get('silent');
  82392. };
  82393. MarkLineView.type = 'markLine';
  82394. return MarkLineView;
  82395. }(MarkerView);
  82396. function createList$2(coordSys, seriesModel, mlModel) {
  82397. var coordDimsInfos;
  82398. if (coordSys) {
  82399. coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
  82400. var info = seriesModel.getData().getDimensionInfo(seriesModel.getData().mapDimension(coordDim)) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  82401. return defaults({
  82402. name: coordDim
  82403. }, info);
  82404. });
  82405. } else {
  82406. coordDimsInfos = [{
  82407. name: 'value',
  82408. type: 'float'
  82409. }];
  82410. }
  82411. var fromData = new List(coordDimsInfos, mlModel);
  82412. var toData = new List(coordDimsInfos, mlModel); // No dimensions
  82413. var lineData = new List([], mlModel);
  82414. var optData = map(mlModel.get('data'), curry(markLineTransform, seriesModel, coordSys, mlModel));
  82415. if (coordSys) {
  82416. optData = filter(optData, curry(markLineFilter, coordSys));
  82417. }
  82418. var dimValueGetter$$1 = coordSys ? dimValueGetter : function (item) {
  82419. return item.value;
  82420. };
  82421. fromData.initData(map(optData, function (item) {
  82422. return item[0];
  82423. }), null, dimValueGetter$$1);
  82424. toData.initData(map(optData, function (item) {
  82425. return item[1];
  82426. }), null, dimValueGetter$$1);
  82427. lineData.initData(map(optData, function (item) {
  82428. return item[2];
  82429. }));
  82430. lineData.hasItemOption = true;
  82431. return {
  82432. from: fromData,
  82433. to: toData,
  82434. line: lineData
  82435. };
  82436. }
  82437. /*
  82438. * Licensed to the Apache Software Foundation (ASF) under one
  82439. * or more contributor license agreements. See the NOTICE file
  82440. * distributed with this work for additional information
  82441. * regarding copyright ownership. The ASF licenses this file
  82442. * to you under the Apache License, Version 2.0 (the
  82443. * "License"); you may not use this file except in compliance
  82444. * with the License. You may obtain a copy of the License at
  82445. *
  82446. * http://www.apache.org/licenses/LICENSE-2.0
  82447. *
  82448. * Unless required by applicable law or agreed to in writing,
  82449. * software distributed under the License is distributed on an
  82450. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82451. * KIND, either express or implied. See the License for the
  82452. * specific language governing permissions and limitations
  82453. * under the License.
  82454. */
  82455. /**
  82456. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82457. */
  82458. function install$37(registers) {
  82459. registers.registerComponentModel(MarkLineModel);
  82460. registers.registerComponentView(MarkLineView);
  82461. registers.registerPreprocessor(function (opt) {
  82462. if (checkMarkerInSeries(opt.series, 'markLine')) {
  82463. // Make sure markLine component is enabled
  82464. opt.markLine = opt.markLine || {};
  82465. }
  82466. });
  82467. }
  82468. /*
  82469. * Licensed to the Apache Software Foundation (ASF) under one
  82470. * or more contributor license agreements. See the NOTICE file
  82471. * distributed with this work for additional information
  82472. * regarding copyright ownership. The ASF licenses this file
  82473. * to you under the Apache License, Version 2.0 (the
  82474. * "License"); you may not use this file except in compliance
  82475. * with the License. You may obtain a copy of the License at
  82476. *
  82477. * http://www.apache.org/licenses/LICENSE-2.0
  82478. *
  82479. * Unless required by applicable law or agreed to in writing,
  82480. * software distributed under the License is distributed on an
  82481. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82482. * KIND, either express or implied. See the License for the
  82483. * specific language governing permissions and limitations
  82484. * under the License.
  82485. */
  82486. /**
  82487. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82488. */
  82489. /*
  82490. * Licensed to the Apache Software Foundation (ASF) under one
  82491. * or more contributor license agreements. See the NOTICE file
  82492. * distributed with this work for additional information
  82493. * regarding copyright ownership. The ASF licenses this file
  82494. * to you under the Apache License, Version 2.0 (the
  82495. * "License"); you may not use this file except in compliance
  82496. * with the License. You may obtain a copy of the License at
  82497. *
  82498. * http://www.apache.org/licenses/LICENSE-2.0
  82499. *
  82500. * Unless required by applicable law or agreed to in writing,
  82501. * software distributed under the License is distributed on an
  82502. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82503. * KIND, either express or implied. See the License for the
  82504. * specific language governing permissions and limitations
  82505. * under the License.
  82506. */
  82507. use(install$37);
  82508. /*
  82509. * Licensed to the Apache Software Foundation (ASF) under one
  82510. * or more contributor license agreements. See the NOTICE file
  82511. * distributed with this work for additional information
  82512. * regarding copyright ownership. The ASF licenses this file
  82513. * to you under the Apache License, Version 2.0 (the
  82514. * "License"); you may not use this file except in compliance
  82515. * with the License. You may obtain a copy of the License at
  82516. *
  82517. * http://www.apache.org/licenses/LICENSE-2.0
  82518. *
  82519. * Unless required by applicable law or agreed to in writing,
  82520. * software distributed under the License is distributed on an
  82521. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82522. * KIND, either express or implied. See the License for the
  82523. * specific language governing permissions and limitations
  82524. * under the License.
  82525. */
  82526. /**
  82527. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82528. */
  82529. /*
  82530. * Licensed to the Apache Software Foundation (ASF) under one
  82531. * or more contributor license agreements. See the NOTICE file
  82532. * distributed with this work for additional information
  82533. * regarding copyright ownership. The ASF licenses this file
  82534. * to you under the Apache License, Version 2.0 (the
  82535. * "License"); you may not use this file except in compliance
  82536. * with the License. You may obtain a copy of the License at
  82537. *
  82538. * http://www.apache.org/licenses/LICENSE-2.0
  82539. *
  82540. * Unless required by applicable law or agreed to in writing,
  82541. * software distributed under the License is distributed on an
  82542. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82543. * KIND, either express or implied. See the License for the
  82544. * specific language governing permissions and limitations
  82545. * under the License.
  82546. */
  82547. var MarkAreaModel =
  82548. /** @class */
  82549. function (_super) {
  82550. __extends(MarkAreaModel, _super);
  82551. function MarkAreaModel() {
  82552. var _this = _super !== null && _super.apply(this, arguments) || this;
  82553. _this.type = MarkAreaModel.type;
  82554. return _this;
  82555. }
  82556. MarkAreaModel.prototype.createMarkerModelFromSeries = function (markerOpt, masterMarkerModel, ecModel) {
  82557. return new MarkAreaModel(markerOpt, masterMarkerModel, ecModel);
  82558. };
  82559. MarkAreaModel.type = 'markArea';
  82560. MarkAreaModel.defaultOption = {
  82561. zlevel: 0,
  82562. // PENDING
  82563. z: 1,
  82564. tooltip: {
  82565. trigger: 'item'
  82566. },
  82567. // markArea should fixed on the coordinate system
  82568. animation: false,
  82569. label: {
  82570. show: true,
  82571. position: 'top'
  82572. },
  82573. itemStyle: {
  82574. // color and borderColor default to use color from series
  82575. // color: 'auto'
  82576. // borderColor: 'auto'
  82577. borderWidth: 0
  82578. },
  82579. emphasis: {
  82580. label: {
  82581. show: true,
  82582. position: 'top'
  82583. }
  82584. }
  82585. };
  82586. return MarkAreaModel;
  82587. }(MarkerModel);
  82588. /*
  82589. * Licensed to the Apache Software Foundation (ASF) under one
  82590. * or more contributor license agreements. See the NOTICE file
  82591. * distributed with this work for additional information
  82592. * regarding copyright ownership. The ASF licenses this file
  82593. * to you under the Apache License, Version 2.0 (the
  82594. * "License"); you may not use this file except in compliance
  82595. * with the License. You may obtain a copy of the License at
  82596. *
  82597. * http://www.apache.org/licenses/LICENSE-2.0
  82598. *
  82599. * Unless required by applicable law or agreed to in writing,
  82600. * software distributed under the License is distributed on an
  82601. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82602. * KIND, either express or implied. See the License for the
  82603. * specific language governing permissions and limitations
  82604. * under the License.
  82605. */
  82606. /**
  82607. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82608. */
  82609. /*
  82610. * Licensed to the Apache Software Foundation (ASF) under one
  82611. * or more contributor license agreements. See the NOTICE file
  82612. * distributed with this work for additional information
  82613. * regarding copyright ownership. The ASF licenses this file
  82614. * to you under the Apache License, Version 2.0 (the
  82615. * "License"); you may not use this file except in compliance
  82616. * with the License. You may obtain a copy of the License at
  82617. *
  82618. * http://www.apache.org/licenses/LICENSE-2.0
  82619. *
  82620. * Unless required by applicable law or agreed to in writing,
  82621. * software distributed under the License is distributed on an
  82622. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82623. * KIND, either express or implied. See the License for the
  82624. * specific language governing permissions and limitations
  82625. * under the License.
  82626. */
  82627. var inner$17 = makeInner();
  82628. var markAreaTransform = function (seriesModel, coordSys, maModel, item) {
  82629. var lt = dataTransform(seriesModel, item[0]);
  82630. var rb = dataTransform(seriesModel, item[1]); // FIXME make sure lt is less than rb
  82631. var ltCoord = lt.coord;
  82632. var rbCoord = rb.coord;
  82633. ltCoord[0] = retrieve(ltCoord[0], -Infinity);
  82634. ltCoord[1] = retrieve(ltCoord[1], -Infinity);
  82635. rbCoord[0] = retrieve(rbCoord[0], Infinity);
  82636. rbCoord[1] = retrieve(rbCoord[1], Infinity); // Merge option into one
  82637. var result = mergeAll([{}, lt, rb]);
  82638. result.coord = [lt.coord, rb.coord];
  82639. result.x0 = lt.x;
  82640. result.y0 = lt.y;
  82641. result.x1 = rb.x;
  82642. result.y1 = rb.y;
  82643. return result;
  82644. };
  82645. function isInifinity$1(val) {
  82646. return !isNaN(val) && !isFinite(val);
  82647. } // If a markArea has one dim
  82648. function ifMarkAreaHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
  82649. var otherDimIndex = 1 - dimIndex;
  82650. return isInifinity$1(fromCoord[otherDimIndex]) && isInifinity$1(toCoord[otherDimIndex]);
  82651. }
  82652. function markAreaFilter(coordSys, item) {
  82653. var fromCoord = item.coord[0];
  82654. var toCoord = item.coord[1];
  82655. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  82656. // In case
  82657. // {
  82658. // markArea: {
  82659. // data: [{ yAxis: 2 }]
  82660. // }
  82661. // }
  82662. if (fromCoord && toCoord && (ifMarkAreaHasOnlyDim(1, fromCoord, toCoord, coordSys) || ifMarkAreaHasOnlyDim(0, fromCoord, toCoord, coordSys))) {
  82663. return true;
  82664. }
  82665. }
  82666. return dataFilter$1(coordSys, {
  82667. coord: fromCoord,
  82668. x: item.x0,
  82669. y: item.y0
  82670. }) || dataFilter$1(coordSys, {
  82671. coord: toCoord,
  82672. x: item.x1,
  82673. y: item.y1
  82674. });
  82675. } // dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
  82676. function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
  82677. var coordSys = seriesModel.coordinateSystem;
  82678. var itemModel = data.getItemModel(idx);
  82679. var point;
  82680. var xPx = parsePercent$1(itemModel.get(dims[0]), api.getWidth());
  82681. var yPx = parsePercent$1(itemModel.get(dims[1]), api.getHeight());
  82682. if (!isNaN(xPx) && !isNaN(yPx)) {
  82683. point = [xPx, yPx];
  82684. } else {
  82685. // Chart like bar may have there own marker positioning logic
  82686. if (seriesModel.getMarkerPosition) {
  82687. // Use the getMarkerPoisition
  82688. point = seriesModel.getMarkerPosition(data.getValues(dims, idx));
  82689. } else {
  82690. var x = data.get(dims[0], idx);
  82691. var y = data.get(dims[1], idx);
  82692. var pt = [x, y];
  82693. coordSys.clampData && coordSys.clampData(pt, pt);
  82694. point = coordSys.dataToPoint(pt, true);
  82695. }
  82696. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  82697. // TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
  82698. var xAxis = coordSys.getAxis('x');
  82699. var yAxis = coordSys.getAxis('y');
  82700. var x = data.get(dims[0], idx);
  82701. var y = data.get(dims[1], idx);
  82702. if (isInifinity$1(x)) {
  82703. point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
  82704. } else if (isInifinity$1(y)) {
  82705. point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
  82706. }
  82707. } // Use x, y if has any
  82708. if (!isNaN(xPx)) {
  82709. point[0] = xPx;
  82710. }
  82711. if (!isNaN(yPx)) {
  82712. point[1] = yPx;
  82713. }
  82714. }
  82715. return point;
  82716. }
  82717. var dimPermutations = [['x0', 'y0'], ['x1', 'y0'], ['x1', 'y1'], ['x0', 'y1']];
  82718. var MarkAreaView =
  82719. /** @class */
  82720. function (_super) {
  82721. __extends(MarkAreaView, _super);
  82722. function MarkAreaView() {
  82723. var _this = _super !== null && _super.apply(this, arguments) || this;
  82724. _this.type = MarkAreaView.type;
  82725. return _this;
  82726. }
  82727. MarkAreaView.prototype.updateTransform = function (markAreaModel, ecModel, api) {
  82728. ecModel.eachSeries(function (seriesModel) {
  82729. var maModel = MarkerModel.getMarkerModelFromSeries(seriesModel, 'markArea');
  82730. if (maModel) {
  82731. var areaData_1 = maModel.getData();
  82732. areaData_1.each(function (idx) {
  82733. var points = map(dimPermutations, function (dim) {
  82734. return getSingleMarkerEndPoint(areaData_1, idx, dim, seriesModel, api);
  82735. }); // Layout
  82736. areaData_1.setItemLayout(idx, points);
  82737. var el = areaData_1.getItemGraphicEl(idx);
  82738. el.setShape('points', points);
  82739. });
  82740. }
  82741. }, this);
  82742. };
  82743. MarkAreaView.prototype.renderSeries = function (seriesModel, maModel, ecModel, api) {
  82744. var coordSys = seriesModel.coordinateSystem;
  82745. var seriesId = seriesModel.id;
  82746. var seriesData = seriesModel.getData();
  82747. var areaGroupMap = this.markerGroupMap;
  82748. var polygonGroup = areaGroupMap.get(seriesId) || areaGroupMap.set(seriesId, {
  82749. group: new Group()
  82750. });
  82751. this.group.add(polygonGroup.group);
  82752. this.markKeep(polygonGroup);
  82753. var areaData = createList$3(coordSys, seriesModel, maModel); // Line data for tooltip and formatter
  82754. maModel.setData(areaData); // Update visual and layout of line
  82755. areaData.each(function (idx) {
  82756. // Layout
  82757. var points = map(dimPermutations, function (dim) {
  82758. return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
  82759. });
  82760. var xAxisScale = coordSys.getAxis('x').scale;
  82761. var yAxisScale = coordSys.getAxis('y').scale;
  82762. var xAxisExtent = xAxisScale.getExtent();
  82763. var yAxisExtent = yAxisScale.getExtent();
  82764. var xPointExtent = [xAxisScale.parse(areaData.get('x0', idx)), xAxisScale.parse(areaData.get('x1', idx))];
  82765. var yPointExtent = [yAxisScale.parse(areaData.get('y0', idx)), yAxisScale.parse(areaData.get('y1', idx))];
  82766. asc(xPointExtent);
  82767. asc(yPointExtent);
  82768. var overlapped = !(xAxisExtent[0] > xPointExtent[1] || xAxisExtent[1] < xPointExtent[0] || yAxisExtent[0] > yPointExtent[1] || yAxisExtent[1] < yPointExtent[0]); // If none of the area is inside coordSys, allClipped is set to be true
  82769. // in layout so that label will not be displayed. See #12591
  82770. var allClipped = !overlapped;
  82771. areaData.setItemLayout(idx, {
  82772. points: points,
  82773. allClipped: allClipped
  82774. });
  82775. var style = areaData.getItemModel(idx).getModel('itemStyle').getItemStyle();
  82776. var color = getVisualFromData(seriesData, 'color');
  82777. if (!style.fill) {
  82778. style.fill = color;
  82779. if (typeof style.fill === 'string') {
  82780. style.fill = modifyAlpha(style.fill, 0.4);
  82781. }
  82782. }
  82783. if (!style.stroke) {
  82784. style.stroke = color;
  82785. } // Visual
  82786. areaData.setItemVisual(idx, 'style', style);
  82787. });
  82788. areaData.diff(inner$17(polygonGroup).data).add(function (idx) {
  82789. var layout = areaData.getItemLayout(idx);
  82790. if (!layout.allClipped) {
  82791. var polygon = new Polygon({
  82792. shape: {
  82793. points: layout.points
  82794. }
  82795. });
  82796. areaData.setItemGraphicEl(idx, polygon);
  82797. polygonGroup.group.add(polygon);
  82798. }
  82799. }).update(function (newIdx, oldIdx) {
  82800. var polygon = inner$17(polygonGroup).data.getItemGraphicEl(oldIdx);
  82801. var layout = areaData.getItemLayout(newIdx);
  82802. if (!layout.allClipped) {
  82803. if (polygon) {
  82804. updateProps(polygon, {
  82805. shape: {
  82806. points: layout.points
  82807. }
  82808. }, maModel, newIdx);
  82809. } else {
  82810. polygon = new Polygon({
  82811. shape: {
  82812. points: layout.points
  82813. }
  82814. });
  82815. }
  82816. areaData.setItemGraphicEl(newIdx, polygon);
  82817. polygonGroup.group.add(polygon);
  82818. } else if (polygon) {
  82819. polygonGroup.group.remove(polygon);
  82820. }
  82821. }).remove(function (idx) {
  82822. var polygon = inner$17(polygonGroup).data.getItemGraphicEl(idx);
  82823. polygonGroup.group.remove(polygon);
  82824. }).execute();
  82825. areaData.eachItemGraphicEl(function (polygon, idx) {
  82826. var itemModel = areaData.getItemModel(idx);
  82827. var style = areaData.getItemVisual(idx, 'style');
  82828. polygon.useStyle(areaData.getItemVisual(idx, 'style'));
  82829. setLabelStyle(polygon, getLabelStatesModels(itemModel), {
  82830. labelFetcher: maModel,
  82831. labelDataIndex: idx,
  82832. defaultText: areaData.getName(idx) || '',
  82833. inheritColor: typeof style.fill === 'string' ? modifyAlpha(style.fill, 1) : '#000'
  82834. });
  82835. setStatesStylesFromModel(polygon, itemModel);
  82836. enableHoverEmphasis(polygon);
  82837. getECData(polygon).dataModel = maModel;
  82838. });
  82839. inner$17(polygonGroup).data = areaData;
  82840. polygonGroup.group.silent = maModel.get('silent') || seriesModel.get('silent');
  82841. };
  82842. MarkAreaView.type = 'markArea';
  82843. return MarkAreaView;
  82844. }(MarkerView);
  82845. function createList$3(coordSys, seriesModel, maModel) {
  82846. var coordDimsInfos;
  82847. var areaData;
  82848. var dims = ['x0', 'y0', 'x1', 'y1'];
  82849. if (coordSys) {
  82850. coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
  82851. var data = seriesModel.getData();
  82852. var info = data.getDimensionInfo(data.mapDimension(coordDim)) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
  82853. return defaults({
  82854. name: coordDim
  82855. }, info);
  82856. });
  82857. areaData = new List(map(dims, function (dim, idx) {
  82858. return {
  82859. name: dim,
  82860. type: coordDimsInfos[idx % 2].type
  82861. };
  82862. }), maModel);
  82863. } else {
  82864. coordDimsInfos = [{
  82865. name: 'value',
  82866. type: 'float'
  82867. }];
  82868. areaData = new List(coordDimsInfos, maModel);
  82869. }
  82870. var optData = map(maModel.get('data'), curry(markAreaTransform, seriesModel, coordSys, maModel));
  82871. if (coordSys) {
  82872. optData = filter(optData, curry(markAreaFilter, coordSys));
  82873. }
  82874. var dimValueGetter$$1 = coordSys ? function (item, dimName, dataIndex, dimIndex) {
  82875. // TODO should convert to ParsedValue?
  82876. return item.coord[Math.floor(dimIndex / 2)][dimIndex % 2];
  82877. } : function (item) {
  82878. return item.value;
  82879. };
  82880. areaData.initData(optData, null, dimValueGetter$$1);
  82881. areaData.hasItemOption = true;
  82882. return areaData;
  82883. }
  82884. /*
  82885. * Licensed to the Apache Software Foundation (ASF) under one
  82886. * or more contributor license agreements. See the NOTICE file
  82887. * distributed with this work for additional information
  82888. * regarding copyright ownership. The ASF licenses this file
  82889. * to you under the Apache License, Version 2.0 (the
  82890. * "License"); you may not use this file except in compliance
  82891. * with the License. You may obtain a copy of the License at
  82892. *
  82893. * http://www.apache.org/licenses/LICENSE-2.0
  82894. *
  82895. * Unless required by applicable law or agreed to in writing,
  82896. * software distributed under the License is distributed on an
  82897. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82898. * KIND, either express or implied. See the License for the
  82899. * specific language governing permissions and limitations
  82900. * under the License.
  82901. */
  82902. /**
  82903. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82904. */
  82905. /*
  82906. * Licensed to the Apache Software Foundation (ASF) under one
  82907. * or more contributor license agreements. See the NOTICE file
  82908. * distributed with this work for additional information
  82909. * regarding copyright ownership. The ASF licenses this file
  82910. * to you under the Apache License, Version 2.0 (the
  82911. * "License"); you may not use this file except in compliance
  82912. * with the License. You may obtain a copy of the License at
  82913. *
  82914. * http://www.apache.org/licenses/LICENSE-2.0
  82915. *
  82916. * Unless required by applicable law or agreed to in writing,
  82917. * software distributed under the License is distributed on an
  82918. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82919. * KIND, either express or implied. See the License for the
  82920. * specific language governing permissions and limitations
  82921. * under the License.
  82922. */
  82923. function install$38(registers) {
  82924. registers.registerComponentModel(MarkAreaModel);
  82925. registers.registerComponentView(MarkAreaView);
  82926. registers.registerPreprocessor(function (opt) {
  82927. if (checkMarkerInSeries(opt.series, 'markArea')) {
  82928. // Make sure markArea component is enabled
  82929. opt.markArea = opt.markArea || {};
  82930. }
  82931. });
  82932. }
  82933. /*
  82934. * Licensed to the Apache Software Foundation (ASF) under one
  82935. * or more contributor license agreements. See the NOTICE file
  82936. * distributed with this work for additional information
  82937. * regarding copyright ownership. The ASF licenses this file
  82938. * to you under the Apache License, Version 2.0 (the
  82939. * "License"); you may not use this file except in compliance
  82940. * with the License. You may obtain a copy of the License at
  82941. *
  82942. * http://www.apache.org/licenses/LICENSE-2.0
  82943. *
  82944. * Unless required by applicable law or agreed to in writing,
  82945. * software distributed under the License is distributed on an
  82946. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82947. * KIND, either express or implied. See the License for the
  82948. * specific language governing permissions and limitations
  82949. * under the License.
  82950. */
  82951. /**
  82952. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82953. */
  82954. /*
  82955. * Licensed to the Apache Software Foundation (ASF) under one
  82956. * or more contributor license agreements. See the NOTICE file
  82957. * distributed with this work for additional information
  82958. * regarding copyright ownership. The ASF licenses this file
  82959. * to you under the Apache License, Version 2.0 (the
  82960. * "License"); you may not use this file except in compliance
  82961. * with the License. You may obtain a copy of the License at
  82962. *
  82963. * http://www.apache.org/licenses/LICENSE-2.0
  82964. *
  82965. * Unless required by applicable law or agreed to in writing,
  82966. * software distributed under the License is distributed on an
  82967. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82968. * KIND, either express or implied. See the License for the
  82969. * specific language governing permissions and limitations
  82970. * under the License.
  82971. */
  82972. use(install$38);
  82973. /*
  82974. * Licensed to the Apache Software Foundation (ASF) under one
  82975. * or more contributor license agreements. See the NOTICE file
  82976. * distributed with this work for additional information
  82977. * regarding copyright ownership. The ASF licenses this file
  82978. * to you under the Apache License, Version 2.0 (the
  82979. * "License"); you may not use this file except in compliance
  82980. * with the License. You may obtain a copy of the License at
  82981. *
  82982. * http://www.apache.org/licenses/LICENSE-2.0
  82983. *
  82984. * Unless required by applicable law or agreed to in writing,
  82985. * software distributed under the License is distributed on an
  82986. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  82987. * KIND, either express or implied. See the License for the
  82988. * specific language governing permissions and limitations
  82989. * under the License.
  82990. */
  82991. /**
  82992. * AUTO-GENERATED FILE. DO NOT MODIFY.
  82993. */
  82994. /*
  82995. * Licensed to the Apache Software Foundation (ASF) under one
  82996. * or more contributor license agreements. See the NOTICE file
  82997. * distributed with this work for additional information
  82998. * regarding copyright ownership. The ASF licenses this file
  82999. * to you under the Apache License, Version 2.0 (the
  83000. * "License"); you may not use this file except in compliance
  83001. * with the License. You may obtain a copy of the License at
  83002. *
  83003. * http://www.apache.org/licenses/LICENSE-2.0
  83004. *
  83005. * Unless required by applicable law or agreed to in writing,
  83006. * software distributed under the License is distributed on an
  83007. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83008. * KIND, either express or implied. See the License for the
  83009. * specific language governing permissions and limitations
  83010. * under the License.
  83011. */
  83012. var TimelineModel =
  83013. /** @class */
  83014. function (_super) {
  83015. __extends(TimelineModel, _super);
  83016. function TimelineModel() {
  83017. var _this = _super !== null && _super.apply(this, arguments) || this;
  83018. _this.type = TimelineModel.type;
  83019. _this.layoutMode = 'box';
  83020. return _this;
  83021. }
  83022. /**
  83023. * @override
  83024. */
  83025. TimelineModel.prototype.init = function (option, parentModel, ecModel) {
  83026. this.mergeDefaultAndTheme(option, ecModel);
  83027. this._initData();
  83028. };
  83029. /**
  83030. * @override
  83031. */
  83032. TimelineModel.prototype.mergeOption = function (option) {
  83033. _super.prototype.mergeOption.apply(this, arguments);
  83034. this._initData();
  83035. };
  83036. TimelineModel.prototype.setCurrentIndex = function (currentIndex) {
  83037. if (currentIndex == null) {
  83038. currentIndex = this.option.currentIndex;
  83039. }
  83040. var count = this._data.count();
  83041. if (this.option.loop) {
  83042. currentIndex = (currentIndex % count + count) % count;
  83043. } else {
  83044. currentIndex >= count && (currentIndex = count - 1);
  83045. currentIndex < 0 && (currentIndex = 0);
  83046. }
  83047. this.option.currentIndex = currentIndex;
  83048. };
  83049. /**
  83050. * @return {number} currentIndex
  83051. */
  83052. TimelineModel.prototype.getCurrentIndex = function () {
  83053. return this.option.currentIndex;
  83054. };
  83055. /**
  83056. * @return {boolean}
  83057. */
  83058. TimelineModel.prototype.isIndexMax = function () {
  83059. return this.getCurrentIndex() >= this._data.count() - 1;
  83060. };
  83061. /**
  83062. * @param {boolean} state true: play, false: stop
  83063. */
  83064. TimelineModel.prototype.setPlayState = function (state) {
  83065. this.option.autoPlay = !!state;
  83066. };
  83067. /**
  83068. * @return {boolean} true: play, false: stop
  83069. */
  83070. TimelineModel.prototype.getPlayState = function () {
  83071. return !!this.option.autoPlay;
  83072. };
  83073. /**
  83074. * @private
  83075. */
  83076. TimelineModel.prototype._initData = function () {
  83077. var thisOption = this.option;
  83078. var dataArr = thisOption.data || [];
  83079. var axisType = thisOption.axisType;
  83080. var names = this._names = [];
  83081. var processedDataArr;
  83082. if (axisType === 'category') {
  83083. processedDataArr = [];
  83084. each$1(dataArr, function (item, index) {
  83085. var value = convertOptionIdName(getDataItemValue(item), '');
  83086. var newItem;
  83087. if (isObject$1(item)) {
  83088. newItem = clone(item);
  83089. newItem.value = index;
  83090. } else {
  83091. newItem = index;
  83092. }
  83093. processedDataArr.push(newItem);
  83094. names.push(value);
  83095. });
  83096. } else {
  83097. processedDataArr = dataArr;
  83098. }
  83099. var dimType = {
  83100. category: 'ordinal',
  83101. time: 'time',
  83102. value: 'number'
  83103. }[axisType] || 'number';
  83104. var data = this._data = new List([{
  83105. name: 'value',
  83106. type: dimType
  83107. }], this);
  83108. data.initData(processedDataArr, names);
  83109. };
  83110. TimelineModel.prototype.getData = function () {
  83111. return this._data;
  83112. };
  83113. /**
  83114. * @public
  83115. * @return {Array.<string>} categoreis
  83116. */
  83117. TimelineModel.prototype.getCategories = function () {
  83118. if (this.get('axisType') === 'category') {
  83119. return this._names.slice();
  83120. }
  83121. };
  83122. TimelineModel.type = 'timeline';
  83123. /**
  83124. * @protected
  83125. */
  83126. TimelineModel.defaultOption = {
  83127. zlevel: 0,
  83128. z: 4,
  83129. show: true,
  83130. axisType: 'time',
  83131. realtime: true,
  83132. left: '20%',
  83133. top: null,
  83134. right: '20%',
  83135. bottom: 0,
  83136. width: null,
  83137. height: 40,
  83138. padding: 5,
  83139. controlPosition: 'left',
  83140. autoPlay: false,
  83141. rewind: false,
  83142. loop: true,
  83143. playInterval: 2000,
  83144. currentIndex: 0,
  83145. itemStyle: {},
  83146. label: {
  83147. color: '#000'
  83148. },
  83149. data: []
  83150. };
  83151. return TimelineModel;
  83152. }(ComponentModel);
  83153. /*
  83154. * Licensed to the Apache Software Foundation (ASF) under one
  83155. * or more contributor license agreements. See the NOTICE file
  83156. * distributed with this work for additional information
  83157. * regarding copyright ownership. The ASF licenses this file
  83158. * to you under the Apache License, Version 2.0 (the
  83159. * "License"); you may not use this file except in compliance
  83160. * with the License. You may obtain a copy of the License at
  83161. *
  83162. * http://www.apache.org/licenses/LICENSE-2.0
  83163. *
  83164. * Unless required by applicable law or agreed to in writing,
  83165. * software distributed under the License is distributed on an
  83166. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83167. * KIND, either express or implied. See the License for the
  83168. * specific language governing permissions and limitations
  83169. * under the License.
  83170. */
  83171. /**
  83172. * AUTO-GENERATED FILE. DO NOT MODIFY.
  83173. */
  83174. /*
  83175. * Licensed to the Apache Software Foundation (ASF) under one
  83176. * or more contributor license agreements. See the NOTICE file
  83177. * distributed with this work for additional information
  83178. * regarding copyright ownership. The ASF licenses this file
  83179. * to you under the Apache License, Version 2.0 (the
  83180. * "License"); you may not use this file except in compliance
  83181. * with the License. You may obtain a copy of the License at
  83182. *
  83183. * http://www.apache.org/licenses/LICENSE-2.0
  83184. *
  83185. * Unless required by applicable law or agreed to in writing,
  83186. * software distributed under the License is distributed on an
  83187. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83188. * KIND, either express or implied. See the License for the
  83189. * specific language governing permissions and limitations
  83190. * under the License.
  83191. */
  83192. var SliderTimelineModel =
  83193. /** @class */
  83194. function (_super) {
  83195. __extends(SliderTimelineModel, _super);
  83196. function SliderTimelineModel() {
  83197. var _this = _super !== null && _super.apply(this, arguments) || this;
  83198. _this.type = SliderTimelineModel.type;
  83199. return _this;
  83200. }
  83201. SliderTimelineModel.type = 'timeline.slider';
  83202. /**
  83203. * @protected
  83204. */
  83205. SliderTimelineModel.defaultOption = inheritDefaultOption(TimelineModel.defaultOption, {
  83206. backgroundColor: 'rgba(0,0,0,0)',
  83207. borderColor: '#ccc',
  83208. borderWidth: 0,
  83209. orient: 'horizontal',
  83210. inverse: false,
  83211. tooltip: {
  83212. trigger: 'item' // data item may also have tootip attr.
  83213. },
  83214. symbol: 'circle',
  83215. symbolSize: 12,
  83216. lineStyle: {
  83217. show: true,
  83218. width: 2,
  83219. color: '#DAE1F5'
  83220. },
  83221. label: {
  83222. position: 'auto',
  83223. // When using number, label position is not
  83224. // restricted by viewRect.
  83225. // positive: right/bottom, negative: left/top
  83226. show: true,
  83227. interval: 'auto',
  83228. rotate: 0,
  83229. // formatter: null,
  83230. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  83231. color: '#A4B1D7'
  83232. },
  83233. itemStyle: {
  83234. color: '#A4B1D7',
  83235. borderWidth: 1
  83236. },
  83237. checkpointStyle: {
  83238. symbol: 'circle',
  83239. symbolSize: 15,
  83240. color: '#316bf3',
  83241. borderColor: '#fff',
  83242. borderWidth: 2,
  83243. shadowBlur: 2,
  83244. shadowOffsetX: 1,
  83245. shadowOffsetY: 1,
  83246. shadowColor: 'rgba(0, 0, 0, 0.3)',
  83247. // borderColor: 'rgba(194,53,49, 0.5)',
  83248. animation: true,
  83249. animationDuration: 300,
  83250. animationEasing: 'quinticInOut'
  83251. },
  83252. controlStyle: {
  83253. show: true,
  83254. showPlayBtn: true,
  83255. showPrevBtn: true,
  83256. showNextBtn: true,
  83257. itemSize: 24,
  83258. itemGap: 12,
  83259. position: 'left',
  83260. 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',
  83261. 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',
  83262. nextIcon: 'M2,18.5A1.52,1.52,0,0,1,.92,18a1.49,1.49,0,0,1,0-2.12L7.81,9.36,1,3.11A1.5,1.5,0,1,1,3,.89l8,7.34a1.48,1.48,0,0,1,.49,1.09,1.51,1.51,0,0,1-.46,1.1L3,18.08A1.5,1.5,0,0,1,2,18.5Z',
  83263. prevIcon: 'M10,.5A1.52,1.52,0,0,1,11.08,1a1.49,1.49,0,0,1,0,2.12L4.19,9.64,11,15.89a1.5,1.5,0,1,1-2,2.22L1,10.77A1.48,1.48,0,0,1,.5,9.68,1.51,1.51,0,0,1,1,8.58L9,.92A1.5,1.5,0,0,1,10,.5Z',
  83264. prevBtnSize: 18,
  83265. nextBtnSize: 18,
  83266. color: '#A4B1D7',
  83267. borderColor: '#A4B1D7',
  83268. borderWidth: 1
  83269. },
  83270. emphasis: {
  83271. label: {
  83272. show: true,
  83273. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  83274. color: '#6f778d'
  83275. },
  83276. itemStyle: {
  83277. color: '#316BF3'
  83278. },
  83279. controlStyle: {
  83280. color: '#316BF3',
  83281. borderColor: '#316BF3',
  83282. borderWidth: 2
  83283. }
  83284. },
  83285. progress: {
  83286. lineStyle: {
  83287. color: '#316BF3'
  83288. },
  83289. itemStyle: {
  83290. color: '#316BF3'
  83291. },
  83292. label: {
  83293. color: '#6f778d'
  83294. }
  83295. },
  83296. data: []
  83297. });
  83298. return SliderTimelineModel;
  83299. }(TimelineModel);
  83300. mixin(SliderTimelineModel, DataFormatMixin.prototype);
  83301. /*
  83302. * Licensed to the Apache Software Foundation (ASF) under one
  83303. * or more contributor license agreements. See the NOTICE file
  83304. * distributed with this work for additional information
  83305. * regarding copyright ownership. The ASF licenses this file
  83306. * to you under the Apache License, Version 2.0 (the
  83307. * "License"); you may not use this file except in compliance
  83308. * with the License. You may obtain a copy of the License at
  83309. *
  83310. * http://www.apache.org/licenses/LICENSE-2.0
  83311. *
  83312. * Unless required by applicable law or agreed to in writing,
  83313. * software distributed under the License is distributed on an
  83314. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83315. * KIND, either express or implied. See the License for the
  83316. * specific language governing permissions and limitations
  83317. * under the License.
  83318. */
  83319. /**
  83320. * AUTO-GENERATED FILE. DO NOT MODIFY.
  83321. */
  83322. /*
  83323. * Licensed to the Apache Software Foundation (ASF) under one
  83324. * or more contributor license agreements. See the NOTICE file
  83325. * distributed with this work for additional information
  83326. * regarding copyright ownership. The ASF licenses this file
  83327. * to you under the Apache License, Version 2.0 (the
  83328. * "License"); you may not use this file except in compliance
  83329. * with the License. You may obtain a copy of the License at
  83330. *
  83331. * http://www.apache.org/licenses/LICENSE-2.0
  83332. *
  83333. * Unless required by applicable law or agreed to in writing,
  83334. * software distributed under the License is distributed on an
  83335. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83336. * KIND, either express or implied. See the License for the
  83337. * specific language governing permissions and limitations
  83338. * under the License.
  83339. */
  83340. var TimelineView =
  83341. /** @class */
  83342. function (_super) {
  83343. __extends(TimelineView, _super);
  83344. function TimelineView() {
  83345. var _this = _super !== null && _super.apply(this, arguments) || this;
  83346. _this.type = TimelineView.type;
  83347. return _this;
  83348. }
  83349. TimelineView.type = 'timeline';
  83350. return TimelineView;
  83351. }(ComponentView);
  83352. /*
  83353. * Licensed to the Apache Software Foundation (ASF) under one
  83354. * or more contributor license agreements. See the NOTICE file
  83355. * distributed with this work for additional information
  83356. * regarding copyright ownership. The ASF licenses this file
  83357. * to you under the Apache License, Version 2.0 (the
  83358. * "License"); you may not use this file except in compliance
  83359. * with the License. You may obtain a copy of the License at
  83360. *
  83361. * http://www.apache.org/licenses/LICENSE-2.0
  83362. *
  83363. * Unless required by applicable law or agreed to in writing,
  83364. * software distributed under the License is distributed on an
  83365. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83366. * KIND, either express or implied. See the License for the
  83367. * specific language governing permissions and limitations
  83368. * under the License.
  83369. */
  83370. /**
  83371. * AUTO-GENERATED FILE. DO NOT MODIFY.
  83372. */
  83373. /*
  83374. * Licensed to the Apache Software Foundation (ASF) under one
  83375. * or more contributor license agreements. See the NOTICE file
  83376. * distributed with this work for additional information
  83377. * regarding copyright ownership. The ASF licenses this file
  83378. * to you under the Apache License, Version 2.0 (the
  83379. * "License"); you may not use this file except in compliance
  83380. * with the License. You may obtain a copy of the License at
  83381. *
  83382. * http://www.apache.org/licenses/LICENSE-2.0
  83383. *
  83384. * Unless required by applicable law or agreed to in writing,
  83385. * software distributed under the License is distributed on an
  83386. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83387. * KIND, either express or implied. See the License for the
  83388. * specific language governing permissions and limitations
  83389. * under the License.
  83390. */
  83391. /**
  83392. * Extend axis 2d
  83393. */
  83394. var TimelineAxis =
  83395. /** @class */
  83396. function (_super) {
  83397. __extends(TimelineAxis, _super);
  83398. function TimelineAxis(dim, scale, coordExtent, axisType) {
  83399. var _this = _super.call(this, dim, scale, coordExtent) || this;
  83400. _this.type = axisType || 'value';
  83401. return _this;
  83402. }
  83403. /**
  83404. * @override
  83405. */
  83406. TimelineAxis.prototype.getLabelModel = function () {
  83407. // Force override
  83408. return this.model.getModel('label');
  83409. };
  83410. /**
  83411. * @override
  83412. */
  83413. TimelineAxis.prototype.isHorizontal = function () {
  83414. return this.model.get('orient') === 'horizontal';
  83415. };
  83416. return TimelineAxis;
  83417. }(Axis);
  83418. /*
  83419. * Licensed to the Apache Software Foundation (ASF) under one
  83420. * or more contributor license agreements. See the NOTICE file
  83421. * distributed with this work for additional information
  83422. * regarding copyright ownership. The ASF licenses this file
  83423. * to you under the Apache License, Version 2.0 (the
  83424. * "License"); you may not use this file except in compliance
  83425. * with the License. You may obtain a copy of the License at
  83426. *
  83427. * http://www.apache.org/licenses/LICENSE-2.0
  83428. *
  83429. * Unless required by applicable law or agreed to in writing,
  83430. * software distributed under the License is distributed on an
  83431. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83432. * KIND, either express or implied. See the License for the
  83433. * specific language governing permissions and limitations
  83434. * under the License.
  83435. */
  83436. /**
  83437. * AUTO-GENERATED FILE. DO NOT MODIFY.
  83438. */
  83439. /*
  83440. * Licensed to the Apache Software Foundation (ASF) under one
  83441. * or more contributor license agreements. See the NOTICE file
  83442. * distributed with this work for additional information
  83443. * regarding copyright ownership. The ASF licenses this file
  83444. * to you under the Apache License, Version 2.0 (the
  83445. * "License"); you may not use this file except in compliance
  83446. * with the License. You may obtain a copy of the License at
  83447. *
  83448. * http://www.apache.org/licenses/LICENSE-2.0
  83449. *
  83450. * Unless required by applicable law or agreed to in writing,
  83451. * software distributed under the License is distributed on an
  83452. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  83453. * KIND, either express or implied. See the License for the
  83454. * specific language governing permissions and limitations
  83455. * under the License.
  83456. */
  83457. var PI$7 = Math.PI;
  83458. var labelDataIndexStore = makeInner();
  83459. var SliderTimelineView =
  83460. /** @class */
  83461. function (_super) {
  83462. __extends(SliderTimelineView, _super);
  83463. function SliderTimelineView() {
  83464. var _this = _super !== null && _super.apply(this, arguments) || this;
  83465. _this.type = SliderTimelineView.type;
  83466. return _this;
  83467. }
  83468. SliderTimelineView.prototype.init = function (ecModel, api) {
  83469. this.api = api;
  83470. };
  83471. /**
  83472. * @override
  83473. */
  83474. SliderTimelineView.prototype.render = function (timelineModel, ecModel, api) {
  83475. this.model = timelineModel;
  83476. this.api = api;
  83477. this.ecModel = ecModel;
  83478. this.group.removeAll();
  83479. if (timelineModel.get('show', true)) {
  83480. var layoutInfo_1 = this._layout(timelineModel, api);
  83481. var mainGroup_1 = this._createGroup('_mainGroup');
  83482. var labelGroup = this._createGroup('_labelGroup');
  83483. var axis_1 = this._axis = this._createAxis(layoutInfo_1, timelineModel);
  83484. timelineModel.formatTooltip = function (dataIndex) {
  83485. var name = axis_1.scale.getLabel({
  83486. value: dataIndex
  83487. });
  83488. return createTooltipMarkup('nameValue', {
  83489. noName: true,
  83490. value: name
  83491. });
  83492. };
  83493. each$1(['AxisLine', 'AxisTick', 'Control', 'CurrentPointer'], function (name) {
  83494. this['_render' + name](layoutInfo_1, mainGroup_1, axis_1, timelineModel);
  83495. }, this);
  83496. this._renderAxisLabel(layoutInfo_1, labelGroup, axis_1, timelineModel);
  83497. this._position(layoutInfo_1, timelineModel);
  83498. }
  83499. this._doPlayStop();
  83500. this._updateTicksStatus();
  83501. };
  83502. /**
  83503. * @override
  83504. */
  83505. SliderTimelineView.prototype.remove = function () {
  83506. this._clearTimer();
  83507. this.group.removeAll();
  83508. };
  83509. /**
  83510. * @override
  83511. */
  83512. SliderTimelineView.prototype.dispose = function () {
  83513. this._clearTimer();
  83514. };
  83515. SliderTimelineView.prototype._layout = function (timelineModel, api) {
  83516. var labelPosOpt = timelineModel.get(['label', 'position']);
  83517. var orient = timelineModel.get('orient');
  83518. var viewRect = getViewRect$5(timelineModel, api);
  83519. var parsedLabelPos; // Auto label offset.
  83520. if (labelPosOpt == null || labelPosOpt === 'auto') {
  83521. parsedLabelPos = orient === 'horizontal' ? viewRect.y + viewRect.height / 2 < api.getHeight() / 2 ? '-' : '+' : viewRect.x + viewRect.width / 2 < api.getWidth() / 2 ? '+' : '-';
  83522. } else if (isString(labelPosOpt)) {
  83523. parsedLabelPos = {
  83524. horizontal: {
  83525. top: '-',
  83526. bottom: '+'
  83527. },
  83528. vertical: {
  83529. left: '-',
  83530. right: '+'
  83531. }
  83532. }[orient][labelPosOpt];
  83533. } else {
  83534. // is number
  83535. parsedLabelPos = labelPosOpt;
  83536. }
  83537. var labelAlignMap = {
  83538. horizontal: 'center',
  83539. vertical: parsedLabelPos >= 0 || parsedLabelPos === '+' ? 'left' : 'right'
  83540. };
  83541. var labelBaselineMap = {
  83542. horizontal: parsedLabelPos >= 0 || parsedLabelPos === '+' ? 'top' : 'bottom',
  83543. vertical: 'middle'
  83544. };
  83545. var rotationMap = {
  83546. horizontal: 0,
  83547. vertical: PI$7 / 2
  83548. }; // Position
  83549. var mainLength = orient === 'vertical' ? viewRect.height : viewRect.width;
  83550. var controlModel = timelineModel.getModel('controlStyle');
  83551. var showControl = controlModel.get('show', true);
  83552. var controlSize = showControl ? controlModel.get('itemSize') : 0;
  83553. var controlGap = showControl ? controlModel.get('itemGap') : 0;
  83554. var sizePlusGap = controlSize + controlGap; // Special label rotate.
  83555. var labelRotation = timelineModel.get(['label', 'rotate']) || 0;
  83556. labelRotation = labelRotation * PI$7 / 180; // To radian.
  83557. var playPosition;
  83558. var prevBtnPosition;
  83559. var nextBtnPosition;
  83560. var controlPosition = controlModel.get('position', true);
  83561. var showPlayBtn = showControl && controlModel.get('showPlayBtn', true);
  83562. var showPrevBtn = showControl && controlModel.get('showPrevBtn', true);
  83563. var showNextBtn = showControl && controlModel.get('showNextBtn', true);
  83564. var xLeft = 0;
  83565. var xRight = mainLength; // position[0] means left, position[1] means middle.
  83566. if (controlPosition === 'left' || controlPosition === 'bottom') {
  83567. showPlayBtn && (playPosition = [0, 0], xLeft += sizePlusGap);
  83568. showPrevBtn && (prevBtnPosition = [xLeft, 0], xLeft += sizePlusGap);
  83569. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  83570. } else {
  83571. // 'top' 'right'
  83572. showPlayBtn && (playPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  83573. showPrevBtn && (prevBtnPosition = [0, 0], xLeft += sizePlusGap);
  83574. showNextBtn && (nextBtnPosition = [xRight - controlSize, 0], xRight -= sizePlusGap);
  83575. }
  83576. var axisExtent = [xLeft, xRight];
  83577. if (timelineModel.get('inverse')) {
  83578. axisExtent.reverse();
  83579. }
  83580. return {
  83581. viewRect: viewRect,
  83582. mainLength: mainLength,
  83583. orient: orient,
  83584. rotation: rotationMap[orient],
  83585. labelRotation: labelRotation,
  83586. labelPosOpt: parsedLabelPos,
  83587. labelAlign: timelineModel.get(['label', 'align']) || labelAlignMap[orient],
  83588. labelBaseline: timelineModel.get(['label', 'verticalAlign']) || timelineModel.get(['label', 'baseline']) || labelBaselineMap[orient],
  83589. // Based on mainGroup.
  83590. playPosition: playPosition,
  83591. prevBtnPosition: prevBtnPosition,
  83592. nextBtnPosition: nextBtnPosition,
  83593. axisExtent: axisExtent,
  83594. controlSize: controlSize,
  83595. controlGap: controlGap
  83596. };
  83597. };
  83598. SliderTimelineView.prototype._position = function (layoutInfo, timelineModel) {
  83599. // Position is be called finally, because bounding rect is needed for
  83600. // adapt content to fill viewRect (auto adapt offset).
  83601. // Timeline may be not all in the viewRect when 'offset' is specified
  83602. // as a number, because it is more appropriate that label aligns at
  83603. // 'offset' but not the other edge defined by viewRect.
  83604. var mainGroup = this._mainGroup;
  83605. var labelGroup = this._labelGroup;
  83606. var viewRect = layoutInfo.viewRect;
  83607. if (layoutInfo.orient === 'vertical') {
  83608. // transform to horizontal, inverse rotate by left-top point.
  83609. var m = create$1();
  83610. var rotateOriginX = viewRect.x;
  83611. var rotateOriginY = viewRect.y + viewRect.height;
  83612. translate(m, m, [-rotateOriginX, -rotateOriginY]);
  83613. rotate(m, m, -PI$7 / 2);
  83614. translate(m, m, [rotateOriginX, rotateOriginY]);
  83615. viewRect = viewRect.clone();
  83616. viewRect.applyTransform(m);
  83617. }
  83618. var viewBound = getBound(viewRect);
  83619. var mainBound = getBound(mainGroup.getBoundingRect());
  83620. var labelBound = getBound(labelGroup.getBoundingRect());
  83621. var mainPosition = [mainGroup.x, mainGroup.y];
  83622. var labelsPosition = [labelGroup.x, labelGroup.y];
  83623. labelsPosition[0] = mainPosition[0] = viewBound[0][0];
  83624. var labelPosOpt = layoutInfo.labelPosOpt;
  83625. if (labelPosOpt == null || isString(labelPosOpt)) {
  83626. // '+' or '-'
  83627. var mainBoundIdx = labelPosOpt === '+' ? 0 : 1;
  83628. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  83629. toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx);
  83630. } else {
  83631. var mainBoundIdx = labelPosOpt >= 0 ? 0 : 1;
  83632. toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx);
  83633. labelsPosition[1] = mainPosition[1] + labelPosOpt;
  83634. }
  83635. mainGroup.setPosition(mainPosition);
  83636. labelGroup.setPosition(labelsPosition);
  83637. mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation;
  83638. setOrigin(mainGroup);
  83639. setOrigin(labelGroup);
  83640. function setOrigin(targetGroup) {
  83641. targetGroup.originX = viewBound[0][0] - targetGroup.x;
  83642. targetGroup.originY = viewBound[1][0] - targetGroup.y;
  83643. }
  83644. function getBound(rect) {
  83645. // [[xmin, xmax], [ymin, ymax]]
  83646. return [[rect.x, rect.x + rect.width], [rect.y, rect.y + rect.height]];
  83647. }
  83648. function toBound(fromPos, from, to, dimIdx, boundIdx) {
  83649. fromPos[dimIdx] += to[dimIdx][boundIdx] - from[dimIdx][boundIdx];
  83650. }
  83651. };
  83652. SliderTimelineView.prototype._createAxis = function (layoutInfo, timelineModel) {
  83653. var data = timelineModel.getData();
  83654. var axisType = timelineModel.get('axisType');
  83655. var scale = createScaleByModel$1(timelineModel, axisType); // Customize scale. The `tickValue` is `dataIndex`.
  83656. scale.getTicks = function () {
  83657. return data.mapArray(['value'], function (value) {
  83658. return {
  83659. value: value
  83660. };
  83661. });
  83662. };
  83663. var dataExtent = data.getDataExtent('value');
  83664. scale.setExtent(dataExtent[0], dataExtent[1]);
  83665. scale.niceTicks();
  83666. var axis = new TimelineAxis('value', scale, layoutInfo.axisExtent, axisType);
  83667. axis.model = timelineModel;
  83668. return axis;
  83669. };
  83670. SliderTimelineView.prototype._createGroup = function (key) {
  83671. var newGroup = this[key] = new Group();
  83672. this.group.add(newGroup);
  83673. return newGroup;
  83674. };
  83675. SliderTimelineView.prototype._renderAxisLine = function (layoutInfo, group, axis, timelineModel) {
  83676. var axisExtent = axis.getExtent();
  83677. if (!timelineModel.get(['lineStyle', 'show'])) {
  83678. return;
  83679. }
  83680. var line = new Line({
  83681. shape: {
  83682. x1: axisExtent[0],
  83683. y1: 0,
  83684. x2: axisExtent[1],
  83685. y2: 0
  83686. },
  83687. style: extend({
  83688. lineCap: 'round'
  83689. }, timelineModel.getModel('lineStyle').getLineStyle()),
  83690. silent: true,
  83691. z2: 1
  83692. });
  83693. group.add(line);
  83694. var progressLine = this._progressLine = new Line({
  83695. shape: {
  83696. x1: axisExtent[0],
  83697. x2: this._currentPointer ? this._currentPointer.x : axisExtent[0],
  83698. y1: 0,
  83699. y2: 0
  83700. },
  83701. style: defaults({
  83702. lineCap: 'round',
  83703. lineWidth: line.style.lineWidth
  83704. }, timelineModel.getModel(['progress', 'lineStyle']).getLineStyle()),
  83705. silent: true,
  83706. z2: 1
  83707. });
  83708. group.add(progressLine);
  83709. };
  83710. SliderTimelineView.prototype._renderAxisTick = function (layoutInfo, group, axis, timelineModel) {
  83711. var _this = this;
  83712. var data = timelineModel.getData(); // Show all ticks, despite ignoring strategy.
  83713. var ticks = axis.scale.getTicks();
  83714. this._tickSymbols = []; // The value is dataIndex, see the costomized scale.
  83715. each$1(ticks, function (tick) {
  83716. var tickCoord = axis.dataToCoord(tick.value);
  83717. var itemModel = data.getItemModel(tick.value);
  83718. var itemStyleModel = itemModel.getModel('itemStyle');
  83719. var hoverStyleModel = itemModel.getModel(['emphasis', 'itemStyle']);
  83720. var progressStyleModel = itemModel.getModel(['progress', 'itemStyle']);
  83721. var symbolOpt = {
  83722. x: tickCoord,
  83723. y: 0,
  83724. onclick: bind(_this._changeTimeline, _this, tick.value)
  83725. };
  83726. var el = giveSymbol(itemModel, itemStyleModel, group, symbolOpt);
  83727. el.ensureState('emphasis').style = hoverStyleModel.getItemStyle();
  83728. el.ensureState('progress').style = progressStyleModel.getItemStyle();
  83729. enableHoverEmphasis(el);
  83730. var ecData = getECData(el);
  83731. if (itemModel.get('tooltip')) {
  83732. ecData.dataIndex = tick.value;
  83733. ecData.dataModel = timelineModel;
  83734. } else {
  83735. ecData.dataIndex = ecData.dataModel = null;
  83736. }
  83737. _this._tickSymbols.push(el);
  83738. });
  83739. };
  83740. SliderTimelineView.prototype._renderAxisLabel = function (layoutInfo, group, axis, timelineModel) {
  83741. var _this = this;
  83742. var labelModel = axis.getLabelModel();
  83743. if (!labelModel.get('show')) {
  83744. return;
  83745. }
  83746. var data = timelineModel.getData();
  83747. var labels = axis.getViewLabels();
  83748. this._tickLabels = [];
  83749. each$1(labels, function (labelItem) {
  83750. // The tickValue is dataIndex, see the costomized scale.
  83751. var dataIndex = labelItem.tickValue;
  83752. var itemModel = data.getItemModel(dataIndex);
  83753. var normalLabelModel = itemModel.getModel('label');
  83754. var hoverLabelModel = itemModel.getModel(['emphasis', 'label']);
  83755. var progressLabelModel = itemModel.getModel(['progress', 'label']);
  83756. var tickCoord = axis.dataToCoord(labelItem.tickValue);
  83757. var textEl = new ZRText({
  83758. x: tickCoord,
  83759. y: 0,
  83760. rotation: layoutInfo.labelRotation - layoutInfo.rotation,
  83761. onclick: bind(_this._changeTimeline, _this, dataIndex),
  83762. silent: false,
  83763. style: createTextStyle(normalLabelModel, {
  83764. text: labelItem.formattedLabel,
  83765. align: layoutInfo.labelAlign,
  83766. verticalAlign: layoutInfo.labelBaseline
  83767. })
  83768. });
  83769. textEl.ensureState('emphasis').style = createTextStyle(hoverLabelModel);
  83770. textEl.ensureState('progress').style = createTextStyle(progressLabelModel);
  83771. group.add(textEl);
  83772. enableHoverEmphasis(textEl);
  83773. labelDataIndexStore(textEl).dataIndex = dataIndex;
  83774. _this._tickLabels.push(textEl);
  83775. });
  83776. };
  83777. SliderTimelineView.prototype._renderControl = function (layoutInfo, group, axis, timelineModel) {
  83778. var controlSize = layoutInfo.controlSize;
  83779. var rotation = layoutInfo.rotation;
  83780. var itemStyle = timelineModel.getModel('controlStyle').getItemStyle();
  83781. var hoverStyle = timelineModel.getModel(['emphasis', 'controlStyle']).getItemStyle();
  83782. var playState = timelineModel.getPlayState();
  83783. var inverse = timelineModel.get('inverse', true);
  83784. makeBtn(layoutInfo.nextBtnPosition, 'next', bind(this._changeTimeline, this, inverse ? '-' : '+'));
  83785. makeBtn(layoutInfo.prevBtnPosition, 'prev', bind(this._changeTimeline, this, inverse ? '+' : '-'));
  83786. makeBtn(layoutInfo.playPosition, playState ? 'stop' : 'play', bind(this._handlePlayClick, this, !playState), true);
  83787. function makeBtn(position, iconName, onclick, willRotate) {
  83788. if (!position) {
  83789. return;
  83790. }
  83791. var iconSize = parsePercent(retrieve2(timelineModel.get(['controlStyle', iconName + 'BtnSize']), controlSize), controlSize);
  83792. var rect = [0, -iconSize / 2, iconSize, iconSize];
  83793. var btn = makeControlIcon(timelineModel, iconName + 'Icon', rect, {
  83794. x: position[0],
  83795. y: position[1],
  83796. originX: controlSize / 2,
  83797. originY: 0,
  83798. rotation: willRotate ? -rotation : 0,
  83799. rectHover: true,
  83800. style: itemStyle,
  83801. onclick: onclick
  83802. });
  83803. btn.ensureState('emphasis').style = hoverStyle;
  83804. group.add(btn);
  83805. enableHoverEmphasis(btn);
  83806. }
  83807. };
  83808. SliderTimelineView.prototype._renderCurrentPointer = function (layoutInfo, group, axis, timelineModel) {
  83809. var data = timelineModel.getData();
  83810. var currentIndex = timelineModel.getCurrentIndex();
  83811. var pointerModel = data.getItemModel(currentIndex).getModel('checkpointStyle');
  83812. var me = this;
  83813. var callback = {
  83814. onCreate: function (pointer) {
  83815. pointer.draggable = true;
  83816. pointer.drift = bind(me._handlePointerDrag, me);
  83817. pointer.ondragend = bind(me._handlePointerDragend, me);
  83818. pointerMoveTo(pointer, me._progressLine, currentIndex, axis, timelineModel, true);
  83819. },
  83820. onUpdate: function (pointer) {
  83821. pointerMoveTo(pointer, me._progressLine, currentIndex, axis, timelineModel);
  83822. }
  83823. }; // Reuse when exists, for animation and drag.
  83824. this._currentPointer = giveSymbol(pointerModel, pointerModel, this._mainGroup, {}, this._currentPointer, callback);
  83825. };
  83826. SliderTimelineView.prototype._handlePlayClick = function (nextState) {
  83827. this._clearTimer();
  83828. this.api.dispatchAction({
  83829. type: 'timelinePlayChange',
  83830. playState: nextState,
  83831. from: this.uid
  83832. });
  83833. };
  83834. SliderTimelineView.prototype._handlePointerDrag = function (dx, dy, e) {
  83835. this._clearTimer();
  83836. this._pointerChangeTimeline([e.offsetX, e.offsetY]);
  83837. };
  83838. SliderTimelineView.prototype._handlePointerDragend = function (e) {
  83839. this._pointerChangeTimeline([e.offsetX, e.offsetY], true);
  83840. };
  83841. SliderTimelineView.prototype._pointerChangeTimeline = function (mousePos, trigger) {
  83842. var toCoord = this._toAxisCoord(mousePos)[0];
  83843. var axis = this._axis;
  83844. var axisExtent = asc(axis.getExtent().slice());
  83845. toCoord > axisExtent[1] && (toCoord = axisExtent[1]);
  83846. toCoord < axisExtent[0] && (toCoord = axisExtent[0]);
  83847. this._currentPointer.x = toCoord;
  83848. this._currentPointer.markRedraw();
  83849. this._progressLine.shape.x2 = toCoord;
  83850. this._progressLine.dirty();
  83851. var targetDataIndex = this._findNearestTick(toCoord);
  83852. var timelineModel = this.model;
  83853. if (trigger || targetDataIndex !== timelineModel.getCurrentIndex() && timelineModel.get('realtime')) {
  83854. this._changeTimeline(targetDataIndex);
  83855. }
  83856. };
  83857. SliderTimelineView.prototype._doPlayStop = function () {
  83858. var _this = this;
  83859. this._clearTimer();
  83860. if (this.model.getPlayState()) {
  83861. this._timer = setTimeout(function () {
  83862. // Do not cache
  83863. var timelineModel = _this.model;
  83864. _this._changeTimeline(timelineModel.getCurrentIndex() + (timelineModel.get('rewind', true) ? -1 : 1));
  83865. }, this.model.get('playInterval'));
  83866. }
  83867. };
  83868. SliderTimelineView.prototype._toAxisCoord = function (vertex) {
  83869. var trans = this._mainGroup.getLocalTransform();
  83870. return applyTransform$1(vertex, trans, true);
  83871. };
  83872. SliderTimelineView.prototype._findNearestTick = function (axisCoord) {
  83873. var data = this.model.getData();
  83874. var dist = Infinity;
  83875. var targetDataIndex;
  83876. var axis = this._axis;
  83877. data.each(['value'], function (value, dataIndex) {
  83878. var coord = axis.dataToCoord(value);
  83879. var d = Math.abs(coord - axisCoord);
  83880. if (d < dist) {
  83881. dist = d;
  83882. targetDataIndex = dataIndex;
  83883. }
  83884. });
  83885. return targetDataIndex;
  83886. };
  83887. SliderTimelineView.prototype._clearTimer = function () {
  83888. if (this._timer) {
  83889. clearTimeout(this._timer);
  83890. this._timer = null;
  83891. }
  83892. };
  83893. SliderTimelineView.prototype._changeTimeline = function (nextIndex) {
  83894. var currentIndex = this.model.getCurrentIndex();
  83895. if (nextIndex === '+') {
  83896. nextIndex = currentIndex + 1;
  83897. } else if (nextIndex === '-') {
  83898. nextIndex = currentIndex - 1;
  83899. }
  83900. this.api.dispatchAction({
  83901. type: 'timelineChange',
  83902. currentIndex: nextIndex,
  83903. from: this.uid
  83904. });
  83905. };
  83906. SliderTimelineView.prototype._updateTicksStatus = function () {
  83907. var currentIndex = this.model.getCurrentIndex();
  83908. var tickSymbols = this._tickSymbols;
  83909. var tickLabels = this._tickLabels;
  83910. if (tickSymbols) {
  83911. for (var i = 0; i < tickSymbols.length; i++) {
  83912. tickSymbols && tickSymbols[i] && tickSymbols[i].toggleState('progress', i < currentIndex);
  83913. }
  83914. }
  83915. if (tickLabels) {
  83916. for (var i = 0; i < tickLabels.length; i++) {
  83917. tickLabels && tickLabels[i] && tickLabels[i].toggleState('progress', labelDataIndexStore(tickLabels[i]).dataIndex <= currentIndex);
  83918. }
  83919. }
  83920. };
  83921. SliderTimelineView.type = 'timeline.slider';
  83922. return SliderTimelineView;
  83923. }(TimelineView);
  83924. function createScaleByModel$1(model, axisType) {
  83925. axisType = axisType || model.get('type');
  83926. if (axisType) {
  83927. switch (axisType) {
  83928. // Buildin scale
  83929. case 'category':
  83930. return new OrdinalScale({
  83931. ordinalMeta: model.getCategories(),
  83932. extent: [Infinity, -Infinity]
  83933. });
  83934. case 'time':
  83935. return new TimeScale({
  83936. locale: model.ecModel.getLocaleModel(),
  83937. useUTC: model.ecModel.get('useUTC')
  83938. });
  83939. default:
  83940. // default to be value
  83941. return new IntervalScale();
  83942. }
  83943. }
  83944. }
  83945. function getViewRect$5(model, api) {
  83946. return getLayoutRect(model.getBoxLayoutParams(), {
  83947. width: api.getWidth(),
  83948. height: api.getHeight()
  83949. }, model.get('padding'));
  83950. }
  83951. function makeControlIcon(timelineModel, objPath, rect, opts) {
  83952. var style = opts.style;
  83953. var icon = createIcon(timelineModel.get(['controlStyle', objPath]), opts || {}, new BoundingRect(rect[0], rect[1], rect[2], rect[3])); // TODO createIcon won't use style in opt.
  83954. if (style) {
  83955. icon.setStyle(style);
  83956. }
  83957. return icon;
  83958. }
  83959. /**
  83960. * Create symbol or update symbol
  83961. * opt: basic position and event handlers
  83962. */
  83963. function giveSymbol(hostModel, itemStyleModel, group, opt, symbol, callback) {
  83964. var color = itemStyleModel.get('color');
  83965. if (!symbol) {
  83966. var symbolType = hostModel.get('symbol');
  83967. symbol = createSymbol(symbolType, -1, -1, 2, 2, color);
  83968. symbol.setStyle('strokeNoScale', true);
  83969. group.add(symbol);
  83970. callback && callback.onCreate(symbol);
  83971. } else {
  83972. symbol.setColor(color);
  83973. group.add(symbol); // Group may be new, also need to add.
  83974. callback && callback.onUpdate(symbol);
  83975. } // Style
  83976. var itemStyle = itemStyleModel.getItemStyle(['color']);
  83977. symbol.setStyle(itemStyle); // Transform and events.
  83978. opt = merge({
  83979. rectHover: true,
  83980. z2: 100
  83981. }, opt, true);
  83982. var symbolSize = hostModel.get('symbolSize');
  83983. symbolSize = symbolSize instanceof Array ? symbolSize.slice() : [+symbolSize, +symbolSize];
  83984. opt.scaleX = symbolSize[0] / 2;
  83985. opt.scaleY = symbolSize[1] / 2;
  83986. var symbolOffset = hostModel.get('symbolOffset');
  83987. if (symbolOffset) {
  83988. opt.x = opt.x || 0;
  83989. opt.y = opt.y || 0;
  83990. opt.x += parsePercent$1(symbolOffset[0], symbolSize[0]);
  83991. opt.y += parsePercent$1(symbolOffset[1], symbolSize[1]);
  83992. }
  83993. var symbolRotate = hostModel.get('symbolRotate');
  83994. opt.rotation = (symbolRotate || 0) * Math.PI / 180 || 0;
  83995. symbol.attr(opt); // FIXME
  83996. // (1) When symbol.style.strokeNoScale is true and updateTransform is not performed,
  83997. // getBoundingRect will return wrong result.
  83998. // (This is supposed to be resolved in zrender, but it is a little difficult to
  83999. // leverage performance and auto updateTransform)
  84000. // (2) All of ancesters of symbol do not scale, so we can just updateTransform symbol.
  84001. symbol.updateTransform();
  84002. return symbol;
  84003. }
  84004. function pointerMoveTo(pointer, progressLine, dataIndex, axis, timelineModel, noAnimation) {
  84005. if (pointer.dragging) {
  84006. return;
  84007. }
  84008. var pointerModel = timelineModel.getModel('checkpointStyle');
  84009. var toCoord = axis.dataToCoord(timelineModel.getData().get('value', dataIndex));
  84010. if (noAnimation || !pointerModel.get('animation', true)) {
  84011. pointer.attr({
  84012. x: toCoord,
  84013. y: 0
  84014. });
  84015. progressLine && progressLine.attr({
  84016. shape: {
  84017. x2: toCoord
  84018. }
  84019. });
  84020. } else {
  84021. var animationCfg = {
  84022. duration: pointerModel.get('animationDuration', true),
  84023. easing: pointerModel.get('animationEasing', true)
  84024. };
  84025. pointer.stopAnimation(null, true);
  84026. pointer.animateTo({
  84027. x: toCoord,
  84028. y: 0
  84029. }, animationCfg);
  84030. progressLine && progressLine.animateTo({
  84031. shape: {
  84032. x2: toCoord
  84033. }
  84034. }, animationCfg);
  84035. }
  84036. }
  84037. /*
  84038. * Licensed to the Apache Software Foundation (ASF) under one
  84039. * or more contributor license agreements. See the NOTICE file
  84040. * distributed with this work for additional information
  84041. * regarding copyright ownership. The ASF licenses this file
  84042. * to you under the Apache License, Version 2.0 (the
  84043. * "License"); you may not use this file except in compliance
  84044. * with the License. You may obtain a copy of the License at
  84045. *
  84046. * http://www.apache.org/licenses/LICENSE-2.0
  84047. *
  84048. * Unless required by applicable law or agreed to in writing,
  84049. * software distributed under the License is distributed on an
  84050. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84051. * KIND, either express or implied. See the License for the
  84052. * specific language governing permissions and limitations
  84053. * under the License.
  84054. */
  84055. /**
  84056. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84057. */
  84058. /*
  84059. * Licensed to the Apache Software Foundation (ASF) under one
  84060. * or more contributor license agreements. See the NOTICE file
  84061. * distributed with this work for additional information
  84062. * regarding copyright ownership. The ASF licenses this file
  84063. * to you under the Apache License, Version 2.0 (the
  84064. * "License"); you may not use this file except in compliance
  84065. * with the License. You may obtain a copy of the License at
  84066. *
  84067. * http://www.apache.org/licenses/LICENSE-2.0
  84068. *
  84069. * Unless required by applicable law or agreed to in writing,
  84070. * software distributed under the License is distributed on an
  84071. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84072. * KIND, either express or implied. See the License for the
  84073. * specific language governing permissions and limitations
  84074. * under the License.
  84075. */
  84076. function installTimelineAction(registers) {
  84077. registers.registerAction({
  84078. type: 'timelineChange',
  84079. event: 'timelineChanged',
  84080. update: 'prepareAndUpdate'
  84081. }, function (payload, ecModel) {
  84082. var timelineModel = ecModel.getComponent('timeline');
  84083. if (timelineModel && payload.currentIndex != null) {
  84084. timelineModel.setCurrentIndex(payload.currentIndex);
  84085. if (!timelineModel.get('loop', true) && timelineModel.isIndexMax()) {
  84086. timelineModel.setPlayState(false);
  84087. }
  84088. } // Set normalized currentIndex to payload.
  84089. ecModel.resetOption('timeline', {
  84090. replaceMerge: timelineModel.get('replaceMerge', true)
  84091. });
  84092. return defaults({
  84093. currentIndex: timelineModel.option.currentIndex
  84094. }, payload);
  84095. });
  84096. registers.registerAction({
  84097. type: 'timelinePlayChange',
  84098. event: 'timelinePlayChanged',
  84099. update: 'update'
  84100. }, function (payload, ecModel) {
  84101. var timelineModel = ecModel.getComponent('timeline');
  84102. if (timelineModel && payload.playState != null) {
  84103. timelineModel.setPlayState(payload.playState);
  84104. }
  84105. });
  84106. }
  84107. /*
  84108. * Licensed to the Apache Software Foundation (ASF) under one
  84109. * or more contributor license agreements. See the NOTICE file
  84110. * distributed with this work for additional information
  84111. * regarding copyright ownership. The ASF licenses this file
  84112. * to you under the Apache License, Version 2.0 (the
  84113. * "License"); you may not use this file except in compliance
  84114. * with the License. You may obtain a copy of the License at
  84115. *
  84116. * http://www.apache.org/licenses/LICENSE-2.0
  84117. *
  84118. * Unless required by applicable law or agreed to in writing,
  84119. * software distributed under the License is distributed on an
  84120. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84121. * KIND, either express or implied. See the License for the
  84122. * specific language governing permissions and limitations
  84123. * under the License.
  84124. */
  84125. /**
  84126. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84127. */
  84128. /*
  84129. * Licensed to the Apache Software Foundation (ASF) under one
  84130. * or more contributor license agreements. See the NOTICE file
  84131. * distributed with this work for additional information
  84132. * regarding copyright ownership. The ASF licenses this file
  84133. * to you under the Apache License, Version 2.0 (the
  84134. * "License"); you may not use this file except in compliance
  84135. * with the License. You may obtain a copy of the License at
  84136. *
  84137. * http://www.apache.org/licenses/LICENSE-2.0
  84138. *
  84139. * Unless required by applicable law or agreed to in writing,
  84140. * software distributed under the License is distributed on an
  84141. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84142. * KIND, either express or implied. See the License for the
  84143. * specific language governing permissions and limitations
  84144. * under the License.
  84145. */
  84146. // @ts-nocheck
  84147. function timelinePreprocessor(option) {
  84148. var timelineOpt = option && option.timeline;
  84149. if (!isArray(timelineOpt)) {
  84150. timelineOpt = timelineOpt ? [timelineOpt] : [];
  84151. }
  84152. each$1(timelineOpt, function (opt) {
  84153. if (!opt) {
  84154. return;
  84155. }
  84156. compatibleEC2(opt);
  84157. });
  84158. }
  84159. function compatibleEC2(opt) {
  84160. var type = opt.type;
  84161. var ec2Types = {
  84162. 'number': 'value',
  84163. 'time': 'time'
  84164. }; // Compatible with ec2
  84165. if (ec2Types[type]) {
  84166. opt.axisType = ec2Types[type];
  84167. delete opt.type;
  84168. }
  84169. transferItem(opt);
  84170. if (has(opt, 'controlPosition')) {
  84171. var controlStyle = opt.controlStyle || (opt.controlStyle = {});
  84172. if (!has(controlStyle, 'position')) {
  84173. controlStyle.position = opt.controlPosition;
  84174. }
  84175. if (controlStyle.position === 'none' && !has(controlStyle, 'show')) {
  84176. controlStyle.show = false;
  84177. delete controlStyle.position;
  84178. }
  84179. delete opt.controlPosition;
  84180. }
  84181. each$1(opt.data || [], function (dataItem) {
  84182. if (isObject$1(dataItem) && !isArray(dataItem)) {
  84183. if (!has(dataItem, 'value') && has(dataItem, 'name')) {
  84184. // In ec2, using name as value.
  84185. dataItem.value = dataItem.name;
  84186. }
  84187. transferItem(dataItem);
  84188. }
  84189. });
  84190. }
  84191. function transferItem(opt) {
  84192. var itemStyle = opt.itemStyle || (opt.itemStyle = {});
  84193. var itemStyleEmphasis = itemStyle.emphasis || (itemStyle.emphasis = {}); // Transfer label out
  84194. var label = opt.label || opt.label || {};
  84195. var labelNormal = label.normal || (label.normal = {});
  84196. var excludeLabelAttr = {
  84197. normal: 1,
  84198. emphasis: 1
  84199. };
  84200. each$1(label, function (value, name) {
  84201. if (!excludeLabelAttr[name] && !has(labelNormal, name)) {
  84202. labelNormal[name] = value;
  84203. }
  84204. });
  84205. if (itemStyleEmphasis.label && !has(label, 'emphasis')) {
  84206. label.emphasis = itemStyleEmphasis.label;
  84207. delete itemStyleEmphasis.label;
  84208. }
  84209. }
  84210. function has(obj, attr) {
  84211. return obj.hasOwnProperty(attr);
  84212. }
  84213. /*
  84214. * Licensed to the Apache Software Foundation (ASF) under one
  84215. * or more contributor license agreements. See the NOTICE file
  84216. * distributed with this work for additional information
  84217. * regarding copyright ownership. The ASF licenses this file
  84218. * to you under the Apache License, Version 2.0 (the
  84219. * "License"); you may not use this file except in compliance
  84220. * with the License. You may obtain a copy of the License at
  84221. *
  84222. * http://www.apache.org/licenses/LICENSE-2.0
  84223. *
  84224. * Unless required by applicable law or agreed to in writing,
  84225. * software distributed under the License is distributed on an
  84226. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84227. * KIND, either express or implied. See the License for the
  84228. * specific language governing permissions and limitations
  84229. * under the License.
  84230. */
  84231. /**
  84232. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84233. */
  84234. function install$39(registers) {
  84235. registers.registerComponentModel(SliderTimelineModel);
  84236. registers.registerComponentView(SliderTimelineView);
  84237. registers.registerSubTypeDefaulter('timeline', function () {
  84238. // Only slider now.
  84239. return 'slider';
  84240. });
  84241. installTimelineAction(registers);
  84242. registers.registerPreprocessor(timelinePreprocessor);
  84243. }
  84244. /*
  84245. * Licensed to the Apache Software Foundation (ASF) under one
  84246. * or more contributor license agreements. See the NOTICE file
  84247. * distributed with this work for additional information
  84248. * regarding copyright ownership. The ASF licenses this file
  84249. * to you under the Apache License, Version 2.0 (the
  84250. * "License"); you may not use this file except in compliance
  84251. * with the License. You may obtain a copy of the License at
  84252. *
  84253. * http://www.apache.org/licenses/LICENSE-2.0
  84254. *
  84255. * Unless required by applicable law or agreed to in writing,
  84256. * software distributed under the License is distributed on an
  84257. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84258. * KIND, either express or implied. See the License for the
  84259. * specific language governing permissions and limitations
  84260. * under the License.
  84261. */
  84262. /**
  84263. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84264. */
  84265. /*
  84266. * Licensed to the Apache Software Foundation (ASF) under one
  84267. * or more contributor license agreements. See the NOTICE file
  84268. * distributed with this work for additional information
  84269. * regarding copyright ownership. The ASF licenses this file
  84270. * to you under the Apache License, Version 2.0 (the
  84271. * "License"); you may not use this file except in compliance
  84272. * with the License. You may obtain a copy of the License at
  84273. *
  84274. * http://www.apache.org/licenses/LICENSE-2.0
  84275. *
  84276. * Unless required by applicable law or agreed to in writing,
  84277. * software distributed under the License is distributed on an
  84278. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84279. * KIND, either express or implied. See the License for the
  84280. * specific language governing permissions and limitations
  84281. * under the License.
  84282. */
  84283. /**
  84284. * DataZoom component entry
  84285. */
  84286. use(install$39);
  84287. /*
  84288. * Licensed to the Apache Software Foundation (ASF) under one
  84289. * or more contributor license agreements. See the NOTICE file
  84290. * distributed with this work for additional information
  84291. * regarding copyright ownership. The ASF licenses this file
  84292. * to you under the Apache License, Version 2.0 (the
  84293. * "License"); you may not use this file except in compliance
  84294. * with the License. You may obtain a copy of the License at
  84295. *
  84296. * http://www.apache.org/licenses/LICENSE-2.0
  84297. *
  84298. * Unless required by applicable law or agreed to in writing,
  84299. * software distributed under the License is distributed on an
  84300. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84301. * KIND, either express or implied. See the License for the
  84302. * specific language governing permissions and limitations
  84303. * under the License.
  84304. */
  84305. /**
  84306. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84307. */
  84308. /*
  84309. * Licensed to the Apache Software Foundation (ASF) under one
  84310. * or more contributor license agreements. See the NOTICE file
  84311. * distributed with this work for additional information
  84312. * regarding copyright ownership. The ASF licenses this file
  84313. * to you under the Apache License, Version 2.0 (the
  84314. * "License"); you may not use this file except in compliance
  84315. * with the License. You may obtain a copy of the License at
  84316. *
  84317. * http://www.apache.org/licenses/LICENSE-2.0
  84318. *
  84319. * Unless required by applicable law or agreed to in writing,
  84320. * software distributed under the License is distributed on an
  84321. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84322. * KIND, either express or implied. See the License for the
  84323. * specific language governing permissions and limitations
  84324. * under the License.
  84325. */
  84326. var DATA_ZOOM_AXIS_DIMENSIONS = ['x', 'y', 'radius', 'angle', 'single']; // Supported coords.
  84327. // FIXME: polar has been broken (but rarely used).
  84328. var SERIES_COORDS = ['cartesian2d', 'polar', 'singleAxis'];
  84329. function isCoordSupported(seriesModel) {
  84330. var coordType = seriesModel.get('coordinateSystem');
  84331. return indexOf$1(SERIES_COORDS, coordType) >= 0;
  84332. }
  84333. function getAxisMainType(axisDim) {
  84334. {
  84335. assert$1(axisDim);
  84336. }
  84337. return axisDim + 'Axis';
  84338. }
  84339. /**
  84340. * If two dataZoomModels has the same axis controlled, we say that they are 'linked'.
  84341. * This function finds all linked dataZoomModels start from the given payload.
  84342. */
  84343. function findEffectedDataZooms(ecModel, payload) {
  84344. // Key: `DataZoomAxisDimension`
  84345. var axisRecords = createHashMap();
  84346. var effectedModels = []; // Key: uid of dataZoomModel
  84347. var effectedModelMap = createHashMap(); // Find the dataZooms specified by payload.
  84348. ecModel.eachComponent({
  84349. mainType: 'dataZoom',
  84350. query: payload
  84351. }, function (dataZoomModel) {
  84352. if (!effectedModelMap.get(dataZoomModel.uid)) {
  84353. addToEffected(dataZoomModel);
  84354. }
  84355. }); // Start from the given dataZoomModels, travel the graph to find
  84356. // all of the linked dataZoom models.
  84357. var foundNewLink;
  84358. do {
  84359. foundNewLink = false;
  84360. ecModel.eachComponent('dataZoom', processSingle);
  84361. } while (foundNewLink);
  84362. function processSingle(dataZoomModel) {
  84363. if (!effectedModelMap.get(dataZoomModel.uid) && isLinked(dataZoomModel)) {
  84364. addToEffected(dataZoomModel);
  84365. foundNewLink = true;
  84366. }
  84367. }
  84368. function addToEffected(dataZoom) {
  84369. effectedModelMap.set(dataZoom.uid, true);
  84370. effectedModels.push(dataZoom);
  84371. markAxisControlled(dataZoom);
  84372. }
  84373. function isLinked(dataZoomModel) {
  84374. var isLink = false;
  84375. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  84376. var axisIdxArr = axisRecords.get(axisDim);
  84377. if (axisIdxArr && axisIdxArr[axisIndex]) {
  84378. isLink = true;
  84379. }
  84380. });
  84381. return isLink;
  84382. }
  84383. function markAxisControlled(dataZoomModel) {
  84384. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  84385. (axisRecords.get(axisDim) || axisRecords.set(axisDim, []))[axisIndex] = true;
  84386. });
  84387. }
  84388. return effectedModels;
  84389. }
  84390. /**
  84391. * Find the first target coordinate system.
  84392. * Available after model built.
  84393. *
  84394. * @return Like {
  84395. * grid: [
  84396. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  84397. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  84398. * ...
  84399. * ], // cartesians must not be null/undefined.
  84400. * polar: [
  84401. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  84402. * ...
  84403. * ], // polars must not be null/undefined.
  84404. * singleAxis: [
  84405. * {model: coord0, axisModels: [], coordIndex: 0}
  84406. * ]
  84407. * }
  84408. */
  84409. function collectReferCoordSysModelInfo(dataZoomModel) {
  84410. var ecModel = dataZoomModel.ecModel;
  84411. var coordSysInfoWrap = {
  84412. infoList: [],
  84413. infoMap: createHashMap()
  84414. };
  84415. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  84416. var axisModel = ecModel.getComponent(getAxisMainType(axisDim), axisIndex);
  84417. if (!axisModel) {
  84418. return;
  84419. }
  84420. var coordSysModel = axisModel.getCoordSysModel();
  84421. if (!coordSysModel) {
  84422. return;
  84423. }
  84424. var coordSysUid = coordSysModel.uid;
  84425. var coordSysInfo = coordSysInfoWrap.infoMap.get(coordSysUid);
  84426. if (!coordSysInfo) {
  84427. coordSysInfo = {
  84428. model: coordSysModel,
  84429. axisModels: []
  84430. };
  84431. coordSysInfoWrap.infoList.push(coordSysInfo);
  84432. coordSysInfoWrap.infoMap.set(coordSysUid, coordSysInfo);
  84433. }
  84434. coordSysInfo.axisModels.push(axisModel);
  84435. });
  84436. return coordSysInfoWrap;
  84437. }
  84438. /*
  84439. * Licensed to the Apache Software Foundation (ASF) under one
  84440. * or more contributor license agreements. See the NOTICE file
  84441. * distributed with this work for additional information
  84442. * regarding copyright ownership. The ASF licenses this file
  84443. * to you under the Apache License, Version 2.0 (the
  84444. * "License"); you may not use this file except in compliance
  84445. * with the License. You may obtain a copy of the License at
  84446. *
  84447. * http://www.apache.org/licenses/LICENSE-2.0
  84448. *
  84449. * Unless required by applicable law or agreed to in writing,
  84450. * software distributed under the License is distributed on an
  84451. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84452. * KIND, either express or implied. See the License for the
  84453. * specific language governing permissions and limitations
  84454. * under the License.
  84455. */
  84456. /**
  84457. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84458. */
  84459. /*
  84460. * Licensed to the Apache Software Foundation (ASF) under one
  84461. * or more contributor license agreements. See the NOTICE file
  84462. * distributed with this work for additional information
  84463. * regarding copyright ownership. The ASF licenses this file
  84464. * to you under the Apache License, Version 2.0 (the
  84465. * "License"); you may not use this file except in compliance
  84466. * with the License. You may obtain a copy of the License at
  84467. *
  84468. * http://www.apache.org/licenses/LICENSE-2.0
  84469. *
  84470. * Unless required by applicable law or agreed to in writing,
  84471. * software distributed under the License is distributed on an
  84472. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84473. * KIND, either express or implied. See the License for the
  84474. * specific language governing permissions and limitations
  84475. * under the License.
  84476. */
  84477. var DataZoomAxisInfo =
  84478. /** @class */
  84479. function () {
  84480. function DataZoomAxisInfo() {
  84481. this.indexList = [];
  84482. this.indexMap = [];
  84483. }
  84484. DataZoomAxisInfo.prototype.add = function (axisCmptIdx) {
  84485. // Remove duplication.
  84486. if (!this.indexMap[axisCmptIdx]) {
  84487. this.indexList.push(axisCmptIdx);
  84488. this.indexMap[axisCmptIdx] = true;
  84489. }
  84490. };
  84491. return DataZoomAxisInfo;
  84492. }();
  84493. var DataZoomModel =
  84494. /** @class */
  84495. function (_super) {
  84496. __extends(DataZoomModel, _super);
  84497. function DataZoomModel() {
  84498. var _this = _super !== null && _super.apply(this, arguments) || this;
  84499. _this.type = DataZoomModel.type;
  84500. _this._autoThrottle = true;
  84501. _this._noTarget = true;
  84502. /**
  84503. * It is `[rangeModeForMin, rangeModeForMax]`.
  84504. * The optional values for `rangeMode`:
  84505. * + `'value'` mode: the axis extent will always be determined by
  84506. * `dataZoom.startValue` and `dataZoom.endValue`, despite
  84507. * how data like and how `axis.min` and `axis.max` are.
  84508. * + `'percent'` mode: `100` represents 100% of the `[dMin, dMax]`,
  84509. * where `dMin` is `axis.min` if `axis.min` specified, otherwise `data.extent[0]`,
  84510. * and `dMax` is `axis.max` if `axis.max` specified, otherwise `data.extent[1]`.
  84511. * Axis extent will be determined by the result of the percent of `[dMin, dMax]`.
  84512. *
  84513. * For example, when users are using dynamic data (update data periodically via `setOption`),
  84514. * if in `'value`' mode, the window will be kept in a fixed value range despite how
  84515. * data are appended, while if in `'percent'` mode, whe window range will be changed alone with
  84516. * the appended data (suppose `axis.min` and `axis.max` are not specified).
  84517. */
  84518. _this._rangePropMode = ['percent', 'percent'];
  84519. return _this;
  84520. }
  84521. DataZoomModel.prototype.init = function (option, parentModel, ecModel) {
  84522. var inputRawOption = retrieveRawOption(option);
  84523. /**
  84524. * Suppose a "main process" start at the point that model prepared (that is,
  84525. * model initialized or merged or method called in `action`).
  84526. * We should keep the `main process` idempotent, that is, given a set of values
  84527. * on `option`, we get the same result.
  84528. *
  84529. * But sometimes, values on `option` will be updated for providing users
  84530. * a "final calculated value" (`dataZoomProcessor` will do that). Those value
  84531. * should not be the base/input of the `main process`.
  84532. *
  84533. * So in that case we should save and keep the input of the `main process`
  84534. * separately, called `settledOption`.
  84535. *
  84536. * For example, consider the case:
  84537. * (Step_1) brush zoom the grid by `toolbox.dataZoom`,
  84538. * where the original input `option.startValue`, `option.endValue` are earsed by
  84539. * calculated value.
  84540. * (Step)2) click the legend to hide and show a series,
  84541. * where the new range is calculated by the earsed `startValue` and `endValue`,
  84542. * which brings incorrect result.
  84543. */
  84544. this.settledOption = inputRawOption;
  84545. this.mergeDefaultAndTheme(option, ecModel);
  84546. this._doInit(inputRawOption);
  84547. };
  84548. DataZoomModel.prototype.mergeOption = function (newOption) {
  84549. var inputRawOption = retrieveRawOption(newOption); //FIX #2591
  84550. merge(this.option, newOption, true);
  84551. merge(this.settledOption, inputRawOption, true);
  84552. this._doInit(inputRawOption);
  84553. };
  84554. DataZoomModel.prototype._doInit = function (inputRawOption) {
  84555. var thisOption = this.option; // if (!env.canvasSupported) {
  84556. // thisOption.realtime = false;
  84557. // }
  84558. this._setDefaultThrottle(inputRawOption);
  84559. this._updateRangeUse(inputRawOption);
  84560. var settledOption = this.settledOption;
  84561. each$1([['start', 'startValue'], ['end', 'endValue']], function (names, index) {
  84562. // start/end has higher priority over startValue/endValue if they
  84563. // both set, but we should make chart.setOption({endValue: 1000})
  84564. // effective, rather than chart.setOption({endValue: 1000, end: null}).
  84565. if (this._rangePropMode[index] === 'value') {
  84566. thisOption[names[0]] = settledOption[names[0]] = null;
  84567. } // Otherwise do nothing and use the merge result.
  84568. }, this);
  84569. this._resetTarget();
  84570. };
  84571. DataZoomModel.prototype._resetTarget = function () {
  84572. var optionOrient = this.get('orient', true);
  84573. var targetAxisIndexMap = this._targetAxisInfoMap = createHashMap();
  84574. var hasAxisSpecified = this._fillSpecifiedTargetAxis(targetAxisIndexMap);
  84575. if (hasAxisSpecified) {
  84576. this._orient = optionOrient || this._makeAutoOrientByTargetAxis();
  84577. } else {
  84578. this._orient = optionOrient || 'horizontal';
  84579. this._fillAutoTargetAxisByOrient(targetAxisIndexMap, this._orient);
  84580. }
  84581. this._noTarget = true;
  84582. targetAxisIndexMap.each(function (axisInfo) {
  84583. if (axisInfo.indexList.length) {
  84584. this._noTarget = false;
  84585. }
  84586. }, this);
  84587. };
  84588. DataZoomModel.prototype._fillSpecifiedTargetAxis = function (targetAxisIndexMap) {
  84589. var hasAxisSpecified = false;
  84590. each$1(DATA_ZOOM_AXIS_DIMENSIONS, function (axisDim) {
  84591. var refering = this.getReferringComponents(getAxisMainType(axisDim), MULTIPLE_REFERRING); // When user set axisIndex as a empty array, we think that user specify axisIndex
  84592. // but do not want use auto mode. Because empty array may be encountered when
  84593. // some error occured.
  84594. if (!refering.specified) {
  84595. return;
  84596. }
  84597. hasAxisSpecified = true;
  84598. var axisInfo = new DataZoomAxisInfo();
  84599. each$1(refering.models, function (axisModel) {
  84600. axisInfo.add(axisModel.componentIndex);
  84601. });
  84602. targetAxisIndexMap.set(axisDim, axisInfo);
  84603. }, this);
  84604. return hasAxisSpecified;
  84605. };
  84606. DataZoomModel.prototype._fillAutoTargetAxisByOrient = function (targetAxisIndexMap, orient) {
  84607. var ecModel = this.ecModel;
  84608. var needAuto = true; // Find axis that parallel to dataZoom as default.
  84609. if (needAuto) {
  84610. var axisDim = orient === 'vertical' ? 'y' : 'x';
  84611. var axisModels = ecModel.findComponents({
  84612. mainType: axisDim + 'Axis'
  84613. });
  84614. setParallelAxis(axisModels, axisDim);
  84615. } // Find axis that parallel to dataZoom as default.
  84616. if (needAuto) {
  84617. var axisModels = ecModel.findComponents({
  84618. mainType: 'singleAxis',
  84619. filter: function (axisModel) {
  84620. return axisModel.get('orient', true) === orient;
  84621. }
  84622. });
  84623. setParallelAxis(axisModels, 'single');
  84624. }
  84625. function setParallelAxis(axisModels, axisDim) {
  84626. // At least use the first parallel axis as the target axis.
  84627. var axisModel = axisModels[0];
  84628. if (!axisModel) {
  84629. return;
  84630. }
  84631. var axisInfo = new DataZoomAxisInfo();
  84632. axisInfo.add(axisModel.componentIndex);
  84633. targetAxisIndexMap.set(axisDim, axisInfo);
  84634. needAuto = false; // Find parallel axes in the same grid.
  84635. if (axisDim === 'x' || axisDim === 'y') {
  84636. var gridModel_1 = axisModel.getReferringComponents('grid', SINGLE_REFERRING).models[0];
  84637. gridModel_1 && each$1(axisModels, function (axModel) {
  84638. if (axisModel.componentIndex !== axModel.componentIndex && gridModel_1 === axModel.getReferringComponents('grid', SINGLE_REFERRING).models[0]) {
  84639. axisInfo.add(axModel.componentIndex);
  84640. }
  84641. });
  84642. }
  84643. }
  84644. if (needAuto) {
  84645. // If no parallel axis, find the first category axis as default. (Also consider polar).
  84646. each$1(DATA_ZOOM_AXIS_DIMENSIONS, function (axisDim) {
  84647. if (!needAuto) {
  84648. return;
  84649. }
  84650. var axisModels = ecModel.findComponents({
  84651. mainType: getAxisMainType(axisDim),
  84652. filter: function (axisModel) {
  84653. return axisModel.get('type', true) === 'category';
  84654. }
  84655. });
  84656. if (axisModels[0]) {
  84657. var axisInfo = new DataZoomAxisInfo();
  84658. axisInfo.add(axisModels[0].componentIndex);
  84659. targetAxisIndexMap.set(axisDim, axisInfo);
  84660. needAuto = false;
  84661. }
  84662. }, this);
  84663. }
  84664. };
  84665. DataZoomModel.prototype._makeAutoOrientByTargetAxis = function () {
  84666. var dim; // Find the first axis
  84667. this.eachTargetAxis(function (axisDim) {
  84668. !dim && (dim = axisDim);
  84669. }, this);
  84670. return dim === 'y' ? 'vertical' : 'horizontal';
  84671. };
  84672. DataZoomModel.prototype._setDefaultThrottle = function (inputRawOption) {
  84673. // When first time user set throttle, auto throttle ends.
  84674. if (inputRawOption.hasOwnProperty('throttle')) {
  84675. this._autoThrottle = false;
  84676. }
  84677. if (this._autoThrottle) {
  84678. var globalOption = this.ecModel.option;
  84679. this.option.throttle = globalOption.animation && globalOption.animationDurationUpdate > 0 ? 100 : 20;
  84680. }
  84681. };
  84682. DataZoomModel.prototype._updateRangeUse = function (inputRawOption) {
  84683. var rangePropMode = this._rangePropMode;
  84684. var rangeModeInOption = this.get('rangeMode');
  84685. each$1([['start', 'startValue'], ['end', 'endValue']], function (names, index) {
  84686. var percentSpecified = inputRawOption[names[0]] != null;
  84687. var valueSpecified = inputRawOption[names[1]] != null;
  84688. if (percentSpecified && !valueSpecified) {
  84689. rangePropMode[index] = 'percent';
  84690. } else if (!percentSpecified && valueSpecified) {
  84691. rangePropMode[index] = 'value';
  84692. } else if (rangeModeInOption) {
  84693. rangePropMode[index] = rangeModeInOption[index];
  84694. } else if (percentSpecified) {
  84695. // percentSpecified && valueSpecified
  84696. rangePropMode[index] = 'percent';
  84697. } // else remain its original setting.
  84698. });
  84699. };
  84700. DataZoomModel.prototype.noTarget = function () {
  84701. return this._noTarget;
  84702. };
  84703. DataZoomModel.prototype.getFirstTargetAxisModel = function () {
  84704. var firstAxisModel;
  84705. this.eachTargetAxis(function (axisDim, axisIndex) {
  84706. if (firstAxisModel == null) {
  84707. firstAxisModel = this.ecModel.getComponent(getAxisMainType(axisDim), axisIndex);
  84708. }
  84709. }, this);
  84710. return firstAxisModel;
  84711. };
  84712. /**
  84713. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  84714. */
  84715. DataZoomModel.prototype.eachTargetAxis = function (callback, context) {
  84716. this._targetAxisInfoMap.each(function (axisInfo, axisDim) {
  84717. each$1(axisInfo.indexList, function (axisIndex) {
  84718. callback.call(context, axisDim, axisIndex);
  84719. });
  84720. });
  84721. };
  84722. /**
  84723. * @return If not found, return null/undefined.
  84724. */
  84725. DataZoomModel.prototype.getAxisProxy = function (axisDim, axisIndex) {
  84726. var axisModel = this.getAxisModel(axisDim, axisIndex);
  84727. if (axisModel) {
  84728. return axisModel.__dzAxisProxy;
  84729. }
  84730. };
  84731. /**
  84732. * @return If not found, return null/undefined.
  84733. */
  84734. DataZoomModel.prototype.getAxisModel = function (axisDim, axisIndex) {
  84735. {
  84736. assert$1(axisDim && axisIndex != null);
  84737. }
  84738. var axisInfo = this._targetAxisInfoMap.get(axisDim);
  84739. if (axisInfo && axisInfo.indexMap[axisIndex]) {
  84740. return this.ecModel.getComponent(getAxisMainType(axisDim), axisIndex);
  84741. }
  84742. };
  84743. /**
  84744. * If not specified, set to undefined.
  84745. */
  84746. DataZoomModel.prototype.setRawRange = function (opt) {
  84747. var thisOption = this.option;
  84748. var settledOption = this.settledOption;
  84749. each$1([['start', 'startValue'], ['end', 'endValue']], function (names) {
  84750. // Consider the pair <start, startValue>:
  84751. // If one has value and the other one is `null/undefined`, we both set them
  84752. // to `settledOption`. This strategy enables the feature to clear the original
  84753. // value in `settledOption` to `null/undefined`.
  84754. // But if both of them are `null/undefined`, we do not set them to `settledOption`
  84755. // and keep `settledOption` with the original value. This strategy enables users to
  84756. // only set <end or endValue> but not set <start or startValue> when calling
  84757. // `dispatchAction`.
  84758. // The pair <end, endValue> is treated in the same way.
  84759. if (opt[names[0]] != null || opt[names[1]] != null) {
  84760. thisOption[names[0]] = settledOption[names[0]] = opt[names[0]];
  84761. thisOption[names[1]] = settledOption[names[1]] = opt[names[1]];
  84762. }
  84763. }, this);
  84764. this._updateRangeUse(opt);
  84765. };
  84766. DataZoomModel.prototype.setCalculatedRange = function (opt) {
  84767. var option = this.option;
  84768. each$1(['start', 'startValue', 'end', 'endValue'], function (name) {
  84769. option[name] = opt[name];
  84770. });
  84771. };
  84772. DataZoomModel.prototype.getPercentRange = function () {
  84773. var axisProxy = this.findRepresentativeAxisProxy();
  84774. if (axisProxy) {
  84775. return axisProxy.getDataPercentWindow();
  84776. }
  84777. };
  84778. /**
  84779. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  84780. *
  84781. * @return [startValue, endValue] value can only be '-' or finite number.
  84782. */
  84783. DataZoomModel.prototype.getValueRange = function (axisDim, axisIndex) {
  84784. if (axisDim == null && axisIndex == null) {
  84785. var axisProxy = this.findRepresentativeAxisProxy();
  84786. if (axisProxy) {
  84787. return axisProxy.getDataValueWindow();
  84788. }
  84789. } else {
  84790. return this.getAxisProxy(axisDim, axisIndex).getDataValueWindow();
  84791. }
  84792. };
  84793. /**
  84794. * @param axisModel If axisModel given, find axisProxy
  84795. * corresponding to the axisModel
  84796. */
  84797. DataZoomModel.prototype.findRepresentativeAxisProxy = function (axisModel) {
  84798. if (axisModel) {
  84799. return axisModel.__dzAxisProxy;
  84800. } // Find the first hosted axisProxy
  84801. var firstProxy;
  84802. var axisDimList = this._targetAxisInfoMap.keys();
  84803. for (var i = 0; i < axisDimList.length; i++) {
  84804. var axisDim = axisDimList[i];
  84805. var axisInfo = this._targetAxisInfoMap.get(axisDim);
  84806. for (var j = 0; j < axisInfo.indexList.length; j++) {
  84807. var proxy = this.getAxisProxy(axisDim, axisInfo.indexList[j]);
  84808. if (proxy.hostedBy(this)) {
  84809. return proxy;
  84810. }
  84811. if (!firstProxy) {
  84812. firstProxy = proxy;
  84813. }
  84814. }
  84815. } // If no hosted proxy found, still need to return a proxy.
  84816. // This case always happens in toolbox dataZoom, where axes are all hosted by
  84817. // other dataZooms.
  84818. return firstProxy;
  84819. };
  84820. DataZoomModel.prototype.getRangePropMode = function () {
  84821. return this._rangePropMode.slice();
  84822. };
  84823. DataZoomModel.prototype.getOrient = function () {
  84824. {
  84825. // Should not be called before initialized.
  84826. assert$1(this._orient);
  84827. }
  84828. return this._orient;
  84829. };
  84830. DataZoomModel.type = 'dataZoom';
  84831. DataZoomModel.dependencies = ['xAxis', 'yAxis', 'radiusAxis', 'angleAxis', 'singleAxis', 'series', 'toolbox'];
  84832. DataZoomModel.defaultOption = {
  84833. zlevel: 0,
  84834. z: 4,
  84835. filterMode: 'filter',
  84836. start: 0,
  84837. end: 100
  84838. };
  84839. return DataZoomModel;
  84840. }(ComponentModel);
  84841. /**
  84842. * Retrieve the those raw params from option, which will be cached separately.
  84843. * becasue they will be overwritten by normalized/calculated values in the main
  84844. * process.
  84845. */
  84846. function retrieveRawOption(option) {
  84847. var ret = {};
  84848. each$1(['start', 'end', 'startValue', 'endValue', 'throttle'], function (name) {
  84849. option.hasOwnProperty(name) && (ret[name] = option[name]);
  84850. });
  84851. return ret;
  84852. }
  84853. /*
  84854. * Licensed to the Apache Software Foundation (ASF) under one
  84855. * or more contributor license agreements. See the NOTICE file
  84856. * distributed with this work for additional information
  84857. * regarding copyright ownership. The ASF licenses this file
  84858. * to you under the Apache License, Version 2.0 (the
  84859. * "License"); you may not use this file except in compliance
  84860. * with the License. You may obtain a copy of the License at
  84861. *
  84862. * http://www.apache.org/licenses/LICENSE-2.0
  84863. *
  84864. * Unless required by applicable law or agreed to in writing,
  84865. * software distributed under the License is distributed on an
  84866. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84867. * KIND, either express or implied. See the License for the
  84868. * specific language governing permissions and limitations
  84869. * under the License.
  84870. */
  84871. /**
  84872. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84873. */
  84874. /*
  84875. * Licensed to the Apache Software Foundation (ASF) under one
  84876. * or more contributor license agreements. See the NOTICE file
  84877. * distributed with this work for additional information
  84878. * regarding copyright ownership. The ASF licenses this file
  84879. * to you under the Apache License, Version 2.0 (the
  84880. * "License"); you may not use this file except in compliance
  84881. * with the License. You may obtain a copy of the License at
  84882. *
  84883. * http://www.apache.org/licenses/LICENSE-2.0
  84884. *
  84885. * Unless required by applicable law or agreed to in writing,
  84886. * software distributed under the License is distributed on an
  84887. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84888. * KIND, either express or implied. See the License for the
  84889. * specific language governing permissions and limitations
  84890. * under the License.
  84891. */
  84892. var InsideZoomModel =
  84893. /** @class */
  84894. function (_super) {
  84895. __extends(InsideZoomModel, _super);
  84896. function InsideZoomModel() {
  84897. var _this = _super !== null && _super.apply(this, arguments) || this;
  84898. _this.type = InsideZoomModel.type;
  84899. return _this;
  84900. }
  84901. InsideZoomModel.type = 'dataZoom.inside';
  84902. InsideZoomModel.defaultOption = inheritDefaultOption(DataZoomModel.defaultOption, {
  84903. disabled: false,
  84904. zoomLock: false,
  84905. zoomOnMouseWheel: true,
  84906. moveOnMouseMove: true,
  84907. moveOnMouseWheel: false,
  84908. preventDefaultMouseMove: true
  84909. });
  84910. return InsideZoomModel;
  84911. }(DataZoomModel);
  84912. /*
  84913. * Licensed to the Apache Software Foundation (ASF) under one
  84914. * or more contributor license agreements. See the NOTICE file
  84915. * distributed with this work for additional information
  84916. * regarding copyright ownership. The ASF licenses this file
  84917. * to you under the Apache License, Version 2.0 (the
  84918. * "License"); you may not use this file except in compliance
  84919. * with the License. You may obtain a copy of the License at
  84920. *
  84921. * http://www.apache.org/licenses/LICENSE-2.0
  84922. *
  84923. * Unless required by applicable law or agreed to in writing,
  84924. * software distributed under the License is distributed on an
  84925. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84926. * KIND, either express or implied. See the License for the
  84927. * specific language governing permissions and limitations
  84928. * under the License.
  84929. */
  84930. /**
  84931. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84932. */
  84933. /*
  84934. * Licensed to the Apache Software Foundation (ASF) under one
  84935. * or more contributor license agreements. See the NOTICE file
  84936. * distributed with this work for additional information
  84937. * regarding copyright ownership. The ASF licenses this file
  84938. * to you under the Apache License, Version 2.0 (the
  84939. * "License"); you may not use this file except in compliance
  84940. * with the License. You may obtain a copy of the License at
  84941. *
  84942. * http://www.apache.org/licenses/LICENSE-2.0
  84943. *
  84944. * Unless required by applicable law or agreed to in writing,
  84945. * software distributed under the License is distributed on an
  84946. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84947. * KIND, either express or implied. See the License for the
  84948. * specific language governing permissions and limitations
  84949. * under the License.
  84950. */
  84951. var DataZoomView =
  84952. /** @class */
  84953. function (_super) {
  84954. __extends(DataZoomView, _super);
  84955. function DataZoomView() {
  84956. var _this = _super !== null && _super.apply(this, arguments) || this;
  84957. _this.type = DataZoomView.type;
  84958. return _this;
  84959. }
  84960. DataZoomView.prototype.render = function (dataZoomModel, ecModel, api, payload) {
  84961. this.dataZoomModel = dataZoomModel;
  84962. this.ecModel = ecModel;
  84963. this.api = api;
  84964. };
  84965. DataZoomView.type = 'dataZoom';
  84966. return DataZoomView;
  84967. }(ComponentView);
  84968. /*
  84969. * Licensed to the Apache Software Foundation (ASF) under one
  84970. * or more contributor license agreements. See the NOTICE file
  84971. * distributed with this work for additional information
  84972. * regarding copyright ownership. The ASF licenses this file
  84973. * to you under the Apache License, Version 2.0 (the
  84974. * "License"); you may not use this file except in compliance
  84975. * with the License. You may obtain a copy of the License at
  84976. *
  84977. * http://www.apache.org/licenses/LICENSE-2.0
  84978. *
  84979. * Unless required by applicable law or agreed to in writing,
  84980. * software distributed under the License is distributed on an
  84981. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  84982. * KIND, either express or implied. See the License for the
  84983. * specific language governing permissions and limitations
  84984. * under the License.
  84985. */
  84986. /**
  84987. * AUTO-GENERATED FILE. DO NOT MODIFY.
  84988. */
  84989. /*
  84990. * Licensed to the Apache Software Foundation (ASF) under one
  84991. * or more contributor license agreements. See the NOTICE file
  84992. * distributed with this work for additional information
  84993. * regarding copyright ownership. The ASF licenses this file
  84994. * to you under the Apache License, Version 2.0 (the
  84995. * "License"); you may not use this file except in compliance
  84996. * with the License. You may obtain a copy of the License at
  84997. *
  84998. * http://www.apache.org/licenses/LICENSE-2.0
  84999. *
  85000. * Unless required by applicable law or agreed to in writing,
  85001. * software distributed under the License is distributed on an
  85002. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85003. * KIND, either express or implied. See the License for the
  85004. * specific language governing permissions and limitations
  85005. * under the License.
  85006. */
  85007. // Only create one roam controller for each coordinate system.
  85008. // one roam controller might be refered by two inside data zoom
  85009. // components (for example, one for x and one for y). When user
  85010. // pan or zoom, only dispatch one action for those data zoom
  85011. // components.
  85012. var inner$18 = makeInner();
  85013. function setViewInfoToCoordSysRecord(api, dataZoomModel, getRange) {
  85014. inner$18(api).coordSysRecordMap.each(function (coordSysRecord) {
  85015. var dzInfo = coordSysRecord.dataZoomInfoMap.get(dataZoomModel.uid);
  85016. if (dzInfo) {
  85017. dzInfo.getRange = getRange;
  85018. }
  85019. });
  85020. }
  85021. function disposeCoordSysRecordIfNeeded(api, dataZoomModel) {
  85022. var coordSysRecordMap = inner$18(api).coordSysRecordMap;
  85023. var coordSysKeyArr = coordSysRecordMap.keys();
  85024. for (var i = 0; i < coordSysKeyArr.length; i++) {
  85025. var coordSysKey = coordSysKeyArr[i];
  85026. var coordSysRecord = coordSysRecordMap.get(coordSysKey);
  85027. var dataZoomInfoMap = coordSysRecord.dataZoomInfoMap;
  85028. if (dataZoomInfoMap) {
  85029. var dzUid = dataZoomModel.uid;
  85030. var dzInfo = dataZoomInfoMap.get(dzUid);
  85031. if (dzInfo) {
  85032. dataZoomInfoMap.removeKey(dzUid);
  85033. if (!dataZoomInfoMap.keys().length) {
  85034. disposeCoordSysRecord(coordSysRecordMap, coordSysRecord);
  85035. }
  85036. }
  85037. }
  85038. }
  85039. }
  85040. function disposeCoordSysRecord(coordSysRecordMap, coordSysRecord) {
  85041. if (coordSysRecord) {
  85042. coordSysRecordMap.removeKey(coordSysRecord.model.uid);
  85043. var controller = coordSysRecord.controller;
  85044. controller && controller.dispose();
  85045. }
  85046. }
  85047. function createCoordSysRecord(api, coordSysModel) {
  85048. // These init props will never change after record created.
  85049. var coordSysRecord = {
  85050. model: coordSysModel,
  85051. containsPoint: curry(containsPoint, coordSysModel),
  85052. dispatchAction: curry(dispatchAction, api),
  85053. dataZoomInfoMap: null,
  85054. controller: null
  85055. }; // Must not do anything depends on coordSysRecord outside the event handler here,
  85056. // because coordSysRecord not completed yet.
  85057. var controller = coordSysRecord.controller = new RoamController(api.getZr());
  85058. each$1(['pan', 'zoom', 'scrollMove'], function (eventName) {
  85059. controller.on(eventName, function (event) {
  85060. var batch = [];
  85061. coordSysRecord.dataZoomInfoMap.each(function (dzInfo) {
  85062. // Check whether the behaviors (zoomOnMouseWheel, moveOnMouseMove,
  85063. // moveOnMouseWheel, ...) enabled.
  85064. if (!event.isAvailableBehavior(dzInfo.model.option)) {
  85065. return;
  85066. }
  85067. var method = (dzInfo.getRange || {})[eventName];
  85068. var range = method && method(dzInfo.dzReferCoordSysInfo, coordSysRecord.model.mainType, coordSysRecord.controller, event);
  85069. !dzInfo.model.get('disabled', true) && range && batch.push({
  85070. dataZoomId: dzInfo.model.id,
  85071. start: range[0],
  85072. end: range[1]
  85073. });
  85074. });
  85075. batch.length && coordSysRecord.dispatchAction(batch);
  85076. });
  85077. });
  85078. return coordSysRecord;
  85079. }
  85080. /**
  85081. * This action will be throttled.
  85082. */
  85083. function dispatchAction(api, batch) {
  85084. api.dispatchAction({
  85085. type: 'dataZoom',
  85086. animation: {
  85087. easing: 'cubicOut',
  85088. duration: 100
  85089. },
  85090. batch: batch
  85091. });
  85092. }
  85093. function containsPoint(coordSysModel, e, x, y) {
  85094. return coordSysModel.coordinateSystem.containPoint([x, y]);
  85095. }
  85096. /**
  85097. * Merge roamController settings when multiple dataZooms share one roamController.
  85098. */
  85099. function mergeControllerParams(dataZoomInfoMap) {
  85100. var controlType; // DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
  85101. // as string, it is probably revert to reserved word by compress tool. See #7411.
  85102. var prefix = 'type_';
  85103. var typePriority = {
  85104. 'type_true': 2,
  85105. 'type_move': 1,
  85106. 'type_false': 0,
  85107. 'type_undefined': -1
  85108. };
  85109. var preventDefaultMouseMove = true;
  85110. dataZoomInfoMap.each(function (dataZoomInfo) {
  85111. var dataZoomModel = dataZoomInfo.model;
  85112. var oneType = dataZoomModel.get('disabled', true) ? false : dataZoomModel.get('zoomLock', true) ? 'move' : true;
  85113. if (typePriority[prefix + oneType] > typePriority[prefix + controlType]) {
  85114. controlType = oneType;
  85115. } // Prevent default move event by default. If one false, do not prevent. Otherwise
  85116. // users may be confused why it does not work when multiple insideZooms exist.
  85117. preventDefaultMouseMove = preventDefaultMouseMove && dataZoomModel.get('preventDefaultMouseMove', true);
  85118. });
  85119. return {
  85120. controlType: controlType,
  85121. opt: {
  85122. // RoamController will enable all of these functionalities,
  85123. // and the final behavior is determined by its event listener
  85124. // provided by each inside zoom.
  85125. zoomOnMouseWheel: true,
  85126. moveOnMouseMove: true,
  85127. moveOnMouseWheel: true,
  85128. preventDefaultMouseMove: !!preventDefaultMouseMove
  85129. }
  85130. };
  85131. }
  85132. function installDataZoomRoamProcessor(registers) {
  85133. registers.registerProcessor(registers.PRIORITY.PROCESSOR.FILTER, function (ecModel, api) {
  85134. var apiInner = inner$18(api);
  85135. var coordSysRecordMap = apiInner.coordSysRecordMap || (apiInner.coordSysRecordMap = createHashMap());
  85136. coordSysRecordMap.each(function (coordSysRecord) {
  85137. // `coordSysRecordMap` always exists (becuase it hold the `roam controller`, which should
  85138. // better not re-create each time), but clear `dataZoomInfoMap` each round of the workflow.
  85139. coordSysRecord.dataZoomInfoMap = null;
  85140. });
  85141. ecModel.eachComponent({
  85142. mainType: 'dataZoom',
  85143. subType: 'inside'
  85144. }, function (dataZoomModel) {
  85145. var dzReferCoordSysWrap = collectReferCoordSysModelInfo(dataZoomModel);
  85146. each$1(dzReferCoordSysWrap.infoList, function (dzCoordSysInfo) {
  85147. var coordSysUid = dzCoordSysInfo.model.uid;
  85148. var coordSysRecord = coordSysRecordMap.get(coordSysUid) || coordSysRecordMap.set(coordSysUid, createCoordSysRecord(api, dzCoordSysInfo.model));
  85149. var dataZoomInfoMap = coordSysRecord.dataZoomInfoMap || (coordSysRecord.dataZoomInfoMap = createHashMap()); // Notice these props might be changed each time for a single dataZoomModel.
  85150. dataZoomInfoMap.set(dataZoomModel.uid, {
  85151. dzReferCoordSysInfo: dzCoordSysInfo,
  85152. model: dataZoomModel,
  85153. getRange: null
  85154. });
  85155. });
  85156. }); // (1) Merge dataZoom settings for each coord sys and set to the roam controller.
  85157. // (2) Clear coord sys if not refered by any dataZoom.
  85158. coordSysRecordMap.each(function (coordSysRecord) {
  85159. var controller = coordSysRecord.controller;
  85160. var firstDzInfo;
  85161. var dataZoomInfoMap = coordSysRecord.dataZoomInfoMap;
  85162. if (dataZoomInfoMap) {
  85163. var firstDzKey = dataZoomInfoMap.keys()[0];
  85164. if (firstDzKey != null) {
  85165. firstDzInfo = dataZoomInfoMap.get(firstDzKey);
  85166. }
  85167. }
  85168. if (!firstDzInfo) {
  85169. disposeCoordSysRecord(coordSysRecordMap, coordSysRecord);
  85170. return;
  85171. }
  85172. var controllerParams = mergeControllerParams(dataZoomInfoMap);
  85173. controller.enable(controllerParams.controlType, controllerParams.opt);
  85174. controller.setPointerChecker(coordSysRecord.containsPoint);
  85175. createOrUpdate(coordSysRecord, 'dispatchAction', firstDzInfo.model.get('throttle', true), 'fixRate');
  85176. });
  85177. });
  85178. }
  85179. /*
  85180. * Licensed to the Apache Software Foundation (ASF) under one
  85181. * or more contributor license agreements. See the NOTICE file
  85182. * distributed with this work for additional information
  85183. * regarding copyright ownership. The ASF licenses this file
  85184. * to you under the Apache License, Version 2.0 (the
  85185. * "License"); you may not use this file except in compliance
  85186. * with the License. You may obtain a copy of the License at
  85187. *
  85188. * http://www.apache.org/licenses/LICENSE-2.0
  85189. *
  85190. * Unless required by applicable law or agreed to in writing,
  85191. * software distributed under the License is distributed on an
  85192. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85193. * KIND, either express or implied. See the License for the
  85194. * specific language governing permissions and limitations
  85195. * under the License.
  85196. */
  85197. /**
  85198. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85199. */
  85200. /*
  85201. * Licensed to the Apache Software Foundation (ASF) under one
  85202. * or more contributor license agreements. See the NOTICE file
  85203. * distributed with this work for additional information
  85204. * regarding copyright ownership. The ASF licenses this file
  85205. * to you under the Apache License, Version 2.0 (the
  85206. * "License"); you may not use this file except in compliance
  85207. * with the License. You may obtain a copy of the License at
  85208. *
  85209. * http://www.apache.org/licenses/LICENSE-2.0
  85210. *
  85211. * Unless required by applicable law or agreed to in writing,
  85212. * software distributed under the License is distributed on an
  85213. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85214. * KIND, either express or implied. See the License for the
  85215. * specific language governing permissions and limitations
  85216. * under the License.
  85217. */
  85218. var InsideZoomView =
  85219. /** @class */
  85220. function (_super) {
  85221. __extends(InsideZoomView, _super);
  85222. function InsideZoomView() {
  85223. var _this = _super !== null && _super.apply(this, arguments) || this;
  85224. _this.type = 'dataZoom.inside';
  85225. return _this;
  85226. }
  85227. InsideZoomView.prototype.render = function (dataZoomModel, ecModel, api) {
  85228. _super.prototype.render.apply(this, arguments);
  85229. if (dataZoomModel.noTarget()) {
  85230. this._clear();
  85231. return;
  85232. } // Hence the `throttle` util ensures to preserve command order,
  85233. // here simply updating range all the time will not cause missing
  85234. // any of the the roam change.
  85235. this.range = dataZoomModel.getPercentRange(); // Reset controllers.
  85236. setViewInfoToCoordSysRecord(api, dataZoomModel, {
  85237. pan: bind(getRangeHandlers.pan, this),
  85238. zoom: bind(getRangeHandlers.zoom, this),
  85239. scrollMove: bind(getRangeHandlers.scrollMove, this)
  85240. });
  85241. };
  85242. InsideZoomView.prototype.dispose = function () {
  85243. this._clear();
  85244. _super.prototype.dispose.apply(this, arguments);
  85245. };
  85246. InsideZoomView.prototype._clear = function () {
  85247. disposeCoordSysRecordIfNeeded(this.api, this.dataZoomModel);
  85248. this.range = null;
  85249. };
  85250. InsideZoomView.type = 'dataZoom.inside';
  85251. return InsideZoomView;
  85252. }(DataZoomView);
  85253. var getRangeHandlers = {
  85254. zoom: function (coordSysInfo, coordSysMainType, controller, e) {
  85255. var lastRange = this.range;
  85256. var range = lastRange.slice(); // Calculate transform by the first axis.
  85257. var axisModel = coordSysInfo.axisModels[0];
  85258. if (!axisModel) {
  85259. return;
  85260. }
  85261. var directionInfo = getDirectionInfo[coordSysMainType](null, [e.originX, e.originY], axisModel, controller, coordSysInfo);
  85262. var percentPoint = (directionInfo.signal > 0 ? directionInfo.pixelStart + directionInfo.pixelLength - directionInfo.pixel : directionInfo.pixel - directionInfo.pixelStart) / directionInfo.pixelLength * (range[1] - range[0]) + range[0];
  85263. var scale = Math.max(1 / e.scale, 0);
  85264. range[0] = (range[0] - percentPoint) * scale + percentPoint;
  85265. range[1] = (range[1] - percentPoint) * scale + percentPoint; // Restrict range.
  85266. var minMaxSpan = this.dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
  85267. sliderMove(0, range, [0, 100], 0, minMaxSpan.minSpan, minMaxSpan.maxSpan);
  85268. this.range = range;
  85269. if (lastRange[0] !== range[0] || lastRange[1] !== range[1]) {
  85270. return range;
  85271. }
  85272. },
  85273. pan: makeMover(function (range, axisModel, coordSysInfo, coordSysMainType, controller, e) {
  85274. var directionInfo = getDirectionInfo[coordSysMainType]([e.oldX, e.oldY], [e.newX, e.newY], axisModel, controller, coordSysInfo);
  85275. return directionInfo.signal * (range[1] - range[0]) * directionInfo.pixel / directionInfo.pixelLength;
  85276. }),
  85277. scrollMove: makeMover(function (range, axisModel, coordSysInfo, coordSysMainType, controller, e) {
  85278. var directionInfo = getDirectionInfo[coordSysMainType]([0, 0], [e.scrollDelta, e.scrollDelta], axisModel, controller, coordSysInfo);
  85279. return directionInfo.signal * (range[1] - range[0]) * e.scrollDelta;
  85280. })
  85281. };
  85282. function makeMover(getPercentDelta) {
  85283. return function (coordSysInfo, coordSysMainType, controller, e) {
  85284. var lastRange = this.range;
  85285. var range = lastRange.slice(); // Calculate transform by the first axis.
  85286. var axisModel = coordSysInfo.axisModels[0];
  85287. if (!axisModel) {
  85288. return;
  85289. }
  85290. var percentDelta = getPercentDelta(range, axisModel, coordSysInfo, coordSysMainType, controller, e);
  85291. sliderMove(percentDelta, range, [0, 100], 'all');
  85292. this.range = range;
  85293. if (lastRange[0] !== range[0] || lastRange[1] !== range[1]) {
  85294. return range;
  85295. }
  85296. };
  85297. }
  85298. var getDirectionInfo = {
  85299. grid: function (oldPoint, newPoint, axisModel, controller, coordSysInfo) {
  85300. var axis = axisModel.axis;
  85301. var ret = {};
  85302. var rect = coordSysInfo.model.coordinateSystem.getRect();
  85303. oldPoint = oldPoint || [0, 0];
  85304. if (axis.dim === 'x') {
  85305. ret.pixel = newPoint[0] - oldPoint[0];
  85306. ret.pixelLength = rect.width;
  85307. ret.pixelStart = rect.x;
  85308. ret.signal = axis.inverse ? 1 : -1;
  85309. } else {
  85310. // axis.dim === 'y'
  85311. ret.pixel = newPoint[1] - oldPoint[1];
  85312. ret.pixelLength = rect.height;
  85313. ret.pixelStart = rect.y;
  85314. ret.signal = axis.inverse ? -1 : 1;
  85315. }
  85316. return ret;
  85317. },
  85318. polar: function (oldPoint, newPoint, axisModel, controller, coordSysInfo) {
  85319. var axis = axisModel.axis;
  85320. var ret = {};
  85321. var polar = coordSysInfo.model.coordinateSystem;
  85322. var radiusExtent = polar.getRadiusAxis().getExtent();
  85323. var angleExtent = polar.getAngleAxis().getExtent();
  85324. oldPoint = oldPoint ? polar.pointToCoord(oldPoint) : [0, 0];
  85325. newPoint = polar.pointToCoord(newPoint);
  85326. if (axisModel.mainType === 'radiusAxis') {
  85327. ret.pixel = newPoint[0] - oldPoint[0]; // ret.pixelLength = Math.abs(radiusExtent[1] - radiusExtent[0]);
  85328. // ret.pixelStart = Math.min(radiusExtent[0], radiusExtent[1]);
  85329. ret.pixelLength = radiusExtent[1] - radiusExtent[0];
  85330. ret.pixelStart = radiusExtent[0];
  85331. ret.signal = axis.inverse ? 1 : -1;
  85332. } else {
  85333. // 'angleAxis'
  85334. ret.pixel = newPoint[1] - oldPoint[1]; // ret.pixelLength = Math.abs(angleExtent[1] - angleExtent[0]);
  85335. // ret.pixelStart = Math.min(angleExtent[0], angleExtent[1]);
  85336. ret.pixelLength = angleExtent[1] - angleExtent[0];
  85337. ret.pixelStart = angleExtent[0];
  85338. ret.signal = axis.inverse ? -1 : 1;
  85339. }
  85340. return ret;
  85341. },
  85342. singleAxis: function (oldPoint, newPoint, axisModel, controller, coordSysInfo) {
  85343. var axis = axisModel.axis;
  85344. var rect = coordSysInfo.model.coordinateSystem.getRect();
  85345. var ret = {};
  85346. oldPoint = oldPoint || [0, 0];
  85347. if (axis.orient === 'horizontal') {
  85348. ret.pixel = newPoint[0] - oldPoint[0];
  85349. ret.pixelLength = rect.width;
  85350. ret.pixelStart = rect.x;
  85351. ret.signal = axis.inverse ? 1 : -1;
  85352. } else {
  85353. // 'vertical'
  85354. ret.pixel = newPoint[1] - oldPoint[1];
  85355. ret.pixelLength = rect.height;
  85356. ret.pixelStart = rect.y;
  85357. ret.signal = axis.inverse ? -1 : 1;
  85358. }
  85359. return ret;
  85360. }
  85361. };
  85362. /*
  85363. * Licensed to the Apache Software Foundation (ASF) under one
  85364. * or more contributor license agreements. See the NOTICE file
  85365. * distributed with this work for additional information
  85366. * regarding copyright ownership. The ASF licenses this file
  85367. * to you under the Apache License, Version 2.0 (the
  85368. * "License"); you may not use this file except in compliance
  85369. * with the License. You may obtain a copy of the License at
  85370. *
  85371. * http://www.apache.org/licenses/LICENSE-2.0
  85372. *
  85373. * Unless required by applicable law or agreed to in writing,
  85374. * software distributed under the License is distributed on an
  85375. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85376. * KIND, either express or implied. See the License for the
  85377. * specific language governing permissions and limitations
  85378. * under the License.
  85379. */
  85380. /**
  85381. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85382. */
  85383. /*
  85384. * Licensed to the Apache Software Foundation (ASF) under one
  85385. * or more contributor license agreements. See the NOTICE file
  85386. * distributed with this work for additional information
  85387. * regarding copyright ownership. The ASF licenses this file
  85388. * to you under the Apache License, Version 2.0 (the
  85389. * "License"); you may not use this file except in compliance
  85390. * with the License. You may obtain a copy of the License at
  85391. *
  85392. * http://www.apache.org/licenses/LICENSE-2.0
  85393. *
  85394. * Unless required by applicable law or agreed to in writing,
  85395. * software distributed under the License is distributed on an
  85396. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85397. * KIND, either express or implied. See the License for the
  85398. * specific language governing permissions and limitations
  85399. * under the License.
  85400. */
  85401. var each$11 = each$1;
  85402. var asc$1 = asc;
  85403. /**
  85404. * Operate single axis.
  85405. * One axis can only operated by one axis operator.
  85406. * Different dataZoomModels may be defined to operate the same axis.
  85407. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  85408. * So dataZoomModels share one axisProxy in that case.
  85409. */
  85410. var AxisProxy =
  85411. /** @class */
  85412. function () {
  85413. function AxisProxy(dimName, axisIndex, dataZoomModel, ecModel) {
  85414. this._dimName = dimName;
  85415. this._axisIndex = axisIndex;
  85416. this.ecModel = ecModel;
  85417. this._dataZoomModel = dataZoomModel; // /**
  85418. // * @readOnly
  85419. // * @private
  85420. // */
  85421. // this.hasSeriesStacked;
  85422. }
  85423. /**
  85424. * Whether the axisProxy is hosted by dataZoomModel.
  85425. */
  85426. AxisProxy.prototype.hostedBy = function (dataZoomModel) {
  85427. return this._dataZoomModel === dataZoomModel;
  85428. };
  85429. /**
  85430. * @return Value can only be NaN or finite value.
  85431. */
  85432. AxisProxy.prototype.getDataValueWindow = function () {
  85433. return this._valueWindow.slice();
  85434. };
  85435. /**
  85436. * @return {Array.<number>}
  85437. */
  85438. AxisProxy.prototype.getDataPercentWindow = function () {
  85439. return this._percentWindow.slice();
  85440. };
  85441. AxisProxy.prototype.getTargetSeriesModels = function () {
  85442. var seriesModels = [];
  85443. this.ecModel.eachSeries(function (seriesModel) {
  85444. if (isCoordSupported(seriesModel)) {
  85445. var axisMainType = getAxisMainType(this._dimName);
  85446. var axisModel = seriesModel.getReferringComponents(axisMainType, SINGLE_REFERRING).models[0];
  85447. if (axisModel && this._axisIndex === axisModel.componentIndex) {
  85448. seriesModels.push(seriesModel);
  85449. }
  85450. }
  85451. }, this);
  85452. return seriesModels;
  85453. };
  85454. AxisProxy.prototype.getAxisModel = function () {
  85455. return this.ecModel.getComponent(this._dimName + 'Axis', this._axisIndex);
  85456. };
  85457. AxisProxy.prototype.getMinMaxSpan = function () {
  85458. return clone(this._minMaxSpan);
  85459. };
  85460. /**
  85461. * Only calculate by given range and this._dataExtent, do not change anything.
  85462. */
  85463. AxisProxy.prototype.calculateDataWindow = function (opt) {
  85464. var dataExtent = this._dataExtent;
  85465. var axisModel = this.getAxisModel();
  85466. var scale = axisModel.axis.scale;
  85467. var rangePropMode = this._dataZoomModel.getRangePropMode();
  85468. var percentExtent = [0, 100];
  85469. var percentWindow = [];
  85470. var valueWindow = [];
  85471. var hasPropModeValue;
  85472. each$11(['start', 'end'], function (prop, idx) {
  85473. var boundPercent = opt[prop];
  85474. var boundValue = opt[prop + 'Value']; // Notice: dataZoom is based either on `percentProp` ('start', 'end') or
  85475. // on `valueProp` ('startValue', 'endValue'). (They are based on the data extent
  85476. // but not min/max of axis, which will be calculated by data window then).
  85477. // The former one is suitable for cases that a dataZoom component controls multiple
  85478. // axes with different unit or extent, and the latter one is suitable for accurate
  85479. // zoom by pixel (e.g., in dataZoomSelect).
  85480. // we use `getRangePropMode()` to mark which prop is used. `rangePropMode` is updated
  85481. // only when setOption or dispatchAction, otherwise it remains its original value.
  85482. // (Why not only record `percentProp` and always map to `valueProp`? Because
  85483. // the map `valueProp` -> `percentProp` -> `valueProp` probably not the original
  85484. // `valueProp`. consider two axes constrolled by one dataZoom. They have different
  85485. // data extent. All of values that are overflow the `dataExtent` will be calculated
  85486. // to percent '100%').
  85487. if (rangePropMode[idx] === 'percent') {
  85488. boundPercent == null && (boundPercent = percentExtent[idx]); // Use scale.parse to math round for category or time axis.
  85489. boundValue = scale.parse(linearMap(boundPercent, percentExtent, dataExtent));
  85490. } else {
  85491. hasPropModeValue = true;
  85492. boundValue = boundValue == null ? dataExtent[idx] : scale.parse(boundValue); // Calculating `percent` from `value` may be not accurate, because
  85493. // This calculation can not be inversed, because all of values that
  85494. // are overflow the `dataExtent` will be calculated to percent '100%'
  85495. boundPercent = linearMap(boundValue, dataExtent, percentExtent);
  85496. } // valueWindow[idx] = round(boundValue);
  85497. // percentWindow[idx] = round(boundPercent);
  85498. valueWindow[idx] = boundValue;
  85499. percentWindow[idx] = boundPercent;
  85500. });
  85501. asc$1(valueWindow);
  85502. asc$1(percentWindow); // The windows from user calling of `dispatchAction` might be out of the extent,
  85503. // or do not obey the `min/maxSpan`, `min/maxValueSpan`. But we dont restrict window
  85504. // by `zoomLock` here, because we see `zoomLock` just as a interaction constraint,
  85505. // where API is able to initialize/modify the window size even though `zoomLock`
  85506. // specified.
  85507. var spans = this._minMaxSpan;
  85508. hasPropModeValue ? restrictSet(valueWindow, percentWindow, dataExtent, percentExtent, false) : restrictSet(percentWindow, valueWindow, percentExtent, dataExtent, true);
  85509. function restrictSet(fromWindow, toWindow, fromExtent, toExtent, toValue) {
  85510. var suffix = toValue ? 'Span' : 'ValueSpan';
  85511. sliderMove(0, fromWindow, fromExtent, 'all', spans['min' + suffix], spans['max' + suffix]);
  85512. for (var i = 0; i < 2; i++) {
  85513. toWindow[i] = linearMap(fromWindow[i], fromExtent, toExtent, true);
  85514. toValue && (toWindow[i] = scale.parse(toWindow[i]));
  85515. }
  85516. }
  85517. return {
  85518. valueWindow: valueWindow,
  85519. percentWindow: percentWindow
  85520. };
  85521. };
  85522. /**
  85523. * Notice: reset should not be called before series.restoreData() called,
  85524. * so it is recommanded to be called in "process stage" but not "model init
  85525. * stage".
  85526. */
  85527. AxisProxy.prototype.reset = function (dataZoomModel) {
  85528. if (dataZoomModel !== this._dataZoomModel) {
  85529. return;
  85530. }
  85531. var targetSeries = this.getTargetSeriesModels(); // Culculate data window and data extent, and record them.
  85532. this._dataExtent = calculateDataExtent(this, this._dimName, targetSeries); // this.hasSeriesStacked = false;
  85533. // each(targetSeries, function (series) {
  85534. // let data = series.getData();
  85535. // let dataDim = data.mapDimension(this._dimName);
  85536. // let stackedDimension = data.getCalculationInfo('stackedDimension');
  85537. // if (stackedDimension && stackedDimension === dataDim) {
  85538. // this.hasSeriesStacked = true;
  85539. // }
  85540. // }, this);
  85541. // `calculateDataWindow` uses min/maxSpan.
  85542. this._updateMinMaxSpan();
  85543. var dataWindow = this.calculateDataWindow(dataZoomModel.settledOption);
  85544. this._valueWindow = dataWindow.valueWindow;
  85545. this._percentWindow = dataWindow.percentWindow; // Update axis setting then.
  85546. this._setAxisModel();
  85547. };
  85548. AxisProxy.prototype.filterData = function (dataZoomModel, api) {
  85549. if (dataZoomModel !== this._dataZoomModel) {
  85550. return;
  85551. }
  85552. var axisDim = this._dimName;
  85553. var seriesModels = this.getTargetSeriesModels();
  85554. var filterMode = dataZoomModel.get('filterMode');
  85555. var valueWindow = this._valueWindow;
  85556. if (filterMode === 'none') {
  85557. return;
  85558. } // FIXME
  85559. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  85560. // with NaN data, NaN will be filtered and stack will be wrong.
  85561. // So we need to force the mode to be set empty.
  85562. // In fect, it is not a big deal that do not support filterMode-'filter'
  85563. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  85564. // selection" some day, which might need "adapt to data extent on the
  85565. // otherAxis", which is disabled by filterMode-'empty'.
  85566. // But currently, stack has been fixed to based on value but not index,
  85567. // so this is not an issue any more.
  85568. // let otherAxisModel = this.getOtherAxisModel();
  85569. // if (dataZoomModel.get('$fromToolbox')
  85570. // && otherAxisModel
  85571. // && otherAxisModel.hasSeriesStacked
  85572. // ) {
  85573. // filterMode = 'empty';
  85574. // }
  85575. // TODO
  85576. // filterMode 'weakFilter' and 'empty' is not optimized for huge data yet.
  85577. each$11(seriesModels, function (seriesModel) {
  85578. var seriesData = seriesModel.getData();
  85579. var dataDims = seriesData.mapDimensionsAll(axisDim);
  85580. if (!dataDims.length) {
  85581. return;
  85582. }
  85583. if (filterMode === 'weakFilter') {
  85584. seriesData.filterSelf(function (dataIndex) {
  85585. var leftOut;
  85586. var rightOut;
  85587. var hasValue;
  85588. for (var i = 0; i < dataDims.length; i++) {
  85589. var value = seriesData.get(dataDims[i], dataIndex);
  85590. var thisHasValue = !isNaN(value);
  85591. var thisLeftOut = value < valueWindow[0];
  85592. var thisRightOut = value > valueWindow[1];
  85593. if (thisHasValue && !thisLeftOut && !thisRightOut) {
  85594. return true;
  85595. }
  85596. thisHasValue && (hasValue = true);
  85597. thisLeftOut && (leftOut = true);
  85598. thisRightOut && (rightOut = true);
  85599. } // If both left out and right out, do not filter.
  85600. return hasValue && leftOut && rightOut;
  85601. });
  85602. } else {
  85603. each$11(dataDims, function (dim) {
  85604. if (filterMode === 'empty') {
  85605. seriesModel.setData(seriesData = seriesData.map(dim, function (value) {
  85606. return !isInWindow(value) ? NaN : value;
  85607. }));
  85608. } else {
  85609. var range = {};
  85610. range[dim] = valueWindow; // console.time('select');
  85611. seriesData.selectRange(range); // console.timeEnd('select');
  85612. }
  85613. });
  85614. }
  85615. each$11(dataDims, function (dim) {
  85616. seriesData.setApproximateExtent(valueWindow, dim);
  85617. });
  85618. });
  85619. function isInWindow(value) {
  85620. return value >= valueWindow[0] && value <= valueWindow[1];
  85621. }
  85622. };
  85623. AxisProxy.prototype._updateMinMaxSpan = function () {
  85624. var minMaxSpan = this._minMaxSpan = {};
  85625. var dataZoomModel = this._dataZoomModel;
  85626. var dataExtent = this._dataExtent;
  85627. each$11(['min', 'max'], function (minMax) {
  85628. var percentSpan = dataZoomModel.get(minMax + 'Span');
  85629. var valueSpan = dataZoomModel.get(minMax + 'ValueSpan');
  85630. valueSpan != null && (valueSpan = this.getAxisModel().axis.scale.parse(valueSpan)); // minValueSpan and maxValueSpan has higher priority than minSpan and maxSpan
  85631. if (valueSpan != null) {
  85632. percentSpan = linearMap(dataExtent[0] + valueSpan, dataExtent, [0, 100], true);
  85633. } else if (percentSpan != null) {
  85634. valueSpan = linearMap(percentSpan, [0, 100], dataExtent, true) - dataExtent[0];
  85635. }
  85636. minMaxSpan[minMax + 'Span'] = percentSpan;
  85637. minMaxSpan[minMax + 'ValueSpan'] = valueSpan;
  85638. }, this);
  85639. };
  85640. AxisProxy.prototype._setAxisModel = function () {
  85641. var axisModel = this.getAxisModel();
  85642. var percentWindow = this._percentWindow;
  85643. var valueWindow = this._valueWindow;
  85644. if (!percentWindow) {
  85645. return;
  85646. } // [0, 500]: arbitrary value, guess axis extent.
  85647. var precision = getPixelPrecision(valueWindow, [0, 500]);
  85648. precision = Math.min(precision, 20); // For value axis, if min/max/scale are not set, we just use the extent obtained
  85649. // by series data, which may be a little different from the extent calculated by
  85650. // `axisHelper.getScaleExtent`. But the different just affects the experience a
  85651. // little when zooming. So it will not be fixed until some users require it strongly.
  85652. var rawExtentInfo = axisModel.axis.scale.rawExtentInfo;
  85653. if (percentWindow[0] !== 0) {
  85654. rawExtentInfo.setDeterminedMinMax('min', +valueWindow[0].toFixed(precision));
  85655. }
  85656. if (percentWindow[1] !== 100) {
  85657. rawExtentInfo.setDeterminedMinMax('max', +valueWindow[1].toFixed(precision));
  85658. }
  85659. rawExtentInfo.freeze();
  85660. };
  85661. return AxisProxy;
  85662. }();
  85663. function calculateDataExtent(axisProxy, axisDim, seriesModels) {
  85664. var dataExtent = [Infinity, -Infinity];
  85665. each$11(seriesModels, function (seriesModel) {
  85666. unionAxisExtentFromData(dataExtent, seriesModel.getData(), axisDim);
  85667. }); // It is important to get "consistent" extent when more then one axes is
  85668. // controlled by a `dataZoom`, otherwise those axes will not be synchronized
  85669. // when zooming. But it is difficult to know what is "consistent", considering
  85670. // axes have different type or even different meanings (For example, two
  85671. // time axes are used to compare data of the same date in different years).
  85672. // So basically dataZoom just obtains extent by series.data (in category axis
  85673. // extent can be obtained from axis.data).
  85674. // Nevertheless, user can set min/max/scale on axes to make extent of axes
  85675. // consistent.
  85676. var axisModel = axisProxy.getAxisModel();
  85677. var rawExtentResult = ensureScaleRawExtentInfo(axisModel.axis.scale, axisModel, dataExtent).calculate();
  85678. return [rawExtentResult.min, rawExtentResult.max];
  85679. }
  85680. /*
  85681. * Licensed to the Apache Software Foundation (ASF) under one
  85682. * or more contributor license agreements. See the NOTICE file
  85683. * distributed with this work for additional information
  85684. * regarding copyright ownership. The ASF licenses this file
  85685. * to you under the Apache License, Version 2.0 (the
  85686. * "License"); you may not use this file except in compliance
  85687. * with the License. You may obtain a copy of the License at
  85688. *
  85689. * http://www.apache.org/licenses/LICENSE-2.0
  85690. *
  85691. * Unless required by applicable law or agreed to in writing,
  85692. * software distributed under the License is distributed on an
  85693. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85694. * KIND, either express or implied. See the License for the
  85695. * specific language governing permissions and limitations
  85696. * under the License.
  85697. */
  85698. /**
  85699. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85700. */
  85701. /*
  85702. * Licensed to the Apache Software Foundation (ASF) under one
  85703. * or more contributor license agreements. See the NOTICE file
  85704. * distributed with this work for additional information
  85705. * regarding copyright ownership. The ASF licenses this file
  85706. * to you under the Apache License, Version 2.0 (the
  85707. * "License"); you may not use this file except in compliance
  85708. * with the License. You may obtain a copy of the License at
  85709. *
  85710. * http://www.apache.org/licenses/LICENSE-2.0
  85711. *
  85712. * Unless required by applicable law or agreed to in writing,
  85713. * software distributed under the License is distributed on an
  85714. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85715. * KIND, either express or implied. See the License for the
  85716. * specific language governing permissions and limitations
  85717. * under the License.
  85718. */
  85719. var dataZoomProcessor = {
  85720. // `dataZoomProcessor` will only be performed in needed series. Consider if
  85721. // there is a line series and a pie series, it is better not to update the
  85722. // line series if only pie series is needed to be updated.
  85723. getTargetSeries: function (ecModel) {
  85724. function eachAxisModel(cb) {
  85725. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  85726. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  85727. var axisModel = ecModel.getComponent(getAxisMainType(axisDim), axisIndex);
  85728. cb(axisDim, axisIndex, axisModel, dataZoomModel);
  85729. });
  85730. });
  85731. } // FIXME: it brings side-effect to `getTargetSeries`.
  85732. // Prepare axis proxies.
  85733. eachAxisModel(function (axisDim, axisIndex, axisModel, dataZoomModel) {
  85734. // dispose all last axis proxy, in case that some axis are deleted.
  85735. axisModel.__dzAxisProxy = null;
  85736. });
  85737. var proxyList = [];
  85738. eachAxisModel(function (axisDim, axisIndex, axisModel, dataZoomModel) {
  85739. // Different dataZooms may constrol the same axis. In that case,
  85740. // an axisProxy serves both of them.
  85741. if (!axisModel.__dzAxisProxy) {
  85742. // Use the first dataZoomModel as the main model of axisProxy.
  85743. axisModel.__dzAxisProxy = new AxisProxy(axisDim, axisIndex, dataZoomModel, ecModel);
  85744. proxyList.push(axisModel.__dzAxisProxy);
  85745. }
  85746. });
  85747. var seriesModelMap = createHashMap();
  85748. each$1(proxyList, function (axisProxy) {
  85749. each$1(axisProxy.getTargetSeriesModels(), function (seriesModel) {
  85750. seriesModelMap.set(seriesModel.uid, seriesModel);
  85751. });
  85752. });
  85753. return seriesModelMap;
  85754. },
  85755. // Consider appendData, where filter should be performed. Because data process is
  85756. // in block mode currently, it is not need to worry about that the overallProgress
  85757. // execute every frame.
  85758. overallReset: function (ecModel, api) {
  85759. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  85760. // We calculate window and reset axis here but not in model
  85761. // init stage and not after action dispatch handler, because
  85762. // reset should be called after seriesData.restoreData.
  85763. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  85764. dataZoomModel.getAxisProxy(axisDim, axisIndex).reset(dataZoomModel);
  85765. }); // Caution: data zoom filtering is order sensitive when using
  85766. // percent range and no min/max/scale set on axis.
  85767. // For example, we have dataZoom definition:
  85768. // [
  85769. // {xAxisIndex: 0, start: 30, end: 70},
  85770. // {yAxisIndex: 0, start: 20, end: 80}
  85771. // ]
  85772. // In this case, [20, 80] of y-dataZoom should be based on data
  85773. // that have filtered by x-dataZoom using range of [30, 70],
  85774. // but should not be based on full raw data. Thus sliding
  85775. // x-dataZoom will change both ranges of xAxis and yAxis,
  85776. // while sliding y-dataZoom will only change the range of yAxis.
  85777. // So we should filter x-axis after reset x-axis immediately,
  85778. // and then reset y-axis and filter y-axis.
  85779. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  85780. dataZoomModel.getAxisProxy(axisDim, axisIndex).filterData(dataZoomModel, api);
  85781. });
  85782. });
  85783. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  85784. // Fullfill all of the range props so that user
  85785. // is able to get them from chart.getOption().
  85786. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  85787. if (axisProxy) {
  85788. var percentRange = axisProxy.getDataPercentWindow();
  85789. var valueRange = axisProxy.getDataValueWindow();
  85790. dataZoomModel.setCalculatedRange({
  85791. start: percentRange[0],
  85792. end: percentRange[1],
  85793. startValue: valueRange[0],
  85794. endValue: valueRange[1]
  85795. });
  85796. }
  85797. });
  85798. }
  85799. };
  85800. /*
  85801. * Licensed to the Apache Software Foundation (ASF) under one
  85802. * or more contributor license agreements. See the NOTICE file
  85803. * distributed with this work for additional information
  85804. * regarding copyright ownership. The ASF licenses this file
  85805. * to you under the Apache License, Version 2.0 (the
  85806. * "License"); you may not use this file except in compliance
  85807. * with the License. You may obtain a copy of the License at
  85808. *
  85809. * http://www.apache.org/licenses/LICENSE-2.0
  85810. *
  85811. * Unless required by applicable law or agreed to in writing,
  85812. * software distributed under the License is distributed on an
  85813. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85814. * KIND, either express or implied. See the License for the
  85815. * specific language governing permissions and limitations
  85816. * under the License.
  85817. */
  85818. /**
  85819. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85820. */
  85821. /*
  85822. * Licensed to the Apache Software Foundation (ASF) under one
  85823. * or more contributor license agreements. See the NOTICE file
  85824. * distributed with this work for additional information
  85825. * regarding copyright ownership. The ASF licenses this file
  85826. * to you under the Apache License, Version 2.0 (the
  85827. * "License"); you may not use this file except in compliance
  85828. * with the License. You may obtain a copy of the License at
  85829. *
  85830. * http://www.apache.org/licenses/LICENSE-2.0
  85831. *
  85832. * Unless required by applicable law or agreed to in writing,
  85833. * software distributed under the License is distributed on an
  85834. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85835. * KIND, either express or implied. See the License for the
  85836. * specific language governing permissions and limitations
  85837. * under the License.
  85838. */
  85839. function installDataZoomAction(registers) {
  85840. registers.registerAction('dataZoom', function (payload, ecModel) {
  85841. var effectedModels = findEffectedDataZooms(ecModel, payload);
  85842. each$1(effectedModels, function (dataZoomModel) {
  85843. dataZoomModel.setRawRange({
  85844. start: payload.start,
  85845. end: payload.end,
  85846. startValue: payload.startValue,
  85847. endValue: payload.endValue
  85848. });
  85849. });
  85850. });
  85851. }
  85852. /*
  85853. * Licensed to the Apache Software Foundation (ASF) under one
  85854. * or more contributor license agreements. See the NOTICE file
  85855. * distributed with this work for additional information
  85856. * regarding copyright ownership. The ASF licenses this file
  85857. * to you under the Apache License, Version 2.0 (the
  85858. * "License"); you may not use this file except in compliance
  85859. * with the License. You may obtain a copy of the License at
  85860. *
  85861. * http://www.apache.org/licenses/LICENSE-2.0
  85862. *
  85863. * Unless required by applicable law or agreed to in writing,
  85864. * software distributed under the License is distributed on an
  85865. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85866. * KIND, either express or implied. See the License for the
  85867. * specific language governing permissions and limitations
  85868. * under the License.
  85869. */
  85870. /**
  85871. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85872. */
  85873. /*
  85874. * Licensed to the Apache Software Foundation (ASF) under one
  85875. * or more contributor license agreements. See the NOTICE file
  85876. * distributed with this work for additional information
  85877. * regarding copyright ownership. The ASF licenses this file
  85878. * to you under the Apache License, Version 2.0 (the
  85879. * "License"); you may not use this file except in compliance
  85880. * with the License. You may obtain a copy of the License at
  85881. *
  85882. * http://www.apache.org/licenses/LICENSE-2.0
  85883. *
  85884. * Unless required by applicable law or agreed to in writing,
  85885. * software distributed under the License is distributed on an
  85886. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85887. * KIND, either express or implied. See the License for the
  85888. * specific language governing permissions and limitations
  85889. * under the License.
  85890. */
  85891. var installed = false;
  85892. function installCommon(registers) {
  85893. if (installed) {
  85894. return;
  85895. }
  85896. installed = true;
  85897. registers.registerProcessor(registers.PRIORITY.PROCESSOR.FILTER, dataZoomProcessor);
  85898. installDataZoomAction(registers);
  85899. registers.registerSubTypeDefaulter('dataZoom', function () {
  85900. // Default 'slider' when no type specified.
  85901. return 'slider';
  85902. });
  85903. }
  85904. /*
  85905. * Licensed to the Apache Software Foundation (ASF) under one
  85906. * or more contributor license agreements. See the NOTICE file
  85907. * distributed with this work for additional information
  85908. * regarding copyright ownership. The ASF licenses this file
  85909. * to you under the Apache License, Version 2.0 (the
  85910. * "License"); you may not use this file except in compliance
  85911. * with the License. You may obtain a copy of the License at
  85912. *
  85913. * http://www.apache.org/licenses/LICENSE-2.0
  85914. *
  85915. * Unless required by applicable law or agreed to in writing,
  85916. * software distributed under the License is distributed on an
  85917. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85918. * KIND, either express or implied. See the License for the
  85919. * specific language governing permissions and limitations
  85920. * under the License.
  85921. */
  85922. /**
  85923. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85924. */
  85925. /*
  85926. * Licensed to the Apache Software Foundation (ASF) under one
  85927. * or more contributor license agreements. See the NOTICE file
  85928. * distributed with this work for additional information
  85929. * regarding copyright ownership. The ASF licenses this file
  85930. * to you under the Apache License, Version 2.0 (the
  85931. * "License"); you may not use this file except in compliance
  85932. * with the License. You may obtain a copy of the License at
  85933. *
  85934. * http://www.apache.org/licenses/LICENSE-2.0
  85935. *
  85936. * Unless required by applicable law or agreed to in writing,
  85937. * software distributed under the License is distributed on an
  85938. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85939. * KIND, either express or implied. See the License for the
  85940. * specific language governing permissions and limitations
  85941. * under the License.
  85942. */
  85943. function install$41(registers) {
  85944. installCommon(registers);
  85945. registers.registerComponentModel(InsideZoomModel);
  85946. registers.registerComponentView(InsideZoomView);
  85947. installDataZoomRoamProcessor(registers);
  85948. }
  85949. /*
  85950. * Licensed to the Apache Software Foundation (ASF) under one
  85951. * or more contributor license agreements. See the NOTICE file
  85952. * distributed with this work for additional information
  85953. * regarding copyright ownership. The ASF licenses this file
  85954. * to you under the Apache License, Version 2.0 (the
  85955. * "License"); you may not use this file except in compliance
  85956. * with the License. You may obtain a copy of the License at
  85957. *
  85958. * http://www.apache.org/licenses/LICENSE-2.0
  85959. *
  85960. * Unless required by applicable law or agreed to in writing,
  85961. * software distributed under the License is distributed on an
  85962. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85963. * KIND, either express or implied. See the License for the
  85964. * specific language governing permissions and limitations
  85965. * under the License.
  85966. */
  85967. /**
  85968. * AUTO-GENERATED FILE. DO NOT MODIFY.
  85969. */
  85970. /*
  85971. * Licensed to the Apache Software Foundation (ASF) under one
  85972. * or more contributor license agreements. See the NOTICE file
  85973. * distributed with this work for additional information
  85974. * regarding copyright ownership. The ASF licenses this file
  85975. * to you under the Apache License, Version 2.0 (the
  85976. * "License"); you may not use this file except in compliance
  85977. * with the License. You may obtain a copy of the License at
  85978. *
  85979. * http://www.apache.org/licenses/LICENSE-2.0
  85980. *
  85981. * Unless required by applicable law or agreed to in writing,
  85982. * software distributed under the License is distributed on an
  85983. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  85984. * KIND, either express or implied. See the License for the
  85985. * specific language governing permissions and limitations
  85986. * under the License.
  85987. */
  85988. var SliderZoomModel =
  85989. /** @class */
  85990. function (_super) {
  85991. __extends(SliderZoomModel, _super);
  85992. function SliderZoomModel() {
  85993. var _this = _super !== null && _super.apply(this, arguments) || this;
  85994. _this.type = SliderZoomModel.type;
  85995. return _this;
  85996. }
  85997. SliderZoomModel.type = 'dataZoom.slider';
  85998. SliderZoomModel.layoutMode = 'box';
  85999. SliderZoomModel.defaultOption = inheritDefaultOption(DataZoomModel.defaultOption, {
  86000. show: true,
  86001. // deault value can only be drived in view stage.
  86002. right: 'ph',
  86003. top: 'ph',
  86004. width: 'ph',
  86005. height: 'ph',
  86006. left: null,
  86007. bottom: null,
  86008. borderColor: '#d2dbee',
  86009. borderRadius: 3,
  86010. backgroundColor: 'rgba(47,69,84,0)',
  86011. // dataBackgroundColor: '#ddd',
  86012. dataBackground: {
  86013. lineStyle: {
  86014. color: '#d2dbee',
  86015. width: 0.5
  86016. },
  86017. areaStyle: {
  86018. color: '#d2dbee',
  86019. opacity: 0.2
  86020. }
  86021. },
  86022. selectedDataBackground: {
  86023. lineStyle: {
  86024. color: '#8fb0f7',
  86025. width: 0.5
  86026. },
  86027. areaStyle: {
  86028. color: '#8fb0f7',
  86029. opacity: 0.2
  86030. }
  86031. },
  86032. // Color of selected window.
  86033. fillerColor: 'rgba(135,175,274,0.2)',
  86034. handleIcon: 'path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z',
  86035. // Percent of the slider height
  86036. handleSize: '100%',
  86037. handleStyle: {
  86038. color: '#fff',
  86039. borderColor: '#ACB8D1'
  86040. },
  86041. moveHandleSize: 7,
  86042. moveHandleIcon: 'path://M-320.9-50L-320.9-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-348-41-339-50-320.9-50z M-212.3-50L-212.3-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-239.4-41-230.4-50-212.3-50z M-103.7-50L-103.7-50c18.1,0,27.1,9,27.1,27.1V85.7c0,18.1-9,27.1-27.1,27.1l0,0c-18.1,0-27.1-9-27.1-27.1V-22.9C-130.9-41-121.8-50-103.7-50z',
  86043. moveHandleStyle: {
  86044. color: '#D2DBEE',
  86045. opacity: 0.7
  86046. },
  86047. showDetail: true,
  86048. showDataShadow: 'auto',
  86049. realtime: true,
  86050. zoomLock: false,
  86051. textStyle: {
  86052. color: '#6E7079'
  86053. },
  86054. brushSelect: true,
  86055. brushStyle: {
  86056. color: 'rgba(135,175,274,0.15)'
  86057. },
  86058. emphasis: {
  86059. handleStyle: {
  86060. borderColor: '#8FB0F7'
  86061. },
  86062. moveHandleStyle: {
  86063. color: '#8FB0F7'
  86064. }
  86065. }
  86066. });
  86067. return SliderZoomModel;
  86068. }(DataZoomModel);
  86069. /*
  86070. * Licensed to the Apache Software Foundation (ASF) under one
  86071. * or more contributor license agreements. See the NOTICE file
  86072. * distributed with this work for additional information
  86073. * regarding copyright ownership. The ASF licenses this file
  86074. * to you under the Apache License, Version 2.0 (the
  86075. * "License"); you may not use this file except in compliance
  86076. * with the License. You may obtain a copy of the License at
  86077. *
  86078. * http://www.apache.org/licenses/LICENSE-2.0
  86079. *
  86080. * Unless required by applicable law or agreed to in writing,
  86081. * software distributed under the License is distributed on an
  86082. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86083. * KIND, either express or implied. See the License for the
  86084. * specific language governing permissions and limitations
  86085. * under the License.
  86086. */
  86087. /**
  86088. * AUTO-GENERATED FILE. DO NOT MODIFY.
  86089. */
  86090. /*
  86091. * Licensed to the Apache Software Foundation (ASF) under one
  86092. * or more contributor license agreements. See the NOTICE file
  86093. * distributed with this work for additional information
  86094. * regarding copyright ownership. The ASF licenses this file
  86095. * to you under the Apache License, Version 2.0 (the
  86096. * "License"); you may not use this file except in compliance
  86097. * with the License. You may obtain a copy of the License at
  86098. *
  86099. * http://www.apache.org/licenses/LICENSE-2.0
  86100. *
  86101. * Unless required by applicable law or agreed to in writing,
  86102. * software distributed under the License is distributed on an
  86103. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86104. * KIND, either express or implied. See the License for the
  86105. * specific language governing permissions and limitations
  86106. * under the License.
  86107. */
  86108. var Rect$3 = Rect; // Constants
  86109. var DEFAULT_LOCATION_EDGE_GAP = 7;
  86110. var DEFAULT_FRAME_BORDER_WIDTH = 1;
  86111. var DEFAULT_FILLER_SIZE = 30;
  86112. var DEFAULT_MOVE_HANDLE_SIZE = 7;
  86113. var HORIZONTAL = 'horizontal';
  86114. var VERTICAL = 'vertical';
  86115. var LABEL_GAP = 5;
  86116. var SHOW_DATA_SHADOW_SERIES_TYPE = ['line', 'bar', 'candlestick', 'scatter'];
  86117. var REALTIME_ANIMATION_CONFIG = {
  86118. easing: 'cubicOut',
  86119. duration: 100
  86120. };
  86121. var SliderZoomView =
  86122. /** @class */
  86123. function (_super) {
  86124. __extends(SliderZoomView, _super);
  86125. function SliderZoomView() {
  86126. var _this = _super !== null && _super.apply(this, arguments) || this;
  86127. _this.type = SliderZoomView.type;
  86128. _this._displayables = {};
  86129. return _this;
  86130. }
  86131. SliderZoomView.prototype.init = function (ecModel, api) {
  86132. this.api = api; // A unique handler for each dataZoom component
  86133. this._onBrush = bind(this._onBrush, this);
  86134. this._onBrushEnd = bind(this._onBrushEnd, this);
  86135. };
  86136. SliderZoomView.prototype.render = function (dataZoomModel, ecModel, api, payload) {
  86137. _super.prototype.render.apply(this, arguments);
  86138. createOrUpdate(this, '_dispatchZoomAction', dataZoomModel.get('throttle'), 'fixRate');
  86139. this._orient = dataZoomModel.getOrient();
  86140. if (dataZoomModel.get('show') === false) {
  86141. this.group.removeAll();
  86142. return;
  86143. }
  86144. if (dataZoomModel.noTarget()) {
  86145. this._clear();
  86146. this.group.removeAll();
  86147. return;
  86148. } // Notice: this._resetInterval() should not be executed when payload.type
  86149. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  86150. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  86151. if (!payload || payload.type !== 'dataZoom' || payload.from !== this.uid) {
  86152. this._buildView();
  86153. }
  86154. this._updateView();
  86155. };
  86156. SliderZoomView.prototype.dispose = function () {
  86157. this._clear();
  86158. _super.prototype.dispose.apply(this, arguments);
  86159. };
  86160. SliderZoomView.prototype._clear = function () {
  86161. clear(this, '_dispatchZoomAction');
  86162. var zr = this.api.getZr();
  86163. zr.off('mousemove', this._onBrush);
  86164. zr.off('mouseup', this._onBrushEnd);
  86165. };
  86166. SliderZoomView.prototype._buildView = function () {
  86167. var thisGroup = this.group;
  86168. thisGroup.removeAll();
  86169. this._brushing = false;
  86170. this._displayables.brushRect = null;
  86171. this._resetLocation();
  86172. this._resetInterval();
  86173. var barGroup = this._displayables.sliderGroup = new Group();
  86174. this._renderBackground();
  86175. this._renderHandle();
  86176. this._renderDataShadow();
  86177. thisGroup.add(barGroup);
  86178. this._positionGroup();
  86179. };
  86180. SliderZoomView.prototype._resetLocation = function () {
  86181. var dataZoomModel = this.dataZoomModel;
  86182. var api = this.api;
  86183. var showMoveHandle = dataZoomModel.get('brushSelect');
  86184. var moveHandleSize = showMoveHandle ? DEFAULT_MOVE_HANDLE_SIZE : 0; // If some of x/y/width/height are not specified,
  86185. // auto-adapt according to target grid.
  86186. var coordRect = this._findCoordRect();
  86187. var ecSize = {
  86188. width: api.getWidth(),
  86189. height: api.getHeight()
  86190. }; // Default align by coordinate system rect.
  86191. var positionInfo = this._orient === HORIZONTAL ? {
  86192. // Why using 'right', because right should be used in vertical,
  86193. // and it is better to be consistent for dealing with position param merge.
  86194. right: ecSize.width - coordRect.x - coordRect.width,
  86195. top: ecSize.height - DEFAULT_FILLER_SIZE - DEFAULT_LOCATION_EDGE_GAP - moveHandleSize,
  86196. width: coordRect.width,
  86197. height: DEFAULT_FILLER_SIZE
  86198. } : {
  86199. right: DEFAULT_LOCATION_EDGE_GAP,
  86200. top: coordRect.y,
  86201. width: DEFAULT_FILLER_SIZE,
  86202. height: coordRect.height
  86203. }; // Do not write back to option and replace value 'ph', because
  86204. // the 'ph' value should be recalculated when resize.
  86205. var layoutParams = getLayoutParams(dataZoomModel.option); // Replace the placeholder value.
  86206. each$1(['right', 'top', 'width', 'height'], function (name) {
  86207. if (layoutParams[name] === 'ph') {
  86208. layoutParams[name] = positionInfo[name];
  86209. }
  86210. });
  86211. var layoutRect = getLayoutRect(layoutParams, ecSize);
  86212. this._location = {
  86213. x: layoutRect.x,
  86214. y: layoutRect.y
  86215. };
  86216. this._size = [layoutRect.width, layoutRect.height];
  86217. this._orient === VERTICAL && this._size.reverse();
  86218. };
  86219. SliderZoomView.prototype._positionGroup = function () {
  86220. var thisGroup = this.group;
  86221. var location = this._location;
  86222. var orient = this._orient; // Just use the first axis to determine mapping.
  86223. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel();
  86224. var inverse = targetAxisModel && targetAxisModel.get('inverse');
  86225. var sliderGroup = this._displayables.sliderGroup;
  86226. var otherAxisInverse = (this._dataShadowInfo || {}).otherAxisInverse; // Transform barGroup.
  86227. sliderGroup.attr(orient === HORIZONTAL && !inverse ? {
  86228. scaleY: otherAxisInverse ? 1 : -1,
  86229. scaleX: 1
  86230. } : orient === HORIZONTAL && inverse ? {
  86231. scaleY: otherAxisInverse ? 1 : -1,
  86232. scaleX: -1
  86233. } : orient === VERTICAL && !inverse ? {
  86234. scaleY: otherAxisInverse ? -1 : 1,
  86235. scaleX: 1,
  86236. rotation: Math.PI / 2
  86237. } // Dont use Math.PI, considering shadow direction.
  86238. : {
  86239. scaleY: otherAxisInverse ? -1 : 1,
  86240. scaleX: -1,
  86241. rotation: Math.PI / 2
  86242. }); // Position barGroup
  86243. var rect = thisGroup.getBoundingRect([sliderGroup]);
  86244. thisGroup.x = location.x - rect.x;
  86245. thisGroup.y = location.y - rect.y;
  86246. thisGroup.markRedraw();
  86247. };
  86248. SliderZoomView.prototype._getViewExtent = function () {
  86249. return [0, this._size[0]];
  86250. };
  86251. SliderZoomView.prototype._renderBackground = function () {
  86252. var dataZoomModel = this.dataZoomModel;
  86253. var size = this._size;
  86254. var barGroup = this._displayables.sliderGroup;
  86255. var brushSelect = dataZoomModel.get('brushSelect');
  86256. barGroup.add(new Rect$3({
  86257. silent: true,
  86258. shape: {
  86259. x: 0,
  86260. y: 0,
  86261. width: size[0],
  86262. height: size[1]
  86263. },
  86264. style: {
  86265. fill: dataZoomModel.get('backgroundColor')
  86266. },
  86267. z2: -40
  86268. })); // Click panel, over shadow, below handles.
  86269. var clickPanel = new Rect$3({
  86270. shape: {
  86271. x: 0,
  86272. y: 0,
  86273. width: size[0],
  86274. height: size[1]
  86275. },
  86276. style: {
  86277. fill: 'transparent'
  86278. },
  86279. z2: 0,
  86280. onclick: bind(this._onClickPanel, this)
  86281. });
  86282. var zr = this.api.getZr();
  86283. if (brushSelect) {
  86284. clickPanel.on('mousedown', this._onBrushStart, this);
  86285. clickPanel.cursor = 'crosshair';
  86286. zr.on('mousemove', this._onBrush);
  86287. zr.on('mouseup', this._onBrushEnd);
  86288. } else {
  86289. zr.off('mousemove', this._onBrush);
  86290. zr.off('mouseup', this._onBrushEnd);
  86291. }
  86292. barGroup.add(clickPanel);
  86293. };
  86294. SliderZoomView.prototype._renderDataShadow = function () {
  86295. var info = this._dataShadowInfo = this._prepareDataShadowInfo();
  86296. this._displayables.dataShadowSegs = [];
  86297. if (!info) {
  86298. return;
  86299. }
  86300. var size = this._size;
  86301. var seriesModel = info.series;
  86302. var data = seriesModel.getRawData();
  86303. var otherDim = seriesModel.getShadowDim ? seriesModel.getShadowDim() // @see candlestick
  86304. : info.otherDim;
  86305. if (otherDim == null) {
  86306. return;
  86307. }
  86308. var otherDataExtent = data.getDataExtent(otherDim); // Nice extent.
  86309. var otherOffset = (otherDataExtent[1] - otherDataExtent[0]) * 0.3;
  86310. otherDataExtent = [otherDataExtent[0] - otherOffset, otherDataExtent[1] + otherOffset];
  86311. var otherShadowExtent = [0, size[1]];
  86312. var thisShadowExtent = [0, size[0]];
  86313. var areaPoints = [[size[0], 0], [0, 0]];
  86314. var linePoints = [];
  86315. var step = thisShadowExtent[1] / (data.count() - 1);
  86316. var thisCoord = 0; // Optimize for large data shadow
  86317. var stride = Math.round(data.count() / size[0]);
  86318. var lastIsEmpty;
  86319. data.each([otherDim], function (value, index) {
  86320. if (stride > 0 && index % stride) {
  86321. thisCoord += step;
  86322. return;
  86323. } // FIXME
  86324. // Should consider axis.min/axis.max when drawing dataShadow.
  86325. // FIXME
  86326. // 应该使用统一的空判断?还是在list里进行空判断?
  86327. var isEmpty = value == null || isNaN(value) || value === ''; // See #4235.
  86328. var otherCoord = isEmpty ? 0 : linearMap(value, otherDataExtent, otherShadowExtent, true); // Attempt to draw data shadow precisely when there are empty value.
  86329. if (isEmpty && !lastIsEmpty && index) {
  86330. areaPoints.push([areaPoints[areaPoints.length - 1][0], 0]);
  86331. linePoints.push([linePoints[linePoints.length - 1][0], 0]);
  86332. } else if (!isEmpty && lastIsEmpty) {
  86333. areaPoints.push([thisCoord, 0]);
  86334. linePoints.push([thisCoord, 0]);
  86335. }
  86336. areaPoints.push([thisCoord, otherCoord]);
  86337. linePoints.push([thisCoord, otherCoord]);
  86338. thisCoord += step;
  86339. lastIsEmpty = isEmpty;
  86340. });
  86341. var dataZoomModel = this.dataZoomModel;
  86342. function createDataShadowGroup(isSelectedArea) {
  86343. var model = dataZoomModel.getModel(isSelectedArea ? 'selectedDataBackground' : 'dataBackground');
  86344. var group = new Group();
  86345. var polygon = new Polygon({
  86346. shape: {
  86347. points: areaPoints
  86348. },
  86349. segmentIgnoreThreshold: 1,
  86350. style: model.getModel('areaStyle').getAreaStyle(),
  86351. silent: true,
  86352. z2: -20
  86353. });
  86354. var polyline = new Polyline({
  86355. shape: {
  86356. points: linePoints
  86357. },
  86358. segmentIgnoreThreshold: 1,
  86359. style: model.getModel('lineStyle').getLineStyle(),
  86360. silent: true,
  86361. z2: -19
  86362. });
  86363. group.add(polygon);
  86364. group.add(polyline);
  86365. return group;
  86366. } // let dataBackgroundModel = dataZoomModel.getModel('dataBackground');
  86367. for (var i = 0; i < 3; i++) {
  86368. var group = createDataShadowGroup(i === 1);
  86369. this._displayables.sliderGroup.add(group);
  86370. this._displayables.dataShadowSegs.push(group);
  86371. }
  86372. };
  86373. SliderZoomView.prototype._prepareDataShadowInfo = function () {
  86374. var dataZoomModel = this.dataZoomModel;
  86375. var showDataShadow = dataZoomModel.get('showDataShadow');
  86376. if (showDataShadow === false) {
  86377. return;
  86378. } // Find a representative series.
  86379. var result;
  86380. var ecModel = this.ecModel;
  86381. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  86382. var seriesModels = dataZoomModel.getAxisProxy(axisDim, axisIndex).getTargetSeriesModels();
  86383. each$1(seriesModels, function (seriesModel) {
  86384. if (result) {
  86385. return;
  86386. }
  86387. if (showDataShadow !== true && indexOf$1(SHOW_DATA_SHADOW_SERIES_TYPE, seriesModel.get('type')) < 0) {
  86388. return;
  86389. }
  86390. var thisAxis = ecModel.getComponent(getAxisMainType(axisDim), axisIndex).axis;
  86391. var otherDim = getOtherDim(axisDim);
  86392. var otherAxisInverse;
  86393. var coordSys = seriesModel.coordinateSystem;
  86394. if (otherDim != null && coordSys.getOtherAxis) {
  86395. otherAxisInverse = coordSys.getOtherAxis(thisAxis).inverse;
  86396. }
  86397. otherDim = seriesModel.getData().mapDimension(otherDim);
  86398. result = {
  86399. thisAxis: thisAxis,
  86400. series: seriesModel,
  86401. thisDim: axisDim,
  86402. otherDim: otherDim,
  86403. otherAxisInverse: otherAxisInverse
  86404. };
  86405. }, this);
  86406. }, this);
  86407. return result;
  86408. };
  86409. SliderZoomView.prototype._renderHandle = function () {
  86410. var thisGroup = this.group;
  86411. var displayables = this._displayables;
  86412. var handles = displayables.handles = [null, null];
  86413. var handleLabels = displayables.handleLabels = [null, null];
  86414. var sliderGroup = this._displayables.sliderGroup;
  86415. var size = this._size;
  86416. var dataZoomModel = this.dataZoomModel;
  86417. var api = this.api;
  86418. var borderRadius = dataZoomModel.get('borderRadius') || 0;
  86419. var brushSelect = dataZoomModel.get('brushSelect');
  86420. var filler = displayables.filler = new Rect$3({
  86421. silent: brushSelect,
  86422. style: {
  86423. fill: dataZoomModel.get('fillerColor')
  86424. },
  86425. textConfig: {
  86426. position: 'inside'
  86427. }
  86428. });
  86429. sliderGroup.add(filler); // Frame border.
  86430. sliderGroup.add(new Rect$3({
  86431. silent: true,
  86432. subPixelOptimize: true,
  86433. shape: {
  86434. x: 0,
  86435. y: 0,
  86436. width: size[0],
  86437. height: size[1],
  86438. r: borderRadius
  86439. },
  86440. style: {
  86441. stroke: dataZoomModel.get('dataBackgroundColor') // deprecated option
  86442. || dataZoomModel.get('borderColor'),
  86443. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  86444. fill: 'rgba(0,0,0,0)'
  86445. }
  86446. })); // Left and right handle to resize
  86447. each$1([0, 1], function (handleIndex) {
  86448. var iconStr = dataZoomModel.get('handleIcon');
  86449. if (!symbolBuildProxies[iconStr] && iconStr.indexOf('path://') < 0 && iconStr.indexOf('image://') < 0) {
  86450. // Compatitable with the old icon parsers. Which can use a path string without path://
  86451. iconStr = 'path://' + iconStr;
  86452. {
  86453. deprecateLog('handleIcon now needs \'path://\' prefix when using a path string');
  86454. }
  86455. }
  86456. var path = createSymbol(iconStr, -1, 0, 2, 2, null, true);
  86457. path.attr({
  86458. cursor: getCursor(this._orient),
  86459. draggable: true,
  86460. drift: bind(this._onDragMove, this, handleIndex),
  86461. ondragend: bind(this._onDragEnd, this),
  86462. onmouseover: bind(this._showDataInfo, this, true),
  86463. onmouseout: bind(this._showDataInfo, this, false),
  86464. z2: 5
  86465. });
  86466. var bRect = path.getBoundingRect();
  86467. var handleSize = dataZoomModel.get('handleSize');
  86468. this._handleHeight = parsePercent$1(handleSize, this._size[1]);
  86469. this._handleWidth = bRect.width / bRect.height * this._handleHeight;
  86470. path.setStyle(dataZoomModel.getModel('handleStyle').getItemStyle());
  86471. path.style.strokeNoScale = true;
  86472. path.rectHover = true;
  86473. path.ensureState('emphasis').style = dataZoomModel.getModel(['emphasis', 'handleStyle']).getItemStyle();
  86474. enableHoverEmphasis(path);
  86475. var handleColor = dataZoomModel.get('handleColor'); // deprecated option
  86476. // Compatitable with previous version
  86477. if (handleColor != null) {
  86478. path.style.fill = handleColor;
  86479. }
  86480. sliderGroup.add(handles[handleIndex] = path);
  86481. var textStyleModel = dataZoomModel.getModel('textStyle');
  86482. thisGroup.add(handleLabels[handleIndex] = new ZRText({
  86483. silent: true,
  86484. invisible: true,
  86485. style: createTextStyle(textStyleModel, {
  86486. x: 0,
  86487. y: 0,
  86488. text: '',
  86489. verticalAlign: 'middle',
  86490. align: 'center',
  86491. fill: textStyleModel.getTextColor(),
  86492. font: textStyleModel.getFont()
  86493. }),
  86494. z2: 10
  86495. }));
  86496. }, this); // Handle to move. Only visible when brushSelect is set true.
  86497. var actualMoveZone = filler;
  86498. if (brushSelect) {
  86499. var moveHandleHeight = parsePercent$1(dataZoomModel.get('moveHandleSize'), size[1]);
  86500. var moveHandle_1 = displayables.moveHandle = new Rect({
  86501. style: dataZoomModel.getModel('moveHandleStyle').getItemStyle(),
  86502. silent: true,
  86503. shape: {
  86504. r: [0, 0, 2, 2],
  86505. y: size[1] - 0.5,
  86506. height: moveHandleHeight
  86507. }
  86508. });
  86509. var iconSize = moveHandleHeight * 0.8;
  86510. var moveHandleIcon = displayables.moveHandleIcon = createSymbol(dataZoomModel.get('moveHandleIcon'), -iconSize / 2, -iconSize / 2, iconSize, iconSize, '#fff', true);
  86511. moveHandleIcon.silent = true;
  86512. moveHandleIcon.y = size[1] + moveHandleHeight / 2 - 0.5;
  86513. moveHandle_1.ensureState('emphasis').style = dataZoomModel.getModel(['emphasis', 'moveHandleStyle']).getItemStyle();
  86514. var moveZoneExpandSize = Math.min(size[1] / 2, Math.max(moveHandleHeight, 10));
  86515. actualMoveZone = displayables.moveZone = new Rect({
  86516. invisible: true,
  86517. shape: {
  86518. y: size[1] - moveZoneExpandSize,
  86519. height: moveHandleHeight + moveZoneExpandSize
  86520. }
  86521. });
  86522. actualMoveZone.on('mouseover', function () {
  86523. api.enterEmphasis(moveHandle_1);
  86524. }).on('mouseout', function () {
  86525. api.leaveEmphasis(moveHandle_1);
  86526. });
  86527. sliderGroup.add(moveHandle_1);
  86528. sliderGroup.add(moveHandleIcon);
  86529. sliderGroup.add(actualMoveZone);
  86530. }
  86531. actualMoveZone.attr({
  86532. draggable: true,
  86533. cursor: getCursor(this._orient),
  86534. drift: bind(this._onDragMove, this, 'all'),
  86535. ondragstart: bind(this._showDataInfo, this, true),
  86536. ondragend: bind(this._onDragEnd, this),
  86537. onmouseover: bind(this._showDataInfo, this, true),
  86538. onmouseout: bind(this._showDataInfo, this, false)
  86539. });
  86540. };
  86541. SliderZoomView.prototype._resetInterval = function () {
  86542. var range = this._range = this.dataZoomModel.getPercentRange();
  86543. var viewExtent = this._getViewExtent();
  86544. this._handleEnds = [linearMap(range[0], [0, 100], viewExtent, true), linearMap(range[1], [0, 100], viewExtent, true)];
  86545. };
  86546. SliderZoomView.prototype._updateInterval = function (handleIndex, delta) {
  86547. var dataZoomModel = this.dataZoomModel;
  86548. var handleEnds = this._handleEnds;
  86549. var viewExtend = this._getViewExtent();
  86550. var minMaxSpan = dataZoomModel.findRepresentativeAxisProxy().getMinMaxSpan();
  86551. var percentExtent = [0, 100];
  86552. sliderMove(delta, handleEnds, viewExtend, dataZoomModel.get('zoomLock') ? 'all' : handleIndex, minMaxSpan.minSpan != null ? linearMap(minMaxSpan.minSpan, percentExtent, viewExtend, true) : null, minMaxSpan.maxSpan != null ? linearMap(minMaxSpan.maxSpan, percentExtent, viewExtend, true) : null);
  86553. var lastRange = this._range;
  86554. var range = this._range = asc([linearMap(handleEnds[0], viewExtend, percentExtent, true), linearMap(handleEnds[1], viewExtend, percentExtent, true)]);
  86555. return !lastRange || lastRange[0] !== range[0] || lastRange[1] !== range[1];
  86556. };
  86557. SliderZoomView.prototype._updateView = function (nonRealtime) {
  86558. var displaybles = this._displayables;
  86559. var handleEnds = this._handleEnds;
  86560. var handleInterval = asc(handleEnds.slice());
  86561. var size = this._size;
  86562. each$1([0, 1], function (handleIndex) {
  86563. // Handles
  86564. var handle = displaybles.handles[handleIndex];
  86565. var handleHeight = this._handleHeight;
  86566. handle.attr({
  86567. scaleX: handleHeight / 2,
  86568. scaleY: handleHeight / 2,
  86569. // This is a trick, by adding an extra tiny offset to let the default handle's end point align to the drag window.
  86570. // NOTE: It may affect some custom shapes a bit. But we prefer to have better result by default.
  86571. x: handleEnds[handleIndex] + (handleIndex ? -1 : 1),
  86572. y: size[1] / 2 - handleHeight / 2
  86573. });
  86574. }, this); // Filler
  86575. displaybles.filler.setShape({
  86576. x: handleInterval[0],
  86577. y: 0,
  86578. width: handleInterval[1] - handleInterval[0],
  86579. height: size[1]
  86580. });
  86581. var viewExtent = {
  86582. x: handleInterval[0],
  86583. width: handleInterval[1] - handleInterval[0]
  86584. }; // Move handle
  86585. if (displaybles.moveHandle) {
  86586. displaybles.moveHandle.setShape(viewExtent);
  86587. displaybles.moveZone.setShape(viewExtent); // Force update path on the invisible object
  86588. displaybles.moveZone.getBoundingRect();
  86589. displaybles.moveHandleIcon && displaybles.moveHandleIcon.attr('x', viewExtent.x + viewExtent.width / 2);
  86590. } // update clip path of shadow.
  86591. var dataShadowSegs = displaybles.dataShadowSegs;
  86592. var segIntervals = [0, handleInterval[0], handleInterval[1], size[0]];
  86593. for (var i = 0; i < dataShadowSegs.length; i++) {
  86594. var segGroup = dataShadowSegs[i];
  86595. var clipPath = segGroup.getClipPath();
  86596. if (!clipPath) {
  86597. clipPath = new Rect();
  86598. segGroup.setClipPath(clipPath);
  86599. }
  86600. clipPath.setShape({
  86601. x: segIntervals[i],
  86602. y: 0,
  86603. width: segIntervals[i + 1] - segIntervals[i],
  86604. height: size[1]
  86605. });
  86606. }
  86607. this._updateDataInfo(nonRealtime);
  86608. };
  86609. SliderZoomView.prototype._updateDataInfo = function (nonRealtime) {
  86610. var dataZoomModel = this.dataZoomModel;
  86611. var displaybles = this._displayables;
  86612. var handleLabels = displaybles.handleLabels;
  86613. var orient = this._orient;
  86614. var labelTexts = ['', '']; // FIXME
  86615. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  86616. if (dataZoomModel.get('showDetail')) {
  86617. var axisProxy = dataZoomModel.findRepresentativeAxisProxy();
  86618. if (axisProxy) {
  86619. var axis = axisProxy.getAxisModel().axis;
  86620. var range = this._range;
  86621. var dataInterval = nonRealtime // See #4434, data and axis are not processed and reset yet in non-realtime mode.
  86622. ? axisProxy.calculateDataWindow({
  86623. start: range[0],
  86624. end: range[1]
  86625. }).valueWindow : axisProxy.getDataValueWindow();
  86626. labelTexts = [this._formatLabel(dataInterval[0], axis), this._formatLabel(dataInterval[1], axis)];
  86627. }
  86628. }
  86629. var orderedHandleEnds = asc(this._handleEnds.slice());
  86630. setLabel.call(this, 0);
  86631. setLabel.call(this, 1);
  86632. function setLabel(handleIndex) {
  86633. // Label
  86634. // Text should not transform by barGroup.
  86635. // Ignore handlers transform
  86636. var barTransform = getTransform(displaybles.handles[handleIndex].parent, this.group);
  86637. var direction = transformDirection(handleIndex === 0 ? 'right' : 'left', barTransform);
  86638. var offset = this._handleWidth / 2 + LABEL_GAP;
  86639. var textPoint = applyTransform$1([orderedHandleEnds[handleIndex] + (handleIndex === 0 ? -offset : offset), this._size[1] / 2], barTransform);
  86640. handleLabels[handleIndex].setStyle({
  86641. x: textPoint[0],
  86642. y: textPoint[1],
  86643. verticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  86644. align: orient === HORIZONTAL ? direction : 'center',
  86645. text: labelTexts[handleIndex]
  86646. });
  86647. }
  86648. };
  86649. SliderZoomView.prototype._formatLabel = function (value, axis) {
  86650. var dataZoomModel = this.dataZoomModel;
  86651. var labelFormatter = dataZoomModel.get('labelFormatter');
  86652. var labelPrecision = dataZoomModel.get('labelPrecision');
  86653. if (labelPrecision == null || labelPrecision === 'auto') {
  86654. labelPrecision = axis.getPixelPrecision();
  86655. }
  86656. var valueStr = value == null || isNaN(value) ? '' // FIXME Glue code
  86657. : axis.type === 'category' || axis.type === 'time' ? axis.scale.getLabel({
  86658. value: Math.round(value)
  86659. }) // param of toFixed should less then 20.
  86660. : value.toFixed(Math.min(labelPrecision, 20));
  86661. return isFunction$1(labelFormatter) ? labelFormatter(value, valueStr) : isString(labelFormatter) ? labelFormatter.replace('{value}', valueStr) : valueStr;
  86662. };
  86663. /**
  86664. * @param showOrHide true: show, false: hide
  86665. */
  86666. SliderZoomView.prototype._showDataInfo = function (showOrHide) {
  86667. // Always show when drgging.
  86668. showOrHide = this._dragging || showOrHide;
  86669. var displayables = this._displayables;
  86670. var handleLabels = displayables.handleLabels;
  86671. handleLabels[0].attr('invisible', !showOrHide);
  86672. handleLabels[1].attr('invisible', !showOrHide); // Highlight move handle
  86673. displayables.moveHandle && this.api[showOrHide ? 'enterEmphasis' : 'leaveEmphasis'](displayables.moveHandle, 1);
  86674. };
  86675. SliderZoomView.prototype._onDragMove = function (handleIndex, dx, dy, event) {
  86676. this._dragging = true; // For mobile device, prevent screen slider on the button.
  86677. stop(event.event); // Transform dx, dy to bar coordination.
  86678. var barTransform = this._displayables.sliderGroup.getLocalTransform();
  86679. var vertex = applyTransform$1([dx, dy], barTransform, true);
  86680. var changed = this._updateInterval(handleIndex, vertex[0]);
  86681. var realtime = this.dataZoomModel.get('realtime');
  86682. this._updateView(!realtime); // Avoid dispatch dataZoom repeatly but range not changed,
  86683. // which cause bad visual effect when progressive enabled.
  86684. changed && realtime && this._dispatchZoomAction(true);
  86685. };
  86686. SliderZoomView.prototype._onDragEnd = function () {
  86687. this._dragging = false;
  86688. this._showDataInfo(false); // While in realtime mode and stream mode, dispatch action when
  86689. // drag end will cause the whole view rerender, which is unnecessary.
  86690. var realtime = this.dataZoomModel.get('realtime');
  86691. !realtime && this._dispatchZoomAction(false);
  86692. };
  86693. SliderZoomView.prototype._onClickPanel = function (e) {
  86694. var size = this._size;
  86695. var localPoint = this._displayables.sliderGroup.transformCoordToLocal(e.offsetX, e.offsetY);
  86696. if (localPoint[0] < 0 || localPoint[0] > size[0] || localPoint[1] < 0 || localPoint[1] > size[1]) {
  86697. return;
  86698. }
  86699. var handleEnds = this._handleEnds;
  86700. var center = (handleEnds[0] + handleEnds[1]) / 2;
  86701. var changed = this._updateInterval('all', localPoint[0] - center);
  86702. this._updateView();
  86703. changed && this._dispatchZoomAction(false);
  86704. };
  86705. SliderZoomView.prototype._onBrushStart = function (e) {
  86706. var x = e.offsetX;
  86707. var y = e.offsetY;
  86708. this._brushStart = new Point(x, y);
  86709. this._brushing = true;
  86710. this._brushStartTime = +new Date(); // this._updateBrushRect(x, y);
  86711. };
  86712. SliderZoomView.prototype._onBrushEnd = function (e) {
  86713. if (!this._brushing) {
  86714. return;
  86715. }
  86716. var brushRect = this._displayables.brushRect;
  86717. this._brushing = false;
  86718. if (!brushRect) {
  86719. return;
  86720. }
  86721. brushRect.attr('ignore', true);
  86722. var brushShape = brushRect.shape;
  86723. var brushEndTime = +new Date(); // console.log(brushEndTime - this._brushStartTime);
  86724. if (brushEndTime - this._brushStartTime < 200 && Math.abs(brushShape.width) < 5) {
  86725. // Will treat it as a click
  86726. return;
  86727. }
  86728. var viewExtend = this._getViewExtent();
  86729. var percentExtent = [0, 100];
  86730. this._range = asc([linearMap(brushShape.x, viewExtend, percentExtent, true), linearMap(brushShape.x + brushShape.width, viewExtend, percentExtent, true)]);
  86731. this._handleEnds = [brushShape.x, brushShape.x + brushShape.width];
  86732. this._updateView();
  86733. this._dispatchZoomAction(false);
  86734. };
  86735. SliderZoomView.prototype._onBrush = function (e) {
  86736. if (this._brushing) {
  86737. // For mobile device, prevent screen slider on the button.
  86738. stop(e.event);
  86739. this._updateBrushRect(e.offsetX, e.offsetY);
  86740. }
  86741. };
  86742. SliderZoomView.prototype._updateBrushRect = function (mouseX, mouseY) {
  86743. var displayables = this._displayables;
  86744. var dataZoomModel = this.dataZoomModel;
  86745. var brushRect = displayables.brushRect;
  86746. if (!brushRect) {
  86747. brushRect = displayables.brushRect = new Rect$3({
  86748. silent: true,
  86749. style: dataZoomModel.getModel('brushStyle').getItemStyle()
  86750. });
  86751. displayables.sliderGroup.add(brushRect);
  86752. }
  86753. brushRect.attr('ignore', false);
  86754. var brushStart = this._brushStart;
  86755. var sliderGroup = this._displayables.sliderGroup;
  86756. var endPoint = sliderGroup.transformCoordToLocal(mouseX, mouseY);
  86757. var startPoint = sliderGroup.transformCoordToLocal(brushStart.x, brushStart.y);
  86758. var size = this._size;
  86759. endPoint[0] = Math.max(Math.min(size[0], endPoint[0]), 0);
  86760. brushRect.setShape({
  86761. x: startPoint[0],
  86762. y: 0,
  86763. width: endPoint[0] - startPoint[0],
  86764. height: size[1]
  86765. });
  86766. };
  86767. /**
  86768. * This action will be throttled.
  86769. */
  86770. SliderZoomView.prototype._dispatchZoomAction = function (realtime) {
  86771. var range = this._range;
  86772. this.api.dispatchAction({
  86773. type: 'dataZoom',
  86774. from: this.uid,
  86775. dataZoomId: this.dataZoomModel.id,
  86776. animation: realtime ? REALTIME_ANIMATION_CONFIG : null,
  86777. start: range[0],
  86778. end: range[1]
  86779. });
  86780. };
  86781. SliderZoomView.prototype._findCoordRect = function () {
  86782. // Find the grid coresponding to the first axis referred by dataZoom.
  86783. var rect;
  86784. var coordSysInfoList = collectReferCoordSysModelInfo(this.dataZoomModel).infoList;
  86785. if (!rect && coordSysInfoList.length) {
  86786. var coordSys = coordSysInfoList[0].model.coordinateSystem;
  86787. rect = coordSys.getRect && coordSys.getRect();
  86788. }
  86789. if (!rect) {
  86790. var width = this.api.getWidth();
  86791. var height = this.api.getHeight();
  86792. rect = {
  86793. x: width * 0.2,
  86794. y: height * 0.2,
  86795. width: width * 0.6,
  86796. height: height * 0.6
  86797. };
  86798. }
  86799. return rect;
  86800. };
  86801. SliderZoomView.type = 'dataZoom.slider';
  86802. return SliderZoomView;
  86803. }(DataZoomView);
  86804. function getOtherDim(thisDim) {
  86805. // FIXME
  86806. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  86807. var map$$1 = {
  86808. x: 'y',
  86809. y: 'x',
  86810. radius: 'angle',
  86811. angle: 'radius'
  86812. };
  86813. return map$$1[thisDim];
  86814. }
  86815. function getCursor(orient) {
  86816. return orient === 'vertical' ? 'ns-resize' : 'ew-resize';
  86817. }
  86818. /*
  86819. * Licensed to the Apache Software Foundation (ASF) under one
  86820. * or more contributor license agreements. See the NOTICE file
  86821. * distributed with this work for additional information
  86822. * regarding copyright ownership. The ASF licenses this file
  86823. * to you under the Apache License, Version 2.0 (the
  86824. * "License"); you may not use this file except in compliance
  86825. * with the License. You may obtain a copy of the License at
  86826. *
  86827. * http://www.apache.org/licenses/LICENSE-2.0
  86828. *
  86829. * Unless required by applicable law or agreed to in writing,
  86830. * software distributed under the License is distributed on an
  86831. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86832. * KIND, either express or implied. See the License for the
  86833. * specific language governing permissions and limitations
  86834. * under the License.
  86835. */
  86836. /**
  86837. * AUTO-GENERATED FILE. DO NOT MODIFY.
  86838. */
  86839. /*
  86840. * Licensed to the Apache Software Foundation (ASF) under one
  86841. * or more contributor license agreements. See the NOTICE file
  86842. * distributed with this work for additional information
  86843. * regarding copyright ownership. The ASF licenses this file
  86844. * to you under the Apache License, Version 2.0 (the
  86845. * "License"); you may not use this file except in compliance
  86846. * with the License. You may obtain a copy of the License at
  86847. *
  86848. * http://www.apache.org/licenses/LICENSE-2.0
  86849. *
  86850. * Unless required by applicable law or agreed to in writing,
  86851. * software distributed under the License is distributed on an
  86852. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86853. * KIND, either express or implied. See the License for the
  86854. * specific language governing permissions and limitations
  86855. * under the License.
  86856. */
  86857. function install$42(registers) {
  86858. registers.registerComponentModel(SliderZoomModel);
  86859. registers.registerComponentView(SliderZoomView);
  86860. installCommon(registers);
  86861. }
  86862. /*
  86863. * Licensed to the Apache Software Foundation (ASF) under one
  86864. * or more contributor license agreements. See the NOTICE file
  86865. * distributed with this work for additional information
  86866. * regarding copyright ownership. The ASF licenses this file
  86867. * to you under the Apache License, Version 2.0 (the
  86868. * "License"); you may not use this file except in compliance
  86869. * with the License. You may obtain a copy of the License at
  86870. *
  86871. * http://www.apache.org/licenses/LICENSE-2.0
  86872. *
  86873. * Unless required by applicable law or agreed to in writing,
  86874. * software distributed under the License is distributed on an
  86875. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86876. * KIND, either express or implied. See the License for the
  86877. * specific language governing permissions and limitations
  86878. * under the License.
  86879. */
  86880. /**
  86881. * AUTO-GENERATED FILE. DO NOT MODIFY.
  86882. */
  86883. /*
  86884. * Licensed to the Apache Software Foundation (ASF) under one
  86885. * or more contributor license agreements. See the NOTICE file
  86886. * distributed with this work for additional information
  86887. * regarding copyright ownership. The ASF licenses this file
  86888. * to you under the Apache License, Version 2.0 (the
  86889. * "License"); you may not use this file except in compliance
  86890. * with the License. You may obtain a copy of the License at
  86891. *
  86892. * http://www.apache.org/licenses/LICENSE-2.0
  86893. *
  86894. * Unless required by applicable law or agreed to in writing,
  86895. * software distributed under the License is distributed on an
  86896. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86897. * KIND, either express or implied. See the License for the
  86898. * specific language governing permissions and limitations
  86899. * under the License.
  86900. */
  86901. function install$40(registers) {
  86902. use(install$41);
  86903. use(install$42); // Do not install './dataZoomSelect',
  86904. // since it only work for toolbox dataZoom.
  86905. }
  86906. /*
  86907. * Licensed to the Apache Software Foundation (ASF) under one
  86908. * or more contributor license agreements. See the NOTICE file
  86909. * distributed with this work for additional information
  86910. * regarding copyright ownership. The ASF licenses this file
  86911. * to you under the Apache License, Version 2.0 (the
  86912. * "License"); you may not use this file except in compliance
  86913. * with the License. You may obtain a copy of the License at
  86914. *
  86915. * http://www.apache.org/licenses/LICENSE-2.0
  86916. *
  86917. * Unless required by applicable law or agreed to in writing,
  86918. * software distributed under the License is distributed on an
  86919. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86920. * KIND, either express or implied. See the License for the
  86921. * specific language governing permissions and limitations
  86922. * under the License.
  86923. */
  86924. /**
  86925. * AUTO-GENERATED FILE. DO NOT MODIFY.
  86926. */
  86927. /*
  86928. * Licensed to the Apache Software Foundation (ASF) under one
  86929. * or more contributor license agreements. See the NOTICE file
  86930. * distributed with this work for additional information
  86931. * regarding copyright ownership. The ASF licenses this file
  86932. * to you under the Apache License, Version 2.0 (the
  86933. * "License"); you may not use this file except in compliance
  86934. * with the License. You may obtain a copy of the License at
  86935. *
  86936. * http://www.apache.org/licenses/LICENSE-2.0
  86937. *
  86938. * Unless required by applicable law or agreed to in writing,
  86939. * software distributed under the License is distributed on an
  86940. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86941. * KIND, either express or implied. See the License for the
  86942. * specific language governing permissions and limitations
  86943. * under the License.
  86944. */
  86945. use(install$40);
  86946. /*
  86947. * Licensed to the Apache Software Foundation (ASF) under one
  86948. * or more contributor license agreements. See the NOTICE file
  86949. * distributed with this work for additional information
  86950. * regarding copyright ownership. The ASF licenses this file
  86951. * to you under the Apache License, Version 2.0 (the
  86952. * "License"); you may not use this file except in compliance
  86953. * with the License. You may obtain a copy of the License at
  86954. *
  86955. * http://www.apache.org/licenses/LICENSE-2.0
  86956. *
  86957. * Unless required by applicable law or agreed to in writing,
  86958. * software distributed under the License is distributed on an
  86959. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86960. * KIND, either express or implied. See the License for the
  86961. * specific language governing permissions and limitations
  86962. * under the License.
  86963. */
  86964. /**
  86965. * AUTO-GENERATED FILE. DO NOT MODIFY.
  86966. */
  86967. /*
  86968. * Licensed to the Apache Software Foundation (ASF) under one
  86969. * or more contributor license agreements. See the NOTICE file
  86970. * distributed with this work for additional information
  86971. * regarding copyright ownership. The ASF licenses this file
  86972. * to you under the Apache License, Version 2.0 (the
  86973. * "License"); you may not use this file except in compliance
  86974. * with the License. You may obtain a copy of the License at
  86975. *
  86976. * http://www.apache.org/licenses/LICENSE-2.0
  86977. *
  86978. * Unless required by applicable law or agreed to in writing,
  86979. * software distributed under the License is distributed on an
  86980. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  86981. * KIND, either express or implied. See the License for the
  86982. * specific language governing permissions and limitations
  86983. * under the License.
  86984. */
  86985. var DEFAULT_TOOLBOX_BTNS = ['rect', 'polygon', 'keep', 'clear'];
  86986. function brushPreprocessor(option, isNew) {
  86987. var brushComponents = normalizeToArray(option ? option.brush : []);
  86988. if (!brushComponents.length) {
  86989. return;
  86990. }
  86991. var brushComponentSpecifiedBtns = [];
  86992. each$1(brushComponents, function (brushOpt) {
  86993. var tbs = brushOpt.hasOwnProperty('toolbox') ? brushOpt.toolbox : [];
  86994. if (tbs instanceof Array) {
  86995. brushComponentSpecifiedBtns = brushComponentSpecifiedBtns.concat(tbs);
  86996. }
  86997. });
  86998. var toolbox = option && option.toolbox;
  86999. if (isArray(toolbox)) {
  87000. toolbox = toolbox[0];
  87001. }
  87002. if (!toolbox) {
  87003. toolbox = {
  87004. feature: {}
  87005. };
  87006. option.toolbox = [toolbox];
  87007. }
  87008. var toolboxFeature = toolbox.feature || (toolbox.feature = {});
  87009. var toolboxBrush = toolboxFeature.brush || (toolboxFeature.brush = {});
  87010. var brushTypes = toolboxBrush.type || (toolboxBrush.type = []);
  87011. brushTypes.push.apply(brushTypes, brushComponentSpecifiedBtns);
  87012. removeDuplicate(brushTypes);
  87013. if (isNew && !brushTypes.length) {
  87014. brushTypes.push.apply(brushTypes, DEFAULT_TOOLBOX_BTNS);
  87015. }
  87016. }
  87017. function removeDuplicate(arr) {
  87018. var map$$1 = {};
  87019. each$1(arr, function (val) {
  87020. map$$1[val] = 1;
  87021. });
  87022. arr.length = 0;
  87023. each$1(map$$1, function (flag, val) {
  87024. arr.push(val);
  87025. });
  87026. }
  87027. /*
  87028. * Licensed to the Apache Software Foundation (ASF) under one
  87029. * or more contributor license agreements. See the NOTICE file
  87030. * distributed with this work for additional information
  87031. * regarding copyright ownership. The ASF licenses this file
  87032. * to you under the Apache License, Version 2.0 (the
  87033. * "License"); you may not use this file except in compliance
  87034. * with the License. You may obtain a copy of the License at
  87035. *
  87036. * http://www.apache.org/licenses/LICENSE-2.0
  87037. *
  87038. * Unless required by applicable law or agreed to in writing,
  87039. * software distributed under the License is distributed on an
  87040. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87041. * KIND, either express or implied. See the License for the
  87042. * specific language governing permissions and limitations
  87043. * under the License.
  87044. */
  87045. /**
  87046. * AUTO-GENERATED FILE. DO NOT MODIFY.
  87047. */
  87048. /*
  87049. * Licensed to the Apache Software Foundation (ASF) under one
  87050. * or more contributor license agreements. See the NOTICE file
  87051. * distributed with this work for additional information
  87052. * regarding copyright ownership. The ASF licenses this file
  87053. * to you under the Apache License, Version 2.0 (the
  87054. * "License"); you may not use this file except in compliance
  87055. * with the License. You may obtain a copy of the License at
  87056. *
  87057. * http://www.apache.org/licenses/LICENSE-2.0
  87058. *
  87059. * Unless required by applicable law or agreed to in writing,
  87060. * software distributed under the License is distributed on an
  87061. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87062. * KIND, either express or implied. See the License for the
  87063. * specific language governing permissions and limitations
  87064. * under the License.
  87065. */
  87066. /**
  87067. * @file Visual solution, for consistent option specification.
  87068. */
  87069. var each$12 = each$1;
  87070. function hasKeys(obj) {
  87071. if (obj) {
  87072. for (var name_1 in obj) {
  87073. if (obj.hasOwnProperty(name_1)) {
  87074. return true;
  87075. }
  87076. }
  87077. }
  87078. }
  87079. function createVisualMappings(option, stateList, supplementVisualOption) {
  87080. var visualMappings = {};
  87081. each$12(stateList, function (state) {
  87082. var mappings = visualMappings[state] = createMappings();
  87083. each$12(option[state], function (visualData, visualType) {
  87084. if (!VisualMapping.isValidType(visualType)) {
  87085. return;
  87086. }
  87087. var mappingOption = {
  87088. type: visualType,
  87089. visual: visualData
  87090. };
  87091. supplementVisualOption && supplementVisualOption(mappingOption, state);
  87092. mappings[visualType] = new VisualMapping(mappingOption); // Prepare a alpha for opacity, for some case that opacity
  87093. // is not supported, such as rendering using gradient color.
  87094. if (visualType === 'opacity') {
  87095. mappingOption = clone(mappingOption);
  87096. mappingOption.type = 'colorAlpha';
  87097. mappings.__hidden.__alphaForOpacity = new VisualMapping(mappingOption);
  87098. }
  87099. });
  87100. });
  87101. return visualMappings;
  87102. function createMappings() {
  87103. var Creater = function () {}; // Make sure hidden fields will not be visited by
  87104. // object iteration (with hasOwnProperty checking).
  87105. Creater.prototype.__hidden = Creater.prototype;
  87106. var obj = new Creater();
  87107. return obj;
  87108. }
  87109. }
  87110. function replaceVisualOption(thisOption, newOption, keys$$1) {
  87111. // Visual attributes merge is not supported, otherwise it
  87112. // brings overcomplicated merge logic. See #2853. So if
  87113. // newOption has anyone of these keys, all of these keys
  87114. // will be reset. Otherwise, all keys remain.
  87115. var has;
  87116. each$1(keys$$1, function (key) {
  87117. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  87118. has = true;
  87119. }
  87120. });
  87121. has && each$1(keys$$1, function (key) {
  87122. if (newOption.hasOwnProperty(key) && hasKeys(newOption[key])) {
  87123. thisOption[key] = clone(newOption[key]);
  87124. } else {
  87125. delete thisOption[key];
  87126. }
  87127. });
  87128. }
  87129. /**
  87130. * @param stateList
  87131. * @param visualMappings
  87132. * @param list
  87133. * @param getValueState param: valueOrIndex, return: state.
  87134. * @param scope Scope for getValueState
  87135. * @param dimension Concrete dimension, if used.
  87136. */
  87137. // ???! handle brush?
  87138. function applyVisual(stateList, visualMappings, data, getValueState, scope, dimension) {
  87139. var visualTypesMap = {};
  87140. each$1(stateList, function (state) {
  87141. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  87142. visualTypesMap[state] = visualTypes;
  87143. });
  87144. var dataIndex;
  87145. function getVisual(key) {
  87146. return getItemVisualFromData(data, dataIndex, key);
  87147. }
  87148. function setVisual(key, value) {
  87149. setItemVisualFromData(data, dataIndex, key, value);
  87150. }
  87151. if (dimension == null) {
  87152. data.each(eachItem);
  87153. } else {
  87154. data.each([dimension], eachItem);
  87155. }
  87156. function eachItem(valueOrIndex, index) {
  87157. dataIndex = dimension == null ? valueOrIndex // First argument is index
  87158. : index;
  87159. var rawDataItem = data.getRawDataItem(dataIndex); // Consider performance
  87160. // @ts-ignore
  87161. if (rawDataItem && rawDataItem.visualMap === false) {
  87162. return;
  87163. }
  87164. var valueState = getValueState.call(scope, valueOrIndex);
  87165. var mappings = visualMappings[valueState];
  87166. var visualTypes = visualTypesMap[valueState];
  87167. for (var i = 0, len = visualTypes.length; i < len; i++) {
  87168. var type = visualTypes[i];
  87169. mappings[type] && mappings[type].applyVisual(valueOrIndex, getVisual, setVisual);
  87170. }
  87171. }
  87172. }
  87173. /**
  87174. * @param data
  87175. * @param stateList
  87176. * @param visualMappings <state, Object.<visualType, module:echarts/visual/VisualMapping>>
  87177. * @param getValueState param: valueOrIndex, return: state.
  87178. * @param dim dimension or dimension index.
  87179. */
  87180. function incrementalApplyVisual(stateList, visualMappings, getValueState, dim) {
  87181. var visualTypesMap = {};
  87182. each$1(stateList, function (state) {
  87183. var visualTypes = VisualMapping.prepareVisualTypes(visualMappings[state]);
  87184. visualTypesMap[state] = visualTypes;
  87185. });
  87186. return {
  87187. progress: function progress(params, data) {
  87188. var dimName;
  87189. if (dim != null) {
  87190. dimName = data.getDimension(dim);
  87191. }
  87192. function getVisual(key) {
  87193. return getItemVisualFromData(data, dataIndex, key);
  87194. }
  87195. function setVisual(key, value) {
  87196. setItemVisualFromData(data, dataIndex, key, value);
  87197. }
  87198. var dataIndex;
  87199. while ((dataIndex = params.next()) != null) {
  87200. var rawDataItem = data.getRawDataItem(dataIndex); // Consider performance
  87201. // @ts-ignore
  87202. if (rawDataItem && rawDataItem.visualMap === false) {
  87203. continue;
  87204. }
  87205. var value = dim != null ? data.get(dimName, dataIndex) : dataIndex;
  87206. var valueState = getValueState(value);
  87207. var mappings = visualMappings[valueState];
  87208. var visualTypes = visualTypesMap[valueState];
  87209. for (var i = 0, len = visualTypes.length; i < len; i++) {
  87210. var type = visualTypes[i];
  87211. mappings[type] && mappings[type].applyVisual(value, getVisual, setVisual);
  87212. }
  87213. }
  87214. }
  87215. };
  87216. }
  87217. /*
  87218. * Licensed to the Apache Software Foundation (ASF) under one
  87219. * or more contributor license agreements. See the NOTICE file
  87220. * distributed with this work for additional information
  87221. * regarding copyright ownership. The ASF licenses this file
  87222. * to you under the Apache License, Version 2.0 (the
  87223. * "License"); you may not use this file except in compliance
  87224. * with the License. You may obtain a copy of the License at
  87225. *
  87226. * http://www.apache.org/licenses/LICENSE-2.0
  87227. *
  87228. * Unless required by applicable law or agreed to in writing,
  87229. * software distributed under the License is distributed on an
  87230. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87231. * KIND, either express or implied. See the License for the
  87232. * specific language governing permissions and limitations
  87233. * under the License.
  87234. */
  87235. /**
  87236. * AUTO-GENERATED FILE. DO NOT MODIFY.
  87237. */
  87238. /*
  87239. * Licensed to the Apache Software Foundation (ASF) under one
  87240. * or more contributor license agreements. See the NOTICE file
  87241. * distributed with this work for additional information
  87242. * regarding copyright ownership. The ASF licenses this file
  87243. * to you under the Apache License, Version 2.0 (the
  87244. * "License"); you may not use this file except in compliance
  87245. * with the License. You may obtain a copy of the License at
  87246. *
  87247. * http://www.apache.org/licenses/LICENSE-2.0
  87248. *
  87249. * Unless required by applicable law or agreed to in writing,
  87250. * software distributed under the License is distributed on an
  87251. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87252. * KIND, either express or implied. See the License for the
  87253. * specific language governing permissions and limitations
  87254. * under the License.
  87255. */
  87256. function makeBrushCommonSelectorForSeries(area) {
  87257. var brushType = area.brushType; // Do not use function binding or curry for performance.
  87258. var selectors = {
  87259. point: function (itemLayout) {
  87260. return selector[brushType].point(itemLayout, selectors, area);
  87261. },
  87262. rect: function (itemLayout) {
  87263. return selector[brushType].rect(itemLayout, selectors, area);
  87264. }
  87265. };
  87266. return selectors;
  87267. }
  87268. var selector = {
  87269. lineX: getLineSelectors(0),
  87270. lineY: getLineSelectors(1),
  87271. rect: {
  87272. point: function (itemLayout, selectors, area) {
  87273. return itemLayout && area.boundingRect.contain(itemLayout[0], itemLayout[1]);
  87274. },
  87275. rect: function (itemLayout, selectors, area) {
  87276. return itemLayout && area.boundingRect.intersect(itemLayout);
  87277. }
  87278. },
  87279. polygon: {
  87280. point: function (itemLayout, selectors, area) {
  87281. return itemLayout && area.boundingRect.contain(itemLayout[0], itemLayout[1]) && contain$1(area.range, itemLayout[0], itemLayout[1]);
  87282. },
  87283. rect: function (itemLayout, selectors, area) {
  87284. var points = area.range;
  87285. if (!itemLayout || points.length <= 1) {
  87286. return false;
  87287. }
  87288. var x = itemLayout.x;
  87289. var y = itemLayout.y;
  87290. var width = itemLayout.width;
  87291. var height = itemLayout.height;
  87292. var p = points[0];
  87293. if (contain$1(points, x, y) || contain$1(points, x + width, y) || contain$1(points, x, y + height) || contain$1(points, x + width, y + height) || BoundingRect.create(itemLayout).contain(p[0], p[1]) || linePolygonIntersect(x, y, x + width, y, points) || linePolygonIntersect(x, y, x, y + height, points) || linePolygonIntersect(x + width, y, x + width, y + height, points) || linePolygonIntersect(x, y + height, x + width, y + height, points)) {
  87294. return true;
  87295. }
  87296. }
  87297. }
  87298. };
  87299. function getLineSelectors(xyIndex) {
  87300. var xy = ['x', 'y'];
  87301. var wh = ['width', 'height'];
  87302. return {
  87303. point: function (itemLayout, selectors, area) {
  87304. if (itemLayout) {
  87305. var range = area.range;
  87306. var p = itemLayout[xyIndex];
  87307. return inLineRange(p, range);
  87308. }
  87309. },
  87310. rect: function (itemLayout, selectors, area) {
  87311. if (itemLayout) {
  87312. var range = area.range;
  87313. var layoutRange = [itemLayout[xy[xyIndex]], itemLayout[xy[xyIndex]] + itemLayout[wh[xyIndex]]];
  87314. layoutRange[1] < layoutRange[0] && layoutRange.reverse();
  87315. return inLineRange(layoutRange[0], range) || inLineRange(layoutRange[1], range) || inLineRange(range[0], layoutRange) || inLineRange(range[1], layoutRange);
  87316. }
  87317. }
  87318. };
  87319. }
  87320. function inLineRange(p, range) {
  87321. return range[0] <= p && p <= range[1];
  87322. }
  87323. /*
  87324. * Licensed to the Apache Software Foundation (ASF) under one
  87325. * or more contributor license agreements. See the NOTICE file
  87326. * distributed with this work for additional information
  87327. * regarding copyright ownership. The ASF licenses this file
  87328. * to you under the Apache License, Version 2.0 (the
  87329. * "License"); you may not use this file except in compliance
  87330. * with the License. You may obtain a copy of the License at
  87331. *
  87332. * http://www.apache.org/licenses/LICENSE-2.0
  87333. *
  87334. * Unless required by applicable law or agreed to in writing,
  87335. * software distributed under the License is distributed on an
  87336. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87337. * KIND, either express or implied. See the License for the
  87338. * specific language governing permissions and limitations
  87339. * under the License.
  87340. */
  87341. /**
  87342. * AUTO-GENERATED FILE. DO NOT MODIFY.
  87343. */
  87344. /*
  87345. * Licensed to the Apache Software Foundation (ASF) under one
  87346. * or more contributor license agreements. See the NOTICE file
  87347. * distributed with this work for additional information
  87348. * regarding copyright ownership. The ASF licenses this file
  87349. * to you under the Apache License, Version 2.0 (the
  87350. * "License"); you may not use this file except in compliance
  87351. * with the License. You may obtain a copy of the License at
  87352. *
  87353. * http://www.apache.org/licenses/LICENSE-2.0
  87354. *
  87355. * Unless required by applicable law or agreed to in writing,
  87356. * software distributed under the License is distributed on an
  87357. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87358. * KIND, either express or implied. See the License for the
  87359. * specific language governing permissions and limitations
  87360. * under the License.
  87361. */
  87362. var COORD_CONVERTS = ['dataToPoint', 'pointToData']; // FIXME
  87363. // how to genarialize to more coordinate systems.
  87364. var INCLUDE_FINDER_MAIN_TYPES = ['grid', 'xAxis', 'yAxis', 'geo', 'graph', 'polar', 'radiusAxis', 'angleAxis', 'bmap'];
  87365. var BrushTargetManager =
  87366. /** @class */
  87367. function () {
  87368. /**
  87369. * @param finder contains Index/Id/Name of xAxis/yAxis/geo/grid
  87370. * Each can be {number|Array.<number>}. like: {xAxisIndex: [3, 4]}
  87371. * @param opt.include include coordinate system types.
  87372. */
  87373. function BrushTargetManager(finder, ecModel, opt) {
  87374. var _this = this;
  87375. this._targetInfoList = [];
  87376. var foundCpts = parseFinder$1(ecModel, finder);
  87377. each$1(targetInfoBuilders, function (builder, type) {
  87378. if (!opt || !opt.include || indexOf$1(opt.include, type) >= 0) {
  87379. builder(foundCpts, _this._targetInfoList);
  87380. }
  87381. });
  87382. }
  87383. BrushTargetManager.prototype.setOutputRanges = function (areas, ecModel) {
  87384. this.matchOutputRanges(areas, ecModel, function (area, coordRange, coordSys) {
  87385. (area.coordRanges || (area.coordRanges = [])).push(coordRange); // area.coordRange is the first of area.coordRanges
  87386. if (!area.coordRange) {
  87387. area.coordRange = coordRange; // In 'category' axis, coord to pixel is not reversible, so we can not
  87388. // rebuild range by coordRange accrately, which may bring trouble when
  87389. // brushing only one item. So we use __rangeOffset to rebuilding range
  87390. // by coordRange. And this it only used in brush component so it is no
  87391. // need to be adapted to coordRanges.
  87392. var result = coordConvert[area.brushType](0, coordSys, coordRange);
  87393. area.__rangeOffset = {
  87394. offset: diffProcessor[area.brushType](result.values, area.range, [1, 1]),
  87395. xyMinMax: result.xyMinMax
  87396. };
  87397. }
  87398. });
  87399. return areas;
  87400. };
  87401. BrushTargetManager.prototype.matchOutputRanges = function (areas, ecModel, cb) {
  87402. each$1(areas, function (area) {
  87403. var targetInfo = this.findTargetInfo(area, ecModel);
  87404. if (targetInfo && targetInfo !== true) {
  87405. each$1(targetInfo.coordSyses, function (coordSys) {
  87406. var result = coordConvert[area.brushType](1, coordSys, area.range);
  87407. cb(area, result.values, coordSys, ecModel);
  87408. });
  87409. }
  87410. }, this);
  87411. };
  87412. /**
  87413. * the `areas` is `BrushModel.areas`.
  87414. * Called in layout stage.
  87415. * convert `area.coordRange` to global range and set panelId to `area.range`.
  87416. */
  87417. BrushTargetManager.prototype.setInputRanges = function (areas, ecModel) {
  87418. each$1(areas, function (area) {
  87419. var targetInfo = this.findTargetInfo(area, ecModel);
  87420. {
  87421. assert$1(!targetInfo || targetInfo === true || area.coordRange, 'coordRange must be specified when coord index specified.');
  87422. assert$1(!targetInfo || targetInfo !== true || area.range, 'range must be specified in global brush.');
  87423. }
  87424. area.range = area.range || []; // convert coordRange to global range and set panelId.
  87425. if (targetInfo && targetInfo !== true) {
  87426. area.panelId = targetInfo.panelId; // (1) area.range shoule always be calculate from coordRange but does
  87427. // not keep its original value, for the sake of the dataZoom scenario,
  87428. // where area.coordRange remains unchanged but area.range may be changed.
  87429. // (2) Only support converting one coordRange to pixel range in brush
  87430. // component. So do not consider `coordRanges`.
  87431. // (3) About __rangeOffset, see comment above.
  87432. var result = coordConvert[area.brushType](0, targetInfo.coordSys, area.coordRange);
  87433. var rangeOffset = area.__rangeOffset;
  87434. area.range = rangeOffset ? diffProcessor[area.brushType](result.values, rangeOffset.offset, getScales(result.xyMinMax, rangeOffset.xyMinMax)) : result.values;
  87435. }
  87436. }, this);
  87437. };
  87438. BrushTargetManager.prototype.makePanelOpts = function (api, getDefaultBrushType) {
  87439. return map(this._targetInfoList, function (targetInfo) {
  87440. var rect = targetInfo.getPanelRect();
  87441. return {
  87442. panelId: targetInfo.panelId,
  87443. defaultBrushType: getDefaultBrushType ? getDefaultBrushType(targetInfo) : null,
  87444. clipPath: makeRectPanelClipPath(rect),
  87445. isTargetByCursor: makeRectIsTargetByCursor(rect, api, targetInfo.coordSysModel),
  87446. getLinearBrushOtherExtent: makeLinearBrushOtherExtent(rect)
  87447. };
  87448. });
  87449. };
  87450. BrushTargetManager.prototype.controlSeries = function (area, seriesModel, ecModel) {
  87451. // Check whether area is bound in coord, and series do not belong to that coord.
  87452. // If do not do this check, some brush (like lineX) will controll all axes.
  87453. var targetInfo = this.findTargetInfo(area, ecModel);
  87454. return targetInfo === true || targetInfo && indexOf$1(targetInfo.coordSyses, seriesModel.coordinateSystem) >= 0;
  87455. };
  87456. /**
  87457. * If return Object, a coord found.
  87458. * If reutrn true, global found.
  87459. * Otherwise nothing found.
  87460. */
  87461. BrushTargetManager.prototype.findTargetInfo = function (area, ecModel) {
  87462. var targetInfoList = this._targetInfoList;
  87463. var foundCpts = parseFinder$1(ecModel, area);
  87464. for (var i = 0; i < targetInfoList.length; i++) {
  87465. var targetInfo = targetInfoList[i];
  87466. var areaPanelId = area.panelId;
  87467. if (areaPanelId) {
  87468. if (targetInfo.panelId === areaPanelId) {
  87469. return targetInfo;
  87470. }
  87471. } else {
  87472. for (var j = 0; j < targetInfoMatchers.length; j++) {
  87473. if (targetInfoMatchers[j](foundCpts, targetInfo)) {
  87474. return targetInfo;
  87475. }
  87476. }
  87477. }
  87478. }
  87479. return true;
  87480. };
  87481. return BrushTargetManager;
  87482. }();
  87483. function formatMinMax(minMax) {
  87484. minMax[0] > minMax[1] && minMax.reverse();
  87485. return minMax;
  87486. }
  87487. function parseFinder$1(ecModel, finder) {
  87488. return parseFinder(ecModel, finder, {
  87489. includeMainTypes: INCLUDE_FINDER_MAIN_TYPES
  87490. });
  87491. }
  87492. var targetInfoBuilders = {
  87493. grid: function (foundCpts, targetInfoList) {
  87494. var xAxisModels = foundCpts.xAxisModels;
  87495. var yAxisModels = foundCpts.yAxisModels;
  87496. var gridModels = foundCpts.gridModels; // Remove duplicated.
  87497. var gridModelMap = createHashMap();
  87498. var xAxesHas = {};
  87499. var yAxesHas = {};
  87500. if (!xAxisModels && !yAxisModels && !gridModels) {
  87501. return;
  87502. }
  87503. each$1(xAxisModels, function (axisModel) {
  87504. var gridModel = axisModel.axis.grid.model;
  87505. gridModelMap.set(gridModel.id, gridModel);
  87506. xAxesHas[gridModel.id] = true;
  87507. });
  87508. each$1(yAxisModels, function (axisModel) {
  87509. var gridModel = axisModel.axis.grid.model;
  87510. gridModelMap.set(gridModel.id, gridModel);
  87511. yAxesHas[gridModel.id] = true;
  87512. });
  87513. each$1(gridModels, function (gridModel) {
  87514. gridModelMap.set(gridModel.id, gridModel);
  87515. xAxesHas[gridModel.id] = true;
  87516. yAxesHas[gridModel.id] = true;
  87517. });
  87518. gridModelMap.each(function (gridModel) {
  87519. var grid = gridModel.coordinateSystem;
  87520. var cartesians = [];
  87521. each$1(grid.getCartesians(), function (cartesian, index) {
  87522. if (indexOf$1(xAxisModels, cartesian.getAxis('x').model) >= 0 || indexOf$1(yAxisModels, cartesian.getAxis('y').model) >= 0) {
  87523. cartesians.push(cartesian);
  87524. }
  87525. });
  87526. targetInfoList.push({
  87527. panelId: 'grid--' + gridModel.id,
  87528. gridModel: gridModel,
  87529. coordSysModel: gridModel,
  87530. // Use the first one as the representitive coordSys.
  87531. coordSys: cartesians[0],
  87532. coordSyses: cartesians,
  87533. getPanelRect: panelRectBuilders.grid,
  87534. xAxisDeclared: xAxesHas[gridModel.id],
  87535. yAxisDeclared: yAxesHas[gridModel.id]
  87536. });
  87537. });
  87538. },
  87539. geo: function (foundCpts, targetInfoList) {
  87540. each$1(foundCpts.geoModels, function (geoModel) {
  87541. var coordSys = geoModel.coordinateSystem;
  87542. targetInfoList.push({
  87543. panelId: 'geo--' + geoModel.id,
  87544. geoModel: geoModel,
  87545. coordSysModel: geoModel,
  87546. coordSys: coordSys,
  87547. coordSyses: [coordSys],
  87548. getPanelRect: panelRectBuilders.geo
  87549. });
  87550. });
  87551. }
  87552. };
  87553. var targetInfoMatchers = [// grid
  87554. function (foundCpts, targetInfo) {
  87555. var xAxisModel = foundCpts.xAxisModel;
  87556. var yAxisModel = foundCpts.yAxisModel;
  87557. var gridModel = foundCpts.gridModel;
  87558. !gridModel && xAxisModel && (gridModel = xAxisModel.axis.grid.model);
  87559. !gridModel && yAxisModel && (gridModel = yAxisModel.axis.grid.model);
  87560. return gridModel && gridModel === targetInfo.gridModel;
  87561. }, // geo
  87562. function (foundCpts, targetInfo) {
  87563. var geoModel = foundCpts.geoModel;
  87564. return geoModel && geoModel === targetInfo.geoModel;
  87565. }];
  87566. var panelRectBuilders = {
  87567. grid: function () {
  87568. // grid is not Transformable.
  87569. return this.coordSys.master.getRect().clone();
  87570. },
  87571. geo: function () {
  87572. var coordSys = this.coordSys;
  87573. var rect = coordSys.getBoundingRect().clone(); // geo roam and zoom transform
  87574. rect.applyTransform(getTransform(coordSys));
  87575. return rect;
  87576. }
  87577. };
  87578. var coordConvert = {
  87579. lineX: curry(axisConvert, 0),
  87580. lineY: curry(axisConvert, 1),
  87581. rect: function (to, coordSys, rangeOrCoordRange) {
  87582. var xminymin = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]]);
  87583. var xmaxymax = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]]);
  87584. var values = [formatMinMax([xminymin[0], xmaxymax[0]]), formatMinMax([xminymin[1], xmaxymax[1]])];
  87585. return {
  87586. values: values,
  87587. xyMinMax: values
  87588. };
  87589. },
  87590. polygon: function (to, coordSys, rangeOrCoordRange) {
  87591. var xyMinMax = [[Infinity, -Infinity], [Infinity, -Infinity]];
  87592. var values = map(rangeOrCoordRange, function (item) {
  87593. var p = coordSys[COORD_CONVERTS[to]](item);
  87594. xyMinMax[0][0] = Math.min(xyMinMax[0][0], p[0]);
  87595. xyMinMax[1][0] = Math.min(xyMinMax[1][0], p[1]);
  87596. xyMinMax[0][1] = Math.max(xyMinMax[0][1], p[0]);
  87597. xyMinMax[1][1] = Math.max(xyMinMax[1][1], p[1]);
  87598. return p;
  87599. });
  87600. return {
  87601. values: values,
  87602. xyMinMax: xyMinMax
  87603. };
  87604. }
  87605. };
  87606. function axisConvert(axisNameIndex, to, coordSys, rangeOrCoordRange) {
  87607. {
  87608. assert$1(coordSys.type === 'cartesian2d', 'lineX/lineY brush is available only in cartesian2d.');
  87609. }
  87610. var axis = coordSys.getAxis(['x', 'y'][axisNameIndex]);
  87611. var values = formatMinMax(map([0, 1], function (i) {
  87612. return to ? axis.coordToData(axis.toLocalCoord(rangeOrCoordRange[i])) : axis.toGlobalCoord(axis.dataToCoord(rangeOrCoordRange[i]));
  87613. }));
  87614. var xyMinMax = [];
  87615. xyMinMax[axisNameIndex] = values;
  87616. xyMinMax[1 - axisNameIndex] = [NaN, NaN];
  87617. return {
  87618. values: values,
  87619. xyMinMax: xyMinMax
  87620. };
  87621. }
  87622. var diffProcessor = {
  87623. lineX: curry(axisDiffProcessor, 0),
  87624. lineY: curry(axisDiffProcessor, 1),
  87625. rect: function (values, refer, scales) {
  87626. return [[values[0][0] - scales[0] * refer[0][0], values[0][1] - scales[0] * refer[0][1]], [values[1][0] - scales[1] * refer[1][0], values[1][1] - scales[1] * refer[1][1]]];
  87627. },
  87628. polygon: function (values, refer, scales) {
  87629. return map(values, function (item, idx) {
  87630. return [item[0] - scales[0] * refer[idx][0], item[1] - scales[1] * refer[idx][1]];
  87631. });
  87632. }
  87633. };
  87634. function axisDiffProcessor(axisNameIndex, values, refer, scales) {
  87635. return [values[0] - scales[axisNameIndex] * refer[0], values[1] - scales[axisNameIndex] * refer[1]];
  87636. } // We have to process scale caused by dataZoom manually,
  87637. // although it might be not accurate.
  87638. // Return [0~1, 0~1]
  87639. function getScales(xyMinMaxCurr, xyMinMaxOrigin) {
  87640. var sizeCurr = getSize(xyMinMaxCurr);
  87641. var sizeOrigin = getSize(xyMinMaxOrigin);
  87642. var scales = [sizeCurr[0] / sizeOrigin[0], sizeCurr[1] / sizeOrigin[1]];
  87643. isNaN(scales[0]) && (scales[0] = 1);
  87644. isNaN(scales[1]) && (scales[1] = 1);
  87645. return scales;
  87646. }
  87647. function getSize(xyMinMax) {
  87648. return xyMinMax ? [xyMinMax[0][1] - xyMinMax[0][0], xyMinMax[1][1] - xyMinMax[1][0]] : [NaN, NaN];
  87649. }
  87650. /*
  87651. * Licensed to the Apache Software Foundation (ASF) under one
  87652. * or more contributor license agreements. See the NOTICE file
  87653. * distributed with this work for additional information
  87654. * regarding copyright ownership. The ASF licenses this file
  87655. * to you under the Apache License, Version 2.0 (the
  87656. * "License"); you may not use this file except in compliance
  87657. * with the License. You may obtain a copy of the License at
  87658. *
  87659. * http://www.apache.org/licenses/LICENSE-2.0
  87660. *
  87661. * Unless required by applicable law or agreed to in writing,
  87662. * software distributed under the License is distributed on an
  87663. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87664. * KIND, either express or implied. See the License for the
  87665. * specific language governing permissions and limitations
  87666. * under the License.
  87667. */
  87668. /**
  87669. * AUTO-GENERATED FILE. DO NOT MODIFY.
  87670. */
  87671. /*
  87672. * Licensed to the Apache Software Foundation (ASF) under one
  87673. * or more contributor license agreements. See the NOTICE file
  87674. * distributed with this work for additional information
  87675. * regarding copyright ownership. The ASF licenses this file
  87676. * to you under the Apache License, Version 2.0 (the
  87677. * "License"); you may not use this file except in compliance
  87678. * with the License. You may obtain a copy of the License at
  87679. *
  87680. * http://www.apache.org/licenses/LICENSE-2.0
  87681. *
  87682. * Unless required by applicable law or agreed to in writing,
  87683. * software distributed under the License is distributed on an
  87684. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87685. * KIND, either express or implied. See the License for the
  87686. * specific language governing permissions and limitations
  87687. * under the License.
  87688. */
  87689. var STATE_LIST = ['inBrush', 'outOfBrush'];
  87690. var DISPATCH_METHOD = '__ecBrushSelect';
  87691. var DISPATCH_FLAG = '__ecInBrushSelectEvent';
  87692. function layoutCovers(ecModel) {
  87693. ecModel.eachComponent({
  87694. mainType: 'brush'
  87695. }, function (brushModel) {
  87696. var brushTargetManager = brushModel.brushTargetManager = new BrushTargetManager(brushModel.option, ecModel);
  87697. brushTargetManager.setInputRanges(brushModel.areas, ecModel);
  87698. });
  87699. }
  87700. /**
  87701. * Register the visual encoding if this modules required.
  87702. */
  87703. function brushVisual(ecModel, api, payload) {
  87704. var brushSelected = [];
  87705. var throttleType;
  87706. var throttleDelay;
  87707. ecModel.eachComponent({
  87708. mainType: 'brush'
  87709. }, function (brushModel) {
  87710. payload && payload.type === 'takeGlobalCursor' && brushModel.setBrushOption(payload.key === 'brush' ? payload.brushOption : {
  87711. brushType: false
  87712. });
  87713. });
  87714. layoutCovers(ecModel);
  87715. ecModel.eachComponent({
  87716. mainType: 'brush'
  87717. }, function (brushModel, brushIndex) {
  87718. var thisBrushSelected = {
  87719. brushId: brushModel.id,
  87720. brushIndex: brushIndex,
  87721. brushName: brushModel.name,
  87722. areas: clone(brushModel.areas),
  87723. selected: []
  87724. }; // Every brush component exists in event params, convenient
  87725. // for user to find by index.
  87726. brushSelected.push(thisBrushSelected);
  87727. var brushOption = brushModel.option;
  87728. var brushLink = brushOption.brushLink;
  87729. var linkedSeriesMap = [];
  87730. var selectedDataIndexForLink = [];
  87731. var rangeInfoBySeries = [];
  87732. var hasBrushExists = false;
  87733. if (!brushIndex) {
  87734. // Only the first throttle setting works.
  87735. throttleType = brushOption.throttleType;
  87736. throttleDelay = brushOption.throttleDelay;
  87737. } // Add boundingRect and selectors to range.
  87738. var areas = map(brushModel.areas, function (area) {
  87739. var builder = boundingRectBuilders[area.brushType];
  87740. var selectableArea = defaults({
  87741. boundingRect: builder ? builder(area) : void 0
  87742. }, area);
  87743. selectableArea.selectors = makeBrushCommonSelectorForSeries(selectableArea);
  87744. return selectableArea;
  87745. });
  87746. var visualMappings = createVisualMappings(brushModel.option, STATE_LIST, function (mappingOption) {
  87747. mappingOption.mappingMethod = 'fixed';
  87748. });
  87749. isArray(brushLink) && each$1(brushLink, function (seriesIndex) {
  87750. linkedSeriesMap[seriesIndex] = 1;
  87751. });
  87752. function linkOthers(seriesIndex) {
  87753. return brushLink === 'all' || !!linkedSeriesMap[seriesIndex];
  87754. } // If no supported brush or no brush on the series,
  87755. // all visuals should be in original state.
  87756. function brushed(rangeInfoList) {
  87757. return !!rangeInfoList.length;
  87758. }
  87759. /**
  87760. * Logic for each series: (If the logic has to be modified one day, do it carefully!)
  87761. *
  87762. * ( brushed ┬ && ┬hasBrushExist ┬ && linkOthers ) => StepA: ┬record, ┬ StepB: ┬visualByRecord.
  87763. * !brushed┘ ├hasBrushExist ┤ └nothing,┘ ├visualByRecord.
  87764. * └!hasBrushExist┘ └nothing.
  87765. * ( !brushed && ┬hasBrushExist ┬ && linkOthers ) => StepA: nothing, StepB: ┬visualByRecord.
  87766. * └!hasBrushExist┘ └nothing.
  87767. * ( brushed ┬ && !linkOthers ) => StepA: nothing, StepB: ┬visualByCheck.
  87768. * !brushed┘ └nothing.
  87769. * ( !brushed && !linkOthers ) => StepA: nothing, StepB: nothing.
  87770. */
  87771. // Step A
  87772. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  87773. var rangeInfoList = rangeInfoBySeries[seriesIndex] = [];
  87774. seriesModel.subType === 'parallel' ? stepAParallel(seriesModel, seriesIndex) : stepAOthers(seriesModel, seriesIndex, rangeInfoList);
  87775. });
  87776. function stepAParallel(seriesModel, seriesIndex) {
  87777. var coordSys = seriesModel.coordinateSystem;
  87778. hasBrushExists = hasBrushExists || coordSys.hasAxisBrushed();
  87779. linkOthers(seriesIndex) && coordSys.eachActiveState(seriesModel.getData(), function (activeState, dataIndex) {
  87780. activeState === 'active' && (selectedDataIndexForLink[dataIndex] = 1);
  87781. });
  87782. }
  87783. function stepAOthers(seriesModel, seriesIndex, rangeInfoList) {
  87784. if (!seriesModel.brushSelector || brushModelNotControll(brushModel, seriesIndex)) {
  87785. return;
  87786. }
  87787. each$1(areas, function (area) {
  87788. if (brushModel.brushTargetManager.controlSeries(area, seriesModel, ecModel)) {
  87789. rangeInfoList.push(area);
  87790. }
  87791. hasBrushExists = hasBrushExists || brushed(rangeInfoList);
  87792. });
  87793. if (linkOthers(seriesIndex) && brushed(rangeInfoList)) {
  87794. var data_1 = seriesModel.getData();
  87795. data_1.each(function (dataIndex) {
  87796. if (checkInRange(seriesModel, rangeInfoList, data_1, dataIndex)) {
  87797. selectedDataIndexForLink[dataIndex] = 1;
  87798. }
  87799. });
  87800. }
  87801. } // Step B
  87802. ecModel.eachSeries(function (seriesModel, seriesIndex) {
  87803. var seriesBrushSelected = {
  87804. seriesId: seriesModel.id,
  87805. seriesIndex: seriesIndex,
  87806. seriesName: seriesModel.name,
  87807. dataIndex: []
  87808. }; // Every series exists in event params, convenient
  87809. // for user to find series by seriesIndex.
  87810. thisBrushSelected.selected.push(seriesBrushSelected);
  87811. var rangeInfoList = rangeInfoBySeries[seriesIndex];
  87812. var data = seriesModel.getData();
  87813. var getValueState = linkOthers(seriesIndex) ? function (dataIndex) {
  87814. return selectedDataIndexForLink[dataIndex] ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush') : 'outOfBrush';
  87815. } : function (dataIndex) {
  87816. return checkInRange(seriesModel, rangeInfoList, data, dataIndex) ? (seriesBrushSelected.dataIndex.push(data.getRawIndex(dataIndex)), 'inBrush') : 'outOfBrush';
  87817. }; // If no supported brush or no brush, all visuals are in original state.
  87818. (linkOthers(seriesIndex) ? hasBrushExists : brushed(rangeInfoList)) && applyVisual(STATE_LIST, visualMappings, data, getValueState);
  87819. });
  87820. });
  87821. dispatchAction$1(api, throttleType, throttleDelay, brushSelected, payload);
  87822. }
  87823. function dispatchAction$1(api, throttleType, throttleDelay, brushSelected, payload) {
  87824. // This event will not be triggered when `setOpion`, otherwise dead lock may
  87825. // triggered when do `setOption` in event listener, which we do not find
  87826. // satisfactory way to solve yet. Some considered resolutions:
  87827. // (a) Diff with prevoius selected data ant only trigger event when changed.
  87828. // But store previous data and diff precisely (i.e., not only by dataIndex, but
  87829. // also detect value changes in selected data) might bring complexity or fragility.
  87830. // (b) Use spectial param like `silent` to suppress event triggering.
  87831. // But such kind of volatile param may be weird in `setOption`.
  87832. if (!payload) {
  87833. return;
  87834. }
  87835. var zr = api.getZr();
  87836. if (zr[DISPATCH_FLAG]) {
  87837. return;
  87838. }
  87839. if (!zr[DISPATCH_METHOD]) {
  87840. zr[DISPATCH_METHOD] = doDispatch;
  87841. }
  87842. var fn = createOrUpdate(zr, DISPATCH_METHOD, throttleDelay, throttleType);
  87843. fn(api, brushSelected);
  87844. }
  87845. function doDispatch(api, brushSelected) {
  87846. if (!api.isDisposed()) {
  87847. var zr = api.getZr();
  87848. zr[DISPATCH_FLAG] = true;
  87849. api.dispatchAction({
  87850. type: 'brushSelect',
  87851. batch: brushSelected
  87852. });
  87853. zr[DISPATCH_FLAG] = false;
  87854. }
  87855. }
  87856. function checkInRange(seriesModel, rangeInfoList, data, dataIndex) {
  87857. for (var i = 0, len = rangeInfoList.length; i < len; i++) {
  87858. var area = rangeInfoList[i];
  87859. if (seriesModel.brushSelector(dataIndex, data, area.selectors, area)) {
  87860. return true;
  87861. }
  87862. }
  87863. }
  87864. function brushModelNotControll(brushModel, seriesIndex) {
  87865. var seriesIndices = brushModel.option.seriesIndex;
  87866. return seriesIndices != null && seriesIndices !== 'all' && (isArray(seriesIndices) ? indexOf$1(seriesIndices, seriesIndex) < 0 : seriesIndex !== seriesIndices);
  87867. }
  87868. var boundingRectBuilders = {
  87869. rect: function (area) {
  87870. return getBoundingRectFromMinMax(area.range);
  87871. },
  87872. polygon: function (area) {
  87873. var minMax;
  87874. var range = area.range;
  87875. for (var i = 0, len = range.length; i < len; i++) {
  87876. minMax = minMax || [[Infinity, -Infinity], [Infinity, -Infinity]];
  87877. var rg = range[i];
  87878. rg[0] < minMax[0][0] && (minMax[0][0] = rg[0]);
  87879. rg[0] > minMax[0][1] && (minMax[0][1] = rg[0]);
  87880. rg[1] < minMax[1][0] && (minMax[1][0] = rg[1]);
  87881. rg[1] > minMax[1][1] && (minMax[1][1] = rg[1]);
  87882. }
  87883. return minMax && getBoundingRectFromMinMax(minMax);
  87884. }
  87885. };
  87886. function getBoundingRectFromMinMax(minMax) {
  87887. return new BoundingRect(minMax[0][0], minMax[1][0], minMax[0][1] - minMax[0][0], minMax[1][1] - minMax[1][0]);
  87888. }
  87889. /*
  87890. * Licensed to the Apache Software Foundation (ASF) under one
  87891. * or more contributor license agreements. See the NOTICE file
  87892. * distributed with this work for additional information
  87893. * regarding copyright ownership. The ASF licenses this file
  87894. * to you under the Apache License, Version 2.0 (the
  87895. * "License"); you may not use this file except in compliance
  87896. * with the License. You may obtain a copy of the License at
  87897. *
  87898. * http://www.apache.org/licenses/LICENSE-2.0
  87899. *
  87900. * Unless required by applicable law or agreed to in writing,
  87901. * software distributed under the License is distributed on an
  87902. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87903. * KIND, either express or implied. See the License for the
  87904. * specific language governing permissions and limitations
  87905. * under the License.
  87906. */
  87907. /**
  87908. * AUTO-GENERATED FILE. DO NOT MODIFY.
  87909. */
  87910. /*
  87911. * Licensed to the Apache Software Foundation (ASF) under one
  87912. * or more contributor license agreements. See the NOTICE file
  87913. * distributed with this work for additional information
  87914. * regarding copyright ownership. The ASF licenses this file
  87915. * to you under the Apache License, Version 2.0 (the
  87916. * "License"); you may not use this file except in compliance
  87917. * with the License. You may obtain a copy of the License at
  87918. *
  87919. * http://www.apache.org/licenses/LICENSE-2.0
  87920. *
  87921. * Unless required by applicable law or agreed to in writing,
  87922. * software distributed under the License is distributed on an
  87923. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  87924. * KIND, either express or implied. See the License for the
  87925. * specific language governing permissions and limitations
  87926. * under the License.
  87927. */
  87928. var BrushView =
  87929. /** @class */
  87930. function (_super) {
  87931. __extends(BrushView, _super);
  87932. function BrushView() {
  87933. var _this = _super !== null && _super.apply(this, arguments) || this;
  87934. _this.type = BrushView.type;
  87935. return _this;
  87936. }
  87937. BrushView.prototype.init = function (ecModel, api) {
  87938. this.ecModel = ecModel;
  87939. this.api = api;
  87940. this.model;
  87941. (this._brushController = new BrushController(api.getZr())).on('brush', bind(this._onBrush, this)).mount();
  87942. };
  87943. BrushView.prototype.render = function (brushModel, ecModel, api, payload) {
  87944. this.model = brushModel;
  87945. this._updateController(brushModel, ecModel, api, payload);
  87946. };
  87947. BrushView.prototype.updateTransform = function (brushModel, ecModel, api, payload) {
  87948. // PENDING: `updateTransform` is a little tricky, whose layout need
  87949. // to be calculate mandatorily and other stages will not be performed.
  87950. // Take care the correctness of the logic. See #11754 .
  87951. layoutCovers(ecModel);
  87952. this._updateController(brushModel, ecModel, api, payload);
  87953. };
  87954. BrushView.prototype.updateVisual = function (brushModel, ecModel, api, payload) {
  87955. this.updateTransform(brushModel, ecModel, api, payload);
  87956. };
  87957. BrushView.prototype.updateView = function (brushModel, ecModel, api, payload) {
  87958. this._updateController(brushModel, ecModel, api, payload);
  87959. };
  87960. BrushView.prototype._updateController = function (brushModel, ecModel, api, payload) {
  87961. // Do not update controller when drawing.
  87962. (!payload || payload.$from !== brushModel.id) && this._brushController.setPanels(brushModel.brushTargetManager.makePanelOpts(api)).enableBrush(brushModel.brushOption).updateCovers(brushModel.areas.slice());
  87963. }; // updateLayout: updateController,
  87964. // updateVisual: updateController,
  87965. BrushView.prototype.dispose = function () {
  87966. this._brushController.dispose();
  87967. };
  87968. BrushView.prototype._onBrush = function (eventParam) {
  87969. var modelId = this.model.id;
  87970. var areas = this.model.brushTargetManager.setOutputRanges(eventParam.areas, this.ecModel); // Action is not dispatched on drag end, because the drag end
  87971. // emits the same params with the last drag move event, and
  87972. // may have some delay when using touch pad, which makes
  87973. // animation not smooth (when using debounce).
  87974. (!eventParam.isEnd || eventParam.removeOnClick) && this.api.dispatchAction({
  87975. type: 'brush',
  87976. brushId: modelId,
  87977. areas: clone(areas),
  87978. $from: modelId
  87979. });
  87980. eventParam.isEnd && this.api.dispatchAction({
  87981. type: 'brushEnd',
  87982. brushId: modelId,
  87983. areas: clone(areas),
  87984. $from: modelId
  87985. });
  87986. };
  87987. BrushView.type = 'brush';
  87988. return BrushView;
  87989. }(ComponentView);
  87990. /*
  87991. * Licensed to the Apache Software Foundation (ASF) under one
  87992. * or more contributor license agreements. See the NOTICE file
  87993. * distributed with this work for additional information
  87994. * regarding copyright ownership. The ASF licenses this file
  87995. * to you under the Apache License, Version 2.0 (the
  87996. * "License"); you may not use this file except in compliance
  87997. * with the License. You may obtain a copy of the License at
  87998. *
  87999. * http://www.apache.org/licenses/LICENSE-2.0
  88000. *
  88001. * Unless required by applicable law or agreed to in writing,
  88002. * software distributed under the License is distributed on an
  88003. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88004. * KIND, either express or implied. See the License for the
  88005. * specific language governing permissions and limitations
  88006. * under the License.
  88007. */
  88008. /**
  88009. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88010. */
  88011. /*
  88012. * Licensed to the Apache Software Foundation (ASF) under one
  88013. * or more contributor license agreements. See the NOTICE file
  88014. * distributed with this work for additional information
  88015. * regarding copyright ownership. The ASF licenses this file
  88016. * to you under the Apache License, Version 2.0 (the
  88017. * "License"); you may not use this file except in compliance
  88018. * with the License. You may obtain a copy of the License at
  88019. *
  88020. * http://www.apache.org/licenses/LICENSE-2.0
  88021. *
  88022. * Unless required by applicable law or agreed to in writing,
  88023. * software distributed under the License is distributed on an
  88024. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88025. * KIND, either express or implied. See the License for the
  88026. * specific language governing permissions and limitations
  88027. * under the License.
  88028. */
  88029. var DEFAULT_OUT_OF_BRUSH_COLOR = '#ddd';
  88030. var BrushModel =
  88031. /** @class */
  88032. function (_super) {
  88033. __extends(BrushModel, _super);
  88034. function BrushModel() {
  88035. var _this = _super !== null && _super.apply(this, arguments) || this;
  88036. _this.type = BrushModel.type;
  88037. /**
  88038. * @readOnly
  88039. */
  88040. _this.areas = [];
  88041. /**
  88042. * Current brush painting area settings.
  88043. * @readOnly
  88044. */
  88045. _this.brushOption = {};
  88046. return _this;
  88047. }
  88048. BrushModel.prototype.optionUpdated = function (newOption, isInit) {
  88049. var thisOption = this.option;
  88050. !isInit && replaceVisualOption(thisOption, newOption, ['inBrush', 'outOfBrush']);
  88051. var inBrush = thisOption.inBrush = thisOption.inBrush || {}; // Always give default visual, consider setOption at the second time.
  88052. thisOption.outOfBrush = thisOption.outOfBrush || {
  88053. color: DEFAULT_OUT_OF_BRUSH_COLOR
  88054. };
  88055. if (!inBrush.hasOwnProperty('liftZ')) {
  88056. // Bigger than the highlight z lift, otherwise it will
  88057. // be effected by the highlight z when brush.
  88058. inBrush.liftZ = 5;
  88059. }
  88060. };
  88061. /**
  88062. * If `areas` is null/undefined, range state remain.
  88063. */
  88064. BrushModel.prototype.setAreas = function (areas) {
  88065. {
  88066. assert$1(isArray(areas));
  88067. each$1(areas, function (area) {
  88068. assert$1(area.brushType, 'Illegal areas');
  88069. });
  88070. } // If areas is null/undefined, range state remain.
  88071. // This helps user to dispatchAction({type: 'brush'}) with no areas
  88072. // set but just want to get the current brush select info from a `brush` event.
  88073. if (!areas) {
  88074. return;
  88075. }
  88076. this.areas = map(areas, function (area) {
  88077. return generateBrushOption(this.option, area);
  88078. }, this);
  88079. };
  88080. /**
  88081. * Set the current painting brush option.
  88082. */
  88083. BrushModel.prototype.setBrushOption = function (brushOption) {
  88084. this.brushOption = generateBrushOption(this.option, brushOption);
  88085. this.brushType = this.brushOption.brushType;
  88086. };
  88087. BrushModel.type = 'brush';
  88088. BrushModel.dependencies = ['geo', 'grid', 'xAxis', 'yAxis', 'parallel', 'series'];
  88089. BrushModel.defaultOption = {
  88090. seriesIndex: 'all',
  88091. brushType: 'rect',
  88092. brushMode: 'single',
  88093. transformable: true,
  88094. brushStyle: {
  88095. borderWidth: 1,
  88096. color: 'rgba(210,219,238,0.3)',
  88097. borderColor: '#D2DBEE'
  88098. },
  88099. throttleType: 'fixRate',
  88100. throttleDelay: 0,
  88101. removeOnClick: true,
  88102. z: 10000
  88103. };
  88104. return BrushModel;
  88105. }(ComponentModel);
  88106. function generateBrushOption(option, brushOption) {
  88107. return merge({
  88108. brushType: option.brushType,
  88109. brushMode: option.brushMode,
  88110. transformable: option.transformable,
  88111. brushStyle: new Model(option.brushStyle).getItemStyle(),
  88112. removeOnClick: option.removeOnClick,
  88113. z: option.z
  88114. }, brushOption, true);
  88115. }
  88116. /*
  88117. * Licensed to the Apache Software Foundation (ASF) under one
  88118. * or more contributor license agreements. See the NOTICE file
  88119. * distributed with this work for additional information
  88120. * regarding copyright ownership. The ASF licenses this file
  88121. * to you under the Apache License, Version 2.0 (the
  88122. * "License"); you may not use this file except in compliance
  88123. * with the License. You may obtain a copy of the License at
  88124. *
  88125. * http://www.apache.org/licenses/LICENSE-2.0
  88126. *
  88127. * Unless required by applicable law or agreed to in writing,
  88128. * software distributed under the License is distributed on an
  88129. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88130. * KIND, either express or implied. See the License for the
  88131. * specific language governing permissions and limitations
  88132. * under the License.
  88133. */
  88134. /**
  88135. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88136. */
  88137. var ToolboxFeature =
  88138. /** @class */
  88139. function () {
  88140. function ToolboxFeature() {}
  88141. return ToolboxFeature;
  88142. }();
  88143. var features = {};
  88144. function registerFeature(name, ctor) {
  88145. features[name] = ctor;
  88146. }
  88147. function getFeature(name) {
  88148. return features[name];
  88149. }
  88150. /*
  88151. * Licensed to the Apache Software Foundation (ASF) under one
  88152. * or more contributor license agreements. See the NOTICE file
  88153. * distributed with this work for additional information
  88154. * regarding copyright ownership. The ASF licenses this file
  88155. * to you under the Apache License, Version 2.0 (the
  88156. * "License"); you may not use this file except in compliance
  88157. * with the License. You may obtain a copy of the License at
  88158. *
  88159. * http://www.apache.org/licenses/LICENSE-2.0
  88160. *
  88161. * Unless required by applicable law or agreed to in writing,
  88162. * software distributed under the License is distributed on an
  88163. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88164. * KIND, either express or implied. See the License for the
  88165. * specific language governing permissions and limitations
  88166. * under the License.
  88167. */
  88168. /**
  88169. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88170. */
  88171. /*
  88172. * Licensed to the Apache Software Foundation (ASF) under one
  88173. * or more contributor license agreements. See the NOTICE file
  88174. * distributed with this work for additional information
  88175. * regarding copyright ownership. The ASF licenses this file
  88176. * to you under the Apache License, Version 2.0 (the
  88177. * "License"); you may not use this file except in compliance
  88178. * with the License. You may obtain a copy of the License at
  88179. *
  88180. * http://www.apache.org/licenses/LICENSE-2.0
  88181. *
  88182. * Unless required by applicable law or agreed to in writing,
  88183. * software distributed under the License is distributed on an
  88184. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88185. * KIND, either express or implied. See the License for the
  88186. * specific language governing permissions and limitations
  88187. * under the License.
  88188. */
  88189. var ICON_TYPES = ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'];
  88190. var BrushFeature =
  88191. /** @class */
  88192. function (_super) {
  88193. __extends(BrushFeature, _super);
  88194. function BrushFeature() {
  88195. return _super !== null && _super.apply(this, arguments) || this;
  88196. }
  88197. BrushFeature.prototype.render = function (featureModel, ecModel, api) {
  88198. var brushType;
  88199. var brushMode;
  88200. var isBrushed;
  88201. ecModel.eachComponent({
  88202. mainType: 'brush'
  88203. }, function (brushModel) {
  88204. brushType = brushModel.brushType;
  88205. brushMode = brushModel.brushOption.brushMode || 'single';
  88206. isBrushed = isBrushed || !!brushModel.areas.length;
  88207. });
  88208. this._brushType = brushType;
  88209. this._brushMode = brushMode;
  88210. each$1(featureModel.get('type', true), function (type) {
  88211. featureModel.setIconStatus(type, (type === 'keep' ? brushMode === 'multiple' : type === 'clear' ? isBrushed : type === brushType) ? 'emphasis' : 'normal');
  88212. });
  88213. };
  88214. BrushFeature.prototype.updateView = function (featureModel, ecModel, api) {
  88215. this.render(featureModel, ecModel, api);
  88216. };
  88217. BrushFeature.prototype.getIcons = function () {
  88218. var model = this.model;
  88219. var availableIcons = model.get('icon', true);
  88220. var icons = {};
  88221. each$1(model.get('type', true), function (type) {
  88222. if (availableIcons[type]) {
  88223. icons[type] = availableIcons[type];
  88224. }
  88225. });
  88226. return icons;
  88227. };
  88228. BrushFeature.prototype.onclick = function (ecModel, api, type) {
  88229. var brushType = this._brushType;
  88230. var brushMode = this._brushMode;
  88231. if (type === 'clear') {
  88232. // Trigger parallel action firstly
  88233. api.dispatchAction({
  88234. type: 'axisAreaSelect',
  88235. intervals: []
  88236. });
  88237. api.dispatchAction({
  88238. type: 'brush',
  88239. command: 'clear',
  88240. // Clear all areas of all brush components.
  88241. areas: []
  88242. });
  88243. } else {
  88244. api.dispatchAction({
  88245. type: 'takeGlobalCursor',
  88246. key: 'brush',
  88247. brushOption: {
  88248. brushType: type === 'keep' ? brushType : brushType === type ? false : type,
  88249. brushMode: type === 'keep' ? brushMode === 'multiple' ? 'single' : 'multiple' : brushMode
  88250. }
  88251. });
  88252. }
  88253. };
  88254. BrushFeature.getDefaultOption = function (ecModel) {
  88255. var defaultOption = {
  88256. show: true,
  88257. type: ICON_TYPES.slice(),
  88258. icon: {
  88259. /* eslint-disable */
  88260. rect: 'M7.3,34.7 M0.4,10V-0.2h9.8 M89.6,10V-0.2h-9.8 M0.4,60v10.2h9.8 M89.6,60v10.2h-9.8 M12.3,22.4V10.5h13.1 M33.6,10.5h7.8 M49.1,10.5h7.8 M77.5,22.4V10.5h-13 M12.3,31.1v8.2 M77.7,31.1v8.2 M12.3,47.6v11.9h13.1 M33.6,59.5h7.6 M49.1,59.5 h7.7 M77.5,47.6v11.9h-13',
  88261. polygon: 'M55.2,34.9c1.7,0,3.1,1.4,3.1,3.1s-1.4,3.1-3.1,3.1 s-3.1-1.4-3.1-3.1S53.5,34.9,55.2,34.9z M50.4,51c1.7,0,3.1,1.4,3.1,3.1c0,1.7-1.4,3.1-3.1,3.1c-1.7,0-3.1-1.4-3.1-3.1 C47.3,52.4,48.7,51,50.4,51z M55.6,37.1l1.5-7.8 M60.1,13.5l1.6-8.7l-7.8,4 M59,19l-1,5.3 M24,16.1l6.4,4.9l6.4-3.3 M48.5,11.6 l-5.9,3.1 M19.1,12.8L9.7,5.1l1.1,7.7 M13.4,29.8l1,7.3l6.6,1.6 M11.6,18.4l1,6.1 M32.8,41.9 M26.6,40.4 M27.3,40.2l6.1,1.6 M49.9,52.1l-5.6-7.6l-4.9-1.2',
  88262. lineX: 'M15.2,30 M19.7,15.6V1.9H29 M34.8,1.9H40.4 M55.3,15.6V1.9H45.9 M19.7,44.4V58.1H29 M34.8,58.1H40.4 M55.3,44.4 V58.1H45.9 M12.5,20.3l-9.4,9.6l9.6,9.8 M3.1,29.9h16.5 M62.5,20.3l9.4,9.6L62.3,39.7 M71.9,29.9H55.4',
  88263. lineY: 'M38.8,7.7 M52.7,12h13.2v9 M65.9,26.6V32 M52.7,46.3h13.2v-9 M24.9,12H11.8v9 M11.8,26.6V32 M24.9,46.3H11.8v-9 M48.2,5.1l-9.3-9l-9.4,9.2 M38.9-3.9V12 M48.2,53.3l-9.3,9l-9.4-9.2 M38.9,62.3V46.4',
  88264. keep: 'M4,10.5V1h10.3 M20.7,1h6.1 M33,1h6.1 M55.4,10.5V1H45.2 M4,17.3v6.6 M55.6,17.3v6.6 M4,30.5V40h10.3 M20.7,40 h6.1 M33,40h6.1 M55.4,30.5V40H45.2 M21,18.9h62.9v48.6H21V18.9z',
  88265. clear: 'M22,14.7l30.9,31 M52.9,14.7L22,45.7 M4.7,16.8V4.2h13.1 M26,4.2h7.8 M41.6,4.2h7.8 M70.3,16.8V4.2H57.2 M4.7,25.9v8.6 M70.3,25.9v8.6 M4.7,43.2v12.6h13.1 M26,55.8h7.8 M41.6,55.8h7.8 M70.3,43.2v12.6H57.2' // jshint ignore:line
  88266. /* eslint-enable */
  88267. },
  88268. // `rect`, `polygon`, `lineX`, `lineY`, `keep`, `clear`
  88269. title: ecModel.getLocale(['toolbox', 'brush', 'title'])
  88270. };
  88271. return defaultOption;
  88272. };
  88273. return BrushFeature;
  88274. }(ToolboxFeature);
  88275. /*
  88276. * Licensed to the Apache Software Foundation (ASF) under one
  88277. * or more contributor license agreements. See the NOTICE file
  88278. * distributed with this work for additional information
  88279. * regarding copyright ownership. The ASF licenses this file
  88280. * to you under the Apache License, Version 2.0 (the
  88281. * "License"); you may not use this file except in compliance
  88282. * with the License. You may obtain a copy of the License at
  88283. *
  88284. * http://www.apache.org/licenses/LICENSE-2.0
  88285. *
  88286. * Unless required by applicable law or agreed to in writing,
  88287. * software distributed under the License is distributed on an
  88288. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88289. * KIND, either express or implied. See the License for the
  88290. * specific language governing permissions and limitations
  88291. * under the License.
  88292. */
  88293. /**
  88294. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88295. */
  88296. /*
  88297. * Licensed to the Apache Software Foundation (ASF) under one
  88298. * or more contributor license agreements. See the NOTICE file
  88299. * distributed with this work for additional information
  88300. * regarding copyright ownership. The ASF licenses this file
  88301. * to you under the Apache License, Version 2.0 (the
  88302. * "License"); you may not use this file except in compliance
  88303. * with the License. You may obtain a copy of the License at
  88304. *
  88305. * http://www.apache.org/licenses/LICENSE-2.0
  88306. *
  88307. * Unless required by applicable law or agreed to in writing,
  88308. * software distributed under the License is distributed on an
  88309. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88310. * KIND, either express or implied. See the License for the
  88311. * specific language governing permissions and limitations
  88312. * under the License.
  88313. */
  88314. function install$43(registers) {
  88315. registers.registerComponentView(BrushView);
  88316. registers.registerComponentModel(BrushModel);
  88317. registers.registerPreprocessor(brushPreprocessor);
  88318. registers.registerVisual(registers.PRIORITY.VISUAL.BRUSH, brushVisual);
  88319. registers.registerAction({
  88320. type: 'brush',
  88321. event: 'brush',
  88322. update: 'updateVisual'
  88323. }, function (payload, ecModel) {
  88324. ecModel.eachComponent({
  88325. mainType: 'brush',
  88326. query: payload
  88327. }, function (brushModel) {
  88328. brushModel.setAreas(payload.areas);
  88329. });
  88330. });
  88331. /**
  88332. * payload: {
  88333. * brushComponents: [
  88334. * {
  88335. * brushId,
  88336. * brushIndex,
  88337. * brushName,
  88338. * series: [
  88339. * {
  88340. * seriesId,
  88341. * seriesIndex,
  88342. * seriesName,
  88343. * rawIndices: [21, 34, ...]
  88344. * },
  88345. * ...
  88346. * ]
  88347. * },
  88348. * ...
  88349. * ]
  88350. * }
  88351. */
  88352. registers.registerAction({
  88353. type: 'brushSelect',
  88354. event: 'brushSelected',
  88355. update: 'none'
  88356. }, function () {});
  88357. registers.registerAction({
  88358. type: 'brushEnd',
  88359. event: 'brushEnd',
  88360. update: 'none'
  88361. }, function () {});
  88362. registerFeature('brush', BrushFeature);
  88363. }
  88364. /*
  88365. * Licensed to the Apache Software Foundation (ASF) under one
  88366. * or more contributor license agreements. See the NOTICE file
  88367. * distributed with this work for additional information
  88368. * regarding copyright ownership. The ASF licenses this file
  88369. * to you under the Apache License, Version 2.0 (the
  88370. * "License"); you may not use this file except in compliance
  88371. * with the License. You may obtain a copy of the License at
  88372. *
  88373. * http://www.apache.org/licenses/LICENSE-2.0
  88374. *
  88375. * Unless required by applicable law or agreed to in writing,
  88376. * software distributed under the License is distributed on an
  88377. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88378. * KIND, either express or implied. See the License for the
  88379. * specific language governing permissions and limitations
  88380. * under the License.
  88381. */
  88382. /**
  88383. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88384. */
  88385. /*
  88386. * Licensed to the Apache Software Foundation (ASF) under one
  88387. * or more contributor license agreements. See the NOTICE file
  88388. * distributed with this work for additional information
  88389. * regarding copyright ownership. The ASF licenses this file
  88390. * to you under the Apache License, Version 2.0 (the
  88391. * "License"); you may not use this file except in compliance
  88392. * with the License. You may obtain a copy of the License at
  88393. *
  88394. * http://www.apache.org/licenses/LICENSE-2.0
  88395. *
  88396. * Unless required by applicable law or agreed to in writing,
  88397. * software distributed under the License is distributed on an
  88398. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88399. * KIND, either express or implied. See the License for the
  88400. * specific language governing permissions and limitations
  88401. * under the License.
  88402. */
  88403. use(install$43);
  88404. /*
  88405. * Licensed to the Apache Software Foundation (ASF) under one
  88406. * or more contributor license agreements. See the NOTICE file
  88407. * distributed with this work for additional information
  88408. * regarding copyright ownership. The ASF licenses this file
  88409. * to you under the Apache License, Version 2.0 (the
  88410. * "License"); you may not use this file except in compliance
  88411. * with the License. You may obtain a copy of the License at
  88412. *
  88413. * http://www.apache.org/licenses/LICENSE-2.0
  88414. *
  88415. * Unless required by applicable law or agreed to in writing,
  88416. * software distributed under the License is distributed on an
  88417. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88418. * KIND, either express or implied. See the License for the
  88419. * specific language governing permissions and limitations
  88420. * under the License.
  88421. */
  88422. /**
  88423. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88424. */
  88425. /*
  88426. * Licensed to the Apache Software Foundation (ASF) under one
  88427. * or more contributor license agreements. See the NOTICE file
  88428. * distributed with this work for additional information
  88429. * regarding copyright ownership. The ASF licenses this file
  88430. * to you under the Apache License, Version 2.0 (the
  88431. * "License"); you may not use this file except in compliance
  88432. * with the License. You may obtain a copy of the License at
  88433. *
  88434. * http://www.apache.org/licenses/LICENSE-2.0
  88435. *
  88436. * Unless required by applicable law or agreed to in writing,
  88437. * software distributed under the License is distributed on an
  88438. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88439. * KIND, either express or implied. See the License for the
  88440. * specific language governing permissions and limitations
  88441. * under the License.
  88442. */
  88443. /**
  88444. * @file Visual mapping.
  88445. */
  88446. var visualDefault = {
  88447. /**
  88448. * @public
  88449. */
  88450. get: function (visualType, key, isCategory) {
  88451. var value = clone((defaultOption$1[visualType] || {})[key]);
  88452. return isCategory ? isArray(value) ? value[value.length - 1] : value : value;
  88453. }
  88454. };
  88455. var defaultOption$1 = {
  88456. color: {
  88457. active: ['#006edd', '#e0ffff'],
  88458. inactive: ['rgba(0,0,0,0)']
  88459. },
  88460. colorHue: {
  88461. active: [0, 360],
  88462. inactive: [0, 0]
  88463. },
  88464. colorSaturation: {
  88465. active: [0.3, 1],
  88466. inactive: [0, 0]
  88467. },
  88468. colorLightness: {
  88469. active: [0.9, 0.5],
  88470. inactive: [0, 0]
  88471. },
  88472. colorAlpha: {
  88473. active: [0.3, 1],
  88474. inactive: [0, 0]
  88475. },
  88476. opacity: {
  88477. active: [0.3, 1],
  88478. inactive: [0, 0]
  88479. },
  88480. symbol: {
  88481. active: ['circle', 'roundRect', 'diamond'],
  88482. inactive: ['none']
  88483. },
  88484. symbolSize: {
  88485. active: [10, 50],
  88486. inactive: [0, 0]
  88487. }
  88488. };
  88489. /*
  88490. * Licensed to the Apache Software Foundation (ASF) under one
  88491. * or more contributor license agreements. See the NOTICE file
  88492. * distributed with this work for additional information
  88493. * regarding copyright ownership. The ASF licenses this file
  88494. * to you under the Apache License, Version 2.0 (the
  88495. * "License"); you may not use this file except in compliance
  88496. * with the License. You may obtain a copy of the License at
  88497. *
  88498. * http://www.apache.org/licenses/LICENSE-2.0
  88499. *
  88500. * Unless required by applicable law or agreed to in writing,
  88501. * software distributed under the License is distributed on an
  88502. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88503. * KIND, either express or implied. See the License for the
  88504. * specific language governing permissions and limitations
  88505. * under the License.
  88506. */
  88507. /**
  88508. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88509. */
  88510. /*
  88511. * Licensed to the Apache Software Foundation (ASF) under one
  88512. * or more contributor license agreements. See the NOTICE file
  88513. * distributed with this work for additional information
  88514. * regarding copyright ownership. The ASF licenses this file
  88515. * to you under the Apache License, Version 2.0 (the
  88516. * "License"); you may not use this file except in compliance
  88517. * with the License. You may obtain a copy of the License at
  88518. *
  88519. * http://www.apache.org/licenses/LICENSE-2.0
  88520. *
  88521. * Unless required by applicable law or agreed to in writing,
  88522. * software distributed under the License is distributed on an
  88523. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88524. * KIND, either express or implied. See the License for the
  88525. * specific language governing permissions and limitations
  88526. * under the License.
  88527. */
  88528. var mapVisual$1 = VisualMapping.mapVisual;
  88529. var eachVisual = VisualMapping.eachVisual;
  88530. var isArray$1 = isArray;
  88531. var each$13 = each$1;
  88532. var asc$2 = asc;
  88533. var linearMap$1 = linearMap;
  88534. var VisualMapModel =
  88535. /** @class */
  88536. function (_super) {
  88537. __extends(VisualMapModel, _super);
  88538. function VisualMapModel() {
  88539. var _this = _super !== null && _super.apply(this, arguments) || this;
  88540. _this.type = VisualMapModel.type;
  88541. _this.stateList = ['inRange', 'outOfRange'];
  88542. _this.replacableOptionKeys = ['inRange', 'outOfRange', 'target', 'controller', 'color'];
  88543. _this.layoutMode = {
  88544. type: 'box',
  88545. ignoreSize: true
  88546. };
  88547. /**
  88548. * [lowerBound, upperBound]
  88549. */
  88550. _this.dataBound = [-Infinity, Infinity];
  88551. _this.targetVisuals = {};
  88552. _this.controllerVisuals = {};
  88553. return _this;
  88554. }
  88555. VisualMapModel.prototype.init = function (option, parentModel, ecModel) {
  88556. this.mergeDefaultAndTheme(option, ecModel);
  88557. };
  88558. /**
  88559. * @protected
  88560. */
  88561. VisualMapModel.prototype.optionUpdated = function (newOption, isInit) {
  88562. var thisOption = this.option; // FIXME
  88563. // necessary?
  88564. // Disable realtime view update if canvas is not supported.
  88565. if (!env.canvasSupported) {
  88566. thisOption.realtime = false;
  88567. }
  88568. !isInit && replaceVisualOption(thisOption, newOption, this.replacableOptionKeys);
  88569. this.textStyleModel = this.getModel('textStyle');
  88570. this.resetItemSize();
  88571. this.completeVisualOption();
  88572. };
  88573. /**
  88574. * @protected
  88575. */
  88576. VisualMapModel.prototype.resetVisual = function (supplementVisualOption) {
  88577. var stateList = this.stateList;
  88578. supplementVisualOption = bind(supplementVisualOption, this);
  88579. this.controllerVisuals = createVisualMappings(this.option.controller, stateList, supplementVisualOption);
  88580. this.targetVisuals = createVisualMappings(this.option.target, stateList, supplementVisualOption);
  88581. };
  88582. /**
  88583. * @public
  88584. */
  88585. VisualMapModel.prototype.getItemSymbol = function () {
  88586. return null;
  88587. };
  88588. /**
  88589. * @protected
  88590. * @return {Array.<number>} An array of series indices.
  88591. */
  88592. VisualMapModel.prototype.getTargetSeriesIndices = function () {
  88593. var optionSeriesIndex = this.option.seriesIndex;
  88594. var seriesIndices = [];
  88595. if (optionSeriesIndex == null || optionSeriesIndex === 'all') {
  88596. this.ecModel.eachSeries(function (seriesModel, index) {
  88597. seriesIndices.push(index);
  88598. });
  88599. } else {
  88600. seriesIndices = normalizeToArray(optionSeriesIndex);
  88601. }
  88602. return seriesIndices;
  88603. };
  88604. /**
  88605. * @public
  88606. */
  88607. VisualMapModel.prototype.eachTargetSeries = function (callback, context) {
  88608. each$1(this.getTargetSeriesIndices(), function (seriesIndex) {
  88609. var seriesModel = this.ecModel.getSeriesByIndex(seriesIndex);
  88610. if (seriesModel) {
  88611. callback.call(context, seriesModel);
  88612. }
  88613. }, this);
  88614. };
  88615. /**
  88616. * @pubilc
  88617. */
  88618. VisualMapModel.prototype.isTargetSeries = function (seriesModel) {
  88619. var is = false;
  88620. this.eachTargetSeries(function (model) {
  88621. model === seriesModel && (is = true);
  88622. });
  88623. return is;
  88624. };
  88625. /**
  88626. * @example
  88627. * this.formatValueText(someVal); // format single numeric value to text.
  88628. * this.formatValueText(someVal, true); // format single category value to text.
  88629. * this.formatValueText([min, max]); // format numeric min-max to text.
  88630. * this.formatValueText([this.dataBound[0], max]); // using data lower bound.
  88631. * this.formatValueText([min, this.dataBound[1]]); // using data upper bound.
  88632. *
  88633. * @param value Real value, or this.dataBound[0 or 1].
  88634. * @param isCategory Only available when value is number.
  88635. * @param edgeSymbols Open-close symbol when value is interval.
  88636. * @protected
  88637. */
  88638. VisualMapModel.prototype.formatValueText = function (value, isCategory, edgeSymbols) {
  88639. var option = this.option;
  88640. var precision = option.precision;
  88641. var dataBound = this.dataBound;
  88642. var formatter = option.formatter;
  88643. var isMinMax;
  88644. edgeSymbols = edgeSymbols || ['<', '>'];
  88645. if (isArray(value)) {
  88646. value = value.slice();
  88647. isMinMax = true;
  88648. }
  88649. var textValue = isCategory ? value // Value is string when isCategory
  88650. : isMinMax ? [toFixed(value[0]), toFixed(value[1])] : toFixed(value);
  88651. if (isString(formatter)) {
  88652. return formatter.replace('{value}', isMinMax ? textValue[0] : textValue).replace('{value2}', isMinMax ? textValue[1] : textValue);
  88653. } else if (isFunction$1(formatter)) {
  88654. return isMinMax ? formatter(value[0], value[1]) : formatter(value);
  88655. }
  88656. if (isMinMax) {
  88657. if (value[0] === dataBound[0]) {
  88658. return edgeSymbols[0] + ' ' + textValue[1];
  88659. } else if (value[1] === dataBound[1]) {
  88660. return edgeSymbols[1] + ' ' + textValue[0];
  88661. } else {
  88662. return textValue[0] + ' - ' + textValue[1];
  88663. }
  88664. } else {
  88665. // Format single value (includes category case).
  88666. return textValue;
  88667. }
  88668. function toFixed(val) {
  88669. return val === dataBound[0] ? 'min' : val === dataBound[1] ? 'max' : (+val).toFixed(Math.min(precision, 20));
  88670. }
  88671. };
  88672. /**
  88673. * @protected
  88674. */
  88675. VisualMapModel.prototype.resetExtent = function () {
  88676. var thisOption = this.option; // Can not calculate data extent by data here.
  88677. // Because series and data may be modified in processing stage.
  88678. // So we do not support the feature "auto min/max".
  88679. var extent = asc$2([thisOption.min, thisOption.max]);
  88680. this._dataExtent = extent;
  88681. };
  88682. /**
  88683. * Return Concrete dimention. If return null/undefined, no dimension used.
  88684. */
  88685. VisualMapModel.prototype.getDataDimension = function (list) {
  88686. var optDim = this.option.dimension;
  88687. var listDimensions = list.dimensions;
  88688. if (optDim == null && !listDimensions.length) {
  88689. return;
  88690. }
  88691. if (optDim != null) {
  88692. return list.getDimension(optDim);
  88693. }
  88694. var dimNames = list.dimensions;
  88695. for (var i = dimNames.length - 1; i >= 0; i--) {
  88696. var dimName = dimNames[i];
  88697. var dimInfo = list.getDimensionInfo(dimName);
  88698. if (!dimInfo.isCalculationCoord) {
  88699. return dimName;
  88700. }
  88701. }
  88702. };
  88703. VisualMapModel.prototype.getExtent = function () {
  88704. return this._dataExtent.slice();
  88705. };
  88706. VisualMapModel.prototype.completeVisualOption = function () {
  88707. var ecModel = this.ecModel;
  88708. var thisOption = this.option;
  88709. var base = {
  88710. inRange: thisOption.inRange,
  88711. outOfRange: thisOption.outOfRange
  88712. };
  88713. var target = thisOption.target || (thisOption.target = {});
  88714. var controller = thisOption.controller || (thisOption.controller = {});
  88715. merge(target, base); // Do not override
  88716. merge(controller, base); // Do not override
  88717. var isCategory = this.isCategory();
  88718. completeSingle.call(this, target);
  88719. completeSingle.call(this, controller);
  88720. completeInactive.call(this, target, 'inRange', 'outOfRange'); // completeInactive.call(this, target, 'outOfRange', 'inRange');
  88721. completeController.call(this, controller);
  88722. function completeSingle(base) {
  88723. // Compatible with ec2 dataRange.color.
  88724. // The mapping order of dataRange.color is: [high value, ..., low value]
  88725. // whereas inRange.color and outOfRange.color is [low value, ..., high value]
  88726. // Notice: ec2 has no inverse.
  88727. if (isArray$1(thisOption.color) // If there has been inRange: {symbol: ...}, adding color is a mistake.
  88728. // So adding color only when no inRange defined.
  88729. && !base.inRange) {
  88730. base.inRange = {
  88731. color: thisOption.color.slice().reverse()
  88732. };
  88733. } // Compatible with previous logic, always give a defautl color, otherwise
  88734. // simple config with no inRange and outOfRange will not work.
  88735. // Originally we use visualMap.color as the default color, but setOption at
  88736. // the second time the default color will be erased. So we change to use
  88737. // constant DEFAULT_COLOR.
  88738. // If user do not want the default color, set inRange: {color: null}.
  88739. base.inRange = base.inRange || {
  88740. color: ecModel.get('gradientColor')
  88741. };
  88742. }
  88743. function completeInactive(base, stateExist, stateAbsent) {
  88744. var optExist = base[stateExist];
  88745. var optAbsent = base[stateAbsent];
  88746. if (optExist && !optAbsent) {
  88747. optAbsent = base[stateAbsent] = {};
  88748. each$13(optExist, function (visualData, visualType) {
  88749. if (!VisualMapping.isValidType(visualType)) {
  88750. return;
  88751. }
  88752. var defa = visualDefault.get(visualType, 'inactive', isCategory);
  88753. if (defa != null) {
  88754. optAbsent[visualType] = defa; // Compatibable with ec2:
  88755. // Only inactive color to rgba(0,0,0,0) can not
  88756. // make label transparent, so use opacity also.
  88757. if (visualType === 'color' && !optAbsent.hasOwnProperty('opacity') && !optAbsent.hasOwnProperty('colorAlpha')) {
  88758. optAbsent.opacity = [0, 0];
  88759. }
  88760. }
  88761. });
  88762. }
  88763. }
  88764. function completeController(controller) {
  88765. var symbolExists = (controller.inRange || {}).symbol || (controller.outOfRange || {}).symbol;
  88766. var symbolSizeExists = (controller.inRange || {}).symbolSize || (controller.outOfRange || {}).symbolSize;
  88767. var inactiveColor = this.get('inactiveColor');
  88768. var itemSymbol = this.getItemSymbol();
  88769. var defaultSymbol = itemSymbol || 'roundRect';
  88770. each$13(this.stateList, function (state) {
  88771. var itemSize = this.itemSize;
  88772. var visuals = controller[state]; // Set inactive color for controller if no other color
  88773. // attr (like colorAlpha) specified.
  88774. if (!visuals) {
  88775. visuals = controller[state] = {
  88776. color: isCategory ? inactiveColor : [inactiveColor]
  88777. };
  88778. } // Consistent symbol and symbolSize if not specified.
  88779. if (visuals.symbol == null) {
  88780. visuals.symbol = symbolExists && clone(symbolExists) || (isCategory ? defaultSymbol : [defaultSymbol]);
  88781. }
  88782. if (visuals.symbolSize == null) {
  88783. visuals.symbolSize = symbolSizeExists && clone(symbolSizeExists) || (isCategory ? itemSize[0] : [itemSize[0], itemSize[0]]);
  88784. } // Filter none
  88785. visuals.symbol = mapVisual$1(visuals.symbol, function (symbol) {
  88786. return symbol === 'none' ? defaultSymbol : symbol;
  88787. }); // Normalize symbolSize
  88788. var symbolSize = visuals.symbolSize;
  88789. if (symbolSize != null) {
  88790. var max_1 = -Infinity; // symbolSize can be object when categories defined.
  88791. eachVisual(symbolSize, function (value) {
  88792. value > max_1 && (max_1 = value);
  88793. });
  88794. visuals.symbolSize = mapVisual$1(symbolSize, function (value) {
  88795. return linearMap$1(value, [0, max_1], [0, itemSize[0]], true);
  88796. });
  88797. }
  88798. }, this);
  88799. }
  88800. };
  88801. VisualMapModel.prototype.resetItemSize = function () {
  88802. this.itemSize = [parseFloat(this.get('itemWidth')), parseFloat(this.get('itemHeight'))];
  88803. };
  88804. VisualMapModel.prototype.isCategory = function () {
  88805. return !!this.option.categories;
  88806. };
  88807. /**
  88808. * @public
  88809. * @abstract
  88810. */
  88811. VisualMapModel.prototype.setSelected = function (selected) {};
  88812. VisualMapModel.prototype.getSelected = function () {
  88813. return null;
  88814. };
  88815. /**
  88816. * @public
  88817. * @abstract
  88818. */
  88819. VisualMapModel.prototype.getValueState = function (value) {
  88820. return null;
  88821. };
  88822. /**
  88823. * FIXME
  88824. * Do not publish to thirt-part-dev temporarily
  88825. * util the interface is stable. (Should it return
  88826. * a function but not visual meta?)
  88827. *
  88828. * @pubilc
  88829. * @abstract
  88830. * @param getColorVisual
  88831. * params: value, valueState
  88832. * return: color
  88833. * @return {Object} visualMeta
  88834. * should includes {stops, outerColors}
  88835. * outerColor means [colorBeyondMinValue, colorBeyondMaxValue]
  88836. */
  88837. VisualMapModel.prototype.getVisualMeta = function (getColorVisual) {
  88838. return null;
  88839. };
  88840. VisualMapModel.type = 'visualMap';
  88841. VisualMapModel.dependencies = ['series'];
  88842. VisualMapModel.defaultOption = {
  88843. show: true,
  88844. zlevel: 0,
  88845. z: 4,
  88846. seriesIndex: 'all',
  88847. min: 0,
  88848. max: 200,
  88849. left: 0,
  88850. right: null,
  88851. top: null,
  88852. bottom: 0,
  88853. itemWidth: null,
  88854. itemHeight: null,
  88855. inverse: false,
  88856. orient: 'vertical',
  88857. backgroundColor: 'rgba(0,0,0,0)',
  88858. borderColor: '#ccc',
  88859. contentColor: '#5793f3',
  88860. inactiveColor: '#aaa',
  88861. borderWidth: 0,
  88862. padding: 5,
  88863. // 接受数组分别设定上右下左边距,同css
  88864. textGap: 10,
  88865. precision: 0,
  88866. textStyle: {
  88867. color: '#333' // 值域文字颜色
  88868. }
  88869. };
  88870. return VisualMapModel;
  88871. }(ComponentModel);
  88872. /*
  88873. * Licensed to the Apache Software Foundation (ASF) under one
  88874. * or more contributor license agreements. See the NOTICE file
  88875. * distributed with this work for additional information
  88876. * regarding copyright ownership. The ASF licenses this file
  88877. * to you under the Apache License, Version 2.0 (the
  88878. * "License"); you may not use this file except in compliance
  88879. * with the License. You may obtain a copy of the License at
  88880. *
  88881. * http://www.apache.org/licenses/LICENSE-2.0
  88882. *
  88883. * Unless required by applicable law or agreed to in writing,
  88884. * software distributed under the License is distributed on an
  88885. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88886. * KIND, either express or implied. See the License for the
  88887. * specific language governing permissions and limitations
  88888. * under the License.
  88889. */
  88890. /**
  88891. * AUTO-GENERATED FILE. DO NOT MODIFY.
  88892. */
  88893. /*
  88894. * Licensed to the Apache Software Foundation (ASF) under one
  88895. * or more contributor license agreements. See the NOTICE file
  88896. * distributed with this work for additional information
  88897. * regarding copyright ownership. The ASF licenses this file
  88898. * to you under the Apache License, Version 2.0 (the
  88899. * "License"); you may not use this file except in compliance
  88900. * with the License. You may obtain a copy of the License at
  88901. *
  88902. * http://www.apache.org/licenses/LICENSE-2.0
  88903. *
  88904. * Unless required by applicable law or agreed to in writing,
  88905. * software distributed under the License is distributed on an
  88906. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  88907. * KIND, either express or implied. See the License for the
  88908. * specific language governing permissions and limitations
  88909. * under the License.
  88910. */
  88911. var DEFAULT_BAR_BOUND = [20, 140];
  88912. var ContinuousModel =
  88913. /** @class */
  88914. function (_super) {
  88915. __extends(ContinuousModel, _super);
  88916. function ContinuousModel() {
  88917. var _this = _super !== null && _super.apply(this, arguments) || this;
  88918. _this.type = ContinuousModel.type;
  88919. return _this;
  88920. }
  88921. /**
  88922. * @override
  88923. */
  88924. ContinuousModel.prototype.optionUpdated = function (newOption, isInit) {
  88925. _super.prototype.optionUpdated.apply(this, arguments);
  88926. this.resetExtent();
  88927. this.resetVisual(function (mappingOption) {
  88928. mappingOption.mappingMethod = 'linear';
  88929. mappingOption.dataExtent = this.getExtent();
  88930. });
  88931. this._resetRange();
  88932. };
  88933. /**
  88934. * @protected
  88935. * @override
  88936. */
  88937. ContinuousModel.prototype.resetItemSize = function () {
  88938. _super.prototype.resetItemSize.apply(this, arguments);
  88939. var itemSize = this.itemSize;
  88940. (itemSize[0] == null || isNaN(itemSize[0])) && (itemSize[0] = DEFAULT_BAR_BOUND[0]);
  88941. (itemSize[1] == null || isNaN(itemSize[1])) && (itemSize[1] = DEFAULT_BAR_BOUND[1]);
  88942. };
  88943. /**
  88944. * @private
  88945. */
  88946. ContinuousModel.prototype._resetRange = function () {
  88947. var dataExtent = this.getExtent();
  88948. var range = this.option.range;
  88949. if (!range || range.auto) {
  88950. // `range` should always be array (so we dont use other
  88951. // value like 'auto') for user-friend. (consider getOption).
  88952. dataExtent.auto = 1;
  88953. this.option.range = dataExtent;
  88954. } else if (isArray(range)) {
  88955. if (range[0] > range[1]) {
  88956. range.reverse();
  88957. }
  88958. range[0] = Math.max(range[0], dataExtent[0]);
  88959. range[1] = Math.min(range[1], dataExtent[1]);
  88960. }
  88961. };
  88962. /**
  88963. * @protected
  88964. * @override
  88965. */
  88966. ContinuousModel.prototype.completeVisualOption = function () {
  88967. _super.prototype.completeVisualOption.apply(this, arguments);
  88968. each$1(this.stateList, function (state) {
  88969. var symbolSize = this.option.controller[state].symbolSize;
  88970. if (symbolSize && symbolSize[0] !== symbolSize[1]) {
  88971. symbolSize[0] = symbolSize[1] / 3; // For good looking.
  88972. }
  88973. }, this);
  88974. };
  88975. /**
  88976. * @override
  88977. */
  88978. ContinuousModel.prototype.setSelected = function (selected) {
  88979. this.option.range = selected.slice();
  88980. this._resetRange();
  88981. };
  88982. /**
  88983. * @public
  88984. */
  88985. ContinuousModel.prototype.getSelected = function () {
  88986. var dataExtent = this.getExtent();
  88987. var dataInterval = asc((this.get('range') || []).slice()); // Clamp
  88988. dataInterval[0] > dataExtent[1] && (dataInterval[0] = dataExtent[1]);
  88989. dataInterval[1] > dataExtent[1] && (dataInterval[1] = dataExtent[1]);
  88990. dataInterval[0] < dataExtent[0] && (dataInterval[0] = dataExtent[0]);
  88991. dataInterval[1] < dataExtent[0] && (dataInterval[1] = dataExtent[0]);
  88992. return dataInterval;
  88993. };
  88994. /**
  88995. * @override
  88996. */
  88997. ContinuousModel.prototype.getValueState = function (value) {
  88998. var range = this.option.range;
  88999. var dataExtent = this.getExtent(); // When range[0] === dataExtent[0], any value larger than dataExtent[0] maps to 'inRange'.
  89000. // range[1] is processed likewise.
  89001. return (range[0] <= dataExtent[0] || range[0] <= value) && (range[1] >= dataExtent[1] || value <= range[1]) ? 'inRange' : 'outOfRange';
  89002. };
  89003. ContinuousModel.prototype.findTargetDataIndices = function (range) {
  89004. var result = [];
  89005. this.eachTargetSeries(function (seriesModel) {
  89006. var dataIndices = [];
  89007. var data = seriesModel.getData();
  89008. data.each(this.getDataDimension(data), function (value, dataIndex) {
  89009. range[0] <= value && value <= range[1] && dataIndices.push(dataIndex);
  89010. }, this);
  89011. result.push({
  89012. seriesId: seriesModel.id,
  89013. dataIndex: dataIndices
  89014. });
  89015. }, this);
  89016. return result;
  89017. };
  89018. /**
  89019. * @implement
  89020. */
  89021. ContinuousModel.prototype.getVisualMeta = function (getColorVisual) {
  89022. var oVals = getColorStopValues(this, 'outOfRange', this.getExtent());
  89023. var iVals = getColorStopValues(this, 'inRange', this.option.range.slice());
  89024. var stops = [];
  89025. function setStop(value, valueState) {
  89026. stops.push({
  89027. value: value,
  89028. color: getColorVisual(value, valueState)
  89029. });
  89030. } // Format to: outOfRange -- inRange -- outOfRange.
  89031. var iIdx = 0;
  89032. var oIdx = 0;
  89033. var iLen = iVals.length;
  89034. var oLen = oVals.length;
  89035. for (; oIdx < oLen && (!iVals.length || oVals[oIdx] <= iVals[0]); oIdx++) {
  89036. // If oVal[oIdx] === iVals[iIdx], oVal[oIdx] should be ignored.
  89037. if (oVals[oIdx] < iVals[iIdx]) {
  89038. setStop(oVals[oIdx], 'outOfRange');
  89039. }
  89040. }
  89041. for (var first = 1; iIdx < iLen; iIdx++, first = 0) {
  89042. // If range is full, value beyond min, max will be clamped.
  89043. // make a singularity
  89044. first && stops.length && setStop(iVals[iIdx], 'outOfRange');
  89045. setStop(iVals[iIdx], 'inRange');
  89046. }
  89047. for (var first = 1; oIdx < oLen; oIdx++) {
  89048. if (!iVals.length || iVals[iVals.length - 1] < oVals[oIdx]) {
  89049. // make a singularity
  89050. if (first) {
  89051. stops.length && setStop(stops[stops.length - 1].value, 'outOfRange');
  89052. first = 0;
  89053. }
  89054. setStop(oVals[oIdx], 'outOfRange');
  89055. }
  89056. }
  89057. var stopsLen = stops.length;
  89058. return {
  89059. stops: stops,
  89060. outerColors: [stopsLen ? stops[0].color : 'transparent', stopsLen ? stops[stopsLen - 1].color : 'transparent']
  89061. };
  89062. };
  89063. ContinuousModel.type = 'visualMap.continuous';
  89064. ContinuousModel.defaultOption = inheritDefaultOption(VisualMapModel.defaultOption, {
  89065. align: 'auto',
  89066. calculable: false,
  89067. hoverLink: true,
  89068. realtime: true,
  89069. handleIcon: 'path://M-11.39,9.77h0a3.5,3.5,0,0,1-3.5,3.5h-22a3.5,3.5,0,0,1-3.5-3.5h0a3.5,3.5,0,0,1,3.5-3.5h22A3.5,3.5,0,0,1-11.39,9.77Z',
  89070. handleSize: '120%',
  89071. handleStyle: {
  89072. borderColor: '#fff',
  89073. borderWidth: 1
  89074. },
  89075. indicatorIcon: 'circle',
  89076. indicatorSize: '50%',
  89077. indicatorStyle: {
  89078. borderColor: '#fff',
  89079. borderWidth: 2,
  89080. shadowBlur: 2,
  89081. shadowOffsetX: 1,
  89082. shadowOffsetY: 1,
  89083. shadowColor: 'rgba(0,0,0,0.2)'
  89084. } // emphasis: {
  89085. // handleStyle: {
  89086. // shadowBlur: 3,
  89087. // shadowOffsetX: 1,
  89088. // shadowOffsetY: 1,
  89089. // shadowColor: 'rgba(0,0,0,0.2)'
  89090. // }
  89091. // }
  89092. });
  89093. return ContinuousModel;
  89094. }(VisualMapModel);
  89095. function getColorStopValues(visualMapModel, valueState, dataExtent) {
  89096. if (dataExtent[0] === dataExtent[1]) {
  89097. return dataExtent.slice();
  89098. } // When using colorHue mapping, it is not linear color any more.
  89099. // Moreover, canvas gradient seems not to be accurate linear.
  89100. // FIXME
  89101. // Should be arbitrary value 100? or based on pixel size?
  89102. var count = 200;
  89103. var step = (dataExtent[1] - dataExtent[0]) / count;
  89104. var value = dataExtent[0];
  89105. var stopValues = [];
  89106. for (var i = 0; i <= count && value < dataExtent[1]; i++) {
  89107. stopValues.push(value);
  89108. value += step;
  89109. }
  89110. stopValues.push(dataExtent[1]);
  89111. return stopValues;
  89112. }
  89113. /*
  89114. * Licensed to the Apache Software Foundation (ASF) under one
  89115. * or more contributor license agreements. See the NOTICE file
  89116. * distributed with this work for additional information
  89117. * regarding copyright ownership. The ASF licenses this file
  89118. * to you under the Apache License, Version 2.0 (the
  89119. * "License"); you may not use this file except in compliance
  89120. * with the License. You may obtain a copy of the License at
  89121. *
  89122. * http://www.apache.org/licenses/LICENSE-2.0
  89123. *
  89124. * Unless required by applicable law or agreed to in writing,
  89125. * software distributed under the License is distributed on an
  89126. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89127. * KIND, either express or implied. See the License for the
  89128. * specific language governing permissions and limitations
  89129. * under the License.
  89130. */
  89131. /**
  89132. * AUTO-GENERATED FILE. DO NOT MODIFY.
  89133. */
  89134. /*
  89135. * Licensed to the Apache Software Foundation (ASF) under one
  89136. * or more contributor license agreements. See the NOTICE file
  89137. * distributed with this work for additional information
  89138. * regarding copyright ownership. The ASF licenses this file
  89139. * to you under the Apache License, Version 2.0 (the
  89140. * "License"); you may not use this file except in compliance
  89141. * with the License. You may obtain a copy of the License at
  89142. *
  89143. * http://www.apache.org/licenses/LICENSE-2.0
  89144. *
  89145. * Unless required by applicable law or agreed to in writing,
  89146. * software distributed under the License is distributed on an
  89147. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89148. * KIND, either express or implied. See the License for the
  89149. * specific language governing permissions and limitations
  89150. * under the License.
  89151. */
  89152. var VisualMapView =
  89153. /** @class */
  89154. function (_super) {
  89155. __extends(VisualMapView, _super);
  89156. function VisualMapView() {
  89157. var _this = _super !== null && _super.apply(this, arguments) || this;
  89158. _this.type = VisualMapView.type;
  89159. _this.autoPositionValues = {
  89160. left: 1,
  89161. right: 1,
  89162. top: 1,
  89163. bottom: 1
  89164. };
  89165. return _this;
  89166. }
  89167. VisualMapView.prototype.init = function (ecModel, api) {
  89168. this.ecModel = ecModel;
  89169. this.api = api;
  89170. };
  89171. /**
  89172. * @protected
  89173. */
  89174. VisualMapView.prototype.render = function (visualMapModel, ecModel, api, payload // TODO: TYPE
  89175. ) {
  89176. this.visualMapModel = visualMapModel;
  89177. if (visualMapModel.get('show') === false) {
  89178. this.group.removeAll();
  89179. return;
  89180. }
  89181. this.doRender(visualMapModel, ecModel, api, payload);
  89182. };
  89183. /**
  89184. * @protected
  89185. */
  89186. VisualMapView.prototype.renderBackground = function (group) {
  89187. var visualMapModel = this.visualMapModel;
  89188. var padding = normalizeCssArray$1(visualMapModel.get('padding') || 0);
  89189. var rect = group.getBoundingRect();
  89190. group.add(new Rect({
  89191. z2: -1,
  89192. silent: true,
  89193. shape: {
  89194. x: rect.x - padding[3],
  89195. y: rect.y - padding[0],
  89196. width: rect.width + padding[3] + padding[1],
  89197. height: rect.height + padding[0] + padding[2]
  89198. },
  89199. style: {
  89200. fill: visualMapModel.get('backgroundColor'),
  89201. stroke: visualMapModel.get('borderColor'),
  89202. lineWidth: visualMapModel.get('borderWidth')
  89203. }
  89204. }));
  89205. };
  89206. /**
  89207. * @protected
  89208. * @param targetValue can be Infinity or -Infinity
  89209. * @param visualCluster Only can be 'color' 'opacity' 'symbol' 'symbolSize'
  89210. * @param opts
  89211. * @param opts.forceState Specify state, instead of using getValueState method.
  89212. * @param opts.convertOpacityToAlpha For color gradient in controller widget.
  89213. * @return {*} Visual value.
  89214. */
  89215. VisualMapView.prototype.getControllerVisual = function (targetValue, visualCluster, opts) {
  89216. opts = opts || {};
  89217. var forceState = opts.forceState;
  89218. var visualMapModel = this.visualMapModel;
  89219. var visualObj = {}; // Default values.
  89220. if (visualCluster === 'color') {
  89221. var defaultColor = visualMapModel.get('contentColor');
  89222. visualObj.color = defaultColor;
  89223. }
  89224. function getter(key) {
  89225. return visualObj[key];
  89226. }
  89227. function setter(key, value) {
  89228. visualObj[key] = value;
  89229. }
  89230. var mappings = visualMapModel.controllerVisuals[forceState || visualMapModel.getValueState(targetValue)];
  89231. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  89232. each$1(visualTypes, function (type) {
  89233. var visualMapping = mappings[type];
  89234. if (opts.convertOpacityToAlpha && type === 'opacity') {
  89235. type = 'colorAlpha';
  89236. visualMapping = mappings.__alphaForOpacity;
  89237. }
  89238. if (VisualMapping.dependsOn(type, visualCluster)) {
  89239. visualMapping && visualMapping.applyVisual(targetValue, getter, setter);
  89240. }
  89241. });
  89242. return visualObj[visualCluster];
  89243. };
  89244. VisualMapView.prototype.positionGroup = function (group) {
  89245. var model = this.visualMapModel;
  89246. var api = this.api;
  89247. positionElement(group, model.getBoxLayoutParams(), {
  89248. width: api.getWidth(),
  89249. height: api.getHeight()
  89250. });
  89251. };
  89252. VisualMapView.prototype.doRender = function (visualMapModel, ecModel, api, payload) {};
  89253. VisualMapView.type = 'visualMap';
  89254. return VisualMapView;
  89255. }(ComponentView);
  89256. /*
  89257. * Licensed to the Apache Software Foundation (ASF) under one
  89258. * or more contributor license agreements. See the NOTICE file
  89259. * distributed with this work for additional information
  89260. * regarding copyright ownership. The ASF licenses this file
  89261. * to you under the Apache License, Version 2.0 (the
  89262. * "License"); you may not use this file except in compliance
  89263. * with the License. You may obtain a copy of the License at
  89264. *
  89265. * http://www.apache.org/licenses/LICENSE-2.0
  89266. *
  89267. * Unless required by applicable law or agreed to in writing,
  89268. * software distributed under the License is distributed on an
  89269. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89270. * KIND, either express or implied. See the License for the
  89271. * specific language governing permissions and limitations
  89272. * under the License.
  89273. */
  89274. /**
  89275. * AUTO-GENERATED FILE. DO NOT MODIFY.
  89276. */
  89277. /*
  89278. * Licensed to the Apache Software Foundation (ASF) under one
  89279. * or more contributor license agreements. See the NOTICE file
  89280. * distributed with this work for additional information
  89281. * regarding copyright ownership. The ASF licenses this file
  89282. * to you under the Apache License, Version 2.0 (the
  89283. * "License"); you may not use this file except in compliance
  89284. * with the License. You may obtain a copy of the License at
  89285. *
  89286. * http://www.apache.org/licenses/LICENSE-2.0
  89287. *
  89288. * Unless required by applicable law or agreed to in writing,
  89289. * software distributed under the License is distributed on an
  89290. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89291. * KIND, either express or implied. See the License for the
  89292. * specific language governing permissions and limitations
  89293. * under the License.
  89294. */
  89295. var paramsSet = [['left', 'right', 'width'], ['top', 'bottom', 'height']];
  89296. /**
  89297. * @param visualMapModel
  89298. * @param api
  89299. * @param itemSize always [short, long]
  89300. * @return {string} 'left' or 'right' or 'top' or 'bottom'
  89301. */
  89302. function getItemAlign(visualMapModel, api, itemSize) {
  89303. var modelOption = visualMapModel.option;
  89304. var itemAlign = modelOption.align;
  89305. if (itemAlign != null && itemAlign !== 'auto') {
  89306. return itemAlign;
  89307. } // Auto decision align.
  89308. var ecSize = {
  89309. width: api.getWidth(),
  89310. height: api.getHeight()
  89311. };
  89312. var realIndex = modelOption.orient === 'horizontal' ? 1 : 0;
  89313. var reals = paramsSet[realIndex];
  89314. var fakeValue = [0, null, 10];
  89315. var layoutInput = {};
  89316. for (var i = 0; i < 3; i++) {
  89317. layoutInput[paramsSet[1 - realIndex][i]] = fakeValue[i];
  89318. layoutInput[reals[i]] = i === 2 ? itemSize[0] : modelOption[reals[i]];
  89319. }
  89320. var rParam = [['x', 'width', 3], ['y', 'height', 0]][realIndex];
  89321. var rect = getLayoutRect(layoutInput, ecSize, modelOption.padding);
  89322. return reals[(rect.margin[rParam[2]] || 0) + rect[rParam[0]] + rect[rParam[1]] * 0.5 < ecSize[rParam[1]] * 0.5 ? 0 : 1];
  89323. }
  89324. /**
  89325. * Prepare dataIndex for outside usage, where dataIndex means rawIndex, and
  89326. * dataIndexInside means filtered index.
  89327. */
  89328. // TODO: TYPE more specified payload types.
  89329. function makeHighDownBatch(batch, visualMapModel) {
  89330. each$1(batch || [], function (batchItem) {
  89331. if (batchItem.dataIndex != null) {
  89332. batchItem.dataIndexInside = batchItem.dataIndex;
  89333. batchItem.dataIndex = null;
  89334. }
  89335. batchItem.highlightKey = 'visualMap' + (visualMapModel ? visualMapModel.componentIndex : '');
  89336. });
  89337. return batch;
  89338. }
  89339. /*
  89340. * Licensed to the Apache Software Foundation (ASF) under one
  89341. * or more contributor license agreements. See the NOTICE file
  89342. * distributed with this work for additional information
  89343. * regarding copyright ownership. The ASF licenses this file
  89344. * to you under the Apache License, Version 2.0 (the
  89345. * "License"); you may not use this file except in compliance
  89346. * with the License. You may obtain a copy of the License at
  89347. *
  89348. * http://www.apache.org/licenses/LICENSE-2.0
  89349. *
  89350. * Unless required by applicable law or agreed to in writing,
  89351. * software distributed under the License is distributed on an
  89352. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89353. * KIND, either express or implied. See the License for the
  89354. * specific language governing permissions and limitations
  89355. * under the License.
  89356. */
  89357. /**
  89358. * AUTO-GENERATED FILE. DO NOT MODIFY.
  89359. */
  89360. /*
  89361. * Licensed to the Apache Software Foundation (ASF) under one
  89362. * or more contributor license agreements. See the NOTICE file
  89363. * distributed with this work for additional information
  89364. * regarding copyright ownership. The ASF licenses this file
  89365. * to you under the Apache License, Version 2.0 (the
  89366. * "License"); you may not use this file except in compliance
  89367. * with the License. You may obtain a copy of the License at
  89368. *
  89369. * http://www.apache.org/licenses/LICENSE-2.0
  89370. *
  89371. * Unless required by applicable law or agreed to in writing,
  89372. * software distributed under the License is distributed on an
  89373. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89374. * KIND, either express or implied. See the License for the
  89375. * specific language governing permissions and limitations
  89376. * under the License.
  89377. */
  89378. var linearMap$2 = linearMap;
  89379. var each$14 = each$1;
  89380. var mathMin$10 = Math.min;
  89381. var mathMax$10 = Math.max; // Arbitrary value
  89382. var HOVER_LINK_SIZE = 12;
  89383. var HOVER_LINK_OUT = 6; // Notice:
  89384. // Any "interval" should be by the order of [low, high].
  89385. // "handle0" (handleIndex === 0) maps to
  89386. // low data value: this._dataInterval[0] and has low coord.
  89387. // "handle1" (handleIndex === 1) maps to
  89388. // high data value: this._dataInterval[1] and has high coord.
  89389. // The logic of transform is implemented in this._createBarGroup.
  89390. var ContinuousView =
  89391. /** @class */
  89392. function (_super) {
  89393. __extends(ContinuousView, _super);
  89394. function ContinuousView() {
  89395. var _this = _super !== null && _super.apply(this, arguments) || this;
  89396. _this.type = ContinuousView.type;
  89397. _this._shapes = {};
  89398. _this._dataInterval = [];
  89399. _this._handleEnds = [];
  89400. _this._hoverLinkDataIndices = [];
  89401. return _this;
  89402. }
  89403. ContinuousView.prototype.doRender = function (visualMapModel, ecModel, api, payload) {
  89404. this._api = api;
  89405. if (!payload || payload.type !== 'selectDataRange' || payload.from !== this.uid) {
  89406. this._buildView();
  89407. }
  89408. };
  89409. ContinuousView.prototype._buildView = function () {
  89410. this.group.removeAll();
  89411. var visualMapModel = this.visualMapModel;
  89412. var thisGroup = this.group;
  89413. this._orient = visualMapModel.get('orient');
  89414. this._useHandle = visualMapModel.get('calculable');
  89415. this._resetInterval();
  89416. this._renderBar(thisGroup);
  89417. var dataRangeText = visualMapModel.get('text');
  89418. this._renderEndsText(thisGroup, dataRangeText, 0);
  89419. this._renderEndsText(thisGroup, dataRangeText, 1); // Do this for background size calculation.
  89420. this._updateView(true); // After updating view, inner shapes is built completely,
  89421. // and then background can be rendered.
  89422. this.renderBackground(thisGroup); // Real update view
  89423. this._updateView();
  89424. this._enableHoverLinkToSeries();
  89425. this._enableHoverLinkFromSeries();
  89426. this.positionGroup(thisGroup);
  89427. };
  89428. ContinuousView.prototype._renderEndsText = function (group, dataRangeText, endsIndex) {
  89429. if (!dataRangeText) {
  89430. return;
  89431. } // Compatible with ec2, text[0] map to high value, text[1] map low value.
  89432. var text = dataRangeText[1 - endsIndex];
  89433. text = text != null ? text + '' : '';
  89434. var visualMapModel = this.visualMapModel;
  89435. var textGap = visualMapModel.get('textGap');
  89436. var itemSize = visualMapModel.itemSize;
  89437. var barGroup = this._shapes.mainGroup;
  89438. var position = this._applyTransform([itemSize[0] / 2, endsIndex === 0 ? -textGap : itemSize[1] + textGap], barGroup);
  89439. var align = this._applyTransform(endsIndex === 0 ? 'bottom' : 'top', barGroup);
  89440. var orient = this._orient;
  89441. var textStyleModel = this.visualMapModel.textStyleModel;
  89442. this.group.add(new ZRText({
  89443. style: {
  89444. x: position[0],
  89445. y: position[1],
  89446. verticalAlign: orient === 'horizontal' ? 'middle' : align,
  89447. align: orient === 'horizontal' ? align : 'center',
  89448. text: text,
  89449. font: textStyleModel.getFont(),
  89450. fill: textStyleModel.getTextColor()
  89451. }
  89452. }));
  89453. };
  89454. ContinuousView.prototype._renderBar = function (targetGroup) {
  89455. var visualMapModel = this.visualMapModel;
  89456. var shapes = this._shapes;
  89457. var itemSize = visualMapModel.itemSize;
  89458. var orient = this._orient;
  89459. var useHandle = this._useHandle;
  89460. var itemAlign = getItemAlign(visualMapModel, this.api, itemSize);
  89461. var mainGroup = shapes.mainGroup = this._createBarGroup(itemAlign);
  89462. var gradientBarGroup = new Group();
  89463. mainGroup.add(gradientBarGroup); // Bar
  89464. gradientBarGroup.add(shapes.outOfRange = createPolygon());
  89465. gradientBarGroup.add(shapes.inRange = createPolygon(null, useHandle ? getCursor$1(this._orient) : null, bind(this._dragHandle, this, 'all', false), bind(this._dragHandle, this, 'all', true))); // A border radius clip.
  89466. gradientBarGroup.setClipPath(new Rect({
  89467. shape: {
  89468. x: 0,
  89469. y: 0,
  89470. width: itemSize[0],
  89471. height: itemSize[1],
  89472. r: 3
  89473. }
  89474. }));
  89475. var textRect = visualMapModel.textStyleModel.getTextRect('国');
  89476. var textSize = mathMax$10(textRect.width, textRect.height); // Handle
  89477. if (useHandle) {
  89478. shapes.handleThumbs = [];
  89479. shapes.handleLabels = [];
  89480. shapes.handleLabelPoints = [];
  89481. this._createHandle(visualMapModel, mainGroup, 0, itemSize, textSize, orient);
  89482. this._createHandle(visualMapModel, mainGroup, 1, itemSize, textSize, orient);
  89483. }
  89484. this._createIndicator(visualMapModel, mainGroup, itemSize, textSize, orient);
  89485. targetGroup.add(mainGroup);
  89486. };
  89487. ContinuousView.prototype._createHandle = function (visualMapModel, mainGroup, handleIndex, itemSize, textSize, orient) {
  89488. var onDrift = bind(this._dragHandle, this, handleIndex, false);
  89489. var onDragEnd = bind(this._dragHandle, this, handleIndex, true);
  89490. var handleSize = parsePercent(visualMapModel.get('handleSize'), itemSize[0]);
  89491. var handleThumb = createSymbol(visualMapModel.get('handleIcon'), -handleSize / 2, -handleSize / 2, handleSize, handleSize, null, true);
  89492. var cursor = getCursor$1(this._orient);
  89493. handleThumb.attr({
  89494. cursor: cursor,
  89495. draggable: true,
  89496. drift: onDrift,
  89497. ondragend: onDragEnd,
  89498. onmousemove: function (e) {
  89499. stop(e.event);
  89500. }
  89501. });
  89502. handleThumb.x = itemSize[0] / 2;
  89503. handleThumb.useStyle(visualMapModel.getModel('handleStyle').getItemStyle());
  89504. handleThumb.setStyle({
  89505. strokeNoScale: true,
  89506. strokeFirst: true
  89507. });
  89508. handleThumb.style.lineWidth *= 2;
  89509. handleThumb.ensureState('emphasis').style = visualMapModel.getModel(['emphasis', 'handleStyle']).getItemStyle();
  89510. setAsHighDownDispatcher(handleThumb, true);
  89511. mainGroup.add(handleThumb); // Text is always horizontal layout but should not be effected by
  89512. // transform (orient/inverse). So label is built separately but not
  89513. // use zrender/graphic/helper/RectText, and is located based on view
  89514. // group (according to handleLabelPoint) but not barGroup.
  89515. var textStyleModel = this.visualMapModel.textStyleModel;
  89516. var handleLabel = new ZRText({
  89517. cursor: cursor,
  89518. draggable: true,
  89519. drift: onDrift,
  89520. onmousemove: function (e) {
  89521. // Fot mobile devicem, prevent screen slider on the button.
  89522. stop(e.event);
  89523. },
  89524. ondragend: onDragEnd,
  89525. style: {
  89526. x: 0,
  89527. y: 0,
  89528. text: '',
  89529. font: textStyleModel.getFont(),
  89530. fill: textStyleModel.getTextColor()
  89531. }
  89532. });
  89533. handleLabel.ensureState('blur').style = {
  89534. opacity: 0.1
  89535. };
  89536. handleLabel.stateTransition = {
  89537. duration: 200
  89538. };
  89539. this.group.add(handleLabel);
  89540. var handleLabelPoint = [handleSize, 0];
  89541. var shapes = this._shapes;
  89542. shapes.handleThumbs[handleIndex] = handleThumb;
  89543. shapes.handleLabelPoints[handleIndex] = handleLabelPoint;
  89544. shapes.handleLabels[handleIndex] = handleLabel;
  89545. };
  89546. ContinuousView.prototype._createIndicator = function (visualMapModel, mainGroup, itemSize, textSize, orient) {
  89547. var scale = parsePercent(visualMapModel.get('indicatorSize'), itemSize[0]);
  89548. var indicator = createSymbol(visualMapModel.get('indicatorIcon'), -scale / 2, -scale / 2, scale, scale, null, true);
  89549. indicator.attr({
  89550. cursor: 'move',
  89551. invisible: true,
  89552. silent: true,
  89553. x: itemSize[0] / 2
  89554. });
  89555. var indicatorStyle = visualMapModel.getModel('indicatorStyle').getItemStyle();
  89556. if (indicator instanceof ZRImage) {
  89557. var pathStyle = indicator.style;
  89558. indicator.useStyle(extend({
  89559. // TODO other properties like x, y ?
  89560. image: pathStyle.image,
  89561. x: pathStyle.x,
  89562. y: pathStyle.y,
  89563. width: pathStyle.width,
  89564. height: pathStyle.height
  89565. }, indicatorStyle));
  89566. } else {
  89567. indicator.useStyle(indicatorStyle);
  89568. }
  89569. mainGroup.add(indicator);
  89570. var textStyleModel = this.visualMapModel.textStyleModel;
  89571. var indicatorLabel = new ZRText({
  89572. silent: true,
  89573. invisible: true,
  89574. style: {
  89575. x: 0,
  89576. y: 0,
  89577. text: '',
  89578. font: textStyleModel.getFont(),
  89579. fill: textStyleModel.getTextColor()
  89580. }
  89581. });
  89582. this.group.add(indicatorLabel);
  89583. var indicatorLabelPoint = [(orient === 'horizontal' ? textSize / 2 : HOVER_LINK_OUT) + itemSize[0] / 2, 0];
  89584. var shapes = this._shapes;
  89585. shapes.indicator = indicator;
  89586. shapes.indicatorLabel = indicatorLabel;
  89587. shapes.indicatorLabelPoint = indicatorLabelPoint;
  89588. this._firstShowIndicator = true;
  89589. };
  89590. ContinuousView.prototype._dragHandle = function (handleIndex, isEnd, // dx is event from ondragend if isEnd is true. It's not used
  89591. dx, dy) {
  89592. if (!this._useHandle) {
  89593. return;
  89594. }
  89595. this._dragging = !isEnd;
  89596. if (!isEnd) {
  89597. // Transform dx, dy to bar coordination.
  89598. var vertex = this._applyTransform([dx, dy], this._shapes.mainGroup, true);
  89599. this._updateInterval(handleIndex, vertex[1]);
  89600. this._hideIndicator(); // Considering realtime, update view should be executed
  89601. // before dispatch action.
  89602. this._updateView();
  89603. } // dragEnd do not dispatch action when realtime.
  89604. if (isEnd === !this.visualMapModel.get('realtime')) {
  89605. // jshint ignore:line
  89606. this.api.dispatchAction({
  89607. type: 'selectDataRange',
  89608. from: this.uid,
  89609. visualMapId: this.visualMapModel.id,
  89610. selected: this._dataInterval.slice()
  89611. });
  89612. }
  89613. if (isEnd) {
  89614. !this._hovering && this._clearHoverLinkToSeries();
  89615. } else if (useHoverLinkOnHandle(this.visualMapModel)) {
  89616. this._doHoverLinkToSeries(this._handleEnds[handleIndex], false);
  89617. }
  89618. };
  89619. ContinuousView.prototype._resetInterval = function () {
  89620. var visualMapModel = this.visualMapModel;
  89621. var dataInterval = this._dataInterval = visualMapModel.getSelected();
  89622. var dataExtent = visualMapModel.getExtent();
  89623. var sizeExtent = [0, visualMapModel.itemSize[1]];
  89624. this._handleEnds = [linearMap$2(dataInterval[0], dataExtent, sizeExtent, true), linearMap$2(dataInterval[1], dataExtent, sizeExtent, true)];
  89625. };
  89626. /**
  89627. * @private
  89628. * @param {(number|string)} handleIndex 0 or 1 or 'all'
  89629. * @param {number} dx
  89630. * @param {number} dy
  89631. */
  89632. ContinuousView.prototype._updateInterval = function (handleIndex, delta) {
  89633. delta = delta || 0;
  89634. var visualMapModel = this.visualMapModel;
  89635. var handleEnds = this._handleEnds;
  89636. var sizeExtent = [0, visualMapModel.itemSize[1]];
  89637. sliderMove(delta, handleEnds, sizeExtent, handleIndex, // cross is forbiden
  89638. 0);
  89639. var dataExtent = visualMapModel.getExtent(); // Update data interval.
  89640. this._dataInterval = [linearMap$2(handleEnds[0], sizeExtent, dataExtent, true), linearMap$2(handleEnds[1], sizeExtent, dataExtent, true)];
  89641. };
  89642. ContinuousView.prototype._updateView = function (forSketch) {
  89643. var visualMapModel = this.visualMapModel;
  89644. var dataExtent = visualMapModel.getExtent();
  89645. var shapes = this._shapes;
  89646. var outOfRangeHandleEnds = [0, visualMapModel.itemSize[1]];
  89647. var inRangeHandleEnds = forSketch ? outOfRangeHandleEnds : this._handleEnds;
  89648. var visualInRange = this._createBarVisual(this._dataInterval, dataExtent, inRangeHandleEnds, 'inRange');
  89649. var visualOutOfRange = this._createBarVisual(dataExtent, dataExtent, outOfRangeHandleEnds, 'outOfRange');
  89650. shapes.inRange.setStyle({
  89651. fill: visualInRange.barColor // opacity: visualInRange.opacity
  89652. }).setShape('points', visualInRange.barPoints);
  89653. shapes.outOfRange.setStyle({
  89654. fill: visualOutOfRange.barColor // opacity: visualOutOfRange.opacity
  89655. }).setShape('points', visualOutOfRange.barPoints);
  89656. this._updateHandle(inRangeHandleEnds, visualInRange);
  89657. };
  89658. ContinuousView.prototype._createBarVisual = function (dataInterval, dataExtent, handleEnds, forceState) {
  89659. var opts = {
  89660. forceState: forceState,
  89661. convertOpacityToAlpha: true
  89662. };
  89663. var colorStops = this._makeColorGradient(dataInterval, opts);
  89664. var symbolSizes = [this.getControllerVisual(dataInterval[0], 'symbolSize', opts), this.getControllerVisual(dataInterval[1], 'symbolSize', opts)];
  89665. var barPoints = this._createBarPoints(handleEnds, symbolSizes);
  89666. return {
  89667. barColor: new LinearGradient(0, 0, 0, 1, colorStops),
  89668. barPoints: barPoints,
  89669. handlesColor: [colorStops[0].color, colorStops[colorStops.length - 1].color]
  89670. };
  89671. };
  89672. ContinuousView.prototype._makeColorGradient = function (dataInterval, opts) {
  89673. // Considering colorHue, which is not linear, so we have to sample
  89674. // to calculate gradient color stops, but not only caculate head
  89675. // and tail.
  89676. var sampleNumber = 100; // Arbitrary value.
  89677. var colorStops = [];
  89678. var step = (dataInterval[1] - dataInterval[0]) / sampleNumber;
  89679. colorStops.push({
  89680. color: this.getControllerVisual(dataInterval[0], 'color', opts),
  89681. offset: 0
  89682. });
  89683. for (var i = 1; i < sampleNumber; i++) {
  89684. var currValue = dataInterval[0] + step * i;
  89685. if (currValue > dataInterval[1]) {
  89686. break;
  89687. }
  89688. colorStops.push({
  89689. color: this.getControllerVisual(currValue, 'color', opts),
  89690. offset: i / sampleNumber
  89691. });
  89692. }
  89693. colorStops.push({
  89694. color: this.getControllerVisual(dataInterval[1], 'color', opts),
  89695. offset: 1
  89696. });
  89697. return colorStops;
  89698. };
  89699. ContinuousView.prototype._createBarPoints = function (handleEnds, symbolSizes) {
  89700. var itemSize = this.visualMapModel.itemSize;
  89701. return [[itemSize[0] - symbolSizes[0], handleEnds[0]], [itemSize[0], handleEnds[0]], [itemSize[0], handleEnds[1]], [itemSize[0] - symbolSizes[1], handleEnds[1]]];
  89702. };
  89703. ContinuousView.prototype._createBarGroup = function (itemAlign) {
  89704. var orient = this._orient;
  89705. var inverse = this.visualMapModel.get('inverse');
  89706. return new Group(orient === 'horizontal' && !inverse ? {
  89707. scaleX: itemAlign === 'bottom' ? 1 : -1,
  89708. rotation: Math.PI / 2
  89709. } : orient === 'horizontal' && inverse ? {
  89710. scaleX: itemAlign === 'bottom' ? -1 : 1,
  89711. rotation: -Math.PI / 2
  89712. } : orient === 'vertical' && !inverse ? {
  89713. scaleX: itemAlign === 'left' ? 1 : -1,
  89714. scaleY: -1
  89715. } : {
  89716. scaleX: itemAlign === 'left' ? 1 : -1
  89717. });
  89718. };
  89719. ContinuousView.prototype._updateHandle = function (handleEnds, visualInRange) {
  89720. if (!this._useHandle) {
  89721. return;
  89722. }
  89723. var shapes = this._shapes;
  89724. var visualMapModel = this.visualMapModel;
  89725. var handleThumbs = shapes.handleThumbs;
  89726. var handleLabels = shapes.handleLabels;
  89727. var itemSize = visualMapModel.itemSize;
  89728. var dataExtent = visualMapModel.getExtent();
  89729. each$14([0, 1], function (handleIndex) {
  89730. var handleThumb = handleThumbs[handleIndex];
  89731. handleThumb.setStyle('fill', visualInRange.handlesColor[handleIndex]);
  89732. handleThumb.y = handleEnds[handleIndex];
  89733. var val = linearMap$2(handleEnds[handleIndex], [0, itemSize[1]], dataExtent, true);
  89734. var symbolSize = this.getControllerVisual(val, 'symbolSize');
  89735. handleThumb.scaleX = handleThumb.scaleY = symbolSize / itemSize[0];
  89736. handleThumb.x = itemSize[0] - symbolSize / 2; // Update handle label position.
  89737. var textPoint = applyTransform$1(shapes.handleLabelPoints[handleIndex], getTransform(handleThumb, this.group));
  89738. handleLabels[handleIndex].setStyle({
  89739. x: textPoint[0],
  89740. y: textPoint[1],
  89741. text: visualMapModel.formatValueText(this._dataInterval[handleIndex]),
  89742. verticalAlign: 'middle',
  89743. align: this._orient === 'vertical' ? this._applyTransform('left', shapes.mainGroup) : 'center'
  89744. });
  89745. }, this);
  89746. };
  89747. ContinuousView.prototype._showIndicator = function (cursorValue, textValue, rangeSymbol, halfHoverLinkSize) {
  89748. var visualMapModel = this.visualMapModel;
  89749. var dataExtent = visualMapModel.getExtent();
  89750. var itemSize = visualMapModel.itemSize;
  89751. var sizeExtent = [0, itemSize[1]];
  89752. var shapes = this._shapes;
  89753. var indicator = shapes.indicator;
  89754. if (!indicator) {
  89755. return;
  89756. }
  89757. indicator.attr('invisible', false);
  89758. var opts = {
  89759. convertOpacityToAlpha: true
  89760. };
  89761. var color = this.getControllerVisual(cursorValue, 'color', opts);
  89762. var symbolSize = this.getControllerVisual(cursorValue, 'symbolSize');
  89763. var y = linearMap$2(cursorValue, dataExtent, sizeExtent, true);
  89764. var x = itemSize[0] - symbolSize / 2;
  89765. var oldIndicatorPos = {
  89766. x: indicator.x,
  89767. y: indicator.y
  89768. }; // Update handle label position.
  89769. indicator.y = y;
  89770. indicator.x = x;
  89771. var textPoint = applyTransform$1(shapes.indicatorLabelPoint, getTransform(indicator, this.group));
  89772. var indicatorLabel = shapes.indicatorLabel;
  89773. indicatorLabel.attr('invisible', false);
  89774. var align = this._applyTransform('left', shapes.mainGroup);
  89775. var orient = this._orient;
  89776. var isHorizontal = orient === 'horizontal';
  89777. indicatorLabel.setStyle({
  89778. text: (rangeSymbol ? rangeSymbol : '') + visualMapModel.formatValueText(textValue),
  89779. verticalAlign: isHorizontal ? align : 'middle',
  89780. align: isHorizontal ? 'center' : align
  89781. });
  89782. var indicatorNewProps = {
  89783. x: x,
  89784. y: y,
  89785. style: {
  89786. fill: color
  89787. }
  89788. };
  89789. var labelNewProps = {
  89790. style: {
  89791. x: textPoint[0],
  89792. y: textPoint[1]
  89793. }
  89794. };
  89795. if (visualMapModel.ecModel.isAnimationEnabled() && !this._firstShowIndicator) {
  89796. var animationCfg = {
  89797. duration: 100,
  89798. easing: 'cubicInOut',
  89799. additive: true
  89800. };
  89801. indicator.x = oldIndicatorPos.x;
  89802. indicator.y = oldIndicatorPos.y;
  89803. indicator.animateTo(indicatorNewProps, animationCfg);
  89804. indicatorLabel.animateTo(labelNewProps, animationCfg);
  89805. } else {
  89806. indicator.attr(indicatorNewProps);
  89807. indicatorLabel.attr(labelNewProps);
  89808. }
  89809. this._firstShowIndicator = false;
  89810. var handleLabels = this._shapes.handleLabels;
  89811. if (handleLabels) {
  89812. for (var i = 0; i < handleLabels.length; i++) {
  89813. // Fade out handle labels.
  89814. // NOTE: Must use api enter/leave on emphasis/blur/select state. Or the global states manager will change it.
  89815. this._api.enterBlur(handleLabels[i]);
  89816. }
  89817. }
  89818. };
  89819. ContinuousView.prototype._enableHoverLinkToSeries = function () {
  89820. var self = this;
  89821. this._shapes.mainGroup.on('mousemove', function (e) {
  89822. self._hovering = true;
  89823. if (!self._dragging) {
  89824. var itemSize = self.visualMapModel.itemSize;
  89825. var pos = self._applyTransform([e.offsetX, e.offsetY], self._shapes.mainGroup, true, true); // For hover link show when hover handle, which might be
  89826. // below or upper than sizeExtent.
  89827. pos[1] = mathMin$10(mathMax$10(0, pos[1]), itemSize[1]);
  89828. self._doHoverLinkToSeries(pos[1], 0 <= pos[0] && pos[0] <= itemSize[0]);
  89829. }
  89830. }).on('mouseout', function () {
  89831. // When mouse is out of handle, hoverLink still need
  89832. // to be displayed when realtime is set as false.
  89833. self._hovering = false;
  89834. !self._dragging && self._clearHoverLinkToSeries();
  89835. });
  89836. };
  89837. ContinuousView.prototype._enableHoverLinkFromSeries = function () {
  89838. var zr = this.api.getZr();
  89839. if (this.visualMapModel.option.hoverLink) {
  89840. zr.on('mouseover', this._hoverLinkFromSeriesMouseOver, this);
  89841. zr.on('mouseout', this._hideIndicator, this);
  89842. } else {
  89843. this._clearHoverLinkFromSeries();
  89844. }
  89845. };
  89846. ContinuousView.prototype._doHoverLinkToSeries = function (cursorPos, hoverOnBar) {
  89847. var visualMapModel = this.visualMapModel;
  89848. var itemSize = visualMapModel.itemSize;
  89849. if (!visualMapModel.option.hoverLink) {
  89850. return;
  89851. }
  89852. var sizeExtent = [0, itemSize[1]];
  89853. var dataExtent = visualMapModel.getExtent(); // For hover link show when hover handle, which might be below or upper than sizeExtent.
  89854. cursorPos = mathMin$10(mathMax$10(sizeExtent[0], cursorPos), sizeExtent[1]);
  89855. var halfHoverLinkSize = getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent);
  89856. var hoverRange = [cursorPos - halfHoverLinkSize, cursorPos + halfHoverLinkSize];
  89857. var cursorValue = linearMap$2(cursorPos, sizeExtent, dataExtent, true);
  89858. var valueRange = [linearMap$2(hoverRange[0], sizeExtent, dataExtent, true), linearMap$2(hoverRange[1], sizeExtent, dataExtent, true)]; // Consider data range is out of visualMap range, see test/visualMap-continuous.html,
  89859. // where china and india has very large population.
  89860. hoverRange[0] < sizeExtent[0] && (valueRange[0] = -Infinity);
  89861. hoverRange[1] > sizeExtent[1] && (valueRange[1] = Infinity); // Do not show indicator when mouse is over handle,
  89862. // otherwise labels overlap, especially when dragging.
  89863. if (hoverOnBar) {
  89864. if (valueRange[0] === -Infinity) {
  89865. this._showIndicator(cursorValue, valueRange[1], '< ', halfHoverLinkSize);
  89866. } else if (valueRange[1] === Infinity) {
  89867. this._showIndicator(cursorValue, valueRange[0], '> ', halfHoverLinkSize);
  89868. } else {
  89869. this._showIndicator(cursorValue, cursorValue, '≈ ', halfHoverLinkSize);
  89870. }
  89871. } // When realtime is set as false, handles, which are in barGroup,
  89872. // also trigger hoverLink, which help user to realize where they
  89873. // focus on when dragging. (see test/heatmap-large.html)
  89874. // When realtime is set as true, highlight will not show when hover
  89875. // handle, because the label on handle, which displays a exact value
  89876. // but not range, might mislead users.
  89877. var oldBatch = this._hoverLinkDataIndices;
  89878. var newBatch = [];
  89879. if (hoverOnBar || useHoverLinkOnHandle(visualMapModel)) {
  89880. newBatch = this._hoverLinkDataIndices = visualMapModel.findTargetDataIndices(valueRange);
  89881. }
  89882. var resultBatches = compressBatches(oldBatch, newBatch);
  89883. this._dispatchHighDown('downplay', makeHighDownBatch(resultBatches[0], visualMapModel));
  89884. this._dispatchHighDown('highlight', makeHighDownBatch(resultBatches[1], visualMapModel));
  89885. };
  89886. ContinuousView.prototype._hoverLinkFromSeriesMouseOver = function (e) {
  89887. var el = e.target;
  89888. var visualMapModel = this.visualMapModel;
  89889. if (!el || getECData(el).dataIndex == null) {
  89890. return;
  89891. }
  89892. var ecData = getECData(el);
  89893. var dataModel = this.ecModel.getSeriesByIndex(ecData.seriesIndex);
  89894. if (!visualMapModel.isTargetSeries(dataModel)) {
  89895. return;
  89896. }
  89897. var data = dataModel.getData(ecData.dataType);
  89898. var value = data.get(visualMapModel.getDataDimension(data), ecData.dataIndex);
  89899. if (!isNaN(value)) {
  89900. this._showIndicator(value, value);
  89901. }
  89902. };
  89903. ContinuousView.prototype._hideIndicator = function () {
  89904. var shapes = this._shapes;
  89905. shapes.indicator && shapes.indicator.attr('invisible', true);
  89906. shapes.indicatorLabel && shapes.indicatorLabel.attr('invisible', true);
  89907. var handleLabels = this._shapes.handleLabels;
  89908. if (handleLabels) {
  89909. for (var i = 0; i < handleLabels.length; i++) {
  89910. // Fade out handle labels.
  89911. // NOTE: Must use api enter/leave on emphasis/blur/select state. Or the global states manager will change it.
  89912. this._api.leaveBlur(handleLabels[i]);
  89913. }
  89914. }
  89915. };
  89916. ContinuousView.prototype._clearHoverLinkToSeries = function () {
  89917. this._hideIndicator();
  89918. var indices = this._hoverLinkDataIndices;
  89919. this._dispatchHighDown('downplay', makeHighDownBatch(indices, this.visualMapModel));
  89920. indices.length = 0;
  89921. };
  89922. ContinuousView.prototype._clearHoverLinkFromSeries = function () {
  89923. this._hideIndicator();
  89924. var zr = this.api.getZr();
  89925. zr.off('mouseover', this._hoverLinkFromSeriesMouseOver);
  89926. zr.off('mouseout', this._hideIndicator);
  89927. };
  89928. ContinuousView.prototype._applyTransform = function (vertex, element, inverse, global) {
  89929. var transform = getTransform(element, global ? null : this.group);
  89930. return isArray(vertex) ? applyTransform$1(vertex, transform, inverse) : transformDirection(vertex, transform, inverse);
  89931. }; // TODO: TYPE more specified payload types.
  89932. ContinuousView.prototype._dispatchHighDown = function (type, batch) {
  89933. batch && batch.length && this.api.dispatchAction({
  89934. type: type,
  89935. batch: batch
  89936. });
  89937. };
  89938. /**
  89939. * @override
  89940. */
  89941. ContinuousView.prototype.dispose = function () {
  89942. this._clearHoverLinkFromSeries();
  89943. this._clearHoverLinkToSeries();
  89944. };
  89945. /**
  89946. * @override
  89947. */
  89948. ContinuousView.prototype.remove = function () {
  89949. this._clearHoverLinkFromSeries();
  89950. this._clearHoverLinkToSeries();
  89951. };
  89952. ContinuousView.type = 'visualMap.continuous';
  89953. return ContinuousView;
  89954. }(VisualMapView);
  89955. function createPolygon(points, cursor, onDrift, onDragEnd) {
  89956. return new Polygon({
  89957. shape: {
  89958. points: points
  89959. },
  89960. draggable: !!onDrift,
  89961. cursor: cursor,
  89962. drift: onDrift,
  89963. onmousemove: function (e) {
  89964. // Fot mobile devicem, prevent screen slider on the button.
  89965. stop(e.event);
  89966. },
  89967. ondragend: onDragEnd
  89968. });
  89969. }
  89970. function getHalfHoverLinkSize(visualMapModel, dataExtent, sizeExtent) {
  89971. var halfHoverLinkSize = HOVER_LINK_SIZE / 2;
  89972. var hoverLinkDataSize = visualMapModel.get('hoverLinkDataSize');
  89973. if (hoverLinkDataSize) {
  89974. halfHoverLinkSize = linearMap$2(hoverLinkDataSize, dataExtent, sizeExtent, true) / 2;
  89975. }
  89976. return halfHoverLinkSize;
  89977. }
  89978. function useHoverLinkOnHandle(visualMapModel) {
  89979. var hoverLinkOnHandle = visualMapModel.get('hoverLinkOnHandle');
  89980. return !!(hoverLinkOnHandle == null ? visualMapModel.get('realtime') : hoverLinkOnHandle);
  89981. }
  89982. function getCursor$1(orient) {
  89983. return orient === 'vertical' ? 'ns-resize' : 'ew-resize';
  89984. }
  89985. /*
  89986. * Licensed to the Apache Software Foundation (ASF) under one
  89987. * or more contributor license agreements. See the NOTICE file
  89988. * distributed with this work for additional information
  89989. * regarding copyright ownership. The ASF licenses this file
  89990. * to you under the Apache License, Version 2.0 (the
  89991. * "License"); you may not use this file except in compliance
  89992. * with the License. You may obtain a copy of the License at
  89993. *
  89994. * http://www.apache.org/licenses/LICENSE-2.0
  89995. *
  89996. * Unless required by applicable law or agreed to in writing,
  89997. * software distributed under the License is distributed on an
  89998. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  89999. * KIND, either express or implied. See the License for the
  90000. * specific language governing permissions and limitations
  90001. * under the License.
  90002. */
  90003. /**
  90004. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90005. */
  90006. /*
  90007. * Licensed to the Apache Software Foundation (ASF) under one
  90008. * or more contributor license agreements. See the NOTICE file
  90009. * distributed with this work for additional information
  90010. * regarding copyright ownership. The ASF licenses this file
  90011. * to you under the Apache License, Version 2.0 (the
  90012. * "License"); you may not use this file except in compliance
  90013. * with the License. You may obtain a copy of the License at
  90014. *
  90015. * http://www.apache.org/licenses/LICENSE-2.0
  90016. *
  90017. * Unless required by applicable law or agreed to in writing,
  90018. * software distributed under the License is distributed on an
  90019. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90020. * KIND, either express or implied. See the License for the
  90021. * specific language governing permissions and limitations
  90022. * under the License.
  90023. */
  90024. var visualMapActionInfo = {
  90025. type: 'selectDataRange',
  90026. event: 'dataRangeSelected',
  90027. // FIXME use updateView appears wrong
  90028. update: 'update'
  90029. };
  90030. var visualMapActionHander = function (payload, ecModel) {
  90031. ecModel.eachComponent({
  90032. mainType: 'visualMap',
  90033. query: payload
  90034. }, function (model) {
  90035. model.setSelected(payload.selected);
  90036. });
  90037. };
  90038. /*
  90039. * Licensed to the Apache Software Foundation (ASF) under one
  90040. * or more contributor license agreements. See the NOTICE file
  90041. * distributed with this work for additional information
  90042. * regarding copyright ownership. The ASF licenses this file
  90043. * to you under the Apache License, Version 2.0 (the
  90044. * "License"); you may not use this file except in compliance
  90045. * with the License. You may obtain a copy of the License at
  90046. *
  90047. * http://www.apache.org/licenses/LICENSE-2.0
  90048. *
  90049. * Unless required by applicable law or agreed to in writing,
  90050. * software distributed under the License is distributed on an
  90051. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90052. * KIND, either express or implied. See the License for the
  90053. * specific language governing permissions and limitations
  90054. * under the License.
  90055. */
  90056. /**
  90057. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90058. */
  90059. /*
  90060. * Licensed to the Apache Software Foundation (ASF) under one
  90061. * or more contributor license agreements. See the NOTICE file
  90062. * distributed with this work for additional information
  90063. * regarding copyright ownership. The ASF licenses this file
  90064. * to you under the Apache License, Version 2.0 (the
  90065. * "License"); you may not use this file except in compliance
  90066. * with the License. You may obtain a copy of the License at
  90067. *
  90068. * http://www.apache.org/licenses/LICENSE-2.0
  90069. *
  90070. * Unless required by applicable law or agreed to in writing,
  90071. * software distributed under the License is distributed on an
  90072. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90073. * KIND, either express or implied. See the License for the
  90074. * specific language governing permissions and limitations
  90075. * under the License.
  90076. */
  90077. var visualMapEncodingHandlers = [{
  90078. createOnAllSeries: true,
  90079. reset: function (seriesModel, ecModel) {
  90080. var resetDefines = [];
  90081. ecModel.eachComponent('visualMap', function (visualMapModel) {
  90082. var pipelineContext = seriesModel.pipelineContext;
  90083. if (!visualMapModel.isTargetSeries(seriesModel) || pipelineContext && pipelineContext.large) {
  90084. return;
  90085. }
  90086. resetDefines.push(incrementalApplyVisual(visualMapModel.stateList, visualMapModel.targetVisuals, bind(visualMapModel.getValueState, visualMapModel), visualMapModel.getDataDimension(seriesModel.getData())));
  90087. });
  90088. return resetDefines;
  90089. }
  90090. }, // Only support color.
  90091. {
  90092. createOnAllSeries: true,
  90093. reset: function (seriesModel, ecModel) {
  90094. var data = seriesModel.getData();
  90095. var visualMetaList = [];
  90096. ecModel.eachComponent('visualMap', function (visualMapModel) {
  90097. if (visualMapModel.isTargetSeries(seriesModel)) {
  90098. var visualMeta = visualMapModel.getVisualMeta(bind(getColorVisual, null, seriesModel, visualMapModel)) || {
  90099. stops: [],
  90100. outerColors: []
  90101. };
  90102. var concreteDim = visualMapModel.getDataDimension(data);
  90103. var dimInfo = data.getDimensionInfo(concreteDim);
  90104. if (dimInfo != null) {
  90105. // visualMeta.dimension should be dimension index, but not concrete dimension.
  90106. visualMeta.dimension = dimInfo.index;
  90107. visualMetaList.push(visualMeta);
  90108. }
  90109. }
  90110. }); // console.log(JSON.stringify(visualMetaList.map(a => a.stops)));
  90111. seriesModel.getData().setVisual('visualMeta', visualMetaList);
  90112. }
  90113. }]; // FIXME
  90114. // performance and export for heatmap?
  90115. // value can be Infinity or -Infinity
  90116. function getColorVisual(seriesModel, visualMapModel, value, valueState) {
  90117. var mappings = visualMapModel.targetVisuals[valueState];
  90118. var visualTypes = VisualMapping.prepareVisualTypes(mappings);
  90119. var resultVisual = {
  90120. color: getVisualFromData(seriesModel.getData(), 'color') // default color.
  90121. };
  90122. for (var i = 0, len = visualTypes.length; i < len; i++) {
  90123. var type = visualTypes[i];
  90124. var mapping = mappings[type === 'opacity' ? '__alphaForOpacity' : type];
  90125. mapping && mapping.applyVisual(value, getVisual, setVisual);
  90126. }
  90127. return resultVisual.color;
  90128. function getVisual(key) {
  90129. return resultVisual[key];
  90130. }
  90131. function setVisual(key, value) {
  90132. resultVisual[key] = value;
  90133. }
  90134. }
  90135. /*
  90136. * Licensed to the Apache Software Foundation (ASF) under one
  90137. * or more contributor license agreements. See the NOTICE file
  90138. * distributed with this work for additional information
  90139. * regarding copyright ownership. The ASF licenses this file
  90140. * to you under the Apache License, Version 2.0 (the
  90141. * "License"); you may not use this file except in compliance
  90142. * with the License. You may obtain a copy of the License at
  90143. *
  90144. * http://www.apache.org/licenses/LICENSE-2.0
  90145. *
  90146. * Unless required by applicable law or agreed to in writing,
  90147. * software distributed under the License is distributed on an
  90148. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90149. * KIND, either express or implied. See the License for the
  90150. * specific language governing permissions and limitations
  90151. * under the License.
  90152. */
  90153. /**
  90154. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90155. */
  90156. /*
  90157. * Licensed to the Apache Software Foundation (ASF) under one
  90158. * or more contributor license agreements. See the NOTICE file
  90159. * distributed with this work for additional information
  90160. * regarding copyright ownership. The ASF licenses this file
  90161. * to you under the Apache License, Version 2.0 (the
  90162. * "License"); you may not use this file except in compliance
  90163. * with the License. You may obtain a copy of the License at
  90164. *
  90165. * http://www.apache.org/licenses/LICENSE-2.0
  90166. *
  90167. * Unless required by applicable law or agreed to in writing,
  90168. * software distributed under the License is distributed on an
  90169. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90170. * KIND, either express or implied. See the License for the
  90171. * specific language governing permissions and limitations
  90172. * under the License.
  90173. */
  90174. // @ts-nocheck
  90175. var each$15 = each$1;
  90176. function visualMapPreprocessor(option) {
  90177. var visualMap = option && option.visualMap;
  90178. if (!isArray(visualMap)) {
  90179. visualMap = visualMap ? [visualMap] : [];
  90180. }
  90181. each$15(visualMap, function (opt) {
  90182. if (!opt) {
  90183. return;
  90184. } // rename splitList to pieces
  90185. if (has$1(opt, 'splitList') && !has$1(opt, 'pieces')) {
  90186. opt.pieces = opt.splitList;
  90187. delete opt.splitList;
  90188. }
  90189. var pieces = opt.pieces;
  90190. if (pieces && isArray(pieces)) {
  90191. each$15(pieces, function (piece) {
  90192. if (isObject$1(piece)) {
  90193. if (has$1(piece, 'start') && !has$1(piece, 'min')) {
  90194. piece.min = piece.start;
  90195. }
  90196. if (has$1(piece, 'end') && !has$1(piece, 'max')) {
  90197. piece.max = piece.end;
  90198. }
  90199. }
  90200. });
  90201. }
  90202. });
  90203. }
  90204. function has$1(obj, name) {
  90205. return obj && obj.hasOwnProperty && obj.hasOwnProperty(name);
  90206. }
  90207. /*
  90208. * Licensed to the Apache Software Foundation (ASF) under one
  90209. * or more contributor license agreements. See the NOTICE file
  90210. * distributed with this work for additional information
  90211. * regarding copyright ownership. The ASF licenses this file
  90212. * to you under the Apache License, Version 2.0 (the
  90213. * "License"); you may not use this file except in compliance
  90214. * with the License. You may obtain a copy of the License at
  90215. *
  90216. * http://www.apache.org/licenses/LICENSE-2.0
  90217. *
  90218. * Unless required by applicable law or agreed to in writing,
  90219. * software distributed under the License is distributed on an
  90220. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90221. * KIND, either express or implied. See the License for the
  90222. * specific language governing permissions and limitations
  90223. * under the License.
  90224. */
  90225. /**
  90226. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90227. */
  90228. /*
  90229. * Licensed to the Apache Software Foundation (ASF) under one
  90230. * or more contributor license agreements. See the NOTICE file
  90231. * distributed with this work for additional information
  90232. * regarding copyright ownership. The ASF licenses this file
  90233. * to you under the Apache License, Version 2.0 (the
  90234. * "License"); you may not use this file except in compliance
  90235. * with the License. You may obtain a copy of the License at
  90236. *
  90237. * http://www.apache.org/licenses/LICENSE-2.0
  90238. *
  90239. * Unless required by applicable law or agreed to in writing,
  90240. * software distributed under the License is distributed on an
  90241. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90242. * KIND, either express or implied. See the License for the
  90243. * specific language governing permissions and limitations
  90244. * under the License.
  90245. */
  90246. var installed$1 = false;
  90247. function installCommon$1(registers) {
  90248. if (installed$1) {
  90249. return;
  90250. }
  90251. installed$1 = true;
  90252. registers.registerSubTypeDefaulter('visualMap', function (option) {
  90253. // Compatible with ec2, when splitNumber === 0, continuous visualMap will be used.
  90254. return !option.categories && (!(option.pieces ? option.pieces.length > 0 : option.splitNumber > 0) || option.calculable) ? 'continuous' : 'piecewise';
  90255. });
  90256. registers.registerAction(visualMapActionInfo, visualMapActionHander);
  90257. each$1(visualMapEncodingHandlers, function (handler) {
  90258. registers.registerVisual(registers.PRIORITY.VISUAL.COMPONENT, handler);
  90259. });
  90260. registers.registerPreprocessor(visualMapPreprocessor);
  90261. }
  90262. /*
  90263. * Licensed to the Apache Software Foundation (ASF) under one
  90264. * or more contributor license agreements. See the NOTICE file
  90265. * distributed with this work for additional information
  90266. * regarding copyright ownership. The ASF licenses this file
  90267. * to you under the Apache License, Version 2.0 (the
  90268. * "License"); you may not use this file except in compliance
  90269. * with the License. You may obtain a copy of the License at
  90270. *
  90271. * http://www.apache.org/licenses/LICENSE-2.0
  90272. *
  90273. * Unless required by applicable law or agreed to in writing,
  90274. * software distributed under the License is distributed on an
  90275. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90276. * KIND, either express or implied. See the License for the
  90277. * specific language governing permissions and limitations
  90278. * under the License.
  90279. */
  90280. /**
  90281. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90282. */
  90283. /*
  90284. * Licensed to the Apache Software Foundation (ASF) under one
  90285. * or more contributor license agreements. See the NOTICE file
  90286. * distributed with this work for additional information
  90287. * regarding copyright ownership. The ASF licenses this file
  90288. * to you under the Apache License, Version 2.0 (the
  90289. * "License"); you may not use this file except in compliance
  90290. * with the License. You may obtain a copy of the License at
  90291. *
  90292. * http://www.apache.org/licenses/LICENSE-2.0
  90293. *
  90294. * Unless required by applicable law or agreed to in writing,
  90295. * software distributed under the License is distributed on an
  90296. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90297. * KIND, either express or implied. See the License for the
  90298. * specific language governing permissions and limitations
  90299. * under the License.
  90300. */
  90301. function install$45(registers) {
  90302. registers.registerComponentModel(ContinuousModel);
  90303. registers.registerComponentView(ContinuousView);
  90304. installCommon$1(registers);
  90305. }
  90306. /*
  90307. * Licensed to the Apache Software Foundation (ASF) under one
  90308. * or more contributor license agreements. See the NOTICE file
  90309. * distributed with this work for additional information
  90310. * regarding copyright ownership. The ASF licenses this file
  90311. * to you under the Apache License, Version 2.0 (the
  90312. * "License"); you may not use this file except in compliance
  90313. * with the License. You may obtain a copy of the License at
  90314. *
  90315. * http://www.apache.org/licenses/LICENSE-2.0
  90316. *
  90317. * Unless required by applicable law or agreed to in writing,
  90318. * software distributed under the License is distributed on an
  90319. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90320. * KIND, either express or implied. See the License for the
  90321. * specific language governing permissions and limitations
  90322. * under the License.
  90323. */
  90324. /**
  90325. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90326. */
  90327. /*
  90328. * Licensed to the Apache Software Foundation (ASF) under one
  90329. * or more contributor license agreements. See the NOTICE file
  90330. * distributed with this work for additional information
  90331. * regarding copyright ownership. The ASF licenses this file
  90332. * to you under the Apache License, Version 2.0 (the
  90333. * "License"); you may not use this file except in compliance
  90334. * with the License. You may obtain a copy of the License at
  90335. *
  90336. * http://www.apache.org/licenses/LICENSE-2.0
  90337. *
  90338. * Unless required by applicable law or agreed to in writing,
  90339. * software distributed under the License is distributed on an
  90340. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90341. * KIND, either express or implied. See the License for the
  90342. * specific language governing permissions and limitations
  90343. * under the License.
  90344. */
  90345. var PiecewiseModel =
  90346. /** @class */
  90347. function (_super) {
  90348. __extends(PiecewiseModel, _super);
  90349. function PiecewiseModel() {
  90350. var _this = _super !== null && _super.apply(this, arguments) || this;
  90351. _this.type = PiecewiseModel.type;
  90352. /**
  90353. * The order is always [low, ..., high].
  90354. * [{text: string, interval: Array.<number>}, ...]
  90355. */
  90356. _this._pieceList = [];
  90357. return _this;
  90358. }
  90359. PiecewiseModel.prototype.optionUpdated = function (newOption, isInit) {
  90360. _super.prototype.optionUpdated.apply(this, arguments);
  90361. this.resetExtent();
  90362. var mode = this._mode = this._determineMode();
  90363. this._pieceList = [];
  90364. resetMethods[this._mode].call(this, this._pieceList);
  90365. this._resetSelected(newOption, isInit);
  90366. var categories = this.option.categories;
  90367. this.resetVisual(function (mappingOption, state) {
  90368. if (mode === 'categories') {
  90369. mappingOption.mappingMethod = 'category';
  90370. mappingOption.categories = clone(categories);
  90371. } else {
  90372. mappingOption.dataExtent = this.getExtent();
  90373. mappingOption.mappingMethod = 'piecewise';
  90374. mappingOption.pieceList = map(this._pieceList, function (piece) {
  90375. piece = clone(piece);
  90376. if (state !== 'inRange') {
  90377. // FIXME
  90378. // outOfRange do not support special visual in pieces.
  90379. piece.visual = null;
  90380. }
  90381. return piece;
  90382. });
  90383. }
  90384. });
  90385. };
  90386. /**
  90387. * @protected
  90388. * @override
  90389. */
  90390. PiecewiseModel.prototype.completeVisualOption = function () {
  90391. // Consider this case:
  90392. // visualMap: {
  90393. // pieces: [{symbol: 'circle', lt: 0}, {symbol: 'rect', gte: 0}]
  90394. // }
  90395. // where no inRange/outOfRange set but only pieces. So we should make
  90396. // default inRange/outOfRange for this case, otherwise visuals that only
  90397. // appear in `pieces` will not be taken into account in visual encoding.
  90398. var option = this.option;
  90399. var visualTypesInPieces = {};
  90400. var visualTypes = VisualMapping.listVisualTypes();
  90401. var isCategory = this.isCategory();
  90402. each$1(option.pieces, function (piece) {
  90403. each$1(visualTypes, function (visualType) {
  90404. if (piece.hasOwnProperty(visualType)) {
  90405. visualTypesInPieces[visualType] = 1;
  90406. }
  90407. });
  90408. });
  90409. each$1(visualTypesInPieces, function (v, visualType) {
  90410. var exists = false;
  90411. each$1(this.stateList, function (state) {
  90412. exists = exists || has(option, state, visualType) || has(option.target, state, visualType);
  90413. }, this);
  90414. !exists && each$1(this.stateList, function (state) {
  90415. (option[state] || (option[state] = {}))[visualType] = visualDefault.get(visualType, state === 'inRange' ? 'active' : 'inactive', isCategory);
  90416. });
  90417. }, this);
  90418. function has(obj, state, visualType) {
  90419. return obj && obj[state] && obj[state].hasOwnProperty(visualType);
  90420. }
  90421. _super.prototype.completeVisualOption.apply(this, arguments);
  90422. };
  90423. PiecewiseModel.prototype._resetSelected = function (newOption, isInit) {
  90424. var thisOption = this.option;
  90425. var pieceList = this._pieceList; // Selected do not merge but all override.
  90426. var selected = (isInit ? thisOption : newOption).selected || {};
  90427. thisOption.selected = selected; // Consider 'not specified' means true.
  90428. each$1(pieceList, function (piece, index) {
  90429. var key = this.getSelectedMapKey(piece);
  90430. if (!selected.hasOwnProperty(key)) {
  90431. selected[key] = true;
  90432. }
  90433. }, this);
  90434. if (thisOption.selectedMode === 'single') {
  90435. // Ensure there is only one selected.
  90436. var hasSel_1 = false;
  90437. each$1(pieceList, function (piece, index) {
  90438. var key = this.getSelectedMapKey(piece);
  90439. if (selected[key]) {
  90440. hasSel_1 ? selected[key] = false : hasSel_1 = true;
  90441. }
  90442. }, this);
  90443. } // thisOption.selectedMode === 'multiple', default: all selected.
  90444. };
  90445. /**
  90446. * @public
  90447. */
  90448. PiecewiseModel.prototype.getItemSymbol = function () {
  90449. return this.get('itemSymbol');
  90450. };
  90451. /**
  90452. * @public
  90453. */
  90454. PiecewiseModel.prototype.getSelectedMapKey = function (piece) {
  90455. return this._mode === 'categories' ? piece.value + '' : piece.index + '';
  90456. };
  90457. /**
  90458. * @public
  90459. */
  90460. PiecewiseModel.prototype.getPieceList = function () {
  90461. return this._pieceList;
  90462. };
  90463. /**
  90464. * @return {string}
  90465. */
  90466. PiecewiseModel.prototype._determineMode = function () {
  90467. var option = this.option;
  90468. return option.pieces && option.pieces.length > 0 ? 'pieces' : this.option.categories ? 'categories' : 'splitNumber';
  90469. };
  90470. /**
  90471. * @override
  90472. */
  90473. PiecewiseModel.prototype.setSelected = function (selected) {
  90474. this.option.selected = clone(selected);
  90475. };
  90476. /**
  90477. * @override
  90478. */
  90479. PiecewiseModel.prototype.getValueState = function (value) {
  90480. var index = VisualMapping.findPieceIndex(value, this._pieceList);
  90481. return index != null ? this.option.selected[this.getSelectedMapKey(this._pieceList[index])] ? 'inRange' : 'outOfRange' : 'outOfRange';
  90482. };
  90483. /**
  90484. * @public
  90485. * @param pieceIndex piece index in visualMapModel.getPieceList()
  90486. */
  90487. PiecewiseModel.prototype.findTargetDataIndices = function (pieceIndex) {
  90488. var result = [];
  90489. var pieceList = this._pieceList;
  90490. this.eachTargetSeries(function (seriesModel) {
  90491. var dataIndices = [];
  90492. var data = seriesModel.getData();
  90493. data.each(this.getDataDimension(data), function (value, dataIndex) {
  90494. // Should always base on model pieceList, because it is order sensitive.
  90495. var pIdx = VisualMapping.findPieceIndex(value, pieceList);
  90496. pIdx === pieceIndex && dataIndices.push(dataIndex);
  90497. }, this);
  90498. result.push({
  90499. seriesId: seriesModel.id,
  90500. dataIndex: dataIndices
  90501. });
  90502. }, this);
  90503. return result;
  90504. };
  90505. /**
  90506. * @private
  90507. * @param piece piece.value or piece.interval is required.
  90508. * @return Can be Infinity or -Infinity
  90509. */
  90510. PiecewiseModel.prototype.getRepresentValue = function (piece) {
  90511. var representValue;
  90512. if (this.isCategory()) {
  90513. representValue = piece.value;
  90514. } else {
  90515. if (piece.value != null) {
  90516. representValue = piece.value;
  90517. } else {
  90518. var pieceInterval = piece.interval || [];
  90519. representValue = pieceInterval[0] === -Infinity && pieceInterval[1] === Infinity ? 0 : (pieceInterval[0] + pieceInterval[1]) / 2;
  90520. }
  90521. }
  90522. return representValue;
  90523. };
  90524. PiecewiseModel.prototype.getVisualMeta = function (getColorVisual) {
  90525. // Do not support category. (category axis is ordinal, numerical)
  90526. if (this.isCategory()) {
  90527. return;
  90528. }
  90529. var stops = [];
  90530. var outerColors = ['', ''];
  90531. var visualMapModel = this;
  90532. function setStop(interval, valueState) {
  90533. var representValue = visualMapModel.getRepresentValue({
  90534. interval: interval
  90535. }); // Not category
  90536. if (!valueState) {
  90537. valueState = visualMapModel.getValueState(representValue);
  90538. }
  90539. var color = getColorVisual(representValue, valueState);
  90540. if (interval[0] === -Infinity) {
  90541. outerColors[0] = color;
  90542. } else if (interval[1] === Infinity) {
  90543. outerColors[1] = color;
  90544. } else {
  90545. stops.push({
  90546. value: interval[0],
  90547. color: color
  90548. }, {
  90549. value: interval[1],
  90550. color: color
  90551. });
  90552. }
  90553. } // Suplement
  90554. var pieceList = this._pieceList.slice();
  90555. if (!pieceList.length) {
  90556. pieceList.push({
  90557. interval: [-Infinity, Infinity]
  90558. });
  90559. } else {
  90560. var edge = pieceList[0].interval[0];
  90561. edge !== -Infinity && pieceList.unshift({
  90562. interval: [-Infinity, edge]
  90563. });
  90564. edge = pieceList[pieceList.length - 1].interval[1];
  90565. edge !== Infinity && pieceList.push({
  90566. interval: [edge, Infinity]
  90567. });
  90568. }
  90569. var curr = -Infinity;
  90570. each$1(pieceList, function (piece) {
  90571. var interval = piece.interval;
  90572. if (interval) {
  90573. // Fulfill gap.
  90574. interval[0] > curr && setStop([curr, interval[0]], 'outOfRange');
  90575. setStop(interval.slice());
  90576. curr = interval[1];
  90577. }
  90578. }, this);
  90579. return {
  90580. stops: stops,
  90581. outerColors: outerColors
  90582. };
  90583. };
  90584. PiecewiseModel.type = 'visualMap.piecewise';
  90585. PiecewiseModel.defaultOption = inheritDefaultOption(VisualMapModel.defaultOption, {
  90586. selected: null,
  90587. minOpen: false,
  90588. maxOpen: false,
  90589. align: 'auto',
  90590. itemWidth: 20,
  90591. itemHeight: 14,
  90592. itemSymbol: 'roundRect',
  90593. pieces: null,
  90594. categories: null,
  90595. splitNumber: 5,
  90596. selectedMode: 'multiple',
  90597. itemGap: 10,
  90598. hoverLink: true // Enable hover highlight.
  90599. });
  90600. return PiecewiseModel;
  90601. }(VisualMapModel);
  90602. /**
  90603. * Key is this._mode
  90604. * @type {Object}
  90605. * @this {module:echarts/component/viusalMap/PiecewiseMode}
  90606. */
  90607. var resetMethods = {
  90608. splitNumber: function (outPieceList) {
  90609. var thisOption = this.option;
  90610. var precision = Math.min(thisOption.precision, 20);
  90611. var dataExtent = this.getExtent();
  90612. var splitNumber = thisOption.splitNumber;
  90613. splitNumber = Math.max(parseInt(splitNumber, 10), 1);
  90614. thisOption.splitNumber = splitNumber;
  90615. var splitStep = (dataExtent[1] - dataExtent[0]) / splitNumber; // Precision auto-adaption
  90616. while (+splitStep.toFixed(precision) !== splitStep && precision < 5) {
  90617. precision++;
  90618. }
  90619. thisOption.precision = precision;
  90620. splitStep = +splitStep.toFixed(precision);
  90621. if (thisOption.minOpen) {
  90622. outPieceList.push({
  90623. interval: [-Infinity, dataExtent[0]],
  90624. close: [0, 0]
  90625. });
  90626. }
  90627. for (var index = 0, curr = dataExtent[0]; index < splitNumber; curr += splitStep, index++) {
  90628. var max = index === splitNumber - 1 ? dataExtent[1] : curr + splitStep;
  90629. outPieceList.push({
  90630. interval: [curr, max],
  90631. close: [1, 1]
  90632. });
  90633. }
  90634. if (thisOption.maxOpen) {
  90635. outPieceList.push({
  90636. interval: [dataExtent[1], Infinity],
  90637. close: [0, 0]
  90638. });
  90639. }
  90640. reformIntervals(outPieceList);
  90641. each$1(outPieceList, function (piece, index) {
  90642. piece.index = index;
  90643. piece.text = this.formatValueText(piece.interval);
  90644. }, this);
  90645. },
  90646. categories: function (outPieceList) {
  90647. var thisOption = this.option;
  90648. each$1(thisOption.categories, function (cate) {
  90649. // FIXME category模式也使用pieceList,但在visualMapping中不是使用pieceList。
  90650. // 是否改一致。
  90651. outPieceList.push({
  90652. text: this.formatValueText(cate, true),
  90653. value: cate
  90654. });
  90655. }, this); // See "Order Rule".
  90656. normalizeReverse(thisOption, outPieceList);
  90657. },
  90658. pieces: function (outPieceList) {
  90659. var thisOption = this.option;
  90660. each$1(thisOption.pieces, function (pieceListItem, index) {
  90661. if (!isObject$1(pieceListItem)) {
  90662. pieceListItem = {
  90663. value: pieceListItem
  90664. };
  90665. }
  90666. var item = {
  90667. text: '',
  90668. index: index
  90669. };
  90670. if (pieceListItem.label != null) {
  90671. item.text = pieceListItem.label;
  90672. }
  90673. if (pieceListItem.hasOwnProperty('value')) {
  90674. var value = item.value = pieceListItem.value;
  90675. item.interval = [value, value];
  90676. item.close = [1, 1];
  90677. } else {
  90678. // `min` `max` is legacy option.
  90679. // `lt` `gt` `lte` `gte` is recommanded.
  90680. var interval = item.interval = [];
  90681. var close_1 = item.close = [0, 0];
  90682. var closeList = [1, 0, 1];
  90683. var infinityList = [-Infinity, Infinity];
  90684. var useMinMax = [];
  90685. for (var lg = 0; lg < 2; lg++) {
  90686. var names = [['gte', 'gt', 'min'], ['lte', 'lt', 'max']][lg];
  90687. for (var i = 0; i < 3 && interval[lg] == null; i++) {
  90688. interval[lg] = pieceListItem[names[i]];
  90689. close_1[lg] = closeList[i];
  90690. useMinMax[lg] = i === 2;
  90691. }
  90692. interval[lg] == null && (interval[lg] = infinityList[lg]);
  90693. }
  90694. useMinMax[0] && interval[1] === Infinity && (close_1[0] = 0);
  90695. useMinMax[1] && interval[0] === -Infinity && (close_1[1] = 0);
  90696. {
  90697. if (interval[0] > interval[1]) {
  90698. console.warn('Piece ' + index + 'is illegal: ' + interval + ' lower bound should not greater then uppper bound.');
  90699. }
  90700. }
  90701. if (interval[0] === interval[1] && close_1[0] && close_1[1]) {
  90702. // Consider: [{min: 5, max: 5, visual: {...}}, {min: 0, max: 5}],
  90703. // we use value to lift the priority when min === max
  90704. item.value = interval[0];
  90705. }
  90706. }
  90707. item.visual = VisualMapping.retrieveVisuals(pieceListItem);
  90708. outPieceList.push(item);
  90709. }, this); // See "Order Rule".
  90710. normalizeReverse(thisOption, outPieceList); // Only pieces
  90711. reformIntervals(outPieceList);
  90712. each$1(outPieceList, function (piece) {
  90713. var close = piece.close;
  90714. var edgeSymbols = [['<', '≤'][close[1]], ['>', '≥'][close[0]]];
  90715. piece.text = piece.text || this.formatValueText(piece.value != null ? piece.value : piece.interval, false, edgeSymbols);
  90716. }, this);
  90717. }
  90718. };
  90719. function normalizeReverse(thisOption, pieceList) {
  90720. var inverse = thisOption.inverse;
  90721. if (thisOption.orient === 'vertical' ? !inverse : inverse) {
  90722. pieceList.reverse();
  90723. }
  90724. }
  90725. /*
  90726. * Licensed to the Apache Software Foundation (ASF) under one
  90727. * or more contributor license agreements. See the NOTICE file
  90728. * distributed with this work for additional information
  90729. * regarding copyright ownership. The ASF licenses this file
  90730. * to you under the Apache License, Version 2.0 (the
  90731. * "License"); you may not use this file except in compliance
  90732. * with the License. You may obtain a copy of the License at
  90733. *
  90734. * http://www.apache.org/licenses/LICENSE-2.0
  90735. *
  90736. * Unless required by applicable law or agreed to in writing,
  90737. * software distributed under the License is distributed on an
  90738. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90739. * KIND, either express or implied. See the License for the
  90740. * specific language governing permissions and limitations
  90741. * under the License.
  90742. */
  90743. /**
  90744. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90745. */
  90746. /*
  90747. * Licensed to the Apache Software Foundation (ASF) under one
  90748. * or more contributor license agreements. See the NOTICE file
  90749. * distributed with this work for additional information
  90750. * regarding copyright ownership. The ASF licenses this file
  90751. * to you under the Apache License, Version 2.0 (the
  90752. * "License"); you may not use this file except in compliance
  90753. * with the License. You may obtain a copy of the License at
  90754. *
  90755. * http://www.apache.org/licenses/LICENSE-2.0
  90756. *
  90757. * Unless required by applicable law or agreed to in writing,
  90758. * software distributed under the License is distributed on an
  90759. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90760. * KIND, either express or implied. See the License for the
  90761. * specific language governing permissions and limitations
  90762. * under the License.
  90763. */
  90764. var PiecewiseVisualMapView =
  90765. /** @class */
  90766. function (_super) {
  90767. __extends(PiecewiseVisualMapView, _super);
  90768. function PiecewiseVisualMapView() {
  90769. var _this = _super !== null && _super.apply(this, arguments) || this;
  90770. _this.type = PiecewiseVisualMapView.type;
  90771. return _this;
  90772. }
  90773. PiecewiseVisualMapView.prototype.doRender = function () {
  90774. var thisGroup = this.group;
  90775. thisGroup.removeAll();
  90776. var visualMapModel = this.visualMapModel;
  90777. var textGap = visualMapModel.get('textGap');
  90778. var textStyleModel = visualMapModel.textStyleModel;
  90779. var textFont = textStyleModel.getFont();
  90780. var textFill = textStyleModel.getTextColor();
  90781. var itemAlign = this._getItemAlign();
  90782. var itemSize = visualMapModel.itemSize;
  90783. var viewData = this._getViewData();
  90784. var endsText = viewData.endsText;
  90785. var showLabel = retrieve(visualMapModel.get('showLabel', true), !endsText);
  90786. endsText && this._renderEndsText(thisGroup, endsText[0], itemSize, showLabel, itemAlign);
  90787. each$1(viewData.viewPieceList, function (item) {
  90788. var piece = item.piece;
  90789. var itemGroup = new Group();
  90790. itemGroup.onclick = bind(this._onItemClick, this, piece);
  90791. this._enableHoverLink(itemGroup, item.indexInModelPieceList); // TODO Category
  90792. var representValue = visualMapModel.getRepresentValue(piece);
  90793. this._createItemSymbol(itemGroup, representValue, [0, 0, itemSize[0], itemSize[1]]);
  90794. if (showLabel) {
  90795. var visualState = this.visualMapModel.getValueState(representValue);
  90796. itemGroup.add(new ZRText({
  90797. style: {
  90798. x: itemAlign === 'right' ? -textGap : itemSize[0] + textGap,
  90799. y: itemSize[1] / 2,
  90800. text: piece.text,
  90801. verticalAlign: 'middle',
  90802. align: itemAlign,
  90803. font: textFont,
  90804. fill: textFill,
  90805. opacity: visualState === 'outOfRange' ? 0.5 : 1
  90806. }
  90807. }));
  90808. }
  90809. thisGroup.add(itemGroup);
  90810. }, this);
  90811. endsText && this._renderEndsText(thisGroup, endsText[1], itemSize, showLabel, itemAlign);
  90812. box(visualMapModel.get('orient'), thisGroup, visualMapModel.get('itemGap'));
  90813. this.renderBackground(thisGroup);
  90814. this.positionGroup(thisGroup);
  90815. };
  90816. PiecewiseVisualMapView.prototype._enableHoverLink = function (itemGroup, pieceIndex) {
  90817. var _this = this;
  90818. itemGroup.on('mouseover', function () {
  90819. return onHoverLink('highlight');
  90820. }).on('mouseout', function () {
  90821. return onHoverLink('downplay');
  90822. });
  90823. var onHoverLink = function (method) {
  90824. var visualMapModel = _this.visualMapModel; // TODO: TYPE More detailed action types
  90825. visualMapModel.option.hoverLink && _this.api.dispatchAction({
  90826. type: method,
  90827. batch: makeHighDownBatch(visualMapModel.findTargetDataIndices(pieceIndex), visualMapModel)
  90828. });
  90829. };
  90830. };
  90831. PiecewiseVisualMapView.prototype._getItemAlign = function () {
  90832. var visualMapModel = this.visualMapModel;
  90833. var modelOption = visualMapModel.option;
  90834. if (modelOption.orient === 'vertical') {
  90835. return getItemAlign(visualMapModel, this.api, visualMapModel.itemSize);
  90836. } else {
  90837. // horizontal, most case left unless specifying right.
  90838. var align = modelOption.align;
  90839. if (!align || align === 'auto') {
  90840. align = 'left';
  90841. }
  90842. return align;
  90843. }
  90844. };
  90845. PiecewiseVisualMapView.prototype._renderEndsText = function (group, text, itemSize, showLabel, itemAlign) {
  90846. if (!text) {
  90847. return;
  90848. }
  90849. var itemGroup = new Group();
  90850. var textStyleModel = this.visualMapModel.textStyleModel;
  90851. itemGroup.add(new ZRText({
  90852. style: {
  90853. x: showLabel ? itemAlign === 'right' ? itemSize[0] : 0 : itemSize[0] / 2,
  90854. y: itemSize[1] / 2,
  90855. verticalAlign: 'middle',
  90856. align: showLabel ? itemAlign : 'center',
  90857. text: text,
  90858. font: textStyleModel.getFont(),
  90859. fill: textStyleModel.getTextColor()
  90860. }
  90861. }));
  90862. group.add(itemGroup);
  90863. };
  90864. /**
  90865. * @private
  90866. * @return {Object} {peiceList, endsText} The order is the same as screen pixel order.
  90867. */
  90868. PiecewiseVisualMapView.prototype._getViewData = function () {
  90869. var visualMapModel = this.visualMapModel;
  90870. var viewPieceList = map(visualMapModel.getPieceList(), function (piece, index) {
  90871. return {
  90872. piece: piece,
  90873. indexInModelPieceList: index
  90874. };
  90875. });
  90876. var endsText = visualMapModel.get('text'); // Consider orient and inverse.
  90877. var orient = visualMapModel.get('orient');
  90878. var inverse = visualMapModel.get('inverse'); // Order of model pieceList is always [low, ..., high]
  90879. if (orient === 'horizontal' ? inverse : !inverse) {
  90880. viewPieceList.reverse();
  90881. } // Origin order of endsText is [high, low]
  90882. else if (endsText) {
  90883. endsText = endsText.slice().reverse();
  90884. }
  90885. return {
  90886. viewPieceList: viewPieceList,
  90887. endsText: endsText
  90888. };
  90889. };
  90890. PiecewiseVisualMapView.prototype._createItemSymbol = function (group, representValue, shapeParam) {
  90891. group.add(createSymbol( // symbol will be string
  90892. this.getControllerVisual(representValue, 'symbol'), shapeParam[0], shapeParam[1], shapeParam[2], shapeParam[3], // color will be string
  90893. this.getControllerVisual(representValue, 'color')));
  90894. };
  90895. PiecewiseVisualMapView.prototype._onItemClick = function (piece) {
  90896. var visualMapModel = this.visualMapModel;
  90897. var option = visualMapModel.option;
  90898. var selected = clone(option.selected);
  90899. var newKey = visualMapModel.getSelectedMapKey(piece);
  90900. if (option.selectedMode === 'single') {
  90901. selected[newKey] = true;
  90902. each$1(selected, function (o, key) {
  90903. selected[key] = key === newKey;
  90904. });
  90905. } else {
  90906. selected[newKey] = !selected[newKey];
  90907. }
  90908. this.api.dispatchAction({
  90909. type: 'selectDataRange',
  90910. from: this.uid,
  90911. visualMapId: this.visualMapModel.id,
  90912. selected: selected
  90913. });
  90914. };
  90915. PiecewiseVisualMapView.type = 'visualMap.piecewise';
  90916. return PiecewiseVisualMapView;
  90917. }(VisualMapView);
  90918. /*
  90919. * Licensed to the Apache Software Foundation (ASF) under one
  90920. * or more contributor license agreements. See the NOTICE file
  90921. * distributed with this work for additional information
  90922. * regarding copyright ownership. The ASF licenses this file
  90923. * to you under the Apache License, Version 2.0 (the
  90924. * "License"); you may not use this file except in compliance
  90925. * with the License. You may obtain a copy of the License at
  90926. *
  90927. * http://www.apache.org/licenses/LICENSE-2.0
  90928. *
  90929. * Unless required by applicable law or agreed to in writing,
  90930. * software distributed under the License is distributed on an
  90931. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90932. * KIND, either express or implied. See the License for the
  90933. * specific language governing permissions and limitations
  90934. * under the License.
  90935. */
  90936. /**
  90937. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90938. */
  90939. /*
  90940. * Licensed to the Apache Software Foundation (ASF) under one
  90941. * or more contributor license agreements. See the NOTICE file
  90942. * distributed with this work for additional information
  90943. * regarding copyright ownership. The ASF licenses this file
  90944. * to you under the Apache License, Version 2.0 (the
  90945. * "License"); you may not use this file except in compliance
  90946. * with the License. You may obtain a copy of the License at
  90947. *
  90948. * http://www.apache.org/licenses/LICENSE-2.0
  90949. *
  90950. * Unless required by applicable law or agreed to in writing,
  90951. * software distributed under the License is distributed on an
  90952. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90953. * KIND, either express or implied. See the License for the
  90954. * specific language governing permissions and limitations
  90955. * under the License.
  90956. */
  90957. function install$46(registers) {
  90958. registers.registerComponentModel(PiecewiseModel);
  90959. registers.registerComponentView(PiecewiseVisualMapView);
  90960. installCommon$1(registers);
  90961. }
  90962. /*
  90963. * Licensed to the Apache Software Foundation (ASF) under one
  90964. * or more contributor license agreements. See the NOTICE file
  90965. * distributed with this work for additional information
  90966. * regarding copyright ownership. The ASF licenses this file
  90967. * to you under the Apache License, Version 2.0 (the
  90968. * "License"); you may not use this file except in compliance
  90969. * with the License. You may obtain a copy of the License at
  90970. *
  90971. * http://www.apache.org/licenses/LICENSE-2.0
  90972. *
  90973. * Unless required by applicable law or agreed to in writing,
  90974. * software distributed under the License is distributed on an
  90975. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90976. * KIND, either express or implied. See the License for the
  90977. * specific language governing permissions and limitations
  90978. * under the License.
  90979. */
  90980. /**
  90981. * AUTO-GENERATED FILE. DO NOT MODIFY.
  90982. */
  90983. /*
  90984. * Licensed to the Apache Software Foundation (ASF) under one
  90985. * or more contributor license agreements. See the NOTICE file
  90986. * distributed with this work for additional information
  90987. * regarding copyright ownership. The ASF licenses this file
  90988. * to you under the Apache License, Version 2.0 (the
  90989. * "License"); you may not use this file except in compliance
  90990. * with the License. You may obtain a copy of the License at
  90991. *
  90992. * http://www.apache.org/licenses/LICENSE-2.0
  90993. *
  90994. * Unless required by applicable law or agreed to in writing,
  90995. * software distributed under the License is distributed on an
  90996. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  90997. * KIND, either express or implied. See the License for the
  90998. * specific language governing permissions and limitations
  90999. * under the License.
  91000. */
  91001. function install$44(registers) {
  91002. use(install$45);
  91003. use(install$46); // Do not install './dataZoomSelect',
  91004. // since it only work for toolbox dataZoom.
  91005. }
  91006. /*
  91007. * Licensed to the Apache Software Foundation (ASF) under one
  91008. * or more contributor license agreements. See the NOTICE file
  91009. * distributed with this work for additional information
  91010. * regarding copyright ownership. The ASF licenses this file
  91011. * to you under the Apache License, Version 2.0 (the
  91012. * "License"); you may not use this file except in compliance
  91013. * with the License. You may obtain a copy of the License at
  91014. *
  91015. * http://www.apache.org/licenses/LICENSE-2.0
  91016. *
  91017. * Unless required by applicable law or agreed to in writing,
  91018. * software distributed under the License is distributed on an
  91019. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91020. * KIND, either express or implied. See the License for the
  91021. * specific language governing permissions and limitations
  91022. * under the License.
  91023. */
  91024. /**
  91025. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91026. */
  91027. /*
  91028. * Licensed to the Apache Software Foundation (ASF) under one
  91029. * or more contributor license agreements. See the NOTICE file
  91030. * distributed with this work for additional information
  91031. * regarding copyright ownership. The ASF licenses this file
  91032. * to you under the Apache License, Version 2.0 (the
  91033. * "License"); you may not use this file except in compliance
  91034. * with the License. You may obtain a copy of the License at
  91035. *
  91036. * http://www.apache.org/licenses/LICENSE-2.0
  91037. *
  91038. * Unless required by applicable law or agreed to in writing,
  91039. * software distributed under the License is distributed on an
  91040. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91041. * KIND, either express or implied. See the License for the
  91042. * specific language governing permissions and limitations
  91043. * under the License.
  91044. */
  91045. use(install$44);
  91046. /*
  91047. * Licensed to the Apache Software Foundation (ASF) under one
  91048. * or more contributor license agreements. See the NOTICE file
  91049. * distributed with this work for additional information
  91050. * regarding copyright ownership. The ASF licenses this file
  91051. * to you under the Apache License, Version 2.0 (the
  91052. * "License"); you may not use this file except in compliance
  91053. * with the License. You may obtain a copy of the License at
  91054. *
  91055. * http://www.apache.org/licenses/LICENSE-2.0
  91056. *
  91057. * Unless required by applicable law or agreed to in writing,
  91058. * software distributed under the License is distributed on an
  91059. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91060. * KIND, either express or implied. See the License for the
  91061. * specific language governing permissions and limitations
  91062. * under the License.
  91063. */
  91064. /**
  91065. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91066. */
  91067. /*
  91068. * Licensed to the Apache Software Foundation (ASF) under one
  91069. * or more contributor license agreements. See the NOTICE file
  91070. * distributed with this work for additional information
  91071. * regarding copyright ownership. The ASF licenses this file
  91072. * to you under the Apache License, Version 2.0 (the
  91073. * "License"); you may not use this file except in compliance
  91074. * with the License. You may obtain a copy of the License at
  91075. *
  91076. * http://www.apache.org/licenses/LICENSE-2.0
  91077. *
  91078. * Unless required by applicable law or agreed to in writing,
  91079. * software distributed under the License is distributed on an
  91080. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91081. * KIND, either express or implied. See the License for the
  91082. * specific language governing permissions and limitations
  91083. * under the License.
  91084. */
  91085. var SelectDataZoomModel =
  91086. /** @class */
  91087. function (_super) {
  91088. __extends(SelectDataZoomModel, _super);
  91089. function SelectDataZoomModel() {
  91090. var _this = _super !== null && _super.apply(this, arguments) || this;
  91091. _this.type = SelectDataZoomModel.type;
  91092. return _this;
  91093. }
  91094. SelectDataZoomModel.type = 'dataZoom.select';
  91095. return SelectDataZoomModel;
  91096. }(DataZoomModel);
  91097. /*
  91098. * Licensed to the Apache Software Foundation (ASF) under one
  91099. * or more contributor license agreements. See the NOTICE file
  91100. * distributed with this work for additional information
  91101. * regarding copyright ownership. The ASF licenses this file
  91102. * to you under the Apache License, Version 2.0 (the
  91103. * "License"); you may not use this file except in compliance
  91104. * with the License. You may obtain a copy of the License at
  91105. *
  91106. * http://www.apache.org/licenses/LICENSE-2.0
  91107. *
  91108. * Unless required by applicable law or agreed to in writing,
  91109. * software distributed under the License is distributed on an
  91110. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91111. * KIND, either express or implied. See the License for the
  91112. * specific language governing permissions and limitations
  91113. * under the License.
  91114. */
  91115. /**
  91116. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91117. */
  91118. /*
  91119. * Licensed to the Apache Software Foundation (ASF) under one
  91120. * or more contributor license agreements. See the NOTICE file
  91121. * distributed with this work for additional information
  91122. * regarding copyright ownership. The ASF licenses this file
  91123. * to you under the Apache License, Version 2.0 (the
  91124. * "License"); you may not use this file except in compliance
  91125. * with the License. You may obtain a copy of the License at
  91126. *
  91127. * http://www.apache.org/licenses/LICENSE-2.0
  91128. *
  91129. * Unless required by applicable law or agreed to in writing,
  91130. * software distributed under the License is distributed on an
  91131. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91132. * KIND, either express or implied. See the License for the
  91133. * specific language governing permissions and limitations
  91134. * under the License.
  91135. */
  91136. var SelectDataZoomView =
  91137. /** @class */
  91138. function (_super) {
  91139. __extends(SelectDataZoomView, _super);
  91140. function SelectDataZoomView() {
  91141. var _this = _super !== null && _super.apply(this, arguments) || this;
  91142. _this.type = SelectDataZoomView.type;
  91143. return _this;
  91144. }
  91145. SelectDataZoomView.type = 'dataZoom.select';
  91146. return SelectDataZoomView;
  91147. }(DataZoomView);
  91148. /*
  91149. * Licensed to the Apache Software Foundation (ASF) under one
  91150. * or more contributor license agreements. See the NOTICE file
  91151. * distributed with this work for additional information
  91152. * regarding copyright ownership. The ASF licenses this file
  91153. * to you under the Apache License, Version 2.0 (the
  91154. * "License"); you may not use this file except in compliance
  91155. * with the License. You may obtain a copy of the License at
  91156. *
  91157. * http://www.apache.org/licenses/LICENSE-2.0
  91158. *
  91159. * Unless required by applicable law or agreed to in writing,
  91160. * software distributed under the License is distributed on an
  91161. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91162. * KIND, either express or implied. See the License for the
  91163. * specific language governing permissions and limitations
  91164. * under the License.
  91165. */
  91166. /**
  91167. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91168. */
  91169. /*
  91170. * Licensed to the Apache Software Foundation (ASF) under one
  91171. * or more contributor license agreements. See the NOTICE file
  91172. * distributed with this work for additional information
  91173. * regarding copyright ownership. The ASF licenses this file
  91174. * to you under the Apache License, Version 2.0 (the
  91175. * "License"); you may not use this file except in compliance
  91176. * with the License. You may obtain a copy of the License at
  91177. *
  91178. * http://www.apache.org/licenses/LICENSE-2.0
  91179. *
  91180. * Unless required by applicable law or agreed to in writing,
  91181. * software distributed under the License is distributed on an
  91182. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91183. * KIND, either express or implied. See the License for the
  91184. * specific language governing permissions and limitations
  91185. * under the License.
  91186. */
  91187. function install$48(registers) {
  91188. registers.registerComponentModel(SelectDataZoomModel);
  91189. registers.registerComponentView(SelectDataZoomView);
  91190. installCommon(registers);
  91191. }
  91192. /*
  91193. * Licensed to the Apache Software Foundation (ASF) under one
  91194. * or more contributor license agreements. See the NOTICE file
  91195. * distributed with this work for additional information
  91196. * regarding copyright ownership. The ASF licenses this file
  91197. * to you under the Apache License, Version 2.0 (the
  91198. * "License"); you may not use this file except in compliance
  91199. * with the License. You may obtain a copy of the License at
  91200. *
  91201. * http://www.apache.org/licenses/LICENSE-2.0
  91202. *
  91203. * Unless required by applicable law or agreed to in writing,
  91204. * software distributed under the License is distributed on an
  91205. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91206. * KIND, either express or implied. See the License for the
  91207. * specific language governing permissions and limitations
  91208. * under the License.
  91209. */
  91210. /**
  91211. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91212. */
  91213. /*
  91214. * Licensed to the Apache Software Foundation (ASF) under one
  91215. * or more contributor license agreements. See the NOTICE file
  91216. * distributed with this work for additional information
  91217. * regarding copyright ownership. The ASF licenses this file
  91218. * to you under the Apache License, Version 2.0 (the
  91219. * "License"); you may not use this file except in compliance
  91220. * with the License. You may obtain a copy of the License at
  91221. *
  91222. * http://www.apache.org/licenses/LICENSE-2.0
  91223. *
  91224. * Unless required by applicable law or agreed to in writing,
  91225. * software distributed under the License is distributed on an
  91226. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91227. * KIND, either express or implied. See the License for the
  91228. * specific language governing permissions and limitations
  91229. * under the License.
  91230. */
  91231. var ToolboxModel =
  91232. /** @class */
  91233. function (_super) {
  91234. __extends(ToolboxModel, _super);
  91235. function ToolboxModel() {
  91236. var _this = _super !== null && _super.apply(this, arguments) || this;
  91237. _this.type = ToolboxModel.type;
  91238. return _this;
  91239. }
  91240. ToolboxModel.prototype.optionUpdated = function () {
  91241. _super.prototype.optionUpdated.apply(this, arguments);
  91242. var ecModel = this.ecModel;
  91243. each$1(this.option.feature, function (featureOpt, featureName) {
  91244. var Feature = getFeature(featureName);
  91245. if (Feature) {
  91246. if (Feature.getDefaultOption) {
  91247. Feature.defaultOption = Feature.getDefaultOption(ecModel);
  91248. }
  91249. merge(featureOpt, Feature.defaultOption);
  91250. }
  91251. });
  91252. };
  91253. ToolboxModel.type = 'toolbox';
  91254. ToolboxModel.layoutMode = {
  91255. type: 'box',
  91256. ignoreSize: true
  91257. };
  91258. ToolboxModel.defaultOption = {
  91259. show: true,
  91260. z: 6,
  91261. zlevel: 0,
  91262. orient: 'horizontal',
  91263. left: 'right',
  91264. top: 'top',
  91265. // right
  91266. // bottom
  91267. backgroundColor: 'transparent',
  91268. borderColor: '#ccc',
  91269. borderRadius: 0,
  91270. borderWidth: 0,
  91271. padding: 5,
  91272. itemSize: 15,
  91273. itemGap: 8,
  91274. showTitle: true,
  91275. iconStyle: {
  91276. borderColor: '#666',
  91277. color: 'none'
  91278. },
  91279. emphasis: {
  91280. iconStyle: {
  91281. borderColor: '#3E98C5'
  91282. }
  91283. },
  91284. // textStyle: {},
  91285. // feature
  91286. tooltip: {
  91287. show: false,
  91288. position: 'bottom'
  91289. }
  91290. };
  91291. return ToolboxModel;
  91292. }(ComponentModel);
  91293. /*
  91294. * Licensed to the Apache Software Foundation (ASF) under one
  91295. * or more contributor license agreements. See the NOTICE file
  91296. * distributed with this work for additional information
  91297. * regarding copyright ownership. The ASF licenses this file
  91298. * to you under the Apache License, Version 2.0 (the
  91299. * "License"); you may not use this file except in compliance
  91300. * with the License. You may obtain a copy of the License at
  91301. *
  91302. * http://www.apache.org/licenses/LICENSE-2.0
  91303. *
  91304. * Unless required by applicable law or agreed to in writing,
  91305. * software distributed under the License is distributed on an
  91306. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91307. * KIND, either express or implied. See the License for the
  91308. * specific language governing permissions and limitations
  91309. * under the License.
  91310. */
  91311. /**
  91312. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91313. */
  91314. /*
  91315. * Licensed to the Apache Software Foundation (ASF) under one
  91316. * or more contributor license agreements. See the NOTICE file
  91317. * distributed with this work for additional information
  91318. * regarding copyright ownership. The ASF licenses this file
  91319. * to you under the Apache License, Version 2.0 (the
  91320. * "License"); you may not use this file except in compliance
  91321. * with the License. You may obtain a copy of the License at
  91322. *
  91323. * http://www.apache.org/licenses/LICENSE-2.0
  91324. *
  91325. * Unless required by applicable law or agreed to in writing,
  91326. * software distributed under the License is distributed on an
  91327. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91328. * KIND, either express or implied. See the License for the
  91329. * specific language governing permissions and limitations
  91330. * under the License.
  91331. */
  91332. var ToolboxView =
  91333. /** @class */
  91334. function (_super) {
  91335. __extends(ToolboxView, _super);
  91336. function ToolboxView() {
  91337. return _super !== null && _super.apply(this, arguments) || this;
  91338. }
  91339. ToolboxView.prototype.render = function (toolboxModel, ecModel, api, payload) {
  91340. var group = this.group;
  91341. group.removeAll();
  91342. if (!toolboxModel.get('show')) {
  91343. return;
  91344. }
  91345. var itemSize = +toolboxModel.get('itemSize');
  91346. var featureOpts = toolboxModel.get('feature') || {};
  91347. var features = this._features || (this._features = {});
  91348. var featureNames = [];
  91349. each$1(featureOpts, function (opt, name) {
  91350. featureNames.push(name);
  91351. });
  91352. new DataDiffer(this._featureNames || [], featureNames).add(processFeature).update(processFeature).remove(curry(processFeature, null)).execute(); // Keep for diff.
  91353. this._featureNames = featureNames;
  91354. function processFeature(newIndex, oldIndex) {
  91355. var featureName = featureNames[newIndex];
  91356. var oldName = featureNames[oldIndex];
  91357. var featureOpt = featureOpts[featureName];
  91358. var featureModel = new Model(featureOpt, toolboxModel, toolboxModel.ecModel);
  91359. var feature; // FIX#11236, merge feature title from MagicType newOption. TODO: consider seriesIndex ?
  91360. if (payload && payload.newTitle != null && payload.featureName === featureName) {
  91361. featureOpt.title = payload.newTitle;
  91362. }
  91363. if (featureName && !oldName) {
  91364. // Create
  91365. if (isUserFeatureName(featureName)) {
  91366. feature = {
  91367. onclick: featureModel.option.onclick,
  91368. featureName: featureName
  91369. };
  91370. } else {
  91371. var Feature = getFeature(featureName);
  91372. if (!Feature) {
  91373. return;
  91374. }
  91375. feature = new Feature();
  91376. }
  91377. features[featureName] = feature;
  91378. } else {
  91379. feature = features[oldName]; // If feature does not exsit.
  91380. if (!feature) {
  91381. return;
  91382. }
  91383. }
  91384. feature.uid = getUID('toolbox-feature');
  91385. feature.model = featureModel;
  91386. feature.ecModel = ecModel;
  91387. feature.api = api;
  91388. if (feature instanceof ToolboxFeature) {
  91389. if (!featureName && oldName) {
  91390. feature.dispose && feature.dispose(ecModel, api);
  91391. return;
  91392. }
  91393. if (!featureModel.get('show') || feature.unusable) {
  91394. feature.remove && feature.remove(ecModel, api);
  91395. return;
  91396. }
  91397. }
  91398. createIconPaths(featureModel, feature, featureName);
  91399. featureModel.setIconStatus = function (iconName, status) {
  91400. var option = this.option;
  91401. var iconPaths = this.iconPaths;
  91402. option.iconStatus = option.iconStatus || {};
  91403. option.iconStatus[iconName] = status;
  91404. if (iconPaths[iconName]) {
  91405. (status === 'emphasis' ? enterEmphasis : leaveEmphasis)(iconPaths[iconName]);
  91406. }
  91407. };
  91408. if (feature instanceof ToolboxFeature) {
  91409. if (feature.render) {
  91410. feature.render(featureModel, ecModel, api, payload);
  91411. }
  91412. }
  91413. }
  91414. function createIconPaths(featureModel, feature, featureName) {
  91415. var iconStyleModel = featureModel.getModel('iconStyle');
  91416. var iconStyleEmphasisModel = featureModel.getModel(['emphasis', 'iconStyle']); // If one feature has mutiple icon. they are orginaized as
  91417. // {
  91418. // icon: {
  91419. // foo: '',
  91420. // bar: ''
  91421. // },
  91422. // title: {
  91423. // foo: '',
  91424. // bar: ''
  91425. // }
  91426. // }
  91427. var icons = feature instanceof ToolboxFeature && feature.getIcons ? feature.getIcons() : featureModel.get('icon');
  91428. var titles = featureModel.get('title') || {};
  91429. var iconsMap;
  91430. var titlesMap;
  91431. if (typeof icons === 'string') {
  91432. iconsMap = {};
  91433. iconsMap[featureName] = icons;
  91434. } else {
  91435. iconsMap = icons;
  91436. }
  91437. if (typeof titles === 'string') {
  91438. titlesMap = {};
  91439. titlesMap[featureName] = titles;
  91440. } else {
  91441. titlesMap = titles;
  91442. }
  91443. var iconPaths = featureModel.iconPaths = {};
  91444. each$1(iconsMap, function (iconStr, iconName) {
  91445. var path = createIcon(iconStr, {}, {
  91446. x: -itemSize / 2,
  91447. y: -itemSize / 2,
  91448. width: itemSize,
  91449. height: itemSize
  91450. }); // TODO handling image
  91451. path.setStyle(iconStyleModel.getItemStyle());
  91452. var pathEmphasisState = path.ensureState('emphasis');
  91453. pathEmphasisState.style = iconStyleEmphasisModel.getItemStyle(); // Text position calculation
  91454. var textContent = new ZRText({
  91455. style: {
  91456. text: titlesMap[iconName],
  91457. align: iconStyleEmphasisModel.get('textAlign'),
  91458. borderRadius: iconStyleEmphasisModel.get('textBorderRadius'),
  91459. padding: iconStyleEmphasisModel.get('textPadding'),
  91460. fill: null
  91461. },
  91462. ignore: true
  91463. });
  91464. path.setTextContent(textContent);
  91465. setTooltipConfig({
  91466. el: path,
  91467. componentModel: toolboxModel,
  91468. itemName: iconName,
  91469. formatterParamsExtra: {
  91470. title: titlesMap[iconName]
  91471. }
  91472. }); // graphic.enableHoverEmphasis(path);
  91473. path.__title = titlesMap[iconName];
  91474. path.on('mouseover', function () {
  91475. // Should not reuse above hoverStyle, which might be modified.
  91476. var hoverStyle = iconStyleEmphasisModel.getItemStyle();
  91477. var defaultTextPosition = toolboxModel.get('orient') === 'vertical' ? toolboxModel.get('right') == null ? 'right' : 'left' : toolboxModel.get('bottom') == null ? 'bottom' : 'top';
  91478. textContent.setStyle({
  91479. fill: iconStyleEmphasisModel.get('textFill') || hoverStyle.fill || hoverStyle.stroke || '#000',
  91480. backgroundColor: iconStyleEmphasisModel.get('textBackgroundColor')
  91481. });
  91482. path.setTextConfig({
  91483. position: iconStyleEmphasisModel.get('textPosition') || defaultTextPosition
  91484. });
  91485. textContent.ignore = !toolboxModel.get('showTitle'); // Use enterEmphasis and leaveEmphasis provide by ec.
  91486. // There are flags managed by the echarts.
  91487. enterEmphasis(this);
  91488. }).on('mouseout', function () {
  91489. if (featureModel.get(['iconStatus', iconName]) !== 'emphasis') {
  91490. leaveEmphasis(this);
  91491. }
  91492. textContent.hide();
  91493. });
  91494. (featureModel.get(['iconStatus', iconName]) === 'emphasis' ? enterEmphasis : leaveEmphasis)(path);
  91495. group.add(path);
  91496. path.on('click', bind(feature.onclick, feature, ecModel, api, iconName));
  91497. iconPaths[iconName] = path;
  91498. });
  91499. }
  91500. layout$3(group, toolboxModel, api); // Render background after group is layout
  91501. // FIXME
  91502. group.add(makeBackground(group.getBoundingRect(), toolboxModel)); // Adjust icon title positions to avoid them out of screen
  91503. group.eachChild(function (icon) {
  91504. var titleText = icon.__title; // const hoverStyle = icon.hoverStyle;
  91505. // TODO simplify code?
  91506. var emphasisState = icon.ensureState('emphasis');
  91507. var emphasisTextConfig = emphasisState.textConfig || (emphasisState.textConfig = {});
  91508. var textContent = icon.getTextContent();
  91509. var emphasisTextState = textContent && textContent.states.emphasis; // May be background element
  91510. if (emphasisTextState && !isFunction$1(emphasisTextState) && titleText) {
  91511. var emphasisTextStyle = emphasisTextState.style || (emphasisTextState.style = {});
  91512. var rect = getBoundingRect(titleText, ZRText.makeFont(emphasisTextStyle));
  91513. var offsetX = icon.x + group.x;
  91514. var offsetY = icon.y + group.y + itemSize;
  91515. var needPutOnTop = false;
  91516. if (offsetY + rect.height > api.getHeight()) {
  91517. emphasisTextConfig.position = 'top';
  91518. needPutOnTop = true;
  91519. }
  91520. var topOffset = needPutOnTop ? -5 - rect.height : itemSize + 8;
  91521. if (offsetX + rect.width / 2 > api.getWidth()) {
  91522. emphasisTextConfig.position = ['100%', topOffset];
  91523. emphasisTextStyle.align = 'right';
  91524. } else if (offsetX - rect.width / 2 < 0) {
  91525. emphasisTextConfig.position = [0, topOffset];
  91526. emphasisTextStyle.align = 'left';
  91527. }
  91528. }
  91529. });
  91530. };
  91531. ToolboxView.prototype.updateView = function (toolboxModel, ecModel, api, payload) {
  91532. each$1(this._features, function (feature) {
  91533. feature instanceof ToolboxFeature && feature.updateView && feature.updateView(feature.model, ecModel, api, payload);
  91534. });
  91535. }; // updateLayout(toolboxModel, ecModel, api, payload) {
  91536. // zrUtil.each(this._features, function (feature) {
  91537. // feature.updateLayout && feature.updateLayout(feature.model, ecModel, api, payload);
  91538. // });
  91539. // },
  91540. ToolboxView.prototype.remove = function (ecModel, api) {
  91541. each$1(this._features, function (feature) {
  91542. feature instanceof ToolboxFeature && feature.remove && feature.remove(ecModel, api);
  91543. });
  91544. this.group.removeAll();
  91545. };
  91546. ToolboxView.prototype.dispose = function (ecModel, api) {
  91547. each$1(this._features, function (feature) {
  91548. feature instanceof ToolboxFeature && feature.dispose && feature.dispose(ecModel, api);
  91549. });
  91550. };
  91551. ToolboxView.type = 'toolbox';
  91552. return ToolboxView;
  91553. }(ComponentView);
  91554. function isUserFeatureName(featureName) {
  91555. return featureName.indexOf('my') === 0;
  91556. }
  91557. /*
  91558. * Licensed to the Apache Software Foundation (ASF) under one
  91559. * or more contributor license agreements. See the NOTICE file
  91560. * distributed with this work for additional information
  91561. * regarding copyright ownership. The ASF licenses this file
  91562. * to you under the Apache License, Version 2.0 (the
  91563. * "License"); you may not use this file except in compliance
  91564. * with the License. You may obtain a copy of the License at
  91565. *
  91566. * http://www.apache.org/licenses/LICENSE-2.0
  91567. *
  91568. * Unless required by applicable law or agreed to in writing,
  91569. * software distributed under the License is distributed on an
  91570. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91571. * KIND, either express or implied. See the License for the
  91572. * specific language governing permissions and limitations
  91573. * under the License.
  91574. */
  91575. /**
  91576. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91577. */
  91578. /*
  91579. * Licensed to the Apache Software Foundation (ASF) under one
  91580. * or more contributor license agreements. See the NOTICE file
  91581. * distributed with this work for additional information
  91582. * regarding copyright ownership. The ASF licenses this file
  91583. * to you under the Apache License, Version 2.0 (the
  91584. * "License"); you may not use this file except in compliance
  91585. * with the License. You may obtain a copy of the License at
  91586. *
  91587. * http://www.apache.org/licenses/LICENSE-2.0
  91588. *
  91589. * Unless required by applicable law or agreed to in writing,
  91590. * software distributed under the License is distributed on an
  91591. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91592. * KIND, either express or implied. See the License for the
  91593. * specific language governing permissions and limitations
  91594. * under the License.
  91595. */
  91596. /* global Uint8Array */
  91597. var SaveAsImage =
  91598. /** @class */
  91599. function (_super) {
  91600. __extends(SaveAsImage, _super);
  91601. function SaveAsImage() {
  91602. return _super !== null && _super.apply(this, arguments) || this;
  91603. }
  91604. SaveAsImage.prototype.onclick = function (ecModel, api) {
  91605. var model = this.model;
  91606. var title = model.get('name') || ecModel.get('title.0.text') || 'echarts';
  91607. var isSvg = api.getZr().painter.getType() === 'svg';
  91608. var type = isSvg ? 'svg' : model.get('type', true) || 'png';
  91609. var url = api.getConnectedDataURL({
  91610. type: type,
  91611. backgroundColor: model.get('backgroundColor', true) || ecModel.get('backgroundColor') || '#fff',
  91612. connectedBackgroundColor: model.get('connectedBackgroundColor'),
  91613. excludeComponents: model.get('excludeComponents'),
  91614. pixelRatio: model.get('pixelRatio')
  91615. }); // Chrome, Firefox, New Edge
  91616. if (typeof MouseEvent === 'function' && (env.browser.newEdge || !env.browser.ie && !env.browser.edge)) {
  91617. var $a = document.createElement('a');
  91618. $a.download = title + '.' + type;
  91619. $a.target = '_blank';
  91620. $a.href = url;
  91621. var evt = new MouseEvent('click', {
  91622. // some micro front-end framework, window maybe is a Proxy
  91623. view: document.defaultView,
  91624. bubbles: true,
  91625. cancelable: false
  91626. });
  91627. $a.dispatchEvent(evt);
  91628. } // IE or old Edge
  91629. else {
  91630. if (window.navigator.msSaveOrOpenBlob || isSvg) {
  91631. var parts = url.split(','); // data:[<mime type>][;charset=<charset>][;base64],<encoded data>
  91632. var base64Encoded = parts[0].indexOf('base64') > -1;
  91633. var bstr = isSvg // should decode the svg data uri first
  91634. ? decodeURIComponent(parts[1]) : parts[1]; // only `atob` when the data uri is encoded with base64
  91635. // otherwise, like `svg` data uri exported by zrender,
  91636. // there will be an error, for it's not encoded with base64.
  91637. // (just a url-encoded string through `encodeURIComponent`)
  91638. base64Encoded && (bstr = atob(bstr));
  91639. var filename = title + '.' + type;
  91640. if (window.navigator.msSaveOrOpenBlob) {
  91641. var n = bstr.length;
  91642. var u8arr = new Uint8Array(n);
  91643. while (n--) {
  91644. u8arr[n] = bstr.charCodeAt(n);
  91645. }
  91646. var blob = new Blob([u8arr]);
  91647. window.navigator.msSaveOrOpenBlob(blob, filename);
  91648. } else {
  91649. var frame = document.createElement('iframe');
  91650. document.body.appendChild(frame);
  91651. var cw = frame.contentWindow;
  91652. var doc = cw.document;
  91653. doc.open('image/svg+xml', 'replace');
  91654. doc.write(bstr);
  91655. doc.close();
  91656. cw.focus();
  91657. doc.execCommand('SaveAs', true, filename);
  91658. document.body.removeChild(frame);
  91659. }
  91660. } else {
  91661. var lang = model.get('lang');
  91662. var html = '' + '<body style="margin:0;">' + '<img src="' + url + '" style="max-width:100%;" title="' + (lang && lang[0] || '') + '" />' + '</body>';
  91663. var tab = window.open();
  91664. tab.document.write(html);
  91665. tab.document.title = title;
  91666. }
  91667. }
  91668. };
  91669. SaveAsImage.getDefaultOption = function (ecModel) {
  91670. var defaultOption = {
  91671. show: true,
  91672. 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',
  91673. title: ecModel.getLocale(['toolbox', 'saveAsImage', 'title']),
  91674. type: 'png',
  91675. // Default use option.backgroundColor
  91676. // backgroundColor: '#fff',
  91677. connectedBackgroundColor: '#fff',
  91678. name: '',
  91679. excludeComponents: ['toolbox'],
  91680. // use current pixel ratio of device by default
  91681. // pixelRatio: 1,
  91682. lang: ecModel.getLocale(['toolbox', 'saveAsImage', 'lang'])
  91683. };
  91684. return defaultOption;
  91685. };
  91686. return SaveAsImage;
  91687. }(ToolboxFeature);
  91688. SaveAsImage.prototype.unusable = !env.canvasSupported;
  91689. /*
  91690. * Licensed to the Apache Software Foundation (ASF) under one
  91691. * or more contributor license agreements. See the NOTICE file
  91692. * distributed with this work for additional information
  91693. * regarding copyright ownership. The ASF licenses this file
  91694. * to you under the Apache License, Version 2.0 (the
  91695. * "License"); you may not use this file except in compliance
  91696. * with the License. You may obtain a copy of the License at
  91697. *
  91698. * http://www.apache.org/licenses/LICENSE-2.0
  91699. *
  91700. * Unless required by applicable law or agreed to in writing,
  91701. * software distributed under the License is distributed on an
  91702. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91703. * KIND, either express or implied. See the License for the
  91704. * specific language governing permissions and limitations
  91705. * under the License.
  91706. */
  91707. /**
  91708. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91709. */
  91710. /*
  91711. * Licensed to the Apache Software Foundation (ASF) under one
  91712. * or more contributor license agreements. See the NOTICE file
  91713. * distributed with this work for additional information
  91714. * regarding copyright ownership. The ASF licenses this file
  91715. * to you under the Apache License, Version 2.0 (the
  91716. * "License"); you may not use this file except in compliance
  91717. * with the License. You may obtain a copy of the License at
  91718. *
  91719. * http://www.apache.org/licenses/LICENSE-2.0
  91720. *
  91721. * Unless required by applicable law or agreed to in writing,
  91722. * software distributed under the License is distributed on an
  91723. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91724. * KIND, either express or implied. See the License for the
  91725. * specific language governing permissions and limitations
  91726. * under the License.
  91727. */
  91728. var INNER_STACK_KEYWORD = '__ec_magicType_stack__';
  91729. var radioTypes = [['line', 'bar'], ['stack']];
  91730. var MagicType =
  91731. /** @class */
  91732. function (_super) {
  91733. __extends(MagicType, _super);
  91734. function MagicType() {
  91735. return _super !== null && _super.apply(this, arguments) || this;
  91736. }
  91737. MagicType.prototype.getIcons = function () {
  91738. var model = this.model;
  91739. var availableIcons = model.get('icon');
  91740. var icons = {};
  91741. each$1(model.get('type'), function (type) {
  91742. if (availableIcons[type]) {
  91743. icons[type] = availableIcons[type];
  91744. }
  91745. });
  91746. return icons;
  91747. };
  91748. MagicType.getDefaultOption = function (ecModel) {
  91749. var defaultOption = {
  91750. show: true,
  91751. type: [],
  91752. // Icon group
  91753. icon: {
  91754. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  91755. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7',
  91756. // eslint-disable-next-line
  91757. 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
  91758. },
  91759. // `line`, `bar`, `stack`, `tiled`
  91760. title: ecModel.getLocale(['toolbox', 'magicType', 'title']),
  91761. option: {},
  91762. seriesIndex: {}
  91763. };
  91764. return defaultOption;
  91765. };
  91766. MagicType.prototype.onclick = function (ecModel, api, type) {
  91767. var model = this.model;
  91768. var seriesIndex = model.get(['seriesIndex', type]); // Not supported magicType
  91769. if (!seriesOptGenreator[type]) {
  91770. return;
  91771. }
  91772. var newOption = {
  91773. series: []
  91774. };
  91775. var generateNewSeriesTypes = function (seriesModel) {
  91776. var seriesType = seriesModel.subType;
  91777. var seriesId = seriesModel.id;
  91778. var newSeriesOpt = seriesOptGenreator[type](seriesType, seriesId, seriesModel, model);
  91779. if (newSeriesOpt) {
  91780. // PENDING If merge original option?
  91781. defaults(newSeriesOpt, seriesModel.option);
  91782. newOption.series.push(newSeriesOpt);
  91783. } // Modify boundaryGap
  91784. var coordSys = seriesModel.coordinateSystem;
  91785. if (coordSys && coordSys.type === 'cartesian2d' && (type === 'line' || type === 'bar')) {
  91786. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  91787. if (categoryAxis) {
  91788. var axisDim = categoryAxis.dim;
  91789. var axisType = axisDim + 'Axis';
  91790. var axisModel = seriesModel.getReferringComponents(axisType, SINGLE_REFERRING).models[0];
  91791. var axisIndex = axisModel.componentIndex;
  91792. newOption[axisType] = newOption[axisType] || [];
  91793. for (var i = 0; i <= axisIndex; i++) {
  91794. newOption[axisType][axisIndex] = newOption[axisType][axisIndex] || {};
  91795. }
  91796. newOption[axisType][axisIndex].boundaryGap = type === 'bar';
  91797. }
  91798. }
  91799. };
  91800. each$1(radioTypes, function (radio) {
  91801. if (indexOf$1(radio, type) >= 0) {
  91802. each$1(radio, function (item) {
  91803. model.setIconStatus(item, 'normal');
  91804. });
  91805. }
  91806. });
  91807. model.setIconStatus(type, 'emphasis');
  91808. ecModel.eachComponent({
  91809. mainType: 'series',
  91810. query: seriesIndex == null ? null : {
  91811. seriesIndex: seriesIndex
  91812. }
  91813. }, generateNewSeriesTypes);
  91814. var newTitle; // Change title of stack
  91815. if (type === 'stack') {
  91816. // use titles in model instead of ecModel
  91817. // as stack and tiled appears in pair, just flip them
  91818. // no need of checking stack state
  91819. newTitle = merge({
  91820. stack: model.option.title.tiled,
  91821. tiled: model.option.title.stack
  91822. }, model.option.title);
  91823. }
  91824. api.dispatchAction({
  91825. type: 'changeMagicType',
  91826. currentType: type,
  91827. newOption: newOption,
  91828. newTitle: newTitle,
  91829. featureName: 'magicType'
  91830. });
  91831. };
  91832. return MagicType;
  91833. }(ToolboxFeature);
  91834. var seriesOptGenreator = {
  91835. 'line': function (seriesType, seriesId, seriesModel, model) {
  91836. if (seriesType === 'bar') {
  91837. return merge({
  91838. id: seriesId,
  91839. type: 'line',
  91840. // Preserve data related option
  91841. data: seriesModel.get('data'),
  91842. stack: seriesModel.get('stack'),
  91843. markPoint: seriesModel.get('markPoint'),
  91844. markLine: seriesModel.get('markLine')
  91845. }, model.get(['option', 'line']) || {}, true);
  91846. }
  91847. },
  91848. 'bar': function (seriesType, seriesId, seriesModel, model) {
  91849. if (seriesType === 'line') {
  91850. return merge({
  91851. id: seriesId,
  91852. type: 'bar',
  91853. // Preserve data related option
  91854. data: seriesModel.get('data'),
  91855. stack: seriesModel.get('stack'),
  91856. markPoint: seriesModel.get('markPoint'),
  91857. markLine: seriesModel.get('markLine')
  91858. }, model.get(['option', 'bar']) || {}, true);
  91859. }
  91860. },
  91861. 'stack': function (seriesType, seriesId, seriesModel, model) {
  91862. var isStack = seriesModel.get('stack') === INNER_STACK_KEYWORD;
  91863. if (seriesType === 'line' || seriesType === 'bar') {
  91864. model.setIconStatus('stack', isStack ? 'normal' : 'emphasis');
  91865. return merge({
  91866. id: seriesId,
  91867. stack: isStack ? '' : INNER_STACK_KEYWORD
  91868. }, model.get(['option', 'stack']) || {}, true);
  91869. }
  91870. }
  91871. }; // TODO: SELF REGISTERED.
  91872. registerAction({
  91873. type: 'changeMagicType',
  91874. event: 'magicTypeChanged',
  91875. update: 'prepareAndUpdate'
  91876. }, function (payload, ecModel) {
  91877. ecModel.mergeOption(payload.newOption);
  91878. });
  91879. /*
  91880. * Licensed to the Apache Software Foundation (ASF) under one
  91881. * or more contributor license agreements. See the NOTICE file
  91882. * distributed with this work for additional information
  91883. * regarding copyright ownership. The ASF licenses this file
  91884. * to you under the Apache License, Version 2.0 (the
  91885. * "License"); you may not use this file except in compliance
  91886. * with the License. You may obtain a copy of the License at
  91887. *
  91888. * http://www.apache.org/licenses/LICENSE-2.0
  91889. *
  91890. * Unless required by applicable law or agreed to in writing,
  91891. * software distributed under the License is distributed on an
  91892. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91893. * KIND, either express or implied. See the License for the
  91894. * specific language governing permissions and limitations
  91895. * under the License.
  91896. */
  91897. /**
  91898. * AUTO-GENERATED FILE. DO NOT MODIFY.
  91899. */
  91900. /*
  91901. * Licensed to the Apache Software Foundation (ASF) under one
  91902. * or more contributor license agreements. See the NOTICE file
  91903. * distributed with this work for additional information
  91904. * regarding copyright ownership. The ASF licenses this file
  91905. * to you under the Apache License, Version 2.0 (the
  91906. * "License"); you may not use this file except in compliance
  91907. * with the License. You may obtain a copy of the License at
  91908. *
  91909. * http://www.apache.org/licenses/LICENSE-2.0
  91910. *
  91911. * Unless required by applicable law or agreed to in writing,
  91912. * software distributed under the License is distributed on an
  91913. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  91914. * KIND, either express or implied. See the License for the
  91915. * specific language governing permissions and limitations
  91916. * under the License.
  91917. */
  91918. var BLOCK_SPLITER = new Array(60).join('-');
  91919. var ITEM_SPLITER = '\t';
  91920. /**
  91921. * Group series into two types
  91922. * 1. on category axis, like line, bar
  91923. * 2. others, like scatter, pie
  91924. */
  91925. function groupSeries(ecModel) {
  91926. var seriesGroupByCategoryAxis = {};
  91927. var otherSeries = [];
  91928. var meta = [];
  91929. ecModel.eachRawSeries(function (seriesModel) {
  91930. var coordSys = seriesModel.coordinateSystem;
  91931. if (coordSys && (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')) {
  91932. // TODO: TYPE Consider polar? Include polar may increase unecessary bundle size.
  91933. var baseAxis = coordSys.getBaseAxis();
  91934. if (baseAxis.type === 'category') {
  91935. var key = baseAxis.dim + '_' + baseAxis.index;
  91936. if (!seriesGroupByCategoryAxis[key]) {
  91937. seriesGroupByCategoryAxis[key] = {
  91938. categoryAxis: baseAxis,
  91939. valueAxis: coordSys.getOtherAxis(baseAxis),
  91940. series: []
  91941. };
  91942. meta.push({
  91943. axisDim: baseAxis.dim,
  91944. axisIndex: baseAxis.index
  91945. });
  91946. }
  91947. seriesGroupByCategoryAxis[key].series.push(seriesModel);
  91948. } else {
  91949. otherSeries.push(seriesModel);
  91950. }
  91951. } else {
  91952. otherSeries.push(seriesModel);
  91953. }
  91954. });
  91955. return {
  91956. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  91957. other: otherSeries,
  91958. meta: meta
  91959. };
  91960. }
  91961. /**
  91962. * Assemble content of series on cateogory axis
  91963. * @inner
  91964. */
  91965. function assembleSeriesWithCategoryAxis(groups) {
  91966. var tables = [];
  91967. each$1(groups, function (group, key) {
  91968. var categoryAxis = group.categoryAxis;
  91969. var valueAxis = group.valueAxis;
  91970. var valueAxisDim = valueAxis.dim;
  91971. var headers = [' '].concat(map(group.series, function (series) {
  91972. return series.name;
  91973. })); // @ts-ignore TODO Polar
  91974. var columns = [categoryAxis.model.getCategories()];
  91975. each$1(group.series, function (series) {
  91976. var rawData = series.getRawData();
  91977. columns.push(series.getRawData().mapArray(rawData.mapDimension(valueAxisDim), function (val) {
  91978. return val;
  91979. }));
  91980. }); // Assemble table content
  91981. var lines = [headers.join(ITEM_SPLITER)];
  91982. for (var i = 0; i < columns[0].length; i++) {
  91983. var items = [];
  91984. for (var j = 0; j < columns.length; j++) {
  91985. items.push(columns[j][i]);
  91986. }
  91987. lines.push(items.join(ITEM_SPLITER));
  91988. }
  91989. tables.push(lines.join('\n'));
  91990. });
  91991. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n');
  91992. }
  91993. /**
  91994. * Assemble content of other series
  91995. */
  91996. function assembleOtherSeries(series) {
  91997. return map(series, function (series) {
  91998. var data = series.getRawData();
  91999. var lines = [series.name];
  92000. var vals = [];
  92001. data.each(data.dimensions, function () {
  92002. var argLen = arguments.length;
  92003. var dataIndex = arguments[argLen - 1];
  92004. var name = data.getName(dataIndex);
  92005. for (var i = 0; i < argLen - 1; i++) {
  92006. vals[i] = arguments[i];
  92007. }
  92008. lines.push((name ? name + ITEM_SPLITER : '') + vals.join(ITEM_SPLITER));
  92009. });
  92010. return lines.join('\n');
  92011. }).join('\n\n' + BLOCK_SPLITER + '\n\n');
  92012. }
  92013. function getContentFromModel(ecModel) {
  92014. var result = groupSeries(ecModel);
  92015. return {
  92016. value: filter([assembleSeriesWithCategoryAxis(result.seriesGroupByCategoryAxis), assembleOtherSeries(result.other)], function (str) {
  92017. return !!str.replace(/[\n\t\s]/g, '');
  92018. }).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  92019. meta: result.meta
  92020. };
  92021. }
  92022. function trim$1(str) {
  92023. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  92024. }
  92025. /**
  92026. * If a block is tsv format
  92027. */
  92028. function isTSVFormat(block) {
  92029. // Simple method to find out if a block is tsv format
  92030. var firstLine = block.slice(0, block.indexOf('\n'));
  92031. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  92032. return true;
  92033. }
  92034. }
  92035. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g');
  92036. /**
  92037. * @param {string} tsv
  92038. * @return {Object}
  92039. */
  92040. function parseTSVContents(tsv) {
  92041. var tsvLines = tsv.split(/\n+/g);
  92042. var headers = trim$1(tsvLines.shift()).split(itemSplitRegex);
  92043. var categories = [];
  92044. var series = map(headers, function (header) {
  92045. return {
  92046. name: header,
  92047. data: []
  92048. };
  92049. });
  92050. for (var i = 0; i < tsvLines.length; i++) {
  92051. var items = trim$1(tsvLines[i]).split(itemSplitRegex);
  92052. categories.push(items.shift());
  92053. for (var j = 0; j < items.length; j++) {
  92054. series[j] && (series[j].data[i] = items[j]);
  92055. }
  92056. }
  92057. return {
  92058. series: series,
  92059. categories: categories
  92060. };
  92061. }
  92062. function parseListContents(str) {
  92063. var lines = str.split(/\n+/g);
  92064. var seriesName = trim$1(lines.shift());
  92065. var data = [];
  92066. for (var i = 0; i < lines.length; i++) {
  92067. // if line is empty, ignore it.
  92068. // there is a case that a user forgot to delete `\n`.
  92069. var line = trim$1(lines[i]);
  92070. if (!line) {
  92071. continue;
  92072. }
  92073. var items = line.split(itemSplitRegex);
  92074. var name_1 = '';
  92075. var value = void 0;
  92076. var hasName = false;
  92077. if (isNaN(items[0])) {
  92078. // First item is name
  92079. hasName = true;
  92080. name_1 = items[0];
  92081. items = items.slice(1);
  92082. data[i] = {
  92083. name: name_1,
  92084. value: []
  92085. };
  92086. value = data[i].value;
  92087. } else {
  92088. value = data[i] = [];
  92089. }
  92090. for (var j = 0; j < items.length; j++) {
  92091. value.push(+items[j]);
  92092. }
  92093. if (value.length === 1) {
  92094. hasName ? data[i].value = value[0] : data[i] = value[0];
  92095. }
  92096. }
  92097. return {
  92098. name: seriesName,
  92099. data: data
  92100. };
  92101. }
  92102. function parseContents(str, blockMetaList) {
  92103. var blocks = str.split(new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g'));
  92104. var newOption = {
  92105. series: []
  92106. };
  92107. each$1(blocks, function (block, idx) {
  92108. if (isTSVFormat(block)) {
  92109. var result = parseTSVContents(block);
  92110. var blockMeta = blockMetaList[idx];
  92111. var axisKey = blockMeta.axisDim + 'Axis';
  92112. if (blockMeta) {
  92113. newOption[axisKey] = newOption[axisKey] || [];
  92114. newOption[axisKey][blockMeta.axisIndex] = {
  92115. data: result.categories
  92116. };
  92117. newOption.series = newOption.series.concat(result.series);
  92118. }
  92119. } else {
  92120. var result = parseListContents(block);
  92121. newOption.series.push(result);
  92122. }
  92123. });
  92124. return newOption;
  92125. }
  92126. var DataView =
  92127. /** @class */
  92128. function (_super) {
  92129. __extends(DataView, _super);
  92130. function DataView() {
  92131. return _super !== null && _super.apply(this, arguments) || this;
  92132. }
  92133. DataView.prototype.onclick = function (ecModel, api) {
  92134. var container = api.getDom();
  92135. var model = this.model;
  92136. if (this._dom) {
  92137. container.removeChild(this._dom);
  92138. }
  92139. var root = document.createElement('div');
  92140. root.style.cssText = 'position:absolute;left:5px;top:5px;bottom:5px;right:5px;';
  92141. root.style.backgroundColor = model.get('backgroundColor') || '#fff'; // Create elements
  92142. var header = document.createElement('h4');
  92143. var lang = model.get('lang') || [];
  92144. header.innerHTML = lang[0] || model.get('title');
  92145. header.style.cssText = 'margin: 10px 20px;';
  92146. header.style.color = model.get('textColor');
  92147. var viewMain = document.createElement('div');
  92148. var textarea = document.createElement('textarea');
  92149. viewMain.style.cssText = 'display:block;width:100%;overflow:auto;';
  92150. var optionToContent = model.get('optionToContent');
  92151. var contentToOption = model.get('contentToOption');
  92152. var result = getContentFromModel(ecModel);
  92153. if (typeof optionToContent === 'function') {
  92154. var htmlOrDom = optionToContent(api.getOption());
  92155. if (typeof htmlOrDom === 'string') {
  92156. viewMain.innerHTML = htmlOrDom;
  92157. } else if (isDom(htmlOrDom)) {
  92158. viewMain.appendChild(htmlOrDom);
  92159. }
  92160. } else {
  92161. // Use default textarea
  92162. viewMain.appendChild(textarea);
  92163. textarea.readOnly = model.get('readOnly');
  92164. textarea.style.cssText = 'width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;';
  92165. textarea.style.color = model.get('textColor');
  92166. textarea.style.borderColor = model.get('textareaBorderColor');
  92167. textarea.style.backgroundColor = model.get('textareaColor');
  92168. textarea.value = result.value;
  92169. }
  92170. var blockMetaList = result.meta;
  92171. var buttonContainer = document.createElement('div');
  92172. buttonContainer.style.cssText = 'position:absolute;bottom:0;left:0;right:0;';
  92173. var buttonStyle = 'float:right;margin-right:20px;border:none;' + 'cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px';
  92174. var closeButton = document.createElement('div');
  92175. var refreshButton = document.createElement('div');
  92176. buttonStyle += ';background-color:' + model.get('buttonColor');
  92177. buttonStyle += ';color:' + model.get('buttonTextColor');
  92178. var self = this;
  92179. function close() {
  92180. container.removeChild(root);
  92181. self._dom = null;
  92182. }
  92183. addEventListener(closeButton, 'click', close);
  92184. addEventListener(refreshButton, 'click', function () {
  92185. if (contentToOption == null && optionToContent != null || contentToOption != null && optionToContent == null) {
  92186. {
  92187. // eslint-disable-next-line
  92188. console.warn('It seems you have just provided one of `contentToOption` and `optionToContent` functions but missed the other one. Data change is ignored.');
  92189. }
  92190. close();
  92191. return;
  92192. }
  92193. var newOption;
  92194. try {
  92195. if (typeof contentToOption === 'function') {
  92196. newOption = contentToOption(viewMain, api.getOption());
  92197. } else {
  92198. newOption = parseContents(textarea.value, blockMetaList);
  92199. }
  92200. } catch (e) {
  92201. close();
  92202. throw new Error('Data view format error ' + e);
  92203. }
  92204. if (newOption) {
  92205. api.dispatchAction({
  92206. type: 'changeDataView',
  92207. newOption: newOption
  92208. });
  92209. }
  92210. close();
  92211. });
  92212. closeButton.innerHTML = lang[1];
  92213. refreshButton.innerHTML = lang[2];
  92214. refreshButton.style.cssText = buttonStyle;
  92215. closeButton.style.cssText = buttonStyle;
  92216. !model.get('readOnly') && buttonContainer.appendChild(refreshButton);
  92217. buttonContainer.appendChild(closeButton);
  92218. root.appendChild(header);
  92219. root.appendChild(viewMain);
  92220. root.appendChild(buttonContainer);
  92221. viewMain.style.height = container.clientHeight - 80 + 'px';
  92222. container.appendChild(root);
  92223. this._dom = root;
  92224. };
  92225. DataView.prototype.remove = function (ecModel, api) {
  92226. this._dom && api.getDom().removeChild(this._dom);
  92227. };
  92228. DataView.prototype.dispose = function (ecModel, api) {
  92229. this.remove(ecModel, api);
  92230. };
  92231. DataView.getDefaultOption = function (ecModel) {
  92232. var defaultOption = {
  92233. show: true,
  92234. readOnly: false,
  92235. optionToContent: null,
  92236. contentToOption: null,
  92237. // eslint-disable-next-line
  92238. 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',
  92239. title: ecModel.getLocale(['toolbox', 'dataView', 'title']),
  92240. lang: ecModel.getLocale(['toolbox', 'dataView', 'lang']),
  92241. backgroundColor: '#fff',
  92242. textColor: '#000',
  92243. textareaColor: '#fff',
  92244. textareaBorderColor: '#333',
  92245. buttonColor: '#c23531',
  92246. buttonTextColor: '#fff'
  92247. };
  92248. return defaultOption;
  92249. };
  92250. return DataView;
  92251. }(ToolboxFeature);
  92252. /**
  92253. * @inner
  92254. */
  92255. function tryMergeDataOption(newData, originalData) {
  92256. return map(newData, function (newVal, idx) {
  92257. var original = originalData && originalData[idx];
  92258. if (isObject$1(original) && !isArray(original)) {
  92259. var newValIsObject = isObject$1(newVal) && !isArray(newVal);
  92260. if (!newValIsObject) {
  92261. newVal = {
  92262. value: newVal
  92263. };
  92264. } // original data has name but new data has no name
  92265. var shouldDeleteName = original.name != null && newVal.name == null; // Original data has option
  92266. newVal = defaults(newVal, original);
  92267. shouldDeleteName && delete newVal.name;
  92268. return newVal;
  92269. } else {
  92270. return newVal;
  92271. }
  92272. });
  92273. } // TODO: SELF REGISTERED.
  92274. registerAction({
  92275. type: 'changeDataView',
  92276. event: 'dataViewChanged',
  92277. update: 'prepareAndUpdate'
  92278. }, function (payload, ecModel) {
  92279. var newSeriesOptList = [];
  92280. each$1(payload.newOption.series, function (seriesOpt) {
  92281. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0];
  92282. if (!seriesModel) {
  92283. // New created series
  92284. // Geuss the series type
  92285. newSeriesOptList.push(extend({
  92286. // Default is scatter
  92287. type: 'scatter'
  92288. }, seriesOpt));
  92289. } else {
  92290. var originalData = seriesModel.get('data');
  92291. newSeriesOptList.push({
  92292. name: seriesOpt.name,
  92293. data: tryMergeDataOption(seriesOpt.data, originalData)
  92294. });
  92295. }
  92296. });
  92297. ecModel.mergeOption(defaults({
  92298. series: newSeriesOptList
  92299. }, payload.newOption));
  92300. });
  92301. /*
  92302. * Licensed to the Apache Software Foundation (ASF) under one
  92303. * or more contributor license agreements. See the NOTICE file
  92304. * distributed with this work for additional information
  92305. * regarding copyright ownership. The ASF licenses this file
  92306. * to you under the Apache License, Version 2.0 (the
  92307. * "License"); you may not use this file except in compliance
  92308. * with the License. You may obtain a copy of the License at
  92309. *
  92310. * http://www.apache.org/licenses/LICENSE-2.0
  92311. *
  92312. * Unless required by applicable law or agreed to in writing,
  92313. * software distributed under the License is distributed on an
  92314. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92315. * KIND, either express or implied. See the License for the
  92316. * specific language governing permissions and limitations
  92317. * under the License.
  92318. */
  92319. /**
  92320. * AUTO-GENERATED FILE. DO NOT MODIFY.
  92321. */
  92322. /*
  92323. * Licensed to the Apache Software Foundation (ASF) under one
  92324. * or more contributor license agreements. See the NOTICE file
  92325. * distributed with this work for additional information
  92326. * regarding copyright ownership. The ASF licenses this file
  92327. * to you under the Apache License, Version 2.0 (the
  92328. * "License"); you may not use this file except in compliance
  92329. * with the License. You may obtain a copy of the License at
  92330. *
  92331. * http://www.apache.org/licenses/LICENSE-2.0
  92332. *
  92333. * Unless required by applicable law or agreed to in writing,
  92334. * software distributed under the License is distributed on an
  92335. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92336. * KIND, either express or implied. See the License for the
  92337. * specific language governing permissions and limitations
  92338. * under the License.
  92339. */
  92340. var each$16 = each$1;
  92341. var inner$19 = makeInner();
  92342. /**
  92343. * @param ecModel
  92344. * @param newSnapshot key is dataZoomId
  92345. */
  92346. function push(ecModel, newSnapshot) {
  92347. var storedSnapshots = getStoreSnapshots(ecModel); // If previous dataZoom can not be found,
  92348. // complete an range with current range.
  92349. each$16(newSnapshot, function (batchItem, dataZoomId) {
  92350. var i = storedSnapshots.length - 1;
  92351. for (; i >= 0; i--) {
  92352. var snapshot = storedSnapshots[i];
  92353. if (snapshot[dataZoomId]) {
  92354. break;
  92355. }
  92356. }
  92357. if (i < 0) {
  92358. // No origin range set, create one by current range.
  92359. var dataZoomModel = ecModel.queryComponents({
  92360. mainType: 'dataZoom',
  92361. subType: 'select',
  92362. id: dataZoomId
  92363. })[0];
  92364. if (dataZoomModel) {
  92365. var percentRange = dataZoomModel.getPercentRange();
  92366. storedSnapshots[0][dataZoomId] = {
  92367. dataZoomId: dataZoomId,
  92368. start: percentRange[0],
  92369. end: percentRange[1]
  92370. };
  92371. }
  92372. }
  92373. });
  92374. storedSnapshots.push(newSnapshot);
  92375. }
  92376. function pop(ecModel) {
  92377. var storedSnapshots = getStoreSnapshots(ecModel);
  92378. var head = storedSnapshots[storedSnapshots.length - 1];
  92379. storedSnapshots.length > 1 && storedSnapshots.pop(); // Find top for all dataZoom.
  92380. var snapshot = {};
  92381. each$16(head, function (batchItem, dataZoomId) {
  92382. for (var i = storedSnapshots.length - 1; i >= 0; i--) {
  92383. batchItem = storedSnapshots[i][dataZoomId];
  92384. if (batchItem) {
  92385. snapshot[dataZoomId] = batchItem;
  92386. break;
  92387. }
  92388. }
  92389. });
  92390. return snapshot;
  92391. }
  92392. function clear$1(ecModel) {
  92393. inner$19(ecModel).snapshots = null;
  92394. }
  92395. function count(ecModel) {
  92396. return getStoreSnapshots(ecModel).length;
  92397. }
  92398. /**
  92399. * History length of each dataZoom may be different.
  92400. * this._history[0] is used to store origin range.
  92401. */
  92402. function getStoreSnapshots(ecModel) {
  92403. var store = inner$19(ecModel);
  92404. if (!store.snapshots) {
  92405. store.snapshots = [{}];
  92406. }
  92407. return store.snapshots;
  92408. }
  92409. /*
  92410. * Licensed to the Apache Software Foundation (ASF) under one
  92411. * or more contributor license agreements. See the NOTICE file
  92412. * distributed with this work for additional information
  92413. * regarding copyright ownership. The ASF licenses this file
  92414. * to you under the Apache License, Version 2.0 (the
  92415. * "License"); you may not use this file except in compliance
  92416. * with the License. You may obtain a copy of the License at
  92417. *
  92418. * http://www.apache.org/licenses/LICENSE-2.0
  92419. *
  92420. * Unless required by applicable law or agreed to in writing,
  92421. * software distributed under the License is distributed on an
  92422. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92423. * KIND, either express or implied. See the License for the
  92424. * specific language governing permissions and limitations
  92425. * under the License.
  92426. */
  92427. /**
  92428. * AUTO-GENERATED FILE. DO NOT MODIFY.
  92429. */
  92430. /*
  92431. * Licensed to the Apache Software Foundation (ASF) under one
  92432. * or more contributor license agreements. See the NOTICE file
  92433. * distributed with this work for additional information
  92434. * regarding copyright ownership. The ASF licenses this file
  92435. * to you under the Apache License, Version 2.0 (the
  92436. * "License"); you may not use this file except in compliance
  92437. * with the License. You may obtain a copy of the License at
  92438. *
  92439. * http://www.apache.org/licenses/LICENSE-2.0
  92440. *
  92441. * Unless required by applicable law or agreed to in writing,
  92442. * software distributed under the License is distributed on an
  92443. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92444. * KIND, either express or implied. See the License for the
  92445. * specific language governing permissions and limitations
  92446. * under the License.
  92447. */
  92448. var RestoreOption =
  92449. /** @class */
  92450. function (_super) {
  92451. __extends(RestoreOption, _super);
  92452. function RestoreOption() {
  92453. return _super !== null && _super.apply(this, arguments) || this;
  92454. }
  92455. RestoreOption.prototype.onclick = function (ecModel, api) {
  92456. clear$1(ecModel);
  92457. api.dispatchAction({
  92458. type: 'restore',
  92459. from: this.uid
  92460. });
  92461. };
  92462. RestoreOption.getDefaultOption = function (ecModel) {
  92463. var defaultOption = {
  92464. show: true,
  92465. // eslint-disable-next-line
  92466. 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',
  92467. title: ecModel.getLocale(['toolbox', 'restore', 'title'])
  92468. };
  92469. return defaultOption;
  92470. };
  92471. return RestoreOption;
  92472. }(ToolboxFeature); // TODO: SELF REGISTERED.
  92473. registerAction({
  92474. type: 'restore',
  92475. event: 'restore',
  92476. update: 'prepareAndUpdate'
  92477. }, function (payload, ecModel) {
  92478. ecModel.resetOption('recreate');
  92479. });
  92480. /*
  92481. * Licensed to the Apache Software Foundation (ASF) under one
  92482. * or more contributor license agreements. See the NOTICE file
  92483. * distributed with this work for additional information
  92484. * regarding copyright ownership. The ASF licenses this file
  92485. * to you under the Apache License, Version 2.0 (the
  92486. * "License"); you may not use this file except in compliance
  92487. * with the License. You may obtain a copy of the License at
  92488. *
  92489. * http://www.apache.org/licenses/LICENSE-2.0
  92490. *
  92491. * Unless required by applicable law or agreed to in writing,
  92492. * software distributed under the License is distributed on an
  92493. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92494. * KIND, either express or implied. See the License for the
  92495. * specific language governing permissions and limitations
  92496. * under the License.
  92497. */
  92498. /**
  92499. * AUTO-GENERATED FILE. DO NOT MODIFY.
  92500. */
  92501. /*
  92502. * Licensed to the Apache Software Foundation (ASF) under one
  92503. * or more contributor license agreements. See the NOTICE file
  92504. * distributed with this work for additional information
  92505. * regarding copyright ownership. The ASF licenses this file
  92506. * to you under the Apache License, Version 2.0 (the
  92507. * "License"); you may not use this file except in compliance
  92508. * with the License. You may obtain a copy of the License at
  92509. *
  92510. * http://www.apache.org/licenses/LICENSE-2.0
  92511. *
  92512. * Unless required by applicable law or agreed to in writing,
  92513. * software distributed under the License is distributed on an
  92514. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92515. * KIND, either express or implied. See the License for the
  92516. * specific language governing permissions and limitations
  92517. * under the License.
  92518. */
  92519. var each$17 = each$1;
  92520. var DATA_ZOOM_ID_BASE = makeInternalComponentId('toolbox-dataZoom_');
  92521. var DataZoomFeature =
  92522. /** @class */
  92523. function (_super) {
  92524. __extends(DataZoomFeature, _super);
  92525. function DataZoomFeature() {
  92526. return _super !== null && _super.apply(this, arguments) || this;
  92527. }
  92528. DataZoomFeature.prototype.render = function (featureModel, ecModel, api, payload) {
  92529. if (!this._brushController) {
  92530. this._brushController = new BrushController(api.getZr());
  92531. this._brushController.on('brush', bind(this._onBrush, this)).mount();
  92532. }
  92533. updateZoomBtnStatus(featureModel, ecModel, this, payload, api);
  92534. updateBackBtnStatus(featureModel, ecModel);
  92535. };
  92536. DataZoomFeature.prototype.onclick = function (ecModel, api, type) {
  92537. handlers$1[type].call(this);
  92538. };
  92539. DataZoomFeature.prototype.remove = function (ecModel, api) {
  92540. this._brushController && this._brushController.unmount();
  92541. };
  92542. DataZoomFeature.prototype.dispose = function (ecModel, api) {
  92543. this._brushController && this._brushController.dispose();
  92544. };
  92545. DataZoomFeature.prototype._onBrush = function (eventParam) {
  92546. var areas = eventParam.areas;
  92547. if (!eventParam.isEnd || !areas.length) {
  92548. return;
  92549. }
  92550. var snapshot = {};
  92551. var ecModel = this.ecModel;
  92552. this._brushController.updateCovers([]); // remove cover
  92553. var brushTargetManager = new BrushTargetManager(makeAxisFinder(this.model), ecModel, {
  92554. include: ['grid']
  92555. });
  92556. brushTargetManager.matchOutputRanges(areas, ecModel, function (area, coordRange, coordSys) {
  92557. if (coordSys.type !== 'cartesian2d') {
  92558. return;
  92559. }
  92560. var brushType = area.brushType;
  92561. if (brushType === 'rect') {
  92562. setBatch('x', coordSys, coordRange[0]);
  92563. setBatch('y', coordSys, coordRange[1]);
  92564. } else {
  92565. setBatch({
  92566. lineX: 'x',
  92567. lineY: 'y'
  92568. }[brushType], coordSys, coordRange);
  92569. }
  92570. });
  92571. push(ecModel, snapshot);
  92572. this._dispatchZoomAction(snapshot);
  92573. function setBatch(dimName, coordSys, minMax) {
  92574. var axis = coordSys.getAxis(dimName);
  92575. var axisModel = axis.model;
  92576. var dataZoomModel = findDataZoom(dimName, axisModel, ecModel); // Restrict range.
  92577. var minMaxSpan = dataZoomModel.findRepresentativeAxisProxy(axisModel).getMinMaxSpan();
  92578. if (minMaxSpan.minValueSpan != null || minMaxSpan.maxValueSpan != null) {
  92579. minMax = sliderMove(0, minMax.slice(), axis.scale.getExtent(), 0, minMaxSpan.minValueSpan, minMaxSpan.maxValueSpan);
  92580. }
  92581. dataZoomModel && (snapshot[dataZoomModel.id] = {
  92582. dataZoomId: dataZoomModel.id,
  92583. startValue: minMax[0],
  92584. endValue: minMax[1]
  92585. });
  92586. }
  92587. function findDataZoom(dimName, axisModel, ecModel) {
  92588. var found;
  92589. ecModel.eachComponent({
  92590. mainType: 'dataZoom',
  92591. subType: 'select'
  92592. }, function (dzModel) {
  92593. var has = dzModel.getAxisModel(dimName, axisModel.componentIndex);
  92594. has && (found = dzModel);
  92595. });
  92596. return found;
  92597. }
  92598. };
  92599. DataZoomFeature.prototype._dispatchZoomAction = function (snapshot) {
  92600. var batch = []; // Convert from hash map to array.
  92601. each$17(snapshot, function (batchItem, dataZoomId) {
  92602. batch.push(clone(batchItem));
  92603. });
  92604. batch.length && this.api.dispatchAction({
  92605. type: 'dataZoom',
  92606. from: this.uid,
  92607. batch: batch
  92608. });
  92609. };
  92610. DataZoomFeature.getDefaultOption = function (ecModel) {
  92611. var defaultOption = {
  92612. show: true,
  92613. filterMode: 'filter',
  92614. // Icon group
  92615. icon: {
  92616. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  92617. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  92618. },
  92619. // `zoom`, `back`
  92620. title: ecModel.getLocale(['toolbox', 'dataZoom', 'title']),
  92621. brushStyle: {
  92622. borderWidth: 0,
  92623. color: 'rgba(210,219,238,0.2)'
  92624. }
  92625. };
  92626. return defaultOption;
  92627. };
  92628. return DataZoomFeature;
  92629. }(ToolboxFeature);
  92630. var handlers$1 = {
  92631. zoom: function () {
  92632. var nextActive = !this._isZoomActive;
  92633. this.api.dispatchAction({
  92634. type: 'takeGlobalCursor',
  92635. key: 'dataZoomSelect',
  92636. dataZoomSelectActive: nextActive
  92637. });
  92638. },
  92639. back: function () {
  92640. this._dispatchZoomAction(pop(this.ecModel));
  92641. }
  92642. };
  92643. function makeAxisFinder(dzFeatureModel) {
  92644. var setting = {
  92645. xAxisIndex: dzFeatureModel.get('xAxisIndex', true),
  92646. yAxisIndex: dzFeatureModel.get('yAxisIndex', true),
  92647. xAxisId: dzFeatureModel.get('xAxisId', true),
  92648. yAxisId: dzFeatureModel.get('yAxisId', true)
  92649. }; // If both `xAxisIndex` `xAxisId` not set, it means 'all'.
  92650. // If both `yAxisIndex` `yAxisId` not set, it means 'all'.
  92651. // Some old cases set like this below to close yAxis control but leave xAxis control:
  92652. // `{ feature: { dataZoom: { yAxisIndex: false } }`.
  92653. if (setting.xAxisIndex == null && setting.xAxisId == null) {
  92654. setting.xAxisIndex = 'all';
  92655. }
  92656. if (setting.yAxisIndex == null && setting.yAxisId == null) {
  92657. setting.yAxisIndex = 'all';
  92658. }
  92659. return setting;
  92660. }
  92661. function updateBackBtnStatus(featureModel, ecModel) {
  92662. featureModel.setIconStatus('back', count(ecModel) > 1 ? 'emphasis' : 'normal');
  92663. }
  92664. function updateZoomBtnStatus(featureModel, ecModel, view, payload, api) {
  92665. var zoomActive = view._isZoomActive;
  92666. if (payload && payload.type === 'takeGlobalCursor') {
  92667. zoomActive = payload.key === 'dataZoomSelect' ? payload.dataZoomSelectActive : false;
  92668. }
  92669. view._isZoomActive = zoomActive;
  92670. featureModel.setIconStatus('zoom', zoomActive ? 'emphasis' : 'normal');
  92671. var brushTargetManager = new BrushTargetManager(makeAxisFinder(featureModel), ecModel, {
  92672. include: ['grid']
  92673. });
  92674. var panels = brushTargetManager.makePanelOpts(api, function (targetInfo) {
  92675. return targetInfo.xAxisDeclared && !targetInfo.yAxisDeclared ? 'lineX' : !targetInfo.xAxisDeclared && targetInfo.yAxisDeclared ? 'lineY' : 'rect';
  92676. });
  92677. view._brushController.setPanels(panels).enableBrush(zoomActive && panels.length ? {
  92678. brushType: 'auto',
  92679. brushStyle: featureModel.getModel('brushStyle').getItemStyle()
  92680. } : false);
  92681. }
  92682. registerInternalOptionCreator('dataZoom', function (ecModel) {
  92683. var toolboxModel = ecModel.getComponent('toolbox', 0);
  92684. if (!toolboxModel) {
  92685. return;
  92686. }
  92687. var dzFeatureModel = toolboxModel.getModel(['feature', 'dataZoom']);
  92688. var dzOptions = [];
  92689. var finder = makeAxisFinder(dzFeatureModel);
  92690. var finderResult = parseFinder(ecModel, finder);
  92691. each$17(finderResult.xAxisModels, function (axisModel) {
  92692. return buildInternalOptions(axisModel, 'xAxis', 'xAxisIndex');
  92693. });
  92694. each$17(finderResult.yAxisModels, function (axisModel) {
  92695. return buildInternalOptions(axisModel, 'yAxis', 'yAxisIndex');
  92696. });
  92697. function buildInternalOptions(axisModel, axisMainType, axisIndexPropName) {
  92698. var axisIndex = axisModel.componentIndex;
  92699. var newOpt = {
  92700. type: 'select',
  92701. $fromToolbox: true,
  92702. // Default to be filter
  92703. filterMode: dzFeatureModel.get('filterMode', true) || 'filter',
  92704. // Id for merge mapping.
  92705. id: DATA_ZOOM_ID_BASE + axisMainType + axisIndex
  92706. };
  92707. newOpt[axisIndexPropName] = axisIndex;
  92708. dzOptions.push(newOpt);
  92709. }
  92710. return dzOptions;
  92711. });
  92712. /*
  92713. * Licensed to the Apache Software Foundation (ASF) under one
  92714. * or more contributor license agreements. See the NOTICE file
  92715. * distributed with this work for additional information
  92716. * regarding copyright ownership. The ASF licenses this file
  92717. * to you under the Apache License, Version 2.0 (the
  92718. * "License"); you may not use this file except in compliance
  92719. * with the License. You may obtain a copy of the License at
  92720. *
  92721. * http://www.apache.org/licenses/LICENSE-2.0
  92722. *
  92723. * Unless required by applicable law or agreed to in writing,
  92724. * software distributed under the License is distributed on an
  92725. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92726. * KIND, either express or implied. See the License for the
  92727. * specific language governing permissions and limitations
  92728. * under the License.
  92729. */
  92730. /**
  92731. * AUTO-GENERATED FILE. DO NOT MODIFY.
  92732. */
  92733. /*
  92734. * Licensed to the Apache Software Foundation (ASF) under one
  92735. * or more contributor license agreements. See the NOTICE file
  92736. * distributed with this work for additional information
  92737. * regarding copyright ownership. The ASF licenses this file
  92738. * to you under the Apache License, Version 2.0 (the
  92739. * "License"); you may not use this file except in compliance
  92740. * with the License. You may obtain a copy of the License at
  92741. *
  92742. * http://www.apache.org/licenses/LICENSE-2.0
  92743. *
  92744. * Unless required by applicable law or agreed to in writing,
  92745. * software distributed under the License is distributed on an
  92746. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92747. * KIND, either express or implied. See the License for the
  92748. * specific language governing permissions and limitations
  92749. * under the License.
  92750. */
  92751. function install$47(registers) {
  92752. registers.registerComponentModel(ToolboxModel);
  92753. registers.registerComponentView(ToolboxView);
  92754. registerFeature('saveAsImage', SaveAsImage);
  92755. registerFeature('magicType', MagicType);
  92756. registerFeature('dataView', DataView);
  92757. registerFeature('dataZoom', DataZoomFeature);
  92758. registerFeature('restore', RestoreOption);
  92759. use(install$48);
  92760. }
  92761. /*
  92762. * Licensed to the Apache Software Foundation (ASF) under one
  92763. * or more contributor license agreements. See the NOTICE file
  92764. * distributed with this work for additional information
  92765. * regarding copyright ownership. The ASF licenses this file
  92766. * to you under the Apache License, Version 2.0 (the
  92767. * "License"); you may not use this file except in compliance
  92768. * with the License. You may obtain a copy of the License at
  92769. *
  92770. * http://www.apache.org/licenses/LICENSE-2.0
  92771. *
  92772. * Unless required by applicable law or agreed to in writing,
  92773. * software distributed under the License is distributed on an
  92774. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92775. * KIND, either express or implied. See the License for the
  92776. * specific language governing permissions and limitations
  92777. * under the License.
  92778. */
  92779. /**
  92780. * AUTO-GENERATED FILE. DO NOT MODIFY.
  92781. */
  92782. /*
  92783. * Licensed to the Apache Software Foundation (ASF) under one
  92784. * or more contributor license agreements. See the NOTICE file
  92785. * distributed with this work for additional information
  92786. * regarding copyright ownership. The ASF licenses this file
  92787. * to you under the Apache License, Version 2.0 (the
  92788. * "License"); you may not use this file except in compliance
  92789. * with the License. You may obtain a copy of the License at
  92790. *
  92791. * http://www.apache.org/licenses/LICENSE-2.0
  92792. *
  92793. * Unless required by applicable law or agreed to in writing,
  92794. * software distributed under the License is distributed on an
  92795. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92796. * KIND, either express or implied. See the License for the
  92797. * specific language governing permissions and limitations
  92798. * under the License.
  92799. */
  92800. use(install$47);
  92801. /*
  92802. * Licensed to the Apache Software Foundation (ASF) under one
  92803. * or more contributor license agreements. See the NOTICE file
  92804. * distributed with this work for additional information
  92805. * regarding copyright ownership. The ASF licenses this file
  92806. * to you under the Apache License, Version 2.0 (the
  92807. * "License"); you may not use this file except in compliance
  92808. * with the License. You may obtain a copy of the License at
  92809. *
  92810. * http://www.apache.org/licenses/LICENSE-2.0
  92811. *
  92812. * Unless required by applicable law or agreed to in writing,
  92813. * software distributed under the License is distributed on an
  92814. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92815. * KIND, either express or implied. See the License for the
  92816. * specific language governing permissions and limitations
  92817. * under the License.
  92818. */
  92819. /**
  92820. * AUTO-GENERATED FILE. DO NOT MODIFY.
  92821. */
  92822. /*
  92823. * Licensed to the Apache Software Foundation (ASF) under one
  92824. * or more contributor license agreements. See the NOTICE file
  92825. * distributed with this work for additional information
  92826. * regarding copyright ownership. The ASF licenses this file
  92827. * to you under the Apache License, Version 2.0 (the
  92828. * "License"); you may not use this file except in compliance
  92829. * with the License. You may obtain a copy of the License at
  92830. *
  92831. * http://www.apache.org/licenses/LICENSE-2.0
  92832. *
  92833. * Unless required by applicable law or agreed to in writing,
  92834. * software distributed under the License is distributed on an
  92835. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  92836. * KIND, either express or implied. See the License for the
  92837. * specific language governing permissions and limitations
  92838. * under the License.
  92839. */
  92840. var inner$20 = makeInner();
  92841. var _nonShapeGraphicElements = {
  92842. // Reserved but not supported in graphic component.
  92843. path: null,
  92844. compoundPath: null,
  92845. // Supported in graphic component.
  92846. group: Group,
  92847. image: ZRImage,
  92848. text: ZRText
  92849. }; // ------------------------
  92850. // Preprocessor
  92851. // ------------------------
  92852. var preprocessor = function (option) {
  92853. var graphicOption = option.graphic; // Convert
  92854. // {graphic: [{left: 10, type: 'circle'}, ...]}
  92855. // or
  92856. // {graphic: {left: 10, type: 'circle'}}
  92857. // to
  92858. // {graphic: [{elements: [{left: 10, type: 'circle'}, ...]}]}
  92859. if (isArray(graphicOption)) {
  92860. if (!graphicOption[0] || !graphicOption[0].elements) {
  92861. option.graphic = [{
  92862. elements: graphicOption
  92863. }];
  92864. } else {
  92865. // Only one graphic instance can be instantiated. (We dont
  92866. // want that too many views are created in echarts._viewMap)
  92867. option.graphic = [option.graphic[0]];
  92868. }
  92869. } else if (graphicOption && !graphicOption.elements) {
  92870. option.graphic = [{
  92871. elements: [graphicOption]
  92872. }];
  92873. }
  92874. };
  92875. var GraphicComponentModel =
  92876. /** @class */
  92877. function (_super) {
  92878. __extends(GraphicComponentModel, _super);
  92879. function GraphicComponentModel() {
  92880. var _this = _super !== null && _super.apply(this, arguments) || this;
  92881. _this.type = GraphicComponentModel.type;
  92882. _this.preventAutoZ = true;
  92883. return _this;
  92884. }
  92885. GraphicComponentModel.prototype.mergeOption = function (option, ecModel) {
  92886. // Prevent default merge to elements
  92887. var elements = this.option.elements;
  92888. this.option.elements = null;
  92889. _super.prototype.mergeOption.call(this, option, ecModel);
  92890. this.option.elements = elements;
  92891. };
  92892. GraphicComponentModel.prototype.optionUpdated = function (newOption, isInit) {
  92893. var thisOption = this.option;
  92894. var newList = (isInit ? thisOption : newOption).elements;
  92895. var existList = thisOption.elements = isInit ? [] : thisOption.elements;
  92896. var flattenedList = [];
  92897. this._flatten(newList, flattenedList, null);
  92898. var mappingResult = mappingToExists(existList, flattenedList, 'normalMerge'); // Clear elOptionsToUpdate
  92899. var elOptionsToUpdate = this._elOptionsToUpdate = [];
  92900. each$1(mappingResult, function (resultItem, index) {
  92901. var newElOption = resultItem.newOption;
  92902. {
  92903. assert$1(isObject$1(newElOption) || resultItem.existing, 'Empty graphic option definition');
  92904. }
  92905. if (!newElOption) {
  92906. return;
  92907. }
  92908. elOptionsToUpdate.push(newElOption);
  92909. setKeyInfoToNewElOption(resultItem, newElOption);
  92910. mergeNewElOptionToExist(existList, index, newElOption);
  92911. setLayoutInfoToExist(existList[index], newElOption);
  92912. }, this); // Clean
  92913. for (var i = existList.length - 1; i >= 0; i--) {
  92914. if (existList[i] == null) {
  92915. existList.splice(i, 1);
  92916. } else {
  92917. // $action should be volatile, otherwise option gotten from
  92918. // `getOption` will contain unexpected $action.
  92919. delete existList[i].$action;
  92920. }
  92921. }
  92922. };
  92923. /**
  92924. * Convert
  92925. * [{
  92926. * type: 'group',
  92927. * id: 'xx',
  92928. * children: [{type: 'circle'}, {type: 'polygon'}]
  92929. * }]
  92930. * to
  92931. * [
  92932. * {type: 'group', id: 'xx'},
  92933. * {type: 'circle', parentId: 'xx'},
  92934. * {type: 'polygon', parentId: 'xx'}
  92935. * ]
  92936. */
  92937. GraphicComponentModel.prototype._flatten = function (optionList, result, parentOption) {
  92938. each$1(optionList, function (option) {
  92939. if (!option) {
  92940. return;
  92941. }
  92942. if (parentOption) {
  92943. option.parentOption = parentOption;
  92944. }
  92945. result.push(option);
  92946. var children = option.children;
  92947. if (option.type === 'group' && children) {
  92948. this._flatten(children, result, option);
  92949. } // Deleting for JSON output, and for not affecting group creation.
  92950. delete option.children;
  92951. }, this);
  92952. }; // FIXME
  92953. // Pass to view using payload? setOption has a payload?
  92954. GraphicComponentModel.prototype.useElOptionsToUpdate = function () {
  92955. var els = this._elOptionsToUpdate; // Clear to avoid render duplicately when zooming.
  92956. this._elOptionsToUpdate = null;
  92957. return els;
  92958. };
  92959. GraphicComponentModel.type = 'graphic';
  92960. GraphicComponentModel.defaultOption = {
  92961. elements: [] // parentId: null
  92962. };
  92963. return GraphicComponentModel;
  92964. }(ComponentModel); // ------------------------
  92965. // View
  92966. // ------------------------
  92967. var GraphicComponentView =
  92968. /** @class */
  92969. function (_super) {
  92970. __extends(GraphicComponentView, _super);
  92971. function GraphicComponentView() {
  92972. var _this = _super !== null && _super.apply(this, arguments) || this;
  92973. _this.type = GraphicComponentView.type;
  92974. return _this;
  92975. }
  92976. GraphicComponentView.prototype.init = function () {
  92977. this._elMap = createHashMap();
  92978. };
  92979. GraphicComponentView.prototype.render = function (graphicModel, ecModel, api) {
  92980. // Having leveraged between use cases and algorithm complexity, a very
  92981. // simple layout mechanism is used:
  92982. // The size(width/height) can be determined by itself or its parent (not
  92983. // implemented yet), but can not by its children. (Top-down travel)
  92984. // The location(x/y) can be determined by the bounding rect of itself
  92985. // (can including its descendants or not) and the size of its parent.
  92986. // (Bottom-up travel)
  92987. // When `chart.clear()` or `chart.setOption({...}, true)` with the same id,
  92988. // view will be reused.
  92989. if (graphicModel !== this._lastGraphicModel) {
  92990. this._clear();
  92991. }
  92992. this._lastGraphicModel = graphicModel;
  92993. this._updateElements(graphicModel);
  92994. this._relocate(graphicModel, api);
  92995. };
  92996. /**
  92997. * Update graphic elements.
  92998. */
  92999. GraphicComponentView.prototype._updateElements = function (graphicModel) {
  93000. var elOptionsToUpdate = graphicModel.useElOptionsToUpdate();
  93001. if (!elOptionsToUpdate) {
  93002. return;
  93003. }
  93004. var elMap = this._elMap;
  93005. var rootGroup = this.group; // Top-down tranverse to assign graphic settings to each elements.
  93006. each$1(elOptionsToUpdate, function (elOption) {
  93007. var id = convertOptionIdName(elOption.id, null);
  93008. var elExisting = id != null ? elMap.get(id) : null;
  93009. var parentId = convertOptionIdName(elOption.parentId, null);
  93010. var targetElParent = parentId != null ? elMap.get(parentId) : rootGroup;
  93011. var elType = elOption.type;
  93012. var elOptionStyle = elOption.style;
  93013. if (elType === 'text' && elOptionStyle) {
  93014. // In top/bottom mode, textVerticalAlign should not be used, which cause
  93015. // inaccurately locating.
  93016. if (elOption.hv && elOption.hv[1]) {
  93017. elOptionStyle.textVerticalAlign = elOptionStyle.textBaseline = elOptionStyle.verticalAlign = elOptionStyle.align = null;
  93018. }
  93019. }
  93020. var textContentOption = elOption.textContent;
  93021. var textConfig = elOption.textConfig;
  93022. if (elOptionStyle && isEC4CompatibleStyle(elOptionStyle, elType, !!textConfig, !!textContentOption)) {
  93023. var convertResult = convertFromEC4CompatibleStyle(elOptionStyle, elType, true);
  93024. if (!textConfig && convertResult.textConfig) {
  93025. textConfig = elOption.textConfig = convertResult.textConfig;
  93026. }
  93027. if (!textContentOption && convertResult.textContent) {
  93028. textContentOption = convertResult.textContent;
  93029. }
  93030. } // Remove unnecessary props to avoid potential problems.
  93031. var elOptionCleaned = getCleanedElOption(elOption); // For simple, do not support parent change, otherwise reorder is needed.
  93032. {
  93033. elExisting && assert$1(targetElParent === elExisting.parent, 'Changing parent is not supported.');
  93034. }
  93035. var $action = elOption.$action || 'merge';
  93036. if ($action === 'merge') {
  93037. elExisting ? elExisting.attr(elOptionCleaned) : createEl$1(id, targetElParent, elOptionCleaned, elMap);
  93038. } else if ($action === 'replace') {
  93039. removeEl(elExisting, elMap);
  93040. createEl$1(id, targetElParent, elOptionCleaned, elMap);
  93041. } else if ($action === 'remove') {
  93042. removeEl(elExisting, elMap);
  93043. }
  93044. var el = elMap.get(id);
  93045. if (el && textContentOption) {
  93046. if ($action === 'merge') {
  93047. var textContentExisting = el.getTextContent();
  93048. textContentExisting ? textContentExisting.attr(textContentOption) : el.setTextContent(new ZRText(textContentOption));
  93049. } else if ($action === 'replace') {
  93050. el.setTextContent(new ZRText(textContentOption));
  93051. }
  93052. }
  93053. if (el) {
  93054. var elInner = inner$20(el);
  93055. elInner.__ecGraphicWidthOption = elOption.width;
  93056. elInner.__ecGraphicHeightOption = elOption.height;
  93057. setEventData(el, graphicModel, elOption);
  93058. setTooltipConfig({
  93059. el: el,
  93060. componentModel: graphicModel,
  93061. itemName: el.name,
  93062. itemTooltipOption: elOption.tooltip
  93063. });
  93064. }
  93065. });
  93066. };
  93067. /**
  93068. * Locate graphic elements.
  93069. */
  93070. GraphicComponentView.prototype._relocate = function (graphicModel, api) {
  93071. var elOptions = graphicModel.option.elements;
  93072. var rootGroup = this.group;
  93073. var elMap = this._elMap;
  93074. var apiWidth = api.getWidth();
  93075. var apiHeight = api.getHeight(); // Top-down to calculate percentage width/height of group
  93076. for (var i = 0; i < elOptions.length; i++) {
  93077. var elOption = elOptions[i];
  93078. var id = convertOptionIdName(elOption.id, null);
  93079. var el = id != null ? elMap.get(id) : null;
  93080. if (!el || !el.isGroup) {
  93081. continue;
  93082. }
  93083. var parentEl = el.parent;
  93084. var isParentRoot = parentEl === rootGroup; // Like 'position:absolut' in css, default 0.
  93085. var elInner = inner$20(el);
  93086. var parentElInner = inner$20(parentEl);
  93087. elInner.__ecGraphicWidth = parsePercent$1(elInner.__ecGraphicWidthOption, isParentRoot ? apiWidth : parentElInner.__ecGraphicWidth) || 0;
  93088. elInner.__ecGraphicHeight = parsePercent$1(elInner.__ecGraphicHeightOption, isParentRoot ? apiHeight : parentElInner.__ecGraphicHeight) || 0;
  93089. } // Bottom-up tranvese all elements (consider ec resize) to locate elements.
  93090. for (var i = elOptions.length - 1; i >= 0; i--) {
  93091. var elOption = elOptions[i];
  93092. var id = convertOptionIdName(elOption.id, null);
  93093. var el = id != null ? elMap.get(id) : null;
  93094. if (!el) {
  93095. continue;
  93096. }
  93097. var parentEl = el.parent;
  93098. var parentElInner = inner$20(parentEl);
  93099. var containerInfo = parentEl === rootGroup ? {
  93100. width: apiWidth,
  93101. height: apiHeight
  93102. } : {
  93103. width: parentElInner.__ecGraphicWidth,
  93104. height: parentElInner.__ecGraphicHeight
  93105. }; // PENDING
  93106. // Currently, when `bounding: 'all'`, the union bounding rect of the group
  93107. // does not include the rect of [0, 0, group.width, group.height], which
  93108. // is probably weird for users. Should we make a break change for it?
  93109. positionElement(el, elOption, containerInfo, null, {
  93110. hv: elOption.hv,
  93111. boundingMode: elOption.bounding
  93112. });
  93113. }
  93114. };
  93115. /**
  93116. * Clear all elements.
  93117. */
  93118. GraphicComponentView.prototype._clear = function () {
  93119. var elMap = this._elMap;
  93120. elMap.each(function (el) {
  93121. removeEl(el, elMap);
  93122. });
  93123. this._elMap = createHashMap();
  93124. };
  93125. GraphicComponentView.prototype.dispose = function () {
  93126. this._clear();
  93127. };
  93128. GraphicComponentView.type = 'graphic';
  93129. return GraphicComponentView;
  93130. }(ComponentView);
  93131. function createEl$1(id, targetElParent, elOption, elMap) {
  93132. var graphicType = elOption.type;
  93133. {
  93134. assert$1(graphicType, 'graphic type MUST be set');
  93135. }
  93136. var Clz = hasOwn(_nonShapeGraphicElements, graphicType) // Those graphic elements are not shapes. They should not be
  93137. // overwritten by users, so do them first.
  93138. ? _nonShapeGraphicElements[graphicType] : getShapeClass(graphicType);
  93139. {
  93140. assert$1(Clz, 'graphic type can not be found');
  93141. }
  93142. var el = new Clz(elOption);
  93143. targetElParent.add(el);
  93144. elMap.set(id, el);
  93145. inner$20(el).__ecGraphicId = id;
  93146. }
  93147. function removeEl(elExisting, elMap) {
  93148. var existElParent = elExisting && elExisting.parent;
  93149. if (existElParent) {
  93150. elExisting.type === 'group' && elExisting.traverse(function (el) {
  93151. removeEl(el, elMap);
  93152. });
  93153. elMap.removeKey(inner$20(elExisting).__ecGraphicId);
  93154. existElParent.remove(elExisting);
  93155. }
  93156. } // Remove unnecessary props to avoid potential problems.
  93157. function getCleanedElOption(elOption) {
  93158. elOption = extend({}, elOption);
  93159. each$1(['id', 'parentId', '$action', 'hv', 'bounding', 'textContent'].concat(LOCATION_PARAMS), function (name) {
  93160. delete elOption[name];
  93161. });
  93162. return elOption;
  93163. }
  93164. function isSetLoc(obj, props) {
  93165. var isSet;
  93166. each$1(props, function (prop) {
  93167. obj[prop] != null && obj[prop] !== 'auto' && (isSet = true);
  93168. });
  93169. return isSet;
  93170. }
  93171. function setKeyInfoToNewElOption(resultItem, newElOption) {
  93172. var existElOption = resultItem.existing; // Set id and type after id assigned.
  93173. newElOption.id = resultItem.keyInfo.id;
  93174. !newElOption.type && existElOption && (newElOption.type = existElOption.type); // Set parent id if not specified
  93175. if (newElOption.parentId == null) {
  93176. var newElParentOption = newElOption.parentOption;
  93177. if (newElParentOption) {
  93178. newElOption.parentId = newElParentOption.id;
  93179. } else if (existElOption) {
  93180. newElOption.parentId = existElOption.parentId;
  93181. }
  93182. } // Clear
  93183. newElOption.parentOption = null;
  93184. }
  93185. function mergeNewElOptionToExist(existList, index, newElOption) {
  93186. // Update existing options, for `getOption` feature.
  93187. var newElOptCopy = extend({}, newElOption);
  93188. var existElOption = existList[index];
  93189. var $action = newElOption.$action || 'merge';
  93190. if ($action === 'merge') {
  93191. if (existElOption) {
  93192. {
  93193. var newType = newElOption.type;
  93194. assert$1(!newType || existElOption.type === newType, 'Please set $action: "replace" to change `type`');
  93195. } // We can ensure that newElOptCopy and existElOption are not
  93196. // the same object, so `merge` will not change newElOptCopy.
  93197. merge(existElOption, newElOptCopy, true); // Rigid body, use ignoreSize.
  93198. mergeLayoutParam(existElOption, newElOptCopy, {
  93199. ignoreSize: true
  93200. }); // Will be used in render.
  93201. copyLayoutParams(newElOption, existElOption);
  93202. } else {
  93203. existList[index] = newElOptCopy;
  93204. }
  93205. } else if ($action === 'replace') {
  93206. existList[index] = newElOptCopy;
  93207. } else if ($action === 'remove') {
  93208. // null will be cleaned later.
  93209. existElOption && (existList[index] = null);
  93210. }
  93211. }
  93212. function setLayoutInfoToExist(existItem, newElOption) {
  93213. if (!existItem) {
  93214. return;
  93215. }
  93216. existItem.hv = newElOption.hv = [// Rigid body, dont care `width`.
  93217. isSetLoc(newElOption, ['left', 'right']), // Rigid body, dont care `height`.
  93218. isSetLoc(newElOption, ['top', 'bottom'])]; // Give default group size. Otherwise layout error may occur.
  93219. if (existItem.type === 'group') {
  93220. var existingGroupOpt = existItem;
  93221. var newGroupOpt = newElOption;
  93222. existingGroupOpt.width == null && (existingGroupOpt.width = newGroupOpt.width = 0);
  93223. existingGroupOpt.height == null && (existingGroupOpt.height = newGroupOpt.height = 0);
  93224. }
  93225. }
  93226. function setEventData(el, graphicModel, elOption) {
  93227. var eventData = getECData(el).eventData; // Simple optimize for large amount of elements that no need event.
  93228. if (!el.silent && !el.ignore && !eventData) {
  93229. eventData = getECData(el).eventData = {
  93230. componentType: 'graphic',
  93231. componentIndex: graphicModel.componentIndex,
  93232. name: el.name
  93233. };
  93234. } // `elOption.info` enables user to mount some info on
  93235. // elements and use them in event handlers.
  93236. if (eventData) {
  93237. eventData.info = elOption.info;
  93238. }
  93239. }
  93240. function install$49(registers) {
  93241. registers.registerComponentModel(GraphicComponentModel);
  93242. registers.registerComponentView(GraphicComponentView);
  93243. registers.registerPreprocessor(preprocessor);
  93244. }
  93245. /*
  93246. * Licensed to the Apache Software Foundation (ASF) under one
  93247. * or more contributor license agreements. See the NOTICE file
  93248. * distributed with this work for additional information
  93249. * regarding copyright ownership. The ASF licenses this file
  93250. * to you under the Apache License, Version 2.0 (the
  93251. * "License"); you may not use this file except in compliance
  93252. * with the License. You may obtain a copy of the License at
  93253. *
  93254. * http://www.apache.org/licenses/LICENSE-2.0
  93255. *
  93256. * Unless required by applicable law or agreed to in writing,
  93257. * software distributed under the License is distributed on an
  93258. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  93259. * KIND, either express or implied. See the License for the
  93260. * specific language governing permissions and limitations
  93261. * under the License.
  93262. */
  93263. /**
  93264. * AUTO-GENERATED FILE. DO NOT MODIFY.
  93265. */
  93266. /*
  93267. * Licensed to the Apache Software Foundation (ASF) under one
  93268. * or more contributor license agreements. See the NOTICE file
  93269. * distributed with this work for additional information
  93270. * regarding copyright ownership. The ASF licenses this file
  93271. * to you under the Apache License, Version 2.0 (the
  93272. * "License"); you may not use this file except in compliance
  93273. * with the License. You may obtain a copy of the License at
  93274. *
  93275. * http://www.apache.org/licenses/LICENSE-2.0
  93276. *
  93277. * Unless required by applicable law or agreed to in writing,
  93278. * software distributed under the License is distributed on an
  93279. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  93280. * KIND, either express or implied. See the License for the
  93281. * specific language governing permissions and limitations
  93282. * under the License.
  93283. */
  93284. use(install$49);
  93285. function createElement(name) {
  93286. return document.createElementNS('http://www.w3.org/2000/svg', name);
  93287. }
  93288. function diff(oldArr, newArr, equals) {
  93289. if (!equals) {
  93290. equals = function (a, b) {
  93291. return a === b;
  93292. };
  93293. }
  93294. oldArr = oldArr.slice();
  93295. newArr = newArr.slice();
  93296. var newLen = newArr.length;
  93297. var oldLen = oldArr.length;
  93298. var editLength = 1;
  93299. var maxEditLength = newLen + oldLen;
  93300. var bestPath = [{
  93301. newPos: -1,
  93302. components: []
  93303. }];
  93304. var oldPos = extractCommon(bestPath[0], newArr, oldArr, 0, equals);
  93305. if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  93306. var indices = [];
  93307. for (var i = 0; i < newArr.length; i++) {
  93308. indices.push(i);
  93309. }
  93310. return [{
  93311. indices: indices,
  93312. count: newArr.length,
  93313. added: false,
  93314. removed: false
  93315. }];
  93316. }
  93317. function execEditLength() {
  93318. for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
  93319. var basePath;
  93320. var addPath = bestPath[diagonalPath - 1];
  93321. var removePath = bestPath[diagonalPath + 1];
  93322. var oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
  93323. if (addPath) {
  93324. bestPath[diagonalPath - 1] = undefined;
  93325. }
  93326. var canAdd = addPath && addPath.newPos + 1 < newLen;
  93327. var canRemove = removePath && 0 <= oldPos && oldPos < oldLen;
  93328. if (!canAdd && !canRemove) {
  93329. bestPath[diagonalPath] = undefined;
  93330. continue;
  93331. }
  93332. if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
  93333. basePath = clonePath(removePath);
  93334. pushComponent(basePath.components, false, true);
  93335. } else {
  93336. basePath = addPath;
  93337. basePath.newPos++;
  93338. pushComponent(basePath.components, true, false);
  93339. }
  93340. oldPos = extractCommon(basePath, newArr, oldArr, diagonalPath, equals);
  93341. if (basePath.newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
  93342. return buildValues(basePath.components);
  93343. } else {
  93344. bestPath[diagonalPath] = basePath;
  93345. }
  93346. }
  93347. editLength++;
  93348. }
  93349. while (editLength <= maxEditLength) {
  93350. var ret = execEditLength();
  93351. if (ret) {
  93352. return ret;
  93353. }
  93354. }
  93355. }
  93356. function extractCommon(basePath, newArr, oldArr, diagonalPath, equals) {
  93357. var newLen = newArr.length;
  93358. var oldLen = oldArr.length;
  93359. var newPos = basePath.newPos;
  93360. var oldPos = newPos - diagonalPath;
  93361. var commonCount = 0;
  93362. while (newPos + 1 < newLen && oldPos + 1 < oldLen && equals(newArr[newPos + 1], oldArr[oldPos + 1])) {
  93363. newPos++;
  93364. oldPos++;
  93365. commonCount++;
  93366. }
  93367. if (commonCount) {
  93368. basePath.components.push({
  93369. count: commonCount,
  93370. added: false,
  93371. removed: false,
  93372. indices: []
  93373. });
  93374. }
  93375. basePath.newPos = newPos;
  93376. return oldPos;
  93377. }
  93378. function pushComponent(components, added, removed) {
  93379. var last = components[components.length - 1];
  93380. if (last && last.added === added && last.removed === removed) {
  93381. components[components.length - 1] = {
  93382. count: last.count + 1,
  93383. added: added,
  93384. removed: removed,
  93385. indices: []
  93386. };
  93387. } else {
  93388. components.push({
  93389. count: 1,
  93390. added: added,
  93391. removed: removed,
  93392. indices: []
  93393. });
  93394. }
  93395. }
  93396. function buildValues(components) {
  93397. var componentPos = 0;
  93398. var componentLen = components.length;
  93399. var newPos = 0;
  93400. var oldPos = 0;
  93401. for (; componentPos < componentLen; componentPos++) {
  93402. var component = components[componentPos];
  93403. if (!component.removed) {
  93404. var indices = [];
  93405. for (var i = newPos; i < newPos + component.count; i++) {
  93406. indices.push(i);
  93407. }
  93408. component.indices = indices;
  93409. newPos += component.count;
  93410. if (!component.added) {
  93411. oldPos += component.count;
  93412. }
  93413. } else {
  93414. for (var i = oldPos; i < oldPos + component.count; i++) {
  93415. component.indices.push(i);
  93416. }
  93417. oldPos += component.count;
  93418. }
  93419. }
  93420. return components;
  93421. }
  93422. function clonePath(path) {
  93423. return {
  93424. newPos: path.newPos,
  93425. components: path.components.slice(0)
  93426. };
  93427. }
  93428. function arrayDiff(oldArr, newArr, equal) {
  93429. return diff(oldArr, newArr, equal);
  93430. }
  93431. var NONE = 'none';
  93432. var mathRound = Math.round;
  93433. var mathSin$4 = Math.sin;
  93434. var mathCos$4 = Math.cos;
  93435. var PI$8 = Math.PI;
  93436. var PI2$10 = Math.PI * 2;
  93437. var degree = 180 / PI$8;
  93438. var EPSILON$4 = 1e-4;
  93439. function round3(val) {
  93440. return mathRound(val * 1e3) / 1e3;
  93441. }
  93442. function round4(val) {
  93443. return mathRound(val * 1e4) / 1e4;
  93444. }
  93445. function isAroundZero$1(val) {
  93446. return val < EPSILON$4 && val > -EPSILON$4;
  93447. }
  93448. function pathHasFill(style) {
  93449. var fill = style.fill;
  93450. return fill != null && fill !== NONE;
  93451. }
  93452. function pathHasStroke(style) {
  93453. var stroke = style.stroke;
  93454. return stroke != null && stroke !== NONE;
  93455. }
  93456. function setTransform(svgEl, m) {
  93457. if (m) {
  93458. attr(svgEl, 'transform', 'matrix(' + round3(m[0]) + ',' + round3(m[1]) + ',' + round3(m[2]) + ',' + round3(m[3]) + ',' + round4(m[4]) + ',' + round4(m[5]) + ')');
  93459. }
  93460. }
  93461. function attr(el, key, val) {
  93462. if (!val || val.type !== 'linear' && val.type !== 'radial') {
  93463. el.setAttribute(key, val);
  93464. }
  93465. }
  93466. function attrXLink(el, key, val) {
  93467. el.setAttributeNS('http://www.w3.org/1999/xlink', key, val);
  93468. }
  93469. function attrXML(el, key, val) {
  93470. el.setAttributeNS('http://www.w3.org/XML/1998/namespace', key, val);
  93471. }
  93472. function bindStyle(svgEl, style, el) {
  93473. var opacity = style.opacity == null ? 1 : style.opacity;
  93474. if (el instanceof ZRImage) {
  93475. svgEl.style.opacity = opacity + '';
  93476. return;
  93477. }
  93478. if (pathHasFill(style)) {
  93479. var fill = style.fill;
  93480. fill = fill === 'transparent' ? NONE : fill;
  93481. attr(svgEl, 'fill', fill);
  93482. attr(svgEl, 'fill-opacity', (style.fillOpacity != null ? style.fillOpacity * opacity : opacity) + '');
  93483. } else {
  93484. attr(svgEl, 'fill', NONE);
  93485. }
  93486. if (pathHasStroke(style)) {
  93487. var stroke = style.stroke;
  93488. stroke = stroke === 'transparent' ? NONE : stroke;
  93489. attr(svgEl, 'stroke', stroke);
  93490. var strokeWidth = style.lineWidth;
  93491. var strokeScale_1 = style.strokeNoScale ? el.getLineScale() : 1;
  93492. attr(svgEl, 'stroke-width', (strokeScale_1 ? strokeWidth / strokeScale_1 : 0) + '');
  93493. attr(svgEl, 'paint-order', style.strokeFirst ? 'stroke' : 'fill');
  93494. attr(svgEl, 'stroke-opacity', (style.strokeOpacity != null ? style.strokeOpacity * opacity : opacity) + '');
  93495. var lineDash = style.lineDash && strokeWidth > 0 && normalizeLineDash(style.lineDash, strokeWidth);
  93496. if (lineDash) {
  93497. var lineDashOffset = style.lineDashOffset;
  93498. if (strokeScale_1 && strokeScale_1 !== 1) {
  93499. lineDash = map(lineDash, function (rawVal) {
  93500. return rawVal / strokeScale_1;
  93501. });
  93502. if (lineDashOffset) {
  93503. lineDashOffset /= strokeScale_1;
  93504. lineDashOffset = mathRound(lineDashOffset);
  93505. }
  93506. }
  93507. attr(svgEl, 'stroke-dasharray', lineDash.join(','));
  93508. attr(svgEl, 'stroke-dashoffset', (lineDashOffset || 0) + '');
  93509. } else {
  93510. attr(svgEl, 'stroke-dasharray', '');
  93511. }
  93512. style.lineCap && attr(svgEl, 'stroke-linecap', style.lineCap);
  93513. style.lineJoin && attr(svgEl, 'stroke-linejoin', style.lineJoin);
  93514. style.miterLimit && attr(svgEl, 'stroke-miterlimit', style.miterLimit + '');
  93515. } else {
  93516. attr(svgEl, 'stroke', NONE);
  93517. }
  93518. }
  93519. var SVGPathRebuilder = function () {
  93520. function SVGPathRebuilder() {}
  93521. SVGPathRebuilder.prototype.reset = function () {
  93522. this._d = [];
  93523. this._str = '';
  93524. };
  93525. SVGPathRebuilder.prototype.moveTo = function (x, y) {
  93526. this._add('M', x, y);
  93527. };
  93528. SVGPathRebuilder.prototype.lineTo = function (x, y) {
  93529. this._add('L', x, y);
  93530. };
  93531. SVGPathRebuilder.prototype.bezierCurveTo = function (x, y, x2, y2, x3, y3) {
  93532. this._add('C', x, y, x2, y2, x3, y3);
  93533. };
  93534. SVGPathRebuilder.prototype.quadraticCurveTo = function (x, y, x2, y2) {
  93535. this._add('Q', x, y, x2, y2);
  93536. };
  93537. SVGPathRebuilder.prototype.arc = function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  93538. this.ellipse(cx, cy, r, r, 0, startAngle, endAngle, anticlockwise);
  93539. };
  93540. SVGPathRebuilder.prototype.ellipse = function (cx, cy, rx, ry, psi, startAngle, endAngle, anticlockwise) {
  93541. var firstCmd = this._d.length === 0;
  93542. var dTheta = endAngle - startAngle;
  93543. var clockwise = !anticlockwise;
  93544. var dThetaPositive = Math.abs(dTheta);
  93545. var isCircle = isAroundZero$1(dThetaPositive - PI2$10) || (clockwise ? dTheta >= PI2$10 : -dTheta >= PI2$10);
  93546. var unifiedTheta = dTheta > 0 ? dTheta % PI2$10 : dTheta % PI2$10 + PI2$10;
  93547. var large = false;
  93548. if (isCircle) {
  93549. large = true;
  93550. } else if (isAroundZero$1(dThetaPositive)) {
  93551. large = false;
  93552. } else {
  93553. large = unifiedTheta >= PI$8 === !!clockwise;
  93554. }
  93555. var x0 = round4(cx + rx * mathCos$4(startAngle));
  93556. var y0 = round4(cy + ry * mathSin$4(startAngle));
  93557. if (isCircle) {
  93558. if (clockwise) {
  93559. dTheta = PI2$10 - 1e-4;
  93560. } else {
  93561. dTheta = -PI2$10 + 1e-4;
  93562. }
  93563. large = true;
  93564. if (firstCmd) {
  93565. this._d.push('M', x0, y0);
  93566. }
  93567. }
  93568. var x = round4(cx + rx * mathCos$4(startAngle + dTheta));
  93569. var y = round4(cy + ry * mathSin$4(startAngle + dTheta));
  93570. if (isNaN(x0) || isNaN(y0) || isNaN(rx) || isNaN(ry) || isNaN(psi) || isNaN(degree) || isNaN(x) || isNaN(y)) {
  93571. return '';
  93572. }
  93573. this._d.push('A', round4(rx), round4(ry), mathRound(psi * degree), +large, +clockwise, x, y);
  93574. };
  93575. SVGPathRebuilder.prototype.rect = function (x, y, w, h) {
  93576. this._add('M', x, y);
  93577. this._add('L', x + w, y);
  93578. this._add('L', x + w, y + h);
  93579. this._add('L', x, y + h);
  93580. this._add('L', x, y);
  93581. };
  93582. SVGPathRebuilder.prototype.closePath = function () {
  93583. if (this._d.length > 0) {
  93584. this._add('Z');
  93585. }
  93586. };
  93587. SVGPathRebuilder.prototype._add = function (cmd, a, b, c, d, e, f, g, h) {
  93588. this._d.push(cmd);
  93589. for (var i = 1; i < arguments.length; i++) {
  93590. var val = arguments[i];
  93591. if (isNaN(val)) {
  93592. this._invalid = true;
  93593. return;
  93594. }
  93595. this._d.push(round4(val));
  93596. }
  93597. };
  93598. SVGPathRebuilder.prototype.generateStr = function () {
  93599. this._str = this._invalid ? '' : this._d.join(' ');
  93600. this._d = [];
  93601. };
  93602. SVGPathRebuilder.prototype.getStr = function () {
  93603. return this._str;
  93604. };
  93605. return SVGPathRebuilder;
  93606. }();
  93607. var svgPath = {
  93608. brush: function (el) {
  93609. var style = el.style;
  93610. var svgEl = el.__svgEl;
  93611. if (!svgEl) {
  93612. svgEl = createElement('path');
  93613. el.__svgEl = svgEl;
  93614. }
  93615. if (!el.path) {
  93616. el.createPathProxy();
  93617. }
  93618. var path = el.path;
  93619. if (el.shapeChanged()) {
  93620. path.beginPath();
  93621. el.buildPath(path, el.shape);
  93622. el.pathUpdated();
  93623. }
  93624. var pathVersion = path.getVersion();
  93625. var elExt = el;
  93626. var svgPathBuilder = elExt.__svgPathBuilder;
  93627. if (elExt.__svgPathVersion !== pathVersion || !svgPathBuilder || el.style.strokePercent < 1) {
  93628. if (!svgPathBuilder) {
  93629. svgPathBuilder = elExt.__svgPathBuilder = new SVGPathRebuilder();
  93630. }
  93631. svgPathBuilder.reset();
  93632. path.rebuildPath(svgPathBuilder, el.style.strokePercent);
  93633. svgPathBuilder.generateStr();
  93634. elExt.__svgPathVersion = pathVersion;
  93635. }
  93636. attr(svgEl, 'd', svgPathBuilder.getStr());
  93637. bindStyle(svgEl, style, el);
  93638. setTransform(svgEl, el.transform);
  93639. }
  93640. };
  93641. var svgImage = {
  93642. brush: function (el) {
  93643. var style = el.style;
  93644. var image = style.image;
  93645. if (image instanceof HTMLImageElement) {
  93646. image = image.src;
  93647. } else if (image instanceof HTMLCanvasElement) {
  93648. image = image.toDataURL();
  93649. }
  93650. if (!image) {
  93651. return;
  93652. }
  93653. var x = style.x || 0;
  93654. var y = style.y || 0;
  93655. var dw = style.width;
  93656. var dh = style.height;
  93657. var svgEl = el.__svgEl;
  93658. if (!svgEl) {
  93659. svgEl = createElement('image');
  93660. el.__svgEl = svgEl;
  93661. }
  93662. if (image !== el.__imageSrc) {
  93663. attrXLink(svgEl, 'href', image);
  93664. el.__imageSrc = image;
  93665. }
  93666. attr(svgEl, 'width', dw + '');
  93667. attr(svgEl, 'height', dh + '');
  93668. attr(svgEl, 'x', x + '');
  93669. attr(svgEl, 'y', y + '');
  93670. bindStyle(svgEl, style, el);
  93671. setTransform(svgEl, el.transform);
  93672. }
  93673. };
  93674. var TEXT_ALIGN_TO_ANCHOR = {
  93675. left: 'start',
  93676. right: 'end',
  93677. center: 'middle',
  93678. middle: 'middle'
  93679. };
  93680. function adjustTextY$1(y, lineHeight, textBaseline) {
  93681. if (textBaseline === 'top') {
  93682. y += lineHeight / 2;
  93683. } else if (textBaseline === 'bottom') {
  93684. y -= lineHeight / 2;
  93685. }
  93686. return y;
  93687. }
  93688. var svgText = {
  93689. brush: function (el) {
  93690. var style = el.style;
  93691. var text = style.text;
  93692. text != null && (text += '');
  93693. if (!text || isNaN(style.x) || isNaN(style.y)) {
  93694. return;
  93695. }
  93696. var textSvgEl = el.__svgEl;
  93697. if (!textSvgEl) {
  93698. textSvgEl = createElement('text');
  93699. attrXML(textSvgEl, 'xml:space', 'preserve');
  93700. el.__svgEl = textSvgEl;
  93701. }
  93702. var font = style.font || DEFAULT_FONT;
  93703. var textSvgElStyle = textSvgEl.style;
  93704. textSvgElStyle.font = font;
  93705. textSvgEl.textContent = text;
  93706. bindStyle(textSvgEl, style, el);
  93707. setTransform(textSvgEl, el.transform);
  93708. var x = style.x || 0;
  93709. var y = adjustTextY$1(style.y || 0, getLineHeight(font), style.textBaseline);
  93710. var textAlign = TEXT_ALIGN_TO_ANCHOR[style.textAlign] || style.textAlign;
  93711. attr(textSvgEl, 'dominant-baseline', 'central');
  93712. attr(textSvgEl, 'text-anchor', textAlign);
  93713. attr(textSvgEl, 'x', x + '');
  93714. attr(textSvgEl, 'y', y + '');
  93715. }
  93716. };
  93717. var MARK_UNUSED = '0';
  93718. var MARK_USED = '1';
  93719. var Definable = function () {
  93720. function Definable(zrId, svgRoot, tagNames, markLabel, domName) {
  93721. this.nextId = 0;
  93722. this._domName = '_dom';
  93723. this.createElement = createElement;
  93724. this._zrId = zrId;
  93725. this._svgRoot = svgRoot;
  93726. this._tagNames = typeof tagNames === 'string' ? [tagNames] : tagNames;
  93727. this._markLabel = markLabel;
  93728. if (domName) {
  93729. this._domName = domName;
  93730. }
  93731. }
  93732. Definable.prototype.getDefs = function (isForceCreating) {
  93733. var svgRoot = this._svgRoot;
  93734. var defs = this._svgRoot.getElementsByTagName('defs');
  93735. if (defs.length === 0) {
  93736. if (isForceCreating) {
  93737. var defs_1 = svgRoot.insertBefore(this.createElement('defs'), svgRoot.firstChild);
  93738. if (!defs_1.contains) {
  93739. defs_1.contains = function (el) {
  93740. var children = defs_1.children;
  93741. if (!children) {
  93742. return false;
  93743. }
  93744. for (var i = children.length - 1; i >= 0; --i) {
  93745. if (children[i] === el) {
  93746. return true;
  93747. }
  93748. }
  93749. return false;
  93750. };
  93751. }
  93752. return defs_1;
  93753. } else {
  93754. return null;
  93755. }
  93756. } else {
  93757. return defs[0];
  93758. }
  93759. };
  93760. Definable.prototype.doUpdate = function (target, onUpdate) {
  93761. if (!target) {
  93762. return;
  93763. }
  93764. var defs = this.getDefs(false);
  93765. if (target[this._domName] && defs.contains(target[this._domName])) {
  93766. if (typeof onUpdate === 'function') {
  93767. onUpdate(target);
  93768. }
  93769. } else {
  93770. var dom = this.add(target);
  93771. if (dom) {
  93772. target[this._domName] = dom;
  93773. }
  93774. }
  93775. };
  93776. Definable.prototype.add = function (target) {
  93777. return null;
  93778. };
  93779. Definable.prototype.addDom = function (dom) {
  93780. var defs = this.getDefs(true);
  93781. if (dom.parentNode !== defs) {
  93782. defs.appendChild(dom);
  93783. }
  93784. };
  93785. Definable.prototype.removeDom = function (target) {
  93786. var defs = this.getDefs(false);
  93787. if (defs && target[this._domName]) {
  93788. defs.removeChild(target[this._domName]);
  93789. target[this._domName] = null;
  93790. }
  93791. };
  93792. Definable.prototype.getDoms = function () {
  93793. var defs = this.getDefs(false);
  93794. if (!defs) {
  93795. return [];
  93796. }
  93797. var doms = [];
  93798. each$1(this._tagNames, function (tagName) {
  93799. var tags = defs.getElementsByTagName(tagName);
  93800. for (var i = 0; i < tags.length; i++) {
  93801. doms.push(tags[i]);
  93802. }
  93803. });
  93804. return doms;
  93805. };
  93806. Definable.prototype.markAllUnused = function () {
  93807. var doms = this.getDoms();
  93808. var that = this;
  93809. each$1(doms, function (dom) {
  93810. dom[that._markLabel] = MARK_UNUSED;
  93811. });
  93812. };
  93813. Definable.prototype.markDomUsed = function (dom) {
  93814. dom && (dom[this._markLabel] = MARK_USED);
  93815. };
  93816. Definable.prototype.markDomUnused = function (dom) {
  93817. dom && (dom[this._markLabel] = MARK_UNUSED);
  93818. };
  93819. Definable.prototype.isDomUnused = function (dom) {
  93820. return dom && dom[this._markLabel] !== MARK_USED;
  93821. };
  93822. Definable.prototype.removeUnused = function () {
  93823. var _this = this;
  93824. var defs = this.getDefs(false);
  93825. if (!defs) {
  93826. return;
  93827. }
  93828. var doms = this.getDoms();
  93829. each$1(doms, function (dom) {
  93830. if (_this.isDomUnused(dom)) {
  93831. defs.removeChild(dom);
  93832. }
  93833. });
  93834. };
  93835. Definable.prototype.getSvgProxy = function (displayable) {
  93836. if (displayable instanceof Path) {
  93837. return svgPath;
  93838. } else if (displayable instanceof ZRImage) {
  93839. return svgImage;
  93840. } else if (displayable instanceof TSpan) {
  93841. return svgText;
  93842. } else {
  93843. return svgPath;
  93844. }
  93845. };
  93846. Definable.prototype.getSvgElement = function (displayable) {
  93847. return displayable.__svgEl;
  93848. };
  93849. return Definable;
  93850. }();
  93851. function isLinearGradient(value) {
  93852. return value.type === 'linear';
  93853. }
  93854. function isRadialGradient(value) {
  93855. return value.type === 'radial';
  93856. }
  93857. function isGradient(value) {
  93858. return value && (value.type === 'linear' || value.type === 'radial');
  93859. }
  93860. var GradientManager = function (_super) {
  93861. __extends(GradientManager, _super);
  93862. function GradientManager(zrId, svgRoot) {
  93863. return _super.call(this, zrId, svgRoot, ['linearGradient', 'radialGradient'], '__gradient_in_use__') || this;
  93864. }
  93865. GradientManager.prototype.addWithoutUpdate = function (svgElement, displayable) {
  93866. if (displayable && displayable.style) {
  93867. var that_1 = this;
  93868. each$1(['fill', 'stroke'], function (fillOrStroke) {
  93869. var value = displayable.style[fillOrStroke];
  93870. if (isGradient(value)) {
  93871. var gradient = value;
  93872. var defs = that_1.getDefs(true);
  93873. var dom = void 0;
  93874. if (gradient.__dom) {
  93875. dom = gradient.__dom;
  93876. if (!defs.contains(gradient.__dom)) {
  93877. that_1.addDom(dom);
  93878. }
  93879. } else {
  93880. dom = that_1.add(gradient);
  93881. }
  93882. that_1.markUsed(displayable);
  93883. var id = dom.getAttribute('id');
  93884. svgElement.setAttribute(fillOrStroke, 'url(#' + id + ')');
  93885. }
  93886. });
  93887. }
  93888. };
  93889. GradientManager.prototype.add = function (gradient) {
  93890. var dom;
  93891. if (isLinearGradient(gradient)) {
  93892. dom = this.createElement('linearGradient');
  93893. } else if (isRadialGradient(gradient)) {
  93894. dom = this.createElement('radialGradient');
  93895. } else {
  93896. logError('Illegal gradient type.');
  93897. return null;
  93898. }
  93899. gradient.id = gradient.id || this.nextId++;
  93900. dom.setAttribute('id', 'zr' + this._zrId + '-gradient-' + gradient.id);
  93901. this.updateDom(gradient, dom);
  93902. this.addDom(dom);
  93903. return dom;
  93904. };
  93905. GradientManager.prototype.update = function (gradient) {
  93906. if (!isGradient(gradient)) {
  93907. return;
  93908. }
  93909. var that = this;
  93910. this.doUpdate(gradient, function () {
  93911. var dom = gradient.__dom;
  93912. if (!dom) {
  93913. return;
  93914. }
  93915. var tagName = dom.tagName;
  93916. var type = gradient.type;
  93917. if (type === 'linear' && tagName === 'linearGradient' || type === 'radial' && tagName === 'radialGradient') {
  93918. that.updateDom(gradient, gradient.__dom);
  93919. } else {
  93920. that.removeDom(gradient);
  93921. that.add(gradient);
  93922. }
  93923. });
  93924. };
  93925. GradientManager.prototype.updateDom = function (gradient, dom) {
  93926. if (isLinearGradient(gradient)) {
  93927. dom.setAttribute('x1', gradient.x + '');
  93928. dom.setAttribute('y1', gradient.y + '');
  93929. dom.setAttribute('x2', gradient.x2 + '');
  93930. dom.setAttribute('y2', gradient.y2 + '');
  93931. } else if (isRadialGradient(gradient)) {
  93932. dom.setAttribute('cx', gradient.x + '');
  93933. dom.setAttribute('cy', gradient.y + '');
  93934. dom.setAttribute('r', gradient.r + '');
  93935. } else {
  93936. logError('Illegal gradient type.');
  93937. return;
  93938. }
  93939. if (gradient.global) {
  93940. dom.setAttribute('gradientUnits', 'userSpaceOnUse');
  93941. } else {
  93942. dom.setAttribute('gradientUnits', 'objectBoundingBox');
  93943. }
  93944. dom.innerHTML = '';
  93945. var colors = gradient.colorStops;
  93946. for (var i = 0, len = colors.length; i < len; ++i) {
  93947. var stop_1 = this.createElement('stop');
  93948. stop_1.setAttribute('offset', colors[i].offset * 100 + '%');
  93949. var color = colors[i].color;
  93950. if (color.indexOf('rgba') > -1) {
  93951. var opacity = parse(color)[3];
  93952. var hex = toHex(color);
  93953. stop_1.setAttribute('stop-color', '#' + hex);
  93954. stop_1.setAttribute('stop-opacity', opacity + '');
  93955. } else {
  93956. stop_1.setAttribute('stop-color', colors[i].color);
  93957. }
  93958. dom.appendChild(stop_1);
  93959. }
  93960. gradient.__dom = dom;
  93961. };
  93962. GradientManager.prototype.markUsed = function (displayable) {
  93963. if (displayable.style) {
  93964. var gradient = displayable.style.fill;
  93965. if (gradient && gradient.__dom) {
  93966. _super.prototype.markDomUsed.call(this, gradient.__dom);
  93967. }
  93968. gradient = displayable.style.stroke;
  93969. if (gradient && gradient.__dom) {
  93970. _super.prototype.markDomUsed.call(this, gradient.__dom);
  93971. }
  93972. }
  93973. };
  93974. return GradientManager;
  93975. }(Definable);
  93976. function isPattern(value) {
  93977. return value && (!!value.image || !!value.svgElement);
  93978. }
  93979. var patternDomMap = new WeakMap();
  93980. var PatternManager = function (_super) {
  93981. __extends(PatternManager, _super);
  93982. function PatternManager(zrId, svgRoot) {
  93983. return _super.call(this, zrId, svgRoot, ['pattern'], '__pattern_in_use__') || this;
  93984. }
  93985. PatternManager.prototype.addWithoutUpdate = function (svgElement, displayable) {
  93986. if (displayable && displayable.style) {
  93987. var that_1 = this;
  93988. each$1(['fill', 'stroke'], function (fillOrStroke) {
  93989. var pattern = displayable.style[fillOrStroke];
  93990. if (isPattern(pattern)) {
  93991. var defs = that_1.getDefs(true);
  93992. var dom = patternDomMap.get(pattern);
  93993. if (dom) {
  93994. if (!defs.contains(dom)) {
  93995. that_1.addDom(dom);
  93996. }
  93997. } else {
  93998. dom = that_1.add(pattern);
  93999. }
  94000. that_1.markUsed(displayable);
  94001. var id = dom.getAttribute('id');
  94002. svgElement.setAttribute(fillOrStroke, 'url(#' + id + ')');
  94003. }
  94004. });
  94005. }
  94006. };
  94007. PatternManager.prototype.add = function (pattern) {
  94008. if (!isPattern(pattern)) {
  94009. return;
  94010. }
  94011. var dom = this.createElement('pattern');
  94012. pattern.id = pattern.id == null ? this.nextId++ : pattern.id;
  94013. dom.setAttribute('id', 'zr' + this._zrId + '-pattern-' + pattern.id);
  94014. dom.setAttribute('x', '0');
  94015. dom.setAttribute('y', '0');
  94016. dom.setAttribute('patternUnits', 'userSpaceOnUse');
  94017. this.updateDom(pattern, dom);
  94018. this.addDom(dom);
  94019. return dom;
  94020. };
  94021. PatternManager.prototype.update = function (pattern) {
  94022. if (!isPattern(pattern)) {
  94023. return;
  94024. }
  94025. var that = this;
  94026. this.doUpdate(pattern, function () {
  94027. var dom = patternDomMap.get(pattern);
  94028. that.updateDom(pattern, dom);
  94029. });
  94030. };
  94031. PatternManager.prototype.updateDom = function (pattern, patternDom) {
  94032. var svgElement = pattern.svgElement;
  94033. if (svgElement instanceof SVGElement) {
  94034. if (svgElement.parentNode !== patternDom) {
  94035. patternDom.innerHTML = '';
  94036. patternDom.appendChild(svgElement);
  94037. patternDom.setAttribute('width', pattern.svgWidth + '');
  94038. patternDom.setAttribute('height', pattern.svgHeight + '');
  94039. }
  94040. } else {
  94041. var img = void 0;
  94042. var prevImage = patternDom.getElementsByTagName('image');
  94043. if (prevImage.length) {
  94044. if (pattern.image) {
  94045. img = prevImage[0];
  94046. } else {
  94047. patternDom.removeChild(prevImage[0]);
  94048. return;
  94049. }
  94050. } else if (pattern.image) {
  94051. img = this.createElement('image');
  94052. }
  94053. if (img) {
  94054. var imageSrc = void 0;
  94055. if (typeof pattern.image === 'string') {
  94056. imageSrc = pattern.image;
  94057. } else if (pattern.image instanceof HTMLImageElement) {
  94058. imageSrc = pattern.image.src;
  94059. } else if (pattern.image instanceof HTMLCanvasElement) {
  94060. imageSrc = pattern.image.toDataURL();
  94061. }
  94062. if (imageSrc) {
  94063. img.setAttribute('href', imageSrc);
  94064. img.setAttribute('x', '0');
  94065. img.setAttribute('y', '0');
  94066. var hostEl = {
  94067. dirty: function () {}
  94068. };
  94069. var createdImage = createOrUpdateImage(imageSrc, img, hostEl, function (img) {
  94070. patternDom.setAttribute('width', img.width + '');
  94071. patternDom.setAttribute('height', img.height + '');
  94072. });
  94073. if (createdImage && createdImage.width && createdImage.height) {
  94074. patternDom.setAttribute('width', createdImage.width + '');
  94075. patternDom.setAttribute('height', createdImage.height + '');
  94076. }
  94077. patternDom.appendChild(img);
  94078. }
  94079. }
  94080. }
  94081. var x = pattern.x || 0;
  94082. var y = pattern.y || 0;
  94083. var rotation = (pattern.rotation || 0) / Math.PI * 180;
  94084. var scaleX = pattern.scaleX || 1;
  94085. var scaleY = pattern.scaleY || 1;
  94086. var transform = "translate(" + x + ", " + y + ") rotate(" + rotation + ") scale(" + scaleX + ", " + scaleY + ")";
  94087. patternDom.setAttribute('patternTransform', transform);
  94088. patternDomMap.set(pattern, patternDom);
  94089. };
  94090. PatternManager.prototype.markUsed = function (displayable) {
  94091. if (displayable.style) {
  94092. if (isPattern(displayable.style.fill)) {
  94093. _super.prototype.markDomUsed.call(this, patternDomMap.get(displayable.style.fill));
  94094. }
  94095. if (isPattern(displayable.style.stroke)) {
  94096. _super.prototype.markDomUsed.call(this, patternDomMap.get(displayable.style.stroke));
  94097. }
  94098. }
  94099. };
  94100. return PatternManager;
  94101. }(Definable);
  94102. function generateClipPathsKey(clipPaths) {
  94103. var key = [];
  94104. if (clipPaths) {
  94105. for (var i = 0; i < clipPaths.length; i++) {
  94106. var clipPath = clipPaths[i];
  94107. key.push(clipPath.id);
  94108. }
  94109. }
  94110. return key.join(',');
  94111. }
  94112. function hasClipPath(displayable) {
  94113. var clipPaths = displayable.__clipPaths;
  94114. return clipPaths && clipPaths.length > 0;
  94115. }
  94116. var ClippathManager = function (_super) {
  94117. __extends(ClippathManager, _super);
  94118. function ClippathManager(zrId, svgRoot) {
  94119. var _this = _super.call(this, zrId, svgRoot, 'clipPath', '__clippath_in_use__') || this;
  94120. _this._refGroups = {};
  94121. _this._keyDuplicateCount = {};
  94122. return _this;
  94123. }
  94124. ClippathManager.prototype.markAllUnused = function () {
  94125. _super.prototype.markAllUnused.call(this);
  94126. for (var key in this._refGroups) {
  94127. this.markDomUnused(this._refGroups[key]);
  94128. }
  94129. this._keyDuplicateCount = {};
  94130. };
  94131. ClippathManager.prototype._getClipPathGroup = function (displayable, prevDisplayable) {
  94132. if (!hasClipPath(displayable)) {
  94133. return;
  94134. }
  94135. var clipPaths = displayable.__clipPaths;
  94136. var keyDuplicateCount = this._keyDuplicateCount;
  94137. var clipPathKey = generateClipPathsKey(clipPaths);
  94138. if (isClipPathChanged(clipPaths, prevDisplayable && prevDisplayable.__clipPaths)) {
  94139. keyDuplicateCount[clipPathKey] = keyDuplicateCount[clipPathKey] || 0;
  94140. keyDuplicateCount[clipPathKey] && (clipPathKey += '-' + keyDuplicateCount[clipPathKey]);
  94141. keyDuplicateCount[clipPathKey]++;
  94142. }
  94143. return this._refGroups[clipPathKey] || (this._refGroups[clipPathKey] = this.createElement('g'));
  94144. };
  94145. ClippathManager.prototype.update = function (displayable, prevDisplayable) {
  94146. var clipGroup = this._getClipPathGroup(displayable, prevDisplayable);
  94147. if (clipGroup) {
  94148. this.markDomUsed(clipGroup);
  94149. this.updateDom(clipGroup, displayable.__clipPaths);
  94150. }
  94151. return clipGroup;
  94152. };
  94153. ClippathManager.prototype.updateDom = function (parentEl, clipPaths) {
  94154. if (clipPaths && clipPaths.length > 0) {
  94155. var defs = this.getDefs(true);
  94156. var clipPath = clipPaths[0];
  94157. var clipPathEl = void 0;
  94158. var id = void 0;
  94159. if (clipPath._dom) {
  94160. id = clipPath._dom.getAttribute('id');
  94161. clipPathEl = clipPath._dom;
  94162. if (!defs.contains(clipPathEl)) {
  94163. defs.appendChild(clipPathEl);
  94164. }
  94165. } else {
  94166. id = 'zr' + this._zrId + '-clip-' + this.nextId;
  94167. ++this.nextId;
  94168. clipPathEl = this.createElement('clipPath');
  94169. clipPathEl.setAttribute('id', id);
  94170. defs.appendChild(clipPathEl);
  94171. clipPath._dom = clipPathEl;
  94172. }
  94173. var svgProxy = this.getSvgProxy(clipPath);
  94174. svgProxy.brush(clipPath);
  94175. var pathEl = this.getSvgElement(clipPath);
  94176. clipPathEl.innerHTML = '';
  94177. clipPathEl.appendChild(pathEl);
  94178. parentEl.setAttribute('clip-path', 'url(#' + id + ')');
  94179. if (clipPaths.length > 1) {
  94180. this.updateDom(clipPathEl, clipPaths.slice(1));
  94181. }
  94182. } else {
  94183. if (parentEl) {
  94184. parentEl.setAttribute('clip-path', 'none');
  94185. }
  94186. }
  94187. };
  94188. ClippathManager.prototype.markUsed = function (displayable) {
  94189. var _this = this;
  94190. if (displayable.__clipPaths) {
  94191. each$1(displayable.__clipPaths, function (clipPath) {
  94192. if (clipPath._dom) {
  94193. _super.prototype.markDomUsed.call(_this, clipPath._dom);
  94194. }
  94195. });
  94196. }
  94197. };
  94198. ClippathManager.prototype.removeUnused = function () {
  94199. _super.prototype.removeUnused.call(this);
  94200. var newRefGroupsMap = {};
  94201. for (var key in this._refGroups) {
  94202. var group = this._refGroups[key];
  94203. if (!this.isDomUnused(group)) {
  94204. newRefGroupsMap[key] = group;
  94205. } else if (group.parentNode) {
  94206. group.parentNode.removeChild(group);
  94207. }
  94208. }
  94209. this._refGroups = newRefGroupsMap;
  94210. };
  94211. return ClippathManager;
  94212. }(Definable);
  94213. var ShadowManager = function (_super) {
  94214. __extends(ShadowManager, _super);
  94215. function ShadowManager(zrId, svgRoot) {
  94216. var _this = _super.call(this, zrId, svgRoot, ['filter'], '__filter_in_use__', '_shadowDom') || this;
  94217. _this._shadowDomMap = {};
  94218. _this._shadowDomPool = [];
  94219. return _this;
  94220. }
  94221. ShadowManager.prototype._getFromPool = function () {
  94222. var shadowDom = this._shadowDomPool.pop();
  94223. if (!shadowDom) {
  94224. shadowDom = this.createElement('filter');
  94225. shadowDom.setAttribute('id', 'zr' + this._zrId + '-shadow-' + this.nextId++);
  94226. var domChild = this.createElement('feDropShadow');
  94227. shadowDom.appendChild(domChild);
  94228. this.addDom(shadowDom);
  94229. }
  94230. return shadowDom;
  94231. };
  94232. ShadowManager.prototype.update = function (svgElement, displayable) {
  94233. var style = displayable.style;
  94234. if (hasShadow(style)) {
  94235. var shadowKey = getShadowKey(displayable);
  94236. var shadowDom = displayable._shadowDom = this._shadowDomMap[shadowKey];
  94237. if (!shadowDom) {
  94238. shadowDom = this._getFromPool();
  94239. this._shadowDomMap[shadowKey] = shadowDom;
  94240. }
  94241. this.updateDom(svgElement, displayable, shadowDom);
  94242. } else {
  94243. this.remove(svgElement, displayable);
  94244. }
  94245. };
  94246. ShadowManager.prototype.remove = function (svgElement, displayable) {
  94247. if (displayable._shadowDom != null) {
  94248. displayable._shadowDom = null;
  94249. svgElement.style.filter = '';
  94250. }
  94251. };
  94252. ShadowManager.prototype.updateDom = function (svgElement, displayable, shadowDom) {
  94253. var domChild = shadowDom.children[0];
  94254. var style = displayable.style;
  94255. var globalScale = displayable.getGlobalScale();
  94256. var scaleX = globalScale[0];
  94257. var scaleY = globalScale[1];
  94258. if (!scaleX || !scaleY) {
  94259. return;
  94260. }
  94261. var offsetX = style.shadowOffsetX || 0;
  94262. var offsetY = style.shadowOffsetY || 0;
  94263. var blur = style.shadowBlur;
  94264. var color = style.shadowColor;
  94265. domChild.setAttribute('dx', offsetX / scaleX + '');
  94266. domChild.setAttribute('dy', offsetY / scaleY + '');
  94267. domChild.setAttribute('flood-color', color);
  94268. var stdDx = blur / 2 / scaleX;
  94269. var stdDy = blur / 2 / scaleY;
  94270. var stdDeviation = stdDx + ' ' + stdDy;
  94271. domChild.setAttribute('stdDeviation', stdDeviation);
  94272. shadowDom.setAttribute('x', '-100%');
  94273. shadowDom.setAttribute('y', '-100%');
  94274. shadowDom.setAttribute('width', '300%');
  94275. shadowDom.setAttribute('height', '300%');
  94276. displayable._shadowDom = shadowDom;
  94277. var id = shadowDom.getAttribute('id');
  94278. svgElement.style.filter = 'url(#' + id + ')';
  94279. };
  94280. ShadowManager.prototype.removeUnused = function () {
  94281. var defs = this.getDefs(false);
  94282. if (!defs) {
  94283. return;
  94284. }
  94285. var shadowDomsPool = this._shadowDomPool;
  94286. for (var key in this._shadowDomMap) {
  94287. var dom = this._shadowDomMap[key];
  94288. shadowDomsPool.push(dom);
  94289. }
  94290. this._shadowDomMap = {};
  94291. };
  94292. return ShadowManager;
  94293. }(Definable);
  94294. function hasShadow(style) {
  94295. return style && (style.shadowBlur || style.shadowOffsetX || style.shadowOffsetY);
  94296. }
  94297. function getShadowKey(displayable) {
  94298. var style = displayable.style;
  94299. var globalScale = displayable.getGlobalScale();
  94300. return [style.shadowColor, (style.shadowBlur || 0).toFixed(2), (style.shadowOffsetX || 0).toFixed(2), (style.shadowOffsetY || 0).toFixed(2), globalScale[0], globalScale[1]].join(',');
  94301. }
  94302. function parseInt10$1(val) {
  94303. return parseInt(val, 10);
  94304. }
  94305. function getSvgProxy(el) {
  94306. if (el instanceof Path) {
  94307. return svgPath;
  94308. } else if (el instanceof ZRImage) {
  94309. return svgImage;
  94310. } else if (el instanceof TSpan) {
  94311. return svgText;
  94312. } else {
  94313. return svgPath;
  94314. }
  94315. }
  94316. function checkParentAvailable(parent, child) {
  94317. return child && parent && child.parentNode !== parent;
  94318. }
  94319. function insertAfter(parent, child, prevSibling) {
  94320. if (checkParentAvailable(parent, child) && prevSibling) {
  94321. var nextSibling = prevSibling.nextSibling;
  94322. nextSibling ? parent.insertBefore(child, nextSibling) : parent.appendChild(child);
  94323. }
  94324. }
  94325. function prepend(parent, child) {
  94326. if (checkParentAvailable(parent, child)) {
  94327. var firstChild = parent.firstChild;
  94328. firstChild ? parent.insertBefore(child, firstChild) : parent.appendChild(child);
  94329. }
  94330. }
  94331. function remove(parent, child) {
  94332. if (child && parent && child.parentNode === parent) {
  94333. parent.removeChild(child);
  94334. }
  94335. }
  94336. function removeFromMyParent(child) {
  94337. if (child && child.parentNode) {
  94338. child.parentNode.removeChild(child);
  94339. }
  94340. }
  94341. function getSvgElement(displayable) {
  94342. return displayable.__svgEl;
  94343. }
  94344. var SVGPainter = function () {
  94345. function SVGPainter(root, storage, opts, zrId) {
  94346. this.type = 'svg';
  94347. this.refreshHover = createMethodNotSupport('refreshHover');
  94348. this.pathToImage = createMethodNotSupport('pathToImage');
  94349. this.configLayer = createMethodNotSupport('configLayer');
  94350. this.root = root;
  94351. this.storage = storage;
  94352. this._opts = opts = extend({}, opts || {});
  94353. var svgDom = createElement('svg');
  94354. svgDom.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns', 'http://www.w3.org/2000/svg');
  94355. svgDom.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
  94356. svgDom.setAttribute('version', '1.1');
  94357. svgDom.setAttribute('baseProfile', 'full');
  94358. svgDom.style.cssText = 'user-select:none;position:absolute;left:0;top:0;';
  94359. var bgRoot = createElement('g');
  94360. svgDom.appendChild(bgRoot);
  94361. var svgRoot = createElement('g');
  94362. svgDom.appendChild(svgRoot);
  94363. this._gradientManager = new GradientManager(zrId, svgRoot);
  94364. this._patternManager = new PatternManager(zrId, svgRoot);
  94365. this._clipPathManager = new ClippathManager(zrId, svgRoot);
  94366. this._shadowManager = new ShadowManager(zrId, svgRoot);
  94367. var viewport = document.createElement('div');
  94368. viewport.style.cssText = 'overflow:hidden;position:relative';
  94369. this._svgDom = svgDom;
  94370. this._svgRoot = svgRoot;
  94371. this._backgroundRoot = bgRoot;
  94372. this._viewport = viewport;
  94373. root.appendChild(viewport);
  94374. viewport.appendChild(svgDom);
  94375. this.resize(opts.width, opts.height);
  94376. this._visibleList = [];
  94377. }
  94378. SVGPainter.prototype.getType = function () {
  94379. return 'svg';
  94380. };
  94381. SVGPainter.prototype.getViewportRoot = function () {
  94382. return this._viewport;
  94383. };
  94384. SVGPainter.prototype.getSvgDom = function () {
  94385. return this._svgDom;
  94386. };
  94387. SVGPainter.prototype.getSvgRoot = function () {
  94388. return this._svgRoot;
  94389. };
  94390. SVGPainter.prototype.getViewportRootOffset = function () {
  94391. var viewportRoot = this.getViewportRoot();
  94392. if (viewportRoot) {
  94393. return {
  94394. offsetLeft: viewportRoot.offsetLeft || 0,
  94395. offsetTop: viewportRoot.offsetTop || 0
  94396. };
  94397. }
  94398. };
  94399. SVGPainter.prototype.refresh = function () {
  94400. var list = this.storage.getDisplayList(true);
  94401. this._paintList(list);
  94402. };
  94403. SVGPainter.prototype.setBackgroundColor = function (backgroundColor) {
  94404. if (this._backgroundRoot && this._backgroundNode) {
  94405. this._backgroundRoot.removeChild(this._backgroundNode);
  94406. }
  94407. var bgNode = createElement('rect');
  94408. bgNode.setAttribute('width', this.getWidth());
  94409. bgNode.setAttribute('height', this.getHeight());
  94410. bgNode.setAttribute('x', 0);
  94411. bgNode.setAttribute('y', 0);
  94412. bgNode.setAttribute('id', 0);
  94413. bgNode.style.fill = backgroundColor;
  94414. this._backgroundRoot.appendChild(bgNode);
  94415. this._backgroundNode = bgNode;
  94416. };
  94417. SVGPainter.prototype.createSVGElement = function (tag) {
  94418. return createElement(tag);
  94419. };
  94420. SVGPainter.prototype.paintOne = function (el) {
  94421. var svgProxy = getSvgProxy(el);
  94422. svgProxy && svgProxy.brush(el);
  94423. return getSvgElement(el);
  94424. };
  94425. SVGPainter.prototype._paintList = function (list) {
  94426. var gradientManager = this._gradientManager;
  94427. var patternManager = this._patternManager;
  94428. var clipPathManager = this._clipPathManager;
  94429. var shadowManager = this._shadowManager;
  94430. gradientManager.markAllUnused();
  94431. patternManager.markAllUnused();
  94432. clipPathManager.markAllUnused();
  94433. shadowManager.markAllUnused();
  94434. var svgRoot = this._svgRoot;
  94435. var visibleList = this._visibleList;
  94436. var listLen = list.length;
  94437. var newVisibleList = [];
  94438. for (var i = 0; i < listLen; i++) {
  94439. var displayable = list[i];
  94440. var svgProxy = getSvgProxy(displayable);
  94441. var svgElement = getSvgElement(displayable);
  94442. if (!displayable.invisible) {
  94443. if (displayable.__dirty || !svgElement) {
  94444. svgProxy && svgProxy.brush(displayable);
  94445. svgElement = getSvgElement(displayable);
  94446. if (svgElement && displayable.style) {
  94447. gradientManager.update(displayable.style.fill);
  94448. gradientManager.update(displayable.style.stroke);
  94449. patternManager.update(displayable.style.fill);
  94450. patternManager.update(displayable.style.stroke);
  94451. shadowManager.update(svgElement, displayable);
  94452. }
  94453. displayable.__dirty = 0;
  94454. }
  94455. if (svgElement) {
  94456. newVisibleList.push(displayable);
  94457. }
  94458. }
  94459. }
  94460. var diff = arrayDiff(visibleList, newVisibleList);
  94461. var prevSvgElement;
  94462. var topPrevSvgElement;
  94463. for (var i = 0; i < diff.length; i++) {
  94464. var item = diff[i];
  94465. if (item.removed) {
  94466. for (var k = 0; k < item.count; k++) {
  94467. var displayable = visibleList[item.indices[k]];
  94468. var svgElement = getSvgElement(displayable);
  94469. hasClipPath(displayable) ? removeFromMyParent(svgElement) : remove(svgRoot, svgElement);
  94470. }
  94471. }
  94472. }
  94473. var prevDisplayable;
  94474. var currentClipGroup;
  94475. for (var i = 0; i < diff.length; i++) {
  94476. var item = diff[i];
  94477. if (item.removed) {
  94478. continue;
  94479. }
  94480. for (var k = 0; k < item.count; k++) {
  94481. var displayable = newVisibleList[item.indices[k]];
  94482. var clipGroup = clipPathManager.update(displayable, prevDisplayable);
  94483. if (clipGroup !== currentClipGroup) {
  94484. prevSvgElement = topPrevSvgElement;
  94485. if (clipGroup) {
  94486. prevSvgElement ? insertAfter(svgRoot, clipGroup, prevSvgElement) : prepend(svgRoot, clipGroup);
  94487. topPrevSvgElement = clipGroup;
  94488. prevSvgElement = null;
  94489. }
  94490. currentClipGroup = clipGroup;
  94491. }
  94492. var svgElement = getSvgElement(displayable);
  94493. prevSvgElement ? insertAfter(currentClipGroup || svgRoot, svgElement, prevSvgElement) : prepend(currentClipGroup || svgRoot, svgElement);
  94494. prevSvgElement = svgElement || prevSvgElement;
  94495. if (!currentClipGroup) {
  94496. topPrevSvgElement = prevSvgElement;
  94497. }
  94498. gradientManager.markUsed(displayable);
  94499. gradientManager.addWithoutUpdate(svgElement, displayable);
  94500. patternManager.markUsed(displayable);
  94501. patternManager.addWithoutUpdate(svgElement, displayable);
  94502. clipPathManager.markUsed(displayable);
  94503. prevDisplayable = displayable;
  94504. }
  94505. }
  94506. gradientManager.removeUnused();
  94507. patternManager.removeUnused();
  94508. clipPathManager.removeUnused();
  94509. shadowManager.removeUnused();
  94510. this._visibleList = newVisibleList;
  94511. };
  94512. SVGPainter.prototype.resize = function (width, height) {
  94513. var viewport = this._viewport;
  94514. viewport.style.display = 'none';
  94515. var opts = this._opts;
  94516. width != null && (opts.width = width);
  94517. height != null && (opts.height = height);
  94518. width = this._getSize(0);
  94519. height = this._getSize(1);
  94520. viewport.style.display = '';
  94521. if (this._width !== width || this._height !== height) {
  94522. this._width = width;
  94523. this._height = height;
  94524. var viewportStyle = viewport.style;
  94525. viewportStyle.width = width + 'px';
  94526. viewportStyle.height = height + 'px';
  94527. var svgRoot = this._svgDom;
  94528. svgRoot.setAttribute('width', width + '');
  94529. svgRoot.setAttribute('height', height + '');
  94530. }
  94531. if (this._backgroundNode) {
  94532. this._backgroundNode.setAttribute('width', width);
  94533. this._backgroundNode.setAttribute('height', height);
  94534. }
  94535. };
  94536. SVGPainter.prototype.getWidth = function () {
  94537. return this._width;
  94538. };
  94539. SVGPainter.prototype.getHeight = function () {
  94540. return this._height;
  94541. };
  94542. SVGPainter.prototype._getSize = function (whIdx) {
  94543. var opts = this._opts;
  94544. var wh = ['width', 'height'][whIdx];
  94545. var cwh = ['clientWidth', 'clientHeight'][whIdx];
  94546. var plt = ['paddingLeft', 'paddingTop'][whIdx];
  94547. var prb = ['paddingRight', 'paddingBottom'][whIdx];
  94548. if (opts[wh] != null && opts[wh] !== 'auto') {
  94549. return parseFloat(opts[wh]);
  94550. }
  94551. var root = this.root;
  94552. var stl = document.defaultView.getComputedStyle(root);
  94553. return (root[cwh] || parseInt10$1(stl[wh]) || parseInt10$1(root.style[wh])) - (parseInt10$1(stl[plt]) || 0) - (parseInt10$1(stl[prb]) || 0) | 0;
  94554. };
  94555. SVGPainter.prototype.dispose = function () {
  94556. this.root.innerHTML = '';
  94557. this._svgRoot = this._backgroundRoot = this._svgDom = this._backgroundNode = this._viewport = this.storage = null;
  94558. };
  94559. SVGPainter.prototype.clear = function () {
  94560. var viewportNode = this._viewport;
  94561. if (viewportNode && viewportNode.parentNode) {
  94562. viewportNode.parentNode.removeChild(viewportNode);
  94563. }
  94564. };
  94565. SVGPainter.prototype.toDataURL = function () {
  94566. this.refresh();
  94567. var svgDom = this._svgDom;
  94568. var outerHTML = svgDom.outerHTML || (svgDom.parentNode && svgDom.parentNode).innerHTML;
  94569. var html = encodeURIComponent(outerHTML.replace(/></g, '>\n\r<'));
  94570. return 'data:image/svg+xml;charset=UTF-8,' + html;
  94571. };
  94572. return SVGPainter;
  94573. }();
  94574. function createMethodNotSupport(method) {
  94575. return function () {
  94576. logError('In SVG mode painter not support method "' + method + '"');
  94577. };
  94578. }
  94579. registerPainter('svg', SVGPainter);
  94580. exports.version = version;
  94581. exports.dependencies = dependencies;
  94582. exports.PRIORITY = PRIORITY;
  94583. exports.init = init;
  94584. exports.connect = connect;
  94585. exports.disConnect = disConnect;
  94586. exports.disconnect = disconnect;
  94587. exports.dispose = dispose;
  94588. exports.getInstanceByDom = getInstanceByDom;
  94589. exports.getInstanceById = getInstanceById;
  94590. exports.registerTheme = registerTheme;
  94591. exports.registerPreprocessor = registerPreprocessor;
  94592. exports.registerProcessor = registerProcessor;
  94593. exports.registerPostInit = registerPostInit;
  94594. exports.registerPostUpdate = registerPostUpdate;
  94595. exports.registerAction = registerAction;
  94596. exports.registerCoordinateSystem = registerCoordinateSystem;
  94597. exports.getCoordinateSystemDimensions = getCoordinateSystemDimensions;
  94598. exports.registerLayout = registerLayout;
  94599. exports.registerVisual = registerVisual;
  94600. exports.registerLoading = registerLoading;
  94601. exports.setCanvasCreator = setCanvasCreator;
  94602. exports.registerMap = registerMap;
  94603. exports.getMap = getMap;
  94604. exports.registerTransform = registerTransform;
  94605. exports.dataTool = dataTool;
  94606. exports.registerLocale = registerLocale;
  94607. exports.zrender = zrender;
  94608. exports.matrix = matrix;
  94609. exports.vector = vector;
  94610. exports.zrUtil = util;
  94611. exports.color = color;
  94612. exports.helper = helper;
  94613. exports.number = number;
  94614. exports.time = time;
  94615. exports.graphic = graphic$1;
  94616. exports.format = format$1;
  94617. exports.util = util$1;
  94618. exports.ComponentModel = ComponentModel;
  94619. exports.ComponentView = ComponentView;
  94620. exports.SeriesModel = SeriesModel;
  94621. exports.ChartView = ChartView;
  94622. exports.extendComponentModel = extendComponentModel;
  94623. exports.extendComponentView = extendComponentView;
  94624. exports.extendSeriesModel = extendSeriesModel;
  94625. exports.extendChartView = extendChartView;
  94626. exports.throttle = throttle;
  94627. exports.use = use;
  94628. exports.parseGeoJSON = parseGeoJSON;
  94629. exports.parseGeoJson = parseGeoJSON;
  94630. exports.env = env;
  94631. exports.List = List;
  94632. exports.Model = Model;
  94633. exports.Axis = Axis;
  94634. exports.innerDrawElementOnCanvas = brushSingle;
  94635. });