index.js 414 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1658993502531, function(require, module, exports) {
  8. exports.__esModule = true;
  9. exports["default"] = exports.Component = void 0;
  10. var _core = require("./core");
  11. exports.Global = _core.Global;
  12. exports.Chart = _core.Chart;
  13. exports.Shape = _core.Shape;
  14. exports.G = _core.G;
  15. exports.Util = _core.Util;
  16. exports.Helper = _core.Helper;
  17. exports.track = _core.track;
  18. require("./geom/");
  19. require("./geom/adjust/");
  20. require("./coord/polar");
  21. require("./component/axis/circle");
  22. require("./component/guide/arc");
  23. require("./component/guide/html");
  24. require("./component/guide/line");
  25. require("./component/guide/rect");
  26. require("./component/guide/text");
  27. require("./component/guide/tag");
  28. require("./component/guide/point");
  29. var _marker = _interopRequireDefault(require("./component/marker"));
  30. var Tooltip = _interopRequireWildcard(require("./plugin/tooltip"));
  31. var Guide = _interopRequireWildcard(require("./plugin/guide"));
  32. var Legend = _interopRequireWildcard(require("./plugin/legend"));
  33. var Animation = _interopRequireWildcard(require("./animation/detail"));
  34. var _animate = _interopRequireDefault(require("./animation/animate"));
  35. exports.Animate = _animate["default"];
  36. require("./interaction/new/index");
  37. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  38. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  39. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  40. /**
  41. * Default, without interactins
  42. */
  43. // polar coordinate
  44. // the axis for polar coordinate
  45. var Component = {
  46. Marker: _marker["default"]
  47. }; // register plugins
  48. exports.Component = Component;
  49. _core.Chart.plugins.register([Tooltip, Legend, Guide, Animation]); // 默认添加交互
  50. var _default = {
  51. Component: Component,
  52. Global: _core.Global,
  53. Chart: _core.Chart,
  54. Shape: _core.Shape,
  55. G: _core.G,
  56. Util: _core.Util,
  57. Helper: _core.Helper,
  58. track: _core.track,
  59. Animate: _animate["default"]
  60. };
  61. exports["default"] = _default;
  62. }, function(modId) {var map = {"./core":1658993502532,"./geom/":1658993502589,"./geom/adjust/":1658993502605,"./coord/polar":1658993502609,"./component/axis/circle":1658993502610,"./component/guide/arc":1658993502611,"./component/guide/html":1658993502613,"./component/guide/line":1658993502614,"./component/guide/rect":1658993502615,"./component/guide/text":1658993502616,"./component/guide/tag":1658993502617,"./component/guide/point":1658993502618,"./component/marker":1658993502619,"./plugin/tooltip":1658993502620,"./plugin/guide":1658993502624,"./plugin/legend":1658993502625,"./animation/detail":1658993502626,"./animation/animate":1658993502630,"./interaction/new/index":1658993502634}; return __REQUIRE__(map[modId], modId); })
  63. __DEFINE__(1658993502532, function(require, module, exports) {
  64. exports.__esModule = true;
  65. exports.Helper = exports.Util = exports.G = exports.track = exports.version = void 0;
  66. var _global = _interopRequireDefault(require("./global"));
  67. exports.Global = _global["default"];
  68. var _chart = _interopRequireDefault(require("./chart/chart"));
  69. exports.Chart = _chart["default"];
  70. var _shape = _interopRequireDefault(require("./geom/shape/shape"));
  71. exports.Shape = _shape["default"];
  72. var G = _interopRequireWildcard(require("./graphic/index"));
  73. exports.G = G;
  74. var Util = _interopRequireWildcard(require("./util/common"));
  75. exports.Util = Util;
  76. var Helper = _interopRequireWildcard(require("./util/helper"));
  77. exports.Helper = Helper;
  78. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  79. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  80. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  81. var track = function track() {
  82. return null;
  83. };
  84. exports.track = track;
  85. var version = _global["default"].version;
  86. exports.version = version;
  87. }, function(modId) { var map = {"./global":1658993502533,"./chart/chart":1658993502538,"./geom/shape/shape":1658993502556,"./graphic/index":1658993502565,"./util/common":1658993502535,"./util/helper":1658993502588}; return __REQUIRE__(map[modId], modId); })
  88. __DEFINE__(1658993502533, function(require, module, exports) {
  89. exports.__esModule = true;
  90. exports["default"] = void 0;
  91. var _theme = _interopRequireDefault(require("./theme"));
  92. var _common = require("./util/common");
  93. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  94. var Global = {
  95. version: '3.7.7',
  96. scales: {},
  97. widthRatio: {
  98. column: 1 / 2,
  99. rose: 0.999999,
  100. multiplePie: 3 / 4
  101. },
  102. lineDash: [4, 4]
  103. };
  104. Global.setTheme = function (theme) {
  105. (0, _common.deepMix)(this, theme);
  106. };
  107. Global.setTheme(_theme["default"]);
  108. var _default = Global;
  109. exports["default"] = _default;
  110. }, function(modId) { var map = {"./theme":1658993502534,"./util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  111. __DEFINE__(1658993502534, function(require, module, exports) {
  112. exports.__esModule = true;
  113. exports["default"] = void 0;
  114. var _common = require("./util/common");
  115. /**
  116. * @fileOverview default theme
  117. * @author dxq613@gail.com
  118. */
  119. var color1 = '#E8E8E8'; // color of axis-line and axis-grid
  120. var color2 = '#808080'; // color of axis label
  121. var defaultAxis = {
  122. label: {
  123. fill: color2,
  124. fontSize: 10
  125. },
  126. line: {
  127. stroke: color1,
  128. lineWidth: 1
  129. },
  130. grid: {
  131. type: 'line',
  132. stroke: color1,
  133. lineWidth: 1,
  134. lineDash: [2]
  135. },
  136. tickLine: null,
  137. labelOffset: 7.5
  138. };
  139. var Theme = {
  140. fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
  141. defaultColor: '#1890FF',
  142. pixelRatio: 1,
  143. padding: 'auto',
  144. appendPadding: 15,
  145. colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
  146. shapes: {
  147. line: ['line', 'dash'],
  148. point: ['circle', 'hollowCircle']
  149. },
  150. sizes: [4, 10],
  151. axis: {
  152. common: defaultAxis,
  153. // common axis configuration
  154. bottom: (0, _common.mix)({}, defaultAxis, {
  155. grid: null
  156. }),
  157. left: (0, _common.mix)({}, defaultAxis, {
  158. line: null
  159. }),
  160. right: (0, _common.mix)({}, defaultAxis, {
  161. line: null
  162. }),
  163. circle: (0, _common.mix)({}, defaultAxis, {
  164. line: null
  165. }),
  166. radius: (0, _common.mix)({}, defaultAxis, {
  167. labelOffset: 4
  168. })
  169. },
  170. shape: {
  171. line: {
  172. lineWidth: 2,
  173. lineJoin: 'round',
  174. lineCap: 'round'
  175. },
  176. point: {
  177. lineWidth: 0,
  178. size: 3
  179. },
  180. area: {
  181. fillOpacity: 0.1
  182. }
  183. },
  184. _defaultAxis: defaultAxis
  185. };
  186. var _default = Theme;
  187. exports["default"] = _default;
  188. }, function(modId) { var map = {"./util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  189. __DEFINE__(1658993502535, function(require, module, exports) {
  190. exports.__esModule = true;
  191. var _exportNames = {
  192. isObjectValueEqual: true,
  193. parsePadding: true,
  194. directionEnabled: true,
  195. toTimeStamp: true,
  196. upperFirst: true,
  197. lowerFirst: true,
  198. isString: true,
  199. isNumber: true,
  200. isBoolean: true,
  201. isFunction: true,
  202. isDate: true,
  203. isArray: true,
  204. isNil: true,
  205. isObject: true,
  206. isPlainObject: true,
  207. isEqual: true,
  208. deepMix: true,
  209. mix: true,
  210. each: true,
  211. uniq: true,
  212. find: true,
  213. Array: true
  214. };
  215. exports.isObjectValueEqual = isObjectValueEqual;
  216. exports.parsePadding = parsePadding;
  217. exports.directionEnabled = directionEnabled;
  218. exports.toTimeStamp = toTimeStamp;
  219. exports.Array = void 0;
  220. var _util = require("@antv/util");
  221. exports.upperFirst = _util.upperFirst;
  222. exports.lowerFirst = _util.lowerFirst;
  223. exports.isString = _util.isString;
  224. exports.isNumber = _util.isNumber;
  225. exports.isBoolean = _util.isBoolean;
  226. exports.isFunction = _util.isFunction;
  227. exports.isDate = _util.isDate;
  228. exports.isArray = _util.isArray;
  229. exports.isNil = _util.isNil;
  230. exports.isObject = _util.isObject;
  231. exports.isPlainObject = _util.isPlainObject;
  232. exports.isEqual = _util.isEqual;
  233. exports.deepMix = _util.deepMix;
  234. exports.mix = _util.mix;
  235. exports.each = _util.each;
  236. exports.uniq = _util.uniq;
  237. exports.find = _util.find;
  238. var ArrayUtil = _interopRequireWildcard(require("./array"));
  239. exports.Array = ArrayUtil;
  240. var _dom = require("./dom");
  241. Object.keys(_dom).forEach(function (key) {
  242. if (key === "default" || key === "__esModule") return;
  243. if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  244. exports[key] = _dom[key];
  245. });
  246. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  247. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  248. /**
  249. * @fileOverview Utility for F2
  250. * @author dxq613 @gmail.com
  251. * @author sima.zhang1990@gmail.com
  252. */
  253. function isObjectValueEqual(a, b) {
  254. // for vue.js
  255. a = Object.assign({}, a);
  256. b = Object.assign({}, b);
  257. var aProps = Object.getOwnPropertyNames(a);
  258. var bProps = Object.getOwnPropertyNames(b);
  259. if (aProps.length !== bProps.length) {
  260. return false;
  261. }
  262. for (var i = 0, len = aProps.length; i < len; i++) {
  263. var propName = aProps[i];
  264. if (a[propName] !== b[propName]) {
  265. return false;
  266. }
  267. }
  268. return true;
  269. }
  270. function parsePadding(padding) {
  271. var top;
  272. var right;
  273. var bottom;
  274. var left;
  275. if ((0, _util.isNumber)(padding) || (0, _util.isString)(padding)) {
  276. top = bottom = left = right = padding;
  277. } else if ((0, _util.isArray)(padding)) {
  278. top = padding[0];
  279. right = !(0, _util.isNil)(padding[1]) ? padding[1] : padding[0];
  280. bottom = !(0, _util.isNil)(padding[2]) ? padding[2] : padding[0];
  281. left = !(0, _util.isNil)(padding[3]) ? padding[3] : right;
  282. }
  283. return [top, right, bottom, left];
  284. }
  285. function directionEnabled(mode, dir) {
  286. if (mode === undefined) {
  287. return true;
  288. } else if (typeof mode === 'string') {
  289. return mode.indexOf(dir) !== -1;
  290. }
  291. return false;
  292. }
  293. function toTimeStamp(value) {
  294. if ((0, _util.isString)(value)) {
  295. if (value.indexOf('T') > 0) {
  296. value = new Date(value).getTime();
  297. } else {
  298. // new Date('2010/01/10') 和 new Date('2010-01-10') 的差别在于:
  299. // 如果仅有年月日时,前者是带有时区的: Fri Jan 10 2020 02:40:13 GMT+0800 (中国标准时间)
  300. // 后者会格式化成 Sun Jan 10 2010 08:00:00 GMT+0800 (中国标准时间)
  301. value = new Date(value.replace(/-/gi, '/')).getTime();
  302. }
  303. }
  304. if ((0, _util.isDate)(value)) {
  305. value = value.getTime();
  306. }
  307. return value;
  308. }
  309. }, function(modId) { var map = {"./array":1658993502536,"./dom":1658993502537}; return __REQUIRE__(map[modId], modId); })
  310. __DEFINE__(1658993502536, function(require, module, exports) {
  311. exports.__esModule = true;
  312. exports.merge = merge;
  313. exports.values = values;
  314. exports.firstValue = firstValue;
  315. exports.group = group;
  316. exports.groupToMap = groupToMap;
  317. exports.remove = remove;
  318. exports.getRange = getRange;
  319. var _util = require("@antv/util");
  320. function merge(dataArray) {
  321. var rst = [];
  322. for (var i = 0, len = dataArray.length; i < len; i++) {
  323. rst = rst.concat(dataArray[i]);
  324. }
  325. return rst;
  326. }
  327. function values(data, name) {
  328. var rst = [];
  329. var tmpMap = {};
  330. for (var i = 0, len = data.length; i < len; i++) {
  331. var obj = data[i];
  332. var value = obj[name];
  333. if (!(0, _util.isNil)(value)) {
  334. if (!(0, _util.isArray)(value)) {
  335. if (!tmpMap[value]) {
  336. rst.push(value);
  337. tmpMap[value] = true;
  338. }
  339. } else {
  340. (0, _util.each)(value, function (val) {
  341. if (!tmpMap[val]) {
  342. rst.push(val);
  343. tmpMap[val] = true;
  344. }
  345. });
  346. }
  347. }
  348. }
  349. return rst;
  350. }
  351. function firstValue(data, name) {
  352. var rst = null;
  353. for (var i = 0, len = data.length; i < len; i++) {
  354. var obj = data[i];
  355. var value = obj[name];
  356. if (!(0, _util.isNil)(value)) {
  357. if ((0, _util.isArray)(value)) {
  358. rst = value[0];
  359. } else {
  360. rst = value;
  361. }
  362. break;
  363. }
  364. }
  365. return rst;
  366. }
  367. function groupToMap(data, fields) {
  368. if (!fields) {
  369. return {
  370. 0: data
  371. };
  372. }
  373. var callback = function callback(row) {
  374. var unique = '_';
  375. for (var i = 0, l = fields.length; i < l; i++) {
  376. unique += row[fields[i]] && row[fields[i]].toString();
  377. }
  378. return unique;
  379. };
  380. var groups = {};
  381. for (var i = 0, len = data.length; i < len; i++) {
  382. var row = data[i];
  383. var key = callback(row);
  384. if (groups[key]) {
  385. groups[key].push(row);
  386. } else {
  387. groups[key] = [row];
  388. }
  389. }
  390. return groups;
  391. }
  392. function group(data, fields, appendConditions) {
  393. if (appendConditions === void 0) {
  394. appendConditions = {};
  395. }
  396. if (!fields) {
  397. return [data];
  398. }
  399. var groups = groupToMap(data, fields);
  400. var array = [];
  401. if (fields.length === 1 && appendConditions[fields[0]]) {
  402. var _values = appendConditions[fields[0]];
  403. (0, _util.each)(_values, function (value) {
  404. value = '_' + value;
  405. array.push(groups[value]);
  406. });
  407. } else {
  408. for (var i in groups) {
  409. array.push(groups[i]);
  410. }
  411. }
  412. return array;
  413. }
  414. function remove(arr, obj) {
  415. if (!arr) {
  416. return;
  417. }
  418. var index = arr.indexOf(obj);
  419. if (index !== -1) {
  420. arr.splice(index, 1);
  421. }
  422. }
  423. function getRange(values) {
  424. if (!values.length) {
  425. return {
  426. min: 0,
  427. max: 0
  428. };
  429. }
  430. var max = Math.max.apply(null, values);
  431. var min = Math.min.apply(null, values);
  432. return {
  433. min: min,
  434. max: max
  435. };
  436. }
  437. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  438. __DEFINE__(1658993502537, function(require, module, exports) {
  439. exports.__esModule = true;
  440. exports.isCanvasElement = isCanvasElement;
  441. exports.getPixelRatio = getPixelRatio;
  442. exports.getStyle = getStyle;
  443. exports.getWidth = getWidth;
  444. exports.getHeight = getHeight;
  445. exports.getDomById = getDomById;
  446. exports.getRelativePosition = getRelativePosition;
  447. exports.addEventListener = addEventListener;
  448. exports.removeEventListener = removeEventListener;
  449. exports.createEvent = createEvent;
  450. exports.measureText = measureText;
  451. exports.isBrowser = exports.isNode = exports.isMy = exports.isWx = void 0;
  452. /**
  453. * Detects support for options object argument in addEventListener.
  454. * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  455. * @private
  456. */
  457. var supportsEventListenerOptions = function () {
  458. var supports = false;
  459. try {
  460. var options = Object.defineProperty({}, 'passive', {
  461. get: function get() {
  462. supports = true;
  463. }
  464. });
  465. window.addEventListener('e', null, options);
  466. } catch (e) {// continue regardless of error
  467. }
  468. return supports;
  469. }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
  470. // https://github.com/chartjs/Chart.js/issues/4287
  471. var eventListenerOptions = supportsEventListenerOptions ? {
  472. passive: true
  473. } : false;
  474. /* global wx, my */
  475. // weixin miniprogram
  476. var isWx = typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function'; // ant miniprogram
  477. exports.isWx = isWx;
  478. var isMy = typeof my === 'object' && typeof my.getSystemInfoSync === 'function'; // in node
  479. exports.isMy = isMy;
  480. var isNode = typeof global && !typeof window; // in browser
  481. exports.isNode = isNode;
  482. var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined';
  483. exports.isBrowser = isBrowser;
  484. function isCanvasElement(el) {
  485. if (!el || typeof el !== 'object') return false;
  486. if (el.nodeType === 1 && el.nodeName) {
  487. // HTMLCanvasElement
  488. return true;
  489. } // CanvasElement
  490. return !!el.isCanvasElement;
  491. }
  492. function getPixelRatio() {
  493. return window && window.devicePixelRatio || 1;
  494. }
  495. function getStyle(el, property) {
  496. return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
  497. }
  498. function getWidth(el) {
  499. var width = getStyle(el, 'width');
  500. if (width === 'auto') {
  501. width = el.offsetWidth;
  502. }
  503. return parseFloat(width);
  504. }
  505. function getHeight(el) {
  506. var height = getStyle(el, 'height');
  507. if (height === 'auto') {
  508. height = el.offsetHeight;
  509. }
  510. return parseFloat(height);
  511. }
  512. function getDomById(id) {
  513. if (!id) {
  514. return null;
  515. }
  516. return document.getElementById(id);
  517. }
  518. function getRelativePosition(point, canvas) {
  519. var canvasDom = canvas.get('el');
  520. if (!canvasDom) return point;
  521. var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
  522. top = _canvasDom$getBoundin.top,
  523. right = _canvasDom$getBoundin.right,
  524. bottom = _canvasDom$getBoundin.bottom,
  525. left = _canvasDom$getBoundin.left;
  526. var paddingLeft = parseFloat(getStyle(canvasDom, 'padding-left'));
  527. var paddingTop = parseFloat(getStyle(canvasDom, 'padding-top'));
  528. var paddingRight = parseFloat(getStyle(canvasDom, 'padding-right'));
  529. var paddingBottom = parseFloat(getStyle(canvasDom, 'padding-bottom'));
  530. var width = right - left - paddingLeft - paddingRight;
  531. var height = bottom - top - paddingTop - paddingBottom;
  532. var pixelRatio = canvas.get('pixelRatio');
  533. var mouseX = (point.x - left - paddingLeft) / width * canvasDom.width / pixelRatio;
  534. var mouseY = (point.y - top - paddingTop) / height * canvasDom.height / pixelRatio;
  535. return {
  536. x: mouseX,
  537. y: mouseY
  538. };
  539. }
  540. function addEventListener(source, type, listener) {
  541. source.addEventListener(type, listener, eventListenerOptions);
  542. }
  543. function removeEventListener(source, type, listener) {
  544. source.removeEventListener(type, listener, eventListenerOptions);
  545. }
  546. function createEventObj(type, chart, x, y, nativeEvent) {
  547. return {
  548. type: type,
  549. chart: chart,
  550. "native": nativeEvent || null,
  551. x: x !== undefined ? x : null,
  552. y: y !== undefined ? y : null
  553. };
  554. }
  555. function createEvent(event, chart) {
  556. var type = event.type;
  557. var clientPoint; // 说明是touch相关事件
  558. if (event.touches) {
  559. // https://developer.mozilla.org/zh-CN/docs/Web/API/TouchEvent/changedTouches
  560. // 这里直接拿changedTouches就可以了,不管是touchstart, touchmove, touchend changedTouches 都是有的
  561. // 为了以防万一,做个空判断
  562. var touch = event.changedTouches[0] || {}; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置
  563. var x = touch.x,
  564. y = touch.y,
  565. clientX = touch.clientX,
  566. clientY = touch.clientY; // 小程序环境会有x,y,这里就直接返回
  567. if (x && y) {
  568. return createEventObj(type, chart, x, y, event);
  569. }
  570. clientPoint = {
  571. x: clientX,
  572. y: clientY
  573. };
  574. } else {
  575. // mouse相关事件
  576. clientPoint = {
  577. x: event.clientX,
  578. y: event.clientY
  579. };
  580. } // 理论上应该是只有有在浏览器环境才会走到这里
  581. var canvas = chart.get('canvas'); // 通过clientX, clientY 计算x, y
  582. var point = getRelativePosition(clientPoint, canvas);
  583. return createEventObj(type, chart, point.x, point.y, event);
  584. }
  585. function measureText(text, font, ctx) {
  586. if (!ctx) {
  587. ctx = document.createElement('canvas').getContext('2d');
  588. }
  589. ctx.font = font || '12px sans-serif';
  590. return ctx.measureText(text);
  591. }
  592. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  593. __DEFINE__(1658993502538, function(require, module, exports) {
  594. exports.__esModule = true;
  595. exports["default"] = void 0;
  596. var _const = require("./const");
  597. var _base = _interopRequireDefault(require("../base"));
  598. var _plot = _interopRequireDefault(require("./plot"));
  599. var _common = require("../util/common");
  600. var _index = _interopRequireDefault(require("../coord/index"));
  601. var _base2 = _interopRequireDefault(require("../geom/base"));
  602. var _scale = _interopRequireDefault(require("./controller/scale"));
  603. var _axis = _interopRequireDefault(require("./controller/axis"));
  604. var _global = _interopRequireDefault(require("../global"));
  605. var _index2 = require("../graphic/index");
  606. var _helper = require("../util/helper");
  607. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  608. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  609. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  610. function compare(a, b) {
  611. return a - b;
  612. }
  613. function _isScaleExist(scales, compareScale) {
  614. var flag = false;
  615. (0, _common.each)(scales, function (scale) {
  616. var scaleValues = [].concat(scale.values);
  617. var compareScaleValues = [].concat(compareScale.values);
  618. if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
  619. flag = true;
  620. return;
  621. }
  622. });
  623. return flag;
  624. }
  625. var Chart = /*#__PURE__*/function (_Base) {
  626. _inheritsLoose(Chart, _Base);
  627. Chart.initPlugins = function initPlugins() {
  628. return {
  629. _plugins: [],
  630. _cacheId: 0,
  631. register: function register(plugins) {
  632. var p = this._plugins;
  633. [].concat(plugins).forEach(function (plugin) {
  634. if (p.indexOf(plugin) === -1) {
  635. p.push(plugin);
  636. }
  637. });
  638. this._cacheId++;
  639. },
  640. unregister: function unregister(plugins) {
  641. var p = this._plugins;
  642. [].concat(plugins).forEach(function (plugin) {
  643. var idx = p.indexOf(plugin);
  644. if (idx !== -1) {
  645. p.splice(idx, 1);
  646. }
  647. });
  648. this._cacheId++;
  649. },
  650. clear: function clear() {
  651. this._plugins = [];
  652. this._cacheId++;
  653. },
  654. count: function count() {
  655. return this._plugins.length;
  656. },
  657. getAll: function getAll() {
  658. return this._plugins;
  659. },
  660. notify: function notify(chart, hook, args) {
  661. var descriptors = this.descriptors(chart);
  662. var ilen = descriptors.length;
  663. var i;
  664. var descriptor;
  665. var plugin;
  666. var params;
  667. var method;
  668. for (i = 0; i < ilen; ++i) {
  669. descriptor = descriptors[i];
  670. plugin = descriptor.plugin;
  671. method = plugin[hook];
  672. if (typeof method === 'function') {
  673. params = [chart].concat(args || []);
  674. if (method.apply(plugin, params) === false) {
  675. return false;
  676. }
  677. }
  678. }
  679. return true;
  680. },
  681. descriptors: function descriptors(chart) {
  682. var cache = chart._plugins || (chart._plugins = {});
  683. if (cache.id === this._cacheId) {
  684. return cache.descriptors;
  685. }
  686. var plugins = [];
  687. var descriptors = [];
  688. this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
  689. var idx = plugins.indexOf(plugin);
  690. if (idx !== -1) {
  691. return;
  692. }
  693. plugins.push(plugin);
  694. descriptors.push({
  695. plugin: plugin
  696. });
  697. });
  698. cache.descriptors = descriptors;
  699. cache.id = this._cacheId;
  700. return descriptors;
  701. }
  702. };
  703. };
  704. var _proto = Chart.prototype;
  705. _proto.getDefaultCfg = function getDefaultCfg() {
  706. return {
  707. /**
  708. * the id of canvas
  709. * @type {String}
  710. */
  711. id: null,
  712. rendered: false,
  713. /**
  714. * padding
  715. * @type {Array|Number}
  716. */
  717. padding: _global["default"].padding,
  718. /**
  719. * data
  720. * @type {Array}
  721. */
  722. data: null,
  723. /**
  724. * scales of chart
  725. * @type {Object}
  726. */
  727. scales: {},
  728. /**
  729. * @private
  730. * geometry instances
  731. * @type {Array}
  732. */
  733. geoms: [],
  734. /**
  735. * scale configuration
  736. * @type {Object}
  737. */
  738. colDefs: null,
  739. pixelRatio: _global["default"].pixelRatio,
  740. /**
  741. * filter options
  742. * @type {Object}
  743. */
  744. filters: null,
  745. appendPadding: _global["default"].appendPadding
  746. };
  747. };
  748. _proto._syncYScales = function _syncYScales() {
  749. var syncY = this.get('syncY');
  750. if (!syncY) {
  751. return;
  752. }
  753. var geoms = this.get('geoms');
  754. var syncScales = [];
  755. var min = [];
  756. var max = [];
  757. (0, _common.each)(geoms, function (geom) {
  758. var yScale = geom.getYScale();
  759. if (yScale.isLinear) {
  760. syncScales.push(yScale);
  761. min.push(yScale.min);
  762. max.push(yScale.max);
  763. }
  764. });
  765. min = Math.min.apply(null, min);
  766. max = Math.max.apply(null, max);
  767. (0, _common.each)(syncScales, function (scale) {
  768. scale.change({
  769. min: min
  770. });
  771. scale.change({
  772. max: max
  773. });
  774. });
  775. };
  776. _proto._getFieldsForLegend = function _getFieldsForLegend() {
  777. var fields = [];
  778. var geoms = this.get('geoms');
  779. (0, _common.each)(geoms, function (geom) {
  780. var attrOptions = geom.get('attrOptions');
  781. var attrCfg = attrOptions.color;
  782. if (attrCfg && attrCfg.field && (0, _common.isString)(attrCfg.field)) {
  783. var arr = attrCfg.field.split('*');
  784. (0, _common.each)(arr, function (item) {
  785. if (fields.indexOf(item) === -1) {
  786. fields.push(item);
  787. }
  788. });
  789. }
  790. });
  791. return fields;
  792. };
  793. _proto._getScaleData = function _getScaleData(field) {
  794. var data = this.get('data');
  795. var filteredData = this.get('filteredData');
  796. if (filteredData.length) {
  797. var legendFields = this._getFieldsForLegend();
  798. if (legendFields.indexOf(field) === -1) {
  799. data = filteredData;
  800. }
  801. }
  802. return data;
  803. } // _updateScales() {
  804. // const scaleController = this.get('scaleController');
  805. // scaleController.updateScales();
  806. // this._adjustScale();
  807. // }
  808. ;
  809. _proto._adjustScale = function _adjustScale() {
  810. var self = this;
  811. var scaleController = self.get('scaleController'); // 看起来是为了让柱状图最小或最大都默认从0开始
  812. var geoms = this.get('geoms');
  813. for (var i = 0; i < geoms.length; i++) {
  814. var geom = geoms[i];
  815. if (geom.get('type') === 'interval') {
  816. var yScale = geom.getYScale();
  817. scaleController.adjustStartZero(yScale);
  818. }
  819. }
  820. };
  821. _proto._removeGeoms = function _removeGeoms() {
  822. var geoms = this.get('geoms');
  823. while (geoms.length > 0) {
  824. var geom = geoms.shift();
  825. geom.destroy();
  826. }
  827. };
  828. _proto._clearGeoms = function _clearGeoms() {
  829. var geoms = this.get('geoms');
  830. for (var i = 0, length = geoms.length; i < length; i++) {
  831. var geom = geoms[i];
  832. geom.clear();
  833. }
  834. };
  835. _proto._clearInner = function _clearInner() {
  836. this._clearGeoms();
  837. Chart.plugins.notify(this, 'clearInner');
  838. this.emit(_const.EVENT_CLEAR_INNER);
  839. this.get('axisController') && this.get('axisController').clear();
  840. };
  841. _proto._initFilteredData = function _initFilteredData() {
  842. var filters = this.get('filters');
  843. var data = this.get('data') || [];
  844. if (filters) {
  845. data = data.filter(function (obj) {
  846. var rst = true;
  847. (0, _common.each)(filters, function (fn, k) {
  848. if (fn) {
  849. rst = fn(obj[k], obj);
  850. if (!rst) {
  851. return false;
  852. }
  853. }
  854. });
  855. return rst;
  856. });
  857. }
  858. this.set('filteredData', data);
  859. };
  860. _proto._changeGeomsData = function _changeGeomsData() {
  861. var geoms = this.get('geoms');
  862. var data = this.get('filteredData');
  863. for (var i = 0, length = geoms.length; i < length; i++) {
  864. var geom = geoms[i];
  865. geom.changeData(data);
  866. }
  867. };
  868. _proto._initGeom = function _initGeom(geom) {
  869. if (geom.get('isInit')) {
  870. return;
  871. }
  872. var coord = this.get('coord');
  873. var data = this.get('filteredData');
  874. var colDefs = this.get('colDefs');
  875. var middlePlot = this.get('middlePlot');
  876. geom.set('chart', this);
  877. geom.set('container', middlePlot.addGroup());
  878. geom.set('data', data);
  879. geom.set('coord', coord);
  880. geom.set('colDefs', colDefs);
  881. geom.init();
  882. this.emit(_const.EVENT_AFTER_GEOM_INIT, geom);
  883. };
  884. _proto._initGeoms = function _initGeoms() {
  885. var geoms = this.get('geoms');
  886. for (var i = 0, length = geoms.length; i < length; i++) {
  887. this._initGeom(geoms[i]);
  888. }
  889. };
  890. _proto._initCoord = function _initCoord() {
  891. var plot = this.get('plotRange');
  892. var coordCfg = (0, _common.mix)({
  893. type: 'cartesian'
  894. }, this.get('coordCfg'), {
  895. plot: plot
  896. });
  897. var type = coordCfg.type;
  898. var C = _index["default"][(0, _common.upperFirst)(type)];
  899. var coord = new C(coordCfg);
  900. this.set('coord', coord);
  901. };
  902. _proto._initLayout = function _initLayout() {
  903. var padding = this.get('_padding');
  904. if (!padding) {
  905. padding = this.get('margin') || this.get('padding');
  906. padding = (0, _common.parsePadding)(padding);
  907. }
  908. var top = padding[0] === 'auto' ? 0 : padding[0];
  909. var right = padding[1] === 'auto' ? 0 : padding[1];
  910. var bottom = padding[2] === 'auto' ? 0 : padding[2];
  911. var left = padding[3] === 'auto' ? 0 : padding[3];
  912. var width = this.get('width');
  913. var height = this.get('height');
  914. var start = {
  915. x: left,
  916. y: top
  917. };
  918. var end = {
  919. x: width - right,
  920. y: height - bottom
  921. };
  922. var plot = this.get('plot');
  923. if (plot) {
  924. plot.reset(start, end);
  925. return;
  926. }
  927. var newPlot = new _plot["default"]({
  928. start: start,
  929. end: end
  930. });
  931. this.set('plotRange', newPlot);
  932. this.set('plot', newPlot);
  933. };
  934. _proto._initCanvas = function _initCanvas() {
  935. var self = this;
  936. try {
  937. var canvas = new _index2.Canvas({
  938. el: self.get('el') || self.get('id'),
  939. context: self.get('context'),
  940. pixelRatio: self.get('pixelRatio'),
  941. width: self.get('width'),
  942. height: self.get('height'),
  943. fontFamily: _global["default"].fontFamily
  944. });
  945. self.set('canvas', canvas);
  946. self.set('el', canvas.get('el'));
  947. self.set('width', canvas.get('width'));
  948. self.set('height', canvas.get('height'));
  949. } catch (error) {
  950. throw error;
  951. }
  952. Chart.plugins.notify(self, 'afterCanvasInit');
  953. };
  954. _proto._initLayers = function _initLayers() {
  955. var canvas = this.get('canvas');
  956. this.set('backPlot', canvas.addGroup());
  957. this.set('middlePlot', canvas.addGroup({
  958. zIndex: 10
  959. }));
  960. this.set('frontPlot', canvas.addGroup({
  961. zIndex: 20
  962. }));
  963. };
  964. _proto._initEvents = function _initEvents() {
  965. var _this2 = this;
  966. // 数据更新后的一些更新
  967. this.on(_const.EVENT_AFTER_DATA_CHANGE, function () {
  968. // 数据更新后,重新设置filterdata
  969. _this2._initFilteredData(); // 更新geoms里的数据
  970. _this2._changeGeomsData();
  971. }); // 大小变化后的一些更新
  972. this.on(_const.EVENT_AFTER_SIZE_CHANGE, function () {
  973. _this2._initLayout(); // layout变化后,坐标轴也需要做相应的变化
  974. var coord = _this2.get('coord');
  975. if (coord) {
  976. coord.reset(_this2.get('plot'));
  977. }
  978. });
  979. };
  980. _proto._initScaleController = function _initScaleController() {
  981. var scaleController = new _scale["default"]({
  982. chart: this
  983. }); // 让colDefs 和 scaleController.defs 用同一个对象,这样就不用考虑同步的问题
  984. this.set('colDefs', scaleController.defs); // 已经实例化的scales 也保持统一个对象
  985. this.set('scales', scaleController.scales);
  986. this.set('scaleController', scaleController);
  987. };
  988. _proto._clearScaleController = function _clearScaleController() {
  989. var scaleController = this.get('scaleController');
  990. scaleController.clear();
  991. };
  992. _proto._init = function _init() {
  993. var self = this;
  994. self._initCanvas();
  995. self._initLayout();
  996. self._initLayers();
  997. self._initEvents();
  998. self._initScaleController();
  999. self.set('axisController', new _axis["default"]({
  1000. frontPlot: self.get('frontPlot').addGroup({
  1001. className: 'axisContainer'
  1002. }),
  1003. backPlot: self.get('backPlot').addGroup({
  1004. className: 'axisContainer'
  1005. }),
  1006. chart: self
  1007. }));
  1008. Chart.plugins.notify(self, 'init');
  1009. };
  1010. function Chart(cfg) {
  1011. var _this;
  1012. _this = _Base.call(this, cfg) || this;
  1013. var self = _assertThisInitialized(_this);
  1014. (0, _common.each)(_base2["default"], function (geomConstructor, className) {
  1015. var methodName = (0, _common.lowerFirst)(className);
  1016. self[methodName] = function (cfg) {
  1017. var geom = new geomConstructor(cfg);
  1018. self.addGeom(geom);
  1019. return geom;
  1020. };
  1021. });
  1022. self._init();
  1023. return _this;
  1024. }
  1025. _proto.init = function init() {
  1026. // 初始filterData
  1027. this._initFilteredData(); // initialization coordinate instance
  1028. this._initCoord();
  1029. Chart.plugins.notify(this, 'beforeGeomInit'); // init all geometry instances
  1030. this._initGeoms(); // 多 Y 轴的情况时,统一 Y 轴的数值范围。
  1031. this._syncYScales(); // do some adjust for data
  1032. this._adjustScale();
  1033. this.emit(_const.EVENT_AFTER_INIT);
  1034. }
  1035. /**
  1036. * set data and some scale configuration
  1037. * @chainable
  1038. * @param {Array} data the dataset to visualize
  1039. * @param {Object} colDefs the configuration for scales
  1040. * @return {Chart} return the chart instance
  1041. */
  1042. ;
  1043. _proto.source = function source(data, colDefs) {
  1044. this.set('data', data);
  1045. if (colDefs) {
  1046. this.scale(colDefs);
  1047. }
  1048. return this;
  1049. };
  1050. _proto.scale = function scale(field, cfg) {
  1051. var scaleController = this.get('scaleController');
  1052. scaleController.setFieldDef(field, cfg);
  1053. return this;
  1054. }
  1055. /**
  1056. * configure the axis
  1057. * @chainable
  1058. * @param {String|Boolean} field the field name of data
  1059. * @param {Object} cfg configuration for axis
  1060. * @return {Chart} return the chart instance
  1061. */
  1062. ;
  1063. _proto.axis = function axis(field, cfg) {
  1064. var axisController = this.get('axisController');
  1065. if (!field) {
  1066. axisController.axisCfg = null;
  1067. } else {
  1068. axisController.axisCfg = axisController.axisCfg || {};
  1069. axisController.axisCfg[field] = cfg;
  1070. }
  1071. return this;
  1072. }
  1073. /**
  1074. * configure the coordinate
  1075. * @chainable
  1076. * @param {String} type set the type of coodinate
  1077. * @param {Object} cfg configuration for coordinate
  1078. * @return {Chart} return the chart instance
  1079. */
  1080. ;
  1081. _proto.coord = function coord(type, cfg) {
  1082. var coordCfg;
  1083. if ((0, _common.isObject)(type)) {
  1084. coordCfg = type;
  1085. } else {
  1086. coordCfg = cfg || {};
  1087. coordCfg.type = type || 'cartesian';
  1088. }
  1089. this.set('coordCfg', coordCfg);
  1090. return this;
  1091. };
  1092. _proto.filter = function filter(field, condition) {
  1093. var filters = this.get('filters') || {};
  1094. filters[field] = condition;
  1095. this.set('filters', filters); // 如果已经render过,则再重新触发一次change
  1096. if (this.get('rendered')) {
  1097. this.emit(_const.EVENT_AFTER_DATA_CHANGE, this.get('data'));
  1098. }
  1099. }
  1100. /**
  1101. * render the chart
  1102. * @chainable
  1103. * @return {Chart} return the chart instance
  1104. */
  1105. ;
  1106. _proto.render = function render() {
  1107. var rendered = this.get('rendered');
  1108. var canvas = this.get('canvas');
  1109. var geoms = this.get('geoms'); // 已经渲染过
  1110. if (rendered) {
  1111. this._initGeoms();
  1112. this._adjustScale();
  1113. } else {
  1114. this.init();
  1115. this.set('rendered', true);
  1116. }
  1117. this.emit(_const.EVENT_BEFORE_RENDER);
  1118. Chart.plugins.notify(this, 'beforeGeomDraw');
  1119. this._renderAxis();
  1120. var middlePlot = this.get('middlePlot');
  1121. if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
  1122. var coord = this.get('coord');
  1123. var clip = (0, _helper.getClip)(coord);
  1124. clip.set('canvas', middlePlot.get('canvas'));
  1125. middlePlot.attr('clip', clip);
  1126. }
  1127. this.emit(_const.EVENT_BEFORE_GEOM_DRAW);
  1128. for (var i = 0, length = geoms.length; i < length; i++) {
  1129. var geom = geoms[i];
  1130. geom.paint();
  1131. }
  1132. this.emit(_const.EVENT_AFTER_GEOM_DRAW);
  1133. Chart.plugins.notify(this, 'afterGeomDraw');
  1134. canvas.sort();
  1135. this.get('frontPlot').sort();
  1136. Chart.plugins.notify(this, 'beforeCanvasDraw');
  1137. canvas.draw();
  1138. this.emit(_const.EVENT_AFTER_RENDER);
  1139. return this;
  1140. }
  1141. /**
  1142. * clear the chart, include geometris and all the shapes
  1143. * @chainable
  1144. * @return {Chart} return the chart
  1145. */
  1146. ;
  1147. _proto.clear = function clear() {
  1148. Chart.plugins.notify(this, 'clear');
  1149. this.emit(_const.EVENT_CLEAR);
  1150. this._clearInner();
  1151. this._removeGeoms();
  1152. this._clearScaleController();
  1153. this.set('legendItems', null);
  1154. this.set('filters', null);
  1155. this.set('isUpdate', false);
  1156. this.set('_padding', null);
  1157. this.set('rendered', false);
  1158. var canvas = this.get('canvas');
  1159. canvas.draw();
  1160. return this;
  1161. };
  1162. _proto.repaint = function repaint() {
  1163. // 如果在没有render之前就repaint的,就直接return退出
  1164. var rendered = this.get('rendered');
  1165. if (!rendered) {
  1166. return;
  1167. }
  1168. this.set('isUpdate', true);
  1169. this.set('legendItems', null);
  1170. Chart.plugins.notify(this, 'repaint');
  1171. this._clearInner();
  1172. this.emit(_const.EVENT_REPAINT);
  1173. this.render();
  1174. };
  1175. _proto.changeData = function changeData(data) {
  1176. this.emit(_const.EVENT_BEFORE_DATA_CHANGE, data);
  1177. this.set('data', data);
  1178. Chart.plugins.notify(this, 'changeData');
  1179. this.emit(_const.EVENT_AFTER_DATA_CHANGE, data);
  1180. this.set('_padding', null);
  1181. this.repaint();
  1182. };
  1183. _proto.changeSize = function changeSize(width, height) {
  1184. if (width) {
  1185. this.set('width', width);
  1186. } else {
  1187. width = this.get('width');
  1188. }
  1189. if (height) {
  1190. this.set('height', height);
  1191. } else {
  1192. height = this.get('height');
  1193. }
  1194. var canvas = this.get('canvas');
  1195. canvas.changeSize(width, height);
  1196. this.emit(_const.EVENT_AFTER_SIZE_CHANGE, {
  1197. width: width,
  1198. height: height
  1199. });
  1200. this.repaint();
  1201. return this;
  1202. };
  1203. _proto.destroy = function destroy() {
  1204. this.clear();
  1205. var canvas = this.get('canvas');
  1206. canvas.destroy();
  1207. Chart.plugins.notify(this, 'afterCanvasDestroyed');
  1208. if (this._interactions) {
  1209. (0, _common.each)(this._interactions, function (interaction) {
  1210. interaction.destroy();
  1211. });
  1212. }
  1213. _Base.prototype.destroy.call(this);
  1214. }
  1215. /**
  1216. * calculate dataset's position on canvas
  1217. * @param {Object} record the dataset
  1218. * @return {Object} return the position
  1219. */
  1220. ;
  1221. _proto.getPosition = function getPosition(record) {
  1222. var self = this;
  1223. var coord = self.get('coord');
  1224. var xScale = self.getXScale();
  1225. var xField = xScale.field;
  1226. var yScales = self.getYScales(); // default first
  1227. var yScale = yScales[0];
  1228. var yField = yScale.field;
  1229. for (var i = 0, len = yScales.length; i < len; i++) {
  1230. var scale = yScales[i];
  1231. var field = scale.field;
  1232. if (record[field]) {
  1233. yScale = scale;
  1234. yField = field;
  1235. break;
  1236. }
  1237. }
  1238. var x = xScale.scale(record[xField]);
  1239. var y = yScale.scale(record[yField]);
  1240. return coord.convertPoint({
  1241. x: x,
  1242. y: y
  1243. });
  1244. }
  1245. /**
  1246. * get the data item of the point
  1247. * @param {Object} point canvas position
  1248. * @return {Object} return the data item
  1249. */
  1250. ;
  1251. _proto.getRecord = function getRecord(point) {
  1252. var self = this;
  1253. var coord = self.get('coord');
  1254. var xScale = self.getXScale();
  1255. var yScale = self.getYScales()[0];
  1256. var invertPoint = coord.invertPoint(point);
  1257. var record = {};
  1258. record[xScale.field] = xScale.invert(invertPoint.x);
  1259. record[yScale.field] = yScale.invert(invertPoint.y);
  1260. return record;
  1261. }
  1262. /**
  1263. * get the dataset of the point
  1264. * @param {Object} point canvas position
  1265. * @return {Array} return the dataset
  1266. **/
  1267. ;
  1268. _proto.getSnapRecords = function getSnapRecords(point) {
  1269. var geom = this.get('geoms')[0];
  1270. var data = [];
  1271. if (geom) {
  1272. // need to judge
  1273. data = geom.getSnapRecords(point);
  1274. }
  1275. return data;
  1276. }
  1277. /**
  1278. * creat scale instances
  1279. * @param {String} field field name of data
  1280. * @return {Scale} return the scale
  1281. */
  1282. ;
  1283. _proto.createScale = function createScale(field) {
  1284. var data = this._getScaleData(field);
  1285. var scaleController = this.get('scaleController');
  1286. return scaleController.createScale(field, data);
  1287. }
  1288. /**
  1289. * @protected
  1290. * add geometry instance to geoms
  1291. * @param {Geom} geom geometry instance
  1292. */
  1293. ;
  1294. _proto.addGeom = function addGeom(geom) {
  1295. var geoms = this.get('geoms');
  1296. geoms.push(geom);
  1297. }
  1298. /**
  1299. * get the scale of x axis
  1300. * @return {Scale} return the scale
  1301. */
  1302. ;
  1303. _proto.getXScale = function getXScale() {
  1304. var self = this;
  1305. var geoms = self.get('geoms');
  1306. var xScale = geoms[0].getXScale();
  1307. return xScale;
  1308. }
  1309. /**
  1310. * get the scale of y axis
  1311. * @return {Array} return the scale
  1312. */
  1313. ;
  1314. _proto.getYScales = function getYScales() {
  1315. var geoms = this.get('geoms');
  1316. var rst = [];
  1317. (0, _common.each)(geoms, function (geom) {
  1318. var yScale = geom.getYScale();
  1319. if (rst.indexOf(yScale) === -1) {
  1320. rst.push(yScale);
  1321. }
  1322. });
  1323. return rst;
  1324. };
  1325. _proto.getLegendItems = function getLegendItems() {
  1326. if (this.get('legendItems')) {
  1327. return this.get('legendItems');
  1328. }
  1329. var legendItems = {};
  1330. var scales = [];
  1331. var geoms = this.get('geoms');
  1332. (0, _common.each)(geoms, function (geom) {
  1333. var colorAttr = geom.getAttr('color');
  1334. if (colorAttr) {
  1335. var scale = colorAttr.getScale('color'); // 只支持分类图例
  1336. if (scale.isCategory && !_isScaleExist(scales, scale)) {
  1337. scales.push(scale);
  1338. var field = scale.field;
  1339. var ticks = scale.getTicks();
  1340. var items = [];
  1341. (0, _common.each)(ticks, function (tick) {
  1342. var text = tick.text;
  1343. var name = text;
  1344. var scaleValue = tick.value;
  1345. var value = scale.invert(scaleValue);
  1346. var color = colorAttr.mapping(value).join('') || _global["default"].defaultColor;
  1347. var marker = {
  1348. fill: color,
  1349. radius: 3,
  1350. symbol: 'circle',
  1351. stroke: '#fff'
  1352. };
  1353. items.push({
  1354. name: name,
  1355. // for display
  1356. dataValue: value,
  1357. // the origin value
  1358. checked: true,
  1359. marker: marker
  1360. });
  1361. });
  1362. legendItems[field] = items;
  1363. }
  1364. }
  1365. });
  1366. this.set('legendItems', legendItems);
  1367. return legendItems;
  1368. } // register the plugins
  1369. ;
  1370. _proto.registerPlugins = function registerPlugins(plugins) {
  1371. var self = this;
  1372. var chartPlugins = self.get('plugins') || [];
  1373. if (!(0, _common.isArray)(chartPlugins)) {
  1374. chartPlugins = [chartPlugins];
  1375. }
  1376. [].concat(plugins).forEach(function (plugin) {
  1377. if (chartPlugins.indexOf(plugin) === -1) {
  1378. plugin.init && plugin.init(self); // init
  1379. chartPlugins.push(plugin);
  1380. }
  1381. });
  1382. Chart.plugins._cacheId++;
  1383. self.set('plugins', chartPlugins);
  1384. };
  1385. _proto._renderAxis = function _renderAxis() {
  1386. var axisController = this.get('axisController');
  1387. var xScale = this.getXScale();
  1388. var yScales = this.getYScales();
  1389. var coord = this.get('coord');
  1390. Chart.plugins.notify(this, 'beforeRenderAxis');
  1391. axisController.createAxis(coord, xScale, yScales);
  1392. };
  1393. _proto._isAutoPadding = function _isAutoPadding() {
  1394. if (this.get('_padding')) {
  1395. return false;
  1396. }
  1397. var padding = this.get('padding');
  1398. if ((0, _common.isArray)(padding)) {
  1399. return padding.indexOf('auto') !== -1;
  1400. }
  1401. return padding === 'auto';
  1402. };
  1403. _proto._updateLayout = function _updateLayout(padding) {
  1404. var width = this.get('width');
  1405. var height = this.get('height');
  1406. var start = {
  1407. x: padding[3],
  1408. y: padding[0]
  1409. };
  1410. var end = {
  1411. x: width - padding[1],
  1412. y: height - padding[2]
  1413. };
  1414. var plot = this.get('plot');
  1415. var coord = this.get('coord');
  1416. plot.reset(start, end);
  1417. coord.reset(plot);
  1418. };
  1419. return Chart;
  1420. }(_base["default"]);
  1421. Chart.plugins = Chart.initPlugins();
  1422. var _default = Chart;
  1423. exports["default"] = _default;
  1424. }, function(modId) { var map = {"./const":1658993502539,"../base":1658993502540,"./plot":1658993502542,"../util/common":1658993502535,"../coord/index":1658993502543,"../geom/base":1658993502548,"./controller/scale":1658993502557,"./controller/axis":1658993502561,"../global":1658993502533,"../graphic/index":1658993502565,"../util/helper":1658993502588}; return __REQUIRE__(map[modId], modId); })
  1425. __DEFINE__(1658993502539, function(require, module, exports) {
  1426. exports.__esModule = true;
  1427. exports.EVENT_REPAINT = exports.EVENT_CLEAR_INNER = exports.EVENT_CLEAR = exports.EVENT_AFTER_GEOM_DRAW = exports.EVENT_BEFORE_GEOM_DRAW = exports.EVENT_AFTER_GEOM_INIT = exports.EVENT_AFTER_SIZE_CHANGE = exports.EVENT_AFTER_DATA_CHANGE = exports.EVENT_BEFORE_DATA_CHANGE = exports.EVENT_AFTER_RENDER = exports.EVENT_BEFORE_RENDER = exports.EVENT_AFTER_INIT = void 0;
  1428. var EVENT_AFTER_INIT = 'afterinit';
  1429. exports.EVENT_AFTER_INIT = EVENT_AFTER_INIT;
  1430. var EVENT_BEFORE_RENDER = 'beforerender';
  1431. exports.EVENT_BEFORE_RENDER = EVENT_BEFORE_RENDER;
  1432. var EVENT_AFTER_RENDER = 'afterrender';
  1433. exports.EVENT_AFTER_RENDER = EVENT_AFTER_RENDER;
  1434. var EVENT_BEFORE_DATA_CHANGE = 'beforedatachange';
  1435. exports.EVENT_BEFORE_DATA_CHANGE = EVENT_BEFORE_DATA_CHANGE;
  1436. var EVENT_AFTER_DATA_CHANGE = 'afterdatachange';
  1437. exports.EVENT_AFTER_DATA_CHANGE = EVENT_AFTER_DATA_CHANGE;
  1438. var EVENT_AFTER_SIZE_CHANGE = '_aftersizechange';
  1439. exports.EVENT_AFTER_SIZE_CHANGE = EVENT_AFTER_SIZE_CHANGE;
  1440. var EVENT_AFTER_GEOM_INIT = '_aftergeominit';
  1441. exports.EVENT_AFTER_GEOM_INIT = EVENT_AFTER_GEOM_INIT;
  1442. var EVENT_BEFORE_GEOM_DRAW = 'beforegeomdraw';
  1443. exports.EVENT_BEFORE_GEOM_DRAW = EVENT_BEFORE_GEOM_DRAW;
  1444. var EVENT_AFTER_GEOM_DRAW = 'aftergeomdraw';
  1445. exports.EVENT_AFTER_GEOM_DRAW = EVENT_AFTER_GEOM_DRAW;
  1446. var EVENT_CLEAR = 'clear';
  1447. exports.EVENT_CLEAR = EVENT_CLEAR;
  1448. var EVENT_CLEAR_INNER = 'clearinner';
  1449. exports.EVENT_CLEAR_INNER = EVENT_CLEAR_INNER;
  1450. var EVENT_REPAINT = 'repaint';
  1451. exports.EVENT_REPAINT = EVENT_REPAINT;
  1452. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  1453. __DEFINE__(1658993502540, function(require, module, exports) {
  1454. exports.__esModule = true;
  1455. exports["default"] = void 0;
  1456. var _emit = _interopRequireDefault(require("./graphic/event/emit"));
  1457. var _common = require("./util/common");
  1458. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  1459. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  1460. var Base = /*#__PURE__*/function (_Emit) {
  1461. _inheritsLoose(Base, _Emit);
  1462. var _proto = Base.prototype;
  1463. _proto.getDefaultCfg = function getDefaultCfg() {
  1464. return {};
  1465. };
  1466. function Base(cfg) {
  1467. var _this;
  1468. _this = _Emit.call(this) || this;
  1469. var attrs = {};
  1470. var defaultCfg = _this.getDefaultCfg();
  1471. _this._attrs = attrs;
  1472. (0, _common.mix)(attrs, defaultCfg, cfg);
  1473. return _this;
  1474. }
  1475. _proto.get = function get(name) {
  1476. return this._attrs[name];
  1477. };
  1478. _proto.set = function set(name, value) {
  1479. this._attrs[name] = value;
  1480. };
  1481. _proto.destroy = function destroy() {
  1482. this._attrs = {};
  1483. this.destroyed = true;
  1484. };
  1485. return Base;
  1486. }(_emit["default"]);
  1487. var _default = Base;
  1488. exports["default"] = _default;
  1489. }, function(modId) { var map = {"./graphic/event/emit":1658993502541,"./util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  1490. __DEFINE__(1658993502541, function(require, module, exports) {
  1491. exports.__esModule = true;
  1492. exports["default"] = void 0;
  1493. var _common = require("../../util/common");
  1494. // 实现简单的事件机制
  1495. var EventEmit = /*#__PURE__*/function () {
  1496. function EventEmit() {
  1497. this.__events = {};
  1498. }
  1499. var _proto = EventEmit.prototype;
  1500. _proto.on = function on(type, listener) {
  1501. if (!type || !listener) {
  1502. return;
  1503. }
  1504. var events = this.__events[type] || [];
  1505. events.push(listener);
  1506. this.__events[type] = events;
  1507. };
  1508. _proto.emit = function emit(type, e) {
  1509. var _this = this;
  1510. if ((0, _common.isObject)(type)) {
  1511. e = type;
  1512. type = e && e.type;
  1513. }
  1514. if (!type) {
  1515. return;
  1516. }
  1517. var events = this.__events[type];
  1518. if (!events || !events.length) {
  1519. return;
  1520. }
  1521. events.forEach(function (listener) {
  1522. listener.call(_this, e);
  1523. });
  1524. };
  1525. _proto.off = function off(type, listener) {
  1526. var __events = this.__events;
  1527. var events = __events[type];
  1528. if (!events || !events.length) {
  1529. return;
  1530. } // 如果没有指定方法,则删除所有项
  1531. if (!listener) {
  1532. delete __events[type];
  1533. return;
  1534. } // 删除指定的 listener
  1535. for (var i = 0, len = events.length; i < len; i++) {
  1536. if (events[i] === listener) {
  1537. events.splice(i, 1);
  1538. i--;
  1539. }
  1540. }
  1541. };
  1542. return EventEmit;
  1543. }();
  1544. var _default = EventEmit;
  1545. exports["default"] = _default;
  1546. }, function(modId) { var map = {"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  1547. __DEFINE__(1658993502542, function(require, module, exports) {
  1548. exports.__esModule = true;
  1549. exports["default"] = void 0;
  1550. var _common = require("../util/common");
  1551. var Plot = /*#__PURE__*/function () {
  1552. function Plot(cfg) {
  1553. (0, _common.mix)(this, cfg);
  1554. this._init();
  1555. }
  1556. var _proto = Plot.prototype;
  1557. _proto._init = function _init() {
  1558. var self = this;
  1559. var start = self.start;
  1560. var end = self.end;
  1561. var xMin = Math.min(start.x, end.x);
  1562. var xMax = Math.max(start.x, end.x);
  1563. var yMin = Math.min(start.y, end.y);
  1564. var yMax = Math.max(start.y, end.y);
  1565. this.tl = {
  1566. x: xMin,
  1567. y: yMin
  1568. };
  1569. this.tr = {
  1570. x: xMax,
  1571. y: yMin
  1572. };
  1573. this.bl = {
  1574. x: xMin,
  1575. y: yMax
  1576. };
  1577. this.br = {
  1578. x: xMax,
  1579. y: yMax
  1580. };
  1581. this.width = xMax - xMin;
  1582. this.height = yMax - yMin;
  1583. }
  1584. /**
  1585. * reset
  1586. * @param {Object} start start point
  1587. * @param {Object} end end point
  1588. */
  1589. ;
  1590. _proto.reset = function reset(start, end) {
  1591. this.start = start;
  1592. this.end = end;
  1593. this._init();
  1594. }
  1595. /**
  1596. * check the point is in the range of plot
  1597. * @param {Number} x x value
  1598. * @param {[type]} y y value
  1599. * @return {Boolean} return the result
  1600. */
  1601. ;
  1602. _proto.isInRange = function isInRange(x, y) {
  1603. if ((0, _common.isObject)(x)) {
  1604. y = x.y;
  1605. x = x.x;
  1606. }
  1607. var tl = this.tl;
  1608. var br = this.br;
  1609. return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
  1610. };
  1611. return Plot;
  1612. }();
  1613. var _default = Plot;
  1614. exports["default"] = _default;
  1615. }, function(modId) { var map = {"../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  1616. __DEFINE__(1658993502543, function(require, module, exports) {
  1617. exports.__esModule = true;
  1618. exports["default"] = void 0;
  1619. var _base = _interopRequireDefault(require("./base"));
  1620. require("./cartesian");
  1621. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  1622. var _default = _base["default"];
  1623. exports["default"] = _default;
  1624. }, function(modId) { var map = {"./base":1658993502544,"./cartesian":1658993502547}; return __REQUIRE__(map[modId], modId); })
  1625. __DEFINE__(1658993502544, function(require, module, exports) {
  1626. exports.__esModule = true;
  1627. exports["default"] = void 0;
  1628. var _common = require("../util/common");
  1629. var _matrix = _interopRequireDefault(require("../graphic/util/matrix"));
  1630. var _vector = _interopRequireDefault(require("../graphic/util/vector2"));
  1631. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  1632. var defaultMatrix = [1, 0, 0, 1, 0, 0];
  1633. var Base = /*#__PURE__*/function () {
  1634. var _proto = Base.prototype;
  1635. _proto._initDefaultCfg = function _initDefaultCfg() {};
  1636. function Base(cfg) {
  1637. this._initDefaultCfg();
  1638. (0, _common.mix)(this, cfg);
  1639. var start;
  1640. var end;
  1641. if (this.plot) {
  1642. start = this.plot.bl;
  1643. end = this.plot.tr;
  1644. this.start = start;
  1645. this.end = end;
  1646. } else {
  1647. start = this.start;
  1648. end = this.end;
  1649. }
  1650. this.init(start, end);
  1651. }
  1652. _proto._scale = function _scale(s1, s2) {
  1653. var matrix = this.matrix;
  1654. var center = this.center;
  1655. _matrix["default"].translate(matrix, matrix, [center.x, center.y]);
  1656. _matrix["default"].scale(matrix, matrix, [s1, s2]);
  1657. _matrix["default"].translate(matrix, matrix, [-center.x, -center.y]);
  1658. };
  1659. _proto.init = function init(start, end) {
  1660. this.matrix = [].concat(defaultMatrix); // 设置中心点
  1661. this.center = {
  1662. x: (end.x - start.x) / 2 + start.x,
  1663. y: (end.y - start.y) / 2 + start.y
  1664. };
  1665. if (this.scale) {
  1666. this._scale(this.scale[0], this.scale[1]);
  1667. }
  1668. };
  1669. _proto.convertPoint = function convertPoint(point) {
  1670. var _this$_convertPoint = this._convertPoint(point),
  1671. x = _this$_convertPoint.x,
  1672. y = _this$_convertPoint.y;
  1673. if (!_matrix["default"].isChanged(this.matrix)) {
  1674. return {
  1675. x: x,
  1676. y: y
  1677. };
  1678. }
  1679. var vector = [x, y];
  1680. _vector["default"].transformMat2d(vector, vector, this.matrix);
  1681. return {
  1682. x: vector[0],
  1683. y: vector[1]
  1684. };
  1685. };
  1686. _proto.invertPoint = function invertPoint(point) {
  1687. return this._invertPoint(point);
  1688. };
  1689. _proto._convertPoint = function _convertPoint(point) {
  1690. return point;
  1691. };
  1692. _proto._invertPoint = function _invertPoint(point) {
  1693. return point;
  1694. };
  1695. _proto.reset = function reset(plot) {
  1696. this.plot = plot;
  1697. var bl = plot.bl,
  1698. tr = plot.tr;
  1699. this.start = bl;
  1700. this.end = tr;
  1701. this.init(bl, tr);
  1702. };
  1703. return Base;
  1704. }();
  1705. var _default = Base;
  1706. exports["default"] = _default;
  1707. }, function(modId) { var map = {"../util/common":1658993502535,"../graphic/util/matrix":1658993502545,"../graphic/util/vector2":1658993502546}; return __REQUIRE__(map[modId], modId); })
  1708. __DEFINE__(1658993502545, function(require, module, exports) {
  1709. exports.__esModule = true;
  1710. exports["default"] = void 0;
  1711. var Matrix = {
  1712. generateDefault: function generateDefault() {
  1713. return [1, 0, 0, 1, 0, 0];
  1714. },
  1715. isChanged: function isChanged(m) {
  1716. return m[0] !== 1 || m[1] !== 0 || m[2] !== 0 || m[3] !== 1 || m[4] !== 0 || m[5] !== 0;
  1717. },
  1718. multiply: function multiply(m1, m2) {
  1719. var m11 = m1[0] * m2[0] + m1[2] * m2[1];
  1720. var m12 = m1[1] * m2[0] + m1[3] * m2[1];
  1721. var m21 = m1[0] * m2[2] + m1[2] * m2[3];
  1722. var m22 = m1[1] * m2[2] + m1[3] * m2[3];
  1723. var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  1724. var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  1725. return [m11, m12, m21, m22, dx, dy];
  1726. },
  1727. scale: function scale(out, m, v) {
  1728. out[0] = m[0] * v[0];
  1729. out[1] = m[1] * v[0];
  1730. out[2] = m[2] * v[1];
  1731. out[3] = m[3] * v[1];
  1732. out[4] = m[4];
  1733. out[5] = m[5];
  1734. return out;
  1735. },
  1736. rotate: function rotate(out, m, radian) {
  1737. var c = Math.cos(radian);
  1738. var s = Math.sin(radian);
  1739. var m11 = m[0] * c + m[2] * s;
  1740. var m12 = m[1] * c + m[3] * s;
  1741. var m21 = m[0] * -s + m[2] * c;
  1742. var m22 = m[1] * -s + m[3] * c;
  1743. out[0] = m11;
  1744. out[1] = m12;
  1745. out[2] = m21;
  1746. out[3] = m22;
  1747. out[4] = m[4];
  1748. out[5] = m[5];
  1749. return out;
  1750. },
  1751. translate: function translate(out, m, v) {
  1752. out[0] = m[0];
  1753. out[1] = m[1];
  1754. out[2] = m[2];
  1755. out[3] = m[3];
  1756. out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
  1757. out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
  1758. return out;
  1759. },
  1760. transform: function transform(m, actions) {
  1761. var out = [].concat(m);
  1762. for (var i = 0, len = actions.length; i < len; i++) {
  1763. var action = actions[i];
  1764. switch (action[0]) {
  1765. case 't':
  1766. Matrix.translate(out, out, [action[1], action[2]]);
  1767. break;
  1768. case 's':
  1769. Matrix.scale(out, out, [action[1], action[2]]);
  1770. break;
  1771. case 'r':
  1772. Matrix.rotate(out, out, action[1]);
  1773. break;
  1774. default:
  1775. break;
  1776. }
  1777. }
  1778. return out;
  1779. }
  1780. };
  1781. var _default = Matrix;
  1782. exports["default"] = _default;
  1783. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  1784. __DEFINE__(1658993502546, function(require, module, exports) {
  1785. exports.__esModule = true;
  1786. exports["default"] = void 0;
  1787. /**
  1788. * 2 Dimensional Vector
  1789. * @module vector2
  1790. */
  1791. var _default = {
  1792. /**
  1793. * Creates a new, empty vector2
  1794. *
  1795. * @return {vector2} a new 2D vector
  1796. */
  1797. create: function create() {
  1798. return [0, 0];
  1799. },
  1800. /**
  1801. * Calculates the length of a vector2
  1802. *
  1803. * @param {vector2} v vector to calculate length of
  1804. * @return {Number} length of v
  1805. */
  1806. length: function length(v) {
  1807. var x = v[0];
  1808. var y = v[1];
  1809. return Math.sqrt(x * x + y * y);
  1810. },
  1811. /**
  1812. * Normalize a vector2
  1813. *
  1814. * @param {vector2} out the receiving vector
  1815. * @param {vector2} v vector to normalize
  1816. * @return {vector2} out
  1817. */
  1818. normalize: function normalize(out, v) {
  1819. var len = this.length(v);
  1820. if (len === 0) {
  1821. out[0] = 0;
  1822. out[1] = 0;
  1823. } else {
  1824. out[0] = v[0] / len;
  1825. out[1] = v[1] / len;
  1826. }
  1827. return out;
  1828. },
  1829. /**
  1830. * Adds two vector2's
  1831. *
  1832. * @param {vector2} out the receiving vector
  1833. * @param {vector2} v1 the first operand
  1834. * @param {vector2} v2 the second operand
  1835. * @return {vector2} out
  1836. */
  1837. add: function add(out, v1, v2) {
  1838. out[0] = v1[0] + v2[0];
  1839. out[1] = v1[1] + v2[1];
  1840. return out;
  1841. },
  1842. /**
  1843. * Subtracts vector v2 from vector v1
  1844. *
  1845. * @param {vector2} out the receiving vector
  1846. * @param {vector2} v1 the first operand
  1847. * @param {vector2} v2 the second operand
  1848. * @return {vector2} out
  1849. */
  1850. sub: function sub(out, v1, v2) {
  1851. out[0] = v1[0] - v2[0];
  1852. out[1] = v1[1] - v2[1];
  1853. return out;
  1854. },
  1855. /**
  1856. * Scales a vector2 by a scalar number
  1857. *
  1858. * @param {vector2} out the receiving vector
  1859. * @param {vector2} v the vector to scale
  1860. * @param {Number} s amount to scale the vector by
  1861. * @return {vector2} out
  1862. */
  1863. scale: function scale(out, v, s) {
  1864. out[0] = v[0] * s;
  1865. out[1] = v[1] * s;
  1866. return out;
  1867. },
  1868. /**
  1869. * Calculates the dot product of two vector2's
  1870. *
  1871. * @param {vector2} v1 the first operand
  1872. * @param {vector2} v2 the second operand
  1873. * @return {Number} dot product of v1 and v2
  1874. */
  1875. dot: function dot(v1, v2) {
  1876. return v1[0] * v2[0] + v1[1] * v2[1];
  1877. },
  1878. /**
  1879. * Calculates the direction of two vector2's
  1880. *
  1881. * @param {vector2} v1 the first operand
  1882. * @param {vector2} v2 the second operand
  1883. * @return {Boolean} the direction of v1 and v2
  1884. */
  1885. direction: function direction(v1, v2) {
  1886. return v1[0] * v2[1] - v2[0] * v1[1];
  1887. },
  1888. /**
  1889. * Calculates the angle of two vector2's
  1890. *
  1891. * @param {vector2} v1 the first operand
  1892. * @param {vector2} v2 the second operand
  1893. * @return {Number} angle of v1 and v2
  1894. */
  1895. angle: function angle(v1, v2) {
  1896. var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
  1897. return Math.acos(theta);
  1898. },
  1899. /**
  1900. * Calculates the angle of two vector2's with direction
  1901. *
  1902. * @param {vector2} v1 the first operand
  1903. * @param {vector2} v2 the second operand
  1904. * @param {Boolean} direction the direction of two vector2's
  1905. * @return {Number} angle of v1 and v2
  1906. */
  1907. angleTo: function angleTo(v1, v2, direction) {
  1908. var angle = this.angle(v1, v2);
  1909. var angleLargeThanPI = this.direction(v1, v2) >= 0;
  1910. if (direction) {
  1911. if (angleLargeThanPI) {
  1912. return Math.PI * 2 - angle;
  1913. }
  1914. return angle;
  1915. }
  1916. if (angleLargeThanPI) {
  1917. return angle;
  1918. }
  1919. return Math.PI * 2 - angle;
  1920. },
  1921. /**
  1922. * whether a vector2 is zero vector
  1923. *
  1924. * @param {vector2} v vector to calculate
  1925. * @return {Boolean} is or not a zero vector
  1926. */
  1927. zero: function zero(v) {
  1928. return v[0] === 0 && v[1] === 0;
  1929. },
  1930. /**
  1931. * Calculates the euclidian distance between two vector2's
  1932. *
  1933. * @param {vector2} v1 the first operand
  1934. * @param {vector2} v2 the second operand
  1935. * @return {Number} distance between a and b
  1936. */
  1937. distance: function distance(v1, v2) {
  1938. var x = v2[0] - v1[0];
  1939. var y = v2[1] - v1[1];
  1940. return Math.sqrt(x * x + y * y);
  1941. },
  1942. /**
  1943. * Creates a new vector2 initialized with values from an existing vector
  1944. *
  1945. * @param {vector2} v vector to clone
  1946. * @return {Array} a new 2D vector
  1947. */
  1948. clone: function clone(v) {
  1949. return [v[0], v[1]];
  1950. },
  1951. /**
  1952. * Return the minimum of two vector2's
  1953. *
  1954. * @param {vector2} out the receiving vector
  1955. * @param {vector2} v1 the first operand
  1956. * @param {vector2} v2 the second operand
  1957. * @return {vector2} out
  1958. */
  1959. min: function min(out, v1, v2) {
  1960. out[0] = Math.min(v1[0], v2[0]);
  1961. out[1] = Math.min(v1[1], v2[1]);
  1962. return out;
  1963. },
  1964. /**
  1965. * Return the maximum of two vector2's
  1966. *
  1967. * @param {vector2} out the receiving vector
  1968. * @param {vector2} v1 the first operand
  1969. * @param {vector2} v2 the second operand
  1970. * @return {vector2} out
  1971. */
  1972. max: function max(out, v1, v2) {
  1973. out[0] = Math.max(v1[0], v2[0]);
  1974. out[1] = Math.max(v1[1], v2[1]);
  1975. return out;
  1976. },
  1977. /**
  1978. * Transforms the vector2 with a mat2d
  1979. *
  1980. * @param {vector2} out the receiving vector
  1981. * @param {vector2} v the vector to transform
  1982. * @param {mat2d} m matrix to transform with
  1983. * @return {vector2} out
  1984. */
  1985. transformMat2d: function transformMat2d(out, v, m) {
  1986. var x = v[0];
  1987. var y = v[1];
  1988. out[0] = m[0] * x + m[2] * y + m[4];
  1989. out[1] = m[1] * x + m[3] * y + m[5];
  1990. return out;
  1991. }
  1992. };
  1993. exports["default"] = _default;
  1994. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  1995. __DEFINE__(1658993502547, function(require, module, exports) {
  1996. exports.__esModule = true;
  1997. exports["default"] = void 0;
  1998. var _base = _interopRequireDefault(require("./base"));
  1999. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2000. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2001. var Cartesian = /*#__PURE__*/function (_Base) {
  2002. _inheritsLoose(Cartesian, _Base);
  2003. function Cartesian() {
  2004. return _Base.apply(this, arguments) || this;
  2005. }
  2006. var _proto = Cartesian.prototype;
  2007. _proto._initDefaultCfg = function _initDefaultCfg() {
  2008. this.type = 'cartesian';
  2009. this.transposed = false;
  2010. this.isRect = true;
  2011. };
  2012. _proto.init = function init(start, end) {
  2013. _Base.prototype.init.call(this, start, end);
  2014. this.x = {
  2015. start: start.x,
  2016. end: end.x
  2017. };
  2018. this.y = {
  2019. start: start.y,
  2020. end: end.y
  2021. };
  2022. };
  2023. _proto._convertPoint = function _convertPoint(point) {
  2024. var self = this;
  2025. var transposed = self.transposed;
  2026. var xDim = transposed ? 'y' : 'x';
  2027. var yDim = transposed ? 'x' : 'y';
  2028. var x = self.x;
  2029. var y = self.y;
  2030. return {
  2031. x: x.start + (x.end - x.start) * point[xDim],
  2032. y: y.start + (y.end - y.start) * point[yDim]
  2033. };
  2034. };
  2035. _proto._invertPoint = function _invertPoint(point) {
  2036. var self = this;
  2037. var transposed = self.transposed;
  2038. var xDim = transposed ? 'y' : 'x';
  2039. var yDim = transposed ? 'x' : 'y';
  2040. var x = self.x;
  2041. var y = self.y;
  2042. var rst = {};
  2043. rst[xDim] = (point.x - x.start) / (x.end - x.start);
  2044. rst[yDim] = (point.y - y.start) / (y.end - y.start);
  2045. return rst;
  2046. };
  2047. return Cartesian;
  2048. }(_base["default"]);
  2049. _base["default"].Cartesian = Cartesian;
  2050. _base["default"].Rect = Cartesian;
  2051. var _default = Cartesian;
  2052. exports["default"] = _default;
  2053. }, function(modId) { var map = {"./base":1658993502544}; return __REQUIRE__(map[modId], modId); })
  2054. __DEFINE__(1658993502548, function(require, module, exports) {
  2055. exports.__esModule = true;
  2056. exports["default"] = void 0;
  2057. var Attr = _interopRequireWildcard(require("../attr/index"));
  2058. var _common = require("../util/common");
  2059. var _base = _interopRequireDefault(require("../base"));
  2060. var _global = _interopRequireDefault(require("../global"));
  2061. var _shape = _interopRequireDefault(require("./shape/shape"));
  2062. var _base2 = _interopRequireDefault(require("@antv/adjust/lib/base"));
  2063. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2064. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  2065. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  2066. function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  2067. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2068. var GROUP_ATTRS = ['color', 'size', 'shape'];
  2069. var FIELD_ORIGIN = '_origin';
  2070. var FIELD_ORIGIN_Y = '_originY';
  2071. function parseFields(field) {
  2072. if ((0, _common.isArray)(field)) {
  2073. return field;
  2074. }
  2075. if ((0, _common.isString)(field)) {
  2076. return field.split('*');
  2077. }
  2078. return [field];
  2079. }
  2080. /**
  2081. * The parent class for Geometry
  2082. * @class Geom
  2083. */
  2084. var Geom = /*#__PURE__*/function (_Base) {
  2085. _inheritsLoose(Geom, _Base);
  2086. function Geom() {
  2087. return _Base.apply(this, arguments) || this;
  2088. }
  2089. var _proto = Geom.prototype;
  2090. _proto.getDefaultCfg = function getDefaultCfg() {
  2091. return {
  2092. /**
  2093. * geometry type
  2094. * @type {String}
  2095. */
  2096. type: null,
  2097. /**
  2098. * the data of geometry
  2099. * @type {Array}
  2100. */
  2101. data: null,
  2102. /**
  2103. * the attrs of geo,etry
  2104. * @type {Object}
  2105. */
  2106. attrs: {},
  2107. scales: {},
  2108. /**
  2109. * group for storing the shapes
  2110. * @type {Canvas}
  2111. */
  2112. container: null,
  2113. /**
  2114. * style options
  2115. * @type {Object}
  2116. */
  2117. styleOptions: null,
  2118. chart: null,
  2119. shapeType: '',
  2120. /**
  2121. * wether to generate key points for each shape
  2122. * @protected
  2123. * @type {Boolean}
  2124. */
  2125. generatePoints: false,
  2126. attrOptions: {},
  2127. sortable: false,
  2128. startOnZero: true,
  2129. visible: true,
  2130. connectNulls: false,
  2131. // 是否丢弃没有值的分组。
  2132. ignoreEmptyGroup: false,
  2133. // 是否已经初始化
  2134. isInit: false
  2135. };
  2136. };
  2137. _proto.init = function init() {
  2138. var self = this;
  2139. var isInit = self.get('isInit');
  2140. if (isInit) {
  2141. return;
  2142. }
  2143. self._initAttrs();
  2144. self._processData();
  2145. self.set('isInit', true);
  2146. };
  2147. _proto._getGroupScales = function _getGroupScales() {
  2148. var self = this;
  2149. var scales = [];
  2150. (0, _common.each)(GROUP_ATTRS, function (attrName) {
  2151. var attr = self.getAttr(attrName);
  2152. if (attr) {
  2153. var attrScales = attr.scales;
  2154. (0, _common.each)(attrScales, function (scale) {
  2155. if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
  2156. scales.push(scale);
  2157. }
  2158. });
  2159. }
  2160. });
  2161. return scales;
  2162. };
  2163. _proto._groupData = function _groupData(data) {
  2164. var self = this;
  2165. var colDefs = self.get('colDefs');
  2166. var groupScales = self._getGroupScales();
  2167. if (groupScales.length) {
  2168. var appendConditions = {};
  2169. var names = [];
  2170. (0, _common.each)(groupScales, function (scale) {
  2171. var field = scale.field;
  2172. names.push(field);
  2173. if (colDefs && colDefs[field] && colDefs[field].values) {
  2174. // users have defined
  2175. appendConditions[scale.field] = colDefs[field].values;
  2176. }
  2177. });
  2178. return _common.Array.group(data, names, appendConditions);
  2179. }
  2180. return [data];
  2181. };
  2182. _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
  2183. var options = this.get('attrOptions');
  2184. options[attrName] = attrCfg;
  2185. var attrs = this.get('attrs'); // 说明已经初始化过了
  2186. if (Object.keys(attrs).length) {
  2187. this._createAttr(attrName, attrCfg);
  2188. }
  2189. };
  2190. _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
  2191. var attrCfg = {};
  2192. attrCfg.field = field;
  2193. if (cfg) {
  2194. if ((0, _common.isFunction)(cfg)) {
  2195. attrCfg.callback = cfg;
  2196. } else {
  2197. attrCfg.values = cfg;
  2198. }
  2199. } else {
  2200. attrCfg.values = defaultValues;
  2201. }
  2202. this._setAttrOptions(attrName, attrCfg);
  2203. };
  2204. _proto._createAttr = function _createAttr(type, option) {
  2205. var self = this;
  2206. var attrs = self.get('attrs');
  2207. var coord = self.get('coord');
  2208. var className = (0, _common.upperFirst)(type);
  2209. var fields = parseFields(option.field);
  2210. if (type === 'position') {
  2211. option.coord = coord;
  2212. }
  2213. var scales = [];
  2214. for (var i = 0, len = fields.length; i < len; i++) {
  2215. var field = fields[i];
  2216. var scale = self._createScale(field);
  2217. scales.push(scale);
  2218. }
  2219. if (type === 'position') {
  2220. var yScale = scales[1]; // 饼图的处理,但是还不知道为啥
  2221. if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
  2222. if (yScale.values.length) {
  2223. yScale.change({
  2224. nice: false,
  2225. min: 0,
  2226. max: Math.max.apply(null, yScale.values)
  2227. });
  2228. }
  2229. }
  2230. }
  2231. option.scales = scales;
  2232. var attr = new Attr[className](option);
  2233. attrs[type] = attr;
  2234. return attr;
  2235. };
  2236. _proto._initAttrs = function _initAttrs() {
  2237. var self = this;
  2238. var attrOptions = self.get('attrOptions');
  2239. for (var type in attrOptions) {
  2240. if (attrOptions.hasOwnProperty(type)) {
  2241. this._createAttr(type, attrOptions[type]);
  2242. }
  2243. }
  2244. };
  2245. _proto._createScale = function _createScale(field) {
  2246. var scales = this.get('scales');
  2247. var scale = scales[field];
  2248. if (!scale) {
  2249. scale = this.get('chart').createScale(field);
  2250. scales[field] = scale;
  2251. }
  2252. return scale;
  2253. };
  2254. _proto._processData = function _processData() {
  2255. var self = this;
  2256. var data = this.get('data');
  2257. var dataArray = [];
  2258. var groupedArray = this._groupData(data);
  2259. if (this.get('ignoreEmptyGroup')) {
  2260. var yScale = this.getYScale();
  2261. groupedArray = groupedArray.filter(function (group) {
  2262. return group.some(function (item) {
  2263. return typeof item[yScale.field] !== 'undefined';
  2264. });
  2265. });
  2266. }
  2267. for (var i = 0, len = groupedArray.length; i < len; i++) {
  2268. var subData = groupedArray[i];
  2269. var tempData = self._saveOrigin(subData);
  2270. if (this.hasAdjust('dodge')) {
  2271. self._numberic(tempData);
  2272. }
  2273. dataArray.push(tempData);
  2274. }
  2275. if (self.get('adjust')) {
  2276. self._adjustData(dataArray);
  2277. }
  2278. if (self.get('sortable')) {
  2279. self._sort(dataArray);
  2280. }
  2281. self.emit('afterprocessdata', {
  2282. dataArray: dataArray
  2283. });
  2284. self.set('mappingData', dataArray);
  2285. self.set('dataArray', dataArray);
  2286. return dataArray;
  2287. };
  2288. _proto._saveOrigin = function _saveOrigin(data) {
  2289. var rst = [];
  2290. for (var i = 0, len = data.length; i < len; i++) {
  2291. var origin = data[i];
  2292. var obj = {};
  2293. for (var k in origin) {
  2294. obj[k] = origin[k];
  2295. }
  2296. obj[FIELD_ORIGIN] = origin;
  2297. rst.push(obj);
  2298. }
  2299. return rst;
  2300. };
  2301. _proto._numberic = function _numberic(data) {
  2302. var positionAttr = this.getAttr('position');
  2303. var scales = positionAttr.scales;
  2304. for (var j = 0, len = data.length; j < len; j++) {
  2305. var obj = data[j];
  2306. var count = Math.min(2, scales.length);
  2307. for (var i = 0; i < count; i++) {
  2308. var scale = scales[i];
  2309. if (scale.isCategory) {
  2310. var field = scale.field;
  2311. obj[field] = scale.translate(obj[field]);
  2312. }
  2313. }
  2314. }
  2315. };
  2316. _proto._adjustData = function _adjustData(dataArray) {
  2317. var self = this;
  2318. var adjust = self.get('adjust');
  2319. if (adjust) {
  2320. var adjustType = (0, _common.upperFirst)(adjust.type);
  2321. if (!_base2["default"][adjustType]) {
  2322. throw new Error('not support such adjust : ' + adjust);
  2323. }
  2324. var xScale = self.getXScale();
  2325. var yScale = self.getYScale();
  2326. var cfg = (0, _common.mix)({
  2327. xField: xScale.field,
  2328. yField: yScale.field
  2329. }, adjust);
  2330. var adjustObject = new _base2["default"][adjustType](cfg);
  2331. adjustObject.processAdjust(dataArray);
  2332. if (adjustType === 'Stack') {
  2333. self._updateStackRange(yScale.field, yScale, dataArray);
  2334. }
  2335. }
  2336. };
  2337. _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
  2338. var mergeArray = _common.Array.merge(dataArray);
  2339. var min = scale.min;
  2340. var max = scale.max;
  2341. for (var i = 0, len = mergeArray.length; i < len; i++) {
  2342. var obj = mergeArray[i];
  2343. var tmpMin = Math.min.apply(null, obj[field]);
  2344. var tmpMax = Math.max.apply(null, obj[field]);
  2345. if (tmpMin < min) {
  2346. min = tmpMin;
  2347. }
  2348. if (tmpMax > max) {
  2349. max = tmpMax;
  2350. }
  2351. }
  2352. if (min < scale.min || max > scale.max) {
  2353. scale.change({
  2354. min: min,
  2355. max: max
  2356. });
  2357. }
  2358. };
  2359. _proto._sort = function _sort(mappedArray) {
  2360. var self = this;
  2361. var xScale = self.getXScale();
  2362. var field = xScale.field,
  2363. type = xScale.type;
  2364. if (type !== 'identity' && xScale.values.length > 1) {
  2365. (0, _common.each)(mappedArray, function (itemArr) {
  2366. itemArr.sort(function (obj1, obj2) {
  2367. if (type === 'timeCat') {
  2368. return (0, _common.toTimeStamp)(obj1[FIELD_ORIGIN][field]) - (0, _common.toTimeStamp)(obj2[FIELD_ORIGIN][field]);
  2369. }
  2370. return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
  2371. });
  2372. });
  2373. }
  2374. self.set('hasSorted', true);
  2375. self.set('dataArray', mappedArray);
  2376. };
  2377. _proto.paint = function paint() {
  2378. var self = this;
  2379. var dataArray = self.get('mappingData');
  2380. var mappedArray = [];
  2381. var shapeFactory = self.getShapeFactory();
  2382. shapeFactory.setCoord(self.get('coord'));
  2383. self._beforeMapping(dataArray);
  2384. for (var i = 0, len = dataArray.length; i < len; i++) {
  2385. var data = dataArray[i];
  2386. if (data.length) {
  2387. var mappedData = self._mapping(data);
  2388. mappedArray.push(mappedData);
  2389. self.draw(mappedData, shapeFactory);
  2390. }
  2391. }
  2392. self.set('dataArray', mappedArray);
  2393. };
  2394. _proto.getShapeFactory = function getShapeFactory() {
  2395. var shapeFactory = this.get('shapeFactory');
  2396. if (!shapeFactory) {
  2397. var shapeType = this.get('shapeType');
  2398. shapeFactory = _shape["default"].getShapeFactory(shapeType);
  2399. this.set('shapeFactory', shapeFactory);
  2400. }
  2401. return shapeFactory;
  2402. };
  2403. _proto._mapping = function _mapping(data) {
  2404. var self = this;
  2405. var attrs = self.get('attrs');
  2406. var yField = self.getYScale().field; // 用来缓存转换的值,减少mapping耗时
  2407. var mappedCache = {};
  2408. var mappedData = new Array(data.length);
  2409. for (var k in attrs) {
  2410. if (attrs.hasOwnProperty(k)) {
  2411. var attr = attrs[k];
  2412. var names = attr.names;
  2413. var scales = attr.scales;
  2414. for (var i = 0, len = data.length; i < len; i++) {
  2415. var record = data[i];
  2416. var mappedRecord = _extends({}, record, mappedData[i]);
  2417. mappedRecord[FIELD_ORIGIN_Y] = record[yField]; // 获取视觉属性对应的value值
  2418. // 位置的缓存命中率低,还是每次单独计算
  2419. if (attr.type === 'position') {
  2420. var values = self._getAttrValues(attr, record);
  2421. for (var j = 0, _len = values.length; j < _len; j++) {
  2422. var val = values[j];
  2423. var name = names[j];
  2424. mappedRecord[name] = (0, _common.isArray)(val) && val.length === 1 ? val[0] : val;
  2425. }
  2426. } else {
  2427. // 除了position其他都只有一项
  2428. var _name = names[0];
  2429. var field = scales[0].field;
  2430. var value = record[field];
  2431. var key = "" + _name + value;
  2432. var _values = mappedCache[key];
  2433. if (!_values) {
  2434. _values = self._getAttrValues(attr, record);
  2435. mappedCache[key] = _values;
  2436. }
  2437. mappedRecord[_name] = _values[0];
  2438. } // 设置新数组
  2439. mappedData[i] = mappedRecord;
  2440. }
  2441. }
  2442. }
  2443. return mappedData;
  2444. };
  2445. _proto._getAttrValues = function _getAttrValues(attr, record) {
  2446. var scales = attr.scales;
  2447. var params = [];
  2448. for (var i = 0, len = scales.length; i < len; i++) {
  2449. var scale = scales[i];
  2450. var field = scale.field;
  2451. if (scale.type === 'identity') {
  2452. params.push(scale.value);
  2453. } else {
  2454. params.push(record[field]);
  2455. }
  2456. }
  2457. var values = attr.mapping.apply(attr, params);
  2458. return values;
  2459. };
  2460. _proto.getAttrValue = function getAttrValue(attrName, record) {
  2461. var attr = this.getAttr(attrName);
  2462. var rst = null;
  2463. if (attr) {
  2464. var values = this._getAttrValues(attr, record);
  2465. rst = values[0];
  2466. }
  2467. return rst;
  2468. };
  2469. _proto._beforeMapping = function _beforeMapping(dataArray) {
  2470. var self = this;
  2471. if (self.get('generatePoints')) {
  2472. self._generatePoints(dataArray);
  2473. }
  2474. };
  2475. _proto.isInCircle = function isInCircle() {
  2476. var coord = this.get('coord');
  2477. return coord && coord.isPolar;
  2478. };
  2479. _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
  2480. if (!fields) {
  2481. return cfg;
  2482. }
  2483. var tmpCfg = {};
  2484. var params = fields.map(function (field) {
  2485. return origin[field];
  2486. });
  2487. (0, _common.each)(cfg, function (v, k) {
  2488. if ((0, _common.isFunction)(v)) {
  2489. tmpCfg[k] = v.apply(null, params);
  2490. } else {
  2491. tmpCfg[k] = v;
  2492. }
  2493. });
  2494. return tmpCfg;
  2495. };
  2496. _proto.getDrawCfg = function getDrawCfg(obj) {
  2497. var self = this;
  2498. var isInCircle = self.isInCircle();
  2499. var cfg = {
  2500. origin: obj,
  2501. x: obj.x,
  2502. y: obj.y,
  2503. color: obj.color,
  2504. size: obj.size,
  2505. shape: obj.shape,
  2506. isInCircle: isInCircle,
  2507. opacity: obj.opacity
  2508. };
  2509. var styleOptions = self.get('styleOptions');
  2510. if (styleOptions && styleOptions.style) {
  2511. cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
  2512. }
  2513. if (self.get('generatePoints')) {
  2514. cfg.points = obj.points;
  2515. cfg.nextPoints = obj.nextPoints;
  2516. }
  2517. if (isInCircle) {
  2518. cfg.center = self.get('coord').center;
  2519. }
  2520. return cfg;
  2521. };
  2522. _proto.draw = function draw(data, shapeFactory) {
  2523. var self = this;
  2524. var container = self.get('container');
  2525. var yScale = self.getYScale();
  2526. (0, _common.each)(data, function (obj, index) {
  2527. if (yScale && (0, _common.isNil)(obj._origin[yScale.field])) {
  2528. return;
  2529. }
  2530. obj.index = index;
  2531. var cfg = self.getDrawCfg(obj);
  2532. var shape = obj.shape;
  2533. self.drawShape(shape, obj, cfg, container, shapeFactory);
  2534. });
  2535. };
  2536. _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
  2537. var gShape = shapeFactory.drawShape(shape, cfg, container);
  2538. if (gShape) {
  2539. (0, _common.each)([].concat(gShape), function (s) {
  2540. s.set('origin', shapeData);
  2541. });
  2542. }
  2543. };
  2544. _proto._generatePoints = function _generatePoints(dataArray) {
  2545. var self = this;
  2546. var shapeFactory = self.getShapeFactory();
  2547. var shapeAttr = self.getAttr('shape');
  2548. (0, _common.each)(dataArray, function (data) {
  2549. for (var i = 0, len = data.length; i < len; i++) {
  2550. var obj = data[i];
  2551. var cfg = self.createShapePointsCfg(obj);
  2552. var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
  2553. var points = shapeFactory.getShapePoints(shape, cfg);
  2554. obj.points = points;
  2555. }
  2556. }); // 添加nextPoints
  2557. (0, _common.each)(dataArray, function (data, index) {
  2558. var nextData = dataArray[index + 1];
  2559. if (nextData) {
  2560. data[0].nextPoints = nextData[0].points;
  2561. }
  2562. });
  2563. }
  2564. /**
  2565. * get the info of each shape
  2566. * @protected
  2567. * @param {Object} obj the data item
  2568. * @return {Object} cfg return the result
  2569. */
  2570. ;
  2571. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  2572. var xScale = this.getXScale();
  2573. var yScale = this.getYScale();
  2574. var x = this._normalizeValues(obj[xScale.field], xScale);
  2575. var y;
  2576. if (yScale) {
  2577. y = this._normalizeValues(obj[yScale.field], yScale);
  2578. } else {
  2579. y = obj.y ? obj.y : 0.1;
  2580. }
  2581. return {
  2582. x: x,
  2583. y: y,
  2584. y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
  2585. };
  2586. };
  2587. _proto.getYMinValue = function getYMinValue() {
  2588. var yScale = this.getYScale();
  2589. var min = yScale.min,
  2590. max = yScale.max;
  2591. var value;
  2592. if (this.get('startOnZero')) {
  2593. if (max <= 0 && min <= 0) {
  2594. value = max;
  2595. } else {
  2596. value = min >= 0 ? min : 0;
  2597. }
  2598. } else {
  2599. value = min;
  2600. }
  2601. return value;
  2602. };
  2603. _proto._normalizeValues = function _normalizeValues(values, scale) {
  2604. var rst = [];
  2605. if ((0, _common.isArray)(values)) {
  2606. for (var i = 0, len = values.length; i < len; i++) {
  2607. var v = values[i];
  2608. rst.push(scale.scale(v));
  2609. }
  2610. } else {
  2611. rst = scale.scale(values);
  2612. }
  2613. return rst;
  2614. };
  2615. _proto.getAttr = function getAttr(name) {
  2616. return this.get('attrs')[name];
  2617. };
  2618. _proto.getXScale = function getXScale() {
  2619. return this.getAttr('position').scales[0];
  2620. };
  2621. _proto.getYScale = function getYScale() {
  2622. return this.getAttr('position').scales[1];
  2623. };
  2624. _proto.hasAdjust = function hasAdjust(adjust) {
  2625. return this.get('adjust') && this.get('adjust').type === adjust;
  2626. };
  2627. _proto._getSnap = function _getSnap(scale, item, arr) {
  2628. var i = 0;
  2629. var values;
  2630. var yField = this.getYScale().field; // 叠加的维度
  2631. if (this.hasAdjust('stack') && scale.field === yField) {
  2632. values = [];
  2633. arr.forEach(function (obj) {
  2634. values.push(obj[FIELD_ORIGIN_Y]);
  2635. });
  2636. for (var len = values.length; i < len; i++) {
  2637. if (values[0][0] > item) {
  2638. break;
  2639. }
  2640. if (values[values.length - 1][1] <= item) {
  2641. i = values.length - 1;
  2642. break;
  2643. }
  2644. if (values[i][0] <= item && values[i][1] > item) {
  2645. break;
  2646. }
  2647. }
  2648. } else {
  2649. values = scale.values;
  2650. values.sort(function (a, b) {
  2651. return a - b;
  2652. });
  2653. for (var _len2 = values.length; i < _len2; i++) {
  2654. // 如果只有1个点直接返回第1个点
  2655. if (_len2 <= 1) {
  2656. break;
  2657. } // 第1个点和第2个点之间
  2658. if ((values[0] + values[1]) / 2 > item) {
  2659. break;
  2660. } // 中间的点
  2661. if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
  2662. break;
  2663. } // 最后2个点
  2664. if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
  2665. i = values.length - 1;
  2666. break;
  2667. }
  2668. }
  2669. }
  2670. var result = values[i];
  2671. return result;
  2672. };
  2673. _proto.getSnapRecords = function getSnapRecords(point) {
  2674. var self = this;
  2675. var coord = self.get('coord');
  2676. var xScale = self.getXScale();
  2677. var yScale = self.getYScale();
  2678. var xfield = xScale.field;
  2679. var dataArray = self.get('dataArray');
  2680. if (!this.get('hasSorted')) {
  2681. this._sort(dataArray);
  2682. }
  2683. var rst = [];
  2684. var invertPoint = coord.invertPoint(point);
  2685. var invertPointX = invertPoint.x;
  2686. if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
  2687. invertPointX = xScale.rangeMin();
  2688. }
  2689. var xValue = xScale.invert(invertPointX);
  2690. if (!xScale.isCategory) {
  2691. xValue = self._getSnap(xScale, xValue);
  2692. }
  2693. var tmp = [];
  2694. dataArray.forEach(function (data) {
  2695. data.forEach(function (obj) {
  2696. var originValue = (0, _common.isNil)(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
  2697. if (self._isEqual(originValue, xValue, xScale)) {
  2698. tmp.push(obj);
  2699. }
  2700. });
  2701. }); // special for pie chart
  2702. if (this.hasAdjust('stack') && coord.isPolar && coord.transposed) {
  2703. if (invertPointX >= 0 && invertPointX <= 1) {
  2704. var yValue = yScale.invert(invertPoint.y);
  2705. yValue = self._getSnap(yScale, yValue, tmp);
  2706. tmp.forEach(function (obj) {
  2707. if ((0, _common.isArray)(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
  2708. rst.push(obj);
  2709. }
  2710. });
  2711. }
  2712. } else {
  2713. rst = tmp;
  2714. }
  2715. return rst;
  2716. };
  2717. _proto.getRecords = function getRecords(value) {
  2718. var _this = this;
  2719. var xScale = this.getXScale();
  2720. var dataArray = this.get('dataArray');
  2721. var xfield = xScale.field;
  2722. return dataArray.map(function (data) {
  2723. for (var len = data.length, i = len - 1; i >= 0; i--) {
  2724. var obj = data[i];
  2725. var originValue = (0, _common.isNil)(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
  2726. if (_this._isEqual(originValue, value, xScale)) {
  2727. return obj;
  2728. }
  2729. }
  2730. return null;
  2731. });
  2732. };
  2733. _proto._isEqual = function _isEqual(originValue, value, scale) {
  2734. if (scale.type === 'timeCat') {
  2735. return (0, _common.toTimeStamp)(originValue) === value;
  2736. }
  2737. return value === originValue;
  2738. };
  2739. _proto.position = function position(field) {
  2740. this._setAttrOptions('position', {
  2741. field: field
  2742. });
  2743. return this;
  2744. };
  2745. _proto.color = function color(field, values) {
  2746. this._createAttrOption('color', field, values, _global["default"].colors);
  2747. return this;
  2748. };
  2749. _proto.size = function size(field, values) {
  2750. this._createAttrOption('size', field, values, _global["default"].sizes);
  2751. return this;
  2752. };
  2753. _proto.shape = function shape(field, values) {
  2754. var type = this.get('type');
  2755. var shapes = _global["default"].shapes[type] || [];
  2756. this._createAttrOption('shape', field, values, shapes);
  2757. return this;
  2758. };
  2759. _proto.style = function style(field, cfg) {
  2760. var styleOptions = this.get('styleOptions');
  2761. if (!styleOptions) {
  2762. styleOptions = {};
  2763. this.set('styleOptions', styleOptions);
  2764. }
  2765. if ((0, _common.isObject)(field)) {
  2766. cfg = field;
  2767. field = null;
  2768. }
  2769. var fields;
  2770. if (field) {
  2771. fields = parseFields(field);
  2772. }
  2773. styleOptions.fields = fields;
  2774. styleOptions.style = cfg;
  2775. return this;
  2776. };
  2777. _proto.adjust = function adjust(type) {
  2778. if ((0, _common.isString)(type)) {
  2779. type = {
  2780. type: type
  2781. };
  2782. }
  2783. this.set('adjust', type);
  2784. return this;
  2785. };
  2786. _proto.animate = function animate(cfg) {
  2787. this.set('animateCfg', cfg);
  2788. return this;
  2789. };
  2790. _proto.changeData = function changeData(data) {
  2791. this.set('data', data); // 改变数据后,情况度量,因为需要重新实例化
  2792. this.set('scales', {});
  2793. if (!this.get('isInit')) return;
  2794. this.set('isInit', false);
  2795. this.init();
  2796. };
  2797. _proto.clearInner = function clearInner() {
  2798. var container = this.get('container');
  2799. if (container) {
  2800. container.clear(); // container.setMatrix([ 1, 0, 0, 1, 0, 0 ]);
  2801. }
  2802. };
  2803. _proto.reset = function reset() {
  2804. this.set('isInit', false);
  2805. this.set('attrs', {});
  2806. this.set('attrOptions', {});
  2807. this.set('adjust', null);
  2808. this.clearInner();
  2809. };
  2810. _proto.clear = function clear() {
  2811. this.clearInner();
  2812. };
  2813. _proto.destroy = function destroy() {
  2814. this.set('isInit', false);
  2815. this.clear();
  2816. _Base.prototype.destroy.call(this);
  2817. };
  2818. _proto._display = function _display(visible) {
  2819. this.set('visible', visible);
  2820. var container = this.get('container');
  2821. var canvas = container.get('canvas');
  2822. container.set('visible', visible);
  2823. canvas.draw();
  2824. };
  2825. _proto.show = function show() {
  2826. this._display(true);
  2827. };
  2828. _proto.hide = function hide() {
  2829. this._display(false);
  2830. };
  2831. return Geom;
  2832. }(_base["default"]);
  2833. var _default = Geom;
  2834. exports["default"] = _default;
  2835. }, function(modId) { var map = {"../attr/index":1658993502549,"../util/common":1658993502535,"../base":1658993502540,"../global":1658993502533,"./shape/shape":1658993502556}; return __REQUIRE__(map[modId], modId); })
  2836. __DEFINE__(1658993502549, function(require, module, exports) {
  2837. exports.__esModule = true;
  2838. exports.Color = exports.Size = exports.Shape = exports.Position = void 0;
  2839. var _position = _interopRequireDefault(require("./position"));
  2840. exports.Position = _position["default"];
  2841. var _shape = _interopRequireDefault(require("./shape"));
  2842. exports.Shape = _shape["default"];
  2843. var _size = _interopRequireDefault(require("./size"));
  2844. exports.Size = _size["default"];
  2845. var _color = _interopRequireDefault(require("./color"));
  2846. exports.Color = _color["default"];
  2847. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2848. }, function(modId) { var map = {"./position":1658993502550,"./shape":1658993502552,"./size":1658993502553,"./color":1658993502554}; return __REQUIRE__(map[modId], modId); })
  2849. __DEFINE__(1658993502550, function(require, module, exports) {
  2850. exports.__esModule = true;
  2851. exports["default"] = void 0;
  2852. var _util = require("@antv/util");
  2853. var _base = _interopRequireDefault(require("./base"));
  2854. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  2855. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2856. var Position = /*#__PURE__*/function (_Base) {
  2857. _inheritsLoose(Position, _Base);
  2858. function Position(cfg) {
  2859. var _this;
  2860. _this = _Base.call(this, cfg) || this;
  2861. _this.names = ['x', 'y'];
  2862. _this.type = 'position';
  2863. return _this;
  2864. }
  2865. var _proto = Position.prototype;
  2866. _proto.mapping = function mapping(x, y) {
  2867. var scales = this.scales;
  2868. var coord = this.coord;
  2869. var scaleX = scales[0];
  2870. var scaleY = scales[1];
  2871. var rstX;
  2872. var rstY;
  2873. var obj;
  2874. if ((0, _util.isNil)(x) || (0, _util.isNil)(y)) {
  2875. return [];
  2876. }
  2877. if ((0, _util.isArray)(y) && (0, _util.isArray)(x)) {
  2878. rstX = [];
  2879. rstY = [];
  2880. for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
  2881. obj = coord.convertPoint({
  2882. x: scaleX.scale(x[i]),
  2883. y: scaleY.scale(y[j])
  2884. });
  2885. rstX.push(obj.x);
  2886. rstY.push(obj.y);
  2887. }
  2888. } else if ((0, _util.isArray)(y)) {
  2889. x = scaleX.scale(x);
  2890. rstY = [];
  2891. (0, _util.each)(y, function (yVal) {
  2892. yVal = scaleY.scale(yVal);
  2893. obj = coord.convertPoint({
  2894. x: x,
  2895. y: yVal
  2896. });
  2897. if (rstX && rstX !== obj.x) {
  2898. if (!(0, _util.isArray)(rstX)) {
  2899. rstX = [rstX];
  2900. }
  2901. rstX.push(obj.x);
  2902. } else {
  2903. rstX = obj.x;
  2904. }
  2905. rstY.push(obj.y);
  2906. });
  2907. } else if ((0, _util.isArray)(x)) {
  2908. y = scaleY.scale(y);
  2909. rstX = [];
  2910. (0, _util.each)(x, function (xVal) {
  2911. xVal = scaleX.scale(xVal);
  2912. obj = coord.convertPoint({
  2913. x: xVal,
  2914. y: y
  2915. });
  2916. if (rstY && rstY !== obj.y) {
  2917. if (!(0, _util.isArray)(rstY)) {
  2918. rstY = [rstY];
  2919. }
  2920. rstY.push(obj.y);
  2921. } else {
  2922. rstY = obj.y;
  2923. }
  2924. rstX.push(obj.x);
  2925. });
  2926. } else {
  2927. x = scaleX.scale(x);
  2928. y = scaleY.scale(y);
  2929. var point = coord.convertPoint({
  2930. x: x,
  2931. y: y
  2932. });
  2933. rstX = point.x;
  2934. rstY = point.y;
  2935. }
  2936. return [rstX, rstY];
  2937. };
  2938. return Position;
  2939. }(_base["default"]);
  2940. var _default = Position;
  2941. exports["default"] = _default;
  2942. }, function(modId) { var map = {"./base":1658993502551}; return __REQUIRE__(map[modId], modId); })
  2943. __DEFINE__(1658993502551, function(require, module, exports) {
  2944. exports.__esModule = true;
  2945. exports["default"] = void 0;
  2946. var _util = require("@antv/util");
  2947. /**
  2948. * @fileOverview the Attribute base class
  2949. */
  2950. function toScaleString(scale, value) {
  2951. if ((0, _util.isString)(value)) {
  2952. return value;
  2953. }
  2954. return scale.invert(scale.scale(value));
  2955. }
  2956. /**
  2957. * 所有视觉通道属性的基类
  2958. * @class Attr
  2959. */
  2960. var AttributeBase = /*#__PURE__*/function () {
  2961. function AttributeBase(cfg) {
  2962. var _this = this;
  2963. /**
  2964. * 属性的类型
  2965. * @type {String}
  2966. */
  2967. this.type = 'base';
  2968. /**
  2969. * 属性的名称
  2970. * @type {String}
  2971. */
  2972. this.name = null;
  2973. /**
  2974. * 回调函数
  2975. * @type {Function}
  2976. */
  2977. this.method = null;
  2978. /**
  2979. * 备选的值数组
  2980. * @type {Array}
  2981. */
  2982. this.values = [];
  2983. /**
  2984. * 属性内部的度量
  2985. * @type {Array}
  2986. */
  2987. this.scales = [];
  2988. /**
  2989. * 是否通过线性取值, 如果未指定,则根据数值的类型判定
  2990. * @type {Boolean}
  2991. */
  2992. this.linear = null;
  2993. /**
  2994. * 当用户设置的 callback 返回 null 时, 应该返回默认 callback 中的值
  2995. */
  2996. var mixedCallback = null;
  2997. var defaultCallback = this.callback;
  2998. if (cfg.callback) {
  2999. var userCallback = cfg.callback;
  3000. mixedCallback = function mixedCallback() {
  3001. for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
  3002. params[_key] = arguments[_key];
  3003. }
  3004. var ret = userCallback.apply(void 0, params);
  3005. if ((0, _util.isNil)(ret)) {
  3006. ret = defaultCallback.apply(_this, params);
  3007. }
  3008. return ret;
  3009. };
  3010. }
  3011. (0, _util.mix)(this, cfg);
  3012. if (mixedCallback) {
  3013. (0, _util.mix)(this, {
  3014. callback: mixedCallback
  3015. });
  3016. }
  3017. } // 获取属性值,将值映射到视觉通道
  3018. var _proto = AttributeBase.prototype;
  3019. _proto._getAttrValue = function _getAttrValue(scale, value) {
  3020. var values = this.values;
  3021. if (scale.isCategory && !this.linear) {
  3022. var index = scale.translate(value);
  3023. return values[index % values.length];
  3024. }
  3025. var percent = scale.scale(value);
  3026. return this.getLinearValue(percent);
  3027. }
  3028. /**
  3029. * 如果进行线性映射,返回对应的映射值
  3030. * @protected
  3031. * @param {Number} percent 百分比
  3032. * @return {*} 颜色值、形状、大小等
  3033. */
  3034. ;
  3035. _proto.getLinearValue = function getLinearValue(percent) {
  3036. var values = this.values;
  3037. var steps = values.length - 1;
  3038. var step = Math.floor(steps * percent);
  3039. var leftPercent = steps * percent - step;
  3040. var start = values[step];
  3041. var end = step === steps ? start : values[step + 1];
  3042. var rstValue = start + (end - start) * leftPercent;
  3043. return rstValue;
  3044. }
  3045. /**
  3046. * 默认的回调函数
  3047. * @param {*} value 回调函数的值
  3048. * @type {Function}
  3049. * @return {Array} 返回映射后的值
  3050. */
  3051. ;
  3052. _proto.callback = function callback(value) {
  3053. var self = this;
  3054. var scale = self.scales[0];
  3055. var rstValue = null;
  3056. if (scale.type === 'identity') {
  3057. rstValue = scale.value;
  3058. } else {
  3059. rstValue = self._getAttrValue(scale, value);
  3060. }
  3061. return rstValue;
  3062. }
  3063. /**
  3064. * 根据度量获取属性名
  3065. * @return {Array} dims of this Attribute
  3066. */
  3067. ;
  3068. _proto.getNames = function getNames() {
  3069. var scales = this.scales;
  3070. var names = this.names;
  3071. var length = Math.min(scales.length, names.length);
  3072. var rst = [];
  3073. for (var i = 0; i < length; i++) {
  3074. rst.push(names[i]);
  3075. }
  3076. return rst;
  3077. }
  3078. /**
  3079. * 根据度量获取维度名
  3080. * @return {Array} dims of this Attribute
  3081. */
  3082. ;
  3083. _proto.getFields = function getFields() {
  3084. var scales = this.scales;
  3085. var rst = [];
  3086. (0, _util.each)(scales, function (scale) {
  3087. rst.push(scale.field);
  3088. });
  3089. return rst;
  3090. }
  3091. /**
  3092. * 根据名称获取度量
  3093. * @param {String} name the name of scale
  3094. * @return {Scale} scale
  3095. */
  3096. ;
  3097. _proto.getScale = function getScale(name) {
  3098. var scales = this.scales;
  3099. var names = this.names;
  3100. var index = names.indexOf(name);
  3101. return scales[index];
  3102. }
  3103. /**
  3104. * 映射数据
  3105. * @param {*} param1...paramn 多个数值
  3106. * @return {Array} 映射的值组成的数组
  3107. */
  3108. ;
  3109. _proto.mapping = function mapping() {
  3110. var scales = this.scales;
  3111. var callback = this.callback;
  3112. for (var _len2 = arguments.length, params = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
  3113. params[_key2] = arguments[_key2];
  3114. }
  3115. var values = params;
  3116. if (callback) {
  3117. for (var i = 0, len = params.length; i < len; i++) {
  3118. params[i] = this._toOriginParam(params[i], scales[i]);
  3119. }
  3120. values = callback.apply(this, params);
  3121. }
  3122. values = [].concat(values);
  3123. return values;
  3124. } // 原始的参数
  3125. ;
  3126. _proto._toOriginParam = function _toOriginParam(param, scale) {
  3127. var rst = param;
  3128. if (!scale.isLinear) {
  3129. if ((0, _util.isArray)(param)) {
  3130. rst = [];
  3131. for (var i = 0, len = param.length; i < len; i++) {
  3132. rst.push(toScaleString(scale, param[i]));
  3133. }
  3134. } else {
  3135. rst = toScaleString(scale, param);
  3136. }
  3137. }
  3138. return rst;
  3139. };
  3140. return AttributeBase;
  3141. }();
  3142. var _default = AttributeBase;
  3143. exports["default"] = _default;
  3144. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  3145. __DEFINE__(1658993502552, function(require, module, exports) {
  3146. exports.__esModule = true;
  3147. exports["default"] = void 0;
  3148. var _base = _interopRequireDefault(require("./base"));
  3149. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3150. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  3151. var Shape = /*#__PURE__*/function (_Base) {
  3152. _inheritsLoose(Shape, _Base);
  3153. function Shape(cfg) {
  3154. var _this;
  3155. _this = _Base.call(this, cfg) || this;
  3156. _this.names = ['shape'];
  3157. _this.type = 'shape';
  3158. _this.gradient = null;
  3159. return _this;
  3160. }
  3161. /**
  3162. * @override
  3163. */
  3164. var _proto = Shape.prototype;
  3165. _proto.getLinearValue = function getLinearValue(percent) {
  3166. var values = this.values;
  3167. var index = Math.round((values.length - 1) * percent);
  3168. return values[index];
  3169. };
  3170. return Shape;
  3171. }(_base["default"]);
  3172. var _default = Shape;
  3173. exports["default"] = _default;
  3174. }, function(modId) { var map = {"./base":1658993502551}; return __REQUIRE__(map[modId], modId); })
  3175. __DEFINE__(1658993502553, function(require, module, exports) {
  3176. exports.__esModule = true;
  3177. exports["default"] = void 0;
  3178. var _base = _interopRequireDefault(require("./base"));
  3179. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3180. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  3181. var Size = /*#__PURE__*/function (_Base) {
  3182. _inheritsLoose(Size, _Base);
  3183. function Size(cfg) {
  3184. var _this;
  3185. _this = _Base.call(this, cfg) || this;
  3186. _this.names = ['size'];
  3187. _this.type = 'size';
  3188. _this.gradient = null;
  3189. return _this;
  3190. }
  3191. return Size;
  3192. }(_base["default"]);
  3193. var _default = Size;
  3194. exports["default"] = _default;
  3195. }, function(modId) { var map = {"./base":1658993502551}; return __REQUIRE__(map[modId], modId); })
  3196. __DEFINE__(1658993502554, function(require, module, exports) {
  3197. exports.__esModule = true;
  3198. exports["default"] = void 0;
  3199. var _util = require("@antv/util");
  3200. var _base = _interopRequireDefault(require("./base"));
  3201. var _colorUtil = require("./color-util");
  3202. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3203. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  3204. var Color = /*#__PURE__*/function (_Base) {
  3205. _inheritsLoose(Color, _Base);
  3206. function Color(cfg) {
  3207. var _this;
  3208. _this = _Base.call(this, cfg) || this;
  3209. _this.names = ['color'];
  3210. _this.type = 'color';
  3211. _this.gradient = null;
  3212. if ((0, _util.isString)(_this.values)) {
  3213. _this.linear = true;
  3214. }
  3215. return _this;
  3216. }
  3217. /**
  3218. * @override
  3219. */
  3220. var _proto = Color.prototype;
  3221. _proto.getLinearValue = function getLinearValue(percent) {
  3222. var gradient = this.gradient;
  3223. if (!gradient) {
  3224. var values = this.values;
  3225. gradient = (0, _colorUtil.gradient)(values);
  3226. this.gradient = gradient;
  3227. }
  3228. return gradient(percent);
  3229. };
  3230. return Color;
  3231. }(_base["default"]);
  3232. var _default = Color;
  3233. exports["default"] = _default;
  3234. }, function(modId) { var map = {"./base":1658993502551,"./color-util":1658993502555}; return __REQUIRE__(map[modId], modId); })
  3235. __DEFINE__(1658993502555, function(require, module, exports) {
  3236. exports.__esModule = true;
  3237. exports.toHex = toHex;
  3238. exports.gradient = gradient;
  3239. var _util = require("@antv/util");
  3240. // Get the interpolation between colors
  3241. function getValue(start, end, percent, index) {
  3242. var value = start[index] + (end[index] - start[index]) * percent;
  3243. return value;
  3244. } // convert to hex
  3245. function arr2hex(arr) {
  3246. return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
  3247. }
  3248. function toRGBValue(value) {
  3249. value = Math.round(value);
  3250. value = value.toString(16);
  3251. if (value.length === 1) {
  3252. value = '0' + value;
  3253. }
  3254. return value;
  3255. }
  3256. function calColor(colors, percent) {
  3257. var steps = colors.length - 1;
  3258. var step = Math.floor(steps * percent);
  3259. var left = steps * percent - step;
  3260. var start = colors[step];
  3261. var end = step === steps ? start : colors[step + 1];
  3262. var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
  3263. return rgb;
  3264. }
  3265. function hex2arr(str) {
  3266. var arr = [];
  3267. arr.push(parseInt(str.substr(1, 2), 16));
  3268. arr.push(parseInt(str.substr(3, 2), 16));
  3269. arr.push(parseInt(str.substr(5, 2), 16));
  3270. return arr;
  3271. }
  3272. var colorCache = {
  3273. black: '#000000',
  3274. blue: '#0000ff',
  3275. grey: '#808080',
  3276. green: '#008000',
  3277. orange: '#ffa500',
  3278. pink: '#ffc0cb',
  3279. purple: '#800080',
  3280. red: '#ff0000',
  3281. white: '#ffffff',
  3282. yellow: '#ffff00'
  3283. };
  3284. /**
  3285. * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
  3286. * @param {String} color color value
  3287. * @return {String} Returns a hexadecimal string
  3288. */
  3289. function toHex(color) {
  3290. if (colorCache[color]) {
  3291. return colorCache[color];
  3292. }
  3293. if (color[0] === '#') {
  3294. if (color.length === 7) {
  3295. return color;
  3296. }
  3297. var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
  3298. return '#' + r + r + g + g + b + b;
  3299. }); // hex3 to hex6
  3300. colorCache[color] = hex;
  3301. return hex;
  3302. } // rgb/rgba to hex
  3303. var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  3304. rst.shift();
  3305. rst = arr2hex(rst);
  3306. colorCache[color] = rst;
  3307. return rst;
  3308. }
  3309. /**
  3310. * handle the gradient color
  3311. * @param {Array} colors the colors
  3312. * @return {String} return the color value
  3313. */
  3314. function gradient(colors) {
  3315. var points = [];
  3316. if ((0, _util.isString)(colors)) {
  3317. colors = colors.split('-');
  3318. }
  3319. (0, _util.each)(colors, function (color) {
  3320. if (color.indexOf('#') === -1) {
  3321. color = toHex(color);
  3322. }
  3323. points.push(hex2arr(color));
  3324. });
  3325. return function (percent) {
  3326. return calColor(points, percent);
  3327. };
  3328. }
  3329. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  3330. __DEFINE__(1658993502556, function(require, module, exports) {
  3331. exports.__esModule = true;
  3332. exports["default"] = void 0;
  3333. var _common = require("../../util/common");
  3334. var _global = _interopRequireDefault(require("../../global"));
  3335. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3336. var Shape = {};
  3337. var ShapeBase = {
  3338. _coord: null,
  3339. /**
  3340. * draw the shape
  3341. * @param {Object} cfg options
  3342. * @param {Object} container container to store the shapes
  3343. */
  3344. draw: function draw(cfg, container) {
  3345. if (this.drawShape) {
  3346. this.drawShape(cfg, container);
  3347. }
  3348. },
  3349. /**
  3350. * set the coordinate instance
  3351. * @param {Coord} coord coordinate instance
  3352. */
  3353. setCoord: function setCoord(coord) {
  3354. this._coord = coord;
  3355. },
  3356. /**
  3357. * convert the normalized value to the canvas position
  3358. * @param {point} point the point to convert
  3359. * @return {point} point return the result
  3360. */
  3361. parsePoint: function parsePoint(point) {
  3362. var coord = this._coord;
  3363. if (coord.isPolar) {
  3364. if (point.x === 1) point.x = 0.9999999;
  3365. if (point.y === 1) point.y = 0.9999999;
  3366. }
  3367. return coord.convertPoint(point);
  3368. },
  3369. /**
  3370. * convert the normalized value to the canvas position
  3371. * @param {points} points the array that store the points
  3372. * @return {points} points return the result
  3373. */
  3374. parsePoints: function parsePoints(points) {
  3375. if (!points) return false;
  3376. var self = this;
  3377. var rst = [];
  3378. points.forEach(function (point) {
  3379. rst.push(self.parsePoint(point));
  3380. });
  3381. return rst;
  3382. }
  3383. };
  3384. var ShapeFactoryBase = {
  3385. defaultShapeType: null,
  3386. setCoord: function setCoord(coord) {
  3387. this._coord = coord;
  3388. },
  3389. getShape: function getShape(type) {
  3390. var self = this;
  3391. if ((0, _common.isArray)(type)) {
  3392. type = type[0];
  3393. }
  3394. var shape = self[type] || self[self.defaultShapeType];
  3395. shape._coord = self._coord;
  3396. return shape;
  3397. },
  3398. getShapePoints: function getShapePoints(type, cfg) {
  3399. var shape = this.getShape(type);
  3400. var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
  3401. var points = fn(cfg);
  3402. return points;
  3403. },
  3404. getDefaultPoints: function getDefaultPoints()
  3405. /* cfg */
  3406. {
  3407. return [];
  3408. },
  3409. drawShape: function drawShape(type, cfg, container) {
  3410. var shape = this.getShape(type);
  3411. if (!cfg.color) {
  3412. cfg.color = _global["default"].colors[0];
  3413. }
  3414. return shape.draw(cfg, container);
  3415. }
  3416. };
  3417. Shape.registerFactory = function (factoryName, cfg) {
  3418. var className = (0, _common.upperFirst)(factoryName);
  3419. var geomObj = (0, _common.mix)({}, ShapeFactoryBase, cfg);
  3420. Shape[className] = geomObj;
  3421. geomObj.name = factoryName;
  3422. return geomObj;
  3423. };
  3424. Shape.registerShape = function (factoryName, shapeType, cfg) {
  3425. var className = (0, _common.upperFirst)(factoryName);
  3426. var factory = Shape[className];
  3427. var shapeObj = (0, _common.mix)({}, ShapeBase, cfg);
  3428. factory[shapeType] = shapeObj;
  3429. return shapeObj;
  3430. };
  3431. Shape.registShape = Shape.registerShape;
  3432. Shape.getShapeFactory = function (factoryName) {
  3433. var self = this;
  3434. factoryName = factoryName || 'point';
  3435. var className = (0, _common.upperFirst)(factoryName);
  3436. return self[className];
  3437. };
  3438. var _default = Shape;
  3439. exports["default"] = _default;
  3440. }, function(modId) { var map = {"../../util/common":1658993502535,"../../global":1658993502533}; return __REQUIRE__(map[modId], modId); })
  3441. __DEFINE__(1658993502557, function(require, module, exports) {
  3442. exports.__esModule = true;
  3443. exports["default"] = void 0;
  3444. var _scale = require("../../scale");
  3445. var _common = require("../../util/common");
  3446. var _global = _interopRequireDefault(require("../../global"));
  3447. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3448. function isFullCircle(coord) {
  3449. if (!coord.isPolar) {
  3450. return false;
  3451. }
  3452. var startAngle = coord.startAngle;
  3453. var endAngle = coord.endAngle;
  3454. if (!(0, _common.isNil)(startAngle) && !(0, _common.isNil)(endAngle) && endAngle - startAngle < Math.PI * 2) {
  3455. return false;
  3456. }
  3457. return true;
  3458. }
  3459. function clearObj(obj) {
  3460. Object.keys(obj).forEach(function (key) {
  3461. delete obj[key];
  3462. });
  3463. }
  3464. var ScaleController = /*#__PURE__*/function () {
  3465. function ScaleController(cfg) {
  3466. // defs 列定义
  3467. this.defs = {}; // 已经实例化的scale
  3468. this.scales = {};
  3469. (0, _common.mix)(this, cfg);
  3470. }
  3471. var _proto = ScaleController.prototype;
  3472. _proto.setFieldDef = function setFieldDef(field, cfg) {
  3473. var defs = this.defs;
  3474. if ((0, _common.isObject)(field)) {
  3475. (0, _common.mix)(defs, field);
  3476. } else {
  3477. defs[field] = cfg;
  3478. } // 因为可能同时变更多个scale,所以要把所有已实例化的scale都更新下
  3479. this.updateScales();
  3480. };
  3481. _proto._getDef = function _getDef(field) {
  3482. var defs = this.defs;
  3483. var def = null;
  3484. if (_global["default"].scales[field] || defs[field]) {
  3485. def = (0, _common.mix)({}, _global["default"].scales[field]);
  3486. (0, _common.each)(defs[field], function (v, k) {
  3487. if ((0, _common.isNil)(v)) {
  3488. delete def[k];
  3489. } else {
  3490. def[k] = v;
  3491. }
  3492. });
  3493. }
  3494. return def;
  3495. };
  3496. _proto._getDefaultType = function _getDefaultType(field, data, def) {
  3497. if (def && def.type) {
  3498. return def.type;
  3499. }
  3500. var type = 'linear';
  3501. var value = _common.Array.firstValue(data, field);
  3502. if ((0, _common.isArray)(value)) {
  3503. value = value[0];
  3504. }
  3505. if ((0, _common.isString)(value)) {
  3506. type = 'cat';
  3507. }
  3508. return type;
  3509. };
  3510. _proto._getScaleDef = function _getScaleDef(type, field, data, def) {
  3511. var values;
  3512. if (def && def.values) {
  3513. values = def.values;
  3514. } else {
  3515. values = _common.Array.values(data, field);
  3516. }
  3517. var cfg = {
  3518. field: field,
  3519. values: values
  3520. };
  3521. if (type !== 'cat' && type !== 'timeCat') {
  3522. if (!def || !(def.min && def.max)) {
  3523. var _Array$getRange = _common.Array.getRange(values),
  3524. min = _Array$getRange.min,
  3525. max = _Array$getRange.max;
  3526. cfg.min = min;
  3527. cfg.max = max;
  3528. cfg.nice = true;
  3529. }
  3530. } else {
  3531. cfg.isRounding = false; // used for tickCount calculation
  3532. }
  3533. return cfg;
  3534. } // 调整range,为了让图形居中
  3535. ;
  3536. _proto._adjustRange = function _adjustRange(type, cfg) {
  3537. var range = cfg.range,
  3538. values = cfg.values; // 如果是线性, 或者有自定义range都不处理
  3539. if (type === 'linear' || range || !values) {
  3540. return cfg;
  3541. }
  3542. var count = values.length; // 单只有一条数据时,在中间显示
  3543. if (count === 1) {
  3544. cfg.range = [0.5, 1];
  3545. } else {
  3546. var chart = this.chart;
  3547. var coord = chart.get('coord');
  3548. var widthRatio = _global["default"].widthRatio.multiplePie;
  3549. var offset = 0;
  3550. if (isFullCircle(coord)) {
  3551. if (!coord.transposed) {
  3552. cfg.range = [0, 1 - 1 / count];
  3553. } else {
  3554. offset = 1 / count * widthRatio;
  3555. cfg.range = [offset / 2, 1 - offset / 2];
  3556. }
  3557. } else {
  3558. // 为了让图形居中,所以才设置range
  3559. offset = 1 / count * 0.5; // 这里可能用0.25会更合理
  3560. cfg.range = [offset, 1 - offset];
  3561. }
  3562. }
  3563. return cfg;
  3564. };
  3565. _proto._getScaleCfg = function _getScaleCfg(field, data) {
  3566. var self = this;
  3567. var def = self._getDef(field);
  3568. if (!data || !data.length) {
  3569. if (def && def.type) {
  3570. def.field = field;
  3571. return {
  3572. type: def.type,
  3573. cfg: def
  3574. };
  3575. }
  3576. return {
  3577. type: 'identity',
  3578. cfg: {
  3579. value: field,
  3580. field: field.toString(),
  3581. values: [field]
  3582. }
  3583. };
  3584. }
  3585. var firstObj = data[0];
  3586. var firstValue = firstObj[field];
  3587. if (firstValue === null) {
  3588. firstValue = _common.Array.firstValue(data, field);
  3589. }
  3590. if ((0, _common.isNumber)(field) || (0, _common.isNil)(firstValue) && !def) {
  3591. return {
  3592. type: 'identity',
  3593. cfg: {
  3594. value: field,
  3595. field: field.toString(),
  3596. values: [field]
  3597. }
  3598. };
  3599. }
  3600. var type = self._getDefaultType(field, data, def);
  3601. var cfg = self._getScaleDef(type, field, data, def);
  3602. def && (0, _common.mix)(cfg, def);
  3603. cfg = this._adjustRange(type, cfg);
  3604. return {
  3605. type: type,
  3606. cfg: cfg
  3607. };
  3608. };
  3609. _proto.createScale = function createScale(field, data) {
  3610. var scales = this.scales;
  3611. var _this$_getScaleCfg = this._getScaleCfg(field, data),
  3612. type = _this$_getScaleCfg.type,
  3613. cfg = _this$_getScaleCfg.cfg;
  3614. var scale = scales[field]; // 如果已经存在,且类型相等时直接返回
  3615. if (scale && scale.type === type) {
  3616. scale.change(cfg);
  3617. return scale;
  3618. }
  3619. var Scale = (0, _scale.getScale)(type);
  3620. var newScale = new Scale(cfg);
  3621. scales[field] = newScale;
  3622. return newScale;
  3623. };
  3624. _proto._updateScale = function _updateScale(scale) {
  3625. var field = scale.field; // 因为每个field的数据都会不同
  3626. var data = this.chart._getScaleData(field);
  3627. var _this$_getScaleCfg2 = this._getScaleCfg(field, data),
  3628. cfg = _this$_getScaleCfg2.cfg;
  3629. scale.change(cfg);
  3630. };
  3631. _proto.updateScales = function updateScales() {
  3632. var _this = this;
  3633. var scales = this.scales; // 修改完列定义后,需要更新已经实例化的scale
  3634. // 如果是还没有实例化的,在geom初始化的时候会被实例化,所以这里可以不用更新
  3635. (0, _common.each)(scales, function (scale) {
  3636. _this._updateScale(scale);
  3637. });
  3638. } // 调整scale从0开始
  3639. ;
  3640. _proto.adjustStartZero = function adjustStartZero(scale) {
  3641. var defs = this.defs;
  3642. var field = scale.field,
  3643. min = scale.min,
  3644. max = scale.max; // 如果有定义,则不处理
  3645. if (defs[field] && defs[field].min) {
  3646. return;
  3647. }
  3648. if (min > 0) {
  3649. scale.change({
  3650. min: 0
  3651. });
  3652. } else if (max < 0) {
  3653. scale.change({
  3654. max: 0
  3655. });
  3656. }
  3657. };
  3658. _proto.clear = function clear() {
  3659. // this.defs = {};
  3660. // this.scales = {};
  3661. clearObj(this.defs);
  3662. clearObj(this.scales);
  3663. this.data = null;
  3664. };
  3665. return ScaleController;
  3666. }();
  3667. var _default = ScaleController;
  3668. exports["default"] = _default;
  3669. }, function(modId) { var map = {"../../scale":1658993502558,"../../util/common":1658993502535,"../../global":1658993502533}; return __REQUIRE__(map[modId], modId); })
  3670. __DEFINE__(1658993502558, function(require, module, exports) {
  3671. exports.__esModule = true;
  3672. exports["default"] = void 0;
  3673. var _scale = require("@antv/scale");
  3674. exports.getScale = _scale.getScale;
  3675. exports.getTickMethod = _scale.getTickMethod;
  3676. var _catTick = _interopRequireDefault(require("./cat-tick"));
  3677. var _linearTick = _interopRequireDefault(require("./linear-tick"));
  3678. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3679. var Linear = (0, _scale.getScale)('linear');
  3680. var Identity = (0, _scale.getScale)('identity');
  3681. var Category = (0, _scale.getScale)('category');
  3682. var TimeCat = (0, _scale.getScale)('timeCat'); // 覆盖0.3.x的 cat 方法
  3683. (0, _scale.registerTickMethod)('cat', _catTick["default"]);
  3684. (0, _scale.registerTickMethod)('time-cat', _catTick["default"]); // 覆盖linear 度量的tick算法
  3685. (0, _scale.registerTickMethod)('wilkinson-extended', _linearTick["default"]);
  3686. _scale.Scale.Linear = Linear;
  3687. _scale.Scale.Identity = Identity;
  3688. _scale.Scale.Category = Category;
  3689. _scale.Scale.Cat = Category;
  3690. _scale.Scale.TimeCat = TimeCat;
  3691. var _default = _scale.Scale;
  3692. exports["default"] = _default;
  3693. }, function(modId) { var map = {"./cat-tick":1658993502559,"./linear-tick":1658993502560}; return __REQUIRE__(map[modId], modId); })
  3694. __DEFINE__(1658993502559, function(require, module, exports) {
  3695. exports.__esModule = true;
  3696. exports["default"] = void 0;
  3697. // cat平均算法,保头保尾
  3698. var _default = function _default(cfg) {
  3699. var values = cfg.values,
  3700. tickCount = cfg.tickCount;
  3701. if (!tickCount) {
  3702. return values;
  3703. }
  3704. if (values.length <= 1) {
  3705. return values;
  3706. } // 获取间隔步长, 最小是1
  3707. var step = parseInt(values.length / (tickCount - 1)) || 1;
  3708. var ticks = []; // 按间隔数取对应节点
  3709. for (var index = 0; index < values.length; index = index + step) {
  3710. ticks.push(values[index]);
  3711. }
  3712. var last = values[values.length - 1]; // 如果最后一个tick不等于原数据的最后一个
  3713. if (ticks[ticks.length - 1] !== last) {
  3714. if (ticks.length >= tickCount) {
  3715. // 如果当前的tick个数满足要求
  3716. ticks[ticks.length - 1] = last;
  3717. } else {
  3718. // 不满足tickCount则直接加入最后一个
  3719. ticks.push(last);
  3720. }
  3721. }
  3722. return ticks;
  3723. };
  3724. exports["default"] = _default;
  3725. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  3726. __DEFINE__(1658993502560, function(require, module, exports) {
  3727. exports.__esModule = true;
  3728. exports["default"] = void 0;
  3729. // 认为是nice的刻度
  3730. var SNAP_COUNT_ARRAY = [1, 1.2, 1.5, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10];
  3731. var DEFAULT_COUNT = 5; // 默认刻度值
  3732. var _default = function _default(cfg) {
  3733. var _ref = cfg || {},
  3734. tickCount = _ref.tickCount,
  3735. tickInterval = _ref.tickInterval;
  3736. var _ref2 = cfg || {},
  3737. min = _ref2.min,
  3738. max = _ref2.max;
  3739. min = isNaN(min) ? 0 : min;
  3740. max = isNaN(max) ? 0 : max;
  3741. var count = tickCount && tickCount >= 2 ? tickCount : DEFAULT_COUNT; // 计算interval, 优先取tickInterval
  3742. var interval = tickInterval || getBestInterval({
  3743. tickCount: count,
  3744. max: max,
  3745. min: min
  3746. }); // 通过interval计算最小tick
  3747. var minTick = Math.floor(min / interval) * interval; // 如果指定了tickInterval, count 需要根据指定的tickInterval来算计
  3748. if (tickInterval) {
  3749. var intervalCount = Math.abs(Math.ceil((max - minTick) / tickInterval)) + 1; // tickCount 作为最小 count 处理
  3750. count = Math.max(count, intervalCount);
  3751. }
  3752. var ticks = [];
  3753. var tickLength = 0;
  3754. var fixedLength = getFixedLength(interval);
  3755. while (tickLength < count) {
  3756. ticks.push(toFixed(minTick + tickLength * interval, fixedLength));
  3757. tickLength++;
  3758. }
  3759. return ticks;
  3760. };
  3761. exports["default"] = _default;
  3762. var DECIMAL_LENGTH = 12;
  3763. function getFactor(number) {
  3764. // 取正数
  3765. number = Math.abs(number);
  3766. var factor = 1;
  3767. if (number === 0) {
  3768. return factor;
  3769. } // 小于1,逐渐放大
  3770. if (number < 1) {
  3771. var count = 0;
  3772. while (number < 1) {
  3773. factor = factor / 10;
  3774. number = number * 10;
  3775. count++;
  3776. } // 浮点数计算出现问题
  3777. if (factor.toString().length > DECIMAL_LENGTH) {
  3778. factor = parseFloat(factor.toFixed(count));
  3779. }
  3780. return factor;
  3781. } // 大于10逐渐缩小
  3782. while (number > 10) {
  3783. factor = factor * 10;
  3784. number = number / 10;
  3785. }
  3786. return factor;
  3787. } // 获取最佳匹配刻度
  3788. function getBestInterval(_ref3) {
  3789. var tickCount = _ref3.tickCount,
  3790. min = _ref3.min,
  3791. max = _ref3.max;
  3792. // 如果最大最小相等,则直接按1处理
  3793. if (min === max) {
  3794. return 1 * getFactor(max);
  3795. } // 1.计算平均刻度间隔
  3796. var avgInterval = (max - min) / (tickCount - 1); // 2.数据标准归一化 映射到[1-10]区间
  3797. var factor = getFactor(avgInterval);
  3798. var calInterval = avgInterval / factor;
  3799. var calMax = max / factor;
  3800. var calMin = min / factor; // 根据平均值推算最逼近刻度值
  3801. var similarityIndex = 0;
  3802. for (var index = 0; index < SNAP_COUNT_ARRAY.length; index++) {
  3803. var item = SNAP_COUNT_ARRAY[index];
  3804. if (calInterval <= item) {
  3805. similarityIndex = index;
  3806. break;
  3807. }
  3808. }
  3809. var similarityInterval = getInterval(similarityIndex, tickCount, calMin, calMax); // 小数点位数还原到数据的位数, 因为similarityIndex有可能是小数,所以需要保留similarityIndex自己的小数位数
  3810. var fixedLength = getFixedLength(similarityInterval) + getFixedLength(factor);
  3811. return toFixed(similarityInterval * factor, fixedLength);
  3812. }
  3813. function getInterval(startIndex, tickCount, min, max) {
  3814. var verify = false;
  3815. var interval = SNAP_COUNT_ARRAY[startIndex]; // 刻度值校验,如果不满足,循环下去
  3816. for (var i = startIndex; i < SNAP_COUNT_ARRAY.length; i++) {
  3817. if (intervalIsVerify({
  3818. interval: SNAP_COUNT_ARRAY[i],
  3819. tickCount: tickCount,
  3820. max: max,
  3821. min: min
  3822. })) {
  3823. // 有符合条件的interval
  3824. interval = SNAP_COUNT_ARRAY[i];
  3825. verify = true;
  3826. break;
  3827. }
  3828. } // 如果不满足, 依次缩小10倍,再计算
  3829. if (!verify) {
  3830. return 10 * getInterval(0, tickCount, min / 10, max / 10);
  3831. }
  3832. return interval;
  3833. } // 刻度是否满足展示需求
  3834. function intervalIsVerify(_ref4) {
  3835. var interval = _ref4.interval,
  3836. tickCount = _ref4.tickCount,
  3837. max = _ref4.max,
  3838. min = _ref4.min;
  3839. var minTick = Math.floor(min / interval) * interval;
  3840. if (minTick + (tickCount - 1) * interval >= max) {
  3841. return true;
  3842. }
  3843. return false;
  3844. } // 计算小数点应该保留的位数
  3845. function getFixedLength(num) {
  3846. var str = num.toString();
  3847. var index = str.indexOf('.');
  3848. var indexOfExp = str.indexOf('e-');
  3849. var length = indexOfExp >= 0 ? parseInt(str.substr(indexOfExp + 2), 10) : str.substr(index + 1).length;
  3850. if (length > 20) {
  3851. // 最多保留20位小数
  3852. length = 20;
  3853. }
  3854. return length;
  3855. } // @antv/util fixedbase不支持科学计数法的判断,需要提mr
  3856. function toFixed(v, length) {
  3857. return parseFloat(v.toFixed(length));
  3858. }
  3859. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  3860. __DEFINE__(1658993502561, function(require, module, exports) {
  3861. exports.__esModule = true;
  3862. exports["default"] = void 0;
  3863. var _common = require("../../util/common");
  3864. var _index = _interopRequireDefault(require("../../component/axis/index"));
  3865. var _global = _interopRequireDefault(require("../../global"));
  3866. var _index2 = require("../../graphic/index");
  3867. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  3868. function formatTicks(ticks) {
  3869. var tmp = ticks.slice(0);
  3870. if (tmp.length > 0) {
  3871. var first = tmp[0];
  3872. var last = tmp[tmp.length - 1];
  3873. if (first.value !== 0) {
  3874. tmp.unshift({
  3875. value: 0
  3876. });
  3877. }
  3878. if (last.value !== 1) {
  3879. tmp.push({
  3880. value: 1
  3881. });
  3882. }
  3883. }
  3884. return tmp;
  3885. }
  3886. var AxisController = /*#__PURE__*/function () {
  3887. function AxisController(cfg) {
  3888. this.axisCfg = {};
  3889. this.frontPlot = null;
  3890. this.backPlot = null;
  3891. this.axes = {}; // store the axes's options
  3892. (0, _common.mix)(this, cfg);
  3893. }
  3894. var _proto = AxisController.prototype;
  3895. _proto._isHide = function _isHide(field) {
  3896. var axisCfg = this.axisCfg;
  3897. return !axisCfg || axisCfg[field] === false;
  3898. };
  3899. _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
  3900. var position = '';
  3901. var field = scale.field;
  3902. var axisCfg = this.axisCfg;
  3903. if (axisCfg[field] && axisCfg[field].position) {
  3904. position = axisCfg[field].position;
  3905. } else if (dimType === 'x') {
  3906. position = transposed ? 'left' : 'bottom';
  3907. } else if (dimType === 'y') {
  3908. position = index ? 'right' : 'left';
  3909. if (transposed) {
  3910. position = 'bottom';
  3911. }
  3912. }
  3913. return position;
  3914. };
  3915. _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
  3916. var start;
  3917. var end;
  3918. var factor = 1; // Mark clockwise or counterclockwise
  3919. if (dimType === 'x') {
  3920. start = {
  3921. x: 0,
  3922. y: 0
  3923. };
  3924. end = {
  3925. x: 1,
  3926. y: 0
  3927. };
  3928. } else {
  3929. if (position === 'right') {
  3930. // there will be several y axes
  3931. start = {
  3932. x: 1,
  3933. y: 0
  3934. };
  3935. end = {
  3936. x: 1,
  3937. y: 1
  3938. };
  3939. } else {
  3940. start = {
  3941. x: 0,
  3942. y: 0
  3943. };
  3944. end = {
  3945. x: 0,
  3946. y: 1
  3947. };
  3948. factor = -1;
  3949. }
  3950. }
  3951. if (coord.transposed) {
  3952. factor *= -1;
  3953. }
  3954. return {
  3955. offsetFactor: factor,
  3956. start: coord.convertPoint(start),
  3957. end: coord.convertPoint(end)
  3958. };
  3959. };
  3960. _proto._getCircleCfg = function _getCircleCfg(coord) {
  3961. return {
  3962. startAngle: coord.startAngle,
  3963. endAngle: coord.endAngle,
  3964. center: coord.center,
  3965. radius: coord.circleRadius
  3966. };
  3967. };
  3968. _proto._getRadiusCfg = function _getRadiusCfg(coord) {
  3969. var transposed = coord.transposed;
  3970. var start;
  3971. var end;
  3972. if (transposed) {
  3973. start = {
  3974. x: 0,
  3975. y: 0
  3976. };
  3977. end = {
  3978. x: 1,
  3979. y: 0
  3980. };
  3981. } else {
  3982. start = {
  3983. x: 0,
  3984. y: 0
  3985. };
  3986. end = {
  3987. x: 0,
  3988. y: 1
  3989. };
  3990. }
  3991. return {
  3992. offsetFactor: -1,
  3993. start: coord.convertPoint(start),
  3994. end: coord.convertPoint(end)
  3995. };
  3996. };
  3997. _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
  3998. var self = this;
  3999. var axisCfg = this.axisCfg;
  4000. var ticks = scale.getTicks();
  4001. var cfg = (0, _common.deepMix)({
  4002. ticks: ticks,
  4003. frontContainer: this.frontPlot,
  4004. backContainer: this.backPlot
  4005. }, defaultCfg, axisCfg[scale.field]);
  4006. var labels = [];
  4007. var label = cfg.label;
  4008. var count = ticks.length;
  4009. var maxWidth = 0;
  4010. var maxHeight = 0;
  4011. var labelCfg = label;
  4012. (0, _common.each)(ticks, function (tick, index) {
  4013. if ((0, _common.isFunction)(label)) {
  4014. var executedLabel = label(tick.text, index, count);
  4015. labelCfg = executedLabel ? (0, _common.mix)({}, _global["default"]._defaultAxis.label, executedLabel) : null;
  4016. }
  4017. if (labelCfg) {
  4018. var textStyle = {};
  4019. if (labelCfg.textAlign) {
  4020. textStyle.textAlign = labelCfg.textAlign;
  4021. }
  4022. if (labelCfg.textBaseline) {
  4023. textStyle.textBaseline = labelCfg.textBaseline;
  4024. }
  4025. var axisLabel = new _index2.Shape.Text({
  4026. className: 'axis-label',
  4027. attrs: (0, _common.mix)({
  4028. x: 0,
  4029. y: 0,
  4030. text: tick.text,
  4031. fontFamily: self.chart.get('canvas').get('fontFamily')
  4032. }, labelCfg),
  4033. value: tick.value,
  4034. textStyle: textStyle,
  4035. top: labelCfg.top,
  4036. context: self.chart.get('canvas').get('context')
  4037. });
  4038. labels.push(axisLabel);
  4039. var _axisLabel$getBBox = axisLabel.getBBox(),
  4040. width = _axisLabel$getBBox.width,
  4041. height = _axisLabel$getBBox.height;
  4042. maxWidth = Math.max(maxWidth, width);
  4043. maxHeight = Math.max(maxHeight, height);
  4044. }
  4045. });
  4046. cfg.labels = labels;
  4047. cfg.maxWidth = maxWidth;
  4048. cfg.maxHeight = maxHeight;
  4049. return cfg;
  4050. };
  4051. _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
  4052. if (index === void 0) {
  4053. index = '';
  4054. }
  4055. var self = this;
  4056. var coordType = coord.type;
  4057. var transposed = coord.transposed;
  4058. var type;
  4059. var key;
  4060. var defaultCfg;
  4061. if (coordType === 'cartesian' || coordType === 'rect') {
  4062. var position = self._getLinePosition(scale, dimType, index, transposed);
  4063. defaultCfg = _global["default"].axis[position];
  4064. defaultCfg.position = position;
  4065. type = 'Line';
  4066. key = position;
  4067. } else {
  4068. if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
  4069. defaultCfg = _global["default"].axis.circle;
  4070. type = 'Circle';
  4071. key = 'circle';
  4072. } else {
  4073. defaultCfg = _global["default"].axis.radius;
  4074. type = 'Line';
  4075. key = 'radius';
  4076. }
  4077. }
  4078. var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);
  4079. cfg.type = type;
  4080. cfg.dimType = dimType;
  4081. cfg.verticalScale = verticalScale;
  4082. cfg.index = index;
  4083. this.axes[key] = cfg;
  4084. };
  4085. _proto.createAxis = function createAxis(coord, xScale, yScales) {
  4086. var self = this;
  4087. if (xScale && !self._isHide(xScale.field)) {
  4088. self._createAxis(coord, xScale, yScales[0], 'x');
  4089. }
  4090. (0, _common.each)(yScales, function (yScale, index) {
  4091. if (!self._isHide(yScale.field)) {
  4092. self._createAxis(coord, yScale, xScale, 'y', index);
  4093. }
  4094. });
  4095. var axes = this.axes;
  4096. var chart = self.chart;
  4097. if (chart._isAutoPadding()) {
  4098. var userPadding = (0, _common.parsePadding)(chart.get('padding'));
  4099. var appendPadding = (0, _common.parsePadding)(chart.get('appendPadding'));
  4100. var legendRange = chart.get('legendRange') || {
  4101. top: 0,
  4102. right: 0,
  4103. bottom: 0,
  4104. left: 0
  4105. };
  4106. var padding = [userPadding[0] === 'auto' ? legendRange.top + appendPadding[0] * 2 : userPadding[0], userPadding[1] === 'auto' ? legendRange.right + appendPadding[1] : userPadding[1], userPadding[2] === 'auto' ? legendRange.bottom + appendPadding[2] : userPadding[2], userPadding[3] === 'auto' ? legendRange.left + appendPadding[3] : userPadding[3]];
  4107. if (coord.isPolar) {
  4108. var circleAxis = axes.circle;
  4109. if (circleAxis) {
  4110. var maxHeight = circleAxis.maxHeight,
  4111. maxWidth = circleAxis.maxWidth,
  4112. labelOffset = circleAxis.labelOffset;
  4113. padding[0] += maxHeight + labelOffset;
  4114. padding[1] += maxWidth + labelOffset;
  4115. padding[2] += maxHeight + labelOffset;
  4116. padding[3] += maxWidth + labelOffset;
  4117. }
  4118. } else {
  4119. if (axes.right && userPadding[1] === 'auto') {
  4120. var _axes$right = axes.right,
  4121. _maxWidth = _axes$right.maxWidth,
  4122. _labelOffset = _axes$right.labelOffset;
  4123. padding[1] += _maxWidth + _labelOffset;
  4124. }
  4125. if (axes.left && userPadding[3] === 'auto') {
  4126. var _axes$left = axes.left,
  4127. _maxWidth2 = _axes$left.maxWidth,
  4128. _labelOffset2 = _axes$left.labelOffset;
  4129. padding[3] += _maxWidth2 + _labelOffset2;
  4130. }
  4131. if (axes.bottom && userPadding[2] === 'auto') {
  4132. var _axes$bottom = axes.bottom,
  4133. _maxHeight = _axes$bottom.maxHeight,
  4134. _labelOffset3 = _axes$bottom.labelOffset;
  4135. padding[2] += _maxHeight + _labelOffset3;
  4136. }
  4137. }
  4138. chart.set('_padding', padding);
  4139. chart._updateLayout(padding);
  4140. }
  4141. (0, _common.each)(axes, function (axis) {
  4142. var type = axis.type,
  4143. grid = axis.grid,
  4144. verticalScale = axis.verticalScale,
  4145. ticks = axis.ticks,
  4146. dimType = axis.dimType,
  4147. position = axis.position,
  4148. index = axis.index;
  4149. var appendCfg;
  4150. if (coord.isPolar) {
  4151. if (type === 'Line') {
  4152. appendCfg = self._getRadiusCfg(coord);
  4153. } else if (type === 'Circle') {
  4154. appendCfg = self._getCircleCfg(coord);
  4155. }
  4156. } else {
  4157. appendCfg = self._getLineCfg(coord, dimType, position);
  4158. }
  4159. if (grid && verticalScale) {
  4160. var gridPoints = [];
  4161. var verticalTicks = formatTicks(verticalScale.getTicks());
  4162. (0, _common.each)(ticks, function (tick) {
  4163. var subPoints = [];
  4164. (0, _common.each)(verticalTicks, function (verticalTick) {
  4165. var x = dimType === 'x' ? tick.value : verticalTick.value;
  4166. var y = dimType === 'x' ? verticalTick.value : tick.value;
  4167. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  4168. var point = coord.convertPoint({
  4169. x: x,
  4170. y: y
  4171. });
  4172. subPoints.push(point);
  4173. }
  4174. });
  4175. gridPoints.push({
  4176. points: subPoints,
  4177. _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
  4178. });
  4179. });
  4180. axis.gridPoints = gridPoints;
  4181. if (coord.isPolar) {
  4182. axis.center = coord.center;
  4183. axis.startAngle = coord.startAngle;
  4184. axis.endAngle = coord.endAngle;
  4185. }
  4186. }
  4187. appendCfg._id = 'axis-' + dimType;
  4188. if (!(0, _common.isNil)(index)) {
  4189. appendCfg._id = 'axis-' + dimType + index;
  4190. }
  4191. new _index["default"][type]((0, _common.mix)(axis, appendCfg));
  4192. });
  4193. };
  4194. _proto.clear = function clear() {
  4195. this.axes = {};
  4196. this.frontPlot.clear();
  4197. this.backPlot.clear();
  4198. };
  4199. return AxisController;
  4200. }();
  4201. var _default = AxisController;
  4202. exports["default"] = _default;
  4203. }, function(modId) { var map = {"../../util/common":1658993502535,"../../component/axis/index":1658993502562,"../../global":1658993502533,"../../graphic/index":1658993502565}; return __REQUIRE__(map[modId], modId); })
  4204. __DEFINE__(1658993502562, function(require, module, exports) {
  4205. exports.__esModule = true;
  4206. exports["default"] = void 0;
  4207. var _abstract = _interopRequireDefault(require("./abstract"));
  4208. require("./line");
  4209. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4210. var _default = _abstract["default"];
  4211. exports["default"] = _default;
  4212. }, function(modId) { var map = {"./abstract":1658993502563,"./line":1658993502564}; return __REQUIRE__(map[modId], modId); })
  4213. __DEFINE__(1658993502563, function(require, module, exports) {
  4214. exports.__esModule = true;
  4215. exports["default"] = void 0;
  4216. var _common = require("../../util/common");
  4217. var _global = _interopRequireDefault(require("../../global"));
  4218. var _vector = _interopRequireDefault(require("../../graphic/util/vector2"));
  4219. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4220. var Abastract = /*#__PURE__*/function () {
  4221. var _proto = Abastract.prototype;
  4222. _proto._initDefaultCfg = function _initDefaultCfg() {
  4223. /**
  4224. * ticks
  4225. * @type {Array}
  4226. */
  4227. this.ticks = [];
  4228. /**
  4229. * the configuration for tickLine
  4230. * @type {Object}
  4231. */
  4232. this.tickLine = {};
  4233. /**
  4234. * the direction of ticks, 1 means clockwise
  4235. * @type {Number}
  4236. */
  4237. this.offsetFactor = 1;
  4238. /**
  4239. * the top container
  4240. * @type {container}
  4241. */
  4242. this.frontContainer = null;
  4243. /**
  4244. * the back container
  4245. * @type {[type]}
  4246. */
  4247. this.backContainer = null;
  4248. /**
  4249. * points for draw grid line
  4250. * @type {Array}
  4251. */
  4252. this.gridPoints = [];
  4253. };
  4254. function Abastract(cfg) {
  4255. this._initDefaultCfg();
  4256. (0, _common.mix)(this, cfg);
  4257. this.draw();
  4258. }
  4259. _proto.draw = function draw() {
  4260. var line = this.line,
  4261. tickLine = this.tickLine,
  4262. label = this.label,
  4263. grid = this.grid;
  4264. grid && this.drawGrid(grid); // draw the grid lines
  4265. tickLine && this.drawTicks(tickLine); // draw the tickLine
  4266. line && this.drawLine(line); // draw axis line
  4267. label && this.drawLabels(); // draw ticks
  4268. };
  4269. _proto.drawTicks = function drawTicks(tickCfg) {
  4270. var self = this;
  4271. var ticks = self.ticks;
  4272. var length = tickCfg.length;
  4273. var container = self.getContainer(tickCfg.top);
  4274. (0, _common.each)(ticks, function (tick) {
  4275. var start = self.getOffsetPoint(tick.value);
  4276. var end = self.getSidePoint(start, length);
  4277. var shape = container.addShape('line', {
  4278. className: 'axis-tick',
  4279. attrs: (0, _common.mix)({
  4280. x1: start.x,
  4281. y1: start.y,
  4282. x2: end.x,
  4283. y2: end.y
  4284. }, tickCfg)
  4285. });
  4286. shape._id = self._id + '-ticks';
  4287. });
  4288. };
  4289. _proto.drawLabels = function drawLabels() {
  4290. var self = this;
  4291. var labelOffset = self.labelOffset;
  4292. var labels = self.labels;
  4293. (0, _common.each)(labels, function (labelShape) {
  4294. var container = self.getContainer(labelShape.get('top'));
  4295. var start = self.getOffsetPoint(labelShape.get('value'));
  4296. var _self$getSidePoint = self.getSidePoint(start, labelOffset),
  4297. x = _self$getSidePoint.x,
  4298. y = _self$getSidePoint.y;
  4299. labelShape.attr((0, _common.mix)({
  4300. x: x,
  4301. y: y
  4302. }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
  4303. labelShape._id = self._id + '-' + labelShape.attr('text');
  4304. container.add(labelShape);
  4305. });
  4306. };
  4307. _proto.drawLine = function drawLine() {};
  4308. _proto.drawGrid = function drawGrid(grid) {
  4309. var self = this;
  4310. var gridPoints = self.gridPoints,
  4311. ticks = self.ticks;
  4312. var gridCfg = grid;
  4313. var count = gridPoints.length;
  4314. (0, _common.each)(gridPoints, function (subPoints, index) {
  4315. if ((0, _common.isFunction)(grid)) {
  4316. var tick = ticks[index] || {};
  4317. var executedGrid = grid(tick.text, index, count);
  4318. gridCfg = executedGrid ? (0, _common.mix)({}, _global["default"]._defaultAxis.grid, executedGrid) : null;
  4319. }
  4320. if (gridCfg) {
  4321. var type = gridCfg.type; // has two types: 'line' and 'arc'
  4322. var points = subPoints.points;
  4323. var container = self.getContainer(gridCfg.top);
  4324. var shape;
  4325. if (type === 'arc') {
  4326. var center = self.center,
  4327. startAngle = self.startAngle,
  4328. endAngle = self.endAngle;
  4329. var radius = _vector["default"].length([points[0].x - center.x, points[0].y - center.y]);
  4330. shape = container.addShape('Arc', {
  4331. className: 'axis-grid',
  4332. attrs: (0, _common.mix)({
  4333. x: center.x,
  4334. y: center.y,
  4335. startAngle: startAngle,
  4336. endAngle: endAngle,
  4337. r: radius
  4338. }, gridCfg)
  4339. });
  4340. } else {
  4341. shape = container.addShape('Polyline', {
  4342. className: 'axis-grid',
  4343. attrs: (0, _common.mix)({
  4344. points: points
  4345. }, gridCfg)
  4346. });
  4347. }
  4348. shape._id = subPoints._id;
  4349. }
  4350. });
  4351. };
  4352. _proto.getOffsetPoint = function getOffsetPoint() {};
  4353. _proto.getAxisVector = function getAxisVector() {};
  4354. _proto.getOffsetVector = function getOffsetVector(point, offset) {
  4355. var self = this;
  4356. var axisVector = self.getAxisVector(point);
  4357. var normal = _vector["default"].normalize([], axisVector);
  4358. var factor = self.offsetFactor;
  4359. var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
  4360. return _vector["default"].scale([], verticalVector, offset);
  4361. };
  4362. _proto.getSidePoint = function getSidePoint(point, offset) {
  4363. var self = this;
  4364. var offsetVector = self.getOffsetVector(point, offset);
  4365. return {
  4366. x: point.x + offsetVector[0],
  4367. y: point.y + offsetVector[1]
  4368. };
  4369. };
  4370. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  4371. var self = this;
  4372. var offsetVector = self.getOffsetVector(point, offset);
  4373. var align;
  4374. var baseLine;
  4375. if (offsetVector[0] > 0) {
  4376. align = 'left';
  4377. } else if (offsetVector[0] < 0) {
  4378. align = 'right';
  4379. } else {
  4380. align = 'center';
  4381. }
  4382. if (offsetVector[1] > 0) {
  4383. baseLine = 'top';
  4384. } else if (offsetVector[1] < 0) {
  4385. baseLine = 'bottom';
  4386. } else {
  4387. baseLine = 'middle';
  4388. }
  4389. return {
  4390. textAlign: align,
  4391. textBaseline: baseLine
  4392. };
  4393. };
  4394. _proto.getContainer = function getContainer(isTop) {
  4395. var frontContainer = this.frontContainer,
  4396. backContainer = this.backContainer;
  4397. return isTop ? frontContainer : backContainer;
  4398. };
  4399. return Abastract;
  4400. }();
  4401. var _default = Abastract;
  4402. exports["default"] = _default;
  4403. }, function(modId) { var map = {"../../util/common":1658993502535,"../../global":1658993502533,"../../graphic/util/vector2":1658993502546}; return __REQUIRE__(map[modId], modId); })
  4404. __DEFINE__(1658993502564, function(require, module, exports) {
  4405. exports.__esModule = true;
  4406. exports["default"] = void 0;
  4407. var _common = require("../../util/common");
  4408. var _abstract = _interopRequireDefault(require("./abstract"));
  4409. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4410. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4411. var Line = /*#__PURE__*/function (_Abstract) {
  4412. _inheritsLoose(Line, _Abstract);
  4413. function Line() {
  4414. return _Abstract.apply(this, arguments) || this;
  4415. }
  4416. var _proto = Line.prototype;
  4417. _proto._initDefaultCfg = function _initDefaultCfg() {
  4418. _Abstract.prototype._initDefaultCfg.call(this);
  4419. this.start = null;
  4420. this.end = null;
  4421. };
  4422. _proto.getOffsetPoint = function getOffsetPoint(value) {
  4423. var start = this.start,
  4424. end = this.end;
  4425. return {
  4426. x: start.x + (end.x - start.x) * value,
  4427. y: start.y + (end.y - start.y) * value
  4428. };
  4429. };
  4430. _proto.getAxisVector = function getAxisVector() {
  4431. var start = this.start,
  4432. end = this.end;
  4433. return [end.x - start.x, end.y - start.y];
  4434. };
  4435. _proto.drawLine = function drawLine(lineCfg) {
  4436. var container = this.getContainer(lineCfg.top);
  4437. var start = this.start,
  4438. end = this.end;
  4439. container.addShape('line', {
  4440. className: 'axis-line',
  4441. attrs: (0, _common.mix)({
  4442. x1: start.x,
  4443. y1: start.y,
  4444. x2: end.x,
  4445. y2: end.y
  4446. }, lineCfg)
  4447. });
  4448. };
  4449. return Line;
  4450. }(_abstract["default"]);
  4451. _abstract["default"].Line = Line;
  4452. var _default = Line;
  4453. exports["default"] = _default;
  4454. }, function(modId) { var map = {"../../util/common":1658993502535,"./abstract":1658993502563}; return __REQUIRE__(map[modId], modId); })
  4455. __DEFINE__(1658993502565, function(require, module, exports) {
  4456. exports.__esModule = true;
  4457. var _canvas = _interopRequireDefault(require("./canvas"));
  4458. exports.Canvas = _canvas["default"];
  4459. var _group = _interopRequireDefault(require("./group"));
  4460. exports.Group = _group["default"];
  4461. var _shape = _interopRequireDefault(require("./shape"));
  4462. exports.Shape = _shape["default"];
  4463. var _matrix = _interopRequireDefault(require("./util/matrix"));
  4464. exports.Matrix = _matrix["default"];
  4465. var _vector = _interopRequireDefault(require("./util/vector2"));
  4466. exports.Vector2 = _vector["default"];
  4467. require("./shape/rect");
  4468. require("./shape/image");
  4469. require("./shape/circle");
  4470. require("./shape/line");
  4471. require("./shape/polygon");
  4472. require("./shape/polyline");
  4473. require("./shape/arc");
  4474. require("./shape/sector");
  4475. require("./shape/text");
  4476. require("./shape/custom");
  4477. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4478. }, function(modId) { var map = {"./canvas":1658993502566,"./group":1658993502573,"./shape":1658993502570,"./util/matrix":1658993502545,"./util/vector2":1658993502546,"./shape/rect":1658993502575,"./shape/image":1658993502576,"./shape/circle":1658993502577,"./shape/line":1658993502578,"./shape/polygon":1658993502580,"./shape/polyline":1658993502581,"./shape/arc":1658993502583,"./shape/sector":1658993502584,"./shape/text":1658993502585,"./shape/custom":1658993502587}; return __REQUIRE__(map[modId], modId); })
  4479. __DEFINE__(1658993502566, function(require, module, exports) {
  4480. exports.__esModule = true;
  4481. exports["default"] = void 0;
  4482. var _emit = _interopRequireDefault(require("./event/emit"));
  4483. var _controller = _interopRequireDefault(require("./event/controller"));
  4484. var _canvasElement = _interopRequireDefault(require("./canvas-element"));
  4485. var _common = require("../util/common");
  4486. var _container = _interopRequireDefault(require("./container"));
  4487. var _group = _interopRequireDefault(require("./group"));
  4488. var _requestAnimationFrame = require("./util/requestAnimationFrame");
  4489. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4490. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4491. var Canvas = /*#__PURE__*/function (_EventEmit) {
  4492. _inheritsLoose(Canvas, _EventEmit);
  4493. var _proto = Canvas.prototype;
  4494. _proto.get = function get(name) {
  4495. return this._attrs[name];
  4496. };
  4497. _proto.set = function set(name, value) {
  4498. this._attrs[name] = value;
  4499. };
  4500. function Canvas(cfg) {
  4501. var _this;
  4502. _this = _EventEmit.call(this) || this;
  4503. _this._attrs = (0, _common.mix)({
  4504. type: 'canvas',
  4505. children: []
  4506. }, cfg);
  4507. _this._initPixelRatio();
  4508. _this._initCanvas();
  4509. return _this;
  4510. }
  4511. _proto._initPixelRatio = function _initPixelRatio() {
  4512. var pixelRatio = this.get('pixelRatio');
  4513. if (!pixelRatio) {
  4514. this.set('pixelRatio', (0, _common.getPixelRatio)());
  4515. }
  4516. };
  4517. _proto.beforeDraw = function beforeDraw() {
  4518. var context = this._attrs.context;
  4519. var el = this._attrs.el;
  4520. context && context.clearRect && context.clearRect(0, 0, el.width, el.height);
  4521. };
  4522. _proto._initCanvas = function _initCanvas() {
  4523. var self = this;
  4524. var el = self.get('el');
  4525. var context = self.get('context');
  4526. if (!el && !context) {
  4527. throw new Error('Please specify the id, el or context of the chart!');
  4528. }
  4529. var canvas;
  4530. if (el) {
  4531. // DOMElement or String
  4532. canvas = (0, _common.isString)(el) ? (0, _common.getDomById)(el) : el;
  4533. } else {
  4534. // 说明没有指定el
  4535. canvas = _canvasElement["default"].create(context);
  4536. }
  4537. if (context && canvas && !canvas.getContext) {
  4538. canvas.getContext = function () {
  4539. return context;
  4540. };
  4541. }
  4542. var width = self.get('width');
  4543. if (!width) {
  4544. width = (0, _common.getWidth)(canvas);
  4545. }
  4546. var height = self.get('height');
  4547. if (!height) {
  4548. height = (0, _common.getHeight)(canvas);
  4549. }
  4550. self.set('canvas', this);
  4551. self.set('el', canvas);
  4552. self.set('context', context || canvas.getContext('2d'));
  4553. self.changeSize(width, height); // 初始化事件控制器
  4554. var eventController = new _controller["default"]({
  4555. canvas: this,
  4556. el: canvas
  4557. });
  4558. self.set('eventController', eventController);
  4559. };
  4560. _proto.changeSize = function changeSize(width, height) {
  4561. var pixelRatio = this.get('pixelRatio');
  4562. var canvasDOM = this.get('el'); // HTMLCanvasElement or canvasElement
  4563. // 浏览器环境设置style样式
  4564. if (canvasDOM.style) {
  4565. canvasDOM.style.width = width + 'px';
  4566. canvasDOM.style.height = height + 'px';
  4567. }
  4568. if ((0, _common.isCanvasElement)(canvasDOM)) {
  4569. canvasDOM.width = width * pixelRatio;
  4570. canvasDOM.height = height * pixelRatio;
  4571. if (pixelRatio !== 1) {
  4572. var ctx = this.get('context');
  4573. ctx.scale(pixelRatio, pixelRatio);
  4574. }
  4575. }
  4576. this.set('width', width);
  4577. this.set('height', height);
  4578. };
  4579. _proto.getWidth = function getWidth() {
  4580. var pixelRatio = this.get('pixelRatio');
  4581. var width = this.get('width');
  4582. return width * pixelRatio;
  4583. };
  4584. _proto.getHeight = function getHeight() {
  4585. var pixelRatio = this.get('pixelRatio');
  4586. var height = this.get('height');
  4587. return height * pixelRatio;
  4588. };
  4589. _proto.getPointByClient = function getPointByClient(clientX, clientY) {
  4590. var el = this.get('el');
  4591. var bbox = el.getBoundingClientRect();
  4592. var width = bbox.right - bbox.left;
  4593. var height = bbox.bottom - bbox.top;
  4594. return {
  4595. x: (clientX - bbox.left) * (el.width / width),
  4596. y: (clientY - bbox.top) * (el.height / height)
  4597. };
  4598. };
  4599. _proto._beginDraw = function _beginDraw() {
  4600. this._attrs.toDraw = true;
  4601. };
  4602. _proto._endDraw = function _endDraw() {
  4603. this._attrs.toDraw = false;
  4604. };
  4605. _proto.draw = function draw() {
  4606. var self = this;
  4607. function drawInner() {
  4608. self.set('animateHandler', (0, _requestAnimationFrame.requestAnimationFrame)(function () {
  4609. self.set('animateHandler', undefined);
  4610. if (self.get('toDraw')) {
  4611. drawInner();
  4612. }
  4613. }));
  4614. self.beforeDraw();
  4615. try {
  4616. var context = self._attrs.context;
  4617. self.drawInner(context); // 支付宝,微信小程序,需要调context.draw才能完成绘制, 所以这里直接判断是否有.draw方法
  4618. if (context.draw) {
  4619. context.draw();
  4620. }
  4621. } catch (ev) {
  4622. console.warn('error in draw canvas, detail as:');
  4623. console.warn(ev);
  4624. self._endDraw();
  4625. }
  4626. self._endDraw();
  4627. }
  4628. if (self.get('destroyed')) {
  4629. return;
  4630. }
  4631. if (self.get('animateHandler')) {
  4632. this._beginDraw();
  4633. } else {
  4634. drawInner();
  4635. }
  4636. };
  4637. _proto.destroy = function destroy() {
  4638. if (this.get('destroyed')) {
  4639. return;
  4640. } // 需要清理 canvas 画布内容,否则会导致 spa 应用 ios 下 canvas 白屏
  4641. // https://stackoverflow.com/questions/52532614/total-canvas-memory-use-exceeds-the-maximum-limit-safari-12
  4642. // https://github.com/antvis/F2/issues/630
  4643. var el = this.get('el');
  4644. el.width = 0;
  4645. el.height = 0;
  4646. this.clear();
  4647. this._attrs = {};
  4648. this.set('destroyed', true);
  4649. };
  4650. _proto.isDestroyed = function isDestroyed() {
  4651. return this.get('destroyed');
  4652. };
  4653. return Canvas;
  4654. }(_emit["default"]);
  4655. (0, _common.mix)(Canvas.prototype, _container["default"], {
  4656. getGroupClass: function getGroupClass() {
  4657. return _group["default"];
  4658. }
  4659. });
  4660. var _default = Canvas;
  4661. exports["default"] = _default;
  4662. }, function(modId) { var map = {"./event/emit":1658993502541,"./event/controller":1658993502567,"./canvas-element":1658993502568,"../util/common":1658993502535,"./container":1658993502569,"./group":1658993502573,"./util/requestAnimationFrame":1658993502574}; return __REQUIRE__(map[modId], modId); })
  4663. __DEFINE__(1658993502567, function(require, module, exports) {
  4664. exports.__esModule = true;
  4665. exports["default"] = void 0;
  4666. var _dom = require("../../util/dom");
  4667. var _common = require("../../util/common");
  4668. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  4669. // 计算滑动的方向
  4670. var calcDirection = function calcDirection(start, end) {
  4671. var xDistance = end.x - start.x;
  4672. var yDistance = end.y - start.y; // x 的距离大于y 说明是横向,否则就是纵向
  4673. if (Math.abs(xDistance) > Math.abs(yDistance)) {
  4674. return xDistance > 0 ? 'right' : 'left';
  4675. }
  4676. return yDistance > 0 ? 'down' : 'up';
  4677. }; // 计算2点之间的距离
  4678. var calcDistance = function calcDistance(point1, point2) {
  4679. var xDistance = Math.abs(point2.x - point1.x);
  4680. var yDistance = Math.abs(point2.y - point1.y);
  4681. return Math.sqrt(xDistance * xDistance + yDistance * yDistance);
  4682. };
  4683. var getCenter = function getCenter(point1, point2) {
  4684. var x = point1.x + (point2.x - point1.x) / 2;
  4685. var y = point1.y + (point2.y - point1.y) / 2;
  4686. return {
  4687. x: x,
  4688. y: y
  4689. };
  4690. };
  4691. var convertPoints = function convertPoints(ev, canvas) {
  4692. var touches = ev.touches; // 认为是mouse事件
  4693. if (!touches) {
  4694. var point = (0, _dom.getRelativePosition)({
  4695. x: ev.clientX,
  4696. y: ev.clientY
  4697. }, canvas);
  4698. return [point];
  4699. }
  4700. var points = [];
  4701. var len = touches.length;
  4702. for (var i = 0; i < len; i++) {
  4703. var touch = touches[i]; // x, y: 相对canvas原点的位置,clientX, clientY 相对于可视窗口的位置
  4704. var x = touch.x,
  4705. y = touch.y,
  4706. clientX = touch.clientX,
  4707. clientY = touch.clientY;
  4708. var _point = void 0; // 小程序环境会有x,y
  4709. if ((0, _common.isNumber)(x) || (0, _common.isNumber)(y)) {
  4710. _point = {
  4711. x: x,
  4712. y: y
  4713. };
  4714. } else {
  4715. // 浏览器环境再计算下canvas的相对位置
  4716. _point = (0, _dom.getRelativePosition)({
  4717. x: clientX,
  4718. y: clientY
  4719. }, canvas);
  4720. }
  4721. points.push(_point);
  4722. }
  4723. return points;
  4724. };
  4725. var PRESS_DELAY = 250;
  4726. var EventController = /*#__PURE__*/function () {
  4727. function EventController(_ref) {
  4728. var _this = this;
  4729. var canvas = _ref.canvas,
  4730. el = _ref.el;
  4731. _defineProperty(this, "_click", function (ev) {
  4732. var points = convertPoints(ev, _this.canvas);
  4733. ev.points = points;
  4734. _this.emitEvent('click', ev);
  4735. });
  4736. _defineProperty(this, "_start", function (ev) {
  4737. var points = convertPoints(ev, _this.canvas);
  4738. if (!points) {
  4739. return;
  4740. }
  4741. ev.points = points;
  4742. _this.emitEvent('touchstart', ev); // 防止上次的内容没有清理掉,重新reset下
  4743. _this.reset(); // 记录touch start 的时间
  4744. _this.startTime = Date.now(); // 记录touch start 的点
  4745. _this.startPoints = points;
  4746. if (points.length > 1) {
  4747. _this.startDistance = calcDistance(points[0], points[1]);
  4748. _this.center = getCenter(points[0], points[1]);
  4749. } else {
  4750. // 如果touchstart后停顿250ms, 则也触发press事件
  4751. _this.pressTimeout = setTimeout(function () {
  4752. // 这里固定触发press事件
  4753. var eventType = 'press';
  4754. var direction = 'none';
  4755. ev.direction = direction;
  4756. _this.emitStart(eventType, ev);
  4757. _this.emitEvent(eventType, ev);
  4758. _this.eventType = eventType;
  4759. _this.direction = direction;
  4760. }, PRESS_DELAY);
  4761. }
  4762. });
  4763. _defineProperty(this, "_move", function (ev) {
  4764. var points = convertPoints(ev, _this.canvas);
  4765. if (!points) return;
  4766. _this.clearPressTimeout();
  4767. ev.points = points;
  4768. _this.emitEvent('touchmove', ev);
  4769. var startPoints = _this.startPoints;
  4770. if (!startPoints) return; // 多指触控
  4771. if (points.length > 1) {
  4772. // touchstart的距离
  4773. var startDistance = _this.startDistance;
  4774. var currentDistance = calcDistance(points[0], points[1]);
  4775. ev.zoom = currentDistance / startDistance;
  4776. ev.center = _this.center; // 触发缩放事件
  4777. _this.emitStart('pinch', ev);
  4778. _this.emitEvent('pinch', ev);
  4779. } else {
  4780. var deltaX = points[0].x - startPoints[0].x;
  4781. var deltaY = points[0].y - startPoints[0].y;
  4782. var direction = _this.direction || calcDirection(startPoints[0], points[0]);
  4783. _this.direction = direction; // 获取press或者pan的事件类型
  4784. // press 按住滑动, pan表示平移
  4785. // 如果start后立刻move,则触发pan, 如果有停顿,则触发press
  4786. var eventType = _this.getEventType(points);
  4787. ev.direction = direction;
  4788. ev.deltaX = deltaX;
  4789. ev.deltaY = deltaY;
  4790. _this.emitStart(eventType, ev);
  4791. _this.emitEvent(eventType, ev); // 记录最后2次move的时间和坐标,为了给swipe事件用
  4792. var prevMoveTime = _this.lastMoveTime;
  4793. var now = Date.now(); // 最后2次的时间间隔一定要大于0,否则swipe没发计算
  4794. if (now - prevMoveTime > 0) {
  4795. _this.prevMoveTime = prevMoveTime;
  4796. _this.prevMovePoints = _this.lastMovePoints;
  4797. _this.lastMoveTime = now;
  4798. _this.lastMovePoints = points;
  4799. }
  4800. }
  4801. });
  4802. _defineProperty(this, "_end", function (ev) {
  4803. _this.emitEnd(ev);
  4804. _this.emitEvent('touchend', ev); // swipe事件处理, 在touchend之后触发
  4805. var lastMoveTime = _this.lastMoveTime;
  4806. var now = Date.now(); // 做这个判断是为了最后一次touchmove后到end前,还有一个停顿的过程
  4807. // 100 是拍的一个值,理论这个值会很短,一般不卡顿的话在10ms以内
  4808. if (now - lastMoveTime < 100) {
  4809. var prevMoveTime = _this.prevMoveTime || _this.startTime;
  4810. var intervalTime = lastMoveTime - prevMoveTime; // 时间间隔一定要大于0, 否则计算没意义
  4811. if (intervalTime > 0) {
  4812. var prevMovePoints = _this.prevMovePoints || _this.startPoints;
  4813. var lastMovePoints = _this.lastMovePoints; // move速率
  4814. var velocity = calcDistance(prevMovePoints[0], lastMovePoints[0]) / intervalTime; // 0.3 是参考hammerjs的设置
  4815. if (velocity > 0.3) {
  4816. ev.velocity = velocity;
  4817. ev.direction = calcDirection(prevMovePoints[0], lastMovePoints[0]);
  4818. _this.emitEvent('swipe', ev);
  4819. }
  4820. }
  4821. }
  4822. _this.reset();
  4823. var touches = ev.touches; // 当多指只释放了1指时也会触发end, 这时重新触发一次start
  4824. if (touches && touches.length > 0) {
  4825. _this._start(ev);
  4826. }
  4827. });
  4828. _defineProperty(this, "_cancel", function (ev) {
  4829. _this.emitEvent('touchcancel', ev);
  4830. _this.reset();
  4831. });
  4832. // canvasEl
  4833. this.canvas = canvas;
  4834. this.delegateEvent(el); // 用来记录当前触发的事件
  4835. this.processEvent = {};
  4836. }
  4837. var _proto = EventController.prototype;
  4838. _proto.delegateEvent = function delegateEvent(canvasEl) {
  4839. // 代理这几个事件
  4840. canvasEl.addEventListener('click', this._click);
  4841. canvasEl.addEventListener('touchstart', this._start);
  4842. canvasEl.addEventListener('touchmove', this._move);
  4843. canvasEl.addEventListener('touchend', this._end);
  4844. canvasEl.addEventListener('touchcancel', this._cancel);
  4845. };
  4846. _proto.emitEvent = function emitEvent(type, ev) {
  4847. var canvas = this.canvas;
  4848. canvas.emit(type, ev);
  4849. };
  4850. _proto.getEventType = function getEventType(points) {
  4851. var eventType = this.eventType,
  4852. canvas = this.canvas,
  4853. startTime = this.startTime,
  4854. startPoints = this.startPoints;
  4855. if (eventType) {
  4856. return eventType;
  4857. }
  4858. var type;
  4859. var panEventListeners = canvas.__events.pan; // 如果没有pan事件的监听,默认都是press
  4860. if (!panEventListeners || !panEventListeners.length) {
  4861. type = 'press';
  4862. } else {
  4863. // 如果有pan事件的处理,press则需要停顿250ms, 且移动距离小于10
  4864. var now = Date.now();
  4865. if (now - startTime > PRESS_DELAY && calcDistance(startPoints[0], points[0]) < 10) {
  4866. type = 'press';
  4867. } else {
  4868. type = 'pan';
  4869. }
  4870. }
  4871. this.eventType = type;
  4872. return type;
  4873. };
  4874. _proto.enable = function enable(eventType) {
  4875. this.processEvent[eventType] = true;
  4876. } // 是否进行中的事件
  4877. ;
  4878. _proto.isProcess = function isProcess(eventType) {
  4879. return this.processEvent[eventType];
  4880. } // 触发start事件
  4881. ;
  4882. _proto.emitStart = function emitStart(type, ev) {
  4883. if (this.isProcess(type)) {
  4884. return;
  4885. }
  4886. this.enable(type);
  4887. this.emitEvent(type + "start", ev);
  4888. } // 触发end事件
  4889. ;
  4890. _proto.emitEnd = function emitEnd(ev) {
  4891. var _this2 = this;
  4892. var processEvent = this.processEvent;
  4893. Object.keys(processEvent).forEach(function (type) {
  4894. _this2.emitEvent(type + "end", ev);
  4895. delete processEvent[type];
  4896. });
  4897. };
  4898. _proto.clearPressTimeout = function clearPressTimeout() {
  4899. if (this.pressTimeout) {
  4900. clearTimeout(this.pressTimeout);
  4901. this.pressTimeout = 0;
  4902. }
  4903. };
  4904. _proto.reset = function reset() {
  4905. this.clearPressTimeout();
  4906. this.startTime = 0;
  4907. this.startPoints = null;
  4908. this.startDistance = 0;
  4909. this.direction = null;
  4910. this.eventType = null;
  4911. this.pinch = false;
  4912. this.prevMoveTime = 0;
  4913. this.prevMovePoints = null;
  4914. this.lastMoveTime = 0;
  4915. this.lastMovePoints = null;
  4916. };
  4917. return EventController;
  4918. }();
  4919. var _default = EventController;
  4920. exports["default"] = _default;
  4921. }, function(modId) { var map = {"../../util/dom":1658993502537,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  4922. __DEFINE__(1658993502568, function(require, module, exports) {
  4923. exports.__esModule = true;
  4924. exports["default"] = void 0;
  4925. var _emit = _interopRequireDefault(require("./event/emit"));
  4926. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  4927. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4928. var CanvasElement = /*#__PURE__*/function (_EventEmit) {
  4929. _inheritsLoose(CanvasElement, _EventEmit);
  4930. function CanvasElement(ctx) {
  4931. var _this;
  4932. _this = _EventEmit.call(this) || this;
  4933. _this.context = ctx; // canvas实际的宽高 (width/height) * pixelRatio
  4934. _this.width = 0;
  4935. _this.height = 0;
  4936. _this.style = {};
  4937. _this.currentStyle = {}; // 用来标识是CanvasElement实例
  4938. _this.isCanvasElement = true;
  4939. return _this;
  4940. }
  4941. var _proto = CanvasElement.prototype;
  4942. _proto.getContext = function getContext()
  4943. /* type */
  4944. {
  4945. return this.context;
  4946. };
  4947. _proto.getBoundingClientRect = function getBoundingClientRect() {
  4948. var width = this.width;
  4949. var height = this.height; // 默认都处理成可视窗口的顶部位置
  4950. return {
  4951. top: 0,
  4952. right: width,
  4953. bottom: height,
  4954. left: 0
  4955. };
  4956. };
  4957. _proto.addEventListener = function addEventListener(type, listener) {
  4958. this.on(type, listener);
  4959. };
  4960. _proto.removeEventListener = function removeEventListener(type, listener) {
  4961. this.off(type, listener);
  4962. };
  4963. _proto.dispatchEvent = function dispatchEvent(type, e) {
  4964. this.emit(type, e);
  4965. };
  4966. return CanvasElement;
  4967. }(_emit["default"]);
  4968. function supportEventListener(canvas) {
  4969. if (!canvas) {
  4970. return false;
  4971. } // 非 HTMLCanvasElement
  4972. if (canvas.nodeType !== 1 || !canvas.nodeName || canvas.nodeName.toLowerCase() !== 'canvas') {
  4973. return false;
  4974. } // 微信小程序canvas.getContext('2d')时也是CanvasRenderingContext2D
  4975. // 也会有ctx.canvas, 而且nodeType也是1,所以还要在看下是否支持addEventListener
  4976. var support = false;
  4977. try {
  4978. canvas.addEventListener('eventTest', function () {
  4979. support = true;
  4980. });
  4981. canvas.dispatchEvent(new Event('eventTest'));
  4982. } catch (error) {
  4983. support = false;
  4984. }
  4985. return support;
  4986. }
  4987. var _default = {
  4988. create: function create(ctx) {
  4989. if (!ctx) {
  4990. return null;
  4991. }
  4992. if (supportEventListener(ctx.canvas)) {
  4993. return ctx.canvas;
  4994. }
  4995. return new CanvasElement(ctx);
  4996. }
  4997. };
  4998. exports["default"] = _default;
  4999. }, function(modId) { var map = {"./event/emit":1658993502541}; return __REQUIRE__(map[modId], modId); })
  5000. __DEFINE__(1658993502569, function(require, module, exports) {
  5001. exports.__esModule = true;
  5002. exports["default"] = void 0;
  5003. var _common = require("../util/common");
  5004. var _shape = _interopRequireDefault(require("./shape"));
  5005. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5006. var SHAPE_MAP = {};
  5007. var INDEX = '_INDEX';
  5008. function getComparer(compare) {
  5009. return function (left, right) {
  5010. var result = compare(left, right);
  5011. return result === 0 ? left[INDEX] - right[INDEX] : result;
  5012. };
  5013. }
  5014. var _default = {
  5015. getGroupClass: function getGroupClass() {},
  5016. getChildren: function getChildren() {
  5017. return this.get('children');
  5018. },
  5019. addShape: function addShape(type, cfg) {
  5020. if (cfg === void 0) {
  5021. cfg = {};
  5022. }
  5023. var canvas = this.get('canvas');
  5024. var shapeType = SHAPE_MAP[type];
  5025. if (!shapeType) {
  5026. shapeType = (0, _common.upperFirst)(type);
  5027. SHAPE_MAP[type] = shapeType;
  5028. }
  5029. cfg.canvas = canvas;
  5030. if (shapeType === 'Text' && canvas && canvas.get('fontFamily')) {
  5031. cfg.attrs.fontFamily = cfg.attrs.fontFamily || canvas.get('fontFamily');
  5032. }
  5033. var shape = new _shape["default"][shapeType](cfg);
  5034. this.add(shape);
  5035. return shape;
  5036. },
  5037. addGroup: function addGroup(cfg) {
  5038. var canvas = this.get('canvas');
  5039. var groupClass = this.getGroupClass();
  5040. cfg = (0, _common.mix)({}, cfg);
  5041. cfg.canvas = canvas;
  5042. cfg.parent = this;
  5043. var rst = new groupClass(cfg);
  5044. this.add(rst);
  5045. return rst;
  5046. },
  5047. contain: function contain(item) {
  5048. var children = this.get('children');
  5049. return children.indexOf(item) > -1;
  5050. },
  5051. sort: function sort() {
  5052. var children = this.get('children');
  5053. for (var i = 0, len = children.length; i < len; i++) {
  5054. var child = children[i];
  5055. child[INDEX] = i;
  5056. }
  5057. children.sort(getComparer(function (obj1, obj2) {
  5058. return obj1.get('zIndex') - obj2.get('zIndex');
  5059. }));
  5060. return this;
  5061. },
  5062. drawInner: function drawInner(context) {
  5063. var children = this.get('children');
  5064. for (var i = 0, len = children.length; i < len; i++) {
  5065. var child = children[i];
  5066. child.draw(context);
  5067. }
  5068. return this;
  5069. },
  5070. clear: function clear() {
  5071. var children = this.get('children');
  5072. while (children.length !== 0) {
  5073. children[children.length - 1].remove(true);
  5074. }
  5075. return this;
  5076. },
  5077. add: function add(items) {
  5078. var self = this;
  5079. var children = self.get('children');
  5080. if (!(0, _common.isArray)(items)) {
  5081. items = [items];
  5082. }
  5083. for (var i = 0, len = items.length; i < len; i++) {
  5084. var item = items[i];
  5085. var parent = item.get('parent');
  5086. if (parent) {
  5087. var descendants = parent.get('children');
  5088. _common.Array.remove(descendants, item);
  5089. }
  5090. self._setEvn(item);
  5091. children.push(item);
  5092. }
  5093. return self;
  5094. },
  5095. _setEvn: function _setEvn(item) {
  5096. var self = this;
  5097. item._attrs.parent = self;
  5098. item._attrs.context = self._attrs.context;
  5099. item._attrs.canvas = self._attrs.canvas;
  5100. var clip = item._attrs.attrs.clip;
  5101. if (clip) {
  5102. clip.set('parent', self);
  5103. clip.set('context', self.get('context'));
  5104. }
  5105. if (item._attrs.isGroup) {
  5106. var children = item._attrs.children;
  5107. for (var i = 0, len = children.length; i < len; i++) {
  5108. item._setEvn(children[i]);
  5109. }
  5110. }
  5111. }
  5112. };
  5113. exports["default"] = _default;
  5114. }, function(modId) { var map = {"../util/common":1658993502535,"./shape":1658993502570}; return __REQUIRE__(map[modId], modId); })
  5115. __DEFINE__(1658993502570, function(require, module, exports) {
  5116. exports.__esModule = true;
  5117. exports["default"] = void 0;
  5118. var _common = require("../util/common");
  5119. var _element = _interopRequireDefault(require("./element"));
  5120. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5121. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5122. var Shape = /*#__PURE__*/function (_Element) {
  5123. _inheritsLoose(Shape, _Element);
  5124. function Shape() {
  5125. return _Element.apply(this, arguments) || this;
  5126. }
  5127. var _proto = Shape.prototype;
  5128. _proto._initProperties = function _initProperties() {
  5129. this._attrs = {
  5130. zIndex: 0,
  5131. visible: true,
  5132. destroyed: false,
  5133. isShape: true,
  5134. attrs: {}
  5135. };
  5136. };
  5137. _proto.getType = function getType() {
  5138. return this._attrs.type;
  5139. };
  5140. _proto.drawInner = function drawInner(context) {
  5141. var self = this;
  5142. var attrs = self.get('attrs');
  5143. self.createPath(context);
  5144. var originOpacity = context.globalAlpha;
  5145. if (self.hasFill()) {
  5146. var fillOpacity = attrs.fillOpacity;
  5147. if (!(0, _common.isNil)(fillOpacity) && fillOpacity !== 1) {
  5148. context.globalAlpha = fillOpacity;
  5149. context.fill();
  5150. context.globalAlpha = originOpacity;
  5151. } else {
  5152. context.fill();
  5153. }
  5154. }
  5155. if (self.hasStroke()) {
  5156. var lineWidth = attrs.lineWidth;
  5157. if (lineWidth > 0) {
  5158. var strokeOpacity = attrs.strokeOpacity;
  5159. if (!(0, _common.isNil)(strokeOpacity) && strokeOpacity !== 1) {
  5160. context.globalAlpha = strokeOpacity;
  5161. }
  5162. context.stroke();
  5163. }
  5164. }
  5165. };
  5166. _proto.getBBox = function getBBox() {
  5167. var bbox = this._attrs.bbox;
  5168. if (!bbox) {
  5169. bbox = this.calculateBox();
  5170. if (bbox) {
  5171. bbox.x = bbox.minX;
  5172. bbox.y = bbox.minY;
  5173. bbox.width = bbox.maxX - bbox.minX;
  5174. bbox.height = bbox.maxY - bbox.minY;
  5175. }
  5176. this._attrs.bbox = bbox;
  5177. }
  5178. return bbox;
  5179. };
  5180. _proto.calculateBox = function calculateBox() {
  5181. return null;
  5182. };
  5183. _proto.createPath = function createPath() {};
  5184. return Shape;
  5185. }(_element["default"]);
  5186. var _default = Shape;
  5187. exports["default"] = _default;
  5188. }, function(modId) { var map = {"../util/common":1658993502535,"./element":1658993502571}; return __REQUIRE__(map[modId], modId); })
  5189. __DEFINE__(1658993502571, function(require, module, exports) {
  5190. exports.__esModule = true;
  5191. exports["default"] = void 0;
  5192. var _common = require("../util/common");
  5193. var _matrix = _interopRequireDefault(require("./util/matrix"));
  5194. var _vector = _interopRequireDefault(require("./util/vector2"));
  5195. var _styleParse = require("./util/style-parse");
  5196. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5197. var ALIAS_ATTRS_MAP = {
  5198. stroke: 'strokeStyle',
  5199. fill: 'fillStyle',
  5200. opacity: 'globalAlpha'
  5201. };
  5202. var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'shadow' // 兼容支付宝小程序
  5203. ];
  5204. var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];
  5205. var Element = /*#__PURE__*/function () {
  5206. var _proto = Element.prototype;
  5207. _proto._initProperties = function _initProperties() {
  5208. this._attrs = {
  5209. zIndex: 0,
  5210. visible: true,
  5211. destroyed: false
  5212. };
  5213. };
  5214. function Element(cfg) {
  5215. this._initProperties();
  5216. (0, _common.mix)(this._attrs, cfg);
  5217. var attrs = this._attrs.attrs;
  5218. if (attrs) {
  5219. this.initAttrs(attrs);
  5220. }
  5221. this.initTransform();
  5222. }
  5223. _proto.get = function get(name) {
  5224. return this._attrs[name];
  5225. };
  5226. _proto.set = function set(name, value) {
  5227. this._attrs[name] = value;
  5228. };
  5229. _proto.isGroup = function isGroup() {
  5230. return this.get('isGroup');
  5231. };
  5232. _proto.isShape = function isShape() {
  5233. return this.get('isShape');
  5234. };
  5235. _proto.initAttrs = function initAttrs(attrs) {
  5236. this.attr((0, _common.mix)(this.getDefaultAttrs(), attrs));
  5237. };
  5238. _proto.getDefaultAttrs = function getDefaultAttrs() {
  5239. return {};
  5240. };
  5241. _proto._setAttr = function _setAttr(name, value) {
  5242. var attrs = this._attrs.attrs;
  5243. if (name === 'clip') {
  5244. value = this._setAttrClip(value);
  5245. } else {
  5246. var alias = ALIAS_ATTRS_MAP[name];
  5247. if (alias) {
  5248. attrs[alias] = value;
  5249. }
  5250. }
  5251. attrs[name] = value;
  5252. };
  5253. _proto._getAttr = function _getAttr(name) {
  5254. return this._attrs.attrs[name];
  5255. } // _afterAttrsSet() {}
  5256. ;
  5257. _proto._setAttrClip = function _setAttrClip(clip) {
  5258. if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
  5259. if (clip.get('canvas') === null) {
  5260. clip = Object.assign({}, clip);
  5261. }
  5262. clip.set('parent', this.get('parent'));
  5263. clip.set('context', this.get('context'));
  5264. return clip;
  5265. }
  5266. return null;
  5267. };
  5268. _proto.attr = function attr(name, value) {
  5269. var self = this;
  5270. if (self.get('destroyed')) return null;
  5271. var argumentsLen = arguments.length;
  5272. if (argumentsLen === 0) {
  5273. return self._attrs.attrs;
  5274. }
  5275. if ((0, _common.isObject)(name)) {
  5276. this._attrs.bbox = null;
  5277. for (var k in name) {
  5278. self._setAttr(k, name[k]);
  5279. }
  5280. if (self._afterAttrsSet) {
  5281. self._afterAttrsSet();
  5282. }
  5283. return self;
  5284. }
  5285. if (argumentsLen === 2) {
  5286. this._attrs.bbox = null;
  5287. self._setAttr(name, value);
  5288. if (self._afterAttrsSet) {
  5289. self._afterAttrsSet();
  5290. }
  5291. return self;
  5292. }
  5293. return self._getAttr(name);
  5294. };
  5295. _proto.getParent = function getParent() {
  5296. return this.get('parent');
  5297. };
  5298. _proto.draw = function draw(context) {
  5299. if (this.get('destroyed')) {
  5300. return;
  5301. }
  5302. if (this.get('visible')) {
  5303. this.setContext(context);
  5304. this.drawInner(context);
  5305. this.restoreContext(context);
  5306. }
  5307. };
  5308. _proto.setContext = function setContext(context) {
  5309. var clip = this._attrs.attrs.clip;
  5310. context.save();
  5311. if (clip) {
  5312. clip.resetTransform(context);
  5313. clip.createPath(context);
  5314. context.clip();
  5315. }
  5316. this.resetContext(context);
  5317. this.resetTransform(context);
  5318. };
  5319. _proto.restoreContext = function restoreContext(context) {
  5320. context.restore();
  5321. };
  5322. _proto.resetContext = function resetContext(context) {
  5323. var elAttrs = this._attrs.attrs;
  5324. if (!this._attrs.isGroup) {
  5325. for (var k in elAttrs) {
  5326. if (SHAPE_ATTRS.indexOf(k) > -1) {
  5327. var v = elAttrs[k];
  5328. if (k === 'fillStyle' || k === 'strokeStyle') {
  5329. v = (0, _styleParse.parseStyle)(v, this, context);
  5330. }
  5331. if (k === 'lineDash' && context.setLineDash && (0, _common.isArray)(v)) {
  5332. context.setLineDash(v);
  5333. } else {
  5334. context[k] = v;
  5335. }
  5336. }
  5337. }
  5338. }
  5339. };
  5340. _proto.hasFill = function hasFill() {
  5341. return this.get('canFill') && this._attrs.attrs.fillStyle;
  5342. };
  5343. _proto.hasStroke = function hasStroke() {
  5344. return this.get('canStroke') && this._attrs.attrs.strokeStyle;
  5345. };
  5346. _proto.drawInner = function drawInner()
  5347. /* context */
  5348. {};
  5349. _proto.show = function show() {
  5350. this.set('visible', true);
  5351. return this;
  5352. };
  5353. _proto.hide = function hide() {
  5354. this.set('visible', false);
  5355. return this;
  5356. };
  5357. _proto.isVisible = function isVisible() {
  5358. return this.get('visible');
  5359. };
  5360. _proto._removeFromParent = function _removeFromParent() {
  5361. var parent = this.get('parent');
  5362. if (parent) {
  5363. var children = parent.get('children');
  5364. _common.Array.remove(children, this);
  5365. }
  5366. return this;
  5367. };
  5368. _proto.remove = function remove(destroy) {
  5369. if (destroy) {
  5370. this.destroy();
  5371. } else {
  5372. this._removeFromParent();
  5373. }
  5374. };
  5375. _proto.destroy = function destroy() {
  5376. var destroyed = this.get('destroyed');
  5377. if (destroyed) {
  5378. return null;
  5379. }
  5380. this._removeFromParent();
  5381. this._attrs = {};
  5382. this.set('destroyed', true);
  5383. };
  5384. _proto.getBBox = function getBBox() {
  5385. return {
  5386. minX: 0,
  5387. maxX: 0,
  5388. minY: 0,
  5389. maxY: 0,
  5390. width: 0,
  5391. height: 0
  5392. };
  5393. };
  5394. _proto.initTransform = function initTransform() {
  5395. var attrs = this._attrs.attrs || {};
  5396. if (!attrs.matrix) {
  5397. attrs.matrix = [1, 0, 0, 1, 0, 0];
  5398. }
  5399. this._attrs.attrs = attrs;
  5400. };
  5401. _proto.getMatrix = function getMatrix() {
  5402. return this._attrs.attrs.matrix;
  5403. };
  5404. _proto.setMatrix = function setMatrix(m) {
  5405. this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
  5406. };
  5407. _proto.transform = function transform(actions) {
  5408. var matrix = this._attrs.attrs.matrix;
  5409. this._attrs.attrs.matrix = _matrix["default"].transform(matrix, actions);
  5410. return this;
  5411. };
  5412. _proto.setTransform = function setTransform(actions) {
  5413. this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
  5414. return this.transform(actions);
  5415. };
  5416. _proto.translate = function translate(x, y) {
  5417. var matrix = this._attrs.attrs.matrix;
  5418. _matrix["default"].translate(matrix, matrix, [x, y]);
  5419. };
  5420. _proto.rotate = function rotate(rad) {
  5421. var matrix = this._attrs.attrs.matrix;
  5422. _matrix["default"].rotate(matrix, matrix, rad);
  5423. };
  5424. _proto.scale = function scale(sx, sy) {
  5425. var matrix = this._attrs.attrs.matrix;
  5426. _matrix["default"].scale(matrix, matrix, [sx, sy]);
  5427. };
  5428. _proto.moveTo = function moveTo(x, y) {
  5429. var cx = this._attrs.x || 0;
  5430. var cy = this._attrs.y || 0;
  5431. this.translate(x - cx, y - cy);
  5432. this.set('x', x);
  5433. this.set('y', y);
  5434. };
  5435. _proto.apply = function apply(v) {
  5436. var m = this._attrs.attrs.matrix;
  5437. _vector["default"].transformMat2d(v, v, m);
  5438. return this;
  5439. };
  5440. _proto.resetTransform = function resetTransform(context) {
  5441. var mo = this._attrs.attrs.matrix;
  5442. if (_matrix["default"].isChanged(mo)) {
  5443. context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
  5444. }
  5445. };
  5446. _proto.isDestroyed = function isDestroyed() {
  5447. return this.get('destroyed');
  5448. };
  5449. return Element;
  5450. }();
  5451. var _default = Element;
  5452. exports["default"] = _default;
  5453. }, function(modId) { var map = {"../util/common":1658993502535,"./util/matrix":1658993502545,"./util/vector2":1658993502546,"./util/style-parse":1658993502572}; return __REQUIRE__(map[modId], modId); })
  5454. __DEFINE__(1658993502572, function(require, module, exports) {
  5455. exports.__esModule = true;
  5456. exports.parseStyle = parseStyle;
  5457. exports["default"] = void 0;
  5458. var _common = require("../../util/common");
  5459. function _mod(n, m) {
  5460. return (n % m + m) % m;
  5461. }
  5462. function _addStop(steps, gradient) {
  5463. (0, _common.each)(steps, function (item) {
  5464. item = item.split(':');
  5465. gradient.addColorStop(Number(item[0]), item[1]);
  5466. });
  5467. } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'
  5468. function _parseLineGradient(color, shape, context) {
  5469. var arr = color.split(' ');
  5470. var angle = arr[0].slice(2, arr[0].length - 1);
  5471. angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
  5472. var steps = arr.slice(1);
  5473. var _shape$getBBox = shape.getBBox(),
  5474. minX = _shape$getBBox.minX,
  5475. minY = _shape$getBBox.minY,
  5476. maxX = _shape$getBBox.maxX,
  5477. maxY = _shape$getBBox.maxY;
  5478. var start;
  5479. var end;
  5480. if (angle >= 0 && angle < 0.5 * Math.PI) {
  5481. start = {
  5482. x: minX,
  5483. y: minY
  5484. };
  5485. end = {
  5486. x: maxX,
  5487. y: maxY
  5488. };
  5489. } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
  5490. start = {
  5491. x: maxX,
  5492. y: minY
  5493. };
  5494. end = {
  5495. x: minX,
  5496. y: maxY
  5497. };
  5498. } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
  5499. start = {
  5500. x: maxX,
  5501. y: maxY
  5502. };
  5503. end = {
  5504. x: minX,
  5505. y: minY
  5506. };
  5507. } else {
  5508. start = {
  5509. x: minX,
  5510. y: maxY
  5511. };
  5512. end = {
  5513. x: maxX,
  5514. y: minY
  5515. };
  5516. }
  5517. var tanTheta = Math.tan(angle);
  5518. var tanTheta2 = tanTheta * tanTheta;
  5519. var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
  5520. var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
  5521. var gradient = context.createLinearGradient(start.x, start.y, x, y);
  5522. _addStop(steps, gradient);
  5523. return gradient;
  5524. } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'
  5525. function _parseRadialGradient(color, shape, context) {
  5526. var arr = color.split(' ');
  5527. var circleCfg = arr[0].slice(2, arr[0].length - 1);
  5528. circleCfg = circleCfg.split(',');
  5529. var fx = parseFloat(circleCfg[0]);
  5530. var fy = parseFloat(circleCfg[1]);
  5531. var fr = parseFloat(circleCfg[2]);
  5532. var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color
  5533. if (fr === 0) {
  5534. var _color = steps[steps.length - 1];
  5535. return _color.split(':')[1];
  5536. }
  5537. var _shape$getBBox2 = shape.getBBox(),
  5538. width = _shape$getBBox2.width,
  5539. height = _shape$getBBox2.height,
  5540. minX = _shape$getBBox2.minX,
  5541. minY = _shape$getBBox2.minY;
  5542. var r = Math.sqrt(width * width + height * height) / 2;
  5543. var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);
  5544. _addStop(steps, gradient);
  5545. return gradient;
  5546. }
  5547. function parseStyle(color, shape, context) {
  5548. if (color[1] === '(') {
  5549. try {
  5550. var firstCode = color[0];
  5551. if (firstCode === 'l') {
  5552. return _parseLineGradient(color, shape, context);
  5553. } else if (firstCode === 'r') {
  5554. return _parseRadialGradient(color, shape, context);
  5555. }
  5556. } catch (ev) {
  5557. console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
  5558. console.error(ev);
  5559. }
  5560. }
  5561. return color;
  5562. }
  5563. var _default = {
  5564. parseStyle: parseStyle
  5565. };
  5566. exports["default"] = _default;
  5567. }, function(modId) { var map = {"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  5568. __DEFINE__(1658993502573, function(require, module, exports) {
  5569. exports.__esModule = true;
  5570. exports["default"] = void 0;
  5571. var _common = require("../util/common");
  5572. var _element = _interopRequireDefault(require("./element"));
  5573. var _container = _interopRequireDefault(require("./container"));
  5574. var _vector = _interopRequireDefault(require("./util/vector2"));
  5575. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5576. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5577. var Group = /*#__PURE__*/function (_Element) {
  5578. _inheritsLoose(Group, _Element);
  5579. function Group() {
  5580. return _Element.apply(this, arguments) || this;
  5581. }
  5582. var _proto = Group.prototype;
  5583. _proto._initProperties = function _initProperties() {
  5584. this._attrs = {
  5585. zIndex: 0,
  5586. visible: true,
  5587. destroyed: false,
  5588. isGroup: true,
  5589. children: []
  5590. };
  5591. };
  5592. _proto.getBBox = function getBBox() {
  5593. var self = this;
  5594. var minX = Infinity;
  5595. var maxX = -Infinity;
  5596. var minY = Infinity;
  5597. var maxY = -Infinity;
  5598. var children = self.get('children');
  5599. for (var i = 0, length = children.length; i < length; i++) {
  5600. var child = children[i];
  5601. if (child.get('visible')) {
  5602. var box = child.getBBox();
  5603. if (!box) {
  5604. continue;
  5605. }
  5606. var leftTop = [box.minX, box.minY];
  5607. var leftBottom = [box.minX, box.maxY];
  5608. var rightTop = [box.maxX, box.minY];
  5609. var rightBottom = [box.maxX, box.maxY];
  5610. var matrix = child.attr('matrix');
  5611. _vector["default"].transformMat2d(leftTop, leftTop, matrix);
  5612. _vector["default"].transformMat2d(leftBottom, leftBottom, matrix);
  5613. _vector["default"].transformMat2d(rightTop, rightTop, matrix);
  5614. _vector["default"].transformMat2d(rightBottom, rightBottom, matrix);
  5615. minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
  5616. maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
  5617. minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
  5618. maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
  5619. }
  5620. }
  5621. return {
  5622. minX: minX,
  5623. minY: minY,
  5624. maxX: maxX,
  5625. maxY: maxY,
  5626. x: minX,
  5627. y: minY,
  5628. width: maxX - minX,
  5629. height: maxY - minY
  5630. };
  5631. };
  5632. _proto.destroy = function destroy() {
  5633. if (this.get('destroyed')) {
  5634. return;
  5635. }
  5636. this.clear();
  5637. _Element.prototype.destroy.call(this);
  5638. };
  5639. return Group;
  5640. }(_element["default"]);
  5641. (0, _common.mix)(Group.prototype, _container["default"], {
  5642. getGroupClass: function getGroupClass() {
  5643. return Group;
  5644. }
  5645. });
  5646. var _default = Group;
  5647. exports["default"] = _default;
  5648. }, function(modId) { var map = {"../util/common":1658993502535,"./element":1658993502571,"./container":1658993502569,"./util/vector2":1658993502546}; return __REQUIRE__(map[modId], modId); })
  5649. __DEFINE__(1658993502574, function(require, module, exports) {
  5650. exports.__esModule = true;
  5651. exports.requestAnimationFrame = void 0;
  5652. var requestAnimationFrame = typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
  5653. return setTimeout(fn, 16);
  5654. };
  5655. exports.requestAnimationFrame = requestAnimationFrame;
  5656. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  5657. __DEFINE__(1658993502575, function(require, module, exports) {
  5658. exports.__esModule = true;
  5659. exports["default"] = void 0;
  5660. var _common = require("../../util/common");
  5661. var _shape = _interopRequireDefault(require("../shape"));
  5662. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5663. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5664. // 为了处理radius 大于 width 或 height 的场景
  5665. function parseRadius(radius, width, height) {
  5666. radius = (0, _common.parsePadding)(radius); // 都为0
  5667. if (!radius[0] && !radius[1] && !radius[2] && !radius[3]) {
  5668. return radius;
  5669. }
  5670. var minWidth = Math.max(radius[0] + radius[1], radius[2] + radius[3]);
  5671. var minHeight = Math.max(radius[0] + radius[3], radius[1] + radius[2]);
  5672. var scale = Math.min(width / minWidth, height / minHeight);
  5673. if (scale < 1) {
  5674. return radius.map(function (r) {
  5675. return r * scale;
  5676. });
  5677. }
  5678. return radius;
  5679. }
  5680. var Rect = /*#__PURE__*/function (_Shape) {
  5681. _inheritsLoose(Rect, _Shape);
  5682. function Rect() {
  5683. return _Shape.apply(this, arguments) || this;
  5684. }
  5685. var _proto = Rect.prototype;
  5686. _proto._initProperties = function _initProperties() {
  5687. _Shape.prototype._initProperties.call(this);
  5688. this._attrs.canFill = true;
  5689. this._attrs.canStroke = true;
  5690. this._attrs.type = 'rect';
  5691. };
  5692. _proto.getDefaultAttrs = function getDefaultAttrs() {
  5693. return {
  5694. x: 0,
  5695. y: 0,
  5696. width: 0,
  5697. height: 0,
  5698. radius: 0,
  5699. lineWidth: 0
  5700. };
  5701. };
  5702. _proto.createPath = function createPath(context) {
  5703. var self = this;
  5704. var attrs = self.get('attrs');
  5705. var x = attrs.x,
  5706. y = attrs.y,
  5707. width = attrs.width,
  5708. height = attrs.height,
  5709. radius = attrs.radius;
  5710. context.beginPath();
  5711. if (!radius || !(width * height)) {
  5712. context.rect(x, y, width, height);
  5713. } else {
  5714. radius = parseRadius(radius, width, height);
  5715. context.moveTo(x + radius[0], y);
  5716. context.lineTo(x + width - radius[1], y);
  5717. context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
  5718. context.lineTo(x + width, y + height - radius[2]);
  5719. context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
  5720. context.lineTo(x + radius[3], y + height);
  5721. context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
  5722. context.lineTo(x, y + radius[0]);
  5723. context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
  5724. context.closePath();
  5725. }
  5726. };
  5727. _proto.calculateBox = function calculateBox() {
  5728. var attrs = this.get('attrs');
  5729. var x = attrs.x,
  5730. y = attrs.y,
  5731. width = attrs.width,
  5732. height = attrs.height;
  5733. return {
  5734. minX: x,
  5735. minY: y,
  5736. maxX: x + width,
  5737. maxY: y + height
  5738. };
  5739. };
  5740. return Rect;
  5741. }(_shape["default"]);
  5742. _shape["default"].Rect = Rect;
  5743. var _default = Rect;
  5744. exports["default"] = _default;
  5745. }, function(modId) { var map = {"../../util/common":1658993502535,"../shape":1658993502570}; return __REQUIRE__(map[modId], modId); })
  5746. __DEFINE__(1658993502576, function(require, module, exports) {
  5747. exports.__esModule = true;
  5748. exports["default"] = void 0;
  5749. var _common = require("../../util/common");
  5750. var _shape = _interopRequireDefault(require("../shape"));
  5751. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5752. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5753. var ImageShape = /*#__PURE__*/function (_Shape) {
  5754. _inheritsLoose(ImageShape, _Shape);
  5755. function ImageShape() {
  5756. return _Shape.apply(this, arguments) || this;
  5757. }
  5758. var _proto = ImageShape.prototype;
  5759. _proto._initProperties = function _initProperties() {
  5760. _Shape.prototype._initProperties.call(this);
  5761. this._attrs.canFill = false;
  5762. this._attrs.canStroke = false;
  5763. this._attrs.loading = false;
  5764. this._attrs.image = null;
  5765. this._attrs.type = 'image';
  5766. };
  5767. _proto.getDefaultAttrs = function getDefaultAttrs() {
  5768. return {
  5769. x: 0,
  5770. y: 0,
  5771. width: 0,
  5772. height: 0
  5773. };
  5774. };
  5775. _proto.createPath = function createPath(context) {
  5776. var _this = this;
  5777. var attrs = this.get('attrs');
  5778. var src = attrs.src;
  5779. if (this.get('loading')) {
  5780. return;
  5781. }
  5782. var image = this.get('image');
  5783. if (image) {
  5784. this.drawImage(context, image);
  5785. } else {
  5786. if (src && Image) {
  5787. this.set('loading', true);
  5788. var _image = new Image();
  5789. _image.src = src; // 设置跨域
  5790. _image.crossOrigin = 'Anonymous';
  5791. _image.onload = function () {
  5792. _this.set('loading', false);
  5793. _this.set('image', _image);
  5794. _this.drawImage(context, _image);
  5795. };
  5796. }
  5797. }
  5798. };
  5799. _proto.drawImage = function drawImage(context, image) {
  5800. var attrs = this.get('attrs');
  5801. var x = attrs.x,
  5802. y = attrs.y,
  5803. width = attrs.width,
  5804. height = attrs.height,
  5805. sx = attrs.sx,
  5806. sy = attrs.sy,
  5807. swidth = attrs.swidth,
  5808. sheight = attrs.sheight;
  5809. if (!(0, _common.isNil)(sx) && !(0, _common.isNil)(sy) && !(0, _common.isNil)(swidth) && !(0, _common.isNil)(sheight)) {
  5810. context.drawImage(image, sx, sy, swidth, sheight, x, y, width, height);
  5811. } else {
  5812. context.drawImage(image, x, y, width, height);
  5813. }
  5814. };
  5815. _proto.calculateBox = function calculateBox() {
  5816. var attrs = this.get('attrs');
  5817. var x = attrs.x,
  5818. y = attrs.y,
  5819. width = attrs.width,
  5820. height = attrs.height; // 和rect一样
  5821. return {
  5822. minX: x,
  5823. minY: y,
  5824. maxX: x + width,
  5825. maxY: y + height
  5826. };
  5827. };
  5828. return ImageShape;
  5829. }(_shape["default"]);
  5830. _shape["default"].Image = ImageShape;
  5831. var _default = ImageShape;
  5832. exports["default"] = _default;
  5833. }, function(modId) { var map = {"../../util/common":1658993502535,"../shape":1658993502570}; return __REQUIRE__(map[modId], modId); })
  5834. __DEFINE__(1658993502577, function(require, module, exports) {
  5835. exports.__esModule = true;
  5836. exports["default"] = void 0;
  5837. var _shape = _interopRequireDefault(require("../shape"));
  5838. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5839. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5840. var Circle = /*#__PURE__*/function (_Shape) {
  5841. _inheritsLoose(Circle, _Shape);
  5842. function Circle() {
  5843. return _Shape.apply(this, arguments) || this;
  5844. }
  5845. var _proto = Circle.prototype;
  5846. _proto._initProperties = function _initProperties() {
  5847. _Shape.prototype._initProperties.call(this);
  5848. this._attrs.canFill = true;
  5849. this._attrs.canStroke = true;
  5850. this._attrs.type = 'circle';
  5851. };
  5852. _proto.getDefaultAttrs = function getDefaultAttrs() {
  5853. return {
  5854. x: 0,
  5855. y: 0,
  5856. r: 0,
  5857. lineWidth: 0
  5858. };
  5859. };
  5860. _proto.createPath = function createPath(context) {
  5861. var attrs = this.get('attrs');
  5862. var x = attrs.x,
  5863. y = attrs.y,
  5864. r = attrs.r;
  5865. context.beginPath();
  5866. context.arc(x, y, r, 0, Math.PI * 2, false);
  5867. context.closePath();
  5868. };
  5869. _proto.calculateBox = function calculateBox() {
  5870. var attrs = this.get('attrs');
  5871. var x = attrs.x,
  5872. y = attrs.y,
  5873. r = attrs.r;
  5874. return {
  5875. minX: x - r,
  5876. maxX: x + r,
  5877. minY: y - r,
  5878. maxY: y + r
  5879. };
  5880. };
  5881. return Circle;
  5882. }(_shape["default"]);
  5883. _shape["default"].Circle = Circle;
  5884. var _default = Circle;
  5885. exports["default"] = _default;
  5886. }, function(modId) { var map = {"../shape":1658993502570}; return __REQUIRE__(map[modId], modId); })
  5887. __DEFINE__(1658993502578, function(require, module, exports) {
  5888. exports.__esModule = true;
  5889. exports["default"] = void 0;
  5890. var _shape = _interopRequireDefault(require("../shape"));
  5891. var _bbox = require("../util/bbox");
  5892. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5893. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5894. var Line = /*#__PURE__*/function (_Shape) {
  5895. _inheritsLoose(Line, _Shape);
  5896. function Line() {
  5897. return _Shape.apply(this, arguments) || this;
  5898. }
  5899. var _proto = Line.prototype;
  5900. _proto._initProperties = function _initProperties() {
  5901. _Shape.prototype._initProperties.call(this);
  5902. this._attrs.canStroke = true;
  5903. this._attrs.type = 'line';
  5904. };
  5905. _proto.getDefaultAttrs = function getDefaultAttrs() {
  5906. return {
  5907. x1: 0,
  5908. y1: 0,
  5909. x2: 0,
  5910. y2: 0,
  5911. lineWidth: 1
  5912. };
  5913. };
  5914. _proto.createPath = function createPath(context) {
  5915. var attrs = this.get('attrs');
  5916. var x1 = attrs.x1,
  5917. y1 = attrs.y1,
  5918. x2 = attrs.x2,
  5919. y2 = attrs.y2;
  5920. context.beginPath();
  5921. context.moveTo(x1, y1);
  5922. context.lineTo(x2, y2);
  5923. };
  5924. _proto.calculateBox = function calculateBox() {
  5925. var attrs = this.get('attrs');
  5926. var x1 = attrs.x1,
  5927. y1 = attrs.y1,
  5928. x2 = attrs.x2,
  5929. y2 = attrs.y2,
  5930. lineWidth = attrs.lineWidth;
  5931. return (0, _bbox.getBBoxFromLine)(x1, y1, x2, y2, lineWidth);
  5932. };
  5933. return Line;
  5934. }(_shape["default"]);
  5935. _shape["default"].Line = Line;
  5936. var _default = Line;
  5937. exports["default"] = _default;
  5938. }, function(modId) { var map = {"../shape":1658993502570,"../util/bbox":1658993502579}; return __REQUIRE__(map[modId], modId); })
  5939. __DEFINE__(1658993502579, function(require, module, exports) {
  5940. exports.__esModule = true;
  5941. exports.getBBoxFromPoints = getBBoxFromPoints;
  5942. exports.getBBoxFromLine = getBBoxFromLine;
  5943. exports.getBBoxFromArc = getBBoxFromArc;
  5944. exports.getBBoxFromBezierGroup = getBBoxFromBezierGroup;
  5945. var _vector = _interopRequireDefault(require("./vector2"));
  5946. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5947. var start = _vector["default"].create();
  5948. var end = _vector["default"].create();
  5949. var extremity = _vector["default"].create();
  5950. function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
  5951. var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
  5952. var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
  5953. return {
  5954. x: x,
  5955. y: y
  5956. };
  5957. } // cubic helper formula at T distance
  5958. function CubicN(T, a, b, c, d) {
  5959. var t2 = T * T;
  5960. var t3 = t2 * T;
  5961. return a + (-a * 3 + T * (3 * a - a * T)) * T + (3 * b + T * (-6 * b + b * 3 * T)) * T + (c * 3 - c * 3 * T) * t2 + d * t3;
  5962. }
  5963. function cubicBezierBounds(c) {
  5964. var minX = Infinity;
  5965. var maxX = -Infinity;
  5966. var minY = Infinity;
  5967. var maxY = -Infinity;
  5968. var s = {
  5969. x: c[0],
  5970. y: c[1]
  5971. };
  5972. var c1 = {
  5973. x: c[2],
  5974. y: c[3]
  5975. };
  5976. var c2 = {
  5977. x: c[4],
  5978. y: c[5]
  5979. };
  5980. var e = {
  5981. x: c[6],
  5982. y: c[7]
  5983. };
  5984. for (var t = 0; t < 100; t++) {
  5985. var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);
  5986. if (pt.x < minX) {
  5987. minX = pt.x;
  5988. }
  5989. if (pt.x > maxX) {
  5990. maxX = pt.x;
  5991. }
  5992. if (pt.y < minY) {
  5993. minY = pt.y;
  5994. }
  5995. if (pt.y > maxY) {
  5996. maxY = pt.y;
  5997. }
  5998. }
  5999. return {
  6000. minX: minX,
  6001. minY: minY,
  6002. maxX: maxX,
  6003. maxY: maxY
  6004. };
  6005. }
  6006. function getBBoxFromPoints(points, lineWidth) {
  6007. if (points.length === 0) {
  6008. return;
  6009. }
  6010. var p = points[0];
  6011. var left = p.x;
  6012. var right = p.x;
  6013. var top = p.y;
  6014. var bottom = p.y;
  6015. var len = points.length;
  6016. for (var i = 1; i < len; i++) {
  6017. p = points[i];
  6018. left = Math.min(left, p.x);
  6019. right = Math.max(right, p.x);
  6020. top = Math.min(top, p.y);
  6021. bottom = Math.max(bottom, p.y);
  6022. }
  6023. lineWidth = lineWidth / 2 || 0;
  6024. return {
  6025. minX: left - lineWidth,
  6026. minY: top - lineWidth,
  6027. maxX: right + lineWidth,
  6028. maxY: bottom + lineWidth
  6029. };
  6030. }
  6031. function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
  6032. lineWidth = lineWidth / 2 || 0;
  6033. return {
  6034. minX: Math.min(x0, x1) - lineWidth,
  6035. minY: Math.min(y0, y1) - lineWidth,
  6036. maxX: Math.max(x0, x1) + lineWidth,
  6037. maxY: Math.max(y0, y1) + lineWidth
  6038. };
  6039. }
  6040. function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
  6041. var diff = Math.abs(startAngle - endAngle);
  6042. if (diff % (Math.PI * 2) < 1e-4 && diff > 1e-4) {
  6043. // Is a circle
  6044. return {
  6045. minX: x - r,
  6046. minY: y - r,
  6047. maxX: x + r,
  6048. maxY: y + r
  6049. };
  6050. }
  6051. start[0] = Math.cos(startAngle) * r + x;
  6052. start[1] = Math.sin(startAngle) * r + y;
  6053. end[0] = Math.cos(endAngle) * r + x;
  6054. end[1] = Math.sin(endAngle) * r + y;
  6055. var min = [0, 0];
  6056. var max = [0, 0];
  6057. _vector["default"].min(min, start, end);
  6058. _vector["default"].max(max, start, end); // Thresh to [0, Math.PI * 2]
  6059. startAngle = startAngle % (Math.PI * 2);
  6060. if (startAngle < 0) {
  6061. startAngle = startAngle + Math.PI * 2;
  6062. }
  6063. endAngle = endAngle % (Math.PI * 2);
  6064. if (endAngle < 0) {
  6065. endAngle = endAngle + Math.PI * 2;
  6066. }
  6067. if (startAngle > endAngle && !anticlockwise) {
  6068. endAngle += Math.PI * 2;
  6069. } else if (startAngle < endAngle && anticlockwise) {
  6070. startAngle += Math.PI * 2;
  6071. }
  6072. if (anticlockwise) {
  6073. var tmp = endAngle;
  6074. endAngle = startAngle;
  6075. startAngle = tmp;
  6076. }
  6077. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  6078. if (angle > startAngle) {
  6079. extremity[0] = Math.cos(angle) * r + x;
  6080. extremity[1] = Math.sin(angle) * r + y;
  6081. _vector["default"].min(min, extremity, min);
  6082. _vector["default"].max(max, extremity, max);
  6083. }
  6084. }
  6085. return {
  6086. minX: min[0],
  6087. minY: min[1],
  6088. maxX: max[0],
  6089. maxY: max[1]
  6090. };
  6091. }
  6092. function getBBoxFromBezierGroup(points, lineWidth) {
  6093. var minX = Infinity;
  6094. var maxX = -Infinity;
  6095. var minY = Infinity;
  6096. var maxY = -Infinity;
  6097. for (var i = 0, len = points.length; i < len; i++) {
  6098. var bbox = cubicBezierBounds(points[i]);
  6099. if (bbox.minX < minX) {
  6100. minX = bbox.minX;
  6101. }
  6102. if (bbox.maxX > maxX) {
  6103. maxX = bbox.maxX;
  6104. }
  6105. if (bbox.minY < minY) {
  6106. minY = bbox.minY;
  6107. }
  6108. if (bbox.maxY > maxY) {
  6109. maxY = bbox.maxY;
  6110. }
  6111. }
  6112. lineWidth = lineWidth / 2 || 0;
  6113. return {
  6114. minX: minX - lineWidth,
  6115. minY: minY - lineWidth,
  6116. maxX: maxX + lineWidth,
  6117. maxY: maxY + lineWidth
  6118. };
  6119. }
  6120. }, function(modId) { var map = {"./vector2":1658993502546}; return __REQUIRE__(map[modId], modId); })
  6121. __DEFINE__(1658993502580, function(require, module, exports) {
  6122. exports.__esModule = true;
  6123. exports["default"] = void 0;
  6124. var _shape = _interopRequireDefault(require("../shape"));
  6125. var _bbox = require("../util/bbox");
  6126. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6127. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6128. var Polygon = /*#__PURE__*/function (_Shape) {
  6129. _inheritsLoose(Polygon, _Shape);
  6130. function Polygon() {
  6131. return _Shape.apply(this, arguments) || this;
  6132. }
  6133. var _proto = Polygon.prototype;
  6134. _proto._initProperties = function _initProperties() {
  6135. _Shape.prototype._initProperties.call(this);
  6136. this._attrs.canFill = true;
  6137. this._attrs.canStroke = true;
  6138. this._attrs.type = 'polygon';
  6139. };
  6140. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6141. return {
  6142. points: null,
  6143. lineWidth: 0
  6144. };
  6145. };
  6146. _proto.createPath = function createPath(context) {
  6147. var self = this;
  6148. var attrs = self.get('attrs');
  6149. var points = attrs.points;
  6150. context.beginPath();
  6151. for (var i = 0, len = points.length; i < len; i++) {
  6152. var point = points[i];
  6153. if (i === 0) {
  6154. context.moveTo(point.x, point.y);
  6155. } else {
  6156. context.lineTo(point.x, point.y);
  6157. }
  6158. }
  6159. context.closePath();
  6160. };
  6161. _proto.calculateBox = function calculateBox() {
  6162. var attrs = this.get('attrs');
  6163. var points = attrs.points;
  6164. return (0, _bbox.getBBoxFromPoints)(points);
  6165. };
  6166. return Polygon;
  6167. }(_shape["default"]);
  6168. _shape["default"].Polygon = Polygon;
  6169. var _default = Polygon;
  6170. exports["default"] = _default;
  6171. }, function(modId) { var map = {"../shape":1658993502570,"../util/bbox":1658993502579}; return __REQUIRE__(map[modId], modId); })
  6172. __DEFINE__(1658993502581, function(require, module, exports) {
  6173. exports.__esModule = true;
  6174. exports["default"] = void 0;
  6175. var _shape = _interopRequireDefault(require("../shape"));
  6176. var _bbox = require("../util/bbox");
  6177. var Smooth = _interopRequireWildcard(require("../util/smooth"));
  6178. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  6179. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  6180. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6181. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6182. // filter the point which x or y is NaN
  6183. function _filterPoints(points) {
  6184. var filteredPoints = [];
  6185. for (var i = 0, len = points.length; i < len; i++) {
  6186. var point = points[i];
  6187. if (!isNaN(point.x) && !isNaN(point.y)) {
  6188. filteredPoints.push(point);
  6189. }
  6190. }
  6191. return filteredPoints;
  6192. }
  6193. var Polyline = /*#__PURE__*/function (_Shape) {
  6194. _inheritsLoose(Polyline, _Shape);
  6195. function Polyline() {
  6196. return _Shape.apply(this, arguments) || this;
  6197. }
  6198. var _proto = Polyline.prototype;
  6199. _proto._initProperties = function _initProperties() {
  6200. _Shape.prototype._initProperties.call(this);
  6201. this._attrs.canFill = true;
  6202. this._attrs.canStroke = true;
  6203. this._attrs.type = 'polyline';
  6204. };
  6205. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6206. return {
  6207. points: null,
  6208. lineWidth: 1,
  6209. smooth: false
  6210. };
  6211. };
  6212. _proto.createPath = function createPath(context) {
  6213. var self = this;
  6214. var attrs = self.get('attrs');
  6215. var points = attrs.points,
  6216. smooth = attrs.smooth;
  6217. var filteredPoints = _filterPoints(points);
  6218. context.beginPath();
  6219. if (filteredPoints.length) {
  6220. context.moveTo(filteredPoints[0].x, filteredPoints[0].y);
  6221. if (smooth) {
  6222. var constaint = [[0, 0], [1, 1]];
  6223. var sps = Smooth.smooth(filteredPoints, false, constaint);
  6224. for (var i = 0, n = sps.length; i < n; i++) {
  6225. var sp = sps[i];
  6226. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  6227. }
  6228. } else {
  6229. var _i;
  6230. var l;
  6231. for (_i = 1, l = filteredPoints.length - 1; _i < l; _i++) {
  6232. context.lineTo(filteredPoints[_i].x, filteredPoints[_i].y);
  6233. }
  6234. context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
  6235. }
  6236. }
  6237. };
  6238. _proto.calculateBox = function calculateBox() {
  6239. var attrs = this.get('attrs');
  6240. var points = attrs.points,
  6241. smooth = attrs.smooth,
  6242. lineWidth = attrs.lineWidth;
  6243. var filteredPoints = _filterPoints(points);
  6244. if (smooth) {
  6245. var newPoints = [];
  6246. var constaint = [[0, 0], [1, 1]];
  6247. var sps = Smooth.smooth(filteredPoints, false, constaint);
  6248. for (var i = 0, n = sps.length; i < n; i++) {
  6249. var sp = sps[i];
  6250. if (i === 0) {
  6251. newPoints.push([filteredPoints[0].x, filteredPoints[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  6252. } else {
  6253. var lastPoint = sps[i - 1];
  6254. newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  6255. }
  6256. }
  6257. return (0, _bbox.getBBoxFromBezierGroup)(newPoints, lineWidth);
  6258. }
  6259. return (0, _bbox.getBBoxFromPoints)(filteredPoints, lineWidth);
  6260. };
  6261. return Polyline;
  6262. }(_shape["default"]);
  6263. _shape["default"].Polyline = Polyline;
  6264. var _default = Polyline;
  6265. exports["default"] = _default;
  6266. }, function(modId) { var map = {"../shape":1658993502570,"../util/bbox":1658993502579,"../util/smooth":1658993502582}; return __REQUIRE__(map[modId], modId); })
  6267. __DEFINE__(1658993502582, function(require, module, exports) {
  6268. exports.__esModule = true;
  6269. exports.smooth = catmullRom2bezier;
  6270. var _vector = _interopRequireDefault(require("./vector2"));
  6271. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6272. /**
  6273. * @fileOverview convert the line to curve
  6274. * @author dxq613@gmail.com
  6275. */
  6276. function getPoint(v) {
  6277. return [v.x, v.y];
  6278. }
  6279. function smoothBezier(points, smooth, isLoop, constraint) {
  6280. var cps = [];
  6281. var prevPoint;
  6282. var nextPoint;
  6283. var hasConstraint = !!constraint;
  6284. var min;
  6285. var max;
  6286. var point;
  6287. var len;
  6288. var l;
  6289. var i;
  6290. if (hasConstraint) {
  6291. min = [Infinity, Infinity];
  6292. max = [-Infinity, -Infinity];
  6293. for (i = 0, l = points.length; i < l; i++) {
  6294. point = getPoint(points[i]);
  6295. _vector["default"].min(min, min, point);
  6296. _vector["default"].max(max, max, point);
  6297. }
  6298. _vector["default"].min(min, min, constraint[0]);
  6299. _vector["default"].max(max, max, constraint[1]);
  6300. }
  6301. for (i = 0, len = points.length; i < len; i++) {
  6302. point = getPoint(points[i]);
  6303. if (isLoop) {
  6304. prevPoint = getPoint(points[i ? i - 1 : len - 1]);
  6305. nextPoint = getPoint(points[(i + 1) % len]);
  6306. } else {
  6307. if (i === 0 || i === len - 1) {
  6308. cps.push([point[0], point[1]]);
  6309. continue;
  6310. } else {
  6311. prevPoint = getPoint(points[i - 1]);
  6312. nextPoint = getPoint(points[i + 1]);
  6313. }
  6314. }
  6315. var v = _vector["default"].sub([], nextPoint, prevPoint);
  6316. _vector["default"].scale(v, v, smooth);
  6317. var d0 = _vector["default"].distance(point, prevPoint);
  6318. var d1 = _vector["default"].distance(point, nextPoint);
  6319. var sum = d0 + d1;
  6320. if (sum !== 0) {
  6321. d0 /= sum;
  6322. d1 /= sum;
  6323. }
  6324. var v1 = _vector["default"].scale([], v, -d0);
  6325. var v2 = _vector["default"].scale([], v, d1);
  6326. var cp0 = _vector["default"].add([], point, v1);
  6327. var cp1 = _vector["default"].add([], point, v2);
  6328. if (hasConstraint) {
  6329. _vector["default"].max(cp0, cp0, min);
  6330. _vector["default"].min(cp0, cp0, max);
  6331. _vector["default"].max(cp1, cp1, min);
  6332. _vector["default"].min(cp1, cp1, max);
  6333. }
  6334. cps.push([cp0[0], cp0[1]]);
  6335. cps.push([cp1[0], cp1[1]]);
  6336. }
  6337. if (isLoop) {
  6338. cps.push(cps.shift());
  6339. }
  6340. return cps;
  6341. }
  6342. function catmullRom2bezier(pointList, z, constraint) {
  6343. var isLoop = !!z;
  6344. var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
  6345. var len = pointList.length;
  6346. var d1 = [];
  6347. var cp1;
  6348. var cp2;
  6349. var p;
  6350. for (var i = 0; i < len - 1; i++) {
  6351. cp1 = controlPointList[i * 2];
  6352. cp2 = controlPointList[i * 2 + 1];
  6353. p = pointList[i + 1];
  6354. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  6355. }
  6356. if (isLoop) {
  6357. cp1 = controlPointList[len];
  6358. cp2 = controlPointList[len + 1];
  6359. p = pointList[0];
  6360. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  6361. }
  6362. return d1;
  6363. }
  6364. }, function(modId) { var map = {"./vector2":1658993502546}; return __REQUIRE__(map[modId], modId); })
  6365. __DEFINE__(1658993502583, function(require, module, exports) {
  6366. exports.__esModule = true;
  6367. exports["default"] = void 0;
  6368. var _shape = _interopRequireDefault(require("../shape"));
  6369. var _bbox = require("../util/bbox");
  6370. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6371. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6372. var Arc = /*#__PURE__*/function (_Shape) {
  6373. _inheritsLoose(Arc, _Shape);
  6374. function Arc() {
  6375. return _Shape.apply(this, arguments) || this;
  6376. }
  6377. var _proto = Arc.prototype;
  6378. _proto._initProperties = function _initProperties() {
  6379. _Shape.prototype._initProperties.call(this);
  6380. this._attrs.canStroke = true;
  6381. this._attrs.canFill = true;
  6382. this._attrs.type = 'arc';
  6383. };
  6384. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6385. return {
  6386. x: 0,
  6387. y: 0,
  6388. r: 0,
  6389. startAngle: 0,
  6390. endAngle: Math.PI * 2,
  6391. anticlockwise: false,
  6392. lineWidth: 1
  6393. };
  6394. };
  6395. _proto.createPath = function createPath(context) {
  6396. var attrs = this.get('attrs');
  6397. var x = attrs.x,
  6398. y = attrs.y,
  6399. r = attrs.r,
  6400. startAngle = attrs.startAngle,
  6401. endAngle = attrs.endAngle,
  6402. anticlockwise = attrs.anticlockwise;
  6403. context.beginPath();
  6404. if (startAngle !== endAngle) {
  6405. context.arc(x, y, r, startAngle, endAngle, anticlockwise);
  6406. }
  6407. };
  6408. _proto.calculateBox = function calculateBox() {
  6409. var attrs = this.get('attrs');
  6410. var x = attrs.x,
  6411. y = attrs.y,
  6412. r = attrs.r,
  6413. startAngle = attrs.startAngle,
  6414. endAngle = attrs.endAngle,
  6415. anticlockwise = attrs.anticlockwise;
  6416. return (0, _bbox.getBBoxFromArc)(x, y, r, startAngle, endAngle, anticlockwise);
  6417. };
  6418. return Arc;
  6419. }(_shape["default"]);
  6420. _shape["default"].Arc = Arc;
  6421. var _default = Arc;
  6422. exports["default"] = _default;
  6423. }, function(modId) { var map = {"../shape":1658993502570,"../util/bbox":1658993502579}; return __REQUIRE__(map[modId], modId); })
  6424. __DEFINE__(1658993502584, function(require, module, exports) {
  6425. exports.__esModule = true;
  6426. exports["default"] = void 0;
  6427. var _shape = _interopRequireDefault(require("../shape"));
  6428. var _bbox = require("../util/bbox");
  6429. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6430. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6431. var Sector = /*#__PURE__*/function (_Shape) {
  6432. _inheritsLoose(Sector, _Shape);
  6433. function Sector() {
  6434. return _Shape.apply(this, arguments) || this;
  6435. }
  6436. var _proto = Sector.prototype;
  6437. _proto._initProperties = function _initProperties() {
  6438. _Shape.prototype._initProperties.call(this);
  6439. this._attrs.canFill = true;
  6440. this._attrs.canStroke = true;
  6441. this._attrs.type = 'sector';
  6442. };
  6443. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6444. return {
  6445. x: 0,
  6446. y: 0,
  6447. lineWidth: 0,
  6448. r: 0,
  6449. r0: 0,
  6450. startAngle: 0,
  6451. endAngle: Math.PI * 2,
  6452. anticlockwise: false
  6453. };
  6454. };
  6455. _proto.createPath = function createPath(context) {
  6456. var attrs = this.get('attrs');
  6457. var x = attrs.x,
  6458. y = attrs.y,
  6459. startAngle = attrs.startAngle,
  6460. endAngle = attrs.endAngle,
  6461. r = attrs.r,
  6462. r0 = attrs.r0,
  6463. anticlockwise = attrs.anticlockwise;
  6464. context.beginPath();
  6465. var unitX = Math.cos(startAngle);
  6466. var unitY = Math.sin(startAngle);
  6467. context.moveTo(unitX * r0 + x, unitY * r0 + y);
  6468. context.lineTo(unitX * r + x, unitY * r + y); // 当扇形的角度非常小的时候,就不进行弧线的绘制;或者整个只有1个扇形时,会出现end<0的情况不绘制
  6469. if (Math.abs(endAngle - startAngle) > 0.0001 || startAngle === 0 && endAngle < 0) {
  6470. context.arc(x, y, r, startAngle, endAngle, anticlockwise);
  6471. context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
  6472. if (r0 !== 0) {
  6473. context.arc(x, y, r0, endAngle, startAngle, !anticlockwise);
  6474. }
  6475. }
  6476. context.closePath();
  6477. };
  6478. _proto.calculateBox = function calculateBox() {
  6479. var attrs = this.get('attrs');
  6480. var x = attrs.x,
  6481. y = attrs.y,
  6482. r = attrs.r,
  6483. r0 = attrs.r0,
  6484. startAngle = attrs.startAngle,
  6485. endAngle = attrs.endAngle,
  6486. anticlockwise = attrs.anticlockwise;
  6487. var outerBBox = (0, _bbox.getBBoxFromArc)(x, y, r, startAngle, endAngle, anticlockwise);
  6488. var innerBBox = (0, _bbox.getBBoxFromArc)(x, y, r0, startAngle, endAngle, anticlockwise);
  6489. return {
  6490. minX: Math.min(outerBBox.minX, innerBBox.minX),
  6491. minY: Math.min(outerBBox.minY, innerBBox.minY),
  6492. maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
  6493. maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
  6494. };
  6495. };
  6496. return Sector;
  6497. }(_shape["default"]);
  6498. _shape["default"].Sector = Sector;
  6499. var _default = Sector;
  6500. exports["default"] = _default;
  6501. }, function(modId) { var map = {"../shape":1658993502570,"../util/bbox":1658993502579}; return __REQUIRE__(map[modId], modId); })
  6502. __DEFINE__(1658993502585, function(require, module, exports) {
  6503. exports.__esModule = true;
  6504. exports["default"] = void 0;
  6505. var _common = require("../../util/common");
  6506. var _shape = _interopRequireDefault(require("../shape"));
  6507. var _rect = _interopRequireDefault(require("../util/rect"));
  6508. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6509. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6510. var textWidthCacheCounter = 0;
  6511. var textWidthCache = {};
  6512. var TEXT_CACHE_MAX = 5000;
  6513. var Text = /*#__PURE__*/function (_Shape) {
  6514. _inheritsLoose(Text, _Shape);
  6515. function Text() {
  6516. return _Shape.apply(this, arguments) || this;
  6517. }
  6518. var _proto = Text.prototype;
  6519. _proto._initProperties = function _initProperties() {
  6520. _Shape.prototype._initProperties.call(this);
  6521. this._attrs.canFill = true;
  6522. this._attrs.canStroke = true;
  6523. this._attrs.type = 'text';
  6524. };
  6525. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6526. return {
  6527. lineWidth: 0,
  6528. lineCount: 1,
  6529. fontSize: 12,
  6530. fontFamily: 'sans-serif',
  6531. fontStyle: 'normal',
  6532. fontWeight: 'normal',
  6533. fontVariant: 'normal',
  6534. textAlign: 'start',
  6535. textBaseline: 'bottom',
  6536. lineHeight: null,
  6537. textArr: null
  6538. };
  6539. };
  6540. _proto._getFontStyle = function _getFontStyle() {
  6541. var attrs = this._attrs.attrs;
  6542. var fontSize = attrs.fontSize,
  6543. fontFamily = attrs.fontFamily,
  6544. fontWeight = attrs.fontWeight,
  6545. fontStyle = attrs.fontStyle,
  6546. fontVariant = attrs.fontVariant;
  6547. return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
  6548. };
  6549. _proto._afterAttrsSet = function _afterAttrsSet() {
  6550. var attrs = this._attrs.attrs;
  6551. attrs.font = this._getFontStyle();
  6552. if (attrs.text) {
  6553. var text = attrs.text;
  6554. var textArr = null;
  6555. var lineCount = 1;
  6556. if ((0, _common.isString)(text) && text.indexOf('\n') !== -1) {
  6557. textArr = text.split('\n');
  6558. lineCount = textArr.length;
  6559. }
  6560. attrs.lineCount = lineCount;
  6561. attrs.textArr = textArr;
  6562. }
  6563. this.set('attrs', attrs);
  6564. };
  6565. _proto._getTextHeight = function _getTextHeight() {
  6566. var attrs = this._attrs.attrs;
  6567. if (attrs.height) {
  6568. return attrs.height;
  6569. }
  6570. var lineCount = attrs.lineCount;
  6571. var fontSize = attrs.fontSize * 1;
  6572. if (lineCount > 1) {
  6573. var spaceingY = this._getSpaceingY();
  6574. return fontSize * lineCount + spaceingY * (lineCount - 1);
  6575. }
  6576. return fontSize;
  6577. };
  6578. _proto._getSpaceingY = function _getSpaceingY() {
  6579. var attrs = this._attrs.attrs;
  6580. var lineHeight = attrs.lineHeight;
  6581. var fontSize = attrs.fontSize * 1;
  6582. return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
  6583. };
  6584. _proto.drawInner = function drawInner(context) {
  6585. var self = this;
  6586. var attrs = self._attrs.attrs;
  6587. var text = attrs.text;
  6588. var x = attrs.x;
  6589. var y = attrs.y;
  6590. if ((0, _common.isNil)(text) || isNaN(x) || isNaN(y)) {
  6591. // text will be 0
  6592. return;
  6593. }
  6594. var textArr = attrs.textArr;
  6595. var fontSize = attrs.fontSize * 1;
  6596. var spaceingY = self._getSpaceingY();
  6597. if (attrs.rotate) {
  6598. // do rotation
  6599. context.translate(x, y);
  6600. context.rotate(attrs.rotate);
  6601. x = 0;
  6602. y = 0;
  6603. }
  6604. var textBaseline = attrs.textBaseline;
  6605. var height;
  6606. if (textArr) {
  6607. height = self._getTextHeight();
  6608. }
  6609. var subY; // context.beginPath();
  6610. if (self.hasFill()) {
  6611. var fillOpacity = attrs.fillOpacity;
  6612. if (!(0, _common.isNil)(fillOpacity) && fillOpacity !== 1) {
  6613. context.globalAlpha = fillOpacity;
  6614. }
  6615. if (textArr) {
  6616. for (var i = 0, len = textArr.length; i < len; i++) {
  6617. var subText = textArr[i];
  6618. subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;
  6619. if (textBaseline === 'middle') {
  6620. subY += height - fontSize - (height - fontSize) / 2;
  6621. }
  6622. if (textBaseline === 'top') {
  6623. subY += height - fontSize;
  6624. }
  6625. context.fillText(subText, x, subY);
  6626. }
  6627. } else {
  6628. context.fillText(text, x, y);
  6629. }
  6630. }
  6631. if (self.hasStroke()) {
  6632. if (textArr) {
  6633. for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
  6634. var _subText = textArr[_i];
  6635. subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;
  6636. if (textBaseline === 'middle') {
  6637. subY += height - fontSize - (height - fontSize) / 2;
  6638. }
  6639. if (textBaseline === 'top') {
  6640. subY += height - fontSize;
  6641. }
  6642. context.strokeText(_subText, x, subY);
  6643. }
  6644. } else {
  6645. context.strokeText(text, x, y);
  6646. }
  6647. }
  6648. };
  6649. _proto.calculateBox = function calculateBox() {
  6650. var self = this;
  6651. var attrs = self._attrs.attrs;
  6652. var x = attrs.x,
  6653. y = attrs.y,
  6654. textAlign = attrs.textAlign,
  6655. textBaseline = attrs.textBaseline;
  6656. var width = self._getTextWidth(); // attrs.width
  6657. if (!width) {
  6658. return {
  6659. minX: x,
  6660. minY: y,
  6661. maxX: x,
  6662. maxY: y
  6663. };
  6664. }
  6665. var height = self._getTextHeight(); // attrs.height
  6666. if (attrs.rotate) {
  6667. var rotatedBox = _rect["default"].calcRotatedBox({
  6668. width: width,
  6669. height: height,
  6670. rotate: attrs.rotate
  6671. });
  6672. width = rotatedBox.width;
  6673. height = rotatedBox.height;
  6674. }
  6675. var point = {
  6676. x: x,
  6677. y: y - height
  6678. }; // default textAlign: start, textBaseline: bottom
  6679. if (textAlign) {
  6680. if (textAlign === 'end' || textAlign === 'right') {
  6681. point.x -= width;
  6682. } else if (textAlign === 'center') {
  6683. point.x -= width / 2;
  6684. }
  6685. }
  6686. if (textBaseline) {
  6687. if (textBaseline === 'top') {
  6688. point.y += height;
  6689. } else if (textBaseline === 'middle') {
  6690. point.y += height / 2;
  6691. }
  6692. }
  6693. return {
  6694. minX: point.x,
  6695. minY: point.y,
  6696. maxX: point.x + width,
  6697. maxY: point.y + height
  6698. };
  6699. };
  6700. _proto._getTextWidth = function _getTextWidth() {
  6701. var attrs = this._attrs.attrs;
  6702. if (attrs.width) {
  6703. return attrs.width;
  6704. }
  6705. var text = attrs.text;
  6706. var context = this.get('context');
  6707. if ((0, _common.isNil)(text)) return undefined;
  6708. var font = attrs.font;
  6709. var textArr = attrs.textArr;
  6710. var key = text + '' + font;
  6711. if (textWidthCache[key]) {
  6712. return textWidthCache[key];
  6713. }
  6714. var width = 0;
  6715. if (textArr) {
  6716. for (var i = 0, length = textArr.length; i < length; i++) {
  6717. var subText = textArr[i];
  6718. width = Math.max(width, (0, _common.measureText)(subText, font, context).width);
  6719. }
  6720. } else {
  6721. width = (0, _common.measureText)(text, font, context).width;
  6722. }
  6723. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  6724. textWidthCacheCounter = 0;
  6725. textWidthCache = {};
  6726. }
  6727. textWidthCacheCounter++;
  6728. textWidthCache[key] = width;
  6729. return width;
  6730. };
  6731. return Text;
  6732. }(_shape["default"]);
  6733. _shape["default"].Text = Text;
  6734. var _default = Text;
  6735. exports["default"] = _default;
  6736. }, function(modId) { var map = {"../../util/common":1658993502535,"../shape":1658993502570,"../util/rect":1658993502586}; return __REQUIRE__(map[modId], modId); })
  6737. __DEFINE__(1658993502586, function(require, module, exports) {
  6738. exports.__esModule = true;
  6739. exports["default"] = void 0;
  6740. var Rect = {
  6741. calcRotatedBox: function calcRotatedBox(_ref) {
  6742. var width = _ref.width,
  6743. height = _ref.height,
  6744. rotate = _ref.rotate;
  6745. var absRotate = Math.abs(rotate);
  6746. return {
  6747. width: Math.abs(width * Math.cos(absRotate) + height * Math.sin(absRotate)),
  6748. height: Math.abs(height * Math.cos(absRotate) + width * Math.sin(absRotate))
  6749. };
  6750. }
  6751. };
  6752. var _default = Rect;
  6753. exports["default"] = _default;
  6754. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  6755. __DEFINE__(1658993502587, function(require, module, exports) {
  6756. exports.__esModule = true;
  6757. exports["default"] = void 0;
  6758. var _shape = _interopRequireDefault(require("../shape"));
  6759. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6760. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6761. var Custom = /*#__PURE__*/function (_Shape) {
  6762. _inheritsLoose(Custom, _Shape);
  6763. function Custom() {
  6764. return _Shape.apply(this, arguments) || this;
  6765. }
  6766. var _proto = Custom.prototype;
  6767. _proto._initProperties = function _initProperties() {
  6768. _Shape.prototype._initProperties.call(this);
  6769. this._attrs.canFill = true;
  6770. this._attrs.canStroke = true;
  6771. this._attrs.createPath = null;
  6772. this._attrs.type = 'custom';
  6773. };
  6774. _proto.createPath = function createPath(context) {
  6775. var createPath = this.get('createPath');
  6776. createPath && createPath.call(this, context);
  6777. };
  6778. _proto.calculateBox = function calculateBox() {
  6779. var calculateBox = this.get('calculateBox');
  6780. return calculateBox && calculateBox.call(this);
  6781. };
  6782. return Custom;
  6783. }(_shape["default"]);
  6784. _shape["default"].Custom = Custom;
  6785. var _default = Custom;
  6786. exports["default"] = _default;
  6787. }, function(modId) { var map = {"../shape":1658993502570}; return __REQUIRE__(map[modId], modId); })
  6788. __DEFINE__(1658993502588, function(require, module, exports) {
  6789. exports.__esModule = true;
  6790. exports.getClip = getClip;
  6791. exports.isPointInPlot = isPointInPlot;
  6792. var _index = require("../graphic/index");
  6793. function getClip(coord) {
  6794. var start = coord.start;
  6795. var end = coord.end;
  6796. var width = end.x - start.x;
  6797. var height = Math.abs(end.y - start.y);
  6798. var margin = 10;
  6799. var clip;
  6800. if (coord.isPolar) {
  6801. var circleRadius = coord.circleRadius,
  6802. center = coord.center,
  6803. startAngle = coord.startAngle,
  6804. endAngle = coord.endAngle;
  6805. clip = new _index.Shape.Sector({
  6806. attrs: {
  6807. x: center.x,
  6808. y: center.y,
  6809. r: circleRadius,
  6810. r0: 0,
  6811. startAngle: startAngle,
  6812. endAngle: endAngle
  6813. }
  6814. });
  6815. } else {
  6816. clip = new _index.Shape.Rect({
  6817. attrs: {
  6818. x: start.x,
  6819. y: end.y - margin,
  6820. width: width,
  6821. height: height + 2 * margin
  6822. }
  6823. });
  6824. }
  6825. clip.isClip = true;
  6826. return clip;
  6827. }
  6828. function isPointInPlot(point, plot) {
  6829. var x = point.x,
  6830. y = point.y;
  6831. var tl = plot.tl,
  6832. tr = plot.tr,
  6833. br = plot.br;
  6834. return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
  6835. }
  6836. }, function(modId) { var map = {"../graphic/index":1658993502565}; return __REQUIRE__(map[modId], modId); })
  6837. __DEFINE__(1658993502589, function(require, module, exports) {
  6838. exports.__esModule = true;
  6839. exports["default"] = void 0;
  6840. var _base = _interopRequireDefault(require("./base"));
  6841. require("./point");
  6842. require("./path");
  6843. require("./line");
  6844. require("./area");
  6845. require("./interval");
  6846. require("./polygon");
  6847. require("./schema");
  6848. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6849. var _default = _base["default"];
  6850. exports["default"] = _default;
  6851. }, function(modId) { var map = {"./base":1658993502548,"./point":1658993502590,"./path":1658993502593,"./line":1658993502595,"./area":1658993502596,"./interval":1658993502598,"./polygon":1658993502601,"./schema":1658993502603}; return __REQUIRE__(map[modId], modId); })
  6852. __DEFINE__(1658993502590, function(require, module, exports) {
  6853. exports.__esModule = true;
  6854. exports["default"] = void 0;
  6855. var _common = require("../util/common");
  6856. var _base = _interopRequireDefault(require("./base"));
  6857. require("./shape/point");
  6858. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6859. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6860. var Point = /*#__PURE__*/function (_Geom) {
  6861. _inheritsLoose(Point, _Geom);
  6862. function Point() {
  6863. return _Geom.apply(this, arguments) || this;
  6864. }
  6865. var _proto = Point.prototype;
  6866. _proto.getDefaultCfg = function getDefaultCfg() {
  6867. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  6868. cfg.type = 'point';
  6869. cfg.shapeType = 'point';
  6870. cfg.generatePoints = false;
  6871. return cfg;
  6872. };
  6873. _proto.draw = function draw(data, shapeFactory) {
  6874. var self = this;
  6875. var container = self.get('container');
  6876. (0, _common.each)(data, function (obj) {
  6877. var shape = obj.shape;
  6878. var cfg = self.getDrawCfg(obj);
  6879. if ((0, _common.isArray)(obj.y)) {
  6880. var hasStack = self.hasAdjust('stack');
  6881. (0, _common.each)(obj.y, function (y, idx) {
  6882. cfg.y = y;
  6883. if (!hasStack || idx !== 0) {
  6884. self.drawShape(shape, obj, cfg, container, shapeFactory);
  6885. }
  6886. });
  6887. } else if (!(0, _common.isNil)(obj.y)) {
  6888. self.drawShape(shape, obj, cfg, container, shapeFactory);
  6889. }
  6890. });
  6891. };
  6892. return Point;
  6893. }(_base["default"]);
  6894. _base["default"].Point = Point;
  6895. var _default = Point;
  6896. exports["default"] = _default;
  6897. }, function(modId) { var map = {"../util/common":1658993502535,"./base":1658993502548,"./shape/point":1658993502591}; return __REQUIRE__(map[modId], modId); })
  6898. __DEFINE__(1658993502591, function(require, module, exports) {
  6899. exports.__esModule = true;
  6900. exports["default"] = void 0;
  6901. var _global = _interopRequireDefault(require("../../global"));
  6902. var _shape = _interopRequireDefault(require("./shape"));
  6903. var _common = require("../../util/common");
  6904. var _util = require("./util");
  6905. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6906. var SHAPES = ['circle', 'hollowCircle', 'rect'];
  6907. var Point = _shape["default"].registerFactory('point', {
  6908. defaultShapeType: 'circle',
  6909. getDefaultPoints: function getDefaultPoints(pointInfo) {
  6910. return (0, _util.splitPoints)(pointInfo);
  6911. }
  6912. });
  6913. function getPointsCfg(cfg) {
  6914. var style = {
  6915. lineWidth: 0,
  6916. stroke: cfg.color,
  6917. fill: cfg.color
  6918. };
  6919. if (cfg.size) {
  6920. style.size = cfg.size;
  6921. }
  6922. (0, _common.mix)(style, cfg.style);
  6923. return (0, _common.mix)({}, _global["default"].shape.point, style);
  6924. }
  6925. function drawShape(cfg, container, shape) {
  6926. if (cfg.size === 0) return;
  6927. var pointCfg = getPointsCfg(cfg);
  6928. var size = pointCfg.r || pointCfg.size;
  6929. var x = cfg.x;
  6930. var y = !(0, _common.isArray)(cfg.y) ? [cfg.y] : cfg.y;
  6931. if (shape === 'hollowCircle') {
  6932. pointCfg.lineWidth = 1;
  6933. pointCfg.fill = null;
  6934. }
  6935. for (var i = 0, len = y.length; i < len; i++) {
  6936. if (shape === 'rect') {
  6937. return container.addShape('Rect', {
  6938. className: 'point',
  6939. attrs: (0, _common.mix)({
  6940. x: x - size,
  6941. y: y[i] - size,
  6942. width: size * 2,
  6943. height: size * 2
  6944. }, pointCfg)
  6945. });
  6946. }
  6947. return container.addShape('Circle', {
  6948. className: 'point',
  6949. attrs: (0, _common.mix)({
  6950. x: x,
  6951. y: y[i],
  6952. r: size
  6953. }, pointCfg)
  6954. });
  6955. }
  6956. }
  6957. (0, _common.each)(SHAPES, function (shapeType) {
  6958. _shape["default"].registerShape('point', shapeType, {
  6959. draw: function draw(cfg, container) {
  6960. return drawShape(cfg, container, shapeType);
  6961. }
  6962. });
  6963. });
  6964. var _default = Point;
  6965. exports["default"] = _default;
  6966. }, function(modId) { var map = {"../../global":1658993502533,"./shape":1658993502556,"../../util/common":1658993502535,"./util":1658993502592}; return __REQUIRE__(map[modId], modId); })
  6967. __DEFINE__(1658993502592, function(require, module, exports) {
  6968. exports.__esModule = true;
  6969. exports.splitPoints = splitPoints;
  6970. exports.splitArray = splitArray;
  6971. var _common = require("../../util/common");
  6972. /**
  6973. * @fileOverview shape util
  6974. * @author dxq613@gmail.com
  6975. */
  6976. function splitPoints(obj) {
  6977. var points = [];
  6978. var x = obj.x;
  6979. var y = obj.y;
  6980. y = (0, _common.isArray)(y) ? y : [y];
  6981. y.forEach(function (yItem, index) {
  6982. var point = {
  6983. x: (0, _common.isArray)(x) ? x[index] : x,
  6984. y: yItem
  6985. };
  6986. points.push(point);
  6987. });
  6988. return points;
  6989. }
  6990. function splitArray(data, yField, connectNulls) {
  6991. if (!data.length) return [];
  6992. var arr = [];
  6993. var tmp = [];
  6994. var yValue;
  6995. (0, _common.each)(data, function (obj) {
  6996. yValue = obj._origin ? obj._origin[yField] : obj[yField];
  6997. if (connectNulls) {
  6998. if (!(0, _common.isNil)(yValue)) {
  6999. tmp.push(obj);
  7000. }
  7001. } else {
  7002. if ((0, _common.isArray)(yValue) && (0, _common.isNil)(yValue[0]) || (0, _common.isNil)(yValue)) {
  7003. if (tmp.length) {
  7004. arr.push(tmp);
  7005. tmp = [];
  7006. }
  7007. } else {
  7008. tmp.push(obj);
  7009. }
  7010. }
  7011. });
  7012. if (tmp.length) {
  7013. arr.push(tmp);
  7014. }
  7015. return arr;
  7016. }
  7017. }, function(modId) { var map = {"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  7018. __DEFINE__(1658993502593, function(require, module, exports) {
  7019. exports.__esModule = true;
  7020. exports["default"] = void 0;
  7021. var _base = _interopRequireDefault(require("./base"));
  7022. var _util = require("./shape/util");
  7023. var _common = require("../util/common");
  7024. require("./shape/line");
  7025. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7026. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7027. var Path = /*#__PURE__*/function (_Geom) {
  7028. _inheritsLoose(Path, _Geom);
  7029. function Path() {
  7030. return _Geom.apply(this, arguments) || this;
  7031. }
  7032. var _proto = Path.prototype;
  7033. _proto.getDefaultCfg = function getDefaultCfg() {
  7034. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7035. cfg.type = 'path';
  7036. cfg.shapeType = 'line';
  7037. return cfg;
  7038. };
  7039. _proto.getDrawCfg = function getDrawCfg(obj) {
  7040. var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
  7041. cfg.isStack = this.hasAdjust('stack');
  7042. return cfg;
  7043. };
  7044. _proto.draw = function draw(data, shapeFactory) {
  7045. var self = this;
  7046. var container = self.get('container');
  7047. var yScale = self.getYScale();
  7048. var connectNulls = self.get('connectNulls');
  7049. var splitArrayObj = (0, _util.splitArray)(data, yScale.field, connectNulls);
  7050. var cfg = this.getDrawCfg(data[0]);
  7051. cfg.origin = data;
  7052. (0, _common.each)(splitArrayObj, function (subData, splitedIndex) {
  7053. cfg.splitedIndex = splitedIndex;
  7054. cfg.points = subData;
  7055. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  7056. });
  7057. };
  7058. return Path;
  7059. }(_base["default"]);
  7060. _base["default"].Path = Path;
  7061. var _default = Path;
  7062. exports["default"] = _default;
  7063. }, function(modId) { var map = {"./base":1658993502548,"./shape/util":1658993502592,"../util/common":1658993502535,"./shape/line":1658993502594}; return __REQUIRE__(map[modId], modId); })
  7064. __DEFINE__(1658993502594, function(require, module, exports) {
  7065. exports.__esModule = true;
  7066. exports["default"] = void 0;
  7067. var _global = _interopRequireDefault(require("../../global"));
  7068. var _shape = _interopRequireDefault(require("./shape"));
  7069. var _common = require("../../util/common");
  7070. var _util = require("./util");
  7071. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7072. // register line geom
  7073. var Line = _shape["default"].registerFactory('line', {
  7074. defaultShapeType: 'line'
  7075. });
  7076. function getStyle(cfg) {
  7077. var style = {
  7078. strokeStyle: cfg.color
  7079. };
  7080. if (cfg.size >= 0) {
  7081. style.lineWidth = cfg.size;
  7082. }
  7083. (0, _common.mix)(style, cfg.style);
  7084. return (0, _common.mix)({}, _global["default"].shape.line, style);
  7085. }
  7086. function drawLines(cfg, container, style, smooth) {
  7087. var points = cfg.points;
  7088. if (points.length && (0, _common.isArray)(points[0].y)) {
  7089. var topPoints = [];
  7090. var bottomPoints = [];
  7091. for (var i = 0, len = points.length; i < len; i++) {
  7092. var point = points[i];
  7093. var tmp = (0, _util.splitPoints)(point);
  7094. bottomPoints.push(tmp[0]);
  7095. topPoints.push(tmp[1]);
  7096. }
  7097. if (cfg.isInCircle) {
  7098. topPoints.push(topPoints[0]);
  7099. bottomPoints.push(bottomPoints[0]);
  7100. }
  7101. if (cfg.isStack) {
  7102. return container.addShape('Polyline', {
  7103. className: 'line',
  7104. attrs: (0, _common.mix)({
  7105. points: topPoints,
  7106. smooth: smooth
  7107. }, style)
  7108. });
  7109. }
  7110. var topShape = container.addShape('Polyline', {
  7111. className: 'line',
  7112. attrs: (0, _common.mix)({
  7113. points: topPoints,
  7114. smooth: smooth
  7115. }, style)
  7116. });
  7117. var bottomShape = container.addShape('Polyline', {
  7118. className: 'line',
  7119. attrs: (0, _common.mix)({
  7120. points: bottomPoints,
  7121. smooth: smooth
  7122. }, style)
  7123. });
  7124. return [topShape, bottomShape];
  7125. }
  7126. if (cfg.isInCircle) {
  7127. points.push(points[0]);
  7128. }
  7129. return container.addShape('Polyline', {
  7130. className: 'line',
  7131. attrs: (0, _common.mix)({
  7132. points: points,
  7133. smooth: smooth
  7134. }, style)
  7135. });
  7136. }
  7137. var SHAPES = ['line', 'smooth', 'dash'];
  7138. (0, _common.each)(SHAPES, function (shapeType) {
  7139. _shape["default"].registerShape('line', shapeType, {
  7140. draw: function draw(cfg, container) {
  7141. var smooth = shapeType === 'smooth';
  7142. var style = getStyle(cfg);
  7143. if (shapeType === 'dash') {
  7144. style.lineDash = _global["default"].lineDash;
  7145. }
  7146. return drawLines(cfg, container, style, smooth);
  7147. }
  7148. });
  7149. });
  7150. var _default = Line;
  7151. exports["default"] = _default;
  7152. }, function(modId) { var map = {"../../global":1658993502533,"./shape":1658993502556,"../../util/common":1658993502535,"./util":1658993502592}; return __REQUIRE__(map[modId], modId); })
  7153. __DEFINE__(1658993502595, function(require, module, exports) {
  7154. exports.__esModule = true;
  7155. exports["default"] = void 0;
  7156. var _path = _interopRequireDefault(require("./path"));
  7157. var _base = _interopRequireDefault(require("./base"));
  7158. require("./shape/line");
  7159. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7160. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7161. var Line = /*#__PURE__*/function (_Path) {
  7162. _inheritsLoose(Line, _Path);
  7163. function Line() {
  7164. return _Path.apply(this, arguments) || this;
  7165. }
  7166. var _proto = Line.prototype;
  7167. _proto.getDefaultCfg = function getDefaultCfg() {
  7168. var cfg = _Path.prototype.getDefaultCfg.call(this);
  7169. cfg.type = 'line';
  7170. cfg.sortable = true;
  7171. return cfg;
  7172. };
  7173. return Line;
  7174. }(_path["default"]);
  7175. _base["default"].Line = Line;
  7176. var _default = Line;
  7177. exports["default"] = _default;
  7178. }, function(modId) { var map = {"./path":1658993502593,"./base":1658993502548,"./shape/line":1658993502594}; return __REQUIRE__(map[modId], modId); })
  7179. __DEFINE__(1658993502596, function(require, module, exports) {
  7180. exports.__esModule = true;
  7181. exports["default"] = void 0;
  7182. var _base = _interopRequireDefault(require("./base"));
  7183. var _util = require("./shape/util");
  7184. var _common = require("../util/common");
  7185. require("./shape/area");
  7186. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7187. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7188. var Area = /*#__PURE__*/function (_Geom) {
  7189. _inheritsLoose(Area, _Geom);
  7190. function Area() {
  7191. return _Geom.apply(this, arguments) || this;
  7192. }
  7193. var _proto = Area.prototype;
  7194. /**
  7195. * get the default configuration
  7196. * @protected
  7197. * @return {Object} return the result
  7198. */
  7199. _proto.getDefaultCfg = function getDefaultCfg() {
  7200. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7201. cfg.type = 'area';
  7202. cfg.shapeType = 'area';
  7203. cfg.generatePoints = true;
  7204. cfg.sortable = true;
  7205. return cfg;
  7206. };
  7207. _proto.draw = function draw(data, shapeFactory) {
  7208. var self = this;
  7209. var container = self.get('container');
  7210. var cfg = this.getDrawCfg(data[0]);
  7211. var yScale = self.getYScale();
  7212. var connectNulls = self.get('connectNulls');
  7213. var splitArrayfn = (0, _util.splitArray)(data, yScale.field, connectNulls);
  7214. cfg.origin = data;
  7215. (0, _common.each)(splitArrayfn, function (subData, splitedIndex) {
  7216. cfg.splitedIndex = splitedIndex;
  7217. var points = subData.map(function (obj) {
  7218. return obj.points;
  7219. });
  7220. cfg.points = points;
  7221. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  7222. });
  7223. };
  7224. return Area;
  7225. }(_base["default"]);
  7226. _base["default"].Area = Area;
  7227. var _default = Area;
  7228. exports["default"] = _default;
  7229. }, function(modId) { var map = {"./base":1658993502548,"./shape/util":1658993502592,"../util/common":1658993502535,"./shape/area":1658993502597}; return __REQUIRE__(map[modId], modId); })
  7230. __DEFINE__(1658993502597, function(require, module, exports) {
  7231. exports.__esModule = true;
  7232. exports["default"] = void 0;
  7233. var _smooth = require("../../graphic/util/smooth");
  7234. var _bbox = require("../../graphic/util/bbox");
  7235. var _global = _interopRequireDefault(require("../../global"));
  7236. var _shape = _interopRequireDefault(require("./shape"));
  7237. var _common = require("../../util/common");
  7238. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7239. function equals(v1, v2) {
  7240. return Math.abs(v1 - v2) < 0.00001;
  7241. }
  7242. function notEmpty(value) {
  7243. return !isNaN(value) && !(0, _common.isNil)(value);
  7244. }
  7245. function filterPoints(points) {
  7246. var filteredPoints = []; // filter the point which x or y is NaN
  7247. for (var i = 0, len = points.length; i < len; i++) {
  7248. var point = points[i];
  7249. if (notEmpty(point.x) && notEmpty(point.y)) {
  7250. filteredPoints.push(point);
  7251. }
  7252. }
  7253. return filteredPoints;
  7254. }
  7255. function equalsCenter(points, center) {
  7256. var eqls = true;
  7257. (0, _common.each)(points, function (point) {
  7258. if (!equals(point.x, center.x) || !equals(point.y, center.y)) {
  7259. eqls = false;
  7260. return false;
  7261. }
  7262. });
  7263. return eqls;
  7264. }
  7265. function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
  7266. var shape;
  7267. var points = topPoints.concat(bottomPoints);
  7268. if (isSmooth) {
  7269. shape = container.addShape('Custom', {
  7270. className: 'area',
  7271. attrs: (0, _common.mix)({
  7272. points: points
  7273. }, style),
  7274. createPath: function createPath(context) {
  7275. var constaint = [[0, 0], [1, 1]];
  7276. var points = filterPoints(this._attrs.attrs.points);
  7277. var pointsLen = points.length;
  7278. var topPoints = points.slice(0, pointsLen / 2);
  7279. var bottomPoints = points.slice(pointsLen / 2, pointsLen);
  7280. var topSps = (0, _smooth.smooth)(topPoints, false, constaint);
  7281. context.beginPath();
  7282. context.moveTo(topPoints[0].x, topPoints[0].y);
  7283. for (var i = 0, n = topSps.length; i < n; i++) {
  7284. var sp = topSps[i];
  7285. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  7286. }
  7287. if (bottomPoints.length) {
  7288. var bottomSps = (0, _smooth.smooth)(bottomPoints, false, constaint);
  7289. context.lineTo(bottomPoints[0].x, bottomPoints[0].y);
  7290. for (var _i = 0, _n = bottomSps.length; _i < _n; _i++) {
  7291. var _sp = bottomSps[_i];
  7292. context.bezierCurveTo(_sp[1], _sp[2], _sp[3], _sp[4], _sp[5], _sp[6]);
  7293. }
  7294. }
  7295. context.closePath();
  7296. },
  7297. calculateBox: function calculateBox() {
  7298. var points = filterPoints(this._attrs.attrs.points);
  7299. return (0, _bbox.getBBoxFromPoints)(points);
  7300. }
  7301. });
  7302. } else {
  7303. shape = container.addShape('Polyline', {
  7304. className: 'area',
  7305. attrs: (0, _common.mix)({
  7306. points: points
  7307. }, style)
  7308. });
  7309. }
  7310. return shape;
  7311. }
  7312. function drawShape(cfg, container, isSmooth) {
  7313. var self = this;
  7314. var points = cfg.points;
  7315. var topPoints = [];
  7316. var bottomPoints = [];
  7317. (0, _common.each)(points, function (point) {
  7318. bottomPoints.push(point[0]);
  7319. topPoints.push(point[1]);
  7320. });
  7321. var style = (0, _common.mix)({
  7322. fillStyle: cfg.color
  7323. }, _global["default"].shape.area, cfg.style);
  7324. bottomPoints.reverse();
  7325. topPoints = self.parsePoints(topPoints);
  7326. bottomPoints = self.parsePoints(bottomPoints);
  7327. if (cfg.isInCircle) {
  7328. topPoints.push(topPoints[0]);
  7329. bottomPoints.unshift(bottomPoints[bottomPoints.length - 1]);
  7330. if (equalsCenter(bottomPoints, cfg.center)) {
  7331. bottomPoints = [];
  7332. }
  7333. }
  7334. return drawRectShape(topPoints, bottomPoints, container, style, isSmooth);
  7335. }
  7336. var Area = _shape["default"].registerFactory('area', {
  7337. defaultShapeType: 'area',
  7338. getDefaultPoints: function getDefaultPoints(obj) {
  7339. var x = obj.x;
  7340. var y = obj.y;
  7341. var y0 = obj.y0;
  7342. y = (0, _common.isArray)(y) ? y : [y0, y];
  7343. var points = [];
  7344. points.push({
  7345. x: x,
  7346. y: y[0]
  7347. }, {
  7348. x: x,
  7349. y: y[1]
  7350. });
  7351. return points;
  7352. }
  7353. });
  7354. var SHAPES = ['area', 'smooth'];
  7355. (0, _common.each)(SHAPES, function (shapeType) {
  7356. _shape["default"].registerShape('area', shapeType, {
  7357. draw: function draw(cfg, container) {
  7358. var smooth = shapeType === 'smooth';
  7359. return drawShape.call(this, cfg, container, smooth);
  7360. }
  7361. });
  7362. });
  7363. var _default = Area;
  7364. exports["default"] = _default;
  7365. }, function(modId) { var map = {"../../graphic/util/smooth":1658993502582,"../../graphic/util/bbox":1658993502579,"../../global":1658993502533,"./shape":1658993502556,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  7366. __DEFINE__(1658993502598, function(require, module, exports) {
  7367. exports.__esModule = true;
  7368. exports["default"] = void 0;
  7369. var _base = _interopRequireDefault(require("./base"));
  7370. var _common = require("../util/common");
  7371. var _size = _interopRequireDefault(require("./mixin/size"));
  7372. require("./shape/interval");
  7373. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7374. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7375. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7376. var Interval = /*#__PURE__*/function (_Geom) {
  7377. _inheritsLoose(Interval, _Geom);
  7378. var _proto = Interval.prototype;
  7379. _proto.getDefaultCfg = function getDefaultCfg() {
  7380. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7381. cfg.type = 'interval';
  7382. cfg.shapeType = 'interval';
  7383. cfg.generatePoints = true;
  7384. return cfg;
  7385. };
  7386. function Interval(cfg) {
  7387. var _this;
  7388. _this = _Geom.call(this, cfg) || this;
  7389. (0, _common.mix)(_assertThisInitialized(_this), _size["default"]);
  7390. return _this;
  7391. }
  7392. _proto.init = function init() {
  7393. _Geom.prototype.init.call(this); // 绑定事件
  7394. this.initEvent();
  7395. };
  7396. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  7397. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  7398. cfg.size = this.getNormalizedSize(obj);
  7399. return cfg;
  7400. };
  7401. _proto.clearInner = function clearInner() {
  7402. _Geom.prototype.clearInner.call(this);
  7403. this.set('defaultSize', null);
  7404. };
  7405. return Interval;
  7406. }(_base["default"]);
  7407. _base["default"].Interval = Interval;
  7408. var _default = Interval;
  7409. exports["default"] = _default;
  7410. }, function(modId) { var map = {"./base":1658993502548,"../util/common":1658993502535,"./mixin/size":1658993502599,"./shape/interval":1658993502600}; return __REQUIRE__(map[modId], modId); })
  7411. __DEFINE__(1658993502599, function(require, module, exports) {
  7412. exports.__esModule = true;
  7413. exports["default"] = void 0;
  7414. var _const = require("../../chart/const");
  7415. var _common = require("../../util/common");
  7416. var _global = _interopRequireDefault(require("../../global"));
  7417. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7418. /**
  7419. * @fileOverview Utility for calculate the with ratui in x axis
  7420. * @author sima.zhang1990@gmail.com
  7421. * @author dxq613@gmail.com
  7422. */
  7423. var SizeMixin = {
  7424. initEvent: function initEvent() {
  7425. var _this = this;
  7426. var chart = this.get('chart');
  7427. if (!chart) {
  7428. return;
  7429. }
  7430. chart.on(_const.EVENT_AFTER_SIZE_CHANGE, function () {
  7431. _this.set('_width', null);
  7432. });
  7433. },
  7434. getDefaultSize: function getDefaultSize() {
  7435. var defaultSize = this.get('defaultSize');
  7436. if (!defaultSize) {
  7437. var coord = this.get('coord');
  7438. var xScale = this.getXScale();
  7439. var dataArray = this.get('dataArray');
  7440. var values = (0, _common.uniq)(xScale.values);
  7441. var count = values.length;
  7442. var range = xScale.range;
  7443. var normalizeSize = 1 / count;
  7444. var widthRatio = 1;
  7445. if (coord && coord.isPolar) {
  7446. if (coord.transposed && count > 1) {
  7447. widthRatio = _global["default"].widthRatio.multiplePie;
  7448. } else {
  7449. widthRatio = _global["default"].widthRatio.rose;
  7450. }
  7451. } else {
  7452. if (xScale.isLinear) {
  7453. normalizeSize *= range[1] - range[0];
  7454. }
  7455. widthRatio = _global["default"].widthRatio.column;
  7456. }
  7457. normalizeSize *= widthRatio;
  7458. if (this.hasAdjust('dodge')) {
  7459. normalizeSize = normalizeSize / dataArray.length;
  7460. }
  7461. defaultSize = normalizeSize;
  7462. this.set('defaultSize', defaultSize);
  7463. }
  7464. return defaultSize;
  7465. },
  7466. getDimWidth: function getDimWidth(dimName) {
  7467. var coord = this.get('coord');
  7468. var start = coord.convertPoint({
  7469. x: 0,
  7470. y: 0
  7471. });
  7472. var end = coord.convertPoint({
  7473. x: dimName === 'x' ? 1 : 0,
  7474. y: dimName === 'x' ? 0 : 1
  7475. });
  7476. var width = 0;
  7477. if (start && end) {
  7478. width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
  7479. }
  7480. return width;
  7481. },
  7482. _getWidth: function _getWidth() {
  7483. var width = this.get('_width');
  7484. if (!width) {
  7485. var coord = this.get('coord');
  7486. if (coord && coord.isPolar && !coord.transposed) {
  7487. width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
  7488. } else {
  7489. width = this.getDimWidth('x');
  7490. }
  7491. this.set('_width', width);
  7492. }
  7493. return width;
  7494. },
  7495. _toNormalizedSize: function _toNormalizedSize(size) {
  7496. var width = this._getWidth();
  7497. return size / width;
  7498. },
  7499. _toCoordSize: function _toCoordSize(normalizeSize) {
  7500. var width = this._getWidth();
  7501. return width * normalizeSize;
  7502. },
  7503. getNormalizedSize: function getNormalizedSize(obj) {
  7504. var size = this.getAttrValue('size', obj);
  7505. if ((0, _common.isNil)(size)) {
  7506. size = this.getDefaultSize();
  7507. } else {
  7508. size = this._toNormalizedSize(size);
  7509. }
  7510. return size;
  7511. },
  7512. getSize: function getSize(obj) {
  7513. var size = this.getAttrValue('size', obj);
  7514. if ((0, _common.isNil)(size)) {
  7515. var normalizeSize = this.getDefaultSize();
  7516. size = this._toCoordSize(normalizeSize);
  7517. }
  7518. return size;
  7519. }
  7520. };
  7521. var _default = SizeMixin;
  7522. exports["default"] = _default;
  7523. }, function(modId) { var map = {"../../chart/const":1658993502539,"../../util/common":1658993502535,"../../global":1658993502533}; return __REQUIRE__(map[modId], modId); })
  7524. __DEFINE__(1658993502600, function(require, module, exports) {
  7525. exports.__esModule = true;
  7526. exports["default"] = void 0;
  7527. var _vector = _interopRequireDefault(require("../../graphic/util/vector2"));
  7528. var _global = _interopRequireDefault(require("../../global"));
  7529. var _shape = _interopRequireDefault(require("./shape"));
  7530. var _common = require("../../util/common");
  7531. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7532. function getRectPoints(cfg) {
  7533. var x = cfg.x,
  7534. y = cfg.y,
  7535. y0 = cfg.y0,
  7536. size = cfg.size;
  7537. var ymin = y0;
  7538. var ymax = y;
  7539. if ((0, _common.isArray)(y)) {
  7540. ymax = y[1];
  7541. ymin = y[0];
  7542. }
  7543. var xmin;
  7544. var xmax;
  7545. if ((0, _common.isArray)(x)) {
  7546. xmin = x[0];
  7547. xmax = x[1];
  7548. } else {
  7549. xmin = x - size / 2;
  7550. xmax = x + size / 2;
  7551. }
  7552. return [{
  7553. x: xmin,
  7554. y: ymin
  7555. }, {
  7556. x: xmin,
  7557. y: ymax
  7558. }, {
  7559. x: xmax,
  7560. y: ymax
  7561. }, {
  7562. x: xmax,
  7563. y: ymin
  7564. }];
  7565. }
  7566. function getRectRange(points) {
  7567. var xValues = [];
  7568. var yValues = [];
  7569. for (var i = 0, len = points.length; i < len; i++) {
  7570. var point = points[i];
  7571. xValues.push(point.x);
  7572. yValues.push(point.y);
  7573. }
  7574. var xMin = Math.min.apply(null, xValues);
  7575. var yMin = Math.min.apply(null, yValues);
  7576. var xMax = Math.max.apply(null, xValues);
  7577. var yMax = Math.max.apply(null, yValues);
  7578. return {
  7579. x: xMin,
  7580. y: yMin,
  7581. width: xMax - xMin,
  7582. height: yMax - yMin
  7583. };
  7584. }
  7585. function getMiddlePoint(a, b) {
  7586. var x = (a.x - b.x) / 2 + b.x;
  7587. var y = (a.y - b.y) / 2 + b.y;
  7588. return {
  7589. x: x,
  7590. y: y
  7591. };
  7592. }
  7593. var Interval = _shape["default"].registerFactory('interval', {
  7594. defaultShapeType: 'rect',
  7595. getDefaultPoints: function getDefaultPoints(cfg) {
  7596. return getRectPoints(cfg);
  7597. }
  7598. });
  7599. _shape["default"].registerShape('interval', 'rect', {
  7600. draw: function draw(cfg, container) {
  7601. var points = this.parsePoints(cfg.points);
  7602. var style = (0, _common.mix)({
  7603. fill: cfg.color
  7604. }, _global["default"].shape.interval, cfg.style);
  7605. if (cfg.isInCircle) {
  7606. var newPoints = points.slice(0);
  7607. if (this._coord.transposed) {
  7608. newPoints = [points[0], points[3], points[2], points[1]];
  7609. }
  7610. var _cfg$center = cfg.center,
  7611. x = _cfg$center.x,
  7612. y = _cfg$center.y;
  7613. var v = [1, 0];
  7614. var v0 = [newPoints[0].x - x, newPoints[0].y - y];
  7615. var v1 = [newPoints[1].x - x, newPoints[1].y - y];
  7616. var v2 = [newPoints[2].x - x, newPoints[2].y - y];
  7617. var startAngle = _vector["default"].angleTo(v, v1);
  7618. var endAngle = _vector["default"].angleTo(v, v2);
  7619. var r0 = _vector["default"].length(v0);
  7620. var r = _vector["default"].length(v1);
  7621. if (startAngle >= 1.5 * Math.PI) {
  7622. startAngle = startAngle - 2 * Math.PI;
  7623. }
  7624. if (endAngle >= 1.5 * Math.PI) {
  7625. endAngle = endAngle - 2 * Math.PI;
  7626. }
  7627. return container.addShape('Sector', {
  7628. className: 'interval',
  7629. attrs: (0, _common.mix)({
  7630. x: x,
  7631. y: y,
  7632. r: r,
  7633. r0: r0,
  7634. startAngle: startAngle,
  7635. endAngle: endAngle
  7636. }, style)
  7637. });
  7638. }
  7639. var rectCfg = getRectRange(points);
  7640. return container.addShape('rect', {
  7641. className: 'interval',
  7642. attrs: (0, _common.mix)(rectCfg, style)
  7643. });
  7644. }
  7645. }); // 金字塔 和 漏斗图
  7646. ['pyramid', 'funnel'].forEach(function (shapeType) {
  7647. _shape["default"].registerShape('interval', shapeType, {
  7648. getPoints: function getPoints(cfg) {
  7649. cfg.size = cfg.size * 2; // 漏斗图的 size 是柱状图的两倍
  7650. return getRectPoints(cfg);
  7651. },
  7652. draw: function draw(cfg, container) {
  7653. var points = this.parsePoints(cfg.points);
  7654. var nextPoints = this.parsePoints(cfg.nextPoints);
  7655. var polygonPoints = null;
  7656. if (nextPoints) {
  7657. polygonPoints = [points[0], points[1], nextPoints[1], nextPoints[0]];
  7658. } else {
  7659. polygonPoints = [points[0], points[1]]; // pyramid 顶部是三角形,所以取中心点就好了,funnel顶部是长方形
  7660. if (shapeType === 'pyramid') {
  7661. polygonPoints.push(getMiddlePoint(points[2], points[3]));
  7662. } else {
  7663. polygonPoints.push(points[2], points[3]);
  7664. }
  7665. }
  7666. var attrs = (0, _common.mix)({
  7667. fill: cfg.color,
  7668. points: polygonPoints
  7669. }, _global["default"].shape.interval, cfg.style);
  7670. return container.addShape('polygon', {
  7671. className: 'interval',
  7672. attrs: attrs
  7673. });
  7674. }
  7675. });
  7676. });
  7677. var _default = Interval;
  7678. exports["default"] = _default;
  7679. }, function(modId) { var map = {"../../graphic/util/vector2":1658993502546,"../../global":1658993502533,"./shape":1658993502556,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  7680. __DEFINE__(1658993502601, function(require, module, exports) {
  7681. exports.__esModule = true;
  7682. exports["default"] = void 0;
  7683. var _base = _interopRequireDefault(require("./base"));
  7684. var _common = require("../util/common");
  7685. require("./shape/polygon");
  7686. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7687. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7688. var Polygon = /*#__PURE__*/function (_Geom) {
  7689. _inheritsLoose(Polygon, _Geom);
  7690. function Polygon() {
  7691. return _Geom.apply(this, arguments) || this;
  7692. }
  7693. var _proto = Polygon.prototype;
  7694. _proto.getDefaultCfg = function getDefaultCfg() {
  7695. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7696. cfg.type = 'polygon';
  7697. cfg.shapeType = 'polygon';
  7698. cfg.generatePoints = true;
  7699. return cfg;
  7700. };
  7701. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  7702. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  7703. var self = this;
  7704. var x = cfg.x;
  7705. var y = cfg.y;
  7706. var temp;
  7707. if (!((0, _common.isArray)(x) && (0, _common.isArray)(y))) {
  7708. var xScale = self.getXScale();
  7709. var yScale = self.getYScale();
  7710. var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
  7711. var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
  7712. var xOffset = 0.5 * 1 / xCount;
  7713. var yOffset = 0.5 * 1 / yCount;
  7714. if (xScale.isCategory && yScale.isCategory) {
  7715. x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
  7716. y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
  7717. } else if ((0, _common.isArray)(x)) {
  7718. temp = x;
  7719. x = [temp[0], temp[0], temp[1], temp[1]];
  7720. y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
  7721. } else if ((0, _common.isArray)(y)) {
  7722. temp = y;
  7723. y = [temp[0], temp[1], temp[1], temp[0]];
  7724. x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
  7725. }
  7726. cfg.x = x;
  7727. cfg.y = y;
  7728. }
  7729. return cfg;
  7730. };
  7731. return Polygon;
  7732. }(_base["default"]);
  7733. _base["default"].Polygon = Polygon;
  7734. var _default = Polygon;
  7735. exports["default"] = _default;
  7736. }, function(modId) { var map = {"./base":1658993502548,"../util/common":1658993502535,"./shape/polygon":1658993502602}; return __REQUIRE__(map[modId], modId); })
  7737. __DEFINE__(1658993502602, function(require, module, exports) {
  7738. exports.__esModule = true;
  7739. exports["default"] = void 0;
  7740. var _shape = _interopRequireDefault(require("./shape"));
  7741. var _common = require("../../util/common");
  7742. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7743. var Polygon = _shape["default"].registerFactory('polygon', {
  7744. defaultShapeType: 'polygon',
  7745. getDefaultPoints: function getDefaultPoints(pointInfo) {
  7746. var points = [];
  7747. var x = pointInfo.x,
  7748. y = pointInfo.y;
  7749. for (var i = 0, len = x.length; i < len; i++) {
  7750. points.push({
  7751. x: x[i],
  7752. y: y[i]
  7753. });
  7754. }
  7755. return points;
  7756. }
  7757. });
  7758. _shape["default"].registerShape('polygon', 'polygon', {
  7759. draw: function draw(cfg, container) {
  7760. var points = this.parsePoints(cfg.points);
  7761. var style = (0, _common.mix)({
  7762. fill: cfg.color,
  7763. points: points
  7764. }, cfg.style);
  7765. return container.addShape('Polygon', {
  7766. className: 'polygon',
  7767. attrs: style
  7768. });
  7769. }
  7770. });
  7771. var _default = Polygon;
  7772. exports["default"] = _default;
  7773. }, function(modId) { var map = {"./shape":1658993502556,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  7774. __DEFINE__(1658993502603, function(require, module, exports) {
  7775. exports.__esModule = true;
  7776. exports["default"] = void 0;
  7777. var _base = _interopRequireDefault(require("./base"));
  7778. var _common = require("../util/common");
  7779. var _size = _interopRequireDefault(require("./mixin/size"));
  7780. require("./shape/schema");
  7781. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7782. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7783. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7784. var Schema = /*#__PURE__*/function (_Geom) {
  7785. _inheritsLoose(Schema, _Geom);
  7786. var _proto = Schema.prototype;
  7787. _proto.getDefaultCfg = function getDefaultCfg() {
  7788. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7789. cfg.type = 'schema';
  7790. cfg.shapeType = 'schema';
  7791. cfg.generatePoints = true;
  7792. return cfg;
  7793. };
  7794. function Schema(cfg) {
  7795. var _this;
  7796. _this = _Geom.call(this, cfg) || this;
  7797. (0, _common.mix)(_assertThisInitialized(_this), _size["default"]);
  7798. return _this;
  7799. }
  7800. _proto.init = function init() {
  7801. _Geom.prototype.init.call(this); // 绑定事件
  7802. this.initEvent();
  7803. };
  7804. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  7805. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  7806. cfg.size = this.getNormalizedSize(obj);
  7807. return cfg;
  7808. };
  7809. _proto.clearInner = function clearInner() {
  7810. _Geom.prototype.clearInner.call(this);
  7811. this.set('defaultSize', null);
  7812. };
  7813. return Schema;
  7814. }(_base["default"]);
  7815. _base["default"].Schema = Schema;
  7816. var _default = Schema;
  7817. exports["default"] = _default;
  7818. }, function(modId) { var map = {"./base":1658993502548,"../util/common":1658993502535,"./mixin/size":1658993502599,"./shape/schema":1658993502604}; return __REQUIRE__(map[modId], modId); })
  7819. __DEFINE__(1658993502604, function(require, module, exports) {
  7820. exports.__esModule = true;
  7821. exports["default"] = void 0;
  7822. var _shape = _interopRequireDefault(require("./shape"));
  7823. var _common = require("../../util/common");
  7824. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7825. function _sortValue(value) {
  7826. var sorted = value.sort(function (a, b) {
  7827. return a < b ? 1 : -1;
  7828. });
  7829. var length = sorted.length;
  7830. if (length < 4) {
  7831. var min = sorted[length - 1];
  7832. for (var i = 0; i < 4 - length; i++) {
  7833. sorted.push(min);
  7834. }
  7835. }
  7836. return sorted;
  7837. } // from left bottom corner, and clockwise
  7838. function getCandlePoints(x, y, width) {
  7839. var yValues = _sortValue(y);
  7840. var points = [{
  7841. x: x,
  7842. y: yValues[0]
  7843. }, {
  7844. x: x,
  7845. y: yValues[1]
  7846. }, {
  7847. x: x - width / 2,
  7848. y: yValues[2]
  7849. }, {
  7850. x: x - width / 2,
  7851. y: yValues[1]
  7852. }, {
  7853. x: x + width / 2,
  7854. y: yValues[1]
  7855. }, {
  7856. x: x + width / 2,
  7857. y: yValues[2]
  7858. }, {
  7859. x: x,
  7860. y: yValues[2]
  7861. }, {
  7862. x: x,
  7863. y: yValues[3]
  7864. }];
  7865. return points;
  7866. }
  7867. var Schema = _shape["default"].registerFactory('schema', {});
  7868. _shape["default"].registerShape('schema', 'candle', {
  7869. getPoints: function getPoints(cfg) {
  7870. return getCandlePoints(cfg.x, cfg.y, cfg.size);
  7871. },
  7872. draw: function draw(cfg, container) {
  7873. var points = this.parsePoints(cfg.points);
  7874. var style = (0, _common.mix)({
  7875. stroke: cfg.color,
  7876. fill: cfg.color,
  7877. lineWidth: 1
  7878. }, cfg.style);
  7879. return container.addShape('Custom', {
  7880. className: 'schema',
  7881. attrs: style,
  7882. createPath: function createPath(ctx) {
  7883. ctx.beginPath();
  7884. ctx.moveTo(points[0].x, points[0].y);
  7885. ctx.lineTo(points[1].x, points[1].y);
  7886. ctx.moveTo(points[2].x, points[2].y);
  7887. for (var i = 3; i < 6; i++) {
  7888. ctx.lineTo(points[i].x, points[i].y);
  7889. }
  7890. ctx.closePath();
  7891. ctx.moveTo(points[6].x, points[6].y);
  7892. ctx.lineTo(points[7].x, points[7].y);
  7893. }
  7894. });
  7895. }
  7896. });
  7897. var _default = Schema;
  7898. exports["default"] = _default;
  7899. }, function(modId) { var map = {"./shape":1658993502556,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  7900. __DEFINE__(1658993502605, function(require, module, exports) {
  7901. exports.__esModule = true;
  7902. var _stack = _interopRequireDefault(require("./stack"));
  7903. exports.Stack = _stack["default"];
  7904. var _dodge = _interopRequireDefault(require("./dodge"));
  7905. exports.Dodge = _dodge["default"];
  7906. var _symmetric = _interopRequireDefault(require("./symmetric"));
  7907. exports.Symmetric = _symmetric["default"];
  7908. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7909. }, function(modId) { var map = {"./stack":1658993502606,"./dodge":1658993502607,"./symmetric":1658993502608}; return __REQUIRE__(map[modId], modId); })
  7910. __DEFINE__(1658993502606, function(require, module, exports) {
  7911. exports.__esModule = true;
  7912. exports["default"] = void 0;
  7913. var _stack = _interopRequireDefault(require("@antv/adjust/lib/stack"));
  7914. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7915. var _default = _stack["default"];
  7916. exports["default"] = _default;
  7917. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  7918. __DEFINE__(1658993502607, function(require, module, exports) {
  7919. exports.__esModule = true;
  7920. exports["default"] = void 0;
  7921. var _dodge = _interopRequireDefault(require("@antv/adjust/lib/dodge"));
  7922. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7923. var _default = _dodge["default"];
  7924. exports["default"] = _default;
  7925. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  7926. __DEFINE__(1658993502608, function(require, module, exports) {
  7927. exports.__esModule = true;
  7928. exports["default"] = void 0;
  7929. var _symmetric = _interopRequireDefault(require("@antv/adjust/lib/symmetric"));
  7930. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7931. var _default = _symmetric["default"];
  7932. exports["default"] = _default;
  7933. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  7934. __DEFINE__(1658993502609, function(require, module, exports) {
  7935. exports.__esModule = true;
  7936. exports["default"] = void 0;
  7937. var _base = _interopRequireDefault(require("./base"));
  7938. var _vector = _interopRequireDefault(require("../graphic/util/vector2"));
  7939. var _matrix = _interopRequireDefault(require("../graphic/util/matrix"));
  7940. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7941. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7942. var Polar = /*#__PURE__*/function (_Base) {
  7943. _inheritsLoose(Polar, _Base);
  7944. function Polar() {
  7945. return _Base.apply(this, arguments) || this;
  7946. }
  7947. var _proto = Polar.prototype;
  7948. _proto._initDefaultCfg = function _initDefaultCfg() {
  7949. this.type = 'polar';
  7950. this.startAngle = -Math.PI / 2;
  7951. this.endAngle = Math.PI * 3 / 2;
  7952. this.inner = 0;
  7953. this.innerRadius = 0; // alias
  7954. this.isPolar = true;
  7955. this.transposed = false;
  7956. this.center = null;
  7957. this.radius = null; // relative, 0 ~ 1
  7958. };
  7959. _proto.init = function init(start, end) {
  7960. _Base.prototype.init.call(this, start, end);
  7961. var self = this;
  7962. var inner = self.inner || self.innerRadius;
  7963. var width = Math.abs(end.x - start.x);
  7964. var height = Math.abs(end.y - start.y);
  7965. var maxRadius;
  7966. var center;
  7967. if (self.startAngle === -Math.PI && self.endAngle === 0) {
  7968. maxRadius = Math.min(width / 2, height);
  7969. center = {
  7970. x: (start.x + end.x) / 2,
  7971. y: start.y
  7972. };
  7973. } else {
  7974. maxRadius = Math.min(width, height) / 2;
  7975. center = {
  7976. x: (start.x + end.x) / 2,
  7977. y: (start.y + end.y) / 2
  7978. };
  7979. }
  7980. var radius = self.radius;
  7981. if (radius > 0 && radius <= 1) {
  7982. maxRadius = maxRadius * radius;
  7983. }
  7984. this.x = {
  7985. start: self.startAngle,
  7986. end: self.endAngle
  7987. };
  7988. this.y = {
  7989. start: maxRadius * inner,
  7990. end: maxRadius
  7991. };
  7992. this.center = center;
  7993. this.circleRadius = maxRadius; // the radius value in px
  7994. };
  7995. _proto._convertPoint = function _convertPoint(point) {
  7996. var self = this;
  7997. var center = self.center;
  7998. var transposed = self.transposed;
  7999. var xDim = transposed ? 'y' : 'x';
  8000. var yDim = transposed ? 'x' : 'y';
  8001. var x = self.x;
  8002. var y = self.y;
  8003. var angle = x.start + (x.end - x.start) * point[xDim];
  8004. var radius = y.start + (y.end - y.start) * point[yDim];
  8005. return {
  8006. x: center.x + Math.cos(angle) * radius,
  8007. y: center.y + Math.sin(angle) * radius
  8008. };
  8009. };
  8010. _proto._invertPoint = function _invertPoint(point) {
  8011. var self = this;
  8012. var center = self.center,
  8013. transposed = self.transposed,
  8014. x = self.x,
  8015. y = self.y;
  8016. var xDim = transposed ? 'y' : 'x';
  8017. var yDim = transposed ? 'x' : 'y';
  8018. var m = [1, 0, 0, 1, 0, 0];
  8019. _matrix["default"].rotate(m, m, x.start);
  8020. var startV = [1, 0];
  8021. _vector["default"].transformMat2d(startV, startV, m);
  8022. startV = [startV[0], startV[1]];
  8023. var pointV = [point.x - center.x, point.y - center.y];
  8024. if (_vector["default"].zero(pointV)) {
  8025. return {
  8026. x: 0,
  8027. y: 0
  8028. };
  8029. }
  8030. var theta = _vector["default"].angleTo(startV, pointV, x.end < x.start);
  8031. if (Math.abs(theta - Math.PI * 2) < 0.001) {
  8032. theta = 0;
  8033. }
  8034. var l = _vector["default"].length(pointV);
  8035. var percentX = theta / (x.end - x.start);
  8036. percentX = x.end - x.start > 0 ? percentX : -percentX;
  8037. var percentY = (l - y.start) / (y.end - y.start);
  8038. var rst = {};
  8039. rst[xDim] = percentX;
  8040. rst[yDim] = percentY;
  8041. return rst;
  8042. };
  8043. return Polar;
  8044. }(_base["default"]);
  8045. _base["default"].Polar = Polar;
  8046. var _default = Polar;
  8047. exports["default"] = _default;
  8048. }, function(modId) { var map = {"./base":1658993502544,"../graphic/util/vector2":1658993502546,"../graphic/util/matrix":1658993502545}; return __REQUIRE__(map[modId], modId); })
  8049. __DEFINE__(1658993502610, function(require, module, exports) {
  8050. exports.__esModule = true;
  8051. exports["default"] = void 0;
  8052. var _common = require("../../util/common");
  8053. var _abstract = _interopRequireDefault(require("./abstract"));
  8054. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8055. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8056. var Circle = /*#__PURE__*/function (_Abstract) {
  8057. _inheritsLoose(Circle, _Abstract);
  8058. function Circle() {
  8059. return _Abstract.apply(this, arguments) || this;
  8060. }
  8061. var _proto = Circle.prototype;
  8062. _proto._initDefaultCfg = function _initDefaultCfg() {
  8063. _Abstract.prototype._initDefaultCfg.call(this);
  8064. this.startAngle = -Math.PI / 2; // start angle,in radian
  8065. this.endAngle = Math.PI * 3 / 2; // end angle, in radian
  8066. this.radius = null; // radius
  8067. this.center = null; // center
  8068. };
  8069. _proto.getOffsetPoint = function getOffsetPoint(value) {
  8070. var startAngle = this.startAngle,
  8071. endAngle = this.endAngle;
  8072. var angle = startAngle + (endAngle - startAngle) * value;
  8073. return this._getCirclePoint(angle);
  8074. };
  8075. _proto._getCirclePoint = function _getCirclePoint(angle, radius) {
  8076. var self = this;
  8077. var center = self.center;
  8078. radius = radius || self.radius;
  8079. return {
  8080. x: center.x + Math.cos(angle) * radius,
  8081. y: center.y + Math.sin(angle) * radius
  8082. };
  8083. };
  8084. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  8085. var self = this;
  8086. var offsetVector = self.getOffsetVector(point, offset);
  8087. var align;
  8088. var baseLine = 'middle';
  8089. if (offsetVector[0] > 0) {
  8090. align = 'left';
  8091. } else if (offsetVector[0] < 0) {
  8092. align = 'right';
  8093. } else {
  8094. align = 'center';
  8095. if (offsetVector[1] > 0) {
  8096. baseLine = 'top';
  8097. } else if (offsetVector[1] < 0) {
  8098. baseLine = 'bottom';
  8099. }
  8100. }
  8101. return {
  8102. textAlign: align,
  8103. textBaseline: baseLine
  8104. };
  8105. };
  8106. _proto.getAxisVector = function getAxisVector(point) {
  8107. var center = this.center;
  8108. var factor = this.offsetFactor;
  8109. return [(point.y - center.y) * factor, (point.x - center.x) * -1 * factor];
  8110. };
  8111. _proto.drawLine = function drawLine(lineCfg) {
  8112. var center = this.center,
  8113. radius = this.radius,
  8114. startAngle = this.startAngle,
  8115. endAngle = this.endAngle;
  8116. var container = this.getContainer(lineCfg.top);
  8117. container.addShape('arc', {
  8118. className: 'axis-line',
  8119. attrs: (0, _common.mix)({
  8120. x: center.x,
  8121. y: center.y,
  8122. r: radius,
  8123. startAngle: startAngle,
  8124. endAngle: endAngle
  8125. }, lineCfg)
  8126. });
  8127. };
  8128. return Circle;
  8129. }(_abstract["default"]);
  8130. _abstract["default"].Circle = Circle;
  8131. var _default = Circle;
  8132. exports["default"] = _default;
  8133. }, function(modId) { var map = {"../../util/common":1658993502535,"./abstract":1658993502563}; return __REQUIRE__(map[modId], modId); })
  8134. __DEFINE__(1658993502611, function(require, module, exports) {
  8135. exports.__esModule = true;
  8136. exports["default"] = void 0;
  8137. var _common = require("../../util/common");
  8138. var _base = _interopRequireDefault(require("./base"));
  8139. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8140. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8141. var Arc = /*#__PURE__*/function (_GuideBase) {
  8142. _inheritsLoose(Arc, _GuideBase);
  8143. function Arc() {
  8144. return _GuideBase.apply(this, arguments) || this;
  8145. }
  8146. var _proto = Arc.prototype;
  8147. _proto._initDefaultCfg = function _initDefaultCfg() {
  8148. this.type = 'arc';
  8149. /**
  8150. * start point
  8151. * @type {Array | Function}
  8152. */
  8153. this.start = [];
  8154. /**
  8155. * end point
  8156. * @type {Array | Function}
  8157. */
  8158. this.end = [];
  8159. /**
  8160. * style configuration
  8161. * @type {Object}
  8162. */
  8163. this.style = {
  8164. stroke: '#999',
  8165. lineWidth: 1
  8166. };
  8167. };
  8168. _proto.render = function render(coord, container) {
  8169. var self = this;
  8170. var start = self.parsePoint(coord, self.start);
  8171. var end = self.parsePoint(coord, self.end);
  8172. if (!start || !end) {
  8173. return;
  8174. }
  8175. var coordCenter = coord.center;
  8176. var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
  8177. var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x);
  8178. var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x);
  8179. var shape = container.addShape('arc', {
  8180. className: 'guide-arc',
  8181. attrs: (0, _common.mix)({
  8182. x: coordCenter.x,
  8183. y: coordCenter.y,
  8184. r: radius,
  8185. startAngle: startAngle,
  8186. endAngle: endAngle
  8187. }, self.style)
  8188. });
  8189. self.element = shape;
  8190. return shape;
  8191. };
  8192. return Arc;
  8193. }(_base["default"]);
  8194. _base["default"].Arc = Arc;
  8195. var _default = Arc;
  8196. exports["default"] = _default;
  8197. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8198. __DEFINE__(1658993502612, function(require, module, exports) {
  8199. exports.__esModule = true;
  8200. exports["default"] = void 0;
  8201. var _common = require("../../util/common");
  8202. var KEYWORDS_PERCENT = {
  8203. min: 0,
  8204. median: 0.5,
  8205. max: 1
  8206. };
  8207. var GuideBase = /*#__PURE__*/function () {
  8208. var _proto = GuideBase.prototype;
  8209. _proto._initDefaultCfg = function _initDefaultCfg() {};
  8210. function GuideBase(cfg) {
  8211. this._initDefaultCfg();
  8212. (0, _common.deepMix)(this, cfg);
  8213. }
  8214. _proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
  8215. var rst;
  8216. if ((0, _common.isNil)(KEYWORDS_PERCENT[val])) {
  8217. rst = scale.scale(val);
  8218. } else {
  8219. rst = KEYWORDS_PERCENT[val];
  8220. }
  8221. return rst;
  8222. };
  8223. _proto.parsePercentPoint = function parsePercentPoint(coord, position) {
  8224. var xPercent = parseFloat(position[0]) / 100;
  8225. var yPercent = parseFloat(position[1]) / 100;
  8226. var start = coord.start;
  8227. var end = coord.end;
  8228. var width = Math.abs(start.x - end.x);
  8229. var height = Math.abs(start.y - end.y);
  8230. var x = width * xPercent + Math.min(start.x, end.x);
  8231. var y = height * yPercent + Math.min(start.y, end.y);
  8232. return {
  8233. x: x,
  8234. y: y
  8235. };
  8236. };
  8237. _proto.parsePoint = function parsePoint(coord, position) {
  8238. var self = this;
  8239. var xScale = self.xScale;
  8240. var yScales = self.yScales;
  8241. if ((0, _common.isFunction)(position)) {
  8242. position = position(xScale, yScales); // position 必须是对象
  8243. } // 如果数据格式是 ['50%', '50%'] 的格式
  8244. // fix: 原始数据中可能会包含 'xxx5%xxx' 这样的数据,需要判断下 https://github.com/antvis/f2/issues/590
  8245. if ((0, _common.isString)(position[0]) && position[0].indexOf('%') !== -1 && !isNaN(position[0].slice(0, -1))) {
  8246. return this.parsePercentPoint(coord, position);
  8247. }
  8248. var x = self._getNormalizedValue(position[0], xScale);
  8249. var y = self._getNormalizedValue(position[1], yScales[0]);
  8250. var point = coord.convertPoint({
  8251. x: x,
  8252. y: y
  8253. });
  8254. if (self.limitInPlot) {
  8255. // limit in chart plotRange
  8256. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  8257. return point;
  8258. }
  8259. return null;
  8260. }
  8261. return point;
  8262. }
  8263. /**
  8264. * render the guide component
  8265. * @param {Coord} coord coordinate instance
  8266. * @param {Canvas.Group} group the container
  8267. */
  8268. ;
  8269. _proto.render = function render()
  8270. /* coord,group */
  8271. {};
  8272. _proto.repaint = function repaint() {
  8273. this.remove();
  8274. var coord = this.coord,
  8275. container = this.container,
  8276. canvas = this.canvas;
  8277. if (container && !container.isDestroyed()) {
  8278. this.render(coord, container);
  8279. canvas.draw();
  8280. }
  8281. };
  8282. _proto.remove = function remove() {
  8283. var element = this.element;
  8284. element && element.remove(true);
  8285. };
  8286. _proto.changeVisible = function changeVisible(visible) {
  8287. var self = this;
  8288. self.visible = visible;
  8289. var element = self.element;
  8290. if (!element) return;
  8291. if (element.set) {
  8292. element.set('visible', visible);
  8293. } else {
  8294. element.style.display = visible ? '' : 'none';
  8295. }
  8296. };
  8297. return GuideBase;
  8298. }();
  8299. var _default = GuideBase;
  8300. exports["default"] = _default;
  8301. }, function(modId) { var map = {"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  8302. __DEFINE__(1658993502613, function(require, module, exports) {
  8303. exports.__esModule = true;
  8304. exports["default"] = void 0;
  8305. var _common = require("../../util/common");
  8306. var _base = _interopRequireDefault(require("./base"));
  8307. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8308. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8309. function getOffsetFromAlign(alignX, alignY, width, height) {
  8310. var result = [];
  8311. if (alignX === 'left' && alignY === 'top') {
  8312. result[0] = 0;
  8313. result[1] = 0;
  8314. } else if (alignX === 'right' && alignY === 'top') {
  8315. result[0] = -width;
  8316. result[1] = 0;
  8317. } else if (alignX === 'left' && alignY === 'bottom') {
  8318. result[0] = 0;
  8319. result[1] = Math.floor(-height);
  8320. } else if (alignX === 'right' && alignY === 'bottom') {
  8321. result[0] = Math.floor(-width);
  8322. result[1] = Math.floor(-height);
  8323. } else if (alignX === 'right' && alignY === 'middle') {
  8324. result[0] = Math.floor(-width);
  8325. result[1] = Math.floor(-height / 2);
  8326. } else if (alignX === 'left' && alignY === 'middle') {
  8327. result[0] = 0;
  8328. result[1] = Math.floor(-height / 2);
  8329. } else if (alignX === 'center' && alignY === 'bottom') {
  8330. result[0] = Math.floor(-width / 2);
  8331. result[1] = Math.floor(-height);
  8332. } else if (alignX === 'center' && alignY === 'top') {
  8333. result[0] = Math.floor(-width / 2);
  8334. result[1] = 0;
  8335. } else {
  8336. result[0] = Math.floor(-width / 2);
  8337. result[1] = Math.floor(-height / 2);
  8338. }
  8339. return result;
  8340. }
  8341. function modifyCSS(DOM, CSS) {
  8342. for (var key in CSS) {
  8343. if (CSS.hasOwnProperty(key)) {
  8344. DOM.style[key] = CSS[key];
  8345. }
  8346. }
  8347. return DOM;
  8348. }
  8349. function createDom(str) {
  8350. var container = document.createElement('div');
  8351. str = str.replace(/(^\s*)|(\s*$)/g, '');
  8352. container.innerHTML = '' + str;
  8353. return container.childNodes[0];
  8354. }
  8355. var Html = /*#__PURE__*/function (_GuideBase) {
  8356. _inheritsLoose(Html, _GuideBase);
  8357. function Html() {
  8358. return _GuideBase.apply(this, arguments) || this;
  8359. }
  8360. var _proto = Html.prototype;
  8361. _proto._initDefaultCfg = function _initDefaultCfg() {
  8362. this.type = 'html';
  8363. /**
  8364. * dom position
  8365. * @type {Object | Array}
  8366. */
  8367. this.position = null;
  8368. /**
  8369. * alignment for horizontal direction,can be 'left','center','right'
  8370. * @type {String}
  8371. */
  8372. this.alignX = 'center';
  8373. /**
  8374. * alignment for vertical direction,can be 'top', 'middle', 'bottom'
  8375. * @type {String}
  8376. */
  8377. this.alignY = 'middle';
  8378. /**
  8379. * offset for horizontal direction
  8380. * @type {Number}
  8381. */
  8382. this.offsetX = null;
  8383. /**
  8384. * offset for vertical direction
  8385. * @type {Number}
  8386. */
  8387. this.offsetY = null;
  8388. /**
  8389. * the html string
  8390. *@type {String | Function}
  8391. */
  8392. this.html = null;
  8393. } // override paint
  8394. ;
  8395. _proto.render = function render(coord, container) {
  8396. var self = this;
  8397. var position = self.parsePoint(coord, self.position);
  8398. if (!position) {
  8399. return;
  8400. }
  8401. var myNode = createDom(self.html);
  8402. myNode = modifyCSS(myNode, {
  8403. position: 'absolute',
  8404. top: Math.floor(position.y) + 'px',
  8405. left: Math.floor(position.x) + 'px',
  8406. visibility: 'hidden'
  8407. });
  8408. var canvasDom = container.get('canvas').get('el');
  8409. var parentNode = canvasDom.parentNode;
  8410. parentNode = modifyCSS(parentNode, {
  8411. position: 'relative'
  8412. });
  8413. var wrapperNode = createDom('<div class="guideWapper" style="position: absolute;top: 0; left: 0;"></div>');
  8414. parentNode.appendChild(wrapperNode);
  8415. wrapperNode.appendChild(myNode);
  8416. var canvasOffsetTop = canvasDom.offsetTop;
  8417. var canvasOffsetLeft = canvasDom.offsetLeft;
  8418. var alignX = self.alignX,
  8419. alignY = self.alignY,
  8420. offsetX = self.offsetX,
  8421. offsetY = self.offsetY;
  8422. var width = (0, _common.getWidth)(myNode);
  8423. var height = (0, _common.getHeight)(myNode);
  8424. var newOffset = getOffsetFromAlign(alignX, alignY, width, height);
  8425. position.x = position.x + newOffset[0] + canvasOffsetLeft;
  8426. position.y = position.y + newOffset[1] + canvasOffsetTop;
  8427. if (offsetX) {
  8428. position.x += offsetX;
  8429. }
  8430. if (offsetY) {
  8431. position.y += offsetY;
  8432. }
  8433. modifyCSS(myNode, {
  8434. top: Math.floor(position.y) + 'px',
  8435. left: Math.floor(position.x) + 'px',
  8436. visibility: 'visible'
  8437. });
  8438. self.element = wrapperNode;
  8439. };
  8440. _proto.remove = function remove() {
  8441. var element = this.element;
  8442. element && element.parentNode && element.parentNode.removeChild(element);
  8443. };
  8444. return Html;
  8445. }(_base["default"]);
  8446. _base["default"].Html = Html;
  8447. var _default = Html;
  8448. exports["default"] = _default;
  8449. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8450. __DEFINE__(1658993502614, function(require, module, exports) {
  8451. exports.__esModule = true;
  8452. exports["default"] = void 0;
  8453. var _common = require("../../util/common");
  8454. var _base = _interopRequireDefault(require("./base"));
  8455. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8456. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8457. var Line = /*#__PURE__*/function (_GuideBase) {
  8458. _inheritsLoose(Line, _GuideBase);
  8459. function Line() {
  8460. return _GuideBase.apply(this, arguments) || this;
  8461. }
  8462. var _proto = Line.prototype;
  8463. _proto._initDefaultCfg = function _initDefaultCfg() {
  8464. this.type = 'line';
  8465. this.start = [];
  8466. this.end = [];
  8467. this.style = {
  8468. stroke: '#000',
  8469. lineWidth: 1
  8470. };
  8471. };
  8472. _proto.render = function render(coord, container) {
  8473. var points = [];
  8474. points[0] = this.parsePoint(coord, this.start);
  8475. points[1] = this.parsePoint(coord, this.end);
  8476. if (!points[0] || !points[1]) {
  8477. return;
  8478. }
  8479. var shape = container.addShape('Line', {
  8480. className: 'guide-line',
  8481. attrs: (0, _common.mix)({
  8482. x1: points[0].x,
  8483. y1: points[0].y,
  8484. x2: points[1].x,
  8485. y2: points[1].y
  8486. }, this.style)
  8487. });
  8488. this.element = shape;
  8489. return shape;
  8490. };
  8491. return Line;
  8492. }(_base["default"]);
  8493. _base["default"].Line = Line;
  8494. var _default = Line;
  8495. exports["default"] = _default;
  8496. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8497. __DEFINE__(1658993502615, function(require, module, exports) {
  8498. exports.__esModule = true;
  8499. exports["default"] = void 0;
  8500. var _common = require("../../util/common");
  8501. var _base = _interopRequireDefault(require("./base"));
  8502. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8503. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8504. var Rect = /*#__PURE__*/function (_GuideBase) {
  8505. _inheritsLoose(Rect, _GuideBase);
  8506. function Rect() {
  8507. return _GuideBase.apply(this, arguments) || this;
  8508. }
  8509. var _proto = Rect.prototype;
  8510. _proto._initDefaultCfg = function _initDefaultCfg() {
  8511. this.type = 'rect';
  8512. this.start = [];
  8513. this.end = [];
  8514. this.style = {
  8515. fill: '#CCD7EB',
  8516. opacity: 0.4
  8517. };
  8518. };
  8519. _proto.render = function render(coord, container) {
  8520. var start = this.parsePoint(coord, this.start);
  8521. var end = this.parsePoint(coord, this.end);
  8522. if (!start || !end) {
  8523. return;
  8524. }
  8525. var shape = container.addShape('rect', {
  8526. className: 'guide-rect',
  8527. attrs: (0, _common.mix)({
  8528. x: Math.min(start.x, end.x),
  8529. y: Math.min(start.y, end.y),
  8530. width: Math.abs(end.x - start.x),
  8531. height: Math.abs(start.y - end.y)
  8532. }, this.style)
  8533. });
  8534. this.element = shape;
  8535. return shape;
  8536. };
  8537. return Rect;
  8538. }(_base["default"]);
  8539. _base["default"].Rect = Rect;
  8540. var _default = Rect;
  8541. exports["default"] = _default;
  8542. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8543. __DEFINE__(1658993502616, function(require, module, exports) {
  8544. exports.__esModule = true;
  8545. exports["default"] = void 0;
  8546. var _common = require("../../util/common");
  8547. var _base = _interopRequireDefault(require("./base"));
  8548. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8549. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8550. var Text = /*#__PURE__*/function (_GuideBase) {
  8551. _inheritsLoose(Text, _GuideBase);
  8552. function Text() {
  8553. return _GuideBase.apply(this, arguments) || this;
  8554. }
  8555. var _proto = Text.prototype;
  8556. _proto._initDefaultCfg = function _initDefaultCfg() {
  8557. this.type = 'text';
  8558. /**
  8559. * the position of text
  8560. * @type {Function | Array}
  8561. */
  8562. this.position = null;
  8563. /**
  8564. * the display content
  8565. * @type {String}
  8566. */
  8567. this.content = null;
  8568. /**
  8569. * style configuration for text
  8570. * @type {Object}
  8571. */
  8572. this.style = {
  8573. fill: '#000'
  8574. };
  8575. /**
  8576. * offset of horizontal direction
  8577. * @type {Number}
  8578. */
  8579. this.offsetX = 0;
  8580. /**
  8581. * offset of vertical direction
  8582. * @type {Number}
  8583. */
  8584. this.offsetY = 0;
  8585. };
  8586. _proto.render = function render(coord, container) {
  8587. var position = this.position;
  8588. var point = this.parsePoint(coord, position);
  8589. if (!point) {
  8590. return;
  8591. }
  8592. var content = this.content,
  8593. style = this.style,
  8594. offsetX = this.offsetX,
  8595. offsetY = this.offsetY;
  8596. if (offsetX) {
  8597. point.x += offsetX;
  8598. }
  8599. if (offsetY) {
  8600. point.y += offsetY;
  8601. }
  8602. var shape = container.addShape('text', {
  8603. className: 'guide-text',
  8604. attrs: (0, _common.mix)({
  8605. x: point.x,
  8606. y: point.y,
  8607. text: content
  8608. }, style)
  8609. });
  8610. this.element = shape;
  8611. return shape;
  8612. };
  8613. return Text;
  8614. }(_base["default"]);
  8615. _base["default"].Text = Text;
  8616. var _default = Text;
  8617. exports["default"] = _default;
  8618. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8619. __DEFINE__(1658993502617, function(require, module, exports) {
  8620. exports.__esModule = true;
  8621. exports["default"] = void 0;
  8622. var _common = require("../../util/common");
  8623. var _base = _interopRequireDefault(require("./base"));
  8624. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8625. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8626. var Tag = /*#__PURE__*/function (_GuideBase) {
  8627. _inheritsLoose(Tag, _GuideBase);
  8628. function Tag() {
  8629. return _GuideBase.apply(this, arguments) || this;
  8630. }
  8631. var _proto = Tag.prototype;
  8632. _proto._initDefaultCfg = function _initDefaultCfg() {
  8633. this.type = 'tag';
  8634. this.position = null;
  8635. this.content = null;
  8636. this.direct = 'tl';
  8637. this.autoAdjust = true;
  8638. this.offsetX = 0;
  8639. this.offsetY = 0;
  8640. this.side = 4;
  8641. this.background = {
  8642. padding: 5,
  8643. radius: 2,
  8644. fill: '#1890FF'
  8645. };
  8646. this.textStyle = {
  8647. fontSize: 12,
  8648. fill: '#fff',
  8649. textAlign: 'center',
  8650. textBaseline: 'middle'
  8651. };
  8652. this.withPoint = true;
  8653. this.pointStyle = {
  8654. fill: '#1890FF',
  8655. r: 3,
  8656. lineWidth: 1,
  8657. stroke: '#fff'
  8658. };
  8659. };
  8660. _proto._getDirect = function _getDirect(container, point, tagWidth, tagHeight) {
  8661. var direct = this.direct;
  8662. var side = this.side;
  8663. var canvas = container.get('canvas');
  8664. var clientWidth = canvas.get('width');
  8665. var clientHeight = canvas.get('height');
  8666. var x = point.x,
  8667. y = point.y;
  8668. var vertical = direct[0];
  8669. var horizontal = direct[1]; // adjust for vertical direction
  8670. if (vertical === 't' && y - side - tagHeight < 0) {
  8671. vertical = 'b';
  8672. } else if (vertical === 'b' && y + side + tagHeight > clientHeight) {
  8673. vertical = 't';
  8674. } // adjust for horizontal direction
  8675. var diff = vertical === 'c' ? side : 0;
  8676. if (horizontal === 'l' && x - diff - tagWidth < 0) {
  8677. horizontal = 'r';
  8678. } else if (horizontal === 'r' && x + diff + tagWidth > clientWidth) {
  8679. horizontal = 'l';
  8680. } else if (horizontal === 'c') {
  8681. if (tagWidth / 2 + x + diff > clientWidth) {
  8682. horizontal = 'l';
  8683. } else if (x - tagWidth / 2 - diff < 0) {
  8684. horizontal = 'r';
  8685. }
  8686. }
  8687. direct = vertical + horizontal;
  8688. return direct;
  8689. };
  8690. _proto.render = function render(coord, container) {
  8691. var position = this.parsePoint(coord, this.position);
  8692. if (!position) {
  8693. return;
  8694. } // 数据不在显示范围内时,x/y 会为NaN
  8695. if (isNaN(position.x) || isNaN(position.y)) {
  8696. return;
  8697. }
  8698. var content = this.content,
  8699. background = this.background,
  8700. textStyle = this.textStyle;
  8701. var shapes = [];
  8702. var wrapperContainer = container.addGroup({
  8703. className: 'guide-tag'
  8704. });
  8705. if (this.withPoint) {
  8706. var pointShape = wrapperContainer.addShape('Circle', {
  8707. className: 'guide-tag-point',
  8708. attrs: (0, _common.mix)({
  8709. x: position.x,
  8710. y: position.y
  8711. }, this.pointStyle)
  8712. });
  8713. shapes.push(pointShape);
  8714. }
  8715. var tagContainer = wrapperContainer.addGroup(); // create a text shape
  8716. var tagText = tagContainer.addShape('text', {
  8717. className: 'guide-tag-text',
  8718. zIndex: 1,
  8719. attrs: (0, _common.mix)({
  8720. x: 0,
  8721. y: 0,
  8722. text: content
  8723. }, textStyle)
  8724. });
  8725. shapes.push(tagText); // create background box
  8726. var textBBox = tagText.getBBox();
  8727. var padding = (0, _common.parsePadding)(background.padding);
  8728. var tagWidth = textBBox.width + padding[1] + padding[3];
  8729. var tagHeight = textBBox.height + padding[0] + padding[2];
  8730. var yMin = textBBox.minY - padding[0];
  8731. var xMin = textBBox.minX - padding[3];
  8732. var tagBg = tagContainer.addShape('rect', {
  8733. className: 'guide-tag-bg',
  8734. zIndex: -1,
  8735. attrs: (0, _common.mix)({
  8736. x: xMin,
  8737. y: yMin,
  8738. width: tagWidth,
  8739. height: tagHeight
  8740. }, background)
  8741. });
  8742. shapes.push(tagBg);
  8743. var direct = this.autoAdjust ? this._getDirect(container, position, tagWidth, tagHeight) : this.direct;
  8744. var side = this.side;
  8745. var x = position.x + this.offsetX;
  8746. var y = position.y + this.offsetY;
  8747. var arrowPoints;
  8748. var radius = (0, _common.parsePadding)(background.radius);
  8749. if (direct === 'tl') {
  8750. arrowPoints = [{
  8751. x: tagWidth + xMin - side - 1,
  8752. y: tagHeight + yMin - 1
  8753. }, // 这个 1 是为了防止出现白边
  8754. {
  8755. x: tagWidth + xMin,
  8756. y: tagHeight + yMin - 1
  8757. }, {
  8758. x: tagWidth + xMin,
  8759. y: tagHeight + side + yMin
  8760. }];
  8761. radius[2] = 0;
  8762. x = x - tagWidth;
  8763. y = y - side - tagHeight;
  8764. } else if (direct === 'cl') {
  8765. arrowPoints = [{
  8766. x: tagWidth + xMin - 1,
  8767. y: (tagHeight - side) / 2 + yMin - 1
  8768. }, {
  8769. x: tagWidth + xMin - 1,
  8770. y: (tagHeight + side) / 2 + yMin + 1
  8771. }, {
  8772. x: tagWidth + side + xMin,
  8773. y: tagHeight / 2 + yMin
  8774. }];
  8775. x = x - tagWidth - side;
  8776. y = y - tagHeight / 2;
  8777. } else if (direct === 'bl') {
  8778. arrowPoints = [{
  8779. x: tagWidth + xMin,
  8780. y: -side + yMin
  8781. }, {
  8782. x: tagWidth + xMin - side - 1,
  8783. y: yMin + 1
  8784. }, {
  8785. x: tagWidth + xMin,
  8786. y: yMin + 1
  8787. }];
  8788. radius[1] = 0;
  8789. x = x - tagWidth;
  8790. y = y + side;
  8791. } else if (direct === 'bc') {
  8792. arrowPoints = [{
  8793. x: tagWidth / 2 + xMin,
  8794. y: -side + yMin
  8795. }, {
  8796. x: (tagWidth - side) / 2 + xMin - 1,
  8797. y: yMin + 1
  8798. }, {
  8799. x: (tagWidth + side) / 2 + xMin + 1,
  8800. y: yMin + 1
  8801. }];
  8802. x = x - tagWidth / 2;
  8803. y = y + side;
  8804. } else if (direct === 'br') {
  8805. arrowPoints = [{
  8806. x: xMin,
  8807. y: yMin - side
  8808. }, {
  8809. x: xMin,
  8810. y: yMin + 1
  8811. }, {
  8812. x: xMin + side + 1,
  8813. y: yMin + 1
  8814. }];
  8815. radius[0] = 0;
  8816. y = y + side;
  8817. } else if (direct === 'cr') {
  8818. arrowPoints = [{
  8819. x: xMin - side,
  8820. y: tagHeight / 2 + yMin
  8821. }, {
  8822. x: xMin + 1,
  8823. y: (tagHeight - side) / 2 + yMin - 1
  8824. }, {
  8825. x: xMin + 1,
  8826. y: (tagHeight + side) / 2 + yMin + 1
  8827. }];
  8828. x = x + side;
  8829. y = y - tagHeight / 2;
  8830. } else if (direct === 'tr') {
  8831. arrowPoints = [{
  8832. x: xMin,
  8833. y: tagHeight + side + yMin
  8834. }, {
  8835. x: xMin,
  8836. y: tagHeight + yMin - 1
  8837. }, {
  8838. x: side + xMin + 1,
  8839. y: tagHeight + yMin - 1
  8840. }];
  8841. radius[3] = 0;
  8842. y = y - tagHeight - side;
  8843. } else if (direct === 'tc') {
  8844. arrowPoints = [{
  8845. x: (tagWidth - side) / 2 + xMin - 1,
  8846. y: tagHeight + yMin - 1
  8847. }, {
  8848. x: (tagWidth + side) / 2 + xMin + 1,
  8849. y: tagHeight + yMin - 1
  8850. }, {
  8851. x: tagWidth / 2 + xMin,
  8852. y: tagHeight + side + yMin
  8853. }];
  8854. x = x - tagWidth / 2;
  8855. y = y - tagHeight - side;
  8856. }
  8857. var sideShape = tagContainer.addShape('Polygon', {
  8858. className: 'guide-tag-side',
  8859. zIndex: 0,
  8860. attrs: {
  8861. points: arrowPoints,
  8862. fill: background.fill
  8863. }
  8864. });
  8865. shapes.push(sideShape);
  8866. tagBg.attr('radius', radius);
  8867. tagContainer.moveTo(x - xMin, y - yMin);
  8868. tagContainer.sort();
  8869. this.element = wrapperContainer;
  8870. return shapes;
  8871. };
  8872. return Tag;
  8873. }(_base["default"]);
  8874. _base["default"].Tag = Tag;
  8875. var _default = Tag;
  8876. exports["default"] = _default;
  8877. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8878. __DEFINE__(1658993502618, function(require, module, exports) {
  8879. exports.__esModule = true;
  8880. exports["default"] = void 0;
  8881. var _common = require("../../util/common");
  8882. var _base = _interopRequireDefault(require("./base"));
  8883. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8884. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8885. var Point = /*#__PURE__*/function (_GuideBase) {
  8886. _inheritsLoose(Point, _GuideBase);
  8887. function Point() {
  8888. return _GuideBase.apply(this, arguments) || this;
  8889. }
  8890. var _proto = Point.prototype;
  8891. _proto._initDefaultCfg = function _initDefaultCfg() {
  8892. this.type = 'point';
  8893. this.position = null;
  8894. this.offsetX = 0;
  8895. this.offsetY = 0;
  8896. this.style = {
  8897. fill: '#1890FF',
  8898. r: 3,
  8899. lineWidth: 1,
  8900. stroke: '#fff'
  8901. };
  8902. };
  8903. _proto.render = function render(coord, container) {
  8904. var position = this.parsePoint(coord, this.position);
  8905. if (!position) return null;
  8906. var shape = container.addShape('Circle', {
  8907. className: 'guide-point',
  8908. attrs: (0, _common.mix)({
  8909. x: position.x + this.offsetX,
  8910. y: position.y + this.offsetY
  8911. }, this.style)
  8912. });
  8913. this.element = shape;
  8914. return shape;
  8915. };
  8916. return Point;
  8917. }(_base["default"]);
  8918. _base["default"].Point = Point;
  8919. var _default = Point;
  8920. exports["default"] = _default;
  8921. }, function(modId) { var map = {"../../util/common":1658993502535,"./base":1658993502612}; return __REQUIRE__(map[modId], modId); })
  8922. __DEFINE__(1658993502619, function(require, module, exports) {
  8923. exports.__esModule = true;
  8924. exports["default"] = void 0;
  8925. var _common = require("../util/common");
  8926. var _index = require("../graphic/index");
  8927. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8928. var SYMBOLS = {
  8929. circle: function circle(x, y, r, ctx) {
  8930. ctx.arc(x, y, r, 0, Math.PI * 2, false);
  8931. },
  8932. square: function square(x, y, r, ctx) {
  8933. ctx.moveTo(x - r, y - r);
  8934. ctx.lineTo(x + r, y - r);
  8935. ctx.lineTo(x + r, y + r);
  8936. ctx.lineTo(x - r, y + r);
  8937. ctx.closePath();
  8938. }
  8939. };
  8940. var Marker = /*#__PURE__*/function (_Shape) {
  8941. _inheritsLoose(Marker, _Shape);
  8942. function Marker() {
  8943. return _Shape.apply(this, arguments) || this;
  8944. }
  8945. var _proto = Marker.prototype;
  8946. _proto._initProperties = function _initProperties() {
  8947. _Shape.prototype._initProperties.call(this);
  8948. this._attrs.canFill = true;
  8949. this._attrs.canStroke = true;
  8950. this._attrs.type = 'marker';
  8951. };
  8952. _proto.getDefaultAttrs = function getDefaultAttrs() {
  8953. return {
  8954. x: 0,
  8955. y: 0,
  8956. lineWidth: 0
  8957. };
  8958. };
  8959. _proto.createPath = function createPath(context) {
  8960. var attrs = this.get('attrs');
  8961. var x = attrs.x,
  8962. y = attrs.y,
  8963. radius = attrs.radius;
  8964. var symbol = attrs.symbol || 'circle';
  8965. var method;
  8966. if ((0, _common.isFunction)(symbol)) {
  8967. method = symbol;
  8968. } else {
  8969. method = SYMBOLS[symbol];
  8970. }
  8971. context.beginPath();
  8972. method(x, y, radius, context, this);
  8973. };
  8974. _proto.calculateBox = function calculateBox() {
  8975. var attrs = this.get('attrs');
  8976. var x = attrs.x,
  8977. y = attrs.y,
  8978. radius = attrs.radius;
  8979. return {
  8980. minX: x - radius,
  8981. minY: y - radius,
  8982. maxX: x + radius,
  8983. maxY: y + radius
  8984. };
  8985. };
  8986. return Marker;
  8987. }(_index.Shape);
  8988. var _default = Marker;
  8989. exports["default"] = _default;
  8990. }, function(modId) { var map = {"../util/common":1658993502535,"../graphic/index":1658993502565}; return __REQUIRE__(map[modId], modId); })
  8991. __DEFINE__(1658993502620, function(require, module, exports) {
  8992. exports.__esModule = true;
  8993. exports.init = init;
  8994. exports.afterGeomDraw = afterGeomDraw;
  8995. exports.clearInner = clearInner;
  8996. exports["default"] = void 0;
  8997. var _common = require("../util/common");
  8998. var _global = _interopRequireDefault(require("../global"));
  8999. var _tooltip = _interopRequireDefault(require("../component/tooltip"));
  9000. var _helper = require("../util/helper");
  9001. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9002. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  9003. // Register the default configuration for Tooltip
  9004. _global["default"].tooltip = (0, _common.deepMix)({
  9005. triggerOn: 'press',
  9006. triggerOff: 'pressend',
  9007. alwaysShow: false,
  9008. showTitle: false,
  9009. showCrosshairs: false,
  9010. crosshairsStyle: {
  9011. stroke: 'rgba(0, 0, 0, 0.25)',
  9012. lineWidth: 1
  9013. },
  9014. showTooltipMarker: true,
  9015. background: {
  9016. radius: 1,
  9017. fill: 'rgba(0, 0, 0, 0.65)',
  9018. padding: [3, 5]
  9019. },
  9020. titleStyle: {
  9021. fontSize: 12,
  9022. fill: '#fff',
  9023. textAlign: 'start',
  9024. textBaseline: 'top'
  9025. },
  9026. nameStyle: {
  9027. fontSize: 12,
  9028. fill: 'rgba(255, 255, 255, 0.65)',
  9029. textAlign: 'start',
  9030. textBaseline: 'middle'
  9031. },
  9032. valueStyle: {
  9033. fontSize: 12,
  9034. fill: '#fff',
  9035. textAlign: 'start',
  9036. textBaseline: 'middle'
  9037. },
  9038. showItemMarker: true,
  9039. itemMarkerStyle: {
  9040. radius: 3,
  9041. symbol: 'circle',
  9042. lineWidth: 1,
  9043. stroke: '#fff'
  9044. },
  9045. layout: 'horizontal',
  9046. snap: false
  9047. }, _global["default"].tooltip || {});
  9048. function _getTooltipValueScale(geom) {
  9049. var colorAttr = geom.getAttr('color');
  9050. if (colorAttr) {
  9051. var colorScale = colorAttr.getScale(colorAttr.type);
  9052. if (colorScale.isLinear) {
  9053. return colorScale;
  9054. }
  9055. }
  9056. var xScale = geom.getXScale();
  9057. var yScale = geom.getYScale();
  9058. if (yScale) {
  9059. return yScale;
  9060. }
  9061. return xScale;
  9062. }
  9063. function getTooltipName(geom, origin) {
  9064. var name;
  9065. var nameScale;
  9066. var groupScales = geom._getGroupScales();
  9067. if (groupScales.length) {
  9068. (0, _common.each)(groupScales, function (scale) {
  9069. nameScale = scale;
  9070. return false;
  9071. });
  9072. }
  9073. if (nameScale) {
  9074. var field = nameScale.field;
  9075. name = nameScale.getText(origin[field]);
  9076. } else {
  9077. var valueScale = _getTooltipValueScale(geom);
  9078. name = valueScale.alias || valueScale.field;
  9079. }
  9080. return name;
  9081. }
  9082. function getTooltipValue(geom, origin) {
  9083. var scale = _getTooltipValueScale(geom);
  9084. return scale.getText(origin[scale.field]);
  9085. }
  9086. function getTooltipTitle(geom, origin) {
  9087. var position = geom.getAttr('position');
  9088. var field = position.getFields()[0];
  9089. var scale = geom.get('scales')[field];
  9090. return scale.getText(origin[scale.field]);
  9091. }
  9092. function _indexOfArray(items, item) {
  9093. var rst = -1;
  9094. (0, _common.each)(items, function (sub, index) {
  9095. if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) {
  9096. rst = index;
  9097. return false;
  9098. }
  9099. });
  9100. return rst;
  9101. }
  9102. function _uniqItems(items) {
  9103. var tmp = [];
  9104. (0, _common.each)(items, function (item) {
  9105. var index = _indexOfArray(tmp, item);
  9106. if (index === -1) {
  9107. tmp.push(item);
  9108. } else {
  9109. tmp[index] = item;
  9110. }
  9111. });
  9112. return tmp;
  9113. }
  9114. function isEqual(arr1, arr2) {
  9115. return JSON.stringify(arr1) === JSON.stringify(arr2);
  9116. }
  9117. var TooltipController = /*#__PURE__*/function () {
  9118. function TooltipController(cfg) {
  9119. var _this = this;
  9120. _defineProperty(this, "handleShowEvent", function (ev) {
  9121. var chart = _this.chart;
  9122. if (!_this.enable) return;
  9123. var plot = chart.get('plotRange');
  9124. var point = (0, _common.createEvent)(ev, chart);
  9125. if (!(0, _helper.isPointInPlot)(point, plot) && !_this._tooltipCfg.alwaysShow) {
  9126. // not in chart plot
  9127. _this.hideTooltip();
  9128. return;
  9129. }
  9130. var lastTimeStamp = _this.timeStamp;
  9131. var timeStamp = +new Date();
  9132. if (timeStamp - lastTimeStamp > 16) {
  9133. _this.showTooltip(point);
  9134. _this.timeStamp = timeStamp;
  9135. }
  9136. });
  9137. _defineProperty(this, "handleHideEvent", function () {
  9138. if (!_this.enable) return;
  9139. _this.hideTooltip();
  9140. });
  9141. this.enable = true;
  9142. this.cfg = {};
  9143. this.tooltip = null;
  9144. this.chart = null;
  9145. this.timeStamp = 0;
  9146. (0, _common.mix)(this, cfg);
  9147. var _chart = this.chart;
  9148. var canvas = _chart.get('canvas');
  9149. this.canvas = canvas;
  9150. this.canvasDom = canvas.get('el');
  9151. }
  9152. var _proto = TooltipController.prototype;
  9153. _proto._setCrosshairsCfg = function _setCrosshairsCfg() {
  9154. var self = this;
  9155. var chart = self.chart;
  9156. var defaultCfg = (0, _common.mix)({}, _global["default"].tooltip);
  9157. var geoms = chart.get('geoms');
  9158. var shapes = [];
  9159. (0, _common.each)(geoms, function (geom) {
  9160. var type = geom.get('type');
  9161. if (shapes.indexOf(type) === -1) {
  9162. shapes.push(type);
  9163. }
  9164. });
  9165. var coordType = chart.get('coord').type;
  9166. if (geoms.length && (coordType === 'cartesian' || coordType === 'rect')) {
  9167. if (shapes.length === 1 && ['line', 'area', 'path', 'point'].indexOf(shapes[0]) !== -1) {
  9168. (0, _common.mix)(defaultCfg, {
  9169. showCrosshairs: true
  9170. });
  9171. }
  9172. }
  9173. return defaultCfg;
  9174. };
  9175. _proto._getMaxLength = function _getMaxLength(cfg) {
  9176. if (cfg === void 0) {
  9177. cfg = {};
  9178. }
  9179. var _cfg = cfg,
  9180. layout = _cfg.layout,
  9181. plotRange = _cfg.plotRange;
  9182. return layout === 'horizontal' ? plotRange.br.x - plotRange.bl.x : plotRange.bl.y - plotRange.tr.y;
  9183. };
  9184. _proto.render = function render() {
  9185. var self = this;
  9186. if (self.tooltip) {
  9187. return;
  9188. }
  9189. var chart = self.chart;
  9190. var canvas = chart.get('canvas');
  9191. var frontPlot = chart.get('frontPlot').addGroup({
  9192. className: 'tooltipContainer',
  9193. zIndex: 10
  9194. });
  9195. var backPlot = chart.get('backPlot').addGroup({
  9196. className: 'tooltipContainer'
  9197. });
  9198. var plotRange = chart.get('plotRange');
  9199. var coord = chart.get('coord');
  9200. var defaultCfg = self._setCrosshairsCfg();
  9201. var cfg = self.cfg; // 通过 chart.tooltip() 接口传入的 tooltip 配置项
  9202. var tooltipCfg = (0, _common.deepMix)({
  9203. plotRange: plotRange,
  9204. frontPlot: frontPlot,
  9205. backPlot: backPlot,
  9206. canvas: canvas,
  9207. fixed: coord.transposed || coord.isPolar
  9208. }, defaultCfg, cfg); // 创建 tooltip 实例需要的配置,不应该修改 this.cfg,即用户传入的配置
  9209. tooltipCfg.maxLength = self._getMaxLength(tooltipCfg);
  9210. this._tooltipCfg = tooltipCfg;
  9211. var tooltip = new _tooltip["default"](tooltipCfg);
  9212. self.tooltip = tooltip; // 需要保持tooltip一直显示
  9213. if (tooltipCfg.alwaysShow && self.prePoint) {
  9214. this.showTooltip(self.prePoint);
  9215. }
  9216. self.bindEvents();
  9217. };
  9218. _proto.clear = function clear() {
  9219. var tooltip = this.tooltip;
  9220. if (tooltip) {
  9221. tooltip.destroy();
  9222. this.unBindEvents();
  9223. }
  9224. this.tooltip = null;
  9225. this._lastActive = null;
  9226. };
  9227. _proto._getTooltipMarkerStyle = function _getTooltipMarkerStyle(cfg) {
  9228. if (cfg === void 0) {
  9229. cfg = {};
  9230. }
  9231. var _cfg2 = cfg,
  9232. type = _cfg2.type,
  9233. items = _cfg2.items;
  9234. var tooltipCfg = this._tooltipCfg;
  9235. if (type === 'rect') {
  9236. var x;
  9237. var y;
  9238. var width;
  9239. var height;
  9240. var chart = this.chart;
  9241. var _chart$get = chart.get('plotRange'),
  9242. tl = _chart$get.tl,
  9243. br = _chart$get.br;
  9244. var coord = chart.get('coord');
  9245. var firstItem = items[0];
  9246. var lastItem = items[items.length - 1];
  9247. var intervalWidth = firstItem.width;
  9248. if (coord.transposed) {
  9249. x = tl.x;
  9250. y = lastItem.y - intervalWidth * 0.75;
  9251. width = br.x - tl.x;
  9252. height = firstItem.y - lastItem.y + 1.5 * intervalWidth;
  9253. } else {
  9254. x = firstItem.x - intervalWidth * 0.75;
  9255. y = tl.y;
  9256. width = lastItem.x - firstItem.x + 1.5 * intervalWidth;
  9257. height = br.y - tl.y;
  9258. }
  9259. cfg.style = (0, _common.mix)({
  9260. x: x,
  9261. y: y,
  9262. width: width,
  9263. height: height,
  9264. fill: '#CCD6EC',
  9265. opacity: 0.3
  9266. }, tooltipCfg.tooltipMarkerStyle);
  9267. } else {
  9268. cfg.style = (0, _common.mix)({
  9269. radius: 4,
  9270. fill: '#fff',
  9271. lineWidth: 2
  9272. }, tooltipCfg.tooltipMarkerStyle);
  9273. }
  9274. return cfg;
  9275. };
  9276. _proto._setTooltip = function _setTooltip(point, items, tooltipMarkerCfg) {
  9277. if (tooltipMarkerCfg === void 0) {
  9278. tooltipMarkerCfg = {};
  9279. }
  9280. this.prePoint = point;
  9281. var lastActive = this._lastActive;
  9282. var tooltip = this.tooltip;
  9283. var cfg = this._tooltipCfg;
  9284. items = _uniqItems(items);
  9285. var chart = this.chart;
  9286. var coord = chart.get('coord');
  9287. var yScale = chart.getYScales()[0];
  9288. var snap = cfg.snap;
  9289. if (snap === false && yScale.isLinear) {
  9290. var invertPoint = coord.invertPoint(point);
  9291. var plot = chart.get('plotRange');
  9292. var tip;
  9293. var pos;
  9294. if ((0, _helper.isPointInPlot)(point, plot)) {
  9295. if (coord.transposed) {
  9296. tip = yScale.invert(invertPoint.x);
  9297. pos = point.x;
  9298. tooltip.setXTipContent(tip);
  9299. tooltip.setXTipPosition(pos);
  9300. tooltip.setYCrosshairPosition(pos);
  9301. } else {
  9302. tip = yScale.invert(invertPoint.y);
  9303. pos = point.y;
  9304. tooltip.setYTipContent(tip);
  9305. tooltip.setYTipPosition(pos);
  9306. tooltip.setXCrosshairPosition(pos);
  9307. }
  9308. }
  9309. }
  9310. if (cfg.onShow) {
  9311. cfg.onShow({
  9312. x: point.x,
  9313. y: point.y,
  9314. tooltip: tooltip,
  9315. items: items,
  9316. tooltipMarkerCfg: tooltipMarkerCfg
  9317. });
  9318. }
  9319. if (isEqual(lastActive, items)) {
  9320. if (snap === false && ((0, _common.directionEnabled)(cfg.crosshairsType, 'y') || cfg.showYTip)) {
  9321. var canvas = this.chart.get('canvas');
  9322. canvas.draw();
  9323. }
  9324. return;
  9325. }
  9326. this._lastActive = items;
  9327. var onChange = cfg.onChange;
  9328. if (onChange) {
  9329. onChange({
  9330. x: point.x,
  9331. y: point.y,
  9332. tooltip: tooltip,
  9333. items: items,
  9334. tooltipMarkerCfg: tooltipMarkerCfg
  9335. });
  9336. }
  9337. var first = items[0];
  9338. var title = first.title || first.name;
  9339. var xTipPosX = first.x;
  9340. if (items.length > 1) {
  9341. xTipPosX = (items[0].x + items[items.length - 1].x) / 2;
  9342. }
  9343. tooltip.setContent(title, items, coord.transposed);
  9344. tooltip.setPosition(items, point);
  9345. if (coord.transposed) {
  9346. var yTipPosY = first.y;
  9347. if (items.length > 1) {
  9348. yTipPosY = (items[0].y + items[items.length - 1].y) / 2;
  9349. }
  9350. tooltip.setYTipContent(title);
  9351. tooltip.setYTipPosition(yTipPosY);
  9352. tooltip.setXCrosshairPosition(yTipPosY);
  9353. if (snap) {
  9354. tooltip.setXTipContent(first.value);
  9355. tooltip.setXTipPosition(xTipPosX);
  9356. tooltip.setYCrosshairPosition(xTipPosX);
  9357. }
  9358. } else {
  9359. tooltip.setXTipContent(title);
  9360. tooltip.setXTipPosition(xTipPosX);
  9361. tooltip.setYCrosshairPosition(xTipPosX);
  9362. if (snap) {
  9363. tooltip.setYTipContent(first.value);
  9364. tooltip.setYTipPosition(first.y);
  9365. tooltip.setXCrosshairPosition(first.y);
  9366. }
  9367. }
  9368. var markerItems = tooltipMarkerCfg.items;
  9369. if (cfg.showTooltipMarker && markerItems.length) {
  9370. tooltipMarkerCfg = this._getTooltipMarkerStyle(tooltipMarkerCfg);
  9371. tooltip.setMarkers(tooltipMarkerCfg);
  9372. } else {
  9373. tooltip.clearMarkers();
  9374. }
  9375. tooltip.show();
  9376. };
  9377. _proto.showTooltip = function showTooltip(point) {
  9378. var self = this;
  9379. var chart = self.chart;
  9380. var tooltipMarkerType;
  9381. var tooltipMarkerItems = [];
  9382. var items = [];
  9383. var cfg = self._tooltipCfg;
  9384. var showItemMarker = cfg.showItemMarker,
  9385. itemMarkerStyle = cfg.itemMarkerStyle,
  9386. alwaysShow = cfg.alwaysShow;
  9387. var marker;
  9388. if (showItemMarker) {
  9389. marker = itemMarkerStyle;
  9390. }
  9391. var geoms = chart.get('geoms');
  9392. var coord = chart.get('coord');
  9393. (0, _common.each)(geoms, function (geom) {
  9394. if (geom.get('visible')) {
  9395. var type = geom.get('type');
  9396. var records = geom.getSnapRecords(point);
  9397. var adjust = geom.get('adjust'); // 漏斗图和金子塔图tooltip位置有问题,暂时不开放显示
  9398. if (type === 'interval' && adjust && adjust.type === 'symmetric') {
  9399. return;
  9400. }
  9401. (0, _common.each)(records, function (record) {
  9402. if (record.x && record.y) {
  9403. var x = record.x,
  9404. y = record.y,
  9405. _origin = record._origin,
  9406. color = record.color;
  9407. var tooltipItem = {
  9408. x: x,
  9409. y: (0, _common.isArray)(y) ? y[1] : y,
  9410. color: color || _global["default"].defaultColor,
  9411. origin: _origin,
  9412. name: getTooltipName(geom, _origin),
  9413. value: getTooltipValue(geom, _origin),
  9414. title: getTooltipTitle(geom, _origin)
  9415. };
  9416. if (marker) {
  9417. tooltipItem.marker = (0, _common.mix)({
  9418. fill: color || _global["default"].defaultColor
  9419. }, marker);
  9420. }
  9421. items.push(tooltipItem);
  9422. if (['line', 'area', 'path'].indexOf(type) !== -1) {
  9423. tooltipMarkerType = 'circle';
  9424. tooltipMarkerItems.push(tooltipItem);
  9425. } else if (type === 'interval' && (coord.type === 'cartesian' || coord.type === 'rect')) {
  9426. tooltipMarkerType = 'rect';
  9427. tooltipItem.width = geom.getSize(record._origin);
  9428. tooltipMarkerItems.push(tooltipItem);
  9429. }
  9430. }
  9431. });
  9432. }
  9433. });
  9434. if (items.length) {
  9435. var tooltipMarkerCfg = {
  9436. items: tooltipMarkerItems,
  9437. type: tooltipMarkerType
  9438. };
  9439. self._setTooltip(point, items, tooltipMarkerCfg);
  9440. return;
  9441. }
  9442. if (!alwaysShow) {
  9443. self.hideTooltip();
  9444. }
  9445. };
  9446. _proto.hideTooltip = function hideTooltip() {
  9447. var cfg = this._tooltipCfg;
  9448. this._lastActive = null;
  9449. var tooltip = this.tooltip;
  9450. if (tooltip) {
  9451. tooltip.hide();
  9452. if (cfg.onHide) {
  9453. cfg.onHide({
  9454. tooltip: tooltip
  9455. });
  9456. }
  9457. var canvas = this.chart.get('canvas');
  9458. canvas.draw();
  9459. }
  9460. };
  9461. _proto._handleEvent = function _handleEvent(methodName, method, action) {
  9462. var canvas = this.canvas;
  9463. (0, _common.each)([].concat(methodName), function (aMethod) {
  9464. if (action === 'bind') {
  9465. canvas.on(aMethod, method);
  9466. } else {
  9467. canvas.off(aMethod, method);
  9468. }
  9469. });
  9470. };
  9471. _proto.bindEvents = function bindEvents() {
  9472. var cfg = this._tooltipCfg;
  9473. var triggerOn = cfg.triggerOn,
  9474. triggerOff = cfg.triggerOff,
  9475. alwaysShow = cfg.alwaysShow;
  9476. triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'bind'); // 如果 !alwaysShow, 则在手势离开后就隐藏
  9477. if (!alwaysShow) {
  9478. this._handleEvent(triggerOff, this.handleHideEvent, 'bind');
  9479. }
  9480. };
  9481. _proto.unBindEvents = function unBindEvents() {
  9482. var cfg = this._tooltipCfg;
  9483. var triggerOn = cfg.triggerOn,
  9484. triggerOff = cfg.triggerOff,
  9485. alwaysShow = cfg.alwaysShow;
  9486. triggerOn && this._handleEvent(triggerOn, this.handleShowEvent, 'unBind');
  9487. if (!alwaysShow) {
  9488. this._handleEvent(triggerOff, this.handleHideEvent, 'unBind');
  9489. }
  9490. };
  9491. return TooltipController;
  9492. }();
  9493. function init(chart) {
  9494. var tooltipController = new TooltipController({
  9495. chart: chart
  9496. });
  9497. chart.set('tooltipController', tooltipController);
  9498. chart.tooltip = function (enable, cfg) {
  9499. if ((0, _common.isObject)(enable)) {
  9500. cfg = enable;
  9501. enable = true;
  9502. }
  9503. tooltipController.enable = enable;
  9504. if (cfg) {
  9505. tooltipController.cfg = cfg;
  9506. }
  9507. return this;
  9508. };
  9509. }
  9510. function afterGeomDraw(chart) {
  9511. var tooltipController = chart.get('tooltipController');
  9512. tooltipController.render();
  9513. chart.showTooltip = function (point) {
  9514. tooltipController.showTooltip(point);
  9515. return this;
  9516. };
  9517. chart.hideTooltip = function () {
  9518. tooltipController.hideTooltip();
  9519. return this;
  9520. };
  9521. }
  9522. function clearInner(chart) {
  9523. var tooltipController = chart.get('tooltipController');
  9524. tooltipController.clear();
  9525. }
  9526. var _default = {
  9527. init: init,
  9528. afterGeomDraw: afterGeomDraw,
  9529. clearInner: clearInner
  9530. };
  9531. exports["default"] = _default;
  9532. }, function(modId) { var map = {"../util/common":1658993502535,"../global":1658993502533,"../component/tooltip":1658993502621,"../util/helper":1658993502588}; return __REQUIRE__(map[modId], modId); })
  9533. __DEFINE__(1658993502621, function(require, module, exports) {
  9534. exports.__esModule = true;
  9535. exports["default"] = void 0;
  9536. var _common = require("../util/common");
  9537. var _marker = _interopRequireDefault(require("./marker"));
  9538. var _list = _interopRequireDefault(require("./list"));
  9539. var _textBox = _interopRequireDefault(require("./text-box"));
  9540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9541. var GAP = 4;
  9542. /**
  9543. * TODOList:
  9544. * 1. 移除 fixed 参数
  9545. */
  9546. var Tooltip = /*#__PURE__*/function () {
  9547. var _proto = Tooltip.prototype;
  9548. _proto.getDefaultCfg = function getDefaultCfg() {
  9549. return {
  9550. /**
  9551. * wether show the crosshairs
  9552. * @type {Object}
  9553. */
  9554. showCrosshairs: false,
  9555. /**
  9556. * the style for crosshairs
  9557. * @type {Object}
  9558. */
  9559. crosshairsStyle: {
  9560. stroke: 'rgba(0, 0, 0, 0.25)',
  9561. lineWidth: 1
  9562. },
  9563. /**
  9564. * the type of crosshairs, optional value is 'x', 'y' or 'xy', default is 'y'
  9565. */
  9566. crosshairsType: 'y',
  9567. /**
  9568. * show or hide the x axis tip
  9569. */
  9570. showXTip: false,
  9571. /**
  9572. * show or hide the y axis tip
  9573. */
  9574. showYTip: false,
  9575. xTip: null,
  9576. xTipBackground: {
  9577. radius: 1,
  9578. fill: 'rgba(0, 0, 0, 0.65)',
  9579. padding: [3, 5]
  9580. },
  9581. xTipTextStyle: {
  9582. fontSize: 12,
  9583. fill: '#fff',
  9584. textAlign: 'center',
  9585. textBaseline: 'middle'
  9586. },
  9587. yTip: null,
  9588. yTipBackground: {
  9589. radius: 1,
  9590. fill: 'rgba(0, 0, 0, 0.65)',
  9591. padding: [3, 5]
  9592. },
  9593. yTipTextStyle: {
  9594. fontSize: 12,
  9595. fill: '#fff',
  9596. textAlign: 'center',
  9597. textBaseline: 'middle'
  9598. },
  9599. /**
  9600. * the style for tooltip container's background
  9601. * @type {Object}
  9602. */
  9603. background: null,
  9604. /**
  9605. * layout, can be horizontal or vertical
  9606. * @type {String}
  9607. */
  9608. layout: 'horizontal',
  9609. offsetX: 0,
  9610. offsetY: 0
  9611. };
  9612. };
  9613. function Tooltip(cfg) {
  9614. (0, _common.deepMix)(this, this.getDefaultCfg(), cfg);
  9615. var frontPlot = this.frontPlot,
  9616. custom = this.custom;
  9617. if (!custom) {
  9618. // custom means user do customize
  9619. var container = new _list["default"]((0, _common.mix)({
  9620. parent: frontPlot,
  9621. zIndex: 3
  9622. }, cfg));
  9623. this.container = container;
  9624. var fixed = this.fixed,
  9625. background = this.background;
  9626. if (!fixed) {
  9627. this.tooltipArrow = frontPlot.addShape('Polygon', {
  9628. className: 'tooltip-arrow',
  9629. visible: false,
  9630. zIndex: 2,
  9631. attrs: (0, _common.mix)({
  9632. points: []
  9633. }, background)
  9634. });
  9635. }
  9636. }
  9637. if (this.showXTip) {
  9638. var xTipBackground = this.xTipBackground,
  9639. xTipTextStyle = this.xTipTextStyle;
  9640. var xTipBox = new _textBox["default"]({
  9641. context: frontPlot.get('context'),
  9642. className: 'xTip',
  9643. background: xTipBackground,
  9644. textStyle: xTipTextStyle,
  9645. visible: false
  9646. });
  9647. frontPlot.add(xTipBox.container);
  9648. this.xTipBox = xTipBox;
  9649. }
  9650. if (this.showYTip) {
  9651. var yTipBackground = this.yTipBackground,
  9652. yTipTextStyle = this.yTipTextStyle;
  9653. var yTipBox = new _textBox["default"]({
  9654. context: frontPlot.get('context'),
  9655. className: 'yTip',
  9656. background: yTipBackground,
  9657. textStyle: yTipTextStyle,
  9658. visible: false
  9659. });
  9660. frontPlot.add(yTipBox.container);
  9661. this.yTipBox = yTipBox;
  9662. }
  9663. if (this.showCrosshairs) {
  9664. this._renderCrosshairs();
  9665. }
  9666. frontPlot.sort();
  9667. }
  9668. _proto.setContent = function setContent(title, items) {
  9669. this.title = title;
  9670. this.items = items;
  9671. if (!this.custom) {
  9672. var container = this.container;
  9673. container.setTitle(title);
  9674. container.setItems(items);
  9675. }
  9676. };
  9677. _proto.setYTipContent = function setYTipContent(val) {
  9678. var yTip = this.yTip;
  9679. if ((0, _common.isFunction)(yTip)) {
  9680. val = yTip(val);
  9681. } else {
  9682. val = (0, _common.mix)({
  9683. text: val
  9684. }, yTip);
  9685. }
  9686. this.yTipBox && this.yTipBox.updateContent(val);
  9687. };
  9688. _proto.setYTipPosition = function setYTipPosition(pos) {
  9689. var plotRange = this.plotRange;
  9690. var crosshairsShapeX = this.crosshairsShapeX;
  9691. if (this.showYTip) {
  9692. var yTipBox = this.yTipBox;
  9693. var yTipHeight = yTipBox.getHeight();
  9694. var yTipWidth = yTipBox.getWidth();
  9695. var posX = plotRange.tl.x - yTipWidth;
  9696. var posY = pos - yTipHeight / 2;
  9697. if (posY <= plotRange.tl.y) {
  9698. posY = plotRange.tl.y;
  9699. }
  9700. if (posY + yTipHeight >= plotRange.br.y) {
  9701. posY = plotRange.br.y - yTipHeight;
  9702. }
  9703. if (posX < 0) {
  9704. posX = plotRange.tl.x;
  9705. crosshairsShapeX && crosshairsShapeX.attr('x1', plotRange.tl.x + yTipWidth);
  9706. }
  9707. yTipBox.updatePosition(posX, posY);
  9708. }
  9709. };
  9710. _proto.setXTipContent = function setXTipContent(val) {
  9711. var xTip = this.xTip;
  9712. if ((0, _common.isFunction)(xTip)) {
  9713. val = xTip(val);
  9714. } else {
  9715. val = (0, _common.mix)({
  9716. text: val
  9717. }, xTip);
  9718. }
  9719. this.xTipBox && this.xTipBox.updateContent(val);
  9720. };
  9721. _proto.setXTipPosition = function setXTipPosition(pos) {
  9722. var showXTip = this.showXTip,
  9723. canvas = this.canvas,
  9724. plotRange = this.plotRange,
  9725. xTipBox = this.xTipBox,
  9726. crosshairsShapeY = this.crosshairsShapeY;
  9727. if (showXTip) {
  9728. // const el = canvas.get('el');
  9729. // const canvasHeight = Util.getHeight(el);
  9730. var canvasHeight = canvas.get('height');
  9731. var xTipWidth = xTipBox.getWidth();
  9732. var xTipHeight = xTipBox.getHeight();
  9733. var posX = pos - xTipWidth / 2;
  9734. var posY = plotRange.br.y;
  9735. if (posX <= plotRange.tl.x) {
  9736. posX = plotRange.tl.x;
  9737. }
  9738. if (posX + xTipWidth >= plotRange.tr.x) {
  9739. posX = plotRange.tr.x - xTipWidth;
  9740. }
  9741. if (canvasHeight - posY < xTipHeight) {
  9742. posY -= xTipHeight;
  9743. }
  9744. xTipBox.updatePosition(posX, posY);
  9745. crosshairsShapeY && crosshairsShapeY.attr('y1', posY);
  9746. }
  9747. };
  9748. _proto.setXCrosshairPosition = function setXCrosshairPosition(pos) {
  9749. this.crosshairsShapeX && this.crosshairsShapeX.moveTo(0, pos);
  9750. };
  9751. _proto.setYCrosshairPosition = function setYCrosshairPosition(pos) {
  9752. this.crosshairsShapeY && this.crosshairsShapeY.moveTo(pos, 0);
  9753. };
  9754. _proto.setPosition = function setPosition(items) {
  9755. var container = this.container,
  9756. plotRange = this.plotRange,
  9757. offsetX = this.offsetX,
  9758. offsetY = this.offsetY,
  9759. fixed = this.fixed,
  9760. tooltipArrow = this.tooltipArrow;
  9761. if (!container) {
  9762. return;
  9763. }
  9764. var containerBBox = container.container.getBBox();
  9765. var minX = containerBBox.minX,
  9766. minY = containerBBox.minY,
  9767. width = containerBBox.width,
  9768. height = containerBBox.height;
  9769. var tl = plotRange.tl,
  9770. tr = plotRange.tr;
  9771. var posX = 0;
  9772. var posY = tl.y - height - GAP + offsetY;
  9773. if (fixed) {
  9774. var x = (tl.x + tr.x) / 2;
  9775. posX = x - width / 2 + offsetX;
  9776. } else {
  9777. var _x;
  9778. if (items.length > 1) {
  9779. _x = (items[0].x + items[items.length - 1].x) / 2;
  9780. } else {
  9781. _x = items[0].x;
  9782. }
  9783. posX = _x - width / 2 + offsetX;
  9784. if (posX < tl.x) {
  9785. posX = tl.x;
  9786. }
  9787. if (posX + width > tr.x) {
  9788. posX = tr.x - width;
  9789. }
  9790. if (tooltipArrow) {
  9791. tooltipArrow.attr('points', [{
  9792. x: _x - 3,
  9793. y: tl.y - GAP + offsetY
  9794. }, {
  9795. x: _x + 3,
  9796. y: tl.y - GAP + offsetY
  9797. }, {
  9798. x: _x,
  9799. y: tl.y + offsetY
  9800. }]);
  9801. var backShape = container.backShape;
  9802. var radius = (0, _common.parsePadding)(backShape.attr('radius'));
  9803. if (_x === tl.x) {
  9804. radius[3] = 0;
  9805. tooltipArrow.attr('points', [{
  9806. x: tl.x,
  9807. y: tl.y + offsetY
  9808. }, {
  9809. x: tl.x,
  9810. y: tl.y - GAP + offsetY
  9811. }, {
  9812. x: tl.x + GAP,
  9813. y: tl.y - GAP + offsetY
  9814. }]);
  9815. } else if (_x === tr.x) {
  9816. radius[2] = 0;
  9817. tooltipArrow.attr('points', [{
  9818. x: tr.x,
  9819. y: tl.y + offsetY
  9820. }, {
  9821. x: tr.x - GAP,
  9822. y: tl.y - GAP + offsetY
  9823. }, {
  9824. x: tr.x,
  9825. y: tl.y - GAP + offsetY
  9826. }]);
  9827. }
  9828. backShape.attr('radius', radius);
  9829. }
  9830. }
  9831. container.moveTo(posX - minX, posY - minY);
  9832. };
  9833. _proto.setMarkers = function setMarkers(cfg) {
  9834. if (cfg === void 0) {
  9835. cfg = {};
  9836. }
  9837. var self = this;
  9838. var _cfg = cfg,
  9839. items = _cfg.items,
  9840. style = _cfg.style,
  9841. type = _cfg.type;
  9842. var markerGroup = self._getMarkerGroup(type);
  9843. if (type === 'circle') {
  9844. for (var i = 0, length = items.length; i < length; i++) {
  9845. var item = items[i];
  9846. var marker = new _marker["default"]({
  9847. className: 'tooltip-circle-marker',
  9848. attrs: (0, _common.mix)({
  9849. x: item.x,
  9850. y: item.y,
  9851. stroke: item.color
  9852. }, style)
  9853. });
  9854. markerGroup.add(marker);
  9855. }
  9856. } else {
  9857. markerGroup.addShape('rect', {
  9858. className: 'tooltip-rect-marker',
  9859. attrs: style
  9860. });
  9861. }
  9862. };
  9863. _proto.clearMarkers = function clearMarkers() {
  9864. var markerGroup = this.markerGroup;
  9865. markerGroup && markerGroup.clear();
  9866. };
  9867. _proto.show = function show() {
  9868. var crosshairsShapeX = this.crosshairsShapeX;
  9869. var crosshairsShapeY = this.crosshairsShapeY;
  9870. var markerGroup = this.markerGroup;
  9871. var container = this.container;
  9872. var tooltipArrow = this.tooltipArrow;
  9873. var xTipBox = this.xTipBox;
  9874. var yTipBox = this.yTipBox;
  9875. var canvas = this.canvas;
  9876. crosshairsShapeX && crosshairsShapeX.show();
  9877. crosshairsShapeY && crosshairsShapeY.show();
  9878. markerGroup && markerGroup.show();
  9879. container && container.show();
  9880. tooltipArrow && tooltipArrow.show();
  9881. xTipBox && xTipBox.show();
  9882. yTipBox && yTipBox.show();
  9883. canvas.draw();
  9884. };
  9885. _proto.hide = function hide() {
  9886. var crosshairsShapeX = this.crosshairsShapeX;
  9887. var crosshairsShapeY = this.crosshairsShapeY;
  9888. var markerGroup = this.markerGroup;
  9889. var container = this.container;
  9890. var tooltipArrow = this.tooltipArrow;
  9891. var xTipBox = this.xTipBox;
  9892. var yTipBox = this.yTipBox;
  9893. crosshairsShapeX && crosshairsShapeX.hide();
  9894. crosshairsShapeY && crosshairsShapeY.hide();
  9895. markerGroup && markerGroup.hide();
  9896. container && container.hide();
  9897. tooltipArrow && tooltipArrow.hide();
  9898. xTipBox && xTipBox.hide();
  9899. yTipBox && yTipBox.hide();
  9900. };
  9901. _proto.destroy = function destroy() {
  9902. var crosshairsShapeX = this.crosshairsShapeX;
  9903. var crosshairsShapeY = this.crosshairsShapeY;
  9904. var markerGroup = this.markerGroup;
  9905. var container = this.container;
  9906. var tooltipArrow = this.tooltipArrow;
  9907. var xTipBox = this.xTipBox;
  9908. var yTipBox = this.yTipBox;
  9909. crosshairsShapeX && crosshairsShapeX.remove(true);
  9910. crosshairsShapeY && crosshairsShapeY.remove(true);
  9911. markerGroup && markerGroup.remove(true);
  9912. tooltipArrow && tooltipArrow.remove(true);
  9913. container && container.clear();
  9914. xTipBox && xTipBox.clear();
  9915. yTipBox && yTipBox.clear();
  9916. this.destroyed = true;
  9917. };
  9918. _proto._getMarkerGroup = function _getMarkerGroup(type) {
  9919. var markerGroup = this.markerGroup;
  9920. if (!markerGroup) {
  9921. if (type === 'circle') {
  9922. markerGroup = this.frontPlot.addGroup({
  9923. zIndex: 1
  9924. });
  9925. this.frontPlot.sort();
  9926. } else {
  9927. markerGroup = this.backPlot.addGroup();
  9928. }
  9929. this.markerGroup = markerGroup;
  9930. } else {
  9931. markerGroup.clear();
  9932. }
  9933. return markerGroup;
  9934. };
  9935. _proto._renderCrosshairs = function _renderCrosshairs() {
  9936. var crosshairsType = this.crosshairsType,
  9937. crosshairsStyle = this.crosshairsStyle,
  9938. frontPlot = this.frontPlot,
  9939. plotRange = this.plotRange;
  9940. var tl = plotRange.tl,
  9941. br = plotRange.br;
  9942. if ((0, _common.directionEnabled)(crosshairsType, 'x')) {
  9943. this.crosshairsShapeX = frontPlot.addShape('Line', {
  9944. className: 'tooltip-crosshairs-x',
  9945. zIndex: 0,
  9946. visible: false,
  9947. attrs: (0, _common.mix)({
  9948. x1: tl.x,
  9949. y1: 0,
  9950. x2: br.x,
  9951. y2: 0
  9952. }, crosshairsStyle)
  9953. });
  9954. }
  9955. if ((0, _common.directionEnabled)(crosshairsType, 'y')) {
  9956. this.crosshairsShapeY = frontPlot.addShape('Line', {
  9957. className: 'tooltip-crosshairs-y',
  9958. zIndex: 0,
  9959. visible: false,
  9960. attrs: (0, _common.mix)({
  9961. x1: 0,
  9962. y1: br.y,
  9963. x2: 0,
  9964. y2: tl.y
  9965. }, crosshairsStyle)
  9966. });
  9967. }
  9968. };
  9969. return Tooltip;
  9970. }();
  9971. var _default = Tooltip;
  9972. exports["default"] = _default;
  9973. }, function(modId) { var map = {"../util/common":1658993502535,"./marker":1658993502619,"./list":1658993502622,"./text-box":1658993502623}; return __REQUIRE__(map[modId], modId); })
  9974. __DEFINE__(1658993502622, function(require, module, exports) {
  9975. exports.__esModule = true;
  9976. exports["default"] = void 0;
  9977. var _common = require("../util/common");
  9978. var _index = require("../graphic/index");
  9979. var _marker = _interopRequireDefault(require("./marker"));
  9980. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  9981. var MARKER_RADIUS = 3;
  9982. var List = /*#__PURE__*/function () {
  9983. var _proto = List.prototype;
  9984. _proto.getDefaultCfg = function getDefaultCfg() {
  9985. return {
  9986. showTitle: false,
  9987. /**
  9988. * title string
  9989. * @type {?String}
  9990. */
  9991. title: null,
  9992. /**
  9993. * items array
  9994. * @type {?Array}
  9995. */
  9996. items: null,
  9997. /**
  9998. * offset between title and items
  9999. * @type {Number}
  10000. */
  10001. titleGap: 12,
  10002. /**
  10003. * offset between each item
  10004. * @type {Number}
  10005. */
  10006. itemGap: 10,
  10007. /**
  10008. * the offset between each item in vertical direaction
  10009. * @type {Number}
  10010. */
  10011. itemMarginBottom: 12,
  10012. /**
  10013. * the formatter for item text
  10014. * @type {[type]}
  10015. */
  10016. itemFormatter: null,
  10017. itemWidth: null,
  10018. /**
  10019. * offset between marker and text
  10020. * @type {Number}
  10021. */
  10022. wordSpace: 6,
  10023. x: 0,
  10024. y: 0,
  10025. layout: 'horizontal',
  10026. /**
  10027. * the join string of `name` and `value`
  10028. * @type {String}
  10029. */
  10030. joinString: ': '
  10031. };
  10032. };
  10033. function List(cfg) {
  10034. (0, _common.deepMix)(this, this.getDefaultCfg(), cfg);
  10035. this._init();
  10036. this._renderTitle();
  10037. this._renderItems();
  10038. }
  10039. _proto._init = function _init() {
  10040. var container = new _index.Group({
  10041. zIndex: this.zIndex || 0
  10042. });
  10043. this.container = container;
  10044. var wrapper = container.addGroup();
  10045. this.wrapper = wrapper;
  10046. var itemsGroup = wrapper.addGroup({
  10047. className: 'itemsGroup'
  10048. });
  10049. this.itemsGroup = itemsGroup;
  10050. if (this.parent) {
  10051. this.parent.add(container);
  10052. }
  10053. };
  10054. _proto._renderTitle = function _renderTitle(title) {
  10055. title = title || this.title;
  10056. var titleShape = this.titleShape;
  10057. var titleHeight = 0;
  10058. if (this.showTitle && title) {
  10059. if (titleShape && !titleShape.get('destroyed')) {
  10060. titleShape.attr('text', title);
  10061. } else {
  10062. var wrapper = this.wrapper,
  10063. titleStyle = this.titleStyle;
  10064. titleShape = wrapper.addShape('text', {
  10065. className: 'title',
  10066. attrs: (0, _common.mix)({
  10067. x: 0,
  10068. y: 0,
  10069. text: title
  10070. }, titleStyle)
  10071. });
  10072. this.titleShape = titleShape;
  10073. }
  10074. titleHeight = titleShape.getBBox().height + this.titleGap;
  10075. }
  10076. this._titleHeight = titleHeight;
  10077. };
  10078. _proto._renderItems = function _renderItems(items) {
  10079. var self = this;
  10080. items = items || self.items;
  10081. if (!items) {
  10082. return;
  10083. }
  10084. if (self.reversed) {
  10085. items.reverse();
  10086. }
  10087. (0, _common.each)(items, function (item, index) {
  10088. self._addItem(item, index);
  10089. });
  10090. if (items.length > 1) {
  10091. this._adjustItems();
  10092. }
  10093. this._renderBackground();
  10094. };
  10095. _proto._renderBackground = function _renderBackground() {
  10096. var background = this.background;
  10097. if (background) {
  10098. var container = this.container;
  10099. var wrapper = this.wrapper;
  10100. var _wrapper$getBBox = wrapper.getBBox(),
  10101. minX = _wrapper$getBBox.minX,
  10102. minY = _wrapper$getBBox.minY,
  10103. width = _wrapper$getBBox.width,
  10104. height = _wrapper$getBBox.height;
  10105. var padding = background.padding || [0, 0, 0, 0];
  10106. padding = (0, _common.parsePadding)(padding);
  10107. var attrs = (0, _common.mix)({
  10108. x: minX - padding[3],
  10109. y: minY - padding[0],
  10110. width: width + padding[1] + padding[3],
  10111. height: height + padding[0] + padding[2]
  10112. }, background);
  10113. var backShape = this.backShape;
  10114. if (backShape) {
  10115. backShape.attr(attrs);
  10116. } else {
  10117. backShape = container.addShape('Rect', {
  10118. zIndex: -1,
  10119. attrs: attrs
  10120. });
  10121. }
  10122. this.backShape = backShape;
  10123. container.sort();
  10124. }
  10125. };
  10126. _proto._addItem = function _addItem(item) {
  10127. var itemsGroup = this.itemsGroup;
  10128. var itemGroup = itemsGroup.addGroup({
  10129. name: item.name,
  10130. value: item.value,
  10131. dataValue: item.dataValue,
  10132. checked: item.checked
  10133. });
  10134. var unCheckStyle = this.unCheckStyle,
  10135. unCheckColor = this.unCheckColor,
  10136. nameStyle = this.nameStyle,
  10137. valueStyle = this.valueStyle,
  10138. wordSpace = this.wordSpace;
  10139. var marker = item.marker,
  10140. value = item.value;
  10141. var startX = 0;
  10142. if (unCheckColor) {
  10143. unCheckStyle.fill = unCheckColor;
  10144. }
  10145. if (marker) {
  10146. var radius = marker.radius || MARKER_RADIUS;
  10147. var markerAttrs = (0, _common.mix)({
  10148. x: radius,
  10149. y: this._titleHeight
  10150. }, marker);
  10151. if (item.checked === false) {
  10152. (0, _common.mix)(markerAttrs, unCheckStyle);
  10153. }
  10154. var markerShape = new _marker["default"]({
  10155. className: 'item-marker',
  10156. attrs: markerAttrs
  10157. });
  10158. itemGroup.add(markerShape);
  10159. startX += markerShape.getBBox().width + wordSpace;
  10160. }
  10161. var nameText;
  10162. var name = item.name;
  10163. if (name) {
  10164. var joinString = this.joinString || '';
  10165. name = value ? name + joinString : name;
  10166. nameText = itemGroup.addShape('text', {
  10167. className: 'name',
  10168. attrs: (0, _common.mix)({
  10169. x: startX,
  10170. y: this._titleHeight,
  10171. text: this._formatItemValue(name)
  10172. }, nameStyle, item.checked === false ? unCheckStyle : null)
  10173. });
  10174. }
  10175. if (value) {
  10176. var valueX = startX;
  10177. if (nameText) {
  10178. valueX += nameText.getBBox().width;
  10179. }
  10180. itemGroup.addShape('text', {
  10181. className: 'value',
  10182. attrs: (0, _common.mix)({
  10183. x: valueX,
  10184. y: this._titleHeight,
  10185. text: value
  10186. }, valueStyle, item.checked === false ? unCheckStyle : null)
  10187. });
  10188. }
  10189. return itemGroup;
  10190. };
  10191. _proto._formatItemValue = function _formatItemValue(value) {
  10192. var formatter = this.itemFormatter;
  10193. if (formatter) {
  10194. value = formatter.call(this, value);
  10195. }
  10196. return value;
  10197. };
  10198. _proto._getMaxItemWidth = function _getMaxItemWidth() {
  10199. var width;
  10200. var itemWidth = this.itemWidth;
  10201. if ((0, _common.isNumber)(itemWidth) || (0, _common.isNil)(itemWidth)) {
  10202. return itemWidth;
  10203. }
  10204. if (itemWidth === 'auto') {
  10205. var itemsGroup = this.itemsGroup;
  10206. var children = itemsGroup.get('children');
  10207. var count = children.length;
  10208. var maxItemWidth = 0;
  10209. for (var i = 0; i < count; i++) {
  10210. var _children$i$getBBox = children[i].getBBox(),
  10211. _width = _children$i$getBBox.width;
  10212. maxItemWidth = Math.max(maxItemWidth, _width);
  10213. }
  10214. var maxLength = this.maxLength;
  10215. var itemGap = this.itemGap;
  10216. var twoAvgWidth = (maxLength - itemGap) / 2;
  10217. var threeAvgWidth = (maxLength - itemGap * 2) / 3;
  10218. if (count === 2) {
  10219. width = Math.max(maxItemWidth, twoAvgWidth);
  10220. } else {
  10221. // 1. max <= 3Avg, 3Avg
  10222. // 2. 3Avg < max && max < 2avg, 2avg
  10223. // 3. max > 2avg, max, one column
  10224. if (maxItemWidth <= threeAvgWidth) {
  10225. width = threeAvgWidth;
  10226. } else if (maxItemWidth <= twoAvgWidth) {
  10227. width = twoAvgWidth;
  10228. } else {
  10229. width = maxItemWidth;
  10230. }
  10231. }
  10232. return width;
  10233. }
  10234. };
  10235. _proto._adjustHorizontal = function _adjustHorizontal() {
  10236. var maxLength = this.maxLength,
  10237. itemsGroup = this.itemsGroup;
  10238. var children = itemsGroup.get('children');
  10239. var itemGap = this.itemGap,
  10240. itemMarginBottom = this.itemMarginBottom;
  10241. var titleHeight = this._titleHeight;
  10242. var row = 0;
  10243. var rowWidth = 0;
  10244. var width;
  10245. var height;
  10246. var itemWidth = this._getMaxItemWidth();
  10247. var legendHitBoxes = [];
  10248. for (var i = 0, len = children.length; i < len; i++) {
  10249. var child = children[i];
  10250. var box = child.getBBox();
  10251. var childHeight = box.height;
  10252. var childWidth = box.width;
  10253. width = itemWidth || childWidth;
  10254. height = childHeight + itemMarginBottom;
  10255. if (width - (maxLength - rowWidth) > 0.0001) {
  10256. row++;
  10257. rowWidth = 0;
  10258. }
  10259. child.moveTo(rowWidth, row * height);
  10260. legendHitBoxes.push({
  10261. x: rowWidth,
  10262. y: row * height + titleHeight - childHeight / 2,
  10263. width: childWidth * 1.375,
  10264. height: childHeight * 1.375
  10265. });
  10266. rowWidth += width + itemGap;
  10267. }
  10268. this.legendHitBoxes = legendHitBoxes;
  10269. return;
  10270. };
  10271. _proto._adjustVertical = function _adjustVertical() {
  10272. var maxLength = this.maxLength,
  10273. itemsGroup = this.itemsGroup;
  10274. var itemGap = this.itemGap,
  10275. itemMarginBottom = this.itemMarginBottom,
  10276. itemWidth = this.itemWidth;
  10277. var titleHeight = this._titleHeight;
  10278. var children = itemsGroup.get('children');
  10279. var colHeight = 0;
  10280. var width;
  10281. var height;
  10282. var maxItemWidth = 0;
  10283. var totalWidth = 0;
  10284. var legendHitBoxes = [];
  10285. for (var i = 0, length = children.length; i < length; i++) {
  10286. var child = children[i];
  10287. var bbox = child.getBBox();
  10288. width = bbox.width;
  10289. height = bbox.height;
  10290. if ((0, _common.isNumber)(itemWidth)) {
  10291. maxItemWidth = itemWidth + itemGap;
  10292. } else if (width > maxItemWidth) {
  10293. maxItemWidth = width + itemGap;
  10294. }
  10295. if (maxLength - colHeight < height) {
  10296. colHeight = 0;
  10297. totalWidth += maxItemWidth;
  10298. child.moveTo(totalWidth, 0);
  10299. legendHitBoxes.push({
  10300. x: totalWidth,
  10301. y: titleHeight - height / 2,
  10302. width: width * 1.375,
  10303. height: height * 1.375
  10304. });
  10305. } else {
  10306. child.moveTo(totalWidth, colHeight);
  10307. legendHitBoxes.push({
  10308. x: totalWidth,
  10309. y: colHeight - height / 2 + titleHeight,
  10310. width: width * 1.375,
  10311. height: height * 1.375
  10312. });
  10313. }
  10314. colHeight += height + itemMarginBottom;
  10315. }
  10316. this.legendHitBoxes = legendHitBoxes;
  10317. return;
  10318. };
  10319. _proto._adjustItems = function _adjustItems() {
  10320. var layout = this.layout;
  10321. if (layout === 'horizontal') {
  10322. this._adjustHorizontal();
  10323. } else {
  10324. this._adjustVertical();
  10325. }
  10326. };
  10327. _proto.moveTo = function moveTo(x, y) {
  10328. this.x = x;
  10329. this.y = y;
  10330. var container = this.container;
  10331. container && container.moveTo(x, y);
  10332. return this;
  10333. };
  10334. _proto.setItems = function setItems(items) {
  10335. this.clearItems();
  10336. this._renderItems(items);
  10337. };
  10338. _proto.setTitle = function setTitle(title) {
  10339. this._renderTitle(title);
  10340. };
  10341. _proto.clearItems = function clearItems() {
  10342. var itemsGroup = this.itemsGroup;
  10343. itemsGroup.clear();
  10344. };
  10345. _proto.getWidth = function getWidth() {
  10346. var container = this.container;
  10347. var bbox = container.getBBox();
  10348. return bbox.width;
  10349. };
  10350. _proto.getHeight = function getHeight() {
  10351. var container = this.container;
  10352. var bbox = container.getBBox();
  10353. return bbox.height;
  10354. };
  10355. _proto.show = function show() {
  10356. var container = this.container;
  10357. container.show();
  10358. };
  10359. _proto.hide = function hide() {
  10360. var container = this.container;
  10361. container.hide();
  10362. };
  10363. _proto.clear = function clear() {
  10364. var container = this.container;
  10365. container.clear();
  10366. container.remove(true);
  10367. };
  10368. return List;
  10369. }();
  10370. var _default = List;
  10371. exports["default"] = _default;
  10372. }, function(modId) { var map = {"../util/common":1658993502535,"../graphic/index":1658993502565,"./marker":1658993502619}; return __REQUIRE__(map[modId], modId); })
  10373. __DEFINE__(1658993502623, function(require, module, exports) {
  10374. exports.__esModule = true;
  10375. exports["default"] = void 0;
  10376. var _common = require("../util/common");
  10377. var _index = require("../graphic/index");
  10378. var TextBox = /*#__PURE__*/function () {
  10379. var _proto = TextBox.prototype;
  10380. _proto.getDefaultCfg = function getDefaultCfg() {
  10381. return {
  10382. x: 0,
  10383. y: 0,
  10384. content: '',
  10385. textStyle: {
  10386. fontSize: 12,
  10387. fill: '#fff',
  10388. textAlign: 'center',
  10389. textBaseline: 'middle',
  10390. fontFamily: 'Arial'
  10391. },
  10392. background: {
  10393. radius: 1,
  10394. fill: 'rgba(0, 0, 0, 0.65)',
  10395. padding: [3, 5]
  10396. },
  10397. width: 0,
  10398. height: 0,
  10399. className: ''
  10400. };
  10401. };
  10402. function TextBox(cfg) {
  10403. (0, _common.deepMix)(this, this.getDefaultCfg(), cfg);
  10404. this._init();
  10405. var content = this.content,
  10406. x = this.x,
  10407. y = this.y;
  10408. if (!(0, _common.isNil)(content)) {
  10409. this.updateContent(content);
  10410. }
  10411. this.updatePosition(x, y);
  10412. }
  10413. _proto._init = function _init() {
  10414. var content = this.content,
  10415. textStyle = this.textStyle,
  10416. background = this.background,
  10417. className = this.className,
  10418. visible = this.visible,
  10419. context = this.context;
  10420. var container = new _index.Group({
  10421. context: context,
  10422. className: className,
  10423. zIndex: 0,
  10424. visible: visible
  10425. });
  10426. var text = container.addShape('Text', {
  10427. className: className + '-text',
  10428. zIndex: 1,
  10429. attrs: (0, _common.mix)({
  10430. text: content,
  10431. x: 0,
  10432. y: 0
  10433. }, textStyle)
  10434. });
  10435. var backgroundShape = container.addShape('Rect', {
  10436. className: className + '-bg',
  10437. zIndex: -1,
  10438. attrs: (0, _common.mix)({
  10439. x: 0,
  10440. y: 0,
  10441. width: 0,
  10442. height: 0
  10443. }, background)
  10444. });
  10445. container.sort();
  10446. this.container = container;
  10447. this.textShape = text;
  10448. this.backgroundShape = backgroundShape;
  10449. };
  10450. _proto._getBBox = function _getBBox() {
  10451. var textShape = this.textShape;
  10452. var background = this.background;
  10453. var textBBox = textShape.getBBox();
  10454. var padding = (0, _common.parsePadding)(background.padding);
  10455. var width = textBBox.width + padding[1] + padding[3];
  10456. var height = textBBox.height + padding[0] + padding[2];
  10457. var x = textBBox.minX - padding[3];
  10458. var y = textBBox.minY - padding[0];
  10459. return {
  10460. x: x,
  10461. y: y,
  10462. width: width,
  10463. height: height
  10464. };
  10465. };
  10466. _proto.updateContent = function updateContent(text) {
  10467. var textShape = this.textShape,
  10468. backgroundShape = this.backgroundShape;
  10469. if (!(0, _common.isNil)(text)) {
  10470. if (!(0, _common.isObject)(text)) {
  10471. text = {
  10472. text: text
  10473. };
  10474. }
  10475. textShape.attr(text); // update box shape
  10476. var _this$_getBBox = this._getBBox(),
  10477. x = _this$_getBBox.x,
  10478. y = _this$_getBBox.y,
  10479. tipWidth = _this$_getBBox.width,
  10480. tipHeight = _this$_getBBox.height;
  10481. var width = this.width || tipWidth;
  10482. var height = this.height || tipHeight;
  10483. backgroundShape.attr({
  10484. x: x,
  10485. y: y,
  10486. width: width,
  10487. height: height
  10488. });
  10489. this._width = width;
  10490. this._height = height;
  10491. this.content = text.text;
  10492. }
  10493. };
  10494. _proto.updatePosition = function updatePosition(x, y) {
  10495. var container = this.container;
  10496. var _this$_getBBox2 = this._getBBox(),
  10497. xMin = _this$_getBBox2.x,
  10498. yMin = _this$_getBBox2.y;
  10499. container.moveTo(x - xMin, y - yMin);
  10500. this.x = x - xMin;
  10501. this.y = y - yMin;
  10502. };
  10503. _proto.getWidth = function getWidth() {
  10504. return this._width;
  10505. };
  10506. _proto.getHeight = function getHeight() {
  10507. return this._height;
  10508. };
  10509. _proto.show = function show() {
  10510. this.container.show();
  10511. };
  10512. _proto.hide = function hide() {
  10513. this.container.hide();
  10514. };
  10515. _proto.clear = function clear() {
  10516. var container = this.container;
  10517. container.clear();
  10518. container.remove(true);
  10519. this.container = null;
  10520. this.textShape = null;
  10521. this.backgroundShape = null;
  10522. };
  10523. return TextBox;
  10524. }();
  10525. var _default = TextBox;
  10526. exports["default"] = _default;
  10527. }, function(modId) { var map = {"../util/common":1658993502535,"../graphic/index":1658993502565}; return __REQUIRE__(map[modId], modId); })
  10528. __DEFINE__(1658993502624, function(require, module, exports) {
  10529. exports.__esModule = true;
  10530. exports.init = init;
  10531. exports.afterGeomDraw = afterGeomDraw;
  10532. exports.clear = clear;
  10533. exports.repaint = repaint;
  10534. exports["default"] = void 0;
  10535. var _common = require("../util/common");
  10536. var _base = _interopRequireDefault(require("../component/guide/base"));
  10537. var _global = _interopRequireDefault(require("../global"));
  10538. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10539. // register the default configuration for Guide
  10540. _global["default"].guide = (0, _common.deepMix)({
  10541. line: {
  10542. style: {
  10543. stroke: '#a3a3a3',
  10544. lineWidth: 1
  10545. },
  10546. top: true
  10547. },
  10548. text: {
  10549. style: {
  10550. fill: '#787878',
  10551. textAlign: 'center',
  10552. textBaseline: 'middle'
  10553. },
  10554. offsetX: 0,
  10555. offsetY: 0,
  10556. top: true
  10557. },
  10558. rect: {
  10559. style: {
  10560. fill: '#fafafa'
  10561. },
  10562. top: false
  10563. },
  10564. arc: {
  10565. style: {
  10566. stroke: '#a3a3a3'
  10567. },
  10568. top: true
  10569. },
  10570. html: {
  10571. offsetX: 0,
  10572. offsetY: 0,
  10573. alignX: 'center',
  10574. alignY: 'middle'
  10575. },
  10576. tag: {
  10577. top: true,
  10578. offsetX: 0,
  10579. offsetY: 0,
  10580. side: 4,
  10581. background: {
  10582. padding: 5,
  10583. radius: 2,
  10584. fill: '#1890FF'
  10585. },
  10586. textStyle: {
  10587. fontSize: 12,
  10588. fill: '#fff',
  10589. textAlign: 'center',
  10590. textBaseline: 'middle'
  10591. }
  10592. },
  10593. point: {
  10594. top: true,
  10595. offsetX: 0,
  10596. offsetY: 0,
  10597. style: {
  10598. fill: '#fff',
  10599. r: 3,
  10600. lineWidth: 2,
  10601. stroke: '#1890ff'
  10602. }
  10603. }
  10604. }, _global["default"].guide || {});
  10605. var GuideController = /*#__PURE__*/function () {
  10606. function GuideController(cfg) {
  10607. this.guides = [];
  10608. this.xScale = null;
  10609. this.yScales = null;
  10610. this.guideShapes = [];
  10611. (0, _common.mix)(this, cfg);
  10612. }
  10613. var _proto = GuideController.prototype;
  10614. _proto._toString = function _toString(position) {
  10615. if ((0, _common.isFunction)(position)) {
  10616. position = position(this.xScale, this.yScales);
  10617. }
  10618. position = position.toString();
  10619. return position;
  10620. };
  10621. _proto._getId = function _getId(shape, guide) {
  10622. var id = guide.id;
  10623. if (!id) {
  10624. var type = guide.type;
  10625. if (type === 'arc' || type === 'line' || type === 'rect') {
  10626. id = this._toString(guide.start) + '-' + this._toString(guide.end);
  10627. } else {
  10628. id = this._toString(guide.position);
  10629. }
  10630. }
  10631. return id;
  10632. };
  10633. _proto.paint = function paint(coord) {
  10634. var self = this;
  10635. var chart = self.chart,
  10636. guides = self.guides,
  10637. xScale = self.xScale,
  10638. yScales = self.yScales;
  10639. var guideShapes = [];
  10640. (0, _common.each)(guides, function (guide, idx) {
  10641. guide.xScale = xScale;
  10642. guide.yScales = yScales;
  10643. var container;
  10644. if (guide.type === 'regionFilter') {
  10645. // TODO: RegionFilter support animation
  10646. guide.chart = chart;
  10647. } else {
  10648. container = guide.top ? self.frontPlot : self.backPlot;
  10649. }
  10650. guide.coord = coord;
  10651. guide.container = container;
  10652. guide.canvas = chart.get('canvas');
  10653. var shape = guide.render(coord, container);
  10654. if (shape) {
  10655. var id = self._getId(shape, guide);
  10656. [].concat(shape).forEach(function (s) {
  10657. s._id = s.get('className') + '-' + id;
  10658. s.set('index', idx);
  10659. guideShapes.push(s);
  10660. });
  10661. }
  10662. });
  10663. self.guideShapes = guideShapes;
  10664. };
  10665. _proto.clear = function clear() {
  10666. this.reset();
  10667. this.guides = [];
  10668. return this;
  10669. };
  10670. _proto.reset = function reset() {
  10671. var guides = this.guides;
  10672. (0, _common.each)(guides, function (guide) {
  10673. guide.remove();
  10674. });
  10675. };
  10676. _proto._createGuide = function _createGuide(type, cfg) {
  10677. var ClassName = (0, _common.upperFirst)(type);
  10678. var guide = new _base["default"][ClassName]((0, _common.deepMix)({}, _global["default"].guide[type], cfg));
  10679. this.guides.push(guide);
  10680. return guide;
  10681. };
  10682. _proto.line = function line(cfg) {
  10683. if (cfg === void 0) {
  10684. cfg = {};
  10685. }
  10686. return this._createGuide('line', cfg);
  10687. };
  10688. _proto.text = function text(cfg) {
  10689. if (cfg === void 0) {
  10690. cfg = {};
  10691. }
  10692. return this._createGuide('text', cfg);
  10693. };
  10694. _proto.arc = function arc(cfg) {
  10695. if (cfg === void 0) {
  10696. cfg = {};
  10697. }
  10698. return this._createGuide('arc', cfg);
  10699. };
  10700. _proto.html = function html(cfg) {
  10701. if (cfg === void 0) {
  10702. cfg = {};
  10703. }
  10704. return this._createGuide('html', cfg);
  10705. };
  10706. _proto.rect = function rect(cfg) {
  10707. if (cfg === void 0) {
  10708. cfg = {};
  10709. }
  10710. return this._createGuide('rect', cfg);
  10711. };
  10712. _proto.tag = function tag(cfg) {
  10713. if (cfg === void 0) {
  10714. cfg = {};
  10715. }
  10716. return this._createGuide('tag', cfg);
  10717. };
  10718. _proto.point = function point(cfg) {
  10719. if (cfg === void 0) {
  10720. cfg = {};
  10721. }
  10722. return this._createGuide('point', cfg);
  10723. };
  10724. _proto.regionFilter = function regionFilter(cfg) {
  10725. if (cfg === void 0) {
  10726. cfg = {};
  10727. }
  10728. return this._createGuide('regionFilter', cfg);
  10729. };
  10730. return GuideController;
  10731. }();
  10732. function init(chart) {
  10733. var guideController = new GuideController({
  10734. frontPlot: chart.get('frontPlot').addGroup({
  10735. zIndex: 20,
  10736. className: 'guideContainer'
  10737. }),
  10738. backPlot: chart.get('backPlot').addGroup({
  10739. className: 'guideContainer'
  10740. })
  10741. });
  10742. chart.set('guideController', guideController);
  10743. /**
  10744. * 为图表添加 guide
  10745. * @return {GuideController} 返回 guide 控制器
  10746. */
  10747. chart.guide = function () {
  10748. return guideController;
  10749. };
  10750. }
  10751. function afterGeomDraw(chart) {
  10752. var guideController = chart.get('guideController');
  10753. if (!guideController.guides.length) {
  10754. return;
  10755. }
  10756. var xScale = chart.getXScale();
  10757. var yScales = chart.getYScales();
  10758. var coord = chart.get('coord');
  10759. guideController.xScale = xScale;
  10760. guideController.yScales = yScales;
  10761. guideController.chart = chart; // for regionFilter
  10762. guideController.paint(coord);
  10763. }
  10764. function clear(chart) {
  10765. chart.get('guideController').clear();
  10766. }
  10767. function repaint(chart) {
  10768. chart.get('guideController').reset();
  10769. }
  10770. var _default = {
  10771. init: init,
  10772. afterGeomDraw: afterGeomDraw,
  10773. clear: clear,
  10774. repaint: repaint
  10775. };
  10776. exports["default"] = _default;
  10777. }, function(modId) { var map = {"../util/common":1658993502535,"../component/guide/base":1658993502612,"../global":1658993502533}; return __REQUIRE__(map[modId], modId); })
  10778. __DEFINE__(1658993502625, function(require, module, exports) {
  10779. exports.__esModule = true;
  10780. exports.init = init;
  10781. exports.beforeGeomDraw = beforeGeomDraw;
  10782. exports.afterGeomDraw = afterGeomDraw;
  10783. exports.clearInner = clearInner;
  10784. exports["default"] = void 0;
  10785. var _common = require("../util/common");
  10786. var _list = _interopRequireDefault(require("../component/list"));
  10787. var _global = _interopRequireDefault(require("../global"));
  10788. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  10789. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  10790. var LEGEND_GAP = 12;
  10791. var MARKER_SIZE = 3;
  10792. var DEFAULT_CFG = {
  10793. itemMarginBottom: 12,
  10794. itemGap: 10,
  10795. showTitle: false,
  10796. titleStyle: {
  10797. fontSize: 12,
  10798. fill: '#808080',
  10799. textAlign: 'start',
  10800. textBaseline: 'top'
  10801. },
  10802. nameStyle: {
  10803. fill: '#808080',
  10804. fontSize: 12,
  10805. textAlign: 'start',
  10806. textBaseline: 'middle'
  10807. },
  10808. valueStyle: {
  10809. fill: '#000000',
  10810. fontSize: 12,
  10811. textAlign: 'start',
  10812. textBaseline: 'middle'
  10813. },
  10814. unCheckStyle: {
  10815. fill: '#bfbfbf'
  10816. },
  10817. itemWidth: 'auto',
  10818. wordSpace: 6,
  10819. selectedMode: 'multiple' // 'multiple' or 'single'
  10820. }; // Register the default configuration for Legend
  10821. _global["default"].legend = (0, _common.deepMix)({
  10822. common: DEFAULT_CFG,
  10823. // common legend configuration
  10824. right: (0, _common.mix)({
  10825. position: 'right',
  10826. layout: 'vertical'
  10827. }, DEFAULT_CFG),
  10828. left: (0, _common.mix)({
  10829. position: 'left',
  10830. layout: 'vertical'
  10831. }, DEFAULT_CFG),
  10832. top: (0, _common.mix)({
  10833. position: 'top',
  10834. layout: 'horizontal'
  10835. }, DEFAULT_CFG),
  10836. bottom: (0, _common.mix)({
  10837. position: 'bottom',
  10838. layout: 'horizontal'
  10839. }, DEFAULT_CFG)
  10840. }, _global["default"].legend || {});
  10841. function getPaddingByPos(pos, appendPadding) {
  10842. var padding = 0;
  10843. appendPadding = (0, _common.parsePadding)(appendPadding);
  10844. switch (pos) {
  10845. case 'top':
  10846. padding = appendPadding[0];
  10847. break;
  10848. case 'right':
  10849. padding = appendPadding[1];
  10850. break;
  10851. case 'bottom':
  10852. padding = appendPadding[2];
  10853. break;
  10854. case 'left':
  10855. padding = appendPadding[3];
  10856. break;
  10857. default:
  10858. break;
  10859. }
  10860. return padding;
  10861. }
  10862. var LegendController = /*#__PURE__*/function () {
  10863. function LegendController(cfg) {
  10864. var _this = this;
  10865. _defineProperty(this, "handleEvent", function (ev) {
  10866. var self = _this;
  10867. function findItem(x, y) {
  10868. var result = null;
  10869. var legends = self.legends;
  10870. (0, _common.each)(legends, function (legendItems) {
  10871. (0, _common.each)(legendItems, function (legend) {
  10872. var itemsGroup = legend.itemsGroup,
  10873. legendHitBoxes = legend.legendHitBoxes;
  10874. var children = itemsGroup.get('children');
  10875. if (children.length) {
  10876. var legendPosX = legend.x;
  10877. var legendPosY = legend.y;
  10878. (0, _common.each)(legendHitBoxes, function (box, index) {
  10879. if (x >= box.x + legendPosX && x <= box.x + box.width + legendPosX && y >= box.y + legendPosY && y <= box.height + box.y + legendPosY) {
  10880. // inbox
  10881. result = {
  10882. clickedItem: children[index],
  10883. clickedLegend: legend
  10884. };
  10885. return false;
  10886. }
  10887. });
  10888. }
  10889. });
  10890. });
  10891. return result;
  10892. }
  10893. var chart = self.chart;
  10894. var _createEvent = (0, _common.createEvent)(ev, chart),
  10895. x = _createEvent.x,
  10896. y = _createEvent.y;
  10897. var clicked = findItem(x, y);
  10898. if (clicked && clicked.clickedLegend.clickable !== false) {
  10899. var clickedItem = clicked.clickedItem,
  10900. clickedLegend = clicked.clickedLegend;
  10901. if (clickedLegend.onClick) {
  10902. ev.clickedItem = clickedItem;
  10903. clickedLegend.onClick(ev);
  10904. } else if (!clickedLegend.custom) {
  10905. var checked = clickedItem.get('checked');
  10906. var value = clickedItem.get('dataValue');
  10907. var filteredVals = clickedLegend.filteredVals,
  10908. field = clickedLegend.field,
  10909. selectedMode = clickedLegend.selectedMode;
  10910. var isSingeSelected = selectedMode === 'single';
  10911. if (isSingeSelected) {
  10912. chart.filter(field, function (val) {
  10913. return val === value;
  10914. });
  10915. } else {
  10916. if (checked) {
  10917. filteredVals.push(value);
  10918. } else {
  10919. _common.Array.remove(filteredVals, value);
  10920. }
  10921. chart.filter(field, function (val) {
  10922. return filteredVals.indexOf(val) === -1;
  10923. });
  10924. }
  10925. chart.repaint();
  10926. }
  10927. }
  10928. });
  10929. this.legendCfg = {};
  10930. this.enable = true;
  10931. this.position = 'top';
  10932. (0, _common.mix)(this, cfg);
  10933. var _chart = this.chart;
  10934. this.canvasDom = _chart.get('canvas').get('el');
  10935. this.clear();
  10936. }
  10937. var _proto = LegendController.prototype;
  10938. _proto.addLegend = function addLegend(scale, items, filteredVals) {
  10939. var self = this;
  10940. var legendCfg = self.legendCfg;
  10941. var field = scale.field;
  10942. var fieldCfg = legendCfg[field];
  10943. if (fieldCfg === false) {
  10944. return null;
  10945. }
  10946. if (fieldCfg && fieldCfg.custom) {
  10947. self.addCustomLegend(field);
  10948. } else {
  10949. var position = legendCfg.position || self.position;
  10950. if (fieldCfg && fieldCfg.position) {
  10951. position = fieldCfg.position;
  10952. }
  10953. if (scale.isCategory) {
  10954. self._addCategoryLegend(scale, items, position, filteredVals);
  10955. }
  10956. }
  10957. };
  10958. _proto.addCustomLegend = function addCustomLegend(field) {
  10959. var self = this;
  10960. var legendCfg = self.legendCfg;
  10961. if (field && legendCfg[field]) {
  10962. legendCfg = legendCfg[field];
  10963. }
  10964. var position = legendCfg.position || self.position;
  10965. var legends = self.legends;
  10966. legends[position] = legends[position] || [];
  10967. var items = legendCfg.items;
  10968. if (!items) {
  10969. return null;
  10970. }
  10971. var container = self.container;
  10972. (0, _common.each)(items, function (item) {
  10973. if (!(0, _common.isPlainObject)(item.marker)) {
  10974. item.marker = {
  10975. symbol: item.marker || 'circle',
  10976. fill: item.fill,
  10977. radius: MARKER_SIZE
  10978. };
  10979. } else {
  10980. item.marker.radius = item.marker.radius || MARKER_SIZE;
  10981. }
  10982. item.checked = (0, _common.isNil)(item.checked) ? true : item.checked;
  10983. item.name = item.name || item.value;
  10984. });
  10985. var legend = new _list["default"]((0, _common.deepMix)({}, _global["default"].legend[position], legendCfg, {
  10986. maxLength: self._getMaxLength(position),
  10987. items: items,
  10988. parent: container
  10989. }));
  10990. legends[position].push(legend);
  10991. };
  10992. _proto.clear = function clear() {
  10993. var legends = this.legends;
  10994. (0, _common.each)(legends, function (legendItems) {
  10995. (0, _common.each)(legendItems, function (legend) {
  10996. legend.clear();
  10997. });
  10998. });
  10999. this.legends = {};
  11000. this.unBindEvents();
  11001. };
  11002. _proto._isFiltered = function _isFiltered(scale, values, value) {
  11003. var rst = false;
  11004. (0, _common.each)(values, function (val) {
  11005. rst = rst || scale.getText(val) === scale.getText(value);
  11006. if (rst) {
  11007. return false;
  11008. }
  11009. });
  11010. return rst;
  11011. };
  11012. _proto._getMaxLength = function _getMaxLength(position) {
  11013. var chart = this.chart;
  11014. var appendPadding = (0, _common.parsePadding)(chart.get('appendPadding'));
  11015. return position === 'right' || position === 'left' ? chart.get('height') - (appendPadding[0] + appendPadding[2]) : chart.get('width') - (appendPadding[1] + appendPadding[3]);
  11016. };
  11017. _proto._addCategoryLegend = function _addCategoryLegend(scale, items, position, filteredVals) {
  11018. var self = this;
  11019. var legendCfg = self.legendCfg,
  11020. legends = self.legends,
  11021. container = self.container,
  11022. chart = self.chart;
  11023. var field = scale.field;
  11024. legends[position] = legends[position] || [];
  11025. var symbol = 'circle';
  11026. if (legendCfg[field] && legendCfg[field].marker) {
  11027. symbol = legendCfg[field].marker;
  11028. } else if (legendCfg.marker) {
  11029. symbol = legendCfg.marker;
  11030. }
  11031. (0, _common.each)(items, function (item) {
  11032. if ((0, _common.isPlainObject)(symbol)) {
  11033. (0, _common.mix)(item.marker, symbol);
  11034. } else {
  11035. item.marker.symbol = symbol;
  11036. }
  11037. if (filteredVals) {
  11038. item.checked = !self._isFiltered(scale, filteredVals, item.dataValue);
  11039. }
  11040. });
  11041. var legendItems = chart.get('legendItems');
  11042. legendItems[field] = items;
  11043. var lastCfg = (0, _common.deepMix)({}, _global["default"].legend[position], legendCfg[field] || legendCfg, {
  11044. maxLength: self._getMaxLength(position),
  11045. items: items,
  11046. field: field,
  11047. filteredVals: filteredVals,
  11048. parent: container
  11049. });
  11050. if (lastCfg.showTitle) {
  11051. (0, _common.deepMix)(lastCfg, {
  11052. title: scale.alias || scale.field
  11053. });
  11054. }
  11055. var legend = new _list["default"](lastCfg);
  11056. legends[position].push(legend);
  11057. return legend;
  11058. };
  11059. _proto._alignLegend = function _alignLegend(legend, pre, position) {
  11060. var self = this;
  11061. var _self$plotRange = self.plotRange,
  11062. tl = _self$plotRange.tl,
  11063. bl = _self$plotRange.bl;
  11064. var chart = self.chart;
  11065. var offsetX = legend.offsetX || 0;
  11066. var offsetY = legend.offsetY || 0;
  11067. var chartWidth = chart.get('width');
  11068. var chartHeight = chart.get('height');
  11069. var appendPadding = (0, _common.parsePadding)(chart.get('appendPadding'));
  11070. var legendHeight = legend.getHeight();
  11071. var legendWidth = legend.getWidth();
  11072. var x = 0;
  11073. var y = 0;
  11074. if (position === 'left' || position === 'right') {
  11075. var verticalAlign = legend.verticalAlign || 'middle';
  11076. var height = Math.abs(tl.y - bl.y);
  11077. x = position === 'left' ? appendPadding[3] : chartWidth - legendWidth - appendPadding[1];
  11078. y = (height - legendHeight) / 2 + tl.y;
  11079. if (verticalAlign === 'top') {
  11080. y = tl.y;
  11081. } else if (verticalAlign === 'bottom') {
  11082. y = bl.y - legendHeight;
  11083. }
  11084. if (pre) {
  11085. y = pre.get('y') - legendHeight - LEGEND_GAP;
  11086. }
  11087. } else {
  11088. var align = legend.align || 'left';
  11089. x = appendPadding[3];
  11090. if (align === 'center') {
  11091. x = chartWidth / 2 - legendWidth / 2;
  11092. } else if (align === 'right') {
  11093. x = chartWidth - (legendWidth + appendPadding[1]);
  11094. }
  11095. y = position === 'top' ? appendPadding[0] + Math.abs(legend.container.getBBox().minY) : chartHeight - legendHeight;
  11096. if (pre) {
  11097. var preWidth = pre.getWidth();
  11098. x = pre.x + preWidth + LEGEND_GAP;
  11099. }
  11100. }
  11101. if (position === 'bottom' && offsetY > 0) {
  11102. offsetY = 0;
  11103. }
  11104. if (position === 'right' && offsetX > 0) {
  11105. offsetX = 0;
  11106. }
  11107. legend.moveTo(x + offsetX, y + offsetY);
  11108. };
  11109. _proto.alignLegends = function alignLegends() {
  11110. var self = this;
  11111. var legends = self.legends;
  11112. (0, _common.each)(legends, function (legendItems, position) {
  11113. (0, _common.each)(legendItems, function (legend, index) {
  11114. var pre = legendItems[index - 1];
  11115. self._alignLegend(legend, pre, position);
  11116. });
  11117. });
  11118. return self;
  11119. };
  11120. _proto.bindEvents = function bindEvents() {
  11121. var legendCfg = this.legendCfg;
  11122. var triggerOn = legendCfg.triggerOn || 'touchstart';
  11123. (0, _common.addEventListener)(this.canvasDom, triggerOn, this.handleEvent);
  11124. };
  11125. _proto.unBindEvents = function unBindEvents() {
  11126. var legendCfg = this.legendCfg;
  11127. var triggerOn = legendCfg.triggerOn || 'touchstart';
  11128. (0, _common.removeEventListener)(this.canvasDom, triggerOn, this.handleEvent);
  11129. };
  11130. return LegendController;
  11131. }();
  11132. function init(chart) {
  11133. var legendController = new LegendController({
  11134. container: chart.get('backPlot'),
  11135. plotRange: chart.get('plotRange'),
  11136. chart: chart
  11137. });
  11138. chart.set('legendController', legendController);
  11139. chart.legend = function (field, cfg) {
  11140. var legendCfg = legendController.legendCfg;
  11141. legendController.enable = true;
  11142. if ((0, _common.isBoolean)(field)) {
  11143. legendController.enable = field;
  11144. legendCfg = cfg || {};
  11145. } else if ((0, _common.isObject)(field)) {
  11146. legendCfg = field;
  11147. } else {
  11148. legendCfg[field] = cfg;
  11149. }
  11150. legendController.legendCfg = legendCfg;
  11151. return this;
  11152. };
  11153. }
  11154. function beforeGeomDraw(chart) {
  11155. var legendController = chart.get('legendController');
  11156. if (!legendController.enable) return null; // legend is not displayed
  11157. var legendCfg = legendController.legendCfg;
  11158. if (legendCfg && legendCfg.custom) {
  11159. legendController.addCustomLegend();
  11160. } else {
  11161. var legendItems = chart.getLegendItems();
  11162. var scales = chart.get('scales');
  11163. var filters = chart.get('filters');
  11164. (0, _common.each)(legendItems, function (items, field) {
  11165. var scale = scales[field];
  11166. var values = scale.values;
  11167. var filteredVals;
  11168. if (filters && filters[field]) {
  11169. filteredVals = values.filter(function (v) {
  11170. return !filters[field](v);
  11171. });
  11172. } else {
  11173. filteredVals = [];
  11174. }
  11175. legendController.addLegend(scale, items, filteredVals);
  11176. });
  11177. }
  11178. if (legendCfg && legendCfg.clickable !== false) {
  11179. legendController.bindEvents();
  11180. }
  11181. var legends = legendController.legends;
  11182. var legendRange = {
  11183. top: 0,
  11184. right: 0,
  11185. bottom: 0,
  11186. left: 0
  11187. };
  11188. (0, _common.each)(legends, function (legendItems, position) {
  11189. var padding = 0;
  11190. (0, _common.each)(legendItems, function (legend) {
  11191. var width = legend.getWidth();
  11192. var height = legend.getHeight();
  11193. if (position === 'top' || position === 'bottom') {
  11194. padding = Math.max(padding, height);
  11195. if (legend.offsetY > 0) {
  11196. padding += legend.offsetY;
  11197. }
  11198. } else {
  11199. padding = Math.max(padding, width);
  11200. if (legend.offsetX > 0) {
  11201. padding += legend.offsetX;
  11202. }
  11203. }
  11204. });
  11205. legendRange[position] = padding + getPaddingByPos(position, chart.get('appendPadding'));
  11206. });
  11207. chart.set('legendRange', legendRange);
  11208. }
  11209. function afterGeomDraw(chart) {
  11210. var legendController = chart.get('legendController');
  11211. legendController.alignLegends();
  11212. }
  11213. function clearInner(chart) {
  11214. var legendController = chart.get('legendController');
  11215. legendController.clear();
  11216. chart.set('legendRange', null);
  11217. }
  11218. var _default = {
  11219. init: init,
  11220. beforeGeomDraw: beforeGeomDraw,
  11221. afterGeomDraw: afterGeomDraw,
  11222. clearInner: clearInner
  11223. };
  11224. exports["default"] = _default;
  11225. }, function(modId) { var map = {"../util/common":1658993502535,"../component/list":1658993502622,"../global":1658993502533}; return __REQUIRE__(map[modId], modId); })
  11226. __DEFINE__(1658993502626, function(require, module, exports) {
  11227. exports.__esModule = true;
  11228. exports.afterCanvasInit = afterCanvasInit;
  11229. exports.beforeCanvasDraw = beforeCanvasDraw;
  11230. exports.afterCanvasDestroyed = afterCanvasDestroyed;
  11231. exports["default"] = void 0;
  11232. var _common = require("../util/common");
  11233. var _element = _interopRequireDefault(require("../graphic/element"));
  11234. var _timeline = _interopRequireDefault(require("../graphic/animate/timeline"));
  11235. var _animator = _interopRequireDefault(require("../graphic/animate/animator"));
  11236. var _animate2 = _interopRequireDefault(require("./animate"));
  11237. var ShapeAction = _interopRequireWildcard(require("./shape-action"));
  11238. var GroupAction = _interopRequireWildcard(require("./group-action"));
  11239. var _chart = _interopRequireDefault(require("../chart/chart"));
  11240. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  11241. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  11242. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  11243. /**
  11244. * Handle the detail animations
  11245. * @author sima.zhang1990@gmail.com
  11246. */
  11247. var timeline;
  11248. _element["default"].prototype.animate = function () {
  11249. var attrs = (0, _common.mix)({}, this.get('attrs'));
  11250. return new _animator["default"](this, attrs, timeline);
  11251. };
  11252. _chart["default"].prototype.animate = function (cfg) {
  11253. this.set('animate', cfg);
  11254. return this;
  11255. };
  11256. _animate2["default"].Action = ShapeAction;
  11257. _animate2["default"].defaultCfg = {
  11258. interval: {
  11259. enter: function enter(coord) {
  11260. if (coord.isPolar && coord.transposed) {
  11261. // for pie chart
  11262. return function (shape) {
  11263. shape.set('zIndex', -1);
  11264. var container = shape.get('parent');
  11265. container.sort();
  11266. };
  11267. }
  11268. return ShapeAction.fadeIn;
  11269. }
  11270. },
  11271. area: {
  11272. enter: function enter(coord) {
  11273. if (coord.isPolar) return null;
  11274. return ShapeAction.fadeIn;
  11275. }
  11276. },
  11277. line: {
  11278. enter: function enter(coord) {
  11279. if (coord.isPolar) return null;
  11280. return ShapeAction.fadeIn;
  11281. }
  11282. },
  11283. path: {
  11284. enter: function enter(coord) {
  11285. if (coord.isPolar) return null;
  11286. return ShapeAction.fadeIn;
  11287. }
  11288. }
  11289. };
  11290. var GROUP_ANIMATION = {
  11291. line: function line(coord) {
  11292. if (coord.isPolar) {
  11293. return GroupAction.groupScaleInXY;
  11294. }
  11295. return GroupAction.groupWaveIn;
  11296. },
  11297. area: function area(coord) {
  11298. if (coord.isPolar) {
  11299. return GroupAction.groupScaleInXY;
  11300. }
  11301. return GroupAction.groupWaveIn;
  11302. },
  11303. path: function path(coord) {
  11304. if (coord.isPolar) {
  11305. return GroupAction.groupScaleInXY;
  11306. }
  11307. return GroupAction.groupWaveIn;
  11308. },
  11309. point: function point() {
  11310. return GroupAction.shapesScaleInXY;
  11311. },
  11312. interval: function interval(coord) {
  11313. var result;
  11314. if (coord.isPolar) {
  11315. // polar coodinate
  11316. result = GroupAction.groupScaleInXY;
  11317. if (coord.transposed) {
  11318. // pie chart
  11319. result = GroupAction.groupWaveIn;
  11320. }
  11321. } else {
  11322. result = coord.transposed ? GroupAction.groupScaleInX : GroupAction.groupScaleInY;
  11323. }
  11324. return result;
  11325. },
  11326. schema: function schema() {
  11327. return GroupAction.groupWaveIn;
  11328. }
  11329. };
  11330. function diff(fromAttrs, toAttrs) {
  11331. var endState = {};
  11332. for (var k in toAttrs) {
  11333. if ((0, _common.isNumber)(fromAttrs[k]) && fromAttrs[k] !== toAttrs[k]) {
  11334. endState[k] = toAttrs[k];
  11335. } else if ((0, _common.isArray)(fromAttrs[k]) && JSON.stringify(fromAttrs[k]) !== JSON.stringify(toAttrs[k])) {
  11336. endState[k] = toAttrs[k];
  11337. }
  11338. }
  11339. return endState;
  11340. } // Add a unique id identifier to each shape
  11341. function _getShapeId(geom, dataObj, geomIdx) {
  11342. var type = geom.get('type');
  11343. var id = 'geom' + geomIdx + '-' + type;
  11344. var xScale = geom.getXScale();
  11345. var yScale = geom.getYScale();
  11346. var xField = xScale.field || 'x';
  11347. var yField = yScale.field || 'y';
  11348. var yVal = dataObj[yField];
  11349. var xVal;
  11350. if (xScale.isIdentity) {
  11351. xVal = xScale.value;
  11352. } else {
  11353. xVal = dataObj[xField];
  11354. }
  11355. if (type === 'interval' || type === 'schema') {
  11356. id += '-' + xVal;
  11357. } else if (type === 'line' || type === 'area' || type === 'path') {
  11358. id += '-' + type;
  11359. } else {
  11360. id += xScale.isCategory ? '-' + xVal : '-' + xVal + '-' + yVal;
  11361. }
  11362. var groupScales = geom._getGroupScales();
  11363. (0, _common.each)(groupScales, function (groupScale) {
  11364. var field = groupScale.field;
  11365. if (groupScale.type !== 'identity') {
  11366. id += '-' + dataObj[field];
  11367. }
  11368. });
  11369. return id;
  11370. } // get geometry's shapes
  11371. function getShapes(geoms, chart, coord) {
  11372. var shapes = [];
  11373. (0, _common.each)(geoms, function (geom, geomIdx) {
  11374. var geomContainer = geom.get('container');
  11375. var geomShapes = geomContainer.get('children');
  11376. var type = geom.get('type');
  11377. var animateCfg = (0, _common.isNil)(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
  11378. if (animateCfg !== false) {
  11379. (0, _common.each)(geomShapes, function (shape, index) {
  11380. if (shape.get('className') === type) {
  11381. shape._id = _getShapeId(geom, shape.get('origin')._origin, geomIdx);
  11382. shape.set('coord', coord);
  11383. shape.set('animateCfg', animateCfg);
  11384. shape.set('index', index);
  11385. shapes.push(shape);
  11386. }
  11387. });
  11388. }
  11389. geom.set('shapes', geomShapes);
  11390. });
  11391. return shapes;
  11392. }
  11393. function cache(shapes) {
  11394. var rst = {};
  11395. for (var i = 0, len = shapes.length; i < len; i++) {
  11396. var shape = shapes[i];
  11397. if (!shape._id || shape.isClip) continue;
  11398. var id = shape._id;
  11399. rst[id] = {
  11400. _id: id,
  11401. type: shape.get('type'),
  11402. // the type of shape
  11403. attrs: (0, _common.mix)({}, shape._attrs.attrs),
  11404. // the graphics attributes of shape
  11405. className: shape.get('className'),
  11406. geomType: shape.get('className'),
  11407. index: shape.get('index'),
  11408. coord: shape.get('coord'),
  11409. animateCfg: shape.get('animateCfg')
  11410. };
  11411. }
  11412. return rst;
  11413. }
  11414. function getAnimate(geomType, coord, animationType, animationName) {
  11415. var result;
  11416. if ((0, _common.isFunction)(animationName)) {
  11417. result = animationName;
  11418. } else if ((0, _common.isString)(animationName)) {
  11419. result = _animate2["default"].Action[animationName];
  11420. } else {
  11421. result = _animate2["default"].getAnimation(geomType, coord, animationType);
  11422. }
  11423. return result;
  11424. }
  11425. function getAnimateCfg(geomType, animationType, animateCfg) {
  11426. if (animateCfg === false || (0, _common.isObject)(animateCfg) && animateCfg[animationType] === false) {
  11427. return false;
  11428. }
  11429. var defaultCfg = _animate2["default"].getAnimateCfg(geomType, animationType);
  11430. if (animateCfg && animateCfg[animationType]) {
  11431. return (0, _common.deepMix)({}, defaultCfg, animateCfg[animationType]);
  11432. }
  11433. return defaultCfg;
  11434. }
  11435. function addAnimate(cache, shapes, canvas) {
  11436. var animate;
  11437. var animateCfg; // the order of animation: leave -> update -> enter
  11438. var updateShapes = [];
  11439. var newShapes = [];
  11440. (0, _common.each)(shapes, function (shape) {
  11441. var result = cache[shape._id];
  11442. if (!result) {
  11443. newShapes.push(shape);
  11444. } else {
  11445. shape.set('cacheShape', result);
  11446. updateShapes.push(shape);
  11447. delete cache[shape._id];
  11448. }
  11449. }); // first do the leave animation
  11450. (0, _common.each)(cache, function (deletedShape) {
  11451. var className = deletedShape.className,
  11452. coord = deletedShape.coord,
  11453. _id = deletedShape._id,
  11454. attrs = deletedShape.attrs,
  11455. index = deletedShape.index,
  11456. type = deletedShape.type;
  11457. animateCfg = getAnimateCfg(className, 'leave', deletedShape.animateCfg);
  11458. if (animateCfg === false) return true;
  11459. animate = getAnimate(className, coord, 'leave', animateCfg.animation);
  11460. if ((0, _common.isFunction)(animate)) {
  11461. var tempShape = canvas.addShape(type, {
  11462. attrs: attrs,
  11463. index: index,
  11464. canvas: canvas,
  11465. className: className
  11466. });
  11467. tempShape._id = _id;
  11468. animate(tempShape, animateCfg, coord);
  11469. }
  11470. }); // then do the update animation
  11471. (0, _common.each)(updateShapes, function (updateShape) {
  11472. var className = updateShape.get('className');
  11473. animateCfg = getAnimateCfg(className, 'update', updateShape.get('animateCfg'));
  11474. if (animateCfg === false) return true;
  11475. var coord = updateShape.get('coord');
  11476. var cacheAttrs = updateShape.get('cacheShape').attrs;
  11477. var endState = diff(cacheAttrs, updateShape._attrs.attrs); // 判断如果属性相同的话就不进行变换
  11478. if (Object.keys(endState).length) {
  11479. animate = getAnimate(className, coord, 'update', animateCfg.animation);
  11480. if ((0, _common.isFunction)(animate)) {
  11481. animate(updateShape, animateCfg, coord);
  11482. } else {
  11483. updateShape.attr(cacheAttrs);
  11484. updateShape.animate().to({
  11485. attrs: endState,
  11486. duration: animateCfg.duration,
  11487. easing: animateCfg.easing,
  11488. delay: animateCfg.delay
  11489. }).onEnd(function () {
  11490. updateShape.set('cacheShape', null);
  11491. });
  11492. }
  11493. }
  11494. }); // last, enter animation
  11495. (0, _common.each)(newShapes, function (newShape) {
  11496. // 新图形元素的进场元素
  11497. var className = newShape.get('className');
  11498. var coord = newShape.get('coord');
  11499. animateCfg = getAnimateCfg(className, 'enter', newShape.get('animateCfg'));
  11500. if (animateCfg === false) return true;
  11501. animate = getAnimate(className, coord, 'enter', animateCfg.animation);
  11502. if ((0, _common.isFunction)(animate)) {
  11503. if (className === 'interval' && coord.isPolar && coord.transposed) {
  11504. var index = newShape.get('index');
  11505. var lastShape = updateShapes[index - 1];
  11506. animate(newShape, animateCfg, lastShape);
  11507. } else {
  11508. animate(newShape, animateCfg, coord);
  11509. }
  11510. }
  11511. });
  11512. }
  11513. function _getAnimateCfgByShapeType(type, chart) {
  11514. if (!type) {
  11515. return null;
  11516. }
  11517. var animateCfg = chart.get('animate');
  11518. if (type.indexOf('guide-tag') > -1) {
  11519. type = 'guide-tag';
  11520. }
  11521. if ((0, _common.isObject)(animateCfg)) {
  11522. return animateCfg[type];
  11523. }
  11524. if (animateCfg === false) {
  11525. return false;
  11526. }
  11527. return null;
  11528. }
  11529. function afterCanvasInit()
  11530. /* chart */
  11531. {
  11532. timeline = new _timeline["default"]();
  11533. timeline.play();
  11534. }
  11535. function beforeCanvasDraw(chart) {
  11536. if (chart.get('animate') === false) {
  11537. return;
  11538. }
  11539. var isUpdate = chart.get('isUpdate');
  11540. var canvas = chart.get('canvas');
  11541. var coord = chart.get('coord');
  11542. var geoms = chart.get('geoms');
  11543. var caches = canvas.get('caches') || [];
  11544. if (caches.length === 0) {
  11545. isUpdate = false;
  11546. }
  11547. var cacheShapes = getShapes(geoms, chart, coord);
  11548. var _chart$get = chart.get('axisController'),
  11549. frontPlot = _chart$get.frontPlot,
  11550. backPlot = _chart$get.backPlot;
  11551. var axisShapes = frontPlot.get('children').concat(backPlot.get('children'));
  11552. var guideShapes = [];
  11553. if (chart.get('guideController')) {
  11554. guideShapes = chart.get('guideController').guideShapes;
  11555. }
  11556. var componentShapes = [];
  11557. axisShapes.concat(guideShapes).forEach(function (s) {
  11558. var className = s.get('className');
  11559. var animateCfg = _getAnimateCfgByShapeType(className, chart);
  11560. s.set('coord', coord);
  11561. s.set('animateCfg', animateCfg);
  11562. componentShapes.push(s);
  11563. cacheShapes.push(s);
  11564. });
  11565. canvas.set('caches', cache(cacheShapes));
  11566. if (isUpdate) {
  11567. addAnimate(caches, cacheShapes, canvas);
  11568. } else {
  11569. // do the appear animation
  11570. var animateCfg;
  11571. var animate;
  11572. (0, _common.each)(geoms, function (geom) {
  11573. var type = geom.get('type');
  11574. var geomCfg = (0, _common.isNil)(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
  11575. if (geomCfg !== false) {
  11576. animateCfg = getAnimateCfg(type, 'appear', geomCfg);
  11577. animate = getAnimate(type, coord, 'appear', animateCfg.animation);
  11578. if ((0, _common.isFunction)(animate)) {
  11579. var shapes = geom.get('shapes');
  11580. (0, _common.each)(shapes, function (shape) {
  11581. animate(shape, animateCfg, coord);
  11582. });
  11583. } else if (GROUP_ANIMATION[type]) {
  11584. // do the default animation
  11585. animate = GroupAction[animateCfg.animation] || GROUP_ANIMATION[type](coord);
  11586. var yScale = geom.getYScale();
  11587. var zeroY = coord.convertPoint({
  11588. x: 0,
  11589. y: yScale.scale(geom.getYMinValue())
  11590. });
  11591. var container = geom.get('container');
  11592. animate && animate(container, animateCfg, coord, zeroY);
  11593. }
  11594. }
  11595. }); // do the animation of components
  11596. (0, _common.each)(componentShapes, function (shape) {
  11597. var animateCfg = shape.get('animateCfg');
  11598. var className = shape.get('className');
  11599. if (animateCfg && animateCfg.appear) {
  11600. // if user configure
  11601. var defaultCfg = _animate2["default"].getAnimateCfg(className, 'appear');
  11602. var appearCfg = (0, _common.deepMix)({}, defaultCfg, animateCfg.appear);
  11603. var _animate = getAnimate(className, coord, 'appear', appearCfg.animation);
  11604. if ((0, _common.isFunction)(_animate)) {
  11605. _animate(shape, appearCfg, coord);
  11606. }
  11607. }
  11608. });
  11609. }
  11610. }
  11611. function afterCanvasDestroyed()
  11612. /* chart */
  11613. {
  11614. timeline.stop();
  11615. }
  11616. var _default = {
  11617. afterCanvasInit: afterCanvasInit,
  11618. beforeCanvasDraw: beforeCanvasDraw,
  11619. afterCanvasDestroyed: afterCanvasDestroyed
  11620. };
  11621. exports["default"] = _default;
  11622. }, function(modId) { var map = {"../util/common":1658993502535,"../graphic/element":1658993502571,"../graphic/animate/timeline":1658993502627,"../graphic/animate/animator":1658993502628,"./animate":1658993502630,"./shape-action":1658993502631,"./group-action":1658993502633,"../chart/chart":1658993502538}; return __REQUIRE__(map[modId], modId); })
  11623. __DEFINE__(1658993502627, function(require, module, exports) {
  11624. exports.__esModule = true;
  11625. exports["default"] = void 0;
  11626. var _requestAnimationFrame = require("../util/requestAnimationFrame");
  11627. var clock = typeof performance === 'object' && performance.now ? performance : Date;
  11628. var Timeline = /*#__PURE__*/function () {
  11629. function Timeline() {
  11630. this.anims = [];
  11631. this.time = null;
  11632. this.playing = false;
  11633. this.canvas = [];
  11634. }
  11635. var _proto = Timeline.prototype;
  11636. _proto.play = function play() {
  11637. var self = this;
  11638. self.time = clock.now();
  11639. self.playing = true;
  11640. function step() {
  11641. if (self.playing) {
  11642. (0, _requestAnimationFrame.requestAnimationFrame)(step);
  11643. self.update();
  11644. }
  11645. }
  11646. (0, _requestAnimationFrame.requestAnimationFrame)(step);
  11647. };
  11648. _proto.stop = function stop() {
  11649. this.playing = false;
  11650. this.time = null;
  11651. this.canvas = [];
  11652. };
  11653. _proto.pushAnim = function pushAnim(animInfo) {
  11654. this.anims.push(animInfo);
  11655. if (this.playing) {
  11656. return;
  11657. }
  11658. this.play();
  11659. };
  11660. _proto.update = function update() {
  11661. var currentTime = clock.now();
  11662. this.canvas = [];
  11663. if (!this.anims.length) {
  11664. this.stop();
  11665. return;
  11666. }
  11667. for (var i = 0; i < this.anims.length; i++) {
  11668. var propertyAnim = this.anims[i];
  11669. if (currentTime < propertyAnim.startTime || propertyAnim.hasEnded) {
  11670. continue;
  11671. }
  11672. var shape = propertyAnim.shape; // shape
  11673. if (shape.get('destroyed')) {
  11674. this.anims.splice(i, 1);
  11675. i--;
  11676. continue;
  11677. }
  11678. var startState = propertyAnim.startState,
  11679. endState = propertyAnim.endState,
  11680. interpolate = propertyAnim.interpolate,
  11681. duration = propertyAnim.duration;
  11682. if (currentTime >= propertyAnim.startTime && !propertyAnim.hasStarted) {
  11683. propertyAnim.hasStarted = true;
  11684. if (propertyAnim.onStart) {
  11685. propertyAnim.onStart();
  11686. }
  11687. }
  11688. var t = (currentTime - propertyAnim.startTime) / duration;
  11689. t = Math.max(0, Math.min(t, 1));
  11690. t = propertyAnim.easing(t);
  11691. if (propertyAnim.onFrame) {
  11692. propertyAnim.onFrame(t);
  11693. } else {
  11694. for (var key in interpolate) {
  11695. var diff = interpolate[key];
  11696. var value = diff(t);
  11697. var newValue = void 0;
  11698. if (key === 'points') {
  11699. newValue = [];
  11700. var aLen = Math.max(startState.points.length, endState.points.length);
  11701. for (var j = 0; j < aLen; j += 2) {
  11702. newValue.push({
  11703. x: value[j],
  11704. y: value[j + 1]
  11705. });
  11706. }
  11707. } else {
  11708. newValue = value;
  11709. }
  11710. shape._attrs.attrs[key] = newValue;
  11711. shape._attrs.bbox = null; // should clear calculated bbox
  11712. }
  11713. }
  11714. var canvas = shape.get('canvas');
  11715. if (this.canvas.indexOf(canvas) === -1) {
  11716. this.canvas.push(canvas);
  11717. }
  11718. if (propertyAnim.onUpdate) {
  11719. propertyAnim.onUpdate(t);
  11720. }
  11721. if (currentTime >= propertyAnim.endTime && !propertyAnim.hasEnded) {
  11722. propertyAnim.hasEnded = true;
  11723. if (propertyAnim.onEnd) {
  11724. propertyAnim.onEnd();
  11725. }
  11726. }
  11727. if (t === 1) {
  11728. // end
  11729. this.anims.splice(i, 1);
  11730. i--;
  11731. }
  11732. }
  11733. this.canvas.map(function (c) {
  11734. c.draw();
  11735. return c;
  11736. });
  11737. this.time = clock.now();
  11738. };
  11739. return Timeline;
  11740. }();
  11741. var _default = Timeline;
  11742. exports["default"] = _default;
  11743. }, function(modId) { var map = {"../util/requestAnimationFrame":1658993502574}; return __REQUIRE__(map[modId], modId); })
  11744. __DEFINE__(1658993502628, function(require, module, exports) {
  11745. exports.__esModule = true;
  11746. exports["default"] = void 0;
  11747. var Easing = _interopRequireWildcard(require("./easing"));
  11748. function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
  11749. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
  11750. function plainArray(arr) {
  11751. var result = [];
  11752. for (var i = 0, len = arr.length; i < len; i++) {
  11753. if (arr[i]) {
  11754. result.push(arr[i].x);
  11755. result.push(arr[i].y);
  11756. }
  11757. }
  11758. return result;
  11759. }
  11760. function interpolateNumber(a, b) {
  11761. a = +a;
  11762. b -= a;
  11763. return function (t) {
  11764. return a + b * t;
  11765. };
  11766. }
  11767. function interpolateArray(a, b) {
  11768. var nb = b ? b.length : 0;
  11769. var na = a ? Math.min(nb, a.length) : 0;
  11770. var x = new Array(na);
  11771. var c = new Array(nb);
  11772. var i;
  11773. for (i = 0; i < na; ++i) {
  11774. x[i] = interpolateNumber(a[i], b[i]);
  11775. }
  11776. for (; i < nb; ++i) {
  11777. c[i] = b[i];
  11778. }
  11779. return function (t) {
  11780. for (i = 0; i < na; ++i) {
  11781. c[i] = x[i](t);
  11782. }
  11783. return c;
  11784. };
  11785. }
  11786. var Animator = /*#__PURE__*/function () {
  11787. function Animator(shape, source, timeline) {
  11788. this.hasStarted = false;
  11789. this.hasEnded = false;
  11790. this.shape = shape;
  11791. this.source = source;
  11792. this.timeline = timeline;
  11793. this.animate = null;
  11794. } // delay, attrs, duration, easing
  11795. var _proto = Animator.prototype;
  11796. _proto.to = function to(cfg) {
  11797. if (cfg === void 0) {
  11798. cfg = {};
  11799. }
  11800. var delay = cfg.delay || 0;
  11801. var attrs = cfg.attrs || {};
  11802. var duration = cfg.duration || 1000;
  11803. var easing; // 缓动函数
  11804. if (typeof cfg.easing === 'function') {
  11805. easing = cfg.easing;
  11806. } else {
  11807. easing = Easing[cfg.easing] || Easing.linear;
  11808. }
  11809. var animInfo = {
  11810. shape: this.shape,
  11811. startTime: this.timeline.time + delay,
  11812. duration: duration,
  11813. easing: easing
  11814. };
  11815. var interpolate = {}; // 差值函数
  11816. for (var attrName in attrs) {
  11817. var startValue = this.source[attrName];
  11818. var endValue = attrs[attrName];
  11819. if (attrName === 'points') {
  11820. startValue = plainArray(startValue);
  11821. endValue = plainArray(endValue);
  11822. interpolate.points = interpolateArray(startValue, endValue);
  11823. this.source.points = startValue;
  11824. attrs.points = endValue;
  11825. } else if (attrName === 'matrix') {
  11826. interpolate.matrix = interpolateArray(startValue, endValue);
  11827. } else {
  11828. interpolate[attrName] = interpolateNumber(startValue, endValue);
  11829. }
  11830. }
  11831. animInfo.interpolate = interpolate;
  11832. animInfo.startState = this.source;
  11833. animInfo.endState = attrs;
  11834. animInfo.endTime = animInfo.startTime + duration;
  11835. this.timeline.pushAnim(animInfo);
  11836. this.animate = animInfo;
  11837. return this;
  11838. };
  11839. _proto.onFrame = function onFrame(callback) {
  11840. // 自定义每一帧动画的动作
  11841. if (this.animate) {
  11842. this.animate.onFrame = function (frame) {
  11843. callback(frame);
  11844. };
  11845. }
  11846. return this;
  11847. };
  11848. _proto.onStart = function onStart(callback) {
  11849. if (this.animate) {
  11850. this.animate.onStart = function () {
  11851. callback();
  11852. };
  11853. }
  11854. return this;
  11855. };
  11856. _proto.onUpdate = function onUpdate(callback) {
  11857. if (this.animate) {
  11858. this.animate.onUpdate = function (frame) {
  11859. callback(frame);
  11860. };
  11861. }
  11862. return this;
  11863. };
  11864. _proto.onEnd = function onEnd(callback) {
  11865. if (this.animate) {
  11866. this.animate.onEnd = function () {
  11867. callback();
  11868. };
  11869. }
  11870. return this;
  11871. };
  11872. return Animator;
  11873. }();
  11874. var _default = Animator;
  11875. exports["default"] = _default;
  11876. }, function(modId) { var map = {"./easing":1658993502629}; return __REQUIRE__(map[modId], modId); })
  11877. __DEFINE__(1658993502629, function(require, module, exports) {
  11878. exports.__esModule = true;
  11879. exports.linear = linear;
  11880. exports.quadraticIn = quadraticIn;
  11881. exports.quadraticOut = quadraticOut;
  11882. exports.quadraticInOut = quadraticInOut;
  11883. exports.cubicIn = cubicIn;
  11884. exports.cubicOut = cubicOut;
  11885. exports.cubicInOut = cubicInOut;
  11886. exports.elasticIn = elasticIn;
  11887. exports.elasticOut = elasticOut;
  11888. exports.elasticInOut = elasticInOut;
  11889. exports.backIn = backIn;
  11890. exports.backOut = backOut;
  11891. exports.backInOut = backInOut;
  11892. exports.bounceIn = bounceIn;
  11893. exports.bounceOut = bounceOut;
  11894. exports.bounceInOut = bounceInOut;
  11895. function linear(k) {
  11896. return k;
  11897. }
  11898. function quadraticIn(k) {
  11899. return k * k;
  11900. }
  11901. function quadraticOut(k) {
  11902. return k * (2 - k);
  11903. }
  11904. function quadraticInOut(k) {
  11905. if ((k *= 2) < 1) {
  11906. return 0.5 * k * k;
  11907. }
  11908. return -0.5 * (--k * (k - 2) - 1);
  11909. }
  11910. function cubicIn(k) {
  11911. return k * k * k;
  11912. }
  11913. function cubicOut(k) {
  11914. return --k * k * k + 1;
  11915. }
  11916. function cubicInOut(k) {
  11917. if ((k *= 2) < 1) {
  11918. return 0.5 * k * k * k;
  11919. }
  11920. return 0.5 * ((k -= 2) * k * k + 2);
  11921. }
  11922. function elasticIn(k) {
  11923. var s;
  11924. var a = 0.1;
  11925. var p = 0.4;
  11926. if (k === 0) return 0;
  11927. if (k === 1) return 1;
  11928. if (!p) {
  11929. p = 0.3;
  11930. }
  11931. if (!a || a < 1) {
  11932. a = 1;
  11933. s = p / 4;
  11934. } else {
  11935. s = p / (2 * Math.PI) * Math.asin(1 / a);
  11936. }
  11937. return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  11938. }
  11939. function elasticOut(k) {
  11940. var s;
  11941. var a = 0.1;
  11942. var p = 0.4;
  11943. if (k === 0) return 0;
  11944. if (k === 1) return 1;
  11945. if (!p) {
  11946. p = 0.3;
  11947. }
  11948. if (!a || a < 1) {
  11949. a = 1;
  11950. s = p / 4;
  11951. } else {
  11952. s = p / (2 * Math.PI) * Math.asin(1 / a);
  11953. }
  11954. return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
  11955. }
  11956. function elasticInOut(k) {
  11957. var s;
  11958. var a = 0.1;
  11959. var p = 0.4;
  11960. if (k === 0) return 0;
  11961. if (k === 1) return 1;
  11962. if (!p) {
  11963. p = 0.3;
  11964. }
  11965. if (!a || a < 1) {
  11966. a = 1;
  11967. s = p / 4;
  11968. } else {
  11969. s = p / (2 * Math.PI) * Math.asin(1 / a);
  11970. }
  11971. if ((k *= 2) < 1) {
  11972. return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  11973. }
  11974. return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  11975. }
  11976. function backIn(k) {
  11977. var s = 1.70158;
  11978. return k * k * ((s + 1) * k - s);
  11979. }
  11980. function backOut(k) {
  11981. var s = 1.70158;
  11982. return (k = k - 1) * k * ((s + 1) * k + s) + 1;
  11983. }
  11984. function backInOut(k) {
  11985. var s = 1.70158 * 1.525;
  11986. if ((k *= 2) < 1) {
  11987. return 0.5 * (k * k * ((s + 1) * k - s));
  11988. }
  11989. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  11990. }
  11991. function bounceIn(k) {
  11992. return 1 - bounceOut(1 - k);
  11993. }
  11994. function bounceOut(k) {
  11995. if ((k /= 1) < 1 / 2.75) {
  11996. return 7.5625 * k * k;
  11997. } else if (k < 2 / 2.75) {
  11998. return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
  11999. } else if (k < 2.5 / 2.75) {
  12000. return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
  12001. }
  12002. return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
  12003. }
  12004. function bounceInOut(k) {
  12005. if (k < 0.5) {
  12006. return bounceIn(k * 2) * 0.5;
  12007. }
  12008. return bounceOut(k * 2 - 1) * 0.5 + 0.5;
  12009. }
  12010. }, function(modId) { var map = {}; return __REQUIRE__(map[modId], modId); })
  12011. __DEFINE__(1658993502630, function(require, module, exports) {
  12012. exports.__esModule = true;
  12013. exports["default"] = void 0;
  12014. var _common = require("../util/common");
  12015. function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
  12016. var defaultAnimationCfg = {
  12017. appear: {
  12018. duration: 450,
  12019. easing: 'quadraticOut'
  12020. },
  12021. // 'appear' animation options
  12022. update: {
  12023. duration: 300,
  12024. easing: 'quadraticOut'
  12025. },
  12026. // 'update' animation options
  12027. enter: {
  12028. duration: 300,
  12029. easing: 'quadraticOut'
  12030. },
  12031. // 'enter' animation options
  12032. leave: {
  12033. duration: 350,
  12034. easing: 'quadraticIn'
  12035. } // 'leave' animation options
  12036. };
  12037. var Animate = {
  12038. defaultCfg: {},
  12039. Action: {},
  12040. getAnimation: function getAnimation(geomType, coord, animationType) {
  12041. var geomAnimateCfg = this.defaultCfg[geomType];
  12042. if (geomAnimateCfg) {
  12043. var animation = geomAnimateCfg[animationType];
  12044. if ((0, _common.isFunction)(animation)) {
  12045. return animation(coord);
  12046. }
  12047. }
  12048. return false;
  12049. },
  12050. getAnimateCfg: function getAnimateCfg(geomType, animationType) {
  12051. var defaultCfg = defaultAnimationCfg[animationType];
  12052. var geomConfig = this.defaultCfg[geomType];
  12053. if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
  12054. return (0, _common.deepMix)({}, defaultCfg, geomConfig.cfg[animationType]);
  12055. }
  12056. return defaultCfg;
  12057. },
  12058. registerAnimation: function registerAnimation(animationName, animationFun) {
  12059. var _extends2;
  12060. if (!this.Action) {
  12061. this.Action = {};
  12062. }
  12063. this.Action = _extends({}, this.Action, (_extends2 = {}, _extends2[animationName] = animationFun, _extends2));
  12064. }
  12065. };
  12066. var _default = Animate;
  12067. exports["default"] = _default;
  12068. }, function(modId) { var map = {"../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  12069. __DEFINE__(1658993502631, function(require, module, exports) {
  12070. exports.__esModule = true;
  12071. exports.fadeIn = fadeIn;
  12072. var _common = require("../util/common");
  12073. var _util = require("./util");
  12074. /**
  12075. * Animation functions for shape
  12076. * @author sima.zhang1990@gmail.com
  12077. */
  12078. /*
  12079. function waveIn(shape, animateCfg, coord) {
  12080. const clip = Helpers.getClip(coord);
  12081. clip.set('canvas', shape.get('canvas'));
  12082. shape.attr('clip', clip);
  12083. const onEnd = function() {
  12084. shape.attr('clip', null);
  12085. clip.remove(true);
  12086. };
  12087. Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
  12088. }
  12089. function scaleInX(shape, animateCfg) {
  12090. const box = shape.getBBox();
  12091. const points = shape.get('origin').points;
  12092. let x;
  12093. const y = (box.minY + box.maxY) / 2;
  12094. if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
  12095. x = box.maxX;
  12096. } else {
  12097. x = box.minX;
  12098. }
  12099. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  12100. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  12101. }
  12102. function scaleInY(shape, animateCfg) {
  12103. const box = shape.getBBox();
  12104. const points = shape.get('origin').points;
  12105. const x = (box.minX + box.maxX) / 2;
  12106. let y;
  12107. if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
  12108. y = box.maxY;
  12109. } else {
  12110. y = box.minY;
  12111. }
  12112. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  12113. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  12114. }
  12115. */
  12116. function fadeIn(shape, animateCfg) {
  12117. var fillOpacity = (0, _common.isNil)(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
  12118. var strokeOpacity = (0, _common.isNil)(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
  12119. shape.attr('fillOpacity', 0);
  12120. shape.attr('strokeOpacity', 0);
  12121. var endState = {
  12122. fillOpacity: fillOpacity,
  12123. strokeOpacity: strokeOpacity
  12124. };
  12125. (0, _util.doAnimation)(shape, endState, animateCfg);
  12126. }
  12127. }, function(modId) { var map = {"../util/common":1658993502535,"./util":1658993502632}; return __REQUIRE__(map[modId], modId); })
  12128. __DEFINE__(1658993502632, function(require, module, exports) {
  12129. exports.__esModule = true;
  12130. exports.getCoordInfo = getCoordInfo;
  12131. exports.getScaledMatrix = getScaledMatrix;
  12132. exports.getAnimateParam = getAnimateParam;
  12133. exports.doAnimation = doAnimation;
  12134. var _index = require("../graphic/index");
  12135. var _common = require("../util/common");
  12136. /**
  12137. * Utility
  12138. * @author sima.zhang1990@gmail.com
  12139. */
  12140. function getCoordInfo(coord) {
  12141. var start = coord.start;
  12142. var end = coord.end;
  12143. return {
  12144. start: start,
  12145. end: end,
  12146. width: end.x - start.x,
  12147. height: Math.abs(end.y - start.y)
  12148. };
  12149. }
  12150. function getScaledMatrix(shape, v, direct) {
  12151. var scaledMatrix;
  12152. shape.apply(v);
  12153. var x = v[0];
  12154. var y = v[1];
  12155. if (direct === 'x') {
  12156. shape.transform([['t', x, y], ['s', 0.01, 1], ['t', -x, -y]]);
  12157. var matrix = shape.getMatrix();
  12158. scaledMatrix = _index.Matrix.transform(matrix, [['t', x, y], ['s', 100, 1], ['t', -x, -y]]);
  12159. } else if (direct === 'y') {
  12160. shape.transform([['t', x, y], ['s', 1, 0.01], ['t', -x, -y]]);
  12161. var _matrix = shape.getMatrix();
  12162. scaledMatrix = _index.Matrix.transform(_matrix, [['t', x, y], ['s', 1, 100], ['t', -x, -y]]);
  12163. } else if (direct === 'xy') {
  12164. shape.transform([['t', x, y], ['s', 0.01, 0.01], ['t', -x, -y]]);
  12165. var _matrix2 = shape.getMatrix();
  12166. scaledMatrix = _index.Matrix.transform(_matrix2, [['t', x, y], ['s', 100, 100], ['t', -x, -y]]);
  12167. }
  12168. return scaledMatrix;
  12169. }
  12170. function getAnimateParam(animateCfg, index, id) {
  12171. var result = {};
  12172. if (animateCfg.delay) {
  12173. result.delay = (0, _common.isFunction)(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
  12174. }
  12175. result.easing = animateCfg.easing;
  12176. result.duration = animateCfg.duration;
  12177. result.delay = animateCfg.delay;
  12178. return result;
  12179. }
  12180. function doAnimation(shape, endState, animateCfg, callback) {
  12181. var id = shape._id;
  12182. var index = shape.get('index');
  12183. var _getAnimateParam = getAnimateParam(animateCfg, index, id),
  12184. easing = _getAnimateParam.easing,
  12185. delay = _getAnimateParam.delay,
  12186. duration = _getAnimateParam.duration;
  12187. var anim = shape.animate().to({
  12188. attrs: endState,
  12189. duration: duration,
  12190. delay: delay,
  12191. easing: easing
  12192. });
  12193. if (callback) {
  12194. anim.onEnd(function () {
  12195. callback();
  12196. });
  12197. }
  12198. }
  12199. }, function(modId) { var map = {"../graphic/index":1658993502565,"../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  12200. __DEFINE__(1658993502633, function(require, module, exports) {
  12201. exports.__esModule = true;
  12202. exports.groupWaveIn = groupWaveIn;
  12203. exports.groupScaleInX = groupScaleInX;
  12204. exports.groupScaleInY = groupScaleInY;
  12205. exports.groupScaleInXY = groupScaleInXY;
  12206. exports.shapesScaleInX = shapesScaleInX;
  12207. exports.shapesScaleInY = shapesScaleInY;
  12208. exports.shapesScaleInXY = shapesScaleInXY;
  12209. var _util = require("./util");
  12210. var _helper = require("../util/helper");
  12211. var _index = require("../graphic/index");
  12212. /**
  12213. * Group animate functions
  12214. * @author sima.zhang1990@gmail.com
  12215. */
  12216. function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
  12217. var _getCoordInfo = (0, _util.getCoordInfo)(coord),
  12218. start = _getCoordInfo.start,
  12219. end = _getCoordInfo.end,
  12220. width = _getCoordInfo.width,
  12221. height = _getCoordInfo.height;
  12222. var x;
  12223. var y;
  12224. var clip = new _index.Shape.Rect({
  12225. attrs: {
  12226. x: start.x,
  12227. y: end.y,
  12228. width: width,
  12229. height: height
  12230. }
  12231. });
  12232. if (type === 'y') {
  12233. x = start.x + width / 2;
  12234. y = zeroY.y < start.y ? zeroY.y : start.y;
  12235. } else if (type === 'x') {
  12236. x = zeroY.x > start.x ? zeroY.x : start.x;
  12237. y = start.y + height / 2;
  12238. } else if (type === 'xy') {
  12239. if (coord.isPolar) {
  12240. x = coord.center.x;
  12241. y = coord.center.y;
  12242. } else {
  12243. x = (start.x + end.x) / 2;
  12244. y = (start.y + end.y) / 2;
  12245. }
  12246. }
  12247. var endMatrix = (0, _util.getScaledMatrix)(clip, [x, y], type);
  12248. clip.isClip = true;
  12249. clip.endState = {
  12250. matrix: endMatrix
  12251. };
  12252. clip.set('canvas', container.get('canvas'));
  12253. container.attr('clip', clip);
  12254. var onEnd = function onEnd() {
  12255. container.attr('clip', null);
  12256. clip.remove(true);
  12257. };
  12258. (0, _util.doAnimation)(clip, clip.endState, animateCfg, onEnd);
  12259. }
  12260. function _shapeScale(container, animateCfg, type) {
  12261. var shapes = container.get('children');
  12262. var x;
  12263. var y;
  12264. var endMatrix;
  12265. for (var i = 0, len = shapes.length; i < len; i++) {
  12266. var shape = shapes[i];
  12267. var box = shape.getBBox();
  12268. x = (box.minX + box.maxX) / 2;
  12269. y = (box.minY + box.maxY) / 2;
  12270. endMatrix = (0, _util.getScaledMatrix)(shape, [x, y], type);
  12271. (0, _util.doAnimation)(shape, {
  12272. matrix: endMatrix
  12273. }, animateCfg);
  12274. }
  12275. }
  12276. function groupScaleInX(container, animateCfg, coord, zeroY) {
  12277. _groupScaleIn(container, animateCfg, coord, zeroY, 'x');
  12278. }
  12279. function groupScaleInY(container, animateCfg, coord, zeroY) {
  12280. _groupScaleIn(container, animateCfg, coord, zeroY, 'y');
  12281. }
  12282. function groupScaleInXY(container, animateCfg, coord, zeroY) {
  12283. _groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
  12284. }
  12285. function shapesScaleInX(container, animateCfg) {
  12286. _shapeScale(container, animateCfg, 'x');
  12287. }
  12288. function shapesScaleInY(container, animateCfg) {
  12289. _shapeScale(container, animateCfg, 'y');
  12290. }
  12291. function shapesScaleInXY(container, animateCfg) {
  12292. _shapeScale(container, animateCfg, 'xy');
  12293. }
  12294. function groupWaveIn(container, animateCfg, coord) {
  12295. var clip = (0, _helper.getClip)(coord);
  12296. clip.set('canvas', container.get('canvas'));
  12297. container.attr('clip', clip);
  12298. var onEnd = function onEnd() {
  12299. container.attr('clip', null);
  12300. clip.remove(true);
  12301. };
  12302. var endState = {};
  12303. if (coord.isPolar) {
  12304. var startAngle = coord.startAngle,
  12305. endAngle = coord.endAngle;
  12306. endState.endAngle = endAngle;
  12307. clip.attr('endAngle', startAngle);
  12308. } else {
  12309. var start = coord.start,
  12310. end = coord.end;
  12311. var width = Math.abs(start.x - end.x);
  12312. var height = Math.abs(start.y - end.y);
  12313. if (coord.isTransposed) {
  12314. clip.attr('height', 0);
  12315. endState.height = height;
  12316. } else {
  12317. clip.attr('width', 0);
  12318. endState.width = width;
  12319. }
  12320. }
  12321. (0, _util.doAnimation)(clip, endState, animateCfg, onEnd);
  12322. }
  12323. }, function(modId) { var map = {"./util":1658993502632,"../util/helper":1658993502588,"../graphic/index":1658993502565}; return __REQUIRE__(map[modId], modId); })
  12324. __DEFINE__(1658993502634, function(require, module, exports) {
  12325. var _register = _interopRequireDefault(require("../register"));
  12326. var _pan = _interopRequireDefault(require("./pan"));
  12327. var _pinch = _interopRequireDefault(require("./pinch"));
  12328. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12329. // 注册交互
  12330. _register["default"].registerInteraction('pan', _pan["default"]);
  12331. _register["default"].registerInteraction('pinch', _pinch["default"]);
  12332. }, function(modId) { var map = {"../register":1658993502635,"./pan":1658993502636,"./pinch":1658993502639}; return __REQUIRE__(map[modId], modId); })
  12333. __DEFINE__(1658993502635, function(require, module, exports) {
  12334. exports.__esModule = true;
  12335. exports["default"] = void 0;
  12336. var _common = require("../util/common");
  12337. var _chart = _interopRequireDefault(require("../chart/chart"));
  12338. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12339. _chart["default"]._Interactions = {};
  12340. _chart["default"].registerInteraction = function (type, constructor) {
  12341. _chart["default"]._Interactions[type] = constructor;
  12342. };
  12343. _chart["default"].getInteraction = function (type) {
  12344. return _chart["default"]._Interactions[type];
  12345. };
  12346. _chart["default"].prototype.interaction = function (type, cfg) {
  12347. var interactions = this._interactions || {};
  12348. if (interactions[type]) {
  12349. // if reprated, destroy last
  12350. interactions[type].destroy();
  12351. }
  12352. var Ctor = _chart["default"].getInteraction(type);
  12353. var interact = new Ctor(cfg, this);
  12354. interactions[type] = interact;
  12355. this._interactions = interactions;
  12356. return this;
  12357. };
  12358. _chart["default"].prototype.clearInteraction = function (type) {
  12359. var interactions = this._interactions;
  12360. if (!interactions) return;
  12361. if (type) {
  12362. interactions[type] && interactions[type].destroy();
  12363. delete interactions[type];
  12364. } else {
  12365. (0, _common.each)(interactions, function (interaction, key) {
  12366. interaction.destroy();
  12367. delete interactions[key];
  12368. });
  12369. }
  12370. return this;
  12371. };
  12372. var _default = _chart["default"];
  12373. exports["default"] = _default;
  12374. }, function(modId) { var map = {"../util/common":1658993502535,"../chart/chart":1658993502538}; return __REQUIRE__(map[modId], modId); })
  12375. __DEFINE__(1658993502636, function(require, module, exports) {
  12376. exports.__esModule = true;
  12377. exports["default"] = void 0;
  12378. var _base = _interopRequireDefault(require("./base"));
  12379. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12380. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  12381. var Pan = /*#__PURE__*/function (_Base) {
  12382. _inheritsLoose(Pan, _Base);
  12383. function Pan() {
  12384. return _Base.apply(this, arguments) || this;
  12385. }
  12386. var _proto = Pan.prototype;
  12387. _proto.getDefaultCfg = function getDefaultCfg() {
  12388. return {
  12389. type: 'pan',
  12390. startEvent: 'panstart',
  12391. processEvent: 'pan',
  12392. endEvent: 'panend'
  12393. };
  12394. };
  12395. _proto.start = function start() {
  12396. var context = this.context;
  12397. context.start();
  12398. };
  12399. _proto.process = function process(e) {
  12400. var direction = e.direction,
  12401. deltaX = e.deltaX;
  12402. if (direction === 'up' || direction === 'down') {
  12403. return;
  12404. }
  12405. e.preventDefault && e.preventDefault();
  12406. var context = this.context;
  12407. var chart = context.chart;
  12408. var coord = chart.get('coord');
  12409. var start = coord.start,
  12410. end = coord.end;
  12411. var coordWidth = end.x - start.x;
  12412. var ratio = deltaX / coordWidth;
  12413. context.doMove(ratio);
  12414. };
  12415. return Pan;
  12416. }(_base["default"]);
  12417. var _default = Pan;
  12418. exports["default"] = _default;
  12419. }, function(modId) { var map = {"./base":1658993502637}; return __REQUIRE__(map[modId], modId); })
  12420. __DEFINE__(1658993502637, function(require, module, exports) {
  12421. exports.__esModule = true;
  12422. exports["default"] = void 0;
  12423. var _common = require("../../util/common");
  12424. var _context = _interopRequireDefault(require("./context"));
  12425. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12426. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  12427. var Base = /*#__PURE__*/function () {
  12428. var _proto = Base.prototype;
  12429. // 交互的上下文
  12430. _proto.getDefaultCfg = function getDefaultCfg() {
  12431. return {};
  12432. };
  12433. _proto.getInteractionContext = function getInteractionContext(chart) {
  12434. var interactionContext = chart.get('interactionContext');
  12435. if (interactionContext) {
  12436. return interactionContext;
  12437. }
  12438. interactionContext = new _context["default"](chart);
  12439. chart.set('interactionContext', interactionContext);
  12440. return interactionContext;
  12441. };
  12442. function Base(cfg, chart) {
  12443. var _this = this;
  12444. _defineProperty(this, "type", '');
  12445. _defineProperty(this, "startEvent", 'touchstart');
  12446. _defineProperty(this, "processEvent", 'touchmove');
  12447. _defineProperty(this, "endEvent", 'touchend');
  12448. _defineProperty(this, "resetEvent", null);
  12449. _defineProperty(this, "context", null);
  12450. _defineProperty(this, "_start", function (ev) {
  12451. _this.preStart && _this.preStart(ev);
  12452. _this.start(ev);
  12453. _this.onStart && _this.onStart(ev);
  12454. });
  12455. _defineProperty(this, "_process", function (ev) {
  12456. _this.preProcess && _this.preProcess(ev);
  12457. _this.process(ev);
  12458. _this.onProcess && _this.onProcess(ev);
  12459. });
  12460. _defineProperty(this, "_end", function (ev) {
  12461. _this.preEnd && _this.preEnd(ev);
  12462. _this.end(ev);
  12463. _this.onEnd && _this.onEnd(ev);
  12464. });
  12465. _defineProperty(this, "_reset", function (ev) {
  12466. _this.preReset && _this.preReset(ev);
  12467. _this.reset(ev);
  12468. _this.onReset && _this.onReset(ev);
  12469. });
  12470. (0, _common.mix)(this, this.getDefaultCfg(), cfg);
  12471. this.context = this.getInteractionContext(chart);
  12472. this.chart = chart; // 只处理range, 暂时先这么处理后面再看情况调整
  12473. var range = this.range;
  12474. if (range) {
  12475. this.context.range = range;
  12476. }
  12477. this._bindEvents(chart);
  12478. }
  12479. _proto._bindEvents = function _bindEvents(chart) {
  12480. var startEvent = this.startEvent,
  12481. processEvent = this.processEvent,
  12482. endEvent = this.endEvent,
  12483. resetEvent = this.resetEvent;
  12484. var canvas = chart.get('canvas'); // 统一绑定事件
  12485. canvas.on(startEvent, this._start);
  12486. canvas.on(processEvent, this._process);
  12487. canvas.on(endEvent, this._end);
  12488. canvas.on(resetEvent, this._reset);
  12489. };
  12490. _proto._clearEvents = function _clearEvents() {
  12491. var chart = this.chart,
  12492. startEvent = this.startEvent,
  12493. processEvent = this.processEvent,
  12494. endEvent = this.endEvent,
  12495. resetEvent = this.resetEvent;
  12496. var canvas = chart.get('canvas'); // 统一绑定事件
  12497. canvas.off(startEvent, this._start);
  12498. canvas.off(processEvent, this._process);
  12499. canvas.off(endEvent, this._end);
  12500. canvas.off(resetEvent, this._start);
  12501. };
  12502. // override
  12503. _proto.start = function start() {} // override
  12504. ;
  12505. _proto.process = function process() {} // override
  12506. ;
  12507. _proto.end = function end() {} // override
  12508. ;
  12509. _proto.reset = function reset() {};
  12510. _proto.destroy = function destroy() {
  12511. this.context.destroy();
  12512. this._clearEvents();
  12513. };
  12514. return Base;
  12515. }();
  12516. var _default = Base;
  12517. exports["default"] = _default;
  12518. }, function(modId) { var map = {"../../util/common":1658993502535,"./context":1658993502638}; return __REQUIRE__(map[modId], modId); })
  12519. __DEFINE__(1658993502638, function(require, module, exports) {
  12520. exports.__esModule = true;
  12521. exports["default"] = void 0;
  12522. var _scale = require("../../scale");
  12523. var _array = require("../../util/array");
  12524. var _const = require("../../chart/const");
  12525. var _common = require("../../util/common");
  12526. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  12527. // 判断新老values是否相等,这里只要判断前后是否相等即可
  12528. function isValuesEqual(values, newValues) {
  12529. if (values.length !== newValues.length) {
  12530. return false;
  12531. }
  12532. var lastIndex = values.length - 1;
  12533. return values[0] === newValues[0] && values[lastIndex] === newValues[lastIndex];
  12534. } // 不同交互之间共享的上下文
  12535. var defaultRange = [0, 1];
  12536. var Context = /*#__PURE__*/function () {
  12537. // 最开始的原始值
  12538. // 当前显示的范围
  12539. // 缩放最小的点数
  12540. // 最小的缩放比例, 默认通过minCount计算
  12541. // minScale = 0.01;
  12542. // 交互开始时,ticks个数,主要为了每次缩放后,更新ticks个数
  12543. // lastTickCount;
  12544. function Context(chart) {
  12545. var _this = this;
  12546. _defineProperty(this, "chart", null);
  12547. _defineProperty(this, "values", null);
  12548. _defineProperty(this, "range", defaultRange);
  12549. _defineProperty(this, "startRange", defaultRange);
  12550. _defineProperty(this, "minCount", 10);
  12551. _defineProperty(this, "_afterinit", function () {
  12552. // 初始化value值
  12553. var scale = _this.getPinchScale(); // 记录原始全量数据
  12554. var values = [].concat(scale.values);
  12555. _this.values = values; // 最小的缩放比例
  12556. if (!_this.minScale) {
  12557. _this.minScale = _this.minCount / values.length;
  12558. } // 初始化的时候有设置range,则初始化成默认比例
  12559. if (_this.range !== defaultRange) {
  12560. _this.updateRange(_this.range);
  12561. _this.updateTicks();
  12562. }
  12563. });
  12564. _defineProperty(this, "_afterdatachange", function () {
  12565. _this.updateRange(_this.range);
  12566. });
  12567. this.chart = chart;
  12568. this._initEvent(chart);
  12569. }
  12570. var _proto = Context.prototype;
  12571. _proto._initEvent = function _initEvent(chart) {
  12572. // 在整体初始化后还需要设置一些初始状态
  12573. chart.on(_const.EVENT_AFTER_INIT, this._afterinit);
  12574. chart.on(_const.EVENT_AFTER_DATA_CHANGE, this._afterdatachange);
  12575. } // 缩放的主轴scale
  12576. ;
  12577. _proto.getPinchScale = function getPinchScale() {
  12578. var chart = this.chart; // 默认缩放x轴
  12579. var scale = chart.getXScale();
  12580. return scale;
  12581. } // 跟随轴的scale
  12582. ;
  12583. _proto.getFollowScale = function getFollowScale() {
  12584. var chart = this.chart; // 默认缩放x轴
  12585. var scales = chart.getYScales() || [];
  12586. return scales[0];
  12587. };
  12588. _proto.start = function start() {
  12589. var range = this.range;
  12590. var scale = this.getPinchScale();
  12591. var start = range[0],
  12592. end = range[1]; // 记录交互起始的范围
  12593. this.startRange = [start, end]; // 记录开始时的ticks个数
  12594. this.lastTickCount = scale.tickCount;
  12595. };
  12596. _proto.doZoom = function doZoom(leftScale, rightScale, zoom) {
  12597. var range = this.startRange,
  12598. minScale = this.minScale;
  12599. var start = range[0],
  12600. end = range[1];
  12601. var zoomOffset = 1 - zoom;
  12602. var rangeLen = end - start;
  12603. var rangeOffset = rangeLen * zoomOffset;
  12604. var leftOffset = rangeOffset * leftScale;
  12605. var rightOffset = rangeOffset * rightScale;
  12606. var newStart = Math.max(0, start - leftOffset);
  12607. var newEnd = Math.min(1, end + rightOffset);
  12608. var newRange = [newStart, newEnd]; // 如果已经到了最小比例,则不能再继续再放大
  12609. if (newEnd - newStart < minScale) {
  12610. return;
  12611. }
  12612. this.updateRange(newRange);
  12613. };
  12614. _proto.doMove = function doMove(ratio) {
  12615. // 不管是0, 还是其他,都不用处理
  12616. if (!ratio) return;
  12617. var range = this.startRange;
  12618. var start = range[0],
  12619. end = range[1];
  12620. var rangeLen = end - start;
  12621. var rangeOffset = rangeLen * ratio;
  12622. var newStart = start - rangeOffset;
  12623. var newEnd = end - rangeOffset; // 处理边界值
  12624. var newRange;
  12625. if (newStart < 0) {
  12626. newRange = [0, rangeLen];
  12627. } else if (newEnd > 1) {
  12628. newRange = [1 - rangeLen, 1];
  12629. } else {
  12630. newRange = [newStart, newEnd];
  12631. }
  12632. this.updateRange(newRange);
  12633. };
  12634. _proto.updateRange = function updateRange(range) {
  12635. var values = this.values; // 0, 1 的范围之间
  12636. var start = range[0],
  12637. end = range[1]; // start 不能小于0
  12638. start = Math.max(0, start); // end 不能大于1
  12639. end = Math.min(1, end); // 设置当前的范围
  12640. this.range = [start, end];
  12641. var len = values.length;
  12642. var valueStart = start * len;
  12643. var valueEnd = end * len; // 从原始数据里截取需要显示的数据
  12644. var newValues = values.slice(valueStart, valueEnd);
  12645. this.repaint(newValues);
  12646. };
  12647. _proto.repaint = function repaint(newValues) {
  12648. var chart = this.chart;
  12649. var scale = this.getPinchScale();
  12650. var currentValues = scale.values,
  12651. ticks = scale.ticks; // 如果新数组和当前显示的数组相同,则不更新
  12652. if (isValuesEqual(currentValues, newValues)) {
  12653. return;
  12654. } // 更新主轴values
  12655. this.updateScale(scale, {
  12656. ticks: ticks,
  12657. values: newValues
  12658. });
  12659. this.updateFollowScale(scale, newValues);
  12660. chart.repaint();
  12661. };
  12662. _proto.updateFollowScale = function updateFollowScale(pinchScale, pinchValues) {
  12663. var chart = this.chart;
  12664. var followScale = this.getFollowScale();
  12665. var pinchField = pinchScale.field,
  12666. pinchScaleType = pinchScale.type;
  12667. var followField = followScale.field; // 根据主轴的value值,找到所有从轴的value值
  12668. var values = []; // 转成map,让查找性能更高
  12669. var pinchValueMap = {};
  12670. pinchValues.forEach(function (item) {
  12671. pinchValueMap[item] = true;
  12672. });
  12673. var data = chart.get('data');
  12674. data.forEach(function (item) {
  12675. if (pinchScaleType === 'timeCat') {
  12676. var value = (0, _common.toTimeStamp)(item[pinchField]);
  12677. if (pinchValueMap[value]) {
  12678. values.push(item[followField]);
  12679. }
  12680. }
  12681. });
  12682. var _getRange = (0, _array.getRange)(values),
  12683. min = _getRange.min,
  12684. max = _getRange.max;
  12685. this.updateScale(followScale, {
  12686. min: min,
  12687. max: max,
  12688. nice: true
  12689. });
  12690. };
  12691. _proto.updateScale = function updateScale(scale, cfg) {
  12692. if (!scale) {
  12693. return;
  12694. }
  12695. scale.change(cfg);
  12696. } // 上一次的tick个数
  12697. ;
  12698. _proto.updateTicks = function updateTicks() {
  12699. var chart = this.chart,
  12700. values = this.values;
  12701. var scale = this.getPinchScale();
  12702. var currentValues = scale.values,
  12703. tickCount = scale.tickCount; // 根据当前数据的比例,和定义的tickCount计算应该需要多少个ticks
  12704. var newTickCount = Math.round(tickCount * values.length / currentValues.length);
  12705. var catTicks = (0, _scale.getTickMethod)('cat');
  12706. var ticks = catTicks({
  12707. tickCount: newTickCount,
  12708. values: values
  12709. });
  12710. this.updateScale(scale, {
  12711. ticks: ticks,
  12712. values: currentValues
  12713. }); // 更新完后,需要重新绘制一次
  12714. chart.repaint();
  12715. };
  12716. _proto.destroy = function destroy() {
  12717. var chart = this.chart;
  12718. chart.off(_const.EVENT_AFTER_INIT, this._afterinit);
  12719. chart.off(_const.EVENT_AFTER_DATA_CHANGE, this._afterdatachange);
  12720. };
  12721. return Context;
  12722. }();
  12723. var _default = Context;
  12724. exports["default"] = _default;
  12725. }, function(modId) { var map = {"../../scale":1658993502558,"../../util/array":1658993502536,"../../chart/const":1658993502539,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  12726. __DEFINE__(1658993502639, function(require, module, exports) {
  12727. exports.__esModule = true;
  12728. exports["default"] = void 0;
  12729. var _base = _interopRequireDefault(require("./base"));
  12730. var _common = require("../../util/common");
  12731. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  12732. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  12733. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  12734. var Pinch = /*#__PURE__*/function (_Base) {
  12735. _inheritsLoose(Pinch, _Base);
  12736. var _proto = Pinch.prototype;
  12737. _proto.getDefaultCfg = function getDefaultCfg() {
  12738. return {
  12739. type: 'pinch',
  12740. startEvent: 'pinchstart',
  12741. processEvent: 'pinch',
  12742. endEvent: 'pinchend'
  12743. };
  12744. };
  12745. function Pinch(cfg, chart) {
  12746. var _this;
  12747. _this = _Base.call(this, cfg, chart) || this;
  12748. var _assertThisInitialize = _assertThisInitialized(_this),
  12749. context = _assertThisInitialize.context;
  12750. (0, _common.mix)(context, cfg);
  12751. return _this;
  12752. }
  12753. _proto.start = function start() {
  12754. var context = this.context;
  12755. context.start();
  12756. };
  12757. _proto.process = function process(e) {
  12758. e.preventDefault && e.preventDefault();
  12759. var zoom = e.zoom,
  12760. center = e.center;
  12761. var context = this.context;
  12762. var chart = context.chart;
  12763. var coord = chart.get('coord');
  12764. var start = coord.start,
  12765. end = coord.end;
  12766. var coordWidth = end.x - start.x;
  12767. var leftLen = Math.abs(center.x - start.x);
  12768. var rightLen = Math.abs(end.x - center.x); // 计算左右缩放的比例
  12769. var leftScale = leftLen / coordWidth;
  12770. var rightScale = rightLen / coordWidth;
  12771. context.doZoom(leftScale, rightScale, zoom);
  12772. };
  12773. _proto.end = function end() {
  12774. // 缩放完成后再更新ticks
  12775. var context = this.context;
  12776. context.updateTicks();
  12777. };
  12778. return Pinch;
  12779. }(_base["default"]);
  12780. var _default = Pinch;
  12781. exports["default"] = _default;
  12782. }, function(modId) { var map = {"./base":1658993502637,"../../util/common":1658993502535}; return __REQUIRE__(map[modId], modId); })
  12783. return __REQUIRE__(1658993502531);
  12784. })()
  12785. //miniprogram-npm-outsideDeps=["@antv/util","@antv/adjust/lib/base","@antv/scale","@antv/adjust/lib/stack","@antv/adjust/lib/dodge","@antv/adjust/lib/symmetric"]
  12786. //# sourceMappingURL=index.js.map