index-legacy.02be7462.js 2.4 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962
  1. ;(function () {
  2. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  3. try {
  4. var info = gen[key](arg)
  5. var value = info.value
  6. } catch (error) {
  7. reject(error)
  8. return
  9. }
  10. if (info.done) {
  11. resolve(value)
  12. } else {
  13. Promise.resolve(value).then(_next, _throw)
  14. }
  15. }
  16. function _asyncToGenerator(fn) {
  17. return function () {
  18. var self = this,
  19. args = arguments
  20. return new Promise(function (resolve, reject) {
  21. var gen = fn.apply(self, args)
  22. function _next(value) {
  23. asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value)
  24. }
  25. function _throw(err) {
  26. asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err)
  27. }
  28. _next(undefined)
  29. })
  30. }
  31. }
  32. function _typeof(obj) {
  33. '@babel/helpers - typeof'
  34. return (
  35. (_typeof =
  36. 'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
  37. ? function (obj) {
  38. return typeof obj
  39. }
  40. : function (obj) {
  41. return obj &&
  42. 'function' == typeof Symbol &&
  43. obj.constructor === Symbol &&
  44. obj !== Symbol.prototype
  45. ? 'symbol'
  46. : typeof obj
  47. }),
  48. _typeof(obj)
  49. )
  50. }
  51. function _defineProperty(obj, key, value) {
  52. if (key in obj) {
  53. Object.defineProperty(obj, key, {
  54. value: value,
  55. enumerable: true,
  56. configurable: true,
  57. writable: true
  58. })
  59. } else {
  60. obj[key] = value
  61. }
  62. return obj
  63. }
  64. var __vite_style__ = document.createElement('style')
  65. __vite_style__.innerHTML =
  66. '._incomeConsus_7nw9z_1{margin:.37333rem;border-radius:.26667rem;background-color:#fff;overflow:hidden}._income_7nw9z_1{padding-top:.48rem}._income_7nw9z_1 ._countPrice_7nw9z_10{font-size:.69333rem;font-weight:700;color:#ff4e19;line-height:.82667rem}._income_7nw9z_1 .van-cell__title{font-size:.42667rem;color:#000}._income_7nw9z_1 ._searchTime_7nw9z_20{position:relative;box-sizing:border-box;max-width:100%;margin-right:.32rem;color:#333}._income_7nw9z_1 ._searchTime_7nw9z_20:after{position:absolute;top:50%;right:-.26667rem;margin-top:-.13333rem;border:.08rem solid;border-color:transparent transparent #999999 #999999;transform:rotate(-45deg);content:" "}._section_7nw9z_37{overflow-x:auto;overflow-y:hidden;margin:0 .32rem}._section_7nw9z_37::-webkit-scrollbar{display:none}._numberCount_7nw9z_45{font-size:.34667rem;color:gray;line-height:.64rem;flex-wrap:nowrap!important;padding:.53333rem 0}._numberCount_7nw9z_45 i{display:inline-block;width:.05333rem;height:1.12rem;border-radius:.05333rem;background:linear-gradient(180deg,#b5c4ff 0%,#5b85f9 100%);margin-right:.16rem}._numberCount_7nw9z_45 ._color1_7nw9z_60{background:linear-gradient(166deg,#59e5d5 0%,#01C1B5 100%)}._numberCount_7nw9z_45 ._color2_7nw9z_63{background:linear-gradient(163deg,#b9ff4b 0%,#91dd1c 100%)}._numberCount_7nw9z_45 ._color3_7nw9z_66{background:linear-gradient(180deg,#ffc979 0%,#ffa92c 100%)}._numberCount_7nw9z_45 ._color4_7nw9z_69{background:linear-gradient(180deg,#e6c474 0%,#be7e2e 100%)}._numberCount_7nw9z_45 ._color5_7nw9z_72{background:linear-gradient(180deg,#4bcdff 0%,#1c96dd 100%)}._numberCount_7nw9z_45 ._color6_7nw9z_75{background:linear-gradient(180deg,#ee90ff 0%,#d22cff 100%)}._numberCount_7nw9z_45 ._color7_7nw9z_78{background:linear-gradient(180deg,#ff6f6f 0%,#ff3c3c 100%)}._numberCount_7nw9z_45 ._color8_7nw9z_81{background:#1aee3e}._numberCount_7nw9z_45 ._color9_7nw9z_84{background:linear-gradient(180deg,#c1a9ff 0%,#7c47ff 100%)}._numberCount_7nw9z_45 ._type_7nw9z_87 span{display:block}._numberCount_7nw9z_45 ._type_7nw9z_87 ._price_7nw9z_90{font-size:.42667rem;font-weight:500;color:#000;line-height:.58667rem}._numberCount_7nw9z_45 .van-col{display:flex;align-items:center;background-color:#f7f7f7;margin-left:.32rem}._numberCount_7nw9z_45 .van-col:first-child{margin-left:0}._incomeTitle_7nw9z_105{display:flex;align-items:center;padding:0 .32rem;font-size:.37333rem;font-weight:500;color:#333;line-height:.53333rem}._incomeTitle_7nw9z_105 i{margin-right:.13333rem;border-radius:.05333rem;display:inline-block;width:.10667rem;height:.37333rem;background:linear-gradient(166deg,#59e5d5 0%,#01C1B5 100%)}._incomeLine_7nw9z_122{height:5.33333rem;padding:0 .26667rem .8rem}._pieSection_7nw9z_126{padding:.48rem 0 0;margin:0 .26667rem .53333rem;display:flex;align-items:center}._pieIncome_7nw9z_132{width:4.26667rem;height:4.26667rem}._rateAll_7nw9z_136{font-size:.32rem;color:#666;line-height:1;display:flex;align-items:flex-start;flex-direction:column}._rateAll_7nw9z_136 img{width:.53333rem;height:.53333rem;margin-right:.10667rem}._rateAll_7nw9z_136>div{padding-bottom:.32rem;display:flex;align-items:center}._rateAll_7nw9z_136 ._rate_7nw9z_136{padding-left:.10667rem;font-size:.37333rem;font-weight:600;color:#333;line-height:.53333rem}._pieData_7nw9z_161{font-size:.37333rem;color:gray;line-height:1;padding-left:.53333rem;display:flex;align-items:flex-start;flex-wrap:wrap;padding-bottom:.32rem}._pieData_7nw9z_161>div{padding-bottom:.32rem;flex-basis:45%}._pieData_7nw9z_161>div:nth-child(2n + 2){flex-basis:55%}._pieData_7nw9z_161>div:nth-child(2n + 2) ._pieTitle_7nw9z_178{min-width:2.4rem}._pieData_7nw9z_161>div:last-child{padding-bottom:0}._pieData_7nw9z_161 i{display:inline-block;width:.29333rem;height:.29333rem;border-radius:50%;background:#5b8ff9}._pieData_7nw9z_161 ._pieLive_7nw9z_191{background:#01C1B5}._pieData_7nw9z_161 ._pieVideo_7nw9z_194{background:#91dd1c}._pieData_7nw9z_161 ._pieMusic_7nw9z_197{background:#ffa92c}._pieData_7nw9z_161 ._pie1_7nw9z_200{background:#be7e2e}._pieData_7nw9z_161 ._pie2_7nw9z_203{background:#1c96dd}._pieData_7nw9z_161 ._pie3_7nw9z_206{background:#d22cff}._pieData_7nw9z_161 ._pie4_7nw9z_209{background:#ff3c3c}._pieData_7nw9z_161 ._pie5_7nw9z_212{background:#1aee3e!important}._pieData_7nw9z_161 ._pie6_7nw9z_215{background:#7c47ff!important}._pieData_7nw9z_161 ._pieTitle_7nw9z_178{display:inline-block;padding-left:.24rem;margin-right:.26667rem;min-width:1.6rem;color:#1a1a1a;border-right:.02667rem solid #808080}._timePopup_7nw9z_226{display:flex;align-items:center;justify-content:center;padding:.26667rem 0}._timeMonth_7nw9z_232,._timeYear_7nw9z_233{padding:0 .74667rem;margin-left:0!important}._timeMonth_7nw9z_232{border-radius:var(--van-button-border-radius) 0 0 var(--van-button-border-radius)}._timeYear_7nw9z_233{border-radius:0 var(--van-button-border-radius) var(--van-button-border-radius) 0}\n'
  67. document.head.appendChild(__vite_style__)
  68. System.register(
  69. [
  70. './vendor-legacy.09f20d09.js',
  71. './index-legacy.f25f109a.js',
  72. './index-legacy.637f35563.js',
  73. './index-legacy.f25f109a11.js',
  74. './index-legacy.595c24c3.js'
  75. ],
  76. function (exports) {
  77. 'use strict'
  78. var defineComponent,
  79. markRaw,
  80. dayjs,
  81. createVNode,
  82. Cell,
  83. Row,
  84. Col,
  85. createTextVNode,
  86. Popup,
  87. DatetimePicker,
  88. Button,
  89. Picker,
  90. request,
  91. moneyFormat,
  92. formatterDate
  93. return {
  94. setters: [
  95. function (module) {
  96. defineComponent = module.d
  97. markRaw = module.aE
  98. dayjs = module.g
  99. createVNode = module.a
  100. Cell = module.C
  101. Row = module.z
  102. Col = module.A
  103. createTextVNode = module.j
  104. Popup = module.P
  105. DatetimePicker = module.V
  106. Button = module.B
  107. Picker = module.ae
  108. },
  109. function () {},
  110. function () {},
  111. function () {},
  112. function (module) {
  113. request = module.r
  114. moneyFormat = module.o
  115. formatterDate = module.k
  116. }
  117. ],
  118. execute: function execute() {
  119. var _Object$freeze, _Object$freeze2, _Object$freeze3
  120. var icon_fly =
  121. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAA2JJREFUWEftl9tLFHEUxz9n1FoqS4IkpNtDQaYlGd3snlYrhgTdifoT6jGqh9CgepCgx3qIHopKuqA+lElZDyph1ENUpoHQhei5pDJ3Tszorjuzl5ndVZHYeZv5nd+cz3zP+Z7frjDJL5nkfGQBM61QVsGsgpkqEG+/tpNLEeswqUIoRHkixdyLFzthPag9FBEiiEEQZQdQ4AAS6qWYs27IcQPUl+QxhQpyCALVwAo06Vj7xTvy5QChaMgxBdQ+5vGLasSGqkKZaSeLzqJR6a3n4XvhDwFmyRL+jBmgvmUKQ2y0y2baYCUeKiVr6dtSxuGMS6yvWDjSRxbQdpT8yEujFXHLEK1ceG00fgCDpVLGl5QBtY+p/GDTSB9ZpVs2Ds4+JeVcTMnF+poKTE4ClSjTI70UT4l4n50sztl7PQQokxIGfQNqN8eA66729hbOgkrddjtlNW2JXh7zOm1nBtP4BszwJooTIbxByfHZCndlLfuT5YkF7GYNIV5E2d+5f3QsjD4fVu4tQh0m3UALUGqrmTjeMkaxrOFzaoAdtkv7HeMiWemE9wj1PKKRKrZgcAeY40P901LBBa+4uB2jHTSh1DoUcA9c6EE4x3pui2BqJycwaQByPQez8IECViQyhueg1k5mY9KBsjTOF/ZicI6v3LKOJW0nQC5XgaNeakTWDXbJBh77iU/oOe1iEYN0AXNHFPloK/aNm+HzUttYwFTuo6xyJEs0sIercE82s88PXGzRXLv0OStRrmFwmRA3ZBtD4RBtZytCo89+C28bQCiWLcmN4Vlir6/TZxxHaUDJSxrrVtLgtGz1NkbagHa/hbiCcCzhGIpIHJVmuJF6mctyP8ZIC1CfM5+/PIjpNy+5w+uWMSr9GSNlQH1KCUM8BQodPO75GG8oD2+4LzvZ6/dbUgds5RDKrXQSIFgnxjLZwad09vs62vXhCKC76f3cC2ckyPl04DzHTKTfLUAzDQWFXhambozUS9zMboSWmKMP+w+O9cvFeYWVzSUo1bSmq55/BRuZRYBel0m+Y1CDUodSY0M4TdMotRzMBM43oJ27mXKUSyilQCcGJ6SWfm1lOr+5gnIkCuYJg+yRA/ycMECvRNrEYkzKyKFfannlFe933ZeL/b5sPOKygJmqmlXwv1fwH9at6ylMGY7gAAAAAElFTkSuQmCC'
  122. var __glob_21_0 = /*#__PURE__*/ Object.freeze(
  123. ((_Object$freeze = { __proto__: null }),
  124. _defineProperty(_Object$freeze, Symbol.toStringTag, 'Module'),
  125. _defineProperty(_Object$freeze, 'default', icon_fly),
  126. _Object$freeze)
  127. )
  128. var icon_user =
  129. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAABDFJREFUWEftmF9oW3UUx7/n3mTt/INaxUEiU1zrHKnaJsW0nVazFbWbxYW6TREEEWT6sBdBfPDNB/Ft4ItTEMZAtKFUzdSuLbVOu3Zp1jSldWPWP3OzdXSCUu1s19wjN7lpbm7u3f3d22UUNA+BXM7vez58z+93fueGsMY/tMb58N8BbJ9JXleZWe/zyBnPcuXSbKyq4c+rUZ1VObibO2VpNvAMMe8DIwywl3NUTEQTIBz6G1UH4z7fgltY14C7z437iaQYGE02yX+SJLnjI38g5QbSFWD0/KlbvXz5BDNvsk/KANG8xGj+eOMDk/bxxRGuADvOjn9G4PaslKbAWm2NgtpjEGGa5tcFYoHAkhNIx4DRn8eaiHB8JUmeIP8gr2jynAgvd20MvltmwJMfAHihJMkKkIGMdBZLNNZ9ZyhUVsBdP46eY8IdBcOsLNOOs46GQEqmAhvivoaLopCOShydTt+ekRYviIrnGo4WrWVSoDx+5O7GXlENR4DtZxMBLPMVTyJrp4XypdVIWCMlmZ6L3xX+sCyAO84MtRBJX+tPr2giXdz+z6ub3hFd58jBtu9HGgnKsKi4aRzJ+76oDh8U1XAE+OQPIzXLmcwZXfsrdBvL0hpQiPb01DTHygIYSia9t914Sb1XPaIJjHEKSfV992wdF13vyEFV9LHTx5IAHPWygs20cF6ZveW7wB7h28Q54Klv3lKgvG68OKwcKW7b1NO/paVN1D2zrWS7dvvpY/dDyaRtA00CJJme79v86GEnax07qIpvm/pqAOCIWSJDXy6EEGaUC7RpMBL5p+yAkakBdTgdYoYsmkwCXhqo3f6+aLzoFrLUe2Sy/20wvyaSkIiODgZa20ArF5/IsmyMqxJnVzJLLZP9nQB35H7mcpYISpSSLv+1bbA++ocwlS7QPaAq0tkpP7z5pgQDQdPkhHled71/6N6H5t3Arc5BzcWtE72/AOxfsVBPQsReT4VvMBD57ZoDqrdKhXfuAJhfKUpeOkn3LvDi3vFrVeK6VPfN66lyL7PyKoAaS2eKJmyag0wHiDOHhuvaf3Xipu0ebBg9Uit5lEYwbSGiB7Pvv8ze0tOQkyrMgwYMFZhI/U4zMAyJ0sw4MVq/84r3siVgOBWvYYUPM9QXct1kvOoGpQnkTz3Rt1iWXkyEd2anJOPHFLBpqqdq6dLiBAGFzW+YkJ2USSD2d4XQOBZ6aloIMJT89E0wv6EPzo/spQbalNaSzuAN4ejJhl1PCAEGE93HGWz3l4aAMQ5C1P0pV2xIBXfMFXUqM4m6ka4+EFodyOtCLccFk1NTjELeJX8q+OyMLeB9o12tksJfMrPt5Ew2t6Vxa1iWkOiTdPjpqFCJ1aDaRKxZUmg/g6vVe9fKTStAezACiJkVXISMeOYGvGc2adv2QXdlvnqr/gdcrZdr3sF/AWQ0XDiCWwUIAAAAAElFTkSuQmCC'
  130. var __glob_21_1 = /*#__PURE__*/ Object.freeze(
  131. ((_Object$freeze2 = { __proto__: null }),
  132. _defineProperty(_Object$freeze2, Symbol.toStringTag, 'Module'),
  133. _defineProperty(_Object$freeze2, 'default', icon_user),
  134. _Object$freeze2)
  135. )
  136. var incomeConsus = '_incomeConsus_7nw9z_1'
  137. var income = '_income_7nw9z_1'
  138. var countPrice = '_countPrice_7nw9z_10'
  139. var searchTime = '_searchTime_7nw9z_20'
  140. var section = '_section_7nw9z_37'
  141. var numberCount = '_numberCount_7nw9z_45'
  142. var color1 = '_color1_7nw9z_60'
  143. var color2 = '_color2_7nw9z_63'
  144. var color3 = '_color3_7nw9z_66'
  145. var color4 = '_color4_7nw9z_69'
  146. var color5 = '_color5_7nw9z_72'
  147. var color6 = '_color6_7nw9z_75'
  148. var color7 = '_color7_7nw9z_78'
  149. var color8 = '_color8_7nw9z_81'
  150. var color9 = '_color9_7nw9z_84'
  151. var type = '_type_7nw9z_87'
  152. var price = '_price_7nw9z_90'
  153. var incomeTitle = '_incomeTitle_7nw9z_105'
  154. var incomeLine = '_incomeLine_7nw9z_122'
  155. var pieSection = '_pieSection_7nw9z_126'
  156. var pieIncome = '_pieIncome_7nw9z_132'
  157. var rateAll = '_rateAll_7nw9z_136'
  158. var rate = '_rate_7nw9z_136'
  159. var pieData = '_pieData_7nw9z_161'
  160. var pieTitle = '_pieTitle_7nw9z_178'
  161. var pieLive = '_pieLive_7nw9z_191'
  162. var pieVideo = '_pieVideo_7nw9z_194'
  163. var pieMusic = '_pieMusic_7nw9z_197'
  164. var pie1 = '_pie1_7nw9z_200'
  165. var pie2 = '_pie2_7nw9z_203'
  166. var pie3 = '_pie3_7nw9z_206'
  167. var pie4 = '_pie4_7nw9z_209'
  168. var pie5 = '_pie5_7nw9z_212'
  169. var pie6 = '_pie6_7nw9z_215'
  170. var timePopup = '_timePopup_7nw9z_226'
  171. var timeMonth = '_timeMonth_7nw9z_232'
  172. var timeYear = '_timeYear_7nw9z_233'
  173. var styles = {
  174. incomeConsus: incomeConsus,
  175. income: income,
  176. countPrice: countPrice,
  177. searchTime: searchTime,
  178. section: section,
  179. numberCount: numberCount,
  180. color1: color1,
  181. color2: color2,
  182. color3: color3,
  183. color4: color4,
  184. color5: color5,
  185. color6: color6,
  186. color7: color7,
  187. color8: color8,
  188. color9: color9,
  189. type: type,
  190. price: price,
  191. incomeTitle: incomeTitle,
  192. incomeLine: incomeLine,
  193. pieSection: pieSection,
  194. pieIncome: pieIncome,
  195. rateAll: rateAll,
  196. rate: rate,
  197. pieData: pieData,
  198. pieTitle: pieTitle,
  199. pieLive: pieLive,
  200. pieVideo: pieVideo,
  201. pieMusic: pieMusic,
  202. pie1: pie1,
  203. pie2: pie2,
  204. pie3: pie3,
  205. pie4: pie4,
  206. pie5: pie5,
  207. pie6: pie6,
  208. timePopup: timePopup,
  209. timeMonth: timeMonth,
  210. timeYear: timeYear
  211. }
  212. /*! *****************************************************************************
  213. Copyright (c) Microsoft Corporation.
  214. Permission to use, copy, modify, and/or distribute this software for any
  215. purpose with or without fee is hereby granted.
  216. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  217. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  218. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  219. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  220. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  221. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  222. PERFORMANCE OF THIS SOFTWARE.
  223. ***************************************************************************** */ /* global Reflect, Promise */ var _extendStatics =
  224. function extendStatics(d, b) {
  225. _extendStatics =
  226. Object.setPrototypeOf ||
  227. ({ __proto__: [] } instanceof Array &&
  228. function (d, b) {
  229. d.__proto__ = b
  230. }) ||
  231. function (d, b) {
  232. for (var p in b) {
  233. if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]
  234. }
  235. }
  236. return _extendStatics(d, b)
  237. }
  238. function __extends(d, b) {
  239. if (typeof b !== 'function' && b !== null)
  240. throw new TypeError(
  241. 'Class extends value ' +
  242. String(b) +
  243. ' is not a constructor or null'
  244. )
  245. _extendStatics(d, b)
  246. function __() {
  247. this.constructor = d
  248. }
  249. d.prototype =
  250. b === null
  251. ? Object.create(b)
  252. : ((__.prototype = b.prototype), new __())
  253. }
  254. var Browser = (function () {
  255. function Browser() {
  256. this.firefox = false
  257. this.ie = false
  258. this.edge = false
  259. this.newEdge = false
  260. this.weChat = false
  261. }
  262. return Browser
  263. })()
  264. var Env = (function () {
  265. function Env() {
  266. this.browser = new Browser()
  267. this.node = false
  268. this.wxa = false
  269. this.worker = false
  270. this.svgSupported = false
  271. this.touchEventsSupported = false
  272. this.pointerEventsSupported = false
  273. this.domSupported = false
  274. this.transformSupported = false
  275. this.transform3dSupported = false
  276. this.hasGlobalWindow = typeof window !== 'undefined'
  277. }
  278. return Env
  279. })()
  280. var env = new Env()
  281. if (
  282. (typeof wx === 'undefined' ? 'undefined' : _typeof(wx)) ===
  283. 'object' &&
  284. typeof wx.getSystemInfoSync === 'function'
  285. ) {
  286. env.wxa = true
  287. env.touchEventsSupported = true
  288. } else if (
  289. typeof document === 'undefined' &&
  290. typeof self !== 'undefined'
  291. ) {
  292. env.worker = true
  293. } else if (typeof navigator === 'undefined') {
  294. env.node = true
  295. env.svgSupported = true
  296. } else {
  297. detect(navigator.userAgent, env)
  298. }
  299. function detect(ua, env) {
  300. var browser = env.browser
  301. var firefox = ua.match(/Firefox\/([\d.]+)/)
  302. var ie =
  303. ua.match(/MSIE\s([\d.]+)/) ||
  304. ua.match(/Trident\/.+?rv:(([\d.]+))/)
  305. var edge = ua.match(/Edge?\/([\d.]+)/)
  306. var weChat = /micromessenger/i.test(ua)
  307. if (firefox) {
  308. browser.firefox = true
  309. browser.version = firefox[1]
  310. }
  311. if (ie) {
  312. browser.ie = true
  313. browser.version = ie[1]
  314. }
  315. if (edge) {
  316. browser.edge = true
  317. browser.version = edge[1]
  318. browser.newEdge = +edge[1].split('.')[0] > 18
  319. }
  320. if (weChat) {
  321. browser.weChat = true
  322. }
  323. env.svgSupported = typeof SVGRect !== 'undefined'
  324. env.touchEventsSupported =
  325. 'ontouchstart' in window && !browser.ie && !browser.edge
  326. env.pointerEventsSupported =
  327. 'onpointerdown' in window &&
  328. (browser.edge || (browser.ie && +browser.version >= 11))
  329. env.domSupported = typeof document !== 'undefined'
  330. var style = document.documentElement.style
  331. env.transform3dSupported =
  332. ((browser.ie && 'transition' in style) ||
  333. browser.edge ||
  334. ('WebKitCSSMatrix' in window &&
  335. 'm11' in new WebKitCSSMatrix()) ||
  336. 'MozPerspective' in style) &&
  337. !('OTransition' in style)
  338. env.transformSupported =
  339. env.transform3dSupported || (browser.ie && +browser.version >= 9)
  340. }
  341. var env$1 = env
  342. var DEFAULT_FONT_SIZE = 12
  343. var DEFAULT_FONT_FAMILY = 'sans-serif'
  344. var DEFAULT_FONT = DEFAULT_FONT_SIZE + 'px ' + DEFAULT_FONT_FAMILY
  345. var OFFSET = 20
  346. var SCALE = 100
  347. var defaultWidthMapStr =
  348. "007LLmW'55;N0500LLLLLLLLLL00NNNLzWW\\\\WQb\\0FWLg\\bWb\\WQ\\WrWWQ000CL5LLFLL0LL**F*gLLLL5F0LF\\FFF5.5N"
  349. function getTextWidthMap(mapStr) {
  350. var map = {}
  351. if (typeof JSON === 'undefined') {
  352. return map
  353. }
  354. for (var i = 0; i < mapStr.length; i++) {
  355. var char = String.fromCharCode(i + 32)
  356. var size = (mapStr.charCodeAt(i) - OFFSET) / SCALE
  357. map[char] = size
  358. }
  359. return map
  360. }
  361. var DEFAULT_TEXT_WIDTH_MAP = getTextWidthMap(defaultWidthMapStr)
  362. var platformApi = {
  363. createCanvas: function createCanvas() {
  364. return (
  365. typeof document !== 'undefined' &&
  366. document.createElement('canvas')
  367. )
  368. },
  369. measureText: (function () {
  370. var _ctx
  371. var _cachedFont
  372. return function (text, font) {
  373. if (!_ctx) {
  374. var canvas = platformApi.createCanvas()
  375. _ctx = canvas && canvas.getContext('2d')
  376. }
  377. if (_ctx) {
  378. if (_cachedFont !== font) {
  379. _cachedFont = _ctx.font = font || DEFAULT_FONT
  380. }
  381. return _ctx.measureText(text)
  382. } else {
  383. text = text || ''
  384. font = font || DEFAULT_FONT
  385. var res = /^([0-9]*?)px$/.exec(font)
  386. var fontSize = +(res && res[1]) || DEFAULT_FONT_SIZE
  387. var width = 0
  388. if (font.indexOf('mono') >= 0) {
  389. width = fontSize * text.length
  390. } else {
  391. for (var i = 0; i < text.length; i++) {
  392. var preCalcWidth = DEFAULT_TEXT_WIDTH_MAP[text[i]]
  393. width +=
  394. preCalcWidth == null
  395. ? fontSize
  396. : preCalcWidth * fontSize
  397. }
  398. }
  399. return { width: width }
  400. }
  401. }
  402. })(),
  403. loadImage: function loadImage(src, onload, onerror) {
  404. var image = new Image()
  405. image.onload = onload
  406. image.onerror = onerror
  407. image.src = src
  408. return image
  409. }
  410. }
  411. var BUILTIN_OBJECT = reduce(
  412. [
  413. 'Function',
  414. 'RegExp',
  415. 'Date',
  416. 'Error',
  417. 'CanvasGradient',
  418. 'CanvasPattern',
  419. 'Image',
  420. 'Canvas'
  421. ],
  422. function (obj, val) {
  423. obj['[object ' + val + ']'] = true
  424. return obj
  425. },
  426. {}
  427. )
  428. var TYPED_ARRAY = reduce(
  429. [
  430. 'Int8',
  431. 'Uint8',
  432. 'Uint8Clamped',
  433. 'Int16',
  434. 'Uint16',
  435. 'Int32',
  436. 'Uint32',
  437. 'Float32',
  438. 'Float64'
  439. ],
  440. function (obj, val) {
  441. obj['[object ' + val + 'Array]'] = true
  442. return obj
  443. },
  444. {}
  445. )
  446. var objToString = Object.prototype.toString
  447. var arrayProto = Array.prototype
  448. var nativeForEach = arrayProto.forEach
  449. var nativeFilter = arrayProto.filter
  450. var nativeSlice = arrayProto.slice
  451. var nativeMap = arrayProto.map
  452. var ctorFunction = function () {}.constructor
  453. var protoFunction = ctorFunction ? ctorFunction.prototype : null
  454. var protoKey = '__proto__'
  455. var idStart = 0x0907
  456. function guid() {
  457. return idStart++
  458. }
  459. function logError() {
  460. var args = []
  461. for (var _i = 0; _i < arguments.length; _i++) {
  462. args[_i] = arguments[_i]
  463. }
  464. if (typeof console !== 'undefined') {
  465. console.error.apply(console, args)
  466. }
  467. }
  468. function clone$3(source) {
  469. if (source == null || _typeof(source) !== 'object') {
  470. return source
  471. }
  472. var result = source
  473. var typeStr = objToString.call(source)
  474. if (typeStr === '[object Array]') {
  475. if (!isPrimitive(source)) {
  476. result = []
  477. for (var i = 0, len = source.length; i < len; i++) {
  478. result[i] = clone$3(source[i])
  479. }
  480. }
  481. } else if (TYPED_ARRAY[typeStr]) {
  482. if (!isPrimitive(source)) {
  483. var Ctor = source.constructor
  484. if (Ctor.from) {
  485. result = Ctor.from(source)
  486. } else {
  487. result = new Ctor(source.length)
  488. for (var i = 0, len = source.length; i < len; i++) {
  489. result[i] = source[i]
  490. }
  491. }
  492. }
  493. } else if (
  494. !BUILTIN_OBJECT[typeStr] &&
  495. !isPrimitive(source) &&
  496. !isDom(source)
  497. ) {
  498. result = {}
  499. for (var key in source) {
  500. if (source.hasOwnProperty(key) && key !== protoKey) {
  501. result[key] = clone$3(source[key])
  502. }
  503. }
  504. }
  505. return result
  506. }
  507. function merge(target, source, overwrite) {
  508. if (!isObject$2(source) || !isObject$2(target)) {
  509. return overwrite ? clone$3(source) : target
  510. }
  511. for (var key in source) {
  512. if (source.hasOwnProperty(key) && key !== protoKey) {
  513. var targetProp = target[key]
  514. var sourceProp = source[key]
  515. if (
  516. isObject$2(sourceProp) &&
  517. isObject$2(targetProp) &&
  518. !isArray(sourceProp) &&
  519. !isArray(targetProp) &&
  520. !isDom(sourceProp) &&
  521. !isDom(targetProp) &&
  522. !isBuiltInObject(sourceProp) &&
  523. !isBuiltInObject(targetProp) &&
  524. !isPrimitive(sourceProp) &&
  525. !isPrimitive(targetProp)
  526. ) {
  527. merge(targetProp, sourceProp, overwrite)
  528. } else if (overwrite || !(key in target)) {
  529. target[key] = clone$3(source[key])
  530. }
  531. }
  532. }
  533. return target
  534. }
  535. function extend(target, source) {
  536. if (Object.assign) {
  537. Object.assign(target, source)
  538. } else {
  539. for (var key in source) {
  540. if (source.hasOwnProperty(key) && key !== protoKey) {
  541. target[key] = source[key]
  542. }
  543. }
  544. }
  545. return target
  546. }
  547. function defaults(target, source, overlay) {
  548. var keysArr = keys(source)
  549. for (var i = 0; i < keysArr.length; i++) {
  550. var key = keysArr[i]
  551. if (overlay ? source[key] != null : target[key] == null) {
  552. target[key] = source[key]
  553. }
  554. }
  555. return target
  556. }
  557. function indexOf(array, value) {
  558. if (array) {
  559. if (array.indexOf) {
  560. return array.indexOf(value)
  561. }
  562. for (var i = 0, len = array.length; i < len; i++) {
  563. if (array[i] === value) {
  564. return i
  565. }
  566. }
  567. }
  568. return -1
  569. }
  570. function inherits(clazz, baseClazz) {
  571. var clazzPrototype = clazz.prototype
  572. function F() {}
  573. F.prototype = baseClazz.prototype
  574. clazz.prototype = new F()
  575. for (var prop in clazzPrototype) {
  576. if (clazzPrototype.hasOwnProperty(prop)) {
  577. clazz.prototype[prop] = clazzPrototype[prop]
  578. }
  579. }
  580. clazz.prototype.constructor = clazz
  581. clazz.superClass = baseClazz
  582. }
  583. function mixin(target, source, override) {
  584. target = 'prototype' in target ? target.prototype : target
  585. source = 'prototype' in source ? source.prototype : source
  586. if (Object.getOwnPropertyNames) {
  587. var keyList = Object.getOwnPropertyNames(source)
  588. for (var i = 0; i < keyList.length; i++) {
  589. var key = keyList[i]
  590. if (key !== 'constructor') {
  591. if (override ? source[key] != null : target[key] == null) {
  592. target[key] = source[key]
  593. }
  594. }
  595. }
  596. } else {
  597. defaults(target, source, override)
  598. }
  599. }
  600. function isArrayLike(data) {
  601. if (!data) {
  602. return false
  603. }
  604. if (typeof data === 'string') {
  605. return false
  606. }
  607. return typeof data.length === 'number'
  608. }
  609. function each$7(arr, cb, context) {
  610. if (!(arr && cb)) {
  611. return
  612. }
  613. if (arr.forEach && arr.forEach === nativeForEach) {
  614. arr.forEach(cb, context)
  615. } else if (arr.length === +arr.length) {
  616. for (var i = 0, len = arr.length; i < len; i++) {
  617. cb.call(context, arr[i], i, arr)
  618. }
  619. } else {
  620. for (var key in arr) {
  621. if (arr.hasOwnProperty(key)) {
  622. cb.call(context, arr[key], key, arr)
  623. }
  624. }
  625. }
  626. }
  627. function map$1(arr, cb, context) {
  628. if (!arr) {
  629. return []
  630. }
  631. if (!cb) {
  632. return slice(arr)
  633. }
  634. if (arr.map && arr.map === nativeMap) {
  635. return arr.map(cb, context)
  636. } else {
  637. var result = []
  638. for (var i = 0, len = arr.length; i < len; i++) {
  639. result.push(cb.call(context, arr[i], i, arr))
  640. }
  641. return result
  642. }
  643. }
  644. function reduce(arr, cb, memo, context) {
  645. if (!(arr && cb)) {
  646. return
  647. }
  648. for (var i = 0, len = arr.length; i < len; i++) {
  649. memo = cb.call(context, memo, arr[i], i, arr)
  650. }
  651. return memo
  652. }
  653. function filter(arr, cb, context) {
  654. if (!arr) {
  655. return []
  656. }
  657. if (!cb) {
  658. return slice(arr)
  659. }
  660. if (arr.filter && arr.filter === nativeFilter) {
  661. return arr.filter(cb, context)
  662. } else {
  663. var result = []
  664. for (var i = 0, len = arr.length; i < len; i++) {
  665. if (cb.call(context, arr[i], i, arr)) {
  666. result.push(arr[i])
  667. }
  668. }
  669. return result
  670. }
  671. }
  672. function keys(obj) {
  673. if (!obj) {
  674. return []
  675. }
  676. if (Object.keys) {
  677. return Object.keys(obj)
  678. }
  679. var keyList = []
  680. for (var key in obj) {
  681. if (obj.hasOwnProperty(key)) {
  682. keyList.push(key)
  683. }
  684. }
  685. return keyList
  686. }
  687. function bindPolyfill(func, context) {
  688. var args = []
  689. for (var _i = 2; _i < arguments.length; _i++) {
  690. args[_i - 2] = arguments[_i]
  691. }
  692. return function () {
  693. return func.apply(
  694. context,
  695. args.concat(nativeSlice.call(arguments))
  696. )
  697. }
  698. }
  699. var bind$1 =
  700. protoFunction && isFunction(protoFunction.bind)
  701. ? protoFunction.call.bind(protoFunction.bind)
  702. : bindPolyfill
  703. function curry$1(func) {
  704. var args = []
  705. for (var _i = 1; _i < arguments.length; _i++) {
  706. args[_i - 1] = arguments[_i]
  707. }
  708. return function () {
  709. return func.apply(this, args.concat(nativeSlice.call(arguments)))
  710. }
  711. }
  712. function isArray(value) {
  713. if (Array.isArray) {
  714. return Array.isArray(value)
  715. }
  716. return objToString.call(value) === '[object Array]'
  717. }
  718. function isFunction(value) {
  719. return typeof value === 'function'
  720. }
  721. function isString(value) {
  722. return typeof value === 'string'
  723. }
  724. function isStringSafe(value) {
  725. return objToString.call(value) === '[object String]'
  726. }
  727. function isNumber(value) {
  728. return typeof value === 'number'
  729. }
  730. function isObject$2(value) {
  731. var type = _typeof(value)
  732. return type === 'function' || (!!value && type === 'object')
  733. }
  734. function isBuiltInObject(value) {
  735. return !!BUILTIN_OBJECT[objToString.call(value)]
  736. }
  737. function isTypedArray(value) {
  738. return !!TYPED_ARRAY[objToString.call(value)]
  739. }
  740. function isDom(value) {
  741. return (
  742. _typeof(value) === 'object' &&
  743. typeof value.nodeType === 'number' &&
  744. _typeof(value.ownerDocument) === 'object'
  745. )
  746. }
  747. function isGradientObject(value) {
  748. return value.colorStops != null
  749. }
  750. function isImagePatternObject(value) {
  751. return value.image != null
  752. }
  753. function isRegExp(value) {
  754. return objToString.call(value) === '[object RegExp]'
  755. }
  756. function eqNaN(value) {
  757. return value !== value
  758. }
  759. function retrieve() {
  760. var args = []
  761. for (var _i = 0; _i < arguments.length; _i++) {
  762. args[_i] = arguments[_i]
  763. }
  764. for (var i = 0, len = args.length; i < len; i++) {
  765. if (args[i] != null) {
  766. return args[i]
  767. }
  768. }
  769. }
  770. function retrieve2(value0, value1) {
  771. return value0 != null ? value0 : value1
  772. }
  773. function retrieve3(value0, value1, value2) {
  774. return value0 != null ? value0 : value1 != null ? value1 : value2
  775. }
  776. function slice(arr) {
  777. var args = []
  778. for (var _i = 1; _i < arguments.length; _i++) {
  779. args[_i - 1] = arguments[_i]
  780. }
  781. return nativeSlice.apply(arr, args)
  782. }
  783. function normalizeCssArray$1(val) {
  784. if (typeof val === 'number') {
  785. return [val, val, val, val]
  786. }
  787. var len = val.length
  788. if (len === 2) {
  789. return [val[0], val[1], val[0], val[1]]
  790. } else if (len === 3) {
  791. return [val[0], val[1], val[2], val[1]]
  792. }
  793. return val
  794. }
  795. function assert(condition, message) {
  796. if (!condition) {
  797. throw new Error(message)
  798. }
  799. }
  800. function trim$1(str) {
  801. if (str == null) {
  802. return null
  803. } else if (typeof str.trim === 'function') {
  804. return str.trim()
  805. } else {
  806. return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '')
  807. }
  808. }
  809. var primitiveKey = '__ec_primitive__'
  810. function setAsPrimitive(obj) {
  811. obj[primitiveKey] = true
  812. }
  813. function isPrimitive(obj) {
  814. return obj[primitiveKey]
  815. }
  816. var HashMap = (function () {
  817. function HashMap(obj) {
  818. this.data = {}
  819. var isArr = isArray(obj)
  820. this.data = {}
  821. var thisMap = this
  822. obj instanceof HashMap
  823. ? obj.each(visit)
  824. : obj && each$7(obj, visit)
  825. function visit(value, key) {
  826. isArr ? thisMap.set(value, key) : thisMap.set(key, value)
  827. }
  828. }
  829. HashMap.prototype.get = function (key) {
  830. return this.data.hasOwnProperty(key) ? this.data[key] : null
  831. }
  832. HashMap.prototype.set = function (key, value) {
  833. return (this.data[key] = value)
  834. }
  835. HashMap.prototype.each = function (cb, context) {
  836. for (var key in this.data) {
  837. if (this.data.hasOwnProperty(key)) {
  838. cb.call(context, this.data[key], key)
  839. }
  840. }
  841. }
  842. HashMap.prototype.keys = function () {
  843. return keys(this.data)
  844. }
  845. HashMap.prototype.removeKey = function (key) {
  846. delete this.data[key]
  847. }
  848. return HashMap
  849. })()
  850. function createHashMap(obj) {
  851. return new HashMap(obj)
  852. }
  853. function concatArray(a, b) {
  854. var newArray = new a.constructor(a.length + b.length)
  855. for (var i = 0; i < a.length; i++) {
  856. newArray[i] = a[i]
  857. }
  858. var offset = a.length
  859. for (var i = 0; i < b.length; i++) {
  860. newArray[i + offset] = b[i]
  861. }
  862. return newArray
  863. }
  864. function createObject(proto, properties) {
  865. var obj
  866. if (Object.create) {
  867. obj = Object.create(proto)
  868. } else {
  869. var StyleCtor = function StyleCtor() {}
  870. StyleCtor.prototype = proto
  871. obj = new StyleCtor()
  872. }
  873. if (properties) {
  874. extend(obj, properties)
  875. }
  876. return obj
  877. }
  878. function disableUserSelect(dom) {
  879. var domStyle = dom.style
  880. domStyle.webkitUserSelect = 'none'
  881. domStyle.userSelect = 'none'
  882. domStyle.webkitTapHighlightColor = 'rgba(0,0,0,0)'
  883. domStyle['-webkit-touch-callout'] = 'none'
  884. }
  885. function hasOwn(own, prop) {
  886. return own.hasOwnProperty(prop)
  887. }
  888. function noop() {}
  889. var RADIAN_TO_DEGREE = 180 / Math.PI
  890. function create$1(x, y) {
  891. if (x == null) {
  892. x = 0
  893. }
  894. if (y == null) {
  895. y = 0
  896. }
  897. return [x, y]
  898. }
  899. function clone$2(v) {
  900. return [v[0], v[1]]
  901. }
  902. function add(out, v1, v2) {
  903. out[0] = v1[0] + v2[0]
  904. out[1] = v1[1] + v2[1]
  905. return out
  906. }
  907. function sub(out, v1, v2) {
  908. out[0] = v1[0] - v2[0]
  909. out[1] = v1[1] - v2[1]
  910. return out
  911. }
  912. function len(v) {
  913. return Math.sqrt(lenSquare(v))
  914. }
  915. function lenSquare(v) {
  916. return v[0] * v[0] + v[1] * v[1]
  917. }
  918. function scale$2(out, v, s) {
  919. out[0] = v[0] * s
  920. out[1] = v[1] * s
  921. return out
  922. }
  923. function normalize$1(out, v) {
  924. var d = len(v)
  925. if (d === 0) {
  926. out[0] = 0
  927. out[1] = 0
  928. } else {
  929. out[0] = v[0] / d
  930. out[1] = v[1] / d
  931. }
  932. return out
  933. }
  934. function distance(v1, v2) {
  935. return Math.sqrt(
  936. (v1[0] - v2[0]) * (v1[0] - v2[0]) +
  937. (v1[1] - v2[1]) * (v1[1] - v2[1])
  938. )
  939. }
  940. var dist$1 = distance
  941. function distanceSquare(v1, v2) {
  942. return (
  943. (v1[0] - v2[0]) * (v1[0] - v2[0]) +
  944. (v1[1] - v2[1]) * (v1[1] - v2[1])
  945. )
  946. }
  947. var distSquare = distanceSquare
  948. function lerp$1(out, v1, v2, t) {
  949. out[0] = v1[0] + t * (v2[0] - v1[0])
  950. out[1] = v1[1] + t * (v2[1] - v1[1])
  951. return out
  952. }
  953. function applyTransform$1(out, v, m) {
  954. var x = v[0]
  955. var y = v[1]
  956. out[0] = m[0] * x + m[2] * y + m[4]
  957. out[1] = m[1] * x + m[3] * y + m[5]
  958. return out
  959. }
  960. function min$1(out, v1, v2) {
  961. out[0] = Math.min(v1[0], v2[0])
  962. out[1] = Math.min(v1[1], v2[1])
  963. return out
  964. }
  965. function max$1(out, v1, v2) {
  966. out[0] = Math.max(v1[0], v2[0])
  967. out[1] = Math.max(v1[1], v2[1])
  968. return out
  969. }
  970. var Param = (function () {
  971. function Param(target, e) {
  972. this.target = target
  973. this.topTarget = e && e.topTarget
  974. }
  975. return Param
  976. })()
  977. var Draggable = (function () {
  978. function Draggable(handler) {
  979. this.handler = handler
  980. handler.on('mousedown', this._dragStart, this)
  981. handler.on('mousemove', this._drag, this)
  982. handler.on('mouseup', this._dragEnd, this)
  983. }
  984. Draggable.prototype._dragStart = function (e) {
  985. var draggingTarget = e.target
  986. while (draggingTarget && !draggingTarget.draggable) {
  987. draggingTarget =
  988. draggingTarget.parent || draggingTarget.__hostTarget
  989. }
  990. if (draggingTarget) {
  991. this._draggingTarget = draggingTarget
  992. draggingTarget.dragging = true
  993. this._x = e.offsetX
  994. this._y = e.offsetY
  995. this.handler.dispatchToElement(
  996. new Param(draggingTarget, e),
  997. 'dragstart',
  998. e.event
  999. )
  1000. }
  1001. }
  1002. Draggable.prototype._drag = function (e) {
  1003. var draggingTarget = this._draggingTarget
  1004. if (draggingTarget) {
  1005. var x = e.offsetX
  1006. var y = e.offsetY
  1007. var dx = x - this._x
  1008. var dy = y - this._y
  1009. this._x = x
  1010. this._y = y
  1011. draggingTarget.drift(dx, dy, e)
  1012. this.handler.dispatchToElement(
  1013. new Param(draggingTarget, e),
  1014. 'drag',
  1015. e.event
  1016. )
  1017. var dropTarget = this.handler.findHover(
  1018. x,
  1019. y,
  1020. draggingTarget
  1021. ).target
  1022. var lastDropTarget = this._dropTarget
  1023. this._dropTarget = dropTarget
  1024. if (draggingTarget !== dropTarget) {
  1025. if (lastDropTarget && dropTarget !== lastDropTarget) {
  1026. this.handler.dispatchToElement(
  1027. new Param(lastDropTarget, e),
  1028. 'dragleave',
  1029. e.event
  1030. )
  1031. }
  1032. if (dropTarget && dropTarget !== lastDropTarget) {
  1033. this.handler.dispatchToElement(
  1034. new Param(dropTarget, e),
  1035. 'dragenter',
  1036. e.event
  1037. )
  1038. }
  1039. }
  1040. }
  1041. }
  1042. Draggable.prototype._dragEnd = function (e) {
  1043. var draggingTarget = this._draggingTarget
  1044. if (draggingTarget) {
  1045. draggingTarget.dragging = false
  1046. }
  1047. this.handler.dispatchToElement(
  1048. new Param(draggingTarget, e),
  1049. 'dragend',
  1050. e.event
  1051. )
  1052. if (this._dropTarget) {
  1053. this.handler.dispatchToElement(
  1054. new Param(this._dropTarget, e),
  1055. 'drop',
  1056. e.event
  1057. )
  1058. }
  1059. this._draggingTarget = null
  1060. this._dropTarget = null
  1061. }
  1062. return Draggable
  1063. })()
  1064. var Draggable$1 = Draggable
  1065. var Eventful = (function () {
  1066. function Eventful(eventProcessors) {
  1067. if (eventProcessors) {
  1068. this._$eventProcessor = eventProcessors
  1069. }
  1070. }
  1071. Eventful.prototype.on = function (event, query, handler, context) {
  1072. if (!this._$handlers) {
  1073. this._$handlers = {}
  1074. }
  1075. var _h = this._$handlers
  1076. if (typeof query === 'function') {
  1077. context = handler
  1078. handler = query
  1079. query = null
  1080. }
  1081. if (!handler || !event) {
  1082. return this
  1083. }
  1084. var eventProcessor = this._$eventProcessor
  1085. if (
  1086. query != null &&
  1087. eventProcessor &&
  1088. eventProcessor.normalizeQuery
  1089. ) {
  1090. query = eventProcessor.normalizeQuery(query)
  1091. }
  1092. if (!_h[event]) {
  1093. _h[event] = []
  1094. }
  1095. for (var i = 0; i < _h[event].length; i++) {
  1096. if (_h[event][i].h === handler) {
  1097. return this
  1098. }
  1099. }
  1100. var wrap = {
  1101. h: handler,
  1102. query: query,
  1103. ctx: context || this,
  1104. callAtLast: handler.zrEventfulCallAtLast
  1105. }
  1106. var lastIndex = _h[event].length - 1
  1107. var lastWrap = _h[event][lastIndex]
  1108. lastWrap && lastWrap.callAtLast
  1109. ? _h[event].splice(lastIndex, 0, wrap)
  1110. : _h[event].push(wrap)
  1111. return this
  1112. }
  1113. Eventful.prototype.isSilent = function (eventName) {
  1114. var _h = this._$handlers
  1115. return !_h || !_h[eventName] || !_h[eventName].length
  1116. }
  1117. Eventful.prototype.off = function (eventType, handler) {
  1118. var _h = this._$handlers
  1119. if (!_h) {
  1120. return this
  1121. }
  1122. if (!eventType) {
  1123. this._$handlers = {}
  1124. return this
  1125. }
  1126. if (handler) {
  1127. if (_h[eventType]) {
  1128. var newList = []
  1129. for (var i = 0, l = _h[eventType].length; i < l; i++) {
  1130. if (_h[eventType][i].h !== handler) {
  1131. newList.push(_h[eventType][i])
  1132. }
  1133. }
  1134. _h[eventType] = newList
  1135. }
  1136. if (_h[eventType] && _h[eventType].length === 0) {
  1137. delete _h[eventType]
  1138. }
  1139. } else {
  1140. delete _h[eventType]
  1141. }
  1142. return this
  1143. }
  1144. Eventful.prototype.trigger = function (eventType) {
  1145. var args = []
  1146. for (var _i = 1; _i < arguments.length; _i++) {
  1147. args[_i - 1] = arguments[_i]
  1148. }
  1149. if (!this._$handlers) {
  1150. return this
  1151. }
  1152. var _h = this._$handlers[eventType]
  1153. var eventProcessor = this._$eventProcessor
  1154. if (_h) {
  1155. var argLen = args.length
  1156. var len = _h.length
  1157. for (var i = 0; i < len; i++) {
  1158. var hItem = _h[i]
  1159. if (
  1160. eventProcessor &&
  1161. eventProcessor.filter &&
  1162. hItem.query != null &&
  1163. !eventProcessor.filter(eventType, hItem.query)
  1164. ) {
  1165. continue
  1166. }
  1167. switch (argLen) {
  1168. case 0:
  1169. hItem.h.call(hItem.ctx)
  1170. break
  1171. case 1:
  1172. hItem.h.call(hItem.ctx, args[0])
  1173. break
  1174. case 2:
  1175. hItem.h.call(hItem.ctx, args[0], args[1])
  1176. break
  1177. default:
  1178. hItem.h.apply(hItem.ctx, args)
  1179. break
  1180. }
  1181. }
  1182. }
  1183. eventProcessor &&
  1184. eventProcessor.afterTrigger &&
  1185. eventProcessor.afterTrigger(eventType)
  1186. return this
  1187. }
  1188. Eventful.prototype.triggerWithContext = function (type) {
  1189. var args = []
  1190. for (var _i = 1; _i < arguments.length; _i++) {
  1191. args[_i - 1] = arguments[_i]
  1192. }
  1193. if (!this._$handlers) {
  1194. return this
  1195. }
  1196. var _h = this._$handlers[type]
  1197. var eventProcessor = this._$eventProcessor
  1198. if (_h) {
  1199. var argLen = args.length
  1200. var ctx = args[argLen - 1]
  1201. var len = _h.length
  1202. for (var i = 0; i < len; i++) {
  1203. var hItem = _h[i]
  1204. if (
  1205. eventProcessor &&
  1206. eventProcessor.filter &&
  1207. hItem.query != null &&
  1208. !eventProcessor.filter(type, hItem.query)
  1209. ) {
  1210. continue
  1211. }
  1212. switch (argLen) {
  1213. case 0:
  1214. hItem.h.call(ctx)
  1215. break
  1216. case 1:
  1217. hItem.h.call(ctx, args[0])
  1218. break
  1219. case 2:
  1220. hItem.h.call(ctx, args[0], args[1])
  1221. break
  1222. default:
  1223. hItem.h.apply(ctx, args.slice(1, argLen - 1))
  1224. break
  1225. }
  1226. }
  1227. }
  1228. eventProcessor &&
  1229. eventProcessor.afterTrigger &&
  1230. eventProcessor.afterTrigger(type)
  1231. return this
  1232. }
  1233. return Eventful
  1234. })()
  1235. var Eventful$1 = Eventful
  1236. var LN2 = Math.log(2)
  1237. function determinant(
  1238. rows,
  1239. rank,
  1240. rowStart,
  1241. rowMask,
  1242. colMask,
  1243. detCache
  1244. ) {
  1245. var cacheKey = rowMask + '-' + colMask
  1246. var fullRank = rows.length
  1247. if (detCache.hasOwnProperty(cacheKey)) {
  1248. return detCache[cacheKey]
  1249. }
  1250. if (rank === 1) {
  1251. var colStart = Math.round(
  1252. Math.log(((1 << fullRank) - 1) & ~colMask) / LN2
  1253. )
  1254. return rows[rowStart][colStart]
  1255. }
  1256. var subRowMask = rowMask | (1 << rowStart)
  1257. var subRowStart = rowStart + 1
  1258. while (rowMask & (1 << subRowStart)) {
  1259. subRowStart++
  1260. }
  1261. var sum = 0
  1262. for (var j = 0, colLocalIdx = 0; j < fullRank; j++) {
  1263. var colTag = 1 << j
  1264. if (!(colTag & colMask)) {
  1265. sum +=
  1266. (colLocalIdx % 2 ? -1 : 1) *
  1267. rows[rowStart][j] *
  1268. determinant(
  1269. rows,
  1270. rank - 1,
  1271. subRowStart,
  1272. subRowMask,
  1273. colMask | colTag,
  1274. detCache
  1275. )
  1276. colLocalIdx++
  1277. }
  1278. }
  1279. detCache[cacheKey] = sum
  1280. return sum
  1281. }
  1282. function buildTransformer(src, dest) {
  1283. var mA = [
  1284. [
  1285. src[0],
  1286. src[1],
  1287. 1,
  1288. 0,
  1289. 0,
  1290. 0,
  1291. -dest[0] * src[0],
  1292. -dest[0] * src[1]
  1293. ],
  1294. [
  1295. 0,
  1296. 0,
  1297. 0,
  1298. src[0],
  1299. src[1],
  1300. 1,
  1301. -dest[1] * src[0],
  1302. -dest[1] * src[1]
  1303. ],
  1304. [
  1305. src[2],
  1306. src[3],
  1307. 1,
  1308. 0,
  1309. 0,
  1310. 0,
  1311. -dest[2] * src[2],
  1312. -dest[2] * src[3]
  1313. ],
  1314. [
  1315. 0,
  1316. 0,
  1317. 0,
  1318. src[2],
  1319. src[3],
  1320. 1,
  1321. -dest[3] * src[2],
  1322. -dest[3] * src[3]
  1323. ],
  1324. [
  1325. src[4],
  1326. src[5],
  1327. 1,
  1328. 0,
  1329. 0,
  1330. 0,
  1331. -dest[4] * src[4],
  1332. -dest[4] * src[5]
  1333. ],
  1334. [
  1335. 0,
  1336. 0,
  1337. 0,
  1338. src[4],
  1339. src[5],
  1340. 1,
  1341. -dest[5] * src[4],
  1342. -dest[5] * src[5]
  1343. ],
  1344. [
  1345. src[6],
  1346. src[7],
  1347. 1,
  1348. 0,
  1349. 0,
  1350. 0,
  1351. -dest[6] * src[6],
  1352. -dest[6] * src[7]
  1353. ],
  1354. [0, 0, 0, src[6], src[7], 1, -dest[7] * src[6], -dest[7] * src[7]]
  1355. ]
  1356. var detCache = {}
  1357. var det = determinant(mA, 8, 0, 0, 0, detCache)
  1358. if (det === 0) {
  1359. return
  1360. }
  1361. var vh = []
  1362. for (var i = 0; i < 8; i++) {
  1363. for (var j = 0; j < 8; j++) {
  1364. vh[j] == null && (vh[j] = 0)
  1365. vh[j] +=
  1366. ((((i + j) % 2 ? -1 : 1) *
  1367. determinant(
  1368. mA,
  1369. 7,
  1370. i === 0 ? 1 : 0,
  1371. 1 << i,
  1372. 1 << j,
  1373. detCache
  1374. )) /
  1375. det) *
  1376. dest[i]
  1377. }
  1378. }
  1379. return function (out, srcPointX, srcPointY) {
  1380. var pk = srcPointX * vh[6] + srcPointY * vh[7] + 1
  1381. out[0] = (srcPointX * vh[0] + srcPointY * vh[1] + vh[2]) / pk
  1382. out[1] = (srcPointX * vh[3] + srcPointY * vh[4] + vh[5]) / pk
  1383. }
  1384. }
  1385. var EVENT_SAVED_PROP = '___zrEVENTSAVED'
  1386. var _calcOut$1 = []
  1387. function transformLocalCoord(out, elFrom, elTarget, inX, inY) {
  1388. return (
  1389. transformCoordWithViewport(_calcOut$1, elFrom, inX, inY, true) &&
  1390. transformCoordWithViewport(
  1391. out,
  1392. elTarget,
  1393. _calcOut$1[0],
  1394. _calcOut$1[1]
  1395. )
  1396. )
  1397. }
  1398. function transformCoordWithViewport(out, el, inX, inY, inverse) {
  1399. if (
  1400. el.getBoundingClientRect &&
  1401. env$1.domSupported &&
  1402. !isCanvasEl(el)
  1403. ) {
  1404. var saved = el[EVENT_SAVED_PROP] || (el[EVENT_SAVED_PROP] = {})
  1405. var markers = prepareCoordMarkers(el, saved)
  1406. var transformer = preparePointerTransformer(
  1407. markers,
  1408. saved,
  1409. inverse
  1410. )
  1411. if (transformer) {
  1412. transformer(out, inX, inY)
  1413. return true
  1414. }
  1415. }
  1416. return false
  1417. }
  1418. function prepareCoordMarkers(el, saved) {
  1419. var markers = saved.markers
  1420. if (markers) {
  1421. return markers
  1422. }
  1423. markers = saved.markers = []
  1424. var propLR = ['left', 'right']
  1425. var propTB = ['top', 'bottom']
  1426. for (var i = 0; i < 4; i++) {
  1427. var marker = document.createElement('div')
  1428. var stl = marker.style
  1429. var idxLR = i % 2
  1430. var idxTB = (i >> 1) % 2
  1431. stl.cssText = [
  1432. 'position: absolute',
  1433. 'visibility: hidden',
  1434. 'padding: 0',
  1435. 'margin: 0',
  1436. 'border-width: 0',
  1437. 'user-select: none',
  1438. 'width:0',
  1439. 'height:0',
  1440. propLR[idxLR] + ':0',
  1441. propTB[idxTB] + ':0',
  1442. propLR[1 - idxLR] + ':auto',
  1443. propTB[1 - idxTB] + ':auto',
  1444. ''
  1445. ].join('!important;')
  1446. el.appendChild(marker)
  1447. markers.push(marker)
  1448. }
  1449. return markers
  1450. }
  1451. function preparePointerTransformer(markers, saved, inverse) {
  1452. var transformerName = inverse ? 'invTrans' : 'trans'
  1453. var transformer = saved[transformerName]
  1454. var oldSrcCoords = saved.srcCoords
  1455. var srcCoords = []
  1456. var destCoords = []
  1457. var oldCoordTheSame = true
  1458. for (var i = 0; i < 4; i++) {
  1459. var rect = markers[i].getBoundingClientRect()
  1460. var ii = 2 * i
  1461. var x = rect.left
  1462. var y = rect.top
  1463. srcCoords.push(x, y)
  1464. oldCoordTheSame =
  1465. oldCoordTheSame &&
  1466. oldSrcCoords &&
  1467. x === oldSrcCoords[ii] &&
  1468. y === oldSrcCoords[ii + 1]
  1469. destCoords.push(markers[i].offsetLeft, markers[i].offsetTop)
  1470. }
  1471. return oldCoordTheSame && transformer
  1472. ? transformer
  1473. : ((saved.srcCoords = srcCoords),
  1474. (saved[transformerName] = inverse
  1475. ? buildTransformer(destCoords, srcCoords)
  1476. : buildTransformer(srcCoords, destCoords)))
  1477. }
  1478. function isCanvasEl(el) {
  1479. return el.nodeName.toUpperCase() === 'CANVAS'
  1480. }
  1481. var MOUSE_EVENT_REG = /^(?:mouse|pointer|contextmenu|drag|drop)|click/
  1482. var _calcOut = []
  1483. var firefoxNotSupportOffsetXY =
  1484. env$1.browser.firefox && +env$1.browser.version.split('.')[0] < 39
  1485. function clientToLocal(el, e, out, calculate) {
  1486. out = out || {}
  1487. if (calculate) {
  1488. calculateZrXY(el, e, out)
  1489. } else if (
  1490. firefoxNotSupportOffsetXY &&
  1491. e.layerX != null &&
  1492. e.layerX !== e.offsetX
  1493. ) {
  1494. out.zrX = e.layerX
  1495. out.zrY = e.layerY
  1496. } else if (e.offsetX != null) {
  1497. out.zrX = e.offsetX
  1498. out.zrY = e.offsetY
  1499. } else {
  1500. calculateZrXY(el, e, out)
  1501. }
  1502. return out
  1503. }
  1504. function calculateZrXY(el, e, out) {
  1505. if (env$1.domSupported && el.getBoundingClientRect) {
  1506. var ex = e.clientX
  1507. var ey = e.clientY
  1508. if (isCanvasEl(el)) {
  1509. var box = el.getBoundingClientRect()
  1510. out.zrX = ex - box.left
  1511. out.zrY = ey - box.top
  1512. return
  1513. } else {
  1514. if (transformCoordWithViewport(_calcOut, el, ex, ey)) {
  1515. out.zrX = _calcOut[0]
  1516. out.zrY = _calcOut[1]
  1517. return
  1518. }
  1519. }
  1520. }
  1521. out.zrX = out.zrY = 0
  1522. }
  1523. function getNativeEvent(e) {
  1524. return e || window.event
  1525. }
  1526. function normalizeEvent(el, e, calculate) {
  1527. e = getNativeEvent(e)
  1528. if (e.zrX != null) {
  1529. return e
  1530. }
  1531. var eventType = e.type
  1532. var isTouch = eventType && eventType.indexOf('touch') >= 0
  1533. if (!isTouch) {
  1534. clientToLocal(el, e, e, calculate)
  1535. var wheelDelta = getWheelDeltaMayPolyfill(e)
  1536. e.zrDelta = wheelDelta ? wheelDelta / 120 : -(e.detail || 0) / 3
  1537. } else {
  1538. var touch =
  1539. eventType !== 'touchend'
  1540. ? e.targetTouches[0]
  1541. : e.changedTouches[0]
  1542. touch && clientToLocal(el, touch, e, calculate)
  1543. }
  1544. var button = e.button
  1545. if (
  1546. e.which == null &&
  1547. button !== undefined &&
  1548. MOUSE_EVENT_REG.test(e.type)
  1549. ) {
  1550. e.which = button & 1 ? 1 : button & 2 ? 3 : button & 4 ? 2 : 0
  1551. }
  1552. return e
  1553. }
  1554. function getWheelDeltaMayPolyfill(e) {
  1555. var rawWheelDelta = e.wheelDelta
  1556. if (rawWheelDelta) {
  1557. return rawWheelDelta
  1558. }
  1559. var deltaX = e.deltaX
  1560. var deltaY = e.deltaY
  1561. if (deltaX == null || deltaY == null) {
  1562. return rawWheelDelta
  1563. }
  1564. var delta = deltaY !== 0 ? Math.abs(deltaY) : Math.abs(deltaX)
  1565. var sign = deltaY > 0 ? -1 : deltaY < 0 ? 1 : deltaX > 0 ? -1 : 1
  1566. return 3 * delta * sign
  1567. }
  1568. function addEventListener(el, name, handler, opt) {
  1569. el.addEventListener(name, handler, opt)
  1570. }
  1571. function removeEventListener(el, name, handler, opt) {
  1572. el.removeEventListener(name, handler, opt)
  1573. }
  1574. var stop = function stop(e) {
  1575. e.preventDefault()
  1576. e.stopPropagation()
  1577. e.cancelBubble = true
  1578. }
  1579. function isMiddleOrRightButtonOnMouseUpDown(e) {
  1580. return e.which === 2 || e.which === 3
  1581. }
  1582. var GestureMgr = (function () {
  1583. function GestureMgr() {
  1584. this._track = []
  1585. }
  1586. GestureMgr.prototype.recognize = function (event, target, root) {
  1587. this._doTrack(event, target, root)
  1588. return this._recognize(event)
  1589. }
  1590. GestureMgr.prototype.clear = function () {
  1591. this._track.length = 0
  1592. return this
  1593. }
  1594. GestureMgr.prototype._doTrack = function (event, target, root) {
  1595. var touches = event.touches
  1596. if (!touches) {
  1597. return
  1598. }
  1599. var trackItem = {
  1600. points: [],
  1601. touches: [],
  1602. target: target,
  1603. event: event
  1604. }
  1605. for (var i = 0, len = touches.length; i < len; i++) {
  1606. var touch = touches[i]
  1607. var pos = clientToLocal(root, touch, {})
  1608. trackItem.points.push([pos.zrX, pos.zrY])
  1609. trackItem.touches.push(touch)
  1610. }
  1611. this._track.push(trackItem)
  1612. }
  1613. GestureMgr.prototype._recognize = function (event) {
  1614. for (var eventName in recognizers) {
  1615. if (recognizers.hasOwnProperty(eventName)) {
  1616. var gestureInfo = recognizers[eventName](this._track, event)
  1617. if (gestureInfo) {
  1618. return gestureInfo
  1619. }
  1620. }
  1621. }
  1622. }
  1623. return GestureMgr
  1624. })()
  1625. function dist(pointPair) {
  1626. var dx = pointPair[1][0] - pointPair[0][0]
  1627. var dy = pointPair[1][1] - pointPair[0][1]
  1628. return Math.sqrt(dx * dx + dy * dy)
  1629. }
  1630. function center(pointPair) {
  1631. return [
  1632. (pointPair[0][0] + pointPair[1][0]) / 2,
  1633. (pointPair[0][1] + pointPair[1][1]) / 2
  1634. ]
  1635. }
  1636. var recognizers = {
  1637. pinch: function pinch(tracks, event) {
  1638. var trackLen = tracks.length
  1639. if (!trackLen) {
  1640. return
  1641. }
  1642. var pinchEnd = (tracks[trackLen - 1] || {}).points
  1643. var pinchPre = (tracks[trackLen - 2] || {}).points || pinchEnd
  1644. if (
  1645. pinchPre &&
  1646. pinchPre.length > 1 &&
  1647. pinchEnd &&
  1648. pinchEnd.length > 1
  1649. ) {
  1650. var pinchScale = dist(pinchEnd) / dist(pinchPre)
  1651. !isFinite(pinchScale) && (pinchScale = 1)
  1652. event.pinchScale = pinchScale
  1653. var pinchCenter = center(pinchEnd)
  1654. event.pinchX = pinchCenter[0]
  1655. event.pinchY = pinchCenter[1]
  1656. return { type: 'pinch', target: tracks[0].target, event: event }
  1657. }
  1658. }
  1659. }
  1660. var SILENT = 'silent'
  1661. function makeEventPacket(eveType, targetInfo, event) {
  1662. return {
  1663. type: eveType,
  1664. event: event,
  1665. target: targetInfo.target,
  1666. topTarget: targetInfo.topTarget,
  1667. cancelBubble: false,
  1668. offsetX: event.zrX,
  1669. offsetY: event.zrY,
  1670. gestureEvent: event.gestureEvent,
  1671. pinchX: event.pinchX,
  1672. pinchY: event.pinchY,
  1673. pinchScale: event.pinchScale,
  1674. wheelDelta: event.zrDelta,
  1675. zrByTouch: event.zrByTouch,
  1676. which: event.which,
  1677. stop: stopEvent
  1678. }
  1679. }
  1680. function stopEvent() {
  1681. stop(this.event)
  1682. }
  1683. var EmptyProxy = (function (_super) {
  1684. __extends(EmptyProxy, _super)
  1685. function EmptyProxy() {
  1686. var _this =
  1687. (_super !== null && _super.apply(this, arguments)) || this
  1688. _this.handler = null
  1689. return _this
  1690. }
  1691. EmptyProxy.prototype.dispose = function () {}
  1692. EmptyProxy.prototype.setCursor = function () {}
  1693. return EmptyProxy
  1694. })(Eventful$1)
  1695. var HoveredResult = (function () {
  1696. function HoveredResult(x, y) {
  1697. this.x = x
  1698. this.y = y
  1699. }
  1700. return HoveredResult
  1701. })()
  1702. var handlerNames = [
  1703. 'click',
  1704. 'dblclick',
  1705. 'mousewheel',
  1706. 'mouseout',
  1707. 'mouseup',
  1708. 'mousedown',
  1709. 'mousemove',
  1710. 'contextmenu'
  1711. ]
  1712. var Handler = (function (_super) {
  1713. __extends(Handler, _super)
  1714. function Handler(storage, painter, proxy, painterRoot) {
  1715. var _this = _super.call(this) || this
  1716. _this._hovered = new HoveredResult(0, 0)
  1717. _this.storage = storage
  1718. _this.painter = painter
  1719. _this.painterRoot = painterRoot
  1720. proxy = proxy || new EmptyProxy()
  1721. _this.proxy = null
  1722. _this.setHandlerProxy(proxy)
  1723. _this._draggingMgr = new Draggable$1(_this)
  1724. return _this
  1725. }
  1726. Handler.prototype.setHandlerProxy = function (proxy) {
  1727. if (this.proxy) {
  1728. this.proxy.dispose()
  1729. }
  1730. if (proxy) {
  1731. each$7(
  1732. handlerNames,
  1733. function (name) {
  1734. proxy.on && proxy.on(name, this[name], this)
  1735. },
  1736. this
  1737. )
  1738. proxy.handler = this
  1739. }
  1740. this.proxy = proxy
  1741. }
  1742. Handler.prototype.mousemove = function (event) {
  1743. var x = event.zrX
  1744. var y = event.zrY
  1745. var isOutside = isOutsideBoundary(this, x, y)
  1746. var lastHovered = this._hovered
  1747. var lastHoveredTarget = lastHovered.target
  1748. if (lastHoveredTarget && !lastHoveredTarget.__zr) {
  1749. lastHovered = this.findHover(lastHovered.x, lastHovered.y)
  1750. lastHoveredTarget = lastHovered.target
  1751. }
  1752. var hovered = (this._hovered = isOutside
  1753. ? new HoveredResult(x, y)
  1754. : this.findHover(x, y))
  1755. var hoveredTarget = hovered.target
  1756. var proxy = this.proxy
  1757. proxy.setCursor &&
  1758. proxy.setCursor(
  1759. hoveredTarget ? hoveredTarget.cursor : 'default'
  1760. )
  1761. if (lastHoveredTarget && hoveredTarget !== lastHoveredTarget) {
  1762. this.dispatchToElement(lastHovered, 'mouseout', event)
  1763. }
  1764. this.dispatchToElement(hovered, 'mousemove', event)
  1765. if (hoveredTarget && hoveredTarget !== lastHoveredTarget) {
  1766. this.dispatchToElement(hovered, 'mouseover', event)
  1767. }
  1768. }
  1769. Handler.prototype.mouseout = function (event) {
  1770. var eventControl = event.zrEventControl
  1771. if (eventControl !== 'only_globalout') {
  1772. this.dispatchToElement(this._hovered, 'mouseout', event)
  1773. }
  1774. if (eventControl !== 'no_globalout') {
  1775. this.trigger('globalout', { type: 'globalout', event: event })
  1776. }
  1777. }
  1778. Handler.prototype.resize = function () {
  1779. this._hovered = new HoveredResult(0, 0)
  1780. }
  1781. Handler.prototype.dispatch = function (eventName, eventArgs) {
  1782. var handler = this[eventName]
  1783. handler && handler.call(this, eventArgs)
  1784. }
  1785. Handler.prototype.dispose = function () {
  1786. this.proxy.dispose()
  1787. this.storage = null
  1788. this.proxy = null
  1789. this.painter = null
  1790. }
  1791. Handler.prototype.setCursorStyle = function (cursorStyle) {
  1792. var proxy = this.proxy
  1793. proxy.setCursor && proxy.setCursor(cursorStyle)
  1794. }
  1795. Handler.prototype.dispatchToElement = function (
  1796. targetInfo,
  1797. eventName,
  1798. event
  1799. ) {
  1800. targetInfo = targetInfo || {}
  1801. var el = targetInfo.target
  1802. if (el && el.silent) {
  1803. return
  1804. }
  1805. var eventKey = 'on' + eventName
  1806. var eventPacket = makeEventPacket(eventName, targetInfo, event)
  1807. while (el) {
  1808. el[eventKey] &&
  1809. (eventPacket.cancelBubble = !!el[eventKey].call(
  1810. el,
  1811. eventPacket
  1812. ))
  1813. el.trigger(eventName, eventPacket)
  1814. el = el.__hostTarget ? el.__hostTarget : el.parent
  1815. if (eventPacket.cancelBubble) {
  1816. break
  1817. }
  1818. }
  1819. if (!eventPacket.cancelBubble) {
  1820. this.trigger(eventName, eventPacket)
  1821. if (this.painter && this.painter.eachOtherLayer) {
  1822. this.painter.eachOtherLayer(function (layer) {
  1823. if (typeof layer[eventKey] === 'function') {
  1824. layer[eventKey].call(layer, eventPacket)
  1825. }
  1826. if (layer.trigger) {
  1827. layer.trigger(eventName, eventPacket)
  1828. }
  1829. })
  1830. }
  1831. }
  1832. }
  1833. Handler.prototype.findHover = function (x, y, exclude) {
  1834. var list = this.storage.getDisplayList()
  1835. var out = new HoveredResult(x, y)
  1836. for (var i = list.length - 1; i >= 0; i--) {
  1837. var hoverCheckResult = void 0
  1838. if (
  1839. list[i] !== exclude &&
  1840. !list[i].ignore &&
  1841. (hoverCheckResult = isHover(list[i], x, y))
  1842. ) {
  1843. !out.topTarget && (out.topTarget = list[i])
  1844. if (hoverCheckResult !== SILENT) {
  1845. out.target = list[i]
  1846. break
  1847. }
  1848. }
  1849. }
  1850. return out
  1851. }
  1852. Handler.prototype.processGesture = function (event, stage) {
  1853. if (!this._gestureMgr) {
  1854. this._gestureMgr = new GestureMgr()
  1855. }
  1856. var gestureMgr = this._gestureMgr
  1857. stage === 'start' && gestureMgr.clear()
  1858. var gestureInfo = gestureMgr.recognize(
  1859. event,
  1860. this.findHover(event.zrX, event.zrY, null).target,
  1861. this.proxy.dom
  1862. )
  1863. stage === 'end' && gestureMgr.clear()
  1864. if (gestureInfo) {
  1865. var type = gestureInfo.type
  1866. event.gestureEvent = type
  1867. var res = new HoveredResult()
  1868. res.target = gestureInfo.target
  1869. this.dispatchToElement(res, type, gestureInfo.event)
  1870. }
  1871. }
  1872. return Handler
  1873. })(Eventful$1)
  1874. each$7(
  1875. [
  1876. 'click',
  1877. 'mousedown',
  1878. 'mouseup',
  1879. 'mousewheel',
  1880. 'dblclick',
  1881. 'contextmenu'
  1882. ],
  1883. function (name) {
  1884. Handler.prototype[name] = function (event) {
  1885. var x = event.zrX
  1886. var y = event.zrY
  1887. var isOutside = isOutsideBoundary(this, x, y)
  1888. var hovered
  1889. var hoveredTarget
  1890. if (name !== 'mouseup' || !isOutside) {
  1891. hovered = this.findHover(x, y)
  1892. hoveredTarget = hovered.target
  1893. }
  1894. if (name === 'mousedown') {
  1895. this._downEl = hoveredTarget
  1896. this._downPoint = [event.zrX, event.zrY]
  1897. this._upEl = hoveredTarget
  1898. } else if (name === 'mouseup') {
  1899. this._upEl = hoveredTarget
  1900. } else if (name === 'click') {
  1901. if (
  1902. this._downEl !== this._upEl ||
  1903. !this._downPoint ||
  1904. dist$1(this._downPoint, [event.zrX, event.zrY]) > 4
  1905. ) {
  1906. return
  1907. }
  1908. this._downPoint = null
  1909. }
  1910. this.dispatchToElement(hovered, name, event)
  1911. }
  1912. }
  1913. )
  1914. function isHover(displayable, x, y) {
  1915. if (
  1916. displayable[displayable.rectHover ? 'rectContain' : 'contain'](
  1917. x,
  1918. y
  1919. )
  1920. ) {
  1921. var el = displayable
  1922. var isSilent = void 0
  1923. var ignoreClip = false
  1924. while (el) {
  1925. if (el.ignoreClip) {
  1926. ignoreClip = true
  1927. }
  1928. if (!ignoreClip) {
  1929. var clipPath = el.getClipPath()
  1930. if (clipPath && !clipPath.contain(x, y)) {
  1931. return false
  1932. }
  1933. if (el.silent) {
  1934. isSilent = true
  1935. }
  1936. }
  1937. var hostEl = el.__hostTarget
  1938. el = hostEl ? hostEl : el.parent
  1939. }
  1940. return isSilent ? SILENT : true
  1941. }
  1942. return false
  1943. }
  1944. function isOutsideBoundary(handlerInstance, x, y) {
  1945. var painter = handlerInstance.painter
  1946. return (
  1947. x < 0 ||
  1948. x > painter.getWidth() ||
  1949. y < 0 ||
  1950. y > painter.getHeight()
  1951. )
  1952. }
  1953. var Handler$1 = Handler
  1954. var DEFAULT_MIN_MERGE = 32
  1955. var DEFAULT_MIN_GALLOPING = 7
  1956. function minRunLength(n) {
  1957. var r = 0
  1958. while (n >= DEFAULT_MIN_MERGE) {
  1959. r |= n & 1
  1960. n >>= 1
  1961. }
  1962. return n + r
  1963. }
  1964. function makeAscendingRun(array, lo, hi, compare) {
  1965. var runHi = lo + 1
  1966. if (runHi === hi) {
  1967. return 1
  1968. }
  1969. if (compare(array[runHi++], array[lo]) < 0) {
  1970. while (
  1971. runHi < hi &&
  1972. compare(array[runHi], array[runHi - 1]) < 0
  1973. ) {
  1974. runHi++
  1975. }
  1976. reverseRun(array, lo, runHi)
  1977. } else {
  1978. while (
  1979. runHi < hi &&
  1980. compare(array[runHi], array[runHi - 1]) >= 0
  1981. ) {
  1982. runHi++
  1983. }
  1984. }
  1985. return runHi - lo
  1986. }
  1987. function reverseRun(array, lo, hi) {
  1988. hi--
  1989. while (lo < hi) {
  1990. var t = array[lo]
  1991. array[lo++] = array[hi]
  1992. array[hi--] = t
  1993. }
  1994. }
  1995. function binaryInsertionSort(array, lo, hi, start, compare) {
  1996. if (start === lo) {
  1997. start++
  1998. }
  1999. for (; start < hi; start++) {
  2000. var pivot = array[start]
  2001. var left = lo
  2002. var right = start
  2003. var mid
  2004. while (left < right) {
  2005. mid = (left + right) >>> 1
  2006. if (compare(pivot, array[mid]) < 0) {
  2007. right = mid
  2008. } else {
  2009. left = mid + 1
  2010. }
  2011. }
  2012. var n = start - left
  2013. switch (n) {
  2014. case 3:
  2015. array[left + 3] = array[left + 2]
  2016. case 2:
  2017. array[left + 2] = array[left + 1]
  2018. case 1:
  2019. array[left + 1] = array[left]
  2020. break
  2021. default:
  2022. while (n > 0) {
  2023. array[left + n] = array[left + n - 1]
  2024. n--
  2025. }
  2026. }
  2027. array[left] = pivot
  2028. }
  2029. }
  2030. function gallopLeft(value, array, start, length, hint, compare) {
  2031. var lastOffset = 0
  2032. var maxOffset = 0
  2033. var offset = 1
  2034. if (compare(value, array[start + hint]) > 0) {
  2035. maxOffset = length - hint
  2036. while (
  2037. offset < maxOffset &&
  2038. compare(value, array[start + hint + offset]) > 0
  2039. ) {
  2040. lastOffset = offset
  2041. offset = (offset << 1) + 1
  2042. if (offset <= 0) {
  2043. offset = maxOffset
  2044. }
  2045. }
  2046. if (offset > maxOffset) {
  2047. offset = maxOffset
  2048. }
  2049. lastOffset += hint
  2050. offset += hint
  2051. } else {
  2052. maxOffset = hint + 1
  2053. while (
  2054. offset < maxOffset &&
  2055. compare(value, array[start + hint - offset]) <= 0
  2056. ) {
  2057. lastOffset = offset
  2058. offset = (offset << 1) + 1
  2059. if (offset <= 0) {
  2060. offset = maxOffset
  2061. }
  2062. }
  2063. if (offset > maxOffset) {
  2064. offset = maxOffset
  2065. }
  2066. var tmp = lastOffset
  2067. lastOffset = hint - offset
  2068. offset = hint - tmp
  2069. }
  2070. lastOffset++
  2071. while (lastOffset < offset) {
  2072. var m = lastOffset + ((offset - lastOffset) >>> 1)
  2073. if (compare(value, array[start + m]) > 0) {
  2074. lastOffset = m + 1
  2075. } else {
  2076. offset = m
  2077. }
  2078. }
  2079. return offset
  2080. }
  2081. function gallopRight(value, array, start, length, hint, compare) {
  2082. var lastOffset = 0
  2083. var maxOffset = 0
  2084. var offset = 1
  2085. if (compare(value, array[start + hint]) < 0) {
  2086. maxOffset = hint + 1
  2087. while (
  2088. offset < maxOffset &&
  2089. compare(value, array[start + hint - offset]) < 0
  2090. ) {
  2091. lastOffset = offset
  2092. offset = (offset << 1) + 1
  2093. if (offset <= 0) {
  2094. offset = maxOffset
  2095. }
  2096. }
  2097. if (offset > maxOffset) {
  2098. offset = maxOffset
  2099. }
  2100. var tmp = lastOffset
  2101. lastOffset = hint - offset
  2102. offset = hint - tmp
  2103. } else {
  2104. maxOffset = length - hint
  2105. while (
  2106. offset < maxOffset &&
  2107. compare(value, array[start + hint + offset]) >= 0
  2108. ) {
  2109. lastOffset = offset
  2110. offset = (offset << 1) + 1
  2111. if (offset <= 0) {
  2112. offset = maxOffset
  2113. }
  2114. }
  2115. if (offset > maxOffset) {
  2116. offset = maxOffset
  2117. }
  2118. lastOffset += hint
  2119. offset += hint
  2120. }
  2121. lastOffset++
  2122. while (lastOffset < offset) {
  2123. var m = lastOffset + ((offset - lastOffset) >>> 1)
  2124. if (compare(value, array[start + m]) < 0) {
  2125. offset = m
  2126. } else {
  2127. lastOffset = m + 1
  2128. }
  2129. }
  2130. return offset
  2131. }
  2132. function TimSort(array, compare) {
  2133. var minGallop = DEFAULT_MIN_GALLOPING
  2134. var runStart
  2135. var runLength
  2136. var stackSize = 0
  2137. var tmp = []
  2138. runStart = []
  2139. runLength = []
  2140. function pushRun(_runStart, _runLength) {
  2141. runStart[stackSize] = _runStart
  2142. runLength[stackSize] = _runLength
  2143. stackSize += 1
  2144. }
  2145. function mergeRuns() {
  2146. while (stackSize > 1) {
  2147. var n = stackSize - 2
  2148. if (
  2149. (n >= 1 &&
  2150. runLength[n - 1] <= runLength[n] + runLength[n + 1]) ||
  2151. (n >= 2 &&
  2152. runLength[n - 2] <= runLength[n] + runLength[n - 1])
  2153. ) {
  2154. if (runLength[n - 1] < runLength[n + 1]) {
  2155. n--
  2156. }
  2157. } else if (runLength[n] > runLength[n + 1]) {
  2158. break
  2159. }
  2160. mergeAt(n)
  2161. }
  2162. }
  2163. function forceMergeRuns() {
  2164. while (stackSize > 1) {
  2165. var n = stackSize - 2
  2166. if (n > 0 && runLength[n - 1] < runLength[n + 1]) {
  2167. n--
  2168. }
  2169. mergeAt(n)
  2170. }
  2171. }
  2172. function mergeAt(i) {
  2173. var start1 = runStart[i]
  2174. var length1 = runLength[i]
  2175. var start2 = runStart[i + 1]
  2176. var length2 = runLength[i + 1]
  2177. runLength[i] = length1 + length2
  2178. if (i === stackSize - 3) {
  2179. runStart[i + 1] = runStart[i + 2]
  2180. runLength[i + 1] = runLength[i + 2]
  2181. }
  2182. stackSize--
  2183. var k = gallopRight(
  2184. array[start2],
  2185. array,
  2186. start1,
  2187. length1,
  2188. 0,
  2189. compare
  2190. )
  2191. start1 += k
  2192. length1 -= k
  2193. if (length1 === 0) {
  2194. return
  2195. }
  2196. length2 = gallopLeft(
  2197. array[start1 + length1 - 1],
  2198. array,
  2199. start2,
  2200. length2,
  2201. length2 - 1,
  2202. compare
  2203. )
  2204. if (length2 === 0) {
  2205. return
  2206. }
  2207. if (length1 <= length2) {
  2208. mergeLow(start1, length1, start2, length2)
  2209. } else {
  2210. mergeHigh(start1, length1, start2, length2)
  2211. }
  2212. }
  2213. function mergeLow(start1, length1, start2, length2) {
  2214. var i = 0
  2215. for (i = 0; i < length1; i++) {
  2216. tmp[i] = array[start1 + i]
  2217. }
  2218. var cursor1 = 0
  2219. var cursor2 = start2
  2220. var dest = start1
  2221. array[dest++] = array[cursor2++]
  2222. if (--length2 === 0) {
  2223. for (i = 0; i < length1; i++) {
  2224. array[dest + i] = tmp[cursor1 + i]
  2225. }
  2226. return
  2227. }
  2228. if (length1 === 1) {
  2229. for (i = 0; i < length2; i++) {
  2230. array[dest + i] = array[cursor2 + i]
  2231. }
  2232. array[dest + length2] = tmp[cursor1]
  2233. return
  2234. }
  2235. var _minGallop = minGallop
  2236. var count1
  2237. var count2
  2238. var exit
  2239. while (1) {
  2240. count1 = 0
  2241. count2 = 0
  2242. exit = false
  2243. do {
  2244. if (compare(array[cursor2], tmp[cursor1]) < 0) {
  2245. array[dest++] = array[cursor2++]
  2246. count2++
  2247. count1 = 0
  2248. if (--length2 === 0) {
  2249. exit = true
  2250. break
  2251. }
  2252. } else {
  2253. array[dest++] = tmp[cursor1++]
  2254. count1++
  2255. count2 = 0
  2256. if (--length1 === 1) {
  2257. exit = true
  2258. break
  2259. }
  2260. }
  2261. } while ((count1 | count2) < _minGallop)
  2262. if (exit) {
  2263. break
  2264. }
  2265. do {
  2266. count1 = gallopRight(
  2267. array[cursor2],
  2268. tmp,
  2269. cursor1,
  2270. length1,
  2271. 0,
  2272. compare
  2273. )
  2274. if (count1 !== 0) {
  2275. for (i = 0; i < count1; i++) {
  2276. array[dest + i] = tmp[cursor1 + i]
  2277. }
  2278. dest += count1
  2279. cursor1 += count1
  2280. length1 -= count1
  2281. if (length1 <= 1) {
  2282. exit = true
  2283. break
  2284. }
  2285. }
  2286. array[dest++] = array[cursor2++]
  2287. if (--length2 === 0) {
  2288. exit = true
  2289. break
  2290. }
  2291. count2 = gallopLeft(
  2292. tmp[cursor1],
  2293. array,
  2294. cursor2,
  2295. length2,
  2296. 0,
  2297. compare
  2298. )
  2299. if (count2 !== 0) {
  2300. for (i = 0; i < count2; i++) {
  2301. array[dest + i] = array[cursor2 + i]
  2302. }
  2303. dest += count2
  2304. cursor2 += count2
  2305. length2 -= count2
  2306. if (length2 === 0) {
  2307. exit = true
  2308. break
  2309. }
  2310. }
  2311. array[dest++] = tmp[cursor1++]
  2312. if (--length1 === 1) {
  2313. exit = true
  2314. break
  2315. }
  2316. _minGallop--
  2317. } while (
  2318. count1 >= DEFAULT_MIN_GALLOPING ||
  2319. count2 >= DEFAULT_MIN_GALLOPING
  2320. )
  2321. if (exit) {
  2322. break
  2323. }
  2324. if (_minGallop < 0) {
  2325. _minGallop = 0
  2326. }
  2327. _minGallop += 2
  2328. }
  2329. minGallop = _minGallop
  2330. minGallop < 1 && (minGallop = 1)
  2331. if (length1 === 1) {
  2332. for (i = 0; i < length2; i++) {
  2333. array[dest + i] = array[cursor2 + i]
  2334. }
  2335. array[dest + length2] = tmp[cursor1]
  2336. } else if (length1 === 0) {
  2337. throw new Error()
  2338. } else {
  2339. for (i = 0; i < length1; i++) {
  2340. array[dest + i] = tmp[cursor1 + i]
  2341. }
  2342. }
  2343. }
  2344. function mergeHigh(start1, length1, start2, length2) {
  2345. var i = 0
  2346. for (i = 0; i < length2; i++) {
  2347. tmp[i] = array[start2 + i]
  2348. }
  2349. var cursor1 = start1 + length1 - 1
  2350. var cursor2 = length2 - 1
  2351. var dest = start2 + length2 - 1
  2352. var customCursor = 0
  2353. var customDest = 0
  2354. array[dest--] = array[cursor1--]
  2355. if (--length1 === 0) {
  2356. customCursor = dest - (length2 - 1)
  2357. for (i = 0; i < length2; i++) {
  2358. array[customCursor + i] = tmp[i]
  2359. }
  2360. return
  2361. }
  2362. if (length2 === 1) {
  2363. dest -= length1
  2364. cursor1 -= length1
  2365. customDest = dest + 1
  2366. customCursor = cursor1 + 1
  2367. for (i = length1 - 1; i >= 0; i--) {
  2368. array[customDest + i] = array[customCursor + i]
  2369. }
  2370. array[dest] = tmp[cursor2]
  2371. return
  2372. }
  2373. var _minGallop = minGallop
  2374. while (true) {
  2375. var count1 = 0
  2376. var count2 = 0
  2377. var exit = false
  2378. do {
  2379. if (compare(tmp[cursor2], array[cursor1]) < 0) {
  2380. array[dest--] = array[cursor1--]
  2381. count1++
  2382. count2 = 0
  2383. if (--length1 === 0) {
  2384. exit = true
  2385. break
  2386. }
  2387. } else {
  2388. array[dest--] = tmp[cursor2--]
  2389. count2++
  2390. count1 = 0
  2391. if (--length2 === 1) {
  2392. exit = true
  2393. break
  2394. }
  2395. }
  2396. } while ((count1 | count2) < _minGallop)
  2397. if (exit) {
  2398. break
  2399. }
  2400. do {
  2401. count1 =
  2402. length1 -
  2403. gallopRight(
  2404. tmp[cursor2],
  2405. array,
  2406. start1,
  2407. length1,
  2408. length1 - 1,
  2409. compare
  2410. )
  2411. if (count1 !== 0) {
  2412. dest -= count1
  2413. cursor1 -= count1
  2414. length1 -= count1
  2415. customDest = dest + 1
  2416. customCursor = cursor1 + 1
  2417. for (i = count1 - 1; i >= 0; i--) {
  2418. array[customDest + i] = array[customCursor + i]
  2419. }
  2420. if (length1 === 0) {
  2421. exit = true
  2422. break
  2423. }
  2424. }
  2425. array[dest--] = tmp[cursor2--]
  2426. if (--length2 === 1) {
  2427. exit = true
  2428. break
  2429. }
  2430. count2 =
  2431. length2 -
  2432. gallopLeft(
  2433. array[cursor1],
  2434. tmp,
  2435. 0,
  2436. length2,
  2437. length2 - 1,
  2438. compare
  2439. )
  2440. if (count2 !== 0) {
  2441. dest -= count2
  2442. cursor2 -= count2
  2443. length2 -= count2
  2444. customDest = dest + 1
  2445. customCursor = cursor2 + 1
  2446. for (i = 0; i < count2; i++) {
  2447. array[customDest + i] = tmp[customCursor + i]
  2448. }
  2449. if (length2 <= 1) {
  2450. exit = true
  2451. break
  2452. }
  2453. }
  2454. array[dest--] = array[cursor1--]
  2455. if (--length1 === 0) {
  2456. exit = true
  2457. break
  2458. }
  2459. _minGallop--
  2460. } while (
  2461. count1 >= DEFAULT_MIN_GALLOPING ||
  2462. count2 >= DEFAULT_MIN_GALLOPING
  2463. )
  2464. if (exit) {
  2465. break
  2466. }
  2467. if (_minGallop < 0) {
  2468. _minGallop = 0
  2469. }
  2470. _minGallop += 2
  2471. }
  2472. minGallop = _minGallop
  2473. if (minGallop < 1) {
  2474. minGallop = 1
  2475. }
  2476. if (length2 === 1) {
  2477. dest -= length1
  2478. cursor1 -= length1
  2479. customDest = dest + 1
  2480. customCursor = cursor1 + 1
  2481. for (i = length1 - 1; i >= 0; i--) {
  2482. array[customDest + i] = array[customCursor + i]
  2483. }
  2484. array[dest] = tmp[cursor2]
  2485. } else if (length2 === 0) {
  2486. throw new Error()
  2487. } else {
  2488. customCursor = dest - (length2 - 1)
  2489. for (i = 0; i < length2; i++) {
  2490. array[customCursor + i] = tmp[i]
  2491. }
  2492. }
  2493. }
  2494. return {
  2495. mergeRuns: mergeRuns,
  2496. forceMergeRuns: forceMergeRuns,
  2497. pushRun: pushRun
  2498. }
  2499. }
  2500. function sort(array, compare, lo, hi) {
  2501. if (!lo) {
  2502. lo = 0
  2503. }
  2504. if (!hi) {
  2505. hi = array.length
  2506. }
  2507. var remaining = hi - lo
  2508. if (remaining < 2) {
  2509. return
  2510. }
  2511. var runLength = 0
  2512. if (remaining < DEFAULT_MIN_MERGE) {
  2513. runLength = makeAscendingRun(array, lo, hi, compare)
  2514. binaryInsertionSort(array, lo, hi, lo + runLength, compare)
  2515. return
  2516. }
  2517. var ts = TimSort(array, compare)
  2518. var minRun = minRunLength(remaining)
  2519. do {
  2520. runLength = makeAscendingRun(array, lo, hi, compare)
  2521. if (runLength < minRun) {
  2522. var force = remaining
  2523. if (force > minRun) {
  2524. force = minRun
  2525. }
  2526. binaryInsertionSort(
  2527. array,
  2528. lo,
  2529. lo + force,
  2530. lo + runLength,
  2531. compare
  2532. )
  2533. runLength = force
  2534. }
  2535. ts.pushRun(lo, runLength)
  2536. ts.mergeRuns()
  2537. remaining -= runLength
  2538. lo += runLength
  2539. } while (remaining !== 0)
  2540. ts.forceMergeRuns()
  2541. }
  2542. var REDRAW_BIT = 1
  2543. var STYLE_CHANGED_BIT = 2
  2544. var SHAPE_CHANGED_BIT = 4
  2545. var invalidZErrorLogged = false
  2546. function logInvalidZError() {
  2547. if (invalidZErrorLogged) {
  2548. return
  2549. }
  2550. invalidZErrorLogged = true
  2551. console.warn(
  2552. 'z / z2 / zlevel of displayable is invalid, which may cause unexpected errors'
  2553. )
  2554. }
  2555. function shapeCompareFunc(a, b) {
  2556. if (a.zlevel === b.zlevel) {
  2557. if (a.z === b.z) {
  2558. return a.z2 - b.z2
  2559. }
  2560. return a.z - b.z
  2561. }
  2562. return a.zlevel - b.zlevel
  2563. }
  2564. var Storage = (function () {
  2565. function Storage() {
  2566. this._roots = []
  2567. this._displayList = []
  2568. this._displayListLen = 0
  2569. this.displayableSortFunc = shapeCompareFunc
  2570. }
  2571. Storage.prototype.traverse = function (cb, context) {
  2572. for (var i = 0; i < this._roots.length; i++) {
  2573. this._roots[i].traverse(cb, context)
  2574. }
  2575. }
  2576. Storage.prototype.getDisplayList = function (
  2577. update,
  2578. includeIgnore
  2579. ) {
  2580. includeIgnore = includeIgnore || false
  2581. var displayList = this._displayList
  2582. if (update || !displayList.length) {
  2583. this.updateDisplayList(includeIgnore)
  2584. }
  2585. return displayList
  2586. }
  2587. Storage.prototype.updateDisplayList = function (includeIgnore) {
  2588. this._displayListLen = 0
  2589. var roots = this._roots
  2590. var displayList = this._displayList
  2591. for (var i = 0, len = roots.length; i < len; i++) {
  2592. this._updateAndAddDisplayable(roots[i], null, includeIgnore)
  2593. }
  2594. displayList.length = this._displayListLen
  2595. sort(displayList, shapeCompareFunc)
  2596. }
  2597. Storage.prototype._updateAndAddDisplayable = function (
  2598. el,
  2599. clipPaths,
  2600. includeIgnore
  2601. ) {
  2602. if (el.ignore && !includeIgnore) {
  2603. return
  2604. }
  2605. el.beforeUpdate()
  2606. el.update()
  2607. el.afterUpdate()
  2608. var userSetClipPath = el.getClipPath()
  2609. if (el.ignoreClip) {
  2610. clipPaths = null
  2611. } else if (userSetClipPath) {
  2612. if (clipPaths) {
  2613. clipPaths = clipPaths.slice()
  2614. } else {
  2615. clipPaths = []
  2616. }
  2617. var currentClipPath = userSetClipPath
  2618. var parentClipPath = el
  2619. while (currentClipPath) {
  2620. currentClipPath.parent = parentClipPath
  2621. currentClipPath.updateTransform()
  2622. clipPaths.push(currentClipPath)
  2623. parentClipPath = currentClipPath
  2624. currentClipPath = currentClipPath.getClipPath()
  2625. }
  2626. }
  2627. if (el.childrenRef) {
  2628. var children = el.childrenRef()
  2629. for (var i = 0; i < children.length; i++) {
  2630. var child = children[i]
  2631. if (el.__dirty) {
  2632. child.__dirty |= REDRAW_BIT
  2633. }
  2634. this._updateAndAddDisplayable(child, clipPaths, includeIgnore)
  2635. }
  2636. el.__dirty = 0
  2637. } else {
  2638. var disp = el
  2639. if (clipPaths && clipPaths.length) {
  2640. disp.__clipPaths = clipPaths
  2641. } else if (disp.__clipPaths && disp.__clipPaths.length > 0) {
  2642. disp.__clipPaths = []
  2643. }
  2644. if (isNaN(disp.z)) {
  2645. logInvalidZError()
  2646. disp.z = 0
  2647. }
  2648. if (isNaN(disp.z2)) {
  2649. logInvalidZError()
  2650. disp.z2 = 0
  2651. }
  2652. if (isNaN(disp.zlevel)) {
  2653. logInvalidZError()
  2654. disp.zlevel = 0
  2655. }
  2656. this._displayList[this._displayListLen++] = disp
  2657. }
  2658. var decalEl = el.getDecalElement && el.getDecalElement()
  2659. if (decalEl) {
  2660. this._updateAndAddDisplayable(decalEl, clipPaths, includeIgnore)
  2661. }
  2662. var textGuide = el.getTextGuideLine()
  2663. if (textGuide) {
  2664. this._updateAndAddDisplayable(
  2665. textGuide,
  2666. clipPaths,
  2667. includeIgnore
  2668. )
  2669. }
  2670. var textEl = el.getTextContent()
  2671. if (textEl) {
  2672. this._updateAndAddDisplayable(textEl, clipPaths, includeIgnore)
  2673. }
  2674. }
  2675. Storage.prototype.addRoot = function (el) {
  2676. if (el.__zr && el.__zr.storage === this) {
  2677. return
  2678. }
  2679. this._roots.push(el)
  2680. }
  2681. Storage.prototype.delRoot = function (el) {
  2682. if (el instanceof Array) {
  2683. for (var i = 0, l = el.length; i < l; i++) {
  2684. this.delRoot(el[i])
  2685. }
  2686. return
  2687. }
  2688. var idx = indexOf(this._roots, el)
  2689. if (idx >= 0) {
  2690. this._roots.splice(idx, 1)
  2691. }
  2692. }
  2693. Storage.prototype.delAllRoots = function () {
  2694. this._roots = []
  2695. this._displayList = []
  2696. this._displayListLen = 0
  2697. return
  2698. }
  2699. Storage.prototype.getRoots = function () {
  2700. return this._roots
  2701. }
  2702. Storage.prototype.dispose = function () {
  2703. this._displayList = null
  2704. this._roots = null
  2705. }
  2706. return Storage
  2707. })()
  2708. var Storage$1 = Storage
  2709. var requestAnimationFrame
  2710. requestAnimationFrame =
  2711. (env$1.hasGlobalWindow &&
  2712. ((window.requestAnimationFrame &&
  2713. window.requestAnimationFrame.bind(window)) ||
  2714. (window.msRequestAnimationFrame &&
  2715. window.msRequestAnimationFrame.bind(window)) ||
  2716. window.mozRequestAnimationFrame ||
  2717. window.webkitRequestAnimationFrame)) ||
  2718. function (func) {
  2719. return setTimeout(func, 16)
  2720. }
  2721. var requestAnimationFrame$1 = requestAnimationFrame
  2722. var easingFuncs = {
  2723. linear: function linear(k) {
  2724. return k
  2725. },
  2726. quadraticIn: function quadraticIn(k) {
  2727. return k * k
  2728. },
  2729. quadraticOut: function quadraticOut(k) {
  2730. return k * (2 - k)
  2731. },
  2732. quadraticInOut: function quadraticInOut(k) {
  2733. if ((k *= 2) < 1) {
  2734. return 0.5 * k * k
  2735. }
  2736. return -0.5 * (--k * (k - 2) - 1)
  2737. },
  2738. cubicIn: function cubicIn(k) {
  2739. return k * k * k
  2740. },
  2741. cubicOut: function cubicOut(k) {
  2742. return --k * k * k + 1
  2743. },
  2744. cubicInOut: function cubicInOut(k) {
  2745. if ((k *= 2) < 1) {
  2746. return 0.5 * k * k * k
  2747. }
  2748. return 0.5 * ((k -= 2) * k * k + 2)
  2749. },
  2750. quarticIn: function quarticIn(k) {
  2751. return k * k * k * k
  2752. },
  2753. quarticOut: function quarticOut(k) {
  2754. return 1 - --k * k * k * k
  2755. },
  2756. quarticInOut: function quarticInOut(k) {
  2757. if ((k *= 2) < 1) {
  2758. return 0.5 * k * k * k * k
  2759. }
  2760. return -0.5 * ((k -= 2) * k * k * k - 2)
  2761. },
  2762. quinticIn: function quinticIn(k) {
  2763. return k * k * k * k * k
  2764. },
  2765. quinticOut: function quinticOut(k) {
  2766. return --k * k * k * k * k + 1
  2767. },
  2768. quinticInOut: function quinticInOut(k) {
  2769. if ((k *= 2) < 1) {
  2770. return 0.5 * k * k * k * k * k
  2771. }
  2772. return 0.5 * ((k -= 2) * k * k * k * k + 2)
  2773. },
  2774. sinusoidalIn: function sinusoidalIn(k) {
  2775. return 1 - Math.cos((k * Math.PI) / 2)
  2776. },
  2777. sinusoidalOut: function sinusoidalOut(k) {
  2778. return Math.sin((k * Math.PI) / 2)
  2779. },
  2780. sinusoidalInOut: function sinusoidalInOut(k) {
  2781. return 0.5 * (1 - Math.cos(Math.PI * k))
  2782. },
  2783. exponentialIn: function exponentialIn(k) {
  2784. return k === 0 ? 0 : Math.pow(1024, k - 1)
  2785. },
  2786. exponentialOut: function exponentialOut(k) {
  2787. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k)
  2788. },
  2789. exponentialInOut: function exponentialInOut(k) {
  2790. if (k === 0) {
  2791. return 0
  2792. }
  2793. if (k === 1) {
  2794. return 1
  2795. }
  2796. if ((k *= 2) < 1) {
  2797. return 0.5 * Math.pow(1024, k - 1)
  2798. }
  2799. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2)
  2800. },
  2801. circularIn: function circularIn(k) {
  2802. return 1 - Math.sqrt(1 - k * k)
  2803. },
  2804. circularOut: function circularOut(k) {
  2805. return Math.sqrt(1 - --k * k)
  2806. },
  2807. circularInOut: function circularInOut(k) {
  2808. if ((k *= 2) < 1) {
  2809. return -0.5 * (Math.sqrt(1 - k * k) - 1)
  2810. }
  2811. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1)
  2812. },
  2813. elasticIn: function elasticIn(k) {
  2814. var s
  2815. var a = 0.1
  2816. var p = 0.4
  2817. if (k === 0) {
  2818. return 0
  2819. }
  2820. if (k === 1) {
  2821. return 1
  2822. }
  2823. if (!a || a < 1) {
  2824. a = 1
  2825. s = p / 4
  2826. } else {
  2827. s = (p * Math.asin(1 / a)) / (2 * Math.PI)
  2828. }
  2829. return -(
  2830. a *
  2831. Math.pow(2, 10 * (k -= 1)) *
  2832. Math.sin(((k - s) * (2 * Math.PI)) / p)
  2833. )
  2834. },
  2835. elasticOut: function elasticOut(k) {
  2836. var s
  2837. var a = 0.1
  2838. var p = 0.4
  2839. if (k === 0) {
  2840. return 0
  2841. }
  2842. if (k === 1) {
  2843. return 1
  2844. }
  2845. if (!a || a < 1) {
  2846. a = 1
  2847. s = p / 4
  2848. } else {
  2849. s = (p * Math.asin(1 / a)) / (2 * Math.PI)
  2850. }
  2851. return (
  2852. a *
  2853. Math.pow(2, -10 * k) *
  2854. Math.sin(((k - s) * (2 * Math.PI)) / p) +
  2855. 1
  2856. )
  2857. },
  2858. elasticInOut: function elasticInOut(k) {
  2859. var s
  2860. var a = 0.1
  2861. var p = 0.4
  2862. if (k === 0) {
  2863. return 0
  2864. }
  2865. if (k === 1) {
  2866. return 1
  2867. }
  2868. if (!a || a < 1) {
  2869. a = 1
  2870. s = p / 4
  2871. } else {
  2872. s = (p * Math.asin(1 / a)) / (2 * Math.PI)
  2873. }
  2874. if ((k *= 2) < 1) {
  2875. return (
  2876. -0.5 *
  2877. (a *
  2878. Math.pow(2, 10 * (k -= 1)) *
  2879. Math.sin(((k - s) * (2 * Math.PI)) / p))
  2880. )
  2881. }
  2882. return (
  2883. a *
  2884. Math.pow(2, -10 * (k -= 1)) *
  2885. Math.sin(((k - s) * (2 * Math.PI)) / p) *
  2886. 0.5 +
  2887. 1
  2888. )
  2889. },
  2890. backIn: function backIn(k) {
  2891. var s = 1.70158
  2892. return k * k * ((s + 1) * k - s)
  2893. },
  2894. backOut: function backOut(k) {
  2895. var s = 1.70158
  2896. return --k * k * ((s + 1) * k + s) + 1
  2897. },
  2898. backInOut: function backInOut(k) {
  2899. var s = 1.70158 * 1.525
  2900. if ((k *= 2) < 1) {
  2901. return 0.5 * (k * k * ((s + 1) * k - s))
  2902. }
  2903. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2)
  2904. },
  2905. bounceIn: function bounceIn(k) {
  2906. return 1 - easingFuncs.bounceOut(1 - k)
  2907. },
  2908. bounceOut: function bounceOut(k) {
  2909. if (k < 1 / 2.75) {
  2910. return 7.5625 * k * k
  2911. } else if (k < 2 / 2.75) {
  2912. return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75
  2913. } else if (k < 2.5 / 2.75) {
  2914. return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375
  2915. } else {
  2916. return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375
  2917. }
  2918. },
  2919. bounceInOut: function bounceInOut(k) {
  2920. if (k < 0.5) {
  2921. return easingFuncs.bounceIn(k * 2) * 0.5
  2922. }
  2923. return easingFuncs.bounceOut(k * 2 - 1) * 0.5 + 0.5
  2924. }
  2925. }
  2926. var easingFuncs$1 = easingFuncs
  2927. var mathPow$2 = Math.pow
  2928. var mathSqrt$3 = Math.sqrt
  2929. var EPSILON$2 = 1e-8
  2930. var EPSILON_NUMERIC = 1e-4
  2931. var THREE_SQRT = mathSqrt$3(3)
  2932. var ONE_THIRD = 1 / 3
  2933. var _v0 = create$1()
  2934. var _v1 = create$1()
  2935. var _v2 = create$1()
  2936. function isAroundZero(val) {
  2937. return val > -EPSILON$2 && val < EPSILON$2
  2938. }
  2939. function isNotAroundZero$1(val) {
  2940. return val > EPSILON$2 || val < -EPSILON$2
  2941. }
  2942. function cubicAt(p0, p1, p2, p3, t) {
  2943. var onet = 1 - t
  2944. return (
  2945. onet * onet * (onet * p0 + 3 * t * p1) +
  2946. t * t * (t * p3 + 3 * onet * p2)
  2947. )
  2948. }
  2949. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  2950. var onet = 1 - t
  2951. return (
  2952. 3 *
  2953. (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet +
  2954. (p3 - p2) * t * t)
  2955. )
  2956. }
  2957. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  2958. var a = p3 + 3 * (p1 - p2) - p0
  2959. var b = 3 * (p2 - p1 * 2 + p0)
  2960. var c = 3 * (p1 - p0)
  2961. var d = p0 - val
  2962. var A = b * b - 3 * a * c
  2963. var B = b * c - 9 * a * d
  2964. var C = c * c - 3 * b * d
  2965. var n = 0
  2966. if (isAroundZero(A) && isAroundZero(B)) {
  2967. if (isAroundZero(b)) {
  2968. roots[0] = 0
  2969. } else {
  2970. var t1 = -c / b
  2971. if (t1 >= 0 && t1 <= 1) {
  2972. roots[n++] = t1
  2973. }
  2974. }
  2975. } else {
  2976. var disc = B * B - 4 * A * C
  2977. if (isAroundZero(disc)) {
  2978. var K = B / A
  2979. var t1 = -b / a + K
  2980. var t2 = -K / 2
  2981. if (t1 >= 0 && t1 <= 1) {
  2982. roots[n++] = t1
  2983. }
  2984. if (t2 >= 0 && t2 <= 1) {
  2985. roots[n++] = t2
  2986. }
  2987. } else if (disc > 0) {
  2988. var discSqrt = mathSqrt$3(disc)
  2989. var Y1 = A * b + 1.5 * a * (-B + discSqrt)
  2990. var Y2 = A * b + 1.5 * a * (-B - discSqrt)
  2991. if (Y1 < 0) {
  2992. Y1 = -mathPow$2(-Y1, ONE_THIRD)
  2993. } else {
  2994. Y1 = mathPow$2(Y1, ONE_THIRD)
  2995. }
  2996. if (Y2 < 0) {
  2997. Y2 = -mathPow$2(-Y2, ONE_THIRD)
  2998. } else {
  2999. Y2 = mathPow$2(Y2, ONE_THIRD)
  3000. }
  3001. var t1 = (-b - (Y1 + Y2)) / (3 * a)
  3002. if (t1 >= 0 && t1 <= 1) {
  3003. roots[n++] = t1
  3004. }
  3005. } else {
  3006. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt$3(A * A * A))
  3007. var theta = Math.acos(T) / 3
  3008. var ASqrt = mathSqrt$3(A)
  3009. var tmp = Math.cos(theta)
  3010. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a)
  3011. var t2 =
  3012. (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a)
  3013. var t3 =
  3014. (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a)
  3015. if (t1 >= 0 && t1 <= 1) {
  3016. roots[n++] = t1
  3017. }
  3018. if (t2 >= 0 && t2 <= 1) {
  3019. roots[n++] = t2
  3020. }
  3021. if (t3 >= 0 && t3 <= 1) {
  3022. roots[n++] = t3
  3023. }
  3024. }
  3025. }
  3026. return n
  3027. }
  3028. function cubicExtrema(p0, p1, p2, p3, extrema) {
  3029. var b = 6 * p2 - 12 * p1 + 6 * p0
  3030. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2
  3031. var c = 3 * p1 - 3 * p0
  3032. var n = 0
  3033. if (isAroundZero(a)) {
  3034. if (isNotAroundZero$1(b)) {
  3035. var t1 = -c / b
  3036. if (t1 >= 0 && t1 <= 1) {
  3037. extrema[n++] = t1
  3038. }
  3039. }
  3040. } else {
  3041. var disc = b * b - 4 * a * c
  3042. if (isAroundZero(disc)) {
  3043. extrema[0] = -b / (2 * a)
  3044. } else if (disc > 0) {
  3045. var discSqrt = mathSqrt$3(disc)
  3046. var t1 = (-b + discSqrt) / (2 * a)
  3047. var t2 = (-b - discSqrt) / (2 * a)
  3048. if (t1 >= 0 && t1 <= 1) {
  3049. extrema[n++] = t1
  3050. }
  3051. if (t2 >= 0 && t2 <= 1) {
  3052. extrema[n++] = t2
  3053. }
  3054. }
  3055. }
  3056. return n
  3057. }
  3058. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  3059. var p01 = (p1 - p0) * t + p0
  3060. var p12 = (p2 - p1) * t + p1
  3061. var p23 = (p3 - p2) * t + p2
  3062. var p012 = (p12 - p01) * t + p01
  3063. var p123 = (p23 - p12) * t + p12
  3064. var p0123 = (p123 - p012) * t + p012
  3065. out[0] = p0
  3066. out[1] = p01
  3067. out[2] = p012
  3068. out[3] = p0123
  3069. out[4] = p0123
  3070. out[5] = p123
  3071. out[6] = p23
  3072. out[7] = p3
  3073. }
  3074. function cubicProjectPoint(
  3075. x0,
  3076. y0,
  3077. x1,
  3078. y1,
  3079. x2,
  3080. y2,
  3081. x3,
  3082. y3,
  3083. x,
  3084. y,
  3085. out
  3086. ) {
  3087. var t
  3088. var interval = 0.005
  3089. var d = Infinity
  3090. var prev
  3091. var next
  3092. var d1
  3093. var d2
  3094. _v0[0] = x
  3095. _v0[1] = y
  3096. for (var _t = 0; _t < 1; _t += 0.05) {
  3097. _v1[0] = cubicAt(x0, x1, x2, x3, _t)
  3098. _v1[1] = cubicAt(y0, y1, y2, y3, _t)
  3099. d1 = distSquare(_v0, _v1)
  3100. if (d1 < d) {
  3101. t = _t
  3102. d = d1
  3103. }
  3104. }
  3105. d = Infinity
  3106. for (var i = 0; i < 32; i++) {
  3107. if (interval < EPSILON_NUMERIC) {
  3108. break
  3109. }
  3110. prev = t - interval
  3111. next = t + interval
  3112. _v1[0] = cubicAt(x0, x1, x2, x3, prev)
  3113. _v1[1] = cubicAt(y0, y1, y2, y3, prev)
  3114. d1 = distSquare(_v1, _v0)
  3115. if (prev >= 0 && d1 < d) {
  3116. t = prev
  3117. d = d1
  3118. } else {
  3119. _v2[0] = cubicAt(x0, x1, x2, x3, next)
  3120. _v2[1] = cubicAt(y0, y1, y2, y3, next)
  3121. d2 = distSquare(_v2, _v0)
  3122. if (next <= 1 && d2 < d) {
  3123. t = next
  3124. d = d2
  3125. } else {
  3126. interval *= 0.5
  3127. }
  3128. }
  3129. }
  3130. if (out) {
  3131. out[0] = cubicAt(x0, x1, x2, x3, t)
  3132. out[1] = cubicAt(y0, y1, y2, y3, t)
  3133. }
  3134. return mathSqrt$3(d)
  3135. }
  3136. function cubicLength(x0, y0, x1, y1, x2, y2, x3, y3, iteration) {
  3137. var px = x0
  3138. var py = y0
  3139. var d = 0
  3140. var step = 1 / iteration
  3141. for (var i = 1; i <= iteration; i++) {
  3142. var t = i * step
  3143. var x = cubicAt(x0, x1, x2, x3, t)
  3144. var y = cubicAt(y0, y1, y2, y3, t)
  3145. var dx = x - px
  3146. var dy = y - py
  3147. d += Math.sqrt(dx * dx + dy * dy)
  3148. px = x
  3149. py = y
  3150. }
  3151. return d
  3152. }
  3153. function quadraticAt(p0, p1, p2, t) {
  3154. var onet = 1 - t
  3155. return onet * (onet * p0 + 2 * t * p1) + t * t * p2
  3156. }
  3157. function quadraticDerivativeAt(p0, p1, p2, t) {
  3158. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1))
  3159. }
  3160. function quadraticRootAt(p0, p1, p2, val, roots) {
  3161. var a = p0 - 2 * p1 + p2
  3162. var b = 2 * (p1 - p0)
  3163. var c = p0 - val
  3164. var n = 0
  3165. if (isAroundZero(a)) {
  3166. if (isNotAroundZero$1(b)) {
  3167. var t1 = -c / b
  3168. if (t1 >= 0 && t1 <= 1) {
  3169. roots[n++] = t1
  3170. }
  3171. }
  3172. } else {
  3173. var disc = b * b - 4 * a * c
  3174. if (isAroundZero(disc)) {
  3175. var t1 = -b / (2 * a)
  3176. if (t1 >= 0 && t1 <= 1) {
  3177. roots[n++] = t1
  3178. }
  3179. } else if (disc > 0) {
  3180. var discSqrt = mathSqrt$3(disc)
  3181. var t1 = (-b + discSqrt) / (2 * a)
  3182. var t2 = (-b - discSqrt) / (2 * a)
  3183. if (t1 >= 0 && t1 <= 1) {
  3184. roots[n++] = t1
  3185. }
  3186. if (t2 >= 0 && t2 <= 1) {
  3187. roots[n++] = t2
  3188. }
  3189. }
  3190. }
  3191. return n
  3192. }
  3193. function quadraticExtremum(p0, p1, p2) {
  3194. var divider = p0 + p2 - 2 * p1
  3195. if (divider === 0) {
  3196. return 0.5
  3197. } else {
  3198. return (p0 - p1) / divider
  3199. }
  3200. }
  3201. function quadraticSubdivide(p0, p1, p2, t, out) {
  3202. var p01 = (p1 - p0) * t + p0
  3203. var p12 = (p2 - p1) * t + p1
  3204. var p012 = (p12 - p01) * t + p01
  3205. out[0] = p0
  3206. out[1] = p01
  3207. out[2] = p012
  3208. out[3] = p012
  3209. out[4] = p12
  3210. out[5] = p2
  3211. }
  3212. function quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, out) {
  3213. var t
  3214. var interval = 0.005
  3215. var d = Infinity
  3216. _v0[0] = x
  3217. _v0[1] = y
  3218. for (var _t = 0; _t < 1; _t += 0.05) {
  3219. _v1[0] = quadraticAt(x0, x1, x2, _t)
  3220. _v1[1] = quadraticAt(y0, y1, y2, _t)
  3221. var d1 = distSquare(_v0, _v1)
  3222. if (d1 < d) {
  3223. t = _t
  3224. d = d1
  3225. }
  3226. }
  3227. d = Infinity
  3228. for (var i = 0; i < 32; i++) {
  3229. if (interval < EPSILON_NUMERIC) {
  3230. break
  3231. }
  3232. var prev = t - interval
  3233. var next = t + interval
  3234. _v1[0] = quadraticAt(x0, x1, x2, prev)
  3235. _v1[1] = quadraticAt(y0, y1, y2, prev)
  3236. var d1 = distSquare(_v1, _v0)
  3237. if (prev >= 0 && d1 < d) {
  3238. t = prev
  3239. d = d1
  3240. } else {
  3241. _v2[0] = quadraticAt(x0, x1, x2, next)
  3242. _v2[1] = quadraticAt(y0, y1, y2, next)
  3243. var d2 = distSquare(_v2, _v0)
  3244. if (next <= 1 && d2 < d) {
  3245. t = next
  3246. d = d2
  3247. } else {
  3248. interval *= 0.5
  3249. }
  3250. }
  3251. }
  3252. if (out) {
  3253. out[0] = quadraticAt(x0, x1, x2, t)
  3254. out[1] = quadraticAt(y0, y1, y2, t)
  3255. }
  3256. return mathSqrt$3(d)
  3257. }
  3258. function quadraticLength(x0, y0, x1, y1, x2, y2, iteration) {
  3259. var px = x0
  3260. var py = y0
  3261. var d = 0
  3262. var step = 1 / iteration
  3263. for (var i = 1; i <= iteration; i++) {
  3264. var t = i * step
  3265. var x = quadraticAt(x0, x1, x2, t)
  3266. var y = quadraticAt(y0, y1, y2, t)
  3267. var dx = x - px
  3268. var dy = y - py
  3269. d += Math.sqrt(dx * dx + dy * dy)
  3270. px = x
  3271. py = y
  3272. }
  3273. return d
  3274. }
  3275. var regexp = /cubic-bezier\(([0-9,\.e ]+)\)/
  3276. function createCubicEasingFunc(cubicEasingStr) {
  3277. var cubic = cubicEasingStr && regexp.exec(cubicEasingStr)
  3278. if (cubic) {
  3279. var points = cubic[1].split(',')
  3280. var a_1 = +trim$1(points[0])
  3281. var b_1 = +trim$1(points[1])
  3282. var c_1 = +trim$1(points[2])
  3283. var d_1 = +trim$1(points[3])
  3284. if (isNaN(a_1 + b_1 + c_1 + d_1)) {
  3285. return
  3286. }
  3287. var roots_1 = []
  3288. return function (p) {
  3289. return p <= 0
  3290. ? 0
  3291. : p >= 1
  3292. ? 1
  3293. : cubicRootAt(0, a_1, c_1, 1, p, roots_1) &&
  3294. cubicAt(0, b_1, d_1, 1, roots_1[0])
  3295. }
  3296. }
  3297. }
  3298. var Clip = (function () {
  3299. function Clip(opts) {
  3300. this._inited = false
  3301. this._startTime = 0
  3302. this._pausedTime = 0
  3303. this._paused = false
  3304. this._life = opts.life || 1000
  3305. this._delay = opts.delay || 0
  3306. this.loop = opts.loop || false
  3307. this.onframe = opts.onframe || noop
  3308. this.ondestroy = opts.ondestroy || noop
  3309. this.onrestart = opts.onrestart || noop
  3310. opts.easing && this.setEasing(opts.easing)
  3311. }
  3312. Clip.prototype.step = function (globalTime, deltaTime) {
  3313. if (!this._inited) {
  3314. this._startTime = globalTime + this._delay
  3315. this._inited = true
  3316. }
  3317. if (this._paused) {
  3318. this._pausedTime += deltaTime
  3319. return
  3320. }
  3321. var life = this._life
  3322. var elapsedTime = globalTime - this._startTime - this._pausedTime
  3323. var percent = elapsedTime / life
  3324. if (percent < 0) {
  3325. percent = 0
  3326. }
  3327. percent = Math.min(percent, 1)
  3328. var easingFunc = this.easingFunc
  3329. var schedule = easingFunc ? easingFunc(percent) : percent
  3330. this.onframe(schedule)
  3331. if (percent === 1) {
  3332. if (this.loop) {
  3333. var remainder = elapsedTime % life
  3334. this._startTime = globalTime - remainder
  3335. this._pausedTime = 0
  3336. this.onrestart()
  3337. } else {
  3338. return true
  3339. }
  3340. }
  3341. return false
  3342. }
  3343. Clip.prototype.pause = function () {
  3344. this._paused = true
  3345. }
  3346. Clip.prototype.resume = function () {
  3347. this._paused = false
  3348. }
  3349. Clip.prototype.setEasing = function (easing) {
  3350. this.easing = easing
  3351. this.easingFunc = isFunction(easing)
  3352. ? easing
  3353. : easingFuncs$1[easing] || createCubicEasingFunc(easing)
  3354. }
  3355. return Clip
  3356. })()
  3357. var Clip$1 = Clip
  3358. var Entry = (function () {
  3359. function Entry(val) {
  3360. this.value = val
  3361. }
  3362. return Entry
  3363. })()
  3364. var LinkedList = (function () {
  3365. function LinkedList() {
  3366. this._len = 0
  3367. }
  3368. LinkedList.prototype.insert = function (val) {
  3369. var entry = new Entry(val)
  3370. this.insertEntry(entry)
  3371. return entry
  3372. }
  3373. LinkedList.prototype.insertEntry = function (entry) {
  3374. if (!this.head) {
  3375. this.head = this.tail = entry
  3376. } else {
  3377. this.tail.next = entry
  3378. entry.prev = this.tail
  3379. entry.next = null
  3380. this.tail = entry
  3381. }
  3382. this._len++
  3383. }
  3384. LinkedList.prototype.remove = function (entry) {
  3385. var prev = entry.prev
  3386. var next = entry.next
  3387. if (prev) {
  3388. prev.next = next
  3389. } else {
  3390. this.head = next
  3391. }
  3392. if (next) {
  3393. next.prev = prev
  3394. } else {
  3395. this.tail = prev
  3396. }
  3397. entry.next = entry.prev = null
  3398. this._len--
  3399. }
  3400. LinkedList.prototype.len = function () {
  3401. return this._len
  3402. }
  3403. LinkedList.prototype.clear = function () {
  3404. this.head = this.tail = null
  3405. this._len = 0
  3406. }
  3407. return LinkedList
  3408. })()
  3409. var LRU = (function () {
  3410. function LRU(maxSize) {
  3411. this._list = new LinkedList()
  3412. this._maxSize = 10
  3413. this._map = {}
  3414. this._maxSize = maxSize
  3415. }
  3416. LRU.prototype.put = function (key, value) {
  3417. var list = this._list
  3418. var map = this._map
  3419. var removed = null
  3420. if (map[key] == null) {
  3421. var len = list.len()
  3422. var entry = this._lastRemovedEntry
  3423. if (len >= this._maxSize && len > 0) {
  3424. var leastUsedEntry = list.head
  3425. list.remove(leastUsedEntry)
  3426. delete map[leastUsedEntry.key]
  3427. removed = leastUsedEntry.value
  3428. this._lastRemovedEntry = leastUsedEntry
  3429. }
  3430. if (entry) {
  3431. entry.value = value
  3432. } else {
  3433. entry = new Entry(value)
  3434. }
  3435. entry.key = key
  3436. list.insertEntry(entry)
  3437. map[key] = entry
  3438. }
  3439. return removed
  3440. }
  3441. LRU.prototype.get = function (key) {
  3442. var entry = this._map[key]
  3443. var list = this._list
  3444. if (entry != null) {
  3445. if (entry !== list.tail) {
  3446. list.remove(entry)
  3447. list.insertEntry(entry)
  3448. }
  3449. return entry.value
  3450. }
  3451. }
  3452. LRU.prototype.clear = function () {
  3453. this._list.clear()
  3454. this._map = {}
  3455. }
  3456. LRU.prototype.len = function () {
  3457. return this._list.len()
  3458. }
  3459. return LRU
  3460. })()
  3461. var LRU$1 = LRU
  3462. var kCSSColorTable = {
  3463. transparent: [0, 0, 0, 0],
  3464. aliceblue: [240, 248, 255, 1],
  3465. antiquewhite: [250, 235, 215, 1],
  3466. aqua: [0, 255, 255, 1],
  3467. aquamarine: [127, 255, 212, 1],
  3468. azure: [240, 255, 255, 1],
  3469. beige: [245, 245, 220, 1],
  3470. bisque: [255, 228, 196, 1],
  3471. black: [0, 0, 0, 1],
  3472. blanchedalmond: [255, 235, 205, 1],
  3473. blue: [0, 0, 255, 1],
  3474. blueviolet: [138, 43, 226, 1],
  3475. brown: [165, 42, 42, 1],
  3476. burlywood: [222, 184, 135, 1],
  3477. cadetblue: [95, 158, 160, 1],
  3478. chartreuse: [127, 255, 0, 1],
  3479. chocolate: [210, 105, 30, 1],
  3480. coral: [255, 127, 80, 1],
  3481. cornflowerblue: [100, 149, 237, 1],
  3482. cornsilk: [255, 248, 220, 1],
  3483. crimson: [220, 20, 60, 1],
  3484. cyan: [0, 255, 255, 1],
  3485. darkblue: [0, 0, 139, 1],
  3486. darkcyan: [0, 139, 139, 1],
  3487. darkgoldenrod: [184, 134, 11, 1],
  3488. darkgray: [169, 169, 169, 1],
  3489. darkgreen: [0, 100, 0, 1],
  3490. darkgrey: [169, 169, 169, 1],
  3491. darkkhaki: [189, 183, 107, 1],
  3492. darkmagenta: [139, 0, 139, 1],
  3493. darkolivegreen: [85, 107, 47, 1],
  3494. darkorange: [255, 140, 0, 1],
  3495. darkorchid: [153, 50, 204, 1],
  3496. darkred: [139, 0, 0, 1],
  3497. darksalmon: [233, 150, 122, 1],
  3498. darkseagreen: [143, 188, 143, 1],
  3499. darkslateblue: [72, 61, 139, 1],
  3500. darkslategray: [47, 79, 79, 1],
  3501. darkslategrey: [47, 79, 79, 1],
  3502. darkturquoise: [0, 206, 209, 1],
  3503. darkviolet: [148, 0, 211, 1],
  3504. deeppink: [255, 20, 147, 1],
  3505. deepskyblue: [0, 191, 255, 1],
  3506. dimgray: [105, 105, 105, 1],
  3507. dimgrey: [105, 105, 105, 1],
  3508. dodgerblue: [30, 144, 255, 1],
  3509. firebrick: [178, 34, 34, 1],
  3510. floralwhite: [255, 250, 240, 1],
  3511. forestgreen: [34, 139, 34, 1],
  3512. fuchsia: [255, 0, 255, 1],
  3513. gainsboro: [220, 220, 220, 1],
  3514. ghostwhite: [248, 248, 255, 1],
  3515. gold: [255, 215, 0, 1],
  3516. goldenrod: [218, 165, 32, 1],
  3517. gray: [128, 128, 128, 1],
  3518. green: [0, 128, 0, 1],
  3519. greenyellow: [173, 255, 47, 1],
  3520. grey: [128, 128, 128, 1],
  3521. honeydew: [240, 255, 240, 1],
  3522. hotpink: [255, 105, 180, 1],
  3523. indianred: [205, 92, 92, 1],
  3524. indigo: [75, 0, 130, 1],
  3525. ivory: [255, 255, 240, 1],
  3526. khaki: [240, 230, 140, 1],
  3527. lavender: [230, 230, 250, 1],
  3528. lavenderblush: [255, 240, 245, 1],
  3529. lawngreen: [124, 252, 0, 1],
  3530. lemonchiffon: [255, 250, 205, 1],
  3531. lightblue: [173, 216, 230, 1],
  3532. lightcoral: [240, 128, 128, 1],
  3533. lightcyan: [224, 255, 255, 1],
  3534. lightgoldenrodyellow: [250, 250, 210, 1],
  3535. lightgray: [211, 211, 211, 1],
  3536. lightgreen: [144, 238, 144, 1],
  3537. lightgrey: [211, 211, 211, 1],
  3538. lightpink: [255, 182, 193, 1],
  3539. lightsalmon: [255, 160, 122, 1],
  3540. lightseagreen: [32, 178, 170, 1],
  3541. lightskyblue: [135, 206, 250, 1],
  3542. lightslategray: [119, 136, 153, 1],
  3543. lightslategrey: [119, 136, 153, 1],
  3544. lightsteelblue: [176, 196, 222, 1],
  3545. lightyellow: [255, 255, 224, 1],
  3546. lime: [0, 255, 0, 1],
  3547. limegreen: [50, 205, 50, 1],
  3548. linen: [250, 240, 230, 1],
  3549. magenta: [255, 0, 255, 1],
  3550. maroon: [128, 0, 0, 1],
  3551. mediumaquamarine: [102, 205, 170, 1],
  3552. mediumblue: [0, 0, 205, 1],
  3553. mediumorchid: [186, 85, 211, 1],
  3554. mediumpurple: [147, 112, 219, 1],
  3555. mediumseagreen: [60, 179, 113, 1],
  3556. mediumslateblue: [123, 104, 238, 1],
  3557. mediumspringgreen: [0, 250, 154, 1],
  3558. mediumturquoise: [72, 209, 204, 1],
  3559. mediumvioletred: [199, 21, 133, 1],
  3560. midnightblue: [25, 25, 112, 1],
  3561. mintcream: [245, 255, 250, 1],
  3562. mistyrose: [255, 228, 225, 1],
  3563. moccasin: [255, 228, 181, 1],
  3564. navajowhite: [255, 222, 173, 1],
  3565. navy: [0, 0, 128, 1],
  3566. oldlace: [253, 245, 230, 1],
  3567. olive: [128, 128, 0, 1],
  3568. olivedrab: [107, 142, 35, 1],
  3569. orange: [255, 165, 0, 1],
  3570. orangered: [255, 69, 0, 1],
  3571. orchid: [218, 112, 214, 1],
  3572. palegoldenrod: [238, 232, 170, 1],
  3573. palegreen: [152, 251, 152, 1],
  3574. paleturquoise: [175, 238, 238, 1],
  3575. palevioletred: [219, 112, 147, 1],
  3576. papayawhip: [255, 239, 213, 1],
  3577. peachpuff: [255, 218, 185, 1],
  3578. peru: [205, 133, 63, 1],
  3579. pink: [255, 192, 203, 1],
  3580. plum: [221, 160, 221, 1],
  3581. powderblue: [176, 224, 230, 1],
  3582. purple: [128, 0, 128, 1],
  3583. red: [255, 0, 0, 1],
  3584. rosybrown: [188, 143, 143, 1],
  3585. royalblue: [65, 105, 225, 1],
  3586. saddlebrown: [139, 69, 19, 1],
  3587. salmon: [250, 128, 114, 1],
  3588. sandybrown: [244, 164, 96, 1],
  3589. seagreen: [46, 139, 87, 1],
  3590. seashell: [255, 245, 238, 1],
  3591. sienna: [160, 82, 45, 1],
  3592. silver: [192, 192, 192, 1],
  3593. skyblue: [135, 206, 235, 1],
  3594. slateblue: [106, 90, 205, 1],
  3595. slategray: [112, 128, 144, 1],
  3596. slategrey: [112, 128, 144, 1],
  3597. snow: [255, 250, 250, 1],
  3598. springgreen: [0, 255, 127, 1],
  3599. steelblue: [70, 130, 180, 1],
  3600. tan: [210, 180, 140, 1],
  3601. teal: [0, 128, 128, 1],
  3602. thistle: [216, 191, 216, 1],
  3603. tomato: [255, 99, 71, 1],
  3604. turquoise: [64, 224, 208, 1],
  3605. violet: [238, 130, 238, 1],
  3606. wheat: [245, 222, 179, 1],
  3607. white: [255, 255, 255, 1],
  3608. whitesmoke: [245, 245, 245, 1],
  3609. yellow: [255, 255, 0, 1],
  3610. yellowgreen: [154, 205, 50, 1]
  3611. }
  3612. function clampCssByte(i) {
  3613. i = Math.round(i)
  3614. return i < 0 ? 0 : i > 255 ? 255 : i
  3615. }
  3616. function clampCssFloat(f) {
  3617. return f < 0 ? 0 : f > 1 ? 1 : f
  3618. }
  3619. function parseCssInt(val) {
  3620. var str = val
  3621. if (str.length && str.charAt(str.length - 1) === '%') {
  3622. return clampCssByte((parseFloat(str) / 100) * 255)
  3623. }
  3624. return clampCssByte(parseInt(str, 10))
  3625. }
  3626. function parseCssFloat(val) {
  3627. var str = val
  3628. if (str.length && str.charAt(str.length - 1) === '%') {
  3629. return clampCssFloat(parseFloat(str) / 100)
  3630. }
  3631. return clampCssFloat(parseFloat(str))
  3632. }
  3633. function cssHueToRgb(m1, m2, h) {
  3634. if (h < 0) {
  3635. h += 1
  3636. } else if (h > 1) {
  3637. h -= 1
  3638. }
  3639. if (h * 6 < 1) {
  3640. return m1 + (m2 - m1) * h * 6
  3641. }
  3642. if (h * 2 < 1) {
  3643. return m2
  3644. }
  3645. if (h * 3 < 2) {
  3646. return m1 + (m2 - m1) * (2 / 3 - h) * 6
  3647. }
  3648. return m1
  3649. }
  3650. function lerpNumber(a, b, p) {
  3651. return a + (b - a) * p
  3652. }
  3653. function setRgba(out, r, g, b, a) {
  3654. out[0] = r
  3655. out[1] = g
  3656. out[2] = b
  3657. out[3] = a
  3658. return out
  3659. }
  3660. function copyRgba(out, a) {
  3661. out[0] = a[0]
  3662. out[1] = a[1]
  3663. out[2] = a[2]
  3664. out[3] = a[3]
  3665. return out
  3666. }
  3667. var colorCache = new LRU$1(20)
  3668. var lastRemovedArr = null
  3669. function putToCache(colorStr, rgbaArr) {
  3670. if (lastRemovedArr) {
  3671. copyRgba(lastRemovedArr, rgbaArr)
  3672. }
  3673. lastRemovedArr = colorCache.put(
  3674. colorStr,
  3675. lastRemovedArr || rgbaArr.slice()
  3676. )
  3677. }
  3678. function parse(colorStr, rgbaArr) {
  3679. if (!colorStr) {
  3680. return
  3681. }
  3682. rgbaArr = rgbaArr || []
  3683. var cached = colorCache.get(colorStr)
  3684. if (cached) {
  3685. return copyRgba(rgbaArr, cached)
  3686. }
  3687. colorStr = colorStr + ''
  3688. var str = colorStr.replace(/ /g, '').toLowerCase()
  3689. if (str in kCSSColorTable) {
  3690. copyRgba(rgbaArr, kCSSColorTable[str])
  3691. putToCache(colorStr, rgbaArr)
  3692. return rgbaArr
  3693. }
  3694. var strLen = str.length
  3695. if (str.charAt(0) === '#') {
  3696. if (strLen === 4 || strLen === 5) {
  3697. var iv = parseInt(str.slice(1, 4), 16)
  3698. if (!(iv >= 0 && iv <= 0xfff)) {
  3699. setRgba(rgbaArr, 0, 0, 0, 1)
  3700. return
  3701. }
  3702. setRgba(
  3703. rgbaArr,
  3704. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  3705. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  3706. (iv & 0xf) | ((iv & 0xf) << 4),
  3707. strLen === 5 ? parseInt(str.slice(4), 16) / 0xf : 1
  3708. )
  3709. putToCache(colorStr, rgbaArr)
  3710. return rgbaArr
  3711. } else if (strLen === 7 || strLen === 9) {
  3712. var iv = parseInt(str.slice(1, 7), 16)
  3713. if (!(iv >= 0 && iv <= 0xffffff)) {
  3714. setRgba(rgbaArr, 0, 0, 0, 1)
  3715. return
  3716. }
  3717. setRgba(
  3718. rgbaArr,
  3719. (iv & 0xff0000) >> 16,
  3720. (iv & 0xff00) >> 8,
  3721. iv & 0xff,
  3722. strLen === 9 ? parseInt(str.slice(7), 16) / 0xff : 1
  3723. )
  3724. putToCache(colorStr, rgbaArr)
  3725. return rgbaArr
  3726. }
  3727. return
  3728. }
  3729. var op = str.indexOf('(')
  3730. var ep = str.indexOf(')')
  3731. if (op !== -1 && ep + 1 === strLen) {
  3732. var fname = str.substr(0, op)
  3733. var params = str.substr(op + 1, ep - (op + 1)).split(',')
  3734. var alpha = 1
  3735. switch (fname) {
  3736. case 'rgba':
  3737. if (params.length !== 4) {
  3738. return params.length === 3
  3739. ? setRgba(rgbaArr, +params[0], +params[1], +params[2], 1)
  3740. : setRgba(rgbaArr, 0, 0, 0, 1)
  3741. }
  3742. alpha = parseCssFloat(params.pop())
  3743. case 'rgb':
  3744. if (params.length !== 3) {
  3745. setRgba(rgbaArr, 0, 0, 0, 1)
  3746. return
  3747. }
  3748. setRgba(
  3749. rgbaArr,
  3750. parseCssInt(params[0]),
  3751. parseCssInt(params[1]),
  3752. parseCssInt(params[2]),
  3753. alpha
  3754. )
  3755. putToCache(colorStr, rgbaArr)
  3756. return rgbaArr
  3757. case 'hsla':
  3758. if (params.length !== 4) {
  3759. setRgba(rgbaArr, 0, 0, 0, 1)
  3760. return
  3761. }
  3762. params[3] = parseCssFloat(params[3])
  3763. hsla2rgba(params, rgbaArr)
  3764. putToCache(colorStr, rgbaArr)
  3765. return rgbaArr
  3766. case 'hsl':
  3767. if (params.length !== 3) {
  3768. setRgba(rgbaArr, 0, 0, 0, 1)
  3769. return
  3770. }
  3771. hsla2rgba(params, rgbaArr)
  3772. putToCache(colorStr, rgbaArr)
  3773. return rgbaArr
  3774. default:
  3775. return
  3776. }
  3777. }
  3778. setRgba(rgbaArr, 0, 0, 0, 1)
  3779. return
  3780. }
  3781. function hsla2rgba(hsla, rgba) {
  3782. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360
  3783. var s = parseCssFloat(hsla[1])
  3784. var l = parseCssFloat(hsla[2])
  3785. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s
  3786. var m1 = l * 2 - m2
  3787. rgba = rgba || []
  3788. setRgba(
  3789. rgba,
  3790. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  3791. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  3792. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255),
  3793. 1
  3794. )
  3795. if (hsla.length === 4) {
  3796. rgba[3] = hsla[3]
  3797. }
  3798. return rgba
  3799. }
  3800. function lift(color, level) {
  3801. var colorArr = parse(color)
  3802. if (colorArr) {
  3803. for (var i = 0; i < 3; i++) {
  3804. if (level < 0) {
  3805. colorArr[i] = (colorArr[i] * (1 - level)) | 0
  3806. } else {
  3807. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0
  3808. }
  3809. if (colorArr[i] > 255) {
  3810. colorArr[i] = 255
  3811. } else if (colorArr[i] < 0) {
  3812. colorArr[i] = 0
  3813. }
  3814. }
  3815. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb')
  3816. }
  3817. }
  3818. function lerp(normalizedValue, colors, fullOutput) {
  3819. if (
  3820. !(colors && colors.length) ||
  3821. !(normalizedValue >= 0 && normalizedValue <= 1)
  3822. ) {
  3823. return
  3824. }
  3825. var value = normalizedValue * (colors.length - 1)
  3826. var leftIndex = Math.floor(value)
  3827. var rightIndex = Math.ceil(value)
  3828. var leftColor = parse(colors[leftIndex])
  3829. var rightColor = parse(colors[rightIndex])
  3830. var dv = value - leftIndex
  3831. var color = stringify(
  3832. [
  3833. clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)),
  3834. clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)),
  3835. clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)),
  3836. clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))
  3837. ],
  3838. 'rgba'
  3839. )
  3840. return fullOutput
  3841. ? {
  3842. color: color,
  3843. leftIndex: leftIndex,
  3844. rightIndex: rightIndex,
  3845. value: value
  3846. }
  3847. : color
  3848. }
  3849. function stringify(arrColor, type) {
  3850. if (!arrColor || !arrColor.length) {
  3851. return
  3852. }
  3853. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2]
  3854. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  3855. colorStr += ',' + arrColor[3]
  3856. }
  3857. return type + '(' + colorStr + ')'
  3858. }
  3859. function lum(color, backgroundLum) {
  3860. var arr = parse(color)
  3861. return arr
  3862. ? ((0.299 * arr[0] + 0.587 * arr[1] + 0.114 * arr[2]) * arr[3]) /
  3863. 255 +
  3864. (1 - arr[3]) * backgroundLum
  3865. : 0
  3866. }
  3867. function isLinearGradient(val) {
  3868. return val.type === 'linear'
  3869. }
  3870. function isRadialGradient(val) {
  3871. return val.type === 'radial'
  3872. }
  3873. ;(function () {
  3874. if (env$1.hasGlobalWindow && isFunction(window.btoa)) {
  3875. return function (str) {
  3876. return window.btoa(unescape(str))
  3877. }
  3878. }
  3879. if (typeof Buffer !== 'undefined') {
  3880. return function (str) {
  3881. return Buffer.from(str).toString('base64')
  3882. }
  3883. }
  3884. return function (str) {
  3885. return null
  3886. }
  3887. })()
  3888. var arraySlice = Array.prototype.slice
  3889. function interpolateNumber$1(p0, p1, percent) {
  3890. return (p1 - p0) * percent + p0
  3891. }
  3892. function interpolate1DArray(out, p0, p1, percent) {
  3893. var len = p0.length
  3894. for (var i = 0; i < len; i++) {
  3895. out[i] = interpolateNumber$1(p0[i], p1[i], percent)
  3896. }
  3897. return out
  3898. }
  3899. function interpolate2DArray(out, p0, p1, percent) {
  3900. var len = p0.length
  3901. var len2 = len && p0[0].length
  3902. for (var i = 0; i < len; i++) {
  3903. if (!out[i]) {
  3904. out[i] = []
  3905. }
  3906. for (var j = 0; j < len2; j++) {
  3907. out[i][j] = interpolateNumber$1(p0[i][j], p1[i][j], percent)
  3908. }
  3909. }
  3910. return out
  3911. }
  3912. function add1DArray(out, p0, p1, sign) {
  3913. var len = p0.length
  3914. for (var i = 0; i < len; i++) {
  3915. out[i] = p0[i] + p1[i] * sign
  3916. }
  3917. return out
  3918. }
  3919. function add2DArray(out, p0, p1, sign) {
  3920. var len = p0.length
  3921. var len2 = len && p0[0].length
  3922. for (var i = 0; i < len; i++) {
  3923. if (!out[i]) {
  3924. out[i] = []
  3925. }
  3926. for (var j = 0; j < len2; j++) {
  3927. out[i][j] = p0[i][j] + p1[i][j] * sign
  3928. }
  3929. }
  3930. return out
  3931. }
  3932. function fillColorStops(val0, val1) {
  3933. var len0 = val0.length
  3934. var len1 = val1.length
  3935. var shorterArr = len0 > len1 ? val1 : val0
  3936. var shorterLen = Math.min(len0, len1)
  3937. var last = shorterArr[shorterLen - 1] || {
  3938. color: [0, 0, 0, 0],
  3939. offset: 0
  3940. }
  3941. for (var i = shorterLen; i < Math.max(len0, len1); i++) {
  3942. shorterArr.push({
  3943. offset: last.offset,
  3944. color: last.color.slice()
  3945. })
  3946. }
  3947. }
  3948. function fillArray(val0, val1, arrDim) {
  3949. var arr0 = val0
  3950. var arr1 = val1
  3951. if (!arr0.push || !arr1.push) {
  3952. return
  3953. }
  3954. var arr0Len = arr0.length
  3955. var arr1Len = arr1.length
  3956. if (arr0Len !== arr1Len) {
  3957. var isPreviousLarger = arr0Len > arr1Len
  3958. if (isPreviousLarger) {
  3959. arr0.length = arr1Len
  3960. } else {
  3961. for (var i = arr0Len; i < arr1Len; i++) {
  3962. arr0.push(arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]))
  3963. }
  3964. }
  3965. }
  3966. var len2 = arr0[0] && arr0[0].length
  3967. for (var i = 0; i < arr0.length; i++) {
  3968. if (arrDim === 1) {
  3969. if (isNaN(arr0[i])) {
  3970. arr0[i] = arr1[i]
  3971. }
  3972. } else {
  3973. for (var j = 0; j < len2; j++) {
  3974. if (isNaN(arr0[i][j])) {
  3975. arr0[i][j] = arr1[i][j]
  3976. }
  3977. }
  3978. }
  3979. }
  3980. }
  3981. function cloneValue(value) {
  3982. if (isArrayLike(value)) {
  3983. var len = value.length
  3984. if (isArrayLike(value[0])) {
  3985. var ret = []
  3986. for (var i = 0; i < len; i++) {
  3987. ret.push(arraySlice.call(value[i]))
  3988. }
  3989. return ret
  3990. }
  3991. return arraySlice.call(value)
  3992. }
  3993. return value
  3994. }
  3995. function rgba2String(rgba) {
  3996. rgba[0] = Math.floor(rgba[0]) || 0
  3997. rgba[1] = Math.floor(rgba[1]) || 0
  3998. rgba[2] = Math.floor(rgba[2]) || 0
  3999. rgba[3] = rgba[3] == null ? 1 : rgba[3]
  4000. return 'rgba(' + rgba.join(',') + ')'
  4001. }
  4002. function guessArrayDim(value) {
  4003. return isArrayLike(value && value[0]) ? 2 : 1
  4004. }
  4005. var VALUE_TYPE_NUMBER = 0
  4006. var VALUE_TYPE_1D_ARRAY = 1
  4007. var VALUE_TYPE_2D_ARRAY = 2
  4008. var VALUE_TYPE_COLOR = 3
  4009. var VALUE_TYPE_LINEAR_GRADIENT = 4
  4010. var VALUE_TYPE_RADIAL_GRADIENT = 5
  4011. var VALUE_TYPE_UNKOWN = 6
  4012. function isGradientValueType(valType) {
  4013. return (
  4014. valType === VALUE_TYPE_LINEAR_GRADIENT ||
  4015. valType === VALUE_TYPE_RADIAL_GRADIENT
  4016. )
  4017. }
  4018. function isArrayValueType(valType) {
  4019. return (
  4020. valType === VALUE_TYPE_1D_ARRAY || valType === VALUE_TYPE_2D_ARRAY
  4021. )
  4022. }
  4023. var tmpRgba = [0, 0, 0, 0]
  4024. var Track = (function () {
  4025. function Track(propName) {
  4026. this.keyframes = []
  4027. this.discrete = false
  4028. this._invalid = false
  4029. this._needsSort = false
  4030. this._lastFr = 0
  4031. this._lastFrP = 0
  4032. this.propName = propName
  4033. }
  4034. Track.prototype.isFinished = function () {
  4035. return this._finished
  4036. }
  4037. Track.prototype.setFinished = function () {
  4038. this._finished = true
  4039. if (this._additiveTrack) {
  4040. this._additiveTrack.setFinished()
  4041. }
  4042. }
  4043. Track.prototype.needsAnimate = function () {
  4044. return this.keyframes.length >= 1
  4045. }
  4046. Track.prototype.getAdditiveTrack = function () {
  4047. return this._additiveTrack
  4048. }
  4049. Track.prototype.addKeyframe = function (time, rawValue, easing) {
  4050. this._needsSort = true
  4051. var keyframes = this.keyframes
  4052. var len = keyframes.length
  4053. var discrete = false
  4054. var valType = VALUE_TYPE_UNKOWN
  4055. var value = rawValue
  4056. if (isArrayLike(rawValue)) {
  4057. var arrayDim = guessArrayDim(rawValue)
  4058. valType = arrayDim
  4059. if (
  4060. (arrayDim === 1 && !isNumber(rawValue[0])) ||
  4061. (arrayDim === 2 && !isNumber(rawValue[0][0]))
  4062. ) {
  4063. discrete = true
  4064. }
  4065. } else {
  4066. if (isNumber(rawValue) && !eqNaN(rawValue)) {
  4067. valType = VALUE_TYPE_NUMBER
  4068. } else if (isString(rawValue)) {
  4069. if (!isNaN(+rawValue)) {
  4070. valType = VALUE_TYPE_NUMBER
  4071. } else {
  4072. var colorArray = parse(rawValue)
  4073. if (colorArray) {
  4074. value = colorArray
  4075. valType = VALUE_TYPE_COLOR
  4076. }
  4077. }
  4078. } else if (isGradientObject(rawValue)) {
  4079. var parsedGradient = extend({}, value)
  4080. parsedGradient.colorStops = map$1(
  4081. rawValue.colorStops,
  4082. function (colorStop) {
  4083. return {
  4084. offset: colorStop.offset,
  4085. color: parse(colorStop.color)
  4086. }
  4087. }
  4088. )
  4089. if (isLinearGradient(rawValue)) {
  4090. valType = VALUE_TYPE_LINEAR_GRADIENT
  4091. } else if (isRadialGradient(rawValue)) {
  4092. valType = VALUE_TYPE_RADIAL_GRADIENT
  4093. }
  4094. value = parsedGradient
  4095. }
  4096. }
  4097. if (len === 0) {
  4098. this.valType = valType
  4099. } else if (
  4100. valType !== this.valType ||
  4101. valType === VALUE_TYPE_UNKOWN
  4102. ) {
  4103. discrete = true
  4104. }
  4105. this.discrete = this.discrete || discrete
  4106. var kf = {
  4107. time: time,
  4108. value: value,
  4109. rawValue: rawValue,
  4110. percent: 0
  4111. }
  4112. if (easing) {
  4113. kf.easing = easing
  4114. kf.easingFunc = isFunction(easing)
  4115. ? easing
  4116. : easingFuncs$1[easing] || createCubicEasingFunc(easing)
  4117. }
  4118. keyframes.push(kf)
  4119. return kf
  4120. }
  4121. Track.prototype.prepare = function (maxTime, additiveTrack) {
  4122. var kfs = this.keyframes
  4123. if (this._needsSort) {
  4124. kfs.sort(function (a, b) {
  4125. return a.time - b.time
  4126. })
  4127. }
  4128. var valType = this.valType
  4129. var kfsLen = kfs.length
  4130. var lastKf = kfs[kfsLen - 1]
  4131. var isDiscrete = this.discrete
  4132. var isArr = isArrayValueType(valType)
  4133. var isGradient = isGradientValueType(valType)
  4134. for (var i = 0; i < kfsLen; i++) {
  4135. var kf = kfs[i]
  4136. var value = kf.value
  4137. var lastValue = lastKf.value
  4138. kf.percent = kf.time / maxTime
  4139. if (!isDiscrete) {
  4140. if (isArr && i !== kfsLen - 1) {
  4141. fillArray(value, lastValue, valType)
  4142. } else if (isGradient) {
  4143. fillColorStops(value.colorStops, lastValue.colorStops)
  4144. }
  4145. }
  4146. }
  4147. if (
  4148. !isDiscrete &&
  4149. valType !== VALUE_TYPE_RADIAL_GRADIENT &&
  4150. additiveTrack &&
  4151. this.needsAnimate() &&
  4152. additiveTrack.needsAnimate() &&
  4153. valType === additiveTrack.valType &&
  4154. !additiveTrack._finished
  4155. ) {
  4156. this._additiveTrack = additiveTrack
  4157. var startValue = kfs[0].value
  4158. for (var i = 0; i < kfsLen; i++) {
  4159. if (valType === VALUE_TYPE_NUMBER) {
  4160. kfs[i].additiveValue = kfs[i].value - startValue
  4161. } else if (valType === VALUE_TYPE_COLOR) {
  4162. kfs[i].additiveValue = add1DArray(
  4163. [],
  4164. kfs[i].value,
  4165. startValue,
  4166. -1
  4167. )
  4168. } else if (isArrayValueType(valType)) {
  4169. kfs[i].additiveValue =
  4170. valType === VALUE_TYPE_1D_ARRAY
  4171. ? add1DArray([], kfs[i].value, startValue, -1)
  4172. : add2DArray([], kfs[i].value, startValue, -1)
  4173. }
  4174. }
  4175. }
  4176. }
  4177. Track.prototype.step = function (target, percent) {
  4178. if (this._finished) {
  4179. return
  4180. }
  4181. if (this._additiveTrack && this._additiveTrack._finished) {
  4182. this._additiveTrack = null
  4183. }
  4184. var isAdditive = this._additiveTrack != null
  4185. var valueKey = isAdditive ? 'additiveValue' : 'value'
  4186. var valType = this.valType
  4187. var keyframes = this.keyframes
  4188. var kfsNum = keyframes.length
  4189. var propName = this.propName
  4190. var isValueColor = valType === VALUE_TYPE_COLOR
  4191. var frameIdx
  4192. var lastFrame = this._lastFr
  4193. var mathMin = Math.min
  4194. var frame
  4195. var nextFrame
  4196. if (kfsNum === 1) {
  4197. frame = nextFrame = keyframes[0]
  4198. } else {
  4199. if (percent < 0) {
  4200. frameIdx = 0
  4201. } else if (percent < this._lastFrP) {
  4202. var start = mathMin(lastFrame + 1, kfsNum - 1)
  4203. for (frameIdx = start; frameIdx >= 0; frameIdx--) {
  4204. if (keyframes[frameIdx].percent <= percent) {
  4205. break
  4206. }
  4207. }
  4208. frameIdx = mathMin(frameIdx, kfsNum - 2)
  4209. } else {
  4210. for (frameIdx = lastFrame; frameIdx < kfsNum; frameIdx++) {
  4211. if (keyframes[frameIdx].percent > percent) {
  4212. break
  4213. }
  4214. }
  4215. frameIdx = mathMin(frameIdx - 1, kfsNum - 2)
  4216. }
  4217. nextFrame = keyframes[frameIdx + 1]
  4218. frame = keyframes[frameIdx]
  4219. }
  4220. if (!(frame && nextFrame)) {
  4221. return
  4222. }
  4223. this._lastFr = frameIdx
  4224. this._lastFrP = percent
  4225. var interval = nextFrame.percent - frame.percent
  4226. var w =
  4227. interval === 0
  4228. ? 1
  4229. : mathMin((percent - frame.percent) / interval, 1)
  4230. if (nextFrame.easingFunc) {
  4231. w = nextFrame.easingFunc(w)
  4232. }
  4233. var targetArr = isAdditive
  4234. ? this._additiveValue
  4235. : isValueColor
  4236. ? tmpRgba
  4237. : target[propName]
  4238. if ((isArrayValueType(valType) || isValueColor) && !targetArr) {
  4239. targetArr = this._additiveValue = []
  4240. }
  4241. if (this.discrete) {
  4242. target[propName] = w < 1 ? frame.rawValue : nextFrame.rawValue
  4243. } else if (isArrayValueType(valType)) {
  4244. valType === VALUE_TYPE_1D_ARRAY
  4245. ? interpolate1DArray(
  4246. targetArr,
  4247. frame[valueKey],
  4248. nextFrame[valueKey],
  4249. w
  4250. )
  4251. : interpolate2DArray(
  4252. targetArr,
  4253. frame[valueKey],
  4254. nextFrame[valueKey],
  4255. w
  4256. )
  4257. } else if (isGradientValueType(valType)) {
  4258. var val = frame[valueKey]
  4259. var nextVal_1 = nextFrame[valueKey]
  4260. var isLinearGradient_1 = valType === VALUE_TYPE_LINEAR_GRADIENT
  4261. target[propName] = {
  4262. type: isLinearGradient_1 ? 'linear' : 'radial',
  4263. x: interpolateNumber$1(val.x, nextVal_1.x, w),
  4264. y: interpolateNumber$1(val.y, nextVal_1.y, w),
  4265. colorStops: map$1(val.colorStops, function (colorStop, idx) {
  4266. var nextColorStop = nextVal_1.colorStops[idx]
  4267. return {
  4268. offset: interpolateNumber$1(
  4269. colorStop.offset,
  4270. nextColorStop.offset,
  4271. w
  4272. ),
  4273. color: rgba2String(
  4274. interpolate1DArray(
  4275. [],
  4276. colorStop.color,
  4277. nextColorStop.color,
  4278. w
  4279. )
  4280. )
  4281. }
  4282. }),
  4283. global: nextVal_1.global
  4284. }
  4285. if (isLinearGradient_1) {
  4286. target[propName].x2 = interpolateNumber$1(
  4287. val.x2,
  4288. nextVal_1.x2,
  4289. w
  4290. )
  4291. target[propName].y2 = interpolateNumber$1(
  4292. val.y2,
  4293. nextVal_1.y2,
  4294. w
  4295. )
  4296. } else {
  4297. target[propName].r = interpolateNumber$1(
  4298. val.r,
  4299. nextVal_1.r,
  4300. w
  4301. )
  4302. }
  4303. } else if (isValueColor) {
  4304. interpolate1DArray(
  4305. targetArr,
  4306. frame[valueKey],
  4307. nextFrame[valueKey],
  4308. w
  4309. )
  4310. if (!isAdditive) {
  4311. target[propName] = rgba2String(targetArr)
  4312. }
  4313. } else {
  4314. var value = interpolateNumber$1(
  4315. frame[valueKey],
  4316. nextFrame[valueKey],
  4317. w
  4318. )
  4319. if (isAdditive) {
  4320. this._additiveValue = value
  4321. } else {
  4322. target[propName] = value
  4323. }
  4324. }
  4325. if (isAdditive) {
  4326. this._addToTarget(target)
  4327. }
  4328. }
  4329. Track.prototype._addToTarget = function (target) {
  4330. var valType = this.valType
  4331. var propName = this.propName
  4332. var additiveValue = this._additiveValue
  4333. if (valType === VALUE_TYPE_NUMBER) {
  4334. target[propName] = target[propName] + additiveValue
  4335. } else if (valType === VALUE_TYPE_COLOR) {
  4336. parse(target[propName], tmpRgba)
  4337. add1DArray(tmpRgba, tmpRgba, additiveValue, 1)
  4338. target[propName] = rgba2String(tmpRgba)
  4339. } else if (valType === VALUE_TYPE_1D_ARRAY) {
  4340. add1DArray(target[propName], target[propName], additiveValue, 1)
  4341. } else if (valType === VALUE_TYPE_2D_ARRAY) {
  4342. add2DArray(target[propName], target[propName], additiveValue, 1)
  4343. }
  4344. }
  4345. return Track
  4346. })()
  4347. var Animator = (function () {
  4348. function Animator(
  4349. target,
  4350. loop,
  4351. allowDiscreteAnimation,
  4352. additiveTo
  4353. ) {
  4354. this._tracks = {}
  4355. this._trackKeys = []
  4356. this._maxTime = 0
  4357. this._started = 0
  4358. this._clip = null
  4359. this._target = target
  4360. this._loop = loop
  4361. if (loop && additiveTo) {
  4362. logError("Can' use additive animation on looped animation.")
  4363. return
  4364. }
  4365. this._additiveAnimators = additiveTo
  4366. this._allowDiscrete = allowDiscreteAnimation
  4367. }
  4368. Animator.prototype.getMaxTime = function () {
  4369. return this._maxTime
  4370. }
  4371. Animator.prototype.getDelay = function () {
  4372. return this._delay
  4373. }
  4374. Animator.prototype.getLoop = function () {
  4375. return this._loop
  4376. }
  4377. Animator.prototype.getTarget = function () {
  4378. return this._target
  4379. }
  4380. Animator.prototype.changeTarget = function (target) {
  4381. this._target = target
  4382. }
  4383. Animator.prototype.when = function (time, props, easing) {
  4384. return this.whenWithKeys(time, props, keys(props), easing)
  4385. }
  4386. Animator.prototype.whenWithKeys = function (
  4387. time,
  4388. props,
  4389. propNames,
  4390. easing
  4391. ) {
  4392. var tracks = this._tracks
  4393. for (var i = 0; i < propNames.length; i++) {
  4394. var propName = propNames[i]
  4395. var track = tracks[propName]
  4396. if (!track) {
  4397. track = tracks[propName] = new Track(propName)
  4398. var initialValue = void 0
  4399. var additiveTrack = this._getAdditiveTrack(propName)
  4400. if (additiveTrack) {
  4401. var addtiveTrackKfs = additiveTrack.keyframes
  4402. var lastFinalKf =
  4403. addtiveTrackKfs[addtiveTrackKfs.length - 1]
  4404. initialValue = lastFinalKf && lastFinalKf.value
  4405. if (
  4406. additiveTrack.valType === VALUE_TYPE_COLOR &&
  4407. initialValue
  4408. ) {
  4409. initialValue = rgba2String(initialValue)
  4410. }
  4411. } else {
  4412. initialValue = this._target[propName]
  4413. }
  4414. if (initialValue == null) {
  4415. continue
  4416. }
  4417. if (time > 0) {
  4418. track.addKeyframe(0, cloneValue(initialValue), easing)
  4419. }
  4420. this._trackKeys.push(propName)
  4421. }
  4422. track.addKeyframe(time, cloneValue(props[propName]), easing)
  4423. }
  4424. this._maxTime = Math.max(this._maxTime, time)
  4425. return this
  4426. }
  4427. Animator.prototype.pause = function () {
  4428. this._clip.pause()
  4429. this._paused = true
  4430. }
  4431. Animator.prototype.resume = function () {
  4432. this._clip.resume()
  4433. this._paused = false
  4434. }
  4435. Animator.prototype.isPaused = function () {
  4436. return !!this._paused
  4437. }
  4438. Animator.prototype.duration = function (duration) {
  4439. this._maxTime = duration
  4440. this._force = true
  4441. return this
  4442. }
  4443. Animator.prototype._doneCallback = function () {
  4444. this._setTracksFinished()
  4445. this._clip = null
  4446. var doneList = this._doneCbs
  4447. if (doneList) {
  4448. var len = doneList.length
  4449. for (var i = 0; i < len; i++) {
  4450. doneList[i].call(this)
  4451. }
  4452. }
  4453. }
  4454. Animator.prototype._abortedCallback = function () {
  4455. this._setTracksFinished()
  4456. var animation = this.animation
  4457. var abortedList = this._abortedCbs
  4458. if (animation) {
  4459. animation.removeClip(this._clip)
  4460. }
  4461. this._clip = null
  4462. if (abortedList) {
  4463. for (var i = 0; i < abortedList.length; i++) {
  4464. abortedList[i].call(this)
  4465. }
  4466. }
  4467. }
  4468. Animator.prototype._setTracksFinished = function () {
  4469. var tracks = this._tracks
  4470. var tracksKeys = this._trackKeys
  4471. for (var i = 0; i < tracksKeys.length; i++) {
  4472. tracks[tracksKeys[i]].setFinished()
  4473. }
  4474. }
  4475. Animator.prototype._getAdditiveTrack = function (trackName) {
  4476. var additiveTrack
  4477. var additiveAnimators = this._additiveAnimators
  4478. if (additiveAnimators) {
  4479. for (var i = 0; i < additiveAnimators.length; i++) {
  4480. var track = additiveAnimators[i].getTrack(trackName)
  4481. if (track) {
  4482. additiveTrack = track
  4483. }
  4484. }
  4485. }
  4486. return additiveTrack
  4487. }
  4488. Animator.prototype.start = function (easing) {
  4489. if (this._started > 0) {
  4490. return
  4491. }
  4492. this._started = 1
  4493. var self = this
  4494. var tracks = []
  4495. var maxTime = this._maxTime || 0
  4496. for (var i = 0; i < this._trackKeys.length; i++) {
  4497. var propName = this._trackKeys[i]
  4498. var track = this._tracks[propName]
  4499. var additiveTrack = this._getAdditiveTrack(propName)
  4500. var kfs = track.keyframes
  4501. var kfsNum = kfs.length
  4502. track.prepare(maxTime, additiveTrack)
  4503. if (track.needsAnimate()) {
  4504. if (!this._allowDiscrete && track.discrete) {
  4505. var lastKf = kfs[kfsNum - 1]
  4506. if (lastKf) {
  4507. self._target[track.propName] = lastKf.rawValue
  4508. }
  4509. track.setFinished()
  4510. } else {
  4511. tracks.push(track)
  4512. }
  4513. }
  4514. }
  4515. if (tracks.length || this._force) {
  4516. var clip = new Clip$1({
  4517. life: maxTime,
  4518. loop: this._loop,
  4519. delay: this._delay || 0,
  4520. onframe: function onframe(percent) {
  4521. self._started = 2
  4522. var additiveAnimators = self._additiveAnimators
  4523. if (additiveAnimators) {
  4524. var stillHasAdditiveAnimator = false
  4525. for (var i = 0; i < additiveAnimators.length; i++) {
  4526. if (additiveAnimators[i]._clip) {
  4527. stillHasAdditiveAnimator = true
  4528. break
  4529. }
  4530. }
  4531. if (!stillHasAdditiveAnimator) {
  4532. self._additiveAnimators = null
  4533. }
  4534. }
  4535. for (var i = 0; i < tracks.length; i++) {
  4536. tracks[i].step(self._target, percent)
  4537. }
  4538. var onframeList = self._onframeCbs
  4539. if (onframeList) {
  4540. for (var i = 0; i < onframeList.length; i++) {
  4541. onframeList[i](self._target, percent)
  4542. }
  4543. }
  4544. },
  4545. ondestroy: function ondestroy() {
  4546. self._doneCallback()
  4547. }
  4548. })
  4549. this._clip = clip
  4550. if (this.animation) {
  4551. this.animation.addClip(clip)
  4552. }
  4553. if (easing) {
  4554. clip.setEasing(easing)
  4555. }
  4556. } else {
  4557. this._doneCallback()
  4558. }
  4559. return this
  4560. }
  4561. Animator.prototype.stop = function (forwardToLast) {
  4562. if (!this._clip) {
  4563. return
  4564. }
  4565. var clip = this._clip
  4566. if (forwardToLast) {
  4567. clip.onframe(1)
  4568. }
  4569. this._abortedCallback()
  4570. }
  4571. Animator.prototype.delay = function (time) {
  4572. this._delay = time
  4573. return this
  4574. }
  4575. Animator.prototype.during = function (cb) {
  4576. if (cb) {
  4577. if (!this._onframeCbs) {
  4578. this._onframeCbs = []
  4579. }
  4580. this._onframeCbs.push(cb)
  4581. }
  4582. return this
  4583. }
  4584. Animator.prototype.done = function (cb) {
  4585. if (cb) {
  4586. if (!this._doneCbs) {
  4587. this._doneCbs = []
  4588. }
  4589. this._doneCbs.push(cb)
  4590. }
  4591. return this
  4592. }
  4593. Animator.prototype.aborted = function (cb) {
  4594. if (cb) {
  4595. if (!this._abortedCbs) {
  4596. this._abortedCbs = []
  4597. }
  4598. this._abortedCbs.push(cb)
  4599. }
  4600. return this
  4601. }
  4602. Animator.prototype.getClip = function () {
  4603. return this._clip
  4604. }
  4605. Animator.prototype.getTrack = function (propName) {
  4606. return this._tracks[propName]
  4607. }
  4608. Animator.prototype.getTracks = function () {
  4609. var _this = this
  4610. return map$1(this._trackKeys, function (key) {
  4611. return _this._tracks[key]
  4612. })
  4613. }
  4614. Animator.prototype.stopTracks = function (
  4615. propNames,
  4616. forwardToLast
  4617. ) {
  4618. if (!propNames.length || !this._clip) {
  4619. return true
  4620. }
  4621. var tracks = this._tracks
  4622. var tracksKeys = this._trackKeys
  4623. for (var i = 0; i < propNames.length; i++) {
  4624. var track = tracks[propNames[i]]
  4625. if (track && !track.isFinished()) {
  4626. if (forwardToLast) {
  4627. track.step(this._target, 1)
  4628. } else if (this._started === 1) {
  4629. track.step(this._target, 0)
  4630. }
  4631. track.setFinished()
  4632. }
  4633. }
  4634. var allAborted = true
  4635. for (var i = 0; i < tracksKeys.length; i++) {
  4636. if (!tracks[tracksKeys[i]].isFinished()) {
  4637. allAborted = false
  4638. break
  4639. }
  4640. }
  4641. if (allAborted) {
  4642. this._abortedCallback()
  4643. }
  4644. return allAborted
  4645. }
  4646. Animator.prototype.saveTo = function (
  4647. target,
  4648. trackKeys,
  4649. firstOrLast
  4650. ) {
  4651. if (!target) {
  4652. return
  4653. }
  4654. trackKeys = trackKeys || this._trackKeys
  4655. for (var i = 0; i < trackKeys.length; i++) {
  4656. var propName = trackKeys[i]
  4657. var track = this._tracks[propName]
  4658. if (!track || track.isFinished()) {
  4659. continue
  4660. }
  4661. var kfs = track.keyframes
  4662. var kf = kfs[firstOrLast ? 0 : kfs.length - 1]
  4663. if (kf) {
  4664. target[propName] = cloneValue(kf.rawValue)
  4665. }
  4666. }
  4667. }
  4668. Animator.prototype.__changeFinalValue = function (
  4669. finalProps,
  4670. trackKeys
  4671. ) {
  4672. trackKeys = trackKeys || keys(finalProps)
  4673. for (var i = 0; i < trackKeys.length; i++) {
  4674. var propName = trackKeys[i]
  4675. var track = this._tracks[propName]
  4676. if (!track) {
  4677. continue
  4678. }
  4679. var kfs = track.keyframes
  4680. if (kfs.length > 1) {
  4681. var lastKf = kfs.pop()
  4682. track.addKeyframe(lastKf.time, finalProps[propName])
  4683. track.prepare(this._maxTime, track.getAdditiveTrack())
  4684. }
  4685. }
  4686. }
  4687. return Animator
  4688. })()
  4689. var Animator$1 = Animator
  4690. function getTime() {
  4691. return new Date().getTime()
  4692. }
  4693. var Animation = (function (_super) {
  4694. __extends(Animation, _super)
  4695. function Animation(opts) {
  4696. var _this = _super.call(this) || this
  4697. _this._running = false
  4698. _this._time = 0
  4699. _this._pausedTime = 0
  4700. _this._pauseStart = 0
  4701. _this._paused = false
  4702. opts = opts || {}
  4703. _this.stage = opts.stage || {}
  4704. return _this
  4705. }
  4706. Animation.prototype.addClip = function (clip) {
  4707. if (clip.animation) {
  4708. this.removeClip(clip)
  4709. }
  4710. if (!this._head) {
  4711. this._head = this._tail = clip
  4712. } else {
  4713. this._tail.next = clip
  4714. clip.prev = this._tail
  4715. clip.next = null
  4716. this._tail = clip
  4717. }
  4718. clip.animation = this
  4719. }
  4720. Animation.prototype.addAnimator = function (animator) {
  4721. animator.animation = this
  4722. var clip = animator.getClip()
  4723. if (clip) {
  4724. this.addClip(clip)
  4725. }
  4726. }
  4727. Animation.prototype.removeClip = function (clip) {
  4728. if (!clip.animation) {
  4729. return
  4730. }
  4731. var prev = clip.prev
  4732. var next = clip.next
  4733. if (prev) {
  4734. prev.next = next
  4735. } else {
  4736. this._head = next
  4737. }
  4738. if (next) {
  4739. next.prev = prev
  4740. } else {
  4741. this._tail = prev
  4742. }
  4743. clip.next = clip.prev = clip.animation = null
  4744. }
  4745. Animation.prototype.removeAnimator = function (animator) {
  4746. var clip = animator.getClip()
  4747. if (clip) {
  4748. this.removeClip(clip)
  4749. }
  4750. animator.animation = null
  4751. }
  4752. Animation.prototype.update = function (
  4753. notTriggerFrameAndStageUpdate
  4754. ) {
  4755. var time = getTime() - this._pausedTime
  4756. var delta = time - this._time
  4757. var clip = this._head
  4758. while (clip) {
  4759. var nextClip = clip.next
  4760. var finished = clip.step(time, delta)
  4761. if (finished) {
  4762. clip.ondestroy()
  4763. this.removeClip(clip)
  4764. clip = nextClip
  4765. } else {
  4766. clip = nextClip
  4767. }
  4768. }
  4769. this._time = time
  4770. if (!notTriggerFrameAndStageUpdate) {
  4771. this.trigger('frame', delta)
  4772. this.stage.update && this.stage.update()
  4773. }
  4774. }
  4775. Animation.prototype._startLoop = function () {
  4776. var self = this
  4777. this._running = true
  4778. function step() {
  4779. if (self._running) {
  4780. requestAnimationFrame$1(step)
  4781. !self._paused && self.update()
  4782. }
  4783. }
  4784. requestAnimationFrame$1(step)
  4785. }
  4786. Animation.prototype.start = function () {
  4787. if (this._running) {
  4788. return
  4789. }
  4790. this._time = getTime()
  4791. this._pausedTime = 0
  4792. this._startLoop()
  4793. }
  4794. Animation.prototype.stop = function () {
  4795. this._running = false
  4796. }
  4797. Animation.prototype.pause = function () {
  4798. if (!this._paused) {
  4799. this._pauseStart = getTime()
  4800. this._paused = true
  4801. }
  4802. }
  4803. Animation.prototype.resume = function () {
  4804. if (this._paused) {
  4805. this._pausedTime += getTime() - this._pauseStart
  4806. this._paused = false
  4807. }
  4808. }
  4809. Animation.prototype.clear = function () {
  4810. var clip = this._head
  4811. while (clip) {
  4812. var nextClip = clip.next
  4813. clip.prev = clip.next = clip.animation = null
  4814. clip = nextClip
  4815. }
  4816. this._head = this._tail = null
  4817. }
  4818. Animation.prototype.isFinished = function () {
  4819. return this._head == null
  4820. }
  4821. Animation.prototype.animate = function (target, options) {
  4822. options = options || {}
  4823. this.start()
  4824. var animator = new Animator$1(target, options.loop)
  4825. this.addAnimator(animator)
  4826. return animator
  4827. }
  4828. return Animation
  4829. })(Eventful$1)
  4830. var Animation$1 = Animation
  4831. var TOUCH_CLICK_DELAY = 300
  4832. var globalEventSupported = env$1.domSupported
  4833. var localNativeListenerNames = (function () {
  4834. var mouseHandlerNames = [
  4835. 'click',
  4836. 'dblclick',
  4837. 'mousewheel',
  4838. 'wheel',
  4839. 'mouseout',
  4840. 'mouseup',
  4841. 'mousedown',
  4842. 'mousemove',
  4843. 'contextmenu'
  4844. ]
  4845. var touchHandlerNames = ['touchstart', 'touchend', 'touchmove']
  4846. var pointerEventNameMap = {
  4847. pointerdown: 1,
  4848. pointerup: 1,
  4849. pointermove: 1,
  4850. pointerout: 1
  4851. }
  4852. var pointerHandlerNames = map$1(mouseHandlerNames, function (name) {
  4853. var nm = name.replace('mouse', 'pointer')
  4854. return pointerEventNameMap.hasOwnProperty(nm) ? nm : name
  4855. })
  4856. return {
  4857. mouse: mouseHandlerNames,
  4858. touch: touchHandlerNames,
  4859. pointer: pointerHandlerNames
  4860. }
  4861. })()
  4862. var globalNativeListenerNames = {
  4863. mouse: ['mousemove', 'mouseup'],
  4864. pointer: ['pointermove', 'pointerup']
  4865. }
  4866. var wheelEventSupported = false
  4867. function isPointerFromTouch(event) {
  4868. var pointerType = event.pointerType
  4869. return pointerType === 'pen' || pointerType === 'touch'
  4870. }
  4871. function setTouchTimer(scope) {
  4872. scope.touching = true
  4873. if (scope.touchTimer != null) {
  4874. clearTimeout(scope.touchTimer)
  4875. scope.touchTimer = null
  4876. }
  4877. scope.touchTimer = setTimeout(function () {
  4878. scope.touching = false
  4879. scope.touchTimer = null
  4880. }, 700)
  4881. }
  4882. function markTouch(event) {
  4883. event && (event.zrByTouch = true)
  4884. }
  4885. function normalizeGlobalEvent(instance, event) {
  4886. return normalizeEvent(
  4887. instance.dom,
  4888. new FakeGlobalEvent(instance, event),
  4889. true
  4890. )
  4891. }
  4892. function isLocalEl(instance, el) {
  4893. var elTmp = el
  4894. var isLocal = false
  4895. while (
  4896. elTmp &&
  4897. elTmp.nodeType !== 9 &&
  4898. !(isLocal =
  4899. elTmp.domBelongToZr ||
  4900. (elTmp !== el && elTmp === instance.painterRoot))
  4901. ) {
  4902. elTmp = elTmp.parentNode
  4903. }
  4904. return isLocal
  4905. }
  4906. var FakeGlobalEvent = (function () {
  4907. function FakeGlobalEvent(instance, event) {
  4908. this.stopPropagation = noop
  4909. this.stopImmediatePropagation = noop
  4910. this.preventDefault = noop
  4911. this.type = event.type
  4912. this.target = this.currentTarget = instance.dom
  4913. this.pointerType = event.pointerType
  4914. this.clientX = event.clientX
  4915. this.clientY = event.clientY
  4916. }
  4917. return FakeGlobalEvent
  4918. })()
  4919. var localDOMHandlers = {
  4920. mousedown: function mousedown(event) {
  4921. event = normalizeEvent(this.dom, event)
  4922. this.__mayPointerCapture = [event.zrX, event.zrY]
  4923. this.trigger('mousedown', event)
  4924. },
  4925. mousemove: function mousemove(event) {
  4926. event = normalizeEvent(this.dom, event)
  4927. var downPoint = this.__mayPointerCapture
  4928. if (
  4929. downPoint &&
  4930. (event.zrX !== downPoint[0] || event.zrY !== downPoint[1])
  4931. ) {
  4932. this.__togglePointerCapture(true)
  4933. }
  4934. this.trigger('mousemove', event)
  4935. },
  4936. mouseup: function mouseup(event) {
  4937. event = normalizeEvent(this.dom, event)
  4938. this.__togglePointerCapture(false)
  4939. this.trigger('mouseup', event)
  4940. },
  4941. mouseout: function mouseout(event) {
  4942. event = normalizeEvent(this.dom, event)
  4943. var element = event.toElement || event.relatedTarget
  4944. if (!isLocalEl(this, element)) {
  4945. if (this.__pointerCapturing) {
  4946. event.zrEventControl = 'no_globalout'
  4947. }
  4948. this.trigger('mouseout', event)
  4949. }
  4950. },
  4951. wheel: function wheel(event) {
  4952. wheelEventSupported = true
  4953. event = normalizeEvent(this.dom, event)
  4954. this.trigger('mousewheel', event)
  4955. },
  4956. mousewheel: function mousewheel(event) {
  4957. if (wheelEventSupported) {
  4958. return
  4959. }
  4960. event = normalizeEvent(this.dom, event)
  4961. this.trigger('mousewheel', event)
  4962. },
  4963. touchstart: function touchstart(event) {
  4964. event = normalizeEvent(this.dom, event)
  4965. markTouch(event)
  4966. this.__lastTouchMoment = new Date()
  4967. this.handler.processGesture(event, 'start')
  4968. localDOMHandlers.mousemove.call(this, event)
  4969. localDOMHandlers.mousedown.call(this, event)
  4970. },
  4971. touchmove: function touchmove(event) {
  4972. event = normalizeEvent(this.dom, event)
  4973. markTouch(event)
  4974. this.handler.processGesture(event, 'change')
  4975. localDOMHandlers.mousemove.call(this, event)
  4976. },
  4977. touchend: function touchend(event) {
  4978. event = normalizeEvent(this.dom, event)
  4979. markTouch(event)
  4980. this.handler.processGesture(event, 'end')
  4981. localDOMHandlers.mouseup.call(this, event)
  4982. if (+new Date() - +this.__lastTouchMoment < TOUCH_CLICK_DELAY) {
  4983. localDOMHandlers.click.call(this, event)
  4984. }
  4985. },
  4986. pointerdown: function pointerdown(event) {
  4987. localDOMHandlers.mousedown.call(this, event)
  4988. },
  4989. pointermove: function pointermove(event) {
  4990. if (!isPointerFromTouch(event)) {
  4991. localDOMHandlers.mousemove.call(this, event)
  4992. }
  4993. },
  4994. pointerup: function pointerup(event) {
  4995. localDOMHandlers.mouseup.call(this, event)
  4996. },
  4997. pointerout: function pointerout(event) {
  4998. if (!isPointerFromTouch(event)) {
  4999. localDOMHandlers.mouseout.call(this, event)
  5000. }
  5001. }
  5002. }
  5003. each$7(['click', 'dblclick', 'contextmenu'], function (name) {
  5004. localDOMHandlers[name] = function (event) {
  5005. event = normalizeEvent(this.dom, event)
  5006. this.trigger(name, event)
  5007. }
  5008. })
  5009. var globalDOMHandlers = {
  5010. pointermove: function pointermove(event) {
  5011. if (!isPointerFromTouch(event)) {
  5012. globalDOMHandlers.mousemove.call(this, event)
  5013. }
  5014. },
  5015. pointerup: function pointerup(event) {
  5016. globalDOMHandlers.mouseup.call(this, event)
  5017. },
  5018. mousemove: function mousemove(event) {
  5019. this.trigger('mousemove', event)
  5020. },
  5021. mouseup: function mouseup(event) {
  5022. var pointerCaptureReleasing = this.__pointerCapturing
  5023. this.__togglePointerCapture(false)
  5024. this.trigger('mouseup', event)
  5025. if (pointerCaptureReleasing) {
  5026. event.zrEventControl = 'only_globalout'
  5027. this.trigger('mouseout', event)
  5028. }
  5029. }
  5030. }
  5031. function mountLocalDOMEventListeners(instance, scope) {
  5032. var domHandlers = scope.domHandlers
  5033. if (env$1.pointerEventsSupported) {
  5034. each$7(
  5035. localNativeListenerNames.pointer,
  5036. function (nativeEventName) {
  5037. mountSingleDOMEventListener(
  5038. scope,
  5039. nativeEventName,
  5040. function (event) {
  5041. domHandlers[nativeEventName].call(instance, event)
  5042. }
  5043. )
  5044. }
  5045. )
  5046. } else {
  5047. if (env$1.touchEventsSupported) {
  5048. each$7(
  5049. localNativeListenerNames.touch,
  5050. function (nativeEventName) {
  5051. mountSingleDOMEventListener(
  5052. scope,
  5053. nativeEventName,
  5054. function (event) {
  5055. domHandlers[nativeEventName].call(instance, event)
  5056. setTouchTimer(scope)
  5057. }
  5058. )
  5059. }
  5060. )
  5061. }
  5062. each$7(
  5063. localNativeListenerNames.mouse,
  5064. function (nativeEventName) {
  5065. mountSingleDOMEventListener(
  5066. scope,
  5067. nativeEventName,
  5068. function (event) {
  5069. event = getNativeEvent(event)
  5070. if (!scope.touching) {
  5071. domHandlers[nativeEventName].call(instance, event)
  5072. }
  5073. }
  5074. )
  5075. }
  5076. )
  5077. }
  5078. }
  5079. function mountGlobalDOMEventListeners(instance, scope) {
  5080. if (env$1.pointerEventsSupported) {
  5081. each$7(globalNativeListenerNames.pointer, mount)
  5082. } else if (!env$1.touchEventsSupported) {
  5083. each$7(globalNativeListenerNames.mouse, mount)
  5084. }
  5085. function mount(nativeEventName) {
  5086. function nativeEventListener(event) {
  5087. event = getNativeEvent(event)
  5088. if (!isLocalEl(instance, event.target)) {
  5089. event = normalizeGlobalEvent(instance, event)
  5090. scope.domHandlers[nativeEventName].call(instance, event)
  5091. }
  5092. }
  5093. mountSingleDOMEventListener(
  5094. scope,
  5095. nativeEventName,
  5096. nativeEventListener,
  5097. { capture: true }
  5098. )
  5099. }
  5100. }
  5101. function mountSingleDOMEventListener(
  5102. scope,
  5103. nativeEventName,
  5104. listener,
  5105. opt
  5106. ) {
  5107. scope.mounted[nativeEventName] = listener
  5108. scope.listenerOpts[nativeEventName] = opt
  5109. addEventListener(scope.domTarget, nativeEventName, listener, opt)
  5110. }
  5111. function unmountDOMEventListeners(scope) {
  5112. var mounted = scope.mounted
  5113. for (var nativeEventName in mounted) {
  5114. if (mounted.hasOwnProperty(nativeEventName)) {
  5115. removeEventListener(
  5116. scope.domTarget,
  5117. nativeEventName,
  5118. mounted[nativeEventName],
  5119. scope.listenerOpts[nativeEventName]
  5120. )
  5121. }
  5122. }
  5123. scope.mounted = {}
  5124. }
  5125. var DOMHandlerScope = (function () {
  5126. function DOMHandlerScope(domTarget, domHandlers) {
  5127. this.mounted = {}
  5128. this.listenerOpts = {}
  5129. this.touching = false
  5130. this.domTarget = domTarget
  5131. this.domHandlers = domHandlers
  5132. }
  5133. return DOMHandlerScope
  5134. })()
  5135. var HandlerDomProxy = (function (_super) {
  5136. __extends(HandlerDomProxy, _super)
  5137. function HandlerDomProxy(dom, painterRoot) {
  5138. var _this = _super.call(this) || this
  5139. _this.__pointerCapturing = false
  5140. _this.dom = dom
  5141. _this.painterRoot = painterRoot
  5142. _this._localHandlerScope = new DOMHandlerScope(
  5143. dom,
  5144. localDOMHandlers
  5145. )
  5146. if (globalEventSupported) {
  5147. _this._globalHandlerScope = new DOMHandlerScope(
  5148. document,
  5149. globalDOMHandlers
  5150. )
  5151. }
  5152. mountLocalDOMEventListeners(_this, _this._localHandlerScope)
  5153. return _this
  5154. }
  5155. HandlerDomProxy.prototype.dispose = function () {
  5156. unmountDOMEventListeners(this._localHandlerScope)
  5157. if (globalEventSupported) {
  5158. unmountDOMEventListeners(this._globalHandlerScope)
  5159. }
  5160. }
  5161. HandlerDomProxy.prototype.setCursor = function (cursorStyle) {
  5162. this.dom.style &&
  5163. (this.dom.style.cursor = cursorStyle || 'default')
  5164. }
  5165. HandlerDomProxy.prototype.__togglePointerCapture = function (
  5166. isPointerCapturing
  5167. ) {
  5168. this.__mayPointerCapture = null
  5169. if (
  5170. globalEventSupported &&
  5171. +this.__pointerCapturing ^ +isPointerCapturing
  5172. ) {
  5173. this.__pointerCapturing = isPointerCapturing
  5174. var globalHandlerScope = this._globalHandlerScope
  5175. isPointerCapturing
  5176. ? mountGlobalDOMEventListeners(this, globalHandlerScope)
  5177. : unmountDOMEventListeners(globalHandlerScope)
  5178. }
  5179. }
  5180. return HandlerDomProxy
  5181. })(Eventful$1)
  5182. var HandlerProxy = HandlerDomProxy
  5183. var dpr = 1
  5184. if (env$1.hasGlobalWindow) {
  5185. dpr = Math.max(
  5186. window.devicePixelRatio ||
  5187. (window.screen &&
  5188. window.screen.deviceXDPI / window.screen.logicalXDPI) ||
  5189. 1,
  5190. 1
  5191. )
  5192. }
  5193. var devicePixelRatio = dpr
  5194. var DARK_MODE_THRESHOLD = 0.4
  5195. var DARK_LABEL_COLOR = '#333'
  5196. var LIGHT_LABEL_COLOR = '#ccc'
  5197. var LIGHTER_LABEL_COLOR = '#eee'
  5198. function create() {
  5199. return [1, 0, 0, 1, 0, 0]
  5200. }
  5201. function identity(out) {
  5202. out[0] = 1
  5203. out[1] = 0
  5204. out[2] = 0
  5205. out[3] = 1
  5206. out[4] = 0
  5207. out[5] = 0
  5208. return out
  5209. }
  5210. function copy(out, m) {
  5211. out[0] = m[0]
  5212. out[1] = m[1]
  5213. out[2] = m[2]
  5214. out[3] = m[3]
  5215. out[4] = m[4]
  5216. out[5] = m[5]
  5217. return out
  5218. }
  5219. function mul(out, m1, m2) {
  5220. var out0 = m1[0] * m2[0] + m1[2] * m2[1]
  5221. var out1 = m1[1] * m2[0] + m1[3] * m2[1]
  5222. var out2 = m1[0] * m2[2] + m1[2] * m2[3]
  5223. var out3 = m1[1] * m2[2] + m1[3] * m2[3]
  5224. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4]
  5225. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  5226. out[0] = out0
  5227. out[1] = out1
  5228. out[2] = out2
  5229. out[3] = out3
  5230. out[4] = out4
  5231. out[5] = out5
  5232. return out
  5233. }
  5234. function translate(out, a, v) {
  5235. out[0] = a[0]
  5236. out[1] = a[1]
  5237. out[2] = a[2]
  5238. out[3] = a[3]
  5239. out[4] = a[4] + v[0]
  5240. out[5] = a[5] + v[1]
  5241. return out
  5242. }
  5243. function rotate(out, a, rad) {
  5244. var aa = a[0]
  5245. var ac = a[2]
  5246. var atx = a[4]
  5247. var ab = a[1]
  5248. var ad = a[3]
  5249. var aty = a[5]
  5250. var st = Math.sin(rad)
  5251. var ct = Math.cos(rad)
  5252. out[0] = aa * ct + ab * st
  5253. out[1] = -aa * st + ab * ct
  5254. out[2] = ac * ct + ad * st
  5255. out[3] = -ac * st + ct * ad
  5256. out[4] = ct * atx + st * aty
  5257. out[5] = ct * aty - st * atx
  5258. return out
  5259. }
  5260. function scale$1(out, a, v) {
  5261. var vx = v[0]
  5262. var vy = v[1]
  5263. out[0] = a[0] * vx
  5264. out[1] = a[1] * vy
  5265. out[2] = a[2] * vx
  5266. out[3] = a[3] * vy
  5267. out[4] = a[4] * vx
  5268. out[5] = a[5] * vy
  5269. return out
  5270. }
  5271. function invert(out, a) {
  5272. var aa = a[0]
  5273. var ac = a[2]
  5274. var atx = a[4]
  5275. var ab = a[1]
  5276. var ad = a[3]
  5277. var aty = a[5]
  5278. var det = aa * ad - ab * ac
  5279. if (!det) {
  5280. return null
  5281. }
  5282. det = 1.0 / det
  5283. out[0] = ad * det
  5284. out[1] = -ab * det
  5285. out[2] = -ac * det
  5286. out[3] = aa * det
  5287. out[4] = (ac * aty - ad * atx) * det
  5288. out[5] = (ab * atx - aa * aty) * det
  5289. return out
  5290. }
  5291. var mIdentity = identity
  5292. var EPSILON$1 = 5e-5
  5293. function isNotAroundZero(val) {
  5294. return val > EPSILON$1 || val < -EPSILON$1
  5295. }
  5296. var scaleTmp = []
  5297. var tmpTransform = []
  5298. var originTransform = create()
  5299. var abs = Math.abs
  5300. var Transformable = (function () {
  5301. function Transformable() {}
  5302. Transformable.prototype.getLocalTransform = function (m) {
  5303. return Transformable.getLocalTransform(this, m)
  5304. }
  5305. Transformable.prototype.setPosition = function (arr) {
  5306. this.x = arr[0]
  5307. this.y = arr[1]
  5308. }
  5309. Transformable.prototype.setScale = function (arr) {
  5310. this.scaleX = arr[0]
  5311. this.scaleY = arr[1]
  5312. }
  5313. Transformable.prototype.setSkew = function (arr) {
  5314. this.skewX = arr[0]
  5315. this.skewY = arr[1]
  5316. }
  5317. Transformable.prototype.setOrigin = function (arr) {
  5318. this.originX = arr[0]
  5319. this.originY = arr[1]
  5320. }
  5321. Transformable.prototype.needLocalTransform = function () {
  5322. return (
  5323. isNotAroundZero(this.rotation) ||
  5324. isNotAroundZero(this.x) ||
  5325. isNotAroundZero(this.y) ||
  5326. isNotAroundZero(this.scaleX - 1) ||
  5327. isNotAroundZero(this.scaleY - 1) ||
  5328. isNotAroundZero(this.skewX) ||
  5329. isNotAroundZero(this.skewY)
  5330. )
  5331. }
  5332. Transformable.prototype.updateTransform = function () {
  5333. var parentTransform = this.parent && this.parent.transform
  5334. var needLocalTransform = this.needLocalTransform()
  5335. var m = this.transform
  5336. if (!(needLocalTransform || parentTransform)) {
  5337. m && mIdentity(m)
  5338. return
  5339. }
  5340. m = m || create()
  5341. if (needLocalTransform) {
  5342. this.getLocalTransform(m)
  5343. } else {
  5344. mIdentity(m)
  5345. }
  5346. if (parentTransform) {
  5347. if (needLocalTransform) {
  5348. mul(m, parentTransform, m)
  5349. } else {
  5350. copy(m, parentTransform)
  5351. }
  5352. }
  5353. this.transform = m
  5354. this._resolveGlobalScaleRatio(m)
  5355. }
  5356. Transformable.prototype._resolveGlobalScaleRatio = function (m) {
  5357. var globalScaleRatio = this.globalScaleRatio
  5358. if (globalScaleRatio != null && globalScaleRatio !== 1) {
  5359. this.getGlobalScale(scaleTmp)
  5360. var relX = scaleTmp[0] < 0 ? -1 : 1
  5361. var relY = scaleTmp[1] < 0 ? -1 : 1
  5362. var sx =
  5363. ((scaleTmp[0] - relX) * globalScaleRatio + relX) /
  5364. scaleTmp[0] || 0
  5365. var sy =
  5366. ((scaleTmp[1] - relY) * globalScaleRatio + relY) /
  5367. scaleTmp[1] || 0
  5368. m[0] *= sx
  5369. m[1] *= sx
  5370. m[2] *= sy
  5371. m[3] *= sy
  5372. }
  5373. this.invTransform = this.invTransform || create()
  5374. invert(this.invTransform, m)
  5375. }
  5376. Transformable.prototype.getComputedTransform = function () {
  5377. var transformNode = this
  5378. var ancestors = []
  5379. while (transformNode) {
  5380. ancestors.push(transformNode)
  5381. transformNode = transformNode.parent
  5382. }
  5383. while ((transformNode = ancestors.pop())) {
  5384. transformNode.updateTransform()
  5385. }
  5386. return this.transform
  5387. }
  5388. Transformable.prototype.setLocalTransform = function (m) {
  5389. if (!m) {
  5390. return
  5391. }
  5392. var sx = m[0] * m[0] + m[1] * m[1]
  5393. var sy = m[2] * m[2] + m[3] * m[3]
  5394. var rotation = Math.atan2(m[1], m[0])
  5395. var shearX = Math.PI / 2 + rotation - Math.atan2(m[3], m[2])
  5396. sy = Math.sqrt(sy) * Math.cos(shearX)
  5397. sx = Math.sqrt(sx)
  5398. this.skewX = shearX
  5399. this.skewY = 0
  5400. this.rotation = -rotation
  5401. this.x = +m[4]
  5402. this.y = +m[5]
  5403. this.scaleX = sx
  5404. this.scaleY = sy
  5405. this.originX = 0
  5406. this.originY = 0
  5407. }
  5408. Transformable.prototype.decomposeTransform = function () {
  5409. if (!this.transform) {
  5410. return
  5411. }
  5412. var parent = this.parent
  5413. var m = this.transform
  5414. if (parent && parent.transform) {
  5415. mul(tmpTransform, parent.invTransform, m)
  5416. m = tmpTransform
  5417. }
  5418. var ox = this.originX
  5419. var oy = this.originY
  5420. if (ox || oy) {
  5421. originTransform[4] = ox
  5422. originTransform[5] = oy
  5423. mul(tmpTransform, m, originTransform)
  5424. tmpTransform[4] -= ox
  5425. tmpTransform[5] -= oy
  5426. m = tmpTransform
  5427. }
  5428. this.setLocalTransform(m)
  5429. }
  5430. Transformable.prototype.getGlobalScale = function (out) {
  5431. var m = this.transform
  5432. out = out || []
  5433. if (!m) {
  5434. out[0] = 1
  5435. out[1] = 1
  5436. return out
  5437. }
  5438. out[0] = Math.sqrt(m[0] * m[0] + m[1] * m[1])
  5439. out[1] = Math.sqrt(m[2] * m[2] + m[3] * m[3])
  5440. if (m[0] < 0) {
  5441. out[0] = -out[0]
  5442. }
  5443. if (m[3] < 0) {
  5444. out[1] = -out[1]
  5445. }
  5446. return out
  5447. }
  5448. Transformable.prototype.transformCoordToLocal = function (x, y) {
  5449. var v2 = [x, y]
  5450. var invTransform = this.invTransform
  5451. if (invTransform) {
  5452. applyTransform$1(v2, v2, invTransform)
  5453. }
  5454. return v2
  5455. }
  5456. Transformable.prototype.transformCoordToGlobal = function (x, y) {
  5457. var v2 = [x, y]
  5458. var transform = this.transform
  5459. if (transform) {
  5460. applyTransform$1(v2, v2, transform)
  5461. }
  5462. return v2
  5463. }
  5464. Transformable.prototype.getLineScale = function () {
  5465. var m = this.transform
  5466. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  5467. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  5468. : 1
  5469. }
  5470. Transformable.prototype.copyTransform = function (source) {
  5471. copyTransform(this, source)
  5472. }
  5473. Transformable.getLocalTransform = function (target, m) {
  5474. m = m || []
  5475. var ox = target.originX || 0
  5476. var oy = target.originY || 0
  5477. var sx = target.scaleX
  5478. var sy = target.scaleY
  5479. var ax = target.anchorX
  5480. var ay = target.anchorY
  5481. var rotation = target.rotation || 0
  5482. var x = target.x
  5483. var y = target.y
  5484. var skewX = target.skewX ? Math.tan(target.skewX) : 0
  5485. var skewY = target.skewY ? Math.tan(-target.skewY) : 0
  5486. if (ox || oy || ax || ay) {
  5487. var dx = ox + ax
  5488. var dy = oy + ay
  5489. m[4] = -dx * sx - skewX * dy * sy
  5490. m[5] = -dy * sy - skewY * dx * sx
  5491. } else {
  5492. m[4] = m[5] = 0
  5493. }
  5494. m[0] = sx
  5495. m[3] = sy
  5496. m[1] = skewY * sx
  5497. m[2] = skewX * sy
  5498. rotation && rotate(m, m, rotation)
  5499. m[4] += ox + x
  5500. m[5] += oy + y
  5501. return m
  5502. }
  5503. Transformable.initDefaultProps = (function () {
  5504. var proto = Transformable.prototype
  5505. proto.scaleX = proto.scaleY = proto.globalScaleRatio = 1
  5506. proto.x =
  5507. proto.y =
  5508. proto.originX =
  5509. proto.originY =
  5510. proto.skewX =
  5511. proto.skewY =
  5512. proto.rotation =
  5513. proto.anchorX =
  5514. proto.anchorY =
  5515. 0
  5516. })()
  5517. return Transformable
  5518. })()
  5519. var TRANSFORMABLE_PROPS = [
  5520. 'x',
  5521. 'y',
  5522. 'originX',
  5523. 'originY',
  5524. 'anchorX',
  5525. 'anchorY',
  5526. 'rotation',
  5527. 'scaleX',
  5528. 'scaleY',
  5529. 'skewX',
  5530. 'skewY'
  5531. ]
  5532. function copyTransform(target, source) {
  5533. for (var i = 0; i < TRANSFORMABLE_PROPS.length; i++) {
  5534. var propName = TRANSFORMABLE_PROPS[i]
  5535. target[propName] = source[propName]
  5536. }
  5537. }
  5538. var Point = (function () {
  5539. function Point(x, y) {
  5540. this.x = x || 0
  5541. this.y = y || 0
  5542. }
  5543. Point.prototype.copy = function (other) {
  5544. this.x = other.x
  5545. this.y = other.y
  5546. return this
  5547. }
  5548. Point.prototype.clone = function () {
  5549. return new Point(this.x, this.y)
  5550. }
  5551. Point.prototype.set = function (x, y) {
  5552. this.x = x
  5553. this.y = y
  5554. return this
  5555. }
  5556. Point.prototype.equal = function (other) {
  5557. return other.x === this.x && other.y === this.y
  5558. }
  5559. Point.prototype.add = function (other) {
  5560. this.x += other.x
  5561. this.y += other.y
  5562. return this
  5563. }
  5564. Point.prototype.scale = function (scalar) {
  5565. this.x *= scalar
  5566. this.y *= scalar
  5567. }
  5568. Point.prototype.scaleAndAdd = function (other, scalar) {
  5569. this.x += other.x * scalar
  5570. this.y += other.y * scalar
  5571. }
  5572. Point.prototype.sub = function (other) {
  5573. this.x -= other.x
  5574. this.y -= other.y
  5575. return this
  5576. }
  5577. Point.prototype.dot = function (other) {
  5578. return this.x * other.x + this.y * other.y
  5579. }
  5580. Point.prototype.len = function () {
  5581. return Math.sqrt(this.x * this.x + this.y * this.y)
  5582. }
  5583. Point.prototype.lenSquare = function () {
  5584. return this.x * this.x + this.y * this.y
  5585. }
  5586. Point.prototype.normalize = function () {
  5587. var len = this.len()
  5588. this.x /= len
  5589. this.y /= len
  5590. return this
  5591. }
  5592. Point.prototype.distance = function (other) {
  5593. var dx = this.x - other.x
  5594. var dy = this.y - other.y
  5595. return Math.sqrt(dx * dx + dy * dy)
  5596. }
  5597. Point.prototype.distanceSquare = function (other) {
  5598. var dx = this.x - other.x
  5599. var dy = this.y - other.y
  5600. return dx * dx + dy * dy
  5601. }
  5602. Point.prototype.negate = function () {
  5603. this.x = -this.x
  5604. this.y = -this.y
  5605. return this
  5606. }
  5607. Point.prototype.transform = function (m) {
  5608. if (!m) {
  5609. return
  5610. }
  5611. var x = this.x
  5612. var y = this.y
  5613. this.x = m[0] * x + m[2] * y + m[4]
  5614. this.y = m[1] * x + m[3] * y + m[5]
  5615. return this
  5616. }
  5617. Point.prototype.toArray = function (out) {
  5618. out[0] = this.x
  5619. out[1] = this.y
  5620. return out
  5621. }
  5622. Point.prototype.fromArray = function (input) {
  5623. this.x = input[0]
  5624. this.y = input[1]
  5625. }
  5626. Point.set = function (p, x, y) {
  5627. p.x = x
  5628. p.y = y
  5629. }
  5630. Point.copy = function (p, p2) {
  5631. p.x = p2.x
  5632. p.y = p2.y
  5633. }
  5634. Point.len = function (p) {
  5635. return Math.sqrt(p.x * p.x + p.y * p.y)
  5636. }
  5637. Point.lenSquare = function (p) {
  5638. return p.x * p.x + p.y * p.y
  5639. }
  5640. Point.dot = function (p0, p1) {
  5641. return p0.x * p1.x + p0.y * p1.y
  5642. }
  5643. Point.add = function (out, p0, p1) {
  5644. out.x = p0.x + p1.x
  5645. out.y = p0.y + p1.y
  5646. }
  5647. Point.sub = function (out, p0, p1) {
  5648. out.x = p0.x - p1.x
  5649. out.y = p0.y - p1.y
  5650. }
  5651. Point.scale = function (out, p0, scalar) {
  5652. out.x = p0.x * scalar
  5653. out.y = p0.y * scalar
  5654. }
  5655. Point.scaleAndAdd = function (out, p0, p1, scalar) {
  5656. out.x = p0.x + p1.x * scalar
  5657. out.y = p0.y + p1.y * scalar
  5658. }
  5659. Point.lerp = function (out, p0, p1, t) {
  5660. var onet = 1 - t
  5661. out.x = onet * p0.x + t * p1.x
  5662. out.y = onet * p0.y + t * p1.y
  5663. }
  5664. return Point
  5665. })()
  5666. var Point$1 = Point
  5667. var mathMin$7 = Math.min
  5668. var mathMax$7 = Math.max
  5669. var lt = new Point$1()
  5670. var rb = new Point$1()
  5671. var lb = new Point$1()
  5672. var rt = new Point$1()
  5673. var minTv$1 = new Point$1()
  5674. var maxTv$1 = new Point$1()
  5675. var BoundingRect = (function () {
  5676. function BoundingRect(x, y, width, height) {
  5677. if (width < 0) {
  5678. x = x + width
  5679. width = -width
  5680. }
  5681. if (height < 0) {
  5682. y = y + height
  5683. height = -height
  5684. }
  5685. this.x = x
  5686. this.y = y
  5687. this.width = width
  5688. this.height = height
  5689. }
  5690. BoundingRect.prototype.union = function (other) {
  5691. var x = mathMin$7(other.x, this.x)
  5692. var y = mathMin$7(other.y, this.y)
  5693. if (isFinite(this.x) && isFinite(this.width)) {
  5694. this.width =
  5695. mathMax$7(other.x + other.width, this.x + this.width) - x
  5696. } else {
  5697. this.width = other.width
  5698. }
  5699. if (isFinite(this.y) && isFinite(this.height)) {
  5700. this.height =
  5701. mathMax$7(other.y + other.height, this.y + this.height) - y
  5702. } else {
  5703. this.height = other.height
  5704. }
  5705. this.x = x
  5706. this.y = y
  5707. }
  5708. BoundingRect.prototype.applyTransform = function (m) {
  5709. BoundingRect.applyTransform(this, this, m)
  5710. }
  5711. BoundingRect.prototype.calculateTransform = function (b) {
  5712. var a = this
  5713. var sx = b.width / a.width
  5714. var sy = b.height / a.height
  5715. var m = create()
  5716. translate(m, m, [-a.x, -a.y])
  5717. scale$1(m, m, [sx, sy])
  5718. translate(m, m, [b.x, b.y])
  5719. return m
  5720. }
  5721. BoundingRect.prototype.intersect = function (b, mtv) {
  5722. if (!b) {
  5723. return false
  5724. }
  5725. if (!(b instanceof BoundingRect)) {
  5726. b = BoundingRect.create(b)
  5727. }
  5728. var a = this
  5729. var ax0 = a.x
  5730. var ax1 = a.x + a.width
  5731. var ay0 = a.y
  5732. var ay1 = a.y + a.height
  5733. var bx0 = b.x
  5734. var bx1 = b.x + b.width
  5735. var by0 = b.y
  5736. var by1 = b.y + b.height
  5737. var overlap = !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0)
  5738. if (mtv) {
  5739. var dMin = Infinity
  5740. var dMax = 0
  5741. var d0 = Math.abs(ax1 - bx0)
  5742. var d1 = Math.abs(bx1 - ax0)
  5743. var d2 = Math.abs(ay1 - by0)
  5744. var d3 = Math.abs(by1 - ay0)
  5745. var dx = Math.min(d0, d1)
  5746. var dy = Math.min(d2, d3)
  5747. if (ax1 < bx0 || bx1 < ax0) {
  5748. if (dx > dMax) {
  5749. dMax = dx
  5750. if (d0 < d1) {
  5751. Point$1.set(maxTv$1, -d0, 0)
  5752. } else {
  5753. Point$1.set(maxTv$1, d1, 0)
  5754. }
  5755. }
  5756. } else {
  5757. if (dx < dMin) {
  5758. dMin = dx
  5759. if (d0 < d1) {
  5760. Point$1.set(minTv$1, d0, 0)
  5761. } else {
  5762. Point$1.set(minTv$1, -d1, 0)
  5763. }
  5764. }
  5765. }
  5766. if (ay1 < by0 || by1 < ay0) {
  5767. if (dy > dMax) {
  5768. dMax = dy
  5769. if (d2 < d3) {
  5770. Point$1.set(maxTv$1, 0, -d2)
  5771. } else {
  5772. Point$1.set(maxTv$1, 0, d3)
  5773. }
  5774. }
  5775. } else {
  5776. if (dx < dMin) {
  5777. dMin = dx
  5778. if (d2 < d3) {
  5779. Point$1.set(minTv$1, 0, d2)
  5780. } else {
  5781. Point$1.set(minTv$1, 0, -d3)
  5782. }
  5783. }
  5784. }
  5785. }
  5786. if (mtv) {
  5787. Point$1.copy(mtv, overlap ? minTv$1 : maxTv$1)
  5788. }
  5789. return overlap
  5790. }
  5791. BoundingRect.prototype.contain = function (x, y) {
  5792. var rect = this
  5793. return (
  5794. x >= rect.x &&
  5795. x <= rect.x + rect.width &&
  5796. y >= rect.y &&
  5797. y <= rect.y + rect.height
  5798. )
  5799. }
  5800. BoundingRect.prototype.clone = function () {
  5801. return new BoundingRect(this.x, this.y, this.width, this.height)
  5802. }
  5803. BoundingRect.prototype.copy = function (other) {
  5804. BoundingRect.copy(this, other)
  5805. }
  5806. BoundingRect.prototype.plain = function () {
  5807. return {
  5808. x: this.x,
  5809. y: this.y,
  5810. width: this.width,
  5811. height: this.height
  5812. }
  5813. }
  5814. BoundingRect.prototype.isFinite = function () {
  5815. return (
  5816. isFinite(this.x) &&
  5817. isFinite(this.y) &&
  5818. isFinite(this.width) &&
  5819. isFinite(this.height)
  5820. )
  5821. }
  5822. BoundingRect.prototype.isZero = function () {
  5823. return this.width === 0 || this.height === 0
  5824. }
  5825. BoundingRect.create = function (rect) {
  5826. return new BoundingRect(rect.x, rect.y, rect.width, rect.height)
  5827. }
  5828. BoundingRect.copy = function (target, source) {
  5829. target.x = source.x
  5830. target.y = source.y
  5831. target.width = source.width
  5832. target.height = source.height
  5833. }
  5834. BoundingRect.applyTransform = function (target, source, m) {
  5835. if (!m) {
  5836. if (target !== source) {
  5837. BoundingRect.copy(target, source)
  5838. }
  5839. return
  5840. }
  5841. if (m[1] < 1e-5 && m[1] > -1e-5 && m[2] < 1e-5 && m[2] > -1e-5) {
  5842. var sx = m[0]
  5843. var sy = m[3]
  5844. var tx = m[4]
  5845. var ty = m[5]
  5846. target.x = source.x * sx + tx
  5847. target.y = source.y * sy + ty
  5848. target.width = source.width * sx
  5849. target.height = source.height * sy
  5850. if (target.width < 0) {
  5851. target.x += target.width
  5852. target.width = -target.width
  5853. }
  5854. if (target.height < 0) {
  5855. target.y += target.height
  5856. target.height = -target.height
  5857. }
  5858. return
  5859. }
  5860. lt.x = lb.x = source.x
  5861. lt.y = rt.y = source.y
  5862. rb.x = rt.x = source.x + source.width
  5863. rb.y = lb.y = source.y + source.height
  5864. lt.transform(m)
  5865. rt.transform(m)
  5866. rb.transform(m)
  5867. lb.transform(m)
  5868. target.x = mathMin$7(lt.x, rb.x, lb.x, rt.x)
  5869. target.y = mathMin$7(lt.y, rb.y, lb.y, rt.y)
  5870. var maxX = mathMax$7(lt.x, rb.x, lb.x, rt.x)
  5871. var maxY = mathMax$7(lt.y, rb.y, lb.y, rt.y)
  5872. target.width = maxX - target.x
  5873. target.height = maxY - target.y
  5874. }
  5875. return BoundingRect
  5876. })()
  5877. var BoundingRect$1 = BoundingRect
  5878. var textWidthCache = {}
  5879. function getWidth(text, font) {
  5880. font = font || DEFAULT_FONT
  5881. var cacheOfFont = textWidthCache[font]
  5882. if (!cacheOfFont) {
  5883. cacheOfFont = textWidthCache[font] = new LRU$1(500)
  5884. }
  5885. var width = cacheOfFont.get(text)
  5886. if (width == null) {
  5887. width = platformApi.measureText(text, font).width
  5888. cacheOfFont.put(text, width)
  5889. }
  5890. return width
  5891. }
  5892. function innerGetBoundingRect(text, font, textAlign, textBaseline) {
  5893. var width = getWidth(text, font)
  5894. var height = getLineHeight(font)
  5895. var x = adjustTextX(0, width, textAlign)
  5896. var y = adjustTextY(0, height, textBaseline)
  5897. var rect = new BoundingRect$1(x, y, width, height)
  5898. return rect
  5899. }
  5900. function getBoundingRect(text, font, textAlign, textBaseline) {
  5901. var textLines = ((text || '') + '').split('\n')
  5902. var len = textLines.length
  5903. if (len === 1) {
  5904. return innerGetBoundingRect(
  5905. textLines[0],
  5906. font,
  5907. textAlign,
  5908. textBaseline
  5909. )
  5910. } else {
  5911. var uniondRect = new BoundingRect$1(0, 0, 0, 0)
  5912. for (var i = 0; i < textLines.length; i++) {
  5913. var rect = innerGetBoundingRect(
  5914. textLines[i],
  5915. font,
  5916. textAlign,
  5917. textBaseline
  5918. )
  5919. i === 0 ? uniondRect.copy(rect) : uniondRect.union(rect)
  5920. }
  5921. return uniondRect
  5922. }
  5923. }
  5924. function adjustTextX(x, width, textAlign) {
  5925. if (textAlign === 'right') {
  5926. x -= width
  5927. } else if (textAlign === 'center') {
  5928. x -= width / 2
  5929. }
  5930. return x
  5931. }
  5932. function adjustTextY(y, height, verticalAlign) {
  5933. if (verticalAlign === 'middle') {
  5934. y -= height / 2
  5935. } else if (verticalAlign === 'bottom') {
  5936. y -= height
  5937. }
  5938. return y
  5939. }
  5940. function getLineHeight(font) {
  5941. return getWidth('国', font)
  5942. }
  5943. function parsePercent$1(value, maxValue) {
  5944. if (typeof value === 'string') {
  5945. if (value.lastIndexOf('%') >= 0) {
  5946. return (parseFloat(value) / 100) * maxValue
  5947. }
  5948. return parseFloat(value)
  5949. }
  5950. return value
  5951. }
  5952. function _calculateTextPosition(out, opts, rect) {
  5953. var textPosition = opts.position || 'inside'
  5954. var distance = opts.distance != null ? opts.distance : 5
  5955. var height = rect.height
  5956. var width = rect.width
  5957. var halfHeight = height / 2
  5958. var x = rect.x
  5959. var y = rect.y
  5960. var textAlign = 'left'
  5961. var textVerticalAlign = 'top'
  5962. if (textPosition instanceof Array) {
  5963. x += parsePercent$1(textPosition[0], rect.width)
  5964. y += parsePercent$1(textPosition[1], rect.height)
  5965. textAlign = null
  5966. textVerticalAlign = null
  5967. } else {
  5968. switch (textPosition) {
  5969. case 'left':
  5970. x -= distance
  5971. y += halfHeight
  5972. textAlign = 'right'
  5973. textVerticalAlign = 'middle'
  5974. break
  5975. case 'right':
  5976. x += distance + width
  5977. y += halfHeight
  5978. textVerticalAlign = 'middle'
  5979. break
  5980. case 'top':
  5981. x += width / 2
  5982. y -= distance
  5983. textAlign = 'center'
  5984. textVerticalAlign = 'bottom'
  5985. break
  5986. case 'bottom':
  5987. x += width / 2
  5988. y += height + distance
  5989. textAlign = 'center'
  5990. break
  5991. case 'inside':
  5992. x += width / 2
  5993. y += halfHeight
  5994. textAlign = 'center'
  5995. textVerticalAlign = 'middle'
  5996. break
  5997. case 'insideLeft':
  5998. x += distance
  5999. y += halfHeight
  6000. textVerticalAlign = 'middle'
  6001. break
  6002. case 'insideRight':
  6003. x += width - distance
  6004. y += halfHeight
  6005. textAlign = 'right'
  6006. textVerticalAlign = 'middle'
  6007. break
  6008. case 'insideTop':
  6009. x += width / 2
  6010. y += distance
  6011. textAlign = 'center'
  6012. break
  6013. case 'insideBottom':
  6014. x += width / 2
  6015. y += height - distance
  6016. textAlign = 'center'
  6017. textVerticalAlign = 'bottom'
  6018. break
  6019. case 'insideTopLeft':
  6020. x += distance
  6021. y += distance
  6022. break
  6023. case 'insideTopRight':
  6024. x += width - distance
  6025. y += distance
  6026. textAlign = 'right'
  6027. break
  6028. case 'insideBottomLeft':
  6029. x += distance
  6030. y += height - distance
  6031. textVerticalAlign = 'bottom'
  6032. break
  6033. case 'insideBottomRight':
  6034. x += width - distance
  6035. y += height - distance
  6036. textAlign = 'right'
  6037. textVerticalAlign = 'bottom'
  6038. break
  6039. }
  6040. }
  6041. out = out || {}
  6042. out.x = x
  6043. out.y = y
  6044. out.align = textAlign
  6045. out.verticalAlign = textVerticalAlign
  6046. return out
  6047. }
  6048. var PRESERVED_NORMAL_STATE = '__zr_normal__'
  6049. var PRIMARY_STATES_KEYS$1 = TRANSFORMABLE_PROPS.concat(['ignore'])
  6050. var DEFAULT_ANIMATABLE_MAP = reduce(
  6051. TRANSFORMABLE_PROPS,
  6052. function (obj, key) {
  6053. obj[key] = true
  6054. return obj
  6055. },
  6056. { ignore: false }
  6057. )
  6058. var tmpTextPosCalcRes = {}
  6059. var tmpBoundingRect = new BoundingRect$1(0, 0, 0, 0)
  6060. var Element = (function () {
  6061. function Element(props) {
  6062. this.id = guid()
  6063. this.animators = []
  6064. this.currentStates = []
  6065. this.states = {}
  6066. this._init(props)
  6067. }
  6068. Element.prototype._init = function (props) {
  6069. this.attr(props)
  6070. }
  6071. Element.prototype.drift = function (dx, dy, e) {
  6072. switch (this.draggable) {
  6073. case 'horizontal':
  6074. dy = 0
  6075. break
  6076. case 'vertical':
  6077. dx = 0
  6078. break
  6079. }
  6080. var m = this.transform
  6081. if (!m) {
  6082. m = this.transform = [1, 0, 0, 1, 0, 0]
  6083. }
  6084. m[4] += dx
  6085. m[5] += dy
  6086. this.decomposeTransform()
  6087. this.markRedraw()
  6088. }
  6089. Element.prototype.beforeUpdate = function () {}
  6090. Element.prototype.afterUpdate = function () {}
  6091. Element.prototype.update = function () {
  6092. this.updateTransform()
  6093. if (this.__dirty) {
  6094. this.updateInnerText()
  6095. }
  6096. }
  6097. Element.prototype.updateInnerText = function (forceUpdate) {
  6098. var textEl = this._textContent
  6099. if (textEl && (!textEl.ignore || forceUpdate)) {
  6100. if (!this.textConfig) {
  6101. this.textConfig = {}
  6102. }
  6103. var textConfig = this.textConfig
  6104. var isLocal = textConfig.local
  6105. var innerTransformable = textEl.innerTransformable
  6106. var textAlign = void 0
  6107. var textVerticalAlign = void 0
  6108. var textStyleChanged = false
  6109. innerTransformable.parent = isLocal ? this : null
  6110. var innerOrigin = false
  6111. innerTransformable.copyTransform(textEl)
  6112. if (textConfig.position != null) {
  6113. var layoutRect = tmpBoundingRect
  6114. if (textConfig.layoutRect) {
  6115. layoutRect.copy(textConfig.layoutRect)
  6116. } else {
  6117. layoutRect.copy(this.getBoundingRect())
  6118. }
  6119. if (!isLocal) {
  6120. layoutRect.applyTransform(this.transform)
  6121. }
  6122. if (this.calculateTextPosition) {
  6123. this.calculateTextPosition(
  6124. tmpTextPosCalcRes,
  6125. textConfig,
  6126. layoutRect
  6127. )
  6128. } else {
  6129. _calculateTextPosition(
  6130. tmpTextPosCalcRes,
  6131. textConfig,
  6132. layoutRect
  6133. )
  6134. }
  6135. innerTransformable.x = tmpTextPosCalcRes.x
  6136. innerTransformable.y = tmpTextPosCalcRes.y
  6137. textAlign = tmpTextPosCalcRes.align
  6138. textVerticalAlign = tmpTextPosCalcRes.verticalAlign
  6139. var textOrigin = textConfig.origin
  6140. if (textOrigin && textConfig.rotation != null) {
  6141. var relOriginX = void 0
  6142. var relOriginY = void 0
  6143. if (textOrigin === 'center') {
  6144. relOriginX = layoutRect.width * 0.5
  6145. relOriginY = layoutRect.height * 0.5
  6146. } else {
  6147. relOriginX = parsePercent$1(
  6148. textOrigin[0],
  6149. layoutRect.width
  6150. )
  6151. relOriginY = parsePercent$1(
  6152. textOrigin[1],
  6153. layoutRect.height
  6154. )
  6155. }
  6156. innerOrigin = true
  6157. innerTransformable.originX =
  6158. -innerTransformable.x +
  6159. relOriginX +
  6160. (isLocal ? 0 : layoutRect.x)
  6161. innerTransformable.originY =
  6162. -innerTransformable.y +
  6163. relOriginY +
  6164. (isLocal ? 0 : layoutRect.y)
  6165. }
  6166. }
  6167. if (textConfig.rotation != null) {
  6168. innerTransformable.rotation = textConfig.rotation
  6169. }
  6170. var textOffset = textConfig.offset
  6171. if (textOffset) {
  6172. innerTransformable.x += textOffset[0]
  6173. innerTransformable.y += textOffset[1]
  6174. if (!innerOrigin) {
  6175. innerTransformable.originX = -textOffset[0]
  6176. innerTransformable.originY = -textOffset[1]
  6177. }
  6178. }
  6179. var isInside =
  6180. textConfig.inside == null
  6181. ? typeof textConfig.position === 'string' &&
  6182. textConfig.position.indexOf('inside') >= 0
  6183. : textConfig.inside
  6184. var innerTextDefaultStyle =
  6185. this._innerTextDefaultStyle ||
  6186. (this._innerTextDefaultStyle = {})
  6187. var textFill = void 0
  6188. var textStroke = void 0
  6189. var autoStroke = void 0
  6190. if (isInside && this.canBeInsideText()) {
  6191. textFill = textConfig.insideFill
  6192. textStroke = textConfig.insideStroke
  6193. if (textFill == null || textFill === 'auto') {
  6194. textFill = this.getInsideTextFill()
  6195. }
  6196. if (textStroke == null || textStroke === 'auto') {
  6197. textStroke = this.getInsideTextStroke(textFill)
  6198. autoStroke = true
  6199. }
  6200. } else {
  6201. textFill = textConfig.outsideFill
  6202. textStroke = textConfig.outsideStroke
  6203. if (textFill == null || textFill === 'auto') {
  6204. textFill = this.getOutsideFill()
  6205. }
  6206. if (textStroke == null || textStroke === 'auto') {
  6207. textStroke = this.getOutsideStroke(textFill)
  6208. autoStroke = true
  6209. }
  6210. }
  6211. textFill = textFill || '#000'
  6212. if (
  6213. textFill !== innerTextDefaultStyle.fill ||
  6214. textStroke !== innerTextDefaultStyle.stroke ||
  6215. autoStroke !== innerTextDefaultStyle.autoStroke ||
  6216. textAlign !== innerTextDefaultStyle.align ||
  6217. textVerticalAlign !== innerTextDefaultStyle.verticalAlign
  6218. ) {
  6219. textStyleChanged = true
  6220. innerTextDefaultStyle.fill = textFill
  6221. innerTextDefaultStyle.stroke = textStroke
  6222. innerTextDefaultStyle.autoStroke = autoStroke
  6223. innerTextDefaultStyle.align = textAlign
  6224. innerTextDefaultStyle.verticalAlign = textVerticalAlign
  6225. textEl.setDefaultTextStyle(innerTextDefaultStyle)
  6226. }
  6227. textEl.__dirty |= REDRAW_BIT
  6228. if (textStyleChanged) {
  6229. textEl.dirtyStyle(true)
  6230. }
  6231. }
  6232. }
  6233. Element.prototype.canBeInsideText = function () {
  6234. return true
  6235. }
  6236. Element.prototype.getInsideTextFill = function () {
  6237. return '#fff'
  6238. }
  6239. Element.prototype.getInsideTextStroke = function (textFill) {
  6240. return '#000'
  6241. }
  6242. Element.prototype.getOutsideFill = function () {
  6243. return this.__zr && this.__zr.isDarkMode()
  6244. ? LIGHT_LABEL_COLOR
  6245. : DARK_LABEL_COLOR
  6246. }
  6247. Element.prototype.getOutsideStroke = function (textFill) {
  6248. var backgroundColor = this.__zr && this.__zr.getBackgroundColor()
  6249. var colorArr =
  6250. typeof backgroundColor === 'string' && parse(backgroundColor)
  6251. if (!colorArr) {
  6252. colorArr = [255, 255, 255, 1]
  6253. }
  6254. var alpha = colorArr[3]
  6255. var isDark = this.__zr.isDarkMode()
  6256. for (var i = 0; i < 3; i++) {
  6257. colorArr[i] =
  6258. colorArr[i] * alpha + (isDark ? 0 : 255) * (1 - alpha)
  6259. }
  6260. colorArr[3] = 1
  6261. return stringify(colorArr, 'rgba')
  6262. }
  6263. Element.prototype.traverse = function (cb, context) {}
  6264. Element.prototype.attrKV = function (key, value) {
  6265. if (key === 'textConfig') {
  6266. this.setTextConfig(value)
  6267. } else if (key === 'textContent') {
  6268. this.setTextContent(value)
  6269. } else if (key === 'clipPath') {
  6270. this.setClipPath(value)
  6271. } else if (key === 'extra') {
  6272. this.extra = this.extra || {}
  6273. extend(this.extra, value)
  6274. } else {
  6275. this[key] = value
  6276. }
  6277. }
  6278. Element.prototype.hide = function () {
  6279. this.ignore = true
  6280. this.markRedraw()
  6281. }
  6282. Element.prototype.show = function () {
  6283. this.ignore = false
  6284. this.markRedraw()
  6285. }
  6286. Element.prototype.attr = function (keyOrObj, value) {
  6287. if (typeof keyOrObj === 'string') {
  6288. this.attrKV(keyOrObj, value)
  6289. } else if (isObject$2(keyOrObj)) {
  6290. var obj = keyOrObj
  6291. var keysArr = keys(obj)
  6292. for (var i = 0; i < keysArr.length; i++) {
  6293. var key = keysArr[i]
  6294. this.attrKV(key, keyOrObj[key])
  6295. }
  6296. }
  6297. this.markRedraw()
  6298. return this
  6299. }
  6300. Element.prototype.saveCurrentToNormalState = function (toState) {
  6301. this._innerSaveToNormal(toState)
  6302. var normalState = this._normalState
  6303. for (var i = 0; i < this.animators.length; i++) {
  6304. var animator = this.animators[i]
  6305. var fromStateTransition = animator.__fromStateTransition
  6306. if (
  6307. animator.getLoop() ||
  6308. (fromStateTransition &&
  6309. fromStateTransition !== PRESERVED_NORMAL_STATE)
  6310. ) {
  6311. continue
  6312. }
  6313. var targetName = animator.targetName
  6314. var target = targetName ? normalState[targetName] : normalState
  6315. animator.saveTo(target)
  6316. }
  6317. }
  6318. Element.prototype._innerSaveToNormal = function (toState) {
  6319. var normalState = this._normalState
  6320. if (!normalState) {
  6321. normalState = this._normalState = {}
  6322. }
  6323. if (toState.textConfig && !normalState.textConfig) {
  6324. normalState.textConfig = this.textConfig
  6325. }
  6326. this._savePrimaryToNormal(
  6327. toState,
  6328. normalState,
  6329. PRIMARY_STATES_KEYS$1
  6330. )
  6331. }
  6332. Element.prototype._savePrimaryToNormal = function (
  6333. toState,
  6334. normalState,
  6335. primaryKeys
  6336. ) {
  6337. for (var i = 0; i < primaryKeys.length; i++) {
  6338. var key = primaryKeys[i]
  6339. if (toState[key] != null && !(key in normalState)) {
  6340. normalState[key] = this[key]
  6341. }
  6342. }
  6343. }
  6344. Element.prototype.hasState = function () {
  6345. return this.currentStates.length > 0
  6346. }
  6347. Element.prototype.getState = function (name) {
  6348. return this.states[name]
  6349. }
  6350. Element.prototype.ensureState = function (name) {
  6351. var states = this.states
  6352. if (!states[name]) {
  6353. states[name] = {}
  6354. }
  6355. return states[name]
  6356. }
  6357. Element.prototype.clearStates = function (noAnimation) {
  6358. this.useState(PRESERVED_NORMAL_STATE, false, noAnimation)
  6359. }
  6360. Element.prototype.useState = function (
  6361. stateName,
  6362. keepCurrentStates,
  6363. noAnimation,
  6364. forceUseHoverLayer
  6365. ) {
  6366. var toNormalState = stateName === PRESERVED_NORMAL_STATE
  6367. var hasStates = this.hasState()
  6368. if (!hasStates && toNormalState) {
  6369. return
  6370. }
  6371. var currentStates = this.currentStates
  6372. var animationCfg = this.stateTransition
  6373. if (
  6374. indexOf(currentStates, stateName) >= 0 &&
  6375. (keepCurrentStates || currentStates.length === 1)
  6376. ) {
  6377. return
  6378. }
  6379. var state
  6380. if (this.stateProxy && !toNormalState) {
  6381. state = this.stateProxy(stateName)
  6382. }
  6383. if (!state) {
  6384. state = this.states && this.states[stateName]
  6385. }
  6386. if (!state && !toNormalState) {
  6387. logError('State ' + stateName + ' not exists.')
  6388. return
  6389. }
  6390. if (!toNormalState) {
  6391. this.saveCurrentToNormalState(state)
  6392. }
  6393. var useHoverLayer = !!(
  6394. (state && state.hoverLayer) ||
  6395. forceUseHoverLayer
  6396. )
  6397. if (useHoverLayer) {
  6398. this._toggleHoverLayerFlag(true)
  6399. }
  6400. this._applyStateObj(
  6401. stateName,
  6402. state,
  6403. this._normalState,
  6404. keepCurrentStates,
  6405. !noAnimation &&
  6406. !this.__inHover &&
  6407. animationCfg &&
  6408. animationCfg.duration > 0,
  6409. animationCfg
  6410. )
  6411. var textContent = this._textContent
  6412. var textGuide = this._textGuide
  6413. if (textContent) {
  6414. textContent.useState(
  6415. stateName,
  6416. keepCurrentStates,
  6417. noAnimation,
  6418. useHoverLayer
  6419. )
  6420. }
  6421. if (textGuide) {
  6422. textGuide.useState(
  6423. stateName,
  6424. keepCurrentStates,
  6425. noAnimation,
  6426. useHoverLayer
  6427. )
  6428. }
  6429. if (toNormalState) {
  6430. this.currentStates = []
  6431. this._normalState = {}
  6432. } else {
  6433. if (!keepCurrentStates) {
  6434. this.currentStates = [stateName]
  6435. } else {
  6436. this.currentStates.push(stateName)
  6437. }
  6438. }
  6439. this._updateAnimationTargets()
  6440. this.markRedraw()
  6441. if (!useHoverLayer && this.__inHover) {
  6442. this._toggleHoverLayerFlag(false)
  6443. this.__dirty &= ~REDRAW_BIT
  6444. }
  6445. return state
  6446. }
  6447. Element.prototype.useStates = function (
  6448. states,
  6449. noAnimation,
  6450. forceUseHoverLayer
  6451. ) {
  6452. if (!states.length) {
  6453. this.clearStates()
  6454. } else {
  6455. var stateObjects = []
  6456. var currentStates = this.currentStates
  6457. var len = states.length
  6458. var notChange = len === currentStates.length
  6459. if (notChange) {
  6460. for (var i = 0; i < len; i++) {
  6461. if (states[i] !== currentStates[i]) {
  6462. notChange = false
  6463. break
  6464. }
  6465. }
  6466. }
  6467. if (notChange) {
  6468. return
  6469. }
  6470. for (var i = 0; i < len; i++) {
  6471. var stateName = states[i]
  6472. var stateObj = void 0
  6473. if (this.stateProxy) {
  6474. stateObj = this.stateProxy(stateName, states)
  6475. }
  6476. if (!stateObj) {
  6477. stateObj = this.states[stateName]
  6478. }
  6479. if (stateObj) {
  6480. stateObjects.push(stateObj)
  6481. }
  6482. }
  6483. var lastStateObj = stateObjects[len - 1]
  6484. var useHoverLayer = !!(
  6485. (lastStateObj && lastStateObj.hoverLayer) ||
  6486. forceUseHoverLayer
  6487. )
  6488. if (useHoverLayer) {
  6489. this._toggleHoverLayerFlag(true)
  6490. }
  6491. var mergedState = this._mergeStates(stateObjects)
  6492. var animationCfg = this.stateTransition
  6493. this.saveCurrentToNormalState(mergedState)
  6494. this._applyStateObj(
  6495. states.join(','),
  6496. mergedState,
  6497. this._normalState,
  6498. false,
  6499. !noAnimation &&
  6500. !this.__inHover &&
  6501. animationCfg &&
  6502. animationCfg.duration > 0,
  6503. animationCfg
  6504. )
  6505. var textContent = this._textContent
  6506. var textGuide = this._textGuide
  6507. if (textContent) {
  6508. textContent.useStates(states, noAnimation, useHoverLayer)
  6509. }
  6510. if (textGuide) {
  6511. textGuide.useStates(states, noAnimation, useHoverLayer)
  6512. }
  6513. this._updateAnimationTargets()
  6514. this.currentStates = states.slice()
  6515. this.markRedraw()
  6516. if (!useHoverLayer && this.__inHover) {
  6517. this._toggleHoverLayerFlag(false)
  6518. this.__dirty &= ~REDRAW_BIT
  6519. }
  6520. }
  6521. }
  6522. Element.prototype._updateAnimationTargets = function () {
  6523. for (var i = 0; i < this.animators.length; i++) {
  6524. var animator = this.animators[i]
  6525. if (animator.targetName) {
  6526. animator.changeTarget(this[animator.targetName])
  6527. }
  6528. }
  6529. }
  6530. Element.prototype.removeState = function (state) {
  6531. var idx = indexOf(this.currentStates, state)
  6532. if (idx >= 0) {
  6533. var currentStates = this.currentStates.slice()
  6534. currentStates.splice(idx, 1)
  6535. this.useStates(currentStates)
  6536. }
  6537. }
  6538. Element.prototype.replaceState = function (
  6539. oldState,
  6540. newState,
  6541. forceAdd
  6542. ) {
  6543. var currentStates = this.currentStates.slice()
  6544. var idx = indexOf(currentStates, oldState)
  6545. var newStateExists = indexOf(currentStates, newState) >= 0
  6546. if (idx >= 0) {
  6547. if (!newStateExists) {
  6548. currentStates[idx] = newState
  6549. } else {
  6550. currentStates.splice(idx, 1)
  6551. }
  6552. } else if (forceAdd && !newStateExists) {
  6553. currentStates.push(newState)
  6554. }
  6555. this.useStates(currentStates)
  6556. }
  6557. Element.prototype.toggleState = function (state, enable) {
  6558. if (enable) {
  6559. this.useState(state, true)
  6560. } else {
  6561. this.removeState(state)
  6562. }
  6563. }
  6564. Element.prototype._mergeStates = function (states) {
  6565. var mergedState = {}
  6566. var mergedTextConfig
  6567. for (var i = 0; i < states.length; i++) {
  6568. var state = states[i]
  6569. extend(mergedState, state)
  6570. if (state.textConfig) {
  6571. mergedTextConfig = mergedTextConfig || {}
  6572. extend(mergedTextConfig, state.textConfig)
  6573. }
  6574. }
  6575. if (mergedTextConfig) {
  6576. mergedState.textConfig = mergedTextConfig
  6577. }
  6578. return mergedState
  6579. }
  6580. Element.prototype._applyStateObj = function (
  6581. stateName,
  6582. state,
  6583. normalState,
  6584. keepCurrentStates,
  6585. transition,
  6586. animationCfg
  6587. ) {
  6588. var needsRestoreToNormal = !(state && keepCurrentStates)
  6589. if (state && state.textConfig) {
  6590. this.textConfig = extend(
  6591. {},
  6592. keepCurrentStates ? this.textConfig : normalState.textConfig
  6593. )
  6594. extend(this.textConfig, state.textConfig)
  6595. } else if (needsRestoreToNormal) {
  6596. if (normalState.textConfig) {
  6597. this.textConfig = normalState.textConfig
  6598. }
  6599. }
  6600. var transitionTarget = {}
  6601. var hasTransition = false
  6602. for (var i = 0; i < PRIMARY_STATES_KEYS$1.length; i++) {
  6603. var key = PRIMARY_STATES_KEYS$1[i]
  6604. var propNeedsTransition =
  6605. transition && DEFAULT_ANIMATABLE_MAP[key]
  6606. if (state && state[key] != null) {
  6607. if (propNeedsTransition) {
  6608. hasTransition = true
  6609. transitionTarget[key] = state[key]
  6610. } else {
  6611. this[key] = state[key]
  6612. }
  6613. } else if (needsRestoreToNormal) {
  6614. if (normalState[key] != null) {
  6615. if (propNeedsTransition) {
  6616. hasTransition = true
  6617. transitionTarget[key] = normalState[key]
  6618. } else {
  6619. this[key] = normalState[key]
  6620. }
  6621. }
  6622. }
  6623. }
  6624. if (!transition) {
  6625. for (var i = 0; i < this.animators.length; i++) {
  6626. var animator = this.animators[i]
  6627. var targetName = animator.targetName
  6628. if (!animator.getLoop()) {
  6629. animator.__changeFinalValue(
  6630. targetName
  6631. ? (state || normalState)[targetName]
  6632. : state || normalState
  6633. )
  6634. }
  6635. }
  6636. }
  6637. if (hasTransition) {
  6638. this._transitionState(stateName, transitionTarget, animationCfg)
  6639. }
  6640. }
  6641. Element.prototype._attachComponent = function (componentEl) {
  6642. if (componentEl.__zr && !componentEl.__hostTarget) {
  6643. return
  6644. }
  6645. if (componentEl === this) {
  6646. return
  6647. }
  6648. var zr = this.__zr
  6649. if (zr) {
  6650. componentEl.addSelfToZr(zr)
  6651. }
  6652. componentEl.__zr = zr
  6653. componentEl.__hostTarget = this
  6654. }
  6655. Element.prototype._detachComponent = function (componentEl) {
  6656. if (componentEl.__zr) {
  6657. componentEl.removeSelfFromZr(componentEl.__zr)
  6658. }
  6659. componentEl.__zr = null
  6660. componentEl.__hostTarget = null
  6661. }
  6662. Element.prototype.getClipPath = function () {
  6663. return this._clipPath
  6664. }
  6665. Element.prototype.setClipPath = function (clipPath) {
  6666. if (this._clipPath && this._clipPath !== clipPath) {
  6667. this.removeClipPath()
  6668. }
  6669. this._attachComponent(clipPath)
  6670. this._clipPath = clipPath
  6671. this.markRedraw()
  6672. }
  6673. Element.prototype.removeClipPath = function () {
  6674. var clipPath = this._clipPath
  6675. if (clipPath) {
  6676. this._detachComponent(clipPath)
  6677. this._clipPath = null
  6678. this.markRedraw()
  6679. }
  6680. }
  6681. Element.prototype.getTextContent = function () {
  6682. return this._textContent
  6683. }
  6684. Element.prototype.setTextContent = function (textEl) {
  6685. var previousTextContent = this._textContent
  6686. if (previousTextContent === textEl) {
  6687. return
  6688. }
  6689. if (previousTextContent && previousTextContent !== textEl) {
  6690. this.removeTextContent()
  6691. }
  6692. textEl.innerTransformable = new Transformable()
  6693. this._attachComponent(textEl)
  6694. this._textContent = textEl
  6695. this.markRedraw()
  6696. }
  6697. Element.prototype.setTextConfig = function (cfg) {
  6698. if (!this.textConfig) {
  6699. this.textConfig = {}
  6700. }
  6701. extend(this.textConfig, cfg)
  6702. this.markRedraw()
  6703. }
  6704. Element.prototype.removeTextConfig = function () {
  6705. this.textConfig = null
  6706. this.markRedraw()
  6707. }
  6708. Element.prototype.removeTextContent = function () {
  6709. var textEl = this._textContent
  6710. if (textEl) {
  6711. textEl.innerTransformable = null
  6712. this._detachComponent(textEl)
  6713. this._textContent = null
  6714. this._innerTextDefaultStyle = null
  6715. this.markRedraw()
  6716. }
  6717. }
  6718. Element.prototype.getTextGuideLine = function () {
  6719. return this._textGuide
  6720. }
  6721. Element.prototype.setTextGuideLine = function (guideLine) {
  6722. if (this._textGuide && this._textGuide !== guideLine) {
  6723. this.removeTextGuideLine()
  6724. }
  6725. this._attachComponent(guideLine)
  6726. this._textGuide = guideLine
  6727. this.markRedraw()
  6728. }
  6729. Element.prototype.removeTextGuideLine = function () {
  6730. var textGuide = this._textGuide
  6731. if (textGuide) {
  6732. this._detachComponent(textGuide)
  6733. this._textGuide = null
  6734. this.markRedraw()
  6735. }
  6736. }
  6737. Element.prototype.markRedraw = function () {
  6738. this.__dirty |= REDRAW_BIT
  6739. var zr = this.__zr
  6740. if (zr) {
  6741. if (this.__inHover) {
  6742. zr.refreshHover()
  6743. } else {
  6744. zr.refresh()
  6745. }
  6746. }
  6747. if (this.__hostTarget) {
  6748. this.__hostTarget.markRedraw()
  6749. }
  6750. }
  6751. Element.prototype.dirty = function () {
  6752. this.markRedraw()
  6753. }
  6754. Element.prototype._toggleHoverLayerFlag = function (inHover) {
  6755. this.__inHover = inHover
  6756. var textContent = this._textContent
  6757. var textGuide = this._textGuide
  6758. if (textContent) {
  6759. textContent.__inHover = inHover
  6760. }
  6761. if (textGuide) {
  6762. textGuide.__inHover = inHover
  6763. }
  6764. }
  6765. Element.prototype.addSelfToZr = function (zr) {
  6766. if (this.__zr === zr) {
  6767. return
  6768. }
  6769. this.__zr = zr
  6770. var animators = this.animators
  6771. if (animators) {
  6772. for (var i = 0; i < animators.length; i++) {
  6773. zr.animation.addAnimator(animators[i])
  6774. }
  6775. }
  6776. if (this._clipPath) {
  6777. this._clipPath.addSelfToZr(zr)
  6778. }
  6779. if (this._textContent) {
  6780. this._textContent.addSelfToZr(zr)
  6781. }
  6782. if (this._textGuide) {
  6783. this._textGuide.addSelfToZr(zr)
  6784. }
  6785. }
  6786. Element.prototype.removeSelfFromZr = function (zr) {
  6787. if (!this.__zr) {
  6788. return
  6789. }
  6790. this.__zr = null
  6791. var animators = this.animators
  6792. if (animators) {
  6793. for (var i = 0; i < animators.length; i++) {
  6794. zr.animation.removeAnimator(animators[i])
  6795. }
  6796. }
  6797. if (this._clipPath) {
  6798. this._clipPath.removeSelfFromZr(zr)
  6799. }
  6800. if (this._textContent) {
  6801. this._textContent.removeSelfFromZr(zr)
  6802. }
  6803. if (this._textGuide) {
  6804. this._textGuide.removeSelfFromZr(zr)
  6805. }
  6806. }
  6807. Element.prototype.animate = function (
  6808. key,
  6809. loop,
  6810. allowDiscreteAnimation
  6811. ) {
  6812. var target = key ? this[key] : this
  6813. var animator = new Animator$1(
  6814. target,
  6815. loop,
  6816. allowDiscreteAnimation
  6817. )
  6818. key && (animator.targetName = key)
  6819. this.addAnimator(animator, key)
  6820. return animator
  6821. }
  6822. Element.prototype.addAnimator = function (animator, key) {
  6823. var zr = this.__zr
  6824. var el = this
  6825. animator
  6826. .during(function () {
  6827. el.updateDuringAnimation(key)
  6828. })
  6829. .done(function () {
  6830. var animators = el.animators
  6831. var idx = indexOf(animators, animator)
  6832. if (idx >= 0) {
  6833. animators.splice(idx, 1)
  6834. }
  6835. })
  6836. this.animators.push(animator)
  6837. if (zr) {
  6838. zr.animation.addAnimator(animator)
  6839. }
  6840. zr && zr.wakeUp()
  6841. }
  6842. Element.prototype.updateDuringAnimation = function (key) {
  6843. this.markRedraw()
  6844. }
  6845. Element.prototype.stopAnimation = function (scope, forwardToLast) {
  6846. var animators = this.animators
  6847. var len = animators.length
  6848. var leftAnimators = []
  6849. for (var i = 0; i < len; i++) {
  6850. var animator = animators[i]
  6851. if (!scope || scope === animator.scope) {
  6852. animator.stop(forwardToLast)
  6853. } else {
  6854. leftAnimators.push(animator)
  6855. }
  6856. }
  6857. this.animators = leftAnimators
  6858. return this
  6859. }
  6860. Element.prototype.animateTo = function (
  6861. target,
  6862. cfg,
  6863. animationProps
  6864. ) {
  6865. animateTo(this, target, cfg, animationProps)
  6866. }
  6867. Element.prototype.animateFrom = function (
  6868. target,
  6869. cfg,
  6870. animationProps
  6871. ) {
  6872. animateTo(this, target, cfg, animationProps, true)
  6873. }
  6874. Element.prototype._transitionState = function (
  6875. stateName,
  6876. target,
  6877. cfg,
  6878. animationProps
  6879. ) {
  6880. var animators = animateTo(this, target, cfg, animationProps)
  6881. for (var i = 0; i < animators.length; i++) {
  6882. animators[i].__fromStateTransition = stateName
  6883. }
  6884. }
  6885. Element.prototype.getBoundingRect = function () {
  6886. return null
  6887. }
  6888. Element.prototype.getPaintRect = function () {
  6889. return null
  6890. }
  6891. Element.initDefaultProps = (function () {
  6892. var elProto = Element.prototype
  6893. elProto.type = 'element'
  6894. elProto.name = ''
  6895. elProto.ignore =
  6896. elProto.silent =
  6897. elProto.isGroup =
  6898. elProto.draggable =
  6899. elProto.dragging =
  6900. elProto.ignoreClip =
  6901. elProto.__inHover =
  6902. false
  6903. elProto.__dirty = REDRAW_BIT
  6904. function createLegacyProperty(key, privateKey, xKey, yKey) {
  6905. Object.defineProperty(elProto, key, {
  6906. get: function get() {
  6907. if (!this[privateKey]) {
  6908. var pos = (this[privateKey] = [])
  6909. enhanceArray(this, pos)
  6910. }
  6911. return this[privateKey]
  6912. },
  6913. set: function set(pos) {
  6914. this[xKey] = pos[0]
  6915. this[yKey] = pos[1]
  6916. this[privateKey] = pos
  6917. enhanceArray(this, pos)
  6918. }
  6919. })
  6920. function enhanceArray(self, pos) {
  6921. Object.defineProperty(pos, 0, {
  6922. get: function get() {
  6923. return self[xKey]
  6924. },
  6925. set: function set(val) {
  6926. self[xKey] = val
  6927. }
  6928. })
  6929. Object.defineProperty(pos, 1, {
  6930. get: function get() {
  6931. return self[yKey]
  6932. },
  6933. set: function set(val) {
  6934. self[yKey] = val
  6935. }
  6936. })
  6937. }
  6938. }
  6939. if (Object.defineProperty) {
  6940. createLegacyProperty('position', '_legacyPos', 'x', 'y')
  6941. createLegacyProperty(
  6942. 'scale',
  6943. '_legacyScale',
  6944. 'scaleX',
  6945. 'scaleY'
  6946. )
  6947. createLegacyProperty(
  6948. 'origin',
  6949. '_legacyOrigin',
  6950. 'originX',
  6951. 'originY'
  6952. )
  6953. }
  6954. })()
  6955. return Element
  6956. })()
  6957. mixin(Element, Eventful$1)
  6958. mixin(Element, Transformable)
  6959. function animateTo(animatable, target, cfg, animationProps, reverse) {
  6960. cfg = cfg || {}
  6961. var animators = []
  6962. animateToShallow(
  6963. animatable,
  6964. '',
  6965. animatable,
  6966. target,
  6967. cfg,
  6968. animationProps,
  6969. animators,
  6970. reverse
  6971. )
  6972. var finishCount = animators.length
  6973. var doneHappened = false
  6974. var cfgDone = cfg.done
  6975. var cfgAborted = cfg.aborted
  6976. var doneCb = function doneCb() {
  6977. doneHappened = true
  6978. finishCount--
  6979. if (finishCount <= 0) {
  6980. doneHappened ? cfgDone && cfgDone() : cfgAborted && cfgAborted()
  6981. }
  6982. }
  6983. var abortedCb = function abortedCb() {
  6984. finishCount--
  6985. if (finishCount <= 0) {
  6986. doneHappened ? cfgDone && cfgDone() : cfgAborted && cfgAborted()
  6987. }
  6988. }
  6989. if (!finishCount) {
  6990. cfgDone && cfgDone()
  6991. }
  6992. if (animators.length > 0 && cfg.during) {
  6993. animators[0].during(function (target, percent) {
  6994. cfg.during(percent)
  6995. })
  6996. }
  6997. for (var i = 0; i < animators.length; i++) {
  6998. var animator = animators[i]
  6999. if (doneCb) {
  7000. animator.done(doneCb)
  7001. }
  7002. if (abortedCb) {
  7003. animator.aborted(abortedCb)
  7004. }
  7005. if (cfg.force) {
  7006. animator.duration(cfg.duration)
  7007. }
  7008. animator.start(cfg.easing)
  7009. }
  7010. return animators
  7011. }
  7012. function copyArrShallow(source, target, len) {
  7013. for (var i = 0; i < len; i++) {
  7014. source[i] = target[i]
  7015. }
  7016. }
  7017. function is2DArray(value) {
  7018. return isArrayLike(value[0])
  7019. }
  7020. function copyValue(target, source, key) {
  7021. if (isArrayLike(source[key])) {
  7022. if (!isArrayLike(target[key])) {
  7023. target[key] = []
  7024. }
  7025. if (isTypedArray(source[key])) {
  7026. var len = source[key].length
  7027. if (target[key].length !== len) {
  7028. target[key] = new source[key].constructor(len)
  7029. copyArrShallow(target[key], source[key], len)
  7030. }
  7031. } else {
  7032. var sourceArr = source[key]
  7033. var targetArr = target[key]
  7034. var len0 = sourceArr.length
  7035. if (is2DArray(sourceArr)) {
  7036. var len1 = sourceArr[0].length
  7037. for (var i = 0; i < len0; i++) {
  7038. if (!targetArr[i]) {
  7039. targetArr[i] = Array.prototype.slice.call(sourceArr[i])
  7040. } else {
  7041. copyArrShallow(targetArr[i], sourceArr[i], len1)
  7042. }
  7043. }
  7044. } else {
  7045. copyArrShallow(targetArr, sourceArr, len0)
  7046. }
  7047. targetArr.length = sourceArr.length
  7048. }
  7049. } else {
  7050. target[key] = source[key]
  7051. }
  7052. }
  7053. function isValueSame(val1, val2) {
  7054. return (
  7055. val1 === val2 ||
  7056. (isArrayLike(val1) &&
  7057. isArrayLike(val2) &&
  7058. is1DArraySame(val1, val2))
  7059. )
  7060. }
  7061. function is1DArraySame(arr0, arr1) {
  7062. var len = arr0.length
  7063. if (len !== arr1.length) {
  7064. return false
  7065. }
  7066. for (var i = 0; i < len; i++) {
  7067. if (arr0[i] !== arr1[i]) {
  7068. return false
  7069. }
  7070. }
  7071. return true
  7072. }
  7073. function animateToShallow(
  7074. animatable,
  7075. topKey,
  7076. animateObj,
  7077. target,
  7078. cfg,
  7079. animationProps,
  7080. animators,
  7081. reverse
  7082. ) {
  7083. var targetKeys = keys(target)
  7084. var duration = cfg.duration
  7085. var delay = cfg.delay
  7086. var additive = cfg.additive
  7087. var setToFinal = cfg.setToFinal
  7088. var animateAll = !isObject$2(animationProps)
  7089. var existsAnimators = animatable.animators
  7090. var animationKeys = []
  7091. for (var k = 0; k < targetKeys.length; k++) {
  7092. var innerKey = targetKeys[k]
  7093. var targetVal = target[innerKey]
  7094. if (
  7095. targetVal != null &&
  7096. animateObj[innerKey] != null &&
  7097. (animateAll || animationProps[innerKey])
  7098. ) {
  7099. if (
  7100. isObject$2(targetVal) &&
  7101. !isArrayLike(targetVal) &&
  7102. !isGradientObject(targetVal)
  7103. ) {
  7104. if (topKey) {
  7105. if (!reverse) {
  7106. animateObj[innerKey] = targetVal
  7107. animatable.updateDuringAnimation(topKey)
  7108. }
  7109. continue
  7110. }
  7111. animateToShallow(
  7112. animatable,
  7113. innerKey,
  7114. animateObj[innerKey],
  7115. targetVal,
  7116. cfg,
  7117. animationProps && animationProps[innerKey],
  7118. animators,
  7119. reverse
  7120. )
  7121. } else {
  7122. animationKeys.push(innerKey)
  7123. }
  7124. } else if (!reverse) {
  7125. animateObj[innerKey] = targetVal
  7126. animatable.updateDuringAnimation(topKey)
  7127. animationKeys.push(innerKey)
  7128. }
  7129. }
  7130. var keyLen = animationKeys.length
  7131. if (!additive && keyLen) {
  7132. for (var i = 0; i < existsAnimators.length; i++) {
  7133. var animator = existsAnimators[i]
  7134. if (animator.targetName === topKey) {
  7135. var allAborted = animator.stopTracks(animationKeys)
  7136. if (allAborted) {
  7137. var idx = indexOf(existsAnimators, animator)
  7138. existsAnimators.splice(idx, 1)
  7139. }
  7140. }
  7141. }
  7142. }
  7143. if (!cfg.force) {
  7144. animationKeys = filter(animationKeys, function (key) {
  7145. return !isValueSame(target[key], animateObj[key])
  7146. })
  7147. keyLen = animationKeys.length
  7148. }
  7149. if (keyLen > 0 || (cfg.force && !animators.length)) {
  7150. var revertedSource = void 0
  7151. var reversedTarget = void 0
  7152. var sourceClone = void 0
  7153. if (reverse) {
  7154. reversedTarget = {}
  7155. if (setToFinal) {
  7156. revertedSource = {}
  7157. }
  7158. for (var i = 0; i < keyLen; i++) {
  7159. var innerKey = animationKeys[i]
  7160. reversedTarget[innerKey] = animateObj[innerKey]
  7161. if (setToFinal) {
  7162. revertedSource[innerKey] = target[innerKey]
  7163. } else {
  7164. animateObj[innerKey] = target[innerKey]
  7165. }
  7166. }
  7167. } else if (setToFinal) {
  7168. sourceClone = {}
  7169. for (var i = 0; i < keyLen; i++) {
  7170. var innerKey = animationKeys[i]
  7171. sourceClone[innerKey] = cloneValue(animateObj[innerKey])
  7172. copyValue(animateObj, target, innerKey)
  7173. }
  7174. }
  7175. var animator = new Animator$1(
  7176. animateObj,
  7177. false,
  7178. false,
  7179. additive
  7180. ? filter(existsAnimators, function (animator) {
  7181. return animator.targetName === topKey
  7182. })
  7183. : null
  7184. )
  7185. animator.targetName = topKey
  7186. if (cfg.scope) {
  7187. animator.scope = cfg.scope
  7188. }
  7189. if (setToFinal && revertedSource) {
  7190. animator.whenWithKeys(0, revertedSource, animationKeys)
  7191. }
  7192. if (sourceClone) {
  7193. animator.whenWithKeys(0, sourceClone, animationKeys)
  7194. }
  7195. animator
  7196. .whenWithKeys(
  7197. duration == null ? 500 : duration,
  7198. reverse ? reversedTarget : target,
  7199. animationKeys
  7200. )
  7201. .delay(delay || 0)
  7202. animatable.addAnimator(animator, topKey)
  7203. animators.push(animator)
  7204. }
  7205. }
  7206. var Element$1 = Element
  7207. var Group$2 = (function (_super) {
  7208. __extends(Group, _super)
  7209. function Group(opts) {
  7210. var _this = _super.call(this) || this
  7211. _this.isGroup = true
  7212. _this._children = []
  7213. _this.attr(opts)
  7214. return _this
  7215. }
  7216. Group.prototype.childrenRef = function () {
  7217. return this._children
  7218. }
  7219. Group.prototype.children = function () {
  7220. return this._children.slice()
  7221. }
  7222. Group.prototype.childAt = function (idx) {
  7223. return this._children[idx]
  7224. }
  7225. Group.prototype.childOfName = function (name) {
  7226. var children = this._children
  7227. for (var i = 0; i < children.length; i++) {
  7228. if (children[i].name === name) {
  7229. return children[i]
  7230. }
  7231. }
  7232. }
  7233. Group.prototype.childCount = function () {
  7234. return this._children.length
  7235. }
  7236. Group.prototype.add = function (child) {
  7237. if (child) {
  7238. if (child !== this && child.parent !== this) {
  7239. this._children.push(child)
  7240. this._doAdd(child)
  7241. }
  7242. }
  7243. return this
  7244. }
  7245. Group.prototype.addBefore = function (child, nextSibling) {
  7246. if (
  7247. child &&
  7248. child !== this &&
  7249. child.parent !== this &&
  7250. nextSibling &&
  7251. nextSibling.parent === this
  7252. ) {
  7253. var children = this._children
  7254. var idx = children.indexOf(nextSibling)
  7255. if (idx >= 0) {
  7256. children.splice(idx, 0, child)
  7257. this._doAdd(child)
  7258. }
  7259. }
  7260. return this
  7261. }
  7262. Group.prototype.replace = function (oldChild, newChild) {
  7263. var idx = indexOf(this._children, oldChild)
  7264. if (idx >= 0) {
  7265. this.replaceAt(newChild, idx)
  7266. }
  7267. return this
  7268. }
  7269. Group.prototype.replaceAt = function (child, index) {
  7270. var children = this._children
  7271. var old = children[index]
  7272. if (
  7273. child &&
  7274. child !== this &&
  7275. child.parent !== this &&
  7276. child !== old
  7277. ) {
  7278. children[index] = child
  7279. old.parent = null
  7280. var zr = this.__zr
  7281. if (zr) {
  7282. old.removeSelfFromZr(zr)
  7283. }
  7284. this._doAdd(child)
  7285. }
  7286. return this
  7287. }
  7288. Group.prototype._doAdd = function (child) {
  7289. if (child.parent) {
  7290. child.parent.remove(child)
  7291. }
  7292. child.parent = this
  7293. var zr = this.__zr
  7294. if (zr && zr !== child.__zr) {
  7295. child.addSelfToZr(zr)
  7296. }
  7297. zr && zr.refresh()
  7298. }
  7299. Group.prototype.remove = function (child) {
  7300. var zr = this.__zr
  7301. var children = this._children
  7302. var idx = indexOf(children, child)
  7303. if (idx < 0) {
  7304. return this
  7305. }
  7306. children.splice(idx, 1)
  7307. child.parent = null
  7308. if (zr) {
  7309. child.removeSelfFromZr(zr)
  7310. }
  7311. zr && zr.refresh()
  7312. return this
  7313. }
  7314. Group.prototype.removeAll = function () {
  7315. var children = this._children
  7316. var zr = this.__zr
  7317. for (var i = 0; i < children.length; i++) {
  7318. var child = children[i]
  7319. if (zr) {
  7320. child.removeSelfFromZr(zr)
  7321. }
  7322. child.parent = null
  7323. }
  7324. children.length = 0
  7325. return this
  7326. }
  7327. Group.prototype.eachChild = function (cb, context) {
  7328. var children = this._children
  7329. for (var i = 0; i < children.length; i++) {
  7330. var child = children[i]
  7331. cb.call(context, child, i)
  7332. }
  7333. return this
  7334. }
  7335. Group.prototype.traverse = function (cb, context) {
  7336. for (var i = 0; i < this._children.length; i++) {
  7337. var child = this._children[i]
  7338. var stopped = cb.call(context, child)
  7339. if (child.isGroup && !stopped) {
  7340. child.traverse(cb, context)
  7341. }
  7342. }
  7343. return this
  7344. }
  7345. Group.prototype.addSelfToZr = function (zr) {
  7346. _super.prototype.addSelfToZr.call(this, zr)
  7347. for (var i = 0; i < this._children.length; i++) {
  7348. var child = this._children[i]
  7349. child.addSelfToZr(zr)
  7350. }
  7351. }
  7352. Group.prototype.removeSelfFromZr = function (zr) {
  7353. _super.prototype.removeSelfFromZr.call(this, zr)
  7354. for (var i = 0; i < this._children.length; i++) {
  7355. var child = this._children[i]
  7356. child.removeSelfFromZr(zr)
  7357. }
  7358. }
  7359. Group.prototype.getBoundingRect = function (includeChildren) {
  7360. var tmpRect = new BoundingRect$1(0, 0, 0, 0)
  7361. var children = includeChildren || this._children
  7362. var tmpMat = []
  7363. var rect = null
  7364. for (var i = 0; i < children.length; i++) {
  7365. var child = children[i]
  7366. if (child.ignore || child.invisible) {
  7367. continue
  7368. }
  7369. var childRect = child.getBoundingRect()
  7370. var transform = child.getLocalTransform(tmpMat)
  7371. if (transform) {
  7372. BoundingRect$1.applyTransform(tmpRect, childRect, transform)
  7373. rect = rect || tmpRect.clone()
  7374. rect.union(tmpRect)
  7375. } else {
  7376. rect = rect || childRect.clone()
  7377. rect.union(childRect)
  7378. }
  7379. }
  7380. return rect || tmpRect
  7381. }
  7382. return Group
  7383. })(Element$1)
  7384. Group$2.prototype.type = 'group'
  7385. var Group$3 = Group$2
  7386. /*!
  7387. * ZRender, a high performance 2d drawing library.
  7388. *
  7389. * Copyright (c) 2013, Baidu Inc.
  7390. * All rights reserved.
  7391. *
  7392. * LICENSE
  7393. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  7394. */ var painterCtors = {}
  7395. var instances$1 = {}
  7396. function delInstance(id) {
  7397. delete instances$1[id]
  7398. }
  7399. function isDarkMode(backgroundColor) {
  7400. if (!backgroundColor) {
  7401. return false
  7402. }
  7403. if (typeof backgroundColor === 'string') {
  7404. return lum(backgroundColor, 1) < DARK_MODE_THRESHOLD
  7405. } else if (backgroundColor.colorStops) {
  7406. var colorStops = backgroundColor.colorStops
  7407. var totalLum = 0
  7408. var len = colorStops.length
  7409. for (var i = 0; i < len; i++) {
  7410. totalLum += lum(colorStops[i].color, 1)
  7411. }
  7412. totalLum /= len
  7413. return totalLum < DARK_MODE_THRESHOLD
  7414. }
  7415. return false
  7416. }
  7417. var ZRender = (function () {
  7418. function ZRender(id, dom, opts) {
  7419. var _this = this
  7420. this._sleepAfterStill = 10
  7421. this._stillFrameAccum = 0
  7422. this._needsRefresh = true
  7423. this._needsRefreshHover = true
  7424. this._darkMode = false
  7425. opts = opts || {}
  7426. this.dom = dom
  7427. this.id = id
  7428. var storage = new Storage$1()
  7429. var rendererType = opts.renderer || 'canvas'
  7430. if (!painterCtors[rendererType]) {
  7431. rendererType = keys(painterCtors)[0]
  7432. }
  7433. opts.useDirtyRect =
  7434. opts.useDirtyRect == null ? false : opts.useDirtyRect
  7435. var painter = new painterCtors[rendererType](
  7436. dom,
  7437. storage,
  7438. opts,
  7439. id
  7440. )
  7441. var ssrMode = opts.ssr || painter.ssrOnly
  7442. this.storage = storage
  7443. this.painter = painter
  7444. var handerProxy =
  7445. !env$1.node && !env$1.worker && !ssrMode
  7446. ? new HandlerProxy(painter.getViewportRoot(), painter.root)
  7447. : null
  7448. this.handler = new Handler$1(
  7449. storage,
  7450. painter,
  7451. handerProxy,
  7452. painter.root
  7453. )
  7454. this.animation = new Animation$1({
  7455. stage: {
  7456. update: ssrMode
  7457. ? null
  7458. : function () {
  7459. return _this._flush(true)
  7460. }
  7461. }
  7462. })
  7463. if (!ssrMode) {
  7464. this.animation.start()
  7465. }
  7466. }
  7467. ZRender.prototype.add = function (el) {
  7468. if (!el) {
  7469. return
  7470. }
  7471. this.storage.addRoot(el)
  7472. el.addSelfToZr(this)
  7473. this.refresh()
  7474. }
  7475. ZRender.prototype.remove = function (el) {
  7476. if (!el) {
  7477. return
  7478. }
  7479. this.storage.delRoot(el)
  7480. el.removeSelfFromZr(this)
  7481. this.refresh()
  7482. }
  7483. ZRender.prototype.configLayer = function (zLevel, config) {
  7484. if (this.painter.configLayer) {
  7485. this.painter.configLayer(zLevel, config)
  7486. }
  7487. this.refresh()
  7488. }
  7489. ZRender.prototype.setBackgroundColor = function (backgroundColor) {
  7490. if (this.painter.setBackgroundColor) {
  7491. this.painter.setBackgroundColor(backgroundColor)
  7492. }
  7493. this.refresh()
  7494. this._backgroundColor = backgroundColor
  7495. this._darkMode = isDarkMode(backgroundColor)
  7496. }
  7497. ZRender.prototype.getBackgroundColor = function () {
  7498. return this._backgroundColor
  7499. }
  7500. ZRender.prototype.setDarkMode = function (darkMode) {
  7501. this._darkMode = darkMode
  7502. }
  7503. ZRender.prototype.isDarkMode = function () {
  7504. return this._darkMode
  7505. }
  7506. ZRender.prototype.refreshImmediately = function (fromInside) {
  7507. if (!fromInside) {
  7508. this.animation.update(true)
  7509. }
  7510. this._needsRefresh = false
  7511. this.painter.refresh()
  7512. this._needsRefresh = false
  7513. }
  7514. ZRender.prototype.refresh = function () {
  7515. this._needsRefresh = true
  7516. this.animation.start()
  7517. }
  7518. ZRender.prototype.flush = function () {
  7519. this._flush(false)
  7520. }
  7521. ZRender.prototype._flush = function (fromInside) {
  7522. var triggerRendered
  7523. var start = getTime()
  7524. if (this._needsRefresh) {
  7525. triggerRendered = true
  7526. this.refreshImmediately(fromInside)
  7527. }
  7528. if (this._needsRefreshHover) {
  7529. triggerRendered = true
  7530. this.refreshHoverImmediately()
  7531. }
  7532. var end = getTime()
  7533. if (triggerRendered) {
  7534. this._stillFrameAccum = 0
  7535. this.trigger('rendered', { elapsedTime: end - start })
  7536. } else if (this._sleepAfterStill > 0) {
  7537. this._stillFrameAccum++
  7538. if (this._stillFrameAccum > this._sleepAfterStill) {
  7539. this.animation.stop()
  7540. }
  7541. }
  7542. }
  7543. ZRender.prototype.setSleepAfterStill = function (stillFramesCount) {
  7544. this._sleepAfterStill = stillFramesCount
  7545. }
  7546. ZRender.prototype.wakeUp = function () {
  7547. this.animation.start()
  7548. this._stillFrameAccum = 0
  7549. }
  7550. ZRender.prototype.refreshHover = function () {
  7551. this._needsRefreshHover = true
  7552. }
  7553. ZRender.prototype.refreshHoverImmediately = function () {
  7554. this._needsRefreshHover = false
  7555. if (
  7556. this.painter.refreshHover &&
  7557. this.painter.getType() === 'canvas'
  7558. ) {
  7559. this.painter.refreshHover()
  7560. }
  7561. }
  7562. ZRender.prototype.resize = function (opts) {
  7563. opts = opts || {}
  7564. this.painter.resize(opts.width, opts.height)
  7565. this.handler.resize()
  7566. }
  7567. ZRender.prototype.clearAnimation = function () {
  7568. this.animation.clear()
  7569. }
  7570. ZRender.prototype.getWidth = function () {
  7571. return this.painter.getWidth()
  7572. }
  7573. ZRender.prototype.getHeight = function () {
  7574. return this.painter.getHeight()
  7575. }
  7576. ZRender.prototype.setCursorStyle = function (cursorStyle) {
  7577. this.handler.setCursorStyle(cursorStyle)
  7578. }
  7579. ZRender.prototype.findHover = function (x, y) {
  7580. return this.handler.findHover(x, y)
  7581. }
  7582. ZRender.prototype.on = function (eventName, eventHandler, context) {
  7583. this.handler.on(eventName, eventHandler, context)
  7584. return this
  7585. }
  7586. ZRender.prototype.off = function (eventName, eventHandler) {
  7587. this.handler.off(eventName, eventHandler)
  7588. }
  7589. ZRender.prototype.trigger = function (eventName, event) {
  7590. this.handler.trigger(eventName, event)
  7591. }
  7592. ZRender.prototype.clear = function () {
  7593. var roots = this.storage.getRoots()
  7594. for (var i = 0; i < roots.length; i++) {
  7595. if (roots[i] instanceof Group$3) {
  7596. roots[i].removeSelfFromZr(this)
  7597. }
  7598. }
  7599. this.storage.delAllRoots()
  7600. this.painter.clear()
  7601. }
  7602. ZRender.prototype.dispose = function () {
  7603. this.animation.stop()
  7604. this.clear()
  7605. this.storage.dispose()
  7606. this.painter.dispose()
  7607. this.handler.dispose()
  7608. this.animation = this.storage = this.painter = this.handler = null
  7609. delInstance(this.id)
  7610. }
  7611. return ZRender
  7612. })()
  7613. function init$1(dom, opts) {
  7614. var zr = new ZRender(guid(), dom, opts)
  7615. instances$1[zr.id] = zr
  7616. return zr
  7617. }
  7618. function _registerPainter(name, Ctor) {
  7619. painterCtors[name] = Ctor
  7620. }
  7621. var RADIAN_EPSILON = 1e-4 // Although chrome already enlarge this number to 100 for `toFixed`, but
  7622. // we sill follow the spec for compatibility.
  7623. var ROUND_SUPPORTED_PRECISION_MAX = 20
  7624. function _trim(str) {
  7625. return str.replace(/^\s+|\s+$/g, '')
  7626. }
  7627. /**
  7628. * Linear mapping a value from domain to range
  7629. * @param val
  7630. * @param domain Domain extent domain[0] can be bigger than domain[1]
  7631. * @param range Range extent range[0] can be bigger than range[1]
  7632. * @param clamp Default to be false
  7633. */ function linearMap(val, domain, range, clamp) {
  7634. var d0 = domain[0]
  7635. var d1 = domain[1]
  7636. var r0 = range[0]
  7637. var r1 = range[1]
  7638. var subDomain = d1 - d0
  7639. var subRange = r1 - r0
  7640. if (subDomain === 0) {
  7641. return subRange === 0 ? r0 : (r0 + r1) / 2
  7642. } // Avoid accuracy problem in edge, such as
  7643. // 146.39 - 62.83 === 83.55999999999999.
  7644. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  7645. // It is a little verbose for efficiency considering this method
  7646. // is a hotspot.
  7647. if (clamp) {
  7648. if (subDomain > 0) {
  7649. if (val <= d0) {
  7650. return r0
  7651. } else if (val >= d1) {
  7652. return r1
  7653. }
  7654. } else {
  7655. if (val >= d0) {
  7656. return r0
  7657. } else if (val <= d1) {
  7658. return r1
  7659. }
  7660. }
  7661. } else {
  7662. if (val === d0) {
  7663. return r0
  7664. }
  7665. if (val === d1) {
  7666. return r1
  7667. }
  7668. }
  7669. return ((val - d0) / subDomain) * subRange + r0
  7670. }
  7671. /**
  7672. * Convert a percent string to absolute number.
  7673. * Returns NaN if percent is not a valid string or number
  7674. */ function parsePercent(percent, all) {
  7675. switch (percent) {
  7676. case 'center':
  7677. case 'middle':
  7678. percent = '50%'
  7679. break
  7680. case 'left':
  7681. case 'top':
  7682. percent = '0%'
  7683. break
  7684. case 'right':
  7685. case 'bottom':
  7686. percent = '100%'
  7687. break
  7688. }
  7689. if (isString(percent)) {
  7690. if (_trim(percent).match(/%$/)) {
  7691. return (parseFloat(percent) / 100) * all
  7692. }
  7693. return parseFloat(percent)
  7694. }
  7695. return percent == null ? NaN : +percent
  7696. }
  7697. function round$1(x, precision, returnStr) {
  7698. if (precision == null) {
  7699. precision = 10
  7700. } // Avoid range error
  7701. precision = Math.min(
  7702. Math.max(0, precision),
  7703. ROUND_SUPPORTED_PRECISION_MAX
  7704. ) // PENDING: 1.005.toFixed(2) is '1.00' rather than '1.01'
  7705. x = (+x).toFixed(precision)
  7706. return returnStr ? x : +x
  7707. }
  7708. /**
  7709. * Inplacd asc sort arr.
  7710. * The input arr will be modified.
  7711. */ function asc$1(arr) {
  7712. arr.sort(function (a, b) {
  7713. return a - b
  7714. })
  7715. return arr
  7716. }
  7717. /**
  7718. * Get precision.
  7719. */ function getPrecision(val) {
  7720. val = +val
  7721. if (isNaN(val)) {
  7722. return 0
  7723. } // It is much faster than methods converting number to string as follows
  7724. // let tmp = val.toString();
  7725. // return tmp.length - 1 - tmp.indexOf('.');
  7726. // especially when precision is low
  7727. // Notice:
  7728. // (1) If the loop count is over about 20, it is slower than `getPrecisionSafe`.
  7729. // (see https://jsbench.me/2vkpcekkvw/1)
  7730. // (2) If the val is less than for example 1e-15, the result may be incorrect.
  7731. // (see test/ut/spec/util/number.test.ts `getPrecision_equal_random`)
  7732. if (val > 1e-14) {
  7733. var e = 1
  7734. for (var i = 0; i < 15; i++, e *= 10) {
  7735. if (Math.round(val * e) / e === val) {
  7736. return i
  7737. }
  7738. }
  7739. }
  7740. return getPrecisionSafe(val)
  7741. }
  7742. /**
  7743. * Get precision with slow but safe method
  7744. */ function getPrecisionSafe(val) {
  7745. // toLowerCase for: '3.4E-12'
  7746. var str = val.toString().toLowerCase() // Consider scientific notation: '3.4e-12' '3.4e+12'
  7747. var eIndex = str.indexOf('e')
  7748. var exp = eIndex > 0 ? +str.slice(eIndex + 1) : 0
  7749. var significandPartLen = eIndex > 0 ? eIndex : str.length
  7750. var dotIndex = str.indexOf('.')
  7751. var decimalPartLen =
  7752. dotIndex < 0 ? 0 : significandPartLen - 1 - dotIndex
  7753. return Math.max(0, decimalPartLen - exp)
  7754. }
  7755. /**
  7756. * Minimal dicernible data precisioin according to a single pixel.
  7757. */ function getPixelPrecision(dataExtent, pixelExtent) {
  7758. var log = Math.log
  7759. var LN10 = Math.LN10
  7760. var dataQuantity = Math.floor(
  7761. log(dataExtent[1] - dataExtent[0]) / LN10
  7762. )
  7763. var sizeQuantity = Math.round(
  7764. log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10
  7765. ) // toFixed() digits argument must be between 0 and 20.
  7766. var precision = Math.min(
  7767. Math.max(-dataQuantity + sizeQuantity, 0),
  7768. 20
  7769. )
  7770. return !isFinite(precision) ? 20 : precision
  7771. }
  7772. /**
  7773. * Get a data of given precision, assuring the sum of percentages
  7774. * in valueList is 1.
  7775. * The largest remainer method is used.
  7776. * https://en.wikipedia.org/wiki/Largest_remainder_method
  7777. *
  7778. * @param valueList a list of all data
  7779. * @param idx index of the data to be processed in valueList
  7780. * @param precision integer number showing digits of precision
  7781. * @return percent ranging from 0 to 100
  7782. */ function getPercentWithPrecision(valueList, idx, precision) {
  7783. if (!valueList[idx]) {
  7784. return 0
  7785. }
  7786. var sum = reduce(
  7787. valueList,
  7788. function (acc, val) {
  7789. return acc + (isNaN(val) ? 0 : val)
  7790. },
  7791. 0
  7792. )
  7793. if (sum === 0) {
  7794. return 0
  7795. }
  7796. var digits = Math.pow(10, precision)
  7797. var votesPerQuota = map$1(valueList, function (val) {
  7798. return ((isNaN(val) ? 0 : val) / sum) * digits * 100
  7799. })
  7800. var targetSeats = digits * 100
  7801. var seats = map$1(votesPerQuota, function (votes) {
  7802. // Assign automatic seats.
  7803. return Math.floor(votes)
  7804. })
  7805. var currentSum = reduce(
  7806. seats,
  7807. function (acc, val) {
  7808. return acc + val
  7809. },
  7810. 0
  7811. )
  7812. var remainder = map$1(votesPerQuota, function (votes, idx) {
  7813. return votes - seats[idx]
  7814. }) // Has remainding votes.
  7815. while (currentSum < targetSeats) {
  7816. // Find next largest remainder.
  7817. var max = Number.NEGATIVE_INFINITY
  7818. var maxId = null
  7819. for (var i = 0, len = remainder.length; i < len; ++i) {
  7820. if (remainder[i] > max) {
  7821. max = remainder[i]
  7822. maxId = i
  7823. }
  7824. } // Add a vote to max remainder.
  7825. ++seats[maxId]
  7826. remainder[maxId] = 0
  7827. ++currentSum
  7828. }
  7829. return seats[idx] / digits
  7830. }
  7831. /**
  7832. * Solve the floating point adding problem like 0.1 + 0.2 === 0.30000000000000004
  7833. * See <http://0.30000000000000004.com/>
  7834. */ function addSafe(val0, val1) {
  7835. var maxPrecision = Math.max(getPrecision(val0), getPrecision(val1)) // const multiplier = Math.pow(10, maxPrecision);
  7836. // return (Math.round(val0 * multiplier) + Math.round(val1 * multiplier)) / multiplier;
  7837. var sum = val0 + val1 // // PENDING: support more?
  7838. return maxPrecision > ROUND_SUPPORTED_PRECISION_MAX
  7839. ? sum
  7840. : round$1(sum, maxPrecision)
  7841. } // Number.MAX_SAFE_INTEGER, ie do not support.
  7842. /**
  7843. * To 0 - 2 * PI, considering negative radian.
  7844. */ function remRadian(radian) {
  7845. var pi2 = Math.PI * 2
  7846. return ((radian % pi2) + pi2) % pi2
  7847. }
  7848. /**
  7849. * @param {type} radian
  7850. * @return {boolean}
  7851. */ function isRadianAroundZero(val) {
  7852. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON
  7853. } // eslint-disable-next-line
  7854. var TIME_REG =
  7855. /^(?:(\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
  7856. /**
  7857. * @param value valid type: number | string | Date, otherwise return `new Date(NaN)`
  7858. * These values can be accepted:
  7859. * + An instance of Date, represent a time in its own time zone.
  7860. * + Or string in a subset of ISO 8601, only including:
  7861. * + only year, month, date: '2012-03', '2012-03-01', '2012-03-01 05', '2012-03-01 05:06',
  7862. * + separated with T or space: '2012-03-01T12:22:33.123', '2012-03-01 12:22:33.123',
  7863. * + time zone: '2012-03-01T12:22:33Z', '2012-03-01T12:22:33+8000', '2012-03-01T12:22:33-05:00',
  7864. * all of which will be treated as local time if time zone is not specified
  7865. * (see <https://momentjs.com/>).
  7866. * + Or other string format, including (all of which will be treated as loacal time):
  7867. * '2012', '2012-3-1', '2012/3/1', '2012/03/01',
  7868. * '2009/6/12 2:00', '2009/6/12 2:05:08', '2009/6/12 2:05:08.123'
  7869. * + a timestamp, which represent a time in UTC.
  7870. * @return date Never be null/undefined. If invalid, return `new Date(NaN)`.
  7871. */ function parseDate(value) {
  7872. if (value instanceof Date) {
  7873. return value
  7874. } else if (isString(value)) {
  7875. // Different browsers parse date in different way, so we parse it manually.
  7876. // Some other issues:
  7877. // new Date('1970-01-01') is UTC,
  7878. // new Date('1970/01/01') and new Date('1970-1-01') is local.
  7879. // See issue #3623
  7880. var match = TIME_REG.exec(value)
  7881. if (!match) {
  7882. // return Invalid Date.
  7883. return new Date(NaN)
  7884. } // Use local time when no timezone offset specifed.
  7885. if (!match[8]) {
  7886. // match[n] can only be string or undefined.
  7887. // But take care of '12' + 1 => '121'.
  7888. return new Date(
  7889. +match[1],
  7890. +(match[2] || 1) - 1,
  7891. +match[3] || 1,
  7892. +match[4] || 0,
  7893. +(match[5] || 0),
  7894. +match[6] || 0,
  7895. match[7] ? +match[7].substring(0, 3) : 0
  7896. )
  7897. } // Timezoneoffset of Javascript Date has considered DST (Daylight Saving Time,
  7898. // https://tc39.github.io/ecma262/#sec-daylight-saving-time-adjustment).
  7899. // For example, system timezone is set as "Time Zone: America/Toronto",
  7900. // then these code will get different result:
  7901. // `new Date(1478411999999).getTimezoneOffset(); // get 240`
  7902. // `new Date(1478412000000).getTimezoneOffset(); // get 300`
  7903. // So we should not use `new Date`, but use `Date.UTC`.
  7904. else {
  7905. var hour = +match[4] || 0
  7906. if (match[8].toUpperCase() !== 'Z') {
  7907. hour -= +match[8].slice(0, 3)
  7908. }
  7909. return new Date(
  7910. Date.UTC(
  7911. +match[1],
  7912. +(match[2] || 1) - 1,
  7913. +match[3] || 1,
  7914. hour,
  7915. +(match[5] || 0),
  7916. +match[6] || 0,
  7917. match[7] ? +match[7].substring(0, 3) : 0
  7918. )
  7919. )
  7920. }
  7921. } else if (value == null) {
  7922. return new Date(NaN)
  7923. }
  7924. return new Date(Math.round(value))
  7925. }
  7926. /**
  7927. * Quantity of a number. e.g. 0.1, 1, 10, 100
  7928. *
  7929. * @param val
  7930. * @return
  7931. */ function quantity(val) {
  7932. return Math.pow(10, quantityExponent(val))
  7933. }
  7934. /**
  7935. * Exponent of the quantity of a number
  7936. * e.g., 1234 equals to 1.234*10^3, so quantityExponent(1234) is 3
  7937. *
  7938. * @param val non-negative value
  7939. * @return
  7940. */ function quantityExponent(val) {
  7941. if (val === 0) {
  7942. return 0
  7943. }
  7944. var exp = Math.floor(Math.log(val) / Math.LN10)
  7945. /**
  7946. * exp is expected to be the rounded-down result of the base-10 log of val.
  7947. * But due to the precision loss with Math.log(val), we need to restore it
  7948. * using 10^exp to make sure we can get val back from exp. #11249
  7949. */ if (val / Math.pow(10, exp) >= 10) {
  7950. exp++
  7951. }
  7952. return exp
  7953. }
  7954. /**
  7955. * find a “nice” number approximately equal to x. Round the number if round = true,
  7956. * take ceiling if round = false. The primary observation is that the “nicest”
  7957. * numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  7958. *
  7959. * See "Nice Numbers for Graph Labels" of Graphic Gems.
  7960. *
  7961. * @param val Non-negative value.
  7962. * @param round
  7963. * @return Niced number
  7964. */ function nice(val, round) {
  7965. var exponent = quantityExponent(val)
  7966. var exp10 = Math.pow(10, exponent)
  7967. var f = val / exp10 // 1 <= f < 10
  7968. var nf
  7969. if (round) {
  7970. if (f < 1.5) {
  7971. nf = 1
  7972. } else if (f < 2.5) {
  7973. nf = 2
  7974. } else if (f < 4) {
  7975. nf = 3
  7976. } else if (f < 7) {
  7977. nf = 5
  7978. } else {
  7979. nf = 10
  7980. }
  7981. } else {
  7982. if (f < 1) {
  7983. nf = 1
  7984. } else if (f < 2) {
  7985. nf = 2
  7986. } else if (f < 3) {
  7987. nf = 3
  7988. } else if (f < 5) {
  7989. nf = 5
  7990. } else {
  7991. nf = 10
  7992. }
  7993. }
  7994. val = nf * exp10 // Fix 3 * 0.1 === 0.30000000000000004 issue (see IEEE 754).
  7995. // 20 is the uppper bound of toFixed.
  7996. return exponent >= -20
  7997. ? +val.toFixed(exponent < 0 ? -exponent : 0)
  7998. : val
  7999. }
  8000. /**
  8001. * [Numberic is defined as]:
  8002. * `parseFloat(val) == val`
  8003. * For example:
  8004. * numeric:
  8005. * typeof number except NaN, '-123', '123', '2e3', '-2e3', '011', 'Infinity', Infinity,
  8006. * and they rounded by white-spaces or line-terminal like ' -123 \n ' (see es spec)
  8007. * not-numeric:
  8008. * null, undefined, [], {}, true, false, 'NaN', NaN, '123ab',
  8009. * empty string, string with only white-spaces or line-terminal (see es spec),
  8010. * 0x12, '0x12', '-0x12', 012, '012', '-012',
  8011. * non-string, ...
  8012. *
  8013. * @test See full test cases in `test/ut/spec/util/number.js`.
  8014. * @return Must be a typeof number. If not numeric, return NaN.
  8015. */ function numericToNumber(val) {
  8016. var valFloat = parseFloat(val)
  8017. return valFloat == val && // eslint-disable-line eqeqeq
  8018. (valFloat !== 0 || !isString(val) || val.indexOf('x') <= 0) // For case ' 0x0 '.
  8019. ? valFloat
  8020. : NaN
  8021. }
  8022. /**
  8023. * Definition of "numeric": see `numericToNumber`.
  8024. */ function isNumeric(val) {
  8025. return !isNaN(numericToNumber(val))
  8026. }
  8027. /**
  8028. * Use random base to prevent users hard code depending on
  8029. * this auto generated marker id.
  8030. * @return An positive integer.
  8031. */ function getRandomIdBase() {
  8032. return Math.round(Math.random() * 9)
  8033. }
  8034. /**
  8035. * Get the greatest common dividor
  8036. *
  8037. * @param {number} a one number
  8038. * @param {number} b the other number
  8039. */ function getGreatestCommonDividor(a, b) {
  8040. if (b === 0) {
  8041. return a
  8042. }
  8043. return getGreatestCommonDividor(b, a % b)
  8044. }
  8045. /**
  8046. * Get the least common multiple
  8047. *
  8048. * @param {number} a one number
  8049. * @param {number} b the other number
  8050. */ function getLeastCommonMultiple(a, b) {
  8051. if (a == null) {
  8052. return b
  8053. }
  8054. if (b == null) {
  8055. return a
  8056. }
  8057. return (a * b) / getGreatestCommonDividor(a, b)
  8058. }
  8059. /**
  8060. * @throws Error
  8061. */ function throwError(msg) {
  8062. throw new Error(msg)
  8063. }
  8064. function interpolateNumber(p0, p1, percent) {
  8065. return (p1 - p0) * percent + p0
  8066. }
  8067. /**
  8068. * Make the name displayable. But we should
  8069. * make sure it is not duplicated with user
  8070. * specified name, so use '\0';
  8071. */ var DUMMY_COMPONENT_NAME_PREFIX = 'series\0'
  8072. var INTERNAL_COMPONENT_ID_PREFIX = '\0_ec_\0'
  8073. /**
  8074. * If value is not array, then translate it to array.
  8075. * @param {*} value
  8076. * @return {Array} [value] or value
  8077. */ function normalizeToArray(value) {
  8078. return value instanceof Array ? value : value == null ? [] : [value]
  8079. }
  8080. /**
  8081. * Sync default option between normal and emphasis like `position` and `show`
  8082. * In case some one will write code like
  8083. * label: {
  8084. * show: false,
  8085. * position: 'outside',
  8086. * fontSize: 18
  8087. * },
  8088. * emphasis: {
  8089. * label: { show: true }
  8090. * }
  8091. */ function defaultEmphasis(opt, key, subOpts) {
  8092. // Caution: performance sensitive.
  8093. if (opt) {
  8094. opt[key] = opt[key] || {}
  8095. opt.emphasis = opt.emphasis || {}
  8096. opt.emphasis[key] = opt.emphasis[key] || {} // Default emphasis option from normal
  8097. for (var i = 0, len = subOpts.length; i < len; i++) {
  8098. var subOptName = subOpts[i]
  8099. if (
  8100. !opt.emphasis[key].hasOwnProperty(subOptName) &&
  8101. opt[key].hasOwnProperty(subOptName)
  8102. ) {
  8103. opt.emphasis[key][subOptName] = opt[key][subOptName]
  8104. }
  8105. }
  8106. }
  8107. }
  8108. var TEXT_STYLE_OPTIONS = [
  8109. 'fontStyle',
  8110. 'fontWeight',
  8111. 'fontSize',
  8112. 'fontFamily',
  8113. 'rich',
  8114. 'tag',
  8115. 'color',
  8116. 'textBorderColor',
  8117. 'textBorderWidth',
  8118. 'width',
  8119. 'height',
  8120. 'lineHeight',
  8121. 'align',
  8122. 'verticalAlign',
  8123. 'baseline',
  8124. 'shadowColor',
  8125. 'shadowBlur',
  8126. 'shadowOffsetX',
  8127. 'shadowOffsetY',
  8128. 'textShadowColor',
  8129. 'textShadowBlur',
  8130. 'textShadowOffsetX',
  8131. 'textShadowOffsetY',
  8132. 'backgroundColor',
  8133. 'borderColor',
  8134. 'borderWidth',
  8135. 'borderRadius',
  8136. 'padding'
  8137. ] // modelUtil.LABEL_OPTIONS = modelUtil.TEXT_STYLE_OPTIONS.concat([
  8138. // 'position', 'offset', 'rotate', 'origin', 'show', 'distance', 'formatter',
  8139. // 'fontStyle', 'fontWeight', 'fontSize', 'fontFamily',
  8140. // // FIXME: deprecated, check and remove it.
  8141. // 'textStyle'
  8142. // ]);
  8143. /**
  8144. * The method do not ensure performance.
  8145. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  8146. * This helper method retieves value from data.
  8147. */ function getDataItemValue(dataItem) {
  8148. return isObject$2(dataItem) &&
  8149. !isArray(dataItem) &&
  8150. !(dataItem instanceof Date)
  8151. ? dataItem.value
  8152. : dataItem
  8153. }
  8154. /**
  8155. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  8156. * This helper method determine if dataItem has extra option besides value
  8157. */ function isDataItemOption(dataItem) {
  8158. return isObject$2(dataItem) && !(dataItem instanceof Array) // // markLine data can be array
  8159. // && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  8160. }
  8161. /**
  8162. * Mapping to existings for merge.
  8163. *
  8164. * Mode "normalMege":
  8165. * The mapping result (merge result) will keep the order of the existing
  8166. * component, rather than the order of new option. Because we should ensure
  8167. * some specified index reference (like xAxisIndex) keep work.
  8168. * And in most cases, "merge option" is used to update partial option but not
  8169. * be expected to change the order.
  8170. *
  8171. * Mode "replaceMege":
  8172. * (1) Only the id mapped components will be merged.
  8173. * (2) Other existing components (except internal compoonets) will be removed.
  8174. * (3) Other new options will be used to create new component.
  8175. * (4) The index of the existing compoents will not be modified.
  8176. * That means their might be "hole" after the removal.
  8177. * The new components are created first at those available index.
  8178. *
  8179. * Mode "replaceAll":
  8180. * This mode try to support that reproduce an echarts instance from another
  8181. * echarts instance (via `getOption`) in some simple cases.
  8182. * In this senario, the `result` index are exactly the consistent with the `newCmptOptions`,
  8183. * which ensures the compoennt index referring (like `xAxisIndex: ?`) corrent. That is,
  8184. * the "hole" in `newCmptOptions` will also be kept.
  8185. * On the contrary, other modes try best to eliminate holes.
  8186. * PENDING: This is an experimental mode yet.
  8187. *
  8188. * @return See the comment of <MappingResult>.
  8189. */ function mappingToExists(existings, newCmptOptions, mode) {
  8190. var isNormalMergeMode = mode === 'normalMerge'
  8191. var isReplaceMergeMode = mode === 'replaceMerge'
  8192. var isReplaceAllMode = mode === 'replaceAll'
  8193. existings = existings || []
  8194. newCmptOptions = (newCmptOptions || []).slice()
  8195. var existingIdIdxMap = createHashMap() // Validate id and name on user input option.
  8196. each$7(newCmptOptions, function (cmptOption, index) {
  8197. if (!isObject$2(cmptOption)) {
  8198. newCmptOptions[index] = null
  8199. return
  8200. }
  8201. })
  8202. var result = prepareResult(existings, existingIdIdxMap, mode)
  8203. if (isNormalMergeMode || isReplaceMergeMode) {
  8204. mappingById(result, existings, existingIdIdxMap, newCmptOptions)
  8205. }
  8206. if (isNormalMergeMode) {
  8207. mappingByName(result, newCmptOptions)
  8208. }
  8209. if (isNormalMergeMode || isReplaceMergeMode) {
  8210. mappingByIndex(result, newCmptOptions, isReplaceMergeMode)
  8211. } else if (isReplaceAllMode) {
  8212. mappingInReplaceAllMode(result, newCmptOptions)
  8213. }
  8214. makeIdAndName(result) // The array `result` MUST NOT contain elided items, otherwise the
  8215. // forEach will ommit those items and result in incorrect result.
  8216. return result
  8217. }
  8218. function prepareResult(existings, existingIdIdxMap, mode) {
  8219. var result = []
  8220. if (mode === 'replaceAll') {
  8221. return result
  8222. } // Do not use native `map` to in case that the array `existings`
  8223. // contains elided items, which will be ommited.
  8224. for (var index = 0; index < existings.length; index++) {
  8225. var existing = existings[index] // Because of replaceMerge, `existing` may be null/undefined.
  8226. if (existing && existing.id != null) {
  8227. existingIdIdxMap.set(existing.id, index)
  8228. } // For non-internal-componnets:
  8229. // Mode "normalMerge": all existings kept.
  8230. // Mode "replaceMerge": all existing removed unless mapped by id.
  8231. // For internal-components:
  8232. // go with "replaceMerge" approach in both mode.
  8233. result.push({
  8234. existing:
  8235. mode === 'replaceMerge' || isComponentIdInternal(existing)
  8236. ? null
  8237. : existing,
  8238. newOption: null,
  8239. keyInfo: null,
  8240. brandNew: null
  8241. })
  8242. }
  8243. return result
  8244. }
  8245. function mappingById(
  8246. result,
  8247. existings,
  8248. existingIdIdxMap,
  8249. newCmptOptions
  8250. ) {
  8251. // Mapping by id if specified.
  8252. each$7(newCmptOptions, function (cmptOption, index) {
  8253. if (!cmptOption || cmptOption.id == null) {
  8254. return
  8255. }
  8256. var optionId = makeComparableKey(cmptOption.id)
  8257. var existingIdx = existingIdIdxMap.get(optionId)
  8258. if (existingIdx != null) {
  8259. var resultItem = result[existingIdx]
  8260. assert(
  8261. !resultItem.newOption,
  8262. 'Duplicated option on id "' + optionId + '".'
  8263. )
  8264. resultItem.newOption = cmptOption // In both mode, if id matched, new option will be merged to
  8265. // the existings rather than creating new component model.
  8266. resultItem.existing = existings[existingIdx]
  8267. newCmptOptions[index] = null
  8268. }
  8269. })
  8270. }
  8271. function mappingByName(result, newCmptOptions) {
  8272. // Mapping by name if specified.
  8273. each$7(newCmptOptions, function (cmptOption, index) {
  8274. if (!cmptOption || cmptOption.name == null) {
  8275. return
  8276. }
  8277. for (var i = 0; i < result.length; i++) {
  8278. var existing = result[i].existing
  8279. if (
  8280. !result[i].newOption && // Consider name: two map to one.
  8281. // Can not match when both ids existing but different.
  8282. existing &&
  8283. (existing.id == null || cmptOption.id == null) &&
  8284. !isComponentIdInternal(cmptOption) &&
  8285. !isComponentIdInternal(existing) &&
  8286. keyExistAndEqual('name', existing, cmptOption)
  8287. ) {
  8288. result[i].newOption = cmptOption
  8289. newCmptOptions[index] = null
  8290. return
  8291. }
  8292. }
  8293. })
  8294. }
  8295. function mappingByIndex(result, newCmptOptions, brandNew) {
  8296. each$7(newCmptOptions, function (cmptOption) {
  8297. if (!cmptOption) {
  8298. return
  8299. } // Find the first place that not mapped by id and not internal component (consider the "hole").
  8300. var resultItem
  8301. var nextIdx = 0
  8302. while (
  8303. // Be `!resultItem` only when `nextIdx >= result.length`.
  8304. (resultItem = result[nextIdx]) && // (1) Existing models that already have id should be able to mapped to. Because
  8305. // after mapping performed, model will always be assigned with an id if user not given.
  8306. // After that all models have id.
  8307. // (2) If new option has id, it can only set to a hole or append to the last. It should
  8308. // not be merged to the existings with different id. Because id should not be overwritten.
  8309. // (3) Name can be overwritten, because axis use name as 'show label text'.
  8310. (resultItem.newOption ||
  8311. isComponentIdInternal(resultItem.existing) || // In mode "replaceMerge", here no not-mapped-non-internal-existing.
  8312. (resultItem.existing &&
  8313. cmptOption.id != null &&
  8314. !keyExistAndEqual('id', cmptOption, resultItem.existing)))
  8315. ) {
  8316. nextIdx++
  8317. }
  8318. if (resultItem) {
  8319. resultItem.newOption = cmptOption
  8320. resultItem.brandNew = brandNew
  8321. } else {
  8322. result.push({
  8323. newOption: cmptOption,
  8324. brandNew: brandNew,
  8325. existing: null,
  8326. keyInfo: null
  8327. })
  8328. }
  8329. nextIdx++
  8330. })
  8331. }
  8332. function mappingInReplaceAllMode(result, newCmptOptions) {
  8333. each$7(newCmptOptions, function (cmptOption) {
  8334. // The feature "reproduce" requires "hole" will also reproduced
  8335. // in case that compoennt index referring are broken.
  8336. result.push({
  8337. newOption: cmptOption,
  8338. brandNew: true,
  8339. existing: null,
  8340. keyInfo: null
  8341. })
  8342. })
  8343. }
  8344. /**
  8345. * Make id and name for mapping result (result of mappingToExists)
  8346. * into `keyInfo` field.
  8347. */ function makeIdAndName(mapResult) {
  8348. // We use this id to hash component models and view instances
  8349. // in echarts. id can be specified by user, or auto generated.
  8350. // The id generation rule ensures new view instance are able
  8351. // to mapped to old instance when setOption are called in
  8352. // no-merge mode. So we generate model id by name and plus
  8353. // type in view id.
  8354. // name can be duplicated among components, which is convenient
  8355. // to specify multi components (like series) by one name.
  8356. // Ensure that each id is distinct.
  8357. var idMap = createHashMap()
  8358. each$7(mapResult, function (item) {
  8359. var existing = item.existing
  8360. existing && idMap.set(existing.id, item)
  8361. })
  8362. each$7(mapResult, function (item) {
  8363. var opt = item.newOption // Force ensure id not duplicated.
  8364. assert(
  8365. !opt ||
  8366. opt.id == null ||
  8367. !idMap.get(opt.id) ||
  8368. idMap.get(opt.id) === item,
  8369. 'id duplicates: ' + (opt && opt.id)
  8370. )
  8371. opt && opt.id != null && idMap.set(opt.id, item)
  8372. !item.keyInfo && (item.keyInfo = {})
  8373. }) // Make name and id.
  8374. each$7(mapResult, function (item, index) {
  8375. var existing = item.existing
  8376. var opt = item.newOption
  8377. var keyInfo = item.keyInfo
  8378. if (!isObject$2(opt)) {
  8379. return
  8380. } // name can be overwitten. Consider case: axis.name = '20km'.
  8381. // But id generated by name will not be changed, which affect
  8382. // only in that case: setOption with 'not merge mode' and view
  8383. // instance will be recreated, which can be accepted.
  8384. keyInfo.name =
  8385. opt.name != null
  8386. ? makeComparableKey(opt.name)
  8387. : existing
  8388. ? existing.name // Avoid diffferent series has the same name,
  8389. : // because name may be used like in color pallet.
  8390. DUMMY_COMPONENT_NAME_PREFIX + index
  8391. if (existing) {
  8392. keyInfo.id = makeComparableKey(existing.id)
  8393. } else if (opt.id != null) {
  8394. keyInfo.id = makeComparableKey(opt.id)
  8395. } else {
  8396. // Consider this situatoin:
  8397. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  8398. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  8399. // Series with the same name between optionA and optionB
  8400. // should be mapped.
  8401. var idNum = 0
  8402. do {
  8403. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++
  8404. } while (idMap.get(keyInfo.id))
  8405. }
  8406. idMap.set(keyInfo.id, item)
  8407. })
  8408. }
  8409. function keyExistAndEqual(attr, obj1, obj2) {
  8410. var key1 = convertOptionIdName(obj1[attr], null)
  8411. var key2 = convertOptionIdName(obj2[attr], null) // See `MappingExistingItem`. `id` and `name` trade string equals to number.
  8412. return key1 != null && key2 != null && key1 === key2
  8413. }
  8414. /**
  8415. * @return return null if not exist.
  8416. */ function makeComparableKey(val) {
  8417. return convertOptionIdName(val, '')
  8418. }
  8419. function convertOptionIdName(idOrName, defaultValue) {
  8420. if (idOrName == null) {
  8421. return defaultValue
  8422. }
  8423. return isString(idOrName)
  8424. ? idOrName
  8425. : isNumber(idOrName) || isStringSafe(idOrName)
  8426. ? idOrName + ''
  8427. : defaultValue
  8428. }
  8429. function isNameSpecified(componentModel) {
  8430. var name = componentModel.name // Is specified when `indexOf` get -1 or > 0.
  8431. return !!(name && name.indexOf(DUMMY_COMPONENT_NAME_PREFIX))
  8432. }
  8433. /**
  8434. * @public
  8435. * @param {Object} cmptOption
  8436. * @return {boolean}
  8437. */ function isComponentIdInternal(cmptOption) {
  8438. return (
  8439. cmptOption &&
  8440. cmptOption.id != null &&
  8441. makeComparableKey(cmptOption.id).indexOf(
  8442. INTERNAL_COMPONENT_ID_PREFIX
  8443. ) === 0
  8444. )
  8445. }
  8446. function makeInternalComponentId(idSuffix) {
  8447. return INTERNAL_COMPONENT_ID_PREFIX + idSuffix
  8448. }
  8449. function setComponentTypeToKeyInfo(
  8450. mappingResult,
  8451. mainType,
  8452. componentModelCtor
  8453. ) {
  8454. // Set mainType and complete subType.
  8455. each$7(mappingResult, function (item) {
  8456. var newOption = item.newOption
  8457. if (isObject$2(newOption)) {
  8458. item.keyInfo.mainType = mainType
  8459. item.keyInfo.subType = determineSubType(
  8460. mainType,
  8461. newOption,
  8462. item.existing,
  8463. componentModelCtor
  8464. )
  8465. }
  8466. })
  8467. }
  8468. function determineSubType(
  8469. mainType,
  8470. newCmptOption,
  8471. existComponent,
  8472. componentModelCtor
  8473. ) {
  8474. var subType = newCmptOption.type
  8475. ? newCmptOption.type
  8476. : existComponent
  8477. ? existComponent.subType // Use determineSubType only when there is no existComponent.
  8478. : componentModelCtor.determineSubType(mainType, newCmptOption) // tooltip, markline, markpoint may always has no subType
  8479. return subType
  8480. }
  8481. /**
  8482. * @param payload Contains dataIndex (means rawIndex) / dataIndexInside / name
  8483. * each of which can be Array or primary type.
  8484. * @return dataIndex If not found, return undefined/null.
  8485. */ function queryDataIndex(data, payload) {
  8486. if (payload.dataIndexInside != null) {
  8487. return payload.dataIndexInside
  8488. } else if (payload.dataIndex != null) {
  8489. return isArray(payload.dataIndex)
  8490. ? map$1(payload.dataIndex, function (value) {
  8491. return data.indexOfRawIndex(value)
  8492. })
  8493. : data.indexOfRawIndex(payload.dataIndex)
  8494. } else if (payload.name != null) {
  8495. return isArray(payload.name)
  8496. ? map$1(payload.name, function (value) {
  8497. return data.indexOfName(value)
  8498. })
  8499. : data.indexOfName(payload.name)
  8500. }
  8501. }
  8502. /**
  8503. * Enable property storage to any host object.
  8504. * Notice: Serialization is not supported.
  8505. *
  8506. * For example:
  8507. * let inner = zrUitl.makeInner();
  8508. *
  8509. * function some1(hostObj) {
  8510. * inner(hostObj).someProperty = 1212;
  8511. * ...
  8512. * }
  8513. * function some2() {
  8514. * let fields = inner(this);
  8515. * fields.someProperty1 = 1212;
  8516. * fields.someProperty2 = 'xx';
  8517. * ...
  8518. * }
  8519. *
  8520. * @return {Function}
  8521. */ function makeInner() {
  8522. var key = '__ec_inner_' + innerUniqueIndex++
  8523. return function (hostObj) {
  8524. return hostObj[key] || (hostObj[key] = {})
  8525. }
  8526. }
  8527. var innerUniqueIndex = getRandomIdBase()
  8528. /**
  8529. * The same behavior as `component.getReferringComponents`.
  8530. */ function parseFinder$1(ecModel, finderInput, opt) {
  8531. var _a = preParseFinder(finderInput, opt),
  8532. mainTypeSpecified = _a.mainTypeSpecified,
  8533. queryOptionMap = _a.queryOptionMap,
  8534. others = _a.others
  8535. var result = others
  8536. var defaultMainType = opt ? opt.defaultMainType : null
  8537. if (!mainTypeSpecified && defaultMainType) {
  8538. queryOptionMap.set(defaultMainType, {})
  8539. }
  8540. queryOptionMap.each(function (queryOption, mainType) {
  8541. var queryResult = queryReferringComponents(
  8542. ecModel,
  8543. mainType,
  8544. queryOption,
  8545. {
  8546. useDefault: defaultMainType === mainType,
  8547. enableAll:
  8548. opt && opt.enableAll != null ? opt.enableAll : true,
  8549. enableNone:
  8550. opt && opt.enableNone != null ? opt.enableNone : true
  8551. }
  8552. )
  8553. result[mainType + 'Models'] = queryResult.models
  8554. result[mainType + 'Model'] = queryResult.models[0]
  8555. })
  8556. return result
  8557. }
  8558. function preParseFinder(finderInput, opt) {
  8559. var finder
  8560. if (isString(finderInput)) {
  8561. var obj = {}
  8562. obj[finderInput + 'Index'] = 0
  8563. finder = obj
  8564. } else {
  8565. finder = finderInput
  8566. }
  8567. var queryOptionMap = createHashMap()
  8568. var others = {}
  8569. var mainTypeSpecified = false
  8570. each$7(finder, function (value, key) {
  8571. // Exclude 'dataIndex' and other illgal keys.
  8572. if (key === 'dataIndex' || key === 'dataIndexInside') {
  8573. others[key] = value
  8574. return
  8575. }
  8576. var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || []
  8577. var mainType = parsedKey[1]
  8578. var queryType = (parsedKey[2] || '').toLowerCase()
  8579. if (
  8580. !mainType ||
  8581. !queryType ||
  8582. (opt &&
  8583. opt.includeMainTypes &&
  8584. indexOf(opt.includeMainTypes, mainType) < 0)
  8585. ) {
  8586. return
  8587. }
  8588. mainTypeSpecified = mainTypeSpecified || !!mainType
  8589. var queryOption =
  8590. queryOptionMap.get(mainType) || queryOptionMap.set(mainType, {})
  8591. queryOption[queryType] = value
  8592. })
  8593. return {
  8594. mainTypeSpecified: mainTypeSpecified,
  8595. queryOptionMap: queryOptionMap,
  8596. others: others
  8597. }
  8598. }
  8599. var SINGLE_REFERRING = {
  8600. useDefault: true,
  8601. enableAll: false,
  8602. enableNone: false
  8603. }
  8604. var MULTIPLE_REFERRING = {
  8605. useDefault: false,
  8606. enableAll: true,
  8607. enableNone: true
  8608. }
  8609. function queryReferringComponents(
  8610. ecModel,
  8611. mainType,
  8612. userOption,
  8613. opt
  8614. ) {
  8615. opt = opt || SINGLE_REFERRING
  8616. var indexOption = userOption.index
  8617. var idOption = userOption.id
  8618. var nameOption = userOption.name
  8619. var result = {
  8620. models: null,
  8621. specified:
  8622. indexOption != null || idOption != null || nameOption != null
  8623. }
  8624. if (!result.specified) {
  8625. // Use the first as default if `useDefault`.
  8626. var firstCmpt = void 0
  8627. result.models =
  8628. opt.useDefault && (firstCmpt = ecModel.getComponent(mainType))
  8629. ? [firstCmpt]
  8630. : []
  8631. return result
  8632. }
  8633. if (indexOption === 'none' || indexOption === false) {
  8634. assert(
  8635. opt.enableNone,
  8636. '`"none"` or `false` is not a valid value on index option.'
  8637. )
  8638. result.models = []
  8639. return result
  8640. } // `queryComponents` will return all components if
  8641. // both all of index/id/name are null/undefined.
  8642. if (indexOption === 'all') {
  8643. assert(
  8644. opt.enableAll,
  8645. '`"all"` is not a valid value on index option.'
  8646. )
  8647. indexOption = idOption = nameOption = null
  8648. }
  8649. result.models = ecModel.queryComponents({
  8650. mainType: mainType,
  8651. index: indexOption,
  8652. id: idOption,
  8653. name: nameOption
  8654. })
  8655. return result
  8656. }
  8657. function setAttribute(dom, key, value) {
  8658. dom.setAttribute ? dom.setAttribute(key, value) : (dom[key] = value)
  8659. }
  8660. function getAttribute(dom, key) {
  8661. return dom.getAttribute ? dom.getAttribute(key) : dom[key]
  8662. }
  8663. function getTooltipRenderMode(renderModeOption) {
  8664. if (renderModeOption === 'auto') {
  8665. // Using html when `document` exists, use richText otherwise
  8666. return env$1.domSupported ? 'html' : 'richText'
  8667. } else {
  8668. return renderModeOption || 'html'
  8669. }
  8670. }
  8671. /**
  8672. * Interpolate raw values of a series with percent
  8673. *
  8674. * @param data data
  8675. * @param labelModel label model of the text element
  8676. * @param sourceValue start value. May be null/undefined when init.
  8677. * @param targetValue end value
  8678. * @param percent 0~1 percentage; 0 uses start value while 1 uses end value
  8679. * @return interpolated values
  8680. * If `sourceValue` and `targetValue` are `number`, return `number`.
  8681. * If `sourceValue` and `targetValue` are `string`, return `string`.
  8682. * If `sourceValue` and `targetValue` are `(string | number)[]`, return `(string | number)[]`.
  8683. * Other cases do not supported.
  8684. */ function interpolateRawValues(
  8685. data,
  8686. precision,
  8687. sourceValue,
  8688. targetValue,
  8689. percent
  8690. ) {
  8691. var isAutoPrecision = precision == null || precision === 'auto'
  8692. if (targetValue == null) {
  8693. return targetValue
  8694. }
  8695. if (isNumber(targetValue)) {
  8696. var value = interpolateNumber(
  8697. sourceValue || 0,
  8698. targetValue,
  8699. percent
  8700. )
  8701. return round$1(
  8702. value,
  8703. isAutoPrecision
  8704. ? Math.max(
  8705. getPrecision(sourceValue || 0),
  8706. getPrecision(targetValue)
  8707. )
  8708. : precision
  8709. )
  8710. } else if (isString(targetValue)) {
  8711. return percent < 1 ? sourceValue : targetValue
  8712. } else {
  8713. var interpolated = []
  8714. var leftArr = sourceValue
  8715. var rightArr = targetValue
  8716. var length_1 = Math.max(
  8717. leftArr ? leftArr.length : 0,
  8718. rightArr.length
  8719. )
  8720. for (var i = 0; i < length_1; ++i) {
  8721. var info = data.getDimensionInfo(i) // Don't interpolate ordinal dims
  8722. if (info && info.type === 'ordinal') {
  8723. // In init, there is no `sourceValue`, but should better not to get undefined result.
  8724. interpolated[i] = (
  8725. percent < 1 && leftArr ? leftArr : rightArr
  8726. )[i]
  8727. } else {
  8728. var leftVal = leftArr && leftArr[i] ? leftArr[i] : 0
  8729. var rightVal = rightArr[i]
  8730. var value = interpolateNumber(leftVal, rightVal, percent)
  8731. interpolated[i] = round$1(
  8732. value,
  8733. isAutoPrecision
  8734. ? Math.max(getPrecision(leftVal), getPrecision(rightVal))
  8735. : precision
  8736. )
  8737. }
  8738. }
  8739. return interpolated
  8740. }
  8741. }
  8742. var TYPE_DELIMITER = '.'
  8743. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___'
  8744. var IS_EXTENDED_CLASS = '___EC__EXTENDED_CLASS___'
  8745. /**
  8746. * Notice, parseClassType('') should returns {main: '', sub: ''}
  8747. * @public
  8748. */ function parseClassType(componentType) {
  8749. var ret = { main: '', sub: '' }
  8750. if (componentType) {
  8751. var typeArr = componentType.split(TYPE_DELIMITER)
  8752. ret.main = typeArr[0] || ''
  8753. ret.sub = typeArr[1] || ''
  8754. }
  8755. return ret
  8756. }
  8757. /**
  8758. * @public
  8759. */ function checkClassType(componentType) {
  8760. assert(
  8761. /^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType),
  8762. 'componentType "' + componentType + '" illegal'
  8763. )
  8764. }
  8765. function isExtendedClass(clz) {
  8766. return !!(clz && clz[IS_EXTENDED_CLASS])
  8767. }
  8768. /**
  8769. * Implements `ExtendableConstructor` for `rootClz`.
  8770. *
  8771. * @usage
  8772. * ```ts
  8773. * class Xxx {}
  8774. * type XxxConstructor = typeof Xxx & ExtendableConstructor
  8775. * enableClassExtend(Xxx as XxxConstructor);
  8776. * ```
  8777. */ function enableClassExtend(rootClz, mandatoryMethods) {
  8778. rootClz.$constructor = rootClz // FIXME: not necessary?
  8779. rootClz.extend = function (proto) {
  8780. var superClass = this
  8781. var ExtendedClass
  8782. if (isESClass(superClass)) {
  8783. ExtendedClass = /** @class */ (function (_super) {
  8784. __extends(class_1, _super)
  8785. function class_1() {
  8786. return _super.apply(this, arguments) || this
  8787. }
  8788. return class_1
  8789. })(superClass)
  8790. } else {
  8791. // For backward compat, we both support ts class inheritance and this
  8792. // "extend" approach.
  8793. // The constructor should keep the same behavior as ts class inheritance:
  8794. // If this constructor/$constructor is not declared, auto invoke the super
  8795. // constructor.
  8796. // If this constructor/$constructor is declared, it is responsible for
  8797. // calling the super constructor.
  8798. ExtendedClass = function ExtendedClass() {
  8799. ;(proto.$constructor || superClass).apply(this, arguments)
  8800. }
  8801. inherits(ExtendedClass, this)
  8802. }
  8803. extend(ExtendedClass.prototype, proto)
  8804. ExtendedClass[IS_EXTENDED_CLASS] = true
  8805. ExtendedClass.extend = this.extend
  8806. ExtendedClass.superCall = superCall
  8807. ExtendedClass.superApply = superApply
  8808. ExtendedClass.superClass = superClass
  8809. return ExtendedClass
  8810. }
  8811. }
  8812. function isESClass(fn) {
  8813. return (
  8814. isFunction(fn) &&
  8815. /^class\s/.test(Function.prototype.toString.call(fn))
  8816. )
  8817. }
  8818. /**
  8819. * A work around to both support ts extend and this extend mechanism.
  8820. * on sub-class.
  8821. * @usage
  8822. * ```ts
  8823. * class Component { ... }
  8824. * classUtil.enableClassExtend(Component);
  8825. * classUtil.enableClassManagement(Component, {registerWhenExtend: true});
  8826. *
  8827. * class Series extends Component { ... }
  8828. * // Without calling `markExtend`, `registerWhenExtend` will not work.
  8829. * Component.markExtend(Series);
  8830. * ```
  8831. */ function mountExtend(SubClz, SupperClz) {
  8832. SubClz.extend = SupperClz.extend
  8833. } // A random offset.
  8834. var classBase = Math.round(Math.random() * 10)
  8835. /**
  8836. * Implements `CheckableConstructor` for `target`.
  8837. * Can not use instanceof, consider different scope by
  8838. * cross domain or es module import in ec extensions.
  8839. * Mount a method "isInstance()" to Clz.
  8840. *
  8841. * @usage
  8842. * ```ts
  8843. * class Xxx {}
  8844. * type XxxConstructor = typeof Xxx & CheckableConstructor;
  8845. * enableClassCheck(Xxx as XxxConstructor)
  8846. * ```
  8847. */ function enableClassCheck(target) {
  8848. var classAttr = ['__\0is_clz', classBase++].join('_')
  8849. target.prototype[classAttr] = true
  8850. target.isInstance = function (obj) {
  8851. return !!(obj && obj[classAttr])
  8852. }
  8853. } // superCall should have class info, which can not be fetch from 'this'.
  8854. // Consider this case:
  8855. // class A has method f,
  8856. // class B inherits class A, overrides method f, f call superApply('f'),
  8857. // class C inherits class B, do not overrides method f,
  8858. // then when method of class C is called, dead loop occured.
  8859. function superCall(context, methodName) {
  8860. var args = []
  8861. for (var _i = 2; _i < arguments.length; _i++) {
  8862. args[_i - 2] = arguments[_i]
  8863. }
  8864. return this.superClass.prototype[methodName].apply(context, args)
  8865. }
  8866. function superApply(context, methodName, args) {
  8867. return this.superClass.prototype[methodName].apply(context, args)
  8868. }
  8869. /**
  8870. * Implements `ClassManager` for `target`
  8871. *
  8872. * @usage
  8873. * ```ts
  8874. * class Xxx {}
  8875. * type XxxConstructor = typeof Xxx & ClassManager
  8876. * enableClassManagement(Xxx as XxxConstructor);
  8877. * ```
  8878. */ function enableClassManagement(target) {
  8879. /**
  8880. * Component model classes
  8881. * key: componentType,
  8882. * value:
  8883. * componentClass, when componentType is 'a'
  8884. * or Object.<subKey, componentClass>, when componentType is 'a.b'
  8885. */ var storage = {}
  8886. target.registerClass = function (clz) {
  8887. // `type` should not be a "instance memeber".
  8888. // If using TS class, should better declared as `static type = 'series.pie'`.
  8889. // otherwise users have to mount `type` on prototype manually.
  8890. // For backward compat and enable instance visit type via `this.type`,
  8891. // we stil support fetch `type` from prototype.
  8892. var componentFullType = clz.type || clz.prototype.type
  8893. if (componentFullType) {
  8894. checkClassType(componentFullType) // If only static type declared, we assign it to prototype mandatorily.
  8895. clz.prototype.type = componentFullType
  8896. var componentTypeInfo = parseClassType(componentFullType)
  8897. if (!componentTypeInfo.sub) {
  8898. storage[componentTypeInfo.main] = clz
  8899. } else if (componentTypeInfo.sub !== IS_CONTAINER) {
  8900. var container = makeContainer(componentTypeInfo)
  8901. container[componentTypeInfo.sub] = clz
  8902. }
  8903. }
  8904. return clz
  8905. }
  8906. target.getClass = function (mainType, subType, throwWhenNotFound) {
  8907. var clz = storage[mainType]
  8908. if (clz && clz[IS_CONTAINER]) {
  8909. clz = subType ? clz[subType] : null
  8910. }
  8911. if (throwWhenNotFound && !clz) {
  8912. throw new Error(
  8913. !subType
  8914. ? mainType + '.' + 'type should be specified.'
  8915. : 'Component ' +
  8916. mainType +
  8917. '.' +
  8918. (subType || '') +
  8919. ' is used but not imported.'
  8920. )
  8921. }
  8922. return clz
  8923. }
  8924. target.getClassesByMainType = function (componentType) {
  8925. var componentTypeInfo = parseClassType(componentType)
  8926. var result = []
  8927. var obj = storage[componentTypeInfo.main]
  8928. if (obj && obj[IS_CONTAINER]) {
  8929. each$7(obj, function (o, type) {
  8930. type !== IS_CONTAINER && result.push(o)
  8931. })
  8932. } else {
  8933. result.push(obj)
  8934. }
  8935. return result
  8936. }
  8937. target.hasClass = function (componentType) {
  8938. // Just consider componentType.main.
  8939. var componentTypeInfo = parseClassType(componentType)
  8940. return !!storage[componentTypeInfo.main]
  8941. }
  8942. /**
  8943. * @return Like ['aa', 'bb'], but can not be ['aa.xx']
  8944. */ target.getAllClassMainTypes = function () {
  8945. var types = []
  8946. each$7(storage, function (obj, type) {
  8947. types.push(type)
  8948. })
  8949. return types
  8950. }
  8951. /**
  8952. * If a main type is container and has sub types
  8953. */ target.hasSubTypes = function (componentType) {
  8954. var componentTypeInfo = parseClassType(componentType)
  8955. var obj = storage[componentTypeInfo.main]
  8956. return obj && obj[IS_CONTAINER]
  8957. }
  8958. function makeContainer(componentTypeInfo) {
  8959. var container = storage[componentTypeInfo.main]
  8960. if (!container || !container[IS_CONTAINER]) {
  8961. container = storage[componentTypeInfo.main] = {}
  8962. container[IS_CONTAINER] = true
  8963. }
  8964. return container
  8965. }
  8966. } // /**
  8967. // * @param {string|Array.<string>} properties
  8968. // */
  8969. // export function setReadOnly(obj, properties) {
  8970. // FIXME It seems broken in IE8 simulation of IE11
  8971. // if (!zrUtil.isArray(properties)) {
  8972. // properties = properties != null ? [properties] : [];
  8973. // }
  8974. // zrUtil.each(properties, function (prop) {
  8975. // let value = obj[prop];
  8976. // Object.defineProperty
  8977. // && Object.defineProperty(obj, prop, {
  8978. // value: value, writable: false
  8979. // });
  8980. // zrUtil.isArray(obj[prop])
  8981. // && Object.freeze
  8982. // && Object.freeze(obj[prop]);
  8983. // });
  8984. // }
  8985. function makeStyleMapper(properties, ignoreParent) {
  8986. // Normalize
  8987. for (var i = 0; i < properties.length; i++) {
  8988. if (!properties[i][1]) {
  8989. properties[i][1] = properties[i][0]
  8990. }
  8991. }
  8992. ignoreParent = ignoreParent || false
  8993. return function (model, excludes, includes) {
  8994. var style = {}
  8995. for (var i = 0; i < properties.length; i++) {
  8996. var propName = properties[i][1]
  8997. if (
  8998. (excludes && indexOf(excludes, propName) >= 0) ||
  8999. (includes && indexOf(includes, propName) < 0)
  9000. ) {
  9001. continue
  9002. }
  9003. var val = model.getShallow(propName, ignoreParent)
  9004. if (val != null) {
  9005. style[properties[i][0]] = val
  9006. }
  9007. } // TODO Text or image?
  9008. return style
  9009. }
  9010. }
  9011. var AREA_STYLE_KEY_MAP = [
  9012. ['fill', 'color'],
  9013. ['shadowBlur'],
  9014. ['shadowOffsetX'],
  9015. ['shadowOffsetY'],
  9016. ['opacity'],
  9017. ['shadowColor'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  9018. // So do not transfer decal directly.
  9019. ]
  9020. var getAreaStyle = makeStyleMapper(AREA_STYLE_KEY_MAP)
  9021. var AreaStyleMixin = /** @class */ (function () {
  9022. function AreaStyleMixin() {}
  9023. AreaStyleMixin.prototype.getAreaStyle = function (
  9024. excludes,
  9025. includes
  9026. ) {
  9027. return getAreaStyle(this, excludes, includes)
  9028. }
  9029. return AreaStyleMixin
  9030. })()
  9031. var globalImageCache = new LRU$1(50)
  9032. function findExistImage(newImageOrSrc) {
  9033. if (typeof newImageOrSrc === 'string') {
  9034. var cachedImgObj = globalImageCache.get(newImageOrSrc)
  9035. return cachedImgObj && cachedImgObj.image
  9036. } else {
  9037. return newImageOrSrc
  9038. }
  9039. }
  9040. function createOrUpdateImage(
  9041. newImageOrSrc,
  9042. image,
  9043. hostEl,
  9044. onload,
  9045. cbPayload
  9046. ) {
  9047. if (!newImageOrSrc) {
  9048. return image
  9049. } else if (typeof newImageOrSrc === 'string') {
  9050. if ((image && image.__zrImageSrc === newImageOrSrc) || !hostEl) {
  9051. return image
  9052. }
  9053. var cachedImgObj = globalImageCache.get(newImageOrSrc)
  9054. var pendingWrap = {
  9055. hostEl: hostEl,
  9056. cb: onload,
  9057. cbPayload: cbPayload
  9058. }
  9059. if (cachedImgObj) {
  9060. image = cachedImgObj.image
  9061. !isImageReady(image) && cachedImgObj.pending.push(pendingWrap)
  9062. } else {
  9063. image = platformApi.loadImage(
  9064. newImageOrSrc,
  9065. imageOnLoad,
  9066. imageOnLoad
  9067. )
  9068. image.__zrImageSrc = newImageOrSrc
  9069. globalImageCache.put(
  9070. newImageOrSrc,
  9071. (image.__cachedImgObj = {
  9072. image: image,
  9073. pending: [pendingWrap]
  9074. })
  9075. )
  9076. }
  9077. return image
  9078. } else {
  9079. return newImageOrSrc
  9080. }
  9081. }
  9082. function imageOnLoad() {
  9083. var cachedImgObj = this.__cachedImgObj
  9084. this.onload = this.onerror = this.__cachedImgObj = null
  9085. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  9086. var pendingWrap = cachedImgObj.pending[i]
  9087. var cb = pendingWrap.cb
  9088. cb && cb(this, pendingWrap.cbPayload)
  9089. pendingWrap.hostEl.dirty()
  9090. }
  9091. cachedImgObj.pending.length = 0
  9092. }
  9093. function isImageReady(image) {
  9094. return image && image.width && image.height
  9095. }
  9096. var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g
  9097. function truncateText(text, containerWidth, font, ellipsis, options) {
  9098. if (!containerWidth) {
  9099. return ''
  9100. }
  9101. var textLines = (text + '').split('\n')
  9102. options = prepareTruncateOptions(
  9103. containerWidth,
  9104. font,
  9105. ellipsis,
  9106. options
  9107. )
  9108. for (var i = 0, len = textLines.length; i < len; i++) {
  9109. textLines[i] = truncateSingleLine(textLines[i], options)
  9110. }
  9111. return textLines.join('\n')
  9112. }
  9113. function prepareTruncateOptions(
  9114. containerWidth,
  9115. font,
  9116. ellipsis,
  9117. options
  9118. ) {
  9119. options = options || {}
  9120. var preparedOpts = extend({}, options)
  9121. preparedOpts.font = font
  9122. ellipsis = retrieve2(ellipsis, '...')
  9123. preparedOpts.maxIterations = retrieve2(options.maxIterations, 2)
  9124. var minChar = (preparedOpts.minChar = retrieve2(options.minChar, 0))
  9125. preparedOpts.cnCharWidth = getWidth('国', font)
  9126. var ascCharWidth = (preparedOpts.ascCharWidth = getWidth('a', font))
  9127. preparedOpts.placeholder = retrieve2(options.placeholder, '')
  9128. var contentWidth = (containerWidth = Math.max(
  9129. 0,
  9130. containerWidth - 1
  9131. ))
  9132. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  9133. contentWidth -= ascCharWidth
  9134. }
  9135. var ellipsisWidth = getWidth(ellipsis, font)
  9136. if (ellipsisWidth > contentWidth) {
  9137. ellipsis = ''
  9138. ellipsisWidth = 0
  9139. }
  9140. contentWidth = containerWidth - ellipsisWidth
  9141. preparedOpts.ellipsis = ellipsis
  9142. preparedOpts.ellipsisWidth = ellipsisWidth
  9143. preparedOpts.contentWidth = contentWidth
  9144. preparedOpts.containerWidth = containerWidth
  9145. return preparedOpts
  9146. }
  9147. function truncateSingleLine(textLine, options) {
  9148. var containerWidth = options.containerWidth
  9149. var font = options.font
  9150. var contentWidth = options.contentWidth
  9151. if (!containerWidth) {
  9152. return ''
  9153. }
  9154. var lineWidth = getWidth(textLine, font)
  9155. if (lineWidth <= containerWidth) {
  9156. return textLine
  9157. }
  9158. for (var j = 0; ; j++) {
  9159. if (lineWidth <= contentWidth || j >= options.maxIterations) {
  9160. textLine += options.ellipsis
  9161. break
  9162. }
  9163. var subLength =
  9164. j === 0
  9165. ? estimateLength(
  9166. textLine,
  9167. contentWidth,
  9168. options.ascCharWidth,
  9169. options.cnCharWidth
  9170. )
  9171. : lineWidth > 0
  9172. ? Math.floor((textLine.length * contentWidth) / lineWidth)
  9173. : 0
  9174. textLine = textLine.substr(0, subLength)
  9175. lineWidth = getWidth(textLine, font)
  9176. }
  9177. if (textLine === '') {
  9178. textLine = options.placeholder
  9179. }
  9180. return textLine
  9181. }
  9182. function estimateLength(
  9183. text,
  9184. contentWidth,
  9185. ascCharWidth,
  9186. cnCharWidth
  9187. ) {
  9188. var width = 0
  9189. var i = 0
  9190. for (var len = text.length; i < len && width < contentWidth; i++) {
  9191. var charCode = text.charCodeAt(i)
  9192. width +=
  9193. 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth
  9194. }
  9195. return i
  9196. }
  9197. function parsePlainText(text, style) {
  9198. text != null && (text += '')
  9199. var overflow = style.overflow
  9200. var padding = style.padding
  9201. var font = style.font
  9202. var truncate = overflow === 'truncate'
  9203. var calculatedLineHeight = getLineHeight(font)
  9204. var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight)
  9205. var bgColorDrawn = !!style.backgroundColor
  9206. var truncateLineOverflow = style.lineOverflow === 'truncate'
  9207. var width = style.width
  9208. var lines
  9209. if (
  9210. width != null &&
  9211. (overflow === 'break' || overflow === 'breakAll')
  9212. ) {
  9213. lines = text
  9214. ? wrapText(text, style.font, width, overflow === 'breakAll', 0)
  9215. .lines
  9216. : []
  9217. } else {
  9218. lines = text ? text.split('\n') : []
  9219. }
  9220. var contentHeight = lines.length * lineHeight
  9221. var height = retrieve2(style.height, contentHeight)
  9222. if (contentHeight > height && truncateLineOverflow) {
  9223. var lineCount = Math.floor(height / lineHeight)
  9224. lines = lines.slice(0, lineCount)
  9225. }
  9226. if (text && truncate && width != null) {
  9227. var options = prepareTruncateOptions(
  9228. width,
  9229. font,
  9230. style.ellipsis,
  9231. {
  9232. minChar: style.truncateMinChar,
  9233. placeholder: style.placeholder
  9234. }
  9235. )
  9236. for (var i = 0; i < lines.length; i++) {
  9237. lines[i] = truncateSingleLine(lines[i], options)
  9238. }
  9239. }
  9240. var outerHeight = height
  9241. var contentWidth = 0
  9242. for (var i = 0; i < lines.length; i++) {
  9243. contentWidth = Math.max(getWidth(lines[i], font), contentWidth)
  9244. }
  9245. if (width == null) {
  9246. width = contentWidth
  9247. }
  9248. var outerWidth = contentWidth
  9249. if (padding) {
  9250. outerHeight += padding[0] + padding[2]
  9251. outerWidth += padding[1] + padding[3]
  9252. width += padding[1] + padding[3]
  9253. }
  9254. if (bgColorDrawn) {
  9255. outerWidth = width
  9256. }
  9257. return {
  9258. lines: lines,
  9259. height: height,
  9260. outerWidth: outerWidth,
  9261. outerHeight: outerHeight,
  9262. lineHeight: lineHeight,
  9263. calculatedLineHeight: calculatedLineHeight,
  9264. contentWidth: contentWidth,
  9265. contentHeight: contentHeight,
  9266. width: width
  9267. }
  9268. }
  9269. var RichTextToken = (function () {
  9270. function RichTextToken() {}
  9271. return RichTextToken
  9272. })()
  9273. var RichTextLine = (function () {
  9274. function RichTextLine(tokens) {
  9275. this.tokens = []
  9276. if (tokens) {
  9277. this.tokens = tokens
  9278. }
  9279. }
  9280. return RichTextLine
  9281. })()
  9282. var RichTextContentBlock = (function () {
  9283. function RichTextContentBlock() {
  9284. this.width = 0
  9285. this.height = 0
  9286. this.contentWidth = 0
  9287. this.contentHeight = 0
  9288. this.outerWidth = 0
  9289. this.outerHeight = 0
  9290. this.lines = []
  9291. }
  9292. return RichTextContentBlock
  9293. })()
  9294. function parseRichText(text, style) {
  9295. var contentBlock = new RichTextContentBlock()
  9296. text != null && (text += '')
  9297. if (!text) {
  9298. return contentBlock
  9299. }
  9300. var topWidth = style.width
  9301. var topHeight = style.height
  9302. var overflow = style.overflow
  9303. var wrapInfo =
  9304. (overflow === 'break' || overflow === 'breakAll') &&
  9305. topWidth != null
  9306. ? {
  9307. width: topWidth,
  9308. accumWidth: 0,
  9309. breakAll: overflow === 'breakAll'
  9310. }
  9311. : null
  9312. var lastIndex = (STYLE_REG.lastIndex = 0)
  9313. var result
  9314. while ((result = STYLE_REG.exec(text)) != null) {
  9315. var matchedIndex = result.index
  9316. if (matchedIndex > lastIndex) {
  9317. pushTokens(
  9318. contentBlock,
  9319. text.substring(lastIndex, matchedIndex),
  9320. style,
  9321. wrapInfo
  9322. )
  9323. }
  9324. pushTokens(contentBlock, result[2], style, wrapInfo, result[1])
  9325. lastIndex = STYLE_REG.lastIndex
  9326. }
  9327. if (lastIndex < text.length) {
  9328. pushTokens(
  9329. contentBlock,
  9330. text.substring(lastIndex, text.length),
  9331. style,
  9332. wrapInfo
  9333. )
  9334. }
  9335. var pendingList = []
  9336. var calculatedHeight = 0
  9337. var calculatedWidth = 0
  9338. var stlPadding = style.padding
  9339. var truncate = overflow === 'truncate'
  9340. var truncateLine = style.lineOverflow === 'truncate'
  9341. function finishLine(line, lineWidth, lineHeight) {
  9342. line.width = lineWidth
  9343. line.lineHeight = lineHeight
  9344. calculatedHeight += lineHeight
  9345. calculatedWidth = Math.max(calculatedWidth, lineWidth)
  9346. }
  9347. outer: for (var i = 0; i < contentBlock.lines.length; i++) {
  9348. var line = contentBlock.lines[i]
  9349. var lineHeight = 0
  9350. var lineWidth = 0
  9351. for (var j = 0; j < line.tokens.length; j++) {
  9352. var token = line.tokens[j]
  9353. var tokenStyle =
  9354. (token.styleName && style.rich[token.styleName]) || {}
  9355. var textPadding = (token.textPadding = tokenStyle.padding)
  9356. var paddingH = textPadding ? textPadding[1] + textPadding[3] : 0
  9357. var font = (token.font = tokenStyle.font || style.font)
  9358. token.contentHeight = getLineHeight(font)
  9359. var tokenHeight = retrieve2(
  9360. tokenStyle.height,
  9361. token.contentHeight
  9362. )
  9363. token.innerHeight = tokenHeight
  9364. textPadding && (tokenHeight += textPadding[0] + textPadding[2])
  9365. token.height = tokenHeight
  9366. token.lineHeight = retrieve3(
  9367. tokenStyle.lineHeight,
  9368. style.lineHeight,
  9369. tokenHeight
  9370. )
  9371. token.align = (tokenStyle && tokenStyle.align) || style.align
  9372. token.verticalAlign =
  9373. (tokenStyle && tokenStyle.verticalAlign) || 'middle'
  9374. if (
  9375. truncateLine &&
  9376. topHeight != null &&
  9377. calculatedHeight + token.lineHeight > topHeight
  9378. ) {
  9379. if (j > 0) {
  9380. line.tokens = line.tokens.slice(0, j)
  9381. finishLine(line, lineWidth, lineHeight)
  9382. contentBlock.lines = contentBlock.lines.slice(0, i + 1)
  9383. } else {
  9384. contentBlock.lines = contentBlock.lines.slice(0, i)
  9385. }
  9386. break outer
  9387. }
  9388. var styleTokenWidth = tokenStyle.width
  9389. var tokenWidthNotSpecified =
  9390. styleTokenWidth == null || styleTokenWidth === 'auto'
  9391. if (
  9392. typeof styleTokenWidth === 'string' &&
  9393. styleTokenWidth.charAt(styleTokenWidth.length - 1) === '%'
  9394. ) {
  9395. token.percentWidth = styleTokenWidth
  9396. pendingList.push(token)
  9397. token.contentWidth = getWidth(token.text, font)
  9398. } else {
  9399. if (tokenWidthNotSpecified) {
  9400. var textBackgroundColor = tokenStyle.backgroundColor
  9401. var bgImg = textBackgroundColor && textBackgroundColor.image
  9402. if (bgImg) {
  9403. bgImg = findExistImage(bgImg)
  9404. if (isImageReady(bgImg)) {
  9405. token.width = Math.max(
  9406. token.width,
  9407. (bgImg.width * tokenHeight) / bgImg.height
  9408. )
  9409. }
  9410. }
  9411. }
  9412. var remainTruncWidth =
  9413. truncate && topWidth != null ? topWidth - lineWidth : null
  9414. if (
  9415. remainTruncWidth != null &&
  9416. remainTruncWidth < token.width
  9417. ) {
  9418. if (
  9419. !tokenWidthNotSpecified ||
  9420. remainTruncWidth < paddingH
  9421. ) {
  9422. token.text = ''
  9423. token.width = token.contentWidth = 0
  9424. } else {
  9425. token.text = truncateText(
  9426. token.text,
  9427. remainTruncWidth - paddingH,
  9428. font,
  9429. style.ellipsis,
  9430. { minChar: style.truncateMinChar }
  9431. )
  9432. token.width = token.contentWidth = getWidth(
  9433. token.text,
  9434. font
  9435. )
  9436. }
  9437. } else {
  9438. token.contentWidth = getWidth(token.text, font)
  9439. }
  9440. }
  9441. token.width += paddingH
  9442. lineWidth += token.width
  9443. tokenStyle &&
  9444. (lineHeight = Math.max(lineHeight, token.lineHeight))
  9445. }
  9446. finishLine(line, lineWidth, lineHeight)
  9447. }
  9448. contentBlock.outerWidth = contentBlock.width = retrieve2(
  9449. topWidth,
  9450. calculatedWidth
  9451. )
  9452. contentBlock.outerHeight = contentBlock.height = retrieve2(
  9453. topHeight,
  9454. calculatedHeight
  9455. )
  9456. contentBlock.contentHeight = calculatedHeight
  9457. contentBlock.contentWidth = calculatedWidth
  9458. if (stlPadding) {
  9459. contentBlock.outerWidth += stlPadding[1] + stlPadding[3]
  9460. contentBlock.outerHeight += stlPadding[0] + stlPadding[2]
  9461. }
  9462. for (var i = 0; i < pendingList.length; i++) {
  9463. var token = pendingList[i]
  9464. var percentWidth = token.percentWidth
  9465. token.width =
  9466. (parseInt(percentWidth, 10) / 100) * contentBlock.width
  9467. }
  9468. return contentBlock
  9469. }
  9470. function pushTokens(block, str, style, wrapInfo, styleName) {
  9471. var isEmptyStr = str === ''
  9472. var tokenStyle = (styleName && style.rich[styleName]) || {}
  9473. var lines = block.lines
  9474. var font = tokenStyle.font || style.font
  9475. var newLine = false
  9476. var strLines
  9477. var linesWidths
  9478. if (wrapInfo) {
  9479. var tokenPadding = tokenStyle.padding
  9480. var tokenPaddingH = tokenPadding
  9481. ? tokenPadding[1] + tokenPadding[3]
  9482. : 0
  9483. if (tokenStyle.width != null && tokenStyle.width !== 'auto') {
  9484. var outerWidth_1 =
  9485. parsePercent$1(tokenStyle.width, wrapInfo.width) +
  9486. tokenPaddingH
  9487. if (lines.length > 0) {
  9488. if (outerWidth_1 + wrapInfo.accumWidth > wrapInfo.width) {
  9489. strLines = str.split('\n')
  9490. newLine = true
  9491. }
  9492. }
  9493. wrapInfo.accumWidth = outerWidth_1
  9494. } else {
  9495. var res = wrapText(
  9496. str,
  9497. font,
  9498. wrapInfo.width,
  9499. wrapInfo.breakAll,
  9500. wrapInfo.accumWidth
  9501. )
  9502. wrapInfo.accumWidth = res.accumWidth + tokenPaddingH
  9503. linesWidths = res.linesWidths
  9504. strLines = res.lines
  9505. }
  9506. } else {
  9507. strLines = str.split('\n')
  9508. }
  9509. for (var i = 0; i < strLines.length; i++) {
  9510. var text = strLines[i]
  9511. var token = new RichTextToken()
  9512. token.styleName = styleName
  9513. token.text = text
  9514. token.isLineHolder = !text && !isEmptyStr
  9515. if (typeof tokenStyle.width === 'number') {
  9516. token.width = tokenStyle.width
  9517. } else {
  9518. token.width = linesWidths
  9519. ? linesWidths[i]
  9520. : getWidth(text, font)
  9521. }
  9522. if (!i && !newLine) {
  9523. var tokens = (
  9524. lines[lines.length - 1] || (lines[0] = new RichTextLine())
  9525. ).tokens
  9526. var tokensLen = tokens.length
  9527. tokensLen === 1 && tokens[0].isLineHolder
  9528. ? (tokens[0] = token)
  9529. : (text || !tokensLen || isEmptyStr) && tokens.push(token)
  9530. } else {
  9531. lines.push(new RichTextLine([token]))
  9532. }
  9533. }
  9534. }
  9535. function isLatin(ch) {
  9536. var code = ch.charCodeAt(0)
  9537. return code >= 0x21 && code <= 0x17f
  9538. }
  9539. var breakCharMap = reduce(
  9540. ',&?/;] '.split(''),
  9541. function (obj, ch) {
  9542. obj[ch] = true
  9543. return obj
  9544. },
  9545. {}
  9546. )
  9547. function isWordBreakChar(ch) {
  9548. if (isLatin(ch)) {
  9549. if (breakCharMap[ch]) {
  9550. return true
  9551. }
  9552. return false
  9553. }
  9554. return true
  9555. }
  9556. function wrapText(text, font, lineWidth, isBreakAll, lastAccumWidth) {
  9557. var lines = []
  9558. var linesWidths = []
  9559. var line = ''
  9560. var currentWord = ''
  9561. var currentWordWidth = 0
  9562. var accumWidth = 0
  9563. for (var i = 0; i < text.length; i++) {
  9564. var ch = text.charAt(i)
  9565. if (ch === '\n') {
  9566. if (currentWord) {
  9567. line += currentWord
  9568. accumWidth += currentWordWidth
  9569. }
  9570. lines.push(line)
  9571. linesWidths.push(accumWidth)
  9572. line = ''
  9573. currentWord = ''
  9574. currentWordWidth = 0
  9575. accumWidth = 0
  9576. continue
  9577. }
  9578. var chWidth = getWidth(ch, font)
  9579. var inWord = isBreakAll ? false : !isWordBreakChar(ch)
  9580. if (
  9581. !lines.length
  9582. ? lastAccumWidth + accumWidth + chWidth > lineWidth
  9583. : accumWidth + chWidth > lineWidth
  9584. ) {
  9585. if (!accumWidth) {
  9586. if (inWord) {
  9587. lines.push(currentWord)
  9588. linesWidths.push(currentWordWidth)
  9589. currentWord = ch
  9590. currentWordWidth = chWidth
  9591. } else {
  9592. lines.push(ch)
  9593. linesWidths.push(chWidth)
  9594. }
  9595. } else if (line || currentWord) {
  9596. if (inWord) {
  9597. if (!line) {
  9598. line = currentWord
  9599. currentWord = ''
  9600. currentWordWidth = 0
  9601. accumWidth = currentWordWidth
  9602. }
  9603. lines.push(line)
  9604. linesWidths.push(accumWidth - currentWordWidth)
  9605. currentWord += ch
  9606. currentWordWidth += chWidth
  9607. line = ''
  9608. accumWidth = currentWordWidth
  9609. } else {
  9610. if (currentWord) {
  9611. line += currentWord
  9612. currentWord = ''
  9613. currentWordWidth = 0
  9614. }
  9615. lines.push(line)
  9616. linesWidths.push(accumWidth)
  9617. line = ch
  9618. accumWidth = chWidth
  9619. }
  9620. }
  9621. continue
  9622. }
  9623. accumWidth += chWidth
  9624. if (inWord) {
  9625. currentWord += ch
  9626. currentWordWidth += chWidth
  9627. } else {
  9628. if (currentWord) {
  9629. line += currentWord
  9630. currentWord = ''
  9631. currentWordWidth = 0
  9632. }
  9633. line += ch
  9634. }
  9635. }
  9636. if (!lines.length && !line) {
  9637. line = text
  9638. currentWord = ''
  9639. currentWordWidth = 0
  9640. }
  9641. if (currentWord) {
  9642. line += currentWord
  9643. }
  9644. if (line) {
  9645. lines.push(line)
  9646. linesWidths.push(accumWidth)
  9647. }
  9648. if (lines.length === 1) {
  9649. accumWidth += lastAccumWidth
  9650. }
  9651. return {
  9652. accumWidth: accumWidth,
  9653. lines: lines,
  9654. linesWidths: linesWidths
  9655. }
  9656. }
  9657. var STYLE_MAGIC_KEY = '__zr_style_' + Math.round(Math.random() * 10)
  9658. var DEFAULT_COMMON_STYLE = {
  9659. shadowBlur: 0,
  9660. shadowOffsetX: 0,
  9661. shadowOffsetY: 0,
  9662. shadowColor: '#000',
  9663. opacity: 1,
  9664. blend: 'source-over'
  9665. }
  9666. var DEFAULT_COMMON_ANIMATION_PROPS = {
  9667. style: {
  9668. shadowBlur: true,
  9669. shadowOffsetX: true,
  9670. shadowOffsetY: true,
  9671. shadowColor: true,
  9672. opacity: true
  9673. }
  9674. }
  9675. DEFAULT_COMMON_STYLE[STYLE_MAGIC_KEY] = true
  9676. var PRIMARY_STATES_KEYS = ['z', 'z2', 'invisible']
  9677. var PRIMARY_STATES_KEYS_IN_HOVER_LAYER = ['invisible']
  9678. var Displayable = (function (_super) {
  9679. __extends(Displayable, _super)
  9680. function Displayable(props) {
  9681. return _super.call(this, props) || this
  9682. }
  9683. Displayable.prototype._init = function (props) {
  9684. var keysArr = keys(props)
  9685. for (var i = 0; i < keysArr.length; i++) {
  9686. var key = keysArr[i]
  9687. if (key === 'style') {
  9688. this.useStyle(props[key])
  9689. } else {
  9690. _super.prototype.attrKV.call(this, key, props[key])
  9691. }
  9692. }
  9693. if (!this.style) {
  9694. this.useStyle({})
  9695. }
  9696. }
  9697. Displayable.prototype.beforeBrush = function () {}
  9698. Displayable.prototype.afterBrush = function () {}
  9699. Displayable.prototype.innerBeforeBrush = function () {}
  9700. Displayable.prototype.innerAfterBrush = function () {}
  9701. Displayable.prototype.shouldBePainted = function (
  9702. viewWidth,
  9703. viewHeight,
  9704. considerClipPath,
  9705. considerAncestors
  9706. ) {
  9707. var m = this.transform
  9708. if (
  9709. this.ignore ||
  9710. this.invisible ||
  9711. this.style.opacity === 0 ||
  9712. (this.culling &&
  9713. isDisplayableCulled(this, viewWidth, viewHeight)) ||
  9714. (m && !m[0] && !m[3])
  9715. ) {
  9716. return false
  9717. }
  9718. if (considerClipPath && this.__clipPaths) {
  9719. for (var i = 0; i < this.__clipPaths.length; ++i) {
  9720. if (this.__clipPaths[i].isZeroArea()) {
  9721. return false
  9722. }
  9723. }
  9724. }
  9725. if (considerAncestors && this.parent) {
  9726. var parent_1 = this.parent
  9727. while (parent_1) {
  9728. if (parent_1.ignore) {
  9729. return false
  9730. }
  9731. parent_1 = parent_1.parent
  9732. }
  9733. }
  9734. return true
  9735. }
  9736. Displayable.prototype.contain = function (x, y) {
  9737. return this.rectContain(x, y)
  9738. }
  9739. Displayable.prototype.traverse = function (cb, context) {
  9740. cb.call(context, this)
  9741. }
  9742. Displayable.prototype.rectContain = function (x, y) {
  9743. var coord = this.transformCoordToLocal(x, y)
  9744. var rect = this.getBoundingRect()
  9745. return rect.contain(coord[0], coord[1])
  9746. }
  9747. Displayable.prototype.getPaintRect = function () {
  9748. var rect = this._paintRect
  9749. if (!this._paintRect || this.__dirty) {
  9750. var transform = this.transform
  9751. var elRect = this.getBoundingRect()
  9752. var style = this.style
  9753. var shadowSize = style.shadowBlur || 0
  9754. var shadowOffsetX = style.shadowOffsetX || 0
  9755. var shadowOffsetY = style.shadowOffsetY || 0
  9756. rect =
  9757. this._paintRect ||
  9758. (this._paintRect = new BoundingRect$1(0, 0, 0, 0))
  9759. if (transform) {
  9760. BoundingRect$1.applyTransform(rect, elRect, transform)
  9761. } else {
  9762. rect.copy(elRect)
  9763. }
  9764. if (shadowSize || shadowOffsetX || shadowOffsetY) {
  9765. rect.width += shadowSize * 2 + Math.abs(shadowOffsetX)
  9766. rect.height += shadowSize * 2 + Math.abs(shadowOffsetY)
  9767. rect.x = Math.min(rect.x, rect.x + shadowOffsetX - shadowSize)
  9768. rect.y = Math.min(rect.y, rect.y + shadowOffsetY - shadowSize)
  9769. }
  9770. var tolerance = this.dirtyRectTolerance
  9771. if (!rect.isZero()) {
  9772. rect.x = Math.floor(rect.x - tolerance)
  9773. rect.y = Math.floor(rect.y - tolerance)
  9774. rect.width = Math.ceil(rect.width + 1 + tolerance * 2)
  9775. rect.height = Math.ceil(rect.height + 1 + tolerance * 2)
  9776. }
  9777. }
  9778. return rect
  9779. }
  9780. Displayable.prototype.setPrevPaintRect = function (paintRect) {
  9781. if (paintRect) {
  9782. this._prevPaintRect =
  9783. this._prevPaintRect || new BoundingRect$1(0, 0, 0, 0)
  9784. this._prevPaintRect.copy(paintRect)
  9785. } else {
  9786. this._prevPaintRect = null
  9787. }
  9788. }
  9789. Displayable.prototype.getPrevPaintRect = function () {
  9790. return this._prevPaintRect
  9791. }
  9792. Displayable.prototype.animateStyle = function (loop) {
  9793. return this.animate('style', loop)
  9794. }
  9795. Displayable.prototype.updateDuringAnimation = function (targetKey) {
  9796. if (targetKey === 'style') {
  9797. this.dirtyStyle()
  9798. } else {
  9799. this.markRedraw()
  9800. }
  9801. }
  9802. Displayable.prototype.attrKV = function (key, value) {
  9803. if (key !== 'style') {
  9804. _super.prototype.attrKV.call(this, key, value)
  9805. } else {
  9806. if (!this.style) {
  9807. this.useStyle(value)
  9808. } else {
  9809. this.setStyle(value)
  9810. }
  9811. }
  9812. }
  9813. Displayable.prototype.setStyle = function (keyOrObj, value) {
  9814. if (typeof keyOrObj === 'string') {
  9815. this.style[keyOrObj] = value
  9816. } else {
  9817. extend(this.style, keyOrObj)
  9818. }
  9819. this.dirtyStyle()
  9820. return this
  9821. }
  9822. Displayable.prototype.dirtyStyle = function (notRedraw) {
  9823. if (!notRedraw) {
  9824. this.markRedraw()
  9825. }
  9826. this.__dirty |= STYLE_CHANGED_BIT
  9827. if (this._rect) {
  9828. this._rect = null
  9829. }
  9830. }
  9831. Displayable.prototype.dirty = function () {
  9832. this.dirtyStyle()
  9833. }
  9834. Displayable.prototype.styleChanged = function () {
  9835. return !!(this.__dirty & STYLE_CHANGED_BIT)
  9836. }
  9837. Displayable.prototype.styleUpdated = function () {
  9838. this.__dirty &= ~STYLE_CHANGED_BIT
  9839. }
  9840. Displayable.prototype.createStyle = function (obj) {
  9841. return createObject(DEFAULT_COMMON_STYLE, obj)
  9842. }
  9843. Displayable.prototype.useStyle = function (obj) {
  9844. if (!obj[STYLE_MAGIC_KEY]) {
  9845. obj = this.createStyle(obj)
  9846. }
  9847. if (this.__inHover) {
  9848. this.__hoverStyle = obj
  9849. } else {
  9850. this.style = obj
  9851. }
  9852. this.dirtyStyle()
  9853. }
  9854. Displayable.prototype.isStyleObject = function (obj) {
  9855. return obj[STYLE_MAGIC_KEY]
  9856. }
  9857. Displayable.prototype._innerSaveToNormal = function (toState) {
  9858. _super.prototype._innerSaveToNormal.call(this, toState)
  9859. var normalState = this._normalState
  9860. if (toState.style && !normalState.style) {
  9861. normalState.style = this._mergeStyle(
  9862. this.createStyle(),
  9863. this.style
  9864. )
  9865. }
  9866. this._savePrimaryToNormal(
  9867. toState,
  9868. normalState,
  9869. PRIMARY_STATES_KEYS
  9870. )
  9871. }
  9872. Displayable.prototype._applyStateObj = function (
  9873. stateName,
  9874. state,
  9875. normalState,
  9876. keepCurrentStates,
  9877. transition,
  9878. animationCfg
  9879. ) {
  9880. _super.prototype._applyStateObj.call(
  9881. this,
  9882. stateName,
  9883. state,
  9884. normalState,
  9885. keepCurrentStates,
  9886. transition,
  9887. animationCfg
  9888. )
  9889. var needsRestoreToNormal = !(state && keepCurrentStates)
  9890. var targetStyle
  9891. if (state && state.style) {
  9892. if (transition) {
  9893. if (keepCurrentStates) {
  9894. targetStyle = state.style
  9895. } else {
  9896. targetStyle = this._mergeStyle(
  9897. this.createStyle(),
  9898. normalState.style
  9899. )
  9900. this._mergeStyle(targetStyle, state.style)
  9901. }
  9902. } else {
  9903. targetStyle = this._mergeStyle(
  9904. this.createStyle(),
  9905. keepCurrentStates ? this.style : normalState.style
  9906. )
  9907. this._mergeStyle(targetStyle, state.style)
  9908. }
  9909. } else if (needsRestoreToNormal) {
  9910. targetStyle = normalState.style
  9911. }
  9912. if (targetStyle) {
  9913. if (transition) {
  9914. var sourceStyle = this.style
  9915. this.style = this.createStyle(
  9916. needsRestoreToNormal ? {} : sourceStyle
  9917. )
  9918. if (needsRestoreToNormal) {
  9919. var changedKeys = keys(sourceStyle)
  9920. for (var i = 0; i < changedKeys.length; i++) {
  9921. var key = changedKeys[i]
  9922. if (key in targetStyle) {
  9923. targetStyle[key] = targetStyle[key]
  9924. this.style[key] = sourceStyle[key]
  9925. }
  9926. }
  9927. }
  9928. var targetKeys = keys(targetStyle)
  9929. for (var i = 0; i < targetKeys.length; i++) {
  9930. var key = targetKeys[i]
  9931. this.style[key] = this.style[key]
  9932. }
  9933. this._transitionState(
  9934. stateName,
  9935. { style: targetStyle },
  9936. animationCfg,
  9937. this.getAnimationStyleProps()
  9938. )
  9939. } else {
  9940. this.useStyle(targetStyle)
  9941. }
  9942. }
  9943. var statesKeys = this.__inHover
  9944. ? PRIMARY_STATES_KEYS_IN_HOVER_LAYER
  9945. : PRIMARY_STATES_KEYS
  9946. for (var i = 0; i < statesKeys.length; i++) {
  9947. var key = statesKeys[i]
  9948. if (state && state[key] != null) {
  9949. this[key] = state[key]
  9950. } else if (needsRestoreToNormal) {
  9951. if (normalState[key] != null) {
  9952. this[key] = normalState[key]
  9953. }
  9954. }
  9955. }
  9956. }
  9957. Displayable.prototype._mergeStates = function (states) {
  9958. var mergedState = _super.prototype._mergeStates.call(this, states)
  9959. var mergedStyle
  9960. for (var i = 0; i < states.length; i++) {
  9961. var state = states[i]
  9962. if (state.style) {
  9963. mergedStyle = mergedStyle || {}
  9964. this._mergeStyle(mergedStyle, state.style)
  9965. }
  9966. }
  9967. if (mergedStyle) {
  9968. mergedState.style = mergedStyle
  9969. }
  9970. return mergedState
  9971. }
  9972. Displayable.prototype._mergeStyle = function (
  9973. targetStyle,
  9974. sourceStyle
  9975. ) {
  9976. extend(targetStyle, sourceStyle)
  9977. return targetStyle
  9978. }
  9979. Displayable.prototype.getAnimationStyleProps = function () {
  9980. return DEFAULT_COMMON_ANIMATION_PROPS
  9981. }
  9982. Displayable.initDefaultProps = (function () {
  9983. var dispProto = Displayable.prototype
  9984. dispProto.type = 'displayable'
  9985. dispProto.invisible = false
  9986. dispProto.z = 0
  9987. dispProto.z2 = 0
  9988. dispProto.zlevel = 0
  9989. dispProto.culling = false
  9990. dispProto.cursor = 'pointer'
  9991. dispProto.rectHover = false
  9992. dispProto.incremental = false
  9993. dispProto._rect = null
  9994. dispProto.dirtyRectTolerance = 0
  9995. dispProto.__dirty = REDRAW_BIT | STYLE_CHANGED_BIT
  9996. })()
  9997. return Displayable
  9998. })(Element$1)
  9999. var tmpRect = new BoundingRect$1(0, 0, 0, 0)
  10000. var viewRect = new BoundingRect$1(0, 0, 0, 0)
  10001. function isDisplayableCulled(el, width, height) {
  10002. tmpRect.copy(el.getBoundingRect())
  10003. if (el.transform) {
  10004. tmpRect.applyTransform(el.transform)
  10005. }
  10006. viewRect.width = width
  10007. viewRect.height = height
  10008. return !tmpRect.intersect(viewRect)
  10009. }
  10010. var Displayable$1 = Displayable
  10011. var mathMin$6 = Math.min
  10012. var mathMax$6 = Math.max
  10013. var mathSin$3 = Math.sin
  10014. var mathCos$3 = Math.cos
  10015. var PI2$7 = Math.PI * 2
  10016. var start = create$1()
  10017. var end = create$1()
  10018. var extremity = create$1()
  10019. function fromPoints(points, min, max) {
  10020. if (points.length === 0) {
  10021. return
  10022. }
  10023. var p = points[0]
  10024. var left = p[0]
  10025. var right = p[0]
  10026. var top = p[1]
  10027. var bottom = p[1]
  10028. for (var i = 1; i < points.length; i++) {
  10029. p = points[i]
  10030. left = mathMin$6(left, p[0])
  10031. right = mathMax$6(right, p[0])
  10032. top = mathMin$6(top, p[1])
  10033. bottom = mathMax$6(bottom, p[1])
  10034. }
  10035. min[0] = left
  10036. min[1] = top
  10037. max[0] = right
  10038. max[1] = bottom
  10039. }
  10040. function fromLine(x0, y0, x1, y1, min, max) {
  10041. min[0] = mathMin$6(x0, x1)
  10042. min[1] = mathMin$6(y0, y1)
  10043. max[0] = mathMax$6(x0, x1)
  10044. max[1] = mathMax$6(y0, y1)
  10045. }
  10046. var xDim = []
  10047. var yDim = []
  10048. function fromCubic(x0, y0, x1, y1, x2, y2, x3, y3, min, max) {
  10049. var cubicExtrema$1 = cubicExtrema
  10050. var cubicAt$1 = cubicAt
  10051. var n = cubicExtrema$1(x0, x1, x2, x3, xDim)
  10052. min[0] = Infinity
  10053. min[1] = Infinity
  10054. max[0] = -Infinity
  10055. max[1] = -Infinity
  10056. for (var i = 0; i < n; i++) {
  10057. var x = cubicAt$1(x0, x1, x2, x3, xDim[i])
  10058. min[0] = mathMin$6(x, min[0])
  10059. max[0] = mathMax$6(x, max[0])
  10060. }
  10061. n = cubicExtrema$1(y0, y1, y2, y3, yDim)
  10062. for (var i = 0; i < n; i++) {
  10063. var y = cubicAt$1(y0, y1, y2, y3, yDim[i])
  10064. min[1] = mathMin$6(y, min[1])
  10065. max[1] = mathMax$6(y, max[1])
  10066. }
  10067. min[0] = mathMin$6(x0, min[0])
  10068. max[0] = mathMax$6(x0, max[0])
  10069. min[0] = mathMin$6(x3, min[0])
  10070. max[0] = mathMax$6(x3, max[0])
  10071. min[1] = mathMin$6(y0, min[1])
  10072. max[1] = mathMax$6(y0, max[1])
  10073. min[1] = mathMin$6(y3, min[1])
  10074. max[1] = mathMax$6(y3, max[1])
  10075. }
  10076. function fromQuadratic(x0, y0, x1, y1, x2, y2, min, max) {
  10077. var quadraticExtremum$1 = quadraticExtremum
  10078. var quadraticAt$1 = quadraticAt
  10079. var tx = mathMax$6(mathMin$6(quadraticExtremum$1(x0, x1, x2), 1), 0)
  10080. var ty = mathMax$6(mathMin$6(quadraticExtremum$1(y0, y1, y2), 1), 0)
  10081. var x = quadraticAt$1(x0, x1, x2, tx)
  10082. var y = quadraticAt$1(y0, y1, y2, ty)
  10083. min[0] = mathMin$6(x0, x2, x)
  10084. min[1] = mathMin$6(y0, y2, y)
  10085. max[0] = mathMax$6(x0, x2, x)
  10086. max[1] = mathMax$6(y0, y2, y)
  10087. }
  10088. function fromArc(
  10089. x,
  10090. y,
  10091. rx,
  10092. ry,
  10093. startAngle,
  10094. endAngle,
  10095. anticlockwise,
  10096. min,
  10097. max
  10098. ) {
  10099. var vec2Min = min$1
  10100. var vec2Max = max$1
  10101. var diff = Math.abs(startAngle - endAngle)
  10102. if (diff % PI2$7 < 1e-4 && diff > 1e-4) {
  10103. min[0] = x - rx
  10104. min[1] = y - ry
  10105. max[0] = x + rx
  10106. max[1] = y + ry
  10107. return
  10108. }
  10109. start[0] = mathCos$3(startAngle) * rx + x
  10110. start[1] = mathSin$3(startAngle) * ry + y
  10111. end[0] = mathCos$3(endAngle) * rx + x
  10112. end[1] = mathSin$3(endAngle) * ry + y
  10113. vec2Min(min, start, end)
  10114. vec2Max(max, start, end)
  10115. startAngle = startAngle % PI2$7
  10116. if (startAngle < 0) {
  10117. startAngle = startAngle + PI2$7
  10118. }
  10119. endAngle = endAngle % PI2$7
  10120. if (endAngle < 0) {
  10121. endAngle = endAngle + PI2$7
  10122. }
  10123. if (startAngle > endAngle && !anticlockwise) {
  10124. endAngle += PI2$7
  10125. } else if (startAngle < endAngle && anticlockwise) {
  10126. startAngle += PI2$7
  10127. }
  10128. if (anticlockwise) {
  10129. var tmp = endAngle
  10130. endAngle = startAngle
  10131. startAngle = tmp
  10132. }
  10133. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  10134. if (angle > startAngle) {
  10135. extremity[0] = mathCos$3(angle) * rx + x
  10136. extremity[1] = mathSin$3(angle) * ry + y
  10137. vec2Min(min, extremity, min)
  10138. vec2Max(max, extremity, max)
  10139. }
  10140. }
  10141. }
  10142. var CMD$4 = { M: 1, L: 2, C: 3, Q: 4, A: 5, Z: 6, R: 7 }
  10143. var tmpOutX = []
  10144. var tmpOutY = []
  10145. var min = []
  10146. var max = []
  10147. var min2 = []
  10148. var max2 = []
  10149. var mathMin$5 = Math.min
  10150. var mathMax$5 = Math.max
  10151. var mathCos$2 = Math.cos
  10152. var mathSin$2 = Math.sin
  10153. var mathAbs$1 = Math.abs
  10154. var PI$4 = Math.PI
  10155. var PI2$6 = PI$4 * 2
  10156. var hasTypedArray = typeof Float32Array !== 'undefined'
  10157. var tmpAngles = []
  10158. function modPI2(radian) {
  10159. var n = Math.round((radian / PI$4) * 1e8) / 1e8
  10160. return (n % 2) * PI$4
  10161. }
  10162. function normalizeArcAngles(angles, anticlockwise) {
  10163. var newStartAngle = modPI2(angles[0])
  10164. if (newStartAngle < 0) {
  10165. newStartAngle += PI2$6
  10166. }
  10167. var delta = newStartAngle - angles[0]
  10168. var newEndAngle = angles[1]
  10169. newEndAngle += delta
  10170. if (!anticlockwise && newEndAngle - newStartAngle >= PI2$6) {
  10171. newEndAngle = newStartAngle + PI2$6
  10172. } else if (anticlockwise && newStartAngle - newEndAngle >= PI2$6) {
  10173. newEndAngle = newStartAngle - PI2$6
  10174. } else if (!anticlockwise && newStartAngle > newEndAngle) {
  10175. newEndAngle =
  10176. newStartAngle + (PI2$6 - modPI2(newStartAngle - newEndAngle))
  10177. } else if (anticlockwise && newStartAngle < newEndAngle) {
  10178. newEndAngle =
  10179. newStartAngle - (PI2$6 - modPI2(newEndAngle - newStartAngle))
  10180. }
  10181. angles[0] = newStartAngle
  10182. angles[1] = newEndAngle
  10183. }
  10184. var PathProxy = (function () {
  10185. function PathProxy(notSaveData) {
  10186. this.dpr = 1
  10187. this._xi = 0
  10188. this._yi = 0
  10189. this._x0 = 0
  10190. this._y0 = 0
  10191. this._len = 0
  10192. if (notSaveData) {
  10193. this._saveData = false
  10194. }
  10195. if (this._saveData) {
  10196. this.data = []
  10197. }
  10198. }
  10199. PathProxy.prototype.increaseVersion = function () {
  10200. this._version++
  10201. }
  10202. PathProxy.prototype.getVersion = function () {
  10203. return this._version
  10204. }
  10205. PathProxy.prototype.setScale = function (
  10206. sx,
  10207. sy,
  10208. segmentIgnoreThreshold
  10209. ) {
  10210. segmentIgnoreThreshold = segmentIgnoreThreshold || 0
  10211. if (segmentIgnoreThreshold > 0) {
  10212. this._ux =
  10213. mathAbs$1(segmentIgnoreThreshold / devicePixelRatio / sx) || 0
  10214. this._uy =
  10215. mathAbs$1(segmentIgnoreThreshold / devicePixelRatio / sy) || 0
  10216. }
  10217. }
  10218. PathProxy.prototype.setDPR = function (dpr) {
  10219. this.dpr = dpr
  10220. }
  10221. PathProxy.prototype.setContext = function (ctx) {
  10222. this._ctx = ctx
  10223. }
  10224. PathProxy.prototype.getContext = function () {
  10225. return this._ctx
  10226. }
  10227. PathProxy.prototype.beginPath = function () {
  10228. this._ctx && this._ctx.beginPath()
  10229. this.reset()
  10230. return this
  10231. }
  10232. PathProxy.prototype.reset = function () {
  10233. if (this._saveData) {
  10234. this._len = 0
  10235. }
  10236. if (this._pathSegLen) {
  10237. this._pathSegLen = null
  10238. this._pathLen = 0
  10239. }
  10240. this._version++
  10241. }
  10242. PathProxy.prototype.moveTo = function (x, y) {
  10243. this._drawPendingPt()
  10244. this.addData(CMD$4.M, x, y)
  10245. this._ctx && this._ctx.moveTo(x, y)
  10246. this._x0 = x
  10247. this._y0 = y
  10248. this._xi = x
  10249. this._yi = y
  10250. return this
  10251. }
  10252. PathProxy.prototype.lineTo = function (x, y) {
  10253. var dx = mathAbs$1(x - this._xi)
  10254. var dy = mathAbs$1(y - this._yi)
  10255. var exceedUnit = dx > this._ux || dy > this._uy
  10256. this.addData(CMD$4.L, x, y)
  10257. if (this._ctx && exceedUnit) {
  10258. this._ctx.lineTo(x, y)
  10259. }
  10260. if (exceedUnit) {
  10261. this._xi = x
  10262. this._yi = y
  10263. this._pendingPtDist = 0
  10264. } else {
  10265. var d2 = dx * dx + dy * dy
  10266. if (d2 > this._pendingPtDist) {
  10267. this._pendingPtX = x
  10268. this._pendingPtY = y
  10269. this._pendingPtDist = d2
  10270. }
  10271. }
  10272. return this
  10273. }
  10274. PathProxy.prototype.bezierCurveTo = function (
  10275. x1,
  10276. y1,
  10277. x2,
  10278. y2,
  10279. x3,
  10280. y3
  10281. ) {
  10282. this._drawPendingPt()
  10283. this.addData(CMD$4.C, x1, y1, x2, y2, x3, y3)
  10284. if (this._ctx) {
  10285. this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3)
  10286. }
  10287. this._xi = x3
  10288. this._yi = y3
  10289. return this
  10290. }
  10291. PathProxy.prototype.quadraticCurveTo = function (x1, y1, x2, y2) {
  10292. this._drawPendingPt()
  10293. this.addData(CMD$4.Q, x1, y1, x2, y2)
  10294. if (this._ctx) {
  10295. this._ctx.quadraticCurveTo(x1, y1, x2, y2)
  10296. }
  10297. this._xi = x2
  10298. this._yi = y2
  10299. return this
  10300. }
  10301. PathProxy.prototype.arc = function (
  10302. cx,
  10303. cy,
  10304. r,
  10305. startAngle,
  10306. endAngle,
  10307. anticlockwise
  10308. ) {
  10309. this._drawPendingPt()
  10310. tmpAngles[0] = startAngle
  10311. tmpAngles[1] = endAngle
  10312. normalizeArcAngles(tmpAngles, anticlockwise)
  10313. startAngle = tmpAngles[0]
  10314. endAngle = tmpAngles[1]
  10315. var delta = endAngle - startAngle
  10316. this.addData(
  10317. CMD$4.A,
  10318. cx,
  10319. cy,
  10320. r,
  10321. r,
  10322. startAngle,
  10323. delta,
  10324. 0,
  10325. anticlockwise ? 0 : 1
  10326. )
  10327. this._ctx &&
  10328. this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise)
  10329. this._xi = mathCos$2(endAngle) * r + cx
  10330. this._yi = mathSin$2(endAngle) * r + cy
  10331. return this
  10332. }
  10333. PathProxy.prototype.arcTo = function (x1, y1, x2, y2, radius) {
  10334. this._drawPendingPt()
  10335. if (this._ctx) {
  10336. this._ctx.arcTo(x1, y1, x2, y2, radius)
  10337. }
  10338. return this
  10339. }
  10340. PathProxy.prototype.rect = function (x, y, w, h) {
  10341. this._drawPendingPt()
  10342. this._ctx && this._ctx.rect(x, y, w, h)
  10343. this.addData(CMD$4.R, x, y, w, h)
  10344. return this
  10345. }
  10346. PathProxy.prototype.closePath = function () {
  10347. this._drawPendingPt()
  10348. this.addData(CMD$4.Z)
  10349. var ctx = this._ctx
  10350. var x0 = this._x0
  10351. var y0 = this._y0
  10352. if (ctx) {
  10353. ctx.closePath()
  10354. }
  10355. this._xi = x0
  10356. this._yi = y0
  10357. return this
  10358. }
  10359. PathProxy.prototype.fill = function (ctx) {
  10360. ctx && ctx.fill()
  10361. this.toStatic()
  10362. }
  10363. PathProxy.prototype.stroke = function (ctx) {
  10364. ctx && ctx.stroke()
  10365. this.toStatic()
  10366. }
  10367. PathProxy.prototype.len = function () {
  10368. return this._len
  10369. }
  10370. PathProxy.prototype.setData = function (data) {
  10371. var len = data.length
  10372. if (!(this.data && this.data.length === len) && hasTypedArray) {
  10373. this.data = new Float32Array(len)
  10374. }
  10375. for (var i = 0; i < len; i++) {
  10376. this.data[i] = data[i]
  10377. }
  10378. this._len = len
  10379. }
  10380. PathProxy.prototype.appendPath = function (path) {
  10381. if (!(path instanceof Array)) {
  10382. path = [path]
  10383. }
  10384. var len = path.length
  10385. var appendSize = 0
  10386. var offset = this._len
  10387. for (var i = 0; i < len; i++) {
  10388. appendSize += path[i].len()
  10389. }
  10390. if (hasTypedArray && this.data instanceof Float32Array) {
  10391. this.data = new Float32Array(offset + appendSize)
  10392. }
  10393. for (var i = 0; i < len; i++) {
  10394. var appendPathData = path[i].data
  10395. for (var k = 0; k < appendPathData.length; k++) {
  10396. this.data[offset++] = appendPathData[k]
  10397. }
  10398. }
  10399. this._len = offset
  10400. }
  10401. PathProxy.prototype.addData = function (
  10402. cmd,
  10403. a,
  10404. b,
  10405. c,
  10406. d,
  10407. e,
  10408. f,
  10409. g,
  10410. h
  10411. ) {
  10412. if (!this._saveData) {
  10413. return
  10414. }
  10415. var data = this.data
  10416. if (this._len + arguments.length > data.length) {
  10417. this._expandData()
  10418. data = this.data
  10419. }
  10420. for (var i = 0; i < arguments.length; i++) {
  10421. data[this._len++] = arguments[i]
  10422. }
  10423. }
  10424. PathProxy.prototype._drawPendingPt = function () {
  10425. if (this._pendingPtDist > 0) {
  10426. this._ctx &&
  10427. this._ctx.lineTo(this._pendingPtX, this._pendingPtY)
  10428. this._pendingPtDist = 0
  10429. }
  10430. }
  10431. PathProxy.prototype._expandData = function () {
  10432. if (!(this.data instanceof Array)) {
  10433. var newData = []
  10434. for (var i = 0; i < this._len; i++) {
  10435. newData[i] = this.data[i]
  10436. }
  10437. this.data = newData
  10438. }
  10439. }
  10440. PathProxy.prototype.toStatic = function () {
  10441. if (!this._saveData) {
  10442. return
  10443. }
  10444. this._drawPendingPt()
  10445. var data = this.data
  10446. if (data instanceof Array) {
  10447. data.length = this._len
  10448. if (hasTypedArray && this._len > 11) {
  10449. this.data = new Float32Array(data)
  10450. }
  10451. }
  10452. }
  10453. PathProxy.prototype.getBoundingRect = function () {
  10454. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE
  10455. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE
  10456. var data = this.data
  10457. var xi = 0
  10458. var yi = 0
  10459. var x0 = 0
  10460. var y0 = 0
  10461. var i
  10462. for (i = 0; i < this._len; ) {
  10463. var cmd = data[i++]
  10464. var isFirst = i === 1
  10465. if (isFirst) {
  10466. xi = data[i]
  10467. yi = data[i + 1]
  10468. x0 = xi
  10469. y0 = yi
  10470. }
  10471. switch (cmd) {
  10472. case CMD$4.M:
  10473. xi = x0 = data[i++]
  10474. yi = y0 = data[i++]
  10475. min2[0] = x0
  10476. min2[1] = y0
  10477. max2[0] = x0
  10478. max2[1] = y0
  10479. break
  10480. case CMD$4.L:
  10481. fromLine(xi, yi, data[i], data[i + 1], min2, max2)
  10482. xi = data[i++]
  10483. yi = data[i++]
  10484. break
  10485. case CMD$4.C:
  10486. fromCubic(
  10487. xi,
  10488. yi,
  10489. data[i++],
  10490. data[i++],
  10491. data[i++],
  10492. data[i++],
  10493. data[i],
  10494. data[i + 1],
  10495. min2,
  10496. max2
  10497. )
  10498. xi = data[i++]
  10499. yi = data[i++]
  10500. break
  10501. case CMD$4.Q:
  10502. fromQuadratic(
  10503. xi,
  10504. yi,
  10505. data[i++],
  10506. data[i++],
  10507. data[i],
  10508. data[i + 1],
  10509. min2,
  10510. max2
  10511. )
  10512. xi = data[i++]
  10513. yi = data[i++]
  10514. break
  10515. case CMD$4.A:
  10516. var cx = data[i++]
  10517. var cy = data[i++]
  10518. var rx = data[i++]
  10519. var ry = data[i++]
  10520. var startAngle = data[i++]
  10521. var endAngle = data[i++] + startAngle
  10522. i += 1
  10523. var anticlockwise = !data[i++]
  10524. if (isFirst) {
  10525. x0 = mathCos$2(startAngle) * rx + cx
  10526. y0 = mathSin$2(startAngle) * ry + cy
  10527. }
  10528. fromArc(
  10529. cx,
  10530. cy,
  10531. rx,
  10532. ry,
  10533. startAngle,
  10534. endAngle,
  10535. anticlockwise,
  10536. min2,
  10537. max2
  10538. )
  10539. xi = mathCos$2(endAngle) * rx + cx
  10540. yi = mathSin$2(endAngle) * ry + cy
  10541. break
  10542. case CMD$4.R:
  10543. x0 = xi = data[i++]
  10544. y0 = yi = data[i++]
  10545. var width = data[i++]
  10546. var height = data[i++]
  10547. fromLine(x0, y0, x0 + width, y0 + height, min2, max2)
  10548. break
  10549. case CMD$4.Z:
  10550. xi = x0
  10551. yi = y0
  10552. break
  10553. }
  10554. min$1(min, min, min2)
  10555. max$1(max, max, max2)
  10556. }
  10557. if (i === 0) {
  10558. min[0] = min[1] = max[0] = max[1] = 0
  10559. }
  10560. return new BoundingRect$1(
  10561. min[0],
  10562. min[1],
  10563. max[0] - min[0],
  10564. max[1] - min[1]
  10565. )
  10566. }
  10567. PathProxy.prototype._calculateLength = function () {
  10568. var data = this.data
  10569. var len = this._len
  10570. var ux = this._ux
  10571. var uy = this._uy
  10572. var xi = 0
  10573. var yi = 0
  10574. var x0 = 0
  10575. var y0 = 0
  10576. if (!this._pathSegLen) {
  10577. this._pathSegLen = []
  10578. }
  10579. var pathSegLen = this._pathSegLen
  10580. var pathTotalLen = 0
  10581. var segCount = 0
  10582. for (var i = 0; i < len; ) {
  10583. var cmd = data[i++]
  10584. var isFirst = i === 1
  10585. if (isFirst) {
  10586. xi = data[i]
  10587. yi = data[i + 1]
  10588. x0 = xi
  10589. y0 = yi
  10590. }
  10591. var l = -1
  10592. switch (cmd) {
  10593. case CMD$4.M:
  10594. xi = x0 = data[i++]
  10595. yi = y0 = data[i++]
  10596. break
  10597. case CMD$4.L: {
  10598. var x2 = data[i++]
  10599. var y2 = data[i++]
  10600. var dx = x2 - xi
  10601. var dy = y2 - yi
  10602. if (
  10603. mathAbs$1(dx) > ux ||
  10604. mathAbs$1(dy) > uy ||
  10605. i === len - 1
  10606. ) {
  10607. l = Math.sqrt(dx * dx + dy * dy)
  10608. xi = x2
  10609. yi = y2
  10610. }
  10611. break
  10612. }
  10613. case CMD$4.C: {
  10614. var x1 = data[i++]
  10615. var y1 = data[i++]
  10616. var x2 = data[i++]
  10617. var y2 = data[i++]
  10618. var x3 = data[i++]
  10619. var y3 = data[i++]
  10620. l = cubicLength(xi, yi, x1, y1, x2, y2, x3, y3, 10)
  10621. xi = x3
  10622. yi = y3
  10623. break
  10624. }
  10625. case CMD$4.Q: {
  10626. var x1 = data[i++]
  10627. var y1 = data[i++]
  10628. var x2 = data[i++]
  10629. var y2 = data[i++]
  10630. l = quadraticLength(xi, yi, x1, y1, x2, y2, 10)
  10631. xi = x2
  10632. yi = y2
  10633. break
  10634. }
  10635. case CMD$4.A:
  10636. var cx = data[i++]
  10637. var cy = data[i++]
  10638. var rx = data[i++]
  10639. var ry = data[i++]
  10640. var startAngle = data[i++]
  10641. var delta = data[i++]
  10642. var endAngle = delta + startAngle
  10643. i += 1
  10644. !data[i++]
  10645. if (isFirst) {
  10646. x0 = mathCos$2(startAngle) * rx + cx
  10647. y0 = mathSin$2(startAngle) * ry + cy
  10648. }
  10649. l = mathMax$5(rx, ry) * mathMin$5(PI2$6, Math.abs(delta))
  10650. xi = mathCos$2(endAngle) * rx + cx
  10651. yi = mathSin$2(endAngle) * ry + cy
  10652. break
  10653. case CMD$4.R: {
  10654. x0 = xi = data[i++]
  10655. y0 = yi = data[i++]
  10656. var width = data[i++]
  10657. var height = data[i++]
  10658. l = width * 2 + height * 2
  10659. break
  10660. }
  10661. case CMD$4.Z: {
  10662. var dx = x0 - xi
  10663. var dy = y0 - yi
  10664. l = Math.sqrt(dx * dx + dy * dy)
  10665. xi = x0
  10666. yi = y0
  10667. break
  10668. }
  10669. }
  10670. if (l >= 0) {
  10671. pathSegLen[segCount++] = l
  10672. pathTotalLen += l
  10673. }
  10674. }
  10675. this._pathLen = pathTotalLen
  10676. return pathTotalLen
  10677. }
  10678. PathProxy.prototype.rebuildPath = function (ctx, percent) {
  10679. var d = this.data
  10680. var ux = this._ux
  10681. var uy = this._uy
  10682. var len = this._len
  10683. var x0
  10684. var y0
  10685. var xi
  10686. var yi
  10687. var x
  10688. var y
  10689. var drawPart = percent < 1
  10690. var pathSegLen
  10691. var pathTotalLen
  10692. var accumLength = 0
  10693. var segCount = 0
  10694. var displayedLength
  10695. var pendingPtDist = 0
  10696. var pendingPtX
  10697. var pendingPtY
  10698. if (drawPart) {
  10699. if (!this._pathSegLen) {
  10700. this._calculateLength()
  10701. }
  10702. pathSegLen = this._pathSegLen
  10703. pathTotalLen = this._pathLen
  10704. displayedLength = percent * pathTotalLen
  10705. if (!displayedLength) {
  10706. return
  10707. }
  10708. }
  10709. lo: for (var i = 0; i < len; ) {
  10710. var cmd = d[i++]
  10711. var isFirst = i === 1
  10712. if (isFirst) {
  10713. xi = d[i]
  10714. yi = d[i + 1]
  10715. x0 = xi
  10716. y0 = yi
  10717. }
  10718. if (cmd !== CMD$4.L && pendingPtDist > 0) {
  10719. ctx.lineTo(pendingPtX, pendingPtY)
  10720. pendingPtDist = 0
  10721. }
  10722. switch (cmd) {
  10723. case CMD$4.M:
  10724. x0 = xi = d[i++]
  10725. y0 = yi = d[i++]
  10726. ctx.moveTo(xi, yi)
  10727. break
  10728. case CMD$4.L: {
  10729. x = d[i++]
  10730. y = d[i++]
  10731. var dx = mathAbs$1(x - xi)
  10732. var dy = mathAbs$1(y - yi)
  10733. if (dx > ux || dy > uy) {
  10734. if (drawPart) {
  10735. var l = pathSegLen[segCount++]
  10736. if (accumLength + l > displayedLength) {
  10737. var t = (displayedLength - accumLength) / l
  10738. ctx.lineTo(xi * (1 - t) + x * t, yi * (1 - t) + y * t)
  10739. break lo
  10740. }
  10741. accumLength += l
  10742. }
  10743. ctx.lineTo(x, y)
  10744. xi = x
  10745. yi = y
  10746. pendingPtDist = 0
  10747. } else {
  10748. var d2 = dx * dx + dy * dy
  10749. if (d2 > pendingPtDist) {
  10750. pendingPtX = x
  10751. pendingPtY = y
  10752. pendingPtDist = d2
  10753. }
  10754. }
  10755. break
  10756. }
  10757. case CMD$4.C: {
  10758. var x1 = d[i++]
  10759. var y1 = d[i++]
  10760. var x2 = d[i++]
  10761. var y2 = d[i++]
  10762. var x3 = d[i++]
  10763. var y3 = d[i++]
  10764. if (drawPart) {
  10765. var l = pathSegLen[segCount++]
  10766. if (accumLength + l > displayedLength) {
  10767. var t = (displayedLength - accumLength) / l
  10768. cubicSubdivide(xi, x1, x2, x3, t, tmpOutX)
  10769. cubicSubdivide(yi, y1, y2, y3, t, tmpOutY)
  10770. ctx.bezierCurveTo(
  10771. tmpOutX[1],
  10772. tmpOutY[1],
  10773. tmpOutX[2],
  10774. tmpOutY[2],
  10775. tmpOutX[3],
  10776. tmpOutY[3]
  10777. )
  10778. break lo
  10779. }
  10780. accumLength += l
  10781. }
  10782. ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3)
  10783. xi = x3
  10784. yi = y3
  10785. break
  10786. }
  10787. case CMD$4.Q: {
  10788. var x1 = d[i++]
  10789. var y1 = d[i++]
  10790. var x2 = d[i++]
  10791. var y2 = d[i++]
  10792. if (drawPart) {
  10793. var l = pathSegLen[segCount++]
  10794. if (accumLength + l > displayedLength) {
  10795. var t = (displayedLength - accumLength) / l
  10796. quadraticSubdivide(xi, x1, x2, t, tmpOutX)
  10797. quadraticSubdivide(yi, y1, y2, t, tmpOutY)
  10798. ctx.quadraticCurveTo(
  10799. tmpOutX[1],
  10800. tmpOutY[1],
  10801. tmpOutX[2],
  10802. tmpOutY[2]
  10803. )
  10804. break lo
  10805. }
  10806. accumLength += l
  10807. }
  10808. ctx.quadraticCurveTo(x1, y1, x2, y2)
  10809. xi = x2
  10810. yi = y2
  10811. break
  10812. }
  10813. case CMD$4.A:
  10814. var cx = d[i++]
  10815. var cy = d[i++]
  10816. var rx = d[i++]
  10817. var ry = d[i++]
  10818. var startAngle = d[i++]
  10819. var delta = d[i++]
  10820. var psi = d[i++]
  10821. var anticlockwise = !d[i++]
  10822. var r = rx > ry ? rx : ry
  10823. var isEllipse = mathAbs$1(rx - ry) > 1e-3
  10824. var endAngle = startAngle + delta
  10825. var breakBuild = false
  10826. if (drawPart) {
  10827. var l = pathSegLen[segCount++]
  10828. if (accumLength + l > displayedLength) {
  10829. endAngle =
  10830. startAngle +
  10831. (delta * (displayedLength - accumLength)) / l
  10832. breakBuild = true
  10833. }
  10834. accumLength += l
  10835. }
  10836. if (isEllipse && ctx.ellipse) {
  10837. ctx.ellipse(
  10838. cx,
  10839. cy,
  10840. rx,
  10841. ry,
  10842. psi,
  10843. startAngle,
  10844. endAngle,
  10845. anticlockwise
  10846. )
  10847. } else {
  10848. ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise)
  10849. }
  10850. if (breakBuild) {
  10851. break lo
  10852. }
  10853. if (isFirst) {
  10854. x0 = mathCos$2(startAngle) * rx + cx
  10855. y0 = mathSin$2(startAngle) * ry + cy
  10856. }
  10857. xi = mathCos$2(endAngle) * rx + cx
  10858. yi = mathSin$2(endAngle) * ry + cy
  10859. break
  10860. case CMD$4.R:
  10861. x0 = xi = d[i]
  10862. y0 = yi = d[i + 1]
  10863. x = d[i++]
  10864. y = d[i++]
  10865. var width = d[i++]
  10866. var height = d[i++]
  10867. if (drawPart) {
  10868. var l = pathSegLen[segCount++]
  10869. if (accumLength + l > displayedLength) {
  10870. var d_1 = displayedLength - accumLength
  10871. ctx.moveTo(x, y)
  10872. ctx.lineTo(x + mathMin$5(d_1, width), y)
  10873. d_1 -= width
  10874. if (d_1 > 0) {
  10875. ctx.lineTo(x + width, y + mathMin$5(d_1, height))
  10876. }
  10877. d_1 -= height
  10878. if (d_1 > 0) {
  10879. ctx.lineTo(x + mathMax$5(width - d_1, 0), y + height)
  10880. }
  10881. d_1 -= width
  10882. if (d_1 > 0) {
  10883. ctx.lineTo(x, y + mathMax$5(height - d_1, 0))
  10884. }
  10885. break lo
  10886. }
  10887. accumLength += l
  10888. }
  10889. ctx.rect(x, y, width, height)
  10890. break
  10891. case CMD$4.Z:
  10892. if (drawPart) {
  10893. var l = pathSegLen[segCount++]
  10894. if (accumLength + l > displayedLength) {
  10895. var t = (displayedLength - accumLength) / l
  10896. ctx.lineTo(xi * (1 - t) + x0 * t, yi * (1 - t) + y0 * t)
  10897. break lo
  10898. }
  10899. accumLength += l
  10900. }
  10901. ctx.closePath()
  10902. xi = x0
  10903. yi = y0
  10904. }
  10905. }
  10906. }
  10907. PathProxy.prototype.clone = function () {
  10908. var newProxy = new PathProxy()
  10909. var data = this.data
  10910. newProxy.data = data.slice
  10911. ? data.slice()
  10912. : Array.prototype.slice.call(data)
  10913. newProxy._len = this._len
  10914. return newProxy
  10915. }
  10916. PathProxy.CMD = CMD$4
  10917. PathProxy.initDefaultProps = (function () {
  10918. var proto = PathProxy.prototype
  10919. proto._saveData = true
  10920. proto._ux = 0
  10921. proto._uy = 0
  10922. proto._pendingPtDist = 0
  10923. proto._version = 0
  10924. })()
  10925. return PathProxy
  10926. })()
  10927. var PathProxy$1 = PathProxy
  10928. function containStroke$4(x0, y0, x1, y1, lineWidth, x, y) {
  10929. if (lineWidth === 0) {
  10930. return false
  10931. }
  10932. var _l = lineWidth
  10933. var _a = 0
  10934. var _b = x0
  10935. if (
  10936. (y > y0 + _l && y > y1 + _l) ||
  10937. (y < y0 - _l && y < y1 - _l) ||
  10938. (x > x0 + _l && x > x1 + _l) ||
  10939. (x < x0 - _l && x < x1 - _l)
  10940. ) {
  10941. return false
  10942. }
  10943. if (x0 !== x1) {
  10944. _a = (y0 - y1) / (x0 - x1)
  10945. _b = (x0 * y1 - x1 * y0) / (x0 - x1)
  10946. } else {
  10947. return Math.abs(x - x0) <= _l / 2
  10948. }
  10949. var tmp = _a * x - y + _b
  10950. var _s = (tmp * tmp) / (_a * _a + 1)
  10951. return _s <= ((_l / 2) * _l) / 2
  10952. }
  10953. function containStroke$3(
  10954. x0,
  10955. y0,
  10956. x1,
  10957. y1,
  10958. x2,
  10959. y2,
  10960. x3,
  10961. y3,
  10962. lineWidth,
  10963. x,
  10964. y
  10965. ) {
  10966. if (lineWidth === 0) {
  10967. return false
  10968. }
  10969. var _l = lineWidth
  10970. if (
  10971. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l) ||
  10972. (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l) ||
  10973. (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l) ||
  10974. (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  10975. ) {
  10976. return false
  10977. }
  10978. var d = cubicProjectPoint(
  10979. x0,
  10980. y0,
  10981. x1,
  10982. y1,
  10983. x2,
  10984. y2,
  10985. x3,
  10986. y3,
  10987. x,
  10988. y,
  10989. null
  10990. )
  10991. return d <= _l / 2
  10992. }
  10993. function containStroke$2(x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  10994. if (lineWidth === 0) {
  10995. return false
  10996. }
  10997. var _l = lineWidth
  10998. if (
  10999. (y > y0 + _l && y > y1 + _l && y > y2 + _l) ||
  11000. (y < y0 - _l && y < y1 - _l && y < y2 - _l) ||
  11001. (x > x0 + _l && x > x1 + _l && x > x2 + _l) ||
  11002. (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  11003. ) {
  11004. return false
  11005. }
  11006. var d = quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, null)
  11007. return d <= _l / 2
  11008. }
  11009. var PI2$5 = Math.PI * 2
  11010. function normalizeRadian(angle) {
  11011. angle %= PI2$5
  11012. if (angle < 0) {
  11013. angle += PI2$5
  11014. }
  11015. return angle
  11016. }
  11017. var PI2$4 = Math.PI * 2
  11018. function containStroke$1(
  11019. cx,
  11020. cy,
  11021. r,
  11022. startAngle,
  11023. endAngle,
  11024. anticlockwise,
  11025. lineWidth,
  11026. x,
  11027. y
  11028. ) {
  11029. if (lineWidth === 0) {
  11030. return false
  11031. }
  11032. var _l = lineWidth
  11033. x -= cx
  11034. y -= cy
  11035. var d = Math.sqrt(x * x + y * y)
  11036. if (d - _l > r || d + _l < r) {
  11037. return false
  11038. }
  11039. if (Math.abs(startAngle - endAngle) % PI2$4 < 1e-4) {
  11040. return true
  11041. }
  11042. if (anticlockwise) {
  11043. var tmp = startAngle
  11044. startAngle = normalizeRadian(endAngle)
  11045. endAngle = normalizeRadian(tmp)
  11046. } else {
  11047. startAngle = normalizeRadian(startAngle)
  11048. endAngle = normalizeRadian(endAngle)
  11049. }
  11050. if (startAngle > endAngle) {
  11051. endAngle += PI2$4
  11052. }
  11053. var angle = Math.atan2(y, x)
  11054. if (angle < 0) {
  11055. angle += PI2$4
  11056. }
  11057. return (
  11058. (angle >= startAngle && angle <= endAngle) ||
  11059. (angle + PI2$4 >= startAngle && angle + PI2$4 <= endAngle)
  11060. )
  11061. }
  11062. function windingLine(x0, y0, x1, y1, x, y) {
  11063. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  11064. return 0
  11065. }
  11066. if (y1 === y0) {
  11067. return 0
  11068. }
  11069. var t = (y - y0) / (y1 - y0)
  11070. var dir = y1 < y0 ? 1 : -1
  11071. if (t === 1 || t === 0) {
  11072. dir = y1 < y0 ? 0.5 : -0.5
  11073. }
  11074. var x_ = t * (x1 - x0) + x0
  11075. return x_ === x ? Infinity : x_ > x ? dir : 0
  11076. }
  11077. var CMD$3 = PathProxy$1.CMD
  11078. var PI2$3 = Math.PI * 2
  11079. var EPSILON = 1e-4
  11080. function isAroundEqual(a, b) {
  11081. return Math.abs(a - b) < EPSILON
  11082. }
  11083. var roots = [-1, -1, -1]
  11084. var extrema = [-1, -1]
  11085. function swapExtrema() {
  11086. var tmp = extrema[0]
  11087. extrema[0] = extrema[1]
  11088. extrema[1] = tmp
  11089. }
  11090. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  11091. if (
  11092. (y > y0 && y > y1 && y > y2 && y > y3) ||
  11093. (y < y0 && y < y1 && y < y2 && y < y3)
  11094. ) {
  11095. return 0
  11096. }
  11097. var nRoots = cubicRootAt(y0, y1, y2, y3, y, roots)
  11098. if (nRoots === 0) {
  11099. return 0
  11100. } else {
  11101. var w = 0
  11102. var nExtrema = -1
  11103. var y0_ = void 0
  11104. var y1_ = void 0
  11105. for (var i = 0; i < nRoots; i++) {
  11106. var t = roots[i]
  11107. var unit = t === 0 || t === 1 ? 0.5 : 1
  11108. var x_ = cubicAt(x0, x1, x2, x3, t)
  11109. if (x_ < x) {
  11110. continue
  11111. }
  11112. if (nExtrema < 0) {
  11113. nExtrema = cubicExtrema(y0, y1, y2, y3, extrema)
  11114. if (extrema[1] < extrema[0] && nExtrema > 1) {
  11115. swapExtrema()
  11116. }
  11117. y0_ = cubicAt(y0, y1, y2, y3, extrema[0])
  11118. if (nExtrema > 1) {
  11119. y1_ = cubicAt(y0, y1, y2, y3, extrema[1])
  11120. }
  11121. }
  11122. if (nExtrema === 2) {
  11123. if (t < extrema[0]) {
  11124. w += y0_ < y0 ? unit : -unit
  11125. } else if (t < extrema[1]) {
  11126. w += y1_ < y0_ ? unit : -unit
  11127. } else {
  11128. w += y3 < y1_ ? unit : -unit
  11129. }
  11130. } else {
  11131. if (t < extrema[0]) {
  11132. w += y0_ < y0 ? unit : -unit
  11133. } else {
  11134. w += y3 < y0_ ? unit : -unit
  11135. }
  11136. }
  11137. }
  11138. return w
  11139. }
  11140. }
  11141. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  11142. if ((y > y0 && y > y1 && y > y2) || (y < y0 && y < y1 && y < y2)) {
  11143. return 0
  11144. }
  11145. var nRoots = quadraticRootAt(y0, y1, y2, y, roots)
  11146. if (nRoots === 0) {
  11147. return 0
  11148. } else {
  11149. var t = quadraticExtremum(y0, y1, y2)
  11150. if (t >= 0 && t <= 1) {
  11151. var w = 0
  11152. var y_ = quadraticAt(y0, y1, y2, t)
  11153. for (var i = 0; i < nRoots; i++) {
  11154. var unit = roots[i] === 0 || roots[i] === 1 ? 0.5 : 1
  11155. var x_ = quadraticAt(x0, x1, x2, roots[i])
  11156. if (x_ < x) {
  11157. continue
  11158. }
  11159. if (roots[i] < t) {
  11160. w += y_ < y0 ? unit : -unit
  11161. } else {
  11162. w += y2 < y_ ? unit : -unit
  11163. }
  11164. }
  11165. return w
  11166. } else {
  11167. var unit = roots[0] === 0 || roots[0] === 1 ? 0.5 : 1
  11168. var x_ = quadraticAt(x0, x1, x2, roots[0])
  11169. if (x_ < x) {
  11170. return 0
  11171. }
  11172. return y2 < y0 ? unit : -unit
  11173. }
  11174. }
  11175. }
  11176. function windingArc(
  11177. cx,
  11178. cy,
  11179. r,
  11180. startAngle,
  11181. endAngle,
  11182. anticlockwise,
  11183. x,
  11184. y
  11185. ) {
  11186. y -= cy
  11187. if (y > r || y < -r) {
  11188. return 0
  11189. }
  11190. var tmp = Math.sqrt(r * r - y * y)
  11191. roots[0] = -tmp
  11192. roots[1] = tmp
  11193. var dTheta = Math.abs(startAngle - endAngle)
  11194. if (dTheta < 1e-4) {
  11195. return 0
  11196. }
  11197. if (dTheta >= PI2$3 - 1e-4) {
  11198. startAngle = 0
  11199. endAngle = PI2$3
  11200. var dir = anticlockwise ? 1 : -1
  11201. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  11202. return dir
  11203. } else {
  11204. return 0
  11205. }
  11206. }
  11207. if (startAngle > endAngle) {
  11208. var tmp_1 = startAngle
  11209. startAngle = endAngle
  11210. endAngle = tmp_1
  11211. }
  11212. if (startAngle < 0) {
  11213. startAngle += PI2$3
  11214. endAngle += PI2$3
  11215. }
  11216. var w = 0
  11217. for (var i = 0; i < 2; i++) {
  11218. var x_ = roots[i]
  11219. if (x_ + cx > x) {
  11220. var angle = Math.atan2(y, x_)
  11221. var dir = anticlockwise ? 1 : -1
  11222. if (angle < 0) {
  11223. angle = PI2$3 + angle
  11224. }
  11225. if (
  11226. (angle >= startAngle && angle <= endAngle) ||
  11227. (angle + PI2$3 >= startAngle && angle + PI2$3 <= endAngle)
  11228. ) {
  11229. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  11230. dir = -dir
  11231. }
  11232. w += dir
  11233. }
  11234. }
  11235. }
  11236. return w
  11237. }
  11238. function containPath(path, lineWidth, isStroke, x, y) {
  11239. var data = path.data
  11240. var len = path.len()
  11241. var w = 0
  11242. var xi = 0
  11243. var yi = 0
  11244. var x0 = 0
  11245. var y0 = 0
  11246. var x1
  11247. var y1
  11248. for (var i = 0; i < len; ) {
  11249. var cmd = data[i++]
  11250. var isFirst = i === 1
  11251. if (cmd === CMD$3.M && i > 1) {
  11252. if (!isStroke) {
  11253. w += windingLine(xi, yi, x0, y0, x, y)
  11254. }
  11255. }
  11256. if (isFirst) {
  11257. xi = data[i]
  11258. yi = data[i + 1]
  11259. x0 = xi
  11260. y0 = yi
  11261. }
  11262. switch (cmd) {
  11263. case CMD$3.M:
  11264. x0 = data[i++]
  11265. y0 = data[i++]
  11266. xi = x0
  11267. yi = y0
  11268. break
  11269. case CMD$3.L:
  11270. if (isStroke) {
  11271. if (
  11272. containStroke$4(
  11273. xi,
  11274. yi,
  11275. data[i],
  11276. data[i + 1],
  11277. lineWidth,
  11278. x,
  11279. y
  11280. )
  11281. ) {
  11282. return true
  11283. }
  11284. } else {
  11285. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0
  11286. }
  11287. xi = data[i++]
  11288. yi = data[i++]
  11289. break
  11290. case CMD$3.C:
  11291. if (isStroke) {
  11292. if (
  11293. containStroke$3(
  11294. xi,
  11295. yi,
  11296. data[i++],
  11297. data[i++],
  11298. data[i++],
  11299. data[i++],
  11300. data[i],
  11301. data[i + 1],
  11302. lineWidth,
  11303. x,
  11304. y
  11305. )
  11306. ) {
  11307. return true
  11308. }
  11309. } else {
  11310. w +=
  11311. windingCubic(
  11312. xi,
  11313. yi,
  11314. data[i++],
  11315. data[i++],
  11316. data[i++],
  11317. data[i++],
  11318. data[i],
  11319. data[i + 1],
  11320. x,
  11321. y
  11322. ) || 0
  11323. }
  11324. xi = data[i++]
  11325. yi = data[i++]
  11326. break
  11327. case CMD$3.Q:
  11328. if (isStroke) {
  11329. if (
  11330. containStroke$2(
  11331. xi,
  11332. yi,
  11333. data[i++],
  11334. data[i++],
  11335. data[i],
  11336. data[i + 1],
  11337. lineWidth,
  11338. x,
  11339. y
  11340. )
  11341. ) {
  11342. return true
  11343. }
  11344. } else {
  11345. w +=
  11346. windingQuadratic(
  11347. xi,
  11348. yi,
  11349. data[i++],
  11350. data[i++],
  11351. data[i],
  11352. data[i + 1],
  11353. x,
  11354. y
  11355. ) || 0
  11356. }
  11357. xi = data[i++]
  11358. yi = data[i++]
  11359. break
  11360. case CMD$3.A:
  11361. var cx = data[i++]
  11362. var cy = data[i++]
  11363. var rx = data[i++]
  11364. var ry = data[i++]
  11365. var theta = data[i++]
  11366. var dTheta = data[i++]
  11367. i += 1
  11368. var anticlockwise = !!(1 - data[i++])
  11369. x1 = Math.cos(theta) * rx + cx
  11370. y1 = Math.sin(theta) * ry + cy
  11371. if (!isFirst) {
  11372. w += windingLine(xi, yi, x1, y1, x, y)
  11373. } else {
  11374. x0 = x1
  11375. y0 = y1
  11376. }
  11377. var _x = ((x - cx) * ry) / rx + cx
  11378. if (isStroke) {
  11379. if (
  11380. containStroke$1(
  11381. cx,
  11382. cy,
  11383. ry,
  11384. theta,
  11385. theta + dTheta,
  11386. anticlockwise,
  11387. lineWidth,
  11388. _x,
  11389. y
  11390. )
  11391. ) {
  11392. return true
  11393. }
  11394. } else {
  11395. w += windingArc(
  11396. cx,
  11397. cy,
  11398. ry,
  11399. theta,
  11400. theta + dTheta,
  11401. anticlockwise,
  11402. _x,
  11403. y
  11404. )
  11405. }
  11406. xi = Math.cos(theta + dTheta) * rx + cx
  11407. yi = Math.sin(theta + dTheta) * ry + cy
  11408. break
  11409. case CMD$3.R:
  11410. x0 = xi = data[i++]
  11411. y0 = yi = data[i++]
  11412. var width = data[i++]
  11413. var height = data[i++]
  11414. x1 = x0 + width
  11415. y1 = y0 + height
  11416. if (isStroke) {
  11417. if (
  11418. containStroke$4(x0, y0, x1, y0, lineWidth, x, y) ||
  11419. containStroke$4(x1, y0, x1, y1, lineWidth, x, y) ||
  11420. containStroke$4(x1, y1, x0, y1, lineWidth, x, y) ||
  11421. containStroke$4(x0, y1, x0, y0, lineWidth, x, y)
  11422. ) {
  11423. return true
  11424. }
  11425. } else {
  11426. w += windingLine(x1, y0, x1, y1, x, y)
  11427. w += windingLine(x0, y1, x0, y0, x, y)
  11428. }
  11429. break
  11430. case CMD$3.Z:
  11431. if (isStroke) {
  11432. if (containStroke$4(xi, yi, x0, y0, lineWidth, x, y)) {
  11433. return true
  11434. }
  11435. } else {
  11436. w += windingLine(xi, yi, x0, y0, x, y)
  11437. }
  11438. xi = x0
  11439. yi = y0
  11440. break
  11441. }
  11442. }
  11443. if (!isStroke && !isAroundEqual(yi, y0)) {
  11444. w += windingLine(xi, yi, x0, y0, x, y) || 0
  11445. }
  11446. return w !== 0
  11447. }
  11448. function contain$1(pathProxy, x, y) {
  11449. return containPath(pathProxy, 0, false, x, y)
  11450. }
  11451. function containStroke(pathProxy, lineWidth, x, y) {
  11452. return containPath(pathProxy, lineWidth, true, x, y)
  11453. }
  11454. var DEFAULT_PATH_STYLE = defaults(
  11455. {
  11456. fill: '#000',
  11457. stroke: null,
  11458. strokePercent: 1,
  11459. fillOpacity: 1,
  11460. strokeOpacity: 1,
  11461. lineDashOffset: 0,
  11462. lineWidth: 1,
  11463. lineCap: 'butt',
  11464. miterLimit: 10,
  11465. strokeNoScale: false,
  11466. strokeFirst: false
  11467. },
  11468. DEFAULT_COMMON_STYLE
  11469. )
  11470. var DEFAULT_PATH_ANIMATION_PROPS = {
  11471. style: defaults(
  11472. {
  11473. fill: true,
  11474. stroke: true,
  11475. strokePercent: true,
  11476. fillOpacity: true,
  11477. strokeOpacity: true,
  11478. lineDashOffset: true,
  11479. lineWidth: true,
  11480. miterLimit: true
  11481. },
  11482. DEFAULT_COMMON_ANIMATION_PROPS.style
  11483. )
  11484. }
  11485. var pathCopyParams = TRANSFORMABLE_PROPS.concat([
  11486. 'invisible',
  11487. 'culling',
  11488. 'z',
  11489. 'z2',
  11490. 'zlevel',
  11491. 'parent'
  11492. ])
  11493. var Path = (function (_super) {
  11494. __extends(Path, _super)
  11495. function Path(opts) {
  11496. return _super.call(this, opts) || this
  11497. }
  11498. Path.prototype.update = function () {
  11499. var _this = this
  11500. _super.prototype.update.call(this)
  11501. var style = this.style
  11502. if (style.decal) {
  11503. var decalEl = (this._decalEl = this._decalEl || new Path())
  11504. if (decalEl.buildPath === Path.prototype.buildPath) {
  11505. decalEl.buildPath = function (ctx) {
  11506. _this.buildPath(ctx, _this.shape)
  11507. }
  11508. }
  11509. decalEl.silent = true
  11510. var decalElStyle = decalEl.style
  11511. for (var key in style) {
  11512. if (decalElStyle[key] !== style[key]) {
  11513. decalElStyle[key] = style[key]
  11514. }
  11515. }
  11516. decalElStyle.fill = style.fill ? style.decal : null
  11517. decalElStyle.decal = null
  11518. decalElStyle.shadowColor = null
  11519. style.strokeFirst && (decalElStyle.stroke = null)
  11520. for (var i = 0; i < pathCopyParams.length; ++i) {
  11521. decalEl[pathCopyParams[i]] = this[pathCopyParams[i]]
  11522. }
  11523. decalEl.__dirty |= REDRAW_BIT
  11524. } else if (this._decalEl) {
  11525. this._decalEl = null
  11526. }
  11527. }
  11528. Path.prototype.getDecalElement = function () {
  11529. return this._decalEl
  11530. }
  11531. Path.prototype._init = function (props) {
  11532. var keysArr = keys(props)
  11533. this.shape = this.getDefaultShape()
  11534. var defaultStyle = this.getDefaultStyle()
  11535. if (defaultStyle) {
  11536. this.useStyle(defaultStyle)
  11537. }
  11538. for (var i = 0; i < keysArr.length; i++) {
  11539. var key = keysArr[i]
  11540. var value = props[key]
  11541. if (key === 'style') {
  11542. if (!this.style) {
  11543. this.useStyle(value)
  11544. } else {
  11545. extend(this.style, value)
  11546. }
  11547. } else if (key === 'shape') {
  11548. extend(this.shape, value)
  11549. } else {
  11550. _super.prototype.attrKV.call(this, key, value)
  11551. }
  11552. }
  11553. if (!this.style) {
  11554. this.useStyle({})
  11555. }
  11556. }
  11557. Path.prototype.getDefaultStyle = function () {
  11558. return null
  11559. }
  11560. Path.prototype.getDefaultShape = function () {
  11561. return {}
  11562. }
  11563. Path.prototype.canBeInsideText = function () {
  11564. return this.hasFill()
  11565. }
  11566. Path.prototype.getInsideTextFill = function () {
  11567. var pathFill = this.style.fill
  11568. if (pathFill !== 'none') {
  11569. if (isString(pathFill)) {
  11570. var fillLum = lum(pathFill, 0)
  11571. if (fillLum > 0.5) {
  11572. return DARK_LABEL_COLOR
  11573. } else if (fillLum > 0.2) {
  11574. return LIGHTER_LABEL_COLOR
  11575. }
  11576. return LIGHT_LABEL_COLOR
  11577. } else if (pathFill) {
  11578. return LIGHT_LABEL_COLOR
  11579. }
  11580. }
  11581. return DARK_LABEL_COLOR
  11582. }
  11583. Path.prototype.getInsideTextStroke = function (textFill) {
  11584. var pathFill = this.style.fill
  11585. if (isString(pathFill)) {
  11586. var zr = this.__zr
  11587. var isDarkMode = !!(zr && zr.isDarkMode())
  11588. var isDarkLabel = lum(textFill, 0) < DARK_MODE_THRESHOLD
  11589. if (isDarkMode === isDarkLabel) {
  11590. return pathFill
  11591. }
  11592. }
  11593. }
  11594. Path.prototype.buildPath = function (ctx, shapeCfg, inBatch) {}
  11595. Path.prototype.pathUpdated = function () {
  11596. this.__dirty &= ~SHAPE_CHANGED_BIT
  11597. }
  11598. Path.prototype.getUpdatedPathProxy = function (inBatch) {
  11599. !this.path && this.createPathProxy()
  11600. this.path.beginPath()
  11601. this.buildPath(this.path, this.shape, inBatch)
  11602. return this.path
  11603. }
  11604. Path.prototype.createPathProxy = function () {
  11605. this.path = new PathProxy$1(false)
  11606. }
  11607. Path.prototype.hasStroke = function () {
  11608. var style = this.style
  11609. var stroke = style.stroke
  11610. return !(
  11611. stroke == null ||
  11612. stroke === 'none' ||
  11613. !(style.lineWidth > 0)
  11614. )
  11615. }
  11616. Path.prototype.hasFill = function () {
  11617. var style = this.style
  11618. var fill = style.fill
  11619. return fill != null && fill !== 'none'
  11620. }
  11621. Path.prototype.getBoundingRect = function () {
  11622. var rect = this._rect
  11623. var style = this.style
  11624. var needsUpdateRect = !rect
  11625. if (needsUpdateRect) {
  11626. var firstInvoke = false
  11627. if (!this.path) {
  11628. firstInvoke = true
  11629. this.createPathProxy()
  11630. }
  11631. var path = this.path
  11632. if (firstInvoke || this.__dirty & SHAPE_CHANGED_BIT) {
  11633. path.beginPath()
  11634. this.buildPath(path, this.shape, false)
  11635. this.pathUpdated()
  11636. }
  11637. rect = path.getBoundingRect()
  11638. }
  11639. this._rect = rect
  11640. if (this.hasStroke() && this.path && this.path.len() > 0) {
  11641. var rectStroke =
  11642. this._rectStroke || (this._rectStroke = rect.clone())
  11643. if (this.__dirty || needsUpdateRect) {
  11644. rectStroke.copy(rect)
  11645. var lineScale = style.strokeNoScale ? this.getLineScale() : 1
  11646. var w = style.lineWidth
  11647. if (!this.hasFill()) {
  11648. var strokeContainThreshold = this.strokeContainThreshold
  11649. w = Math.max(
  11650. w,
  11651. strokeContainThreshold == null
  11652. ? 4
  11653. : strokeContainThreshold
  11654. )
  11655. }
  11656. if (lineScale > 1e-10) {
  11657. rectStroke.width += w / lineScale
  11658. rectStroke.height += w / lineScale
  11659. rectStroke.x -= w / lineScale / 2
  11660. rectStroke.y -= w / lineScale / 2
  11661. }
  11662. }
  11663. return rectStroke
  11664. }
  11665. return rect
  11666. }
  11667. Path.prototype.contain = function (x, y) {
  11668. var localPos = this.transformCoordToLocal(x, y)
  11669. var rect = this.getBoundingRect()
  11670. var style = this.style
  11671. x = localPos[0]
  11672. y = localPos[1]
  11673. if (rect.contain(x, y)) {
  11674. var pathProxy = this.path
  11675. if (this.hasStroke()) {
  11676. var lineWidth = style.lineWidth
  11677. var lineScale = style.strokeNoScale ? this.getLineScale() : 1
  11678. if (lineScale > 1e-10) {
  11679. if (!this.hasFill()) {
  11680. lineWidth = Math.max(
  11681. lineWidth,
  11682. this.strokeContainThreshold
  11683. )
  11684. }
  11685. if (containStroke(pathProxy, lineWidth / lineScale, x, y)) {
  11686. return true
  11687. }
  11688. }
  11689. }
  11690. if (this.hasFill()) {
  11691. return contain$1(pathProxy, x, y)
  11692. }
  11693. }
  11694. return false
  11695. }
  11696. Path.prototype.dirtyShape = function () {
  11697. this.__dirty |= SHAPE_CHANGED_BIT
  11698. if (this._rect) {
  11699. this._rect = null
  11700. }
  11701. if (this._decalEl) {
  11702. this._decalEl.dirtyShape()
  11703. }
  11704. this.markRedraw()
  11705. }
  11706. Path.prototype.dirty = function () {
  11707. this.dirtyStyle()
  11708. this.dirtyShape()
  11709. }
  11710. Path.prototype.animateShape = function (loop) {
  11711. return this.animate('shape', loop)
  11712. }
  11713. Path.prototype.updateDuringAnimation = function (targetKey) {
  11714. if (targetKey === 'style') {
  11715. this.dirtyStyle()
  11716. } else if (targetKey === 'shape') {
  11717. this.dirtyShape()
  11718. } else {
  11719. this.markRedraw()
  11720. }
  11721. }
  11722. Path.prototype.attrKV = function (key, value) {
  11723. if (key === 'shape') {
  11724. this.setShape(value)
  11725. } else {
  11726. _super.prototype.attrKV.call(this, key, value)
  11727. }
  11728. }
  11729. Path.prototype.setShape = function (keyOrObj, value) {
  11730. var shape = this.shape
  11731. if (!shape) {
  11732. shape = this.shape = {}
  11733. }
  11734. if (typeof keyOrObj === 'string') {
  11735. shape[keyOrObj] = value
  11736. } else {
  11737. extend(shape, keyOrObj)
  11738. }
  11739. this.dirtyShape()
  11740. return this
  11741. }
  11742. Path.prototype.shapeChanged = function () {
  11743. return !!(this.__dirty & SHAPE_CHANGED_BIT)
  11744. }
  11745. Path.prototype.createStyle = function (obj) {
  11746. return createObject(DEFAULT_PATH_STYLE, obj)
  11747. }
  11748. Path.prototype._innerSaveToNormal = function (toState) {
  11749. _super.prototype._innerSaveToNormal.call(this, toState)
  11750. var normalState = this._normalState
  11751. if (toState.shape && !normalState.shape) {
  11752. normalState.shape = extend({}, this.shape)
  11753. }
  11754. }
  11755. Path.prototype._applyStateObj = function (
  11756. stateName,
  11757. state,
  11758. normalState,
  11759. keepCurrentStates,
  11760. transition,
  11761. animationCfg
  11762. ) {
  11763. _super.prototype._applyStateObj.call(
  11764. this,
  11765. stateName,
  11766. state,
  11767. normalState,
  11768. keepCurrentStates,
  11769. transition,
  11770. animationCfg
  11771. )
  11772. var needsRestoreToNormal = !(state && keepCurrentStates)
  11773. var targetShape
  11774. if (state && state.shape) {
  11775. if (transition) {
  11776. if (keepCurrentStates) {
  11777. targetShape = state.shape
  11778. } else {
  11779. targetShape = extend({}, normalState.shape)
  11780. extend(targetShape, state.shape)
  11781. }
  11782. } else {
  11783. targetShape = extend(
  11784. {},
  11785. keepCurrentStates ? this.shape : normalState.shape
  11786. )
  11787. extend(targetShape, state.shape)
  11788. }
  11789. } else if (needsRestoreToNormal) {
  11790. targetShape = normalState.shape
  11791. }
  11792. if (targetShape) {
  11793. if (transition) {
  11794. this.shape = extend({}, this.shape)
  11795. var targetShapePrimaryProps = {}
  11796. var shapeKeys = keys(targetShape)
  11797. for (var i = 0; i < shapeKeys.length; i++) {
  11798. var key = shapeKeys[i]
  11799. if (_typeof(targetShape[key]) === 'object') {
  11800. this.shape[key] = targetShape[key]
  11801. } else {
  11802. targetShapePrimaryProps[key] = targetShape[key]
  11803. }
  11804. }
  11805. this._transitionState(
  11806. stateName,
  11807. { shape: targetShapePrimaryProps },
  11808. animationCfg
  11809. )
  11810. } else {
  11811. this.shape = targetShape
  11812. this.dirtyShape()
  11813. }
  11814. }
  11815. }
  11816. Path.prototype._mergeStates = function (states) {
  11817. var mergedState = _super.prototype._mergeStates.call(this, states)
  11818. var mergedShape
  11819. for (var i = 0; i < states.length; i++) {
  11820. var state = states[i]
  11821. if (state.shape) {
  11822. mergedShape = mergedShape || {}
  11823. this._mergeStyle(mergedShape, state.shape)
  11824. }
  11825. }
  11826. if (mergedShape) {
  11827. mergedState.shape = mergedShape
  11828. }
  11829. return mergedState
  11830. }
  11831. Path.prototype.getAnimationStyleProps = function () {
  11832. return DEFAULT_PATH_ANIMATION_PROPS
  11833. }
  11834. Path.prototype.isZeroArea = function () {
  11835. return false
  11836. }
  11837. Path.extend = function (defaultProps) {
  11838. var Sub = (function (_super) {
  11839. __extends(Sub, _super)
  11840. function Sub(opts) {
  11841. var _this = _super.call(this, opts) || this
  11842. defaultProps.init && defaultProps.init.call(_this, opts)
  11843. return _this
  11844. }
  11845. Sub.prototype.getDefaultStyle = function () {
  11846. return clone$3(defaultProps.style)
  11847. }
  11848. Sub.prototype.getDefaultShape = function () {
  11849. return clone$3(defaultProps.shape)
  11850. }
  11851. return Sub
  11852. })(Path)
  11853. for (var key in defaultProps) {
  11854. if (typeof defaultProps[key] === 'function') {
  11855. Sub.prototype[key] = defaultProps[key]
  11856. }
  11857. }
  11858. return Sub
  11859. }
  11860. Path.initDefaultProps = (function () {
  11861. var pathProto = Path.prototype
  11862. pathProto.type = 'path'
  11863. pathProto.strokeContainThreshold = 5
  11864. pathProto.segmentIgnoreThreshold = 0
  11865. pathProto.subPixelOptimize = false
  11866. pathProto.autoBatch = false
  11867. pathProto.__dirty =
  11868. REDRAW_BIT | STYLE_CHANGED_BIT | SHAPE_CHANGED_BIT
  11869. })()
  11870. return Path
  11871. })(Displayable$1)
  11872. var Path$1 = Path
  11873. var DEFAULT_TSPAN_STYLE = defaults(
  11874. {
  11875. strokeFirst: true,
  11876. font: DEFAULT_FONT,
  11877. x: 0,
  11878. y: 0,
  11879. textAlign: 'left',
  11880. textBaseline: 'top',
  11881. miterLimit: 2
  11882. },
  11883. DEFAULT_PATH_STYLE
  11884. )
  11885. var TSpan = (function (_super) {
  11886. __extends(TSpan, _super)
  11887. function TSpan() {
  11888. return (_super !== null && _super.apply(this, arguments)) || this
  11889. }
  11890. TSpan.prototype.hasStroke = function () {
  11891. var style = this.style
  11892. var stroke = style.stroke
  11893. return stroke != null && stroke !== 'none' && style.lineWidth > 0
  11894. }
  11895. TSpan.prototype.hasFill = function () {
  11896. var style = this.style
  11897. var fill = style.fill
  11898. return fill != null && fill !== 'none'
  11899. }
  11900. TSpan.prototype.createStyle = function (obj) {
  11901. return createObject(DEFAULT_TSPAN_STYLE, obj)
  11902. }
  11903. TSpan.prototype.setBoundingRect = function (rect) {
  11904. this._rect = rect
  11905. }
  11906. TSpan.prototype.getBoundingRect = function () {
  11907. var style = this.style
  11908. if (!this._rect) {
  11909. var text = style.text
  11910. text != null ? (text += '') : (text = '')
  11911. var rect = getBoundingRect(
  11912. text,
  11913. style.font,
  11914. style.textAlign,
  11915. style.textBaseline
  11916. )
  11917. rect.x += style.x || 0
  11918. rect.y += style.y || 0
  11919. if (this.hasStroke()) {
  11920. var w = style.lineWidth
  11921. rect.x -= w / 2
  11922. rect.y -= w / 2
  11923. rect.width += w
  11924. rect.height += w
  11925. }
  11926. this._rect = rect
  11927. }
  11928. return this._rect
  11929. }
  11930. TSpan.initDefaultProps = (function () {
  11931. var tspanProto = TSpan.prototype
  11932. tspanProto.dirtyRectTolerance = 10
  11933. })()
  11934. return TSpan
  11935. })(Displayable$1)
  11936. TSpan.prototype.type = 'tspan'
  11937. var TSpan$1 = TSpan
  11938. var DEFAULT_IMAGE_STYLE = defaults(
  11939. { x: 0, y: 0 },
  11940. DEFAULT_COMMON_STYLE
  11941. )
  11942. var DEFAULT_IMAGE_ANIMATION_PROPS = {
  11943. style: defaults(
  11944. {
  11945. x: true,
  11946. y: true,
  11947. width: true,
  11948. height: true,
  11949. sx: true,
  11950. sy: true,
  11951. sWidth: true,
  11952. sHeight: true
  11953. },
  11954. DEFAULT_COMMON_ANIMATION_PROPS.style
  11955. )
  11956. }
  11957. function isImageLike(source) {
  11958. return !!(
  11959. source &&
  11960. typeof source !== 'string' &&
  11961. source.width &&
  11962. source.height
  11963. )
  11964. }
  11965. var ZRImage = (function (_super) {
  11966. __extends(ZRImage, _super)
  11967. function ZRImage() {
  11968. return (_super !== null && _super.apply(this, arguments)) || this
  11969. }
  11970. ZRImage.prototype.createStyle = function (obj) {
  11971. return createObject(DEFAULT_IMAGE_STYLE, obj)
  11972. }
  11973. ZRImage.prototype._getSize = function (dim) {
  11974. var style = this.style
  11975. var size = style[dim]
  11976. if (size != null) {
  11977. return size
  11978. }
  11979. var imageSource = isImageLike(style.image)
  11980. ? style.image
  11981. : this.__image
  11982. if (!imageSource) {
  11983. return 0
  11984. }
  11985. var otherDim = dim === 'width' ? 'height' : 'width'
  11986. var otherDimSize = style[otherDim]
  11987. if (otherDimSize == null) {
  11988. return imageSource[dim]
  11989. } else {
  11990. return (imageSource[dim] / imageSource[otherDim]) * otherDimSize
  11991. }
  11992. }
  11993. ZRImage.prototype.getWidth = function () {
  11994. return this._getSize('width')
  11995. }
  11996. ZRImage.prototype.getHeight = function () {
  11997. return this._getSize('height')
  11998. }
  11999. ZRImage.prototype.getAnimationStyleProps = function () {
  12000. return DEFAULT_IMAGE_ANIMATION_PROPS
  12001. }
  12002. ZRImage.prototype.getBoundingRect = function () {
  12003. var style = this.style
  12004. if (!this._rect) {
  12005. this._rect = new BoundingRect$1(
  12006. style.x || 0,
  12007. style.y || 0,
  12008. this.getWidth(),
  12009. this.getHeight()
  12010. )
  12011. }
  12012. return this._rect
  12013. }
  12014. return ZRImage
  12015. })(Displayable$1)
  12016. ZRImage.prototype.type = 'image'
  12017. var ZRImage$1 = ZRImage
  12018. function buildPath$2(ctx, shape) {
  12019. var x = shape.x
  12020. var y = shape.y
  12021. var width = shape.width
  12022. var height = shape.height
  12023. var r = shape.r
  12024. var r1
  12025. var r2
  12026. var r3
  12027. var r4
  12028. if (width < 0) {
  12029. x = x + width
  12030. width = -width
  12031. }
  12032. if (height < 0) {
  12033. y = y + height
  12034. height = -height
  12035. }
  12036. if (typeof r === 'number') {
  12037. r1 = r2 = r3 = r4 = r
  12038. } else if (r instanceof Array) {
  12039. if (r.length === 1) {
  12040. r1 = r2 = r3 = r4 = r[0]
  12041. } else if (r.length === 2) {
  12042. r1 = r3 = r[0]
  12043. r2 = r4 = r[1]
  12044. } else if (r.length === 3) {
  12045. r1 = r[0]
  12046. r2 = r4 = r[1]
  12047. r3 = r[2]
  12048. } else {
  12049. r1 = r[0]
  12050. r2 = r[1]
  12051. r3 = r[2]
  12052. r4 = r[3]
  12053. }
  12054. } else {
  12055. r1 = r2 = r3 = r4 = 0
  12056. }
  12057. var total
  12058. if (r1 + r2 > width) {
  12059. total = r1 + r2
  12060. r1 *= width / total
  12061. r2 *= width / total
  12062. }
  12063. if (r3 + r4 > width) {
  12064. total = r3 + r4
  12065. r3 *= width / total
  12066. r4 *= width / total
  12067. }
  12068. if (r2 + r3 > height) {
  12069. total = r2 + r3
  12070. r2 *= height / total
  12071. r3 *= height / total
  12072. }
  12073. if (r1 + r4 > height) {
  12074. total = r1 + r4
  12075. r1 *= height / total
  12076. r4 *= height / total
  12077. }
  12078. ctx.moveTo(x + r1, y)
  12079. ctx.lineTo(x + width - r2, y)
  12080. r2 !== 0 && ctx.arc(x + width - r2, y + r2, r2, -Math.PI / 2, 0)
  12081. ctx.lineTo(x + width, y + height - r3)
  12082. r3 !== 0 &&
  12083. ctx.arc(x + width - r3, y + height - r3, r3, 0, Math.PI / 2)
  12084. ctx.lineTo(x + r4, y + height)
  12085. r4 !== 0 &&
  12086. ctx.arc(x + r4, y + height - r4, r4, Math.PI / 2, Math.PI)
  12087. ctx.lineTo(x, y + r1)
  12088. r1 !== 0 && ctx.arc(x + r1, y + r1, r1, Math.PI, Math.PI * 1.5)
  12089. }
  12090. var round = Math.round
  12091. function subPixelOptimizeLine$1(outputShape, inputShape, style) {
  12092. if (!inputShape) {
  12093. return
  12094. }
  12095. var x1 = inputShape.x1
  12096. var x2 = inputShape.x2
  12097. var y1 = inputShape.y1
  12098. var y2 = inputShape.y2
  12099. outputShape.x1 = x1
  12100. outputShape.x2 = x2
  12101. outputShape.y1 = y1
  12102. outputShape.y2 = y2
  12103. var lineWidth = style && style.lineWidth
  12104. if (!lineWidth) {
  12105. return outputShape
  12106. }
  12107. if (round(x1 * 2) === round(x2 * 2)) {
  12108. outputShape.x1 = outputShape.x2 = subPixelOptimize$1(
  12109. x1,
  12110. lineWidth,
  12111. true
  12112. )
  12113. }
  12114. if (round(y1 * 2) === round(y2 * 2)) {
  12115. outputShape.y1 = outputShape.y2 = subPixelOptimize$1(
  12116. y1,
  12117. lineWidth,
  12118. true
  12119. )
  12120. }
  12121. return outputShape
  12122. }
  12123. function subPixelOptimizeRect$1(outputShape, inputShape, style) {
  12124. if (!inputShape) {
  12125. return
  12126. }
  12127. var originX = inputShape.x
  12128. var originY = inputShape.y
  12129. var originWidth = inputShape.width
  12130. var originHeight = inputShape.height
  12131. outputShape.x = originX
  12132. outputShape.y = originY
  12133. outputShape.width = originWidth
  12134. outputShape.height = originHeight
  12135. var lineWidth = style && style.lineWidth
  12136. if (!lineWidth) {
  12137. return outputShape
  12138. }
  12139. outputShape.x = subPixelOptimize$1(originX, lineWidth, true)
  12140. outputShape.y = subPixelOptimize$1(originY, lineWidth, true)
  12141. outputShape.width = Math.max(
  12142. subPixelOptimize$1(originX + originWidth, lineWidth, false) -
  12143. outputShape.x,
  12144. originWidth === 0 ? 0 : 1
  12145. )
  12146. outputShape.height = Math.max(
  12147. subPixelOptimize$1(originY + originHeight, lineWidth, false) -
  12148. outputShape.y,
  12149. originHeight === 0 ? 0 : 1
  12150. )
  12151. return outputShape
  12152. }
  12153. function subPixelOptimize$1(position, lineWidth, positiveOrNegative) {
  12154. if (!lineWidth) {
  12155. return position
  12156. }
  12157. var doubledPosition = round(position * 2)
  12158. return (doubledPosition + round(lineWidth)) % 2 === 0
  12159. ? doubledPosition / 2
  12160. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2
  12161. }
  12162. var RectShape = (function () {
  12163. function RectShape() {
  12164. this.x = 0
  12165. this.y = 0
  12166. this.width = 0
  12167. this.height = 0
  12168. }
  12169. return RectShape
  12170. })()
  12171. var subPixelOptimizeOutputShape$1 = {}
  12172. var Rect$1 = (function (_super) {
  12173. __extends(Rect, _super)
  12174. function Rect(opts) {
  12175. return _super.call(this, opts) || this
  12176. }
  12177. Rect.prototype.getDefaultShape = function () {
  12178. return new RectShape()
  12179. }
  12180. Rect.prototype.buildPath = function (ctx, shape) {
  12181. var x
  12182. var y
  12183. var width
  12184. var height
  12185. if (this.subPixelOptimize) {
  12186. var optimizedShape = subPixelOptimizeRect$1(
  12187. subPixelOptimizeOutputShape$1,
  12188. shape,
  12189. this.style
  12190. )
  12191. x = optimizedShape.x
  12192. y = optimizedShape.y
  12193. width = optimizedShape.width
  12194. height = optimizedShape.height
  12195. optimizedShape.r = shape.r
  12196. shape = optimizedShape
  12197. } else {
  12198. x = shape.x
  12199. y = shape.y
  12200. width = shape.width
  12201. height = shape.height
  12202. }
  12203. if (!shape.r) {
  12204. ctx.rect(x, y, width, height)
  12205. } else {
  12206. buildPath$2(ctx, shape)
  12207. }
  12208. }
  12209. Rect.prototype.isZeroArea = function () {
  12210. return !this.shape.width || !this.shape.height
  12211. }
  12212. return Rect
  12213. })(Path$1)
  12214. Rect$1.prototype.type = 'rect'
  12215. var Rect$2 = Rect$1
  12216. var DEFAULT_RICH_TEXT_COLOR = { fill: '#000' }
  12217. var DEFAULT_STROKE_LINE_WIDTH = 2
  12218. var DEFAULT_TEXT_ANIMATION_PROPS = {
  12219. style: defaults(
  12220. {
  12221. fill: true,
  12222. stroke: true,
  12223. fillOpacity: true,
  12224. strokeOpacity: true,
  12225. lineWidth: true,
  12226. fontSize: true,
  12227. lineHeight: true,
  12228. width: true,
  12229. height: true,
  12230. textShadowColor: true,
  12231. textShadowBlur: true,
  12232. textShadowOffsetX: true,
  12233. textShadowOffsetY: true,
  12234. backgroundColor: true,
  12235. padding: true,
  12236. borderColor: true,
  12237. borderWidth: true,
  12238. borderRadius: true
  12239. },
  12240. DEFAULT_COMMON_ANIMATION_PROPS.style
  12241. )
  12242. }
  12243. var ZRText = (function (_super) {
  12244. __extends(ZRText, _super)
  12245. function ZRText(opts) {
  12246. var _this = _super.call(this) || this
  12247. _this.type = 'text'
  12248. _this._children = []
  12249. _this._defaultStyle = DEFAULT_RICH_TEXT_COLOR
  12250. _this.attr(opts)
  12251. return _this
  12252. }
  12253. ZRText.prototype.childrenRef = function () {
  12254. return this._children
  12255. }
  12256. ZRText.prototype.update = function () {
  12257. _super.prototype.update.call(this)
  12258. if (this.styleChanged()) {
  12259. this._updateSubTexts()
  12260. }
  12261. for (var i = 0; i < this._children.length; i++) {
  12262. var child = this._children[i]
  12263. child.zlevel = this.zlevel
  12264. child.z = this.z
  12265. child.z2 = this.z2
  12266. child.culling = this.culling
  12267. child.cursor = this.cursor
  12268. child.invisible = this.invisible
  12269. }
  12270. }
  12271. ZRText.prototype.updateTransform = function () {
  12272. var innerTransformable = this.innerTransformable
  12273. if (innerTransformable) {
  12274. innerTransformable.updateTransform()
  12275. if (innerTransformable.transform) {
  12276. this.transform = innerTransformable.transform
  12277. }
  12278. } else {
  12279. _super.prototype.updateTransform.call(this)
  12280. }
  12281. }
  12282. ZRText.prototype.getLocalTransform = function (m) {
  12283. var innerTransformable = this.innerTransformable
  12284. return innerTransformable
  12285. ? innerTransformable.getLocalTransform(m)
  12286. : _super.prototype.getLocalTransform.call(this, m)
  12287. }
  12288. ZRText.prototype.getComputedTransform = function () {
  12289. if (this.__hostTarget) {
  12290. this.__hostTarget.getComputedTransform()
  12291. this.__hostTarget.updateInnerText(true)
  12292. }
  12293. return _super.prototype.getComputedTransform.call(this)
  12294. }
  12295. ZRText.prototype._updateSubTexts = function () {
  12296. this._childCursor = 0
  12297. normalizeTextStyle(this.style)
  12298. this.style.rich
  12299. ? this._updateRichTexts()
  12300. : this._updatePlainTexts()
  12301. this._children.length = this._childCursor
  12302. this.styleUpdated()
  12303. }
  12304. ZRText.prototype.addSelfToZr = function (zr) {
  12305. _super.prototype.addSelfToZr.call(this, zr)
  12306. for (var i = 0; i < this._children.length; i++) {
  12307. this._children[i].__zr = zr
  12308. }
  12309. }
  12310. ZRText.prototype.removeSelfFromZr = function (zr) {
  12311. _super.prototype.removeSelfFromZr.call(this, zr)
  12312. for (var i = 0; i < this._children.length; i++) {
  12313. this._children[i].__zr = null
  12314. }
  12315. }
  12316. ZRText.prototype.getBoundingRect = function () {
  12317. if (this.styleChanged()) {
  12318. this._updateSubTexts()
  12319. }
  12320. if (!this._rect) {
  12321. var tmpRect = new BoundingRect$1(0, 0, 0, 0)
  12322. var children = this._children
  12323. var tmpMat = []
  12324. var rect = null
  12325. for (var i = 0; i < children.length; i++) {
  12326. var child = children[i]
  12327. var childRect = child.getBoundingRect()
  12328. var transform = child.getLocalTransform(tmpMat)
  12329. if (transform) {
  12330. tmpRect.copy(childRect)
  12331. tmpRect.applyTransform(transform)
  12332. rect = rect || tmpRect.clone()
  12333. rect.union(tmpRect)
  12334. } else {
  12335. rect = rect || childRect.clone()
  12336. rect.union(childRect)
  12337. }
  12338. }
  12339. this._rect = rect || tmpRect
  12340. }
  12341. return this._rect
  12342. }
  12343. ZRText.prototype.setDefaultTextStyle = function (defaultTextStyle) {
  12344. this._defaultStyle = defaultTextStyle || DEFAULT_RICH_TEXT_COLOR
  12345. }
  12346. ZRText.prototype.setTextContent = function (textContent) {}
  12347. ZRText.prototype._mergeStyle = function (targetStyle, sourceStyle) {
  12348. if (!sourceStyle) {
  12349. return targetStyle
  12350. }
  12351. var sourceRich = sourceStyle.rich
  12352. var targetRich = targetStyle.rich || (sourceRich && {})
  12353. extend(targetStyle, sourceStyle)
  12354. if (sourceRich && targetRich) {
  12355. this._mergeRich(targetRich, sourceRich)
  12356. targetStyle.rich = targetRich
  12357. } else if (targetRich) {
  12358. targetStyle.rich = targetRich
  12359. }
  12360. return targetStyle
  12361. }
  12362. ZRText.prototype._mergeRich = function (targetRich, sourceRich) {
  12363. var richNames = keys(sourceRich)
  12364. for (var i = 0; i < richNames.length; i++) {
  12365. var richName = richNames[i]
  12366. targetRich[richName] = targetRich[richName] || {}
  12367. extend(targetRich[richName], sourceRich[richName])
  12368. }
  12369. }
  12370. ZRText.prototype.getAnimationStyleProps = function () {
  12371. return DEFAULT_TEXT_ANIMATION_PROPS
  12372. }
  12373. ZRText.prototype._getOrCreateChild = function (Ctor) {
  12374. var child = this._children[this._childCursor]
  12375. if (!child || !(child instanceof Ctor)) {
  12376. child = new Ctor()
  12377. }
  12378. this._children[this._childCursor++] = child
  12379. child.__zr = this.__zr
  12380. child.parent = this
  12381. return child
  12382. }
  12383. ZRText.prototype._updatePlainTexts = function () {
  12384. var style = this.style
  12385. var textFont = style.font || DEFAULT_FONT
  12386. var textPadding = style.padding
  12387. var text = getStyleText(style)
  12388. var contentBlock = parsePlainText(text, style)
  12389. var needDrawBg = needDrawBackground(style)
  12390. var bgColorDrawn = !!style.backgroundColor
  12391. var outerHeight = contentBlock.outerHeight
  12392. var outerWidth = contentBlock.outerWidth
  12393. var contentWidth = contentBlock.contentWidth
  12394. var textLines = contentBlock.lines
  12395. var lineHeight = contentBlock.lineHeight
  12396. var defaultStyle = this._defaultStyle
  12397. var baseX = style.x || 0
  12398. var baseY = style.y || 0
  12399. var textAlign = style.align || defaultStyle.align || 'left'
  12400. var verticalAlign =
  12401. style.verticalAlign || defaultStyle.verticalAlign || 'top'
  12402. var textX = baseX
  12403. var textY = adjustTextY(
  12404. baseY,
  12405. contentBlock.contentHeight,
  12406. verticalAlign
  12407. )
  12408. if (needDrawBg || textPadding) {
  12409. var boxX = adjustTextX(baseX, outerWidth, textAlign)
  12410. var boxY = adjustTextY(baseY, outerHeight, verticalAlign)
  12411. needDrawBg &&
  12412. this._renderBackground(
  12413. style,
  12414. style,
  12415. boxX,
  12416. boxY,
  12417. outerWidth,
  12418. outerHeight
  12419. )
  12420. }
  12421. textY += lineHeight / 2
  12422. if (textPadding) {
  12423. textX = getTextXForPadding(baseX, textAlign, textPadding)
  12424. if (verticalAlign === 'top') {
  12425. textY += textPadding[0]
  12426. } else if (verticalAlign === 'bottom') {
  12427. textY -= textPadding[2]
  12428. }
  12429. }
  12430. var defaultLineWidth = 0
  12431. var useDefaultFill = false
  12432. var textFill = getFill(
  12433. 'fill' in style
  12434. ? style.fill
  12435. : ((useDefaultFill = true), defaultStyle.fill)
  12436. )
  12437. var textStroke = getStroke(
  12438. 'stroke' in style
  12439. ? style.stroke
  12440. : !bgColorDrawn &&
  12441. (!defaultStyle.autoStroke || useDefaultFill)
  12442. ? ((defaultLineWidth = DEFAULT_STROKE_LINE_WIDTH),
  12443. defaultStyle.stroke)
  12444. : null
  12445. )
  12446. var hasShadow = style.textShadowBlur > 0
  12447. var fixedBoundingRect =
  12448. style.width != null &&
  12449. (style.overflow === 'truncate' ||
  12450. style.overflow === 'break' ||
  12451. style.overflow === 'breakAll')
  12452. var calculatedLineHeight = contentBlock.calculatedLineHeight
  12453. for (var i = 0; i < textLines.length; i++) {
  12454. var el = this._getOrCreateChild(TSpan$1)
  12455. var subElStyle = el.createStyle()
  12456. el.useStyle(subElStyle)
  12457. subElStyle.text = textLines[i]
  12458. subElStyle.x = textX
  12459. subElStyle.y = textY
  12460. if (textAlign) {
  12461. subElStyle.textAlign = textAlign
  12462. }
  12463. subElStyle.textBaseline = 'middle'
  12464. subElStyle.opacity = style.opacity
  12465. subElStyle.strokeFirst = true
  12466. if (hasShadow) {
  12467. subElStyle.shadowBlur = style.textShadowBlur || 0
  12468. subElStyle.shadowColor =
  12469. style.textShadowColor || 'transparent'
  12470. subElStyle.shadowOffsetX = style.textShadowOffsetX || 0
  12471. subElStyle.shadowOffsetY = style.textShadowOffsetY || 0
  12472. }
  12473. subElStyle.stroke = textStroke
  12474. subElStyle.fill = textFill
  12475. if (textStroke) {
  12476. subElStyle.lineWidth = style.lineWidth || defaultLineWidth
  12477. subElStyle.lineDash = style.lineDash
  12478. subElStyle.lineDashOffset = style.lineDashOffset || 0
  12479. }
  12480. subElStyle.font = textFont
  12481. setSeparateFont(subElStyle, style)
  12482. textY += lineHeight
  12483. if (fixedBoundingRect) {
  12484. el.setBoundingRect(
  12485. new BoundingRect$1(
  12486. adjustTextX(
  12487. subElStyle.x,
  12488. style.width,
  12489. subElStyle.textAlign
  12490. ),
  12491. adjustTextY(
  12492. subElStyle.y,
  12493. calculatedLineHeight,
  12494. subElStyle.textBaseline
  12495. ),
  12496. contentWidth,
  12497. calculatedLineHeight
  12498. )
  12499. )
  12500. }
  12501. }
  12502. }
  12503. ZRText.prototype._updateRichTexts = function () {
  12504. var style = this.style
  12505. var text = getStyleText(style)
  12506. var contentBlock = parseRichText(text, style)
  12507. var contentWidth = contentBlock.width
  12508. var outerWidth = contentBlock.outerWidth
  12509. var outerHeight = contentBlock.outerHeight
  12510. var textPadding = style.padding
  12511. var baseX = style.x || 0
  12512. var baseY = style.y || 0
  12513. var defaultStyle = this._defaultStyle
  12514. var textAlign = style.align || defaultStyle.align
  12515. var verticalAlign =
  12516. style.verticalAlign || defaultStyle.verticalAlign
  12517. var boxX = adjustTextX(baseX, outerWidth, textAlign)
  12518. var boxY = adjustTextY(baseY, outerHeight, verticalAlign)
  12519. var xLeft = boxX
  12520. var lineTop = boxY
  12521. if (textPadding) {
  12522. xLeft += textPadding[3]
  12523. lineTop += textPadding[0]
  12524. }
  12525. var xRight = xLeft + contentWidth
  12526. if (needDrawBackground(style)) {
  12527. this._renderBackground(
  12528. style,
  12529. style,
  12530. boxX,
  12531. boxY,
  12532. outerWidth,
  12533. outerHeight
  12534. )
  12535. }
  12536. var bgColorDrawn = !!style.backgroundColor
  12537. for (var i = 0; i < contentBlock.lines.length; i++) {
  12538. var line = contentBlock.lines[i]
  12539. var tokens = line.tokens
  12540. var tokenCount = tokens.length
  12541. var lineHeight = line.lineHeight
  12542. var remainedWidth = line.width
  12543. var leftIndex = 0
  12544. var lineXLeft = xLeft
  12545. var lineXRight = xRight
  12546. var rightIndex = tokenCount - 1
  12547. var token = void 0
  12548. while (
  12549. leftIndex < tokenCount &&
  12550. ((token = tokens[leftIndex]),
  12551. !token.align || token.align === 'left')
  12552. ) {
  12553. this._placeToken(
  12554. token,
  12555. style,
  12556. lineHeight,
  12557. lineTop,
  12558. lineXLeft,
  12559. 'left',
  12560. bgColorDrawn
  12561. )
  12562. remainedWidth -= token.width
  12563. lineXLeft += token.width
  12564. leftIndex++
  12565. }
  12566. while (
  12567. rightIndex >= 0 &&
  12568. ((token = tokens[rightIndex]), token.align === 'right')
  12569. ) {
  12570. this._placeToken(
  12571. token,
  12572. style,
  12573. lineHeight,
  12574. lineTop,
  12575. lineXRight,
  12576. 'right',
  12577. bgColorDrawn
  12578. )
  12579. remainedWidth -= token.width
  12580. lineXRight -= token.width
  12581. rightIndex--
  12582. }
  12583. lineXLeft +=
  12584. (contentWidth -
  12585. (lineXLeft - xLeft) -
  12586. (xRight - lineXRight) -
  12587. remainedWidth) /
  12588. 2
  12589. while (leftIndex <= rightIndex) {
  12590. token = tokens[leftIndex]
  12591. this._placeToken(
  12592. token,
  12593. style,
  12594. lineHeight,
  12595. lineTop,
  12596. lineXLeft + token.width / 2,
  12597. 'center',
  12598. bgColorDrawn
  12599. )
  12600. lineXLeft += token.width
  12601. leftIndex++
  12602. }
  12603. lineTop += lineHeight
  12604. }
  12605. }
  12606. ZRText.prototype._placeToken = function (
  12607. token,
  12608. style,
  12609. lineHeight,
  12610. lineTop,
  12611. x,
  12612. textAlign,
  12613. parentBgColorDrawn
  12614. ) {
  12615. var tokenStyle = style.rich[token.styleName] || {}
  12616. tokenStyle.text = token.text
  12617. var verticalAlign = token.verticalAlign
  12618. var y = lineTop + lineHeight / 2
  12619. if (verticalAlign === 'top') {
  12620. y = lineTop + token.height / 2
  12621. } else if (verticalAlign === 'bottom') {
  12622. y = lineTop + lineHeight - token.height / 2
  12623. }
  12624. var needDrawBg =
  12625. !token.isLineHolder && needDrawBackground(tokenStyle)
  12626. needDrawBg &&
  12627. this._renderBackground(
  12628. tokenStyle,
  12629. style,
  12630. textAlign === 'right'
  12631. ? x - token.width
  12632. : textAlign === 'center'
  12633. ? x - token.width / 2
  12634. : x,
  12635. y - token.height / 2,
  12636. token.width,
  12637. token.height
  12638. )
  12639. var bgColorDrawn = !!tokenStyle.backgroundColor
  12640. var textPadding = token.textPadding
  12641. if (textPadding) {
  12642. x = getTextXForPadding(x, textAlign, textPadding)
  12643. y -= token.height / 2 - textPadding[0] - token.innerHeight / 2
  12644. }
  12645. var el = this._getOrCreateChild(TSpan$1)
  12646. var subElStyle = el.createStyle()
  12647. el.useStyle(subElStyle)
  12648. var defaultStyle = this._defaultStyle
  12649. var useDefaultFill = false
  12650. var defaultLineWidth = 0
  12651. var textFill = getFill(
  12652. 'fill' in tokenStyle
  12653. ? tokenStyle.fill
  12654. : 'fill' in style
  12655. ? style.fill
  12656. : ((useDefaultFill = true), defaultStyle.fill)
  12657. )
  12658. var textStroke = getStroke(
  12659. 'stroke' in tokenStyle
  12660. ? tokenStyle.stroke
  12661. : 'stroke' in style
  12662. ? style.stroke
  12663. : !bgColorDrawn &&
  12664. !parentBgColorDrawn &&
  12665. (!defaultStyle.autoStroke || useDefaultFill)
  12666. ? ((defaultLineWidth = DEFAULT_STROKE_LINE_WIDTH),
  12667. defaultStyle.stroke)
  12668. : null
  12669. )
  12670. var hasShadow =
  12671. tokenStyle.textShadowBlur > 0 || style.textShadowBlur > 0
  12672. subElStyle.text = token.text
  12673. subElStyle.x = x
  12674. subElStyle.y = y
  12675. if (hasShadow) {
  12676. subElStyle.shadowBlur =
  12677. tokenStyle.textShadowBlur || style.textShadowBlur || 0
  12678. subElStyle.shadowColor =
  12679. tokenStyle.textShadowColor ||
  12680. style.textShadowColor ||
  12681. 'transparent'
  12682. subElStyle.shadowOffsetX =
  12683. tokenStyle.textShadowOffsetX || style.textShadowOffsetX || 0
  12684. subElStyle.shadowOffsetY =
  12685. tokenStyle.textShadowOffsetY || style.textShadowOffsetY || 0
  12686. }
  12687. subElStyle.textAlign = textAlign
  12688. subElStyle.textBaseline = 'middle'
  12689. subElStyle.font = token.font || DEFAULT_FONT
  12690. subElStyle.opacity = retrieve3(
  12691. tokenStyle.opacity,
  12692. style.opacity,
  12693. 1
  12694. )
  12695. setSeparateFont(subElStyle, tokenStyle)
  12696. if (textStroke) {
  12697. subElStyle.lineWidth = retrieve3(
  12698. tokenStyle.lineWidth,
  12699. style.lineWidth,
  12700. defaultLineWidth
  12701. )
  12702. subElStyle.lineDash = retrieve2(
  12703. tokenStyle.lineDash,
  12704. style.lineDash
  12705. )
  12706. subElStyle.lineDashOffset = style.lineDashOffset || 0
  12707. subElStyle.stroke = textStroke
  12708. }
  12709. if (textFill) {
  12710. subElStyle.fill = textFill
  12711. }
  12712. var textWidth = token.contentWidth
  12713. var textHeight = token.contentHeight
  12714. el.setBoundingRect(
  12715. new BoundingRect$1(
  12716. adjustTextX(subElStyle.x, textWidth, subElStyle.textAlign),
  12717. adjustTextY(
  12718. subElStyle.y,
  12719. textHeight,
  12720. subElStyle.textBaseline
  12721. ),
  12722. textWidth,
  12723. textHeight
  12724. )
  12725. )
  12726. }
  12727. ZRText.prototype._renderBackground = function (
  12728. style,
  12729. topStyle,
  12730. x,
  12731. y,
  12732. width,
  12733. height
  12734. ) {
  12735. var textBackgroundColor = style.backgroundColor
  12736. var textBorderWidth = style.borderWidth
  12737. var textBorderColor = style.borderColor
  12738. var isImageBg = textBackgroundColor && textBackgroundColor.image
  12739. var isPlainOrGradientBg = textBackgroundColor && !isImageBg
  12740. var textBorderRadius = style.borderRadius
  12741. var self = this
  12742. var rectEl
  12743. var imgEl
  12744. if (
  12745. isPlainOrGradientBg ||
  12746. style.lineHeight ||
  12747. (textBorderWidth && textBorderColor)
  12748. ) {
  12749. rectEl = this._getOrCreateChild(Rect$2)
  12750. rectEl.useStyle(rectEl.createStyle())
  12751. rectEl.style.fill = null
  12752. var rectShape = rectEl.shape
  12753. rectShape.x = x
  12754. rectShape.y = y
  12755. rectShape.width = width
  12756. rectShape.height = height
  12757. rectShape.r = textBorderRadius
  12758. rectEl.dirtyShape()
  12759. }
  12760. if (isPlainOrGradientBg) {
  12761. var rectStyle = rectEl.style
  12762. rectStyle.fill = textBackgroundColor || null
  12763. rectStyle.fillOpacity = retrieve2(style.fillOpacity, 1)
  12764. } else if (isImageBg) {
  12765. imgEl = this._getOrCreateChild(ZRImage$1)
  12766. imgEl.onload = function () {
  12767. self.dirtyStyle()
  12768. }
  12769. var imgStyle = imgEl.style
  12770. imgStyle.image = textBackgroundColor.image
  12771. imgStyle.x = x
  12772. imgStyle.y = y
  12773. imgStyle.width = width
  12774. imgStyle.height = height
  12775. }
  12776. if (textBorderWidth && textBorderColor) {
  12777. var rectStyle = rectEl.style
  12778. rectStyle.lineWidth = textBorderWidth
  12779. rectStyle.stroke = textBorderColor
  12780. rectStyle.strokeOpacity = retrieve2(style.strokeOpacity, 1)
  12781. rectStyle.lineDash = style.borderDash
  12782. rectStyle.lineDashOffset = style.borderDashOffset || 0
  12783. rectEl.strokeContainThreshold = 0
  12784. if (rectEl.hasFill() && rectEl.hasStroke()) {
  12785. rectStyle.strokeFirst = true
  12786. rectStyle.lineWidth *= 2
  12787. }
  12788. }
  12789. var commonStyle = (rectEl || imgEl).style
  12790. commonStyle.shadowBlur = style.shadowBlur || 0
  12791. commonStyle.shadowColor = style.shadowColor || 'transparent'
  12792. commonStyle.shadowOffsetX = style.shadowOffsetX || 0
  12793. commonStyle.shadowOffsetY = style.shadowOffsetY || 0
  12794. commonStyle.opacity = retrieve3(
  12795. style.opacity,
  12796. topStyle.opacity,
  12797. 1
  12798. )
  12799. }
  12800. ZRText.makeFont = function (style) {
  12801. var font = ''
  12802. if (hasSeparateFont(style)) {
  12803. font = [
  12804. style.fontStyle,
  12805. style.fontWeight,
  12806. parseFontSize(style.fontSize),
  12807. style.fontFamily || 'sans-serif'
  12808. ].join(' ')
  12809. }
  12810. return (font && trim$1(font)) || style.textFont || style.font
  12811. }
  12812. return ZRText
  12813. })(Displayable$1)
  12814. var VALID_TEXT_ALIGN = { left: true, right: 1, center: 1 }
  12815. var VALID_TEXT_VERTICAL_ALIGN = { top: 1, bottom: 1, middle: 1 }
  12816. var FONT_PARTS = ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily']
  12817. function parseFontSize(fontSize) {
  12818. if (
  12819. typeof fontSize === 'string' &&
  12820. (fontSize.indexOf('px') !== -1 ||
  12821. fontSize.indexOf('rem') !== -1 ||
  12822. fontSize.indexOf('em') !== -1)
  12823. ) {
  12824. return fontSize
  12825. } else if (!isNaN(+fontSize)) {
  12826. return fontSize + 'px'
  12827. } else {
  12828. return DEFAULT_FONT_SIZE + 'px'
  12829. }
  12830. }
  12831. function setSeparateFont(targetStyle, sourceStyle) {
  12832. for (var i = 0; i < FONT_PARTS.length; i++) {
  12833. var fontProp = FONT_PARTS[i]
  12834. var val = sourceStyle[fontProp]
  12835. if (val != null) {
  12836. targetStyle[fontProp] = val
  12837. }
  12838. }
  12839. }
  12840. function hasSeparateFont(style) {
  12841. return (
  12842. style.fontSize != null || style.fontFamily || style.fontWeight
  12843. )
  12844. }
  12845. function normalizeTextStyle(style) {
  12846. normalizeStyle(style)
  12847. each$7(style.rich, normalizeStyle)
  12848. return style
  12849. }
  12850. function normalizeStyle(style) {
  12851. if (style) {
  12852. style.font = ZRText.makeFont(style)
  12853. var textAlign = style.align
  12854. textAlign === 'middle' && (textAlign = 'center')
  12855. style.align =
  12856. textAlign == null || VALID_TEXT_ALIGN[textAlign]
  12857. ? textAlign
  12858. : 'left'
  12859. var verticalAlign = style.verticalAlign
  12860. verticalAlign === 'center' && (verticalAlign = 'middle')
  12861. style.verticalAlign =
  12862. verticalAlign == null ||
  12863. VALID_TEXT_VERTICAL_ALIGN[verticalAlign]
  12864. ? verticalAlign
  12865. : 'top'
  12866. var textPadding = style.padding
  12867. if (textPadding) {
  12868. style.padding = normalizeCssArray$1(style.padding)
  12869. }
  12870. }
  12871. }
  12872. function getStroke(stroke, lineWidth) {
  12873. return stroke == null ||
  12874. lineWidth <= 0 ||
  12875. stroke === 'transparent' ||
  12876. stroke === 'none'
  12877. ? null
  12878. : stroke.image || stroke.colorStops
  12879. ? '#000'
  12880. : stroke
  12881. }
  12882. function getFill(fill) {
  12883. return fill == null || fill === 'none'
  12884. ? null
  12885. : fill.image || fill.colorStops
  12886. ? '#000'
  12887. : fill
  12888. }
  12889. function getTextXForPadding(x, textAlign, textPadding) {
  12890. return textAlign === 'right'
  12891. ? x - textPadding[1]
  12892. : textAlign === 'center'
  12893. ? x + textPadding[3] / 2 - textPadding[1] / 2
  12894. : x + textPadding[3]
  12895. }
  12896. function getStyleText(style) {
  12897. var text = style.text
  12898. text != null && (text += '')
  12899. return text
  12900. }
  12901. function needDrawBackground(style) {
  12902. return !!(
  12903. style.backgroundColor ||
  12904. style.lineHeight ||
  12905. (style.borderWidth && style.borderColor)
  12906. )
  12907. }
  12908. var ZRText$1 = ZRText
  12909. var getECData = makeInner()
  12910. var setCommonECData = function setCommonECData(
  12911. seriesIndex,
  12912. dataType,
  12913. dataIdx,
  12914. el
  12915. ) {
  12916. if (el) {
  12917. var ecData = getECData(el) // Add data index and series index for indexing the data by element
  12918. // Useful in tooltip
  12919. ecData.dataIndex = dataIdx
  12920. ecData.dataType = dataType
  12921. ecData.seriesIndex = seriesIndex // TODO: not store dataIndex on children.
  12922. if (el.type === 'group') {
  12923. el.traverse(function (child) {
  12924. var childECData = getECData(child)
  12925. childECData.seriesIndex = seriesIndex
  12926. childECData.dataIndex = dataIdx
  12927. childECData.dataType = dataType
  12928. })
  12929. }
  12930. }
  12931. }
  12932. var _highlightNextDigit = 1
  12933. var _highlightKeyMap = {}
  12934. var getSavedStates = makeInner()
  12935. var getComponentStates = makeInner()
  12936. var HOVER_STATE_NORMAL = 0
  12937. var HOVER_STATE_BLUR = 1
  12938. var HOVER_STATE_EMPHASIS = 2
  12939. var SPECIAL_STATES = ['emphasis', 'blur', 'select']
  12940. var DISPLAY_STATES = ['normal', 'emphasis', 'blur', 'select']
  12941. var Z2_EMPHASIS_LIFT = 10
  12942. var Z2_SELECT_LIFT = 9
  12943. var HIGHLIGHT_ACTION_TYPE = 'highlight'
  12944. var DOWNPLAY_ACTION_TYPE = 'downplay'
  12945. var SELECT_ACTION_TYPE = 'select'
  12946. var UNSELECT_ACTION_TYPE = 'unselect'
  12947. var TOGGLE_SELECT_ACTION_TYPE = 'toggleSelect'
  12948. function hasFillOrStroke(fillOrStroke) {
  12949. return fillOrStroke != null && fillOrStroke !== 'none'
  12950. } // Most lifted color are duplicated.
  12951. var liftedColorCache = new LRU$1(100)
  12952. function liftColor(color) {
  12953. if (isString(color)) {
  12954. var liftedColor = liftedColorCache.get(color)
  12955. if (!liftedColor) {
  12956. liftedColor = lift(color, -0.1)
  12957. liftedColorCache.put(color, liftedColor)
  12958. }
  12959. return liftedColor
  12960. } else if (isGradientObject(color)) {
  12961. var ret = extend({}, color)
  12962. ret.colorStops = map$1(color.colorStops, function (stop) {
  12963. return { offset: stop.offset, color: lift(stop.color, -0.1) }
  12964. })
  12965. return ret
  12966. } // Change nothing.
  12967. return color
  12968. }
  12969. function doChangeHoverState(el, stateName, hoverStateEnum) {
  12970. if (
  12971. el.onHoverStateChange &&
  12972. (el.hoverState || 0) !== hoverStateEnum
  12973. ) {
  12974. el.onHoverStateChange(stateName)
  12975. }
  12976. el.hoverState = hoverStateEnum
  12977. }
  12978. function singleEnterEmphasis(el) {
  12979. // Only mark the flag.
  12980. // States will be applied in the echarts.ts in next frame.
  12981. doChangeHoverState(el, 'emphasis', HOVER_STATE_EMPHASIS)
  12982. }
  12983. function singleLeaveEmphasis(el) {
  12984. // Only mark the flag.
  12985. // States will be applied in the echarts.ts in next frame.
  12986. if (el.hoverState === HOVER_STATE_EMPHASIS) {
  12987. doChangeHoverState(el, 'normal', HOVER_STATE_NORMAL)
  12988. }
  12989. }
  12990. function singleEnterBlur(el) {
  12991. doChangeHoverState(el, 'blur', HOVER_STATE_BLUR)
  12992. }
  12993. function singleLeaveBlur(el) {
  12994. if (el.hoverState === HOVER_STATE_BLUR) {
  12995. doChangeHoverState(el, 'normal', HOVER_STATE_NORMAL)
  12996. }
  12997. }
  12998. function singleEnterSelect(el) {
  12999. el.selected = true
  13000. }
  13001. function singleLeaveSelect(el) {
  13002. el.selected = false
  13003. }
  13004. function updateElementState(el, updater, commonParam) {
  13005. updater(el, commonParam)
  13006. }
  13007. function traverseUpdateState(el, updater, commonParam) {
  13008. updateElementState(el, updater, commonParam)
  13009. el.isGroup &&
  13010. el.traverse(function (child) {
  13011. updateElementState(child, updater, commonParam)
  13012. })
  13013. }
  13014. function setStatesFlag(el, stateName) {
  13015. switch (stateName) {
  13016. case 'emphasis':
  13017. el.hoverState = HOVER_STATE_EMPHASIS
  13018. break
  13019. case 'normal':
  13020. el.hoverState = HOVER_STATE_NORMAL
  13021. break
  13022. case 'blur':
  13023. el.hoverState = HOVER_STATE_BLUR
  13024. break
  13025. case 'select':
  13026. el.selected = true
  13027. }
  13028. }
  13029. function getFromStateStyle(el, props, toStateName, defaultValue) {
  13030. var style = el.style
  13031. var fromState = {}
  13032. for (var i = 0; i < props.length; i++) {
  13033. var propName = props[i]
  13034. var val = style[propName]
  13035. fromState[propName] =
  13036. val == null ? defaultValue && defaultValue[propName] : val
  13037. }
  13038. for (var i = 0; i < el.animators.length; i++) {
  13039. var animator = el.animators[i]
  13040. if (
  13041. animator.__fromStateTransition && // Dont consider the animation to emphasis state.
  13042. animator.__fromStateTransition.indexOf(toStateName) < 0 &&
  13043. animator.targetName === 'style'
  13044. ) {
  13045. animator.saveTo(fromState, props)
  13046. }
  13047. }
  13048. return fromState
  13049. }
  13050. function createEmphasisDefaultState(
  13051. el,
  13052. stateName,
  13053. targetStates,
  13054. state
  13055. ) {
  13056. var hasSelect = targetStates && indexOf(targetStates, 'select') >= 0
  13057. var cloned = false
  13058. if (el instanceof Path$1) {
  13059. var store = getSavedStates(el)
  13060. var fromFill = hasSelect
  13061. ? store.selectFill || store.normalFill
  13062. : store.normalFill
  13063. var fromStroke = hasSelect
  13064. ? store.selectStroke || store.normalStroke
  13065. : store.normalStroke
  13066. if (hasFillOrStroke(fromFill) || hasFillOrStroke(fromStroke)) {
  13067. state = state || {}
  13068. var emphasisStyle = state.style || {} // inherit case
  13069. if (emphasisStyle.fill === 'inherit') {
  13070. cloned = true
  13071. state = extend({}, state)
  13072. emphasisStyle = extend({}, emphasisStyle)
  13073. emphasisStyle.fill = fromFill
  13074. } // Apply default color lift
  13075. else if (
  13076. !hasFillOrStroke(emphasisStyle.fill) &&
  13077. hasFillOrStroke(fromFill)
  13078. ) {
  13079. cloned = true // Not modify the original value.
  13080. state = extend({}, state)
  13081. emphasisStyle = extend({}, emphasisStyle) // Already being applied 'emphasis'. DON'T lift color multiple times.
  13082. emphasisStyle.fill = liftColor(fromFill)
  13083. } // Not highlight stroke if fill has been highlighted.
  13084. else if (
  13085. !hasFillOrStroke(emphasisStyle.stroke) &&
  13086. hasFillOrStroke(fromStroke)
  13087. ) {
  13088. if (!cloned) {
  13089. state = extend({}, state)
  13090. emphasisStyle = extend({}, emphasisStyle)
  13091. }
  13092. emphasisStyle.stroke = liftColor(fromStroke)
  13093. }
  13094. state.style = emphasisStyle
  13095. }
  13096. }
  13097. if (state) {
  13098. // TODO Share with textContent?
  13099. if (state.z2 == null) {
  13100. if (!cloned) {
  13101. state = extend({}, state)
  13102. }
  13103. var z2EmphasisLift = el.z2EmphasisLift
  13104. state.z2 =
  13105. el.z2 +
  13106. (z2EmphasisLift != null ? z2EmphasisLift : Z2_EMPHASIS_LIFT)
  13107. }
  13108. }
  13109. return state
  13110. }
  13111. function createSelectDefaultState(el, stateName, state) {
  13112. // const hasSelect = indexOf(el.currentStates, stateName) >= 0;
  13113. if (state) {
  13114. // TODO Share with textContent?
  13115. if (state.z2 == null) {
  13116. state = extend({}, state)
  13117. var z2SelectLift = el.z2SelectLift
  13118. state.z2 =
  13119. el.z2 + (z2SelectLift != null ? z2SelectLift : Z2_SELECT_LIFT)
  13120. }
  13121. }
  13122. return state
  13123. }
  13124. function createBlurDefaultState(el, stateName, state) {
  13125. var hasBlur = indexOf(el.currentStates, stateName) >= 0
  13126. var currentOpacity = el.style.opacity
  13127. var fromState = !hasBlur
  13128. ? getFromStateStyle(el, ['opacity'], stateName, { opacity: 1 })
  13129. : null
  13130. state = state || {}
  13131. var blurStyle = state.style || {}
  13132. if (blurStyle.opacity == null) {
  13133. // clone state
  13134. state = extend({}, state)
  13135. blurStyle = extend(
  13136. {
  13137. // Already being applied 'emphasis'. DON'T mul opacity multiple times.
  13138. opacity: hasBlur ? currentOpacity : fromState.opacity * 0.1
  13139. },
  13140. blurStyle
  13141. )
  13142. state.style = blurStyle
  13143. }
  13144. return state
  13145. }
  13146. function elementStateProxy(stateName, targetStates) {
  13147. var state = this.states[stateName]
  13148. if (this.style) {
  13149. if (stateName === 'emphasis') {
  13150. return createEmphasisDefaultState(
  13151. this,
  13152. stateName,
  13153. targetStates,
  13154. state
  13155. )
  13156. } else if (stateName === 'blur') {
  13157. return createBlurDefaultState(this, stateName, state)
  13158. } else if (stateName === 'select') {
  13159. return createSelectDefaultState(this, stateName, state)
  13160. }
  13161. }
  13162. return state
  13163. }
  13164. /**FI
  13165. * Set hover style (namely "emphasis style") of element.
  13166. * @param el Should not be `zrender/graphic/Group`.
  13167. * @param focus 'self' | 'selfInSeries' | 'series'
  13168. */ function setDefaultStateProxy(el) {
  13169. el.stateProxy = elementStateProxy
  13170. var textContent = el.getTextContent()
  13171. var textGuide = el.getTextGuideLine()
  13172. if (textContent) {
  13173. textContent.stateProxy = elementStateProxy
  13174. }
  13175. if (textGuide) {
  13176. textGuide.stateProxy = elementStateProxy
  13177. }
  13178. }
  13179. function enterEmphasisWhenMouseOver(el, e) {
  13180. !shouldSilent(el, e) && // "emphasis" event highlight has higher priority than mouse highlight.
  13181. !el.__highByOuter &&
  13182. traverseUpdateState(el, singleEnterEmphasis)
  13183. }
  13184. function leaveEmphasisWhenMouseOut(el, e) {
  13185. !shouldSilent(el, e) && // "emphasis" event highlight has higher priority than mouse highlight.
  13186. !el.__highByOuter &&
  13187. traverseUpdateState(el, singleLeaveEmphasis)
  13188. }
  13189. function enterEmphasis(el, highlightDigit) {
  13190. el.__highByOuter |= 1 << (highlightDigit || 0)
  13191. traverseUpdateState(el, singleEnterEmphasis)
  13192. }
  13193. function leaveEmphasis(el, highlightDigit) {
  13194. !(el.__highByOuter &= ~(1 << (highlightDigit || 0))) &&
  13195. traverseUpdateState(el, singleLeaveEmphasis)
  13196. }
  13197. function enterBlur(el) {
  13198. traverseUpdateState(el, singleEnterBlur)
  13199. }
  13200. function leaveBlur(el) {
  13201. traverseUpdateState(el, singleLeaveBlur)
  13202. }
  13203. function enterSelect(el) {
  13204. traverseUpdateState(el, singleEnterSelect)
  13205. }
  13206. function leaveSelect(el) {
  13207. traverseUpdateState(el, singleLeaveSelect)
  13208. }
  13209. function shouldSilent(el, e) {
  13210. return el.__highDownSilentOnTouch && e.zrByTouch
  13211. }
  13212. function allLeaveBlur(api) {
  13213. var model = api.getModel()
  13214. var leaveBlurredSeries = []
  13215. var allComponentViews = []
  13216. model.eachComponent(function (componentType, componentModel) {
  13217. var componentStates = getComponentStates(componentModel)
  13218. var isSeries = componentType === 'series'
  13219. var view = isSeries
  13220. ? api.getViewOfSeriesModel(componentModel)
  13221. : api.getViewOfComponentModel(componentModel)
  13222. !isSeries && allComponentViews.push(view)
  13223. if (componentStates.isBlured) {
  13224. // Leave blur anyway
  13225. view.group.traverse(function (child) {
  13226. singleLeaveBlur(child)
  13227. })
  13228. isSeries && leaveBlurredSeries.push(componentModel)
  13229. }
  13230. componentStates.isBlured = false
  13231. })
  13232. each$7(allComponentViews, function (view) {
  13233. if (view && view.toggleBlurSeries) {
  13234. view.toggleBlurSeries(leaveBlurredSeries, false, model)
  13235. }
  13236. })
  13237. }
  13238. function blurSeries(targetSeriesIndex, focus, blurScope, api) {
  13239. var ecModel = api.getModel()
  13240. blurScope = blurScope || 'coordinateSystem'
  13241. function leaveBlurOfIndices(data, dataIndices) {
  13242. for (var i = 0; i < dataIndices.length; i++) {
  13243. var itemEl = data.getItemGraphicEl(dataIndices[i])
  13244. itemEl && leaveBlur(itemEl)
  13245. }
  13246. }
  13247. if (targetSeriesIndex == null) {
  13248. return
  13249. }
  13250. if (!focus || focus === 'none') {
  13251. return
  13252. }
  13253. var targetSeriesModel = ecModel.getSeriesByIndex(targetSeriesIndex)
  13254. var targetCoordSys = targetSeriesModel.coordinateSystem
  13255. if (targetCoordSys && targetCoordSys.master) {
  13256. targetCoordSys = targetCoordSys.master
  13257. }
  13258. var blurredSeries = []
  13259. ecModel.eachSeries(function (seriesModel) {
  13260. var sameSeries = targetSeriesModel === seriesModel
  13261. var coordSys = seriesModel.coordinateSystem
  13262. if (coordSys && coordSys.master) {
  13263. coordSys = coordSys.master
  13264. }
  13265. var sameCoordSys =
  13266. coordSys && targetCoordSys
  13267. ? coordSys === targetCoordSys
  13268. : sameSeries // If there is no coordinate system. use sameSeries instead.
  13269. if (
  13270. !(
  13271. // Not blur other series if blurScope series
  13272. (
  13273. (blurScope === 'series' && !sameSeries) || // Not blur other coordinate system if blurScope is coordinateSystem
  13274. (blurScope === 'coordinateSystem' && !sameCoordSys) || // Not blur self series if focus is series.
  13275. (focus === 'series' && sameSeries)
  13276. ) // TODO blurScope: coordinate system
  13277. )
  13278. ) {
  13279. var view = api.getViewOfSeriesModel(seriesModel)
  13280. view.group.traverse(function (child) {
  13281. singleEnterBlur(child)
  13282. })
  13283. if (isArrayLike(focus)) {
  13284. leaveBlurOfIndices(seriesModel.getData(), focus)
  13285. } else if (isObject$2(focus)) {
  13286. var dataTypes = keys(focus)
  13287. for (var d = 0; d < dataTypes.length; d++) {
  13288. leaveBlurOfIndices(
  13289. seriesModel.getData(dataTypes[d]),
  13290. focus[dataTypes[d]]
  13291. )
  13292. }
  13293. }
  13294. blurredSeries.push(seriesModel)
  13295. getComponentStates(seriesModel).isBlured = true
  13296. }
  13297. })
  13298. ecModel.eachComponent(function (componentType, componentModel) {
  13299. if (componentType === 'series') {
  13300. return
  13301. }
  13302. var view = api.getViewOfComponentModel(componentModel)
  13303. if (view && view.toggleBlurSeries) {
  13304. view.toggleBlurSeries(blurredSeries, true, ecModel)
  13305. }
  13306. })
  13307. }
  13308. function blurComponent(componentMainType, componentIndex, api) {
  13309. if (componentMainType == null || componentIndex == null) {
  13310. return
  13311. }
  13312. var componentModel = api
  13313. .getModel()
  13314. .getComponent(componentMainType, componentIndex)
  13315. if (!componentModel) {
  13316. return
  13317. }
  13318. getComponentStates(componentModel).isBlured = true
  13319. var view = api.getViewOfComponentModel(componentModel)
  13320. if (!view || !view.focusBlurEnabled) {
  13321. return
  13322. }
  13323. view.group.traverse(function (child) {
  13324. singleEnterBlur(child)
  13325. })
  13326. }
  13327. function blurSeriesFromHighlightPayload(seriesModel, payload, api) {
  13328. var seriesIndex = seriesModel.seriesIndex
  13329. var data = seriesModel.getData(payload.dataType)
  13330. if (!data) {
  13331. return
  13332. }
  13333. var dataIndex = queryDataIndex(data, payload) // Pick the first one if there is multiple/none exists.
  13334. dataIndex = (isArray(dataIndex) ? dataIndex[0] : dataIndex) || 0
  13335. var el = data.getItemGraphicEl(dataIndex)
  13336. if (!el) {
  13337. var count = data.count()
  13338. var current = 0 // If data on dataIndex is NaN.
  13339. while (!el && current < count) {
  13340. el = data.getItemGraphicEl(current++)
  13341. }
  13342. }
  13343. if (el) {
  13344. var ecData = getECData(el)
  13345. blurSeries(seriesIndex, ecData.focus, ecData.blurScope, api)
  13346. } else {
  13347. // If there is no element put on the data. Try getting it from raw option
  13348. // TODO Should put it on seriesModel?
  13349. var focus_1 = seriesModel.get(['emphasis', 'focus'])
  13350. var blurScope = seriesModel.get(['emphasis', 'blurScope'])
  13351. if (focus_1 != null) {
  13352. blurSeries(seriesIndex, focus_1, blurScope, api)
  13353. }
  13354. }
  13355. }
  13356. function findComponentHighDownDispatchers(
  13357. componentMainType,
  13358. componentIndex,
  13359. name,
  13360. api
  13361. ) {
  13362. var ret = { focusSelf: false, dispatchers: null }
  13363. if (
  13364. componentMainType == null ||
  13365. componentMainType === 'series' ||
  13366. componentIndex == null ||
  13367. name == null
  13368. ) {
  13369. return ret
  13370. }
  13371. var componentModel = api
  13372. .getModel()
  13373. .getComponent(componentMainType, componentIndex)
  13374. if (!componentModel) {
  13375. return ret
  13376. }
  13377. var view = api.getViewOfComponentModel(componentModel)
  13378. if (!view || !view.findHighDownDispatchers) {
  13379. return ret
  13380. }
  13381. var dispatchers = view.findHighDownDispatchers(name) // At presnet, the component (like Geo) only blur inside itself.
  13382. // So we do not use `blurScope` in component.
  13383. var focusSelf
  13384. for (var i = 0; i < dispatchers.length; i++) {
  13385. if (getECData(dispatchers[i]).focus === 'self') {
  13386. focusSelf = true
  13387. break
  13388. }
  13389. }
  13390. return { focusSelf: focusSelf, dispatchers: dispatchers }
  13391. }
  13392. function handleGlobalMouseOverForHighDown(dispatcher, e, api) {
  13393. var ecData = getECData(dispatcher)
  13394. var _a = findComponentHighDownDispatchers(
  13395. ecData.componentMainType,
  13396. ecData.componentIndex,
  13397. ecData.componentHighDownName,
  13398. api
  13399. ),
  13400. dispatchers = _a.dispatchers,
  13401. focusSelf = _a.focusSelf // If `findHighDownDispatchers` is supported on the component,
  13402. // highlight/downplay elements with the same name.
  13403. if (dispatchers) {
  13404. if (focusSelf) {
  13405. blurComponent(
  13406. ecData.componentMainType,
  13407. ecData.componentIndex,
  13408. api
  13409. )
  13410. }
  13411. each$7(dispatchers, function (dispatcher) {
  13412. return enterEmphasisWhenMouseOver(dispatcher, e)
  13413. })
  13414. } else {
  13415. // Try blur all in the related series. Then emphasis the hoverred.
  13416. // TODO. progressive mode.
  13417. blurSeries(
  13418. ecData.seriesIndex,
  13419. ecData.focus,
  13420. ecData.blurScope,
  13421. api
  13422. )
  13423. if (ecData.focus === 'self') {
  13424. blurComponent(
  13425. ecData.componentMainType,
  13426. ecData.componentIndex,
  13427. api
  13428. )
  13429. } // Other than series, component that not support `findHighDownDispatcher` will
  13430. // also use it. But in this case, highlight/downplay are only supported in
  13431. // mouse hover but not in dispatchAction.
  13432. enterEmphasisWhenMouseOver(dispatcher, e)
  13433. }
  13434. }
  13435. function handleGlobalMouseOutForHighDown(dispatcher, e, api) {
  13436. allLeaveBlur(api)
  13437. var ecData = getECData(dispatcher)
  13438. var dispatchers = findComponentHighDownDispatchers(
  13439. ecData.componentMainType,
  13440. ecData.componentIndex,
  13441. ecData.componentHighDownName,
  13442. api
  13443. ).dispatchers
  13444. if (dispatchers) {
  13445. each$7(dispatchers, function (dispatcher) {
  13446. return leaveEmphasisWhenMouseOut(dispatcher, e)
  13447. })
  13448. } else {
  13449. leaveEmphasisWhenMouseOut(dispatcher, e)
  13450. }
  13451. }
  13452. function toggleSelectionFromPayload(seriesModel, payload, api) {
  13453. if (!isSelectChangePayload(payload)) {
  13454. return
  13455. }
  13456. var dataType = payload.dataType
  13457. var data = seriesModel.getData(dataType)
  13458. var dataIndex = queryDataIndex(data, payload)
  13459. if (!isArray(dataIndex)) {
  13460. dataIndex = [dataIndex]
  13461. }
  13462. seriesModel[
  13463. payload.type === TOGGLE_SELECT_ACTION_TYPE
  13464. ? 'toggleSelect'
  13465. : payload.type === SELECT_ACTION_TYPE
  13466. ? 'select'
  13467. : 'unselect'
  13468. ](dataIndex, dataType)
  13469. }
  13470. function updateSeriesElementSelection(seriesModel) {
  13471. var allData = seriesModel.getAllData()
  13472. each$7(allData, function (_a) {
  13473. var data = _a.data,
  13474. type = _a.type
  13475. data.eachItemGraphicEl(function (el, idx) {
  13476. seriesModel.isSelected(idx, type)
  13477. ? enterSelect(el)
  13478. : leaveSelect(el)
  13479. })
  13480. })
  13481. }
  13482. function getAllSelectedIndices(ecModel) {
  13483. var ret = []
  13484. ecModel.eachSeries(function (seriesModel) {
  13485. var allData = seriesModel.getAllData()
  13486. each$7(allData, function (_a) {
  13487. _a.data
  13488. var type = _a.type
  13489. var dataIndices = seriesModel.getSelectedDataIndices()
  13490. if (dataIndices.length > 0) {
  13491. var item = {
  13492. dataIndex: dataIndices,
  13493. seriesIndex: seriesModel.seriesIndex
  13494. }
  13495. if (type != null) {
  13496. item.dataType = type
  13497. }
  13498. ret.push(item)
  13499. }
  13500. })
  13501. })
  13502. return ret
  13503. }
  13504. /**
  13505. * Enable the function that mouseover will trigger the emphasis state.
  13506. *
  13507. * NOTE:
  13508. * This function should be used on the element with dataIndex, seriesIndex.
  13509. *
  13510. */ function enableHoverEmphasis(el, focus, blurScope) {
  13511. setAsHighDownDispatcher(el, true)
  13512. traverseUpdateState(el, setDefaultStateProxy)
  13513. enableHoverFocus(el, focus, blurScope)
  13514. }
  13515. function disableHoverEmphasis(el) {
  13516. setAsHighDownDispatcher(el, false)
  13517. }
  13518. function toggleHoverEmphasis(el, focus, blurScope, isDisabled) {
  13519. isDisabled
  13520. ? disableHoverEmphasis(el)
  13521. : enableHoverEmphasis(el, focus, blurScope)
  13522. }
  13523. function enableHoverFocus(el, focus, blurScope) {
  13524. var ecData = getECData(el)
  13525. if (focus != null) {
  13526. // TODO dataIndex may be set after this function. This check is not useful.
  13527. // if (ecData.dataIndex == null) {
  13528. // if (__DEV__) {
  13529. // console.warn('focus can only been set on element with dataIndex');
  13530. // }
  13531. // }
  13532. // else {
  13533. ecData.focus = focus
  13534. ecData.blurScope = blurScope // }
  13535. } else if (ecData.focus) {
  13536. ecData.focus = null
  13537. }
  13538. }
  13539. var OTHER_STATES = ['emphasis', 'blur', 'select']
  13540. var defaultStyleGetterMap = {
  13541. itemStyle: 'getItemStyle',
  13542. lineStyle: 'getLineStyle',
  13543. areaStyle: 'getAreaStyle'
  13544. }
  13545. /**
  13546. * Set emphasis/blur/selected states of element.
  13547. */ function setStatesStylesFromModel(
  13548. el,
  13549. itemModel,
  13550. styleType, // default itemStyle
  13551. getter
  13552. ) {
  13553. styleType = styleType || 'itemStyle'
  13554. for (var i = 0; i < OTHER_STATES.length; i++) {
  13555. var stateName = OTHER_STATES[i]
  13556. var model = itemModel.getModel([stateName, styleType])
  13557. var state = el.ensureState(stateName) // Let it throw error if getterType is not found.
  13558. state.style = getter
  13559. ? getter(model)
  13560. : model[defaultStyleGetterMap[styleType]]()
  13561. }
  13562. }
  13563. /**
  13564. *
  13565. * Set element as highlight / downplay dispatcher.
  13566. * It will be checked when element recieved mouseover event or from highlight action.
  13567. * It's in change of all highlight/downplay behavior of it's children.
  13568. *
  13569. * @param el
  13570. * @param el.highDownSilentOnTouch
  13571. * In touch device, mouseover event will be trigger on touchstart event
  13572. * (see module:zrender/dom/HandlerProxy). By this mechanism, we can
  13573. * conveniently use hoverStyle when tap on touch screen without additional
  13574. * code for compatibility.
  13575. * But if the chart/component has select feature, which usually also use
  13576. * hoverStyle, there might be conflict between 'select-highlight' and
  13577. * 'hover-highlight' especially when roam is enabled (see geo for example).
  13578. * In this case, `highDownSilentOnTouch` should be used to disable
  13579. * hover-highlight on touch device.
  13580. * @param asDispatcher If `false`, do not set as "highDownDispatcher".
  13581. */ function setAsHighDownDispatcher(el, asDispatcher) {
  13582. var disable = asDispatcher === false
  13583. var extendedEl = el // Make `highDownSilentOnTouch` and `onStateChange` only work after
  13584. // `setAsHighDownDispatcher` called. Avoid it is modified by user unexpectedly.
  13585. if (el.highDownSilentOnTouch) {
  13586. extendedEl.__highDownSilentOnTouch = el.highDownSilentOnTouch
  13587. } // Simple optimize, since this method might be
  13588. // called for each elements of a group in some cases.
  13589. if (!disable || extendedEl.__highDownDispatcher) {
  13590. // Emphasis, normal can be triggered manually by API or other components like hover link.
  13591. // el[method]('emphasis', onElementEmphasisEvent)[method]('normal', onElementNormalEvent);
  13592. // Also keep previous record.
  13593. extendedEl.__highByOuter = extendedEl.__highByOuter || 0
  13594. extendedEl.__highDownDispatcher = !disable
  13595. }
  13596. }
  13597. function isHighDownDispatcher(el) {
  13598. return !!(el && el.__highDownDispatcher)
  13599. }
  13600. /**
  13601. * Support hightlight/downplay record on each elements.
  13602. * For the case: hover highlight/downplay (legend, visualMap, ...) and
  13603. * user triggerred hightlight/downplay should not conflict.
  13604. * Only all of the highlightDigit cleared, return to normal.
  13605. * @param {string} highlightKey
  13606. * @return {number} highlightDigit
  13607. */ function getHighlightDigit(highlightKey) {
  13608. var highlightDigit = _highlightKeyMap[highlightKey]
  13609. if (highlightDigit == null && _highlightNextDigit <= 32) {
  13610. highlightDigit = _highlightKeyMap[highlightKey] =
  13611. _highlightNextDigit++
  13612. }
  13613. return highlightDigit
  13614. }
  13615. function isSelectChangePayload(payload) {
  13616. var payloadType = payload.type
  13617. return (
  13618. payloadType === SELECT_ACTION_TYPE ||
  13619. payloadType === UNSELECT_ACTION_TYPE ||
  13620. payloadType === TOGGLE_SELECT_ACTION_TYPE
  13621. )
  13622. }
  13623. function isHighDownPayload(payload) {
  13624. var payloadType = payload.type
  13625. return (
  13626. payloadType === HIGHLIGHT_ACTION_TYPE ||
  13627. payloadType === DOWNPLAY_ACTION_TYPE
  13628. )
  13629. }
  13630. function savePathStates(el) {
  13631. var store = getSavedStates(el)
  13632. store.normalFill = el.style.fill
  13633. store.normalStroke = el.style.stroke
  13634. var selectState = el.states.select || {}
  13635. store.selectFill =
  13636. (selectState.style && selectState.style.fill) || null
  13637. store.selectStroke =
  13638. (selectState.style && selectState.style.stroke) || null
  13639. }
  13640. var CMD$2 = PathProxy$1.CMD
  13641. var points = [[], [], []]
  13642. var mathSqrt$2 = Math.sqrt
  13643. var mathAtan2 = Math.atan2
  13644. function transformPath(path, m) {
  13645. if (!m) {
  13646. return
  13647. }
  13648. var data = path.data
  13649. var len = path.len()
  13650. var cmd
  13651. var nPoint
  13652. var i
  13653. var j
  13654. var k
  13655. var p
  13656. var M = CMD$2.M
  13657. var C = CMD$2.C
  13658. var L = CMD$2.L
  13659. var R = CMD$2.R
  13660. var A = CMD$2.A
  13661. var Q = CMD$2.Q
  13662. for (i = 0, j = 0; i < len; ) {
  13663. cmd = data[i++]
  13664. j = i
  13665. nPoint = 0
  13666. switch (cmd) {
  13667. case M:
  13668. nPoint = 1
  13669. break
  13670. case L:
  13671. nPoint = 1
  13672. break
  13673. case C:
  13674. nPoint = 3
  13675. break
  13676. case Q:
  13677. nPoint = 2
  13678. break
  13679. case A:
  13680. var x = m[4]
  13681. var y = m[5]
  13682. var sx = mathSqrt$2(m[0] * m[0] + m[1] * m[1])
  13683. var sy = mathSqrt$2(m[2] * m[2] + m[3] * m[3])
  13684. var angle = mathAtan2(-m[1] / sy, m[0] / sx)
  13685. data[i] *= sx
  13686. data[i++] += x
  13687. data[i] *= sy
  13688. data[i++] += y
  13689. data[i++] *= sx
  13690. data[i++] *= sy
  13691. data[i++] += angle
  13692. data[i++] += angle
  13693. i += 2
  13694. j = i
  13695. break
  13696. case R:
  13697. p[0] = data[i++]
  13698. p[1] = data[i++]
  13699. applyTransform$1(p, p, m)
  13700. data[j++] = p[0]
  13701. data[j++] = p[1]
  13702. p[0] += data[i++]
  13703. p[1] += data[i++]
  13704. applyTransform$1(p, p, m)
  13705. data[j++] = p[0]
  13706. data[j++] = p[1]
  13707. }
  13708. for (k = 0; k < nPoint; k++) {
  13709. var p_1 = points[k]
  13710. p_1[0] = data[i++]
  13711. p_1[1] = data[i++]
  13712. applyTransform$1(p_1, p_1, m)
  13713. data[j++] = p_1[0]
  13714. data[j++] = p_1[1]
  13715. }
  13716. }
  13717. path.increaseVersion()
  13718. }
  13719. var mathSqrt$1 = Math.sqrt
  13720. var mathSin$1 = Math.sin
  13721. var mathCos$1 = Math.cos
  13722. var PI$3 = Math.PI
  13723. function vMag(v) {
  13724. return Math.sqrt(v[0] * v[0] + v[1] * v[1])
  13725. }
  13726. function vRatio(u, v) {
  13727. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v))
  13728. }
  13729. function vAngle(u, v) {
  13730. return (
  13731. (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v))
  13732. )
  13733. }
  13734. function processArc(
  13735. x1,
  13736. y1,
  13737. x2,
  13738. y2,
  13739. fa,
  13740. fs,
  13741. rx,
  13742. ry,
  13743. psiDeg,
  13744. cmd,
  13745. path
  13746. ) {
  13747. var psi = psiDeg * (PI$3 / 180.0)
  13748. var xp =
  13749. (mathCos$1(psi) * (x1 - x2)) / 2.0 +
  13750. (mathSin$1(psi) * (y1 - y2)) / 2.0
  13751. var yp =
  13752. (-1 * mathSin$1(psi) * (x1 - x2)) / 2.0 +
  13753. (mathCos$1(psi) * (y1 - y2)) / 2.0
  13754. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry)
  13755. if (lambda > 1) {
  13756. rx *= mathSqrt$1(lambda)
  13757. ry *= mathSqrt$1(lambda)
  13758. }
  13759. var f =
  13760. (fa === fs ? -1 : 1) *
  13761. mathSqrt$1(
  13762. (rx * rx * (ry * ry) -
  13763. rx * rx * (yp * yp) -
  13764. ry * ry * (xp * xp)) /
  13765. (rx * rx * (yp * yp) + ry * ry * (xp * xp))
  13766. ) || 0
  13767. var cxp = (f * rx * yp) / ry
  13768. var cyp = (f * -ry * xp) / rx
  13769. var cx =
  13770. (x1 + x2) / 2.0 + mathCos$1(psi) * cxp - mathSin$1(psi) * cyp
  13771. var cy =
  13772. (y1 + y2) / 2.0 + mathSin$1(psi) * cxp + mathCos$1(psi) * cyp
  13773. var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry])
  13774. var u = [(xp - cxp) / rx, (yp - cyp) / ry]
  13775. var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry]
  13776. var dTheta = vAngle(u, v)
  13777. if (vRatio(u, v) <= -1) {
  13778. dTheta = PI$3
  13779. }
  13780. if (vRatio(u, v) >= 1) {
  13781. dTheta = 0
  13782. }
  13783. if (dTheta < 0) {
  13784. var n = Math.round((dTheta / PI$3) * 1e6) / 1e6
  13785. dTheta = PI$3 * 2 + (n % 2) * PI$3
  13786. }
  13787. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs)
  13788. }
  13789. var commandReg = /([mlvhzcqtsa])([^mlvhzcqtsa]*)/gi
  13790. var numberReg = /-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g
  13791. function createPathProxyFromString(data) {
  13792. var path = new PathProxy$1()
  13793. if (!data) {
  13794. return path
  13795. }
  13796. var cpx = 0
  13797. var cpy = 0
  13798. var subpathX = cpx
  13799. var subpathY = cpy
  13800. var prevCmd
  13801. var CMD = PathProxy$1.CMD
  13802. var cmdList = data.match(commandReg)
  13803. if (!cmdList) {
  13804. return path
  13805. }
  13806. for (var l = 0; l < cmdList.length; l++) {
  13807. var cmdText = cmdList[l]
  13808. var cmdStr = cmdText.charAt(0)
  13809. var cmd = void 0
  13810. var p = cmdText.match(numberReg) || []
  13811. var pLen = p.length
  13812. for (var i = 0; i < pLen; i++) {
  13813. p[i] = parseFloat(p[i])
  13814. }
  13815. var off = 0
  13816. while (off < pLen) {
  13817. var ctlPtx = void 0
  13818. var ctlPty = void 0
  13819. var rx = void 0
  13820. var ry = void 0
  13821. var psi = void 0
  13822. var fa = void 0
  13823. var fs = void 0
  13824. var x1 = cpx
  13825. var y1 = cpy
  13826. var len = void 0
  13827. var pathData = void 0
  13828. switch (cmdStr) {
  13829. case 'l':
  13830. cpx += p[off++]
  13831. cpy += p[off++]
  13832. cmd = CMD.L
  13833. path.addData(cmd, cpx, cpy)
  13834. break
  13835. case 'L':
  13836. cpx = p[off++]
  13837. cpy = p[off++]
  13838. cmd = CMD.L
  13839. path.addData(cmd, cpx, cpy)
  13840. break
  13841. case 'm':
  13842. cpx += p[off++]
  13843. cpy += p[off++]
  13844. cmd = CMD.M
  13845. path.addData(cmd, cpx, cpy)
  13846. subpathX = cpx
  13847. subpathY = cpy
  13848. cmdStr = 'l'
  13849. break
  13850. case 'M':
  13851. cpx = p[off++]
  13852. cpy = p[off++]
  13853. cmd = CMD.M
  13854. path.addData(cmd, cpx, cpy)
  13855. subpathX = cpx
  13856. subpathY = cpy
  13857. cmdStr = 'L'
  13858. break
  13859. case 'h':
  13860. cpx += p[off++]
  13861. cmd = CMD.L
  13862. path.addData(cmd, cpx, cpy)
  13863. break
  13864. case 'H':
  13865. cpx = p[off++]
  13866. cmd = CMD.L
  13867. path.addData(cmd, cpx, cpy)
  13868. break
  13869. case 'v':
  13870. cpy += p[off++]
  13871. cmd = CMD.L
  13872. path.addData(cmd, cpx, cpy)
  13873. break
  13874. case 'V':
  13875. cpy = p[off++]
  13876. cmd = CMD.L
  13877. path.addData(cmd, cpx, cpy)
  13878. break
  13879. case 'C':
  13880. cmd = CMD.C
  13881. path.addData(
  13882. cmd,
  13883. p[off++],
  13884. p[off++],
  13885. p[off++],
  13886. p[off++],
  13887. p[off++],
  13888. p[off++]
  13889. )
  13890. cpx = p[off - 2]
  13891. cpy = p[off - 1]
  13892. break
  13893. case 'c':
  13894. cmd = CMD.C
  13895. path.addData(
  13896. cmd,
  13897. p[off++] + cpx,
  13898. p[off++] + cpy,
  13899. p[off++] + cpx,
  13900. p[off++] + cpy,
  13901. p[off++] + cpx,
  13902. p[off++] + cpy
  13903. )
  13904. cpx += p[off - 2]
  13905. cpy += p[off - 1]
  13906. break
  13907. case 'S':
  13908. ctlPtx = cpx
  13909. ctlPty = cpy
  13910. len = path.len()
  13911. pathData = path.data
  13912. if (prevCmd === CMD.C) {
  13913. ctlPtx += cpx - pathData[len - 4]
  13914. ctlPty += cpy - pathData[len - 3]
  13915. }
  13916. cmd = CMD.C
  13917. x1 = p[off++]
  13918. y1 = p[off++]
  13919. cpx = p[off++]
  13920. cpy = p[off++]
  13921. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy)
  13922. break
  13923. case 's':
  13924. ctlPtx = cpx
  13925. ctlPty = cpy
  13926. len = path.len()
  13927. pathData = path.data
  13928. if (prevCmd === CMD.C) {
  13929. ctlPtx += cpx - pathData[len - 4]
  13930. ctlPty += cpy - pathData[len - 3]
  13931. }
  13932. cmd = CMD.C
  13933. x1 = cpx + p[off++]
  13934. y1 = cpy + p[off++]
  13935. cpx += p[off++]
  13936. cpy += p[off++]
  13937. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy)
  13938. break
  13939. case 'Q':
  13940. x1 = p[off++]
  13941. y1 = p[off++]
  13942. cpx = p[off++]
  13943. cpy = p[off++]
  13944. cmd = CMD.Q
  13945. path.addData(cmd, x1, y1, cpx, cpy)
  13946. break
  13947. case 'q':
  13948. x1 = p[off++] + cpx
  13949. y1 = p[off++] + cpy
  13950. cpx += p[off++]
  13951. cpy += p[off++]
  13952. cmd = CMD.Q
  13953. path.addData(cmd, x1, y1, cpx, cpy)
  13954. break
  13955. case 'T':
  13956. ctlPtx = cpx
  13957. ctlPty = cpy
  13958. len = path.len()
  13959. pathData = path.data
  13960. if (prevCmd === CMD.Q) {
  13961. ctlPtx += cpx - pathData[len - 4]
  13962. ctlPty += cpy - pathData[len - 3]
  13963. }
  13964. cpx = p[off++]
  13965. cpy = p[off++]
  13966. cmd = CMD.Q
  13967. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy)
  13968. break
  13969. case 't':
  13970. ctlPtx = cpx
  13971. ctlPty = cpy
  13972. len = path.len()
  13973. pathData = path.data
  13974. if (prevCmd === CMD.Q) {
  13975. ctlPtx += cpx - pathData[len - 4]
  13976. ctlPty += cpy - pathData[len - 3]
  13977. }
  13978. cpx += p[off++]
  13979. cpy += p[off++]
  13980. cmd = CMD.Q
  13981. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy)
  13982. break
  13983. case 'A':
  13984. rx = p[off++]
  13985. ry = p[off++]
  13986. psi = p[off++]
  13987. fa = p[off++]
  13988. fs = p[off++]
  13989. ;(x1 = cpx), (y1 = cpy)
  13990. cpx = p[off++]
  13991. cpy = p[off++]
  13992. cmd = CMD.A
  13993. processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path)
  13994. break
  13995. case 'a':
  13996. rx = p[off++]
  13997. ry = p[off++]
  13998. psi = p[off++]
  13999. fa = p[off++]
  14000. fs = p[off++]
  14001. ;(x1 = cpx), (y1 = cpy)
  14002. cpx += p[off++]
  14003. cpy += p[off++]
  14004. cmd = CMD.A
  14005. processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path)
  14006. break
  14007. }
  14008. }
  14009. if (cmdStr === 'z' || cmdStr === 'Z') {
  14010. cmd = CMD.Z
  14011. path.addData(cmd)
  14012. cpx = subpathX
  14013. cpy = subpathY
  14014. }
  14015. prevCmd = cmd
  14016. }
  14017. path.toStatic()
  14018. return path
  14019. }
  14020. var SVGPath = (function (_super) {
  14021. __extends(SVGPath, _super)
  14022. function SVGPath() {
  14023. return (_super !== null && _super.apply(this, arguments)) || this
  14024. }
  14025. SVGPath.prototype.applyTransform = function (m) {}
  14026. return SVGPath
  14027. })(Path$1)
  14028. function isPathProxy(path) {
  14029. return path.setData != null
  14030. }
  14031. function createPathOptions(str, opts) {
  14032. var pathProxy = createPathProxyFromString(str)
  14033. var innerOpts = extend({}, opts)
  14034. innerOpts.buildPath = function (path) {
  14035. if (isPathProxy(path)) {
  14036. path.setData(pathProxy.data)
  14037. var ctx = path.getContext()
  14038. if (ctx) {
  14039. path.rebuildPath(ctx, 1)
  14040. }
  14041. } else {
  14042. var ctx = path
  14043. pathProxy.rebuildPath(ctx, 1)
  14044. }
  14045. }
  14046. innerOpts.applyTransform = function (m) {
  14047. transformPath(pathProxy, m)
  14048. this.dirtyShape()
  14049. }
  14050. return innerOpts
  14051. }
  14052. function createFromString(str, opts) {
  14053. return new SVGPath(createPathOptions(str, opts))
  14054. }
  14055. function extendFromString(str, defaultOpts) {
  14056. var innerOpts = createPathOptions(str, defaultOpts)
  14057. var Sub = (function (_super) {
  14058. __extends(Sub, _super)
  14059. function Sub(opts) {
  14060. var _this = _super.call(this, opts) || this
  14061. _this.applyTransform = innerOpts.applyTransform
  14062. _this.buildPath = innerOpts.buildPath
  14063. return _this
  14064. }
  14065. return Sub
  14066. })(SVGPath)
  14067. return Sub
  14068. }
  14069. function mergePath$1(pathEls, opts) {
  14070. var pathList = []
  14071. var len = pathEls.length
  14072. for (var i = 0; i < len; i++) {
  14073. var pathEl = pathEls[i]
  14074. pathList.push(pathEl.getUpdatedPathProxy(true))
  14075. }
  14076. var pathBundle = new Path$1(opts)
  14077. pathBundle.createPathProxy()
  14078. pathBundle.buildPath = function (path) {
  14079. if (isPathProxy(path)) {
  14080. path.appendPath(pathList)
  14081. var ctx = path.getContext()
  14082. if (ctx) {
  14083. path.rebuildPath(ctx, 1)
  14084. }
  14085. }
  14086. }
  14087. return pathBundle
  14088. }
  14089. function clonePath(sourcePath, opts) {
  14090. opts = opts || {}
  14091. var path = new Path$1()
  14092. if (sourcePath.shape) {
  14093. path.setShape(sourcePath.shape)
  14094. }
  14095. path.setStyle(sourcePath.style)
  14096. if (opts.bakeTransform) {
  14097. transformPath(path.path, sourcePath.getComputedTransform())
  14098. } else {
  14099. if (opts.toLocal) {
  14100. path.setLocalTransform(sourcePath.getComputedTransform())
  14101. } else {
  14102. path.copyTransform(sourcePath)
  14103. }
  14104. }
  14105. path.buildPath = sourcePath.buildPath
  14106. path.applyTransform = path.applyTransform
  14107. path.z = sourcePath.z
  14108. path.z2 = sourcePath.z2
  14109. path.zlevel = sourcePath.zlevel
  14110. return path
  14111. }
  14112. var CircleShape = (function () {
  14113. function CircleShape() {
  14114. this.cx = 0
  14115. this.cy = 0
  14116. this.r = 0
  14117. }
  14118. return CircleShape
  14119. })()
  14120. var Circle = (function (_super) {
  14121. __extends(Circle, _super)
  14122. function Circle(opts) {
  14123. return _super.call(this, opts) || this
  14124. }
  14125. Circle.prototype.getDefaultShape = function () {
  14126. return new CircleShape()
  14127. }
  14128. Circle.prototype.buildPath = function (ctx, shape) {
  14129. ctx.moveTo(shape.cx + shape.r, shape.cy)
  14130. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2)
  14131. }
  14132. return Circle
  14133. })(Path$1)
  14134. Circle.prototype.type = 'circle'
  14135. var Circle$1 = Circle
  14136. var EllipseShape = (function () {
  14137. function EllipseShape() {
  14138. this.cx = 0
  14139. this.cy = 0
  14140. this.rx = 0
  14141. this.ry = 0
  14142. }
  14143. return EllipseShape
  14144. })()
  14145. var Ellipse = (function (_super) {
  14146. __extends(Ellipse, _super)
  14147. function Ellipse(opts) {
  14148. return _super.call(this, opts) || this
  14149. }
  14150. Ellipse.prototype.getDefaultShape = function () {
  14151. return new EllipseShape()
  14152. }
  14153. Ellipse.prototype.buildPath = function (ctx, shape) {
  14154. var k = 0.5522848
  14155. var x = shape.cx
  14156. var y = shape.cy
  14157. var a = shape.rx
  14158. var b = shape.ry
  14159. var ox = a * k
  14160. var oy = b * k
  14161. ctx.moveTo(x - a, y)
  14162. ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b)
  14163. ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y)
  14164. ctx.bezierCurveTo(x + a, y + oy, x + ox, y + b, x, y + b)
  14165. ctx.bezierCurveTo(x - ox, y + b, x - a, y + oy, x - a, y)
  14166. ctx.closePath()
  14167. }
  14168. return Ellipse
  14169. })(Path$1)
  14170. Ellipse.prototype.type = 'ellipse'
  14171. var Ellipse$1 = Ellipse
  14172. var PI$2 = Math.PI
  14173. var PI2$2 = PI$2 * 2
  14174. var mathSin = Math.sin
  14175. var mathCos = Math.cos
  14176. var mathACos = Math.acos
  14177. var mathATan2 = Math.atan2
  14178. var mathAbs = Math.abs
  14179. var mathSqrt = Math.sqrt
  14180. var mathMax$4 = Math.max
  14181. var mathMin$4 = Math.min
  14182. var e = 1e-4
  14183. function intersect(x0, y0, x1, y1, x2, y2, x3, y3) {
  14184. var dx10 = x1 - x0
  14185. var dy10 = y1 - y0
  14186. var dx32 = x3 - x2
  14187. var dy32 = y3 - y2
  14188. var t = dy32 * dx10 - dx32 * dy10
  14189. if (t * t < e) {
  14190. return
  14191. }
  14192. t = (dx32 * (y0 - y2) - dy32 * (x0 - x2)) / t
  14193. return [x0 + t * dx10, y0 + t * dy10]
  14194. }
  14195. function computeCornerTangents(
  14196. x0,
  14197. y0,
  14198. x1,
  14199. y1,
  14200. radius,
  14201. cr,
  14202. clockwise
  14203. ) {
  14204. var x01 = x0 - x1
  14205. var y01 = y0 - y1
  14206. var lo = (clockwise ? cr : -cr) / mathSqrt(x01 * x01 + y01 * y01)
  14207. var ox = lo * y01
  14208. var oy = -lo * x01
  14209. var x11 = x0 + ox
  14210. var y11 = y0 + oy
  14211. var x10 = x1 + ox
  14212. var y10 = y1 + oy
  14213. var x00 = (x11 + x10) / 2
  14214. var y00 = (y11 + y10) / 2
  14215. var dx = x10 - x11
  14216. var dy = y10 - y11
  14217. var d2 = dx * dx + dy * dy
  14218. var r = radius - cr
  14219. var s = x11 * y10 - x10 * y11
  14220. var d =
  14221. (dy < 0 ? -1 : 1) * mathSqrt(mathMax$4(0, r * r * d2 - s * s))
  14222. var cx0 = (s * dy - dx * d) / d2
  14223. var cy0 = (-s * dx - dy * d) / d2
  14224. var cx1 = (s * dy + dx * d) / d2
  14225. var cy1 = (-s * dx + dy * d) / d2
  14226. var dx0 = cx0 - x00
  14227. var dy0 = cy0 - y00
  14228. var dx1 = cx1 - x00
  14229. var dy1 = cy1 - y00
  14230. if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) {
  14231. cx0 = cx1
  14232. cy0 = cy1
  14233. }
  14234. return {
  14235. cx: cx0,
  14236. cy: cy0,
  14237. x0: -ox,
  14238. y0: -oy,
  14239. x1: cx0 * (radius / r - 1),
  14240. y1: cy0 * (radius / r - 1)
  14241. }
  14242. }
  14243. function normalizeCornerRadius(cr) {
  14244. var arr
  14245. if (isArray(cr)) {
  14246. var len = cr.length
  14247. if (!len) {
  14248. return cr
  14249. }
  14250. if (len === 1) {
  14251. arr = [cr[0], cr[0], 0, 0]
  14252. } else if (len === 2) {
  14253. arr = [cr[0], cr[0], cr[1], cr[1]]
  14254. } else if (len === 3) {
  14255. arr = cr.concat(cr[2])
  14256. } else {
  14257. arr = cr
  14258. }
  14259. } else {
  14260. arr = [cr, cr, cr, cr]
  14261. }
  14262. return arr
  14263. }
  14264. function buildPath$1(ctx, shape) {
  14265. var _a
  14266. var radius = mathMax$4(shape.r, 0)
  14267. var innerRadius = mathMax$4(shape.r0 || 0, 0)
  14268. var hasRadius = radius > 0
  14269. var hasInnerRadius = innerRadius > 0
  14270. if (!hasRadius && !hasInnerRadius) {
  14271. return
  14272. }
  14273. if (!hasRadius) {
  14274. radius = innerRadius
  14275. innerRadius = 0
  14276. }
  14277. if (innerRadius > radius) {
  14278. var tmp = radius
  14279. radius = innerRadius
  14280. innerRadius = tmp
  14281. }
  14282. var startAngle = shape.startAngle,
  14283. endAngle = shape.endAngle
  14284. if (isNaN(startAngle) || isNaN(endAngle)) {
  14285. return
  14286. }
  14287. var cx = shape.cx,
  14288. cy = shape.cy
  14289. var clockwise = !!shape.clockwise
  14290. var arc = mathAbs(endAngle - startAngle)
  14291. var mod = arc > PI2$2 && arc % PI2$2
  14292. mod > e && (arc = mod)
  14293. if (!(radius > e)) {
  14294. ctx.moveTo(cx, cy)
  14295. } else if (arc > PI2$2 - e) {
  14296. ctx.moveTo(
  14297. cx + radius * mathCos(startAngle),
  14298. cy + radius * mathSin(startAngle)
  14299. )
  14300. ctx.arc(cx, cy, radius, startAngle, endAngle, !clockwise)
  14301. if (innerRadius > e) {
  14302. ctx.moveTo(
  14303. cx + innerRadius * mathCos(endAngle),
  14304. cy + innerRadius * mathSin(endAngle)
  14305. )
  14306. ctx.arc(cx, cy, innerRadius, endAngle, startAngle, clockwise)
  14307. }
  14308. } else {
  14309. var icrStart = void 0
  14310. var icrEnd = void 0
  14311. var ocrStart = void 0
  14312. var ocrEnd = void 0
  14313. var ocrs = void 0
  14314. var ocre = void 0
  14315. var icrs = void 0
  14316. var icre = void 0
  14317. var ocrMax = void 0
  14318. var icrMax = void 0
  14319. var limitedOcrMax = void 0
  14320. var limitedIcrMax = void 0
  14321. var xre = void 0
  14322. var yre = void 0
  14323. var xirs = void 0
  14324. var yirs = void 0
  14325. var xrs = radius * mathCos(startAngle)
  14326. var yrs = radius * mathSin(startAngle)
  14327. var xire = innerRadius * mathCos(endAngle)
  14328. var yire = innerRadius * mathSin(endAngle)
  14329. var hasArc = arc > e
  14330. if (hasArc) {
  14331. var cornerRadius = shape.cornerRadius
  14332. if (cornerRadius) {
  14333. ;(_a = normalizeCornerRadius(cornerRadius)),
  14334. (icrStart = _a[0]),
  14335. (icrEnd = _a[1]),
  14336. (ocrStart = _a[2]),
  14337. (ocrEnd = _a[3])
  14338. }
  14339. var halfRd = mathAbs(radius - innerRadius) / 2
  14340. ocrs = mathMin$4(halfRd, ocrStart)
  14341. ocre = mathMin$4(halfRd, ocrEnd)
  14342. icrs = mathMin$4(halfRd, icrStart)
  14343. icre = mathMin$4(halfRd, icrEnd)
  14344. limitedOcrMax = ocrMax = mathMax$4(ocrs, ocre)
  14345. limitedIcrMax = icrMax = mathMax$4(icrs, icre)
  14346. if (ocrMax > e || icrMax > e) {
  14347. xre = radius * mathCos(endAngle)
  14348. yre = radius * mathSin(endAngle)
  14349. xirs = innerRadius * mathCos(startAngle)
  14350. yirs = innerRadius * mathSin(startAngle)
  14351. if (arc < PI$2) {
  14352. var it_1 = intersect(
  14353. xrs,
  14354. yrs,
  14355. xirs,
  14356. yirs,
  14357. xre,
  14358. yre,
  14359. xire,
  14360. yire
  14361. )
  14362. if (it_1) {
  14363. var x0 = xrs - it_1[0]
  14364. var y0 = yrs - it_1[1]
  14365. var x1 = xre - it_1[0]
  14366. var y1 = yre - it_1[1]
  14367. var a =
  14368. 1 /
  14369. mathSin(
  14370. mathACos(
  14371. (x0 * x1 + y0 * y1) /
  14372. (mathSqrt(x0 * x0 + y0 * y0) *
  14373. mathSqrt(x1 * x1 + y1 * y1))
  14374. ) / 2
  14375. )
  14376. var b = mathSqrt(it_1[0] * it_1[0] + it_1[1] * it_1[1])
  14377. limitedOcrMax = mathMin$4(ocrMax, (radius - b) / (a + 1))
  14378. limitedIcrMax = mathMin$4(
  14379. icrMax,
  14380. (innerRadius - b) / (a - 1)
  14381. )
  14382. }
  14383. }
  14384. }
  14385. }
  14386. if (!hasArc) {
  14387. ctx.moveTo(cx + xrs, cy + yrs)
  14388. } else if (limitedOcrMax > e) {
  14389. var crStart = mathMin$4(ocrStart, limitedOcrMax)
  14390. var crEnd = mathMin$4(ocrEnd, limitedOcrMax)
  14391. var ct0 = computeCornerTangents(
  14392. xirs,
  14393. yirs,
  14394. xrs,
  14395. yrs,
  14396. radius,
  14397. crStart,
  14398. clockwise
  14399. )
  14400. var ct1 = computeCornerTangents(
  14401. xre,
  14402. yre,
  14403. xire,
  14404. yire,
  14405. radius,
  14406. crEnd,
  14407. clockwise
  14408. )
  14409. ctx.moveTo(cx + ct0.cx + ct0.x0, cy + ct0.cy + ct0.y0)
  14410. if (limitedOcrMax < ocrMax && crStart === crEnd) {
  14411. ctx.arc(
  14412. cx + ct0.cx,
  14413. cy + ct0.cy,
  14414. limitedOcrMax,
  14415. mathATan2(ct0.y0, ct0.x0),
  14416. mathATan2(ct1.y0, ct1.x0),
  14417. !clockwise
  14418. )
  14419. } else {
  14420. crStart > 0 &&
  14421. ctx.arc(
  14422. cx + ct0.cx,
  14423. cy + ct0.cy,
  14424. crStart,
  14425. mathATan2(ct0.y0, ct0.x0),
  14426. mathATan2(ct0.y1, ct0.x1),
  14427. !clockwise
  14428. )
  14429. ctx.arc(
  14430. cx,
  14431. cy,
  14432. radius,
  14433. mathATan2(ct0.cy + ct0.y1, ct0.cx + ct0.x1),
  14434. mathATan2(ct1.cy + ct1.y1, ct1.cx + ct1.x1),
  14435. !clockwise
  14436. )
  14437. crEnd > 0 &&
  14438. ctx.arc(
  14439. cx + ct1.cx,
  14440. cy + ct1.cy,
  14441. crEnd,
  14442. mathATan2(ct1.y1, ct1.x1),
  14443. mathATan2(ct1.y0, ct1.x0),
  14444. !clockwise
  14445. )
  14446. }
  14447. } else {
  14448. ctx.moveTo(cx + xrs, cy + yrs)
  14449. ctx.arc(cx, cy, radius, startAngle, endAngle, !clockwise)
  14450. }
  14451. if (!(innerRadius > e) || !hasArc) {
  14452. ctx.lineTo(cx + xire, cy + yire)
  14453. } else if (limitedIcrMax > e) {
  14454. var crStart = mathMin$4(icrStart, limitedIcrMax)
  14455. var crEnd = mathMin$4(icrEnd, limitedIcrMax)
  14456. var ct0 = computeCornerTangents(
  14457. xire,
  14458. yire,
  14459. xre,
  14460. yre,
  14461. innerRadius,
  14462. -crEnd,
  14463. clockwise
  14464. )
  14465. var ct1 = computeCornerTangents(
  14466. xrs,
  14467. yrs,
  14468. xirs,
  14469. yirs,
  14470. innerRadius,
  14471. -crStart,
  14472. clockwise
  14473. )
  14474. ctx.lineTo(cx + ct0.cx + ct0.x0, cy + ct0.cy + ct0.y0)
  14475. if (limitedIcrMax < icrMax && crStart === crEnd) {
  14476. ctx.arc(
  14477. cx + ct0.cx,
  14478. cy + ct0.cy,
  14479. limitedIcrMax,
  14480. mathATan2(ct0.y0, ct0.x0),
  14481. mathATan2(ct1.y0, ct1.x0),
  14482. !clockwise
  14483. )
  14484. } else {
  14485. crEnd > 0 &&
  14486. ctx.arc(
  14487. cx + ct0.cx,
  14488. cy + ct0.cy,
  14489. crEnd,
  14490. mathATan2(ct0.y0, ct0.x0),
  14491. mathATan2(ct0.y1, ct0.x1),
  14492. !clockwise
  14493. )
  14494. ctx.arc(
  14495. cx,
  14496. cy,
  14497. innerRadius,
  14498. mathATan2(ct0.cy + ct0.y1, ct0.cx + ct0.x1),
  14499. mathATan2(ct1.cy + ct1.y1, ct1.cx + ct1.x1),
  14500. clockwise
  14501. )
  14502. crStart > 0 &&
  14503. ctx.arc(
  14504. cx + ct1.cx,
  14505. cy + ct1.cy,
  14506. crStart,
  14507. mathATan2(ct1.y1, ct1.x1),
  14508. mathATan2(ct1.y0, ct1.x0),
  14509. !clockwise
  14510. )
  14511. }
  14512. } else {
  14513. ctx.lineTo(cx + xire, cy + yire)
  14514. ctx.arc(cx, cy, innerRadius, endAngle, startAngle, clockwise)
  14515. }
  14516. }
  14517. ctx.closePath()
  14518. }
  14519. var SectorShape = (function () {
  14520. function SectorShape() {
  14521. this.cx = 0
  14522. this.cy = 0
  14523. this.r0 = 0
  14524. this.r = 0
  14525. this.startAngle = 0
  14526. this.endAngle = Math.PI * 2
  14527. this.clockwise = true
  14528. this.cornerRadius = 0
  14529. }
  14530. return SectorShape
  14531. })()
  14532. var Sector = (function (_super) {
  14533. __extends(Sector, _super)
  14534. function Sector(opts) {
  14535. return _super.call(this, opts) || this
  14536. }
  14537. Sector.prototype.getDefaultShape = function () {
  14538. return new SectorShape()
  14539. }
  14540. Sector.prototype.buildPath = function (ctx, shape) {
  14541. buildPath$1(ctx, shape)
  14542. }
  14543. Sector.prototype.isZeroArea = function () {
  14544. return (
  14545. this.shape.startAngle === this.shape.endAngle ||
  14546. this.shape.r === this.shape.r0
  14547. )
  14548. }
  14549. return Sector
  14550. })(Path$1)
  14551. Sector.prototype.type = 'sector'
  14552. var Sector$1 = Sector
  14553. var RingShape = (function () {
  14554. function RingShape() {
  14555. this.cx = 0
  14556. this.cy = 0
  14557. this.r = 0
  14558. this.r0 = 0
  14559. }
  14560. return RingShape
  14561. })()
  14562. var Ring = (function (_super) {
  14563. __extends(Ring, _super)
  14564. function Ring(opts) {
  14565. return _super.call(this, opts) || this
  14566. }
  14567. Ring.prototype.getDefaultShape = function () {
  14568. return new RingShape()
  14569. }
  14570. Ring.prototype.buildPath = function (ctx, shape) {
  14571. var x = shape.cx
  14572. var y = shape.cy
  14573. var PI2 = Math.PI * 2
  14574. ctx.moveTo(x + shape.r, y)
  14575. ctx.arc(x, y, shape.r, 0, PI2, false)
  14576. ctx.moveTo(x + shape.r0, y)
  14577. ctx.arc(x, y, shape.r0, 0, PI2, true)
  14578. }
  14579. return Ring
  14580. })(Path$1)
  14581. Ring.prototype.type = 'ring'
  14582. var Ring$1 = Ring
  14583. function smoothBezier(points, smooth, isLoop, constraint) {
  14584. var cps = []
  14585. var v = []
  14586. var v1 = []
  14587. var v2 = []
  14588. var prevPoint
  14589. var nextPoint
  14590. var min
  14591. var max
  14592. if (constraint) {
  14593. min = [Infinity, Infinity]
  14594. max = [-Infinity, -Infinity]
  14595. for (var i = 0, len = points.length; i < len; i++) {
  14596. min$1(min, min, points[i])
  14597. max$1(max, max, points[i])
  14598. }
  14599. min$1(min, min, constraint[0])
  14600. max$1(max, max, constraint[1])
  14601. }
  14602. for (var i = 0, len = points.length; i < len; i++) {
  14603. var point = points[i]
  14604. if (isLoop) {
  14605. prevPoint = points[i ? i - 1 : len - 1]
  14606. nextPoint = points[(i + 1) % len]
  14607. } else {
  14608. if (i === 0 || i === len - 1) {
  14609. cps.push(clone$2(points[i]))
  14610. continue
  14611. } else {
  14612. prevPoint = points[i - 1]
  14613. nextPoint = points[i + 1]
  14614. }
  14615. }
  14616. sub(v, nextPoint, prevPoint)
  14617. scale$2(v, v, smooth)
  14618. var d0 = distance(point, prevPoint)
  14619. var d1 = distance(point, nextPoint)
  14620. var sum = d0 + d1
  14621. if (sum !== 0) {
  14622. d0 /= sum
  14623. d1 /= sum
  14624. }
  14625. scale$2(v1, v, -d0)
  14626. scale$2(v2, v, d1)
  14627. var cp0 = add([], point, v1)
  14628. var cp1 = add([], point, v2)
  14629. if (constraint) {
  14630. max$1(cp0, cp0, min)
  14631. min$1(cp0, cp0, max)
  14632. max$1(cp1, cp1, min)
  14633. min$1(cp1, cp1, max)
  14634. }
  14635. cps.push(cp0)
  14636. cps.push(cp1)
  14637. }
  14638. if (isLoop) {
  14639. cps.push(cps.shift())
  14640. }
  14641. return cps
  14642. }
  14643. function buildPath(ctx, shape, closePath) {
  14644. var smooth = shape.smooth
  14645. var points = shape.points
  14646. if (points && points.length >= 2) {
  14647. if (smooth) {
  14648. var controlPoints = smoothBezier(
  14649. points,
  14650. smooth,
  14651. closePath,
  14652. shape.smoothConstraint
  14653. )
  14654. ctx.moveTo(points[0][0], points[0][1])
  14655. var len = points.length
  14656. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  14657. var cp1 = controlPoints[i * 2]
  14658. var cp2 = controlPoints[i * 2 + 1]
  14659. var p = points[(i + 1) % len]
  14660. ctx.bezierCurveTo(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1])
  14661. }
  14662. } else {
  14663. ctx.moveTo(points[0][0], points[0][1])
  14664. for (var i = 1, l = points.length; i < l; i++) {
  14665. ctx.lineTo(points[i][0], points[i][1])
  14666. }
  14667. }
  14668. closePath && ctx.closePath()
  14669. }
  14670. }
  14671. var PolygonShape = (function () {
  14672. function PolygonShape() {
  14673. this.points = null
  14674. this.smooth = 0
  14675. this.smoothConstraint = null
  14676. }
  14677. return PolygonShape
  14678. })()
  14679. var Polygon = (function (_super) {
  14680. __extends(Polygon, _super)
  14681. function Polygon(opts) {
  14682. return _super.call(this, opts) || this
  14683. }
  14684. Polygon.prototype.getDefaultShape = function () {
  14685. return new PolygonShape()
  14686. }
  14687. Polygon.prototype.buildPath = function (ctx, shape) {
  14688. buildPath(ctx, shape, true)
  14689. }
  14690. return Polygon
  14691. })(Path$1)
  14692. Polygon.prototype.type = 'polygon'
  14693. var Polygon$1 = Polygon
  14694. var PolylineShape = (function () {
  14695. function PolylineShape() {
  14696. this.points = null
  14697. this.percent = 1
  14698. this.smooth = 0
  14699. this.smoothConstraint = null
  14700. }
  14701. return PolylineShape
  14702. })()
  14703. var Polyline = (function (_super) {
  14704. __extends(Polyline, _super)
  14705. function Polyline(opts) {
  14706. return _super.call(this, opts) || this
  14707. }
  14708. Polyline.prototype.getDefaultStyle = function () {
  14709. return { stroke: '#000', fill: null }
  14710. }
  14711. Polyline.prototype.getDefaultShape = function () {
  14712. return new PolylineShape()
  14713. }
  14714. Polyline.prototype.buildPath = function (ctx, shape) {
  14715. buildPath(ctx, shape, false)
  14716. }
  14717. return Polyline
  14718. })(Path$1)
  14719. Polyline.prototype.type = 'polyline'
  14720. var Polyline$1 = Polyline
  14721. var subPixelOptimizeOutputShape = {}
  14722. var LineShape = (function () {
  14723. function LineShape() {
  14724. this.x1 = 0
  14725. this.y1 = 0
  14726. this.x2 = 0
  14727. this.y2 = 0
  14728. this.percent = 1
  14729. }
  14730. return LineShape
  14731. })()
  14732. var Line = (function (_super) {
  14733. __extends(Line, _super)
  14734. function Line(opts) {
  14735. return _super.call(this, opts) || this
  14736. }
  14737. Line.prototype.getDefaultStyle = function () {
  14738. return { stroke: '#000', fill: null }
  14739. }
  14740. Line.prototype.getDefaultShape = function () {
  14741. return new LineShape()
  14742. }
  14743. Line.prototype.buildPath = function (ctx, shape) {
  14744. var x1
  14745. var y1
  14746. var x2
  14747. var y2
  14748. if (this.subPixelOptimize) {
  14749. var optimizedShape = subPixelOptimizeLine$1(
  14750. subPixelOptimizeOutputShape,
  14751. shape,
  14752. this.style
  14753. )
  14754. x1 = optimizedShape.x1
  14755. y1 = optimizedShape.y1
  14756. x2 = optimizedShape.x2
  14757. y2 = optimizedShape.y2
  14758. } else {
  14759. x1 = shape.x1
  14760. y1 = shape.y1
  14761. x2 = shape.x2
  14762. y2 = shape.y2
  14763. }
  14764. var percent = shape.percent
  14765. if (percent === 0) {
  14766. return
  14767. }
  14768. ctx.moveTo(x1, y1)
  14769. if (percent < 1) {
  14770. x2 = x1 * (1 - percent) + x2 * percent
  14771. y2 = y1 * (1 - percent) + y2 * percent
  14772. }
  14773. ctx.lineTo(x2, y2)
  14774. }
  14775. Line.prototype.pointAt = function (p) {
  14776. var shape = this.shape
  14777. return [
  14778. shape.x1 * (1 - p) + shape.x2 * p,
  14779. shape.y1 * (1 - p) + shape.y2 * p
  14780. ]
  14781. }
  14782. return Line
  14783. })(Path$1)
  14784. Line.prototype.type = 'line'
  14785. var Line$1 = Line
  14786. var out = []
  14787. var BezierCurveShape = (function () {
  14788. function BezierCurveShape() {
  14789. this.x1 = 0
  14790. this.y1 = 0
  14791. this.x2 = 0
  14792. this.y2 = 0
  14793. this.cpx1 = 0
  14794. this.cpy1 = 0
  14795. this.percent = 1
  14796. }
  14797. return BezierCurveShape
  14798. })()
  14799. function someVectorAt(shape, t, isTangent) {
  14800. var cpx2 = shape.cpx2
  14801. var cpy2 = shape.cpy2
  14802. if (cpx2 != null || cpy2 != null) {
  14803. return [
  14804. (isTangent ? cubicDerivativeAt : cubicAt)(
  14805. shape.x1,
  14806. shape.cpx1,
  14807. shape.cpx2,
  14808. shape.x2,
  14809. t
  14810. ),
  14811. (isTangent ? cubicDerivativeAt : cubicAt)(
  14812. shape.y1,
  14813. shape.cpy1,
  14814. shape.cpy2,
  14815. shape.y2,
  14816. t
  14817. )
  14818. ]
  14819. } else {
  14820. return [
  14821. (isTangent ? quadraticDerivativeAt : quadraticAt)(
  14822. shape.x1,
  14823. shape.cpx1,
  14824. shape.x2,
  14825. t
  14826. ),
  14827. (isTangent ? quadraticDerivativeAt : quadraticAt)(
  14828. shape.y1,
  14829. shape.cpy1,
  14830. shape.y2,
  14831. t
  14832. )
  14833. ]
  14834. }
  14835. }
  14836. var BezierCurve = (function (_super) {
  14837. __extends(BezierCurve, _super)
  14838. function BezierCurve(opts) {
  14839. return _super.call(this, opts) || this
  14840. }
  14841. BezierCurve.prototype.getDefaultStyle = function () {
  14842. return { stroke: '#000', fill: null }
  14843. }
  14844. BezierCurve.prototype.getDefaultShape = function () {
  14845. return new BezierCurveShape()
  14846. }
  14847. BezierCurve.prototype.buildPath = function (ctx, shape) {
  14848. var x1 = shape.x1
  14849. var y1 = shape.y1
  14850. var x2 = shape.x2
  14851. var y2 = shape.y2
  14852. var cpx1 = shape.cpx1
  14853. var cpy1 = shape.cpy1
  14854. var cpx2 = shape.cpx2
  14855. var cpy2 = shape.cpy2
  14856. var percent = shape.percent
  14857. if (percent === 0) {
  14858. return
  14859. }
  14860. ctx.moveTo(x1, y1)
  14861. if (cpx2 == null || cpy2 == null) {
  14862. if (percent < 1) {
  14863. quadraticSubdivide(x1, cpx1, x2, percent, out)
  14864. cpx1 = out[1]
  14865. x2 = out[2]
  14866. quadraticSubdivide(y1, cpy1, y2, percent, out)
  14867. cpy1 = out[1]
  14868. y2 = out[2]
  14869. }
  14870. ctx.quadraticCurveTo(cpx1, cpy1, x2, y2)
  14871. } else {
  14872. if (percent < 1) {
  14873. cubicSubdivide(x1, cpx1, cpx2, x2, percent, out)
  14874. cpx1 = out[1]
  14875. cpx2 = out[2]
  14876. x2 = out[3]
  14877. cubicSubdivide(y1, cpy1, cpy2, y2, percent, out)
  14878. cpy1 = out[1]
  14879. cpy2 = out[2]
  14880. y2 = out[3]
  14881. }
  14882. ctx.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x2, y2)
  14883. }
  14884. }
  14885. BezierCurve.prototype.pointAt = function (t) {
  14886. return someVectorAt(this.shape, t, false)
  14887. }
  14888. BezierCurve.prototype.tangentAt = function (t) {
  14889. var p = someVectorAt(this.shape, t, true)
  14890. return normalize$1(p, p)
  14891. }
  14892. return BezierCurve
  14893. })(Path$1)
  14894. BezierCurve.prototype.type = 'bezier-curve'
  14895. var BezierCurve$1 = BezierCurve
  14896. var ArcShape = (function () {
  14897. function ArcShape() {
  14898. this.cx = 0
  14899. this.cy = 0
  14900. this.r = 0
  14901. this.startAngle = 0
  14902. this.endAngle = Math.PI * 2
  14903. this.clockwise = true
  14904. }
  14905. return ArcShape
  14906. })()
  14907. var Arc = (function (_super) {
  14908. __extends(Arc, _super)
  14909. function Arc(opts) {
  14910. return _super.call(this, opts) || this
  14911. }
  14912. Arc.prototype.getDefaultStyle = function () {
  14913. return { stroke: '#000', fill: null }
  14914. }
  14915. Arc.prototype.getDefaultShape = function () {
  14916. return new ArcShape()
  14917. }
  14918. Arc.prototype.buildPath = function (ctx, shape) {
  14919. var x = shape.cx
  14920. var y = shape.cy
  14921. var r = Math.max(shape.r, 0)
  14922. var startAngle = shape.startAngle
  14923. var endAngle = shape.endAngle
  14924. var clockwise = shape.clockwise
  14925. var unitX = Math.cos(startAngle)
  14926. var unitY = Math.sin(startAngle)
  14927. ctx.moveTo(unitX * r + x, unitY * r + y)
  14928. ctx.arc(x, y, r, startAngle, endAngle, !clockwise)
  14929. }
  14930. return Arc
  14931. })(Path$1)
  14932. Arc.prototype.type = 'arc'
  14933. var Arc$1 = Arc
  14934. var CompoundPath = (function (_super) {
  14935. __extends(CompoundPath, _super)
  14936. function CompoundPath() {
  14937. var _this =
  14938. (_super !== null && _super.apply(this, arguments)) || this
  14939. _this.type = 'compound'
  14940. return _this
  14941. }
  14942. CompoundPath.prototype._updatePathDirty = function () {
  14943. var paths = this.shape.paths
  14944. var dirtyPath = this.shapeChanged()
  14945. for (var i = 0; i < paths.length; i++) {
  14946. dirtyPath = dirtyPath || paths[i].shapeChanged()
  14947. }
  14948. if (dirtyPath) {
  14949. this.dirtyShape()
  14950. }
  14951. }
  14952. CompoundPath.prototype.beforeBrush = function () {
  14953. this._updatePathDirty()
  14954. var paths = this.shape.paths || []
  14955. var scale = this.getGlobalScale()
  14956. for (var i = 0; i < paths.length; i++) {
  14957. if (!paths[i].path) {
  14958. paths[i].createPathProxy()
  14959. }
  14960. paths[i].path.setScale(
  14961. scale[0],
  14962. scale[1],
  14963. paths[i].segmentIgnoreThreshold
  14964. )
  14965. }
  14966. }
  14967. CompoundPath.prototype.buildPath = function (ctx, shape) {
  14968. var paths = shape.paths || []
  14969. for (var i = 0; i < paths.length; i++) {
  14970. paths[i].buildPath(ctx, paths[i].shape, true)
  14971. }
  14972. }
  14973. CompoundPath.prototype.afterBrush = function () {
  14974. var paths = this.shape.paths || []
  14975. for (var i = 0; i < paths.length; i++) {
  14976. paths[i].pathUpdated()
  14977. }
  14978. }
  14979. CompoundPath.prototype.getBoundingRect = function () {
  14980. this._updatePathDirty.call(this)
  14981. return Path$1.prototype.getBoundingRect.call(this)
  14982. }
  14983. return CompoundPath
  14984. })(Path$1)
  14985. var CompoundPath$1 = CompoundPath
  14986. var Gradient = (function () {
  14987. function Gradient(colorStops) {
  14988. this.colorStops = colorStops || []
  14989. }
  14990. Gradient.prototype.addColorStop = function (offset, color) {
  14991. this.colorStops.push({ offset: offset, color: color })
  14992. }
  14993. return Gradient
  14994. })()
  14995. var Gradient$1 = Gradient
  14996. var LinearGradient = (function (_super) {
  14997. __extends(LinearGradient, _super)
  14998. function LinearGradient(x, y, x2, y2, colorStops, globalCoord) {
  14999. var _this = _super.call(this, colorStops) || this
  15000. _this.x = x == null ? 0 : x
  15001. _this.y = y == null ? 0 : y
  15002. _this.x2 = x2 == null ? 1 : x2
  15003. _this.y2 = y2 == null ? 0 : y2
  15004. _this.type = 'linear'
  15005. _this.global = globalCoord || false
  15006. return _this
  15007. }
  15008. return LinearGradient
  15009. })(Gradient$1)
  15010. var LinearGradient$1 = LinearGradient
  15011. var RadialGradient = (function (_super) {
  15012. __extends(RadialGradient, _super)
  15013. function RadialGradient(x, y, r, colorStops, globalCoord) {
  15014. var _this = _super.call(this, colorStops) || this
  15015. _this.x = x == null ? 0.5 : x
  15016. _this.y = y == null ? 0.5 : y
  15017. _this.r = r == null ? 0.5 : r
  15018. _this.type = 'radial'
  15019. _this.global = globalCoord || false
  15020. return _this
  15021. }
  15022. return RadialGradient
  15023. })(Gradient$1)
  15024. var RadialGradient$1 = RadialGradient
  15025. var extent = [0, 0]
  15026. var extent2 = [0, 0]
  15027. var minTv = new Point$1()
  15028. var maxTv = new Point$1()
  15029. var OrientedBoundingRect = (function () {
  15030. function OrientedBoundingRect(rect, transform) {
  15031. this._corners = []
  15032. this._axes = []
  15033. this._origin = [0, 0]
  15034. for (var i = 0; i < 4; i++) {
  15035. this._corners[i] = new Point$1()
  15036. }
  15037. for (var i = 0; i < 2; i++) {
  15038. this._axes[i] = new Point$1()
  15039. }
  15040. if (rect) {
  15041. this.fromBoundingRect(rect, transform)
  15042. }
  15043. }
  15044. OrientedBoundingRect.prototype.fromBoundingRect = function (
  15045. rect,
  15046. transform
  15047. ) {
  15048. var corners = this._corners
  15049. var axes = this._axes
  15050. var x = rect.x
  15051. var y = rect.y
  15052. var x2 = x + rect.width
  15053. var y2 = y + rect.height
  15054. corners[0].set(x, y)
  15055. corners[1].set(x2, y)
  15056. corners[2].set(x2, y2)
  15057. corners[3].set(x, y2)
  15058. if (transform) {
  15059. for (var i = 0; i < 4; i++) {
  15060. corners[i].transform(transform)
  15061. }
  15062. }
  15063. Point$1.sub(axes[0], corners[1], corners[0])
  15064. Point$1.sub(axes[1], corners[3], corners[0])
  15065. axes[0].normalize()
  15066. axes[1].normalize()
  15067. for (var i = 0; i < 2; i++) {
  15068. this._origin[i] = axes[i].dot(corners[0])
  15069. }
  15070. }
  15071. OrientedBoundingRect.prototype.intersect = function (other, mtv) {
  15072. var overlapped = true
  15073. var noMtv = !mtv
  15074. minTv.set(Infinity, Infinity)
  15075. maxTv.set(0, 0)
  15076. if (
  15077. !this._intersectCheckOneSide(
  15078. this,
  15079. other,
  15080. minTv,
  15081. maxTv,
  15082. noMtv,
  15083. 1
  15084. )
  15085. ) {
  15086. overlapped = false
  15087. if (noMtv) {
  15088. return overlapped
  15089. }
  15090. }
  15091. if (
  15092. !this._intersectCheckOneSide(
  15093. other,
  15094. this,
  15095. minTv,
  15096. maxTv,
  15097. noMtv,
  15098. -1
  15099. )
  15100. ) {
  15101. overlapped = false
  15102. if (noMtv) {
  15103. return overlapped
  15104. }
  15105. }
  15106. if (!noMtv) {
  15107. Point$1.copy(mtv, overlapped ? minTv : maxTv)
  15108. }
  15109. return overlapped
  15110. }
  15111. OrientedBoundingRect.prototype._intersectCheckOneSide = function (
  15112. self,
  15113. other,
  15114. minTv,
  15115. maxTv,
  15116. noMtv,
  15117. inverse
  15118. ) {
  15119. var overlapped = true
  15120. for (var i = 0; i < 2; i++) {
  15121. var axis = this._axes[i]
  15122. this._getProjMinMaxOnAxis(i, self._corners, extent)
  15123. this._getProjMinMaxOnAxis(i, other._corners, extent2)
  15124. if (extent[1] < extent2[0] || extent[0] > extent2[1]) {
  15125. overlapped = false
  15126. if (noMtv) {
  15127. return overlapped
  15128. }
  15129. var dist0 = Math.abs(extent2[0] - extent[1])
  15130. var dist1 = Math.abs(extent[0] - extent2[1])
  15131. if (Math.min(dist0, dist1) > maxTv.len()) {
  15132. if (dist0 < dist1) {
  15133. Point$1.scale(maxTv, axis, -dist0 * inverse)
  15134. } else {
  15135. Point$1.scale(maxTv, axis, dist1 * inverse)
  15136. }
  15137. }
  15138. } else if (minTv) {
  15139. var dist0 = Math.abs(extent2[0] - extent[1])
  15140. var dist1 = Math.abs(extent[0] - extent2[1])
  15141. if (Math.min(dist0, dist1) < minTv.len()) {
  15142. if (dist0 < dist1) {
  15143. Point$1.scale(minTv, axis, dist0 * inverse)
  15144. } else {
  15145. Point$1.scale(minTv, axis, -dist1 * inverse)
  15146. }
  15147. }
  15148. }
  15149. }
  15150. return overlapped
  15151. }
  15152. OrientedBoundingRect.prototype._getProjMinMaxOnAxis = function (
  15153. dim,
  15154. corners,
  15155. out
  15156. ) {
  15157. var axis = this._axes[dim]
  15158. var origin = this._origin
  15159. var proj = corners[0].dot(axis) + origin[dim]
  15160. var min = proj
  15161. var max = proj
  15162. for (var i = 1; i < corners.length; i++) {
  15163. var proj_1 = corners[i].dot(axis) + origin[dim]
  15164. min = Math.min(proj_1, min)
  15165. max = Math.max(proj_1, max)
  15166. }
  15167. out[0] = min
  15168. out[1] = max
  15169. }
  15170. return OrientedBoundingRect
  15171. })()
  15172. var OrientedBoundingRect$1 = OrientedBoundingRect
  15173. var m = []
  15174. var IncrementalDisplayable = (function (_super) {
  15175. __extends(IncrementalDisplayable, _super)
  15176. function IncrementalDisplayable() {
  15177. var _this =
  15178. (_super !== null && _super.apply(this, arguments)) || this
  15179. _this.notClear = true
  15180. _this.incremental = true
  15181. _this._displayables = []
  15182. _this._temporaryDisplayables = []
  15183. _this._cursor = 0
  15184. return _this
  15185. }
  15186. IncrementalDisplayable.prototype.traverse = function (cb, context) {
  15187. cb.call(context, this)
  15188. }
  15189. IncrementalDisplayable.prototype.useStyle = function () {
  15190. this.style = {}
  15191. }
  15192. IncrementalDisplayable.prototype.getCursor = function () {
  15193. return this._cursor
  15194. }
  15195. IncrementalDisplayable.prototype.innerAfterBrush = function () {
  15196. this._cursor = this._displayables.length
  15197. }
  15198. IncrementalDisplayable.prototype.clearDisplaybles = function () {
  15199. this._displayables = []
  15200. this._temporaryDisplayables = []
  15201. this._cursor = 0
  15202. this.markRedraw()
  15203. this.notClear = false
  15204. }
  15205. IncrementalDisplayable.prototype.clearTemporalDisplayables =
  15206. function () {
  15207. this._temporaryDisplayables = []
  15208. }
  15209. IncrementalDisplayable.prototype.addDisplayable = function (
  15210. displayable,
  15211. notPersistent
  15212. ) {
  15213. if (notPersistent) {
  15214. this._temporaryDisplayables.push(displayable)
  15215. } else {
  15216. this._displayables.push(displayable)
  15217. }
  15218. this.markRedraw()
  15219. }
  15220. IncrementalDisplayable.prototype.addDisplayables = function (
  15221. displayables,
  15222. notPersistent
  15223. ) {
  15224. notPersistent = notPersistent || false
  15225. for (var i = 0; i < displayables.length; i++) {
  15226. this.addDisplayable(displayables[i], notPersistent)
  15227. }
  15228. }
  15229. IncrementalDisplayable.prototype.getDisplayables = function () {
  15230. return this._displayables
  15231. }
  15232. IncrementalDisplayable.prototype.getTemporalDisplayables =
  15233. function () {
  15234. return this._temporaryDisplayables
  15235. }
  15236. IncrementalDisplayable.prototype.eachPendingDisplayable = function (
  15237. cb
  15238. ) {
  15239. for (var i = this._cursor; i < this._displayables.length; i++) {
  15240. cb && cb(this._displayables[i])
  15241. }
  15242. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  15243. cb && cb(this._temporaryDisplayables[i])
  15244. }
  15245. }
  15246. IncrementalDisplayable.prototype.update = function () {
  15247. this.updateTransform()
  15248. for (var i = this._cursor; i < this._displayables.length; i++) {
  15249. var displayable = this._displayables[i]
  15250. displayable.parent = this
  15251. displayable.update()
  15252. displayable.parent = null
  15253. }
  15254. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  15255. var displayable = this._temporaryDisplayables[i]
  15256. displayable.parent = this
  15257. displayable.update()
  15258. displayable.parent = null
  15259. }
  15260. }
  15261. IncrementalDisplayable.prototype.getBoundingRect = function () {
  15262. if (!this._rect) {
  15263. var rect = new BoundingRect$1(
  15264. Infinity,
  15265. Infinity,
  15266. -Infinity,
  15267. -Infinity
  15268. )
  15269. for (var i = 0; i < this._displayables.length; i++) {
  15270. var displayable = this._displayables[i]
  15271. var childRect = displayable.getBoundingRect().clone()
  15272. if (displayable.needLocalTransform()) {
  15273. childRect.applyTransform(displayable.getLocalTransform(m))
  15274. }
  15275. rect.union(childRect)
  15276. }
  15277. this._rect = rect
  15278. }
  15279. return this._rect
  15280. }
  15281. IncrementalDisplayable.prototype.contain = function (x, y) {
  15282. var localPos = this.transformCoordToLocal(x, y)
  15283. var rect = this.getBoundingRect()
  15284. if (rect.contain(localPos[0], localPos[1])) {
  15285. for (var i = 0; i < this._displayables.length; i++) {
  15286. var displayable = this._displayables[i]
  15287. if (displayable.contain(x, y)) {
  15288. return true
  15289. }
  15290. }
  15291. }
  15292. return false
  15293. }
  15294. return IncrementalDisplayable
  15295. })(Displayable$1)
  15296. var IncrementalDisplayable$1 = IncrementalDisplayable
  15297. var transitionStore = makeInner()
  15298. /**
  15299. * Return null if animation is disabled.
  15300. */ function getAnimationConfig(
  15301. animationType,
  15302. animatableModel,
  15303. dataIndex, // Extra opts can override the option in animatable model.
  15304. extraOpts, // TODO It's only for pictorial bar now.
  15305. extraDelayParams
  15306. ) {
  15307. var animationPayload // Check if there is global animation configuration from dataZoom/resize can override the config in option.
  15308. // If animation is enabled. Will use this animation config in payload.
  15309. // If animation is disabled. Just ignore it.
  15310. if (animatableModel && animatableModel.ecModel) {
  15311. var updatePayload = animatableModel.ecModel.getUpdatePayload()
  15312. animationPayload = updatePayload && updatePayload.animation
  15313. }
  15314. var animationEnabled =
  15315. animatableModel && animatableModel.isAnimationEnabled()
  15316. var isUpdate = animationType === 'update'
  15317. if (animationEnabled) {
  15318. var duration = void 0
  15319. var easing = void 0
  15320. var delay = void 0
  15321. if (extraOpts) {
  15322. duration = retrieve2(extraOpts.duration, 200)
  15323. easing = retrieve2(extraOpts.easing, 'cubicOut')
  15324. delay = 0
  15325. } else {
  15326. duration = animatableModel.getShallow(
  15327. isUpdate ? 'animationDurationUpdate' : 'animationDuration'
  15328. )
  15329. easing = animatableModel.getShallow(
  15330. isUpdate ? 'animationEasingUpdate' : 'animationEasing'
  15331. )
  15332. delay = animatableModel.getShallow(
  15333. isUpdate ? 'animationDelayUpdate' : 'animationDelay'
  15334. )
  15335. } // animation from payload has highest priority.
  15336. if (animationPayload) {
  15337. animationPayload.duration != null &&
  15338. (duration = animationPayload.duration)
  15339. animationPayload.easing != null &&
  15340. (easing = animationPayload.easing)
  15341. animationPayload.delay != null &&
  15342. (delay = animationPayload.delay)
  15343. }
  15344. if (isFunction(delay)) {
  15345. delay = delay(dataIndex, extraDelayParams)
  15346. }
  15347. if (isFunction(duration)) {
  15348. duration = duration(dataIndex)
  15349. }
  15350. var config = {
  15351. duration: duration || 0,
  15352. delay: delay,
  15353. easing: easing
  15354. }
  15355. return config
  15356. } else {
  15357. return null
  15358. }
  15359. }
  15360. function animateOrSetProps(
  15361. animationType,
  15362. el,
  15363. props,
  15364. animatableModel,
  15365. dataIndex,
  15366. cb,
  15367. during
  15368. ) {
  15369. var isFrom = false
  15370. var removeOpt
  15371. if (isFunction(dataIndex)) {
  15372. during = cb
  15373. cb = dataIndex
  15374. dataIndex = null
  15375. } else if (isObject$2(dataIndex)) {
  15376. cb = dataIndex.cb
  15377. during = dataIndex.during
  15378. isFrom = dataIndex.isFrom
  15379. removeOpt = dataIndex.removeOpt
  15380. dataIndex = dataIndex.dataIndex
  15381. }
  15382. var isRemove = animationType === 'leave'
  15383. if (!isRemove) {
  15384. // Must stop the remove animation.
  15385. el.stopAnimation('leave')
  15386. }
  15387. var animationConfig = getAnimationConfig(
  15388. animationType,
  15389. animatableModel,
  15390. dataIndex,
  15391. isRemove ? removeOpt || {} : null,
  15392. animatableModel && animatableModel.getAnimationDelayParams
  15393. ? animatableModel.getAnimationDelayParams(el, dataIndex)
  15394. : null
  15395. )
  15396. if (animationConfig && animationConfig.duration > 0) {
  15397. var duration = animationConfig.duration
  15398. var animationDelay = animationConfig.delay
  15399. var animationEasing = animationConfig.easing
  15400. var animateConfig = {
  15401. duration: duration,
  15402. delay: animationDelay || 0,
  15403. easing: animationEasing,
  15404. done: cb,
  15405. force: !!cb || !!during, // Set to final state in update/init animation.
  15406. // So the post processing based on the path shape can be done correctly.
  15407. setToFinal: !isRemove,
  15408. scope: animationType,
  15409. during: during
  15410. }
  15411. isFrom
  15412. ? el.animateFrom(props, animateConfig)
  15413. : el.animateTo(props, animateConfig)
  15414. } else {
  15415. el.stopAnimation() // If `isFrom`, the props is the "from" props.
  15416. !isFrom && el.attr(props) // Call during at least once.
  15417. during && during(1)
  15418. cb && cb()
  15419. }
  15420. }
  15421. /**
  15422. * Update graphic element properties with or without animation according to the
  15423. * configuration in series.
  15424. *
  15425. * Caution: this method will stop previous animation.
  15426. * So do not use this method to one element twice before
  15427. * animation starts, unless you know what you are doing.
  15428. * @example
  15429. * graphic.updateProps(el, {
  15430. * position: [100, 100]
  15431. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  15432. * // Or
  15433. * graphic.updateProps(el, {
  15434. * position: [100, 100]
  15435. * }, seriesModel, function () { console.log('Animation done!'); });
  15436. */ function updateProps$1(
  15437. el,
  15438. props, // TODO: TYPE AnimatableModel
  15439. animatableModel,
  15440. dataIndex,
  15441. cb,
  15442. during
  15443. ) {
  15444. animateOrSetProps(
  15445. 'update',
  15446. el,
  15447. props,
  15448. animatableModel,
  15449. dataIndex,
  15450. cb,
  15451. during
  15452. )
  15453. }
  15454. /**
  15455. * Init graphic element properties with or without animation according to the
  15456. * configuration in series.
  15457. *
  15458. * Caution: this method will stop previous animation.
  15459. * So do not use this method to one element twice before
  15460. * animation starts, unless you know what you are doing.
  15461. */ function initProps(
  15462. el,
  15463. props,
  15464. animatableModel,
  15465. dataIndex,
  15466. cb,
  15467. during
  15468. ) {
  15469. animateOrSetProps(
  15470. 'enter',
  15471. el,
  15472. props,
  15473. animatableModel,
  15474. dataIndex,
  15475. cb,
  15476. during
  15477. )
  15478. }
  15479. /**
  15480. * If element is removed.
  15481. * It can determine if element is having remove animation.
  15482. */ function isElementRemoved(el) {
  15483. if (!el.__zr) {
  15484. return true
  15485. }
  15486. for (var i = 0; i < el.animators.length; i++) {
  15487. var animator = el.animators[i]
  15488. if (animator.scope === 'leave') {
  15489. return true
  15490. }
  15491. }
  15492. return false
  15493. }
  15494. /**
  15495. * Remove graphic element
  15496. */ function removeElement(
  15497. el,
  15498. props,
  15499. animatableModel,
  15500. dataIndex,
  15501. cb,
  15502. during
  15503. ) {
  15504. // Don't do remove animation twice.
  15505. if (isElementRemoved(el)) {
  15506. return
  15507. }
  15508. animateOrSetProps(
  15509. 'leave',
  15510. el,
  15511. props,
  15512. animatableModel,
  15513. dataIndex,
  15514. cb,
  15515. during
  15516. )
  15517. }
  15518. function fadeOutDisplayable(el, animatableModel, dataIndex, done) {
  15519. el.removeTextContent()
  15520. el.removeTextGuideLine()
  15521. removeElement(
  15522. el,
  15523. { style: { opacity: 0 } },
  15524. animatableModel,
  15525. dataIndex,
  15526. done
  15527. )
  15528. }
  15529. function removeElementWithFadeOut(el, animatableModel, dataIndex) {
  15530. function doRemove() {
  15531. el.parent && el.parent.remove(el)
  15532. } // Hide label and labelLine first
  15533. // TODO Also use fade out animation?
  15534. if (!el.isGroup) {
  15535. fadeOutDisplayable(el, animatableModel, dataIndex, doRemove)
  15536. } else {
  15537. el.traverse(function (disp) {
  15538. if (!disp.isGroup) {
  15539. // Can invoke doRemove multiple times.
  15540. fadeOutDisplayable(disp, animatableModel, dataIndex, doRemove)
  15541. }
  15542. })
  15543. }
  15544. }
  15545. /**
  15546. * Save old style for style transition in universalTransition module.
  15547. * It's used when element will be reused in each render.
  15548. * For chart like map, heatmap, which will always create new element.
  15549. * We don't need to save this because universalTransition can get old style from the old element
  15550. */ function saveOldStyle(el) {
  15551. transitionStore(el).oldStyle = el.style
  15552. }
  15553. function getOldStyle(el) {
  15554. return transitionStore(el).oldStyle
  15555. }
  15556. var mathMax$3 = Math.max
  15557. var mathMin$3 = Math.min
  15558. var _customShapeMap = {}
  15559. /**
  15560. * Extend shape with parameters
  15561. */ function extendShape(opts) {
  15562. return Path$1.extend(opts)
  15563. }
  15564. var extendPathFromString = extendFromString
  15565. /**
  15566. * Extend path
  15567. */ function extendPath(pathData, opts) {
  15568. return extendPathFromString(pathData, opts)
  15569. }
  15570. /**
  15571. * Register a user defined shape.
  15572. * The shape class can be fetched by `getShapeClass`
  15573. * This method will overwrite the registered shapes, including
  15574. * the registered built-in shapes, if using the same `name`.
  15575. * The shape can be used in `custom series` and
  15576. * `graphic component` by declaring `{type: name}`.
  15577. *
  15578. * @param name
  15579. * @param ShapeClass Can be generated by `extendShape`.
  15580. */ function registerShape(name, ShapeClass) {
  15581. _customShapeMap[name] = ShapeClass
  15582. }
  15583. /**
  15584. * Find shape class registered by `registerShape`. Usually used in
  15585. * fetching user defined shape.
  15586. *
  15587. * [Caution]:
  15588. * (1) This method **MUST NOT be used inside echarts !!!**, unless it is prepared
  15589. * to use user registered shapes.
  15590. * Because the built-in shape (see `getBuiltInShape`) will be registered by
  15591. * `registerShape` by default. That enables users to get both built-in
  15592. * shapes as well as the shapes belonging to themsleves. But users can overwrite
  15593. * the built-in shapes by using names like 'circle', 'rect' via calling
  15594. * `registerShape`. So the echarts inner featrues should not fetch shapes from here
  15595. * in case that it is overwritten by users, except that some features, like
  15596. * `custom series`, `graphic component`, do it deliberately.
  15597. *
  15598. * (2) In the features like `custom series`, `graphic component`, the user input
  15599. * `{tpye: 'xxx'}` does not only specify shapes but also specify other graphic
  15600. * elements like `'group'`, `'text'`, `'image'` or event `'path'`. Those names
  15601. * are reserved names, that is, if some user register a shape named `'image'`,
  15602. * the shape will not be used. If we intending to add some more reserved names
  15603. * in feature, that might bring break changes (disable some existing user shape
  15604. * names). But that case probably rearly happen. So we dont make more mechanism
  15605. * to resolve this issue here.
  15606. *
  15607. * @param name
  15608. * @return The shape class. If not found, return nothing.
  15609. */ function getShapeClass(name) {
  15610. if (_customShapeMap.hasOwnProperty(name)) {
  15611. return _customShapeMap[name]
  15612. }
  15613. }
  15614. /**
  15615. * Create a path element from path data string
  15616. * @param pathData
  15617. * @param opts
  15618. * @param rect
  15619. * @param layout 'center' or 'cover' default to be cover
  15620. */ function makePath(pathData, opts, rect, layout) {
  15621. var path = createFromString(pathData, opts)
  15622. if (rect) {
  15623. if (layout === 'center') {
  15624. rect = centerGraphic(rect, path.getBoundingRect())
  15625. }
  15626. resizePath(path, rect)
  15627. }
  15628. return path
  15629. }
  15630. /**
  15631. * Create a image element from image url
  15632. * @param imageUrl image url
  15633. * @param opts options
  15634. * @param rect constrain rect
  15635. * @param layout 'center' or 'cover'. Default to be 'cover'
  15636. */ function makeImage(imageUrl, rect, layout) {
  15637. var zrImg = new ZRImage$1({
  15638. style: {
  15639. image: imageUrl,
  15640. x: rect.x,
  15641. y: rect.y,
  15642. width: rect.width,
  15643. height: rect.height
  15644. },
  15645. onload: function onload(img) {
  15646. if (layout === 'center') {
  15647. var boundingRect = { width: img.width, height: img.height }
  15648. zrImg.setStyle(centerGraphic(rect, boundingRect))
  15649. }
  15650. }
  15651. })
  15652. return zrImg
  15653. }
  15654. /**
  15655. * Get position of centered element in bounding box.
  15656. *
  15657. * @param rect element local bounding box
  15658. * @param boundingRect constraint bounding box
  15659. * @return element position containing x, y, width, and height
  15660. */ function centerGraphic(rect, boundingRect) {
  15661. // Set rect to center, keep width / height ratio.
  15662. var aspect = boundingRect.width / boundingRect.height
  15663. var width = rect.height * aspect
  15664. var height
  15665. if (width <= rect.width) {
  15666. height = rect.height
  15667. } else {
  15668. width = rect.width
  15669. height = width / aspect
  15670. }
  15671. var cx = rect.x + rect.width / 2
  15672. var cy = rect.y + rect.height / 2
  15673. return {
  15674. x: cx - width / 2,
  15675. y: cy - height / 2,
  15676. width: width,
  15677. height: height
  15678. }
  15679. }
  15680. var mergePath = mergePath$1
  15681. /**
  15682. * Resize a path to fit the rect
  15683. * @param path
  15684. * @param rect
  15685. */ function resizePath(path, rect) {
  15686. if (!path.applyTransform) {
  15687. return
  15688. }
  15689. var pathRect = path.getBoundingRect()
  15690. var m = pathRect.calculateTransform(rect)
  15691. path.applyTransform(m)
  15692. }
  15693. /**
  15694. * Sub pixel optimize line for canvas
  15695. */ function subPixelOptimizeLine(param) {
  15696. subPixelOptimizeLine$1(param.shape, param.shape, param.style)
  15697. return param
  15698. }
  15699. /**
  15700. * Sub pixel optimize rect for canvas
  15701. */ function subPixelOptimizeRect(param) {
  15702. subPixelOptimizeRect$1(param.shape, param.shape, param.style)
  15703. return param
  15704. }
  15705. /**
  15706. * Sub pixel optimize for canvas
  15707. *
  15708. * @param position Coordinate, such as x, y
  15709. * @param lineWidth Should be nonnegative integer.
  15710. * @param positiveOrNegative Default false (negative).
  15711. * @return Optimized position.
  15712. */ var subPixelOptimize = subPixelOptimize$1
  15713. /**
  15714. * Get transform matrix of target (param target),
  15715. * in coordinate of its ancestor (param ancestor)
  15716. *
  15717. * @param target
  15718. * @param [ancestor]
  15719. */ function getTransform$1(target, ancestor) {
  15720. var mat = identity([])
  15721. while (target && target !== ancestor) {
  15722. mul(mat, target.getLocalTransform(), mat)
  15723. target = target.parent
  15724. }
  15725. return mat
  15726. }
  15727. /**
  15728. * Apply transform to an vertex.
  15729. * @param target [x, y]
  15730. * @param transform Can be:
  15731. * + Transform matrix: like [1, 0, 0, 1, 0, 0]
  15732. * + {position, rotation, scale}, the same as `zrender/Transformable`.
  15733. * @param invert Whether use invert matrix.
  15734. * @return [x, y]
  15735. */ function applyTransform(target, transform, invert$1) {
  15736. if (transform && !isArrayLike(transform)) {
  15737. transform = Transformable.getLocalTransform(transform)
  15738. }
  15739. if (invert$1) {
  15740. transform = invert([], transform)
  15741. }
  15742. return applyTransform$1([], target, transform)
  15743. }
  15744. /**
  15745. * @param direction 'left' 'right' 'top' 'bottom'
  15746. * @param transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  15747. * @param invert Whether use invert matrix.
  15748. * @return Transformed direction. 'left' 'right' 'top' 'bottom'
  15749. */ function transformDirection(direction, transform, invert) {
  15750. // Pick a base, ensure that transform result will not be (0, 0).
  15751. var hBase =
  15752. transform[4] === 0 || transform[5] === 0 || transform[0] === 0
  15753. ? 1
  15754. : Math.abs((2 * transform[4]) / transform[0])
  15755. var vBase =
  15756. transform[4] === 0 || transform[5] === 0 || transform[2] === 0
  15757. ? 1
  15758. : Math.abs((2 * transform[4]) / transform[2])
  15759. var vertex = [
  15760. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  15761. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  15762. ]
  15763. vertex = applyTransform(vertex, transform, invert)
  15764. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  15765. ? vertex[0] > 0
  15766. ? 'right'
  15767. : 'left'
  15768. : vertex[1] > 0
  15769. ? 'bottom'
  15770. : 'top'
  15771. }
  15772. function isNotGroup(el) {
  15773. return !el.isGroup
  15774. }
  15775. function isPath(el) {
  15776. return el.shape != null
  15777. }
  15778. /**
  15779. * Apply group transition animation from g1 to g2.
  15780. * If no animatableModel, no animation.
  15781. */ function groupTransition(g1, g2, animatableModel) {
  15782. if (!g1 || !g2) {
  15783. return
  15784. }
  15785. function getElMap(g) {
  15786. var elMap = {}
  15787. g.traverse(function (el) {
  15788. if (isNotGroup(el) && el.anid) {
  15789. elMap[el.anid] = el
  15790. }
  15791. })
  15792. return elMap
  15793. }
  15794. function getAnimatableProps(el) {
  15795. var obj = { x: el.x, y: el.y, rotation: el.rotation }
  15796. if (isPath(el)) {
  15797. obj.shape = extend({}, el.shape)
  15798. }
  15799. return obj
  15800. }
  15801. var elMap1 = getElMap(g1)
  15802. g2.traverse(function (el) {
  15803. if (isNotGroup(el) && el.anid) {
  15804. var oldEl = elMap1[el.anid]
  15805. if (oldEl) {
  15806. var newProp = getAnimatableProps(el)
  15807. el.attr(getAnimatableProps(oldEl))
  15808. updateProps$1(
  15809. el,
  15810. newProp,
  15811. animatableModel,
  15812. getECData(el).dataIndex
  15813. )
  15814. }
  15815. }
  15816. })
  15817. }
  15818. function clipPointsByRect(points, rect) {
  15819. // FIXME: this way migth be incorrect when grpahic clipped by a corner.
  15820. // and when element have border.
  15821. return map$1(points, function (point) {
  15822. var x = point[0]
  15823. x = mathMax$3(x, rect.x)
  15824. x = mathMin$3(x, rect.x + rect.width)
  15825. var y = point[1]
  15826. y = mathMax$3(y, rect.y)
  15827. y = mathMin$3(y, rect.y + rect.height)
  15828. return [x, y]
  15829. })
  15830. }
  15831. /**
  15832. * Return a new clipped rect. If rect size are negative, return undefined.
  15833. */ function clipRectByRect(targetRect, rect) {
  15834. var x = mathMax$3(targetRect.x, rect.x)
  15835. var x2 = mathMin$3(
  15836. targetRect.x + targetRect.width,
  15837. rect.x + rect.width
  15838. )
  15839. var y = mathMax$3(targetRect.y, rect.y)
  15840. var y2 = mathMin$3(
  15841. targetRect.y + targetRect.height,
  15842. rect.y + rect.height
  15843. ) // If the total rect is cliped, nothing, including the border,
  15844. // should be painted. So return undefined.
  15845. if (x2 >= x && y2 >= y) {
  15846. return { x: x, y: y, width: x2 - x, height: y2 - y }
  15847. }
  15848. }
  15849. function createIcon(
  15850. iconStr, // Support 'image://' or 'path://' or direct svg path.
  15851. opt,
  15852. rect
  15853. ) {
  15854. var innerOpts = extend({ rectHover: true }, opt)
  15855. var style = (innerOpts.style = { strokeNoScale: true })
  15856. rect = rect || { x: -1, y: -1, width: 2, height: 2 }
  15857. if (iconStr) {
  15858. return iconStr.indexOf('image://') === 0
  15859. ? ((style.image = iconStr.slice(8)),
  15860. defaults(style, rect),
  15861. new ZRImage$1(innerOpts))
  15862. : makePath(
  15863. iconStr.replace('path://', ''),
  15864. innerOpts,
  15865. rect,
  15866. 'center'
  15867. )
  15868. }
  15869. }
  15870. /**
  15871. * Return `true` if the given line (line `a`) and the given polygon
  15872. * are intersect.
  15873. * Note that we do not count colinear as intersect here because no
  15874. * requirement for that. We could do that if required in future.
  15875. */ function linePolygonIntersect(a1x, a1y, a2x, a2y, points) {
  15876. for (
  15877. var i = 0, p2 = points[points.length - 1];
  15878. i < points.length;
  15879. i++
  15880. ) {
  15881. var p = points[i]
  15882. if (
  15883. lineLineIntersect$1(
  15884. a1x,
  15885. a1y,
  15886. a2x,
  15887. a2y,
  15888. p[0],
  15889. p[1],
  15890. p2[0],
  15891. p2[1]
  15892. )
  15893. ) {
  15894. return true
  15895. }
  15896. p2 = p
  15897. }
  15898. }
  15899. /**
  15900. * Return `true` if the given two lines (line `a` and line `b`)
  15901. * are intersect.
  15902. * Note that we do not count colinear as intersect here because no
  15903. * requirement for that. We could do that if required in future.
  15904. */ function lineLineIntersect$1(
  15905. a1x,
  15906. a1y,
  15907. a2x,
  15908. a2y,
  15909. b1x,
  15910. b1y,
  15911. b2x,
  15912. b2y
  15913. ) {
  15914. // let `vec_m` to be `vec_a2 - vec_a1` and `vec_n` to be `vec_b2 - vec_b1`.
  15915. var mx = a2x - a1x
  15916. var my = a2y - a1y
  15917. var nx = b2x - b1x
  15918. var ny = b2y - b1y // `vec_m` and `vec_n` are parallel iff
  15919. // exising `k` such that `vec_m = k · vec_n`, equivalent to `vec_m X vec_n = 0`.
  15920. var nmCrossProduct = crossProduct2d$1(nx, ny, mx, my)
  15921. if (nearZero(nmCrossProduct)) {
  15922. return false
  15923. } // `vec_m` and `vec_n` are intersect iff
  15924. // existing `p` and `q` in [0, 1] such that `vec_a1 + p * vec_m = vec_b1 + q * vec_n`,
  15925. // such that `q = ((vec_a1 - vec_b1) X vec_m) / (vec_n X vec_m)`
  15926. // and `p = ((vec_a1 - vec_b1) X vec_n) / (vec_n X vec_m)`.
  15927. var b1a1x = a1x - b1x
  15928. var b1a1y = a1y - b1y
  15929. var q = crossProduct2d$1(b1a1x, b1a1y, mx, my) / nmCrossProduct
  15930. if (q < 0 || q > 1) {
  15931. return false
  15932. }
  15933. var p = crossProduct2d$1(b1a1x, b1a1y, nx, ny) / nmCrossProduct
  15934. if (p < 0 || p > 1) {
  15935. return false
  15936. }
  15937. return true
  15938. }
  15939. /**
  15940. * Cross product of 2-dimension vector.
  15941. */ function crossProduct2d$1(x1, y1, x2, y2) {
  15942. return x1 * y2 - x2 * y1
  15943. }
  15944. function nearZero(val) {
  15945. return val <= 1e-6 && val >= -1e-6
  15946. }
  15947. function setTooltipConfig(opt) {
  15948. var itemTooltipOption = opt.itemTooltipOption
  15949. var componentModel = opt.componentModel
  15950. var itemName = opt.itemName
  15951. var itemTooltipOptionObj = isString(itemTooltipOption)
  15952. ? { formatter: itemTooltipOption }
  15953. : itemTooltipOption
  15954. var mainType = componentModel.mainType
  15955. var componentIndex = componentModel.componentIndex
  15956. var formatterParams = {
  15957. componentType: mainType,
  15958. name: itemName,
  15959. $vars: ['name']
  15960. }
  15961. formatterParams[mainType + 'Index'] = componentIndex
  15962. var formatterParamsExtra = opt.formatterParamsExtra
  15963. if (formatterParamsExtra) {
  15964. each$7(keys(formatterParamsExtra), function (key) {
  15965. if (!hasOwn(formatterParams, key)) {
  15966. formatterParams[key] = formatterParamsExtra[key]
  15967. formatterParams.$vars.push(key)
  15968. }
  15969. })
  15970. }
  15971. var ecData = getECData(opt.el)
  15972. ecData.componentMainType = mainType
  15973. ecData.componentIndex = componentIndex
  15974. ecData.tooltipConfig = {
  15975. name: itemName,
  15976. option: defaults(
  15977. { content: itemName, formatterParams: formatterParams },
  15978. itemTooltipOptionObj
  15979. )
  15980. }
  15981. }
  15982. function traverseElement(el, cb) {
  15983. var stopped // TODO
  15984. // Polyfill for fixing zrender group traverse don't visit it's root issue.
  15985. if (el.isGroup) {
  15986. stopped = cb(el)
  15987. }
  15988. if (!stopped) {
  15989. el.traverse(cb)
  15990. }
  15991. }
  15992. function traverseElements(els, cb) {
  15993. if (els) {
  15994. if (isArray(els)) {
  15995. for (var i = 0; i < els.length; i++) {
  15996. traverseElement(els[i], cb)
  15997. }
  15998. } else {
  15999. traverseElement(els, cb)
  16000. }
  16001. }
  16002. } // Register built-in shapes. These shapes might be overwirtten
  16003. // by users, although we do not recommend that.
  16004. registerShape('circle', Circle$1)
  16005. registerShape('ellipse', Ellipse$1)
  16006. registerShape('sector', Sector$1)
  16007. registerShape('ring', Ring$1)
  16008. registerShape('polygon', Polygon$1)
  16009. registerShape('polyline', Polyline$1)
  16010. registerShape('rect', Rect$2)
  16011. registerShape('line', Line$1)
  16012. registerShape('bezierCurve', BezierCurve$1)
  16013. registerShape('arc', Arc$1)
  16014. var graphic = /*#__PURE__*/ Object.freeze(
  16015. ((_Object$freeze3 = { __proto__: null }),
  16016. _defineProperty(_Object$freeze3, Symbol.toStringTag, 'Module'),
  16017. _defineProperty(_Object$freeze3, 'updateProps', updateProps$1),
  16018. _defineProperty(_Object$freeze3, 'initProps', initProps),
  16019. _defineProperty(_Object$freeze3, 'removeElement', removeElement),
  16020. _defineProperty(
  16021. _Object$freeze3,
  16022. 'removeElementWithFadeOut',
  16023. removeElementWithFadeOut
  16024. ),
  16025. _defineProperty(
  16026. _Object$freeze3,
  16027. 'isElementRemoved',
  16028. isElementRemoved
  16029. ),
  16030. _defineProperty(_Object$freeze3, 'extendShape', extendShape),
  16031. _defineProperty(_Object$freeze3, 'extendPath', extendPath),
  16032. _defineProperty(_Object$freeze3, 'registerShape', registerShape),
  16033. _defineProperty(_Object$freeze3, 'getShapeClass', getShapeClass),
  16034. _defineProperty(_Object$freeze3, 'makePath', makePath),
  16035. _defineProperty(_Object$freeze3, 'makeImage', makeImage),
  16036. _defineProperty(_Object$freeze3, 'mergePath', mergePath),
  16037. _defineProperty(_Object$freeze3, 'resizePath', resizePath),
  16038. _defineProperty(
  16039. _Object$freeze3,
  16040. 'subPixelOptimizeLine',
  16041. subPixelOptimizeLine
  16042. ),
  16043. _defineProperty(
  16044. _Object$freeze3,
  16045. 'subPixelOptimizeRect',
  16046. subPixelOptimizeRect
  16047. ),
  16048. _defineProperty(
  16049. _Object$freeze3,
  16050. 'subPixelOptimize',
  16051. subPixelOptimize
  16052. ),
  16053. _defineProperty(_Object$freeze3, 'getTransform', getTransform$1),
  16054. _defineProperty(_Object$freeze3, 'applyTransform', applyTransform),
  16055. _defineProperty(
  16056. _Object$freeze3,
  16057. 'transformDirection',
  16058. transformDirection
  16059. ),
  16060. _defineProperty(
  16061. _Object$freeze3,
  16062. 'groupTransition',
  16063. groupTransition
  16064. ),
  16065. _defineProperty(
  16066. _Object$freeze3,
  16067. 'clipPointsByRect',
  16068. clipPointsByRect
  16069. ),
  16070. _defineProperty(_Object$freeze3, 'clipRectByRect', clipRectByRect),
  16071. _defineProperty(_Object$freeze3, 'createIcon', createIcon),
  16072. _defineProperty(
  16073. _Object$freeze3,
  16074. 'linePolygonIntersect',
  16075. linePolygonIntersect
  16076. ),
  16077. _defineProperty(
  16078. _Object$freeze3,
  16079. 'lineLineIntersect',
  16080. lineLineIntersect$1
  16081. ),
  16082. _defineProperty(
  16083. _Object$freeze3,
  16084. 'setTooltipConfig',
  16085. setTooltipConfig
  16086. ),
  16087. _defineProperty(
  16088. _Object$freeze3,
  16089. 'traverseElements',
  16090. traverseElements
  16091. ),
  16092. _defineProperty(_Object$freeze3, 'Group', Group$3),
  16093. _defineProperty(_Object$freeze3, 'Image', ZRImage$1),
  16094. _defineProperty(_Object$freeze3, 'Text', ZRText$1),
  16095. _defineProperty(_Object$freeze3, 'Circle', Circle$1),
  16096. _defineProperty(_Object$freeze3, 'Ellipse', Ellipse$1),
  16097. _defineProperty(_Object$freeze3, 'Sector', Sector$1),
  16098. _defineProperty(_Object$freeze3, 'Ring', Ring$1),
  16099. _defineProperty(_Object$freeze3, 'Polygon', Polygon$1),
  16100. _defineProperty(_Object$freeze3, 'Polyline', Polyline$1),
  16101. _defineProperty(_Object$freeze3, 'Rect', Rect$2),
  16102. _defineProperty(_Object$freeze3, 'Line', Line$1),
  16103. _defineProperty(_Object$freeze3, 'BezierCurve', BezierCurve$1),
  16104. _defineProperty(_Object$freeze3, 'Arc', Arc$1),
  16105. _defineProperty(
  16106. _Object$freeze3,
  16107. 'IncrementalDisplayable',
  16108. IncrementalDisplayable$1
  16109. ),
  16110. _defineProperty(_Object$freeze3, 'CompoundPath', CompoundPath$1),
  16111. _defineProperty(
  16112. _Object$freeze3,
  16113. 'LinearGradient',
  16114. LinearGradient$1
  16115. ),
  16116. _defineProperty(
  16117. _Object$freeze3,
  16118. 'RadialGradient',
  16119. RadialGradient$1
  16120. ),
  16121. _defineProperty(_Object$freeze3, 'BoundingRect', BoundingRect$1),
  16122. _defineProperty(
  16123. _Object$freeze3,
  16124. 'OrientedBoundingRect',
  16125. OrientedBoundingRect$1
  16126. ),
  16127. _defineProperty(_Object$freeze3, 'Point', Point$1),
  16128. _defineProperty(_Object$freeze3, 'Path', Path$1),
  16129. _Object$freeze3)
  16130. )
  16131. var EMPTY_OBJ = {}
  16132. function setLabelText(label, labelTexts) {
  16133. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  16134. var stateName = SPECIAL_STATES[i]
  16135. var text = labelTexts[stateName]
  16136. var state = label.ensureState(stateName)
  16137. state.style = state.style || {}
  16138. state.style.text = text
  16139. }
  16140. var oldStates = label.currentStates.slice()
  16141. label.clearStates(true)
  16142. label.setStyle({ text: labelTexts.normal })
  16143. label.useStates(oldStates, true)
  16144. }
  16145. function getLabelText(opt, stateModels, interpolatedValue) {
  16146. var labelFetcher = opt.labelFetcher
  16147. var labelDataIndex = opt.labelDataIndex
  16148. var labelDimIndex = opt.labelDimIndex
  16149. var normalModel = stateModels.normal
  16150. var baseText
  16151. if (labelFetcher) {
  16152. baseText = labelFetcher.getFormattedLabel(
  16153. labelDataIndex,
  16154. 'normal',
  16155. null,
  16156. labelDimIndex,
  16157. normalModel && normalModel.get('formatter'),
  16158. interpolatedValue != null
  16159. ? { interpolatedValue: interpolatedValue }
  16160. : null
  16161. )
  16162. }
  16163. if (baseText == null) {
  16164. baseText = isFunction(opt.defaultText)
  16165. ? opt.defaultText(labelDataIndex, opt, interpolatedValue)
  16166. : opt.defaultText
  16167. }
  16168. var statesText = { normal: baseText }
  16169. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  16170. var stateName = SPECIAL_STATES[i]
  16171. var stateModel = stateModels[stateName]
  16172. statesText[stateName] = retrieve2(
  16173. labelFetcher
  16174. ? labelFetcher.getFormattedLabel(
  16175. labelDataIndex,
  16176. stateName,
  16177. null,
  16178. labelDimIndex,
  16179. stateModel && stateModel.get('formatter')
  16180. )
  16181. : null,
  16182. baseText
  16183. )
  16184. }
  16185. return statesText
  16186. }
  16187. function setLabelStyle(
  16188. targetEl,
  16189. labelStatesModels,
  16190. opt,
  16191. stateSpecified // TODO specified position?
  16192. ) {
  16193. opt = opt || EMPTY_OBJ
  16194. var isSetOnText = targetEl instanceof ZRText$1
  16195. var needsCreateText = false
  16196. for (var i = 0; i < DISPLAY_STATES.length; i++) {
  16197. var stateModel = labelStatesModels[DISPLAY_STATES[i]]
  16198. if (stateModel && stateModel.getShallow('show')) {
  16199. needsCreateText = true
  16200. break
  16201. }
  16202. }
  16203. var textContent = isSetOnText ? targetEl : targetEl.getTextContent()
  16204. if (needsCreateText) {
  16205. if (!isSetOnText) {
  16206. // Reuse the previous
  16207. if (!textContent) {
  16208. textContent = new ZRText$1()
  16209. targetEl.setTextContent(textContent)
  16210. } // Use same state proxy
  16211. if (targetEl.stateProxy) {
  16212. textContent.stateProxy = targetEl.stateProxy
  16213. }
  16214. }
  16215. var labelStatesTexts = getLabelText(opt, labelStatesModels)
  16216. var normalModel = labelStatesModels.normal
  16217. var showNormal = !!normalModel.getShallow('show')
  16218. var normalStyle = createTextStyle(
  16219. normalModel,
  16220. stateSpecified && stateSpecified.normal,
  16221. opt,
  16222. false,
  16223. !isSetOnText
  16224. )
  16225. normalStyle.text = labelStatesTexts.normal
  16226. if (!isSetOnText) {
  16227. // Always create new
  16228. targetEl.setTextConfig(
  16229. createTextConfig(normalModel, opt, false)
  16230. )
  16231. }
  16232. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  16233. var stateName = SPECIAL_STATES[i]
  16234. var stateModel = labelStatesModels[stateName]
  16235. if (stateModel) {
  16236. var stateObj = textContent.ensureState(stateName)
  16237. var stateShow = !!retrieve2(
  16238. stateModel.getShallow('show'),
  16239. showNormal
  16240. )
  16241. if (stateShow !== showNormal) {
  16242. stateObj.ignore = !stateShow
  16243. }
  16244. stateObj.style = createTextStyle(
  16245. stateModel,
  16246. stateSpecified && stateSpecified[stateName],
  16247. opt,
  16248. true,
  16249. !isSetOnText
  16250. )
  16251. stateObj.style.text = labelStatesTexts[stateName]
  16252. if (!isSetOnText) {
  16253. var targetElEmphasisState = targetEl.ensureState(stateName)
  16254. targetElEmphasisState.textConfig = createTextConfig(
  16255. stateModel,
  16256. opt,
  16257. true
  16258. )
  16259. }
  16260. }
  16261. } // PENDING: if there is many requirements that emphasis position
  16262. // need to be different from normal position, we might consider
  16263. // auto slient is those cases.
  16264. textContent.silent = !!normalModel.getShallow('silent') // Keep x and y
  16265. if (textContent.style.x != null) {
  16266. normalStyle.x = textContent.style.x
  16267. }
  16268. if (textContent.style.y != null) {
  16269. normalStyle.y = textContent.style.y
  16270. }
  16271. textContent.ignore = !showNormal // Always create new style.
  16272. textContent.useStyle(normalStyle)
  16273. textContent.dirty()
  16274. if (opt.enableTextSetter) {
  16275. labelInner(textContent).setLabelText = function (
  16276. interpolatedValue
  16277. ) {
  16278. var labelStatesTexts = getLabelText(
  16279. opt,
  16280. labelStatesModels,
  16281. interpolatedValue
  16282. )
  16283. setLabelText(textContent, labelStatesTexts)
  16284. }
  16285. }
  16286. } else if (textContent) {
  16287. // Not display rich text.
  16288. textContent.ignore = true
  16289. }
  16290. targetEl.dirty()
  16291. }
  16292. function getLabelStatesModels(itemModel, labelName) {
  16293. labelName = labelName || 'label'
  16294. var statesModels = { normal: itemModel.getModel(labelName) }
  16295. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  16296. var stateName = SPECIAL_STATES[i]
  16297. statesModels[stateName] = itemModel.getModel([
  16298. stateName,
  16299. labelName
  16300. ])
  16301. }
  16302. return statesModels
  16303. }
  16304. /**
  16305. * Set basic textStyle properties.
  16306. */ function createTextStyle(
  16307. textStyleModel,
  16308. specifiedTextStyle, // Fixed style in the code. Can't be set by model.
  16309. opt,
  16310. isNotNormal,
  16311. isAttached // If text is attached on an element. If so, auto color will handling in zrender.
  16312. ) {
  16313. var textStyle = {}
  16314. setTextStyleCommon(
  16315. textStyle,
  16316. textStyleModel,
  16317. opt,
  16318. isNotNormal,
  16319. isAttached
  16320. )
  16321. specifiedTextStyle && extend(textStyle, specifiedTextStyle) // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
  16322. return textStyle
  16323. }
  16324. function createTextConfig(textStyleModel, opt, isNotNormal) {
  16325. opt = opt || {}
  16326. var textConfig = {}
  16327. var labelPosition
  16328. var labelRotate = textStyleModel.getShallow('rotate')
  16329. var labelDistance = retrieve2(
  16330. textStyleModel.getShallow('distance'),
  16331. isNotNormal ? null : 5
  16332. )
  16333. var labelOffset = textStyleModel.getShallow('offset')
  16334. labelPosition =
  16335. textStyleModel.getShallow('position') ||
  16336. (isNotNormal ? null : 'inside') // 'outside' is not a valid zr textPostion value, but used
  16337. // in bar series, and magric type should be considered.
  16338. labelPosition === 'outside' &&
  16339. (labelPosition = opt.defaultOutsidePosition || 'top')
  16340. if (labelPosition != null) {
  16341. textConfig.position = labelPosition
  16342. }
  16343. if (labelOffset != null) {
  16344. textConfig.offset = labelOffset
  16345. }
  16346. if (labelRotate != null) {
  16347. labelRotate *= Math.PI / 180
  16348. textConfig.rotation = labelRotate
  16349. }
  16350. if (labelDistance != null) {
  16351. textConfig.distance = labelDistance
  16352. } // fill and auto is determined by the color of path fill if it's not specified by developers.
  16353. textConfig.outsideFill =
  16354. textStyleModel.get('color') === 'inherit'
  16355. ? opt.inheritColor || null
  16356. : 'auto'
  16357. return textConfig
  16358. }
  16359. /**
  16360. * The uniform entry of set text style, that is, retrieve style definitions
  16361. * from `model` and set to `textStyle` object.
  16362. *
  16363. * Never in merge mode, but in overwrite mode, that is, all of the text style
  16364. * properties will be set. (Consider the states of normal and emphasis and
  16365. * default value can be adopted, merge would make the logic too complicated
  16366. * to manage.)
  16367. */ function setTextStyleCommon(
  16368. textStyle,
  16369. textStyleModel,
  16370. opt,
  16371. isNotNormal,
  16372. isAttached
  16373. ) {
  16374. // Consider there will be abnormal when merge hover style to normal style if given default value.
  16375. opt = opt || EMPTY_OBJ
  16376. var ecModel = textStyleModel.ecModel
  16377. var globalTextStyle = ecModel && ecModel.option.textStyle // Consider case:
  16378. // {
  16379. // data: [{
  16380. // value: 12,
  16381. // label: {
  16382. // rich: {
  16383. // // no 'a' here but using parent 'a'.
  16384. // }
  16385. // }
  16386. // }],
  16387. // rich: {
  16388. // a: { ... }
  16389. // }
  16390. // }
  16391. var richItemNames = getRichItemNames(textStyleModel)
  16392. var richResult
  16393. if (richItemNames) {
  16394. richResult = {}
  16395. for (var name_1 in richItemNames) {
  16396. if (richItemNames.hasOwnProperty(name_1)) {
  16397. // Cascade is supported in rich.
  16398. var richTextStyle = textStyleModel.getModel(['rich', name_1]) // In rich, never `disableBox`.
  16399. // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
  16400. // the default color `'blue'` will not be adopted if no color declared in `rich`.
  16401. // That might confuses users. So probably we should put `textStyleModel` as the
  16402. // root ancestor of the `richTextStyle`. But that would be a break change.
  16403. setTokenTextStyle(
  16404. (richResult[name_1] = {}),
  16405. richTextStyle,
  16406. globalTextStyle,
  16407. opt,
  16408. isNotNormal,
  16409. isAttached,
  16410. false,
  16411. true
  16412. )
  16413. }
  16414. }
  16415. }
  16416. if (richResult) {
  16417. textStyle.rich = richResult
  16418. }
  16419. var overflow = textStyleModel.get('overflow')
  16420. if (overflow) {
  16421. textStyle.overflow = overflow
  16422. }
  16423. var margin = textStyleModel.get('minMargin')
  16424. if (margin != null) {
  16425. textStyle.margin = margin
  16426. }
  16427. setTokenTextStyle(
  16428. textStyle,
  16429. textStyleModel,
  16430. globalTextStyle,
  16431. opt,
  16432. isNotNormal,
  16433. isAttached,
  16434. true,
  16435. false
  16436. )
  16437. } // Consider case:
  16438. // {
  16439. // data: [{
  16440. // value: 12,
  16441. // label: {
  16442. // rich: {
  16443. // // no 'a' here but using parent 'a'.
  16444. // }
  16445. // }
  16446. // }],
  16447. // rich: {
  16448. // a: { ... }
  16449. // }
  16450. // }
  16451. // TODO TextStyleModel
  16452. function getRichItemNames(textStyleModel) {
  16453. // Use object to remove duplicated names.
  16454. var richItemNameMap
  16455. while (
  16456. textStyleModel &&
  16457. textStyleModel !== textStyleModel.ecModel
  16458. ) {
  16459. var rich = (textStyleModel.option || EMPTY_OBJ).rich
  16460. if (rich) {
  16461. richItemNameMap = richItemNameMap || {}
  16462. var richKeys = keys(rich)
  16463. for (var i = 0; i < richKeys.length; i++) {
  16464. var richKey = richKeys[i]
  16465. richItemNameMap[richKey] = 1
  16466. }
  16467. }
  16468. textStyleModel = textStyleModel.parentModel
  16469. }
  16470. return richItemNameMap
  16471. }
  16472. var TEXT_PROPS_WITH_GLOBAL = [
  16473. 'fontStyle',
  16474. 'fontWeight',
  16475. 'fontSize',
  16476. 'fontFamily',
  16477. 'textShadowColor',
  16478. 'textShadowBlur',
  16479. 'textShadowOffsetX',
  16480. 'textShadowOffsetY'
  16481. ]
  16482. var TEXT_PROPS_SELF = [
  16483. 'align',
  16484. 'lineHeight',
  16485. 'width',
  16486. 'height',
  16487. 'tag',
  16488. 'verticalAlign'
  16489. ]
  16490. var TEXT_PROPS_BOX = [
  16491. 'padding',
  16492. 'borderWidth',
  16493. 'borderRadius',
  16494. 'borderDashOffset',
  16495. 'backgroundColor',
  16496. 'borderColor',
  16497. 'shadowColor',
  16498. 'shadowBlur',
  16499. 'shadowOffsetX',
  16500. 'shadowOffsetY'
  16501. ]
  16502. function setTokenTextStyle(
  16503. textStyle,
  16504. textStyleModel,
  16505. globalTextStyle,
  16506. opt,
  16507. isNotNormal,
  16508. isAttached,
  16509. isBlock,
  16510. inRich
  16511. ) {
  16512. // In merge mode, default value should not be given.
  16513. globalTextStyle = (!isNotNormal && globalTextStyle) || EMPTY_OBJ
  16514. var inheritColor = opt && opt.inheritColor
  16515. var fillColor = textStyleModel.getShallow('color')
  16516. var strokeColor = textStyleModel.getShallow('textBorderColor')
  16517. var opacity = retrieve2(
  16518. textStyleModel.getShallow('opacity'),
  16519. globalTextStyle.opacity
  16520. )
  16521. if (fillColor === 'inherit' || fillColor === 'auto') {
  16522. if (inheritColor) {
  16523. fillColor = inheritColor
  16524. } else {
  16525. fillColor = null
  16526. }
  16527. }
  16528. if (strokeColor === 'inherit' || strokeColor === 'auto') {
  16529. if (inheritColor) {
  16530. strokeColor = inheritColor
  16531. } else {
  16532. strokeColor = null
  16533. }
  16534. }
  16535. if (!isAttached) {
  16536. // Only use default global textStyle.color if text is individual.
  16537. // Otherwise it will use the strategy of attached text color because text may be on a path.
  16538. fillColor = fillColor || globalTextStyle.color
  16539. strokeColor = strokeColor || globalTextStyle.textBorderColor
  16540. }
  16541. if (fillColor != null) {
  16542. textStyle.fill = fillColor
  16543. }
  16544. if (strokeColor != null) {
  16545. textStyle.stroke = strokeColor
  16546. }
  16547. var textBorderWidth = retrieve2(
  16548. textStyleModel.getShallow('textBorderWidth'),
  16549. globalTextStyle.textBorderWidth
  16550. )
  16551. if (textBorderWidth != null) {
  16552. textStyle.lineWidth = textBorderWidth
  16553. }
  16554. var textBorderType = retrieve2(
  16555. textStyleModel.getShallow('textBorderType'),
  16556. globalTextStyle.textBorderType
  16557. )
  16558. if (textBorderType != null) {
  16559. textStyle.lineDash = textBorderType
  16560. }
  16561. var textBorderDashOffset = retrieve2(
  16562. textStyleModel.getShallow('textBorderDashOffset'),
  16563. globalTextStyle.textBorderDashOffset
  16564. )
  16565. if (textBorderDashOffset != null) {
  16566. textStyle.lineDashOffset = textBorderDashOffset
  16567. }
  16568. if (!isNotNormal && opacity == null && !inRich) {
  16569. opacity = opt && opt.defaultOpacity
  16570. }
  16571. if (opacity != null) {
  16572. textStyle.opacity = opacity
  16573. } // TODO
  16574. if (!isNotNormal && !isAttached) {
  16575. // Set default finally.
  16576. if (textStyle.fill == null && opt.inheritColor) {
  16577. textStyle.fill = opt.inheritColor
  16578. }
  16579. } // Do not use `getFont` here, because merge should be supported, where
  16580. // part of these properties may be changed in emphasis style, and the
  16581. // others should remain their original value got from normal style.
  16582. for (var i = 0; i < TEXT_PROPS_WITH_GLOBAL.length; i++) {
  16583. var key = TEXT_PROPS_WITH_GLOBAL[i]
  16584. var val = retrieve2(
  16585. textStyleModel.getShallow(key),
  16586. globalTextStyle[key]
  16587. )
  16588. if (val != null) {
  16589. textStyle[key] = val
  16590. }
  16591. }
  16592. for (var i = 0; i < TEXT_PROPS_SELF.length; i++) {
  16593. var key = TEXT_PROPS_SELF[i]
  16594. var val = textStyleModel.getShallow(key)
  16595. if (val != null) {
  16596. textStyle[key] = val
  16597. }
  16598. }
  16599. if (textStyle.verticalAlign == null) {
  16600. var baseline = textStyleModel.getShallow('baseline')
  16601. if (baseline != null) {
  16602. textStyle.verticalAlign = baseline
  16603. }
  16604. }
  16605. if (!isBlock || !opt.disableBox) {
  16606. for (var i = 0; i < TEXT_PROPS_BOX.length; i++) {
  16607. var key = TEXT_PROPS_BOX[i]
  16608. var val = textStyleModel.getShallow(key)
  16609. if (val != null) {
  16610. textStyle[key] = val
  16611. }
  16612. }
  16613. var borderType = textStyleModel.getShallow('borderType')
  16614. if (borderType != null) {
  16615. textStyle.borderDash = borderType
  16616. }
  16617. if (
  16618. (textStyle.backgroundColor === 'auto' ||
  16619. textStyle.backgroundColor === 'inherit') &&
  16620. inheritColor
  16621. ) {
  16622. textStyle.backgroundColor = inheritColor
  16623. }
  16624. if (
  16625. (textStyle.borderColor === 'auto' ||
  16626. textStyle.borderColor === 'inherit') &&
  16627. inheritColor
  16628. ) {
  16629. textStyle.borderColor = inheritColor
  16630. }
  16631. }
  16632. }
  16633. function getFont(opt, ecModel) {
  16634. var gTextStyleModel = ecModel && ecModel.getModel('textStyle')
  16635. return trim$1(
  16636. [
  16637. // FIXME in node-canvas fontWeight is before fontStyle
  16638. opt.fontStyle ||
  16639. (gTextStyleModel &&
  16640. gTextStyleModel.getShallow('fontStyle')) ||
  16641. '',
  16642. opt.fontWeight ||
  16643. (gTextStyleModel &&
  16644. gTextStyleModel.getShallow('fontWeight')) ||
  16645. '',
  16646. (opt.fontSize ||
  16647. (gTextStyleModel && gTextStyleModel.getShallow('fontSize')) ||
  16648. 12) + 'px',
  16649. opt.fontFamily ||
  16650. (gTextStyleModel &&
  16651. gTextStyleModel.getShallow('fontFamily')) ||
  16652. 'sans-serif'
  16653. ].join(' ')
  16654. )
  16655. }
  16656. var labelInner = makeInner()
  16657. function setLabelValueAnimation(
  16658. label,
  16659. labelStatesModels,
  16660. value,
  16661. getDefaultText
  16662. ) {
  16663. if (!label) {
  16664. return
  16665. }
  16666. var obj = labelInner(label)
  16667. obj.prevValue = obj.value
  16668. obj.value = value
  16669. var normalLabelModel = labelStatesModels.normal
  16670. obj.valueAnimation = normalLabelModel.get('valueAnimation')
  16671. if (obj.valueAnimation) {
  16672. obj.precision = normalLabelModel.get('precision')
  16673. obj.defaultInterpolatedText = getDefaultText
  16674. obj.statesModels = labelStatesModels
  16675. }
  16676. }
  16677. function animateLabelValue(
  16678. textEl,
  16679. dataIndex,
  16680. data,
  16681. animatableModel,
  16682. labelFetcher
  16683. ) {
  16684. var labelInnerStore = labelInner(textEl)
  16685. if (
  16686. !labelInnerStore.valueAnimation ||
  16687. labelInnerStore.prevValue === labelInnerStore.value
  16688. ) {
  16689. // Value not changed, no new label animation
  16690. return
  16691. }
  16692. var defaultInterpolatedText =
  16693. labelInnerStore.defaultInterpolatedText // Consider the case that being animating, do not use the `obj.value`,
  16694. // Otherwise it will jump to the `obj.value` when this new animation started.
  16695. var currValue = retrieve2(
  16696. labelInnerStore.interpolatedValue,
  16697. labelInnerStore.prevValue
  16698. )
  16699. var targetValue = labelInnerStore.value
  16700. function during(percent) {
  16701. var interpolated = interpolateRawValues(
  16702. data,
  16703. labelInnerStore.precision,
  16704. currValue,
  16705. targetValue,
  16706. percent
  16707. )
  16708. labelInnerStore.interpolatedValue =
  16709. percent === 1 ? null : interpolated
  16710. var labelText = getLabelText(
  16711. {
  16712. labelDataIndex: dataIndex,
  16713. labelFetcher: labelFetcher,
  16714. defaultText: defaultInterpolatedText
  16715. ? defaultInterpolatedText(interpolated)
  16716. : interpolated + ''
  16717. },
  16718. labelInnerStore.statesModels,
  16719. interpolated
  16720. )
  16721. setLabelText(textEl, labelText)
  16722. }
  16723. textEl.percent = 0
  16724. ;(labelInnerStore.prevValue == null ? initProps : updateProps$1)(
  16725. textEl,
  16726. {
  16727. // percent is used to prevent animation from being aborted #15916
  16728. percent: 1
  16729. },
  16730. animatableModel,
  16731. dataIndex,
  16732. null,
  16733. during
  16734. )
  16735. }
  16736. var PATH_COLOR = ['textStyle', 'color']
  16737. var textStyleParams = [
  16738. 'fontStyle',
  16739. 'fontWeight',
  16740. 'fontSize',
  16741. 'fontFamily',
  16742. 'padding',
  16743. 'lineHeight',
  16744. 'rich',
  16745. 'width',
  16746. 'height',
  16747. 'overflow'
  16748. ] // TODO Performance improvement?
  16749. var tmpText = new ZRText$1()
  16750. var TextStyleMixin = /** @class */ (function () {
  16751. function TextStyleMixin() {}
  16752. /**
  16753. * Get color property or get color from option.textStyle.color
  16754. */ // TODO Callback
  16755. TextStyleMixin.prototype.getTextColor = function (isEmphasis) {
  16756. var ecModel = this.ecModel
  16757. return (
  16758. this.getShallow('color') ||
  16759. (!isEmphasis && ecModel ? ecModel.get(PATH_COLOR) : null)
  16760. )
  16761. }
  16762. /**
  16763. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  16764. * @return {string}
  16765. */ TextStyleMixin.prototype.getFont = function () {
  16766. return getFont(
  16767. {
  16768. fontStyle: this.getShallow('fontStyle'),
  16769. fontWeight: this.getShallow('fontWeight'),
  16770. fontSize: this.getShallow('fontSize'),
  16771. fontFamily: this.getShallow('fontFamily')
  16772. },
  16773. this.ecModel
  16774. )
  16775. }
  16776. TextStyleMixin.prototype.getTextRect = function (text) {
  16777. var style = {
  16778. text: text,
  16779. verticalAlign:
  16780. this.getShallow('verticalAlign') ||
  16781. this.getShallow('baseline')
  16782. }
  16783. for (var i = 0; i < textStyleParams.length; i++) {
  16784. style[textStyleParams[i]] = this.getShallow(textStyleParams[i])
  16785. }
  16786. tmpText.useStyle(style)
  16787. tmpText.update()
  16788. return tmpText.getBoundingRect()
  16789. }
  16790. return TextStyleMixin
  16791. })()
  16792. var TextStyleMixin$1 = TextStyleMixin
  16793. var LINE_STYLE_KEY_MAP = [
  16794. ['lineWidth', 'width'],
  16795. ['stroke', 'color'],
  16796. ['opacity'],
  16797. ['shadowBlur'],
  16798. ['shadowOffsetX'],
  16799. ['shadowOffsetY'],
  16800. ['shadowColor'],
  16801. ['lineDash', 'type'],
  16802. ['lineDashOffset', 'dashOffset'],
  16803. ['lineCap', 'cap'],
  16804. ['lineJoin', 'join'],
  16805. ['miterLimit'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  16806. // So do not transfer decal directly.
  16807. ]
  16808. var getLineStyle = makeStyleMapper(LINE_STYLE_KEY_MAP)
  16809. var LineStyleMixin = /** @class */ (function () {
  16810. function LineStyleMixin() {}
  16811. LineStyleMixin.prototype.getLineStyle = function (excludes) {
  16812. return getLineStyle(this, excludes)
  16813. }
  16814. return LineStyleMixin
  16815. })()
  16816. var ITEM_STYLE_KEY_MAP = [
  16817. ['fill', 'color'],
  16818. ['stroke', 'borderColor'],
  16819. ['lineWidth', 'borderWidth'],
  16820. ['opacity'],
  16821. ['shadowBlur'],
  16822. ['shadowOffsetX'],
  16823. ['shadowOffsetY'],
  16824. ['shadowColor'],
  16825. ['lineDash', 'borderType'],
  16826. ['lineDashOffset', 'borderDashOffset'],
  16827. ['lineCap', 'borderCap'],
  16828. ['lineJoin', 'borderJoin'],
  16829. ['miterLimit', 'borderMiterLimit'] // Option decal is in `DecalObject` but style.decal is in `PatternObject`.
  16830. // So do not transfer decal directly.
  16831. ]
  16832. var getItemStyle = makeStyleMapper(ITEM_STYLE_KEY_MAP)
  16833. var ItemStyleMixin = /** @class */ (function () {
  16834. function ItemStyleMixin() {}
  16835. ItemStyleMixin.prototype.getItemStyle = function (
  16836. excludes,
  16837. includes
  16838. ) {
  16839. return getItemStyle(this, excludes, includes)
  16840. }
  16841. return ItemStyleMixin
  16842. })()
  16843. var Model = /** @class */ (function () {
  16844. function Model(option, parentModel, ecModel) {
  16845. this.parentModel = parentModel
  16846. this.ecModel = ecModel
  16847. this.option = option // Simple optimization
  16848. // if (this.init) {
  16849. // if (arguments.length <= 4) {
  16850. // this.init(option, parentModel, ecModel, extraOpt);
  16851. // }
  16852. // else {
  16853. // this.init.apply(this, arguments);
  16854. // }
  16855. // }
  16856. }
  16857. Model.prototype.init = function (option, parentModel, ecModel) {
  16858. var rest = []
  16859. for (var _i = 3; _i < arguments.length; _i++) {
  16860. rest[_i - 3] = arguments[_i]
  16861. }
  16862. }
  16863. /**
  16864. * Merge the input option to me.
  16865. */ Model.prototype.mergeOption = function (option, ecModel) {
  16866. merge(this.option, option, true)
  16867. } // `path` can be 'a.b.c', so the return value type have to be `ModelOption`
  16868. // TODO: TYPE strict key check?
  16869. // get(path: string | string[], ignoreParent?: boolean): ModelOption;
  16870. Model.prototype.get = function (path, ignoreParent) {
  16871. if (path == null) {
  16872. return this.option
  16873. }
  16874. return this._doGet(
  16875. this.parsePath(path),
  16876. !ignoreParent && this.parentModel
  16877. )
  16878. }
  16879. Model.prototype.getShallow = function (key, ignoreParent) {
  16880. var option = this.option
  16881. var val = option == null ? option : option[key]
  16882. if (val == null && !ignoreParent) {
  16883. var parentModel = this.parentModel
  16884. if (parentModel) {
  16885. // FIXME:TS do not know how to make it works
  16886. val = parentModel.getShallow(key)
  16887. }
  16888. }
  16889. return val
  16890. } // `path` can be 'a.b.c', so the return value type have to be `Model<ModelOption>`
  16891. // getModel(path: string | string[], parentModel?: Model): Model;
  16892. // TODO 'a.b.c' is deprecated
  16893. Model.prototype.getModel = function (path, parentModel) {
  16894. var hasPath = path != null
  16895. var pathFinal = hasPath ? this.parsePath(path) : null
  16896. var obj = hasPath ? this._doGet(pathFinal) : this.option
  16897. parentModel =
  16898. parentModel ||
  16899. (this.parentModel &&
  16900. this.parentModel.getModel(this.resolveParentPath(pathFinal)))
  16901. return new Model(obj, parentModel, this.ecModel)
  16902. }
  16903. /**
  16904. * If model has option
  16905. */ Model.prototype.isEmpty = function () {
  16906. return this.option == null
  16907. }
  16908. Model.prototype.restoreData = function () {} // Pending
  16909. Model.prototype.clone = function () {
  16910. var Ctor = this.constructor
  16911. return new Ctor(clone$3(this.option))
  16912. } // setReadOnly(properties): void {
  16913. // clazzUtil.setReadOnly(this, properties);
  16914. // }
  16915. // If path is null/undefined, return null/undefined.
  16916. Model.prototype.parsePath = function (path) {
  16917. if (typeof path === 'string') {
  16918. return path.split('.')
  16919. }
  16920. return path
  16921. } // Resolve path for parent. Perhaps useful when parent use a different property.
  16922. // Default to be a identity resolver.
  16923. // Can be modified to a different resolver.
  16924. Model.prototype.resolveParentPath = function (path) {
  16925. return path
  16926. } // FIXME:TS check whether put this method here
  16927. Model.prototype.isAnimationEnabled = function () {
  16928. if (!env$1.node && this.option) {
  16929. if (this.option.animation != null) {
  16930. return !!this.option.animation
  16931. } else if (this.parentModel) {
  16932. return this.parentModel.isAnimationEnabled()
  16933. }
  16934. }
  16935. }
  16936. Model.prototype._doGet = function (pathArr, parentModel) {
  16937. var obj = this.option
  16938. if (!pathArr) {
  16939. return obj
  16940. }
  16941. for (var i = 0; i < pathArr.length; i++) {
  16942. // Ignore empty
  16943. if (!pathArr[i]) {
  16944. continue
  16945. } // obj could be number/string/... (like 0)
  16946. obj = obj && _typeof(obj) === 'object' ? obj[pathArr[i]] : null
  16947. if (obj == null) {
  16948. break
  16949. }
  16950. }
  16951. if (obj == null && parentModel) {
  16952. obj = parentModel._doGet(
  16953. this.resolveParentPath(pathArr),
  16954. parentModel.parentModel
  16955. )
  16956. }
  16957. return obj
  16958. }
  16959. return Model
  16960. })()
  16961. enableClassExtend(Model)
  16962. enableClassCheck(Model)
  16963. mixin(Model, LineStyleMixin)
  16964. mixin(Model, ItemStyleMixin)
  16965. mixin(Model, AreaStyleMixin)
  16966. mixin(Model, TextStyleMixin$1)
  16967. var Model$1 = Model
  16968. var base = Math.round(Math.random() * 10)
  16969. /**
  16970. * @public
  16971. * @param {string} type
  16972. * @return {string}
  16973. */ function getUID(type) {
  16974. // Considering the case of crossing js context,
  16975. // use Math.random to make id as unique as possible.
  16976. return [type || '', base++].join('_')
  16977. }
  16978. /**
  16979. * Implements `SubTypeDefaulterManager` for `target`.
  16980. */ function enableSubTypeDefaulter(target) {
  16981. var subTypeDefaulters = {}
  16982. target.registerSubTypeDefaulter = function (
  16983. componentType,
  16984. defaulter
  16985. ) {
  16986. var componentTypeInfo = parseClassType(componentType)
  16987. subTypeDefaulters[componentTypeInfo.main] = defaulter
  16988. }
  16989. target.determineSubType = function (componentType, option) {
  16990. var type = option.type
  16991. if (!type) {
  16992. var componentTypeMain = parseClassType(componentType).main
  16993. if (
  16994. target.hasSubTypes(componentType) &&
  16995. subTypeDefaulters[componentTypeMain]
  16996. ) {
  16997. type = subTypeDefaulters[componentTypeMain](option)
  16998. }
  16999. }
  17000. return type
  17001. }
  17002. }
  17003. /**
  17004. * Implements `TopologicalTravelable<any>` for `entity`.
  17005. *
  17006. * Topological travel on Activity Network (Activity On Vertices).
  17007. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  17008. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  17009. * If there is circular dependencey, Error will be thrown.
  17010. */ function enableTopologicalTravel(entity, dependencyGetter) {
  17011. /**
  17012. * @param targetNameList Target Component type list.
  17013. * Can be ['aa', 'bb', 'aa.xx']
  17014. * @param fullNameList By which we can build dependency graph.
  17015. * @param callback Params: componentType, dependencies.
  17016. * @param context Scope of callback.
  17017. */ entity.topologicalTravel = function (
  17018. targetNameList,
  17019. fullNameList,
  17020. callback,
  17021. context
  17022. ) {
  17023. if (!targetNameList.length) {
  17024. return
  17025. }
  17026. var result = makeDepndencyGraph(fullNameList)
  17027. var graph = result.graph
  17028. var noEntryList = result.noEntryList
  17029. var targetNameSet = {}
  17030. each$7(targetNameList, function (name) {
  17031. targetNameSet[name] = true
  17032. })
  17033. while (noEntryList.length) {
  17034. var currComponentType = noEntryList.pop()
  17035. var currVertex = graph[currComponentType]
  17036. var isInTargetNameSet = !!targetNameSet[currComponentType]
  17037. if (isInTargetNameSet) {
  17038. callback.call(
  17039. context,
  17040. currComponentType,
  17041. currVertex.originalDeps.slice()
  17042. )
  17043. delete targetNameSet[currComponentType]
  17044. }
  17045. each$7(
  17046. currVertex.successor,
  17047. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  17048. )
  17049. }
  17050. each$7(targetNameSet, function () {
  17051. var errMsg = ''
  17052. throw new Error(errMsg)
  17053. })
  17054. function removeEdge(succComponentType) {
  17055. graph[succComponentType].entryCount--
  17056. if (graph[succComponentType].entryCount === 0) {
  17057. noEntryList.push(succComponentType)
  17058. }
  17059. } // Consider this case: legend depends on series, and we call
  17060. // chart.setOption({series: [...]}), where only series is in option.
  17061. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  17062. // not be called, but only sereis.mergeOption is called. Thus legend
  17063. // have no chance to update its local record about series (like which
  17064. // name of series is available in legend).
  17065. function removeEdgeAndAdd(succComponentType) {
  17066. targetNameSet[succComponentType] = true
  17067. removeEdge(succComponentType)
  17068. }
  17069. }
  17070. function makeDepndencyGraph(fullNameList) {
  17071. var graph = {}
  17072. var noEntryList = []
  17073. each$7(fullNameList, function (name) {
  17074. var thisItem = createDependencyGraphItem(graph, name)
  17075. var originalDeps = (thisItem.originalDeps =
  17076. dependencyGetter(name))
  17077. var availableDeps = getAvailableDependencies(
  17078. originalDeps,
  17079. fullNameList
  17080. )
  17081. thisItem.entryCount = availableDeps.length
  17082. if (thisItem.entryCount === 0) {
  17083. noEntryList.push(name)
  17084. }
  17085. each$7(availableDeps, function (dependentName) {
  17086. if (indexOf(thisItem.predecessor, dependentName) < 0) {
  17087. thisItem.predecessor.push(dependentName)
  17088. }
  17089. var thatItem = createDependencyGraphItem(graph, dependentName)
  17090. if (indexOf(thatItem.successor, dependentName) < 0) {
  17091. thatItem.successor.push(name)
  17092. }
  17093. })
  17094. })
  17095. return { graph: graph, noEntryList: noEntryList }
  17096. }
  17097. function createDependencyGraphItem(graph, name) {
  17098. if (!graph[name]) {
  17099. graph[name] = { predecessor: [], successor: [] }
  17100. }
  17101. return graph[name]
  17102. }
  17103. function getAvailableDependencies(originalDeps, fullNameList) {
  17104. var availableDeps = []
  17105. each$7(originalDeps, function (dep) {
  17106. indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep)
  17107. })
  17108. return availableDeps
  17109. }
  17110. }
  17111. function inheritDefaultOption(superOption, subOption) {
  17112. // See also `model/Component.ts#getDefaultOption`
  17113. return merge(merge({}, superOption, true), subOption, true)
  17114. }
  17115. /*
  17116. * Licensed to the Apache Software Foundation (ASF) under one
  17117. * or more contributor license agreements. See the NOTICE file
  17118. * distributed with this work for additional information
  17119. * regarding copyright ownership. The ASF licenses this file
  17120. * to you under the Apache License, Version 2.0 (the
  17121. * "License"); you may not use this file except in compliance
  17122. * with the License. You may obtain a copy of the License at
  17123. *
  17124. * http://www.apache.org/licenses/LICENSE-2.0
  17125. *
  17126. * Unless required by applicable law or agreed to in writing,
  17127. * software distributed under the License is distributed on an
  17128. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17129. * KIND, either express or implied. See the License for the
  17130. * specific language governing permissions and limitations
  17131. * under the License.
  17132. */ /**
  17133. * AUTO-GENERATED FILE. DO NOT MODIFY.
  17134. */ /*
  17135. * Licensed to the Apache Software Foundation (ASF) under one
  17136. * or more contributor license agreements. See the NOTICE file
  17137. * distributed with this work for additional information
  17138. * regarding copyright ownership. The ASF licenses this file
  17139. * to you under the Apache License, Version 2.0 (the
  17140. * "License"); you may not use this file except in compliance
  17141. * with the License. You may obtain a copy of the License at
  17142. *
  17143. * http://www.apache.org/licenses/LICENSE-2.0
  17144. *
  17145. * Unless required by applicable law or agreed to in writing,
  17146. * software distributed under the License is distributed on an
  17147. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17148. * KIND, either express or implied. See the License for the
  17149. * specific language governing permissions and limitations
  17150. * under the License.
  17151. */ /**
  17152. * Language: English.
  17153. */ var langEN = {
  17154. time: {
  17155. month: [
  17156. 'January',
  17157. 'February',
  17158. 'March',
  17159. 'April',
  17160. 'May',
  17161. 'June',
  17162. 'July',
  17163. 'August',
  17164. 'September',
  17165. 'October',
  17166. 'November',
  17167. 'December'
  17168. ],
  17169. monthAbbr: [
  17170. 'Jan',
  17171. 'Feb',
  17172. 'Mar',
  17173. 'Apr',
  17174. 'May',
  17175. 'Jun',
  17176. 'Jul',
  17177. 'Aug',
  17178. 'Sep',
  17179. 'Oct',
  17180. 'Nov',
  17181. 'Dec'
  17182. ],
  17183. dayOfWeek: [
  17184. 'Sunday',
  17185. 'Monday',
  17186. 'Tuesday',
  17187. 'Wednesday',
  17188. 'Thursday',
  17189. 'Friday',
  17190. 'Saturday'
  17191. ],
  17192. dayOfWeekAbbr: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
  17193. },
  17194. legend: { selector: { all: 'All', inverse: 'Inv' } },
  17195. toolbox: {
  17196. brush: {
  17197. title: {
  17198. rect: 'Box Select',
  17199. polygon: 'Lasso Select',
  17200. lineX: 'Horizontally Select',
  17201. lineY: 'Vertically Select',
  17202. keep: 'Keep Selections',
  17203. clear: 'Clear Selections'
  17204. }
  17205. },
  17206. dataView: {
  17207. title: 'Data View',
  17208. lang: ['Data View', 'Close', 'Refresh']
  17209. },
  17210. dataZoom: { title: { zoom: 'Zoom', back: 'Zoom Reset' } },
  17211. magicType: {
  17212. title: {
  17213. line: 'Switch to Line Chart',
  17214. bar: 'Switch to Bar Chart',
  17215. stack: 'Stack',
  17216. tiled: 'Tile'
  17217. }
  17218. },
  17219. restore: { title: 'Restore' },
  17220. saveAsImage: {
  17221. title: 'Save as Image',
  17222. lang: ['Right Click to Save Image']
  17223. }
  17224. },
  17225. series: {
  17226. typeNames: {
  17227. pie: 'Pie chart',
  17228. bar: 'Bar chart',
  17229. line: 'Line chart',
  17230. scatter: 'Scatter plot',
  17231. effectScatter: 'Ripple scatter plot',
  17232. radar: 'Radar chart',
  17233. tree: 'Tree',
  17234. treemap: 'Treemap',
  17235. boxplot: 'Boxplot',
  17236. candlestick: 'Candlestick',
  17237. k: 'K line chart',
  17238. heatmap: 'Heat map',
  17239. map: 'Map',
  17240. parallel: 'Parallel coordinate map',
  17241. lines: 'Line graph',
  17242. graph: 'Relationship graph',
  17243. sankey: 'Sankey diagram',
  17244. funnel: 'Funnel chart',
  17245. gauge: 'Gauge',
  17246. pictorialBar: 'Pictorial bar',
  17247. themeRiver: 'Theme River Map',
  17248. sunburst: 'Sunburst'
  17249. }
  17250. },
  17251. aria: {
  17252. general: {
  17253. withTitle: 'This is a chart about "{title}"',
  17254. withoutTitle: 'This is a chart'
  17255. },
  17256. series: {
  17257. single: {
  17258. prefix: '',
  17259. withName: ' with type {seriesType} named {seriesName}.',
  17260. withoutName: ' with type {seriesType}.'
  17261. },
  17262. multiple: {
  17263. prefix: '. It consists of {seriesCount} series count.',
  17264. withName:
  17265. ' The {seriesId} series is a {seriesType} representing {seriesName}.',
  17266. withoutName: ' The {seriesId} series is a {seriesType}.',
  17267. separator: { middle: '', end: '' }
  17268. }
  17269. },
  17270. data: {
  17271. allData: 'The data is as follows: ',
  17272. partialData: 'The first {displayCnt} items are: ',
  17273. withName: 'the data for {name} is {value}',
  17274. withoutName: '{value}',
  17275. separator: { middle: ', ', end: '. ' }
  17276. }
  17277. }
  17278. }
  17279. /*
  17280. * Licensed to the Apache Software Foundation (ASF) under one
  17281. * or more contributor license agreements. See the NOTICE file
  17282. * distributed with this work for additional information
  17283. * regarding copyright ownership. The ASF licenses this file
  17284. * to you under the Apache License, Version 2.0 (the
  17285. * "License"); you may not use this file except in compliance
  17286. * with the License. You may obtain a copy of the License at
  17287. *
  17288. * http://www.apache.org/licenses/LICENSE-2.0
  17289. *
  17290. * Unless required by applicable law or agreed to in writing,
  17291. * software distributed under the License is distributed on an
  17292. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17293. * KIND, either express or implied. See the License for the
  17294. * specific language governing permissions and limitations
  17295. * under the License.
  17296. */ /**
  17297. * AUTO-GENERATED FILE. DO NOT MODIFY.
  17298. */ /*
  17299. * Licensed to the Apache Software Foundation (ASF) under one
  17300. * or more contributor license agreements. See the NOTICE file
  17301. * distributed with this work for additional information
  17302. * regarding copyright ownership. The ASF licenses this file
  17303. * to you under the Apache License, Version 2.0 (the
  17304. * "License"); you may not use this file except in compliance
  17305. * with the License. You may obtain a copy of the License at
  17306. *
  17307. * http://www.apache.org/licenses/LICENSE-2.0
  17308. *
  17309. * Unless required by applicable law or agreed to in writing,
  17310. * software distributed under the License is distributed on an
  17311. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  17312. * KIND, either express or implied. See the License for the
  17313. * specific language governing permissions and limitations
  17314. * under the License.
  17315. */ var langZH = {
  17316. time: {
  17317. month: [
  17318. '一月',
  17319. '二月',
  17320. '三月',
  17321. '四月',
  17322. '五月',
  17323. '六月',
  17324. '七月',
  17325. '八月',
  17326. '九月',
  17327. '十月',
  17328. '十一月',
  17329. '十二月'
  17330. ],
  17331. monthAbbr: [
  17332. '1月',
  17333. '2月',
  17334. '3月',
  17335. '4月',
  17336. '5月',
  17337. '6月',
  17338. '7月',
  17339. '8月',
  17340. '9月',
  17341. '10月',
  17342. '11月',
  17343. '12月'
  17344. ],
  17345. dayOfWeek: [
  17346. '星期日',
  17347. '星期一',
  17348. '星期二',
  17349. '星期三',
  17350. '星期四',
  17351. '星期五',
  17352. '星期六'
  17353. ],
  17354. dayOfWeekAbbr: ['日', '一', '二', '三', '四', '五', '六']
  17355. },
  17356. legend: { selector: { all: '全选', inverse: '反选' } },
  17357. toolbox: {
  17358. brush: {
  17359. title: {
  17360. rect: '矩形选择',
  17361. polygon: '圈选',
  17362. lineX: '横向选择',
  17363. lineY: '纵向选择',
  17364. keep: '保持选择',
  17365. clear: '清除选择'
  17366. }
  17367. },
  17368. dataView: {
  17369. title: '数据视图',
  17370. lang: ['数据视图', '关闭', '刷新']
  17371. },
  17372. dataZoom: { title: { zoom: '区域缩放', back: '区域缩放还原' } },
  17373. magicType: {
  17374. title: {
  17375. line: '切换为折线图',
  17376. bar: '切换为柱状图',
  17377. stack: '切换为堆叠',
  17378. tiled: '切换为平铺'
  17379. }
  17380. },
  17381. restore: { title: '还原' },
  17382. saveAsImage: { title: '保存为图片', lang: ['右键另存为图片'] }
  17383. },
  17384. series: {
  17385. typeNames: {
  17386. pie: '饼图',
  17387. bar: '柱状图',
  17388. line: '折线图',
  17389. scatter: '散点图',
  17390. effectScatter: '涟漪散点图',
  17391. radar: '雷达图',
  17392. tree: '树图',
  17393. treemap: '矩形树图',
  17394. boxplot: '箱型图',
  17395. candlestick: 'K线图',
  17396. k: 'K线图',
  17397. heatmap: '热力图',
  17398. map: '地图',
  17399. parallel: '平行坐标图',
  17400. lines: '线图',
  17401. graph: '关系图',
  17402. sankey: '桑基图',
  17403. funnel: '漏斗图',
  17404. gauge: '仪表盘图',
  17405. pictorialBar: '象形柱图',
  17406. themeRiver: '主题河流图',
  17407. sunburst: '旭日图'
  17408. }
  17409. },
  17410. aria: {
  17411. general: {
  17412. withTitle: '这是一个关于“{title}”的图表。',
  17413. withoutTitle: '这是一个图表,'
  17414. },
  17415. series: {
  17416. single: {
  17417. prefix: '',
  17418. withName: '图表类型是{seriesType},表示{seriesName}。',
  17419. withoutName: '图表类型是{seriesType}。'
  17420. },
  17421. multiple: {
  17422. prefix: '它由{seriesCount}个图表系列组成。',
  17423. withName:
  17424. '第{seriesId}个系列是一个表示{seriesName}的{seriesType},',
  17425. withoutName: '第{seriesId}个系列是一个{seriesType},',
  17426. separator: { middle: ';', end: '。' }
  17427. }
  17428. },
  17429. data: {
  17430. allData: '其数据是——',
  17431. partialData: '其中,前{displayCnt}项是——',
  17432. withName: '{name}的数据是{value}',
  17433. withoutName: '{value}',
  17434. separator: { middle: ',', end: '' }
  17435. }
  17436. }
  17437. }
  17438. var LOCALE_ZH = 'ZH'
  17439. var LOCALE_EN = 'EN'
  17440. var DEFAULT_LOCALE = LOCALE_EN
  17441. var localeStorage = {}
  17442. var localeModels = {}
  17443. var SYSTEM_LANG = !env$1.domSupported
  17444. ? DEFAULT_LOCALE
  17445. : (function () {
  17446. var langStr = /* eslint-disable-next-line */ (
  17447. document.documentElement.lang ||
  17448. navigator.language ||
  17449. navigator.browserLanguage
  17450. ).toUpperCase()
  17451. return langStr.indexOf(LOCALE_ZH) > -1
  17452. ? LOCALE_ZH
  17453. : DEFAULT_LOCALE
  17454. })()
  17455. function registerLocale(locale, localeObj) {
  17456. locale = locale.toUpperCase()
  17457. localeModels[locale] = new Model$1(localeObj)
  17458. localeStorage[locale] = localeObj
  17459. } // export function getLocale(locale: string) {
  17460. // return localeStorage[locale];
  17461. // }
  17462. function createLocaleObject(locale) {
  17463. if (isString(locale)) {
  17464. var localeObj = localeStorage[locale.toUpperCase()] || {}
  17465. if (locale === LOCALE_ZH || locale === LOCALE_EN) {
  17466. return clone$3(localeObj)
  17467. } else {
  17468. return merge(
  17469. clone$3(localeObj),
  17470. clone$3(localeStorage[DEFAULT_LOCALE]),
  17471. false
  17472. )
  17473. }
  17474. } else {
  17475. return merge(
  17476. clone$3(locale),
  17477. clone$3(localeStorage[DEFAULT_LOCALE]),
  17478. false
  17479. )
  17480. }
  17481. }
  17482. function getLocaleModel(lang) {
  17483. return localeModels[lang]
  17484. }
  17485. function getDefaultLocaleModel() {
  17486. return localeModels[DEFAULT_LOCALE]
  17487. } // Default locale
  17488. registerLocale(LOCALE_EN, langEN)
  17489. registerLocale(LOCALE_ZH, langZH)
  17490. var ONE_SECOND = 1000
  17491. var ONE_MINUTE = ONE_SECOND * 60
  17492. var ONE_HOUR = ONE_MINUTE * 60
  17493. var ONE_DAY = ONE_HOUR * 24
  17494. var ONE_YEAR = ONE_DAY * 365
  17495. var defaultLeveledFormatter = {
  17496. year: '{yyyy}',
  17497. month: '{MMM}',
  17498. day: '{d}',
  17499. hour: '{HH}:{mm}',
  17500. minute: '{HH}:{mm}',
  17501. second: '{HH}:{mm}:{ss}',
  17502. millisecond: '{HH}:{mm}:{ss} {SSS}',
  17503. none: '{yyyy}-{MM}-{dd} {HH}:{mm}:{ss} {SSS}'
  17504. }
  17505. var fullDayFormatter = '{yyyy}-{MM}-{dd}'
  17506. var fullLeveledFormatter = {
  17507. year: '{yyyy}',
  17508. month: '{yyyy}-{MM}',
  17509. day: fullDayFormatter,
  17510. hour: fullDayFormatter + ' ' + defaultLeveledFormatter.hour,
  17511. minute: fullDayFormatter + ' ' + defaultLeveledFormatter.minute,
  17512. second: fullDayFormatter + ' ' + defaultLeveledFormatter.second,
  17513. millisecond: defaultLeveledFormatter.none
  17514. }
  17515. var primaryTimeUnits = [
  17516. 'year',
  17517. 'month',
  17518. 'day',
  17519. 'hour',
  17520. 'minute',
  17521. 'second',
  17522. 'millisecond'
  17523. ]
  17524. var timeUnits = [
  17525. 'year',
  17526. 'half-year',
  17527. 'quarter',
  17528. 'month',
  17529. 'week',
  17530. 'half-week',
  17531. 'day',
  17532. 'half-day',
  17533. 'quarter-day',
  17534. 'hour',
  17535. 'minute',
  17536. 'second',
  17537. 'millisecond'
  17538. ]
  17539. function pad(str, len) {
  17540. str += ''
  17541. return '0000'.substr(0, len - str.length) + str
  17542. }
  17543. function getPrimaryTimeUnit(timeUnit) {
  17544. switch (timeUnit) {
  17545. case 'half-year':
  17546. case 'quarter':
  17547. return 'month'
  17548. case 'week':
  17549. case 'half-week':
  17550. return 'day'
  17551. case 'half-day':
  17552. case 'quarter-day':
  17553. return 'hour'
  17554. default:
  17555. // year, minutes, second, milliseconds
  17556. return timeUnit
  17557. }
  17558. }
  17559. function isPrimaryTimeUnit(timeUnit) {
  17560. return timeUnit === getPrimaryTimeUnit(timeUnit)
  17561. }
  17562. function getDefaultFormatPrecisionOfInterval(timeUnit) {
  17563. switch (timeUnit) {
  17564. case 'year':
  17565. case 'month':
  17566. return 'day'
  17567. case 'millisecond':
  17568. return 'millisecond'
  17569. default:
  17570. // Also for day, hour, minute, second
  17571. return 'second'
  17572. }
  17573. }
  17574. function format( // Note: The result based on `isUTC` are totally different, which can not be just simply
  17575. // substituted by the result without `isUTC`. So we make the param `isUTC` mandatory.
  17576. time,
  17577. template,
  17578. isUTC,
  17579. lang
  17580. ) {
  17581. var date = parseDate(time)
  17582. var y = date[fullYearGetterName(isUTC)]()
  17583. var M = date[monthGetterName(isUTC)]() + 1
  17584. var q = Math.floor((M - 1) / 3) + 1
  17585. var d = date[dateGetterName(isUTC)]()
  17586. var e = date['get' + (isUTC ? 'UTC' : '') + 'Day']()
  17587. var H = date[hoursGetterName(isUTC)]()
  17588. var h = ((H - 1) % 12) + 1
  17589. var m = date[minutesGetterName(isUTC)]()
  17590. var s = date[secondsGetterName(isUTC)]()
  17591. var S = date[millisecondsGetterName(isUTC)]()
  17592. var localeModel =
  17593. lang instanceof Model$1
  17594. ? lang
  17595. : getLocaleModel(lang || SYSTEM_LANG) || getDefaultLocaleModel()
  17596. var timeModel = localeModel.getModel('time')
  17597. var month = timeModel.get('month')
  17598. var monthAbbr = timeModel.get('monthAbbr')
  17599. var dayOfWeek = timeModel.get('dayOfWeek')
  17600. var dayOfWeekAbbr = timeModel.get('dayOfWeekAbbr')
  17601. return (template || '')
  17602. .replace(/{yyyy}/g, y + '')
  17603. .replace(/{yy}/g, (y % 100) + '')
  17604. .replace(/{Q}/g, q + '')
  17605. .replace(/{MMMM}/g, month[M - 1])
  17606. .replace(/{MMM}/g, monthAbbr[M - 1])
  17607. .replace(/{MM}/g, pad(M, 2))
  17608. .replace(/{M}/g, M + '')
  17609. .replace(/{dd}/g, pad(d, 2))
  17610. .replace(/{d}/g, d + '')
  17611. .replace(/{eeee}/g, dayOfWeek[e])
  17612. .replace(/{ee}/g, dayOfWeekAbbr[e])
  17613. .replace(/{e}/g, e + '')
  17614. .replace(/{HH}/g, pad(H, 2))
  17615. .replace(/{H}/g, H + '')
  17616. .replace(/{hh}/g, pad(h + '', 2))
  17617. .replace(/{h}/g, h + '')
  17618. .replace(/{mm}/g, pad(m, 2))
  17619. .replace(/{m}/g, m + '')
  17620. .replace(/{ss}/g, pad(s, 2))
  17621. .replace(/{s}/g, s + '')
  17622. .replace(/{SSS}/g, pad(S, 3))
  17623. .replace(/{S}/g, S + '')
  17624. }
  17625. function leveledFormat(tick, idx, formatter, lang, isUTC) {
  17626. var template = null
  17627. if (isString(formatter)) {
  17628. // Single formatter for all units at all levels
  17629. template = formatter
  17630. } else if (isFunction(formatter)) {
  17631. // Callback formatter
  17632. template = formatter(tick.value, idx, { level: tick.level })
  17633. } else {
  17634. var defaults$1 = extend({}, defaultLeveledFormatter)
  17635. if (tick.level > 0) {
  17636. for (var i = 0; i < primaryTimeUnits.length; ++i) {
  17637. defaults$1[primaryTimeUnits[i]] =
  17638. '{primary|' + defaults$1[primaryTimeUnits[i]] + '}'
  17639. }
  17640. }
  17641. var mergedFormatter = formatter
  17642. ? formatter.inherit === false
  17643. ? formatter // Use formatter with bigger units
  17644. : defaults(formatter, defaults$1)
  17645. : defaults$1
  17646. var unit = getUnitFromValue(tick.value, isUTC)
  17647. if (mergedFormatter[unit]) {
  17648. template = mergedFormatter[unit]
  17649. } else if (mergedFormatter.inherit) {
  17650. // Unit formatter is not defined and should inherit from bigger units
  17651. var targetId = timeUnits.indexOf(unit)
  17652. for (var i = targetId - 1; i >= 0; --i) {
  17653. if (mergedFormatter[unit]) {
  17654. template = mergedFormatter[unit]
  17655. break
  17656. }
  17657. }
  17658. template = template || defaults$1.none
  17659. }
  17660. if (isArray(template)) {
  17661. var levelId =
  17662. tick.level == null
  17663. ? 0
  17664. : tick.level >= 0
  17665. ? tick.level
  17666. : template.length + tick.level
  17667. levelId = Math.min(levelId, template.length - 1)
  17668. template = template[levelId]
  17669. }
  17670. }
  17671. return format(new Date(tick.value), template, isUTC, lang)
  17672. }
  17673. function getUnitFromValue(value, isUTC) {
  17674. var date = parseDate(value)
  17675. var M = date[monthGetterName(isUTC)]() + 1
  17676. var d = date[dateGetterName(isUTC)]()
  17677. var h = date[hoursGetterName(isUTC)]()
  17678. var m = date[minutesGetterName(isUTC)]()
  17679. var s = date[secondsGetterName(isUTC)]()
  17680. var S = date[millisecondsGetterName(isUTC)]()
  17681. var isSecond = S === 0
  17682. var isMinute = isSecond && s === 0
  17683. var isHour = isMinute && m === 0
  17684. var isDay = isHour && h === 0
  17685. var isMonth = isDay && d === 1
  17686. var isYear = isMonth && M === 1
  17687. if (isYear) {
  17688. return 'year'
  17689. } else if (isMonth) {
  17690. return 'month'
  17691. } else if (isDay) {
  17692. return 'day'
  17693. } else if (isHour) {
  17694. return 'hour'
  17695. } else if (isMinute) {
  17696. return 'minute'
  17697. } else if (isSecond) {
  17698. return 'second'
  17699. } else {
  17700. return 'millisecond'
  17701. }
  17702. }
  17703. function getUnitValue(value, unit, isUTC) {
  17704. var date = isNumber(value) ? parseDate(value) : value
  17705. unit = unit || getUnitFromValue(value, isUTC)
  17706. switch (unit) {
  17707. case 'year':
  17708. return date[fullYearGetterName(isUTC)]()
  17709. case 'half-year':
  17710. return date[monthGetterName(isUTC)]() >= 6 ? 1 : 0
  17711. case 'quarter':
  17712. return Math.floor((date[monthGetterName(isUTC)]() + 1) / 4)
  17713. case 'month':
  17714. return date[monthGetterName(isUTC)]()
  17715. case 'day':
  17716. return date[dateGetterName(isUTC)]()
  17717. case 'half-day':
  17718. return date[hoursGetterName(isUTC)]() / 24
  17719. case 'hour':
  17720. return date[hoursGetterName(isUTC)]()
  17721. case 'minute':
  17722. return date[minutesGetterName(isUTC)]()
  17723. case 'second':
  17724. return date[secondsGetterName(isUTC)]()
  17725. case 'millisecond':
  17726. return date[millisecondsGetterName(isUTC)]()
  17727. }
  17728. }
  17729. function fullYearGetterName(isUTC) {
  17730. return isUTC ? 'getUTCFullYear' : 'getFullYear'
  17731. }
  17732. function monthGetterName(isUTC) {
  17733. return isUTC ? 'getUTCMonth' : 'getMonth'
  17734. }
  17735. function dateGetterName(isUTC) {
  17736. return isUTC ? 'getUTCDate' : 'getDate'
  17737. }
  17738. function hoursGetterName(isUTC) {
  17739. return isUTC ? 'getUTCHours' : 'getHours'
  17740. }
  17741. function minutesGetterName(isUTC) {
  17742. return isUTC ? 'getUTCMinutes' : 'getMinutes'
  17743. }
  17744. function secondsGetterName(isUTC) {
  17745. return isUTC ? 'getUTCSeconds' : 'getSeconds'
  17746. }
  17747. function millisecondsGetterName(isUTC) {
  17748. return isUTC ? 'getUTCMilliseconds' : 'getMilliseconds'
  17749. }
  17750. function fullYearSetterName(isUTC) {
  17751. return isUTC ? 'setUTCFullYear' : 'setFullYear'
  17752. }
  17753. function monthSetterName(isUTC) {
  17754. return isUTC ? 'setUTCMonth' : 'setMonth'
  17755. }
  17756. function dateSetterName(isUTC) {
  17757. return isUTC ? 'setUTCDate' : 'setDate'
  17758. }
  17759. function hoursSetterName(isUTC) {
  17760. return isUTC ? 'setUTCHours' : 'setHours'
  17761. }
  17762. function minutesSetterName(isUTC) {
  17763. return isUTC ? 'setUTCMinutes' : 'setMinutes'
  17764. }
  17765. function secondsSetterName(isUTC) {
  17766. return isUTC ? 'setUTCSeconds' : 'setSeconds'
  17767. }
  17768. function millisecondsSetterName(isUTC) {
  17769. return isUTC ? 'setUTCMilliseconds' : 'setMilliseconds'
  17770. }
  17771. /**
  17772. * Add a comma each three digit.
  17773. */ function addCommas(x) {
  17774. if (!isNumeric(x)) {
  17775. return isString(x) ? x : '-'
  17776. }
  17777. var parts = (x + '').split('.')
  17778. return (
  17779. parts[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g, '$1,') +
  17780. (parts.length > 1 ? '.' + parts[1] : '')
  17781. )
  17782. }
  17783. function toCamelCase(str, upperCaseFirst) {
  17784. str = (str || '')
  17785. .toLowerCase()
  17786. .replace(/-(.)/g, function (match, group1) {
  17787. return group1.toUpperCase()
  17788. })
  17789. if (upperCaseFirst && str) {
  17790. str = str.charAt(0).toUpperCase() + str.slice(1)
  17791. }
  17792. return str
  17793. }
  17794. var normalizeCssArray = normalizeCssArray$1
  17795. var replaceReg = /([&<>"'])/g
  17796. var replaceMap = {
  17797. '&': '&amp;',
  17798. '<': '&lt;',
  17799. '>': '&gt;',
  17800. '"': '&quot;',
  17801. "'": '&#39;'
  17802. }
  17803. function encodeHTML(source) {
  17804. return source == null
  17805. ? ''
  17806. : (source + '').replace(replaceReg, function (str, c) {
  17807. return replaceMap[c]
  17808. })
  17809. }
  17810. /**
  17811. * Make value user readable for tooltip and label.
  17812. * "User readable":
  17813. * Try to not print programmer-specific text like NaN, Infinity, null, undefined.
  17814. * Avoid to display an empty string, which users can not recognize there is
  17815. * a value and it might look like a bug.
  17816. */ function makeValueReadable(value, valueType, useUTC) {
  17817. var USER_READABLE_DEFUALT_TIME_PATTERN =
  17818. '{yyyy}-{MM}-{dd} {HH}:{mm}:{ss}'
  17819. function stringToUserReadable(str) {
  17820. return str && trim$1(str) ? str : '-'
  17821. }
  17822. function isNumberUserReadable(num) {
  17823. return !!(num != null && !isNaN(num) && isFinite(num))
  17824. }
  17825. var isTypeTime = valueType === 'time'
  17826. var isValueDate = value instanceof Date
  17827. if (isTypeTime || isValueDate) {
  17828. var date = isTypeTime ? parseDate(value) : value
  17829. if (!isNaN(+date)) {
  17830. return format(date, USER_READABLE_DEFUALT_TIME_PATTERN, useUTC)
  17831. } else if (isValueDate) {
  17832. return '-'
  17833. } // In other cases, continue to try to display the value in the following code.
  17834. }
  17835. if (valueType === 'ordinal') {
  17836. return isStringSafe(value)
  17837. ? stringToUserReadable(value)
  17838. : isNumber(value)
  17839. ? isNumberUserReadable(value)
  17840. ? value + ''
  17841. : '-'
  17842. : '-'
  17843. } // By default.
  17844. var numericResult = numericToNumber(value)
  17845. return isNumberUserReadable(numericResult)
  17846. ? addCommas(numericResult)
  17847. : isStringSafe(value)
  17848. ? stringToUserReadable(value)
  17849. : typeof value === 'boolean'
  17850. ? value + ''
  17851. : '-'
  17852. }
  17853. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
  17854. var wrapVar = function wrapVar(varName, seriesIdx) {
  17855. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}'
  17856. }
  17857. /**
  17858. * Template formatter
  17859. * @param {Array.<Object>|Object} paramsList
  17860. */ function formatTpl(tpl, paramsList, encode) {
  17861. if (!isArray(paramsList)) {
  17862. paramsList = [paramsList]
  17863. }
  17864. var seriesLen = paramsList.length
  17865. if (!seriesLen) {
  17866. return ''
  17867. }
  17868. var $vars = paramsList[0].$vars || []
  17869. for (var i = 0; i < $vars.length; i++) {
  17870. var alias = TPL_VAR_ALIAS[i]
  17871. tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0))
  17872. }
  17873. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  17874. for (var k = 0; k < $vars.length; k++) {
  17875. var val = paramsList[seriesIdx][$vars[k]]
  17876. tpl = tpl.replace(
  17877. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  17878. encode ? encodeHTML(val) : val
  17879. )
  17880. }
  17881. }
  17882. return tpl
  17883. }
  17884. function getTooltipMarker(inOpt, extraCssText) {
  17885. var opt = isString(inOpt)
  17886. ? { color: inOpt, extraCssText: extraCssText }
  17887. : inOpt || {}
  17888. var color = opt.color
  17889. var type = opt.type
  17890. extraCssText = opt.extraCssText
  17891. var renderMode = opt.renderMode || 'html'
  17892. if (!color) {
  17893. return ''
  17894. }
  17895. if (renderMode === 'html') {
  17896. return type === 'subItem'
  17897. ? '<span style="display:inline-block;vertical-align:middle;margin-right:8px;margin-left:3px;' +
  17898. 'border-radius:4px;width:4px;height:4px;background-color:' + // Only support string
  17899. encodeHTML(color) +
  17900. ';' +
  17901. (extraCssText || '') +
  17902. '"></span>'
  17903. : '<span style="display:inline-block;margin-right:4px;' +
  17904. 'border-radius:10px;width:10px;height:10px;background-color:' +
  17905. encodeHTML(color) +
  17906. ';' +
  17907. (extraCssText || '') +
  17908. '"></span>'
  17909. } else {
  17910. // Should better not to auto generate style name by auto-increment number here.
  17911. // Because this util is usually called in tooltip formatter, which is probably
  17912. // called repeatly when mouse move and the auto-increment number increases fast.
  17913. // Users can make their own style name by theirselves, make it unique and readable.
  17914. var markerId = opt.markerId || 'markerX'
  17915. return {
  17916. renderMode: renderMode,
  17917. content: '{' + markerId + '|} ',
  17918. style:
  17919. type === 'subItem'
  17920. ? {
  17921. width: 4,
  17922. height: 4,
  17923. borderRadius: 2,
  17924. backgroundColor: color
  17925. }
  17926. : {
  17927. width: 10,
  17928. height: 10,
  17929. borderRadius: 5,
  17930. backgroundColor: color
  17931. }
  17932. }
  17933. }
  17934. }
  17935. /**
  17936. * @return Never be null/undefined.
  17937. */ function convertToColorString(color, defaultColor) {
  17938. defaultColor = defaultColor || 'transparent'
  17939. return isString(color)
  17940. ? color
  17941. : isObject$2(color)
  17942. ? (color.colorStops && (color.colorStops[0] || {}).color) ||
  17943. defaultColor
  17944. : defaultColor
  17945. }
  17946. /**
  17947. * open new tab
  17948. * @param link url
  17949. * @param target blank or self
  17950. */ function windowOpen(link, target) {
  17951. /* global window */ if (target === '_blank' || target === 'blank') {
  17952. var blank = window.open()
  17953. blank.opener = null
  17954. blank.location.href = link
  17955. } else {
  17956. window.open(link, target)
  17957. }
  17958. }
  17959. var each$6 = each$7
  17960. /**
  17961. * @public
  17962. */ var LOCATION_PARAMS = [
  17963. 'left',
  17964. 'right',
  17965. 'top',
  17966. 'bottom',
  17967. 'width',
  17968. 'height'
  17969. ]
  17970. /**
  17971. * @public
  17972. */ var HV_NAMES = [
  17973. ['width', 'left', 'right'],
  17974. ['height', 'top', 'bottom']
  17975. ]
  17976. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  17977. var x = 0
  17978. var y = 0
  17979. if (maxWidth == null) {
  17980. maxWidth = Infinity
  17981. }
  17982. if (maxHeight == null) {
  17983. maxHeight = Infinity
  17984. }
  17985. var currentLineMaxSize = 0
  17986. group.eachChild(function (child, idx) {
  17987. var rect = child.getBoundingRect()
  17988. var nextChild = group.childAt(idx + 1)
  17989. var nextChildRect = nextChild && nextChild.getBoundingRect()
  17990. var nextX
  17991. var nextY
  17992. if (orient === 'horizontal') {
  17993. var moveX =
  17994. rect.width + (nextChildRect ? -nextChildRect.x + rect.x : 0)
  17995. nextX = x + moveX // Wrap when width exceeds maxWidth or meet a `newline` group
  17996. // FIXME compare before adding gap?
  17997. if (nextX > maxWidth || child.newline) {
  17998. x = 0
  17999. nextX = moveX
  18000. y += currentLineMaxSize + gap
  18001. currentLineMaxSize = rect.height
  18002. } else {
  18003. // FIXME: consider rect.y is not `0`?
  18004. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height)
  18005. }
  18006. } else {
  18007. var moveY =
  18008. rect.height + (nextChildRect ? -nextChildRect.y + rect.y : 0)
  18009. nextY = y + moveY // Wrap when width exceeds maxHeight or meet a `newline` group
  18010. if (nextY > maxHeight || child.newline) {
  18011. x += currentLineMaxSize + gap
  18012. y = 0
  18013. nextY = moveY
  18014. currentLineMaxSize = rect.width
  18015. } else {
  18016. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width)
  18017. }
  18018. }
  18019. if (child.newline) {
  18020. return
  18021. }
  18022. child.x = x
  18023. child.y = y
  18024. child.markRedraw()
  18025. orient === 'horizontal' ? (x = nextX + gap) : (y = nextY + gap)
  18026. })
  18027. }
  18028. /**
  18029. * VBox or HBox layouting
  18030. * @param {string} orient
  18031. * @param {module:zrender/graphic/Group} group
  18032. * @param {number} gap
  18033. * @param {number} [width=Infinity]
  18034. * @param {number} [height=Infinity]
  18035. */ var box = boxLayout
  18036. /**
  18037. * VBox layouting
  18038. * @param {module:zrender/graphic/Group} group
  18039. * @param {number} gap
  18040. * @param {number} [width=Infinity]
  18041. * @param {number} [height=Infinity]
  18042. */ curry$1(boxLayout, 'vertical')
  18043. /**
  18044. * HBox layouting
  18045. * @param {module:zrender/graphic/Group} group
  18046. * @param {number} gap
  18047. * @param {number} [width=Infinity]
  18048. * @param {number} [height=Infinity]
  18049. */ curry$1(boxLayout, 'horizontal')
  18050. /**
  18051. * Parse position info.
  18052. */ function getLayoutRect(positionInfo, containerRect, margin) {
  18053. margin = normalizeCssArray(margin || 0)
  18054. var containerWidth = containerRect.width
  18055. var containerHeight = containerRect.height
  18056. var left = parsePercent(positionInfo.left, containerWidth)
  18057. var top = parsePercent(positionInfo.top, containerHeight)
  18058. var right = parsePercent(positionInfo.right, containerWidth)
  18059. var bottom = parsePercent(positionInfo.bottom, containerHeight)
  18060. var width = parsePercent(positionInfo.width, containerWidth)
  18061. var height = parsePercent(positionInfo.height, containerHeight)
  18062. var verticalMargin = margin[2] + margin[0]
  18063. var horizontalMargin = margin[1] + margin[3]
  18064. var aspect = positionInfo.aspect // If width is not specified, calculate width from left and right
  18065. if (isNaN(width)) {
  18066. width = containerWidth - right - horizontalMargin - left
  18067. }
  18068. if (isNaN(height)) {
  18069. height = containerHeight - bottom - verticalMargin - top
  18070. }
  18071. if (aspect != null) {
  18072. // If width and height are not given
  18073. // 1. Graph should not exceeds the container
  18074. // 2. Aspect must be keeped
  18075. // 3. Graph should take the space as more as possible
  18076. // FIXME
  18077. // Margin is not considered, because there is no case that both
  18078. // using margin and aspect so far.
  18079. if (isNaN(width) && isNaN(height)) {
  18080. if (aspect > containerWidth / containerHeight) {
  18081. width = containerWidth * 0.8
  18082. } else {
  18083. height = containerHeight * 0.8
  18084. }
  18085. } // Calculate width or height with given aspect
  18086. if (isNaN(width)) {
  18087. width = aspect * height
  18088. }
  18089. if (isNaN(height)) {
  18090. height = width / aspect
  18091. }
  18092. } // If left is not specified, calculate left from right and width
  18093. if (isNaN(left)) {
  18094. left = containerWidth - right - width - horizontalMargin
  18095. }
  18096. if (isNaN(top)) {
  18097. top = containerHeight - bottom - height - verticalMargin
  18098. } // Align left and top
  18099. switch (positionInfo.left || positionInfo.right) {
  18100. case 'center':
  18101. left = containerWidth / 2 - width / 2 - margin[3]
  18102. break
  18103. case 'right':
  18104. left = containerWidth - width - horizontalMargin
  18105. break
  18106. }
  18107. switch (positionInfo.top || positionInfo.bottom) {
  18108. case 'middle':
  18109. case 'center':
  18110. top = containerHeight / 2 - height / 2 - margin[0]
  18111. break
  18112. case 'bottom':
  18113. top = containerHeight - height - verticalMargin
  18114. break
  18115. } // If something is wrong and left, top, width, height are calculated as NaN
  18116. left = left || 0
  18117. top = top || 0
  18118. if (isNaN(width)) {
  18119. // Width may be NaN if only one value is given except width
  18120. width = containerWidth - horizontalMargin - left - (right || 0)
  18121. }
  18122. if (isNaN(height)) {
  18123. // Height may be NaN if only one value is given except height
  18124. height = containerHeight - verticalMargin - top - (bottom || 0)
  18125. }
  18126. var rect = new BoundingRect$1(
  18127. left + margin[3],
  18128. top + margin[0],
  18129. width,
  18130. height
  18131. )
  18132. rect.margin = margin
  18133. return rect
  18134. }
  18135. /**
  18136. * Position a zr element in viewport
  18137. * Group position is specified by either
  18138. * {left, top}, {right, bottom}
  18139. * If all properties exists, right and bottom will be igonred.
  18140. *
  18141. * Logic:
  18142. * 1. Scale (against origin point in parent coord)
  18143. * 2. Rotate (against origin point in parent coord)
  18144. * 3. Traslate (with el.position by this method)
  18145. * So this method only fixes the last step 'Traslate', which does not affect
  18146. * scaling and rotating.
  18147. *
  18148. * If be called repeatly with the same input el, the same result will be gotten.
  18149. *
  18150. * Return true if the layout happend.
  18151. *
  18152. * @param el Should have `getBoundingRect` method.
  18153. * @param positionInfo
  18154. * @param positionInfo.left
  18155. * @param positionInfo.top
  18156. * @param positionInfo.right
  18157. * @param positionInfo.bottom
  18158. * @param positionInfo.width Only for opt.boundingModel: 'raw'
  18159. * @param positionInfo.height Only for opt.boundingModel: 'raw'
  18160. * @param containerRect
  18161. * @param margin
  18162. * @param opt
  18163. * @param opt.hv Only horizontal or only vertical. Default to be [1, 1]
  18164. * @param opt.boundingMode
  18165. * Specify how to calculate boundingRect when locating.
  18166. * 'all': Position the boundingRect that is transformed and uioned
  18167. * both itself and its descendants.
  18168. * This mode simplies confine the elements in the bounding
  18169. * of their container (e.g., using 'right: 0').
  18170. * 'raw': Position the boundingRect that is not transformed and only itself.
  18171. * This mode is useful when you want a element can overflow its
  18172. * container. (Consider a rotated circle needs to be located in a corner.)
  18173. * In this mode positionInfo.width/height can only be number.
  18174. */ function positionElement(
  18175. el,
  18176. positionInfo,
  18177. containerRect,
  18178. margin,
  18179. opt,
  18180. out
  18181. ) {
  18182. var h = !opt || !opt.hv || opt.hv[0]
  18183. var v = !opt || !opt.hv || opt.hv[1]
  18184. var boundingMode = (opt && opt.boundingMode) || 'all'
  18185. out = out || el
  18186. out.x = el.x
  18187. out.y = el.y
  18188. if (!h && !v) {
  18189. return false
  18190. }
  18191. var rect
  18192. if (boundingMode === 'raw') {
  18193. rect =
  18194. el.type === 'group'
  18195. ? new BoundingRect$1(
  18196. 0,
  18197. 0,
  18198. +positionInfo.width || 0,
  18199. +positionInfo.height || 0
  18200. )
  18201. : el.getBoundingRect()
  18202. } else {
  18203. rect = el.getBoundingRect()
  18204. if (el.needLocalTransform()) {
  18205. var transform = el.getLocalTransform() // Notice: raw rect may be inner object of el,
  18206. // which should not be modified.
  18207. rect = rect.clone()
  18208. rect.applyTransform(transform)
  18209. }
  18210. } // The real width and height can not be specified but calculated by the given el.
  18211. var layoutRect = getLayoutRect(
  18212. defaults(
  18213. { width: rect.width, height: rect.height },
  18214. positionInfo
  18215. ),
  18216. containerRect,
  18217. margin
  18218. ) // Because 'tranlate' is the last step in transform
  18219. // (see zrender/core/Transformable#getLocalTransform),
  18220. // we can just only modify el.position to get final result.
  18221. var dx = h ? layoutRect.x - rect.x : 0
  18222. var dy = v ? layoutRect.y - rect.y : 0
  18223. if (boundingMode === 'raw') {
  18224. out.x = dx
  18225. out.y = dy
  18226. } else {
  18227. out.x += dx
  18228. out.y += dy
  18229. }
  18230. if (out === el) {
  18231. el.markRedraw()
  18232. }
  18233. return true
  18234. }
  18235. function fetchLayoutMode(ins) {
  18236. var layoutMode = ins.layoutMode || ins.constructor.layoutMode
  18237. return isObject$2(layoutMode)
  18238. ? layoutMode
  18239. : layoutMode
  18240. ? { type: layoutMode }
  18241. : null
  18242. }
  18243. /**
  18244. * Consider Case:
  18245. * When default option has {left: 0, width: 100}, and we set {right: 0}
  18246. * through setOption or media query, using normal zrUtil.merge will cause
  18247. * {right: 0} does not take effect.
  18248. *
  18249. * @example
  18250. * ComponentModel.extend({
  18251. * init: function () {
  18252. * ...
  18253. * let inputPositionParams = layout.getLayoutParams(option);
  18254. * this.mergeOption(inputPositionParams);
  18255. * },
  18256. * mergeOption: function (newOption) {
  18257. * newOption && zrUtil.merge(thisOption, newOption, true);
  18258. * layout.mergeLayoutParam(thisOption, newOption);
  18259. * }
  18260. * });
  18261. *
  18262. * @param targetOption
  18263. * @param newOption
  18264. * @param opt
  18265. */ function mergeLayoutParam(targetOption, newOption, opt) {
  18266. var ignoreSize = opt && opt.ignoreSize
  18267. !isArray(ignoreSize) && (ignoreSize = [ignoreSize, ignoreSize])
  18268. var hResult = merge(HV_NAMES[0], 0)
  18269. var vResult = merge(HV_NAMES[1], 1)
  18270. copy(HV_NAMES[0], targetOption, hResult)
  18271. copy(HV_NAMES[1], targetOption, vResult)
  18272. function merge(names, hvIdx) {
  18273. var newParams = {}
  18274. var newValueCount = 0
  18275. var merged = {}
  18276. var mergedValueCount = 0
  18277. var enoughParamNumber = 2
  18278. each$6(names, function (name) {
  18279. merged[name] = targetOption[name]
  18280. })
  18281. each$6(names, function (name) {
  18282. // Consider case: newOption.width is null, which is
  18283. // set by user for removing width setting.
  18284. hasProp(newOption, name) &&
  18285. (newParams[name] = merged[name] = newOption[name])
  18286. hasValue(newParams, name) && newValueCount++
  18287. hasValue(merged, name) && mergedValueCount++
  18288. })
  18289. if (ignoreSize[hvIdx]) {
  18290. // Only one of left/right is premitted to exist.
  18291. if (hasValue(newOption, names[1])) {
  18292. merged[names[2]] = null
  18293. } else if (hasValue(newOption, names[2])) {
  18294. merged[names[1]] = null
  18295. }
  18296. return merged
  18297. } // Case: newOption: {width: ..., right: ...},
  18298. // or targetOption: {right: ...} and newOption: {width: ...},
  18299. // There is no conflict when merged only has params count
  18300. // little than enoughParamNumber.
  18301. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  18302. return merged
  18303. } // Case: newOption: {width: ..., right: ...},
  18304. // Than we can make sure user only want those two, and ignore
  18305. // all origin params in targetOption.
  18306. else if (newValueCount >= enoughParamNumber) {
  18307. return newParams
  18308. } else {
  18309. // Chose another param from targetOption by priority.
  18310. for (var i = 0; i < names.length; i++) {
  18311. var name_1 = names[i]
  18312. if (
  18313. !hasProp(newParams, name_1) &&
  18314. hasProp(targetOption, name_1)
  18315. ) {
  18316. newParams[name_1] = targetOption[name_1]
  18317. break
  18318. }
  18319. }
  18320. return newParams
  18321. }
  18322. }
  18323. function hasProp(obj, name) {
  18324. return obj.hasOwnProperty(name)
  18325. }
  18326. function hasValue(obj, name) {
  18327. return obj[name] != null && obj[name] !== 'auto'
  18328. }
  18329. function copy(names, target, source) {
  18330. each$6(names, function (name) {
  18331. target[name] = source[name]
  18332. })
  18333. }
  18334. }
  18335. /**
  18336. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  18337. */ function getLayoutParams(source) {
  18338. return copyLayoutParams({}, source)
  18339. }
  18340. /**
  18341. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  18342. * @param {Object} source
  18343. * @return {Object} Result contains those props.
  18344. */ function copyLayoutParams(target, source) {
  18345. source &&
  18346. target &&
  18347. each$6(LOCATION_PARAMS, function (name) {
  18348. source.hasOwnProperty(name) && (target[name] = source[name])
  18349. })
  18350. return target
  18351. }
  18352. var inner$b = makeInner()
  18353. var ComponentModel = /** @class */ (function (_super) {
  18354. __extends(ComponentModel, _super)
  18355. function ComponentModel(option, parentModel, ecModel) {
  18356. var _this =
  18357. _super.call(this, option, parentModel, ecModel) || this
  18358. _this.uid = getUID('ec_cpt_model')
  18359. return _this
  18360. }
  18361. ComponentModel.prototype.init = function (
  18362. option,
  18363. parentModel,
  18364. ecModel
  18365. ) {
  18366. this.mergeDefaultAndTheme(option, ecModel)
  18367. }
  18368. ComponentModel.prototype.mergeDefaultAndTheme = function (
  18369. option,
  18370. ecModel
  18371. ) {
  18372. var layoutMode = fetchLayoutMode(this)
  18373. var inputPositionParams = layoutMode
  18374. ? getLayoutParams(option)
  18375. : {}
  18376. var themeModel = ecModel.getTheme()
  18377. merge(option, themeModel.get(this.mainType))
  18378. merge(option, this.getDefaultOption())
  18379. if (layoutMode) {
  18380. mergeLayoutParam(option, inputPositionParams, layoutMode)
  18381. }
  18382. }
  18383. ComponentModel.prototype.mergeOption = function (option, ecModel) {
  18384. merge(this.option, option, true)
  18385. var layoutMode = fetchLayoutMode(this)
  18386. if (layoutMode) {
  18387. mergeLayoutParam(this.option, option, layoutMode)
  18388. }
  18389. }
  18390. /**
  18391. * Called immediately after `init` or `mergeOption` of this instance called.
  18392. */ ComponentModel.prototype.optionUpdated = function (
  18393. newCptOption,
  18394. isInit
  18395. ) {}
  18396. /**
  18397. * [How to declare defaultOption]:
  18398. *
  18399. * (A) If using class declaration in typescript (since echarts 5):
  18400. * ```ts
  18401. * import {ComponentOption} from '../model/option.js';
  18402. * export interface XxxOption extends ComponentOption {
  18403. * aaa: number
  18404. * }
  18405. * export class XxxModel extends Component {
  18406. * static type = 'xxx';
  18407. * static defaultOption: XxxOption = {
  18408. * aaa: 123
  18409. * }
  18410. * }
  18411. * Component.registerClass(XxxModel);
  18412. * ```
  18413. * ```ts
  18414. * import {inheritDefaultOption} from '../util/component.js';
  18415. * import {XxxModel, XxxOption} from './XxxModel.js';
  18416. * export interface XxxSubOption extends XxxOption {
  18417. * bbb: number
  18418. * }
  18419. * class XxxSubModel extends XxxModel {
  18420. * static defaultOption: XxxSubOption = inheritDefaultOption(XxxModel.defaultOption, {
  18421. * bbb: 456
  18422. * })
  18423. * fn() {
  18424. * let opt = this.getDefaultOption();
  18425. * // opt is {aaa: 123, bbb: 456}
  18426. * }
  18427. * }
  18428. * ```
  18429. *
  18430. * (B) If using class extend (previous approach in echarts 3 & 4):
  18431. * ```js
  18432. * let XxxComponent = Component.extend({
  18433. * defaultOption: {
  18434. * xx: 123
  18435. * }
  18436. * })
  18437. * ```
  18438. * ```js
  18439. * let XxxSubComponent = XxxComponent.extend({
  18440. * defaultOption: {
  18441. * yy: 456
  18442. * },
  18443. * fn: function () {
  18444. * let opt = this.getDefaultOption();
  18445. * // opt is {xx: 123, yy: 456}
  18446. * }
  18447. * })
  18448. * ```
  18449. */ ComponentModel.prototype.getDefaultOption = function () {
  18450. var ctor = this.constructor // If using class declaration, it is different to travel super class
  18451. // in legacy env and auto merge defaultOption. So if using class
  18452. // declaration, defaultOption should be merged manually.
  18453. if (!isExtendedClass(ctor)) {
  18454. // When using ts class, defaultOption must be declared as static.
  18455. return ctor.defaultOption
  18456. } // FIXME: remove this approach?
  18457. var fields = inner$b(this)
  18458. if (!fields.defaultOption) {
  18459. var optList = []
  18460. var clz = ctor
  18461. while (clz) {
  18462. var opt = clz.prototype.defaultOption
  18463. opt && optList.push(opt)
  18464. clz = clz.superClass
  18465. }
  18466. var defaultOption = {}
  18467. for (var i = optList.length - 1; i >= 0; i--) {
  18468. defaultOption = merge(defaultOption, optList[i], true)
  18469. }
  18470. fields.defaultOption = defaultOption
  18471. }
  18472. return fields.defaultOption
  18473. }
  18474. /**
  18475. * Notice: always force to input param `useDefault` in case that forget to consider it.
  18476. * The same behavior as `modelUtil.parseFinder`.
  18477. *
  18478. * @param useDefault In many cases like series refer axis and axis refer grid,
  18479. * If axis index / axis id not specified, use the first target as default.
  18480. * In other cases like dataZoom refer axis, if not specified, measn no refer.
  18481. */ ComponentModel.prototype.getReferringComponents = function (
  18482. mainType,
  18483. opt
  18484. ) {
  18485. var indexKey = mainType + 'Index'
  18486. var idKey = mainType + 'Id'
  18487. return queryReferringComponents(
  18488. this.ecModel,
  18489. mainType,
  18490. { index: this.get(indexKey, true), id: this.get(idKey, true) },
  18491. opt
  18492. )
  18493. }
  18494. ComponentModel.prototype.getBoxLayoutParams = function () {
  18495. // Consider itself having box layout configs.
  18496. var boxLayoutModel = this
  18497. return {
  18498. left: boxLayoutModel.get('left'),
  18499. top: boxLayoutModel.get('top'),
  18500. right: boxLayoutModel.get('right'),
  18501. bottom: boxLayoutModel.get('bottom'),
  18502. width: boxLayoutModel.get('width'),
  18503. height: boxLayoutModel.get('height')
  18504. }
  18505. }
  18506. /**
  18507. * Get key for zlevel.
  18508. * If developers don't configure zlevel. We will assign zlevel to series based on the key.
  18509. * For example, lines with trail effect and progressive series will in an individual zlevel.
  18510. */ ComponentModel.prototype.getZLevelKey = function () {
  18511. return ''
  18512. }
  18513. ComponentModel.prototype.setZLevel = function (zlevel) {
  18514. this.option.zlevel = zlevel
  18515. }
  18516. ComponentModel.protoInitialize = (function () {
  18517. var proto = ComponentModel.prototype
  18518. proto.type = 'component'
  18519. proto.id = ''
  18520. proto.name = ''
  18521. proto.mainType = ''
  18522. proto.subType = ''
  18523. proto.componentIndex = 0
  18524. })()
  18525. return ComponentModel
  18526. })(Model$1)
  18527. mountExtend(ComponentModel, Model$1)
  18528. enableClassManagement(ComponentModel)
  18529. enableSubTypeDefaulter(ComponentModel)
  18530. enableTopologicalTravel(ComponentModel, getDependencies)
  18531. function getDependencies(componentType) {
  18532. var deps = []
  18533. each$7(
  18534. ComponentModel.getClassesByMainType(componentType),
  18535. function (clz) {
  18536. deps = deps.concat(
  18537. clz.dependencies || clz.prototype.dependencies || []
  18538. )
  18539. }
  18540. ) // Ensure main type.
  18541. deps = map$1(deps, function (type) {
  18542. return parseClassType(type).main
  18543. }) // Hack dataset for convenience.
  18544. if (componentType !== 'dataset' && indexOf(deps, 'dataset') <= 0) {
  18545. deps.unshift('dataset')
  18546. }
  18547. return deps
  18548. }
  18549. var ComponentModel$1 = ComponentModel
  18550. /*
  18551. * Licensed to the Apache Software Foundation (ASF) under one
  18552. * or more contributor license agreements. See the NOTICE file
  18553. * distributed with this work for additional information
  18554. * regarding copyright ownership. The ASF licenses this file
  18555. * to you under the Apache License, Version 2.0 (the
  18556. * "License"); you may not use this file except in compliance
  18557. * with the License. You may obtain a copy of the License at
  18558. *
  18559. * http://www.apache.org/licenses/LICENSE-2.0
  18560. *
  18561. * Unless required by applicable law or agreed to in writing,
  18562. * software distributed under the License is distributed on an
  18563. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18564. * KIND, either express or implied. See the License for the
  18565. * specific language governing permissions and limitations
  18566. * under the License.
  18567. */ /**
  18568. * AUTO-GENERATED FILE. DO NOT MODIFY.
  18569. */ /*
  18570. * Licensed to the Apache Software Foundation (ASF) under one
  18571. * or more contributor license agreements. See the NOTICE file
  18572. * distributed with this work for additional information
  18573. * regarding copyright ownership. The ASF licenses this file
  18574. * to you under the Apache License, Version 2.0 (the
  18575. * "License"); you may not use this file except in compliance
  18576. * with the License. You may obtain a copy of the License at
  18577. *
  18578. * http://www.apache.org/licenses/LICENSE-2.0
  18579. *
  18580. * Unless required by applicable law or agreed to in writing,
  18581. * software distributed under the License is distributed on an
  18582. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  18583. * KIND, either express or implied. See the License for the
  18584. * specific language governing permissions and limitations
  18585. * under the License.
  18586. */ var platform = '' // Navigator not exists in node
  18587. if (typeof navigator !== 'undefined') {
  18588. /* global navigator */ platform = navigator.platform || ''
  18589. }
  18590. var decalColor = 'rgba(0, 0, 0, 0.2)'
  18591. var globalDefault = {
  18592. darkMode: 'auto', // backgroundColor: 'rgba(0,0,0,0)',
  18593. colorBy: 'series',
  18594. color: [
  18595. '#5470c6',
  18596. '#91cc75',
  18597. '#fac858',
  18598. '#ee6666',
  18599. '#73c0de',
  18600. '#3ba272',
  18601. '#fc8452',
  18602. '#9a60b4',
  18603. '#ea7ccc'
  18604. ],
  18605. gradientColor: ['#f6efa6', '#d88273', '#bf444c'],
  18606. aria: {
  18607. decal: {
  18608. decals: [
  18609. {
  18610. color: decalColor,
  18611. dashArrayX: [1, 0],
  18612. dashArrayY: [2, 5],
  18613. symbolSize: 1,
  18614. rotation: Math.PI / 6
  18615. },
  18616. {
  18617. color: decalColor,
  18618. symbol: 'circle',
  18619. dashArrayX: [
  18620. [8, 8],
  18621. [0, 8, 8, 0]
  18622. ],
  18623. dashArrayY: [6, 0],
  18624. symbolSize: 0.8
  18625. },
  18626. {
  18627. color: decalColor,
  18628. dashArrayX: [1, 0],
  18629. dashArrayY: [4, 3],
  18630. rotation: -Math.PI / 4
  18631. },
  18632. {
  18633. color: decalColor,
  18634. dashArrayX: [
  18635. [6, 6],
  18636. [0, 6, 6, 0]
  18637. ],
  18638. dashArrayY: [6, 0]
  18639. },
  18640. {
  18641. color: decalColor,
  18642. dashArrayX: [
  18643. [1, 0],
  18644. [1, 6]
  18645. ],
  18646. dashArrayY: [1, 0, 6, 0],
  18647. rotation: Math.PI / 4
  18648. },
  18649. {
  18650. color: decalColor,
  18651. symbol: 'triangle',
  18652. dashArrayX: [
  18653. [9, 9],
  18654. [0, 9, 9, 0]
  18655. ],
  18656. dashArrayY: [7, 2],
  18657. symbolSize: 0.75
  18658. }
  18659. ]
  18660. }
  18661. }, // If xAxis and yAxis declared, grid is created by default.
  18662. // grid: {},
  18663. textStyle: {
  18664. // color: '#000',
  18665. // decoration: 'none',
  18666. // PENDING
  18667. fontFamily: platform.match(/^Win/)
  18668. ? 'Microsoft YaHei'
  18669. : 'sans-serif', // fontFamily: 'Arial, Verdana, sans-serif',
  18670. fontSize: 12,
  18671. fontStyle: 'normal',
  18672. fontWeight: 'normal'
  18673. }, // http://blogs.adobe.com/webplatform/2014/02/24/using-blend-modes-in-html-canvas/
  18674. // https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  18675. // Default is source-over
  18676. blendMode: null,
  18677. stateAnimation: { duration: 300, easing: 'cubicOut' },
  18678. animation: 'auto',
  18679. animationDuration: 1000,
  18680. animationDurationUpdate: 500,
  18681. animationEasing: 'cubicInOut',
  18682. animationEasingUpdate: 'cubicInOut',
  18683. animationThreshold: 2000, // Configuration for progressive/incremental rendering
  18684. progressiveThreshold: 3000,
  18685. progressive: 400, // Threshold of if use single hover layer to optimize.
  18686. // It is recommended that `hoverLayerThreshold` is equivalent to or less than
  18687. // `progressiveThreshold`, otherwise hover will cause restart of progressive,
  18688. // which is unexpected.
  18689. // see example <echarts/test/heatmap-large.html>.
  18690. hoverLayerThreshold: 3000, // See: module:echarts/scale/Time
  18691. useUTC: false
  18692. }
  18693. var VISUAL_DIMENSIONS = createHashMap([
  18694. 'tooltip',
  18695. 'label',
  18696. 'itemName',
  18697. 'itemId',
  18698. 'itemGroupId',
  18699. 'seriesName'
  18700. ])
  18701. var SOURCE_FORMAT_ORIGINAL = 'original'
  18702. var SOURCE_FORMAT_ARRAY_ROWS = 'arrayRows'
  18703. var SOURCE_FORMAT_OBJECT_ROWS = 'objectRows'
  18704. var SOURCE_FORMAT_KEYED_COLUMNS = 'keyedColumns'
  18705. var SOURCE_FORMAT_TYPED_ARRAY = 'typedArray'
  18706. var SOURCE_FORMAT_UNKNOWN = 'unknown'
  18707. var SERIES_LAYOUT_BY_COLUMN = 'column'
  18708. var SERIES_LAYOUT_BY_ROW = 'row'
  18709. var BE_ORDINAL = {
  18710. Must: 1,
  18711. Might: 2,
  18712. Not: 3 // Other cases
  18713. }
  18714. var innerGlobalModel = makeInner()
  18715. /**
  18716. * MUST be called before mergeOption of all series.
  18717. */ function resetSourceDefaulter(ecModel) {
  18718. // `datasetMap` is used to make default encode.
  18719. innerGlobalModel(ecModel).datasetMap = createHashMap()
  18720. }
  18721. /**
  18722. * [The strategy of the arrengment of data dimensions for dataset]:
  18723. * "value way": all axes are non-category axes. So series one by one take
  18724. * several (the number is coordSysDims.length) dimensions from dataset.
  18725. * The result of data arrengment of data dimensions like:
  18726. * | ser0_x | ser0_y | ser1_x | ser1_y | ser2_x | ser2_y |
  18727. * "category way": at least one axis is category axis. So the the first data
  18728. * dimension is always mapped to the first category axis and shared by
  18729. * all of the series. The other data dimensions are taken by series like
  18730. * "value way" does.
  18731. * The result of data arrengment of data dimensions like:
  18732. * | ser_shared_x | ser0_y | ser1_y | ser2_y |
  18733. *
  18734. * @return encode Never be `null/undefined`.
  18735. */ function makeSeriesEncodeForAxisCoordSys(
  18736. coordDimensions,
  18737. seriesModel,
  18738. source
  18739. ) {
  18740. var encode = {}
  18741. var datasetModel = querySeriesUpstreamDatasetModel(seriesModel) // Currently only make default when using dataset, util more reqirements occur.
  18742. if (!datasetModel || !coordDimensions) {
  18743. return encode
  18744. }
  18745. var encodeItemName = []
  18746. var encodeSeriesName = []
  18747. var ecModel = seriesModel.ecModel
  18748. var datasetMap = innerGlobalModel(ecModel).datasetMap
  18749. var key = datasetModel.uid + '_' + source.seriesLayoutBy
  18750. var baseCategoryDimIndex
  18751. var categoryWayValueDimStart
  18752. coordDimensions = coordDimensions.slice()
  18753. each$7(coordDimensions, function (coordDimInfoLoose, coordDimIdx) {
  18754. var coordDimInfo = isObject$2(coordDimInfoLoose)
  18755. ? coordDimInfoLoose
  18756. : (coordDimensions[coordDimIdx] = { name: coordDimInfoLoose })
  18757. if (
  18758. coordDimInfo.type === 'ordinal' &&
  18759. baseCategoryDimIndex == null
  18760. ) {
  18761. baseCategoryDimIndex = coordDimIdx
  18762. categoryWayValueDimStart =
  18763. getDataDimCountOnCoordDim(coordDimInfo)
  18764. }
  18765. encode[coordDimInfo.name] = []
  18766. })
  18767. var datasetRecord =
  18768. datasetMap.get(key) ||
  18769. datasetMap.set(key, {
  18770. categoryWayDim: categoryWayValueDimStart,
  18771. valueWayDim: 0
  18772. }) // TODO
  18773. // Auto detect first time axis and do arrangement.
  18774. each$7(coordDimensions, function (coordDimInfo, coordDimIdx) {
  18775. var coordDimName = coordDimInfo.name
  18776. var count = getDataDimCountOnCoordDim(coordDimInfo) // In value way.
  18777. if (baseCategoryDimIndex == null) {
  18778. var start = datasetRecord.valueWayDim
  18779. pushDim(encode[coordDimName], start, count)
  18780. pushDim(encodeSeriesName, start, count)
  18781. datasetRecord.valueWayDim += count // ??? TODO give a better default series name rule?
  18782. // especially when encode x y specified.
  18783. // consider: when mutiple series share one dimension
  18784. // category axis, series name should better use
  18785. // the other dimsion name. On the other hand, use
  18786. // both dimensions name.
  18787. } // In category way, the first category axis.
  18788. else if (baseCategoryDimIndex === coordDimIdx) {
  18789. pushDim(encode[coordDimName], 0, count)
  18790. pushDim(encodeItemName, 0, count)
  18791. } // In category way, the other axis.
  18792. else {
  18793. var start = datasetRecord.categoryWayDim
  18794. pushDim(encode[coordDimName], start, count)
  18795. pushDim(encodeSeriesName, start, count)
  18796. datasetRecord.categoryWayDim += count
  18797. }
  18798. })
  18799. function pushDim(dimIdxArr, idxFrom, idxCount) {
  18800. for (var i = 0; i < idxCount; i++) {
  18801. dimIdxArr.push(idxFrom + i)
  18802. }
  18803. }
  18804. function getDataDimCountOnCoordDim(coordDimInfo) {
  18805. var dimsDef = coordDimInfo.dimsDef
  18806. return dimsDef ? dimsDef.length : 1
  18807. }
  18808. encodeItemName.length && (encode.itemName = encodeItemName)
  18809. encodeSeriesName.length && (encode.seriesName = encodeSeriesName)
  18810. return encode
  18811. }
  18812. /**
  18813. * Work for data like [{name: ..., value: ...}, ...].
  18814. *
  18815. * @return encode Never be `null/undefined`.
  18816. */ function makeSeriesEncodeForNameBased(
  18817. seriesModel,
  18818. source,
  18819. dimCount
  18820. ) {
  18821. var encode = {}
  18822. var datasetModel = querySeriesUpstreamDatasetModel(seriesModel) // Currently only make default when using dataset, util more reqirements occur.
  18823. if (!datasetModel) {
  18824. return encode
  18825. }
  18826. var sourceFormat = source.sourceFormat
  18827. var dimensionsDefine = source.dimensionsDefine
  18828. var potentialNameDimIndex
  18829. if (
  18830. sourceFormat === SOURCE_FORMAT_OBJECT_ROWS ||
  18831. sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS
  18832. ) {
  18833. each$7(dimensionsDefine, function (dim, idx) {
  18834. if ((isObject$2(dim) ? dim.name : dim) === 'name') {
  18835. potentialNameDimIndex = idx
  18836. }
  18837. })
  18838. }
  18839. var idxResult = (function () {
  18840. var idxRes0 = {}
  18841. var idxRes1 = {}
  18842. var guessRecords = [] // 5 is an experience value.
  18843. for (var i = 0, len = Math.min(5, dimCount); i < len; i++) {
  18844. var guessResult = doGuessOrdinal(
  18845. source.data,
  18846. sourceFormat,
  18847. source.seriesLayoutBy,
  18848. dimensionsDefine,
  18849. source.startIndex,
  18850. i
  18851. )
  18852. guessRecords.push(guessResult)
  18853. var isPureNumber = guessResult === BE_ORDINAL.Not // [Strategy of idxRes0]: find the first BE_ORDINAL.Not as the value dim,
  18854. // and then find a name dim with the priority:
  18855. // "BE_ORDINAL.Might|BE_ORDINAL.Must" > "other dim" > "the value dim itself".
  18856. if (
  18857. isPureNumber &&
  18858. idxRes0.v == null &&
  18859. i !== potentialNameDimIndex
  18860. ) {
  18861. idxRes0.v = i
  18862. }
  18863. if (
  18864. idxRes0.n == null ||
  18865. idxRes0.n === idxRes0.v ||
  18866. (!isPureNumber && guessRecords[idxRes0.n] === BE_ORDINAL.Not)
  18867. ) {
  18868. idxRes0.n = i
  18869. }
  18870. if (
  18871. fulfilled(idxRes0) &&
  18872. guessRecords[idxRes0.n] !== BE_ORDINAL.Not
  18873. ) {
  18874. return idxRes0
  18875. } // [Strategy of idxRes1]: if idxRes0 not satisfied (that is, no BE_ORDINAL.Not),
  18876. // find the first BE_ORDINAL.Might as the value dim,
  18877. // and then find a name dim with the priority:
  18878. // "other dim" > "the value dim itself".
  18879. // That is for backward compat: number-like (e.g., `'3'`, `'55'`) can be
  18880. // treated as number.
  18881. if (!isPureNumber) {
  18882. if (
  18883. guessResult === BE_ORDINAL.Might &&
  18884. idxRes1.v == null &&
  18885. i !== potentialNameDimIndex
  18886. ) {
  18887. idxRes1.v = i
  18888. }
  18889. if (idxRes1.n == null || idxRes1.n === idxRes1.v) {
  18890. idxRes1.n = i
  18891. }
  18892. }
  18893. }
  18894. function fulfilled(idxResult) {
  18895. return idxResult.v != null && idxResult.n != null
  18896. }
  18897. return fulfilled(idxRes0)
  18898. ? idxRes0
  18899. : fulfilled(idxRes1)
  18900. ? idxRes1
  18901. : null
  18902. })()
  18903. if (idxResult) {
  18904. encode.value = [idxResult.v] // `potentialNameDimIndex` has highest priority.
  18905. var nameDimIndex =
  18906. potentialNameDimIndex != null
  18907. ? potentialNameDimIndex
  18908. : idxResult.n // By default, label use itemName in charts.
  18909. // So we dont set encodeLabel here.
  18910. encode.itemName = [nameDimIndex]
  18911. encode.seriesName = [nameDimIndex]
  18912. }
  18913. return encode
  18914. }
  18915. /**
  18916. * @return If return null/undefined, indicate that should not use datasetModel.
  18917. */ function querySeriesUpstreamDatasetModel(seriesModel) {
  18918. // Caution: consider the scenario:
  18919. // A dataset is declared and a series is not expected to use the dataset,
  18920. // and at the beginning `setOption({series: { noData })` (just prepare other
  18921. // option but no data), then `setOption({series: {data: [...]}); In this case,
  18922. // the user should set an empty array to avoid that dataset is used by default.
  18923. var thisData = seriesModel.get('data', true)
  18924. if (!thisData) {
  18925. return queryReferringComponents(
  18926. seriesModel.ecModel,
  18927. 'dataset',
  18928. {
  18929. index: seriesModel.get('datasetIndex', true),
  18930. id: seriesModel.get('datasetId', true)
  18931. },
  18932. SINGLE_REFERRING
  18933. ).models[0]
  18934. }
  18935. }
  18936. /**
  18937. * @return Always return an array event empty.
  18938. */ function queryDatasetUpstreamDatasetModels(datasetModel) {
  18939. // Only these attributes declared, we by defualt reference to `datasetIndex: 0`.
  18940. // Otherwise, no reference.
  18941. if (
  18942. !datasetModel.get('transform', true) &&
  18943. !datasetModel.get('fromTransformResult', true)
  18944. ) {
  18945. return []
  18946. }
  18947. return queryReferringComponents(
  18948. datasetModel.ecModel,
  18949. 'dataset',
  18950. {
  18951. index: datasetModel.get('fromDatasetIndex', true),
  18952. id: datasetModel.get('fromDatasetId', true)
  18953. },
  18954. SINGLE_REFERRING
  18955. ).models
  18956. }
  18957. /**
  18958. * The rule should not be complex, otherwise user might not
  18959. * be able to known where the data is wrong.
  18960. * The code is ugly, but how to make it neat?
  18961. */ function guessOrdinal(source, dimIndex) {
  18962. return doGuessOrdinal(
  18963. source.data,
  18964. source.sourceFormat,
  18965. source.seriesLayoutBy,
  18966. source.dimensionsDefine,
  18967. source.startIndex,
  18968. dimIndex
  18969. )
  18970. } // dimIndex may be overflow source data.
  18971. // return {BE_ORDINAL}
  18972. function doGuessOrdinal(
  18973. data,
  18974. sourceFormat,
  18975. seriesLayoutBy,
  18976. dimensionsDefine,
  18977. startIndex,
  18978. dimIndex
  18979. ) {
  18980. var result // Experience value.
  18981. var maxLoop = 5
  18982. if (isTypedArray(data)) {
  18983. return BE_ORDINAL.Not
  18984. } // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
  18985. // always exists in source.
  18986. var dimName
  18987. var dimType
  18988. if (dimensionsDefine) {
  18989. var dimDefItem = dimensionsDefine[dimIndex]
  18990. if (isObject$2(dimDefItem)) {
  18991. dimName = dimDefItem.name
  18992. dimType = dimDefItem.type
  18993. } else if (isString(dimDefItem)) {
  18994. dimName = dimDefItem
  18995. }
  18996. }
  18997. if (dimType != null) {
  18998. return dimType === 'ordinal' ? BE_ORDINAL.Must : BE_ORDINAL.Not
  18999. }
  19000. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  19001. var dataArrayRows = data
  19002. if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
  19003. var sample = dataArrayRows[dimIndex]
  19004. for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
  19005. if ((result = detectValue(sample[startIndex + i])) != null) {
  19006. return result
  19007. }
  19008. }
  19009. } else {
  19010. for (var i = 0; i < dataArrayRows.length && i < maxLoop; i++) {
  19011. var row = dataArrayRows[startIndex + i]
  19012. if (row && (result = detectValue(row[dimIndex])) != null) {
  19013. return result
  19014. }
  19015. }
  19016. }
  19017. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  19018. var dataObjectRows = data
  19019. if (!dimName) {
  19020. return BE_ORDINAL.Not
  19021. }
  19022. for (var i = 0; i < dataObjectRows.length && i < maxLoop; i++) {
  19023. var item = dataObjectRows[i]
  19024. if (item && (result = detectValue(item[dimName])) != null) {
  19025. return result
  19026. }
  19027. }
  19028. } else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  19029. var dataKeyedColumns = data
  19030. if (!dimName) {
  19031. return BE_ORDINAL.Not
  19032. }
  19033. var sample = dataKeyedColumns[dimName]
  19034. if (!sample || isTypedArray(sample)) {
  19035. return BE_ORDINAL.Not
  19036. }
  19037. for (var i = 0; i < sample.length && i < maxLoop; i++) {
  19038. if ((result = detectValue(sample[i])) != null) {
  19039. return result
  19040. }
  19041. }
  19042. } else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  19043. var dataOriginal = data
  19044. for (var i = 0; i < dataOriginal.length && i < maxLoop; i++) {
  19045. var item = dataOriginal[i]
  19046. var val = getDataItemValue(item)
  19047. if (!isArray(val)) {
  19048. return BE_ORDINAL.Not
  19049. }
  19050. if ((result = detectValue(val[dimIndex])) != null) {
  19051. return result
  19052. }
  19053. }
  19054. }
  19055. function detectValue(val) {
  19056. var beStr = isString(val) // Consider usage convenience, '1', '2' will be treated as "number".
  19057. // `isFinit('')` get `true`.
  19058. if (val != null && isFinite(val) && val !== '') {
  19059. return beStr ? BE_ORDINAL.Might : BE_ORDINAL.Not
  19060. } else if (beStr && val !== '-') {
  19061. return BE_ORDINAL.Must
  19062. }
  19063. }
  19064. return BE_ORDINAL.Not
  19065. }
  19066. var internalOptionCreatorMap = createHashMap()
  19067. function registerInternalOptionCreator(mainType, creator) {
  19068. assert(internalOptionCreatorMap.get(mainType) == null && creator)
  19069. internalOptionCreatorMap.set(mainType, creator)
  19070. }
  19071. function concatInternalOptions(ecModel, mainType, newCmptOptionList) {
  19072. var internalOptionCreator = internalOptionCreatorMap.get(mainType)
  19073. if (!internalOptionCreator) {
  19074. return newCmptOptionList
  19075. }
  19076. var internalOptions = internalOptionCreator(ecModel)
  19077. if (!internalOptions) {
  19078. return newCmptOptionList
  19079. }
  19080. return newCmptOptionList.concat(internalOptions)
  19081. }
  19082. var innerColor = makeInner()
  19083. makeInner()
  19084. var PaletteMixin = /** @class */ (function () {
  19085. function PaletteMixin() {}
  19086. PaletteMixin.prototype.getColorFromPalette = function (
  19087. name,
  19088. scope,
  19089. requestNum
  19090. ) {
  19091. var defaultPalette = normalizeToArray(this.get('color', true))
  19092. var layeredPalette = this.get('colorLayer', true)
  19093. return getFromPalette(
  19094. this,
  19095. innerColor,
  19096. defaultPalette,
  19097. layeredPalette,
  19098. name,
  19099. scope,
  19100. requestNum
  19101. )
  19102. }
  19103. PaletteMixin.prototype.clearColorPalette = function () {
  19104. clearPalette(this, innerColor)
  19105. }
  19106. return PaletteMixin
  19107. })()
  19108. function getNearestPalette(palettes, requestColorNum) {
  19109. var paletteNum = palettes.length // TODO palettes must be in order
  19110. for (var i = 0; i < paletteNum; i++) {
  19111. if (palettes[i].length > requestColorNum) {
  19112. return palettes[i]
  19113. }
  19114. }
  19115. return palettes[paletteNum - 1]
  19116. }
  19117. /**
  19118. * @param name MUST NOT be null/undefined. Otherwise call this function
  19119. * twise with the same parameters will get different result.
  19120. * @param scope default this.
  19121. * @return Can be null/undefined
  19122. */ function getFromPalette(
  19123. that,
  19124. inner,
  19125. defaultPalette,
  19126. layeredPalette,
  19127. name,
  19128. scope,
  19129. requestNum
  19130. ) {
  19131. scope = scope || that
  19132. var scopeFields = inner(scope)
  19133. var paletteIdx = scopeFields.paletteIdx || 0
  19134. var paletteNameMap = (scopeFields.paletteNameMap =
  19135. scopeFields.paletteNameMap || {}) // Use `hasOwnProperty` to avoid conflict with Object.prototype.
  19136. if (paletteNameMap.hasOwnProperty(name)) {
  19137. return paletteNameMap[name]
  19138. }
  19139. var palette =
  19140. requestNum == null || !layeredPalette
  19141. ? defaultPalette
  19142. : getNearestPalette(layeredPalette, requestNum) // In case can't find in layered color palette.
  19143. palette = palette || defaultPalette
  19144. if (!palette || !palette.length) {
  19145. return
  19146. }
  19147. var pickedPaletteItem = palette[paletteIdx]
  19148. if (name) {
  19149. paletteNameMap[name] = pickedPaletteItem
  19150. }
  19151. scopeFields.paletteIdx = (paletteIdx + 1) % palette.length
  19152. return pickedPaletteItem
  19153. }
  19154. function clearPalette(that, inner) {
  19155. inner(that).paletteIdx = 0
  19156. inner(that).paletteNameMap = {}
  19157. } // Internal method names:
  19158. // -----------------------
  19159. var reCreateSeriesIndices
  19160. var assertSeriesInitialized
  19161. var initBase
  19162. var OPTION_INNER_KEY = '\0_ec_inner'
  19163. var OPTION_INNER_VALUE = 1
  19164. var GlobalModel = /** @class */ (function (_super) {
  19165. __extends(GlobalModel, _super)
  19166. function GlobalModel() {
  19167. return (_super !== null && _super.apply(this, arguments)) || this
  19168. }
  19169. GlobalModel.prototype.init = function (
  19170. option,
  19171. parentModel,
  19172. ecModel,
  19173. theme,
  19174. locale,
  19175. optionManager
  19176. ) {
  19177. theme = theme || {}
  19178. this.option = null // Mark as not initialized.
  19179. this._theme = new Model$1(theme)
  19180. this._locale = new Model$1(locale)
  19181. this._optionManager = optionManager
  19182. }
  19183. GlobalModel.prototype.setOption = function (
  19184. option,
  19185. opts,
  19186. optionPreprocessorFuncs
  19187. ) {
  19188. var innerOpt = normalizeSetOptionInput(opts)
  19189. this._optionManager.setOption(
  19190. option,
  19191. optionPreprocessorFuncs,
  19192. innerOpt
  19193. )
  19194. this._resetOption(null, innerOpt)
  19195. }
  19196. /**
  19197. * @param type null/undefined: reset all.
  19198. * 'recreate': force recreate all.
  19199. * 'timeline': only reset timeline option
  19200. * 'media': only reset media query option
  19201. * @return Whether option changed.
  19202. */ GlobalModel.prototype.resetOption = function (type, opt) {
  19203. return this._resetOption(type, normalizeSetOptionInput(opt))
  19204. }
  19205. GlobalModel.prototype._resetOption = function (type, opt) {
  19206. var optionChanged = false
  19207. var optionManager = this._optionManager
  19208. if (!type || type === 'recreate') {
  19209. var baseOption = optionManager.mountOption(type === 'recreate')
  19210. if (!this.option || type === 'recreate') {
  19211. initBase(this, baseOption)
  19212. } else {
  19213. this.restoreData()
  19214. this._mergeOption(baseOption, opt)
  19215. }
  19216. optionChanged = true
  19217. }
  19218. if (type === 'timeline' || type === 'media') {
  19219. this.restoreData()
  19220. } // By design, if `setOption(option2)` at the second time, and `option2` is a `ECUnitOption`,
  19221. // it should better not have the same props with `MediaUnit['option']`.
  19222. // Becuase either `option2` or `MediaUnit['option']` will be always merged to "current option"
  19223. // rather than original "baseOption". If they both override a prop, the result might be
  19224. // unexpected when media state changed after `setOption` called.
  19225. // If we really need to modify a props in each `MediaUnit['option']`, use the full version
  19226. // (`{baseOption, media}`) in `setOption`.
  19227. // For `timeline`, the case is the same.
  19228. if (!type || type === 'recreate' || type === 'timeline') {
  19229. var timelineOption = optionManager.getTimelineOption(this)
  19230. if (timelineOption) {
  19231. optionChanged = true
  19232. this._mergeOption(timelineOption, opt)
  19233. }
  19234. }
  19235. if (!type || type === 'recreate' || type === 'media') {
  19236. var mediaOptions = optionManager.getMediaOption(this)
  19237. if (mediaOptions.length) {
  19238. each$7(
  19239. mediaOptions,
  19240. function (mediaOption) {
  19241. optionChanged = true
  19242. this._mergeOption(mediaOption, opt)
  19243. },
  19244. this
  19245. )
  19246. }
  19247. }
  19248. return optionChanged
  19249. }
  19250. GlobalModel.prototype.mergeOption = function (option) {
  19251. this._mergeOption(option, null)
  19252. }
  19253. GlobalModel.prototype._mergeOption = function (newOption, opt) {
  19254. var option = this.option
  19255. var componentsMap = this._componentsMap
  19256. var componentsCount = this._componentsCount
  19257. var newCmptTypes = []
  19258. var newCmptTypeMap = createHashMap()
  19259. var replaceMergeMainTypeMap = opt && opt.replaceMergeMainTypeMap
  19260. resetSourceDefaulter(this) // If no component class, merge directly.
  19261. // For example: color, animaiton options, etc.
  19262. each$7(newOption, function (componentOption, mainType) {
  19263. if (componentOption == null) {
  19264. return
  19265. }
  19266. if (!ComponentModel$1.hasClass(mainType)) {
  19267. // globalSettingTask.dirty();
  19268. option[mainType] =
  19269. option[mainType] == null
  19270. ? clone$3(componentOption)
  19271. : merge(option[mainType], componentOption, true)
  19272. } else if (mainType) {
  19273. newCmptTypes.push(mainType)
  19274. newCmptTypeMap.set(mainType, true)
  19275. }
  19276. })
  19277. if (replaceMergeMainTypeMap) {
  19278. // If there is a mainType `xxx` in `replaceMerge` but not declared in option,
  19279. // we trade it as it is declared in option as `{xxx: []}`. Because:
  19280. // (1) for normal merge, `{xxx: null/undefined}` are the same meaning as `{xxx: []}`.
  19281. // (2) some preprocessor may convert some of `{xxx: null/undefined}` to `{xxx: []}`.
  19282. replaceMergeMainTypeMap.each(function (
  19283. val,
  19284. mainTypeInReplaceMerge
  19285. ) {
  19286. if (
  19287. ComponentModel$1.hasClass(mainTypeInReplaceMerge) &&
  19288. !newCmptTypeMap.get(mainTypeInReplaceMerge)
  19289. ) {
  19290. newCmptTypes.push(mainTypeInReplaceMerge)
  19291. newCmptTypeMap.set(mainTypeInReplaceMerge, true)
  19292. }
  19293. })
  19294. }
  19295. ComponentModel$1.topologicalTravel(
  19296. newCmptTypes,
  19297. ComponentModel$1.getAllClassMainTypes(),
  19298. visitComponent,
  19299. this
  19300. )
  19301. function visitComponent(mainType) {
  19302. var newCmptOptionList = concatInternalOptions(
  19303. this,
  19304. mainType,
  19305. normalizeToArray(newOption[mainType])
  19306. )
  19307. var oldCmptList = componentsMap.get(mainType)
  19308. var mergeMode = !oldCmptList // `!oldCmptList` means init. See the comment in `mappingToExists`
  19309. ? 'replaceAll'
  19310. : replaceMergeMainTypeMap &&
  19311. replaceMergeMainTypeMap.get(mainType)
  19312. ? 'replaceMerge'
  19313. : 'normalMerge'
  19314. var mappingResult = mappingToExists(
  19315. oldCmptList,
  19316. newCmptOptionList,
  19317. mergeMode
  19318. ) // Set mainType and complete subType.
  19319. setComponentTypeToKeyInfo(
  19320. mappingResult,
  19321. mainType,
  19322. ComponentModel$1
  19323. ) // Empty it before the travel, in order to prevent `this._componentsMap`
  19324. // from being used in the `init`/`mergeOption`/`optionUpdated` of some
  19325. // components, which is probably incorrect logic.
  19326. option[mainType] = null
  19327. componentsMap.set(mainType, null)
  19328. componentsCount.set(mainType, 0)
  19329. var optionsByMainType = []
  19330. var cmptsByMainType = []
  19331. var cmptsCountByMainType = 0
  19332. var tooltipExists
  19333. each$7(
  19334. mappingResult,
  19335. function (resultItem, index) {
  19336. var componentModel = resultItem.existing
  19337. var newCmptOption = resultItem.newOption
  19338. if (!newCmptOption) {
  19339. if (componentModel) {
  19340. // Consider where is no new option and should be merged using {},
  19341. // see removeEdgeAndAdd in topologicalTravel and
  19342. // ComponentModel.getAllClassMainTypes.
  19343. componentModel.mergeOption({}, this)
  19344. componentModel.optionUpdated({}, false)
  19345. } // If no both `resultItem.exist` and `resultItem.option`,
  19346. // either it is in `replaceMerge` and not matched by any id,
  19347. // or it has been removed in previous `replaceMerge` and left a "hole" in this component index.
  19348. } else {
  19349. var isSeriesType = mainType === 'series'
  19350. var ComponentModelClass = ComponentModel$1.getClass(
  19351. mainType,
  19352. resultItem.keyInfo.subType,
  19353. !isSeriesType // Give a more detailed warn later if series don't exists
  19354. )
  19355. if (!ComponentModelClass) {
  19356. return
  19357. } // TODO Before multiple tooltips get supported, we do this check to avoid unexpected exception.
  19358. if (mainType === 'tooltip') {
  19359. if (tooltipExists) {
  19360. return
  19361. }
  19362. tooltipExists = true
  19363. }
  19364. if (
  19365. componentModel &&
  19366. componentModel.constructor === ComponentModelClass
  19367. ) {
  19368. componentModel.name = resultItem.keyInfo.name // componentModel.settingTask && componentModel.settingTask.dirty();
  19369. componentModel.mergeOption(newCmptOption, this)
  19370. componentModel.optionUpdated(newCmptOption, false)
  19371. } else {
  19372. // PENDING Global as parent ?
  19373. var extraOpt = extend(
  19374. { componentIndex: index },
  19375. resultItem.keyInfo
  19376. )
  19377. componentModel = new ComponentModelClass(
  19378. newCmptOption,
  19379. this,
  19380. this,
  19381. extraOpt
  19382. ) // Assign `keyInfo`
  19383. extend(componentModel, extraOpt)
  19384. if (resultItem.brandNew) {
  19385. componentModel.__requireNewView = true
  19386. }
  19387. componentModel.init(newCmptOption, this, this) // Call optionUpdated after init.
  19388. // newCmptOption has been used as componentModel.option
  19389. // and may be merged with theme and default, so pass null
  19390. // to avoid confusion.
  19391. componentModel.optionUpdated(null, true)
  19392. }
  19393. }
  19394. if (componentModel) {
  19395. optionsByMainType.push(componentModel.option)
  19396. cmptsByMainType.push(componentModel)
  19397. cmptsCountByMainType++
  19398. } else {
  19399. // Always do assign to avoid elided item in array.
  19400. optionsByMainType.push(void 0)
  19401. cmptsByMainType.push(void 0)
  19402. }
  19403. },
  19404. this
  19405. )
  19406. option[mainType] = optionsByMainType
  19407. componentsMap.set(mainType, cmptsByMainType)
  19408. componentsCount.set(mainType, cmptsCountByMainType) // Backup series for filtering.
  19409. if (mainType === 'series') {
  19410. reCreateSeriesIndices(this)
  19411. }
  19412. } // If no series declared, ensure `_seriesIndices` initialized.
  19413. if (!this._seriesIndices) {
  19414. reCreateSeriesIndices(this)
  19415. }
  19416. }
  19417. /**
  19418. * Get option for output (cloned option and inner info removed)
  19419. */ GlobalModel.prototype.getOption = function () {
  19420. var option = clone$3(this.option)
  19421. each$7(option, function (optInMainType, mainType) {
  19422. if (ComponentModel$1.hasClass(mainType)) {
  19423. var opts = normalizeToArray(optInMainType) // Inner cmpts need to be removed.
  19424. // Inner cmpts might not be at last since ec5.0, but still
  19425. // compatible for users: if inner cmpt at last, splice the returned array.
  19426. var realLen = opts.length
  19427. var metNonInner = false
  19428. for (var i = realLen - 1; i >= 0; i--) {
  19429. // Remove options with inner id.
  19430. if (opts[i] && !isComponentIdInternal(opts[i])) {
  19431. metNonInner = true
  19432. } else {
  19433. opts[i] = null
  19434. !metNonInner && realLen--
  19435. }
  19436. }
  19437. opts.length = realLen
  19438. option[mainType] = opts
  19439. }
  19440. })
  19441. delete option[OPTION_INNER_KEY]
  19442. return option
  19443. }
  19444. GlobalModel.prototype.getTheme = function () {
  19445. return this._theme
  19446. }
  19447. GlobalModel.prototype.getLocaleModel = function () {
  19448. return this._locale
  19449. }
  19450. GlobalModel.prototype.setUpdatePayload = function (payload) {
  19451. this._payload = payload
  19452. }
  19453. GlobalModel.prototype.getUpdatePayload = function () {
  19454. return this._payload
  19455. }
  19456. /**
  19457. * @param idx If not specified, return the first one.
  19458. */ GlobalModel.prototype.getComponent = function (mainType, idx) {
  19459. var list = this._componentsMap.get(mainType)
  19460. if (list) {
  19461. var cmpt = list[idx || 0]
  19462. if (cmpt) {
  19463. return cmpt
  19464. } else if (idx == null) {
  19465. for (var i = 0; i < list.length; i++) {
  19466. if (list[i]) {
  19467. return list[i]
  19468. }
  19469. }
  19470. }
  19471. }
  19472. }
  19473. /**
  19474. * @return Never be null/undefined.
  19475. */ GlobalModel.prototype.queryComponents = function (condition) {
  19476. var mainType = condition.mainType
  19477. if (!mainType) {
  19478. return []
  19479. }
  19480. var index = condition.index
  19481. var id = condition.id
  19482. var name = condition.name
  19483. var cmpts = this._componentsMap.get(mainType)
  19484. if (!cmpts || !cmpts.length) {
  19485. return []
  19486. }
  19487. var result
  19488. if (index != null) {
  19489. result = []
  19490. each$7(normalizeToArray(index), function (idx) {
  19491. cmpts[idx] && result.push(cmpts[idx])
  19492. })
  19493. } else if (id != null) {
  19494. result = queryByIdOrName('id', id, cmpts)
  19495. } else if (name != null) {
  19496. result = queryByIdOrName('name', name, cmpts)
  19497. } else {
  19498. // Return all non-empty components in that mainType
  19499. result = filter(cmpts, function (cmpt) {
  19500. return !!cmpt
  19501. })
  19502. }
  19503. return filterBySubType(result, condition)
  19504. }
  19505. /**
  19506. * The interface is different from queryComponents,
  19507. * which is convenient for inner usage.
  19508. *
  19509. * @usage
  19510. * let result = findComponents(
  19511. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  19512. * );
  19513. * let result = findComponents(
  19514. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  19515. * );
  19516. * let result = findComponents(
  19517. * {mainType: 'series',
  19518. * filter: function (model, index) {...}}
  19519. * );
  19520. * // result like [component0, componnet1, ...]
  19521. */ GlobalModel.prototype.findComponents = function (condition) {
  19522. var query = condition.query
  19523. var mainType = condition.mainType
  19524. var queryCond = getQueryCond(query)
  19525. var result = queryCond
  19526. ? this.queryComponents(queryCond) // Retrieve all non-empty components.
  19527. : filter(this._componentsMap.get(mainType), function (cmpt) {
  19528. return !!cmpt
  19529. })
  19530. return doFilter(filterBySubType(result, condition))
  19531. function getQueryCond(q) {
  19532. var indexAttr = mainType + 'Index'
  19533. var idAttr = mainType + 'Id'
  19534. var nameAttr = mainType + 'Name'
  19535. return q &&
  19536. (q[indexAttr] != null ||
  19537. q[idAttr] != null ||
  19538. q[nameAttr] != null)
  19539. ? {
  19540. mainType: mainType, // subType will be filtered finally.
  19541. index: q[indexAttr],
  19542. id: q[idAttr],
  19543. name: q[nameAttr]
  19544. }
  19545. : null
  19546. }
  19547. function doFilter(res) {
  19548. return condition.filter ? filter(res, condition.filter) : res
  19549. }
  19550. }
  19551. GlobalModel.prototype.eachComponent = function (
  19552. mainType,
  19553. cb,
  19554. context
  19555. ) {
  19556. var componentsMap = this._componentsMap
  19557. if (isFunction(mainType)) {
  19558. var ctxForAll_1 = cb
  19559. var cbForAll_1 = mainType
  19560. componentsMap.each(function (cmpts, componentType) {
  19561. for (var i = 0; cmpts && i < cmpts.length; i++) {
  19562. var cmpt = cmpts[i]
  19563. cmpt &&
  19564. cbForAll_1.call(
  19565. ctxForAll_1,
  19566. componentType,
  19567. cmpt,
  19568. cmpt.componentIndex
  19569. )
  19570. }
  19571. })
  19572. } else {
  19573. var cmpts = isString(mainType)
  19574. ? componentsMap.get(mainType)
  19575. : isObject$2(mainType)
  19576. ? this.findComponents(mainType)
  19577. : null
  19578. for (var i = 0; cmpts && i < cmpts.length; i++) {
  19579. var cmpt = cmpts[i]
  19580. cmpt && cb.call(context, cmpt, cmpt.componentIndex)
  19581. }
  19582. }
  19583. }
  19584. /**
  19585. * Get series list before filtered by name.
  19586. */ GlobalModel.prototype.getSeriesByName = function (name) {
  19587. var nameStr = convertOptionIdName(name, null)
  19588. return filter(
  19589. this._componentsMap.get('series'),
  19590. function (oneSeries) {
  19591. return (
  19592. !!oneSeries && nameStr != null && oneSeries.name === nameStr
  19593. )
  19594. }
  19595. )
  19596. }
  19597. /**
  19598. * Get series list before filtered by index.
  19599. */ GlobalModel.prototype.getSeriesByIndex = function (
  19600. seriesIndex
  19601. ) {
  19602. return this._componentsMap.get('series')[seriesIndex]
  19603. }
  19604. /**
  19605. * Get series list before filtered by type.
  19606. * FIXME: rename to getRawSeriesByType?
  19607. */ GlobalModel.prototype.getSeriesByType = function (subType) {
  19608. return filter(
  19609. this._componentsMap.get('series'),
  19610. function (oneSeries) {
  19611. return !!oneSeries && oneSeries.subType === subType
  19612. }
  19613. )
  19614. }
  19615. /**
  19616. * Get all series before filtered.
  19617. */ GlobalModel.prototype.getSeries = function () {
  19618. return filter(
  19619. this._componentsMap.get('series'),
  19620. function (oneSeries) {
  19621. return !!oneSeries
  19622. }
  19623. )
  19624. }
  19625. /**
  19626. * Count series before filtered.
  19627. */ GlobalModel.prototype.getSeriesCount = function () {
  19628. return this._componentsCount.get('series')
  19629. }
  19630. /**
  19631. * After filtering, series may be different
  19632. * frome raw series.
  19633. */ GlobalModel.prototype.eachSeries = function (cb, context) {
  19634. assertSeriesInitialized(this)
  19635. each$7(
  19636. this._seriesIndices,
  19637. function (rawSeriesIndex) {
  19638. var series = this._componentsMap.get('series')[rawSeriesIndex]
  19639. cb.call(context, series, rawSeriesIndex)
  19640. },
  19641. this
  19642. )
  19643. }
  19644. /**
  19645. * Iterate raw series before filtered.
  19646. *
  19647. * @param {Function} cb
  19648. * @param {*} context
  19649. */ GlobalModel.prototype.eachRawSeries = function (cb, context) {
  19650. each$7(this._componentsMap.get('series'), function (series) {
  19651. series && cb.call(context, series, series.componentIndex)
  19652. })
  19653. }
  19654. /**
  19655. * After filtering, series may be different.
  19656. * frome raw series.
  19657. */ GlobalModel.prototype.eachSeriesByType = function (
  19658. subType,
  19659. cb,
  19660. context
  19661. ) {
  19662. assertSeriesInitialized(this)
  19663. each$7(
  19664. this._seriesIndices,
  19665. function (rawSeriesIndex) {
  19666. var series = this._componentsMap.get('series')[rawSeriesIndex]
  19667. if (series.subType === subType) {
  19668. cb.call(context, series, rawSeriesIndex)
  19669. }
  19670. },
  19671. this
  19672. )
  19673. }
  19674. /**
  19675. * Iterate raw series before filtered of given type.
  19676. */ GlobalModel.prototype.eachRawSeriesByType = function (
  19677. subType,
  19678. cb,
  19679. context
  19680. ) {
  19681. return each$7(this.getSeriesByType(subType), cb, context)
  19682. }
  19683. GlobalModel.prototype.isSeriesFiltered = function (seriesModel) {
  19684. assertSeriesInitialized(this)
  19685. return (
  19686. this._seriesIndicesMap.get(seriesModel.componentIndex) == null
  19687. )
  19688. }
  19689. GlobalModel.prototype.getCurrentSeriesIndices = function () {
  19690. return (this._seriesIndices || []).slice()
  19691. }
  19692. GlobalModel.prototype.filterSeries = function (cb, context) {
  19693. assertSeriesInitialized(this)
  19694. var newSeriesIndices = []
  19695. each$7(
  19696. this._seriesIndices,
  19697. function (seriesRawIdx) {
  19698. var series = this._componentsMap.get('series')[seriesRawIdx]
  19699. cb.call(context, series, seriesRawIdx) &&
  19700. newSeriesIndices.push(seriesRawIdx)
  19701. },
  19702. this
  19703. )
  19704. this._seriesIndices = newSeriesIndices
  19705. this._seriesIndicesMap = createHashMap(newSeriesIndices)
  19706. }
  19707. GlobalModel.prototype.restoreData = function (payload) {
  19708. reCreateSeriesIndices(this)
  19709. var componentsMap = this._componentsMap
  19710. var componentTypes = []
  19711. componentsMap.each(function (components, componentType) {
  19712. if (ComponentModel$1.hasClass(componentType)) {
  19713. componentTypes.push(componentType)
  19714. }
  19715. })
  19716. ComponentModel$1.topologicalTravel(
  19717. componentTypes,
  19718. ComponentModel$1.getAllClassMainTypes(),
  19719. function (componentType) {
  19720. each$7(
  19721. componentsMap.get(componentType),
  19722. function (component) {
  19723. if (
  19724. component &&
  19725. (componentType !== 'series' ||
  19726. !isNotTargetSeries(component, payload))
  19727. ) {
  19728. component.restoreData()
  19729. }
  19730. }
  19731. )
  19732. }
  19733. )
  19734. }
  19735. GlobalModel.internalField = (function () {
  19736. reCreateSeriesIndices = function reCreateSeriesIndices(ecModel) {
  19737. var seriesIndices = (ecModel._seriesIndices = [])
  19738. each$7(ecModel._componentsMap.get('series'), function (series) {
  19739. // series may have been removed by `replaceMerge`.
  19740. series && seriesIndices.push(series.componentIndex)
  19741. })
  19742. ecModel._seriesIndicesMap = createHashMap(seriesIndices)
  19743. }
  19744. assertSeriesInitialized = function assertSeriesInitialized(
  19745. ecModel
  19746. ) {}
  19747. initBase = function initBase(ecModel, baseOption) {
  19748. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  19749. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  19750. ecModel.option = {}
  19751. ecModel.option[OPTION_INNER_KEY] = OPTION_INNER_VALUE // Init with series: [], in case of calling findSeries method
  19752. // before series initialized.
  19753. ecModel._componentsMap = createHashMap({ series: [] })
  19754. ecModel._componentsCount = createHashMap() // If user spefied `option.aria`, aria will be enable. This detection should be
  19755. // performed before theme and globalDefault merge.
  19756. var airaOption = baseOption.aria
  19757. if (isObject$2(airaOption) && airaOption.enabled == null) {
  19758. airaOption.enabled = true
  19759. }
  19760. mergeTheme(baseOption, ecModel._theme.option) // TODO Needs clone when merging to the unexisted property
  19761. merge(baseOption, globalDefault, false)
  19762. ecModel._mergeOption(baseOption, null)
  19763. }
  19764. })()
  19765. return GlobalModel
  19766. })(Model$1)
  19767. function isNotTargetSeries(seriesModel, payload) {
  19768. if (payload) {
  19769. var index = payload.seriesIndex
  19770. var id = payload.seriesId
  19771. var name_1 = payload.seriesName
  19772. return (
  19773. (index != null && seriesModel.componentIndex !== index) ||
  19774. (id != null && seriesModel.id !== id) ||
  19775. (name_1 != null && seriesModel.name !== name_1)
  19776. )
  19777. }
  19778. }
  19779. function mergeTheme(option, theme) {
  19780. // PENDING
  19781. // NOT use `colorLayer` in theme if option has `color`
  19782. var notMergeColorLayer = option.color && !option.colorLayer
  19783. each$7(theme, function (themeItem, name) {
  19784. if (name === 'colorLayer' && notMergeColorLayer) {
  19785. return
  19786. } // If it is component model mainType, the model handles that merge later.
  19787. // otherwise, merge them here.
  19788. if (!ComponentModel$1.hasClass(name)) {
  19789. if (_typeof(themeItem) === 'object') {
  19790. option[name] = !option[name]
  19791. ? clone$3(themeItem)
  19792. : merge(option[name], themeItem, false)
  19793. } else {
  19794. if (option[name] == null) {
  19795. option[name] = themeItem
  19796. }
  19797. }
  19798. }
  19799. })
  19800. }
  19801. function queryByIdOrName(attr, idOrName, cmpts) {
  19802. // Here is a break from echarts4: string and number are
  19803. // treated as equal.
  19804. if (isArray(idOrName)) {
  19805. var keyMap_1 = createHashMap()
  19806. each$7(idOrName, function (idOrNameItem) {
  19807. if (idOrNameItem != null) {
  19808. var idName = convertOptionIdName(idOrNameItem, null)
  19809. idName != null && keyMap_1.set(idOrNameItem, true)
  19810. }
  19811. })
  19812. return filter(cmpts, function (cmpt) {
  19813. return cmpt && keyMap_1.get(cmpt[attr])
  19814. })
  19815. } else {
  19816. var idName_1 = convertOptionIdName(idOrName, null)
  19817. return filter(cmpts, function (cmpt) {
  19818. return cmpt && idName_1 != null && cmpt[attr] === idName_1
  19819. })
  19820. }
  19821. }
  19822. function filterBySubType(components, condition) {
  19823. // Using hasOwnProperty for restrict. Consider
  19824. // subType is undefined in user payload.
  19825. return condition.hasOwnProperty('subType')
  19826. ? filter(components, function (cmpt) {
  19827. return cmpt && cmpt.subType === condition.subType
  19828. })
  19829. : components
  19830. }
  19831. function normalizeSetOptionInput(opts) {
  19832. var replaceMergeMainTypeMap = createHashMap()
  19833. opts &&
  19834. each$7(normalizeToArray(opts.replaceMerge), function (mainType) {
  19835. replaceMergeMainTypeMap.set(mainType, true)
  19836. })
  19837. return { replaceMergeMainTypeMap: replaceMergeMainTypeMap }
  19838. }
  19839. mixin(GlobalModel, PaletteMixin)
  19840. var GlobalModel$1 = GlobalModel
  19841. var availableMethods = [
  19842. 'getDom',
  19843. 'getZr',
  19844. 'getWidth',
  19845. 'getHeight',
  19846. 'getDevicePixelRatio',
  19847. 'dispatchAction',
  19848. 'isSSR',
  19849. 'isDisposed',
  19850. 'on',
  19851. 'off',
  19852. 'getDataURL',
  19853. 'getConnectedDataURL', // 'getModel',
  19854. 'getOption', // 'getViewOfComponentModel',
  19855. // 'getViewOfSeriesModel',
  19856. 'getId',
  19857. 'updateLabelLayout'
  19858. ]
  19859. var ExtensionAPI = /** @class */ (function () {
  19860. function ExtensionAPI(ecInstance) {
  19861. each$7(
  19862. availableMethods,
  19863. function (methodName) {
  19864. this[methodName] = bind$1(ecInstance[methodName], ecInstance)
  19865. },
  19866. this
  19867. )
  19868. }
  19869. return ExtensionAPI
  19870. })()
  19871. var ExtensionAPI$1 = ExtensionAPI
  19872. var coordinateSystemCreators = {}
  19873. var CoordinateSystemManager = /** @class */ (function () {
  19874. function CoordinateSystemManager() {
  19875. this._coordinateSystems = []
  19876. }
  19877. CoordinateSystemManager.prototype.create = function (ecModel, api) {
  19878. var coordinateSystems = []
  19879. each$7(coordinateSystemCreators, function (creater, type) {
  19880. var list = creater.create(ecModel, api)
  19881. coordinateSystems = coordinateSystems.concat(list || [])
  19882. })
  19883. this._coordinateSystems = coordinateSystems
  19884. }
  19885. CoordinateSystemManager.prototype.update = function (ecModel, api) {
  19886. each$7(this._coordinateSystems, function (coordSys) {
  19887. coordSys.update && coordSys.update(ecModel, api)
  19888. })
  19889. }
  19890. CoordinateSystemManager.prototype.getCoordinateSystems =
  19891. function () {
  19892. return this._coordinateSystems.slice()
  19893. }
  19894. CoordinateSystemManager.register = function (type, creator) {
  19895. coordinateSystemCreators[type] = creator
  19896. }
  19897. CoordinateSystemManager.get = function (type) {
  19898. return coordinateSystemCreators[type]
  19899. }
  19900. return CoordinateSystemManager
  19901. })()
  19902. var CoordinateSystem = CoordinateSystemManager
  19903. var QUERY_REG = /^(min|max)?(.+)$/ // Key: mainType
  19904. // type FakeComponentsMap = HashMap<(MappingExistingItem & { subType: string })[]>;
  19905. /**
  19906. * TERM EXPLANATIONS:
  19907. * See `ECOption` and `ECUnitOption` in `src/util/types.ts`.
  19908. */ var OptionManager = /** @class */ (function () {
  19909. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  19910. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  19911. // rawOption cloned and backuped when timeline changed, which does no
  19912. // good to performance. What's more, that both timeline and setOption
  19913. // method supply 'notMerge' brings complex and some problems.
  19914. // Consider this case:
  19915. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  19916. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  19917. function OptionManager(api) {
  19918. this._timelineOptions = []
  19919. this._mediaList = []
  19920. /**
  19921. * -1, means default.
  19922. * empty means no media.
  19923. */ this._currentMediaIndices = []
  19924. this._api = api
  19925. }
  19926. OptionManager.prototype.setOption = function (
  19927. rawOption,
  19928. optionPreprocessorFuncs,
  19929. opt
  19930. ) {
  19931. if (rawOption) {
  19932. // That set dat primitive is dangerous if user reuse the data when setOption again.
  19933. each$7(normalizeToArray(rawOption.series), function (series) {
  19934. series &&
  19935. series.data &&
  19936. isTypedArray(series.data) &&
  19937. setAsPrimitive(series.data)
  19938. })
  19939. each$7(normalizeToArray(rawOption.dataset), function (dataset) {
  19940. dataset &&
  19941. dataset.source &&
  19942. isTypedArray(dataset.source) &&
  19943. setAsPrimitive(dataset.source)
  19944. })
  19945. } // Caution: some series modify option data, if do not clone,
  19946. // it should ensure that the repeat modify correctly
  19947. // (create a new object when modify itself).
  19948. rawOption = clone$3(rawOption) // FIXME
  19949. // If some property is set in timeline options or media option but
  19950. // not set in baseOption, a warning should be given.
  19951. var optionBackup = this._optionBackup
  19952. var newParsedOption = parseRawOption(
  19953. rawOption,
  19954. optionPreprocessorFuncs,
  19955. !optionBackup
  19956. )
  19957. this._newBaseOption = newParsedOption.baseOption // For setOption at second time (using merge mode);
  19958. if (optionBackup) {
  19959. // FIXME
  19960. // the restore merge solution is essentially incorrect.
  19961. // the mapping can not be 100% consistent with ecModel, which probably brings
  19962. // potential bug!
  19963. // The first merge is delayed, becuase in most cases, users do not call `setOption` twice.
  19964. // let fakeCmptsMap = this._fakeCmptsMap;
  19965. // if (!fakeCmptsMap) {
  19966. // fakeCmptsMap = this._fakeCmptsMap = createHashMap();
  19967. // mergeToBackupOption(fakeCmptsMap, null, optionBackup.baseOption, null);
  19968. // }
  19969. // mergeToBackupOption(
  19970. // fakeCmptsMap, optionBackup.baseOption, newParsedOption.baseOption, opt
  19971. // );
  19972. // For simplicity, timeline options and media options do not support merge,
  19973. // that is, if you `setOption` twice and both has timeline options, the latter
  19974. // timeline opitons will not be merged to the formers, but just substitude them.
  19975. if (newParsedOption.timelineOptions.length) {
  19976. optionBackup.timelineOptions = newParsedOption.timelineOptions
  19977. }
  19978. if (newParsedOption.mediaList.length) {
  19979. optionBackup.mediaList = newParsedOption.mediaList
  19980. }
  19981. if (newParsedOption.mediaDefault) {
  19982. optionBackup.mediaDefault = newParsedOption.mediaDefault
  19983. }
  19984. } else {
  19985. this._optionBackup = newParsedOption
  19986. }
  19987. }
  19988. OptionManager.prototype.mountOption = function (isRecreate) {
  19989. var optionBackup = this._optionBackup
  19990. this._timelineOptions = optionBackup.timelineOptions
  19991. this._mediaList = optionBackup.mediaList
  19992. this._mediaDefault = optionBackup.mediaDefault
  19993. this._currentMediaIndices = []
  19994. return clone$3(
  19995. isRecreate // this._optionBackup.baseOption, which is created at the first `setOption`
  19996. ? // called, and is merged into every new option by inner method `mergeToBackupOption`
  19997. // each time `setOption` called, can be only used in `isRecreate`, because
  19998. // its reliability is under suspicion. In other cases option merge is
  19999. // performed by `model.mergeOption`.
  20000. optionBackup.baseOption
  20001. : this._newBaseOption
  20002. )
  20003. }
  20004. OptionManager.prototype.getTimelineOption = function (ecModel) {
  20005. var option
  20006. var timelineOptions = this._timelineOptions
  20007. if (timelineOptions.length) {
  20008. // getTimelineOption can only be called after ecModel inited,
  20009. // so we can get currentIndex from timelineModel.
  20010. var timelineModel = ecModel.getComponent('timeline')
  20011. if (timelineModel) {
  20012. option = clone$3(
  20013. // FIXME:TS as TimelineModel or quivlant interface
  20014. timelineOptions[timelineModel.getCurrentIndex()]
  20015. )
  20016. }
  20017. }
  20018. return option
  20019. }
  20020. OptionManager.prototype.getMediaOption = function (ecModel) {
  20021. var ecWidth = this._api.getWidth()
  20022. var ecHeight = this._api.getHeight()
  20023. var mediaList = this._mediaList
  20024. var mediaDefault = this._mediaDefault
  20025. var indices = []
  20026. var result = [] // No media defined.
  20027. if (!mediaList.length && !mediaDefault) {
  20028. return result
  20029. } // Multi media may be applied, the latter defined media has higher priority.
  20030. for (var i = 0, len = mediaList.length; i < len; i++) {
  20031. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  20032. indices.push(i)
  20033. }
  20034. } // FIXME
  20035. // Whether mediaDefault should force users to provide? Otherwise
  20036. // the change by media query can not be recorvered.
  20037. if (!indices.length && mediaDefault) {
  20038. indices = [-1]
  20039. }
  20040. if (
  20041. indices.length &&
  20042. !indicesEquals(indices, this._currentMediaIndices)
  20043. ) {
  20044. result = map$1(indices, function (index) {
  20045. return clone$3(
  20046. index === -1 ? mediaDefault.option : mediaList[index].option
  20047. )
  20048. })
  20049. } // Otherwise return nothing.
  20050. this._currentMediaIndices = indices
  20051. return result
  20052. }
  20053. return OptionManager
  20054. })()
  20055. /**
  20056. * [RAW_OPTION_PATTERNS]
  20057. * (Note: "series: []" represents all other props in `ECUnitOption`)
  20058. *
  20059. * (1) No prop "baseOption" declared:
  20060. * Root option is used as "baseOption" (except prop "options" and "media").
  20061. * ```js
  20062. * option = {
  20063. * series: [],
  20064. * timeline: {},
  20065. * options: [],
  20066. * };
  20067. * option = {
  20068. * series: [],
  20069. * media: {},
  20070. * };
  20071. * option = {
  20072. * series: [],
  20073. * timeline: {},
  20074. * options: [],
  20075. * media: {},
  20076. * }
  20077. * ```
  20078. *
  20079. * (2) Prop "baseOption" declared:
  20080. * If "baseOption" declared, `ECUnitOption` props can only be declared
  20081. * inside "baseOption" except prop "timeline" (compat ec2).
  20082. * ```js
  20083. * option = {
  20084. * baseOption: {
  20085. * timeline: {},
  20086. * series: [],
  20087. * },
  20088. * options: []
  20089. * };
  20090. * option = {
  20091. * baseOption: {
  20092. * series: [],
  20093. * },
  20094. * media: []
  20095. * };
  20096. * option = {
  20097. * baseOption: {
  20098. * timeline: {},
  20099. * series: [],
  20100. * },
  20101. * options: []
  20102. * media: []
  20103. * };
  20104. * option = {
  20105. * // ec3 compat ec2: allow (only) `timeline` declared
  20106. * // outside baseOption. Keep this setting for compat.
  20107. * timeline: {},
  20108. * baseOption: {
  20109. * series: [],
  20110. * },
  20111. * options: [],
  20112. * media: []
  20113. * };
  20114. * ```
  20115. */ function parseRawOption( // `rawOption` May be modified
  20116. rawOption,
  20117. optionPreprocessorFuncs,
  20118. isNew
  20119. ) {
  20120. var mediaList = []
  20121. var mediaDefault
  20122. var baseOption
  20123. var declaredBaseOption = rawOption.baseOption // Compatible with ec2, [RAW_OPTION_PATTERNS] above.
  20124. var timelineOnRoot = rawOption.timeline
  20125. var timelineOptionsOnRoot = rawOption.options
  20126. var mediaOnRoot = rawOption.media
  20127. var hasMedia = !!rawOption.media
  20128. var hasTimeline = !!(
  20129. timelineOptionsOnRoot ||
  20130. timelineOnRoot ||
  20131. (declaredBaseOption && declaredBaseOption.timeline)
  20132. )
  20133. if (declaredBaseOption) {
  20134. baseOption = declaredBaseOption // For merge option.
  20135. if (!baseOption.timeline) {
  20136. baseOption.timeline = timelineOnRoot
  20137. }
  20138. } // For convenience, enable to use the root option as the `baseOption`:
  20139. // `{ ...normalOptionProps, media: [{ ... }, { ... }] }`
  20140. else {
  20141. if (hasTimeline || hasMedia) {
  20142. rawOption.options = rawOption.media = null
  20143. }
  20144. baseOption = rawOption
  20145. }
  20146. if (hasMedia) {
  20147. if (isArray(mediaOnRoot)) {
  20148. each$7(mediaOnRoot, function (singleMedia) {
  20149. if (singleMedia && singleMedia.option) {
  20150. if (singleMedia.query) {
  20151. mediaList.push(singleMedia)
  20152. } else if (!mediaDefault) {
  20153. // Use the first media default.
  20154. mediaDefault = singleMedia
  20155. }
  20156. }
  20157. })
  20158. }
  20159. }
  20160. doPreprocess(baseOption)
  20161. each$7(timelineOptionsOnRoot, function (option) {
  20162. return doPreprocess(option)
  20163. })
  20164. each$7(mediaList, function (media) {
  20165. return doPreprocess(media.option)
  20166. })
  20167. function doPreprocess(option) {
  20168. each$7(optionPreprocessorFuncs, function (preProcess) {
  20169. preProcess(option, isNew)
  20170. })
  20171. }
  20172. return {
  20173. baseOption: baseOption,
  20174. timelineOptions: timelineOptionsOnRoot || [],
  20175. mediaDefault: mediaDefault,
  20176. mediaList: mediaList
  20177. }
  20178. }
  20179. /**
  20180. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  20181. * Support: width, height, aspectRatio
  20182. * Can use max or min as prefix.
  20183. */ function applyMediaQuery(query, ecWidth, ecHeight) {
  20184. var realMap = {
  20185. width: ecWidth,
  20186. height: ecHeight,
  20187. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  20188. }
  20189. var applicatable = true
  20190. each$7(query, function (value, attr) {
  20191. var matched = attr.match(QUERY_REG)
  20192. if (!matched || !matched[1] || !matched[2]) {
  20193. return
  20194. }
  20195. var operator = matched[1]
  20196. var realAttr = matched[2].toLowerCase()
  20197. if (!compare(realMap[realAttr], value, operator)) {
  20198. applicatable = false
  20199. }
  20200. })
  20201. return applicatable
  20202. }
  20203. function compare(real, expect, operator) {
  20204. if (operator === 'min') {
  20205. return real >= expect
  20206. } else if (operator === 'max') {
  20207. return real <= expect
  20208. } else {
  20209. // Equals
  20210. return real === expect
  20211. }
  20212. }
  20213. function indicesEquals(indices1, indices2) {
  20214. // indices is always order by asc and has only finite number.
  20215. return indices1.join(',') === indices2.join(',')
  20216. }
  20217. /**
  20218. * Consider case:
  20219. * `chart.setOption(opt1);`
  20220. * Then user do some interaction like dataZoom, dataView changing.
  20221. * `chart.setOption(opt2);`
  20222. * Then user press 'reset button' in toolbox.
  20223. *
  20224. * After doing that all of the interaction effects should be reset, the
  20225. * chart should be the same as the result of invoke
  20226. * `chart.setOption(opt1); chart.setOption(opt2);`.
  20227. *
  20228. * Although it is not able ensure that
  20229. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  20230. * `chart.setOption(merge(opt1, opt2));` exactly,
  20231. * this might be the only simple way to implement that feature.
  20232. *
  20233. * MEMO: We've considered some other approaches:
  20234. * 1. Each model handle its self restoration but not uniform treatment.
  20235. * (Too complex in logic and error-prone)
  20236. * 2. Use a shadow ecModel. (Performace expensive)
  20237. *
  20238. * FIXME: A possible solution:
  20239. * Add a extra level of model for each component model. The inheritance chain would be:
  20240. * ecModel <- componentModel <- componentActionModel <- dataItemModel
  20241. * And all of the actions can only modify the `componentActionModel` rather than
  20242. * `componentModel`. `setOption` will only modify the `ecModel` and `componentModel`.
  20243. * When "resotre" action triggered, model from `componentActionModel` will be discarded
  20244. * instead of recreating the "ecModel" from the "_optionBackup".
  20245. */ // function mergeToBackupOption(
  20246. // fakeCmptsMap: FakeComponentsMap,
  20247. // // `tarOption` Can be null/undefined, means init
  20248. // tarOption: ECUnitOption,
  20249. // newOption: ECUnitOption,
  20250. // // Can be null/undefined
  20251. // opt: InnerSetOptionOpts
  20252. // ): void {
  20253. // newOption = newOption || {} as ECUnitOption;
  20254. // const notInit = !!tarOption;
  20255. // each(newOption, function (newOptsInMainType, mainType) {
  20256. // if (newOptsInMainType == null) {
  20257. // return;
  20258. // }
  20259. // if (!ComponentModel.hasClass(mainType)) {
  20260. // if (tarOption) {
  20261. // tarOption[mainType] = merge(tarOption[mainType], newOptsInMainType, true);
  20262. // }
  20263. // }
  20264. // else {
  20265. // const oldTarOptsInMainType = notInit ? normalizeToArray(tarOption[mainType]) : null;
  20266. // const oldFakeCmptsInMainType = fakeCmptsMap.get(mainType) || [];
  20267. // const resultTarOptsInMainType = notInit ? (tarOption[mainType] = [] as ComponentOption[]) : null;
  20268. // const resultFakeCmptsInMainType = fakeCmptsMap.set(mainType, []);
  20269. // const mappingResult = mappingToExists(
  20270. // oldFakeCmptsInMainType,
  20271. // normalizeToArray(newOptsInMainType),
  20272. // (opt && opt.replaceMergeMainTypeMap.get(mainType)) ? 'replaceMerge' : 'normalMerge'
  20273. // );
  20274. // setComponentTypeToKeyInfo(mappingResult, mainType, ComponentModel as ComponentModelConstructor);
  20275. // each(mappingResult, function (resultItem, index) {
  20276. // // The same logic as `Global.ts#_mergeOption`.
  20277. // let fakeCmpt = resultItem.existing;
  20278. // const newOption = resultItem.newOption;
  20279. // const keyInfo = resultItem.keyInfo;
  20280. // let fakeCmptOpt;
  20281. // if (!newOption) {
  20282. // fakeCmptOpt = oldTarOptsInMainType[index];
  20283. // }
  20284. // else {
  20285. // if (fakeCmpt && fakeCmpt.subType === keyInfo.subType) {
  20286. // fakeCmpt.name = keyInfo.name;
  20287. // if (notInit) {
  20288. // fakeCmptOpt = merge(oldTarOptsInMainType[index], newOption, true);
  20289. // }
  20290. // }
  20291. // else {
  20292. // fakeCmpt = extend({}, keyInfo);
  20293. // if (notInit) {
  20294. // fakeCmptOpt = clone(newOption);
  20295. // }
  20296. // }
  20297. // }
  20298. // if (fakeCmpt) {
  20299. // notInit && resultTarOptsInMainType.push(fakeCmptOpt);
  20300. // resultFakeCmptsInMainType.push(fakeCmpt);
  20301. // }
  20302. // else {
  20303. // notInit && resultTarOptsInMainType.push(void 0);
  20304. // resultFakeCmptsInMainType.push(void 0);
  20305. // }
  20306. // });
  20307. // }
  20308. // });
  20309. // }
  20310. var OptionManager$1 = OptionManager
  20311. var each$5 = each$7
  20312. var isObject$1 = isObject$2
  20313. var POSSIBLE_STYLES = [
  20314. 'areaStyle',
  20315. 'lineStyle',
  20316. 'nodeStyle',
  20317. 'linkStyle',
  20318. 'chordStyle',
  20319. 'label',
  20320. 'labelLine'
  20321. ]
  20322. function compatEC2ItemStyle(opt) {
  20323. var itemStyleOpt = opt && opt.itemStyle
  20324. if (!itemStyleOpt) {
  20325. return
  20326. }
  20327. for (var i = 0, len = POSSIBLE_STYLES.length; i < len; i++) {
  20328. var styleName = POSSIBLE_STYLES[i]
  20329. var normalItemStyleOpt = itemStyleOpt.normal
  20330. var emphasisItemStyleOpt = itemStyleOpt.emphasis
  20331. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  20332. opt[styleName] = opt[styleName] || {}
  20333. if (!opt[styleName].normal) {
  20334. opt[styleName].normal = normalItemStyleOpt[styleName]
  20335. } else {
  20336. merge(opt[styleName].normal, normalItemStyleOpt[styleName])
  20337. }
  20338. normalItemStyleOpt[styleName] = null
  20339. }
  20340. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  20341. opt[styleName] = opt[styleName] || {}
  20342. if (!opt[styleName].emphasis) {
  20343. opt[styleName].emphasis = emphasisItemStyleOpt[styleName]
  20344. } else {
  20345. merge(
  20346. opt[styleName].emphasis,
  20347. emphasisItemStyleOpt[styleName]
  20348. )
  20349. }
  20350. emphasisItemStyleOpt[styleName] = null
  20351. }
  20352. }
  20353. }
  20354. function convertNormalEmphasis(opt, optType, useExtend) {
  20355. if (
  20356. opt &&
  20357. opt[optType] &&
  20358. (opt[optType].normal || opt[optType].emphasis)
  20359. ) {
  20360. var normalOpt = opt[optType].normal
  20361. var emphasisOpt = opt[optType].emphasis
  20362. if (normalOpt) {
  20363. if (useExtend) {
  20364. opt[optType].normal = opt[optType].emphasis = null
  20365. defaults(opt[optType], normalOpt)
  20366. } else {
  20367. opt[optType] = normalOpt
  20368. }
  20369. }
  20370. if (emphasisOpt) {
  20371. opt.emphasis = opt.emphasis || {}
  20372. opt.emphasis[optType] = emphasisOpt // Also compat the case user mix the style and focus together in ec3 style
  20373. // for example: { itemStyle: { normal: {}, emphasis: {focus, shadowBlur} } }
  20374. if (emphasisOpt.focus) {
  20375. opt.emphasis.focus = emphasisOpt.focus
  20376. }
  20377. if (emphasisOpt.blurScope) {
  20378. opt.emphasis.blurScope = emphasisOpt.blurScope
  20379. }
  20380. }
  20381. }
  20382. }
  20383. function removeEC3NormalStatus(opt) {
  20384. convertNormalEmphasis(opt, 'itemStyle')
  20385. convertNormalEmphasis(opt, 'lineStyle')
  20386. convertNormalEmphasis(opt, 'areaStyle')
  20387. convertNormalEmphasis(opt, 'label')
  20388. convertNormalEmphasis(opt, 'labelLine') // treemap
  20389. convertNormalEmphasis(opt, 'upperLabel') // graph
  20390. convertNormalEmphasis(opt, 'edgeLabel')
  20391. }
  20392. function compatTextStyle(opt, propName) {
  20393. // Check whether is not object (string\null\undefined ...)
  20394. var labelOptSingle = isObject$1(opt) && opt[propName]
  20395. var textStyle =
  20396. isObject$1(labelOptSingle) && labelOptSingle.textStyle
  20397. if (textStyle) {
  20398. for (var i = 0, len = TEXT_STYLE_OPTIONS.length; i < len; i++) {
  20399. var textPropName = TEXT_STYLE_OPTIONS[i]
  20400. if (textStyle.hasOwnProperty(textPropName)) {
  20401. labelOptSingle[textPropName] = textStyle[textPropName]
  20402. }
  20403. }
  20404. }
  20405. }
  20406. function compatEC3CommonStyles(opt) {
  20407. if (opt) {
  20408. removeEC3NormalStatus(opt)
  20409. compatTextStyle(opt, 'label')
  20410. opt.emphasis && compatTextStyle(opt.emphasis, 'label')
  20411. }
  20412. }
  20413. function processSeries(seriesOpt) {
  20414. if (!isObject$1(seriesOpt)) {
  20415. return
  20416. }
  20417. compatEC2ItemStyle(seriesOpt)
  20418. removeEC3NormalStatus(seriesOpt)
  20419. compatTextStyle(seriesOpt, 'label') // treemap
  20420. compatTextStyle(seriesOpt, 'upperLabel') // graph
  20421. compatTextStyle(seriesOpt, 'edgeLabel')
  20422. if (seriesOpt.emphasis) {
  20423. compatTextStyle(seriesOpt.emphasis, 'label') // treemap
  20424. compatTextStyle(seriesOpt.emphasis, 'upperLabel') // graph
  20425. compatTextStyle(seriesOpt.emphasis, 'edgeLabel')
  20426. }
  20427. var markPoint = seriesOpt.markPoint
  20428. if (markPoint) {
  20429. compatEC2ItemStyle(markPoint)
  20430. compatEC3CommonStyles(markPoint)
  20431. }
  20432. var markLine = seriesOpt.markLine
  20433. if (markLine) {
  20434. compatEC2ItemStyle(markLine)
  20435. compatEC3CommonStyles(markLine)
  20436. }
  20437. var markArea = seriesOpt.markArea
  20438. if (markArea) {
  20439. compatEC3CommonStyles(markArea)
  20440. }
  20441. var data = seriesOpt.data // Break with ec3: if `setOption` again, there may be no `type` in option,
  20442. // then the backward compat based on option type will not be performed.
  20443. if (seriesOpt.type === 'graph') {
  20444. data = data || seriesOpt.nodes
  20445. var edgeData = seriesOpt.links || seriesOpt.edges
  20446. if (edgeData && !isTypedArray(edgeData)) {
  20447. for (var i = 0; i < edgeData.length; i++) {
  20448. compatEC3CommonStyles(edgeData[i])
  20449. }
  20450. }
  20451. each$7(seriesOpt.categories, function (opt) {
  20452. removeEC3NormalStatus(opt)
  20453. })
  20454. }
  20455. if (data && !isTypedArray(data)) {
  20456. for (var i = 0; i < data.length; i++) {
  20457. compatEC3CommonStyles(data[i])
  20458. }
  20459. } // mark point data
  20460. markPoint = seriesOpt.markPoint
  20461. if (markPoint && markPoint.data) {
  20462. var mpData = markPoint.data
  20463. for (var i = 0; i < mpData.length; i++) {
  20464. compatEC3CommonStyles(mpData[i])
  20465. }
  20466. } // mark line data
  20467. markLine = seriesOpt.markLine
  20468. if (markLine && markLine.data) {
  20469. var mlData = markLine.data
  20470. for (var i = 0; i < mlData.length; i++) {
  20471. if (isArray(mlData[i])) {
  20472. compatEC3CommonStyles(mlData[i][0])
  20473. compatEC3CommonStyles(mlData[i][1])
  20474. } else {
  20475. compatEC3CommonStyles(mlData[i])
  20476. }
  20477. }
  20478. } // Series
  20479. if (seriesOpt.type === 'gauge') {
  20480. compatTextStyle(seriesOpt, 'axisLabel')
  20481. compatTextStyle(seriesOpt, 'title')
  20482. compatTextStyle(seriesOpt, 'detail')
  20483. } else if (seriesOpt.type === 'treemap') {
  20484. convertNormalEmphasis(seriesOpt.breadcrumb, 'itemStyle')
  20485. each$7(seriesOpt.levels, function (opt) {
  20486. removeEC3NormalStatus(opt)
  20487. })
  20488. } else if (seriesOpt.type === 'tree') {
  20489. removeEC3NormalStatus(seriesOpt.leaves)
  20490. } // sunburst starts from ec4, so it does not need to compat levels.
  20491. }
  20492. function toArr(o) {
  20493. return isArray(o) ? o : o ? [o] : []
  20494. }
  20495. function toObj(o) {
  20496. return (isArray(o) ? o[0] : o) || {}
  20497. }
  20498. function globalCompatStyle(option, isTheme) {
  20499. each$5(toArr(option.series), function (seriesOpt) {
  20500. isObject$1(seriesOpt) && processSeries(seriesOpt)
  20501. })
  20502. var axes = [
  20503. 'xAxis',
  20504. 'yAxis',
  20505. 'radiusAxis',
  20506. 'angleAxis',
  20507. 'singleAxis',
  20508. 'parallelAxis',
  20509. 'radar'
  20510. ]
  20511. isTheme &&
  20512. axes.push('valueAxis', 'categoryAxis', 'logAxis', 'timeAxis')
  20513. each$5(axes, function (axisName) {
  20514. each$5(toArr(option[axisName]), function (axisOpt) {
  20515. if (axisOpt) {
  20516. compatTextStyle(axisOpt, 'axisLabel')
  20517. compatTextStyle(axisOpt.axisPointer, 'label')
  20518. }
  20519. })
  20520. })
  20521. each$5(toArr(option.parallel), function (parallelOpt) {
  20522. var parallelAxisDefault =
  20523. parallelOpt && parallelOpt.parallelAxisDefault
  20524. compatTextStyle(parallelAxisDefault, 'axisLabel')
  20525. compatTextStyle(
  20526. parallelAxisDefault && parallelAxisDefault.axisPointer,
  20527. 'label'
  20528. )
  20529. })
  20530. each$5(toArr(option.calendar), function (calendarOpt) {
  20531. convertNormalEmphasis(calendarOpt, 'itemStyle')
  20532. compatTextStyle(calendarOpt, 'dayLabel')
  20533. compatTextStyle(calendarOpt, 'monthLabel')
  20534. compatTextStyle(calendarOpt, 'yearLabel')
  20535. }) // radar.name.textStyle
  20536. each$5(toArr(option.radar), function (radarOpt) {
  20537. compatTextStyle(radarOpt, 'name') // Use axisName instead of name because component has name property
  20538. if (radarOpt.name && radarOpt.axisName == null) {
  20539. radarOpt.axisName = radarOpt.name
  20540. delete radarOpt.name
  20541. }
  20542. if (radarOpt.nameGap != null && radarOpt.axisNameGap == null) {
  20543. radarOpt.axisNameGap = radarOpt.nameGap
  20544. delete radarOpt.nameGap
  20545. }
  20546. })
  20547. each$5(toArr(option.geo), function (geoOpt) {
  20548. if (isObject$1(geoOpt)) {
  20549. compatEC3CommonStyles(geoOpt)
  20550. each$5(toArr(geoOpt.regions), function (regionObj) {
  20551. compatEC3CommonStyles(regionObj)
  20552. })
  20553. }
  20554. })
  20555. each$5(toArr(option.timeline), function (timelineOpt) {
  20556. compatEC3CommonStyles(timelineOpt)
  20557. convertNormalEmphasis(timelineOpt, 'label')
  20558. convertNormalEmphasis(timelineOpt, 'itemStyle')
  20559. convertNormalEmphasis(timelineOpt, 'controlStyle', true)
  20560. var data = timelineOpt.data
  20561. isArray(data) &&
  20562. each$7(data, function (item) {
  20563. if (isObject$2(item)) {
  20564. convertNormalEmphasis(item, 'label')
  20565. convertNormalEmphasis(item, 'itemStyle')
  20566. }
  20567. })
  20568. })
  20569. each$5(toArr(option.toolbox), function (toolboxOpt) {
  20570. convertNormalEmphasis(toolboxOpt, 'iconStyle')
  20571. each$5(toolboxOpt.feature, function (featureOpt) {
  20572. convertNormalEmphasis(featureOpt, 'iconStyle')
  20573. })
  20574. })
  20575. compatTextStyle(toObj(option.axisPointer), 'label')
  20576. compatTextStyle(toObj(option.tooltip).axisPointer, 'label') // Clean logs
  20577. // storedLogs = {};
  20578. }
  20579. function get(opt, path) {
  20580. var pathArr = path.split(',')
  20581. var obj = opt
  20582. for (var i = 0; i < pathArr.length; i++) {
  20583. obj = obj && obj[pathArr[i]]
  20584. if (obj == null) {
  20585. break
  20586. }
  20587. }
  20588. return obj
  20589. }
  20590. function set(opt, path, val, overwrite) {
  20591. var pathArr = path.split(',')
  20592. var obj = opt
  20593. var key
  20594. var i = 0
  20595. for (; i < pathArr.length - 1; i++) {
  20596. key = pathArr[i]
  20597. if (obj[key] == null) {
  20598. obj[key] = {}
  20599. }
  20600. obj = obj[key]
  20601. }
  20602. if (overwrite || obj[pathArr[i]] == null) {
  20603. obj[pathArr[i]] = val
  20604. }
  20605. }
  20606. function compatLayoutProperties(option) {
  20607. option &&
  20608. each$7(LAYOUT_PROPERTIES, function (prop) {
  20609. if (prop[0] in option && !(prop[1] in option)) {
  20610. option[prop[1]] = option[prop[0]]
  20611. }
  20612. })
  20613. }
  20614. var LAYOUT_PROPERTIES = [
  20615. ['x', 'left'],
  20616. ['y', 'top'],
  20617. ['x2', 'right'],
  20618. ['y2', 'bottom']
  20619. ]
  20620. var COMPATITABLE_COMPONENTS = [
  20621. 'grid',
  20622. 'geo',
  20623. 'parallel',
  20624. 'legend',
  20625. 'toolbox',
  20626. 'title',
  20627. 'visualMap',
  20628. 'dataZoom',
  20629. 'timeline'
  20630. ]
  20631. var BAR_ITEM_STYLE_MAP = [
  20632. ['borderRadius', 'barBorderRadius'],
  20633. ['borderColor', 'barBorderColor'],
  20634. ['borderWidth', 'barBorderWidth']
  20635. ]
  20636. function compatBarItemStyle(option) {
  20637. var itemStyle = option && option.itemStyle
  20638. if (itemStyle) {
  20639. for (var i = 0; i < BAR_ITEM_STYLE_MAP.length; i++) {
  20640. var oldName = BAR_ITEM_STYLE_MAP[i][1]
  20641. var newName = BAR_ITEM_STYLE_MAP[i][0]
  20642. if (itemStyle[oldName] != null) {
  20643. itemStyle[newName] = itemStyle[oldName]
  20644. }
  20645. }
  20646. }
  20647. }
  20648. function compatPieLabel(option) {
  20649. if (!option) {
  20650. return
  20651. }
  20652. if (
  20653. option.alignTo === 'edge' &&
  20654. option.margin != null &&
  20655. option.edgeDistance == null
  20656. ) {
  20657. option.edgeDistance = option.margin
  20658. }
  20659. }
  20660. function compatSunburstState(option) {
  20661. if (!option) {
  20662. return
  20663. }
  20664. if (option.downplay && !option.blur) {
  20665. option.blur = option.downplay
  20666. }
  20667. }
  20668. function compatGraphFocus(option) {
  20669. if (!option) {
  20670. return
  20671. }
  20672. if (option.focusNodeAdjacency != null) {
  20673. option.emphasis = option.emphasis || {}
  20674. if (option.emphasis.focus == null) {
  20675. option.emphasis.focus = 'adjacency'
  20676. }
  20677. }
  20678. }
  20679. function traverseTree(data, cb) {
  20680. if (data) {
  20681. for (var i = 0; i < data.length; i++) {
  20682. cb(data[i])
  20683. data[i] && traverseTree(data[i].children, cb)
  20684. }
  20685. }
  20686. }
  20687. function globalBackwardCompat(option, isTheme) {
  20688. globalCompatStyle(option, isTheme) // Make sure series array for model initialization.
  20689. option.series = normalizeToArray(option.series)
  20690. each$7(option.series, function (seriesOpt) {
  20691. if (!isObject$2(seriesOpt)) {
  20692. return
  20693. }
  20694. var seriesType = seriesOpt.type
  20695. if (seriesType === 'line') {
  20696. if (seriesOpt.clipOverflow != null) {
  20697. seriesOpt.clip = seriesOpt.clipOverflow
  20698. }
  20699. } else if (seriesType === 'pie' || seriesType === 'gauge') {
  20700. if (seriesOpt.clockWise != null) {
  20701. seriesOpt.clockwise = seriesOpt.clockWise
  20702. }
  20703. compatPieLabel(seriesOpt.label)
  20704. var data = seriesOpt.data
  20705. if (data && !isTypedArray(data)) {
  20706. for (var i = 0; i < data.length; i++) {
  20707. compatPieLabel(data[i])
  20708. }
  20709. }
  20710. if (seriesOpt.hoverOffset != null) {
  20711. seriesOpt.emphasis = seriesOpt.emphasis || {}
  20712. if ((seriesOpt.emphasis.scaleSize = null)) {
  20713. seriesOpt.emphasis.scaleSize = seriesOpt.hoverOffset
  20714. }
  20715. }
  20716. } else if (seriesType === 'gauge') {
  20717. var pointerColor = get(seriesOpt, 'pointer.color')
  20718. pointerColor != null &&
  20719. set(seriesOpt, 'itemStyle.color', pointerColor)
  20720. } else if (seriesType === 'bar') {
  20721. compatBarItemStyle(seriesOpt)
  20722. compatBarItemStyle(seriesOpt.backgroundStyle)
  20723. compatBarItemStyle(seriesOpt.emphasis)
  20724. var data = seriesOpt.data
  20725. if (data && !isTypedArray(data)) {
  20726. for (var i = 0; i < data.length; i++) {
  20727. if (_typeof(data[i]) === 'object') {
  20728. compatBarItemStyle(data[i])
  20729. compatBarItemStyle(data[i] && data[i].emphasis)
  20730. }
  20731. }
  20732. }
  20733. } else if (seriesType === 'sunburst') {
  20734. var highlightPolicy = seriesOpt.highlightPolicy
  20735. if (highlightPolicy) {
  20736. seriesOpt.emphasis = seriesOpt.emphasis || {}
  20737. if (!seriesOpt.emphasis.focus) {
  20738. seriesOpt.emphasis.focus = highlightPolicy
  20739. }
  20740. }
  20741. compatSunburstState(seriesOpt)
  20742. traverseTree(seriesOpt.data, compatSunburstState)
  20743. } else if (seriesType === 'graph' || seriesType === 'sankey') {
  20744. compatGraphFocus(seriesOpt) // TODO nodes, edges?
  20745. } else if (seriesType === 'map') {
  20746. if (seriesOpt.mapType && !seriesOpt.map) {
  20747. seriesOpt.map = seriesOpt.mapType
  20748. }
  20749. if (seriesOpt.mapLocation) {
  20750. defaults(seriesOpt, seriesOpt.mapLocation)
  20751. }
  20752. }
  20753. if (seriesOpt.hoverAnimation != null) {
  20754. seriesOpt.emphasis = seriesOpt.emphasis || {}
  20755. if (seriesOpt.emphasis && seriesOpt.emphasis.scale == null) {
  20756. seriesOpt.emphasis.scale = seriesOpt.hoverAnimation
  20757. }
  20758. }
  20759. compatLayoutProperties(seriesOpt)
  20760. }) // dataRange has changed to visualMap
  20761. if (option.dataRange) {
  20762. option.visualMap = option.dataRange
  20763. }
  20764. each$7(COMPATITABLE_COMPONENTS, function (componentName) {
  20765. var options = option[componentName]
  20766. if (options) {
  20767. if (!isArray(options)) {
  20768. options = [options]
  20769. }
  20770. each$7(options, function (option) {
  20771. compatLayoutProperties(option)
  20772. })
  20773. }
  20774. })
  20775. } // data processing stage is blocked in stream.
  20776. // See <module:echarts/stream/Scheduler#performDataProcessorTasks>
  20777. // (2) Only register once when import repeatedly.
  20778. // Should be executed after series is filtered and before stack calculation.
  20779. function dataStack(ecModel) {
  20780. var stackInfoMap = createHashMap()
  20781. ecModel.eachSeries(function (seriesModel) {
  20782. var stack = seriesModel.get('stack') // Compatible: when `stack` is set as '', do not stack.
  20783. if (stack) {
  20784. var stackInfoList =
  20785. stackInfoMap.get(stack) || stackInfoMap.set(stack, [])
  20786. var data = seriesModel.getData()
  20787. var stackInfo = {
  20788. // Used for calculate axis extent automatically.
  20789. // TODO: Type getCalculationInfo return more specific type?
  20790. stackResultDimension: data.getCalculationInfo(
  20791. 'stackResultDimension'
  20792. ),
  20793. stackedOverDimension: data.getCalculationInfo(
  20794. 'stackedOverDimension'
  20795. ),
  20796. stackedDimension: data.getCalculationInfo('stackedDimension'),
  20797. stackedByDimension:
  20798. data.getCalculationInfo('stackedByDimension'),
  20799. isStackedByIndex: data.getCalculationInfo('isStackedByIndex'),
  20800. data: data,
  20801. seriesModel: seriesModel
  20802. } // If stacked on axis that do not support data stack.
  20803. if (
  20804. !stackInfo.stackedDimension ||
  20805. !(stackInfo.isStackedByIndex || stackInfo.stackedByDimension)
  20806. ) {
  20807. return
  20808. }
  20809. stackInfoList.length &&
  20810. data.setCalculationInfo(
  20811. 'stackedOnSeries',
  20812. stackInfoList[stackInfoList.length - 1].seriesModel
  20813. )
  20814. stackInfoList.push(stackInfo)
  20815. }
  20816. })
  20817. stackInfoMap.each(calculateStack)
  20818. }
  20819. function calculateStack(stackInfoList) {
  20820. each$7(stackInfoList, function (targetStackInfo, idxInStack) {
  20821. var resultVal = []
  20822. var resultNaN = [NaN, NaN]
  20823. var dims = [
  20824. targetStackInfo.stackResultDimension,
  20825. targetStackInfo.stackedOverDimension
  20826. ]
  20827. var targetData = targetStackInfo.data
  20828. var isStackedByIndex = targetStackInfo.isStackedByIndex
  20829. var stackStrategy =
  20830. targetStackInfo.seriesModel.get('stackStrategy') || 'samesign' // Should not write on raw data, because stack series model list changes
  20831. // depending on legend selection.
  20832. targetData.modify(dims, function (v0, v1, dataIndex) {
  20833. var sum = targetData.get(
  20834. targetStackInfo.stackedDimension,
  20835. dataIndex
  20836. ) // Consider `connectNulls` of line area, if value is NaN, stackedOver
  20837. // should also be NaN, to draw a appropriate belt area.
  20838. if (isNaN(sum)) {
  20839. return resultNaN
  20840. }
  20841. var byValue
  20842. var stackedDataRawIndex
  20843. if (isStackedByIndex) {
  20844. stackedDataRawIndex = targetData.getRawIndex(dataIndex)
  20845. } else {
  20846. byValue = targetData.get(
  20847. targetStackInfo.stackedByDimension,
  20848. dataIndex
  20849. )
  20850. } // If stackOver is NaN, chart view will render point on value start.
  20851. var stackedOver = NaN
  20852. for (var j = idxInStack - 1; j >= 0; j--) {
  20853. var stackInfo = stackInfoList[j] // Has been optimized by inverted indices on `stackedByDimension`.
  20854. if (!isStackedByIndex) {
  20855. stackedDataRawIndex = stackInfo.data.rawIndexOf(
  20856. stackInfo.stackedByDimension,
  20857. byValue
  20858. )
  20859. }
  20860. if (stackedDataRawIndex >= 0) {
  20861. var val = stackInfo.data.getByRawIndex(
  20862. stackInfo.stackResultDimension,
  20863. stackedDataRawIndex
  20864. ) // Considering positive stack, negative stack and empty data
  20865. if (
  20866. stackStrategy === 'all' || // single stack group
  20867. (stackStrategy === 'positive' && val > 0) ||
  20868. (stackStrategy === 'negative' && val < 0) ||
  20869. (stackStrategy === 'samesign' && sum >= 0 && val > 0) || // All positive stack
  20870. (stackStrategy === 'samesign' && sum <= 0 && val < 0) // All negative stack
  20871. ) {
  20872. // The sum has to be very small to be affected by the
  20873. // floating arithmetic problem. An incorrect result will probably
  20874. // cause axis min/max to be filtered incorrectly.
  20875. sum = addSafe(sum, val)
  20876. stackedOver = val
  20877. break
  20878. }
  20879. }
  20880. }
  20881. resultVal[0] = sum
  20882. resultVal[1] = stackedOver
  20883. return resultVal
  20884. })
  20885. })
  20886. }
  20887. var SourceImpl = /** @class */ (function () {
  20888. function SourceImpl(fields) {
  20889. this.data =
  20890. fields.data ||
  20891. (fields.sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS ? {} : [])
  20892. this.sourceFormat = fields.sourceFormat || SOURCE_FORMAT_UNKNOWN // Visit config
  20893. this.seriesLayoutBy =
  20894. fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN
  20895. this.startIndex = fields.startIndex || 0
  20896. this.dimensionsDetectedCount = fields.dimensionsDetectedCount
  20897. this.metaRawOption = fields.metaRawOption
  20898. var dimensionsDefine = (this.dimensionsDefine =
  20899. fields.dimensionsDefine)
  20900. if (dimensionsDefine) {
  20901. for (var i = 0; i < dimensionsDefine.length; i++) {
  20902. var dim = dimensionsDefine[i]
  20903. if (dim.type == null) {
  20904. if (guessOrdinal(this, i) === BE_ORDINAL.Must) {
  20905. dim.type = 'ordinal'
  20906. }
  20907. }
  20908. }
  20909. }
  20910. }
  20911. return SourceImpl
  20912. })()
  20913. function isSourceInstance(val) {
  20914. return val instanceof SourceImpl
  20915. }
  20916. /**
  20917. * Create a source from option.
  20918. * NOTE: Created source is immutable. Don't change any properties in it.
  20919. */ function createSource(
  20920. sourceData,
  20921. thisMetaRawOption, // can be null. If not provided, auto detect it from `sourceData`.
  20922. sourceFormat
  20923. ) {
  20924. sourceFormat = sourceFormat || detectSourceFormat(sourceData)
  20925. var seriesLayoutBy = thisMetaRawOption.seriesLayoutBy
  20926. var determined = determineSourceDimensions(
  20927. sourceData,
  20928. sourceFormat,
  20929. seriesLayoutBy,
  20930. thisMetaRawOption.sourceHeader,
  20931. thisMetaRawOption.dimensions
  20932. )
  20933. var source = new SourceImpl({
  20934. data: sourceData,
  20935. sourceFormat: sourceFormat,
  20936. seriesLayoutBy: seriesLayoutBy,
  20937. dimensionsDefine: determined.dimensionsDefine,
  20938. startIndex: determined.startIndex,
  20939. dimensionsDetectedCount: determined.dimensionsDetectedCount,
  20940. metaRawOption: clone$3(thisMetaRawOption)
  20941. })
  20942. return source
  20943. }
  20944. /**
  20945. * Wrap original series data for some compatibility cases.
  20946. */ function createSourceFromSeriesDataOption(data) {
  20947. return new SourceImpl({
  20948. data: data,
  20949. sourceFormat: isTypedArray(data)
  20950. ? SOURCE_FORMAT_TYPED_ARRAY
  20951. : SOURCE_FORMAT_ORIGINAL
  20952. })
  20953. }
  20954. /**
  20955. * Clone source but excludes source data.
  20956. */ function cloneSourceShallow(source) {
  20957. return new SourceImpl({
  20958. data: source.data,
  20959. sourceFormat: source.sourceFormat,
  20960. seriesLayoutBy: source.seriesLayoutBy,
  20961. dimensionsDefine: clone$3(source.dimensionsDefine),
  20962. startIndex: source.startIndex,
  20963. dimensionsDetectedCount: source.dimensionsDetectedCount
  20964. })
  20965. }
  20966. /**
  20967. * Note: An empty array will be detected as `SOURCE_FORMAT_ARRAY_ROWS`.
  20968. */ function detectSourceFormat(data) {
  20969. var sourceFormat = SOURCE_FORMAT_UNKNOWN
  20970. if (isTypedArray(data)) {
  20971. sourceFormat = SOURCE_FORMAT_TYPED_ARRAY
  20972. } else if (isArray(data)) {
  20973. // FIXME Whether tolerate null in top level array?
  20974. if (data.length === 0) {
  20975. sourceFormat = SOURCE_FORMAT_ARRAY_ROWS
  20976. }
  20977. for (var i = 0, len = data.length; i < len; i++) {
  20978. var item = data[i]
  20979. if (item == null) {
  20980. continue
  20981. } else if (isArray(item)) {
  20982. sourceFormat = SOURCE_FORMAT_ARRAY_ROWS
  20983. break
  20984. } else if (isObject$2(item)) {
  20985. sourceFormat = SOURCE_FORMAT_OBJECT_ROWS
  20986. break
  20987. }
  20988. }
  20989. } else if (isObject$2(data)) {
  20990. for (var key in data) {
  20991. if (hasOwn(data, key) && isArrayLike(data[key])) {
  20992. sourceFormat = SOURCE_FORMAT_KEYED_COLUMNS
  20993. break
  20994. }
  20995. }
  20996. }
  20997. return sourceFormat
  20998. }
  20999. /**
  21000. * Determine the source definitions from data standalone dimensions definitions
  21001. * are not specified.
  21002. */ function determineSourceDimensions(
  21003. data,
  21004. sourceFormat,
  21005. seriesLayoutBy,
  21006. sourceHeader, // standalone raw dimensions definition, like:
  21007. // {
  21008. // dimensions: ['aa', 'bb', { name: 'cc', type: 'time' }]
  21009. // }
  21010. // in `dataset` or `series`
  21011. dimensionsDefine
  21012. ) {
  21013. var dimensionsDetectedCount
  21014. var startIndex // PEDING: could data be null/undefined here?
  21015. // currently, if `dataset.source` not specified, error thrown.
  21016. // if `series.data` not specified, nothing rendered without error thrown.
  21017. // Should test these cases.
  21018. if (!data) {
  21019. return {
  21020. dimensionsDefine: normalizeDimensionsOption(dimensionsDefine),
  21021. startIndex: startIndex,
  21022. dimensionsDetectedCount: dimensionsDetectedCount
  21023. }
  21024. }
  21025. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  21026. var dataArrayRows = data // Rule: Most of the first line are string: it is header.
  21027. // Caution: consider a line with 5 string and 1 number,
  21028. // it still can not be sure it is a head, because the
  21029. // 5 string may be 5 values of category columns.
  21030. if (sourceHeader === 'auto' || sourceHeader == null) {
  21031. arrayRowsTravelFirst(
  21032. function (val) {
  21033. // '-' is regarded as null/undefined.
  21034. if (val != null && val !== '-') {
  21035. if (isString(val)) {
  21036. startIndex == null && (startIndex = 1)
  21037. } else {
  21038. startIndex = 0
  21039. }
  21040. } // 10 is an experience number, avoid long loop.
  21041. },
  21042. seriesLayoutBy,
  21043. dataArrayRows,
  21044. 10
  21045. )
  21046. } else {
  21047. startIndex = isNumber(sourceHeader)
  21048. ? sourceHeader
  21049. : sourceHeader
  21050. ? 1
  21051. : 0
  21052. }
  21053. if (!dimensionsDefine && startIndex === 1) {
  21054. dimensionsDefine = []
  21055. arrayRowsTravelFirst(
  21056. function (val, index) {
  21057. dimensionsDefine[index] = val != null ? val + '' : ''
  21058. },
  21059. seriesLayoutBy,
  21060. dataArrayRows,
  21061. Infinity
  21062. )
  21063. }
  21064. dimensionsDetectedCount = dimensionsDefine
  21065. ? dimensionsDefine.length
  21066. : seriesLayoutBy === SERIES_LAYOUT_BY_ROW
  21067. ? dataArrayRows.length
  21068. : dataArrayRows[0]
  21069. ? dataArrayRows[0].length
  21070. : null
  21071. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  21072. if (!dimensionsDefine) {
  21073. dimensionsDefine = objectRowsCollectDimensions(data)
  21074. }
  21075. } else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  21076. if (!dimensionsDefine) {
  21077. dimensionsDefine = []
  21078. each$7(data, function (colArr, key) {
  21079. dimensionsDefine.push(key)
  21080. })
  21081. }
  21082. } else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  21083. var value0 = getDataItemValue(data[0])
  21084. dimensionsDetectedCount = (isArray(value0) && value0.length) || 1
  21085. } else;
  21086. return {
  21087. startIndex: startIndex,
  21088. dimensionsDefine: normalizeDimensionsOption(dimensionsDefine),
  21089. dimensionsDetectedCount: dimensionsDetectedCount
  21090. }
  21091. }
  21092. function objectRowsCollectDimensions(data) {
  21093. var firstIndex = 0
  21094. var obj
  21095. while (firstIndex < data.length && !(obj = data[firstIndex++])) {} // jshint ignore: line
  21096. if (obj) {
  21097. var dimensions_1 = []
  21098. each$7(obj, function (value, key) {
  21099. dimensions_1.push(key)
  21100. })
  21101. return dimensions_1
  21102. }
  21103. } // Consider dimensions defined like ['A', 'price', 'B', 'price', 'C', 'price'],
  21104. // which is reasonable. But dimension name is duplicated.
  21105. // Returns undefined or an array contains only object without null/undefiend or string.
  21106. function normalizeDimensionsOption(dimensionsDefine) {
  21107. if (!dimensionsDefine) {
  21108. // The meaning of null/undefined is different from empty array.
  21109. return
  21110. }
  21111. var nameMap = createHashMap()
  21112. return map$1(dimensionsDefine, function (rawItem, index) {
  21113. rawItem = isObject$2(rawItem) ? rawItem : { name: rawItem } // Other fields will be discarded.
  21114. var item = {
  21115. name: rawItem.name,
  21116. displayName: rawItem.displayName,
  21117. type: rawItem.type
  21118. } // User can set null in dimensions.
  21119. // We dont auto specify name, othewise a given name may
  21120. // cause it be refered unexpectedly.
  21121. if (item.name == null) {
  21122. return item
  21123. } // Also consider number form like 2012.
  21124. item.name += '' // User may also specify displayName.
  21125. // displayName will always exists except user not
  21126. // specified or dim name is not specified or detected.
  21127. // (A auto generated dim name will not be used as
  21128. // displayName).
  21129. if (item.displayName == null) {
  21130. item.displayName = item.name
  21131. }
  21132. var exist = nameMap.get(item.name)
  21133. if (!exist) {
  21134. nameMap.set(item.name, { count: 1 })
  21135. } else {
  21136. item.name += '-' + exist.count++
  21137. }
  21138. return item
  21139. })
  21140. }
  21141. function arrayRowsTravelFirst(cb, seriesLayoutBy, data, maxLoop) {
  21142. if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
  21143. for (var i = 0; i < data.length && i < maxLoop; i++) {
  21144. cb(data[i] ? data[i][0] : null, i)
  21145. }
  21146. } else {
  21147. var value0 = data[0] || []
  21148. for (var i = 0; i < value0.length && i < maxLoop; i++) {
  21149. cb(value0[i], i)
  21150. }
  21151. }
  21152. }
  21153. function shouldRetrieveDataByName(source) {
  21154. var sourceFormat = source.sourceFormat
  21155. return (
  21156. sourceFormat === SOURCE_FORMAT_OBJECT_ROWS ||
  21157. sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS
  21158. )
  21159. }
  21160. /*
  21161. * Licensed to the Apache Software Foundation (ASF) under one
  21162. * or more contributor license agreements. See the NOTICE file
  21163. * distributed with this work for additional information
  21164. * regarding copyright ownership. The ASF licenses this file
  21165. * to you under the Apache License, Version 2.0 (the
  21166. * "License"); you may not use this file except in compliance
  21167. * with the License. You may obtain a copy of the License at
  21168. *
  21169. * http://www.apache.org/licenses/LICENSE-2.0
  21170. *
  21171. * Unless required by applicable law or agreed to in writing,
  21172. * software distributed under the License is distributed on an
  21173. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21174. * KIND, either express or implied. See the License for the
  21175. * specific language governing permissions and limitations
  21176. * under the License.
  21177. */ /**
  21178. * AUTO-GENERATED FILE. DO NOT MODIFY.
  21179. */ /*
  21180. * Licensed to the Apache Software Foundation (ASF) under one
  21181. * or more contributor license agreements. See the NOTICE file
  21182. * distributed with this work for additional information
  21183. * regarding copyright ownership. The ASF licenses this file
  21184. * to you under the Apache License, Version 2.0 (the
  21185. * "License"); you may not use this file except in compliance
  21186. * with the License. You may obtain a copy of the License at
  21187. *
  21188. * http://www.apache.org/licenses/LICENSE-2.0
  21189. *
  21190. * Unless required by applicable law or agreed to in writing,
  21191. * software distributed under the License is distributed on an
  21192. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21193. * KIND, either express or implied. See the License for the
  21194. * specific language governing permissions and limitations
  21195. * under the License.
  21196. */ var _a, _b, _c // TODO
  21197. var providerMethods
  21198. var mountMethods
  21199. /**
  21200. * If normal array used, mutable chunk size is supported.
  21201. * If typed array used, chunk size must be fixed.
  21202. */ var DefaultDataProvider = /** @class */ (function () {
  21203. function DefaultDataProvider(sourceParam, dimSize) {
  21204. // let source: Source;
  21205. var source = !isSourceInstance(sourceParam)
  21206. ? createSourceFromSeriesDataOption(sourceParam)
  21207. : sourceParam // declare source is Source;
  21208. this._source = source
  21209. var data = (this._data = source.data) // Typed array. TODO IE10+?
  21210. if (source.sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) {
  21211. this._offset = 0
  21212. this._dimSize = dimSize
  21213. this._data = data
  21214. }
  21215. mountMethods(this, data, source)
  21216. }
  21217. DefaultDataProvider.prototype.getSource = function () {
  21218. return this._source
  21219. }
  21220. DefaultDataProvider.prototype.count = function () {
  21221. return 0
  21222. }
  21223. DefaultDataProvider.prototype.getItem = function (idx, out) {
  21224. return
  21225. }
  21226. DefaultDataProvider.prototype.appendData = function (newData) {}
  21227. DefaultDataProvider.prototype.clean = function () {}
  21228. DefaultDataProvider.protoInitialize = (function () {
  21229. // PENDING: To avoid potential incompat (e.g., prototype
  21230. // is visited somewhere), still init them on prototype.
  21231. var proto = DefaultDataProvider.prototype
  21232. proto.pure = false
  21233. proto.persistent = true
  21234. })()
  21235. DefaultDataProvider.internalField = (function () {
  21236. var _a
  21237. mountMethods = function mountMethods(provider, data, source) {
  21238. var sourceFormat = source.sourceFormat
  21239. var seriesLayoutBy = source.seriesLayoutBy
  21240. var startIndex = source.startIndex
  21241. var dimsDef = source.dimensionsDefine
  21242. var methods =
  21243. providerMethods[getMethodMapKey(sourceFormat, seriesLayoutBy)]
  21244. extend(provider, methods)
  21245. if (sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) {
  21246. provider.getItem = getItemForTypedArray
  21247. provider.count = countForTypedArray
  21248. provider.fillStorage = fillStorageForTypedArray
  21249. } else {
  21250. var rawItemGetter = getRawSourceItemGetter(
  21251. sourceFormat,
  21252. seriesLayoutBy
  21253. )
  21254. provider.getItem = bind$1(
  21255. rawItemGetter,
  21256. null,
  21257. data,
  21258. startIndex,
  21259. dimsDef
  21260. )
  21261. var rawCounter = getRawSourceDataCounter(
  21262. sourceFormat,
  21263. seriesLayoutBy
  21264. )
  21265. provider.count = bind$1(
  21266. rawCounter,
  21267. null,
  21268. data,
  21269. startIndex,
  21270. dimsDef
  21271. )
  21272. }
  21273. }
  21274. var getItemForTypedArray = function getItemForTypedArray(
  21275. idx,
  21276. out
  21277. ) {
  21278. idx = idx - this._offset
  21279. out = out || []
  21280. var data = this._data
  21281. var dimSize = this._dimSize
  21282. var offset = dimSize * idx
  21283. for (var i = 0; i < dimSize; i++) {
  21284. out[i] = data[offset + i]
  21285. }
  21286. return out
  21287. }
  21288. var fillStorageForTypedArray = function fillStorageForTypedArray(
  21289. start,
  21290. end,
  21291. storage,
  21292. extent
  21293. ) {
  21294. var data = this._data
  21295. var dimSize = this._dimSize
  21296. for (var dim = 0; dim < dimSize; dim++) {
  21297. var dimExtent = extent[dim]
  21298. var min = dimExtent[0] == null ? Infinity : dimExtent[0]
  21299. var max = dimExtent[1] == null ? -Infinity : dimExtent[1]
  21300. var count = end - start
  21301. var arr = storage[dim]
  21302. for (var i = 0; i < count; i++) {
  21303. // appendData with TypedArray will always do replace in provider.
  21304. var val = data[i * dimSize + dim]
  21305. arr[start + i] = val
  21306. val < min && (min = val)
  21307. val > max && (max = val)
  21308. }
  21309. dimExtent[0] = min
  21310. dimExtent[1] = max
  21311. }
  21312. }
  21313. var countForTypedArray = function countForTypedArray() {
  21314. return this._data ? this._data.length / this._dimSize : 0
  21315. }
  21316. providerMethods =
  21317. ((_a = {}),
  21318. (_a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN] =
  21319. { pure: true, appendData: appendDataSimply }),
  21320. (_a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW] = {
  21321. pure: true,
  21322. appendData: function appendData() {
  21323. throw new Error(
  21324. 'Do not support appendData when set seriesLayoutBy: "row".'
  21325. )
  21326. }
  21327. }),
  21328. (_a[SOURCE_FORMAT_OBJECT_ROWS] = {
  21329. pure: true,
  21330. appendData: appendDataSimply
  21331. }),
  21332. (_a[SOURCE_FORMAT_KEYED_COLUMNS] = {
  21333. pure: true,
  21334. appendData: function appendData(newData) {
  21335. var data = this._data
  21336. each$7(newData, function (newCol, key) {
  21337. var oldCol = data[key] || (data[key] = [])
  21338. for (var i = 0; i < (newCol || []).length; i++) {
  21339. oldCol.push(newCol[i])
  21340. }
  21341. })
  21342. }
  21343. }),
  21344. (_a[SOURCE_FORMAT_ORIGINAL] = { appendData: appendDataSimply }),
  21345. (_a[SOURCE_FORMAT_TYPED_ARRAY] = {
  21346. persistent: false,
  21347. pure: true,
  21348. appendData: function appendData(newData) {
  21349. this._data = newData
  21350. }, // Clean self if data is already used.
  21351. clean: function clean() {
  21352. // PENDING
  21353. this._offset += this.count()
  21354. this._data = null
  21355. }
  21356. }),
  21357. _a)
  21358. function appendDataSimply(newData) {
  21359. for (var i = 0; i < newData.length; i++) {
  21360. this._data.push(newData[i])
  21361. }
  21362. }
  21363. })()
  21364. return DefaultDataProvider
  21365. })()
  21366. var getItemSimply = function getItemSimply(
  21367. rawData,
  21368. startIndex,
  21369. dimsDef,
  21370. idx
  21371. ) {
  21372. return rawData[idx]
  21373. }
  21374. var rawSourceItemGetterMap =
  21375. ((_a = {}),
  21376. (_a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN] =
  21377. function (rawData, startIndex, dimsDef, idx) {
  21378. return rawData[idx + startIndex]
  21379. }),
  21380. (_a[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW] =
  21381. function (rawData, startIndex, dimsDef, idx, out) {
  21382. idx += startIndex
  21383. var item = out || []
  21384. var data = rawData
  21385. for (var i = 0; i < data.length; i++) {
  21386. var row = data[i]
  21387. item[i] = row ? row[idx] : null
  21388. }
  21389. return item
  21390. }),
  21391. (_a[SOURCE_FORMAT_OBJECT_ROWS] = getItemSimply),
  21392. (_a[SOURCE_FORMAT_KEYED_COLUMNS] = function (
  21393. rawData,
  21394. startIndex,
  21395. dimsDef,
  21396. idx,
  21397. out
  21398. ) {
  21399. var item = out || []
  21400. for (var i = 0; i < dimsDef.length; i++) {
  21401. var dimName = dimsDef[i].name
  21402. var col = rawData[dimName]
  21403. item[i] = col ? col[idx] : null
  21404. }
  21405. return item
  21406. }),
  21407. (_a[SOURCE_FORMAT_ORIGINAL] = getItemSimply),
  21408. _a)
  21409. function getRawSourceItemGetter(sourceFormat, seriesLayoutBy) {
  21410. var method =
  21411. rawSourceItemGetterMap[
  21412. getMethodMapKey(sourceFormat, seriesLayoutBy)
  21413. ]
  21414. return method
  21415. }
  21416. var countSimply = function countSimply(rawData, startIndex, dimsDef) {
  21417. return rawData.length
  21418. }
  21419. var rawSourceDataCounterMap =
  21420. ((_b = {}),
  21421. (_b[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_COLUMN] =
  21422. function (rawData, startIndex, dimsDef) {
  21423. return Math.max(0, rawData.length - startIndex)
  21424. }),
  21425. (_b[SOURCE_FORMAT_ARRAY_ROWS + '_' + SERIES_LAYOUT_BY_ROW] =
  21426. function (rawData, startIndex, dimsDef) {
  21427. var row = rawData[0]
  21428. return row ? Math.max(0, row.length - startIndex) : 0
  21429. }),
  21430. (_b[SOURCE_FORMAT_OBJECT_ROWS] = countSimply),
  21431. (_b[SOURCE_FORMAT_KEYED_COLUMNS] = function (
  21432. rawData,
  21433. startIndex,
  21434. dimsDef
  21435. ) {
  21436. var dimName = dimsDef[0].name
  21437. var col = rawData[dimName]
  21438. return col ? col.length : 0
  21439. }),
  21440. (_b[SOURCE_FORMAT_ORIGINAL] = countSimply),
  21441. _b)
  21442. function getRawSourceDataCounter(sourceFormat, seriesLayoutBy) {
  21443. var method =
  21444. rawSourceDataCounterMap[
  21445. getMethodMapKey(sourceFormat, seriesLayoutBy)
  21446. ]
  21447. return method
  21448. }
  21449. var getRawValueSimply = function getRawValueSimply(
  21450. dataItem,
  21451. dimIndex,
  21452. property
  21453. ) {
  21454. return dataItem[dimIndex]
  21455. }
  21456. var rawSourceValueGetterMap =
  21457. ((_c = {}),
  21458. (_c[SOURCE_FORMAT_ARRAY_ROWS] = getRawValueSimply),
  21459. (_c[SOURCE_FORMAT_OBJECT_ROWS] = function (
  21460. dataItem,
  21461. dimIndex,
  21462. property
  21463. ) {
  21464. return dataItem[property]
  21465. }),
  21466. (_c[SOURCE_FORMAT_KEYED_COLUMNS] = getRawValueSimply),
  21467. (_c[SOURCE_FORMAT_ORIGINAL] = function (
  21468. dataItem,
  21469. dimIndex,
  21470. property
  21471. ) {
  21472. // FIXME: In some case (markpoint in geo (geo-map.html)),
  21473. // dataItem is {coord: [...]}
  21474. var value = getDataItemValue(dataItem)
  21475. return !(value instanceof Array) ? value : value[dimIndex]
  21476. }),
  21477. (_c[SOURCE_FORMAT_TYPED_ARRAY] = getRawValueSimply),
  21478. _c)
  21479. function getRawSourceValueGetter(sourceFormat) {
  21480. var method = rawSourceValueGetterMap[sourceFormat]
  21481. return method
  21482. }
  21483. function getMethodMapKey(sourceFormat, seriesLayoutBy) {
  21484. return sourceFormat === SOURCE_FORMAT_ARRAY_ROWS
  21485. ? sourceFormat + '_' + seriesLayoutBy
  21486. : sourceFormat
  21487. } // ??? FIXME can these logic be more neat: getRawValue, getRawDataItem,
  21488. // Consider persistent.
  21489. // Caution: why use raw value to display on label or tooltip?
  21490. // A reason is to avoid format. For example time value we do not know
  21491. // how to format is expected. More over, if stack is used, calculated
  21492. // value may be 0.91000000001, which have brings trouble to display.
  21493. // TODO: consider how to treat null/undefined/NaN when display?
  21494. function retrieveRawValue(
  21495. data,
  21496. dataIndex, // If dimIndex is null/undefined, return OptionDataItem.
  21497. // Otherwise, return OptionDataValue.
  21498. dim
  21499. ) {
  21500. if (!data) {
  21501. return
  21502. } // Consider data may be not persistent.
  21503. var dataItem = data.getRawDataItem(dataIndex)
  21504. if (dataItem == null) {
  21505. return
  21506. }
  21507. var store = data.getStore()
  21508. var sourceFormat = store.getSource().sourceFormat
  21509. if (dim != null) {
  21510. var dimIndex = data.getDimensionIndex(dim)
  21511. var property = store.getDimensionProperty(dimIndex)
  21512. return getRawSourceValueGetter(sourceFormat)(
  21513. dataItem,
  21514. dimIndex,
  21515. property
  21516. )
  21517. } else {
  21518. var result = dataItem
  21519. if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  21520. result = getDataItemValue(dataItem)
  21521. }
  21522. return result
  21523. }
  21524. }
  21525. var DIMENSION_LABEL_REG = /\{@(.+?)\}/g
  21526. var DataFormatMixin = /** @class */ (function () {
  21527. function DataFormatMixin() {}
  21528. /**
  21529. * Get params for formatter
  21530. */ DataFormatMixin.prototype.getDataParams = function (
  21531. dataIndex,
  21532. dataType
  21533. ) {
  21534. var data = this.getData(dataType)
  21535. var rawValue = this.getRawValue(dataIndex, dataType)
  21536. var rawDataIndex = data.getRawIndex(dataIndex)
  21537. var name = data.getName(dataIndex)
  21538. var itemOpt = data.getRawDataItem(dataIndex)
  21539. var style = data.getItemVisual(dataIndex, 'style')
  21540. var color =
  21541. style &&
  21542. style[data.getItemVisual(dataIndex, 'drawType') || 'fill']
  21543. var borderColor = style && style.stroke
  21544. var mainType = this.mainType
  21545. var isSeries = mainType === 'series'
  21546. var userOutput = data.userOutput && data.userOutput.get()
  21547. return {
  21548. componentType: mainType,
  21549. componentSubType: this.subType,
  21550. componentIndex: this.componentIndex,
  21551. seriesType: isSeries ? this.subType : null,
  21552. seriesIndex: this.seriesIndex,
  21553. seriesId: isSeries ? this.id : null,
  21554. seriesName: isSeries ? this.name : null,
  21555. name: name,
  21556. dataIndex: rawDataIndex,
  21557. data: itemOpt,
  21558. dataType: dataType,
  21559. value: rawValue,
  21560. color: color,
  21561. borderColor: borderColor,
  21562. dimensionNames: userOutput ? userOutput.fullDimensions : null,
  21563. encode: userOutput ? userOutput.encode : null, // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  21564. $vars: ['seriesName', 'name', 'value']
  21565. }
  21566. }
  21567. /**
  21568. * Format label
  21569. * @param dataIndex
  21570. * @param status 'normal' by default
  21571. * @param dataType
  21572. * @param labelDimIndex Only used in some chart that
  21573. * use formatter in different dimensions, like radar.
  21574. * @param formatter Formatter given outside.
  21575. * @return return null/undefined if no formatter
  21576. */ DataFormatMixin.prototype.getFormattedLabel = function (
  21577. dataIndex,
  21578. status,
  21579. dataType,
  21580. labelDimIndex,
  21581. formatter,
  21582. extendParams
  21583. ) {
  21584. status = status || 'normal'
  21585. var data = this.getData(dataType)
  21586. var params = this.getDataParams(dataIndex, dataType)
  21587. if (extendParams) {
  21588. params.value = extendParams.interpolatedValue
  21589. }
  21590. if (labelDimIndex != null && isArray(params.value)) {
  21591. params.value = params.value[labelDimIndex]
  21592. }
  21593. if (!formatter) {
  21594. var itemModel = data.getItemModel(dataIndex) // @ts-ignore
  21595. formatter = itemModel.get(
  21596. status === 'normal'
  21597. ? ['label', 'formatter']
  21598. : [status, 'label', 'formatter']
  21599. )
  21600. }
  21601. if (isFunction(formatter)) {
  21602. params.status = status
  21603. params.dimensionIndex = labelDimIndex
  21604. return formatter(params)
  21605. } else if (isString(formatter)) {
  21606. var str = formatTpl(formatter, params) // Support 'aaa{@[3]}bbb{@product}ccc'.
  21607. // Do not support '}' in dim name util have to.
  21608. return str.replace(
  21609. DIMENSION_LABEL_REG,
  21610. function (origin, dimStr) {
  21611. var len = dimStr.length
  21612. var dimLoose = dimStr
  21613. if (
  21614. dimLoose.charAt(0) === '[' &&
  21615. dimLoose.charAt(len - 1) === ']'
  21616. ) {
  21617. dimLoose = +dimLoose.slice(1, len - 1) // Also support: '[]' => 0
  21618. }
  21619. var val = retrieveRawValue(data, dataIndex, dimLoose)
  21620. if (
  21621. extendParams &&
  21622. isArray(extendParams.interpolatedValue)
  21623. ) {
  21624. var dimIndex = data.getDimensionIndex(dimLoose)
  21625. if (dimIndex >= 0) {
  21626. val = extendParams.interpolatedValue[dimIndex]
  21627. }
  21628. }
  21629. return val != null ? val + '' : ''
  21630. }
  21631. )
  21632. }
  21633. }
  21634. /**
  21635. * Get raw value in option
  21636. */ DataFormatMixin.prototype.getRawValue = function (
  21637. idx,
  21638. dataType
  21639. ) {
  21640. return retrieveRawValue(this.getData(dataType), idx)
  21641. }
  21642. /**
  21643. * Should be implemented.
  21644. * @param {number} dataIndex
  21645. * @param {boolean} [multipleSeries=false]
  21646. * @param {string} [dataType]
  21647. */ DataFormatMixin.prototype.formatTooltip = function (
  21648. dataIndex,
  21649. multipleSeries,
  21650. dataType
  21651. ) {
  21652. // Empty function
  21653. return
  21654. }
  21655. return DataFormatMixin
  21656. })() // but guess little chance has been used outside. Do we need to backward
  21657. // compat it?
  21658. // type TooltipFormatResultLegacyObject = {
  21659. // // `html` means the markup language text, either in 'html' or 'richText'.
  21660. // // The name `html` is not appropriate becuase in 'richText' it is not a HTML
  21661. // // string. But still support it for backward compat.
  21662. // html: string;
  21663. // markers: Dictionary<ColorString>;
  21664. // };
  21665. /**
  21666. * For backward compat, normalize the return from `formatTooltip`.
  21667. */ function normalizeTooltipFormatResult(result) {
  21668. var markupText // let markers: Dictionary<ColorString>;
  21669. var markupFragment
  21670. if (isObject$2(result)) {
  21671. if (result.type) {
  21672. markupFragment = result
  21673. } // else {
  21674. // markupText = (result as TooltipFormatResultLegacyObject).html;
  21675. // markers = (result as TooltipFormatResultLegacyObject).markers;
  21676. // if (markersExisting) {
  21677. // markers = zrUtil.merge(markersExisting, markers);
  21678. // }
  21679. // }
  21680. } else {
  21681. markupText = result
  21682. }
  21683. return {
  21684. text: markupText, // markers: markers || markersExisting,
  21685. frag: markupFragment
  21686. }
  21687. }
  21688. /**
  21689. * @param {Object} define
  21690. * @return See the return of `createTask`.
  21691. */ function createTask(define) {
  21692. return new Task(define)
  21693. }
  21694. var Task = /** @class */ (function () {
  21695. function Task(define) {
  21696. define = define || {}
  21697. this._reset = define.reset
  21698. this._plan = define.plan
  21699. this._count = define.count
  21700. this._onDirty = define.onDirty
  21701. this._dirty = true
  21702. }
  21703. /**
  21704. * @param step Specified step.
  21705. * @param skip Skip customer perform call.
  21706. * @param modBy Sampling window size.
  21707. * @param modDataCount Sampling count.
  21708. * @return whether unfinished.
  21709. */ Task.prototype.perform = function (performArgs) {
  21710. var upTask = this._upstream
  21711. var skip = performArgs && performArgs.skip // TODO some refactor.
  21712. // Pull data. Must pull data each time, because context.data
  21713. // may be updated by Series.setData.
  21714. if (this._dirty && upTask) {
  21715. var context = this.context
  21716. context.data = context.outputData = upTask.context.outputData
  21717. }
  21718. if (this.__pipeline) {
  21719. this.__pipeline.currentTask = this
  21720. }
  21721. var planResult
  21722. if (this._plan && !skip) {
  21723. planResult = this._plan(this.context)
  21724. } // Support sharding by mod, which changes the render sequence and makes the rendered graphic
  21725. // elements uniformed distributed when progress, especially when moving or zooming.
  21726. var lastModBy = normalizeModBy(this._modBy)
  21727. var lastModDataCount = this._modDataCount || 0
  21728. var modBy = normalizeModBy(performArgs && performArgs.modBy)
  21729. var modDataCount = (performArgs && performArgs.modDataCount) || 0
  21730. if (lastModBy !== modBy || lastModDataCount !== modDataCount) {
  21731. planResult = 'reset'
  21732. }
  21733. function normalizeModBy(val) {
  21734. !(val >= 1) && (val = 1) // jshint ignore:line
  21735. return val
  21736. }
  21737. var forceFirstProgress
  21738. if (this._dirty || planResult === 'reset') {
  21739. this._dirty = false
  21740. forceFirstProgress = this._doReset(skip)
  21741. }
  21742. this._modBy = modBy
  21743. this._modDataCount = modDataCount
  21744. var step = performArgs && performArgs.step
  21745. if (upTask) {
  21746. this._dueEnd = upTask._outputDueEnd
  21747. } // DataTask or overallTask
  21748. else {
  21749. this._dueEnd = this._count
  21750. ? this._count(this.context)
  21751. : Infinity
  21752. } // Note: Stubs, that its host overall task let it has progress, has progress.
  21753. // If no progress, pass index from upstream to downstream each time plan called.
  21754. if (this._progress) {
  21755. var start = this._dueIndex
  21756. var end = Math.min(
  21757. step != null ? this._dueIndex + step : Infinity,
  21758. this._dueEnd
  21759. )
  21760. if (!skip && (forceFirstProgress || start < end)) {
  21761. var progress = this._progress
  21762. if (isArray(progress)) {
  21763. for (var i = 0; i < progress.length; i++) {
  21764. this._doProgress(
  21765. progress[i],
  21766. start,
  21767. end,
  21768. modBy,
  21769. modDataCount
  21770. )
  21771. }
  21772. } else {
  21773. this._doProgress(progress, start, end, modBy, modDataCount)
  21774. }
  21775. }
  21776. this._dueIndex = end // If no `outputDueEnd`, assume that output data and
  21777. // input data is the same, so use `dueIndex` as `outputDueEnd`.
  21778. var outputDueEnd =
  21779. this._settedOutputEnd != null ? this._settedOutputEnd : end
  21780. this._outputDueEnd = outputDueEnd
  21781. } else {
  21782. // (1) Some overall task has no progress.
  21783. // (2) Stubs, that its host overall task do not let it has progress, has no progress.
  21784. // This should always be performed so it can be passed to downstream.
  21785. this._dueIndex = this._outputDueEnd =
  21786. this._settedOutputEnd != null
  21787. ? this._settedOutputEnd
  21788. : this._dueEnd
  21789. }
  21790. return this.unfinished()
  21791. }
  21792. Task.prototype.dirty = function () {
  21793. this._dirty = true
  21794. this._onDirty && this._onDirty(this.context)
  21795. }
  21796. Task.prototype._doProgress = function (
  21797. progress,
  21798. start,
  21799. end,
  21800. modBy,
  21801. modDataCount
  21802. ) {
  21803. iterator.reset(start, end, modBy, modDataCount)
  21804. this._callingProgress = progress
  21805. this._callingProgress(
  21806. {
  21807. start: start,
  21808. end: end,
  21809. count: end - start,
  21810. next: iterator.next
  21811. },
  21812. this.context
  21813. )
  21814. }
  21815. Task.prototype._doReset = function (skip) {
  21816. this._dueIndex = this._outputDueEnd = this._dueEnd = 0
  21817. this._settedOutputEnd = null
  21818. var progress
  21819. var forceFirstProgress
  21820. if (!skip && this._reset) {
  21821. progress = this._reset(this.context)
  21822. if (progress && progress.progress) {
  21823. forceFirstProgress = progress.forceFirstProgress
  21824. progress = progress.progress
  21825. } // To simplify no progress checking, array must has item.
  21826. if (isArray(progress) && !progress.length) {
  21827. progress = null
  21828. }
  21829. }
  21830. this._progress = progress
  21831. this._modBy = this._modDataCount = null
  21832. var downstream = this._downstream
  21833. downstream && downstream.dirty()
  21834. return forceFirstProgress
  21835. }
  21836. Task.prototype.unfinished = function () {
  21837. return this._progress && this._dueIndex < this._dueEnd
  21838. }
  21839. /**
  21840. * @param downTask The downstream task.
  21841. * @return The downstream task.
  21842. */ Task.prototype.pipe = function (downTask) {
  21843. if (this._downstream !== downTask || this._dirty) {
  21844. this._downstream = downTask
  21845. downTask._upstream = this
  21846. downTask.dirty()
  21847. }
  21848. }
  21849. Task.prototype.dispose = function () {
  21850. if (this._disposed) {
  21851. return
  21852. }
  21853. this._upstream && (this._upstream._downstream = null)
  21854. this._downstream && (this._downstream._upstream = null)
  21855. this._dirty = false
  21856. this._disposed = true
  21857. }
  21858. Task.prototype.getUpstream = function () {
  21859. return this._upstream
  21860. }
  21861. Task.prototype.getDownstream = function () {
  21862. return this._downstream
  21863. }
  21864. Task.prototype.setOutputEnd = function (end) {
  21865. // This only happend in dataTask, dataZoom, map, currently.
  21866. // where dataZoom do not set end each time, but only set
  21867. // when reset. So we should record the setted end, in case
  21868. // that the stub of dataZoom perform again and earse the
  21869. // setted end by upstream.
  21870. this._outputDueEnd = this._settedOutputEnd = end
  21871. }
  21872. return Task
  21873. })()
  21874. var iterator = (function () {
  21875. var end
  21876. var current
  21877. var modBy
  21878. var modDataCount
  21879. var winCount
  21880. var it = {
  21881. reset: function reset(s, e, sStep, sCount) {
  21882. current = s
  21883. end = e
  21884. modBy = sStep
  21885. modDataCount = sCount
  21886. winCount = Math.ceil(modDataCount / modBy)
  21887. it.next =
  21888. modBy > 1 && modDataCount > 0 ? modNext : sequentialNext
  21889. }
  21890. }
  21891. return it
  21892. function sequentialNext() {
  21893. return current < end ? current++ : null
  21894. }
  21895. function modNext() {
  21896. var dataIndex =
  21897. (current % winCount) * modBy + Math.ceil(current / winCount)
  21898. var result =
  21899. current >= end
  21900. ? null
  21901. : dataIndex < modDataCount
  21902. ? dataIndex // If modDataCount is smaller than data.count() (consider `appendData` case),
  21903. : // Use normal linear rendering mode.
  21904. current
  21905. current++
  21906. return result
  21907. }
  21908. })() ///////////////////////////////////////////////////////////
  21909. // For stream debug (Should be commented out after used!)
  21910. // @usage: printTask(this, 'begin');
  21911. // @usage: printTask(this, null, {someExtraProp});
  21912. // @usage: Use `__idxInPipeline` as conditional breakpiont.
  21913. //
  21914. // window.printTask = function (task: any, prefix: string, extra: { [key: string]: unknown }): void {
  21915. // window.ecTaskUID == null && (window.ecTaskUID = 0);
  21916. // task.uidDebug == null && (task.uidDebug = `task_${window.ecTaskUID++}`);
  21917. // task.agent && task.agent.uidDebug == null && (task.agent.uidDebug = `task_${window.ecTaskUID++}`);
  21918. // let props = [];
  21919. // if (task.__pipeline) {
  21920. // let val = `${task.__idxInPipeline}/${task.__pipeline.tail.__idxInPipeline} ${task.agent ? '(stub)' : ''}`;
  21921. // props.push({text: '__idxInPipeline/total', value: val});
  21922. // } else {
  21923. // let stubCount = 0;
  21924. // task.agentStubMap.each(() => stubCount++);
  21925. // props.push({text: 'idx', value: `overall (stubs: ${stubCount})`});
  21926. // }
  21927. // props.push({text: 'uid', value: task.uidDebug});
  21928. // if (task.__pipeline) {
  21929. // props.push({text: 'pipelineId', value: task.__pipeline.id});
  21930. // task.agent && props.push(
  21931. // {text: 'stubFor', value: task.agent.uidDebug}
  21932. // );
  21933. // }
  21934. // props.push(
  21935. // {text: 'dirty', value: task._dirty},
  21936. // {text: 'dueIndex', value: task._dueIndex},
  21937. // {text: 'dueEnd', value: task._dueEnd},
  21938. // {text: 'outputDueEnd', value: task._outputDueEnd}
  21939. // );
  21940. // if (extra) {
  21941. // Object.keys(extra).forEach(key => {
  21942. // props.push({text: key, value: extra[key]});
  21943. // });
  21944. // }
  21945. // let args = ['color: blue'];
  21946. // let msg = `%c[${prefix || 'T'}] %c` + props.map(item => (
  21947. // args.push('color: green', 'color: red'),
  21948. // `${item.text}: %c${item.value}`
  21949. // )).join('%c, ');
  21950. // console.log.apply(console, [msg].concat(args));
  21951. // // console.log(this);
  21952. // };
  21953. // window.printPipeline = function (task: any, prefix: string) {
  21954. // const pipeline = task.__pipeline;
  21955. // let currTask = pipeline.head;
  21956. // while (currTask) {
  21957. // window.printTask(currTask, prefix);
  21958. // currTask = currTask._downstream;
  21959. // }
  21960. // };
  21961. // window.showChain = function (chainHeadTask) {
  21962. // var chain = [];
  21963. // var task = chainHeadTask;
  21964. // while (task) {
  21965. // chain.push({
  21966. // task: task,
  21967. // up: task._upstream,
  21968. // down: task._downstream,
  21969. // idxInPipeline: task.__idxInPipeline
  21970. // });
  21971. // task = task._downstream;
  21972. // }
  21973. // return chain;
  21974. // };
  21975. // window.findTaskInChain = function (task, chainHeadTask) {
  21976. // let chain = window.showChain(chainHeadTask);
  21977. // let result = [];
  21978. // for (let i = 0; i < chain.length; i++) {
  21979. // let chainItem = chain[i];
  21980. // if (chainItem.task === task) {
  21981. // result.push(i);
  21982. // }
  21983. // }
  21984. // return result;
  21985. // };
  21986. // window.printChainAEachInChainB = function (chainHeadTaskA, chainHeadTaskB) {
  21987. // let chainA = window.showChain(chainHeadTaskA);
  21988. // for (let i = 0; i < chainA.length; i++) {
  21989. // console.log('chainAIdx:', i, 'inChainB:', window.findTaskInChain(chainA[i].task, chainHeadTaskB));
  21990. // }
  21991. // };
  21992. /**
  21993. * Convert raw the value in to inner value in List.
  21994. *
  21995. * [Performance sensitive]
  21996. *
  21997. * [Caution]: this is the key logic of user value parser.
  21998. * For backward compatibiliy, do not modify it until have to!
  21999. */ function parseDataValue(
  22000. value, // For high performance, do not omit the second param.
  22001. opt
  22002. ) {
  22003. // Performance sensitive.
  22004. var dimType = opt && opt.type
  22005. if (dimType === 'ordinal') {
  22006. // If given value is a category string
  22007. return value
  22008. }
  22009. if (
  22010. dimType === 'time' && // spead up when using timestamp
  22011. !isNumber(value) &&
  22012. value != null &&
  22013. value !== '-'
  22014. ) {
  22015. value = +parseDate(value)
  22016. } // dimType defaults 'number'.
  22017. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  22018. // parse to NaN.
  22019. // number-like string (like ' 123 ') can be converted to a number.
  22020. // where null/undefined or other string will be converted to NaN.
  22021. return value == null || value === ''
  22022. ? NaN // If string (like '-'), using '+' parse to NaN
  22023. : // If object, also parse to NaN
  22024. +value
  22025. }
  22026. var valueParserMap = createHashMap({
  22027. number: function number(val) {
  22028. // Do not use `numericToNumber` here. We have by defualt `numericToNumber`.
  22029. // Here the number parser can have loose rule:
  22030. // enable to cut suffix: "120px" => 120, "14%" => 14.
  22031. return parseFloat(val)
  22032. },
  22033. time: function time(val) {
  22034. // return timestamp.
  22035. return +parseDate(val)
  22036. },
  22037. trim: function trim(val) {
  22038. return isString(val) ? trim$1(val) : val
  22039. }
  22040. })
  22041. function getRawValueParser(type) {
  22042. return valueParserMap.get(type)
  22043. }
  22044. var ORDER_COMPARISON_OP_MAP = {
  22045. lt: function lt(lval, rval) {
  22046. return lval < rval
  22047. },
  22048. lte: function lte(lval, rval) {
  22049. return lval <= rval
  22050. },
  22051. gt: function gt(lval, rval) {
  22052. return lval > rval
  22053. },
  22054. gte: function gte(lval, rval) {
  22055. return lval >= rval
  22056. }
  22057. }
  22058. var FilterOrderComparator = /** @class */ (function () {
  22059. function FilterOrderComparator(op, rval) {
  22060. if (!isNumber(rval)) {
  22061. var errMsg = ''
  22062. throwError(errMsg)
  22063. }
  22064. this._opFn = ORDER_COMPARISON_OP_MAP[op]
  22065. this._rvalFloat = numericToNumber(rval)
  22066. } // Performance sensitive.
  22067. FilterOrderComparator.prototype.evaluate = function (lval) {
  22068. // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.
  22069. return isNumber(lval)
  22070. ? this._opFn(lval, this._rvalFloat)
  22071. : this._opFn(numericToNumber(lval), this._rvalFloat)
  22072. }
  22073. return FilterOrderComparator
  22074. })()
  22075. var SortOrderComparator = /** @class */ (function () {
  22076. /**
  22077. * @param order by defualt: 'asc'
  22078. * @param incomparable by defualt: Always on the tail.
  22079. * That is, if 'asc' => 'max', if 'desc' => 'min'
  22080. * See the definition of "incomparable" in [SORT_COMPARISON_RULE]
  22081. */ function SortOrderComparator(order, incomparable) {
  22082. var isDesc = order === 'desc'
  22083. this._resultLT = isDesc ? 1 : -1
  22084. if (incomparable == null) {
  22085. incomparable = isDesc ? 'min' : 'max'
  22086. }
  22087. this._incomparable = incomparable === 'min' ? -Infinity : Infinity
  22088. } // See [SORT_COMPARISON_RULE].
  22089. // Performance sensitive.
  22090. SortOrderComparator.prototype.evaluate = function (lval, rval) {
  22091. // Most cases is 'number', and typeof maybe 10 times faseter than parseFloat.
  22092. var lvalFloat = isNumber(lval) ? lval : numericToNumber(lval)
  22093. var rvalFloat = isNumber(rval) ? rval : numericToNumber(rval)
  22094. var lvalNotNumeric = isNaN(lvalFloat)
  22095. var rvalNotNumeric = isNaN(rvalFloat)
  22096. if (lvalNotNumeric) {
  22097. lvalFloat = this._incomparable
  22098. }
  22099. if (rvalNotNumeric) {
  22100. rvalFloat = this._incomparable
  22101. }
  22102. if (lvalNotNumeric && rvalNotNumeric) {
  22103. var lvalIsStr = isString(lval)
  22104. var rvalIsStr = isString(rval)
  22105. if (lvalIsStr) {
  22106. lvalFloat = rvalIsStr ? lval : 0
  22107. }
  22108. if (rvalIsStr) {
  22109. rvalFloat = lvalIsStr ? rval : 0
  22110. }
  22111. }
  22112. return lvalFloat < rvalFloat
  22113. ? this._resultLT
  22114. : lvalFloat > rvalFloat
  22115. ? -this._resultLT
  22116. : 0
  22117. }
  22118. return SortOrderComparator
  22119. })()
  22120. var FilterEqualityComparator = /** @class */ (function () {
  22121. function FilterEqualityComparator(isEq, rval) {
  22122. this._rval = rval
  22123. this._isEQ = isEq
  22124. this._rvalTypeof = _typeof(rval)
  22125. this._rvalFloat = numericToNumber(rval)
  22126. } // Performance sensitive.
  22127. FilterEqualityComparator.prototype.evaluate = function (lval) {
  22128. var eqResult = lval === this._rval
  22129. if (!eqResult) {
  22130. var lvalTypeof = _typeof(lval)
  22131. if (
  22132. lvalTypeof !== this._rvalTypeof &&
  22133. (lvalTypeof === 'number' || this._rvalTypeof === 'number')
  22134. ) {
  22135. eqResult = numericToNumber(lval) === this._rvalFloat
  22136. }
  22137. }
  22138. return this._isEQ ? eqResult : !eqResult
  22139. }
  22140. return FilterEqualityComparator
  22141. })()
  22142. /**
  22143. * [FILTER_COMPARISON_RULE]
  22144. * `lt`|`lte`|`gt`|`gte`:
  22145. * + rval must be a number. And lval will be converted to number (`numericToNumber`) to compare.
  22146. * `eq`:
  22147. * + If same type, compare with `===`.
  22148. * + If there is one number, convert to number (`numericToNumber`) to compare.
  22149. * + Else return `false`.
  22150. * `ne`:
  22151. * + Not `eq`.
  22152. *
  22153. *
  22154. * [SORT_COMPARISON_RULE]
  22155. * All the values are grouped into three categories:
  22156. * + "numeric" (number and numeric string)
  22157. * + "non-numeric-string" (string that excluding numeric string)
  22158. * + "others"
  22159. * "numeric" vs "numeric": values are ordered by number order.
  22160. * "non-numeric-string" vs "non-numeric-string": values are ordered by ES spec (#sec-abstract-relational-comparison).
  22161. * "others" vs "others": do not change order (always return 0).
  22162. * "numeric" vs "non-numeric-string": "non-numeric-string" is treated as "incomparable".
  22163. * "number" vs "others": "others" is treated as "incomparable".
  22164. * "non-numeric-string" vs "others": "others" is treated as "incomparable".
  22165. * "incomparable" will be seen as -Infinity or Infinity (depends on the settings).
  22166. * MEMO:
  22167. * non-numeric string sort make sence when need to put the items with the same tag together.
  22168. * But if we support string sort, we still need to avoid the misleading like `'2' > '12'`,
  22169. * So we treat "numeric-string" sorted by number order rather than string comparison.
  22170. *
  22171. *
  22172. * [CHECK_LIST_OF_THE_RULE_DESIGN]
  22173. * + Do not support string comparison until required. And also need to
  22174. * void the misleading of "2" > "12".
  22175. * + Should avoid the misleading case:
  22176. * `" 22 " gte "22"` is `true` but `" 22 " eq "22"` is `false`.
  22177. * + JS bad case should be avoided: null <= 0, [] <= 0, ' ' <= 0, ...
  22178. * + Only "numeric" can be converted to comparable number, otherwise converted to NaN.
  22179. * See `util/number.ts#numericToNumber`.
  22180. *
  22181. * @return If `op` is not `RelationalOperator`, return null;
  22182. */ function createFilterComparator(op, rval) {
  22183. return op === 'eq' || op === 'ne'
  22184. ? new FilterEqualityComparator(op === 'eq', rval)
  22185. : hasOwn(ORDER_COMPARISON_OP_MAP, op)
  22186. ? new FilterOrderComparator(op, rval)
  22187. : null
  22188. }
  22189. /**
  22190. * TODO: disable writable.
  22191. * This structure will be exposed to users.
  22192. */ var ExternalSource = /** @class */ (function () {
  22193. function ExternalSource() {}
  22194. ExternalSource.prototype.getRawData = function () {
  22195. // Only built-in transform available.
  22196. throw new Error('not supported')
  22197. }
  22198. ExternalSource.prototype.getRawDataItem = function (dataIndex) {
  22199. // Only built-in transform available.
  22200. throw new Error('not supported')
  22201. }
  22202. ExternalSource.prototype.cloneRawData = function () {
  22203. return
  22204. }
  22205. /**
  22206. * @return If dimension not found, return null/undefined.
  22207. */ ExternalSource.prototype.getDimensionInfo = function (dim) {
  22208. return
  22209. }
  22210. /**
  22211. * dimensions defined if and only if either:
  22212. * (a) dataset.dimensions are declared.
  22213. * (b) dataset data include dimensions definitions in data (detected or via specified `sourceHeader`).
  22214. * If dimensions are defined, `dimensionInfoAll` is corresponding to
  22215. * the defined dimensions.
  22216. * Otherwise, `dimensionInfoAll` is determined by data columns.
  22217. * @return Always return an array (even empty array).
  22218. */ ExternalSource.prototype.cloneAllDimensionInfo = function () {
  22219. return
  22220. }
  22221. ExternalSource.prototype.count = function () {
  22222. return
  22223. }
  22224. /**
  22225. * Only support by dimension index.
  22226. * No need to support by dimension name in transform function,
  22227. * becuase transform function is not case-specific, no need to use name literally.
  22228. */ ExternalSource.prototype.retrieveValue = function (
  22229. dataIndex,
  22230. dimIndex
  22231. ) {
  22232. return
  22233. }
  22234. ExternalSource.prototype.retrieveValueFromItem = function (
  22235. dataItem,
  22236. dimIndex
  22237. ) {
  22238. return
  22239. }
  22240. ExternalSource.prototype.convertValue = function (rawVal, dimInfo) {
  22241. return parseDataValue(rawVal, dimInfo)
  22242. }
  22243. return ExternalSource
  22244. })()
  22245. function createExternalSource(internalSource, externalTransform) {
  22246. var extSource = new ExternalSource()
  22247. var data = internalSource.data
  22248. var sourceFormat = (extSource.sourceFormat =
  22249. internalSource.sourceFormat)
  22250. var sourceHeaderCount = internalSource.startIndex
  22251. var errMsg = ''
  22252. if (internalSource.seriesLayoutBy !== SERIES_LAYOUT_BY_COLUMN) {
  22253. throwError(errMsg)
  22254. } // [MEMO]
  22255. // Create a new dimensions structure for exposing.
  22256. // Do not expose all dimension info to users directly.
  22257. // Becuase the dimension is probably auto detected from data and not might reliable.
  22258. // Should not lead the transformers to think that is relialbe and return it.
  22259. // See [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.
  22260. var dimensions = []
  22261. var dimsByName = {}
  22262. var dimsDef = internalSource.dimensionsDefine
  22263. if (dimsDef) {
  22264. each$7(dimsDef, function (dimDef, idx) {
  22265. var name = dimDef.name
  22266. var dimDefExt = {
  22267. index: idx,
  22268. name: name,
  22269. displayName: dimDef.displayName
  22270. }
  22271. dimensions.push(dimDefExt) // Users probably not sepcify dimension name. For simplicity, data transform
  22272. // do not generate dimension name.
  22273. if (name != null) {
  22274. // Dimension name should not be duplicated.
  22275. // For simplicity, data transform forbid name duplication, do not generate
  22276. // new name like module `completeDimensions.ts` did, but just tell users.
  22277. var errMsg_1 = ''
  22278. if (hasOwn(dimsByName, name)) {
  22279. throwError(errMsg_1)
  22280. }
  22281. dimsByName[name] = dimDefExt
  22282. }
  22283. })
  22284. } // If dimension definitions are not defined and can not be detected.
  22285. // e.g., pure data `[[11, 22], ...]`.
  22286. else {
  22287. for (
  22288. var i = 0;
  22289. i < internalSource.dimensionsDetectedCount || 0;
  22290. i++
  22291. ) {
  22292. // Do not generete name or anything others. The consequence process in
  22293. // `transform` or `series` probably have there own name generation strategry.
  22294. dimensions.push({ index: i })
  22295. }
  22296. } // Implement public methods:
  22297. var rawItemGetter = getRawSourceItemGetter(
  22298. sourceFormat,
  22299. SERIES_LAYOUT_BY_COLUMN
  22300. )
  22301. if (externalTransform.__isBuiltIn) {
  22302. extSource.getRawDataItem = function (dataIndex) {
  22303. return rawItemGetter(
  22304. data,
  22305. sourceHeaderCount,
  22306. dimensions,
  22307. dataIndex
  22308. )
  22309. }
  22310. extSource.getRawData = bind$1(getRawData, null, internalSource)
  22311. }
  22312. extSource.cloneRawData = bind$1(cloneRawData, null, internalSource)
  22313. var rawCounter = getRawSourceDataCounter(
  22314. sourceFormat,
  22315. SERIES_LAYOUT_BY_COLUMN
  22316. )
  22317. extSource.count = bind$1(
  22318. rawCounter,
  22319. null,
  22320. data,
  22321. sourceHeaderCount,
  22322. dimensions
  22323. )
  22324. var rawValueGetter = getRawSourceValueGetter(sourceFormat)
  22325. extSource.retrieveValue = function (dataIndex, dimIndex) {
  22326. var rawItem = rawItemGetter(
  22327. data,
  22328. sourceHeaderCount,
  22329. dimensions,
  22330. dataIndex
  22331. )
  22332. return retrieveValueFromItem(rawItem, dimIndex)
  22333. }
  22334. var retrieveValueFromItem = (extSource.retrieveValueFromItem =
  22335. function (dataItem, dimIndex) {
  22336. if (dataItem == null) {
  22337. return
  22338. }
  22339. var dimDef = dimensions[dimIndex] // When `dimIndex` is `null`, `rawValueGetter` return the whole item.
  22340. if (dimDef) {
  22341. return rawValueGetter(dataItem, dimIndex, dimDef.name)
  22342. }
  22343. })
  22344. extSource.getDimensionInfo = bind$1(
  22345. getDimensionInfo,
  22346. null,
  22347. dimensions,
  22348. dimsByName
  22349. )
  22350. extSource.cloneAllDimensionInfo = bind$1(
  22351. cloneAllDimensionInfo,
  22352. null,
  22353. dimensions
  22354. )
  22355. return extSource
  22356. }
  22357. function getRawData(upstream) {
  22358. var sourceFormat = upstream.sourceFormat
  22359. if (!isSupportedSourceFormat(sourceFormat)) {
  22360. var errMsg = ''
  22361. throwError(errMsg)
  22362. }
  22363. return upstream.data
  22364. }
  22365. function cloneRawData(upstream) {
  22366. var sourceFormat = upstream.sourceFormat
  22367. var data = upstream.data
  22368. if (!isSupportedSourceFormat(sourceFormat)) {
  22369. var errMsg = ''
  22370. throwError(errMsg)
  22371. }
  22372. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  22373. var result = []
  22374. for (var i = 0, len = data.length; i < len; i++) {
  22375. // Not strictly clone for performance
  22376. result.push(data[i].slice())
  22377. }
  22378. return result
  22379. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  22380. var result = []
  22381. for (var i = 0, len = data.length; i < len; i++) {
  22382. // Not strictly clone for performance
  22383. result.push(extend({}, data[i]))
  22384. }
  22385. return result
  22386. }
  22387. }
  22388. function getDimensionInfo(dimensions, dimsByName, dim) {
  22389. if (dim == null) {
  22390. return
  22391. } // Keep the same logic as `List::getDimension` did.
  22392. if (
  22393. isNumber(dim) || // If being a number-like string but not being defined a dimension name.
  22394. (!isNaN(dim) && !hasOwn(dimsByName, dim))
  22395. ) {
  22396. return dimensions[dim]
  22397. } else if (hasOwn(dimsByName, dim)) {
  22398. return dimsByName[dim]
  22399. }
  22400. }
  22401. function cloneAllDimensionInfo(dimensions) {
  22402. return clone$3(dimensions)
  22403. }
  22404. var externalTransformMap = createHashMap()
  22405. function registerExternalTransform(externalTransform) {
  22406. externalTransform = clone$3(externalTransform)
  22407. var type = externalTransform.type
  22408. var errMsg = ''
  22409. if (!type) {
  22410. throwError(errMsg)
  22411. }
  22412. var typeParsed = type.split(':')
  22413. if (typeParsed.length !== 2) {
  22414. throwError(errMsg)
  22415. } // Namespace 'echarts:xxx' is official namespace, where the transforms should
  22416. // be called directly via 'xxx' rather than 'echarts:xxx'.
  22417. var isBuiltIn = false
  22418. if (typeParsed[0] === 'echarts') {
  22419. type = typeParsed[1]
  22420. isBuiltIn = true
  22421. }
  22422. externalTransform.__isBuiltIn = isBuiltIn
  22423. externalTransformMap.set(type, externalTransform)
  22424. }
  22425. function applyDataTransform(
  22426. rawTransOption,
  22427. sourceList,
  22428. infoForPrint
  22429. ) {
  22430. var pipedTransOption = normalizeToArray(rawTransOption)
  22431. var pipeLen = pipedTransOption.length
  22432. var errMsg = ''
  22433. if (!pipeLen) {
  22434. throwError(errMsg)
  22435. }
  22436. for (var i = 0, len = pipeLen; i < len; i++) {
  22437. var transOption = pipedTransOption[i]
  22438. sourceList = applySingleDataTransform(transOption, sourceList) // piped transform only support single input, except the fist one.
  22439. // piped transform only support single output, except the last one.
  22440. if (i !== len - 1) {
  22441. sourceList.length = Math.max(sourceList.length, 1)
  22442. }
  22443. }
  22444. return sourceList
  22445. }
  22446. function applySingleDataTransform(
  22447. transOption,
  22448. upSourceList,
  22449. infoForPrint, // If `pipeIndex` is null/undefined, no piped transform.
  22450. pipeIndex
  22451. ) {
  22452. var errMsg = ''
  22453. if (!upSourceList.length) {
  22454. throwError(errMsg)
  22455. }
  22456. if (!isObject$2(transOption)) {
  22457. throwError(errMsg)
  22458. }
  22459. var transType = transOption.type
  22460. var externalTransform = externalTransformMap.get(transType)
  22461. if (!externalTransform) {
  22462. throwError(errMsg)
  22463. } // Prepare source
  22464. var extUpSourceList = map$1(upSourceList, function (upSource) {
  22465. return createExternalSource(upSource, externalTransform)
  22466. })
  22467. var resultList = normalizeToArray(
  22468. externalTransform.transform({
  22469. upstream: extUpSourceList[0],
  22470. upstreamList: extUpSourceList,
  22471. config: clone$3(transOption.config)
  22472. })
  22473. )
  22474. return map$1(resultList, function (result, resultIndex) {
  22475. var errMsg = ''
  22476. if (!isObject$2(result)) {
  22477. throwError(errMsg)
  22478. }
  22479. if (!result.data) {
  22480. throwError(errMsg)
  22481. }
  22482. var sourceFormat = detectSourceFormat(result.data)
  22483. if (!isSupportedSourceFormat(sourceFormat)) {
  22484. throwError(errMsg)
  22485. }
  22486. var resultMetaRawOption
  22487. var firstUpSource = upSourceList[0]
  22488. /**
  22489. * Intuitively, the end users known the content of the original `dataset.source`,
  22490. * calucating the transform result in mind.
  22491. * Suppose the original `dataset.source` is:
  22492. * ```js
  22493. * [
  22494. * ['product', '2012', '2013', '2014', '2015'],
  22495. * ['AAA', 41.1, 30.4, 65.1, 53.3],
  22496. * ['BBB', 86.5, 92.1, 85.7, 83.1],
  22497. * ['CCC', 24.1, 67.2, 79.5, 86.4]
  22498. * ]
  22499. * ```
  22500. * The dimension info have to be detected from the source data.
  22501. * Some of the transformers (like filter, sort) will follow the dimension info
  22502. * of upstream, while others use new dimensions (like aggregate).
  22503. * Transformer can output a field `dimensions` to define the its own output dimensions.
  22504. * We also allow transformers to ignore the output `dimensions` field, and
  22505. * inherit the upstream dimensions definition. It can reduce the burden of handling
  22506. * dimensions in transformers.
  22507. *
  22508. * See also [DIMENSION_INHERIT_RULE] in `sourceManager.ts`.
  22509. */ if (
  22510. firstUpSource &&
  22511. resultIndex === 0 && // If transformer returns `dimensions`, it means that the transformer has different
  22512. // dimensions definitions. We do not inherit anything from upstream.
  22513. !result.dimensions
  22514. ) {
  22515. var startIndex = firstUpSource.startIndex // We copy the header of upstream to the result becuase:
  22516. // (1) The returned data always does not contain header line and can not be used
  22517. // as dimension-detection. In this case we can not use "detected dimensions" of
  22518. // upstream directly, because it might be detected based on different `seriesLayoutBy`.
  22519. // (2) We should support that the series read the upstream source in `seriesLayoutBy: 'row'`.
  22520. // So the original detected header should be add to the result, otherwise they can not be read.
  22521. if (startIndex) {
  22522. result.data = firstUpSource.data
  22523. .slice(0, startIndex)
  22524. .concat(result.data)
  22525. }
  22526. resultMetaRawOption = {
  22527. seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,
  22528. sourceHeader: startIndex,
  22529. dimensions: firstUpSource.metaRawOption.dimensions
  22530. }
  22531. } else {
  22532. resultMetaRawOption = {
  22533. seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN,
  22534. sourceHeader: 0,
  22535. dimensions: result.dimensions
  22536. }
  22537. }
  22538. return createSource(result.data, resultMetaRawOption, null)
  22539. })
  22540. }
  22541. function isSupportedSourceFormat(sourceFormat) {
  22542. return (
  22543. sourceFormat === SOURCE_FORMAT_ARRAY_ROWS ||
  22544. sourceFormat === SOURCE_FORMAT_OBJECT_ROWS
  22545. )
  22546. }
  22547. var UNDEFINED =
  22548. 'undefined' /* global Float64Array, Int32Array, Uint32Array, Uint16Array */ // Caution: MUST not use `new CtorUint32Array(arr, 0, len)`, because the Ctor of array is
  22549. // different from the Ctor of typed array.
  22550. var CtorUint32Array =
  22551. (typeof Uint32Array === 'undefined'
  22552. ? 'undefined'
  22553. : _typeof(Uint32Array)) === UNDEFINED
  22554. ? Array
  22555. : Uint32Array
  22556. var CtorUint16Array =
  22557. (typeof Uint16Array === 'undefined'
  22558. ? 'undefined'
  22559. : _typeof(Uint16Array)) === UNDEFINED
  22560. ? Array
  22561. : Uint16Array
  22562. var CtorInt32Array$1 =
  22563. (typeof Int32Array === 'undefined'
  22564. ? 'undefined'
  22565. : _typeof(Int32Array)) === UNDEFINED
  22566. ? Array
  22567. : Int32Array
  22568. var CtorFloat64Array =
  22569. (typeof Float64Array === 'undefined'
  22570. ? 'undefined'
  22571. : _typeof(Float64Array)) === UNDEFINED
  22572. ? Array
  22573. : Float64Array
  22574. /**
  22575. * Multi dimensional data store
  22576. */ var dataCtors = {
  22577. float: CtorFloat64Array,
  22578. int: CtorInt32Array$1, // Ordinal data type can be string or int
  22579. ordinal: Array,
  22580. number: Array,
  22581. time: CtorFloat64Array
  22582. }
  22583. var defaultDimValueGetters
  22584. function getIndicesCtor(rawCount) {
  22585. // The possible max value in this._indicies is always this._rawCount despite of filtering.
  22586. return rawCount > 65535 ? CtorUint32Array : CtorUint16Array
  22587. }
  22588. function getInitialExtent() {
  22589. return [Infinity, -Infinity]
  22590. }
  22591. function cloneChunk(originalChunk) {
  22592. var Ctor = originalChunk.constructor // Only shallow clone is enough when Array.
  22593. return Ctor === Array
  22594. ? originalChunk.slice()
  22595. : new Ctor(originalChunk)
  22596. }
  22597. function prepareStore(store, dimIdx, dimType, end, append) {
  22598. var DataCtor = dataCtors[dimType || 'float']
  22599. if (append) {
  22600. var oldStore = store[dimIdx]
  22601. var oldLen = oldStore && oldStore.length
  22602. if (!(oldLen === end)) {
  22603. var newStore = new DataCtor(end) // The cost of the copy is probably inconsiderable
  22604. // within the initial chunkSize.
  22605. for (var j = 0; j < oldLen; j++) {
  22606. newStore[j] = oldStore[j]
  22607. }
  22608. store[dimIdx] = newStore
  22609. }
  22610. } else {
  22611. store[dimIdx] = new DataCtor(end)
  22612. }
  22613. }
  22614. /**
  22615. * Basically, DataStore API keep immutable.
  22616. */ var DataStore = /** @class */ (function () {
  22617. function DataStore() {
  22618. this._chunks = [] // It will not be calculated util needed.
  22619. this._rawExtent = []
  22620. this._extent = []
  22621. this._count = 0
  22622. this._rawCount = 0
  22623. this._calcDimNameToIdx = createHashMap()
  22624. }
  22625. /**
  22626. * Initialize from data
  22627. */ DataStore.prototype.initData = function (
  22628. provider,
  22629. inputDimensions,
  22630. dimValueGetter
  22631. ) {
  22632. this._provider = provider // Clear
  22633. this._chunks = []
  22634. this._indices = null
  22635. this.getRawIndex = this._getRawIdxIdentity
  22636. var source = provider.getSource()
  22637. var defaultGetter = (this.defaultDimValueGetter =
  22638. defaultDimValueGetters[source.sourceFormat]) // Default dim value getter
  22639. this._dimValueGetter = dimValueGetter || defaultGetter // Reset raw extent.
  22640. this._rawExtent = []
  22641. shouldRetrieveDataByName(source)
  22642. this._dimensions = map$1(inputDimensions, function (dim) {
  22643. return {
  22644. // Only pick these two props. Not leak other properties like orderMeta.
  22645. type: dim.type,
  22646. property: dim.property
  22647. }
  22648. })
  22649. this._initDataFromProvider(0, provider.count())
  22650. }
  22651. DataStore.prototype.getProvider = function () {
  22652. return this._provider
  22653. }
  22654. /**
  22655. * Caution: even when a `source` instance owned by a series, the created data store
  22656. * may still be shared by different sereis (the source hash does not use all `source`
  22657. * props, see `sourceManager`). In this case, the `source` props that are not used in
  22658. * hash (like `source.dimensionDefine`) probably only belongs to a certain series and
  22659. * thus should not be fetch here.
  22660. */ DataStore.prototype.getSource = function () {
  22661. return this._provider.getSource()
  22662. }
  22663. /**
  22664. * @caution Only used in dataStack.
  22665. */ DataStore.prototype.ensureCalculationDimension = function (
  22666. dimName,
  22667. type
  22668. ) {
  22669. var calcDimNameToIdx = this._calcDimNameToIdx
  22670. var dimensions = this._dimensions
  22671. var calcDimIdx = calcDimNameToIdx.get(dimName)
  22672. if (calcDimIdx != null) {
  22673. if (dimensions[calcDimIdx].type === type) {
  22674. return calcDimIdx
  22675. }
  22676. } else {
  22677. calcDimIdx = dimensions.length
  22678. }
  22679. dimensions[calcDimIdx] = { type: type }
  22680. calcDimNameToIdx.set(dimName, calcDimIdx)
  22681. this._chunks[calcDimIdx] = new dataCtors[type || 'float'](
  22682. this._rawCount
  22683. )
  22684. this._rawExtent[calcDimIdx] = getInitialExtent()
  22685. return calcDimIdx
  22686. }
  22687. DataStore.prototype.collectOrdinalMeta = function (
  22688. dimIdx,
  22689. ordinalMeta
  22690. ) {
  22691. var chunk = this._chunks[dimIdx]
  22692. var dim = this._dimensions[dimIdx]
  22693. var rawExtents = this._rawExtent
  22694. var offset = dim.ordinalOffset || 0
  22695. var len = chunk.length
  22696. if (offset === 0) {
  22697. // We need to reset the rawExtent if collect is from start.
  22698. // Because this dimension may be guessed as number and calcuating a wrong extent.
  22699. rawExtents[dimIdx] = getInitialExtent()
  22700. }
  22701. var dimRawExtent = rawExtents[dimIdx] // Parse from previous data offset. len may be changed after appendData
  22702. for (var i = offset; i < len; i++) {
  22703. var val = (chunk[i] = ordinalMeta.parseAndCollect(chunk[i]))
  22704. if (!isNaN(val)) {
  22705. dimRawExtent[0] = Math.min(val, dimRawExtent[0])
  22706. dimRawExtent[1] = Math.max(val, dimRawExtent[1])
  22707. }
  22708. }
  22709. dim.ordinalMeta = ordinalMeta
  22710. dim.ordinalOffset = len
  22711. dim.type = 'ordinal' // Force to be ordinal
  22712. }
  22713. DataStore.prototype.getOrdinalMeta = function (dimIdx) {
  22714. var dimInfo = this._dimensions[dimIdx]
  22715. var ordinalMeta = dimInfo.ordinalMeta
  22716. return ordinalMeta
  22717. }
  22718. DataStore.prototype.getDimensionProperty = function (dimIndex) {
  22719. var item = this._dimensions[dimIndex]
  22720. return item && item.property
  22721. }
  22722. /**
  22723. * Caution: Can be only called on raw data (before `this._indices` created).
  22724. */ DataStore.prototype.appendData = function (data) {
  22725. var provider = this._provider
  22726. var start = this.count()
  22727. provider.appendData(data)
  22728. var end = provider.count()
  22729. if (!provider.persistent) {
  22730. end += start
  22731. }
  22732. if (start < end) {
  22733. this._initDataFromProvider(start, end, true)
  22734. }
  22735. return [start, end]
  22736. }
  22737. DataStore.prototype.appendValues = function (values, minFillLen) {
  22738. var chunks = this._chunks
  22739. var dimensions = this._dimensions
  22740. var dimLen = dimensions.length
  22741. var rawExtent = this._rawExtent
  22742. var start = this.count()
  22743. var end = start + Math.max(values.length, minFillLen || 0)
  22744. for (var i = 0; i < dimLen; i++) {
  22745. var dim = dimensions[i]
  22746. prepareStore(chunks, i, dim.type, end, true)
  22747. }
  22748. var emptyDataItem = []
  22749. for (var idx = start; idx < end; idx++) {
  22750. var sourceIdx = idx - start // Store the data by dimensions
  22751. for (var dimIdx = 0; dimIdx < dimLen; dimIdx++) {
  22752. var dim = dimensions[dimIdx]
  22753. var val = defaultDimValueGetters.arrayRows.call(
  22754. this,
  22755. values[sourceIdx] || emptyDataItem,
  22756. dim.property,
  22757. sourceIdx,
  22758. dimIdx
  22759. )
  22760. chunks[dimIdx][idx] = val
  22761. var dimRawExtent = rawExtent[dimIdx]
  22762. val < dimRawExtent[0] && (dimRawExtent[0] = val)
  22763. val > dimRawExtent[1] && (dimRawExtent[1] = val)
  22764. }
  22765. }
  22766. this._rawCount = this._count = end
  22767. return { start: start, end: end }
  22768. }
  22769. DataStore.prototype._initDataFromProvider = function (
  22770. start,
  22771. end,
  22772. append
  22773. ) {
  22774. var provider = this._provider
  22775. var chunks = this._chunks
  22776. var dimensions = this._dimensions
  22777. var dimLen = dimensions.length
  22778. var rawExtent = this._rawExtent
  22779. var dimNames = map$1(dimensions, function (dim) {
  22780. return dim.property
  22781. })
  22782. for (var i = 0; i < dimLen; i++) {
  22783. var dim = dimensions[i]
  22784. if (!rawExtent[i]) {
  22785. rawExtent[i] = getInitialExtent()
  22786. }
  22787. prepareStore(chunks, i, dim.type, end, append)
  22788. }
  22789. if (provider.fillStorage) {
  22790. provider.fillStorage(start, end, chunks, rawExtent)
  22791. } else {
  22792. var dataItem = []
  22793. for (var idx = start; idx < end; idx++) {
  22794. // NOTICE: Try not to write things into dataItem
  22795. dataItem = provider.getItem(idx, dataItem) // Each data item is value
  22796. // [1, 2]
  22797. // 2
  22798. // Bar chart, line chart which uses category axis
  22799. // only gives the 'y' value. 'x' value is the indices of category
  22800. // Use a tempValue to normalize the value to be a (x, y) value
  22801. // Store the data by dimensions
  22802. for (var dimIdx = 0; dimIdx < dimLen; dimIdx++) {
  22803. var dimStorage = chunks[dimIdx] // PENDING NULL is empty or zero
  22804. var val = this._dimValueGetter(
  22805. dataItem,
  22806. dimNames[dimIdx],
  22807. idx,
  22808. dimIdx
  22809. )
  22810. dimStorage[idx] = val
  22811. var dimRawExtent = rawExtent[dimIdx]
  22812. val < dimRawExtent[0] && (dimRawExtent[0] = val)
  22813. val > dimRawExtent[1] && (dimRawExtent[1] = val)
  22814. }
  22815. }
  22816. }
  22817. if (!provider.persistent && provider.clean) {
  22818. // Clean unused data if data source is typed array.
  22819. provider.clean()
  22820. }
  22821. this._rawCount = this._count = end // Reset data extent
  22822. this._extent = []
  22823. }
  22824. DataStore.prototype.count = function () {
  22825. return this._count
  22826. }
  22827. /**
  22828. * Get value. Return NaN if idx is out of range.
  22829. */ DataStore.prototype.get = function (dim, idx) {
  22830. if (!(idx >= 0 && idx < this._count)) {
  22831. return NaN
  22832. }
  22833. var dimStore = this._chunks[dim]
  22834. return dimStore ? dimStore[this.getRawIndex(idx)] : NaN
  22835. }
  22836. DataStore.prototype.getValues = function (dimensions, idx) {
  22837. var values = []
  22838. var dimArr = []
  22839. if (idx == null) {
  22840. idx = dimensions // TODO get all from store?
  22841. dimensions = [] // All dimensions
  22842. for (var i = 0; i < this._dimensions.length; i++) {
  22843. dimArr.push(i)
  22844. }
  22845. } else {
  22846. dimArr = dimensions
  22847. }
  22848. for (var i = 0, len = dimArr.length; i < len; i++) {
  22849. values.push(this.get(dimArr[i], idx))
  22850. }
  22851. return values
  22852. }
  22853. /**
  22854. * @param dim concrete dim
  22855. */ DataStore.prototype.getByRawIndex = function (dim, rawIdx) {
  22856. if (!(rawIdx >= 0 && rawIdx < this._rawCount)) {
  22857. return NaN
  22858. }
  22859. var dimStore = this._chunks[dim]
  22860. return dimStore ? dimStore[rawIdx] : NaN
  22861. }
  22862. /**
  22863. * Get sum of data in one dimension
  22864. */ DataStore.prototype.getSum = function (dim) {
  22865. var dimData = this._chunks[dim]
  22866. var sum = 0
  22867. if (dimData) {
  22868. for (var i = 0, len = this.count(); i < len; i++) {
  22869. var value = this.get(dim, i)
  22870. if (!isNaN(value)) {
  22871. sum += value
  22872. }
  22873. }
  22874. }
  22875. return sum
  22876. }
  22877. /**
  22878. * Get median of data in one dimension
  22879. */ DataStore.prototype.getMedian = function (dim) {
  22880. var dimDataArray = [] // map all data of one dimension
  22881. this.each([dim], function (val) {
  22882. if (!isNaN(val)) {
  22883. dimDataArray.push(val)
  22884. }
  22885. }) // TODO
  22886. // Use quick select?
  22887. var sortedDimDataArray = dimDataArray.sort(function (a, b) {
  22888. return a - b
  22889. })
  22890. var len = this.count() // calculate median
  22891. return len === 0
  22892. ? 0
  22893. : len % 2 === 1
  22894. ? sortedDimDataArray[(len - 1) / 2]
  22895. : (sortedDimDataArray[len / 2] +
  22896. sortedDimDataArray[len / 2 - 1]) /
  22897. 2
  22898. }
  22899. /**
  22900. * Retreive the index with given raw data index
  22901. */ DataStore.prototype.indexOfRawIndex = function (rawIndex) {
  22902. if (rawIndex >= this._rawCount || rawIndex < 0) {
  22903. return -1
  22904. }
  22905. if (!this._indices) {
  22906. return rawIndex
  22907. } // Indices are ascending
  22908. var indices = this._indices // If rawIndex === dataIndex
  22909. var rawDataIndex = indices[rawIndex]
  22910. if (
  22911. rawDataIndex != null &&
  22912. rawDataIndex < this._count &&
  22913. rawDataIndex === rawIndex
  22914. ) {
  22915. return rawIndex
  22916. }
  22917. var left = 0
  22918. var right = this._count - 1
  22919. while (left <= right) {
  22920. var mid = ((left + right) / 2) | 0
  22921. if (indices[mid] < rawIndex) {
  22922. left = mid + 1
  22923. } else if (indices[mid] > rawIndex) {
  22924. right = mid - 1
  22925. } else {
  22926. return mid
  22927. }
  22928. }
  22929. return -1
  22930. }
  22931. /**
  22932. * Retreive the index of nearest value
  22933. * @param dim
  22934. * @param value
  22935. * @param [maxDistance=Infinity]
  22936. * @return If and only if multiple indices has
  22937. * the same value, they are put to the result.
  22938. */ DataStore.prototype.indicesOfNearest = function (
  22939. dim,
  22940. value,
  22941. maxDistance
  22942. ) {
  22943. var chunks = this._chunks
  22944. var dimData = chunks[dim]
  22945. var nearestIndices = []
  22946. if (!dimData) {
  22947. return nearestIndices
  22948. }
  22949. if (maxDistance == null) {
  22950. maxDistance = Infinity
  22951. }
  22952. var minDist = Infinity
  22953. var minDiff = -1
  22954. var nearestIndicesLen = 0 // Check the test case of `test/ut/spec/data/SeriesData.js`.
  22955. for (var i = 0, len = this.count(); i < len; i++) {
  22956. var dataIndex = this.getRawIndex(i)
  22957. var diff = value - dimData[dataIndex]
  22958. var dist = Math.abs(diff)
  22959. if (dist <= maxDistance) {
  22960. // When the `value` is at the middle of `this.get(dim, i)` and `this.get(dim, i+1)`,
  22961. // we'd better not push both of them to `nearestIndices`, otherwise it is easy to
  22962. // get more than one item in `nearestIndices` (more specifically, in `tooltip`).
  22963. // So we chose the one that `diff >= 0` in this csae.
  22964. // But if `this.get(dim, i)` and `this.get(dim, j)` get the same value, both of them
  22965. // should be push to `nearestIndices`.
  22966. if (
  22967. dist < minDist ||
  22968. (dist === minDist && diff >= 0 && minDiff < 0)
  22969. ) {
  22970. minDist = dist
  22971. minDiff = diff
  22972. nearestIndicesLen = 0
  22973. }
  22974. if (diff === minDiff) {
  22975. nearestIndices[nearestIndicesLen++] = i
  22976. }
  22977. }
  22978. }
  22979. nearestIndices.length = nearestIndicesLen
  22980. return nearestIndices
  22981. }
  22982. DataStore.prototype.getIndices = function () {
  22983. var newIndices
  22984. var indices = this._indices
  22985. if (indices) {
  22986. var Ctor = indices.constructor
  22987. var thisCount = this._count // `new Array(a, b, c)` is different from `new Uint32Array(a, b, c)`.
  22988. if (Ctor === Array) {
  22989. newIndices = new Ctor(thisCount)
  22990. for (var i = 0; i < thisCount; i++) {
  22991. newIndices[i] = indices[i]
  22992. }
  22993. } else {
  22994. newIndices = new Ctor(indices.buffer, 0, thisCount)
  22995. }
  22996. } else {
  22997. var Ctor = getIndicesCtor(this._rawCount)
  22998. newIndices = new Ctor(this.count())
  22999. for (var i = 0; i < newIndices.length; i++) {
  23000. newIndices[i] = i
  23001. }
  23002. }
  23003. return newIndices
  23004. }
  23005. /**
  23006. * Data filter.
  23007. */ DataStore.prototype.filter = function (dims, cb) {
  23008. if (!this._count) {
  23009. return this
  23010. }
  23011. var newStore = this.clone()
  23012. var count = newStore.count()
  23013. var Ctor = getIndicesCtor(newStore._rawCount)
  23014. var newIndices = new Ctor(count)
  23015. var value = []
  23016. var dimSize = dims.length
  23017. var offset = 0
  23018. var dim0 = dims[0]
  23019. var chunks = newStore._chunks
  23020. for (var i = 0; i < count; i++) {
  23021. var keep = void 0
  23022. var rawIdx = newStore.getRawIndex(i) // Simple optimization
  23023. if (dimSize === 0) {
  23024. keep = cb(i)
  23025. } else if (dimSize === 1) {
  23026. var val = chunks[dim0][rawIdx]
  23027. keep = cb(val, i)
  23028. } else {
  23029. var k = 0
  23030. for (; k < dimSize; k++) {
  23031. value[k] = chunks[dims[k]][rawIdx]
  23032. }
  23033. value[k] = i
  23034. keep = cb.apply(null, value)
  23035. }
  23036. if (keep) {
  23037. newIndices[offset++] = rawIdx
  23038. }
  23039. } // Set indices after filtered.
  23040. if (offset < count) {
  23041. newStore._indices = newIndices
  23042. }
  23043. newStore._count = offset // Reset data extent
  23044. newStore._extent = []
  23045. newStore._updateGetRawIdx()
  23046. return newStore
  23047. }
  23048. /**
  23049. * Select data in range. (For optimization of filter)
  23050. * (Manually inline code, support 5 million data filtering in data zoom.)
  23051. */ DataStore.prototype.selectRange = function (range) {
  23052. var newStore = this.clone()
  23053. var len = newStore._count
  23054. if (!len) {
  23055. return this
  23056. }
  23057. var dims = keys(range)
  23058. var dimSize = dims.length
  23059. if (!dimSize) {
  23060. return this
  23061. }
  23062. var originalCount = newStore.count()
  23063. var Ctor = getIndicesCtor(newStore._rawCount)
  23064. var newIndices = new Ctor(originalCount)
  23065. var offset = 0
  23066. var dim0 = dims[0]
  23067. var min = range[dim0][0]
  23068. var max = range[dim0][1]
  23069. var storeArr = newStore._chunks
  23070. var quickFinished = false
  23071. if (!newStore._indices) {
  23072. // Extreme optimization for common case. About 2x faster in chrome.
  23073. var idx = 0
  23074. if (dimSize === 1) {
  23075. var dimStorage = storeArr[dims[0]]
  23076. for (var i = 0; i < len; i++) {
  23077. var val = dimStorage[i] // NaN will not be filtered. Consider the case, in line chart, empty
  23078. // value indicates the line should be broken. But for the case like
  23079. // scatter plot, a data item with empty value will not be rendered,
  23080. // but the axis extent may be effected if some other dim of the data
  23081. // item has value. Fortunately it is not a significant negative effect.
  23082. if ((val >= min && val <= max) || isNaN(val)) {
  23083. newIndices[offset++] = idx
  23084. }
  23085. idx++
  23086. }
  23087. quickFinished = true
  23088. } else if (dimSize === 2) {
  23089. var dimStorage = storeArr[dims[0]]
  23090. var dimStorage2 = storeArr[dims[1]]
  23091. var min2 = range[dims[1]][0]
  23092. var max2 = range[dims[1]][1]
  23093. for (var i = 0; i < len; i++) {
  23094. var val = dimStorage[i]
  23095. var val2 = dimStorage2[i] // Do not filter NaN, see comment above.
  23096. if (
  23097. ((val >= min && val <= max) || isNaN(val)) &&
  23098. ((val2 >= min2 && val2 <= max2) || isNaN(val2))
  23099. ) {
  23100. newIndices[offset++] = idx
  23101. }
  23102. idx++
  23103. }
  23104. quickFinished = true
  23105. }
  23106. }
  23107. if (!quickFinished) {
  23108. if (dimSize === 1) {
  23109. for (var i = 0; i < originalCount; i++) {
  23110. var rawIndex = newStore.getRawIndex(i)
  23111. var val = storeArr[dims[0]][rawIndex] // Do not filter NaN, see comment above.
  23112. if ((val >= min && val <= max) || isNaN(val)) {
  23113. newIndices[offset++] = rawIndex
  23114. }
  23115. }
  23116. } else {
  23117. for (var i = 0; i < originalCount; i++) {
  23118. var keep = true
  23119. var rawIndex = newStore.getRawIndex(i)
  23120. for (var k = 0; k < dimSize; k++) {
  23121. var dimk = dims[k]
  23122. var val = storeArr[dimk][rawIndex] // Do not filter NaN, see comment above.
  23123. if (val < range[dimk][0] || val > range[dimk][1]) {
  23124. keep = false
  23125. }
  23126. }
  23127. if (keep) {
  23128. newIndices[offset++] = newStore.getRawIndex(i)
  23129. }
  23130. }
  23131. }
  23132. } // Set indices after filtered.
  23133. if (offset < originalCount) {
  23134. newStore._indices = newIndices
  23135. }
  23136. newStore._count = offset // Reset data extent
  23137. newStore._extent = []
  23138. newStore._updateGetRawIdx()
  23139. return newStore
  23140. } // /**
  23141. // * Data mapping to a plain array
  23142. // */
  23143. // mapArray(dims: DimensionIndex[], cb: MapArrayCb): any[] {
  23144. // const result: any[] = [];
  23145. // this.each(dims, function () {
  23146. // result.push(cb && (cb as MapArrayCb).apply(null, arguments));
  23147. // });
  23148. // return result;
  23149. // }
  23150. /**
  23151. * Data mapping to a new List with given dimensions
  23152. */ DataStore.prototype.map = function (dims, cb) {
  23153. // TODO only clone picked chunks.
  23154. var target = this.clone(dims)
  23155. this._updateDims(target, dims, cb)
  23156. return target
  23157. }
  23158. /**
  23159. * @caution Danger!! Only used in dataStack.
  23160. */ DataStore.prototype.modify = function (dims, cb) {
  23161. this._updateDims(this, dims, cb)
  23162. }
  23163. DataStore.prototype._updateDims = function (target, dims, cb) {
  23164. var targetChunks = target._chunks
  23165. var tmpRetValue = []
  23166. var dimSize = dims.length
  23167. var dataCount = target.count()
  23168. var values = []
  23169. var rawExtent = target._rawExtent
  23170. for (var i = 0; i < dims.length; i++) {
  23171. rawExtent[dims[i]] = getInitialExtent()
  23172. }
  23173. for (var dataIndex = 0; dataIndex < dataCount; dataIndex++) {
  23174. var rawIndex = target.getRawIndex(dataIndex)
  23175. for (var k = 0; k < dimSize; k++) {
  23176. values[k] = targetChunks[dims[k]][rawIndex]
  23177. }
  23178. values[dimSize] = dataIndex
  23179. var retValue = cb && cb.apply(null, values)
  23180. if (retValue != null) {
  23181. // a number or string (in oridinal dimension)?
  23182. if (_typeof(retValue) !== 'object') {
  23183. tmpRetValue[0] = retValue
  23184. retValue = tmpRetValue
  23185. }
  23186. for (var i = 0; i < retValue.length; i++) {
  23187. var dim = dims[i]
  23188. var val = retValue[i]
  23189. var rawExtentOnDim = rawExtent[dim]
  23190. var dimStore = targetChunks[dim]
  23191. if (dimStore) {
  23192. dimStore[rawIndex] = val
  23193. }
  23194. if (val < rawExtentOnDim[0]) {
  23195. rawExtentOnDim[0] = val
  23196. }
  23197. if (val > rawExtentOnDim[1]) {
  23198. rawExtentOnDim[1] = val
  23199. }
  23200. }
  23201. }
  23202. }
  23203. }
  23204. /**
  23205. * Large data down sampling using largest-triangle-three-buckets
  23206. * @param {string} valueDimension
  23207. * @param {number} targetCount
  23208. */ DataStore.prototype.lttbDownSample = function (
  23209. valueDimension,
  23210. rate
  23211. ) {
  23212. var target = this.clone([valueDimension], true)
  23213. var targetStorage = target._chunks
  23214. var dimStore = targetStorage[valueDimension]
  23215. var len = this.count()
  23216. var sampledIndex = 0
  23217. var frameSize = Math.floor(1 / rate)
  23218. var currentRawIndex = this.getRawIndex(0)
  23219. var maxArea
  23220. var area
  23221. var nextRawIndex
  23222. var newIndices = new (getIndicesCtor(this._rawCount))(
  23223. Math.min((Math.ceil(len / frameSize) + 2) * 2, len)
  23224. ) // First frame use the first data.
  23225. newIndices[sampledIndex++] = currentRawIndex
  23226. for (var i = 1; i < len - 1; i += frameSize) {
  23227. var nextFrameStart = Math.min(i + frameSize, len - 1)
  23228. var nextFrameEnd = Math.min(i + frameSize * 2, len)
  23229. var avgX = (nextFrameEnd + nextFrameStart) / 2
  23230. var avgY = 0
  23231. for (var idx = nextFrameStart; idx < nextFrameEnd; idx++) {
  23232. var rawIndex = this.getRawIndex(idx)
  23233. var y = dimStore[rawIndex]
  23234. if (isNaN(y)) {
  23235. continue
  23236. }
  23237. avgY += y
  23238. }
  23239. avgY /= nextFrameEnd - nextFrameStart
  23240. var frameStart = i
  23241. var frameEnd = Math.min(i + frameSize, len)
  23242. var pointAX = i - 1
  23243. var pointAY = dimStore[currentRawIndex]
  23244. maxArea = -1
  23245. nextRawIndex = frameStart
  23246. var firstNaNIndex = -1
  23247. var countNaN = 0 // Find a point from current frame that construct a triangel with largest area with previous selected point
  23248. // And the average of next frame.
  23249. for (var idx = frameStart; idx < frameEnd; idx++) {
  23250. var rawIndex = this.getRawIndex(idx)
  23251. var y = dimStore[rawIndex]
  23252. if (isNaN(y)) {
  23253. countNaN++
  23254. if (firstNaNIndex < 0) {
  23255. firstNaNIndex = rawIndex
  23256. }
  23257. continue
  23258. } // Calculate triangle area over three buckets
  23259. area = Math.abs(
  23260. (pointAX - avgX) * (y - pointAY) -
  23261. (pointAX - idx) * (avgY - pointAY)
  23262. )
  23263. if (area > maxArea) {
  23264. maxArea = area
  23265. nextRawIndex = rawIndex // Next a is this b
  23266. }
  23267. }
  23268. if (countNaN > 0 && countNaN < frameEnd - frameStart) {
  23269. // Append first NaN point in every bucket.
  23270. // It is necessary to ensure the correct order of indices.
  23271. newIndices[sampledIndex++] = Math.min(
  23272. firstNaNIndex,
  23273. nextRawIndex
  23274. )
  23275. nextRawIndex = Math.max(firstNaNIndex, nextRawIndex)
  23276. }
  23277. newIndices[sampledIndex++] = nextRawIndex
  23278. currentRawIndex = nextRawIndex // This a is the next a (chosen b)
  23279. } // First frame use the last data.
  23280. newIndices[sampledIndex++] = this.getRawIndex(len - 1)
  23281. target._count = sampledIndex
  23282. target._indices = newIndices
  23283. target.getRawIndex = this._getRawIdx
  23284. return target
  23285. }
  23286. /**
  23287. * Large data down sampling on given dimension
  23288. * @param sampleIndex Sample index for name and id
  23289. */ DataStore.prototype.downSample = function (
  23290. dimension,
  23291. rate,
  23292. sampleValue,
  23293. sampleIndex
  23294. ) {
  23295. var target = this.clone([dimension], true)
  23296. var targetStorage = target._chunks
  23297. var frameValues = []
  23298. var frameSize = Math.floor(1 / rate)
  23299. var dimStore = targetStorage[dimension]
  23300. var len = this.count()
  23301. var rawExtentOnDim = (target._rawExtent[dimension] =
  23302. getInitialExtent())
  23303. var newIndices = new (getIndicesCtor(this._rawCount))(
  23304. Math.ceil(len / frameSize)
  23305. )
  23306. var offset = 0
  23307. for (var i = 0; i < len; i += frameSize) {
  23308. // Last frame
  23309. if (frameSize > len - i) {
  23310. frameSize = len - i
  23311. frameValues.length = frameSize
  23312. }
  23313. for (var k = 0; k < frameSize; k++) {
  23314. var dataIdx = this.getRawIndex(i + k)
  23315. frameValues[k] = dimStore[dataIdx]
  23316. }
  23317. var value = sampleValue(frameValues)
  23318. var sampleFrameIdx = this.getRawIndex(
  23319. Math.min(i + sampleIndex(frameValues, value) || 0, len - 1)
  23320. ) // Only write value on the filtered data
  23321. dimStore[sampleFrameIdx] = value
  23322. if (value < rawExtentOnDim[0]) {
  23323. rawExtentOnDim[0] = value
  23324. }
  23325. if (value > rawExtentOnDim[1]) {
  23326. rawExtentOnDim[1] = value
  23327. }
  23328. newIndices[offset++] = sampleFrameIdx
  23329. }
  23330. target._count = offset
  23331. target._indices = newIndices
  23332. target._updateGetRawIdx()
  23333. return target
  23334. }
  23335. /**
  23336. * Data iteration
  23337. * @param ctx default this
  23338. * @example
  23339. * list.each('x', function (x, idx) {});
  23340. * list.each(['x', 'y'], function (x, y, idx) {});
  23341. * list.each(function (idx) {})
  23342. */ DataStore.prototype.each = function (dims, cb) {
  23343. if (!this._count) {
  23344. return
  23345. }
  23346. var dimSize = dims.length
  23347. var chunks = this._chunks
  23348. for (var i = 0, len = this.count(); i < len; i++) {
  23349. var rawIdx = this.getRawIndex(i) // Simple optimization
  23350. switch (dimSize) {
  23351. case 0:
  23352. cb(i)
  23353. break
  23354. case 1:
  23355. cb(chunks[dims[0]][rawIdx], i)
  23356. break
  23357. case 2:
  23358. cb(chunks[dims[0]][rawIdx], chunks[dims[1]][rawIdx], i)
  23359. break
  23360. default:
  23361. var k = 0
  23362. var value = []
  23363. for (; k < dimSize; k++) {
  23364. value[k] = chunks[dims[k]][rawIdx]
  23365. } // Index
  23366. value[k] = i
  23367. cb.apply(null, value)
  23368. }
  23369. }
  23370. }
  23371. /**
  23372. * Get extent of data in one dimension
  23373. */ DataStore.prototype.getDataExtent = function (dim) {
  23374. // Make sure use concrete dim as cache name.
  23375. var dimData = this._chunks[dim]
  23376. var initialExtent = getInitialExtent()
  23377. if (!dimData) {
  23378. return initialExtent
  23379. } // Make more strict checkings to ensure hitting cache.
  23380. var currEnd = this.count() // Consider the most cases when using data zoom, `getDataExtent`
  23381. // happened before filtering. We cache raw extent, which is not
  23382. // necessary to be cleared and recalculated when restore data.
  23383. var useRaw = !this._indices
  23384. var dimExtent
  23385. if (useRaw) {
  23386. return this._rawExtent[dim].slice()
  23387. }
  23388. dimExtent = this._extent[dim]
  23389. if (dimExtent) {
  23390. return dimExtent.slice()
  23391. }
  23392. dimExtent = initialExtent
  23393. var min = dimExtent[0]
  23394. var max = dimExtent[1]
  23395. for (var i = 0; i < currEnd; i++) {
  23396. var rawIdx = this.getRawIndex(i)
  23397. var value = dimData[rawIdx]
  23398. value < min && (min = value)
  23399. value > max && (max = value)
  23400. }
  23401. dimExtent = [min, max]
  23402. this._extent[dim] = dimExtent
  23403. return dimExtent
  23404. }
  23405. /**
  23406. * Get raw data item
  23407. */ DataStore.prototype.getRawDataItem = function (idx) {
  23408. var rawIdx = this.getRawIndex(idx)
  23409. if (!this._provider.persistent) {
  23410. var val = []
  23411. var chunks = this._chunks
  23412. for (var i = 0; i < chunks.length; i++) {
  23413. val.push(chunks[i][rawIdx])
  23414. }
  23415. return val
  23416. } else {
  23417. return this._provider.getItem(rawIdx)
  23418. }
  23419. }
  23420. /**
  23421. * Clone shallow.
  23422. *
  23423. * @param clonedDims Determine which dims to clone. Will share the data if not specified.
  23424. */ DataStore.prototype.clone = function (
  23425. clonedDims,
  23426. ignoreIndices
  23427. ) {
  23428. var target = new DataStore()
  23429. var chunks = this._chunks
  23430. var clonedDimsMap =
  23431. clonedDims &&
  23432. reduce(
  23433. clonedDims,
  23434. function (obj, dimIdx) {
  23435. obj[dimIdx] = true
  23436. return obj
  23437. },
  23438. {}
  23439. )
  23440. if (clonedDimsMap) {
  23441. for (var i = 0; i < chunks.length; i++) {
  23442. // Not clone if dim is not picked.
  23443. target._chunks[i] = !clonedDimsMap[i]
  23444. ? chunks[i]
  23445. : cloneChunk(chunks[i])
  23446. }
  23447. } else {
  23448. target._chunks = chunks
  23449. }
  23450. this._copyCommonProps(target)
  23451. if (!ignoreIndices) {
  23452. target._indices = this._cloneIndices()
  23453. }
  23454. target._updateGetRawIdx()
  23455. return target
  23456. }
  23457. DataStore.prototype._copyCommonProps = function (target) {
  23458. target._count = this._count
  23459. target._rawCount = this._rawCount
  23460. target._provider = this._provider
  23461. target._dimensions = this._dimensions
  23462. target._extent = clone$3(this._extent)
  23463. target._rawExtent = clone$3(this._rawExtent)
  23464. }
  23465. DataStore.prototype._cloneIndices = function () {
  23466. if (this._indices) {
  23467. var Ctor = this._indices.constructor
  23468. var indices = void 0
  23469. if (Ctor === Array) {
  23470. var thisCount = this._indices.length
  23471. indices = new Ctor(thisCount)
  23472. for (var i = 0; i < thisCount; i++) {
  23473. indices[i] = this._indices[i]
  23474. }
  23475. } else {
  23476. indices = new Ctor(this._indices)
  23477. }
  23478. return indices
  23479. }
  23480. return null
  23481. }
  23482. DataStore.prototype._getRawIdxIdentity = function (idx) {
  23483. return idx
  23484. }
  23485. DataStore.prototype._getRawIdx = function (idx) {
  23486. if (idx < this._count && idx >= 0) {
  23487. return this._indices[idx]
  23488. }
  23489. return -1
  23490. }
  23491. DataStore.prototype._updateGetRawIdx = function () {
  23492. this.getRawIndex = this._indices
  23493. ? this._getRawIdx
  23494. : this._getRawIdxIdentity
  23495. }
  23496. DataStore.internalField = (function () {
  23497. function getDimValueSimply(
  23498. dataItem,
  23499. property,
  23500. dataIndex,
  23501. dimIndex
  23502. ) {
  23503. return parseDataValue(
  23504. dataItem[dimIndex],
  23505. this._dimensions[dimIndex]
  23506. )
  23507. }
  23508. defaultDimValueGetters = {
  23509. arrayRows: getDimValueSimply,
  23510. objectRows: function objectRows(
  23511. dataItem,
  23512. property,
  23513. dataIndex,
  23514. dimIndex
  23515. ) {
  23516. return parseDataValue(
  23517. dataItem[property],
  23518. this._dimensions[dimIndex]
  23519. )
  23520. },
  23521. keyedColumns: getDimValueSimply,
  23522. original: function original(
  23523. dataItem,
  23524. property,
  23525. dataIndex,
  23526. dimIndex
  23527. ) {
  23528. // Performance sensitive, do not use modelUtil.getDataItemValue.
  23529. // If dataItem is an plain object with no value field, the let `value`
  23530. // will be assigned with the object, but it will be tread correctly
  23531. // in the `convertValue`.
  23532. var value =
  23533. dataItem &&
  23534. (dataItem.value == null ? dataItem : dataItem.value)
  23535. return parseDataValue(
  23536. value instanceof Array
  23537. ? value[dimIndex] // If value is a single number or something else not array.
  23538. : value,
  23539. this._dimensions[dimIndex]
  23540. )
  23541. },
  23542. typedArray: function typedArray(
  23543. dataItem,
  23544. property,
  23545. dataIndex,
  23546. dimIndex
  23547. ) {
  23548. return dataItem[dimIndex]
  23549. }
  23550. }
  23551. })()
  23552. return DataStore
  23553. })()
  23554. /**
  23555. * [REQUIREMENT_MEMO]:
  23556. * (0) `metaRawOption` means `dimensions`/`sourceHeader`/`seriesLayoutBy` in raw option.
  23557. * (1) Keep support the feature: `metaRawOption` can be specified both on `series` and
  23558. * `root-dataset`. Them on `series` has higher priority.
  23559. * (2) Do not support to set `metaRawOption` on a `non-root-dataset`, because it might
  23560. * confuse users: whether those props indicate how to visit the upstream source or visit
  23561. * the transform result source, and some transforms has nothing to do with these props,
  23562. * and some transforms might have multiple upstream.
  23563. * (3) Transforms should specify `metaRawOption` in each output, just like they can be
  23564. * declared in `root-dataset`.
  23565. * (4) At present only support visit source in `SERIES_LAYOUT_BY_COLUMN` in transforms.
  23566. * That is for reducing complexity in transfroms.
  23567. * PENDING: Whether to provide transposition transform?
  23568. *
  23569. * [IMPLEMENTAION_MEMO]:
  23570. * "sourceVisitConfig" are calculated from `metaRawOption` and `data`.
  23571. * They will not be calculated until `source` is about to be visited (to prevent from
  23572. * duplicate calcuation). `source` is visited only in series and input to transforms.
  23573. *
  23574. * [DIMENSION_INHERIT_RULE]:
  23575. * By default the dimensions are inherited from ancestors, unless a transform return
  23576. * a new dimensions definition.
  23577. * Consider the case:
  23578. * ```js
  23579. * dataset: [{
  23580. * source: [ ['Product', 'Sales', 'Prise'], ['Cookies', 321, 44.21], ...]
  23581. * }, {
  23582. * transform: { type: 'filter', ... }
  23583. * }]
  23584. * dataset: [{
  23585. * dimension: ['Product', 'Sales', 'Prise'],
  23586. * source: [ ['Cookies', 321, 44.21], ...]
  23587. * }, {
  23588. * transform: { type: 'filter', ... }
  23589. * }]
  23590. * ```
  23591. * The two types of option should have the same behavior after transform.
  23592. *
  23593. *
  23594. * [SCENARIO]:
  23595. * (1) Provide source data directly:
  23596. * ```js
  23597. * series: {
  23598. * encode: {...},
  23599. * dimensions: [...]
  23600. * seriesLayoutBy: 'row',
  23601. * data: [[...]]
  23602. * }
  23603. * ```
  23604. * (2) Series refer to dataset.
  23605. * ```js
  23606. * series: [{
  23607. * encode: {...}
  23608. * // Ignore datasetIndex means `datasetIndex: 0`
  23609. * // and the dimensions defination in dataset is used
  23610. * }, {
  23611. * encode: {...},
  23612. * seriesLayoutBy: 'column',
  23613. * datasetIndex: 1
  23614. * }]
  23615. * ```
  23616. * (3) dataset transform
  23617. * ```js
  23618. * dataset: [{
  23619. * source: [...]
  23620. * }, {
  23621. * source: [...]
  23622. * }, {
  23623. * // By default from 0.
  23624. * transform: { type: 'filter', config: {...} }
  23625. * }, {
  23626. * // Piped.
  23627. * transform: [
  23628. * { type: 'filter', config: {...} },
  23629. * { type: 'sort', config: {...} }
  23630. * ]
  23631. * }, {
  23632. * id: 'regressionData',
  23633. * fromDatasetIndex: 1,
  23634. * // Third-party transform
  23635. * transform: { type: 'ecStat:regression', config: {...} }
  23636. * }, {
  23637. * // retrieve the extra result.
  23638. * id: 'regressionFormula',
  23639. * fromDatasetId: 'regressionData',
  23640. * fromTransformResult: 1
  23641. * }]
  23642. * ```
  23643. */ var SourceManager = /** @class */ (function () {
  23644. function SourceManager(sourceHost) {
  23645. // Cached source. Do not repeat calculating if not dirty.
  23646. this._sourceList = []
  23647. this._storeList = [] // version sign of each upstream source manager.
  23648. this._upstreamSignList = []
  23649. this._versionSignBase = 0
  23650. this._dirty = true
  23651. this._sourceHost = sourceHost
  23652. }
  23653. /**
  23654. * Mark dirty.
  23655. */ SourceManager.prototype.dirty = function () {
  23656. this._setLocalSource([], [])
  23657. this._storeList = []
  23658. this._dirty = true
  23659. }
  23660. SourceManager.prototype._setLocalSource = function (
  23661. sourceList,
  23662. upstreamSignList
  23663. ) {
  23664. this._sourceList = sourceList
  23665. this._upstreamSignList = upstreamSignList
  23666. this._versionSignBase++
  23667. if (this._versionSignBase > 9e10) {
  23668. this._versionSignBase = 0
  23669. }
  23670. }
  23671. /**
  23672. * For detecting whether the upstream source is dirty, so that
  23673. * the local cached source (in `_sourceList`) should be discarded.
  23674. */ SourceManager.prototype._getVersionSign = function () {
  23675. return this._sourceHost.uid + '_' + this._versionSignBase
  23676. }
  23677. /**
  23678. * Always return a source instance. Otherwise throw error.
  23679. */ SourceManager.prototype.prepareSource = function () {
  23680. // For the case that call `setOption` multiple time but no data changed,
  23681. // cache the result source to prevent from repeating transform.
  23682. if (this._isDirty()) {
  23683. this._createSource()
  23684. this._dirty = false
  23685. }
  23686. }
  23687. SourceManager.prototype._createSource = function () {
  23688. this._setLocalSource([], [])
  23689. var sourceHost = this._sourceHost
  23690. var upSourceMgrList = this._getUpstreamSourceManagers()
  23691. var hasUpstream = !!upSourceMgrList.length
  23692. var resultSourceList
  23693. var upstreamSignList
  23694. if (isSeries(sourceHost)) {
  23695. var seriesModel = sourceHost
  23696. var data = void 0
  23697. var sourceFormat = void 0
  23698. var upSource = void 0 // Has upstream dataset
  23699. if (hasUpstream) {
  23700. var upSourceMgr = upSourceMgrList[0]
  23701. upSourceMgr.prepareSource()
  23702. upSource = upSourceMgr.getSource()
  23703. data = upSource.data
  23704. sourceFormat = upSource.sourceFormat
  23705. upstreamSignList = [upSourceMgr._getVersionSign()]
  23706. } // Series data is from own.
  23707. else {
  23708. data = seriesModel.get('data', true)
  23709. sourceFormat = isTypedArray(data)
  23710. ? SOURCE_FORMAT_TYPED_ARRAY
  23711. : SOURCE_FORMAT_ORIGINAL
  23712. upstreamSignList = []
  23713. } // See [REQUIREMENT_MEMO], merge settings on series and parent dataset if it is root.
  23714. var newMetaRawOption = this._getSourceMetaRawOption() || {}
  23715. var upMetaRawOption = (upSource && upSource.metaRawOption) || {}
  23716. var seriesLayoutBy =
  23717. retrieve2(
  23718. newMetaRawOption.seriesLayoutBy,
  23719. upMetaRawOption.seriesLayoutBy
  23720. ) || null
  23721. var sourceHeader = retrieve2(
  23722. newMetaRawOption.sourceHeader,
  23723. upMetaRawOption.sourceHeader
  23724. ) // Note here we should not use `upSource.dimensionsDefine`. Consider the case:
  23725. // `upSource.dimensionsDefine` is detected by `seriesLayoutBy: 'column'`,
  23726. // but series need `seriesLayoutBy: 'row'`.
  23727. var dimensions = retrieve2(
  23728. newMetaRawOption.dimensions,
  23729. upMetaRawOption.dimensions
  23730. ) // We share source with dataset as much as possible
  23731. // to avoid extra memroy cost of high dimensional data.
  23732. var needsCreateSource =
  23733. seriesLayoutBy !== upMetaRawOption.seriesLayoutBy ||
  23734. !!sourceHeader !== !!upMetaRawOption.sourceHeader ||
  23735. dimensions
  23736. resultSourceList = needsCreateSource
  23737. ? [
  23738. createSource(
  23739. data,
  23740. {
  23741. seriesLayoutBy: seriesLayoutBy,
  23742. sourceHeader: sourceHeader,
  23743. dimensions: dimensions
  23744. },
  23745. sourceFormat
  23746. )
  23747. ]
  23748. : []
  23749. } else {
  23750. var datasetModel = sourceHost // Has upstream dataset.
  23751. if (hasUpstream) {
  23752. var result = this._applyTransform(upSourceMgrList)
  23753. resultSourceList = result.sourceList
  23754. upstreamSignList = result.upstreamSignList
  23755. } // Is root dataset.
  23756. else {
  23757. var sourceData = datasetModel.get('source', true)
  23758. resultSourceList = [
  23759. createSource(
  23760. sourceData,
  23761. this._getSourceMetaRawOption(),
  23762. null
  23763. )
  23764. ]
  23765. upstreamSignList = []
  23766. }
  23767. }
  23768. this._setLocalSource(resultSourceList, upstreamSignList)
  23769. }
  23770. SourceManager.prototype._applyTransform = function (upMgrList) {
  23771. var datasetModel = this._sourceHost
  23772. var transformOption = datasetModel.get('transform', true)
  23773. var fromTransformResult = datasetModel.get(
  23774. 'fromTransformResult',
  23775. true
  23776. )
  23777. if (fromTransformResult != null) {
  23778. var errMsg = ''
  23779. if (upMgrList.length !== 1) {
  23780. doThrow(errMsg)
  23781. }
  23782. }
  23783. var sourceList
  23784. var upSourceList = []
  23785. var upstreamSignList = []
  23786. each$7(upMgrList, function (upMgr) {
  23787. upMgr.prepareSource()
  23788. var upSource = upMgr.getSource(fromTransformResult || 0)
  23789. var errMsg = ''
  23790. if (fromTransformResult != null && !upSource) {
  23791. doThrow(errMsg)
  23792. }
  23793. upSourceList.push(upSource)
  23794. upstreamSignList.push(upMgr._getVersionSign())
  23795. })
  23796. if (transformOption) {
  23797. sourceList = applyDataTransform(transformOption, upSourceList, {
  23798. datasetIndex: datasetModel.componentIndex
  23799. })
  23800. } else if (fromTransformResult != null) {
  23801. sourceList = [cloneSourceShallow(upSourceList[0])]
  23802. }
  23803. return {
  23804. sourceList: sourceList,
  23805. upstreamSignList: upstreamSignList
  23806. }
  23807. }
  23808. SourceManager.prototype._isDirty = function () {
  23809. if (this._dirty) {
  23810. return true
  23811. } // All sourceList is from the some upsteam.
  23812. var upSourceMgrList = this._getUpstreamSourceManagers()
  23813. for (var i = 0; i < upSourceMgrList.length; i++) {
  23814. var upSrcMgr = upSourceMgrList[i]
  23815. if (
  23816. // Consider the case that there is ancestor diry, call it recursively.
  23817. // The performance is probably not an issue because usually the chain is not long.
  23818. upSrcMgr._isDirty() ||
  23819. this._upstreamSignList[i] !== upSrcMgr._getVersionSign()
  23820. ) {
  23821. return true
  23822. }
  23823. }
  23824. }
  23825. /**
  23826. * @param sourceIndex By defualt 0, means "main source".
  23827. * Most cases there is only one source.
  23828. */ SourceManager.prototype.getSource = function (sourceIndex) {
  23829. sourceIndex = sourceIndex || 0
  23830. var source = this._sourceList[sourceIndex]
  23831. if (!source) {
  23832. // Series may share source instance with dataset.
  23833. var upSourceMgrList = this._getUpstreamSourceManagers()
  23834. return (
  23835. upSourceMgrList[0] &&
  23836. upSourceMgrList[0].getSource(sourceIndex)
  23837. )
  23838. }
  23839. return source
  23840. }
  23841. /**
  23842. *
  23843. * Get a data store which can be shared across series.
  23844. * Only available for series.
  23845. *
  23846. * @param seriesDimRequest Dimensions that are generated in series.
  23847. * Should have been sorted by `storeDimIndex` asc.
  23848. */ SourceManager.prototype.getSharedDataStore = function (
  23849. seriesDimRequest
  23850. ) {
  23851. var schema = seriesDimRequest.makeStoreSchema()
  23852. return this._innerGetDataStore(
  23853. schema.dimensions,
  23854. seriesDimRequest.source,
  23855. schema.hash
  23856. )
  23857. }
  23858. SourceManager.prototype._innerGetDataStore = function (
  23859. storeDims,
  23860. seriesSource,
  23861. sourceReadKey
  23862. ) {
  23863. // TODO Can use other sourceIndex?
  23864. var sourceIndex = 0
  23865. var storeList = this._storeList
  23866. var cachedStoreMap = storeList[sourceIndex]
  23867. if (!cachedStoreMap) {
  23868. cachedStoreMap = storeList[sourceIndex] = {}
  23869. }
  23870. var cachedStore = cachedStoreMap[sourceReadKey]
  23871. if (!cachedStore) {
  23872. var upSourceMgr = this._getUpstreamSourceManagers()[0]
  23873. if (isSeries(this._sourceHost) && upSourceMgr) {
  23874. cachedStore = upSourceMgr._innerGetDataStore(
  23875. storeDims,
  23876. seriesSource,
  23877. sourceReadKey
  23878. )
  23879. } else {
  23880. cachedStore = new DataStore() // Always create store from source of series.
  23881. cachedStore.initData(
  23882. new DefaultDataProvider(seriesSource, storeDims.length),
  23883. storeDims
  23884. )
  23885. }
  23886. cachedStoreMap[sourceReadKey] = cachedStore
  23887. }
  23888. return cachedStore
  23889. }
  23890. /**
  23891. * PEDING: Is it fast enough?
  23892. * If no upstream, return empty array.
  23893. */ SourceManager.prototype._getUpstreamSourceManagers =
  23894. function () {
  23895. // Always get the relationship from the raw option.
  23896. // Do not cache the link of the dependency graph, so that
  23897. // no need to update them when change happen.
  23898. var sourceHost = this._sourceHost
  23899. if (isSeries(sourceHost)) {
  23900. var datasetModel = querySeriesUpstreamDatasetModel(sourceHost)
  23901. return !datasetModel ? [] : [datasetModel.getSourceManager()]
  23902. } else {
  23903. return map$1(
  23904. queryDatasetUpstreamDatasetModels(sourceHost),
  23905. function (datasetModel) {
  23906. return datasetModel.getSourceManager()
  23907. }
  23908. )
  23909. }
  23910. }
  23911. SourceManager.prototype._getSourceMetaRawOption = function () {
  23912. var sourceHost = this._sourceHost
  23913. var seriesLayoutBy
  23914. var sourceHeader
  23915. var dimensions
  23916. if (isSeries(sourceHost)) {
  23917. seriesLayoutBy = sourceHost.get('seriesLayoutBy', true)
  23918. sourceHeader = sourceHost.get('sourceHeader', true)
  23919. dimensions = sourceHost.get('dimensions', true)
  23920. } // See [REQUIREMENT_MEMO], `non-root-dataset` do not support them.
  23921. else if (!this._getUpstreamSourceManagers().length) {
  23922. var model = sourceHost
  23923. seriesLayoutBy = model.get('seriesLayoutBy', true)
  23924. sourceHeader = model.get('sourceHeader', true)
  23925. dimensions = model.get('dimensions', true)
  23926. }
  23927. return {
  23928. seriesLayoutBy: seriesLayoutBy,
  23929. sourceHeader: sourceHeader,
  23930. dimensions: dimensions
  23931. }
  23932. }
  23933. return SourceManager
  23934. })() // disable the transform merge, but do not disable transfrom clone from rawOption.
  23935. function disableTransformOptionMerge(datasetModel) {
  23936. var transformOption = datasetModel.option.transform
  23937. transformOption && setAsPrimitive(datasetModel.option.transform)
  23938. }
  23939. function isSeries(sourceHost) {
  23940. // Avoid circular dependency with Series.ts
  23941. return sourceHost.mainType === 'series'
  23942. }
  23943. function doThrow(errMsg) {
  23944. throw new Error(errMsg)
  23945. }
  23946. var TOOLTIP_LINE_HEIGHT_CSS = 'line-height:1' // TODO: more textStyle option
  23947. function getTooltipTextStyle(textStyle, renderMode) {
  23948. var nameFontColor = textStyle.color || '#6e7079'
  23949. var nameFontSize = textStyle.fontSize || 12
  23950. var nameFontWeight = textStyle.fontWeight || '400'
  23951. var valueFontColor = textStyle.color || '#464646'
  23952. var valueFontSize = textStyle.fontSize || 14
  23953. var valueFontWeight = textStyle.fontWeight || '900'
  23954. if (renderMode === 'html') {
  23955. // `textStyle` is probably from user input, should be encoded to reduce security risk.
  23956. return {
  23957. // eslint-disable-next-line max-len
  23958. nameStyle:
  23959. 'font-size:' +
  23960. encodeHTML(nameFontSize + '') +
  23961. 'px;color:' +
  23962. encodeHTML(nameFontColor) +
  23963. ';font-weight:' +
  23964. encodeHTML(nameFontWeight + ''), // eslint-disable-next-line max-len
  23965. valueStyle:
  23966. 'font-size:' +
  23967. encodeHTML(valueFontSize + '') +
  23968. 'px;color:' +
  23969. encodeHTML(valueFontColor) +
  23970. ';font-weight:' +
  23971. encodeHTML(valueFontWeight + '')
  23972. }
  23973. } else {
  23974. return {
  23975. nameStyle: {
  23976. fontSize: nameFontSize,
  23977. fill: nameFontColor,
  23978. fontWeight: nameFontWeight
  23979. },
  23980. valueStyle: {
  23981. fontSize: valueFontSize,
  23982. fill: valueFontColor,
  23983. fontWeight: valueFontWeight
  23984. }
  23985. }
  23986. }
  23987. } // See `TooltipMarkupLayoutIntent['innerGapLevel']`.
  23988. // (value from UI design)
  23989. var HTML_GAPS = [0, 10, 20, 30]
  23990. var RICH_TEXT_GAPS = ['', '\n', '\n\n', '\n\n\n'] // eslint-disable-next-line max-len
  23991. function createTooltipMarkup(type, option) {
  23992. option.type = type
  23993. return option
  23994. }
  23995. function isSectionFragment(frag) {
  23996. return frag.type === 'section'
  23997. }
  23998. function getBuilder(frag) {
  23999. return isSectionFragment(frag) ? buildSection : buildNameValue
  24000. }
  24001. function getBlockGapLevel(frag) {
  24002. if (isSectionFragment(frag)) {
  24003. var gapLevel_1 = 0
  24004. var subBlockLen = frag.blocks.length
  24005. var hasInnerGap_1 =
  24006. subBlockLen > 1 || (subBlockLen > 0 && !frag.noHeader)
  24007. each$7(frag.blocks, function (subBlock) {
  24008. var subGapLevel = getBlockGapLevel(subBlock) // If the some of the sub-blocks have some gaps (like 10px) inside, this block
  24009. // should use a larger gap (like 20px) to distinguish those sub-blocks.
  24010. if (subGapLevel >= gapLevel_1) {
  24011. gapLevel_1 =
  24012. subGapLevel +
  24013. +(
  24014. hasInnerGap_1 && // 0 always can not be readable gap level.
  24015. (!subGapLevel || // If no header, always keep the sub gap level. Otherwise
  24016. // look weird in case `multipleSeries`.
  24017. (isSectionFragment(subBlock) && !subBlock.noHeader))
  24018. )
  24019. }
  24020. })
  24021. return gapLevel_1
  24022. }
  24023. return 0
  24024. }
  24025. function buildSection(
  24026. ctx,
  24027. fragment,
  24028. topMarginForOuterGap,
  24029. toolTipTextStyle
  24030. ) {
  24031. var noHeader = fragment.noHeader
  24032. var gaps = getGap(getBlockGapLevel(fragment))
  24033. var subMarkupTextList = []
  24034. var subBlocks = fragment.blocks || []
  24035. assert(!subBlocks || isArray(subBlocks))
  24036. subBlocks = subBlocks || []
  24037. var orderMode = ctx.orderMode
  24038. if (fragment.sortBlocks && orderMode) {
  24039. subBlocks = subBlocks.slice()
  24040. var orderMap = { valueAsc: 'asc', valueDesc: 'desc' }
  24041. if (hasOwn(orderMap, orderMode)) {
  24042. var comparator_1 = new SortOrderComparator(
  24043. orderMap[orderMode],
  24044. null
  24045. )
  24046. subBlocks.sort(function (a, b) {
  24047. return comparator_1.evaluate(a.sortParam, b.sortParam)
  24048. })
  24049. } // FIXME 'seriesDesc' necessary?
  24050. else if (orderMode === 'seriesDesc') {
  24051. subBlocks.reverse()
  24052. }
  24053. }
  24054. each$7(subBlocks, function (subBlock, idx) {
  24055. var valueFormatter = fragment.valueFormatter
  24056. var subMarkupText = getBuilder(subBlock)(
  24057. // Inherit valueFormatter
  24058. valueFormatter
  24059. ? extend(extend({}, ctx), { valueFormatter: valueFormatter })
  24060. : ctx,
  24061. subBlock,
  24062. idx > 0 ? gaps.html : 0,
  24063. toolTipTextStyle
  24064. )
  24065. subMarkupText != null && subMarkupTextList.push(subMarkupText)
  24066. })
  24067. var subMarkupText =
  24068. ctx.renderMode === 'richText'
  24069. ? subMarkupTextList.join(gaps.richText)
  24070. : wrapBlockHTML(
  24071. subMarkupTextList.join(''),
  24072. noHeader ? topMarginForOuterGap : gaps.html
  24073. )
  24074. if (noHeader) {
  24075. return subMarkupText
  24076. }
  24077. var displayableHeader = makeValueReadable(
  24078. fragment.header,
  24079. 'ordinal',
  24080. ctx.useUTC
  24081. )
  24082. var nameStyle = getTooltipTextStyle(
  24083. toolTipTextStyle,
  24084. ctx.renderMode
  24085. ).nameStyle
  24086. if (ctx.renderMode === 'richText') {
  24087. return (
  24088. wrapInlineNameRichText(ctx, displayableHeader, nameStyle) +
  24089. gaps.richText +
  24090. subMarkupText
  24091. )
  24092. } else {
  24093. return wrapBlockHTML(
  24094. '<div style="' +
  24095. nameStyle +
  24096. ';' +
  24097. TOOLTIP_LINE_HEIGHT_CSS +
  24098. ';">' +
  24099. encodeHTML(displayableHeader) +
  24100. '</div>' +
  24101. subMarkupText,
  24102. topMarginForOuterGap
  24103. )
  24104. }
  24105. }
  24106. function buildNameValue(
  24107. ctx,
  24108. fragment,
  24109. topMarginForOuterGap,
  24110. toolTipTextStyle
  24111. ) {
  24112. var renderMode = ctx.renderMode
  24113. var noName = fragment.noName
  24114. var noValue = fragment.noValue
  24115. var noMarker = !fragment.markerType
  24116. var name = fragment.name
  24117. var useUTC = ctx.useUTC
  24118. var valueFormatter =
  24119. fragment.valueFormatter ||
  24120. ctx.valueFormatter ||
  24121. function (value) {
  24122. value = isArray(value) ? value : [value]
  24123. return map$1(value, function (val, idx) {
  24124. return makeValueReadable(
  24125. val,
  24126. isArray(valueTypeOption)
  24127. ? valueTypeOption[idx]
  24128. : valueTypeOption,
  24129. useUTC
  24130. )
  24131. })
  24132. }
  24133. if (noName && noValue) {
  24134. return
  24135. }
  24136. var markerStr = noMarker
  24137. ? ''
  24138. : ctx.markupStyleCreator.makeTooltipMarker(
  24139. fragment.markerType,
  24140. fragment.markerColor || '#333',
  24141. renderMode
  24142. )
  24143. var readableName = noName
  24144. ? ''
  24145. : makeValueReadable(name, 'ordinal', useUTC)
  24146. var valueTypeOption = fragment.valueType
  24147. var readableValueList = noValue
  24148. ? []
  24149. : valueFormatter(fragment.value)
  24150. var valueAlignRight = !noMarker || !noName // It little weird if only value next to marker but far from marker.
  24151. var valueCloseToMarker = !noMarker && noName
  24152. var _a = getTooltipTextStyle(toolTipTextStyle, renderMode),
  24153. nameStyle = _a.nameStyle,
  24154. valueStyle = _a.valueStyle
  24155. return renderMode === 'richText'
  24156. ? (noMarker ? '' : markerStr) +
  24157. (noName
  24158. ? ''
  24159. : wrapInlineNameRichText(ctx, readableName, nameStyle)) + // Value has commas inside, so use ' ' as delimiter for multiple values.
  24160. (noValue
  24161. ? ''
  24162. : wrapInlineValueRichText(
  24163. ctx,
  24164. readableValueList,
  24165. valueAlignRight,
  24166. valueCloseToMarker,
  24167. valueStyle
  24168. ))
  24169. : wrapBlockHTML(
  24170. (noMarker ? '' : markerStr) +
  24171. (noName
  24172. ? ''
  24173. : wrapInlineNameHTML(
  24174. readableName,
  24175. !noMarker,
  24176. nameStyle
  24177. )) +
  24178. (noValue
  24179. ? ''
  24180. : wrapInlineValueHTML(
  24181. readableValueList,
  24182. valueAlignRight,
  24183. valueCloseToMarker,
  24184. valueStyle
  24185. )),
  24186. topMarginForOuterGap
  24187. )
  24188. }
  24189. /**
  24190. * @return markupText. null/undefined means no content.
  24191. */ function buildTooltipMarkup(
  24192. fragment,
  24193. markupStyleCreator,
  24194. renderMode,
  24195. orderMode,
  24196. useUTC,
  24197. toolTipTextStyle
  24198. ) {
  24199. if (!fragment) {
  24200. return
  24201. }
  24202. var builder = getBuilder(fragment)
  24203. var ctx = {
  24204. useUTC: useUTC,
  24205. renderMode: renderMode,
  24206. orderMode: orderMode,
  24207. markupStyleCreator: markupStyleCreator,
  24208. valueFormatter: fragment.valueFormatter
  24209. }
  24210. return builder(ctx, fragment, 0, toolTipTextStyle)
  24211. }
  24212. function getGap(gapLevel) {
  24213. return {
  24214. html: HTML_GAPS[gapLevel],
  24215. richText: RICH_TEXT_GAPS[gapLevel]
  24216. }
  24217. }
  24218. function wrapBlockHTML(encodedContent, topGap) {
  24219. var clearfix = '<div style="clear:both"></div>'
  24220. var marginCSS = 'margin: ' + topGap + 'px 0 0'
  24221. return (
  24222. '<div style="' +
  24223. marginCSS +
  24224. ';' +
  24225. TOOLTIP_LINE_HEIGHT_CSS +
  24226. ';">' +
  24227. encodedContent +
  24228. clearfix +
  24229. '</div>'
  24230. )
  24231. }
  24232. function wrapInlineNameHTML(name, leftHasMarker, style) {
  24233. var marginCss = leftHasMarker ? 'margin-left:2px' : ''
  24234. return (
  24235. '<span style="' +
  24236. style +
  24237. ';' +
  24238. marginCss +
  24239. '">' +
  24240. encodeHTML(name) +
  24241. '</span>'
  24242. )
  24243. }
  24244. function wrapInlineValueHTML(
  24245. valueList,
  24246. alignRight,
  24247. valueCloseToMarker,
  24248. style
  24249. ) {
  24250. // Do not too close to marker, considering there are multiple values separated by spaces.
  24251. var paddingStr = valueCloseToMarker ? '10px' : '20px'
  24252. var alignCSS = alignRight
  24253. ? 'float:right;margin-left:' + paddingStr
  24254. : ''
  24255. valueList = isArray(valueList) ? valueList : [valueList]
  24256. return (
  24257. '<span style="' +
  24258. alignCSS +
  24259. ';' +
  24260. style +
  24261. '">' + // Value has commas inside, so use ' ' as delimiter for multiple values.
  24262. map$1(valueList, function (value) {
  24263. return encodeHTML(value)
  24264. }).join('&nbsp;&nbsp;') +
  24265. '</span>'
  24266. )
  24267. }
  24268. function wrapInlineNameRichText(ctx, name, style) {
  24269. return ctx.markupStyleCreator.wrapRichTextStyle(name, style)
  24270. }
  24271. function wrapInlineValueRichText(
  24272. ctx,
  24273. values,
  24274. alignRight,
  24275. valueCloseToMarker,
  24276. style
  24277. ) {
  24278. var styles = [style]
  24279. var paddingLeft = valueCloseToMarker ? 10 : 20
  24280. alignRight &&
  24281. styles.push({ padding: [0, 0, 0, paddingLeft], align: 'right' }) // Value has commas inside, so use ' ' as delimiter for multiple values.
  24282. return ctx.markupStyleCreator.wrapRichTextStyle(
  24283. isArray(values) ? values.join(' ') : values,
  24284. styles
  24285. )
  24286. }
  24287. function retrieveVisualColorForTooltipMarker(series, dataIndex) {
  24288. var style = series.getData().getItemVisual(dataIndex, 'style')
  24289. var color = style[series.visualDrawType]
  24290. return convertToColorString(color)
  24291. }
  24292. function getPaddingFromTooltipModel(model, renderMode) {
  24293. var padding = model.get('padding')
  24294. return padding != null
  24295. ? padding // We give slightly different to look pretty.
  24296. : renderMode === 'richText'
  24297. ? [8, 10]
  24298. : 10
  24299. }
  24300. /**
  24301. * The major feature is generate styles for `renderMode: 'richText'`.
  24302. * But it also serves `renderMode: 'html'` to provide
  24303. * "renderMode-independent" API.
  24304. */ var TooltipMarkupStyleCreator = /** @class */ (function () {
  24305. function TooltipMarkupStyleCreator() {
  24306. this.richTextStyles = {} // Notice that "generate a style name" usuall happens repeatly when mouse moving and
  24307. // displaying a tooltip. So we put the `_nextStyleNameId` as a member of each creator
  24308. // rather than static shared by all creators (which will cause it increase to fast).
  24309. this._nextStyleNameId = getRandomIdBase()
  24310. }
  24311. TooltipMarkupStyleCreator.prototype._generateStyleName =
  24312. function () {
  24313. return '__EC_aUTo_' + this._nextStyleNameId++
  24314. }
  24315. TooltipMarkupStyleCreator.prototype.makeTooltipMarker = function (
  24316. markerType,
  24317. colorStr,
  24318. renderMode
  24319. ) {
  24320. var markerId =
  24321. renderMode === 'richText' ? this._generateStyleName() : null
  24322. var marker = getTooltipMarker({
  24323. color: colorStr,
  24324. type: markerType,
  24325. renderMode: renderMode,
  24326. markerId: markerId
  24327. })
  24328. if (isString(marker)) {
  24329. return marker
  24330. } else {
  24331. this.richTextStyles[markerId] = marker.style
  24332. return marker.content
  24333. }
  24334. }
  24335. /**
  24336. * @usage
  24337. * ```ts
  24338. * const styledText = markupStyleCreator.wrapRichTextStyle([
  24339. * // The styles will be auto merged.
  24340. * {
  24341. * fontSize: 12,
  24342. * color: 'blue'
  24343. * },
  24344. * {
  24345. * padding: 20
  24346. * }
  24347. * ]);
  24348. * ```
  24349. */ TooltipMarkupStyleCreator.prototype.wrapRichTextStyle =
  24350. function (text, styles) {
  24351. var finalStl = {}
  24352. if (isArray(styles)) {
  24353. each$7(styles, function (stl) {
  24354. return extend(finalStl, stl)
  24355. })
  24356. } else {
  24357. extend(finalStl, styles)
  24358. }
  24359. var styleName = this._generateStyleName()
  24360. this.richTextStyles[styleName] = finalStl
  24361. return '{' + styleName + '|' + text + '}'
  24362. }
  24363. return TooltipMarkupStyleCreator
  24364. })()
  24365. function defaultSeriesFormatTooltip(opt) {
  24366. var series = opt.series
  24367. var dataIndex = opt.dataIndex
  24368. var multipleSeries = opt.multipleSeries
  24369. var data = series.getData()
  24370. var tooltipDims = data.mapDimensionsAll('defaultedTooltip')
  24371. var tooltipDimLen = tooltipDims.length
  24372. var value = series.getRawValue(dataIndex)
  24373. var isValueArr = isArray(value)
  24374. var markerColor = retrieveVisualColorForTooltipMarker(
  24375. series,
  24376. dataIndex
  24377. ) // Complicated rule for pretty tooltip.
  24378. var inlineValue
  24379. var inlineValueType
  24380. var subBlocks
  24381. var sortParam
  24382. if (tooltipDimLen > 1 || (isValueArr && !tooltipDimLen)) {
  24383. var formatArrResult = formatTooltipArrayValue(
  24384. value,
  24385. series,
  24386. dataIndex,
  24387. tooltipDims,
  24388. markerColor
  24389. )
  24390. inlineValue = formatArrResult.inlineValues
  24391. inlineValueType = formatArrResult.inlineValueTypes
  24392. subBlocks = formatArrResult.blocks // Only support tooltip sort by the first inline value. It's enough in most cases.
  24393. sortParam = formatArrResult.inlineValues[0]
  24394. } else if (tooltipDimLen) {
  24395. var dimInfo = data.getDimensionInfo(tooltipDims[0])
  24396. sortParam = inlineValue = retrieveRawValue(
  24397. data,
  24398. dataIndex,
  24399. tooltipDims[0]
  24400. )
  24401. inlineValueType = dimInfo.type
  24402. } else {
  24403. sortParam = inlineValue = isValueArr ? value[0] : value
  24404. } // Do not show generated series name. It might not be readable.
  24405. var seriesNameSpecified = isNameSpecified(series)
  24406. var seriesName = (seriesNameSpecified && series.name) || ''
  24407. var itemName = data.getName(dataIndex)
  24408. var inlineName = multipleSeries ? seriesName : itemName
  24409. return createTooltipMarkup('section', {
  24410. header: seriesName, // When series name not specified, do not show a header line with only '-'.
  24411. // This case alway happen in tooltip.trigger: 'item'.
  24412. noHeader: multipleSeries || !seriesNameSpecified,
  24413. sortParam: sortParam,
  24414. blocks: [
  24415. createTooltipMarkup('nameValue', {
  24416. markerType: 'item',
  24417. markerColor: markerColor, // Do not mix display seriesName and itemName in one tooltip,
  24418. // which might confuses users.
  24419. name: inlineName, // name dimension might be auto assigned, where the name might
  24420. // be not readable. So we check trim here.
  24421. noName: !trim$1(inlineName),
  24422. value: inlineValue,
  24423. valueType: inlineValueType
  24424. })
  24425. ].concat(subBlocks || [])
  24426. })
  24427. }
  24428. function formatTooltipArrayValue(
  24429. value,
  24430. series,
  24431. dataIndex,
  24432. tooltipDims,
  24433. colorStr
  24434. ) {
  24435. // check: category-no-encode-has-axis-data in dataset.html
  24436. var data = series.getData()
  24437. var isValueMultipleLine = reduce(
  24438. value,
  24439. function (isValueMultipleLine, val, idx) {
  24440. var dimItem = data.getDimensionInfo(idx)
  24441. return (isValueMultipleLine =
  24442. isValueMultipleLine ||
  24443. (dimItem &&
  24444. dimItem.tooltip !== false &&
  24445. dimItem.displayName != null))
  24446. },
  24447. false
  24448. )
  24449. var inlineValues = []
  24450. var inlineValueTypes = []
  24451. var blocks = []
  24452. tooltipDims.length
  24453. ? each$7(tooltipDims, function (dim) {
  24454. setEachItem(retrieveRawValue(data, dataIndex, dim), dim)
  24455. }) // By default, all dims is used on tooltip.
  24456. : each$7(value, setEachItem)
  24457. function setEachItem(val, dim) {
  24458. var dimInfo = data.getDimensionInfo(dim) // If `dimInfo.tooltip` is not set, show tooltip.
  24459. if (!dimInfo || dimInfo.otherDims.tooltip === false) {
  24460. return
  24461. }
  24462. if (isValueMultipleLine) {
  24463. blocks.push(
  24464. createTooltipMarkup('nameValue', {
  24465. markerType: 'subItem',
  24466. markerColor: colorStr,
  24467. name: dimInfo.displayName,
  24468. value: val,
  24469. valueType: dimInfo.type
  24470. })
  24471. )
  24472. } else {
  24473. inlineValues.push(val)
  24474. inlineValueTypes.push(dimInfo.type)
  24475. }
  24476. }
  24477. return {
  24478. inlineValues: inlineValues,
  24479. inlineValueTypes: inlineValueTypes,
  24480. blocks: blocks
  24481. }
  24482. }
  24483. var inner$a = makeInner()
  24484. function getSelectionKey(data, dataIndex) {
  24485. return data.getName(dataIndex) || data.getId(dataIndex)
  24486. }
  24487. var SERIES_UNIVERSAL_TRANSITION_PROP = '__universalTransitionEnabled'
  24488. var SeriesModel = /** @class */ (function (_super) {
  24489. __extends(SeriesModel, _super)
  24490. function SeriesModel() {
  24491. // [Caution]: Becuase this class or desecendants can be used as `XXX.extend(subProto)`,
  24492. // the class members must not be initialized in constructor or declaration place.
  24493. // Otherwise there is bad case:
  24494. // class A {xxx = 1;}
  24495. // enableClassExtend(A);
  24496. // class B extends A {}
  24497. // var C = B.extend({xxx: 5});
  24498. // var c = new C();
  24499. // console.log(c.xxx); // expect 5 but always 1.
  24500. var _this =
  24501. (_super !== null && _super.apply(this, arguments)) || this // ---------------------------------------
  24502. // Props about data selection
  24503. // ---------------------------------------
  24504. _this._selectedDataIndicesMap = {}
  24505. return _this
  24506. }
  24507. SeriesModel.prototype.init = function (
  24508. option,
  24509. parentModel,
  24510. ecModel
  24511. ) {
  24512. this.seriesIndex = this.componentIndex
  24513. this.dataTask = createTask({
  24514. count: dataTaskCount,
  24515. reset: dataTaskReset
  24516. })
  24517. this.dataTask.context = { model: this }
  24518. this.mergeDefaultAndTheme(option, ecModel)
  24519. var sourceManager = (inner$a(this).sourceManager =
  24520. new SourceManager(this))
  24521. sourceManager.prepareSource()
  24522. var data = this.getInitialData(option, ecModel)
  24523. wrapData(data, this)
  24524. this.dataTask.context.data = data
  24525. inner$a(this).dataBeforeProcessed = data // If we reverse the order (make data firstly, and then make
  24526. // dataBeforeProcessed by cloneShallow), cloneShallow will
  24527. // cause data.graph.data !== data when using
  24528. // module:echarts/data/Graph or module:echarts/data/Tree.
  24529. // See module:echarts/data/helper/linkSeriesData
  24530. // Theoretically, it is unreasonable to call `seriesModel.getData()` in the model
  24531. // init or merge stage, because the data can be restored. So we do not `restoreData`
  24532. // and `setData` here, which forbids calling `seriesModel.getData()` in this stage.
  24533. // Call `seriesModel.getRawData()` instead.
  24534. // this.restoreData();
  24535. autoSeriesName(this)
  24536. this._initSelectedMapFromData(data)
  24537. }
  24538. /**
  24539. * Util for merge default and theme to option
  24540. */ SeriesModel.prototype.mergeDefaultAndTheme = function (
  24541. option,
  24542. ecModel
  24543. ) {
  24544. var layoutMode = fetchLayoutMode(this)
  24545. var inputPositionParams = layoutMode
  24546. ? getLayoutParams(option)
  24547. : {} // Backward compat: using subType on theme.
  24548. // But if name duplicate between series subType
  24549. // (for example: parallel) add component mainType,
  24550. // add suffix 'Series'.
  24551. var themeSubType = this.subType
  24552. if (ComponentModel$1.hasClass(themeSubType)) {
  24553. themeSubType += 'Series'
  24554. }
  24555. merge(option, ecModel.getTheme().get(this.subType))
  24556. merge(option, this.getDefaultOption()) // Default label emphasis `show`
  24557. defaultEmphasis(option, 'label', ['show'])
  24558. this.fillDataTextStyle(option.data)
  24559. if (layoutMode) {
  24560. mergeLayoutParam(option, inputPositionParams, layoutMode)
  24561. }
  24562. }
  24563. SeriesModel.prototype.mergeOption = function (
  24564. newSeriesOption,
  24565. ecModel
  24566. ) {
  24567. // this.settingTask.dirty();
  24568. newSeriesOption = merge(this.option, newSeriesOption, true)
  24569. this.fillDataTextStyle(newSeriesOption.data)
  24570. var layoutMode = fetchLayoutMode(this)
  24571. if (layoutMode) {
  24572. mergeLayoutParam(this.option, newSeriesOption, layoutMode)
  24573. }
  24574. var sourceManager = inner$a(this).sourceManager
  24575. sourceManager.dirty()
  24576. sourceManager.prepareSource()
  24577. var data = this.getInitialData(newSeriesOption, ecModel)
  24578. wrapData(data, this)
  24579. this.dataTask.dirty()
  24580. this.dataTask.context.data = data
  24581. inner$a(this).dataBeforeProcessed = data
  24582. autoSeriesName(this)
  24583. this._initSelectedMapFromData(data)
  24584. }
  24585. SeriesModel.prototype.fillDataTextStyle = function (data) {
  24586. // Default data label emphasis `show`
  24587. // FIXME Tree structure data ?
  24588. // FIXME Performance ?
  24589. if (data && !isTypedArray(data)) {
  24590. var props = ['show']
  24591. for (var i = 0; i < data.length; i++) {
  24592. if (data[i] && data[i].label) {
  24593. defaultEmphasis(data[i], 'label', props)
  24594. }
  24595. }
  24596. }
  24597. }
  24598. /**
  24599. * Init a data structure from data related option in series
  24600. * Must be overriden.
  24601. */ SeriesModel.prototype.getInitialData = function (
  24602. option,
  24603. ecModel
  24604. ) {
  24605. return
  24606. }
  24607. /**
  24608. * Append data to list
  24609. */ SeriesModel.prototype.appendData = function (params) {
  24610. // FIXME ???
  24611. // (1) If data from dataset, forbidden append.
  24612. // (2) support append data of dataset.
  24613. var data = this.getRawData()
  24614. data.appendData(params.data)
  24615. }
  24616. /**
  24617. * Consider some method like `filter`, `map` need make new data,
  24618. * We should make sure that `seriesModel.getData()` get correct
  24619. * data in the stream procedure. So we fetch data from upstream
  24620. * each time `task.perform` called.
  24621. */ SeriesModel.prototype.getData = function (dataType) {
  24622. var task = getCurrentTask(this)
  24623. if (task) {
  24624. var data = task.context.data
  24625. return dataType == null ? data : data.getLinkedData(dataType)
  24626. } else {
  24627. // When series is not alive (that may happen when click toolbox
  24628. // restore or setOption with not merge mode), series data may
  24629. // be still need to judge animation or something when graphic
  24630. // elements want to know whether fade out.
  24631. return inner$a(this).data
  24632. }
  24633. }
  24634. SeriesModel.prototype.getAllData = function () {
  24635. var mainData = this.getData()
  24636. return mainData && mainData.getLinkedDataAll
  24637. ? mainData.getLinkedDataAll()
  24638. : [{ data: mainData }]
  24639. }
  24640. SeriesModel.prototype.setData = function (data) {
  24641. var task = getCurrentTask(this)
  24642. if (task) {
  24643. var context = task.context // Consider case: filter, data sample.
  24644. // FIXME:TS never used, so comment it
  24645. // if (context.data !== data && task.modifyOutputEnd) {
  24646. // task.setOutputEnd(data.count());
  24647. // }
  24648. context.outputData = data // Caution: setData should update context.data,
  24649. // Because getData may be called multiply in a
  24650. // single stage and expect to get the data just
  24651. // set. (For example, AxisProxy, x y both call
  24652. // getData and setDate sequentially).
  24653. // So the context.data should be fetched from
  24654. // upstream each time when a stage starts to be
  24655. // performed.
  24656. if (task !== this.dataTask) {
  24657. context.data = data
  24658. }
  24659. }
  24660. inner$a(this).data = data
  24661. }
  24662. SeriesModel.prototype.getEncode = function () {
  24663. var encode = this.get('encode', true)
  24664. if (encode) {
  24665. return createHashMap(encode)
  24666. }
  24667. }
  24668. SeriesModel.prototype.getSourceManager = function () {
  24669. return inner$a(this).sourceManager
  24670. }
  24671. SeriesModel.prototype.getSource = function () {
  24672. return this.getSourceManager().getSource()
  24673. }
  24674. /**
  24675. * Get data before processed
  24676. */ SeriesModel.prototype.getRawData = function () {
  24677. return inner$a(this).dataBeforeProcessed
  24678. }
  24679. SeriesModel.prototype.getColorBy = function () {
  24680. var colorBy = this.get('colorBy')
  24681. return colorBy || 'series'
  24682. }
  24683. SeriesModel.prototype.isColorBySeries = function () {
  24684. return this.getColorBy() === 'series'
  24685. }
  24686. /**
  24687. * Get base axis if has coordinate system and has axis.
  24688. * By default use coordSys.getBaseAxis();
  24689. * Can be overrided for some chart.
  24690. * @return {type} description
  24691. */ SeriesModel.prototype.getBaseAxis = function () {
  24692. var coordSys = this.coordinateSystem // @ts-ignore
  24693. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis()
  24694. }
  24695. /**
  24696. * Default tooltip formatter
  24697. *
  24698. * @param dataIndex
  24699. * @param multipleSeries
  24700. * @param dataType
  24701. * @param renderMode valid values: 'html'(by default) and 'richText'.
  24702. * 'html' is used for rendering tooltip in extra DOM form, and the result
  24703. * string is used as DOM HTML content.
  24704. * 'richText' is used for rendering tooltip in rich text form, for those where
  24705. * DOM operation is not supported.
  24706. * @return formatted tooltip with `html` and `markers`
  24707. * Notice: The override method can also return string
  24708. */ SeriesModel.prototype.formatTooltip = function (
  24709. dataIndex,
  24710. multipleSeries,
  24711. dataType
  24712. ) {
  24713. return defaultSeriesFormatTooltip({
  24714. series: this,
  24715. dataIndex: dataIndex,
  24716. multipleSeries: multipleSeries
  24717. })
  24718. }
  24719. SeriesModel.prototype.isAnimationEnabled = function () {
  24720. var ecModel = this.ecModel // Disable animation if using echarts in node but not give ssr flag.
  24721. // In ssr mode, renderToString will generate svg with css animation.
  24722. if (env$1.node && !(ecModel && ecModel.ssr)) {
  24723. return false
  24724. }
  24725. var animationEnabled = this.getShallow('animation')
  24726. if (animationEnabled) {
  24727. if (
  24728. this.getData().count() > this.getShallow('animationThreshold')
  24729. ) {
  24730. animationEnabled = false
  24731. }
  24732. }
  24733. return !!animationEnabled
  24734. }
  24735. SeriesModel.prototype.restoreData = function () {
  24736. this.dataTask.dirty()
  24737. }
  24738. SeriesModel.prototype.getColorFromPalette = function (
  24739. name,
  24740. scope,
  24741. requestColorNum
  24742. ) {
  24743. var ecModel = this.ecModel // PENDING
  24744. var color = PaletteMixin.prototype.getColorFromPalette.call(
  24745. this,
  24746. name,
  24747. scope,
  24748. requestColorNum
  24749. )
  24750. if (!color) {
  24751. color = ecModel.getColorFromPalette(
  24752. name,
  24753. scope,
  24754. requestColorNum
  24755. )
  24756. }
  24757. return color
  24758. }
  24759. /**
  24760. * Use `data.mapDimensionsAll(coordDim)` instead.
  24761. * @deprecated
  24762. */ SeriesModel.prototype.coordDimToDataDim = function (coordDim) {
  24763. return this.getRawData().mapDimensionsAll(coordDim)
  24764. }
  24765. /**
  24766. * Get progressive rendering count each step
  24767. */ SeriesModel.prototype.getProgressive = function () {
  24768. return this.get('progressive')
  24769. }
  24770. /**
  24771. * Get progressive rendering count each step
  24772. */ SeriesModel.prototype.getProgressiveThreshold = function () {
  24773. return this.get('progressiveThreshold')
  24774. } // PENGING If selectedMode is null ?
  24775. SeriesModel.prototype.select = function (
  24776. innerDataIndices,
  24777. dataType
  24778. ) {
  24779. this._innerSelect(this.getData(dataType), innerDataIndices)
  24780. }
  24781. SeriesModel.prototype.unselect = function (
  24782. innerDataIndices,
  24783. dataType
  24784. ) {
  24785. var selectedMap = this.option.selectedMap
  24786. if (!selectedMap) {
  24787. return
  24788. }
  24789. var selectedMode = this.option.selectedMode
  24790. var data = this.getData(dataType)
  24791. if (selectedMode === 'series' || selectedMap === 'all') {
  24792. this.option.selectedMap = {}
  24793. this._selectedDataIndicesMap = {}
  24794. return
  24795. }
  24796. for (var i = 0; i < innerDataIndices.length; i++) {
  24797. var dataIndex = innerDataIndices[i]
  24798. var nameOrId = getSelectionKey(data, dataIndex)
  24799. selectedMap[nameOrId] = false
  24800. this._selectedDataIndicesMap[nameOrId] = -1
  24801. }
  24802. }
  24803. SeriesModel.prototype.toggleSelect = function (
  24804. innerDataIndices,
  24805. dataType
  24806. ) {
  24807. var tmpArr = []
  24808. for (var i = 0; i < innerDataIndices.length; i++) {
  24809. tmpArr[0] = innerDataIndices[i]
  24810. this.isSelected(innerDataIndices[i], dataType)
  24811. ? this.unselect(tmpArr, dataType)
  24812. : this.select(tmpArr, dataType)
  24813. }
  24814. }
  24815. SeriesModel.prototype.getSelectedDataIndices = function () {
  24816. if (this.option.selectedMap === 'all') {
  24817. return [].slice.call(this.getData().getIndices())
  24818. }
  24819. var selectedDataIndicesMap = this._selectedDataIndicesMap
  24820. var nameOrIds = keys(selectedDataIndicesMap)
  24821. var dataIndices = []
  24822. for (var i = 0; i < nameOrIds.length; i++) {
  24823. var dataIndex = selectedDataIndicesMap[nameOrIds[i]]
  24824. if (dataIndex >= 0) {
  24825. dataIndices.push(dataIndex)
  24826. }
  24827. }
  24828. return dataIndices
  24829. }
  24830. SeriesModel.prototype.isSelected = function (dataIndex, dataType) {
  24831. var selectedMap = this.option.selectedMap
  24832. if (!selectedMap) {
  24833. return false
  24834. }
  24835. var data = this.getData(dataType)
  24836. return (
  24837. (selectedMap === 'all' ||
  24838. selectedMap[getSelectionKey(data, dataIndex)]) &&
  24839. !data.getItemModel(dataIndex).get(['select', 'disabled'])
  24840. )
  24841. }
  24842. SeriesModel.prototype.isUniversalTransitionEnabled = function () {
  24843. if (this[SERIES_UNIVERSAL_TRANSITION_PROP]) {
  24844. return true
  24845. }
  24846. var universalTransitionOpt = this.option.universalTransition // Quick reject
  24847. if (!universalTransitionOpt) {
  24848. return false
  24849. }
  24850. if (universalTransitionOpt === true) {
  24851. return true
  24852. } // Can be simply 'universalTransition: true'
  24853. return universalTransitionOpt && universalTransitionOpt.enabled
  24854. }
  24855. SeriesModel.prototype._innerSelect = function (
  24856. data,
  24857. innerDataIndices
  24858. ) {
  24859. var _a, _b
  24860. var option = this.option
  24861. var selectedMode = option.selectedMode
  24862. var len = innerDataIndices.length
  24863. if (!selectedMode || !len) {
  24864. return
  24865. }
  24866. if (selectedMode === 'series') {
  24867. option.selectedMap = 'all'
  24868. } else if (selectedMode === 'multiple') {
  24869. if (!isObject$2(option.selectedMap)) {
  24870. option.selectedMap = {}
  24871. }
  24872. var selectedMap = option.selectedMap
  24873. for (var i = 0; i < len; i++) {
  24874. var dataIndex = innerDataIndices[i] // TODO diffrent types of data share same object.
  24875. var nameOrId = getSelectionKey(data, dataIndex)
  24876. selectedMap[nameOrId] = true
  24877. this._selectedDataIndicesMap[nameOrId] =
  24878. data.getRawIndex(dataIndex)
  24879. }
  24880. } else if (selectedMode === 'single' || selectedMode === true) {
  24881. var lastDataIndex = innerDataIndices[len - 1]
  24882. var nameOrId = getSelectionKey(data, lastDataIndex)
  24883. option.selectedMap = ((_a = {}), (_a[nameOrId] = true), _a)
  24884. this._selectedDataIndicesMap =
  24885. ((_b = {}),
  24886. (_b[nameOrId] = data.getRawIndex(lastDataIndex)),
  24887. _b)
  24888. }
  24889. }
  24890. SeriesModel.prototype._initSelectedMapFromData = function (data) {
  24891. // Ignore select info in data if selectedMap exists.
  24892. // NOTE It's only for legacy usage. edge data is not supported.
  24893. if (this.option.selectedMap) {
  24894. return
  24895. }
  24896. var dataIndices = []
  24897. if (data.hasItemOption) {
  24898. data.each(function (idx) {
  24899. var rawItem = data.getRawDataItem(idx)
  24900. if (rawItem && rawItem.selected) {
  24901. dataIndices.push(idx)
  24902. }
  24903. })
  24904. }
  24905. if (dataIndices.length > 0) {
  24906. this._innerSelect(data, dataIndices)
  24907. }
  24908. } // /**
  24909. // * @see {module:echarts/stream/Scheduler}
  24910. // */
  24911. // abstract pipeTask: null
  24912. SeriesModel.registerClass = function (clz) {
  24913. return ComponentModel$1.registerClass(clz)
  24914. }
  24915. SeriesModel.protoInitialize = (function () {
  24916. var proto = SeriesModel.prototype
  24917. proto.type = 'series.__base__'
  24918. proto.seriesIndex = 0
  24919. proto.ignoreStyleOnData = false
  24920. proto.hasSymbolVisual = false
  24921. proto.defaultSymbol = 'circle' // Make sure the values can be accessed!
  24922. proto.visualStyleAccessPath = 'itemStyle'
  24923. proto.visualDrawType = 'fill'
  24924. })()
  24925. return SeriesModel
  24926. })(ComponentModel$1)
  24927. mixin(SeriesModel, DataFormatMixin)
  24928. mixin(SeriesModel, PaletteMixin)
  24929. mountExtend(SeriesModel, ComponentModel$1)
  24930. /**
  24931. * MUST be called after `prepareSource` called
  24932. * Here we need to make auto series, especially for auto legend. But we
  24933. * do not modify series.name in option to avoid side effects.
  24934. */ function autoSeriesName(seriesModel) {
  24935. // User specified name has higher priority, otherwise it may cause
  24936. // series can not be queried unexpectedly.
  24937. var name = seriesModel.name
  24938. if (!isNameSpecified(seriesModel)) {
  24939. seriesModel.name = getSeriesAutoName(seriesModel) || name
  24940. }
  24941. }
  24942. function getSeriesAutoName(seriesModel) {
  24943. var data = seriesModel.getRawData()
  24944. var dataDims = data.mapDimensionsAll('seriesName')
  24945. var nameArr = []
  24946. each$7(dataDims, function (dataDim) {
  24947. var dimInfo = data.getDimensionInfo(dataDim)
  24948. dimInfo.displayName && nameArr.push(dimInfo.displayName)
  24949. })
  24950. return nameArr.join(' ')
  24951. }
  24952. function dataTaskCount(context) {
  24953. return context.model.getRawData().count()
  24954. }
  24955. function dataTaskReset(context) {
  24956. var seriesModel = context.model
  24957. seriesModel.setData(seriesModel.getRawData().cloneShallow())
  24958. return dataTaskProgress
  24959. }
  24960. function dataTaskProgress(param, context) {
  24961. // Avoid repead cloneShallow when data just created in reset.
  24962. if (context.outputData && param.end > context.outputData.count()) {
  24963. context.model.getRawData().cloneShallow(context.outputData)
  24964. }
  24965. } // TODO refactor
  24966. function wrapData(data, seriesModel) {
  24967. each$7(
  24968. concatArray(data.CHANGABLE_METHODS, data.DOWNSAMPLE_METHODS),
  24969. function (methodName) {
  24970. data.wrapMethod(methodName, curry$1(onDataChange, seriesModel))
  24971. }
  24972. )
  24973. }
  24974. function onDataChange(seriesModel, newList) {
  24975. var task = getCurrentTask(seriesModel)
  24976. if (task) {
  24977. // Consider case: filter, selectRange
  24978. task.setOutputEnd((newList || this).count())
  24979. }
  24980. return newList
  24981. }
  24982. function getCurrentTask(seriesModel) {
  24983. var scheduler = (seriesModel.ecModel || {}).scheduler
  24984. var pipeline = scheduler && scheduler.getPipeline(seriesModel.uid)
  24985. if (pipeline) {
  24986. // When pipline finished, the currrentTask keep the last
  24987. // task (renderTask).
  24988. var task = pipeline.currentTask
  24989. if (task) {
  24990. var agentStubMap = task.agentStubMap
  24991. if (agentStubMap) {
  24992. task = agentStubMap.get(seriesModel.uid)
  24993. }
  24994. }
  24995. return task
  24996. }
  24997. }
  24998. var SeriesModel$1 = SeriesModel
  24999. var ComponentView = /** @class */ (function () {
  25000. function ComponentView() {
  25001. this.group = new Group$3()
  25002. this.uid = getUID('viewComponent')
  25003. }
  25004. ComponentView.prototype.init = function (ecModel, api) {}
  25005. ComponentView.prototype.render = function (
  25006. model,
  25007. ecModel,
  25008. api,
  25009. payload
  25010. ) {}
  25011. ComponentView.prototype.dispose = function (ecModel, api) {}
  25012. ComponentView.prototype.updateView = function (
  25013. model,
  25014. ecModel,
  25015. api,
  25016. payload
  25017. ) {
  25018. // Do nothing;
  25019. }
  25020. ComponentView.prototype.updateLayout = function (
  25021. model,
  25022. ecModel,
  25023. api,
  25024. payload
  25025. ) {
  25026. // Do nothing;
  25027. }
  25028. ComponentView.prototype.updateVisual = function (
  25029. model,
  25030. ecModel,
  25031. api,
  25032. payload
  25033. ) {
  25034. // Do nothing;
  25035. }
  25036. /**
  25037. * Hook for toggle blur target series.
  25038. * Can be used in marker for blur or leave blur the markers
  25039. */ ComponentView.prototype.toggleBlurSeries = function (
  25040. seriesModels,
  25041. isBlur,
  25042. ecModel
  25043. ) {
  25044. // Do nothing;
  25045. }
  25046. /**
  25047. * Traverse the new rendered elements.
  25048. *
  25049. * It will traverse the new added element in progressive rendering.
  25050. * And traverse all in normal rendering.
  25051. */ ComponentView.prototype.eachRendered = function (cb) {
  25052. var group = this.group
  25053. if (group) {
  25054. group.traverse(cb)
  25055. }
  25056. }
  25057. return ComponentView
  25058. })()
  25059. enableClassExtend(ComponentView)
  25060. enableClassManagement(ComponentView)
  25061. var ComponentView$1 = ComponentView
  25062. /**
  25063. * @return {string} If large mode changed, return string 'reset';
  25064. */ function createRenderPlanner() {
  25065. var inner = makeInner()
  25066. return function (seriesModel) {
  25067. var fields = inner(seriesModel)
  25068. var pipelineContext = seriesModel.pipelineContext
  25069. var originalLarge = !!fields.large
  25070. var originalProgressive = !!fields.progressiveRender // FIXME: if the planner works on a filtered series, `pipelineContext` does not
  25071. // exists. See #11611 . Probably we need to modify this structure, see the comment
  25072. // on `performRawSeries` in `Schedular.js`.
  25073. var large = (fields.large = !!(
  25074. pipelineContext && pipelineContext.large
  25075. ))
  25076. var progressive = (fields.progressiveRender = !!(
  25077. pipelineContext && pipelineContext.progressiveRender
  25078. ))
  25079. return (
  25080. !!(
  25081. originalLarge !== large || originalProgressive !== progressive
  25082. ) && 'reset'
  25083. )
  25084. }
  25085. }
  25086. var inner$9 = makeInner()
  25087. var renderPlanner = createRenderPlanner()
  25088. var ChartView = /** @class */ (function () {
  25089. function ChartView() {
  25090. this.group = new Group$3()
  25091. this.uid = getUID('viewChart')
  25092. this.renderTask = createTask({
  25093. plan: renderTaskPlan,
  25094. reset: renderTaskReset
  25095. })
  25096. this.renderTask.context = { view: this }
  25097. }
  25098. ChartView.prototype.init = function (ecModel, api) {}
  25099. ChartView.prototype.render = function (
  25100. seriesModel,
  25101. ecModel,
  25102. api,
  25103. payload
  25104. ) {}
  25105. /**
  25106. * Highlight series or specified data item.
  25107. */ ChartView.prototype.highlight = function (
  25108. seriesModel,
  25109. ecModel,
  25110. api,
  25111. payload
  25112. ) {
  25113. var data = seriesModel.getData(payload && payload.dataType)
  25114. if (!data) {
  25115. return
  25116. }
  25117. toggleHighlight(data, payload, 'emphasis')
  25118. }
  25119. /**
  25120. * Downplay series or specified data item.
  25121. */ ChartView.prototype.downplay = function (
  25122. seriesModel,
  25123. ecModel,
  25124. api,
  25125. payload
  25126. ) {
  25127. var data = seriesModel.getData(payload && payload.dataType)
  25128. if (!data) {
  25129. return
  25130. }
  25131. toggleHighlight(data, payload, 'normal')
  25132. }
  25133. /**
  25134. * Remove self.
  25135. */ ChartView.prototype.remove = function (ecModel, api) {
  25136. this.group.removeAll()
  25137. }
  25138. /**
  25139. * Dispose self.
  25140. */ ChartView.prototype.dispose = function (ecModel, api) {}
  25141. ChartView.prototype.updateView = function (
  25142. seriesModel,
  25143. ecModel,
  25144. api,
  25145. payload
  25146. ) {
  25147. this.render(seriesModel, ecModel, api, payload)
  25148. } // FIXME never used?
  25149. ChartView.prototype.updateLayout = function (
  25150. seriesModel,
  25151. ecModel,
  25152. api,
  25153. payload
  25154. ) {
  25155. this.render(seriesModel, ecModel, api, payload)
  25156. } // FIXME never used?
  25157. ChartView.prototype.updateVisual = function (
  25158. seriesModel,
  25159. ecModel,
  25160. api,
  25161. payload
  25162. ) {
  25163. this.render(seriesModel, ecModel, api, payload)
  25164. }
  25165. /**
  25166. * Traverse the new rendered elements.
  25167. *
  25168. * It will traverse the new added element in progressive rendering.
  25169. * And traverse all in normal rendering.
  25170. */ ChartView.prototype.eachRendered = function (cb) {
  25171. traverseElements(this.group, cb)
  25172. }
  25173. ChartView.markUpdateMethod = function (payload, methodName) {
  25174. inner$9(payload).updateMethod = methodName
  25175. }
  25176. ChartView.protoInitialize = (function () {
  25177. var proto = ChartView.prototype
  25178. proto.type = 'chart'
  25179. })()
  25180. return ChartView
  25181. })()
  25182. /**
  25183. * Set state of single element
  25184. */ function elSetState(el, state, highlightDigit) {
  25185. if (el && isHighDownDispatcher(el)) {
  25186. ;(state === 'emphasis' ? enterEmphasis : leaveEmphasis)(
  25187. el,
  25188. highlightDigit
  25189. )
  25190. }
  25191. }
  25192. function toggleHighlight(data, payload, state) {
  25193. var dataIndex = queryDataIndex(data, payload)
  25194. var highlightDigit =
  25195. payload && payload.highlightKey != null
  25196. ? getHighlightDigit(payload.highlightKey)
  25197. : null
  25198. if (dataIndex != null) {
  25199. each$7(normalizeToArray(dataIndex), function (dataIdx) {
  25200. elSetState(
  25201. data.getItemGraphicEl(dataIdx),
  25202. state,
  25203. highlightDigit
  25204. )
  25205. })
  25206. } else {
  25207. data.eachItemGraphicEl(function (el) {
  25208. elSetState(el, state, highlightDigit)
  25209. })
  25210. }
  25211. }
  25212. enableClassExtend(ChartView)
  25213. enableClassManagement(ChartView)
  25214. function renderTaskPlan(context) {
  25215. return renderPlanner(context.model)
  25216. }
  25217. function renderTaskReset(context) {
  25218. var seriesModel = context.model
  25219. var ecModel = context.ecModel
  25220. var api = context.api
  25221. var payload = context.payload // FIXME: remove updateView updateVisual
  25222. var progressiveRender =
  25223. seriesModel.pipelineContext.progressiveRender
  25224. var view = context.view
  25225. var updateMethod = payload && inner$9(payload).updateMethod
  25226. var methodName = progressiveRender
  25227. ? 'incrementalPrepareRender'
  25228. : updateMethod && view[updateMethod]
  25229. ? updateMethod // `appendData` is also supported when data amount
  25230. : // is less than progressive threshold.
  25231. 'render'
  25232. if (methodName !== 'render') {
  25233. view[methodName](seriesModel, ecModel, api, payload)
  25234. }
  25235. return progressMethodMap[methodName]
  25236. }
  25237. var progressMethodMap = {
  25238. incrementalPrepareRender: {
  25239. progress: function progress(params, context) {
  25240. context.view.incrementalRender(
  25241. params,
  25242. context.model,
  25243. context.ecModel,
  25244. context.api,
  25245. context.payload
  25246. )
  25247. }
  25248. },
  25249. render: {
  25250. // Put view.render in `progress` to support appendData. But in this case
  25251. // view.render should not be called in reset, otherwise it will be called
  25252. // twise. Use `forceFirstProgress` to make sure that view.render is called
  25253. // in any cases.
  25254. forceFirstProgress: true,
  25255. progress: function progress(params, context) {
  25256. context.view.render(
  25257. context.model,
  25258. context.ecModel,
  25259. context.api,
  25260. context.payload
  25261. )
  25262. }
  25263. }
  25264. }
  25265. var ChartView$1 = ChartView
  25266. /*
  25267. * Licensed to the Apache Software Foundation (ASF) under one
  25268. * or more contributor license agreements. See the NOTICE file
  25269. * distributed with this work for additional information
  25270. * regarding copyright ownership. The ASF licenses this file
  25271. * to you under the Apache License, Version 2.0 (the
  25272. * "License"); you may not use this file except in compliance
  25273. * with the License. You may obtain a copy of the License at
  25274. *
  25275. * http://www.apache.org/licenses/LICENSE-2.0
  25276. *
  25277. * Unless required by applicable law or agreed to in writing,
  25278. * software distributed under the License is distributed on an
  25279. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25280. * KIND, either express or implied. See the License for the
  25281. * specific language governing permissions and limitations
  25282. * under the License.
  25283. */ /**
  25284. * AUTO-GENERATED FILE. DO NOT MODIFY.
  25285. */ /*
  25286. * Licensed to the Apache Software Foundation (ASF) under one
  25287. * or more contributor license agreements. See the NOTICE file
  25288. * distributed with this work for additional information
  25289. * regarding copyright ownership. The ASF licenses this file
  25290. * to you under the Apache License, Version 2.0 (the
  25291. * "License"); you may not use this file except in compliance
  25292. * with the License. You may obtain a copy of the License at
  25293. *
  25294. * http://www.apache.org/licenses/LICENSE-2.0
  25295. *
  25296. * Unless required by applicable law or agreed to in writing,
  25297. * software distributed under the License is distributed on an
  25298. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  25299. * KIND, either express or implied. See the License for the
  25300. * specific language governing permissions and limitations
  25301. * under the License.
  25302. */ var ORIGIN_METHOD = '\0__throttleOriginMethod'
  25303. var RATE = '\0__throttleRate'
  25304. var THROTTLE_TYPE = '\0__throttleType'
  25305. /**
  25306. * @public
  25307. * @param {(Function)} fn
  25308. * @param {number} [delay=0] Unit: ms.
  25309. * @param {boolean} [debounce=false]
  25310. * true: If call interval less than `delay`, only the last call works.
  25311. * false: If call interval less than `delay, call works on fixed rate.
  25312. * @return {(Function)} throttled fn.
  25313. */ function throttle(fn, delay, debounce) {
  25314. var currCall
  25315. var lastCall = 0
  25316. var lastExec = 0
  25317. var timer = null
  25318. var diff
  25319. var scope
  25320. var args
  25321. var debounceNextCall
  25322. delay = delay || 0
  25323. function exec() {
  25324. lastExec = new Date().getTime()
  25325. timer = null
  25326. fn.apply(scope, args || [])
  25327. }
  25328. var cb = function cb() {
  25329. var cbArgs = []
  25330. for (var _i = 0; _i < arguments.length; _i++) {
  25331. cbArgs[_i] = arguments[_i]
  25332. }
  25333. currCall = new Date().getTime()
  25334. scope = this
  25335. args = cbArgs
  25336. var thisDelay = debounceNextCall || delay
  25337. var thisDebounce = debounceNextCall || debounce
  25338. debounceNextCall = null
  25339. diff = currCall - (thisDebounce ? lastCall : lastExec) - thisDelay
  25340. clearTimeout(timer) // Here we should make sure that: the `exec` SHOULD NOT be called later
  25341. // than a new call of `cb`, that is, preserving the command order. Consider
  25342. // calculating "scale rate" when roaming as an example. When a call of `cb`
  25343. // happens, either the `exec` is called dierectly, or the call is delayed.
  25344. // But the delayed call should never be later than next call of `cb`. Under
  25345. // this assurance, we can simply update view state each time `dispatchAction`
  25346. // triggered by user roaming, but not need to add extra code to avoid the
  25347. // state being "rolled-back".
  25348. if (thisDebounce) {
  25349. timer = setTimeout(exec, thisDelay)
  25350. } else {
  25351. if (diff >= 0) {
  25352. exec()
  25353. } else {
  25354. timer = setTimeout(exec, -diff)
  25355. }
  25356. }
  25357. lastCall = currCall
  25358. }
  25359. /**
  25360. * Clear throttle.
  25361. * @public
  25362. */ cb.clear = function () {
  25363. if (timer) {
  25364. clearTimeout(timer)
  25365. timer = null
  25366. }
  25367. }
  25368. /**
  25369. * Enable debounce once.
  25370. */ cb.debounceNextCall = function (debounceDelay) {
  25371. debounceNextCall = debounceDelay
  25372. }
  25373. return cb
  25374. }
  25375. /**
  25376. * Create throttle method or update throttle rate.
  25377. *
  25378. * @example
  25379. * ComponentView.prototype.render = function () {
  25380. * ...
  25381. * throttle.createOrUpdate(
  25382. * this,
  25383. * '_dispatchAction',
  25384. * this.model.get('throttle'),
  25385. * 'fixRate'
  25386. * );
  25387. * };
  25388. * ComponentView.prototype.remove = function () {
  25389. * throttle.clear(this, '_dispatchAction');
  25390. * };
  25391. * ComponentView.prototype.dispose = function () {
  25392. * throttle.clear(this, '_dispatchAction');
  25393. * };
  25394. *
  25395. */ function createOrUpdate(obj, fnAttr, rate, throttleType) {
  25396. var fn = obj[fnAttr]
  25397. if (!fn) {
  25398. return
  25399. }
  25400. var originFn = fn[ORIGIN_METHOD] || fn
  25401. var lastThrottleType = fn[THROTTLE_TYPE]
  25402. var lastRate = fn[RATE]
  25403. if (lastRate !== rate || lastThrottleType !== throttleType) {
  25404. if (rate == null || !throttleType) {
  25405. return (obj[fnAttr] = originFn)
  25406. }
  25407. fn = obj[fnAttr] = throttle(
  25408. originFn,
  25409. rate,
  25410. throttleType === 'debounce'
  25411. )
  25412. fn[ORIGIN_METHOD] = originFn
  25413. fn[THROTTLE_TYPE] = throttleType
  25414. fn[RATE] = rate
  25415. }
  25416. return fn
  25417. }
  25418. /**
  25419. * Clear throttle. Example see throttle.createOrUpdate.
  25420. */ function clear$1(obj, fnAttr) {
  25421. var fn = obj[fnAttr]
  25422. if (fn && fn[ORIGIN_METHOD]) {
  25423. // Clear throttle
  25424. fn.clear && fn.clear()
  25425. obj[fnAttr] = fn[ORIGIN_METHOD]
  25426. }
  25427. }
  25428. var inner$8 = makeInner()
  25429. var defaultStyleMappers = {
  25430. itemStyle: makeStyleMapper(ITEM_STYLE_KEY_MAP, true),
  25431. lineStyle: makeStyleMapper(LINE_STYLE_KEY_MAP, true)
  25432. }
  25433. var defaultColorKey = { lineStyle: 'stroke', itemStyle: 'fill' }
  25434. function getStyleMapper(seriesModel, stylePath) {
  25435. var styleMapper =
  25436. seriesModel.visualStyleMapper || defaultStyleMappers[stylePath]
  25437. if (!styleMapper) {
  25438. console.warn("Unkown style type '" + stylePath + "'.")
  25439. return defaultStyleMappers.itemStyle
  25440. }
  25441. return styleMapper
  25442. }
  25443. function getDefaultColorKey(seriesModel, stylePath) {
  25444. // return defaultColorKey[stylePath] ||
  25445. var colorKey =
  25446. seriesModel.visualDrawType || defaultColorKey[stylePath]
  25447. if (!colorKey) {
  25448. console.warn("Unkown style type '" + stylePath + "'.")
  25449. return 'fill'
  25450. }
  25451. return colorKey
  25452. }
  25453. var seriesStyleTask = {
  25454. createOnAllSeries: true,
  25455. performRawSeries: true,
  25456. reset: function reset(seriesModel, ecModel) {
  25457. var data = seriesModel.getData()
  25458. var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle' // Set in itemStyle
  25459. var styleModel = seriesModel.getModel(stylePath)
  25460. var getStyle = getStyleMapper(seriesModel, stylePath)
  25461. var globalStyle = getStyle(styleModel)
  25462. var decalOption = styleModel.getShallow('decal')
  25463. if (decalOption) {
  25464. data.setVisual('decal', decalOption)
  25465. decalOption.dirty = true
  25466. } // TODO
  25467. var colorKey = getDefaultColorKey(seriesModel, stylePath)
  25468. var color = globalStyle[colorKey] // TODO style callback
  25469. var colorCallback = isFunction(color) ? color : null
  25470. var hasAutoColor =
  25471. globalStyle.fill === 'auto' || globalStyle.stroke === 'auto' // Get from color palette by default.
  25472. if (!globalStyle[colorKey] || colorCallback || hasAutoColor) {
  25473. // Note: if some series has color specified (e.g., by itemStyle.color), we DO NOT
  25474. // make it effect palette. Bacause some scenarios users need to make some series
  25475. // transparent or as background, which should better not effect the palette.
  25476. var colorPalette = seriesModel.getColorFromPalette(
  25477. // TODO series count changed.
  25478. seriesModel.name,
  25479. null,
  25480. ecModel.getSeriesCount()
  25481. )
  25482. if (!globalStyle[colorKey]) {
  25483. globalStyle[colorKey] = colorPalette
  25484. data.setVisual('colorFromPalette', true)
  25485. }
  25486. globalStyle.fill =
  25487. globalStyle.fill === 'auto' || isFunction(globalStyle.fill)
  25488. ? colorPalette
  25489. : globalStyle.fill
  25490. globalStyle.stroke =
  25491. globalStyle.stroke === 'auto' ||
  25492. isFunction(globalStyle.stroke)
  25493. ? colorPalette
  25494. : globalStyle.stroke
  25495. }
  25496. data.setVisual('style', globalStyle)
  25497. data.setVisual('drawType', colorKey) // Only visible series has each data be visual encoded
  25498. if (!ecModel.isSeriesFiltered(seriesModel) && colorCallback) {
  25499. data.setVisual('colorFromPalette', false)
  25500. return {
  25501. dataEach: function dataEach(data, idx) {
  25502. var dataParams = seriesModel.getDataParams(idx)
  25503. var itemStyle = extend({}, globalStyle)
  25504. itemStyle[colorKey] = colorCallback(dataParams)
  25505. data.setItemVisual(idx, 'style', itemStyle)
  25506. }
  25507. }
  25508. }
  25509. }
  25510. }
  25511. var sharedModel = new Model$1()
  25512. var dataStyleTask = {
  25513. createOnAllSeries: true,
  25514. performRawSeries: true,
  25515. reset: function reset(seriesModel, ecModel) {
  25516. if (
  25517. seriesModel.ignoreStyleOnData ||
  25518. ecModel.isSeriesFiltered(seriesModel)
  25519. ) {
  25520. return
  25521. }
  25522. var data = seriesModel.getData()
  25523. var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle' // Set in itemStyle
  25524. var getStyle = getStyleMapper(seriesModel, stylePath)
  25525. var colorKey = data.getVisual('drawType')
  25526. return {
  25527. dataEach: data.hasItemOption
  25528. ? function (data, idx) {
  25529. // Not use getItemModel for performance considuration
  25530. var rawItem = data.getRawDataItem(idx)
  25531. if (rawItem && rawItem[stylePath]) {
  25532. sharedModel.option = rawItem[stylePath]
  25533. var style = getStyle(sharedModel)
  25534. var existsStyle = data.ensureUniqueItemVisual(
  25535. idx,
  25536. 'style'
  25537. )
  25538. extend(existsStyle, style)
  25539. if (sharedModel.option.decal) {
  25540. data.setItemVisual(
  25541. idx,
  25542. 'decal',
  25543. sharedModel.option.decal
  25544. )
  25545. sharedModel.option.decal.dirty = true
  25546. }
  25547. if (colorKey in style) {
  25548. data.setItemVisual(idx, 'colorFromPalette', false)
  25549. }
  25550. }
  25551. }
  25552. : null
  25553. }
  25554. }
  25555. } // Pick color from palette for the data which has not been set with color yet.
  25556. // Note: do not support stream rendering. No such cases yet.
  25557. var dataColorPaletteTask = {
  25558. performRawSeries: true,
  25559. overallReset: function overallReset(ecModel) {
  25560. // Each type of series use one scope.
  25561. // Pie and funnel are using diferrent scopes
  25562. var paletteScopeGroupByType = createHashMap()
  25563. ecModel.eachSeries(function (seriesModel) {
  25564. var colorBy = seriesModel.getColorBy()
  25565. if (seriesModel.isColorBySeries()) {
  25566. return
  25567. }
  25568. var key = seriesModel.type + '-' + colorBy
  25569. var colorScope = paletteScopeGroupByType.get(key)
  25570. if (!colorScope) {
  25571. colorScope = {}
  25572. paletteScopeGroupByType.set(key, colorScope)
  25573. }
  25574. inner$8(seriesModel).scope = colorScope
  25575. })
  25576. ecModel.eachSeries(function (seriesModel) {
  25577. if (
  25578. seriesModel.isColorBySeries() ||
  25579. ecModel.isSeriesFiltered(seriesModel)
  25580. ) {
  25581. return
  25582. }
  25583. var dataAll = seriesModel.getRawData()
  25584. var idxMap = {}
  25585. var data = seriesModel.getData()
  25586. var colorScope = inner$8(seriesModel).scope
  25587. var stylePath = seriesModel.visualStyleAccessPath || 'itemStyle'
  25588. var colorKey = getDefaultColorKey(seriesModel, stylePath)
  25589. data.each(function (idx) {
  25590. var rawIdx = data.getRawIndex(idx)
  25591. idxMap[rawIdx] = idx
  25592. }) // Iterate on data before filtered. To make sure color from palette can be
  25593. // Consistent when toggling legend.
  25594. dataAll.each(function (rawIdx) {
  25595. var idx = idxMap[rawIdx]
  25596. var fromPalette = data.getItemVisual(idx, 'colorFromPalette') // Get color from palette for each data only when the color is inherited from series color, which is
  25597. // also picked from color palette. So following situation is not in the case:
  25598. // 1. series.itemStyle.color is set
  25599. // 2. color is encoded by visualMap
  25600. if (fromPalette) {
  25601. var itemStyle = data.ensureUniqueItemVisual(idx, 'style')
  25602. var name_1 = dataAll.getName(rawIdx) || rawIdx + ''
  25603. var dataCount = dataAll.count()
  25604. itemStyle[colorKey] = seriesModel.getColorFromPalette(
  25605. name_1,
  25606. colorScope,
  25607. dataCount
  25608. )
  25609. }
  25610. })
  25611. })
  25612. }
  25613. }
  25614. var PI$1 = Math.PI
  25615. /**
  25616. * @param {module:echarts/ExtensionAPI} api
  25617. * @param {Object} [opts]
  25618. * @param {string} [opts.text]
  25619. * @param {string} [opts.color]
  25620. * @param {string} [opts.textColor]
  25621. * @return {module:zrender/Element}
  25622. */ function defaultLoading(api, opts) {
  25623. opts = opts || {}
  25624. defaults(opts, {
  25625. text: 'loading',
  25626. textColor: '#000',
  25627. fontSize: 12,
  25628. fontWeight: 'normal',
  25629. fontStyle: 'normal',
  25630. fontFamily: 'sans-serif',
  25631. maskColor: 'rgba(255, 255, 255, 0.8)',
  25632. showSpinner: true,
  25633. color: '#5470c6',
  25634. spinnerRadius: 10,
  25635. lineWidth: 5,
  25636. zlevel: 0
  25637. })
  25638. var group = new Group$3()
  25639. var mask = new Rect$2({
  25640. style: { fill: opts.maskColor },
  25641. zlevel: opts.zlevel,
  25642. z: 10000
  25643. })
  25644. group.add(mask)
  25645. var textContent = new ZRText$1({
  25646. style: {
  25647. text: opts.text,
  25648. fill: opts.textColor,
  25649. fontSize: opts.fontSize,
  25650. fontWeight: opts.fontWeight,
  25651. fontStyle: opts.fontStyle,
  25652. fontFamily: opts.fontFamily
  25653. },
  25654. zlevel: opts.zlevel,
  25655. z: 10001
  25656. })
  25657. var labelRect = new Rect$2({
  25658. style: { fill: 'none' },
  25659. textContent: textContent,
  25660. textConfig: { position: 'right', distance: 10 },
  25661. zlevel: opts.zlevel,
  25662. z: 10001
  25663. })
  25664. group.add(labelRect)
  25665. var arc
  25666. if (opts.showSpinner) {
  25667. arc = new Arc$1({
  25668. shape: {
  25669. startAngle: -PI$1 / 2,
  25670. endAngle: -PI$1 / 2 + 0.1,
  25671. r: opts.spinnerRadius
  25672. },
  25673. style: {
  25674. stroke: opts.color,
  25675. lineCap: 'round',
  25676. lineWidth: opts.lineWidth
  25677. },
  25678. zlevel: opts.zlevel,
  25679. z: 10001
  25680. })
  25681. arc
  25682. .animateShape(true)
  25683. .when(1000, { endAngle: (PI$1 * 3) / 2 })
  25684. .start('circularInOut')
  25685. arc
  25686. .animateShape(true)
  25687. .when(1000, { startAngle: (PI$1 * 3) / 2 })
  25688. .delay(300)
  25689. .start('circularInOut')
  25690. group.add(arc)
  25691. } // Inject resize
  25692. group.resize = function () {
  25693. var textWidth = textContent.getBoundingRect().width
  25694. var r = opts.showSpinner ? opts.spinnerRadius : 0 // cx = (containerWidth - arcDiameter - textDistance - textWidth) / 2
  25695. // textDistance needs to be calculated when both animation and text exist
  25696. var cx =
  25697. (api.getWidth() -
  25698. r * 2 -
  25699. (opts.showSpinner && textWidth ? 10 : 0) -
  25700. textWidth) /
  25701. 2 -
  25702. (opts.showSpinner && textWidth ? 0 : 5 + textWidth / 2) + // only show the text
  25703. (opts.showSpinner ? 0 : textWidth / 2) + // only show the spinner
  25704. (textWidth ? 0 : r)
  25705. var cy = api.getHeight() / 2
  25706. opts.showSpinner && arc.setShape({ cx: cx, cy: cy })
  25707. labelRect.setShape({
  25708. x: cx - r,
  25709. y: cy - r,
  25710. width: r * 2,
  25711. height: r * 2
  25712. })
  25713. mask.setShape({
  25714. x: 0,
  25715. y: 0,
  25716. width: api.getWidth(),
  25717. height: api.getHeight()
  25718. })
  25719. }
  25720. group.resize()
  25721. return group
  25722. }
  25723. var Scheduler = /** @class */ (function () {
  25724. function Scheduler(
  25725. ecInstance,
  25726. api,
  25727. dataProcessorHandlers,
  25728. visualHandlers
  25729. ) {
  25730. // key: handlerUID
  25731. this._stageTaskMap = createHashMap()
  25732. this.ecInstance = ecInstance
  25733. this.api = api // Fix current processors in case that in some rear cases that
  25734. // processors might be registered after echarts instance created.
  25735. // Register processors incrementally for a echarts instance is
  25736. // not supported by this stream architecture.
  25737. dataProcessorHandlers = this._dataProcessorHandlers =
  25738. dataProcessorHandlers.slice()
  25739. visualHandlers = this._visualHandlers = visualHandlers.slice()
  25740. this._allHandlers = dataProcessorHandlers.concat(visualHandlers)
  25741. }
  25742. Scheduler.prototype.restoreData = function (ecModel, payload) {
  25743. // TODO: Only restore needed series and components, but not all components.
  25744. // Currently `restoreData` of all of the series and component will be called.
  25745. // But some independent components like `title`, `legend`, `graphic`, `toolbox`,
  25746. // `tooltip`, `axisPointer`, etc, do not need series refresh when `setOption`,
  25747. // and some components like coordinate system, axes, dataZoom, visualMap only
  25748. // need their target series refresh.
  25749. // (1) If we are implementing this feature some day, we should consider these cases:
  25750. // if a data processor depends on a component (e.g., dataZoomProcessor depends
  25751. // on the settings of `dataZoom`), it should be re-performed if the component
  25752. // is modified by `setOption`.
  25753. // (2) If a processor depends on sevral series, speicified by its `getTargetSeries`,
  25754. // it should be re-performed when the result array of `getTargetSeries` changed.
  25755. // We use `dependencies` to cover these issues.
  25756. // (3) How to update target series when coordinate system related components modified.
  25757. // TODO: simply the dirty mechanism? Check whether only the case here can set tasks dirty,
  25758. // and this case all of the tasks will be set as dirty.
  25759. ecModel.restoreData(payload) // Theoretically an overall task not only depends on each of its target series, but also
  25760. // depends on all of the series.
  25761. // The overall task is not in pipeline, and `ecModel.restoreData` only set pipeline tasks
  25762. // dirty. If `getTargetSeries` of an overall task returns nothing, we should also ensure
  25763. // that the overall task is set as dirty and to be performed, otherwise it probably cause
  25764. // state chaos. So we have to set dirty of all of the overall tasks manually, otherwise it
  25765. // probably cause state chaos (consider `dataZoomProcessor`).
  25766. this._stageTaskMap.each(function (taskRecord) {
  25767. var overallTask = taskRecord.overallTask
  25768. overallTask && overallTask.dirty()
  25769. })
  25770. } // If seriesModel provided, incremental threshold is check by series data.
  25771. Scheduler.prototype.getPerformArgs = function (task, isBlock) {
  25772. // For overall task
  25773. if (!task.__pipeline) {
  25774. return
  25775. }
  25776. var pipeline = this._pipelineMap.get(task.__pipeline.id)
  25777. var pCtx = pipeline.context
  25778. var incremental =
  25779. !isBlock &&
  25780. pipeline.progressiveEnabled &&
  25781. (!pCtx || pCtx.progressiveRender) &&
  25782. task.__idxInPipeline > pipeline.blockIndex
  25783. var step = incremental ? pipeline.step : null
  25784. var modDataCount = pCtx && pCtx.modDataCount
  25785. var modBy =
  25786. modDataCount != null ? Math.ceil(modDataCount / step) : null
  25787. return { step: step, modBy: modBy, modDataCount: modDataCount }
  25788. }
  25789. Scheduler.prototype.getPipeline = function (pipelineId) {
  25790. return this._pipelineMap.get(pipelineId)
  25791. }
  25792. /**
  25793. * Current, progressive rendering starts from visual and layout.
  25794. * Always detect render mode in the same stage, avoiding that incorrect
  25795. * detection caused by data filtering.
  25796. * Caution:
  25797. * `updateStreamModes` use `seriesModel.getData()`.
  25798. */ Scheduler.prototype.updateStreamModes = function (
  25799. seriesModel,
  25800. view
  25801. ) {
  25802. var pipeline = this._pipelineMap.get(seriesModel.uid)
  25803. var data = seriesModel.getData()
  25804. var dataLen = data.count() // `progressiveRender` means that can render progressively in each
  25805. // animation frame. Note that some types of series do not provide
  25806. // `view.incrementalPrepareRender` but support `chart.appendData`. We
  25807. // use the term `incremental` but not `progressive` to describe the
  25808. // case that `chart.appendData`.
  25809. var progressiveRender =
  25810. pipeline.progressiveEnabled &&
  25811. view.incrementalPrepareRender &&
  25812. dataLen >= pipeline.threshold
  25813. var large =
  25814. seriesModel.get('large') &&
  25815. dataLen >= seriesModel.get('largeThreshold') // TODO: modDataCount should not updated if `appendData`, otherwise cause whole repaint.
  25816. // see `test/candlestick-large3.html`
  25817. var modDataCount =
  25818. seriesModel.get('progressiveChunkMode') === 'mod'
  25819. ? dataLen
  25820. : null
  25821. seriesModel.pipelineContext = pipeline.context = {
  25822. progressiveRender: progressiveRender,
  25823. modDataCount: modDataCount,
  25824. large: large
  25825. }
  25826. }
  25827. Scheduler.prototype.restorePipelines = function (ecModel) {
  25828. var scheduler = this
  25829. var pipelineMap = (scheduler._pipelineMap = createHashMap())
  25830. ecModel.eachSeries(function (seriesModel) {
  25831. var progressive = seriesModel.getProgressive()
  25832. var pipelineId = seriesModel.uid
  25833. pipelineMap.set(pipelineId, {
  25834. id: pipelineId,
  25835. head: null,
  25836. tail: null,
  25837. threshold: seriesModel.getProgressiveThreshold(),
  25838. progressiveEnabled:
  25839. progressive &&
  25840. !(
  25841. seriesModel.preventIncremental &&
  25842. seriesModel.preventIncremental()
  25843. ),
  25844. blockIndex: -1,
  25845. step: Math.round(progressive || 700),
  25846. count: 0
  25847. })
  25848. scheduler._pipe(seriesModel, seriesModel.dataTask)
  25849. })
  25850. }
  25851. Scheduler.prototype.prepareStageTasks = function () {
  25852. var stageTaskMap = this._stageTaskMap
  25853. var ecModel = this.api.getModel()
  25854. var api = this.api
  25855. each$7(
  25856. this._allHandlers,
  25857. function (handler) {
  25858. var record =
  25859. stageTaskMap.get(handler.uid) ||
  25860. stageTaskMap.set(handler.uid, {})
  25861. var errMsg = ''
  25862. assert(!(handler.reset && handler.overallReset), errMsg)
  25863. handler.reset &&
  25864. this._createSeriesStageTask(handler, record, ecModel, api)
  25865. handler.overallReset &&
  25866. this._createOverallStageTask(handler, record, ecModel, api)
  25867. },
  25868. this
  25869. )
  25870. }
  25871. Scheduler.prototype.prepareView = function (
  25872. view,
  25873. model,
  25874. ecModel,
  25875. api
  25876. ) {
  25877. var renderTask = view.renderTask
  25878. var context = renderTask.context
  25879. context.model = model
  25880. context.ecModel = ecModel
  25881. context.api = api
  25882. renderTask.__block = !view.incrementalPrepareRender
  25883. this._pipe(model, renderTask)
  25884. }
  25885. Scheduler.prototype.performDataProcessorTasks = function (
  25886. ecModel,
  25887. payload
  25888. ) {
  25889. // If we do not use `block` here, it should be considered when to update modes.
  25890. this._performStageTasks(
  25891. this._dataProcessorHandlers,
  25892. ecModel,
  25893. payload,
  25894. { block: true }
  25895. )
  25896. }
  25897. Scheduler.prototype.performVisualTasks = function (
  25898. ecModel,
  25899. payload,
  25900. opt
  25901. ) {
  25902. this._performStageTasks(
  25903. this._visualHandlers,
  25904. ecModel,
  25905. payload,
  25906. opt
  25907. )
  25908. }
  25909. Scheduler.prototype._performStageTasks = function (
  25910. stageHandlers,
  25911. ecModel,
  25912. payload,
  25913. opt
  25914. ) {
  25915. opt = opt || {}
  25916. var unfinished = false
  25917. var scheduler = this
  25918. each$7(stageHandlers, function (stageHandler, idx) {
  25919. if (
  25920. opt.visualType &&
  25921. opt.visualType !== stageHandler.visualType
  25922. ) {
  25923. return
  25924. }
  25925. var stageHandlerRecord = scheduler._stageTaskMap.get(
  25926. stageHandler.uid
  25927. )
  25928. var seriesTaskMap = stageHandlerRecord.seriesTaskMap
  25929. var overallTask = stageHandlerRecord.overallTask
  25930. if (overallTask) {
  25931. var overallNeedDirty_1
  25932. var agentStubMap = overallTask.agentStubMap
  25933. agentStubMap.each(function (stub) {
  25934. if (needSetDirty(opt, stub)) {
  25935. stub.dirty()
  25936. overallNeedDirty_1 = true
  25937. }
  25938. })
  25939. overallNeedDirty_1 && overallTask.dirty()
  25940. scheduler.updatePayload(overallTask, payload)
  25941. var performArgs_1 = scheduler.getPerformArgs(
  25942. overallTask,
  25943. opt.block
  25944. ) // Execute stubs firstly, which may set the overall task dirty,
  25945. // then execute the overall task. And stub will call seriesModel.setData,
  25946. // which ensures that in the overallTask seriesModel.getData() will not
  25947. // return incorrect data.
  25948. agentStubMap.each(function (stub) {
  25949. stub.perform(performArgs_1)
  25950. })
  25951. if (overallTask.perform(performArgs_1)) {
  25952. unfinished = true
  25953. }
  25954. } else if (seriesTaskMap) {
  25955. seriesTaskMap.each(function (task, pipelineId) {
  25956. if (needSetDirty(opt, task)) {
  25957. task.dirty()
  25958. }
  25959. var performArgs = scheduler.getPerformArgs(task, opt.block) // FIXME
  25960. // if intending to decalare `performRawSeries` in handlers, only
  25961. // stream-independent (specifically, data item independent) operations can be
  25962. // performed. Because is a series is filtered, most of the tasks will not
  25963. // be performed. A stream-dependent operation probably cause wrong biz logic.
  25964. // Perhaps we should not provide a separate callback for this case instead
  25965. // of providing the config `performRawSeries`. The stream-dependent operaions
  25966. // and stream-independent operations should better not be mixed.
  25967. performArgs.skip =
  25968. !stageHandler.performRawSeries &&
  25969. ecModel.isSeriesFiltered(task.context.model)
  25970. scheduler.updatePayload(task, payload)
  25971. if (task.perform(performArgs)) {
  25972. unfinished = true
  25973. }
  25974. })
  25975. }
  25976. })
  25977. function needSetDirty(opt, task) {
  25978. return (
  25979. opt.setDirty &&
  25980. (!opt.dirtyMap || opt.dirtyMap.get(task.__pipeline.id))
  25981. )
  25982. }
  25983. this.unfinished = unfinished || this.unfinished
  25984. }
  25985. Scheduler.prototype.performSeriesTasks = function (ecModel) {
  25986. var unfinished
  25987. ecModel.eachSeries(function (seriesModel) {
  25988. // Progress to the end for dataInit and dataRestore.
  25989. unfinished = seriesModel.dataTask.perform() || unfinished
  25990. })
  25991. this.unfinished = unfinished || this.unfinished
  25992. }
  25993. Scheduler.prototype.plan = function () {
  25994. // Travel pipelines, check block.
  25995. this._pipelineMap.each(function (pipeline) {
  25996. var task = pipeline.tail
  25997. do {
  25998. if (task.__block) {
  25999. pipeline.blockIndex = task.__idxInPipeline
  26000. break
  26001. }
  26002. task = task.getUpstream()
  26003. } while (task)
  26004. })
  26005. }
  26006. Scheduler.prototype.updatePayload = function (task, payload) {
  26007. payload !== 'remain' && (task.context.payload = payload)
  26008. }
  26009. Scheduler.prototype._createSeriesStageTask = function (
  26010. stageHandler,
  26011. stageHandlerRecord,
  26012. ecModel,
  26013. api
  26014. ) {
  26015. var scheduler = this
  26016. var oldSeriesTaskMap = stageHandlerRecord.seriesTaskMap // The count of stages are totally about only several dozen, so
  26017. // do not need to reuse the map.
  26018. var newSeriesTaskMap = (stageHandlerRecord.seriesTaskMap =
  26019. createHashMap())
  26020. var seriesType = stageHandler.seriesType
  26021. var getTargetSeries = stageHandler.getTargetSeries // If a stageHandler should cover all series, `createOnAllSeries` should be declared mandatorily,
  26022. // to avoid some typo or abuse. Otherwise if an extension do not specify a `seriesType`,
  26023. // it works but it may cause other irrelevant charts blocked.
  26024. if (stageHandler.createOnAllSeries) {
  26025. ecModel.eachRawSeries(create)
  26026. } else if (seriesType) {
  26027. ecModel.eachRawSeriesByType(seriesType, create)
  26028. } else if (getTargetSeries) {
  26029. getTargetSeries(ecModel, api).each(create)
  26030. }
  26031. function create(seriesModel) {
  26032. var pipelineId = seriesModel.uid // Init tasks for each seriesModel only once.
  26033. // Reuse original task instance.
  26034. var task = newSeriesTaskMap.set(
  26035. pipelineId,
  26036. (oldSeriesTaskMap && oldSeriesTaskMap.get(pipelineId)) ||
  26037. createTask({
  26038. plan: seriesTaskPlan,
  26039. reset: seriesTaskReset,
  26040. count: seriesTaskCount
  26041. })
  26042. )
  26043. task.context = {
  26044. model: seriesModel,
  26045. ecModel: ecModel,
  26046. api: api, // PENDING: `useClearVisual` not used?
  26047. useClearVisual:
  26048. stageHandler.isVisual && !stageHandler.isLayout,
  26049. plan: stageHandler.plan,
  26050. reset: stageHandler.reset,
  26051. scheduler: scheduler
  26052. }
  26053. scheduler._pipe(seriesModel, task)
  26054. }
  26055. }
  26056. Scheduler.prototype._createOverallStageTask = function (
  26057. stageHandler,
  26058. stageHandlerRecord,
  26059. ecModel,
  26060. api
  26061. ) {
  26062. var scheduler = this
  26063. var overallTask = (stageHandlerRecord.overallTask =
  26064. stageHandlerRecord.overallTask || // For overall task, the function only be called on reset stage.
  26065. createTask({ reset: overallTaskReset }))
  26066. overallTask.context = {
  26067. ecModel: ecModel,
  26068. api: api,
  26069. overallReset: stageHandler.overallReset,
  26070. scheduler: scheduler
  26071. }
  26072. var oldAgentStubMap = overallTask.agentStubMap // The count of stages are totally about only several dozen, so
  26073. // do not need to reuse the map.
  26074. var newAgentStubMap = (overallTask.agentStubMap = createHashMap())
  26075. var seriesType = stageHandler.seriesType
  26076. var getTargetSeries = stageHandler.getTargetSeries
  26077. var overallProgress = true
  26078. var shouldOverallTaskDirty = false // FIXME:TS never used, so comment it
  26079. // let modifyOutputEnd = stageHandler.modifyOutputEnd;
  26080. // An overall task with seriesType detected or has `getTargetSeries`, we add
  26081. // stub in each pipelines, it will set the overall task dirty when the pipeline
  26082. // progress. Moreover, to avoid call the overall task each frame (too frequent),
  26083. // we set the pipeline block.
  26084. var errMsg = ''
  26085. assert(!stageHandler.createOnAllSeries, errMsg)
  26086. if (seriesType) {
  26087. ecModel.eachRawSeriesByType(seriesType, createStub)
  26088. } else if (getTargetSeries) {
  26089. getTargetSeries(ecModel, api).each(createStub)
  26090. } // Otherwise, (usually it is legancy case), the overall task will only be
  26091. // executed when upstream dirty. Otherwise the progressive rendering of all
  26092. // pipelines will be disabled unexpectedly. But it still needs stubs to receive
  26093. // dirty info from upsteam.
  26094. else {
  26095. overallProgress = false
  26096. each$7(ecModel.getSeries(), createStub)
  26097. }
  26098. function createStub(seriesModel) {
  26099. var pipelineId = seriesModel.uid
  26100. var stub = newAgentStubMap.set(
  26101. pipelineId,
  26102. (oldAgentStubMap && oldAgentStubMap.get(pipelineId)) || // When the result of `getTargetSeries` changed, the overallTask
  26103. // should be set as dirty and re-performed.
  26104. ((shouldOverallTaskDirty = true),
  26105. createTask({ reset: stubReset, onDirty: stubOnDirty }))
  26106. )
  26107. stub.context = {
  26108. model: seriesModel,
  26109. overallProgress: overallProgress // FIXME:TS never used, so comment it
  26110. // modifyOutputEnd: modifyOutputEnd
  26111. }
  26112. stub.agent = overallTask
  26113. stub.__block = overallProgress
  26114. scheduler._pipe(seriesModel, stub)
  26115. }
  26116. if (shouldOverallTaskDirty) {
  26117. overallTask.dirty()
  26118. }
  26119. }
  26120. Scheduler.prototype._pipe = function (seriesModel, task) {
  26121. var pipelineId = seriesModel.uid
  26122. var pipeline = this._pipelineMap.get(pipelineId)
  26123. !pipeline.head && (pipeline.head = task)
  26124. pipeline.tail && pipeline.tail.pipe(task)
  26125. pipeline.tail = task
  26126. task.__idxInPipeline = pipeline.count++
  26127. task.__pipeline = pipeline
  26128. }
  26129. Scheduler.wrapStageHandler = function (stageHandler, visualType) {
  26130. if (isFunction(stageHandler)) {
  26131. stageHandler = {
  26132. overallReset: stageHandler,
  26133. seriesType: detectSeriseType(stageHandler)
  26134. }
  26135. }
  26136. stageHandler.uid = getUID('stageHandler')
  26137. visualType && (stageHandler.visualType = visualType)
  26138. return stageHandler
  26139. }
  26140. return Scheduler
  26141. })()
  26142. function overallTaskReset(context) {
  26143. context.overallReset(context.ecModel, context.api, context.payload)
  26144. }
  26145. function stubReset(context) {
  26146. return context.overallProgress && stubProgress
  26147. }
  26148. function stubProgress() {
  26149. this.agent.dirty()
  26150. this.getDownstream().dirty()
  26151. }
  26152. function stubOnDirty() {
  26153. this.agent && this.agent.dirty()
  26154. }
  26155. function seriesTaskPlan(context) {
  26156. return context.plan
  26157. ? context.plan(
  26158. context.model,
  26159. context.ecModel,
  26160. context.api,
  26161. context.payload
  26162. )
  26163. : null
  26164. }
  26165. function seriesTaskReset(context) {
  26166. if (context.useClearVisual) {
  26167. context.data.clearAllVisual()
  26168. }
  26169. var resetDefines = (context.resetDefines = normalizeToArray(
  26170. context.reset(
  26171. context.model,
  26172. context.ecModel,
  26173. context.api,
  26174. context.payload
  26175. )
  26176. ))
  26177. return resetDefines.length > 1
  26178. ? map$1(resetDefines, function (v, idx) {
  26179. return makeSeriesTaskProgress(idx)
  26180. })
  26181. : singleSeriesTaskProgress
  26182. }
  26183. var singleSeriesTaskProgress = makeSeriesTaskProgress(0)
  26184. function makeSeriesTaskProgress(resetDefineIdx) {
  26185. return function (params, context) {
  26186. var data = context.data
  26187. var resetDefine = context.resetDefines[resetDefineIdx]
  26188. if (resetDefine && resetDefine.dataEach) {
  26189. for (var i = params.start; i < params.end; i++) {
  26190. resetDefine.dataEach(data, i)
  26191. }
  26192. } else if (resetDefine && resetDefine.progress) {
  26193. resetDefine.progress(params, data)
  26194. }
  26195. }
  26196. }
  26197. function seriesTaskCount(context) {
  26198. return context.data.count()
  26199. }
  26200. /**
  26201. * Only some legacy stage handlers (usually in echarts extensions) are pure function.
  26202. * To ensure that they can work normally, they should work in block mode, that is,
  26203. * they should not be started util the previous tasks finished. So they cause the
  26204. * progressive rendering disabled. We try to detect the series type, to narrow down
  26205. * the block range to only the series type they concern, but not all series.
  26206. */ function detectSeriseType(legacyFunc) {
  26207. seriesType = null
  26208. try {
  26209. // Assume there is no async when calling `eachSeriesByType`.
  26210. legacyFunc(ecModelMock, apiMock)
  26211. } catch (e) {}
  26212. return seriesType
  26213. }
  26214. var ecModelMock = {}
  26215. var apiMock = {}
  26216. var seriesType
  26217. mockMethods(ecModelMock, GlobalModel$1)
  26218. mockMethods(apiMock, ExtensionAPI$1)
  26219. ecModelMock.eachSeriesByType = ecModelMock.eachRawSeriesByType =
  26220. function (type) {
  26221. seriesType = type
  26222. }
  26223. ecModelMock.eachComponent = function (cond) {
  26224. if (cond.mainType === 'series' && cond.subType) {
  26225. seriesType = cond.subType
  26226. }
  26227. }
  26228. function mockMethods(target, Clz) {
  26229. /* eslint-disable */ for (var name_1 in Clz.prototype) {
  26230. // Do not use hasOwnProperty
  26231. target[name_1] = noop
  26232. } /* eslint-enable */
  26233. }
  26234. var Scheduler$1 = Scheduler
  26235. /*
  26236. * Licensed to the Apache Software Foundation (ASF) under one
  26237. * or more contributor license agreements. See the NOTICE file
  26238. * distributed with this work for additional information
  26239. * regarding copyright ownership. The ASF licenses this file
  26240. * to you under the Apache License, Version 2.0 (the
  26241. * "License"); you may not use this file except in compliance
  26242. * with the License. You may obtain a copy of the License at
  26243. *
  26244. * http://www.apache.org/licenses/LICENSE-2.0
  26245. *
  26246. * Unless required by applicable law or agreed to in writing,
  26247. * software distributed under the License is distributed on an
  26248. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26249. * KIND, either express or implied. See the License for the
  26250. * specific language governing permissions and limitations
  26251. * under the License.
  26252. */ /**
  26253. * AUTO-GENERATED FILE. DO NOT MODIFY.
  26254. */ /*
  26255. * Licensed to the Apache Software Foundation (ASF) under one
  26256. * or more contributor license agreements. See the NOTICE file
  26257. * distributed with this work for additional information
  26258. * regarding copyright ownership. The ASF licenses this file
  26259. * to you under the Apache License, Version 2.0 (the
  26260. * "License"); you may not use this file except in compliance
  26261. * with the License. You may obtain a copy of the License at
  26262. *
  26263. * http://www.apache.org/licenses/LICENSE-2.0
  26264. *
  26265. * Unless required by applicable law or agreed to in writing,
  26266. * software distributed under the License is distributed on an
  26267. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26268. * KIND, either express or implied. See the License for the
  26269. * specific language governing permissions and limitations
  26270. * under the License.
  26271. */ var colorAll = [
  26272. '#37A2DA',
  26273. '#32C5E9',
  26274. '#67E0E3',
  26275. '#9FE6B8',
  26276. '#FFDB5C',
  26277. '#ff9f7f',
  26278. '#fb7293',
  26279. '#E062AE',
  26280. '#E690D1',
  26281. '#e7bcf3',
  26282. '#9d96f5',
  26283. '#8378EA',
  26284. '#96BFFF'
  26285. ]
  26286. var lightTheme = {
  26287. color: colorAll,
  26288. colorLayer: [
  26289. ['#37A2DA', '#ffd85c', '#fd7b5f'],
  26290. [
  26291. '#37A2DA',
  26292. '#67E0E3',
  26293. '#FFDB5C',
  26294. '#ff9f7f',
  26295. '#E062AE',
  26296. '#9d96f5'
  26297. ],
  26298. [
  26299. '#37A2DA',
  26300. '#32C5E9',
  26301. '#9FE6B8',
  26302. '#FFDB5C',
  26303. '#ff9f7f',
  26304. '#fb7293',
  26305. '#e7bcf3',
  26306. '#8378EA',
  26307. '#96BFFF'
  26308. ],
  26309. colorAll
  26310. ]
  26311. }
  26312. /*
  26313. * Licensed to the Apache Software Foundation (ASF) under one
  26314. * or more contributor license agreements. See the NOTICE file
  26315. * distributed with this work for additional information
  26316. * regarding copyright ownership. The ASF licenses this file
  26317. * to you under the Apache License, Version 2.0 (the
  26318. * "License"); you may not use this file except in compliance
  26319. * with the License. You may obtain a copy of the License at
  26320. *
  26321. * http://www.apache.org/licenses/LICENSE-2.0
  26322. *
  26323. * Unless required by applicable law or agreed to in writing,
  26324. * software distributed under the License is distributed on an
  26325. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26326. * KIND, either express or implied. See the License for the
  26327. * specific language governing permissions and limitations
  26328. * under the License.
  26329. */ /**
  26330. * AUTO-GENERATED FILE. DO NOT MODIFY.
  26331. */ /*
  26332. * Licensed to the Apache Software Foundation (ASF) under one
  26333. * or more contributor license agreements. See the NOTICE file
  26334. * distributed with this work for additional information
  26335. * regarding copyright ownership. The ASF licenses this file
  26336. * to you under the Apache License, Version 2.0 (the
  26337. * "License"); you may not use this file except in compliance
  26338. * with the License. You may obtain a copy of the License at
  26339. *
  26340. * http://www.apache.org/licenses/LICENSE-2.0
  26341. *
  26342. * Unless required by applicable law or agreed to in writing,
  26343. * software distributed under the License is distributed on an
  26344. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26345. * KIND, either express or implied. See the License for the
  26346. * specific language governing permissions and limitations
  26347. * under the License.
  26348. */ var contrastColor = '#B9B8CE'
  26349. var backgroundColor = '#100C2A'
  26350. var axisCommon = function axisCommon() {
  26351. return {
  26352. axisLine: { lineStyle: { color: contrastColor } },
  26353. splitLine: { lineStyle: { color: '#484753' } },
  26354. splitArea: {
  26355. areaStyle: {
  26356. color: ['rgba(255,255,255,0.02)', 'rgba(255,255,255,0.05)']
  26357. }
  26358. },
  26359. minorSplitLine: { lineStyle: { color: '#20203B' } }
  26360. }
  26361. }
  26362. var colorPalette = [
  26363. '#4992ff',
  26364. '#7cffb2',
  26365. '#fddd60',
  26366. '#ff6e76',
  26367. '#58d9f9',
  26368. '#05c091',
  26369. '#ff8a45',
  26370. '#8d48e3',
  26371. '#dd79ff'
  26372. ]
  26373. var theme = {
  26374. darkMode: true,
  26375. color: colorPalette,
  26376. backgroundColor: backgroundColor,
  26377. axisPointer: {
  26378. lineStyle: { color: '#817f91' },
  26379. crossStyle: { color: '#817f91' },
  26380. label: {
  26381. // TODO Contrast of label backgorundColor
  26382. color: '#fff'
  26383. }
  26384. },
  26385. legend: { textStyle: { color: contrastColor } },
  26386. textStyle: { color: contrastColor },
  26387. title: {
  26388. textStyle: { color: '#EEF1FA' },
  26389. subtextStyle: { color: '#B9B8CE' }
  26390. },
  26391. toolbox: { iconStyle: { borderColor: contrastColor } },
  26392. dataZoom: {
  26393. borderColor: '#71708A',
  26394. textStyle: { color: contrastColor },
  26395. brushStyle: { color: 'rgba(135,163,206,0.3)' },
  26396. handleStyle: { color: '#353450', borderColor: '#C5CBE3' },
  26397. moveHandleStyle: { color: '#B0B6C3', opacity: 0.3 },
  26398. fillerColor: 'rgba(135,163,206,0.2)',
  26399. emphasis: {
  26400. handleStyle: { borderColor: '#91B7F2', color: '#4D587D' },
  26401. moveHandleStyle: { color: '#636D9A', opacity: 0.7 }
  26402. },
  26403. dataBackground: {
  26404. lineStyle: { color: '#71708A', width: 1 },
  26405. areaStyle: { color: '#71708A' }
  26406. },
  26407. selectedDataBackground: {
  26408. lineStyle: { color: '#87A3CE' },
  26409. areaStyle: { color: '#87A3CE' }
  26410. }
  26411. },
  26412. visualMap: { textStyle: { color: contrastColor } },
  26413. timeline: {
  26414. lineStyle: { color: contrastColor },
  26415. label: { color: contrastColor },
  26416. controlStyle: { color: contrastColor, borderColor: contrastColor }
  26417. },
  26418. calendar: {
  26419. itemStyle: { color: backgroundColor },
  26420. dayLabel: { color: contrastColor },
  26421. monthLabel: { color: contrastColor },
  26422. yearLabel: { color: contrastColor }
  26423. },
  26424. timeAxis: axisCommon(),
  26425. logAxis: axisCommon(),
  26426. valueAxis: axisCommon(),
  26427. categoryAxis: axisCommon(),
  26428. line: { symbol: 'circle' },
  26429. graph: { color: colorPalette },
  26430. gauge: {
  26431. title: { color: contrastColor },
  26432. axisLine: {
  26433. lineStyle: { color: [[1, 'rgba(207,212,219,0.2)']] }
  26434. },
  26435. axisLabel: { color: contrastColor },
  26436. detail: { color: '#EEF1FA' }
  26437. },
  26438. candlestick: {
  26439. itemStyle: {
  26440. color: '#f64e56',
  26441. color0: '#54ea92',
  26442. borderColor: '#f64e56',
  26443. borderColor0: '#54ea92' // borderColor: '#ca2824',
  26444. // borderColor0: '#09a443'
  26445. }
  26446. }
  26447. }
  26448. theme.categoryAxis.splitLine.show = false
  26449. var darkTheme = theme
  26450. /**
  26451. * Usage of query:
  26452. * `chart.on('click', query, handler);`
  26453. * The `query` can be:
  26454. * + The component type query string, only `mainType` or `mainType.subType`,
  26455. * like: 'xAxis', 'series', 'xAxis.category' or 'series.line'.
  26456. * + The component query object, like:
  26457. * `{seriesIndex: 2}`, `{seriesName: 'xx'}`, `{seriesId: 'some'}`,
  26458. * `{xAxisIndex: 2}`, `{xAxisName: 'xx'}`, `{xAxisId: 'some'}`.
  26459. * + The data query object, like:
  26460. * `{dataIndex: 123}`, `{dataType: 'link'}`, `{name: 'some'}`.
  26461. * + The other query object (cmponent customized query), like:
  26462. * `{element: 'some'}` (only available in custom series).
  26463. *
  26464. * Caveat: If a prop in the `query` object is `null/undefined`, it is the
  26465. * same as there is no such prop in the `query` object.
  26466. */ var ECEventProcessor = /** @class */ (function () {
  26467. function ECEventProcessor() {}
  26468. ECEventProcessor.prototype.normalizeQuery = function (query) {
  26469. var cptQuery = {}
  26470. var dataQuery = {}
  26471. var otherQuery = {} // `query` is `mainType` or `mainType.subType` of component.
  26472. if (isString(query)) {
  26473. var condCptType = parseClassType(query) // `.main` and `.sub` may be ''.
  26474. cptQuery.mainType = condCptType.main || null
  26475. cptQuery.subType = condCptType.sub || null
  26476. } // `query` is an object, convert to {mainType, index, name, id}.
  26477. else {
  26478. // `xxxIndex`, `xxxName`, `xxxId`, `name`, `dataIndex`, `dataType` is reserved,
  26479. // can not be used in `compomentModel.filterForExposedEvent`.
  26480. var suffixes_1 = ['Index', 'Name', 'Id']
  26481. var dataKeys_1 = { name: 1, dataIndex: 1, dataType: 1 }
  26482. each$7(query, function (val, key) {
  26483. var reserved = false
  26484. for (var i = 0; i < suffixes_1.length; i++) {
  26485. var propSuffix = suffixes_1[i]
  26486. var suffixPos = key.lastIndexOf(propSuffix)
  26487. if (
  26488. suffixPos > 0 &&
  26489. suffixPos === key.length - propSuffix.length
  26490. ) {
  26491. var mainType = key.slice(0, suffixPos) // Consider `dataIndex`.
  26492. if (mainType !== 'data') {
  26493. cptQuery.mainType = mainType
  26494. cptQuery[propSuffix.toLowerCase()] = val
  26495. reserved = true
  26496. }
  26497. }
  26498. }
  26499. if (dataKeys_1.hasOwnProperty(key)) {
  26500. dataQuery[key] = val
  26501. reserved = true
  26502. }
  26503. if (!reserved) {
  26504. otherQuery[key] = val
  26505. }
  26506. })
  26507. }
  26508. return {
  26509. cptQuery: cptQuery,
  26510. dataQuery: dataQuery,
  26511. otherQuery: otherQuery
  26512. }
  26513. }
  26514. ECEventProcessor.prototype.filter = function (eventType, query) {
  26515. // They should be assigned before each trigger call.
  26516. var eventInfo = this.eventInfo
  26517. if (!eventInfo) {
  26518. return true
  26519. }
  26520. var targetEl = eventInfo.targetEl
  26521. var packedEvent = eventInfo.packedEvent
  26522. var model = eventInfo.model
  26523. var view = eventInfo.view // For event like 'globalout'.
  26524. if (!model || !view) {
  26525. return true
  26526. }
  26527. var cptQuery = query.cptQuery
  26528. var dataQuery = query.dataQuery
  26529. return (
  26530. check(cptQuery, model, 'mainType') &&
  26531. check(cptQuery, model, 'subType') &&
  26532. check(cptQuery, model, 'index', 'componentIndex') &&
  26533. check(cptQuery, model, 'name') &&
  26534. check(cptQuery, model, 'id') &&
  26535. check(dataQuery, packedEvent, 'name') &&
  26536. check(dataQuery, packedEvent, 'dataIndex') &&
  26537. check(dataQuery, packedEvent, 'dataType') &&
  26538. (!view.filterForExposedEvent ||
  26539. view.filterForExposedEvent(
  26540. eventType,
  26541. query.otherQuery,
  26542. targetEl,
  26543. packedEvent
  26544. ))
  26545. )
  26546. function check(query, host, prop, propOnHost) {
  26547. return (
  26548. query[prop] == null ||
  26549. host[propOnHost || prop] === query[prop]
  26550. )
  26551. }
  26552. }
  26553. ECEventProcessor.prototype.afterTrigger = function () {
  26554. // Make sure the eventInfo wont be used in next trigger.
  26555. this.eventInfo = null
  26556. }
  26557. return ECEventProcessor
  26558. })()
  26559. var SYMBOL_PROPS_WITH_CB = [
  26560. 'symbol',
  26561. 'symbolSize',
  26562. 'symbolRotate',
  26563. 'symbolOffset'
  26564. ]
  26565. var SYMBOL_PROPS = SYMBOL_PROPS_WITH_CB.concat(['symbolKeepAspect']) // Encoding visual for all series include which is filtered for legend drawing
  26566. var seriesSymbolTask = {
  26567. createOnAllSeries: true, // For legend.
  26568. performRawSeries: true,
  26569. reset: function reset(seriesModel, ecModel) {
  26570. var data = seriesModel.getData()
  26571. if (seriesModel.legendIcon) {
  26572. data.setVisual('legendIcon', seriesModel.legendIcon)
  26573. }
  26574. if (!seriesModel.hasSymbolVisual) {
  26575. return
  26576. }
  26577. var symbolOptions = {}
  26578. var symbolOptionsCb = {}
  26579. var hasCallback = false
  26580. for (var i = 0; i < SYMBOL_PROPS_WITH_CB.length; i++) {
  26581. var symbolPropName = SYMBOL_PROPS_WITH_CB[i]
  26582. var val = seriesModel.get(symbolPropName)
  26583. if (isFunction(val)) {
  26584. hasCallback = true
  26585. symbolOptionsCb[symbolPropName] = val
  26586. } else {
  26587. symbolOptions[symbolPropName] = val
  26588. }
  26589. }
  26590. symbolOptions.symbol =
  26591. symbolOptions.symbol || seriesModel.defaultSymbol
  26592. data.setVisual(
  26593. extend(
  26594. {
  26595. legendIcon: seriesModel.legendIcon || symbolOptions.symbol,
  26596. symbolKeepAspect: seriesModel.get('symbolKeepAspect')
  26597. },
  26598. symbolOptions
  26599. )
  26600. ) // Only visible series has each data be visual encoded
  26601. if (ecModel.isSeriesFiltered(seriesModel)) {
  26602. return
  26603. }
  26604. var symbolPropsCb = keys(symbolOptionsCb)
  26605. function dataEach(data, idx) {
  26606. var rawValue = seriesModel.getRawValue(idx)
  26607. var params = seriesModel.getDataParams(idx)
  26608. for (var i = 0; i < symbolPropsCb.length; i++) {
  26609. var symbolPropName = symbolPropsCb[i]
  26610. data.setItemVisual(
  26611. idx,
  26612. symbolPropName,
  26613. symbolOptionsCb[symbolPropName](rawValue, params)
  26614. )
  26615. }
  26616. }
  26617. return { dataEach: hasCallback ? dataEach : null }
  26618. }
  26619. }
  26620. var dataSymbolTask = {
  26621. createOnAllSeries: true, // For legend.
  26622. performRawSeries: true,
  26623. reset: function reset(seriesModel, ecModel) {
  26624. if (!seriesModel.hasSymbolVisual) {
  26625. return
  26626. } // Only visible series has each data be visual encoded
  26627. if (ecModel.isSeriesFiltered(seriesModel)) {
  26628. return
  26629. }
  26630. var data = seriesModel.getData()
  26631. function dataEach(data, idx) {
  26632. var itemModel = data.getItemModel(idx)
  26633. for (var i = 0; i < SYMBOL_PROPS.length; i++) {
  26634. var symbolPropName = SYMBOL_PROPS[i]
  26635. var val = itemModel.getShallow(symbolPropName, true)
  26636. if (val != null) {
  26637. data.setItemVisual(idx, symbolPropName, val)
  26638. }
  26639. }
  26640. }
  26641. return { dataEach: data.hasItemOption ? dataEach : null }
  26642. }
  26643. }
  26644. /*
  26645. * Licensed to the Apache Software Foundation (ASF) under one
  26646. * or more contributor license agreements. See the NOTICE file
  26647. * distributed with this work for additional information
  26648. * regarding copyright ownership. The ASF licenses this file
  26649. * to you under the Apache License, Version 2.0 (the
  26650. * "License"); you may not use this file except in compliance
  26651. * with the License. You may obtain a copy of the License at
  26652. *
  26653. * http://www.apache.org/licenses/LICENSE-2.0
  26654. *
  26655. * Unless required by applicable law or agreed to in writing,
  26656. * software distributed under the License is distributed on an
  26657. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26658. * KIND, either express or implied. See the License for the
  26659. * specific language governing permissions and limitations
  26660. * under the License.
  26661. */ /**
  26662. * AUTO-GENERATED FILE. DO NOT MODIFY.
  26663. */ /*
  26664. * Licensed to the Apache Software Foundation (ASF) under one
  26665. * or more contributor license agreements. See the NOTICE file
  26666. * distributed with this work for additional information
  26667. * regarding copyright ownership. The ASF licenses this file
  26668. * to you under the Apache License, Version 2.0 (the
  26669. * "License"); you may not use this file except in compliance
  26670. * with the License. You may obtain a copy of the License at
  26671. *
  26672. * http://www.apache.org/licenses/LICENSE-2.0
  26673. *
  26674. * Unless required by applicable law or agreed to in writing,
  26675. * software distributed under the License is distributed on an
  26676. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26677. * KIND, either express or implied. See the License for the
  26678. * specific language governing permissions and limitations
  26679. * under the License.
  26680. */ function getItemVisualFromData(data, dataIndex, key) {
  26681. switch (key) {
  26682. case 'color':
  26683. var style = data.getItemVisual(dataIndex, 'style')
  26684. return style[data.getVisual('drawType')]
  26685. case 'opacity':
  26686. return data.getItemVisual(dataIndex, 'style').opacity
  26687. case 'symbol':
  26688. case 'symbolSize':
  26689. case 'liftZ':
  26690. return data.getItemVisual(dataIndex, key)
  26691. }
  26692. }
  26693. function getVisualFromData(data, key) {
  26694. switch (key) {
  26695. case 'color':
  26696. var style = data.getVisual('style')
  26697. return style[data.getVisual('drawType')]
  26698. case 'opacity':
  26699. return data.getVisual('style').opacity
  26700. case 'symbol':
  26701. case 'symbolSize':
  26702. case 'liftZ':
  26703. return data.getVisual(key)
  26704. }
  26705. } // Inlucdes: pieSelect, pieUnSelect, pieToggleSelect, mapSelect, mapUnSelect, mapToggleSelect
  26706. function createLegacyDataSelectAction(seriesType, ecRegisterAction) {
  26707. function getSeriesIndices(ecModel, payload) {
  26708. var seriesIndices = []
  26709. ecModel.eachComponent(
  26710. { mainType: 'series', subType: seriesType, query: payload },
  26711. function (seriesModel) {
  26712. seriesIndices.push(seriesModel.seriesIndex)
  26713. }
  26714. )
  26715. return seriesIndices
  26716. }
  26717. each$7(
  26718. [
  26719. [seriesType + 'ToggleSelect', 'toggleSelect'],
  26720. [seriesType + 'Select', 'select'],
  26721. [seriesType + 'UnSelect', 'unselect']
  26722. ],
  26723. function (eventsMap) {
  26724. ecRegisterAction(
  26725. eventsMap[0],
  26726. function (payload, ecModel, api) {
  26727. payload = extend({}, payload)
  26728. api.dispatchAction(
  26729. extend(payload, {
  26730. type: eventsMap[1],
  26731. seriesIndex: getSeriesIndices(ecModel, payload)
  26732. })
  26733. )
  26734. }
  26735. )
  26736. }
  26737. )
  26738. }
  26739. function handleSeriesLegacySelectEvents(
  26740. type,
  26741. eventPostfix,
  26742. ecIns,
  26743. ecModel,
  26744. payload
  26745. ) {
  26746. var legacyEventName = type + eventPostfix
  26747. if (!ecIns.isSilent(legacyEventName)) {
  26748. ecModel.eachComponent(
  26749. { mainType: 'series', subType: 'pie' },
  26750. function (seriesModel) {
  26751. var seriesIndex = seriesModel.seriesIndex
  26752. var selectedMap = seriesModel.option.selectedMap
  26753. var selected = payload.selected
  26754. for (var i = 0; i < selected.length; i++) {
  26755. if (selected[i].seriesIndex === seriesIndex) {
  26756. var data = seriesModel.getData()
  26757. var dataIndex = queryDataIndex(
  26758. data,
  26759. payload.fromActionPayload
  26760. )
  26761. ecIns.trigger(legacyEventName, {
  26762. type: legacyEventName,
  26763. seriesId: seriesModel.id,
  26764. name: isArray(dataIndex)
  26765. ? data.getName(dataIndex[0])
  26766. : data.getName(dataIndex),
  26767. selected: isString(selectedMap)
  26768. ? selectedMap
  26769. : extend({}, selectedMap)
  26770. })
  26771. }
  26772. }
  26773. }
  26774. )
  26775. }
  26776. }
  26777. function handleLegacySelectEvents(messageCenter, ecIns, api) {
  26778. messageCenter.on('selectchanged', function (params) {
  26779. var ecModel = api.getModel()
  26780. if (params.isFromClick) {
  26781. handleSeriesLegacySelectEvents(
  26782. 'map',
  26783. 'selectchanged',
  26784. ecIns,
  26785. ecModel,
  26786. params
  26787. )
  26788. handleSeriesLegacySelectEvents(
  26789. 'pie',
  26790. 'selectchanged',
  26791. ecIns,
  26792. ecModel,
  26793. params
  26794. )
  26795. } else if (params.fromAction === 'select') {
  26796. handleSeriesLegacySelectEvents(
  26797. 'map',
  26798. 'selected',
  26799. ecIns,
  26800. ecModel,
  26801. params
  26802. )
  26803. handleSeriesLegacySelectEvents(
  26804. 'pie',
  26805. 'selected',
  26806. ecIns,
  26807. ecModel,
  26808. params
  26809. )
  26810. } else if (params.fromAction === 'unselect') {
  26811. handleSeriesLegacySelectEvents(
  26812. 'map',
  26813. 'unselected',
  26814. ecIns,
  26815. ecModel,
  26816. params
  26817. )
  26818. handleSeriesLegacySelectEvents(
  26819. 'pie',
  26820. 'unselected',
  26821. ecIns,
  26822. ecModel,
  26823. params
  26824. )
  26825. }
  26826. })
  26827. }
  26828. /*
  26829. * Licensed to the Apache Software Foundation (ASF) under one
  26830. * or more contributor license agreements. See the NOTICE file
  26831. * distributed with this work for additional information
  26832. * regarding copyright ownership. The ASF licenses this file
  26833. * to you under the Apache License, Version 2.0 (the
  26834. * "License"); you may not use this file except in compliance
  26835. * with the License. You may obtain a copy of the License at
  26836. *
  26837. * http://www.apache.org/licenses/LICENSE-2.0
  26838. *
  26839. * Unless required by applicable law or agreed to in writing,
  26840. * software distributed under the License is distributed on an
  26841. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26842. * KIND, either express or implied. See the License for the
  26843. * specific language governing permissions and limitations
  26844. * under the License.
  26845. */ /**
  26846. * AUTO-GENERATED FILE. DO NOT MODIFY.
  26847. */ /*
  26848. * Licensed to the Apache Software Foundation (ASF) under one
  26849. * or more contributor license agreements. See the NOTICE file
  26850. * distributed with this work for additional information
  26851. * regarding copyright ownership. The ASF licenses this file
  26852. * to you under the Apache License, Version 2.0 (the
  26853. * "License"); you may not use this file except in compliance
  26854. * with the License. You may obtain a copy of the License at
  26855. *
  26856. * http://www.apache.org/licenses/LICENSE-2.0
  26857. *
  26858. * Unless required by applicable law or agreed to in writing,
  26859. * software distributed under the License is distributed on an
  26860. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  26861. * KIND, either express or implied. See the License for the
  26862. * specific language governing permissions and limitations
  26863. * under the License.
  26864. */ function findEventDispatcher(target, det, returnFirstMatch) {
  26865. var found
  26866. while (target) {
  26867. if (det(target)) {
  26868. found = target
  26869. if (returnFirstMatch) {
  26870. break
  26871. }
  26872. }
  26873. target = target.__hostTarget || target.parent
  26874. }
  26875. return found
  26876. }
  26877. var wmUniqueIndex = Math.round(Math.random() * 9)
  26878. var supportDefineProperty =
  26879. typeof Object.defineProperty === 'function'
  26880. var WeakMap = (function () {
  26881. function WeakMap() {
  26882. this._id = '__ec_inner_' + wmUniqueIndex++
  26883. }
  26884. WeakMap.prototype.get = function (key) {
  26885. return this._guard(key)[this._id]
  26886. }
  26887. WeakMap.prototype.set = function (key, value) {
  26888. var target = this._guard(key)
  26889. if (supportDefineProperty) {
  26890. Object.defineProperty(target, this._id, {
  26891. value: value,
  26892. enumerable: false,
  26893. configurable: true
  26894. })
  26895. } else {
  26896. target[this._id] = value
  26897. }
  26898. return this
  26899. }
  26900. WeakMap.prototype['delete'] = function (key) {
  26901. if (this.has(key)) {
  26902. delete this._guard(key)[this._id]
  26903. return true
  26904. }
  26905. return false
  26906. }
  26907. WeakMap.prototype.has = function (key) {
  26908. return !!this._guard(key)[this._id]
  26909. }
  26910. WeakMap.prototype._guard = function (key) {
  26911. if (key !== Object(key)) {
  26912. throw TypeError('Value of WeakMap is not a non-null object.')
  26913. }
  26914. return key
  26915. }
  26916. return WeakMap
  26917. })()
  26918. var WeakMap$1 = WeakMap
  26919. /**
  26920. * Triangle shape
  26921. * @inner
  26922. */ var Triangle = Path$1.extend({
  26923. type: 'triangle',
  26924. shape: { cx: 0, cy: 0, width: 0, height: 0 },
  26925. buildPath: function buildPath(path, shape) {
  26926. var cx = shape.cx
  26927. var cy = shape.cy
  26928. var width = shape.width / 2
  26929. var height = shape.height / 2
  26930. path.moveTo(cx, cy - height)
  26931. path.lineTo(cx + width, cy + height)
  26932. path.lineTo(cx - width, cy + height)
  26933. path.closePath()
  26934. }
  26935. })
  26936. /**
  26937. * Diamond shape
  26938. * @inner
  26939. */ var Diamond = Path$1.extend({
  26940. type: 'diamond',
  26941. shape: { cx: 0, cy: 0, width: 0, height: 0 },
  26942. buildPath: function buildPath(path, shape) {
  26943. var cx = shape.cx
  26944. var cy = shape.cy
  26945. var width = shape.width / 2
  26946. var height = shape.height / 2
  26947. path.moveTo(cx, cy - height)
  26948. path.lineTo(cx + width, cy)
  26949. path.lineTo(cx, cy + height)
  26950. path.lineTo(cx - width, cy)
  26951. path.closePath()
  26952. }
  26953. })
  26954. /**
  26955. * Pin shape
  26956. * @inner
  26957. */ var Pin = Path$1.extend({
  26958. type: 'pin',
  26959. shape: {
  26960. // x, y on the cusp
  26961. x: 0,
  26962. y: 0,
  26963. width: 0,
  26964. height: 0
  26965. },
  26966. buildPath: function buildPath(path, shape) {
  26967. var x = shape.x
  26968. var y = shape.y
  26969. var w = (shape.width / 5) * 3 // Height must be larger than width
  26970. var h = Math.max(w, shape.height)
  26971. var r = w / 2 // Dist on y with tangent point and circle center
  26972. var dy = (r * r) / (h - r)
  26973. var cy = y - h + r + dy
  26974. var angle = Math.asin(dy / r) // Dist on x with tangent point and circle center
  26975. var dx = Math.cos(angle) * r
  26976. var tanX = Math.sin(angle)
  26977. var tanY = Math.cos(angle)
  26978. var cpLen = r * 0.6
  26979. var cpLen2 = r * 0.7
  26980. path.moveTo(x - dx, cy + dy)
  26981. path.arc(x, cy, r, Math.PI - angle, Math.PI * 2 + angle)
  26982. path.bezierCurveTo(
  26983. x + dx - tanX * cpLen,
  26984. cy + dy + tanY * cpLen,
  26985. x,
  26986. y - cpLen2,
  26987. x,
  26988. y
  26989. )
  26990. path.bezierCurveTo(
  26991. x,
  26992. y - cpLen2,
  26993. x - dx + tanX * cpLen,
  26994. cy + dy + tanY * cpLen,
  26995. x - dx,
  26996. cy + dy
  26997. )
  26998. path.closePath()
  26999. }
  27000. })
  27001. /**
  27002. * Arrow shape
  27003. * @inner
  27004. */ var Arrow = Path$1.extend({
  27005. type: 'arrow',
  27006. shape: { x: 0, y: 0, width: 0, height: 0 },
  27007. buildPath: function buildPath(ctx, shape) {
  27008. var height = shape.height
  27009. var width = shape.width
  27010. var x = shape.x
  27011. var y = shape.y
  27012. var dx = (width / 3) * 2
  27013. ctx.moveTo(x, y)
  27014. ctx.lineTo(x + dx, y + height)
  27015. ctx.lineTo(x, y + (height / 4) * 3)
  27016. ctx.lineTo(x - dx, y + height)
  27017. ctx.lineTo(x, y)
  27018. ctx.closePath()
  27019. }
  27020. })
  27021. /**
  27022. * Map of path contructors
  27023. */ // TODO Use function to build symbol path.
  27024. var symbolCtors = {
  27025. line: Line$1,
  27026. rect: Rect$2,
  27027. roundRect: Rect$2,
  27028. square: Rect$2,
  27029. circle: Circle$1,
  27030. diamond: Diamond,
  27031. pin: Pin,
  27032. arrow: Arrow,
  27033. triangle: Triangle
  27034. }
  27035. var symbolShapeMakers = {
  27036. line: function line(x, y, w, h, shape) {
  27037. shape.x1 = x
  27038. shape.y1 = y + h / 2
  27039. shape.x2 = x + w
  27040. shape.y2 = y + h / 2
  27041. },
  27042. rect: function rect(x, y, w, h, shape) {
  27043. shape.x = x
  27044. shape.y = y
  27045. shape.width = w
  27046. shape.height = h
  27047. },
  27048. roundRect: function roundRect(x, y, w, h, shape) {
  27049. shape.x = x
  27050. shape.y = y
  27051. shape.width = w
  27052. shape.height = h
  27053. shape.r = Math.min(w, h) / 4
  27054. },
  27055. square: function square(x, y, w, h, shape) {
  27056. var size = Math.min(w, h)
  27057. shape.x = x
  27058. shape.y = y
  27059. shape.width = size
  27060. shape.height = size
  27061. },
  27062. circle: function circle(x, y, w, h, shape) {
  27063. // Put circle in the center of square
  27064. shape.cx = x + w / 2
  27065. shape.cy = y + h / 2
  27066. shape.r = Math.min(w, h) / 2
  27067. },
  27068. diamond: function diamond(x, y, w, h, shape) {
  27069. shape.cx = x + w / 2
  27070. shape.cy = y + h / 2
  27071. shape.width = w
  27072. shape.height = h
  27073. },
  27074. pin: function pin(x, y, w, h, shape) {
  27075. shape.x = x + w / 2
  27076. shape.y = y + h / 2
  27077. shape.width = w
  27078. shape.height = h
  27079. },
  27080. arrow: function arrow(x, y, w, h, shape) {
  27081. shape.x = x + w / 2
  27082. shape.y = y + h / 2
  27083. shape.width = w
  27084. shape.height = h
  27085. },
  27086. triangle: function triangle(x, y, w, h, shape) {
  27087. shape.cx = x + w / 2
  27088. shape.cy = y + h / 2
  27089. shape.width = w
  27090. shape.height = h
  27091. }
  27092. }
  27093. var symbolBuildProxies = {}
  27094. each$7(symbolCtors, function (Ctor, name) {
  27095. symbolBuildProxies[name] = new Ctor()
  27096. })
  27097. var SymbolClz$1 = Path$1.extend({
  27098. type: 'symbol',
  27099. shape: { symbolType: '', x: 0, y: 0, width: 0, height: 0 },
  27100. calculateTextPosition: function calculateTextPosition(
  27101. out,
  27102. config,
  27103. rect
  27104. ) {
  27105. var res = _calculateTextPosition(out, config, rect)
  27106. var shape = this.shape
  27107. if (
  27108. shape &&
  27109. shape.symbolType === 'pin' &&
  27110. config.position === 'inside'
  27111. ) {
  27112. res.y = rect.y + rect.height * 0.4
  27113. }
  27114. return res
  27115. },
  27116. buildPath: function buildPath(ctx, shape, inBundle) {
  27117. var symbolType = shape.symbolType
  27118. if (symbolType !== 'none') {
  27119. var proxySymbol = symbolBuildProxies[symbolType]
  27120. if (!proxySymbol) {
  27121. // Default rect
  27122. symbolType = 'rect'
  27123. proxySymbol = symbolBuildProxies[symbolType]
  27124. }
  27125. symbolShapeMakers[symbolType](
  27126. shape.x,
  27127. shape.y,
  27128. shape.width,
  27129. shape.height,
  27130. proxySymbol.shape
  27131. )
  27132. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle)
  27133. }
  27134. }
  27135. }) // Provide setColor helper method to avoid determine if set the fill or stroke outside
  27136. function symbolPathSetColor(color, innerColor) {
  27137. if (this.type !== 'image') {
  27138. var symbolStyle = this.style
  27139. if (this.__isEmptyBrush) {
  27140. symbolStyle.stroke = color
  27141. symbolStyle.fill = innerColor || '#fff' // TODO Same width with lineStyle in LineView
  27142. symbolStyle.lineWidth = 2
  27143. } else if (this.shape.symbolType === 'line') {
  27144. symbolStyle.stroke = color
  27145. } else {
  27146. symbolStyle.fill = color
  27147. }
  27148. this.markRedraw()
  27149. }
  27150. }
  27151. /**
  27152. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  27153. */ function createSymbol(
  27154. symbolType,
  27155. x,
  27156. y,
  27157. w,
  27158. h,
  27159. color, // whether to keep the ratio of w/h,
  27160. keepAspect
  27161. ) {
  27162. // TODO Support image object, DynamicImage.
  27163. var isEmpty = symbolType.indexOf('empty') === 0
  27164. if (isEmpty) {
  27165. symbolType =
  27166. symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6)
  27167. }
  27168. var symbolPath
  27169. if (symbolType.indexOf('image://') === 0) {
  27170. symbolPath = makeImage(
  27171. symbolType.slice(8),
  27172. new BoundingRect$1(x, y, w, h),
  27173. keepAspect ? 'center' : 'cover'
  27174. )
  27175. } else if (symbolType.indexOf('path://') === 0) {
  27176. symbolPath = makePath(
  27177. symbolType.slice(7),
  27178. {},
  27179. new BoundingRect$1(x, y, w, h),
  27180. keepAspect ? 'center' : 'cover'
  27181. )
  27182. } else {
  27183. symbolPath = new SymbolClz$1({
  27184. shape: {
  27185. symbolType: symbolType,
  27186. x: x,
  27187. y: y,
  27188. width: w,
  27189. height: h
  27190. }
  27191. })
  27192. }
  27193. symbolPath.__isEmptyBrush = isEmpty // TODO Should deprecate setColor
  27194. symbolPath.setColor = symbolPathSetColor
  27195. if (color) {
  27196. symbolPath.setColor(color)
  27197. }
  27198. return symbolPath
  27199. }
  27200. function normalizeSymbolSize(symbolSize) {
  27201. if (!isArray(symbolSize)) {
  27202. symbolSize = [+symbolSize, +symbolSize]
  27203. }
  27204. return [symbolSize[0] || 0, symbolSize[1] || 0]
  27205. }
  27206. function normalizeSymbolOffset(symbolOffset, symbolSize) {
  27207. if (symbolOffset == null) {
  27208. return
  27209. }
  27210. if (!isArray(symbolOffset)) {
  27211. symbolOffset = [symbolOffset, symbolOffset]
  27212. }
  27213. return [
  27214. parsePercent(symbolOffset[0], symbolSize[0]) || 0,
  27215. parsePercent(
  27216. retrieve2(symbolOffset[1], symbolOffset[0]),
  27217. symbolSize[1]
  27218. ) || 0
  27219. ]
  27220. }
  27221. function isSafeNum(num) {
  27222. return isFinite(num)
  27223. }
  27224. function createLinearGradient(ctx, obj, rect) {
  27225. var x = obj.x == null ? 0 : obj.x
  27226. var x2 = obj.x2 == null ? 1 : obj.x2
  27227. var y = obj.y == null ? 0 : obj.y
  27228. var y2 = obj.y2 == null ? 0 : obj.y2
  27229. if (!obj.global) {
  27230. x = x * rect.width + rect.x
  27231. x2 = x2 * rect.width + rect.x
  27232. y = y * rect.height + rect.y
  27233. y2 = y2 * rect.height + rect.y
  27234. }
  27235. x = isSafeNum(x) ? x : 0
  27236. x2 = isSafeNum(x2) ? x2 : 1
  27237. y = isSafeNum(y) ? y : 0
  27238. y2 = isSafeNum(y2) ? y2 : 0
  27239. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2)
  27240. return canvasGradient
  27241. }
  27242. function createRadialGradient(ctx, obj, rect) {
  27243. var width = rect.width
  27244. var height = rect.height
  27245. var min = Math.min(width, height)
  27246. var x = obj.x == null ? 0.5 : obj.x
  27247. var y = obj.y == null ? 0.5 : obj.y
  27248. var r = obj.r == null ? 0.5 : obj.r
  27249. if (!obj.global) {
  27250. x = x * width + rect.x
  27251. y = y * height + rect.y
  27252. r = r * min
  27253. }
  27254. x = isSafeNum(x) ? x : 0.5
  27255. y = isSafeNum(y) ? y : 0.5
  27256. r = r >= 0 && isSafeNum(r) ? r : 0.5
  27257. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r)
  27258. return canvasGradient
  27259. }
  27260. function getCanvasGradient(ctx, obj, rect) {
  27261. var canvasGradient =
  27262. obj.type === 'radial'
  27263. ? createRadialGradient(ctx, obj, rect)
  27264. : createLinearGradient(ctx, obj, rect)
  27265. var colorStops = obj.colorStops
  27266. for (var i = 0; i < colorStops.length; i++) {
  27267. canvasGradient.addColorStop(
  27268. colorStops[i].offset,
  27269. colorStops[i].color
  27270. )
  27271. }
  27272. return canvasGradient
  27273. }
  27274. function isClipPathChanged(clipPaths, prevClipPaths) {
  27275. if (clipPaths === prevClipPaths || (!clipPaths && !prevClipPaths)) {
  27276. return false
  27277. }
  27278. if (
  27279. !clipPaths ||
  27280. !prevClipPaths ||
  27281. clipPaths.length !== prevClipPaths.length
  27282. ) {
  27283. return true
  27284. }
  27285. for (var i = 0; i < clipPaths.length; i++) {
  27286. if (clipPaths[i] !== prevClipPaths[i]) {
  27287. return true
  27288. }
  27289. }
  27290. return false
  27291. }
  27292. function parseInt10(val) {
  27293. return parseInt(val, 10)
  27294. }
  27295. function getSize$1(root, whIdx, opts) {
  27296. var wh = ['width', 'height'][whIdx]
  27297. var cwh = ['clientWidth', 'clientHeight'][whIdx]
  27298. var plt = ['paddingLeft', 'paddingTop'][whIdx]
  27299. var prb = ['paddingRight', 'paddingBottom'][whIdx]
  27300. if (opts[wh] != null && opts[wh] !== 'auto') {
  27301. return parseFloat(opts[wh])
  27302. }
  27303. var stl = document.defaultView.getComputedStyle(root)
  27304. return (
  27305. ((root[cwh] ||
  27306. parseInt10(stl[wh]) ||
  27307. parseInt10(root.style[wh])) -
  27308. (parseInt10(stl[plt]) || 0) -
  27309. (parseInt10(stl[prb]) || 0)) |
  27310. 0
  27311. )
  27312. }
  27313. function normalizeLineDash(lineType, lineWidth) {
  27314. if (!lineType || lineType === 'solid' || !(lineWidth > 0)) {
  27315. return null
  27316. }
  27317. return lineType === 'dashed'
  27318. ? [4 * lineWidth, 2 * lineWidth]
  27319. : lineType === 'dotted'
  27320. ? [lineWidth]
  27321. : isNumber(lineType)
  27322. ? [lineType]
  27323. : isArray(lineType)
  27324. ? lineType
  27325. : null
  27326. }
  27327. function getLineDash(el) {
  27328. var style = el.style
  27329. var lineDash =
  27330. style.lineDash &&
  27331. style.lineWidth > 0 &&
  27332. normalizeLineDash(style.lineDash, style.lineWidth)
  27333. var lineDashOffset = style.lineDashOffset
  27334. if (lineDash) {
  27335. var lineScale_1 =
  27336. style.strokeNoScale && el.getLineScale ? el.getLineScale() : 1
  27337. if (lineScale_1 && lineScale_1 !== 1) {
  27338. lineDash = map$1(lineDash, function (rawVal) {
  27339. return rawVal / lineScale_1
  27340. })
  27341. lineDashOffset /= lineScale_1
  27342. }
  27343. }
  27344. return [lineDash, lineDashOffset]
  27345. }
  27346. var pathProxyForDraw = new PathProxy$1(true)
  27347. function styleHasStroke(style) {
  27348. var stroke = style.stroke
  27349. return !(
  27350. stroke == null ||
  27351. stroke === 'none' ||
  27352. !(style.lineWidth > 0)
  27353. )
  27354. }
  27355. function isValidStrokeFillStyle(strokeOrFill) {
  27356. return typeof strokeOrFill === 'string' && strokeOrFill !== 'none'
  27357. }
  27358. function styleHasFill(style) {
  27359. var fill = style.fill
  27360. return fill != null && fill !== 'none'
  27361. }
  27362. function doFillPath(ctx, style) {
  27363. if (style.fillOpacity != null && style.fillOpacity !== 1) {
  27364. var originalGlobalAlpha = ctx.globalAlpha
  27365. ctx.globalAlpha = style.fillOpacity * style.opacity
  27366. ctx.fill()
  27367. ctx.globalAlpha = originalGlobalAlpha
  27368. } else {
  27369. ctx.fill()
  27370. }
  27371. }
  27372. function doStrokePath(ctx, style) {
  27373. if (style.strokeOpacity != null && style.strokeOpacity !== 1) {
  27374. var originalGlobalAlpha = ctx.globalAlpha
  27375. ctx.globalAlpha = style.strokeOpacity * style.opacity
  27376. ctx.stroke()
  27377. ctx.globalAlpha = originalGlobalAlpha
  27378. } else {
  27379. ctx.stroke()
  27380. }
  27381. }
  27382. function createCanvasPattern(ctx, pattern, el) {
  27383. var image = createOrUpdateImage(pattern.image, pattern.__image, el)
  27384. if (isImageReady(image)) {
  27385. var canvasPattern = ctx.createPattern(
  27386. image,
  27387. pattern.repeat || 'repeat'
  27388. )
  27389. if (
  27390. typeof DOMMatrix === 'function' &&
  27391. canvasPattern &&
  27392. canvasPattern.setTransform
  27393. ) {
  27394. var matrix = new DOMMatrix()
  27395. matrix.translateSelf(pattern.x || 0, pattern.y || 0)
  27396. matrix.rotateSelf(
  27397. 0,
  27398. 0,
  27399. (pattern.rotation || 0) * RADIAN_TO_DEGREE
  27400. )
  27401. matrix.scaleSelf(pattern.scaleX || 1, pattern.scaleY || 1)
  27402. canvasPattern.setTransform(matrix)
  27403. }
  27404. return canvasPattern
  27405. }
  27406. }
  27407. function brushPath(ctx, el, style, inBatch) {
  27408. var _a
  27409. var hasStroke = styleHasStroke(style)
  27410. var hasFill = styleHasFill(style)
  27411. var strokePercent = style.strokePercent
  27412. var strokePart = strokePercent < 1
  27413. var firstDraw = !el.path
  27414. if ((!el.silent || strokePart) && firstDraw) {
  27415. el.createPathProxy()
  27416. }
  27417. var path = el.path || pathProxyForDraw
  27418. var dirtyFlag = el.__dirty
  27419. if (!inBatch) {
  27420. var fill = style.fill
  27421. var stroke = style.stroke
  27422. var hasFillGradient = hasFill && !!fill.colorStops
  27423. var hasStrokeGradient = hasStroke && !!stroke.colorStops
  27424. var hasFillPattern = hasFill && !!fill.image
  27425. var hasStrokePattern = hasStroke && !!stroke.image
  27426. var fillGradient = void 0
  27427. var strokeGradient = void 0
  27428. var fillPattern = void 0
  27429. var strokePattern = void 0
  27430. var rect = void 0
  27431. if (hasFillGradient || hasStrokeGradient) {
  27432. rect = el.getBoundingRect()
  27433. }
  27434. if (hasFillGradient) {
  27435. fillGradient = dirtyFlag
  27436. ? getCanvasGradient(ctx, fill, rect)
  27437. : el.__canvasFillGradient
  27438. el.__canvasFillGradient = fillGradient
  27439. }
  27440. if (hasStrokeGradient) {
  27441. strokeGradient = dirtyFlag
  27442. ? getCanvasGradient(ctx, stroke, rect)
  27443. : el.__canvasStrokeGradient
  27444. el.__canvasStrokeGradient = strokeGradient
  27445. }
  27446. if (hasFillPattern) {
  27447. fillPattern =
  27448. dirtyFlag || !el.__canvasFillPattern
  27449. ? createCanvasPattern(ctx, fill, el)
  27450. : el.__canvasFillPattern
  27451. el.__canvasFillPattern = fillPattern
  27452. }
  27453. if (hasStrokePattern) {
  27454. strokePattern =
  27455. dirtyFlag || !el.__canvasStrokePattern
  27456. ? createCanvasPattern(ctx, stroke, el)
  27457. : el.__canvasStrokePattern
  27458. el.__canvasStrokePattern = fillPattern
  27459. }
  27460. if (hasFillGradient) {
  27461. ctx.fillStyle = fillGradient
  27462. } else if (hasFillPattern) {
  27463. if (fillPattern) {
  27464. ctx.fillStyle = fillPattern
  27465. } else {
  27466. hasFill = false
  27467. }
  27468. }
  27469. if (hasStrokeGradient) {
  27470. ctx.strokeStyle = strokeGradient
  27471. } else if (hasStrokePattern) {
  27472. if (strokePattern) {
  27473. ctx.strokeStyle = strokePattern
  27474. } else {
  27475. hasStroke = false
  27476. }
  27477. }
  27478. }
  27479. var scale = el.getGlobalScale()
  27480. path.setScale(scale[0], scale[1], el.segmentIgnoreThreshold)
  27481. var lineDash
  27482. var lineDashOffset
  27483. if (ctx.setLineDash && style.lineDash) {
  27484. ;(_a = getLineDash(el)),
  27485. (lineDash = _a[0]),
  27486. (lineDashOffset = _a[1])
  27487. }
  27488. var needsRebuild = true
  27489. if (firstDraw || dirtyFlag & SHAPE_CHANGED_BIT) {
  27490. path.setDPR(ctx.dpr)
  27491. if (strokePart) {
  27492. path.setContext(null)
  27493. } else {
  27494. path.setContext(ctx)
  27495. needsRebuild = false
  27496. }
  27497. path.reset()
  27498. el.buildPath(path, el.shape, inBatch)
  27499. path.toStatic()
  27500. el.pathUpdated()
  27501. }
  27502. if (needsRebuild) {
  27503. path.rebuildPath(ctx, strokePart ? strokePercent : 1)
  27504. }
  27505. if (lineDash) {
  27506. ctx.setLineDash(lineDash)
  27507. ctx.lineDashOffset = lineDashOffset
  27508. }
  27509. if (!inBatch) {
  27510. if (style.strokeFirst) {
  27511. if (hasStroke) {
  27512. doStrokePath(ctx, style)
  27513. }
  27514. if (hasFill) {
  27515. doFillPath(ctx, style)
  27516. }
  27517. } else {
  27518. if (hasFill) {
  27519. doFillPath(ctx, style)
  27520. }
  27521. if (hasStroke) {
  27522. doStrokePath(ctx, style)
  27523. }
  27524. }
  27525. }
  27526. if (lineDash) {
  27527. ctx.setLineDash([])
  27528. }
  27529. }
  27530. function brushImage(ctx, el, style) {
  27531. var image = (el.__image = createOrUpdateImage(
  27532. style.image,
  27533. el.__image,
  27534. el,
  27535. el.onload
  27536. ))
  27537. if (!image || !isImageReady(image)) {
  27538. return
  27539. }
  27540. var x = style.x || 0
  27541. var y = style.y || 0
  27542. var width = el.getWidth()
  27543. var height = el.getHeight()
  27544. var aspect = image.width / image.height
  27545. if (width == null && height != null) {
  27546. width = height * aspect
  27547. } else if (height == null && width != null) {
  27548. height = width / aspect
  27549. } else if (width == null && height == null) {
  27550. width = image.width
  27551. height = image.height
  27552. }
  27553. if (style.sWidth && style.sHeight) {
  27554. var sx = style.sx || 0
  27555. var sy = style.sy || 0
  27556. ctx.drawImage(
  27557. image,
  27558. sx,
  27559. sy,
  27560. style.sWidth,
  27561. style.sHeight,
  27562. x,
  27563. y,
  27564. width,
  27565. height
  27566. )
  27567. } else if (style.sx && style.sy) {
  27568. var sx = style.sx
  27569. var sy = style.sy
  27570. var sWidth = width - sx
  27571. var sHeight = height - sy
  27572. ctx.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height)
  27573. } else {
  27574. ctx.drawImage(image, x, y, width, height)
  27575. }
  27576. }
  27577. function brushText(ctx, el, style) {
  27578. var _a
  27579. var text = style.text
  27580. text != null && (text += '')
  27581. if (text) {
  27582. ctx.font = style.font || DEFAULT_FONT
  27583. ctx.textAlign = style.textAlign
  27584. ctx.textBaseline = style.textBaseline
  27585. var lineDash = void 0
  27586. var lineDashOffset = void 0
  27587. if (ctx.setLineDash && style.lineDash) {
  27588. ;(_a = getLineDash(el)),
  27589. (lineDash = _a[0]),
  27590. (lineDashOffset = _a[1])
  27591. }
  27592. if (lineDash) {
  27593. ctx.setLineDash(lineDash)
  27594. ctx.lineDashOffset = lineDashOffset
  27595. }
  27596. if (style.strokeFirst) {
  27597. if (styleHasStroke(style)) {
  27598. ctx.strokeText(text, style.x, style.y)
  27599. }
  27600. if (styleHasFill(style)) {
  27601. ctx.fillText(text, style.x, style.y)
  27602. }
  27603. } else {
  27604. if (styleHasFill(style)) {
  27605. ctx.fillText(text, style.x, style.y)
  27606. }
  27607. if (styleHasStroke(style)) {
  27608. ctx.strokeText(text, style.x, style.y)
  27609. }
  27610. }
  27611. if (lineDash) {
  27612. ctx.setLineDash([])
  27613. }
  27614. }
  27615. }
  27616. var SHADOW_NUMBER_PROPS = [
  27617. 'shadowBlur',
  27618. 'shadowOffsetX',
  27619. 'shadowOffsetY'
  27620. ]
  27621. var STROKE_PROPS = [
  27622. ['lineCap', 'butt'],
  27623. ['lineJoin', 'miter'],
  27624. ['miterLimit', 10]
  27625. ]
  27626. function bindCommonProps(ctx, style, prevStyle, forceSetAll, scope) {
  27627. var styleChanged = false
  27628. if (!forceSetAll) {
  27629. prevStyle = prevStyle || {}
  27630. if (style === prevStyle) {
  27631. return false
  27632. }
  27633. }
  27634. if (forceSetAll || style.opacity !== prevStyle.opacity) {
  27635. flushPathDrawn(ctx, scope)
  27636. styleChanged = true
  27637. var opacity = Math.max(Math.min(style.opacity, 1), 0)
  27638. ctx.globalAlpha = isNaN(opacity)
  27639. ? DEFAULT_COMMON_STYLE.opacity
  27640. : opacity
  27641. }
  27642. if (forceSetAll || style.blend !== prevStyle.blend) {
  27643. if (!styleChanged) {
  27644. flushPathDrawn(ctx, scope)
  27645. styleChanged = true
  27646. }
  27647. ctx.globalCompositeOperation =
  27648. style.blend || DEFAULT_COMMON_STYLE.blend
  27649. }
  27650. for (var i = 0; i < SHADOW_NUMBER_PROPS.length; i++) {
  27651. var propName = SHADOW_NUMBER_PROPS[i]
  27652. if (forceSetAll || style[propName] !== prevStyle[propName]) {
  27653. if (!styleChanged) {
  27654. flushPathDrawn(ctx, scope)
  27655. styleChanged = true
  27656. }
  27657. ctx[propName] = ctx.dpr * (style[propName] || 0)
  27658. }
  27659. }
  27660. if (forceSetAll || style.shadowColor !== prevStyle.shadowColor) {
  27661. if (!styleChanged) {
  27662. flushPathDrawn(ctx, scope)
  27663. styleChanged = true
  27664. }
  27665. ctx.shadowColor =
  27666. style.shadowColor || DEFAULT_COMMON_STYLE.shadowColor
  27667. }
  27668. return styleChanged
  27669. }
  27670. function bindPathAndTextCommonStyle(
  27671. ctx,
  27672. el,
  27673. prevEl,
  27674. forceSetAll,
  27675. scope
  27676. ) {
  27677. var style = getStyle(el, scope.inHover)
  27678. var prevStyle = forceSetAll
  27679. ? null
  27680. : (prevEl && getStyle(prevEl, scope.inHover)) || {}
  27681. if (style === prevStyle) {
  27682. return false
  27683. }
  27684. var styleChanged = bindCommonProps(
  27685. ctx,
  27686. style,
  27687. prevStyle,
  27688. forceSetAll,
  27689. scope
  27690. )
  27691. if (forceSetAll || style.fill !== prevStyle.fill) {
  27692. if (!styleChanged) {
  27693. flushPathDrawn(ctx, scope)
  27694. styleChanged = true
  27695. }
  27696. isValidStrokeFillStyle(style.fill) && (ctx.fillStyle = style.fill)
  27697. }
  27698. if (forceSetAll || style.stroke !== prevStyle.stroke) {
  27699. if (!styleChanged) {
  27700. flushPathDrawn(ctx, scope)
  27701. styleChanged = true
  27702. }
  27703. isValidStrokeFillStyle(style.stroke) &&
  27704. (ctx.strokeStyle = style.stroke)
  27705. }
  27706. if (forceSetAll || style.opacity !== prevStyle.opacity) {
  27707. if (!styleChanged) {
  27708. flushPathDrawn(ctx, scope)
  27709. styleChanged = true
  27710. }
  27711. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity
  27712. }
  27713. if (el.hasStroke()) {
  27714. var lineWidth = style.lineWidth
  27715. var newLineWidth =
  27716. lineWidth /
  27717. (style.strokeNoScale && el.getLineScale ? el.getLineScale() : 1)
  27718. if (ctx.lineWidth !== newLineWidth) {
  27719. if (!styleChanged) {
  27720. flushPathDrawn(ctx, scope)
  27721. styleChanged = true
  27722. }
  27723. ctx.lineWidth = newLineWidth
  27724. }
  27725. }
  27726. for (var i = 0; i < STROKE_PROPS.length; i++) {
  27727. var prop = STROKE_PROPS[i]
  27728. var propName = prop[0]
  27729. if (forceSetAll || style[propName] !== prevStyle[propName]) {
  27730. if (!styleChanged) {
  27731. flushPathDrawn(ctx, scope)
  27732. styleChanged = true
  27733. }
  27734. ctx[propName] = style[propName] || prop[1]
  27735. }
  27736. }
  27737. return styleChanged
  27738. }
  27739. function bindImageStyle(ctx, el, prevEl, forceSetAll, scope) {
  27740. return bindCommonProps(
  27741. ctx,
  27742. getStyle(el, scope.inHover),
  27743. prevEl && getStyle(prevEl, scope.inHover),
  27744. forceSetAll,
  27745. scope
  27746. )
  27747. }
  27748. function setContextTransform(ctx, el) {
  27749. var m = el.transform
  27750. var dpr = ctx.dpr || 1
  27751. if (m) {
  27752. ctx.setTransform(
  27753. dpr * m[0],
  27754. dpr * m[1],
  27755. dpr * m[2],
  27756. dpr * m[3],
  27757. dpr * m[4],
  27758. dpr * m[5]
  27759. )
  27760. } else {
  27761. ctx.setTransform(dpr, 0, 0, dpr, 0, 0)
  27762. }
  27763. }
  27764. function updateClipStatus(clipPaths, ctx, scope) {
  27765. var allClipped = false
  27766. for (var i = 0; i < clipPaths.length; i++) {
  27767. var clipPath = clipPaths[i]
  27768. allClipped = allClipped || clipPath.isZeroArea()
  27769. setContextTransform(ctx, clipPath)
  27770. ctx.beginPath()
  27771. clipPath.buildPath(ctx, clipPath.shape)
  27772. ctx.clip()
  27773. }
  27774. scope.allClipped = allClipped
  27775. }
  27776. function isTransformChanged(m0, m1) {
  27777. if (m0 && m1) {
  27778. return (
  27779. m0[0] !== m1[0] ||
  27780. m0[1] !== m1[1] ||
  27781. m0[2] !== m1[2] ||
  27782. m0[3] !== m1[3] ||
  27783. m0[4] !== m1[4] ||
  27784. m0[5] !== m1[5]
  27785. )
  27786. } else if (!m0 && !m1) {
  27787. return false
  27788. }
  27789. return true
  27790. }
  27791. var DRAW_TYPE_PATH = 1
  27792. var DRAW_TYPE_IMAGE = 2
  27793. var DRAW_TYPE_TEXT = 3
  27794. var DRAW_TYPE_INCREMENTAL = 4
  27795. function canPathBatch(style) {
  27796. var hasFill = styleHasFill(style)
  27797. var hasStroke = styleHasStroke(style)
  27798. return !(
  27799. style.lineDash ||
  27800. !(+hasFill ^ +hasStroke) ||
  27801. (hasFill && typeof style.fill !== 'string') ||
  27802. (hasStroke && typeof style.stroke !== 'string') ||
  27803. style.strokePercent < 1 ||
  27804. style.strokeOpacity < 1 ||
  27805. style.fillOpacity < 1
  27806. )
  27807. }
  27808. function flushPathDrawn(ctx, scope) {
  27809. scope.batchFill && ctx.fill()
  27810. scope.batchStroke && ctx.stroke()
  27811. scope.batchFill = ''
  27812. scope.batchStroke = ''
  27813. }
  27814. function getStyle(el, inHover) {
  27815. return inHover ? el.__hoverStyle || el.style : el.style
  27816. }
  27817. function brushSingle(ctx, el) {
  27818. brush(
  27819. ctx,
  27820. el,
  27821. { inHover: false, viewWidth: 0, viewHeight: 0 },
  27822. true
  27823. )
  27824. }
  27825. function brush(ctx, el, scope, isLast) {
  27826. var m = el.transform
  27827. if (
  27828. !el.shouldBePainted(
  27829. scope.viewWidth,
  27830. scope.viewHeight,
  27831. false,
  27832. false
  27833. )
  27834. ) {
  27835. el.__dirty &= ~REDRAW_BIT
  27836. el.__isRendered = false
  27837. return
  27838. }
  27839. var clipPaths = el.__clipPaths
  27840. var prevElClipPaths = scope.prevElClipPaths
  27841. var forceSetTransform = false
  27842. var forceSetStyle = false
  27843. if (
  27844. !prevElClipPaths ||
  27845. isClipPathChanged(clipPaths, prevElClipPaths)
  27846. ) {
  27847. if (prevElClipPaths && prevElClipPaths.length) {
  27848. flushPathDrawn(ctx, scope)
  27849. ctx.restore()
  27850. forceSetStyle = forceSetTransform = true
  27851. scope.prevElClipPaths = null
  27852. scope.allClipped = false
  27853. scope.prevEl = null
  27854. }
  27855. if (clipPaths && clipPaths.length) {
  27856. flushPathDrawn(ctx, scope)
  27857. ctx.save()
  27858. updateClipStatus(clipPaths, ctx, scope)
  27859. forceSetTransform = true
  27860. }
  27861. scope.prevElClipPaths = clipPaths
  27862. }
  27863. if (scope.allClipped) {
  27864. el.__isRendered = false
  27865. return
  27866. }
  27867. el.beforeBrush && el.beforeBrush()
  27868. el.innerBeforeBrush()
  27869. var prevEl = scope.prevEl
  27870. if (!prevEl) {
  27871. forceSetStyle = forceSetTransform = true
  27872. }
  27873. var canBatchPath =
  27874. el instanceof Path$1 && el.autoBatch && canPathBatch(el.style)
  27875. if (forceSetTransform || isTransformChanged(m, prevEl.transform)) {
  27876. flushPathDrawn(ctx, scope)
  27877. setContextTransform(ctx, el)
  27878. } else if (!canBatchPath) {
  27879. flushPathDrawn(ctx, scope)
  27880. }
  27881. var style = getStyle(el, scope.inHover)
  27882. if (el instanceof Path$1) {
  27883. if (scope.lastDrawType !== DRAW_TYPE_PATH) {
  27884. forceSetStyle = true
  27885. scope.lastDrawType = DRAW_TYPE_PATH
  27886. }
  27887. bindPathAndTextCommonStyle(ctx, el, prevEl, forceSetStyle, scope)
  27888. if (!canBatchPath || (!scope.batchFill && !scope.batchStroke)) {
  27889. ctx.beginPath()
  27890. }
  27891. brushPath(ctx, el, style, canBatchPath)
  27892. if (canBatchPath) {
  27893. scope.batchFill = style.fill || ''
  27894. scope.batchStroke = style.stroke || ''
  27895. }
  27896. } else {
  27897. if (el instanceof TSpan$1) {
  27898. if (scope.lastDrawType !== DRAW_TYPE_TEXT) {
  27899. forceSetStyle = true
  27900. scope.lastDrawType = DRAW_TYPE_TEXT
  27901. }
  27902. bindPathAndTextCommonStyle(
  27903. ctx,
  27904. el,
  27905. prevEl,
  27906. forceSetStyle,
  27907. scope
  27908. )
  27909. brushText(ctx, el, style)
  27910. } else if (el instanceof ZRImage$1) {
  27911. if (scope.lastDrawType !== DRAW_TYPE_IMAGE) {
  27912. forceSetStyle = true
  27913. scope.lastDrawType = DRAW_TYPE_IMAGE
  27914. }
  27915. bindImageStyle(ctx, el, prevEl, forceSetStyle, scope)
  27916. brushImage(ctx, el, style)
  27917. } else if (el.getTemporalDisplayables) {
  27918. if (scope.lastDrawType !== DRAW_TYPE_INCREMENTAL) {
  27919. forceSetStyle = true
  27920. scope.lastDrawType = DRAW_TYPE_INCREMENTAL
  27921. }
  27922. brushIncremental(ctx, el, scope)
  27923. }
  27924. }
  27925. if (canBatchPath && isLast) {
  27926. flushPathDrawn(ctx, scope)
  27927. }
  27928. el.innerAfterBrush()
  27929. el.afterBrush && el.afterBrush()
  27930. scope.prevEl = el
  27931. el.__dirty = 0
  27932. el.__isRendered = true
  27933. }
  27934. function brushIncremental(ctx, el, scope) {
  27935. var displayables = el.getDisplayables()
  27936. var temporalDisplayables = el.getTemporalDisplayables()
  27937. ctx.save()
  27938. var innerScope = {
  27939. prevElClipPaths: null,
  27940. prevEl: null,
  27941. allClipped: false,
  27942. viewWidth: scope.viewWidth,
  27943. viewHeight: scope.viewHeight,
  27944. inHover: scope.inHover
  27945. }
  27946. var i
  27947. var len
  27948. for (i = el.getCursor(), len = displayables.length; i < len; i++) {
  27949. var displayable = displayables[i]
  27950. displayable.beforeBrush && displayable.beforeBrush()
  27951. displayable.innerBeforeBrush()
  27952. brush(ctx, displayable, innerScope, i === len - 1)
  27953. displayable.innerAfterBrush()
  27954. displayable.afterBrush && displayable.afterBrush()
  27955. innerScope.prevEl = displayable
  27956. }
  27957. for (
  27958. var i_1 = 0, len_1 = temporalDisplayables.length;
  27959. i_1 < len_1;
  27960. i_1++
  27961. ) {
  27962. var displayable = temporalDisplayables[i_1]
  27963. displayable.beforeBrush && displayable.beforeBrush()
  27964. displayable.innerBeforeBrush()
  27965. brush(ctx, displayable, innerScope, i_1 === len_1 - 1)
  27966. displayable.innerAfterBrush()
  27967. displayable.afterBrush && displayable.afterBrush()
  27968. innerScope.prevEl = displayable
  27969. }
  27970. el.clearTemporalDisplayables()
  27971. el.notClear = true
  27972. ctx.restore()
  27973. }
  27974. var decalMap = new WeakMap$1()
  27975. var decalCache = new LRU$1(100)
  27976. var decalKeys = [
  27977. 'symbol',
  27978. 'symbolSize',
  27979. 'symbolKeepAspect',
  27980. 'color',
  27981. 'backgroundColor',
  27982. 'dashArrayX',
  27983. 'dashArrayY',
  27984. 'maxTileWidth',
  27985. 'maxTileHeight'
  27986. ]
  27987. /**
  27988. * Create or update pattern image from decal options
  27989. *
  27990. * @param {InnerDecalObject | 'none'} decalObject decal options, 'none' if no decal
  27991. * @return {Pattern} pattern with generated image, null if no decal
  27992. */ function createOrUpdatePatternFromDecal(decalObject, api) {
  27993. if (decalObject === 'none') {
  27994. return null
  27995. }
  27996. var dpr = api.getDevicePixelRatio()
  27997. var zr = api.getZr()
  27998. var isSVG = zr.painter.type === 'svg'
  27999. if (decalObject.dirty) {
  28000. decalMap['delete'](decalObject)
  28001. }
  28002. var oldPattern = decalMap.get(decalObject)
  28003. if (oldPattern) {
  28004. return oldPattern
  28005. }
  28006. var decalOpt = defaults(decalObject, {
  28007. symbol: 'rect',
  28008. symbolSize: 1,
  28009. symbolKeepAspect: true,
  28010. color: 'rgba(0, 0, 0, 0.2)',
  28011. backgroundColor: null,
  28012. dashArrayX: 5,
  28013. dashArrayY: 5,
  28014. rotation: 0,
  28015. maxTileWidth: 512,
  28016. maxTileHeight: 512
  28017. })
  28018. if (decalOpt.backgroundColor === 'none') {
  28019. decalOpt.backgroundColor = null
  28020. }
  28021. var pattern = { repeat: 'repeat' }
  28022. setPatternnSource(pattern)
  28023. pattern.rotation = decalOpt.rotation
  28024. pattern.scaleX = pattern.scaleY = isSVG ? 1 : 1 / dpr
  28025. decalMap.set(decalObject, pattern)
  28026. decalObject.dirty = false
  28027. return pattern
  28028. function setPatternnSource(pattern) {
  28029. var keys = [dpr]
  28030. var isValidKey = true
  28031. for (var i = 0; i < decalKeys.length; ++i) {
  28032. var value = decalOpt[decalKeys[i]]
  28033. if (
  28034. value != null &&
  28035. !isArray(value) &&
  28036. !isString(value) &&
  28037. !isNumber(value) &&
  28038. typeof value !== 'boolean'
  28039. ) {
  28040. isValidKey = false
  28041. break
  28042. }
  28043. keys.push(value)
  28044. }
  28045. var cacheKey
  28046. if (isValidKey) {
  28047. cacheKey = keys.join(',') + (isSVG ? '-svg' : '')
  28048. var cache = decalCache.get(cacheKey)
  28049. if (cache) {
  28050. isSVG ? (pattern.svgElement = cache) : (pattern.image = cache)
  28051. }
  28052. }
  28053. var dashArrayX = normalizeDashArrayX(decalOpt.dashArrayX)
  28054. var dashArrayY = normalizeDashArrayY(decalOpt.dashArrayY)
  28055. var symbolArray = normalizeSymbolArray(decalOpt.symbol)
  28056. var lineBlockLengthsX = getLineBlockLengthX(dashArrayX)
  28057. var lineBlockLengthY = getLineBlockLengthY(dashArrayY)
  28058. var canvas = !isSVG && platformApi.createCanvas()
  28059. var svgRoot = isSVG && {
  28060. tag: 'g',
  28061. attrs: {},
  28062. key: 'dcl',
  28063. children: []
  28064. }
  28065. var pSize = getPatternSize()
  28066. var ctx
  28067. if (canvas) {
  28068. canvas.width = pSize.width * dpr
  28069. canvas.height = pSize.height * dpr
  28070. ctx = canvas.getContext('2d')
  28071. }
  28072. brushDecal()
  28073. if (isValidKey) {
  28074. decalCache.put(cacheKey, canvas || svgRoot)
  28075. }
  28076. pattern.image = canvas
  28077. pattern.svgElement = svgRoot
  28078. pattern.svgWidth = pSize.width
  28079. pattern.svgHeight = pSize.height
  28080. /**
  28081. * Get minumum length that can make a repeatable pattern.
  28082. *
  28083. * @return {Object} pattern width and height
  28084. */ function getPatternSize() {
  28085. /**
  28086. * For example, if dash is [[3, 2], [2, 1]] for X, it looks like
  28087. * |--- --- --- --- --- ...
  28088. * |-- -- -- -- -- -- -- -- ...
  28089. * |--- --- --- --- --- ...
  28090. * |-- -- -- -- -- -- -- -- ...
  28091. * So the minumum length of X is 15,
  28092. * which is the least common multiple of `3 + 2` and `2 + 1`
  28093. * |--- --- --- |--- --- ...
  28094. * |-- -- -- -- -- |-- -- -- ...
  28095. */ var width = 1
  28096. for (
  28097. var i = 0, xlen = lineBlockLengthsX.length;
  28098. i < xlen;
  28099. ++i
  28100. ) {
  28101. width = getLeastCommonMultiple(width, lineBlockLengthsX[i])
  28102. }
  28103. var symbolRepeats = 1
  28104. for (var i = 0, xlen = symbolArray.length; i < xlen; ++i) {
  28105. symbolRepeats = getLeastCommonMultiple(
  28106. symbolRepeats,
  28107. symbolArray[i].length
  28108. )
  28109. }
  28110. width *= symbolRepeats
  28111. var height =
  28112. lineBlockLengthY *
  28113. lineBlockLengthsX.length *
  28114. symbolArray.length
  28115. return {
  28116. width: Math.max(1, Math.min(width, decalOpt.maxTileWidth)),
  28117. height: Math.max(1, Math.min(height, decalOpt.maxTileHeight))
  28118. }
  28119. }
  28120. function brushDecal() {
  28121. if (ctx) {
  28122. ctx.clearRect(0, 0, canvas.width, canvas.height)
  28123. if (decalOpt.backgroundColor) {
  28124. ctx.fillStyle = decalOpt.backgroundColor
  28125. ctx.fillRect(0, 0, canvas.width, canvas.height)
  28126. }
  28127. }
  28128. var ySum = 0
  28129. for (var i = 0; i < dashArrayY.length; ++i) {
  28130. ySum += dashArrayY[i]
  28131. }
  28132. if (ySum <= 0) {
  28133. // dashArrayY is 0, draw nothing
  28134. return
  28135. }
  28136. var y = -lineBlockLengthY
  28137. var yId = 0
  28138. var yIdTotal = 0
  28139. var xId0 = 0
  28140. while (y < pSize.height) {
  28141. if (yId % 2 === 0) {
  28142. var symbolYId = (yIdTotal / 2) % symbolArray.length
  28143. var x = 0
  28144. var xId1 = 0
  28145. var xId1Total = 0
  28146. while (x < pSize.width * 2) {
  28147. var xSum = 0
  28148. for (var i = 0; i < dashArrayX[xId0].length; ++i) {
  28149. xSum += dashArrayX[xId0][i]
  28150. }
  28151. if (xSum <= 0) {
  28152. // Skip empty line
  28153. break
  28154. } // E.g., [15, 5, 20, 5] draws only for 15 and 20
  28155. if (xId1 % 2 === 0) {
  28156. var size = (1 - decalOpt.symbolSize) * 0.5
  28157. var left = x + dashArrayX[xId0][xId1] * size
  28158. var top_1 = y + dashArrayY[yId] * size
  28159. var width = dashArrayX[xId0][xId1] * decalOpt.symbolSize
  28160. var height = dashArrayY[yId] * decalOpt.symbolSize
  28161. var symbolXId =
  28162. (xId1Total / 2) % symbolArray[symbolYId].length
  28163. brushSymbol(
  28164. left,
  28165. top_1,
  28166. width,
  28167. height,
  28168. symbolArray[symbolYId][symbolXId]
  28169. )
  28170. }
  28171. x += dashArrayX[xId0][xId1]
  28172. ++xId1Total
  28173. ++xId1
  28174. if (xId1 === dashArrayX[xId0].length) {
  28175. xId1 = 0
  28176. }
  28177. }
  28178. ++xId0
  28179. if (xId0 === dashArrayX.length) {
  28180. xId0 = 0
  28181. }
  28182. }
  28183. y += dashArrayY[yId]
  28184. ++yIdTotal
  28185. ++yId
  28186. if (yId === dashArrayY.length) {
  28187. yId = 0
  28188. }
  28189. }
  28190. function brushSymbol(x, y, width, height, symbolType) {
  28191. var scale = isSVG ? 1 : dpr
  28192. var symbol = createSymbol(
  28193. symbolType,
  28194. x * scale,
  28195. y * scale,
  28196. width * scale,
  28197. height * scale,
  28198. decalOpt.color,
  28199. decalOpt.symbolKeepAspect
  28200. )
  28201. if (isSVG) {
  28202. var symbolVNode = zr.painter.renderOneToVNode(symbol)
  28203. if (symbolVNode) {
  28204. svgRoot.children.push(symbolVNode)
  28205. }
  28206. } else {
  28207. // Paint to canvas for all other renderers.
  28208. brushSingle(ctx, symbol)
  28209. }
  28210. }
  28211. }
  28212. }
  28213. }
  28214. /**
  28215. * Convert symbol array into normalized array
  28216. *
  28217. * @param {string | (string | string[])[]} symbol symbol input
  28218. * @return {string[][]} normolized symbol array
  28219. */ function normalizeSymbolArray(symbol) {
  28220. if (!symbol || symbol.length === 0) {
  28221. return [['rect']]
  28222. }
  28223. if (isString(symbol)) {
  28224. return [[symbol]]
  28225. }
  28226. var isAllString = true
  28227. for (var i = 0; i < symbol.length; ++i) {
  28228. if (!isString(symbol[i])) {
  28229. isAllString = false
  28230. break
  28231. }
  28232. }
  28233. if (isAllString) {
  28234. return normalizeSymbolArray([symbol])
  28235. }
  28236. var result = []
  28237. for (var i = 0; i < symbol.length; ++i) {
  28238. if (isString(symbol[i])) {
  28239. result.push([symbol[i]])
  28240. } else {
  28241. result.push(symbol[i])
  28242. }
  28243. }
  28244. return result
  28245. }
  28246. /**
  28247. * Convert dash input into dashArray
  28248. *
  28249. * @param {DecalDashArrayX} dash dash input
  28250. * @return {number[][]} normolized dash array
  28251. */ function normalizeDashArrayX(dash) {
  28252. if (!dash || dash.length === 0) {
  28253. return [[0, 0]]
  28254. }
  28255. if (isNumber(dash)) {
  28256. var dashValue = Math.ceil(dash)
  28257. return [[dashValue, dashValue]]
  28258. }
  28259. /**
  28260. * [20, 5] should be normalized into [[20, 5]],
  28261. * while [20, [5, 10]] should be normalized into [[20, 20], [5, 10]]
  28262. */ var isAllNumber = true
  28263. for (var i = 0; i < dash.length; ++i) {
  28264. if (!isNumber(dash[i])) {
  28265. isAllNumber = false
  28266. break
  28267. }
  28268. }
  28269. if (isAllNumber) {
  28270. return normalizeDashArrayX([dash])
  28271. }
  28272. var result = []
  28273. for (var i = 0; i < dash.length; ++i) {
  28274. if (isNumber(dash[i])) {
  28275. var dashValue = Math.ceil(dash[i])
  28276. result.push([dashValue, dashValue])
  28277. } else {
  28278. var dashValue = map$1(dash[i], function (n) {
  28279. return Math.ceil(n)
  28280. })
  28281. if (dashValue.length % 2 === 1) {
  28282. // [4, 2, 1] means |---- - -- |---- - -- |
  28283. // so normalize it to be [4, 2, 1, 4, 2, 1]
  28284. result.push(dashValue.concat(dashValue))
  28285. } else {
  28286. result.push(dashValue)
  28287. }
  28288. }
  28289. }
  28290. return result
  28291. }
  28292. /**
  28293. * Convert dash input into dashArray
  28294. *
  28295. * @param {DecalDashArrayY} dash dash input
  28296. * @return {number[]} normolized dash array
  28297. */ function normalizeDashArrayY(dash) {
  28298. if (!dash || (_typeof(dash) === 'object' && dash.length === 0)) {
  28299. return [0, 0]
  28300. }
  28301. if (isNumber(dash)) {
  28302. var dashValue_1 = Math.ceil(dash)
  28303. return [dashValue_1, dashValue_1]
  28304. }
  28305. var dashValue = map$1(dash, function (n) {
  28306. return Math.ceil(n)
  28307. })
  28308. return dash.length % 2 ? dashValue.concat(dashValue) : dashValue
  28309. }
  28310. /**
  28311. * Get block length of each line. A block is the length of dash line and space.
  28312. * For example, a line with [4, 1] has a dash line of 4 and a space of 1 after
  28313. * that, so the block length of this line is 5.
  28314. *
  28315. * @param {number[][]} dash dash arrary of X or Y
  28316. * @return {number[]} block length of each line
  28317. */ function getLineBlockLengthX(dash) {
  28318. return map$1(dash, function (line) {
  28319. return getLineBlockLengthY(line)
  28320. })
  28321. }
  28322. function getLineBlockLengthY(dash) {
  28323. var blockLength = 0
  28324. for (var i = 0; i < dash.length; ++i) {
  28325. blockLength += dash[i]
  28326. }
  28327. if (dash.length % 2 === 1) {
  28328. // [4, 2, 1] means |---- - -- |---- - -- |
  28329. // So total length is (4 + 2 + 1) * 2
  28330. return blockLength * 2
  28331. }
  28332. return blockLength
  28333. }
  28334. function decalVisual(ecModel, api) {
  28335. ecModel.eachRawSeries(function (seriesModel) {
  28336. if (ecModel.isSeriesFiltered(seriesModel)) {
  28337. return
  28338. }
  28339. var data = seriesModel.getData()
  28340. if (data.hasItemVisual()) {
  28341. data.each(function (idx) {
  28342. var decal = data.getItemVisual(idx, 'decal')
  28343. if (decal) {
  28344. var itemStyle = data.ensureUniqueItemVisual(idx, 'style')
  28345. itemStyle.decal = createOrUpdatePatternFromDecal(decal, api)
  28346. }
  28347. })
  28348. }
  28349. var decal = data.getVisual('decal')
  28350. if (decal) {
  28351. var style = data.getVisual('style')
  28352. style.decal = createOrUpdatePatternFromDecal(decal, api)
  28353. }
  28354. })
  28355. }
  28356. var lifecycle = new Eventful$1()
  28357. var lifecycle$1 = lifecycle // The implentations will be registered when installing the component.
  28358. // Avoid these code being bundled to the core module.
  28359. var implsStore = {} // TODO Type
  28360. function registerImpl(name, impl) {
  28361. implsStore[name] = impl
  28362. }
  28363. function getImpl(name) {
  28364. return implsStore[name]
  28365. }
  28366. var hasWindow = typeof window !== 'undefined'
  28367. var TEST_FRAME_REMAIN_TIME = 1
  28368. var PRIORITY_PROCESSOR_SERIES_FILTER = 800 // Some data processors depends on the stack result dimension (to calculate data extent).
  28369. // So data stack stage should be in front of data processing stage.
  28370. var PRIORITY_PROCESSOR_DATASTACK = 900 // "Data filter" will block the stream, so it should be
  28371. // put at the begining of data processing.
  28372. var PRIORITY_PROCESSOR_FILTER = 1000
  28373. var PRIORITY_PROCESSOR_DEFAULT = 2000
  28374. var PRIORITY_PROCESSOR_STATISTIC = 5000
  28375. var PRIORITY_VISUAL_LAYOUT = 1000
  28376. var PRIORITY_VISUAL_PROGRESSIVE_LAYOUT = 1100
  28377. var PRIORITY_VISUAL_GLOBAL = 2000
  28378. var PRIORITY_VISUAL_CHART = 3000
  28379. var PRIORITY_VISUAL_COMPONENT = 4000 // Visual property in data. Greater than `PRIORITY_VISUAL_COMPONENT` to enable to
  28380. // overwrite the viusal result of component (like `visualMap`)
  28381. // using data item specific setting (like itemStyle.xxx on data item)
  28382. var PRIORITY_VISUAL_CHART_DATA_CUSTOM = 4500 // Greater than `PRIORITY_VISUAL_CHART_DATA_CUSTOM` to enable to layout based on
  28383. // visual result like `symbolSize`.
  28384. var PRIORITY_VISUAL_POST_CHART_LAYOUT = 4600
  28385. var PRIORITY_VISUAL_BRUSH = 5000
  28386. var PRIORITY_VISUAL_ARIA = 6000
  28387. var PRIORITY_VISUAL_DECAL = 7000
  28388. var PRIORITY = {
  28389. PROCESSOR: {
  28390. FILTER: PRIORITY_PROCESSOR_FILTER,
  28391. SERIES_FILTER: PRIORITY_PROCESSOR_SERIES_FILTER,
  28392. STATISTIC: PRIORITY_PROCESSOR_STATISTIC
  28393. },
  28394. VISUAL: {
  28395. LAYOUT: PRIORITY_VISUAL_LAYOUT,
  28396. PROGRESSIVE_LAYOUT: PRIORITY_VISUAL_PROGRESSIVE_LAYOUT,
  28397. GLOBAL: PRIORITY_VISUAL_GLOBAL,
  28398. CHART: PRIORITY_VISUAL_CHART,
  28399. POST_CHART_LAYOUT: PRIORITY_VISUAL_POST_CHART_LAYOUT,
  28400. COMPONENT: PRIORITY_VISUAL_COMPONENT,
  28401. BRUSH: PRIORITY_VISUAL_BRUSH,
  28402. CHART_ITEM: PRIORITY_VISUAL_CHART_DATA_CUSTOM,
  28403. ARIA: PRIORITY_VISUAL_ARIA,
  28404. DECAL: PRIORITY_VISUAL_DECAL
  28405. }
  28406. } // Main process have three entries: `setOption`, `dispatchAction` and `resize`,
  28407. // where they must not be invoked nestedly, except the only case: invoke
  28408. // dispatchAction with updateMethod "none" in main process.
  28409. // This flag is used to carry out this rule.
  28410. // All events will be triggered out side main process (i.e. when !this[IN_MAIN_PROCESS]).
  28411. var IN_MAIN_PROCESS_KEY = '__flagInMainProcess'
  28412. var PENDING_UPDATE = '__pendingUpdate'
  28413. var STATUS_NEEDS_UPDATE_KEY = '__needsUpdateStatus'
  28414. var ACTION_REG = /^[a-zA-Z0-9_]+$/
  28415. var CONNECT_STATUS_KEY = '__connectUpdateStatus'
  28416. var CONNECT_STATUS_PENDING = 0
  28417. var CONNECT_STATUS_UPDATING = 1
  28418. var CONNECT_STATUS_UPDATED = 2
  28419. function createRegisterEventWithLowercaseECharts(method) {
  28420. return function () {
  28421. var args = []
  28422. for (var _i = 0; _i < arguments.length; _i++) {
  28423. args[_i] = arguments[_i]
  28424. }
  28425. if (this.isDisposed()) {
  28426. disposedWarning(this.id)
  28427. return
  28428. }
  28429. return toLowercaseNameAndCallEventful(this, method, args)
  28430. }
  28431. }
  28432. function createRegisterEventWithLowercaseMessageCenter(method) {
  28433. return function () {
  28434. var args = []
  28435. for (var _i = 0; _i < arguments.length; _i++) {
  28436. args[_i] = arguments[_i]
  28437. }
  28438. return toLowercaseNameAndCallEventful(this, method, args)
  28439. }
  28440. }
  28441. function toLowercaseNameAndCallEventful(host, method, args) {
  28442. // `args[0]` is event name. Event name is all lowercase.
  28443. args[0] = args[0] && args[0].toLowerCase()
  28444. return Eventful$1.prototype[method].apply(host, args)
  28445. }
  28446. var MessageCenter = /** @class */ (function (_super) {
  28447. __extends(MessageCenter, _super)
  28448. function MessageCenter() {
  28449. return (_super !== null && _super.apply(this, arguments)) || this
  28450. }
  28451. return MessageCenter
  28452. })(Eventful$1)
  28453. var messageCenterProto = MessageCenter.prototype
  28454. messageCenterProto.on =
  28455. createRegisterEventWithLowercaseMessageCenter('on')
  28456. messageCenterProto.off =
  28457. createRegisterEventWithLowercaseMessageCenter('off') // ---------------------------------------
  28458. // Internal method names for class ECharts
  28459. // ---------------------------------------
  28460. var prepare
  28461. var prepareView
  28462. var updateDirectly
  28463. var updateMethods
  28464. var doConvertPixel
  28465. var updateStreamModes
  28466. var doDispatchAction
  28467. var flushPendingActions
  28468. var triggerUpdatedEvent
  28469. var bindRenderedEvent
  28470. var bindMouseEvent
  28471. var render
  28472. var renderComponents
  28473. var renderSeries
  28474. var createExtensionAPI
  28475. var enableConnect
  28476. var markStatusToUpdate
  28477. var applyChangedStates
  28478. var ECharts = /** @class */ (function (_super) {
  28479. __extends(ECharts, _super)
  28480. function ECharts(
  28481. dom, // Theme name or themeOption.
  28482. theme,
  28483. opts
  28484. ) {
  28485. var _this = _super.call(this, new ECEventProcessor()) || this
  28486. _this._chartsViews = []
  28487. _this._chartsMap = {}
  28488. _this._componentsViews = []
  28489. _this._componentsMap = {} // Can't dispatch action during rendering procedure
  28490. _this._pendingActions = []
  28491. opts = opts || {} // Get theme by name
  28492. if (isString(theme)) {
  28493. theme = themeStorage[theme]
  28494. }
  28495. _this._dom = dom
  28496. var defaultRenderer = 'canvas'
  28497. var defaultUseDirtyRect = false
  28498. var zr = (_this._zr = init$1(dom, {
  28499. renderer: opts.renderer || defaultRenderer,
  28500. devicePixelRatio: opts.devicePixelRatio,
  28501. width: opts.width,
  28502. height: opts.height,
  28503. ssr: opts.ssr,
  28504. useDirtyRect:
  28505. opts.useDirtyRect == null
  28506. ? defaultUseDirtyRect
  28507. : opts.useDirtyRect
  28508. }))
  28509. _this._ssr = opts.ssr // Expect 60 fps.
  28510. _this._throttledZrFlush = throttle(bind$1(zr.flush, zr), 17)
  28511. theme = clone$3(theme)
  28512. theme && globalBackwardCompat(theme, true)
  28513. _this._theme = theme
  28514. _this._locale = createLocaleObject(opts.locale || SYSTEM_LANG)
  28515. _this._coordSysMgr = new CoordinateSystem()
  28516. var api = (_this._api = createExtensionAPI(_this)) // Sort on demand
  28517. function prioritySortFunc(a, b) {
  28518. return a.__prio - b.__prio
  28519. }
  28520. sort(visualFuncs, prioritySortFunc)
  28521. sort(dataProcessorFuncs, prioritySortFunc)
  28522. _this._scheduler = new Scheduler$1(
  28523. _this,
  28524. api,
  28525. dataProcessorFuncs,
  28526. visualFuncs
  28527. )
  28528. _this._messageCenter = new MessageCenter() // Init mouse events
  28529. _this._initEvents() // In case some people write `window.onresize = chart.resize`
  28530. _this.resize = bind$1(_this.resize, _this)
  28531. zr.animation.on('frame', _this._onframe, _this)
  28532. bindRenderedEvent(zr, _this)
  28533. bindMouseEvent(zr, _this) // ECharts instance can be used as value.
  28534. setAsPrimitive(_this)
  28535. return _this
  28536. }
  28537. ECharts.prototype._onframe = function () {
  28538. if (this._disposed) {
  28539. return
  28540. }
  28541. applyChangedStates(this)
  28542. var scheduler = this._scheduler // Lazy update
  28543. if (this[PENDING_UPDATE]) {
  28544. var silent = this[PENDING_UPDATE].silent
  28545. this[IN_MAIN_PROCESS_KEY] = true
  28546. try {
  28547. prepare(this)
  28548. updateMethods.update.call(
  28549. this,
  28550. null,
  28551. this[PENDING_UPDATE].updateParams
  28552. )
  28553. } catch (e) {
  28554. this[IN_MAIN_PROCESS_KEY] = false
  28555. this[PENDING_UPDATE] = null
  28556. throw e
  28557. } // At present, in each frame, zrender performs:
  28558. // (1) animation step forward.
  28559. // (2) trigger('frame') (where this `_onframe` is called)
  28560. // (3) zrender flush (render).
  28561. // If we do nothing here, since we use `setToFinal: true`, the step (3) above
  28562. // will render the final state of the elements before the real animation started.
  28563. this._zr.flush()
  28564. this[IN_MAIN_PROCESS_KEY] = false
  28565. this[PENDING_UPDATE] = null
  28566. flushPendingActions.call(this, silent)
  28567. triggerUpdatedEvent.call(this, silent)
  28568. } // Avoid do both lazy update and progress in one frame.
  28569. else if (scheduler.unfinished) {
  28570. // Stream progress.
  28571. var remainTime = TEST_FRAME_REMAIN_TIME
  28572. var ecModel = this._model
  28573. var api = this._api
  28574. scheduler.unfinished = false
  28575. do {
  28576. var startTime = +new Date()
  28577. scheduler.performSeriesTasks(ecModel) // Currently dataProcessorFuncs do not check threshold.
  28578. scheduler.performDataProcessorTasks(ecModel)
  28579. updateStreamModes(this, ecModel) // Do not update coordinate system here. Because that coord system update in
  28580. // each frame is not a good user experience. So we follow the rule that
  28581. // the extent of the coordinate system is determin in the first frame (the
  28582. // frame is executed immedietely after task reset.
  28583. // this._coordSysMgr.update(ecModel, api);
  28584. // console.log('--- ec frame visual ---', remainTime);
  28585. scheduler.performVisualTasks(ecModel)
  28586. renderSeries(this, this._model, api, 'remain', {})
  28587. remainTime -= +new Date() - startTime
  28588. } while (remainTime > 0 && scheduler.unfinished) // Call flush explicitly for trigger finished event.
  28589. if (!scheduler.unfinished) {
  28590. this._zr.flush()
  28591. } // Else, zr flushing be ensue within the same frame,
  28592. // because zr flushing is after onframe event.
  28593. }
  28594. }
  28595. ECharts.prototype.getDom = function () {
  28596. return this._dom
  28597. }
  28598. ECharts.prototype.getId = function () {
  28599. return this.id
  28600. }
  28601. ECharts.prototype.getZr = function () {
  28602. return this._zr
  28603. }
  28604. ECharts.prototype.isSSR = function () {
  28605. return this._ssr
  28606. }
  28607. /* eslint-disable-next-line */ ECharts.prototype.setOption =
  28608. function (option, notMerge, lazyUpdate) {
  28609. if (this[IN_MAIN_PROCESS_KEY]) {
  28610. return
  28611. }
  28612. if (this._disposed) {
  28613. disposedWarning(this.id)
  28614. return
  28615. }
  28616. var silent
  28617. var replaceMerge
  28618. var transitionOpt
  28619. if (isObject$2(notMerge)) {
  28620. lazyUpdate = notMerge.lazyUpdate
  28621. silent = notMerge.silent
  28622. replaceMerge = notMerge.replaceMerge
  28623. transitionOpt = notMerge.transition
  28624. notMerge = notMerge.notMerge
  28625. }
  28626. this[IN_MAIN_PROCESS_KEY] = true
  28627. if (!this._model || notMerge) {
  28628. var optionManager = new OptionManager$1(this._api)
  28629. var theme = this._theme
  28630. var ecModel = (this._model = new GlobalModel$1())
  28631. ecModel.scheduler = this._scheduler
  28632. ecModel.ssr = this._ssr
  28633. ecModel.init(
  28634. null,
  28635. null,
  28636. null,
  28637. theme,
  28638. this._locale,
  28639. optionManager
  28640. )
  28641. }
  28642. this._model.setOption(
  28643. option,
  28644. { replaceMerge: replaceMerge },
  28645. optionPreprocessorFuncs
  28646. )
  28647. var updateParams = {
  28648. seriesTransition: transitionOpt,
  28649. optionChanged: true
  28650. }
  28651. if (lazyUpdate) {
  28652. this[PENDING_UPDATE] = {
  28653. silent: silent,
  28654. updateParams: updateParams
  28655. }
  28656. this[IN_MAIN_PROCESS_KEY] = false // `setOption(option, {lazyMode: true})` may be called when zrender has been slept.
  28657. // It should wake it up to make sure zrender start to render at the next frame.
  28658. this.getZr().wakeUp()
  28659. } else {
  28660. try {
  28661. prepare(this)
  28662. updateMethods.update.call(this, null, updateParams)
  28663. } catch (e) {
  28664. this[PENDING_UPDATE] = null
  28665. this[IN_MAIN_PROCESS_KEY] = false
  28666. throw e
  28667. } // Ensure zr refresh sychronously, and then pixel in canvas can be
  28668. // fetched after `setOption`.
  28669. if (!this._ssr) {
  28670. // not use flush when using ssr mode.
  28671. this._zr.flush()
  28672. }
  28673. this[PENDING_UPDATE] = null
  28674. this[IN_MAIN_PROCESS_KEY] = false
  28675. flushPendingActions.call(this, silent)
  28676. triggerUpdatedEvent.call(this, silent)
  28677. }
  28678. }
  28679. /**
  28680. * @deprecated
  28681. */ ECharts.prototype.setTheme = function () {} // We don't want developers to use getModel directly.
  28682. ECharts.prototype.getModel = function () {
  28683. return this._model
  28684. }
  28685. ECharts.prototype.getOption = function () {
  28686. return this._model && this._model.getOption()
  28687. }
  28688. ECharts.prototype.getWidth = function () {
  28689. return this._zr.getWidth()
  28690. }
  28691. ECharts.prototype.getHeight = function () {
  28692. return this._zr.getHeight()
  28693. }
  28694. ECharts.prototype.getDevicePixelRatio = function () {
  28695. return (
  28696. this._zr.painter.dpr /* eslint-disable-next-line */ ||
  28697. (hasWindow && window.devicePixelRatio) ||
  28698. 1
  28699. )
  28700. }
  28701. /**
  28702. * Get canvas which has all thing rendered
  28703. * @deprecated Use renderToCanvas instead.
  28704. */ ECharts.prototype.getRenderedCanvas = function (opts) {
  28705. return this.renderToCanvas(opts)
  28706. }
  28707. ECharts.prototype.renderToCanvas = function (opts) {
  28708. opts = opts || {}
  28709. var painter = this._zr.painter
  28710. return painter.getRenderedCanvas({
  28711. backgroundColor:
  28712. opts.backgroundColor || this._model.get('backgroundColor'),
  28713. pixelRatio: opts.pixelRatio || this.getDevicePixelRatio()
  28714. })
  28715. }
  28716. ECharts.prototype.renderToSVGString = function (opts) {
  28717. opts = opts || {}
  28718. var painter = this._zr.painter
  28719. return painter.renderToString({ useViewBox: opts.useViewBox })
  28720. }
  28721. /**
  28722. * Get svg data url
  28723. */ ECharts.prototype.getSvgDataURL = function () {
  28724. if (!env$1.svgSupported) {
  28725. return
  28726. }
  28727. var zr = this._zr
  28728. var list = zr.storage.getDisplayList() // Stop animations
  28729. each$7(list, function (el) {
  28730. el.stopAnimation(null, true)
  28731. })
  28732. return zr.painter.toDataURL()
  28733. }
  28734. ECharts.prototype.getDataURL = function (opts) {
  28735. if (this._disposed) {
  28736. disposedWarning(this.id)
  28737. return
  28738. }
  28739. opts = opts || {}
  28740. var excludeComponents = opts.excludeComponents
  28741. var ecModel = this._model
  28742. var excludesComponentViews = []
  28743. var self = this
  28744. each$7(excludeComponents, function (componentType) {
  28745. ecModel.eachComponent(
  28746. { mainType: componentType },
  28747. function (component) {
  28748. var view = self._componentsMap[component.__viewId]
  28749. if (!view.group.ignore) {
  28750. excludesComponentViews.push(view)
  28751. view.group.ignore = true
  28752. }
  28753. }
  28754. )
  28755. })
  28756. var url =
  28757. this._zr.painter.getType() === 'svg'
  28758. ? this.getSvgDataURL()
  28759. : this.renderToCanvas(opts).toDataURL(
  28760. 'image/' + ((opts && opts.type) || 'png')
  28761. )
  28762. each$7(excludesComponentViews, function (view) {
  28763. view.group.ignore = false
  28764. })
  28765. return url
  28766. }
  28767. ECharts.prototype.getConnectedDataURL = function (opts) {
  28768. if (this._disposed) {
  28769. disposedWarning(this.id)
  28770. return
  28771. }
  28772. var isSvg = opts.type === 'svg'
  28773. var groupId = this.group
  28774. var mathMin = Math.min
  28775. var mathMax = Math.max
  28776. var MAX_NUMBER = Infinity
  28777. if (connectedGroups[groupId]) {
  28778. var left_1 = MAX_NUMBER
  28779. var top_1 = MAX_NUMBER
  28780. var right_1 = -MAX_NUMBER
  28781. var bottom_1 = -MAX_NUMBER
  28782. var canvasList_1 = []
  28783. var dpr_1 =
  28784. (opts && opts.pixelRatio) || this.getDevicePixelRatio()
  28785. each$7(instances, function (chart, id) {
  28786. if (chart.group === groupId) {
  28787. var canvas = isSvg
  28788. ? chart.getZr().painter.getSvgDom().innerHTML
  28789. : chart.renderToCanvas(clone$3(opts))
  28790. var boundingRect = chart.getDom().getBoundingClientRect()
  28791. left_1 = mathMin(boundingRect.left, left_1)
  28792. top_1 = mathMin(boundingRect.top, top_1)
  28793. right_1 = mathMax(boundingRect.right, right_1)
  28794. bottom_1 = mathMax(boundingRect.bottom, bottom_1)
  28795. canvasList_1.push({
  28796. dom: canvas,
  28797. left: boundingRect.left,
  28798. top: boundingRect.top
  28799. })
  28800. }
  28801. })
  28802. left_1 *= dpr_1
  28803. top_1 *= dpr_1
  28804. right_1 *= dpr_1
  28805. bottom_1 *= dpr_1
  28806. var width = right_1 - left_1
  28807. var height = bottom_1 - top_1
  28808. var targetCanvas = platformApi.createCanvas()
  28809. var zr_1 = init$1(targetCanvas, {
  28810. renderer: isSvg ? 'svg' : 'canvas'
  28811. })
  28812. zr_1.resize({ width: width, height: height })
  28813. if (isSvg) {
  28814. var content_1 = ''
  28815. each$7(canvasList_1, function (item) {
  28816. var x = item.left - left_1
  28817. var y = item.top - top_1
  28818. content_1 +=
  28819. '<g transform="translate(' +
  28820. x +
  28821. ',' +
  28822. y +
  28823. ')">' +
  28824. item.dom +
  28825. '</g>'
  28826. })
  28827. zr_1.painter.getSvgRoot().innerHTML = content_1
  28828. if (opts.connectedBackgroundColor) {
  28829. zr_1.painter.setBackgroundColor(
  28830. opts.connectedBackgroundColor
  28831. )
  28832. }
  28833. zr_1.refreshImmediately()
  28834. return zr_1.painter.toDataURL()
  28835. } else {
  28836. // Background between the charts
  28837. if (opts.connectedBackgroundColor) {
  28838. zr_1.add(
  28839. new Rect$2({
  28840. shape: { x: 0, y: 0, width: width, height: height },
  28841. style: { fill: opts.connectedBackgroundColor }
  28842. })
  28843. )
  28844. }
  28845. each$7(canvasList_1, function (item) {
  28846. var img = new ZRImage$1({
  28847. style: {
  28848. x: item.left * dpr_1 - left_1,
  28849. y: item.top * dpr_1 - top_1,
  28850. image: item.dom
  28851. }
  28852. })
  28853. zr_1.add(img)
  28854. })
  28855. zr_1.refreshImmediately()
  28856. return targetCanvas.toDataURL(
  28857. 'image/' + ((opts && opts.type) || 'png')
  28858. )
  28859. }
  28860. } else {
  28861. return this.getDataURL(opts)
  28862. }
  28863. }
  28864. ECharts.prototype.convertToPixel = function (finder, value) {
  28865. return doConvertPixel(this, 'convertToPixel', finder, value)
  28866. }
  28867. ECharts.prototype.convertFromPixel = function (finder, value) {
  28868. return doConvertPixel(this, 'convertFromPixel', finder, value)
  28869. }
  28870. /**
  28871. * Is the specified coordinate systems or components contain the given pixel point.
  28872. * @param {Array|number} value
  28873. * @return {boolean} result
  28874. */ ECharts.prototype.containPixel = function (finder, value) {
  28875. if (this._disposed) {
  28876. disposedWarning(this.id)
  28877. return
  28878. }
  28879. var ecModel = this._model
  28880. var result
  28881. var findResult = parseFinder$1(ecModel, finder)
  28882. each$7(
  28883. findResult,
  28884. function (models, key) {
  28885. key.indexOf('Models') >= 0 &&
  28886. each$7(
  28887. models,
  28888. function (model) {
  28889. var coordSys = model.coordinateSystem
  28890. if (coordSys && coordSys.containPoint) {
  28891. result = result || !!coordSys.containPoint(value)
  28892. } else if (key === 'seriesModels') {
  28893. var view = this._chartsMap[model.__viewId]
  28894. if (view && view.containPoint) {
  28895. result = result || view.containPoint(value, model)
  28896. }
  28897. } else;
  28898. },
  28899. this
  28900. )
  28901. },
  28902. this
  28903. )
  28904. return !!result
  28905. }
  28906. /**
  28907. * Get visual from series or data.
  28908. * @param finder
  28909. * If string, e.g., 'series', means {seriesIndex: 0}.
  28910. * If Object, could contain some of these properties below:
  28911. * {
  28912. * seriesIndex / seriesId / seriesName,
  28913. * dataIndex / dataIndexInside
  28914. * }
  28915. * If dataIndex is not specified, series visual will be fetched,
  28916. * but not data item visual.
  28917. * If all of seriesIndex, seriesId, seriesName are not specified,
  28918. * visual will be fetched from first series.
  28919. * @param visualType 'color', 'symbol', 'symbolSize'
  28920. */ ECharts.prototype.getVisual = function (finder, visualType) {
  28921. var ecModel = this._model
  28922. var parsedFinder = parseFinder$1(ecModel, finder, {
  28923. defaultMainType: 'series'
  28924. })
  28925. var seriesModel = parsedFinder.seriesModel
  28926. var data = seriesModel.getData()
  28927. var dataIndexInside = parsedFinder.hasOwnProperty(
  28928. 'dataIndexInside'
  28929. )
  28930. ? parsedFinder.dataIndexInside
  28931. : parsedFinder.hasOwnProperty('dataIndex')
  28932. ? data.indexOfRawIndex(parsedFinder.dataIndex)
  28933. : null
  28934. return dataIndexInside != null
  28935. ? getItemVisualFromData(data, dataIndexInside, visualType)
  28936. : getVisualFromData(data, visualType)
  28937. }
  28938. /**
  28939. * Get view of corresponding component model
  28940. */ ECharts.prototype.getViewOfComponentModel = function (
  28941. componentModel
  28942. ) {
  28943. return this._componentsMap[componentModel.__viewId]
  28944. }
  28945. /**
  28946. * Get view of corresponding series model
  28947. */ ECharts.prototype.getViewOfSeriesModel = function (
  28948. seriesModel
  28949. ) {
  28950. return this._chartsMap[seriesModel.__viewId]
  28951. }
  28952. ECharts.prototype._initEvents = function () {
  28953. var _this = this
  28954. each$7(MOUSE_EVENT_NAMES, function (eveName) {
  28955. var handler = function handler(e) {
  28956. var ecModel = _this.getModel()
  28957. var el = e.target
  28958. var params
  28959. var isGlobalOut = eveName === 'globalout' // no e.target when 'globalout'.
  28960. if (isGlobalOut) {
  28961. params = {}
  28962. } else {
  28963. el &&
  28964. findEventDispatcher(
  28965. el,
  28966. function (parent) {
  28967. var ecData = getECData(parent)
  28968. if (ecData && ecData.dataIndex != null) {
  28969. var dataModel =
  28970. ecData.dataModel ||
  28971. ecModel.getSeriesByIndex(ecData.seriesIndex)
  28972. params =
  28973. (dataModel &&
  28974. dataModel.getDataParams(
  28975. ecData.dataIndex,
  28976. ecData.dataType
  28977. )) ||
  28978. {}
  28979. return true
  28980. } // If element has custom eventData of components
  28981. else if (ecData.eventData) {
  28982. params = extend({}, ecData.eventData)
  28983. return true
  28984. }
  28985. },
  28986. true
  28987. )
  28988. } // Contract: if params prepared in mouse event,
  28989. // these properties must be specified:
  28990. // {
  28991. // componentType: string (component main type)
  28992. // componentIndex: number
  28993. // }
  28994. // Otherwise event query can not work.
  28995. if (params) {
  28996. var componentType = params.componentType
  28997. var componentIndex = params.componentIndex // Special handling for historic reason: when trigger by
  28998. // markLine/markPoint/markArea, the componentType is
  28999. // 'markLine'/'markPoint'/'markArea', but we should better
  29000. // enable them to be queried by seriesIndex, since their
  29001. // option is set in each series.
  29002. if (
  29003. componentType === 'markLine' ||
  29004. componentType === 'markPoint' ||
  29005. componentType === 'markArea'
  29006. ) {
  29007. componentType = 'series'
  29008. componentIndex = params.seriesIndex
  29009. }
  29010. var model =
  29011. componentType &&
  29012. componentIndex != null &&
  29013. ecModel.getComponent(componentType, componentIndex)
  29014. var view =
  29015. model &&
  29016. _this[
  29017. model.mainType === 'series'
  29018. ? '_chartsMap'
  29019. : '_componentsMap'
  29020. ][model.__viewId]
  29021. params.event = e
  29022. params.type = eveName
  29023. _this._$eventProcessor.eventInfo = {
  29024. targetEl: el,
  29025. packedEvent: params,
  29026. model: model,
  29027. view: view
  29028. }
  29029. _this.trigger(eveName, params)
  29030. }
  29031. } // Consider that some component (like tooltip, brush, ...)
  29032. // register zr event handler, but user event handler might
  29033. // do anything, such as call `setOption` or `dispatchAction`,
  29034. // which probably update any of the content and probably
  29035. // cause problem if it is called previous other inner handlers.
  29036. handler.zrEventfulCallAtLast = true
  29037. _this._zr.on(eveName, handler, _this)
  29038. })
  29039. each$7(eventActionMap, function (actionType, eventType) {
  29040. _this._messageCenter.on(
  29041. eventType,
  29042. function (event) {
  29043. this.trigger(eventType, event)
  29044. },
  29045. _this
  29046. )
  29047. }) // Extra events
  29048. // TODO register?
  29049. each$7(['selectchanged'], function (eventType) {
  29050. _this._messageCenter.on(
  29051. eventType,
  29052. function (event) {
  29053. this.trigger(eventType, event)
  29054. },
  29055. _this
  29056. )
  29057. })
  29058. handleLegacySelectEvents(this._messageCenter, this, this._api)
  29059. }
  29060. ECharts.prototype.isDisposed = function () {
  29061. return this._disposed
  29062. }
  29063. ECharts.prototype.clear = function () {
  29064. if (this._disposed) {
  29065. disposedWarning(this.id)
  29066. return
  29067. }
  29068. this.setOption({ series: [] }, true)
  29069. }
  29070. ECharts.prototype.dispose = function () {
  29071. if (this._disposed) {
  29072. disposedWarning(this.id)
  29073. return
  29074. }
  29075. this._disposed = true
  29076. var dom = this.getDom()
  29077. if (dom) {
  29078. setAttribute(this.getDom(), DOM_ATTRIBUTE_KEY, '')
  29079. }
  29080. var chart = this
  29081. var api = chart._api
  29082. var ecModel = chart._model
  29083. each$7(chart._componentsViews, function (component) {
  29084. component.dispose(ecModel, api)
  29085. })
  29086. each$7(chart._chartsViews, function (chart) {
  29087. chart.dispose(ecModel, api)
  29088. }) // Dispose after all views disposed
  29089. chart._zr.dispose() // Set properties to null.
  29090. // To reduce the memory cost in case the top code still holds this instance unexpectedly.
  29091. chart._dom =
  29092. chart._model =
  29093. chart._chartsMap =
  29094. chart._componentsMap =
  29095. chart._chartsViews =
  29096. chart._componentsViews =
  29097. chart._scheduler =
  29098. chart._api =
  29099. chart._zr =
  29100. chart._throttledZrFlush =
  29101. chart._theme =
  29102. chart._coordSysMgr =
  29103. chart._messageCenter =
  29104. null
  29105. delete instances[chart.id]
  29106. }
  29107. /**
  29108. * Resize the chart
  29109. */ ECharts.prototype.resize = function (opts) {
  29110. if (this[IN_MAIN_PROCESS_KEY]) {
  29111. return
  29112. }
  29113. if (this._disposed) {
  29114. disposedWarning(this.id)
  29115. return
  29116. }
  29117. this._zr.resize(opts)
  29118. var ecModel = this._model // Resize loading effect
  29119. this._loadingFX && this._loadingFX.resize()
  29120. if (!ecModel) {
  29121. return
  29122. }
  29123. var needPrepare = ecModel.resetOption('media')
  29124. var silent = opts && opts.silent // There is some real cases that:
  29125. // chart.setOption(option, { lazyUpdate: true });
  29126. // chart.resize();
  29127. if (this[PENDING_UPDATE]) {
  29128. if (silent == null) {
  29129. silent = this[PENDING_UPDATE].silent
  29130. }
  29131. needPrepare = true
  29132. this[PENDING_UPDATE] = null
  29133. }
  29134. this[IN_MAIN_PROCESS_KEY] = true
  29135. try {
  29136. needPrepare && prepare(this)
  29137. updateMethods.update.call(this, {
  29138. type: 'resize',
  29139. animation: extend(
  29140. {
  29141. // Disable animation
  29142. duration: 0
  29143. },
  29144. opts && opts.animation
  29145. )
  29146. })
  29147. } catch (e) {
  29148. this[IN_MAIN_PROCESS_KEY] = false
  29149. throw e
  29150. }
  29151. this[IN_MAIN_PROCESS_KEY] = false
  29152. flushPendingActions.call(this, silent)
  29153. triggerUpdatedEvent.call(this, silent)
  29154. }
  29155. ECharts.prototype.showLoading = function (name, cfg) {
  29156. if (this._disposed) {
  29157. disposedWarning(this.id)
  29158. return
  29159. }
  29160. if (isObject$2(name)) {
  29161. cfg = name
  29162. name = ''
  29163. }
  29164. name = name || 'default'
  29165. this.hideLoading()
  29166. if (!loadingEffects[name]) {
  29167. return
  29168. }
  29169. var el = loadingEffects[name](this._api, cfg)
  29170. var zr = this._zr
  29171. this._loadingFX = el
  29172. zr.add(el)
  29173. }
  29174. /**
  29175. * Hide loading effect
  29176. */ ECharts.prototype.hideLoading = function () {
  29177. if (this._disposed) {
  29178. disposedWarning(this.id)
  29179. return
  29180. }
  29181. this._loadingFX && this._zr.remove(this._loadingFX)
  29182. this._loadingFX = null
  29183. }
  29184. ECharts.prototype.makeActionFromEvent = function (eventObj) {
  29185. var payload = extend({}, eventObj)
  29186. payload.type = eventActionMap[eventObj.type]
  29187. return payload
  29188. }
  29189. /**
  29190. * @param opt If pass boolean, means opt.silent
  29191. * @param opt.silent Default `false`. Whether trigger events.
  29192. * @param opt.flush Default `undefined`.
  29193. * true: Flush immediately, and then pixel in canvas can be fetched
  29194. * immediately. Caution: it might affect performance.
  29195. * false: Not flush.
  29196. * undefined: Auto decide whether perform flush.
  29197. */ ECharts.prototype.dispatchAction = function (payload, opt) {
  29198. if (this._disposed) {
  29199. disposedWarning(this.id)
  29200. return
  29201. }
  29202. if (!isObject$2(opt)) {
  29203. opt = { silent: !!opt }
  29204. }
  29205. if (!actions[payload.type]) {
  29206. return
  29207. } // Avoid dispatch action before setOption. Especially in `connect`.
  29208. if (!this._model) {
  29209. return
  29210. } // May dispatchAction in rendering procedure
  29211. if (this[IN_MAIN_PROCESS_KEY]) {
  29212. this._pendingActions.push(payload)
  29213. return
  29214. }
  29215. var silent = opt.silent
  29216. doDispatchAction.call(this, payload, silent)
  29217. var flush = opt.flush
  29218. if (flush) {
  29219. this._zr.flush()
  29220. } else if (flush !== false && env$1.browser.weChat) {
  29221. // In WeChat embeded browser, `requestAnimationFrame` and `setInterval`
  29222. // hang when sliding page (on touch event), which cause that zr does not
  29223. // refresh util user interaction finished, which is not expected.
  29224. // But `dispatchAction` may be called too frequently when pan on touch
  29225. // screen, which impacts performance if do not throttle them.
  29226. this._throttledZrFlush()
  29227. }
  29228. flushPendingActions.call(this, silent)
  29229. triggerUpdatedEvent.call(this, silent)
  29230. }
  29231. ECharts.prototype.updateLabelLayout = function () {
  29232. lifecycle$1.trigger(
  29233. 'series:layoutlabels',
  29234. this._model,
  29235. this._api,
  29236. {
  29237. // Not adding series labels.
  29238. // TODO
  29239. updatedSeries: []
  29240. }
  29241. )
  29242. }
  29243. ECharts.prototype.appendData = function (params) {
  29244. if (this._disposed) {
  29245. disposedWarning(this.id)
  29246. return
  29247. }
  29248. var seriesIndex = params.seriesIndex
  29249. var ecModel = this.getModel()
  29250. var seriesModel = ecModel.getSeriesByIndex(seriesIndex)
  29251. seriesModel.appendData(params) // Note: `appendData` does not support that update extent of coordinate
  29252. // system, util some scenario require that. In the expected usage of
  29253. // `appendData`, the initial extent of coordinate system should better
  29254. // be fixed by axis `min`/`max` setting or initial data, otherwise if
  29255. // the extent changed while `appendData`, the location of the painted
  29256. // graphic elements have to be changed, which make the usage of
  29257. // `appendData` meaningless.
  29258. this._scheduler.unfinished = true
  29259. this.getZr().wakeUp()
  29260. } // A work around for no `internal` modifier in ts yet but
  29261. // need to strictly hide private methods to JS users.
  29262. ECharts.internalField = (function () {
  29263. prepare = function prepare(ecIns) {
  29264. var scheduler = ecIns._scheduler
  29265. scheduler.restorePipelines(ecIns._model)
  29266. scheduler.prepareStageTasks()
  29267. prepareView(ecIns, true)
  29268. prepareView(ecIns, false)
  29269. scheduler.plan()
  29270. }
  29271. /**
  29272. * Prepare view instances of charts and components
  29273. */ prepareView = function prepareView(ecIns, isComponent) {
  29274. var ecModel = ecIns._model
  29275. var scheduler = ecIns._scheduler
  29276. var viewList = isComponent
  29277. ? ecIns._componentsViews
  29278. : ecIns._chartsViews
  29279. var viewMap = isComponent
  29280. ? ecIns._componentsMap
  29281. : ecIns._chartsMap
  29282. var zr = ecIns._zr
  29283. var api = ecIns._api
  29284. for (var i = 0; i < viewList.length; i++) {
  29285. viewList[i].__alive = false
  29286. }
  29287. isComponent
  29288. ? ecModel.eachComponent(function (componentType, model) {
  29289. componentType !== 'series' && doPrepare(model)
  29290. })
  29291. : ecModel.eachSeries(doPrepare)
  29292. function doPrepare(model) {
  29293. // By defaut view will be reused if possible for the case that `setOption` with "notMerge"
  29294. // mode and need to enable transition animation. (Usually, when they have the same id, or
  29295. // especially no id but have the same type & name & index. See the `model.id` generation
  29296. // rule in `makeIdAndName` and `viewId` generation rule here).
  29297. // But in `replaceMerge` mode, this feature should be able to disabled when it is clear that
  29298. // the new model has nothing to do with the old model.
  29299. var requireNewView = model.__requireNewView // This command should not work twice.
  29300. model.__requireNewView = false // Consider: id same and type changed.
  29301. var viewId = '_ec_' + model.id + '_' + model.type
  29302. var view = !requireNewView && viewMap[viewId]
  29303. if (!view) {
  29304. var classType = parseClassType(model.type)
  29305. var Clazz = isComponent
  29306. ? ComponentView$1.getClass(classType.main, classType.sub) // FIXME:TS
  29307. : // (ChartView as ChartViewConstructor).getClass('series', classType.sub)
  29308. // For backward compat, still support a chart type declared as only subType
  29309. // like "liquidfill", but recommend "series.liquidfill"
  29310. // But need a base class to make a type series.
  29311. ChartView$1.getClass(classType.sub)
  29312. view = new Clazz()
  29313. view.init(ecModel, api)
  29314. viewMap[viewId] = view
  29315. viewList.push(view)
  29316. zr.add(view.group)
  29317. }
  29318. model.__viewId = view.__id = viewId
  29319. view.__alive = true
  29320. view.__model = model
  29321. view.group.__ecComponentInfo = {
  29322. mainType: model.mainType,
  29323. index: model.componentIndex
  29324. }
  29325. !isComponent &&
  29326. scheduler.prepareView(view, model, ecModel, api)
  29327. }
  29328. for (var i = 0; i < viewList.length; ) {
  29329. var view = viewList[i]
  29330. if (!view.__alive) {
  29331. !isComponent && view.renderTask.dispose()
  29332. zr.remove(view.group)
  29333. view.dispose(ecModel, api)
  29334. viewList.splice(i, 1)
  29335. if (viewMap[view.__id] === view) {
  29336. delete viewMap[view.__id]
  29337. }
  29338. view.__id = view.group.__ecComponentInfo = null
  29339. } else {
  29340. i++
  29341. }
  29342. }
  29343. }
  29344. updateDirectly = function updateDirectly(
  29345. ecIns,
  29346. method,
  29347. payload,
  29348. mainType,
  29349. subType
  29350. ) {
  29351. var ecModel = ecIns._model
  29352. ecModel.setUpdatePayload(payload) // broadcast
  29353. if (!mainType) {
  29354. // FIXME
  29355. // Chart will not be update directly here, except set dirty.
  29356. // But there is no such scenario now.
  29357. each$7(
  29358. []
  29359. .concat(ecIns._componentsViews)
  29360. .concat(ecIns._chartsViews),
  29361. callView
  29362. )
  29363. return
  29364. }
  29365. var query = {}
  29366. query[mainType + 'Id'] = payload[mainType + 'Id']
  29367. query[mainType + 'Index'] = payload[mainType + 'Index']
  29368. query[mainType + 'Name'] = payload[mainType + 'Name']
  29369. var condition = { mainType: mainType, query: query }
  29370. subType && (condition.subType = subType) // subType may be '' by parseClassType;
  29371. var excludeSeriesId = payload.excludeSeriesId
  29372. var excludeSeriesIdMap
  29373. if (excludeSeriesId != null) {
  29374. excludeSeriesIdMap = createHashMap()
  29375. each$7(normalizeToArray(excludeSeriesId), function (id) {
  29376. var modelId = convertOptionIdName(id, null)
  29377. if (modelId != null) {
  29378. excludeSeriesIdMap.set(modelId, true)
  29379. }
  29380. })
  29381. } // If dispatchAction before setOption, do nothing.
  29382. ecModel &&
  29383. ecModel.eachComponent(
  29384. condition,
  29385. function (model) {
  29386. var isExcluded =
  29387. excludeSeriesIdMap &&
  29388. excludeSeriesIdMap.get(model.id) !== null
  29389. if (isExcluded) {
  29390. return
  29391. }
  29392. if (isHighDownPayload(payload)) {
  29393. if (model instanceof SeriesModel$1) {
  29394. if (
  29395. payload.type === HIGHLIGHT_ACTION_TYPE &&
  29396. !payload.notBlur &&
  29397. !model.get(['emphasis', 'disabled'])
  29398. ) {
  29399. blurSeriesFromHighlightPayload(
  29400. model,
  29401. payload,
  29402. ecIns._api
  29403. )
  29404. }
  29405. } else {
  29406. var _a = findComponentHighDownDispatchers(
  29407. model.mainType,
  29408. model.componentIndex,
  29409. payload.name,
  29410. ecIns._api
  29411. ),
  29412. focusSelf = _a.focusSelf,
  29413. dispatchers = _a.dispatchers
  29414. if (
  29415. payload.type === HIGHLIGHT_ACTION_TYPE &&
  29416. focusSelf &&
  29417. !payload.notBlur
  29418. ) {
  29419. blurComponent(
  29420. model.mainType,
  29421. model.componentIndex,
  29422. ecIns._api
  29423. )
  29424. } // PENDING:
  29425. // Whether to put this "enter emphasis" code in `ComponentView`,
  29426. // which will be the same as `ChartView` but might be not necessary
  29427. // and will be far from this logic.
  29428. if (dispatchers) {
  29429. each$7(dispatchers, function (dispatcher) {
  29430. payload.type === HIGHLIGHT_ACTION_TYPE
  29431. ? enterEmphasis(dispatcher)
  29432. : leaveEmphasis(dispatcher)
  29433. })
  29434. }
  29435. }
  29436. } else if (isSelectChangePayload(payload)) {
  29437. // TODO geo
  29438. if (model instanceof SeriesModel$1) {
  29439. toggleSelectionFromPayload(model, payload, ecIns._api)
  29440. updateSeriesElementSelection(model)
  29441. markStatusToUpdate(ecIns)
  29442. }
  29443. }
  29444. },
  29445. ecIns
  29446. )
  29447. ecModel &&
  29448. ecModel.eachComponent(
  29449. condition,
  29450. function (model) {
  29451. var isExcluded =
  29452. excludeSeriesIdMap &&
  29453. excludeSeriesIdMap.get(model.id) !== null
  29454. if (isExcluded) {
  29455. return
  29456. }
  29457. callView(
  29458. ecIns[
  29459. mainType === 'series'
  29460. ? '_chartsMap'
  29461. : '_componentsMap'
  29462. ][model.__viewId]
  29463. )
  29464. },
  29465. ecIns
  29466. )
  29467. function callView(view) {
  29468. view &&
  29469. view.__alive &&
  29470. view[method] &&
  29471. view[method](view.__model, ecModel, ecIns._api, payload)
  29472. }
  29473. }
  29474. updateMethods = {
  29475. prepareAndUpdate: function prepareAndUpdate(payload) {
  29476. prepare(this)
  29477. updateMethods.update.call(this, payload, {
  29478. // Needs to mark option changed if newOption is given.
  29479. // It's from MagicType.
  29480. // TODO If use a separate flag optionChanged in payload?
  29481. optionChanged: payload.newOption != null
  29482. })
  29483. },
  29484. update: function update(payload, updateParams) {
  29485. var ecModel = this._model
  29486. var api = this._api
  29487. var zr = this._zr
  29488. var coordSysMgr = this._coordSysMgr
  29489. var scheduler = this._scheduler // update before setOption
  29490. if (!ecModel) {
  29491. return
  29492. }
  29493. ecModel.setUpdatePayload(payload)
  29494. scheduler.restoreData(ecModel, payload)
  29495. scheduler.performSeriesTasks(ecModel) // TODO
  29496. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  29497. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  29498. // Create new coordinate system each update
  29499. // In LineView may save the old coordinate system and use it to get the orignal point
  29500. coordSysMgr.create(ecModel, api)
  29501. scheduler.performDataProcessorTasks(ecModel, payload) // Current stream render is not supported in data process. So we can update
  29502. // stream modes after data processing, where the filtered data is used to
  29503. // deteming whether use progressive rendering.
  29504. updateStreamModes(this, ecModel) // We update stream modes before coordinate system updated, then the modes info
  29505. // can be fetched when coord sys updating (consider the barGrid extent fix). But
  29506. // the drawback is the full coord info can not be fetched. Fortunately this full
  29507. // coord is not requied in stream mode updater currently.
  29508. coordSysMgr.update(ecModel, api)
  29509. clearColorPalette(ecModel)
  29510. scheduler.performVisualTasks(ecModel, payload)
  29511. render(this, ecModel, api, payload, updateParams) // Set background
  29512. var backgroundColor =
  29513. ecModel.get('backgroundColor') || 'transparent'
  29514. var darkMode = ecModel.get('darkMode')
  29515. zr.setBackgroundColor(backgroundColor) // Force set dark mode.
  29516. if (darkMode != null && darkMode !== 'auto') {
  29517. zr.setDarkMode(darkMode)
  29518. }
  29519. lifecycle$1.trigger('afterupdate', ecModel, api)
  29520. },
  29521. updateTransform: function updateTransform(payload) {
  29522. var _this = this
  29523. var ecModel = this._model
  29524. var api = this._api // update before setOption
  29525. if (!ecModel) {
  29526. return
  29527. }
  29528. ecModel.setUpdatePayload(payload) // ChartView.markUpdateMethod(payload, 'updateTransform');
  29529. var componentDirtyList = []
  29530. ecModel.eachComponent(function (
  29531. componentType,
  29532. componentModel
  29533. ) {
  29534. if (componentType === 'series') {
  29535. return
  29536. }
  29537. var componentView =
  29538. _this.getViewOfComponentModel(componentModel)
  29539. if (componentView && componentView.__alive) {
  29540. if (componentView.updateTransform) {
  29541. var result = componentView.updateTransform(
  29542. componentModel,
  29543. ecModel,
  29544. api,
  29545. payload
  29546. )
  29547. result &&
  29548. result.update &&
  29549. componentDirtyList.push(componentView)
  29550. } else {
  29551. componentDirtyList.push(componentView)
  29552. }
  29553. }
  29554. })
  29555. var seriesDirtyMap = createHashMap()
  29556. ecModel.eachSeries(function (seriesModel) {
  29557. var chartView = _this._chartsMap[seriesModel.__viewId]
  29558. if (chartView.updateTransform) {
  29559. var result = chartView.updateTransform(
  29560. seriesModel,
  29561. ecModel,
  29562. api,
  29563. payload
  29564. )
  29565. result &&
  29566. result.update &&
  29567. seriesDirtyMap.set(seriesModel.uid, 1)
  29568. } else {
  29569. seriesDirtyMap.set(seriesModel.uid, 1)
  29570. }
  29571. })
  29572. clearColorPalette(ecModel) // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.
  29573. // this._scheduler.performVisualTasks(ecModel, payload, 'layout', true);
  29574. this._scheduler.performVisualTasks(ecModel, payload, {
  29575. setDirty: true,
  29576. dirtyMap: seriesDirtyMap
  29577. }) // Currently, not call render of components. Geo render cost a lot.
  29578. // renderComponents(ecIns, ecModel, api, payload, componentDirtyList);
  29579. renderSeries(this, ecModel, api, payload, {}, seriesDirtyMap)
  29580. lifecycle$1.trigger('afterupdate', ecModel, api)
  29581. },
  29582. updateView: function updateView(payload) {
  29583. var ecModel = this._model // update before setOption
  29584. if (!ecModel) {
  29585. return
  29586. }
  29587. ecModel.setUpdatePayload(payload)
  29588. ChartView$1.markUpdateMethod(payload, 'updateView')
  29589. clearColorPalette(ecModel) // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.
  29590. this._scheduler.performVisualTasks(ecModel, payload, {
  29591. setDirty: true
  29592. })
  29593. render(this, ecModel, this._api, payload, {})
  29594. lifecycle$1.trigger('afterupdate', ecModel, this._api)
  29595. },
  29596. updateVisual: function updateVisual(payload) {
  29597. // updateMethods.update.call(this, payload);
  29598. var _this = this
  29599. var ecModel = this._model // update before setOption
  29600. if (!ecModel) {
  29601. return
  29602. }
  29603. ecModel.setUpdatePayload(payload) // clear all visual
  29604. ecModel.eachSeries(function (seriesModel) {
  29605. seriesModel.getData().clearAllVisual()
  29606. }) // Perform visual
  29607. ChartView$1.markUpdateMethod(payload, 'updateVisual')
  29608. clearColorPalette(ecModel) // Keep pipe to the exist pipeline because it depends on the render task of the full pipeline.
  29609. this._scheduler.performVisualTasks(ecModel, payload, {
  29610. visualType: 'visual',
  29611. setDirty: true
  29612. })
  29613. ecModel.eachComponent(function (
  29614. componentType,
  29615. componentModel
  29616. ) {
  29617. if (componentType !== 'series') {
  29618. var componentView =
  29619. _this.getViewOfComponentModel(componentModel)
  29620. componentView &&
  29621. componentView.__alive &&
  29622. componentView.updateVisual(
  29623. componentModel,
  29624. ecModel,
  29625. _this._api,
  29626. payload
  29627. )
  29628. }
  29629. })
  29630. ecModel.eachSeries(function (seriesModel) {
  29631. var chartView = _this._chartsMap[seriesModel.__viewId]
  29632. chartView.updateVisual(
  29633. seriesModel,
  29634. ecModel,
  29635. _this._api,
  29636. payload
  29637. )
  29638. })
  29639. lifecycle$1.trigger('afterupdate', ecModel, this._api)
  29640. },
  29641. updateLayout: function updateLayout(payload) {
  29642. updateMethods.update.call(this, payload)
  29643. }
  29644. }
  29645. doConvertPixel = function doConvertPixel(
  29646. ecIns,
  29647. methodName,
  29648. finder,
  29649. value
  29650. ) {
  29651. if (ecIns._disposed) {
  29652. disposedWarning(ecIns.id)
  29653. return
  29654. }
  29655. var ecModel = ecIns._model
  29656. var coordSysList = ecIns._coordSysMgr.getCoordinateSystems()
  29657. var result
  29658. var parsedFinder = parseFinder$1(ecModel, finder)
  29659. for (var i = 0; i < coordSysList.length; i++) {
  29660. var coordSys = coordSysList[i]
  29661. if (
  29662. coordSys[methodName] &&
  29663. (result = coordSys[methodName](
  29664. ecModel,
  29665. parsedFinder,
  29666. value
  29667. )) != null
  29668. ) {
  29669. return result
  29670. }
  29671. }
  29672. }
  29673. updateStreamModes = function updateStreamModes(ecIns, ecModel) {
  29674. var chartsMap = ecIns._chartsMap
  29675. var scheduler = ecIns._scheduler
  29676. ecModel.eachSeries(function (seriesModel) {
  29677. scheduler.updateStreamModes(
  29678. seriesModel,
  29679. chartsMap[seriesModel.__viewId]
  29680. )
  29681. })
  29682. }
  29683. doDispatchAction = function doDispatchAction(payload, silent) {
  29684. var _this = this
  29685. var ecModel = this.getModel()
  29686. var payloadType = payload.type
  29687. var escapeConnect = payload.escapeConnect
  29688. var actionWrap = actions[payloadType]
  29689. var actionInfo = actionWrap.actionInfo
  29690. var cptTypeTmp = (actionInfo.update || 'update').split(':')
  29691. var updateMethod = cptTypeTmp.pop()
  29692. var cptType =
  29693. cptTypeTmp[0] != null && parseClassType(cptTypeTmp[0])
  29694. this[IN_MAIN_PROCESS_KEY] = true
  29695. var payloads = [payload]
  29696. var batched = false // Batch action
  29697. if (payload.batch) {
  29698. batched = true
  29699. payloads = map$1(payload.batch, function (item) {
  29700. item = defaults(extend({}, item), payload)
  29701. item.batch = null
  29702. return item
  29703. })
  29704. }
  29705. var eventObjBatch = []
  29706. var eventObj
  29707. var isSelectChange = isSelectChangePayload(payload)
  29708. var isHighDown = isHighDownPayload(payload) // Only leave blur once if there are multiple batches.
  29709. if (isHighDown) {
  29710. allLeaveBlur(this._api)
  29711. }
  29712. each$7(payloads, function (batchItem) {
  29713. // Action can specify the event by return it.
  29714. eventObj = actionWrap.action(
  29715. batchItem,
  29716. _this._model,
  29717. _this._api
  29718. ) // Emit event outside
  29719. eventObj = eventObj || extend({}, batchItem) // Convert type to eventType
  29720. eventObj.type = actionInfo.event || eventObj.type
  29721. eventObjBatch.push(eventObj) // light update does not perform data process, layout and visual.
  29722. if (isHighDown) {
  29723. var _a = preParseFinder(payload),
  29724. queryOptionMap = _a.queryOptionMap,
  29725. mainTypeSpecified = _a.mainTypeSpecified
  29726. var componentMainType = mainTypeSpecified
  29727. ? queryOptionMap.keys()[0]
  29728. : 'series'
  29729. updateDirectly(
  29730. _this,
  29731. updateMethod,
  29732. batchItem,
  29733. componentMainType
  29734. )
  29735. markStatusToUpdate(_this)
  29736. } else if (isSelectChange) {
  29737. // At present `dispatchAction({ type: 'select', ... })` is not supported on components.
  29738. // geo still use 'geoselect'.
  29739. updateDirectly(_this, updateMethod, batchItem, 'series')
  29740. markStatusToUpdate(_this)
  29741. } else if (cptType) {
  29742. updateDirectly(
  29743. _this,
  29744. updateMethod,
  29745. batchItem,
  29746. cptType.main,
  29747. cptType.sub
  29748. )
  29749. }
  29750. })
  29751. if (
  29752. updateMethod !== 'none' &&
  29753. !isHighDown &&
  29754. !isSelectChange &&
  29755. !cptType
  29756. ) {
  29757. try {
  29758. // Still dirty
  29759. if (this[PENDING_UPDATE]) {
  29760. prepare(this)
  29761. updateMethods.update.call(this, payload)
  29762. this[PENDING_UPDATE] = null
  29763. } else {
  29764. updateMethods[updateMethod].call(this, payload)
  29765. }
  29766. } catch (e) {
  29767. this[IN_MAIN_PROCESS_KEY] = false
  29768. throw e
  29769. }
  29770. } // Follow the rule of action batch
  29771. if (batched) {
  29772. eventObj = {
  29773. type: actionInfo.event || payloadType,
  29774. escapeConnect: escapeConnect,
  29775. batch: eventObjBatch
  29776. }
  29777. } else {
  29778. eventObj = eventObjBatch[0]
  29779. }
  29780. this[IN_MAIN_PROCESS_KEY] = false
  29781. if (!silent) {
  29782. var messageCenter = this._messageCenter
  29783. messageCenter.trigger(eventObj.type, eventObj) // Extra triggered 'selectchanged' event
  29784. if (isSelectChange) {
  29785. var newObj = {
  29786. type: 'selectchanged',
  29787. escapeConnect: escapeConnect,
  29788. selected: getAllSelectedIndices(ecModel),
  29789. isFromClick: payload.isFromClick || false,
  29790. fromAction: payload.type,
  29791. fromActionPayload: payload
  29792. }
  29793. messageCenter.trigger(newObj.type, newObj)
  29794. }
  29795. }
  29796. }
  29797. flushPendingActions = function flushPendingActions(silent) {
  29798. var pendingActions = this._pendingActions
  29799. while (pendingActions.length) {
  29800. var payload = pendingActions.shift()
  29801. doDispatchAction.call(this, payload, silent)
  29802. }
  29803. }
  29804. triggerUpdatedEvent = function triggerUpdatedEvent(silent) {
  29805. !silent && this.trigger('updated')
  29806. }
  29807. /**
  29808. * Event `rendered` is triggered when zr
  29809. * rendered. It is useful for realtime
  29810. * snapshot (reflect animation).
  29811. *
  29812. * Event `finished` is triggered when:
  29813. * (1) zrender rendering finished.
  29814. * (2) initial animation finished.
  29815. * (3) progressive rendering finished.
  29816. * (4) no pending action.
  29817. * (5) no delayed setOption needs to be processed.
  29818. */ bindRenderedEvent = function bindRenderedEvent(zr, ecIns) {
  29819. zr.on('rendered', function (params) {
  29820. ecIns.trigger('rendered', params) // The `finished` event should not be triggered repeatly,
  29821. // so it should only be triggered when rendering indeed happend
  29822. // in zrender. (Consider the case that dipatchAction is keep
  29823. // triggering when mouse move).
  29824. if (
  29825. // Although zr is dirty if initial animation is not finished
  29826. // and this checking is called on frame, we also check
  29827. // animation finished for robustness.
  29828. zr.animation.isFinished() &&
  29829. !ecIns[PENDING_UPDATE] &&
  29830. !ecIns._scheduler.unfinished &&
  29831. !ecIns._pendingActions.length
  29832. ) {
  29833. ecIns.trigger('finished')
  29834. }
  29835. })
  29836. }
  29837. bindMouseEvent = function bindMouseEvent(zr, ecIns) {
  29838. zr.on('mouseover', function (e) {
  29839. var el = e.target
  29840. var dispatcher = findEventDispatcher(el, isHighDownDispatcher)
  29841. if (dispatcher) {
  29842. handleGlobalMouseOverForHighDown(dispatcher, e, ecIns._api)
  29843. markStatusToUpdate(ecIns)
  29844. }
  29845. })
  29846. .on('mouseout', function (e) {
  29847. var el = e.target
  29848. var dispatcher = findEventDispatcher(
  29849. el,
  29850. isHighDownDispatcher
  29851. )
  29852. if (dispatcher) {
  29853. handleGlobalMouseOutForHighDown(dispatcher, e, ecIns._api)
  29854. markStatusToUpdate(ecIns)
  29855. }
  29856. })
  29857. .on('click', function (e) {
  29858. var el = e.target
  29859. var dispatcher = findEventDispatcher(
  29860. el,
  29861. function (target) {
  29862. return getECData(target).dataIndex != null
  29863. },
  29864. true
  29865. )
  29866. if (dispatcher) {
  29867. var actionType = dispatcher.selected
  29868. ? 'unselect'
  29869. : 'select'
  29870. var ecData = getECData(dispatcher)
  29871. ecIns._api.dispatchAction({
  29872. type: actionType,
  29873. dataType: ecData.dataType,
  29874. dataIndexInside: ecData.dataIndex,
  29875. seriesIndex: ecData.seriesIndex,
  29876. isFromClick: true
  29877. })
  29878. }
  29879. })
  29880. }
  29881. function clearColorPalette(ecModel) {
  29882. ecModel.clearColorPalette()
  29883. ecModel.eachSeries(function (seriesModel) {
  29884. seriesModel.clearColorPalette()
  29885. })
  29886. }
  29887. function allocateZlevels(ecModel) {
  29888. var componentZLevels = []
  29889. var seriesZLevels = []
  29890. var hasSeperateZLevel = false
  29891. ecModel.eachComponent(function (componentType, componentModel) {
  29892. var zlevel = componentModel.get('zlevel') || 0
  29893. var z = componentModel.get('z') || 0
  29894. var zlevelKey = componentModel.getZLevelKey()
  29895. hasSeperateZLevel = hasSeperateZLevel || !!zlevelKey
  29896. ;(componentType === 'series'
  29897. ? seriesZLevels
  29898. : componentZLevels
  29899. ).push({
  29900. zlevel: zlevel,
  29901. z: z,
  29902. idx: componentModel.componentIndex,
  29903. type: componentType,
  29904. key: zlevelKey
  29905. })
  29906. })
  29907. if (hasSeperateZLevel) {
  29908. // Series after component
  29909. var zLevels = componentZLevels.concat(seriesZLevels)
  29910. var lastSeriesZLevel_1
  29911. var lastSeriesKey_1
  29912. sort(zLevels, function (a, b) {
  29913. if (a.zlevel === b.zlevel) {
  29914. return a.z - b.z
  29915. }
  29916. return a.zlevel - b.zlevel
  29917. })
  29918. each$7(zLevels, function (item) {
  29919. var componentModel = ecModel.getComponent(
  29920. item.type,
  29921. item.idx
  29922. )
  29923. var zlevel = item.zlevel
  29924. var key = item.key
  29925. if (lastSeriesZLevel_1 != null) {
  29926. zlevel = Math.max(lastSeriesZLevel_1, zlevel)
  29927. }
  29928. if (key) {
  29929. if (
  29930. zlevel === lastSeriesZLevel_1 &&
  29931. key !== lastSeriesKey_1
  29932. ) {
  29933. zlevel++
  29934. }
  29935. lastSeriesKey_1 = key
  29936. } else if (lastSeriesKey_1) {
  29937. if (zlevel === lastSeriesZLevel_1) {
  29938. zlevel++
  29939. }
  29940. lastSeriesKey_1 = ''
  29941. }
  29942. lastSeriesZLevel_1 = zlevel
  29943. componentModel.setZLevel(zlevel)
  29944. })
  29945. }
  29946. }
  29947. render = function render(
  29948. ecIns,
  29949. ecModel,
  29950. api,
  29951. payload,
  29952. updateParams
  29953. ) {
  29954. allocateZlevels(ecModel)
  29955. renderComponents(ecIns, ecModel, api, payload, updateParams)
  29956. each$7(ecIns._chartsViews, function (chart) {
  29957. chart.__alive = false
  29958. })
  29959. renderSeries(ecIns, ecModel, api, payload, updateParams) // Remove groups of unrendered charts
  29960. each$7(ecIns._chartsViews, function (chart) {
  29961. if (!chart.__alive) {
  29962. chart.remove(ecModel, api)
  29963. }
  29964. })
  29965. }
  29966. renderComponents = function renderComponents(
  29967. ecIns,
  29968. ecModel,
  29969. api,
  29970. payload,
  29971. updateParams,
  29972. dirtyList
  29973. ) {
  29974. each$7(
  29975. dirtyList || ecIns._componentsViews,
  29976. function (componentView) {
  29977. var componentModel = componentView.__model
  29978. clearStates(componentModel, componentView)
  29979. componentView.render(componentModel, ecModel, api, payload)
  29980. updateZ(componentModel, componentView)
  29981. updateStates(componentModel, componentView)
  29982. }
  29983. )
  29984. }
  29985. /**
  29986. * Render each chart and component
  29987. */ renderSeries = function renderSeries(
  29988. ecIns,
  29989. ecModel,
  29990. api,
  29991. payload,
  29992. updateParams,
  29993. dirtyMap
  29994. ) {
  29995. // Render all charts
  29996. var scheduler = ecIns._scheduler
  29997. updateParams = extend(updateParams || {}, {
  29998. updatedSeries: ecModel.getSeries()
  29999. }) // TODO progressive?
  30000. lifecycle$1.trigger(
  30001. 'series:beforeupdate',
  30002. ecModel,
  30003. api,
  30004. updateParams
  30005. )
  30006. var unfinished = false
  30007. ecModel.eachSeries(function (seriesModel) {
  30008. var chartView = ecIns._chartsMap[seriesModel.__viewId]
  30009. chartView.__alive = true
  30010. var renderTask = chartView.renderTask
  30011. scheduler.updatePayload(renderTask, payload) // TODO states on marker.
  30012. clearStates(seriesModel, chartView)
  30013. if (dirtyMap && dirtyMap.get(seriesModel.uid)) {
  30014. renderTask.dirty()
  30015. }
  30016. if (
  30017. renderTask.perform(scheduler.getPerformArgs(renderTask))
  30018. ) {
  30019. unfinished = true
  30020. }
  30021. chartView.group.silent = !!seriesModel.get('silent') // Should not call markRedraw on group, because it will disable zrender
  30022. // increamental render (alway render from the __startIndex each frame)
  30023. // chartView.group.markRedraw();
  30024. updateBlend(seriesModel, chartView)
  30025. updateSeriesElementSelection(seriesModel)
  30026. })
  30027. scheduler.unfinished = unfinished || scheduler.unfinished
  30028. lifecycle$1.trigger(
  30029. 'series:layoutlabels',
  30030. ecModel,
  30031. api,
  30032. updateParams
  30033. ) // transition after label is layouted.
  30034. lifecycle$1.trigger(
  30035. 'series:transition',
  30036. ecModel,
  30037. api,
  30038. updateParams
  30039. )
  30040. ecModel.eachSeries(function (seriesModel) {
  30041. var chartView = ecIns._chartsMap[seriesModel.__viewId] // Update Z after labels updated. Before applying states.
  30042. updateZ(seriesModel, chartView) // NOTE: Update states after label is updated.
  30043. // label should be in normal status when layouting.
  30044. updateStates(seriesModel, chartView)
  30045. }) // If use hover layer
  30046. updateHoverLayerStatus(ecIns, ecModel)
  30047. lifecycle$1.trigger(
  30048. 'series:afterupdate',
  30049. ecModel,
  30050. api,
  30051. updateParams
  30052. )
  30053. }
  30054. markStatusToUpdate = function markStatusToUpdate(ecIns) {
  30055. ecIns[STATUS_NEEDS_UPDATE_KEY] = true // Wake up zrender if it's sleep. Let it update states in the next frame.
  30056. ecIns.getZr().wakeUp()
  30057. }
  30058. applyChangedStates = function applyChangedStates(ecIns) {
  30059. if (!ecIns[STATUS_NEEDS_UPDATE_KEY]) {
  30060. return
  30061. }
  30062. ecIns.getZr().storage.traverse(function (el) {
  30063. // Not applied on removed elements, it may still in fading.
  30064. if (isElementRemoved(el)) {
  30065. return
  30066. }
  30067. applyElementStates(el)
  30068. })
  30069. ecIns[STATUS_NEEDS_UPDATE_KEY] = false
  30070. }
  30071. function applyElementStates(el) {
  30072. var newStates = []
  30073. var oldStates = el.currentStates // Keep other states.
  30074. for (var i = 0; i < oldStates.length; i++) {
  30075. var stateName = oldStates[i]
  30076. if (
  30077. !(
  30078. stateName === 'emphasis' ||
  30079. stateName === 'blur' ||
  30080. stateName === 'select'
  30081. )
  30082. ) {
  30083. newStates.push(stateName)
  30084. }
  30085. } // Only use states when it's exists.
  30086. if (el.selected && el.states.select) {
  30087. newStates.push('select')
  30088. }
  30089. if (
  30090. el.hoverState === HOVER_STATE_EMPHASIS &&
  30091. el.states.emphasis
  30092. ) {
  30093. newStates.push('emphasis')
  30094. } else if (
  30095. el.hoverState === HOVER_STATE_BLUR &&
  30096. el.states.blur
  30097. ) {
  30098. newStates.push('blur')
  30099. }
  30100. el.useStates(newStates)
  30101. }
  30102. function updateHoverLayerStatus(ecIns, ecModel) {
  30103. var zr = ecIns._zr
  30104. var storage = zr.storage
  30105. var elCount = 0
  30106. storage.traverse(function (el) {
  30107. if (!el.isGroup) {
  30108. elCount++
  30109. }
  30110. })
  30111. if (
  30112. elCount > ecModel.get('hoverLayerThreshold') &&
  30113. !env$1.node &&
  30114. !env$1.worker
  30115. ) {
  30116. ecModel.eachSeries(function (seriesModel) {
  30117. if (seriesModel.preventUsingHoverLayer) {
  30118. return
  30119. }
  30120. var chartView = ecIns._chartsMap[seriesModel.__viewId]
  30121. if (chartView.__alive) {
  30122. chartView.eachRendered(function (el) {
  30123. if (el.states.emphasis) {
  30124. el.states.emphasis.hoverLayer = true
  30125. }
  30126. })
  30127. }
  30128. })
  30129. }
  30130. }
  30131. /**
  30132. * Update chart and blend.
  30133. */ function updateBlend(seriesModel, chartView) {
  30134. var blendMode = seriesModel.get('blendMode') || null
  30135. chartView.eachRendered(function (el) {
  30136. // FIXME marker and other components
  30137. if (!el.isGroup) {
  30138. // DONT mark the element dirty. In case element is incremental and don't wan't to rerender.
  30139. el.style.blend = blendMode
  30140. }
  30141. })
  30142. }
  30143. function updateZ(model, view) {
  30144. if (model.preventAutoZ) {
  30145. return
  30146. }
  30147. var z = model.get('z') || 0
  30148. var zlevel = model.get('zlevel') || 0 // Set z and zlevel
  30149. view.eachRendered(function (el) {
  30150. doUpdateZ(el, z, zlevel, -Infinity) // Don't traverse the children because it has been traversed in _updateZ.
  30151. return true
  30152. })
  30153. }
  30154. function doUpdateZ(el, z, zlevel, maxZ2) {
  30155. // Group may also have textContent
  30156. var label = el.getTextContent()
  30157. var labelLine = el.getTextGuideLine()
  30158. var isGroup = el.isGroup
  30159. if (isGroup) {
  30160. // set z & zlevel of children elements of Group
  30161. var children = el.childrenRef()
  30162. for (var i = 0; i < children.length; i++) {
  30163. maxZ2 = Math.max(
  30164. doUpdateZ(children[i], z, zlevel, maxZ2),
  30165. maxZ2
  30166. )
  30167. }
  30168. } else {
  30169. // not Group
  30170. el.z = z
  30171. el.zlevel = zlevel
  30172. maxZ2 = Math.max(el.z2, maxZ2)
  30173. } // always set z and zlevel if label/labelLine exists
  30174. if (label) {
  30175. label.z = z
  30176. label.zlevel = zlevel // lift z2 of text content
  30177. // TODO if el.emphasis.z2 is spcefied, what about textContent.
  30178. isFinite(maxZ2) && (label.z2 = maxZ2 + 2)
  30179. }
  30180. if (labelLine) {
  30181. var textGuideLineConfig = el.textGuideLineConfig
  30182. labelLine.z = z
  30183. labelLine.zlevel = zlevel
  30184. isFinite(maxZ2) &&
  30185. (labelLine.z2 =
  30186. maxZ2 +
  30187. (textGuideLineConfig && textGuideLineConfig.showAbove
  30188. ? 1
  30189. : -1))
  30190. }
  30191. return maxZ2
  30192. } // Clear states without animation.
  30193. // TODO States on component.
  30194. function clearStates(model, view) {
  30195. view.eachRendered(function (el) {
  30196. // Not applied on removed elements, it may still in fading.
  30197. if (isElementRemoved(el)) {
  30198. return
  30199. }
  30200. var textContent = el.getTextContent()
  30201. var textGuide = el.getTextGuideLine()
  30202. if (el.stateTransition) {
  30203. el.stateTransition = null
  30204. }
  30205. if (textContent && textContent.stateTransition) {
  30206. textContent.stateTransition = null
  30207. }
  30208. if (textGuide && textGuide.stateTransition) {
  30209. textGuide.stateTransition = null
  30210. } // TODO If el is incremental.
  30211. if (el.hasState()) {
  30212. el.prevStates = el.currentStates
  30213. el.clearStates()
  30214. } else if (el.prevStates) {
  30215. el.prevStates = null
  30216. }
  30217. })
  30218. }
  30219. function updateStates(model, view) {
  30220. var stateAnimationModel = model.getModel('stateAnimation')
  30221. var enableAnimation = model.isAnimationEnabled()
  30222. var duration = stateAnimationModel.get('duration')
  30223. var stateTransition =
  30224. duration > 0
  30225. ? {
  30226. duration: duration,
  30227. delay: stateAnimationModel.get('delay'),
  30228. easing: stateAnimationModel.get('easing') // additive: stateAnimationModel.get('additive')
  30229. }
  30230. : null
  30231. view.eachRendered(function (el) {
  30232. if (el.states && el.states.emphasis) {
  30233. // Not applied on removed elements, it may still in fading.
  30234. if (isElementRemoved(el)) {
  30235. return
  30236. }
  30237. if (el instanceof Path$1) {
  30238. savePathStates(el)
  30239. } // Only updated on changed element. In case element is incremental and don't wan't to rerender.
  30240. // TODO, a more proper way?
  30241. if (el.__dirty) {
  30242. var prevStates = el.prevStates // Restore states without animation
  30243. if (prevStates) {
  30244. el.useStates(prevStates)
  30245. }
  30246. } // Update state transition and enable animation again.
  30247. if (enableAnimation) {
  30248. el.stateTransition = stateTransition
  30249. var textContent = el.getTextContent()
  30250. var textGuide = el.getTextGuideLine() // TODO Is it necessary to animate label?
  30251. if (textContent) {
  30252. textContent.stateTransition = stateTransition
  30253. }
  30254. if (textGuide) {
  30255. textGuide.stateTransition = stateTransition
  30256. }
  30257. } // The use higlighted and selected flag to toggle states.
  30258. if (el.__dirty) {
  30259. applyElementStates(el)
  30260. }
  30261. }
  30262. })
  30263. }
  30264. createExtensionAPI = function createExtensionAPI(ecIns) {
  30265. return new /** @class */ ((function (_super) {
  30266. __extends(class_1, _super)
  30267. function class_1() {
  30268. return (
  30269. (_super !== null && _super.apply(this, arguments)) || this
  30270. )
  30271. }
  30272. class_1.prototype.getCoordinateSystems = function () {
  30273. return ecIns._coordSysMgr.getCoordinateSystems()
  30274. }
  30275. class_1.prototype.getComponentByElement = function (el) {
  30276. while (el) {
  30277. var modelInfo = el.__ecComponentInfo
  30278. if (modelInfo != null) {
  30279. return ecIns._model.getComponent(
  30280. modelInfo.mainType,
  30281. modelInfo.index
  30282. )
  30283. }
  30284. el = el.parent
  30285. }
  30286. }
  30287. class_1.prototype.enterEmphasis = function (
  30288. el,
  30289. highlightDigit
  30290. ) {
  30291. enterEmphasis(el, highlightDigit)
  30292. markStatusToUpdate(ecIns)
  30293. }
  30294. class_1.prototype.leaveEmphasis = function (
  30295. el,
  30296. highlightDigit
  30297. ) {
  30298. leaveEmphasis(el, highlightDigit)
  30299. markStatusToUpdate(ecIns)
  30300. }
  30301. class_1.prototype.enterBlur = function (el) {
  30302. enterBlur(el)
  30303. markStatusToUpdate(ecIns)
  30304. }
  30305. class_1.prototype.leaveBlur = function (el) {
  30306. leaveBlur(el)
  30307. markStatusToUpdate(ecIns)
  30308. }
  30309. class_1.prototype.enterSelect = function (el) {
  30310. enterSelect(el)
  30311. markStatusToUpdate(ecIns)
  30312. }
  30313. class_1.prototype.leaveSelect = function (el) {
  30314. leaveSelect(el)
  30315. markStatusToUpdate(ecIns)
  30316. }
  30317. class_1.prototype.getModel = function () {
  30318. return ecIns.getModel()
  30319. }
  30320. class_1.prototype.getViewOfComponentModel = function (
  30321. componentModel
  30322. ) {
  30323. return ecIns.getViewOfComponentModel(componentModel)
  30324. }
  30325. class_1.prototype.getViewOfSeriesModel = function (
  30326. seriesModel
  30327. ) {
  30328. return ecIns.getViewOfSeriesModel(seriesModel)
  30329. }
  30330. return class_1
  30331. })(ExtensionAPI$1))(ecIns)
  30332. }
  30333. enableConnect = function enableConnect(chart) {
  30334. function updateConnectedChartsStatus(charts, status) {
  30335. for (var i = 0; i < charts.length; i++) {
  30336. var otherChart = charts[i]
  30337. otherChart[CONNECT_STATUS_KEY] = status
  30338. }
  30339. }
  30340. each$7(eventActionMap, function (actionType, eventType) {
  30341. chart._messageCenter.on(eventType, function (event) {
  30342. if (
  30343. connectedGroups[chart.group] &&
  30344. chart[CONNECT_STATUS_KEY] !== CONNECT_STATUS_PENDING
  30345. ) {
  30346. if (event && event.escapeConnect) {
  30347. return
  30348. }
  30349. var action_1 = chart.makeActionFromEvent(event)
  30350. var otherCharts_1 = []
  30351. each$7(instances, function (otherChart) {
  30352. if (
  30353. otherChart !== chart &&
  30354. otherChart.group === chart.group
  30355. ) {
  30356. otherCharts_1.push(otherChart)
  30357. }
  30358. })
  30359. updateConnectedChartsStatus(
  30360. otherCharts_1,
  30361. CONNECT_STATUS_PENDING
  30362. )
  30363. each$7(otherCharts_1, function (otherChart) {
  30364. if (
  30365. otherChart[CONNECT_STATUS_KEY] !==
  30366. CONNECT_STATUS_UPDATING
  30367. ) {
  30368. otherChart.dispatchAction(action_1)
  30369. }
  30370. })
  30371. updateConnectedChartsStatus(
  30372. otherCharts_1,
  30373. CONNECT_STATUS_UPDATED
  30374. )
  30375. }
  30376. })
  30377. })
  30378. }
  30379. })()
  30380. return ECharts
  30381. })(Eventful$1)
  30382. var echartsProto = ECharts.prototype
  30383. echartsProto.on = createRegisterEventWithLowercaseECharts('on')
  30384. echartsProto.off = createRegisterEventWithLowercaseECharts('off')
  30385. /**
  30386. * @deprecated
  30387. */ // @ts-ignore
  30388. echartsProto.one = function (eventName, cb, ctx) {
  30389. var self = this
  30390. function wrapped() {
  30391. var args2 = []
  30392. for (var _i = 0; _i < arguments.length; _i++) {
  30393. args2[_i] = arguments[_i]
  30394. }
  30395. cb && cb.apply && cb.apply(this, args2) // @ts-ignore
  30396. self.off(eventName, wrapped)
  30397. }
  30398. this.on.call(this, eventName, wrapped, ctx)
  30399. }
  30400. var MOUSE_EVENT_NAMES = [
  30401. 'click',
  30402. 'dblclick',
  30403. 'mouseover',
  30404. 'mouseout',
  30405. 'mousemove',
  30406. 'mousedown',
  30407. 'mouseup',
  30408. 'globalout',
  30409. 'contextmenu'
  30410. ]
  30411. function disposedWarning(id) {}
  30412. var actions = {}
  30413. /**
  30414. * Map eventType to actionType
  30415. */ var eventActionMap = {}
  30416. var dataProcessorFuncs = []
  30417. var optionPreprocessorFuncs = []
  30418. var visualFuncs = []
  30419. var themeStorage = {}
  30420. var loadingEffects = {}
  30421. var instances = {}
  30422. var connectedGroups = {}
  30423. var idBase = +new Date() - 0
  30424. var DOM_ATTRIBUTE_KEY = '_echarts_instance_'
  30425. /**
  30426. * @param opts.devicePixelRatio Use window.devicePixelRatio by default
  30427. * @param opts.renderer Can choose 'canvas' or 'svg' to render the chart.
  30428. * @param opts.width Use clientWidth of the input `dom` by default.
  30429. * Can be 'auto' (the same as null/undefined)
  30430. * @param opts.height Use clientHeight of the input `dom` by default.
  30431. * Can be 'auto' (the same as null/undefined)
  30432. * @param opts.locale Specify the locale.
  30433. * @param opts.useDirtyRect Enable dirty rectangle rendering or not.
  30434. */ function init(dom, theme, opts) {
  30435. var isClient = !(opts && opts.ssr)
  30436. if (isClient) {
  30437. var existInstance = getInstanceByDom(dom)
  30438. if (existInstance) {
  30439. return existInstance
  30440. }
  30441. }
  30442. var chart = new ECharts(dom, theme, opts)
  30443. chart.id = 'ec_' + idBase++
  30444. instances[chart.id] = chart
  30445. isClient && setAttribute(dom, DOM_ATTRIBUTE_KEY, chart.id)
  30446. enableConnect(chart)
  30447. lifecycle$1.trigger('afterinit', chart)
  30448. return chart
  30449. }
  30450. function getInstanceByDom(dom) {
  30451. return instances[getAttribute(dom, DOM_ATTRIBUTE_KEY)]
  30452. }
  30453. /**
  30454. * Register theme
  30455. */ function registerTheme(name, theme) {
  30456. themeStorage[name] = theme
  30457. }
  30458. /**
  30459. * Register option preprocessor
  30460. */ function registerPreprocessor(preprocessorFunc) {
  30461. if (indexOf(optionPreprocessorFuncs, preprocessorFunc) < 0) {
  30462. optionPreprocessorFuncs.push(preprocessorFunc)
  30463. }
  30464. }
  30465. function registerProcessor(priority, processor) {
  30466. normalizeRegister(
  30467. dataProcessorFuncs,
  30468. priority,
  30469. processor,
  30470. PRIORITY_PROCESSOR_DEFAULT
  30471. )
  30472. }
  30473. /**
  30474. * Register postIniter
  30475. * @param {Function} postInitFunc
  30476. */ function registerPostInit(postInitFunc) {
  30477. registerUpdateLifecycle('afterinit', postInitFunc)
  30478. }
  30479. /**
  30480. * Register postUpdater
  30481. * @param {Function} postUpdateFunc
  30482. */ function registerPostUpdate(postUpdateFunc) {
  30483. registerUpdateLifecycle('afterupdate', postUpdateFunc)
  30484. }
  30485. function registerUpdateLifecycle(name, cb) {
  30486. lifecycle$1.on(name, cb)
  30487. }
  30488. function registerAction(actionInfo, eventName, action) {
  30489. if (isFunction(eventName)) {
  30490. action = eventName
  30491. eventName = ''
  30492. }
  30493. var actionType = isObject$2(actionInfo)
  30494. ? actionInfo.type
  30495. : [actionInfo, (actionInfo = { event: eventName })][0] // Event name is all lowercase
  30496. actionInfo.event = (actionInfo.event || actionType).toLowerCase()
  30497. eventName = actionInfo.event
  30498. if (eventActionMap[eventName]) {
  30499. // Already registered.
  30500. return
  30501. } // Validate action type and event name.
  30502. assert(ACTION_REG.test(actionType) && ACTION_REG.test(eventName))
  30503. if (!actions[actionType]) {
  30504. actions[actionType] = { action: action, actionInfo: actionInfo }
  30505. }
  30506. eventActionMap[eventName] = actionType
  30507. }
  30508. function registerCoordinateSystem(type, coordSysCreator) {
  30509. CoordinateSystem.register(type, coordSysCreator)
  30510. }
  30511. function registerLayout(priority, layoutTask) {
  30512. normalizeRegister(
  30513. visualFuncs,
  30514. priority,
  30515. layoutTask,
  30516. PRIORITY_VISUAL_LAYOUT,
  30517. 'layout'
  30518. )
  30519. }
  30520. function registerVisual(priority, visualTask) {
  30521. normalizeRegister(
  30522. visualFuncs,
  30523. priority,
  30524. visualTask,
  30525. PRIORITY_VISUAL_CHART,
  30526. 'visual'
  30527. )
  30528. }
  30529. var registeredTasks = []
  30530. function normalizeRegister(
  30531. targetList,
  30532. priority,
  30533. fn,
  30534. defaultPriority,
  30535. visualType
  30536. ) {
  30537. if (isFunction(priority) || isObject$2(priority)) {
  30538. fn = priority
  30539. priority = defaultPriority
  30540. }
  30541. if (indexOf(registeredTasks, fn) >= 0) {
  30542. return
  30543. }
  30544. registeredTasks.push(fn)
  30545. var stageHandler = Scheduler$1.wrapStageHandler(fn, visualType)
  30546. stageHandler.__prio = priority
  30547. stageHandler.__raw = fn
  30548. targetList.push(stageHandler)
  30549. }
  30550. function registerLoading(name, loadingFx) {
  30551. loadingEffects[name] = loadingFx
  30552. }
  30553. /**
  30554. * The parameters and usage: see `geoSourceManager.registerMap`.
  30555. * Compatible with previous `echarts.registerMap`.
  30556. */ function registerMap(mapName, geoJson, specialAreas) {
  30557. var registerMap = getImpl('registerMap')
  30558. registerMap && registerMap(mapName, geoJson, specialAreas)
  30559. }
  30560. var registerTransform = registerExternalTransform
  30561. /**
  30562. * Globa dispatchAction to a specified chart instance.
  30563. */ // export function dispatchAction(payload: { chartId: string } & Payload, opt?: Parameters<ECharts['dispatchAction']>[1]) {
  30564. // if (!payload || !payload.chartId) {
  30565. // // Must have chartId to find chart
  30566. // return;
  30567. // }
  30568. // const chart = instances[payload.chartId];
  30569. // if (chart) {
  30570. // chart.dispatchAction(payload, opt);
  30571. // }
  30572. // }
  30573. // Buitlin global visual
  30574. registerVisual(PRIORITY_VISUAL_GLOBAL, seriesStyleTask)
  30575. registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataStyleTask)
  30576. registerVisual(
  30577. PRIORITY_VISUAL_CHART_DATA_CUSTOM,
  30578. dataColorPaletteTask
  30579. )
  30580. registerVisual(PRIORITY_VISUAL_GLOBAL, seriesSymbolTask)
  30581. registerVisual(PRIORITY_VISUAL_CHART_DATA_CUSTOM, dataSymbolTask)
  30582. registerVisual(PRIORITY_VISUAL_DECAL, decalVisual)
  30583. registerPreprocessor(globalBackwardCompat)
  30584. registerProcessor(PRIORITY_PROCESSOR_DATASTACK, dataStack)
  30585. registerLoading('default', defaultLoading) // Default actions
  30586. registerAction(
  30587. {
  30588. type: HIGHLIGHT_ACTION_TYPE,
  30589. event: HIGHLIGHT_ACTION_TYPE,
  30590. update: HIGHLIGHT_ACTION_TYPE
  30591. },
  30592. noop
  30593. )
  30594. registerAction(
  30595. {
  30596. type: DOWNPLAY_ACTION_TYPE,
  30597. event: DOWNPLAY_ACTION_TYPE,
  30598. update: DOWNPLAY_ACTION_TYPE
  30599. },
  30600. noop
  30601. )
  30602. registerAction(
  30603. {
  30604. type: SELECT_ACTION_TYPE,
  30605. event: SELECT_ACTION_TYPE,
  30606. update: SELECT_ACTION_TYPE
  30607. },
  30608. noop
  30609. )
  30610. registerAction(
  30611. {
  30612. type: UNSELECT_ACTION_TYPE,
  30613. event: UNSELECT_ACTION_TYPE,
  30614. update: UNSELECT_ACTION_TYPE
  30615. },
  30616. noop
  30617. )
  30618. registerAction(
  30619. {
  30620. type: TOGGLE_SELECT_ACTION_TYPE,
  30621. event: TOGGLE_SELECT_ACTION_TYPE,
  30622. update: TOGGLE_SELECT_ACTION_TYPE
  30623. },
  30624. noop
  30625. ) // Default theme
  30626. registerTheme('light', lightTheme)
  30627. registerTheme('dark', darkTheme) // For backward compatibility, where the namespace `dataTool` will
  30628. /*
  30629. * Licensed to the Apache Software Foundation (ASF) under one
  30630. * or more contributor license agreements. See the NOTICE file
  30631. * distributed with this work for additional information
  30632. * regarding copyright ownership. The ASF licenses this file
  30633. * to you under the Apache License, Version 2.0 (the
  30634. * "License"); you may not use this file except in compliance
  30635. * with the License. You may obtain a copy of the License at
  30636. *
  30637. * http://www.apache.org/licenses/LICENSE-2.0
  30638. *
  30639. * Unless required by applicable law or agreed to in writing,
  30640. * software distributed under the License is distributed on an
  30641. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30642. * KIND, either express or implied. See the License for the
  30643. * specific language governing permissions and limitations
  30644. * under the License.
  30645. */ /**
  30646. * AUTO-GENERATED FILE. DO NOT MODIFY.
  30647. */ /*
  30648. * Licensed to the Apache Software Foundation (ASF) under one
  30649. * or more contributor license agreements. See the NOTICE file
  30650. * distributed with this work for additional information
  30651. * regarding copyright ownership. The ASF licenses this file
  30652. * to you under the Apache License, Version 2.0 (the
  30653. * "License"); you may not use this file except in compliance
  30654. * with the License. You may obtain a copy of the License at
  30655. *
  30656. * http://www.apache.org/licenses/LICENSE-2.0
  30657. *
  30658. * Unless required by applicable law or agreed to in writing,
  30659. * software distributed under the License is distributed on an
  30660. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  30661. * KIND, either express or implied. See the License for the
  30662. * specific language governing permissions and limitations
  30663. * under the License.
  30664. */ function dataIndexMapValueLength(valNumOrArrLengthMoreThan2) {
  30665. return valNumOrArrLengthMoreThan2 == null
  30666. ? 0
  30667. : valNumOrArrLengthMoreThan2.length || 1
  30668. }
  30669. function defaultKeyGetter(item) {
  30670. return item
  30671. }
  30672. var DataDiffer = /** @class */ (function () {
  30673. /**
  30674. * @param context Can be visited by this.context in callback.
  30675. */ function DataDiffer(
  30676. oldArr,
  30677. newArr,
  30678. oldKeyGetter,
  30679. newKeyGetter,
  30680. context, // By default: 'oneToOne'.
  30681. diffMode
  30682. ) {
  30683. this._old = oldArr
  30684. this._new = newArr
  30685. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter
  30686. this._newKeyGetter = newKeyGetter || defaultKeyGetter // Visible in callback via `this.context`;
  30687. this.context = context
  30688. this._diffModeMultiple = diffMode === 'multiple'
  30689. }
  30690. /**
  30691. * Callback function when add a data
  30692. */ DataDiffer.prototype.add = function (func) {
  30693. this._add = func
  30694. return this
  30695. }
  30696. /**
  30697. * Callback function when update a data
  30698. */ DataDiffer.prototype.update = function (func) {
  30699. this._update = func
  30700. return this
  30701. }
  30702. /**
  30703. * Callback function when update a data and only work in `cbMode: 'byKey'`.
  30704. */ DataDiffer.prototype.updateManyToOne = function (func) {
  30705. this._updateManyToOne = func
  30706. return this
  30707. }
  30708. /**
  30709. * Callback function when update a data and only work in `cbMode: 'byKey'`.
  30710. */ DataDiffer.prototype.updateOneToMany = function (func) {
  30711. this._updateOneToMany = func
  30712. return this
  30713. }
  30714. /**
  30715. * Callback function when update a data and only work in `cbMode: 'byKey'`.
  30716. */ DataDiffer.prototype.updateManyToMany = function (func) {
  30717. this._updateManyToMany = func
  30718. return this
  30719. }
  30720. /**
  30721. * Callback function when remove a data
  30722. */ DataDiffer.prototype.remove = function (func) {
  30723. this._remove = func
  30724. return this
  30725. }
  30726. DataDiffer.prototype.execute = function () {
  30727. this[
  30728. this._diffModeMultiple ? '_executeMultiple' : '_executeOneToOne'
  30729. ]()
  30730. }
  30731. DataDiffer.prototype._executeOneToOne = function () {
  30732. var oldArr = this._old
  30733. var newArr = this._new
  30734. var newDataIndexMap = {}
  30735. var oldDataKeyArr = new Array(oldArr.length)
  30736. var newDataKeyArr = new Array(newArr.length)
  30737. this._initIndexMap(oldArr, null, oldDataKeyArr, '_oldKeyGetter')
  30738. this._initIndexMap(
  30739. newArr,
  30740. newDataIndexMap,
  30741. newDataKeyArr,
  30742. '_newKeyGetter'
  30743. )
  30744. for (var i = 0; i < oldArr.length; i++) {
  30745. var oldKey = oldDataKeyArr[i]
  30746. var newIdxMapVal = newDataIndexMap[oldKey]
  30747. var newIdxMapValLen = dataIndexMapValueLength(newIdxMapVal) // idx can never be empty array here. see 'set null' logic below.
  30748. if (newIdxMapValLen > 1) {
  30749. // Consider there is duplicate key (for example, use dataItem.name as key).
  30750. // We should make sure every item in newArr and oldArr can be visited.
  30751. var newIdx = newIdxMapVal.shift()
  30752. if (newIdxMapVal.length === 1) {
  30753. newDataIndexMap[oldKey] = newIdxMapVal[0]
  30754. }
  30755. this._update && this._update(newIdx, i)
  30756. } else if (newIdxMapValLen === 1) {
  30757. newDataIndexMap[oldKey] = null
  30758. this._update && this._update(newIdxMapVal, i)
  30759. } else {
  30760. this._remove && this._remove(i)
  30761. }
  30762. }
  30763. this._performRestAdd(newDataKeyArr, newDataIndexMap)
  30764. }
  30765. /**
  30766. * For example, consider the case:
  30767. * oldData: [o0, o1, o2, o3, o4, o5, o6, o7],
  30768. * newData: [n0, n1, n2, n3, n4, n5, n6, n7, n8],
  30769. * Where:
  30770. * o0, o1, n0 has key 'a' (many to one)
  30771. * o5, n4, n5, n6 has key 'b' (one to many)
  30772. * o2, n1 has key 'c' (one to one)
  30773. * n2, n3 has key 'd' (add)
  30774. * o3, o4 has key 'e' (remove)
  30775. * o6, o7, n7, n8 has key 'f' (many to many, treated as add and remove)
  30776. * Then:
  30777. * (The order of the following directives are not ensured.)
  30778. * this._updateManyToOne(n0, [o0, o1]);
  30779. * this._updateOneToMany([n4, n5, n6], o5);
  30780. * this._update(n1, o2);
  30781. * this._remove(o3);
  30782. * this._remove(o4);
  30783. * this._remove(o6);
  30784. * this._remove(o7);
  30785. * this._add(n2);
  30786. * this._add(n3);
  30787. * this._add(n7);
  30788. * this._add(n8);
  30789. */ DataDiffer.prototype._executeMultiple = function () {
  30790. var oldArr = this._old
  30791. var newArr = this._new
  30792. var oldDataIndexMap = {}
  30793. var newDataIndexMap = {}
  30794. var oldDataKeyArr = []
  30795. var newDataKeyArr = []
  30796. this._initIndexMap(
  30797. oldArr,
  30798. oldDataIndexMap,
  30799. oldDataKeyArr,
  30800. '_oldKeyGetter'
  30801. )
  30802. this._initIndexMap(
  30803. newArr,
  30804. newDataIndexMap,
  30805. newDataKeyArr,
  30806. '_newKeyGetter'
  30807. )
  30808. for (var i = 0; i < oldDataKeyArr.length; i++) {
  30809. var oldKey = oldDataKeyArr[i]
  30810. var oldIdxMapVal = oldDataIndexMap[oldKey]
  30811. var newIdxMapVal = newDataIndexMap[oldKey]
  30812. var oldIdxMapValLen = dataIndexMapValueLength(oldIdxMapVal)
  30813. var newIdxMapValLen = dataIndexMapValueLength(newIdxMapVal)
  30814. if (oldIdxMapValLen > 1 && newIdxMapValLen === 1) {
  30815. this._updateManyToOne &&
  30816. this._updateManyToOne(newIdxMapVal, oldIdxMapVal)
  30817. newDataIndexMap[oldKey] = null
  30818. } else if (oldIdxMapValLen === 1 && newIdxMapValLen > 1) {
  30819. this._updateOneToMany &&
  30820. this._updateOneToMany(newIdxMapVal, oldIdxMapVal)
  30821. newDataIndexMap[oldKey] = null
  30822. } else if (oldIdxMapValLen === 1 && newIdxMapValLen === 1) {
  30823. this._update && this._update(newIdxMapVal, oldIdxMapVal)
  30824. newDataIndexMap[oldKey] = null
  30825. } else if (oldIdxMapValLen > 1 && newIdxMapValLen > 1) {
  30826. this._updateManyToMany &&
  30827. this._updateManyToMany(newIdxMapVal, oldIdxMapVal)
  30828. newDataIndexMap[oldKey] = null
  30829. } else if (oldIdxMapValLen > 1) {
  30830. for (var i_1 = 0; i_1 < oldIdxMapValLen; i_1++) {
  30831. this._remove && this._remove(oldIdxMapVal[i_1])
  30832. }
  30833. } else {
  30834. this._remove && this._remove(oldIdxMapVal)
  30835. }
  30836. }
  30837. this._performRestAdd(newDataKeyArr, newDataIndexMap)
  30838. }
  30839. DataDiffer.prototype._performRestAdd = function (
  30840. newDataKeyArr,
  30841. newDataIndexMap
  30842. ) {
  30843. for (var i = 0; i < newDataKeyArr.length; i++) {
  30844. var newKey = newDataKeyArr[i]
  30845. var newIdxMapVal = newDataIndexMap[newKey]
  30846. var idxMapValLen = dataIndexMapValueLength(newIdxMapVal)
  30847. if (idxMapValLen > 1) {
  30848. for (var j = 0; j < idxMapValLen; j++) {
  30849. this._add && this._add(newIdxMapVal[j])
  30850. }
  30851. } else if (idxMapValLen === 1) {
  30852. this._add && this._add(newIdxMapVal)
  30853. } // Support both `newDataKeyArr` are duplication removed or not removed.
  30854. newDataIndexMap[newKey] = null
  30855. }
  30856. }
  30857. DataDiffer.prototype._initIndexMap = function (
  30858. arr, // Can be null.
  30859. map, // In 'byKey', the output `keyArr` is duplication removed.
  30860. // In 'byIndex', the output `keyArr` is not duplication removed and
  30861. // its indices are accurately corresponding to `arr`.
  30862. keyArr,
  30863. keyGetterName
  30864. ) {
  30865. var cbModeMultiple = this._diffModeMultiple
  30866. for (var i = 0; i < arr.length; i++) {
  30867. // Add prefix to avoid conflict with Object.prototype.
  30868. var key = '_ec_' + this[keyGetterName](arr[i], i)
  30869. if (!cbModeMultiple) {
  30870. keyArr[i] = key
  30871. }
  30872. if (!map) {
  30873. continue
  30874. }
  30875. var idxMapVal = map[key]
  30876. var idxMapValLen = dataIndexMapValueLength(idxMapVal)
  30877. if (idxMapValLen === 0) {
  30878. // Simple optimize: in most cases, one index has one key,
  30879. // do not need array.
  30880. map[key] = i
  30881. if (cbModeMultiple) {
  30882. keyArr.push(key)
  30883. }
  30884. } else if (idxMapValLen === 1) {
  30885. map[key] = [idxMapVal, i]
  30886. } else {
  30887. idxMapVal.push(i)
  30888. }
  30889. }
  30890. }
  30891. return DataDiffer
  30892. })()
  30893. var DataDiffer$1 = DataDiffer
  30894. var DimensionUserOuput = /** @class */ (function () {
  30895. function DimensionUserOuput(encode, dimRequest) {
  30896. this._encode = encode
  30897. this._schema = dimRequest
  30898. }
  30899. DimensionUserOuput.prototype.get = function () {
  30900. return {
  30901. // Do not generate full dimension name until fist used.
  30902. fullDimensions: this._getFullDimensionNames(),
  30903. encode: this._encode
  30904. }
  30905. }
  30906. /**
  30907. * Get all data store dimension names.
  30908. * Theoretically a series data store is defined both by series and used dataset (if any).
  30909. * If some dimensions are omitted for performance reason in `this.dimensions`,
  30910. * the dimension name may not be auto-generated if user does not specify a dimension name.
  30911. * In this case, the dimension name is `null`/`undefined`.
  30912. */ DimensionUserOuput.prototype._getFullDimensionNames =
  30913. function () {
  30914. if (!this._cachedDimNames) {
  30915. this._cachedDimNames = this._schema
  30916. ? this._schema.makeOutputDimensionNames()
  30917. : []
  30918. }
  30919. return this._cachedDimNames
  30920. }
  30921. return DimensionUserOuput
  30922. })()
  30923. function summarizeDimensions(data, schema) {
  30924. var summary = {}
  30925. var encode = (summary.encode = {})
  30926. var notExtraCoordDimMap = createHashMap()
  30927. var defaultedLabel = []
  30928. var defaultedTooltip = []
  30929. var userOutputEncode = {}
  30930. each$7(data.dimensions, function (dimName) {
  30931. var dimItem = data.getDimensionInfo(dimName)
  30932. var coordDim = dimItem.coordDim
  30933. if (coordDim) {
  30934. var coordDimIndex = dimItem.coordDimIndex
  30935. getOrCreateEncodeArr(encode, coordDim)[coordDimIndex] = dimName
  30936. if (!dimItem.isExtraCoord) {
  30937. notExtraCoordDimMap.set(coordDim, 1) // Use the last coord dim (and label friendly) as default label,
  30938. // because when dataset is used, it is hard to guess which dimension
  30939. // can be value dimension. If both show x, y on label is not look good,
  30940. // and conventionally y axis is focused more.
  30941. if (mayLabelDimType(dimItem.type)) {
  30942. defaultedLabel[0] = dimName
  30943. } // User output encode do not contain generated coords.
  30944. // And it only has index. User can use index to retrieve value from the raw item array.
  30945. getOrCreateEncodeArr(userOutputEncode, coordDim)[
  30946. coordDimIndex
  30947. ] = data.getDimensionIndex(dimItem.name)
  30948. }
  30949. if (dimItem.defaultTooltip) {
  30950. defaultedTooltip.push(dimName)
  30951. }
  30952. }
  30953. VISUAL_DIMENSIONS.each(function (v, otherDim) {
  30954. var encodeArr = getOrCreateEncodeArr(encode, otherDim)
  30955. var dimIndex = dimItem.otherDims[otherDim]
  30956. if (dimIndex != null && dimIndex !== false) {
  30957. encodeArr[dimIndex] = dimItem.name
  30958. }
  30959. })
  30960. })
  30961. var dataDimsOnCoord = []
  30962. var encodeFirstDimNotExtra = {}
  30963. notExtraCoordDimMap.each(function (v, coordDim) {
  30964. var dimArr = encode[coordDim]
  30965. encodeFirstDimNotExtra[coordDim] = dimArr[0] // Not necessary to remove duplicate, because a data
  30966. // dim canot on more than one coordDim.
  30967. dataDimsOnCoord = dataDimsOnCoord.concat(dimArr)
  30968. })
  30969. summary.dataDimsOnCoord = dataDimsOnCoord
  30970. summary.dataDimIndicesOnCoord = map$1(
  30971. dataDimsOnCoord,
  30972. function (dimName) {
  30973. return data.getDimensionInfo(dimName).storeDimIndex
  30974. }
  30975. )
  30976. summary.encodeFirstDimNotExtra = encodeFirstDimNotExtra
  30977. var encodeLabel = encode.label // FIXME `encode.label` is not recommanded, because formatter can not be set
  30978. // in this way. Use label.formatter instead. May be remove this approach someday.
  30979. if (encodeLabel && encodeLabel.length) {
  30980. defaultedLabel = encodeLabel.slice()
  30981. }
  30982. var encodeTooltip = encode.tooltip
  30983. if (encodeTooltip && encodeTooltip.length) {
  30984. defaultedTooltip = encodeTooltip.slice()
  30985. } else if (!defaultedTooltip.length) {
  30986. defaultedTooltip = defaultedLabel.slice()
  30987. }
  30988. encode.defaultedLabel = defaultedLabel
  30989. encode.defaultedTooltip = defaultedTooltip
  30990. summary.userOutput = new DimensionUserOuput(
  30991. userOutputEncode,
  30992. schema
  30993. )
  30994. return summary
  30995. }
  30996. function getOrCreateEncodeArr(encode, dim) {
  30997. if (!encode.hasOwnProperty(dim)) {
  30998. encode[dim] = []
  30999. }
  31000. return encode[dim]
  31001. } // FIXME:TS should be type `AxisType`
  31002. function getDimensionTypeByAxis(axisType) {
  31003. return axisType === 'category'
  31004. ? 'ordinal'
  31005. : axisType === 'time'
  31006. ? 'time'
  31007. : 'float'
  31008. }
  31009. function mayLabelDimType(dimType) {
  31010. // In most cases, ordinal and time do not suitable for label.
  31011. // Ordinal info can be displayed on axis. Time is too long.
  31012. return !(dimType === 'ordinal' || dimType === 'time')
  31013. } // function findTheLastDimMayLabel(data) {
  31014. // // Get last value dim
  31015. // let dimensions = data.dimensions.slice();
  31016. // let valueType;
  31017. // let valueDim;
  31018. // while (dimensions.length && (
  31019. // valueDim = dimensions.pop(),
  31020. // valueType = data.getDimensionInfo(valueDim).type,
  31021. // valueType === 'ordinal' || valueType === 'time'
  31022. // )) {} // jshint ignore:line
  31023. // return valueDim;
  31024. // }
  31025. var SeriesDimensionDefine = /** @class */ (function () {
  31026. /**
  31027. * @param opt All of the fields will be shallow copied.
  31028. */ function SeriesDimensionDefine(opt) {
  31029. /**
  31030. * The format of `otherDims` is:
  31031. * ```js
  31032. * {
  31033. * tooltip?: number
  31034. * label?: number
  31035. * itemName?: number
  31036. * seriesName?: number
  31037. * }
  31038. * ```
  31039. *
  31040. * A `series.encode` can specified these fields:
  31041. * ```js
  31042. * encode: {
  31043. * // "3, 1, 5" is the index of data dimension.
  31044. * tooltip: [3, 1, 5],
  31045. * label: [0, 3],
  31046. * ...
  31047. * }
  31048. * ```
  31049. * `otherDims` is the parse result of the `series.encode` above, like:
  31050. * ```js
  31051. * // Suppose the index of this data dimension is `3`.
  31052. * this.otherDims = {
  31053. * // `3` is at the index `0` of the `encode.tooltip`
  31054. * tooltip: 0,
  31055. * // `3` is at the index `1` of the `encode.label`
  31056. * label: 1
  31057. * };
  31058. * ```
  31059. *
  31060. * This prop should never be `null`/`undefined` after initialized.
  31061. */ this.otherDims = {}
  31062. if (opt != null) {
  31063. extend(this, opt)
  31064. }
  31065. }
  31066. return SeriesDimensionDefine
  31067. })()
  31068. var SeriesDimensionDefine$1 = SeriesDimensionDefine
  31069. var inner$7 = makeInner()
  31070. var dimTypeShort = {
  31071. float: 'f',
  31072. int: 'i',
  31073. ordinal: 'o',
  31074. number: 'n',
  31075. time: 't'
  31076. }
  31077. /**
  31078. * Represents the dimension requirement of a series.
  31079. *
  31080. * NOTICE:
  31081. * When there are too many dimensions in dataset and many series, only the used dimensions
  31082. * (i.e., used by coord sys and declared in `series.encode`) are add to `dimensionDefineList`.
  31083. * But users may query data by other unused dimension names.
  31084. * In this case, users can only query data if and only if they have defined dimension names
  31085. * via ec option, so we provide `getDimensionIndexFromSource`, which only query them from
  31086. * `source` dimensions.
  31087. */ var SeriesDataSchema = /** @class */ (function () {
  31088. function SeriesDataSchema(opt) {
  31089. this.dimensions = opt.dimensions
  31090. this._dimOmitted = opt.dimensionOmitted
  31091. this.source = opt.source
  31092. this._fullDimCount = opt.fullDimensionCount
  31093. this._updateDimOmitted(opt.dimensionOmitted)
  31094. }
  31095. SeriesDataSchema.prototype.isDimensionOmitted = function () {
  31096. return this._dimOmitted
  31097. }
  31098. SeriesDataSchema.prototype._updateDimOmitted = function (
  31099. dimensionOmitted
  31100. ) {
  31101. this._dimOmitted = dimensionOmitted
  31102. if (!dimensionOmitted) {
  31103. return
  31104. }
  31105. if (!this._dimNameMap) {
  31106. this._dimNameMap = ensureSourceDimNameMap(this.source)
  31107. }
  31108. }
  31109. /**
  31110. * @caution Can only be used when `dimensionOmitted: true`.
  31111. *
  31112. * Get index by user defined dimension name (i.e., not internal generate name).
  31113. * That is, get index from `dimensionsDefine`.
  31114. * If no `dimensionsDefine`, or no name get, return -1.
  31115. */ SeriesDataSchema.prototype.getSourceDimensionIndex = function (
  31116. dimName
  31117. ) {
  31118. return retrieve2(this._dimNameMap.get(dimName), -1)
  31119. }
  31120. /**
  31121. * @caution Can only be used when `dimensionOmitted: true`.
  31122. *
  31123. * Notice: may return `null`/`undefined` if user not specify dimension names.
  31124. */ SeriesDataSchema.prototype.getSourceDimension = function (
  31125. dimIndex
  31126. ) {
  31127. var dimensionsDefine = this.source.dimensionsDefine
  31128. if (dimensionsDefine) {
  31129. return dimensionsDefine[dimIndex]
  31130. }
  31131. }
  31132. SeriesDataSchema.prototype.makeStoreSchema = function () {
  31133. var dimCount = this._fullDimCount
  31134. var willRetrieveDataByName = shouldRetrieveDataByName(this.source)
  31135. var makeHashStrict = !shouldOmitUnusedDimensions(dimCount) // If source don't have dimensions or series don't omit unsed dimensions.
  31136. // Generate from seriesDimList directly
  31137. var dimHash = ''
  31138. var dims = []
  31139. for (
  31140. var fullDimIdx = 0, seriesDimIdx = 0;
  31141. fullDimIdx < dimCount;
  31142. fullDimIdx++
  31143. ) {
  31144. var property = void 0
  31145. var type = void 0
  31146. var ordinalMeta = void 0
  31147. var seriesDimDef = this.dimensions[seriesDimIdx] // The list has been sorted by `storeDimIndex` asc.
  31148. if (seriesDimDef && seriesDimDef.storeDimIndex === fullDimIdx) {
  31149. property = willRetrieveDataByName ? seriesDimDef.name : null
  31150. type = seriesDimDef.type
  31151. ordinalMeta = seriesDimDef.ordinalMeta
  31152. seriesDimIdx++
  31153. } else {
  31154. var sourceDimDef = this.getSourceDimension(fullDimIdx)
  31155. if (sourceDimDef) {
  31156. property = willRetrieveDataByName ? sourceDimDef.name : null
  31157. type = sourceDimDef.type
  31158. }
  31159. }
  31160. dims.push({
  31161. property: property,
  31162. type: type,
  31163. ordinalMeta: ordinalMeta
  31164. }) // If retrieving data by index,
  31165. // use <index, type, ordinalMeta> to determine whether data can be shared.
  31166. // (Becuase in this case there might be no dimension name defined in dataset, but indices always exists).
  31167. // (indices are always 0, 1, 2, ..., so we can ignore them to shorten the hash).
  31168. // Otherwise if retrieving data by property name (like `data: [{aa: 123, bb: 765}, ...]`),
  31169. // use <property, type, ordinalMeta> in hash.
  31170. if (
  31171. willRetrieveDataByName &&
  31172. property != null && // For data stack, we have make sure each series has its own dim on this store.
  31173. // So we do not add property to hash to make sure they can share this store.
  31174. (!seriesDimDef || !seriesDimDef.isCalculationCoord)
  31175. ) {
  31176. dimHash += makeHashStrict // Use escape character '`' in case that property name contains '$'.
  31177. ? property.replace(/\`/g, '`1').replace(/\$/g, '`2') // For better performance, when there are large dimensions, tolerant this defects that hardly meet.
  31178. : property
  31179. }
  31180. dimHash += '$'
  31181. dimHash += dimTypeShort[type] || 'f'
  31182. if (ordinalMeta) {
  31183. dimHash += ordinalMeta.uid
  31184. }
  31185. dimHash += '$'
  31186. } // Source from endpoint(usually series) will be read differently
  31187. // when seriesLayoutBy or startIndex(which is affected by sourceHeader) are different.
  31188. // So we use this three props as key.
  31189. var source = this.source
  31190. var hash = [
  31191. source.seriesLayoutBy,
  31192. source.startIndex,
  31193. dimHash
  31194. ].join('$$')
  31195. return { dimensions: dims, hash: hash }
  31196. }
  31197. SeriesDataSchema.prototype.makeOutputDimensionNames = function () {
  31198. var result = []
  31199. for (
  31200. var fullDimIdx = 0, seriesDimIdx = 0;
  31201. fullDimIdx < this._fullDimCount;
  31202. fullDimIdx++
  31203. ) {
  31204. var name_1 = void 0
  31205. var seriesDimDef = this.dimensions[seriesDimIdx] // The list has been sorted by `storeDimIndex` asc.
  31206. if (seriesDimDef && seriesDimDef.storeDimIndex === fullDimIdx) {
  31207. if (!seriesDimDef.isCalculationCoord) {
  31208. name_1 = seriesDimDef.name
  31209. }
  31210. seriesDimIdx++
  31211. } else {
  31212. var sourceDimDef = this.getSourceDimension(fullDimIdx)
  31213. if (sourceDimDef) {
  31214. name_1 = sourceDimDef.name
  31215. }
  31216. }
  31217. result.push(name_1)
  31218. }
  31219. return result
  31220. }
  31221. SeriesDataSchema.prototype.appendCalculationDimension = function (
  31222. dimDef
  31223. ) {
  31224. this.dimensions.push(dimDef)
  31225. dimDef.isCalculationCoord = true
  31226. this._fullDimCount++ // If append dimension on a data store, consider the store
  31227. // might be shared by different series, series dimensions not
  31228. // really map to store dimensions.
  31229. this._updateDimOmitted(true)
  31230. }
  31231. return SeriesDataSchema
  31232. })()
  31233. function isSeriesDataSchema(schema) {
  31234. return schema instanceof SeriesDataSchema
  31235. }
  31236. function createDimNameMap(dimsDef) {
  31237. var dataDimNameMap = createHashMap()
  31238. for (var i = 0; i < (dimsDef || []).length; i++) {
  31239. var dimDefItemRaw = dimsDef[i]
  31240. var userDimName = isObject$2(dimDefItemRaw)
  31241. ? dimDefItemRaw.name
  31242. : dimDefItemRaw
  31243. if (
  31244. userDimName != null &&
  31245. dataDimNameMap.get(userDimName) == null
  31246. ) {
  31247. dataDimNameMap.set(userDimName, i)
  31248. }
  31249. }
  31250. return dataDimNameMap
  31251. }
  31252. function ensureSourceDimNameMap(source) {
  31253. var innerSource = inner$7(source)
  31254. return (
  31255. innerSource.dimNameMap ||
  31256. (innerSource.dimNameMap = createDimNameMap(
  31257. source.dimensionsDefine
  31258. ))
  31259. )
  31260. }
  31261. function shouldOmitUnusedDimensions(dimCount) {
  31262. return dimCount > 30
  31263. }
  31264. var isObject = isObject$2
  31265. var map = map$1
  31266. var CtorInt32Array =
  31267. typeof Int32Array === 'undefined' ? Array : Int32Array // Use prefix to avoid index to be the same as otherIdList[idx],
  31268. // which will cause weird udpate animation.
  31269. var ID_PREFIX = 'e\0\0'
  31270. var INDEX_NOT_FOUND = -1 // type SeriesDimensionIndex = DimensionIndex;
  31271. var TRANSFERABLE_PROPERTIES = [
  31272. 'hasItemOption',
  31273. '_nameList',
  31274. '_idList',
  31275. '_invertedIndicesMap',
  31276. '_dimSummary',
  31277. 'userOutput',
  31278. '_rawData',
  31279. '_dimValueGetter',
  31280. '_nameDimIdx',
  31281. '_idDimIdx',
  31282. '_nameRepeatCount'
  31283. ]
  31284. var CLONE_PROPERTIES = ['_approximateExtent'] // -----------------------------
  31285. // Internal method declarations:
  31286. // -----------------------------
  31287. var prepareInvertedIndex
  31288. var getId
  31289. var getIdNameFromStore
  31290. var normalizeDimensions
  31291. var transferProperties
  31292. var cloneListForMapAndSample
  31293. var makeIdFromName
  31294. var SeriesData = /** @class */ (function () {
  31295. /**
  31296. * @param dimensionsInput.dimensions
  31297. * For example, ['someDimName', {name: 'someDimName', type: 'someDimType'}, ...].
  31298. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  31299. */ function SeriesData(dimensionsInput, hostModel) {
  31300. this.type = 'list'
  31301. this._dimOmitted = false
  31302. this._nameList = []
  31303. this._idList = [] // Models of data option is stored sparse for optimizing memory cost
  31304. // Never used yet (not used yet).
  31305. // private _optionModels: Model[] = [];
  31306. // Global visual properties after visual coding
  31307. this._visual = {} // Globel layout properties.
  31308. this._layout = {} // Item visual properties after visual coding
  31309. this._itemVisuals = [] // Item layout properties after layout
  31310. this._itemLayouts = [] // Graphic elemnents
  31311. this._graphicEls = [] // key: dim, value: extent
  31312. this._approximateExtent = {}
  31313. this._calculationInfo = {} // Having detected that there is data item is non primitive type
  31314. // (in type `OptionDataItemObject`).
  31315. // Like `data: [ { value: xx, itemStyle: {...} }, ...]`
  31316. // At present it only happen in `SOURCE_FORMAT_ORIGINAL`.
  31317. this.hasItemOption = false // Methods that create a new list based on this list should be listed here.
  31318. // Notice that those method should `RETURN` the new list.
  31319. this.TRANSFERABLE_METHODS = [
  31320. 'cloneShallow',
  31321. 'downSample',
  31322. 'lttbDownSample',
  31323. 'map'
  31324. ] // Methods that change indices of this list should be listed here.
  31325. this.CHANGABLE_METHODS = ['filterSelf', 'selectRange']
  31326. this.DOWNSAMPLE_METHODS = ['downSample', 'lttbDownSample']
  31327. var dimensions
  31328. var assignStoreDimIdx = false
  31329. if (isSeriesDataSchema(dimensionsInput)) {
  31330. dimensions = dimensionsInput.dimensions
  31331. this._dimOmitted = dimensionsInput.isDimensionOmitted()
  31332. this._schema = dimensionsInput
  31333. } else {
  31334. assignStoreDimIdx = true
  31335. dimensions = dimensionsInput
  31336. }
  31337. dimensions = dimensions || ['x', 'y']
  31338. var dimensionInfos = {}
  31339. var dimensionNames = []
  31340. var invertedIndicesMap = {}
  31341. var needsHasOwn = false
  31342. var emptyObj = {}
  31343. for (var i = 0; i < dimensions.length; i++) {
  31344. // Use the original dimensions[i], where other flag props may exists.
  31345. var dimInfoInput = dimensions[i]
  31346. var dimensionInfo = isString(dimInfoInput)
  31347. ? new SeriesDimensionDefine$1({ name: dimInfoInput })
  31348. : !(dimInfoInput instanceof SeriesDimensionDefine$1)
  31349. ? new SeriesDimensionDefine$1(dimInfoInput)
  31350. : dimInfoInput
  31351. var dimensionName = dimensionInfo.name
  31352. dimensionInfo.type = dimensionInfo.type || 'float'
  31353. if (!dimensionInfo.coordDim) {
  31354. dimensionInfo.coordDim = dimensionName
  31355. dimensionInfo.coordDimIndex = 0
  31356. }
  31357. var otherDims = (dimensionInfo.otherDims =
  31358. dimensionInfo.otherDims || {})
  31359. dimensionNames.push(dimensionName)
  31360. dimensionInfos[dimensionName] = dimensionInfo
  31361. if (emptyObj[dimensionName] != null) {
  31362. needsHasOwn = true
  31363. }
  31364. if (dimensionInfo.createInvertedIndices) {
  31365. invertedIndicesMap[dimensionName] = []
  31366. }
  31367. if (otherDims.itemName === 0) {
  31368. this._nameDimIdx = i
  31369. }
  31370. if (otherDims.itemId === 0) {
  31371. this._idDimIdx = i
  31372. }
  31373. if (assignStoreDimIdx) {
  31374. dimensionInfo.storeDimIndex = i
  31375. }
  31376. }
  31377. this.dimensions = dimensionNames
  31378. this._dimInfos = dimensionInfos
  31379. this._initGetDimensionInfo(needsHasOwn)
  31380. this.hostModel = hostModel
  31381. this._invertedIndicesMap = invertedIndicesMap
  31382. if (this._dimOmitted) {
  31383. var dimIdxToName_1 = (this._dimIdxToName = createHashMap())
  31384. each$7(dimensionNames, function (dimName) {
  31385. dimIdxToName_1.set(
  31386. dimensionInfos[dimName].storeDimIndex,
  31387. dimName
  31388. )
  31389. })
  31390. }
  31391. }
  31392. /**
  31393. *
  31394. * Get concrete dimension name by dimension name or dimension index.
  31395. * If input a dimension name, do not validate whether the dimension name exits.
  31396. *
  31397. * @caution
  31398. * @param dim Must make sure the dimension is `SeriesDimensionLoose`.
  31399. * Because only those dimensions will have auto-generated dimension names if not
  31400. * have a user-specified name, and other dimensions will get a return of null/undefined.
  31401. *
  31402. * @notice Becuause of this reason, should better use `getDimensionIndex` instead, for examples:
  31403. * ```js
  31404. * const val = data.getStore().get(data.getDimensionIndex(dim), dataIdx);
  31405. * ```
  31406. *
  31407. * @return Concrete dim name.
  31408. */ SeriesData.prototype.getDimension = function (dim) {
  31409. var dimIdx = this._recognizeDimIndex(dim)
  31410. if (dimIdx == null) {
  31411. return dim
  31412. }
  31413. dimIdx = dim
  31414. if (!this._dimOmitted) {
  31415. return this.dimensions[dimIdx]
  31416. } // Retrieve from series dimension definition becuase it probably contains
  31417. // generated dimension name (like 'x', 'y').
  31418. var dimName = this._dimIdxToName.get(dimIdx)
  31419. if (dimName != null) {
  31420. return dimName
  31421. }
  31422. var sourceDimDef = this._schema.getSourceDimension(dimIdx)
  31423. if (sourceDimDef) {
  31424. return sourceDimDef.name
  31425. }
  31426. }
  31427. /**
  31428. * Get dimension index in data store. Return -1 if not found.
  31429. * Can be used to index value from getRawValue.
  31430. */ SeriesData.prototype.getDimensionIndex = function (dim) {
  31431. var dimIdx = this._recognizeDimIndex(dim)
  31432. if (dimIdx != null) {
  31433. return dimIdx
  31434. }
  31435. if (dim == null) {
  31436. return -1
  31437. }
  31438. var dimInfo = this._getDimInfo(dim)
  31439. return dimInfo
  31440. ? dimInfo.storeDimIndex
  31441. : this._dimOmitted
  31442. ? this._schema.getSourceDimensionIndex(dim)
  31443. : -1
  31444. }
  31445. /**
  31446. * The meanings of the input parameter `dim`:
  31447. *
  31448. * + If dim is a number (e.g., `1`), it means the index of the dimension.
  31449. * For example, `getDimension(0)` will return 'x' or 'lng' or 'radius'.
  31450. * + If dim is a number-like string (e.g., `"1"`):
  31451. * + If there is the same concrete dim name defined in `series.dimensions` or `dataset.dimensions`,
  31452. * it means that concrete name.
  31453. * + If not, it will be converted to a number, which means the index of the dimension.
  31454. * (why? because of the backward compatbility. We have been tolerating number-like string in
  31455. * dimension setting, although now it seems that it is not a good idea.)
  31456. * For example, `visualMap[i].dimension: "1"` is the same meaning as `visualMap[i].dimension: 1`,
  31457. * if no dimension name is defined as `"1"`.
  31458. * + If dim is a not-number-like string, it means the concrete dim name.
  31459. * For example, it can be be default name `"x"`, `"y"`, `"z"`, `"lng"`, `"lat"`, `"angle"`, `"radius"`,
  31460. * or customized in `dimensions` property of option like `"age"`.
  31461. *
  31462. * @return recogonized `DimensionIndex`. Otherwise return null/undefined (means that dim is `DimensionName`).
  31463. */ SeriesData.prototype._recognizeDimIndex = function (dim) {
  31464. if (
  31465. isNumber(dim) || // If being a number-like string but not being defined as a dimension name.
  31466. (dim != null &&
  31467. !isNaN(dim) &&
  31468. !this._getDimInfo(dim) &&
  31469. (!this._dimOmitted ||
  31470. this._schema.getSourceDimensionIndex(dim) < 0))
  31471. ) {
  31472. return +dim
  31473. }
  31474. }
  31475. SeriesData.prototype._getStoreDimIndex = function (dim) {
  31476. var dimIdx = this.getDimensionIndex(dim)
  31477. return dimIdx
  31478. }
  31479. /**
  31480. * Get type and calculation info of particular dimension
  31481. * @param dim
  31482. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  31483. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  31484. */ SeriesData.prototype.getDimensionInfo = function (dim) {
  31485. // Do not clone, because there may be categories in dimInfo.
  31486. return this._getDimInfo(this.getDimension(dim))
  31487. }
  31488. SeriesData.prototype._initGetDimensionInfo = function (
  31489. needsHasOwn
  31490. ) {
  31491. var dimensionInfos = this._dimInfos
  31492. this._getDimInfo = needsHasOwn
  31493. ? function (dimName) {
  31494. return dimensionInfos.hasOwnProperty(dimName)
  31495. ? dimensionInfos[dimName]
  31496. : undefined
  31497. }
  31498. : function (dimName) {
  31499. return dimensionInfos[dimName]
  31500. }
  31501. }
  31502. /**
  31503. * concrete dimension name list on coord.
  31504. */ SeriesData.prototype.getDimensionsOnCoord = function () {
  31505. return this._dimSummary.dataDimsOnCoord.slice()
  31506. }
  31507. SeriesData.prototype.mapDimension = function (coordDim, idx) {
  31508. var dimensionsSummary = this._dimSummary
  31509. if (idx == null) {
  31510. return dimensionsSummary.encodeFirstDimNotExtra[coordDim]
  31511. }
  31512. var dims = dimensionsSummary.encode[coordDim]
  31513. return dims ? dims[idx] : null
  31514. }
  31515. SeriesData.prototype.mapDimensionsAll = function (coordDim) {
  31516. var dimensionsSummary = this._dimSummary
  31517. var dims = dimensionsSummary.encode[coordDim]
  31518. return (dims || []).slice()
  31519. }
  31520. SeriesData.prototype.getStore = function () {
  31521. return this._store
  31522. }
  31523. /**
  31524. * Initialize from data
  31525. * @param data source or data or data store.
  31526. * @param nameList The name of a datum is used on data diff and
  31527. * default label/tooltip.
  31528. * A name can be specified in encode.itemName,
  31529. * or dataItem.name (only for series option data),
  31530. * or provided in nameList from outside.
  31531. */ SeriesData.prototype.initData = function (
  31532. data,
  31533. nameList,
  31534. dimValueGetter
  31535. ) {
  31536. var _this = this
  31537. var store
  31538. if (data instanceof DataStore) {
  31539. store = data
  31540. }
  31541. if (!store) {
  31542. var dimensions = this.dimensions
  31543. var provider =
  31544. isSourceInstance(data) || isArrayLike(data)
  31545. ? new DefaultDataProvider(data, dimensions.length)
  31546. : data
  31547. store = new DataStore()
  31548. var dimensionInfos = map(dimensions, function (dimName) {
  31549. return {
  31550. type: _this._dimInfos[dimName].type,
  31551. property: dimName
  31552. }
  31553. })
  31554. store.initData(provider, dimensionInfos, dimValueGetter)
  31555. }
  31556. this._store = store // Reset
  31557. this._nameList = (nameList || []).slice()
  31558. this._idList = []
  31559. this._nameRepeatCount = {}
  31560. this._doInit(0, store.count()) // Cache summary info for fast visit. See "dimensionHelper".
  31561. // Needs to be initialized after store is prepared.
  31562. this._dimSummary = summarizeDimensions(this, this._schema)
  31563. this.userOutput = this._dimSummary.userOutput
  31564. }
  31565. /**
  31566. * Caution: Can be only called on raw data (before `this._indices` created).
  31567. */ SeriesData.prototype.appendData = function (data) {
  31568. var range = this._store.appendData(data)
  31569. this._doInit(range[0], range[1])
  31570. }
  31571. /**
  31572. * Caution: Can be only called on raw data (before `this._indices` created).
  31573. * This method does not modify `rawData` (`dataProvider`), but only
  31574. * add values to store.
  31575. *
  31576. * The final count will be increased by `Math.max(values.length, names.length)`.
  31577. *
  31578. * @param values That is the SourceType: 'arrayRows', like
  31579. * [
  31580. * [12, 33, 44],
  31581. * [NaN, 43, 1],
  31582. * ['-', 'asdf', 0]
  31583. * ]
  31584. * Each item is exaclty cooresponding to a dimension.
  31585. */ SeriesData.prototype.appendValues = function (values, names) {
  31586. var _a = this._store.appendValues(values, names.length),
  31587. start = _a.start,
  31588. end = _a.end
  31589. var shouldMakeIdFromName = this._shouldMakeIdFromName()
  31590. this._updateOrdinalMeta()
  31591. if (names) {
  31592. for (var idx = start; idx < end; idx++) {
  31593. var sourceIdx = idx - start
  31594. this._nameList[idx] = names[sourceIdx]
  31595. if (shouldMakeIdFromName) {
  31596. makeIdFromName(this, idx)
  31597. }
  31598. }
  31599. }
  31600. }
  31601. SeriesData.prototype._updateOrdinalMeta = function () {
  31602. var store = this._store
  31603. var dimensions = this.dimensions
  31604. for (var i = 0; i < dimensions.length; i++) {
  31605. var dimInfo = this._dimInfos[dimensions[i]]
  31606. if (dimInfo.ordinalMeta) {
  31607. store.collectOrdinalMeta(
  31608. dimInfo.storeDimIndex,
  31609. dimInfo.ordinalMeta
  31610. )
  31611. }
  31612. }
  31613. }
  31614. SeriesData.prototype._shouldMakeIdFromName = function () {
  31615. var provider = this._store.getProvider()
  31616. return (
  31617. this._idDimIdx == null &&
  31618. provider.getSource().sourceFormat !==
  31619. SOURCE_FORMAT_TYPED_ARRAY &&
  31620. !provider.fillStorage
  31621. )
  31622. }
  31623. SeriesData.prototype._doInit = function (start, end) {
  31624. if (start >= end) {
  31625. return
  31626. }
  31627. var store = this._store
  31628. var provider = store.getProvider()
  31629. this._updateOrdinalMeta()
  31630. var nameList = this._nameList
  31631. var idList = this._idList
  31632. var sourceFormat = provider.getSource().sourceFormat
  31633. var isFormatOriginal = sourceFormat === SOURCE_FORMAT_ORIGINAL // Each data item is value
  31634. // [1, 2]
  31635. // 2
  31636. // Bar chart, line chart which uses category axis
  31637. // only gives the 'y' value. 'x' value is the indices of category
  31638. // Use a tempValue to normalize the value to be a (x, y) value
  31639. // If dataItem is {name: ...} or {id: ...}, it has highest priority.
  31640. // This kind of ids and names are always stored `_nameList` and `_idList`.
  31641. if (isFormatOriginal && !provider.pure) {
  31642. var sharedDataItem = []
  31643. for (var idx = start; idx < end; idx++) {
  31644. // NOTICE: Try not to write things into dataItem
  31645. var dataItem = provider.getItem(idx, sharedDataItem)
  31646. if (!this.hasItemOption && isDataItemOption(dataItem)) {
  31647. this.hasItemOption = true
  31648. }
  31649. if (dataItem) {
  31650. var itemName = dataItem.name
  31651. if (nameList[idx] == null && itemName != null) {
  31652. nameList[idx] = convertOptionIdName(itemName, null)
  31653. }
  31654. var itemId = dataItem.id
  31655. if (idList[idx] == null && itemId != null) {
  31656. idList[idx] = convertOptionIdName(itemId, null)
  31657. }
  31658. }
  31659. }
  31660. }
  31661. if (this._shouldMakeIdFromName()) {
  31662. for (var idx = start; idx < end; idx++) {
  31663. makeIdFromName(this, idx)
  31664. }
  31665. }
  31666. prepareInvertedIndex(this)
  31667. }
  31668. /**
  31669. * PENDING: In fact currently this function is only used to short-circuit
  31670. * the calling of `scale.unionExtentFromData` when data have been filtered by modules
  31671. * like "dataZoom". `scale.unionExtentFromData` is used to calculate data extent for series on
  31672. * an axis, but if a "axis related data filter module" is used, the extent of the axis have
  31673. * been fixed and no need to calling `scale.unionExtentFromData` actually.
  31674. * But if we add "custom data filter" in future, which is not "axis related", this method may
  31675. * be still needed.
  31676. *
  31677. * Optimize for the scenario that data is filtered by a given extent.
  31678. * Consider that if data amount is more than hundreds of thousand,
  31679. * extent calculation will cost more than 10ms and the cache will
  31680. * be erased because of the filtering.
  31681. */ SeriesData.prototype.getApproximateExtent = function (dim) {
  31682. return (
  31683. this._approximateExtent[dim] ||
  31684. this._store.getDataExtent(this._getStoreDimIndex(dim))
  31685. )
  31686. }
  31687. /**
  31688. * Calculate extent on a filtered data might be time consuming.
  31689. * Approximate extent is only used for: calculte extent of filtered data outside.
  31690. */ SeriesData.prototype.setApproximateExtent = function (
  31691. extent,
  31692. dim
  31693. ) {
  31694. dim = this.getDimension(dim)
  31695. this._approximateExtent[dim] = extent.slice()
  31696. }
  31697. SeriesData.prototype.getCalculationInfo = function (key) {
  31698. return this._calculationInfo[key]
  31699. }
  31700. SeriesData.prototype.setCalculationInfo = function (key, value) {
  31701. isObject(key)
  31702. ? extend(this._calculationInfo, key)
  31703. : (this._calculationInfo[key] = value)
  31704. }
  31705. /**
  31706. * @return Never be null/undefined. `number` will be converted to string. Becuase:
  31707. * In most cases, name is used in display, where returning a string is more convenient.
  31708. * In other cases, name is used in query (see `indexOfName`), where we can keep the
  31709. * rule that name `2` equals to name `'2'`.
  31710. */ SeriesData.prototype.getName = function (idx) {
  31711. var rawIndex = this.getRawIndex(idx)
  31712. var name = this._nameList[rawIndex]
  31713. if (name == null && this._nameDimIdx != null) {
  31714. name = getIdNameFromStore(this, this._nameDimIdx, rawIndex)
  31715. }
  31716. if (name == null) {
  31717. name = ''
  31718. }
  31719. return name
  31720. }
  31721. SeriesData.prototype._getCategory = function (dimIdx, idx) {
  31722. var ordinal = this._store.get(dimIdx, idx)
  31723. var ordinalMeta = this._store.getOrdinalMeta(dimIdx)
  31724. if (ordinalMeta) {
  31725. return ordinalMeta.categories[ordinal]
  31726. }
  31727. return ordinal
  31728. }
  31729. /**
  31730. * @return Never null/undefined. `number` will be converted to string. Becuase:
  31731. * In all cases having encountered at present, id is used in making diff comparison, which
  31732. * are usually based on hash map. We can keep the rule that the internal id are always string
  31733. * (treat `2` is the same as `'2'`) to make the related logic simple.
  31734. */ SeriesData.prototype.getId = function (idx) {
  31735. return getId(this, this.getRawIndex(idx))
  31736. }
  31737. SeriesData.prototype.count = function () {
  31738. return this._store.count()
  31739. }
  31740. /**
  31741. * Get value. Return NaN if idx is out of range.
  31742. *
  31743. * @notice Should better to use `data.getStore().get(dimIndex, dataIdx)` instead.
  31744. */ SeriesData.prototype.get = function (dim, idx) {
  31745. var store = this._store
  31746. var dimInfo = this._dimInfos[dim]
  31747. if (dimInfo) {
  31748. return store.get(dimInfo.storeDimIndex, idx)
  31749. }
  31750. }
  31751. /**
  31752. * @notice Should better to use `data.getStore().getByRawIndex(dimIndex, dataIdx)` instead.
  31753. */ SeriesData.prototype.getByRawIndex = function (dim, rawIdx) {
  31754. var store = this._store
  31755. var dimInfo = this._dimInfos[dim]
  31756. if (dimInfo) {
  31757. return store.getByRawIndex(dimInfo.storeDimIndex, rawIdx)
  31758. }
  31759. }
  31760. SeriesData.prototype.getIndices = function () {
  31761. return this._store.getIndices()
  31762. }
  31763. SeriesData.prototype.getDataExtent = function (dim) {
  31764. return this._store.getDataExtent(this._getStoreDimIndex(dim))
  31765. }
  31766. SeriesData.prototype.getSum = function (dim) {
  31767. return this._store.getSum(this._getStoreDimIndex(dim))
  31768. }
  31769. SeriesData.prototype.getMedian = function (dim) {
  31770. return this._store.getMedian(this._getStoreDimIndex(dim))
  31771. }
  31772. SeriesData.prototype.getValues = function (dimensions, idx) {
  31773. var _this = this
  31774. var store = this._store
  31775. return isArray(dimensions)
  31776. ? store.getValues(
  31777. map(dimensions, function (dim) {
  31778. return _this._getStoreDimIndex(dim)
  31779. }),
  31780. idx
  31781. )
  31782. : store.getValues(dimensions)
  31783. }
  31784. /**
  31785. * If value is NaN. Inlcuding '-'
  31786. * Only check the coord dimensions.
  31787. */ SeriesData.prototype.hasValue = function (idx) {
  31788. var dataDimIndicesOnCoord = this._dimSummary.dataDimIndicesOnCoord
  31789. for (
  31790. var i = 0, len = dataDimIndicesOnCoord.length;
  31791. i < len;
  31792. i++
  31793. ) {
  31794. // Ordinal type originally can be string or number.
  31795. // But when an ordinal type is used on coord, it can
  31796. // not be string but only number. So we can also use isNaN.
  31797. if (isNaN(this._store.get(dataDimIndicesOnCoord[i], idx))) {
  31798. return false
  31799. }
  31800. }
  31801. return true
  31802. }
  31803. /**
  31804. * Retreive the index with given name
  31805. */ SeriesData.prototype.indexOfName = function (name) {
  31806. for (var i = 0, len = this._store.count(); i < len; i++) {
  31807. if (this.getName(i) === name) {
  31808. return i
  31809. }
  31810. }
  31811. return -1
  31812. }
  31813. SeriesData.prototype.getRawIndex = function (idx) {
  31814. return this._store.getRawIndex(idx)
  31815. }
  31816. SeriesData.prototype.indexOfRawIndex = function (rawIndex) {
  31817. return this._store.indexOfRawIndex(rawIndex)
  31818. }
  31819. /**
  31820. * Only support the dimension which inverted index created.
  31821. * Do not support other cases until required.
  31822. * @param dim concrete dim
  31823. * @param value ordinal index
  31824. * @return rawIndex
  31825. */ SeriesData.prototype.rawIndexOf = function (dim, value) {
  31826. var invertedIndices = dim && this._invertedIndicesMap[dim]
  31827. var rawIndex = invertedIndices[value]
  31828. if (rawIndex == null || isNaN(rawIndex)) {
  31829. return INDEX_NOT_FOUND
  31830. }
  31831. return rawIndex
  31832. }
  31833. /**
  31834. * Retreive the index of nearest value
  31835. * @param dim
  31836. * @param value
  31837. * @param [maxDistance=Infinity]
  31838. * @return If and only if multiple indices has
  31839. * the same value, they are put to the result.
  31840. */ SeriesData.prototype.indicesOfNearest = function (
  31841. dim,
  31842. value,
  31843. maxDistance
  31844. ) {
  31845. return this._store.indicesOfNearest(
  31846. this._getStoreDimIndex(dim),
  31847. value,
  31848. maxDistance
  31849. )
  31850. }
  31851. SeriesData.prototype.each = function (dims, cb, ctx) {
  31852. if (isFunction(dims)) {
  31853. ctx = cb
  31854. cb = dims
  31855. dims = []
  31856. } // ctxCompat just for compat echarts3
  31857. var fCtx = ctx || this
  31858. var dimIndices = map(
  31859. normalizeDimensions(dims),
  31860. this._getStoreDimIndex,
  31861. this
  31862. )
  31863. this._store.each(dimIndices, fCtx ? bind$1(cb, fCtx) : cb)
  31864. }
  31865. SeriesData.prototype.filterSelf = function (dims, cb, ctx) {
  31866. if (isFunction(dims)) {
  31867. ctx = cb
  31868. cb = dims
  31869. dims = []
  31870. } // ctxCompat just for compat echarts3
  31871. var fCtx = ctx || this
  31872. var dimIndices = map(
  31873. normalizeDimensions(dims),
  31874. this._getStoreDimIndex,
  31875. this
  31876. )
  31877. this._store = this._store.filter(
  31878. dimIndices,
  31879. fCtx ? bind$1(cb, fCtx) : cb
  31880. )
  31881. return this
  31882. }
  31883. /**
  31884. * Select data in range. (For optimization of filter)
  31885. * (Manually inline code, support 5 million data filtering in data zoom.)
  31886. */ SeriesData.prototype.selectRange = function (range) {
  31887. var _this = this
  31888. var innerRange = {}
  31889. var dims = keys(range)
  31890. each$7(dims, function (dim) {
  31891. var dimIdx = _this._getStoreDimIndex(dim)
  31892. innerRange[dimIdx] = range[dim]
  31893. })
  31894. this._store = this._store.selectRange(innerRange)
  31895. return this
  31896. }
  31897. /* eslint-enable max-len */ SeriesData.prototype.mapArray =
  31898. function (dims, cb, ctx) {
  31899. if (isFunction(dims)) {
  31900. ctx = cb
  31901. cb = dims
  31902. dims = []
  31903. } // ctxCompat just for compat echarts3
  31904. ctx = ctx || this
  31905. var result = []
  31906. this.each(
  31907. dims,
  31908. function () {
  31909. result.push(cb && cb.apply(this, arguments))
  31910. },
  31911. ctx
  31912. )
  31913. return result
  31914. }
  31915. SeriesData.prototype.map = function (dims, cb, ctx, ctxCompat) {
  31916. var fCtx = ctx || ctxCompat || this
  31917. var dimIndices = map(
  31918. normalizeDimensions(dims),
  31919. this._getStoreDimIndex,
  31920. this
  31921. )
  31922. var list = cloneListForMapAndSample(this)
  31923. list._store = this._store.map(
  31924. dimIndices,
  31925. fCtx ? bind$1(cb, fCtx) : cb
  31926. )
  31927. return list
  31928. }
  31929. SeriesData.prototype.modify = function (dims, cb, ctx, ctxCompat) {
  31930. var fCtx = ctx || ctxCompat || this
  31931. var dimIndices = map(
  31932. normalizeDimensions(dims),
  31933. this._getStoreDimIndex,
  31934. this
  31935. ) // If do shallow clone here, if there are too many stacked series,
  31936. // it still cost lots of memory, becuase `_store.dimensions` are not shared.
  31937. // We should consider there probably be shallow clone happen in each sereis
  31938. // in consequent filter/map.
  31939. this._store.modify(dimIndices, fCtx ? bind$1(cb, fCtx) : cb)
  31940. }
  31941. /**
  31942. * Large data down sampling on given dimension
  31943. * @param sampleIndex Sample index for name and id
  31944. */ SeriesData.prototype.downSample = function (
  31945. dimension,
  31946. rate,
  31947. sampleValue,
  31948. sampleIndex
  31949. ) {
  31950. var list = cloneListForMapAndSample(this)
  31951. list._store = this._store.downSample(
  31952. this._getStoreDimIndex(dimension),
  31953. rate,
  31954. sampleValue,
  31955. sampleIndex
  31956. )
  31957. return list
  31958. }
  31959. /**
  31960. * Large data down sampling using largest-triangle-three-buckets
  31961. * @param {string} valueDimension
  31962. * @param {number} targetCount
  31963. */ SeriesData.prototype.lttbDownSample = function (
  31964. valueDimension,
  31965. rate
  31966. ) {
  31967. var list = cloneListForMapAndSample(this)
  31968. list._store = this._store.lttbDownSample(
  31969. this._getStoreDimIndex(valueDimension),
  31970. rate
  31971. )
  31972. return list
  31973. }
  31974. SeriesData.prototype.getRawDataItem = function (idx) {
  31975. return this._store.getRawDataItem(idx)
  31976. }
  31977. /**
  31978. * Get model of one data item.
  31979. */ // TODO: Type of data item
  31980. SeriesData.prototype.getItemModel = function (idx) {
  31981. var hostModel = this.hostModel
  31982. var dataItem = this.getRawDataItem(idx)
  31983. return new Model$1(
  31984. dataItem,
  31985. hostModel,
  31986. hostModel && hostModel.ecModel
  31987. )
  31988. }
  31989. /**
  31990. * Create a data differ
  31991. */ SeriesData.prototype.diff = function (otherList) {
  31992. var thisList = this
  31993. return new DataDiffer$1(
  31994. otherList ? otherList.getStore().getIndices() : [],
  31995. this.getStore().getIndices(),
  31996. function (idx) {
  31997. return getId(otherList, idx)
  31998. },
  31999. function (idx) {
  32000. return getId(thisList, idx)
  32001. }
  32002. )
  32003. }
  32004. /**
  32005. * Get visual property.
  32006. */ SeriesData.prototype.getVisual = function (key) {
  32007. var visual = this._visual
  32008. return visual && visual[key]
  32009. }
  32010. SeriesData.prototype.setVisual = function (kvObj, val) {
  32011. this._visual = this._visual || {}
  32012. if (isObject(kvObj)) {
  32013. extend(this._visual, kvObj)
  32014. } else {
  32015. this._visual[kvObj] = val
  32016. }
  32017. }
  32018. /**
  32019. * Get visual property of single data item
  32020. */ // eslint-disable-next-line
  32021. SeriesData.prototype.getItemVisual = function (idx, key) {
  32022. var itemVisual = this._itemVisuals[idx]
  32023. var val = itemVisual && itemVisual[key]
  32024. if (val == null) {
  32025. // Use global visual property
  32026. return this.getVisual(key)
  32027. }
  32028. return val
  32029. }
  32030. /**
  32031. * If exists visual property of single data item
  32032. */ SeriesData.prototype.hasItemVisual = function () {
  32033. return this._itemVisuals.length > 0
  32034. }
  32035. /**
  32036. * Make sure itemVisual property is unique
  32037. */ // TODO: use key to save visual to reduce memory.
  32038. SeriesData.prototype.ensureUniqueItemVisual = function (idx, key) {
  32039. var itemVisuals = this._itemVisuals
  32040. var itemVisual = itemVisuals[idx]
  32041. if (!itemVisual) {
  32042. itemVisual = itemVisuals[idx] = {}
  32043. }
  32044. var val = itemVisual[key]
  32045. if (val == null) {
  32046. val = this.getVisual(key) // TODO Performance?
  32047. if (isArray(val)) {
  32048. val = val.slice()
  32049. } else if (isObject(val)) {
  32050. val = extend({}, val)
  32051. }
  32052. itemVisual[key] = val
  32053. }
  32054. return val
  32055. } // eslint-disable-next-line
  32056. SeriesData.prototype.setItemVisual = function (idx, key, value) {
  32057. var itemVisual = this._itemVisuals[idx] || {}
  32058. this._itemVisuals[idx] = itemVisual
  32059. if (isObject(key)) {
  32060. extend(itemVisual, key)
  32061. } else {
  32062. itemVisual[key] = value
  32063. }
  32064. }
  32065. /**
  32066. * Clear itemVisuals and list visual.
  32067. */ SeriesData.prototype.clearAllVisual = function () {
  32068. this._visual = {}
  32069. this._itemVisuals = []
  32070. }
  32071. SeriesData.prototype.setLayout = function (key, val) {
  32072. isObject(key)
  32073. ? extend(this._layout, key)
  32074. : (this._layout[key] = val)
  32075. }
  32076. /**
  32077. * Get layout property.
  32078. */ SeriesData.prototype.getLayout = function (key) {
  32079. return this._layout[key]
  32080. }
  32081. /**
  32082. * Get layout of single data item
  32083. */ SeriesData.prototype.getItemLayout = function (idx) {
  32084. return this._itemLayouts[idx]
  32085. }
  32086. /**
  32087. * Set layout of single data item
  32088. */ SeriesData.prototype.setItemLayout = function (
  32089. idx,
  32090. layout,
  32091. merge
  32092. ) {
  32093. this._itemLayouts[idx] = merge
  32094. ? extend(this._itemLayouts[idx] || {}, layout)
  32095. : layout
  32096. }
  32097. /**
  32098. * Clear all layout of single data item
  32099. */ SeriesData.prototype.clearItemLayouts = function () {
  32100. this._itemLayouts.length = 0
  32101. }
  32102. /**
  32103. * Set graphic element relative to data. It can be set as null
  32104. */ SeriesData.prototype.setItemGraphicEl = function (idx, el) {
  32105. var seriesIndex = this.hostModel && this.hostModel.seriesIndex
  32106. setCommonECData(seriesIndex, this.dataType, idx, el)
  32107. this._graphicEls[idx] = el
  32108. }
  32109. SeriesData.prototype.getItemGraphicEl = function (idx) {
  32110. return this._graphicEls[idx]
  32111. }
  32112. SeriesData.prototype.eachItemGraphicEl = function (cb, context) {
  32113. each$7(this._graphicEls, function (el, idx) {
  32114. if (el) {
  32115. cb && cb.call(context, el, idx)
  32116. }
  32117. })
  32118. }
  32119. /**
  32120. * Shallow clone a new list except visual and layout properties, and graph elements.
  32121. * New list only change the indices.
  32122. */ SeriesData.prototype.cloneShallow = function (list) {
  32123. if (!list) {
  32124. list = new SeriesData(
  32125. this._schema
  32126. ? this._schema
  32127. : map(this.dimensions, this._getDimInfo, this),
  32128. this.hostModel
  32129. )
  32130. }
  32131. transferProperties(list, this)
  32132. list._store = this._store
  32133. return list
  32134. }
  32135. /**
  32136. * Wrap some method to add more feature
  32137. */ SeriesData.prototype.wrapMethod = function (
  32138. methodName,
  32139. injectFunction
  32140. ) {
  32141. var originalMethod = this[methodName]
  32142. if (!isFunction(originalMethod)) {
  32143. return
  32144. }
  32145. this.__wrappedMethods = this.__wrappedMethods || []
  32146. this.__wrappedMethods.push(methodName)
  32147. this[methodName] = function () {
  32148. var res = originalMethod.apply(this, arguments)
  32149. return injectFunction.apply(
  32150. this,
  32151. [res].concat(slice(arguments))
  32152. )
  32153. }
  32154. } // ----------------------------------------------------------
  32155. // A work around for internal method visiting private member.
  32156. // ----------------------------------------------------------
  32157. SeriesData.internalField = (function () {
  32158. prepareInvertedIndex = function prepareInvertedIndex(data) {
  32159. var invertedIndicesMap = data._invertedIndicesMap
  32160. each$7(invertedIndicesMap, function (invertedIndices, dim) {
  32161. var dimInfo = data._dimInfos[dim] // Currently, only dimensions that has ordinalMeta can create inverted indices.
  32162. var ordinalMeta = dimInfo.ordinalMeta
  32163. var store = data._store
  32164. if (ordinalMeta) {
  32165. invertedIndices = invertedIndicesMap[dim] =
  32166. new CtorInt32Array(ordinalMeta.categories.length) // The default value of TypedArray is 0. To avoid miss
  32167. // mapping to 0, we should set it as INDEX_NOT_FOUND.
  32168. for (var i = 0; i < invertedIndices.length; i++) {
  32169. invertedIndices[i] = INDEX_NOT_FOUND
  32170. }
  32171. for (var i = 0; i < store.count(); i++) {
  32172. // Only support the case that all values are distinct.
  32173. invertedIndices[store.get(dimInfo.storeDimIndex, i)] = i
  32174. }
  32175. }
  32176. })
  32177. }
  32178. getIdNameFromStore = function getIdNameFromStore(
  32179. data,
  32180. dimIdx,
  32181. idx
  32182. ) {
  32183. return convertOptionIdName(data._getCategory(dimIdx, idx), null)
  32184. }
  32185. /**
  32186. * @see the comment of `List['getId']`.
  32187. */ getId = function getId(data, rawIndex) {
  32188. var id = data._idList[rawIndex]
  32189. if (id == null && data._idDimIdx != null) {
  32190. id = getIdNameFromStore(data, data._idDimIdx, rawIndex)
  32191. }
  32192. if (id == null) {
  32193. id = ID_PREFIX + rawIndex
  32194. }
  32195. return id
  32196. }
  32197. normalizeDimensions = function normalizeDimensions(dimensions) {
  32198. if (!isArray(dimensions)) {
  32199. dimensions = dimensions != null ? [dimensions] : []
  32200. }
  32201. return dimensions
  32202. }
  32203. /**
  32204. * Data in excludeDimensions is copied, otherwise transfered.
  32205. */ cloneListForMapAndSample = function cloneListForMapAndSample(
  32206. original
  32207. ) {
  32208. var list = new SeriesData(
  32209. original._schema
  32210. ? original._schema
  32211. : map(original.dimensions, original._getDimInfo, original),
  32212. original.hostModel
  32213. ) // FIXME If needs stackedOn, value may already been stacked
  32214. transferProperties(list, original)
  32215. return list
  32216. }
  32217. transferProperties = function transferProperties(target, source) {
  32218. each$7(
  32219. TRANSFERABLE_PROPERTIES.concat(source.__wrappedMethods || []),
  32220. function (propName) {
  32221. if (source.hasOwnProperty(propName)) {
  32222. target[propName] = source[propName]
  32223. }
  32224. }
  32225. )
  32226. target.__wrappedMethods = source.__wrappedMethods
  32227. each$7(CLONE_PROPERTIES, function (propName) {
  32228. target[propName] = clone$3(source[propName])
  32229. })
  32230. target._calculationInfo = extend({}, source._calculationInfo)
  32231. }
  32232. makeIdFromName = function makeIdFromName(data, idx) {
  32233. var nameList = data._nameList
  32234. var idList = data._idList
  32235. var nameDimIdx = data._nameDimIdx
  32236. var idDimIdx = data._idDimIdx
  32237. var name = nameList[idx]
  32238. var id = idList[idx]
  32239. if (name == null && nameDimIdx != null) {
  32240. nameList[idx] = name = getIdNameFromStore(
  32241. data,
  32242. nameDimIdx,
  32243. idx
  32244. )
  32245. }
  32246. if (id == null && idDimIdx != null) {
  32247. idList[idx] = id = getIdNameFromStore(data, idDimIdx, idx)
  32248. }
  32249. if (id == null && name != null) {
  32250. var nameRepeatCount = data._nameRepeatCount
  32251. var nmCnt = (nameRepeatCount[name] =
  32252. (nameRepeatCount[name] || 0) + 1)
  32253. id = name
  32254. if (nmCnt > 1) {
  32255. id += '__ec__' + nmCnt
  32256. }
  32257. idList[idx] = id
  32258. }
  32259. }
  32260. })()
  32261. return SeriesData
  32262. })()
  32263. var SeriesData$1 = SeriesData
  32264. /**
  32265. * This method builds the relationship between:
  32266. * + "what the coord sys or series requires (see `coordDimensions`)",
  32267. * + "what the user defines (in `encode` and `dimensions`, see `opt.dimensionsDefine` and `opt.encodeDefine`)"
  32268. * + "what the data source provids (see `source`)".
  32269. *
  32270. * Some guess strategy will be adapted if user does not define something.
  32271. * If no 'value' dimension specified, the first no-named dimension will be
  32272. * named as 'value'.
  32273. *
  32274. * @return The results are always sorted by `storeDimIndex` asc.
  32275. */ function prepareSeriesDataSchema(source, opt) { // TODO: TYPE completeDimensions type
  32276. if (!isSourceInstance(source)) {
  32277. source = createSourceFromSeriesDataOption(source)
  32278. }
  32279. opt = opt || {}
  32280. var sysDims = opt.coordDimensions || []
  32281. var dimsDef = opt.dimensionsDefine || source.dimensionsDefine || []
  32282. var coordDimNameMap = createHashMap()
  32283. var resultList = []
  32284. var dimCount = getDimCount(
  32285. source,
  32286. sysDims,
  32287. dimsDef,
  32288. opt.dimensionsCount
  32289. ) // Try to ignore unsed dimensions if sharing a high dimension datastore
  32290. // 30 is an experience value.
  32291. var omitUnusedDimensions =
  32292. opt.canOmitUnusedDimensions &&
  32293. shouldOmitUnusedDimensions(dimCount)
  32294. var isUsingSourceDimensionsDef = dimsDef === source.dimensionsDefine
  32295. var dataDimNameMap = isUsingSourceDimensionsDef
  32296. ? ensureSourceDimNameMap(source)
  32297. : createDimNameMap(dimsDef)
  32298. var encodeDef = opt.encodeDefine
  32299. if (!encodeDef && opt.encodeDefaulter) {
  32300. encodeDef = opt.encodeDefaulter(source, dimCount)
  32301. }
  32302. var encodeDefMap = createHashMap(encodeDef)
  32303. var indicesMap = new CtorInt32Array$1(dimCount)
  32304. for (var i = 0; i < indicesMap.length; i++) {
  32305. indicesMap[i] = -1
  32306. }
  32307. function getResultItem(dimIdx) {
  32308. var idx = indicesMap[dimIdx]
  32309. if (idx < 0) {
  32310. var dimDefItemRaw = dimsDef[dimIdx]
  32311. var dimDefItem = isObject$2(dimDefItemRaw)
  32312. ? dimDefItemRaw
  32313. : { name: dimDefItemRaw }
  32314. var resultItem = new SeriesDimensionDefine$1()
  32315. var userDimName = dimDefItem.name
  32316. if (
  32317. userDimName != null &&
  32318. dataDimNameMap.get(userDimName) != null
  32319. ) {
  32320. // Only if `series.dimensions` is defined in option
  32321. // displayName, will be set, and dimension will be diplayed vertically in
  32322. // tooltip by default.
  32323. resultItem.name = resultItem.displayName = userDimName
  32324. }
  32325. dimDefItem.type != null && (resultItem.type = dimDefItem.type)
  32326. dimDefItem.displayName != null &&
  32327. (resultItem.displayName = dimDefItem.displayName)
  32328. var newIdx = resultList.length
  32329. indicesMap[dimIdx] = newIdx
  32330. resultItem.storeDimIndex = dimIdx
  32331. resultList.push(resultItem)
  32332. return resultItem
  32333. }
  32334. return resultList[idx]
  32335. }
  32336. if (!omitUnusedDimensions) {
  32337. for (var i = 0; i < dimCount; i++) {
  32338. getResultItem(i)
  32339. }
  32340. } // Set `coordDim` and `coordDimIndex` by `encodeDefMap` and normalize `encodeDefMap`.
  32341. encodeDefMap.each(function (dataDimsRaw, coordDim) {
  32342. var dataDims = normalizeToArray(dataDimsRaw).slice() // Note: It is allowed that `dataDims.length` is `0`, e.g., options is
  32343. // `{encode: {x: -1, y: 1}}`. Should not filter anything in
  32344. // this case.
  32345. if (
  32346. dataDims.length === 1 &&
  32347. !isString(dataDims[0]) &&
  32348. dataDims[0] < 0
  32349. ) {
  32350. encodeDefMap.set(coordDim, false)
  32351. return
  32352. }
  32353. var validDataDims = encodeDefMap.set(coordDim, [])
  32354. each$7(dataDims, function (resultDimIdxOrName, idx) {
  32355. // The input resultDimIdx can be dim name or index.
  32356. var resultDimIdx = isString(resultDimIdxOrName)
  32357. ? dataDimNameMap.get(resultDimIdxOrName)
  32358. : resultDimIdxOrName
  32359. if (resultDimIdx != null && resultDimIdx < dimCount) {
  32360. validDataDims[idx] = resultDimIdx
  32361. applyDim(getResultItem(resultDimIdx), coordDim, idx)
  32362. }
  32363. })
  32364. }) // Apply templetes and default order from `sysDims`.
  32365. var availDimIdx = 0
  32366. each$7(sysDims, function (sysDimItemRaw) {
  32367. var coordDim
  32368. var sysDimItemDimsDef
  32369. var sysDimItemOtherDims
  32370. var sysDimItem
  32371. if (isString(sysDimItemRaw)) {
  32372. coordDim = sysDimItemRaw
  32373. sysDimItem = {}
  32374. } else {
  32375. sysDimItem = sysDimItemRaw
  32376. coordDim = sysDimItem.name
  32377. var ordinalMeta = sysDimItem.ordinalMeta
  32378. sysDimItem.ordinalMeta = null
  32379. sysDimItem = extend({}, sysDimItem)
  32380. sysDimItem.ordinalMeta = ordinalMeta // `coordDimIndex` should not be set directly.
  32381. sysDimItemDimsDef = sysDimItem.dimsDef
  32382. sysDimItemOtherDims = sysDimItem.otherDims
  32383. sysDimItem.name =
  32384. sysDimItem.coordDim =
  32385. sysDimItem.coordDimIndex =
  32386. sysDimItem.dimsDef =
  32387. sysDimItem.otherDims =
  32388. null
  32389. }
  32390. var dataDims = encodeDefMap.get(coordDim) // negative resultDimIdx means no need to mapping.
  32391. if (dataDims === false) {
  32392. return
  32393. }
  32394. dataDims = normalizeToArray(dataDims) // dimensions provides default dim sequences.
  32395. if (!dataDims.length) {
  32396. for (
  32397. var i = 0;
  32398. i < ((sysDimItemDimsDef && sysDimItemDimsDef.length) || 1);
  32399. i++
  32400. ) {
  32401. while (
  32402. availDimIdx < dimCount &&
  32403. getResultItem(availDimIdx).coordDim != null
  32404. ) {
  32405. availDimIdx++
  32406. }
  32407. availDimIdx < dimCount && dataDims.push(availDimIdx++)
  32408. }
  32409. } // Apply templates.
  32410. each$7(dataDims, function (resultDimIdx, coordDimIndex) {
  32411. var resultItem = getResultItem(resultDimIdx) // Coordinate system has a higher priority on dim type than source.
  32412. if (isUsingSourceDimensionsDef && sysDimItem.type != null) {
  32413. resultItem.type = sysDimItem.type
  32414. }
  32415. applyDim(
  32416. defaults(resultItem, sysDimItem),
  32417. coordDim,
  32418. coordDimIndex
  32419. )
  32420. if (resultItem.name == null && sysDimItemDimsDef) {
  32421. var sysDimItemDimsDefItem = sysDimItemDimsDef[coordDimIndex]
  32422. !isObject$2(sysDimItemDimsDefItem) &&
  32423. (sysDimItemDimsDefItem = { name: sysDimItemDimsDefItem })
  32424. resultItem.name = resultItem.displayName =
  32425. sysDimItemDimsDefItem.name
  32426. resultItem.defaultTooltip =
  32427. sysDimItemDimsDefItem.defaultTooltip
  32428. } // FIXME refactor, currently only used in case: {otherDims: {tooltip: false}}
  32429. sysDimItemOtherDims &&
  32430. defaults(resultItem.otherDims, sysDimItemOtherDims)
  32431. })
  32432. })
  32433. function applyDim(resultItem, coordDim, coordDimIndex) {
  32434. if (VISUAL_DIMENSIONS.get(coordDim) != null) {
  32435. resultItem.otherDims[coordDim] = coordDimIndex
  32436. } else {
  32437. resultItem.coordDim = coordDim
  32438. resultItem.coordDimIndex = coordDimIndex
  32439. coordDimNameMap.set(coordDim, true)
  32440. }
  32441. } // Make sure the first extra dim is 'value'.
  32442. var generateCoord = opt.generateCoord
  32443. var generateCoordCount = opt.generateCoordCount
  32444. var fromZero = generateCoordCount != null
  32445. generateCoordCount = generateCoord ? generateCoordCount || 1 : 0
  32446. var extra = generateCoord || 'value'
  32447. function ifNoNameFillWithCoordName(resultItem) {
  32448. if (resultItem.name == null) {
  32449. // Duplication will be removed in the next step.
  32450. resultItem.name = resultItem.coordDim
  32451. }
  32452. } // Set dim `name` and other `coordDim` and other props.
  32453. if (!omitUnusedDimensions) {
  32454. for (
  32455. var resultDimIdx = 0;
  32456. resultDimIdx < dimCount;
  32457. resultDimIdx++
  32458. ) {
  32459. var resultItem = getResultItem(resultDimIdx)
  32460. var coordDim = resultItem.coordDim
  32461. if (coordDim == null) {
  32462. // TODO no need to generate coordDim for isExtraCoord?
  32463. resultItem.coordDim = genCoordDimName(
  32464. extra,
  32465. coordDimNameMap,
  32466. fromZero
  32467. )
  32468. resultItem.coordDimIndex = 0 // Series specified generateCoord is using out.
  32469. if (!generateCoord || generateCoordCount <= 0) {
  32470. resultItem.isExtraCoord = true
  32471. }
  32472. generateCoordCount--
  32473. }
  32474. ifNoNameFillWithCoordName(resultItem)
  32475. if (
  32476. resultItem.type == null &&
  32477. (guessOrdinal(source, resultDimIdx) === BE_ORDINAL.Must || // Consider the case:
  32478. // {
  32479. // dataset: {source: [
  32480. // ['2001', 123],
  32481. // ['2002', 456],
  32482. // ...
  32483. // ['The others', 987],
  32484. // ]},
  32485. // series: {type: 'pie'}
  32486. // }
  32487. // The first colum should better be treated as a "ordinal" although it
  32488. // might not able to be detected as an "ordinal" by `guessOrdinal`.
  32489. (resultItem.isExtraCoord &&
  32490. (resultItem.otherDims.itemName != null ||
  32491. resultItem.otherDims.seriesName != null)))
  32492. ) {
  32493. resultItem.type = 'ordinal'
  32494. }
  32495. }
  32496. } else {
  32497. each$7(resultList, function (resultItem) {
  32498. // PENDING: guessOrdinal or let user specify type: 'ordinal' manually?
  32499. ifNoNameFillWithCoordName(resultItem)
  32500. }) // Sort dimensions: there are some rule that use the last dim as label,
  32501. // and for some latter travel process easier.
  32502. resultList.sort(function (item0, item1) {
  32503. return item0.storeDimIndex - item1.storeDimIndex
  32504. })
  32505. }
  32506. removeDuplication(resultList)
  32507. return new SeriesDataSchema({
  32508. source: source,
  32509. dimensions: resultList,
  32510. fullDimensionCount: dimCount,
  32511. dimensionOmitted: omitUnusedDimensions
  32512. })
  32513. }
  32514. function removeDuplication(result) {
  32515. var duplicationMap = createHashMap()
  32516. for (var i = 0; i < result.length; i++) {
  32517. var dim = result[i]
  32518. var dimOriginalName = dim.name
  32519. var count = duplicationMap.get(dimOriginalName) || 0
  32520. if (count > 0) {
  32521. // Starts from 0.
  32522. dim.name = dimOriginalName + (count - 1)
  32523. }
  32524. count++
  32525. duplicationMap.set(dimOriginalName, count)
  32526. }
  32527. } // ??? TODO
  32528. // Originally detect dimCount by data[0]. Should we
  32529. // optimize it to only by sysDims and dimensions and encode.
  32530. // So only necessary dims will be initialized.
  32531. // But
  32532. // (1) custom series should be considered. where other dims
  32533. // may be visited.
  32534. // (2) sometimes user need to calcualte bubble size or use visualMap
  32535. // on other dimensions besides coordSys needed.
  32536. // So, dims that is not used by system, should be shared in data store?
  32537. function getDimCount(source, sysDims, dimsDef, optDimCount) {
  32538. // Note that the result dimCount should not small than columns count
  32539. // of data, otherwise `dataDimNameMap` checking will be incorrect.
  32540. var dimCount = Math.max(
  32541. source.dimensionsDetectedCount || 1,
  32542. sysDims.length,
  32543. dimsDef.length,
  32544. optDimCount || 0
  32545. )
  32546. each$7(sysDims, function (sysDimItem) {
  32547. var sysDimItemDimsDef
  32548. if (
  32549. isObject$2(sysDimItem) &&
  32550. (sysDimItemDimsDef = sysDimItem.dimsDef)
  32551. ) {
  32552. dimCount = Math.max(dimCount, sysDimItemDimsDef.length)
  32553. }
  32554. })
  32555. return dimCount
  32556. }
  32557. function genCoordDimName(name, map, fromZero) {
  32558. var mapData = map.data
  32559. if (fromZero || mapData.hasOwnProperty(name)) {
  32560. var i = 0
  32561. while (mapData.hasOwnProperty(name + i)) {
  32562. i++
  32563. }
  32564. name += i
  32565. }
  32566. map.set(name, true)
  32567. return name
  32568. }
  32569. /**
  32570. * @class
  32571. * For example:
  32572. * {
  32573. * coordSysName: 'cartesian2d',
  32574. * coordSysDims: ['x', 'y', ...],
  32575. * axisMap: HashMap({
  32576. * x: xAxisModel,
  32577. * y: yAxisModel
  32578. * }),
  32579. * categoryAxisMap: HashMap({
  32580. * x: xAxisModel,
  32581. * y: undefined
  32582. * }),
  32583. * // The index of the first category axis in `coordSysDims`.
  32584. * // `null/undefined` means no category axis exists.
  32585. * firstCategoryDimIndex: 1,
  32586. * // To replace user specified encode.
  32587. * }
  32588. */ var CoordSysInfo = /** @class */ (function () {
  32589. function CoordSysInfo(coordSysName) {
  32590. this.coordSysDims = []
  32591. this.axisMap = createHashMap()
  32592. this.categoryAxisMap = createHashMap()
  32593. this.coordSysName = coordSysName
  32594. }
  32595. return CoordSysInfo
  32596. })()
  32597. function getCoordSysInfoBySeries(seriesModel) {
  32598. var coordSysName = seriesModel.get('coordinateSystem')
  32599. var result = new CoordSysInfo(coordSysName)
  32600. var fetch = fetchers[coordSysName]
  32601. if (fetch) {
  32602. fetch(seriesModel, result, result.axisMap, result.categoryAxisMap)
  32603. return result
  32604. }
  32605. }
  32606. var fetchers = {
  32607. cartesian2d: function cartesian2d(
  32608. seriesModel,
  32609. result,
  32610. axisMap,
  32611. categoryAxisMap
  32612. ) {
  32613. var xAxisModel = seriesModel.getReferringComponents(
  32614. 'xAxis',
  32615. SINGLE_REFERRING
  32616. ).models[0]
  32617. var yAxisModel = seriesModel.getReferringComponents(
  32618. 'yAxis',
  32619. SINGLE_REFERRING
  32620. ).models[0]
  32621. result.coordSysDims = ['x', 'y']
  32622. axisMap.set('x', xAxisModel)
  32623. axisMap.set('y', yAxisModel)
  32624. if (isCategory(xAxisModel)) {
  32625. categoryAxisMap.set('x', xAxisModel)
  32626. result.firstCategoryDimIndex = 0
  32627. }
  32628. if (isCategory(yAxisModel)) {
  32629. categoryAxisMap.set('y', yAxisModel)
  32630. result.firstCategoryDimIndex == null &&
  32631. (result.firstCategoryDimIndex = 1)
  32632. }
  32633. },
  32634. singleAxis: function singleAxis(
  32635. seriesModel,
  32636. result,
  32637. axisMap,
  32638. categoryAxisMap
  32639. ) {
  32640. var singleAxisModel = seriesModel.getReferringComponents(
  32641. 'singleAxis',
  32642. SINGLE_REFERRING
  32643. ).models[0]
  32644. result.coordSysDims = ['single']
  32645. axisMap.set('single', singleAxisModel)
  32646. if (isCategory(singleAxisModel)) {
  32647. categoryAxisMap.set('single', singleAxisModel)
  32648. result.firstCategoryDimIndex = 0
  32649. }
  32650. },
  32651. polar: function polar(
  32652. seriesModel,
  32653. result,
  32654. axisMap,
  32655. categoryAxisMap
  32656. ) {
  32657. var polarModel = seriesModel.getReferringComponents(
  32658. 'polar',
  32659. SINGLE_REFERRING
  32660. ).models[0]
  32661. var radiusAxisModel = polarModel.findAxisModel('radiusAxis')
  32662. var angleAxisModel = polarModel.findAxisModel('angleAxis')
  32663. result.coordSysDims = ['radius', 'angle']
  32664. axisMap.set('radius', radiusAxisModel)
  32665. axisMap.set('angle', angleAxisModel)
  32666. if (isCategory(radiusAxisModel)) {
  32667. categoryAxisMap.set('radius', radiusAxisModel)
  32668. result.firstCategoryDimIndex = 0
  32669. }
  32670. if (isCategory(angleAxisModel)) {
  32671. categoryAxisMap.set('angle', angleAxisModel)
  32672. result.firstCategoryDimIndex == null &&
  32673. (result.firstCategoryDimIndex = 1)
  32674. }
  32675. },
  32676. geo: function geo(seriesModel, result, axisMap, categoryAxisMap) {
  32677. result.coordSysDims = ['lng', 'lat']
  32678. },
  32679. parallel: function parallel(
  32680. seriesModel,
  32681. result,
  32682. axisMap,
  32683. categoryAxisMap
  32684. ) {
  32685. var ecModel = seriesModel.ecModel
  32686. var parallelModel = ecModel.getComponent(
  32687. 'parallel',
  32688. seriesModel.get('parallelIndex')
  32689. )
  32690. var coordSysDims = (result.coordSysDims =
  32691. parallelModel.dimensions.slice())
  32692. each$7(
  32693. parallelModel.parallelAxisIndex,
  32694. function (axisIndex, index) {
  32695. var axisModel = ecModel.getComponent(
  32696. 'parallelAxis',
  32697. axisIndex
  32698. )
  32699. var axisDim = coordSysDims[index]
  32700. axisMap.set(axisDim, axisModel)
  32701. if (isCategory(axisModel)) {
  32702. categoryAxisMap.set(axisDim, axisModel)
  32703. if (result.firstCategoryDimIndex == null) {
  32704. result.firstCategoryDimIndex = index
  32705. }
  32706. }
  32707. }
  32708. )
  32709. }
  32710. }
  32711. function isCategory(axisModel) {
  32712. return axisModel.get('type') === 'category'
  32713. }
  32714. /**
  32715. * Note that it is too complicated to support 3d stack by value
  32716. * (have to create two-dimension inverted index), so in 3d case
  32717. * we just support that stacked by index.
  32718. *
  32719. * @param seriesModel
  32720. * @param dimensionsInput The same as the input of <module:echarts/data/SeriesData>.
  32721. * The input will be modified.
  32722. * @param opt
  32723. * @param opt.stackedCoordDimension Specify a coord dimension if needed.
  32724. * @param opt.byIndex=false
  32725. * @return calculationInfo
  32726. * {
  32727. * stackedDimension: string
  32728. * stackedByDimension: string
  32729. * isStackedByIndex: boolean
  32730. * stackedOverDimension: string
  32731. * stackResultDimension: string
  32732. * }
  32733. */ function enableDataStack(seriesModel, dimensionsInput, opt) {
  32734. opt = opt || {}
  32735. var byIndex = opt.byIndex
  32736. var stackedCoordDimension = opt.stackedCoordDimension
  32737. var dimensionDefineList
  32738. var schema
  32739. var store
  32740. if (isLegacyDimensionsInput(dimensionsInput)) {
  32741. dimensionDefineList = dimensionsInput
  32742. } else {
  32743. schema = dimensionsInput.schema
  32744. dimensionDefineList = schema.dimensions
  32745. store = dimensionsInput.store
  32746. } // Compatibal: when `stack` is set as '', do not stack.
  32747. var mayStack = !!(seriesModel && seriesModel.get('stack'))
  32748. var stackedByDimInfo
  32749. var stackedDimInfo
  32750. var stackResultDimension
  32751. var stackedOverDimension
  32752. each$7(dimensionDefineList, function (dimensionInfo, index) {
  32753. if (isString(dimensionInfo)) {
  32754. dimensionDefineList[index] = dimensionInfo = {
  32755. name: dimensionInfo
  32756. }
  32757. }
  32758. if (mayStack && !dimensionInfo.isExtraCoord) {
  32759. // Find the first ordinal dimension as the stackedByDimInfo.
  32760. if (
  32761. !byIndex &&
  32762. !stackedByDimInfo &&
  32763. dimensionInfo.ordinalMeta
  32764. ) {
  32765. stackedByDimInfo = dimensionInfo
  32766. } // Find the first stackable dimension as the stackedDimInfo.
  32767. if (
  32768. !stackedDimInfo &&
  32769. dimensionInfo.type !== 'ordinal' &&
  32770. dimensionInfo.type !== 'time' &&
  32771. (!stackedCoordDimension ||
  32772. stackedCoordDimension === dimensionInfo.coordDim)
  32773. ) {
  32774. stackedDimInfo = dimensionInfo
  32775. }
  32776. }
  32777. })
  32778. if (stackedDimInfo && !byIndex && !stackedByDimInfo) {
  32779. // Compatible with previous design, value axis (time axis) only stack by index.
  32780. // It may make sense if the user provides elaborately constructed data.
  32781. byIndex = true
  32782. } // Add stack dimension, they can be both calculated by coordinate system in `unionExtent`.
  32783. // That put stack logic in List is for using conveniently in echarts extensions, but it
  32784. // might not be a good way.
  32785. if (stackedDimInfo) {
  32786. // Use a weird name that not duplicated with other names.
  32787. // Also need to use seriesModel.id as postfix because different
  32788. // series may share same data store. The stack dimension needs to be distinguished.
  32789. stackResultDimension = '__\0ecstackresult_' + seriesModel.id
  32790. stackedOverDimension = '__\0ecstackedover_' + seriesModel.id // Create inverted index to fast query index by value.
  32791. if (stackedByDimInfo) {
  32792. stackedByDimInfo.createInvertedIndices = true
  32793. }
  32794. var stackedDimCoordDim_1 = stackedDimInfo.coordDim
  32795. var stackedDimType = stackedDimInfo.type
  32796. var stackedDimCoordIndex_1 = 0
  32797. each$7(dimensionDefineList, function (dimensionInfo) {
  32798. if (dimensionInfo.coordDim === stackedDimCoordDim_1) {
  32799. stackedDimCoordIndex_1++
  32800. }
  32801. })
  32802. var stackedOverDimensionDefine = {
  32803. name: stackResultDimension,
  32804. coordDim: stackedDimCoordDim_1,
  32805. coordDimIndex: stackedDimCoordIndex_1,
  32806. type: stackedDimType,
  32807. isExtraCoord: true,
  32808. isCalculationCoord: true,
  32809. storeDimIndex: dimensionDefineList.length
  32810. }
  32811. var stackResultDimensionDefine = {
  32812. name: stackedOverDimension, // This dimension contains stack base (generally, 0), so do not set it as
  32813. // `stackedDimCoordDim` to avoid extent calculation, consider log scale.
  32814. coordDim: stackedOverDimension,
  32815. coordDimIndex: stackedDimCoordIndex_1 + 1,
  32816. type: stackedDimType,
  32817. isExtraCoord: true,
  32818. isCalculationCoord: true,
  32819. storeDimIndex: dimensionDefineList.length + 1
  32820. }
  32821. if (schema) {
  32822. if (store) {
  32823. stackedOverDimensionDefine.storeDimIndex =
  32824. store.ensureCalculationDimension(
  32825. stackedOverDimension,
  32826. stackedDimType
  32827. )
  32828. stackResultDimensionDefine.storeDimIndex =
  32829. store.ensureCalculationDimension(
  32830. stackResultDimension,
  32831. stackedDimType
  32832. )
  32833. }
  32834. schema.appendCalculationDimension(stackedOverDimensionDefine)
  32835. schema.appendCalculationDimension(stackResultDimensionDefine)
  32836. } else {
  32837. dimensionDefineList.push(stackedOverDimensionDefine)
  32838. dimensionDefineList.push(stackResultDimensionDefine)
  32839. }
  32840. }
  32841. return {
  32842. stackedDimension: stackedDimInfo && stackedDimInfo.name,
  32843. stackedByDimension: stackedByDimInfo && stackedByDimInfo.name,
  32844. isStackedByIndex: byIndex,
  32845. stackedOverDimension: stackedOverDimension,
  32846. stackResultDimension: stackResultDimension
  32847. }
  32848. }
  32849. function isLegacyDimensionsInput(dimensionsInput) {
  32850. return !isSeriesDataSchema(dimensionsInput.schema)
  32851. }
  32852. function isDimensionStacked(data, stackedDim) {
  32853. // Each single series only maps to one pair of axis. So we do not need to
  32854. // check stackByDim, whatever stacked by a dimension or stacked by index.
  32855. return (
  32856. !!stackedDim &&
  32857. stackedDim === data.getCalculationInfo('stackedDimension')
  32858. )
  32859. }
  32860. function getStackedDimension(data, targetDim) {
  32861. return isDimensionStacked(data, targetDim)
  32862. ? data.getCalculationInfo('stackResultDimension')
  32863. : targetDim
  32864. }
  32865. function getCoordSysDimDefs(seriesModel, coordSysInfo) {
  32866. var coordSysName = seriesModel.get('coordinateSystem')
  32867. var registeredCoordSys = CoordinateSystem.get(coordSysName)
  32868. var coordSysDimDefs
  32869. if (coordSysInfo && coordSysInfo.coordSysDims) {
  32870. coordSysDimDefs = map$1(
  32871. coordSysInfo.coordSysDims,
  32872. function (dim) {
  32873. var dimInfo = { name: dim }
  32874. var axisModel = coordSysInfo.axisMap.get(dim)
  32875. if (axisModel) {
  32876. var axisType = axisModel.get('type')
  32877. dimInfo.type = getDimensionTypeByAxis(axisType)
  32878. }
  32879. return dimInfo
  32880. }
  32881. )
  32882. }
  32883. if (!coordSysDimDefs) {
  32884. // Get dimensions from registered coordinate system
  32885. coordSysDimDefs = (registeredCoordSys &&
  32886. (registeredCoordSys.getDimensionsInfo
  32887. ? registeredCoordSys.getDimensionsInfo()
  32888. : registeredCoordSys.dimensions.slice())) || ['x', 'y']
  32889. }
  32890. return coordSysDimDefs
  32891. }
  32892. function injectOrdinalMeta(
  32893. dimInfoList,
  32894. createInvertedIndices,
  32895. coordSysInfo
  32896. ) {
  32897. var firstCategoryDimIndex
  32898. var hasNameEncode
  32899. coordSysInfo &&
  32900. each$7(dimInfoList, function (dimInfo, dimIndex) {
  32901. var coordDim = dimInfo.coordDim
  32902. var categoryAxisModel =
  32903. coordSysInfo.categoryAxisMap.get(coordDim)
  32904. if (categoryAxisModel) {
  32905. if (firstCategoryDimIndex == null) {
  32906. firstCategoryDimIndex = dimIndex
  32907. }
  32908. dimInfo.ordinalMeta = categoryAxisModel.getOrdinalMeta()
  32909. if (createInvertedIndices) {
  32910. dimInfo.createInvertedIndices = true
  32911. }
  32912. }
  32913. if (dimInfo.otherDims.itemName != null) {
  32914. hasNameEncode = true
  32915. }
  32916. })
  32917. if (!hasNameEncode && firstCategoryDimIndex != null) {
  32918. dimInfoList[firstCategoryDimIndex].otherDims.itemName = 0
  32919. }
  32920. return firstCategoryDimIndex
  32921. }
  32922. /**
  32923. * Caution: there are side effects to `sourceManager` in this method.
  32924. * Should better only be called in `Series['getInitialData']`.
  32925. */ function createSeriesData(sourceRaw, seriesModel, opt) {
  32926. opt = opt || {}
  32927. var sourceManager = seriesModel.getSourceManager()
  32928. var source
  32929. var isOriginalSource = false
  32930. if (sourceRaw) {
  32931. isOriginalSource = true
  32932. source = createSourceFromSeriesDataOption(sourceRaw)
  32933. } else {
  32934. source = sourceManager.getSource() // Is series.data. not dataset.
  32935. isOriginalSource = source.sourceFormat === SOURCE_FORMAT_ORIGINAL
  32936. }
  32937. var coordSysInfo = getCoordSysInfoBySeries(seriesModel)
  32938. var coordSysDimDefs = getCoordSysDimDefs(seriesModel, coordSysInfo)
  32939. var useEncodeDefaulter = opt.useEncodeDefaulter
  32940. var encodeDefaulter = isFunction(useEncodeDefaulter)
  32941. ? useEncodeDefaulter
  32942. : useEncodeDefaulter
  32943. ? curry$1(
  32944. makeSeriesEncodeForAxisCoordSys,
  32945. coordSysDimDefs,
  32946. seriesModel
  32947. )
  32948. : null
  32949. var createDimensionOptions = {
  32950. coordDimensions: coordSysDimDefs,
  32951. generateCoord: opt.generateCoord,
  32952. encodeDefine: seriesModel.getEncode(),
  32953. encodeDefaulter: encodeDefaulter,
  32954. canOmitUnusedDimensions: !isOriginalSource
  32955. }
  32956. var schema = prepareSeriesDataSchema(source, createDimensionOptions)
  32957. var firstCategoryDimIndex = injectOrdinalMeta(
  32958. schema.dimensions,
  32959. opt.createInvertedIndices,
  32960. coordSysInfo
  32961. )
  32962. var store = !isOriginalSource
  32963. ? sourceManager.getSharedDataStore(schema)
  32964. : null
  32965. var stackCalculationInfo = enableDataStack(seriesModel, {
  32966. schema: schema,
  32967. store: store
  32968. })
  32969. var data = new SeriesData$1(schema, seriesModel)
  32970. data.setCalculationInfo(stackCalculationInfo)
  32971. var dimValueGetter =
  32972. firstCategoryDimIndex != null && isNeedCompleteOrdinalData(source)
  32973. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  32974. // Use dataIndex as ordinal value in categoryAxis
  32975. return dimIndex === firstCategoryDimIndex
  32976. ? dataIndex
  32977. : this.defaultDimValueGetter(
  32978. itemOpt,
  32979. dimName,
  32980. dataIndex,
  32981. dimIndex
  32982. )
  32983. }
  32984. : null
  32985. data.hasItemOption = false
  32986. data.initData(
  32987. // Try to reuse the data store in sourceManager if using dataset.
  32988. isOriginalSource ? source : store,
  32989. null,
  32990. dimValueGetter
  32991. )
  32992. return data
  32993. }
  32994. function isNeedCompleteOrdinalData(source) {
  32995. if (source.sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  32996. var sampleItem = firstDataNotNull(source.data || [])
  32997. return !isArray(getDataItemValue(sampleItem))
  32998. }
  32999. }
  33000. function firstDataNotNull(arr) {
  33001. var i = 0
  33002. while (i < arr.length && arr[i] == null) {
  33003. i++
  33004. }
  33005. return arr[i]
  33006. }
  33007. var Scale = /** @class */ (function () {
  33008. function Scale(setting) {
  33009. this._setting = setting || {}
  33010. this._extent = [Infinity, -Infinity]
  33011. }
  33012. Scale.prototype.getSetting = function (name) {
  33013. return this._setting[name]
  33014. }
  33015. /**
  33016. * Set extent from data
  33017. */ Scale.prototype.unionExtent = function (other) {
  33018. var extent = this._extent
  33019. other[0] < extent[0] && (extent[0] = other[0])
  33020. other[1] > extent[1] && (extent[1] = other[1]) // not setExtent because in log axis it may transformed to power
  33021. // this.setExtent(extent[0], extent[1]);
  33022. }
  33023. /**
  33024. * Set extent from data
  33025. */ Scale.prototype.unionExtentFromData = function (data, dim) {
  33026. this.unionExtent(data.getApproximateExtent(dim))
  33027. }
  33028. /**
  33029. * Get extent
  33030. *
  33031. * Extent is always in increase order.
  33032. */ Scale.prototype.getExtent = function () {
  33033. return this._extent.slice()
  33034. }
  33035. /**
  33036. * Set extent
  33037. */ Scale.prototype.setExtent = function (start, end) {
  33038. var thisExtent = this._extent
  33039. if (!isNaN(start)) {
  33040. thisExtent[0] = start
  33041. }
  33042. if (!isNaN(end)) {
  33043. thisExtent[1] = end
  33044. }
  33045. }
  33046. /**
  33047. * If value is in extent range
  33048. */ Scale.prototype.isInExtentRange = function (value) {
  33049. return this._extent[0] <= value && this._extent[1] >= value
  33050. }
  33051. /**
  33052. * When axis extent depends on data and no data exists,
  33053. * axis ticks should not be drawn, which is named 'blank'.
  33054. */ Scale.prototype.isBlank = function () {
  33055. return this._isBlank
  33056. }
  33057. /**
  33058. * When axis extent depends on data and no data exists,
  33059. * axis ticks should not be drawn, which is named 'blank'.
  33060. */ Scale.prototype.setBlank = function (isBlank) {
  33061. this._isBlank = isBlank
  33062. }
  33063. return Scale
  33064. })()
  33065. enableClassManagement(Scale)
  33066. var Scale$1 = Scale
  33067. var uidBase = 0
  33068. var OrdinalMeta = /** @class */ (function () {
  33069. function OrdinalMeta(opt) {
  33070. this.categories = opt.categories || []
  33071. this._needCollect = opt.needCollect
  33072. this._deduplication = opt.deduplication
  33073. this.uid = ++uidBase
  33074. }
  33075. OrdinalMeta.createByAxisModel = function (axisModel) {
  33076. var option = axisModel.option
  33077. var data = option.data
  33078. var categories = data && map$1(data, getName)
  33079. return new OrdinalMeta({
  33080. categories: categories,
  33081. needCollect: !categories, // deduplication is default in axis.
  33082. deduplication: option.dedplication !== false
  33083. })
  33084. }
  33085. OrdinalMeta.prototype.getOrdinal = function (category) {
  33086. // @ts-ignore
  33087. return this._getOrCreateMap().get(category)
  33088. }
  33089. /**
  33090. * @return The ordinal. If not found, return NaN.
  33091. */ OrdinalMeta.prototype.parseAndCollect = function (category) {
  33092. var index
  33093. var needCollect = this._needCollect // The value of category dim can be the index of the given category set.
  33094. // This feature is only supported when !needCollect, because we should
  33095. // consider a common case: a value is 2017, which is a number but is
  33096. // expected to be tread as a category. This case usually happen in dataset,
  33097. // where it happent to be no need of the index feature.
  33098. if (!isString(category) && !needCollect) {
  33099. return category
  33100. } // Optimize for the scenario:
  33101. // category is ['2012-01-01', '2012-01-02', ...], where the input
  33102. // data has been ensured not duplicate and is large data.
  33103. // Notice, if a dataset dimension provide categroies, usually echarts
  33104. // should remove duplication except user tell echarts dont do that
  33105. // (set axis.deduplication = false), because echarts do not know whether
  33106. // the values in the category dimension has duplication (consider the
  33107. // parallel-aqi example)
  33108. if (needCollect && !this._deduplication) {
  33109. index = this.categories.length
  33110. this.categories[index] = category
  33111. return index
  33112. }
  33113. var map = this._getOrCreateMap() // @ts-ignore
  33114. index = map.get(category)
  33115. if (index == null) {
  33116. if (needCollect) {
  33117. index = this.categories.length
  33118. this.categories[index] = category // @ts-ignore
  33119. map.set(category, index)
  33120. } else {
  33121. index = NaN
  33122. }
  33123. }
  33124. return index
  33125. } // Consider big data, do not create map until needed.
  33126. OrdinalMeta.prototype._getOrCreateMap = function () {
  33127. return this._map || (this._map = createHashMap(this.categories))
  33128. }
  33129. return OrdinalMeta
  33130. })()
  33131. function getName(obj) {
  33132. if (isObject$2(obj) && obj.value != null) {
  33133. return obj.value
  33134. } else {
  33135. return obj + ''
  33136. }
  33137. }
  33138. var OrdinalMeta$1 = OrdinalMeta
  33139. function isIntervalOrLogScale(scale) {
  33140. return scale.type === 'interval' || scale.type === 'log'
  33141. }
  33142. /**
  33143. * @param extent Both extent[0] and extent[1] should be valid number.
  33144. * Should be extent[0] < extent[1].
  33145. * @param splitNumber splitNumber should be >= 1.
  33146. */ function intervalScaleNiceTicks(
  33147. extent,
  33148. splitNumber,
  33149. minInterval,
  33150. maxInterval
  33151. ) {
  33152. var result = {}
  33153. var span = extent[1] - extent[0]
  33154. var interval = (result.interval = nice(span / splitNumber, true))
  33155. if (minInterval != null && interval < minInterval) {
  33156. interval = result.interval = minInterval
  33157. }
  33158. if (maxInterval != null && interval > maxInterval) {
  33159. interval = result.interval = maxInterval
  33160. } // Tow more digital for tick.
  33161. var precision = (result.intervalPrecision =
  33162. getIntervalPrecision(interval)) // Niced extent inside original extent
  33163. var niceTickExtent = (result.niceTickExtent = [
  33164. round$1(Math.ceil(extent[0] / interval) * interval, precision),
  33165. round$1(Math.floor(extent[1] / interval) * interval, precision)
  33166. ])
  33167. fixExtent(niceTickExtent, extent)
  33168. return result
  33169. }
  33170. function increaseInterval(interval) {
  33171. var exp10 = Math.pow(10, quantityExponent(interval)) // Increase interval
  33172. var f = interval / exp10
  33173. if (!f) {
  33174. f = 1
  33175. } else if (f === 2) {
  33176. f = 3
  33177. } else if (f === 3) {
  33178. f = 5
  33179. } else {
  33180. // f is 1 or 5
  33181. f *= 2
  33182. }
  33183. return round$1(f * exp10)
  33184. }
  33185. /**
  33186. * @return interval precision
  33187. */ function getIntervalPrecision(interval) {
  33188. // Tow more digital for tick.
  33189. return getPrecision(interval) + 2
  33190. }
  33191. function clamp(niceTickExtent, idx, extent) {
  33192. niceTickExtent[idx] = Math.max(
  33193. Math.min(niceTickExtent[idx], extent[1]),
  33194. extent[0]
  33195. )
  33196. } // In some cases (e.g., splitNumber is 1), niceTickExtent may be out of extent.
  33197. function fixExtent(niceTickExtent, extent) {
  33198. !isFinite(niceTickExtent[0]) && (niceTickExtent[0] = extent[0])
  33199. !isFinite(niceTickExtent[1]) && (niceTickExtent[1] = extent[1])
  33200. clamp(niceTickExtent, 0, extent)
  33201. clamp(niceTickExtent, 1, extent)
  33202. if (niceTickExtent[0] > niceTickExtent[1]) {
  33203. niceTickExtent[0] = niceTickExtent[1]
  33204. }
  33205. }
  33206. function contain(val, extent) {
  33207. return val >= extent[0] && val <= extent[1]
  33208. }
  33209. function normalize(val, extent) {
  33210. if (extent[1] === extent[0]) {
  33211. return 0.5
  33212. }
  33213. return (val - extent[0]) / (extent[1] - extent[0])
  33214. }
  33215. function scale(val, extent) {
  33216. return val * (extent[1] - extent[0]) + extent[0]
  33217. }
  33218. var OrdinalScale = /** @class */ (function (_super) {
  33219. __extends(OrdinalScale, _super)
  33220. function OrdinalScale(setting) {
  33221. var _this = _super.call(this, setting) || this
  33222. _this.type = 'ordinal'
  33223. var ordinalMeta = _this.getSetting('ordinalMeta') // Caution: Should not use instanceof, consider ec-extensions using
  33224. // import approach to get OrdinalMeta class.
  33225. if (!ordinalMeta) {
  33226. ordinalMeta = new OrdinalMeta$1({})
  33227. }
  33228. if (isArray(ordinalMeta)) {
  33229. ordinalMeta = new OrdinalMeta$1({
  33230. categories: map$1(ordinalMeta, function (item) {
  33231. return isObject$2(item) ? item.value : item
  33232. })
  33233. })
  33234. }
  33235. _this._ordinalMeta = ordinalMeta
  33236. _this._extent = _this.getSetting('extent') || [
  33237. 0,
  33238. ordinalMeta.categories.length - 1
  33239. ]
  33240. return _this
  33241. }
  33242. OrdinalScale.prototype.parse = function (val) {
  33243. // Caution: Math.round(null) will return `0` rather than `NaN`
  33244. if (val == null) {
  33245. return NaN
  33246. }
  33247. return isString(val)
  33248. ? this._ordinalMeta.getOrdinal(val) // val might be float.
  33249. : Math.round(val)
  33250. }
  33251. OrdinalScale.prototype.contain = function (rank) {
  33252. rank = this.parse(rank)
  33253. return (
  33254. contain(rank, this._extent) &&
  33255. this._ordinalMeta.categories[rank] != null
  33256. )
  33257. }
  33258. /**
  33259. * Normalize given rank or name to linear [0, 1]
  33260. * @param val raw ordinal number.
  33261. * @return normalized value in [0, 1].
  33262. */ OrdinalScale.prototype.normalize = function (val) {
  33263. val = this._getTickNumber(this.parse(val))
  33264. return normalize(val, this._extent)
  33265. }
  33266. /**
  33267. * @param val normalized value in [0, 1].
  33268. * @return raw ordinal number.
  33269. */ OrdinalScale.prototype.scale = function (val) {
  33270. val = Math.round(scale(val, this._extent))
  33271. return this.getRawOrdinalNumber(val)
  33272. }
  33273. OrdinalScale.prototype.getTicks = function () {
  33274. var ticks = []
  33275. var extent = this._extent
  33276. var rank = extent[0]
  33277. while (rank <= extent[1]) {
  33278. ticks.push({ value: rank })
  33279. rank++
  33280. }
  33281. return ticks
  33282. }
  33283. OrdinalScale.prototype.getMinorTicks = function (splitNumber) {
  33284. // Not support.
  33285. return
  33286. }
  33287. /**
  33288. * @see `Ordinal['_ordinalNumbersByTick']`
  33289. */ OrdinalScale.prototype.setSortInfo = function (info) {
  33290. if (info == null) {
  33291. this._ordinalNumbersByTick = this._ticksByOrdinalNumber = null
  33292. return
  33293. }
  33294. var infoOrdinalNumbers = info.ordinalNumbers
  33295. var ordinalsByTick = (this._ordinalNumbersByTick = [])
  33296. var ticksByOrdinal = (this._ticksByOrdinalNumber = []) // Unnecessary support negative tick in `realtimeSort`.
  33297. var tickNum = 0
  33298. var allCategoryLen = this._ordinalMeta.categories.length
  33299. for (
  33300. var len = Math.min(allCategoryLen, infoOrdinalNumbers.length);
  33301. tickNum < len;
  33302. ++tickNum
  33303. ) {
  33304. var ordinalNumber = infoOrdinalNumbers[tickNum]
  33305. ordinalsByTick[tickNum] = ordinalNumber
  33306. ticksByOrdinal[ordinalNumber] = tickNum
  33307. } // Handle that `series.data` only covers part of the `axis.category.data`.
  33308. var unusedOrdinal = 0
  33309. for (; tickNum < allCategoryLen; ++tickNum) {
  33310. while (ticksByOrdinal[unusedOrdinal] != null) {
  33311. unusedOrdinal++
  33312. }
  33313. ordinalsByTick.push(unusedOrdinal)
  33314. ticksByOrdinal[unusedOrdinal] = tickNum
  33315. }
  33316. }
  33317. OrdinalScale.prototype._getTickNumber = function (ordinal) {
  33318. var ticksByOrdinalNumber = this._ticksByOrdinalNumber // also support ordinal out of range of `ordinalMeta.categories.length`,
  33319. // where ordinal numbers are used as tick value directly.
  33320. return ticksByOrdinalNumber &&
  33321. ordinal >= 0 &&
  33322. ordinal < ticksByOrdinalNumber.length
  33323. ? ticksByOrdinalNumber[ordinal]
  33324. : ordinal
  33325. }
  33326. /**
  33327. * @usage
  33328. * ```js
  33329. * const ordinalNumber = ordinalScale.getRawOrdinalNumber(tickVal);
  33330. *
  33331. * // case0
  33332. * const rawOrdinalValue = axisModel.getCategories()[ordinalNumber];
  33333. * // case1
  33334. * const rawOrdinalValue = this._ordinalMeta.categories[ordinalNumber];
  33335. * // case2
  33336. * const coord = axis.dataToCoord(ordinalNumber);
  33337. * ```
  33338. *
  33339. * @param {OrdinalNumber} tickNumber index of display
  33340. */ OrdinalScale.prototype.getRawOrdinalNumber = function (
  33341. tickNumber
  33342. ) {
  33343. var ordinalNumbersByTick = this._ordinalNumbersByTick // tickNumber may be out of range, e.g., when axis max is larger than `ordinalMeta.categories.length`.,
  33344. // where ordinal numbers are used as tick value directly.
  33345. return ordinalNumbersByTick &&
  33346. tickNumber >= 0 &&
  33347. tickNumber < ordinalNumbersByTick.length
  33348. ? ordinalNumbersByTick[tickNumber]
  33349. : tickNumber
  33350. }
  33351. /**
  33352. * Get item on tick
  33353. */ OrdinalScale.prototype.getLabel = function (tick) {
  33354. if (!this.isBlank()) {
  33355. var ordinalNumber = this.getRawOrdinalNumber(tick.value)
  33356. var cateogry = this._ordinalMeta.categories[ordinalNumber] // Note that if no data, ordinalMeta.categories is an empty array.
  33357. // Return empty if it's not exist.
  33358. return cateogry == null ? '' : cateogry + ''
  33359. }
  33360. }
  33361. OrdinalScale.prototype.count = function () {
  33362. return this._extent[1] - this._extent[0] + 1
  33363. }
  33364. OrdinalScale.prototype.unionExtentFromData = function (data, dim) {
  33365. this.unionExtent(data.getApproximateExtent(dim))
  33366. }
  33367. /**
  33368. * @override
  33369. * If value is in extent range
  33370. */ OrdinalScale.prototype.isInExtentRange = function (value) {
  33371. value = this._getTickNumber(value)
  33372. return this._extent[0] <= value && this._extent[1] >= value
  33373. }
  33374. OrdinalScale.prototype.getOrdinalMeta = function () {
  33375. return this._ordinalMeta
  33376. }
  33377. OrdinalScale.prototype.calcNiceTicks = function () {}
  33378. OrdinalScale.prototype.calcNiceExtent = function () {}
  33379. OrdinalScale.type = 'ordinal'
  33380. return OrdinalScale
  33381. })(Scale$1)
  33382. Scale$1.registerClass(OrdinalScale)
  33383. var OrdinalScale$1 = OrdinalScale
  33384. var roundNumber = round$1
  33385. var IntervalScale = /** @class */ (function (_super) {
  33386. __extends(IntervalScale, _super)
  33387. function IntervalScale() {
  33388. var _this =
  33389. (_super !== null && _super.apply(this, arguments)) || this
  33390. _this.type = 'interval' // Step is calculated in adjustExtent.
  33391. _this._interval = 0
  33392. _this._intervalPrecision = 2
  33393. return _this
  33394. }
  33395. IntervalScale.prototype.parse = function (val) {
  33396. return val
  33397. }
  33398. IntervalScale.prototype.contain = function (val) {
  33399. return contain(val, this._extent)
  33400. }
  33401. IntervalScale.prototype.normalize = function (val) {
  33402. return normalize(val, this._extent)
  33403. }
  33404. IntervalScale.prototype.scale = function (val) {
  33405. return scale(val, this._extent)
  33406. }
  33407. IntervalScale.prototype.setExtent = function (start, end) {
  33408. var thisExtent = this._extent // start,end may be a Number like '25',so...
  33409. if (!isNaN(start)) {
  33410. thisExtent[0] = parseFloat(start)
  33411. }
  33412. if (!isNaN(end)) {
  33413. thisExtent[1] = parseFloat(end)
  33414. }
  33415. }
  33416. IntervalScale.prototype.unionExtent = function (other) {
  33417. var extent = this._extent
  33418. other[0] < extent[0] && (extent[0] = other[0])
  33419. other[1] > extent[1] && (extent[1] = other[1]) // unionExtent may called by it's sub classes
  33420. this.setExtent(extent[0], extent[1])
  33421. }
  33422. IntervalScale.prototype.getInterval = function () {
  33423. return this._interval
  33424. }
  33425. IntervalScale.prototype.setInterval = function (interval) {
  33426. this._interval = interval // Dropped auto calculated niceExtent and use user setted extent
  33427. // We assume user wan't to set both interval, min, max to get a better result
  33428. this._niceExtent = this._extent.slice()
  33429. this._intervalPrecision = getIntervalPrecision(interval)
  33430. }
  33431. /**
  33432. * @param expandToNicedExtent Whether expand the ticks to niced extent.
  33433. */ IntervalScale.prototype.getTicks = function (
  33434. expandToNicedExtent
  33435. ) {
  33436. var interval = this._interval
  33437. var extent = this._extent
  33438. var niceTickExtent = this._niceExtent
  33439. var intervalPrecision = this._intervalPrecision
  33440. var ticks = [] // If interval is 0, return [];
  33441. if (!interval) {
  33442. return ticks
  33443. } // Consider this case: using dataZoom toolbox, zoom and zoom.
  33444. var safeLimit = 10000
  33445. if (extent[0] < niceTickExtent[0]) {
  33446. if (expandToNicedExtent) {
  33447. ticks.push({
  33448. value: roundNumber(
  33449. niceTickExtent[0] - interval,
  33450. intervalPrecision
  33451. )
  33452. })
  33453. } else {
  33454. ticks.push({ value: extent[0] })
  33455. }
  33456. }
  33457. var tick = niceTickExtent[0]
  33458. while (tick <= niceTickExtent[1]) {
  33459. ticks.push({ value: tick }) // Avoid rounding error
  33460. tick = roundNumber(tick + interval, intervalPrecision)
  33461. if (tick === ticks[ticks.length - 1].value) {
  33462. // Consider out of safe float point, e.g.,
  33463. // -3711126.9907707 + 2e-10 === -3711126.9907707
  33464. break
  33465. }
  33466. if (ticks.length > safeLimit) {
  33467. return []
  33468. }
  33469. } // Consider this case: the last item of ticks is smaller
  33470. // than niceTickExtent[1] and niceTickExtent[1] === extent[1].
  33471. var lastNiceTick = ticks.length
  33472. ? ticks[ticks.length - 1].value
  33473. : niceTickExtent[1]
  33474. if (extent[1] > lastNiceTick) {
  33475. if (expandToNicedExtent) {
  33476. ticks.push({
  33477. value: roundNumber(
  33478. lastNiceTick + interval,
  33479. intervalPrecision
  33480. )
  33481. })
  33482. } else {
  33483. ticks.push({ value: extent[1] })
  33484. }
  33485. }
  33486. return ticks
  33487. }
  33488. IntervalScale.prototype.getMinorTicks = function (splitNumber) {
  33489. var ticks = this.getTicks(true)
  33490. var minorTicks = []
  33491. var extent = this.getExtent()
  33492. for (var i = 1; i < ticks.length; i++) {
  33493. var nextTick = ticks[i]
  33494. var prevTick = ticks[i - 1]
  33495. var count = 0
  33496. var minorTicksGroup = []
  33497. var interval = nextTick.value - prevTick.value
  33498. var minorInterval = interval / splitNumber
  33499. while (count < splitNumber - 1) {
  33500. var minorTick = roundNumber(
  33501. prevTick.value + (count + 1) * minorInterval
  33502. ) // For the first and last interval. The count may be less than splitNumber.
  33503. if (minorTick > extent[0] && minorTick < extent[1]) {
  33504. minorTicksGroup.push(minorTick)
  33505. }
  33506. count++
  33507. }
  33508. minorTicks.push(minorTicksGroup)
  33509. }
  33510. return minorTicks
  33511. }
  33512. /**
  33513. * @param opt.precision If 'auto', use nice presision.
  33514. * @param opt.pad returns 1.50 but not 1.5 if precision is 2.
  33515. */ IntervalScale.prototype.getLabel = function (data, opt) {
  33516. if (data == null) {
  33517. return ''
  33518. }
  33519. var precision = opt && opt.precision
  33520. if (precision == null) {
  33521. precision = getPrecision(data.value) || 0
  33522. } else if (precision === 'auto') {
  33523. // Should be more precise then tick.
  33524. precision = this._intervalPrecision
  33525. } // (1) If `precision` is set, 12.005 should be display as '12.00500'.
  33526. // (2) Use roundNumber (toFixed) to avoid scientific notation like '3.5e-7'.
  33527. var dataNum = roundNumber(data.value, precision, true)
  33528. return addCommas(dataNum)
  33529. }
  33530. /**
  33531. * @param splitNumber By default `5`.
  33532. */ IntervalScale.prototype.calcNiceTicks = function (
  33533. splitNumber,
  33534. minInterval,
  33535. maxInterval
  33536. ) {
  33537. splitNumber = splitNumber || 5
  33538. var extent = this._extent
  33539. var span = extent[1] - extent[0]
  33540. if (!isFinite(span)) {
  33541. return
  33542. } // User may set axis min 0 and data are all negative
  33543. // FIXME If it needs to reverse ?
  33544. if (span < 0) {
  33545. span = -span
  33546. extent.reverse()
  33547. }
  33548. var result = intervalScaleNiceTicks(
  33549. extent,
  33550. splitNumber,
  33551. minInterval,
  33552. maxInterval
  33553. )
  33554. this._intervalPrecision = result.intervalPrecision
  33555. this._interval = result.interval
  33556. this._niceExtent = result.niceTickExtent
  33557. }
  33558. IntervalScale.prototype.calcNiceExtent = function (opt) {
  33559. var extent = this._extent // If extent start and end are same, expand them
  33560. if (extent[0] === extent[1]) {
  33561. if (extent[0] !== 0) {
  33562. // Expand extent
  33563. var expandSize = extent[0] // In the fowllowing case
  33564. // Axis has been fixed max 100
  33565. // Plus data are all 100 and axis extent are [100, 100].
  33566. // Extend to the both side will cause expanded max is larger than fixed max.
  33567. // So only expand to the smaller side.
  33568. if (!opt.fixMax) {
  33569. extent[1] += expandSize / 2
  33570. extent[0] -= expandSize / 2
  33571. } else {
  33572. extent[0] -= expandSize / 2
  33573. }
  33574. } else {
  33575. extent[1] = 1
  33576. }
  33577. }
  33578. var span = extent[1] - extent[0] // If there are no data and extent are [Infinity, -Infinity]
  33579. if (!isFinite(span)) {
  33580. extent[0] = 0
  33581. extent[1] = 1
  33582. }
  33583. this.calcNiceTicks(
  33584. opt.splitNumber,
  33585. opt.minInterval,
  33586. opt.maxInterval
  33587. ) // let extent = this._extent;
  33588. var interval = this._interval
  33589. if (!opt.fixMin) {
  33590. extent[0] = roundNumber(
  33591. Math.floor(extent[0] / interval) * interval
  33592. )
  33593. }
  33594. if (!opt.fixMax) {
  33595. extent[1] = roundNumber(
  33596. Math.ceil(extent[1] / interval) * interval
  33597. )
  33598. }
  33599. }
  33600. IntervalScale.prototype.setNiceExtent = function (min, max) {
  33601. this._niceExtent = [min, max]
  33602. }
  33603. IntervalScale.type = 'interval'
  33604. return IntervalScale
  33605. })(Scale$1)
  33606. Scale$1.registerClass(IntervalScale)
  33607. var IntervalScale$1 = IntervalScale
  33608. /* global Float32Array */ var supportFloat32Array =
  33609. typeof Float32Array !== 'undefined'
  33610. var Float32ArrayCtor = !supportFloat32Array ? Array : Float32Array
  33611. function createFloat32Array(arg) {
  33612. if (isArray(arg)) {
  33613. // Return self directly if don't support TypedArray.
  33614. return supportFloat32Array ? new Float32Array(arg) : arg
  33615. } // Else is number
  33616. return new Float32ArrayCtor(arg)
  33617. }
  33618. var STACK_PREFIX = '__ec_stack_'
  33619. function getSeriesStackId(seriesModel) {
  33620. return (
  33621. seriesModel.get('stack') || STACK_PREFIX + seriesModel.seriesIndex
  33622. )
  33623. }
  33624. function getAxisKey(axis) {
  33625. return axis.dim + axis.index
  33626. }
  33627. function prepareLayoutBarSeries(seriesType, ecModel) {
  33628. var seriesModels = []
  33629. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  33630. // Check series coordinate, do layout for cartesian2d only
  33631. if (isOnCartesian(seriesModel)) {
  33632. seriesModels.push(seriesModel)
  33633. }
  33634. })
  33635. return seriesModels
  33636. }
  33637. /**
  33638. * Map from (baseAxis.dim + '_' + baseAxis.index) to min gap of two adjacent
  33639. * values.
  33640. * This works for time axes, value axes, and log axes.
  33641. * For a single time axis, return value is in the form like
  33642. * {'x_0': [1000000]}.
  33643. * The value of 1000000 is in milliseconds.
  33644. */ function getValueAxesMinGaps(barSeries) {
  33645. /**
  33646. * Map from axis.index to values.
  33647. * For a single time axis, axisValues is in the form like
  33648. * {'x_0': [1495555200000, 1495641600000, 1495728000000]}.
  33649. * Items in axisValues[x], e.g. 1495555200000, are time values of all
  33650. * series.
  33651. */ var axisValues = {}
  33652. each$7(barSeries, function (seriesModel) {
  33653. var cartesian = seriesModel.coordinateSystem
  33654. var baseAxis = cartesian.getBaseAxis()
  33655. if (baseAxis.type !== 'time' && baseAxis.type !== 'value') {
  33656. return
  33657. }
  33658. var data = seriesModel.getData()
  33659. var key = baseAxis.dim + '_' + baseAxis.index
  33660. var dimIdx = data.getDimensionIndex(
  33661. data.mapDimension(baseAxis.dim)
  33662. )
  33663. var store = data.getStore()
  33664. for (var i = 0, cnt = store.count(); i < cnt; ++i) {
  33665. var value = store.get(dimIdx, i)
  33666. if (!axisValues[key]) {
  33667. // No previous data for the axis
  33668. axisValues[key] = [value]
  33669. } else {
  33670. // No value in previous series
  33671. axisValues[key].push(value)
  33672. } // Ignore duplicated time values in the same axis
  33673. }
  33674. })
  33675. var axisMinGaps = {}
  33676. for (var key in axisValues) {
  33677. if (axisValues.hasOwnProperty(key)) {
  33678. var valuesInAxis = axisValues[key]
  33679. if (valuesInAxis) {
  33680. // Sort axis values into ascending order to calculate gaps
  33681. valuesInAxis.sort(function (a, b) {
  33682. return a - b
  33683. })
  33684. var min = null
  33685. for (var j = 1; j < valuesInAxis.length; ++j) {
  33686. var delta = valuesInAxis[j] - valuesInAxis[j - 1]
  33687. if (delta > 0) {
  33688. // Ignore 0 delta because they are of the same axis value
  33689. min = min === null ? delta : Math.min(min, delta)
  33690. }
  33691. } // Set to null if only have one data
  33692. axisMinGaps[key] = min
  33693. }
  33694. }
  33695. }
  33696. return axisMinGaps
  33697. }
  33698. function makeColumnLayout(barSeries) {
  33699. var axisMinGaps = getValueAxesMinGaps(barSeries)
  33700. var seriesInfoList = []
  33701. each$7(barSeries, function (seriesModel) {
  33702. var cartesian = seriesModel.coordinateSystem
  33703. var baseAxis = cartesian.getBaseAxis()
  33704. var axisExtent = baseAxis.getExtent()
  33705. var bandWidth
  33706. if (baseAxis.type === 'category') {
  33707. bandWidth = baseAxis.getBandWidth()
  33708. } else if (
  33709. baseAxis.type === 'value' ||
  33710. baseAxis.type === 'time'
  33711. ) {
  33712. var key = baseAxis.dim + '_' + baseAxis.index
  33713. var minGap = axisMinGaps[key]
  33714. var extentSpan = Math.abs(axisExtent[1] - axisExtent[0])
  33715. var scale = baseAxis.scale.getExtent()
  33716. var scaleSpan = Math.abs(scale[1] - scale[0])
  33717. bandWidth = minGap
  33718. ? (extentSpan / scaleSpan) * minGap
  33719. : extentSpan // When there is only one data value
  33720. } else {
  33721. var data = seriesModel.getData()
  33722. bandWidth =
  33723. Math.abs(axisExtent[1] - axisExtent[0]) / data.count()
  33724. }
  33725. var barWidth = parsePercent(
  33726. seriesModel.get('barWidth'),
  33727. bandWidth
  33728. )
  33729. var barMaxWidth = parsePercent(
  33730. seriesModel.get('barMaxWidth'),
  33731. bandWidth
  33732. )
  33733. var barMinWidth = parsePercent(
  33734. // barMinWidth by default is 0.5 / 1 in cartesian. Because in value axis,
  33735. // the auto-calculated bar width might be less than 0.5 / 1.
  33736. seriesModel.get('barMinWidth') ||
  33737. (isInLargeMode(seriesModel) ? 0.5 : 1),
  33738. bandWidth
  33739. )
  33740. var barGap = seriesModel.get('barGap')
  33741. var barCategoryGap = seriesModel.get('barCategoryGap')
  33742. seriesInfoList.push({
  33743. bandWidth: bandWidth,
  33744. barWidth: barWidth,
  33745. barMaxWidth: barMaxWidth,
  33746. barMinWidth: barMinWidth,
  33747. barGap: barGap,
  33748. barCategoryGap: barCategoryGap,
  33749. axisKey: getAxisKey(baseAxis),
  33750. stackId: getSeriesStackId(seriesModel)
  33751. })
  33752. })
  33753. return doCalBarWidthAndOffset(seriesInfoList)
  33754. }
  33755. function doCalBarWidthAndOffset(seriesInfoList) {
  33756. // Columns info on each category axis. Key is cartesian name
  33757. var columnsMap = {}
  33758. each$7(seriesInfoList, function (seriesInfo, idx) {
  33759. var axisKey = seriesInfo.axisKey
  33760. var bandWidth = seriesInfo.bandWidth
  33761. var columnsOnAxis = columnsMap[axisKey] || {
  33762. bandWidth: bandWidth,
  33763. remainedWidth: bandWidth,
  33764. autoWidthCount: 0,
  33765. categoryGap: null,
  33766. gap: '20%',
  33767. stacks: {}
  33768. }
  33769. var stacks = columnsOnAxis.stacks
  33770. columnsMap[axisKey] = columnsOnAxis
  33771. var stackId = seriesInfo.stackId
  33772. if (!stacks[stackId]) {
  33773. columnsOnAxis.autoWidthCount++
  33774. }
  33775. stacks[stackId] = stacks[stackId] || { width: 0, maxWidth: 0 } // Caution: In a single coordinate system, these barGrid attributes
  33776. // will be shared by series. Consider that they have default values,
  33777. // only the attributes set on the last series will work.
  33778. // Do not change this fact unless there will be a break change.
  33779. var barWidth = seriesInfo.barWidth
  33780. if (barWidth && !stacks[stackId].width) {
  33781. // See #6312, do not restrict width.
  33782. stacks[stackId].width = barWidth
  33783. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth)
  33784. columnsOnAxis.remainedWidth -= barWidth
  33785. }
  33786. var barMaxWidth = seriesInfo.barMaxWidth
  33787. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth)
  33788. var barMinWidth = seriesInfo.barMinWidth
  33789. barMinWidth && (stacks[stackId].minWidth = barMinWidth)
  33790. var barGap = seriesInfo.barGap
  33791. barGap != null && (columnsOnAxis.gap = barGap)
  33792. var barCategoryGap = seriesInfo.barCategoryGap
  33793. barCategoryGap != null &&
  33794. (columnsOnAxis.categoryGap = barCategoryGap)
  33795. })
  33796. var result = {}
  33797. each$7(columnsMap, function (columnsOnAxis, coordSysName) {
  33798. result[coordSysName] = {}
  33799. var stacks = columnsOnAxis.stacks
  33800. var bandWidth = columnsOnAxis.bandWidth
  33801. var categoryGapPercent = columnsOnAxis.categoryGap
  33802. if (categoryGapPercent == null) {
  33803. var columnCount = keys(stacks).length // More columns in one group
  33804. // the spaces between group is smaller. Or the column will be too thin.
  33805. categoryGapPercent = Math.max(35 - columnCount * 4, 15) + '%'
  33806. }
  33807. var categoryGap = parsePercent(categoryGapPercent, bandWidth)
  33808. var barGapPercent = parsePercent(columnsOnAxis.gap, 1)
  33809. var remainedWidth = columnsOnAxis.remainedWidth
  33810. var autoWidthCount = columnsOnAxis.autoWidthCount
  33811. var autoWidth =
  33812. (remainedWidth - categoryGap) /
  33813. (autoWidthCount + (autoWidthCount - 1) * barGapPercent)
  33814. autoWidth = Math.max(autoWidth, 0) // Find if any auto calculated bar exceeded maxBarWidth
  33815. each$7(stacks, function (column) {
  33816. var maxWidth = column.maxWidth
  33817. var minWidth = column.minWidth
  33818. if (!column.width) {
  33819. var finalWidth = autoWidth
  33820. if (maxWidth && maxWidth < finalWidth) {
  33821. finalWidth = Math.min(maxWidth, remainedWidth)
  33822. } // `minWidth` has higher priority. `minWidth` decide that wheter the
  33823. // bar is able to be visible. So `minWidth` should not be restricted
  33824. // by `maxWidth` or `remainedWidth` (which is from `bandWidth`). In
  33825. // the extreme cases for `value` axis, bars are allowed to overlap
  33826. // with each other if `minWidth` specified.
  33827. if (minWidth && minWidth > finalWidth) {
  33828. finalWidth = minWidth
  33829. }
  33830. if (finalWidth !== autoWidth) {
  33831. column.width = finalWidth
  33832. remainedWidth -= finalWidth + barGapPercent * finalWidth
  33833. autoWidthCount--
  33834. }
  33835. } else {
  33836. // `barMinWidth/barMaxWidth` has higher priority than `barWidth`, as
  33837. // CSS does. Becuase barWidth can be a percent value, where
  33838. // `barMaxWidth` can be used to restrict the final width.
  33839. var finalWidth = column.width
  33840. if (maxWidth) {
  33841. finalWidth = Math.min(finalWidth, maxWidth)
  33842. } // `minWidth` has higher priority, as described above
  33843. if (minWidth) {
  33844. finalWidth = Math.max(finalWidth, minWidth)
  33845. }
  33846. column.width = finalWidth
  33847. remainedWidth -= finalWidth + barGapPercent * finalWidth
  33848. autoWidthCount--
  33849. }
  33850. }) // Recalculate width again
  33851. autoWidth =
  33852. (remainedWidth - categoryGap) /
  33853. (autoWidthCount + (autoWidthCount - 1) * barGapPercent)
  33854. autoWidth = Math.max(autoWidth, 0)
  33855. var widthSum = 0
  33856. var lastColumn
  33857. each$7(stacks, function (column, idx) {
  33858. if (!column.width) {
  33859. column.width = autoWidth
  33860. }
  33861. lastColumn = column
  33862. widthSum += column.width * (1 + barGapPercent)
  33863. })
  33864. if (lastColumn) {
  33865. widthSum -= lastColumn.width * barGapPercent
  33866. }
  33867. var offset = -widthSum / 2
  33868. each$7(stacks, function (column, stackId) {
  33869. result[coordSysName][stackId] = result[coordSysName][
  33870. stackId
  33871. ] || {
  33872. bandWidth: bandWidth,
  33873. offset: offset,
  33874. width: column.width
  33875. }
  33876. offset += column.width * (1 + barGapPercent)
  33877. })
  33878. })
  33879. return result
  33880. }
  33881. function retrieveColumnLayout(barWidthAndOffset, axis, seriesModel) {
  33882. if (barWidthAndOffset && axis) {
  33883. var result = barWidthAndOffset[getAxisKey(axis)]
  33884. if (result != null && seriesModel != null) {
  33885. return result[getSeriesStackId(seriesModel)]
  33886. }
  33887. return result
  33888. }
  33889. }
  33890. function layout$2(seriesType, ecModel) {
  33891. var seriesModels = prepareLayoutBarSeries(seriesType, ecModel)
  33892. var barWidthAndOffset = makeColumnLayout(seriesModels)
  33893. each$7(seriesModels, function (seriesModel) {
  33894. var data = seriesModel.getData()
  33895. var cartesian = seriesModel.coordinateSystem
  33896. var baseAxis = cartesian.getBaseAxis()
  33897. var stackId = getSeriesStackId(seriesModel)
  33898. var columnLayoutInfo =
  33899. barWidthAndOffset[getAxisKey(baseAxis)][stackId]
  33900. var columnOffset = columnLayoutInfo.offset
  33901. var columnWidth = columnLayoutInfo.width
  33902. data.setLayout({
  33903. bandWidth: columnLayoutInfo.bandWidth,
  33904. offset: columnOffset,
  33905. size: columnWidth
  33906. })
  33907. })
  33908. } // TODO: Do not support stack in large mode yet.
  33909. function createProgressiveLayout(seriesType) {
  33910. return {
  33911. seriesType: seriesType,
  33912. plan: createRenderPlanner(),
  33913. reset: function reset(seriesModel) {
  33914. if (!isOnCartesian(seriesModel)) {
  33915. return
  33916. }
  33917. var data = seriesModel.getData()
  33918. var cartesian = seriesModel.coordinateSystem
  33919. var baseAxis = cartesian.getBaseAxis()
  33920. var valueAxis = cartesian.getOtherAxis(baseAxis)
  33921. var valueDimIdx = data.getDimensionIndex(
  33922. data.mapDimension(valueAxis.dim)
  33923. )
  33924. var baseDimIdx = data.getDimensionIndex(
  33925. data.mapDimension(baseAxis.dim)
  33926. )
  33927. var drawBackground = seriesModel.get('showBackground', true)
  33928. var valueDim = data.mapDimension(valueAxis.dim)
  33929. var stackResultDim = data.getCalculationInfo(
  33930. 'stackResultDimension'
  33931. )
  33932. var stacked =
  33933. isDimensionStacked(data, valueDim) &&
  33934. !!data.getCalculationInfo('stackedOnSeries')
  33935. var isValueAxisH = valueAxis.isHorizontal()
  33936. var valueAxisStart = getValueAxisStart(baseAxis, valueAxis)
  33937. var isLarge = isInLargeMode(seriesModel)
  33938. var barMinHeight = seriesModel.get('barMinHeight') || 0
  33939. var stackedDimIdx =
  33940. stackResultDim && data.getDimensionIndex(stackResultDim) // Layout info.
  33941. var columnWidth = data.getLayout('size')
  33942. var columnOffset = data.getLayout('offset')
  33943. return {
  33944. progress: function progress(params, data) {
  33945. var count = params.count
  33946. var largePoints = isLarge && createFloat32Array(count * 3)
  33947. var largeBackgroundPoints =
  33948. isLarge && drawBackground && createFloat32Array(count * 3)
  33949. var largeDataIndices = isLarge && createFloat32Array(count)
  33950. var coordLayout = cartesian.master.getRect()
  33951. var bgSize = isValueAxisH
  33952. ? coordLayout.width
  33953. : coordLayout.height
  33954. var dataIndex
  33955. var store = data.getStore()
  33956. var idxOffset = 0
  33957. while ((dataIndex = params.next()) != null) {
  33958. var value = store.get(
  33959. stacked ? stackedDimIdx : valueDimIdx,
  33960. dataIndex
  33961. )
  33962. var baseValue = store.get(baseDimIdx, dataIndex)
  33963. var baseCoord = valueAxisStart
  33964. var startValue = void 0 // Because of the barMinHeight, we can not use the value in
  33965. // stackResultDimension directly.
  33966. if (stacked) {
  33967. startValue = +value - store.get(valueDimIdx, dataIndex)
  33968. }
  33969. var x = void 0
  33970. var y = void 0
  33971. var width = void 0
  33972. var height = void 0
  33973. if (isValueAxisH) {
  33974. var coord = cartesian.dataToPoint([value, baseValue])
  33975. if (stacked) {
  33976. var startCoord = cartesian.dataToPoint([
  33977. startValue,
  33978. baseValue
  33979. ])
  33980. baseCoord = startCoord[0]
  33981. }
  33982. x = baseCoord
  33983. y = coord[1] + columnOffset
  33984. width = coord[0] - baseCoord
  33985. height = columnWidth
  33986. if (Math.abs(width) < barMinHeight) {
  33987. width = (width < 0 ? -1 : 1) * barMinHeight
  33988. }
  33989. } else {
  33990. var coord = cartesian.dataToPoint([baseValue, value])
  33991. if (stacked) {
  33992. var startCoord = cartesian.dataToPoint([
  33993. baseValue,
  33994. startValue
  33995. ])
  33996. baseCoord = startCoord[1]
  33997. }
  33998. x = coord[0] + columnOffset
  33999. y = baseCoord
  34000. width = columnWidth
  34001. height = coord[1] - baseCoord
  34002. if (Math.abs(height) < barMinHeight) {
  34003. // Include zero to has a positive bar
  34004. height = (height <= 0 ? -1 : 1) * barMinHeight
  34005. }
  34006. }
  34007. if (!isLarge) {
  34008. data.setItemLayout(dataIndex, {
  34009. x: x,
  34010. y: y,
  34011. width: width,
  34012. height: height
  34013. })
  34014. } else {
  34015. largePoints[idxOffset] = x
  34016. largePoints[idxOffset + 1] = y
  34017. largePoints[idxOffset + 2] = isValueAxisH
  34018. ? width
  34019. : height
  34020. if (largeBackgroundPoints) {
  34021. largeBackgroundPoints[idxOffset] = isValueAxisH
  34022. ? coordLayout.x
  34023. : x
  34024. largeBackgroundPoints[idxOffset + 1] = isValueAxisH
  34025. ? y
  34026. : coordLayout.y
  34027. largeBackgroundPoints[idxOffset + 2] = bgSize
  34028. }
  34029. largeDataIndices[dataIndex] = dataIndex
  34030. }
  34031. idxOffset += 3
  34032. }
  34033. if (isLarge) {
  34034. data.setLayout({
  34035. largePoints: largePoints,
  34036. largeDataIndices: largeDataIndices,
  34037. largeBackgroundPoints: largeBackgroundPoints,
  34038. valueAxisHorizontal: isValueAxisH
  34039. })
  34040. }
  34041. }
  34042. }
  34043. }
  34044. }
  34045. }
  34046. function isOnCartesian(seriesModel) {
  34047. return (
  34048. seriesModel.coordinateSystem &&
  34049. seriesModel.coordinateSystem.type === 'cartesian2d'
  34050. )
  34051. }
  34052. function isInLargeMode(seriesModel) {
  34053. return (
  34054. seriesModel.pipelineContext && seriesModel.pipelineContext.large
  34055. )
  34056. } // See cases in `test/bar-start.html` and `#7412`, `#8747`.
  34057. function getValueAxisStart(baseAxis, valueAxis) {
  34058. return valueAxis.toGlobalCoord(
  34059. valueAxis.dataToCoord(valueAxis.type === 'log' ? 1 : 0)
  34060. )
  34061. }
  34062. var bisect = function bisect(a, x, lo, hi) {
  34063. while (lo < hi) {
  34064. var mid = (lo + hi) >>> 1
  34065. if (a[mid][1] < x) {
  34066. lo = mid + 1
  34067. } else {
  34068. hi = mid
  34069. }
  34070. }
  34071. return lo
  34072. }
  34073. var TimeScale = /** @class */ (function (_super) {
  34074. __extends(TimeScale, _super)
  34075. function TimeScale(settings) {
  34076. var _this = _super.call(this, settings) || this
  34077. _this.type = 'time'
  34078. return _this
  34079. }
  34080. /**
  34081. * Get label is mainly for other components like dataZoom, tooltip.
  34082. */ TimeScale.prototype.getLabel = function (tick) {
  34083. var useUTC = this.getSetting('useUTC')
  34084. return format(
  34085. tick.value,
  34086. fullLeveledFormatter[
  34087. getDefaultFormatPrecisionOfInterval(
  34088. getPrimaryTimeUnit(this._minLevelUnit)
  34089. )
  34090. ] || fullLeveledFormatter.second,
  34091. useUTC,
  34092. this.getSetting('locale')
  34093. )
  34094. }
  34095. TimeScale.prototype.getFormattedLabel = function (
  34096. tick,
  34097. idx,
  34098. labelFormatter
  34099. ) {
  34100. var isUTC = this.getSetting('useUTC')
  34101. var lang = this.getSetting('locale')
  34102. return leveledFormat(tick, idx, labelFormatter, lang, isUTC)
  34103. }
  34104. /**
  34105. * @override
  34106. */ TimeScale.prototype.getTicks = function () {
  34107. var interval = this._interval
  34108. var extent = this._extent
  34109. var ticks = [] // If interval is 0, return [];
  34110. if (!interval) {
  34111. return ticks
  34112. }
  34113. ticks.push({ value: extent[0], level: 0 })
  34114. var useUTC = this.getSetting('useUTC')
  34115. var innerTicks = getIntervalTicks(
  34116. this._minLevelUnit,
  34117. this._approxInterval,
  34118. useUTC,
  34119. extent
  34120. )
  34121. ticks = ticks.concat(innerTicks)
  34122. ticks.push({ value: extent[1], level: 0 })
  34123. return ticks
  34124. }
  34125. TimeScale.prototype.calcNiceExtent = function (opt) {
  34126. var extent = this._extent // If extent start and end are same, expand them
  34127. if (extent[0] === extent[1]) {
  34128. // Expand extent
  34129. extent[0] -= ONE_DAY
  34130. extent[1] += ONE_DAY
  34131. } // If there are no data and extent are [Infinity, -Infinity]
  34132. if (extent[1] === -Infinity && extent[0] === Infinity) {
  34133. var d = new Date()
  34134. extent[1] = +new Date(
  34135. d.getFullYear(),
  34136. d.getMonth(),
  34137. d.getDate()
  34138. )
  34139. extent[0] = extent[1] - ONE_DAY
  34140. }
  34141. this.calcNiceTicks(
  34142. opt.splitNumber,
  34143. opt.minInterval,
  34144. opt.maxInterval
  34145. )
  34146. }
  34147. TimeScale.prototype.calcNiceTicks = function (
  34148. approxTickNum,
  34149. minInterval,
  34150. maxInterval
  34151. ) {
  34152. approxTickNum = approxTickNum || 10
  34153. var extent = this._extent
  34154. var span = extent[1] - extent[0]
  34155. this._approxInterval = span / approxTickNum
  34156. if (minInterval != null && this._approxInterval < minInterval) {
  34157. this._approxInterval = minInterval
  34158. }
  34159. if (maxInterval != null && this._approxInterval > maxInterval) {
  34160. this._approxInterval = maxInterval
  34161. }
  34162. var scaleIntervalsLen = scaleIntervals.length
  34163. var idx = Math.min(
  34164. bisect(
  34165. scaleIntervals,
  34166. this._approxInterval,
  34167. 0,
  34168. scaleIntervalsLen
  34169. ),
  34170. scaleIntervalsLen - 1
  34171. ) // Interval that can be used to calculate ticks
  34172. this._interval = scaleIntervals[idx][1] // Min level used when picking ticks from top down.
  34173. // We check one more level to avoid the ticks are to sparse in some case.
  34174. this._minLevelUnit = scaleIntervals[Math.max(idx - 1, 0)][0]
  34175. }
  34176. TimeScale.prototype.parse = function (val) {
  34177. // val might be float.
  34178. return isNumber(val) ? val : +parseDate(val)
  34179. }
  34180. TimeScale.prototype.contain = function (val) {
  34181. return contain(this.parse(val), this._extent)
  34182. }
  34183. TimeScale.prototype.normalize = function (val) {
  34184. return normalize(this.parse(val), this._extent)
  34185. }
  34186. TimeScale.prototype.scale = function (val) {
  34187. return scale(val, this._extent)
  34188. }
  34189. TimeScale.type = 'time'
  34190. return TimeScale
  34191. })(IntervalScale$1)
  34192. /**
  34193. * This implementation was originally copied from "d3.js"
  34194. * <https://github.com/d3/d3/blob/b516d77fb8566b576088e73410437494717ada26/src/time/scale.js>
  34195. * with some modifications made for this program.
  34196. * See the license statement at the head of this file.
  34197. */ var scaleIntervals = [
  34198. // Format interval
  34199. ['second', ONE_SECOND],
  34200. ['minute', ONE_MINUTE],
  34201. ['hour', ONE_HOUR],
  34202. ['quarter-day', ONE_HOUR * 6],
  34203. ['half-day', ONE_HOUR * 12],
  34204. ['day', ONE_DAY * 1.2],
  34205. ['half-week', ONE_DAY * 3.5],
  34206. ['week', ONE_DAY * 7],
  34207. ['month', ONE_DAY * 31],
  34208. ['quarter', ONE_DAY * 95],
  34209. ['half-year', ONE_YEAR / 2],
  34210. ['year', ONE_YEAR] // 1Y
  34211. ]
  34212. function isUnitValueSame(unit, valueA, valueB, isUTC) {
  34213. var dateA = parseDate(valueA)
  34214. var dateB = parseDate(valueB)
  34215. var isSame = function isSame(unit) {
  34216. return (
  34217. getUnitValue(dateA, unit, isUTC) ===
  34218. getUnitValue(dateB, unit, isUTC)
  34219. )
  34220. }
  34221. var isSameYear = function isSameYear() {
  34222. return isSame('year')
  34223. } // const isSameHalfYear = () => isSameYear() && isSame('half-year');
  34224. // const isSameQuater = () => isSameYear() && isSame('quarter');
  34225. var isSameMonth = function isSameMonth() {
  34226. return isSameYear() && isSame('month')
  34227. }
  34228. var isSameDay = function isSameDay() {
  34229. return isSameMonth() && isSame('day')
  34230. } // const isSameHalfDay = () => isSameDay() && isSame('half-day');
  34231. var isSameHour = function isSameHour() {
  34232. return isSameDay() && isSame('hour')
  34233. }
  34234. var isSameMinute = function isSameMinute() {
  34235. return isSameHour() && isSame('minute')
  34236. }
  34237. var isSameSecond = function isSameSecond() {
  34238. return isSameMinute() && isSame('second')
  34239. }
  34240. var isSameMilliSecond = function isSameMilliSecond() {
  34241. return isSameSecond() && isSame('millisecond')
  34242. }
  34243. switch (unit) {
  34244. case 'year':
  34245. return isSameYear()
  34246. case 'month':
  34247. return isSameMonth()
  34248. case 'day':
  34249. return isSameDay()
  34250. case 'hour':
  34251. return isSameHour()
  34252. case 'minute':
  34253. return isSameMinute()
  34254. case 'second':
  34255. return isSameSecond()
  34256. case 'millisecond':
  34257. return isSameMilliSecond()
  34258. }
  34259. } // const primaryUnitGetters = {
  34260. // year: fullYearGetterName(),
  34261. // month: monthGetterName(),
  34262. // day: dateGetterName(),
  34263. // hour: hoursGetterName(),
  34264. // minute: minutesGetterName(),
  34265. // second: secondsGetterName(),
  34266. // millisecond: millisecondsGetterName()
  34267. // };
  34268. // const primaryUnitUTCGetters = {
  34269. // year: fullYearGetterName(true),
  34270. // month: monthGetterName(true),
  34271. // day: dateGetterName(true),
  34272. // hour: hoursGetterName(true),
  34273. // minute: minutesGetterName(true),
  34274. // second: secondsGetterName(true),
  34275. // millisecond: millisecondsGetterName(true)
  34276. // };
  34277. // function moveTick(date: Date, unitName: TimeUnit, step: number, isUTC: boolean) {
  34278. // step = step || 1;
  34279. // switch (getPrimaryTimeUnit(unitName)) {
  34280. // case 'year':
  34281. // date[fullYearSetterName(isUTC)](date[fullYearGetterName(isUTC)]() + step);
  34282. // break;
  34283. // case 'month':
  34284. // date[monthSetterName(isUTC)](date[monthGetterName(isUTC)]() + step);
  34285. // break;
  34286. // case 'day':
  34287. // date[dateSetterName(isUTC)](date[dateGetterName(isUTC)]() + step);
  34288. // break;
  34289. // case 'hour':
  34290. // date[hoursSetterName(isUTC)](date[hoursGetterName(isUTC)]() + step);
  34291. // break;
  34292. // case 'minute':
  34293. // date[minutesSetterName(isUTC)](date[minutesGetterName(isUTC)]() + step);
  34294. // break;
  34295. // case 'second':
  34296. // date[secondsSetterName(isUTC)](date[secondsGetterName(isUTC)]() + step);
  34297. // break;
  34298. // case 'millisecond':
  34299. // date[millisecondsSetterName(isUTC)](date[millisecondsGetterName(isUTC)]() + step);
  34300. // break;
  34301. // }
  34302. // return date.getTime();
  34303. // }
  34304. // const DATE_INTERVALS = [[8, 7.5], [4, 3.5], [2, 1.5]];
  34305. // const MONTH_INTERVALS = [[6, 5.5], [3, 2.5], [2, 1.5]];
  34306. // const MINUTES_SECONDS_INTERVALS = [[30, 30], [20, 20], [15, 15], [10, 10], [5, 5], [2, 2]];
  34307. function getDateInterval(approxInterval, daysInMonth) {
  34308. approxInterval /= ONE_DAY
  34309. return approxInterval > 16
  34310. ? 16 // Math.floor(daysInMonth / 2) + 1 // In this case we only want one tick betwen two month.
  34311. : approxInterval > 7.5
  34312. ? 7 // TODO week 7 or day 8?
  34313. : approxInterval > 3.5
  34314. ? 4
  34315. : approxInterval > 1.5
  34316. ? 2
  34317. : 1
  34318. }
  34319. function getMonthInterval(approxInterval) {
  34320. var APPROX_ONE_MONTH = 30 * ONE_DAY
  34321. approxInterval /= APPROX_ONE_MONTH
  34322. return approxInterval > 6
  34323. ? 6
  34324. : approxInterval > 3
  34325. ? 3
  34326. : approxInterval > 2
  34327. ? 2
  34328. : 1
  34329. }
  34330. function getHourInterval(approxInterval) {
  34331. approxInterval /= ONE_HOUR
  34332. return approxInterval > 12
  34333. ? 12
  34334. : approxInterval > 6
  34335. ? 6
  34336. : approxInterval > 3.5
  34337. ? 4
  34338. : approxInterval > 2
  34339. ? 2
  34340. : 1
  34341. }
  34342. function getMinutesAndSecondsInterval(approxInterval, isMinutes) {
  34343. approxInterval /= isMinutes ? ONE_MINUTE : ONE_SECOND
  34344. return approxInterval > 30
  34345. ? 30
  34346. : approxInterval > 20
  34347. ? 20
  34348. : approxInterval > 15
  34349. ? 15
  34350. : approxInterval > 10
  34351. ? 10
  34352. : approxInterval > 5
  34353. ? 5
  34354. : approxInterval > 2
  34355. ? 2
  34356. : 1
  34357. }
  34358. function getMillisecondsInterval(approxInterval) {
  34359. return nice(approxInterval, true)
  34360. }
  34361. function getFirstTimestampOfUnit(date, unitName, isUTC) {
  34362. var outDate = new Date(date)
  34363. switch (getPrimaryTimeUnit(unitName)) {
  34364. case 'year':
  34365. case 'month':
  34366. outDate[monthSetterName(isUTC)](0)
  34367. case 'day':
  34368. outDate[dateSetterName(isUTC)](1)
  34369. case 'hour':
  34370. outDate[hoursSetterName(isUTC)](0)
  34371. case 'minute':
  34372. outDate[minutesSetterName(isUTC)](0)
  34373. case 'second':
  34374. outDate[secondsSetterName(isUTC)](0)
  34375. outDate[millisecondsSetterName(isUTC)](0)
  34376. }
  34377. return outDate.getTime()
  34378. }
  34379. function getIntervalTicks(
  34380. bottomUnitName,
  34381. approxInterval,
  34382. isUTC,
  34383. extent
  34384. ) {
  34385. var safeLimit = 10000
  34386. var unitNames = timeUnits
  34387. var iter = 0
  34388. function addTicksInSpan(
  34389. interval,
  34390. minTimestamp,
  34391. maxTimestamp,
  34392. getMethodName,
  34393. setMethodName,
  34394. isDate,
  34395. out
  34396. ) {
  34397. var date = new Date(minTimestamp)
  34398. var dateTime = minTimestamp
  34399. var d = date[getMethodName]() // if (isDate) {
  34400. // d -= 1; // Starts with 0; PENDING
  34401. // }
  34402. while (dateTime < maxTimestamp && dateTime <= extent[1]) {
  34403. out.push({ value: dateTime })
  34404. d += interval
  34405. date[setMethodName](d)
  34406. dateTime = date.getTime()
  34407. } // This extra tick is for calcuating ticks of next level. Will not been added to the final result
  34408. out.push({ value: dateTime, notAdd: true })
  34409. }
  34410. function addLevelTicks(unitName, lastLevelTicks, levelTicks) {
  34411. var newAddedTicks = []
  34412. var isFirstLevel = !lastLevelTicks.length
  34413. if (
  34414. isUnitValueSame(
  34415. getPrimaryTimeUnit(unitName),
  34416. extent[0],
  34417. extent[1],
  34418. isUTC
  34419. )
  34420. ) {
  34421. return
  34422. }
  34423. if (isFirstLevel) {
  34424. lastLevelTicks = [
  34425. {
  34426. // TODO Optimize. Not include so may ticks.
  34427. value: getFirstTimestampOfUnit(
  34428. new Date(extent[0]),
  34429. unitName,
  34430. isUTC
  34431. )
  34432. },
  34433. { value: extent[1] }
  34434. ]
  34435. }
  34436. for (var i = 0; i < lastLevelTicks.length - 1; i++) {
  34437. var startTick = lastLevelTicks[i].value
  34438. var endTick = lastLevelTicks[i + 1].value
  34439. if (startTick === endTick) {
  34440. continue
  34441. }
  34442. var interval = void 0
  34443. var getterName = void 0
  34444. var setterName = void 0
  34445. var isDate = false
  34446. switch (unitName) {
  34447. case 'year':
  34448. interval = Math.max(
  34449. 1,
  34450. Math.round(approxInterval / ONE_DAY / 365)
  34451. )
  34452. getterName = fullYearGetterName(isUTC)
  34453. setterName = fullYearSetterName(isUTC)
  34454. break
  34455. case 'half-year':
  34456. case 'quarter':
  34457. case 'month':
  34458. interval = getMonthInterval(approxInterval)
  34459. getterName = monthGetterName(isUTC)
  34460. setterName = monthSetterName(isUTC)
  34461. break
  34462. case 'week': // PENDING If week is added. Ignore day.
  34463. case 'half-week':
  34464. case 'day':
  34465. interval = getDateInterval(approxInterval) // Use 32 days and let interval been 16
  34466. getterName = dateGetterName(isUTC)
  34467. setterName = dateSetterName(isUTC)
  34468. isDate = true
  34469. break
  34470. case 'half-day':
  34471. case 'quarter-day':
  34472. case 'hour':
  34473. interval = getHourInterval(approxInterval)
  34474. getterName = hoursGetterName(isUTC)
  34475. setterName = hoursSetterName(isUTC)
  34476. break
  34477. case 'minute':
  34478. interval = getMinutesAndSecondsInterval(
  34479. approxInterval,
  34480. true
  34481. )
  34482. getterName = minutesGetterName(isUTC)
  34483. setterName = minutesSetterName(isUTC)
  34484. break
  34485. case 'second':
  34486. interval = getMinutesAndSecondsInterval(
  34487. approxInterval,
  34488. false
  34489. )
  34490. getterName = secondsGetterName(isUTC)
  34491. setterName = secondsSetterName(isUTC)
  34492. break
  34493. case 'millisecond':
  34494. interval = getMillisecondsInterval(approxInterval)
  34495. getterName = millisecondsGetterName(isUTC)
  34496. setterName = millisecondsSetterName(isUTC)
  34497. break
  34498. }
  34499. addTicksInSpan(
  34500. interval,
  34501. startTick,
  34502. endTick,
  34503. getterName,
  34504. setterName,
  34505. isDate,
  34506. newAddedTicks
  34507. )
  34508. if (unitName === 'year' && levelTicks.length > 1 && i === 0) {
  34509. // Add nearest years to the left extent.
  34510. levelTicks.unshift({ value: levelTicks[0].value - interval })
  34511. }
  34512. }
  34513. for (var i = 0; i < newAddedTicks.length; i++) {
  34514. levelTicks.push(newAddedTicks[i])
  34515. } // newAddedTicks.length && console.log(unitName, newAddedTicks);
  34516. return newAddedTicks
  34517. }
  34518. var levelsTicks = []
  34519. var currentLevelTicks = []
  34520. var tickCount = 0
  34521. var lastLevelTickCount = 0
  34522. for (var i = 0; i < unitNames.length && iter++ < safeLimit; ++i) {
  34523. var primaryTimeUnit = getPrimaryTimeUnit(unitNames[i])
  34524. if (!isPrimaryTimeUnit(unitNames[i])) {
  34525. // TODO
  34526. continue
  34527. }
  34528. addLevelTicks(
  34529. unitNames[i],
  34530. levelsTicks[levelsTicks.length - 1] || [],
  34531. currentLevelTicks
  34532. )
  34533. var nextPrimaryTimeUnit = unitNames[i + 1]
  34534. ? getPrimaryTimeUnit(unitNames[i + 1])
  34535. : null
  34536. if (primaryTimeUnit !== nextPrimaryTimeUnit) {
  34537. if (currentLevelTicks.length) {
  34538. lastLevelTickCount = tickCount // Remove the duplicate so the tick count can be precisely.
  34539. currentLevelTicks.sort(function (a, b) {
  34540. return a.value - b.value
  34541. })
  34542. var levelTicksRemoveDuplicated = []
  34543. for (var i_1 = 0; i_1 < currentLevelTicks.length; ++i_1) {
  34544. var tickValue = currentLevelTicks[i_1].value
  34545. if (
  34546. i_1 === 0 ||
  34547. currentLevelTicks[i_1 - 1].value !== tickValue
  34548. ) {
  34549. levelTicksRemoveDuplicated.push(currentLevelTicks[i_1])
  34550. if (tickValue >= extent[0] && tickValue <= extent[1]) {
  34551. tickCount++
  34552. }
  34553. }
  34554. }
  34555. var targetTickNum = (extent[1] - extent[0]) / approxInterval // Added too much in this level and not too less in last level
  34556. if (
  34557. tickCount > targetTickNum * 1.5 &&
  34558. lastLevelTickCount > targetTickNum / 1.5
  34559. ) {
  34560. break
  34561. } // Only treat primary time unit as one level.
  34562. levelsTicks.push(levelTicksRemoveDuplicated)
  34563. if (
  34564. tickCount > targetTickNum ||
  34565. bottomUnitName === unitNames[i]
  34566. ) {
  34567. break
  34568. }
  34569. } // Reset if next unitName is primary
  34570. currentLevelTicks = []
  34571. }
  34572. }
  34573. var levelsTicksInExtent = filter(
  34574. map$1(levelsTicks, function (levelTicks) {
  34575. return filter(levelTicks, function (tick) {
  34576. return (
  34577. tick.value >= extent[0] &&
  34578. tick.value <= extent[1] &&
  34579. !tick.notAdd
  34580. )
  34581. })
  34582. }),
  34583. function (levelTicks) {
  34584. return levelTicks.length > 0
  34585. }
  34586. )
  34587. var ticks = []
  34588. var maxLevel = levelsTicksInExtent.length - 1
  34589. for (var i = 0; i < levelsTicksInExtent.length; ++i) {
  34590. var levelTicks = levelsTicksInExtent[i]
  34591. for (var k = 0; k < levelTicks.length; ++k) {
  34592. ticks.push({ value: levelTicks[k].value, level: maxLevel - i })
  34593. }
  34594. }
  34595. ticks.sort(function (a, b) {
  34596. return a.value - b.value
  34597. }) // Remove duplicates
  34598. var result = []
  34599. for (var i = 0; i < ticks.length; ++i) {
  34600. if (i === 0 || ticks[i].value !== ticks[i - 1].value) {
  34601. result.push(ticks[i])
  34602. }
  34603. }
  34604. return result
  34605. }
  34606. Scale$1.registerClass(TimeScale)
  34607. var TimeScale$1 = TimeScale
  34608. var scaleProto = Scale$1.prototype // FIXME:TS refactor: not good to call it directly with `this`?
  34609. var intervalScaleProto = IntervalScale$1.prototype
  34610. var roundingErrorFix = round$1
  34611. var mathFloor = Math.floor
  34612. var mathCeil = Math.ceil
  34613. var mathPow$1 = Math.pow
  34614. var mathLog$1 = Math.log
  34615. var LogScale = /** @class */ (function (_super) {
  34616. __extends(LogScale, _super)
  34617. function LogScale() {
  34618. var _this =
  34619. (_super !== null && _super.apply(this, arguments)) || this
  34620. _this.type = 'log'
  34621. _this.base = 10
  34622. _this._originalScale = new IntervalScale$1() // FIXME:TS actually used by `IntervalScale`
  34623. _this._interval = 0
  34624. return _this
  34625. }
  34626. /**
  34627. * @param Whether expand the ticks to niced extent.
  34628. */ LogScale.prototype.getTicks = function (expandToNicedExtent) {
  34629. var originalScale = this._originalScale
  34630. var extent = this._extent
  34631. var originalExtent = originalScale.getExtent()
  34632. var ticks = intervalScaleProto.getTicks.call(
  34633. this,
  34634. expandToNicedExtent
  34635. )
  34636. return map$1(
  34637. ticks,
  34638. function (tick) {
  34639. var val = tick.value
  34640. var powVal = round$1(mathPow$1(this.base, val)) // Fix #4158
  34641. powVal =
  34642. val === extent[0] && this._fixMin
  34643. ? fixRoundingError(powVal, originalExtent[0])
  34644. : powVal
  34645. powVal =
  34646. val === extent[1] && this._fixMax
  34647. ? fixRoundingError(powVal, originalExtent[1])
  34648. : powVal
  34649. return { value: powVal }
  34650. },
  34651. this
  34652. )
  34653. }
  34654. LogScale.prototype.setExtent = function (start, end) {
  34655. var base = this.base
  34656. start = mathLog$1(start) / mathLog$1(base)
  34657. end = mathLog$1(end) / mathLog$1(base)
  34658. intervalScaleProto.setExtent.call(this, start, end)
  34659. }
  34660. /**
  34661. * @return {number} end
  34662. */ LogScale.prototype.getExtent = function () {
  34663. var base = this.base
  34664. var extent = scaleProto.getExtent.call(this)
  34665. extent[0] = mathPow$1(base, extent[0])
  34666. extent[1] = mathPow$1(base, extent[1]) // Fix #4158
  34667. var originalScale = this._originalScale
  34668. var originalExtent = originalScale.getExtent()
  34669. this._fixMin &&
  34670. (extent[0] = fixRoundingError(extent[0], originalExtent[0]))
  34671. this._fixMax &&
  34672. (extent[1] = fixRoundingError(extent[1], originalExtent[1]))
  34673. return extent
  34674. }
  34675. LogScale.prototype.unionExtent = function (extent) {
  34676. this._originalScale.unionExtent(extent)
  34677. var base = this.base
  34678. extent[0] = mathLog$1(extent[0]) / mathLog$1(base)
  34679. extent[1] = mathLog$1(extent[1]) / mathLog$1(base)
  34680. scaleProto.unionExtent.call(this, extent)
  34681. }
  34682. LogScale.prototype.unionExtentFromData = function (data, dim) {
  34683. // TODO
  34684. // filter value that <= 0
  34685. this.unionExtent(data.getApproximateExtent(dim))
  34686. }
  34687. /**
  34688. * Update interval and extent of intervals for nice ticks
  34689. * @param approxTickNum default 10 Given approx tick number
  34690. */ LogScale.prototype.calcNiceTicks = function (approxTickNum) {
  34691. approxTickNum = approxTickNum || 10
  34692. var extent = this._extent
  34693. var span = extent[1] - extent[0]
  34694. if (span === Infinity || span <= 0) {
  34695. return
  34696. }
  34697. var interval = quantity(span)
  34698. var err = (approxTickNum / span) * interval // Filter ticks to get closer to the desired count.
  34699. if (err <= 0.5) {
  34700. interval *= 10
  34701. } // Interval should be integer
  34702. while (
  34703. !isNaN(interval) &&
  34704. Math.abs(interval) < 1 &&
  34705. Math.abs(interval) > 0
  34706. ) {
  34707. interval *= 10
  34708. }
  34709. var niceExtent = [
  34710. round$1(mathCeil(extent[0] / interval) * interval),
  34711. round$1(mathFloor(extent[1] / interval) * interval)
  34712. ]
  34713. this._interval = interval
  34714. this._niceExtent = niceExtent
  34715. }
  34716. LogScale.prototype.calcNiceExtent = function (opt) {
  34717. intervalScaleProto.calcNiceExtent.call(this, opt)
  34718. this._fixMin = opt.fixMin
  34719. this._fixMax = opt.fixMax
  34720. }
  34721. LogScale.prototype.parse = function (val) {
  34722. return val
  34723. }
  34724. LogScale.prototype.contain = function (val) {
  34725. val = mathLog$1(val) / mathLog$1(this.base)
  34726. return contain(val, this._extent)
  34727. }
  34728. LogScale.prototype.normalize = function (val) {
  34729. val = mathLog$1(val) / mathLog$1(this.base)
  34730. return normalize(val, this._extent)
  34731. }
  34732. LogScale.prototype.scale = function (val) {
  34733. val = scale(val, this._extent)
  34734. return mathPow$1(this.base, val)
  34735. }
  34736. LogScale.type = 'log'
  34737. return LogScale
  34738. })(Scale$1)
  34739. var proto = LogScale.prototype
  34740. proto.getMinorTicks = intervalScaleProto.getMinorTicks
  34741. proto.getLabel = intervalScaleProto.getLabel
  34742. function fixRoundingError(val, originalVal) {
  34743. return roundingErrorFix(val, getPrecision(originalVal))
  34744. }
  34745. Scale$1.registerClass(LogScale)
  34746. var LogScale$1 = LogScale
  34747. var ScaleRawExtentInfo = /** @class */ (function () {
  34748. function ScaleRawExtentInfo(
  34749. scale,
  34750. model, // Usually: data extent from all series on this axis.
  34751. originalExtent
  34752. ) {
  34753. this._prepareParams(scale, model, originalExtent)
  34754. }
  34755. /**
  34756. * Parameters depending on ouside (like model, user callback)
  34757. * are prepared and fixed here.
  34758. */ ScaleRawExtentInfo.prototype._prepareParams = function (
  34759. scale,
  34760. model, // Usually: data extent from all series on this axis.
  34761. dataExtent
  34762. ) {
  34763. if (dataExtent[1] < dataExtent[0]) {
  34764. dataExtent = [NaN, NaN]
  34765. }
  34766. this._dataMin = dataExtent[0]
  34767. this._dataMax = dataExtent[1]
  34768. var isOrdinal = (this._isOrdinal = scale.type === 'ordinal')
  34769. this._needCrossZero =
  34770. scale.type === 'interval' &&
  34771. model.getNeedCrossZero &&
  34772. model.getNeedCrossZero()
  34773. var modelMinRaw = (this._modelMinRaw = model.get('min', true))
  34774. if (isFunction(modelMinRaw)) {
  34775. // This callback alway provide users the full data extent (before data filtered).
  34776. this._modelMinNum = parseAxisModelMinMax(
  34777. scale,
  34778. modelMinRaw({ min: dataExtent[0], max: dataExtent[1] })
  34779. )
  34780. } else if (modelMinRaw !== 'dataMin') {
  34781. this._modelMinNum = parseAxisModelMinMax(scale, modelMinRaw)
  34782. }
  34783. var modelMaxRaw = (this._modelMaxRaw = model.get('max', true))
  34784. if (isFunction(modelMaxRaw)) {
  34785. // This callback alway provide users the full data extent (before data filtered).
  34786. this._modelMaxNum = parseAxisModelMinMax(
  34787. scale,
  34788. modelMaxRaw({ min: dataExtent[0], max: dataExtent[1] })
  34789. )
  34790. } else if (modelMaxRaw !== 'dataMax') {
  34791. this._modelMaxNum = parseAxisModelMinMax(scale, modelMaxRaw)
  34792. }
  34793. if (isOrdinal) {
  34794. // FIXME: there is a flaw here: if there is no "block" data processor like `dataZoom`,
  34795. // and progressive rendering is using, here the category result might just only contain
  34796. // the processed chunk rather than the entire result.
  34797. this._axisDataLen = model.getCategories().length
  34798. } else {
  34799. var boundaryGap = model.get('boundaryGap')
  34800. var boundaryGapArr = isArray(boundaryGap)
  34801. ? boundaryGap
  34802. : [boundaryGap || 0, boundaryGap || 0]
  34803. if (
  34804. typeof boundaryGapArr[0] === 'boolean' ||
  34805. typeof boundaryGapArr[1] === 'boolean'
  34806. ) {
  34807. this._boundaryGapInner = [0, 0]
  34808. } else {
  34809. this._boundaryGapInner = [
  34810. parsePercent$1(boundaryGapArr[0], 1),
  34811. parsePercent$1(boundaryGapArr[1], 1)
  34812. ]
  34813. }
  34814. }
  34815. }
  34816. /**
  34817. * Calculate extent by prepared parameters.
  34818. * This method has no external dependency and can be called duplicatedly,
  34819. * getting the same result.
  34820. * If parameters changed, should call this method to recalcuate.
  34821. */ ScaleRawExtentInfo.prototype.calculate = function () {
  34822. // Notice: When min/max is not set (that is, when there are null/undefined,
  34823. // which is the most common case), these cases should be ensured:
  34824. // (1) For 'ordinal', show all axis.data.
  34825. // (2) For others:
  34826. // + `boundaryGap` is applied (if min/max set, boundaryGap is
  34827. // disabled).
  34828. // + If `needCrossZero`, min/max should be zero, otherwise, min/max should
  34829. // be the result that originalExtent enlarged by boundaryGap.
  34830. // (3) If no data, it should be ensured that `scale.setBlank` is set.
  34831. var isOrdinal = this._isOrdinal
  34832. var dataMin = this._dataMin
  34833. var dataMax = this._dataMax
  34834. var axisDataLen = this._axisDataLen
  34835. var boundaryGapInner = this._boundaryGapInner
  34836. var span = !isOrdinal
  34837. ? dataMax - dataMin || Math.abs(dataMin)
  34838. : null // Currently if a `'value'` axis model min is specified as 'dataMin'/'dataMax',
  34839. // `boundaryGap` will not be used. It's the different from specifying as `null`/`undefined`.
  34840. var min =
  34841. this._modelMinRaw === 'dataMin' ? dataMin : this._modelMinNum
  34842. var max =
  34843. this._modelMaxRaw === 'dataMax' ? dataMax : this._modelMaxNum // If `_modelMinNum`/`_modelMaxNum` is `null`/`undefined`, should not be fixed.
  34844. var minFixed = min != null
  34845. var maxFixed = max != null
  34846. if (min == null) {
  34847. min = isOrdinal
  34848. ? axisDataLen
  34849. ? 0
  34850. : NaN
  34851. : dataMin - boundaryGapInner[0] * span
  34852. }
  34853. if (max == null) {
  34854. max = isOrdinal
  34855. ? axisDataLen
  34856. ? axisDataLen - 1
  34857. : NaN
  34858. : dataMax + boundaryGapInner[1] * span
  34859. }
  34860. ;(min == null || !isFinite(min)) && (min = NaN)
  34861. ;(max == null || !isFinite(max)) && (max = NaN)
  34862. var isBlank =
  34863. eqNaN(min) || eqNaN(max) || (isOrdinal && !axisDataLen) // If data extent modified, need to recalculated to ensure cross zero.
  34864. if (this._needCrossZero) {
  34865. // Axis is over zero and min is not set
  34866. if (min > 0 && max > 0 && !minFixed) {
  34867. min = 0 // minFixed = true;
  34868. } // Axis is under zero and max is not set
  34869. if (min < 0 && max < 0 && !maxFixed) {
  34870. max = 0 // maxFixed = true;
  34871. } // PENDING:
  34872. // When `needCrossZero` and all data is positive/negative, should it be ensured
  34873. // that the results processed by boundaryGap are positive/negative?
  34874. // If so, here `minFixed`/`maxFixed` need to be set.
  34875. }
  34876. var determinedMin = this._determinedMin
  34877. var determinedMax = this._determinedMax
  34878. if (determinedMin != null) {
  34879. min = determinedMin
  34880. minFixed = true
  34881. }
  34882. if (determinedMax != null) {
  34883. max = determinedMax
  34884. maxFixed = true
  34885. } // Ensure min/max be finite number or NaN here. (not to be null/undefined)
  34886. // `NaN` means min/max axis is blank.
  34887. return {
  34888. min: min,
  34889. max: max,
  34890. minFixed: minFixed,
  34891. maxFixed: maxFixed,
  34892. isBlank: isBlank
  34893. }
  34894. }
  34895. ScaleRawExtentInfo.prototype.modifyDataMinMax = function (
  34896. minMaxName,
  34897. val
  34898. ) {
  34899. this[DATA_MIN_MAX_ATTR[minMaxName]] = val
  34900. }
  34901. ScaleRawExtentInfo.prototype.setDeterminedMinMax = function (
  34902. minMaxName,
  34903. val
  34904. ) {
  34905. var attr = DETERMINED_MIN_MAX_ATTR[minMaxName]
  34906. this[attr] = val
  34907. }
  34908. ScaleRawExtentInfo.prototype.freeze = function () {
  34909. // @ts-ignore
  34910. this.frozen = true
  34911. }
  34912. return ScaleRawExtentInfo
  34913. })()
  34914. var DETERMINED_MIN_MAX_ATTR = {
  34915. min: '_determinedMin',
  34916. max: '_determinedMax'
  34917. }
  34918. var DATA_MIN_MAX_ATTR = { min: '_dataMin', max: '_dataMax' }
  34919. /**
  34920. * Get scale min max and related info only depends on model settings.
  34921. * This method can be called after coordinate system created.
  34922. * For example, in data processing stage.
  34923. *
  34924. * Scale extent info probably be required multiple times during a workflow.
  34925. * For example:
  34926. * (1) `dataZoom` depends it to get the axis extent in "100%" state.
  34927. * (2) `processor/extentCalculator` depends it to make sure whether axis extent is specified.
  34928. * (3) `coordSys.update` use it to finally decide the scale extent.
  34929. * But the callback of `min`/`max` should not be called multiple times.
  34930. * The code below should not be implemented repeatedly either.
  34931. * So we cache the result in the scale instance, which will be recreated at the begining
  34932. * of the workflow (because `scale` instance will be recreated each round of the workflow).
  34933. */ function ensureScaleRawExtentInfo(
  34934. scale,
  34935. model, // Usually: data extent from all series on this axis.
  34936. originalExtent
  34937. ) {
  34938. // Do not permit to recreate.
  34939. var rawExtentInfo = scale.rawExtentInfo
  34940. if (rawExtentInfo) {
  34941. return rawExtentInfo
  34942. }
  34943. rawExtentInfo = new ScaleRawExtentInfo(scale, model, originalExtent) // @ts-ignore
  34944. scale.rawExtentInfo = rawExtentInfo
  34945. return rawExtentInfo
  34946. }
  34947. function parseAxisModelMinMax(scale, minMax) {
  34948. return minMax == null
  34949. ? null
  34950. : eqNaN(minMax)
  34951. ? NaN
  34952. : scale.parse(minMax)
  34953. }
  34954. /**
  34955. * Get axis scale extent before niced.
  34956. * Item of returned array can only be number (including Infinity and NaN).
  34957. *
  34958. * Caution:
  34959. * Precondition of calling this method:
  34960. * The scale extent has been initialized using series data extent via
  34961. * `scale.setExtent` or `scale.unionExtentFromData`;
  34962. */ function getScaleExtent(scale, model) {
  34963. var scaleType = scale.type
  34964. var rawExtentResult = ensureScaleRawExtentInfo(
  34965. scale,
  34966. model,
  34967. scale.getExtent()
  34968. ).calculate()
  34969. scale.setBlank(rawExtentResult.isBlank)
  34970. var min = rawExtentResult.min
  34971. 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
  34972. // is base axis
  34973. // FIXME
  34974. // (1) Consider support value axis, where below zero and axis `onZero` should be handled properly.
  34975. // (2) Refactor the logic with `barGrid`. Is it not need to `makeBarWidthAndOffsetInfo` twice with different extent?
  34976. // Should not depend on series type `bar`?
  34977. // (3) Fix that might overlap when using dataZoom.
  34978. // (4) Consider other chart types using `barGrid`?
  34979. // See #6728, #4862, `test/bar-overflow-time-plot.html`
  34980. var ecModel = model.ecModel
  34981. if (
  34982. ecModel &&
  34983. scaleType === 'time' /*|| scaleType === 'interval' */
  34984. ) {
  34985. var barSeriesModels = prepareLayoutBarSeries('bar', ecModel)
  34986. var isBaseAxisAndHasBarSeries_1 = false
  34987. each$7(barSeriesModels, function (seriesModel) {
  34988. isBaseAxisAndHasBarSeries_1 =
  34989. isBaseAxisAndHasBarSeries_1 ||
  34990. seriesModel.getBaseAxis() === model.axis
  34991. })
  34992. if (isBaseAxisAndHasBarSeries_1) {
  34993. // Calculate placement of bars on axis. TODO should be decoupled
  34994. // with barLayout
  34995. var barWidthAndOffset = makeColumnLayout(barSeriesModels) // Adjust axis min and max to account for overflow
  34996. var adjustedScale = adjustScaleForOverflow(
  34997. min,
  34998. max,
  34999. model,
  35000. barWidthAndOffset
  35001. )
  35002. min = adjustedScale.min
  35003. max = adjustedScale.max
  35004. }
  35005. }
  35006. return {
  35007. extent: [min, max], // "fix" means "fixed", the value should not be
  35008. // changed in the subsequent steps.
  35009. fixMin: rawExtentResult.minFixed,
  35010. fixMax: rawExtentResult.maxFixed
  35011. }
  35012. }
  35013. function adjustScaleForOverflow(
  35014. min,
  35015. max,
  35016. model, // Only support cartesian coord yet.
  35017. barWidthAndOffset
  35018. ) {
  35019. // Get Axis Length
  35020. var axisExtent = model.axis.getExtent()
  35021. var axisLength = axisExtent[1] - axisExtent[0] // Get bars on current base axis and calculate min and max overflow
  35022. var barsOnCurrentAxis = retrieveColumnLayout(
  35023. barWidthAndOffset,
  35024. model.axis
  35025. )
  35026. if (barsOnCurrentAxis === undefined) {
  35027. return { min: min, max: max }
  35028. }
  35029. var minOverflow = Infinity
  35030. each$7(barsOnCurrentAxis, function (item) {
  35031. minOverflow = Math.min(item.offset, minOverflow)
  35032. })
  35033. var maxOverflow = -Infinity
  35034. each$7(barsOnCurrentAxis, function (item) {
  35035. maxOverflow = Math.max(item.offset + item.width, maxOverflow)
  35036. })
  35037. minOverflow = Math.abs(minOverflow)
  35038. maxOverflow = Math.abs(maxOverflow)
  35039. var totalOverFlow = minOverflow + maxOverflow // Calculate required buffer based on old range and overflow
  35040. var oldRange = max - min
  35041. var oldRangePercentOfNew =
  35042. 1 - (minOverflow + maxOverflow) / axisLength
  35043. var overflowBuffer = oldRange / oldRangePercentOfNew - oldRange
  35044. max += overflowBuffer * (maxOverflow / totalOverFlow)
  35045. min -= overflowBuffer * (minOverflow / totalOverFlow)
  35046. return { min: min, max: max }
  35047. } // Precondition of calling this method:
  35048. // The scale extent has been initailized using series data extent via
  35049. // `scale.setExtent` or `scale.unionExtentFromData`;
  35050. function niceScaleExtent(scale, inModel) {
  35051. var model = inModel
  35052. var extentInfo = getScaleExtent(scale, model)
  35053. var extent = extentInfo.extent
  35054. var splitNumber = model.get('splitNumber')
  35055. if (scale instanceof LogScale$1) {
  35056. scale.base = model.get('logBase')
  35057. }
  35058. var scaleType = scale.type
  35059. var interval = model.get('interval')
  35060. var isIntervalOrTime =
  35061. scaleType === 'interval' || scaleType === 'time'
  35062. scale.setExtent(extent[0], extent[1])
  35063. scale.calcNiceExtent({
  35064. splitNumber: splitNumber,
  35065. fixMin: extentInfo.fixMin,
  35066. fixMax: extentInfo.fixMax,
  35067. minInterval: isIntervalOrTime ? model.get('minInterval') : null,
  35068. maxInterval: isIntervalOrTime ? model.get('maxInterval') : null
  35069. }) // If some one specified the min, max. And the default calculated interval
  35070. // is not good enough. He can specify the interval. It is often appeared
  35071. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  35072. // to be 60.
  35073. // FIXME
  35074. if (interval != null) {
  35075. scale.setInterval && scale.setInterval(interval)
  35076. }
  35077. }
  35078. /**
  35079. * @param axisType Default retrieve from model.type
  35080. */ function createScaleByModel(model, axisType) {
  35081. axisType = axisType || model.get('type')
  35082. if (axisType) {
  35083. switch (
  35084. axisType // Buildin scale
  35085. ) {
  35086. case 'category':
  35087. return new OrdinalScale$1({
  35088. ordinalMeta: model.getOrdinalMeta
  35089. ? model.getOrdinalMeta()
  35090. : model.getCategories(),
  35091. extent: [Infinity, -Infinity]
  35092. })
  35093. case 'time':
  35094. return new TimeScale$1({
  35095. locale: model.ecModel.getLocaleModel(),
  35096. useUTC: model.ecModel.get('useUTC')
  35097. })
  35098. default:
  35099. // case 'value'/'interval', 'log', or others.
  35100. return new (Scale$1.getClass(axisType) || IntervalScale$1)()
  35101. }
  35102. }
  35103. }
  35104. /**
  35105. * Check if the axis cross 0
  35106. */ function ifAxisCrossZero(axis) {
  35107. var dataExtent = axis.scale.getExtent()
  35108. var min = dataExtent[0]
  35109. var max = dataExtent[1]
  35110. return !((min > 0 && max > 0) || (min < 0 && max < 0))
  35111. }
  35112. /**
  35113. * @param axis
  35114. * @return Label formatter function.
  35115. * param: {number} tickValue,
  35116. * param: {number} idx, the index in all ticks.
  35117. * If category axis, this param is not required.
  35118. * return: {string} label string.
  35119. */ function makeLabelFormatter(axis) {
  35120. var labelFormatter = axis.getLabelModel().get('formatter')
  35121. var categoryTickStart =
  35122. axis.type === 'category' ? axis.scale.getExtent()[0] : null
  35123. if (axis.scale.type === 'time') {
  35124. return (function (tpl) {
  35125. return function (tick, idx) {
  35126. return axis.scale.getFormattedLabel(tick, idx, tpl)
  35127. }
  35128. })(labelFormatter)
  35129. } else if (isString(labelFormatter)) {
  35130. return (function (tpl) {
  35131. return function (tick) {
  35132. // For category axis, get raw value; for numeric axis,
  35133. // get formatted label like '1,333,444'.
  35134. var label = axis.scale.getLabel(tick)
  35135. var text = tpl.replace('{value}', label != null ? label : '')
  35136. return text
  35137. }
  35138. })(labelFormatter)
  35139. } else if (isFunction(labelFormatter)) {
  35140. return (function (cb) {
  35141. return function (tick, idx) {
  35142. // The original intention of `idx` is "the index of the tick in all ticks".
  35143. // But the previous implementation of category axis do not consider the
  35144. // `axisLabel.interval`, which cause that, for example, the `interval` is
  35145. // `1`, then the ticks "name5", "name7", "name9" are displayed, where the
  35146. // corresponding `idx` are `0`, `2`, `4`, but not `0`, `1`, `2`. So we keep
  35147. // the definition here for back compatibility.
  35148. if (categoryTickStart != null) {
  35149. idx = tick.value - categoryTickStart
  35150. }
  35151. return cb(
  35152. getAxisRawValue(axis, tick),
  35153. idx,
  35154. tick.level != null ? { level: tick.level } : null
  35155. )
  35156. }
  35157. })(labelFormatter)
  35158. } else {
  35159. return function (tick) {
  35160. return axis.scale.getLabel(tick)
  35161. }
  35162. }
  35163. }
  35164. function getAxisRawValue(axis, tick) {
  35165. // In category axis with data zoom, tick is not the original
  35166. // index of axis.data. So tick should not be exposed to user
  35167. // in category axis.
  35168. return axis.type === 'category'
  35169. ? axis.scale.getLabel(tick)
  35170. : tick.value
  35171. }
  35172. /**
  35173. * @param axis
  35174. * @return Be null/undefined if no labels.
  35175. */ function estimateLabelUnionRect(axis) {
  35176. var axisModel = axis.model
  35177. var scale = axis.scale
  35178. if (!axisModel.get(['axisLabel', 'show']) || scale.isBlank()) {
  35179. return
  35180. }
  35181. var realNumberScaleTicks
  35182. var tickCount
  35183. var categoryScaleExtent = scale.getExtent() // Optimize for large category data, avoid call `getTicks()`.
  35184. if (scale instanceof OrdinalScale$1) {
  35185. tickCount = scale.count()
  35186. } else {
  35187. realNumberScaleTicks = scale.getTicks()
  35188. tickCount = realNumberScaleTicks.length
  35189. }
  35190. var axisLabelModel = axis.getLabelModel()
  35191. var labelFormatter = makeLabelFormatter(axis)
  35192. var rect
  35193. var step = 1 // Simple optimization for large amount of labels
  35194. if (tickCount > 40) {
  35195. step = Math.ceil(tickCount / 40)
  35196. }
  35197. for (var i = 0; i < tickCount; i += step) {
  35198. var tick = realNumberScaleTicks
  35199. ? realNumberScaleTicks[i]
  35200. : { value: categoryScaleExtent[0] + i }
  35201. var label = labelFormatter(tick, i)
  35202. var unrotatedSingleRect = axisLabelModel.getTextRect(label)
  35203. var singleRect = rotateTextRect(
  35204. unrotatedSingleRect,
  35205. axisLabelModel.get('rotate') || 0
  35206. )
  35207. rect ? rect.union(singleRect) : (rect = singleRect)
  35208. }
  35209. return rect
  35210. }
  35211. function rotateTextRect(textRect, rotate) {
  35212. var rotateRadians = (rotate * Math.PI) / 180
  35213. var beforeWidth = textRect.width
  35214. var beforeHeight = textRect.height
  35215. var afterWidth =
  35216. beforeWidth * Math.abs(Math.cos(rotateRadians)) +
  35217. Math.abs(beforeHeight * Math.sin(rotateRadians))
  35218. var afterHeight =
  35219. beforeWidth * Math.abs(Math.sin(rotateRadians)) +
  35220. Math.abs(beforeHeight * Math.cos(rotateRadians))
  35221. var rotatedRect = new BoundingRect$1(
  35222. textRect.x,
  35223. textRect.y,
  35224. afterWidth,
  35225. afterHeight
  35226. )
  35227. return rotatedRect
  35228. }
  35229. /**
  35230. * @param model axisLabelModel or axisTickModel
  35231. * @return {number|String} Can be null|'auto'|number|function
  35232. */ function getOptionCategoryInterval(model) {
  35233. var interval = model.get('interval')
  35234. return interval == null ? 'auto' : interval
  35235. }
  35236. /**
  35237. * Set `categoryInterval` as 0 implicitly indicates that
  35238. * show all labels reguardless of overlap.
  35239. * @param {Object} axis axisModel.axis
  35240. */ function shouldShowAllLabels(axis) {
  35241. return (
  35242. axis.type === 'category' &&
  35243. getOptionCategoryInterval(axis.getLabelModel()) === 0
  35244. )
  35245. }
  35246. function getDataDimensionsOnAxis(data, axisDim) {
  35247. // Remove duplicated dat dimensions caused by `getStackedDimension`.
  35248. var dataDimMap = {} // Currently `mapDimensionsAll` will contain stack result dimension ('__\0ecstackresult').
  35249. // PENDING: is it reasonable? Do we need to remove the original dim from "coord dim" since
  35250. // there has been stacked result dim?
  35251. each$7(data.mapDimensionsAll(axisDim), function (dataDim) {
  35252. // For example, the extent of the original dimension
  35253. // is [0.1, 0.5], the extent of the `stackResultDimension`
  35254. // is [7, 9], the final extent should NOT include [0.1, 0.5],
  35255. // because there is no graphic corresponding to [0.1, 0.5].
  35256. // See the case in `test/area-stack.html` `main1`, where area line
  35257. // stack needs `yAxis` not start from 0.
  35258. dataDimMap[getStackedDimension(data, dataDim)] = true
  35259. })
  35260. return keys(dataDimMap)
  35261. }
  35262. function unionAxisExtentFromData(dataExtent, data, axisDim) {
  35263. if (data) {
  35264. each$7(getDataDimensionsOnAxis(data, axisDim), function (dim) {
  35265. var seriesExtent = data.getApproximateExtent(dim)
  35266. seriesExtent[0] < dataExtent[0] &&
  35267. (dataExtent[0] = seriesExtent[0])
  35268. seriesExtent[1] > dataExtent[1] &&
  35269. (dataExtent[1] = seriesExtent[1])
  35270. })
  35271. }
  35272. }
  35273. /*
  35274. * Licensed to the Apache Software Foundation (ASF) under one
  35275. * or more contributor license agreements. See the NOTICE file
  35276. * distributed with this work for additional information
  35277. * regarding copyright ownership. The ASF licenses this file
  35278. * to you under the Apache License, Version 2.0 (the
  35279. * "License"); you may not use this file except in compliance
  35280. * with the License. You may obtain a copy of the License at
  35281. *
  35282. * http://www.apache.org/licenses/LICENSE-2.0
  35283. *
  35284. * Unless required by applicable law or agreed to in writing,
  35285. * software distributed under the License is distributed on an
  35286. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35287. * KIND, either express or implied. See the License for the
  35288. * specific language governing permissions and limitations
  35289. * under the License.
  35290. */
  35291. /**
  35292. * AUTO-GENERATED FILE. DO NOT MODIFY.
  35293. */
  35294. /*
  35295. * Licensed to the Apache Software Foundation (ASF) under one
  35296. * or more contributor license agreements. See the NOTICE file
  35297. * distributed with this work for additional information
  35298. * regarding copyright ownership. The ASF licenses this file
  35299. * to you under the Apache License, Version 2.0 (the
  35300. * "License"); you may not use this file except in compliance
  35301. * with the License. You may obtain a copy of the License at
  35302. *
  35303. * http://www.apache.org/licenses/LICENSE-2.0
  35304. *
  35305. * Unless required by applicable law or agreed to in writing,
  35306. * software distributed under the License is distributed on an
  35307. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  35308. * KIND, either express or implied. See the License for the
  35309. * specific language governing permissions and limitations
  35310. * under the License.
  35311. */ // eslint-disable-next-line @typescript-eslint/no-unused-vars
  35312. var AxisModelCommonMixin = /** @class */ (function () {
  35313. function AxisModelCommonMixin() {}
  35314. AxisModelCommonMixin.prototype.getNeedCrossZero = function () {
  35315. var option = this.option
  35316. return !option.scale
  35317. }
  35318. /**
  35319. * Should be implemented by each axis model if necessary.
  35320. * @return coordinate system model
  35321. */ AxisModelCommonMixin.prototype.getCoordSysModel = function () {
  35322. return
  35323. }
  35324. return AxisModelCommonMixin
  35325. })()
  35326. var extensions = []
  35327. var extensionRegisters = {
  35328. registerPreprocessor: registerPreprocessor,
  35329. registerProcessor: registerProcessor,
  35330. registerPostInit: registerPostInit,
  35331. registerPostUpdate: registerPostUpdate,
  35332. registerUpdateLifecycle: registerUpdateLifecycle,
  35333. registerAction: registerAction,
  35334. registerCoordinateSystem: registerCoordinateSystem,
  35335. registerLayout: registerLayout,
  35336. registerVisual: registerVisual,
  35337. registerTransform: registerTransform,
  35338. registerLoading: registerLoading,
  35339. registerMap: registerMap,
  35340. registerImpl: registerImpl,
  35341. PRIORITY: PRIORITY,
  35342. ComponentModel: ComponentModel$1,
  35343. ComponentView: ComponentView$1,
  35344. SeriesModel: SeriesModel$1,
  35345. ChartView: ChartView$1, // TODO Use ComponentModel and SeriesModel instead of Constructor
  35346. registerComponentModel: function registerComponentModel(
  35347. ComponentModelClass
  35348. ) {
  35349. ComponentModel$1.registerClass(ComponentModelClass)
  35350. },
  35351. registerComponentView: function registerComponentView(
  35352. ComponentViewClass
  35353. ) {
  35354. ComponentView$1.registerClass(ComponentViewClass)
  35355. },
  35356. registerSeriesModel: function registerSeriesModel(
  35357. SeriesModelClass
  35358. ) {
  35359. SeriesModel$1.registerClass(SeriesModelClass)
  35360. },
  35361. registerChartView: function registerChartView(ChartViewClass) {
  35362. ChartView$1.registerClass(ChartViewClass)
  35363. },
  35364. registerSubTypeDefaulter: function registerSubTypeDefaulter(
  35365. componentType,
  35366. defaulter
  35367. ) {
  35368. ComponentModel$1.registerSubTypeDefaulter(
  35369. componentType,
  35370. defaulter
  35371. )
  35372. },
  35373. registerPainter: function registerPainter(
  35374. painterType,
  35375. PainterCtor
  35376. ) {
  35377. _registerPainter(painterType, PainterCtor)
  35378. }
  35379. }
  35380. function use(ext) {
  35381. if (isArray(ext)) {
  35382. // use([ChartLine, ChartBar]);
  35383. each$7(ext, function (singleExt) {
  35384. use(singleExt)
  35385. })
  35386. return
  35387. }
  35388. if (indexOf(extensions, ext) >= 0) {
  35389. return
  35390. }
  35391. extensions.push(ext)
  35392. if (isFunction(ext)) {
  35393. ext = { install: ext }
  35394. }
  35395. ext.install(extensionRegisters)
  35396. }
  35397. var inner$6 = makeInner()
  35398. function createAxisLabels(axis) {
  35399. // Only ordinal scale support tick interval
  35400. return axis.type === 'category'
  35401. ? makeCategoryLabels(axis)
  35402. : makeRealNumberLabels(axis)
  35403. }
  35404. /**
  35405. * @param {module:echats/coord/Axis} axis
  35406. * @param {module:echarts/model/Model} tickModel For example, can be axisTick, splitLine, splitArea.
  35407. * @return {Object} {
  35408. * ticks: Array.<number>
  35409. * tickCategoryInterval: number
  35410. * }
  35411. */ function createAxisTicks(axis, tickModel) {
  35412. // Only ordinal scale support tick interval
  35413. return axis.type === 'category'
  35414. ? makeCategoryTicks(axis, tickModel)
  35415. : {
  35416. ticks: map$1(axis.scale.getTicks(), function (tick) {
  35417. return tick.value
  35418. })
  35419. }
  35420. }
  35421. function makeCategoryLabels(axis) {
  35422. var labelModel = axis.getLabelModel()
  35423. var result = makeCategoryLabelsActually(axis, labelModel)
  35424. return !labelModel.get('show') || axis.scale.isBlank()
  35425. ? {
  35426. labels: [],
  35427. labelCategoryInterval: result.labelCategoryInterval
  35428. }
  35429. : result
  35430. }
  35431. function makeCategoryLabelsActually(axis, labelModel) {
  35432. var labelsCache = getListCache(axis, 'labels')
  35433. var optionLabelInterval = getOptionCategoryInterval(labelModel)
  35434. var result = listCacheGet(labelsCache, optionLabelInterval)
  35435. if (result) {
  35436. return result
  35437. }
  35438. var labels
  35439. var numericLabelInterval
  35440. if (isFunction(optionLabelInterval)) {
  35441. labels = makeLabelsByCustomizedCategoryInterval(
  35442. axis,
  35443. optionLabelInterval
  35444. )
  35445. } else {
  35446. numericLabelInterval =
  35447. optionLabelInterval === 'auto'
  35448. ? makeAutoCategoryInterval(axis)
  35449. : optionLabelInterval
  35450. labels = makeLabelsByNumericCategoryInterval(
  35451. axis,
  35452. numericLabelInterval
  35453. )
  35454. } // Cache to avoid calling interval function repeatly.
  35455. return listCacheSet(labelsCache, optionLabelInterval, {
  35456. labels: labels,
  35457. labelCategoryInterval: numericLabelInterval
  35458. })
  35459. }
  35460. function makeCategoryTicks(axis, tickModel) {
  35461. var ticksCache = getListCache(axis, 'ticks')
  35462. var optionTickInterval = getOptionCategoryInterval(tickModel)
  35463. var result = listCacheGet(ticksCache, optionTickInterval)
  35464. if (result) {
  35465. return result
  35466. }
  35467. var ticks
  35468. var tickCategoryInterval // Optimize for the case that large category data and no label displayed,
  35469. // we should not return all ticks.
  35470. if (!tickModel.get('show') || axis.scale.isBlank()) {
  35471. ticks = []
  35472. }
  35473. if (isFunction(optionTickInterval)) {
  35474. ticks = makeLabelsByCustomizedCategoryInterval(
  35475. axis,
  35476. optionTickInterval,
  35477. true
  35478. )
  35479. } // Always use label interval by default despite label show. Consider this
  35480. // scenario, Use multiple grid with the xAxis sync, and only one xAxis shows
  35481. // labels. `splitLine` and `axisTick` should be consistent in this case.
  35482. else if (optionTickInterval === 'auto') {
  35483. var labelsResult = makeCategoryLabelsActually(
  35484. axis,
  35485. axis.getLabelModel()
  35486. )
  35487. tickCategoryInterval = labelsResult.labelCategoryInterval
  35488. ticks = map$1(labelsResult.labels, function (labelItem) {
  35489. return labelItem.tickValue
  35490. })
  35491. } else {
  35492. tickCategoryInterval = optionTickInterval
  35493. ticks = makeLabelsByNumericCategoryInterval(
  35494. axis,
  35495. tickCategoryInterval,
  35496. true
  35497. )
  35498. } // Cache to avoid calling interval function repeatly.
  35499. return listCacheSet(ticksCache, optionTickInterval, {
  35500. ticks: ticks,
  35501. tickCategoryInterval: tickCategoryInterval
  35502. })
  35503. }
  35504. function makeRealNumberLabels(axis) {
  35505. var ticks = axis.scale.getTicks()
  35506. var labelFormatter = makeLabelFormatter(axis)
  35507. return {
  35508. labels: map$1(ticks, function (tick, idx) {
  35509. return {
  35510. level: tick.level,
  35511. formattedLabel: labelFormatter(tick, idx),
  35512. rawLabel: axis.scale.getLabel(tick),
  35513. tickValue: tick.value
  35514. }
  35515. })
  35516. }
  35517. }
  35518. function getListCache(axis, prop) {
  35519. // Because key can be funciton, and cache size always be small, we use array cache.
  35520. return inner$6(axis)[prop] || (inner$6(axis)[prop] = [])
  35521. }
  35522. function listCacheGet(cache, key) {
  35523. for (var i = 0; i < cache.length; i++) {
  35524. if (cache[i].key === key) {
  35525. return cache[i].value
  35526. }
  35527. }
  35528. }
  35529. function listCacheSet(cache, key, value) {
  35530. cache.push({ key: key, value: value })
  35531. return value
  35532. }
  35533. function makeAutoCategoryInterval(axis) {
  35534. var result = inner$6(axis).autoInterval
  35535. return result != null
  35536. ? result
  35537. : (inner$6(axis).autoInterval = axis.calculateCategoryInterval())
  35538. }
  35539. /**
  35540. * Calculate interval for category axis ticks and labels.
  35541. * To get precise result, at least one of `getRotate` and `isHorizontal`
  35542. * should be implemented in axis.
  35543. */ function calculateCategoryInterval(axis) {
  35544. var params = fetchAutoCategoryIntervalCalculationParams(axis)
  35545. var labelFormatter = makeLabelFormatter(axis)
  35546. var rotation =
  35547. ((params.axisRotate - params.labelRotate) / 180) * Math.PI
  35548. var ordinalScale = axis.scale
  35549. var ordinalExtent = ordinalScale.getExtent() // Providing this method is for optimization:
  35550. // avoid generating a long array by `getTicks`
  35551. // in large category data case.
  35552. var tickCount = ordinalScale.count()
  35553. if (ordinalExtent[1] - ordinalExtent[0] < 1) {
  35554. return 0
  35555. }
  35556. var step = 1 // Simple optimization. Empirical value: tick count should less than 40.
  35557. if (tickCount > 40) {
  35558. step = Math.max(1, Math.floor(tickCount / 40))
  35559. }
  35560. var tickValue = ordinalExtent[0]
  35561. var unitSpan =
  35562. axis.dataToCoord(tickValue + 1) - axis.dataToCoord(tickValue)
  35563. var unitW = Math.abs(unitSpan * Math.cos(rotation))
  35564. var unitH = Math.abs(unitSpan * Math.sin(rotation))
  35565. var maxW = 0
  35566. var maxH = 0 // Caution: Performance sensitive for large category data.
  35567. // Consider dataZoom, we should make appropriate step to avoid O(n) loop.
  35568. for (; tickValue <= ordinalExtent[1]; tickValue += step) {
  35569. var width = 0
  35570. var height = 0 // Not precise, do not consider align and vertical align
  35571. // and each distance from axis line yet.
  35572. var rect = getBoundingRect(
  35573. labelFormatter({ value: tickValue }),
  35574. params.font,
  35575. 'center',
  35576. 'top'
  35577. ) // Magic number
  35578. width = rect.width * 1.3
  35579. height = rect.height * 1.3 // Min size, void long loop.
  35580. maxW = Math.max(maxW, width, 7)
  35581. maxH = Math.max(maxH, height, 7)
  35582. }
  35583. var dw = maxW / unitW
  35584. var dh = maxH / unitH // 0/0 is NaN, 1/0 is Infinity.
  35585. isNaN(dw) && (dw = Infinity)
  35586. isNaN(dh) && (dh = Infinity)
  35587. var interval = Math.max(0, Math.floor(Math.min(dw, dh)))
  35588. var cache = inner$6(axis.model)
  35589. var axisExtent = axis.getExtent()
  35590. var lastAutoInterval = cache.lastAutoInterval
  35591. var lastTickCount = cache.lastTickCount // Use cache to keep interval stable while moving zoom window,
  35592. // otherwise the calculated interval might jitter when the zoom
  35593. // window size is close to the interval-changing size.
  35594. // For example, if all of the axis labels are `a, b, c, d, e, f, g`.
  35595. // The jitter will cause that sometimes the displayed labels are
  35596. // `a, d, g` (interval: 2) sometimes `a, c, e`(interval: 1).
  35597. if (
  35598. lastAutoInterval != null &&
  35599. lastTickCount != null &&
  35600. Math.abs(lastAutoInterval - interval) <= 1 &&
  35601. Math.abs(lastTickCount - tickCount) <= 1 && // Always choose the bigger one, otherwise the critical
  35602. // point is not the same when zooming in or zooming out.
  35603. lastAutoInterval > interval && // If the axis change is caused by chart resize, the cache should not
  35604. // be used. Otherwise some hiden labels might not be shown again.
  35605. cache.axisExtent0 === axisExtent[0] &&
  35606. cache.axisExtent1 === axisExtent[1]
  35607. ) {
  35608. interval = lastAutoInterval
  35609. } // Only update cache if cache not used, otherwise the
  35610. // changing of interval is too insensitive.
  35611. else {
  35612. cache.lastTickCount = tickCount
  35613. cache.lastAutoInterval = interval
  35614. cache.axisExtent0 = axisExtent[0]
  35615. cache.axisExtent1 = axisExtent[1]
  35616. }
  35617. return interval
  35618. }
  35619. function fetchAutoCategoryIntervalCalculationParams(axis) {
  35620. var labelModel = axis.getLabelModel()
  35621. return {
  35622. axisRotate: axis.getRotate
  35623. ? axis.getRotate()
  35624. : axis.isHorizontal && !axis.isHorizontal()
  35625. ? 90
  35626. : 0,
  35627. labelRotate: labelModel.get('rotate') || 0,
  35628. font: labelModel.getFont()
  35629. }
  35630. }
  35631. function makeLabelsByNumericCategoryInterval(
  35632. axis,
  35633. categoryInterval,
  35634. onlyTick
  35635. ) {
  35636. var labelFormatter = makeLabelFormatter(axis)
  35637. var ordinalScale = axis.scale
  35638. var ordinalExtent = ordinalScale.getExtent()
  35639. var labelModel = axis.getLabelModel()
  35640. var result = [] // TODO: axisType: ordinalTime, pick the tick from each month/day/year/...
  35641. var step = Math.max((categoryInterval || 0) + 1, 1)
  35642. var startTick = ordinalExtent[0]
  35643. var tickCount = ordinalScale.count() // Calculate start tick based on zero if possible to keep label consistent
  35644. // while zooming and moving while interval > 0. Otherwise the selection
  35645. // of displayable ticks and symbols probably keep changing.
  35646. // 3 is empirical value.
  35647. if (startTick !== 0 && step > 1 && tickCount / step > 2) {
  35648. startTick = Math.round(Math.ceil(startTick / step) * step)
  35649. } // (1) Only add min max label here but leave overlap checking
  35650. // to render stage, which also ensure the returned list
  35651. // suitable for splitLine and splitArea rendering.
  35652. // (2) Scales except category always contain min max label so
  35653. // do not need to perform this process.
  35654. var showAllLabel = shouldShowAllLabels(axis)
  35655. var includeMinLabel = labelModel.get('showMinLabel') || showAllLabel
  35656. var includeMaxLabel = labelModel.get('showMaxLabel') || showAllLabel
  35657. if (includeMinLabel && startTick !== ordinalExtent[0]) {
  35658. addItem(ordinalExtent[0])
  35659. } // Optimize: avoid generating large array by `ordinalScale.getTicks()`.
  35660. var tickValue = startTick
  35661. for (; tickValue <= ordinalExtent[1]; tickValue += step) {
  35662. addItem(tickValue)
  35663. }
  35664. if (includeMaxLabel && tickValue - step !== ordinalExtent[1]) {
  35665. addItem(ordinalExtent[1])
  35666. }
  35667. function addItem(tickValue) {
  35668. var tickObj = { value: tickValue }
  35669. result.push(
  35670. onlyTick
  35671. ? tickValue
  35672. : {
  35673. formattedLabel: labelFormatter(tickObj),
  35674. rawLabel: ordinalScale.getLabel(tickObj),
  35675. tickValue: tickValue
  35676. }
  35677. )
  35678. }
  35679. return result
  35680. }
  35681. function makeLabelsByCustomizedCategoryInterval(
  35682. axis,
  35683. categoryInterval,
  35684. onlyTick
  35685. ) {
  35686. var ordinalScale = axis.scale
  35687. var labelFormatter = makeLabelFormatter(axis)
  35688. var result = []
  35689. each$7(ordinalScale.getTicks(), function (tick) {
  35690. var rawLabel = ordinalScale.getLabel(tick)
  35691. var tickValue = tick.value
  35692. if (categoryInterval(tick.value, rawLabel)) {
  35693. result.push(
  35694. onlyTick
  35695. ? tickValue
  35696. : {
  35697. formattedLabel: labelFormatter(tick),
  35698. rawLabel: rawLabel,
  35699. tickValue: tickValue
  35700. }
  35701. )
  35702. }
  35703. })
  35704. return result
  35705. }
  35706. var NORMALIZED_EXTENT = [0, 1]
  35707. /**
  35708. * Base class of Axis.
  35709. */ var Axis = /** @class */ (function () {
  35710. function Axis(dim, scale, extent) {
  35711. this.onBand = false
  35712. this.inverse = false
  35713. this.dim = dim
  35714. this.scale = scale
  35715. this._extent = extent || [0, 0]
  35716. }
  35717. /**
  35718. * If axis extent contain given coord
  35719. */ Axis.prototype.contain = function (coord) {
  35720. var extent = this._extent
  35721. var min = Math.min(extent[0], extent[1])
  35722. var max = Math.max(extent[0], extent[1])
  35723. return coord >= min && coord <= max
  35724. }
  35725. /**
  35726. * If axis extent contain given data
  35727. */ Axis.prototype.containData = function (data) {
  35728. return this.scale.contain(data)
  35729. }
  35730. /**
  35731. * Get coord extent.
  35732. */ Axis.prototype.getExtent = function () {
  35733. return this._extent.slice()
  35734. }
  35735. /**
  35736. * Get precision used for formatting
  35737. */ Axis.prototype.getPixelPrecision = function (dataExtent) {
  35738. return getPixelPrecision(
  35739. dataExtent || this.scale.getExtent(),
  35740. this._extent
  35741. )
  35742. }
  35743. /**
  35744. * Set coord extent
  35745. */ Axis.prototype.setExtent = function (start, end) {
  35746. var extent = this._extent
  35747. extent[0] = start
  35748. extent[1] = end
  35749. }
  35750. /**
  35751. * Convert data to coord. Data is the rank if it has an ordinal scale
  35752. */ Axis.prototype.dataToCoord = function (data, clamp) {
  35753. var extent = this._extent
  35754. var scale = this.scale
  35755. data = scale.normalize(data)
  35756. if (this.onBand && scale.type === 'ordinal') {
  35757. extent = extent.slice()
  35758. fixExtentWithBands(extent, scale.count())
  35759. }
  35760. return linearMap(data, NORMALIZED_EXTENT, extent, clamp)
  35761. }
  35762. /**
  35763. * Convert coord to data. Data is the rank if it has an ordinal scale
  35764. */ Axis.prototype.coordToData = function (coord, clamp) {
  35765. var extent = this._extent
  35766. var scale = this.scale
  35767. if (this.onBand && scale.type === 'ordinal') {
  35768. extent = extent.slice()
  35769. fixExtentWithBands(extent, scale.count())
  35770. }
  35771. var t = linearMap(coord, extent, NORMALIZED_EXTENT, clamp)
  35772. return this.scale.scale(t)
  35773. }
  35774. /**
  35775. * Convert pixel point to data in axis
  35776. */ Axis.prototype.pointToData = function (point, clamp) {
  35777. // Should be implemented in derived class if necessary.
  35778. return
  35779. }
  35780. /**
  35781. * Different from `zrUtil.map(axis.getTicks(), axis.dataToCoord, axis)`,
  35782. * `axis.getTicksCoords` considers `onBand`, which is used by
  35783. * `boundaryGap:true` of category axis and splitLine and splitArea.
  35784. * @param opt.tickModel default: axis.model.getModel('axisTick')
  35785. * @param opt.clamp If `true`, the first and the last
  35786. * tick must be at the axis end points. Otherwise, clip ticks
  35787. * that outside the axis extent.
  35788. */ Axis.prototype.getTicksCoords = function (opt) {
  35789. opt = opt || {}
  35790. var tickModel = opt.tickModel || this.getTickModel()
  35791. var result = createAxisTicks(this, tickModel)
  35792. var ticks = result.ticks
  35793. var ticksCoords = map$1(
  35794. ticks,
  35795. function (tickVal) {
  35796. return {
  35797. coord: this.dataToCoord(
  35798. this.scale.type === 'ordinal'
  35799. ? this.scale.getRawOrdinalNumber(tickVal)
  35800. : tickVal
  35801. ),
  35802. tickValue: tickVal
  35803. }
  35804. },
  35805. this
  35806. )
  35807. var alignWithLabel = tickModel.get('alignWithLabel')
  35808. fixOnBandTicksCoords(this, ticksCoords, alignWithLabel, opt.clamp)
  35809. return ticksCoords
  35810. }
  35811. Axis.prototype.getMinorTicksCoords = function () {
  35812. if (this.scale.type === 'ordinal') {
  35813. // Category axis doesn't support minor ticks
  35814. return []
  35815. }
  35816. var minorTickModel = this.model.getModel('minorTick')
  35817. var splitNumber = minorTickModel.get('splitNumber') // Protection.
  35818. if (!(splitNumber > 0 && splitNumber < 100)) {
  35819. splitNumber = 5
  35820. }
  35821. var minorTicks = this.scale.getMinorTicks(splitNumber)
  35822. var minorTicksCoords = map$1(
  35823. minorTicks,
  35824. function (minorTicksGroup) {
  35825. return map$1(
  35826. minorTicksGroup,
  35827. function (minorTick) {
  35828. return {
  35829. coord: this.dataToCoord(minorTick),
  35830. tickValue: minorTick
  35831. }
  35832. },
  35833. this
  35834. )
  35835. },
  35836. this
  35837. )
  35838. return minorTicksCoords
  35839. }
  35840. Axis.prototype.getViewLabels = function () {
  35841. return createAxisLabels(this).labels
  35842. }
  35843. Axis.prototype.getLabelModel = function () {
  35844. return this.model.getModel('axisLabel')
  35845. }
  35846. /**
  35847. * Notice here we only get the default tick model. For splitLine
  35848. * or splitArea, we should pass the splitLineModel or splitAreaModel
  35849. * manually when calling `getTicksCoords`.
  35850. * In GL, this method may be overrided to:
  35851. * `axisModel.getModel('axisTick', grid3DModel.getModel('axisTick'));`
  35852. */ Axis.prototype.getTickModel = function () {
  35853. return this.model.getModel('axisTick')
  35854. }
  35855. /**
  35856. * Get width of band
  35857. */ Axis.prototype.getBandWidth = function () {
  35858. var axisExtent = this._extent
  35859. var dataExtent = this.scale.getExtent()
  35860. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0) // Fix #2728, avoid NaN when only one data.
  35861. len === 0 && (len = 1)
  35862. var size = Math.abs(axisExtent[1] - axisExtent[0])
  35863. return Math.abs(size) / len
  35864. }
  35865. /**
  35866. * Only be called in category axis.
  35867. * Can be overrided, consider other axes like in 3D.
  35868. * @return Auto interval for cateogry axis tick and label
  35869. */ Axis.prototype.calculateCategoryInterval = function () {
  35870. return calculateCategoryInterval(this)
  35871. }
  35872. return Axis
  35873. })()
  35874. function fixExtentWithBands(extent, nTick) {
  35875. var size = extent[1] - extent[0]
  35876. var len = nTick
  35877. var margin = size / len / 2
  35878. extent[0] += margin
  35879. extent[1] -= margin
  35880. } // If axis has labels [1, 2, 3, 4]. Bands on the axis are
  35881. // |---1---|---2---|---3---|---4---|.
  35882. // So the displayed ticks and splitLine/splitArea should between
  35883. // each data item, otherwise cause misleading (e.g., split tow bars
  35884. // of a single data item when there are two bar series).
  35885. // Also consider if tickCategoryInterval > 0 and onBand, ticks and
  35886. // splitLine/spliteArea should layout appropriately corresponding
  35887. // to displayed labels. (So we should not use `getBandWidth` in this
  35888. // case).
  35889. function fixOnBandTicksCoords(
  35890. axis,
  35891. ticksCoords,
  35892. alignWithLabel,
  35893. clamp
  35894. ) {
  35895. var ticksLen = ticksCoords.length
  35896. if (!axis.onBand || alignWithLabel || !ticksLen) {
  35897. return
  35898. }
  35899. var axisExtent = axis.getExtent()
  35900. var last
  35901. var diffSize
  35902. if (ticksLen === 1) {
  35903. ticksCoords[0].coord = axisExtent[0]
  35904. last = ticksCoords[1] = { coord: axisExtent[0] }
  35905. } else {
  35906. var crossLen =
  35907. ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue
  35908. var shift_1 =
  35909. (ticksCoords[ticksLen - 1].coord - ticksCoords[0].coord) /
  35910. crossLen
  35911. each$7(ticksCoords, function (ticksItem) {
  35912. ticksItem.coord -= shift_1 / 2
  35913. })
  35914. var dataExtent = axis.scale.getExtent()
  35915. diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue
  35916. last = {
  35917. coord: ticksCoords[ticksLen - 1].coord + shift_1 * diffSize
  35918. }
  35919. ticksCoords.push(last)
  35920. }
  35921. var inverse = axisExtent[0] > axisExtent[1] // Handling clamp.
  35922. if (littleThan(ticksCoords[0].coord, axisExtent[0])) {
  35923. clamp
  35924. ? (ticksCoords[0].coord = axisExtent[0])
  35925. : ticksCoords.shift()
  35926. }
  35927. if (clamp && littleThan(axisExtent[0], ticksCoords[0].coord)) {
  35928. ticksCoords.unshift({ coord: axisExtent[0] })
  35929. }
  35930. if (littleThan(axisExtent[1], last.coord)) {
  35931. clamp ? (last.coord = axisExtent[1]) : ticksCoords.pop()
  35932. }
  35933. if (clamp && littleThan(last.coord, axisExtent[1])) {
  35934. ticksCoords.push({ coord: axisExtent[1] })
  35935. }
  35936. function littleThan(a, b) {
  35937. // Avoid rounding error cause calculated tick coord different with extent.
  35938. // It may cause an extra unecessary tick added.
  35939. a = round$1(a)
  35940. b = round$1(b)
  35941. return inverse ? a > b : a < b
  35942. }
  35943. }
  35944. var Axis$1 = Axis
  35945. var PI2$1 = Math.PI * 2
  35946. var CMD$1 = PathProxy$1.CMD
  35947. var DEFAULT_SEARCH_SPACE = ['top', 'right', 'bottom', 'left']
  35948. function getCandidateAnchor(pos, distance, rect, outPt, outDir) {
  35949. var width = rect.width
  35950. var height = rect.height
  35951. switch (pos) {
  35952. case 'top':
  35953. outPt.set(rect.x + width / 2, rect.y - distance)
  35954. outDir.set(0, -1)
  35955. break
  35956. case 'bottom':
  35957. outPt.set(rect.x + width / 2, rect.y + height + distance)
  35958. outDir.set(0, 1)
  35959. break
  35960. case 'left':
  35961. outPt.set(rect.x - distance, rect.y + height / 2)
  35962. outDir.set(-1, 0)
  35963. break
  35964. case 'right':
  35965. outPt.set(rect.x + width + distance, rect.y + height / 2)
  35966. outDir.set(1, 0)
  35967. break
  35968. }
  35969. }
  35970. function projectPointToArc(
  35971. cx,
  35972. cy,
  35973. r,
  35974. startAngle,
  35975. endAngle,
  35976. anticlockwise,
  35977. x,
  35978. y,
  35979. out
  35980. ) {
  35981. x -= cx
  35982. y -= cy
  35983. var d = Math.sqrt(x * x + y * y)
  35984. x /= d
  35985. y /= d // Intersect point.
  35986. var ox = x * r + cx
  35987. var oy = y * r + cy
  35988. if (Math.abs(startAngle - endAngle) % PI2$1 < 1e-4) {
  35989. // Is a circle
  35990. out[0] = ox
  35991. out[1] = oy
  35992. return d - r
  35993. }
  35994. if (anticlockwise) {
  35995. var tmp = startAngle
  35996. startAngle = normalizeRadian(endAngle)
  35997. endAngle = normalizeRadian(tmp)
  35998. } else {
  35999. startAngle = normalizeRadian(startAngle)
  36000. endAngle = normalizeRadian(endAngle)
  36001. }
  36002. if (startAngle > endAngle) {
  36003. endAngle += PI2$1
  36004. }
  36005. var angle = Math.atan2(y, x)
  36006. if (angle < 0) {
  36007. angle += PI2$1
  36008. }
  36009. if (
  36010. (angle >= startAngle && angle <= endAngle) ||
  36011. (angle + PI2$1 >= startAngle && angle + PI2$1 <= endAngle)
  36012. ) {
  36013. // Project point is on the arc.
  36014. out[0] = ox
  36015. out[1] = oy
  36016. return d - r
  36017. }
  36018. var x1 = r * Math.cos(startAngle) + cx
  36019. var y1 = r * Math.sin(startAngle) + cy
  36020. var x2 = r * Math.cos(endAngle) + cx
  36021. var y2 = r * Math.sin(endAngle) + cy
  36022. var d1 = (x1 - x) * (x1 - x) + (y1 - y) * (y1 - y)
  36023. var d2 = (x2 - x) * (x2 - x) + (y2 - y) * (y2 - y)
  36024. if (d1 < d2) {
  36025. out[0] = x1
  36026. out[1] = y1
  36027. return Math.sqrt(d1)
  36028. } else {
  36029. out[0] = x2
  36030. out[1] = y2
  36031. return Math.sqrt(d2)
  36032. }
  36033. }
  36034. function projectPointToLine(x1, y1, x2, y2, x, y, out, limitToEnds) {
  36035. var dx = x - x1
  36036. var dy = y - y1
  36037. var dx1 = x2 - x1
  36038. var dy1 = y2 - y1
  36039. var lineLen = Math.sqrt(dx1 * dx1 + dy1 * dy1)
  36040. dx1 /= lineLen
  36041. dy1 /= lineLen // dot product
  36042. var projectedLen = dx * dx1 + dy * dy1
  36043. var t = projectedLen / lineLen
  36044. if (limitToEnds) {
  36045. t = Math.min(Math.max(t, 0), 1)
  36046. }
  36047. t *= lineLen
  36048. var ox = (out[0] = x1 + t * dx1)
  36049. var oy = (out[1] = y1 + t * dy1)
  36050. return Math.sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y))
  36051. }
  36052. function projectPointToRect(x1, y1, width, height, x, y, out) {
  36053. if (width < 0) {
  36054. x1 = x1 + width
  36055. width = -width
  36056. }
  36057. if (height < 0) {
  36058. y1 = y1 + height
  36059. height = -height
  36060. }
  36061. var x2 = x1 + width
  36062. var y2 = y1 + height
  36063. var ox = (out[0] = Math.min(Math.max(x, x1), x2))
  36064. var oy = (out[1] = Math.min(Math.max(y, y1), y2))
  36065. return Math.sqrt((ox - x) * (ox - x) + (oy - y) * (oy - y))
  36066. }
  36067. var tmpPt = []
  36068. function nearestPointOnRect(pt, rect, out) {
  36069. var dist = projectPointToRect(
  36070. rect.x,
  36071. rect.y,
  36072. rect.width,
  36073. rect.height,
  36074. pt.x,
  36075. pt.y,
  36076. tmpPt
  36077. )
  36078. out.set(tmpPt[0], tmpPt[1])
  36079. return dist
  36080. }
  36081. /**
  36082. * Calculate min distance corresponding point.
  36083. * This method won't evaluate if point is in the path.
  36084. */ function nearestPointOnPath(pt, path, out) {
  36085. var xi = 0
  36086. var yi = 0
  36087. var x0 = 0
  36088. var y0 = 0
  36089. var x1
  36090. var y1
  36091. var minDist = Infinity
  36092. var data = path.data
  36093. var x = pt.x
  36094. var y = pt.y
  36095. for (var i = 0; i < data.length; ) {
  36096. var cmd = data[i++]
  36097. if (i === 1) {
  36098. xi = data[i]
  36099. yi = data[i + 1]
  36100. x0 = xi
  36101. y0 = yi
  36102. }
  36103. var d = minDist
  36104. switch (cmd) {
  36105. case CMD$1.M: // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  36106. // 在 closePath 的时候使用
  36107. x0 = data[i++]
  36108. y0 = data[i++]
  36109. xi = x0
  36110. yi = y0
  36111. break
  36112. case CMD$1.L:
  36113. d = projectPointToLine(
  36114. xi,
  36115. yi,
  36116. data[i],
  36117. data[i + 1],
  36118. x,
  36119. y,
  36120. tmpPt,
  36121. true
  36122. )
  36123. xi = data[i++]
  36124. yi = data[i++]
  36125. break
  36126. case CMD$1.C:
  36127. d = cubicProjectPoint(
  36128. xi,
  36129. yi,
  36130. data[i++],
  36131. data[i++],
  36132. data[i++],
  36133. data[i++],
  36134. data[i],
  36135. data[i + 1],
  36136. x,
  36137. y,
  36138. tmpPt
  36139. )
  36140. xi = data[i++]
  36141. yi = data[i++]
  36142. break
  36143. case CMD$1.Q:
  36144. d = quadraticProjectPoint(
  36145. xi,
  36146. yi,
  36147. data[i++],
  36148. data[i++],
  36149. data[i],
  36150. data[i + 1],
  36151. x,
  36152. y,
  36153. tmpPt
  36154. )
  36155. xi = data[i++]
  36156. yi = data[i++]
  36157. break
  36158. case CMD$1.A: // TODO Arc 判断的开销比较大
  36159. var cx = data[i++]
  36160. var cy = data[i++]
  36161. var rx = data[i++]
  36162. var ry = data[i++]
  36163. var theta = data[i++]
  36164. var dTheta = data[i++] // TODO Arc 旋转
  36165. i += 1
  36166. var anticlockwise = !!(1 - data[i++])
  36167. x1 = Math.cos(theta) * rx + cx
  36168. y1 = Math.sin(theta) * ry + cy // 不是直接使用 arc 命令
  36169. if (i <= 1) {
  36170. // 第一个命令起点还未定义
  36171. x0 = x1
  36172. y0 = y1
  36173. } // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  36174. var _x = ((x - cx) * ry) / rx + cx
  36175. d = projectPointToArc(
  36176. cx,
  36177. cy,
  36178. ry,
  36179. theta,
  36180. theta + dTheta,
  36181. anticlockwise,
  36182. _x,
  36183. y,
  36184. tmpPt
  36185. )
  36186. xi = Math.cos(theta + dTheta) * rx + cx
  36187. yi = Math.sin(theta + dTheta) * ry + cy
  36188. break
  36189. case CMD$1.R:
  36190. x0 = xi = data[i++]
  36191. y0 = yi = data[i++]
  36192. var width = data[i++]
  36193. var height = data[i++]
  36194. d = projectPointToRect(x0, y0, width, height, x, y, tmpPt)
  36195. break
  36196. case CMD$1.Z:
  36197. d = projectPointToLine(xi, yi, x0, y0, x, y, tmpPt, true)
  36198. xi = x0
  36199. yi = y0
  36200. break
  36201. }
  36202. if (d < minDist) {
  36203. minDist = d
  36204. out.set(tmpPt[0], tmpPt[1])
  36205. }
  36206. }
  36207. return minDist
  36208. } // Temporal varible for intermediate usage.
  36209. var pt0 = new Point$1()
  36210. var pt1 = new Point$1()
  36211. var pt2 = new Point$1()
  36212. var dir = new Point$1()
  36213. var dir2 = new Point$1()
  36214. /**
  36215. * Calculate a proper guide line based on the label position and graphic element definition
  36216. * @param label
  36217. * @param labelRect
  36218. * @param target
  36219. * @param targetRect
  36220. */ function updateLabelLinePoints(target, labelLineModel) {
  36221. if (!target) {
  36222. return
  36223. }
  36224. var labelLine = target.getTextGuideLine()
  36225. var label = target.getTextContent() // Needs to create text guide in each charts.
  36226. if (!(label && labelLine)) {
  36227. return
  36228. }
  36229. var labelGuideConfig = target.textGuideLineConfig || {}
  36230. var points = [
  36231. [0, 0],
  36232. [0, 0],
  36233. [0, 0]
  36234. ]
  36235. var searchSpace =
  36236. labelGuideConfig.candidates || DEFAULT_SEARCH_SPACE
  36237. var labelRect = label.getBoundingRect().clone()
  36238. labelRect.applyTransform(label.getComputedTransform())
  36239. var minDist = Infinity
  36240. var anchorPoint = labelGuideConfig.anchor
  36241. var targetTransform = target.getComputedTransform()
  36242. var targetInversedTransform =
  36243. targetTransform && invert([], targetTransform)
  36244. var len = labelLineModel.get('length2') || 0
  36245. if (anchorPoint) {
  36246. pt2.copy(anchorPoint)
  36247. }
  36248. for (var i = 0; i < searchSpace.length; i++) {
  36249. var candidate = searchSpace[i]
  36250. getCandidateAnchor(candidate, 0, labelRect, pt0, dir)
  36251. Point$1.scaleAndAdd(pt1, pt0, dir, len) // Transform to target coord space.
  36252. pt1.transform(targetInversedTransform) // Note: getBoundingRect will ensure the `path` being created.
  36253. var boundingRect = target.getBoundingRect()
  36254. var dist = anchorPoint
  36255. ? anchorPoint.distance(pt1)
  36256. : target instanceof Path$1
  36257. ? nearestPointOnPath(pt1, target.path, pt2)
  36258. : nearestPointOnRect(pt1, boundingRect, pt2) // TODO pt2 is in the path
  36259. if (dist < minDist) {
  36260. minDist = dist // Transform back to global space.
  36261. pt1.transform(targetTransform)
  36262. pt2.transform(targetTransform)
  36263. pt2.toArray(points[0])
  36264. pt1.toArray(points[1])
  36265. pt0.toArray(points[2])
  36266. }
  36267. }
  36268. limitTurnAngle(points, labelLineModel.get('minTurnAngle'))
  36269. labelLine.setShape({ points: points })
  36270. } // Temporal variable for the limitTurnAngle function
  36271. var tmpArr = []
  36272. var tmpProjPoint = new Point$1()
  36273. /**
  36274. * Reduce the line segment attached to the label to limit the turn angle between two segments.
  36275. * @param linePoints
  36276. * @param minTurnAngle Radian of minimum turn angle. 0 - 180
  36277. */ function limitTurnAngle(linePoints, minTurnAngle) {
  36278. if (!(minTurnAngle <= 180 && minTurnAngle > 0)) {
  36279. return
  36280. }
  36281. minTurnAngle = (minTurnAngle / 180) * Math.PI // The line points can be
  36282. // /pt1----pt2 (label)
  36283. // /
  36284. // pt0/
  36285. pt0.fromArray(linePoints[0])
  36286. pt1.fromArray(linePoints[1])
  36287. pt2.fromArray(linePoints[2])
  36288. Point$1.sub(dir, pt0, pt1)
  36289. Point$1.sub(dir2, pt2, pt1)
  36290. var len1 = dir.len()
  36291. var len2 = dir2.len()
  36292. if (len1 < 1e-3 || len2 < 1e-3) {
  36293. return
  36294. }
  36295. dir.scale(1 / len1)
  36296. dir2.scale(1 / len2)
  36297. var angleCos = dir.dot(dir2)
  36298. var minTurnAngleCos = Math.cos(minTurnAngle)
  36299. if (minTurnAngleCos < angleCos) {
  36300. // Smaller than minTurnAngle
  36301. // Calculate project point of pt0 on pt1-pt2
  36302. var d = projectPointToLine(
  36303. pt1.x,
  36304. pt1.y,
  36305. pt2.x,
  36306. pt2.y,
  36307. pt0.x,
  36308. pt0.y,
  36309. tmpArr,
  36310. false
  36311. )
  36312. tmpProjPoint.fromArray(tmpArr) // Calculate new projected length with limited minTurnAngle and get the new connect point
  36313. tmpProjPoint.scaleAndAdd(
  36314. dir2,
  36315. d / Math.tan(Math.PI - minTurnAngle)
  36316. ) // Limit the new calculated connect point between pt1 and pt2.
  36317. var t =
  36318. pt2.x !== pt1.x
  36319. ? (tmpProjPoint.x - pt1.x) / (pt2.x - pt1.x)
  36320. : (tmpProjPoint.y - pt1.y) / (pt2.y - pt1.y)
  36321. if (isNaN(t)) {
  36322. return
  36323. }
  36324. if (t < 0) {
  36325. Point$1.copy(tmpProjPoint, pt1)
  36326. } else if (t > 1) {
  36327. Point$1.copy(tmpProjPoint, pt2)
  36328. }
  36329. tmpProjPoint.toArray(linePoints[1])
  36330. }
  36331. }
  36332. /**
  36333. * Limit the angle of line and the surface
  36334. * @param maxSurfaceAngle Radian of minimum turn angle. 0 - 180. 0 is same direction to normal. 180 is opposite
  36335. */ function limitSurfaceAngle(
  36336. linePoints,
  36337. surfaceNormal,
  36338. maxSurfaceAngle
  36339. ) {
  36340. if (!(maxSurfaceAngle <= 180 && maxSurfaceAngle > 0)) {
  36341. return
  36342. }
  36343. maxSurfaceAngle = (maxSurfaceAngle / 180) * Math.PI
  36344. pt0.fromArray(linePoints[0])
  36345. pt1.fromArray(linePoints[1])
  36346. pt2.fromArray(linePoints[2])
  36347. Point$1.sub(dir, pt1, pt0)
  36348. Point$1.sub(dir2, pt2, pt1)
  36349. var len1 = dir.len()
  36350. var len2 = dir2.len()
  36351. if (len1 < 1e-3 || len2 < 1e-3) {
  36352. return
  36353. }
  36354. dir.scale(1 / len1)
  36355. dir2.scale(1 / len2)
  36356. var angleCos = dir.dot(surfaceNormal)
  36357. var maxSurfaceAngleCos = Math.cos(maxSurfaceAngle)
  36358. if (angleCos < maxSurfaceAngleCos) {
  36359. // Calculate project point of pt0 on pt1-pt2
  36360. var d = projectPointToLine(
  36361. pt1.x,
  36362. pt1.y,
  36363. pt2.x,
  36364. pt2.y,
  36365. pt0.x,
  36366. pt0.y,
  36367. tmpArr,
  36368. false
  36369. )
  36370. tmpProjPoint.fromArray(tmpArr)
  36371. var HALF_PI = Math.PI / 2
  36372. var angle2 = Math.acos(dir2.dot(surfaceNormal))
  36373. var newAngle = HALF_PI + angle2 - maxSurfaceAngle
  36374. if (newAngle >= HALF_PI) {
  36375. // parallel
  36376. Point$1.copy(tmpProjPoint, pt2)
  36377. } else {
  36378. // Calculate new projected length with limited minTurnAngle and get the new connect point
  36379. tmpProjPoint.scaleAndAdd(
  36380. dir2,
  36381. d / Math.tan(Math.PI / 2 - newAngle)
  36382. ) // Limit the new calculated connect point between pt1 and pt2.
  36383. var t =
  36384. pt2.x !== pt1.x
  36385. ? (tmpProjPoint.x - pt1.x) / (pt2.x - pt1.x)
  36386. : (tmpProjPoint.y - pt1.y) / (pt2.y - pt1.y)
  36387. if (isNaN(t)) {
  36388. return
  36389. }
  36390. if (t < 0) {
  36391. Point$1.copy(tmpProjPoint, pt1)
  36392. } else if (t > 1) {
  36393. Point$1.copy(tmpProjPoint, pt2)
  36394. }
  36395. }
  36396. tmpProjPoint.toArray(linePoints[1])
  36397. }
  36398. }
  36399. function setLabelLineState(labelLine, ignore, stateName, stateModel) {
  36400. var isNormal = stateName === 'normal'
  36401. var stateObj = isNormal
  36402. ? labelLine
  36403. : labelLine.ensureState(stateName) // Make sure display.
  36404. stateObj.ignore = ignore // Set smooth
  36405. var smooth = stateModel.get('smooth')
  36406. if (smooth && smooth === true) {
  36407. smooth = 0.3
  36408. }
  36409. stateObj.shape = stateObj.shape || {}
  36410. if (smooth > 0) {
  36411. stateObj.shape.smooth = smooth
  36412. }
  36413. var styleObj = stateModel.getModel('lineStyle').getLineStyle()
  36414. isNormal
  36415. ? labelLine.useStyle(styleObj)
  36416. : (stateObj.style = styleObj)
  36417. }
  36418. function buildLabelLinePath(path, shape) {
  36419. var smooth = shape.smooth
  36420. var points = shape.points
  36421. if (!points) {
  36422. return
  36423. }
  36424. path.moveTo(points[0][0], points[0][1])
  36425. if (smooth > 0 && points.length >= 3) {
  36426. var len1 = dist$1(points[0], points[1])
  36427. var len2 = dist$1(points[1], points[2])
  36428. if (!len1 || !len2) {
  36429. path.lineTo(points[1][0], points[1][1])
  36430. path.lineTo(points[2][0], points[2][1])
  36431. return
  36432. }
  36433. var moveLen = Math.min(len1, len2) * smooth
  36434. var midPoint0 = lerp$1([], points[1], points[0], moveLen / len1)
  36435. var midPoint2 = lerp$1([], points[1], points[2], moveLen / len2)
  36436. var midPoint1 = lerp$1([], midPoint0, midPoint2, 0.5)
  36437. path.bezierCurveTo(
  36438. midPoint0[0],
  36439. midPoint0[1],
  36440. midPoint0[0],
  36441. midPoint0[1],
  36442. midPoint1[0],
  36443. midPoint1[1]
  36444. )
  36445. path.bezierCurveTo(
  36446. midPoint2[0],
  36447. midPoint2[1],
  36448. midPoint2[0],
  36449. midPoint2[1],
  36450. points[2][0],
  36451. points[2][1]
  36452. )
  36453. } else {
  36454. for (var i = 1; i < points.length; i++) {
  36455. path.lineTo(points[i][0], points[i][1])
  36456. }
  36457. }
  36458. }
  36459. /**
  36460. * Create a label line if necessary and set it's style.
  36461. */ function setLabelLineStyle(targetEl, statesModels, defaultStyle) {
  36462. var labelLine = targetEl.getTextGuideLine()
  36463. var label = targetEl.getTextContent()
  36464. if (!label) {
  36465. // Not show label line if there is no label.
  36466. if (labelLine) {
  36467. targetEl.removeTextGuideLine()
  36468. }
  36469. return
  36470. }
  36471. var normalModel = statesModels.normal
  36472. var showNormal = normalModel.get('show')
  36473. var labelIgnoreNormal = label.ignore
  36474. for (var i = 0; i < DISPLAY_STATES.length; i++) {
  36475. var stateName = DISPLAY_STATES[i]
  36476. var stateModel = statesModels[stateName]
  36477. var isNormal = stateName === 'normal'
  36478. if (stateModel) {
  36479. var stateShow = stateModel.get('show')
  36480. var isLabelIgnored = isNormal
  36481. ? labelIgnoreNormal
  36482. : retrieve2(
  36483. label.states[stateName] && label.states[stateName].ignore,
  36484. labelIgnoreNormal
  36485. )
  36486. if (
  36487. isLabelIgnored || // Not show when label is not shown in this state.
  36488. !retrieve2(stateShow, showNormal) // Use normal state by default if not set.
  36489. ) {
  36490. var stateObj = isNormal
  36491. ? labelLine
  36492. : labelLine && labelLine.states[stateName]
  36493. if (stateObj) {
  36494. stateObj.ignore = true
  36495. }
  36496. continue
  36497. } // Create labelLine if not exists
  36498. if (!labelLine) {
  36499. labelLine = new Polyline$1()
  36500. targetEl.setTextGuideLine(labelLine) // Reset state of normal because it's new created.
  36501. // NOTE: NORMAL should always been the first!
  36502. if (!isNormal && (labelIgnoreNormal || !showNormal)) {
  36503. setLabelLineState(
  36504. labelLine,
  36505. true,
  36506. 'normal',
  36507. statesModels.normal
  36508. )
  36509. } // Use same state proxy.
  36510. if (targetEl.stateProxy) {
  36511. labelLine.stateProxy = targetEl.stateProxy
  36512. }
  36513. }
  36514. setLabelLineState(labelLine, false, stateName, stateModel)
  36515. }
  36516. }
  36517. if (labelLine) {
  36518. defaults(labelLine.style, defaultStyle) // Not fill.
  36519. labelLine.style.fill = null
  36520. var showAbove = normalModel.get('showAbove')
  36521. var labelLineConfig = (targetEl.textGuideLineConfig =
  36522. targetEl.textGuideLineConfig || {})
  36523. labelLineConfig.showAbove = showAbove || false // Custom the buildPath.
  36524. labelLine.buildPath = buildLabelLinePath
  36525. }
  36526. }
  36527. function getLabelLineStatesModels(itemModel, labelLineName) {
  36528. labelLineName = labelLineName || 'labelLine'
  36529. var statesModels = { normal: itemModel.getModel(labelLineName) }
  36530. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  36531. var stateName = SPECIAL_STATES[i]
  36532. statesModels[stateName] = itemModel.getModel([
  36533. stateName,
  36534. labelLineName
  36535. ])
  36536. }
  36537. return statesModels
  36538. }
  36539. function prepareLayoutList(input) {
  36540. var list = []
  36541. for (var i = 0; i < input.length; i++) {
  36542. var rawItem = input[i]
  36543. if (rawItem.defaultAttr.ignore) {
  36544. continue
  36545. }
  36546. var label = rawItem.label
  36547. var transform = label.getComputedTransform() // NOTE: Get bounding rect after getComputedTransform, or label may not been updated by the host el.
  36548. var localRect = label.getBoundingRect()
  36549. var isAxisAligned =
  36550. !transform || (transform[1] < 1e-5 && transform[2] < 1e-5)
  36551. var minMargin = label.style.margin || 0
  36552. var globalRect = localRect.clone()
  36553. globalRect.applyTransform(transform)
  36554. globalRect.x -= minMargin / 2
  36555. globalRect.y -= minMargin / 2
  36556. globalRect.width += minMargin
  36557. globalRect.height += minMargin
  36558. var obb = isAxisAligned
  36559. ? new OrientedBoundingRect$1(localRect, transform)
  36560. : null
  36561. list.push({
  36562. label: label,
  36563. labelLine: rawItem.labelLine,
  36564. rect: globalRect,
  36565. localRect: localRect,
  36566. obb: obb,
  36567. priority: rawItem.priority,
  36568. defaultAttr: rawItem.defaultAttr,
  36569. layoutOption: rawItem.computedLayoutOption,
  36570. axisAligned: isAxisAligned,
  36571. transform: transform
  36572. })
  36573. }
  36574. return list
  36575. }
  36576. function shiftLayout(
  36577. list,
  36578. xyDim,
  36579. sizeDim,
  36580. minBound,
  36581. maxBound,
  36582. balanceShift
  36583. ) {
  36584. var len = list.length
  36585. if (len < 2) {
  36586. return
  36587. }
  36588. list.sort(function (a, b) {
  36589. return a.rect[xyDim] - b.rect[xyDim]
  36590. })
  36591. var lastPos = 0
  36592. var delta
  36593. var adjusted = false
  36594. var totalShifts = 0
  36595. for (var i = 0; i < len; i++) {
  36596. var item = list[i]
  36597. var rect = item.rect
  36598. delta = rect[xyDim] - lastPos
  36599. if (delta < 0) {
  36600. // shiftForward(i, len, -delta);
  36601. rect[xyDim] -= delta
  36602. item.label[xyDim] -= delta
  36603. adjusted = true
  36604. }
  36605. var shift = Math.max(-delta, 0)
  36606. totalShifts += shift
  36607. lastPos = rect[xyDim] + rect[sizeDim]
  36608. }
  36609. if (totalShifts > 0 && balanceShift) {
  36610. // Shift back to make the distribution more equally.
  36611. shiftList(-totalShifts / len, 0, len)
  36612. } // TODO bleedMargin?
  36613. var first = list[0]
  36614. var last = list[len - 1]
  36615. var minGap
  36616. var maxGap
  36617. updateMinMaxGap() // If ends exceed two bounds, squeeze at most 80%, then take the gap of two bounds.
  36618. minGap < 0 && squeezeGaps(-minGap, 0.8)
  36619. maxGap < 0 && squeezeGaps(maxGap, 0.8)
  36620. updateMinMaxGap()
  36621. takeBoundsGap(minGap, maxGap, 1)
  36622. takeBoundsGap(maxGap, minGap, -1) // Handle bailout when there is not enough space.
  36623. updateMinMaxGap()
  36624. if (minGap < 0) {
  36625. squeezeWhenBailout(-minGap)
  36626. }
  36627. if (maxGap < 0) {
  36628. squeezeWhenBailout(maxGap)
  36629. }
  36630. function updateMinMaxGap() {
  36631. minGap = first.rect[xyDim] - minBound
  36632. maxGap = maxBound - last.rect[xyDim] - last.rect[sizeDim]
  36633. }
  36634. function takeBoundsGap(gapThisBound, gapOtherBound, moveDir) {
  36635. if (gapThisBound < 0) {
  36636. // Move from other gap if can.
  36637. var moveFromMaxGap = Math.min(gapOtherBound, -gapThisBound)
  36638. if (moveFromMaxGap > 0) {
  36639. shiftList(moveFromMaxGap * moveDir, 0, len)
  36640. var remained = moveFromMaxGap + gapThisBound
  36641. if (remained < 0) {
  36642. squeezeGaps(-remained * moveDir, 1)
  36643. }
  36644. } else {
  36645. squeezeGaps(-gapThisBound * moveDir, 1)
  36646. }
  36647. }
  36648. }
  36649. function shiftList(delta, start, end) {
  36650. if (delta !== 0) {
  36651. adjusted = true
  36652. }
  36653. for (var i = start; i < end; i++) {
  36654. var item = list[i]
  36655. var rect = item.rect
  36656. rect[xyDim] += delta
  36657. item.label[xyDim] += delta
  36658. }
  36659. } // Squeeze gaps if the labels exceed margin.
  36660. function squeezeGaps(delta, maxSqeezePercent) {
  36661. var gaps = []
  36662. var totalGaps = 0
  36663. for (var i = 1; i < len; i++) {
  36664. var prevItemRect = list[i - 1].rect
  36665. var gap = Math.max(
  36666. list[i].rect[xyDim] -
  36667. prevItemRect[xyDim] -
  36668. prevItemRect[sizeDim],
  36669. 0
  36670. )
  36671. gaps.push(gap)
  36672. totalGaps += gap
  36673. }
  36674. if (!totalGaps) {
  36675. return
  36676. }
  36677. var squeezePercent = Math.min(
  36678. Math.abs(delta) / totalGaps,
  36679. maxSqeezePercent
  36680. )
  36681. if (delta > 0) {
  36682. for (var i = 0; i < len - 1; i++) {
  36683. // Distribute the shift delta to all gaps.
  36684. var movement = gaps[i] * squeezePercent // Forward
  36685. shiftList(movement, 0, i + 1)
  36686. }
  36687. } else {
  36688. // Backward
  36689. for (var i = len - 1; i > 0; i--) {
  36690. // Distribute the shift delta to all gaps.
  36691. var movement = gaps[i - 1] * squeezePercent
  36692. shiftList(-movement, i, len)
  36693. }
  36694. }
  36695. }
  36696. /**
  36697. * Squeeze to allow overlap if there is no more space available.
  36698. * Let other overlapping strategy like hideOverlap do the job instead of keep exceeding the bounds.
  36699. */ function squeezeWhenBailout(delta) {
  36700. var dir = delta < 0 ? -1 : 1
  36701. delta = Math.abs(delta)
  36702. var moveForEachLabel = Math.ceil(delta / (len - 1))
  36703. for (var i = 0; i < len - 1; i++) {
  36704. if (dir > 0) {
  36705. // Forward
  36706. shiftList(moveForEachLabel, 0, i + 1)
  36707. } else {
  36708. // Backward
  36709. shiftList(-moveForEachLabel, len - i - 1, len)
  36710. }
  36711. delta -= moveForEachLabel
  36712. if (delta <= 0) {
  36713. return
  36714. }
  36715. }
  36716. }
  36717. return adjusted
  36718. }
  36719. /**
  36720. * Adjust labels on x direction to avoid overlap.
  36721. */ function shiftLayoutOnX(
  36722. list,
  36723. leftBound,
  36724. rightBound, // If average the shifts on all labels and add them to 0
  36725. // TODO: Not sure if should enable it.
  36726. // Pros: The angle of lines will distribute more equally
  36727. // Cons: In some layout. It may not what user wanted. like in pie. the label of last sector is usually changed unexpectedly.
  36728. balanceShift
  36729. ) {
  36730. return shiftLayout(
  36731. list,
  36732. 'x',
  36733. 'width',
  36734. leftBound,
  36735. rightBound,
  36736. balanceShift
  36737. )
  36738. }
  36739. /**
  36740. * Adjust labels on y direction to avoid overlap.
  36741. */ function shiftLayoutOnY(
  36742. list,
  36743. topBound,
  36744. bottomBound, // If average the shifts on all labels and add them to 0
  36745. balanceShift
  36746. ) {
  36747. return shiftLayout(
  36748. list,
  36749. 'y',
  36750. 'height',
  36751. topBound,
  36752. bottomBound,
  36753. balanceShift
  36754. )
  36755. }
  36756. function hideOverlap(labelList) {
  36757. var displayedLabels = [] // TODO, render overflow visible first, put in the displayedLabels.
  36758. labelList.sort(function (a, b) {
  36759. return b.priority - a.priority
  36760. })
  36761. var globalRect = new BoundingRect$1(0, 0, 0, 0)
  36762. function hideEl(el) {
  36763. if (!el.ignore) {
  36764. // Show on emphasis.
  36765. var emphasisState = el.ensureState('emphasis')
  36766. if (emphasisState.ignore == null) {
  36767. emphasisState.ignore = false
  36768. }
  36769. }
  36770. el.ignore = true
  36771. }
  36772. for (var i = 0; i < labelList.length; i++) {
  36773. var labelItem = labelList[i]
  36774. var isAxisAligned = labelItem.axisAligned
  36775. var localRect = labelItem.localRect
  36776. var transform = labelItem.transform
  36777. var label = labelItem.label
  36778. var labelLine = labelItem.labelLine
  36779. globalRect.copy(labelItem.rect) // Add a threshold because layout may be aligned precisely.
  36780. globalRect.width -= 0.1
  36781. globalRect.height -= 0.1
  36782. globalRect.x += 0.05
  36783. globalRect.y += 0.05
  36784. var obb = labelItem.obb
  36785. var overlapped = false
  36786. for (var j = 0; j < displayedLabels.length; j++) {
  36787. var existsTextCfg = displayedLabels[j] // Fast rejection.
  36788. if (!globalRect.intersect(existsTextCfg.rect)) {
  36789. continue
  36790. }
  36791. if (isAxisAligned && existsTextCfg.axisAligned) {
  36792. // Is overlapped
  36793. overlapped = true
  36794. break
  36795. }
  36796. if (!existsTextCfg.obb) {
  36797. // If self is not axis aligned. But other is.
  36798. existsTextCfg.obb = new OrientedBoundingRect$1(
  36799. existsTextCfg.localRect,
  36800. existsTextCfg.transform
  36801. )
  36802. }
  36803. if (!obb) {
  36804. // If self is axis aligned. But other is not.
  36805. obb = new OrientedBoundingRect$1(localRect, transform)
  36806. }
  36807. if (obb.intersect(existsTextCfg.obb)) {
  36808. overlapped = true
  36809. break
  36810. }
  36811. } // TODO Callback to determine if this overlap should be handled?
  36812. if (overlapped) {
  36813. hideEl(label)
  36814. labelLine && hideEl(labelLine)
  36815. } else {
  36816. label.attr('ignore', labelItem.defaultAttr.ignore)
  36817. labelLine &&
  36818. labelLine.attr(
  36819. 'ignore',
  36820. labelItem.defaultAttr.labelGuideIgnore
  36821. )
  36822. displayedLabels.push(labelItem)
  36823. }
  36824. }
  36825. }
  36826. function cloneArr(points) {
  36827. if (points) {
  36828. var newPoints = []
  36829. for (var i = 0; i < points.length; i++) {
  36830. newPoints.push(points[i].slice())
  36831. }
  36832. return newPoints
  36833. }
  36834. }
  36835. function prepareLayoutCallbackParams(labelItem, hostEl) {
  36836. var label = labelItem.label
  36837. var labelLine = hostEl && hostEl.getTextGuideLine()
  36838. return {
  36839. dataIndex: labelItem.dataIndex,
  36840. dataType: labelItem.dataType,
  36841. seriesIndex: labelItem.seriesModel.seriesIndex,
  36842. text: labelItem.label.style.text,
  36843. rect: labelItem.hostRect,
  36844. labelRect: labelItem.rect, // x: labelAttr.x,
  36845. // y: labelAttr.y,
  36846. align: label.style.align,
  36847. verticalAlign: label.style.verticalAlign,
  36848. labelLinePoints: cloneArr(labelLine && labelLine.shape.points)
  36849. }
  36850. }
  36851. var LABEL_OPTION_TO_STYLE_KEYS = [
  36852. 'align',
  36853. 'verticalAlign',
  36854. 'width',
  36855. 'height',
  36856. 'fontSize'
  36857. ]
  36858. var dummyTransformable = new Transformable()
  36859. var labelLayoutInnerStore = makeInner()
  36860. var labelLineAnimationStore = makeInner()
  36861. function extendWithKeys(target, source, keys) {
  36862. for (var i = 0; i < keys.length; i++) {
  36863. var key = keys[i]
  36864. if (source[key] != null) {
  36865. target[key] = source[key]
  36866. }
  36867. }
  36868. }
  36869. var LABEL_LAYOUT_PROPS = ['x', 'y', 'rotation']
  36870. var LabelManager = /** @class */ (function () {
  36871. function LabelManager() {
  36872. this._labelList = []
  36873. this._chartViewList = []
  36874. }
  36875. LabelManager.prototype.clearLabels = function () {
  36876. this._labelList = []
  36877. this._chartViewList = []
  36878. }
  36879. /**
  36880. * Add label to manager
  36881. */ LabelManager.prototype._addLabel = function (
  36882. dataIndex,
  36883. dataType,
  36884. seriesModel,
  36885. label,
  36886. layoutOption
  36887. ) {
  36888. var labelStyle = label.style
  36889. var hostEl = label.__hostTarget
  36890. var textConfig = hostEl.textConfig || {} // TODO: If label is in other state.
  36891. var labelTransform = label.getComputedTransform()
  36892. var labelRect = label.getBoundingRect().plain()
  36893. BoundingRect$1.applyTransform(
  36894. labelRect,
  36895. labelRect,
  36896. labelTransform
  36897. )
  36898. if (labelTransform) {
  36899. dummyTransformable.setLocalTransform(labelTransform)
  36900. } else {
  36901. // Identity transform.
  36902. dummyTransformable.x =
  36903. dummyTransformable.y =
  36904. dummyTransformable.rotation =
  36905. dummyTransformable.originX =
  36906. dummyTransformable.originY =
  36907. 0
  36908. dummyTransformable.scaleX = dummyTransformable.scaleY = 1
  36909. }
  36910. var host = label.__hostTarget
  36911. var hostRect
  36912. if (host) {
  36913. hostRect = host.getBoundingRect().plain()
  36914. var transform = host.getComputedTransform()
  36915. BoundingRect$1.applyTransform(hostRect, hostRect, transform)
  36916. }
  36917. var labelGuide = hostRect && host.getTextGuideLine()
  36918. this._labelList.push({
  36919. label: label,
  36920. labelLine: labelGuide,
  36921. seriesModel: seriesModel,
  36922. dataIndex: dataIndex,
  36923. dataType: dataType,
  36924. layoutOption: layoutOption,
  36925. computedLayoutOption: null,
  36926. rect: labelRect,
  36927. hostRect: hostRect, // Label with lower priority will be hidden when overlapped
  36928. // Use rect size as default priority
  36929. priority: hostRect ? hostRect.width * hostRect.height : 0, // Save default label attributes.
  36930. // For restore if developers want get back to default value in callback.
  36931. defaultAttr: {
  36932. ignore: label.ignore,
  36933. labelGuideIgnore: labelGuide && labelGuide.ignore,
  36934. x: dummyTransformable.x,
  36935. y: dummyTransformable.y,
  36936. scaleX: dummyTransformable.scaleX,
  36937. scaleY: dummyTransformable.scaleY,
  36938. rotation: dummyTransformable.rotation,
  36939. style: {
  36940. x: labelStyle.x,
  36941. y: labelStyle.y,
  36942. align: labelStyle.align,
  36943. verticalAlign: labelStyle.verticalAlign,
  36944. width: labelStyle.width,
  36945. height: labelStyle.height,
  36946. fontSize: labelStyle.fontSize
  36947. },
  36948. cursor: label.cursor,
  36949. attachedPos: textConfig.position,
  36950. attachedRot: textConfig.rotation
  36951. }
  36952. })
  36953. }
  36954. LabelManager.prototype.addLabelsOfSeries = function (chartView) {
  36955. var _this = this
  36956. this._chartViewList.push(chartView)
  36957. var seriesModel = chartView.__model
  36958. var layoutOption = seriesModel.get('labelLayout')
  36959. /**
  36960. * Ignore layouting if it's not specified anything.
  36961. */ if (
  36962. !(isFunction(layoutOption) || keys(layoutOption).length)
  36963. ) {
  36964. return
  36965. }
  36966. chartView.group.traverse(function (child) {
  36967. if (child.ignore) {
  36968. return true // Stop traverse descendants.
  36969. } // Only support label being hosted on graphic elements.
  36970. var textEl = child.getTextContent()
  36971. var ecData = getECData(child) // Can only attach the text on the element with dataIndex
  36972. if (textEl && !textEl.disableLabelLayout) {
  36973. _this._addLabel(
  36974. ecData.dataIndex,
  36975. ecData.dataType,
  36976. seriesModel,
  36977. textEl,
  36978. layoutOption
  36979. )
  36980. }
  36981. })
  36982. }
  36983. LabelManager.prototype.updateLayoutConfig = function (api) {
  36984. var width = api.getWidth()
  36985. var height = api.getHeight()
  36986. function createDragHandler(el, labelLineModel) {
  36987. return function () {
  36988. updateLabelLinePoints(el, labelLineModel)
  36989. }
  36990. }
  36991. for (var i = 0; i < this._labelList.length; i++) {
  36992. var labelItem = this._labelList[i]
  36993. var label = labelItem.label
  36994. var hostEl = label.__hostTarget
  36995. var defaultLabelAttr = labelItem.defaultAttr
  36996. var layoutOption = void 0 // TODO A global layout option?
  36997. if (isFunction(labelItem.layoutOption)) {
  36998. layoutOption = labelItem.layoutOption(
  36999. prepareLayoutCallbackParams(labelItem, hostEl)
  37000. )
  37001. } else {
  37002. layoutOption = labelItem.layoutOption
  37003. }
  37004. layoutOption = layoutOption || {}
  37005. labelItem.computedLayoutOption = layoutOption
  37006. var degreeToRadian = Math.PI / 180 // TODO hostEl should always exists.
  37007. // Or label should not have parent because the x, y is all in global space.
  37008. if (hostEl) {
  37009. hostEl.setTextConfig({
  37010. // Force to set local false.
  37011. local: false, // Ignore position and rotation config on the host el if x or y is changed.
  37012. position:
  37013. layoutOption.x != null || layoutOption.y != null
  37014. ? null
  37015. : defaultLabelAttr.attachedPos, // Ignore rotation config on the host el if rotation is changed.
  37016. rotation:
  37017. layoutOption.rotate != null
  37018. ? layoutOption.rotate * degreeToRadian
  37019. : defaultLabelAttr.attachedRot,
  37020. offset: [layoutOption.dx || 0, layoutOption.dy || 0]
  37021. })
  37022. }
  37023. var needsUpdateLabelLine = false
  37024. if (layoutOption.x != null) {
  37025. // TODO width of chart view.
  37026. label.x = parsePercent(layoutOption.x, width)
  37027. label.setStyle('x', 0) // Ignore movement in style. TODO: origin.
  37028. needsUpdateLabelLine = true
  37029. } else {
  37030. label.x = defaultLabelAttr.x
  37031. label.setStyle('x', defaultLabelAttr.style.x)
  37032. }
  37033. if (layoutOption.y != null) {
  37034. // TODO height of chart view.
  37035. label.y = parsePercent(layoutOption.y, height)
  37036. label.setStyle('y', 0) // Ignore movement in style.
  37037. needsUpdateLabelLine = true
  37038. } else {
  37039. label.y = defaultLabelAttr.y
  37040. label.setStyle('y', defaultLabelAttr.style.y)
  37041. }
  37042. if (layoutOption.labelLinePoints) {
  37043. var guideLine = hostEl.getTextGuideLine()
  37044. if (guideLine) {
  37045. guideLine.setShape({ points: layoutOption.labelLinePoints }) // Not update
  37046. needsUpdateLabelLine = false
  37047. }
  37048. }
  37049. var labelLayoutStore = labelLayoutInnerStore(label)
  37050. labelLayoutStore.needsUpdateLabelLine = needsUpdateLabelLine
  37051. label.rotation =
  37052. layoutOption.rotate != null
  37053. ? layoutOption.rotate * degreeToRadian
  37054. : defaultLabelAttr.rotation
  37055. label.scaleX = defaultLabelAttr.scaleX
  37056. label.scaleY = defaultLabelAttr.scaleY
  37057. for (var k = 0; k < LABEL_OPTION_TO_STYLE_KEYS.length; k++) {
  37058. var key = LABEL_OPTION_TO_STYLE_KEYS[k]
  37059. label.setStyle(
  37060. key,
  37061. layoutOption[key] != null
  37062. ? layoutOption[key]
  37063. : defaultLabelAttr.style[key]
  37064. )
  37065. }
  37066. if (layoutOption.draggable) {
  37067. label.draggable = true
  37068. label.cursor = 'move'
  37069. if (hostEl) {
  37070. var hostModel = labelItem.seriesModel
  37071. if (labelItem.dataIndex != null) {
  37072. var data = labelItem.seriesModel.getData(
  37073. labelItem.dataType
  37074. )
  37075. hostModel = data.getItemModel(labelItem.dataIndex)
  37076. }
  37077. label.on(
  37078. 'drag',
  37079. createDragHandler(hostEl, hostModel.getModel('labelLine'))
  37080. )
  37081. }
  37082. } else {
  37083. // TODO Other drag functions?
  37084. label.off('drag')
  37085. label.cursor = defaultLabelAttr.cursor
  37086. }
  37087. }
  37088. }
  37089. LabelManager.prototype.layout = function (api) {
  37090. var width = api.getWidth()
  37091. var height = api.getHeight()
  37092. var labelList = prepareLayoutList(this._labelList)
  37093. var labelsNeedsAdjustOnX = filter(labelList, function (item) {
  37094. return item.layoutOption.moveOverlap === 'shiftX'
  37095. })
  37096. var labelsNeedsAdjustOnY = filter(labelList, function (item) {
  37097. return item.layoutOption.moveOverlap === 'shiftY'
  37098. })
  37099. shiftLayoutOnX(labelsNeedsAdjustOnX, 0, width)
  37100. shiftLayoutOnY(labelsNeedsAdjustOnY, 0, height)
  37101. var labelsNeedsHideOverlap = filter(labelList, function (item) {
  37102. return item.layoutOption.hideOverlap
  37103. })
  37104. hideOverlap(labelsNeedsHideOverlap)
  37105. }
  37106. /**
  37107. * Process all labels. Not only labels with layoutOption.
  37108. */ LabelManager.prototype.processLabelsOverall = function () {
  37109. var _this = this
  37110. each$7(this._chartViewList, function (chartView) {
  37111. var seriesModel = chartView.__model
  37112. var ignoreLabelLineUpdate = chartView.ignoreLabelLineUpdate
  37113. var animationEnabled = seriesModel.isAnimationEnabled()
  37114. chartView.group.traverse(function (child) {
  37115. if (child.ignore && !child.forceLabelAnimation) {
  37116. return true // Stop traverse descendants.
  37117. }
  37118. var needsUpdateLabelLine = !ignoreLabelLineUpdate
  37119. var label = child.getTextContent()
  37120. if (!needsUpdateLabelLine && label) {
  37121. needsUpdateLabelLine =
  37122. labelLayoutInnerStore(label).needsUpdateLabelLine
  37123. }
  37124. if (needsUpdateLabelLine) {
  37125. _this._updateLabelLine(child, seriesModel)
  37126. }
  37127. if (animationEnabled) {
  37128. _this._animateLabels(child, seriesModel)
  37129. }
  37130. })
  37131. })
  37132. }
  37133. LabelManager.prototype._updateLabelLine = function (
  37134. el,
  37135. seriesModel
  37136. ) {
  37137. // Only support label being hosted on graphic elements.
  37138. var textEl = el.getTextContent() // Update label line style.
  37139. var ecData = getECData(el)
  37140. var dataIndex = ecData.dataIndex // Only support labelLine on the labels represent data.
  37141. if (textEl && dataIndex != null) {
  37142. var data = seriesModel.getData(ecData.dataType)
  37143. var itemModel = data.getItemModel(dataIndex)
  37144. var defaultStyle = {}
  37145. var visualStyle = data.getItemVisual(dataIndex, 'style')
  37146. var visualType = data.getVisual('drawType') // Default to be same with main color
  37147. defaultStyle.stroke = visualStyle[visualType]
  37148. var labelLineModel = itemModel.getModel('labelLine')
  37149. setLabelLineStyle(
  37150. el,
  37151. getLabelLineStatesModels(itemModel),
  37152. defaultStyle
  37153. )
  37154. updateLabelLinePoints(el, labelLineModel)
  37155. }
  37156. }
  37157. LabelManager.prototype._animateLabels = function (el, seriesModel) {
  37158. var textEl = el.getTextContent()
  37159. var guideLine = el.getTextGuideLine() // Animate
  37160. if (
  37161. textEl && // `forceLabelAnimation` has the highest priority
  37162. (el.forceLabelAnimation ||
  37163. (!textEl.ignore &&
  37164. !textEl.invisible &&
  37165. !el.disableLabelAnimation &&
  37166. !isElementRemoved(el)))
  37167. ) {
  37168. var layoutStore = labelLayoutInnerStore(textEl)
  37169. var oldLayout = layoutStore.oldLayout
  37170. var ecData = getECData(el)
  37171. var dataIndex = ecData.dataIndex
  37172. var newProps = {
  37173. x: textEl.x,
  37174. y: textEl.y,
  37175. rotation: textEl.rotation
  37176. }
  37177. var data = seriesModel.getData(ecData.dataType)
  37178. if (!oldLayout) {
  37179. textEl.attr(newProps) // Disable fade in animation if value animation is enabled.
  37180. if (!labelInner(textEl).valueAnimation) {
  37181. var oldOpacity = retrieve2(textEl.style.opacity, 1) // Fade in animation
  37182. textEl.style.opacity = 0
  37183. initProps(
  37184. textEl,
  37185. { style: { opacity: oldOpacity } },
  37186. seriesModel,
  37187. dataIndex
  37188. )
  37189. }
  37190. } else {
  37191. textEl.attr(oldLayout) // Make sure the animation from is in the right status.
  37192. var prevStates = el.prevStates
  37193. if (prevStates) {
  37194. if (indexOf(prevStates, 'select') >= 0) {
  37195. textEl.attr(layoutStore.oldLayoutSelect)
  37196. }
  37197. if (indexOf(prevStates, 'emphasis') >= 0) {
  37198. textEl.attr(layoutStore.oldLayoutEmphasis)
  37199. }
  37200. }
  37201. updateProps$1(textEl, newProps, seriesModel, dataIndex)
  37202. }
  37203. layoutStore.oldLayout = newProps
  37204. if (textEl.states.select) {
  37205. var layoutSelect = (layoutStore.oldLayoutSelect = {})
  37206. extendWithKeys(layoutSelect, newProps, LABEL_LAYOUT_PROPS)
  37207. extendWithKeys(
  37208. layoutSelect,
  37209. textEl.states.select,
  37210. LABEL_LAYOUT_PROPS
  37211. )
  37212. }
  37213. if (textEl.states.emphasis) {
  37214. var layoutEmphasis = (layoutStore.oldLayoutEmphasis = {})
  37215. extendWithKeys(layoutEmphasis, newProps, LABEL_LAYOUT_PROPS)
  37216. extendWithKeys(
  37217. layoutEmphasis,
  37218. textEl.states.emphasis,
  37219. LABEL_LAYOUT_PROPS
  37220. )
  37221. }
  37222. animateLabelValue(
  37223. textEl,
  37224. dataIndex,
  37225. data,
  37226. seriesModel,
  37227. seriesModel
  37228. )
  37229. }
  37230. if (guideLine && !guideLine.ignore && !guideLine.invisible) {
  37231. var layoutStore = labelLineAnimationStore(guideLine)
  37232. var oldLayout = layoutStore.oldLayout
  37233. var newLayout = { points: guideLine.shape.points }
  37234. if (!oldLayout) {
  37235. guideLine.setShape(newLayout)
  37236. guideLine.style.strokePercent = 0
  37237. initProps(
  37238. guideLine,
  37239. { style: { strokePercent: 1 } },
  37240. seriesModel
  37241. )
  37242. } else {
  37243. guideLine.attr({ shape: oldLayout })
  37244. updateProps$1(guideLine, { shape: newLayout }, seriesModel)
  37245. }
  37246. layoutStore.oldLayout = newLayout
  37247. }
  37248. }
  37249. return LabelManager
  37250. })()
  37251. var LabelManager$1 = LabelManager
  37252. var getLabelManager = makeInner()
  37253. function installLabelLayout(registers) {
  37254. registers.registerUpdateLifecycle(
  37255. 'series:beforeupdate',
  37256. function (ecModel, api, params) {
  37257. // TODO api provide an namespace that can save stuff per instance
  37258. var labelManager = getLabelManager(api).labelManager
  37259. if (!labelManager) {
  37260. labelManager = getLabelManager(api).labelManager =
  37261. new LabelManager$1()
  37262. }
  37263. labelManager.clearLabels()
  37264. }
  37265. )
  37266. registers.registerUpdateLifecycle(
  37267. 'series:layoutlabels',
  37268. function (ecModel, api, params) {
  37269. var labelManager = getLabelManager(api).labelManager
  37270. params.updatedSeries.forEach(function (series) {
  37271. labelManager.addLabelsOfSeries(
  37272. api.getViewOfSeriesModel(series)
  37273. )
  37274. })
  37275. labelManager.updateLayoutConfig(api)
  37276. labelManager.layout(api)
  37277. labelManager.processLabelsOverall()
  37278. }
  37279. )
  37280. }
  37281. var LineSeriesModel = /** @class */ (function (_super) {
  37282. __extends(LineSeriesModel, _super)
  37283. function LineSeriesModel() {
  37284. var _this =
  37285. (_super !== null && _super.apply(this, arguments)) || this
  37286. _this.type = LineSeriesModel.type
  37287. _this.hasSymbolVisual = true
  37288. return _this
  37289. }
  37290. LineSeriesModel.prototype.getInitialData = function (option) {
  37291. return createSeriesData(null, this, { useEncodeDefaulter: true })
  37292. }
  37293. LineSeriesModel.prototype.getLegendIcon = function (opt) {
  37294. var group = new Group$3()
  37295. var line = createSymbol(
  37296. 'line',
  37297. 0,
  37298. opt.itemHeight / 2,
  37299. opt.itemWidth,
  37300. 0,
  37301. opt.lineStyle.stroke,
  37302. false
  37303. )
  37304. group.add(line)
  37305. line.setStyle(opt.lineStyle)
  37306. var visualType = this.getData().getVisual('symbol')
  37307. var visualRotate = this.getData().getVisual('symbolRotate')
  37308. var symbolType = visualType === 'none' ? 'circle' : visualType // Symbol size is 80% when there is a line
  37309. var size = opt.itemHeight * 0.8
  37310. var symbol = createSymbol(
  37311. symbolType,
  37312. (opt.itemWidth - size) / 2,
  37313. (opt.itemHeight - size) / 2,
  37314. size,
  37315. size,
  37316. opt.itemStyle.fill
  37317. )
  37318. group.add(symbol)
  37319. symbol.setStyle(opt.itemStyle)
  37320. var symbolRotate =
  37321. opt.iconRotate === 'inherit'
  37322. ? visualRotate
  37323. : opt.iconRotate || 0
  37324. symbol.rotation = (symbolRotate * Math.PI) / 180
  37325. symbol.setOrigin([opt.itemWidth / 2, opt.itemHeight / 2])
  37326. if (symbolType.indexOf('empty') > -1) {
  37327. symbol.style.stroke = symbol.style.fill
  37328. symbol.style.fill = '#fff'
  37329. symbol.style.lineWidth = 2
  37330. }
  37331. return group
  37332. }
  37333. LineSeriesModel.type = 'series.line'
  37334. LineSeriesModel.dependencies = ['grid', 'polar']
  37335. LineSeriesModel.defaultOption = {
  37336. // zlevel: 0,
  37337. z: 3,
  37338. coordinateSystem: 'cartesian2d',
  37339. legendHoverLink: true,
  37340. clip: true,
  37341. label: { position: 'top' }, // itemStyle: {
  37342. // },
  37343. endLabel: { show: false, valueAnimation: true, distance: 8 },
  37344. lineStyle: { width: 2, type: 'solid' },
  37345. emphasis: { scale: true }, // areaStyle: {
  37346. // origin of areaStyle. Valid values:
  37347. // `'auto'/null/undefined`: from axisLine to data
  37348. // `'start'`: from min to data
  37349. // `'end'`: from data to max
  37350. // origin: 'auto'
  37351. // },
  37352. // false, 'start', 'end', 'middle'
  37353. step: false, // Disabled if step is true
  37354. smooth: false,
  37355. smoothMonotone: null,
  37356. symbol: 'emptyCircle',
  37357. symbolSize: 4,
  37358. symbolRotate: null,
  37359. showSymbol: true, // `false`: follow the label interval strategy.
  37360. // `true`: show all symbols.
  37361. // `'auto'`: If possible, show all symbols, otherwise
  37362. // follow the label interval strategy.
  37363. showAllSymbol: 'auto', // Whether to connect break point.
  37364. connectNulls: false, // Sampling for large data. Can be: 'average', 'max', 'min', 'sum', 'lttb'.
  37365. sampling: 'none',
  37366. animationEasing: 'linear', // Disable progressive
  37367. progressive: 0,
  37368. hoverLayerThreshold: Infinity,
  37369. universalTransition: { divideShape: 'clone' },
  37370. triggerLineEvent: false
  37371. }
  37372. return LineSeriesModel
  37373. })(SeriesModel$1)
  37374. var LineSeries = LineSeriesModel
  37375. /**
  37376. * @return label string. Not null/undefined
  37377. */ function getDefaultLabel(data, dataIndex) {
  37378. var labelDims = data.mapDimensionsAll('defaultedLabel')
  37379. var len = labelDims.length // Simple optimization (in lots of cases, label dims length is 1)
  37380. if (len === 1) {
  37381. var rawVal = retrieveRawValue(data, dataIndex, labelDims[0])
  37382. return rawVal != null ? rawVal + '' : null
  37383. } else if (len) {
  37384. var vals = []
  37385. for (var i = 0; i < labelDims.length; i++) {
  37386. vals.push(retrieveRawValue(data, dataIndex, labelDims[i]))
  37387. }
  37388. return vals.join(' ')
  37389. }
  37390. }
  37391. function getDefaultInterpolatedLabel(data, interpolatedValue) {
  37392. var labelDims = data.mapDimensionsAll('defaultedLabel')
  37393. if (!isArray(interpolatedValue)) {
  37394. return interpolatedValue + ''
  37395. }
  37396. var vals = []
  37397. for (var i = 0; i < labelDims.length; i++) {
  37398. var dimIndex = data.getDimensionIndex(labelDims[i])
  37399. if (dimIndex >= 0) {
  37400. vals.push(interpolatedValue[dimIndex])
  37401. }
  37402. }
  37403. return vals.join(' ')
  37404. }
  37405. var Symbol$1 = /** @class */ (function (_super) {
  37406. __extends(_Symbol, _super)
  37407. function _Symbol(data, idx, seriesScope, opts) {
  37408. var _this = _super.call(this) || this
  37409. _this.updateData(data, idx, seriesScope, opts)
  37410. return _this
  37411. }
  37412. _Symbol.prototype._createSymbol = function (
  37413. symbolType,
  37414. data,
  37415. idx,
  37416. symbolSize,
  37417. keepAspect
  37418. ) {
  37419. // Remove paths created before
  37420. this.removeAll() // let symbolPath = createSymbol(
  37421. // symbolType, -0.5, -0.5, 1, 1, color
  37422. // );
  37423. // If width/height are set too small (e.g., set to 1) on ios10
  37424. // and macOS Sierra, a circle stroke become a rect, no matter what
  37425. // the scale is set. So we set width/height as 2. See #4150.
  37426. var symbolPath = createSymbol(
  37427. symbolType,
  37428. -1,
  37429. -1,
  37430. 2,
  37431. 2,
  37432. null,
  37433. keepAspect
  37434. )
  37435. symbolPath.attr({
  37436. z2: 100,
  37437. culling: true,
  37438. scaleX: symbolSize[0] / 2,
  37439. scaleY: symbolSize[1] / 2
  37440. }) // Rewrite drift method
  37441. symbolPath.drift = driftSymbol
  37442. this._symbolType = symbolType
  37443. this.add(symbolPath)
  37444. }
  37445. /**
  37446. * Stop animation
  37447. * @param {boolean} toLastFrame
  37448. */ _Symbol.prototype.stopSymbolAnimation = function (toLastFrame) {
  37449. this.childAt(0).stopAnimation(null, toLastFrame)
  37450. }
  37451. _Symbol.prototype.getSymbolType = function () {
  37452. return this._symbolType
  37453. }
  37454. /**
  37455. * FIXME:
  37456. * Caution: This method breaks the encapsulation of this module,
  37457. * but it indeed brings convenience. So do not use the method
  37458. * unless you detailedly know all the implements of `Symbol`,
  37459. * especially animation.
  37460. *
  37461. * Get symbol path element.
  37462. */ _Symbol.prototype.getSymbolPath = function () {
  37463. return this.childAt(0)
  37464. }
  37465. /**
  37466. * Highlight symbol
  37467. */ _Symbol.prototype.highlight = function () {
  37468. enterEmphasis(this.childAt(0))
  37469. }
  37470. /**
  37471. * Downplay symbol
  37472. */ _Symbol.prototype.downplay = function () {
  37473. leaveEmphasis(this.childAt(0))
  37474. }
  37475. /**
  37476. * @param {number} zlevel
  37477. * @param {number} z
  37478. */ _Symbol.prototype.setZ = function (zlevel, z) {
  37479. var symbolPath = this.childAt(0)
  37480. symbolPath.zlevel = zlevel
  37481. symbolPath.z = z
  37482. }
  37483. _Symbol.prototype.setDraggable = function (
  37484. draggable,
  37485. hasCursorOption
  37486. ) {
  37487. var symbolPath = this.childAt(0)
  37488. symbolPath.draggable = draggable
  37489. symbolPath.cursor =
  37490. !hasCursorOption && draggable ? 'move' : symbolPath.cursor
  37491. }
  37492. /**
  37493. * Update symbol properties
  37494. */ _Symbol.prototype.updateData = function (
  37495. data,
  37496. idx,
  37497. seriesScope,
  37498. opts
  37499. ) {
  37500. this.silent = false
  37501. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle'
  37502. var seriesModel = data.hostModel
  37503. var symbolSize = _Symbol.getSymbolSize(data, idx)
  37504. var isInit = symbolType !== this._symbolType
  37505. var disableAnimation = opts && opts.disableAnimation
  37506. if (isInit) {
  37507. var keepAspect = data.getItemVisual(idx, 'symbolKeepAspect')
  37508. this._createSymbol(
  37509. symbolType,
  37510. data,
  37511. idx,
  37512. symbolSize,
  37513. keepAspect
  37514. )
  37515. } else {
  37516. var symbolPath = this.childAt(0)
  37517. symbolPath.silent = false
  37518. var target = {
  37519. scaleX: symbolSize[0] / 2,
  37520. scaleY: symbolSize[1] / 2
  37521. }
  37522. disableAnimation
  37523. ? symbolPath.attr(target)
  37524. : updateProps$1(symbolPath, target, seriesModel, idx)
  37525. saveOldStyle(symbolPath)
  37526. }
  37527. this._updateCommon(data, idx, symbolSize, seriesScope, opts)
  37528. if (isInit) {
  37529. var symbolPath = this.childAt(0)
  37530. if (!disableAnimation) {
  37531. var target = {
  37532. scaleX: this._sizeX,
  37533. scaleY: this._sizeY,
  37534. style: {
  37535. // Always fadeIn. Because it has fadeOut animation when symbol is removed..
  37536. opacity: symbolPath.style.opacity
  37537. }
  37538. }
  37539. symbolPath.scaleX = symbolPath.scaleY = 0
  37540. symbolPath.style.opacity = 0
  37541. initProps(symbolPath, target, seriesModel, idx)
  37542. }
  37543. }
  37544. if (disableAnimation) {
  37545. // Must stop leave transition manually if don't call initProps or updateProps.
  37546. this.childAt(0).stopAnimation('leave')
  37547. }
  37548. }
  37549. _Symbol.prototype._updateCommon = function (
  37550. data,
  37551. idx,
  37552. symbolSize,
  37553. seriesScope,
  37554. opts
  37555. ) {
  37556. var symbolPath = this.childAt(0)
  37557. var seriesModel = data.hostModel
  37558. var emphasisItemStyle
  37559. var blurItemStyle
  37560. var selectItemStyle
  37561. var focus
  37562. var blurScope
  37563. var emphasisDisabled
  37564. var labelStatesModels
  37565. var hoverScale
  37566. var cursorStyle
  37567. if (seriesScope) {
  37568. emphasisItemStyle = seriesScope.emphasisItemStyle
  37569. blurItemStyle = seriesScope.blurItemStyle
  37570. selectItemStyle = seriesScope.selectItemStyle
  37571. focus = seriesScope.focus
  37572. blurScope = seriesScope.blurScope
  37573. labelStatesModels = seriesScope.labelStatesModels
  37574. hoverScale = seriesScope.hoverScale
  37575. cursorStyle = seriesScope.cursorStyle
  37576. emphasisDisabled = seriesScope.emphasisDisabled
  37577. }
  37578. if (!seriesScope || data.hasItemOption) {
  37579. var itemModel =
  37580. seriesScope && seriesScope.itemModel
  37581. ? seriesScope.itemModel
  37582. : data.getItemModel(idx)
  37583. var emphasisModel = itemModel.getModel('emphasis')
  37584. emphasisItemStyle = emphasisModel
  37585. .getModel('itemStyle')
  37586. .getItemStyle()
  37587. selectItemStyle = itemModel
  37588. .getModel(['select', 'itemStyle'])
  37589. .getItemStyle()
  37590. blurItemStyle = itemModel
  37591. .getModel(['blur', 'itemStyle'])
  37592. .getItemStyle()
  37593. focus = emphasisModel.get('focus')
  37594. blurScope = emphasisModel.get('blurScope')
  37595. emphasisDisabled = emphasisModel.get('disabled')
  37596. labelStatesModels = getLabelStatesModels(itemModel)
  37597. hoverScale = emphasisModel.getShallow('scale')
  37598. cursorStyle = itemModel.getShallow('cursor')
  37599. }
  37600. var symbolRotate = data.getItemVisual(idx, 'symbolRotate')
  37601. symbolPath.attr(
  37602. 'rotation',
  37603. ((symbolRotate || 0) * Math.PI) / 180 || 0
  37604. )
  37605. var symbolOffset = normalizeSymbolOffset(
  37606. data.getItemVisual(idx, 'symbolOffset'),
  37607. symbolSize
  37608. )
  37609. if (symbolOffset) {
  37610. symbolPath.x = symbolOffset[0]
  37611. symbolPath.y = symbolOffset[1]
  37612. }
  37613. cursorStyle && symbolPath.attr('cursor', cursorStyle)
  37614. var symbolStyle = data.getItemVisual(idx, 'style')
  37615. var visualColor = symbolStyle.fill
  37616. if (symbolPath instanceof ZRImage$1) {
  37617. var pathStyle = symbolPath.style
  37618. symbolPath.useStyle(
  37619. extend(
  37620. {
  37621. // TODO other properties like x, y ?
  37622. image: pathStyle.image,
  37623. x: pathStyle.x,
  37624. y: pathStyle.y,
  37625. width: pathStyle.width,
  37626. height: pathStyle.height
  37627. },
  37628. symbolStyle
  37629. )
  37630. )
  37631. } else {
  37632. if (symbolPath.__isEmptyBrush) {
  37633. // fill and stroke will be swapped if it's empty.
  37634. // So we cloned a new style to avoid it affecting the original style in visual storage.
  37635. // TODO Better implementation. No empty logic!
  37636. symbolPath.useStyle(extend({}, symbolStyle))
  37637. } else {
  37638. symbolPath.useStyle(symbolStyle)
  37639. } // Disable decal because symbol scale will been applied on the decal.
  37640. symbolPath.style.decal = null
  37641. symbolPath.setColor(visualColor, opts && opts.symbolInnerColor)
  37642. symbolPath.style.strokeNoScale = true
  37643. }
  37644. var liftZ = data.getItemVisual(idx, 'liftZ')
  37645. var z2Origin = this._z2
  37646. if (liftZ != null) {
  37647. if (z2Origin == null) {
  37648. this._z2 = symbolPath.z2
  37649. symbolPath.z2 += liftZ
  37650. }
  37651. } else if (z2Origin != null) {
  37652. symbolPath.z2 = z2Origin
  37653. this._z2 = null
  37654. }
  37655. var useNameLabel = opts && opts.useNameLabel
  37656. setLabelStyle(symbolPath, labelStatesModels, {
  37657. labelFetcher: seriesModel,
  37658. labelDataIndex: idx,
  37659. defaultText: getLabelDefaultText,
  37660. inheritColor: visualColor,
  37661. defaultOpacity: symbolStyle.opacity
  37662. }) // Do not execute util needed.
  37663. function getLabelDefaultText(idx) {
  37664. return useNameLabel
  37665. ? data.getName(idx)
  37666. : getDefaultLabel(data, idx)
  37667. }
  37668. this._sizeX = symbolSize[0] / 2
  37669. this._sizeY = symbolSize[1] / 2
  37670. var emphasisState = symbolPath.ensureState('emphasis')
  37671. emphasisState.style = emphasisItemStyle
  37672. symbolPath.ensureState('select').style = selectItemStyle
  37673. symbolPath.ensureState('blur').style = blurItemStyle
  37674. if (hoverScale) {
  37675. var scaleRatio = Math.max(
  37676. isNumber(hoverScale) ? hoverScale : 1.1,
  37677. 3 / this._sizeY
  37678. )
  37679. emphasisState.scaleX = this._sizeX * scaleRatio
  37680. emphasisState.scaleY = this._sizeY * scaleRatio
  37681. }
  37682. this.setSymbolScale(1)
  37683. toggleHoverEmphasis(this, focus, blurScope, emphasisDisabled)
  37684. }
  37685. _Symbol.prototype.setSymbolScale = function (scale) {
  37686. this.scaleX = this.scaleY = scale
  37687. }
  37688. _Symbol.prototype.fadeOut = function (cb, seriesModel, opt) {
  37689. var symbolPath = this.childAt(0)
  37690. var dataIndex = getECData(this).dataIndex
  37691. var animationOpt = opt && opt.animation // Avoid mistaken hover when fading out
  37692. this.silent = symbolPath.silent = true // Not show text when animating
  37693. if (opt && opt.fadeLabel) {
  37694. var textContent = symbolPath.getTextContent()
  37695. if (textContent) {
  37696. removeElement(
  37697. textContent,
  37698. { style: { opacity: 0 } },
  37699. seriesModel,
  37700. {
  37701. dataIndex: dataIndex,
  37702. removeOpt: animationOpt,
  37703. cb: function cb() {
  37704. symbolPath.removeTextContent()
  37705. }
  37706. }
  37707. )
  37708. }
  37709. } else {
  37710. symbolPath.removeTextContent()
  37711. }
  37712. removeElement(
  37713. symbolPath,
  37714. { style: { opacity: 0 }, scaleX: 0, scaleY: 0 },
  37715. seriesModel,
  37716. { dataIndex: dataIndex, cb: cb, removeOpt: animationOpt }
  37717. )
  37718. }
  37719. _Symbol.getSymbolSize = function (data, idx) {
  37720. return normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'))
  37721. }
  37722. return _Symbol
  37723. })(Group$3)
  37724. function driftSymbol(dx, dy) {
  37725. this.parent.drift(dx, dy)
  37726. }
  37727. var SymbolClz = Symbol$1
  37728. function symbolNeedsDraw(data, point, idx, opt) {
  37729. return (
  37730. point &&
  37731. !isNaN(point[0]) &&
  37732. !isNaN(point[1]) &&
  37733. !(opt.isIgnore && opt.isIgnore(idx)) && // We do not set clipShape on group, because it will cut part of
  37734. // the symbol element shape. We use the same clip shape here as
  37735. // the line clip.
  37736. !(opt.clipShape && !opt.clipShape.contain(point[0], point[1])) &&
  37737. data.getItemVisual(idx, 'symbol') !== 'none'
  37738. )
  37739. }
  37740. function normalizeUpdateOpt(opt) {
  37741. if (opt != null && !isObject$2(opt)) {
  37742. opt = { isIgnore: opt }
  37743. }
  37744. return opt || {}
  37745. }
  37746. function makeSeriesScope(data) {
  37747. var seriesModel = data.hostModel
  37748. var emphasisModel = seriesModel.getModel('emphasis')
  37749. return {
  37750. emphasisItemStyle: emphasisModel
  37751. .getModel('itemStyle')
  37752. .getItemStyle(),
  37753. blurItemStyle: seriesModel
  37754. .getModel(['blur', 'itemStyle'])
  37755. .getItemStyle(),
  37756. selectItemStyle: seriesModel
  37757. .getModel(['select', 'itemStyle'])
  37758. .getItemStyle(),
  37759. focus: emphasisModel.get('focus'),
  37760. blurScope: emphasisModel.get('blurScope'),
  37761. emphasisDisabled: emphasisModel.get('disabled'),
  37762. hoverScale: emphasisModel.get('scale'),
  37763. labelStatesModels: getLabelStatesModels(seriesModel),
  37764. cursorStyle: seriesModel.get('cursor')
  37765. }
  37766. }
  37767. var SymbolDraw = /** @class */ (function () {
  37768. function SymbolDraw(SymbolCtor) {
  37769. this.group = new Group$3()
  37770. this._SymbolCtor = SymbolCtor || SymbolClz
  37771. }
  37772. /**
  37773. * Update symbols draw by new data
  37774. */ SymbolDraw.prototype.updateData = function (data, opt) {
  37775. // Remove progressive els.
  37776. this._progressiveEls = null
  37777. opt = normalizeUpdateOpt(opt)
  37778. var group = this.group
  37779. var seriesModel = data.hostModel
  37780. var oldData = this._data
  37781. var SymbolCtor = this._SymbolCtor
  37782. var disableAnimation = opt.disableAnimation
  37783. var seriesScope = makeSeriesScope(data)
  37784. var symbolUpdateOpt = { disableAnimation: disableAnimation }
  37785. var getSymbolPoint =
  37786. opt.getSymbolPoint ||
  37787. function (idx) {
  37788. return data.getItemLayout(idx)
  37789. } // There is no oldLineData only when first rendering or switching from
  37790. // stream mode to normal mode, where previous elements should be removed.
  37791. if (!oldData) {
  37792. group.removeAll()
  37793. }
  37794. data
  37795. .diff(oldData)
  37796. .add(function (newIdx) {
  37797. var point = getSymbolPoint(newIdx)
  37798. if (symbolNeedsDraw(data, point, newIdx, opt)) {
  37799. var symbolEl = new SymbolCtor(
  37800. data,
  37801. newIdx,
  37802. seriesScope,
  37803. symbolUpdateOpt
  37804. )
  37805. symbolEl.setPosition(point)
  37806. data.setItemGraphicEl(newIdx, symbolEl)
  37807. group.add(symbolEl)
  37808. }
  37809. })
  37810. .update(function (newIdx, oldIdx) {
  37811. var symbolEl = oldData.getItemGraphicEl(oldIdx)
  37812. var point = getSymbolPoint(newIdx)
  37813. if (!symbolNeedsDraw(data, point, newIdx, opt)) {
  37814. group.remove(symbolEl)
  37815. return
  37816. }
  37817. var newSymbolType =
  37818. data.getItemVisual(newIdx, 'symbol') || 'circle'
  37819. var oldSymbolType =
  37820. symbolEl &&
  37821. symbolEl.getSymbolType &&
  37822. symbolEl.getSymbolType()
  37823. if (
  37824. !symbolEl || // Create a new if symbol type changed.
  37825. (oldSymbolType && oldSymbolType !== newSymbolType)
  37826. ) {
  37827. group.remove(symbolEl)
  37828. symbolEl = new SymbolCtor(
  37829. data,
  37830. newIdx,
  37831. seriesScope,
  37832. symbolUpdateOpt
  37833. )
  37834. symbolEl.setPosition(point)
  37835. } else {
  37836. symbolEl.updateData(
  37837. data,
  37838. newIdx,
  37839. seriesScope,
  37840. symbolUpdateOpt
  37841. )
  37842. var target = { x: point[0], y: point[1] }
  37843. disableAnimation
  37844. ? symbolEl.attr(target)
  37845. : updateProps$1(symbolEl, target, seriesModel)
  37846. } // Add back
  37847. group.add(symbolEl)
  37848. data.setItemGraphicEl(newIdx, symbolEl)
  37849. })
  37850. .remove(function (oldIdx) {
  37851. var el = oldData.getItemGraphicEl(oldIdx)
  37852. el &&
  37853. el.fadeOut(function () {
  37854. group.remove(el)
  37855. }, seriesModel)
  37856. })
  37857. .execute()
  37858. this._getSymbolPoint = getSymbolPoint
  37859. this._data = data
  37860. }
  37861. SymbolDraw.prototype.updateLayout = function () {
  37862. var _this = this
  37863. var data = this._data
  37864. if (data) {
  37865. // Not use animation
  37866. data.eachItemGraphicEl(function (el, idx) {
  37867. var point = _this._getSymbolPoint(idx)
  37868. el.setPosition(point)
  37869. el.markRedraw()
  37870. })
  37871. }
  37872. }
  37873. SymbolDraw.prototype.incrementalPrepareUpdate = function (data) {
  37874. this._seriesScope = makeSeriesScope(data)
  37875. this._data = null
  37876. this.group.removeAll()
  37877. }
  37878. /**
  37879. * Update symbols draw by new data
  37880. */ SymbolDraw.prototype.incrementalUpdate = function (
  37881. taskParams,
  37882. data,
  37883. opt
  37884. ) {
  37885. // Clear
  37886. this._progressiveEls = []
  37887. opt = normalizeUpdateOpt(opt)
  37888. function updateIncrementalAndHover(el) {
  37889. if (!el.isGroup) {
  37890. el.incremental = true
  37891. el.ensureState('emphasis').hoverLayer = true
  37892. }
  37893. }
  37894. for (var idx = taskParams.start; idx < taskParams.end; idx++) {
  37895. var point = data.getItemLayout(idx)
  37896. if (symbolNeedsDraw(data, point, idx, opt)) {
  37897. var el = new this._SymbolCtor(data, idx, this._seriesScope)
  37898. el.traverse(updateIncrementalAndHover)
  37899. el.setPosition(point)
  37900. this.group.add(el)
  37901. data.setItemGraphicEl(idx, el)
  37902. this._progressiveEls.push(el)
  37903. }
  37904. }
  37905. }
  37906. SymbolDraw.prototype.eachRendered = function (cb) {
  37907. traverseElements(this._progressiveEls || this.group, cb)
  37908. }
  37909. SymbolDraw.prototype.remove = function (enableAnimation) {
  37910. var group = this.group
  37911. var data = this._data // Incremental model do not have this._data.
  37912. if (data && enableAnimation) {
  37913. data.eachItemGraphicEl(function (el) {
  37914. el.fadeOut(function () {
  37915. group.remove(el)
  37916. }, data.hostModel)
  37917. })
  37918. } else {
  37919. group.removeAll()
  37920. }
  37921. }
  37922. return SymbolDraw
  37923. })()
  37924. var SymbolDraw$1 = SymbolDraw
  37925. function prepareDataCoordInfo(coordSys, data, valueOrigin) {
  37926. var baseAxis = coordSys.getBaseAxis()
  37927. var valueAxis = coordSys.getOtherAxis(baseAxis)
  37928. var valueStart = getValueStart(valueAxis, valueOrigin)
  37929. var baseAxisDim = baseAxis.dim
  37930. var valueAxisDim = valueAxis.dim
  37931. var valueDim = data.mapDimension(valueAxisDim)
  37932. var baseDim = data.mapDimension(baseAxisDim)
  37933. var baseDataOffset =
  37934. valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0
  37935. var dims = map$1(coordSys.dimensions, function (coordDim) {
  37936. return data.mapDimension(coordDim)
  37937. })
  37938. var stacked = false
  37939. var stackResultDim = data.getCalculationInfo('stackResultDimension')
  37940. if (isDimensionStacked(data, dims[0] /*, dims[1]*/)) {
  37941. // jshint ignore:line
  37942. stacked = true
  37943. dims[0] = stackResultDim
  37944. }
  37945. if (isDimensionStacked(data, dims[1] /*, dims[0]*/)) {
  37946. // jshint ignore:line
  37947. stacked = true
  37948. dims[1] = stackResultDim
  37949. }
  37950. return {
  37951. dataDimsForPoint: dims,
  37952. valueStart: valueStart,
  37953. valueAxisDim: valueAxisDim,
  37954. baseAxisDim: baseAxisDim,
  37955. stacked: !!stacked,
  37956. valueDim: valueDim,
  37957. baseDim: baseDim,
  37958. baseDataOffset: baseDataOffset,
  37959. stackedOverDimension: data.getCalculationInfo(
  37960. 'stackedOverDimension'
  37961. )
  37962. }
  37963. }
  37964. function getValueStart(valueAxis, valueOrigin) {
  37965. var valueStart = 0
  37966. var extent = valueAxis.scale.getExtent()
  37967. if (valueOrigin === 'start') {
  37968. valueStart = extent[0]
  37969. } else if (valueOrigin === 'end') {
  37970. valueStart = extent[1]
  37971. } // If origin is specified as a number, use it as
  37972. // valueStart directly
  37973. else if (isNumber(valueOrigin) && !isNaN(valueOrigin)) {
  37974. valueStart = valueOrigin
  37975. } // auto
  37976. else {
  37977. // Both positive
  37978. if (extent[0] > 0) {
  37979. valueStart = extent[0]
  37980. } // Both negative
  37981. else if (extent[1] < 0) {
  37982. valueStart = extent[1]
  37983. } // If is one positive, and one negative, onZero shall be true
  37984. }
  37985. return valueStart
  37986. }
  37987. function getStackedOnPoint(dataCoordInfo, coordSys, data, idx) {
  37988. var value = NaN
  37989. if (dataCoordInfo.stacked) {
  37990. value = data.get(
  37991. data.getCalculationInfo('stackedOverDimension'),
  37992. idx
  37993. )
  37994. }
  37995. if (isNaN(value)) {
  37996. value = dataCoordInfo.valueStart
  37997. }
  37998. var baseDataOffset = dataCoordInfo.baseDataOffset
  37999. var stackedData = []
  38000. stackedData[baseDataOffset] = data.get(dataCoordInfo.baseDim, idx)
  38001. stackedData[1 - baseDataOffset] = value
  38002. return coordSys.dataToPoint(stackedData)
  38003. }
  38004. function diffData(oldData, newData) {
  38005. var diffResult = []
  38006. newData
  38007. .diff(oldData)
  38008. .add(function (idx) {
  38009. diffResult.push({ cmd: '+', idx: idx })
  38010. })
  38011. .update(function (newIdx, oldIdx) {
  38012. diffResult.push({ cmd: '=', idx: oldIdx, idx1: newIdx })
  38013. })
  38014. .remove(function (idx) {
  38015. diffResult.push({ cmd: '-', idx: idx })
  38016. })
  38017. .execute()
  38018. return diffResult
  38019. }
  38020. function lineAnimationDiff(
  38021. oldData,
  38022. newData,
  38023. oldStackedOnPoints,
  38024. newStackedOnPoints,
  38025. oldCoordSys,
  38026. newCoordSys,
  38027. oldValueOrigin,
  38028. newValueOrigin
  38029. ) {
  38030. var diff = diffData(oldData, newData) // let newIdList = newData.mapArray(newData.getId);
  38031. // let oldIdList = oldData.mapArray(oldData.getId);
  38032. // convertToIntId(newIdList, oldIdList);
  38033. // // FIXME One data ?
  38034. // diff = arrayDiff(oldIdList, newIdList);
  38035. var currPoints = []
  38036. var nextPoints = [] // Points for stacking base line
  38037. var currStackedPoints = []
  38038. var nextStackedPoints = []
  38039. var status = []
  38040. var sortedIndices = []
  38041. var rawIndices = []
  38042. var newDataOldCoordInfo = prepareDataCoordInfo(
  38043. oldCoordSys,
  38044. newData,
  38045. oldValueOrigin
  38046. ) // const oldDataNewCoordInfo = prepareDataCoordInfo(newCoordSys, oldData, newValueOrigin);
  38047. var oldPoints = oldData.getLayout('points') || []
  38048. var newPoints = newData.getLayout('points') || []
  38049. for (var i = 0; i < diff.length; i++) {
  38050. var diffItem = diff[i]
  38051. var pointAdded = true
  38052. var oldIdx2 = void 0
  38053. var newIdx2 = void 0 // FIXME, animation is not so perfect when dataZoom window moves fast
  38054. // Which is in case remvoing or add more than one data in the tail or head
  38055. switch (diffItem.cmd) {
  38056. case '=':
  38057. oldIdx2 = diffItem.idx * 2
  38058. newIdx2 = diffItem.idx1 * 2
  38059. var currentX = oldPoints[oldIdx2]
  38060. var currentY = oldPoints[oldIdx2 + 1]
  38061. var nextX = newPoints[newIdx2]
  38062. var nextY = newPoints[newIdx2 + 1] // If previous data is NaN, use next point directly
  38063. if (isNaN(currentX) || isNaN(currentY)) {
  38064. currentX = nextX
  38065. currentY = nextY
  38066. }
  38067. currPoints.push(currentX, currentY)
  38068. nextPoints.push(nextX, nextY)
  38069. currStackedPoints.push(
  38070. oldStackedOnPoints[oldIdx2],
  38071. oldStackedOnPoints[oldIdx2 + 1]
  38072. )
  38073. nextStackedPoints.push(
  38074. newStackedOnPoints[newIdx2],
  38075. newStackedOnPoints[newIdx2 + 1]
  38076. )
  38077. rawIndices.push(newData.getRawIndex(diffItem.idx1))
  38078. break
  38079. case '+':
  38080. var newIdx = diffItem.idx
  38081. var newDataDimsForPoint = newDataOldCoordInfo.dataDimsForPoint
  38082. var oldPt = oldCoordSys.dataToPoint([
  38083. newData.get(newDataDimsForPoint[0], newIdx),
  38084. newData.get(newDataDimsForPoint[1], newIdx)
  38085. ])
  38086. newIdx2 = newIdx * 2
  38087. currPoints.push(oldPt[0], oldPt[1])
  38088. nextPoints.push(newPoints[newIdx2], newPoints[newIdx2 + 1])
  38089. var stackedOnPoint = getStackedOnPoint(
  38090. newDataOldCoordInfo,
  38091. oldCoordSys,
  38092. newData,
  38093. newIdx
  38094. )
  38095. currStackedPoints.push(stackedOnPoint[0], stackedOnPoint[1])
  38096. nextStackedPoints.push(
  38097. newStackedOnPoints[newIdx2],
  38098. newStackedOnPoints[newIdx2 + 1]
  38099. )
  38100. rawIndices.push(newData.getRawIndex(newIdx))
  38101. break
  38102. case '-':
  38103. pointAdded = false
  38104. } // Original indices
  38105. if (pointAdded) {
  38106. status.push(diffItem)
  38107. sortedIndices.push(sortedIndices.length)
  38108. }
  38109. } // Diff result may be crossed if all items are changed
  38110. // Sort by data index
  38111. sortedIndices.sort(function (a, b) {
  38112. return rawIndices[a] - rawIndices[b]
  38113. })
  38114. var len = currPoints.length
  38115. var sortedCurrPoints = createFloat32Array(len)
  38116. var sortedNextPoints = createFloat32Array(len)
  38117. var sortedCurrStackedPoints = createFloat32Array(len)
  38118. var sortedNextStackedPoints = createFloat32Array(len)
  38119. var sortedStatus = []
  38120. for (var i = 0; i < sortedIndices.length; i++) {
  38121. var idx = sortedIndices[i]
  38122. var i2 = i * 2
  38123. var idx2 = idx * 2
  38124. sortedCurrPoints[i2] = currPoints[idx2]
  38125. sortedCurrPoints[i2 + 1] = currPoints[idx2 + 1]
  38126. sortedNextPoints[i2] = nextPoints[idx2]
  38127. sortedNextPoints[i2 + 1] = nextPoints[idx2 + 1]
  38128. sortedCurrStackedPoints[i2] = currStackedPoints[idx2]
  38129. sortedCurrStackedPoints[i2 + 1] = currStackedPoints[idx2 + 1]
  38130. sortedNextStackedPoints[i2] = nextStackedPoints[idx2]
  38131. sortedNextStackedPoints[i2 + 1] = nextStackedPoints[idx2 + 1]
  38132. sortedStatus[i] = status[idx]
  38133. }
  38134. return {
  38135. current: sortedCurrPoints,
  38136. next: sortedNextPoints,
  38137. stackedOnCurrent: sortedCurrStackedPoints,
  38138. stackedOnNext: sortedNextStackedPoints,
  38139. status: sortedStatus
  38140. }
  38141. }
  38142. var mathMin$2 = Math.min
  38143. var mathMax$2 = Math.max
  38144. function isPointNull$1(x, y) {
  38145. return isNaN(x) || isNaN(y)
  38146. }
  38147. /**
  38148. * Draw smoothed line in non-monotone, in may cause undesired curve in extreme
  38149. * situations. This should be used when points are non-monotone neither in x or
  38150. * y dimension.
  38151. */ function drawSegment(
  38152. ctx,
  38153. points,
  38154. start,
  38155. segLen,
  38156. allLen,
  38157. dir,
  38158. smooth,
  38159. smoothMonotone,
  38160. connectNulls
  38161. ) {
  38162. var prevX
  38163. var prevY
  38164. var cpx0
  38165. var cpy0
  38166. var cpx1
  38167. var cpy1
  38168. var idx = start
  38169. var k = 0
  38170. for (; k < segLen; k++) {
  38171. var x = points[idx * 2]
  38172. var y = points[idx * 2 + 1]
  38173. if (idx >= allLen || idx < 0) {
  38174. break
  38175. }
  38176. if (isPointNull$1(x, y)) {
  38177. if (connectNulls) {
  38178. idx += dir
  38179. continue
  38180. }
  38181. break
  38182. }
  38183. if (idx === start) {
  38184. ctx[dir > 0 ? 'moveTo' : 'lineTo'](x, y)
  38185. cpx0 = x
  38186. cpy0 = y
  38187. } else {
  38188. var dx = x - prevX
  38189. var dy = y - prevY // Ignore tiny segment.
  38190. if (dx * dx + dy * dy < 0.5) {
  38191. idx += dir
  38192. continue
  38193. }
  38194. if (smooth > 0) {
  38195. var nextIdx = idx + dir
  38196. var nextX = points[nextIdx * 2]
  38197. var nextY = points[nextIdx * 2 + 1] // Ignore duplicate point
  38198. while (nextX === x && nextY === y && k < segLen) {
  38199. k++
  38200. nextIdx += dir
  38201. idx += dir
  38202. nextX = points[nextIdx * 2]
  38203. nextY = points[nextIdx * 2 + 1]
  38204. x = points[idx * 2]
  38205. y = points[idx * 2 + 1]
  38206. dx = x - prevX
  38207. dy = y - prevY
  38208. }
  38209. var tmpK = k + 1
  38210. if (connectNulls) {
  38211. // Find next point not null
  38212. while (isPointNull$1(nextX, nextY) && tmpK < segLen) {
  38213. tmpK++
  38214. nextIdx += dir
  38215. nextX = points[nextIdx * 2]
  38216. nextY = points[nextIdx * 2 + 1]
  38217. }
  38218. }
  38219. var ratioNextSeg = 0.5
  38220. var vx = 0
  38221. var vy = 0
  38222. var nextCpx0 = void 0
  38223. var nextCpy0 = void 0 // Is last point
  38224. if (tmpK >= segLen || isPointNull$1(nextX, nextY)) {
  38225. cpx1 = x
  38226. cpy1 = y
  38227. } else {
  38228. vx = nextX - prevX
  38229. vy = nextY - prevY
  38230. var dx0 = x - prevX
  38231. var dx1 = nextX - x
  38232. var dy0 = y - prevY
  38233. var dy1 = nextY - y
  38234. var lenPrevSeg = void 0
  38235. var lenNextSeg = void 0
  38236. if (smoothMonotone === 'x') {
  38237. lenPrevSeg = Math.abs(dx0)
  38238. lenNextSeg = Math.abs(dx1)
  38239. var dir_1 = vx > 0 ? 1 : -1
  38240. cpx1 = x - dir_1 * lenPrevSeg * smooth
  38241. cpy1 = y
  38242. nextCpx0 = x + dir_1 * lenNextSeg * smooth
  38243. nextCpy0 = y
  38244. } else if (smoothMonotone === 'y') {
  38245. lenPrevSeg = Math.abs(dy0)
  38246. lenNextSeg = Math.abs(dy1)
  38247. var dir_2 = vy > 0 ? 1 : -1
  38248. cpx1 = x
  38249. cpy1 = y - dir_2 * lenPrevSeg * smooth
  38250. nextCpx0 = x
  38251. nextCpy0 = y + dir_2 * lenNextSeg * smooth
  38252. } else {
  38253. lenPrevSeg = Math.sqrt(dx0 * dx0 + dy0 * dy0)
  38254. lenNextSeg = Math.sqrt(dx1 * dx1 + dy1 * dy1) // Use ratio of seg length
  38255. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg)
  38256. cpx1 = x - vx * smooth * (1 - ratioNextSeg)
  38257. cpy1 = y - vy * smooth * (1 - ratioNextSeg) // cp0 of next segment
  38258. nextCpx0 = x + vx * smooth * ratioNextSeg
  38259. nextCpy0 = y + vy * smooth * ratioNextSeg // Smooth constraint between point and next point.
  38260. // Avoid exceeding extreme after smoothing.
  38261. nextCpx0 = mathMin$2(nextCpx0, mathMax$2(nextX, x))
  38262. nextCpy0 = mathMin$2(nextCpy0, mathMax$2(nextY, y))
  38263. nextCpx0 = mathMax$2(nextCpx0, mathMin$2(nextX, x))
  38264. nextCpy0 = mathMax$2(nextCpy0, mathMin$2(nextY, y)) // Reclaculate cp1 based on the adjusted cp0 of next seg.
  38265. vx = nextCpx0 - x
  38266. vy = nextCpy0 - y
  38267. cpx1 = x - (vx * lenPrevSeg) / lenNextSeg
  38268. cpy1 = y - (vy * lenPrevSeg) / lenNextSeg // Smooth constraint between point and prev point.
  38269. // Avoid exceeding extreme after smoothing.
  38270. cpx1 = mathMin$2(cpx1, mathMax$2(prevX, x))
  38271. cpy1 = mathMin$2(cpy1, mathMax$2(prevY, y))
  38272. cpx1 = mathMax$2(cpx1, mathMin$2(prevX, x))
  38273. cpy1 = mathMax$2(cpy1, mathMin$2(prevY, y)) // Adjust next cp0 again.
  38274. vx = x - cpx1
  38275. vy = y - cpy1
  38276. nextCpx0 = x + (vx * lenNextSeg) / lenPrevSeg
  38277. nextCpy0 = y + (vy * lenNextSeg) / lenPrevSeg
  38278. }
  38279. }
  38280. ctx.bezierCurveTo(cpx0, cpy0, cpx1, cpy1, x, y)
  38281. cpx0 = nextCpx0
  38282. cpy0 = nextCpy0
  38283. } else {
  38284. ctx.lineTo(x, y)
  38285. }
  38286. }
  38287. prevX = x
  38288. prevY = y
  38289. idx += dir
  38290. }
  38291. return k
  38292. }
  38293. var ECPolylineShape = /** @class */ (function () {
  38294. function ECPolylineShape() {
  38295. this.smooth = 0
  38296. this.smoothConstraint = true
  38297. }
  38298. return ECPolylineShape
  38299. })()
  38300. var ECPolyline = /** @class */ (function (_super) {
  38301. __extends(ECPolyline, _super)
  38302. function ECPolyline(opts) {
  38303. var _this = _super.call(this, opts) || this
  38304. _this.type = 'ec-polyline'
  38305. return _this
  38306. }
  38307. ECPolyline.prototype.getDefaultStyle = function () {
  38308. return { stroke: '#000', fill: null }
  38309. }
  38310. ECPolyline.prototype.getDefaultShape = function () {
  38311. return new ECPolylineShape()
  38312. }
  38313. ECPolyline.prototype.buildPath = function (ctx, shape) {
  38314. var points = shape.points
  38315. var i = 0
  38316. var len = points.length / 2 // const result = getBoundingBox(points, shape.smoothConstraint);
  38317. if (shape.connectNulls) {
  38318. // Must remove first and last null values avoid draw error in polygon
  38319. for (; len > 0; len--) {
  38320. if (
  38321. !isPointNull$1(points[len * 2 - 2], points[len * 2 - 1])
  38322. ) {
  38323. break
  38324. }
  38325. }
  38326. for (; i < len; i++) {
  38327. if (!isPointNull$1(points[i * 2], points[i * 2 + 1])) {
  38328. break
  38329. }
  38330. }
  38331. }
  38332. while (i < len) {
  38333. i +=
  38334. drawSegment(
  38335. ctx,
  38336. points,
  38337. i,
  38338. len,
  38339. len,
  38340. 1,
  38341. shape.smooth,
  38342. shape.smoothMonotone,
  38343. shape.connectNulls
  38344. ) + 1
  38345. }
  38346. }
  38347. ECPolyline.prototype.getPointOn = function (xOrY, dim) {
  38348. if (!this.path) {
  38349. this.createPathProxy()
  38350. this.buildPath(this.path, this.shape)
  38351. }
  38352. var path = this.path
  38353. var data = path.data
  38354. var CMD = PathProxy$1.CMD
  38355. var x0
  38356. var y0
  38357. var isDimX = dim === 'x'
  38358. var roots = []
  38359. for (var i = 0; i < data.length; ) {
  38360. var cmd = data[i++]
  38361. var x = void 0
  38362. var y = void 0
  38363. var x2 = void 0
  38364. var y2 = void 0
  38365. var x3 = void 0
  38366. var y3 = void 0
  38367. var t = void 0
  38368. switch (cmd) {
  38369. case CMD.M:
  38370. x0 = data[i++]
  38371. y0 = data[i++]
  38372. break
  38373. case CMD.L:
  38374. x = data[i++]
  38375. y = data[i++]
  38376. t = isDimX ? (xOrY - x0) / (x - x0) : (xOrY - y0) / (y - y0)
  38377. if (t <= 1 && t >= 0) {
  38378. var val = isDimX ? (y - y0) * t + y0 : (x - x0) * t + x0
  38379. return isDimX ? [xOrY, val] : [val, xOrY]
  38380. }
  38381. x0 = x
  38382. y0 = y
  38383. break
  38384. case CMD.C:
  38385. x = data[i++]
  38386. y = data[i++]
  38387. x2 = data[i++]
  38388. y2 = data[i++]
  38389. x3 = data[i++]
  38390. y3 = data[i++]
  38391. var nRoot = isDimX
  38392. ? cubicRootAt(x0, x, x2, x3, xOrY, roots)
  38393. : cubicRootAt(y0, y, y2, y3, xOrY, roots)
  38394. if (nRoot > 0) {
  38395. for (var i_1 = 0; i_1 < nRoot; i_1++) {
  38396. var t_1 = roots[i_1]
  38397. if (t_1 <= 1 && t_1 >= 0) {
  38398. var val = isDimX
  38399. ? cubicAt(y0, y, y2, y3, t_1)
  38400. : cubicAt(x0, x, x2, x3, t_1)
  38401. return isDimX ? [xOrY, val] : [val, xOrY]
  38402. }
  38403. }
  38404. }
  38405. x0 = x3
  38406. y0 = y3
  38407. break
  38408. }
  38409. }
  38410. }
  38411. return ECPolyline
  38412. })(Path$1)
  38413. var ECPolygonShape = /** @class */ (function (_super) {
  38414. __extends(ECPolygonShape, _super)
  38415. function ECPolygonShape() {
  38416. return (_super !== null && _super.apply(this, arguments)) || this
  38417. }
  38418. return ECPolygonShape
  38419. })(ECPolylineShape)
  38420. var ECPolygon = /** @class */ (function (_super) {
  38421. __extends(ECPolygon, _super)
  38422. function ECPolygon(opts) {
  38423. var _this = _super.call(this, opts) || this
  38424. _this.type = 'ec-polygon'
  38425. return _this
  38426. }
  38427. ECPolygon.prototype.getDefaultShape = function () {
  38428. return new ECPolygonShape()
  38429. }
  38430. ECPolygon.prototype.buildPath = function (ctx, shape) {
  38431. var points = shape.points
  38432. var stackedOnPoints = shape.stackedOnPoints
  38433. var i = 0
  38434. var len = points.length / 2
  38435. var smoothMonotone = shape.smoothMonotone
  38436. if (shape.connectNulls) {
  38437. // Must remove first and last null values avoid draw error in polygon
  38438. for (; len > 0; len--) {
  38439. if (
  38440. !isPointNull$1(points[len * 2 - 2], points[len * 2 - 1])
  38441. ) {
  38442. break
  38443. }
  38444. }
  38445. for (; i < len; i++) {
  38446. if (!isPointNull$1(points[i * 2], points[i * 2 + 1])) {
  38447. break
  38448. }
  38449. }
  38450. }
  38451. while (i < len) {
  38452. var k = drawSegment(
  38453. ctx,
  38454. points,
  38455. i,
  38456. len,
  38457. len,
  38458. 1,
  38459. shape.smooth,
  38460. smoothMonotone,
  38461. shape.connectNulls
  38462. )
  38463. drawSegment(
  38464. ctx,
  38465. stackedOnPoints,
  38466. i + k - 1,
  38467. k,
  38468. len,
  38469. -1,
  38470. shape.stackedOnSmooth,
  38471. smoothMonotone,
  38472. shape.connectNulls
  38473. )
  38474. i += k + 1
  38475. ctx.closePath()
  38476. }
  38477. }
  38478. return ECPolygon
  38479. })(Path$1)
  38480. function createGridClipPath(
  38481. cartesian,
  38482. hasAnimation,
  38483. seriesModel,
  38484. done,
  38485. during
  38486. ) {
  38487. var rect = cartesian.getArea()
  38488. var x = rect.x
  38489. var y = rect.y
  38490. var width = rect.width
  38491. var height = rect.height
  38492. var lineWidth = seriesModel.get(['lineStyle', 'width']) || 2 // Expand the clip path a bit to avoid the border is clipped and looks thinner
  38493. x -= lineWidth / 2
  38494. y -= lineWidth / 2
  38495. width += lineWidth
  38496. height += lineWidth // fix: https://github.com/apache/incubator-echarts/issues/11369
  38497. x = Math.floor(x)
  38498. width = Math.round(width)
  38499. var clipPath = new Rect$2({
  38500. shape: { x: x, y: y, width: width, height: height }
  38501. })
  38502. if (hasAnimation) {
  38503. var baseAxis = cartesian.getBaseAxis()
  38504. var isHorizontal = baseAxis.isHorizontal()
  38505. var isAxisInversed = baseAxis.inverse
  38506. if (isHorizontal) {
  38507. if (isAxisInversed) {
  38508. clipPath.shape.x += width
  38509. }
  38510. clipPath.shape.width = 0
  38511. } else {
  38512. if (!isAxisInversed) {
  38513. clipPath.shape.y += height
  38514. }
  38515. clipPath.shape.height = 0
  38516. }
  38517. var duringCb = isFunction(during)
  38518. ? function (percent) {
  38519. during(percent, clipPath)
  38520. }
  38521. : null
  38522. initProps(
  38523. clipPath,
  38524. { shape: { width: width, height: height, x: x, y: y } },
  38525. seriesModel,
  38526. null,
  38527. done,
  38528. duringCb
  38529. )
  38530. }
  38531. return clipPath
  38532. }
  38533. function createPolarClipPath(polar, hasAnimation, seriesModel) {
  38534. var sectorArea = polar.getArea() // Avoid float number rounding error for symbol on the edge of axis extent.
  38535. var r0 = round$1(sectorArea.r0, 1)
  38536. var r = round$1(sectorArea.r, 1)
  38537. var clipPath = new Sector$1({
  38538. shape: {
  38539. cx: round$1(polar.cx, 1),
  38540. cy: round$1(polar.cy, 1),
  38541. r0: r0,
  38542. r: r,
  38543. startAngle: sectorArea.startAngle,
  38544. endAngle: sectorArea.endAngle,
  38545. clockwise: sectorArea.clockwise
  38546. }
  38547. })
  38548. if (hasAnimation) {
  38549. var isRadial = polar.getBaseAxis().dim === 'angle'
  38550. if (isRadial) {
  38551. clipPath.shape.endAngle = sectorArea.startAngle
  38552. } else {
  38553. clipPath.shape.r = r0
  38554. }
  38555. initProps(
  38556. clipPath,
  38557. { shape: { endAngle: sectorArea.endAngle, r: r } },
  38558. seriesModel
  38559. )
  38560. }
  38561. return clipPath
  38562. }
  38563. function createClipPath(
  38564. coordSys,
  38565. hasAnimation,
  38566. seriesModel,
  38567. done,
  38568. during
  38569. ) {
  38570. if (!coordSys) {
  38571. return null
  38572. } else if (coordSys.type === 'polar') {
  38573. return createPolarClipPath(coordSys, hasAnimation, seriesModel)
  38574. } else if (coordSys.type === 'cartesian2d') {
  38575. return createGridClipPath(
  38576. coordSys,
  38577. hasAnimation,
  38578. seriesModel,
  38579. done,
  38580. during
  38581. )
  38582. }
  38583. return null
  38584. }
  38585. /*
  38586. * Licensed to the Apache Software Foundation (ASF) under one
  38587. * or more contributor license agreements. See the NOTICE file
  38588. * distributed with this work for additional information
  38589. * regarding copyright ownership. The ASF licenses this file
  38590. * to you under the Apache License, Version 2.0 (the
  38591. * "License"); you may not use this file except in compliance
  38592. * with the License. You may obtain a copy of the License at
  38593. *
  38594. * http://www.apache.org/licenses/LICENSE-2.0
  38595. *
  38596. * Unless required by applicable law or agreed to in writing,
  38597. * software distributed under the License is distributed on an
  38598. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38599. * KIND, either express or implied. See the License for the
  38600. * specific language governing permissions and limitations
  38601. * under the License.
  38602. */ /**
  38603. * AUTO-GENERATED FILE. DO NOT MODIFY.
  38604. */ /*
  38605. * Licensed to the Apache Software Foundation (ASF) under one
  38606. * or more contributor license agreements. See the NOTICE file
  38607. * distributed with this work for additional information
  38608. * regarding copyright ownership. The ASF licenses this file
  38609. * to you under the Apache License, Version 2.0 (the
  38610. * "License"); you may not use this file except in compliance
  38611. * with the License. You may obtain a copy of the License at
  38612. *
  38613. * http://www.apache.org/licenses/LICENSE-2.0
  38614. *
  38615. * Unless required by applicable law or agreed to in writing,
  38616. * software distributed under the License is distributed on an
  38617. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  38618. * KIND, either express or implied. See the License for the
  38619. * specific language governing permissions and limitations
  38620. * under the License.
  38621. */ function isCoordinateSystemType(coordSys, type) {
  38622. return coordSys.type === type
  38623. }
  38624. function isPointsSame(points1, points2) {
  38625. if (points1.length !== points2.length) {
  38626. return
  38627. }
  38628. for (var i = 0; i < points1.length; i++) {
  38629. if (points1[i] !== points2[i]) {
  38630. return
  38631. }
  38632. }
  38633. return true
  38634. }
  38635. function bboxFromPoints(points) {
  38636. var minX = Infinity
  38637. var minY = Infinity
  38638. var maxX = -Infinity
  38639. var maxY = -Infinity
  38640. for (var i = 0; i < points.length; ) {
  38641. var x = points[i++]
  38642. var y = points[i++]
  38643. if (!isNaN(x)) {
  38644. minX = Math.min(x, minX)
  38645. maxX = Math.max(x, maxX)
  38646. }
  38647. if (!isNaN(y)) {
  38648. minY = Math.min(y, minY)
  38649. maxY = Math.max(y, maxY)
  38650. }
  38651. }
  38652. return [
  38653. [minX, minY],
  38654. [maxX, maxY]
  38655. ]
  38656. }
  38657. function getBoundingDiff(points1, points2) {
  38658. var _a = bboxFromPoints(points1),
  38659. min1 = _a[0],
  38660. max1 = _a[1]
  38661. var _b = bboxFromPoints(points2),
  38662. min2 = _b[0],
  38663. max2 = _b[1] // Get a max value from each corner of two boundings.
  38664. return Math.max(
  38665. Math.abs(min1[0] - min2[0]),
  38666. Math.abs(min1[1] - min2[1]),
  38667. Math.abs(max1[0] - max2[0]),
  38668. Math.abs(max1[1] - max2[1])
  38669. )
  38670. }
  38671. function getSmooth(smooth) {
  38672. return isNumber(smooth) ? smooth : smooth ? 0.5 : 0
  38673. }
  38674. function getStackedOnPoints(coordSys, data, dataCoordInfo) {
  38675. if (!dataCoordInfo.valueDim) {
  38676. return []
  38677. }
  38678. var len = data.count()
  38679. var points = createFloat32Array(len * 2)
  38680. for (var idx = 0; idx < len; idx++) {
  38681. var pt = getStackedOnPoint(dataCoordInfo, coordSys, data, idx)
  38682. points[idx * 2] = pt[0]
  38683. points[idx * 2 + 1] = pt[1]
  38684. }
  38685. return points
  38686. }
  38687. function turnPointsIntoStep(
  38688. points,
  38689. coordSys,
  38690. stepTurnAt,
  38691. connectNulls
  38692. ) {
  38693. var baseAxis = coordSys.getBaseAxis()
  38694. var baseIndex =
  38695. baseAxis.dim === 'x' || baseAxis.dim === 'radius' ? 0 : 1
  38696. var stepPoints = []
  38697. var i = 0
  38698. var stepPt = []
  38699. var pt = []
  38700. var nextPt = []
  38701. var filteredPoints = []
  38702. if (connectNulls) {
  38703. for (i = 0; i < points.length; i += 2) {
  38704. if (!isNaN(points[i]) && !isNaN(points[i + 1])) {
  38705. filteredPoints.push(points[i], points[i + 1])
  38706. }
  38707. }
  38708. points = filteredPoints
  38709. }
  38710. for (i = 0; i < points.length - 2; i += 2) {
  38711. nextPt[0] = points[i + 2]
  38712. nextPt[1] = points[i + 3]
  38713. pt[0] = points[i]
  38714. pt[1] = points[i + 1]
  38715. stepPoints.push(pt[0], pt[1])
  38716. switch (stepTurnAt) {
  38717. case 'end':
  38718. stepPt[baseIndex] = nextPt[baseIndex]
  38719. stepPt[1 - baseIndex] = pt[1 - baseIndex]
  38720. stepPoints.push(stepPt[0], stepPt[1])
  38721. break
  38722. case 'middle':
  38723. var middle = (pt[baseIndex] + nextPt[baseIndex]) / 2
  38724. var stepPt2 = []
  38725. stepPt[baseIndex] = stepPt2[baseIndex] = middle
  38726. stepPt[1 - baseIndex] = pt[1 - baseIndex]
  38727. stepPt2[1 - baseIndex] = nextPt[1 - baseIndex]
  38728. stepPoints.push(stepPt[0], stepPt[1])
  38729. stepPoints.push(stepPt2[0], stepPt2[1])
  38730. break
  38731. default:
  38732. // default is start
  38733. stepPt[baseIndex] = pt[baseIndex]
  38734. stepPt[1 - baseIndex] = nextPt[1 - baseIndex]
  38735. stepPoints.push(stepPt[0], stepPt[1])
  38736. }
  38737. } // Last points
  38738. stepPoints.push(points[i++], points[i++])
  38739. return stepPoints
  38740. }
  38741. /**
  38742. * Clip color stops to edge. Avoid creating too large gradients.
  38743. * Which may lead to blurry when GPU acceleration is enabled. See #15680
  38744. *
  38745. * The stops has been sorted from small to large.
  38746. */ function clipColorStops(colorStops, maxSize) {
  38747. var newColorStops = []
  38748. var len = colorStops.length // coord will always < 0 in prevOutOfRangeColorStop.
  38749. var prevOutOfRangeColorStop
  38750. var prevInRangeColorStop
  38751. function lerpStop(stop0, stop1, clippedCoord) {
  38752. var coord0 = stop0.coord
  38753. var p = (clippedCoord - coord0) / (stop1.coord - coord0)
  38754. var color = lerp(p, [stop0.color, stop1.color])
  38755. return { coord: clippedCoord, color: color }
  38756. }
  38757. for (var i = 0; i < len; i++) {
  38758. var stop_1 = colorStops[i]
  38759. var coord = stop_1.coord
  38760. if (coord < 0) {
  38761. prevOutOfRangeColorStop = stop_1
  38762. } else if (coord > maxSize) {
  38763. if (prevInRangeColorStop) {
  38764. newColorStops.push(
  38765. lerpStop(prevInRangeColorStop, stop_1, maxSize)
  38766. )
  38767. } else if (prevOutOfRangeColorStop) {
  38768. // If there are two stops and coord range is between these two stops
  38769. newColorStops.push(
  38770. lerpStop(prevOutOfRangeColorStop, stop_1, 0),
  38771. lerpStop(prevOutOfRangeColorStop, stop_1, maxSize)
  38772. )
  38773. } // All following stop will be out of range. So just ignore them.
  38774. break
  38775. } else {
  38776. if (prevOutOfRangeColorStop) {
  38777. newColorStops.push(
  38778. lerpStop(prevOutOfRangeColorStop, stop_1, 0)
  38779. ) // Reset
  38780. prevOutOfRangeColorStop = null
  38781. }
  38782. newColorStops.push(stop_1)
  38783. prevInRangeColorStop = stop_1
  38784. }
  38785. }
  38786. return newColorStops
  38787. }
  38788. function getVisualGradient(data, coordSys, api) {
  38789. var visualMetaList = data.getVisual('visualMeta')
  38790. if (!visualMetaList || !visualMetaList.length || !data.count()) {
  38791. // When data.count() is 0, gradient range can not be calculated.
  38792. return
  38793. }
  38794. if (coordSys.type !== 'cartesian2d') {
  38795. return
  38796. }
  38797. var coordDim
  38798. var visualMeta
  38799. for (var i = visualMetaList.length - 1; i >= 0; i--) {
  38800. var dimInfo = data.getDimensionInfo(visualMetaList[i].dimension)
  38801. coordDim = dimInfo && dimInfo.coordDim // Can only be x or y
  38802. if (coordDim === 'x' || coordDim === 'y') {
  38803. visualMeta = visualMetaList[i]
  38804. break
  38805. }
  38806. }
  38807. if (!visualMeta) {
  38808. return
  38809. } // If the area to be rendered is bigger than area defined by LinearGradient,
  38810. // the canvas spec prescribes that the color of the first stop and the last
  38811. // stop should be used. But if two stops are added at offset 0, in effect
  38812. // browsers use the color of the second stop to render area outside
  38813. // LinearGradient. So we can only infinitesimally extend area defined in
  38814. // LinearGradient to render `outerColors`.
  38815. var axis = coordSys.getAxis(coordDim) // dataToCoord mapping may not be linear, but must be monotonic.
  38816. var colorStops = map$1(visualMeta.stops, function (stop) {
  38817. // offset will be calculated later.
  38818. return {
  38819. coord: axis.toGlobalCoord(axis.dataToCoord(stop.value)),
  38820. color: stop.color
  38821. }
  38822. })
  38823. var stopLen = colorStops.length
  38824. var outerColors = visualMeta.outerColors.slice()
  38825. if (
  38826. stopLen &&
  38827. colorStops[0].coord > colorStops[stopLen - 1].coord
  38828. ) {
  38829. colorStops.reverse()
  38830. outerColors.reverse()
  38831. }
  38832. var colorStopsInRange = clipColorStops(
  38833. colorStops,
  38834. coordDim === 'x' ? api.getWidth() : api.getHeight()
  38835. )
  38836. var inRangeStopLen = colorStopsInRange.length
  38837. if (!inRangeStopLen && stopLen) {
  38838. // All stops are out of range. All will be the same color.
  38839. return colorStops[0].coord < 0
  38840. ? outerColors[1]
  38841. ? outerColors[1]
  38842. : colorStops[stopLen - 1].color
  38843. : outerColors[0]
  38844. ? outerColors[0]
  38845. : colorStops[0].color
  38846. }
  38847. var tinyExtent = 10 // Arbitrary value: 10px
  38848. var minCoord = colorStopsInRange[0].coord - tinyExtent
  38849. var maxCoord =
  38850. colorStopsInRange[inRangeStopLen - 1].coord + tinyExtent
  38851. var coordSpan = maxCoord - minCoord
  38852. if (coordSpan < 1e-3) {
  38853. return 'transparent'
  38854. }
  38855. each$7(colorStopsInRange, function (stop) {
  38856. stop.offset = (stop.coord - minCoord) / coordSpan
  38857. })
  38858. colorStopsInRange.push({
  38859. // NOTE: inRangeStopLen may still be 0 if stoplen is zero.
  38860. offset: inRangeStopLen
  38861. ? colorStopsInRange[inRangeStopLen - 1].offset
  38862. : 0.5,
  38863. color: outerColors[1] || 'transparent'
  38864. })
  38865. colorStopsInRange.unshift({
  38866. offset: inRangeStopLen ? colorStopsInRange[0].offset : 0.5,
  38867. color: outerColors[0] || 'transparent'
  38868. })
  38869. var gradient = new LinearGradient$1(
  38870. 0,
  38871. 0,
  38872. 0,
  38873. 0,
  38874. colorStopsInRange,
  38875. true
  38876. )
  38877. gradient[coordDim] = minCoord
  38878. gradient[coordDim + '2'] = maxCoord
  38879. return gradient
  38880. }
  38881. function getIsIgnoreFunc(seriesModel, data, coordSys) {
  38882. var showAllSymbol = seriesModel.get('showAllSymbol')
  38883. var isAuto = showAllSymbol === 'auto'
  38884. if (showAllSymbol && !isAuto) {
  38885. return
  38886. }
  38887. var categoryAxis = coordSys.getAxesByScale('ordinal')[0]
  38888. if (!categoryAxis) {
  38889. return
  38890. } // Note that category label interval strategy might bring some weird effect
  38891. // in some scenario: users may wonder why some of the symbols are not
  38892. // displayed. So we show all symbols as possible as we can.
  38893. if (
  38894. isAuto && // Simplify the logic, do not determine label overlap here.
  38895. canShowAllSymbolForCategory(categoryAxis, data)
  38896. ) {
  38897. return
  38898. } // Otherwise follow the label interval strategy on category axis.
  38899. var categoryDataDim = data.mapDimension(categoryAxis.dim)
  38900. var labelMap = {}
  38901. each$7(categoryAxis.getViewLabels(), function (labelItem) {
  38902. var ordinalNumber = categoryAxis.scale.getRawOrdinalNumber(
  38903. labelItem.tickValue
  38904. )
  38905. labelMap[ordinalNumber] = 1
  38906. })
  38907. return function (dataIndex) {
  38908. return !labelMap.hasOwnProperty(
  38909. data.get(categoryDataDim, dataIndex)
  38910. )
  38911. }
  38912. }
  38913. function canShowAllSymbolForCategory(categoryAxis, data) {
  38914. // In mose cases, line is monotonous on category axis, and the label size
  38915. // is close with each other. So we check the symbol size and some of the
  38916. // label size alone with the category axis to estimate whether all symbol
  38917. // can be shown without overlap.
  38918. var axisExtent = categoryAxis.getExtent()
  38919. var availSize =
  38920. Math.abs(axisExtent[1] - axisExtent[0]) /
  38921. categoryAxis.scale.count()
  38922. isNaN(availSize) && (availSize = 0) // 0/0 is NaN.
  38923. // Sampling some points, max 5.
  38924. var dataLen = data.count()
  38925. var step = Math.max(1, Math.round(dataLen / 5))
  38926. for (var dataIndex = 0; dataIndex < dataLen; dataIndex += step) {
  38927. if (
  38928. SymbolClz.getSymbolSize(
  38929. data,
  38930. dataIndex // Only for cartesian, where `isHorizontal` exists.
  38931. )[categoryAxis.isHorizontal() ? 1 : 0] * // Empirical number
  38932. 1.5 >
  38933. availSize
  38934. ) {
  38935. return false
  38936. }
  38937. }
  38938. return true
  38939. }
  38940. function isPointNull(x, y) {
  38941. return isNaN(x) || isNaN(y)
  38942. }
  38943. function getLastIndexNotNull(points) {
  38944. var len = points.length / 2
  38945. for (; len > 0; len--) {
  38946. if (!isPointNull(points[len * 2 - 2], points[len * 2 - 1])) {
  38947. break
  38948. }
  38949. }
  38950. return len - 1
  38951. }
  38952. function getPointAtIndex(points, idx) {
  38953. return [points[idx * 2], points[idx * 2 + 1]]
  38954. }
  38955. function getIndexRange(points, xOrY, dim) {
  38956. var len = points.length / 2
  38957. var dimIdx = dim === 'x' ? 0 : 1
  38958. var a
  38959. var b
  38960. var prevIndex = 0
  38961. var nextIndex = -1
  38962. for (var i = 0; i < len; i++) {
  38963. b = points[i * 2 + dimIdx]
  38964. if (isNaN(b) || isNaN(points[i * 2 + 1 - dimIdx])) {
  38965. continue
  38966. }
  38967. if (i === 0) {
  38968. a = b
  38969. continue
  38970. }
  38971. if ((a <= xOrY && b >= xOrY) || (a >= xOrY && b <= xOrY)) {
  38972. nextIndex = i
  38973. break
  38974. }
  38975. prevIndex = i
  38976. a = b
  38977. }
  38978. return { range: [prevIndex, nextIndex], t: (xOrY - a) / (b - a) }
  38979. }
  38980. function anyStateShowEndLabel(seriesModel) {
  38981. if (seriesModel.get(['endLabel', 'show'])) {
  38982. return true
  38983. }
  38984. for (var i = 0; i < SPECIAL_STATES.length; i++) {
  38985. if (seriesModel.get([SPECIAL_STATES[i], 'endLabel', 'show'])) {
  38986. return true
  38987. }
  38988. }
  38989. return false
  38990. }
  38991. function createLineClipPath(
  38992. lineView,
  38993. coordSys,
  38994. hasAnimation,
  38995. seriesModel
  38996. ) {
  38997. if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
  38998. var endLabelModel_1 = seriesModel.getModel('endLabel')
  38999. var valueAnimation_1 = endLabelModel_1.get('valueAnimation')
  39000. var data_1 = seriesModel.getData()
  39001. var labelAnimationRecord_1 = { lastFrameIndex: 0 }
  39002. var during = anyStateShowEndLabel(seriesModel)
  39003. ? function (percent, clipRect) {
  39004. lineView._endLabelOnDuring(
  39005. percent,
  39006. clipRect,
  39007. data_1,
  39008. labelAnimationRecord_1,
  39009. valueAnimation_1,
  39010. endLabelModel_1,
  39011. coordSys
  39012. )
  39013. }
  39014. : null
  39015. var isHorizontal = coordSys.getBaseAxis().isHorizontal()
  39016. var clipPath = createGridClipPath(
  39017. coordSys,
  39018. hasAnimation,
  39019. seriesModel,
  39020. function () {
  39021. var endLabel = lineView._endLabel
  39022. if (endLabel && hasAnimation) {
  39023. if (labelAnimationRecord_1.originalX != null) {
  39024. endLabel.attr({
  39025. x: labelAnimationRecord_1.originalX,
  39026. y: labelAnimationRecord_1.originalY
  39027. })
  39028. }
  39029. }
  39030. },
  39031. during
  39032. ) // Expand clip shape to avoid clipping when line value exceeds axis
  39033. if (!seriesModel.get('clip', true)) {
  39034. var rectShape = clipPath.shape
  39035. var expandSize = Math.max(rectShape.width, rectShape.height)
  39036. if (isHorizontal) {
  39037. rectShape.y -= expandSize
  39038. rectShape.height += expandSize * 2
  39039. } else {
  39040. rectShape.x -= expandSize
  39041. rectShape.width += expandSize * 2
  39042. }
  39043. } // Set to the final frame. To make sure label layout is right.
  39044. if (during) {
  39045. during(1, clipPath)
  39046. }
  39047. return clipPath
  39048. } else {
  39049. return createPolarClipPath(coordSys, hasAnimation, seriesModel)
  39050. }
  39051. }
  39052. function getEndLabelStateSpecified(endLabelModel, coordSys) {
  39053. var baseAxis = coordSys.getBaseAxis()
  39054. var isHorizontal = baseAxis.isHorizontal()
  39055. var isBaseInversed = baseAxis.inverse
  39056. var align = isHorizontal
  39057. ? isBaseInversed
  39058. ? 'right'
  39059. : 'left'
  39060. : 'center'
  39061. var verticalAlign = isHorizontal
  39062. ? 'middle'
  39063. : isBaseInversed
  39064. ? 'top'
  39065. : 'bottom'
  39066. return {
  39067. normal: {
  39068. align: endLabelModel.get('align') || align,
  39069. verticalAlign:
  39070. endLabelModel.get('verticalAlign') || verticalAlign
  39071. }
  39072. }
  39073. }
  39074. var LineView = /** @class */ (function (_super) {
  39075. __extends(LineView, _super)
  39076. function LineView() {
  39077. return (_super !== null && _super.apply(this, arguments)) || this
  39078. }
  39079. LineView.prototype.init = function () {
  39080. var lineGroup = new Group$3()
  39081. var symbolDraw = new SymbolDraw$1()
  39082. this.group.add(symbolDraw.group)
  39083. this._symbolDraw = symbolDraw
  39084. this._lineGroup = lineGroup
  39085. }
  39086. LineView.prototype.render = function (seriesModel, ecModel, api) {
  39087. var _this = this
  39088. var coordSys = seriesModel.coordinateSystem
  39089. var group = this.group
  39090. var data = seriesModel.getData()
  39091. var lineStyleModel = seriesModel.getModel('lineStyle')
  39092. var areaStyleModel = seriesModel.getModel('areaStyle')
  39093. var points = data.getLayout('points') || []
  39094. var isCoordSysPolar = coordSys.type === 'polar'
  39095. var prevCoordSys = this._coordSys
  39096. var symbolDraw = this._symbolDraw
  39097. var polyline = this._polyline
  39098. var polygon = this._polygon
  39099. var lineGroup = this._lineGroup
  39100. var hasAnimation = seriesModel.get('animation')
  39101. var isAreaChart = !areaStyleModel.isEmpty()
  39102. var valueOrigin = areaStyleModel.get('origin')
  39103. var dataCoordInfo = prepareDataCoordInfo(
  39104. coordSys,
  39105. data,
  39106. valueOrigin
  39107. )
  39108. var stackedOnPoints =
  39109. isAreaChart && getStackedOnPoints(coordSys, data, dataCoordInfo)
  39110. var showSymbol = seriesModel.get('showSymbol')
  39111. var connectNulls = seriesModel.get('connectNulls')
  39112. var isIgnoreFunc =
  39113. showSymbol &&
  39114. !isCoordSysPolar &&
  39115. getIsIgnoreFunc(seriesModel, data, coordSys) // Remove temporary symbols
  39116. var oldData = this._data
  39117. oldData &&
  39118. oldData.eachItemGraphicEl(function (el, idx) {
  39119. if (el.__temp) {
  39120. group.remove(el)
  39121. oldData.setItemGraphicEl(idx, null)
  39122. }
  39123. }) // Remove previous created symbols if showSymbol changed to false
  39124. if (!showSymbol) {
  39125. symbolDraw.remove()
  39126. }
  39127. group.add(lineGroup) // FIXME step not support polar
  39128. var step = !isCoordSysPolar ? seriesModel.get('step') : false
  39129. var clipShapeForSymbol
  39130. if (
  39131. coordSys &&
  39132. coordSys.getArea &&
  39133. seriesModel.get('clip', true)
  39134. ) {
  39135. clipShapeForSymbol = coordSys.getArea() // Avoid float number rounding error for symbol on the edge of axis extent.
  39136. // See #7913 and `test/dataZoom-clip.html`.
  39137. if (clipShapeForSymbol.width != null) {
  39138. clipShapeForSymbol.x -= 0.1
  39139. clipShapeForSymbol.y -= 0.1
  39140. clipShapeForSymbol.width += 0.2
  39141. clipShapeForSymbol.height += 0.2
  39142. } else if (clipShapeForSymbol.r0) {
  39143. clipShapeForSymbol.r0 -= 0.5
  39144. clipShapeForSymbol.r += 0.5
  39145. }
  39146. }
  39147. this._clipShapeForSymbol = clipShapeForSymbol
  39148. var visualColor =
  39149. getVisualGradient(data, coordSys, api) ||
  39150. data.getVisual('style')[data.getVisual('drawType')] // Initialization animation or coordinate system changed
  39151. if (
  39152. !(
  39153. polyline &&
  39154. prevCoordSys.type === coordSys.type &&
  39155. step === this._step
  39156. )
  39157. ) {
  39158. showSymbol &&
  39159. symbolDraw.updateData(data, {
  39160. isIgnore: isIgnoreFunc,
  39161. clipShape: clipShapeForSymbol,
  39162. disableAnimation: true,
  39163. getSymbolPoint: function getSymbolPoint(idx) {
  39164. return [points[idx * 2], points[idx * 2 + 1]]
  39165. }
  39166. })
  39167. hasAnimation &&
  39168. this._initSymbolLabelAnimation(
  39169. data,
  39170. coordSys,
  39171. clipShapeForSymbol
  39172. )
  39173. if (step) {
  39174. // TODO If stacked series is not step
  39175. points = turnPointsIntoStep(
  39176. points,
  39177. coordSys,
  39178. step,
  39179. connectNulls
  39180. )
  39181. if (stackedOnPoints) {
  39182. stackedOnPoints = turnPointsIntoStep(
  39183. stackedOnPoints,
  39184. coordSys,
  39185. step,
  39186. connectNulls
  39187. )
  39188. }
  39189. }
  39190. polyline = this._newPolyline(points)
  39191. if (isAreaChart) {
  39192. polygon = this._newPolygon(points, stackedOnPoints)
  39193. } // If areaStyle is removed
  39194. else if (polygon) {
  39195. lineGroup.remove(polygon)
  39196. polygon = this._polygon = null
  39197. } // NOTE: Must update _endLabel before setClipPath.
  39198. if (!isCoordSysPolar) {
  39199. this._initOrUpdateEndLabel(
  39200. seriesModel,
  39201. coordSys,
  39202. convertToColorString(visualColor)
  39203. )
  39204. }
  39205. lineGroup.setClipPath(
  39206. createLineClipPath(this, coordSys, true, seriesModel)
  39207. )
  39208. } else {
  39209. if (isAreaChart && !polygon) {
  39210. // If areaStyle is added
  39211. polygon = this._newPolygon(points, stackedOnPoints)
  39212. } else if (polygon && !isAreaChart) {
  39213. // If areaStyle is removed
  39214. lineGroup.remove(polygon)
  39215. polygon = this._polygon = null
  39216. } // NOTE: Must update _endLabel before setClipPath.
  39217. if (!isCoordSysPolar) {
  39218. this._initOrUpdateEndLabel(
  39219. seriesModel,
  39220. coordSys,
  39221. convertToColorString(visualColor)
  39222. )
  39223. } // Update clipPath
  39224. var oldClipPath = lineGroup.getClipPath()
  39225. if (oldClipPath) {
  39226. var newClipPath = createLineClipPath(
  39227. this,
  39228. coordSys,
  39229. false,
  39230. seriesModel
  39231. )
  39232. initProps(
  39233. oldClipPath,
  39234. { shape: newClipPath.shape },
  39235. seriesModel
  39236. )
  39237. } else {
  39238. lineGroup.setClipPath(
  39239. createLineClipPath(this, coordSys, true, seriesModel)
  39240. )
  39241. } // Always update, or it is wrong in the case turning on legend
  39242. // because points are not changed
  39243. showSymbol &&
  39244. symbolDraw.updateData(data, {
  39245. isIgnore: isIgnoreFunc,
  39246. clipShape: clipShapeForSymbol,
  39247. disableAnimation: true,
  39248. getSymbolPoint: function getSymbolPoint(idx) {
  39249. return [points[idx * 2], points[idx * 2 + 1]]
  39250. }
  39251. }) // In the case data zoom triggerred refreshing frequently
  39252. // Data may not change if line has a category axis. So it should animate nothing
  39253. if (
  39254. !isPointsSame(this._stackedOnPoints, stackedOnPoints) ||
  39255. !isPointsSame(this._points, points)
  39256. ) {
  39257. if (hasAnimation) {
  39258. this._doUpdateAnimation(
  39259. data,
  39260. stackedOnPoints,
  39261. coordSys,
  39262. api,
  39263. step,
  39264. valueOrigin,
  39265. connectNulls
  39266. )
  39267. } else {
  39268. // Not do it in update with animation
  39269. if (step) {
  39270. // TODO If stacked series is not step
  39271. points = turnPointsIntoStep(
  39272. points,
  39273. coordSys,
  39274. step,
  39275. connectNulls
  39276. )
  39277. if (stackedOnPoints) {
  39278. stackedOnPoints = turnPointsIntoStep(
  39279. stackedOnPoints,
  39280. coordSys,
  39281. step,
  39282. connectNulls
  39283. )
  39284. }
  39285. }
  39286. polyline.setShape({ points: points })
  39287. polygon &&
  39288. polygon.setShape({
  39289. points: points,
  39290. stackedOnPoints: stackedOnPoints
  39291. })
  39292. }
  39293. }
  39294. }
  39295. var emphasisModel = seriesModel.getModel('emphasis')
  39296. var focus = emphasisModel.get('focus')
  39297. var blurScope = emphasisModel.get('blurScope')
  39298. var emphasisDisabled = emphasisModel.get('disabled')
  39299. polyline.useStyle(
  39300. defaults(
  39301. // Use color in lineStyle first
  39302. lineStyleModel.getLineStyle(),
  39303. { fill: 'none', stroke: visualColor, lineJoin: 'bevel' }
  39304. )
  39305. )
  39306. setStatesStylesFromModel(polyline, seriesModel, 'lineStyle')
  39307. if (
  39308. polyline.style.lineWidth > 0 &&
  39309. seriesModel.get(['emphasis', 'lineStyle', 'width']) === 'bolder'
  39310. ) {
  39311. var emphasisLineStyle = polyline.getState('emphasis').style
  39312. emphasisLineStyle.lineWidth = +polyline.style.lineWidth + 1
  39313. } // Needs seriesIndex for focus
  39314. getECData(polyline).seriesIndex = seriesModel.seriesIndex
  39315. toggleHoverEmphasis(polyline, focus, blurScope, emphasisDisabled)
  39316. var smooth = getSmooth(seriesModel.get('smooth'))
  39317. var smoothMonotone = seriesModel.get('smoothMonotone')
  39318. polyline.setShape({
  39319. smooth: smooth,
  39320. smoothMonotone: smoothMonotone,
  39321. connectNulls: connectNulls
  39322. })
  39323. if (polygon) {
  39324. var stackedOnSeries = data.getCalculationInfo('stackedOnSeries')
  39325. var stackedOnSmooth = 0
  39326. polygon.useStyle(
  39327. defaults(areaStyleModel.getAreaStyle(), {
  39328. fill: visualColor,
  39329. opacity: 0.7,
  39330. lineJoin: 'bevel',
  39331. decal: data.getVisual('style').decal
  39332. })
  39333. )
  39334. if (stackedOnSeries) {
  39335. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'))
  39336. }
  39337. polygon.setShape({
  39338. smooth: smooth,
  39339. stackedOnSmooth: stackedOnSmooth,
  39340. smoothMonotone: smoothMonotone,
  39341. connectNulls: connectNulls
  39342. })
  39343. setStatesStylesFromModel(polygon, seriesModel, 'areaStyle') // Needs seriesIndex for focus
  39344. getECData(polygon).seriesIndex = seriesModel.seriesIndex
  39345. toggleHoverEmphasis(polygon, focus, blurScope, emphasisDisabled)
  39346. }
  39347. var changePolyState = function changePolyState(toState) {
  39348. _this._changePolyState(toState)
  39349. }
  39350. data.eachItemGraphicEl(function (el) {
  39351. // Switch polyline / polygon state if element changed its state.
  39352. el && (el.onHoverStateChange = changePolyState)
  39353. })
  39354. this._polyline.onHoverStateChange = changePolyState
  39355. this._data = data // Save the coordinate system for transition animation when data changed
  39356. this._coordSys = coordSys
  39357. this._stackedOnPoints = stackedOnPoints
  39358. this._points = points
  39359. this._step = step
  39360. this._valueOrigin = valueOrigin
  39361. if (seriesModel.get('triggerLineEvent')) {
  39362. this.packEventData(seriesModel, polyline)
  39363. polygon && this.packEventData(seriesModel, polygon)
  39364. }
  39365. }
  39366. LineView.prototype.packEventData = function (seriesModel, el) {
  39367. getECData(el).eventData = {
  39368. componentType: 'series',
  39369. componentSubType: 'line',
  39370. componentIndex: seriesModel.componentIndex,
  39371. seriesIndex: seriesModel.seriesIndex,
  39372. seriesName: seriesModel.name,
  39373. seriesType: 'line'
  39374. }
  39375. }
  39376. LineView.prototype.highlight = function (
  39377. seriesModel,
  39378. ecModel,
  39379. api,
  39380. payload
  39381. ) {
  39382. var data = seriesModel.getData()
  39383. var dataIndex = queryDataIndex(data, payload)
  39384. this._changePolyState('emphasis')
  39385. if (
  39386. !(dataIndex instanceof Array) &&
  39387. dataIndex != null &&
  39388. dataIndex >= 0
  39389. ) {
  39390. var points = data.getLayout('points')
  39391. var symbol = data.getItemGraphicEl(dataIndex)
  39392. if (!symbol) {
  39393. // Create a temporary symbol if it is not exists
  39394. var x = points[dataIndex * 2]
  39395. var y = points[dataIndex * 2 + 1]
  39396. if (isNaN(x) || isNaN(y)) {
  39397. // Null data
  39398. return
  39399. } // fix #11360: should't draw symbol outside clipShapeForSymbol
  39400. if (
  39401. this._clipShapeForSymbol &&
  39402. !this._clipShapeForSymbol.contain(x, y)
  39403. ) {
  39404. return
  39405. }
  39406. var zlevel = seriesModel.get('zlevel')
  39407. var z = seriesModel.get('z')
  39408. symbol = new SymbolClz(data, dataIndex)
  39409. symbol.x = x
  39410. symbol.y = y
  39411. symbol.setZ(zlevel, z) // ensure label text of the temporary symbol is in front of line and area polygon
  39412. var symbolLabel = symbol.getSymbolPath().getTextContent()
  39413. if (symbolLabel) {
  39414. symbolLabel.zlevel = zlevel
  39415. symbolLabel.z = z
  39416. symbolLabel.z2 = this._polyline.z2 + 1
  39417. }
  39418. symbol.__temp = true
  39419. data.setItemGraphicEl(dataIndex, symbol) // Stop scale animation
  39420. symbol.stopSymbolAnimation(true)
  39421. this.group.add(symbol)
  39422. }
  39423. symbol.highlight()
  39424. } else {
  39425. // Highlight whole series
  39426. ChartView$1.prototype.highlight.call(
  39427. this,
  39428. seriesModel,
  39429. ecModel,
  39430. api,
  39431. payload
  39432. )
  39433. }
  39434. }
  39435. LineView.prototype.downplay = function (
  39436. seriesModel,
  39437. ecModel,
  39438. api,
  39439. payload
  39440. ) {
  39441. var data = seriesModel.getData()
  39442. var dataIndex = queryDataIndex(data, payload)
  39443. this._changePolyState('normal')
  39444. if (dataIndex != null && dataIndex >= 0) {
  39445. var symbol = data.getItemGraphicEl(dataIndex)
  39446. if (symbol) {
  39447. if (symbol.__temp) {
  39448. data.setItemGraphicEl(dataIndex, null)
  39449. this.group.remove(symbol)
  39450. } else {
  39451. symbol.downplay()
  39452. }
  39453. }
  39454. } else {
  39455. // FIXME
  39456. // can not downplay completely.
  39457. // Downplay whole series
  39458. ChartView$1.prototype.downplay.call(
  39459. this,
  39460. seriesModel,
  39461. ecModel,
  39462. api,
  39463. payload
  39464. )
  39465. }
  39466. }
  39467. LineView.prototype._changePolyState = function (toState) {
  39468. var polygon = this._polygon
  39469. setStatesFlag(this._polyline, toState)
  39470. polygon && setStatesFlag(polygon, toState)
  39471. }
  39472. LineView.prototype._newPolyline = function (points) {
  39473. var polyline = this._polyline // Remove previous created polyline
  39474. if (polyline) {
  39475. this._lineGroup.remove(polyline)
  39476. }
  39477. polyline = new ECPolyline({
  39478. shape: { points: points },
  39479. segmentIgnoreThreshold: 2,
  39480. z2: 10
  39481. })
  39482. this._lineGroup.add(polyline)
  39483. this._polyline = polyline
  39484. return polyline
  39485. }
  39486. LineView.prototype._newPolygon = function (
  39487. points,
  39488. stackedOnPoints
  39489. ) {
  39490. var polygon = this._polygon // Remove previous created polygon
  39491. if (polygon) {
  39492. this._lineGroup.remove(polygon)
  39493. }
  39494. polygon = new ECPolygon({
  39495. shape: { points: points, stackedOnPoints: stackedOnPoints },
  39496. segmentIgnoreThreshold: 2
  39497. })
  39498. this._lineGroup.add(polygon)
  39499. this._polygon = polygon
  39500. return polygon
  39501. }
  39502. LineView.prototype._initSymbolLabelAnimation = function (
  39503. data,
  39504. coordSys,
  39505. clipShape
  39506. ) {
  39507. var isHorizontalOrRadial
  39508. var isCoordSysPolar
  39509. var baseAxis = coordSys.getBaseAxis()
  39510. var isAxisInverse = baseAxis.inverse
  39511. if (coordSys.type === 'cartesian2d') {
  39512. isHorizontalOrRadial = baseAxis.isHorizontal()
  39513. isCoordSysPolar = false
  39514. } else if (coordSys.type === 'polar') {
  39515. isHorizontalOrRadial = baseAxis.dim === 'angle'
  39516. isCoordSysPolar = true
  39517. }
  39518. var seriesModel = data.hostModel
  39519. var seriesDuration = seriesModel.get('animationDuration')
  39520. if (isFunction(seriesDuration)) {
  39521. seriesDuration = seriesDuration(null)
  39522. }
  39523. var seriesDalay = seriesModel.get('animationDelay') || 0
  39524. var seriesDalayValue = isFunction(seriesDalay)
  39525. ? seriesDalay(null)
  39526. : seriesDalay
  39527. data.eachItemGraphicEl(function (symbol, idx) {
  39528. var el = symbol
  39529. if (el) {
  39530. var point = [symbol.x, symbol.y]
  39531. var start = void 0
  39532. var end = void 0
  39533. var current = void 0
  39534. if (clipShape) {
  39535. if (isCoordSysPolar) {
  39536. var polarClip = clipShape
  39537. var coord = coordSys.pointToCoord(point)
  39538. if (isHorizontalOrRadial) {
  39539. start = polarClip.startAngle
  39540. end = polarClip.endAngle
  39541. current = (-coord[1] / 180) * Math.PI
  39542. } else {
  39543. start = polarClip.r0
  39544. end = polarClip.r
  39545. current = coord[0]
  39546. }
  39547. } else {
  39548. var gridClip = clipShape
  39549. if (isHorizontalOrRadial) {
  39550. start = gridClip.x
  39551. end = gridClip.x + gridClip.width
  39552. current = symbol.x
  39553. } else {
  39554. start = gridClip.y + gridClip.height
  39555. end = gridClip.y
  39556. current = symbol.y
  39557. }
  39558. }
  39559. }
  39560. var ratio =
  39561. end === start ? 0 : (current - start) / (end - start)
  39562. if (isAxisInverse) {
  39563. ratio = 1 - ratio
  39564. }
  39565. var delay = isFunction(seriesDalay)
  39566. ? seriesDalay(idx)
  39567. : seriesDuration * ratio + seriesDalayValue
  39568. var symbolPath = el.getSymbolPath()
  39569. var text = symbolPath.getTextContent()
  39570. el.attr({ scaleX: 0, scaleY: 0 })
  39571. el.animateTo(
  39572. { scaleX: 1, scaleY: 1 },
  39573. { duration: 200, setToFinal: true, delay: delay }
  39574. )
  39575. if (text) {
  39576. text.animateFrom(
  39577. { style: { opacity: 0 } },
  39578. { duration: 300, delay: delay }
  39579. )
  39580. }
  39581. symbolPath.disableLabelAnimation = true
  39582. }
  39583. })
  39584. }
  39585. LineView.prototype._initOrUpdateEndLabel = function (
  39586. seriesModel,
  39587. coordSys,
  39588. inheritColor
  39589. ) {
  39590. var endLabelModel = seriesModel.getModel('endLabel')
  39591. if (anyStateShowEndLabel(seriesModel)) {
  39592. var data_2 = seriesModel.getData()
  39593. var polyline = this._polyline // series may be filtered.
  39594. var points = data_2.getLayout('points')
  39595. if (!points) {
  39596. polyline.removeTextContent()
  39597. this._endLabel = null
  39598. return
  39599. }
  39600. var endLabel = this._endLabel
  39601. if (!endLabel) {
  39602. endLabel = this._endLabel = new ZRText$1({
  39603. z2: 200 // should be higher than item symbol
  39604. })
  39605. endLabel.ignoreClip = true
  39606. polyline.setTextContent(this._endLabel)
  39607. polyline.disableLabelAnimation = true
  39608. } // Find last non-NaN data to display data
  39609. var dataIndex = getLastIndexNotNull(points)
  39610. if (dataIndex >= 0) {
  39611. setLabelStyle(
  39612. polyline,
  39613. getLabelStatesModels(seriesModel, 'endLabel'),
  39614. {
  39615. inheritColor: inheritColor,
  39616. labelFetcher: seriesModel,
  39617. labelDataIndex: dataIndex,
  39618. defaultText: function defaultText(
  39619. dataIndex,
  39620. opt,
  39621. interpolatedValue
  39622. ) {
  39623. return interpolatedValue != null
  39624. ? getDefaultInterpolatedLabel(
  39625. data_2,
  39626. interpolatedValue
  39627. )
  39628. : getDefaultLabel(data_2, dataIndex)
  39629. },
  39630. enableTextSetter: true
  39631. },
  39632. getEndLabelStateSpecified(endLabelModel, coordSys)
  39633. )
  39634. polyline.textConfig.position = null
  39635. }
  39636. } else if (this._endLabel) {
  39637. this._polyline.removeTextContent()
  39638. this._endLabel = null
  39639. }
  39640. }
  39641. LineView.prototype._endLabelOnDuring = function (
  39642. percent,
  39643. clipRect,
  39644. data,
  39645. animationRecord,
  39646. valueAnimation,
  39647. endLabelModel,
  39648. coordSys
  39649. ) {
  39650. var endLabel = this._endLabel
  39651. var polyline = this._polyline
  39652. if (endLabel) {
  39653. // NOTE: Don't remove percent < 1. percent === 1 means the first frame during render.
  39654. // The label is not prepared at this time.
  39655. if (percent < 1 && animationRecord.originalX == null) {
  39656. animationRecord.originalX = endLabel.x
  39657. animationRecord.originalY = endLabel.y
  39658. }
  39659. var points = data.getLayout('points')
  39660. var seriesModel = data.hostModel
  39661. var connectNulls = seriesModel.get('connectNulls')
  39662. var precision = endLabelModel.get('precision')
  39663. var distance = endLabelModel.get('distance') || 0
  39664. var baseAxis = coordSys.getBaseAxis()
  39665. var isHorizontal = baseAxis.isHorizontal()
  39666. var isBaseInversed = baseAxis.inverse
  39667. var clipShape = clipRect.shape
  39668. var xOrY = isBaseInversed
  39669. ? isHorizontal
  39670. ? clipShape.x
  39671. : clipShape.y + clipShape.height
  39672. : isHorizontal
  39673. ? clipShape.x + clipShape.width
  39674. : clipShape.y
  39675. var distanceX =
  39676. (isHorizontal ? distance : 0) * (isBaseInversed ? -1 : 1)
  39677. var distanceY =
  39678. (isHorizontal ? 0 : -distance) * (isBaseInversed ? -1 : 1)
  39679. var dim = isHorizontal ? 'x' : 'y'
  39680. var dataIndexRange = getIndexRange(points, xOrY, dim)
  39681. var indices = dataIndexRange.range
  39682. var diff = indices[1] - indices[0]
  39683. var value = void 0
  39684. if (diff >= 1) {
  39685. // diff > 1 && connectNulls, which is on the null data.
  39686. if (diff > 1 && !connectNulls) {
  39687. var pt = getPointAtIndex(points, indices[0])
  39688. endLabel.attr({
  39689. x: pt[0] + distanceX,
  39690. y: pt[1] + distanceY
  39691. })
  39692. valueAnimation &&
  39693. (value = seriesModel.getRawValue(indices[0]))
  39694. } else {
  39695. var pt = polyline.getPointOn(xOrY, dim)
  39696. pt &&
  39697. endLabel.attr({
  39698. x: pt[0] + distanceX,
  39699. y: pt[1] + distanceY
  39700. })
  39701. var startValue = seriesModel.getRawValue(indices[0])
  39702. var endValue = seriesModel.getRawValue(indices[1])
  39703. valueAnimation &&
  39704. (value = interpolateRawValues(
  39705. data,
  39706. precision,
  39707. startValue,
  39708. endValue,
  39709. dataIndexRange.t
  39710. ))
  39711. }
  39712. animationRecord.lastFrameIndex = indices[0]
  39713. } else {
  39714. // If diff <= 0, which is the range is not found(Include NaN)
  39715. // Choose the first point or last point.
  39716. var idx =
  39717. percent === 1 || animationRecord.lastFrameIndex > 0
  39718. ? indices[0]
  39719. : 0
  39720. var pt = getPointAtIndex(points, idx)
  39721. valueAnimation && (value = seriesModel.getRawValue(idx))
  39722. endLabel.attr({ x: pt[0] + distanceX, y: pt[1] + distanceY })
  39723. }
  39724. if (valueAnimation) {
  39725. labelInner(endLabel).setLabelText(value)
  39726. }
  39727. }
  39728. }
  39729. /**
  39730. * @private
  39731. */ // FIXME Two value axis
  39732. LineView.prototype._doUpdateAnimation = function (
  39733. data,
  39734. stackedOnPoints,
  39735. coordSys,
  39736. api,
  39737. step,
  39738. valueOrigin,
  39739. connectNulls
  39740. ) {
  39741. var polyline = this._polyline
  39742. var polygon = this._polygon
  39743. var seriesModel = data.hostModel
  39744. var diff = lineAnimationDiff(
  39745. this._data,
  39746. data,
  39747. this._stackedOnPoints,
  39748. stackedOnPoints,
  39749. this._coordSys,
  39750. coordSys,
  39751. this._valueOrigin
  39752. )
  39753. var current = diff.current
  39754. var stackedOnCurrent = diff.stackedOnCurrent
  39755. var next = diff.next
  39756. var stackedOnNext = diff.stackedOnNext
  39757. if (step) {
  39758. // TODO If stacked series is not step
  39759. current = turnPointsIntoStep(
  39760. diff.current,
  39761. coordSys,
  39762. step,
  39763. connectNulls
  39764. )
  39765. stackedOnCurrent = turnPointsIntoStep(
  39766. diff.stackedOnCurrent,
  39767. coordSys,
  39768. step,
  39769. connectNulls
  39770. )
  39771. next = turnPointsIntoStep(
  39772. diff.next,
  39773. coordSys,
  39774. step,
  39775. connectNulls
  39776. )
  39777. stackedOnNext = turnPointsIntoStep(
  39778. diff.stackedOnNext,
  39779. coordSys,
  39780. step,
  39781. connectNulls
  39782. )
  39783. } // Don't apply animation if diff is large.
  39784. // For better result and avoid memory explosion problems like
  39785. // https://github.com/apache/incubator-echarts/issues/12229
  39786. if (
  39787. getBoundingDiff(current, next) > 3000 ||
  39788. (polygon &&
  39789. getBoundingDiff(stackedOnCurrent, stackedOnNext) > 3000)
  39790. ) {
  39791. polyline.stopAnimation()
  39792. polyline.setShape({ points: next })
  39793. if (polygon) {
  39794. polygon.stopAnimation()
  39795. polygon.setShape({
  39796. points: next,
  39797. stackedOnPoints: stackedOnNext
  39798. })
  39799. }
  39800. return
  39801. }
  39802. polyline.shape.__points = diff.current
  39803. polyline.shape.points = current
  39804. var target = { shape: { points: next } } // Also animate the original points.
  39805. // If points reference is changed when turning into step line.
  39806. if (diff.current !== current) {
  39807. target.shape.__points = diff.next
  39808. } // Stop previous animation.
  39809. polyline.stopAnimation()
  39810. updateProps$1(polyline, target, seriesModel)
  39811. if (polygon) {
  39812. polygon.setShape({
  39813. // Reuse the points with polyline.
  39814. points: current,
  39815. stackedOnPoints: stackedOnCurrent
  39816. })
  39817. polygon.stopAnimation()
  39818. updateProps$1(
  39819. polygon,
  39820. { shape: { stackedOnPoints: stackedOnNext } },
  39821. seriesModel
  39822. ) // If use attr directly in updateProps.
  39823. if (polyline.shape.points !== polygon.shape.points) {
  39824. polygon.shape.points = polyline.shape.points
  39825. }
  39826. }
  39827. var updatedDataInfo = []
  39828. var diffStatus = diff.status
  39829. for (var i = 0; i < diffStatus.length; i++) {
  39830. var cmd = diffStatus[i].cmd
  39831. if (cmd === '=') {
  39832. var el = data.getItemGraphicEl(diffStatus[i].idx1)
  39833. if (el) {
  39834. updatedDataInfo.push({
  39835. el: el,
  39836. ptIdx: i // Index of points
  39837. })
  39838. }
  39839. }
  39840. }
  39841. if (polyline.animators && polyline.animators.length) {
  39842. polyline.animators[0].during(function () {
  39843. polygon && polygon.dirtyShape()
  39844. var points = polyline.shape.__points
  39845. for (var i = 0; i < updatedDataInfo.length; i++) {
  39846. var el = updatedDataInfo[i].el
  39847. var offset = updatedDataInfo[i].ptIdx * 2
  39848. el.x = points[offset]
  39849. el.y = points[offset + 1]
  39850. el.markRedraw()
  39851. }
  39852. })
  39853. }
  39854. }
  39855. LineView.prototype.remove = function (ecModel) {
  39856. var group = this.group
  39857. var oldData = this._data
  39858. this._lineGroup.removeAll()
  39859. this._symbolDraw.remove(true) // Remove temporary created elements when highlighting
  39860. oldData &&
  39861. oldData.eachItemGraphicEl(function (el, idx) {
  39862. if (el.__temp) {
  39863. group.remove(el)
  39864. oldData.setItemGraphicEl(idx, null)
  39865. }
  39866. })
  39867. this._polyline =
  39868. this._polygon =
  39869. this._coordSys =
  39870. this._points =
  39871. this._stackedOnPoints =
  39872. this._endLabel =
  39873. this._data =
  39874. null
  39875. }
  39876. LineView.type = 'line'
  39877. return LineView
  39878. })(ChartView$1)
  39879. var LineView$1 = LineView
  39880. function pointsLayout(seriesType, forceStoreInTypedArray) {
  39881. return {
  39882. seriesType: seriesType,
  39883. plan: createRenderPlanner(),
  39884. reset: function reset(seriesModel) {
  39885. var data = seriesModel.getData()
  39886. var coordSys = seriesModel.coordinateSystem
  39887. var pipelineContext = seriesModel.pipelineContext
  39888. var useTypedArray =
  39889. forceStoreInTypedArray || pipelineContext.large
  39890. if (!coordSys) {
  39891. return
  39892. }
  39893. var dims = map$1(coordSys.dimensions, function (dim) {
  39894. return data.mapDimension(dim)
  39895. }).slice(0, 2)
  39896. var dimLen = dims.length
  39897. var stackResultDim = data.getCalculationInfo(
  39898. 'stackResultDimension'
  39899. )
  39900. if (isDimensionStacked(data, dims[0])) {
  39901. dims[0] = stackResultDim
  39902. }
  39903. if (isDimensionStacked(data, dims[1])) {
  39904. dims[1] = stackResultDim
  39905. }
  39906. var store = data.getStore()
  39907. var dimIdx0 = data.getDimensionIndex(dims[0])
  39908. var dimIdx1 = data.getDimensionIndex(dims[1])
  39909. return (
  39910. dimLen && {
  39911. progress: function progress(params, data) {
  39912. var segCount = params.end - params.start
  39913. var points =
  39914. useTypedArray && createFloat32Array(segCount * dimLen)
  39915. var tmpIn = []
  39916. var tmpOut = []
  39917. for (
  39918. var i = params.start, offset = 0;
  39919. i < params.end;
  39920. i++
  39921. ) {
  39922. var point = void 0
  39923. if (dimLen === 1) {
  39924. var x = store.get(dimIdx0, i) // NOTE: Make sure the second parameter is null to use default strategy.
  39925. point = coordSys.dataToPoint(x, null, tmpOut)
  39926. } else {
  39927. tmpIn[0] = store.get(dimIdx0, i)
  39928. tmpIn[1] = store.get(dimIdx1, i) // Let coordinate system to handle the NaN data.
  39929. point = coordSys.dataToPoint(tmpIn, null, tmpOut)
  39930. }
  39931. if (useTypedArray) {
  39932. points[offset++] = point[0]
  39933. points[offset++] = point[1]
  39934. } else {
  39935. data.setItemLayout(i, point.slice())
  39936. }
  39937. }
  39938. useTypedArray && data.setLayout('points', points)
  39939. }
  39940. }
  39941. )
  39942. }
  39943. }
  39944. }
  39945. var samplers = {
  39946. average: function average(frame) {
  39947. var sum = 0
  39948. var count = 0
  39949. for (var i = 0; i < frame.length; i++) {
  39950. if (!isNaN(frame[i])) {
  39951. sum += frame[i]
  39952. count++
  39953. }
  39954. } // Return NaN if count is 0
  39955. return count === 0 ? NaN : sum / count
  39956. },
  39957. sum: function sum(frame) {
  39958. var sum = 0
  39959. for (var i = 0; i < frame.length; i++) {
  39960. // Ignore NaN
  39961. sum += frame[i] || 0
  39962. }
  39963. return sum
  39964. },
  39965. max: function max(frame) {
  39966. var max = -Infinity
  39967. for (var i = 0; i < frame.length; i++) {
  39968. frame[i] > max && (max = frame[i])
  39969. } // NaN will cause illegal axis extent.
  39970. return isFinite(max) ? max : NaN
  39971. },
  39972. min: function min(frame) {
  39973. var min = Infinity
  39974. for (var i = 0; i < frame.length; i++) {
  39975. frame[i] < min && (min = frame[i])
  39976. } // NaN will cause illegal axis extent.
  39977. return isFinite(min) ? min : NaN
  39978. }, // TODO
  39979. // Median
  39980. nearest: function nearest(frame) {
  39981. return frame[0]
  39982. }
  39983. }
  39984. var indexSampler = function indexSampler(frame) {
  39985. return Math.round(frame.length / 2)
  39986. }
  39987. function dataSample(seriesType) {
  39988. return {
  39989. seriesType: seriesType, // FIXME:TS never used, so comment it
  39990. // modifyOutputEnd: true,
  39991. reset: function reset(seriesModel, ecModel, api) {
  39992. var data = seriesModel.getData()
  39993. var sampling = seriesModel.get('sampling')
  39994. var coordSys = seriesModel.coordinateSystem
  39995. var count = data.count() // Only cartesian2d support down sampling. Disable it when there is few data.
  39996. if (count > 10 && coordSys.type === 'cartesian2d' && sampling) {
  39997. var baseAxis = coordSys.getBaseAxis()
  39998. var valueAxis = coordSys.getOtherAxis(baseAxis)
  39999. var extent = baseAxis.getExtent()
  40000. var dpr = api.getDevicePixelRatio() // Coordinste system has been resized
  40001. var size = Math.abs(extent[1] - extent[0]) * (dpr || 1)
  40002. var rate = Math.round(count / size)
  40003. if (isFinite(rate) && rate > 1) {
  40004. if (sampling === 'lttb') {
  40005. seriesModel.setData(
  40006. data.lttbDownSample(
  40007. data.mapDimension(valueAxis.dim),
  40008. 1 / rate
  40009. )
  40010. )
  40011. }
  40012. var sampler = void 0
  40013. if (isString(sampling)) {
  40014. sampler = samplers[sampling]
  40015. } else if (isFunction(sampling)) {
  40016. sampler = sampling
  40017. }
  40018. if (sampler) {
  40019. // Only support sample the first dim mapped from value axis.
  40020. seriesModel.setData(
  40021. data.downSample(
  40022. data.mapDimension(valueAxis.dim),
  40023. 1 / rate,
  40024. sampler,
  40025. indexSampler
  40026. )
  40027. )
  40028. }
  40029. }
  40030. }
  40031. }
  40032. }
  40033. }
  40034. function install$i(registers) {
  40035. registers.registerChartView(LineView$1)
  40036. registers.registerSeriesModel(LineSeries)
  40037. registers.registerLayout(pointsLayout('line', true))
  40038. registers.registerVisual({
  40039. seriesType: 'line',
  40040. reset: function reset(seriesModel) {
  40041. var data = seriesModel.getData() // Visual coding for legend
  40042. var lineStyle = seriesModel.getModel('lineStyle').getLineStyle()
  40043. if (lineStyle && !lineStyle.stroke) {
  40044. // Fill in visual should be palette color if
  40045. // has color callback
  40046. lineStyle.stroke = data.getVisual('style').fill
  40047. }
  40048. data.setVisual('legendLineStyle', lineStyle)
  40049. }
  40050. }) // Down sample after filter
  40051. registers.registerProcessor(
  40052. registers.PRIORITY.PROCESSOR.STATISTIC,
  40053. dataSample('line')
  40054. )
  40055. }
  40056. var BaseBarSeriesModel = /** @class */ (function (_super) {
  40057. __extends(BaseBarSeriesModel, _super)
  40058. function BaseBarSeriesModel() {
  40059. var _this =
  40060. (_super !== null && _super.apply(this, arguments)) || this
  40061. _this.type = BaseBarSeriesModel.type
  40062. return _this
  40063. }
  40064. BaseBarSeriesModel.prototype.getInitialData = function (
  40065. option,
  40066. ecModel
  40067. ) {
  40068. return createSeriesData(null, this, { useEncodeDefaulter: true })
  40069. }
  40070. BaseBarSeriesModel.prototype.getMarkerPosition = function (value) {
  40071. var coordSys = this.coordinateSystem
  40072. if (coordSys && coordSys.clampData) {
  40073. // PENDING if clamp ?
  40074. var pt = coordSys.dataToPoint(coordSys.clampData(value))
  40075. var data = this.getData()
  40076. var offset = data.getLayout('offset')
  40077. var size = data.getLayout('size')
  40078. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1
  40079. pt[offsetIndex] += offset + size / 2
  40080. return pt
  40081. }
  40082. return [NaN, NaN]
  40083. }
  40084. BaseBarSeriesModel.type = 'series.__base_bar__'
  40085. BaseBarSeriesModel.defaultOption = {
  40086. // zlevel: 0,
  40087. z: 2,
  40088. coordinateSystem: 'cartesian2d',
  40089. legendHoverLink: true, // stack: null
  40090. // Cartesian coordinate system
  40091. // xAxisIndex: 0,
  40092. // yAxisIndex: 0,
  40093. barMinHeight: 0,
  40094. barMinAngle: 0, // cursor: null,
  40095. large: false,
  40096. largeThreshold: 400,
  40097. progressive: 3e3,
  40098. progressiveChunkMode: 'mod'
  40099. }
  40100. return BaseBarSeriesModel
  40101. })(SeriesModel$1)
  40102. SeriesModel$1.registerClass(BaseBarSeriesModel)
  40103. var BaseBarSeriesModel$1 = BaseBarSeriesModel
  40104. var BarSeriesModel = /** @class */ (function (_super) {
  40105. __extends(BarSeriesModel, _super)
  40106. function BarSeriesModel() {
  40107. var _this =
  40108. (_super !== null && _super.apply(this, arguments)) || this
  40109. _this.type = BarSeriesModel.type
  40110. return _this
  40111. }
  40112. BarSeriesModel.prototype.getInitialData = function () {
  40113. return createSeriesData(null, this, {
  40114. useEncodeDefaulter: true,
  40115. createInvertedIndices: !!this.get('realtimeSort', true) || null
  40116. })
  40117. }
  40118. /**
  40119. * @override
  40120. */ BarSeriesModel.prototype.getProgressive = function () {
  40121. // Do not support progressive in normal mode.
  40122. return this.get('large') ? this.get('progressive') : false
  40123. }
  40124. /**
  40125. * @override
  40126. */ BarSeriesModel.prototype.getProgressiveThreshold = function () {
  40127. // Do not support progressive in normal mode.
  40128. var progressiveThreshold = this.get('progressiveThreshold')
  40129. var largeThreshold = this.get('largeThreshold')
  40130. if (largeThreshold > progressiveThreshold) {
  40131. progressiveThreshold = largeThreshold
  40132. }
  40133. return progressiveThreshold
  40134. }
  40135. BarSeriesModel.prototype.brushSelector = function (
  40136. dataIndex,
  40137. data,
  40138. selectors
  40139. ) {
  40140. return selectors.rect(data.getItemLayout(dataIndex))
  40141. }
  40142. BarSeriesModel.type = 'series.bar'
  40143. BarSeriesModel.dependencies = ['grid', 'polar']
  40144. BarSeriesModel.defaultOption = inheritDefaultOption(
  40145. BaseBarSeriesModel$1.defaultOption,
  40146. {
  40147. // If clipped
  40148. // Only available on cartesian2d
  40149. clip: true,
  40150. roundCap: false,
  40151. showBackground: false,
  40152. backgroundStyle: {
  40153. color: 'rgba(180, 180, 180, 0.2)',
  40154. borderColor: null,
  40155. borderWidth: 0,
  40156. borderType: 'solid',
  40157. borderRadius: 0,
  40158. shadowBlur: 0,
  40159. shadowColor: null,
  40160. shadowOffsetX: 0,
  40161. shadowOffsetY: 0,
  40162. opacity: 1
  40163. },
  40164. select: { itemStyle: { borderColor: '#212121' } },
  40165. realtimeSort: false
  40166. }
  40167. )
  40168. return BarSeriesModel
  40169. })(BaseBarSeriesModel$1)
  40170. var BarSeries = BarSeriesModel
  40171. /**
  40172. * Sausage: similar to sector, but have half circle on both sides
  40173. */ var SausageShape = /** @class */ (function () {
  40174. function SausageShape() {
  40175. this.cx = 0
  40176. this.cy = 0
  40177. this.r0 = 0
  40178. this.r = 0
  40179. this.startAngle = 0
  40180. this.endAngle = Math.PI * 2
  40181. this.clockwise = true
  40182. }
  40183. return SausageShape
  40184. })()
  40185. var SausagePath = /** @class */ (function (_super) {
  40186. __extends(SausagePath, _super)
  40187. function SausagePath(opts) {
  40188. var _this = _super.call(this, opts) || this
  40189. _this.type = 'sausage'
  40190. return _this
  40191. }
  40192. SausagePath.prototype.getDefaultShape = function () {
  40193. return new SausageShape()
  40194. }
  40195. SausagePath.prototype.buildPath = function (ctx, shape) {
  40196. var cx = shape.cx
  40197. var cy = shape.cy
  40198. var r0 = Math.max(shape.r0 || 0, 0)
  40199. var r = Math.max(shape.r, 0)
  40200. var dr = (r - r0) * 0.5
  40201. var rCenter = r0 + dr
  40202. var startAngle = shape.startAngle
  40203. var endAngle = shape.endAngle
  40204. var clockwise = shape.clockwise
  40205. var PI2 = Math.PI * 2
  40206. var lessThanCircle = clockwise
  40207. ? endAngle - startAngle < PI2
  40208. : startAngle - endAngle < PI2
  40209. if (!lessThanCircle) {
  40210. // Normalize angles
  40211. startAngle = endAngle - (clockwise ? PI2 : -PI2)
  40212. }
  40213. var unitStartX = Math.cos(startAngle)
  40214. var unitStartY = Math.sin(startAngle)
  40215. var unitEndX = Math.cos(endAngle)
  40216. var unitEndY = Math.sin(endAngle)
  40217. if (lessThanCircle) {
  40218. ctx.moveTo(unitStartX * r0 + cx, unitStartY * r0 + cy)
  40219. ctx.arc(
  40220. unitStartX * rCenter + cx,
  40221. unitStartY * rCenter + cy,
  40222. dr,
  40223. -Math.PI + startAngle,
  40224. startAngle,
  40225. !clockwise
  40226. )
  40227. } else {
  40228. ctx.moveTo(unitStartX * r + cx, unitStartY * r + cy)
  40229. }
  40230. ctx.arc(cx, cy, r, startAngle, endAngle, !clockwise)
  40231. ctx.arc(
  40232. unitEndX * rCenter + cx,
  40233. unitEndY * rCenter + cy,
  40234. dr,
  40235. endAngle - Math.PI * 2,
  40236. endAngle - Math.PI,
  40237. !clockwise
  40238. )
  40239. if (r0 !== 0) {
  40240. ctx.arc(cx, cy, r0, endAngle, startAngle, clockwise)
  40241. } // ctx.closePath();
  40242. }
  40243. return SausagePath
  40244. })(Path$1)
  40245. var Sausage = SausagePath
  40246. function createSectorCalculateTextPosition(positionMapping, opts) {
  40247. opts = opts || {}
  40248. var isRoundCap = opts.isRoundCap
  40249. return function (out, opts, boundingRect) {
  40250. var textPosition = opts.position
  40251. if (!textPosition || textPosition instanceof Array) {
  40252. return _calculateTextPosition(out, opts, boundingRect)
  40253. }
  40254. var mappedSectorPosition = positionMapping(textPosition)
  40255. var distance = opts.distance != null ? opts.distance : 5
  40256. var sector = this.shape
  40257. var cx = sector.cx
  40258. var cy = sector.cy
  40259. var r = sector.r
  40260. var r0 = sector.r0
  40261. var middleR = (r + r0) / 2
  40262. var startAngle = sector.startAngle
  40263. var endAngle = sector.endAngle
  40264. var middleAngle = (startAngle + endAngle) / 2
  40265. var extraDist = isRoundCap ? Math.abs(r - r0) / 2 : 0
  40266. var mathCos = Math.cos
  40267. var mathSin = Math.sin // base position: top-left
  40268. var x = cx + r * mathCos(startAngle)
  40269. var y = cy + r * mathSin(startAngle)
  40270. var textAlign = 'left'
  40271. var textVerticalAlign = 'top'
  40272. switch (mappedSectorPosition) {
  40273. case 'startArc':
  40274. x = cx + (r0 - distance) * mathCos(middleAngle)
  40275. y = cy + (r0 - distance) * mathSin(middleAngle)
  40276. textAlign = 'center'
  40277. textVerticalAlign = 'top'
  40278. break
  40279. case 'insideStartArc':
  40280. x = cx + (r0 + distance) * mathCos(middleAngle)
  40281. y = cy + (r0 + distance) * mathSin(middleAngle)
  40282. textAlign = 'center'
  40283. textVerticalAlign = 'bottom'
  40284. break
  40285. case 'startAngle':
  40286. x =
  40287. cx +
  40288. middleR * mathCos(startAngle) +
  40289. adjustAngleDistanceX(
  40290. startAngle,
  40291. distance + extraDist,
  40292. false
  40293. )
  40294. y =
  40295. cy +
  40296. middleR * mathSin(startAngle) +
  40297. adjustAngleDistanceY(
  40298. startAngle,
  40299. distance + extraDist,
  40300. false
  40301. )
  40302. textAlign = 'right'
  40303. textVerticalAlign = 'middle'
  40304. break
  40305. case 'insideStartAngle':
  40306. x =
  40307. cx +
  40308. middleR * mathCos(startAngle) +
  40309. adjustAngleDistanceX(
  40310. startAngle,
  40311. -distance + extraDist,
  40312. false
  40313. )
  40314. y =
  40315. cy +
  40316. middleR * mathSin(startAngle) +
  40317. adjustAngleDistanceY(
  40318. startAngle,
  40319. -distance + extraDist,
  40320. false
  40321. )
  40322. textAlign = 'left'
  40323. textVerticalAlign = 'middle'
  40324. break
  40325. case 'middle':
  40326. x = cx + middleR * mathCos(middleAngle)
  40327. y = cy + middleR * mathSin(middleAngle)
  40328. textAlign = 'center'
  40329. textVerticalAlign = 'middle'
  40330. break
  40331. case 'endArc':
  40332. x = cx + (r + distance) * mathCos(middleAngle)
  40333. y = cy + (r + distance) * mathSin(middleAngle)
  40334. textAlign = 'center'
  40335. textVerticalAlign = 'bottom'
  40336. break
  40337. case 'insideEndArc':
  40338. x = cx + (r - distance) * mathCos(middleAngle)
  40339. y = cy + (r - distance) * mathSin(middleAngle)
  40340. textAlign = 'center'
  40341. textVerticalAlign = 'top'
  40342. break
  40343. case 'endAngle':
  40344. x =
  40345. cx +
  40346. middleR * mathCos(endAngle) +
  40347. adjustAngleDistanceX(endAngle, distance + extraDist, true)
  40348. y =
  40349. cy +
  40350. middleR * mathSin(endAngle) +
  40351. adjustAngleDistanceY(endAngle, distance + extraDist, true)
  40352. textAlign = 'left'
  40353. textVerticalAlign = 'middle'
  40354. break
  40355. case 'insideEndAngle':
  40356. x =
  40357. cx +
  40358. middleR * mathCos(endAngle) +
  40359. adjustAngleDistanceX(endAngle, -distance + extraDist, true)
  40360. y =
  40361. cy +
  40362. middleR * mathSin(endAngle) +
  40363. adjustAngleDistanceY(endAngle, -distance + extraDist, true)
  40364. textAlign = 'right'
  40365. textVerticalAlign = 'middle'
  40366. break
  40367. default:
  40368. return _calculateTextPosition(out, opts, boundingRect)
  40369. }
  40370. out = out || {}
  40371. out.x = x
  40372. out.y = y
  40373. out.align = textAlign
  40374. out.verticalAlign = textVerticalAlign
  40375. return out
  40376. }
  40377. }
  40378. function setSectorTextRotation(
  40379. sector,
  40380. textPosition,
  40381. positionMapping,
  40382. rotateType
  40383. ) {
  40384. if (isNumber(rotateType)) {
  40385. // user-set rotation
  40386. sector.setTextConfig({ rotation: rotateType })
  40387. return
  40388. } else if (isArray(textPosition)) {
  40389. // user-set position, use 0 as auto rotation
  40390. sector.setTextConfig({ rotation: 0 })
  40391. return
  40392. }
  40393. var shape = sector.shape
  40394. var startAngle = shape.clockwise ? shape.startAngle : shape.endAngle
  40395. var endAngle = shape.clockwise ? shape.endAngle : shape.startAngle
  40396. var middleAngle = (startAngle + endAngle) / 2
  40397. var anchorAngle
  40398. var mappedSectorPosition = positionMapping(textPosition)
  40399. switch (mappedSectorPosition) {
  40400. case 'startArc':
  40401. case 'insideStartArc':
  40402. case 'middle':
  40403. case 'insideEndArc':
  40404. case 'endArc':
  40405. anchorAngle = middleAngle
  40406. break
  40407. case 'startAngle':
  40408. case 'insideStartAngle':
  40409. anchorAngle = startAngle
  40410. break
  40411. case 'endAngle':
  40412. case 'insideEndAngle':
  40413. anchorAngle = endAngle
  40414. break
  40415. default:
  40416. sector.setTextConfig({ rotation: 0 })
  40417. return
  40418. }
  40419. var rotate = Math.PI * 1.5 - anchorAngle
  40420. /**
  40421. * TODO: labels with rotate > Math.PI / 2 should be rotate another
  40422. * half round flipped to increase readability. However, only middle
  40423. * position supports this for now, because in other positions, the
  40424. * anchor point is not at the center of the text, so the positions
  40425. * after rotating is not as expected.
  40426. */ if (
  40427. mappedSectorPosition === 'middle' &&
  40428. rotate > Math.PI / 2 &&
  40429. rotate < Math.PI * 1.5
  40430. ) {
  40431. rotate -= Math.PI
  40432. }
  40433. sector.setTextConfig({ rotation: rotate })
  40434. }
  40435. function adjustAngleDistanceX(angle, distance, isEnd) {
  40436. return distance * Math.sin(angle) * (isEnd ? -1 : 1)
  40437. }
  40438. function adjustAngleDistanceY(angle, distance, isEnd) {
  40439. return distance * Math.cos(angle) * (isEnd ? 1 : -1)
  40440. }
  40441. var mathMax$1 = Math.max
  40442. var mathMin$1 = Math.min
  40443. function getClipArea(coord, data) {
  40444. var coordSysClipArea = coord.getArea && coord.getArea()
  40445. if (isCoordinateSystemType(coord, 'cartesian2d')) {
  40446. var baseAxis = coord.getBaseAxis() // When boundaryGap is false or using time axis. bar may exceed the grid.
  40447. // We should not clip this part.
  40448. // See test/bar2.html
  40449. if (baseAxis.type !== 'category' || !baseAxis.onBand) {
  40450. var expandWidth = data.getLayout('bandWidth')
  40451. if (baseAxis.isHorizontal()) {
  40452. coordSysClipArea.x -= expandWidth
  40453. coordSysClipArea.width += expandWidth * 2
  40454. } else {
  40455. coordSysClipArea.y -= expandWidth
  40456. coordSysClipArea.height += expandWidth * 2
  40457. }
  40458. }
  40459. }
  40460. return coordSysClipArea
  40461. }
  40462. var BarView = /** @class */ (function (_super) {
  40463. __extends(BarView, _super)
  40464. function BarView() {
  40465. var _this = _super.call(this) || this
  40466. _this.type = BarView.type
  40467. _this._isFirstFrame = true
  40468. return _this
  40469. }
  40470. BarView.prototype.render = function (
  40471. seriesModel,
  40472. ecModel,
  40473. api,
  40474. payload
  40475. ) {
  40476. this._model = seriesModel
  40477. this._removeOnRenderedListener(api)
  40478. this._updateDrawMode(seriesModel)
  40479. var coordinateSystemType = seriesModel.get('coordinateSystem')
  40480. if (
  40481. coordinateSystemType === 'cartesian2d' ||
  40482. coordinateSystemType === 'polar'
  40483. ) {
  40484. // Clear previously rendered progressive elements.
  40485. this._progressiveEls = null
  40486. this._isLargeDraw
  40487. ? this._renderLarge(seriesModel, ecModel, api)
  40488. : this._renderNormal(seriesModel, ecModel, api, payload)
  40489. }
  40490. }
  40491. BarView.prototype.incrementalPrepareRender = function (
  40492. seriesModel
  40493. ) {
  40494. this._clear()
  40495. this._updateDrawMode(seriesModel) // incremental also need to clip, otherwise might be overlow.
  40496. // But must not set clip in each frame, otherwise all of the children will be marked redraw.
  40497. this._updateLargeClip(seriesModel)
  40498. }
  40499. BarView.prototype.incrementalRender = function (
  40500. params,
  40501. seriesModel
  40502. ) {
  40503. // Reset
  40504. this._progressiveEls = [] // Do not support progressive in normal mode.
  40505. this._incrementalRenderLarge(params, seriesModel)
  40506. }
  40507. BarView.prototype.eachRendered = function (cb) {
  40508. traverseElements(this._progressiveEls || this.group, cb)
  40509. }
  40510. BarView.prototype._updateDrawMode = function (seriesModel) {
  40511. var isLargeDraw = seriesModel.pipelineContext.large
  40512. if (
  40513. this._isLargeDraw == null ||
  40514. isLargeDraw !== this._isLargeDraw
  40515. ) {
  40516. this._isLargeDraw = isLargeDraw
  40517. this._clear()
  40518. }
  40519. }
  40520. BarView.prototype._renderNormal = function (
  40521. seriesModel,
  40522. ecModel,
  40523. api,
  40524. payload
  40525. ) {
  40526. var group = this.group
  40527. var data = seriesModel.getData()
  40528. var oldData = this._data
  40529. var coord = seriesModel.coordinateSystem
  40530. var baseAxis = coord.getBaseAxis()
  40531. var isHorizontalOrRadial
  40532. if (coord.type === 'cartesian2d') {
  40533. isHorizontalOrRadial = baseAxis.isHorizontal()
  40534. } else if (coord.type === 'polar') {
  40535. isHorizontalOrRadial = baseAxis.dim === 'angle'
  40536. }
  40537. var animationModel = seriesModel.isAnimationEnabled()
  40538. ? seriesModel
  40539. : null
  40540. var realtimeSortCfg = shouldRealtimeSort(seriesModel, coord)
  40541. if (realtimeSortCfg) {
  40542. this._enableRealtimeSort(realtimeSortCfg, data, api)
  40543. }
  40544. var needsClip = seriesModel.get('clip', true) || realtimeSortCfg
  40545. var coordSysClipArea = getClipArea(coord, data) // If there is clipPath created in large mode. Remove it.
  40546. group.removeClipPath() // We don't use clipPath in normal mode because we needs a perfect animation
  40547. // And don't want the label are clipped.
  40548. var roundCap = seriesModel.get('roundCap', true)
  40549. var drawBackground = seriesModel.get('showBackground', true)
  40550. var backgroundModel = seriesModel.getModel('backgroundStyle')
  40551. var barBorderRadius = backgroundModel.get('borderRadius') || 0
  40552. var bgEls = []
  40553. var oldBgEls = this._backgroundEls
  40554. var isInitSort = payload && payload.isInitSort
  40555. var isChangeOrder = payload && payload.type === 'changeAxisOrder'
  40556. function createBackground(dataIndex) {
  40557. var bgLayout = getLayout[coord.type](data, dataIndex)
  40558. var bgEl = createBackgroundEl(
  40559. coord,
  40560. isHorizontalOrRadial,
  40561. bgLayout
  40562. )
  40563. bgEl.useStyle(backgroundModel.getItemStyle()) // Only cartesian2d support borderRadius.
  40564. if (coord.type === 'cartesian2d') {
  40565. bgEl.setShape('r', barBorderRadius)
  40566. }
  40567. bgEls[dataIndex] = bgEl
  40568. return bgEl
  40569. }
  40570. data
  40571. .diff(oldData)
  40572. .add(function (dataIndex) {
  40573. var itemModel = data.getItemModel(dataIndex)
  40574. var layout = getLayout[coord.type](data, dataIndex, itemModel)
  40575. if (drawBackground) {
  40576. createBackground(dataIndex)
  40577. } // If dataZoom in filteMode: 'empty', the baseValue can be set as NaN in "axisProxy".
  40578. if (
  40579. !data.hasValue(dataIndex) ||
  40580. !isValidLayout[coord.type](layout)
  40581. ) {
  40582. return
  40583. }
  40584. var isClipped = false
  40585. if (needsClip) {
  40586. // Clip will modify the layout params.
  40587. // And return a boolean to determine if the shape are fully clipped.
  40588. isClipped = clip[coord.type](coordSysClipArea, layout)
  40589. }
  40590. var el = elementCreator[coord.type](
  40591. seriesModel,
  40592. data,
  40593. dataIndex,
  40594. layout,
  40595. isHorizontalOrRadial,
  40596. animationModel,
  40597. baseAxis.model,
  40598. false,
  40599. roundCap
  40600. )
  40601. if (realtimeSortCfg) {
  40602. /**
  40603. * Force label animation because even if the element is
  40604. * ignored because it's clipped, it may not be clipped after
  40605. * changing order. Then, if not using forceLabelAnimation,
  40606. * the label animation was never started, in which case,
  40607. * the label will be the final value and doesn't have label
  40608. * animation.
  40609. */ el.forceLabelAnimation = true
  40610. }
  40611. updateStyle(
  40612. el,
  40613. data,
  40614. dataIndex,
  40615. itemModel,
  40616. layout,
  40617. seriesModel,
  40618. isHorizontalOrRadial,
  40619. coord.type === 'polar'
  40620. )
  40621. if (isInitSort) {
  40622. el.attr({ shape: layout })
  40623. } else if (realtimeSortCfg) {
  40624. updateRealtimeAnimation(
  40625. realtimeSortCfg,
  40626. animationModel,
  40627. el,
  40628. layout,
  40629. dataIndex,
  40630. isHorizontalOrRadial,
  40631. false,
  40632. false
  40633. )
  40634. } else {
  40635. initProps(el, { shape: layout }, seriesModel, dataIndex)
  40636. }
  40637. data.setItemGraphicEl(dataIndex, el)
  40638. group.add(el)
  40639. el.ignore = isClipped
  40640. })
  40641. .update(function (newIndex, oldIndex) {
  40642. var itemModel = data.getItemModel(newIndex)
  40643. var layout = getLayout[coord.type](data, newIndex, itemModel)
  40644. if (drawBackground) {
  40645. var bgEl = void 0
  40646. if (oldBgEls.length === 0) {
  40647. bgEl = createBackground(oldIndex)
  40648. } else {
  40649. bgEl = oldBgEls[oldIndex]
  40650. bgEl.useStyle(backgroundModel.getItemStyle()) // Only cartesian2d support borderRadius.
  40651. if (coord.type === 'cartesian2d') {
  40652. bgEl.setShape('r', barBorderRadius)
  40653. }
  40654. bgEls[newIndex] = bgEl
  40655. }
  40656. var bgLayout = getLayout[coord.type](data, newIndex)
  40657. var shape = createBackgroundShape(
  40658. isHorizontalOrRadial,
  40659. bgLayout,
  40660. coord
  40661. )
  40662. updateProps$1(
  40663. bgEl,
  40664. { shape: shape },
  40665. animationModel,
  40666. newIndex
  40667. )
  40668. }
  40669. var el = oldData.getItemGraphicEl(oldIndex)
  40670. if (
  40671. !data.hasValue(newIndex) ||
  40672. !isValidLayout[coord.type](layout)
  40673. ) {
  40674. group.remove(el)
  40675. return
  40676. }
  40677. var isClipped = false
  40678. if (needsClip) {
  40679. isClipped = clip[coord.type](coordSysClipArea, layout)
  40680. if (isClipped) {
  40681. group.remove(el)
  40682. }
  40683. }
  40684. if (!el) {
  40685. el = elementCreator[coord.type](
  40686. seriesModel,
  40687. data,
  40688. newIndex,
  40689. layout,
  40690. isHorizontalOrRadial,
  40691. animationModel,
  40692. baseAxis.model,
  40693. !!el,
  40694. roundCap
  40695. )
  40696. } else {
  40697. saveOldStyle(el)
  40698. }
  40699. if (realtimeSortCfg) {
  40700. el.forceLabelAnimation = true
  40701. }
  40702. if (isChangeOrder) {
  40703. var textEl = el.getTextContent()
  40704. if (textEl) {
  40705. var labelInnerStore = labelInner(textEl)
  40706. if (labelInnerStore.prevValue != null) {
  40707. /**
  40708. * Set preValue to be value so that no new label
  40709. * should be started, otherwise, it will take a full
  40710. * `animationDurationUpdate` time to finish the
  40711. * animation, which is not expected.
  40712. */ labelInnerStore.prevValue = labelInnerStore.value
  40713. }
  40714. }
  40715. } // Not change anything if only order changed.
  40716. // Especially not change label.
  40717. else {
  40718. updateStyle(
  40719. el,
  40720. data,
  40721. newIndex,
  40722. itemModel,
  40723. layout,
  40724. seriesModel,
  40725. isHorizontalOrRadial,
  40726. coord.type === 'polar'
  40727. )
  40728. }
  40729. if (isInitSort) {
  40730. el.attr({ shape: layout })
  40731. } else if (realtimeSortCfg) {
  40732. updateRealtimeAnimation(
  40733. realtimeSortCfg,
  40734. animationModel,
  40735. el,
  40736. layout,
  40737. newIndex,
  40738. isHorizontalOrRadial,
  40739. true,
  40740. isChangeOrder
  40741. )
  40742. } else {
  40743. updateProps$1(
  40744. el,
  40745. { shape: layout },
  40746. seriesModel,
  40747. newIndex,
  40748. null
  40749. )
  40750. }
  40751. data.setItemGraphicEl(newIndex, el)
  40752. el.ignore = isClipped
  40753. group.add(el)
  40754. })
  40755. .remove(function (dataIndex) {
  40756. var el = oldData.getItemGraphicEl(dataIndex)
  40757. el && removeElementWithFadeOut(el, seriesModel, dataIndex)
  40758. })
  40759. .execute()
  40760. var bgGroup =
  40761. this._backgroundGroup || (this._backgroundGroup = new Group$3())
  40762. bgGroup.removeAll()
  40763. for (var i = 0; i < bgEls.length; ++i) {
  40764. bgGroup.add(bgEls[i])
  40765. }
  40766. group.add(bgGroup)
  40767. this._backgroundEls = bgEls
  40768. this._data = data
  40769. }
  40770. BarView.prototype._renderLarge = function (
  40771. seriesModel,
  40772. ecModel,
  40773. api
  40774. ) {
  40775. this._clear()
  40776. createLarge(seriesModel, this.group)
  40777. this._updateLargeClip(seriesModel)
  40778. }
  40779. BarView.prototype._incrementalRenderLarge = function (
  40780. params,
  40781. seriesModel
  40782. ) {
  40783. this._removeBackground()
  40784. createLarge(seriesModel, this.group, this._progressiveEls, true)
  40785. }
  40786. BarView.prototype._updateLargeClip = function (seriesModel) {
  40787. // Use clipPath in large mode.
  40788. var clipPath =
  40789. seriesModel.get('clip', true) &&
  40790. createClipPath(seriesModel.coordinateSystem, false, seriesModel)
  40791. var group = this.group
  40792. if (clipPath) {
  40793. group.setClipPath(clipPath)
  40794. } else {
  40795. group.removeClipPath()
  40796. }
  40797. }
  40798. BarView.prototype._enableRealtimeSort = function (
  40799. realtimeSortCfg,
  40800. data,
  40801. api
  40802. ) {
  40803. var _this = this // If no data in the first frame, wait for data to initSort
  40804. if (!data.count()) {
  40805. return
  40806. }
  40807. var baseAxis = realtimeSortCfg.baseAxis
  40808. if (this._isFirstFrame) {
  40809. this._dispatchInitSort(data, realtimeSortCfg, api)
  40810. this._isFirstFrame = false
  40811. } else {
  40812. var orderMapping_1 = function orderMapping_1(idx) {
  40813. var el = data.getItemGraphicEl(idx)
  40814. var shape = el && el.shape
  40815. return (
  40816. (shape && // The result should be consistent with the initial sort by data value.
  40817. // Do not support the case that both positive and negative exist.
  40818. Math.abs(
  40819. baseAxis.isHorizontal() ? shape.height : shape.width
  40820. )) || // If data is NaN, shape.xxx may be NaN, so use || 0 here in case
  40821. 0
  40822. )
  40823. }
  40824. this._onRendered = function () {
  40825. _this._updateSortWithinSameData(
  40826. data,
  40827. orderMapping_1,
  40828. baseAxis,
  40829. api
  40830. )
  40831. }
  40832. api.getZr().on('rendered', this._onRendered)
  40833. }
  40834. }
  40835. BarView.prototype._dataSort = function (
  40836. data,
  40837. baseAxis,
  40838. orderMapping
  40839. ) {
  40840. var info = []
  40841. data.each(
  40842. data.mapDimension(baseAxis.dim),
  40843. function (ordinalNumber, dataIdx) {
  40844. var mappedValue = orderMapping(dataIdx)
  40845. mappedValue = mappedValue == null ? NaN : mappedValue
  40846. info.push({
  40847. dataIndex: dataIdx,
  40848. mappedValue: mappedValue,
  40849. ordinalNumber: ordinalNumber
  40850. })
  40851. }
  40852. )
  40853. info.sort(function (a, b) {
  40854. // If NaN, it will be treated as min val.
  40855. return b.mappedValue - a.mappedValue
  40856. })
  40857. return {
  40858. ordinalNumbers: map$1(info, function (item) {
  40859. return item.ordinalNumber
  40860. })
  40861. }
  40862. }
  40863. BarView.prototype._isOrderChangedWithinSameData = function (
  40864. data,
  40865. orderMapping,
  40866. baseAxis
  40867. ) {
  40868. var scale = baseAxis.scale
  40869. var ordinalDataDim = data.mapDimension(baseAxis.dim)
  40870. var lastValue = Number.MAX_VALUE
  40871. for (
  40872. var tickNum = 0, len = scale.getOrdinalMeta().categories.length;
  40873. tickNum < len;
  40874. ++tickNum
  40875. ) {
  40876. var rawIdx = data.rawIndexOf(
  40877. ordinalDataDim,
  40878. scale.getRawOrdinalNumber(tickNum)
  40879. )
  40880. var value =
  40881. rawIdx < 0 // If some tick have no bar, the tick will be treated as min.
  40882. ? Number.MIN_VALUE // PENDING: if dataZoom on baseAxis exits, is it a performance issue?
  40883. : orderMapping(data.indexOfRawIndex(rawIdx))
  40884. if (value > lastValue) {
  40885. return true
  40886. }
  40887. lastValue = value
  40888. }
  40889. return false
  40890. }
  40891. /*
  40892. * Consider the case when A and B changed order, whose representing
  40893. * bars are both out of sight, we don't wish to trigger reorder action
  40894. * as long as the order in the view doesn't change.
  40895. */ BarView.prototype._isOrderDifferentInView = function (
  40896. orderInfo,
  40897. baseAxis
  40898. ) {
  40899. var scale = baseAxis.scale
  40900. var extent = scale.getExtent()
  40901. var tickNum = Math.max(0, extent[0])
  40902. var tickMax = Math.min(
  40903. extent[1],
  40904. scale.getOrdinalMeta().categories.length - 1
  40905. )
  40906. for (; tickNum <= tickMax; ++tickNum) {
  40907. if (
  40908. orderInfo.ordinalNumbers[tickNum] !==
  40909. scale.getRawOrdinalNumber(tickNum)
  40910. ) {
  40911. return true
  40912. }
  40913. }
  40914. }
  40915. BarView.prototype._updateSortWithinSameData = function (
  40916. data,
  40917. orderMapping,
  40918. baseAxis,
  40919. api
  40920. ) {
  40921. if (
  40922. !this._isOrderChangedWithinSameData(
  40923. data,
  40924. orderMapping,
  40925. baseAxis
  40926. )
  40927. ) {
  40928. return
  40929. }
  40930. var sortInfo = this._dataSort(data, baseAxis, orderMapping)
  40931. if (this._isOrderDifferentInView(sortInfo, baseAxis)) {
  40932. this._removeOnRenderedListener(api)
  40933. api.dispatchAction({
  40934. type: 'changeAxisOrder',
  40935. componentType: baseAxis.dim + 'Axis',
  40936. axisId: baseAxis.index,
  40937. sortInfo: sortInfo
  40938. })
  40939. }
  40940. }
  40941. BarView.prototype._dispatchInitSort = function (
  40942. data,
  40943. realtimeSortCfg,
  40944. api
  40945. ) {
  40946. var baseAxis = realtimeSortCfg.baseAxis
  40947. var sortResult = this._dataSort(
  40948. data,
  40949. baseAxis,
  40950. function (dataIdx) {
  40951. return data.get(
  40952. data.mapDimension(realtimeSortCfg.otherAxis.dim),
  40953. dataIdx
  40954. )
  40955. }
  40956. )
  40957. api.dispatchAction({
  40958. type: 'changeAxisOrder',
  40959. componentType: baseAxis.dim + 'Axis',
  40960. isInitSort: true,
  40961. axisId: baseAxis.index,
  40962. sortInfo: sortResult
  40963. })
  40964. }
  40965. BarView.prototype.remove = function (ecModel, api) {
  40966. this._clear(this._model)
  40967. this._removeOnRenderedListener(api)
  40968. }
  40969. BarView.prototype.dispose = function (ecModel, api) {
  40970. this._removeOnRenderedListener(api)
  40971. }
  40972. BarView.prototype._removeOnRenderedListener = function (api) {
  40973. if (this._onRendered) {
  40974. api.getZr().off('rendered', this._onRendered)
  40975. this._onRendered = null
  40976. }
  40977. }
  40978. BarView.prototype._clear = function (model) {
  40979. var group = this.group
  40980. var data = this._data
  40981. if (
  40982. model &&
  40983. model.isAnimationEnabled() &&
  40984. data &&
  40985. !this._isLargeDraw
  40986. ) {
  40987. this._removeBackground()
  40988. this._backgroundEls = []
  40989. data.eachItemGraphicEl(function (el) {
  40990. removeElementWithFadeOut(el, model, getECData(el).dataIndex)
  40991. })
  40992. } else {
  40993. group.removeAll()
  40994. }
  40995. this._data = null
  40996. this._isFirstFrame = true
  40997. }
  40998. BarView.prototype._removeBackground = function () {
  40999. this.group.remove(this._backgroundGroup)
  41000. this._backgroundGroup = null
  41001. }
  41002. BarView.type = 'bar'
  41003. return BarView
  41004. })(ChartView$1)
  41005. var clip = {
  41006. cartesian2d: function cartesian2d(coordSysBoundingRect, layout) {
  41007. var signWidth = layout.width < 0 ? -1 : 1
  41008. var signHeight = layout.height < 0 ? -1 : 1 // Needs positive width and height
  41009. if (signWidth < 0) {
  41010. layout.x += layout.width
  41011. layout.width = -layout.width
  41012. }
  41013. if (signHeight < 0) {
  41014. layout.y += layout.height
  41015. layout.height = -layout.height
  41016. }
  41017. var coordSysX2 =
  41018. coordSysBoundingRect.x + coordSysBoundingRect.width
  41019. var coordSysY2 =
  41020. coordSysBoundingRect.y + coordSysBoundingRect.height
  41021. var x = mathMax$1(layout.x, coordSysBoundingRect.x)
  41022. var x2 = mathMin$1(layout.x + layout.width, coordSysX2)
  41023. var y = mathMax$1(layout.y, coordSysBoundingRect.y)
  41024. var y2 = mathMin$1(layout.y + layout.height, coordSysY2)
  41025. var xClipped = x2 < x
  41026. var yClipped = y2 < y // When xClipped or yClipped, the element will be marked as `ignore`.
  41027. // But we should also place the element at the edge of the coord sys bounding rect.
  41028. // Beause if data changed and the bar show again, its transition animaiton
  41029. // will begin at this place.
  41030. layout.x = xClipped && x > coordSysX2 ? x2 : x
  41031. layout.y = yClipped && y > coordSysY2 ? y2 : y
  41032. layout.width = xClipped ? 0 : x2 - x
  41033. layout.height = yClipped ? 0 : y2 - y // Reverse back
  41034. if (signWidth < 0) {
  41035. layout.x += layout.width
  41036. layout.width = -layout.width
  41037. }
  41038. if (signHeight < 0) {
  41039. layout.y += layout.height
  41040. layout.height = -layout.height
  41041. }
  41042. return xClipped || yClipped
  41043. },
  41044. polar: function polar(coordSysClipArea, layout) {
  41045. var signR = layout.r0 <= layout.r ? 1 : -1 // Make sure r is larger than r0
  41046. if (signR < 0) {
  41047. var tmp = layout.r
  41048. layout.r = layout.r0
  41049. layout.r0 = tmp
  41050. }
  41051. var r = mathMin$1(layout.r, coordSysClipArea.r)
  41052. var r0 = mathMax$1(layout.r0, coordSysClipArea.r0)
  41053. layout.r = r
  41054. layout.r0 = r0
  41055. var clipped = r - r0 < 0 // Reverse back
  41056. if (signR < 0) {
  41057. var tmp = layout.r
  41058. layout.r = layout.r0
  41059. layout.r0 = tmp
  41060. }
  41061. return clipped
  41062. }
  41063. }
  41064. var elementCreator = {
  41065. cartesian2d: function cartesian2d(
  41066. seriesModel,
  41067. data,
  41068. newIndex,
  41069. layout,
  41070. isHorizontal,
  41071. animationModel,
  41072. axisModel,
  41073. isUpdate,
  41074. roundCap
  41075. ) {
  41076. var rect = new Rect$2({ shape: extend({}, layout), z2: 1 })
  41077. rect.__dataIndex = newIndex
  41078. rect.name = 'item'
  41079. if (animationModel) {
  41080. var rectShape = rect.shape
  41081. var animateProperty = isHorizontal ? 'height' : 'width'
  41082. rectShape[animateProperty] = 0
  41083. }
  41084. return rect
  41085. },
  41086. polar: function polar(
  41087. seriesModel,
  41088. data,
  41089. newIndex,
  41090. layout,
  41091. isRadial,
  41092. animationModel,
  41093. axisModel,
  41094. isUpdate,
  41095. roundCap
  41096. ) {
  41097. var ShapeClass = !isRadial && roundCap ? Sausage : Sector$1
  41098. var sector = new ShapeClass({ shape: layout, z2: 1 })
  41099. sector.name = 'item'
  41100. var positionMap = createPolarPositionMapping(isRadial)
  41101. sector.calculateTextPosition = createSectorCalculateTextPosition(
  41102. positionMap,
  41103. { isRoundCap: ShapeClass === Sausage }
  41104. ) // Animation
  41105. if (animationModel) {
  41106. var sectorShape = sector.shape
  41107. var animateProperty = isRadial ? 'r' : 'endAngle'
  41108. var animateTarget = {}
  41109. sectorShape[animateProperty] = isRadial ? 0 : layout.startAngle
  41110. animateTarget[animateProperty] = layout[animateProperty]
  41111. ;(isUpdate ? updateProps$1 : initProps)(
  41112. sector,
  41113. {
  41114. shape: animateTarget // __value: typeof dataValue === 'string' ? parseInt(dataValue, 10) : dataValue
  41115. },
  41116. animationModel
  41117. )
  41118. }
  41119. return sector
  41120. }
  41121. }
  41122. function shouldRealtimeSort(seriesModel, coordSys) {
  41123. var realtimeSortOption = seriesModel.get('realtimeSort', true)
  41124. var baseAxis = coordSys.getBaseAxis()
  41125. if (
  41126. realtimeSortOption &&
  41127. baseAxis.type === 'category' &&
  41128. coordSys.type === 'cartesian2d'
  41129. ) {
  41130. return {
  41131. baseAxis: baseAxis,
  41132. otherAxis: coordSys.getOtherAxis(baseAxis)
  41133. }
  41134. }
  41135. }
  41136. function updateRealtimeAnimation(
  41137. realtimeSortCfg,
  41138. seriesAnimationModel,
  41139. el,
  41140. layout,
  41141. newIndex,
  41142. isHorizontal,
  41143. isUpdate,
  41144. isChangeOrder
  41145. ) {
  41146. var seriesTarget
  41147. var axisTarget
  41148. if (isHorizontal) {
  41149. axisTarget = { x: layout.x, width: layout.width }
  41150. seriesTarget = { y: layout.y, height: layout.height }
  41151. } else {
  41152. axisTarget = { y: layout.y, height: layout.height }
  41153. seriesTarget = { x: layout.x, width: layout.width }
  41154. }
  41155. if (!isChangeOrder) {
  41156. // Keep the original growth animation if only axis order changed.
  41157. // Not start a new animation.
  41158. ;(isUpdate ? updateProps$1 : initProps)(
  41159. el,
  41160. { shape: seriesTarget },
  41161. seriesAnimationModel,
  41162. newIndex,
  41163. null
  41164. )
  41165. }
  41166. var axisAnimationModel = seriesAnimationModel
  41167. ? realtimeSortCfg.baseAxis.model
  41168. : null
  41169. ;(isUpdate ? updateProps$1 : initProps)(
  41170. el,
  41171. { shape: axisTarget },
  41172. axisAnimationModel,
  41173. newIndex
  41174. )
  41175. }
  41176. function checkPropertiesNotValid(obj, props) {
  41177. for (var i = 0; i < props.length; i++) {
  41178. if (!isFinite(obj[props[i]])) {
  41179. return true
  41180. }
  41181. }
  41182. return false
  41183. }
  41184. var rectPropties = ['x', 'y', 'width', 'height']
  41185. var polarPropties = ['cx', 'cy', 'r', 'startAngle', 'endAngle']
  41186. var isValidLayout = {
  41187. cartesian2d: function cartesian2d(layout) {
  41188. return !checkPropertiesNotValid(layout, rectPropties)
  41189. },
  41190. polar: function polar(layout) {
  41191. return !checkPropertiesNotValid(layout, polarPropties)
  41192. }
  41193. }
  41194. var getLayout = {
  41195. // itemModel is only used to get borderWidth, which is not needed
  41196. // when calculating bar background layout.
  41197. cartesian2d: function cartesian2d(data, dataIndex, itemModel) {
  41198. var layout = data.getItemLayout(dataIndex)
  41199. var fixedLineWidth = itemModel
  41200. ? getLineWidth(itemModel, layout)
  41201. : 0 // fix layout with lineWidth
  41202. var signX = layout.width > 0 ? 1 : -1
  41203. var signY = layout.height > 0 ? 1 : -1
  41204. return {
  41205. x: layout.x + (signX * fixedLineWidth) / 2,
  41206. y: layout.y + (signY * fixedLineWidth) / 2,
  41207. width: layout.width - signX * fixedLineWidth,
  41208. height: layout.height - signY * fixedLineWidth
  41209. }
  41210. },
  41211. polar: function polar(data, dataIndex, itemModel) {
  41212. var layout = data.getItemLayout(dataIndex)
  41213. return {
  41214. cx: layout.cx,
  41215. cy: layout.cy,
  41216. r0: layout.r0,
  41217. r: layout.r,
  41218. startAngle: layout.startAngle,
  41219. endAngle: layout.endAngle,
  41220. clockwise: layout.clockwise
  41221. }
  41222. }
  41223. }
  41224. function isZeroOnPolar(layout) {
  41225. return (
  41226. layout.startAngle != null &&
  41227. layout.endAngle != null &&
  41228. layout.startAngle === layout.endAngle
  41229. )
  41230. }
  41231. function createPolarPositionMapping(isRadial) {
  41232. return (function (isRadial) {
  41233. var arcOrAngle = isRadial ? 'Arc' : 'Angle'
  41234. return function (position) {
  41235. switch (position) {
  41236. case 'start':
  41237. case 'insideStart':
  41238. case 'end':
  41239. case 'insideEnd':
  41240. return position + arcOrAngle
  41241. default:
  41242. return position
  41243. }
  41244. }
  41245. })(isRadial)
  41246. }
  41247. function updateStyle(
  41248. el,
  41249. data,
  41250. dataIndex,
  41251. itemModel,
  41252. layout,
  41253. seriesModel,
  41254. isHorizontalOrRadial,
  41255. isPolar
  41256. ) {
  41257. var style = data.getItemVisual(dataIndex, 'style')
  41258. if (!isPolar) {
  41259. el.setShape(
  41260. 'r',
  41261. itemModel.get(['itemStyle', 'borderRadius']) || 0
  41262. )
  41263. }
  41264. el.useStyle(style)
  41265. var cursorStyle = itemModel.getShallow('cursor')
  41266. cursorStyle && el.attr('cursor', cursorStyle)
  41267. var labelPositionOutside = isPolar
  41268. ? isHorizontalOrRadial
  41269. ? layout.r >= layout.r0
  41270. ? 'endArc'
  41271. : 'startArc'
  41272. : layout.endAngle >= layout.startAngle
  41273. ? 'endAngle'
  41274. : 'startAngle'
  41275. : isHorizontalOrRadial
  41276. ? layout.height >= 0
  41277. ? 'bottom'
  41278. : 'top'
  41279. : layout.width >= 0
  41280. ? 'right'
  41281. : 'left'
  41282. var labelStatesModels = getLabelStatesModels(itemModel)
  41283. setLabelStyle(el, labelStatesModels, {
  41284. labelFetcher: seriesModel,
  41285. labelDataIndex: dataIndex,
  41286. defaultText: getDefaultLabel(seriesModel.getData(), dataIndex),
  41287. inheritColor: style.fill,
  41288. defaultOpacity: style.opacity,
  41289. defaultOutsidePosition: labelPositionOutside
  41290. })
  41291. var label = el.getTextContent()
  41292. if (isPolar && label) {
  41293. var position = itemModel.get(['label', 'position'])
  41294. el.textConfig.inside = position === 'middle' ? true : null
  41295. setSectorTextRotation(
  41296. el,
  41297. position === 'outside' ? labelPositionOutside : position,
  41298. createPolarPositionMapping(isHorizontalOrRadial),
  41299. itemModel.get(['label', 'rotate'])
  41300. )
  41301. }
  41302. setLabelValueAnimation(
  41303. label,
  41304. labelStatesModels,
  41305. seriesModel.getRawValue(dataIndex),
  41306. function (value) {
  41307. return getDefaultInterpolatedLabel(data, value)
  41308. }
  41309. )
  41310. var emphasisModel = itemModel.getModel(['emphasis'])
  41311. toggleHoverEmphasis(
  41312. el,
  41313. emphasisModel.get('focus'),
  41314. emphasisModel.get('blurScope'),
  41315. emphasisModel.get('disabled')
  41316. )
  41317. setStatesStylesFromModel(el, itemModel)
  41318. if (isZeroOnPolar(layout)) {
  41319. el.style.fill = 'none'
  41320. el.style.stroke = 'none'
  41321. each$7(el.states, function (state) {
  41322. if (state.style) {
  41323. state.style.fill = state.style.stroke = 'none'
  41324. }
  41325. })
  41326. }
  41327. } // In case width or height are too small.
  41328. function getLineWidth(itemModel, rawLayout) {
  41329. // Has no border.
  41330. var borderColor = itemModel.get(['itemStyle', 'borderColor'])
  41331. if (!borderColor || borderColor === 'none') {
  41332. return 0
  41333. }
  41334. var lineWidth = itemModel.get(['itemStyle', 'borderWidth']) || 0 // width or height may be NaN for empty data
  41335. var width = isNaN(rawLayout.width)
  41336. ? Number.MAX_VALUE
  41337. : Math.abs(rawLayout.width)
  41338. var height = isNaN(rawLayout.height)
  41339. ? Number.MAX_VALUE
  41340. : Math.abs(rawLayout.height)
  41341. return Math.min(lineWidth, width, height)
  41342. }
  41343. var LagePathShape = /** @class */ (function () {
  41344. function LagePathShape() {}
  41345. return LagePathShape
  41346. })()
  41347. var LargePath = /** @class */ (function (_super) {
  41348. __extends(LargePath, _super)
  41349. function LargePath(opts) {
  41350. var _this = _super.call(this, opts) || this
  41351. _this.type = 'largeBar'
  41352. return _this
  41353. }
  41354. LargePath.prototype.getDefaultShape = function () {
  41355. return new LagePathShape()
  41356. }
  41357. LargePath.prototype.buildPath = function (ctx, shape) {
  41358. // Drawing lines is more efficient than drawing
  41359. // a whole line or drawing rects.
  41360. var points = shape.points
  41361. var baseDimIdx = this.baseDimIdx
  41362. var valueDimIdx = 1 - this.baseDimIdx
  41363. var startPoint = []
  41364. var size = []
  41365. var barWidth = this.barWidth
  41366. for (var i = 0; i < points.length; i += 3) {
  41367. size[baseDimIdx] = barWidth
  41368. size[valueDimIdx] = points[i + 2]
  41369. startPoint[baseDimIdx] = points[i + baseDimIdx]
  41370. startPoint[valueDimIdx] = points[i + valueDimIdx]
  41371. ctx.rect(startPoint[0], startPoint[1], size[0], size[1])
  41372. }
  41373. }
  41374. return LargePath
  41375. })(Path$1)
  41376. function createLarge(
  41377. seriesModel,
  41378. group,
  41379. progressiveEls,
  41380. incremental
  41381. ) {
  41382. // TODO support polar
  41383. var data = seriesModel.getData()
  41384. var baseDimIdx = data.getLayout('valueAxisHorizontal') ? 1 : 0
  41385. var largeDataIndices = data.getLayout('largeDataIndices')
  41386. var barWidth = data.getLayout('size')
  41387. var backgroundModel = seriesModel.getModel('backgroundStyle')
  41388. var bgPoints = data.getLayout('largeBackgroundPoints')
  41389. if (bgPoints) {
  41390. var bgEl = new LargePath({
  41391. shape: { points: bgPoints },
  41392. incremental: !!incremental,
  41393. silent: true,
  41394. z2: 0
  41395. })
  41396. bgEl.baseDimIdx = baseDimIdx
  41397. bgEl.largeDataIndices = largeDataIndices
  41398. bgEl.barWidth = barWidth
  41399. bgEl.useStyle(backgroundModel.getItemStyle())
  41400. group.add(bgEl)
  41401. progressiveEls && progressiveEls.push(bgEl)
  41402. }
  41403. var el = new LargePath({
  41404. shape: { points: data.getLayout('largePoints') },
  41405. incremental: !!incremental,
  41406. z2: 1
  41407. })
  41408. el.baseDimIdx = baseDimIdx
  41409. el.largeDataIndices = largeDataIndices
  41410. el.barWidth = barWidth
  41411. group.add(el)
  41412. el.useStyle(data.getVisual('style')) // Enable tooltip and user mouse/touch event handlers.
  41413. getECData(el).seriesIndex = seriesModel.seriesIndex
  41414. if (!seriesModel.get('silent')) {
  41415. el.on('mousedown', largePathUpdateDataIndex)
  41416. el.on('mousemove', largePathUpdateDataIndex)
  41417. }
  41418. progressiveEls && progressiveEls.push(el)
  41419. } // Use throttle to avoid frequently traverse to find dataIndex.
  41420. var largePathUpdateDataIndex = throttle(
  41421. function (event) {
  41422. var largePath = this
  41423. var dataIndex = largePathFindDataIndex(
  41424. largePath,
  41425. event.offsetX,
  41426. event.offsetY
  41427. )
  41428. getECData(largePath).dataIndex = dataIndex >= 0 ? dataIndex : null
  41429. },
  41430. 30,
  41431. false
  41432. )
  41433. function largePathFindDataIndex(largePath, x, y) {
  41434. var baseDimIdx = largePath.baseDimIdx
  41435. var valueDimIdx = 1 - baseDimIdx
  41436. var points = largePath.shape.points
  41437. var largeDataIndices = largePath.largeDataIndices
  41438. var startPoint = []
  41439. var size = []
  41440. var barWidth = largePath.barWidth
  41441. for (var i = 0, len = points.length / 3; i < len; i++) {
  41442. var ii = i * 3
  41443. size[baseDimIdx] = barWidth
  41444. size[valueDimIdx] = points[ii + 2]
  41445. startPoint[baseDimIdx] = points[ii + baseDimIdx]
  41446. startPoint[valueDimIdx] = points[ii + valueDimIdx]
  41447. if (size[valueDimIdx] < 0) {
  41448. startPoint[valueDimIdx] += size[valueDimIdx]
  41449. size[valueDimIdx] = -size[valueDimIdx]
  41450. }
  41451. if (
  41452. x >= startPoint[0] &&
  41453. x <= startPoint[0] + size[0] &&
  41454. y >= startPoint[1] &&
  41455. y <= startPoint[1] + size[1]
  41456. ) {
  41457. return largeDataIndices[i]
  41458. }
  41459. }
  41460. return -1
  41461. }
  41462. function createBackgroundShape(isHorizontalOrRadial, layout, coord) {
  41463. if (isCoordinateSystemType(coord, 'cartesian2d')) {
  41464. var rectShape = layout
  41465. var coordLayout = coord.getArea()
  41466. return {
  41467. x: isHorizontalOrRadial ? rectShape.x : coordLayout.x,
  41468. y: isHorizontalOrRadial ? coordLayout.y : rectShape.y,
  41469. width: isHorizontalOrRadial
  41470. ? rectShape.width
  41471. : coordLayout.width,
  41472. height: isHorizontalOrRadial
  41473. ? coordLayout.height
  41474. : rectShape.height
  41475. }
  41476. } else {
  41477. var coordLayout = coord.getArea()
  41478. var sectorShape = layout
  41479. return {
  41480. cx: coordLayout.cx,
  41481. cy: coordLayout.cy,
  41482. r0: isHorizontalOrRadial ? coordLayout.r0 : sectorShape.r0,
  41483. r: isHorizontalOrRadial ? coordLayout.r : sectorShape.r,
  41484. startAngle: isHorizontalOrRadial ? sectorShape.startAngle : 0,
  41485. endAngle: isHorizontalOrRadial
  41486. ? sectorShape.endAngle
  41487. : Math.PI * 2
  41488. }
  41489. }
  41490. }
  41491. function createBackgroundEl(coord, isHorizontalOrRadial, layout) {
  41492. var ElementClz = coord.type === 'polar' ? Sector$1 : Rect$2
  41493. return new ElementClz({
  41494. shape: createBackgroundShape(isHorizontalOrRadial, layout, coord),
  41495. silent: true,
  41496. z2: 0
  41497. })
  41498. }
  41499. var BarView$1 = BarView
  41500. function install$h(registers) {
  41501. registers.registerChartView(BarView$1)
  41502. registers.registerSeriesModel(BarSeries)
  41503. registers.registerLayout(
  41504. registers.PRIORITY.VISUAL.LAYOUT,
  41505. curry$1(layout$2, 'bar')
  41506. ) // Do layout after other overall layout, which can preapre some informations.
  41507. registers.registerLayout(
  41508. registers.PRIORITY.VISUAL.PROGRESSIVE_LAYOUT,
  41509. createProgressiveLayout('bar')
  41510. ) // Down sample after filter
  41511. registers.registerProcessor(
  41512. registers.PRIORITY.PROCESSOR.STATISTIC,
  41513. dataSample('bar')
  41514. )
  41515. /**
  41516. * @payload
  41517. * @property {string} [componentType=series]
  41518. * @property {number} [dx]
  41519. * @property {number} [dy]
  41520. * @property {number} [zoom]
  41521. * @property {number} [originX]
  41522. * @property {number} [originY]
  41523. */ registers.registerAction(
  41524. {
  41525. type: 'changeAxisOrder',
  41526. event: 'changeAxisOrder',
  41527. update: 'update'
  41528. },
  41529. function (payload, ecModel) {
  41530. var componentType = payload.componentType || 'series'
  41531. ecModel.eachComponent(
  41532. { mainType: componentType, query: payload },
  41533. function (componentModel) {
  41534. if (payload.sortInfo) {
  41535. componentModel.axis.setCategorySortInfo(payload.sortInfo)
  41536. }
  41537. }
  41538. )
  41539. }
  41540. )
  41541. }
  41542. var PI2 = Math.PI * 2
  41543. var RADIAN$1 = Math.PI / 180
  41544. function getViewRect(seriesModel, api) {
  41545. return getLayoutRect(seriesModel.getBoxLayoutParams(), {
  41546. width: api.getWidth(),
  41547. height: api.getHeight()
  41548. })
  41549. }
  41550. function getBasicPieLayout(seriesModel, api) {
  41551. var viewRect = getViewRect(seriesModel, api)
  41552. var center = seriesModel.get('center')
  41553. var radius = seriesModel.get('radius')
  41554. if (!isArray(radius)) {
  41555. radius = [0, radius]
  41556. }
  41557. if (!isArray(center)) {
  41558. center = [center, center]
  41559. }
  41560. var width = parsePercent(viewRect.width, api.getWidth())
  41561. var height = parsePercent(viewRect.height, api.getHeight())
  41562. var size = Math.min(width, height)
  41563. var cx = parsePercent(center[0], width) + viewRect.x
  41564. var cy = parsePercent(center[1], height) + viewRect.y
  41565. var r0 = parsePercent(radius[0], size / 2)
  41566. var r = parsePercent(radius[1], size / 2)
  41567. return { cx: cx, cy: cy, r0: r0, r: r }
  41568. }
  41569. function pieLayout(seriesType, ecModel, api) {
  41570. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  41571. var data = seriesModel.getData()
  41572. var valueDim = data.mapDimension('value')
  41573. var viewRect = getViewRect(seriesModel, api)
  41574. var _a = getBasicPieLayout(seriesModel, api),
  41575. cx = _a.cx,
  41576. cy = _a.cy,
  41577. r = _a.r,
  41578. r0 = _a.r0
  41579. var startAngle = -seriesModel.get('startAngle') * RADIAN$1
  41580. var minAngle = seriesModel.get('minAngle') * RADIAN$1
  41581. var validDataCount = 0
  41582. data.each(valueDim, function (value) {
  41583. !isNaN(value) && validDataCount++
  41584. })
  41585. var sum = data.getSum(valueDim) // Sum may be 0
  41586. var unitRadian = (Math.PI / (sum || validDataCount)) * 2
  41587. var clockwise = seriesModel.get('clockwise')
  41588. var roseType = seriesModel.get('roseType')
  41589. var stillShowZeroSum = seriesModel.get('stillShowZeroSum') // [0...max]
  41590. var extent = data.getDataExtent(valueDim)
  41591. extent[0] = 0 // In the case some sector angle is smaller than minAngle
  41592. var restAngle = PI2
  41593. var valueSumLargerThanMinAngle = 0
  41594. var currentAngle = startAngle
  41595. var dir = clockwise ? 1 : -1
  41596. data.setLayout({ viewRect: viewRect, r: r })
  41597. data.each(valueDim, function (value, idx) {
  41598. var angle
  41599. if (isNaN(value)) {
  41600. data.setItemLayout(idx, {
  41601. angle: NaN,
  41602. startAngle: NaN,
  41603. endAngle: NaN,
  41604. clockwise: clockwise,
  41605. cx: cx,
  41606. cy: cy,
  41607. r0: r0,
  41608. r: roseType ? NaN : r
  41609. })
  41610. return
  41611. } // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  41612. if (roseType !== 'area') {
  41613. angle =
  41614. sum === 0 && stillShowZeroSum
  41615. ? unitRadian
  41616. : value * unitRadian
  41617. } else {
  41618. angle = PI2 / validDataCount
  41619. }
  41620. if (angle < minAngle) {
  41621. angle = minAngle
  41622. restAngle -= minAngle
  41623. } else {
  41624. valueSumLargerThanMinAngle += value
  41625. }
  41626. var endAngle = currentAngle + dir * angle
  41627. data.setItemLayout(idx, {
  41628. angle: angle,
  41629. startAngle: currentAngle,
  41630. endAngle: endAngle,
  41631. clockwise: clockwise,
  41632. cx: cx,
  41633. cy: cy,
  41634. r0: r0,
  41635. r: roseType ? linearMap(value, extent, [r0, r]) : r
  41636. })
  41637. currentAngle = endAngle
  41638. }) // Some sector is constrained by minAngle
  41639. // Rest sectors needs recalculate angle
  41640. if (restAngle < PI2 && validDataCount) {
  41641. // Average the angle if rest angle is not enough after all angles is
  41642. // Constrained by minAngle
  41643. if (restAngle <= 1e-3) {
  41644. var angle_1 = PI2 / validDataCount
  41645. data.each(valueDim, function (value, idx) {
  41646. if (!isNaN(value)) {
  41647. var layout_1 = data.getItemLayout(idx)
  41648. layout_1.angle = angle_1
  41649. layout_1.startAngle = startAngle + dir * idx * angle_1
  41650. layout_1.endAngle = startAngle + dir * (idx + 1) * angle_1
  41651. }
  41652. })
  41653. } else {
  41654. unitRadian = restAngle / valueSumLargerThanMinAngle
  41655. currentAngle = startAngle
  41656. data.each(valueDim, function (value, idx) {
  41657. if (!isNaN(value)) {
  41658. var layout_2 = data.getItemLayout(idx)
  41659. var angle =
  41660. layout_2.angle === minAngle
  41661. ? minAngle
  41662. : value * unitRadian
  41663. layout_2.startAngle = currentAngle
  41664. layout_2.endAngle = currentAngle + dir * angle
  41665. currentAngle += dir * angle
  41666. }
  41667. })
  41668. }
  41669. }
  41670. })
  41671. }
  41672. /*
  41673. * Licensed to the Apache Software Foundation (ASF) under one
  41674. * or more contributor license agreements. See the NOTICE file
  41675. * distributed with this work for additional information
  41676. * regarding copyright ownership. The ASF licenses this file
  41677. * to you under the Apache License, Version 2.0 (the
  41678. * "License"); you may not use this file except in compliance
  41679. * with the License. You may obtain a copy of the License at
  41680. *
  41681. * http://www.apache.org/licenses/LICENSE-2.0
  41682. *
  41683. * Unless required by applicable law or agreed to in writing,
  41684. * software distributed under the License is distributed on an
  41685. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41686. * KIND, either express or implied. See the License for the
  41687. * specific language governing permissions and limitations
  41688. * under the License.
  41689. */ /**
  41690. * AUTO-GENERATED FILE. DO NOT MODIFY.
  41691. */ /*
  41692. * Licensed to the Apache Software Foundation (ASF) under one
  41693. * or more contributor license agreements. See the NOTICE file
  41694. * distributed with this work for additional information
  41695. * regarding copyright ownership. The ASF licenses this file
  41696. * to you under the Apache License, Version 2.0 (the
  41697. * "License"); you may not use this file except in compliance
  41698. * with the License. You may obtain a copy of the License at
  41699. *
  41700. * http://www.apache.org/licenses/LICENSE-2.0
  41701. *
  41702. * Unless required by applicable law or agreed to in writing,
  41703. * software distributed under the License is distributed on an
  41704. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  41705. * KIND, either express or implied. See the License for the
  41706. * specific language governing permissions and limitations
  41707. * under the License.
  41708. */ function dataFilter(seriesType) {
  41709. return {
  41710. seriesType: seriesType,
  41711. reset: function reset(seriesModel, ecModel) {
  41712. var legendModels = ecModel.findComponents({
  41713. mainType: 'legend'
  41714. })
  41715. if (!legendModels || !legendModels.length) {
  41716. return
  41717. }
  41718. var data = seriesModel.getData()
  41719. data.filterSelf(function (idx) {
  41720. var name = data.getName(idx) // If in any legend component the status is not selected.
  41721. for (var i = 0; i < legendModels.length; i++) {
  41722. // @ts-ignore FIXME: LegendModel
  41723. if (!legendModels[i].isSelected(name)) {
  41724. return false
  41725. }
  41726. }
  41727. return true
  41728. })
  41729. }
  41730. }
  41731. }
  41732. var RADIAN = Math.PI / 180
  41733. function adjustSingleSide(
  41734. list,
  41735. cx,
  41736. cy,
  41737. r,
  41738. dir,
  41739. viewWidth,
  41740. viewHeight,
  41741. viewLeft,
  41742. viewTop,
  41743. farthestX
  41744. ) {
  41745. if (list.length < 2) {
  41746. return
  41747. }
  41748. function recalculateXOnSemiToAlignOnEllipseCurve(semi) {
  41749. var rB = semi.rB
  41750. var rB2 = rB * rB
  41751. for (var i = 0; i < semi.list.length; i++) {
  41752. var item = semi.list[i]
  41753. var dy = Math.abs(item.label.y - cy) // horizontal r is always same with original r because x is not changed.
  41754. var rA = r + item.len
  41755. var rA2 = rA * rA // Use ellipse implicit function to calculate x
  41756. var dx = Math.sqrt((1 - Math.abs((dy * dy) / rB2)) * rA2)
  41757. var newX = cx + (dx + item.len2) * dir
  41758. var deltaX = newX - item.label.x
  41759. var newTargetWidth = item.targetTextWidth - deltaX * dir // text x is changed, so need to recalculate width.
  41760. constrainTextWidth(item, newTargetWidth, true)
  41761. item.label.x = newX
  41762. }
  41763. } // Adjust X based on the shifted y. Make tight labels aligned on an ellipse curve.
  41764. function recalculateX(items) {
  41765. // Extremes of
  41766. var topSemi = { list: [], maxY: 0 }
  41767. var bottomSemi = { list: [], maxY: 0 }
  41768. for (var i = 0; i < items.length; i++) {
  41769. if (items[i].labelAlignTo !== 'none') {
  41770. continue
  41771. }
  41772. var item = items[i]
  41773. var semi = item.label.y > cy ? bottomSemi : topSemi
  41774. var dy = Math.abs(item.label.y - cy)
  41775. if (dy >= semi.maxY) {
  41776. var dx = item.label.x - cx - item.len2 * dir // horizontal r is always same with original r because x is not changed.
  41777. var rA = r + item.len // Canculate rB based on the topest / bottemest label.
  41778. var rB =
  41779. Math.abs(dx) < rA
  41780. ? Math.sqrt((dy * dy) / (1 - (dx * dx) / rA / rA))
  41781. : rA
  41782. semi.rB = rB
  41783. semi.maxY = dy
  41784. }
  41785. semi.list.push(item)
  41786. }
  41787. recalculateXOnSemiToAlignOnEllipseCurve(topSemi)
  41788. recalculateXOnSemiToAlignOnEllipseCurve(bottomSemi)
  41789. }
  41790. var len = list.length
  41791. for (var i = 0; i < len; i++) {
  41792. if (
  41793. list[i].position === 'outer' &&
  41794. list[i].labelAlignTo === 'labelLine'
  41795. ) {
  41796. var dx = list[i].label.x - farthestX
  41797. list[i].linePoints[1][0] += dx
  41798. list[i].label.x = farthestX
  41799. }
  41800. }
  41801. if (shiftLayoutOnY(list, viewTop, viewTop + viewHeight)) {
  41802. recalculateX(list)
  41803. }
  41804. }
  41805. function avoidOverlap(
  41806. labelLayoutList,
  41807. cx,
  41808. cy,
  41809. r,
  41810. viewWidth,
  41811. viewHeight,
  41812. viewLeft,
  41813. viewTop
  41814. ) {
  41815. var leftList = []
  41816. var rightList = []
  41817. var leftmostX = Number.MAX_VALUE
  41818. var rightmostX = -Number.MAX_VALUE
  41819. for (var i = 0; i < labelLayoutList.length; i++) {
  41820. var label = labelLayoutList[i].label
  41821. if (isPositionCenter(labelLayoutList[i])) {
  41822. continue
  41823. }
  41824. if (label.x < cx) {
  41825. leftmostX = Math.min(leftmostX, label.x)
  41826. leftList.push(labelLayoutList[i])
  41827. } else {
  41828. rightmostX = Math.max(rightmostX, label.x)
  41829. rightList.push(labelLayoutList[i])
  41830. }
  41831. }
  41832. for (var i = 0; i < labelLayoutList.length; i++) {
  41833. var layout = labelLayoutList[i]
  41834. if (!isPositionCenter(layout) && layout.linePoints) {
  41835. if (layout.labelStyleWidth != null) {
  41836. continue
  41837. }
  41838. var label = layout.label
  41839. var linePoints = layout.linePoints
  41840. var targetTextWidth = void 0
  41841. if (layout.labelAlignTo === 'edge') {
  41842. if (label.x < cx) {
  41843. targetTextWidth =
  41844. linePoints[2][0] -
  41845. layout.labelDistance -
  41846. viewLeft -
  41847. layout.edgeDistance
  41848. } else {
  41849. targetTextWidth =
  41850. viewLeft +
  41851. viewWidth -
  41852. layout.edgeDistance -
  41853. linePoints[2][0] -
  41854. layout.labelDistance
  41855. }
  41856. } else if (layout.labelAlignTo === 'labelLine') {
  41857. if (label.x < cx) {
  41858. targetTextWidth = leftmostX - viewLeft - layout.bleedMargin
  41859. } else {
  41860. targetTextWidth =
  41861. viewLeft + viewWidth - rightmostX - layout.bleedMargin
  41862. }
  41863. } else {
  41864. if (label.x < cx) {
  41865. targetTextWidth = label.x - viewLeft - layout.bleedMargin
  41866. } else {
  41867. targetTextWidth =
  41868. viewLeft + viewWidth - label.x - layout.bleedMargin
  41869. }
  41870. }
  41871. layout.targetTextWidth = targetTextWidth
  41872. constrainTextWidth(layout, targetTextWidth)
  41873. }
  41874. }
  41875. adjustSingleSide(
  41876. rightList,
  41877. cx,
  41878. cy,
  41879. r,
  41880. 1,
  41881. viewWidth,
  41882. viewHeight,
  41883. viewLeft,
  41884. viewTop,
  41885. rightmostX
  41886. )
  41887. adjustSingleSide(
  41888. leftList,
  41889. cx,
  41890. cy,
  41891. r,
  41892. -1,
  41893. viewWidth,
  41894. viewHeight,
  41895. viewLeft,
  41896. viewTop,
  41897. leftmostX
  41898. )
  41899. for (var i = 0; i < labelLayoutList.length; i++) {
  41900. var layout = labelLayoutList[i]
  41901. if (!isPositionCenter(layout) && layout.linePoints) {
  41902. var label = layout.label
  41903. var linePoints = layout.linePoints
  41904. var isAlignToEdge = layout.labelAlignTo === 'edge'
  41905. var padding = label.style.padding
  41906. var paddingH = padding ? padding[1] + padding[3] : 0 // textRect.width already contains paddingH if bgColor is set
  41907. var extraPaddingH = label.style.backgroundColor ? 0 : paddingH
  41908. var realTextWidth = layout.rect.width + extraPaddingH
  41909. var dist = linePoints[1][0] - linePoints[2][0]
  41910. if (isAlignToEdge) {
  41911. if (label.x < cx) {
  41912. linePoints[2][0] =
  41913. viewLeft +
  41914. layout.edgeDistance +
  41915. realTextWidth +
  41916. layout.labelDistance
  41917. } else {
  41918. linePoints[2][0] =
  41919. viewLeft +
  41920. viewWidth -
  41921. layout.edgeDistance -
  41922. realTextWidth -
  41923. layout.labelDistance
  41924. }
  41925. } else {
  41926. if (label.x < cx) {
  41927. linePoints[2][0] = label.x + layout.labelDistance
  41928. } else {
  41929. linePoints[2][0] = label.x - layout.labelDistance
  41930. }
  41931. linePoints[1][0] = linePoints[2][0] + dist
  41932. }
  41933. linePoints[1][1] = linePoints[2][1] = label.y
  41934. }
  41935. }
  41936. }
  41937. /**
  41938. * Set max width of each label, and then wrap each label to the max width.
  41939. *
  41940. * @param layout label layout
  41941. * @param availableWidth max width for the label to display
  41942. * @param forceRecalculate recaculate the text layout even if the current width
  41943. * is smaller than `availableWidth`. This is useful when the text was previously
  41944. * wrapped by calling `constrainTextWidth` but now `availableWidth` changed, in
  41945. * which case, previous wrapping should be redo.
  41946. */ function constrainTextWidth(
  41947. layout,
  41948. availableWidth,
  41949. forceRecalculate
  41950. ) {
  41951. if (forceRecalculate === void 0) {
  41952. forceRecalculate = false
  41953. }
  41954. if (layout.labelStyleWidth != null) {
  41955. // User-defined style.width has the highest priority.
  41956. return
  41957. }
  41958. var label = layout.label
  41959. var style = label.style
  41960. var textRect = layout.rect
  41961. var bgColor = style.backgroundColor
  41962. var padding = style.padding
  41963. var paddingH = padding ? padding[1] + padding[3] : 0
  41964. var overflow = style.overflow // textRect.width already contains paddingH if bgColor is set
  41965. var oldOuterWidth = textRect.width + (bgColor ? 0 : paddingH)
  41966. if (availableWidth < oldOuterWidth || forceRecalculate) {
  41967. var oldHeight = textRect.height
  41968. if (overflow && overflow.match('break')) {
  41969. // Temporarily set background to be null to calculate
  41970. // the bounding box without backgroud.
  41971. label.setStyle('backgroundColor', null) // Set constraining width
  41972. label.setStyle('width', availableWidth - paddingH) // This is the real bounding box of the text without padding
  41973. var innerRect = label.getBoundingRect()
  41974. label.setStyle('width', Math.ceil(innerRect.width))
  41975. label.setStyle('backgroundColor', bgColor)
  41976. } else {
  41977. var availableInnerWidth = availableWidth - paddingH
  41978. var newWidth =
  41979. availableWidth < oldOuterWidth // Current text is too wide, use `availableWidth` as max width.
  41980. ? availableInnerWidth // Current available width is enough, but the text may have
  41981. : // already been wrapped with a smaller available width.
  41982. forceRecalculate
  41983. ? availableInnerWidth > layout.unconstrainedWidth // Current available is larger than text width,
  41984. ? // so don't constrain width (otherwise it may have
  41985. // empty space in the background).
  41986. null // Current available is smaller than text width, so
  41987. : // use the current available width as constraining
  41988. // width.
  41989. availableInnerWidth // Current available width is enough, so no need to
  41990. : // constrain.
  41991. null
  41992. label.setStyle('width', newWidth)
  41993. }
  41994. var newRect = label.getBoundingRect()
  41995. textRect.width = newRect.width
  41996. var margin = (label.style.margin || 0) + 2.1
  41997. textRect.height = newRect.height + margin
  41998. textRect.y -= (textRect.height - oldHeight) / 2
  41999. }
  42000. }
  42001. function isPositionCenter(sectorShape) {
  42002. // Not change x for center label
  42003. return sectorShape.position === 'center'
  42004. }
  42005. function pieLabelLayout(seriesModel) {
  42006. var data = seriesModel.getData()
  42007. var labelLayoutList = []
  42008. var cx
  42009. var cy
  42010. var hasLabelRotate = false
  42011. var minShowLabelRadian =
  42012. (seriesModel.get('minShowLabelAngle') || 0) * RADIAN
  42013. var viewRect = data.getLayout('viewRect')
  42014. var r = data.getLayout('r')
  42015. var viewWidth = viewRect.width
  42016. var viewLeft = viewRect.x
  42017. var viewTop = viewRect.y
  42018. var viewHeight = viewRect.height
  42019. function setNotShow(el) {
  42020. el.ignore = true
  42021. }
  42022. function isLabelShown(label) {
  42023. if (!label.ignore) {
  42024. return true
  42025. }
  42026. for (var key in label.states) {
  42027. if (label.states[key].ignore === false) {
  42028. return true
  42029. }
  42030. }
  42031. return false
  42032. }
  42033. data.each(function (idx) {
  42034. var sector = data.getItemGraphicEl(idx)
  42035. var sectorShape = sector.shape
  42036. var label = sector.getTextContent()
  42037. var labelLine = sector.getTextGuideLine()
  42038. var itemModel = data.getItemModel(idx)
  42039. var labelModel = itemModel.getModel('label') // Use position in normal or emphasis
  42040. var labelPosition =
  42041. labelModel.get('position') ||
  42042. itemModel.get(['emphasis', 'label', 'position'])
  42043. var labelDistance = labelModel.get('distanceToLabelLine')
  42044. var labelAlignTo = labelModel.get('alignTo')
  42045. var edgeDistance = parsePercent(
  42046. labelModel.get('edgeDistance'),
  42047. viewWidth
  42048. )
  42049. var bleedMargin = labelModel.get('bleedMargin')
  42050. var labelLineModel = itemModel.getModel('labelLine')
  42051. var labelLineLen = labelLineModel.get('length')
  42052. labelLineLen = parsePercent(labelLineLen, viewWidth)
  42053. var labelLineLen2 = labelLineModel.get('length2')
  42054. labelLineLen2 = parsePercent(labelLineLen2, viewWidth)
  42055. if (
  42056. Math.abs(sectorShape.endAngle - sectorShape.startAngle) <
  42057. minShowLabelRadian
  42058. ) {
  42059. each$7(label.states, setNotShow)
  42060. label.ignore = true
  42061. return
  42062. }
  42063. if (!isLabelShown(label)) {
  42064. return
  42065. }
  42066. var midAngle = (sectorShape.startAngle + sectorShape.endAngle) / 2
  42067. var nx = Math.cos(midAngle)
  42068. var ny = Math.sin(midAngle)
  42069. var textX
  42070. var textY
  42071. var linePoints
  42072. var textAlign
  42073. cx = sectorShape.cx
  42074. cy = sectorShape.cy
  42075. var isLabelInside =
  42076. labelPosition === 'inside' || labelPosition === 'inner'
  42077. if (labelPosition === 'center') {
  42078. textX = sectorShape.cx
  42079. textY = sectorShape.cy
  42080. textAlign = 'center'
  42081. } else {
  42082. var x1 =
  42083. (isLabelInside
  42084. ? ((sectorShape.r + sectorShape.r0) / 2) * nx
  42085. : sectorShape.r * nx) + cx
  42086. var y1 =
  42087. (isLabelInside
  42088. ? ((sectorShape.r + sectorShape.r0) / 2) * ny
  42089. : sectorShape.r * ny) + cy
  42090. textX = x1 + nx * 3
  42091. textY = y1 + ny * 3
  42092. if (!isLabelInside) {
  42093. // For roseType
  42094. var x2 = x1 + nx * (labelLineLen + r - sectorShape.r)
  42095. var y2 = y1 + ny * (labelLineLen + r - sectorShape.r)
  42096. var x3 = x2 + (nx < 0 ? -1 : 1) * labelLineLen2
  42097. var y3 = y2
  42098. if (labelAlignTo === 'edge') {
  42099. // Adjust textX because text align of edge is opposite
  42100. textX =
  42101. nx < 0
  42102. ? viewLeft + edgeDistance
  42103. : viewLeft + viewWidth - edgeDistance
  42104. } else {
  42105. textX = x3 + (nx < 0 ? -labelDistance : labelDistance)
  42106. }
  42107. textY = y3
  42108. linePoints = [
  42109. [x1, y1],
  42110. [x2, y2],
  42111. [x3, y3]
  42112. ]
  42113. }
  42114. textAlign = isLabelInside
  42115. ? 'center'
  42116. : labelAlignTo === 'edge'
  42117. ? nx > 0
  42118. ? 'right'
  42119. : 'left'
  42120. : nx > 0
  42121. ? 'left'
  42122. : 'right'
  42123. }
  42124. var PI = Math.PI
  42125. var labelRotate = 0
  42126. var rotate = labelModel.get('rotate')
  42127. if (isNumber(rotate)) {
  42128. labelRotate = rotate * (PI / 180)
  42129. } else if (labelPosition === 'center') {
  42130. labelRotate = 0
  42131. } else if (rotate === 'radial' || rotate === true) {
  42132. var radialAngle = nx < 0 ? -midAngle + PI : -midAngle
  42133. labelRotate = radialAngle
  42134. } else if (
  42135. rotate === 'tangential' &&
  42136. labelPosition !== 'outside' &&
  42137. labelPosition !== 'outer'
  42138. ) {
  42139. var rad = Math.atan2(nx, ny)
  42140. if (rad < 0) {
  42141. rad = PI * 2 + rad
  42142. }
  42143. var isDown = ny > 0
  42144. if (isDown) {
  42145. rad = PI + rad
  42146. }
  42147. labelRotate = rad - PI
  42148. }
  42149. hasLabelRotate = !!labelRotate
  42150. label.x = textX
  42151. label.y = textY
  42152. label.rotation = labelRotate
  42153. label.setStyle({ verticalAlign: 'middle' }) // Not sectorShape the inside label
  42154. if (!isLabelInside) {
  42155. var textRect = label.getBoundingRect().clone()
  42156. textRect.applyTransform(label.getComputedTransform()) // Text has a default 1px stroke. Exclude this.
  42157. var margin = (label.style.margin || 0) + 2.1
  42158. textRect.y -= margin / 2
  42159. textRect.height += margin
  42160. labelLayoutList.push({
  42161. label: label,
  42162. labelLine: labelLine,
  42163. position: labelPosition,
  42164. len: labelLineLen,
  42165. len2: labelLineLen2,
  42166. minTurnAngle: labelLineModel.get('minTurnAngle'),
  42167. maxSurfaceAngle: labelLineModel.get('maxSurfaceAngle'),
  42168. surfaceNormal: new Point$1(nx, ny),
  42169. linePoints: linePoints,
  42170. textAlign: textAlign,
  42171. labelDistance: labelDistance,
  42172. labelAlignTo: labelAlignTo,
  42173. edgeDistance: edgeDistance,
  42174. bleedMargin: bleedMargin,
  42175. rect: textRect,
  42176. unconstrainedWidth: textRect.width,
  42177. labelStyleWidth: label.style.width
  42178. })
  42179. } else {
  42180. label.setStyle({ align: textAlign })
  42181. var selectState = label.states.select
  42182. if (selectState) {
  42183. selectState.x += label.x
  42184. selectState.y += label.y
  42185. }
  42186. }
  42187. sector.setTextConfig({ inside: isLabelInside })
  42188. })
  42189. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  42190. avoidOverlap(
  42191. labelLayoutList,
  42192. cx,
  42193. cy,
  42194. r,
  42195. viewWidth,
  42196. viewHeight,
  42197. viewLeft,
  42198. viewTop
  42199. )
  42200. }
  42201. for (var i = 0; i < labelLayoutList.length; i++) {
  42202. var layout = labelLayoutList[i]
  42203. var label = layout.label
  42204. var labelLine = layout.labelLine
  42205. var notShowLabel = isNaN(label.x) || isNaN(label.y)
  42206. if (label) {
  42207. label.setStyle({ align: layout.textAlign })
  42208. if (notShowLabel) {
  42209. each$7(label.states, setNotShow)
  42210. label.ignore = true
  42211. }
  42212. var selectState = label.states.select
  42213. if (selectState) {
  42214. selectState.x += label.x
  42215. selectState.y += label.y
  42216. }
  42217. }
  42218. if (labelLine) {
  42219. var linePoints = layout.linePoints
  42220. if (notShowLabel || !linePoints) {
  42221. each$7(labelLine.states, setNotShow)
  42222. labelLine.ignore = true
  42223. } else {
  42224. limitTurnAngle(linePoints, layout.minTurnAngle)
  42225. limitSurfaceAngle(
  42226. linePoints,
  42227. layout.surfaceNormal,
  42228. layout.maxSurfaceAngle
  42229. )
  42230. labelLine.setShape({ points: linePoints }) // Set the anchor to the midpoint of sector
  42231. label.__hostTarget.textGuideLineConfig = {
  42232. anchor: new Point$1(linePoints[0][0], linePoints[0][1])
  42233. }
  42234. }
  42235. }
  42236. }
  42237. }
  42238. function getSectorCornerRadius(model, shape, zeroIfNull) {
  42239. var cornerRadius = model.get('borderRadius')
  42240. if (cornerRadius == null) {
  42241. return zeroIfNull ? { cornerRadius: 0 } : null
  42242. }
  42243. if (!isArray(cornerRadius)) {
  42244. cornerRadius = [
  42245. cornerRadius,
  42246. cornerRadius,
  42247. cornerRadius,
  42248. cornerRadius
  42249. ]
  42250. }
  42251. var dr = Math.abs(shape.r || 0 - shape.r0 || 0)
  42252. return {
  42253. cornerRadius: map$1(cornerRadius, function (cr) {
  42254. return parsePercent$1(cr, dr)
  42255. })
  42256. }
  42257. }
  42258. /**
  42259. * Piece of pie including Sector, Label, LabelLine
  42260. */ var PiePiece = /** @class */ (function (_super) {
  42261. __extends(PiePiece, _super)
  42262. function PiePiece(data, idx, startAngle) {
  42263. var _this = _super.call(this) || this
  42264. _this.z2 = 2
  42265. var text = new ZRText$1()
  42266. _this.setTextContent(text)
  42267. _this.updateData(data, idx, startAngle, true)
  42268. return _this
  42269. }
  42270. PiePiece.prototype.updateData = function (
  42271. data,
  42272. idx,
  42273. startAngle,
  42274. firstCreate
  42275. ) {
  42276. var sector = this
  42277. var seriesModel = data.hostModel
  42278. var itemModel = data.getItemModel(idx)
  42279. var emphasisModel = itemModel.getModel('emphasis')
  42280. var layout = data.getItemLayout(idx) // cornerRadius & innerCornerRadius doesn't exist in the item layout. Use `0` if null value is specified.
  42281. // see `setItemLayout` in `pieLayout.ts`.
  42282. var sectorShape = extend(
  42283. getSectorCornerRadius(
  42284. itemModel.getModel('itemStyle'),
  42285. layout,
  42286. true
  42287. ),
  42288. layout
  42289. ) // Ignore NaN data.
  42290. if (isNaN(sectorShape.startAngle)) {
  42291. // Use NaN shape to avoid drawing shape.
  42292. sector.setShape(sectorShape)
  42293. return
  42294. }
  42295. if (firstCreate) {
  42296. sector.setShape(sectorShape)
  42297. var animationType = seriesModel.getShallow('animationType')
  42298. if (seriesModel.ecModel.ssr) {
  42299. // Use scale animation in SSR mode(opacity?)
  42300. // Because CSS SVG animation doesn't support very customized shape animation.
  42301. initProps(sector, { scaleX: 0, scaleY: 0 }, seriesModel, {
  42302. dataIndex: idx,
  42303. isFrom: true
  42304. })
  42305. sector.originX = sectorShape.cx
  42306. sector.originY = sectorShape.cy
  42307. } else if (animationType === 'scale') {
  42308. sector.shape.r = layout.r0
  42309. initProps(
  42310. sector,
  42311. { shape: { r: layout.r } },
  42312. seriesModel,
  42313. idx
  42314. )
  42315. } // Expansion
  42316. else {
  42317. if (startAngle != null) {
  42318. sector.setShape({
  42319. startAngle: startAngle,
  42320. endAngle: startAngle
  42321. })
  42322. initProps(
  42323. sector,
  42324. {
  42325. shape: {
  42326. startAngle: layout.startAngle,
  42327. endAngle: layout.endAngle
  42328. }
  42329. },
  42330. seriesModel,
  42331. idx
  42332. )
  42333. } else {
  42334. sector.shape.endAngle = layout.startAngle
  42335. updateProps$1(
  42336. sector,
  42337. { shape: { endAngle: layout.endAngle } },
  42338. seriesModel,
  42339. idx
  42340. )
  42341. }
  42342. }
  42343. } else {
  42344. saveOldStyle(sector) // Transition animation from the old shape
  42345. updateProps$1(sector, { shape: sectorShape }, seriesModel, idx)
  42346. }
  42347. sector.useStyle(data.getItemVisual(idx, 'style'))
  42348. setStatesStylesFromModel(sector, itemModel)
  42349. var midAngle = (layout.startAngle + layout.endAngle) / 2
  42350. var offset = seriesModel.get('selectedOffset')
  42351. var dx = Math.cos(midAngle) * offset
  42352. var dy = Math.sin(midAngle) * offset
  42353. var cursorStyle = itemModel.getShallow('cursor')
  42354. cursorStyle && sector.attr('cursor', cursorStyle)
  42355. this._updateLabel(seriesModel, data, idx)
  42356. sector.ensureState('emphasis').shape = extend(
  42357. {
  42358. r:
  42359. layout.r +
  42360. (emphasisModel.get('scale')
  42361. ? emphasisModel.get('scaleSize') || 0
  42362. : 0)
  42363. },
  42364. getSectorCornerRadius(
  42365. emphasisModel.getModel('itemStyle'),
  42366. layout
  42367. )
  42368. )
  42369. extend(sector.ensureState('select'), {
  42370. x: dx,
  42371. y: dy,
  42372. shape: getSectorCornerRadius(
  42373. itemModel.getModel(['select', 'itemStyle']),
  42374. layout
  42375. )
  42376. })
  42377. extend(sector.ensureState('blur'), {
  42378. shape: getSectorCornerRadius(
  42379. itemModel.getModel(['blur', 'itemStyle']),
  42380. layout
  42381. )
  42382. })
  42383. var labelLine = sector.getTextGuideLine()
  42384. var labelText = sector.getTextContent()
  42385. labelLine &&
  42386. extend(labelLine.ensureState('select'), { x: dx, y: dy }) // TODO: needs dx, dy in zrender?
  42387. extend(labelText.ensureState('select'), { x: dx, y: dy })
  42388. toggleHoverEmphasis(
  42389. this,
  42390. emphasisModel.get('focus'),
  42391. emphasisModel.get('blurScope'),
  42392. emphasisModel.get('disabled')
  42393. )
  42394. }
  42395. PiePiece.prototype._updateLabel = function (
  42396. seriesModel,
  42397. data,
  42398. idx
  42399. ) {
  42400. var sector = this
  42401. var itemModel = data.getItemModel(idx)
  42402. var labelLineModel = itemModel.getModel('labelLine')
  42403. var style = data.getItemVisual(idx, 'style')
  42404. var visualColor = style && style.fill
  42405. var visualOpacity = style && style.opacity
  42406. setLabelStyle(sector, getLabelStatesModels(itemModel), {
  42407. labelFetcher: data.hostModel,
  42408. labelDataIndex: idx,
  42409. inheritColor: visualColor,
  42410. defaultOpacity: visualOpacity,
  42411. defaultText:
  42412. seriesModel.getFormattedLabel(idx, 'normal') ||
  42413. data.getName(idx)
  42414. })
  42415. var labelText = sector.getTextContent() // Set textConfig on sector.
  42416. sector.setTextConfig({
  42417. // reset position, rotation
  42418. position: null,
  42419. rotation: null
  42420. }) // Make sure update style on labelText after setLabelStyle.
  42421. // Because setLabelStyle will replace a new style on it.
  42422. labelText.attr({ z2: 10 })
  42423. var labelPosition = seriesModel.get(['label', 'position'])
  42424. if (labelPosition !== 'outside' && labelPosition !== 'outer') {
  42425. sector.removeTextGuideLine()
  42426. } else {
  42427. var polyline = this.getTextGuideLine()
  42428. if (!polyline) {
  42429. polyline = new Polyline$1()
  42430. this.setTextGuideLine(polyline)
  42431. } // Default use item visual color
  42432. setLabelLineStyle(this, getLabelLineStatesModels(itemModel), {
  42433. stroke: visualColor,
  42434. opacity: retrieve3(
  42435. labelLineModel.get(['lineStyle', 'opacity']),
  42436. visualOpacity,
  42437. 1
  42438. )
  42439. })
  42440. }
  42441. }
  42442. return PiePiece
  42443. })(Sector$1) // Pie view
  42444. var PieView = /** @class */ (function (_super) {
  42445. __extends(PieView, _super)
  42446. function PieView() {
  42447. var _this =
  42448. (_super !== null && _super.apply(this, arguments)) || this
  42449. _this.ignoreLabelLineUpdate = true
  42450. return _this
  42451. }
  42452. PieView.prototype.render = function (
  42453. seriesModel,
  42454. ecModel,
  42455. api,
  42456. payload
  42457. ) {
  42458. var data = seriesModel.getData()
  42459. var oldData = this._data
  42460. var group = this.group
  42461. var startAngle // First render
  42462. if (!oldData && data.count() > 0) {
  42463. var shape = data.getItemLayout(0)
  42464. for (
  42465. var s = 1;
  42466. isNaN(shape && shape.startAngle) && s < data.count();
  42467. ++s
  42468. ) {
  42469. shape = data.getItemLayout(s)
  42470. }
  42471. if (shape) {
  42472. startAngle = shape.startAngle
  42473. }
  42474. } // remove empty-circle if it exists
  42475. if (this._emptyCircleSector) {
  42476. group.remove(this._emptyCircleSector)
  42477. } // when all data are filtered, show lightgray empty circle
  42478. if (data.count() === 0 && seriesModel.get('showEmptyCircle')) {
  42479. var sector = new Sector$1({
  42480. shape: getBasicPieLayout(seriesModel, api)
  42481. })
  42482. sector.useStyle(
  42483. seriesModel.getModel('emptyCircleStyle').getItemStyle()
  42484. )
  42485. this._emptyCircleSector = sector
  42486. group.add(sector)
  42487. }
  42488. data
  42489. .diff(oldData)
  42490. .add(function (idx) {
  42491. var piePiece = new PiePiece(data, idx, startAngle)
  42492. data.setItemGraphicEl(idx, piePiece)
  42493. group.add(piePiece)
  42494. })
  42495. .update(function (newIdx, oldIdx) {
  42496. var piePiece = oldData.getItemGraphicEl(oldIdx)
  42497. piePiece.updateData(data, newIdx, startAngle)
  42498. piePiece.off('click')
  42499. group.add(piePiece)
  42500. data.setItemGraphicEl(newIdx, piePiece)
  42501. })
  42502. .remove(function (idx) {
  42503. var piePiece = oldData.getItemGraphicEl(idx)
  42504. removeElementWithFadeOut(piePiece, seriesModel, idx)
  42505. })
  42506. .execute()
  42507. pieLabelLayout(seriesModel) // Always use initial animation.
  42508. if (seriesModel.get('animationTypeUpdate') !== 'expansion') {
  42509. this._data = data
  42510. }
  42511. }
  42512. PieView.prototype.dispose = function () {}
  42513. PieView.prototype.containPoint = function (point, seriesModel) {
  42514. var data = seriesModel.getData()
  42515. var itemLayout = data.getItemLayout(0)
  42516. if (itemLayout) {
  42517. var dx = point[0] - itemLayout.cx
  42518. var dy = point[1] - itemLayout.cy
  42519. var radius = Math.sqrt(dx * dx + dy * dy)
  42520. return radius <= itemLayout.r && radius >= itemLayout.r0
  42521. }
  42522. }
  42523. PieView.type = 'pie'
  42524. return PieView
  42525. })(ChartView$1)
  42526. var PieView$1 = PieView
  42527. /**
  42528. * [Usage]:
  42529. * (1)
  42530. * createListSimply(seriesModel, ['value']);
  42531. * (2)
  42532. * createListSimply(seriesModel, {
  42533. * coordDimensions: ['value'],
  42534. * dimensionsCount: 5
  42535. * });
  42536. */ function createSeriesDataSimply(seriesModel, opt, nameList) {
  42537. opt =
  42538. (isArray(opt) && { coordDimensions: opt }) ||
  42539. extend({ encodeDefine: seriesModel.getEncode() }, opt)
  42540. var source = seriesModel.getSource()
  42541. var dimensions = prepareSeriesDataSchema(source, opt).dimensions
  42542. var list = new SeriesData$1(dimensions, seriesModel)
  42543. list.initData(source, nameList)
  42544. return list
  42545. }
  42546. /*
  42547. * Licensed to the Apache Software Foundation (ASF) under one
  42548. * or more contributor license agreements. See the NOTICE file
  42549. * distributed with this work for additional information
  42550. * regarding copyright ownership. The ASF licenses this file
  42551. * to you under the Apache License, Version 2.0 (the
  42552. * "License"); you may not use this file except in compliance
  42553. * with the License. You may obtain a copy of the License at
  42554. *
  42555. * http://www.apache.org/licenses/LICENSE-2.0
  42556. *
  42557. * Unless required by applicable law or agreed to in writing,
  42558. * software distributed under the License is distributed on an
  42559. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42560. * KIND, either express or implied. See the License for the
  42561. * specific language governing permissions and limitations
  42562. * under the License.
  42563. */ /**
  42564. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42565. */ /*
  42566. * Licensed to the Apache Software Foundation (ASF) under one
  42567. * or more contributor license agreements. See the NOTICE file
  42568. * distributed with this work for additional information
  42569. * regarding copyright ownership. The ASF licenses this file
  42570. * to you under the Apache License, Version 2.0 (the
  42571. * "License"); you may not use this file except in compliance
  42572. * with the License. You may obtain a copy of the License at
  42573. *
  42574. * http://www.apache.org/licenses/LICENSE-2.0
  42575. *
  42576. * Unless required by applicable law or agreed to in writing,
  42577. * software distributed under the License is distributed on an
  42578. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42579. * KIND, either express or implied. See the License for the
  42580. * specific language governing permissions and limitations
  42581. * under the License.
  42582. */ /**
  42583. * LegendVisualProvider is an bridge that pick encoded color from data and
  42584. * provide to the legend component.
  42585. */ var LegendVisualProvider = /** @class */ (function () {
  42586. function LegendVisualProvider( // Function to get data after filtered. It stores all the encoding info
  42587. getDataWithEncodedVisual, // Function to get raw data before filtered.
  42588. getRawData
  42589. ) {
  42590. this._getDataWithEncodedVisual = getDataWithEncodedVisual
  42591. this._getRawData = getRawData
  42592. }
  42593. LegendVisualProvider.prototype.getAllNames = function () {
  42594. var rawData = this._getRawData() // We find the name from the raw data. In case it's filtered by the legend component.
  42595. // Normally, the name can be found in rawData, but can't be found in filtered data will display as gray.
  42596. return rawData.mapArray(rawData.getName)
  42597. }
  42598. LegendVisualProvider.prototype.containName = function (name) {
  42599. var rawData = this._getRawData()
  42600. return rawData.indexOfName(name) >= 0
  42601. }
  42602. LegendVisualProvider.prototype.indexOfName = function (name) {
  42603. // Only get data when necessary.
  42604. // Because LegendVisualProvider constructor may be new in the stage that data is not prepared yet.
  42605. // Invoking Series#getData immediately will throw an error.
  42606. var dataWithEncodedVisual = this._getDataWithEncodedVisual()
  42607. return dataWithEncodedVisual.indexOfName(name)
  42608. }
  42609. LegendVisualProvider.prototype.getItemVisual = function (
  42610. dataIndex,
  42611. key
  42612. ) {
  42613. // Get encoded visual properties from final filtered data.
  42614. var dataWithEncodedVisual = this._getDataWithEncodedVisual()
  42615. return dataWithEncodedVisual.getItemVisual(dataIndex, key)
  42616. }
  42617. return LegendVisualProvider
  42618. })()
  42619. var LegendVisualProvider$1 = LegendVisualProvider
  42620. var PieSeriesModel = /** @class */ (function (_super) {
  42621. __extends(PieSeriesModel, _super)
  42622. function PieSeriesModel() {
  42623. return (_super !== null && _super.apply(this, arguments)) || this
  42624. }
  42625. /**
  42626. * @overwrite
  42627. */ PieSeriesModel.prototype.init = function (option) {
  42628. _super.prototype.init.apply(this, arguments) // Enable legend selection for each data item
  42629. // Use a function instead of direct access because data reference may changed
  42630. this.legendVisualProvider = new LegendVisualProvider$1(
  42631. bind$1(this.getData, this),
  42632. bind$1(this.getRawData, this)
  42633. )
  42634. this._defaultLabelLine(option)
  42635. }
  42636. /**
  42637. * @overwrite
  42638. */ PieSeriesModel.prototype.mergeOption = function () {
  42639. _super.prototype.mergeOption.apply(this, arguments)
  42640. }
  42641. /**
  42642. * @overwrite
  42643. */ PieSeriesModel.prototype.getInitialData = function () {
  42644. return createSeriesDataSimply(this, {
  42645. coordDimensions: ['value'],
  42646. encodeDefaulter: curry$1(makeSeriesEncodeForNameBased, this)
  42647. })
  42648. }
  42649. /**
  42650. * @overwrite
  42651. */ PieSeriesModel.prototype.getDataParams = function (dataIndex) {
  42652. var data = this.getData()
  42653. var params = _super.prototype.getDataParams.call(this, dataIndex) // FIXME toFixed?
  42654. var valueList = []
  42655. data.each(data.mapDimension('value'), function (value) {
  42656. valueList.push(value)
  42657. })
  42658. params.percent = getPercentWithPrecision(
  42659. valueList,
  42660. dataIndex,
  42661. data.hostModel.get('percentPrecision')
  42662. )
  42663. params.$vars.push('percent')
  42664. return params
  42665. }
  42666. PieSeriesModel.prototype._defaultLabelLine = function (option) {
  42667. // Extend labelLine emphasis
  42668. defaultEmphasis(option, 'labelLine', ['show'])
  42669. var labelLineNormalOpt = option.labelLine
  42670. var labelLineEmphasisOpt = option.emphasis.labelLine // Not show label line if `label.normal.show = false`
  42671. labelLineNormalOpt.show =
  42672. labelLineNormalOpt.show && option.label.show
  42673. labelLineEmphasisOpt.show =
  42674. labelLineEmphasisOpt.show && option.emphasis.label.show
  42675. }
  42676. PieSeriesModel.type = 'series.pie'
  42677. PieSeriesModel.defaultOption = {
  42678. // zlevel: 0,
  42679. z: 2,
  42680. legendHoverLink: true,
  42681. colorBy: 'data', // 默认全局居中
  42682. center: ['50%', '50%'],
  42683. radius: [0, '75%'], // 默认顺时针
  42684. clockwise: true,
  42685. startAngle: 90, // 最小角度改为0
  42686. minAngle: 0, // If the angle of a sector less than `minShowLabelAngle`,
  42687. // the label will not be displayed.
  42688. minShowLabelAngle: 0, // 选中时扇区偏移量
  42689. selectedOffset: 10, // 选择模式,默认关闭,可选single,multiple
  42690. // selectedMode: false,
  42691. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  42692. // roseType: null,
  42693. percentPrecision: 2, // If still show when all data zero.
  42694. stillShowZeroSum: true, // cursor: null,
  42695. left: 0,
  42696. top: 0,
  42697. right: 0,
  42698. bottom: 0,
  42699. width: null,
  42700. height: null,
  42701. label: {
  42702. // color: 'inherit',
  42703. // If rotate around circle
  42704. rotate: 0,
  42705. show: true,
  42706. overflow: 'truncate', // 'outer', 'inside', 'center'
  42707. position: 'outer', // 'none', 'labelLine', 'edge'. Works only when position is 'outer'
  42708. alignTo: 'none', // Closest distance between label and chart edge.
  42709. // Works only position is 'outer' and alignTo is 'edge'.
  42710. edgeDistance: '25%', // Works only position is 'outer' and alignTo is not 'edge'.
  42711. bleedMargin: 10, // Distance between text and label line.
  42712. distanceToLabelLine: 5 // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  42713. // 默认使用全局文本样式,详见TEXTSTYLE
  42714. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  42715. }, // Enabled when label.normal.position is 'outer'
  42716. labelLine: {
  42717. show: true, // 引导线两段中的第一段长度
  42718. length: 15, // 引导线两段中的第二段长度
  42719. length2: 15,
  42720. smooth: false,
  42721. minTurnAngle: 90,
  42722. maxSurfaceAngle: 90,
  42723. lineStyle: {
  42724. // color: 各异,
  42725. width: 1,
  42726. type: 'solid'
  42727. }
  42728. },
  42729. itemStyle: { borderWidth: 1, borderJoin: 'round' },
  42730. showEmptyCircle: true,
  42731. emptyCircleStyle: { color: 'lightgray', opacity: 1 },
  42732. labelLayout: {
  42733. // Hide the overlapped label.
  42734. hideOverlap: true
  42735. },
  42736. emphasis: { scale: true, scaleSize: 5 }, // If use strategy to avoid label overlapping
  42737. avoidLabelOverlap: true, // Animation type. Valid values: expansion, scale
  42738. animationType: 'expansion',
  42739. animationDuration: 1000, // Animation type when update. Valid values: transition, expansion
  42740. animationTypeUpdate: 'transition',
  42741. animationEasingUpdate: 'cubicInOut',
  42742. animationDurationUpdate: 500,
  42743. animationEasing: 'cubicInOut'
  42744. }
  42745. return PieSeriesModel
  42746. })(SeriesModel$1)
  42747. var PieSeriesModel$1 = PieSeriesModel
  42748. function negativeDataFilter(seriesType) {
  42749. return {
  42750. seriesType: seriesType,
  42751. reset: function reset(seriesModel, ecModel) {
  42752. var data = seriesModel.getData()
  42753. data.filterSelf(function (idx) {
  42754. // handle negative value condition
  42755. var valueDim = data.mapDimension('value')
  42756. var curValue = data.get(valueDim, idx)
  42757. if (isNumber(curValue) && !isNaN(curValue) && curValue < 0) {
  42758. return false
  42759. }
  42760. return true
  42761. })
  42762. }
  42763. }
  42764. }
  42765. function install$g(registers) {
  42766. registers.registerChartView(PieView$1)
  42767. registers.registerSeriesModel(PieSeriesModel$1)
  42768. createLegacyDataSelectAction('pie', registers.registerAction)
  42769. registers.registerLayout(curry$1(pieLayout, 'pie'))
  42770. registers.registerProcessor(dataFilter('pie'))
  42771. registers.registerProcessor(negativeDataFilter('pie'))
  42772. }
  42773. var GridModel = /** @class */ (function (_super) {
  42774. __extends(GridModel, _super)
  42775. function GridModel() {
  42776. return (_super !== null && _super.apply(this, arguments)) || this
  42777. }
  42778. GridModel.type = 'grid'
  42779. GridModel.dependencies = ['xAxis', 'yAxis']
  42780. GridModel.layoutMode = 'box'
  42781. GridModel.defaultOption = {
  42782. show: false, // zlevel: 0,
  42783. z: 0,
  42784. left: '10%',
  42785. top: 60,
  42786. right: '10%',
  42787. bottom: 70, // If grid size contain label
  42788. containLabel: false, // width: {totalWidth} - left - right,
  42789. // height: {totalHeight} - top - bottom,
  42790. backgroundColor: 'rgba(0,0,0,0)',
  42791. borderWidth: 1,
  42792. borderColor: '#ccc'
  42793. }
  42794. return GridModel
  42795. })(ComponentModel$1)
  42796. var GridModel$1 = GridModel
  42797. var CartesianAxisModel = /** @class */ (function (_super) {
  42798. __extends(CartesianAxisModel, _super)
  42799. function CartesianAxisModel() {
  42800. return (_super !== null && _super.apply(this, arguments)) || this
  42801. }
  42802. CartesianAxisModel.prototype.getCoordSysModel = function () {
  42803. return this.getReferringComponents('grid', SINGLE_REFERRING)
  42804. .models[0]
  42805. }
  42806. CartesianAxisModel.type = 'cartesian2dAxis'
  42807. return CartesianAxisModel
  42808. })(ComponentModel$1)
  42809. mixin(CartesianAxisModel, AxisModelCommonMixin)
  42810. var defaultOption = {
  42811. show: true, // zlevel: 0,
  42812. z: 0, // Inverse the axis.
  42813. inverse: false, // Axis name displayed.
  42814. name: '', // 'start' | 'middle' | 'end'
  42815. nameLocation: 'end', // By degree. By default auto rotate by nameLocation.
  42816. nameRotate: null,
  42817. nameTruncate: { maxWidth: null, ellipsis: '...', placeholder: '.' }, // Use global text style by default.
  42818. nameTextStyle: {}, // The gap between axisName and axisLine.
  42819. nameGap: 15, // Default `false` to support tooltip.
  42820. silent: false, // Default `false` to avoid legacy user event listener fail.
  42821. triggerEvent: false,
  42822. tooltip: { show: false },
  42823. axisPointer: {},
  42824. axisLine: {
  42825. show: true,
  42826. onZero: true,
  42827. onZeroAxisIndex: null,
  42828. lineStyle: { color: '#6E7079', width: 1, type: 'solid' }, // The arrow at both ends the the axis.
  42829. symbol: ['none', 'none'],
  42830. symbolSize: [10, 15]
  42831. },
  42832. axisTick: {
  42833. show: true, // Whether axisTick is inside the grid or outside the grid.
  42834. inside: false, // The length of axisTick.
  42835. length: 5,
  42836. lineStyle: { width: 1 }
  42837. },
  42838. axisLabel: {
  42839. show: true, // Whether axisLabel is inside the grid or outside the grid.
  42840. inside: false,
  42841. rotate: 0, // true | false | null/undefined (auto)
  42842. showMinLabel: null, // true | false | null/undefined (auto)
  42843. showMaxLabel: null,
  42844. margin: 8, // formatter: null,
  42845. fontSize: 12
  42846. },
  42847. splitLine: {
  42848. show: true,
  42849. lineStyle: { color: ['#E0E6F1'], width: 1, type: 'solid' }
  42850. },
  42851. splitArea: {
  42852. show: false,
  42853. areaStyle: {
  42854. color: ['rgba(250,250,250,0.2)', 'rgba(210,219,238,0.2)']
  42855. }
  42856. }
  42857. }
  42858. var categoryAxis = merge(
  42859. {
  42860. // The gap at both ends of the axis. For categoryAxis, boolean.
  42861. boundaryGap: true, // Set false to faster category collection.
  42862. deduplication: null, // splitArea: {
  42863. // show: false
  42864. // },
  42865. splitLine: { show: false },
  42866. axisTick: {
  42867. // If tick is align with label when boundaryGap is true
  42868. alignWithLabel: false,
  42869. interval: 'auto'
  42870. },
  42871. axisLabel: { interval: 'auto' }
  42872. },
  42873. defaultOption
  42874. )
  42875. var valueAxis = merge(
  42876. {
  42877. boundaryGap: [0, 0],
  42878. axisLine: {
  42879. // Not shown when other axis is categoryAxis in cartesian
  42880. show: 'auto'
  42881. },
  42882. axisTick: {
  42883. // Not shown when other axis is categoryAxis in cartesian
  42884. show: 'auto'
  42885. }, // TODO
  42886. // min/max: [30, datamin, 60] or [20, datamin] or [datamin, 60]
  42887. splitNumber: 5,
  42888. minorTick: {
  42889. // Minor tick, not available for cateogry axis.
  42890. show: false, // Split number of minor ticks. The value should be in range of (0, 100)
  42891. splitNumber: 5, // Lenght of minor tick
  42892. length: 3, // Line style
  42893. lineStyle: {
  42894. // Default to be same with axisTick
  42895. }
  42896. },
  42897. minorSplitLine: {
  42898. show: false,
  42899. lineStyle: { color: '#F4F7FD', width: 1 }
  42900. }
  42901. },
  42902. defaultOption
  42903. )
  42904. var timeAxis = merge(
  42905. {
  42906. splitNumber: 6,
  42907. axisLabel: {
  42908. // To eliminate labels that are not nice
  42909. showMinLabel: false,
  42910. showMaxLabel: false,
  42911. rich: { primary: { fontWeight: 'bold' } }
  42912. },
  42913. splitLine: { show: false }
  42914. },
  42915. valueAxis
  42916. )
  42917. var logAxis = defaults({ logBase: 10 }, valueAxis)
  42918. var axisDefault = {
  42919. category: categoryAxis,
  42920. value: valueAxis,
  42921. time: timeAxis,
  42922. log: logAxis
  42923. }
  42924. /*
  42925. * Licensed to the Apache Software Foundation (ASF) under one
  42926. * or more contributor license agreements. See the NOTICE file
  42927. * distributed with this work for additional information
  42928. * regarding copyright ownership. The ASF licenses this file
  42929. * to you under the Apache License, Version 2.0 (the
  42930. * "License"); you may not use this file except in compliance
  42931. * with the License. You may obtain a copy of the License at
  42932. *
  42933. * http://www.apache.org/licenses/LICENSE-2.0
  42934. *
  42935. * Unless required by applicable law or agreed to in writing,
  42936. * software distributed under the License is distributed on an
  42937. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42938. * KIND, either express or implied. See the License for the
  42939. * specific language governing permissions and limitations
  42940. * under the License.
  42941. */ /**
  42942. * AUTO-GENERATED FILE. DO NOT MODIFY.
  42943. */ /*
  42944. * Licensed to the Apache Software Foundation (ASF) under one
  42945. * or more contributor license agreements. See the NOTICE file
  42946. * distributed with this work for additional information
  42947. * regarding copyright ownership. The ASF licenses this file
  42948. * to you under the Apache License, Version 2.0 (the
  42949. * "License"); you may not use this file except in compliance
  42950. * with the License. You may obtain a copy of the License at
  42951. *
  42952. * http://www.apache.org/licenses/LICENSE-2.0
  42953. *
  42954. * Unless required by applicable law or agreed to in writing,
  42955. * software distributed under the License is distributed on an
  42956. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  42957. * KIND, either express or implied. See the License for the
  42958. * specific language governing permissions and limitations
  42959. * under the License.
  42960. */ var AXIS_TYPES = { value: 1, category: 1, time: 1, log: 1 }
  42961. /**
  42962. * Generate sub axis model class
  42963. * @param axisName 'x' 'y' 'radius' 'angle' 'parallel' ...
  42964. */ function axisModelCreator(
  42965. registers,
  42966. axisName,
  42967. BaseAxisModelClass,
  42968. extraDefaultOption
  42969. ) {
  42970. each$7(AXIS_TYPES, function (v, axisType) {
  42971. var defaultOption = merge(
  42972. merge({}, axisDefault[axisType], true),
  42973. extraDefaultOption,
  42974. true
  42975. )
  42976. var AxisModel = /** @class */ (function (_super) {
  42977. __extends(AxisModel, _super)
  42978. function AxisModel() {
  42979. var _this =
  42980. (_super !== null && _super.apply(this, arguments)) || this
  42981. _this.type = axisName + 'Axis.' + axisType
  42982. return _this
  42983. }
  42984. AxisModel.prototype.mergeDefaultAndTheme = function (
  42985. option,
  42986. ecModel
  42987. ) {
  42988. var layoutMode = fetchLayoutMode(this)
  42989. var inputPositionParams = layoutMode
  42990. ? getLayoutParams(option)
  42991. : {}
  42992. var themeModel = ecModel.getTheme()
  42993. merge(option, themeModel.get(axisType + 'Axis'))
  42994. merge(option, this.getDefaultOption())
  42995. option.type = getAxisType(option)
  42996. if (layoutMode) {
  42997. mergeLayoutParam(option, inputPositionParams, layoutMode)
  42998. }
  42999. }
  43000. AxisModel.prototype.optionUpdated = function () {
  43001. var thisOption = this.option
  43002. if (thisOption.type === 'category') {
  43003. this.__ordinalMeta = OrdinalMeta$1.createByAxisModel(this)
  43004. }
  43005. }
  43006. /**
  43007. * Should not be called before all of 'getInitailData' finished.
  43008. * Because categories are collected during initializing data.
  43009. */ AxisModel.prototype.getCategories = function (rawData) {
  43010. var option = this.option // FIXME
  43011. // warning if called before all of 'getInitailData' finished.
  43012. if (option.type === 'category') {
  43013. if (rawData) {
  43014. return option.data
  43015. }
  43016. return this.__ordinalMeta.categories
  43017. }
  43018. }
  43019. AxisModel.prototype.getOrdinalMeta = function () {
  43020. return this.__ordinalMeta
  43021. }
  43022. AxisModel.type = axisName + 'Axis.' + axisType
  43023. AxisModel.defaultOption = defaultOption
  43024. return AxisModel
  43025. })(BaseAxisModelClass)
  43026. registers.registerComponentModel(AxisModel)
  43027. })
  43028. registers.registerSubTypeDefaulter(axisName + 'Axis', getAxisType)
  43029. }
  43030. function getAxisType(option) {
  43031. // Default axis with data is category axis
  43032. return option.type || (option.data ? 'category' : 'value')
  43033. }
  43034. var Cartesian = /** @class */ (function () {
  43035. function Cartesian(name) {
  43036. this.type = 'cartesian'
  43037. this._dimList = []
  43038. this._axes = {}
  43039. this.name = name || ''
  43040. }
  43041. Cartesian.prototype.getAxis = function (dim) {
  43042. return this._axes[dim]
  43043. }
  43044. Cartesian.prototype.getAxes = function () {
  43045. return map$1(
  43046. this._dimList,
  43047. function (dim) {
  43048. return this._axes[dim]
  43049. },
  43050. this
  43051. )
  43052. }
  43053. Cartesian.prototype.getAxesByScale = function (scaleType) {
  43054. scaleType = scaleType.toLowerCase()
  43055. return filter(this.getAxes(), function (axis) {
  43056. return axis.scale.type === scaleType
  43057. })
  43058. }
  43059. Cartesian.prototype.addAxis = function (axis) {
  43060. var dim = axis.dim
  43061. this._axes[dim] = axis
  43062. this._dimList.push(dim)
  43063. }
  43064. return Cartesian
  43065. })()
  43066. var Cartesian$1 = Cartesian
  43067. var cartesian2DDimensions = ['x', 'y']
  43068. function canCalculateAffineTransform(scale) {
  43069. return scale.type === 'interval' || scale.type === 'time'
  43070. }
  43071. var Cartesian2D = /** @class */ (function (_super) {
  43072. __extends(Cartesian2D, _super)
  43073. function Cartesian2D() {
  43074. var _this =
  43075. (_super !== null && _super.apply(this, arguments)) || this
  43076. _this.type = 'cartesian2d'
  43077. _this.dimensions = cartesian2DDimensions
  43078. return _this
  43079. }
  43080. /**
  43081. * Calculate an affine transform matrix if two axes are time or value.
  43082. * It's mainly for accelartion on the large time series data.
  43083. */ Cartesian2D.prototype.calcAffineTransform = function () {
  43084. this._transform = this._invTransform = null
  43085. var xAxisScale = this.getAxis('x').scale
  43086. var yAxisScale = this.getAxis('y').scale
  43087. if (
  43088. !canCalculateAffineTransform(xAxisScale) ||
  43089. !canCalculateAffineTransform(yAxisScale)
  43090. ) {
  43091. return
  43092. }
  43093. var xScaleExtent = xAxisScale.getExtent()
  43094. var yScaleExtent = yAxisScale.getExtent()
  43095. var start = this.dataToPoint([xScaleExtent[0], yScaleExtent[0]])
  43096. var end = this.dataToPoint([xScaleExtent[1], yScaleExtent[1]])
  43097. var xScaleSpan = xScaleExtent[1] - xScaleExtent[0]
  43098. var yScaleSpan = yScaleExtent[1] - yScaleExtent[0]
  43099. if (!xScaleSpan || !yScaleSpan) {
  43100. return
  43101. } // Accelerate data to point calculation on the special large time series data.
  43102. var scaleX = (end[0] - start[0]) / xScaleSpan
  43103. var scaleY = (end[1] - start[1]) / yScaleSpan
  43104. var translateX = start[0] - xScaleExtent[0] * scaleX
  43105. var translateY = start[1] - yScaleExtent[0] * scaleY
  43106. var m = (this._transform = [
  43107. scaleX,
  43108. 0,
  43109. 0,
  43110. scaleY,
  43111. translateX,
  43112. translateY
  43113. ])
  43114. this._invTransform = invert([], m)
  43115. }
  43116. /**
  43117. * Base axis will be used on stacking.
  43118. */ Cartesian2D.prototype.getBaseAxis = function () {
  43119. return (
  43120. this.getAxesByScale('ordinal')[0] ||
  43121. this.getAxesByScale('time')[0] ||
  43122. this.getAxis('x')
  43123. )
  43124. }
  43125. Cartesian2D.prototype.containPoint = function (point) {
  43126. var axisX = this.getAxis('x')
  43127. var axisY = this.getAxis('y')
  43128. return (
  43129. axisX.contain(axisX.toLocalCoord(point[0])) &&
  43130. axisY.contain(axisY.toLocalCoord(point[1]))
  43131. )
  43132. }
  43133. Cartesian2D.prototype.containData = function (data) {
  43134. return (
  43135. this.getAxis('x').containData(data[0]) &&
  43136. this.getAxis('y').containData(data[1])
  43137. )
  43138. }
  43139. Cartesian2D.prototype.containZone = function (data1, data2) {
  43140. var zoneDiag1 = this.dataToPoint(data1)
  43141. var zoneDiag2 = this.dataToPoint(data2)
  43142. var area = this.getArea()
  43143. var zone = new BoundingRect$1(
  43144. zoneDiag1[0],
  43145. zoneDiag1[1],
  43146. zoneDiag2[0] - zoneDiag1[0],
  43147. zoneDiag2[1] - zoneDiag1[1]
  43148. )
  43149. return area.intersect(zone)
  43150. }
  43151. Cartesian2D.prototype.dataToPoint = function (data, clamp, out) {
  43152. out = out || []
  43153. var xVal = data[0]
  43154. var yVal = data[1] // Fast path
  43155. if (
  43156. this._transform && // It's supported that if data is like `[Inifity, 123]`, where only Y pixel calculated.
  43157. xVal != null &&
  43158. isFinite(xVal) &&
  43159. yVal != null &&
  43160. isFinite(yVal)
  43161. ) {
  43162. return applyTransform$1(out, data, this._transform)
  43163. }
  43164. var xAxis = this.getAxis('x')
  43165. var yAxis = this.getAxis('y')
  43166. out[0] = xAxis.toGlobalCoord(xAxis.dataToCoord(xVal, clamp))
  43167. out[1] = yAxis.toGlobalCoord(yAxis.dataToCoord(yVal, clamp))
  43168. return out
  43169. }
  43170. Cartesian2D.prototype.clampData = function (data, out) {
  43171. var xScale = this.getAxis('x').scale
  43172. var yScale = this.getAxis('y').scale
  43173. var xAxisExtent = xScale.getExtent()
  43174. var yAxisExtent = yScale.getExtent()
  43175. var x = xScale.parse(data[0])
  43176. var y = yScale.parse(data[1])
  43177. out = out || []
  43178. out[0] = Math.min(
  43179. Math.max(Math.min(xAxisExtent[0], xAxisExtent[1]), x),
  43180. Math.max(xAxisExtent[0], xAxisExtent[1])
  43181. )
  43182. out[1] = Math.min(
  43183. Math.max(Math.min(yAxisExtent[0], yAxisExtent[1]), y),
  43184. Math.max(yAxisExtent[0], yAxisExtent[1])
  43185. )
  43186. return out
  43187. }
  43188. Cartesian2D.prototype.pointToData = function (point, clamp) {
  43189. var out = []
  43190. if (this._invTransform) {
  43191. return applyTransform$1(out, point, this._invTransform)
  43192. }
  43193. var xAxis = this.getAxis('x')
  43194. var yAxis = this.getAxis('y')
  43195. out[0] = xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp)
  43196. out[1] = yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  43197. return out
  43198. }
  43199. Cartesian2D.prototype.getOtherAxis = function (axis) {
  43200. return this.getAxis(axis.dim === 'x' ? 'y' : 'x')
  43201. }
  43202. /**
  43203. * Get rect area of cartesian.
  43204. * Area will have a contain function to determine if a point is in the coordinate system.
  43205. */ Cartesian2D.prototype.getArea = function () {
  43206. var xExtent = this.getAxis('x').getGlobalExtent()
  43207. var yExtent = this.getAxis('y').getGlobalExtent()
  43208. var x = Math.min(xExtent[0], xExtent[1])
  43209. var y = Math.min(yExtent[0], yExtent[1])
  43210. var width = Math.max(xExtent[0], xExtent[1]) - x
  43211. var height = Math.max(yExtent[0], yExtent[1]) - y
  43212. return new BoundingRect$1(x, y, width, height)
  43213. }
  43214. return Cartesian2D
  43215. })(Cartesian$1)
  43216. var Cartesian2D$1 = Cartesian2D
  43217. var Axis2D = /** @class */ (function (_super) {
  43218. __extends(Axis2D, _super)
  43219. function Axis2D(dim, scale, coordExtent, axisType, position) {
  43220. var _this = _super.call(this, dim, scale, coordExtent) || this
  43221. /**
  43222. * Index of axis, can be used as key
  43223. * Injected outside.
  43224. */ _this.index = 0
  43225. _this.type = axisType || 'value'
  43226. _this.position = position || 'bottom'
  43227. return _this
  43228. }
  43229. Axis2D.prototype.isHorizontal = function () {
  43230. var position = this.position
  43231. return position === 'top' || position === 'bottom'
  43232. }
  43233. /**
  43234. * Each item cooresponds to this.getExtent(), which
  43235. * means globalExtent[0] may greater than globalExtent[1],
  43236. * unless `asc` is input.
  43237. *
  43238. * @param {boolean} [asc]
  43239. * @return {Array.<number>}
  43240. */ Axis2D.prototype.getGlobalExtent = function (asc) {
  43241. var ret = this.getExtent()
  43242. ret[0] = this.toGlobalCoord(ret[0])
  43243. ret[1] = this.toGlobalCoord(ret[1])
  43244. asc && ret[0] > ret[1] && ret.reverse()
  43245. return ret
  43246. }
  43247. Axis2D.prototype.pointToData = function (point, clamp) {
  43248. return this.coordToData(
  43249. this.toLocalCoord(point[this.dim === 'x' ? 0 : 1]),
  43250. clamp
  43251. )
  43252. }
  43253. /**
  43254. * Set ordinalSortInfo
  43255. * @param info new OrdinalSortInfo
  43256. */ Axis2D.prototype.setCategorySortInfo = function (info) {
  43257. if (this.type !== 'category') {
  43258. return false
  43259. }
  43260. this.model.option.categorySortInfo = info
  43261. this.scale.setSortInfo(info)
  43262. }
  43263. return Axis2D
  43264. })(Axis$1)
  43265. var Axis2D$1 = Axis2D
  43266. /**
  43267. * Can only be called after coordinate system creation stage.
  43268. * (Can be called before coordinate system update stage).
  43269. */ function layout$1(gridModel, axisModel, opt) {
  43270. opt = opt || {}
  43271. var grid = gridModel.coordinateSystem
  43272. var axis = axisModel.axis
  43273. var layout = {}
  43274. var otherAxisOnZeroOf = axis.getAxesOnZeroOf()[0]
  43275. var rawAxisPosition = axis.position
  43276. var axisPosition = otherAxisOnZeroOf ? 'onZero' : rawAxisPosition
  43277. var axisDim = axis.dim
  43278. var rect = grid.getRect()
  43279. var rectBound = [
  43280. rect.x,
  43281. rect.x + rect.width,
  43282. rect.y,
  43283. rect.y + rect.height
  43284. ]
  43285. var idx = { left: 0, right: 1, top: 0, bottom: 1, onZero: 2 }
  43286. var axisOffset = axisModel.get('offset') || 0
  43287. var posBound =
  43288. axisDim === 'x'
  43289. ? [rectBound[2] - axisOffset, rectBound[3] + axisOffset]
  43290. : [rectBound[0] - axisOffset, rectBound[1] + axisOffset]
  43291. if (otherAxisOnZeroOf) {
  43292. var onZeroCoord = otherAxisOnZeroOf.toGlobalCoord(
  43293. otherAxisOnZeroOf.dataToCoord(0)
  43294. )
  43295. posBound[idx.onZero] = Math.max(
  43296. Math.min(onZeroCoord, posBound[1]),
  43297. posBound[0]
  43298. )
  43299. } // Axis position
  43300. layout.position = [
  43301. axisDim === 'y' ? posBound[idx[axisPosition]] : rectBound[0],
  43302. axisDim === 'x' ? posBound[idx[axisPosition]] : rectBound[3]
  43303. ] // Axis rotation
  43304. layout.rotation = (Math.PI / 2) * (axisDim === 'x' ? 0 : 1) // Tick and label direction, x y is axisDim
  43305. var dirMap = { top: -1, bottom: 1, left: -1, right: 1 }
  43306. layout.labelDirection =
  43307. layout.tickDirection =
  43308. layout.nameDirection =
  43309. dirMap[rawAxisPosition]
  43310. layout.labelOffset = otherAxisOnZeroOf
  43311. ? posBound[idx[rawAxisPosition]] - posBound[idx.onZero]
  43312. : 0
  43313. if (axisModel.get(['axisTick', 'inside'])) {
  43314. layout.tickDirection = -layout.tickDirection
  43315. }
  43316. if (
  43317. retrieve(opt.labelInside, axisModel.get(['axisLabel', 'inside']))
  43318. ) {
  43319. layout.labelDirection = -layout.labelDirection
  43320. } // Special label rotation
  43321. var labelRotate = axisModel.get(['axisLabel', 'rotate'])
  43322. layout.labelRotate =
  43323. axisPosition === 'top' ? -labelRotate : labelRotate // Over splitLine and splitArea
  43324. layout.z2 = 1
  43325. return layout
  43326. }
  43327. function isCartesian2DSeries(seriesModel) {
  43328. return seriesModel.get('coordinateSystem') === 'cartesian2d'
  43329. }
  43330. function findAxisModels(seriesModel) {
  43331. var axisModelMap = { xAxisModel: null, yAxisModel: null }
  43332. each$7(axisModelMap, function (v, key) {
  43333. var axisType = key.replace(/Model$/, '')
  43334. var axisModel = seriesModel.getReferringComponents(
  43335. axisType,
  43336. SINGLE_REFERRING
  43337. ).models[0]
  43338. axisModelMap[key] = axisModel
  43339. })
  43340. return axisModelMap
  43341. }
  43342. var mathLog = Math.log
  43343. function alignScaleTicks(scale, axisModel, alignToScale) {
  43344. var intervalScaleProto = IntervalScale$1.prototype // NOTE: There is a precondition for log scale here:
  43345. // In log scale we store _interval and _extent of exponent value.
  43346. // So if we use the method of InternalScale to set/get these data.
  43347. // It process the exponent value, which is linear and what we want here.
  43348. var alignToTicks = intervalScaleProto.getTicks.call(alignToScale)
  43349. var alignToNicedTicks = intervalScaleProto.getTicks.call(
  43350. alignToScale,
  43351. true
  43352. )
  43353. var alignToSplitNumber = alignToTicks.length - 1
  43354. var alignToInterval =
  43355. intervalScaleProto.getInterval.call(alignToScale)
  43356. var scaleExtent = getScaleExtent(scale, axisModel)
  43357. var rawExtent = scaleExtent.extent
  43358. var isMinFixed = scaleExtent.fixMin
  43359. var isMaxFixed = scaleExtent.fixMax
  43360. if (scale.type === 'log') {
  43361. var logBase = mathLog(scale.base)
  43362. rawExtent = [
  43363. mathLog(rawExtent[0]) / logBase,
  43364. mathLog(rawExtent[1]) / logBase
  43365. ]
  43366. }
  43367. scale.setExtent(rawExtent[0], rawExtent[1])
  43368. scale.calcNiceExtent({
  43369. splitNumber: alignToSplitNumber,
  43370. fixMin: isMinFixed,
  43371. fixMax: isMaxFixed
  43372. })
  43373. var extent = intervalScaleProto.getExtent.call(scale) // Need to update the rawExtent.
  43374. // Because value in rawExtent may be not parsed. e.g. 'dataMin', 'dataMax'
  43375. if (isMinFixed) {
  43376. rawExtent[0] = extent[0]
  43377. }
  43378. if (isMaxFixed) {
  43379. rawExtent[1] = extent[1]
  43380. }
  43381. var interval = intervalScaleProto.getInterval.call(scale)
  43382. var min = rawExtent[0]
  43383. var max = rawExtent[1]
  43384. if (isMinFixed && isMaxFixed) {
  43385. // User set min, max, divide to get new interval
  43386. interval = (max - min) / alignToSplitNumber
  43387. } else if (isMinFixed) {
  43388. max = rawExtent[0] + interval * alignToSplitNumber // User set min, expand extent on the other side
  43389. while (
  43390. max < rawExtent[1] &&
  43391. isFinite(max) &&
  43392. isFinite(rawExtent[1])
  43393. ) {
  43394. interval = increaseInterval(interval)
  43395. max = rawExtent[0] + interval * alignToSplitNumber
  43396. }
  43397. } else if (isMaxFixed) {
  43398. // User set max, expand extent on the other side
  43399. min = rawExtent[1] - interval * alignToSplitNumber
  43400. while (
  43401. min > rawExtent[0] &&
  43402. isFinite(min) &&
  43403. isFinite(rawExtent[0])
  43404. ) {
  43405. interval = increaseInterval(interval)
  43406. min = rawExtent[1] - interval * alignToSplitNumber
  43407. }
  43408. } else {
  43409. var nicedSplitNumber = scale.getTicks().length - 1
  43410. if (nicedSplitNumber > alignToSplitNumber) {
  43411. interval = increaseInterval(interval)
  43412. }
  43413. var range = interval * alignToSplitNumber
  43414. max = Math.ceil(rawExtent[1] / interval) * interval
  43415. min = round$1(max - range) // Not change the result that crossing zero.
  43416. if (min < 0 && rawExtent[0] >= 0) {
  43417. min = 0
  43418. max = round$1(range)
  43419. } else if (max > 0 && rawExtent[1] <= 0) {
  43420. max = 0
  43421. min = -round$1(range)
  43422. }
  43423. } // Adjust min, max based on the extent of alignTo. When min or max is set in alignTo scale
  43424. var t0 =
  43425. (alignToTicks[0].value - alignToNicedTicks[0].value) /
  43426. alignToInterval
  43427. var t1 =
  43428. (alignToTicks[alignToSplitNumber].value -
  43429. alignToNicedTicks[alignToSplitNumber].value) /
  43430. alignToInterval // NOTE: Must in setExtent -> setInterval -> setNiceExtent order.
  43431. intervalScaleProto.setExtent.call(
  43432. scale,
  43433. min + interval * t0,
  43434. max + interval * t1
  43435. )
  43436. intervalScaleProto.setInterval.call(scale, interval)
  43437. if (t0 || t1) {
  43438. intervalScaleProto.setNiceExtent.call(
  43439. scale,
  43440. min + interval,
  43441. max - interval
  43442. )
  43443. }
  43444. }
  43445. var Grid = /** @class */ (function () {
  43446. function Grid(gridModel, ecModel, api) {
  43447. // FIXME:TS where used (different from registered type 'cartesian2d')?
  43448. this.type = 'grid'
  43449. this._coordsMap = {}
  43450. this._coordsList = []
  43451. this._axesMap = {}
  43452. this._axesList = []
  43453. this.axisPointerEnabled = true
  43454. this.dimensions = cartesian2DDimensions
  43455. this._initCartesian(gridModel, ecModel, api)
  43456. this.model = gridModel
  43457. }
  43458. Grid.prototype.getRect = function () {
  43459. return this._rect
  43460. }
  43461. Grid.prototype.update = function (ecModel, api) {
  43462. var axesMap = this._axesMap
  43463. this._updateScale(ecModel, this.model)
  43464. function updateAxisTicks(axes) {
  43465. var alignTo // Axis is added in order of axisIndex.
  43466. var axesIndices = keys(axes)
  43467. var len = axesIndices.length
  43468. if (!len) {
  43469. return
  43470. }
  43471. var axisNeedsAlign = [] // Process once and calculate the ticks for those don't use alignTicks.
  43472. for (var i = len - 1; i >= 0; i--) {
  43473. var idx = +axesIndices[i] // Convert to number.
  43474. var axis = axes[idx]
  43475. var model = axis.model
  43476. var scale = axis.scale
  43477. if (
  43478. // Only value and log axis without interval support alignTicks.
  43479. isIntervalOrLogScale(scale) &&
  43480. model.get('alignTicks') &&
  43481. model.get('interval') == null
  43482. ) {
  43483. axisNeedsAlign.push(axis)
  43484. } else {
  43485. niceScaleExtent(scale, model)
  43486. if (isIntervalOrLogScale(scale)) {
  43487. // Can only align to interval or log axis.
  43488. alignTo = axis
  43489. }
  43490. }
  43491. } // PENDING. Should we find the axis that both set interval, min, max and align to this one?
  43492. if (axisNeedsAlign.length) {
  43493. if (!alignTo) {
  43494. alignTo = axisNeedsAlign.pop()
  43495. niceScaleExtent(alignTo.scale, alignTo.model)
  43496. }
  43497. each$7(axisNeedsAlign, function (axis) {
  43498. alignScaleTicks(axis.scale, axis.model, alignTo.scale)
  43499. })
  43500. }
  43501. }
  43502. updateAxisTicks(axesMap.x)
  43503. updateAxisTicks(axesMap.y) // Key: axisDim_axisIndex, value: boolean, whether onZero target.
  43504. var onZeroRecords = {}
  43505. each$7(axesMap.x, function (xAxis) {
  43506. fixAxisOnZero(axesMap, 'y', xAxis, onZeroRecords)
  43507. })
  43508. each$7(axesMap.y, function (yAxis) {
  43509. fixAxisOnZero(axesMap, 'x', yAxis, onZeroRecords)
  43510. }) // Resize again if containLabel is enabled
  43511. // FIXME It may cause getting wrong grid size in data processing stage
  43512. this.resize(this.model, api)
  43513. }
  43514. /**
  43515. * Resize the grid
  43516. */ Grid.prototype.resize = function (
  43517. gridModel,
  43518. api,
  43519. ignoreContainLabel
  43520. ) {
  43521. var boxLayoutParams = gridModel.getBoxLayoutParams()
  43522. var isContainLabel =
  43523. !ignoreContainLabel && gridModel.get('containLabel')
  43524. var gridRect = getLayoutRect(boxLayoutParams, {
  43525. width: api.getWidth(),
  43526. height: api.getHeight()
  43527. })
  43528. this._rect = gridRect
  43529. var axesList = this._axesList
  43530. adjustAxes() // Minus label size
  43531. if (isContainLabel) {
  43532. each$7(axesList, function (axis) {
  43533. if (!axis.model.get(['axisLabel', 'inside'])) {
  43534. var labelUnionRect = estimateLabelUnionRect(axis)
  43535. if (labelUnionRect) {
  43536. var dim = axis.isHorizontal() ? 'height' : 'width'
  43537. var margin = axis.model.get(['axisLabel', 'margin'])
  43538. gridRect[dim] -= labelUnionRect[dim] + margin
  43539. if (axis.position === 'top') {
  43540. gridRect.y += labelUnionRect.height + margin
  43541. } else if (axis.position === 'left') {
  43542. gridRect.x += labelUnionRect.width + margin
  43543. }
  43544. }
  43545. }
  43546. })
  43547. adjustAxes()
  43548. }
  43549. each$7(this._coordsList, function (coord) {
  43550. // Calculate affine matrix to accelerate the data to point transform.
  43551. // If all the axes scales are time or value.
  43552. coord.calcAffineTransform()
  43553. })
  43554. function adjustAxes() {
  43555. each$7(axesList, function (axis) {
  43556. var isHorizontal = axis.isHorizontal()
  43557. var extent = isHorizontal
  43558. ? [0, gridRect.width]
  43559. : [0, gridRect.height]
  43560. var idx = axis.inverse ? 1 : 0
  43561. axis.setExtent(extent[idx], extent[1 - idx])
  43562. updateAxisTransform(
  43563. axis,
  43564. isHorizontal ? gridRect.x : gridRect.y
  43565. )
  43566. })
  43567. }
  43568. }
  43569. Grid.prototype.getAxis = function (dim, axisIndex) {
  43570. var axesMapOnDim = this._axesMap[dim]
  43571. if (axesMapOnDim != null) {
  43572. return axesMapOnDim[axisIndex || 0]
  43573. }
  43574. }
  43575. Grid.prototype.getAxes = function () {
  43576. return this._axesList.slice()
  43577. }
  43578. Grid.prototype.getCartesian = function (xAxisIndex, yAxisIndex) {
  43579. if (xAxisIndex != null && yAxisIndex != null) {
  43580. var key = 'x' + xAxisIndex + 'y' + yAxisIndex
  43581. return this._coordsMap[key]
  43582. }
  43583. if (isObject$2(xAxisIndex)) {
  43584. yAxisIndex = xAxisIndex.yAxisIndex
  43585. xAxisIndex = xAxisIndex.xAxisIndex
  43586. }
  43587. for (
  43588. var i = 0, coordList = this._coordsList;
  43589. i < coordList.length;
  43590. i++
  43591. ) {
  43592. if (
  43593. coordList[i].getAxis('x').index === xAxisIndex ||
  43594. coordList[i].getAxis('y').index === yAxisIndex
  43595. ) {
  43596. return coordList[i]
  43597. }
  43598. }
  43599. }
  43600. Grid.prototype.getCartesians = function () {
  43601. return this._coordsList.slice()
  43602. }
  43603. /**
  43604. * @implements
  43605. */ Grid.prototype.convertToPixel = function (
  43606. ecModel,
  43607. finder,
  43608. value
  43609. ) {
  43610. var target = this._findConvertTarget(finder)
  43611. return target.cartesian
  43612. ? target.cartesian.dataToPoint(value)
  43613. : target.axis
  43614. ? target.axis.toGlobalCoord(target.axis.dataToCoord(value))
  43615. : null
  43616. }
  43617. /**
  43618. * @implements
  43619. */ Grid.prototype.convertFromPixel = function (
  43620. ecModel,
  43621. finder,
  43622. value
  43623. ) {
  43624. var target = this._findConvertTarget(finder)
  43625. return target.cartesian
  43626. ? target.cartesian.pointToData(value)
  43627. : target.axis
  43628. ? target.axis.coordToData(target.axis.toLocalCoord(value))
  43629. : null
  43630. }
  43631. Grid.prototype._findConvertTarget = function (finder) {
  43632. var seriesModel = finder.seriesModel
  43633. var xAxisModel =
  43634. finder.xAxisModel ||
  43635. (seriesModel &&
  43636. seriesModel.getReferringComponents('xAxis', SINGLE_REFERRING)
  43637. .models[0])
  43638. var yAxisModel =
  43639. finder.yAxisModel ||
  43640. (seriesModel &&
  43641. seriesModel.getReferringComponents('yAxis', SINGLE_REFERRING)
  43642. .models[0])
  43643. var gridModel = finder.gridModel
  43644. var coordsList = this._coordsList
  43645. var cartesian
  43646. var axis
  43647. if (seriesModel) {
  43648. cartesian = seriesModel.coordinateSystem
  43649. indexOf(coordsList, cartesian) < 0 && (cartesian = null)
  43650. } else if (xAxisModel && yAxisModel) {
  43651. cartesian = this.getCartesian(
  43652. xAxisModel.componentIndex,
  43653. yAxisModel.componentIndex
  43654. )
  43655. } else if (xAxisModel) {
  43656. axis = this.getAxis('x', xAxisModel.componentIndex)
  43657. } else if (yAxisModel) {
  43658. axis = this.getAxis('y', yAxisModel.componentIndex)
  43659. } // Lowest priority.
  43660. else if (gridModel) {
  43661. var grid = gridModel.coordinateSystem
  43662. if (grid === this) {
  43663. cartesian = this._coordsList[0]
  43664. }
  43665. }
  43666. return { cartesian: cartesian, axis: axis }
  43667. }
  43668. /**
  43669. * @implements
  43670. */ Grid.prototype.containPoint = function (point) {
  43671. var coord = this._coordsList[0]
  43672. if (coord) {
  43673. return coord.containPoint(point)
  43674. }
  43675. }
  43676. /**
  43677. * Initialize cartesian coordinate systems
  43678. */ Grid.prototype._initCartesian = function (
  43679. gridModel,
  43680. ecModel,
  43681. api
  43682. ) {
  43683. var _this = this
  43684. var grid = this
  43685. var axisPositionUsed = {
  43686. left: false,
  43687. right: false,
  43688. top: false,
  43689. bottom: false
  43690. }
  43691. var axesMap = { x: {}, y: {} }
  43692. var axesCount = { x: 0, y: 0 } /// Create axis
  43693. ecModel.eachComponent('xAxis', createAxisCreator('x'), this)
  43694. ecModel.eachComponent('yAxis', createAxisCreator('y'), this)
  43695. if (!axesCount.x || !axesCount.y) {
  43696. // Roll back when there no either x or y axis
  43697. this._axesMap = {}
  43698. this._axesList = []
  43699. return
  43700. }
  43701. this._axesMap = axesMap /// Create cartesian2d
  43702. each$7(axesMap.x, function (xAxis, xAxisIndex) {
  43703. each$7(axesMap.y, function (yAxis, yAxisIndex) {
  43704. var key = 'x' + xAxisIndex + 'y' + yAxisIndex
  43705. var cartesian = new Cartesian2D$1(key)
  43706. cartesian.master = _this
  43707. cartesian.model = gridModel
  43708. _this._coordsMap[key] = cartesian
  43709. _this._coordsList.push(cartesian)
  43710. cartesian.addAxis(xAxis)
  43711. cartesian.addAxis(yAxis)
  43712. })
  43713. })
  43714. function createAxisCreator(dimName) {
  43715. return function (axisModel, idx) {
  43716. if (!isAxisUsedInTheGrid(axisModel, gridModel)) {
  43717. return
  43718. }
  43719. var axisPosition = axisModel.get('position')
  43720. if (dimName === 'x') {
  43721. // Fix position
  43722. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  43723. // Default bottom of X
  43724. axisPosition = axisPositionUsed.bottom ? 'top' : 'bottom'
  43725. }
  43726. } else {
  43727. // Fix position
  43728. if (axisPosition !== 'left' && axisPosition !== 'right') {
  43729. // Default left of Y
  43730. axisPosition = axisPositionUsed.left ? 'right' : 'left'
  43731. }
  43732. }
  43733. axisPositionUsed[axisPosition] = true
  43734. var axis = new Axis2D$1(
  43735. dimName,
  43736. createScaleByModel(axisModel),
  43737. [0, 0],
  43738. axisModel.get('type'),
  43739. axisPosition
  43740. )
  43741. var isCategory = axis.type === 'category'
  43742. axis.onBand = isCategory && axisModel.get('boundaryGap')
  43743. axis.inverse = axisModel.get('inverse') // Inject axis into axisModel
  43744. axisModel.axis = axis // Inject axisModel into axis
  43745. axis.model = axisModel // Inject grid info axis
  43746. axis.grid = grid // Index of axis, can be used as key
  43747. axis.index = idx
  43748. grid._axesList.push(axis)
  43749. axesMap[dimName][idx] = axis
  43750. axesCount[dimName]++
  43751. }
  43752. }
  43753. }
  43754. /**
  43755. * Update cartesian properties from series.
  43756. */ Grid.prototype._updateScale = function (ecModel, gridModel) {
  43757. // Reset scale
  43758. each$7(this._axesList, function (axis) {
  43759. axis.scale.setExtent(Infinity, -Infinity)
  43760. if (axis.type === 'category') {
  43761. var categorySortInfo = axis.model.get('categorySortInfo')
  43762. axis.scale.setSortInfo(categorySortInfo)
  43763. }
  43764. })
  43765. ecModel.eachSeries(function (seriesModel) {
  43766. if (isCartesian2DSeries(seriesModel)) {
  43767. var axesModelMap = findAxisModels(seriesModel)
  43768. var xAxisModel = axesModelMap.xAxisModel
  43769. var yAxisModel = axesModelMap.yAxisModel
  43770. if (
  43771. !isAxisUsedInTheGrid(xAxisModel, gridModel) ||
  43772. !isAxisUsedInTheGrid(yAxisModel, gridModel)
  43773. ) {
  43774. return
  43775. }
  43776. var cartesian = this.getCartesian(
  43777. xAxisModel.componentIndex,
  43778. yAxisModel.componentIndex
  43779. )
  43780. var data = seriesModel.getData()
  43781. var xAxis = cartesian.getAxis('x')
  43782. var yAxis = cartesian.getAxis('y')
  43783. unionExtent(data, xAxis)
  43784. unionExtent(data, yAxis)
  43785. }
  43786. }, this)
  43787. function unionExtent(data, axis) {
  43788. each$7(getDataDimensionsOnAxis(data, axis.dim), function (dim) {
  43789. axis.scale.unionExtentFromData(data, dim)
  43790. })
  43791. }
  43792. }
  43793. /**
  43794. * @param dim 'x' or 'y' or 'auto' or null/undefined
  43795. */ Grid.prototype.getTooltipAxes = function (dim) {
  43796. var baseAxes = []
  43797. var otherAxes = []
  43798. each$7(this.getCartesians(), function (cartesian) {
  43799. var baseAxis =
  43800. dim != null && dim !== 'auto'
  43801. ? cartesian.getAxis(dim)
  43802. : cartesian.getBaseAxis()
  43803. var otherAxis = cartesian.getOtherAxis(baseAxis)
  43804. indexOf(baseAxes, baseAxis) < 0 && baseAxes.push(baseAxis)
  43805. indexOf(otherAxes, otherAxis) < 0 && otherAxes.push(otherAxis)
  43806. })
  43807. return { baseAxes: baseAxes, otherAxes: otherAxes }
  43808. }
  43809. Grid.create = function (ecModel, api) {
  43810. var grids = []
  43811. ecModel.eachComponent('grid', function (gridModel, idx) {
  43812. var grid = new Grid(gridModel, ecModel, api)
  43813. grid.name = 'grid_' + idx // dataSampling requires axis extent, so resize
  43814. // should be performed in create stage.
  43815. grid.resize(gridModel, api, true)
  43816. gridModel.coordinateSystem = grid
  43817. grids.push(grid)
  43818. }) // Inject the coordinateSystems into seriesModel
  43819. ecModel.eachSeries(function (seriesModel) {
  43820. if (!isCartesian2DSeries(seriesModel)) {
  43821. return
  43822. }
  43823. var axesModelMap = findAxisModels(seriesModel)
  43824. var xAxisModel = axesModelMap.xAxisModel
  43825. var yAxisModel = axesModelMap.yAxisModel
  43826. var gridModel = xAxisModel.getCoordSysModel()
  43827. var grid = gridModel.coordinateSystem
  43828. seriesModel.coordinateSystem = grid.getCartesian(
  43829. xAxisModel.componentIndex,
  43830. yAxisModel.componentIndex
  43831. )
  43832. })
  43833. return grids
  43834. } // For deciding which dimensions to use when creating list data
  43835. Grid.dimensions = cartesian2DDimensions
  43836. return Grid
  43837. })()
  43838. /**
  43839. * Check if the axis is used in the specified grid.
  43840. */ function isAxisUsedInTheGrid(axisModel, gridModel) {
  43841. return axisModel.getCoordSysModel() === gridModel
  43842. }
  43843. function fixAxisOnZero(
  43844. axesMap,
  43845. otherAxisDim,
  43846. axis, // Key: see `getOnZeroRecordKey`
  43847. onZeroRecords
  43848. ) {
  43849. axis.getAxesOnZeroOf = function () {
  43850. // TODO: onZero of multiple axes.
  43851. return otherAxisOnZeroOf ? [otherAxisOnZeroOf] : []
  43852. } // onZero can not be enabled in these two situations:
  43853. // 1. When any other axis is a category axis.
  43854. // 2. When no axis is cross 0 point.
  43855. var otherAxes = axesMap[otherAxisDim]
  43856. var otherAxisOnZeroOf
  43857. var axisModel = axis.model
  43858. var onZero = axisModel.get(['axisLine', 'onZero'])
  43859. var onZeroAxisIndex = axisModel.get(['axisLine', 'onZeroAxisIndex'])
  43860. if (!onZero) {
  43861. return
  43862. } // If target axis is specified.
  43863. if (onZeroAxisIndex != null) {
  43864. if (canOnZeroToAxis(otherAxes[onZeroAxisIndex])) {
  43865. otherAxisOnZeroOf = otherAxes[onZeroAxisIndex]
  43866. }
  43867. } else {
  43868. // Find the first available other axis.
  43869. for (var idx in otherAxes) {
  43870. if (
  43871. otherAxes.hasOwnProperty(idx) &&
  43872. canOnZeroToAxis(otherAxes[idx]) && // Consider that two Y axes on one value axis,
  43873. // if both onZero, the two Y axes overlap.
  43874. !onZeroRecords[getOnZeroRecordKey(otherAxes[idx])]
  43875. ) {
  43876. otherAxisOnZeroOf = otherAxes[idx]
  43877. break
  43878. }
  43879. }
  43880. }
  43881. if (otherAxisOnZeroOf) {
  43882. onZeroRecords[getOnZeroRecordKey(otherAxisOnZeroOf)] = true
  43883. }
  43884. function getOnZeroRecordKey(axis) {
  43885. return axis.dim + '_' + axis.index
  43886. }
  43887. }
  43888. function canOnZeroToAxis(axis) {
  43889. return (
  43890. axis &&
  43891. axis.type !== 'category' &&
  43892. axis.type !== 'time' &&
  43893. ifAxisCrossZero(axis)
  43894. )
  43895. }
  43896. function updateAxisTransform(axis, coordBase) {
  43897. var axisExtent = axis.getExtent()
  43898. var axisExtentSum = axisExtent[0] + axisExtent[1] // Fast transform
  43899. axis.toGlobalCoord =
  43900. axis.dim === 'x'
  43901. ? function (coord) {
  43902. return coord + coordBase
  43903. }
  43904. : function (coord) {
  43905. return axisExtentSum - coord + coordBase
  43906. }
  43907. axis.toLocalCoord =
  43908. axis.dim === 'x'
  43909. ? function (coord) {
  43910. return coord - coordBase
  43911. }
  43912. : function (coord) {
  43913. return axisExtentSum - coord + coordBase
  43914. }
  43915. }
  43916. var Grid$1 = Grid
  43917. var PI = Math.PI
  43918. /**
  43919. * A final axis is translated and rotated from a "standard axis".
  43920. * So opt.position and opt.rotation is required.
  43921. *
  43922. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  43923. * for example: (0, 0) ------------> (0, 50)
  43924. *
  43925. * nameDirection or tickDirection or labelDirection is 1 means tick
  43926. * or label is below the standard axis, whereas is -1 means above
  43927. * the standard axis. labelOffset means offset between label and axis,
  43928. * which is useful when 'onZero', where axisLabel is in the grid and
  43929. * label in outside grid.
  43930. *
  43931. * Tips: like always,
  43932. * positive rotation represents anticlockwise, and negative rotation
  43933. * represents clockwise.
  43934. * The direction of position coordinate is the same as the direction
  43935. * of screen coordinate.
  43936. *
  43937. * Do not need to consider axis 'inverse', which is auto processed by
  43938. * axis extent.
  43939. */ var AxisBuilder = /** @class */ (function () {
  43940. function AxisBuilder(axisModel, opt) {
  43941. this.group = new Group$3()
  43942. this.opt = opt
  43943. this.axisModel = axisModel // Default value
  43944. defaults(opt, {
  43945. labelOffset: 0,
  43946. nameDirection: 1,
  43947. tickDirection: 1,
  43948. labelDirection: 1,
  43949. silent: true,
  43950. handleAutoShown: function handleAutoShown() {
  43951. return true
  43952. }
  43953. }) // FIXME Not use a seperate text group?
  43954. var transformGroup = new Group$3({
  43955. x: opt.position[0],
  43956. y: opt.position[1],
  43957. rotation: opt.rotation
  43958. }) // this.group.add(transformGroup);
  43959. // this._transformGroup = transformGroup;
  43960. transformGroup.updateTransform()
  43961. this._transformGroup = transformGroup
  43962. }
  43963. AxisBuilder.prototype.hasBuilder = function (name) {
  43964. return !!builders[name]
  43965. }
  43966. AxisBuilder.prototype.add = function (name) {
  43967. builders[name](
  43968. this.opt,
  43969. this.axisModel,
  43970. this.group,
  43971. this._transformGroup
  43972. )
  43973. }
  43974. AxisBuilder.prototype.getGroup = function () {
  43975. return this.group
  43976. }
  43977. AxisBuilder.innerTextLayout = function (
  43978. axisRotation,
  43979. textRotation,
  43980. direction
  43981. ) {
  43982. var rotationDiff = remRadian(textRotation - axisRotation)
  43983. var textAlign
  43984. var textVerticalAlign
  43985. if (isRadianAroundZero(rotationDiff)) {
  43986. // Label is parallel with axis line.
  43987. textVerticalAlign = direction > 0 ? 'top' : 'bottom'
  43988. textAlign = 'center'
  43989. } else if (isRadianAroundZero(rotationDiff - PI)) {
  43990. // Label is inverse parallel with axis line.
  43991. textVerticalAlign = direction > 0 ? 'bottom' : 'top'
  43992. textAlign = 'center'
  43993. } else {
  43994. textVerticalAlign = 'middle'
  43995. if (rotationDiff > 0 && rotationDiff < PI) {
  43996. textAlign = direction > 0 ? 'right' : 'left'
  43997. } else {
  43998. textAlign = direction > 0 ? 'left' : 'right'
  43999. }
  44000. }
  44001. return {
  44002. rotation: rotationDiff,
  44003. textAlign: textAlign,
  44004. textVerticalAlign: textVerticalAlign
  44005. }
  44006. }
  44007. AxisBuilder.makeAxisEventDataBase = function (axisModel) {
  44008. var eventData = {
  44009. componentType: axisModel.mainType,
  44010. componentIndex: axisModel.componentIndex
  44011. }
  44012. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex
  44013. return eventData
  44014. }
  44015. AxisBuilder.isLabelSilent = function (axisModel) {
  44016. var tooltipOpt = axisModel.get('tooltip')
  44017. return (
  44018. axisModel.get('silent') || // Consider mouse cursor, add these restrictions.
  44019. !(
  44020. axisModel.get('triggerEvent') ||
  44021. (tooltipOpt && tooltipOpt.show)
  44022. )
  44023. )
  44024. }
  44025. return AxisBuilder
  44026. })()
  44027. var builders = {
  44028. axisLine: function axisLine(opt, axisModel, group, transformGroup) {
  44029. var shown = axisModel.get(['axisLine', 'show'])
  44030. if (shown === 'auto' && opt.handleAutoShown) {
  44031. shown = opt.handleAutoShown('axisLine')
  44032. }
  44033. if (!shown) {
  44034. return
  44035. }
  44036. var extent = axisModel.axis.getExtent()
  44037. var matrix = transformGroup.transform
  44038. var pt1 = [extent[0], 0]
  44039. var pt2 = [extent[1], 0]
  44040. if (matrix) {
  44041. applyTransform$1(pt1, pt1, matrix)
  44042. applyTransform$1(pt2, pt2, matrix)
  44043. }
  44044. var lineStyle = extend(
  44045. { lineCap: 'round' },
  44046. axisModel.getModel(['axisLine', 'lineStyle']).getLineStyle()
  44047. )
  44048. var line = new Line$1({
  44049. // Id for animation
  44050. subPixelOptimize: true,
  44051. shape: { x1: pt1[0], y1: pt1[1], x2: pt2[0], y2: pt2[1] },
  44052. style: lineStyle,
  44053. strokeContainThreshold: opt.strokeContainThreshold || 5,
  44054. silent: true,
  44055. z2: 1
  44056. })
  44057. line.anid = 'line'
  44058. group.add(line)
  44059. var arrows = axisModel.get(['axisLine', 'symbol'])
  44060. if (arrows != null) {
  44061. var arrowSize = axisModel.get(['axisLine', 'symbolSize'])
  44062. if (isString(arrows)) {
  44063. // Use the same arrow for start and end point
  44064. arrows = [arrows, arrows]
  44065. }
  44066. if (isString(arrowSize) || isNumber(arrowSize)) {
  44067. // Use the same size for width and height
  44068. arrowSize = [arrowSize, arrowSize]
  44069. }
  44070. var arrowOffset = normalizeSymbolOffset(
  44071. axisModel.get(['axisLine', 'symbolOffset']) || 0,
  44072. arrowSize
  44073. )
  44074. var symbolWidth_1 = arrowSize[0]
  44075. var symbolHeight_1 = arrowSize[1]
  44076. each$7(
  44077. [
  44078. {
  44079. rotate: opt.rotation + Math.PI / 2,
  44080. offset: arrowOffset[0],
  44081. r: 0
  44082. },
  44083. {
  44084. rotate: opt.rotation - Math.PI / 2,
  44085. offset: arrowOffset[1],
  44086. r: Math.sqrt(
  44087. (pt1[0] - pt2[0]) * (pt1[0] - pt2[0]) +
  44088. (pt1[1] - pt2[1]) * (pt1[1] - pt2[1])
  44089. )
  44090. }
  44091. ],
  44092. function (point, index) {
  44093. if (arrows[index] !== 'none' && arrows[index] != null) {
  44094. var symbol = createSymbol(
  44095. arrows[index],
  44096. -symbolWidth_1 / 2,
  44097. -symbolHeight_1 / 2,
  44098. symbolWidth_1,
  44099. symbolHeight_1,
  44100. lineStyle.stroke,
  44101. true
  44102. ) // Calculate arrow position with offset
  44103. var r = point.r + point.offset
  44104. symbol.attr({
  44105. rotation: point.rotate,
  44106. x: pt1[0] + r * Math.cos(opt.rotation),
  44107. y: pt1[1] - r * Math.sin(opt.rotation),
  44108. silent: true,
  44109. z2: 11
  44110. })
  44111. group.add(symbol)
  44112. }
  44113. }
  44114. )
  44115. }
  44116. },
  44117. axisTickLabel: function axisTickLabel(
  44118. opt,
  44119. axisModel,
  44120. group,
  44121. transformGroup
  44122. ) {
  44123. var ticksEls = buildAxisMajorTicks(
  44124. group,
  44125. transformGroup,
  44126. axisModel,
  44127. opt
  44128. )
  44129. var labelEls = buildAxisLabel(
  44130. group,
  44131. transformGroup,
  44132. axisModel,
  44133. opt
  44134. )
  44135. fixMinMaxLabelShow(axisModel, labelEls, ticksEls)
  44136. buildAxisMinorTicks(
  44137. group,
  44138. transformGroup,
  44139. axisModel,
  44140. opt.tickDirection
  44141. ) // This bit fixes the label overlap issue for the time chart.
  44142. // See https://github.com/apache/echarts/issues/14266 for more.
  44143. if (axisModel.get(['axisLabel', 'hideOverlap'])) {
  44144. var labelList = prepareLayoutList(
  44145. map$1(labelEls, function (label) {
  44146. return {
  44147. label: label,
  44148. priority: label.z2,
  44149. defaultAttr: { ignore: label.ignore }
  44150. }
  44151. })
  44152. )
  44153. hideOverlap(labelList)
  44154. }
  44155. },
  44156. axisName: function axisName(opt, axisModel, group, transformGroup) {
  44157. var name = retrieve(opt.axisName, axisModel.get('name'))
  44158. if (!name) {
  44159. return
  44160. }
  44161. var nameLocation = axisModel.get('nameLocation')
  44162. var nameDirection = opt.nameDirection
  44163. var textStyleModel = axisModel.getModel('nameTextStyle')
  44164. var gap = axisModel.get('nameGap') || 0
  44165. var extent = axisModel.axis.getExtent()
  44166. var gapSignal = extent[0] > extent[1] ? -1 : 1
  44167. var pos = [
  44168. nameLocation === 'start'
  44169. ? extent[0] - gapSignal * gap
  44170. : nameLocation === 'end'
  44171. ? extent[1] + gapSignal * gap
  44172. : (extent[0] + extent[1]) / 2, // Reuse labelOffset.
  44173. isNameLocationCenter(nameLocation)
  44174. ? opt.labelOffset + nameDirection * gap
  44175. : 0
  44176. ]
  44177. var labelLayout
  44178. var nameRotation = axisModel.get('nameRotate')
  44179. if (nameRotation != null) {
  44180. nameRotation = (nameRotation * PI) / 180 // To radian.
  44181. }
  44182. var axisNameAvailableWidth
  44183. if (isNameLocationCenter(nameLocation)) {
  44184. labelLayout = AxisBuilder.innerTextLayout(
  44185. opt.rotation,
  44186. nameRotation != null ? nameRotation : opt.rotation, // Adapt to axis.
  44187. nameDirection
  44188. )
  44189. } else {
  44190. labelLayout = endTextLayout(
  44191. opt.rotation,
  44192. nameLocation,
  44193. nameRotation || 0,
  44194. extent
  44195. )
  44196. axisNameAvailableWidth = opt.axisNameAvailableWidth
  44197. if (axisNameAvailableWidth != null) {
  44198. axisNameAvailableWidth = Math.abs(
  44199. axisNameAvailableWidth / Math.sin(labelLayout.rotation)
  44200. )
  44201. !isFinite(axisNameAvailableWidth) &&
  44202. (axisNameAvailableWidth = null)
  44203. }
  44204. }
  44205. var textFont = textStyleModel.getFont()
  44206. var truncateOpt = axisModel.get('nameTruncate', true) || {}
  44207. var ellipsis = truncateOpt.ellipsis
  44208. var maxWidth = retrieve(
  44209. opt.nameTruncateMaxWidth,
  44210. truncateOpt.maxWidth,
  44211. axisNameAvailableWidth
  44212. )
  44213. var textEl = new ZRText$1({
  44214. x: pos[0],
  44215. y: pos[1],
  44216. rotation: labelLayout.rotation,
  44217. silent: AxisBuilder.isLabelSilent(axisModel),
  44218. style: createTextStyle(textStyleModel, {
  44219. text: name,
  44220. font: textFont,
  44221. overflow: 'truncate',
  44222. width: maxWidth,
  44223. ellipsis: ellipsis,
  44224. fill:
  44225. textStyleModel.getTextColor() ||
  44226. axisModel.get(['axisLine', 'lineStyle', 'color']),
  44227. align: textStyleModel.get('align') || labelLayout.textAlign,
  44228. verticalAlign:
  44229. textStyleModel.get('verticalAlign') ||
  44230. labelLayout.textVerticalAlign
  44231. }),
  44232. z2: 1
  44233. })
  44234. setTooltipConfig({
  44235. el: textEl,
  44236. componentModel: axisModel,
  44237. itemName: name
  44238. })
  44239. textEl.__fullText = name // Id for animation
  44240. textEl.anid = 'name'
  44241. if (axisModel.get('triggerEvent')) {
  44242. var eventData = AxisBuilder.makeAxisEventDataBase(axisModel)
  44243. eventData.targetType = 'axisName'
  44244. eventData.name = name
  44245. getECData(textEl).eventData = eventData
  44246. } // FIXME
  44247. transformGroup.add(textEl)
  44248. textEl.updateTransform()
  44249. group.add(textEl)
  44250. textEl.decomposeTransform()
  44251. }
  44252. }
  44253. function endTextLayout(rotation, textPosition, textRotate, extent) {
  44254. var rotationDiff = remRadian(textRotate - rotation)
  44255. var textAlign
  44256. var textVerticalAlign
  44257. var inverse = extent[0] > extent[1]
  44258. var onLeft =
  44259. (textPosition === 'start' && !inverse) ||
  44260. (textPosition !== 'start' && inverse)
  44261. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  44262. textVerticalAlign = onLeft ? 'bottom' : 'top'
  44263. textAlign = 'center'
  44264. } else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  44265. textVerticalAlign = onLeft ? 'top' : 'bottom'
  44266. textAlign = 'center'
  44267. } else {
  44268. textVerticalAlign = 'middle'
  44269. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  44270. textAlign = onLeft ? 'left' : 'right'
  44271. } else {
  44272. textAlign = onLeft ? 'right' : 'left'
  44273. }
  44274. }
  44275. return {
  44276. rotation: rotationDiff,
  44277. textAlign: textAlign,
  44278. textVerticalAlign: textVerticalAlign
  44279. }
  44280. }
  44281. function fixMinMaxLabelShow(axisModel, labelEls, tickEls) {
  44282. if (shouldShowAllLabels(axisModel.axis)) {
  44283. return
  44284. } // If min or max are user set, we need to check
  44285. // If the tick on min(max) are overlap on their neighbour tick
  44286. // If they are overlapped, we need to hide the min(max) tick label
  44287. var showMinLabel = axisModel.get(['axisLabel', 'showMinLabel'])
  44288. var showMaxLabel = axisModel.get(['axisLabel', 'showMaxLabel']) // FIXME
  44289. // Have not consider onBand yet, where tick els is more than label els.
  44290. labelEls = labelEls || []
  44291. tickEls = tickEls || []
  44292. var firstLabel = labelEls[0]
  44293. var nextLabel = labelEls[1]
  44294. var lastLabel = labelEls[labelEls.length - 1]
  44295. var prevLabel = labelEls[labelEls.length - 2]
  44296. var firstTick = tickEls[0]
  44297. var nextTick = tickEls[1]
  44298. var lastTick = tickEls[tickEls.length - 1]
  44299. var prevTick = tickEls[tickEls.length - 2]
  44300. if (showMinLabel === false) {
  44301. ignoreEl(firstLabel)
  44302. ignoreEl(firstTick)
  44303. } else if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  44304. if (showMinLabel) {
  44305. ignoreEl(nextLabel)
  44306. ignoreEl(nextTick)
  44307. } else {
  44308. ignoreEl(firstLabel)
  44309. ignoreEl(firstTick)
  44310. }
  44311. }
  44312. if (showMaxLabel === false) {
  44313. ignoreEl(lastLabel)
  44314. ignoreEl(lastTick)
  44315. } else if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  44316. if (showMaxLabel) {
  44317. ignoreEl(prevLabel)
  44318. ignoreEl(prevTick)
  44319. } else {
  44320. ignoreEl(lastLabel)
  44321. ignoreEl(lastTick)
  44322. }
  44323. }
  44324. }
  44325. function ignoreEl(el) {
  44326. el && (el.ignore = true)
  44327. }
  44328. function isTwoLabelOverlapped(current, next) {
  44329. // current and next has the same rotation.
  44330. var firstRect = current && current.getBoundingRect().clone()
  44331. var nextRect = next && next.getBoundingRect().clone()
  44332. if (!firstRect || !nextRect) {
  44333. return
  44334. } // When checking intersect of two rotated labels, we use mRotationBack
  44335. // to avoid that boundingRect is enlarge when using `boundingRect.applyTransform`.
  44336. var mRotationBack = identity([])
  44337. rotate(mRotationBack, mRotationBack, -current.rotation)
  44338. firstRect.applyTransform(
  44339. mul([], mRotationBack, current.getLocalTransform())
  44340. )
  44341. nextRect.applyTransform(
  44342. mul([], mRotationBack, next.getLocalTransform())
  44343. )
  44344. return firstRect.intersect(nextRect)
  44345. }
  44346. function isNameLocationCenter(nameLocation) {
  44347. return nameLocation === 'middle' || nameLocation === 'center'
  44348. }
  44349. function createTicks(
  44350. ticksCoords,
  44351. tickTransform,
  44352. tickEndCoord,
  44353. tickLineStyle,
  44354. anidPrefix
  44355. ) {
  44356. var tickEls = []
  44357. var pt1 = []
  44358. var pt2 = []
  44359. for (var i = 0; i < ticksCoords.length; i++) {
  44360. var tickCoord = ticksCoords[i].coord
  44361. pt1[0] = tickCoord
  44362. pt1[1] = 0
  44363. pt2[0] = tickCoord
  44364. pt2[1] = tickEndCoord
  44365. if (tickTransform) {
  44366. applyTransform$1(pt1, pt1, tickTransform)
  44367. applyTransform$1(pt2, pt2, tickTransform)
  44368. } // Tick line, Not use group transform to have better line draw
  44369. var tickEl = new Line$1({
  44370. subPixelOptimize: true,
  44371. shape: { x1: pt1[0], y1: pt1[1], x2: pt2[0], y2: pt2[1] },
  44372. style: tickLineStyle,
  44373. z2: 2,
  44374. autoBatch: true,
  44375. silent: true
  44376. })
  44377. tickEl.anid = anidPrefix + '_' + ticksCoords[i].tickValue
  44378. tickEls.push(tickEl)
  44379. }
  44380. return tickEls
  44381. }
  44382. function buildAxisMajorTicks(group, transformGroup, axisModel, opt) {
  44383. var axis = axisModel.axis
  44384. var tickModel = axisModel.getModel('axisTick')
  44385. var shown = tickModel.get('show')
  44386. if (shown === 'auto' && opt.handleAutoShown) {
  44387. shown = opt.handleAutoShown('axisTick')
  44388. }
  44389. if (!shown || axis.scale.isBlank()) {
  44390. return
  44391. }
  44392. var lineStyleModel = tickModel.getModel('lineStyle')
  44393. var tickEndCoord = opt.tickDirection * tickModel.get('length')
  44394. var ticksCoords = axis.getTicksCoords()
  44395. var ticksEls = createTicks(
  44396. ticksCoords,
  44397. transformGroup.transform,
  44398. tickEndCoord,
  44399. defaults(lineStyleModel.getLineStyle(), {
  44400. stroke: axisModel.get(['axisLine', 'lineStyle', 'color'])
  44401. }),
  44402. 'ticks'
  44403. )
  44404. for (var i = 0; i < ticksEls.length; i++) {
  44405. group.add(ticksEls[i])
  44406. }
  44407. return ticksEls
  44408. }
  44409. function buildAxisMinorTicks(
  44410. group,
  44411. transformGroup,
  44412. axisModel,
  44413. tickDirection
  44414. ) {
  44415. var axis = axisModel.axis
  44416. var minorTickModel = axisModel.getModel('minorTick')
  44417. if (!minorTickModel.get('show') || axis.scale.isBlank()) {
  44418. return
  44419. }
  44420. var minorTicksCoords = axis.getMinorTicksCoords()
  44421. if (!minorTicksCoords.length) {
  44422. return
  44423. }
  44424. var lineStyleModel = minorTickModel.getModel('lineStyle')
  44425. var tickEndCoord = tickDirection * minorTickModel.get('length')
  44426. var minorTickLineStyle = defaults(
  44427. lineStyleModel.getLineStyle(),
  44428. defaults(axisModel.getModel('axisTick').getLineStyle(), {
  44429. stroke: axisModel.get(['axisLine', 'lineStyle', 'color'])
  44430. })
  44431. )
  44432. for (var i = 0; i < minorTicksCoords.length; i++) {
  44433. var minorTicksEls = createTicks(
  44434. minorTicksCoords[i],
  44435. transformGroup.transform,
  44436. tickEndCoord,
  44437. minorTickLineStyle,
  44438. 'minorticks_' + i
  44439. )
  44440. for (var k = 0; k < minorTicksEls.length; k++) {
  44441. group.add(minorTicksEls[k])
  44442. }
  44443. }
  44444. }
  44445. function buildAxisLabel(group, transformGroup, axisModel, opt) {
  44446. var axis = axisModel.axis
  44447. var show = retrieve(
  44448. opt.axisLabelShow,
  44449. axisModel.get(['axisLabel', 'show'])
  44450. )
  44451. if (!show || axis.scale.isBlank()) {
  44452. return
  44453. }
  44454. var labelModel = axisModel.getModel('axisLabel')
  44455. var labelMargin = labelModel.get('margin')
  44456. var labels = axis.getViewLabels() // Special label rotate.
  44457. var labelRotation =
  44458. ((retrieve(opt.labelRotate, labelModel.get('rotate')) || 0) *
  44459. PI) /
  44460. 180
  44461. var labelLayout = AxisBuilder.innerTextLayout(
  44462. opt.rotation,
  44463. labelRotation,
  44464. opt.labelDirection
  44465. )
  44466. var rawCategoryData =
  44467. axisModel.getCategories && axisModel.getCategories(true)
  44468. var labelEls = []
  44469. var silent = AxisBuilder.isLabelSilent(axisModel)
  44470. var triggerEvent = axisModel.get('triggerEvent')
  44471. each$7(labels, function (labelItem, index) {
  44472. var tickValue =
  44473. axis.scale.type === 'ordinal'
  44474. ? axis.scale.getRawOrdinalNumber(labelItem.tickValue)
  44475. : labelItem.tickValue
  44476. var formattedLabel = labelItem.formattedLabel
  44477. var rawLabel = labelItem.rawLabel
  44478. var itemLabelModel = labelModel
  44479. if (rawCategoryData && rawCategoryData[tickValue]) {
  44480. var rawCategoryItem = rawCategoryData[tickValue]
  44481. if (isObject$2(rawCategoryItem) && rawCategoryItem.textStyle) {
  44482. itemLabelModel = new Model$1(
  44483. rawCategoryItem.textStyle,
  44484. labelModel,
  44485. axisModel.ecModel
  44486. )
  44487. }
  44488. }
  44489. var textColor =
  44490. itemLabelModel.getTextColor() ||
  44491. axisModel.get(['axisLine', 'lineStyle', 'color'])
  44492. var tickCoord = axis.dataToCoord(tickValue)
  44493. var textEl = new ZRText$1({
  44494. x: tickCoord,
  44495. y: opt.labelOffset + opt.labelDirection * labelMargin,
  44496. rotation: labelLayout.rotation,
  44497. silent: silent,
  44498. z2: 10 + (labelItem.level || 0),
  44499. style: createTextStyle(itemLabelModel, {
  44500. text: formattedLabel,
  44501. align:
  44502. itemLabelModel.getShallow('align', true) ||
  44503. labelLayout.textAlign,
  44504. verticalAlign:
  44505. itemLabelModel.getShallow('verticalAlign', true) ||
  44506. itemLabelModel.getShallow('baseline', true) ||
  44507. labelLayout.textVerticalAlign,
  44508. fill: isFunction(textColor)
  44509. ? textColor(
  44510. // (1) In category axis with data zoom, tick is not the original
  44511. // index of axis.data. So tick should not be exposed to user
  44512. // in category axis.
  44513. // (2) Compatible with previous version, which always use formatted label as
  44514. // input. But in interval scale the formatted label is like '223,445', which
  44515. // maked user repalce ','. So we modify it to return original val but remain
  44516. // it as 'string' to avoid error in replacing.
  44517. axis.type === 'category'
  44518. ? rawLabel
  44519. : axis.type === 'value'
  44520. ? tickValue + ''
  44521. : tickValue,
  44522. index
  44523. )
  44524. : textColor
  44525. })
  44526. })
  44527. textEl.anid = 'label_' + tickValue // Pack data for mouse event
  44528. if (triggerEvent) {
  44529. var eventData = AxisBuilder.makeAxisEventDataBase(axisModel)
  44530. eventData.targetType = 'axisLabel'
  44531. eventData.value = rawLabel
  44532. eventData.tickIndex = index
  44533. if (axis.type === 'category') {
  44534. eventData.dataIndex = tickValue
  44535. }
  44536. getECData(textEl).eventData = eventData
  44537. } // FIXME
  44538. transformGroup.add(textEl)
  44539. textEl.updateTransform()
  44540. labelEls.push(textEl)
  44541. group.add(textEl)
  44542. textEl.decomposeTransform()
  44543. })
  44544. return labelEls
  44545. }
  44546. var AxisBuilder$1 = AxisBuilder // allAxesInfo should be updated when setOption performed.
  44547. function collect(ecModel, api) {
  44548. var result = {
  44549. /**
  44550. * key: makeKey(axis.model)
  44551. * value: {
  44552. * axis,
  44553. * coordSys,
  44554. * axisPointerModel,
  44555. * triggerTooltip,
  44556. * involveSeries,
  44557. * snap,
  44558. * seriesModels,
  44559. * seriesDataCount
  44560. * }
  44561. */ axesInfo: {},
  44562. seriesInvolved: false,
  44563. /**
  44564. * key: makeKey(coordSys.model)
  44565. * value: Object: key makeKey(axis.model), value: axisInfo
  44566. */ coordSysAxesInfo: {},
  44567. coordSysMap: {}
  44568. }
  44569. collectAxesInfo(result, ecModel, api) // Check seriesInvolved for performance, in case too many series in some chart.
  44570. result.seriesInvolved && collectSeriesInfo(result, ecModel)
  44571. return result
  44572. }
  44573. function collectAxesInfo(result, ecModel, api) {
  44574. var globalTooltipModel = ecModel.getComponent('tooltip')
  44575. var globalAxisPointerModel = ecModel.getComponent('axisPointer') // links can only be set on global.
  44576. var linksOption = globalAxisPointerModel.get('link', true) || []
  44577. var linkGroups = [] // Collect axes info.
  44578. each$7(api.getCoordinateSystems(), function (coordSys) {
  44579. // Some coordinate system do not support axes, like geo.
  44580. if (!coordSys.axisPointerEnabled) {
  44581. return
  44582. }
  44583. var coordSysKey = makeKey(coordSys.model)
  44584. var axesInfoInCoordSys = (result.coordSysAxesInfo[coordSysKey] =
  44585. {})
  44586. result.coordSysMap[coordSysKey] = coordSys // Set tooltip (like 'cross') is a convienent way to show axisPointer
  44587. // for user. So we enable seting tooltip on coordSys model.
  44588. var coordSysModel = coordSys.model
  44589. var baseTooltipModel = coordSysModel.getModel(
  44590. 'tooltip',
  44591. globalTooltipModel
  44592. )
  44593. each$7(
  44594. coordSys.getAxes(),
  44595. curry$1(saveTooltipAxisInfo, false, null)
  44596. ) // If axis tooltip used, choose tooltip axis for each coordSys.
  44597. // Notice this case: coordSys is `grid` but not `cartesian2D` here.
  44598. if (
  44599. coordSys.getTooltipAxes &&
  44600. globalTooltipModel && // If tooltip.showContent is set as false, tooltip will not
  44601. // show but axisPointer will show as normal.
  44602. baseTooltipModel.get('show')
  44603. ) {
  44604. // Compatible with previous logic. But series.tooltip.trigger: 'axis'
  44605. // or series.data[n].tooltip.trigger: 'axis' are not support any more.
  44606. var triggerAxis = baseTooltipModel.get('trigger') === 'axis'
  44607. var cross =
  44608. baseTooltipModel.get(['axisPointer', 'type']) === 'cross'
  44609. var tooltipAxes = coordSys.getTooltipAxes(
  44610. baseTooltipModel.get(['axisPointer', 'axis'])
  44611. )
  44612. if (triggerAxis || cross) {
  44613. each$7(
  44614. tooltipAxes.baseAxes,
  44615. curry$1(
  44616. saveTooltipAxisInfo,
  44617. cross ? 'cross' : true,
  44618. triggerAxis
  44619. )
  44620. )
  44621. }
  44622. if (cross) {
  44623. each$7(
  44624. tooltipAxes.otherAxes,
  44625. curry$1(saveTooltipAxisInfo, 'cross', false)
  44626. )
  44627. }
  44628. } // fromTooltip: true | false | 'cross'
  44629. // triggerTooltip: true | false | null
  44630. function saveTooltipAxisInfo(fromTooltip, triggerTooltip, axis) {
  44631. var axisPointerModel = axis.model.getModel(
  44632. 'axisPointer',
  44633. globalAxisPointerModel
  44634. )
  44635. var axisPointerShow = axisPointerModel.get('show')
  44636. if (
  44637. !axisPointerShow ||
  44638. (axisPointerShow === 'auto' &&
  44639. !fromTooltip &&
  44640. !isHandleTrigger(axisPointerModel))
  44641. ) {
  44642. return
  44643. }
  44644. if (triggerTooltip == null) {
  44645. triggerTooltip = axisPointerModel.get('triggerTooltip')
  44646. }
  44647. axisPointerModel = fromTooltip
  44648. ? makeAxisPointerModel(
  44649. axis,
  44650. baseTooltipModel,
  44651. globalAxisPointerModel,
  44652. ecModel,
  44653. fromTooltip,
  44654. triggerTooltip
  44655. )
  44656. : axisPointerModel
  44657. var snap = axisPointerModel.get('snap')
  44658. var axisKey = makeKey(axis.model)
  44659. var involveSeries =
  44660. triggerTooltip || snap || axis.type === 'category' // If result.axesInfo[key] exist, override it (tooltip has higher priority).
  44661. var axisInfo = (result.axesInfo[axisKey] = {
  44662. key: axisKey,
  44663. axis: axis,
  44664. coordSys: coordSys,
  44665. axisPointerModel: axisPointerModel,
  44666. triggerTooltip: triggerTooltip,
  44667. involveSeries: involveSeries,
  44668. snap: snap,
  44669. useHandle: isHandleTrigger(axisPointerModel),
  44670. seriesModels: [],
  44671. linkGroup: null
  44672. })
  44673. axesInfoInCoordSys[axisKey] = axisInfo
  44674. result.seriesInvolved = result.seriesInvolved || involveSeries
  44675. var groupIndex = getLinkGroupIndex(linksOption, axis)
  44676. if (groupIndex != null) {
  44677. var linkGroup =
  44678. linkGroups[groupIndex] ||
  44679. (linkGroups[groupIndex] = { axesInfo: {} })
  44680. linkGroup.axesInfo[axisKey] = axisInfo
  44681. linkGroup.mapper = linksOption[groupIndex].mapper
  44682. axisInfo.linkGroup = linkGroup
  44683. }
  44684. }
  44685. })
  44686. }
  44687. function makeAxisPointerModel(
  44688. axis,
  44689. baseTooltipModel,
  44690. globalAxisPointerModel,
  44691. ecModel,
  44692. fromTooltip,
  44693. triggerTooltip
  44694. ) {
  44695. var tooltipAxisPointerModel =
  44696. baseTooltipModel.getModel('axisPointer')
  44697. var fields = [
  44698. 'type',
  44699. 'snap',
  44700. 'lineStyle',
  44701. 'shadowStyle',
  44702. 'label',
  44703. 'animation',
  44704. 'animationDurationUpdate',
  44705. 'animationEasingUpdate',
  44706. 'z'
  44707. ]
  44708. var volatileOption = {}
  44709. each$7(fields, function (field) {
  44710. volatileOption[field] = clone$3(
  44711. tooltipAxisPointerModel.get(field)
  44712. )
  44713. }) // category axis do not auto snap, otherwise some tick that do not
  44714. // has value can not be hovered. value/time/log axis default snap if
  44715. // triggered from tooltip and trigger tooltip.
  44716. volatileOption.snap = axis.type !== 'category' && !!triggerTooltip // Compatibel with previous behavior, tooltip axis do not show label by default.
  44717. // Only these properties can be overrided from tooltip to axisPointer.
  44718. if (tooltipAxisPointerModel.get('type') === 'cross') {
  44719. volatileOption.type = 'line'
  44720. }
  44721. var labelOption =
  44722. volatileOption.label || (volatileOption.label = {}) // Follow the convention, do not show label when triggered by tooltip by default.
  44723. labelOption.show == null && (labelOption.show = false)
  44724. if (fromTooltip === 'cross') {
  44725. // When 'cross', both axes show labels.
  44726. var tooltipAxisPointerLabelShow = tooltipAxisPointerModel.get([
  44727. 'label',
  44728. 'show'
  44729. ])
  44730. labelOption.show =
  44731. tooltipAxisPointerLabelShow != null
  44732. ? tooltipAxisPointerLabelShow
  44733. : true // If triggerTooltip, this is a base axis, which should better not use cross style
  44734. // (cross style is dashed by default)
  44735. if (!triggerTooltip) {
  44736. var crossStyle = (volatileOption.lineStyle =
  44737. tooltipAxisPointerModel.get('crossStyle'))
  44738. crossStyle && defaults(labelOption, crossStyle.textStyle)
  44739. }
  44740. }
  44741. return axis.model.getModel(
  44742. 'axisPointer',
  44743. new Model$1(volatileOption, globalAxisPointerModel, ecModel)
  44744. )
  44745. }
  44746. function collectSeriesInfo(result, ecModel) {
  44747. // Prepare data for axis trigger
  44748. ecModel.eachSeries(function (seriesModel) {
  44749. // Notice this case: this coordSys is `cartesian2D` but not `grid`.
  44750. var coordSys = seriesModel.coordinateSystem
  44751. var seriesTooltipTrigger = seriesModel.get(
  44752. ['tooltip', 'trigger'],
  44753. true
  44754. )
  44755. var seriesTooltipShow = seriesModel.get(['tooltip', 'show'], true)
  44756. if (
  44757. !coordSys ||
  44758. seriesTooltipTrigger === 'none' ||
  44759. seriesTooltipTrigger === false ||
  44760. seriesTooltipTrigger === 'item' ||
  44761. seriesTooltipShow === false ||
  44762. seriesModel.get(['axisPointer', 'show'], true) === false
  44763. ) {
  44764. return
  44765. }
  44766. each$7(
  44767. result.coordSysAxesInfo[makeKey(coordSys.model)],
  44768. function (axisInfo) {
  44769. var axis = axisInfo.axis
  44770. if (coordSys.getAxis(axis.dim) === axis) {
  44771. axisInfo.seriesModels.push(seriesModel)
  44772. axisInfo.seriesDataCount == null &&
  44773. (axisInfo.seriesDataCount = 0)
  44774. axisInfo.seriesDataCount += seriesModel.getData().count()
  44775. }
  44776. }
  44777. )
  44778. })
  44779. }
  44780. /**
  44781. * For example:
  44782. * {
  44783. * axisPointer: {
  44784. * links: [{
  44785. * xAxisIndex: [2, 4],
  44786. * yAxisIndex: 'all'
  44787. * }, {
  44788. * xAxisId: ['a5', 'a7'],
  44789. * xAxisName: 'xxx'
  44790. * }]
  44791. * }
  44792. * }
  44793. */ function getLinkGroupIndex(linksOption, axis) {
  44794. var axisModel = axis.model
  44795. var dim = axis.dim
  44796. for (var i = 0; i < linksOption.length; i++) {
  44797. var linkOption = linksOption[i] || {}
  44798. if (
  44799. checkPropInLink(linkOption[dim + 'AxisId'], axisModel.id) ||
  44800. checkPropInLink(
  44801. linkOption[dim + 'AxisIndex'],
  44802. axisModel.componentIndex
  44803. ) ||
  44804. checkPropInLink(linkOption[dim + 'AxisName'], axisModel.name)
  44805. ) {
  44806. return i
  44807. }
  44808. }
  44809. }
  44810. function checkPropInLink(linkPropValue, axisPropValue) {
  44811. return (
  44812. linkPropValue === 'all' ||
  44813. (isArray(linkPropValue) &&
  44814. indexOf(linkPropValue, axisPropValue) >= 0) ||
  44815. linkPropValue === axisPropValue
  44816. )
  44817. }
  44818. function fixValue(axisModel) {
  44819. var axisInfo = getAxisInfo(axisModel)
  44820. if (!axisInfo) {
  44821. return
  44822. }
  44823. var axisPointerModel = axisInfo.axisPointerModel
  44824. var scale = axisInfo.axis.scale
  44825. var option = axisPointerModel.option
  44826. var status = axisPointerModel.get('status')
  44827. var value = axisPointerModel.get('value') // Parse init value for category and time axis.
  44828. if (value != null) {
  44829. value = scale.parse(value)
  44830. }
  44831. var useHandle = isHandleTrigger(axisPointerModel) // If `handle` used, `axisPointer` will always be displayed, so value
  44832. // and status should be initialized.
  44833. if (status == null) {
  44834. option.status = useHandle ? 'show' : 'hide'
  44835. }
  44836. var extent = scale.getExtent().slice()
  44837. extent[0] > extent[1] && extent.reverse()
  44838. if (
  44839. // Pick a value on axis when initializing.
  44840. value == null || // If both `handle` and `dataZoom` are used, value may be out of axis extent,
  44841. // where we should re-pick a value to keep `handle` displaying normally.
  44842. value > extent[1]
  44843. ) {
  44844. // Make handle displayed on the end of the axis when init, which looks better.
  44845. value = extent[1]
  44846. }
  44847. if (value < extent[0]) {
  44848. value = extent[0]
  44849. }
  44850. option.value = value
  44851. if (useHandle) {
  44852. option.status = axisInfo.axis.scale.isBlank() ? 'hide' : 'show'
  44853. }
  44854. }
  44855. function getAxisInfo(axisModel) {
  44856. var coordSysAxesInfo = (
  44857. axisModel.ecModel.getComponent('axisPointer') || {}
  44858. ).coordSysAxesInfo
  44859. return (
  44860. coordSysAxesInfo && coordSysAxesInfo.axesInfo[makeKey(axisModel)]
  44861. )
  44862. }
  44863. function getAxisPointerModel(axisModel) {
  44864. var axisInfo = getAxisInfo(axisModel)
  44865. return axisInfo && axisInfo.axisPointerModel
  44866. }
  44867. function isHandleTrigger(axisPointerModel) {
  44868. return !!axisPointerModel.get(['handle', 'show'])
  44869. }
  44870. /**
  44871. * @param {module:echarts/model/Model} model
  44872. * @return {string} unique key
  44873. */ function makeKey(model) {
  44874. return model.type + '||' + model.id
  44875. }
  44876. var axisPointerClazz = {}
  44877. /**
  44878. * Base class of AxisView.
  44879. */ var AxisView = /** @class */ (function (_super) {
  44880. __extends(AxisView, _super)
  44881. function AxisView() {
  44882. var _this =
  44883. (_super !== null && _super.apply(this, arguments)) || this
  44884. _this.type = AxisView.type
  44885. return _this
  44886. }
  44887. /**
  44888. * @override
  44889. */ AxisView.prototype.render = function (
  44890. axisModel,
  44891. ecModel,
  44892. api,
  44893. payload
  44894. ) {
  44895. // FIXME
  44896. // This process should proformed after coordinate systems updated
  44897. // (axis scale updated), and should be performed each time update.
  44898. // So put it here temporarily, although it is not appropriate to
  44899. // put a model-writing procedure in `view`.
  44900. this.axisPointerClass && fixValue(axisModel)
  44901. _super.prototype.render.apply(this, arguments)
  44902. this._doUpdateAxisPointerClass(axisModel, api, true)
  44903. }
  44904. /**
  44905. * Action handler.
  44906. */ AxisView.prototype.updateAxisPointer = function (
  44907. axisModel,
  44908. ecModel,
  44909. api,
  44910. payload
  44911. ) {
  44912. this._doUpdateAxisPointerClass(axisModel, api, false)
  44913. }
  44914. /**
  44915. * @override
  44916. */ AxisView.prototype.remove = function (ecModel, api) {
  44917. var axisPointer = this._axisPointer
  44918. axisPointer && axisPointer.remove(api)
  44919. }
  44920. /**
  44921. * @override
  44922. */ AxisView.prototype.dispose = function (ecModel, api) {
  44923. this._disposeAxisPointer(api)
  44924. _super.prototype.dispose.apply(this, arguments)
  44925. }
  44926. AxisView.prototype._doUpdateAxisPointerClass = function (
  44927. axisModel,
  44928. api,
  44929. forceRender
  44930. ) {
  44931. var Clazz = AxisView.getAxisPointerClass(this.axisPointerClass)
  44932. if (!Clazz) {
  44933. return
  44934. }
  44935. var axisPointerModel = getAxisPointerModel(axisModel)
  44936. axisPointerModel
  44937. ? (
  44938. this._axisPointer || (this._axisPointer = new Clazz())
  44939. ).render(axisModel, axisPointerModel, api, forceRender)
  44940. : this._disposeAxisPointer(api)
  44941. }
  44942. AxisView.prototype._disposeAxisPointer = function (api) {
  44943. this._axisPointer && this._axisPointer.dispose(api)
  44944. this._axisPointer = null
  44945. }
  44946. AxisView.registerAxisPointerClass = function (type, clazz) {
  44947. axisPointerClazz[type] = clazz
  44948. }
  44949. AxisView.getAxisPointerClass = function (type) {
  44950. return type && axisPointerClazz[type]
  44951. }
  44952. AxisView.type = 'axis'
  44953. return AxisView
  44954. })(ComponentView$1)
  44955. var AxisView$1 = AxisView
  44956. var inner$5 = makeInner()
  44957. function rectCoordAxisBuildSplitArea(
  44958. axisView,
  44959. axisGroup,
  44960. axisModel,
  44961. gridModel
  44962. ) {
  44963. var axis = axisModel.axis
  44964. if (axis.scale.isBlank()) {
  44965. return
  44966. } // TODO: TYPE
  44967. var splitAreaModel = axisModel.getModel('splitArea')
  44968. var areaStyleModel = splitAreaModel.getModel('areaStyle')
  44969. var areaColors = areaStyleModel.get('color')
  44970. var gridRect = gridModel.coordinateSystem.getRect()
  44971. var ticksCoords = axis.getTicksCoords({
  44972. tickModel: splitAreaModel,
  44973. clamp: true
  44974. })
  44975. if (!ticksCoords.length) {
  44976. return
  44977. } // For Making appropriate splitArea animation, the color and anid
  44978. // should be corresponding to previous one if possible.
  44979. var areaColorsLen = areaColors.length
  44980. var lastSplitAreaColors = inner$5(axisView).splitAreaColors
  44981. var newSplitAreaColors = createHashMap()
  44982. var colorIndex = 0
  44983. if (lastSplitAreaColors) {
  44984. for (var i = 0; i < ticksCoords.length; i++) {
  44985. var cIndex = lastSplitAreaColors.get(ticksCoords[i].tickValue)
  44986. if (cIndex != null) {
  44987. colorIndex =
  44988. (cIndex + (areaColorsLen - 1) * i) % areaColorsLen
  44989. break
  44990. }
  44991. }
  44992. }
  44993. var prev = axis.toGlobalCoord(ticksCoords[0].coord)
  44994. var areaStyle = areaStyleModel.getAreaStyle()
  44995. areaColors = isArray(areaColors) ? areaColors : [areaColors]
  44996. for (var i = 1; i < ticksCoords.length; i++) {
  44997. var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord)
  44998. var x = void 0
  44999. var y = void 0
  45000. var width = void 0
  45001. var height = void 0
  45002. if (axis.isHorizontal()) {
  45003. x = prev
  45004. y = gridRect.y
  45005. width = tickCoord - x
  45006. height = gridRect.height
  45007. prev = x + width
  45008. } else {
  45009. x = gridRect.x
  45010. y = prev
  45011. width = gridRect.width
  45012. height = tickCoord - y
  45013. prev = y + height
  45014. }
  45015. var tickValue = ticksCoords[i - 1].tickValue
  45016. tickValue != null && newSplitAreaColors.set(tickValue, colorIndex)
  45017. axisGroup.add(
  45018. new Rect$2({
  45019. anid: tickValue != null ? 'area_' + tickValue : null,
  45020. shape: { x: x, y: y, width: width, height: height },
  45021. style: defaults({ fill: areaColors[colorIndex] }, areaStyle),
  45022. autoBatch: true,
  45023. silent: true
  45024. })
  45025. )
  45026. colorIndex = (colorIndex + 1) % areaColorsLen
  45027. }
  45028. inner$5(axisView).splitAreaColors = newSplitAreaColors
  45029. }
  45030. function rectCoordAxisHandleRemove(axisView) {
  45031. inner$5(axisView).splitAreaColors = null
  45032. }
  45033. var axisBuilderAttrs = ['axisLine', 'axisTickLabel', 'axisName']
  45034. var selfBuilderAttrs = ['splitArea', 'splitLine', 'minorSplitLine']
  45035. var CartesianAxisView = /** @class */ (function (_super) {
  45036. __extends(CartesianAxisView, _super)
  45037. function CartesianAxisView() {
  45038. var _this =
  45039. (_super !== null && _super.apply(this, arguments)) || this
  45040. _this.type = CartesianAxisView.type
  45041. _this.axisPointerClass = 'CartesianAxisPointer'
  45042. return _this
  45043. }
  45044. /**
  45045. * @override
  45046. */ CartesianAxisView.prototype.render = function (
  45047. axisModel,
  45048. ecModel,
  45049. api,
  45050. payload
  45051. ) {
  45052. this.group.removeAll()
  45053. var oldAxisGroup = this._axisGroup
  45054. this._axisGroup = new Group$3()
  45055. this.group.add(this._axisGroup)
  45056. if (!axisModel.get('show')) {
  45057. return
  45058. }
  45059. var gridModel = axisModel.getCoordSysModel()
  45060. var layout = layout$1(gridModel, axisModel)
  45061. var axisBuilder = new AxisBuilder$1(
  45062. axisModel,
  45063. extend(
  45064. {
  45065. handleAutoShown: function handleAutoShown(elementType) {
  45066. var cartesians =
  45067. gridModel.coordinateSystem.getCartesians()
  45068. for (var i = 0; i < cartesians.length; i++) {
  45069. if (
  45070. isIntervalOrLogScale(
  45071. cartesians[i].getOtherAxis(axisModel.axis).scale
  45072. )
  45073. ) {
  45074. // Still show axis tick or axisLine if other axis is value / log
  45075. return true
  45076. }
  45077. } // Not show axisTick or axisLine if other axis is category / time
  45078. return false
  45079. }
  45080. },
  45081. layout
  45082. )
  45083. )
  45084. each$7(axisBuilderAttrs, axisBuilder.add, axisBuilder)
  45085. this._axisGroup.add(axisBuilder.getGroup())
  45086. each$7(
  45087. selfBuilderAttrs,
  45088. function (name) {
  45089. if (axisModel.get([name, 'show'])) {
  45090. axisElementBuilders[name](
  45091. this,
  45092. this._axisGroup,
  45093. axisModel,
  45094. gridModel
  45095. )
  45096. }
  45097. },
  45098. this
  45099. ) // THIS is a special case for bar racing chart.
  45100. // Update the axis label from the natural initial layout to
  45101. // sorted layout should has no animation.
  45102. var isInitialSortFromBarRacing =
  45103. payload &&
  45104. payload.type === 'changeAxisOrder' &&
  45105. payload.isInitSort
  45106. if (!isInitialSortFromBarRacing) {
  45107. groupTransition(oldAxisGroup, this._axisGroup, axisModel)
  45108. }
  45109. _super.prototype.render.call(
  45110. this,
  45111. axisModel,
  45112. ecModel,
  45113. api,
  45114. payload
  45115. )
  45116. }
  45117. CartesianAxisView.prototype.remove = function () {
  45118. rectCoordAxisHandleRemove(this)
  45119. }
  45120. CartesianAxisView.type = 'cartesianAxis'
  45121. return CartesianAxisView
  45122. })(AxisView$1)
  45123. var axisElementBuilders = {
  45124. splitLine: function splitLine(
  45125. axisView,
  45126. axisGroup,
  45127. axisModel,
  45128. gridModel
  45129. ) {
  45130. var axis = axisModel.axis
  45131. if (axis.scale.isBlank()) {
  45132. return
  45133. }
  45134. var splitLineModel = axisModel.getModel('splitLine')
  45135. var lineStyleModel = splitLineModel.getModel('lineStyle')
  45136. var lineColors = lineStyleModel.get('color')
  45137. lineColors = isArray(lineColors) ? lineColors : [lineColors]
  45138. var gridRect = gridModel.coordinateSystem.getRect()
  45139. var isHorizontal = axis.isHorizontal()
  45140. var lineCount = 0
  45141. var ticksCoords = axis.getTicksCoords({
  45142. tickModel: splitLineModel
  45143. })
  45144. var p1 = []
  45145. var p2 = []
  45146. var lineStyle = lineStyleModel.getLineStyle()
  45147. for (var i = 0; i < ticksCoords.length; i++) {
  45148. var tickCoord = axis.toGlobalCoord(ticksCoords[i].coord)
  45149. if (isHorizontal) {
  45150. p1[0] = tickCoord
  45151. p1[1] = gridRect.y
  45152. p2[0] = tickCoord
  45153. p2[1] = gridRect.y + gridRect.height
  45154. } else {
  45155. p1[0] = gridRect.x
  45156. p1[1] = tickCoord
  45157. p2[0] = gridRect.x + gridRect.width
  45158. p2[1] = tickCoord
  45159. }
  45160. var colorIndex = lineCount++ % lineColors.length
  45161. var tickValue = ticksCoords[i].tickValue
  45162. axisGroup.add(
  45163. new Line$1({
  45164. anid:
  45165. tickValue != null
  45166. ? 'line_' + ticksCoords[i].tickValue
  45167. : null,
  45168. subPixelOptimize: true,
  45169. autoBatch: true,
  45170. shape: { x1: p1[0], y1: p1[1], x2: p2[0], y2: p2[1] },
  45171. style: defaults(
  45172. { stroke: lineColors[colorIndex] },
  45173. lineStyle
  45174. ),
  45175. silent: true
  45176. })
  45177. )
  45178. }
  45179. },
  45180. minorSplitLine: function minorSplitLine(
  45181. axisView,
  45182. axisGroup,
  45183. axisModel,
  45184. gridModel
  45185. ) {
  45186. var axis = axisModel.axis
  45187. var minorSplitLineModel = axisModel.getModel('minorSplitLine')
  45188. var lineStyleModel = minorSplitLineModel.getModel('lineStyle')
  45189. var gridRect = gridModel.coordinateSystem.getRect()
  45190. var isHorizontal = axis.isHorizontal()
  45191. var minorTicksCoords = axis.getMinorTicksCoords()
  45192. if (!minorTicksCoords.length) {
  45193. return
  45194. }
  45195. var p1 = []
  45196. var p2 = []
  45197. var lineStyle = lineStyleModel.getLineStyle()
  45198. for (var i = 0; i < minorTicksCoords.length; i++) {
  45199. for (var k = 0; k < minorTicksCoords[i].length; k++) {
  45200. var tickCoord = axis.toGlobalCoord(
  45201. minorTicksCoords[i][k].coord
  45202. )
  45203. if (isHorizontal) {
  45204. p1[0] = tickCoord
  45205. p1[1] = gridRect.y
  45206. p2[0] = tickCoord
  45207. p2[1] = gridRect.y + gridRect.height
  45208. } else {
  45209. p1[0] = gridRect.x
  45210. p1[1] = tickCoord
  45211. p2[0] = gridRect.x + gridRect.width
  45212. p2[1] = tickCoord
  45213. }
  45214. axisGroup.add(
  45215. new Line$1({
  45216. anid: 'minor_line_' + minorTicksCoords[i][k].tickValue,
  45217. subPixelOptimize: true,
  45218. autoBatch: true,
  45219. shape: { x1: p1[0], y1: p1[1], x2: p2[0], y2: p2[1] },
  45220. style: lineStyle,
  45221. silent: true
  45222. })
  45223. )
  45224. }
  45225. }
  45226. },
  45227. splitArea: function splitArea(
  45228. axisView,
  45229. axisGroup,
  45230. axisModel,
  45231. gridModel
  45232. ) {
  45233. rectCoordAxisBuildSplitArea(
  45234. axisView,
  45235. axisGroup,
  45236. axisModel,
  45237. gridModel
  45238. )
  45239. }
  45240. }
  45241. var CartesianXAxisView = /** @class */ (function (_super) {
  45242. __extends(CartesianXAxisView, _super)
  45243. function CartesianXAxisView() {
  45244. var _this =
  45245. (_super !== null && _super.apply(this, arguments)) || this
  45246. _this.type = CartesianXAxisView.type
  45247. return _this
  45248. }
  45249. CartesianXAxisView.type = 'xAxis'
  45250. return CartesianXAxisView
  45251. })(CartesianAxisView)
  45252. var CartesianYAxisView = /** @class */ (function (_super) {
  45253. __extends(CartesianYAxisView, _super)
  45254. function CartesianYAxisView() {
  45255. var _this =
  45256. (_super !== null && _super.apply(this, arguments)) || this
  45257. _this.type = CartesianXAxisView.type
  45258. return _this
  45259. }
  45260. CartesianYAxisView.type = 'yAxis'
  45261. return CartesianYAxisView
  45262. })(CartesianAxisView)
  45263. var GridView = /** @class */ (function (_super) {
  45264. __extends(GridView, _super)
  45265. function GridView() {
  45266. var _this =
  45267. (_super !== null && _super.apply(this, arguments)) || this
  45268. _this.type = 'grid'
  45269. return _this
  45270. }
  45271. GridView.prototype.render = function (gridModel, ecModel) {
  45272. this.group.removeAll()
  45273. if (gridModel.get('show')) {
  45274. this.group.add(
  45275. new Rect$2({
  45276. shape: gridModel.coordinateSystem.getRect(),
  45277. style: defaults(
  45278. { fill: gridModel.get('backgroundColor') },
  45279. gridModel.getItemStyle()
  45280. ),
  45281. silent: true,
  45282. z2: -1
  45283. })
  45284. )
  45285. }
  45286. }
  45287. GridView.type = 'grid'
  45288. return GridView
  45289. })(ComponentView$1)
  45290. var extraOption = {
  45291. // gridIndex: 0,
  45292. // gridId: '',
  45293. offset: 0
  45294. }
  45295. function install$f(registers) {
  45296. registers.registerComponentView(GridView)
  45297. registers.registerComponentModel(GridModel$1)
  45298. registers.registerCoordinateSystem('cartesian2d', Grid$1)
  45299. axisModelCreator(registers, 'x', CartesianAxisModel, extraOption)
  45300. axisModelCreator(registers, 'y', CartesianAxisModel, extraOption)
  45301. registers.registerComponentView(CartesianXAxisView)
  45302. registers.registerComponentView(CartesianYAxisView)
  45303. registers.registerPreprocessor(function (option) {
  45304. // Only create grid when need
  45305. if (option.xAxis && option.yAxis && !option.grid) {
  45306. option.grid = {}
  45307. }
  45308. })
  45309. }
  45310. var ATTR = '\0_ec_interaction_mutex'
  45311. function take(zr, resourceKey, userKey) {
  45312. var store = getStore(zr)
  45313. store[resourceKey] = userKey
  45314. }
  45315. function release(zr, resourceKey, userKey) {
  45316. var store = getStore(zr)
  45317. var uKey = store[resourceKey]
  45318. if (uKey === userKey) {
  45319. store[resourceKey] = null
  45320. }
  45321. }
  45322. function isTaken(zr, resourceKey) {
  45323. return !!getStore(zr)[resourceKey]
  45324. }
  45325. function getStore(zr) {
  45326. return zr[ATTR] || (zr[ATTR] = {})
  45327. }
  45328. /**
  45329. * payload: {
  45330. * type: 'takeGlobalCursor',
  45331. * key: 'dataZoomSelect', or 'brush', or ...,
  45332. * If no userKey, release global cursor.
  45333. * }
  45334. */ // TODO: SELF REGISTERED.
  45335. registerAction(
  45336. {
  45337. type: 'takeGlobalCursor',
  45338. event: 'globalCursorTaken',
  45339. update: 'update'
  45340. },
  45341. noop
  45342. )
  45343. var RoamController = /** @class */ (function (_super) {
  45344. __extends(RoamController, _super)
  45345. function RoamController(zr) {
  45346. var _this = _super.call(this) || this
  45347. _this._zr = zr // Avoid two roamController bind the same handler
  45348. var mousedownHandler = bind$1(_this._mousedownHandler, _this)
  45349. var mousemoveHandler = bind$1(_this._mousemoveHandler, _this)
  45350. var mouseupHandler = bind$1(_this._mouseupHandler, _this)
  45351. var mousewheelHandler = bind$1(_this._mousewheelHandler, _this)
  45352. var pinchHandler = bind$1(_this._pinchHandler, _this)
  45353. /**
  45354. * Notice: only enable needed types. For example, if 'zoom'
  45355. * is not needed, 'zoom' should not be enabled, otherwise
  45356. * default mousewheel behaviour (scroll page) will be disabled.
  45357. */ _this.enable = function (controlType, opt) {
  45358. // Disable previous first
  45359. this.disable()
  45360. this._opt = defaults(clone$3(opt) || {}, {
  45361. zoomOnMouseWheel: true,
  45362. moveOnMouseMove: true, // By default, wheel do not trigger move.
  45363. moveOnMouseWheel: false,
  45364. preventDefaultMouseMove: true
  45365. })
  45366. if (controlType == null) {
  45367. controlType = true
  45368. }
  45369. if (
  45370. controlType === true ||
  45371. controlType === 'move' ||
  45372. controlType === 'pan'
  45373. ) {
  45374. zr.on('mousedown', mousedownHandler)
  45375. zr.on('mousemove', mousemoveHandler)
  45376. zr.on('mouseup', mouseupHandler)
  45377. }
  45378. if (
  45379. controlType === true ||
  45380. controlType === 'scale' ||
  45381. controlType === 'zoom'
  45382. ) {
  45383. zr.on('mousewheel', mousewheelHandler)
  45384. zr.on('pinch', pinchHandler)
  45385. }
  45386. }
  45387. _this.disable = function () {
  45388. zr.off('mousedown', mousedownHandler)
  45389. zr.off('mousemove', mousemoveHandler)
  45390. zr.off('mouseup', mouseupHandler)
  45391. zr.off('mousewheel', mousewheelHandler)
  45392. zr.off('pinch', pinchHandler)
  45393. }
  45394. return _this
  45395. }
  45396. RoamController.prototype.isDragging = function () {
  45397. return this._dragging
  45398. }
  45399. RoamController.prototype.isPinching = function () {
  45400. return this._pinching
  45401. }
  45402. RoamController.prototype.setPointerChecker = function (
  45403. pointerChecker
  45404. ) {
  45405. this.pointerChecker = pointerChecker
  45406. }
  45407. RoamController.prototype.dispose = function () {
  45408. this.disable()
  45409. }
  45410. RoamController.prototype._mousedownHandler = function (e) {
  45411. if (
  45412. isMiddleOrRightButtonOnMouseUpDown(e) ||
  45413. (e.target && e.target.draggable)
  45414. ) {
  45415. return
  45416. }
  45417. var x = e.offsetX
  45418. var y = e.offsetY // Only check on mosedown, but not mousemove.
  45419. // Mouse can be out of target when mouse moving.
  45420. if (this.pointerChecker && this.pointerChecker(e, x, y)) {
  45421. this._x = x
  45422. this._y = y
  45423. this._dragging = true
  45424. }
  45425. }
  45426. RoamController.prototype._mousemoveHandler = function (e) {
  45427. if (
  45428. !this._dragging ||
  45429. !isAvailableBehavior('moveOnMouseMove', e, this._opt) ||
  45430. e.gestureEvent === 'pinch' ||
  45431. isTaken(this._zr, 'globalPan')
  45432. ) {
  45433. return
  45434. }
  45435. var x = e.offsetX
  45436. var y = e.offsetY
  45437. var oldX = this._x
  45438. var oldY = this._y
  45439. var dx = x - oldX
  45440. var dy = y - oldY
  45441. this._x = x
  45442. this._y = y
  45443. this._opt.preventDefaultMouseMove && stop(e.event)
  45444. trigger$1(this, 'pan', 'moveOnMouseMove', e, {
  45445. dx: dx,
  45446. dy: dy,
  45447. oldX: oldX,
  45448. oldY: oldY,
  45449. newX: x,
  45450. newY: y,
  45451. isAvailableBehavior: null
  45452. })
  45453. }
  45454. RoamController.prototype._mouseupHandler = function (e) {
  45455. if (!isMiddleOrRightButtonOnMouseUpDown(e)) {
  45456. this._dragging = false
  45457. }
  45458. }
  45459. RoamController.prototype._mousewheelHandler = function (e) {
  45460. var shouldZoom = isAvailableBehavior(
  45461. 'zoomOnMouseWheel',
  45462. e,
  45463. this._opt
  45464. )
  45465. var shouldMove = isAvailableBehavior(
  45466. 'moveOnMouseWheel',
  45467. e,
  45468. this._opt
  45469. )
  45470. var wheelDelta = e.wheelDelta
  45471. var absWheelDeltaDelta = Math.abs(wheelDelta)
  45472. var originX = e.offsetX
  45473. var originY = e.offsetY // wheelDelta maybe -0 in chrome mac.
  45474. if (wheelDelta === 0 || (!shouldZoom && !shouldMove)) {
  45475. return
  45476. } // If both `shouldZoom` and `shouldMove` is true, trigger
  45477. // their event both, and the final behavior is determined
  45478. // by event listener themselves.
  45479. if (shouldZoom) {
  45480. // Convenience:
  45481. // Mac and VM Windows on Mac: scroll up: zoom out.
  45482. // Windows: scroll up: zoom in.
  45483. // FIXME: Should do more test in different environment.
  45484. // wheelDelta is too complicated in difference nvironment
  45485. // (https://developer.mozilla.org/en-US/docs/Web/Events/mousewheel),
  45486. // although it has been normallized by zrender.
  45487. // wheelDelta of mouse wheel is bigger than touch pad.
  45488. var factor =
  45489. absWheelDeltaDelta > 3
  45490. ? 1.4
  45491. : absWheelDeltaDelta > 1
  45492. ? 1.2
  45493. : 1.1
  45494. var scale = wheelDelta > 0 ? factor : 1 / factor
  45495. checkPointerAndTrigger(this, 'zoom', 'zoomOnMouseWheel', e, {
  45496. scale: scale,
  45497. originX: originX,
  45498. originY: originY,
  45499. isAvailableBehavior: null
  45500. })
  45501. }
  45502. if (shouldMove) {
  45503. // FIXME: Should do more test in different environment.
  45504. var absDelta = Math.abs(wheelDelta) // wheelDelta of mouse wheel is bigger than touch pad.
  45505. var scrollDelta =
  45506. (wheelDelta > 0 ? 1 : -1) *
  45507. (absDelta > 3 ? 0.4 : absDelta > 1 ? 0.15 : 0.05)
  45508. checkPointerAndTrigger(
  45509. this,
  45510. 'scrollMove',
  45511. 'moveOnMouseWheel',
  45512. e,
  45513. {
  45514. scrollDelta: scrollDelta,
  45515. originX: originX,
  45516. originY: originY,
  45517. isAvailableBehavior: null
  45518. }
  45519. )
  45520. }
  45521. }
  45522. RoamController.prototype._pinchHandler = function (e) {
  45523. if (isTaken(this._zr, 'globalPan')) {
  45524. return
  45525. }
  45526. var scale = e.pinchScale > 1 ? 1.1 : 1 / 1.1
  45527. checkPointerAndTrigger(this, 'zoom', null, e, {
  45528. scale: scale,
  45529. originX: e.pinchX,
  45530. originY: e.pinchY,
  45531. isAvailableBehavior: null
  45532. })
  45533. }
  45534. return RoamController
  45535. })(Eventful$1)
  45536. function checkPointerAndTrigger(
  45537. controller,
  45538. eventName,
  45539. behaviorToCheck,
  45540. e,
  45541. contollerEvent
  45542. ) {
  45543. if (
  45544. controller.pointerChecker &&
  45545. controller.pointerChecker(
  45546. e,
  45547. contollerEvent.originX,
  45548. contollerEvent.originY
  45549. )
  45550. ) {
  45551. // When mouse is out of roamController rect,
  45552. // default befavoius should not be be disabled, otherwise
  45553. // page sliding is disabled, contrary to expectation.
  45554. stop(e.event)
  45555. trigger$1(
  45556. controller,
  45557. eventName,
  45558. behaviorToCheck,
  45559. e,
  45560. contollerEvent
  45561. )
  45562. }
  45563. }
  45564. function trigger$1(
  45565. controller,
  45566. eventName,
  45567. behaviorToCheck,
  45568. e,
  45569. contollerEvent
  45570. ) {
  45571. // Also provide behavior checker for event listener, for some case that
  45572. // multiple components share one listener.
  45573. contollerEvent.isAvailableBehavior = bind$1(
  45574. isAvailableBehavior,
  45575. null,
  45576. behaviorToCheck,
  45577. e
  45578. ) // TODO should not have type issue.
  45579. controller.trigger(eventName, contollerEvent)
  45580. } // settings: {
  45581. // zoomOnMouseWheel
  45582. // moveOnMouseMove
  45583. // moveOnMouseWheel
  45584. // }
  45585. // The value can be: true / false / 'shift' / 'ctrl' / 'alt'.
  45586. function isAvailableBehavior(behaviorToCheck, e, settings) {
  45587. var setting = settings[behaviorToCheck]
  45588. return (
  45589. !behaviorToCheck ||
  45590. (setting && (!isString(setting) || e.event[setting + 'Key']))
  45591. )
  45592. }
  45593. var RoamController$1 = RoamController
  45594. /*
  45595. * Licensed to the Apache Software Foundation (ASF) under one
  45596. * or more contributor license agreements. See the NOTICE file
  45597. * distributed with this work for additional information
  45598. * regarding copyright ownership. The ASF licenses this file
  45599. * to you under the Apache License, Version 2.0 (the
  45600. * "License"); you may not use this file except in compliance
  45601. * with the License. You may obtain a copy of the License at
  45602. *
  45603. * http://www.apache.org/licenses/LICENSE-2.0
  45604. *
  45605. * Unless required by applicable law or agreed to in writing,
  45606. * software distributed under the License is distributed on an
  45607. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45608. * KIND, either express or implied. See the License for the
  45609. * specific language governing permissions and limitations
  45610. * under the License.
  45611. */ /**
  45612. * AUTO-GENERATED FILE. DO NOT MODIFY.
  45613. */ /*
  45614. * Licensed to the Apache Software Foundation (ASF) under one
  45615. * or more contributor license agreements. See the NOTICE file
  45616. * distributed with this work for additional information
  45617. * regarding copyright ownership. The ASF licenses this file
  45618. * to you under the Apache License, Version 2.0 (the
  45619. * "License"); you may not use this file except in compliance
  45620. * with the License. You may obtain a copy of the License at
  45621. *
  45622. * http://www.apache.org/licenses/LICENSE-2.0
  45623. *
  45624. * Unless required by applicable law or agreed to in writing,
  45625. * software distributed under the License is distributed on an
  45626. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45627. * KIND, either express or implied. See the License for the
  45628. * specific language governing permissions and limitations
  45629. * under the License.
  45630. */ var IRRELEVANT_EXCLUDES = { axisPointer: 1, tooltip: 1, brush: 1 }
  45631. /**
  45632. * Avoid that: mouse click on a elements that is over geo or graph,
  45633. * but roam is triggered.
  45634. */ function onIrrelevantElement(e, api, targetCoordSysModel) {
  45635. var model = api.getComponentByElement(e.topTarget) // If model is axisModel, it works only if it is injected with coordinateSystem.
  45636. var coordSys = model && model.coordinateSystem
  45637. return (
  45638. model &&
  45639. model !== targetCoordSysModel &&
  45640. !IRRELEVANT_EXCLUDES.hasOwnProperty(model.mainType) &&
  45641. coordSys &&
  45642. coordSys.model !== targetCoordSysModel
  45643. )
  45644. }
  45645. /*
  45646. * Licensed to the Apache Software Foundation (ASF) under one
  45647. * or more contributor license agreements. See the NOTICE file
  45648. * distributed with this work for additional information
  45649. * regarding copyright ownership. The ASF licenses this file
  45650. * to you under the Apache License, Version 2.0 (the
  45651. * "License"); you may not use this file except in compliance
  45652. * with the License. You may obtain a copy of the License at
  45653. *
  45654. * http://www.apache.org/licenses/LICENSE-2.0
  45655. *
  45656. * Unless required by applicable law or agreed to in writing,
  45657. * software distributed under the License is distributed on an
  45658. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45659. * KIND, either express or implied. See the License for the
  45660. * specific language governing permissions and limitations
  45661. * under the License.
  45662. */ /**
  45663. * AUTO-GENERATED FILE. DO NOT MODIFY.
  45664. */ /*
  45665. * Licensed to the Apache Software Foundation (ASF) under one
  45666. * or more contributor license agreements. See the NOTICE file
  45667. * distributed with this work for additional information
  45668. * regarding copyright ownership. The ASF licenses this file
  45669. * to you under the Apache License, Version 2.0 (the
  45670. * "License"); you may not use this file except in compliance
  45671. * with the License. You may obtain a copy of the License at
  45672. *
  45673. * http://www.apache.org/licenses/LICENSE-2.0
  45674. *
  45675. * Unless required by applicable law or agreed to in writing,
  45676. * software distributed under the License is distributed on an
  45677. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  45678. * KIND, either express or implied. See the License for the
  45679. * specific language governing permissions and limitations
  45680. * under the License.
  45681. */ /**
  45682. * Calculate slider move result.
  45683. * Usage:
  45684. * (1) If both handle0 and handle1 are needed to be moved, set minSpan the same as
  45685. * maxSpan and the same as `Math.abs(handleEnd[1] - handleEnds[0])`.
  45686. * (2) If handle0 is forbidden to cross handle1, set minSpan as `0`.
  45687. *
  45688. * @param delta Move length.
  45689. * @param handleEnds handleEnds[0] can be bigger then handleEnds[1].
  45690. * handleEnds will be modified in this method.
  45691. * @param extent handleEnds is restricted by extent.
  45692. * extent[0] should less or equals than extent[1].
  45693. * @param handleIndex Can be 'all', means that both move the two handleEnds.
  45694. * @param minSpan The range of dataZoom can not be smaller than that.
  45695. * If not set, handle0 and cross handle1. If set as a non-negative
  45696. * number (including `0`), handles will push each other when reaching
  45697. * the minSpan.
  45698. * @param maxSpan The range of dataZoom can not be larger than that.
  45699. * @return The input handleEnds.
  45700. */ function sliderMove(
  45701. delta,
  45702. handleEnds,
  45703. extent,
  45704. handleIndex,
  45705. minSpan,
  45706. maxSpan
  45707. ) {
  45708. delta = delta || 0
  45709. var extentSpan = extent[1] - extent[0] // Notice maxSpan and minSpan can be null/undefined.
  45710. if (minSpan != null) {
  45711. minSpan = restrict(minSpan, [0, extentSpan])
  45712. }
  45713. if (maxSpan != null) {
  45714. maxSpan = Math.max(maxSpan, minSpan != null ? minSpan : 0)
  45715. }
  45716. if (handleIndex === 'all') {
  45717. var handleSpan = Math.abs(handleEnds[1] - handleEnds[0])
  45718. handleSpan = restrict(handleSpan, [0, extentSpan])
  45719. minSpan = maxSpan = restrict(handleSpan, [minSpan, maxSpan])
  45720. handleIndex = 0
  45721. }
  45722. handleEnds[0] = restrict(handleEnds[0], extent)
  45723. handleEnds[1] = restrict(handleEnds[1], extent)
  45724. var originalDistSign = getSpanSign(handleEnds, handleIndex)
  45725. handleEnds[handleIndex] += delta // Restrict in extent.
  45726. var extentMinSpan = minSpan || 0
  45727. var realExtent = extent.slice()
  45728. originalDistSign.sign < 0
  45729. ? (realExtent[0] += extentMinSpan)
  45730. : (realExtent[1] -= extentMinSpan)
  45731. handleEnds[handleIndex] = restrict(
  45732. handleEnds[handleIndex],
  45733. realExtent
  45734. ) // Expand span.
  45735. var currDistSign
  45736. currDistSign = getSpanSign(handleEnds, handleIndex)
  45737. if (
  45738. minSpan != null &&
  45739. (currDistSign.sign !== originalDistSign.sign ||
  45740. currDistSign.span < minSpan)
  45741. ) {
  45742. // If minSpan exists, 'cross' is forbidden.
  45743. handleEnds[1 - handleIndex] =
  45744. handleEnds[handleIndex] + originalDistSign.sign * minSpan
  45745. } // Shrink span.
  45746. currDistSign = getSpanSign(handleEnds, handleIndex)
  45747. if (maxSpan != null && currDistSign.span > maxSpan) {
  45748. handleEnds[1 - handleIndex] =
  45749. handleEnds[handleIndex] + currDistSign.sign * maxSpan
  45750. }
  45751. return handleEnds
  45752. }
  45753. function getSpanSign(handleEnds, handleIndex) {
  45754. var dist = handleEnds[handleIndex] - handleEnds[1 - handleIndex] // If `handleEnds[0] === handleEnds[1]`, always believe that handleEnd[0]
  45755. // is at left of handleEnds[1] for non-cross case.
  45756. return {
  45757. span: Math.abs(dist),
  45758. sign: dist > 0 ? -1 : dist < 0 ? 1 : handleIndex ? -1 : 1
  45759. }
  45760. }
  45761. function restrict(value, extend) {
  45762. return Math.min(
  45763. extend[1] != null ? extend[1] : Infinity,
  45764. Math.max(extend[0] != null ? extend[0] : -Infinity, value)
  45765. )
  45766. }
  45767. var BRUSH_PANEL_GLOBAL = true
  45768. var mathMin = Math.min
  45769. var mathMax = Math.max
  45770. var mathPow = Math.pow
  45771. var COVER_Z = 10000
  45772. var UNSELECT_THRESHOLD = 6
  45773. var MIN_RESIZE_LINE_WIDTH = 6
  45774. var MUTEX_RESOURCE_KEY = 'globalPan'
  45775. var DIRECTION_MAP = { w: [0, 0], e: [0, 1], n: [1, 0], s: [1, 1] }
  45776. var CURSOR_MAP = {
  45777. w: 'ew',
  45778. e: 'ew',
  45779. n: 'ns',
  45780. s: 'ns',
  45781. ne: 'nesw',
  45782. sw: 'nesw',
  45783. nw: 'nwse',
  45784. se: 'nwse'
  45785. }
  45786. var DEFAULT_BRUSH_OPT = {
  45787. brushStyle: {
  45788. lineWidth: 2,
  45789. stroke: 'rgba(210,219,238,0.3)',
  45790. fill: '#D2DBEE'
  45791. },
  45792. transformable: true,
  45793. brushMode: 'single',
  45794. removeOnClick: false
  45795. }
  45796. var baseUID = 0
  45797. /**
  45798. * params:
  45799. * areas: Array.<Array>, coord relates to container group,
  45800. * If no container specified, to global.
  45801. * opt {
  45802. * isEnd: boolean,
  45803. * removeOnClick: boolean
  45804. * }
  45805. */ var BrushController = /** @class */ (function (_super) {
  45806. __extends(BrushController, _super)
  45807. function BrushController(zr) {
  45808. var _this = _super.call(this) || this
  45809. /**
  45810. * @internal
  45811. */ _this._track = []
  45812. /**
  45813. * @internal
  45814. */ _this._covers = []
  45815. _this._handlers = {}
  45816. _this._zr = zr
  45817. _this.group = new Group$3()
  45818. _this._uid = 'brushController_' + baseUID++
  45819. each$7(
  45820. pointerHandlers,
  45821. function (handler, eventName) {
  45822. this._handlers[eventName] = bind$1(handler, this)
  45823. },
  45824. _this
  45825. )
  45826. return _this
  45827. }
  45828. /**
  45829. * If set to `false`, select disabled.
  45830. */ BrushController.prototype.enableBrush = function (brushOption) {
  45831. this._brushType && this._doDisableBrush()
  45832. brushOption.brushType && this._doEnableBrush(brushOption)
  45833. return this
  45834. }
  45835. BrushController.prototype._doEnableBrush = function (brushOption) {
  45836. var zr = this._zr // Consider roam, which takes globalPan too.
  45837. if (!this._enableGlobalPan) {
  45838. take(zr, MUTEX_RESOURCE_KEY, this._uid)
  45839. }
  45840. each$7(this._handlers, function (handler, eventName) {
  45841. zr.on(eventName, handler)
  45842. })
  45843. this._brushType = brushOption.brushType
  45844. this._brushOption = merge(
  45845. clone$3(DEFAULT_BRUSH_OPT),
  45846. brushOption,
  45847. true
  45848. )
  45849. }
  45850. BrushController.prototype._doDisableBrush = function () {
  45851. var zr = this._zr
  45852. release(zr, MUTEX_RESOURCE_KEY, this._uid)
  45853. each$7(this._handlers, function (handler, eventName) {
  45854. zr.off(eventName, handler)
  45855. })
  45856. this._brushType = this._brushOption = null
  45857. }
  45858. /**
  45859. * @param panelOpts If not pass, it is global brush.
  45860. */ BrushController.prototype.setPanels = function (panelOpts) {
  45861. if (panelOpts && panelOpts.length) {
  45862. var panels_1 = (this._panels = {})
  45863. each$7(panelOpts, function (panelOpts) {
  45864. panels_1[panelOpts.panelId] = clone$3(panelOpts)
  45865. })
  45866. } else {
  45867. this._panels = null
  45868. }
  45869. return this
  45870. }
  45871. BrushController.prototype.mount = function (opt) {
  45872. opt = opt || {}
  45873. this._enableGlobalPan = opt.enableGlobalPan
  45874. var thisGroup = this.group
  45875. this._zr.add(thisGroup)
  45876. thisGroup.attr({
  45877. x: opt.x || 0,
  45878. y: opt.y || 0,
  45879. rotation: opt.rotation || 0,
  45880. scaleX: opt.scaleX || 1,
  45881. scaleY: opt.scaleY || 1
  45882. })
  45883. this._transform = thisGroup.getLocalTransform()
  45884. return this
  45885. } // eachCover(cb, context): void {
  45886. // each(this._covers, cb, context);
  45887. // }
  45888. /**
  45889. * Update covers.
  45890. * @param coverConfigList
  45891. * If coverConfigList is null/undefined, all covers removed.
  45892. */ BrushController.prototype.updateCovers = function (
  45893. coverConfigList
  45894. ) {
  45895. coverConfigList = map$1(coverConfigList, function (coverConfig) {
  45896. return merge(clone$3(DEFAULT_BRUSH_OPT), coverConfig, true)
  45897. })
  45898. var tmpIdPrefix = '\0-brush-index-'
  45899. var oldCovers = this._covers
  45900. var newCovers = (this._covers = [])
  45901. var controller = this
  45902. var creatingCover = this._creatingCover
  45903. new DataDiffer$1(oldCovers, coverConfigList, oldGetKey, getKey)
  45904. .add(addOrUpdate)
  45905. .update(addOrUpdate)
  45906. .remove(remove)
  45907. .execute()
  45908. return this
  45909. function getKey(brushOption, index) {
  45910. return (
  45911. (brushOption.id != null
  45912. ? brushOption.id
  45913. : tmpIdPrefix + index) +
  45914. '-' +
  45915. brushOption.brushType
  45916. )
  45917. }
  45918. function oldGetKey(cover, index) {
  45919. return getKey(cover.__brushOption, index)
  45920. }
  45921. function addOrUpdate(newIndex, oldIndex) {
  45922. var newBrushInternal = coverConfigList[newIndex] // Consider setOption in event listener of brushSelect,
  45923. // where updating cover when creating should be forbiden.
  45924. if (oldIndex != null && oldCovers[oldIndex] === creatingCover) {
  45925. newCovers[newIndex] = oldCovers[oldIndex]
  45926. } else {
  45927. var cover = (newCovers[newIndex] =
  45928. oldIndex != null
  45929. ? ((oldCovers[oldIndex].__brushOption = newBrushInternal),
  45930. oldCovers[oldIndex])
  45931. : endCreating(
  45932. controller,
  45933. createCover(controller, newBrushInternal)
  45934. ))
  45935. updateCoverAfterCreation(controller, cover)
  45936. }
  45937. }
  45938. function remove(oldIndex) {
  45939. if (oldCovers[oldIndex] !== creatingCover) {
  45940. controller.group.remove(oldCovers[oldIndex])
  45941. }
  45942. }
  45943. }
  45944. BrushController.prototype.unmount = function () {
  45945. this.enableBrush(false) // container may 'removeAll' outside.
  45946. clearCovers(this)
  45947. this._zr.remove(this.group)
  45948. return this
  45949. }
  45950. BrushController.prototype.dispose = function () {
  45951. this.unmount()
  45952. this.off()
  45953. }
  45954. return BrushController
  45955. })(Eventful$1)
  45956. function createCover(controller, brushOption) {
  45957. var cover = coverRenderers[brushOption.brushType].createCover(
  45958. controller,
  45959. brushOption
  45960. )
  45961. cover.__brushOption = brushOption
  45962. updateZ(cover, brushOption)
  45963. controller.group.add(cover)
  45964. return cover
  45965. }
  45966. function endCreating(controller, creatingCover) {
  45967. var coverRenderer = getCoverRenderer(creatingCover)
  45968. if (coverRenderer.endCreating) {
  45969. coverRenderer.endCreating(controller, creatingCover)
  45970. updateZ(creatingCover, creatingCover.__brushOption)
  45971. }
  45972. return creatingCover
  45973. }
  45974. function updateCoverShape(controller, cover) {
  45975. var brushOption = cover.__brushOption
  45976. getCoverRenderer(cover).updateCoverShape(
  45977. controller,
  45978. cover,
  45979. brushOption.range,
  45980. brushOption
  45981. )
  45982. }
  45983. function updateZ(cover, brushOption) {
  45984. var z = brushOption.z
  45985. z == null && (z = COVER_Z)
  45986. cover.traverse(function (el) {
  45987. el.z = z
  45988. el.z2 = z // Consider in given container.
  45989. })
  45990. }
  45991. function updateCoverAfterCreation(controller, cover) {
  45992. getCoverRenderer(cover).updateCommon(controller, cover)
  45993. updateCoverShape(controller, cover)
  45994. }
  45995. function getCoverRenderer(cover) {
  45996. return coverRenderers[cover.__brushOption.brushType]
  45997. } // return target panel or `true` (means global panel)
  45998. function getPanelByPoint(controller, e, localCursorPoint) {
  45999. var panels = controller._panels
  46000. if (!panels) {
  46001. return BRUSH_PANEL_GLOBAL // Global panel
  46002. }
  46003. var panel
  46004. var transform = controller._transform
  46005. each$7(panels, function (pn) {
  46006. pn.isTargetByCursor(e, localCursorPoint, transform) &&
  46007. (panel = pn)
  46008. })
  46009. return panel
  46010. } // Return a panel or true
  46011. function getPanelByCover(controller, cover) {
  46012. var panels = controller._panels
  46013. if (!panels) {
  46014. return BRUSH_PANEL_GLOBAL // Global panel
  46015. }
  46016. var panelId = cover.__brushOption.panelId // User may give cover without coord sys info,
  46017. // which is then treated as global panel.
  46018. return panelId != null ? panels[panelId] : BRUSH_PANEL_GLOBAL
  46019. }
  46020. function clearCovers(controller) {
  46021. var covers = controller._covers
  46022. var originalLength = covers.length
  46023. each$7(
  46024. covers,
  46025. function (cover) {
  46026. controller.group.remove(cover)
  46027. },
  46028. controller
  46029. )
  46030. covers.length = 0
  46031. return !!originalLength
  46032. }
  46033. function trigger(controller, opt) {
  46034. var areas = map$1(controller._covers, function (cover) {
  46035. var brushOption = cover.__brushOption
  46036. var range = clone$3(brushOption.range)
  46037. return {
  46038. brushType: brushOption.brushType,
  46039. panelId: brushOption.panelId,
  46040. range: range
  46041. }
  46042. })
  46043. controller.trigger('brush', {
  46044. areas: areas,
  46045. isEnd: !!opt.isEnd,
  46046. removeOnClick: !!opt.removeOnClick
  46047. })
  46048. }
  46049. function shouldShowCover(controller) {
  46050. var track = controller._track
  46051. if (!track.length) {
  46052. return false
  46053. }
  46054. var p2 = track[track.length - 1]
  46055. var p1 = track[0]
  46056. var dx = p2[0] - p1[0]
  46057. var dy = p2[1] - p1[1]
  46058. var dist = mathPow(dx * dx + dy * dy, 0.5)
  46059. return dist > UNSELECT_THRESHOLD
  46060. }
  46061. function getTrackEnds(track) {
  46062. var tail = track.length - 1
  46063. tail < 0 && (tail = 0)
  46064. return [track[0], track[tail]]
  46065. }
  46066. function createBaseRectCover(
  46067. rectRangeConverter,
  46068. controller,
  46069. brushOption,
  46070. edgeNameSequences
  46071. ) {
  46072. var cover = new Group$3()
  46073. cover.add(
  46074. new Rect$2({
  46075. name: 'main',
  46076. style: makeStyle(brushOption),
  46077. silent: true,
  46078. draggable: true,
  46079. cursor: 'move',
  46080. drift: curry$1(
  46081. driftRect,
  46082. rectRangeConverter,
  46083. controller,
  46084. cover,
  46085. ['n', 's', 'w', 'e']
  46086. ),
  46087. ondragend: curry$1(trigger, controller, { isEnd: true })
  46088. })
  46089. )
  46090. each$7(edgeNameSequences, function (nameSequence) {
  46091. cover.add(
  46092. new Rect$2({
  46093. name: nameSequence.join(''),
  46094. style: { opacity: 0 },
  46095. draggable: true,
  46096. silent: true,
  46097. invisible: true,
  46098. drift: curry$1(
  46099. driftRect,
  46100. rectRangeConverter,
  46101. controller,
  46102. cover,
  46103. nameSequence
  46104. ),
  46105. ondragend: curry$1(trigger, controller, { isEnd: true })
  46106. })
  46107. )
  46108. })
  46109. return cover
  46110. }
  46111. function updateBaseRect(controller, cover, localRange, brushOption) {
  46112. var lineWidth = brushOption.brushStyle.lineWidth || 0
  46113. var handleSize = mathMax(lineWidth, MIN_RESIZE_LINE_WIDTH)
  46114. var x = localRange[0][0]
  46115. var y = localRange[1][0]
  46116. var xa = x - lineWidth / 2
  46117. var ya = y - lineWidth / 2
  46118. var x2 = localRange[0][1]
  46119. var y2 = localRange[1][1]
  46120. var x2a = x2 - handleSize + lineWidth / 2
  46121. var y2a = y2 - handleSize + lineWidth / 2
  46122. var width = x2 - x
  46123. var height = y2 - y
  46124. var widtha = width + lineWidth
  46125. var heighta = height + lineWidth
  46126. updateRectShape(controller, cover, 'main', x, y, width, height)
  46127. if (brushOption.transformable) {
  46128. updateRectShape(
  46129. controller,
  46130. cover,
  46131. 'w',
  46132. xa,
  46133. ya,
  46134. handleSize,
  46135. heighta
  46136. )
  46137. updateRectShape(
  46138. controller,
  46139. cover,
  46140. 'e',
  46141. x2a,
  46142. ya,
  46143. handleSize,
  46144. heighta
  46145. )
  46146. updateRectShape(
  46147. controller,
  46148. cover,
  46149. 'n',
  46150. xa,
  46151. ya,
  46152. widtha,
  46153. handleSize
  46154. )
  46155. updateRectShape(
  46156. controller,
  46157. cover,
  46158. 's',
  46159. xa,
  46160. y2a,
  46161. widtha,
  46162. handleSize
  46163. )
  46164. updateRectShape(
  46165. controller,
  46166. cover,
  46167. 'nw',
  46168. xa,
  46169. ya,
  46170. handleSize,
  46171. handleSize
  46172. )
  46173. updateRectShape(
  46174. controller,
  46175. cover,
  46176. 'ne',
  46177. x2a,
  46178. ya,
  46179. handleSize,
  46180. handleSize
  46181. )
  46182. updateRectShape(
  46183. controller,
  46184. cover,
  46185. 'sw',
  46186. xa,
  46187. y2a,
  46188. handleSize,
  46189. handleSize
  46190. )
  46191. updateRectShape(
  46192. controller,
  46193. cover,
  46194. 'se',
  46195. x2a,
  46196. y2a,
  46197. handleSize,
  46198. handleSize
  46199. )
  46200. }
  46201. }
  46202. function updateCommon(controller, cover) {
  46203. var brushOption = cover.__brushOption
  46204. var transformable = brushOption.transformable
  46205. var mainEl = cover.childAt(0)
  46206. mainEl.useStyle(makeStyle(brushOption))
  46207. mainEl.attr({
  46208. silent: !transformable,
  46209. cursor: transformable ? 'move' : 'default'
  46210. })
  46211. each$7(
  46212. [
  46213. ['w'],
  46214. ['e'],
  46215. ['n'],
  46216. ['s'],
  46217. ['s', 'e'],
  46218. ['s', 'w'],
  46219. ['n', 'e'],
  46220. ['n', 'w']
  46221. ],
  46222. function (nameSequence) {
  46223. var el = cover.childOfName(nameSequence.join(''))
  46224. var globalDir =
  46225. nameSequence.length === 1
  46226. ? getGlobalDirection1(controller, nameSequence[0])
  46227. : getGlobalDirection2(controller, nameSequence)
  46228. el &&
  46229. el.attr({
  46230. silent: !transformable,
  46231. invisible: !transformable,
  46232. cursor: transformable
  46233. ? CURSOR_MAP[globalDir] + '-resize'
  46234. : null
  46235. })
  46236. }
  46237. )
  46238. }
  46239. function updateRectShape(controller, cover, name, x, y, w, h) {
  46240. var el = cover.childOfName(name)
  46241. el &&
  46242. el.setShape(
  46243. pointsToRect(
  46244. clipByPanel(controller, cover, [
  46245. [x, y],
  46246. [x + w, y + h]
  46247. ])
  46248. )
  46249. )
  46250. }
  46251. function makeStyle(brushOption) {
  46252. return defaults({ strokeNoScale: true }, brushOption.brushStyle)
  46253. }
  46254. function formatRectRange(x, y, x2, y2) {
  46255. var min = [mathMin(x, x2), mathMin(y, y2)]
  46256. var max = [mathMax(x, x2), mathMax(y, y2)]
  46257. return [
  46258. [min[0], max[0]],
  46259. [min[1], max[1]] // y range
  46260. ]
  46261. }
  46262. function getTransform(controller) {
  46263. return getTransform$1(controller.group)
  46264. }
  46265. function getGlobalDirection1(controller, localDirName) {
  46266. var map = { w: 'left', e: 'right', n: 'top', s: 'bottom' }
  46267. var inverseMap = { left: 'w', right: 'e', top: 'n', bottom: 's' }
  46268. var dir = transformDirection(
  46269. map[localDirName],
  46270. getTransform(controller)
  46271. )
  46272. return inverseMap[dir]
  46273. }
  46274. function getGlobalDirection2(controller, localDirNameSeq) {
  46275. var globalDir = [
  46276. getGlobalDirection1(controller, localDirNameSeq[0]),
  46277. getGlobalDirection1(controller, localDirNameSeq[1])
  46278. ]
  46279. ;(globalDir[0] === 'e' || globalDir[0] === 'w') &&
  46280. globalDir.reverse()
  46281. return globalDir.join('')
  46282. }
  46283. function driftRect(
  46284. rectRangeConverter,
  46285. controller,
  46286. cover,
  46287. dirNameSequence,
  46288. dx,
  46289. dy
  46290. ) {
  46291. var brushOption = cover.__brushOption
  46292. var rectRange = rectRangeConverter.toRectRange(brushOption.range)
  46293. var localDelta = toLocalDelta(controller, dx, dy)
  46294. each$7(dirNameSequence, function (dirName) {
  46295. var ind = DIRECTION_MAP[dirName]
  46296. rectRange[ind[0]][ind[1]] += localDelta[ind[0]]
  46297. })
  46298. brushOption.range = rectRangeConverter.fromRectRange(
  46299. formatRectRange(
  46300. rectRange[0][0],
  46301. rectRange[1][0],
  46302. rectRange[0][1],
  46303. rectRange[1][1]
  46304. )
  46305. )
  46306. updateCoverAfterCreation(controller, cover)
  46307. trigger(controller, { isEnd: false })
  46308. }
  46309. function driftPolygon(controller, cover, dx, dy) {
  46310. var range = cover.__brushOption.range
  46311. var localDelta = toLocalDelta(controller, dx, dy)
  46312. each$7(range, function (point) {
  46313. point[0] += localDelta[0]
  46314. point[1] += localDelta[1]
  46315. })
  46316. updateCoverAfterCreation(controller, cover)
  46317. trigger(controller, { isEnd: false })
  46318. }
  46319. function toLocalDelta(controller, dx, dy) {
  46320. var thisGroup = controller.group
  46321. var localD = thisGroup.transformCoordToLocal(dx, dy)
  46322. var localZero = thisGroup.transformCoordToLocal(0, 0)
  46323. return [localD[0] - localZero[0], localD[1] - localZero[1]]
  46324. }
  46325. function clipByPanel(controller, cover, data) {
  46326. var panel = getPanelByCover(controller, cover)
  46327. return panel && panel !== BRUSH_PANEL_GLOBAL
  46328. ? panel.clipPath(data, controller._transform)
  46329. : clone$3(data)
  46330. }
  46331. function pointsToRect(points) {
  46332. var xmin = mathMin(points[0][0], points[1][0])
  46333. var ymin = mathMin(points[0][1], points[1][1])
  46334. var xmax = mathMax(points[0][0], points[1][0])
  46335. var ymax = mathMax(points[0][1], points[1][1])
  46336. return { x: xmin, y: ymin, width: xmax - xmin, height: ymax - ymin }
  46337. }
  46338. function resetCursor(controller, e, localCursorPoint) {
  46339. if (
  46340. // Check active
  46341. !controller._brushType || // resetCursor should be always called when mouse is in zr area,
  46342. // but not called when mouse is out of zr area to avoid bad influence
  46343. // if `mousemove`, `mouseup` are triggered from `document` event.
  46344. isOutsideZrArea(controller, e.offsetX, e.offsetY)
  46345. ) {
  46346. return
  46347. }
  46348. var zr = controller._zr
  46349. var covers = controller._covers
  46350. var currPanel = getPanelByPoint(controller, e, localCursorPoint) // Check whether in covers.
  46351. if (!controller._dragging) {
  46352. for (var i = 0; i < covers.length; i++) {
  46353. var brushOption = covers[i].__brushOption
  46354. if (
  46355. currPanel &&
  46356. (currPanel === BRUSH_PANEL_GLOBAL ||
  46357. brushOption.panelId === currPanel.panelId) &&
  46358. coverRenderers[brushOption.brushType].contain(
  46359. covers[i],
  46360. localCursorPoint[0],
  46361. localCursorPoint[1]
  46362. )
  46363. ) {
  46364. // Use cursor style set on cover.
  46365. return
  46366. }
  46367. }
  46368. }
  46369. currPanel && zr.setCursorStyle('crosshair')
  46370. }
  46371. function preventDefault(e) {
  46372. var rawE = e.event
  46373. rawE.preventDefault && rawE.preventDefault()
  46374. }
  46375. function mainShapeContain(cover, x, y) {
  46376. return cover.childOfName('main').contain(x, y)
  46377. }
  46378. function updateCoverByMouse(controller, e, localCursorPoint, isEnd) {
  46379. var creatingCover = controller._creatingCover
  46380. var panel = controller._creatingPanel
  46381. var thisBrushOption = controller._brushOption
  46382. var eventParams
  46383. controller._track.push(localCursorPoint.slice())
  46384. if (shouldShowCover(controller) || creatingCover) {
  46385. if (panel && !creatingCover) {
  46386. thisBrushOption.brushMode === 'single' &&
  46387. clearCovers(controller)
  46388. var brushOption = clone$3(thisBrushOption)
  46389. brushOption.brushType = determineBrushType(
  46390. brushOption.brushType,
  46391. panel
  46392. )
  46393. brushOption.panelId =
  46394. panel === BRUSH_PANEL_GLOBAL ? null : panel.panelId
  46395. creatingCover = controller._creatingCover = createCover(
  46396. controller,
  46397. brushOption
  46398. )
  46399. controller._covers.push(creatingCover)
  46400. }
  46401. if (creatingCover) {
  46402. var coverRenderer =
  46403. coverRenderers[
  46404. determineBrushType(controller._brushType, panel)
  46405. ]
  46406. var coverBrushOption = creatingCover.__brushOption
  46407. coverBrushOption.range = coverRenderer.getCreatingRange(
  46408. clipByPanel(controller, creatingCover, controller._track)
  46409. )
  46410. if (isEnd) {
  46411. endCreating(controller, creatingCover)
  46412. coverRenderer.updateCommon(controller, creatingCover)
  46413. }
  46414. updateCoverShape(controller, creatingCover)
  46415. eventParams = { isEnd: isEnd }
  46416. }
  46417. } else if (
  46418. isEnd &&
  46419. thisBrushOption.brushMode === 'single' &&
  46420. thisBrushOption.removeOnClick
  46421. ) {
  46422. // Help user to remove covers easily, only by a tiny drag, in 'single' mode.
  46423. // But a single click do not clear covers, because user may have casual
  46424. // clicks (for example, click on other component and do not expect covers
  46425. // disappear).
  46426. // Only some cover removed, trigger action, but not every click trigger action.
  46427. if (
  46428. getPanelByPoint(controller, e, localCursorPoint) &&
  46429. clearCovers(controller)
  46430. ) {
  46431. eventParams = { isEnd: isEnd, removeOnClick: true }
  46432. }
  46433. }
  46434. return eventParams
  46435. }
  46436. function determineBrushType(brushType, panel) {
  46437. if (brushType === 'auto') {
  46438. return panel.defaultBrushType
  46439. }
  46440. return brushType
  46441. }
  46442. var pointerHandlers = {
  46443. mousedown: function mousedown(e) {
  46444. if (this._dragging) {
  46445. // In case some browser do not support globalOut,
  46446. // and release mouse out side the browser.
  46447. handleDragEnd(this, e)
  46448. } else if (!e.target || !e.target.draggable) {
  46449. preventDefault(e)
  46450. var localCursorPoint = this.group.transformCoordToLocal(
  46451. e.offsetX,
  46452. e.offsetY
  46453. )
  46454. this._creatingCover = null
  46455. var panel = (this._creatingPanel = getPanelByPoint(
  46456. this,
  46457. e,
  46458. localCursorPoint
  46459. ))
  46460. if (panel) {
  46461. this._dragging = true
  46462. this._track = [localCursorPoint.slice()]
  46463. }
  46464. }
  46465. },
  46466. mousemove: function mousemove(e) {
  46467. var x = e.offsetX
  46468. var y = e.offsetY
  46469. var localCursorPoint = this.group.transformCoordToLocal(x, y)
  46470. resetCursor(this, e, localCursorPoint)
  46471. if (this._dragging) {
  46472. preventDefault(e)
  46473. var eventParams = updateCoverByMouse(
  46474. this,
  46475. e,
  46476. localCursorPoint,
  46477. false
  46478. )
  46479. eventParams && trigger(this, eventParams)
  46480. }
  46481. },
  46482. mouseup: function mouseup(e) {
  46483. handleDragEnd(this, e)
  46484. }
  46485. }
  46486. function handleDragEnd(controller, e) {
  46487. if (controller._dragging) {
  46488. preventDefault(e)
  46489. var x = e.offsetX
  46490. var y = e.offsetY
  46491. var localCursorPoint = controller.group.transformCoordToLocal(
  46492. x,
  46493. y
  46494. )
  46495. var eventParams = updateCoverByMouse(
  46496. controller,
  46497. e,
  46498. localCursorPoint,
  46499. true
  46500. )
  46501. controller._dragging = false
  46502. controller._track = []
  46503. controller._creatingCover = null // trigger event shoule be at final, after procedure will be nested.
  46504. eventParams && trigger(controller, eventParams)
  46505. }
  46506. }
  46507. function isOutsideZrArea(controller, x, y) {
  46508. var zr = controller._zr
  46509. return x < 0 || x > zr.getWidth() || y < 0 || y > zr.getHeight()
  46510. }
  46511. /**
  46512. * key: brushType
  46513. */ var coverRenderers = {
  46514. lineX: getLineRenderer(0),
  46515. lineY: getLineRenderer(1),
  46516. rect: {
  46517. createCover: function createCover(controller, brushOption) {
  46518. function returnInput(range) {
  46519. return range
  46520. }
  46521. return createBaseRectCover(
  46522. { toRectRange: returnInput, fromRectRange: returnInput },
  46523. controller,
  46524. brushOption,
  46525. [
  46526. ['w'],
  46527. ['e'],
  46528. ['n'],
  46529. ['s'],
  46530. ['s', 'e'],
  46531. ['s', 'w'],
  46532. ['n', 'e'],
  46533. ['n', 'w']
  46534. ]
  46535. )
  46536. },
  46537. getCreatingRange: function getCreatingRange(localTrack) {
  46538. var ends = getTrackEnds(localTrack)
  46539. return formatRectRange(
  46540. ends[1][0],
  46541. ends[1][1],
  46542. ends[0][0],
  46543. ends[0][1]
  46544. )
  46545. },
  46546. updateCoverShape: function updateCoverShape(
  46547. controller,
  46548. cover,
  46549. localRange,
  46550. brushOption
  46551. ) {
  46552. updateBaseRect(controller, cover, localRange, brushOption)
  46553. },
  46554. updateCommon: updateCommon,
  46555. contain: mainShapeContain
  46556. },
  46557. polygon: {
  46558. createCover: function createCover(controller, brushOption) {
  46559. var cover = new Group$3() // Do not use graphic.Polygon because graphic.Polyline do not close the
  46560. // border of the shape when drawing, which is a better experience for user.
  46561. cover.add(
  46562. new Polyline$1({
  46563. name: 'main',
  46564. style: makeStyle(brushOption),
  46565. silent: true
  46566. })
  46567. )
  46568. return cover
  46569. },
  46570. getCreatingRange: function getCreatingRange(localTrack) {
  46571. return localTrack
  46572. },
  46573. endCreating: function endCreating(controller, cover) {
  46574. cover.remove(cover.childAt(0)) // Use graphic.Polygon close the shape.
  46575. cover.add(
  46576. new Polygon$1({
  46577. name: 'main',
  46578. draggable: true,
  46579. drift: curry$1(driftPolygon, controller, cover),
  46580. ondragend: curry$1(trigger, controller, { isEnd: true })
  46581. })
  46582. )
  46583. },
  46584. updateCoverShape: function updateCoverShape(
  46585. controller,
  46586. cover,
  46587. localRange,
  46588. brushOption
  46589. ) {
  46590. cover
  46591. .childAt(0)
  46592. .setShape({
  46593. points: clipByPanel(controller, cover, localRange)
  46594. })
  46595. },
  46596. updateCommon: updateCommon,
  46597. contain: mainShapeContain
  46598. }
  46599. }
  46600. function getLineRenderer(xyIndex) {
  46601. return {
  46602. createCover: function createCover(controller, brushOption) {
  46603. return createBaseRectCover(
  46604. {
  46605. toRectRange: function toRectRange(range) {
  46606. var rectRange = [range, [0, 100]]
  46607. xyIndex && rectRange.reverse()
  46608. return rectRange
  46609. },
  46610. fromRectRange: function fromRectRange(rectRange) {
  46611. return rectRange[xyIndex]
  46612. }
  46613. },
  46614. controller,
  46615. brushOption,
  46616. [
  46617. [['w'], ['e']],
  46618. [['n'], ['s']]
  46619. ][xyIndex]
  46620. )
  46621. },
  46622. getCreatingRange: function getCreatingRange(localTrack) {
  46623. var ends = getTrackEnds(localTrack)
  46624. var min = mathMin(ends[0][xyIndex], ends[1][xyIndex])
  46625. var max = mathMax(ends[0][xyIndex], ends[1][xyIndex])
  46626. return [min, max]
  46627. },
  46628. updateCoverShape: function updateCoverShape(
  46629. controller,
  46630. cover,
  46631. localRange,
  46632. brushOption
  46633. ) {
  46634. var otherExtent // If brushWidth not specified, fit the panel.
  46635. var panel = getPanelByCover(controller, cover)
  46636. if (
  46637. panel !== BRUSH_PANEL_GLOBAL &&
  46638. panel.getLinearBrushOtherExtent
  46639. ) {
  46640. otherExtent = panel.getLinearBrushOtherExtent(xyIndex)
  46641. } else {
  46642. var zr = controller._zr
  46643. otherExtent = [
  46644. 0,
  46645. [zr.getWidth(), zr.getHeight()][1 - xyIndex]
  46646. ]
  46647. }
  46648. var rectRange = [localRange, otherExtent]
  46649. xyIndex && rectRange.reverse()
  46650. updateBaseRect(controller, cover, rectRange, brushOption)
  46651. },
  46652. updateCommon: updateCommon,
  46653. contain: mainShapeContain
  46654. }
  46655. }
  46656. var BrushController$1 = BrushController
  46657. function makeRectPanelClipPath(rect) {
  46658. rect = normalizeRect(rect)
  46659. return function (localPoints) {
  46660. return clipPointsByRect(localPoints, rect)
  46661. }
  46662. }
  46663. function makeLinearBrushOtherExtent(rect, specifiedXYIndex) {
  46664. rect = normalizeRect(rect)
  46665. return function (xyIndex) {
  46666. var idx = specifiedXYIndex != null ? specifiedXYIndex : xyIndex
  46667. var brushWidth = idx ? rect.width : rect.height
  46668. var base = idx ? rect.x : rect.y
  46669. return [base, base + (brushWidth || 0)]
  46670. }
  46671. }
  46672. function makeRectIsTargetByCursor(rect, api, targetModel) {
  46673. var boundingRect = normalizeRect(rect)
  46674. return function (e, localCursorPoint) {
  46675. return (
  46676. boundingRect.contain(
  46677. localCursorPoint[0],
  46678. localCursorPoint[1]
  46679. ) && !onIrrelevantElement(e, api, targetModel)
  46680. )
  46681. }
  46682. } // Consider width/height is negative.
  46683. function normalizeRect(rect) {
  46684. return BoundingRect$1.create(rect)
  46685. }
  46686. var inner$4 = makeInner()
  46687. var clone$1 = clone$3
  46688. var bind = bind$1
  46689. /**
  46690. * Base axis pointer class in 2D.
  46691. */ var BaseAxisPointer = /** @class */ (function () {
  46692. function BaseAxisPointer() {
  46693. this._dragging = false
  46694. /**
  46695. * In px, arbitrary value. Do not set too small,
  46696. * no animation is ok for most cases.
  46697. */ this.animationThreshold = 15
  46698. }
  46699. /**
  46700. * @implement
  46701. */ BaseAxisPointer.prototype.render = function (
  46702. axisModel,
  46703. axisPointerModel,
  46704. api,
  46705. forceRender
  46706. ) {
  46707. var value = axisPointerModel.get('value')
  46708. var status = axisPointerModel.get('status') // Bind them to `this`, not in closure, otherwise they will not
  46709. // be replaced when user calling setOption in not merge mode.
  46710. this._axisModel = axisModel
  46711. this._axisPointerModel = axisPointerModel
  46712. this._api = api // Optimize: `render` will be called repeatly during mouse move.
  46713. // So it is power consuming if performing `render` each time,
  46714. // especially on mobile device.
  46715. if (
  46716. !forceRender &&
  46717. this._lastValue === value &&
  46718. this._lastStatus === status
  46719. ) {
  46720. return
  46721. }
  46722. this._lastValue = value
  46723. this._lastStatus = status
  46724. var group = this._group
  46725. var handle = this._handle
  46726. if (!status || status === 'hide') {
  46727. // Do not clear here, for animation better.
  46728. group && group.hide()
  46729. handle && handle.hide()
  46730. return
  46731. }
  46732. group && group.show()
  46733. handle && handle.show() // Otherwise status is 'show'
  46734. var elOption = {}
  46735. this.makeElOption(
  46736. elOption,
  46737. value,
  46738. axisModel,
  46739. axisPointerModel,
  46740. api
  46741. ) // Enable change axis pointer type.
  46742. var graphicKey = elOption.graphicKey
  46743. if (graphicKey !== this._lastGraphicKey) {
  46744. this.clear(api)
  46745. }
  46746. this._lastGraphicKey = graphicKey
  46747. var moveAnimation = (this._moveAnimation =
  46748. this.determineAnimation(axisModel, axisPointerModel))
  46749. if (!group) {
  46750. group = this._group = new Group$3()
  46751. this.createPointerEl(
  46752. group,
  46753. elOption,
  46754. axisModel,
  46755. axisPointerModel
  46756. )
  46757. this.createLabelEl(group, elOption, axisModel, axisPointerModel)
  46758. api.getZr().add(group)
  46759. } else {
  46760. var doUpdateProps = curry$1(
  46761. updateProps,
  46762. axisPointerModel,
  46763. moveAnimation
  46764. )
  46765. this.updatePointerEl(group, elOption, doUpdateProps)
  46766. this.updateLabelEl(
  46767. group,
  46768. elOption,
  46769. doUpdateProps,
  46770. axisPointerModel
  46771. )
  46772. }
  46773. updateMandatoryProps(group, axisPointerModel, true)
  46774. this._renderHandle(value)
  46775. }
  46776. /**
  46777. * @implement
  46778. */ BaseAxisPointer.prototype.remove = function (api) {
  46779. this.clear(api)
  46780. }
  46781. /**
  46782. * @implement
  46783. */ BaseAxisPointer.prototype.dispose = function (api) {
  46784. this.clear(api)
  46785. }
  46786. /**
  46787. * @protected
  46788. */ BaseAxisPointer.prototype.determineAnimation = function (
  46789. axisModel,
  46790. axisPointerModel
  46791. ) {
  46792. var animation = axisPointerModel.get('animation')
  46793. var axis = axisModel.axis
  46794. var isCategoryAxis = axis.type === 'category'
  46795. var useSnap = axisPointerModel.get('snap') // Value axis without snap always do not snap.
  46796. if (!useSnap && !isCategoryAxis) {
  46797. return false
  46798. }
  46799. if (animation === 'auto' || animation == null) {
  46800. var animationThreshold = this.animationThreshold
  46801. if (
  46802. isCategoryAxis &&
  46803. axis.getBandWidth() > animationThreshold
  46804. ) {
  46805. return true
  46806. } // It is important to auto animation when snap used. Consider if there is
  46807. // a dataZoom, animation will be disabled when too many points exist, while
  46808. // it will be enabled for better visual effect when little points exist.
  46809. if (useSnap) {
  46810. var seriesDataCount = getAxisInfo(axisModel).seriesDataCount
  46811. var axisExtent = axis.getExtent() // Approximate band width
  46812. return (
  46813. Math.abs(axisExtent[0] - axisExtent[1]) / seriesDataCount >
  46814. animationThreshold
  46815. )
  46816. }
  46817. return false
  46818. }
  46819. return animation === true
  46820. }
  46821. /**
  46822. * add {pointer, label, graphicKey} to elOption
  46823. * @protected
  46824. */ BaseAxisPointer.prototype.makeElOption = function (
  46825. elOption,
  46826. value,
  46827. axisModel,
  46828. axisPointerModel,
  46829. api
  46830. ) {
  46831. // Shoule be implemenented by sub-class.
  46832. }
  46833. /**
  46834. * @protected
  46835. */ BaseAxisPointer.prototype.createPointerEl = function (
  46836. group,
  46837. elOption,
  46838. axisModel,
  46839. axisPointerModel
  46840. ) {
  46841. var pointerOption = elOption.pointer
  46842. if (pointerOption) {
  46843. var pointerEl = (inner$4(group).pointerEl = new graphic[
  46844. pointerOption.type
  46845. ](clone$1(elOption.pointer)))
  46846. group.add(pointerEl)
  46847. }
  46848. }
  46849. /**
  46850. * @protected
  46851. */ BaseAxisPointer.prototype.createLabelEl = function (
  46852. group,
  46853. elOption,
  46854. axisModel,
  46855. axisPointerModel
  46856. ) {
  46857. if (elOption.label) {
  46858. var labelEl = (inner$4(group).labelEl = new ZRText$1(
  46859. clone$1(elOption.label)
  46860. ))
  46861. group.add(labelEl)
  46862. updateLabelShowHide(labelEl, axisPointerModel)
  46863. }
  46864. }
  46865. /**
  46866. * @protected
  46867. */ BaseAxisPointer.prototype.updatePointerEl = function (
  46868. group,
  46869. elOption,
  46870. updateProps
  46871. ) {
  46872. var pointerEl = inner$4(group).pointerEl
  46873. if (pointerEl && elOption.pointer) {
  46874. pointerEl.setStyle(elOption.pointer.style)
  46875. updateProps(pointerEl, { shape: elOption.pointer.shape })
  46876. }
  46877. }
  46878. /**
  46879. * @protected
  46880. */ BaseAxisPointer.prototype.updateLabelEl = function (
  46881. group,
  46882. elOption,
  46883. updateProps,
  46884. axisPointerModel
  46885. ) {
  46886. var labelEl = inner$4(group).labelEl
  46887. if (labelEl) {
  46888. labelEl.setStyle(elOption.label.style)
  46889. updateProps(labelEl, {
  46890. // Consider text length change in vertical axis, animation should
  46891. // be used on shape, otherwise the effect will be weird.
  46892. // TODOTODO
  46893. // shape: elOption.label.shape,
  46894. x: elOption.label.x,
  46895. y: elOption.label.y
  46896. })
  46897. updateLabelShowHide(labelEl, axisPointerModel)
  46898. }
  46899. }
  46900. /**
  46901. * @private
  46902. */ BaseAxisPointer.prototype._renderHandle = function (value) {
  46903. if (this._dragging || !this.updateHandleTransform) {
  46904. return
  46905. }
  46906. var axisPointerModel = this._axisPointerModel
  46907. var zr = this._api.getZr()
  46908. var handle = this._handle
  46909. var handleModel = axisPointerModel.getModel('handle')
  46910. var status = axisPointerModel.get('status')
  46911. if (!handleModel.get('show') || !status || status === 'hide') {
  46912. handle && zr.remove(handle)
  46913. this._handle = null
  46914. return
  46915. }
  46916. var isInit
  46917. if (!this._handle) {
  46918. isInit = true
  46919. handle = this._handle = createIcon(handleModel.get('icon'), {
  46920. cursor: 'move',
  46921. draggable: true,
  46922. onmousemove: function onmousemove(e) {
  46923. // Fot mobile devicem, prevent screen slider on the button.
  46924. stop(e.event)
  46925. },
  46926. onmousedown: bind(this._onHandleDragMove, this, 0, 0),
  46927. drift: bind(this._onHandleDragMove, this),
  46928. ondragend: bind(this._onHandleDragEnd, this)
  46929. })
  46930. zr.add(handle)
  46931. }
  46932. updateMandatoryProps(handle, axisPointerModel, false) // update style
  46933. handle.setStyle(
  46934. handleModel.getItemStyle(null, [
  46935. 'color',
  46936. 'borderColor',
  46937. 'borderWidth',
  46938. 'opacity',
  46939. 'shadowColor',
  46940. 'shadowBlur',
  46941. 'shadowOffsetX',
  46942. 'shadowOffsetY'
  46943. ])
  46944. ) // update position
  46945. var handleSize = handleModel.get('size')
  46946. if (!isArray(handleSize)) {
  46947. handleSize = [handleSize, handleSize]
  46948. }
  46949. handle.scaleX = handleSize[0] / 2
  46950. handle.scaleY = handleSize[1] / 2
  46951. createOrUpdate(
  46952. this,
  46953. '_doDispatchAxisPointer',
  46954. handleModel.get('throttle') || 0,
  46955. 'fixRate'
  46956. )
  46957. this._moveHandleToValue(value, isInit)
  46958. }
  46959. BaseAxisPointer.prototype._moveHandleToValue = function (
  46960. value,
  46961. isInit
  46962. ) {
  46963. updateProps(
  46964. this._axisPointerModel,
  46965. !isInit && this._moveAnimation,
  46966. this._handle,
  46967. getHandleTransProps(
  46968. this.getHandleTransform(
  46969. value,
  46970. this._axisModel,
  46971. this._axisPointerModel
  46972. )
  46973. )
  46974. )
  46975. }
  46976. BaseAxisPointer.prototype._onHandleDragMove = function (dx, dy) {
  46977. var handle = this._handle
  46978. if (!handle) {
  46979. return
  46980. }
  46981. this._dragging = true // Persistent for throttle.
  46982. var trans = this.updateHandleTransform(
  46983. getHandleTransProps(handle),
  46984. [dx, dy],
  46985. this._axisModel,
  46986. this._axisPointerModel
  46987. )
  46988. this._payloadInfo = trans
  46989. handle.stopAnimation()
  46990. handle.attr(getHandleTransProps(trans))
  46991. inner$4(handle).lastProp = null
  46992. this._doDispatchAxisPointer()
  46993. }
  46994. /**
  46995. * Throttled method.
  46996. */ BaseAxisPointer.prototype._doDispatchAxisPointer = function () {
  46997. var handle = this._handle
  46998. if (!handle) {
  46999. return
  47000. }
  47001. var payloadInfo = this._payloadInfo
  47002. var axisModel = this._axisModel
  47003. this._api.dispatchAction({
  47004. type: 'updateAxisPointer',
  47005. x: payloadInfo.cursorPoint[0],
  47006. y: payloadInfo.cursorPoint[1],
  47007. tooltipOption: payloadInfo.tooltipOption,
  47008. axesInfo: [
  47009. {
  47010. axisDim: axisModel.axis.dim,
  47011. axisIndex: axisModel.componentIndex
  47012. }
  47013. ]
  47014. })
  47015. }
  47016. BaseAxisPointer.prototype._onHandleDragEnd = function () {
  47017. this._dragging = false
  47018. var handle = this._handle
  47019. if (!handle) {
  47020. return
  47021. }
  47022. var value = this._axisPointerModel.get('value') // Consider snap or categroy axis, handle may be not consistent with
  47023. // axisPointer. So move handle to align the exact value position when
  47024. // drag ended.
  47025. this._moveHandleToValue(value) // For the effect: tooltip will be shown when finger holding on handle
  47026. // button, and will be hidden after finger left handle button.
  47027. this._api.dispatchAction({ type: 'hideTip' })
  47028. }
  47029. /**
  47030. * @private
  47031. */ BaseAxisPointer.prototype.clear = function (api) {
  47032. this._lastValue = null
  47033. this._lastStatus = null
  47034. var zr = api.getZr()
  47035. var group = this._group
  47036. var handle = this._handle
  47037. if (zr && group) {
  47038. this._lastGraphicKey = null
  47039. group && zr.remove(group)
  47040. handle && zr.remove(handle)
  47041. this._group = null
  47042. this._handle = null
  47043. this._payloadInfo = null
  47044. }
  47045. clear$1(this, '_doDispatchAxisPointer')
  47046. }
  47047. /**
  47048. * @protected
  47049. */ BaseAxisPointer.prototype.doClear = function () {
  47050. // Implemented by sub-class if necessary.
  47051. }
  47052. BaseAxisPointer.prototype.buildLabel = function (
  47053. xy,
  47054. wh,
  47055. xDimIndex
  47056. ) {
  47057. xDimIndex = xDimIndex || 0
  47058. return {
  47059. x: xy[xDimIndex],
  47060. y: xy[1 - xDimIndex],
  47061. width: wh[xDimIndex],
  47062. height: wh[1 - xDimIndex]
  47063. }
  47064. }
  47065. return BaseAxisPointer
  47066. })()
  47067. function updateProps(animationModel, moveAnimation, el, props) {
  47068. // Animation optimize.
  47069. if (!propsEqual(inner$4(el).lastProp, props)) {
  47070. inner$4(el).lastProp = props
  47071. moveAnimation
  47072. ? updateProps$1(el, props, animationModel)
  47073. : (el.stopAnimation(), el.attr(props))
  47074. }
  47075. }
  47076. function propsEqual(lastProps, newProps) {
  47077. if (isObject$2(lastProps) && isObject$2(newProps)) {
  47078. var equals_1 = true
  47079. each$7(newProps, function (item, key) {
  47080. equals_1 = equals_1 && propsEqual(lastProps[key], item)
  47081. })
  47082. return !!equals_1
  47083. } else {
  47084. return lastProps === newProps
  47085. }
  47086. }
  47087. function updateLabelShowHide(labelEl, axisPointerModel) {
  47088. labelEl[axisPointerModel.get(['label', 'show']) ? 'show' : 'hide']()
  47089. }
  47090. function getHandleTransProps(trans) {
  47091. return {
  47092. x: trans.x || 0,
  47093. y: trans.y || 0,
  47094. rotation: trans.rotation || 0
  47095. }
  47096. }
  47097. function updateMandatoryProps(group, axisPointerModel, silent) {
  47098. var z = axisPointerModel.get('z')
  47099. var zlevel = axisPointerModel.get('zlevel')
  47100. group &&
  47101. group.traverse(function (el) {
  47102. if (el.type !== 'group') {
  47103. z != null && (el.z = z)
  47104. zlevel != null && (el.zlevel = zlevel)
  47105. el.silent = silent
  47106. }
  47107. })
  47108. }
  47109. var BaseAxisPointer$1 = BaseAxisPointer
  47110. function buildElStyle(axisPointerModel) {
  47111. var axisPointerType = axisPointerModel.get('type')
  47112. var styleModel = axisPointerModel.getModel(
  47113. axisPointerType + 'Style'
  47114. )
  47115. var style
  47116. if (axisPointerType === 'line') {
  47117. style = styleModel.getLineStyle()
  47118. style.fill = null
  47119. } else if (axisPointerType === 'shadow') {
  47120. style = styleModel.getAreaStyle()
  47121. style.stroke = null
  47122. }
  47123. return style
  47124. }
  47125. /**
  47126. * @param {Function} labelPos {align, verticalAlign, position}
  47127. */ function buildLabelElOption(
  47128. elOption,
  47129. axisModel,
  47130. axisPointerModel,
  47131. api,
  47132. labelPos
  47133. ) {
  47134. var value = axisPointerModel.get('value')
  47135. var text = getValueLabel(
  47136. value,
  47137. axisModel.axis,
  47138. axisModel.ecModel,
  47139. axisPointerModel.get('seriesDataIndices'),
  47140. {
  47141. precision: axisPointerModel.get(['label', 'precision']),
  47142. formatter: axisPointerModel.get(['label', 'formatter'])
  47143. }
  47144. )
  47145. var labelModel = axisPointerModel.getModel('label')
  47146. var paddings = normalizeCssArray(labelModel.get('padding') || 0)
  47147. var font = labelModel.getFont()
  47148. var textRect = getBoundingRect(text, font)
  47149. var position = labelPos.position
  47150. var width = textRect.width + paddings[1] + paddings[3]
  47151. var height = textRect.height + paddings[0] + paddings[2] // Adjust by align.
  47152. var align = labelPos.align
  47153. align === 'right' && (position[0] -= width)
  47154. align === 'center' && (position[0] -= width / 2)
  47155. var verticalAlign = labelPos.verticalAlign
  47156. verticalAlign === 'bottom' && (position[1] -= height)
  47157. verticalAlign === 'middle' && (position[1] -= height / 2) // Not overflow ec container
  47158. confineInContainer(position, width, height, api)
  47159. var bgColor = labelModel.get('backgroundColor')
  47160. if (!bgColor || bgColor === 'auto') {
  47161. bgColor = axisModel.get(['axisLine', 'lineStyle', 'color'])
  47162. }
  47163. elOption.label = {
  47164. // shape: {x: 0, y: 0, width: width, height: height, r: labelModel.get('borderRadius')},
  47165. x: position[0],
  47166. y: position[1],
  47167. style: createTextStyle(labelModel, {
  47168. text: text,
  47169. font: font,
  47170. fill: labelModel.getTextColor(),
  47171. padding: paddings,
  47172. backgroundColor: bgColor
  47173. }), // Lable should be over axisPointer.
  47174. z2: 10
  47175. }
  47176. } // Do not overflow ec container
  47177. function confineInContainer(position, width, height, api) {
  47178. var viewWidth = api.getWidth()
  47179. var viewHeight = api.getHeight()
  47180. position[0] = Math.min(position[0] + width, viewWidth) - width
  47181. position[1] = Math.min(position[1] + height, viewHeight) - height
  47182. position[0] = Math.max(position[0], 0)
  47183. position[1] = Math.max(position[1], 0)
  47184. }
  47185. function getValueLabel(value, axis, ecModel, seriesDataIndices, opt) {
  47186. value = axis.scale.parse(value)
  47187. var text = axis.scale.getLabel(
  47188. { value: value },
  47189. {
  47190. // If `precision` is set, width can be fixed (like '12.00500'), which
  47191. // helps to debounce when when moving label.
  47192. precision: opt.precision
  47193. }
  47194. )
  47195. var formatter = opt.formatter
  47196. if (formatter) {
  47197. var params_1 = {
  47198. value: getAxisRawValue(axis, { value: value }),
  47199. axisDimension: axis.dim,
  47200. axisIndex: axis.index,
  47201. seriesData: []
  47202. }
  47203. each$7(seriesDataIndices, function (idxItem) {
  47204. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex)
  47205. var dataIndex = idxItem.dataIndexInside
  47206. var dataParams = series && series.getDataParams(dataIndex)
  47207. dataParams && params_1.seriesData.push(dataParams)
  47208. })
  47209. if (isString(formatter)) {
  47210. text = formatter.replace('{value}', text)
  47211. } else if (isFunction(formatter)) {
  47212. text = formatter(params_1)
  47213. }
  47214. }
  47215. return text
  47216. }
  47217. function getTransformedPosition(axis, value, layoutInfo) {
  47218. var transform = create()
  47219. rotate(transform, transform, layoutInfo.rotation)
  47220. translate(transform, transform, layoutInfo.position)
  47221. return applyTransform(
  47222. [
  47223. axis.dataToCoord(value),
  47224. (layoutInfo.labelOffset || 0) +
  47225. (layoutInfo.labelDirection || 1) *
  47226. (layoutInfo.labelMargin || 0)
  47227. ],
  47228. transform
  47229. )
  47230. }
  47231. function buildCartesianSingleLabelElOption(
  47232. value,
  47233. elOption,
  47234. layoutInfo,
  47235. axisModel,
  47236. axisPointerModel,
  47237. api
  47238. ) {
  47239. // @ts-ignore
  47240. var textLayout = AxisBuilder$1.innerTextLayout(
  47241. layoutInfo.rotation,
  47242. 0,
  47243. layoutInfo.labelDirection
  47244. )
  47245. layoutInfo.labelMargin = axisPointerModel.get(['label', 'margin'])
  47246. buildLabelElOption(elOption, axisModel, axisPointerModel, api, {
  47247. position: getTransformedPosition(
  47248. axisModel.axis,
  47249. value,
  47250. layoutInfo
  47251. ),
  47252. align: textLayout.textAlign,
  47253. verticalAlign: textLayout.textVerticalAlign
  47254. })
  47255. }
  47256. function makeLineShape(p1, p2, xDimIndex) {
  47257. xDimIndex = xDimIndex || 0
  47258. return {
  47259. x1: p1[xDimIndex],
  47260. y1: p1[1 - xDimIndex],
  47261. x2: p2[xDimIndex],
  47262. y2: p2[1 - xDimIndex]
  47263. }
  47264. }
  47265. function makeRectShape(xy, wh, xDimIndex) {
  47266. xDimIndex = xDimIndex || 0
  47267. return {
  47268. x: xy[xDimIndex],
  47269. y: xy[1 - xDimIndex],
  47270. width: wh[xDimIndex],
  47271. height: wh[1 - xDimIndex]
  47272. }
  47273. }
  47274. var CartesianAxisPointer = /** @class */ (function (_super) {
  47275. __extends(CartesianAxisPointer, _super)
  47276. function CartesianAxisPointer() {
  47277. return (_super !== null && _super.apply(this, arguments)) || this
  47278. }
  47279. /**
  47280. * @override
  47281. */ CartesianAxisPointer.prototype.makeElOption = function (
  47282. elOption,
  47283. value,
  47284. axisModel,
  47285. axisPointerModel,
  47286. api
  47287. ) {
  47288. var axis = axisModel.axis
  47289. var grid = axis.grid
  47290. var axisPointerType = axisPointerModel.get('type')
  47291. var otherExtent = getCartesian(grid, axis)
  47292. .getOtherAxis(axis)
  47293. .getGlobalExtent()
  47294. var pixelValue = axis.toGlobalCoord(axis.dataToCoord(value, true))
  47295. if (axisPointerType && axisPointerType !== 'none') {
  47296. var elStyle = buildElStyle(axisPointerModel)
  47297. var pointerOption = pointerShapeBuilder[axisPointerType](
  47298. axis,
  47299. pixelValue,
  47300. otherExtent
  47301. )
  47302. pointerOption.style = elStyle
  47303. elOption.graphicKey = pointerOption.type
  47304. elOption.pointer = pointerOption
  47305. }
  47306. var layoutInfo = layout$1(grid.model, axisModel)
  47307. buildCartesianSingleLabelElOption(
  47308. // @ts-ignore
  47309. value,
  47310. elOption,
  47311. layoutInfo,
  47312. axisModel,
  47313. axisPointerModel,
  47314. api
  47315. )
  47316. }
  47317. /**
  47318. * @override
  47319. */ CartesianAxisPointer.prototype.getHandleTransform = function (
  47320. value,
  47321. axisModel,
  47322. axisPointerModel
  47323. ) {
  47324. var layoutInfo = layout$1(axisModel.axis.grid.model, axisModel, {
  47325. labelInside: false
  47326. }) // @ts-ignore
  47327. layoutInfo.labelMargin = axisPointerModel.get([
  47328. 'handle',
  47329. 'margin'
  47330. ])
  47331. var pos = getTransformedPosition(
  47332. axisModel.axis,
  47333. value,
  47334. layoutInfo
  47335. )
  47336. return {
  47337. x: pos[0],
  47338. y: pos[1],
  47339. rotation:
  47340. layoutInfo.rotation +
  47341. (layoutInfo.labelDirection < 0 ? Math.PI : 0)
  47342. }
  47343. }
  47344. /**
  47345. * @override
  47346. */ CartesianAxisPointer.prototype.updateHandleTransform =
  47347. function (transform, delta, axisModel, axisPointerModel) {
  47348. var axis = axisModel.axis
  47349. var grid = axis.grid
  47350. var axisExtent = axis.getGlobalExtent(true)
  47351. var otherExtent = getCartesian(grid, axis)
  47352. .getOtherAxis(axis)
  47353. .getGlobalExtent()
  47354. var dimIndex = axis.dim === 'x' ? 0 : 1
  47355. var currPosition = [transform.x, transform.y]
  47356. currPosition[dimIndex] += delta[dimIndex]
  47357. currPosition[dimIndex] = Math.min(
  47358. axisExtent[1],
  47359. currPosition[dimIndex]
  47360. )
  47361. currPosition[dimIndex] = Math.max(
  47362. axisExtent[0],
  47363. currPosition[dimIndex]
  47364. )
  47365. var cursorOtherValue = (otherExtent[1] + otherExtent[0]) / 2
  47366. var cursorPoint = [cursorOtherValue, cursorOtherValue]
  47367. cursorPoint[dimIndex] = currPosition[dimIndex] // Make tooltip do not overlap axisPointer and in the middle of the grid.
  47368. var tooltipOptions = [
  47369. { verticalAlign: 'middle' },
  47370. { align: 'center' }
  47371. ]
  47372. return {
  47373. x: currPosition[0],
  47374. y: currPosition[1],
  47375. rotation: transform.rotation,
  47376. cursorPoint: cursorPoint,
  47377. tooltipOption: tooltipOptions[dimIndex]
  47378. }
  47379. }
  47380. return CartesianAxisPointer
  47381. })(BaseAxisPointer$1)
  47382. function getCartesian(grid, axis) {
  47383. var opt = {}
  47384. opt[axis.dim + 'AxisIndex'] = axis.index
  47385. return grid.getCartesian(opt)
  47386. }
  47387. var pointerShapeBuilder = {
  47388. line: function line(axis, pixelValue, otherExtent) {
  47389. var targetShape = makeLineShape(
  47390. [pixelValue, otherExtent[0]],
  47391. [pixelValue, otherExtent[1]],
  47392. getAxisDimIndex(axis)
  47393. )
  47394. return {
  47395. type: 'Line',
  47396. subPixelOptimize: true,
  47397. shape: targetShape
  47398. }
  47399. },
  47400. shadow: function shadow(axis, pixelValue, otherExtent) {
  47401. var bandWidth = Math.max(1, axis.getBandWidth())
  47402. var span = otherExtent[1] - otherExtent[0]
  47403. return {
  47404. type: 'Rect',
  47405. shape: makeRectShape(
  47406. [pixelValue - bandWidth / 2, otherExtent[0]],
  47407. [bandWidth, span],
  47408. getAxisDimIndex(axis)
  47409. )
  47410. }
  47411. }
  47412. }
  47413. function getAxisDimIndex(axis) {
  47414. return axis.dim === 'x' ? 0 : 1
  47415. }
  47416. var CartesianAxisPointer$1 = CartesianAxisPointer
  47417. var AxisPointerModel = /** @class */ (function (_super) {
  47418. __extends(AxisPointerModel, _super)
  47419. function AxisPointerModel() {
  47420. var _this =
  47421. (_super !== null && _super.apply(this, arguments)) || this
  47422. _this.type = AxisPointerModel.type
  47423. return _this
  47424. }
  47425. AxisPointerModel.type = 'axisPointer'
  47426. AxisPointerModel.defaultOption = {
  47427. // 'auto' means that show when triggered by tooltip or handle.
  47428. show: 'auto', // zlevel: 0,
  47429. z: 50,
  47430. type: 'line', // axispointer triggered by tootip determine snap automatically,
  47431. // see `modelHelper`.
  47432. snap: false,
  47433. triggerTooltip: true,
  47434. value: null,
  47435. status: null,
  47436. link: [], // Do not set 'auto' here, otherwise global animation: false
  47437. // will not effect at this axispointer.
  47438. animation: null,
  47439. animationDurationUpdate: 200,
  47440. lineStyle: { color: '#B9BEC9', width: 1, type: 'dashed' },
  47441. shadowStyle: { color: 'rgba(210,219,238,0.2)' },
  47442. label: {
  47443. show: true,
  47444. formatter: null,
  47445. precision: 'auto',
  47446. margin: 3,
  47447. color: '#fff',
  47448. padding: [5, 7, 5, 7],
  47449. backgroundColor: 'auto',
  47450. borderColor: null,
  47451. borderWidth: 0,
  47452. borderRadius: 3
  47453. },
  47454. handle: {
  47455. show: false, // eslint-disable-next-line
  47456. 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',
  47457. size: 45, // handle margin is from symbol center to axis, which is stable when circular move.
  47458. margin: 50, // color: '#1b8bbd'
  47459. // color: '#2f4554'
  47460. color: '#333',
  47461. shadowBlur: 3,
  47462. shadowColor: '#aaa',
  47463. shadowOffsetX: 0,
  47464. shadowOffsetY: 2, // For mobile performance
  47465. throttle: 40
  47466. }
  47467. }
  47468. return AxisPointerModel
  47469. })(ComponentModel$1)
  47470. var AxisPointerModel$1 = AxisPointerModel
  47471. var inner$3 = makeInner()
  47472. var each$4 = each$7
  47473. /**
  47474. * @param {string} key
  47475. * @param {module:echarts/ExtensionAPI} api
  47476. * @param {Function} handler
  47477. * param: {string} currTrigger
  47478. * param: {Array.<number>} point
  47479. */ function register(key, api, handler) {
  47480. if (env$1.node) {
  47481. return
  47482. }
  47483. var zr = api.getZr()
  47484. inner$3(zr).records || (inner$3(zr).records = {})
  47485. initGlobalListeners(zr, api)
  47486. var record =
  47487. inner$3(zr).records[key] || (inner$3(zr).records[key] = {})
  47488. record.handler = handler
  47489. }
  47490. function initGlobalListeners(zr, api) {
  47491. if (inner$3(zr).initialized) {
  47492. return
  47493. }
  47494. inner$3(zr).initialized = true
  47495. useHandler('click', curry$1(doEnter, 'click'))
  47496. useHandler('mousemove', curry$1(doEnter, 'mousemove')) // useHandler('mouseout', onLeave);
  47497. useHandler('globalout', onLeave)
  47498. function useHandler(eventType, cb) {
  47499. zr.on(eventType, function (e) {
  47500. var dis = makeDispatchAction$1(api)
  47501. each$4(inner$3(zr).records, function (record) {
  47502. record && cb(record, e, dis.dispatchAction)
  47503. })
  47504. dispatchTooltipFinally(dis.pendings, api)
  47505. })
  47506. }
  47507. }
  47508. function dispatchTooltipFinally(pendings, api) {
  47509. var showLen = pendings.showTip.length
  47510. var hideLen = pendings.hideTip.length
  47511. var actuallyPayload
  47512. if (showLen) {
  47513. actuallyPayload = pendings.showTip[showLen - 1]
  47514. } else if (hideLen) {
  47515. actuallyPayload = pendings.hideTip[hideLen - 1]
  47516. }
  47517. if (actuallyPayload) {
  47518. actuallyPayload.dispatchAction = null
  47519. api.dispatchAction(actuallyPayload)
  47520. }
  47521. }
  47522. function onLeave(record, e, dispatchAction) {
  47523. record.handler('leave', null, dispatchAction)
  47524. }
  47525. function doEnter(currTrigger, record, e, dispatchAction) {
  47526. record.handler(currTrigger, e, dispatchAction)
  47527. }
  47528. function makeDispatchAction$1(api) {
  47529. var pendings = { showTip: [], hideTip: [] } // FIXME
  47530. // better approach?
  47531. // 'showTip' and 'hideTip' can be triggered by axisPointer and tooltip,
  47532. // which may be conflict, (axisPointer call showTip but tooltip call hideTip);
  47533. // So we have to add "final stage" to merge those dispatched actions.
  47534. var dispatchAction = function dispatchAction(payload) {
  47535. var pendingList = pendings[payload.type]
  47536. if (pendingList) {
  47537. pendingList.push(payload)
  47538. } else {
  47539. payload.dispatchAction = dispatchAction
  47540. api.dispatchAction(payload)
  47541. }
  47542. }
  47543. return { dispatchAction: dispatchAction, pendings: pendings }
  47544. }
  47545. function unregister(key, api) {
  47546. if (env$1.node) {
  47547. return
  47548. }
  47549. var zr = api.getZr()
  47550. var record = (inner$3(zr).records || {})[key]
  47551. if (record) {
  47552. inner$3(zr).records[key] = null
  47553. }
  47554. }
  47555. var AxisPointerView = /** @class */ (function (_super) {
  47556. __extends(AxisPointerView, _super)
  47557. function AxisPointerView() {
  47558. var _this =
  47559. (_super !== null && _super.apply(this, arguments)) || this
  47560. _this.type = AxisPointerView.type
  47561. return _this
  47562. }
  47563. AxisPointerView.prototype.render = function (
  47564. globalAxisPointerModel,
  47565. ecModel,
  47566. api
  47567. ) {
  47568. var globalTooltipModel = ecModel.getComponent('tooltip')
  47569. var triggerOn =
  47570. globalAxisPointerModel.get('triggerOn') ||
  47571. (globalTooltipModel && globalTooltipModel.get('triggerOn')) ||
  47572. 'mousemove|click' // Register global listener in AxisPointerView to enable
  47573. // AxisPointerView to be independent to Tooltip.
  47574. register(
  47575. 'axisPointer',
  47576. api,
  47577. function (currTrigger, e, dispatchAction) {
  47578. // If 'none', it is not controlled by mouse totally.
  47579. if (
  47580. triggerOn !== 'none' &&
  47581. (currTrigger === 'leave' ||
  47582. triggerOn.indexOf(currTrigger) >= 0)
  47583. ) {
  47584. dispatchAction({
  47585. type: 'updateAxisPointer',
  47586. currTrigger: currTrigger,
  47587. x: e && e.offsetX,
  47588. y: e && e.offsetY
  47589. })
  47590. }
  47591. }
  47592. )
  47593. }
  47594. AxisPointerView.prototype.remove = function (ecModel, api) {
  47595. unregister('axisPointer', api)
  47596. }
  47597. AxisPointerView.prototype.dispose = function (ecModel, api) {
  47598. unregister('axisPointer', api)
  47599. }
  47600. AxisPointerView.type = 'axisPointer'
  47601. return AxisPointerView
  47602. })(ComponentView$1)
  47603. var AxisPointerView$1 = AxisPointerView
  47604. /**
  47605. * @param finder contains {seriesIndex, dataIndex, dataIndexInside}
  47606. * @param ecModel
  47607. * @return {point: [x, y], el: ...} point Will not be null.
  47608. */ function findPointFromSeries(finder, ecModel) {
  47609. var point = []
  47610. var seriesIndex = finder.seriesIndex
  47611. var seriesModel
  47612. if (
  47613. seriesIndex == null ||
  47614. !(seriesModel = ecModel.getSeriesByIndex(seriesIndex))
  47615. ) {
  47616. return { point: [] }
  47617. }
  47618. var data = seriesModel.getData()
  47619. var dataIndex = queryDataIndex(data, finder)
  47620. if (dataIndex == null || dataIndex < 0 || isArray(dataIndex)) {
  47621. return { point: [] }
  47622. }
  47623. var el = data.getItemGraphicEl(dataIndex)
  47624. var coordSys = seriesModel.coordinateSystem
  47625. if (seriesModel.getTooltipPosition) {
  47626. point = seriesModel.getTooltipPosition(dataIndex) || []
  47627. } else if (coordSys && coordSys.dataToPoint) {
  47628. if (finder.isStacked) {
  47629. var baseAxis = coordSys.getBaseAxis()
  47630. var valueAxis = coordSys.getOtherAxis(baseAxis)
  47631. var valueAxisDim = valueAxis.dim
  47632. var baseAxisDim = baseAxis.dim
  47633. var baseDataOffset =
  47634. valueAxisDim === 'x' || valueAxisDim === 'radius' ? 1 : 0
  47635. var baseDim = data.mapDimension(baseAxisDim)
  47636. var stackedData = []
  47637. stackedData[baseDataOffset] = data.get(baseDim, dataIndex)
  47638. stackedData[1 - baseDataOffset] = data.get(
  47639. data.getCalculationInfo('stackResultDimension'),
  47640. dataIndex
  47641. )
  47642. point = coordSys.dataToPoint(stackedData) || []
  47643. } else {
  47644. point =
  47645. coordSys.dataToPoint(
  47646. data.getValues(
  47647. map$1(coordSys.dimensions, function (dim) {
  47648. return data.mapDimension(dim)
  47649. }),
  47650. dataIndex
  47651. )
  47652. ) || []
  47653. }
  47654. } else if (el) {
  47655. // Use graphic bounding rect
  47656. var rect = el.getBoundingRect().clone()
  47657. rect.applyTransform(el.transform)
  47658. point = [rect.x + rect.width / 2, rect.y + rect.height / 2]
  47659. }
  47660. return { point: point, el: el }
  47661. }
  47662. var inner$2 = makeInner()
  47663. /**
  47664. * Basic logic: check all axis, if they do not demand show/highlight,
  47665. * then hide/downplay them.
  47666. *
  47667. * @return content of event obj for echarts.connect.
  47668. */ function axisTrigger(payload, ecModel, api) {
  47669. var currTrigger = payload.currTrigger
  47670. var point = [payload.x, payload.y]
  47671. var finder = payload
  47672. var dispatchAction =
  47673. payload.dispatchAction || bind$1(api.dispatchAction, api)
  47674. var coordSysAxesInfo =
  47675. ecModel.getComponent('axisPointer').coordSysAxesInfo // Pending
  47676. // See #6121. But we are not able to reproduce it yet.
  47677. if (!coordSysAxesInfo) {
  47678. return
  47679. }
  47680. if (illegalPoint(point)) {
  47681. // Used in the default behavior of `connection`: use the sample seriesIndex
  47682. // and dataIndex. And also used in the tooltipView trigger.
  47683. point = findPointFromSeries(
  47684. {
  47685. seriesIndex: finder.seriesIndex, // Do not use dataIndexInside from other ec instance.
  47686. // FIXME: auto detect it?
  47687. dataIndex: finder.dataIndex
  47688. },
  47689. ecModel
  47690. ).point
  47691. }
  47692. var isIllegalPoint = illegalPoint(point) // Axis and value can be specified when calling dispatchAction({type: 'updateAxisPointer'}).
  47693. // Notice: In this case, it is difficult to get the `point` (which is necessary to show
  47694. // tooltip, so if point is not given, we just use the point found by sample seriesIndex
  47695. // and dataIndex.
  47696. var inputAxesInfo = finder.axesInfo
  47697. var axesInfo = coordSysAxesInfo.axesInfo
  47698. var shouldHide = currTrigger === 'leave' || illegalPoint(point)
  47699. var outputPayload = {}
  47700. var showValueMap = {}
  47701. var dataByCoordSys = { list: [], map: {} }
  47702. var updaters = {
  47703. showPointer: curry$1(showPointer, showValueMap),
  47704. showTooltip: curry$1(showTooltip, dataByCoordSys)
  47705. } // Process for triggered axes.
  47706. each$7(
  47707. coordSysAxesInfo.coordSysMap,
  47708. function (coordSys, coordSysKey) {
  47709. // If a point given, it must be contained by the coordinate system.
  47710. var coordSysContainsPoint =
  47711. isIllegalPoint || coordSys.containPoint(point)
  47712. each$7(
  47713. coordSysAxesInfo.coordSysAxesInfo[coordSysKey],
  47714. function (axisInfo, key) {
  47715. var axis = axisInfo.axis
  47716. var inputAxisInfo = findInputAxisInfo(
  47717. inputAxesInfo,
  47718. axisInfo
  47719. ) // If no inputAxesInfo, no axis is restricted.
  47720. if (
  47721. !shouldHide &&
  47722. coordSysContainsPoint &&
  47723. (!inputAxesInfo || inputAxisInfo)
  47724. ) {
  47725. var val = inputAxisInfo && inputAxisInfo.value
  47726. if (val == null && !isIllegalPoint) {
  47727. val = axis.pointToData(point)
  47728. }
  47729. val != null &&
  47730. processOnAxis(
  47731. axisInfo,
  47732. val,
  47733. updaters,
  47734. false,
  47735. outputPayload
  47736. )
  47737. }
  47738. }
  47739. )
  47740. }
  47741. ) // Process for linked axes.
  47742. var linkTriggers = {}
  47743. each$7(axesInfo, function (tarAxisInfo, tarKey) {
  47744. var linkGroup = tarAxisInfo.linkGroup // If axis has been triggered in the previous stage, it should not be triggered by link.
  47745. if (linkGroup && !showValueMap[tarKey]) {
  47746. each$7(linkGroup.axesInfo, function (srcAxisInfo, srcKey) {
  47747. var srcValItem = showValueMap[srcKey] // If srcValItem exist, source axis is triggered, so link to target axis.
  47748. if (srcAxisInfo !== tarAxisInfo && srcValItem) {
  47749. var val = srcValItem.value
  47750. linkGroup.mapper &&
  47751. (val = tarAxisInfo.axis.scale.parse(
  47752. linkGroup.mapper(
  47753. val,
  47754. makeMapperParam(srcAxisInfo),
  47755. makeMapperParam(tarAxisInfo)
  47756. )
  47757. ))
  47758. linkTriggers[tarAxisInfo.key] = val
  47759. }
  47760. })
  47761. }
  47762. })
  47763. each$7(linkTriggers, function (val, tarKey) {
  47764. processOnAxis(
  47765. axesInfo[tarKey],
  47766. val,
  47767. updaters,
  47768. true,
  47769. outputPayload
  47770. )
  47771. })
  47772. updateModelActually(showValueMap, axesInfo, outputPayload)
  47773. dispatchTooltipActually(
  47774. dataByCoordSys,
  47775. point,
  47776. payload,
  47777. dispatchAction
  47778. )
  47779. dispatchHighDownActually(axesInfo, dispatchAction, api)
  47780. return outputPayload
  47781. }
  47782. function processOnAxis(
  47783. axisInfo,
  47784. newValue,
  47785. updaters,
  47786. noSnap,
  47787. outputFinder
  47788. ) {
  47789. var axis = axisInfo.axis
  47790. if (axis.scale.isBlank() || !axis.containData(newValue)) {
  47791. return
  47792. }
  47793. if (!axisInfo.involveSeries) {
  47794. updaters.showPointer(axisInfo, newValue)
  47795. return
  47796. } // Heavy calculation. So put it after axis.containData checking.
  47797. var payloadInfo = buildPayloadsBySeries(newValue, axisInfo)
  47798. var payloadBatch = payloadInfo.payloadBatch
  47799. var snapToValue = payloadInfo.snapToValue // Fill content of event obj for echarts.connect.
  47800. // By default use the first involved series data as a sample to connect.
  47801. if (payloadBatch[0] && outputFinder.seriesIndex == null) {
  47802. extend(outputFinder, payloadBatch[0])
  47803. } // If no linkSource input, this process is for collecting link
  47804. // target, where snap should not be accepted.
  47805. if (!noSnap && axisInfo.snap) {
  47806. if (axis.containData(snapToValue) && snapToValue != null) {
  47807. newValue = snapToValue
  47808. }
  47809. }
  47810. updaters.showPointer(axisInfo, newValue, payloadBatch) // Tooltip should always be snapToValue, otherwise there will be
  47811. // incorrect "axis value ~ series value" mapping displayed in tooltip.
  47812. updaters.showTooltip(axisInfo, payloadInfo, snapToValue)
  47813. }
  47814. function buildPayloadsBySeries(value, axisInfo) {
  47815. var axis = axisInfo.axis
  47816. var dim = axis.dim
  47817. var snapToValue = value
  47818. var payloadBatch = []
  47819. var minDist = Number.MAX_VALUE
  47820. var minDiff = -1
  47821. each$7(axisInfo.seriesModels, function (series, idx) {
  47822. var dataDim = series.getData().mapDimensionsAll(dim)
  47823. var seriesNestestValue
  47824. var dataIndices
  47825. if (series.getAxisTooltipData) {
  47826. var result = series.getAxisTooltipData(dataDim, value, axis)
  47827. dataIndices = result.dataIndices
  47828. seriesNestestValue = result.nestestValue
  47829. } else {
  47830. dataIndices = series.getData().indicesOfNearest(
  47831. dataDim[0],
  47832. value, // Add a threshold to avoid find the wrong dataIndex
  47833. // when data length is not same.
  47834. // false,
  47835. axis.type === 'category' ? 0.5 : null
  47836. )
  47837. if (!dataIndices.length) {
  47838. return
  47839. }
  47840. seriesNestestValue = series
  47841. .getData()
  47842. .get(dataDim[0], dataIndices[0])
  47843. }
  47844. if (seriesNestestValue == null || !isFinite(seriesNestestValue)) {
  47845. return
  47846. }
  47847. var diff = value - seriesNestestValue
  47848. var dist = Math.abs(diff) // Consider category case
  47849. if (dist <= minDist) {
  47850. if (dist < minDist || (diff >= 0 && minDiff < 0)) {
  47851. minDist = dist
  47852. minDiff = diff
  47853. snapToValue = seriesNestestValue
  47854. payloadBatch.length = 0
  47855. }
  47856. each$7(dataIndices, function (dataIndex) {
  47857. payloadBatch.push({
  47858. seriesIndex: series.seriesIndex,
  47859. dataIndexInside: dataIndex,
  47860. dataIndex: series.getData().getRawIndex(dataIndex)
  47861. })
  47862. })
  47863. }
  47864. })
  47865. return { payloadBatch: payloadBatch, snapToValue: snapToValue }
  47866. }
  47867. function showPointer(showValueMap, axisInfo, value, payloadBatch) {
  47868. showValueMap[axisInfo.key] = {
  47869. value: value,
  47870. payloadBatch: payloadBatch
  47871. }
  47872. }
  47873. function showTooltip(dataByCoordSys, axisInfo, payloadInfo, value) {
  47874. var payloadBatch = payloadInfo.payloadBatch
  47875. var axis = axisInfo.axis
  47876. var axisModel = axis.model
  47877. var axisPointerModel = axisInfo.axisPointerModel // If no data, do not create anything in dataByCoordSys,
  47878. // whose length will be used to judge whether dispatch action.
  47879. if (!axisInfo.triggerTooltip || !payloadBatch.length) {
  47880. return
  47881. }
  47882. var coordSysModel = axisInfo.coordSys.model
  47883. var coordSysKey = makeKey(coordSysModel)
  47884. var coordSysItem = dataByCoordSys.map[coordSysKey]
  47885. if (!coordSysItem) {
  47886. coordSysItem = dataByCoordSys.map[coordSysKey] = {
  47887. coordSysId: coordSysModel.id,
  47888. coordSysIndex: coordSysModel.componentIndex,
  47889. coordSysType: coordSysModel.type,
  47890. coordSysMainType: coordSysModel.mainType,
  47891. dataByAxis: []
  47892. }
  47893. dataByCoordSys.list.push(coordSysItem)
  47894. }
  47895. coordSysItem.dataByAxis.push({
  47896. axisDim: axis.dim,
  47897. axisIndex: axisModel.componentIndex,
  47898. axisType: axisModel.type,
  47899. axisId: axisModel.id,
  47900. value: value, // Caustion: viewHelper.getValueLabel is actually on "view stage", which
  47901. // depends that all models have been updated. So it should not be performed
  47902. // here. Considering axisPointerModel used here is volatile, which is hard
  47903. // to be retrieve in TooltipView, we prepare parameters here.
  47904. valueLabelOpt: {
  47905. precision: axisPointerModel.get(['label', 'precision']),
  47906. formatter: axisPointerModel.get(['label', 'formatter'])
  47907. },
  47908. seriesDataIndices: payloadBatch.slice()
  47909. })
  47910. }
  47911. function updateModelActually(showValueMap, axesInfo, outputPayload) {
  47912. var outputAxesInfo = (outputPayload.axesInfo = []) // Basic logic: If no 'show' required, 'hide' this axisPointer.
  47913. each$7(axesInfo, function (axisInfo, key) {
  47914. var option = axisInfo.axisPointerModel.option
  47915. var valItem = showValueMap[key]
  47916. if (valItem) {
  47917. !axisInfo.useHandle && (option.status = 'show')
  47918. option.value = valItem.value // For label formatter param and highlight.
  47919. option.seriesDataIndices = (valItem.payloadBatch || []).slice()
  47920. } // When always show (e.g., handle used), remain
  47921. // original value and status.
  47922. else {
  47923. // If hide, value still need to be set, consider
  47924. // click legend to toggle axis blank.
  47925. !axisInfo.useHandle && (option.status = 'hide')
  47926. } // If status is 'hide', should be no info in payload.
  47927. option.status === 'show' &&
  47928. outputAxesInfo.push({
  47929. axisDim: axisInfo.axis.dim,
  47930. axisIndex: axisInfo.axis.model.componentIndex,
  47931. value: option.value
  47932. })
  47933. })
  47934. }
  47935. function dispatchTooltipActually(
  47936. dataByCoordSys,
  47937. point,
  47938. payload,
  47939. dispatchAction
  47940. ) {
  47941. // Basic logic: If no showTip required, hideTip will be dispatched.
  47942. if (illegalPoint(point) || !dataByCoordSys.list.length) {
  47943. dispatchAction({ type: 'hideTip' })
  47944. return
  47945. } // In most case only one axis (or event one series is used). It is
  47946. // convinient to fetch payload.seriesIndex and payload.dataIndex
  47947. // dirtectly. So put the first seriesIndex and dataIndex of the first
  47948. // axis on the payload.
  47949. var sampleItem =
  47950. ((dataByCoordSys.list[0].dataByAxis[0] || {}).seriesDataIndices ||
  47951. [])[0] || {}
  47952. dispatchAction({
  47953. type: 'showTip',
  47954. escapeConnect: true,
  47955. x: point[0],
  47956. y: point[1],
  47957. tooltipOption: payload.tooltipOption,
  47958. position: payload.position,
  47959. dataIndexInside: sampleItem.dataIndexInside,
  47960. dataIndex: sampleItem.dataIndex,
  47961. seriesIndex: sampleItem.seriesIndex,
  47962. dataByCoordSys: dataByCoordSys.list
  47963. })
  47964. }
  47965. function dispatchHighDownActually(axesInfo, dispatchAction, api) {
  47966. // FIXME
  47967. // highlight status modification shoule be a stage of main process?
  47968. // (Consider confilct (e.g., legend and axisPointer) and setOption)
  47969. var zr = api.getZr()
  47970. var highDownKey = 'axisPointerLastHighlights'
  47971. var lastHighlights = inner$2(zr)[highDownKey] || {}
  47972. var newHighlights = (inner$2(zr)[highDownKey] = {}) // Update highlight/downplay status according to axisPointer model.
  47973. // Build hash map and remove duplicate incidentally.
  47974. each$7(axesInfo, function (axisInfo, key) {
  47975. var option = axisInfo.axisPointerModel.option
  47976. option.status === 'show' &&
  47977. each$7(option.seriesDataIndices, function (batchItem) {
  47978. var key = batchItem.seriesIndex + ' | ' + batchItem.dataIndex
  47979. newHighlights[key] = batchItem
  47980. })
  47981. }) // Diff.
  47982. var toHighlight = []
  47983. var toDownplay = []
  47984. each$7(lastHighlights, function (batchItem, key) {
  47985. !newHighlights[key] && toDownplay.push(batchItem)
  47986. })
  47987. each$7(newHighlights, function (batchItem, key) {
  47988. !lastHighlights[key] && toHighlight.push(batchItem)
  47989. })
  47990. toDownplay.length &&
  47991. api.dispatchAction({
  47992. type: 'downplay',
  47993. escapeConnect: true, // Not blur others when highlight in axisPointer.
  47994. notBlur: true,
  47995. batch: toDownplay
  47996. })
  47997. toHighlight.length &&
  47998. api.dispatchAction({
  47999. type: 'highlight',
  48000. escapeConnect: true, // Not blur others when highlight in axisPointer.
  48001. notBlur: true,
  48002. batch: toHighlight
  48003. })
  48004. }
  48005. function findInputAxisInfo(inputAxesInfo, axisInfo) {
  48006. for (var i = 0; i < (inputAxesInfo || []).length; i++) {
  48007. var inputAxisInfo = inputAxesInfo[i]
  48008. if (
  48009. axisInfo.axis.dim === inputAxisInfo.axisDim &&
  48010. axisInfo.axis.model.componentIndex === inputAxisInfo.axisIndex
  48011. ) {
  48012. return inputAxisInfo
  48013. }
  48014. }
  48015. }
  48016. function makeMapperParam(axisInfo) {
  48017. var axisModel = axisInfo.axis.model
  48018. var item = {}
  48019. var dim = (item.axisDim = axisInfo.axis.dim)
  48020. item.axisIndex = item[dim + 'AxisIndex'] = axisModel.componentIndex
  48021. item.axisName = item[dim + 'AxisName'] = axisModel.name
  48022. item.axisId = item[dim + 'AxisId'] = axisModel.id
  48023. return item
  48024. }
  48025. function illegalPoint(point) {
  48026. return (
  48027. !point ||
  48028. point[0] == null ||
  48029. isNaN(point[0]) ||
  48030. point[1] == null ||
  48031. isNaN(point[1])
  48032. )
  48033. }
  48034. function install$e(registers) {
  48035. // CartesianAxisPointer is not supposed to be required here. But consider
  48036. // echarts.simple.js and online build tooltip, which only require gridSimple,
  48037. // CartesianAxisPointer should be able to required somewhere.
  48038. AxisView$1.registerAxisPointerClass(
  48039. 'CartesianAxisPointer',
  48040. CartesianAxisPointer$1
  48041. )
  48042. registers.registerComponentModel(AxisPointerModel$1)
  48043. registers.registerComponentView(AxisPointerView$1)
  48044. registers.registerPreprocessor(function (option) {
  48045. // Always has a global axisPointerModel for default setting.
  48046. if (option) {
  48047. ;(!option.axisPointer || option.axisPointer.length === 0) &&
  48048. (option.axisPointer = {})
  48049. var link = option.axisPointer.link // Normalize to array to avoid object mergin. But if link
  48050. // is not set, remain null/undefined, otherwise it will
  48051. // override existent link setting.
  48052. if (link && !isArray(link)) {
  48053. option.axisPointer.link = [link]
  48054. }
  48055. }
  48056. }) // This process should proformed after coordinate systems created
  48057. // and series data processed. So put it on statistic processing stage.
  48058. registers.registerProcessor(
  48059. registers.PRIORITY.PROCESSOR.STATISTIC,
  48060. function (ecModel, api) {
  48061. // Build axisPointerModel, mergin tooltip.axisPointer model for each axis.
  48062. // allAxesInfo should be updated when setOption performed.
  48063. ecModel.getComponent('axisPointer').coordSysAxesInfo = collect(
  48064. ecModel,
  48065. api
  48066. )
  48067. }
  48068. ) // Broadcast to all views.
  48069. registers.registerAction(
  48070. {
  48071. type: 'updateAxisPointer',
  48072. event: 'updateAxisPointer',
  48073. update: ':updateAxisPointer'
  48074. },
  48075. axisTrigger
  48076. )
  48077. }
  48078. function install$d(registers) {
  48079. use(install$f)
  48080. use(install$e)
  48081. }
  48082. var DATA_ZOOM_AXIS_DIMENSIONS = [
  48083. 'x',
  48084. 'y',
  48085. 'radius',
  48086. 'angle',
  48087. 'single'
  48088. ] // Supported coords.
  48089. // FIXME: polar has been broken (but rarely used).
  48090. var SERIES_COORDS = ['cartesian2d', 'polar', 'singleAxis']
  48091. function isCoordSupported(seriesModel) {
  48092. var coordType = seriesModel.get('coordinateSystem')
  48093. return indexOf(SERIES_COORDS, coordType) >= 0
  48094. }
  48095. function getAxisMainType(axisDim) {
  48096. return axisDim + 'Axis'
  48097. }
  48098. /**
  48099. * If two dataZoomModels has the same axis controlled, we say that they are 'linked'.
  48100. * This function finds all linked dataZoomModels start from the given payload.
  48101. */ function findEffectedDataZooms(ecModel, payload) {
  48102. // Key: `DataZoomAxisDimension`
  48103. var axisRecords = createHashMap()
  48104. var effectedModels = [] // Key: uid of dataZoomModel
  48105. var effectedModelMap = createHashMap() // Find the dataZooms specified by payload.
  48106. ecModel.eachComponent(
  48107. { mainType: 'dataZoom', query: payload },
  48108. function (dataZoomModel) {
  48109. if (!effectedModelMap.get(dataZoomModel.uid)) {
  48110. addToEffected(dataZoomModel)
  48111. }
  48112. }
  48113. ) // Start from the given dataZoomModels, travel the graph to find
  48114. // all of the linked dataZoom models.
  48115. var foundNewLink
  48116. do {
  48117. foundNewLink = false
  48118. ecModel.eachComponent('dataZoom', processSingle)
  48119. } while (foundNewLink)
  48120. function processSingle(dataZoomModel) {
  48121. if (
  48122. !effectedModelMap.get(dataZoomModel.uid) &&
  48123. isLinked(dataZoomModel)
  48124. ) {
  48125. addToEffected(dataZoomModel)
  48126. foundNewLink = true
  48127. }
  48128. }
  48129. function addToEffected(dataZoom) {
  48130. effectedModelMap.set(dataZoom.uid, true)
  48131. effectedModels.push(dataZoom)
  48132. markAxisControlled(dataZoom)
  48133. }
  48134. function isLinked(dataZoomModel) {
  48135. var isLink = false
  48136. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  48137. var axisIdxArr = axisRecords.get(axisDim)
  48138. if (axisIdxArr && axisIdxArr[axisIndex]) {
  48139. isLink = true
  48140. }
  48141. })
  48142. return isLink
  48143. }
  48144. function markAxisControlled(dataZoomModel) {
  48145. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  48146. ;(axisRecords.get(axisDim) || axisRecords.set(axisDim, []))[
  48147. axisIndex
  48148. ] = true
  48149. })
  48150. }
  48151. return effectedModels
  48152. }
  48153. /**
  48154. * Find the first target coordinate system.
  48155. * Available after model built.
  48156. *
  48157. * @return Like {
  48158. * grid: [
  48159. * {model: coord0, axisModels: [axis1, axis3], coordIndex: 1},
  48160. * {model: coord1, axisModels: [axis0, axis2], coordIndex: 0},
  48161. * ...
  48162. * ], // cartesians must not be null/undefined.
  48163. * polar: [
  48164. * {model: coord0, axisModels: [axis4], coordIndex: 0},
  48165. * ...
  48166. * ], // polars must not be null/undefined.
  48167. * singleAxis: [
  48168. * {model: coord0, axisModels: [], coordIndex: 0}
  48169. * ]
  48170. * }
  48171. */ function collectReferCoordSysModelInfo(dataZoomModel) {
  48172. var ecModel = dataZoomModel.ecModel
  48173. var coordSysInfoWrap = { infoList: [], infoMap: createHashMap() }
  48174. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  48175. var axisModel = ecModel.getComponent(
  48176. getAxisMainType(axisDim),
  48177. axisIndex
  48178. )
  48179. if (!axisModel) {
  48180. return
  48181. }
  48182. var coordSysModel = axisModel.getCoordSysModel()
  48183. if (!coordSysModel) {
  48184. return
  48185. }
  48186. var coordSysUid = coordSysModel.uid
  48187. var coordSysInfo = coordSysInfoWrap.infoMap.get(coordSysUid)
  48188. if (!coordSysInfo) {
  48189. coordSysInfo = { model: coordSysModel, axisModels: [] }
  48190. coordSysInfoWrap.infoList.push(coordSysInfo)
  48191. coordSysInfoWrap.infoMap.set(coordSysUid, coordSysInfo)
  48192. }
  48193. coordSysInfo.axisModels.push(axisModel)
  48194. })
  48195. return coordSysInfoWrap
  48196. }
  48197. var DataZoomAxisInfo = /** @class */ (function () {
  48198. function DataZoomAxisInfo() {
  48199. this.indexList = []
  48200. this.indexMap = []
  48201. }
  48202. DataZoomAxisInfo.prototype.add = function (axisCmptIdx) {
  48203. // Remove duplication.
  48204. if (!this.indexMap[axisCmptIdx]) {
  48205. this.indexList.push(axisCmptIdx)
  48206. this.indexMap[axisCmptIdx] = true
  48207. }
  48208. }
  48209. return DataZoomAxisInfo
  48210. })()
  48211. var DataZoomModel = /** @class */ (function (_super) {
  48212. __extends(DataZoomModel, _super)
  48213. function DataZoomModel() {
  48214. var _this =
  48215. (_super !== null && _super.apply(this, arguments)) || this
  48216. _this.type = DataZoomModel.type
  48217. _this._autoThrottle = true
  48218. _this._noTarget = true
  48219. /**
  48220. * It is `[rangeModeForMin, rangeModeForMax]`.
  48221. * The optional values for `rangeMode`:
  48222. * + `'value'` mode: the axis extent will always be determined by
  48223. * `dataZoom.startValue` and `dataZoom.endValue`, despite
  48224. * how data like and how `axis.min` and `axis.max` are.
  48225. * + `'percent'` mode: `100` represents 100% of the `[dMin, dMax]`,
  48226. * where `dMin` is `axis.min` if `axis.min` specified, otherwise `data.extent[0]`,
  48227. * and `dMax` is `axis.max` if `axis.max` specified, otherwise `data.extent[1]`.
  48228. * Axis extent will be determined by the result of the percent of `[dMin, dMax]`.
  48229. *
  48230. * For example, when users are using dynamic data (update data periodically via `setOption`),
  48231. * if in `'value`' mode, the window will be kept in a fixed value range despite how
  48232. * data are appended, while if in `'percent'` mode, whe window range will be changed alone with
  48233. * the appended data (suppose `axis.min` and `axis.max` are not specified).
  48234. */ _this._rangePropMode = ['percent', 'percent']
  48235. return _this
  48236. }
  48237. DataZoomModel.prototype.init = function (
  48238. option,
  48239. parentModel,
  48240. ecModel
  48241. ) {
  48242. var inputRawOption = retrieveRawOption(option)
  48243. /**
  48244. * Suppose a "main process" start at the point that model prepared (that is,
  48245. * model initialized or merged or method called in `action`).
  48246. * We should keep the `main process` idempotent, that is, given a set of values
  48247. * on `option`, we get the same result.
  48248. *
  48249. * But sometimes, values on `option` will be updated for providing users
  48250. * a "final calculated value" (`dataZoomProcessor` will do that). Those value
  48251. * should not be the base/input of the `main process`.
  48252. *
  48253. * So in that case we should save and keep the input of the `main process`
  48254. * separately, called `settledOption`.
  48255. *
  48256. * For example, consider the case:
  48257. * (Step_1) brush zoom the grid by `toolbox.dataZoom`,
  48258. * where the original input `option.startValue`, `option.endValue` are earsed by
  48259. * calculated value.
  48260. * (Step)2) click the legend to hide and show a series,
  48261. * where the new range is calculated by the earsed `startValue` and `endValue`,
  48262. * which brings incorrect result.
  48263. */ this.settledOption = inputRawOption
  48264. this.mergeDefaultAndTheme(option, ecModel)
  48265. this._doInit(inputRawOption)
  48266. }
  48267. DataZoomModel.prototype.mergeOption = function (newOption) {
  48268. var inputRawOption = retrieveRawOption(newOption) //FIX #2591
  48269. merge(this.option, newOption, true)
  48270. merge(this.settledOption, inputRawOption, true)
  48271. this._doInit(inputRawOption)
  48272. }
  48273. DataZoomModel.prototype._doInit = function (inputRawOption) {
  48274. var thisOption = this.option
  48275. this._setDefaultThrottle(inputRawOption)
  48276. this._updateRangeUse(inputRawOption)
  48277. var settledOption = this.settledOption
  48278. each$7(
  48279. [
  48280. ['start', 'startValue'],
  48281. ['end', 'endValue']
  48282. ],
  48283. function (names, index) {
  48284. // start/end has higher priority over startValue/endValue if they
  48285. // both set, but we should make chart.setOption({endValue: 1000})
  48286. // effective, rather than chart.setOption({endValue: 1000, end: null}).
  48287. if (this._rangePropMode[index] === 'value') {
  48288. thisOption[names[0]] = settledOption[names[0]] = null
  48289. } // Otherwise do nothing and use the merge result.
  48290. },
  48291. this
  48292. )
  48293. this._resetTarget()
  48294. }
  48295. DataZoomModel.prototype._resetTarget = function () {
  48296. var optionOrient = this.get('orient', true)
  48297. var targetAxisIndexMap = (this._targetAxisInfoMap =
  48298. createHashMap())
  48299. var hasAxisSpecified =
  48300. this._fillSpecifiedTargetAxis(targetAxisIndexMap)
  48301. if (hasAxisSpecified) {
  48302. this._orient =
  48303. optionOrient || this._makeAutoOrientByTargetAxis()
  48304. } else {
  48305. this._orient = optionOrient || 'horizontal'
  48306. this._fillAutoTargetAxisByOrient(
  48307. targetAxisIndexMap,
  48308. this._orient
  48309. )
  48310. }
  48311. this._noTarget = true
  48312. targetAxisIndexMap.each(function (axisInfo) {
  48313. if (axisInfo.indexList.length) {
  48314. this._noTarget = false
  48315. }
  48316. }, this)
  48317. }
  48318. DataZoomModel.prototype._fillSpecifiedTargetAxis = function (
  48319. targetAxisIndexMap
  48320. ) {
  48321. var hasAxisSpecified = false
  48322. each$7(
  48323. DATA_ZOOM_AXIS_DIMENSIONS,
  48324. function (axisDim) {
  48325. var refering = this.getReferringComponents(
  48326. getAxisMainType(axisDim),
  48327. MULTIPLE_REFERRING
  48328. ) // When user set axisIndex as a empty array, we think that user specify axisIndex
  48329. // but do not want use auto mode. Because empty array may be encountered when
  48330. // some error occured.
  48331. if (!refering.specified) {
  48332. return
  48333. }
  48334. hasAxisSpecified = true
  48335. var axisInfo = new DataZoomAxisInfo()
  48336. each$7(refering.models, function (axisModel) {
  48337. axisInfo.add(axisModel.componentIndex)
  48338. })
  48339. targetAxisIndexMap.set(axisDim, axisInfo)
  48340. },
  48341. this
  48342. )
  48343. return hasAxisSpecified
  48344. }
  48345. DataZoomModel.prototype._fillAutoTargetAxisByOrient = function (
  48346. targetAxisIndexMap,
  48347. orient
  48348. ) {
  48349. var ecModel = this.ecModel
  48350. var needAuto = true // Find axis that parallel to dataZoom as default.
  48351. if (needAuto) {
  48352. var axisDim = orient === 'vertical' ? 'y' : 'x'
  48353. var axisModels = ecModel.findComponents({
  48354. mainType: axisDim + 'Axis'
  48355. })
  48356. setParallelAxis(axisModels, axisDim)
  48357. } // Find axis that parallel to dataZoom as default.
  48358. if (needAuto) {
  48359. var axisModels = ecModel.findComponents({
  48360. mainType: 'singleAxis',
  48361. filter: function filter(axisModel) {
  48362. return axisModel.get('orient', true) === orient
  48363. }
  48364. })
  48365. setParallelAxis(axisModels, 'single')
  48366. }
  48367. function setParallelAxis(axisModels, axisDim) {
  48368. // At least use the first parallel axis as the target axis.
  48369. var axisModel = axisModels[0]
  48370. if (!axisModel) {
  48371. return
  48372. }
  48373. var axisInfo = new DataZoomAxisInfo()
  48374. axisInfo.add(axisModel.componentIndex)
  48375. targetAxisIndexMap.set(axisDim, axisInfo)
  48376. needAuto = false // Find parallel axes in the same grid.
  48377. if (axisDim === 'x' || axisDim === 'y') {
  48378. var gridModel_1 = axisModel.getReferringComponents(
  48379. 'grid',
  48380. SINGLE_REFERRING
  48381. ).models[0]
  48382. gridModel_1 &&
  48383. each$7(axisModels, function (axModel) {
  48384. if (
  48385. axisModel.componentIndex !== axModel.componentIndex &&
  48386. gridModel_1 ===
  48387. axModel.getReferringComponents(
  48388. 'grid',
  48389. SINGLE_REFERRING
  48390. ).models[0]
  48391. ) {
  48392. axisInfo.add(axModel.componentIndex)
  48393. }
  48394. })
  48395. }
  48396. }
  48397. if (needAuto) {
  48398. // If no parallel axis, find the first category axis as default. (Also consider polar).
  48399. each$7(
  48400. DATA_ZOOM_AXIS_DIMENSIONS,
  48401. function (axisDim) {
  48402. if (!needAuto) {
  48403. return
  48404. }
  48405. var axisModels = ecModel.findComponents({
  48406. mainType: getAxisMainType(axisDim),
  48407. filter: function filter(axisModel) {
  48408. return axisModel.get('type', true) === 'category'
  48409. }
  48410. })
  48411. if (axisModels[0]) {
  48412. var axisInfo = new DataZoomAxisInfo()
  48413. axisInfo.add(axisModels[0].componentIndex)
  48414. targetAxisIndexMap.set(axisDim, axisInfo)
  48415. needAuto = false
  48416. }
  48417. },
  48418. this
  48419. )
  48420. }
  48421. }
  48422. DataZoomModel.prototype._makeAutoOrientByTargetAxis = function () {
  48423. var dim // Find the first axis
  48424. this.eachTargetAxis(function (axisDim) {
  48425. !dim && (dim = axisDim)
  48426. }, this)
  48427. return dim === 'y' ? 'vertical' : 'horizontal'
  48428. }
  48429. DataZoomModel.prototype._setDefaultThrottle = function (
  48430. inputRawOption
  48431. ) {
  48432. // When first time user set throttle, auto throttle ends.
  48433. if (inputRawOption.hasOwnProperty('throttle')) {
  48434. this._autoThrottle = false
  48435. }
  48436. if (this._autoThrottle) {
  48437. var globalOption = this.ecModel.option
  48438. this.option.throttle =
  48439. globalOption.animation &&
  48440. globalOption.animationDurationUpdate > 0
  48441. ? 100
  48442. : 20
  48443. }
  48444. }
  48445. DataZoomModel.prototype._updateRangeUse = function (
  48446. inputRawOption
  48447. ) {
  48448. var rangePropMode = this._rangePropMode
  48449. var rangeModeInOption = this.get('rangeMode')
  48450. each$7(
  48451. [
  48452. ['start', 'startValue'],
  48453. ['end', 'endValue']
  48454. ],
  48455. function (names, index) {
  48456. var percentSpecified = inputRawOption[names[0]] != null
  48457. var valueSpecified = inputRawOption[names[1]] != null
  48458. if (percentSpecified && !valueSpecified) {
  48459. rangePropMode[index] = 'percent'
  48460. } else if (!percentSpecified && valueSpecified) {
  48461. rangePropMode[index] = 'value'
  48462. } else if (rangeModeInOption) {
  48463. rangePropMode[index] = rangeModeInOption[index]
  48464. } else if (percentSpecified) {
  48465. // percentSpecified && valueSpecified
  48466. rangePropMode[index] = 'percent'
  48467. } // else remain its original setting.
  48468. }
  48469. )
  48470. }
  48471. DataZoomModel.prototype.noTarget = function () {
  48472. return this._noTarget
  48473. }
  48474. DataZoomModel.prototype.getFirstTargetAxisModel = function () {
  48475. var firstAxisModel
  48476. this.eachTargetAxis(function (axisDim, axisIndex) {
  48477. if (firstAxisModel == null) {
  48478. firstAxisModel = this.ecModel.getComponent(
  48479. getAxisMainType(axisDim),
  48480. axisIndex
  48481. )
  48482. }
  48483. }, this)
  48484. return firstAxisModel
  48485. }
  48486. /**
  48487. * @param {Function} callback param: axisModel, dimNames, axisIndex, dataZoomModel, ecModel
  48488. */ DataZoomModel.prototype.eachTargetAxis = function (
  48489. callback,
  48490. context
  48491. ) {
  48492. this._targetAxisInfoMap.each(function (axisInfo, axisDim) {
  48493. each$7(axisInfo.indexList, function (axisIndex) {
  48494. callback.call(context, axisDim, axisIndex)
  48495. })
  48496. })
  48497. }
  48498. /**
  48499. * @return If not found, return null/undefined.
  48500. */ DataZoomModel.prototype.getAxisProxy = function (
  48501. axisDim,
  48502. axisIndex
  48503. ) {
  48504. var axisModel = this.getAxisModel(axisDim, axisIndex)
  48505. if (axisModel) {
  48506. return axisModel.__dzAxisProxy
  48507. }
  48508. }
  48509. /**
  48510. * @return If not found, return null/undefined.
  48511. */ DataZoomModel.prototype.getAxisModel = function (
  48512. axisDim,
  48513. axisIndex
  48514. ) {
  48515. var axisInfo = this._targetAxisInfoMap.get(axisDim)
  48516. if (axisInfo && axisInfo.indexMap[axisIndex]) {
  48517. return this.ecModel.getComponent(
  48518. getAxisMainType(axisDim),
  48519. axisIndex
  48520. )
  48521. }
  48522. }
  48523. /**
  48524. * If not specified, set to undefined.
  48525. */ DataZoomModel.prototype.setRawRange = function (opt) {
  48526. var thisOption = this.option
  48527. var settledOption = this.settledOption
  48528. each$7(
  48529. [
  48530. ['start', 'startValue'],
  48531. ['end', 'endValue']
  48532. ],
  48533. function (names) {
  48534. // Consider the pair <start, startValue>:
  48535. // If one has value and the other one is `null/undefined`, we both set them
  48536. // to `settledOption`. This strategy enables the feature to clear the original
  48537. // value in `settledOption` to `null/undefined`.
  48538. // But if both of them are `null/undefined`, we do not set them to `settledOption`
  48539. // and keep `settledOption` with the original value. This strategy enables users to
  48540. // only set <end or endValue> but not set <start or startValue> when calling
  48541. // `dispatchAction`.
  48542. // The pair <end, endValue> is treated in the same way.
  48543. if (opt[names[0]] != null || opt[names[1]] != null) {
  48544. thisOption[names[0]] = settledOption[names[0]] =
  48545. opt[names[0]]
  48546. thisOption[names[1]] = settledOption[names[1]] =
  48547. opt[names[1]]
  48548. }
  48549. },
  48550. this
  48551. )
  48552. this._updateRangeUse(opt)
  48553. }
  48554. DataZoomModel.prototype.setCalculatedRange = function (opt) {
  48555. var option = this.option
  48556. each$7(
  48557. ['start', 'startValue', 'end', 'endValue'],
  48558. function (name) {
  48559. option[name] = opt[name]
  48560. }
  48561. )
  48562. }
  48563. DataZoomModel.prototype.getPercentRange = function () {
  48564. var axisProxy = this.findRepresentativeAxisProxy()
  48565. if (axisProxy) {
  48566. return axisProxy.getDataPercentWindow()
  48567. }
  48568. }
  48569. /**
  48570. * For example, chart.getModel().getComponent('dataZoom').getValueRange('y', 0);
  48571. *
  48572. * @return [startValue, endValue] value can only be '-' or finite number.
  48573. */ DataZoomModel.prototype.getValueRange = function (
  48574. axisDim,
  48575. axisIndex
  48576. ) {
  48577. if (axisDim == null && axisIndex == null) {
  48578. var axisProxy = this.findRepresentativeAxisProxy()
  48579. if (axisProxy) {
  48580. return axisProxy.getDataValueWindow()
  48581. }
  48582. } else {
  48583. return this.getAxisProxy(
  48584. axisDim,
  48585. axisIndex
  48586. ).getDataValueWindow()
  48587. }
  48588. }
  48589. /**
  48590. * @param axisModel If axisModel given, find axisProxy
  48591. * corresponding to the axisModel
  48592. */ DataZoomModel.prototype.findRepresentativeAxisProxy = function (
  48593. axisModel
  48594. ) {
  48595. if (axisModel) {
  48596. return axisModel.__dzAxisProxy
  48597. } // Find the first hosted axisProxy
  48598. var firstProxy
  48599. var axisDimList = this._targetAxisInfoMap.keys()
  48600. for (var i = 0; i < axisDimList.length; i++) {
  48601. var axisDim = axisDimList[i]
  48602. var axisInfo = this._targetAxisInfoMap.get(axisDim)
  48603. for (var j = 0; j < axisInfo.indexList.length; j++) {
  48604. var proxy = this.getAxisProxy(axisDim, axisInfo.indexList[j])
  48605. if (proxy.hostedBy(this)) {
  48606. return proxy
  48607. }
  48608. if (!firstProxy) {
  48609. firstProxy = proxy
  48610. }
  48611. }
  48612. } // If no hosted proxy found, still need to return a proxy.
  48613. // This case always happens in toolbox dataZoom, where axes are all hosted by
  48614. // other dataZooms.
  48615. return firstProxy
  48616. }
  48617. DataZoomModel.prototype.getRangePropMode = function () {
  48618. return this._rangePropMode.slice()
  48619. }
  48620. DataZoomModel.prototype.getOrient = function () {
  48621. return this._orient
  48622. }
  48623. DataZoomModel.type = 'dataZoom'
  48624. DataZoomModel.dependencies = [
  48625. 'xAxis',
  48626. 'yAxis',
  48627. 'radiusAxis',
  48628. 'angleAxis',
  48629. 'singleAxis',
  48630. 'series',
  48631. 'toolbox'
  48632. ]
  48633. DataZoomModel.defaultOption = {
  48634. // zlevel: 0,
  48635. z: 4,
  48636. filterMode: 'filter',
  48637. start: 0,
  48638. end: 100
  48639. }
  48640. return DataZoomModel
  48641. })(ComponentModel$1)
  48642. /**
  48643. * Retrieve the those raw params from option, which will be cached separately.
  48644. * becasue they will be overwritten by normalized/calculated values in the main
  48645. * process.
  48646. */ function retrieveRawOption(option) {
  48647. var ret = {}
  48648. each$7(
  48649. ['start', 'end', 'startValue', 'endValue', 'throttle'],
  48650. function (name) {
  48651. option.hasOwnProperty(name) && (ret[name] = option[name])
  48652. }
  48653. )
  48654. return ret
  48655. }
  48656. var DataZoomModel$1 = DataZoomModel
  48657. var SelectDataZoomModel = /** @class */ (function (_super) {
  48658. __extends(SelectDataZoomModel, _super)
  48659. function SelectDataZoomModel() {
  48660. var _this =
  48661. (_super !== null && _super.apply(this, arguments)) || this
  48662. _this.type = SelectDataZoomModel.type
  48663. return _this
  48664. }
  48665. SelectDataZoomModel.type = 'dataZoom.select'
  48666. return SelectDataZoomModel
  48667. })(DataZoomModel$1)
  48668. var SelectZoomModel = SelectDataZoomModel
  48669. var DataZoomView = /** @class */ (function (_super) {
  48670. __extends(DataZoomView, _super)
  48671. function DataZoomView() {
  48672. var _this =
  48673. (_super !== null && _super.apply(this, arguments)) || this
  48674. _this.type = DataZoomView.type
  48675. return _this
  48676. }
  48677. DataZoomView.prototype.render = function (
  48678. dataZoomModel,
  48679. ecModel,
  48680. api,
  48681. payload
  48682. ) {
  48683. this.dataZoomModel = dataZoomModel
  48684. this.ecModel = ecModel
  48685. this.api = api
  48686. }
  48687. DataZoomView.type = 'dataZoom'
  48688. return DataZoomView
  48689. })(ComponentView$1)
  48690. var DataZoomView$1 = DataZoomView
  48691. var SelectDataZoomView = /** @class */ (function (_super) {
  48692. __extends(SelectDataZoomView, _super)
  48693. function SelectDataZoomView() {
  48694. var _this =
  48695. (_super !== null && _super.apply(this, arguments)) || this
  48696. _this.type = SelectDataZoomView.type
  48697. return _this
  48698. }
  48699. SelectDataZoomView.type = 'dataZoom.select'
  48700. return SelectDataZoomView
  48701. })(DataZoomView$1)
  48702. var SelectZoomView = SelectDataZoomView
  48703. var each$3 = each$7
  48704. var asc = asc$1
  48705. /**
  48706. * Operate single axis.
  48707. * One axis can only operated by one axis operator.
  48708. * Different dataZoomModels may be defined to operate the same axis.
  48709. * (i.e. 'inside' data zoom and 'slider' data zoom components)
  48710. * So dataZoomModels share one axisProxy in that case.
  48711. */ var AxisProxy = /** @class */ (function () {
  48712. function AxisProxy(dimName, axisIndex, dataZoomModel, ecModel) {
  48713. this._dimName = dimName
  48714. this._axisIndex = axisIndex
  48715. this.ecModel = ecModel
  48716. this._dataZoomModel = dataZoomModel // /**
  48717. // * @readOnly
  48718. // * @private
  48719. // */
  48720. // this.hasSeriesStacked;
  48721. }
  48722. /**
  48723. * Whether the axisProxy is hosted by dataZoomModel.
  48724. */ AxisProxy.prototype.hostedBy = function (dataZoomModel) {
  48725. return this._dataZoomModel === dataZoomModel
  48726. }
  48727. /**
  48728. * @return Value can only be NaN or finite value.
  48729. */ AxisProxy.prototype.getDataValueWindow = function () {
  48730. return this._valueWindow.slice()
  48731. }
  48732. /**
  48733. * @return {Array.<number>}
  48734. */ AxisProxy.prototype.getDataPercentWindow = function () {
  48735. return this._percentWindow.slice()
  48736. }
  48737. AxisProxy.prototype.getTargetSeriesModels = function () {
  48738. var seriesModels = []
  48739. this.ecModel.eachSeries(function (seriesModel) {
  48740. if (isCoordSupported(seriesModel)) {
  48741. var axisMainType = getAxisMainType(this._dimName)
  48742. var axisModel = seriesModel.getReferringComponents(
  48743. axisMainType,
  48744. SINGLE_REFERRING
  48745. ).models[0]
  48746. if (
  48747. axisModel &&
  48748. this._axisIndex === axisModel.componentIndex
  48749. ) {
  48750. seriesModels.push(seriesModel)
  48751. }
  48752. }
  48753. }, this)
  48754. return seriesModels
  48755. }
  48756. AxisProxy.prototype.getAxisModel = function () {
  48757. return this.ecModel.getComponent(
  48758. this._dimName + 'Axis',
  48759. this._axisIndex
  48760. )
  48761. }
  48762. AxisProxy.prototype.getMinMaxSpan = function () {
  48763. return clone$3(this._minMaxSpan)
  48764. }
  48765. /**
  48766. * Only calculate by given range and this._dataExtent, do not change anything.
  48767. */ AxisProxy.prototype.calculateDataWindow = function (opt) {
  48768. var dataExtent = this._dataExtent
  48769. var axisModel = this.getAxisModel()
  48770. var scale = axisModel.axis.scale
  48771. var rangePropMode = this._dataZoomModel.getRangePropMode()
  48772. var percentExtent = [0, 100]
  48773. var percentWindow = []
  48774. var valueWindow = []
  48775. var hasPropModeValue
  48776. each$3(['start', 'end'], function (prop, idx) {
  48777. var boundPercent = opt[prop]
  48778. var boundValue = opt[prop + 'Value'] // Notice: dataZoom is based either on `percentProp` ('start', 'end') or
  48779. // on `valueProp` ('startValue', 'endValue'). (They are based on the data extent
  48780. // but not min/max of axis, which will be calculated by data window then).
  48781. // The former one is suitable for cases that a dataZoom component controls multiple
  48782. // axes with different unit or extent, and the latter one is suitable for accurate
  48783. // zoom by pixel (e.g., in dataZoomSelect).
  48784. // we use `getRangePropMode()` to mark which prop is used. `rangePropMode` is updated
  48785. // only when setOption or dispatchAction, otherwise it remains its original value.
  48786. // (Why not only record `percentProp` and always map to `valueProp`? Because
  48787. // the map `valueProp` -> `percentProp` -> `valueProp` probably not the original
  48788. // `valueProp`. consider two axes constrolled by one dataZoom. They have different
  48789. // data extent. All of values that are overflow the `dataExtent` will be calculated
  48790. // to percent '100%').
  48791. if (rangePropMode[idx] === 'percent') {
  48792. boundPercent == null && (boundPercent = percentExtent[idx]) // Use scale.parse to math round for category or time axis.
  48793. boundValue = scale.parse(
  48794. linearMap(boundPercent, percentExtent, dataExtent)
  48795. )
  48796. } else {
  48797. hasPropModeValue = true
  48798. boundValue =
  48799. boundValue == null
  48800. ? dataExtent[idx]
  48801. : scale.parse(boundValue) // Calculating `percent` from `value` may be not accurate, because
  48802. // This calculation can not be inversed, because all of values that
  48803. // are overflow the `dataExtent` will be calculated to percent '100%'
  48804. boundPercent = linearMap(
  48805. boundValue,
  48806. dataExtent,
  48807. percentExtent
  48808. )
  48809. } // valueWindow[idx] = round(boundValue);
  48810. // percentWindow[idx] = round(boundPercent);
  48811. valueWindow[idx] = boundValue
  48812. percentWindow[idx] = boundPercent
  48813. })
  48814. asc(valueWindow)
  48815. asc(percentWindow) // The windows from user calling of `dispatchAction` might be out of the extent,
  48816. // or do not obey the `min/maxSpan`, `min/maxValueSpan`. But we dont restrict window
  48817. // by `zoomLock` here, because we see `zoomLock` just as a interaction constraint,
  48818. // where API is able to initialize/modify the window size even though `zoomLock`
  48819. // specified.
  48820. var spans = this._minMaxSpan
  48821. hasPropModeValue
  48822. ? restrictSet(
  48823. valueWindow,
  48824. percentWindow,
  48825. dataExtent,
  48826. percentExtent,
  48827. false
  48828. )
  48829. : restrictSet(
  48830. percentWindow,
  48831. valueWindow,
  48832. percentExtent,
  48833. dataExtent,
  48834. true
  48835. )
  48836. function restrictSet(
  48837. fromWindow,
  48838. toWindow,
  48839. fromExtent,
  48840. toExtent,
  48841. toValue
  48842. ) {
  48843. var suffix = toValue ? 'Span' : 'ValueSpan'
  48844. sliderMove(
  48845. 0,
  48846. fromWindow,
  48847. fromExtent,
  48848. 'all',
  48849. spans['min' + suffix],
  48850. spans['max' + suffix]
  48851. )
  48852. for (var i = 0; i < 2; i++) {
  48853. toWindow[i] = linearMap(
  48854. fromWindow[i],
  48855. fromExtent,
  48856. toExtent,
  48857. true
  48858. )
  48859. toValue && (toWindow[i] = scale.parse(toWindow[i]))
  48860. }
  48861. }
  48862. return { valueWindow: valueWindow, percentWindow: percentWindow }
  48863. }
  48864. /**
  48865. * Notice: reset should not be called before series.restoreData() called,
  48866. * so it is recommanded to be called in "process stage" but not "model init
  48867. * stage".
  48868. */ AxisProxy.prototype.reset = function (dataZoomModel) {
  48869. if (dataZoomModel !== this._dataZoomModel) {
  48870. return
  48871. }
  48872. var targetSeries = this.getTargetSeriesModels() // Culculate data window and data extent, and record them.
  48873. this._dataExtent = calculateDataExtent(
  48874. this,
  48875. this._dimName,
  48876. targetSeries
  48877. ) // `calculateDataWindow` uses min/maxSpan.
  48878. this._updateMinMaxSpan()
  48879. var dataWindow = this.calculateDataWindow(
  48880. dataZoomModel.settledOption
  48881. )
  48882. this._valueWindow = dataWindow.valueWindow
  48883. this._percentWindow = dataWindow.percentWindow // Update axis setting then.
  48884. this._setAxisModel()
  48885. }
  48886. AxisProxy.prototype.filterData = function (dataZoomModel, api) {
  48887. if (dataZoomModel !== this._dataZoomModel) {
  48888. return
  48889. }
  48890. var axisDim = this._dimName
  48891. var seriesModels = this.getTargetSeriesModels()
  48892. var filterMode = dataZoomModel.get('filterMode')
  48893. var valueWindow = this._valueWindow
  48894. if (filterMode === 'none') {
  48895. return
  48896. } // FIXME
  48897. // Toolbox may has dataZoom injected. And if there are stacked bar chart
  48898. // with NaN data, NaN will be filtered and stack will be wrong.
  48899. // So we need to force the mode to be set empty.
  48900. // In fect, it is not a big deal that do not support filterMode-'filter'
  48901. // when using toolbox#dataZoom, utill tooltip#dataZoom support "single axis
  48902. // selection" some day, which might need "adapt to data extent on the
  48903. // otherAxis", which is disabled by filterMode-'empty'.
  48904. // But currently, stack has been fixed to based on value but not index,
  48905. // so this is not an issue any more.
  48906. // let otherAxisModel = this.getOtherAxisModel();
  48907. // if (dataZoomModel.get('$fromToolbox')
  48908. // && otherAxisModel
  48909. // && otherAxisModel.hasSeriesStacked
  48910. // ) {
  48911. // filterMode = 'empty';
  48912. // }
  48913. // TODO
  48914. // filterMode 'weakFilter' and 'empty' is not optimized for huge data yet.
  48915. each$3(seriesModels, function (seriesModel) {
  48916. var seriesData = seriesModel.getData()
  48917. var dataDims = seriesData.mapDimensionsAll(axisDim)
  48918. if (!dataDims.length) {
  48919. return
  48920. }
  48921. if (filterMode === 'weakFilter') {
  48922. var store_1 = seriesData.getStore()
  48923. var dataDimIndices_1 = map$1(
  48924. dataDims,
  48925. function (dim) {
  48926. return seriesData.getDimensionIndex(dim)
  48927. },
  48928. seriesData
  48929. )
  48930. seriesData.filterSelf(function (dataIndex) {
  48931. var leftOut
  48932. var rightOut
  48933. var hasValue
  48934. for (var i = 0; i < dataDims.length; i++) {
  48935. var value = store_1.get(dataDimIndices_1[i], dataIndex)
  48936. var thisHasValue = !isNaN(value)
  48937. var thisLeftOut = value < valueWindow[0]
  48938. var thisRightOut = value > valueWindow[1]
  48939. if (thisHasValue && !thisLeftOut && !thisRightOut) {
  48940. return true
  48941. }
  48942. thisHasValue && (hasValue = true)
  48943. thisLeftOut && (leftOut = true)
  48944. thisRightOut && (rightOut = true)
  48945. } // If both left out and right out, do not filter.
  48946. return hasValue && leftOut && rightOut
  48947. })
  48948. } else {
  48949. each$3(dataDims, function (dim) {
  48950. if (filterMode === 'empty') {
  48951. seriesModel.setData(
  48952. (seriesData = seriesData.map(dim, function (value) {
  48953. return !isInWindow(value) ? NaN : value
  48954. }))
  48955. )
  48956. } else {
  48957. var range = {}
  48958. range[dim] = valueWindow // console.time('select');
  48959. seriesData.selectRange(range) // console.timeEnd('select');
  48960. }
  48961. })
  48962. }
  48963. each$3(dataDims, function (dim) {
  48964. seriesData.setApproximateExtent(valueWindow, dim)
  48965. })
  48966. })
  48967. function isInWindow(value) {
  48968. return value >= valueWindow[0] && value <= valueWindow[1]
  48969. }
  48970. }
  48971. AxisProxy.prototype._updateMinMaxSpan = function () {
  48972. var minMaxSpan = (this._minMaxSpan = {})
  48973. var dataZoomModel = this._dataZoomModel
  48974. var dataExtent = this._dataExtent
  48975. each$3(
  48976. ['min', 'max'],
  48977. function (minMax) {
  48978. var percentSpan = dataZoomModel.get(minMax + 'Span')
  48979. var valueSpan = dataZoomModel.get(minMax + 'ValueSpan')
  48980. valueSpan != null &&
  48981. (valueSpan =
  48982. this.getAxisModel().axis.scale.parse(valueSpan)) // minValueSpan and maxValueSpan has higher priority than minSpan and maxSpan
  48983. if (valueSpan != null) {
  48984. percentSpan = linearMap(
  48985. dataExtent[0] + valueSpan,
  48986. dataExtent,
  48987. [0, 100],
  48988. true
  48989. )
  48990. } else if (percentSpan != null) {
  48991. valueSpan =
  48992. linearMap(percentSpan, [0, 100], dataExtent, true) -
  48993. dataExtent[0]
  48994. }
  48995. minMaxSpan[minMax + 'Span'] = percentSpan
  48996. minMaxSpan[minMax + 'ValueSpan'] = valueSpan
  48997. },
  48998. this
  48999. )
  49000. }
  49001. AxisProxy.prototype._setAxisModel = function () {
  49002. var axisModel = this.getAxisModel()
  49003. var percentWindow = this._percentWindow
  49004. var valueWindow = this._valueWindow
  49005. if (!percentWindow) {
  49006. return
  49007. } // [0, 500]: arbitrary value, guess axis extent.
  49008. var precision = getPixelPrecision(valueWindow, [0, 500])
  49009. precision = Math.min(precision, 20) // For value axis, if min/max/scale are not set, we just use the extent obtained
  49010. // by series data, which may be a little different from the extent calculated by
  49011. // `axisHelper.getScaleExtent`. But the different just affects the experience a
  49012. // little when zooming. So it will not be fixed until some users require it strongly.
  49013. var rawExtentInfo = axisModel.axis.scale.rawExtentInfo
  49014. if (percentWindow[0] !== 0) {
  49015. rawExtentInfo.setDeterminedMinMax(
  49016. 'min',
  49017. +valueWindow[0].toFixed(precision)
  49018. )
  49019. }
  49020. if (percentWindow[1] !== 100) {
  49021. rawExtentInfo.setDeterminedMinMax(
  49022. 'max',
  49023. +valueWindow[1].toFixed(precision)
  49024. )
  49025. }
  49026. rawExtentInfo.freeze()
  49027. }
  49028. return AxisProxy
  49029. })()
  49030. function calculateDataExtent(axisProxy, axisDim, seriesModels) {
  49031. var dataExtent = [Infinity, -Infinity]
  49032. each$3(seriesModels, function (seriesModel) {
  49033. unionAxisExtentFromData(
  49034. dataExtent,
  49035. seriesModel.getData(),
  49036. axisDim
  49037. )
  49038. }) // It is important to get "consistent" extent when more then one axes is
  49039. // controlled by a `dataZoom`, otherwise those axes will not be synchronized
  49040. // when zooming. But it is difficult to know what is "consistent", considering
  49041. // axes have different type or even different meanings (For example, two
  49042. // time axes are used to compare data of the same date in different years).
  49043. // So basically dataZoom just obtains extent by series.data (in category axis
  49044. // extent can be obtained from axis.data).
  49045. // Nevertheless, user can set min/max/scale on axes to make extent of axes
  49046. // consistent.
  49047. var axisModel = axisProxy.getAxisModel()
  49048. var rawExtentResult = ensureScaleRawExtentInfo(
  49049. axisModel.axis.scale,
  49050. axisModel,
  49051. dataExtent
  49052. ).calculate()
  49053. return [rawExtentResult.min, rawExtentResult.max]
  49054. }
  49055. var AxisProxy$1 = AxisProxy
  49056. var dataZoomProcessor = {
  49057. // `dataZoomProcessor` will only be performed in needed series. Consider if
  49058. // there is a line series and a pie series, it is better not to update the
  49059. // line series if only pie series is needed to be updated.
  49060. getTargetSeries: function getTargetSeries(ecModel) {
  49061. function eachAxisModel(cb) {
  49062. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  49063. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  49064. var axisModel = ecModel.getComponent(
  49065. getAxisMainType(axisDim),
  49066. axisIndex
  49067. )
  49068. cb(axisDim, axisIndex, axisModel, dataZoomModel)
  49069. })
  49070. })
  49071. } // FIXME: it brings side-effect to `getTargetSeries`.
  49072. // Prepare axis proxies.
  49073. eachAxisModel(function (
  49074. axisDim,
  49075. axisIndex,
  49076. axisModel,
  49077. dataZoomModel
  49078. ) {
  49079. // dispose all last axis proxy, in case that some axis are deleted.
  49080. axisModel.__dzAxisProxy = null
  49081. })
  49082. var proxyList = []
  49083. eachAxisModel(function (
  49084. axisDim,
  49085. axisIndex,
  49086. axisModel,
  49087. dataZoomModel
  49088. ) {
  49089. // Different dataZooms may constrol the same axis. In that case,
  49090. // an axisProxy serves both of them.
  49091. if (!axisModel.__dzAxisProxy) {
  49092. // Use the first dataZoomModel as the main model of axisProxy.
  49093. axisModel.__dzAxisProxy = new AxisProxy$1(
  49094. axisDim,
  49095. axisIndex,
  49096. dataZoomModel,
  49097. ecModel
  49098. )
  49099. proxyList.push(axisModel.__dzAxisProxy)
  49100. }
  49101. })
  49102. var seriesModelMap = createHashMap()
  49103. each$7(proxyList, function (axisProxy) {
  49104. each$7(
  49105. axisProxy.getTargetSeriesModels(),
  49106. function (seriesModel) {
  49107. seriesModelMap.set(seriesModel.uid, seriesModel)
  49108. }
  49109. )
  49110. })
  49111. return seriesModelMap
  49112. }, // Consider appendData, where filter should be performed. Because data process is
  49113. // in block mode currently, it is not need to worry about that the overallProgress
  49114. // execute every frame.
  49115. overallReset: function overallReset(ecModel, api) {
  49116. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  49117. // We calculate window and reset axis here but not in model
  49118. // init stage and not after action dispatch handler, because
  49119. // reset should be called after seriesData.restoreData.
  49120. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  49121. dataZoomModel
  49122. .getAxisProxy(axisDim, axisIndex)
  49123. .reset(dataZoomModel)
  49124. }) // Caution: data zoom filtering is order sensitive when using
  49125. // percent range and no min/max/scale set on axis.
  49126. // For example, we have dataZoom definition:
  49127. // [
  49128. // {xAxisIndex: 0, start: 30, end: 70},
  49129. // {yAxisIndex: 0, start: 20, end: 80}
  49130. // ]
  49131. // In this case, [20, 80] of y-dataZoom should be based on data
  49132. // that have filtered by x-dataZoom using range of [30, 70],
  49133. // but should not be based on full raw data. Thus sliding
  49134. // x-dataZoom will change both ranges of xAxis and yAxis,
  49135. // while sliding y-dataZoom will only change the range of yAxis.
  49136. // So we should filter x-axis after reset x-axis immediately,
  49137. // and then reset y-axis and filter y-axis.
  49138. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  49139. dataZoomModel
  49140. .getAxisProxy(axisDim, axisIndex)
  49141. .filterData(dataZoomModel, api)
  49142. })
  49143. })
  49144. ecModel.eachComponent('dataZoom', function (dataZoomModel) {
  49145. // Fullfill all of the range props so that user
  49146. // is able to get them from chart.getOption().
  49147. var axisProxy = dataZoomModel.findRepresentativeAxisProxy()
  49148. if (axisProxy) {
  49149. var percentRange = axisProxy.getDataPercentWindow()
  49150. var valueRange = axisProxy.getDataValueWindow()
  49151. dataZoomModel.setCalculatedRange({
  49152. start: percentRange[0],
  49153. end: percentRange[1],
  49154. startValue: valueRange[0],
  49155. endValue: valueRange[1]
  49156. })
  49157. }
  49158. })
  49159. }
  49160. }
  49161. var dataZoomProcessor$1 = dataZoomProcessor
  49162. function installDataZoomAction(registers) {
  49163. registers.registerAction('dataZoom', function (payload, ecModel) {
  49164. var effectedModels = findEffectedDataZooms(ecModel, payload)
  49165. each$7(effectedModels, function (dataZoomModel) {
  49166. dataZoomModel.setRawRange({
  49167. start: payload.start,
  49168. end: payload.end,
  49169. startValue: payload.startValue,
  49170. endValue: payload.endValue
  49171. })
  49172. })
  49173. })
  49174. }
  49175. var installed = false
  49176. function installCommon(registers) {
  49177. if (installed) {
  49178. return
  49179. }
  49180. installed = true
  49181. registers.registerProcessor(
  49182. registers.PRIORITY.PROCESSOR.FILTER,
  49183. dataZoomProcessor$1
  49184. )
  49185. installDataZoomAction(registers)
  49186. registers.registerSubTypeDefaulter('dataZoom', function () {
  49187. // Default 'slider' when no type specified.
  49188. return 'slider'
  49189. })
  49190. }
  49191. function install$c(registers) {
  49192. registers.registerComponentModel(SelectZoomModel)
  49193. registers.registerComponentView(SelectZoomView)
  49194. installCommon(registers)
  49195. }
  49196. /*
  49197. * Licensed to the Apache Software Foundation (ASF) under one
  49198. * or more contributor license agreements. See the NOTICE file
  49199. * distributed with this work for additional information
  49200. * regarding copyright ownership. The ASF licenses this file
  49201. * to you under the Apache License, Version 2.0 (the
  49202. * "License"); you may not use this file except in compliance
  49203. * with the License. You may obtain a copy of the License at
  49204. *
  49205. * http://www.apache.org/licenses/LICENSE-2.0
  49206. *
  49207. * Unless required by applicable law or agreed to in writing,
  49208. * software distributed under the License is distributed on an
  49209. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  49210. * KIND, either express or implied. See the License for the
  49211. * specific language governing permissions and limitations
  49212. * under the License.
  49213. */ /**
  49214. * AUTO-GENERATED FILE. DO NOT MODIFY.
  49215. */ var ToolboxFeature = /** @class */ (function () {
  49216. function ToolboxFeature() {}
  49217. return ToolboxFeature
  49218. })()
  49219. var features = {}
  49220. function registerFeature(name, ctor) {
  49221. features[name] = ctor
  49222. }
  49223. function getFeature(name) {
  49224. return features[name]
  49225. }
  49226. var ToolboxModel = /** @class */ (function (_super) {
  49227. __extends(ToolboxModel, _super)
  49228. function ToolboxModel() {
  49229. var _this =
  49230. (_super !== null && _super.apply(this, arguments)) || this
  49231. _this.type = ToolboxModel.type
  49232. return _this
  49233. }
  49234. ToolboxModel.prototype.optionUpdated = function () {
  49235. _super.prototype.optionUpdated.apply(this, arguments)
  49236. var ecModel = this.ecModel
  49237. each$7(this.option.feature, function (featureOpt, featureName) {
  49238. var Feature = getFeature(featureName)
  49239. if (Feature) {
  49240. if (Feature.getDefaultOption) {
  49241. Feature.defaultOption = Feature.getDefaultOption(ecModel)
  49242. }
  49243. merge(featureOpt, Feature.defaultOption)
  49244. }
  49245. })
  49246. }
  49247. ToolboxModel.type = 'toolbox'
  49248. ToolboxModel.layoutMode = { type: 'box', ignoreSize: true }
  49249. ToolboxModel.defaultOption = {
  49250. show: true,
  49251. z: 6, // zlevel: 0,
  49252. orient: 'horizontal',
  49253. left: 'right',
  49254. top: 'top', // right
  49255. // bottom
  49256. backgroundColor: 'transparent',
  49257. borderColor: '#ccc',
  49258. borderRadius: 0,
  49259. borderWidth: 0,
  49260. padding: 5,
  49261. itemSize: 15,
  49262. itemGap: 8,
  49263. showTitle: true,
  49264. iconStyle: { borderColor: '#666', color: 'none' },
  49265. emphasis: { iconStyle: { borderColor: '#3E98C5' } }, // textStyle: {},
  49266. // feature
  49267. tooltip: { show: false, position: 'bottom' }
  49268. }
  49269. return ToolboxModel
  49270. })(ComponentModel$1)
  49271. var ToolboxModel$1 = ToolboxModel
  49272. /**
  49273. * Layout list like component.
  49274. * It will box layout each items in group of component and then position the whole group in the viewport
  49275. * @param {module:zrender/group/Group} group
  49276. * @param {module:echarts/model/Component} componentModel
  49277. * @param {module:echarts/ExtensionAPI}
  49278. */ function layout(group, componentModel, api) {
  49279. var boxLayoutParams = componentModel.getBoxLayoutParams()
  49280. var padding = componentModel.get('padding')
  49281. var viewportSize = {
  49282. width: api.getWidth(),
  49283. height: api.getHeight()
  49284. }
  49285. var rect = getLayoutRect(boxLayoutParams, viewportSize, padding)
  49286. box(
  49287. componentModel.get('orient'),
  49288. group,
  49289. componentModel.get('itemGap'),
  49290. rect.width,
  49291. rect.height
  49292. )
  49293. positionElement(group, boxLayoutParams, viewportSize, padding)
  49294. }
  49295. function makeBackground(rect, componentModel) {
  49296. var padding = normalizeCssArray(componentModel.get('padding'))
  49297. var style = componentModel.getItemStyle(['color', 'opacity'])
  49298. style.fill = componentModel.get('backgroundColor')
  49299. rect = new Rect$2({
  49300. shape: {
  49301. x: rect.x - padding[3],
  49302. y: rect.y - padding[0],
  49303. width: rect.width + padding[1] + padding[3],
  49304. height: rect.height + padding[0] + padding[2],
  49305. r: componentModel.get('borderRadius')
  49306. },
  49307. style: style,
  49308. silent: true,
  49309. z2: -1
  49310. }) // FIXME
  49311. // `subPixelOptimizeRect` may bring some gap between edge of viewpart
  49312. // and background rect when setting like `left: 0`, `top: 0`.
  49313. // graphic.subPixelOptimizeRect(rect);
  49314. return rect
  49315. }
  49316. var ToolboxView = /** @class */ (function (_super) {
  49317. __extends(ToolboxView, _super)
  49318. function ToolboxView() {
  49319. return (_super !== null && _super.apply(this, arguments)) || this
  49320. }
  49321. ToolboxView.prototype.render = function (
  49322. toolboxModel,
  49323. ecModel,
  49324. api,
  49325. payload
  49326. ) {
  49327. var group = this.group
  49328. group.removeAll()
  49329. if (!toolboxModel.get('show')) {
  49330. return
  49331. }
  49332. var itemSize = +toolboxModel.get('itemSize')
  49333. var isVertical = toolboxModel.get('orient') === 'vertical'
  49334. var featureOpts = toolboxModel.get('feature') || {}
  49335. var features = this._features || (this._features = {})
  49336. var featureNames = []
  49337. each$7(featureOpts, function (opt, name) {
  49338. featureNames.push(name)
  49339. })
  49340. new DataDiffer$1(this._featureNames || [], featureNames)
  49341. .add(processFeature)
  49342. .update(processFeature)
  49343. .remove(curry$1(processFeature, null))
  49344. .execute() // Keep for diff.
  49345. this._featureNames = featureNames
  49346. function processFeature(newIndex, oldIndex) {
  49347. var featureName = featureNames[newIndex]
  49348. var oldName = featureNames[oldIndex]
  49349. var featureOpt = featureOpts[featureName]
  49350. var featureModel = new Model$1(
  49351. featureOpt,
  49352. toolboxModel,
  49353. toolboxModel.ecModel
  49354. )
  49355. var feature // FIX#11236, merge feature title from MagicType newOption. TODO: consider seriesIndex ?
  49356. if (
  49357. payload &&
  49358. payload.newTitle != null &&
  49359. payload.featureName === featureName
  49360. ) {
  49361. featureOpt.title = payload.newTitle
  49362. }
  49363. if (featureName && !oldName) {
  49364. // Create
  49365. if (isUserFeatureName(featureName)) {
  49366. feature = {
  49367. onclick: featureModel.option.onclick,
  49368. featureName: featureName
  49369. }
  49370. } else {
  49371. var Feature = getFeature(featureName)
  49372. if (!Feature) {
  49373. return
  49374. }
  49375. feature = new Feature()
  49376. }
  49377. features[featureName] = feature
  49378. } else {
  49379. feature = features[oldName] // If feature does not exsit.
  49380. if (!feature) {
  49381. return
  49382. }
  49383. }
  49384. feature.uid = getUID('toolbox-feature')
  49385. feature.model = featureModel
  49386. feature.ecModel = ecModel
  49387. feature.api = api
  49388. var isToolboxFeature = feature instanceof ToolboxFeature
  49389. if (!featureName && oldName) {
  49390. isToolboxFeature &&
  49391. feature.dispose &&
  49392. feature.dispose(ecModel, api)
  49393. return
  49394. }
  49395. if (
  49396. !featureModel.get('show') ||
  49397. (isToolboxFeature && feature.unusable)
  49398. ) {
  49399. isToolboxFeature &&
  49400. feature.remove &&
  49401. feature.remove(ecModel, api)
  49402. return
  49403. }
  49404. createIconPaths(featureModel, feature, featureName)
  49405. featureModel.setIconStatus = function (iconName, status) {
  49406. var option = this.option
  49407. var iconPaths = this.iconPaths
  49408. option.iconStatus = option.iconStatus || {}
  49409. option.iconStatus[iconName] = status
  49410. if (iconPaths[iconName]) {
  49411. ;(status === 'emphasis' ? enterEmphasis : leaveEmphasis)(
  49412. iconPaths[iconName]
  49413. )
  49414. }
  49415. }
  49416. if (feature instanceof ToolboxFeature) {
  49417. if (feature.render) {
  49418. feature.render(featureModel, ecModel, api, payload)
  49419. }
  49420. }
  49421. }
  49422. function createIconPaths(featureModel, feature, featureName) {
  49423. var iconStyleModel = featureModel.getModel('iconStyle')
  49424. var iconStyleEmphasisModel = featureModel.getModel([
  49425. 'emphasis',
  49426. 'iconStyle'
  49427. ]) // If one feature has mutiple icon. they are orginaized as
  49428. // {
  49429. // icon: {
  49430. // foo: '',
  49431. // bar: ''
  49432. // },
  49433. // title: {
  49434. // foo: '',
  49435. // bar: ''
  49436. // }
  49437. // }
  49438. var icons =
  49439. feature instanceof ToolboxFeature && feature.getIcons
  49440. ? feature.getIcons()
  49441. : featureModel.get('icon')
  49442. var titles = featureModel.get('title') || {}
  49443. var iconsMap
  49444. var titlesMap
  49445. if (isString(icons)) {
  49446. iconsMap = {}
  49447. iconsMap[featureName] = icons
  49448. } else {
  49449. iconsMap = icons
  49450. }
  49451. if (isString(titles)) {
  49452. titlesMap = {}
  49453. titlesMap[featureName] = titles
  49454. } else {
  49455. titlesMap = titles
  49456. }
  49457. var iconPaths = (featureModel.iconPaths = {})
  49458. each$7(iconsMap, function (iconStr, iconName) {
  49459. var path = createIcon(
  49460. iconStr,
  49461. {},
  49462. {
  49463. x: -itemSize / 2,
  49464. y: -itemSize / 2,
  49465. width: itemSize,
  49466. height: itemSize
  49467. }
  49468. ) // TODO handling image
  49469. path.setStyle(iconStyleModel.getItemStyle())
  49470. var pathEmphasisState = path.ensureState('emphasis')
  49471. pathEmphasisState.style =
  49472. iconStyleEmphasisModel.getItemStyle() // Text position calculation
  49473. var textContent = new ZRText$1({
  49474. style: {
  49475. text: titlesMap[iconName],
  49476. align: iconStyleEmphasisModel.get('textAlign'),
  49477. borderRadius:
  49478. iconStyleEmphasisModel.get('textBorderRadius'),
  49479. padding: iconStyleEmphasisModel.get('textPadding'),
  49480. fill: null
  49481. },
  49482. ignore: true
  49483. })
  49484. path.setTextContent(textContent)
  49485. setTooltipConfig({
  49486. el: path,
  49487. componentModel: toolboxModel,
  49488. itemName: iconName,
  49489. formatterParamsExtra: { title: titlesMap[iconName] }
  49490. })
  49491. path.__title = titlesMap[iconName]
  49492. path
  49493. .on('mouseover', function () {
  49494. // Should not reuse above hoverStyle, which might be modified.
  49495. var hoverStyle = iconStyleEmphasisModel.getItemStyle()
  49496. var defaultTextPosition = isVertical
  49497. ? toolboxModel.get('right') == null &&
  49498. toolboxModel.get('left') !== 'right'
  49499. ? 'right'
  49500. : 'left'
  49501. : toolboxModel.get('bottom') == null &&
  49502. toolboxModel.get('top') !== 'bottom'
  49503. ? 'bottom'
  49504. : 'top'
  49505. textContent.setStyle({
  49506. fill:
  49507. iconStyleEmphasisModel.get('textFill') ||
  49508. hoverStyle.fill ||
  49509. hoverStyle.stroke ||
  49510. '#000',
  49511. backgroundColor: iconStyleEmphasisModel.get(
  49512. 'textBackgroundColor'
  49513. )
  49514. })
  49515. path.setTextConfig({
  49516. position:
  49517. iconStyleEmphasisModel.get('textPosition') ||
  49518. defaultTextPosition
  49519. })
  49520. textContent.ignore = !toolboxModel.get('showTitle') // Use enterEmphasis and leaveEmphasis provide by ec.
  49521. // There are flags managed by the echarts.
  49522. api.enterEmphasis(this)
  49523. })
  49524. .on('mouseout', function () {
  49525. if (
  49526. featureModel.get(['iconStatus', iconName]) !==
  49527. 'emphasis'
  49528. ) {
  49529. api.leaveEmphasis(this)
  49530. }
  49531. textContent.hide()
  49532. })
  49533. ;(featureModel.get(['iconStatus', iconName]) === 'emphasis'
  49534. ? enterEmphasis
  49535. : leaveEmphasis)(path)
  49536. group.add(path)
  49537. path.on(
  49538. 'click',
  49539. bind$1(feature.onclick, feature, ecModel, api, iconName)
  49540. )
  49541. iconPaths[iconName] = path
  49542. })
  49543. }
  49544. layout(group, toolboxModel, api) // Render background after group is layout
  49545. // FIXME
  49546. group.add(makeBackground(group.getBoundingRect(), toolboxModel)) // Adjust icon title positions to avoid them out of screen
  49547. isVertical ||
  49548. group.eachChild(function (icon) {
  49549. var titleText = icon.__title // const hoverStyle = icon.hoverStyle;
  49550. // TODO simplify code?
  49551. var emphasisState = icon.ensureState('emphasis')
  49552. var emphasisTextConfig =
  49553. emphasisState.textConfig || (emphasisState.textConfig = {})
  49554. var textContent = icon.getTextContent()
  49555. var emphasisTextState =
  49556. textContent && textContent.ensureState('emphasis') // May be background element
  49557. if (
  49558. emphasisTextState &&
  49559. !isFunction(emphasisTextState) &&
  49560. titleText
  49561. ) {
  49562. var emphasisTextStyle =
  49563. emphasisTextState.style || (emphasisTextState.style = {})
  49564. var rect = getBoundingRect(
  49565. titleText,
  49566. ZRText$1.makeFont(emphasisTextStyle)
  49567. )
  49568. var offsetX = icon.x + group.x
  49569. var offsetY = icon.y + group.y + itemSize
  49570. var needPutOnTop = false
  49571. if (offsetY + rect.height > api.getHeight()) {
  49572. emphasisTextConfig.position = 'top'
  49573. needPutOnTop = true
  49574. }
  49575. var topOffset = needPutOnTop
  49576. ? -5 - rect.height
  49577. : itemSize + 10
  49578. if (offsetX + rect.width / 2 > api.getWidth()) {
  49579. emphasisTextConfig.position = ['100%', topOffset]
  49580. emphasisTextStyle.align = 'right'
  49581. } else if (offsetX - rect.width / 2 < 0) {
  49582. emphasisTextConfig.position = [0, topOffset]
  49583. emphasisTextStyle.align = 'left'
  49584. }
  49585. }
  49586. })
  49587. }
  49588. ToolboxView.prototype.updateView = function (
  49589. toolboxModel,
  49590. ecModel,
  49591. api,
  49592. payload
  49593. ) {
  49594. each$7(this._features, function (feature) {
  49595. feature instanceof ToolboxFeature &&
  49596. feature.updateView &&
  49597. feature.updateView(feature.model, ecModel, api, payload)
  49598. })
  49599. } // updateLayout(toolboxModel, ecModel, api, payload) {
  49600. // zrUtil.each(this._features, function (feature) {
  49601. // feature.updateLayout && feature.updateLayout(feature.model, ecModel, api, payload);
  49602. // });
  49603. // },
  49604. ToolboxView.prototype.remove = function (ecModel, api) {
  49605. each$7(this._features, function (feature) {
  49606. feature instanceof ToolboxFeature &&
  49607. feature.remove &&
  49608. feature.remove(ecModel, api)
  49609. })
  49610. this.group.removeAll()
  49611. }
  49612. ToolboxView.prototype.dispose = function (ecModel, api) {
  49613. each$7(this._features, function (feature) {
  49614. feature instanceof ToolboxFeature &&
  49615. feature.dispose &&
  49616. feature.dispose(ecModel, api)
  49617. })
  49618. }
  49619. ToolboxView.type = 'toolbox'
  49620. return ToolboxView
  49621. })(ComponentView$1)
  49622. function isUserFeatureName(featureName) {
  49623. return featureName.indexOf('my') === 0
  49624. }
  49625. var ToolboxView$1 = ToolboxView
  49626. /* global window, document */ var SaveAsImage =
  49627. /** @class */ (function (_super) {
  49628. __extends(SaveAsImage, _super)
  49629. function SaveAsImage() {
  49630. return (
  49631. (_super !== null && _super.apply(this, arguments)) || this
  49632. )
  49633. }
  49634. SaveAsImage.prototype.onclick = function (ecModel, api) {
  49635. var model = this.model
  49636. var title =
  49637. model.get('name') || ecModel.get('title.0.text') || 'echarts'
  49638. var isSvg = api.getZr().painter.getType() === 'svg'
  49639. var type = isSvg ? 'svg' : model.get('type', true) || 'png'
  49640. var url = api.getConnectedDataURL({
  49641. type: type,
  49642. backgroundColor:
  49643. model.get('backgroundColor', true) ||
  49644. ecModel.get('backgroundColor') ||
  49645. '#fff',
  49646. connectedBackgroundColor: model.get(
  49647. 'connectedBackgroundColor'
  49648. ),
  49649. excludeComponents: model.get('excludeComponents'),
  49650. pixelRatio: model.get('pixelRatio')
  49651. })
  49652. var browser = env$1.browser // Chrome, Firefox, New Edge
  49653. if (
  49654. isFunction(MouseEvent) &&
  49655. (browser.newEdge || (!browser.ie && !browser.edge))
  49656. ) {
  49657. var $a = document.createElement('a')
  49658. $a.download = title + '.' + type
  49659. $a.target = '_blank'
  49660. $a.href = url
  49661. var evt = new MouseEvent('click', {
  49662. // some micro front-end framework, window maybe is a Proxy
  49663. view: document.defaultView,
  49664. bubbles: true,
  49665. cancelable: false
  49666. })
  49667. $a.dispatchEvent(evt)
  49668. } // IE or old Edge
  49669. else {
  49670. // @ts-ignore
  49671. if (window.navigator.msSaveOrOpenBlob || isSvg) {
  49672. var parts = url.split(',') // data:[<mime type>][;charset=<charset>][;base64],<encoded data>
  49673. var base64Encoded = parts[0].indexOf('base64') > -1
  49674. var bstr = isSvg // should decode the svg data uri first
  49675. ? decodeURIComponent(parts[1])
  49676. : parts[1] // only `atob` when the data uri is encoded with base64
  49677. // otherwise, like `svg` data uri exported by zrender,
  49678. // there will be an error, for it's not encoded with base64.
  49679. // (just a url-encoded string through `encodeURIComponent`)
  49680. base64Encoded && (bstr = window.atob(bstr))
  49681. var filename = title + '.' + type // @ts-ignore
  49682. if (window.navigator.msSaveOrOpenBlob) {
  49683. var n = bstr.length
  49684. var u8arr = new Uint8Array(n)
  49685. while (n--) {
  49686. u8arr[n] = bstr.charCodeAt(n)
  49687. }
  49688. var blob = new Blob([u8arr]) // @ts-ignore
  49689. window.navigator.msSaveOrOpenBlob(blob, filename)
  49690. } else {
  49691. var frame = document.createElement('iframe')
  49692. document.body.appendChild(frame)
  49693. var cw = frame.contentWindow
  49694. var doc = cw.document
  49695. doc.open('image/svg+xml', 'replace')
  49696. doc.write(bstr)
  49697. doc.close()
  49698. cw.focus()
  49699. doc.execCommand('SaveAs', true, filename)
  49700. document.body.removeChild(frame)
  49701. }
  49702. } else {
  49703. var lang = model.get('lang')
  49704. var html =
  49705. '' +
  49706. '<body style="margin:0;">' +
  49707. '<img src="' +
  49708. url +
  49709. '" style="max-width:100%;" title="' +
  49710. ((lang && lang[0]) || '') +
  49711. '" />' +
  49712. '</body>'
  49713. var tab = window.open()
  49714. tab.document.write(html)
  49715. tab.document.title = title
  49716. }
  49717. }
  49718. }
  49719. SaveAsImage.getDefaultOption = function (ecModel) {
  49720. var defaultOption = {
  49721. show: true,
  49722. 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',
  49723. title: ecModel
  49724. .getLocaleModel()
  49725. .get(['toolbox', 'saveAsImage', 'title']),
  49726. type: 'png', // Default use option.backgroundColor
  49727. // backgroundColor: '#fff',
  49728. connectedBackgroundColor: '#fff',
  49729. name: '',
  49730. excludeComponents: ['toolbox'], // use current pixel ratio of device by default
  49731. // pixelRatio: 1,
  49732. lang: ecModel
  49733. .getLocaleModel()
  49734. .get(['toolbox', 'saveAsImage', 'lang'])
  49735. }
  49736. return defaultOption
  49737. }
  49738. return SaveAsImage
  49739. })(ToolboxFeature)
  49740. var SaveAsImage$1 = SaveAsImage
  49741. var INNER_STACK_KEYWORD = '__ec_magicType_stack__'
  49742. var radioTypes = [['line', 'bar'], ['stack']]
  49743. var MagicType = /** @class */ (function (_super) {
  49744. __extends(MagicType, _super)
  49745. function MagicType() {
  49746. return (_super !== null && _super.apply(this, arguments)) || this
  49747. }
  49748. MagicType.prototype.getIcons = function () {
  49749. var model = this.model
  49750. var availableIcons = model.get('icon')
  49751. var icons = {}
  49752. each$7(model.get('type'), function (type) {
  49753. if (availableIcons[type]) {
  49754. icons[type] = availableIcons[type]
  49755. }
  49756. })
  49757. return icons
  49758. }
  49759. MagicType.getDefaultOption = function (ecModel) {
  49760. var defaultOption = {
  49761. show: true,
  49762. type: [], // Icon group
  49763. icon: {
  49764. line: 'M4.1,28.9h7.1l9.3-22l7.4,38l9.7-19.7l3,12.8h14.9M4.1,58h51.4',
  49765. bar: 'M6.7,22.9h10V48h-10V22.9zM24.9,13h10v35h-10V13zM43.2,2h10v46h-10V2zM3.1,58h53.7', // eslint-disable-next-line
  49766. stack:
  49767. '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
  49768. }, // `line`, `bar`, `stack`, `tiled`
  49769. title: ecModel
  49770. .getLocaleModel()
  49771. .get(['toolbox', 'magicType', 'title']),
  49772. option: {},
  49773. seriesIndex: {}
  49774. }
  49775. return defaultOption
  49776. }
  49777. MagicType.prototype.onclick = function (ecModel, api, type) {
  49778. var model = this.model
  49779. var seriesIndex = model.get(['seriesIndex', type]) // Not supported magicType
  49780. if (!seriesOptGenreator[type]) {
  49781. return
  49782. }
  49783. var newOption = { series: [] }
  49784. var generateNewSeriesTypes = function generateNewSeriesTypes(
  49785. seriesModel
  49786. ) {
  49787. var seriesType = seriesModel.subType
  49788. var seriesId = seriesModel.id
  49789. var newSeriesOpt = seriesOptGenreator[type](
  49790. seriesType,
  49791. seriesId,
  49792. seriesModel,
  49793. model
  49794. )
  49795. if (newSeriesOpt) {
  49796. // PENDING If merge original option?
  49797. defaults(newSeriesOpt, seriesModel.option)
  49798. newOption.series.push(newSeriesOpt)
  49799. } // Modify boundaryGap
  49800. var coordSys = seriesModel.coordinateSystem
  49801. if (
  49802. coordSys &&
  49803. coordSys.type === 'cartesian2d' &&
  49804. (type === 'line' || type === 'bar')
  49805. ) {
  49806. var categoryAxis = coordSys.getAxesByScale('ordinal')[0]
  49807. if (categoryAxis) {
  49808. var axisDim = categoryAxis.dim
  49809. var axisType = axisDim + 'Axis'
  49810. var axisModel = seriesModel.getReferringComponents(
  49811. axisType,
  49812. SINGLE_REFERRING
  49813. ).models[0]
  49814. var axisIndex = axisModel.componentIndex
  49815. newOption[axisType] = newOption[axisType] || []
  49816. for (var i = 0; i <= axisIndex; i++) {
  49817. newOption[axisType][axisIndex] =
  49818. newOption[axisType][axisIndex] || {}
  49819. }
  49820. newOption[axisType][axisIndex].boundaryGap = type === 'bar'
  49821. }
  49822. }
  49823. }
  49824. each$7(radioTypes, function (radio) {
  49825. if (indexOf(radio, type) >= 0) {
  49826. each$7(radio, function (item) {
  49827. model.setIconStatus(item, 'normal')
  49828. })
  49829. }
  49830. })
  49831. model.setIconStatus(type, 'emphasis')
  49832. ecModel.eachComponent(
  49833. {
  49834. mainType: 'series',
  49835. query:
  49836. seriesIndex == null ? null : { seriesIndex: seriesIndex }
  49837. },
  49838. generateNewSeriesTypes
  49839. )
  49840. var newTitle
  49841. var currentType = type // Change title of stack
  49842. if (type === 'stack') {
  49843. // use titles in model instead of ecModel
  49844. // as stack and tiled appears in pair, just flip them
  49845. // no need of checking stack state
  49846. newTitle = merge(
  49847. {
  49848. stack: model.option.title.tiled,
  49849. tiled: model.option.title.stack
  49850. },
  49851. model.option.title
  49852. )
  49853. if (model.get(['iconStatus', type]) !== 'emphasis') {
  49854. currentType = 'tiled'
  49855. }
  49856. }
  49857. api.dispatchAction({
  49858. type: 'changeMagicType',
  49859. currentType: currentType,
  49860. newOption: newOption,
  49861. newTitle: newTitle,
  49862. featureName: 'magicType'
  49863. })
  49864. }
  49865. return MagicType
  49866. })(ToolboxFeature)
  49867. var seriesOptGenreator = {
  49868. line: function line(seriesType, seriesId, seriesModel, model) {
  49869. if (seriesType === 'bar') {
  49870. return merge(
  49871. {
  49872. id: seriesId,
  49873. type: 'line', // Preserve data related option
  49874. data: seriesModel.get('data'),
  49875. stack: seriesModel.get('stack'),
  49876. markPoint: seriesModel.get('markPoint'),
  49877. markLine: seriesModel.get('markLine')
  49878. },
  49879. model.get(['option', 'line']) || {},
  49880. true
  49881. )
  49882. }
  49883. },
  49884. bar: function bar(seriesType, seriesId, seriesModel, model) {
  49885. if (seriesType === 'line') {
  49886. return merge(
  49887. {
  49888. id: seriesId,
  49889. type: 'bar', // Preserve data related option
  49890. data: seriesModel.get('data'),
  49891. stack: seriesModel.get('stack'),
  49892. markPoint: seriesModel.get('markPoint'),
  49893. markLine: seriesModel.get('markLine')
  49894. },
  49895. model.get(['option', 'bar']) || {},
  49896. true
  49897. )
  49898. }
  49899. },
  49900. stack: function stack(seriesType, seriesId, seriesModel, model) {
  49901. var isStack = seriesModel.get('stack') === INNER_STACK_KEYWORD
  49902. if (seriesType === 'line' || seriesType === 'bar') {
  49903. model.setIconStatus('stack', isStack ? 'normal' : 'emphasis')
  49904. return merge(
  49905. { id: seriesId, stack: isStack ? '' : INNER_STACK_KEYWORD },
  49906. model.get(['option', 'stack']) || {},
  49907. true
  49908. )
  49909. }
  49910. }
  49911. } // TODO: SELF REGISTERED.
  49912. registerAction(
  49913. {
  49914. type: 'changeMagicType',
  49915. event: 'magicTypeChanged',
  49916. update: 'prepareAndUpdate'
  49917. },
  49918. function (payload, ecModel) {
  49919. ecModel.mergeOption(payload.newOption)
  49920. }
  49921. )
  49922. var MagicType$1 = MagicType
  49923. /* global document */ var BLOCK_SPLITER = new Array(60).join('-')
  49924. var ITEM_SPLITER = '\t'
  49925. /**
  49926. * Group series into two types
  49927. * 1. on category axis, like line, bar
  49928. * 2. others, like scatter, pie
  49929. */ function groupSeries(ecModel) {
  49930. var seriesGroupByCategoryAxis = {}
  49931. var otherSeries = []
  49932. var meta = []
  49933. ecModel.eachRawSeries(function (seriesModel) {
  49934. var coordSys = seriesModel.coordinateSystem
  49935. if (
  49936. coordSys &&
  49937. (coordSys.type === 'cartesian2d' || coordSys.type === 'polar')
  49938. ) {
  49939. // TODO: TYPE Consider polar? Include polar may increase unecessary bundle size.
  49940. var baseAxis = coordSys.getBaseAxis()
  49941. if (baseAxis.type === 'category') {
  49942. var key = baseAxis.dim + '_' + baseAxis.index
  49943. if (!seriesGroupByCategoryAxis[key]) {
  49944. seriesGroupByCategoryAxis[key] = {
  49945. categoryAxis: baseAxis,
  49946. valueAxis: coordSys.getOtherAxis(baseAxis),
  49947. series: []
  49948. }
  49949. meta.push({
  49950. axisDim: baseAxis.dim,
  49951. axisIndex: baseAxis.index
  49952. })
  49953. }
  49954. seriesGroupByCategoryAxis[key].series.push(seriesModel)
  49955. } else {
  49956. otherSeries.push(seriesModel)
  49957. }
  49958. } else {
  49959. otherSeries.push(seriesModel)
  49960. }
  49961. })
  49962. return {
  49963. seriesGroupByCategoryAxis: seriesGroupByCategoryAxis,
  49964. other: otherSeries,
  49965. meta: meta
  49966. }
  49967. }
  49968. /**
  49969. * Assemble content of series on cateogory axis
  49970. * @inner
  49971. */ function assembleSeriesWithCategoryAxis(groups) {
  49972. var tables = []
  49973. each$7(groups, function (group, key) {
  49974. var categoryAxis = group.categoryAxis
  49975. var valueAxis = group.valueAxis
  49976. var valueAxisDim = valueAxis.dim
  49977. var headers = [' '].concat(
  49978. map$1(group.series, function (series) {
  49979. return series.name
  49980. })
  49981. ) // @ts-ignore TODO Polar
  49982. var columns = [categoryAxis.model.getCategories()]
  49983. each$7(group.series, function (series) {
  49984. var rawData = series.getRawData()
  49985. columns.push(
  49986. series
  49987. .getRawData()
  49988. .mapArray(
  49989. rawData.mapDimension(valueAxisDim),
  49990. function (val) {
  49991. return val
  49992. }
  49993. )
  49994. )
  49995. }) // Assemble table content
  49996. var lines = [headers.join(ITEM_SPLITER)]
  49997. for (var i = 0; i < columns[0].length; i++) {
  49998. var items = []
  49999. for (var j = 0; j < columns.length; j++) {
  50000. items.push(columns[j][i])
  50001. }
  50002. lines.push(items.join(ITEM_SPLITER))
  50003. }
  50004. tables.push(lines.join('\n'))
  50005. })
  50006. return tables.join('\n\n' + BLOCK_SPLITER + '\n\n')
  50007. }
  50008. /**
  50009. * Assemble content of other series
  50010. */ function assembleOtherSeries(series) {
  50011. return map$1(series, function (series) {
  50012. var data = series.getRawData()
  50013. var lines = [series.name]
  50014. var vals = []
  50015. data.each(data.dimensions, function () {
  50016. var argLen = arguments.length
  50017. var dataIndex = arguments[argLen - 1]
  50018. var name = data.getName(dataIndex)
  50019. for (var i = 0; i < argLen - 1; i++) {
  50020. vals[i] = arguments[i]
  50021. }
  50022. lines.push(
  50023. (name ? name + ITEM_SPLITER : '') + vals.join(ITEM_SPLITER)
  50024. )
  50025. })
  50026. return lines.join('\n')
  50027. }).join('\n\n' + BLOCK_SPLITER + '\n\n')
  50028. }
  50029. function getContentFromModel(ecModel) {
  50030. var result = groupSeries(ecModel)
  50031. return {
  50032. value: filter(
  50033. [
  50034. assembleSeriesWithCategoryAxis(
  50035. result.seriesGroupByCategoryAxis
  50036. ),
  50037. assembleOtherSeries(result.other)
  50038. ],
  50039. function (str) {
  50040. return !!str.replace(/[\n\t\s]/g, '')
  50041. }
  50042. ).join('\n\n' + BLOCK_SPLITER + '\n\n'),
  50043. meta: result.meta
  50044. }
  50045. }
  50046. function trim(str) {
  50047. return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '')
  50048. }
  50049. /**
  50050. * If a block is tsv format
  50051. */ function isTSVFormat(block) {
  50052. // Simple method to find out if a block is tsv format
  50053. var firstLine = block.slice(0, block.indexOf('\n'))
  50054. if (firstLine.indexOf(ITEM_SPLITER) >= 0) {
  50055. return true
  50056. }
  50057. }
  50058. var itemSplitRegex = new RegExp('[' + ITEM_SPLITER + ']+', 'g')
  50059. /**
  50060. * @param {string} tsv
  50061. * @return {Object}
  50062. */ function parseTSVContents(tsv) {
  50063. var tsvLines = tsv.split(/\n+/g)
  50064. var headers = trim(tsvLines.shift()).split(itemSplitRegex)
  50065. var categories = []
  50066. var series = map$1(headers, function (header) {
  50067. return { name: header, data: [] }
  50068. })
  50069. for (var i = 0; i < tsvLines.length; i++) {
  50070. var items = trim(tsvLines[i]).split(itemSplitRegex)
  50071. categories.push(items.shift())
  50072. for (var j = 0; j < items.length; j++) {
  50073. series[j] && (series[j].data[i] = items[j])
  50074. }
  50075. }
  50076. return { series: series, categories: categories }
  50077. }
  50078. function parseListContents(str) {
  50079. var lines = str.split(/\n+/g)
  50080. var seriesName = trim(lines.shift())
  50081. var data = []
  50082. for (var i = 0; i < lines.length; i++) {
  50083. // if line is empty, ignore it.
  50084. // there is a case that a user forgot to delete `\n`.
  50085. var line = trim(lines[i])
  50086. if (!line) {
  50087. continue
  50088. }
  50089. var items = line.split(itemSplitRegex)
  50090. var name_1 = ''
  50091. var value = void 0
  50092. var hasName = false
  50093. if (isNaN(items[0])) {
  50094. // First item is name
  50095. hasName = true
  50096. name_1 = items[0]
  50097. items = items.slice(1)
  50098. data[i] = { name: name_1, value: [] }
  50099. value = data[i].value
  50100. } else {
  50101. value = data[i] = []
  50102. }
  50103. for (var j = 0; j < items.length; j++) {
  50104. value.push(+items[j])
  50105. }
  50106. if (value.length === 1) {
  50107. hasName ? (data[i].value = value[0]) : (data[i] = value[0])
  50108. }
  50109. }
  50110. return { name: seriesName, data: data }
  50111. }
  50112. function parseContents(str, blockMetaList) {
  50113. var blocks = str.split(
  50114. new RegExp('\n*' + BLOCK_SPLITER + '\n*', 'g')
  50115. )
  50116. var newOption = { series: [] }
  50117. each$7(blocks, function (block, idx) {
  50118. if (isTSVFormat(block)) {
  50119. var result = parseTSVContents(block)
  50120. var blockMeta = blockMetaList[idx]
  50121. var axisKey = blockMeta.axisDim + 'Axis'
  50122. if (blockMeta) {
  50123. newOption[axisKey] = newOption[axisKey] || []
  50124. newOption[axisKey][blockMeta.axisIndex] = {
  50125. data: result.categories
  50126. }
  50127. newOption.series = newOption.series.concat(result.series)
  50128. }
  50129. } else {
  50130. var result = parseListContents(block)
  50131. newOption.series.push(result)
  50132. }
  50133. })
  50134. return newOption
  50135. }
  50136. var DataView = /** @class */ (function (_super) {
  50137. __extends(DataView, _super)
  50138. function DataView() {
  50139. return (_super !== null && _super.apply(this, arguments)) || this
  50140. }
  50141. DataView.prototype.onclick = function (ecModel, api) {
  50142. // FIXME: better way?
  50143. setTimeout(function () {
  50144. api.dispatchAction({ type: 'hideTip' })
  50145. })
  50146. var container = api.getDom()
  50147. var model = this.model
  50148. if (this._dom) {
  50149. container.removeChild(this._dom)
  50150. }
  50151. var root = document.createElement('div') // use padding to avoid 5px whitespace
  50152. root.style.cssText =
  50153. 'position:absolute;top:0;bottom:0;left:0;right:0;padding:5px'
  50154. root.style.backgroundColor =
  50155. model.get('backgroundColor') || '#fff' // Create elements
  50156. var header = document.createElement('h4')
  50157. var lang = model.get('lang') || []
  50158. header.innerHTML = lang[0] || model.get('title')
  50159. header.style.cssText = 'margin:10px 20px'
  50160. header.style.color = model.get('textColor')
  50161. var viewMain = document.createElement('div')
  50162. var textarea = document.createElement('textarea')
  50163. viewMain.style.cssText = 'overflow:auto'
  50164. var optionToContent = model.get('optionToContent')
  50165. var contentToOption = model.get('contentToOption')
  50166. var result = getContentFromModel(ecModel)
  50167. if (isFunction(optionToContent)) {
  50168. var htmlOrDom = optionToContent(api.getOption())
  50169. if (isString(htmlOrDom)) {
  50170. viewMain.innerHTML = htmlOrDom
  50171. } else if (isDom(htmlOrDom)) {
  50172. viewMain.appendChild(htmlOrDom)
  50173. }
  50174. } else {
  50175. // Use default textarea
  50176. textarea.readOnly = model.get('readOnly')
  50177. var style = textarea.style // eslint-disable-next-line max-len
  50178. style.cssText =
  50179. 'display:block;width:100%;height:100%;font-family:monospace;font-size:14px;line-height:1.6rem;resize:none;box-sizing:border-box;outline:none'
  50180. style.color = model.get('textColor')
  50181. style.borderColor = model.get('textareaBorderColor')
  50182. style.backgroundColor = model.get('textareaColor')
  50183. textarea.value = result.value
  50184. viewMain.appendChild(textarea)
  50185. }
  50186. var blockMetaList = result.meta
  50187. var buttonContainer = document.createElement('div')
  50188. buttonContainer.style.cssText =
  50189. 'position:absolute;bottom:5px;left:0;right:0' // eslint-disable-next-line max-len
  50190. var buttonStyle =
  50191. 'float:right;margin-right:20px;border:none;cursor:pointer;padding:2px 5px;font-size:12px;border-radius:3px'
  50192. var closeButton = document.createElement('div')
  50193. var refreshButton = document.createElement('div')
  50194. buttonStyle += ';background-color:' + model.get('buttonColor')
  50195. buttonStyle += ';color:' + model.get('buttonTextColor')
  50196. var self = this
  50197. function close() {
  50198. container.removeChild(root)
  50199. self._dom = null
  50200. }
  50201. addEventListener(closeButton, 'click', close)
  50202. addEventListener(refreshButton, 'click', function () {
  50203. if (
  50204. (contentToOption == null && optionToContent != null) ||
  50205. (contentToOption != null && optionToContent == null)
  50206. ) {
  50207. close()
  50208. return
  50209. }
  50210. var newOption
  50211. try {
  50212. if (isFunction(contentToOption)) {
  50213. newOption = contentToOption(viewMain, api.getOption())
  50214. } else {
  50215. newOption = parseContents(textarea.value, blockMetaList)
  50216. }
  50217. } catch (e) {
  50218. close()
  50219. throw new Error('Data view format error ' + e)
  50220. }
  50221. if (newOption) {
  50222. api.dispatchAction({
  50223. type: 'changeDataView',
  50224. newOption: newOption
  50225. })
  50226. }
  50227. close()
  50228. })
  50229. closeButton.innerHTML = lang[1]
  50230. refreshButton.innerHTML = lang[2]
  50231. refreshButton.style.cssText = closeButton.style.cssText =
  50232. buttonStyle
  50233. !model.get('readOnly') &&
  50234. buttonContainer.appendChild(refreshButton)
  50235. buttonContainer.appendChild(closeButton)
  50236. root.appendChild(header)
  50237. root.appendChild(viewMain)
  50238. root.appendChild(buttonContainer)
  50239. viewMain.style.height = container.clientHeight - 80 + 'px'
  50240. container.appendChild(root)
  50241. this._dom = root
  50242. }
  50243. DataView.prototype.remove = function (ecModel, api) {
  50244. this._dom && api.getDom().removeChild(this._dom)
  50245. }
  50246. DataView.prototype.dispose = function (ecModel, api) {
  50247. this.remove(ecModel, api)
  50248. }
  50249. DataView.getDefaultOption = function (ecModel) {
  50250. var defaultOption = {
  50251. show: true,
  50252. readOnly: false,
  50253. optionToContent: null,
  50254. contentToOption: null, // eslint-disable-next-line
  50255. 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',
  50256. title: ecModel
  50257. .getLocaleModel()
  50258. .get(['toolbox', 'dataView', 'title']),
  50259. lang: ecModel
  50260. .getLocaleModel()
  50261. .get(['toolbox', 'dataView', 'lang']),
  50262. backgroundColor: '#fff',
  50263. textColor: '#000',
  50264. textareaColor: '#fff',
  50265. textareaBorderColor: '#333',
  50266. buttonColor: '#c23531',
  50267. buttonTextColor: '#fff'
  50268. }
  50269. return defaultOption
  50270. }
  50271. return DataView
  50272. })(ToolboxFeature)
  50273. /**
  50274. * @inner
  50275. */ function tryMergeDataOption(newData, originalData) {
  50276. return map$1(newData, function (newVal, idx) {
  50277. var original = originalData && originalData[idx]
  50278. if (isObject$2(original) && !isArray(original)) {
  50279. var newValIsObject = isObject$2(newVal) && !isArray(newVal)
  50280. if (!newValIsObject) {
  50281. newVal = { value: newVal }
  50282. } // original data has name but new data has no name
  50283. var shouldDeleteName =
  50284. original.name != null && newVal.name == null // Original data has option
  50285. newVal = defaults(newVal, original)
  50286. shouldDeleteName && delete newVal.name
  50287. return newVal
  50288. } else {
  50289. return newVal
  50290. }
  50291. })
  50292. } // TODO: SELF REGISTERED.
  50293. registerAction(
  50294. {
  50295. type: 'changeDataView',
  50296. event: 'dataViewChanged',
  50297. update: 'prepareAndUpdate'
  50298. },
  50299. function (payload, ecModel) {
  50300. var newSeriesOptList = []
  50301. each$7(payload.newOption.series, function (seriesOpt) {
  50302. var seriesModel = ecModel.getSeriesByName(seriesOpt.name)[0]
  50303. if (!seriesModel) {
  50304. // New created series
  50305. // Geuss the series type
  50306. newSeriesOptList.push(
  50307. extend(
  50308. {
  50309. // Default is scatter
  50310. type: 'scatter'
  50311. },
  50312. seriesOpt
  50313. )
  50314. )
  50315. } else {
  50316. var originalData = seriesModel.get('data')
  50317. newSeriesOptList.push({
  50318. name: seriesOpt.name,
  50319. data: tryMergeDataOption(seriesOpt.data, originalData)
  50320. })
  50321. }
  50322. })
  50323. ecModel.mergeOption(
  50324. defaults({ series: newSeriesOptList }, payload.newOption)
  50325. )
  50326. }
  50327. )
  50328. var DataView$1 = DataView
  50329. var each$2 = each$7
  50330. var inner$1 = makeInner()
  50331. /**
  50332. * @param ecModel
  50333. * @param newSnapshot key is dataZoomId
  50334. */ function push(ecModel, newSnapshot) {
  50335. var storedSnapshots = getStoreSnapshots(ecModel) // If previous dataZoom can not be found,
  50336. // complete an range with current range.
  50337. each$2(newSnapshot, function (batchItem, dataZoomId) {
  50338. var i = storedSnapshots.length - 1
  50339. for (; i >= 0; i--) {
  50340. var snapshot = storedSnapshots[i]
  50341. if (snapshot[dataZoomId]) {
  50342. break
  50343. }
  50344. }
  50345. if (i < 0) {
  50346. // No origin range set, create one by current range.
  50347. var dataZoomModel = ecModel.queryComponents({
  50348. mainType: 'dataZoom',
  50349. subType: 'select',
  50350. id: dataZoomId
  50351. })[0]
  50352. if (dataZoomModel) {
  50353. var percentRange = dataZoomModel.getPercentRange()
  50354. storedSnapshots[0][dataZoomId] = {
  50355. dataZoomId: dataZoomId,
  50356. start: percentRange[0],
  50357. end: percentRange[1]
  50358. }
  50359. }
  50360. }
  50361. })
  50362. storedSnapshots.push(newSnapshot)
  50363. }
  50364. function pop(ecModel) {
  50365. var storedSnapshots = getStoreSnapshots(ecModel)
  50366. var head = storedSnapshots[storedSnapshots.length - 1]
  50367. storedSnapshots.length > 1 && storedSnapshots.pop() // Find top for all dataZoom.
  50368. var snapshot = {}
  50369. each$2(head, function (batchItem, dataZoomId) {
  50370. for (var i = storedSnapshots.length - 1; i >= 0; i--) {
  50371. batchItem = storedSnapshots[i][dataZoomId]
  50372. if (batchItem) {
  50373. snapshot[dataZoomId] = batchItem
  50374. break
  50375. }
  50376. }
  50377. })
  50378. return snapshot
  50379. }
  50380. function clear(ecModel) {
  50381. inner$1(ecModel).snapshots = null
  50382. }
  50383. function count(ecModel) {
  50384. return getStoreSnapshots(ecModel).length
  50385. }
  50386. /**
  50387. * History length of each dataZoom may be different.
  50388. * this._history[0] is used to store origin range.
  50389. */ function getStoreSnapshots(ecModel) {
  50390. var store = inner$1(ecModel)
  50391. if (!store.snapshots) {
  50392. store.snapshots = [{}]
  50393. }
  50394. return store.snapshots
  50395. }
  50396. var RestoreOption = /** @class */ (function (_super) {
  50397. __extends(RestoreOption, _super)
  50398. function RestoreOption() {
  50399. return (_super !== null && _super.apply(this, arguments)) || this
  50400. }
  50401. RestoreOption.prototype.onclick = function (ecModel, api) {
  50402. clear(ecModel)
  50403. api.dispatchAction({ type: 'restore', from: this.uid })
  50404. }
  50405. RestoreOption.getDefaultOption = function (ecModel) {
  50406. var defaultOption = {
  50407. show: true, // eslint-disable-next-line
  50408. 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',
  50409. title: ecModel
  50410. .getLocaleModel()
  50411. .get(['toolbox', 'restore', 'title'])
  50412. }
  50413. return defaultOption
  50414. }
  50415. return RestoreOption
  50416. })(ToolboxFeature) // TODO: SELF REGISTERED.
  50417. registerAction(
  50418. { type: 'restore', event: 'restore', update: 'prepareAndUpdate' },
  50419. function (payload, ecModel) {
  50420. ecModel.resetOption('recreate')
  50421. }
  50422. )
  50423. var Restore = RestoreOption // how to genarialize to more coordinate systems.
  50424. var INCLUDE_FINDER_MAIN_TYPES = [
  50425. 'grid',
  50426. 'xAxis',
  50427. 'yAxis',
  50428. 'geo',
  50429. 'graph',
  50430. 'polar',
  50431. 'radiusAxis',
  50432. 'angleAxis',
  50433. 'bmap'
  50434. ]
  50435. var BrushTargetManager = /** @class */ (function () {
  50436. /**
  50437. * @param finder contains Index/Id/Name of xAxis/yAxis/geo/grid
  50438. * Each can be {number|Array.<number>}. like: {xAxisIndex: [3, 4]}
  50439. * @param opt.include include coordinate system types.
  50440. */ function BrushTargetManager(finder, ecModel, opt) {
  50441. var _this = this
  50442. this._targetInfoList = []
  50443. var foundCpts = parseFinder(ecModel, finder)
  50444. each$7(targetInfoBuilders, function (builder, type) {
  50445. if (!opt || !opt.include || indexOf(opt.include, type) >= 0) {
  50446. builder(foundCpts, _this._targetInfoList)
  50447. }
  50448. })
  50449. }
  50450. BrushTargetManager.prototype.setOutputRanges = function (
  50451. areas,
  50452. ecModel
  50453. ) {
  50454. this.matchOutputRanges(
  50455. areas,
  50456. ecModel,
  50457. function (area, coordRange, coordSys) {
  50458. ;(area.coordRanges || (area.coordRanges = [])).push(
  50459. coordRange
  50460. ) // area.coordRange is the first of area.coordRanges
  50461. if (!area.coordRange) {
  50462. area.coordRange = coordRange // In 'category' axis, coord to pixel is not reversible, so we can not
  50463. // rebuild range by coordRange accrately, which may bring trouble when
  50464. // brushing only one item. So we use __rangeOffset to rebuilding range
  50465. // by coordRange. And this it only used in brush component so it is no
  50466. // need to be adapted to coordRanges.
  50467. var result = coordConvert[area.brushType](
  50468. 0,
  50469. coordSys,
  50470. coordRange
  50471. )
  50472. area.__rangeOffset = {
  50473. offset: diffProcessor[area.brushType](
  50474. result.values,
  50475. area.range,
  50476. [1, 1]
  50477. ),
  50478. xyMinMax: result.xyMinMax
  50479. }
  50480. }
  50481. }
  50482. )
  50483. return areas
  50484. }
  50485. BrushTargetManager.prototype.matchOutputRanges = function (
  50486. areas,
  50487. ecModel,
  50488. cb
  50489. ) {
  50490. each$7(
  50491. areas,
  50492. function (area) {
  50493. var targetInfo = this.findTargetInfo(area, ecModel)
  50494. if (targetInfo && targetInfo !== true) {
  50495. each$7(targetInfo.coordSyses, function (coordSys) {
  50496. var result = coordConvert[area.brushType](
  50497. 1,
  50498. coordSys,
  50499. area.range,
  50500. true
  50501. )
  50502. cb(area, result.values, coordSys, ecModel)
  50503. })
  50504. }
  50505. },
  50506. this
  50507. )
  50508. }
  50509. /**
  50510. * the `areas` is `BrushModel.areas`.
  50511. * Called in layout stage.
  50512. * convert `area.coordRange` to global range and set panelId to `area.range`.
  50513. */ BrushTargetManager.prototype.setInputRanges = function (
  50514. areas,
  50515. ecModel
  50516. ) {
  50517. each$7(
  50518. areas,
  50519. function (area) {
  50520. var targetInfo = this.findTargetInfo(area, ecModel)
  50521. area.range = area.range || [] // convert coordRange to global range and set panelId.
  50522. if (targetInfo && targetInfo !== true) {
  50523. area.panelId = targetInfo.panelId // (1) area.range shoule always be calculate from coordRange but does
  50524. // not keep its original value, for the sake of the dataZoom scenario,
  50525. // where area.coordRange remains unchanged but area.range may be changed.
  50526. // (2) Only support converting one coordRange to pixel range in brush
  50527. // component. So do not consider `coordRanges`.
  50528. // (3) About __rangeOffset, see comment above.
  50529. var result = coordConvert[area.brushType](
  50530. 0,
  50531. targetInfo.coordSys,
  50532. area.coordRange
  50533. )
  50534. var rangeOffset = area.__rangeOffset
  50535. area.range = rangeOffset
  50536. ? diffProcessor[area.brushType](
  50537. result.values,
  50538. rangeOffset.offset,
  50539. getScales(result.xyMinMax, rangeOffset.xyMinMax)
  50540. )
  50541. : result.values
  50542. }
  50543. },
  50544. this
  50545. )
  50546. }
  50547. BrushTargetManager.prototype.makePanelOpts = function (
  50548. api,
  50549. getDefaultBrushType
  50550. ) {
  50551. return map$1(this._targetInfoList, function (targetInfo) {
  50552. var rect = targetInfo.getPanelRect()
  50553. return {
  50554. panelId: targetInfo.panelId,
  50555. defaultBrushType: getDefaultBrushType
  50556. ? getDefaultBrushType(targetInfo)
  50557. : null,
  50558. clipPath: makeRectPanelClipPath(rect),
  50559. isTargetByCursor: makeRectIsTargetByCursor(
  50560. rect,
  50561. api,
  50562. targetInfo.coordSysModel
  50563. ),
  50564. getLinearBrushOtherExtent: makeLinearBrushOtherExtent(rect)
  50565. }
  50566. })
  50567. }
  50568. BrushTargetManager.prototype.controlSeries = function (
  50569. area,
  50570. seriesModel,
  50571. ecModel
  50572. ) {
  50573. // Check whether area is bound in coord, and series do not belong to that coord.
  50574. // If do not do this check, some brush (like lineX) will controll all axes.
  50575. var targetInfo = this.findTargetInfo(area, ecModel)
  50576. return (
  50577. targetInfo === true ||
  50578. (targetInfo &&
  50579. indexOf(
  50580. targetInfo.coordSyses,
  50581. seriesModel.coordinateSystem
  50582. ) >= 0)
  50583. )
  50584. }
  50585. /**
  50586. * If return Object, a coord found.
  50587. * If reutrn true, global found.
  50588. * Otherwise nothing found.
  50589. */ BrushTargetManager.prototype.findTargetInfo = function (
  50590. area,
  50591. ecModel
  50592. ) {
  50593. var targetInfoList = this._targetInfoList
  50594. var foundCpts = parseFinder(ecModel, area)
  50595. for (var i = 0; i < targetInfoList.length; i++) {
  50596. var targetInfo = targetInfoList[i]
  50597. var areaPanelId = area.panelId
  50598. if (areaPanelId) {
  50599. if (targetInfo.panelId === areaPanelId) {
  50600. return targetInfo
  50601. }
  50602. } else {
  50603. for (var j = 0; j < targetInfoMatchers.length; j++) {
  50604. if (targetInfoMatchers[j](foundCpts, targetInfo)) {
  50605. return targetInfo
  50606. }
  50607. }
  50608. }
  50609. }
  50610. return true
  50611. }
  50612. return BrushTargetManager
  50613. })()
  50614. function formatMinMax(minMax) {
  50615. minMax[0] > minMax[1] && minMax.reverse()
  50616. return minMax
  50617. }
  50618. function parseFinder(ecModel, finder) {
  50619. return parseFinder$1(ecModel, finder, {
  50620. includeMainTypes: INCLUDE_FINDER_MAIN_TYPES
  50621. })
  50622. }
  50623. var targetInfoBuilders = {
  50624. grid: function grid(foundCpts, targetInfoList) {
  50625. var xAxisModels = foundCpts.xAxisModels
  50626. var yAxisModels = foundCpts.yAxisModels
  50627. var gridModels = foundCpts.gridModels // Remove duplicated.
  50628. var gridModelMap = createHashMap()
  50629. var xAxesHas = {}
  50630. var yAxesHas = {}
  50631. if (!xAxisModels && !yAxisModels && !gridModels) {
  50632. return
  50633. }
  50634. each$7(xAxisModels, function (axisModel) {
  50635. var gridModel = axisModel.axis.grid.model
  50636. gridModelMap.set(gridModel.id, gridModel)
  50637. xAxesHas[gridModel.id] = true
  50638. })
  50639. each$7(yAxisModels, function (axisModel) {
  50640. var gridModel = axisModel.axis.grid.model
  50641. gridModelMap.set(gridModel.id, gridModel)
  50642. yAxesHas[gridModel.id] = true
  50643. })
  50644. each$7(gridModels, function (gridModel) {
  50645. gridModelMap.set(gridModel.id, gridModel)
  50646. xAxesHas[gridModel.id] = true
  50647. yAxesHas[gridModel.id] = true
  50648. })
  50649. gridModelMap.each(function (gridModel) {
  50650. var grid = gridModel.coordinateSystem
  50651. var cartesians = []
  50652. each$7(grid.getCartesians(), function (cartesian, index) {
  50653. if (
  50654. indexOf(xAxisModels, cartesian.getAxis('x').model) >= 0 ||
  50655. indexOf(yAxisModels, cartesian.getAxis('y').model) >= 0
  50656. ) {
  50657. cartesians.push(cartesian)
  50658. }
  50659. })
  50660. targetInfoList.push({
  50661. panelId: 'grid--' + gridModel.id,
  50662. gridModel: gridModel,
  50663. coordSysModel: gridModel, // Use the first one as the representitive coordSys.
  50664. coordSys: cartesians[0],
  50665. coordSyses: cartesians,
  50666. getPanelRect: panelRectBuilders.grid,
  50667. xAxisDeclared: xAxesHas[gridModel.id],
  50668. yAxisDeclared: yAxesHas[gridModel.id]
  50669. })
  50670. })
  50671. },
  50672. geo: function geo(foundCpts, targetInfoList) {
  50673. each$7(foundCpts.geoModels, function (geoModel) {
  50674. var coordSys = geoModel.coordinateSystem
  50675. targetInfoList.push({
  50676. panelId: 'geo--' + geoModel.id,
  50677. geoModel: geoModel,
  50678. coordSysModel: geoModel,
  50679. coordSys: coordSys,
  50680. coordSyses: [coordSys],
  50681. getPanelRect: panelRectBuilders.geo
  50682. })
  50683. })
  50684. }
  50685. }
  50686. var targetInfoMatchers = [
  50687. // grid
  50688. function (foundCpts, targetInfo) {
  50689. var xAxisModel = foundCpts.xAxisModel
  50690. var yAxisModel = foundCpts.yAxisModel
  50691. var gridModel = foundCpts.gridModel
  50692. !gridModel &&
  50693. xAxisModel &&
  50694. (gridModel = xAxisModel.axis.grid.model)
  50695. !gridModel &&
  50696. yAxisModel &&
  50697. (gridModel = yAxisModel.axis.grid.model)
  50698. return gridModel && gridModel === targetInfo.gridModel
  50699. }, // geo
  50700. function (foundCpts, targetInfo) {
  50701. var geoModel = foundCpts.geoModel
  50702. return geoModel && geoModel === targetInfo.geoModel
  50703. }
  50704. ]
  50705. var panelRectBuilders = {
  50706. grid: function grid() {
  50707. // grid is not Transformable.
  50708. return this.coordSys.master.getRect().clone()
  50709. },
  50710. geo: function geo() {
  50711. var coordSys = this.coordSys
  50712. var rect = coordSys.getBoundingRect().clone() // geo roam and zoom transform
  50713. rect.applyTransform(getTransform$1(coordSys))
  50714. return rect
  50715. }
  50716. }
  50717. var coordConvert = {
  50718. lineX: curry$1(axisConvert, 0),
  50719. lineY: curry$1(axisConvert, 1),
  50720. rect: function rect(to, coordSys, rangeOrCoordRange, clamp) {
  50721. var xminymin = to
  50722. ? coordSys.pointToData(
  50723. [rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]],
  50724. clamp
  50725. )
  50726. : coordSys.dataToPoint(
  50727. [rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]],
  50728. clamp
  50729. )
  50730. var xmaxymax = to
  50731. ? coordSys.pointToData(
  50732. [rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]],
  50733. clamp
  50734. )
  50735. : coordSys.dataToPoint(
  50736. [rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]],
  50737. clamp
  50738. )
  50739. var values = [
  50740. formatMinMax([xminymin[0], xmaxymax[0]]),
  50741. formatMinMax([xminymin[1], xmaxymax[1]])
  50742. ]
  50743. return { values: values, xyMinMax: values }
  50744. },
  50745. polygon: function polygon(to, coordSys, rangeOrCoordRange, clamp) {
  50746. var xyMinMax = [
  50747. [Infinity, -Infinity],
  50748. [Infinity, -Infinity]
  50749. ]
  50750. var values = map$1(rangeOrCoordRange, function (item) {
  50751. var p = to
  50752. ? coordSys.pointToData(item, clamp)
  50753. : coordSys.dataToPoint(item, clamp)
  50754. xyMinMax[0][0] = Math.min(xyMinMax[0][0], p[0])
  50755. xyMinMax[1][0] = Math.min(xyMinMax[1][0], p[1])
  50756. xyMinMax[0][1] = Math.max(xyMinMax[0][1], p[0])
  50757. xyMinMax[1][1] = Math.max(xyMinMax[1][1], p[1])
  50758. return p
  50759. })
  50760. return { values: values, xyMinMax: xyMinMax }
  50761. }
  50762. }
  50763. function axisConvert(axisNameIndex, to, coordSys, rangeOrCoordRange) {
  50764. var axis = coordSys.getAxis(['x', 'y'][axisNameIndex])
  50765. var values = formatMinMax(
  50766. map$1([0, 1], function (i) {
  50767. return to
  50768. ? axis.coordToData(
  50769. axis.toLocalCoord(rangeOrCoordRange[i]),
  50770. true
  50771. )
  50772. : axis.toGlobalCoord(axis.dataToCoord(rangeOrCoordRange[i]))
  50773. })
  50774. )
  50775. var xyMinMax = []
  50776. xyMinMax[axisNameIndex] = values
  50777. xyMinMax[1 - axisNameIndex] = [NaN, NaN]
  50778. return { values: values, xyMinMax: xyMinMax }
  50779. }
  50780. var diffProcessor = {
  50781. lineX: curry$1(axisDiffProcessor, 0),
  50782. lineY: curry$1(axisDiffProcessor, 1),
  50783. rect: function rect(values, refer, scales) {
  50784. return [
  50785. [
  50786. values[0][0] - scales[0] * refer[0][0],
  50787. values[0][1] - scales[0] * refer[0][1]
  50788. ],
  50789. [
  50790. values[1][0] - scales[1] * refer[1][0],
  50791. values[1][1] - scales[1] * refer[1][1]
  50792. ]
  50793. ]
  50794. },
  50795. polygon: function polygon(values, refer, scales) {
  50796. return map$1(values, function (item, idx) {
  50797. return [
  50798. item[0] - scales[0] * refer[idx][0],
  50799. item[1] - scales[1] * refer[idx][1]
  50800. ]
  50801. })
  50802. }
  50803. }
  50804. function axisDiffProcessor(axisNameIndex, values, refer, scales) {
  50805. return [
  50806. values[0] - scales[axisNameIndex] * refer[0],
  50807. values[1] - scales[axisNameIndex] * refer[1]
  50808. ]
  50809. } // We have to process scale caused by dataZoom manually,
  50810. // although it might be not accurate.
  50811. // Return [0~1, 0~1]
  50812. function getScales(xyMinMaxCurr, xyMinMaxOrigin) {
  50813. var sizeCurr = getSize(xyMinMaxCurr)
  50814. var sizeOrigin = getSize(xyMinMaxOrigin)
  50815. var scales = [
  50816. sizeCurr[0] / sizeOrigin[0],
  50817. sizeCurr[1] / sizeOrigin[1]
  50818. ]
  50819. isNaN(scales[0]) && (scales[0] = 1)
  50820. isNaN(scales[1]) && (scales[1] = 1)
  50821. return scales
  50822. }
  50823. function getSize(xyMinMax) {
  50824. return xyMinMax
  50825. ? [
  50826. xyMinMax[0][1] - xyMinMax[0][0],
  50827. xyMinMax[1][1] - xyMinMax[1][0]
  50828. ]
  50829. : [NaN, NaN]
  50830. }
  50831. var BrushTargetManager$1 = BrushTargetManager
  50832. var each$1 = each$7
  50833. var DATA_ZOOM_ID_BASE = makeInternalComponentId('toolbox-dataZoom_')
  50834. var DataZoomFeature = /** @class */ (function (_super) {
  50835. __extends(DataZoomFeature, _super)
  50836. function DataZoomFeature() {
  50837. return (_super !== null && _super.apply(this, arguments)) || this
  50838. }
  50839. DataZoomFeature.prototype.render = function (
  50840. featureModel,
  50841. ecModel,
  50842. api,
  50843. payload
  50844. ) {
  50845. if (!this._brushController) {
  50846. this._brushController = new BrushController$1(api.getZr())
  50847. this._brushController
  50848. .on('brush', bind$1(this._onBrush, this))
  50849. .mount()
  50850. }
  50851. updateZoomBtnStatus(featureModel, ecModel, this, payload, api)
  50852. updateBackBtnStatus(featureModel, ecModel)
  50853. }
  50854. DataZoomFeature.prototype.onclick = function (ecModel, api, type) {
  50855. handlers[type].call(this)
  50856. }
  50857. DataZoomFeature.prototype.remove = function (ecModel, api) {
  50858. this._brushController && this._brushController.unmount()
  50859. }
  50860. DataZoomFeature.prototype.dispose = function (ecModel, api) {
  50861. this._brushController && this._brushController.dispose()
  50862. }
  50863. DataZoomFeature.prototype._onBrush = function (eventParam) {
  50864. var areas = eventParam.areas
  50865. if (!eventParam.isEnd || !areas.length) {
  50866. return
  50867. }
  50868. var snapshot = {}
  50869. var ecModel = this.ecModel
  50870. this._brushController.updateCovers([]) // remove cover
  50871. var brushTargetManager = new BrushTargetManager$1(
  50872. makeAxisFinder(this.model),
  50873. ecModel,
  50874. { include: ['grid'] }
  50875. )
  50876. brushTargetManager.matchOutputRanges(
  50877. areas,
  50878. ecModel,
  50879. function (area, coordRange, coordSys) {
  50880. if (coordSys.type !== 'cartesian2d') {
  50881. return
  50882. }
  50883. var brushType = area.brushType
  50884. if (brushType === 'rect') {
  50885. setBatch('x', coordSys, coordRange[0])
  50886. setBatch('y', coordSys, coordRange[1])
  50887. } else {
  50888. setBatch(
  50889. { lineX: 'x', lineY: 'y' }[brushType],
  50890. coordSys,
  50891. coordRange
  50892. )
  50893. }
  50894. }
  50895. )
  50896. push(ecModel, snapshot)
  50897. this._dispatchZoomAction(snapshot)
  50898. function setBatch(dimName, coordSys, minMax) {
  50899. var axis = coordSys.getAxis(dimName)
  50900. var axisModel = axis.model
  50901. var dataZoomModel = findDataZoom(dimName, axisModel, ecModel) // Restrict range.
  50902. var minMaxSpan = dataZoomModel
  50903. .findRepresentativeAxisProxy(axisModel)
  50904. .getMinMaxSpan()
  50905. if (
  50906. minMaxSpan.minValueSpan != null ||
  50907. minMaxSpan.maxValueSpan != null
  50908. ) {
  50909. minMax = sliderMove(
  50910. 0,
  50911. minMax.slice(),
  50912. axis.scale.getExtent(),
  50913. 0,
  50914. minMaxSpan.minValueSpan,
  50915. minMaxSpan.maxValueSpan
  50916. )
  50917. }
  50918. dataZoomModel &&
  50919. (snapshot[dataZoomModel.id] = {
  50920. dataZoomId: dataZoomModel.id,
  50921. startValue: minMax[0],
  50922. endValue: minMax[1]
  50923. })
  50924. }
  50925. function findDataZoom(dimName, axisModel, ecModel) {
  50926. var found
  50927. ecModel.eachComponent(
  50928. { mainType: 'dataZoom', subType: 'select' },
  50929. function (dzModel) {
  50930. var has = dzModel.getAxisModel(
  50931. dimName,
  50932. axisModel.componentIndex
  50933. )
  50934. has && (found = dzModel)
  50935. }
  50936. )
  50937. return found
  50938. }
  50939. }
  50940. DataZoomFeature.prototype._dispatchZoomAction = function (
  50941. snapshot
  50942. ) {
  50943. var batch = [] // Convert from hash map to array.
  50944. each$1(snapshot, function (batchItem, dataZoomId) {
  50945. batch.push(clone$3(batchItem))
  50946. })
  50947. batch.length &&
  50948. this.api.dispatchAction({
  50949. type: 'dataZoom',
  50950. from: this.uid,
  50951. batch: batch
  50952. })
  50953. }
  50954. DataZoomFeature.getDefaultOption = function (ecModel) {
  50955. var defaultOption = {
  50956. show: true,
  50957. filterMode: 'filter', // Icon group
  50958. icon: {
  50959. zoom: 'M0,13.5h26.9 M13.5,26.9V0 M32.1,13.5H58V58H13.5 V32.1',
  50960. back: 'M22,1.4L9.9,13.5l12.3,12.3 M10.3,13.5H54.9v44.6 H10.3v-26'
  50961. }, // `zoom`, `back`
  50962. title: ecModel
  50963. .getLocaleModel()
  50964. .get(['toolbox', 'dataZoom', 'title']),
  50965. brushStyle: { borderWidth: 0, color: 'rgba(210,219,238,0.2)' }
  50966. }
  50967. return defaultOption
  50968. }
  50969. return DataZoomFeature
  50970. })(ToolboxFeature)
  50971. var handlers = {
  50972. zoom: function zoom() {
  50973. var nextActive = !this._isZoomActive
  50974. this.api.dispatchAction({
  50975. type: 'takeGlobalCursor',
  50976. key: 'dataZoomSelect',
  50977. dataZoomSelectActive: nextActive
  50978. })
  50979. },
  50980. back: function back() {
  50981. this._dispatchZoomAction(pop(this.ecModel))
  50982. }
  50983. }
  50984. function makeAxisFinder(dzFeatureModel) {
  50985. var setting = {
  50986. xAxisIndex: dzFeatureModel.get('xAxisIndex', true),
  50987. yAxisIndex: dzFeatureModel.get('yAxisIndex', true),
  50988. xAxisId: dzFeatureModel.get('xAxisId', true),
  50989. yAxisId: dzFeatureModel.get('yAxisId', true)
  50990. } // If both `xAxisIndex` `xAxisId` not set, it means 'all'.
  50991. // If both `yAxisIndex` `yAxisId` not set, it means 'all'.
  50992. // Some old cases set like this below to close yAxis control but leave xAxis control:
  50993. // `{ feature: { dataZoom: { yAxisIndex: false } }`.
  50994. if (setting.xAxisIndex == null && setting.xAxisId == null) {
  50995. setting.xAxisIndex = 'all'
  50996. }
  50997. if (setting.yAxisIndex == null && setting.yAxisId == null) {
  50998. setting.yAxisIndex = 'all'
  50999. }
  51000. return setting
  51001. }
  51002. function updateBackBtnStatus(featureModel, ecModel) {
  51003. featureModel.setIconStatus(
  51004. 'back',
  51005. count(ecModel) > 1 ? 'emphasis' : 'normal'
  51006. )
  51007. }
  51008. function updateZoomBtnStatus(
  51009. featureModel,
  51010. ecModel,
  51011. view,
  51012. payload,
  51013. api
  51014. ) {
  51015. var zoomActive = view._isZoomActive
  51016. if (payload && payload.type === 'takeGlobalCursor') {
  51017. zoomActive =
  51018. payload.key === 'dataZoomSelect'
  51019. ? payload.dataZoomSelectActive
  51020. : false
  51021. }
  51022. view._isZoomActive = zoomActive
  51023. featureModel.setIconStatus(
  51024. 'zoom',
  51025. zoomActive ? 'emphasis' : 'normal'
  51026. )
  51027. var brushTargetManager = new BrushTargetManager$1(
  51028. makeAxisFinder(featureModel),
  51029. ecModel,
  51030. { include: ['grid'] }
  51031. )
  51032. var panels = brushTargetManager.makePanelOpts(
  51033. api,
  51034. function (targetInfo) {
  51035. return targetInfo.xAxisDeclared && !targetInfo.yAxisDeclared
  51036. ? 'lineX'
  51037. : !targetInfo.xAxisDeclared && targetInfo.yAxisDeclared
  51038. ? 'lineY'
  51039. : 'rect'
  51040. }
  51041. )
  51042. view._brushController
  51043. .setPanels(panels)
  51044. .enableBrush(
  51045. zoomActive && panels.length
  51046. ? {
  51047. brushType: 'auto',
  51048. brushStyle: featureModel
  51049. .getModel('brushStyle')
  51050. .getItemStyle()
  51051. }
  51052. : false
  51053. )
  51054. }
  51055. registerInternalOptionCreator('dataZoom', function (ecModel) {
  51056. var toolboxModel = ecModel.getComponent('toolbox', 0)
  51057. var featureDataZoomPath = ['feature', 'dataZoom']
  51058. if (
  51059. !toolboxModel ||
  51060. toolboxModel.get(featureDataZoomPath) == null
  51061. ) {
  51062. return
  51063. }
  51064. var dzFeatureModel = toolboxModel.getModel(featureDataZoomPath)
  51065. var dzOptions = []
  51066. var finder = makeAxisFinder(dzFeatureModel)
  51067. var finderResult = parseFinder$1(ecModel, finder)
  51068. each$1(finderResult.xAxisModels, function (axisModel) {
  51069. return buildInternalOptions(axisModel, 'xAxis', 'xAxisIndex')
  51070. })
  51071. each$1(finderResult.yAxisModels, function (axisModel) {
  51072. return buildInternalOptions(axisModel, 'yAxis', 'yAxisIndex')
  51073. })
  51074. function buildInternalOptions(
  51075. axisModel,
  51076. axisMainType,
  51077. axisIndexPropName
  51078. ) {
  51079. var axisIndex = axisModel.componentIndex
  51080. var newOpt = {
  51081. type: 'select',
  51082. $fromToolbox: true, // Default to be filter
  51083. filterMode: dzFeatureModel.get('filterMode', true) || 'filter', // Id for merge mapping.
  51084. id: DATA_ZOOM_ID_BASE + axisMainType + axisIndex
  51085. }
  51086. newOpt[axisIndexPropName] = axisIndex
  51087. dzOptions.push(newOpt)
  51088. }
  51089. return dzOptions
  51090. })
  51091. var DataZoom = DataZoomFeature
  51092. function install$b(registers) {
  51093. registers.registerComponentModel(ToolboxModel$1)
  51094. registers.registerComponentView(ToolboxView$1)
  51095. registerFeature('saveAsImage', SaveAsImage$1)
  51096. registerFeature('magicType', MagicType$1)
  51097. registerFeature('dataView', DataView$1)
  51098. registerFeature('dataZoom', DataZoom)
  51099. registerFeature('restore', Restore)
  51100. use(install$c)
  51101. }
  51102. var TooltipModel = /** @class */ (function (_super) {
  51103. __extends(TooltipModel, _super)
  51104. function TooltipModel() {
  51105. var _this =
  51106. (_super !== null && _super.apply(this, arguments)) || this
  51107. _this.type = TooltipModel.type
  51108. return _this
  51109. }
  51110. TooltipModel.type = 'tooltip'
  51111. TooltipModel.dependencies = ['axisPointer']
  51112. TooltipModel.defaultOption = {
  51113. // zlevel: 0,
  51114. z: 60,
  51115. show: true, // tooltip main content
  51116. showContent: true, // 'trigger' only works on coordinate system.
  51117. // 'item' | 'axis' | 'none'
  51118. trigger: 'item', // 'click' | 'mousemove' | 'none'
  51119. triggerOn: 'mousemove|click',
  51120. alwaysShowContent: false,
  51121. displayMode: 'single',
  51122. renderMode: 'auto', // whether restraint content inside viewRect.
  51123. // If renderMode: 'richText', default true.
  51124. // If renderMode: 'html', defaut false (for backward compat).
  51125. confine: null,
  51126. showDelay: 0,
  51127. hideDelay: 100, // Animation transition time, unit is second
  51128. transitionDuration: 0.4,
  51129. enterable: false,
  51130. backgroundColor: '#fff', // box shadow
  51131. shadowBlur: 10,
  51132. shadowColor: 'rgba(0, 0, 0, .2)',
  51133. shadowOffsetX: 1,
  51134. shadowOffsetY: 2, // tooltip border radius, unit is px, default is 4
  51135. borderRadius: 4, // tooltip border width, unit is px, default is 0 (no border)
  51136. borderWidth: 1, // Tooltip inside padding, default is 5 for all direction
  51137. // Array is allowed to set up, right, bottom, left, same with css
  51138. // The default value: See `tooltip/tooltipMarkup.ts#getPaddingFromTooltipModel`.
  51139. padding: null, // Extra css text
  51140. extraCssText: '', // axis indicator, trigger by axis
  51141. axisPointer: {
  51142. // default is line
  51143. // legal values: 'line' | 'shadow' | 'cross'
  51144. type: 'line', // Valid when type is line, appoint tooltip line locate on which line. Optional
  51145. // legal values: 'x' | 'y' | 'angle' | 'radius' | 'auto'
  51146. // default is 'auto', chose the axis which type is category.
  51147. // for multiply y axis, cartesian coord chose x axis, polar chose angle axis
  51148. axis: 'auto',
  51149. animation: 'auto',
  51150. animationDurationUpdate: 200,
  51151. animationEasingUpdate: 'exponentialOut',
  51152. crossStyle: {
  51153. color: '#999',
  51154. width: 1,
  51155. type: 'dashed', // TODO formatter
  51156. textStyle: {}
  51157. } // lineStyle and shadowStyle should not be specified here,
  51158. // otherwise it will always override those styles on option.axisPointer.
  51159. },
  51160. textStyle: { color: '#666', fontSize: 14 }
  51161. }
  51162. return TooltipModel
  51163. })(ComponentModel$1)
  51164. var TooltipModel$1 = TooltipModel
  51165. /* global document */ function shouldTooltipConfine(tooltipModel) {
  51166. var confineOption = tooltipModel.get('confine')
  51167. return confineOption != null
  51168. ? !!confineOption // In richText mode, the outside part can not be visible.
  51169. : tooltipModel.get('renderMode') === 'richText'
  51170. }
  51171. function testStyle(styleProps) {
  51172. if (!env$1.domSupported) {
  51173. return
  51174. }
  51175. var style = document.documentElement.style
  51176. for (var i = 0, len = styleProps.length; i < len; i++) {
  51177. if (styleProps[i] in style) {
  51178. return styleProps[i]
  51179. }
  51180. }
  51181. }
  51182. var TRANSFORM_VENDOR = testStyle([
  51183. 'transform',
  51184. 'webkitTransform',
  51185. 'OTransform',
  51186. 'MozTransform',
  51187. 'msTransform'
  51188. ])
  51189. var TRANSITION_VENDOR = testStyle([
  51190. 'webkitTransition',
  51191. 'transition',
  51192. 'OTransition',
  51193. 'MozTransition',
  51194. 'msTransition'
  51195. ])
  51196. function toCSSVendorPrefix(styleVendor, styleProp) {
  51197. if (!styleVendor) {
  51198. return styleProp
  51199. }
  51200. styleProp = toCamelCase(styleProp, true)
  51201. var idx = styleVendor.indexOf(styleProp)
  51202. styleVendor =
  51203. idx === -1
  51204. ? styleProp
  51205. : '-' + styleVendor.slice(0, idx) + '-' + styleProp
  51206. return styleVendor.toLowerCase()
  51207. }
  51208. function getComputedStyle(el, style) {
  51209. var stl =
  51210. el.currentStyle ||
  51211. (document.defaultView &&
  51212. document.defaultView.getComputedStyle(el))
  51213. return stl ? (style ? stl[style] : stl) : null
  51214. }
  51215. /* global document, window */ var CSS_TRANSITION_VENDOR =
  51216. toCSSVendorPrefix(TRANSITION_VENDOR, 'transition')
  51217. var CSS_TRANSFORM_VENDOR = toCSSVendorPrefix(
  51218. TRANSFORM_VENDOR,
  51219. 'transform'
  51220. ) // eslint-disable-next-line
  51221. var gCssText =
  51222. 'position:absolute;display:block;border-style:solid;white-space:nowrap;z-index:9999999;' +
  51223. (env$1.transform3dSupported ? 'will-change:transform;' : '')
  51224. function mirrorPos(pos) {
  51225. pos =
  51226. pos === 'left'
  51227. ? 'right'
  51228. : pos === 'right'
  51229. ? 'left'
  51230. : pos === 'top'
  51231. ? 'bottom'
  51232. : 'top'
  51233. return pos
  51234. }
  51235. function assembleArrow(tooltipModel, borderColor, arrowPosition) {
  51236. if (!isString(arrowPosition) || arrowPosition === 'inside') {
  51237. return ''
  51238. }
  51239. var backgroundColor = tooltipModel.get('backgroundColor')
  51240. var borderWidth = tooltipModel.get('borderWidth')
  51241. borderColor = convertToColorString(borderColor)
  51242. var arrowPos = mirrorPos(arrowPosition)
  51243. var arrowSize = Math.max(Math.round(borderWidth) * 1.5, 6)
  51244. var positionStyle = ''
  51245. var transformStyle = CSS_TRANSFORM_VENDOR + ':'
  51246. var rotateDeg
  51247. if (indexOf(['left', 'right'], arrowPos) > -1) {
  51248. positionStyle += 'top:50%'
  51249. transformStyle +=
  51250. 'translateY(-50%) rotate(' +
  51251. (rotateDeg = arrowPos === 'left' ? -225 : -45) +
  51252. 'deg)'
  51253. } else {
  51254. positionStyle += 'left:50%'
  51255. transformStyle +=
  51256. 'translateX(-50%) rotate(' +
  51257. (rotateDeg = arrowPos === 'top' ? 225 : 45) +
  51258. 'deg)'
  51259. }
  51260. var rotateRadian = (rotateDeg * Math.PI) / 180
  51261. var arrowWH = arrowSize + borderWidth
  51262. var rotatedWH =
  51263. arrowWH * Math.abs(Math.cos(rotateRadian)) +
  51264. arrowWH * Math.abs(Math.sin(rotateRadian))
  51265. var arrowOffset =
  51266. Math.round(
  51267. ((rotatedWH - Math.SQRT2 * borderWidth) / 2 +
  51268. Math.SQRT2 * borderWidth -
  51269. (rotatedWH - arrowWH) / 2) *
  51270. 100
  51271. ) / 100
  51272. positionStyle += ';' + arrowPos + ':-' + arrowOffset + 'px'
  51273. var borderStyle = borderColor + ' solid ' + borderWidth + 'px;'
  51274. var styleCss = [
  51275. 'position:absolute;width:' +
  51276. arrowSize +
  51277. 'px;height:' +
  51278. arrowSize +
  51279. 'px;',
  51280. positionStyle + ';' + transformStyle + ';',
  51281. 'border-bottom:' + borderStyle,
  51282. 'border-right:' + borderStyle,
  51283. 'background-color:' + backgroundColor + ';'
  51284. ]
  51285. return '<div style="' + styleCss.join('') + '"></div>'
  51286. }
  51287. function assembleTransition(duration, onlyFade) {
  51288. var transitionCurve = 'cubic-bezier(0.23,1,0.32,1)'
  51289. var transitionOption = ' ' + duration / 2 + 's ' + transitionCurve
  51290. var transitionText =
  51291. 'opacity' + transitionOption + ',visibility' + transitionOption
  51292. if (!onlyFade) {
  51293. transitionOption = ' ' + duration + 's ' + transitionCurve
  51294. transitionText += env$1.transformSupported
  51295. ? ',' + CSS_TRANSFORM_VENDOR + transitionOption
  51296. : ',left' + transitionOption + ',top' + transitionOption
  51297. }
  51298. return CSS_TRANSITION_VENDOR + ':' + transitionText
  51299. }
  51300. function assembleTransform(x, y, toString) {
  51301. // If using float on style, the final width of the dom might
  51302. // keep changing slightly while mouse move. So `toFixed(0)` them.
  51303. var x0 = x.toFixed(0) + 'px'
  51304. var y0 = y.toFixed(0) + 'px' // not support transform, use `left` and `top` instead.
  51305. if (!env$1.transformSupported) {
  51306. return toString
  51307. ? 'top:' + y0 + ';left:' + x0 + ';'
  51308. : [
  51309. ['top', y0],
  51310. ['left', x0]
  51311. ]
  51312. } // support transform
  51313. var is3d = env$1.transform3dSupported
  51314. var translate =
  51315. 'translate' +
  51316. (is3d ? '3d' : '') +
  51317. '(' +
  51318. x0 +
  51319. ',' +
  51320. y0 +
  51321. (is3d ? ',0' : '') +
  51322. ')'
  51323. return toString
  51324. ? 'top:0;left:0;' + CSS_TRANSFORM_VENDOR + ':' + translate + ';'
  51325. : [
  51326. ['top', 0],
  51327. ['left', 0],
  51328. [TRANSFORM_VENDOR, translate]
  51329. ]
  51330. }
  51331. /**
  51332. * @param {Object} textStyle
  51333. * @return {string}
  51334. * @inner
  51335. */ function assembleFont(textStyleModel) {
  51336. var cssText = []
  51337. var fontSize = textStyleModel.get('fontSize')
  51338. var color = textStyleModel.getTextColor()
  51339. color && cssText.push('color:' + color)
  51340. cssText.push('font:' + textStyleModel.getFont())
  51341. fontSize && // @ts-ignore, leave it to the tooltip refactor.
  51342. cssText.push(
  51343. 'line-height:' + Math.round((fontSize * 3) / 2) + 'px'
  51344. )
  51345. var shadowColor = textStyleModel.get('textShadowColor')
  51346. var shadowBlur = textStyleModel.get('textShadowBlur') || 0
  51347. var shadowOffsetX = textStyleModel.get('textShadowOffsetX') || 0
  51348. var shadowOffsetY = textStyleModel.get('textShadowOffsetY') || 0
  51349. shadowColor &&
  51350. shadowBlur &&
  51351. cssText.push(
  51352. 'text-shadow:' +
  51353. shadowOffsetX +
  51354. 'px ' +
  51355. shadowOffsetY +
  51356. 'px ' +
  51357. shadowBlur +
  51358. 'px ' +
  51359. shadowColor
  51360. )
  51361. each$7(['decoration', 'align'], function (name) {
  51362. var val = textStyleModel.get(name)
  51363. val && cssText.push('text-' + name + ':' + val)
  51364. })
  51365. return cssText.join(';')
  51366. }
  51367. function assembleCssText(tooltipModel, enableTransition, onlyFade) {
  51368. var cssText = []
  51369. var transitionDuration = tooltipModel.get('transitionDuration')
  51370. var backgroundColor = tooltipModel.get('backgroundColor')
  51371. var shadowBlur = tooltipModel.get('shadowBlur')
  51372. var shadowColor = tooltipModel.get('shadowColor')
  51373. var shadowOffsetX = tooltipModel.get('shadowOffsetX')
  51374. var shadowOffsetY = tooltipModel.get('shadowOffsetY')
  51375. var textStyleModel = tooltipModel.getModel('textStyle')
  51376. var padding = getPaddingFromTooltipModel(tooltipModel, 'html')
  51377. var boxShadow =
  51378. shadowOffsetX +
  51379. 'px ' +
  51380. shadowOffsetY +
  51381. 'px ' +
  51382. shadowBlur +
  51383. 'px ' +
  51384. shadowColor
  51385. cssText.push('box-shadow:' + boxShadow) // Animation transition. Do not animate when transitionDuration is 0.
  51386. enableTransition &&
  51387. transitionDuration &&
  51388. cssText.push(assembleTransition(transitionDuration, onlyFade))
  51389. if (backgroundColor) {
  51390. cssText.push('background-color:' + backgroundColor)
  51391. } // Border style
  51392. each$7(['width', 'color', 'radius'], function (name) {
  51393. var borderName = 'border-' + name
  51394. var camelCase = toCamelCase(borderName)
  51395. var val = tooltipModel.get(camelCase)
  51396. val != null &&
  51397. cssText.push(
  51398. borderName + ':' + val + (name === 'color' ? '' : 'px')
  51399. )
  51400. }) // Text style
  51401. cssText.push(assembleFont(textStyleModel)) // Padding
  51402. if (padding != null) {
  51403. cssText.push(
  51404. 'padding:' + normalizeCssArray(padding).join('px ') + 'px'
  51405. )
  51406. }
  51407. return cssText.join(';') + ';'
  51408. } // If not able to make, do not modify the input `out`.
  51409. function makeStyleCoord$1(out, zr, appendToBody, zrX, zrY) {
  51410. var zrPainter = zr && zr.painter
  51411. if (appendToBody) {
  51412. var zrViewportRoot = zrPainter && zrPainter.getViewportRoot()
  51413. if (zrViewportRoot) {
  51414. // Some APPs might use scale on body, so we support CSS transform here.
  51415. transformLocalCoord(
  51416. out,
  51417. zrViewportRoot,
  51418. document.body,
  51419. zrX,
  51420. zrY
  51421. )
  51422. }
  51423. } else {
  51424. out[0] = zrX
  51425. out[1] = zrY // xy should be based on canvas root. But tooltipContent is
  51426. // the sibling of canvas root. So padding of ec container
  51427. // should be considered here.
  51428. var viewportRootOffset =
  51429. zrPainter && zrPainter.getViewportRootOffset()
  51430. if (viewportRootOffset) {
  51431. out[0] += viewportRootOffset.offsetLeft
  51432. out[1] += viewportRootOffset.offsetTop
  51433. }
  51434. }
  51435. out[2] = out[0] / zr.getWidth()
  51436. out[3] = out[1] / zr.getHeight()
  51437. }
  51438. var TooltipHTMLContent = /** @class */ (function () {
  51439. function TooltipHTMLContent(container, api, opt) {
  51440. this._show = false
  51441. this._styleCoord = [0, 0, 0, 0]
  51442. this._enterable = true
  51443. this._firstShow = true
  51444. this._longHide = true
  51445. if (env$1.wxa) {
  51446. return null
  51447. }
  51448. var el = document.createElement('div') // TODO: TYPE
  51449. el.domBelongToZr = true
  51450. this.el = el
  51451. var zr = (this._zr = api.getZr())
  51452. var appendToBody = (this._appendToBody = opt && opt.appendToBody)
  51453. makeStyleCoord$1(
  51454. this._styleCoord,
  51455. zr,
  51456. appendToBody,
  51457. api.getWidth() / 2,
  51458. api.getHeight() / 2
  51459. )
  51460. if (appendToBody) {
  51461. document.body.appendChild(el)
  51462. } else {
  51463. container.appendChild(el)
  51464. }
  51465. this._container = container // FIXME
  51466. // Is it needed to trigger zr event manually if
  51467. // the browser do not support `pointer-events: none`.
  51468. var self = this
  51469. el.onmouseenter = function () {
  51470. // clear the timeout in hideLater and keep showing tooltip
  51471. if (self._enterable) {
  51472. clearTimeout(self._hideTimeout)
  51473. self._show = true
  51474. }
  51475. self._inContent = true
  51476. }
  51477. el.onmousemove = function (e) {
  51478. e = e || window.event
  51479. if (!self._enterable) {
  51480. // `pointer-events: none` is set to tooltip content div
  51481. // if `enterable` is set as `false`, and `el.onmousemove`
  51482. // can not be triggered. But in browser that do not
  51483. // support `pointer-events`, we need to do this:
  51484. // Try trigger zrender event to avoid mouse
  51485. // in and out shape too frequently
  51486. var handler = zr.handler
  51487. var zrViewportRoot = zr.painter.getViewportRoot()
  51488. normalizeEvent(zrViewportRoot, e, true)
  51489. handler.dispatch('mousemove', e)
  51490. }
  51491. }
  51492. el.onmouseleave = function () {
  51493. // set `_inContent` to `false` before `hideLater`
  51494. self._inContent = false
  51495. if (self._enterable) {
  51496. if (self._show) {
  51497. self.hideLater(self._hideDelay)
  51498. }
  51499. }
  51500. }
  51501. }
  51502. /**
  51503. * Update when tooltip is rendered
  51504. */ TooltipHTMLContent.prototype.update = function (tooltipModel) {
  51505. // FIXME
  51506. // Move this logic to ec main?
  51507. var container = this._container
  51508. var position = getComputedStyle(container, 'position')
  51509. var domStyle = container.style
  51510. if (domStyle.position !== 'absolute' && position !== 'absolute') {
  51511. domStyle.position = 'relative'
  51512. } // move tooltip if chart resized
  51513. var alwaysShowContent = tooltipModel.get('alwaysShowContent')
  51514. alwaysShowContent && this._moveIfResized() // update className
  51515. this.el.className = tooltipModel.get('className') || '' // Hide the tooltip
  51516. // PENDING
  51517. // this.hide();
  51518. }
  51519. TooltipHTMLContent.prototype.show = function (
  51520. tooltipModel,
  51521. nearPointColor
  51522. ) {
  51523. clearTimeout(this._hideTimeout)
  51524. clearTimeout(this._longHideTimeout)
  51525. var el = this.el
  51526. var style = el.style
  51527. var styleCoord = this._styleCoord
  51528. if (!el.innerHTML) {
  51529. style.display = 'none'
  51530. } else {
  51531. style.cssText =
  51532. gCssText +
  51533. assembleCssText(
  51534. tooltipModel,
  51535. !this._firstShow,
  51536. this._longHide
  51537. ) + // initial transform
  51538. assembleTransform(styleCoord[0], styleCoord[1], true) +
  51539. ('border-color:' +
  51540. convertToColorString(nearPointColor) +
  51541. ';') +
  51542. (tooltipModel.get('extraCssText') || '') + // If mouse occasionally move over the tooltip, a mouseout event will be
  51543. // triggered by canvas, and cause some unexpectable result like dragging
  51544. // stop, "unfocusAdjacency". Here `pointer-events: none` is used to solve
  51545. // it. Although it is not supported by IE8~IE10, fortunately it is a rare
  51546. // scenario.
  51547. (';pointer-events:' + (this._enterable ? 'auto' : 'none'))
  51548. }
  51549. this._show = true
  51550. this._firstShow = false
  51551. this._longHide = false
  51552. }
  51553. TooltipHTMLContent.prototype.setContent = function (
  51554. content,
  51555. markers,
  51556. tooltipModel,
  51557. borderColor,
  51558. arrowPosition
  51559. ) {
  51560. var el = this.el
  51561. if (content == null) {
  51562. el.innerHTML = ''
  51563. return
  51564. }
  51565. var arrow = ''
  51566. if (
  51567. isString(arrowPosition) &&
  51568. tooltipModel.get('trigger') === 'item' &&
  51569. !shouldTooltipConfine(tooltipModel)
  51570. ) {
  51571. arrow = assembleArrow(tooltipModel, borderColor, arrowPosition)
  51572. }
  51573. if (isString(content)) {
  51574. el.innerHTML = content + arrow
  51575. } else if (content) {
  51576. // Clear previous
  51577. el.innerHTML = ''
  51578. if (!isArray(content)) {
  51579. content = [content]
  51580. }
  51581. for (var i = 0; i < content.length; i++) {
  51582. if (isDom(content[i]) && content[i].parentNode !== el) {
  51583. el.appendChild(content[i])
  51584. }
  51585. } // no arrow if empty
  51586. if (arrow && el.childNodes.length) {
  51587. // no need to create a new parent element, but it's not supported by IE 10 and older.
  51588. // const arrowEl = document.createRange().createContextualFragment(arrow);
  51589. var arrowEl = document.createElement('div')
  51590. arrowEl.innerHTML = arrow
  51591. el.appendChild(arrowEl)
  51592. }
  51593. }
  51594. }
  51595. TooltipHTMLContent.prototype.setEnterable = function (enterable) {
  51596. this._enterable = enterable
  51597. }
  51598. TooltipHTMLContent.prototype.getSize = function () {
  51599. var el = this.el
  51600. return [el.offsetWidth, el.offsetHeight]
  51601. }
  51602. TooltipHTMLContent.prototype.moveTo = function (zrX, zrY) {
  51603. var styleCoord = this._styleCoord
  51604. makeStyleCoord$1(
  51605. styleCoord,
  51606. this._zr,
  51607. this._appendToBody,
  51608. zrX,
  51609. zrY
  51610. )
  51611. if (styleCoord[0] != null && styleCoord[1] != null) {
  51612. var style_1 = this.el.style
  51613. var transforms = assembleTransform(styleCoord[0], styleCoord[1])
  51614. each$7(transforms, function (transform) {
  51615. style_1[transform[0]] = transform[1]
  51616. })
  51617. }
  51618. }
  51619. /**
  51620. * when `alwaysShowContent` is true,
  51621. * move the tooltip after chart resized
  51622. */ TooltipHTMLContent.prototype._moveIfResized = function () {
  51623. // The ratio of left to width
  51624. var ratioX = this._styleCoord[2] // The ratio of top to height
  51625. var ratioY = this._styleCoord[3]
  51626. this.moveTo(
  51627. ratioX * this._zr.getWidth(),
  51628. ratioY * this._zr.getHeight()
  51629. )
  51630. }
  51631. TooltipHTMLContent.prototype.hide = function () {
  51632. var _this = this
  51633. var style = this.el.style
  51634. style.visibility = 'hidden'
  51635. style.opacity = '0'
  51636. env$1.transform3dSupported && (style.willChange = '')
  51637. this._show = false
  51638. this._longHideTimeout = setTimeout(function () {
  51639. return (_this._longHide = true)
  51640. }, 500)
  51641. }
  51642. TooltipHTMLContent.prototype.hideLater = function (time) {
  51643. if (this._show && !(this._inContent && this._enterable)) {
  51644. if (time) {
  51645. this._hideDelay = time // Set show false to avoid invoke hideLater multiple times
  51646. this._show = false
  51647. this._hideTimeout = setTimeout(bind$1(this.hide, this), time)
  51648. } else {
  51649. this.hide()
  51650. }
  51651. }
  51652. }
  51653. TooltipHTMLContent.prototype.isShow = function () {
  51654. return this._show
  51655. }
  51656. TooltipHTMLContent.prototype.dispose = function () {
  51657. this.el.parentNode.removeChild(this.el)
  51658. }
  51659. return TooltipHTMLContent
  51660. })()
  51661. var TooltipHTMLContent$1 = TooltipHTMLContent
  51662. var TooltipRichContent = /** @class */ (function () {
  51663. function TooltipRichContent(api) {
  51664. this._show = false
  51665. this._styleCoord = [0, 0, 0, 0]
  51666. this._enterable = true
  51667. this._zr = api.getZr()
  51668. makeStyleCoord(
  51669. this._styleCoord,
  51670. this._zr,
  51671. api.getWidth() / 2,
  51672. api.getHeight() / 2
  51673. )
  51674. }
  51675. /**
  51676. * Update when tooltip is rendered
  51677. */ TooltipRichContent.prototype.update = function (tooltipModel) {
  51678. var alwaysShowContent = tooltipModel.get('alwaysShowContent')
  51679. alwaysShowContent && this._moveIfResized()
  51680. }
  51681. TooltipRichContent.prototype.show = function () {
  51682. if (this._hideTimeout) {
  51683. clearTimeout(this._hideTimeout)
  51684. }
  51685. this.el.show()
  51686. this._show = true
  51687. }
  51688. /**
  51689. * Set tooltip content
  51690. */ TooltipRichContent.prototype.setContent = function (
  51691. content,
  51692. markupStyleCreator,
  51693. tooltipModel,
  51694. borderColor,
  51695. arrowPosition
  51696. ) {
  51697. var _this = this
  51698. if (isObject$2(content)) {
  51699. throwError('')
  51700. }
  51701. if (this.el) {
  51702. this._zr.remove(this.el)
  51703. }
  51704. var textStyleModel = tooltipModel.getModel('textStyle')
  51705. this.el = new ZRText$1({
  51706. style: {
  51707. rich: markupStyleCreator.richTextStyles,
  51708. text: content,
  51709. lineHeight: 22,
  51710. borderWidth: 1,
  51711. borderColor: borderColor,
  51712. textShadowColor: textStyleModel.get('textShadowColor'),
  51713. fill: tooltipModel.get(['textStyle', 'color']),
  51714. padding: getPaddingFromTooltipModel(tooltipModel, 'richText'),
  51715. verticalAlign: 'top',
  51716. align: 'left'
  51717. },
  51718. z: tooltipModel.get('z')
  51719. })
  51720. each$7(
  51721. [
  51722. 'backgroundColor',
  51723. 'borderRadius',
  51724. 'shadowColor',
  51725. 'shadowBlur',
  51726. 'shadowOffsetX',
  51727. 'shadowOffsetY'
  51728. ],
  51729. function (propName) {
  51730. _this.el.style[propName] = tooltipModel.get(propName)
  51731. }
  51732. )
  51733. each$7(
  51734. ['textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY'],
  51735. function (propName) {
  51736. _this.el.style[propName] = textStyleModel.get(propName) || 0
  51737. }
  51738. )
  51739. this._zr.add(this.el)
  51740. var self = this
  51741. this.el.on('mouseover', function () {
  51742. // clear the timeout in hideLater and keep showing tooltip
  51743. if (self._enterable) {
  51744. clearTimeout(self._hideTimeout)
  51745. self._show = true
  51746. }
  51747. self._inContent = true
  51748. })
  51749. this.el.on('mouseout', function () {
  51750. if (self._enterable) {
  51751. if (self._show) {
  51752. self.hideLater(self._hideDelay)
  51753. }
  51754. }
  51755. self._inContent = false
  51756. })
  51757. }
  51758. TooltipRichContent.prototype.setEnterable = function (enterable) {
  51759. this._enterable = enterable
  51760. }
  51761. TooltipRichContent.prototype.getSize = function () {
  51762. var el = this.el
  51763. var bounding = this.el.getBoundingRect() // bounding rect does not include shadow. For renderMode richText,
  51764. // if overflow, it will be cut. So calculate them accurately.
  51765. var shadowOuterSize = calcShadowOuterSize(el.style)
  51766. return [
  51767. bounding.width + shadowOuterSize.left + shadowOuterSize.right,
  51768. bounding.height + shadowOuterSize.top + shadowOuterSize.bottom
  51769. ]
  51770. }
  51771. TooltipRichContent.prototype.moveTo = function (x, y) {
  51772. var el = this.el
  51773. if (el) {
  51774. var styleCoord = this._styleCoord
  51775. makeStyleCoord(styleCoord, this._zr, x, y)
  51776. x = styleCoord[0]
  51777. y = styleCoord[1]
  51778. var style = el.style
  51779. var borderWidth = mathMaxWith0(style.borderWidth || 0)
  51780. var shadowOuterSize = calcShadowOuterSize(style) // rich text x, y do not include border.
  51781. el.x = x + borderWidth + shadowOuterSize.left
  51782. el.y = y + borderWidth + shadowOuterSize.top
  51783. el.markRedraw()
  51784. }
  51785. }
  51786. /**
  51787. * when `alwaysShowContent` is true,
  51788. * move the tooltip after chart resized
  51789. */ TooltipRichContent.prototype._moveIfResized = function () {
  51790. // The ratio of left to width
  51791. var ratioX = this._styleCoord[2] // The ratio of top to height
  51792. var ratioY = this._styleCoord[3]
  51793. this.moveTo(
  51794. ratioX * this._zr.getWidth(),
  51795. ratioY * this._zr.getHeight()
  51796. )
  51797. }
  51798. TooltipRichContent.prototype.hide = function () {
  51799. if (this.el) {
  51800. this.el.hide()
  51801. }
  51802. this._show = false
  51803. }
  51804. TooltipRichContent.prototype.hideLater = function (time) {
  51805. if (this._show && !(this._inContent && this._enterable)) {
  51806. if (time) {
  51807. this._hideDelay = time // Set show false to avoid invoke hideLater multiple times
  51808. this._show = false
  51809. this._hideTimeout = setTimeout(bind$1(this.hide, this), time)
  51810. } else {
  51811. this.hide()
  51812. }
  51813. }
  51814. }
  51815. TooltipRichContent.prototype.isShow = function () {
  51816. return this._show
  51817. }
  51818. TooltipRichContent.prototype.dispose = function () {
  51819. this._zr.remove(this.el)
  51820. }
  51821. return TooltipRichContent
  51822. })()
  51823. function mathMaxWith0(val) {
  51824. return Math.max(0, val)
  51825. }
  51826. function calcShadowOuterSize(style) {
  51827. var shadowBlur = mathMaxWith0(style.shadowBlur || 0)
  51828. var shadowOffsetX = mathMaxWith0(style.shadowOffsetX || 0)
  51829. var shadowOffsetY = mathMaxWith0(style.shadowOffsetY || 0)
  51830. return {
  51831. left: mathMaxWith0(shadowBlur - shadowOffsetX),
  51832. right: mathMaxWith0(shadowBlur + shadowOffsetX),
  51833. top: mathMaxWith0(shadowBlur - shadowOffsetY),
  51834. bottom: mathMaxWith0(shadowBlur + shadowOffsetY)
  51835. }
  51836. }
  51837. function makeStyleCoord(out, zr, zrX, zrY) {
  51838. out[0] = zrX
  51839. out[1] = zrY
  51840. out[2] = out[0] / zr.getWidth()
  51841. out[3] = out[1] / zr.getHeight()
  51842. }
  51843. var TooltipRichContent$1 = TooltipRichContent
  51844. var proxyRect = new Rect$2({
  51845. shape: { x: -1, y: -1, width: 2, height: 2 }
  51846. })
  51847. var TooltipView = /** @class */ (function (_super) {
  51848. __extends(TooltipView, _super)
  51849. function TooltipView() {
  51850. var _this =
  51851. (_super !== null && _super.apply(this, arguments)) || this
  51852. _this.type = TooltipView.type
  51853. return _this
  51854. }
  51855. TooltipView.prototype.init = function (ecModel, api) {
  51856. if (env$1.node || !api.getDom()) {
  51857. return
  51858. }
  51859. var tooltipModel = ecModel.getComponent('tooltip')
  51860. var renderMode = (this._renderMode = getTooltipRenderMode(
  51861. tooltipModel.get('renderMode')
  51862. ))
  51863. this._tooltipContent =
  51864. renderMode === 'richText'
  51865. ? new TooltipRichContent$1(api)
  51866. : new TooltipHTMLContent$1(api.getDom(), api, {
  51867. appendToBody: tooltipModel.get('appendToBody', true)
  51868. })
  51869. }
  51870. TooltipView.prototype.render = function (
  51871. tooltipModel,
  51872. ecModel,
  51873. api
  51874. ) {
  51875. if (env$1.node || !api.getDom()) {
  51876. return
  51877. } // Reset
  51878. this.group.removeAll()
  51879. this._tooltipModel = tooltipModel
  51880. this._ecModel = ecModel
  51881. this._api = api
  51882. /**
  51883. * @private
  51884. * @type {boolean}
  51885. */ this._alwaysShowContent =
  51886. tooltipModel.get('alwaysShowContent')
  51887. var tooltipContent = this._tooltipContent
  51888. tooltipContent.update(tooltipModel)
  51889. tooltipContent.setEnterable(tooltipModel.get('enterable'))
  51890. this._initGlobalListener()
  51891. this._keepShow() // PENDING
  51892. // `mousemove` event will be triggered very frequently when the mouse moves fast,
  51893. // which causes that the `updatePosition` function was also called frequently.
  51894. // In Chrome with devtools open and Firefox, tooltip looks laggy and shakes. See #14695 #16101
  51895. // To avoid frequent triggering,
  51896. // consider throttling it in 50ms when transition is enabled
  51897. if (
  51898. this._renderMode !== 'richText' &&
  51899. tooltipModel.get('transitionDuration')
  51900. ) {
  51901. createOrUpdate(this, '_updatePosition', 50, 'fixRate')
  51902. } else {
  51903. clear$1(this, '_updatePosition')
  51904. }
  51905. }
  51906. TooltipView.prototype._initGlobalListener = function () {
  51907. var tooltipModel = this._tooltipModel
  51908. var triggerOn = tooltipModel.get('triggerOn')
  51909. register(
  51910. 'itemTooltip',
  51911. this._api,
  51912. bind$1(function (currTrigger, e, dispatchAction) {
  51913. // If 'none', it is not controlled by mouse totally.
  51914. if (triggerOn !== 'none') {
  51915. if (triggerOn.indexOf(currTrigger) >= 0) {
  51916. this._tryShow(e, dispatchAction)
  51917. } else if (currTrigger === 'leave') {
  51918. this._hide(dispatchAction)
  51919. }
  51920. }
  51921. }, this)
  51922. )
  51923. }
  51924. TooltipView.prototype._keepShow = function () {
  51925. var tooltipModel = this._tooltipModel
  51926. var ecModel = this._ecModel
  51927. var api = this._api
  51928. var triggerOn = tooltipModel.get('triggerOn') // Try to keep the tooltip show when refreshing
  51929. if (
  51930. this._lastX != null &&
  51931. this._lastY != null && // When user is willing to control tooltip totally using API,
  51932. // self.manuallyShowTip({x, y}) might cause tooltip hide,
  51933. // which is not expected.
  51934. triggerOn !== 'none' &&
  51935. triggerOn !== 'click'
  51936. ) {
  51937. var self_1 = this
  51938. clearTimeout(this._refreshUpdateTimeout)
  51939. this._refreshUpdateTimeout = setTimeout(function () {
  51940. // Show tip next tick after other charts are rendered
  51941. // In case highlight action has wrong result
  51942. // FIXME
  51943. !api.isDisposed() &&
  51944. self_1.manuallyShowTip(tooltipModel, ecModel, api, {
  51945. x: self_1._lastX,
  51946. y: self_1._lastY,
  51947. dataByCoordSys: self_1._lastDataByCoordSys
  51948. })
  51949. })
  51950. }
  51951. }
  51952. /**
  51953. * Show tip manually by
  51954. * dispatchAction({
  51955. * type: 'showTip',
  51956. * x: 10,
  51957. * y: 10
  51958. * });
  51959. * Or
  51960. * dispatchAction({
  51961. * type: 'showTip',
  51962. * seriesIndex: 0,
  51963. * dataIndex or dataIndexInside or name
  51964. * });
  51965. *
  51966. * TODO Batch
  51967. */ TooltipView.prototype.manuallyShowTip = function (
  51968. tooltipModel,
  51969. ecModel,
  51970. api,
  51971. payload
  51972. ) {
  51973. if (payload.from === this.uid || env$1.node || !api.getDom()) {
  51974. return
  51975. }
  51976. var dispatchAction = makeDispatchAction(payload, api) // Reset ticket
  51977. this._ticket = '' // When triggered from axisPointer.
  51978. var dataByCoordSys = payload.dataByCoordSys
  51979. var cmptRef = findComponentReference(payload, ecModel, api)
  51980. if (cmptRef) {
  51981. var rect = cmptRef.el.getBoundingRect().clone()
  51982. rect.applyTransform(cmptRef.el.transform)
  51983. this._tryShow(
  51984. {
  51985. offsetX: rect.x + rect.width / 2,
  51986. offsetY: rect.y + rect.height / 2,
  51987. target: cmptRef.el,
  51988. position: payload.position, // When manully trigger, the mouse is not on the el, so we'd better to
  51989. // position tooltip on the bottom of the el and display arrow is possible.
  51990. positionDefault: 'bottom'
  51991. },
  51992. dispatchAction
  51993. )
  51994. } else if (
  51995. payload.tooltip &&
  51996. payload.x != null &&
  51997. payload.y != null
  51998. ) {
  51999. var el = proxyRect
  52000. el.x = payload.x
  52001. el.y = payload.y
  52002. el.update()
  52003. getECData(el).tooltipConfig = {
  52004. name: null,
  52005. option: payload.tooltip
  52006. } // Manually show tooltip while view is not using zrender elements.
  52007. this._tryShow(
  52008. { offsetX: payload.x, offsetY: payload.y, target: el },
  52009. dispatchAction
  52010. )
  52011. } else if (dataByCoordSys) {
  52012. this._tryShow(
  52013. {
  52014. offsetX: payload.x,
  52015. offsetY: payload.y,
  52016. position: payload.position,
  52017. dataByCoordSys: dataByCoordSys,
  52018. tooltipOption: payload.tooltipOption
  52019. },
  52020. dispatchAction
  52021. )
  52022. } else if (payload.seriesIndex != null) {
  52023. if (
  52024. this._manuallyAxisShowTip(tooltipModel, ecModel, api, payload)
  52025. ) {
  52026. return
  52027. }
  52028. var pointInfo = findPointFromSeries(payload, ecModel)
  52029. var cx = pointInfo.point[0]
  52030. var cy = pointInfo.point[1]
  52031. if (cx != null && cy != null) {
  52032. this._tryShow(
  52033. {
  52034. offsetX: cx,
  52035. offsetY: cy,
  52036. target: pointInfo.el,
  52037. position: payload.position, // When manully trigger, the mouse is not on the el, so we'd better to
  52038. // position tooltip on the bottom of the el and display arrow is possible.
  52039. positionDefault: 'bottom'
  52040. },
  52041. dispatchAction
  52042. )
  52043. }
  52044. } else if (payload.x != null && payload.y != null) {
  52045. // FIXME
  52046. // should wrap dispatchAction like `axisPointer/globalListener` ?
  52047. api.dispatchAction({
  52048. type: 'updateAxisPointer',
  52049. x: payload.x,
  52050. y: payload.y
  52051. })
  52052. this._tryShow(
  52053. {
  52054. offsetX: payload.x,
  52055. offsetY: payload.y,
  52056. position: payload.position,
  52057. target: api.getZr().findHover(payload.x, payload.y).target
  52058. },
  52059. dispatchAction
  52060. )
  52061. }
  52062. }
  52063. TooltipView.prototype.manuallyHideTip = function (
  52064. tooltipModel,
  52065. ecModel,
  52066. api,
  52067. payload
  52068. ) {
  52069. var tooltipContent = this._tooltipContent
  52070. if (!this._alwaysShowContent && this._tooltipModel) {
  52071. tooltipContent.hideLater(this._tooltipModel.get('hideDelay'))
  52072. }
  52073. this._lastX = this._lastY = this._lastDataByCoordSys = null
  52074. if (payload.from !== this.uid) {
  52075. this._hide(makeDispatchAction(payload, api))
  52076. }
  52077. } // Be compatible with previous design, that is, when tooltip.type is 'axis' and
  52078. // dispatchAction 'showTip' with seriesIndex and dataIndex will trigger axis pointer
  52079. // and tooltip.
  52080. TooltipView.prototype._manuallyAxisShowTip = function (
  52081. tooltipModel,
  52082. ecModel,
  52083. api,
  52084. payload
  52085. ) {
  52086. var seriesIndex = payload.seriesIndex
  52087. var dataIndex = payload.dataIndex // @ts-ignore
  52088. var coordSysAxesInfo =
  52089. ecModel.getComponent('axisPointer').coordSysAxesInfo
  52090. if (
  52091. seriesIndex == null ||
  52092. dataIndex == null ||
  52093. coordSysAxesInfo == null
  52094. ) {
  52095. return
  52096. }
  52097. var seriesModel = ecModel.getSeriesByIndex(seriesIndex)
  52098. if (!seriesModel) {
  52099. return
  52100. }
  52101. var data = seriesModel.getData()
  52102. var tooltipCascadedModel = buildTooltipModel(
  52103. [
  52104. data.getItemModel(dataIndex),
  52105. seriesModel,
  52106. (seriesModel.coordinateSystem || {}).model
  52107. ],
  52108. this._tooltipModel
  52109. )
  52110. if (tooltipCascadedModel.get('trigger') !== 'axis') {
  52111. return
  52112. }
  52113. api.dispatchAction({
  52114. type: 'updateAxisPointer',
  52115. seriesIndex: seriesIndex,
  52116. dataIndex: dataIndex,
  52117. position: payload.position
  52118. })
  52119. return true
  52120. }
  52121. TooltipView.prototype._tryShow = function (e, dispatchAction) {
  52122. var el = e.target
  52123. var tooltipModel = this._tooltipModel
  52124. if (!tooltipModel) {
  52125. return
  52126. } // Save mouse x, mouse y. So we can try to keep showing the tip if chart is refreshed
  52127. this._lastX = e.offsetX
  52128. this._lastY = e.offsetY
  52129. var dataByCoordSys = e.dataByCoordSys
  52130. if (dataByCoordSys && dataByCoordSys.length) {
  52131. this._showAxisTooltip(dataByCoordSys, e)
  52132. } else if (el) {
  52133. this._lastDataByCoordSys = null
  52134. var seriesDispatcher_1
  52135. var cmptDispatcher_1
  52136. findEventDispatcher(
  52137. el,
  52138. function (target) {
  52139. // Always show item tooltip if mouse is on the element with dataIndex
  52140. if (getECData(target).dataIndex != null) {
  52141. seriesDispatcher_1 = target
  52142. return true
  52143. } // Tooltip provided directly. Like legend.
  52144. if (getECData(target).tooltipConfig != null) {
  52145. cmptDispatcher_1 = target
  52146. return true
  52147. }
  52148. },
  52149. true
  52150. )
  52151. if (seriesDispatcher_1) {
  52152. this._showSeriesItemTooltip(
  52153. e,
  52154. seriesDispatcher_1,
  52155. dispatchAction
  52156. )
  52157. } else if (cmptDispatcher_1) {
  52158. this._showComponentItemTooltip(
  52159. e,
  52160. cmptDispatcher_1,
  52161. dispatchAction
  52162. )
  52163. } else {
  52164. this._hide(dispatchAction)
  52165. }
  52166. } else {
  52167. this._lastDataByCoordSys = null
  52168. this._hide(dispatchAction)
  52169. }
  52170. }
  52171. TooltipView.prototype._showOrMove = function (tooltipModel, cb) {
  52172. // showDelay is used in this case: tooltip.enterable is set
  52173. // as true. User intent to move mouse into tooltip and click
  52174. // something. `showDelay` makes it easier to enter the content
  52175. // but tooltip do not move immediately.
  52176. var delay = tooltipModel.get('showDelay')
  52177. cb = bind$1(cb, this)
  52178. clearTimeout(this._showTimout)
  52179. delay > 0 ? (this._showTimout = setTimeout(cb, delay)) : cb()
  52180. }
  52181. TooltipView.prototype._showAxisTooltip = function (
  52182. dataByCoordSys,
  52183. e
  52184. ) {
  52185. var ecModel = this._ecModel
  52186. var globalTooltipModel = this._tooltipModel
  52187. var point = [e.offsetX, e.offsetY]
  52188. var singleTooltipModel = buildTooltipModel(
  52189. [e.tooltipOption],
  52190. globalTooltipModel
  52191. )
  52192. var renderMode = this._renderMode
  52193. var cbParamsList = []
  52194. var articleMarkup = createTooltipMarkup('section', {
  52195. blocks: [],
  52196. noHeader: true
  52197. }) // Only for legacy: `Serise['formatTooltip']` returns a string.
  52198. var markupTextArrLegacy = []
  52199. var markupStyleCreator = new TooltipMarkupStyleCreator()
  52200. each$7(dataByCoordSys, function (itemCoordSys) {
  52201. each$7(itemCoordSys.dataByAxis, function (axisItem) {
  52202. var axisModel = ecModel.getComponent(
  52203. axisItem.axisDim + 'Axis',
  52204. axisItem.axisIndex
  52205. )
  52206. var axisValue = axisItem.value
  52207. if (!axisModel || axisValue == null) {
  52208. return
  52209. }
  52210. var axisValueLabel = getValueLabel(
  52211. axisValue,
  52212. axisModel.axis,
  52213. ecModel,
  52214. axisItem.seriesDataIndices,
  52215. axisItem.valueLabelOpt
  52216. )
  52217. var axisSectionMarkup = createTooltipMarkup('section', {
  52218. header: axisValueLabel,
  52219. noHeader: !trim$1(axisValueLabel),
  52220. sortBlocks: true,
  52221. blocks: []
  52222. })
  52223. articleMarkup.blocks.push(axisSectionMarkup)
  52224. each$7(axisItem.seriesDataIndices, function (idxItem) {
  52225. var series = ecModel.getSeriesByIndex(idxItem.seriesIndex)
  52226. var dataIndex = idxItem.dataIndexInside
  52227. var cbParams = series.getDataParams(dataIndex) // Can't find data.
  52228. if (cbParams.dataIndex < 0) {
  52229. return
  52230. }
  52231. cbParams.axisDim = axisItem.axisDim
  52232. cbParams.axisIndex = axisItem.axisIndex
  52233. cbParams.axisType = axisItem.axisType
  52234. cbParams.axisId = axisItem.axisId
  52235. cbParams.axisValue = getAxisRawValue(axisModel.axis, {
  52236. value: axisValue
  52237. })
  52238. cbParams.axisValueLabel = axisValueLabel // Pre-create marker style for makers. Users can assemble richText
  52239. // text in `formatter` callback and use those markers style.
  52240. cbParams.marker = markupStyleCreator.makeTooltipMarker(
  52241. 'item',
  52242. convertToColorString(cbParams.color),
  52243. renderMode
  52244. )
  52245. var seriesTooltipResult = normalizeTooltipFormatResult(
  52246. series.formatTooltip(dataIndex, true, null)
  52247. )
  52248. var frag = seriesTooltipResult.frag
  52249. if (frag) {
  52250. var valueFormatter = buildTooltipModel(
  52251. [series],
  52252. globalTooltipModel
  52253. ).get('valueFormatter')
  52254. axisSectionMarkup.blocks.push(
  52255. valueFormatter
  52256. ? extend({ valueFormatter: valueFormatter }, frag)
  52257. : frag
  52258. )
  52259. }
  52260. if (seriesTooltipResult.text) {
  52261. markupTextArrLegacy.push(seriesTooltipResult.text)
  52262. }
  52263. cbParamsList.push(cbParams)
  52264. })
  52265. })
  52266. }) // In most cases, the second axis is displays upper on the first one.
  52267. // So we reverse it to look better.
  52268. articleMarkup.blocks.reverse()
  52269. markupTextArrLegacy.reverse()
  52270. var positionExpr = e.position
  52271. var orderMode = singleTooltipModel.get('order')
  52272. var builtMarkupText = buildTooltipMarkup(
  52273. articleMarkup,
  52274. markupStyleCreator,
  52275. renderMode,
  52276. orderMode,
  52277. ecModel.get('useUTC'),
  52278. singleTooltipModel.get('textStyle')
  52279. )
  52280. builtMarkupText && markupTextArrLegacy.unshift(builtMarkupText)
  52281. var blockBreak = renderMode === 'richText' ? '\n\n' : '<br/>'
  52282. var allMarkupText = markupTextArrLegacy.join(blockBreak)
  52283. this._showOrMove(singleTooltipModel, function () {
  52284. if (
  52285. this._updateContentNotChangedOnAxis(
  52286. dataByCoordSys,
  52287. cbParamsList
  52288. )
  52289. ) {
  52290. this._updatePosition(
  52291. singleTooltipModel,
  52292. positionExpr,
  52293. point[0],
  52294. point[1],
  52295. this._tooltipContent,
  52296. cbParamsList
  52297. )
  52298. } else {
  52299. this._showTooltipContent(
  52300. singleTooltipModel,
  52301. allMarkupText,
  52302. cbParamsList,
  52303. Math.random() + '',
  52304. point[0],
  52305. point[1],
  52306. positionExpr,
  52307. null,
  52308. markupStyleCreator
  52309. )
  52310. }
  52311. }) // Do not trigger events here, because this branch only be entered
  52312. // from dispatchAction.
  52313. }
  52314. TooltipView.prototype._showSeriesItemTooltip = function (
  52315. e,
  52316. dispatcher,
  52317. dispatchAction
  52318. ) {
  52319. var ecModel = this._ecModel
  52320. var ecData = getECData(dispatcher) // Use dataModel in element if possible
  52321. // Used when mouseover on a element like markPoint or edge
  52322. // In which case, the data is not main data in series.
  52323. var seriesIndex = ecData.seriesIndex
  52324. var seriesModel = ecModel.getSeriesByIndex(seriesIndex) // For example, graph link.
  52325. var dataModel = ecData.dataModel || seriesModel
  52326. var dataIndex = ecData.dataIndex
  52327. var dataType = ecData.dataType
  52328. var data = dataModel.getData(dataType)
  52329. var renderMode = this._renderMode
  52330. var positionDefault = e.positionDefault
  52331. var tooltipModel = buildTooltipModel(
  52332. [
  52333. data.getItemModel(dataIndex),
  52334. dataModel,
  52335. seriesModel && (seriesModel.coordinateSystem || {}).model
  52336. ],
  52337. this._tooltipModel,
  52338. positionDefault ? { position: positionDefault } : null
  52339. )
  52340. var tooltipTrigger = tooltipModel.get('trigger')
  52341. if (tooltipTrigger != null && tooltipTrigger !== 'item') {
  52342. return
  52343. }
  52344. var params = dataModel.getDataParams(dataIndex, dataType)
  52345. var markupStyleCreator = new TooltipMarkupStyleCreator() // Pre-create marker style for makers. Users can assemble richText
  52346. // text in `formatter` callback and use those markers style.
  52347. params.marker = markupStyleCreator.makeTooltipMarker(
  52348. 'item',
  52349. convertToColorString(params.color),
  52350. renderMode
  52351. )
  52352. var seriesTooltipResult = normalizeTooltipFormatResult(
  52353. dataModel.formatTooltip(dataIndex, false, dataType)
  52354. )
  52355. var orderMode = tooltipModel.get('order')
  52356. var valueFormatter = tooltipModel.get('valueFormatter')
  52357. var frag = seriesTooltipResult.frag
  52358. var markupText = frag
  52359. ? buildTooltipMarkup(
  52360. valueFormatter
  52361. ? extend({ valueFormatter: valueFormatter }, frag)
  52362. : frag,
  52363. markupStyleCreator,
  52364. renderMode,
  52365. orderMode,
  52366. ecModel.get('useUTC'),
  52367. tooltipModel.get('textStyle')
  52368. )
  52369. : seriesTooltipResult.text
  52370. var asyncTicket = 'item_' + dataModel.name + '_' + dataIndex
  52371. this._showOrMove(tooltipModel, function () {
  52372. this._showTooltipContent(
  52373. tooltipModel,
  52374. markupText,
  52375. params,
  52376. asyncTicket,
  52377. e.offsetX,
  52378. e.offsetY,
  52379. e.position,
  52380. e.target,
  52381. markupStyleCreator
  52382. )
  52383. }) // FIXME
  52384. // duplicated showtip if manuallyShowTip is called from dispatchAction.
  52385. dispatchAction({
  52386. type: 'showTip',
  52387. dataIndexInside: dataIndex,
  52388. dataIndex: data.getRawIndex(dataIndex),
  52389. seriesIndex: seriesIndex,
  52390. from: this.uid
  52391. })
  52392. }
  52393. TooltipView.prototype._showComponentItemTooltip = function (
  52394. e,
  52395. el,
  52396. dispatchAction
  52397. ) {
  52398. var ecData = getECData(el)
  52399. var tooltipConfig = ecData.tooltipConfig
  52400. var tooltipOpt = tooltipConfig.option || {}
  52401. if (isString(tooltipOpt)) {
  52402. var content = tooltipOpt
  52403. tooltipOpt = {
  52404. content: content, // Fixed formatter
  52405. formatter: content
  52406. }
  52407. }
  52408. var tooltipModelCascade = [tooltipOpt]
  52409. var cmpt = this._ecModel.getComponent(
  52410. ecData.componentMainType,
  52411. ecData.componentIndex
  52412. )
  52413. if (cmpt) {
  52414. tooltipModelCascade.push(cmpt)
  52415. } // In most cases, component tooltip formatter has different params with series tooltip formatter,
  52416. // so that they can not share the same formatter. Since the global tooltip formatter is used for series
  52417. // by convension, we do not use it as the default formatter for component.
  52418. tooltipModelCascade.push({ formatter: tooltipOpt.content })
  52419. var positionDefault = e.positionDefault
  52420. var subTooltipModel = buildTooltipModel(
  52421. tooltipModelCascade,
  52422. this._tooltipModel,
  52423. positionDefault ? { position: positionDefault } : null
  52424. )
  52425. var defaultHtml = subTooltipModel.get('content')
  52426. var asyncTicket = Math.random() + '' // PENDING: this case do not support richText style yet.
  52427. var markupStyleCreator = new TooltipMarkupStyleCreator() // Do not check whether `trigger` is 'none' here, because `trigger`
  52428. // only works on coordinate system. In fact, we have not found case
  52429. // that requires setting `trigger` nothing on component yet.
  52430. this._showOrMove(subTooltipModel, function () {
  52431. // Use formatterParams from element defined in component
  52432. // Avoid users modify it.
  52433. var formatterParams = clone$3(
  52434. subTooltipModel.get('formatterParams') || {}
  52435. )
  52436. this._showTooltipContent(
  52437. subTooltipModel,
  52438. defaultHtml,
  52439. formatterParams,
  52440. asyncTicket,
  52441. e.offsetX,
  52442. e.offsetY,
  52443. e.position,
  52444. el,
  52445. markupStyleCreator
  52446. )
  52447. }) // If not dispatch showTip, tip may be hide triggered by axis.
  52448. dispatchAction({ type: 'showTip', from: this.uid })
  52449. }
  52450. TooltipView.prototype._showTooltipContent = function (
  52451. // Use Model<TooltipOption> insteadof TooltipModel because this model may be from series or other options.
  52452. // Instead of top level tooltip.
  52453. tooltipModel,
  52454. defaultHtml,
  52455. params,
  52456. asyncTicket,
  52457. x,
  52458. y,
  52459. positionExpr,
  52460. el,
  52461. markupStyleCreator
  52462. ) {
  52463. // Reset ticket
  52464. this._ticket = ''
  52465. if (
  52466. !tooltipModel.get('showContent') ||
  52467. !tooltipModel.get('show')
  52468. ) {
  52469. return
  52470. }
  52471. var tooltipContent = this._tooltipContent
  52472. tooltipContent.setEnterable(tooltipModel.get('enterable'))
  52473. var formatter = tooltipModel.get('formatter')
  52474. positionExpr = positionExpr || tooltipModel.get('position')
  52475. var html = defaultHtml
  52476. var nearPoint = this._getNearestPoint(
  52477. [x, y],
  52478. params,
  52479. tooltipModel.get('trigger'),
  52480. tooltipModel.get('borderColor')
  52481. )
  52482. var nearPointColor = nearPoint.color
  52483. if (formatter) {
  52484. if (isString(formatter)) {
  52485. var useUTC = tooltipModel.ecModel.get('useUTC')
  52486. var params0 = isArray(params) ? params[0] : params
  52487. var isTimeAxis =
  52488. params0 &&
  52489. params0.axisType &&
  52490. params0.axisType.indexOf('time') >= 0
  52491. html = formatter
  52492. if (isTimeAxis) {
  52493. html = format(params0.axisValue, html, useUTC)
  52494. }
  52495. html = formatTpl(html, params, true)
  52496. } else if (isFunction(formatter)) {
  52497. var callback = bind$1(function (cbTicket, html) {
  52498. if (cbTicket === this._ticket) {
  52499. tooltipContent.setContent(
  52500. html,
  52501. markupStyleCreator,
  52502. tooltipModel,
  52503. nearPointColor,
  52504. positionExpr
  52505. )
  52506. this._updatePosition(
  52507. tooltipModel,
  52508. positionExpr,
  52509. x,
  52510. y,
  52511. tooltipContent,
  52512. params,
  52513. el
  52514. )
  52515. }
  52516. }, this)
  52517. this._ticket = asyncTicket
  52518. html = formatter(params, asyncTicket, callback)
  52519. } else {
  52520. html = formatter
  52521. }
  52522. }
  52523. tooltipContent.setContent(
  52524. html,
  52525. markupStyleCreator,
  52526. tooltipModel,
  52527. nearPointColor,
  52528. positionExpr
  52529. )
  52530. tooltipContent.show(tooltipModel, nearPointColor)
  52531. this._updatePosition(
  52532. tooltipModel,
  52533. positionExpr,
  52534. x,
  52535. y,
  52536. tooltipContent,
  52537. params,
  52538. el
  52539. )
  52540. }
  52541. TooltipView.prototype._getNearestPoint = function (
  52542. point,
  52543. tooltipDataParams,
  52544. trigger,
  52545. borderColor
  52546. ) {
  52547. if (trigger === 'axis' || isArray(tooltipDataParams)) {
  52548. return {
  52549. color:
  52550. borderColor ||
  52551. (this._renderMode === 'html' ? '#fff' : 'none')
  52552. }
  52553. }
  52554. if (!isArray(tooltipDataParams)) {
  52555. return {
  52556. color:
  52557. borderColor ||
  52558. tooltipDataParams.color ||
  52559. tooltipDataParams.borderColor
  52560. }
  52561. }
  52562. }
  52563. TooltipView.prototype._updatePosition = function (
  52564. tooltipModel,
  52565. positionExpr,
  52566. x, // Mouse x
  52567. y, // Mouse y
  52568. content,
  52569. params,
  52570. el
  52571. ) {
  52572. var viewWidth = this._api.getWidth()
  52573. var viewHeight = this._api.getHeight()
  52574. positionExpr = positionExpr || tooltipModel.get('position')
  52575. var contentSize = content.getSize()
  52576. var align = tooltipModel.get('align')
  52577. var vAlign = tooltipModel.get('verticalAlign')
  52578. var rect = el && el.getBoundingRect().clone()
  52579. el && rect.applyTransform(el.transform)
  52580. if (isFunction(positionExpr)) {
  52581. // Callback of position can be an array or a string specify the position
  52582. positionExpr = positionExpr([x, y], params, content.el, rect, {
  52583. viewSize: [viewWidth, viewHeight],
  52584. contentSize: contentSize.slice()
  52585. })
  52586. }
  52587. if (isArray(positionExpr)) {
  52588. x = parsePercent(positionExpr[0], viewWidth)
  52589. y = parsePercent(positionExpr[1], viewHeight)
  52590. } else if (isObject$2(positionExpr)) {
  52591. var boxLayoutPosition = positionExpr
  52592. boxLayoutPosition.width = contentSize[0]
  52593. boxLayoutPosition.height = contentSize[1]
  52594. var layoutRect = getLayoutRect(boxLayoutPosition, {
  52595. width: viewWidth,
  52596. height: viewHeight
  52597. })
  52598. x = layoutRect.x
  52599. y = layoutRect.y
  52600. align = null // When positionExpr is left/top/right/bottom,
  52601. // align and verticalAlign will not work.
  52602. vAlign = null
  52603. } // Specify tooltip position by string 'top' 'bottom' 'left' 'right' around graphic element
  52604. else if (isString(positionExpr) && el) {
  52605. var pos = calcTooltipPosition(
  52606. positionExpr,
  52607. rect,
  52608. contentSize,
  52609. tooltipModel.get('borderWidth')
  52610. )
  52611. x = pos[0]
  52612. y = pos[1]
  52613. } else {
  52614. var pos = refixTooltipPosition(
  52615. x,
  52616. y,
  52617. content,
  52618. viewWidth,
  52619. viewHeight,
  52620. align ? null : 20,
  52621. vAlign ? null : 20
  52622. )
  52623. x = pos[0]
  52624. y = pos[1]
  52625. }
  52626. align &&
  52627. (x -= isCenterAlign(align)
  52628. ? contentSize[0] / 2
  52629. : align === 'right'
  52630. ? contentSize[0]
  52631. : 0)
  52632. vAlign &&
  52633. (y -= isCenterAlign(vAlign)
  52634. ? contentSize[1] / 2
  52635. : vAlign === 'bottom'
  52636. ? contentSize[1]
  52637. : 0)
  52638. if (shouldTooltipConfine(tooltipModel)) {
  52639. var pos = confineTooltipPosition(
  52640. x,
  52641. y,
  52642. content,
  52643. viewWidth,
  52644. viewHeight
  52645. )
  52646. x = pos[0]
  52647. y = pos[1]
  52648. }
  52649. content.moveTo(x, y)
  52650. } // FIXME
  52651. // Should we remove this but leave this to user?
  52652. TooltipView.prototype._updateContentNotChangedOnAxis = function (
  52653. dataByCoordSys,
  52654. cbParamsList
  52655. ) {
  52656. var lastCoordSys = this._lastDataByCoordSys
  52657. var lastCbParamsList = this._cbParamsList
  52658. var contentNotChanged =
  52659. !!lastCoordSys && lastCoordSys.length === dataByCoordSys.length
  52660. contentNotChanged &&
  52661. each$7(
  52662. lastCoordSys,
  52663. function (lastItemCoordSys, indexCoordSys) {
  52664. var lastDataByAxis = lastItemCoordSys.dataByAxis || []
  52665. var thisItemCoordSys = dataByCoordSys[indexCoordSys] || {}
  52666. var thisDataByAxis = thisItemCoordSys.dataByAxis || []
  52667. contentNotChanged =
  52668. contentNotChanged &&
  52669. lastDataByAxis.length === thisDataByAxis.length
  52670. contentNotChanged &&
  52671. each$7(lastDataByAxis, function (lastItem, indexAxis) {
  52672. var thisItem = thisDataByAxis[indexAxis] || {}
  52673. var lastIndices = lastItem.seriesDataIndices || []
  52674. var newIndices = thisItem.seriesDataIndices || []
  52675. contentNotChanged =
  52676. contentNotChanged &&
  52677. lastItem.value === thisItem.value &&
  52678. lastItem.axisType === thisItem.axisType &&
  52679. lastItem.axisId === thisItem.axisId &&
  52680. lastIndices.length === newIndices.length
  52681. contentNotChanged &&
  52682. each$7(lastIndices, function (lastIdxItem, j) {
  52683. var newIdxItem = newIndices[j]
  52684. contentNotChanged =
  52685. contentNotChanged &&
  52686. lastIdxItem.seriesIndex ===
  52687. newIdxItem.seriesIndex &&
  52688. lastIdxItem.dataIndex === newIdxItem.dataIndex
  52689. }) // check is cbParams data value changed
  52690. lastCbParamsList &&
  52691. each$7(
  52692. lastItem.seriesDataIndices,
  52693. function (idxItem) {
  52694. var seriesIdx = idxItem.seriesIndex
  52695. var cbParams = cbParamsList[seriesIdx]
  52696. var lastCbParams = lastCbParamsList[seriesIdx]
  52697. if (
  52698. cbParams &&
  52699. lastCbParams &&
  52700. lastCbParams.data !== cbParams.data
  52701. ) {
  52702. contentNotChanged = false
  52703. }
  52704. }
  52705. )
  52706. })
  52707. }
  52708. )
  52709. this._lastDataByCoordSys = dataByCoordSys
  52710. this._cbParamsList = cbParamsList
  52711. return !!contentNotChanged
  52712. }
  52713. TooltipView.prototype._hide = function (dispatchAction) {
  52714. // Do not directly hideLater here, because this behavior may be prevented
  52715. // in dispatchAction when showTip is dispatched.
  52716. // FIXME
  52717. // duplicated hideTip if manuallyHideTip is called from dispatchAction.
  52718. this._lastDataByCoordSys = null
  52719. dispatchAction({ type: 'hideTip', from: this.uid })
  52720. }
  52721. TooltipView.prototype.dispose = function (ecModel, api) {
  52722. if (env$1.node || !api.getDom()) {
  52723. return
  52724. }
  52725. clear$1(this, '_updatePosition')
  52726. this._tooltipContent.dispose()
  52727. unregister('itemTooltip', api)
  52728. }
  52729. TooltipView.type = 'tooltip'
  52730. return TooltipView
  52731. })(ComponentView$1)
  52732. /**
  52733. * From top to bottom. (the last one should be globalTooltipModel);
  52734. */ function buildTooltipModel(
  52735. modelCascade,
  52736. globalTooltipModel,
  52737. defaultTooltipOption
  52738. ) {
  52739. // Last is always tooltip model.
  52740. var ecModel = globalTooltipModel.ecModel
  52741. var resultModel
  52742. if (defaultTooltipOption) {
  52743. resultModel = new Model$1(defaultTooltipOption, ecModel, ecModel)
  52744. resultModel = new Model$1(
  52745. globalTooltipModel.option,
  52746. resultModel,
  52747. ecModel
  52748. )
  52749. } else {
  52750. resultModel = globalTooltipModel
  52751. }
  52752. for (var i = modelCascade.length - 1; i >= 0; i--) {
  52753. var tooltipOpt = modelCascade[i]
  52754. if (tooltipOpt) {
  52755. if (tooltipOpt instanceof Model$1) {
  52756. tooltipOpt = tooltipOpt.get('tooltip', true)
  52757. } // In each data item tooltip can be simply write:
  52758. // {
  52759. // value: 10,
  52760. // tooltip: 'Something you need to know'
  52761. // }
  52762. if (isString(tooltipOpt)) {
  52763. tooltipOpt = { formatter: tooltipOpt }
  52764. }
  52765. if (tooltipOpt) {
  52766. resultModel = new Model$1(tooltipOpt, resultModel, ecModel)
  52767. }
  52768. }
  52769. }
  52770. return resultModel
  52771. }
  52772. function makeDispatchAction(payload, api) {
  52773. return payload.dispatchAction || bind$1(api.dispatchAction, api)
  52774. }
  52775. function refixTooltipPosition(
  52776. x,
  52777. y,
  52778. content,
  52779. viewWidth,
  52780. viewHeight,
  52781. gapH,
  52782. gapV
  52783. ) {
  52784. var size = content.getSize()
  52785. var width = size[0]
  52786. var height = size[1]
  52787. if (gapH != null) {
  52788. // Add extra 2 pixels for this case:
  52789. // At present the "values" in defaut tooltip are using CSS `float: right`.
  52790. // When the right edge of the tooltip box is on the right side of the
  52791. // viewport, the `float` layout might push the "values" to the second line.
  52792. if (x + width + gapH + 2 > viewWidth) {
  52793. x -= width + gapH
  52794. } else {
  52795. x += gapH
  52796. }
  52797. }
  52798. if (gapV != null) {
  52799. if (y + height + gapV > viewHeight) {
  52800. y -= height + gapV
  52801. } else {
  52802. y += gapV
  52803. }
  52804. }
  52805. return [x, y]
  52806. }
  52807. function confineTooltipPosition(
  52808. x,
  52809. y,
  52810. content,
  52811. viewWidth,
  52812. viewHeight
  52813. ) {
  52814. var size = content.getSize()
  52815. var width = size[0]
  52816. var height = size[1]
  52817. x = Math.min(x + width, viewWidth) - width
  52818. y = Math.min(y + height, viewHeight) - height
  52819. x = Math.max(x, 0)
  52820. y = Math.max(y, 0)
  52821. return [x, y]
  52822. }
  52823. function calcTooltipPosition(
  52824. position,
  52825. rect,
  52826. contentSize,
  52827. borderWidth
  52828. ) {
  52829. var domWidth = contentSize[0]
  52830. var domHeight = contentSize[1]
  52831. var offset = Math.ceil(Math.SQRT2 * borderWidth) + 8
  52832. var x = 0
  52833. var y = 0
  52834. var rectWidth = rect.width
  52835. var rectHeight = rect.height
  52836. switch (position) {
  52837. case 'inside':
  52838. x = rect.x + rectWidth / 2 - domWidth / 2
  52839. y = rect.y + rectHeight / 2 - domHeight / 2
  52840. break
  52841. case 'top':
  52842. x = rect.x + rectWidth / 2 - domWidth / 2
  52843. y = rect.y - domHeight - offset
  52844. break
  52845. case 'bottom':
  52846. x = rect.x + rectWidth / 2 - domWidth / 2
  52847. y = rect.y + rectHeight + offset
  52848. break
  52849. case 'left':
  52850. x = rect.x - domWidth - offset
  52851. y = rect.y + rectHeight / 2 - domHeight / 2
  52852. break
  52853. case 'right':
  52854. x = rect.x + rectWidth + offset
  52855. y = rect.y + rectHeight / 2 - domHeight / 2
  52856. }
  52857. return [x, y]
  52858. }
  52859. function isCenterAlign(align) {
  52860. return align === 'center' || align === 'middle'
  52861. }
  52862. /**
  52863. * Find target component by payload like:
  52864. * ```js
  52865. * { legendId: 'some_id', name: 'xxx' }
  52866. * { toolboxIndex: 1, name: 'xxx' }
  52867. * { geoName: 'some_name', name: 'xxx' }
  52868. * ```
  52869. * PENDING: at present only
  52870. *
  52871. * If not found, return null/undefined.
  52872. */ function findComponentReference(payload, ecModel, api) {
  52873. var queryOptionMap = preParseFinder(payload).queryOptionMap
  52874. var componentMainType = queryOptionMap.keys()[0]
  52875. if (!componentMainType || componentMainType === 'series') {
  52876. return
  52877. }
  52878. var queryResult = queryReferringComponents(
  52879. ecModel,
  52880. componentMainType,
  52881. queryOptionMap.get(componentMainType),
  52882. { useDefault: false, enableAll: false, enableNone: false }
  52883. )
  52884. var model = queryResult.models[0]
  52885. if (!model) {
  52886. return
  52887. }
  52888. var view = api.getViewOfComponentModel(model)
  52889. var el
  52890. view.group.traverse(function (subEl) {
  52891. var tooltipConfig = getECData(subEl).tooltipConfig
  52892. if (tooltipConfig && tooltipConfig.name === payload.name) {
  52893. el = subEl
  52894. return true // stop
  52895. }
  52896. })
  52897. if (el) {
  52898. return {
  52899. componentMainType: componentMainType,
  52900. componentIndex: model.componentIndex,
  52901. el: el
  52902. }
  52903. }
  52904. }
  52905. var TooltipView$1 = TooltipView
  52906. function install$a(registers) {
  52907. use(install$e)
  52908. registers.registerComponentModel(TooltipModel$1)
  52909. registers.registerComponentView(TooltipView$1)
  52910. /**
  52911. * @action
  52912. * @property {string} type
  52913. * @property {number} seriesIndex
  52914. * @property {number} dataIndex
  52915. * @property {number} [x]
  52916. * @property {number} [y]
  52917. */ registers.registerAction(
  52918. {
  52919. type: 'showTip',
  52920. event: 'showTip',
  52921. update: 'tooltip:manuallyShowTip'
  52922. },
  52923. noop
  52924. )
  52925. registers.registerAction(
  52926. {
  52927. type: 'hideTip',
  52928. event: 'hideTip',
  52929. update: 'tooltip:manuallyHideTip'
  52930. },
  52931. noop
  52932. )
  52933. }
  52934. var TitleModel = /** @class */ (function (_super) {
  52935. __extends(TitleModel, _super)
  52936. function TitleModel() {
  52937. var _this =
  52938. (_super !== null && _super.apply(this, arguments)) || this
  52939. _this.type = TitleModel.type
  52940. _this.layoutMode = { type: 'box', ignoreSize: true }
  52941. return _this
  52942. }
  52943. TitleModel.type = 'title'
  52944. TitleModel.defaultOption = {
  52945. // zlevel: 0,
  52946. z: 6,
  52947. show: true,
  52948. text: '',
  52949. target: 'blank',
  52950. subtext: '',
  52951. subtarget: 'blank',
  52952. left: 0,
  52953. top: 0,
  52954. backgroundColor: 'rgba(0,0,0,0)',
  52955. borderColor: '#ccc',
  52956. borderWidth: 0,
  52957. padding: 5,
  52958. itemGap: 10,
  52959. textStyle: { fontSize: 18, fontWeight: 'bold', color: '#464646' },
  52960. subtextStyle: { fontSize: 12, color: '#6E7079' }
  52961. }
  52962. return TitleModel
  52963. })(ComponentModel$1) // View
  52964. var TitleView = /** @class */ (function (_super) {
  52965. __extends(TitleView, _super)
  52966. function TitleView() {
  52967. var _this =
  52968. (_super !== null && _super.apply(this, arguments)) || this
  52969. _this.type = TitleView.type
  52970. return _this
  52971. }
  52972. TitleView.prototype.render = function (titleModel, ecModel, api) {
  52973. this.group.removeAll()
  52974. if (!titleModel.get('show')) {
  52975. return
  52976. }
  52977. var group = this.group
  52978. var textStyleModel = titleModel.getModel('textStyle')
  52979. var subtextStyleModel = titleModel.getModel('subtextStyle')
  52980. var textAlign = titleModel.get('textAlign')
  52981. var textVerticalAlign = retrieve2(
  52982. titleModel.get('textBaseline'),
  52983. titleModel.get('textVerticalAlign')
  52984. )
  52985. var textEl = new ZRText$1({
  52986. style: createTextStyle(
  52987. textStyleModel,
  52988. {
  52989. text: titleModel.get('text'),
  52990. fill: textStyleModel.getTextColor()
  52991. },
  52992. { disableBox: true }
  52993. ),
  52994. z2: 10
  52995. })
  52996. var textRect = textEl.getBoundingRect()
  52997. var subText = titleModel.get('subtext')
  52998. var subTextEl = new ZRText$1({
  52999. style: createTextStyle(
  53000. subtextStyleModel,
  53001. {
  53002. text: subText,
  53003. fill: subtextStyleModel.getTextColor(),
  53004. y: textRect.height + titleModel.get('itemGap'),
  53005. verticalAlign: 'top'
  53006. },
  53007. { disableBox: true }
  53008. ),
  53009. z2: 10
  53010. })
  53011. var link = titleModel.get('link')
  53012. var sublink = titleModel.get('sublink')
  53013. var triggerEvent = titleModel.get('triggerEvent', true)
  53014. textEl.silent = !link && !triggerEvent
  53015. subTextEl.silent = !sublink && !triggerEvent
  53016. if (link) {
  53017. textEl.on('click', function () {
  53018. windowOpen(link, '_' + titleModel.get('target'))
  53019. })
  53020. }
  53021. if (sublink) {
  53022. subTextEl.on('click', function () {
  53023. windowOpen(sublink, '_' + titleModel.get('subtarget'))
  53024. })
  53025. }
  53026. getECData(textEl).eventData = getECData(subTextEl).eventData =
  53027. triggerEvent
  53028. ? {
  53029. componentType: 'title',
  53030. componentIndex: titleModel.componentIndex
  53031. }
  53032. : null
  53033. group.add(textEl)
  53034. subText && group.add(subTextEl) // If no subText, but add subTextEl, there will be an empty line.
  53035. var groupRect = group.getBoundingRect()
  53036. var layoutOption = titleModel.getBoxLayoutParams()
  53037. layoutOption.width = groupRect.width
  53038. layoutOption.height = groupRect.height
  53039. var layoutRect = getLayoutRect(
  53040. layoutOption,
  53041. { width: api.getWidth(), height: api.getHeight() },
  53042. titleModel.get('padding')
  53043. ) // Adjust text align based on position
  53044. if (!textAlign) {
  53045. // Align left if title is on the left. center and right is same
  53046. textAlign = titleModel.get('left') || titleModel.get('right') // @ts-ignore
  53047. if (textAlign === 'middle') {
  53048. textAlign = 'center'
  53049. } // Adjust layout by text align
  53050. if (textAlign === 'right') {
  53051. layoutRect.x += layoutRect.width
  53052. } else if (textAlign === 'center') {
  53053. layoutRect.x += layoutRect.width / 2
  53054. }
  53055. }
  53056. if (!textVerticalAlign) {
  53057. textVerticalAlign =
  53058. titleModel.get('top') || titleModel.get('bottom') // @ts-ignore
  53059. if (textVerticalAlign === 'center') {
  53060. textVerticalAlign = 'middle'
  53061. }
  53062. if (textVerticalAlign === 'bottom') {
  53063. layoutRect.y += layoutRect.height
  53064. } else if (textVerticalAlign === 'middle') {
  53065. layoutRect.y += layoutRect.height / 2
  53066. }
  53067. textVerticalAlign = textVerticalAlign || 'top'
  53068. }
  53069. group.x = layoutRect.x
  53070. group.y = layoutRect.y
  53071. group.markRedraw()
  53072. var alignStyle = {
  53073. align: textAlign,
  53074. verticalAlign: textVerticalAlign
  53075. }
  53076. textEl.setStyle(alignStyle)
  53077. subTextEl.setStyle(alignStyle) // Render background
  53078. // Get groupRect again because textAlign has been changed
  53079. groupRect = group.getBoundingRect()
  53080. var padding = layoutRect.margin
  53081. var style = titleModel.getItemStyle(['color', 'opacity'])
  53082. style.fill = titleModel.get('backgroundColor')
  53083. var rect = new Rect$2({
  53084. shape: {
  53085. x: groupRect.x - padding[3],
  53086. y: groupRect.y - padding[0],
  53087. width: groupRect.width + padding[1] + padding[3],
  53088. height: groupRect.height + padding[0] + padding[2],
  53089. r: titleModel.get('borderRadius')
  53090. },
  53091. style: style,
  53092. subPixelOptimize: true,
  53093. silent: true
  53094. })
  53095. group.add(rect)
  53096. }
  53097. TitleView.type = 'title'
  53098. return TitleView
  53099. })(ComponentView$1)
  53100. function install$9(registers) {
  53101. registers.registerComponentModel(TitleModel)
  53102. registers.registerComponentView(TitleView)
  53103. }
  53104. var getDefaultSelectorOptions = function getDefaultSelectorOptions(
  53105. ecModel,
  53106. type
  53107. ) {
  53108. if (type === 'all') {
  53109. return {
  53110. type: 'all',
  53111. title: ecModel
  53112. .getLocaleModel()
  53113. .get(['legend', 'selector', 'all'])
  53114. }
  53115. } else if (type === 'inverse') {
  53116. return {
  53117. type: 'inverse',
  53118. title: ecModel
  53119. .getLocaleModel()
  53120. .get(['legend', 'selector', 'inverse'])
  53121. }
  53122. }
  53123. }
  53124. var LegendModel = /** @class */ (function (_super) {
  53125. __extends(LegendModel, _super)
  53126. function LegendModel() {
  53127. var _this =
  53128. (_super !== null && _super.apply(this, arguments)) || this
  53129. _this.type = LegendModel.type
  53130. _this.layoutMode = {
  53131. type: 'box', // legend.width/height are maxWidth/maxHeight actually,
  53132. // whereas realy width/height is calculated by its content.
  53133. // (Setting {left: 10, right: 10} does not make sense).
  53134. // So consider the case:
  53135. // `setOption({legend: {left: 10});`
  53136. // then `setOption({legend: {right: 10});`
  53137. // The previous `left` should be cleared by setting `ignoreSize`.
  53138. ignoreSize: true
  53139. }
  53140. return _this
  53141. }
  53142. LegendModel.prototype.init = function (
  53143. option,
  53144. parentModel,
  53145. ecModel
  53146. ) {
  53147. this.mergeDefaultAndTheme(option, ecModel)
  53148. option.selected = option.selected || {}
  53149. this._updateSelector(option)
  53150. }
  53151. LegendModel.prototype.mergeOption = function (option, ecModel) {
  53152. _super.prototype.mergeOption.call(this, option, ecModel)
  53153. this._updateSelector(option)
  53154. }
  53155. LegendModel.prototype._updateSelector = function (option) {
  53156. var selector = option.selector
  53157. var ecModel = this.ecModel
  53158. if (selector === true) {
  53159. selector = option.selector = ['all', 'inverse']
  53160. }
  53161. if (isArray(selector)) {
  53162. each$7(selector, function (item, index) {
  53163. isString(item) && (item = { type: item })
  53164. selector[index] = merge(
  53165. item,
  53166. getDefaultSelectorOptions(ecModel, item.type)
  53167. )
  53168. })
  53169. }
  53170. }
  53171. LegendModel.prototype.optionUpdated = function () {
  53172. this._updateData(this.ecModel)
  53173. var legendData = this._data // If selectedMode is single, try to select one
  53174. if (legendData[0] && this.get('selectedMode') === 'single') {
  53175. var hasSelected = false // If has any selected in option.selected
  53176. for (var i = 0; i < legendData.length; i++) {
  53177. var name_1 = legendData[i].get('name')
  53178. if (this.isSelected(name_1)) {
  53179. // Force to unselect others
  53180. this.select(name_1)
  53181. hasSelected = true
  53182. break
  53183. }
  53184. } // Try select the first if selectedMode is single
  53185. !hasSelected && this.select(legendData[0].get('name'))
  53186. }
  53187. }
  53188. LegendModel.prototype._updateData = function (ecModel) {
  53189. var potentialData = []
  53190. var availableNames = []
  53191. ecModel.eachRawSeries(function (seriesModel) {
  53192. var seriesName = seriesModel.name
  53193. availableNames.push(seriesName)
  53194. var isPotential
  53195. if (seriesModel.legendVisualProvider) {
  53196. var provider = seriesModel.legendVisualProvider
  53197. var names = provider.getAllNames()
  53198. if (!ecModel.isSeriesFiltered(seriesModel)) {
  53199. availableNames = availableNames.concat(names)
  53200. }
  53201. if (names.length) {
  53202. potentialData = potentialData.concat(names)
  53203. } else {
  53204. isPotential = true
  53205. }
  53206. } else {
  53207. isPotential = true
  53208. }
  53209. if (isPotential && isNameSpecified(seriesModel)) {
  53210. potentialData.push(seriesModel.name)
  53211. }
  53212. })
  53213. /**
  53214. * @type {Array.<string>}
  53215. * @private
  53216. */ this._availableNames = availableNames // If legend.data not specified in option, use availableNames as data,
  53217. // which is convinient for user preparing option.
  53218. var rawData = this.get('data') || potentialData
  53219. var legendData = map$1(
  53220. rawData,
  53221. function (dataItem) {
  53222. // Can be string or number
  53223. if (isString(dataItem) || isNumber(dataItem)) {
  53224. dataItem = { name: dataItem }
  53225. }
  53226. return new Model$1(dataItem, this, this.ecModel)
  53227. },
  53228. this
  53229. )
  53230. /**
  53231. * @type {Array.<module:echarts/model/Model>}
  53232. * @private
  53233. */ this._data = legendData
  53234. }
  53235. LegendModel.prototype.getData = function () {
  53236. return this._data
  53237. }
  53238. LegendModel.prototype.select = function (name) {
  53239. var selected = this.option.selected
  53240. var selectedMode = this.get('selectedMode')
  53241. if (selectedMode === 'single') {
  53242. var data = this._data
  53243. each$7(data, function (dataItem) {
  53244. selected[dataItem.get('name')] = false
  53245. })
  53246. }
  53247. selected[name] = true
  53248. }
  53249. LegendModel.prototype.unSelect = function (name) {
  53250. if (this.get('selectedMode') !== 'single') {
  53251. this.option.selected[name] = false
  53252. }
  53253. }
  53254. LegendModel.prototype.toggleSelected = function (name) {
  53255. var selected = this.option.selected // Default is true
  53256. if (!selected.hasOwnProperty(name)) {
  53257. selected[name] = true
  53258. }
  53259. this[selected[name] ? 'unSelect' : 'select'](name)
  53260. }
  53261. LegendModel.prototype.allSelect = function () {
  53262. var data = this._data
  53263. var selected = this.option.selected
  53264. each$7(data, function (dataItem) {
  53265. selected[dataItem.get('name', true)] = true
  53266. })
  53267. }
  53268. LegendModel.prototype.inverseSelect = function () {
  53269. var data = this._data
  53270. var selected = this.option.selected
  53271. each$7(data, function (dataItem) {
  53272. var name = dataItem.get('name', true) // Initially, default value is true
  53273. if (!selected.hasOwnProperty(name)) {
  53274. selected[name] = true
  53275. }
  53276. selected[name] = !selected[name]
  53277. })
  53278. }
  53279. LegendModel.prototype.isSelected = function (name) {
  53280. var selected = this.option.selected
  53281. return (
  53282. !(selected.hasOwnProperty(name) && !selected[name]) &&
  53283. indexOf(this._availableNames, name) >= 0
  53284. )
  53285. }
  53286. LegendModel.prototype.getOrient = function () {
  53287. return this.get('orient') === 'vertical'
  53288. ? { index: 1, name: 'vertical' }
  53289. : { index: 0, name: 'horizontal' }
  53290. }
  53291. LegendModel.type = 'legend.plain'
  53292. LegendModel.dependencies = ['series']
  53293. LegendModel.defaultOption = {
  53294. // zlevel: 0,
  53295. z: 4,
  53296. show: true,
  53297. orient: 'horizontal',
  53298. left: 'center', // right: 'center',
  53299. top: 0, // bottom: null,
  53300. align: 'auto',
  53301. backgroundColor: 'rgba(0,0,0,0)',
  53302. borderColor: '#ccc',
  53303. borderRadius: 0,
  53304. borderWidth: 0,
  53305. padding: 5,
  53306. itemGap: 10,
  53307. itemWidth: 25,
  53308. itemHeight: 14,
  53309. symbolRotate: 'inherit',
  53310. symbolKeepAspect: true,
  53311. inactiveColor: '#ccc',
  53312. inactiveBorderColor: '#ccc',
  53313. inactiveBorderWidth: 'auto',
  53314. itemStyle: {
  53315. color: 'inherit',
  53316. opacity: 'inherit',
  53317. borderColor: 'inherit',
  53318. borderWidth: 'auto',
  53319. borderCap: 'inherit',
  53320. borderJoin: 'inherit',
  53321. borderDashOffset: 'inherit',
  53322. borderMiterLimit: 'inherit'
  53323. },
  53324. lineStyle: {
  53325. width: 'auto',
  53326. color: 'inherit',
  53327. inactiveColor: '#ccc',
  53328. inactiveWidth: 2,
  53329. opacity: 'inherit',
  53330. type: 'inherit',
  53331. cap: 'inherit',
  53332. join: 'inherit',
  53333. dashOffset: 'inherit',
  53334. miterLimit: 'inherit'
  53335. },
  53336. textStyle: { color: '#333' },
  53337. selectedMode: true,
  53338. selector: false,
  53339. selectorLabel: {
  53340. show: true,
  53341. borderRadius: 10,
  53342. padding: [3, 5, 3, 5],
  53343. fontSize: 12,
  53344. fontFamily: 'sans-serif',
  53345. color: '#666',
  53346. borderWidth: 1,
  53347. borderColor: '#666'
  53348. },
  53349. emphasis: {
  53350. selectorLabel: {
  53351. show: true,
  53352. color: '#eee',
  53353. backgroundColor: '#666'
  53354. }
  53355. },
  53356. selectorPosition: 'auto',
  53357. selectorItemGap: 7,
  53358. selectorButtonGap: 10,
  53359. tooltip: { show: false }
  53360. }
  53361. return LegendModel
  53362. })(ComponentModel$1)
  53363. var LegendModel$1 = LegendModel
  53364. var curry = curry$1
  53365. var each = each$7
  53366. var Group$1 = Group$3
  53367. var LegendView = /** @class */ (function (_super) {
  53368. __extends(LegendView, _super)
  53369. function LegendView() {
  53370. var _this =
  53371. (_super !== null && _super.apply(this, arguments)) || this
  53372. _this.type = LegendView.type
  53373. _this.newlineDisabled = false
  53374. return _this
  53375. }
  53376. LegendView.prototype.init = function () {
  53377. this.group.add((this._contentGroup = new Group$1()))
  53378. this.group.add((this._selectorGroup = new Group$1()))
  53379. this._isFirstRender = true
  53380. }
  53381. /**
  53382. * @protected
  53383. */ LegendView.prototype.getContentGroup = function () {
  53384. return this._contentGroup
  53385. }
  53386. /**
  53387. * @protected
  53388. */ LegendView.prototype.getSelectorGroup = function () {
  53389. return this._selectorGroup
  53390. }
  53391. /**
  53392. * @override
  53393. */ LegendView.prototype.render = function (
  53394. legendModel,
  53395. ecModel,
  53396. api
  53397. ) {
  53398. var isFirstRender = this._isFirstRender
  53399. this._isFirstRender = false
  53400. this.resetInner()
  53401. if (!legendModel.get('show', true)) {
  53402. return
  53403. }
  53404. var itemAlign = legendModel.get('align')
  53405. var orient = legendModel.get('orient')
  53406. if (!itemAlign || itemAlign === 'auto') {
  53407. itemAlign =
  53408. legendModel.get('left') === 'right' && orient === 'vertical'
  53409. ? 'right'
  53410. : 'left'
  53411. } // selector has been normalized to an array in model
  53412. var selector = legendModel.get('selector', true)
  53413. var selectorPosition = legendModel.get('selectorPosition', true)
  53414. if (
  53415. selector &&
  53416. (!selectorPosition || selectorPosition === 'auto')
  53417. ) {
  53418. selectorPosition = orient === 'horizontal' ? 'end' : 'start'
  53419. }
  53420. this.renderInner(
  53421. itemAlign,
  53422. legendModel,
  53423. ecModel,
  53424. api,
  53425. selector,
  53426. orient,
  53427. selectorPosition
  53428. ) // Perform layout.
  53429. var positionInfo = legendModel.getBoxLayoutParams()
  53430. var viewportSize = {
  53431. width: api.getWidth(),
  53432. height: api.getHeight()
  53433. }
  53434. var padding = legendModel.get('padding')
  53435. var maxSize = getLayoutRect(positionInfo, viewportSize, padding)
  53436. var mainRect = this.layoutInner(
  53437. legendModel,
  53438. itemAlign,
  53439. maxSize,
  53440. isFirstRender,
  53441. selector,
  53442. selectorPosition
  53443. ) // Place mainGroup, based on the calculated `mainRect`.
  53444. var layoutRect = getLayoutRect(
  53445. defaults(
  53446. { width: mainRect.width, height: mainRect.height },
  53447. positionInfo
  53448. ),
  53449. viewportSize,
  53450. padding
  53451. )
  53452. this.group.x = layoutRect.x - mainRect.x
  53453. this.group.y = layoutRect.y - mainRect.y
  53454. this.group.markRedraw() // Render background after group is layout.
  53455. this.group.add(
  53456. (this._backgroundEl = makeBackground(mainRect, legendModel))
  53457. )
  53458. }
  53459. LegendView.prototype.resetInner = function () {
  53460. this.getContentGroup().removeAll()
  53461. this._backgroundEl && this.group.remove(this._backgroundEl)
  53462. this.getSelectorGroup().removeAll()
  53463. }
  53464. LegendView.prototype.renderInner = function (
  53465. itemAlign,
  53466. legendModel,
  53467. ecModel,
  53468. api,
  53469. selector,
  53470. orient,
  53471. selectorPosition
  53472. ) {
  53473. var contentGroup = this.getContentGroup()
  53474. var legendDrawnMap = createHashMap()
  53475. var selectMode = legendModel.get('selectedMode')
  53476. var excludeSeriesId = []
  53477. ecModel.eachRawSeries(function (seriesModel) {
  53478. !seriesModel.get('legendHoverLink') &&
  53479. excludeSeriesId.push(seriesModel.id)
  53480. })
  53481. each(
  53482. legendModel.getData(),
  53483. function (legendItemModel, dataIndex) {
  53484. var name = legendItemModel.get('name') // Use empty string or \n as a newline string
  53485. if (!this.newlineDisabled && (name === '' || name === '\n')) {
  53486. var g = new Group$1() // @ts-ignore
  53487. g.newline = true
  53488. contentGroup.add(g)
  53489. return
  53490. } // Representitive series.
  53491. var seriesModel = ecModel.getSeriesByName(name)[0]
  53492. if (legendDrawnMap.get(name)) {
  53493. // Have been drawed
  53494. return
  53495. } // Legend to control series.
  53496. if (seriesModel) {
  53497. var data = seriesModel.getData()
  53498. var lineVisualStyle =
  53499. data.getVisual('legendLineStyle') || {}
  53500. var legendIcon = data.getVisual('legendIcon')
  53501. /**
  53502. * `data.getVisual('style')` may be the color from the register
  53503. * in series. For example, for line series,
  53504. */ var style = data.getVisual('style')
  53505. var itemGroup = this._createItem(
  53506. seriesModel,
  53507. name,
  53508. dataIndex,
  53509. legendItemModel,
  53510. legendModel,
  53511. itemAlign,
  53512. lineVisualStyle,
  53513. style,
  53514. legendIcon,
  53515. selectMode,
  53516. api
  53517. )
  53518. itemGroup
  53519. .on(
  53520. 'click',
  53521. curry(
  53522. dispatchSelectAction,
  53523. name,
  53524. null,
  53525. api,
  53526. excludeSeriesId
  53527. )
  53528. )
  53529. .on(
  53530. 'mouseover',
  53531. curry(
  53532. dispatchHighlightAction,
  53533. seriesModel.name,
  53534. null,
  53535. api,
  53536. excludeSeriesId
  53537. )
  53538. )
  53539. .on(
  53540. 'mouseout',
  53541. curry(
  53542. dispatchDownplayAction,
  53543. seriesModel.name,
  53544. null,
  53545. api,
  53546. excludeSeriesId
  53547. )
  53548. )
  53549. legendDrawnMap.set(name, true)
  53550. } else {
  53551. // Legend to control data. In pie and funnel.
  53552. ecModel.eachRawSeries(function (seriesModel) {
  53553. // In case multiple series has same data name
  53554. if (legendDrawnMap.get(name)) {
  53555. return
  53556. }
  53557. if (seriesModel.legendVisualProvider) {
  53558. var provider = seriesModel.legendVisualProvider
  53559. if (!provider.containName(name)) {
  53560. return
  53561. }
  53562. var idx = provider.indexOfName(name)
  53563. var style = provider.getItemVisual(idx, 'style')
  53564. var legendIcon = provider.getItemVisual(
  53565. idx,
  53566. 'legendIcon'
  53567. )
  53568. var colorArr = parse(style.fill) // Color may be set to transparent in visualMap when data is out of range.
  53569. // Do not show nothing.
  53570. if (colorArr && colorArr[3] === 0) {
  53571. colorArr[3] = 0.2 // TODO color is set to 0, 0, 0, 0. Should show correct RGBA
  53572. style = extend(extend({}, style), {
  53573. fill: stringify(colorArr, 'rgba')
  53574. })
  53575. }
  53576. var itemGroup = this._createItem(
  53577. seriesModel,
  53578. name,
  53579. dataIndex,
  53580. legendItemModel,
  53581. legendModel,
  53582. itemAlign,
  53583. {},
  53584. style,
  53585. legendIcon,
  53586. selectMode,
  53587. api
  53588. ) // FIXME: consider different series has items with the same name.
  53589. itemGroup
  53590. .on(
  53591. 'click',
  53592. curry(
  53593. dispatchSelectAction,
  53594. null,
  53595. name,
  53596. api,
  53597. excludeSeriesId
  53598. )
  53599. ) // Should not specify the series name, consider legend controls
  53600. // more than one pie series.
  53601. .on(
  53602. 'mouseover',
  53603. curry(
  53604. dispatchHighlightAction,
  53605. null,
  53606. name,
  53607. api,
  53608. excludeSeriesId
  53609. )
  53610. )
  53611. .on(
  53612. 'mouseout',
  53613. curry(
  53614. dispatchDownplayAction,
  53615. null,
  53616. name,
  53617. api,
  53618. excludeSeriesId
  53619. )
  53620. )
  53621. legendDrawnMap.set(name, true)
  53622. }
  53623. }, this)
  53624. }
  53625. },
  53626. this
  53627. )
  53628. if (selector) {
  53629. this._createSelector(
  53630. selector,
  53631. legendModel,
  53632. api,
  53633. orient,
  53634. selectorPosition
  53635. )
  53636. }
  53637. }
  53638. LegendView.prototype._createSelector = function (
  53639. selector,
  53640. legendModel,
  53641. api,
  53642. orient,
  53643. selectorPosition
  53644. ) {
  53645. var selectorGroup = this.getSelectorGroup()
  53646. each(selector, function createSelectorButton(selectorItem) {
  53647. var type = selectorItem.type
  53648. var labelText = new ZRText$1({
  53649. style: {
  53650. x: 0,
  53651. y: 0,
  53652. align: 'center',
  53653. verticalAlign: 'middle'
  53654. },
  53655. onclick: function onclick() {
  53656. api.dispatchAction({
  53657. type:
  53658. type === 'all'
  53659. ? 'legendAllSelect'
  53660. : 'legendInverseSelect'
  53661. })
  53662. }
  53663. })
  53664. selectorGroup.add(labelText)
  53665. var labelModel = legendModel.getModel('selectorLabel')
  53666. var emphasisLabelModel = legendModel.getModel([
  53667. 'emphasis',
  53668. 'selectorLabel'
  53669. ])
  53670. setLabelStyle(
  53671. labelText,
  53672. { normal: labelModel, emphasis: emphasisLabelModel },
  53673. { defaultText: selectorItem.title }
  53674. )
  53675. enableHoverEmphasis(labelText)
  53676. })
  53677. }
  53678. LegendView.prototype._createItem = function (
  53679. seriesModel,
  53680. name,
  53681. dataIndex,
  53682. legendItemModel,
  53683. legendModel,
  53684. itemAlign,
  53685. lineVisualStyle,
  53686. itemVisualStyle,
  53687. legendIcon,
  53688. selectMode,
  53689. api
  53690. ) {
  53691. var drawType = seriesModel.visualDrawType
  53692. var itemWidth = legendModel.get('itemWidth')
  53693. var itemHeight = legendModel.get('itemHeight')
  53694. var isSelected = legendModel.isSelected(name)
  53695. var iconRotate = legendItemModel.get('symbolRotate')
  53696. var symbolKeepAspect = legendItemModel.get('symbolKeepAspect')
  53697. var legendIconType = legendItemModel.get('icon')
  53698. legendIcon = legendIconType || legendIcon || 'roundRect'
  53699. var style = getLegendStyle(
  53700. legendIcon,
  53701. legendItemModel,
  53702. lineVisualStyle,
  53703. itemVisualStyle,
  53704. drawType,
  53705. isSelected,
  53706. api
  53707. )
  53708. var itemGroup = new Group$1()
  53709. var textStyleModel = legendItemModel.getModel('textStyle')
  53710. if (
  53711. isFunction(seriesModel.getLegendIcon) &&
  53712. (!legendIconType || legendIconType === 'inherit')
  53713. ) {
  53714. // Series has specific way to define legend icon
  53715. itemGroup.add(
  53716. seriesModel.getLegendIcon({
  53717. itemWidth: itemWidth,
  53718. itemHeight: itemHeight,
  53719. icon: legendIcon,
  53720. iconRotate: iconRotate,
  53721. itemStyle: style.itemStyle,
  53722. lineStyle: style.lineStyle,
  53723. symbolKeepAspect: symbolKeepAspect
  53724. })
  53725. )
  53726. } else {
  53727. // Use default legend icon policy for most series
  53728. var rotate =
  53729. legendIconType === 'inherit' &&
  53730. seriesModel.getData().getVisual('symbol')
  53731. ? iconRotate === 'inherit'
  53732. ? seriesModel.getData().getVisual('symbolRotate')
  53733. : iconRotate
  53734. : 0 // No rotation for no icon
  53735. itemGroup.add(
  53736. getDefaultLegendIcon({
  53737. itemWidth: itemWidth,
  53738. itemHeight: itemHeight,
  53739. icon: legendIcon,
  53740. iconRotate: rotate,
  53741. itemStyle: style.itemStyle,
  53742. lineStyle: style.lineStyle,
  53743. symbolKeepAspect: symbolKeepAspect
  53744. })
  53745. )
  53746. }
  53747. var textX = itemAlign === 'left' ? itemWidth + 5 : -5
  53748. var textAlign = itemAlign
  53749. var formatter = legendModel.get('formatter')
  53750. var content = name
  53751. if (isString(formatter) && formatter) {
  53752. content = formatter.replace('{name}', name != null ? name : '')
  53753. } else if (isFunction(formatter)) {
  53754. content = formatter(name)
  53755. }
  53756. var inactiveColor = legendItemModel.get('inactiveColor')
  53757. itemGroup.add(
  53758. new ZRText$1({
  53759. style: createTextStyle(textStyleModel, {
  53760. text: content,
  53761. x: textX,
  53762. y: itemHeight / 2,
  53763. fill: isSelected
  53764. ? textStyleModel.getTextColor()
  53765. : inactiveColor,
  53766. align: textAlign,
  53767. verticalAlign: 'middle'
  53768. })
  53769. })
  53770. ) // Add a invisible rect to increase the area of mouse hover
  53771. var hitRect = new Rect$2({
  53772. shape: itemGroup.getBoundingRect(),
  53773. invisible: true
  53774. })
  53775. var tooltipModel = legendItemModel.getModel('tooltip')
  53776. if (tooltipModel.get('show')) {
  53777. setTooltipConfig({
  53778. el: hitRect,
  53779. componentModel: legendModel,
  53780. itemName: name,
  53781. itemTooltipOption: tooltipModel.option
  53782. })
  53783. }
  53784. itemGroup.add(hitRect)
  53785. itemGroup.eachChild(function (child) {
  53786. child.silent = true
  53787. })
  53788. hitRect.silent = !selectMode
  53789. this.getContentGroup().add(itemGroup)
  53790. enableHoverEmphasis(itemGroup) // @ts-ignore
  53791. itemGroup.__legendDataIndex = dataIndex
  53792. return itemGroup
  53793. }
  53794. LegendView.prototype.layoutInner = function (
  53795. legendModel,
  53796. itemAlign,
  53797. maxSize,
  53798. isFirstRender,
  53799. selector,
  53800. selectorPosition
  53801. ) {
  53802. var contentGroup = this.getContentGroup()
  53803. var selectorGroup = this.getSelectorGroup() // Place items in contentGroup.
  53804. box(
  53805. legendModel.get('orient'),
  53806. contentGroup,
  53807. legendModel.get('itemGap'),
  53808. maxSize.width,
  53809. maxSize.height
  53810. )
  53811. var contentRect = contentGroup.getBoundingRect()
  53812. var contentPos = [-contentRect.x, -contentRect.y]
  53813. selectorGroup.markRedraw()
  53814. contentGroup.markRedraw()
  53815. if (selector) {
  53816. // Place buttons in selectorGroup
  53817. box(
  53818. // Buttons in selectorGroup always layout horizontally
  53819. 'horizontal',
  53820. selectorGroup,
  53821. legendModel.get('selectorItemGap', true)
  53822. )
  53823. var selectorRect = selectorGroup.getBoundingRect()
  53824. var selectorPos = [-selectorRect.x, -selectorRect.y]
  53825. var selectorButtonGap = legendModel.get(
  53826. 'selectorButtonGap',
  53827. true
  53828. )
  53829. var orientIdx = legendModel.getOrient().index
  53830. var wh = orientIdx === 0 ? 'width' : 'height'
  53831. var hw = orientIdx === 0 ? 'height' : 'width'
  53832. var yx = orientIdx === 0 ? 'y' : 'x'
  53833. if (selectorPosition === 'end') {
  53834. selectorPos[orientIdx] += contentRect[wh] + selectorButtonGap
  53835. } else {
  53836. contentPos[orientIdx] += selectorRect[wh] + selectorButtonGap
  53837. } //Always align selector to content as 'middle'
  53838. selectorPos[1 - orientIdx] +=
  53839. contentRect[hw] / 2 - selectorRect[hw] / 2
  53840. selectorGroup.x = selectorPos[0]
  53841. selectorGroup.y = selectorPos[1]
  53842. contentGroup.x = contentPos[0]
  53843. contentGroup.y = contentPos[1]
  53844. var mainRect = { x: 0, y: 0 }
  53845. mainRect[wh] =
  53846. contentRect[wh] + selectorButtonGap + selectorRect[wh]
  53847. mainRect[hw] = Math.max(contentRect[hw], selectorRect[hw])
  53848. mainRect[yx] = Math.min(
  53849. 0,
  53850. selectorRect[yx] + selectorPos[1 - orientIdx]
  53851. )
  53852. return mainRect
  53853. } else {
  53854. contentGroup.x = contentPos[0]
  53855. contentGroup.y = contentPos[1]
  53856. return this.group.getBoundingRect()
  53857. }
  53858. }
  53859. /**
  53860. * @protected
  53861. */ LegendView.prototype.remove = function () {
  53862. this.getContentGroup().removeAll()
  53863. this._isFirstRender = true
  53864. }
  53865. LegendView.type = 'legend.plain'
  53866. return LegendView
  53867. })(ComponentView$1)
  53868. function getLegendStyle(
  53869. iconType,
  53870. legendItemModel,
  53871. lineVisualStyle,
  53872. itemVisualStyle,
  53873. drawType,
  53874. isSelected,
  53875. api
  53876. ) {
  53877. /**
  53878. * Use series style if is inherit;
  53879. * elsewise, use legend style
  53880. */ function handleCommonProps(style, visualStyle) {
  53881. // If lineStyle.width is 'auto', it is set to be 2 if series has border
  53882. if (style.lineWidth === 'auto') {
  53883. style.lineWidth = visualStyle.lineWidth > 0 ? 2 : 0
  53884. }
  53885. each(style, function (propVal, propName) {
  53886. style[propName] === 'inherit' &&
  53887. (style[propName] = visualStyle[propName])
  53888. })
  53889. } // itemStyle
  53890. var itemStyleModel = legendItemModel.getModel('itemStyle')
  53891. var itemStyle = itemStyleModel.getItemStyle()
  53892. var iconBrushType =
  53893. iconType.lastIndexOf('empty', 0) === 0 ? 'fill' : 'stroke'
  53894. var decalStyle = itemStyleModel.getShallow('decal')
  53895. itemStyle.decal =
  53896. !decalStyle || decalStyle === 'inherit'
  53897. ? itemVisualStyle.decal
  53898. : createOrUpdatePatternFromDecal(decalStyle, api)
  53899. if (itemStyle.fill === 'inherit') {
  53900. /**
  53901. * Series with visualDrawType as 'stroke' should have
  53902. * series stroke as legend fill
  53903. */ itemStyle.fill = itemVisualStyle[drawType]
  53904. }
  53905. if (itemStyle.stroke === 'inherit') {
  53906. /**
  53907. * icon type with "emptyXXX" should use fill color
  53908. * in visual style
  53909. */ itemStyle.stroke = itemVisualStyle[iconBrushType]
  53910. }
  53911. if (itemStyle.opacity === 'inherit') {
  53912. /**
  53913. * Use lineStyle.opacity if drawType is stroke
  53914. */ itemStyle.opacity = (
  53915. drawType === 'fill' ? itemVisualStyle : lineVisualStyle
  53916. ).opacity
  53917. }
  53918. handleCommonProps(itemStyle, itemVisualStyle) // lineStyle
  53919. var legendLineModel = legendItemModel.getModel('lineStyle')
  53920. var lineStyle = legendLineModel.getLineStyle()
  53921. handleCommonProps(lineStyle, lineVisualStyle) // Fix auto color to real color
  53922. itemStyle.fill === 'auto' && (itemStyle.fill = itemVisualStyle.fill)
  53923. itemStyle.stroke === 'auto' &&
  53924. (itemStyle.stroke = itemVisualStyle.fill)
  53925. lineStyle.stroke === 'auto' &&
  53926. (lineStyle.stroke = itemVisualStyle.fill)
  53927. if (!isSelected) {
  53928. var borderWidth = legendItemModel.get('inactiveBorderWidth')
  53929. /**
  53930. * Since stroke is set to be inactiveBorderColor, it may occur that
  53931. * there is no border in series but border in legend, so we need to
  53932. * use border only when series has border if is set to be auto
  53933. */ var visualHasBorder = itemStyle[iconBrushType]
  53934. itemStyle.lineWidth =
  53935. borderWidth === 'auto'
  53936. ? itemVisualStyle.lineWidth > 0 && visualHasBorder
  53937. ? 2
  53938. : 0
  53939. : itemStyle.lineWidth
  53940. itemStyle.fill = legendItemModel.get('inactiveColor')
  53941. itemStyle.stroke = legendItemModel.get('inactiveBorderColor')
  53942. lineStyle.stroke = legendLineModel.get('inactiveColor')
  53943. lineStyle.lineWidth = legendLineModel.get('inactiveWidth')
  53944. }
  53945. return { itemStyle: itemStyle, lineStyle: lineStyle }
  53946. }
  53947. function getDefaultLegendIcon(opt) {
  53948. var symboType = opt.icon || 'roundRect'
  53949. var icon = createSymbol(
  53950. symboType,
  53951. 0,
  53952. 0,
  53953. opt.itemWidth,
  53954. opt.itemHeight,
  53955. opt.itemStyle.fill,
  53956. opt.symbolKeepAspect
  53957. )
  53958. icon.setStyle(opt.itemStyle)
  53959. icon.rotation = ((opt.iconRotate || 0) * Math.PI) / 180
  53960. icon.setOrigin([opt.itemWidth / 2, opt.itemHeight / 2])
  53961. if (symboType.indexOf('empty') > -1) {
  53962. icon.style.stroke = icon.style.fill
  53963. icon.style.fill = '#fff'
  53964. icon.style.lineWidth = 2
  53965. }
  53966. return icon
  53967. }
  53968. function dispatchSelectAction(
  53969. seriesName,
  53970. dataName,
  53971. api,
  53972. excludeSeriesId
  53973. ) {
  53974. // downplay before unselect
  53975. dispatchDownplayAction(seriesName, dataName, api, excludeSeriesId)
  53976. api.dispatchAction({
  53977. type: 'legendToggleSelect',
  53978. name: seriesName != null ? seriesName : dataName
  53979. }) // highlight after select
  53980. // TODO higlight immediately may cause animation loss.
  53981. dispatchHighlightAction(seriesName, dataName, api, excludeSeriesId)
  53982. }
  53983. function isUseHoverLayer(api) {
  53984. var list = api.getZr().storage.getDisplayList()
  53985. var emphasisState
  53986. var i = 0
  53987. var len = list.length
  53988. while (i < len && !(emphasisState = list[i].states.emphasis)) {
  53989. i++
  53990. }
  53991. return emphasisState && emphasisState.hoverLayer
  53992. }
  53993. function dispatchHighlightAction(
  53994. seriesName,
  53995. dataName,
  53996. api,
  53997. excludeSeriesId
  53998. ) {
  53999. // If element hover will move to a hoverLayer.
  54000. if (!isUseHoverLayer(api)) {
  54001. api.dispatchAction({
  54002. type: 'highlight',
  54003. seriesName: seriesName,
  54004. name: dataName,
  54005. excludeSeriesId: excludeSeriesId
  54006. })
  54007. }
  54008. }
  54009. function dispatchDownplayAction(
  54010. seriesName,
  54011. dataName,
  54012. api,
  54013. excludeSeriesId
  54014. ) {
  54015. // If element hover will move to a hoverLayer.
  54016. if (!isUseHoverLayer(api)) {
  54017. api.dispatchAction({
  54018. type: 'downplay',
  54019. seriesName: seriesName,
  54020. name: dataName,
  54021. excludeSeriesId: excludeSeriesId
  54022. })
  54023. }
  54024. }
  54025. var LegendView$1 = LegendView
  54026. /*
  54027. * Licensed to the Apache Software Foundation (ASF) under one
  54028. * or more contributor license agreements. See the NOTICE file
  54029. * distributed with this work for additional information
  54030. * regarding copyright ownership. The ASF licenses this file
  54031. * to you under the Apache License, Version 2.0 (the
  54032. * "License"); you may not use this file except in compliance
  54033. * with the License. You may obtain a copy of the License at
  54034. *
  54035. * http://www.apache.org/licenses/LICENSE-2.0
  54036. *
  54037. * Unless required by applicable law or agreed to in writing,
  54038. * software distributed under the License is distributed on an
  54039. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54040. * KIND, either express or implied. See the License for the
  54041. * specific language governing permissions and limitations
  54042. * under the License.
  54043. */ /**
  54044. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54045. */ /*
  54046. * Licensed to the Apache Software Foundation (ASF) under one
  54047. * or more contributor license agreements. See the NOTICE file
  54048. * distributed with this work for additional information
  54049. * regarding copyright ownership. The ASF licenses this file
  54050. * to you under the Apache License, Version 2.0 (the
  54051. * "License"); you may not use this file except in compliance
  54052. * with the License. You may obtain a copy of the License at
  54053. *
  54054. * http://www.apache.org/licenses/LICENSE-2.0
  54055. *
  54056. * Unless required by applicable law or agreed to in writing,
  54057. * software distributed under the License is distributed on an
  54058. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54059. * KIND, either express or implied. See the License for the
  54060. * specific language governing permissions and limitations
  54061. * under the License.
  54062. */ function legendFilter(ecModel) {
  54063. var legendModels = ecModel.findComponents({ mainType: 'legend' })
  54064. if (legendModels && legendModels.length) {
  54065. ecModel.filterSeries(function (series) {
  54066. // If in any legend component the status is not selected.
  54067. // Because in legend series is assumed selected when it is not in the legend data.
  54068. for (var i = 0; i < legendModels.length; i++) {
  54069. if (!legendModels[i].isSelected(series.name)) {
  54070. return false
  54071. }
  54072. }
  54073. return true
  54074. })
  54075. }
  54076. }
  54077. function legendSelectActionHandler(methodName, payload, ecModel) {
  54078. var selectedMap = {}
  54079. var isToggleSelect = methodName === 'toggleSelected'
  54080. var isSelected // Update all legend components
  54081. ecModel.eachComponent('legend', function (legendModel) {
  54082. if (isToggleSelect && isSelected != null) {
  54083. // Force other legend has same selected status
  54084. // Or the first is toggled to true and other are toggled to false
  54085. // In the case one legend has some item unSelected in option. And if other legend
  54086. // doesn't has the item, they will assume it is selected.
  54087. legendModel[isSelected ? 'select' : 'unSelect'](payload.name)
  54088. } else if (
  54089. methodName === 'allSelect' ||
  54090. methodName === 'inverseSelect'
  54091. ) {
  54092. legendModel[methodName]()
  54093. } else {
  54094. legendModel[methodName](payload.name)
  54095. isSelected = legendModel.isSelected(payload.name)
  54096. }
  54097. var legendData = legendModel.getData()
  54098. each$7(legendData, function (model) {
  54099. var name = model.get('name') // Wrap element
  54100. if (name === '\n' || name === '') {
  54101. return
  54102. }
  54103. var isItemSelected = legendModel.isSelected(name)
  54104. if (selectedMap.hasOwnProperty(name)) {
  54105. // Unselected if any legend is unselected
  54106. selectedMap[name] = selectedMap[name] && isItemSelected
  54107. } else {
  54108. selectedMap[name] = isItemSelected
  54109. }
  54110. })
  54111. }) // Return the event explicitly
  54112. return methodName === 'allSelect' || methodName === 'inverseSelect'
  54113. ? { selected: selectedMap }
  54114. : { name: payload.name, selected: selectedMap }
  54115. }
  54116. function installLegendAction(registers) {
  54117. /**
  54118. * @event legendToggleSelect
  54119. * @type {Object}
  54120. * @property {string} type 'legendToggleSelect'
  54121. * @property {string} [from]
  54122. * @property {string} name Series name or data item name
  54123. */ registers.registerAction(
  54124. 'legendToggleSelect',
  54125. 'legendselectchanged',
  54126. curry$1(legendSelectActionHandler, 'toggleSelected')
  54127. )
  54128. registers.registerAction(
  54129. 'legendAllSelect',
  54130. 'legendselectall',
  54131. curry$1(legendSelectActionHandler, 'allSelect')
  54132. )
  54133. registers.registerAction(
  54134. 'legendInverseSelect',
  54135. 'legendinverseselect',
  54136. curry$1(legendSelectActionHandler, 'inverseSelect')
  54137. )
  54138. /**
  54139. * @event legendSelect
  54140. * @type {Object}
  54141. * @property {string} type 'legendSelect'
  54142. * @property {string} name Series name or data item name
  54143. */ registers.registerAction(
  54144. 'legendSelect',
  54145. 'legendselected',
  54146. curry$1(legendSelectActionHandler, 'select')
  54147. )
  54148. /**
  54149. * @event legendUnSelect
  54150. * @type {Object}
  54151. * @property {string} type 'legendUnSelect'
  54152. * @property {string} name Series name or data item name
  54153. */ registers.registerAction(
  54154. 'legendUnSelect',
  54155. 'legendunselected',
  54156. curry$1(legendSelectActionHandler, 'unSelect')
  54157. )
  54158. }
  54159. function install$8(registers) {
  54160. registers.registerComponentModel(LegendModel$1)
  54161. registers.registerComponentView(LegendView$1)
  54162. registers.registerProcessor(
  54163. registers.PRIORITY.PROCESSOR.SERIES_FILTER,
  54164. legendFilter
  54165. )
  54166. registers.registerSubTypeDefaulter('legend', function () {
  54167. return 'plain'
  54168. })
  54169. installLegendAction(registers)
  54170. }
  54171. var ScrollableLegendModel = /** @class */ (function (_super) {
  54172. __extends(ScrollableLegendModel, _super)
  54173. function ScrollableLegendModel() {
  54174. var _this =
  54175. (_super !== null && _super.apply(this, arguments)) || this
  54176. _this.type = ScrollableLegendModel.type
  54177. return _this
  54178. }
  54179. /**
  54180. * @param {number} scrollDataIndex
  54181. */ ScrollableLegendModel.prototype.setScrollDataIndex = function (
  54182. scrollDataIndex
  54183. ) {
  54184. this.option.scrollDataIndex = scrollDataIndex
  54185. }
  54186. ScrollableLegendModel.prototype.init = function (
  54187. option,
  54188. parentModel,
  54189. ecModel
  54190. ) {
  54191. var inputPositionParams = getLayoutParams(option)
  54192. _super.prototype.init.call(this, option, parentModel, ecModel)
  54193. mergeAndNormalizeLayoutParams(this, option, inputPositionParams)
  54194. }
  54195. /**
  54196. * @override
  54197. */ ScrollableLegendModel.prototype.mergeOption = function (
  54198. option,
  54199. ecModel
  54200. ) {
  54201. _super.prototype.mergeOption.call(this, option, ecModel)
  54202. mergeAndNormalizeLayoutParams(this, this.option, option)
  54203. }
  54204. ScrollableLegendModel.type = 'legend.scroll'
  54205. ScrollableLegendModel.defaultOption = inheritDefaultOption(
  54206. LegendModel$1.defaultOption,
  54207. {
  54208. scrollDataIndex: 0,
  54209. pageButtonItemGap: 5,
  54210. pageButtonGap: null,
  54211. pageButtonPosition: 'end',
  54212. pageFormatter: '{current}/{total}',
  54213. pageIcons: {
  54214. horizontal: ['M0,0L12,-10L12,10z', 'M0,0L-12,-10L-12,10z'],
  54215. vertical: ['M0,0L20,0L10,-20z', 'M0,0L20,0L10,20z']
  54216. },
  54217. pageIconColor: '#2f4554',
  54218. pageIconInactiveColor: '#aaa',
  54219. pageIconSize: 15,
  54220. pageTextStyle: { color: '#333' },
  54221. animationDurationUpdate: 800
  54222. }
  54223. )
  54224. return ScrollableLegendModel
  54225. })(LegendModel$1)
  54226. function mergeAndNormalizeLayoutParams(legendModel, target, raw) {
  54227. var orient = legendModel.getOrient()
  54228. var ignoreSize = [1, 1]
  54229. ignoreSize[orient.index] = 0
  54230. mergeLayoutParam(target, raw, {
  54231. type: 'box',
  54232. ignoreSize: !!ignoreSize
  54233. })
  54234. }
  54235. var ScrollableLegendModel$1 = ScrollableLegendModel
  54236. var Group = Group$3
  54237. var WH = ['width', 'height']
  54238. var XY = ['x', 'y']
  54239. var ScrollableLegendView = /** @class */ (function (_super) {
  54240. __extends(ScrollableLegendView, _super)
  54241. function ScrollableLegendView() {
  54242. var _this =
  54243. (_super !== null && _super.apply(this, arguments)) || this
  54244. _this.type = ScrollableLegendView.type
  54245. _this.newlineDisabled = true
  54246. _this._currentIndex = 0
  54247. return _this
  54248. }
  54249. ScrollableLegendView.prototype.init = function () {
  54250. _super.prototype.init.call(this)
  54251. this.group.add((this._containerGroup = new Group()))
  54252. this._containerGroup.add(this.getContentGroup())
  54253. this.group.add((this._controllerGroup = new Group()))
  54254. }
  54255. /**
  54256. * @override
  54257. */ ScrollableLegendView.prototype.resetInner = function () {
  54258. _super.prototype.resetInner.call(this)
  54259. this._controllerGroup.removeAll()
  54260. this._containerGroup.removeClipPath()
  54261. this._containerGroup.__rectSize = null
  54262. }
  54263. /**
  54264. * @override
  54265. */ ScrollableLegendView.prototype.renderInner = function (
  54266. itemAlign,
  54267. legendModel,
  54268. ecModel,
  54269. api,
  54270. selector,
  54271. orient,
  54272. selectorPosition
  54273. ) {
  54274. var self = this // Render content items.
  54275. _super.prototype.renderInner.call(
  54276. this,
  54277. itemAlign,
  54278. legendModel,
  54279. ecModel,
  54280. api,
  54281. selector,
  54282. orient,
  54283. selectorPosition
  54284. )
  54285. var controllerGroup = this._controllerGroup // FIXME: support be 'auto' adapt to size number text length,
  54286. // e.g., '3/12345' should not overlap with the control arrow button.
  54287. var pageIconSize = legendModel.get('pageIconSize', true)
  54288. var pageIconSizeArr = isArray(pageIconSize)
  54289. ? pageIconSize
  54290. : [pageIconSize, pageIconSize]
  54291. createPageButton('pagePrev', 0)
  54292. var pageTextStyleModel = legendModel.getModel('pageTextStyle')
  54293. controllerGroup.add(
  54294. new ZRText$1({
  54295. name: 'pageText',
  54296. style: {
  54297. // Placeholder to calculate a proper layout.
  54298. text: 'xx/xx',
  54299. fill: pageTextStyleModel.getTextColor(),
  54300. font: pageTextStyleModel.getFont(),
  54301. verticalAlign: 'middle',
  54302. align: 'center'
  54303. },
  54304. silent: true
  54305. })
  54306. )
  54307. createPageButton('pageNext', 1)
  54308. function createPageButton(name, iconIdx) {
  54309. var pageDataIndexName = name + 'DataIndex'
  54310. var icon = createIcon(
  54311. legendModel.get('pageIcons', true)[
  54312. legendModel.getOrient().name
  54313. ][iconIdx],
  54314. {
  54315. // Buttons will be created in each render, so we do not need
  54316. // to worry about avoiding using legendModel kept in scope.
  54317. onclick: bind$1(
  54318. self._pageGo,
  54319. self,
  54320. pageDataIndexName,
  54321. legendModel,
  54322. api
  54323. )
  54324. },
  54325. {
  54326. x: -pageIconSizeArr[0] / 2,
  54327. y: -pageIconSizeArr[1] / 2,
  54328. width: pageIconSizeArr[0],
  54329. height: pageIconSizeArr[1]
  54330. }
  54331. )
  54332. icon.name = name
  54333. controllerGroup.add(icon)
  54334. }
  54335. }
  54336. /**
  54337. * @override
  54338. */ ScrollableLegendView.prototype.layoutInner = function (
  54339. legendModel,
  54340. itemAlign,
  54341. maxSize,
  54342. isFirstRender,
  54343. selector,
  54344. selectorPosition
  54345. ) {
  54346. var selectorGroup = this.getSelectorGroup()
  54347. var orientIdx = legendModel.getOrient().index
  54348. var wh = WH[orientIdx]
  54349. var xy = XY[orientIdx]
  54350. var hw = WH[1 - orientIdx]
  54351. var yx = XY[1 - orientIdx]
  54352. selector &&
  54353. box(
  54354. // Buttons in selectorGroup always layout horizontally
  54355. 'horizontal',
  54356. selectorGroup,
  54357. legendModel.get('selectorItemGap', true)
  54358. )
  54359. var selectorButtonGap = legendModel.get('selectorButtonGap', true)
  54360. var selectorRect = selectorGroup.getBoundingRect()
  54361. var selectorPos = [-selectorRect.x, -selectorRect.y]
  54362. var processMaxSize = clone$3(maxSize)
  54363. selector &&
  54364. (processMaxSize[wh] =
  54365. maxSize[wh] - selectorRect[wh] - selectorButtonGap)
  54366. var mainRect = this._layoutContentAndController(
  54367. legendModel,
  54368. isFirstRender,
  54369. processMaxSize,
  54370. orientIdx,
  54371. wh,
  54372. hw,
  54373. yx,
  54374. xy
  54375. )
  54376. if (selector) {
  54377. if (selectorPosition === 'end') {
  54378. selectorPos[orientIdx] += mainRect[wh] + selectorButtonGap
  54379. } else {
  54380. var offset = selectorRect[wh] + selectorButtonGap
  54381. selectorPos[orientIdx] -= offset
  54382. mainRect[xy] -= offset
  54383. }
  54384. mainRect[wh] += selectorRect[wh] + selectorButtonGap
  54385. selectorPos[1 - orientIdx] +=
  54386. mainRect[yx] + mainRect[hw] / 2 - selectorRect[hw] / 2
  54387. mainRect[hw] = Math.max(mainRect[hw], selectorRect[hw])
  54388. mainRect[yx] = Math.min(
  54389. mainRect[yx],
  54390. selectorRect[yx] + selectorPos[1 - orientIdx]
  54391. )
  54392. selectorGroup.x = selectorPos[0]
  54393. selectorGroup.y = selectorPos[1]
  54394. selectorGroup.markRedraw()
  54395. }
  54396. return mainRect
  54397. }
  54398. ScrollableLegendView.prototype._layoutContentAndController =
  54399. function (
  54400. legendModel,
  54401. isFirstRender,
  54402. maxSize,
  54403. orientIdx,
  54404. wh,
  54405. hw,
  54406. yx,
  54407. xy
  54408. ) {
  54409. var contentGroup = this.getContentGroup()
  54410. var containerGroup = this._containerGroup
  54411. var controllerGroup = this._controllerGroup // Place items in contentGroup.
  54412. box(
  54413. legendModel.get('orient'),
  54414. contentGroup,
  54415. legendModel.get('itemGap'),
  54416. !orientIdx ? null : maxSize.width,
  54417. orientIdx ? null : maxSize.height
  54418. )
  54419. box(
  54420. // Buttons in controller are layout always horizontally.
  54421. 'horizontal',
  54422. controllerGroup,
  54423. legendModel.get('pageButtonItemGap', true)
  54424. )
  54425. var contentRect = contentGroup.getBoundingRect()
  54426. var controllerRect = controllerGroup.getBoundingRect()
  54427. var showController = (this._showController =
  54428. contentRect[wh] > maxSize[wh]) // In case that the inner elements of contentGroup layout do not based on [0, 0]
  54429. var contentPos = [-contentRect.x, -contentRect.y] // Remain contentPos when scroll animation perfroming.
  54430. // If first rendering, `contentGroup.position` is [0, 0], which
  54431. // does not make sense and may cause unexepcted animation if adopted.
  54432. if (!isFirstRender) {
  54433. contentPos[orientIdx] = contentGroup[xy]
  54434. } // Layout container group based on 0.
  54435. var containerPos = [0, 0]
  54436. var controllerPos = [-controllerRect.x, -controllerRect.y]
  54437. var pageButtonGap = retrieve2(
  54438. legendModel.get('pageButtonGap', true),
  54439. legendModel.get('itemGap', true)
  54440. ) // Place containerGroup and controllerGroup and contentGroup.
  54441. if (showController) {
  54442. var pageButtonPosition = legendModel.get(
  54443. 'pageButtonPosition',
  54444. true
  54445. ) // controller is on the right / bottom.
  54446. if (pageButtonPosition === 'end') {
  54447. controllerPos[orientIdx] += maxSize[wh] - controllerRect[wh]
  54448. } // controller is on the left / top.
  54449. else {
  54450. containerPos[orientIdx] +=
  54451. controllerRect[wh] + pageButtonGap
  54452. }
  54453. } // Always align controller to content as 'middle'.
  54454. controllerPos[1 - orientIdx] +=
  54455. contentRect[hw] / 2 - controllerRect[hw] / 2
  54456. contentGroup.setPosition(contentPos)
  54457. containerGroup.setPosition(containerPos)
  54458. controllerGroup.setPosition(controllerPos) // Calculate `mainRect` and set `clipPath`.
  54459. // mainRect should not be calculated by `this.group.getBoundingRect()`
  54460. // for sake of the overflow.
  54461. var mainRect = { x: 0, y: 0 } // Consider content may be overflow (should be clipped).
  54462. mainRect[wh] = showController ? maxSize[wh] : contentRect[wh]
  54463. mainRect[hw] = Math.max(contentRect[hw], controllerRect[hw]) // `containerRect[yx] + containerPos[1 - orientIdx]` is 0.
  54464. mainRect[yx] = Math.min(
  54465. 0,
  54466. controllerRect[yx] + controllerPos[1 - orientIdx]
  54467. )
  54468. containerGroup.__rectSize = maxSize[wh]
  54469. if (showController) {
  54470. var clipShape = { x: 0, y: 0 }
  54471. clipShape[wh] = Math.max(
  54472. maxSize[wh] - controllerRect[wh] - pageButtonGap,
  54473. 0
  54474. )
  54475. clipShape[hw] = mainRect[hw]
  54476. containerGroup.setClipPath(new Rect$2({ shape: clipShape })) // Consider content may be larger than container, container rect
  54477. // can not be obtained from `containerGroup.getBoundingRect()`.
  54478. containerGroup.__rectSize = clipShape[wh]
  54479. } else {
  54480. // Do not remove or ignore controller. Keep them set as placeholders.
  54481. controllerGroup.eachChild(function (child) {
  54482. child.attr({ invisible: true, silent: true })
  54483. })
  54484. } // Content translate animation.
  54485. var pageInfo = this._getPageInfo(legendModel)
  54486. pageInfo.pageIndex != null &&
  54487. updateProps$1(
  54488. contentGroup,
  54489. {
  54490. x: pageInfo.contentPosition[0],
  54491. y: pageInfo.contentPosition[1]
  54492. }, // When switch from "show controller" to "not show controller", view should be
  54493. // updated immediately without animation, otherwise causes weird effect.
  54494. showController ? legendModel : null
  54495. )
  54496. this._updatePageInfoView(legendModel, pageInfo)
  54497. return mainRect
  54498. }
  54499. ScrollableLegendView.prototype._pageGo = function (
  54500. to,
  54501. legendModel,
  54502. api
  54503. ) {
  54504. var scrollDataIndex = this._getPageInfo(legendModel)[to]
  54505. scrollDataIndex != null &&
  54506. api.dispatchAction({
  54507. type: 'legendScroll',
  54508. scrollDataIndex: scrollDataIndex,
  54509. legendId: legendModel.id
  54510. })
  54511. }
  54512. ScrollableLegendView.prototype._updatePageInfoView = function (
  54513. legendModel,
  54514. pageInfo
  54515. ) {
  54516. var controllerGroup = this._controllerGroup
  54517. each$7(['pagePrev', 'pageNext'], function (name) {
  54518. var key = name + 'DataIndex'
  54519. var canJump = pageInfo[key] != null
  54520. var icon = controllerGroup.childOfName(name)
  54521. if (icon) {
  54522. icon.setStyle(
  54523. 'fill',
  54524. canJump
  54525. ? legendModel.get('pageIconColor', true)
  54526. : legendModel.get('pageIconInactiveColor', true)
  54527. )
  54528. icon.cursor = canJump ? 'pointer' : 'default'
  54529. }
  54530. })
  54531. var pageText = controllerGroup.childOfName('pageText')
  54532. var pageFormatter = legendModel.get('pageFormatter')
  54533. var pageIndex = pageInfo.pageIndex
  54534. var current = pageIndex != null ? pageIndex + 1 : 0
  54535. var total = pageInfo.pageCount
  54536. pageText &&
  54537. pageFormatter &&
  54538. pageText.setStyle(
  54539. 'text',
  54540. isString(pageFormatter)
  54541. ? pageFormatter
  54542. .replace(
  54543. '{current}',
  54544. current == null ? '' : current + ''
  54545. )
  54546. .replace('{total}', total == null ? '' : total + '')
  54547. : pageFormatter({ current: current, total: total })
  54548. )
  54549. }
  54550. /**
  54551. * contentPosition: Array.<number>, null when data item not found.
  54552. * pageIndex: number, null when data item not found.
  54553. * pageCount: number, always be a number, can be 0.
  54554. * pagePrevDataIndex: number, null when no previous page.
  54555. * pageNextDataIndex: number, null when no next page.
  54556. * }
  54557. */ ScrollableLegendView.prototype._getPageInfo = function (
  54558. legendModel
  54559. ) {
  54560. var scrollDataIndex = legendModel.get('scrollDataIndex', true)
  54561. var contentGroup = this.getContentGroup()
  54562. var containerRectSize = this._containerGroup.__rectSize
  54563. var orientIdx = legendModel.getOrient().index
  54564. var wh = WH[orientIdx]
  54565. var xy = XY[orientIdx]
  54566. var targetItemIndex = this._findTargetItemIndex(scrollDataIndex)
  54567. var children = contentGroup.children()
  54568. var targetItem = children[targetItemIndex]
  54569. var itemCount = children.length
  54570. var pCount = !itemCount ? 0 : 1
  54571. var result = {
  54572. contentPosition: [contentGroup.x, contentGroup.y],
  54573. pageCount: pCount,
  54574. pageIndex: pCount - 1,
  54575. pagePrevDataIndex: null,
  54576. pageNextDataIndex: null
  54577. }
  54578. if (!targetItem) {
  54579. return result
  54580. }
  54581. var targetItemInfo = getItemInfo(targetItem)
  54582. result.contentPosition[orientIdx] = -targetItemInfo.s // Strategy:
  54583. // (1) Always align based on the left/top most item.
  54584. // (2) It is user-friendly that the last item shown in the
  54585. // current window is shown at the begining of next window.
  54586. // Otherwise if half of the last item is cut by the window,
  54587. // it will have no chance to display entirely.
  54588. // (3) Consider that item size probably be different, we
  54589. // have calculate pageIndex by size rather than item index,
  54590. // and we can not get page index directly by division.
  54591. // (4) The window is to narrow to contain more than
  54592. // one item, we should make sure that the page can be fliped.
  54593. for (
  54594. var i = targetItemIndex + 1,
  54595. winStartItemInfo = targetItemInfo,
  54596. winEndItemInfo = targetItemInfo,
  54597. currItemInfo = null;
  54598. i <= itemCount;
  54599. ++i
  54600. ) {
  54601. currItemInfo = getItemInfo(children[i])
  54602. if (
  54603. // Half of the last item is out of the window.
  54604. (!currItemInfo &&
  54605. winEndItemInfo.e >
  54606. winStartItemInfo.s + containerRectSize) || // If the current item does not intersect with the window, the new page
  54607. // can be started at the current item or the last item.
  54608. (currItemInfo && !intersect(currItemInfo, winStartItemInfo.s))
  54609. ) {
  54610. if (winEndItemInfo.i > winStartItemInfo.i) {
  54611. winStartItemInfo = winEndItemInfo
  54612. } else {
  54613. // e.g., when page size is smaller than item size.
  54614. winStartItemInfo = currItemInfo
  54615. }
  54616. if (winStartItemInfo) {
  54617. if (result.pageNextDataIndex == null) {
  54618. result.pageNextDataIndex = winStartItemInfo.i
  54619. }
  54620. ++result.pageCount
  54621. }
  54622. }
  54623. winEndItemInfo = currItemInfo
  54624. }
  54625. for (
  54626. var i = targetItemIndex - 1,
  54627. winStartItemInfo = targetItemInfo,
  54628. winEndItemInfo = targetItemInfo,
  54629. currItemInfo = null;
  54630. i >= -1;
  54631. --i
  54632. ) {
  54633. currItemInfo = getItemInfo(children[i])
  54634. if (
  54635. // If the the end item does not intersect with the window started
  54636. // from the current item, a page can be settled.
  54637. (!currItemInfo ||
  54638. !intersect(winEndItemInfo, currItemInfo.s)) && // e.g., when page size is smaller than item size.
  54639. winStartItemInfo.i < winEndItemInfo.i
  54640. ) {
  54641. winEndItemInfo = winStartItemInfo
  54642. if (result.pagePrevDataIndex == null) {
  54643. result.pagePrevDataIndex = winStartItemInfo.i
  54644. }
  54645. ++result.pageCount
  54646. ++result.pageIndex
  54647. }
  54648. winStartItemInfo = currItemInfo
  54649. }
  54650. return result
  54651. function getItemInfo(el) {
  54652. if (el) {
  54653. var itemRect = el.getBoundingRect()
  54654. var start = itemRect[xy] + el[xy]
  54655. return {
  54656. s: start,
  54657. e: start + itemRect[wh],
  54658. i: el.__legendDataIndex
  54659. }
  54660. }
  54661. }
  54662. function intersect(itemInfo, winStart) {
  54663. return (
  54664. itemInfo.e >= winStart &&
  54665. itemInfo.s <= winStart + containerRectSize
  54666. )
  54667. }
  54668. }
  54669. ScrollableLegendView.prototype._findTargetItemIndex = function (
  54670. targetDataIndex
  54671. ) {
  54672. if (!this._showController) {
  54673. return 0
  54674. }
  54675. var index
  54676. var contentGroup = this.getContentGroup()
  54677. var defaultIndex
  54678. contentGroup.eachChild(function (child, idx) {
  54679. var legendDataIdx = child.__legendDataIndex // FIXME
  54680. // If the given targetDataIndex (from model) is illegal,
  54681. // we use defaultIndex. But the index on the legend model and
  54682. // action payload is still illegal. That case will not be
  54683. // changed until some scenario requires.
  54684. if (defaultIndex == null && legendDataIdx != null) {
  54685. defaultIndex = idx
  54686. }
  54687. if (legendDataIdx === targetDataIndex) {
  54688. index = idx
  54689. }
  54690. })
  54691. return index != null ? index : defaultIndex
  54692. }
  54693. ScrollableLegendView.type = 'legend.scroll'
  54694. return ScrollableLegendView
  54695. })(LegendView$1)
  54696. var ScrollableLegendView$1 = ScrollableLegendView
  54697. /*
  54698. * Licensed to the Apache Software Foundation (ASF) under one
  54699. * or more contributor license agreements. See the NOTICE file
  54700. * distributed with this work for additional information
  54701. * regarding copyright ownership. The ASF licenses this file
  54702. * to you under the Apache License, Version 2.0 (the
  54703. * "License"); you may not use this file except in compliance
  54704. * with the License. You may obtain a copy of the License at
  54705. *
  54706. * http://www.apache.org/licenses/LICENSE-2.0
  54707. *
  54708. * Unless required by applicable law or agreed to in writing,
  54709. * software distributed under the License is distributed on an
  54710. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54711. * KIND, either express or implied. See the License for the
  54712. * specific language governing permissions and limitations
  54713. * under the License.
  54714. */ /**
  54715. * AUTO-GENERATED FILE. DO NOT MODIFY.
  54716. */ /*
  54717. * Licensed to the Apache Software Foundation (ASF) under one
  54718. * or more contributor license agreements. See the NOTICE file
  54719. * distributed with this work for additional information
  54720. * regarding copyright ownership. The ASF licenses this file
  54721. * to you under the Apache License, Version 2.0 (the
  54722. * "License"); you may not use this file except in compliance
  54723. * with the License. You may obtain a copy of the License at
  54724. *
  54725. * http://www.apache.org/licenses/LICENSE-2.0
  54726. *
  54727. * Unless required by applicable law or agreed to in writing,
  54728. * software distributed under the License is distributed on an
  54729. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  54730. * KIND, either express or implied. See the License for the
  54731. * specific language governing permissions and limitations
  54732. * under the License.
  54733. */ function installScrollableLegendAction(registers) {
  54734. /**
  54735. * @event legendScroll
  54736. * @type {Object}
  54737. * @property {string} type 'legendScroll'
  54738. * @property {string} scrollDataIndex
  54739. */ registers.registerAction(
  54740. 'legendScroll',
  54741. 'legendscroll',
  54742. function (payload, ecModel) {
  54743. var scrollDataIndex = payload.scrollDataIndex
  54744. scrollDataIndex != null &&
  54745. ecModel.eachComponent(
  54746. { mainType: 'legend', subType: 'scroll', query: payload },
  54747. function (legendModel) {
  54748. legendModel.setScrollDataIndex(scrollDataIndex)
  54749. }
  54750. )
  54751. }
  54752. )
  54753. }
  54754. function install$7(registers) {
  54755. use(install$8)
  54756. registers.registerComponentModel(ScrollableLegendModel$1)
  54757. registers.registerComponentView(ScrollableLegendView$1)
  54758. installScrollableLegendAction(registers)
  54759. }
  54760. function install$6(registers) {
  54761. use(install$8)
  54762. use(install$7)
  54763. }
  54764. var InsideZoomModel = /** @class */ (function (_super) {
  54765. __extends(InsideZoomModel, _super)
  54766. function InsideZoomModel() {
  54767. var _this =
  54768. (_super !== null && _super.apply(this, arguments)) || this
  54769. _this.type = InsideZoomModel.type
  54770. return _this
  54771. }
  54772. InsideZoomModel.type = 'dataZoom.inside'
  54773. InsideZoomModel.defaultOption = inheritDefaultOption(
  54774. DataZoomModel$1.defaultOption,
  54775. {
  54776. disabled: false,
  54777. zoomLock: false,
  54778. zoomOnMouseWheel: true,
  54779. moveOnMouseMove: true,
  54780. moveOnMouseWheel: false,
  54781. preventDefaultMouseMove: true
  54782. }
  54783. )
  54784. return InsideZoomModel
  54785. })(DataZoomModel$1)
  54786. var InsideZoomModel$1 = InsideZoomModel
  54787. var inner = makeInner()
  54788. function setViewInfoToCoordSysRecord(api, dataZoomModel, getRange) {
  54789. inner(api).coordSysRecordMap.each(function (coordSysRecord) {
  54790. var dzInfo = coordSysRecord.dataZoomInfoMap.get(dataZoomModel.uid)
  54791. if (dzInfo) {
  54792. dzInfo.getRange = getRange
  54793. }
  54794. })
  54795. }
  54796. function disposeCoordSysRecordIfNeeded(api, dataZoomModel) {
  54797. var coordSysRecordMap = inner(api).coordSysRecordMap
  54798. var coordSysKeyArr = coordSysRecordMap.keys()
  54799. for (var i = 0; i < coordSysKeyArr.length; i++) {
  54800. var coordSysKey = coordSysKeyArr[i]
  54801. var coordSysRecord = coordSysRecordMap.get(coordSysKey)
  54802. var dataZoomInfoMap = coordSysRecord.dataZoomInfoMap
  54803. if (dataZoomInfoMap) {
  54804. var dzUid = dataZoomModel.uid
  54805. var dzInfo = dataZoomInfoMap.get(dzUid)
  54806. if (dzInfo) {
  54807. dataZoomInfoMap.removeKey(dzUid)
  54808. if (!dataZoomInfoMap.keys().length) {
  54809. disposeCoordSysRecord(coordSysRecordMap, coordSysRecord)
  54810. }
  54811. }
  54812. }
  54813. }
  54814. }
  54815. function disposeCoordSysRecord(coordSysRecordMap, coordSysRecord) {
  54816. if (coordSysRecord) {
  54817. coordSysRecordMap.removeKey(coordSysRecord.model.uid)
  54818. var controller = coordSysRecord.controller
  54819. controller && controller.dispose()
  54820. }
  54821. }
  54822. function createCoordSysRecord(api, coordSysModel) {
  54823. // These init props will never change after record created.
  54824. var coordSysRecord = {
  54825. model: coordSysModel,
  54826. containsPoint: curry$1(containsPoint, coordSysModel),
  54827. dispatchAction: curry$1(dispatchAction, api),
  54828. dataZoomInfoMap: null,
  54829. controller: null
  54830. } // Must not do anything depends on coordSysRecord outside the event handler here,
  54831. // because coordSysRecord not completed yet.
  54832. var controller = (coordSysRecord.controller = new RoamController$1(
  54833. api.getZr()
  54834. ))
  54835. each$7(['pan', 'zoom', 'scrollMove'], function (eventName) {
  54836. controller.on(eventName, function (event) {
  54837. var batch = []
  54838. coordSysRecord.dataZoomInfoMap.each(function (dzInfo) {
  54839. // Check whether the behaviors (zoomOnMouseWheel, moveOnMouseMove,
  54840. // moveOnMouseWheel, ...) enabled.
  54841. if (!event.isAvailableBehavior(dzInfo.model.option)) {
  54842. return
  54843. }
  54844. var method = (dzInfo.getRange || {})[eventName]
  54845. var range =
  54846. method &&
  54847. method(
  54848. dzInfo.dzReferCoordSysInfo,
  54849. coordSysRecord.model.mainType,
  54850. coordSysRecord.controller,
  54851. event
  54852. )
  54853. !dzInfo.model.get('disabled', true) &&
  54854. range &&
  54855. batch.push({
  54856. dataZoomId: dzInfo.model.id,
  54857. start: range[0],
  54858. end: range[1]
  54859. })
  54860. })
  54861. batch.length && coordSysRecord.dispatchAction(batch)
  54862. })
  54863. })
  54864. return coordSysRecord
  54865. }
  54866. /**
  54867. * This action will be throttled.
  54868. */ function dispatchAction(api, batch) {
  54869. if (!api.isDisposed()) {
  54870. api.dispatchAction({
  54871. type: 'dataZoom',
  54872. animation: { easing: 'cubicOut', duration: 100 },
  54873. batch: batch
  54874. })
  54875. }
  54876. }
  54877. function containsPoint(coordSysModel, e, x, y) {
  54878. return coordSysModel.coordinateSystem.containPoint([x, y])
  54879. }
  54880. /**
  54881. * Merge roamController settings when multiple dataZooms share one roamController.
  54882. */ function mergeControllerParams(dataZoomInfoMap) {
  54883. var controlType // DO NOT use reserved word (true, false, undefined) as key literally. Even if encapsulated
  54884. // as string, it is probably revert to reserved word by compress tool. See #7411.
  54885. var prefix = 'type_'
  54886. var typePriority = {
  54887. type_true: 2,
  54888. type_move: 1,
  54889. type_false: 0,
  54890. type_undefined: -1
  54891. }
  54892. var preventDefaultMouseMove = true
  54893. dataZoomInfoMap.each(function (dataZoomInfo) {
  54894. var dataZoomModel = dataZoomInfo.model
  54895. var oneType = dataZoomModel.get('disabled', true)
  54896. ? false
  54897. : dataZoomModel.get('zoomLock', true)
  54898. ? 'move'
  54899. : true
  54900. if (
  54901. typePriority[prefix + oneType] >
  54902. typePriority[prefix + controlType]
  54903. ) {
  54904. controlType = oneType
  54905. } // Prevent default move event by default. If one false, do not prevent. Otherwise
  54906. // users may be confused why it does not work when multiple insideZooms exist.
  54907. preventDefaultMouseMove =
  54908. preventDefaultMouseMove &&
  54909. dataZoomModel.get('preventDefaultMouseMove', true)
  54910. })
  54911. return {
  54912. controlType: controlType,
  54913. opt: {
  54914. // RoamController will enable all of these functionalities,
  54915. // and the final behavior is determined by its event listener
  54916. // provided by each inside zoom.
  54917. zoomOnMouseWheel: true,
  54918. moveOnMouseMove: true,
  54919. moveOnMouseWheel: true,
  54920. preventDefaultMouseMove: !!preventDefaultMouseMove
  54921. }
  54922. }
  54923. }
  54924. function installDataZoomRoamProcessor(registers) {
  54925. registers.registerProcessor(
  54926. registers.PRIORITY.PROCESSOR.FILTER,
  54927. function (ecModel, api) {
  54928. var apiInner = inner(api)
  54929. var coordSysRecordMap =
  54930. apiInner.coordSysRecordMap ||
  54931. (apiInner.coordSysRecordMap = createHashMap())
  54932. coordSysRecordMap.each(function (coordSysRecord) {
  54933. // `coordSysRecordMap` always exists (becuase it hold the `roam controller`, which should
  54934. // better not re-create each time), but clear `dataZoomInfoMap` each round of the workflow.
  54935. coordSysRecord.dataZoomInfoMap = null
  54936. })
  54937. ecModel.eachComponent(
  54938. { mainType: 'dataZoom', subType: 'inside' },
  54939. function (dataZoomModel) {
  54940. var dzReferCoordSysWrap =
  54941. collectReferCoordSysModelInfo(dataZoomModel)
  54942. each$7(
  54943. dzReferCoordSysWrap.infoList,
  54944. function (dzCoordSysInfo) {
  54945. var coordSysUid = dzCoordSysInfo.model.uid
  54946. var coordSysRecord =
  54947. coordSysRecordMap.get(coordSysUid) ||
  54948. coordSysRecordMap.set(
  54949. coordSysUid,
  54950. createCoordSysRecord(api, dzCoordSysInfo.model)
  54951. )
  54952. var dataZoomInfoMap =
  54953. coordSysRecord.dataZoomInfoMap ||
  54954. (coordSysRecord.dataZoomInfoMap = createHashMap()) // Notice these props might be changed each time for a single dataZoomModel.
  54955. dataZoomInfoMap.set(dataZoomModel.uid, {
  54956. dzReferCoordSysInfo: dzCoordSysInfo,
  54957. model: dataZoomModel,
  54958. getRange: null
  54959. })
  54960. }
  54961. )
  54962. }
  54963. ) // (1) Merge dataZoom settings for each coord sys and set to the roam controller.
  54964. // (2) Clear coord sys if not refered by any dataZoom.
  54965. coordSysRecordMap.each(function (coordSysRecord) {
  54966. var controller = coordSysRecord.controller
  54967. var firstDzInfo
  54968. var dataZoomInfoMap = coordSysRecord.dataZoomInfoMap
  54969. if (dataZoomInfoMap) {
  54970. var firstDzKey = dataZoomInfoMap.keys()[0]
  54971. if (firstDzKey != null) {
  54972. firstDzInfo = dataZoomInfoMap.get(firstDzKey)
  54973. }
  54974. }
  54975. if (!firstDzInfo) {
  54976. disposeCoordSysRecord(coordSysRecordMap, coordSysRecord)
  54977. return
  54978. }
  54979. var controllerParams = mergeControllerParams(dataZoomInfoMap)
  54980. controller.enable(
  54981. controllerParams.controlType,
  54982. controllerParams.opt
  54983. )
  54984. controller.setPointerChecker(coordSysRecord.containsPoint)
  54985. createOrUpdate(
  54986. coordSysRecord,
  54987. 'dispatchAction',
  54988. firstDzInfo.model.get('throttle', true),
  54989. 'fixRate'
  54990. )
  54991. })
  54992. }
  54993. )
  54994. }
  54995. var InsideZoomView = /** @class */ (function (_super) {
  54996. __extends(InsideZoomView, _super)
  54997. function InsideZoomView() {
  54998. var _this =
  54999. (_super !== null && _super.apply(this, arguments)) || this
  55000. _this.type = 'dataZoom.inside'
  55001. return _this
  55002. }
  55003. InsideZoomView.prototype.render = function (
  55004. dataZoomModel,
  55005. ecModel,
  55006. api
  55007. ) {
  55008. _super.prototype.render.apply(this, arguments)
  55009. if (dataZoomModel.noTarget()) {
  55010. this._clear()
  55011. return
  55012. } // Hence the `throttle` util ensures to preserve command order,
  55013. // here simply updating range all the time will not cause missing
  55014. // any of the the roam change.
  55015. this.range = dataZoomModel.getPercentRange() // Reset controllers.
  55016. setViewInfoToCoordSysRecord(api, dataZoomModel, {
  55017. pan: bind$1(getRangeHandlers.pan, this),
  55018. zoom: bind$1(getRangeHandlers.zoom, this),
  55019. scrollMove: bind$1(getRangeHandlers.scrollMove, this)
  55020. })
  55021. }
  55022. InsideZoomView.prototype.dispose = function () {
  55023. this._clear()
  55024. _super.prototype.dispose.apply(this, arguments)
  55025. }
  55026. InsideZoomView.prototype._clear = function () {
  55027. disposeCoordSysRecordIfNeeded(this.api, this.dataZoomModel)
  55028. this.range = null
  55029. }
  55030. InsideZoomView.type = 'dataZoom.inside'
  55031. return InsideZoomView
  55032. })(DataZoomView$1)
  55033. var getRangeHandlers = {
  55034. zoom: function zoom(coordSysInfo, coordSysMainType, controller, e) {
  55035. var lastRange = this.range
  55036. var range = lastRange.slice() // Calculate transform by the first axis.
  55037. var axisModel = coordSysInfo.axisModels[0]
  55038. if (!axisModel) {
  55039. return
  55040. }
  55041. var directionInfo = getDirectionInfo[coordSysMainType](
  55042. null,
  55043. [e.originX, e.originY],
  55044. axisModel,
  55045. controller,
  55046. coordSysInfo
  55047. )
  55048. var percentPoint =
  55049. ((directionInfo.signal > 0
  55050. ? directionInfo.pixelStart +
  55051. directionInfo.pixelLength -
  55052. directionInfo.pixel
  55053. : directionInfo.pixel - directionInfo.pixelStart) /
  55054. directionInfo.pixelLength) *
  55055. (range[1] - range[0]) +
  55056. range[0]
  55057. var scale = Math.max(1 / e.scale, 0)
  55058. range[0] = (range[0] - percentPoint) * scale + percentPoint
  55059. range[1] = (range[1] - percentPoint) * scale + percentPoint // Restrict range.
  55060. var minMaxSpan = this.dataZoomModel
  55061. .findRepresentativeAxisProxy()
  55062. .getMinMaxSpan()
  55063. sliderMove(
  55064. 0,
  55065. range,
  55066. [0, 100],
  55067. 0,
  55068. minMaxSpan.minSpan,
  55069. minMaxSpan.maxSpan
  55070. )
  55071. this.range = range
  55072. if (lastRange[0] !== range[0] || lastRange[1] !== range[1]) {
  55073. return range
  55074. }
  55075. },
  55076. pan: makeMover(function (
  55077. range,
  55078. axisModel,
  55079. coordSysInfo,
  55080. coordSysMainType,
  55081. controller,
  55082. e
  55083. ) {
  55084. var directionInfo = getDirectionInfo[coordSysMainType](
  55085. [e.oldX, e.oldY],
  55086. [e.newX, e.newY],
  55087. axisModel,
  55088. controller,
  55089. coordSysInfo
  55090. )
  55091. return (
  55092. (directionInfo.signal *
  55093. (range[1] - range[0]) *
  55094. directionInfo.pixel) /
  55095. directionInfo.pixelLength
  55096. )
  55097. }),
  55098. scrollMove: makeMover(function (
  55099. range,
  55100. axisModel,
  55101. coordSysInfo,
  55102. coordSysMainType,
  55103. controller,
  55104. e
  55105. ) {
  55106. var directionInfo = getDirectionInfo[coordSysMainType](
  55107. [0, 0],
  55108. [e.scrollDelta, e.scrollDelta],
  55109. axisModel,
  55110. controller,
  55111. coordSysInfo
  55112. )
  55113. return (
  55114. directionInfo.signal * (range[1] - range[0]) * e.scrollDelta
  55115. )
  55116. })
  55117. }
  55118. function makeMover(getPercentDelta) {
  55119. return function (coordSysInfo, coordSysMainType, controller, e) {
  55120. var lastRange = this.range
  55121. var range = lastRange.slice() // Calculate transform by the first axis.
  55122. var axisModel = coordSysInfo.axisModels[0]
  55123. if (!axisModel) {
  55124. return
  55125. }
  55126. var percentDelta = getPercentDelta(
  55127. range,
  55128. axisModel,
  55129. coordSysInfo,
  55130. coordSysMainType,
  55131. controller,
  55132. e
  55133. )
  55134. sliderMove(percentDelta, range, [0, 100], 'all')
  55135. this.range = range
  55136. if (lastRange[0] !== range[0] || lastRange[1] !== range[1]) {
  55137. return range
  55138. }
  55139. }
  55140. }
  55141. var getDirectionInfo = {
  55142. grid: function grid(
  55143. oldPoint,
  55144. newPoint,
  55145. axisModel,
  55146. controller,
  55147. coordSysInfo
  55148. ) {
  55149. var axis = axisModel.axis
  55150. var ret = {}
  55151. var rect = coordSysInfo.model.coordinateSystem.getRect()
  55152. oldPoint = oldPoint || [0, 0]
  55153. if (axis.dim === 'x') {
  55154. ret.pixel = newPoint[0] - oldPoint[0]
  55155. ret.pixelLength = rect.width
  55156. ret.pixelStart = rect.x
  55157. ret.signal = axis.inverse ? 1 : -1
  55158. } else {
  55159. // axis.dim === 'y'
  55160. ret.pixel = newPoint[1] - oldPoint[1]
  55161. ret.pixelLength = rect.height
  55162. ret.pixelStart = rect.y
  55163. ret.signal = axis.inverse ? -1 : 1
  55164. }
  55165. return ret
  55166. },
  55167. polar: function polar(
  55168. oldPoint,
  55169. newPoint,
  55170. axisModel,
  55171. controller,
  55172. coordSysInfo
  55173. ) {
  55174. var axis = axisModel.axis
  55175. var ret = {}
  55176. var polar = coordSysInfo.model.coordinateSystem
  55177. var radiusExtent = polar.getRadiusAxis().getExtent()
  55178. var angleExtent = polar.getAngleAxis().getExtent()
  55179. oldPoint = oldPoint ? polar.pointToCoord(oldPoint) : [0, 0]
  55180. newPoint = polar.pointToCoord(newPoint)
  55181. if (axisModel.mainType === 'radiusAxis') {
  55182. ret.pixel = newPoint[0] - oldPoint[0] // ret.pixelLength = Math.abs(radiusExtent[1] - radiusExtent[0]);
  55183. // ret.pixelStart = Math.min(radiusExtent[0], radiusExtent[1]);
  55184. ret.pixelLength = radiusExtent[1] - radiusExtent[0]
  55185. ret.pixelStart = radiusExtent[0]
  55186. ret.signal = axis.inverse ? 1 : -1
  55187. } else {
  55188. // 'angleAxis'
  55189. ret.pixel = newPoint[1] - oldPoint[1] // ret.pixelLength = Math.abs(angleExtent[1] - angleExtent[0]);
  55190. // ret.pixelStart = Math.min(angleExtent[0], angleExtent[1]);
  55191. ret.pixelLength = angleExtent[1] - angleExtent[0]
  55192. ret.pixelStart = angleExtent[0]
  55193. ret.signal = axis.inverse ? -1 : 1
  55194. }
  55195. return ret
  55196. },
  55197. singleAxis: function singleAxis(
  55198. oldPoint,
  55199. newPoint,
  55200. axisModel,
  55201. controller,
  55202. coordSysInfo
  55203. ) {
  55204. var axis = axisModel.axis
  55205. var rect = coordSysInfo.model.coordinateSystem.getRect()
  55206. var ret = {}
  55207. oldPoint = oldPoint || [0, 0]
  55208. if (axis.orient === 'horizontal') {
  55209. ret.pixel = newPoint[0] - oldPoint[0]
  55210. ret.pixelLength = rect.width
  55211. ret.pixelStart = rect.x
  55212. ret.signal = axis.inverse ? 1 : -1
  55213. } else {
  55214. // 'vertical'
  55215. ret.pixel = newPoint[1] - oldPoint[1]
  55216. ret.pixelLength = rect.height
  55217. ret.pixelStart = rect.y
  55218. ret.signal = axis.inverse ? -1 : 1
  55219. }
  55220. return ret
  55221. }
  55222. }
  55223. var InsideZoomView$1 = InsideZoomView
  55224. function install$5(registers) {
  55225. installCommon(registers)
  55226. registers.registerComponentModel(InsideZoomModel$1)
  55227. registers.registerComponentView(InsideZoomView$1)
  55228. installDataZoomRoamProcessor(registers)
  55229. }
  55230. var SliderZoomModel = /** @class */ (function (_super) {
  55231. __extends(SliderZoomModel, _super)
  55232. function SliderZoomModel() {
  55233. var _this =
  55234. (_super !== null && _super.apply(this, arguments)) || this
  55235. _this.type = SliderZoomModel.type
  55236. return _this
  55237. }
  55238. SliderZoomModel.type = 'dataZoom.slider'
  55239. SliderZoomModel.layoutMode = 'box'
  55240. SliderZoomModel.defaultOption = inheritDefaultOption(
  55241. DataZoomModel$1.defaultOption,
  55242. {
  55243. show: true, // deault value can only be drived in view stage.
  55244. right: 'ph',
  55245. top: 'ph',
  55246. width: 'ph',
  55247. height: 'ph',
  55248. left: null,
  55249. bottom: null,
  55250. borderColor: '#d2dbee',
  55251. borderRadius: 3,
  55252. backgroundColor: 'rgba(47,69,84,0)', // dataBackgroundColor: '#ddd',
  55253. dataBackground: {
  55254. lineStyle: { color: '#d2dbee', width: 0.5 },
  55255. areaStyle: { color: '#d2dbee', opacity: 0.2 }
  55256. },
  55257. selectedDataBackground: {
  55258. lineStyle: { color: '#8fb0f7', width: 0.5 },
  55259. areaStyle: { color: '#8fb0f7', opacity: 0.2 }
  55260. }, // Color of selected window.
  55261. fillerColor: 'rgba(135,175,274,0.2)',
  55262. handleIcon:
  55263. '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', // Percent of the slider height
  55264. handleSize: '100%',
  55265. handleStyle: { color: '#fff', borderColor: '#ACB8D1' },
  55266. moveHandleSize: 7,
  55267. moveHandleIcon:
  55268. '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',
  55269. moveHandleStyle: { color: '#D2DBEE', opacity: 0.7 },
  55270. showDetail: true,
  55271. showDataShadow: 'auto',
  55272. realtime: true,
  55273. zoomLock: false,
  55274. textStyle: { color: '#6E7079' },
  55275. brushSelect: true,
  55276. brushStyle: { color: 'rgba(135,175,274,0.15)' },
  55277. emphasis: {
  55278. handleStyle: { borderColor: '#8FB0F7' },
  55279. moveHandleStyle: { color: '#8FB0F7' }
  55280. }
  55281. }
  55282. )
  55283. return SliderZoomModel
  55284. })(DataZoomModel$1)
  55285. var SliderZoomModel$1 = SliderZoomModel
  55286. var Rect = Rect$2 // Constants
  55287. var DEFAULT_LOCATION_EDGE_GAP = 7
  55288. var DEFAULT_FRAME_BORDER_WIDTH = 1
  55289. var DEFAULT_FILLER_SIZE = 30
  55290. var DEFAULT_MOVE_HANDLE_SIZE = 7
  55291. var HORIZONTAL = 'horizontal'
  55292. var VERTICAL = 'vertical'
  55293. var LABEL_GAP = 5
  55294. var SHOW_DATA_SHADOW_SERIES_TYPE = [
  55295. 'line',
  55296. 'bar',
  55297. 'candlestick',
  55298. 'scatter'
  55299. ]
  55300. var REALTIME_ANIMATION_CONFIG = {
  55301. easing: 'cubicOut',
  55302. duration: 100,
  55303. delay: 0
  55304. }
  55305. var SliderZoomView = /** @class */ (function (_super) {
  55306. __extends(SliderZoomView, _super)
  55307. function SliderZoomView() {
  55308. var _this =
  55309. (_super !== null && _super.apply(this, arguments)) || this
  55310. _this.type = SliderZoomView.type
  55311. _this._displayables = {}
  55312. return _this
  55313. }
  55314. SliderZoomView.prototype.init = function (ecModel, api) {
  55315. this.api = api // A unique handler for each dataZoom component
  55316. this._onBrush = bind$1(this._onBrush, this)
  55317. this._onBrushEnd = bind$1(this._onBrushEnd, this)
  55318. }
  55319. SliderZoomView.prototype.render = function (
  55320. dataZoomModel,
  55321. ecModel,
  55322. api,
  55323. payload
  55324. ) {
  55325. _super.prototype.render.apply(this, arguments)
  55326. createOrUpdate(
  55327. this,
  55328. '_dispatchZoomAction',
  55329. dataZoomModel.get('throttle'),
  55330. 'fixRate'
  55331. )
  55332. this._orient = dataZoomModel.getOrient()
  55333. if (dataZoomModel.get('show') === false) {
  55334. this.group.removeAll()
  55335. return
  55336. }
  55337. if (dataZoomModel.noTarget()) {
  55338. this._clear()
  55339. this.group.removeAll()
  55340. return
  55341. } // Notice: this._resetInterval() should not be executed when payload.type
  55342. // is 'dataZoom', origin this._range should be maintained, otherwise 'pan'
  55343. // or 'zoom' info will be missed because of 'throttle' of this.dispatchAction,
  55344. if (
  55345. !payload ||
  55346. payload.type !== 'dataZoom' ||
  55347. payload.from !== this.uid
  55348. ) {
  55349. this._buildView()
  55350. }
  55351. this._updateView()
  55352. }
  55353. SliderZoomView.prototype.dispose = function () {
  55354. this._clear()
  55355. _super.prototype.dispose.apply(this, arguments)
  55356. }
  55357. SliderZoomView.prototype._clear = function () {
  55358. clear$1(this, '_dispatchZoomAction')
  55359. var zr = this.api.getZr()
  55360. zr.off('mousemove', this._onBrush)
  55361. zr.off('mouseup', this._onBrushEnd)
  55362. }
  55363. SliderZoomView.prototype._buildView = function () {
  55364. var thisGroup = this.group
  55365. thisGroup.removeAll()
  55366. this._brushing = false
  55367. this._displayables.brushRect = null
  55368. this._resetLocation()
  55369. this._resetInterval()
  55370. var barGroup = (this._displayables.sliderGroup = new Group$3())
  55371. this._renderBackground()
  55372. this._renderHandle()
  55373. this._renderDataShadow()
  55374. thisGroup.add(barGroup)
  55375. this._positionGroup()
  55376. }
  55377. SliderZoomView.prototype._resetLocation = function () {
  55378. var dataZoomModel = this.dataZoomModel
  55379. var api = this.api
  55380. var showMoveHandle = dataZoomModel.get('brushSelect')
  55381. var moveHandleSize = showMoveHandle ? DEFAULT_MOVE_HANDLE_SIZE : 0 // If some of x/y/width/height are not specified,
  55382. // auto-adapt according to target grid.
  55383. var coordRect = this._findCoordRect()
  55384. var ecSize = { width: api.getWidth(), height: api.getHeight() } // Default align by coordinate system rect.
  55385. var positionInfo =
  55386. this._orient === HORIZONTAL
  55387. ? {
  55388. // Why using 'right', because right should be used in vertical,
  55389. // and it is better to be consistent for dealing with position param merge.
  55390. right: ecSize.width - coordRect.x - coordRect.width,
  55391. top:
  55392. ecSize.height -
  55393. DEFAULT_FILLER_SIZE -
  55394. DEFAULT_LOCATION_EDGE_GAP -
  55395. moveHandleSize,
  55396. width: coordRect.width,
  55397. height: DEFAULT_FILLER_SIZE
  55398. }
  55399. : {
  55400. right: DEFAULT_LOCATION_EDGE_GAP,
  55401. top: coordRect.y,
  55402. width: DEFAULT_FILLER_SIZE,
  55403. height: coordRect.height
  55404. } // Do not write back to option and replace value 'ph', because
  55405. // the 'ph' value should be recalculated when resize.
  55406. var layoutParams = getLayoutParams(dataZoomModel.option) // Replace the placeholder value.
  55407. each$7(['right', 'top', 'width', 'height'], function (name) {
  55408. if (layoutParams[name] === 'ph') {
  55409. layoutParams[name] = positionInfo[name]
  55410. }
  55411. })
  55412. var layoutRect = getLayoutRect(layoutParams, ecSize)
  55413. this._location = { x: layoutRect.x, y: layoutRect.y }
  55414. this._size = [layoutRect.width, layoutRect.height]
  55415. this._orient === VERTICAL && this._size.reverse()
  55416. }
  55417. SliderZoomView.prototype._positionGroup = function () {
  55418. var thisGroup = this.group
  55419. var location = this._location
  55420. var orient = this._orient // Just use the first axis to determine mapping.
  55421. var targetAxisModel = this.dataZoomModel.getFirstTargetAxisModel()
  55422. var inverse = targetAxisModel && targetAxisModel.get('inverse')
  55423. var sliderGroup = this._displayables.sliderGroup
  55424. var otherAxisInverse = (this._dataShadowInfo || {})
  55425. .otherAxisInverse // Transform barGroup.
  55426. sliderGroup.attr(
  55427. orient === HORIZONTAL && !inverse
  55428. ? { scaleY: otherAxisInverse ? 1 : -1, scaleX: 1 }
  55429. : orient === HORIZONTAL && inverse
  55430. ? { scaleY: otherAxisInverse ? 1 : -1, scaleX: -1 }
  55431. : orient === VERTICAL && !inverse
  55432. ? {
  55433. scaleY: otherAxisInverse ? -1 : 1,
  55434. scaleX: 1,
  55435. rotation: Math.PI / 2
  55436. } // Dont use Math.PI, considering shadow direction.
  55437. : {
  55438. scaleY: otherAxisInverse ? -1 : 1,
  55439. scaleX: -1,
  55440. rotation: Math.PI / 2
  55441. }
  55442. ) // Position barGroup
  55443. var rect = thisGroup.getBoundingRect([sliderGroup])
  55444. thisGroup.x = location.x - rect.x
  55445. thisGroup.y = location.y - rect.y
  55446. thisGroup.markRedraw()
  55447. }
  55448. SliderZoomView.prototype._getViewExtent = function () {
  55449. return [0, this._size[0]]
  55450. }
  55451. SliderZoomView.prototype._renderBackground = function () {
  55452. var dataZoomModel = this.dataZoomModel
  55453. var size = this._size
  55454. var barGroup = this._displayables.sliderGroup
  55455. var brushSelect = dataZoomModel.get('brushSelect')
  55456. barGroup.add(
  55457. new Rect({
  55458. silent: true,
  55459. shape: { x: 0, y: 0, width: size[0], height: size[1] },
  55460. style: { fill: dataZoomModel.get('backgroundColor') },
  55461. z2: -40
  55462. })
  55463. ) // Click panel, over shadow, below handles.
  55464. var clickPanel = new Rect({
  55465. shape: { x: 0, y: 0, width: size[0], height: size[1] },
  55466. style: { fill: 'transparent' },
  55467. z2: 0,
  55468. onclick: bind$1(this._onClickPanel, this)
  55469. })
  55470. var zr = this.api.getZr()
  55471. if (brushSelect) {
  55472. clickPanel.on('mousedown', this._onBrushStart, this)
  55473. clickPanel.cursor = 'crosshair'
  55474. zr.on('mousemove', this._onBrush)
  55475. zr.on('mouseup', this._onBrushEnd)
  55476. } else {
  55477. zr.off('mousemove', this._onBrush)
  55478. zr.off('mouseup', this._onBrushEnd)
  55479. }
  55480. barGroup.add(clickPanel)
  55481. }
  55482. SliderZoomView.prototype._renderDataShadow = function () {
  55483. var info = (this._dataShadowInfo = this._prepareDataShadowInfo())
  55484. this._displayables.dataShadowSegs = []
  55485. if (!info) {
  55486. return
  55487. }
  55488. var size = this._size
  55489. var oldSize = this._shadowSize || []
  55490. var seriesModel = info.series
  55491. var data = seriesModel.getRawData()
  55492. var otherDim = seriesModel.getShadowDim
  55493. ? seriesModel.getShadowDim() // @see candlestick
  55494. : info.otherDim
  55495. if (otherDim == null) {
  55496. return
  55497. }
  55498. var polygonPts = this._shadowPolygonPts
  55499. var polylinePts = this._shadowPolylinePts // Not re-render if data doesn't change.
  55500. if (
  55501. data !== this._shadowData ||
  55502. otherDim !== this._shadowDim ||
  55503. size[0] !== oldSize[0] ||
  55504. size[1] !== oldSize[1]
  55505. ) {
  55506. var otherDataExtent_1 = data.getDataExtent(otherDim) // Nice extent.
  55507. var otherOffset =
  55508. (otherDataExtent_1[1] - otherDataExtent_1[0]) * 0.3
  55509. otherDataExtent_1 = [
  55510. otherDataExtent_1[0] - otherOffset,
  55511. otherDataExtent_1[1] + otherOffset
  55512. ]
  55513. var otherShadowExtent_1 = [0, size[1]]
  55514. var thisShadowExtent = [0, size[0]]
  55515. var areaPoints_1 = [
  55516. [size[0], 0],
  55517. [0, 0]
  55518. ]
  55519. var linePoints_1 = []
  55520. var step_1 = thisShadowExtent[1] / (data.count() - 1)
  55521. var thisCoord_1 = 0 // Optimize for large data shadow
  55522. var stride_1 = Math.round(data.count() / size[0])
  55523. var lastIsEmpty_1
  55524. data.each([otherDim], function (value, index) {
  55525. if (stride_1 > 0 && index % stride_1) {
  55526. thisCoord_1 += step_1
  55527. return
  55528. } // FIXME
  55529. // Should consider axis.min/axis.max when drawing dataShadow.
  55530. // FIXME
  55531. // 应该使用统一的空判断?还是在list里进行空判断?
  55532. var isEmpty = value == null || isNaN(value) || value === '' // See #4235.
  55533. var otherCoord = isEmpty
  55534. ? 0
  55535. : linearMap(
  55536. value,
  55537. otherDataExtent_1,
  55538. otherShadowExtent_1,
  55539. true
  55540. ) // Attempt to draw data shadow precisely when there are empty value.
  55541. if (isEmpty && !lastIsEmpty_1 && index) {
  55542. areaPoints_1.push([
  55543. areaPoints_1[areaPoints_1.length - 1][0],
  55544. 0
  55545. ])
  55546. linePoints_1.push([
  55547. linePoints_1[linePoints_1.length - 1][0],
  55548. 0
  55549. ])
  55550. } else if (!isEmpty && lastIsEmpty_1) {
  55551. areaPoints_1.push([thisCoord_1, 0])
  55552. linePoints_1.push([thisCoord_1, 0])
  55553. }
  55554. areaPoints_1.push([thisCoord_1, otherCoord])
  55555. linePoints_1.push([thisCoord_1, otherCoord])
  55556. thisCoord_1 += step_1
  55557. lastIsEmpty_1 = isEmpty
  55558. })
  55559. polygonPts = this._shadowPolygonPts = areaPoints_1
  55560. polylinePts = this._shadowPolylinePts = linePoints_1
  55561. }
  55562. this._shadowData = data
  55563. this._shadowDim = otherDim
  55564. this._shadowSize = [size[0], size[1]]
  55565. var dataZoomModel = this.dataZoomModel
  55566. function createDataShadowGroup(isSelectedArea) {
  55567. var model = dataZoomModel.getModel(
  55568. isSelectedArea ? 'selectedDataBackground' : 'dataBackground'
  55569. )
  55570. var group = new Group$3()
  55571. var polygon = new Polygon$1({
  55572. shape: { points: polygonPts },
  55573. segmentIgnoreThreshold: 1,
  55574. style: model.getModel('areaStyle').getAreaStyle(),
  55575. silent: true,
  55576. z2: -20
  55577. })
  55578. var polyline = new Polyline$1({
  55579. shape: { points: polylinePts },
  55580. segmentIgnoreThreshold: 1,
  55581. style: model.getModel('lineStyle').getLineStyle(),
  55582. silent: true,
  55583. z2: -19
  55584. })
  55585. group.add(polygon)
  55586. group.add(polyline)
  55587. return group
  55588. } // let dataBackgroundModel = dataZoomModel.getModel('dataBackground');
  55589. for (var i = 0; i < 3; i++) {
  55590. var group = createDataShadowGroup(i === 1)
  55591. this._displayables.sliderGroup.add(group)
  55592. this._displayables.dataShadowSegs.push(group)
  55593. }
  55594. }
  55595. SliderZoomView.prototype._prepareDataShadowInfo = function () {
  55596. var dataZoomModel = this.dataZoomModel
  55597. var showDataShadow = dataZoomModel.get('showDataShadow')
  55598. if (showDataShadow === false) {
  55599. return
  55600. } // Find a representative series.
  55601. var result
  55602. var ecModel = this.ecModel
  55603. dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
  55604. var seriesModels = dataZoomModel
  55605. .getAxisProxy(axisDim, axisIndex)
  55606. .getTargetSeriesModels()
  55607. each$7(
  55608. seriesModels,
  55609. function (seriesModel) {
  55610. if (result) {
  55611. return
  55612. }
  55613. if (
  55614. showDataShadow !== true &&
  55615. indexOf(
  55616. SHOW_DATA_SHADOW_SERIES_TYPE,
  55617. seriesModel.get('type')
  55618. ) < 0
  55619. ) {
  55620. return
  55621. }
  55622. var thisAxis = ecModel.getComponent(
  55623. getAxisMainType(axisDim),
  55624. axisIndex
  55625. ).axis
  55626. var otherDim = getOtherDim(axisDim)
  55627. var otherAxisInverse
  55628. var coordSys = seriesModel.coordinateSystem
  55629. if (otherDim != null && coordSys.getOtherAxis) {
  55630. otherAxisInverse = coordSys.getOtherAxis(thisAxis).inverse
  55631. }
  55632. otherDim = seriesModel.getData().mapDimension(otherDim)
  55633. result = {
  55634. thisAxis: thisAxis,
  55635. series: seriesModel,
  55636. thisDim: axisDim,
  55637. otherDim: otherDim,
  55638. otherAxisInverse: otherAxisInverse
  55639. }
  55640. },
  55641. this
  55642. )
  55643. }, this)
  55644. return result
  55645. }
  55646. SliderZoomView.prototype._renderHandle = function () {
  55647. var thisGroup = this.group
  55648. var displayables = this._displayables
  55649. var handles = (displayables.handles = [null, null])
  55650. var handleLabels = (displayables.handleLabels = [null, null])
  55651. var sliderGroup = this._displayables.sliderGroup
  55652. var size = this._size
  55653. var dataZoomModel = this.dataZoomModel
  55654. var api = this.api
  55655. var borderRadius = dataZoomModel.get('borderRadius') || 0
  55656. var brushSelect = dataZoomModel.get('brushSelect')
  55657. var filler = (displayables.filler = new Rect({
  55658. silent: brushSelect,
  55659. style: { fill: dataZoomModel.get('fillerColor') },
  55660. textConfig: { position: 'inside' }
  55661. }))
  55662. sliderGroup.add(filler) // Frame border.
  55663. sliderGroup.add(
  55664. new Rect({
  55665. silent: true,
  55666. subPixelOptimize: true,
  55667. shape: {
  55668. x: 0,
  55669. y: 0,
  55670. width: size[0],
  55671. height: size[1],
  55672. r: borderRadius
  55673. },
  55674. style: {
  55675. // deprecated option
  55676. stroke:
  55677. dataZoomModel.get('dataBackgroundColor') ||
  55678. dataZoomModel.get('borderColor'),
  55679. lineWidth: DEFAULT_FRAME_BORDER_WIDTH,
  55680. fill: 'rgba(0,0,0,0)'
  55681. }
  55682. })
  55683. ) // Left and right handle to resize
  55684. each$7(
  55685. [0, 1],
  55686. function (handleIndex) {
  55687. var iconStr = dataZoomModel.get('handleIcon')
  55688. if (
  55689. !symbolBuildProxies[iconStr] &&
  55690. iconStr.indexOf('path://') < 0 &&
  55691. iconStr.indexOf('image://') < 0
  55692. ) {
  55693. // Compatitable with the old icon parsers. Which can use a path string without path://
  55694. iconStr = 'path://' + iconStr
  55695. }
  55696. var path = createSymbol(iconStr, -1, 0, 2, 2, null, true)
  55697. path.attr({
  55698. cursor: getCursor(this._orient),
  55699. draggable: true,
  55700. drift: bind$1(this._onDragMove, this, handleIndex),
  55701. ondragend: bind$1(this._onDragEnd, this),
  55702. onmouseover: bind$1(this._showDataInfo, this, true),
  55703. onmouseout: bind$1(this._showDataInfo, this, false),
  55704. z2: 5
  55705. })
  55706. var bRect = path.getBoundingRect()
  55707. var handleSize = dataZoomModel.get('handleSize')
  55708. this._handleHeight = parsePercent(handleSize, this._size[1])
  55709. this._handleWidth =
  55710. (bRect.width / bRect.height) * this._handleHeight
  55711. path.setStyle(
  55712. dataZoomModel.getModel('handleStyle').getItemStyle()
  55713. )
  55714. path.style.strokeNoScale = true
  55715. path.rectHover = true
  55716. path.ensureState('emphasis').style = dataZoomModel
  55717. .getModel(['emphasis', 'handleStyle'])
  55718. .getItemStyle()
  55719. enableHoverEmphasis(path)
  55720. var handleColor = dataZoomModel.get('handleColor') // deprecated option
  55721. // Compatitable with previous version
  55722. if (handleColor != null) {
  55723. path.style.fill = handleColor
  55724. }
  55725. sliderGroup.add((handles[handleIndex] = path))
  55726. var textStyleModel = dataZoomModel.getModel('textStyle')
  55727. thisGroup.add(
  55728. (handleLabels[handleIndex] = new ZRText$1({
  55729. silent: true,
  55730. invisible: true,
  55731. style: createTextStyle(textStyleModel, {
  55732. x: 0,
  55733. y: 0,
  55734. text: '',
  55735. verticalAlign: 'middle',
  55736. align: 'center',
  55737. fill: textStyleModel.getTextColor(),
  55738. font: textStyleModel.getFont()
  55739. }),
  55740. z2: 10
  55741. }))
  55742. )
  55743. },
  55744. this
  55745. ) // Handle to move. Only visible when brushSelect is set true.
  55746. var actualMoveZone = filler
  55747. if (brushSelect) {
  55748. var moveHandleHeight = parsePercent(
  55749. dataZoomModel.get('moveHandleSize'),
  55750. size[1]
  55751. )
  55752. var moveHandle_1 = (displayables.moveHandle = new Rect$2({
  55753. style: dataZoomModel
  55754. .getModel('moveHandleStyle')
  55755. .getItemStyle(),
  55756. silent: true,
  55757. shape: {
  55758. r: [0, 0, 2, 2],
  55759. y: size[1] - 0.5,
  55760. height: moveHandleHeight
  55761. }
  55762. }))
  55763. var iconSize = moveHandleHeight * 0.8
  55764. var moveHandleIcon = (displayables.moveHandleIcon =
  55765. createSymbol(
  55766. dataZoomModel.get('moveHandleIcon'),
  55767. -iconSize / 2,
  55768. -iconSize / 2,
  55769. iconSize,
  55770. iconSize,
  55771. '#fff',
  55772. true
  55773. ))
  55774. moveHandleIcon.silent = true
  55775. moveHandleIcon.y = size[1] + moveHandleHeight / 2 - 0.5
  55776. moveHandle_1.ensureState('emphasis').style = dataZoomModel
  55777. .getModel(['emphasis', 'moveHandleStyle'])
  55778. .getItemStyle()
  55779. var moveZoneExpandSize = Math.min(
  55780. size[1] / 2,
  55781. Math.max(moveHandleHeight, 10)
  55782. )
  55783. actualMoveZone = displayables.moveZone = new Rect$2({
  55784. invisible: true,
  55785. shape: {
  55786. y: size[1] - moveZoneExpandSize,
  55787. height: moveHandleHeight + moveZoneExpandSize
  55788. }
  55789. })
  55790. actualMoveZone
  55791. .on('mouseover', function () {
  55792. api.enterEmphasis(moveHandle_1)
  55793. })
  55794. .on('mouseout', function () {
  55795. api.leaveEmphasis(moveHandle_1)
  55796. })
  55797. sliderGroup.add(moveHandle_1)
  55798. sliderGroup.add(moveHandleIcon)
  55799. sliderGroup.add(actualMoveZone)
  55800. }
  55801. actualMoveZone.attr({
  55802. draggable: true,
  55803. cursor: getCursor(this._orient),
  55804. drift: bind$1(this._onDragMove, this, 'all'),
  55805. ondragstart: bind$1(this._showDataInfo, this, true),
  55806. ondragend: bind$1(this._onDragEnd, this),
  55807. onmouseover: bind$1(this._showDataInfo, this, true),
  55808. onmouseout: bind$1(this._showDataInfo, this, false)
  55809. })
  55810. }
  55811. SliderZoomView.prototype._resetInterval = function () {
  55812. var range = (this._range = this.dataZoomModel.getPercentRange())
  55813. var viewExtent = this._getViewExtent()
  55814. this._handleEnds = [
  55815. linearMap(range[0], [0, 100], viewExtent, true),
  55816. linearMap(range[1], [0, 100], viewExtent, true)
  55817. ]
  55818. }
  55819. SliderZoomView.prototype._updateInterval = function (
  55820. handleIndex,
  55821. delta
  55822. ) {
  55823. var dataZoomModel = this.dataZoomModel
  55824. var handleEnds = this._handleEnds
  55825. var viewExtend = this._getViewExtent()
  55826. var minMaxSpan = dataZoomModel
  55827. .findRepresentativeAxisProxy()
  55828. .getMinMaxSpan()
  55829. var percentExtent = [0, 100]
  55830. sliderMove(
  55831. delta,
  55832. handleEnds,
  55833. viewExtend,
  55834. dataZoomModel.get('zoomLock') ? 'all' : handleIndex,
  55835. minMaxSpan.minSpan != null
  55836. ? linearMap(
  55837. minMaxSpan.minSpan,
  55838. percentExtent,
  55839. viewExtend,
  55840. true
  55841. )
  55842. : null,
  55843. minMaxSpan.maxSpan != null
  55844. ? linearMap(
  55845. minMaxSpan.maxSpan,
  55846. percentExtent,
  55847. viewExtend,
  55848. true
  55849. )
  55850. : null
  55851. )
  55852. var lastRange = this._range
  55853. var range = (this._range = asc$1([
  55854. linearMap(handleEnds[0], viewExtend, percentExtent, true),
  55855. linearMap(handleEnds[1], viewExtend, percentExtent, true)
  55856. ]))
  55857. return (
  55858. !lastRange ||
  55859. lastRange[0] !== range[0] ||
  55860. lastRange[1] !== range[1]
  55861. )
  55862. }
  55863. SliderZoomView.prototype._updateView = function (nonRealtime) {
  55864. var displaybles = this._displayables
  55865. var handleEnds = this._handleEnds
  55866. var handleInterval = asc$1(handleEnds.slice())
  55867. var size = this._size
  55868. each$7(
  55869. [0, 1],
  55870. function (handleIndex) {
  55871. // Handles
  55872. var handle = displaybles.handles[handleIndex]
  55873. var handleHeight = this._handleHeight
  55874. handle.attr({
  55875. scaleX: handleHeight / 2,
  55876. scaleY: handleHeight / 2, // This is a trick, by adding an extra tiny offset to let the default handle's end point align to the drag window.
  55877. // NOTE: It may affect some custom shapes a bit. But we prefer to have better result by default.
  55878. x: handleEnds[handleIndex] + (handleIndex ? -1 : 1),
  55879. y: size[1] / 2 - handleHeight / 2
  55880. })
  55881. },
  55882. this
  55883. ) // Filler
  55884. displaybles.filler.setShape({
  55885. x: handleInterval[0],
  55886. y: 0,
  55887. width: handleInterval[1] - handleInterval[0],
  55888. height: size[1]
  55889. })
  55890. var viewExtent = {
  55891. x: handleInterval[0],
  55892. width: handleInterval[1] - handleInterval[0]
  55893. } // Move handle
  55894. if (displaybles.moveHandle) {
  55895. displaybles.moveHandle.setShape(viewExtent)
  55896. displaybles.moveZone.setShape(viewExtent) // Force update path on the invisible object
  55897. displaybles.moveZone.getBoundingRect()
  55898. displaybles.moveHandleIcon &&
  55899. displaybles.moveHandleIcon.attr(
  55900. 'x',
  55901. viewExtent.x + viewExtent.width / 2
  55902. )
  55903. } // update clip path of shadow.
  55904. var dataShadowSegs = displaybles.dataShadowSegs
  55905. var segIntervals = [
  55906. 0,
  55907. handleInterval[0],
  55908. handleInterval[1],
  55909. size[0]
  55910. ]
  55911. for (var i = 0; i < dataShadowSegs.length; i++) {
  55912. var segGroup = dataShadowSegs[i]
  55913. var clipPath = segGroup.getClipPath()
  55914. if (!clipPath) {
  55915. clipPath = new Rect$2()
  55916. segGroup.setClipPath(clipPath)
  55917. }
  55918. clipPath.setShape({
  55919. x: segIntervals[i],
  55920. y: 0,
  55921. width: segIntervals[i + 1] - segIntervals[i],
  55922. height: size[1]
  55923. })
  55924. }
  55925. this._updateDataInfo(nonRealtime)
  55926. }
  55927. SliderZoomView.prototype._updateDataInfo = function (nonRealtime) {
  55928. var dataZoomModel = this.dataZoomModel
  55929. var displaybles = this._displayables
  55930. var handleLabels = displaybles.handleLabels
  55931. var orient = this._orient
  55932. var labelTexts = ['', ''] // FIXME
  55933. // date型,支持formatter,autoformatter(ec2 date.getAutoFormatter)
  55934. if (dataZoomModel.get('showDetail')) {
  55935. var axisProxy = dataZoomModel.findRepresentativeAxisProxy()
  55936. if (axisProxy) {
  55937. var axis = axisProxy.getAxisModel().axis
  55938. var range = this._range
  55939. var dataInterval = nonRealtime // See #4434, data and axis are not processed and reset yet in non-realtime mode.
  55940. ? axisProxy.calculateDataWindow({
  55941. start: range[0],
  55942. end: range[1]
  55943. }).valueWindow
  55944. : axisProxy.getDataValueWindow()
  55945. labelTexts = [
  55946. this._formatLabel(dataInterval[0], axis),
  55947. this._formatLabel(dataInterval[1], axis)
  55948. ]
  55949. }
  55950. }
  55951. var orderedHandleEnds = asc$1(this._handleEnds.slice())
  55952. setLabel.call(this, 0)
  55953. setLabel.call(this, 1)
  55954. function setLabel(handleIndex) {
  55955. // Label
  55956. // Text should not transform by barGroup.
  55957. // Ignore handlers transform
  55958. var barTransform = getTransform$1(
  55959. displaybles.handles[handleIndex].parent,
  55960. this.group
  55961. )
  55962. var direction = transformDirection(
  55963. handleIndex === 0 ? 'right' : 'left',
  55964. barTransform
  55965. )
  55966. var offset = this._handleWidth / 2 + LABEL_GAP
  55967. var textPoint = applyTransform(
  55968. [
  55969. orderedHandleEnds[handleIndex] +
  55970. (handleIndex === 0 ? -offset : offset),
  55971. this._size[1] / 2
  55972. ],
  55973. barTransform
  55974. )
  55975. handleLabels[handleIndex].setStyle({
  55976. x: textPoint[0],
  55977. y: textPoint[1],
  55978. verticalAlign: orient === HORIZONTAL ? 'middle' : direction,
  55979. align: orient === HORIZONTAL ? direction : 'center',
  55980. text: labelTexts[handleIndex]
  55981. })
  55982. }
  55983. }
  55984. SliderZoomView.prototype._formatLabel = function (value, axis) {
  55985. var dataZoomModel = this.dataZoomModel
  55986. var labelFormatter = dataZoomModel.get('labelFormatter')
  55987. var labelPrecision = dataZoomModel.get('labelPrecision')
  55988. if (labelPrecision == null || labelPrecision === 'auto') {
  55989. labelPrecision = axis.getPixelPrecision()
  55990. }
  55991. var valueStr =
  55992. value == null || isNaN(value)
  55993. ? '' // FIXME Glue code
  55994. : axis.type === 'category' || axis.type === 'time'
  55995. ? axis.scale.getLabel({ value: Math.round(value) }) // param of toFixed should less then 20.
  55996. : value.toFixed(Math.min(labelPrecision, 20))
  55997. return isFunction(labelFormatter)
  55998. ? labelFormatter(value, valueStr)
  55999. : isString(labelFormatter)
  56000. ? labelFormatter.replace('{value}', valueStr)
  56001. : valueStr
  56002. }
  56003. /**
  56004. * @param showOrHide true: show, false: hide
  56005. */ SliderZoomView.prototype._showDataInfo = function (showOrHide) {
  56006. // Always show when drgging.
  56007. showOrHide = this._dragging || showOrHide
  56008. var displayables = this._displayables
  56009. var handleLabels = displayables.handleLabels
  56010. handleLabels[0].attr('invisible', !showOrHide)
  56011. handleLabels[1].attr('invisible', !showOrHide) // Highlight move handle
  56012. displayables.moveHandle &&
  56013. this.api[showOrHide ? 'enterEmphasis' : 'leaveEmphasis'](
  56014. displayables.moveHandle,
  56015. 1
  56016. )
  56017. }
  56018. SliderZoomView.prototype._onDragMove = function (
  56019. handleIndex,
  56020. dx,
  56021. dy,
  56022. event
  56023. ) {
  56024. this._dragging = true // For mobile device, prevent screen slider on the button.
  56025. stop(event.event) // Transform dx, dy to bar coordination.
  56026. var barTransform =
  56027. this._displayables.sliderGroup.getLocalTransform()
  56028. var vertex = applyTransform([dx, dy], barTransform, true)
  56029. var changed = this._updateInterval(handleIndex, vertex[0])
  56030. var realtime = this.dataZoomModel.get('realtime')
  56031. this._updateView(!realtime) // Avoid dispatch dataZoom repeatly but range not changed,
  56032. // which cause bad visual effect when progressive enabled.
  56033. changed && realtime && this._dispatchZoomAction(true)
  56034. }
  56035. SliderZoomView.prototype._onDragEnd = function () {
  56036. this._dragging = false
  56037. this._showDataInfo(false) // While in realtime mode and stream mode, dispatch action when
  56038. // drag end will cause the whole view rerender, which is unnecessary.
  56039. var realtime = this.dataZoomModel.get('realtime')
  56040. !realtime && this._dispatchZoomAction(false)
  56041. }
  56042. SliderZoomView.prototype._onClickPanel = function (e) {
  56043. var size = this._size
  56044. var localPoint =
  56045. this._displayables.sliderGroup.transformCoordToLocal(
  56046. e.offsetX,
  56047. e.offsetY
  56048. )
  56049. if (
  56050. localPoint[0] < 0 ||
  56051. localPoint[0] > size[0] ||
  56052. localPoint[1] < 0 ||
  56053. localPoint[1] > size[1]
  56054. ) {
  56055. return
  56056. }
  56057. var handleEnds = this._handleEnds
  56058. var center = (handleEnds[0] + handleEnds[1]) / 2
  56059. var changed = this._updateInterval('all', localPoint[0] - center)
  56060. this._updateView()
  56061. changed && this._dispatchZoomAction(false)
  56062. }
  56063. SliderZoomView.prototype._onBrushStart = function (e) {
  56064. var x = e.offsetX
  56065. var y = e.offsetY
  56066. this._brushStart = new Point$1(x, y)
  56067. this._brushing = true
  56068. this._brushStartTime = +new Date() // this._updateBrushRect(x, y);
  56069. }
  56070. SliderZoomView.prototype._onBrushEnd = function (e) {
  56071. if (!this._brushing) {
  56072. return
  56073. }
  56074. var brushRect = this._displayables.brushRect
  56075. this._brushing = false
  56076. if (!brushRect) {
  56077. return
  56078. }
  56079. brushRect.attr('ignore', true)
  56080. var brushShape = brushRect.shape
  56081. var brushEndTime = +new Date() // console.log(brushEndTime - this._brushStartTime);
  56082. if (
  56083. brushEndTime - this._brushStartTime < 200 &&
  56084. Math.abs(brushShape.width) < 5
  56085. ) {
  56086. // Will treat it as a click
  56087. return
  56088. }
  56089. var viewExtend = this._getViewExtent()
  56090. var percentExtent = [0, 100]
  56091. this._range = asc$1([
  56092. linearMap(brushShape.x, viewExtend, percentExtent, true),
  56093. linearMap(
  56094. brushShape.x + brushShape.width,
  56095. viewExtend,
  56096. percentExtent,
  56097. true
  56098. )
  56099. ])
  56100. this._handleEnds = [brushShape.x, brushShape.x + brushShape.width]
  56101. this._updateView()
  56102. this._dispatchZoomAction(false)
  56103. }
  56104. SliderZoomView.prototype._onBrush = function (e) {
  56105. if (this._brushing) {
  56106. // For mobile device, prevent screen slider on the button.
  56107. stop(e.event)
  56108. this._updateBrushRect(e.offsetX, e.offsetY)
  56109. }
  56110. }
  56111. SliderZoomView.prototype._updateBrushRect = function (
  56112. mouseX,
  56113. mouseY
  56114. ) {
  56115. var displayables = this._displayables
  56116. var dataZoomModel = this.dataZoomModel
  56117. var brushRect = displayables.brushRect
  56118. if (!brushRect) {
  56119. brushRect = displayables.brushRect = new Rect({
  56120. silent: true,
  56121. style: dataZoomModel.getModel('brushStyle').getItemStyle()
  56122. })
  56123. displayables.sliderGroup.add(brushRect)
  56124. }
  56125. brushRect.attr('ignore', false)
  56126. var brushStart = this._brushStart
  56127. var sliderGroup = this._displayables.sliderGroup
  56128. var endPoint = sliderGroup.transformCoordToLocal(mouseX, mouseY)
  56129. var startPoint = sliderGroup.transformCoordToLocal(
  56130. brushStart.x,
  56131. brushStart.y
  56132. )
  56133. var size = this._size
  56134. endPoint[0] = Math.max(Math.min(size[0], endPoint[0]), 0)
  56135. brushRect.setShape({
  56136. x: startPoint[0],
  56137. y: 0,
  56138. width: endPoint[0] - startPoint[0],
  56139. height: size[1]
  56140. })
  56141. }
  56142. /**
  56143. * This action will be throttled.
  56144. */ SliderZoomView.prototype._dispatchZoomAction = function (
  56145. realtime
  56146. ) {
  56147. var range = this._range
  56148. this.api.dispatchAction({
  56149. type: 'dataZoom',
  56150. from: this.uid,
  56151. dataZoomId: this.dataZoomModel.id,
  56152. animation: realtime ? REALTIME_ANIMATION_CONFIG : null,
  56153. start: range[0],
  56154. end: range[1]
  56155. })
  56156. }
  56157. SliderZoomView.prototype._findCoordRect = function () {
  56158. // Find the grid coresponding to the first axis referred by dataZoom.
  56159. var rect
  56160. var coordSysInfoList = collectReferCoordSysModelInfo(
  56161. this.dataZoomModel
  56162. ).infoList
  56163. if (!rect && coordSysInfoList.length) {
  56164. var coordSys = coordSysInfoList[0].model.coordinateSystem
  56165. rect = coordSys.getRect && coordSys.getRect()
  56166. }
  56167. if (!rect) {
  56168. var width = this.api.getWidth()
  56169. var height = this.api.getHeight()
  56170. rect = {
  56171. x: width * 0.2,
  56172. y: height * 0.2,
  56173. width: width * 0.6,
  56174. height: height * 0.6
  56175. }
  56176. }
  56177. return rect
  56178. }
  56179. SliderZoomView.type = 'dataZoom.slider'
  56180. return SliderZoomView
  56181. })(DataZoomView$1)
  56182. function getOtherDim(thisDim) {
  56183. // FIXME
  56184. // 这个逻辑和getOtherAxis里一致,但是写在这里是否不好
  56185. var map = { x: 'y', y: 'x', radius: 'angle', angle: 'radius' }
  56186. return map[thisDim]
  56187. }
  56188. function getCursor(orient) {
  56189. return orient === 'vertical' ? 'ns-resize' : 'ew-resize'
  56190. }
  56191. var SliderZoomView$1 = SliderZoomView
  56192. function install$4(registers) {
  56193. registers.registerComponentModel(SliderZoomModel$1)
  56194. registers.registerComponentView(SliderZoomView$1)
  56195. installCommon(registers)
  56196. }
  56197. function install$3(registers) {
  56198. use(install$5)
  56199. use(install$4) // Do not install './dataZoomSelect',
  56200. // since it only work for toolbox dataZoom.
  56201. }
  56202. var RELATIONAL_EXPRESSION_OP_ALIAS_MAP = {
  56203. value: 'eq', // PENDING: not good for literal semantic?
  56204. '<': 'lt',
  56205. '<=': 'lte',
  56206. '>': 'gt',
  56207. '>=': 'gte',
  56208. '=': 'eq',
  56209. '!=': 'ne',
  56210. '<>': 'ne' // Might mileading for sake of the different between '==' and '===',
  56211. // So dont support them.
  56212. // '==': 'eq',
  56213. // '===': 'seq',
  56214. // '!==': 'sne'
  56215. // PENDING: Whether support some common alias "ge", "le", "neq"?
  56216. // ge: 'gte',
  56217. // le: 'lte',
  56218. // neq: 'ne',
  56219. } // type RelationalExpressionOpEvaluate = (tarVal: unknown, condVal: unknown) => boolean;
  56220. var RegExpEvaluator = /** @class */ (function () {
  56221. function RegExpEvaluator(rVal) {
  56222. // Support condVal: RegExp | string
  56223. var condValue = (this._condVal = isString(rVal)
  56224. ? new RegExp(rVal)
  56225. : isRegExp(rVal)
  56226. ? rVal
  56227. : null)
  56228. if (condValue == null) {
  56229. var errMsg = ''
  56230. throwError(errMsg)
  56231. }
  56232. }
  56233. RegExpEvaluator.prototype.evaluate = function (lVal) {
  56234. var type = _typeof(lVal)
  56235. return isString(type)
  56236. ? this._condVal.test(lVal)
  56237. : isNumber(type)
  56238. ? this._condVal.test(lVal + '')
  56239. : false
  56240. }
  56241. return RegExpEvaluator
  56242. })()
  56243. var ConstConditionInternal = /** @class */ (function () {
  56244. function ConstConditionInternal() {}
  56245. ConstConditionInternal.prototype.evaluate = function () {
  56246. return this.value
  56247. }
  56248. return ConstConditionInternal
  56249. })()
  56250. var AndConditionInternal = /** @class */ (function () {
  56251. function AndConditionInternal() {}
  56252. AndConditionInternal.prototype.evaluate = function () {
  56253. var children = this.children
  56254. for (var i = 0; i < children.length; i++) {
  56255. if (!children[i].evaluate()) {
  56256. return false
  56257. }
  56258. }
  56259. return true
  56260. }
  56261. return AndConditionInternal
  56262. })()
  56263. var OrConditionInternal = /** @class */ (function () {
  56264. function OrConditionInternal() {}
  56265. OrConditionInternal.prototype.evaluate = function () {
  56266. var children = this.children
  56267. for (var i = 0; i < children.length; i++) {
  56268. if (children[i].evaluate()) {
  56269. return true
  56270. }
  56271. }
  56272. return false
  56273. }
  56274. return OrConditionInternal
  56275. })()
  56276. var NotConditionInternal = /** @class */ (function () {
  56277. function NotConditionInternal() {}
  56278. NotConditionInternal.prototype.evaluate = function () {
  56279. return !this.child.evaluate()
  56280. }
  56281. return NotConditionInternal
  56282. })()
  56283. var RelationalConditionInternal = /** @class */ (function () {
  56284. function RelationalConditionInternal() {}
  56285. RelationalConditionInternal.prototype.evaluate = function () {
  56286. var needParse = !!this.valueParser // Call getValue with no `this`.
  56287. var getValue = this.getValue
  56288. var tarValRaw = getValue(this.valueGetterParam)
  56289. var tarValParsed = needParse ? this.valueParser(tarValRaw) : null // Relational cond follow "and" logic internally.
  56290. for (var i = 0; i < this.subCondList.length; i++) {
  56291. if (
  56292. !this.subCondList[i].evaluate(
  56293. needParse ? tarValParsed : tarValRaw
  56294. )
  56295. ) {
  56296. return false
  56297. }
  56298. }
  56299. return true
  56300. }
  56301. return RelationalConditionInternal
  56302. })()
  56303. function parseOption(exprOption, getters) {
  56304. if (exprOption === true || exprOption === false) {
  56305. var cond = new ConstConditionInternal()
  56306. cond.value = exprOption
  56307. return cond
  56308. }
  56309. var errMsg = ''
  56310. if (!isObjectNotArray(exprOption)) {
  56311. throwError(errMsg)
  56312. }
  56313. if (exprOption.and) {
  56314. return parseAndOrOption('and', exprOption, getters)
  56315. } else if (exprOption.or) {
  56316. return parseAndOrOption('or', exprOption, getters)
  56317. } else if (exprOption.not) {
  56318. return parseNotOption(exprOption, getters)
  56319. }
  56320. return parseRelationalOption(exprOption, getters)
  56321. }
  56322. function parseAndOrOption(op, exprOption, getters) {
  56323. var subOptionArr = exprOption[op]
  56324. var errMsg = ''
  56325. if (!isArray(subOptionArr)) {
  56326. throwError(errMsg)
  56327. }
  56328. if (!subOptionArr.length) {
  56329. throwError(errMsg)
  56330. }
  56331. var cond =
  56332. op === 'and'
  56333. ? new AndConditionInternal()
  56334. : new OrConditionInternal()
  56335. cond.children = map$1(subOptionArr, function (subOption) {
  56336. return parseOption(subOption, getters)
  56337. })
  56338. if (!cond.children.length) {
  56339. throwError(errMsg)
  56340. }
  56341. return cond
  56342. }
  56343. function parseNotOption(exprOption, getters) {
  56344. var subOption = exprOption.not
  56345. var errMsg = ''
  56346. if (!isObjectNotArray(subOption)) {
  56347. throwError(errMsg)
  56348. }
  56349. var cond = new NotConditionInternal()
  56350. cond.child = parseOption(subOption, getters)
  56351. if (!cond.child) {
  56352. throwError(errMsg)
  56353. }
  56354. return cond
  56355. }
  56356. function parseRelationalOption(exprOption, getters) {
  56357. var errMsg = ''
  56358. var valueGetterParam = getters.prepareGetValue(exprOption)
  56359. var subCondList = []
  56360. var exprKeys = keys(exprOption)
  56361. var parserName = exprOption.parser
  56362. var valueParser = parserName ? getRawValueParser(parserName) : null
  56363. for (var i = 0; i < exprKeys.length; i++) {
  56364. var keyRaw = exprKeys[i]
  56365. if (
  56366. keyRaw === 'parser' ||
  56367. getters.valueGetterAttrMap.get(keyRaw)
  56368. ) {
  56369. continue
  56370. }
  56371. var op = hasOwn(RELATIONAL_EXPRESSION_OP_ALIAS_MAP, keyRaw)
  56372. ? RELATIONAL_EXPRESSION_OP_ALIAS_MAP[keyRaw]
  56373. : keyRaw
  56374. var condValueRaw = exprOption[keyRaw]
  56375. var condValueParsed = valueParser
  56376. ? valueParser(condValueRaw)
  56377. : condValueRaw
  56378. var evaluator =
  56379. createFilterComparator(op, condValueParsed) ||
  56380. (op === 'reg' && new RegExpEvaluator(condValueParsed))
  56381. if (!evaluator) {
  56382. throwError(errMsg)
  56383. }
  56384. subCondList.push(evaluator)
  56385. }
  56386. if (!subCondList.length) {
  56387. throwError(errMsg)
  56388. }
  56389. var cond = new RelationalConditionInternal()
  56390. cond.valueGetterParam = valueGetterParam
  56391. cond.valueParser = valueParser
  56392. cond.getValue = getters.getValue
  56393. cond.subCondList = subCondList
  56394. return cond
  56395. }
  56396. function isObjectNotArray(val) {
  56397. return isObject$2(val) && !isArrayLike(val)
  56398. }
  56399. var ConditionalExpressionParsed = /** @class */ (function () {
  56400. function ConditionalExpressionParsed(exprOption, getters) {
  56401. this._cond = parseOption(exprOption, getters)
  56402. }
  56403. ConditionalExpressionParsed.prototype.evaluate = function () {
  56404. return this._cond.evaluate()
  56405. }
  56406. return ConditionalExpressionParsed
  56407. })()
  56408. function parseConditionalExpression(exprOption, getters) {
  56409. return new ConditionalExpressionParsed(exprOption, getters)
  56410. }
  56411. var filterTransform = {
  56412. type: 'echarts:filter', // PEDING: enhance to filter by index rather than create new data
  56413. transform: function transform(params) {
  56414. // [Caveat] Fail-Fast:
  56415. // Do not return the whole dataset unless user config indicate it explicitly.
  56416. // For example, if no condition specified by mistake, return an empty result
  56417. // is better than return the entire raw soruce for user to find the mistake.
  56418. var upstream = params.upstream
  56419. var rawItem
  56420. var condition = parseConditionalExpression(params.config, {
  56421. valueGetterAttrMap: createHashMap({ dimension: true }),
  56422. prepareGetValue: function prepareGetValue(exprOption) {
  56423. var errMsg = ''
  56424. var dimLoose = exprOption.dimension
  56425. if (!hasOwn(exprOption, 'dimension')) {
  56426. throwError(errMsg)
  56427. }
  56428. var dimInfo = upstream.getDimensionInfo(dimLoose)
  56429. if (!dimInfo) {
  56430. throwError(errMsg)
  56431. }
  56432. return { dimIdx: dimInfo.index }
  56433. },
  56434. getValue: function getValue(param) {
  56435. return upstream.retrieveValueFromItem(rawItem, param.dimIdx)
  56436. }
  56437. })
  56438. var resultData = []
  56439. for (var i = 0, len = upstream.count(); i < len; i++) {
  56440. rawItem = upstream.getRawDataItem(i)
  56441. if (condition.evaluate()) {
  56442. resultData.push(rawItem)
  56443. }
  56444. }
  56445. return { data: resultData }
  56446. }
  56447. }
  56448. var sortTransform = {
  56449. type: 'echarts:sort',
  56450. transform: function transform(params) {
  56451. var upstream = params.upstream
  56452. var config = params.config
  56453. var errMsg = '' // Normalize
  56454. // const orderExprList: OrderExpression[] = isArray(config[0])
  56455. // ? config as OrderExpression[]
  56456. // : [config as OrderExpression];
  56457. var orderExprList = normalizeToArray(config)
  56458. if (!orderExprList.length) {
  56459. throwError(errMsg)
  56460. }
  56461. var orderDefList = []
  56462. each$7(orderExprList, function (orderExpr) {
  56463. var dimLoose = orderExpr.dimension
  56464. var order = orderExpr.order
  56465. var parserName = orderExpr.parser
  56466. var incomparable = orderExpr.incomparable
  56467. if (dimLoose == null) {
  56468. throwError(errMsg)
  56469. }
  56470. if (order !== 'asc' && order !== 'desc') {
  56471. throwError(errMsg)
  56472. }
  56473. if (
  56474. incomparable &&
  56475. incomparable !== 'min' &&
  56476. incomparable !== 'max'
  56477. ) {
  56478. var errMsg_1 = ''
  56479. throwError(errMsg_1)
  56480. }
  56481. if (order !== 'asc' && order !== 'desc') {
  56482. var errMsg_2 = ''
  56483. throwError(errMsg_2)
  56484. }
  56485. var dimInfo = upstream.getDimensionInfo(dimLoose)
  56486. if (!dimInfo) {
  56487. throwError(errMsg)
  56488. }
  56489. var parser = parserName ? getRawValueParser(parserName) : null
  56490. if (parserName && !parser) {
  56491. throwError(errMsg)
  56492. }
  56493. orderDefList.push({
  56494. dimIdx: dimInfo.index,
  56495. parser: parser,
  56496. comparator: new SortOrderComparator(order, incomparable)
  56497. })
  56498. }) // TODO: support it?
  56499. var sourceFormat = upstream.sourceFormat
  56500. if (
  56501. sourceFormat !== SOURCE_FORMAT_ARRAY_ROWS &&
  56502. sourceFormat !== SOURCE_FORMAT_OBJECT_ROWS
  56503. ) {
  56504. throwError(errMsg)
  56505. } // Other upstream format are all array.
  56506. var resultData = []
  56507. for (var i = 0, len = upstream.count(); i < len; i++) {
  56508. resultData.push(upstream.getRawDataItem(i))
  56509. }
  56510. resultData.sort(function (item0, item1) {
  56511. for (var i = 0; i < orderDefList.length; i++) {
  56512. var orderDef = orderDefList[i]
  56513. var val0 = upstream.retrieveValueFromItem(
  56514. item0,
  56515. orderDef.dimIdx
  56516. )
  56517. var val1 = upstream.retrieveValueFromItem(
  56518. item1,
  56519. orderDef.dimIdx
  56520. )
  56521. if (orderDef.parser) {
  56522. val0 = orderDef.parser(val0)
  56523. val1 = orderDef.parser(val1)
  56524. }
  56525. var result = orderDef.comparator.evaluate(val0, val1)
  56526. if (result !== 0) {
  56527. return result
  56528. }
  56529. }
  56530. return 0
  56531. })
  56532. return { data: resultData }
  56533. }
  56534. }
  56535. function install$2(registers) {
  56536. registers.registerTransform(filterTransform)
  56537. registers.registerTransform(sortTransform)
  56538. }
  56539. var DatasetModel = /** @class */ (function (_super) {
  56540. __extends(DatasetModel, _super)
  56541. function DatasetModel() {
  56542. var _this =
  56543. (_super !== null && _super.apply(this, arguments)) || this
  56544. _this.type = 'dataset'
  56545. return _this
  56546. }
  56547. DatasetModel.prototype.init = function (
  56548. option,
  56549. parentModel,
  56550. ecModel
  56551. ) {
  56552. _super.prototype.init.call(this, option, parentModel, ecModel)
  56553. this._sourceManager = new SourceManager(this)
  56554. disableTransformOptionMerge(this)
  56555. }
  56556. DatasetModel.prototype.mergeOption = function (newOption, ecModel) {
  56557. _super.prototype.mergeOption.call(this, newOption, ecModel)
  56558. disableTransformOptionMerge(this)
  56559. }
  56560. DatasetModel.prototype.optionUpdated = function () {
  56561. this._sourceManager.dirty()
  56562. }
  56563. DatasetModel.prototype.getSourceManager = function () {
  56564. return this._sourceManager
  56565. }
  56566. DatasetModel.type = 'dataset'
  56567. DatasetModel.defaultOption = {
  56568. seriesLayoutBy: SERIES_LAYOUT_BY_COLUMN
  56569. }
  56570. return DatasetModel
  56571. })(ComponentModel$1)
  56572. var DatasetView = /** @class */ (function (_super) {
  56573. __extends(DatasetView, _super)
  56574. function DatasetView() {
  56575. var _this =
  56576. (_super !== null && _super.apply(this, arguments)) || this
  56577. _this.type = 'dataset'
  56578. return _this
  56579. }
  56580. DatasetView.type = 'dataset'
  56581. return DatasetView
  56582. })(ComponentView$1)
  56583. function install$1(registers) {
  56584. registers.registerComponentModel(DatasetModel)
  56585. registers.registerComponentView(DatasetView)
  56586. }
  56587. var CMD = PathProxy$1.CMD
  56588. function aroundEqual(a, b) {
  56589. return Math.abs(a - b) < 1e-5
  56590. }
  56591. function pathToBezierCurves(path) {
  56592. var data = path.data
  56593. var len = path.len()
  56594. var bezierArrayGroups = []
  56595. var currentSubpath
  56596. var xi = 0
  56597. var yi = 0
  56598. var x0 = 0
  56599. var y0 = 0
  56600. function createNewSubpath(x, y) {
  56601. if (currentSubpath && currentSubpath.length > 2) {
  56602. bezierArrayGroups.push(currentSubpath)
  56603. }
  56604. currentSubpath = [x, y]
  56605. }
  56606. function addLine(x0, y0, x1, y1) {
  56607. if (!(aroundEqual(x0, x1) && aroundEqual(y0, y1))) {
  56608. currentSubpath.push(x0, y0, x1, y1, x1, y1)
  56609. }
  56610. }
  56611. function addArc(startAngle, endAngle, cx, cy, rx, ry) {
  56612. var delta = Math.abs(endAngle - startAngle)
  56613. var len = (Math.tan(delta / 4) * 4) / 3
  56614. var dir = endAngle < startAngle ? -1 : 1
  56615. var c1 = Math.cos(startAngle)
  56616. var s1 = Math.sin(startAngle)
  56617. var c2 = Math.cos(endAngle)
  56618. var s2 = Math.sin(endAngle)
  56619. var x1 = c1 * rx + cx
  56620. var y1 = s1 * ry + cy
  56621. var x4 = c2 * rx + cx
  56622. var y4 = s2 * ry + cy
  56623. var hx = rx * len * dir
  56624. var hy = ry * len * dir
  56625. currentSubpath.push(
  56626. x1 - hx * s1,
  56627. y1 + hy * c1,
  56628. x4 + hx * s2,
  56629. y4 - hy * c2,
  56630. x4,
  56631. y4
  56632. )
  56633. }
  56634. var x1
  56635. var y1
  56636. var x2
  56637. var y2
  56638. for (var i = 0; i < len; ) {
  56639. var cmd = data[i++]
  56640. var isFirst = i === 1
  56641. if (isFirst) {
  56642. xi = data[i]
  56643. yi = data[i + 1]
  56644. x0 = xi
  56645. y0 = yi
  56646. if (cmd === CMD.L || cmd === CMD.C || cmd === CMD.Q) {
  56647. currentSubpath = [x0, y0]
  56648. }
  56649. }
  56650. switch (cmd) {
  56651. case CMD.M:
  56652. xi = x0 = data[i++]
  56653. yi = y0 = data[i++]
  56654. createNewSubpath(x0, y0)
  56655. break
  56656. case CMD.L:
  56657. x1 = data[i++]
  56658. y1 = data[i++]
  56659. addLine(xi, yi, x1, y1)
  56660. xi = x1
  56661. yi = y1
  56662. break
  56663. case CMD.C:
  56664. currentSubpath.push(
  56665. data[i++],
  56666. data[i++],
  56667. data[i++],
  56668. data[i++],
  56669. (xi = data[i++]),
  56670. (yi = data[i++])
  56671. )
  56672. break
  56673. case CMD.Q:
  56674. x1 = data[i++]
  56675. y1 = data[i++]
  56676. x2 = data[i++]
  56677. y2 = data[i++]
  56678. currentSubpath.push(
  56679. xi + (2 / 3) * (x1 - xi),
  56680. yi + (2 / 3) * (y1 - yi),
  56681. x2 + (2 / 3) * (x1 - x2),
  56682. y2 + (2 / 3) * (y1 - y2),
  56683. x2,
  56684. y2
  56685. )
  56686. xi = x2
  56687. yi = y2
  56688. break
  56689. case CMD.A:
  56690. var cx = data[i++]
  56691. var cy = data[i++]
  56692. var rx = data[i++]
  56693. var ry = data[i++]
  56694. var startAngle = data[i++]
  56695. var endAngle = data[i++] + startAngle
  56696. i += 1
  56697. var anticlockwise = !data[i++]
  56698. x1 = Math.cos(startAngle) * rx + cx
  56699. y1 = Math.sin(startAngle) * ry + cy
  56700. if (isFirst) {
  56701. x0 = x1
  56702. y0 = y1
  56703. createNewSubpath(x0, y0)
  56704. } else {
  56705. addLine(xi, yi, x1, y1)
  56706. }
  56707. xi = Math.cos(endAngle) * rx + cx
  56708. yi = Math.sin(endAngle) * ry + cy
  56709. var step = ((anticlockwise ? -1 : 1) * Math.PI) / 2
  56710. for (
  56711. var angle = startAngle;
  56712. anticlockwise ? angle > endAngle : angle < endAngle;
  56713. angle += step
  56714. ) {
  56715. var nextAngle = anticlockwise
  56716. ? Math.max(angle + step, endAngle)
  56717. : Math.min(angle + step, endAngle)
  56718. addArc(angle, nextAngle, cx, cy, rx, ry)
  56719. }
  56720. break
  56721. case CMD.R:
  56722. x0 = xi = data[i++]
  56723. y0 = yi = data[i++]
  56724. x1 = x0 + data[i++]
  56725. y1 = y0 + data[i++]
  56726. createNewSubpath(x1, y0)
  56727. addLine(x1, y0, x1, y1)
  56728. addLine(x1, y1, x0, y1)
  56729. addLine(x0, y1, x0, y0)
  56730. addLine(x0, y0, x1, y0)
  56731. break
  56732. case CMD.Z:
  56733. currentSubpath && addLine(xi, yi, x0, y0)
  56734. xi = x0
  56735. yi = y0
  56736. break
  56737. }
  56738. }
  56739. if (currentSubpath && currentSubpath.length > 2) {
  56740. bezierArrayGroups.push(currentSubpath)
  56741. }
  56742. return bezierArrayGroups
  56743. }
  56744. function adpativeBezier(x0, y0, x1, y1, x2, y2, x3, y3, out, scale) {
  56745. if (
  56746. aroundEqual(x0, x1) &&
  56747. aroundEqual(y0, y1) &&
  56748. aroundEqual(x2, x3) &&
  56749. aroundEqual(y2, y3)
  56750. ) {
  56751. out.push(x3, y3)
  56752. return
  56753. }
  56754. var PIXEL_DISTANCE = 2 / scale
  56755. var PIXEL_DISTANCE_SQR = PIXEL_DISTANCE * PIXEL_DISTANCE
  56756. var dx = x3 - x0
  56757. var dy = y3 - y0
  56758. var d = Math.sqrt(dx * dx + dy * dy)
  56759. dx /= d
  56760. dy /= d
  56761. var dx1 = x1 - x0
  56762. var dy1 = y1 - y0
  56763. var dx2 = x2 - x3
  56764. var dy2 = y2 - y3
  56765. var cp1LenSqr = dx1 * dx1 + dy1 * dy1
  56766. var cp2LenSqr = dx2 * dx2 + dy2 * dy2
  56767. if (
  56768. cp1LenSqr < PIXEL_DISTANCE_SQR &&
  56769. cp2LenSqr < PIXEL_DISTANCE_SQR
  56770. ) {
  56771. out.push(x3, y3)
  56772. return
  56773. }
  56774. var projLen1 = dx * dx1 + dy * dy1
  56775. var projLen2 = -dx * dx2 - dy * dy2
  56776. var d1Sqr = cp1LenSqr - projLen1 * projLen1
  56777. var d2Sqr = cp2LenSqr - projLen2 * projLen2
  56778. if (
  56779. d1Sqr < PIXEL_DISTANCE_SQR &&
  56780. projLen1 >= 0 &&
  56781. d2Sqr < PIXEL_DISTANCE_SQR &&
  56782. projLen2 >= 0
  56783. ) {
  56784. out.push(x3, y3)
  56785. return
  56786. }
  56787. var tmpSegX = []
  56788. var tmpSegY = []
  56789. cubicSubdivide(x0, x1, x2, x3, 0.5, tmpSegX)
  56790. cubicSubdivide(y0, y1, y2, y3, 0.5, tmpSegY)
  56791. adpativeBezier(
  56792. tmpSegX[0],
  56793. tmpSegY[0],
  56794. tmpSegX[1],
  56795. tmpSegY[1],
  56796. tmpSegX[2],
  56797. tmpSegY[2],
  56798. tmpSegX[3],
  56799. tmpSegY[3],
  56800. out,
  56801. scale
  56802. )
  56803. adpativeBezier(
  56804. tmpSegX[4],
  56805. tmpSegY[4],
  56806. tmpSegX[5],
  56807. tmpSegY[5],
  56808. tmpSegX[6],
  56809. tmpSegY[6],
  56810. tmpSegX[7],
  56811. tmpSegY[7],
  56812. out,
  56813. scale
  56814. )
  56815. }
  56816. function pathToPolygons(path, scale) {
  56817. var bezierArrayGroups = pathToBezierCurves(path)
  56818. var polygons = []
  56819. scale = scale || 1
  56820. for (var i = 0; i < bezierArrayGroups.length; i++) {
  56821. var beziers = bezierArrayGroups[i]
  56822. var polygon = []
  56823. var x0 = beziers[0]
  56824. var y0 = beziers[1]
  56825. polygon.push(x0, y0)
  56826. for (var k = 2; k < beziers.length; ) {
  56827. var x1 = beziers[k++]
  56828. var y1 = beziers[k++]
  56829. var x2 = beziers[k++]
  56830. var y2 = beziers[k++]
  56831. var x3 = beziers[k++]
  56832. var y3 = beziers[k++]
  56833. adpativeBezier(x0, y0, x1, y1, x2, y2, x3, y3, polygon, scale)
  56834. x0 = x3
  56835. y0 = y3
  56836. }
  56837. polygons.push(polygon)
  56838. }
  56839. return polygons
  56840. }
  56841. function getDividingGrids(dimSize, rowDim, count) {
  56842. var rowSize = dimSize[rowDim]
  56843. var columnSize = dimSize[1 - rowDim]
  56844. var ratio = Math.abs(rowSize / columnSize)
  56845. var rowCount = Math.ceil(Math.sqrt(ratio * count))
  56846. var columnCount = Math.floor(count / rowCount)
  56847. if (columnCount === 0) {
  56848. columnCount = 1
  56849. rowCount = count
  56850. }
  56851. var grids = []
  56852. for (var i = 0; i < rowCount; i++) {
  56853. grids.push(columnCount)
  56854. }
  56855. var currentCount = rowCount * columnCount
  56856. var remained = count - currentCount
  56857. if (remained > 0) {
  56858. for (var i = 0; i < remained; i++) {
  56859. grids[i % rowCount] += 1
  56860. }
  56861. }
  56862. return grids
  56863. }
  56864. function divideSector(sectorShape, count, outShapes) {
  56865. var r0 = sectorShape.r0
  56866. var r = sectorShape.r
  56867. var startAngle = sectorShape.startAngle
  56868. var endAngle = sectorShape.endAngle
  56869. var angle = Math.abs(endAngle - startAngle)
  56870. var arcLen = angle * r
  56871. var deltaR = r - r0
  56872. var isAngleRow = arcLen > Math.abs(deltaR)
  56873. var grids = getDividingGrids(
  56874. [arcLen, deltaR],
  56875. isAngleRow ? 0 : 1,
  56876. count
  56877. )
  56878. var rowSize = (isAngleRow ? angle : deltaR) / grids.length
  56879. for (var row = 0; row < grids.length; row++) {
  56880. var columnSize = (isAngleRow ? deltaR : angle) / grids[row]
  56881. for (var column = 0; column < grids[row]; column++) {
  56882. var newShape = {}
  56883. if (isAngleRow) {
  56884. newShape.startAngle = startAngle + rowSize * row
  56885. newShape.endAngle = startAngle + rowSize * (row + 1)
  56886. newShape.r0 = r0 + columnSize * column
  56887. newShape.r = r0 + columnSize * (column + 1)
  56888. } else {
  56889. newShape.startAngle = startAngle + columnSize * column
  56890. newShape.endAngle = startAngle + columnSize * (column + 1)
  56891. newShape.r0 = r0 + rowSize * row
  56892. newShape.r = r0 + rowSize * (row + 1)
  56893. }
  56894. newShape.clockwise = sectorShape.clockwise
  56895. newShape.cx = sectorShape.cx
  56896. newShape.cy = sectorShape.cy
  56897. outShapes.push(newShape)
  56898. }
  56899. }
  56900. }
  56901. function divideRect(rectShape, count, outShapes) {
  56902. var width = rectShape.width
  56903. var height = rectShape.height
  56904. var isHorizontalRow = width > height
  56905. var grids = getDividingGrids(
  56906. [width, height],
  56907. isHorizontalRow ? 0 : 1,
  56908. count
  56909. )
  56910. var rowSizeDim = isHorizontalRow ? 'width' : 'height'
  56911. var columnSizeDim = isHorizontalRow ? 'height' : 'width'
  56912. var rowDim = isHorizontalRow ? 'x' : 'y'
  56913. var columnDim = isHorizontalRow ? 'y' : 'x'
  56914. var rowSize = rectShape[rowSizeDim] / grids.length
  56915. for (var row = 0; row < grids.length; row++) {
  56916. var columnSize = rectShape[columnSizeDim] / grids[row]
  56917. for (var column = 0; column < grids[row]; column++) {
  56918. var newShape = {}
  56919. newShape[rowDim] = row * rowSize
  56920. newShape[columnDim] = column * columnSize
  56921. newShape[rowSizeDim] = rowSize
  56922. newShape[columnSizeDim] = columnSize
  56923. newShape.x += rectShape.x
  56924. newShape.y += rectShape.y
  56925. outShapes.push(newShape)
  56926. }
  56927. }
  56928. }
  56929. function crossProduct2d(x1, y1, x2, y2) {
  56930. return x1 * y2 - x2 * y1
  56931. }
  56932. function lineLineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  56933. var mx = a2x - a1x
  56934. var my = a2y - a1y
  56935. var nx = b2x - b1x
  56936. var ny = b2y - b1y
  56937. var nmCrossProduct = crossProduct2d(nx, ny, mx, my)
  56938. if (Math.abs(nmCrossProduct) < 1e-6) {
  56939. return null
  56940. }
  56941. var b1a1x = a1x - b1x
  56942. var b1a1y = a1y - b1y
  56943. var p = crossProduct2d(b1a1x, b1a1y, nx, ny) / nmCrossProduct
  56944. if (p < 0 || p > 1) {
  56945. return null
  56946. }
  56947. return new Point$1(p * mx + a1x, p * my + a1y)
  56948. }
  56949. function projPtOnLine(pt, lineA, lineB) {
  56950. var dir = new Point$1()
  56951. Point$1.sub(dir, lineB, lineA)
  56952. dir.normalize()
  56953. var dir2 = new Point$1()
  56954. Point$1.sub(dir2, pt, lineA)
  56955. var len = dir2.dot(dir)
  56956. return len
  56957. }
  56958. function addToPoly(poly, pt) {
  56959. var last = poly[poly.length - 1]
  56960. if (last && last[0] === pt[0] && last[1] === pt[1]) {
  56961. return
  56962. }
  56963. poly.push(pt)
  56964. }
  56965. function splitPolygonByLine(points, lineA, lineB) {
  56966. var len = points.length
  56967. var intersections = []
  56968. for (var i = 0; i < len; i++) {
  56969. var p0 = points[i]
  56970. var p1 = points[(i + 1) % len]
  56971. var intersectionPt = lineLineIntersect(
  56972. p0[0],
  56973. p0[1],
  56974. p1[0],
  56975. p1[1],
  56976. lineA.x,
  56977. lineA.y,
  56978. lineB.x,
  56979. lineB.y
  56980. )
  56981. if (intersectionPt) {
  56982. intersections.push({
  56983. projPt: projPtOnLine(intersectionPt, lineA, lineB),
  56984. pt: intersectionPt,
  56985. idx: i
  56986. })
  56987. }
  56988. }
  56989. if (intersections.length < 2) {
  56990. return [{ points: points }, { points: points }]
  56991. }
  56992. intersections.sort(function (a, b) {
  56993. return a.projPt - b.projPt
  56994. })
  56995. var splitPt0 = intersections[0]
  56996. var splitPt1 = intersections[intersections.length - 1]
  56997. if (splitPt1.idx < splitPt0.idx) {
  56998. var tmp = splitPt0
  56999. splitPt0 = splitPt1
  57000. splitPt1 = tmp
  57001. }
  57002. var splitPt0Arr = [splitPt0.pt.x, splitPt0.pt.y]
  57003. var splitPt1Arr = [splitPt1.pt.x, splitPt1.pt.y]
  57004. var newPolyA = [splitPt0Arr]
  57005. var newPolyB = [splitPt1Arr]
  57006. for (var i = splitPt0.idx + 1; i <= splitPt1.idx; i++) {
  57007. addToPoly(newPolyA, points[i].slice())
  57008. }
  57009. addToPoly(newPolyA, splitPt1Arr)
  57010. addToPoly(newPolyA, splitPt0Arr)
  57011. for (var i = splitPt1.idx + 1; i <= splitPt0.idx + len; i++) {
  57012. addToPoly(newPolyB, points[i % len].slice())
  57013. }
  57014. addToPoly(newPolyB, splitPt0Arr)
  57015. addToPoly(newPolyB, splitPt1Arr)
  57016. return [{ points: newPolyA }, { points: newPolyB }]
  57017. }
  57018. function binaryDividePolygon(polygonShape) {
  57019. var points = polygonShape.points
  57020. var min = []
  57021. var max = []
  57022. fromPoints(points, min, max)
  57023. var boundingRect = new BoundingRect$1(
  57024. min[0],
  57025. min[1],
  57026. max[0] - min[0],
  57027. max[1] - min[1]
  57028. )
  57029. var width = boundingRect.width
  57030. var height = boundingRect.height
  57031. var x = boundingRect.x
  57032. var y = boundingRect.y
  57033. var pt0 = new Point$1()
  57034. var pt1 = new Point$1()
  57035. if (width > height) {
  57036. pt0.x = pt1.x = x + width / 2
  57037. pt0.y = y
  57038. pt1.y = y + height
  57039. } else {
  57040. pt0.y = pt1.y = y + height / 2
  57041. pt0.x = x
  57042. pt1.x = x + width
  57043. }
  57044. return splitPolygonByLine(points, pt0, pt1)
  57045. }
  57046. function binaryDivideRecursive(divider, shape, count, out) {
  57047. if (count === 1) {
  57048. out.push(shape)
  57049. } else {
  57050. var mid = Math.floor(count / 2)
  57051. var sub = divider(shape)
  57052. binaryDivideRecursive(divider, sub[0], mid, out)
  57053. binaryDivideRecursive(divider, sub[1], count - mid, out)
  57054. }
  57055. return out
  57056. }
  57057. function clone(path, count) {
  57058. var paths = []
  57059. for (var i = 0; i < count; i++) {
  57060. paths.push(clonePath(path))
  57061. }
  57062. return paths
  57063. }
  57064. function copyPathProps(source, target) {
  57065. target.setStyle(source.style)
  57066. target.z = source.z
  57067. target.z2 = source.z2
  57068. target.zlevel = source.zlevel
  57069. }
  57070. function polygonConvert(points) {
  57071. var out = []
  57072. for (var i = 0; i < points.length; ) {
  57073. out.push([points[i++], points[i++]])
  57074. }
  57075. return out
  57076. }
  57077. function split(path, count) {
  57078. var outShapes = []
  57079. var shape = path.shape
  57080. var OutShapeCtor
  57081. switch (path.type) {
  57082. case 'rect':
  57083. divideRect(shape, count, outShapes)
  57084. OutShapeCtor = Rect$2
  57085. break
  57086. case 'sector':
  57087. divideSector(shape, count, outShapes)
  57088. OutShapeCtor = Sector$1
  57089. break
  57090. case 'circle':
  57091. divideSector(
  57092. {
  57093. r0: 0,
  57094. r: shape.r,
  57095. startAngle: 0,
  57096. endAngle: Math.PI * 2,
  57097. cx: shape.cx,
  57098. cy: shape.cy
  57099. },
  57100. count,
  57101. outShapes
  57102. )
  57103. OutShapeCtor = Sector$1
  57104. break
  57105. default:
  57106. var m = path.getComputedTransform()
  57107. var scale = m
  57108. ? Math.sqrt(
  57109. Math.max(
  57110. m[0] * m[0] + m[1] * m[1],
  57111. m[2] * m[2] + m[3] * m[3]
  57112. )
  57113. )
  57114. : 1
  57115. var polygons = map$1(
  57116. pathToPolygons(path.getUpdatedPathProxy(), scale),
  57117. function (poly) {
  57118. return polygonConvert(poly)
  57119. }
  57120. )
  57121. var polygonCount = polygons.length
  57122. if (polygonCount === 0) {
  57123. binaryDivideRecursive(
  57124. binaryDividePolygon,
  57125. { points: polygons[0] },
  57126. count,
  57127. outShapes
  57128. )
  57129. } else if (polygonCount === count) {
  57130. for (var i = 0; i < polygonCount; i++) {
  57131. outShapes.push({ points: polygons[i] })
  57132. }
  57133. } else {
  57134. var totalArea_1 = 0
  57135. var items = map$1(polygons, function (poly) {
  57136. var min = []
  57137. var max = []
  57138. fromPoints(poly, min, max)
  57139. var area = (max[1] - min[1]) * (max[0] - min[0])
  57140. totalArea_1 += area
  57141. return { poly: poly, area: area }
  57142. })
  57143. items.sort(function (a, b) {
  57144. return b.area - a.area
  57145. })
  57146. var left = count
  57147. for (var i = 0; i < polygonCount; i++) {
  57148. var item = items[i]
  57149. if (left <= 0) {
  57150. break
  57151. }
  57152. var selfCount =
  57153. i === polygonCount - 1
  57154. ? left
  57155. : Math.ceil((item.area / totalArea_1) * count)
  57156. if (selfCount < 0) {
  57157. continue
  57158. }
  57159. binaryDivideRecursive(
  57160. binaryDividePolygon,
  57161. { points: item.poly },
  57162. selfCount,
  57163. outShapes
  57164. )
  57165. left -= selfCount
  57166. }
  57167. }
  57168. OutShapeCtor = Polygon$1
  57169. break
  57170. }
  57171. if (!OutShapeCtor) {
  57172. return clone(path, count)
  57173. }
  57174. var out = []
  57175. for (var i = 0; i < outShapes.length; i++) {
  57176. var subPath = new OutShapeCtor()
  57177. subPath.setShape(outShapes[i])
  57178. copyPathProps(path, subPath)
  57179. out.push(subPath)
  57180. }
  57181. return out
  57182. }
  57183. function alignSubpath(subpath1, subpath2) {
  57184. var len1 = subpath1.length
  57185. var len2 = subpath2.length
  57186. if (len1 === len2) {
  57187. return [subpath1, subpath2]
  57188. }
  57189. var tmpSegX = []
  57190. var tmpSegY = []
  57191. var shorterPath = len1 < len2 ? subpath1 : subpath2
  57192. var shorterLen = Math.min(len1, len2)
  57193. var diff = Math.abs(len2 - len1) / 6
  57194. var shorterBezierCount = (shorterLen - 2) / 6
  57195. var eachCurveSubDivCount = Math.ceil(diff / shorterBezierCount) + 1
  57196. var newSubpath = [shorterPath[0], shorterPath[1]]
  57197. var remained = diff
  57198. for (var i = 2; i < shorterLen; ) {
  57199. var x0 = shorterPath[i - 2]
  57200. var y0 = shorterPath[i - 1]
  57201. var x1 = shorterPath[i++]
  57202. var y1 = shorterPath[i++]
  57203. var x2 = shorterPath[i++]
  57204. var y2 = shorterPath[i++]
  57205. var x3 = shorterPath[i++]
  57206. var y3 = shorterPath[i++]
  57207. if (remained <= 0) {
  57208. newSubpath.push(x1, y1, x2, y2, x3, y3)
  57209. continue
  57210. }
  57211. var actualSubDivCount =
  57212. Math.min(remained, eachCurveSubDivCount - 1) + 1
  57213. for (var k = 1; k <= actualSubDivCount; k++) {
  57214. var p = k / actualSubDivCount
  57215. cubicSubdivide(x0, x1, x2, x3, p, tmpSegX)
  57216. cubicSubdivide(y0, y1, y2, y3, p, tmpSegY)
  57217. x0 = tmpSegX[3]
  57218. y0 = tmpSegY[3]
  57219. newSubpath.push(
  57220. tmpSegX[1],
  57221. tmpSegY[1],
  57222. tmpSegX[2],
  57223. tmpSegY[2],
  57224. x0,
  57225. y0
  57226. )
  57227. x1 = tmpSegX[5]
  57228. y1 = tmpSegY[5]
  57229. x2 = tmpSegX[6]
  57230. y2 = tmpSegY[6]
  57231. }
  57232. remained -= actualSubDivCount - 1
  57233. }
  57234. return shorterPath === subpath1
  57235. ? [newSubpath, subpath2]
  57236. : [subpath1, newSubpath]
  57237. }
  57238. function createSubpath(lastSubpathSubpath, otherSubpath) {
  57239. var len = lastSubpathSubpath.length
  57240. var lastX = lastSubpathSubpath[len - 2]
  57241. var lastY = lastSubpathSubpath[len - 1]
  57242. var newSubpath = []
  57243. for (var i = 0; i < otherSubpath.length; ) {
  57244. newSubpath[i++] = lastX
  57245. newSubpath[i++] = lastY
  57246. }
  57247. return newSubpath
  57248. }
  57249. function alignBezierCurves(array1, array2) {
  57250. var _a
  57251. var lastSubpath1
  57252. var lastSubpath2
  57253. var newArray1 = []
  57254. var newArray2 = []
  57255. for (var i = 0; i < Math.max(array1.length, array2.length); i++) {
  57256. var subpath1 = array1[i]
  57257. var subpath2 = array2[i]
  57258. var newSubpath1 = void 0
  57259. var newSubpath2 = void 0
  57260. if (!subpath1) {
  57261. newSubpath1 = createSubpath(lastSubpath1 || subpath2, subpath2)
  57262. newSubpath2 = subpath2
  57263. } else if (!subpath2) {
  57264. newSubpath2 = createSubpath(lastSubpath2 || subpath1, subpath1)
  57265. newSubpath1 = subpath1
  57266. } else {
  57267. ;(_a = alignSubpath(subpath1, subpath2)),
  57268. (newSubpath1 = _a[0]),
  57269. (newSubpath2 = _a[1])
  57270. lastSubpath1 = newSubpath1
  57271. lastSubpath2 = newSubpath2
  57272. }
  57273. newArray1.push(newSubpath1)
  57274. newArray2.push(newSubpath2)
  57275. }
  57276. return [newArray1, newArray2]
  57277. }
  57278. function centroid(array) {
  57279. var signedArea = 0
  57280. var cx = 0
  57281. var cy = 0
  57282. var len = array.length
  57283. for (var i = 0, j = len - 2; i < len; j = i, i += 2) {
  57284. var x0 = array[j]
  57285. var y0 = array[j + 1]
  57286. var x1 = array[i]
  57287. var y1 = array[i + 1]
  57288. var a = x0 * y1 - x1 * y0
  57289. signedArea += a
  57290. cx += (x0 + x1) * a
  57291. cy += (y0 + y1) * a
  57292. }
  57293. if (signedArea === 0) {
  57294. return [array[0] || 0, array[1] || 0]
  57295. }
  57296. return [cx / signedArea / 3, cy / signedArea / 3, signedArea]
  57297. }
  57298. function findBestRingOffset(
  57299. fromSubBeziers,
  57300. toSubBeziers,
  57301. fromCp,
  57302. toCp
  57303. ) {
  57304. var bezierCount = (fromSubBeziers.length - 2) / 6
  57305. var bestScore = Infinity
  57306. var bestOffset = 0
  57307. var len = fromSubBeziers.length
  57308. var len2 = len - 2
  57309. for (var offset = 0; offset < bezierCount; offset++) {
  57310. var cursorOffset = offset * 6
  57311. var score = 0
  57312. for (var k = 0; k < len; k += 2) {
  57313. var idx =
  57314. k === 0 ? cursorOffset : ((cursorOffset + k - 2) % len2) + 2
  57315. var x0 = fromSubBeziers[idx] - fromCp[0]
  57316. var y0 = fromSubBeziers[idx + 1] - fromCp[1]
  57317. var x1 = toSubBeziers[k] - toCp[0]
  57318. var y1 = toSubBeziers[k + 1] - toCp[1]
  57319. var dx = x1 - x0
  57320. var dy = y1 - y0
  57321. score += dx * dx + dy * dy
  57322. }
  57323. if (score < bestScore) {
  57324. bestScore = score
  57325. bestOffset = offset
  57326. }
  57327. }
  57328. return bestOffset
  57329. }
  57330. function reverse(array) {
  57331. var newArr = []
  57332. var len = array.length
  57333. for (var i = 0; i < len; i += 2) {
  57334. newArr[i] = array[len - i - 2]
  57335. newArr[i + 1] = array[len - i - 1]
  57336. }
  57337. return newArr
  57338. }
  57339. function findBestMorphingRotation(
  57340. fromArr,
  57341. toArr,
  57342. searchAngleIteration,
  57343. searchAngleRange
  57344. ) {
  57345. var result = []
  57346. var fromNeedsReverse
  57347. for (var i = 0; i < fromArr.length; i++) {
  57348. var fromSubpathBezier = fromArr[i]
  57349. var toSubpathBezier = toArr[i]
  57350. var fromCp = centroid(fromSubpathBezier)
  57351. var toCp = centroid(toSubpathBezier)
  57352. if (fromNeedsReverse == null) {
  57353. fromNeedsReverse = fromCp[2] < 0 !== toCp[2] < 0
  57354. }
  57355. var newFromSubpathBezier = []
  57356. var newToSubpathBezier = []
  57357. var bestAngle = 0
  57358. var bestScore = Infinity
  57359. var tmpArr = []
  57360. var len = fromSubpathBezier.length
  57361. if (fromNeedsReverse) {
  57362. fromSubpathBezier = reverse(fromSubpathBezier)
  57363. }
  57364. var offset =
  57365. findBestRingOffset(
  57366. fromSubpathBezier,
  57367. toSubpathBezier,
  57368. fromCp,
  57369. toCp
  57370. ) * 6
  57371. var len2 = len - 2
  57372. for (var k = 0; k < len2; k += 2) {
  57373. var idx = ((offset + k) % len2) + 2
  57374. newFromSubpathBezier[k + 2] = fromSubpathBezier[idx] - fromCp[0]
  57375. newFromSubpathBezier[k + 3] =
  57376. fromSubpathBezier[idx + 1] - fromCp[1]
  57377. }
  57378. newFromSubpathBezier[0] = fromSubpathBezier[offset] - fromCp[0]
  57379. newFromSubpathBezier[1] =
  57380. fromSubpathBezier[offset + 1] - fromCp[1]
  57381. if (searchAngleIteration > 0) {
  57382. var step = searchAngleRange / searchAngleIteration
  57383. for (
  57384. var angle = -searchAngleRange / 2;
  57385. angle <= searchAngleRange / 2;
  57386. angle += step
  57387. ) {
  57388. var sa = Math.sin(angle)
  57389. var ca = Math.cos(angle)
  57390. var score = 0
  57391. for (var k = 0; k < fromSubpathBezier.length; k += 2) {
  57392. var x0 = newFromSubpathBezier[k]
  57393. var y0 = newFromSubpathBezier[k + 1]
  57394. var x1 = toSubpathBezier[k] - toCp[0]
  57395. var y1 = toSubpathBezier[k + 1] - toCp[1]
  57396. var newX1 = x1 * ca - y1 * sa
  57397. var newY1 = x1 * sa + y1 * ca
  57398. tmpArr[k] = newX1
  57399. tmpArr[k + 1] = newY1
  57400. var dx = newX1 - x0
  57401. var dy = newY1 - y0
  57402. score += dx * dx + dy * dy
  57403. }
  57404. if (score < bestScore) {
  57405. bestScore = score
  57406. bestAngle = angle
  57407. for (var m = 0; m < tmpArr.length; m++) {
  57408. newToSubpathBezier[m] = tmpArr[m]
  57409. }
  57410. }
  57411. }
  57412. } else {
  57413. for (var i_1 = 0; i_1 < len; i_1 += 2) {
  57414. newToSubpathBezier[i_1] = toSubpathBezier[i_1] - toCp[0]
  57415. newToSubpathBezier[i_1 + 1] =
  57416. toSubpathBezier[i_1 + 1] - toCp[1]
  57417. }
  57418. }
  57419. result.push({
  57420. from: newFromSubpathBezier,
  57421. to: newToSubpathBezier,
  57422. fromCp: fromCp,
  57423. toCp: toCp,
  57424. rotation: -bestAngle
  57425. })
  57426. }
  57427. return result
  57428. }
  57429. function isCombineMorphing(path) {
  57430. return path.__isCombineMorphing
  57431. }
  57432. var SAVED_METHOD_PREFIX = '__mOriginal_'
  57433. function saveAndModifyMethod(obj, methodName, modifiers) {
  57434. var savedMethodName = SAVED_METHOD_PREFIX + methodName
  57435. var originalMethod = obj[savedMethodName] || obj[methodName]
  57436. if (!obj[savedMethodName]) {
  57437. obj[savedMethodName] = obj[methodName]
  57438. }
  57439. var replace = modifiers.replace
  57440. var after = modifiers.after
  57441. var before = modifiers.before
  57442. obj[methodName] = function () {
  57443. var args = arguments
  57444. var res
  57445. before && before.apply(this, args)
  57446. if (replace) {
  57447. res = replace.apply(this, args)
  57448. } else {
  57449. res = originalMethod.apply(this, args)
  57450. }
  57451. after && after.apply(this, args)
  57452. return res
  57453. }
  57454. }
  57455. function restoreMethod(obj, methodName) {
  57456. var savedMethodName = SAVED_METHOD_PREFIX + methodName
  57457. if (obj[savedMethodName]) {
  57458. obj[methodName] = obj[savedMethodName]
  57459. obj[savedMethodName] = null
  57460. }
  57461. }
  57462. function applyTransformOnBeziers(bezierCurves, mm) {
  57463. for (var i = 0; i < bezierCurves.length; i++) {
  57464. var subBeziers = bezierCurves[i]
  57465. for (var k = 0; k < subBeziers.length; ) {
  57466. var x = subBeziers[k]
  57467. var y = subBeziers[k + 1]
  57468. subBeziers[k++] = mm[0] * x + mm[2] * y + mm[4]
  57469. subBeziers[k++] = mm[1] * x + mm[3] * y + mm[5]
  57470. }
  57471. }
  57472. }
  57473. function prepareMorphPath(fromPath, toPath) {
  57474. var fromPathProxy = fromPath.getUpdatedPathProxy()
  57475. var toPathProxy = toPath.getUpdatedPathProxy()
  57476. var _a = alignBezierCurves(
  57477. pathToBezierCurves(fromPathProxy),
  57478. pathToBezierCurves(toPathProxy)
  57479. ),
  57480. fromBezierCurves = _a[0],
  57481. toBezierCurves = _a[1]
  57482. var fromPathTransform = fromPath.getComputedTransform()
  57483. var toPathTransform = toPath.getComputedTransform()
  57484. function updateIdentityTransform() {
  57485. this.transform = null
  57486. }
  57487. fromPathTransform &&
  57488. applyTransformOnBeziers(fromBezierCurves, fromPathTransform)
  57489. toPathTransform &&
  57490. applyTransformOnBeziers(toBezierCurves, toPathTransform)
  57491. saveAndModifyMethod(toPath, 'updateTransform', {
  57492. replace: updateIdentityTransform
  57493. })
  57494. toPath.transform = null
  57495. var morphingData = findBestMorphingRotation(
  57496. fromBezierCurves,
  57497. toBezierCurves,
  57498. 10,
  57499. Math.PI
  57500. )
  57501. var tmpArr = []
  57502. saveAndModifyMethod(toPath, 'buildPath', {
  57503. replace: function replace(path) {
  57504. var t = toPath.__morphT
  57505. var onet = 1 - t
  57506. var newCp = []
  57507. for (var i = 0; i < morphingData.length; i++) {
  57508. var item = morphingData[i]
  57509. var from = item.from
  57510. var to = item.to
  57511. var angle = item.rotation * t
  57512. var fromCp = item.fromCp
  57513. var toCp = item.toCp
  57514. var sa = Math.sin(angle)
  57515. var ca = Math.cos(angle)
  57516. lerp$1(newCp, fromCp, toCp, t)
  57517. for (var m = 0; m < from.length; m += 2) {
  57518. var x0_1 = from[m]
  57519. var y0_1 = from[m + 1]
  57520. var x1 = to[m]
  57521. var y1 = to[m + 1]
  57522. var x = x0_1 * onet + x1 * t
  57523. var y = y0_1 * onet + y1 * t
  57524. tmpArr[m] = x * ca - y * sa + newCp[0]
  57525. tmpArr[m + 1] = x * sa + y * ca + newCp[1]
  57526. }
  57527. var x0 = tmpArr[0]
  57528. var y0 = tmpArr[1]
  57529. path.moveTo(x0, y0)
  57530. for (var m = 2; m < from.length; ) {
  57531. var x1 = tmpArr[m++]
  57532. var y1 = tmpArr[m++]
  57533. var x2 = tmpArr[m++]
  57534. var y2 = tmpArr[m++]
  57535. var x3 = tmpArr[m++]
  57536. var y3 = tmpArr[m++]
  57537. if (x0 === x1 && y0 === y1 && x2 === x3 && y2 === y3) {
  57538. path.lineTo(x3, y3)
  57539. } else {
  57540. path.bezierCurveTo(x1, y1, x2, y2, x3, y3)
  57541. }
  57542. x0 = x3
  57543. y0 = y3
  57544. }
  57545. }
  57546. }
  57547. })
  57548. }
  57549. function morphPath(fromPath, toPath, animationOpts) {
  57550. if (!fromPath || !toPath) {
  57551. return toPath
  57552. }
  57553. var oldDone = animationOpts.done
  57554. var oldDuring = animationOpts.during
  57555. prepareMorphPath(fromPath, toPath)
  57556. toPath.__morphT = 0
  57557. function restoreToPath() {
  57558. restoreMethod(toPath, 'buildPath')
  57559. restoreMethod(toPath, 'updateTransform')
  57560. toPath.__morphT = -1
  57561. toPath.createPathProxy()
  57562. toPath.dirtyShape()
  57563. }
  57564. toPath.animateTo(
  57565. { __morphT: 1 },
  57566. defaults(
  57567. {
  57568. during: function during(p) {
  57569. toPath.dirtyShape()
  57570. oldDuring && oldDuring(p)
  57571. },
  57572. done: function done() {
  57573. restoreToPath()
  57574. oldDone && oldDone()
  57575. }
  57576. },
  57577. animationOpts
  57578. )
  57579. )
  57580. return toPath
  57581. }
  57582. function hilbert(x, y, minX, minY, maxX, maxY) {
  57583. var bits = 16
  57584. x =
  57585. maxX === minX
  57586. ? 0
  57587. : Math.round((32767 * (x - minX)) / (maxX - minX))
  57588. y =
  57589. maxY === minY
  57590. ? 0
  57591. : Math.round((32767 * (y - minY)) / (maxY - minY))
  57592. var d = 0
  57593. var tmp
  57594. for (var s = (1 << bits) / 2; s > 0; s /= 2) {
  57595. var rx = 0
  57596. var ry = 0
  57597. if ((x & s) > 0) {
  57598. rx = 1
  57599. }
  57600. if ((y & s) > 0) {
  57601. ry = 1
  57602. }
  57603. d += s * s * ((3 * rx) ^ ry)
  57604. if (ry === 0) {
  57605. if (rx === 1) {
  57606. x = s - 1 - x
  57607. y = s - 1 - y
  57608. }
  57609. tmp = x
  57610. x = y
  57611. y = tmp
  57612. }
  57613. }
  57614. return d
  57615. }
  57616. function sortPaths(pathList) {
  57617. var xMin = Infinity
  57618. var yMin = Infinity
  57619. var xMax = -Infinity
  57620. var yMax = -Infinity
  57621. var cps = map$1(pathList, function (path) {
  57622. var rect = path.getBoundingRect()
  57623. var m = path.getComputedTransform()
  57624. var x = rect.x + rect.width / 2 + (m ? m[4] : 0)
  57625. var y = rect.y + rect.height / 2 + (m ? m[5] : 0)
  57626. xMin = Math.min(x, xMin)
  57627. yMin = Math.min(y, yMin)
  57628. xMax = Math.max(x, xMax)
  57629. yMax = Math.max(y, yMax)
  57630. return [x, y]
  57631. })
  57632. var items = map$1(cps, function (cp, idx) {
  57633. return {
  57634. cp: cp,
  57635. z: hilbert(cp[0], cp[1], xMin, yMin, xMax, yMax),
  57636. path: pathList[idx]
  57637. }
  57638. })
  57639. return items
  57640. .sort(function (a, b) {
  57641. return a.z - b.z
  57642. })
  57643. .map(function (item) {
  57644. return item.path
  57645. })
  57646. }
  57647. function defaultDividePath(param) {
  57648. return split(param.path, param.count)
  57649. }
  57650. function createEmptyReturn() {
  57651. return { fromIndividuals: [], toIndividuals: [], count: 0 }
  57652. }
  57653. function combineMorph(fromList, toPath, animationOpts) {
  57654. var fromPathList = []
  57655. function addFromPath(fromList) {
  57656. for (var i = 0; i < fromList.length; i++) {
  57657. var from = fromList[i]
  57658. if (isCombineMorphing(from)) {
  57659. addFromPath(from.childrenRef())
  57660. } else if (from instanceof Path$1) {
  57661. fromPathList.push(from)
  57662. }
  57663. }
  57664. }
  57665. addFromPath(fromList)
  57666. var separateCount = fromPathList.length
  57667. if (!separateCount) {
  57668. return createEmptyReturn()
  57669. }
  57670. var dividePath = animationOpts.dividePath || defaultDividePath
  57671. var toSubPathList = dividePath({
  57672. path: toPath,
  57673. count: separateCount
  57674. })
  57675. if (toSubPathList.length !== separateCount) {
  57676. console.error('Invalid morphing: unmatched splitted path')
  57677. return createEmptyReturn()
  57678. }
  57679. fromPathList = sortPaths(fromPathList)
  57680. toSubPathList = sortPaths(toSubPathList)
  57681. var oldDone = animationOpts.done
  57682. var oldDuring = animationOpts.during
  57683. var individualDelay = animationOpts.individualDelay
  57684. var identityTransform = new Transformable()
  57685. for (var i = 0; i < separateCount; i++) {
  57686. var from = fromPathList[i]
  57687. var to = toSubPathList[i]
  57688. to.parent = toPath
  57689. to.copyTransform(identityTransform)
  57690. if (!individualDelay) {
  57691. prepareMorphPath(from, to)
  57692. }
  57693. }
  57694. toPath.__isCombineMorphing = true
  57695. toPath.childrenRef = function () {
  57696. return toSubPathList
  57697. }
  57698. function addToSubPathListToZr(zr) {
  57699. for (var i = 0; i < toSubPathList.length; i++) {
  57700. toSubPathList[i].addSelfToZr(zr)
  57701. }
  57702. }
  57703. saveAndModifyMethod(toPath, 'addSelfToZr', {
  57704. after: function after(zr) {
  57705. addToSubPathListToZr(zr)
  57706. }
  57707. })
  57708. saveAndModifyMethod(toPath, 'removeSelfFromZr', {
  57709. after: function after(zr) {
  57710. for (var i = 0; i < toSubPathList.length; i++) {
  57711. toSubPathList[i].removeSelfFromZr(zr)
  57712. }
  57713. }
  57714. })
  57715. function restoreToPath() {
  57716. toPath.__isCombineMorphing = false
  57717. toPath.__morphT = -1
  57718. toPath.childrenRef = null
  57719. restoreMethod(toPath, 'addSelfToZr')
  57720. restoreMethod(toPath, 'removeSelfFromZr')
  57721. }
  57722. var toLen = toSubPathList.length
  57723. if (individualDelay) {
  57724. var animating_1 = toLen
  57725. var eachDone = function eachDone() {
  57726. animating_1--
  57727. if (animating_1 === 0) {
  57728. restoreToPath()
  57729. oldDone && oldDone()
  57730. }
  57731. }
  57732. for (var i = 0; i < toLen; i++) {
  57733. var indivdualAnimationOpts = individualDelay
  57734. ? defaults(
  57735. {
  57736. delay:
  57737. (animationOpts.delay || 0) +
  57738. individualDelay(
  57739. i,
  57740. toLen,
  57741. fromPathList[i],
  57742. toSubPathList[i]
  57743. ),
  57744. done: eachDone
  57745. },
  57746. animationOpts
  57747. )
  57748. : animationOpts
  57749. morphPath(
  57750. fromPathList[i],
  57751. toSubPathList[i],
  57752. indivdualAnimationOpts
  57753. )
  57754. }
  57755. } else {
  57756. toPath.__morphT = 0
  57757. toPath.animateTo(
  57758. { __morphT: 1 },
  57759. defaults(
  57760. {
  57761. during: function during(p) {
  57762. for (var i = 0; i < toLen; i++) {
  57763. var child = toSubPathList[i]
  57764. child.__morphT = toPath.__morphT
  57765. child.dirtyShape()
  57766. }
  57767. oldDuring && oldDuring(p)
  57768. },
  57769. done: function done() {
  57770. restoreToPath()
  57771. for (var i = 0; i < fromList.length; i++) {
  57772. restoreMethod(fromList[i], 'updateTransform')
  57773. }
  57774. oldDone && oldDone()
  57775. }
  57776. },
  57777. animationOpts
  57778. )
  57779. )
  57780. }
  57781. if (toPath.__zr) {
  57782. addToSubPathListToZr(toPath.__zr)
  57783. }
  57784. return {
  57785. fromIndividuals: fromPathList,
  57786. toIndividuals: toSubPathList,
  57787. count: toLen
  57788. }
  57789. }
  57790. function separateMorph(fromPath, toPathList, animationOpts) {
  57791. var toLen = toPathList.length
  57792. var fromPathList = []
  57793. var dividePath = animationOpts.dividePath || defaultDividePath
  57794. function addFromPath(fromList) {
  57795. for (var i = 0; i < fromList.length; i++) {
  57796. var from = fromList[i]
  57797. if (isCombineMorphing(from)) {
  57798. addFromPath(from.childrenRef())
  57799. } else if (from instanceof Path$1) {
  57800. fromPathList.push(from)
  57801. }
  57802. }
  57803. }
  57804. if (isCombineMorphing(fromPath)) {
  57805. addFromPath(fromPath.childrenRef())
  57806. var fromLen = fromPathList.length
  57807. if (fromLen < toLen) {
  57808. var k = 0
  57809. for (var i = fromLen; i < toLen; i++) {
  57810. fromPathList.push(clonePath(fromPathList[k++ % fromLen]))
  57811. }
  57812. }
  57813. fromPathList.length = toLen
  57814. } else {
  57815. fromPathList = dividePath({ path: fromPath, count: toLen })
  57816. var fromPathTransform = fromPath.getComputedTransform()
  57817. for (var i = 0; i < fromPathList.length; i++) {
  57818. fromPathList[i].setLocalTransform(fromPathTransform)
  57819. }
  57820. if (fromPathList.length !== toLen) {
  57821. console.error('Invalid morphing: unmatched splitted path')
  57822. return createEmptyReturn()
  57823. }
  57824. }
  57825. fromPathList = sortPaths(fromPathList)
  57826. toPathList = sortPaths(toPathList)
  57827. var individualDelay = animationOpts.individualDelay
  57828. for (var i = 0; i < toLen; i++) {
  57829. var indivdualAnimationOpts = individualDelay
  57830. ? defaults(
  57831. {
  57832. delay:
  57833. (animationOpts.delay || 0) +
  57834. individualDelay(
  57835. i,
  57836. toLen,
  57837. fromPathList[i],
  57838. toPathList[i]
  57839. )
  57840. },
  57841. animationOpts
  57842. )
  57843. : animationOpts
  57844. morphPath(fromPathList[i], toPathList[i], indivdualAnimationOpts)
  57845. }
  57846. return {
  57847. fromIndividuals: fromPathList,
  57848. toIndividuals: toPathList,
  57849. count: toPathList.length
  57850. }
  57851. }
  57852. function isMultiple(elements) {
  57853. return isArray(elements[0])
  57854. }
  57855. function prepareMorphBatches(one, many) {
  57856. var batches = []
  57857. var batchCount = one.length
  57858. for (var i = 0; i < batchCount; i++) {
  57859. batches.push({ one: one[i], many: [] })
  57860. }
  57861. for (var i = 0; i < many.length; i++) {
  57862. var len = many[i].length
  57863. var k = void 0
  57864. for (k = 0; k < len; k++) {
  57865. batches[k % batchCount].many.push(many[i][k])
  57866. }
  57867. }
  57868. var off = 0 // If one has more paths than each one of many. average them.
  57869. for (var i = batchCount - 1; i >= 0; i--) {
  57870. if (!batches[i].many.length) {
  57871. var moveFrom = batches[off].many
  57872. if (moveFrom.length <= 1) {
  57873. // Not enough
  57874. // Start from the first one.
  57875. if (off) {
  57876. off = 0
  57877. } else {
  57878. return batches
  57879. }
  57880. }
  57881. var len = moveFrom.length
  57882. var mid = Math.ceil(len / 2)
  57883. batches[i].many = moveFrom.slice(mid, len)
  57884. batches[off].many = moveFrom.slice(0, mid)
  57885. off++
  57886. }
  57887. }
  57888. return batches
  57889. }
  57890. var pathDividers = {
  57891. clone: function clone(params) {
  57892. var ret = [] // Fitting the alpha
  57893. var approxOpacity =
  57894. 1 - Math.pow(1 - params.path.style.opacity, 1 / params.count)
  57895. for (var i = 0; i < params.count; i++) {
  57896. var cloned = clonePath(params.path)
  57897. cloned.setStyle('opacity', approxOpacity)
  57898. ret.push(cloned)
  57899. }
  57900. return ret
  57901. }, // Use the default divider
  57902. split: null
  57903. }
  57904. function applyMorphAnimation(
  57905. from,
  57906. to,
  57907. divideShape,
  57908. seriesModel,
  57909. dataIndex,
  57910. animateOtherProps
  57911. ) {
  57912. if (!from.length || !to.length) {
  57913. return
  57914. }
  57915. var updateAnimationCfg = getAnimationConfig(
  57916. 'update',
  57917. seriesModel,
  57918. dataIndex
  57919. )
  57920. if (!(updateAnimationCfg && updateAnimationCfg.duration > 0)) {
  57921. return
  57922. }
  57923. var animationDelay = seriesModel
  57924. .getModel('universalTransition')
  57925. .get('delay')
  57926. var animationCfg = Object.assign(
  57927. {
  57928. // Need to setToFinal so the further calculation based on the style can be correct.
  57929. // Like emphasis color.
  57930. setToFinal: true
  57931. },
  57932. updateAnimationCfg
  57933. )
  57934. var many
  57935. var one
  57936. if (isMultiple(from)) {
  57937. // manyToOne
  57938. many = from
  57939. one = to
  57940. }
  57941. if (isMultiple(to)) {
  57942. // oneToMany
  57943. many = to
  57944. one = from
  57945. }
  57946. function morphOneBatch(
  57947. batch,
  57948. fromIsMany,
  57949. animateIndex,
  57950. animateCount,
  57951. forceManyOne
  57952. ) {
  57953. var batchMany = batch.many
  57954. var batchOne = batch.one
  57955. if (batchMany.length === 1 && !forceManyOne) {
  57956. // Is one to one
  57957. var batchFrom = fromIsMany ? batchMany[0] : batchOne
  57958. var batchTo = fromIsMany ? batchOne : batchMany[0]
  57959. if (isCombineMorphing(batchFrom)) {
  57960. // Keep doing combine animation.
  57961. morphOneBatch(
  57962. { many: [batchFrom], one: batchTo },
  57963. true,
  57964. animateIndex,
  57965. animateCount,
  57966. true
  57967. )
  57968. } else {
  57969. var individualAnimationCfg = animationDelay
  57970. ? defaults(
  57971. { delay: animationDelay(animateIndex, animateCount) },
  57972. animationCfg
  57973. )
  57974. : animationCfg
  57975. morphPath(batchFrom, batchTo, individualAnimationCfg)
  57976. animateOtherProps(
  57977. batchFrom,
  57978. batchTo,
  57979. batchFrom,
  57980. batchTo,
  57981. individualAnimationCfg
  57982. )
  57983. }
  57984. } else {
  57985. var separateAnimationCfg = defaults(
  57986. {
  57987. dividePath: pathDividers[divideShape],
  57988. individualDelay:
  57989. animationDelay &&
  57990. function (idx, count, fromPath, toPath) {
  57991. return animationDelay(idx + animateIndex, animateCount)
  57992. }
  57993. },
  57994. animationCfg
  57995. )
  57996. var _a = fromIsMany
  57997. ? combineMorph(batchMany, batchOne, separateAnimationCfg)
  57998. : separateMorph(batchOne, batchMany, separateAnimationCfg),
  57999. fromIndividuals = _a.fromIndividuals,
  58000. toIndividuals = _a.toIndividuals
  58001. var count = fromIndividuals.length
  58002. for (var k = 0; k < count; k++) {
  58003. var individualAnimationCfg = animationDelay
  58004. ? defaults(
  58005. { delay: animationDelay(k, count) },
  58006. animationCfg
  58007. )
  58008. : animationCfg
  58009. animateOtherProps(
  58010. fromIndividuals[k],
  58011. toIndividuals[k],
  58012. fromIsMany ? batchMany[k] : batch.one,
  58013. fromIsMany ? batch.one : batchMany[k],
  58014. individualAnimationCfg
  58015. )
  58016. }
  58017. }
  58018. }
  58019. var fromIsMany = many
  58020. ? many === from // Is one to one. If the path number not match. also needs do merge and separate morphing.
  58021. : from.length > to.length
  58022. var morphBatches = many
  58023. ? prepareMorphBatches(one, many)
  58024. : prepareMorphBatches(fromIsMany ? to : from, [
  58025. fromIsMany ? from : to
  58026. ])
  58027. var animateCount = 0
  58028. for (var i = 0; i < morphBatches.length; i++) {
  58029. animateCount += morphBatches[i].many.length
  58030. }
  58031. var animateIndex = 0
  58032. for (var i = 0; i < morphBatches.length; i++) {
  58033. morphOneBatch(
  58034. morphBatches[i],
  58035. fromIsMany,
  58036. animateIndex,
  58037. animateCount
  58038. )
  58039. animateIndex += morphBatches[i].many.length
  58040. }
  58041. }
  58042. function getPathList(elements) {
  58043. if (!elements) {
  58044. return []
  58045. }
  58046. if (isArray(elements)) {
  58047. var pathList_1 = []
  58048. for (var i = 0; i < elements.length; i++) {
  58049. pathList_1.push(getPathList(elements[i]))
  58050. }
  58051. return pathList_1
  58052. }
  58053. var pathList = []
  58054. elements.traverse(function (el) {
  58055. if (
  58056. el instanceof Path$1 &&
  58057. !el.disableMorphing &&
  58058. !el.invisible &&
  58059. !el.ignore
  58060. ) {
  58061. pathList.push(el)
  58062. }
  58063. })
  58064. return pathList
  58065. }
  58066. var DATA_COUNT_THRESHOLD = 1e4
  58067. var getUniversalTransitionGlobalStore = makeInner()
  58068. function getGroupIdDimension(data) {
  58069. var dimensions = data.dimensions
  58070. for (var i = 0; i < dimensions.length; i++) {
  58071. var dimInfo = data.getDimensionInfo(dimensions[i])
  58072. if (dimInfo && dimInfo.otherDims.itemGroupId === 0) {
  58073. return dimensions[i]
  58074. }
  58075. }
  58076. }
  58077. function flattenDataDiffItems(list) {
  58078. var items = []
  58079. each$7(list, function (seriesInfo) {
  58080. var data = seriesInfo.data
  58081. if (data.count() > DATA_COUNT_THRESHOLD) {
  58082. return
  58083. }
  58084. var indices = data.getIndices()
  58085. var groupDim = getGroupIdDimension(data)
  58086. for (var dataIndex = 0; dataIndex < indices.length; dataIndex++) {
  58087. items.push({
  58088. data: data,
  58089. dim: seriesInfo.dim || groupDim,
  58090. divide: seriesInfo.divide,
  58091. dataIndex: dataIndex
  58092. })
  58093. }
  58094. })
  58095. return items
  58096. }
  58097. function fadeInElement(newEl, newSeries, newIndex) {
  58098. newEl.traverse(function (el) {
  58099. if (el instanceof Path$1) {
  58100. // TODO use fade in animation for target element.
  58101. initProps(el, { style: { opacity: 0 } }, newSeries, {
  58102. dataIndex: newIndex,
  58103. isFrom: true
  58104. })
  58105. }
  58106. })
  58107. }
  58108. function removeEl(el) {
  58109. if (el.parent) {
  58110. // Bake parent transform to element.
  58111. // So it can still have proper transform to transition after it's removed.
  58112. var computedTransform = el.getComputedTransform()
  58113. el.setLocalTransform(computedTransform)
  58114. el.parent.remove(el)
  58115. }
  58116. }
  58117. function stopAnimation(el) {
  58118. el.stopAnimation()
  58119. if (el.isGroup) {
  58120. el.traverse(function (child) {
  58121. child.stopAnimation()
  58122. })
  58123. }
  58124. }
  58125. function animateElementStyles(el, dataIndex, seriesModel) {
  58126. var animationConfig = getAnimationConfig(
  58127. 'update',
  58128. seriesModel,
  58129. dataIndex
  58130. )
  58131. animationConfig &&
  58132. el.traverse(function (child) {
  58133. if (child instanceof Displayable$1) {
  58134. var oldStyle = getOldStyle(child)
  58135. if (oldStyle) {
  58136. child.animateFrom({ style: oldStyle }, animationConfig)
  58137. }
  58138. }
  58139. })
  58140. }
  58141. function isAllIdSame(oldDiffItems, newDiffItems) {
  58142. var len = oldDiffItems.length
  58143. if (len !== newDiffItems.length) {
  58144. return false
  58145. }
  58146. for (var i = 0; i < len; i++) {
  58147. var oldItem = oldDiffItems[i]
  58148. var newItem = newDiffItems[i]
  58149. if (
  58150. oldItem.data.getId(oldItem.dataIndex) !==
  58151. newItem.data.getId(newItem.dataIndex)
  58152. ) {
  58153. return false
  58154. }
  58155. }
  58156. return true
  58157. }
  58158. function transitionBetween(oldList, newList, api) {
  58159. var oldDiffItems = flattenDataDiffItems(oldList)
  58160. var newDiffItems = flattenDataDiffItems(newList)
  58161. function updateMorphingPathProps(
  58162. from,
  58163. to,
  58164. rawFrom,
  58165. rawTo,
  58166. animationCfg
  58167. ) {
  58168. if (rawFrom || from) {
  58169. to.animateFrom(
  58170. {
  58171. style:
  58172. rawFrom && rawFrom !== from // dividingMethod like clone may override the style(opacity)
  58173. ? // So extend it to raw style.
  58174. extend(extend({}, rawFrom.style), from.style)
  58175. : from.style
  58176. },
  58177. animationCfg
  58178. )
  58179. }
  58180. }
  58181. function findKeyDim(items) {
  58182. for (var i = 0; i < items.length; i++) {
  58183. if (items[i].dim) {
  58184. return items[i].dim
  58185. }
  58186. }
  58187. }
  58188. var oldKeyDim = findKeyDim(oldDiffItems)
  58189. var newKeyDim = findKeyDim(newDiffItems)
  58190. var hasMorphAnimation = false
  58191. function createKeyGetter(isOld, onlyGetId) {
  58192. return function (diffItem) {
  58193. var data = diffItem.data
  58194. var dataIndex = diffItem.dataIndex // TODO if specified dim
  58195. if (onlyGetId) {
  58196. return data.getId(dataIndex)
  58197. } // Use group id as transition key by default.
  58198. // So we can achieve multiple to multiple animation like drilldown / up naturally.
  58199. // If group id not exits. Use id instead. If so, only one to one transition will be applied.
  58200. var dataGroupId =
  58201. data.hostModel && data.hostModel.get('dataGroupId') // If specified key dimension(itemGroupId by default). Use this same dimension from other data.
  58202. // PENDING: If only use key dimension of newData.
  58203. var keyDim = isOld
  58204. ? oldKeyDim || newKeyDim
  58205. : newKeyDim || oldKeyDim
  58206. var dimInfo = keyDim && data.getDimensionInfo(keyDim)
  58207. var dimOrdinalMeta = dimInfo && dimInfo.ordinalMeta
  58208. if (dimInfo) {
  58209. // Get from encode.itemGroupId.
  58210. var key = data.get(dimInfo.name, dataIndex)
  58211. if (dimOrdinalMeta) {
  58212. return dimOrdinalMeta.categories[key] || key + ''
  58213. }
  58214. return key + ''
  58215. } // Get groupId from raw item. { groupId: '' }
  58216. var itemVal = data.getRawDataItem(dataIndex)
  58217. if (itemVal && itemVal.groupId) {
  58218. return itemVal.groupId + ''
  58219. }
  58220. return dataGroupId || data.getId(dataIndex)
  58221. }
  58222. } // Use id if it's very likely to be an one to one animation
  58223. // It's more robust than groupId
  58224. // TODO Check if key dimension is specified.
  58225. var useId = isAllIdSame(oldDiffItems, newDiffItems)
  58226. var isElementStillInChart = {}
  58227. if (!useId) {
  58228. // We may have different diff strategy with basicTransition if we use other dimension as key.
  58229. // If so, we can't simply check if oldEl is same with newEl. We need a map to check if oldEl is still being used in the new chart.
  58230. // We can't use the elements that already being morphed. Let it keep it's original basic transition.
  58231. for (var i = 0; i < newDiffItems.length; i++) {
  58232. var newItem = newDiffItems[i]
  58233. var el = newItem.data.getItemGraphicEl(newItem.dataIndex)
  58234. if (el) {
  58235. isElementStillInChart[el.id] = true
  58236. }
  58237. }
  58238. }
  58239. function updateOneToOne(newIndex, oldIndex) {
  58240. var oldItem = oldDiffItems[oldIndex]
  58241. var newItem = newDiffItems[newIndex]
  58242. var newSeries = newItem.data.hostModel // TODO Mark this elements is morphed and don't morph them anymore
  58243. var oldEl = oldItem.data.getItemGraphicEl(oldItem.dataIndex)
  58244. var newEl = newItem.data.getItemGraphicEl(newItem.dataIndex) // Can't handle same elements.
  58245. if (oldEl === newEl) {
  58246. newEl &&
  58247. animateElementStyles(newEl, newItem.dataIndex, newSeries)
  58248. return
  58249. }
  58250. if (
  58251. // We can't use the elements that already being morphed
  58252. oldEl &&
  58253. isElementStillInChart[oldEl.id]
  58254. ) {
  58255. return
  58256. }
  58257. if (newEl) {
  58258. // TODO: If keep animating the group in case
  58259. // some of the elements don't want to be morphed.
  58260. // TODO Label?
  58261. stopAnimation(newEl)
  58262. if (oldEl) {
  58263. stopAnimation(oldEl) // If old element is doing leaving animation. stop it and remove it immediately.
  58264. removeEl(oldEl)
  58265. hasMorphAnimation = true
  58266. applyMorphAnimation(
  58267. getPathList(oldEl),
  58268. getPathList(newEl),
  58269. newItem.divide,
  58270. newSeries,
  58271. newIndex,
  58272. updateMorphingPathProps
  58273. )
  58274. } else {
  58275. fadeInElement(newEl, newSeries, newIndex)
  58276. }
  58277. } // else keep oldEl leaving animation.
  58278. }
  58279. new DataDiffer$1(
  58280. oldDiffItems,
  58281. newDiffItems,
  58282. createKeyGetter(true, useId),
  58283. createKeyGetter(false, useId),
  58284. null,
  58285. 'multiple'
  58286. )
  58287. .update(updateOneToOne)
  58288. .updateManyToOne(function (newIndex, oldIndices) {
  58289. var newItem = newDiffItems[newIndex]
  58290. var newData = newItem.data
  58291. var newSeries = newData.hostModel
  58292. var newEl = newData.getItemGraphicEl(newItem.dataIndex)
  58293. var oldElsList = filter(
  58294. map$1(oldIndices, function (idx) {
  58295. return oldDiffItems[idx].data.getItemGraphicEl(
  58296. oldDiffItems[idx].dataIndex
  58297. )
  58298. }),
  58299. function (oldEl) {
  58300. return (
  58301. oldEl &&
  58302. oldEl !== newEl &&
  58303. !isElementStillInChart[oldEl.id]
  58304. )
  58305. }
  58306. )
  58307. if (newEl) {
  58308. stopAnimation(newEl)
  58309. if (oldElsList.length) {
  58310. // If old element is doing leaving animation. stop it and remove it immediately.
  58311. each$7(oldElsList, function (oldEl) {
  58312. stopAnimation(oldEl)
  58313. removeEl(oldEl)
  58314. })
  58315. hasMorphAnimation = true
  58316. applyMorphAnimation(
  58317. getPathList(oldElsList),
  58318. getPathList(newEl),
  58319. newItem.divide,
  58320. newSeries,
  58321. newIndex,
  58322. updateMorphingPathProps
  58323. )
  58324. } else {
  58325. fadeInElement(newEl, newSeries, newItem.dataIndex)
  58326. }
  58327. } // else keep oldEl leaving animation.
  58328. })
  58329. .updateOneToMany(function (newIndices, oldIndex) {
  58330. var oldItem = oldDiffItems[oldIndex]
  58331. var oldEl = oldItem.data.getItemGraphicEl(oldItem.dataIndex) // We can't use the elements that already being morphed
  58332. if (oldEl && isElementStillInChart[oldEl.id]) {
  58333. return
  58334. }
  58335. var newElsList = filter(
  58336. map$1(newIndices, function (idx) {
  58337. return newDiffItems[idx].data.getItemGraphicEl(
  58338. newDiffItems[idx].dataIndex
  58339. )
  58340. }),
  58341. function (el) {
  58342. return el && el !== oldEl
  58343. }
  58344. )
  58345. var newSeris = newDiffItems[newIndices[0]].data.hostModel
  58346. if (newElsList.length) {
  58347. each$7(newElsList, function (newEl) {
  58348. return stopAnimation(newEl)
  58349. })
  58350. if (oldEl) {
  58351. stopAnimation(oldEl) // If old element is doing leaving animation. stop it and remove it immediately.
  58352. removeEl(oldEl)
  58353. hasMorphAnimation = true
  58354. applyMorphAnimation(
  58355. getPathList(oldEl),
  58356. getPathList(newElsList),
  58357. oldItem.divide, // Use divide on old.
  58358. newSeris,
  58359. newIndices[0],
  58360. updateMorphingPathProps
  58361. )
  58362. } else {
  58363. each$7(newElsList, function (newEl) {
  58364. return fadeInElement(newEl, newSeris, newIndices[0])
  58365. })
  58366. }
  58367. } // else keep oldEl leaving animation.
  58368. })
  58369. .updateManyToMany(function (newIndices, oldIndices) {
  58370. // If two data are same and both have groupId.
  58371. // Normally they should be diff by id.
  58372. new DataDiffer$1(
  58373. oldIndices,
  58374. newIndices,
  58375. function (rawIdx) {
  58376. return oldDiffItems[rawIdx].data.getId(
  58377. oldDiffItems[rawIdx].dataIndex
  58378. )
  58379. },
  58380. function (rawIdx) {
  58381. return newDiffItems[rawIdx].data.getId(
  58382. newDiffItems[rawIdx].dataIndex
  58383. )
  58384. }
  58385. )
  58386. .update(function (newIndex, oldIndex) {
  58387. // Use the original index
  58388. updateOneToOne(newIndices[newIndex], oldIndices[oldIndex])
  58389. })
  58390. .execute()
  58391. })
  58392. .execute()
  58393. if (hasMorphAnimation) {
  58394. each$7(newList, function (_a) {
  58395. var data = _a.data
  58396. var seriesModel = data.hostModel
  58397. var view = seriesModel && api.getViewOfSeriesModel(seriesModel)
  58398. var animationCfg = getAnimationConfig('update', seriesModel, 0) // use 0 index.
  58399. if (
  58400. view &&
  58401. seriesModel.isAnimationEnabled() &&
  58402. animationCfg &&
  58403. animationCfg.duration > 0
  58404. ) {
  58405. view.group.traverse(function (el) {
  58406. if (el instanceof Path$1 && !el.animators.length) {
  58407. // We can't accept there still exists element that has no animation
  58408. // if universalTransition is enabled
  58409. el.animateFrom({ style: { opacity: 0 } }, animationCfg)
  58410. }
  58411. })
  58412. }
  58413. })
  58414. }
  58415. }
  58416. function getSeriesTransitionKey(series) {
  58417. var seriesKey = series
  58418. .getModel('universalTransition')
  58419. .get('seriesKey')
  58420. if (!seriesKey) {
  58421. // Use series id by default.
  58422. return series.id
  58423. }
  58424. return seriesKey
  58425. }
  58426. function convertArraySeriesKeyToString(seriesKey) {
  58427. if (isArray(seriesKey)) {
  58428. // Order independent.
  58429. return seriesKey.sort().join(',')
  58430. }
  58431. return seriesKey
  58432. }
  58433. function getDivideShapeFromData(data) {
  58434. if (data.hostModel) {
  58435. return data.hostModel
  58436. .getModel('universalTransition')
  58437. .get('divideShape')
  58438. }
  58439. }
  58440. function findTransitionSeriesBatches(globalStore, params) {
  58441. var updateBatches = createHashMap()
  58442. var oldDataMap = createHashMap() // Map that only store key in array seriesKey.
  58443. // Which is used to query the old data when transition from one to multiple series.
  58444. var oldDataMapForSplit = createHashMap()
  58445. each$7(globalStore.oldSeries, function (series, idx) {
  58446. var oldData = globalStore.oldData[idx]
  58447. var transitionKey = getSeriesTransitionKey(series)
  58448. var transitionKeyStr =
  58449. convertArraySeriesKeyToString(transitionKey)
  58450. oldDataMap.set(transitionKeyStr, oldData)
  58451. if (isArray(transitionKey)) {
  58452. // Same key can't in different array seriesKey.
  58453. each$7(transitionKey, function (key) {
  58454. oldDataMapForSplit.set(key, {
  58455. data: oldData,
  58456. key: transitionKeyStr
  58457. })
  58458. })
  58459. }
  58460. })
  58461. each$7(params.updatedSeries, function (series) {
  58462. if (
  58463. series.isUniversalTransitionEnabled() &&
  58464. series.isAnimationEnabled()
  58465. ) {
  58466. var newData = series.getData()
  58467. var transitionKey = getSeriesTransitionKey(series)
  58468. var transitionKeyStr =
  58469. convertArraySeriesKeyToString(transitionKey) // Only transition between series with same id.
  58470. var oldData = oldDataMap.get(transitionKeyStr) // string transition key is the best match.
  58471. if (oldData) {
  58472. updateBatches.set(transitionKeyStr, {
  58473. oldSeries: [
  58474. { divide: getDivideShapeFromData(oldData), data: oldData }
  58475. ],
  58476. newSeries: [
  58477. { divide: getDivideShapeFromData(newData), data: newData }
  58478. ]
  58479. })
  58480. } else {
  58481. // Transition from multiple series.
  58482. if (isArray(transitionKey)) {
  58483. var oldSeries_1 = []
  58484. each$7(transitionKey, function (key) {
  58485. var oldData = oldDataMap.get(key)
  58486. if (oldData) {
  58487. oldSeries_1.push({
  58488. divide: getDivideShapeFromData(oldData),
  58489. data: oldData
  58490. })
  58491. }
  58492. })
  58493. if (oldSeries_1.length) {
  58494. updateBatches.set(transitionKeyStr, {
  58495. oldSeries: oldSeries_1,
  58496. newSeries: [
  58497. {
  58498. data: newData,
  58499. divide: getDivideShapeFromData(newData)
  58500. }
  58501. ]
  58502. })
  58503. }
  58504. } else {
  58505. // Try transition to multiple series.
  58506. var oldData_1 = oldDataMapForSplit.get(transitionKey)
  58507. if (oldData_1) {
  58508. var batch = updateBatches.get(oldData_1.key)
  58509. if (!batch) {
  58510. batch = {
  58511. oldSeries: [
  58512. {
  58513. data: oldData_1.data,
  58514. divide: getDivideShapeFromData(oldData_1.data)
  58515. }
  58516. ],
  58517. newSeries: []
  58518. }
  58519. updateBatches.set(oldData_1.key, batch)
  58520. }
  58521. batch.newSeries.push({
  58522. data: newData,
  58523. divide: getDivideShapeFromData(newData)
  58524. })
  58525. }
  58526. }
  58527. }
  58528. }
  58529. })
  58530. return updateBatches
  58531. }
  58532. function querySeries(series, finder) {
  58533. for (var i = 0; i < series.length; i++) {
  58534. var found =
  58535. (finder.seriesIndex != null &&
  58536. finder.seriesIndex === series[i].seriesIndex) ||
  58537. (finder.seriesId != null && finder.seriesId === series[i].id)
  58538. if (found) {
  58539. return i
  58540. }
  58541. }
  58542. }
  58543. function transitionSeriesFromOpt(
  58544. transitionOpt,
  58545. globalStore,
  58546. params,
  58547. api
  58548. ) {
  58549. var from = []
  58550. var to = []
  58551. each$7(normalizeToArray(transitionOpt.from), function (finder) {
  58552. var idx = querySeries(globalStore.oldSeries, finder)
  58553. if (idx >= 0) {
  58554. from.push({
  58555. data: globalStore.oldData[idx], // TODO can specify divideShape in transition.
  58556. divide: getDivideShapeFromData(globalStore.oldData[idx]),
  58557. dim: finder.dimension
  58558. })
  58559. }
  58560. })
  58561. each$7(normalizeToArray(transitionOpt.to), function (finder) {
  58562. var idx = querySeries(params.updatedSeries, finder)
  58563. if (idx >= 0) {
  58564. var data = params.updatedSeries[idx].getData()
  58565. to.push({
  58566. data: data,
  58567. divide: getDivideShapeFromData(data),
  58568. dim: finder.dimension
  58569. })
  58570. }
  58571. })
  58572. if (from.length > 0 && to.length > 0) {
  58573. transitionBetween(from, to, api)
  58574. }
  58575. }
  58576. function installUniversalTransition(registers) {
  58577. registers.registerUpdateLifecycle(
  58578. 'series:beforeupdate',
  58579. function (ecMOdel, api, params) {
  58580. each$7(
  58581. normalizeToArray(params.seriesTransition),
  58582. function (transOpt) {
  58583. each$7(normalizeToArray(transOpt.to), function (finder) {
  58584. var series = params.updatedSeries
  58585. for (var i = 0; i < series.length; i++) {
  58586. if (
  58587. (finder.seriesIndex != null &&
  58588. finder.seriesIndex === series[i].seriesIndex) ||
  58589. (finder.seriesId != null &&
  58590. finder.seriesId === series[i].id)
  58591. ) {
  58592. series[i][SERIES_UNIVERSAL_TRANSITION_PROP] = true
  58593. }
  58594. }
  58595. })
  58596. }
  58597. )
  58598. }
  58599. )
  58600. registers.registerUpdateLifecycle(
  58601. 'series:transition',
  58602. function (ecModel, api, params) {
  58603. // TODO api provide an namespace that can save stuff per instance
  58604. var globalStore = getUniversalTransitionGlobalStore(api) // TODO multiple to multiple series.
  58605. if (
  58606. globalStore.oldSeries &&
  58607. params.updatedSeries &&
  58608. params.optionChanged
  58609. ) {
  58610. // Use give transition config if its' give;
  58611. var transitionOpt = params.seriesTransition
  58612. if (transitionOpt) {
  58613. each$7(normalizeToArray(transitionOpt), function (opt) {
  58614. transitionSeriesFromOpt(opt, globalStore, params, api)
  58615. })
  58616. } else {
  58617. // Else guess from series based on transition series key.
  58618. var updateBatches_1 = findTransitionSeriesBatches(
  58619. globalStore,
  58620. params
  58621. )
  58622. each$7(updateBatches_1.keys(), function (key) {
  58623. var batch = updateBatches_1.get(key)
  58624. transitionBetween(batch.oldSeries, batch.newSeries, api)
  58625. })
  58626. } // Reset
  58627. each$7(params.updatedSeries, function (series) {
  58628. // Reset;
  58629. if (series[SERIES_UNIVERSAL_TRANSITION_PROP]) {
  58630. series[SERIES_UNIVERSAL_TRANSITION_PROP] = false
  58631. }
  58632. })
  58633. } // Save all series of current update. Not only the updated one.
  58634. var allSeries = ecModel.getSeries()
  58635. var savedSeries = (globalStore.oldSeries = [])
  58636. var savedData = (globalStore.oldData = [])
  58637. for (var i = 0; i < allSeries.length; i++) {
  58638. var data = allSeries[i].getData() // Only save the data that can have transition.
  58639. // Avoid large data costing too much extra memory
  58640. if (data.count() < DATA_COUNT_THRESHOLD) {
  58641. savedSeries.push(allSeries[i])
  58642. savedData.push(data)
  58643. }
  58644. }
  58645. }
  58646. )
  58647. }
  58648. function createDom(id, painter, dpr) {
  58649. var newDom = platformApi.createCanvas()
  58650. var width = painter.getWidth()
  58651. var height = painter.getHeight()
  58652. var newDomStyle = newDom.style
  58653. if (newDomStyle) {
  58654. newDomStyle.position = 'absolute'
  58655. newDomStyle.left = '0'
  58656. newDomStyle.top = '0'
  58657. newDomStyle.width = width + 'px'
  58658. newDomStyle.height = height + 'px'
  58659. newDom.setAttribute('data-zr-dom-id', id)
  58660. }
  58661. newDom.width = width * dpr
  58662. newDom.height = height * dpr
  58663. return newDom
  58664. }
  58665. var Layer = (function (_super) {
  58666. __extends(Layer, _super)
  58667. function Layer(id, painter, dpr) {
  58668. var _this = _super.call(this) || this
  58669. _this.motionBlur = false
  58670. _this.lastFrameAlpha = 0.7
  58671. _this.dpr = 1
  58672. _this.virtual = false
  58673. _this.config = {}
  58674. _this.incremental = false
  58675. _this.zlevel = 0
  58676. _this.maxRepaintRectCount = 5
  58677. _this.__dirty = true
  58678. _this.__firstTimePaint = true
  58679. _this.__used = false
  58680. _this.__drawIndex = 0
  58681. _this.__startIndex = 0
  58682. _this.__endIndex = 0
  58683. _this.__prevStartIndex = null
  58684. _this.__prevEndIndex = null
  58685. var dom
  58686. dpr = dpr || devicePixelRatio
  58687. if (typeof id === 'string') {
  58688. dom = createDom(id, painter, dpr)
  58689. } else if (isObject$2(id)) {
  58690. dom = id
  58691. id = dom.id
  58692. }
  58693. _this.id = id
  58694. _this.dom = dom
  58695. var domStyle = dom.style
  58696. if (domStyle) {
  58697. disableUserSelect(dom)
  58698. dom.onselectstart = function () {
  58699. return false
  58700. }
  58701. domStyle.padding = '0'
  58702. domStyle.margin = '0'
  58703. domStyle.borderWidth = '0'
  58704. }
  58705. _this.painter = painter
  58706. _this.dpr = dpr
  58707. return _this
  58708. }
  58709. Layer.prototype.getElementCount = function () {
  58710. return this.__endIndex - this.__startIndex
  58711. }
  58712. Layer.prototype.afterBrush = function () {
  58713. this.__prevStartIndex = this.__startIndex
  58714. this.__prevEndIndex = this.__endIndex
  58715. }
  58716. Layer.prototype.initContext = function () {
  58717. this.ctx = this.dom.getContext('2d')
  58718. this.ctx.dpr = this.dpr
  58719. }
  58720. Layer.prototype.setUnpainted = function () {
  58721. this.__firstTimePaint = true
  58722. }
  58723. Layer.prototype.createBackBuffer = function () {
  58724. var dpr = this.dpr
  58725. this.domBack = createDom('back-' + this.id, this.painter, dpr)
  58726. this.ctxBack = this.domBack.getContext('2d')
  58727. if (dpr !== 1) {
  58728. this.ctxBack.scale(dpr, dpr)
  58729. }
  58730. }
  58731. Layer.prototype.createRepaintRects = function (
  58732. displayList,
  58733. prevList,
  58734. viewWidth,
  58735. viewHeight
  58736. ) {
  58737. if (this.__firstTimePaint) {
  58738. this.__firstTimePaint = false
  58739. return null
  58740. }
  58741. var mergedRepaintRects = []
  58742. var maxRepaintRectCount = this.maxRepaintRectCount
  58743. var full = false
  58744. var pendingRect = new BoundingRect$1(0, 0, 0, 0)
  58745. function addRectToMergePool(rect) {
  58746. if (!rect.isFinite() || rect.isZero()) {
  58747. return
  58748. }
  58749. if (mergedRepaintRects.length === 0) {
  58750. var boundingRect = new BoundingRect$1(0, 0, 0, 0)
  58751. boundingRect.copy(rect)
  58752. mergedRepaintRects.push(boundingRect)
  58753. } else {
  58754. var isMerged = false
  58755. var minDeltaArea = Infinity
  58756. var bestRectToMergeIdx = 0
  58757. for (var i = 0; i < mergedRepaintRects.length; ++i) {
  58758. var mergedRect = mergedRepaintRects[i]
  58759. if (mergedRect.intersect(rect)) {
  58760. var pendingRect_1 = new BoundingRect$1(0, 0, 0, 0)
  58761. pendingRect_1.copy(mergedRect)
  58762. pendingRect_1.union(rect)
  58763. mergedRepaintRects[i] = pendingRect_1
  58764. isMerged = true
  58765. break
  58766. } else if (full) {
  58767. pendingRect.copy(rect)
  58768. pendingRect.union(mergedRect)
  58769. var aArea = rect.width * rect.height
  58770. var bArea = mergedRect.width * mergedRect.height
  58771. var pendingArea = pendingRect.width * pendingRect.height
  58772. var deltaArea = pendingArea - aArea - bArea
  58773. if (deltaArea < minDeltaArea) {
  58774. minDeltaArea = deltaArea
  58775. bestRectToMergeIdx = i
  58776. }
  58777. }
  58778. }
  58779. if (full) {
  58780. mergedRepaintRects[bestRectToMergeIdx].union(rect)
  58781. isMerged = true
  58782. }
  58783. if (!isMerged) {
  58784. var boundingRect = new BoundingRect$1(0, 0, 0, 0)
  58785. boundingRect.copy(rect)
  58786. mergedRepaintRects.push(boundingRect)
  58787. }
  58788. if (!full) {
  58789. full = mergedRepaintRects.length >= maxRepaintRectCount
  58790. }
  58791. }
  58792. }
  58793. for (var i = this.__startIndex; i < this.__endIndex; ++i) {
  58794. var el = displayList[i]
  58795. if (el) {
  58796. var shouldPaint = el.shouldBePainted(
  58797. viewWidth,
  58798. viewHeight,
  58799. true,
  58800. true
  58801. )
  58802. var prevRect =
  58803. el.__isRendered && (el.__dirty & REDRAW_BIT || !shouldPaint)
  58804. ? el.getPrevPaintRect()
  58805. : null
  58806. if (prevRect) {
  58807. addRectToMergePool(prevRect)
  58808. }
  58809. var curRect =
  58810. shouldPaint && (el.__dirty & REDRAW_BIT || !el.__isRendered)
  58811. ? el.getPaintRect()
  58812. : null
  58813. if (curRect) {
  58814. addRectToMergePool(curRect)
  58815. }
  58816. }
  58817. }
  58818. for (
  58819. var i = this.__prevStartIndex;
  58820. i < this.__prevEndIndex;
  58821. ++i
  58822. ) {
  58823. var el = prevList[i]
  58824. var shouldPaint = el.shouldBePainted(
  58825. viewWidth,
  58826. viewHeight,
  58827. true,
  58828. true
  58829. )
  58830. if (el && (!shouldPaint || !el.__zr) && el.__isRendered) {
  58831. var prevRect = el.getPrevPaintRect()
  58832. if (prevRect) {
  58833. addRectToMergePool(prevRect)
  58834. }
  58835. }
  58836. }
  58837. var hasIntersections
  58838. do {
  58839. hasIntersections = false
  58840. for (var i = 0; i < mergedRepaintRects.length; ) {
  58841. if (mergedRepaintRects[i].isZero()) {
  58842. mergedRepaintRects.splice(i, 1)
  58843. continue
  58844. }
  58845. for (var j = i + 1; j < mergedRepaintRects.length; ) {
  58846. if (
  58847. mergedRepaintRects[i].intersect(mergedRepaintRects[j])
  58848. ) {
  58849. hasIntersections = true
  58850. mergedRepaintRects[i].union(mergedRepaintRects[j])
  58851. mergedRepaintRects.splice(j, 1)
  58852. } else {
  58853. j++
  58854. }
  58855. }
  58856. i++
  58857. }
  58858. } while (hasIntersections)
  58859. this._paintRects = mergedRepaintRects
  58860. return mergedRepaintRects
  58861. }
  58862. Layer.prototype.debugGetPaintRects = function () {
  58863. return (this._paintRects || []).slice()
  58864. }
  58865. Layer.prototype.resize = function (width, height) {
  58866. var dpr = this.dpr
  58867. var dom = this.dom
  58868. var domStyle = dom.style
  58869. var domBack = this.domBack
  58870. if (domStyle) {
  58871. domStyle.width = width + 'px'
  58872. domStyle.height = height + 'px'
  58873. }
  58874. dom.width = width * dpr
  58875. dom.height = height * dpr
  58876. if (domBack) {
  58877. domBack.width = width * dpr
  58878. domBack.height = height * dpr
  58879. if (dpr !== 1) {
  58880. this.ctxBack.scale(dpr, dpr)
  58881. }
  58882. }
  58883. }
  58884. Layer.prototype.clear = function (
  58885. clearAll,
  58886. clearColor,
  58887. repaintRects
  58888. ) {
  58889. var dom = this.dom
  58890. var ctx = this.ctx
  58891. var width = dom.width
  58892. var height = dom.height
  58893. clearColor = clearColor || this.clearColor
  58894. var haveMotionBLur = this.motionBlur && !clearAll
  58895. var lastFrameAlpha = this.lastFrameAlpha
  58896. var dpr = this.dpr
  58897. var self = this
  58898. if (haveMotionBLur) {
  58899. if (!this.domBack) {
  58900. this.createBackBuffer()
  58901. }
  58902. this.ctxBack.globalCompositeOperation = 'copy'
  58903. this.ctxBack.drawImage(dom, 0, 0, width / dpr, height / dpr)
  58904. }
  58905. var domBack = this.domBack
  58906. function doClear(x, y, width, height) {
  58907. ctx.clearRect(x, y, width, height)
  58908. if (clearColor && clearColor !== 'transparent') {
  58909. var clearColorGradientOrPattern = void 0
  58910. if (isGradientObject(clearColor)) {
  58911. clearColorGradientOrPattern =
  58912. clearColor.__canvasGradient ||
  58913. getCanvasGradient(ctx, clearColor, {
  58914. x: 0,
  58915. y: 0,
  58916. width: width,
  58917. height: height
  58918. })
  58919. clearColor.__canvasGradient = clearColorGradientOrPattern
  58920. } else if (isImagePatternObject(clearColor)) {
  58921. clearColorGradientOrPattern = createCanvasPattern(
  58922. ctx,
  58923. clearColor,
  58924. {
  58925. dirty: function dirty() {
  58926. self.setUnpainted()
  58927. self.__painter.refresh()
  58928. }
  58929. }
  58930. )
  58931. }
  58932. ctx.save()
  58933. ctx.fillStyle = clearColorGradientOrPattern || clearColor
  58934. ctx.fillRect(x, y, width, height)
  58935. ctx.restore()
  58936. }
  58937. if (haveMotionBLur) {
  58938. ctx.save()
  58939. ctx.globalAlpha = lastFrameAlpha
  58940. ctx.drawImage(domBack, x, y, width, height)
  58941. ctx.restore()
  58942. }
  58943. }
  58944. if (!repaintRects || haveMotionBLur) {
  58945. doClear(0, 0, width, height)
  58946. } else if (repaintRects.length) {
  58947. each$7(repaintRects, function (rect) {
  58948. doClear(
  58949. rect.x * dpr,
  58950. rect.y * dpr,
  58951. rect.width * dpr,
  58952. rect.height * dpr
  58953. )
  58954. })
  58955. }
  58956. }
  58957. return Layer
  58958. })(Eventful$1)
  58959. var Layer$1 = Layer
  58960. var HOVER_LAYER_ZLEVEL = 1e5
  58961. var CANVAS_ZLEVEL = 314159
  58962. var EL_AFTER_INCREMENTAL_INC = 0.01
  58963. var INCREMENTAL_INC = 0.001
  58964. function isLayerValid(layer) {
  58965. if (!layer) {
  58966. return false
  58967. }
  58968. if (layer.__builtin__) {
  58969. return true
  58970. }
  58971. if (
  58972. typeof layer.resize !== 'function' ||
  58973. typeof layer.refresh !== 'function'
  58974. ) {
  58975. return false
  58976. }
  58977. return true
  58978. }
  58979. function createRoot(width, height) {
  58980. var domRoot = document.createElement('div')
  58981. domRoot.style.cssText =
  58982. [
  58983. 'position:relative',
  58984. 'width:' + width + 'px',
  58985. 'height:' + height + 'px',
  58986. 'padding:0',
  58987. 'margin:0',
  58988. 'border-width:0'
  58989. ].join(';') + ';'
  58990. return domRoot
  58991. }
  58992. var CanvasPainter = (function () {
  58993. function CanvasPainter(root, storage, opts, id) {
  58994. this.type = 'canvas'
  58995. this._zlevelList = []
  58996. this._prevDisplayList = []
  58997. this._layers = {}
  58998. this._layerConfig = {}
  58999. this._needsManuallyCompositing = false
  59000. this.type = 'canvas'
  59001. var singleCanvas =
  59002. !root.nodeName || root.nodeName.toUpperCase() === 'CANVAS'
  59003. this._opts = opts = extend({}, opts || {})
  59004. this.dpr = opts.devicePixelRatio || devicePixelRatio
  59005. this._singleCanvas = singleCanvas
  59006. this.root = root
  59007. var rootStyle = root.style
  59008. if (rootStyle) {
  59009. disableUserSelect(root)
  59010. root.innerHTML = ''
  59011. }
  59012. this.storage = storage
  59013. var zlevelList = this._zlevelList
  59014. this._prevDisplayList = []
  59015. var layers = this._layers
  59016. if (!singleCanvas) {
  59017. this._width = getSize$1(root, 0, opts)
  59018. this._height = getSize$1(root, 1, opts)
  59019. var domRoot = (this._domRoot = createRoot(
  59020. this._width,
  59021. this._height
  59022. ))
  59023. root.appendChild(domRoot)
  59024. } else {
  59025. var rootCanvas = root
  59026. var width = rootCanvas.width
  59027. var height = rootCanvas.height
  59028. if (opts.width != null) {
  59029. width = opts.width
  59030. }
  59031. if (opts.height != null) {
  59032. height = opts.height
  59033. }
  59034. this.dpr = opts.devicePixelRatio || 1
  59035. rootCanvas.width = width * this.dpr
  59036. rootCanvas.height = height * this.dpr
  59037. this._width = width
  59038. this._height = height
  59039. var mainLayer = new Layer$1(rootCanvas, this, this.dpr)
  59040. mainLayer.__builtin__ = true
  59041. mainLayer.initContext()
  59042. layers[CANVAS_ZLEVEL] = mainLayer
  59043. mainLayer.zlevel = CANVAS_ZLEVEL
  59044. zlevelList.push(CANVAS_ZLEVEL)
  59045. this._domRoot = root
  59046. }
  59047. }
  59048. CanvasPainter.prototype.getType = function () {
  59049. return 'canvas'
  59050. }
  59051. CanvasPainter.prototype.isSingleCanvas = function () {
  59052. return this._singleCanvas
  59053. }
  59054. CanvasPainter.prototype.getViewportRoot = function () {
  59055. return this._domRoot
  59056. }
  59057. CanvasPainter.prototype.getViewportRootOffset = function () {
  59058. var viewportRoot = this.getViewportRoot()
  59059. if (viewportRoot) {
  59060. return {
  59061. offsetLeft: viewportRoot.offsetLeft || 0,
  59062. offsetTop: viewportRoot.offsetTop || 0
  59063. }
  59064. }
  59065. }
  59066. CanvasPainter.prototype.refresh = function (paintAll) {
  59067. var list = this.storage.getDisplayList(true)
  59068. var prevList = this._prevDisplayList
  59069. var zlevelList = this._zlevelList
  59070. this._redrawId = Math.random()
  59071. this._paintList(list, prevList, paintAll, this._redrawId)
  59072. for (var i = 0; i < zlevelList.length; i++) {
  59073. var z = zlevelList[i]
  59074. var layer = this._layers[z]
  59075. if (!layer.__builtin__ && layer.refresh) {
  59076. var clearColor = i === 0 ? this._backgroundColor : null
  59077. layer.refresh(clearColor)
  59078. }
  59079. }
  59080. if (this._opts.useDirtyRect) {
  59081. this._prevDisplayList = list.slice()
  59082. }
  59083. return this
  59084. }
  59085. CanvasPainter.prototype.refreshHover = function () {
  59086. this._paintHoverList(this.storage.getDisplayList(false))
  59087. }
  59088. CanvasPainter.prototype._paintHoverList = function (list) {
  59089. var len = list.length
  59090. var hoverLayer = this._hoverlayer
  59091. hoverLayer && hoverLayer.clear()
  59092. if (!len) {
  59093. return
  59094. }
  59095. var scope = {
  59096. inHover: true,
  59097. viewWidth: this._width,
  59098. viewHeight: this._height
  59099. }
  59100. var ctx
  59101. for (var i = 0; i < len; i++) {
  59102. var el = list[i]
  59103. if (el.__inHover) {
  59104. if (!hoverLayer) {
  59105. hoverLayer = this._hoverlayer =
  59106. this.getLayer(HOVER_LAYER_ZLEVEL)
  59107. }
  59108. if (!ctx) {
  59109. ctx = hoverLayer.ctx
  59110. ctx.save()
  59111. }
  59112. brush(ctx, el, scope, i === len - 1)
  59113. }
  59114. }
  59115. if (ctx) {
  59116. ctx.restore()
  59117. }
  59118. }
  59119. CanvasPainter.prototype.getHoverLayer = function () {
  59120. return this.getLayer(HOVER_LAYER_ZLEVEL)
  59121. }
  59122. CanvasPainter.prototype.paintOne = function (ctx, el) {
  59123. brushSingle(ctx, el)
  59124. }
  59125. CanvasPainter.prototype._paintList = function (
  59126. list,
  59127. prevList,
  59128. paintAll,
  59129. redrawId
  59130. ) {
  59131. if (this._redrawId !== redrawId) {
  59132. return
  59133. }
  59134. paintAll = paintAll || false
  59135. this._updateLayerStatus(list)
  59136. var _a = this._doPaintList(list, prevList, paintAll),
  59137. finished = _a.finished,
  59138. needsRefreshHover = _a.needsRefreshHover
  59139. if (this._needsManuallyCompositing) {
  59140. this._compositeManually()
  59141. }
  59142. if (needsRefreshHover) {
  59143. this._paintHoverList(list)
  59144. }
  59145. if (!finished) {
  59146. var self_1 = this
  59147. requestAnimationFrame$1(function () {
  59148. self_1._paintList(list, prevList, paintAll, redrawId)
  59149. })
  59150. } else {
  59151. this.eachLayer(function (layer) {
  59152. layer.afterBrush && layer.afterBrush()
  59153. })
  59154. }
  59155. }
  59156. CanvasPainter.prototype._compositeManually = function () {
  59157. var ctx = this.getLayer(CANVAS_ZLEVEL).ctx
  59158. var width = this._domRoot.width
  59159. var height = this._domRoot.height
  59160. ctx.clearRect(0, 0, width, height)
  59161. this.eachBuiltinLayer(function (layer) {
  59162. if (layer.virtual) {
  59163. ctx.drawImage(layer.dom, 0, 0, width, height)
  59164. }
  59165. })
  59166. }
  59167. CanvasPainter.prototype._doPaintList = function (
  59168. list,
  59169. prevList,
  59170. paintAll
  59171. ) {
  59172. var _this = this
  59173. var layerList = []
  59174. var useDirtyRect = this._opts.useDirtyRect
  59175. for (var zi = 0; zi < this._zlevelList.length; zi++) {
  59176. var zlevel = this._zlevelList[zi]
  59177. var layer = this._layers[zlevel]
  59178. if (
  59179. layer.__builtin__ &&
  59180. layer !== this._hoverlayer &&
  59181. (layer.__dirty || paintAll)
  59182. ) {
  59183. layerList.push(layer)
  59184. }
  59185. }
  59186. var finished = true
  59187. var needsRefreshHover = false
  59188. var _loop_1 = function _loop_1(k) {
  59189. var layer = layerList[k]
  59190. var ctx = layer.ctx
  59191. var repaintRects =
  59192. useDirtyRect &&
  59193. layer.createRepaintRects(
  59194. list,
  59195. prevList,
  59196. this_1._width,
  59197. this_1._height
  59198. )
  59199. var start = paintAll ? layer.__startIndex : layer.__drawIndex
  59200. var useTimer = !paintAll && layer.incremental && Date.now
  59201. var startTime = useTimer && Date.now()
  59202. var clearColor =
  59203. layer.zlevel === this_1._zlevelList[0]
  59204. ? this_1._backgroundColor
  59205. : null
  59206. if (layer.__startIndex === layer.__endIndex) {
  59207. layer.clear(false, clearColor, repaintRects)
  59208. } else if (start === layer.__startIndex) {
  59209. var firstEl = list[start]
  59210. if (!firstEl.incremental || !firstEl.notClear || paintAll) {
  59211. layer.clear(false, clearColor, repaintRects)
  59212. }
  59213. }
  59214. if (start === -1) {
  59215. console.error('For some unknown reason. drawIndex is -1')
  59216. start = layer.__startIndex
  59217. }
  59218. var i
  59219. var repaint = function repaint(repaintRect) {
  59220. var scope = {
  59221. inHover: false,
  59222. allClipped: false,
  59223. prevEl: null,
  59224. viewWidth: _this._width,
  59225. viewHeight: _this._height
  59226. }
  59227. for (i = start; i < layer.__endIndex; i++) {
  59228. var el = list[i]
  59229. if (el.__inHover) {
  59230. needsRefreshHover = true
  59231. }
  59232. _this._doPaintEl(
  59233. el,
  59234. layer,
  59235. useDirtyRect,
  59236. repaintRect,
  59237. scope,
  59238. i === layer.__endIndex - 1
  59239. )
  59240. if (useTimer) {
  59241. var dTime = Date.now() - startTime
  59242. if (dTime > 15) {
  59243. break
  59244. }
  59245. }
  59246. }
  59247. if (scope.prevElClipPaths) {
  59248. ctx.restore()
  59249. }
  59250. }
  59251. if (repaintRects) {
  59252. if (repaintRects.length === 0) {
  59253. i = layer.__endIndex
  59254. } else {
  59255. var dpr = this_1.dpr
  59256. for (var r = 0; r < repaintRects.length; ++r) {
  59257. var rect = repaintRects[r]
  59258. ctx.save()
  59259. ctx.beginPath()
  59260. ctx.rect(
  59261. rect.x * dpr,
  59262. rect.y * dpr,
  59263. rect.width * dpr,
  59264. rect.height * dpr
  59265. )
  59266. ctx.clip()
  59267. repaint(rect)
  59268. ctx.restore()
  59269. }
  59270. }
  59271. } else {
  59272. ctx.save()
  59273. repaint()
  59274. ctx.restore()
  59275. }
  59276. layer.__drawIndex = i
  59277. if (layer.__drawIndex < layer.__endIndex) {
  59278. finished = false
  59279. }
  59280. }
  59281. var this_1 = this
  59282. for (var k = 0; k < layerList.length; k++) {
  59283. _loop_1(k)
  59284. }
  59285. if (env$1.wxa) {
  59286. each$7(this._layers, function (layer) {
  59287. if (layer && layer.ctx && layer.ctx.draw) {
  59288. layer.ctx.draw()
  59289. }
  59290. })
  59291. }
  59292. return {
  59293. finished: finished,
  59294. needsRefreshHover: needsRefreshHover
  59295. }
  59296. }
  59297. CanvasPainter.prototype._doPaintEl = function (
  59298. el,
  59299. currentLayer,
  59300. useDirtyRect,
  59301. repaintRect,
  59302. scope,
  59303. isLast
  59304. ) {
  59305. var ctx = currentLayer.ctx
  59306. if (useDirtyRect) {
  59307. var paintRect = el.getPaintRect()
  59308. if (
  59309. !repaintRect ||
  59310. (paintRect && paintRect.intersect(repaintRect))
  59311. ) {
  59312. brush(ctx, el, scope, isLast)
  59313. el.setPrevPaintRect(paintRect)
  59314. }
  59315. } else {
  59316. brush(ctx, el, scope, isLast)
  59317. }
  59318. }
  59319. CanvasPainter.prototype.getLayer = function (zlevel, virtual) {
  59320. if (this._singleCanvas && !this._needsManuallyCompositing) {
  59321. zlevel = CANVAS_ZLEVEL
  59322. }
  59323. var layer = this._layers[zlevel]
  59324. if (!layer) {
  59325. layer = new Layer$1('zr_' + zlevel, this, this.dpr)
  59326. layer.zlevel = zlevel
  59327. layer.__builtin__ = true
  59328. if (this._layerConfig[zlevel]) {
  59329. merge(layer, this._layerConfig[zlevel], true)
  59330. } else if (
  59331. this._layerConfig[zlevel - EL_AFTER_INCREMENTAL_INC]
  59332. ) {
  59333. merge(
  59334. layer,
  59335. this._layerConfig[zlevel - EL_AFTER_INCREMENTAL_INC],
  59336. true
  59337. )
  59338. }
  59339. if (virtual) {
  59340. layer.virtual = virtual
  59341. }
  59342. this.insertLayer(zlevel, layer)
  59343. layer.initContext()
  59344. }
  59345. return layer
  59346. }
  59347. CanvasPainter.prototype.insertLayer = function (zlevel, layer) {
  59348. var layersMap = this._layers
  59349. var zlevelList = this._zlevelList
  59350. var len = zlevelList.length
  59351. var domRoot = this._domRoot
  59352. var prevLayer = null
  59353. var i = -1
  59354. if (layersMap[zlevel]) {
  59355. return
  59356. }
  59357. if (!isLayerValid(layer)) {
  59358. return
  59359. }
  59360. if (len > 0 && zlevel > zlevelList[0]) {
  59361. for (i = 0; i < len - 1; i++) {
  59362. if (zlevelList[i] < zlevel && zlevelList[i + 1] > zlevel) {
  59363. break
  59364. }
  59365. }
  59366. prevLayer = layersMap[zlevelList[i]]
  59367. }
  59368. zlevelList.splice(i + 1, 0, zlevel)
  59369. layersMap[zlevel] = layer
  59370. if (!layer.virtual) {
  59371. if (prevLayer) {
  59372. var prevDom = prevLayer.dom
  59373. if (prevDom.nextSibling) {
  59374. domRoot.insertBefore(layer.dom, prevDom.nextSibling)
  59375. } else {
  59376. domRoot.appendChild(layer.dom)
  59377. }
  59378. } else {
  59379. if (domRoot.firstChild) {
  59380. domRoot.insertBefore(layer.dom, domRoot.firstChild)
  59381. } else {
  59382. domRoot.appendChild(layer.dom)
  59383. }
  59384. }
  59385. }
  59386. layer.__painter = this
  59387. }
  59388. CanvasPainter.prototype.eachLayer = function (cb, context) {
  59389. var zlevelList = this._zlevelList
  59390. for (var i = 0; i < zlevelList.length; i++) {
  59391. var z = zlevelList[i]
  59392. cb.call(context, this._layers[z], z)
  59393. }
  59394. }
  59395. CanvasPainter.prototype.eachBuiltinLayer = function (cb, context) {
  59396. var zlevelList = this._zlevelList
  59397. for (var i = 0; i < zlevelList.length; i++) {
  59398. var z = zlevelList[i]
  59399. var layer = this._layers[z]
  59400. if (layer.__builtin__) {
  59401. cb.call(context, layer, z)
  59402. }
  59403. }
  59404. }
  59405. CanvasPainter.prototype.eachOtherLayer = function (cb, context) {
  59406. var zlevelList = this._zlevelList
  59407. for (var i = 0; i < zlevelList.length; i++) {
  59408. var z = zlevelList[i]
  59409. var layer = this._layers[z]
  59410. if (!layer.__builtin__) {
  59411. cb.call(context, layer, z)
  59412. }
  59413. }
  59414. }
  59415. CanvasPainter.prototype.getLayers = function () {
  59416. return this._layers
  59417. }
  59418. CanvasPainter.prototype._updateLayerStatus = function (list) {
  59419. this.eachBuiltinLayer(function (layer, z) {
  59420. layer.__dirty = layer.__used = false
  59421. })
  59422. function updatePrevLayer(idx) {
  59423. if (prevLayer) {
  59424. if (prevLayer.__endIndex !== idx) {
  59425. prevLayer.__dirty = true
  59426. }
  59427. prevLayer.__endIndex = idx
  59428. }
  59429. }
  59430. if (this._singleCanvas) {
  59431. for (var i_1 = 1; i_1 < list.length; i_1++) {
  59432. var el = list[i_1]
  59433. if (el.zlevel !== list[i_1 - 1].zlevel || el.incremental) {
  59434. this._needsManuallyCompositing = true
  59435. break
  59436. }
  59437. }
  59438. }
  59439. var prevLayer = null
  59440. var incrementalLayerCount = 0
  59441. var prevZlevel
  59442. var i
  59443. for (i = 0; i < list.length; i++) {
  59444. var el = list[i]
  59445. var zlevel = el.zlevel
  59446. var layer = void 0
  59447. if (prevZlevel !== zlevel) {
  59448. prevZlevel = zlevel
  59449. incrementalLayerCount = 0
  59450. }
  59451. if (el.incremental) {
  59452. layer = this.getLayer(
  59453. zlevel + INCREMENTAL_INC,
  59454. this._needsManuallyCompositing
  59455. )
  59456. layer.incremental = true
  59457. incrementalLayerCount = 1
  59458. } else {
  59459. layer = this.getLayer(
  59460. zlevel +
  59461. (incrementalLayerCount > 0
  59462. ? EL_AFTER_INCREMENTAL_INC
  59463. : 0),
  59464. this._needsManuallyCompositing
  59465. )
  59466. }
  59467. if (!layer.__builtin__) {
  59468. logError(
  59469. 'ZLevel ' +
  59470. zlevel +
  59471. ' has been used by unkown layer ' +
  59472. layer.id
  59473. )
  59474. }
  59475. if (layer !== prevLayer) {
  59476. layer.__used = true
  59477. if (layer.__startIndex !== i) {
  59478. layer.__dirty = true
  59479. }
  59480. layer.__startIndex = i
  59481. if (!layer.incremental) {
  59482. layer.__drawIndex = i
  59483. } else {
  59484. layer.__drawIndex = -1
  59485. }
  59486. updatePrevLayer(i)
  59487. prevLayer = layer
  59488. }
  59489. if (el.__dirty & REDRAW_BIT && !el.__inHover) {
  59490. layer.__dirty = true
  59491. if (layer.incremental && layer.__drawIndex < 0) {
  59492. layer.__drawIndex = i
  59493. }
  59494. }
  59495. }
  59496. updatePrevLayer(i)
  59497. this.eachBuiltinLayer(function (layer, z) {
  59498. if (!layer.__used && layer.getElementCount() > 0) {
  59499. layer.__dirty = true
  59500. layer.__startIndex = layer.__endIndex = layer.__drawIndex = 0
  59501. }
  59502. if (layer.__dirty && layer.__drawIndex < 0) {
  59503. layer.__drawIndex = layer.__startIndex
  59504. }
  59505. })
  59506. }
  59507. CanvasPainter.prototype.clear = function () {
  59508. this.eachBuiltinLayer(this._clearLayer)
  59509. return this
  59510. }
  59511. CanvasPainter.prototype._clearLayer = function (layer) {
  59512. layer.clear()
  59513. }
  59514. CanvasPainter.prototype.setBackgroundColor = function (
  59515. backgroundColor
  59516. ) {
  59517. this._backgroundColor = backgroundColor
  59518. each$7(this._layers, function (layer) {
  59519. layer.setUnpainted()
  59520. })
  59521. }
  59522. CanvasPainter.prototype.configLayer = function (zlevel, config) {
  59523. if (config) {
  59524. var layerConfig = this._layerConfig
  59525. if (!layerConfig[zlevel]) {
  59526. layerConfig[zlevel] = config
  59527. } else {
  59528. merge(layerConfig[zlevel], config, true)
  59529. }
  59530. for (var i = 0; i < this._zlevelList.length; i++) {
  59531. var _zlevel = this._zlevelList[i]
  59532. if (
  59533. _zlevel === zlevel ||
  59534. _zlevel === zlevel + EL_AFTER_INCREMENTAL_INC
  59535. ) {
  59536. var layer = this._layers[_zlevel]
  59537. merge(layer, layerConfig[zlevel], true)
  59538. }
  59539. }
  59540. }
  59541. }
  59542. CanvasPainter.prototype.delLayer = function (zlevel) {
  59543. var layers = this._layers
  59544. var zlevelList = this._zlevelList
  59545. var layer = layers[zlevel]
  59546. if (!layer) {
  59547. return
  59548. }
  59549. layer.dom.parentNode.removeChild(layer.dom)
  59550. delete layers[zlevel]
  59551. zlevelList.splice(indexOf(zlevelList, zlevel), 1)
  59552. }
  59553. CanvasPainter.prototype.resize = function (width, height) {
  59554. if (!this._domRoot.style) {
  59555. if (width == null || height == null) {
  59556. return
  59557. }
  59558. this._width = width
  59559. this._height = height
  59560. this.getLayer(CANVAS_ZLEVEL).resize(width, height)
  59561. } else {
  59562. var domRoot = this._domRoot
  59563. domRoot.style.display = 'none'
  59564. var opts = this._opts
  59565. var root = this.root
  59566. width != null && (opts.width = width)
  59567. height != null && (opts.height = height)
  59568. width = getSize$1(root, 0, opts)
  59569. height = getSize$1(root, 1, opts)
  59570. domRoot.style.display = ''
  59571. if (this._width !== width || height !== this._height) {
  59572. domRoot.style.width = width + 'px'
  59573. domRoot.style.height = height + 'px'
  59574. for (var id in this._layers) {
  59575. if (this._layers.hasOwnProperty(id)) {
  59576. this._layers[id].resize(width, height)
  59577. }
  59578. }
  59579. this.refresh(true)
  59580. }
  59581. this._width = width
  59582. this._height = height
  59583. }
  59584. return this
  59585. }
  59586. CanvasPainter.prototype.clearLayer = function (zlevel) {
  59587. var layer = this._layers[zlevel]
  59588. if (layer) {
  59589. layer.clear()
  59590. }
  59591. }
  59592. CanvasPainter.prototype.dispose = function () {
  59593. this.root.innerHTML = ''
  59594. this.root = this.storage = this._domRoot = this._layers = null
  59595. }
  59596. CanvasPainter.prototype.getRenderedCanvas = function (opts) {
  59597. opts = opts || {}
  59598. if (this._singleCanvas && !this._compositeManually) {
  59599. return this._layers[CANVAS_ZLEVEL].dom
  59600. }
  59601. var imageLayer = new Layer$1(
  59602. 'image',
  59603. this,
  59604. opts.pixelRatio || this.dpr
  59605. )
  59606. imageLayer.initContext()
  59607. imageLayer.clear(
  59608. false,
  59609. opts.backgroundColor || this._backgroundColor
  59610. )
  59611. var ctx = imageLayer.ctx
  59612. if (opts.pixelRatio <= this.dpr) {
  59613. this.refresh()
  59614. var width_1 = imageLayer.dom.width
  59615. var height_1 = imageLayer.dom.height
  59616. this.eachLayer(function (layer) {
  59617. if (layer.__builtin__) {
  59618. ctx.drawImage(layer.dom, 0, 0, width_1, height_1)
  59619. } else if (layer.renderToCanvas) {
  59620. ctx.save()
  59621. layer.renderToCanvas(ctx)
  59622. ctx.restore()
  59623. }
  59624. })
  59625. } else {
  59626. var scope = {
  59627. inHover: false,
  59628. viewWidth: this._width,
  59629. viewHeight: this._height
  59630. }
  59631. var displayList = this.storage.getDisplayList(true)
  59632. for (var i = 0, len = displayList.length; i < len; i++) {
  59633. var el = displayList[i]
  59634. brush(ctx, el, scope, i === len - 1)
  59635. }
  59636. }
  59637. return imageLayer.dom
  59638. }
  59639. CanvasPainter.prototype.getWidth = function () {
  59640. return this._width
  59641. }
  59642. CanvasPainter.prototype.getHeight = function () {
  59643. return this._height
  59644. }
  59645. return CanvasPainter
  59646. })()
  59647. var CanvasPainter$1 = CanvasPainter
  59648. function install(registers) {
  59649. registers.registerPainter('canvas', CanvasPainter$1)
  59650. }
  59651. var lineChartOption = {
  59652. legend: { show: false },
  59653. emphasis: { lineStyle: { width: 2 } },
  59654. xAxis: {
  59655. boundaryGap: false,
  59656. data: [
  59657. '01\u6708',
  59658. '02\u6708',
  59659. '03\u6708',
  59660. '04\u6708',
  59661. '05\u6708',
  59662. '06\u6708',
  59663. '07\u6708',
  59664. '08\u6708',
  59665. '09\u6708',
  59666. '10\u6708',
  59667. '11\u6708',
  59668. '12\u6708'
  59669. ],
  59670. type: 'category',
  59671. axisLine: { lineStyle: { color: '#8C8C8C' } }
  59672. },
  59673. color: [
  59674. '#5B8FF9',
  59675. '#01C1B5',
  59676. '#91DD1C',
  59677. '#FFA92C',
  59678. '#BE7E2E',
  59679. '#1C96DD',
  59680. '#D22CFF',
  59681. '#FF3C3C',
  59682. '#1AEE3E',
  59683. '#7c47ff'
  59684. ],
  59685. series: [
  59686. {
  59687. lineStyle: { width: 1 },
  59688. data: [
  59689. '0.00',
  59690. '0.00',
  59691. '0.00',
  59692. '0.00',
  59693. '0.00',
  59694. '0.00',
  59695. '0.00',
  59696. '0.00',
  59697. '0.00',
  59698. '0.00',
  59699. '0.00',
  59700. '0.00'
  59701. ],
  59702. symbol: 'circle',
  59703. name: '\u966A\u7EC3\u8BFE',
  59704. type: 'line',
  59705. emphasis: { lineStyle: { width: 1 } }
  59706. },
  59707. {
  59708. lineStyle: { width: 1 },
  59709. data: [
  59710. '0.00',
  59711. '0.00',
  59712. '0.00',
  59713. '0.00',
  59714. '0.00',
  59715. '0.00',
  59716. '0.00',
  59717. '0.00',
  59718. '0.00',
  59719. '0.00',
  59720. '0.00',
  59721. '0.00'
  59722. ],
  59723. symbol: 'circle',
  59724. name: '\u76F4\u64AD\u8BFE',
  59725. type: 'line',
  59726. emphasis: { lineStyle: { width: 1 } }
  59727. },
  59728. {
  59729. lineStyle: { width: 1 },
  59730. data: [
  59731. '0.00',
  59732. '0.00',
  59733. '0.00',
  59734. '0.00',
  59735. '0.00',
  59736. '0.00',
  59737. '0.00',
  59738. '0.00',
  59739. '0.00',
  59740. '0.00',
  59741. '0.00',
  59742. '0.00'
  59743. ],
  59744. symbol: 'circle',
  59745. name: '\u89C6\u9891\u8BFE',
  59746. type: 'line',
  59747. emphasis: { lineStyle: { width: 1 } }
  59748. },
  59749. {
  59750. lineStyle: { width: 1 },
  59751. data: [
  59752. '0.00',
  59753. '0.00',
  59754. '0.00',
  59755. '0.00',
  59756. '0.00',
  59757. '0.00',
  59758. '0.00',
  59759. '0.00',
  59760. '0.00',
  59761. '0.00',
  59762. '0.00',
  59763. '0.00'
  59764. ],
  59765. symbol: 'circle',
  59766. name: '\u4E50\u8C31',
  59767. type: 'line',
  59768. emphasis: { lineStyle: { width: 1 } }
  59769. },
  59770. {
  59771. lineStyle: { width: 1 },
  59772. data: [
  59773. '0.00',
  59774. '0.00',
  59775. '0.00',
  59776. '0.00',
  59777. '0.00',
  59778. '0.00',
  59779. '0.00',
  59780. '0.00',
  59781. '0.00',
  59782. '0.00',
  59783. '0.00',
  59784. '0.00'
  59785. ],
  59786. symbol: 'circle',
  59787. name: '\u5C0F\u9177Ai\u63A8\u5E7F',
  59788. type: 'line',
  59789. emphasis: { lineStyle: { width: 1 } }
  59790. },
  59791. {
  59792. lineStyle: { width: 1 },
  59793. data: [
  59794. '0.00',
  59795. '0.00',
  59796. '0.00',
  59797. '0.00',
  59798. '0.00',
  59799. '0.00',
  59800. '0.00',
  59801. '0.00',
  59802. '0.00',
  59803. '0.00',
  59804. '0.00',
  59805. '0.00'
  59806. ],
  59807. symbol: 'circle',
  59808. name: '\u76F4\u64AD\u8BFE\u63A8\u8350',
  59809. type: 'line',
  59810. emphasis: { lineStyle: { width: 1 } }
  59811. },
  59812. {
  59813. lineStyle: { width: 1 },
  59814. data: [
  59815. '0.00',
  59816. '0.00',
  59817. '0.00',
  59818. '0.00',
  59819. '0.00',
  59820. '0.00',
  59821. '0.00',
  59822. '0.00',
  59823. '0.00',
  59824. '0.00',
  59825. '0.00',
  59826. '0.00'
  59827. ],
  59828. symbol: 'circle',
  59829. name: '\u89C6\u9891\u8BFE\u63A8\u8350',
  59830. type: 'line',
  59831. emphasis: { lineStyle: { width: 1 } }
  59832. },
  59833. {
  59834. lineStyle: { width: 1 },
  59835. data: [
  59836. '0.00',
  59837. '0.00',
  59838. '0.00',
  59839. '0.00',
  59840. '0.00',
  59841. '0.00',
  59842. '0.00',
  59843. '0.00',
  59844. '0.00',
  59845. '0.00',
  59846. '0.00',
  59847. '0.00'
  59848. ],
  59849. symbol: 'circle',
  59850. name: '\u5546\u54C1\u63A8\u8350',
  59851. type: 'line',
  59852. emphasis: { lineStyle: { width: 1 } }
  59853. },
  59854. {
  59855. lineStyle: { width: 1 },
  59856. data: [
  59857. '0.00',
  59858. '0.00',
  59859. '0.00',
  59860. '0.00',
  59861. '0.00',
  59862. '0.00',
  59863. '0.00',
  59864. '0.00',
  59865. '0.00',
  59866. '0.00',
  59867. '0.00',
  59868. '0.00'
  59869. ],
  59870. symbol: 'circle',
  59871. name: '\u4E50\u8C31\u63A8\u8350',
  59872. type: 'line',
  59873. emphasis: { lineStyle: { width: 1 } }
  59874. },
  59875. {
  59876. lineStyle: { width: 1 },
  59877. data: [
  59878. '0.00',
  59879. '0.00',
  59880. '0.00',
  59881. '0.00',
  59882. '0.00',
  59883. '0.00',
  59884. '0.00',
  59885. '0.00',
  59886. '0.00',
  59887. '0.00',
  59888. '0.00',
  59889. '0.00'
  59890. ],
  59891. symbol: 'circle',
  59892. name: '\u6D3B\u52A8\u62A5\u540D',
  59893. type: 'line',
  59894. emphasis: { lineStyle: { width: 1 } }
  59895. }
  59896. ],
  59897. title: { show: false },
  59898. grid: {
  59899. bottom: '3%',
  59900. containLabel: true,
  59901. left: '3%',
  59902. right: '5%',
  59903. top: '7%'
  59904. },
  59905. tooltip: { trigger: 'axis', confine: true },
  59906. yAxis: {
  59907. type: 'value',
  59908. splitLine: {
  59909. axisLine: { lineStyle: { color: '#8C8C8C' } },
  59910. lineStyle: { color: ['#E2E2E2'] }
  59911. }
  59912. },
  59913. dataZoom: [{ type: 'inside', throttle: 100 }],
  59914. toolbox: { feature: { saveAsImage: { show: false } } }
  59915. }
  59916. var pieChartOption = {
  59917. tooltip: {
  59918. position: ['30%', '30%'],
  59919. trigger: 'item',
  59920. padding: 3,
  59921. textStyle: { fontSize: 12 },
  59922. borderWidth: 0,
  59923. formatter: '{b} : {c} ({d}%)'
  59924. },
  59925. series: [
  59926. {
  59927. avoidLabelOverlap: false,
  59928. label: { show: false },
  59929. data: [
  59930. { name: '\u966A\u7EC3\u8BFE', value: '0.00' },
  59931. { name: '\u76F4\u64AD\u8BFE', value: '0.00' },
  59932. { name: '\u89C6\u9891\u8BFE', value: '0.00' },
  59933. { name: '\u4E50\u8C31', value: '0.00' },
  59934. { name: '\u5C0F\u9177Ai\u63A8\u5E7F', value: '0.00' },
  59935. { name: '\u76F4\u64AD\u8BFE\u63A8\u8350', value: '0.00' },
  59936. { name: '\u89C6\u9891\u8BFE\u63A8\u8350', value: '0.00' },
  59937. { name: '\u5546\u54C1\u63A8\u8350', value: '0.00' },
  59938. { name: '\u4E50\u8C31\u63A8\u8350', value: '0.00' },
  59939. { name: '\u6D3B\u52A8\u62A5\u540D', value: '0.00' }
  59940. ],
  59941. type: 'pie',
  59942. radius: ['50%', '80%']
  59943. }
  59944. ],
  59945. grid: {
  59946. bottom: '0%',
  59947. containLabel: true,
  59948. left: '0%',
  59949. right: '0%',
  59950. top: '0%'
  59951. },
  59952. toolbox: { feature: { saveAsImage: { show: false } } },
  59953. color: [
  59954. '#5B8FF9',
  59955. '#01C1B5',
  59956. '#91DD1C',
  59957. '#FFA92C',
  59958. '#BE7E2E',
  59959. '#1C96DD',
  59960. '#D22CFF',
  59961. '#FF3C3C',
  59962. '#1AEE3E',
  59963. '#7c47ff'
  59964. ]
  59965. } // 注册必须的组件
  59966. use([
  59967. install$9,
  59968. install$a,
  59969. install$d,
  59970. install$1,
  59971. install$2,
  59972. install$h,
  59973. installLabelLayout,
  59974. installUniversalTransition,
  59975. install,
  59976. install$g,
  59977. install$b,
  59978. install$6,
  59979. install$3,
  59980. install$i
  59981. ])
  59982. var getAssetsHomeFile = exports(
  59983. 'getAssetsHomeFile',
  59984. function (fileName) {
  59985. var path = './images/'.concat(fileName)
  59986. var modules = {
  59987. './images/icon_fly.png': __glob_21_0,
  59988. './images/icon_user.png': __glob_21_1
  59989. }
  59990. return modules[path].default
  59991. }
  59992. )
  59993. var yearColumns = []
  59994. var year = dayjs().year()
  59995. var defaultIndex = 10
  59996. for (var i = year - 10; i <= year + 10; i++) {
  59997. yearColumns.push({ text: ''.concat(i, '\u5E74'), value: i })
  59998. }
  59999. var index = exports(
  60000. 'default',
  60001. defineComponent({
  60002. name: 'IncomeConsus',
  60003. data: function data() {
  60004. return {
  60005. moneyInfo: {
  60006. totalSingleRate: 0,
  60007. totalShareRate: 0,
  60008. totalInAmount: 0,
  60009. practiceAmount: 0,
  60010. practiceRate: 0,
  60011. liveAmount: 0,
  60012. liveRate: 0,
  60013. videoAmount: 0,
  60014. videoRate: 0,
  60015. musicAmount: 0,
  60016. musicRate: 0,
  60017. vipShareAmount: 0,
  60018. vipShareRate: 0,
  60019. liveShareAmount: 0,
  60020. liveShareRate: 0,
  60021. videoShareAmount: 0,
  60022. videoShareRate: 0,
  60023. mallShareAmount: 0,
  60024. mallShareRate: 0,
  60025. musicShareAmount: 0,
  60026. musicShareRate: 0,
  60027. actiRegistShareAmount: 0,
  60028. actiRegistShareRate: 0
  60029. },
  60030. params: { timeType: 'YEAR', dateTime: ''.concat(year) },
  60031. dateTimeStr: ''.concat(year, '\u5E74'),
  60032. myChart: null,
  60033. myChart2: null,
  60034. timerStatus: false,
  60035. currentDate: new Date()
  60036. }
  60037. },
  60038. mounted: function mounted() {
  60039. var _this2 = this
  60040. return _asyncToGenerator(
  60041. /*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
  60042. return regeneratorRuntime.wrap(function _callee$(_context) {
  60043. while (1) {
  60044. switch ((_context.prev = _context.next)) {
  60045. case 0:
  60046. _this2.myChart = markRaw(
  60047. init(document.getElementById('incomeClass'))
  60048. )
  60049. _this2.myChart2 = markRaw(
  60050. init(document.getElementById('structrueClass'))
  60051. )
  60052. _this2.getList()
  60053. case 3:
  60054. case 'end':
  60055. return _context.stop()
  60056. }
  60057. }
  60058. }, _callee)
  60059. })
  60060. )()
  60061. },
  60062. methods: {
  60063. getList: function getList() {
  60064. var _this3 = this
  60065. return _asyncToGenerator(
  60066. /*#__PURE__*/ regeneratorRuntime.mark(function _callee2() {
  60067. var params, res, result, lineData
  60068. return regeneratorRuntime.wrap(
  60069. function _callee2$(_context2) {
  60070. while (1) {
  60071. switch ((_context2.prev = _context2.next)) {
  60072. case 0:
  60073. _context2.prev = 0
  60074. params = _this3.params
  60075. _context2.next = 4
  60076. return request.post(
  60077. '/api-teacher/userAccount/accountTotal',
  60078. { data: params }
  60079. )
  60080. case 4:
  60081. res = _context2.sent
  60082. result = res.data || {}
  60083. _this3.moneyInfo = {
  60084. totalSingleRate:
  60085. result.practiceRate +
  60086. result.liveRate +
  60087. result.videoRate +
  60088. result.musicRate,
  60089. totalShareRate:
  60090. result.vipShareRate +
  60091. result.liveShareRate +
  60092. result.videoShareRate +
  60093. result.musicShareRate +
  60094. result.mallShareRate +
  60095. result.actiRegistShareRate,
  60096. totalInAmount: result.totalInAmount || 0,
  60097. practiceAmount: result.practiceAmount || 0,
  60098. practiceRate: result.practiceRate || 0,
  60099. liveAmount: result.liveAmount || 0,
  60100. liveRate: result.liveRate || 0,
  60101. videoAmount: result.videoAmount || 0,
  60102. videoRate: result.videoRate || 0,
  60103. musicAmount: result.musicAmount || 0,
  60104. musicRate: result.musicRate || 0,
  60105. vipShareAmount: result.vipShareAmount || 0,
  60106. vipShareRate: result.vipShareRate || 0,
  60107. liveShareAmount: result.liveShareAmount || 0,
  60108. liveShareRate: result.liveShareRate || 0,
  60109. videoShareAmount:
  60110. result.videoShareAmount || 0,
  60111. videoShareRate: result.videoShareRate || 0,
  60112. mallShareAmount: result.mallShareAmount || 0,
  60113. mallShareRate: result.mallShareRate || 0,
  60114. musicShareAmount:
  60115. result.musicShareAmount || 0,
  60116. musicShareRate: result.musicShareRate || 0,
  60117. actiRegistShareAmount:
  60118. result.actiRegistShareAmount || 0,
  60119. actiRegistShareRate:
  60120. result.actiRegistShareRate || 0
  60121. } // 处理折线图数据
  60122. lineData = {
  60123. xAxis: [],
  60124. practiceAmount: [],
  60125. liveAmount: [],
  60126. videoAmount: [],
  60127. musicAmount: [],
  60128. vipShareAmount: [],
  60129. liveShareAmount: [],
  60130. videoShareAmount: [],
  60131. mallShareAmount: [],
  60132. musicShareAmount: [],
  60133. actiRegistShareAmount: []
  60134. }
  60135. ;(result.infoList || []).forEach(function (
  60136. item
  60137. ) {
  60138. if (params.timeType === 'YEAR') {
  60139. lineData.xAxis.push(
  60140. dayjs(item.timeStr).format('MM月')
  60141. )
  60142. } else if (params.timeType === 'MONTH') {
  60143. lineData.xAxis.push(
  60144. dayjs(item.timeStr).format('DD日')
  60145. )
  60146. }
  60147. lineData.practiceAmount.push(
  60148. item.practiceAmount
  60149. )
  60150. lineData.liveAmount.push(item.liveAmount)
  60151. lineData.videoAmount.push(item.videoAmount)
  60152. lineData.musicAmount.push(item.musicAmount)
  60153. lineData.vipShareAmount.push(
  60154. item.vipShareAmount
  60155. ) // 小酷Ai
  60156. lineData.liveShareAmount.push(
  60157. item.liveShareAmount
  60158. )
  60159. lineData.videoShareAmount.push(
  60160. item.videoShareAmount
  60161. )
  60162. lineData.mallShareAmount.push(
  60163. item.mallShareAmount
  60164. )
  60165. lineData.musicShareAmount.push(
  60166. item.musicShareAmount
  60167. )
  60168. lineData.actiRegistShareAmount.push(
  60169. item.actiRegistShareAmount
  60170. )
  60171. }) // 初始化折线图
  60172. lineChartOption.xAxis.data = lineData.xAxis
  60173. lineChartOption.series[0].data =
  60174. lineData.practiceAmount
  60175. lineChartOption.series[1].data =
  60176. lineData.liveAmount
  60177. lineChartOption.series[2].data =
  60178. lineData.videoAmount
  60179. lineChartOption.series[3].data =
  60180. lineData.musicAmount
  60181. lineChartOption.series[4].data =
  60182. lineData.vipShareAmount
  60183. lineChartOption.series[5].data =
  60184. lineData.liveShareAmount
  60185. lineChartOption.series[6].data =
  60186. lineData.videoShareAmount
  60187. lineChartOption.series[7].data =
  60188. lineData.mallShareAmount
  60189. lineChartOption.series[8].data =
  60190. lineData.musicShareAmount
  60191. lineChartOption.series[9].data =
  60192. lineData.actiRegistShareAmount // console.log(lineChartOption)
  60193. _this3.myChart.clear()
  60194. _this3.myChart.setOption(lineChartOption) // 处理饼图数据
  60195. pieChartOption.series[0].data[0].value =
  60196. result.practiceAmount
  60197. pieChartOption.series[0].data[1].value =
  60198. result.liveAmount
  60199. pieChartOption.series[0].data[2].value =
  60200. result.videoAmount
  60201. pieChartOption.series[0].data[3].value =
  60202. result.musicAmount
  60203. pieChartOption.series[0].data[4].value =
  60204. result.vipShareAmount
  60205. pieChartOption.series[0].data[5].value =
  60206. result.liveShareAmount
  60207. pieChartOption.series[0].data[6].value =
  60208. result.videoShareAmount
  60209. pieChartOption.series[0].data[7].value =
  60210. result.mallShareAmount
  60211. pieChartOption.series[0].data[8].value =
  60212. result.musicShareAmount
  60213. pieChartOption.series[0].data[9].value =
  60214. result.actiRegistShareAmount
  60215. _this3.myChart2.clear()
  60216. _this3.myChart2.setOption(pieChartOption)
  60217. _context2.next = 38
  60218. break
  60219. case 36:
  60220. _context2.prev = 36
  60221. _context2.t0 = _context2['catch'](0)
  60222. case 38:
  60223. case 'end':
  60224. return _context2.stop()
  60225. }
  60226. }
  60227. },
  60228. _callee2,
  60229. null,
  60230. [[0, 36]]
  60231. )
  60232. })
  60233. )()
  60234. }
  60235. },
  60236. render: function render() {
  60237. var _this4 = this
  60238. return createVNode('div', { style: { overflow: 'hidden' } }, [
  60239. createVNode('div', { class: styles.incomeConsus }, [
  60240. createVNode(
  60241. Cell,
  60242. { class: styles.income, title: '总收入(元)' },
  60243. {
  60244. label: function label() {
  60245. return createVNode(
  60246. 'span',
  60247. { class: styles.countPrice },
  60248. [moneyFormat(_this4.moneyInfo.totalInAmount)]
  60249. )
  60250. },
  60251. value: function value() {
  60252. return createVNode(
  60253. 'span',
  60254. {
  60255. class: styles.searchTime,
  60256. onClick: function onClick() {
  60257. return (_this4.timerStatus = true)
  60258. }
  60259. },
  60260. [_this4.dateTimeStr]
  60261. )
  60262. }
  60263. }
  60264. ),
  60265. createVNode('div', { class: styles.section }, [
  60266. createVNode(
  60267. Row,
  60268. { class: styles.numberCount },
  60269. {
  60270. default: function _default() {
  60271. return [
  60272. createVNode(
  60273. Col,
  60274. { span: 6 },
  60275. {
  60276. default: function _default() {
  60277. return [
  60278. createVNode('i', null, null),
  60279. createVNode(
  60280. 'div',
  60281. { class: styles.type },
  60282. [
  60283. createVNode('span', null, [
  60284. createTextVNode(
  60285. '\u966A\u7EC3\u8BFE'
  60286. )
  60287. ]),
  60288. createVNode(
  60289. 'span',
  60290. { class: styles.price },
  60291. [
  60292. moneyFormat(
  60293. _this4.moneyInfo.practiceAmount
  60294. )
  60295. ]
  60296. )
  60297. ]
  60298. )
  60299. ]
  60300. }
  60301. }
  60302. ),
  60303. createVNode(
  60304. Col,
  60305. { span: 6 },
  60306. {
  60307. default: function _default() {
  60308. return [
  60309. createVNode(
  60310. 'i',
  60311. { class: styles.color1 },
  60312. null
  60313. ),
  60314. createVNode(
  60315. 'div',
  60316. { class: styles.type },
  60317. [
  60318. createVNode('span', null, [
  60319. createTextVNode(
  60320. '\u76F4\u64AD\u8BFE'
  60321. )
  60322. ]),
  60323. createVNode(
  60324. 'span',
  60325. { class: styles.price },
  60326. [
  60327. moneyFormat(
  60328. _this4.moneyInfo.liveAmount
  60329. )
  60330. ]
  60331. )
  60332. ]
  60333. )
  60334. ]
  60335. }
  60336. }
  60337. ),
  60338. createVNode(
  60339. Col,
  60340. { span: 6 },
  60341. {
  60342. default: function _default() {
  60343. return [
  60344. createVNode(
  60345. 'i',
  60346. { class: styles.color2 },
  60347. null
  60348. ),
  60349. createVNode(
  60350. 'div',
  60351. { class: styles.type },
  60352. [
  60353. createVNode('span', null, [
  60354. createTextVNode(
  60355. '\u89C6\u9891\u8BFE'
  60356. )
  60357. ]),
  60358. createVNode(
  60359. 'span',
  60360. { class: styles.price },
  60361. [
  60362. moneyFormat(
  60363. _this4.moneyInfo.videoAmount
  60364. )
  60365. ]
  60366. )
  60367. ]
  60368. )
  60369. ]
  60370. }
  60371. }
  60372. ),
  60373. createVNode(
  60374. Col,
  60375. { span: 6 },
  60376. {
  60377. default: function _default() {
  60378. return [
  60379. createVNode(
  60380. 'i',
  60381. { class: styles.color3 },
  60382. null
  60383. ),
  60384. createVNode(
  60385. 'div',
  60386. { class: styles.type },
  60387. [
  60388. createVNode('span', null, [
  60389. createTextVNode('\u4E50\u8C31')
  60390. ]),
  60391. createVNode(
  60392. 'span',
  60393. { class: styles.price },
  60394. [
  60395. moneyFormat(
  60396. _this4.moneyInfo.musicAmount
  60397. )
  60398. ]
  60399. )
  60400. ]
  60401. )
  60402. ]
  60403. }
  60404. }
  60405. ),
  60406. createVNode(
  60407. Col,
  60408. { span: 6 },
  60409. {
  60410. default: function _default() {
  60411. return [
  60412. createVNode(
  60413. 'i',
  60414. { class: styles.color4 },
  60415. null
  60416. ),
  60417. createVNode(
  60418. 'div',
  60419. { class: styles.type },
  60420. [
  60421. createVNode('span', null, [
  60422. createTextVNode(
  60423. '\u5C0F\u9177Ai\u63A8\u5E7F'
  60424. )
  60425. ]),
  60426. createVNode(
  60427. 'span',
  60428. { class: styles.price },
  60429. [
  60430. moneyFormat(
  60431. _this4.moneyInfo.vipShareAmount
  60432. )
  60433. ]
  60434. )
  60435. ]
  60436. )
  60437. ]
  60438. }
  60439. }
  60440. ),
  60441. createVNode(
  60442. Col,
  60443. { span: 6 },
  60444. {
  60445. default: function _default() {
  60446. return [
  60447. createVNode(
  60448. 'i',
  60449. { class: styles.color5 },
  60450. null
  60451. ),
  60452. createVNode(
  60453. 'div',
  60454. { class: styles.type },
  60455. [
  60456. createVNode('span', null, [
  60457. createTextVNode(
  60458. '\u76F4\u64AD\u8BFE\u63A8\u8350'
  60459. )
  60460. ]),
  60461. createVNode(
  60462. 'span',
  60463. { class: styles.price },
  60464. [
  60465. moneyFormat(
  60466. _this4.moneyInfo.liveShareAmount
  60467. )
  60468. ]
  60469. )
  60470. ]
  60471. )
  60472. ]
  60473. }
  60474. }
  60475. ),
  60476. createVNode(
  60477. Col,
  60478. { span: 6 },
  60479. {
  60480. default: function _default() {
  60481. return [
  60482. createVNode(
  60483. 'i',
  60484. { class: styles.color6 },
  60485. null
  60486. ),
  60487. createVNode(
  60488. 'div',
  60489. { class: styles.type },
  60490. [
  60491. createVNode('span', null, [
  60492. createTextVNode(
  60493. '\u89C6\u9891\u8BFE\u63A8\u8350'
  60494. )
  60495. ]),
  60496. createVNode(
  60497. 'span',
  60498. { class: styles.price },
  60499. [
  60500. moneyFormat(
  60501. _this4.moneyInfo
  60502. .videoShareAmount
  60503. )
  60504. ]
  60505. )
  60506. ]
  60507. )
  60508. ]
  60509. }
  60510. }
  60511. ),
  60512. createVNode(
  60513. Col,
  60514. { span: 6 },
  60515. {
  60516. default: function _default() {
  60517. return [
  60518. createVNode(
  60519. 'i',
  60520. { class: styles.color7 },
  60521. null
  60522. ),
  60523. createVNode(
  60524. 'div',
  60525. { class: styles.type },
  60526. [
  60527. createVNode('span', null, [
  60528. createTextVNode(
  60529. '\u5546\u54C1\u63A8\u8350'
  60530. )
  60531. ]),
  60532. createVNode(
  60533. 'span',
  60534. { class: styles.price },
  60535. [
  60536. moneyFormat(
  60537. _this4.moneyInfo.mallShareAmount
  60538. )
  60539. ]
  60540. )
  60541. ]
  60542. )
  60543. ]
  60544. }
  60545. }
  60546. ),
  60547. createVNode(
  60548. Col,
  60549. { span: 6 },
  60550. {
  60551. default: function _default() {
  60552. return [
  60553. createVNode(
  60554. 'i',
  60555. { class: styles.color8 },
  60556. null
  60557. ),
  60558. createVNode(
  60559. 'div',
  60560. { class: styles.type },
  60561. [
  60562. createVNode('span', null, [
  60563. createTextVNode(
  60564. '\u4E50\u8C31\u63A8\u8350'
  60565. )
  60566. ]),
  60567. createVNode(
  60568. 'span',
  60569. { class: styles.price },
  60570. [
  60571. moneyFormat(
  60572. _this4.moneyInfo
  60573. .musicShareAmount
  60574. )
  60575. ]
  60576. )
  60577. ]
  60578. )
  60579. ]
  60580. }
  60581. }
  60582. ),
  60583. createVNode(
  60584. Col,
  60585. { span: 6 },
  60586. {
  60587. default: function _default() {
  60588. return [
  60589. createVNode(
  60590. 'i',
  60591. { class: styles.color9 },
  60592. null
  60593. ),
  60594. createVNode(
  60595. 'div',
  60596. { class: styles.type },
  60597. [
  60598. createVNode('span', null, [
  60599. createTextVNode(
  60600. '\u6D3B\u52A8\u62A5\u540D'
  60601. )
  60602. ]),
  60603. createVNode(
  60604. 'span',
  60605. { class: styles.price },
  60606. [
  60607. moneyFormat(
  60608. _this4.moneyInfo
  60609. .actiRegistShareAmount
  60610. )
  60611. ]
  60612. )
  60613. ]
  60614. )
  60615. ]
  60616. }
  60617. }
  60618. )
  60619. ]
  60620. }
  60621. }
  60622. )
  60623. ]),
  60624. createVNode(
  60625. 'div',
  60626. { id: 'incomeClass', class: styles.incomeLine },
  60627. null
  60628. ),
  60629. createVNode('div', { class: styles.incomeTitle }, [
  60630. createVNode('i', null, null),
  60631. createTextVNode('\u6536\u5165\u7ED3\u6784')
  60632. ]),
  60633. createVNode(
  60634. 'div',
  60635. { class: [styles.pieSection, 'van-hairline--bottom'] },
  60636. [
  60637. createVNode(
  60638. 'div',
  60639. { id: 'structrueClass', class: styles.pieIncome },
  60640. null
  60641. ),
  60642. createVNode('div', { class: styles.rateAll }, [
  60643. createVNode('div', null, [
  60644. createVNode(
  60645. 'img',
  60646. { src: getAssetsHomeFile('icon_user.png') },
  60647. null
  60648. ),
  60649. createVNode('span', null, [
  60650. createTextVNode(
  60651. '\u4E2A\u4EBA\u6536\u5165\u603B\u5360\u6BD4'
  60652. )
  60653. ]),
  60654. createVNode('span', { class: styles.rate }, [
  60655. this.moneyInfo.totalSingleRate,
  60656. createTextVNode('%')
  60657. ])
  60658. ]),
  60659. createVNode('div', null, [
  60660. createVNode(
  60661. 'img',
  60662. { src: getAssetsHomeFile('icon_fly.png') },
  60663. null
  60664. ),
  60665. createVNode('span', null, [
  60666. createTextVNode(
  60667. '\u63A8\u5E7F\u6536\u76CA\u603B\u5360\u6BD4'
  60668. )
  60669. ]),
  60670. createVNode('span', { class: styles.rate }, [
  60671. this.moneyInfo.totalShareRate,
  60672. createTextVNode('%')
  60673. ])
  60674. ])
  60675. ])
  60676. ]
  60677. ),
  60678. createVNode('div', { class: styles.pieData }, [
  60679. createVNode('div', null, [
  60680. createVNode('i', { class: styles.piePractice }, null),
  60681. createVNode('span', { class: styles.pieTitle }, [
  60682. createTextVNode('\u966A\u7EC3\u8BFE')
  60683. ]),
  60684. createVNode('span', null, [
  60685. this.moneyInfo.practiceRate,
  60686. createTextVNode('%')
  60687. ])
  60688. ]),
  60689. createVNode('div', null, [
  60690. createVNode('i', { class: styles.pie1 }, null),
  60691. createVNode('span', { class: styles.pieTitle }, [
  60692. createTextVNode('\u5C0F\u9177Ai\u63A8\u5E7F')
  60693. ]),
  60694. createVNode('span', null, [
  60695. this.moneyInfo.vipShareRate,
  60696. createTextVNode('%')
  60697. ])
  60698. ]),
  60699. createVNode('div', null, [
  60700. createVNode('i', { class: styles.pieLive }, null),
  60701. createVNode('span', { class: styles.pieTitle }, [
  60702. createTextVNode('\u76F4\u64AD\u8BFE')
  60703. ]),
  60704. createVNode('span', null, [
  60705. this.moneyInfo.liveRate,
  60706. createTextVNode('%')
  60707. ])
  60708. ]),
  60709. createVNode('div', null, [
  60710. createVNode('i', { class: styles.pie2 }, null),
  60711. createVNode('span', { class: styles.pieTitle }, [
  60712. createTextVNode('\u76F4\u64AD\u8BFE\u63A8\u8350')
  60713. ]),
  60714. createVNode('span', null, [
  60715. this.moneyInfo.liveShareRate,
  60716. createTextVNode('%')
  60717. ])
  60718. ]),
  60719. createVNode('div', null, [
  60720. createVNode('i', { class: styles.pieVideo }, null),
  60721. createVNode('span', { class: styles.pieTitle }, [
  60722. createTextVNode('\u89C6\u9891\u8BFE')
  60723. ]),
  60724. createVNode('span', null, [
  60725. this.moneyInfo.videoRate,
  60726. createTextVNode('%')
  60727. ])
  60728. ]),
  60729. createVNode('div', null, [
  60730. createVNode('i', { class: styles.pie3 }, null),
  60731. createVNode('span', { class: styles.pieTitle }, [
  60732. createTextVNode('\u89C6\u9891\u8BFE\u63A8\u8350')
  60733. ]),
  60734. createVNode('span', null, [
  60735. this.moneyInfo.videoShareRate,
  60736. createTextVNode('%')
  60737. ])
  60738. ]),
  60739. createVNode('div', null, [
  60740. createVNode('i', { class: styles.pieMusic }, null),
  60741. createVNode('span', { class: styles.pieTitle }, [
  60742. createTextVNode('\u4E50\u8C31')
  60743. ]),
  60744. createVNode('span', null, [
  60745. this.moneyInfo.musicRate,
  60746. createTextVNode('%')
  60747. ])
  60748. ]),
  60749. createVNode('div', null, [
  60750. createVNode('i', { class: styles.pie5 }, null),
  60751. createVNode('span', { class: styles.pieTitle }, [
  60752. createTextVNode('\u4E50\u8C31\u63A8\u8350')
  60753. ]),
  60754. createVNode('span', null, [
  60755. this.moneyInfo.musicShareRate,
  60756. createTextVNode('%')
  60757. ])
  60758. ]),
  60759. createVNode('div', null, [
  60760. createVNode('i', { class: styles.pie6 }, null),
  60761. createVNode('span', { class: styles.pieTitle }, [
  60762. createTextVNode('\u6D3B\u52A8\u62A5\u540D')
  60763. ]),
  60764. createVNode('span', null, [
  60765. this.moneyInfo.actiRegistShareRate,
  60766. createTextVNode('%')
  60767. ])
  60768. ]),
  60769. createVNode('div', null, [
  60770. createVNode('i', { class: styles.pie4 }, null),
  60771. createVNode('span', { class: styles.pieTitle }, [
  60772. createTextVNode('\u5546\u54C1\u63A8\u8350')
  60773. ]),
  60774. createVNode('span', null, [
  60775. this.moneyInfo.mallShareRate,
  60776. createTextVNode('%')
  60777. ])
  60778. ])
  60779. ])
  60780. ]),
  60781. createVNode(
  60782. Popup,
  60783. {
  60784. show: this.timerStatus,
  60785. 'onUpdate:show': function onUpdateShow($event) {
  60786. return (_this4.timerStatus = $event)
  60787. },
  60788. position: 'bottom',
  60789. round: true,
  60790. zIndex: 99999999
  60791. },
  60792. {
  60793. default: function _default() {
  60794. return [
  60795. _this4.params.timeType === 'MONTH' &&
  60796. createVNode(
  60797. DatetimePicker,
  60798. {
  60799. modelValue: _this4.currentDate,
  60800. 'onUpdate:modelValue':
  60801. function onUpdateModelValue($event) {
  60802. return (_this4.currentDate = $event)
  60803. },
  60804. type: 'year-month',
  60805. title: '选择时间',
  60806. formatter: formatterDate,
  60807. onCancle: function onCancle() {
  60808. return (_this4.timerStatus = false)
  60809. },
  60810. onConfirm: function onConfirm(value) {
  60811. _this4.params.dateTime =
  60812. dayjs(value).format('YYYY-MM')
  60813. _this4.dateTimeStr =
  60814. dayjs(value).format('YYYY年MM月')
  60815. _this4.timerStatus = false
  60816. _this4.getList()
  60817. }
  60818. },
  60819. {
  60820. 'columns-top': function columnsTop() {
  60821. return createVNode(
  60822. 'div',
  60823. { class: styles.timePopup },
  60824. [
  60825. createVNode(
  60826. Button,
  60827. {
  60828. type: 'primary',
  60829. plain:
  60830. _this4.params.timeType !== 'MONTH',
  60831. size: 'mini',
  60832. class: styles.timeMonth,
  60833. onClick: function onClick() {
  60834. return (_this4.params.timeType =
  60835. 'MONTH')
  60836. }
  60837. },
  60838. {
  60839. default: function _default() {
  60840. return [
  60841. createTextVNode('\u6309\u6708')
  60842. ]
  60843. }
  60844. }
  60845. ),
  60846. createVNode(
  60847. Button,
  60848. {
  60849. type: 'primary',
  60850. plain:
  60851. _this4.params.timeType !== 'YEAR',
  60852. size: 'mini',
  60853. class: styles.timeYear,
  60854. onClick: function onClick() {
  60855. return (_this4.params.timeType =
  60856. 'YEAR')
  60857. }
  60858. },
  60859. {
  60860. default: function _default() {
  60861. return [
  60862. createTextVNode('\u6309\u5E74')
  60863. ]
  60864. }
  60865. }
  60866. )
  60867. ]
  60868. )
  60869. }
  60870. }
  60871. ),
  60872. _this4.params.timeType === 'YEAR' &&
  60873. createVNode(
  60874. Picker,
  60875. {
  60876. modelValue: _this4.currentDate,
  60877. 'onUpdate:modelValue':
  60878. function onUpdateModelValue($event) {
  60879. return (_this4.currentDate = $event)
  60880. },
  60881. title: '选择时间',
  60882. columns: yearColumns,
  60883. defaultIndex: defaultIndex,
  60884. onCancel: function onCancel() {
  60885. return (_this4.timerStatus = false)
  60886. },
  60887. onConfirm: function onConfirm(obj, index) {
  60888. _this4.params.dateTime = obj.value
  60889. defaultIndex = index // 记录当前选择的年份
  60890. _this4.dateTimeStr = obj.text
  60891. _this4.timerStatus = false
  60892. _this4.getList()
  60893. }
  60894. },
  60895. {
  60896. 'columns-top': function columnsTop() {
  60897. return createVNode(
  60898. 'div',
  60899. { class: styles.timePopup },
  60900. [
  60901. createVNode(
  60902. Button,
  60903. {
  60904. type: 'primary',
  60905. plain:
  60906. _this4.params.timeType !== 'MONTH',
  60907. size: 'mini',
  60908. class: styles.timeMonth,
  60909. onClick: function onClick() {
  60910. return (_this4.params.timeType =
  60911. 'MONTH')
  60912. }
  60913. },
  60914. {
  60915. default: function _default() {
  60916. return [
  60917. createTextVNode('\u6309\u6708')
  60918. ]
  60919. }
  60920. }
  60921. ),
  60922. createVNode(
  60923. Button,
  60924. {
  60925. type: 'primary',
  60926. plain:
  60927. _this4.params.timeType !== 'YEAR',
  60928. onClick: function onClick() {
  60929. return (_this4.params.timeType =
  60930. 'YEAR')
  60931. },
  60932. size: 'mini',
  60933. class: styles.timeYear
  60934. },
  60935. {
  60936. default: function _default() {
  60937. return [
  60938. createTextVNode('\u6309\u5E74')
  60939. ]
  60940. }
  60941. }
  60942. )
  60943. ]
  60944. )
  60945. }
  60946. }
  60947. )
  60948. ]
  60949. }
  60950. }
  60951. )
  60952. ])
  60953. }
  60954. })
  60955. )
  60956. }
  60957. }
  60958. }
  60959. )
  60960. })()