f2.js 359 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["F2"] = factory();
  8. else
  9. root["F2"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, {
  50. /******/ configurable: false,
  51. /******/ enumerable: true,
  52. /******/ get: getter
  53. /******/ });
  54. /******/ }
  55. /******/ };
  56. /******/
  57. /******/ // getDefaultExport function for compatibility with non-harmony modules
  58. /******/ __webpack_require__.n = function(module) {
  59. /******/ var getter = module && module.__esModule ?
  60. /******/ function getDefault() { return module['default']; } :
  61. /******/ function getModuleExports() { return module; };
  62. /******/ __webpack_require__.d(getter, 'a', getter);
  63. /******/ return getter;
  64. /******/ };
  65. /******/
  66. /******/ // Object.prototype.hasOwnProperty.call
  67. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  68. /******/
  69. /******/ // __webpack_public_path__
  70. /******/ __webpack_require__.p = "";
  71. /******/
  72. /******/ // Load entry module and return exports
  73. /******/ return __webpack_require__(__webpack_require__.s = 129);
  74. /******/ })
  75. /************************************************************************/
  76. /******/ ([
  77. /* 0 */
  78. /***/ (function(module, exports, __webpack_require__) {
  79. /**
  80. * @fileOverview Utility for F2
  81. * @author dxq613@gmail.com
  82. */
  83. var DomUtil = __webpack_require__(43);
  84. var Util = {
  85. upperFirst: __webpack_require__(44),
  86. lowerFirst: __webpack_require__(45),
  87. isString: __webpack_require__(15),
  88. isNumber: __webpack_require__(13),
  89. isBoolean: __webpack_require__(46),
  90. isFunction: __webpack_require__(47),
  91. isDate: __webpack_require__(33),
  92. isArray: __webpack_require__(10),
  93. isNil: __webpack_require__(7),
  94. isObject: __webpack_require__(18),
  95. isPlainObject: __webpack_require__(28),
  96. deepMix: __webpack_require__(49),
  97. mix: __webpack_require__(16),
  98. each: __webpack_require__(3),
  99. isObjectValueEqual: function isObjectValueEqual(a, b) {
  100. // for vue.js
  101. a = Object.assign({}, a);
  102. b = Object.assign({}, b);
  103. var aProps = Object.getOwnPropertyNames(a);
  104. var bProps = Object.getOwnPropertyNames(b);
  105. if (aProps.length !== bProps.length) {
  106. return false;
  107. }
  108. for (var i = 0, len = aProps.length; i < len; i++) {
  109. var propName = aProps[i];
  110. if (a[propName] !== b[propName]) {
  111. return false;
  112. }
  113. }
  114. return true;
  115. },
  116. wrapBehavior: function wrapBehavior(obj, action) {
  117. if (obj['_wrap_' + action]) {
  118. return obj['_wrap_' + action];
  119. }
  120. var method = function method(e) {
  121. obj[action](e);
  122. };
  123. obj['_wrap_' + action] = method;
  124. return method;
  125. },
  126. getWrapBehavior: function getWrapBehavior(obj, action) {
  127. return obj['_wrap_' + action];
  128. },
  129. parsePadding: function parsePadding(padding) {
  130. var top;
  131. var right;
  132. var bottom;
  133. var left;
  134. if (Util.isNumber(padding) || Util.isString(padding)) {
  135. top = bottom = left = right = padding;
  136. } else if (Util.isArray(padding)) {
  137. top = padding[0];
  138. right = !Util.isNil(padding[1]) ? padding[1] : padding[0];
  139. bottom = !Util.isNil(padding[2]) ? padding[2] : padding[0];
  140. left = !Util.isNil(padding[3]) ? padding[3] : right;
  141. }
  142. return [top, right, bottom, left];
  143. },
  144. directionEnabled: function directionEnabled(mode, dir) {
  145. if (mode === undefined) {
  146. return true;
  147. } else if (typeof mode === 'string') {
  148. return mode.indexOf(dir) !== -1;
  149. }
  150. return false;
  151. }
  152. };
  153. Util.Array = {
  154. merge: function merge(dataArray) {
  155. var rst = [];
  156. for (var i = 0, len = dataArray.length; i < len; i++) {
  157. rst = rst.concat(dataArray[i]);
  158. }
  159. return rst;
  160. },
  161. values: function values(data, name) {
  162. var rst = [];
  163. var tmpMap = {};
  164. for (var i = 0, len = data.length; i < len; i++) {
  165. var obj = data[i];
  166. var value = obj[name];
  167. if (!Util.isNil(value)) {
  168. if (!Util.isArray(value)) {
  169. if (!tmpMap[value]) {
  170. rst.push(value);
  171. tmpMap[value] = true;
  172. }
  173. } else {
  174. Util.each(value, function (val) {
  175. if (!tmpMap[val]) {
  176. rst.push(val);
  177. tmpMap[val] = true;
  178. }
  179. });
  180. }
  181. }
  182. }
  183. return rst;
  184. },
  185. firstValue: function firstValue(data, name) {
  186. var rst = null;
  187. for (var i = 0, len = data.length; i < len; i++) {
  188. var obj = data[i];
  189. var value = obj[name];
  190. if (!Util.isNil(value)) {
  191. if (Util.isArray(value)) {
  192. rst = value[0];
  193. } else {
  194. rst = value;
  195. }
  196. break;
  197. }
  198. }
  199. return rst;
  200. },
  201. group: function group(data, fields, appendConditions) {
  202. if (appendConditions === void 0) {
  203. appendConditions = {};
  204. }
  205. if (!fields) {
  206. return [data];
  207. }
  208. var groups = Util.Array.groupToMap(data, fields);
  209. var array = [];
  210. if (fields.length === 1 && appendConditions[fields[0]]) {
  211. var values = appendConditions[fields[0]];
  212. Util.each(values, function (value) {
  213. value = '_' + value;
  214. array.push(groups[value]);
  215. });
  216. } else {
  217. for (var i in groups) {
  218. array.push(groups[i]);
  219. }
  220. }
  221. return array;
  222. },
  223. groupToMap: function groupToMap(data, fields) {
  224. if (!fields) {
  225. return {
  226. 0: data
  227. };
  228. }
  229. var callback = function callback(row) {
  230. var unique = '_';
  231. for (var i = 0, l = fields.length; i < l; i++) {
  232. unique += row[fields[i]] && row[fields[i]].toString();
  233. }
  234. return unique;
  235. };
  236. var groups = {};
  237. for (var i = 0, len = data.length; i < len; i++) {
  238. var row = data[i];
  239. var key = callback(row);
  240. if (groups[key]) {
  241. groups[key].push(row);
  242. } else {
  243. groups[key] = [row];
  244. }
  245. }
  246. return groups;
  247. },
  248. remove: function remove(arr, obj) {
  249. if (!arr) {
  250. return;
  251. }
  252. var index = arr.indexOf(obj);
  253. if (index !== -1) {
  254. arr.splice(index, 1);
  255. }
  256. },
  257. getRange: function getRange(values) {
  258. if (!values.length) {
  259. return {
  260. min: 0,
  261. max: 0
  262. };
  263. }
  264. var max = Math.max.apply(null, values);
  265. var min = Math.min.apply(null, values);
  266. return {
  267. min: min,
  268. max: max
  269. };
  270. }
  271. };
  272. Util.mix(Util, DomUtil);
  273. module.exports = Util;
  274. /***/ }),
  275. /* 1 */
  276. /***/ (function(module, exports, __webpack_require__) {
  277. var Theme = __webpack_require__(42);
  278. var Util = __webpack_require__(0);
  279. var Global = {
  280. version: '3.3.3',
  281. trackable: true,
  282. scales: {},
  283. widthRatio: {
  284. column: 1 / 2,
  285. rose: 0.999999,
  286. multiplePie: 3 / 4
  287. },
  288. lineDash: [4, 4]
  289. };
  290. Global.setTheme = function (theme) {
  291. Util.deepMix(this, theme);
  292. };
  293. Global.setTheme(Theme);
  294. module.exports = Global;
  295. /***/ }),
  296. /* 2 */
  297. /***/ (function(module, exports, __webpack_require__) {
  298. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  299. var Util = __webpack_require__(0);
  300. var Element = __webpack_require__(25);
  301. var Shape =
  302. /*#__PURE__*/
  303. function (_Element) {
  304. _inheritsLoose(Shape, _Element);
  305. function Shape() {
  306. return _Element.apply(this, arguments) || this;
  307. }
  308. var _proto = Shape.prototype;
  309. _proto._initProperties = function _initProperties() {
  310. this._attrs = {
  311. zIndex: 0,
  312. visible: true,
  313. destroyed: false,
  314. isShape: true,
  315. attrs: {}
  316. };
  317. };
  318. _proto.getType = function getType() {
  319. return this._attrs.type;
  320. };
  321. _proto.drawInner = function drawInner(context) {
  322. var self = this;
  323. var attrs = self.get('attrs');
  324. self.createPath(context);
  325. var originOpacity = context.globalAlpha;
  326. if (self.hasFill()) {
  327. var fillOpacity = attrs.fillOpacity;
  328. if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
  329. context.globalAlpha = fillOpacity;
  330. context.fill();
  331. context.globalAlpha = originOpacity;
  332. } else {
  333. context.fill();
  334. }
  335. }
  336. if (self.hasStroke()) {
  337. var lineWidth = attrs.lineWidth;
  338. if (lineWidth > 0) {
  339. var strokeOpacity = attrs.strokeOpacity;
  340. if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
  341. context.globalAlpha = strokeOpacity;
  342. }
  343. context.stroke();
  344. }
  345. }
  346. };
  347. _proto.getBBox = function getBBox() {
  348. var bbox = this._attrs.bbox;
  349. if (!bbox) {
  350. bbox = this.calculateBox();
  351. if (bbox) {
  352. bbox.x = bbox.minX;
  353. bbox.y = bbox.minY;
  354. bbox.width = bbox.maxX - bbox.minX;
  355. bbox.height = bbox.maxY - bbox.minY;
  356. }
  357. this._attrs.bbox = bbox;
  358. }
  359. return bbox;
  360. };
  361. _proto.calculateBox = function calculateBox() {
  362. return null;
  363. };
  364. _proto.createPath = function createPath() {};
  365. return Shape;
  366. }(Element);
  367. module.exports = Shape;
  368. /***/ }),
  369. /* 3 */
  370. /***/ (function(module, exports, __webpack_require__) {
  371. var isObject = __webpack_require__(18);
  372. var isArray = __webpack_require__(10);
  373. var each = function each(elements, func) {
  374. if (!elements) {
  375. return;
  376. }
  377. var rst = void 0;
  378. if (isArray(elements)) {
  379. for (var i = 0, len = elements.length; i < len; i++) {
  380. rst = func(elements[i], i);
  381. if (rst === false) {
  382. break;
  383. }
  384. }
  385. } else if (isObject(elements)) {
  386. for (var k in elements) {
  387. if (elements.hasOwnProperty(k)) {
  388. rst = func(elements[k], k);
  389. if (rst === false) {
  390. break;
  391. }
  392. }
  393. }
  394. }
  395. };
  396. module.exports = each;
  397. /***/ }),
  398. /* 4 */
  399. /***/ (function(module, exports) {
  400. /**
  401. * 2 Dimensional Vector
  402. * @module vector2
  403. */
  404. module.exports = {
  405. /**
  406. * Creates a new, empty vector2
  407. *
  408. * @return {vector2} a new 2D vector
  409. */
  410. create: function create() {
  411. return [0, 0];
  412. },
  413. /**
  414. * Calculates the length of a vector2
  415. *
  416. * @param {vector2} v vector to calculate length of
  417. * @return {Number} length of v
  418. */
  419. length: function length(v) {
  420. var x = v[0];
  421. var y = v[1];
  422. return Math.sqrt(x * x + y * y);
  423. },
  424. /**
  425. * Normalize a vector2
  426. *
  427. * @param {vector2} out the receiving vector
  428. * @param {vector2} v vector to normalize
  429. * @return {vector2} out
  430. */
  431. normalize: function normalize(out, v) {
  432. var len = this.length(v);
  433. if (len === 0) {
  434. out[0] = 0;
  435. out[1] = 0;
  436. } else {
  437. out[0] = v[0] / len;
  438. out[1] = v[1] / len;
  439. }
  440. return out;
  441. },
  442. /**
  443. * Adds two vector2's
  444. *
  445. * @param {vector2} out the receiving vector
  446. * @param {vector2} v1 the first operand
  447. * @param {vector2} v2 the second operand
  448. * @return {vector2} out
  449. */
  450. add: function add(out, v1, v2) {
  451. out[0] = v1[0] + v2[0];
  452. out[1] = v1[1] + v2[1];
  453. return out;
  454. },
  455. /**
  456. * Subtracts vector v2 from vector v1
  457. *
  458. * @param {vector2} out the receiving vector
  459. * @param {vector2} v1 the first operand
  460. * @param {vector2} v2 the second operand
  461. * @return {vector2} out
  462. */
  463. sub: function sub(out, v1, v2) {
  464. out[0] = v1[0] - v2[0];
  465. out[1] = v1[1] - v2[1];
  466. return out;
  467. },
  468. /**
  469. * Scales a vector2 by a scalar number
  470. *
  471. * @param {vector2} out the receiving vector
  472. * @param {vector2} v the vector to scale
  473. * @param {Number} s amount to scale the vector by
  474. * @return {vector2} out
  475. */
  476. scale: function scale(out, v, s) {
  477. out[0] = v[0] * s;
  478. out[1] = v[1] * s;
  479. return out;
  480. },
  481. /**
  482. * Calculates the dot product of two vector2's
  483. *
  484. * @param {vector2} v1 the first operand
  485. * @param {vector2} v2 the second operand
  486. * @return {Number} dot product of v1 and v2
  487. */
  488. dot: function dot(v1, v2) {
  489. return v1[0] * v2[0] + v1[1] * v2[1];
  490. },
  491. /**
  492. * Calculates the direction of two vector2's
  493. *
  494. * @param {vector2} v1 the first operand
  495. * @param {vector2} v2 the second operand
  496. * @return {Boolean} the direction of v1 and v2
  497. */
  498. direction: function direction(v1, v2) {
  499. return v1[0] * v2[1] - v2[0] * v1[1];
  500. },
  501. /**
  502. * Calculates the angle of two vector2's
  503. *
  504. * @param {vector2} v1 the first operand
  505. * @param {vector2} v2 the second operand
  506. * @return {Number} angle of v1 and v2
  507. */
  508. angle: function angle(v1, v2) {
  509. var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
  510. return Math.acos(theta);
  511. },
  512. /**
  513. * Calculates the angle of two vector2's with direction
  514. *
  515. * @param {vector2} v1 the first operand
  516. * @param {vector2} v2 the second operand
  517. * @param {Boolean} direction the direction of two vector2's
  518. * @return {Number} angle of v1 and v2
  519. */
  520. angleTo: function angleTo(v1, v2, direction) {
  521. var angle = this.angle(v1, v2);
  522. var angleLargeThanPI = this.direction(v1, v2) >= 0;
  523. if (direction) {
  524. if (angleLargeThanPI) {
  525. return Math.PI * 2 - angle;
  526. }
  527. return angle;
  528. }
  529. if (angleLargeThanPI) {
  530. return angle;
  531. }
  532. return Math.PI * 2 - angle;
  533. },
  534. /**
  535. * whether a vector2 is zero vector
  536. *
  537. * @param {vector2} v vector to calculate
  538. * @return {Boolean} is or not a zero vector
  539. */
  540. zero: function zero(v) {
  541. return v[0] === 0 && v[1] === 0;
  542. },
  543. /**
  544. * Calculates the euclidian distance between two vector2's
  545. *
  546. * @param {vector2} v1 the first operand
  547. * @param {vector2} v2 the second operand
  548. * @return {Number} distance between a and b
  549. */
  550. distance: function distance(v1, v2) {
  551. var x = v2[0] - v1[0];
  552. var y = v2[1] - v1[1];
  553. return Math.sqrt(x * x + y * y);
  554. },
  555. /**
  556. * Creates a new vector2 initialized with values from an existing vector
  557. *
  558. * @param {vector2} v vector to clone
  559. * @return {Array} a new 2D vector
  560. */
  561. clone: function clone(v) {
  562. return [v[0], v[1]];
  563. },
  564. /**
  565. * Return the minimum of two vector2's
  566. *
  567. * @param {vector2} out the receiving vector
  568. * @param {vector2} v1 the first operand
  569. * @param {vector2} v2 the second operand
  570. * @return {vector2} out
  571. */
  572. min: function min(out, v1, v2) {
  573. out[0] = Math.min(v1[0], v2[0]);
  574. out[1] = Math.min(v1[1], v2[1]);
  575. return out;
  576. },
  577. /**
  578. * Return the maximum of two vector2's
  579. *
  580. * @param {vector2} out the receiving vector
  581. * @param {vector2} v1 the first operand
  582. * @param {vector2} v2 the second operand
  583. * @return {vector2} out
  584. */
  585. max: function max(out, v1, v2) {
  586. out[0] = Math.max(v1[0], v2[0]);
  587. out[1] = Math.max(v1[1], v2[1]);
  588. return out;
  589. },
  590. /**
  591. * Transforms the vector2 with a mat2d
  592. *
  593. * @param {vector2} out the receiving vector
  594. * @param {vector2} v the vector to transform
  595. * @param {mat2d} m matrix to transform with
  596. * @return {vector2} out
  597. */
  598. transformMat2d: function transformMat2d(out, v, m) {
  599. var x = v[0];
  600. var y = v[1];
  601. out[0] = m[0] * x + m[2] * y + m[4];
  602. out[1] = m[1] * x + m[3] * y + m[5];
  603. return out;
  604. }
  605. };
  606. /***/ }),
  607. /* 5 */
  608. /***/ (function(module, exports, __webpack_require__) {
  609. var G = {
  610. Canvas: __webpack_require__(68),
  611. Group: __webpack_require__(31),
  612. Shape: __webpack_require__(2),
  613. Matrix: __webpack_require__(23),
  614. Vector2: __webpack_require__(4)
  615. };
  616. __webpack_require__(70);
  617. __webpack_require__(71);
  618. __webpack_require__(72);
  619. __webpack_require__(73);
  620. __webpack_require__(74);
  621. __webpack_require__(75);
  622. __webpack_require__(76);
  623. __webpack_require__(77);
  624. __webpack_require__(78);
  625. module.exports = G;
  626. /***/ }),
  627. /* 6 */
  628. /***/ (function(module, exports, __webpack_require__) {
  629. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  630. var Util = __webpack_require__(0);
  631. var Base = __webpack_require__(29);
  632. var GROUP_ATTRS = ['color', 'size', 'shape'];
  633. var FIELD_ORIGIN = '_origin';
  634. var FIELD_ORIGIN_Y = '_originY';
  635. var Global = __webpack_require__(1);
  636. var Attr = __webpack_require__(53);
  637. var GeometryShape = __webpack_require__(9);
  638. var Adjust = __webpack_require__(22);
  639. function parseFields(field) {
  640. if (Util.isArray(field)) {
  641. return field;
  642. }
  643. if (Util.isString(field)) {
  644. return field.split('*');
  645. }
  646. return [field];
  647. }
  648. /**
  649. * The parent class for Geometry
  650. * @class Geom
  651. */
  652. var Geom =
  653. /*#__PURE__*/
  654. function (_Base) {
  655. _inheritsLoose(Geom, _Base);
  656. function Geom() {
  657. return _Base.apply(this, arguments) || this;
  658. }
  659. var _proto = Geom.prototype;
  660. _proto.getDefaultCfg = function getDefaultCfg() {
  661. return {
  662. /**
  663. * geometry type
  664. * @type {String}
  665. */
  666. type: null,
  667. /**
  668. * the data of geometry
  669. * @type {Array}
  670. */
  671. data: null,
  672. /**
  673. * the attrs of geo,etry
  674. * @type {Object}
  675. */
  676. attrs: {},
  677. scales: {},
  678. /**
  679. * group for storing the shapes
  680. * @type {Canvas}
  681. */
  682. container: null,
  683. /**
  684. * style options
  685. * @type {Object}
  686. */
  687. styleOptions: null,
  688. chart: null,
  689. shapeType: '',
  690. /**
  691. * wether to generate key points for each shape
  692. * @protected
  693. * @type {Boolean}
  694. */
  695. generatePoints: false,
  696. attrOptions: {},
  697. sortable: false,
  698. startOnZero: true,
  699. visible: true,
  700. connectNulls: false
  701. };
  702. };
  703. _proto.init = function init() {
  704. var self = this;
  705. self._initAttrs();
  706. var dataArray = self._processData();
  707. if (self.get('adjust')) {
  708. self._adjustData(dataArray);
  709. }
  710. self.set('dataArray', dataArray);
  711. };
  712. _proto._getGroupScales = function _getGroupScales() {
  713. var self = this;
  714. var scales = [];
  715. Util.each(GROUP_ATTRS, function (attrName) {
  716. var attr = self.getAttr(attrName);
  717. if (attr) {
  718. var attrScales = attr.scales;
  719. Util.each(attrScales, function (scale) {
  720. if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
  721. scales.push(scale);
  722. }
  723. });
  724. }
  725. });
  726. return scales;
  727. };
  728. _proto._groupData = function _groupData(data) {
  729. var self = this;
  730. var colDefs = self.get('colDefs');
  731. var groupScales = self._getGroupScales();
  732. if (groupScales.length) {
  733. var appendConditions = {};
  734. var names = [];
  735. Util.each(groupScales, function (scale) {
  736. var field = scale.field;
  737. names.push(field);
  738. if (colDefs && colDefs[field] && colDefs[field].values) {
  739. // users have defined
  740. appendConditions[scale.field] = colDefs[field].values;
  741. }
  742. });
  743. return Util.Array.group(data, names, appendConditions);
  744. }
  745. return [data];
  746. };
  747. _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
  748. var options = this.get('attrOptions');
  749. options[attrName] = attrCfg;
  750. };
  751. _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
  752. var attrCfg = {};
  753. attrCfg.field = field;
  754. if (cfg) {
  755. if (Util.isFunction(cfg)) {
  756. attrCfg.callback = cfg;
  757. } else {
  758. attrCfg.values = cfg;
  759. }
  760. } else {
  761. attrCfg.values = defaultValues;
  762. }
  763. this._setAttrOptions(attrName, attrCfg);
  764. };
  765. _proto._initAttrs = function _initAttrs() {
  766. var self = this;
  767. var attrs = self.get('attrs');
  768. var attrOptions = self.get('attrOptions');
  769. var coord = self.get('coord');
  770. for (var type in attrOptions) {
  771. if (attrOptions.hasOwnProperty(type)) {
  772. var option = attrOptions[type];
  773. var className = Util.upperFirst(type);
  774. var fields = parseFields(option.field);
  775. if (type === 'position') {
  776. option.coord = coord;
  777. }
  778. var scales = [];
  779. for (var i = 0, len = fields.length; i < len; i++) {
  780. var field = fields[i];
  781. var scale = self._createScale(field);
  782. scales.push(scale);
  783. }
  784. if (type === 'position') {
  785. var yScale = scales[1];
  786. if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
  787. if (yScale.values.length) {
  788. yScale.change({
  789. nice: false,
  790. min: 0,
  791. max: Math.max.apply(null, yScale.values)
  792. });
  793. }
  794. }
  795. }
  796. option.scales = scales;
  797. var attr = new Attr[className](option);
  798. attrs[type] = attr;
  799. }
  800. }
  801. };
  802. _proto._createScale = function _createScale(field) {
  803. var scales = this.get('scales');
  804. var scale = scales[field];
  805. if (!scale) {
  806. scale = this.get('chart').createScale(field);
  807. scales[field] = scale;
  808. }
  809. return scale;
  810. };
  811. _proto._processData = function _processData() {
  812. var self = this;
  813. var data = this.get('data');
  814. var dataArray = [];
  815. var groupedArray = this._groupData(data);
  816. for (var i = 0, len = groupedArray.length; i < len; i++) {
  817. var subData = groupedArray[i];
  818. var tempData = self._saveOrigin(subData);
  819. if (this.hasAdjust('dodge')) {
  820. self._numberic(tempData);
  821. }
  822. dataArray.push(tempData);
  823. }
  824. return dataArray;
  825. };
  826. _proto._saveOrigin = function _saveOrigin(data) {
  827. var rst = [];
  828. for (var i = 0, len = data.length; i < len; i++) {
  829. var origin = data[i];
  830. var obj = {};
  831. for (var k in origin) {
  832. obj[k] = origin[k];
  833. }
  834. obj[FIELD_ORIGIN] = origin;
  835. rst.push(obj);
  836. }
  837. return rst;
  838. };
  839. _proto._numberic = function _numberic(data) {
  840. var positionAttr = this.getAttr('position');
  841. var scales = positionAttr.scales;
  842. for (var j = 0, len = data.length; j < len; j++) {
  843. var obj = data[j];
  844. var count = Math.min(2, scales.length);
  845. for (var i = 0; i < count; i++) {
  846. var scale = scales[i];
  847. if (scale.isCategory) {
  848. var field = scale.field;
  849. obj[field] = scale.translate(obj[field]);
  850. }
  851. }
  852. }
  853. };
  854. _proto._adjustData = function _adjustData(dataArray) {
  855. var self = this;
  856. var adjust = self.get('adjust');
  857. if (adjust) {
  858. var adjustType = Util.upperFirst(adjust.type);
  859. if (!Adjust[adjustType]) {
  860. throw new Error('not support such adjust : ' + adjust);
  861. }
  862. var xScale = self.getXScale();
  863. var yScale = self.getYScale();
  864. var cfg = Util.mix({
  865. xField: xScale.field,
  866. yField: yScale.field
  867. }, adjust);
  868. var adjustObject = new Adjust[adjustType](cfg);
  869. adjustObject.processAdjust(dataArray);
  870. if (adjustType === 'Stack') {
  871. self._updateStackRange(yScale.field, yScale, dataArray);
  872. }
  873. }
  874. };
  875. _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
  876. var mergeArray = Util.Array.merge(dataArray);
  877. var min = scale.min;
  878. var max = scale.max;
  879. for (var i = 0, len = mergeArray.length; i < len; i++) {
  880. var obj = mergeArray[i];
  881. var tmpMin = Math.min.apply(null, obj[field]);
  882. var tmpMax = Math.max.apply(null, obj[field]);
  883. if (tmpMin < min) {
  884. min = tmpMin;
  885. }
  886. if (tmpMax > max) {
  887. max = tmpMax;
  888. }
  889. }
  890. if (min < scale.min || max > scale.max) {
  891. scale.change({
  892. min: min,
  893. max: max
  894. });
  895. }
  896. };
  897. _proto._sort = function _sort(mappedArray) {
  898. var self = this;
  899. var xScale = self.getXScale();
  900. var field = xScale.field,
  901. type = xScale.type;
  902. if (type !== 'identity' && xScale.values.length > 1) {
  903. Util.each(mappedArray, function (itemArr) {
  904. itemArr.sort(function (obj1, obj2) {
  905. if (type === 'timeCat') {
  906. return xScale._toTimeStamp(obj1[FIELD_ORIGIN][field]) - xScale._toTimeStamp(obj2[FIELD_ORIGIN][field]);
  907. }
  908. return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
  909. });
  910. });
  911. }
  912. self.set('hasSorted', true);
  913. self.set('dataArray', mappedArray);
  914. };
  915. _proto.paint = function paint() {
  916. var self = this;
  917. var dataArray = self.get('dataArray');
  918. var mappedArray = [];
  919. var shapeFactory = self.getShapeFactory();
  920. shapeFactory.setCoord(self.get('coord'));
  921. self._beforeMapping(dataArray);
  922. for (var i = 0, len = dataArray.length; i < len; i++) {
  923. var data = dataArray[i];
  924. if (data.length) {
  925. data = self._mapping(data);
  926. mappedArray.push(data);
  927. self.draw(data, shapeFactory);
  928. }
  929. }
  930. self.set('dataArray', mappedArray);
  931. };
  932. _proto.getShapeFactory = function getShapeFactory() {
  933. var shapeFactory = this.get('shapeFactory');
  934. if (!shapeFactory) {
  935. var shapeType = this.get('shapeType');
  936. shapeFactory = GeometryShape.getShapeFactory(shapeType);
  937. this.set('shapeFactory', shapeFactory);
  938. }
  939. return shapeFactory;
  940. };
  941. _proto._mapping = function _mapping(data) {
  942. var self = this;
  943. var attrs = self.get('attrs');
  944. var yField = self.getYScale().field;
  945. var mappedData = [];
  946. for (var i = 0, len = data.length; i < len; i++) {
  947. var record = data[i];
  948. var newRecord = {};
  949. newRecord[FIELD_ORIGIN] = record[FIELD_ORIGIN];
  950. newRecord.points = record.points; // 避免
  951. newRecord[FIELD_ORIGIN_Y] = record[yField];
  952. for (var k in attrs) {
  953. if (attrs.hasOwnProperty(k)) {
  954. var attr = attrs[k];
  955. var names = attr.names;
  956. var values = self._getAttrValues(attr, record);
  957. if (names.length > 1) {
  958. for (var j = 0, _len = values.length; j < _len; j++) {
  959. var val = values[j];
  960. var name = names[j];
  961. newRecord[name] = Util.isArray(val) && val.length === 1 ? val[0] : val;
  962. }
  963. } else {
  964. newRecord[names[0]] = values.length === 1 ? values[0] : values;
  965. }
  966. }
  967. }
  968. mappedData.push(newRecord);
  969. }
  970. return mappedData;
  971. };
  972. _proto._getAttrValues = function _getAttrValues(attr, record) {
  973. var scales = attr.scales;
  974. var params = [];
  975. for (var i = 0, len = scales.length; i < len; i++) {
  976. var scale = scales[i];
  977. var field = scale.field;
  978. if (scale.type === 'identity') {
  979. params.push(scale.value);
  980. } else {
  981. params.push(record[field]);
  982. }
  983. }
  984. var values = attr.mapping.apply(attr, params);
  985. return values;
  986. };
  987. _proto.getAttrValue = function getAttrValue(attrName, record) {
  988. var attr = this.getAttr(attrName);
  989. var rst = null;
  990. if (attr) {
  991. var values = this._getAttrValues(attr, record);
  992. rst = values[0];
  993. }
  994. return rst;
  995. };
  996. _proto._beforeMapping = function _beforeMapping(dataArray) {
  997. var self = this;
  998. if (self.get('sortable')) {
  999. self._sort(dataArray);
  1000. }
  1001. if (self.get('generatePoints')) {
  1002. Util.each(dataArray, function (data) {
  1003. self._generatePoints(data);
  1004. });
  1005. }
  1006. };
  1007. _proto.isInCircle = function isInCircle() {
  1008. var coord = this.get('coord');
  1009. return coord && coord.isPolar;
  1010. };
  1011. _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
  1012. if (!fields) {
  1013. return cfg;
  1014. }
  1015. var tmpCfg = {};
  1016. var params = fields.map(function (field) {
  1017. return origin[field];
  1018. });
  1019. Util.each(cfg, function (v, k) {
  1020. if (Util.isFunction(v)) {
  1021. tmpCfg[k] = v.apply(null, params);
  1022. } else {
  1023. tmpCfg[k] = v;
  1024. }
  1025. });
  1026. return tmpCfg;
  1027. };
  1028. _proto.getDrawCfg = function getDrawCfg(obj) {
  1029. var self = this;
  1030. var isInCircle = self.isInCircle();
  1031. var cfg = {
  1032. origin: obj,
  1033. x: obj.x,
  1034. y: obj.y,
  1035. color: obj.color,
  1036. size: obj.size,
  1037. shape: obj.shape,
  1038. isInCircle: isInCircle,
  1039. opacity: obj.opacity
  1040. };
  1041. var styleOptions = self.get('styleOptions');
  1042. if (styleOptions && styleOptions.style) {
  1043. cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
  1044. }
  1045. if (self.get('generatePoints')) {
  1046. cfg.points = obj.points;
  1047. }
  1048. if (isInCircle) {
  1049. cfg.center = self.get('coord').center;
  1050. }
  1051. return cfg;
  1052. };
  1053. _proto.draw = function draw(data, shapeFactory) {
  1054. var self = this;
  1055. var container = self.get('container');
  1056. var yScale = self.getYScale();
  1057. Util.each(data, function (obj, index) {
  1058. if (yScale && Util.isNil(obj._origin[yScale.field])) {
  1059. return;
  1060. }
  1061. obj.index = index;
  1062. var cfg = self.getDrawCfg(obj);
  1063. var shape = obj.shape;
  1064. self.drawShape(shape, obj, cfg, container, shapeFactory);
  1065. });
  1066. };
  1067. _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
  1068. var gShape = shapeFactory.drawShape(shape, cfg, container);
  1069. if (gShape) {
  1070. Util.each([].concat(gShape), function (s) {
  1071. s.set('origin', shapeData);
  1072. });
  1073. }
  1074. };
  1075. _proto._generatePoints = function _generatePoints(data) {
  1076. var self = this;
  1077. var shapeFactory = self.getShapeFactory();
  1078. var shapeAttr = self.getAttr('shape');
  1079. for (var i = 0, len = data.length; i < len; i++) {
  1080. var obj = data[i];
  1081. var cfg = self.createShapePointsCfg(obj);
  1082. var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
  1083. var points = shapeFactory.getShapePoints(shape, cfg);
  1084. obj.points = points;
  1085. }
  1086. };
  1087. /**
  1088. * get the info of each shape
  1089. * @protected
  1090. * @param {Object} obj the data item
  1091. * @return {Object} cfg return the result
  1092. */
  1093. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  1094. var xScale = this.getXScale();
  1095. var yScale = this.getYScale();
  1096. var x = this._normalizeValues(obj[xScale.field], xScale);
  1097. var y;
  1098. if (yScale) {
  1099. y = this._normalizeValues(obj[yScale.field], yScale);
  1100. } else {
  1101. y = obj.y ? obj.y : 0.1;
  1102. }
  1103. return {
  1104. x: x,
  1105. y: y,
  1106. y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
  1107. };
  1108. };
  1109. _proto.getYMinValue = function getYMinValue() {
  1110. var yScale = this.getYScale();
  1111. var min = yScale.min,
  1112. max = yScale.max;
  1113. var value;
  1114. if (this.get('startOnZero')) {
  1115. if (max <= 0 && min <= 0) {
  1116. value = max;
  1117. } else {
  1118. value = min >= 0 ? min : 0;
  1119. }
  1120. } else {
  1121. value = min;
  1122. }
  1123. return value;
  1124. };
  1125. _proto._normalizeValues = function _normalizeValues(values, scale) {
  1126. var rst = [];
  1127. if (Util.isArray(values)) {
  1128. for (var i = 0, len = values.length; i < len; i++) {
  1129. var v = values[i];
  1130. rst.push(scale.scale(v));
  1131. }
  1132. } else {
  1133. rst = scale.scale(values);
  1134. }
  1135. return rst;
  1136. };
  1137. _proto.getAttr = function getAttr(name) {
  1138. return this.get('attrs')[name];
  1139. };
  1140. _proto.getXScale = function getXScale() {
  1141. return this.getAttr('position').scales[0];
  1142. };
  1143. _proto.getYScale = function getYScale() {
  1144. return this.getAttr('position').scales[1];
  1145. };
  1146. _proto.hasAdjust = function hasAdjust(adjust) {
  1147. return this.get('adjust') && this.get('adjust').type === adjust;
  1148. };
  1149. _proto._getSnap = function _getSnap(scale, item, arr) {
  1150. var i = 0;
  1151. var values;
  1152. var yField = this.getYScale().field; // 叠加的维度
  1153. if (this.hasAdjust('stack') && scale.field === yField) {
  1154. values = [];
  1155. arr.forEach(function (obj) {
  1156. values.push(obj[FIELD_ORIGIN_Y]);
  1157. });
  1158. for (var len = values.length; i < len; i++) {
  1159. if (values[0][0] > item) {
  1160. break;
  1161. }
  1162. if (values[values.length - 1][1] <= item) {
  1163. i = values.length - 1;
  1164. break;
  1165. }
  1166. if (values[i][0] <= item && values[i][1] > item) {
  1167. break;
  1168. }
  1169. }
  1170. } else {
  1171. values = scale.values;
  1172. values.sort(function (a, b) {
  1173. return a - b;
  1174. });
  1175. for (var _len2 = values.length; i < _len2; i++) {
  1176. if ((values[0] + values[1]) / 2 > item) {
  1177. break;
  1178. }
  1179. if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
  1180. break;
  1181. }
  1182. if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
  1183. i = values.length - 1;
  1184. break;
  1185. }
  1186. }
  1187. }
  1188. var result = values[i];
  1189. return result;
  1190. };
  1191. _proto.getSnapRecords = function getSnapRecords(point) {
  1192. var self = this;
  1193. var coord = self.get('coord');
  1194. var xScale = self.getXScale();
  1195. var yScale = self.getYScale();
  1196. var xfield = xScale.field;
  1197. var dataArray = self.get('dataArray');
  1198. if (!this.get('hasSorted')) {
  1199. this._sort(dataArray);
  1200. }
  1201. var rst = [];
  1202. var invertPoint = coord.invertPoint(point);
  1203. var invertPointX = invertPoint.x;
  1204. if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
  1205. invertPointX = xScale.rangeMin();
  1206. }
  1207. var xValue = xScale.invert(invertPointX);
  1208. if (!xScale.isCategory) {
  1209. xValue = self._getSnap(xScale, xValue);
  1210. }
  1211. var tmp = [];
  1212. dataArray.forEach(function (data) {
  1213. data.forEach(function (obj) {
  1214. var originValue = Util.isNil(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
  1215. if (self._isEqual(originValue, xValue, xScale)) {
  1216. tmp.push(obj);
  1217. }
  1218. });
  1219. }); // special for pie chart
  1220. if (this.hasAdjust('stack') && coord.isPolar && coord.transposed && xScale.values.length === 1) {
  1221. if (invertPointX >= 0 && invertPointX <= 1) {
  1222. var yValue = yScale.invert(invertPoint.y);
  1223. yValue = self._getSnap(yScale, yValue, tmp);
  1224. tmp.forEach(function (obj) {
  1225. if (Util.isArray(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
  1226. rst.push(obj);
  1227. }
  1228. });
  1229. }
  1230. } else {
  1231. rst = tmp;
  1232. }
  1233. return rst;
  1234. };
  1235. _proto._isEqual = function _isEqual(originValue, value, scale) {
  1236. if (scale.type === 'timeCat') {
  1237. return scale._toTimeStamp(originValue) === value;
  1238. }
  1239. return value === originValue;
  1240. };
  1241. _proto.position = function position(field) {
  1242. this._setAttrOptions('position', {
  1243. field: field
  1244. });
  1245. return this;
  1246. };
  1247. _proto.color = function color(field, values) {
  1248. this._createAttrOption('color', field, values, Global.colors);
  1249. return this;
  1250. };
  1251. _proto.size = function size(field, values) {
  1252. this._createAttrOption('size', field, values, Global.sizes);
  1253. return this;
  1254. };
  1255. _proto.shape = function shape(field, values) {
  1256. var type = this.get('type');
  1257. var shapes = Global.shapes[type] || [];
  1258. this._createAttrOption('shape', field, values, shapes);
  1259. return this;
  1260. };
  1261. _proto.style = function style(field, cfg) {
  1262. var styleOptions = this.get('styleOptions');
  1263. if (!styleOptions) {
  1264. styleOptions = {};
  1265. this.set('styleOptions', styleOptions);
  1266. }
  1267. if (Util.isObject(field)) {
  1268. cfg = field;
  1269. field = null;
  1270. }
  1271. var fields;
  1272. if (field) {
  1273. fields = parseFields(field);
  1274. }
  1275. styleOptions.fields = fields;
  1276. styleOptions.style = cfg;
  1277. return this;
  1278. };
  1279. _proto.adjust = function adjust(type) {
  1280. if (Util.isString(type)) {
  1281. type = {
  1282. type: type
  1283. };
  1284. }
  1285. this.set('adjust', type);
  1286. return this;
  1287. };
  1288. _proto.animate = function animate(cfg) {
  1289. this.set('animateCfg', cfg);
  1290. return this;
  1291. };
  1292. _proto.reset = function reset() {
  1293. this.set('attrOptions', {});
  1294. this.set('adjust', null);
  1295. this.clearInner();
  1296. };
  1297. _proto.clearInner = function clearInner() {
  1298. var container = this.get('container');
  1299. if (container) {
  1300. container.clear();
  1301. container.setMatrix([1, 0, 0, 1, 0, 0]);
  1302. }
  1303. container && container.clear();
  1304. this.set('attrs', {});
  1305. this.set('groupScales', null);
  1306. this.set('xDistance', null);
  1307. this.set('_width', null);
  1308. };
  1309. _proto.clear = function clear() {
  1310. this.clearInner();
  1311. this.set('scales', {});
  1312. };
  1313. _proto.destroy = function destroy() {
  1314. this.clear();
  1315. _Base.prototype.destroy.call(this);
  1316. };
  1317. _proto._display = function _display(visible) {
  1318. this.set('visible', visible);
  1319. var container = this.get('container');
  1320. var canvas = container.get('canvas');
  1321. container.set('visible', visible);
  1322. canvas.draw();
  1323. };
  1324. _proto.show = function show() {
  1325. this._display(true);
  1326. };
  1327. _proto.hide = function hide() {
  1328. this._display(false);
  1329. };
  1330. return Geom;
  1331. }(Base);
  1332. module.exports = Geom;
  1333. /***/ }),
  1334. /* 7 */
  1335. /***/ (function(module, exports) {
  1336. // isFinite,
  1337. var isNil = function isNil(value) {
  1338. /**
  1339. * isNil(null) => true
  1340. * isNil() => true
  1341. */
  1342. return value === null || value === undefined;
  1343. };
  1344. module.exports = isNil;
  1345. /***/ }),
  1346. /* 8 */
  1347. /***/ (function(module, exports) {
  1348. var toString = {}.toString;
  1349. var isType = function isType(value, type) {
  1350. return toString.call(value) === '[object ' + type + ']';
  1351. };
  1352. module.exports = isType;
  1353. /***/ }),
  1354. /* 9 */
  1355. /***/ (function(module, exports, __webpack_require__) {
  1356. var Util = __webpack_require__(0);
  1357. var Global = __webpack_require__(1);
  1358. var Shape = {};
  1359. var ShapeBase = {
  1360. _coord: null,
  1361. /**
  1362. * draw the shape
  1363. * @param {Object} cfg options
  1364. * @param {Object} container container to store the shapes
  1365. */
  1366. draw: function draw(cfg, container) {
  1367. if (this.drawShape) {
  1368. this.drawShape(cfg, container);
  1369. }
  1370. },
  1371. /**
  1372. * set the coordinate instance
  1373. * @param {Coord} coord coordinate instance
  1374. */
  1375. setCoord: function setCoord(coord) {
  1376. this._coord = coord;
  1377. },
  1378. /**
  1379. * convert the normalized value to the canvas position
  1380. * @param {point} point the point to convert
  1381. * @return {point} point return the result
  1382. */
  1383. parsePoint: function parsePoint(point) {
  1384. var coord = this._coord;
  1385. if (coord.isPolar) {
  1386. if (point.x === 1) point.x = 0.9999999;
  1387. if (point.y === 1) point.y = 0.9999999;
  1388. }
  1389. return coord.convertPoint(point);
  1390. },
  1391. /**
  1392. * convert the normalized value to the canvas position
  1393. * @param {points} points the array that store the points
  1394. * @return {points} points return the result
  1395. */
  1396. parsePoints: function parsePoints(points) {
  1397. if (!points) return false;
  1398. var self = this;
  1399. var rst = [];
  1400. points.forEach(function (point) {
  1401. rst.push(self.parsePoint(point));
  1402. });
  1403. return rst;
  1404. }
  1405. };
  1406. var ShapeFactoryBase = {
  1407. defaultShapeType: null,
  1408. setCoord: function setCoord(coord) {
  1409. this._coord = coord;
  1410. },
  1411. getShape: function getShape(type) {
  1412. var self = this;
  1413. if (Util.isArray(type)) {
  1414. type = type[0];
  1415. }
  1416. var shape = self[type] || self[self.defaultShapeType];
  1417. shape._coord = self._coord;
  1418. return shape;
  1419. },
  1420. getShapePoints: function getShapePoints(type, cfg) {
  1421. var shape = this.getShape(type);
  1422. var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
  1423. var points = fn(cfg);
  1424. return points;
  1425. },
  1426. getDefaultPoints: function getDefaultPoints()
  1427. /* cfg */
  1428. {
  1429. return [];
  1430. },
  1431. drawShape: function drawShape(type, cfg, container) {
  1432. var shape = this.getShape(type);
  1433. if (!cfg.color) {
  1434. cfg.color = Global.colors[0];
  1435. }
  1436. return shape.draw(cfg, container);
  1437. }
  1438. };
  1439. Shape.registerFactory = function (factoryName, cfg) {
  1440. var className = Util.upperFirst(factoryName);
  1441. var geomObj = Util.mix({}, ShapeFactoryBase, cfg);
  1442. Shape[className] = geomObj;
  1443. geomObj.name = factoryName;
  1444. return geomObj;
  1445. };
  1446. Shape.registerShape = function (factoryName, shapeType, cfg) {
  1447. var className = Util.upperFirst(factoryName);
  1448. var factory = Shape[className];
  1449. var shapeObj = Util.mix({}, ShapeBase, cfg);
  1450. factory[shapeType] = shapeObj;
  1451. return shapeObj;
  1452. };
  1453. Shape.registShape = Shape.registerShape;
  1454. Shape.getShapeFactory = function (factoryName) {
  1455. var self = this;
  1456. factoryName = factoryName || 'point';
  1457. var className = Util.upperFirst(factoryName);
  1458. return self[className];
  1459. };
  1460. module.exports = Shape;
  1461. /***/ }),
  1462. /* 10 */
  1463. /***/ (function(module, exports, __webpack_require__) {
  1464. var isType = __webpack_require__(8);
  1465. var isArray = Array.isArray ? Array.isArray : function (value) {
  1466. return isType(value, 'Array');
  1467. };
  1468. module.exports = isArray;
  1469. /***/ }),
  1470. /* 11 */
  1471. /***/ (function(module, exports, __webpack_require__) {
  1472. var Vector2 = __webpack_require__(4);
  1473. var start = Vector2.create();
  1474. var end = Vector2.create();
  1475. var extremity = Vector2.create();
  1476. function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
  1477. var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
  1478. var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
  1479. return {
  1480. x: x,
  1481. y: y
  1482. };
  1483. } // cubic helper formula at T distance
  1484. function CubicN(T, a, b, c, d) {
  1485. var t2 = T * T;
  1486. var t3 = t2 * T;
  1487. 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;
  1488. }
  1489. function cubicBezierBounds(c) {
  1490. var minX = Infinity;
  1491. var maxX = -Infinity;
  1492. var minY = Infinity;
  1493. var maxY = -Infinity;
  1494. var s = {
  1495. x: c[0],
  1496. y: c[1]
  1497. };
  1498. var c1 = {
  1499. x: c[2],
  1500. y: c[3]
  1501. };
  1502. var c2 = {
  1503. x: c[4],
  1504. y: c[5]
  1505. };
  1506. var e = {
  1507. x: c[6],
  1508. y: c[7]
  1509. };
  1510. for (var t = 0; t < 100; t++) {
  1511. var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);
  1512. if (pt.x < minX) {
  1513. minX = pt.x;
  1514. }
  1515. if (pt.x > maxX) {
  1516. maxX = pt.x;
  1517. }
  1518. if (pt.y < minY) {
  1519. minY = pt.y;
  1520. }
  1521. if (pt.y > maxY) {
  1522. maxY = pt.y;
  1523. }
  1524. }
  1525. return {
  1526. minX: minX,
  1527. minY: minY,
  1528. maxX: maxX,
  1529. maxY: maxY
  1530. };
  1531. }
  1532. module.exports = {
  1533. getBBoxFromPoints: function getBBoxFromPoints(points, lineWidth) {
  1534. if (points.length === 0) {
  1535. return;
  1536. }
  1537. var p = points[0];
  1538. var left = p.x;
  1539. var right = p.x;
  1540. var top = p.y;
  1541. var bottom = p.y;
  1542. var len = points.length;
  1543. for (var i = 1; i < len; i++) {
  1544. p = points[i];
  1545. left = Math.min(left, p.x);
  1546. right = Math.max(right, p.x);
  1547. top = Math.min(top, p.y);
  1548. bottom = Math.max(bottom, p.y);
  1549. }
  1550. lineWidth = lineWidth / 2 || 0;
  1551. return {
  1552. minX: left - lineWidth,
  1553. minY: top - lineWidth,
  1554. maxX: right + lineWidth,
  1555. maxY: bottom + lineWidth
  1556. };
  1557. },
  1558. getBBoxFromLine: function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
  1559. lineWidth = lineWidth / 2 || 0;
  1560. return {
  1561. minX: Math.min(x0, x1) - lineWidth,
  1562. minY: Math.min(y0, y1) - lineWidth,
  1563. maxX: Math.max(x0, x1) + lineWidth,
  1564. maxY: Math.max(y0, y1) + lineWidth
  1565. };
  1566. },
  1567. getBBoxFromArc: function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
  1568. var diff = Math.abs(startAngle - endAngle);
  1569. if (diff % Math.PI * 2 < 1e-4 && diff > 1e-4) {
  1570. // Is a circle
  1571. return {
  1572. minX: x - r,
  1573. minY: y - r,
  1574. maxX: x + r,
  1575. maxY: y + r
  1576. };
  1577. }
  1578. start[0] = Math.cos(startAngle) * r + x;
  1579. start[1] = Math.sin(startAngle) * r + y;
  1580. end[0] = Math.cos(endAngle) * r + x;
  1581. end[1] = Math.sin(endAngle) * r + y;
  1582. var min = [0, 0];
  1583. var max = [0, 0];
  1584. Vector2.min(min, start, end);
  1585. Vector2.max(max, start, end); // Thresh to [0, Math.PI * 2]
  1586. startAngle = startAngle % (Math.PI * 2);
  1587. if (startAngle < 0) {
  1588. startAngle = startAngle + Math.PI * 2;
  1589. }
  1590. endAngle = endAngle % (Math.PI * 2);
  1591. if (endAngle < 0) {
  1592. endAngle = endAngle + Math.PI * 2;
  1593. }
  1594. if (startAngle > endAngle && !anticlockwise) {
  1595. endAngle += Math.PI * 2;
  1596. } else if (startAngle < endAngle && anticlockwise) {
  1597. startAngle += Math.PI * 2;
  1598. }
  1599. if (anticlockwise) {
  1600. var tmp = endAngle;
  1601. endAngle = startAngle;
  1602. startAngle = tmp;
  1603. }
  1604. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  1605. if (angle > startAngle) {
  1606. extremity[0] = Math.cos(angle) * r + x;
  1607. extremity[1] = Math.sin(angle) * r + y;
  1608. Vector2.min(min, extremity, min);
  1609. Vector2.max(max, extremity, max);
  1610. }
  1611. }
  1612. return {
  1613. minX: min[0],
  1614. minY: min[1],
  1615. maxX: max[0],
  1616. maxY: max[1]
  1617. };
  1618. },
  1619. getBBoxFromBezierGroup: function getBBoxFromBezierGroup(points, lineWidth) {
  1620. var minX = Infinity;
  1621. var maxX = -Infinity;
  1622. var minY = Infinity;
  1623. var maxY = -Infinity;
  1624. for (var i = 0, len = points.length; i < len; i++) {
  1625. var bbox = cubicBezierBounds(points[i]);
  1626. if (bbox.minX < minX) {
  1627. minX = bbox.minX;
  1628. }
  1629. if (bbox.maxX > maxX) {
  1630. maxX = bbox.maxX;
  1631. }
  1632. if (bbox.minY < minY) {
  1633. minY = bbox.minY;
  1634. }
  1635. if (bbox.maxY > maxY) {
  1636. maxY = bbox.maxY;
  1637. }
  1638. }
  1639. lineWidth = lineWidth / 2 || 0;
  1640. return {
  1641. minX: minX - lineWidth,
  1642. minY: minY - lineWidth,
  1643. maxX: maxX + lineWidth,
  1644. maxY: maxY + lineWidth
  1645. };
  1646. }
  1647. };
  1648. /***/ }),
  1649. /* 12 */
  1650. /***/ (function(module, exports, __webpack_require__) {
  1651. var Util = __webpack_require__(0);
  1652. var KEYWORDS_PERCENT = {
  1653. min: 0,
  1654. median: 0.5,
  1655. max: 1
  1656. };
  1657. var GuideBase =
  1658. /*#__PURE__*/
  1659. function () {
  1660. var _proto = GuideBase.prototype;
  1661. _proto._initDefaultCfg = function _initDefaultCfg() {};
  1662. function GuideBase(cfg) {
  1663. this._initDefaultCfg();
  1664. Util.deepMix(this, cfg);
  1665. }
  1666. _proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
  1667. var rst;
  1668. if (Util.isNil(KEYWORDS_PERCENT[val])) {
  1669. rst = scale.scale(val);
  1670. } else {
  1671. rst = KEYWORDS_PERCENT[val];
  1672. }
  1673. return rst;
  1674. };
  1675. _proto.parsePercentPoint = function parsePercentPoint(coord, position) {
  1676. var xPercent = parseFloat(position[0]) / 100;
  1677. var yPercent = parseFloat(position[1]) / 100;
  1678. var start = coord.start;
  1679. var end = coord.end;
  1680. var width = Math.abs(start.x - end.x);
  1681. var height = Math.abs(start.y - end.y);
  1682. var x = width * xPercent + Math.min(start.x, end.x);
  1683. var y = height * yPercent + Math.min(start.y, end.y);
  1684. return {
  1685. x: x,
  1686. y: y
  1687. };
  1688. };
  1689. _proto.parsePoint = function parsePoint(coord, position) {
  1690. var self = this;
  1691. var xScale = self.xScale;
  1692. var yScales = self.yScales;
  1693. if (Util.isFunction(position)) {
  1694. position = position(xScale, yScales); // position 必须是对象
  1695. } // 如果数据格式是 ['50%', '50%'] 的格式
  1696. if (Util.isString(position[0]) && position[0].indexOf('%') !== -1) {
  1697. return this.parsePercentPoint(coord, position);
  1698. }
  1699. var x = self._getNormalizedValue(position[0], xScale);
  1700. var y = self._getNormalizedValue(position[1], yScales[0]);
  1701. var point = coord.convertPoint({
  1702. x: x,
  1703. y: y
  1704. });
  1705. if (self.limitInPlot) {
  1706. // limit in chart plotRange
  1707. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  1708. return point;
  1709. }
  1710. return null;
  1711. }
  1712. return point;
  1713. };
  1714. /**
  1715. * render the guide component
  1716. * @param {Coord} coord coordinate instance
  1717. * @param {Canvas.Group} group the container
  1718. */
  1719. _proto.render = function render()
  1720. /* coord,group */
  1721. {};
  1722. _proto.repaint = function repaint() {
  1723. this.remove();
  1724. var coord = this.coord,
  1725. container = this.container,
  1726. canvas = this.canvas;
  1727. if (container && !container.isDestroyed()) {
  1728. this.render(coord, container);
  1729. canvas.draw();
  1730. }
  1731. };
  1732. _proto.remove = function remove() {
  1733. var element = this.element;
  1734. element && element.remove(true);
  1735. };
  1736. _proto.changeVisible = function changeVisible(visible) {
  1737. var self = this;
  1738. self.visible = visible;
  1739. var element = self.element;
  1740. if (!element) return;
  1741. if (element.set) {
  1742. element.set('visible', visible);
  1743. } else {
  1744. element.style.display = visible ? '' : 'none';
  1745. }
  1746. };
  1747. return GuideBase;
  1748. }();
  1749. module.exports = GuideBase;
  1750. /***/ }),
  1751. /* 13 */
  1752. /***/ (function(module, exports, __webpack_require__) {
  1753. /**
  1754. * 判断是否数字
  1755. * @return {Boolean} 是否数字
  1756. */
  1757. var isType = __webpack_require__(8);
  1758. var isNumber = function isNumber(value) {
  1759. return isType(value, 'Number');
  1760. };
  1761. module.exports = isNumber;
  1762. /***/ }),
  1763. /* 14 */
  1764. /***/ (function(module, exports, __webpack_require__) {
  1765. var mix = __webpack_require__(16);
  1766. var each = __webpack_require__(3);
  1767. var isObject = __webpack_require__(18);
  1768. var isNil = __webpack_require__(7);
  1769. var Scale =
  1770. /*#__PURE__*/
  1771. function () {
  1772. var _proto = Scale.prototype;
  1773. _proto._initDefaultCfg = function _initDefaultCfg() {
  1774. this.type = 'base';
  1775. /**
  1776. * 格式化函数,输出文本或者tick时的格式化函数
  1777. * @type {Function}
  1778. */
  1779. this.formatter = null;
  1780. /**
  1781. * 输出的值域
  1782. * @type {Array}
  1783. */
  1784. this.range = [0, 1];
  1785. /**
  1786. * 度量的标记
  1787. * @type {Array}
  1788. */
  1789. this.ticks = null;
  1790. /**
  1791. * 参与度量计算的值,可选项
  1792. * @type {Array}
  1793. */
  1794. this.values = [];
  1795. };
  1796. function Scale(cfg) {
  1797. this._initDefaultCfg();
  1798. mix(this, cfg);
  1799. this.init();
  1800. }
  1801. /**
  1802. * 度量初始化
  1803. * @protected
  1804. */
  1805. _proto.init = function init() {};
  1806. /**
  1807. * 获取该度量的ticks,返回的是多个对象,
  1808. * - text: tick 的文本
  1809. * - value: 对应的度量转换后的值
  1810. * <code>
  1811. * [
  1812. * {text: 0,value:0}
  1813. * {text: 1,value:0.2}
  1814. * {text: 2,value:0.4}
  1815. * {text: 3,value:0.6}
  1816. * {text: 4,value:0.8}
  1817. * {text: 5,value:1}
  1818. * ]
  1819. * </code>
  1820. * @param {Number} count 输出tick的个数的近似值,默认是 10
  1821. * @return {Array} 返回 ticks 数组
  1822. */
  1823. _proto.getTicks = function getTicks() {
  1824. var self = this;
  1825. var ticks = self.ticks;
  1826. var rst = [];
  1827. each(ticks, function (tick) {
  1828. var obj;
  1829. if (isObject(tick)) {
  1830. obj = tick;
  1831. } else {
  1832. obj = {
  1833. text: self.getText(tick),
  1834. tickValue: tick,
  1835. value: self.scale(tick)
  1836. };
  1837. }
  1838. rst.push(obj);
  1839. });
  1840. return rst;
  1841. };
  1842. /**
  1843. * 获取格式化后的文本
  1844. * @param {*} value 输入的数据
  1845. * @param {*} key 字段的 key
  1846. * @return {String} 格式化的文本
  1847. */
  1848. _proto.getText = function getText(value, key) {
  1849. var formatter = this.formatter;
  1850. value = formatter ? formatter(value, key) : value;
  1851. if (isNil(value) || !value.toString) {
  1852. value = '';
  1853. }
  1854. return value.toString();
  1855. };
  1856. /**
  1857. * 输出的值域最小值
  1858. * @protected
  1859. * @return {Number} 返回最小的值
  1860. */
  1861. _proto.rangeMin = function rangeMin() {
  1862. return this.range[0];
  1863. };
  1864. /**
  1865. * 输出的值域最大值
  1866. * @protected
  1867. * @return {Number} 返回最大的值
  1868. */
  1869. _proto.rangeMax = function rangeMax() {
  1870. var range = this.range;
  1871. return range[range.length - 1];
  1872. };
  1873. /**
  1874. * 度量转换后的结果,翻转回输入域
  1875. * @param {Number} value 需要翻转的数值
  1876. * @return {*} 度量的输入值
  1877. */
  1878. _proto.invert = function invert(value) {
  1879. return value;
  1880. };
  1881. /**
  1882. * 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等
  1883. * @param {*} value 传入的值
  1884. * @return {Number} 转换的值
  1885. */
  1886. _proto.translate = function translate(value) {
  1887. return value;
  1888. };
  1889. /**
  1890. * 进行度量转换
  1891. * @param {*} value 输入值
  1892. * @return {Number} 输出值,在设定的输出值域之间,默认[0,1]
  1893. */
  1894. _proto.scale = function scale(value) {
  1895. return value;
  1896. };
  1897. /**
  1898. * 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等
  1899. * @return {Scale} 克隆的度量
  1900. */
  1901. _proto.clone = function clone() {
  1902. var self = this;
  1903. var constr = self.constructor;
  1904. var cfg = {};
  1905. each(self, function (v, k) {
  1906. cfg[k] = self[k];
  1907. });
  1908. return new constr(cfg);
  1909. };
  1910. /**
  1911. * 更改度量的属性信息
  1912. * @param {Object} info 属性信息
  1913. * @chainable
  1914. * @return {Scale} 返回自身的引用
  1915. */
  1916. _proto.change = function change(info) {
  1917. this.ticks = null;
  1918. mix(this, info);
  1919. this.init();
  1920. return this;
  1921. };
  1922. return Scale;
  1923. }();
  1924. module.exports = Scale;
  1925. /***/ }),
  1926. /* 15 */
  1927. /***/ (function(module, exports, __webpack_require__) {
  1928. var isType = __webpack_require__(8);
  1929. var isString = function isString(str) {
  1930. return isType(str, 'String');
  1931. };
  1932. module.exports = isString;
  1933. /***/ }),
  1934. /* 16 */
  1935. /***/ (function(module, exports) {
  1936. function _mix(dist, obj) {
  1937. for (var key in obj) {
  1938. if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
  1939. dist[key] = obj[key];
  1940. }
  1941. }
  1942. }
  1943. var mix = function mix(dist, src1, src2, src3) {
  1944. if (src1) _mix(dist, src1);
  1945. if (src2) _mix(dist, src2);
  1946. if (src3) _mix(dist, src3);
  1947. return dist;
  1948. };
  1949. module.exports = mix;
  1950. /***/ }),
  1951. /* 17 */
  1952. /***/ (function(module, exports, __webpack_require__) {
  1953. /**
  1954. * @fileOverview the Attribute base class
  1955. */
  1956. var isString = __webpack_require__(15);
  1957. var isArray = __webpack_require__(10);
  1958. var mix = __webpack_require__(16);
  1959. var each = __webpack_require__(3);
  1960. function toScaleString(scale, value) {
  1961. if (isString(value)) {
  1962. return value;
  1963. }
  1964. return scale.invert(scale.scale(value));
  1965. }
  1966. /**
  1967. * 所有视觉通道属性的基类
  1968. * @class Attr
  1969. */
  1970. var AttributeBase =
  1971. /*#__PURE__*/
  1972. function () {
  1973. function AttributeBase(cfg) {
  1974. /**
  1975. * 属性的类型
  1976. * @type {String}
  1977. */
  1978. this.type = 'base';
  1979. /**
  1980. * 属性的名称
  1981. * @type {String}
  1982. */
  1983. this.name = null;
  1984. /**
  1985. * 回调函数
  1986. * @type {Function}
  1987. */
  1988. this.method = null;
  1989. /**
  1990. * 备选的值数组
  1991. * @type {Array}
  1992. */
  1993. this.values = [];
  1994. /**
  1995. * 属性内部的度量
  1996. * @type {Array}
  1997. */
  1998. this.scales = [];
  1999. /**
  2000. * 是否通过线性取值, 如果未指定,则根据数值的类型判定
  2001. * @type {Boolean}
  2002. */
  2003. this.linear = null;
  2004. mix(this, cfg);
  2005. } // 获取属性值,将值映射到视觉通道
  2006. var _proto = AttributeBase.prototype;
  2007. _proto._getAttrValue = function _getAttrValue(scale, value) {
  2008. var values = this.values;
  2009. if (scale.isCategory && !this.linear) {
  2010. var index = scale.translate(value);
  2011. return values[index % values.length];
  2012. }
  2013. var percent = scale.scale(value);
  2014. return this.getLinearValue(percent);
  2015. };
  2016. /**
  2017. * 如果进行线性映射,返回对应的映射值
  2018. * @protected
  2019. * @param {Number} percent 百分比
  2020. * @return {*} 颜色值、形状、大小等
  2021. */
  2022. _proto.getLinearValue = function getLinearValue(percent) {
  2023. var values = this.values;
  2024. var steps = values.length - 1;
  2025. var step = Math.floor(steps * percent);
  2026. var leftPercent = steps * percent - step;
  2027. var start = values[step];
  2028. var end = step === steps ? start : values[step + 1];
  2029. var rstValue = start + (end - start) * leftPercent;
  2030. return rstValue;
  2031. };
  2032. /**
  2033. * 默认的回调函数
  2034. * @param {*} value 回调函数的值
  2035. * @type {Function}
  2036. * @return {Array} 返回映射后的值
  2037. */
  2038. _proto.callback = function callback(value) {
  2039. var self = this;
  2040. var scale = self.scales[0];
  2041. var rstValue = null;
  2042. if (scale.type === 'identity') {
  2043. rstValue = scale.value;
  2044. } else {
  2045. rstValue = self._getAttrValue(scale, value);
  2046. }
  2047. return rstValue;
  2048. };
  2049. /**
  2050. * 根据度量获取属性名
  2051. * @return {Array} dims of this Attribute
  2052. */
  2053. _proto.getNames = function getNames() {
  2054. var scales = this.scales;
  2055. var names = this.names;
  2056. var length = Math.min(scales.length, names.length);
  2057. var rst = [];
  2058. for (var i = 0; i < length; i++) {
  2059. rst.push(names[i]);
  2060. }
  2061. return rst;
  2062. };
  2063. /**
  2064. * 根据度量获取维度名
  2065. * @return {Array} dims of this Attribute
  2066. */
  2067. _proto.getFields = function getFields() {
  2068. var scales = this.scales;
  2069. var rst = [];
  2070. each(scales, function (scale) {
  2071. rst.push(scale.field);
  2072. });
  2073. return rst;
  2074. };
  2075. /**
  2076. * 根据名称获取度量
  2077. * @param {String} name the name of scale
  2078. * @return {Scale} scale
  2079. */
  2080. _proto.getScale = function getScale(name) {
  2081. var scales = this.scales;
  2082. var names = this.names;
  2083. var index = names.indexOf(name);
  2084. return scales[index];
  2085. };
  2086. /**
  2087. * 映射数据
  2088. * @param {*} param1...paramn 多个数值
  2089. * @return {Array} 映射的值组成的数组
  2090. */
  2091. _proto.mapping = function mapping() {
  2092. var scales = this.scales;
  2093. var callback = this.callback;
  2094. for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
  2095. params[_key] = arguments[_key];
  2096. }
  2097. var values = params;
  2098. if (callback) {
  2099. for (var i = 0, len = params.length; i < len; i++) {
  2100. params[i] = this._toOriginParam(params[i], scales[i]);
  2101. }
  2102. values = callback.apply(this, params);
  2103. }
  2104. values = [].concat(values);
  2105. return values;
  2106. }; // 原始的参数
  2107. _proto._toOriginParam = function _toOriginParam(param, scale) {
  2108. var rst = param;
  2109. if (!scale.isLinear) {
  2110. if (isArray(param)) {
  2111. rst = [];
  2112. for (var i = 0, len = param.length; i < len; i++) {
  2113. rst.push(toScaleString(scale, param[i]));
  2114. }
  2115. } else {
  2116. rst = toScaleString(scale, param);
  2117. }
  2118. }
  2119. return rst;
  2120. };
  2121. return AttributeBase;
  2122. }();
  2123. module.exports = AttributeBase;
  2124. /***/ }),
  2125. /* 18 */
  2126. /***/ (function(module, exports) {
  2127. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  2128. return typeof obj;
  2129. } : function (obj) {
  2130. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  2131. };
  2132. var isObject = function isObject(value) {
  2133. /**
  2134. * isObject({}) => true
  2135. * isObject([1, 2, 3]) => true
  2136. * isObject(Function) => true
  2137. * isObject(null) => false
  2138. */
  2139. var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
  2140. return value !== null && type === 'object' || type === 'function';
  2141. };
  2142. module.exports = isObject;
  2143. /***/ }),
  2144. /* 19 */
  2145. /***/ (function(module, exports, __webpack_require__) {
  2146. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  2147. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  2148. var Base = __webpack_require__(29);
  2149. var Plot = __webpack_require__(50);
  2150. var Util = __webpack_require__(0);
  2151. var Coord = __webpack_require__(51);
  2152. var Geom = __webpack_require__(6);
  2153. var ScaleController = __webpack_require__(59);
  2154. var AxisController = __webpack_require__(65);
  2155. var Global = __webpack_require__(1);
  2156. var _require = __webpack_require__(5),
  2157. Canvas = _require.Canvas;
  2158. var Helper = __webpack_require__(26);
  2159. function isFullCircle(coord) {
  2160. var startAngle = coord.startAngle;
  2161. var endAngle = coord.endAngle;
  2162. if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) {
  2163. return false;
  2164. }
  2165. return true;
  2166. }
  2167. function compare(a, b) {
  2168. return a - b;
  2169. }
  2170. function _isScaleExist(scales, compareScale) {
  2171. var flag = false;
  2172. Util.each(scales, function (scale) {
  2173. var scaleValues = [].concat(scale.values);
  2174. var compareScaleValues = [].concat(compareScale.values);
  2175. if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
  2176. flag = true;
  2177. return;
  2178. }
  2179. });
  2180. return flag;
  2181. }
  2182. var Chart =
  2183. /*#__PURE__*/
  2184. function (_Base) {
  2185. _inheritsLoose(Chart, _Base);
  2186. Chart.initPlugins = function initPlugins() {
  2187. return {
  2188. _plugins: [],
  2189. _cacheId: 0,
  2190. register: function register(plugins) {
  2191. var p = this._plugins;
  2192. [].concat(plugins).forEach(function (plugin) {
  2193. if (p.indexOf(plugin) === -1) {
  2194. p.push(plugin);
  2195. }
  2196. });
  2197. this._cacheId++;
  2198. },
  2199. unregister: function unregister(plugins) {
  2200. var p = this._plugins;
  2201. [].concat(plugins).forEach(function (plugin) {
  2202. var idx = p.indexOf(plugin);
  2203. if (idx !== -1) {
  2204. p.splice(idx, 1);
  2205. }
  2206. });
  2207. this._cacheId++;
  2208. },
  2209. clear: function clear() {
  2210. this._plugins = [];
  2211. this._cacheId++;
  2212. },
  2213. count: function count() {
  2214. return this._plugins.length;
  2215. },
  2216. getAll: function getAll() {
  2217. return this._plugins;
  2218. },
  2219. notify: function notify(chart, hook, args) {
  2220. var descriptors = this.descriptors(chart);
  2221. var ilen = descriptors.length;
  2222. var i;
  2223. var descriptor;
  2224. var plugin;
  2225. var params;
  2226. var method;
  2227. for (i = 0; i < ilen; ++i) {
  2228. descriptor = descriptors[i];
  2229. plugin = descriptor.plugin;
  2230. method = plugin[hook];
  2231. if (typeof method === 'function') {
  2232. params = [chart].concat(args || []);
  2233. if (method.apply(plugin, params) === false) {
  2234. return false;
  2235. }
  2236. }
  2237. }
  2238. return true;
  2239. },
  2240. descriptors: function descriptors(chart) {
  2241. var cache = chart._plugins || (chart._plugins = {});
  2242. if (cache.id === this._cacheId) {
  2243. return cache.descriptors;
  2244. }
  2245. var plugins = [];
  2246. var descriptors = [];
  2247. this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
  2248. var idx = plugins.indexOf(plugin);
  2249. if (idx !== -1) {
  2250. return;
  2251. }
  2252. plugins.push(plugin);
  2253. descriptors.push({
  2254. plugin: plugin
  2255. });
  2256. });
  2257. cache.descriptors = descriptors;
  2258. cache.id = this._cacheId;
  2259. return descriptors;
  2260. }
  2261. };
  2262. };
  2263. var _proto = Chart.prototype;
  2264. _proto.getDefaultCfg = function getDefaultCfg() {
  2265. return {
  2266. /**
  2267. * the id of canvas
  2268. * @type {String}
  2269. */
  2270. id: null,
  2271. /**
  2272. * padding
  2273. * @type {Array|Number}
  2274. */
  2275. padding: Global.padding,
  2276. /**
  2277. * data
  2278. * @type {Array}
  2279. */
  2280. data: null,
  2281. /**
  2282. * scales of chart
  2283. * @type {Object}
  2284. */
  2285. scales: {},
  2286. /**
  2287. * @private
  2288. * geometry instances
  2289. * @type {Array}
  2290. */
  2291. geoms: null,
  2292. /**
  2293. * scale configuration
  2294. * @type {Object}
  2295. */
  2296. colDefs: null,
  2297. pixelRatio: Global.pixelRatio,
  2298. /**
  2299. * filter options
  2300. * @type {Object}
  2301. */
  2302. filters: null,
  2303. appendPadding: Global.appendPadding
  2304. };
  2305. };
  2306. _proto._syncYScales = function _syncYScales() {
  2307. var geoms = this.get('geoms');
  2308. var syncScales = [];
  2309. var min = [];
  2310. var max = [];
  2311. Util.each(geoms, function (geom) {
  2312. var yScale = geom.getYScale();
  2313. if (yScale.isLinear) {
  2314. syncScales.push(yScale);
  2315. min.push(yScale.min);
  2316. max.push(yScale.max);
  2317. }
  2318. });
  2319. min = Math.min.apply(null, min);
  2320. max = Math.max.apply(null, max);
  2321. Util.each(syncScales, function (scale) {
  2322. scale.change({
  2323. min: min
  2324. });
  2325. scale.change({
  2326. max: max
  2327. });
  2328. });
  2329. };
  2330. _proto._getFieldsForLegend = function _getFieldsForLegend() {
  2331. var fields = [];
  2332. var geoms = this.get('geoms');
  2333. Util.each(geoms, function (geom) {
  2334. var attrOptions = geom.get('attrOptions');
  2335. var attrCfg = attrOptions.color;
  2336. if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) {
  2337. var arr = attrCfg.field.split('*');
  2338. Util.each(arr, function (item) {
  2339. if (fields.indexOf(item) === -1) {
  2340. fields.push(item);
  2341. }
  2342. });
  2343. }
  2344. });
  2345. return fields;
  2346. };
  2347. _proto._createScale = function _createScale(field, data) {
  2348. var scaleController = this.get('scaleController');
  2349. return scaleController.createScale(field, data);
  2350. };
  2351. _proto._adjustScale = function _adjustScale() {
  2352. var self = this;
  2353. var coord = self.get('coord');
  2354. var xScale = self.getXScale();
  2355. var yScales = self.getYScales();
  2356. var scales = [];
  2357. xScale && scales.push(xScale);
  2358. scales = scales.concat(yScales);
  2359. var inFullCircle = coord.isPolar && isFullCircle(coord);
  2360. var scaleController = self.get('scaleController');
  2361. var colDefs = scaleController.defs;
  2362. Util.each(scales, function (scale) {
  2363. if ((scale.isCategory || scale.isIdentity) && scale.values && !(colDefs[scale.field] && colDefs[scale.field].range)) {
  2364. var count = scale.values.length;
  2365. var range;
  2366. if (count === 1) {
  2367. range = [0.5, 1];
  2368. } else {
  2369. var widthRatio = 1;
  2370. var offset = 0;
  2371. if (inFullCircle) {
  2372. if (!coord.transposed) {
  2373. range = [0, 1 - 1 / count];
  2374. } else {
  2375. widthRatio = Global.widthRatio.multiplePie;
  2376. offset = 1 / count * widthRatio;
  2377. range = [offset / 2, 1 - offset / 2];
  2378. }
  2379. } else {
  2380. offset = 1 / count * 1 / 2;
  2381. range = [offset, 1 - offset];
  2382. }
  2383. }
  2384. scale.range = range;
  2385. }
  2386. });
  2387. var geoms = this.get('geoms');
  2388. for (var i = 0; i < geoms.length; i++) {
  2389. var geom = geoms[i];
  2390. if (geom.get('type') === 'interval') {
  2391. var yScale = geom.getYScale();
  2392. var field = yScale.field,
  2393. min = yScale.min,
  2394. max = yScale.max,
  2395. type = yScale.type;
  2396. if (!(colDefs[field] && colDefs[field].min) && type !== 'time') {
  2397. if (min > 0) {
  2398. yScale.change({
  2399. min: 0
  2400. });
  2401. } else if (max <= 0) {
  2402. yScale.change({
  2403. max: 0
  2404. });
  2405. }
  2406. }
  2407. }
  2408. }
  2409. };
  2410. _proto._removeGeoms = function _removeGeoms() {
  2411. var geoms = this.get('geoms');
  2412. while (geoms.length > 0) {
  2413. var geom = geoms.shift();
  2414. geom.destroy();
  2415. }
  2416. };
  2417. _proto._clearGeoms = function _clearGeoms() {
  2418. var geoms = this.get('geoms');
  2419. for (var i = 0, length = geoms.length; i < length; i++) {
  2420. var geom = geoms[i];
  2421. geom.clear();
  2422. }
  2423. };
  2424. _proto._clearInner = function _clearInner() {
  2425. this.set('scales', {});
  2426. this.set('legendItems', null);
  2427. this._clearGeoms();
  2428. Chart.plugins.notify(this, 'clearInner');
  2429. this.get('axisController') && this.get('axisController').clear();
  2430. };
  2431. _proto._execFilter = function _execFilter(data) {
  2432. var filters = this.get('filters');
  2433. if (filters) {
  2434. data = data.filter(function (obj) {
  2435. var rst = true;
  2436. Util.each(filters, function (fn, k) {
  2437. if (fn) {
  2438. rst = fn(obj[k], obj);
  2439. if (!rst) {
  2440. return false;
  2441. }
  2442. }
  2443. });
  2444. return rst;
  2445. });
  2446. }
  2447. return data;
  2448. };
  2449. _proto._initGeoms = function _initGeoms(geoms) {
  2450. var coord = this.get('coord');
  2451. var data = this.get('filteredData');
  2452. var colDefs = this.get('colDefs');
  2453. for (var i = 0, length = geoms.length; i < length; i++) {
  2454. var geom = geoms[i];
  2455. geom.set('data', data);
  2456. geom.set('coord', coord);
  2457. geom.set('colDefs', colDefs);
  2458. geom.init();
  2459. }
  2460. };
  2461. _proto._initCoord = function _initCoord() {
  2462. var plot = this.get('plotRange');
  2463. var coordCfg = Util.mix({
  2464. type: 'cartesian'
  2465. }, this.get('coordCfg'), {
  2466. plot: plot
  2467. });
  2468. var type = coordCfg.type;
  2469. var C = Coord[Util.upperFirst(type)];
  2470. var coord = new C(coordCfg);
  2471. this.set('coord', coord);
  2472. };
  2473. _proto._initLayout = function _initLayout() {
  2474. var padding = this.get('_padding');
  2475. if (!padding) {
  2476. padding = this.get('margin') || this.get('padding');
  2477. padding = Util.parsePadding(padding);
  2478. }
  2479. var top = padding[0] === 'auto' ? 0 : padding[0];
  2480. var right = padding[1] === 'auto' ? 0 : padding[1];
  2481. var bottom = padding[2] === 'auto' ? 0 : padding[2];
  2482. var left = padding[3] === 'auto' ? 0 : padding[3];
  2483. var width = this.get('width');
  2484. var height = this.get('height');
  2485. var plot = new Plot({
  2486. start: {
  2487. x: left,
  2488. y: top
  2489. },
  2490. end: {
  2491. x: width - right,
  2492. y: height - bottom
  2493. }
  2494. });
  2495. this.set('plotRange', plot);
  2496. this.set('plot', plot);
  2497. };
  2498. _proto._initCanvas = function _initCanvas() {
  2499. var self = this;
  2500. try {
  2501. var canvas = new Canvas({
  2502. el: self.get('el') || self.get('id'),
  2503. context: self.get('context'),
  2504. pixelRatio: self.get('pixelRatio'),
  2505. width: self.get('width'),
  2506. height: self.get('height'),
  2507. fontFamily: Global.fontFamily
  2508. });
  2509. self.set('canvas', canvas);
  2510. self.set('width', canvas.get('width'));
  2511. self.set('height', canvas.get('height'));
  2512. } catch (error) {
  2513. throw error;
  2514. }
  2515. Chart.plugins.notify(self, 'afterCanvasInit');
  2516. self._initLayout();
  2517. };
  2518. _proto._initLayers = function _initLayers() {
  2519. var canvas = this.get('canvas');
  2520. this.set('backPlot', canvas.addGroup());
  2521. this.set('middlePlot', canvas.addGroup({
  2522. zIndex: 10
  2523. }));
  2524. this.set('frontPlot', canvas.addGroup({
  2525. zIndex: 20
  2526. }));
  2527. };
  2528. _proto._init = function _init() {
  2529. var self = this;
  2530. self._initCanvas();
  2531. self._initLayers();
  2532. self.set('geoms', []);
  2533. self.set('scaleController', new ScaleController());
  2534. self.set('axisController', new AxisController({
  2535. frontPlot: self.get('frontPlot').addGroup({
  2536. className: 'axisContainer'
  2537. }),
  2538. backPlot: self.get('backPlot').addGroup({
  2539. className: 'axisContainer'
  2540. }),
  2541. chart: self
  2542. }));
  2543. Chart.plugins.notify(self, 'init');
  2544. };
  2545. function Chart(cfg) {
  2546. var _this;
  2547. _this = _Base.call(this, cfg) || this;
  2548. var self = _assertThisInitialized(_assertThisInitialized(_this));
  2549. Util.each(Geom, function (geomConstructor, className) {
  2550. var methodName = Util.lowerFirst(className);
  2551. self[methodName] = function (cfg) {
  2552. var geom = new geomConstructor(cfg);
  2553. self.addGeom(geom);
  2554. return geom;
  2555. };
  2556. });
  2557. self._init();
  2558. return _this;
  2559. }
  2560. /**
  2561. * set data and some scale configuration
  2562. * @chainable
  2563. * @param {Array} data the dataset to visualize
  2564. * @param {Object} colDefs the configuration for scales
  2565. * @return {Chart} return the chart instance
  2566. */
  2567. _proto.source = function source(data, colDefs) {
  2568. this.set('data', data);
  2569. if (colDefs) {
  2570. this.scale(colDefs);
  2571. }
  2572. return this;
  2573. };
  2574. _proto.scale = function scale(field, cfg) {
  2575. var colDefs = this.get('colDefs') || {};
  2576. if (Util.isObject(field)) {
  2577. Util.mix(colDefs, field);
  2578. } else {
  2579. colDefs[field] = cfg;
  2580. }
  2581. this.set('colDefs', colDefs);
  2582. var scaleController = this.get('scaleController');
  2583. scaleController.defs = colDefs;
  2584. return this;
  2585. };
  2586. /**
  2587. * configure the axis
  2588. * @chainable
  2589. * @param {String|Boolean} field the field name of data
  2590. * @param {Object} cfg configuration for axis
  2591. * @return {Chart} return the chart instance
  2592. */
  2593. _proto.axis = function axis(field, cfg) {
  2594. var axisController = this.get('axisController');
  2595. if (!field) {
  2596. axisController.axisCfg = null;
  2597. } else {
  2598. axisController.axisCfg = axisController.axisCfg || {};
  2599. axisController.axisCfg[field] = cfg;
  2600. }
  2601. return this;
  2602. };
  2603. /**
  2604. * configure the coordinate
  2605. * @chainable
  2606. * @param {String} type set the type of coodinate
  2607. * @param {Object} cfg configuration for coordinate
  2608. * @return {Chart} return the chart instance
  2609. */
  2610. _proto.coord = function coord(type, cfg) {
  2611. var coordCfg;
  2612. if (Util.isObject(type)) {
  2613. coordCfg = type;
  2614. } else {
  2615. coordCfg = cfg || {};
  2616. coordCfg.type = type || 'cartesian';
  2617. }
  2618. this.set('coordCfg', coordCfg);
  2619. return this;
  2620. };
  2621. _proto.filter = function filter(field, condition) {
  2622. var filters = this.get('filters') || {};
  2623. filters[field] = condition;
  2624. this.set('filters', filters);
  2625. };
  2626. /**
  2627. * render the chart
  2628. * @chainable
  2629. * @return {Chart} return the chart instance
  2630. */
  2631. _proto.render = function render() {
  2632. var canvas = this.get('canvas');
  2633. var geoms = this.get('geoms');
  2634. var data = this.get('data') || [];
  2635. var filteredData = this._execFilter(data); // filter data
  2636. this.set('filteredData', filteredData);
  2637. this._initCoord(); // initialization coordinate instance
  2638. Chart.plugins.notify(this, 'beforeGeomInit');
  2639. this._initGeoms(geoms); // init all geometry instances
  2640. this.get('syncY') && this._syncYScales();
  2641. this._adjustScale(); // do some adjust for data
  2642. Chart.plugins.notify(this, 'beforeGeomDraw');
  2643. this._renderAxis();
  2644. var middlePlot = this.get('middlePlot');
  2645. if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
  2646. var coord = this.get('coord');
  2647. var clip = Helper.getClip(coord);
  2648. clip.set('canvas', middlePlot.get('canvas'));
  2649. middlePlot.attr('clip', clip);
  2650. }
  2651. for (var i = 0, length = geoms.length; i < length; i++) {
  2652. var geom = geoms[i];
  2653. geom.paint();
  2654. }
  2655. Chart.plugins.notify(this, 'afterGeomDraw');
  2656. canvas.sort();
  2657. this.get('frontPlot').sort();
  2658. Chart.plugins.notify(this, 'beforeCanvasDraw');
  2659. canvas.draw();
  2660. return this;
  2661. };
  2662. /**
  2663. * clear the chart, include geometris and all the shapes
  2664. * @chainable
  2665. * @return {Chart} return the chart
  2666. */
  2667. _proto.clear = function clear() {
  2668. Chart.plugins.notify(this, 'clear');
  2669. this._removeGeoms();
  2670. this._clearInner();
  2671. this.set('filters', null);
  2672. this.set('isUpdate', false);
  2673. this.set('_padding', null);
  2674. var canvas = this.get('canvas');
  2675. canvas.draw();
  2676. return this;
  2677. };
  2678. _proto.repaint = function repaint() {
  2679. this.set('isUpdate', true);
  2680. Chart.plugins.notify(this, 'repaint');
  2681. this._clearInner();
  2682. this.render();
  2683. };
  2684. _proto.changeData = function changeData(data) {
  2685. this.set('data', data);
  2686. Chart.plugins.notify(this, 'changeData');
  2687. this.set('_padding', null);
  2688. this.repaint();
  2689. };
  2690. _proto.changeSize = function changeSize(width, height) {
  2691. if (width) {
  2692. this.set('width', width);
  2693. } else {
  2694. width = this.get('width');
  2695. }
  2696. if (height) {
  2697. this.set('height', height);
  2698. } else {
  2699. height = this.get('height');
  2700. }
  2701. var canvas = this.get('canvas');
  2702. canvas.changeSize(width, height);
  2703. this._initLayout();
  2704. this.repaint();
  2705. return this;
  2706. };
  2707. _proto.destroy = function destroy() {
  2708. this.clear();
  2709. var canvas = this.get('canvas');
  2710. canvas.destroy();
  2711. Chart.plugins.notify(this, 'afterCanvasDestroyed');
  2712. if (this._interactions) {
  2713. Util.each(this._interactions, function (interaction) {
  2714. interaction.destroy();
  2715. });
  2716. }
  2717. _Base.prototype.destroy.call(this);
  2718. };
  2719. /**
  2720. * calculate dataset's position on canvas
  2721. * @param {Object} record the dataset
  2722. * @return {Object} return the position
  2723. */
  2724. _proto.getPosition = function getPosition(record) {
  2725. var self = this;
  2726. var coord = self.get('coord');
  2727. var xScale = self.getXScale();
  2728. var yScale = self.getYScales()[0];
  2729. var xField = xScale.field;
  2730. var x = xScale.scale(record[xField]);
  2731. var yField = yScale.field;
  2732. var y = yScale.scale(record[yField]);
  2733. return coord.convertPoint({
  2734. x: x,
  2735. y: y
  2736. });
  2737. };
  2738. /**
  2739. * get the data item of the point
  2740. * @param {Object} point canvas position
  2741. * @return {Object} return the data item
  2742. */
  2743. _proto.getRecord = function getRecord(point) {
  2744. var self = this;
  2745. var coord = self.get('coord');
  2746. var xScale = self.getXScale();
  2747. var yScale = self.getYScales()[0];
  2748. var invertPoint = coord.invertPoint(point);
  2749. var record = {};
  2750. record[xScale.field] = xScale.invert(invertPoint.x);
  2751. record[yScale.field] = yScale.invert(invertPoint.y);
  2752. return record;
  2753. };
  2754. /**
  2755. * get the dataset of the point
  2756. * @param {Object} point canvas position
  2757. * @return {Array} return the dataset
  2758. **/
  2759. _proto.getSnapRecords = function getSnapRecords(point) {
  2760. var geom = this.get('geoms')[0];
  2761. var data = [];
  2762. if (geom) {
  2763. // need to judge
  2764. data = geom.getSnapRecords(point);
  2765. }
  2766. return data;
  2767. };
  2768. /**
  2769. * creat scale instances
  2770. * @param {String} field field name of data
  2771. * @return {Scale} return the scale
  2772. */
  2773. _proto.createScale = function createScale(field) {
  2774. var data = this.get('data');
  2775. var filteredData = this.get('filteredData');
  2776. if (filteredData.length) {
  2777. var legendFields = this._getFieldsForLegend();
  2778. if (legendFields.indexOf(field) === -1) {
  2779. data = filteredData;
  2780. }
  2781. }
  2782. var scales = this.get('scales');
  2783. if (!scales[field]) {
  2784. scales[field] = this._createScale(field, data);
  2785. }
  2786. return scales[field];
  2787. };
  2788. /**
  2789. * @protected
  2790. * add geometry instance to geoms
  2791. * @param {Geom} geom geometry instance
  2792. */
  2793. _proto.addGeom = function addGeom(geom) {
  2794. var geoms = this.get('geoms');
  2795. var middlePlot = this.get('middlePlot');
  2796. geoms.push(geom);
  2797. geom.set('chart', this);
  2798. geom.set('container', middlePlot.addGroup());
  2799. };
  2800. /**
  2801. * get the scale of x axis
  2802. * @return {Scale} return the scale
  2803. */
  2804. _proto.getXScale = function getXScale() {
  2805. var self = this;
  2806. var geoms = self.get('geoms');
  2807. var xScale = geoms[0].getXScale();
  2808. return xScale;
  2809. };
  2810. /**
  2811. * get the scale of y axis
  2812. * @return {Array} return the scale
  2813. */
  2814. _proto.getYScales = function getYScales() {
  2815. var geoms = this.get('geoms');
  2816. var rst = [];
  2817. Util.each(geoms, function (geom) {
  2818. var yScale = geom.getYScale();
  2819. if (rst.indexOf(yScale) === -1) {
  2820. rst.push(yScale);
  2821. }
  2822. });
  2823. return rst;
  2824. };
  2825. _proto.getLegendItems = function getLegendItems() {
  2826. if (this.get('legendItems')) {
  2827. return this.get('legendItems');
  2828. }
  2829. var legendItems = {};
  2830. var scales = [];
  2831. var geoms = this.get('geoms');
  2832. Util.each(geoms, function (geom) {
  2833. var colorAttr = geom.getAttr('color');
  2834. if (colorAttr) {
  2835. var scale = colorAttr.getScale('color');
  2836. if (scale.type !== 'identity' && !_isScaleExist(scales, scale)) {
  2837. scales.push(scale);
  2838. var field = scale.field;
  2839. var ticks = scale.getTicks();
  2840. var items = [];
  2841. Util.each(ticks, function (tick) {
  2842. var text = tick.text;
  2843. var name = text;
  2844. var scaleValue = tick.value;
  2845. var value = scale.invert(scaleValue);
  2846. var color = colorAttr.mapping(value).join('') || Global.defaultColor;
  2847. var marker = {
  2848. fill: color,
  2849. radius: 3,
  2850. symbol: 'circle',
  2851. stroke: '#fff'
  2852. };
  2853. items.push({
  2854. name: name,
  2855. // for display
  2856. dataValue: value,
  2857. // the origin value
  2858. checked: true,
  2859. marker: marker
  2860. });
  2861. });
  2862. legendItems[field] = items;
  2863. }
  2864. }
  2865. });
  2866. this.set('legendItems', legendItems);
  2867. return legendItems;
  2868. }; // register the plugins
  2869. _proto.registerPlugins = function registerPlugins(plugins) {
  2870. var self = this;
  2871. var chartPlugins = self.get('plugins') || [];
  2872. if (!Util.isArray(chartPlugins)) {
  2873. chartPlugins = [chartPlugins];
  2874. }
  2875. [].concat(plugins).forEach(function (plugin) {
  2876. if (chartPlugins.indexOf(plugin) === -1) {
  2877. plugin.init && plugin.init(self); // init
  2878. chartPlugins.push(plugin);
  2879. }
  2880. });
  2881. Chart.plugins._cacheId++;
  2882. self.set('plugins', chartPlugins);
  2883. };
  2884. _proto._renderAxis = function _renderAxis() {
  2885. var axisController = this.get('axisController');
  2886. var xScale = this.getXScale();
  2887. var yScales = this.getYScales();
  2888. var coord = this.get('coord');
  2889. Chart.plugins.notify(this, 'beforeRenderAxis');
  2890. axisController.createAxis(coord, xScale, yScales);
  2891. };
  2892. _proto._isAutoPadding = function _isAutoPadding() {
  2893. if (this.get('_padding')) {
  2894. return false;
  2895. }
  2896. var padding = this.get('padding');
  2897. if (Util.isArray(padding)) {
  2898. return padding.indexOf('auto') !== -1;
  2899. }
  2900. return padding === 'auto';
  2901. };
  2902. _proto._updateLayout = function _updateLayout(padding) {
  2903. var width = this.get('width');
  2904. var height = this.get('height');
  2905. var start = {
  2906. x: padding[3],
  2907. y: padding[0]
  2908. };
  2909. var end = {
  2910. x: width - padding[1],
  2911. y: height - padding[2]
  2912. };
  2913. var plot = this.get('plot');
  2914. var coord = this.get('coord');
  2915. plot.reset(start, end);
  2916. coord.reset(plot);
  2917. };
  2918. return Chart;
  2919. }(Base);
  2920. Chart.plugins = Chart.initPlugins();
  2921. module.exports = Chart;
  2922. /***/ }),
  2923. /* 20 */
  2924. /***/ (function(module, exports, __webpack_require__) {
  2925. /**
  2926. * @fileOverview shape util
  2927. * @author dxq613@gmail.com
  2928. */
  2929. var Util = __webpack_require__(0);
  2930. var ShapeUtil = {
  2931. splitPoints: function splitPoints(obj) {
  2932. var points = [];
  2933. var x = obj.x;
  2934. var y = obj.y;
  2935. y = Util.isArray(y) ? y : [y];
  2936. y.forEach(function (yItem, index) {
  2937. var point = {
  2938. x: Util.isArray(x) ? x[index] : x,
  2939. y: yItem
  2940. };
  2941. points.push(point);
  2942. });
  2943. return points;
  2944. },
  2945. splitArray: function splitArray(data, yField, connectNulls) {
  2946. if (!data.length) return [];
  2947. var arr = [];
  2948. var tmp = [];
  2949. var yValue;
  2950. Util.each(data, function (obj) {
  2951. yValue = obj._origin ? obj._origin[yField] : obj[yField];
  2952. if (connectNulls) {
  2953. if (!Util.isNil(yValue)) {
  2954. tmp.push(obj);
  2955. }
  2956. } else {
  2957. if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) {
  2958. if (tmp.length) {
  2959. arr.push(tmp);
  2960. tmp = [];
  2961. }
  2962. } else {
  2963. tmp.push(obj);
  2964. }
  2965. }
  2966. });
  2967. if (tmp.length) {
  2968. arr.push(tmp);
  2969. }
  2970. return arr;
  2971. }
  2972. };
  2973. module.exports = ShapeUtil;
  2974. /***/ }),
  2975. /* 21 */
  2976. /***/ (function(module, exports, __webpack_require__) {
  2977. var Util = __webpack_require__(0);
  2978. var Base =
  2979. /*#__PURE__*/
  2980. function () {
  2981. var _proto = Base.prototype;
  2982. _proto._initDefaultCfg = function _initDefaultCfg() {};
  2983. function Base(cfg) {
  2984. this._initDefaultCfg();
  2985. Util.mix(this, cfg);
  2986. var start;
  2987. var end;
  2988. if (this.plot) {
  2989. start = this.plot.bl;
  2990. end = this.plot.tr;
  2991. this.start = start;
  2992. this.end = end;
  2993. } else {
  2994. start = this.start;
  2995. end = this.end;
  2996. }
  2997. this.init(start, end);
  2998. }
  2999. _proto.init = function init() {};
  3000. _proto.convertPoint = function convertPoint(point) {
  3001. return point;
  3002. };
  3003. _proto.invertPoint = function invertPoint(point) {
  3004. return point;
  3005. };
  3006. _proto.reset = function reset(plot) {
  3007. this.plot = plot;
  3008. var bl = plot.bl,
  3009. tr = plot.tr;
  3010. this.start = bl;
  3011. this.end = tr;
  3012. this.init(bl, tr);
  3013. };
  3014. return Base;
  3015. }();
  3016. module.exports = Base;
  3017. /***/ }),
  3018. /* 22 */
  3019. /***/ (function(module, exports, __webpack_require__) {
  3020. var mix = __webpack_require__(16);
  3021. var Adjust =
  3022. /*#__PURE__*/
  3023. function () {
  3024. var _proto = Adjust.prototype;
  3025. _proto._initDefaultCfg = function _initDefaultCfg() {
  3026. this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
  3027. };
  3028. function Adjust(cfg) {
  3029. this._initDefaultCfg();
  3030. mix(this, cfg);
  3031. }
  3032. /**
  3033. * @override
  3034. */
  3035. _proto.processAdjust = function processAdjust()
  3036. /* dataArray */
  3037. {};
  3038. return Adjust;
  3039. }();
  3040. module.exports = Adjust;
  3041. /***/ }),
  3042. /* 23 */
  3043. /***/ (function(module, exports) {
  3044. var Matrix = {
  3045. multiply: function multiply(m1, m2) {
  3046. var m11 = m1[0] * m2[0] + m1[2] * m2[1];
  3047. var m12 = m1[1] * m2[0] + m1[3] * m2[1];
  3048. var m21 = m1[0] * m2[2] + m1[2] * m2[3];
  3049. var m22 = m1[1] * m2[2] + m1[3] * m2[3];
  3050. var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  3051. var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  3052. return [m11, m12, m21, m22, dx, dy];
  3053. },
  3054. scale: function scale(out, m, v) {
  3055. out[0] = m[0] * v[0];
  3056. out[1] = m[1] * v[0];
  3057. out[2] = m[2] * v[1];
  3058. out[3] = m[3] * v[1];
  3059. out[4] = m[4];
  3060. out[5] = m[5];
  3061. return out;
  3062. },
  3063. rotate: function rotate(out, m, radian) {
  3064. var c = Math.cos(radian);
  3065. var s = Math.sin(radian);
  3066. var m11 = m[0] * c + m[2] * s;
  3067. var m12 = m[1] * c + m[3] * s;
  3068. var m21 = m[0] * -s + m[2] * c;
  3069. var m22 = m[1] * -s + m[3] * c;
  3070. out[0] = m11;
  3071. out[1] = m12;
  3072. out[2] = m21;
  3073. out[3] = m22;
  3074. out[4] = m[4];
  3075. out[5] = m[5];
  3076. return out;
  3077. },
  3078. translate: function translate(out, m, v) {
  3079. out[0] = m[0];
  3080. out[1] = m[1];
  3081. out[2] = m[2];
  3082. out[3] = m[3];
  3083. out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
  3084. out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
  3085. return out;
  3086. },
  3087. transform: function transform(m, actions) {
  3088. var out = [].concat(m);
  3089. for (var i = 0, len = actions.length; i < len; i++) {
  3090. var action = actions[i];
  3091. switch (action[0]) {
  3092. case 't':
  3093. Matrix.translate(out, out, [action[1], action[2]]);
  3094. break;
  3095. case 's':
  3096. Matrix.scale(out, out, [action[1], action[2]]);
  3097. break;
  3098. case 'r':
  3099. Matrix.rotate(out, out, action[1]);
  3100. break;
  3101. default:
  3102. break;
  3103. }
  3104. }
  3105. return out;
  3106. }
  3107. };
  3108. module.exports = Matrix;
  3109. /***/ }),
  3110. /* 24 */
  3111. /***/ (function(module, exports, __webpack_require__) {
  3112. var Util = __webpack_require__(0);
  3113. var Global = __webpack_require__(1);
  3114. var Vector2 = __webpack_require__(4);
  3115. var Abastract =
  3116. /*#__PURE__*/
  3117. function () {
  3118. var _proto = Abastract.prototype;
  3119. _proto._initDefaultCfg = function _initDefaultCfg() {
  3120. /**
  3121. * ticks
  3122. * @type {Array}
  3123. */
  3124. this.ticks = [];
  3125. /**
  3126. * the configuration for tickLine
  3127. * @type {Object}
  3128. */
  3129. this.tickLine = {};
  3130. /**
  3131. * the direction of ticks, 1 means clockwise
  3132. * @type {Number}
  3133. */
  3134. this.offsetFactor = 1;
  3135. /**
  3136. * the top container
  3137. * @type {container}
  3138. */
  3139. this.frontContainer = null;
  3140. /**
  3141. * the back container
  3142. * @type {[type]}
  3143. */
  3144. this.backContainer = null;
  3145. /**
  3146. * points for draw grid line
  3147. * @type {Array}
  3148. */
  3149. this.gridPoints = [];
  3150. };
  3151. function Abastract(cfg) {
  3152. this._initDefaultCfg();
  3153. Util.mix(this, cfg);
  3154. this.draw();
  3155. }
  3156. _proto.draw = function draw() {
  3157. var line = this.line,
  3158. tickLine = this.tickLine,
  3159. label = this.label,
  3160. grid = this.grid;
  3161. grid && this.drawGrid(grid); // draw the grid lines
  3162. tickLine && this.drawTicks(tickLine); // draw the tickLine
  3163. line && this.drawLine(line); // draw axis line
  3164. label && this.drawLabels(); // draw ticks
  3165. };
  3166. _proto.drawTicks = function drawTicks(tickCfg) {
  3167. var self = this;
  3168. var ticks = self.ticks;
  3169. var length = tickCfg.length;
  3170. var container = self.getContainer(tickCfg.top);
  3171. Util.each(ticks, function (tick) {
  3172. var start = self.getOffsetPoint(tick.value);
  3173. var end = self.getSidePoint(start, length);
  3174. var shape = container.addShape('line', {
  3175. className: 'axis-tick',
  3176. attrs: Util.mix({
  3177. x1: start.x,
  3178. y1: start.y,
  3179. x2: end.x,
  3180. y2: end.y
  3181. }, tickCfg)
  3182. });
  3183. shape._id = self._id + '-ticks';
  3184. });
  3185. };
  3186. _proto.drawLabels = function drawLabels() {
  3187. var self = this;
  3188. var labelOffset = self.labelOffset;
  3189. var labels = self.labels;
  3190. Util.each(labels, function (labelShape) {
  3191. var container = self.getContainer(labelShape.get('top'));
  3192. var start = self.getOffsetPoint(labelShape.get('value'));
  3193. var _self$getSidePoint = self.getSidePoint(start, labelOffset),
  3194. x = _self$getSidePoint.x,
  3195. y = _self$getSidePoint.y;
  3196. labelShape.attr(Util.mix({
  3197. x: x,
  3198. y: y
  3199. }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
  3200. labelShape._id = self._id + '-' + labelShape.attr('text');
  3201. container.add(labelShape);
  3202. });
  3203. };
  3204. _proto.drawLine = function drawLine() {};
  3205. _proto.drawGrid = function drawGrid(grid) {
  3206. var self = this;
  3207. var gridPoints = self.gridPoints,
  3208. ticks = self.ticks;
  3209. var gridCfg = grid;
  3210. var count = gridPoints.length;
  3211. Util.each(gridPoints, function (subPoints, index) {
  3212. if (Util.isFunction(grid)) {
  3213. var tick = ticks[index] || {};
  3214. var executedGrid = grid(tick.text, index, count);
  3215. gridCfg = executedGrid ? Util.mix({}, Global._defaultAxis.grid, executedGrid) : null;
  3216. }
  3217. if (gridCfg) {
  3218. var type = gridCfg.type; // has two types: 'line' and 'arc'
  3219. var points = subPoints.points;
  3220. var container = self.getContainer(gridCfg.top);
  3221. var shape;
  3222. if (type === 'arc') {
  3223. var center = self.center,
  3224. startAngle = self.startAngle,
  3225. endAngle = self.endAngle;
  3226. var radius = Vector2.length([points[0].x - center.x, points[0].y - center.y]);
  3227. shape = container.addShape('Arc', {
  3228. className: 'axis-grid',
  3229. attrs: Util.mix({
  3230. x: center.x,
  3231. y: center.y,
  3232. startAngle: startAngle,
  3233. endAngle: endAngle,
  3234. r: radius
  3235. }, gridCfg)
  3236. });
  3237. } else {
  3238. shape = container.addShape('Polyline', {
  3239. className: 'axis-grid',
  3240. attrs: Util.mix({
  3241. points: points
  3242. }, gridCfg)
  3243. });
  3244. }
  3245. shape._id = subPoints._id;
  3246. }
  3247. });
  3248. };
  3249. _proto.getOffsetPoint = function getOffsetPoint() {};
  3250. _proto.getAxisVector = function getAxisVector() {};
  3251. _proto.getOffsetVector = function getOffsetVector(point, offset) {
  3252. var self = this;
  3253. var axisVector = self.getAxisVector(point);
  3254. var normal = Vector2.normalize([], axisVector);
  3255. var factor = self.offsetFactor;
  3256. var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
  3257. return Vector2.scale([], verticalVector, offset);
  3258. };
  3259. _proto.getSidePoint = function getSidePoint(point, offset) {
  3260. var self = this;
  3261. var offsetVector = self.getOffsetVector(point, offset);
  3262. return {
  3263. x: point.x + offsetVector[0],
  3264. y: point.y + offsetVector[1]
  3265. };
  3266. };
  3267. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  3268. var self = this;
  3269. var offsetVector = self.getOffsetVector(point, offset);
  3270. var align;
  3271. var baseLine;
  3272. if (offsetVector[0] > 0) {
  3273. align = 'left';
  3274. } else if (offsetVector[0] < 0) {
  3275. align = 'right';
  3276. } else {
  3277. align = 'center';
  3278. }
  3279. if (offsetVector[1] > 0) {
  3280. baseLine = 'top';
  3281. } else if (offsetVector[1] < 0) {
  3282. baseLine = 'bottom';
  3283. } else {
  3284. baseLine = 'middle';
  3285. }
  3286. return {
  3287. textAlign: align,
  3288. textBaseline: baseLine
  3289. };
  3290. };
  3291. _proto.getContainer = function getContainer(isTop) {
  3292. var frontContainer = this.frontContainer,
  3293. backContainer = this.backContainer;
  3294. return isTop ? frontContainer : backContainer;
  3295. };
  3296. return Abastract;
  3297. }();
  3298. module.exports = Abastract;
  3299. /***/ }),
  3300. /* 25 */
  3301. /***/ (function(module, exports, __webpack_require__) {
  3302. var Util = __webpack_require__(0);
  3303. var MatrixUtil = __webpack_require__(23);
  3304. var Vector2 = __webpack_require__(4);
  3305. var StyleUtil = __webpack_require__(69);
  3306. function isUnchanged(m) {
  3307. return m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
  3308. }
  3309. var ALIAS_ATTRS_MAP = {
  3310. stroke: 'strokeStyle',
  3311. fill: 'fillStyle',
  3312. opacity: 'globalAlpha'
  3313. };
  3314. var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash'];
  3315. var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];
  3316. var Element =
  3317. /*#__PURE__*/
  3318. function () {
  3319. var _proto = Element.prototype;
  3320. _proto._initProperties = function _initProperties() {
  3321. this._attrs = {
  3322. zIndex: 0,
  3323. visible: true,
  3324. destroyed: false
  3325. };
  3326. };
  3327. function Element(cfg) {
  3328. this._initProperties();
  3329. Util.mix(this._attrs, cfg);
  3330. var attrs = this._attrs.attrs;
  3331. if (attrs) {
  3332. this.initAttrs(attrs);
  3333. }
  3334. this.initTransform();
  3335. }
  3336. _proto.get = function get(name) {
  3337. return this._attrs[name];
  3338. };
  3339. _proto.set = function set(name, value) {
  3340. this._attrs[name] = value;
  3341. };
  3342. _proto.isGroup = function isGroup() {
  3343. return this.get('isGroup');
  3344. };
  3345. _proto.isShape = function isShape() {
  3346. return this.get('isShape');
  3347. };
  3348. _proto.initAttrs = function initAttrs(attrs) {
  3349. this.attr(Util.mix(this.getDefaultAttrs(), attrs));
  3350. };
  3351. _proto.getDefaultAttrs = function getDefaultAttrs() {
  3352. return {};
  3353. };
  3354. _proto._setAttr = function _setAttr(name, value) {
  3355. var attrs = this._attrs.attrs;
  3356. if (name === 'clip') {
  3357. value = this._setAttrClip(value);
  3358. } else {
  3359. var alias = ALIAS_ATTRS_MAP[name];
  3360. if (alias) {
  3361. attrs[alias] = value;
  3362. }
  3363. }
  3364. attrs[name] = value;
  3365. };
  3366. _proto._getAttr = function _getAttr(name) {
  3367. return this._attrs.attrs[name];
  3368. }; // _afterAttrsSet() {}
  3369. _proto._setAttrClip = function _setAttrClip(clip) {
  3370. if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
  3371. if (clip.get('canvas') === null) {
  3372. clip = Object.assign({}, clip);
  3373. }
  3374. clip.set('parent', this.get('parent'));
  3375. clip.set('context', this.get('context'));
  3376. return clip;
  3377. }
  3378. return null;
  3379. };
  3380. _proto.attr = function attr(name, value) {
  3381. var self = this;
  3382. if (self.get('destroyed')) return null;
  3383. var argumentsLen = arguments.length;
  3384. if (argumentsLen === 0) {
  3385. return self._attrs.attrs;
  3386. }
  3387. if (Util.isObject(name)) {
  3388. this._attrs.bbox = null;
  3389. for (var k in name) {
  3390. self._setAttr(k, name[k]);
  3391. }
  3392. if (self._afterAttrsSet) {
  3393. self._afterAttrsSet();
  3394. }
  3395. return self;
  3396. }
  3397. if (argumentsLen === 2) {
  3398. this._attrs.bbox = null;
  3399. self._setAttr(name, value);
  3400. if (self._afterAttrsSet) {
  3401. self._afterAttrsSet();
  3402. }
  3403. return self;
  3404. }
  3405. return self._getAttr(name);
  3406. };
  3407. _proto.getParent = function getParent() {
  3408. return this.get('parent');
  3409. };
  3410. _proto.draw = function draw(context) {
  3411. if (this.get('destroyed')) {
  3412. return;
  3413. }
  3414. if (this.get('visible')) {
  3415. this.setContext(context);
  3416. this.drawInner(context);
  3417. this.restoreContext(context);
  3418. }
  3419. };
  3420. _proto.setContext = function setContext(context) {
  3421. var clip = this._attrs.attrs.clip;
  3422. context.save();
  3423. if (clip) {
  3424. clip.resetTransform(context);
  3425. clip.createPath(context);
  3426. context.clip();
  3427. }
  3428. this.resetContext(context);
  3429. this.resetTransform(context);
  3430. };
  3431. _proto.restoreContext = function restoreContext(context) {
  3432. context.restore();
  3433. };
  3434. _proto.resetContext = function resetContext(context) {
  3435. var elAttrs = this._attrs.attrs;
  3436. if (!this._attrs.isGroup) {
  3437. for (var k in elAttrs) {
  3438. if (SHAPE_ATTRS.indexOf(k) > -1) {
  3439. var v = elAttrs[k];
  3440. if (k === 'fillStyle' || k === 'strokeStyle') {
  3441. v = StyleUtil.parseStyle(v, this, context);
  3442. }
  3443. if (k === 'lineDash' && context.setLineDash && Util.isArray(v)) {
  3444. context.setLineDash(v);
  3445. } else {
  3446. context[k] = v;
  3447. }
  3448. }
  3449. }
  3450. }
  3451. };
  3452. _proto.hasFill = function hasFill() {
  3453. return this.get('canFill') && this._attrs.attrs.fillStyle;
  3454. };
  3455. _proto.hasStroke = function hasStroke() {
  3456. return this.get('canStroke') && this._attrs.attrs.strokeStyle;
  3457. };
  3458. _proto.drawInner = function drawInner()
  3459. /* context */
  3460. {};
  3461. _proto.show = function show() {
  3462. this.set('visible', true);
  3463. return this;
  3464. };
  3465. _proto.hide = function hide() {
  3466. this.set('visible', false);
  3467. return this;
  3468. };
  3469. _proto.isVisible = function isVisible() {
  3470. return this.get('visible');
  3471. };
  3472. _proto._removeFromParent = function _removeFromParent() {
  3473. var parent = this.get('parent');
  3474. if (parent) {
  3475. var children = parent.get('children');
  3476. Util.Array.remove(children, this);
  3477. }
  3478. return this;
  3479. };
  3480. _proto.remove = function remove(destroy) {
  3481. if (destroy) {
  3482. this.destroy();
  3483. } else {
  3484. this._removeFromParent();
  3485. }
  3486. };
  3487. _proto.destroy = function destroy() {
  3488. var destroyed = this.get('destroyed');
  3489. if (destroyed) {
  3490. return null;
  3491. }
  3492. this._removeFromParent();
  3493. this._attrs = {};
  3494. this.set('destroyed', true);
  3495. };
  3496. _proto.getBBox = function getBBox() {
  3497. return {
  3498. minX: 0,
  3499. maxX: 0,
  3500. minY: 0,
  3501. maxY: 0,
  3502. width: 0,
  3503. height: 0
  3504. };
  3505. };
  3506. _proto.initTransform = function initTransform() {
  3507. var attrs = this._attrs.attrs || {};
  3508. if (!attrs.matrix) {
  3509. attrs.matrix = [1, 0, 0, 1, 0, 0];
  3510. }
  3511. this._attrs.attrs = attrs;
  3512. };
  3513. _proto.getMatrix = function getMatrix() {
  3514. return this._attrs.attrs.matrix;
  3515. };
  3516. _proto.setMatrix = function setMatrix(m) {
  3517. this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
  3518. };
  3519. _proto.transform = function transform(actions) {
  3520. var matrix = this._attrs.attrs.matrix;
  3521. this._attrs.attrs.matrix = MatrixUtil.transform(matrix, actions);
  3522. return this;
  3523. };
  3524. _proto.setTransform = function setTransform(actions) {
  3525. this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
  3526. return this.transform(actions);
  3527. };
  3528. _proto.translate = function translate(x, y) {
  3529. var matrix = this._attrs.attrs.matrix;
  3530. MatrixUtil.translate(matrix, matrix, [x, y]);
  3531. };
  3532. _proto.rotate = function rotate(rad) {
  3533. var matrix = this._attrs.attrs.matrix;
  3534. MatrixUtil.rotate(matrix, matrix, rad);
  3535. };
  3536. _proto.scale = function scale(sx, sy) {
  3537. var matrix = this._attrs.attrs.matrix;
  3538. MatrixUtil.scale(matrix, matrix, [sx, sy]);
  3539. };
  3540. _proto.moveTo = function moveTo(x, y) {
  3541. var cx = this._attrs.x || 0;
  3542. var cy = this._attrs.y || 0;
  3543. this.translate(x - cx, y - cy);
  3544. this.set('x', x);
  3545. this.set('y', y);
  3546. };
  3547. _proto.apply = function apply(v) {
  3548. var m = this._attrs.attrs.matrix;
  3549. Vector2.transformMat2d(v, v, m);
  3550. return this;
  3551. };
  3552. _proto.resetTransform = function resetTransform(context) {
  3553. var mo = this._attrs.attrs.matrix;
  3554. if (!isUnchanged(mo)) {
  3555. context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
  3556. }
  3557. };
  3558. _proto.isDestroyed = function isDestroyed() {
  3559. return this.get('destroyed');
  3560. };
  3561. return Element;
  3562. }();
  3563. module.exports = Element;
  3564. /***/ }),
  3565. /* 26 */
  3566. /***/ (function(module, exports, __webpack_require__) {
  3567. var _require = __webpack_require__(5),
  3568. Shape = _require.Shape;
  3569. module.exports = {
  3570. getClip: function getClip(coord) {
  3571. var start = coord.start;
  3572. var end = coord.end;
  3573. var width = end.x - start.x;
  3574. var height = Math.abs(end.y - start.y);
  3575. var margin = 10;
  3576. var clip;
  3577. if (coord.isPolar) {
  3578. var circleRadius = coord.circleRadius,
  3579. center = coord.center,
  3580. startAngle = coord.startAngle,
  3581. endAngle = coord.endAngle;
  3582. clip = new Shape.Sector({
  3583. attrs: {
  3584. x: center.x,
  3585. y: center.y,
  3586. r: circleRadius,
  3587. r0: 0,
  3588. startAngle: startAngle,
  3589. endAngle: endAngle
  3590. }
  3591. });
  3592. } else {
  3593. clip = new Shape.Rect({
  3594. attrs: {
  3595. x: start.x,
  3596. y: end.y - margin,
  3597. width: width,
  3598. height: height + 2 * margin
  3599. }
  3600. });
  3601. }
  3602. clip.isClip = true;
  3603. return clip;
  3604. },
  3605. isPointInPlot: function isPointInPlot(point, plot) {
  3606. var x = point.x,
  3607. y = point.y;
  3608. var tl = plot.tl,
  3609. tr = plot.tr,
  3610. br = plot.br;
  3611. return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
  3612. }
  3613. };
  3614. /***/ }),
  3615. /* 27 */
  3616. /***/ (function(module, exports, __webpack_require__) {
  3617. var isNil = __webpack_require__(7);
  3618. function toString(value) {
  3619. if (isNil(value)) return '';
  3620. return value.toString();
  3621. }
  3622. module.exports = toString;
  3623. /***/ }),
  3624. /* 28 */
  3625. /***/ (function(module, exports, __webpack_require__) {
  3626. var isObjectLike = __webpack_require__(48);
  3627. var isType = __webpack_require__(8);
  3628. var isPlainObject = function isPlainObject(value) {
  3629. /**
  3630. * isObjectLike(new Foo) => false
  3631. * isObjectLike([1, 2, 3]) => false
  3632. * isObjectLike({ x: 0, y: 0 }) => true
  3633. * isObjectLike(Object.create(null)) => true
  3634. */
  3635. if (!isObjectLike(value) || !isType(value, 'Object')) {
  3636. return false;
  3637. }
  3638. if (Object.getPrototypeOf(value) === null) {
  3639. return true;
  3640. }
  3641. var proto = value;
  3642. while (Object.getPrototypeOf(proto) !== null) {
  3643. proto = Object.getPrototypeOf(proto);
  3644. }
  3645. return Object.getPrototypeOf(value) === proto;
  3646. };
  3647. module.exports = isPlainObject;
  3648. /***/ }),
  3649. /* 29 */
  3650. /***/ (function(module, exports, __webpack_require__) {
  3651. /**
  3652. * @fileOverview Base class of chart and geometry
  3653. * @author dxq613@gmail.com
  3654. */
  3655. var Util = __webpack_require__(0);
  3656. var Base =
  3657. /*#__PURE__*/
  3658. function () {
  3659. var _proto = Base.prototype;
  3660. _proto.getDefaultCfg = function getDefaultCfg() {
  3661. return {};
  3662. };
  3663. function Base(cfg) {
  3664. var attrs = {};
  3665. var defaultCfg = this.getDefaultCfg();
  3666. this._attrs = attrs;
  3667. Util.mix(attrs, defaultCfg, cfg);
  3668. }
  3669. _proto.get = function get(name) {
  3670. return this._attrs[name];
  3671. };
  3672. _proto.set = function set(name, value) {
  3673. this._attrs[name] = value;
  3674. };
  3675. _proto.destroy = function destroy() {
  3676. this._attrs = {};
  3677. this.destroyed = true;
  3678. };
  3679. return Base;
  3680. }();
  3681. module.exports = Base;
  3682. /***/ }),
  3683. /* 30 */
  3684. /***/ (function(module, exports, __webpack_require__) {
  3685. var Util = __webpack_require__(0);
  3686. var Shape = __webpack_require__(2);
  3687. var SHAPE_MAP = {};
  3688. var INDEX = '_INDEX';
  3689. function getComparer(compare) {
  3690. return function (left, right) {
  3691. var result = compare(left, right);
  3692. return result === 0 ? left[INDEX] - right[INDEX] : result;
  3693. };
  3694. }
  3695. module.exports = {
  3696. getGroupClass: function getGroupClass() {},
  3697. getChildren: function getChildren() {
  3698. return this.get('children');
  3699. },
  3700. addShape: function addShape(type, cfg) {
  3701. if (cfg === void 0) {
  3702. cfg = {};
  3703. }
  3704. var canvas = this.get('canvas');
  3705. var shapeType = SHAPE_MAP[type];
  3706. if (!shapeType) {
  3707. shapeType = Util.upperFirst(type);
  3708. SHAPE_MAP[type] = shapeType;
  3709. }
  3710. cfg.canvas = canvas;
  3711. if (shapeType === 'Text' && canvas && canvas.get('fontFamily')) {
  3712. cfg.attrs.fontFamily = cfg.attrs.fontFamily || canvas.get('fontFamily');
  3713. }
  3714. var shape = new Shape[shapeType](cfg);
  3715. this.add(shape);
  3716. return shape;
  3717. },
  3718. addGroup: function addGroup(cfg) {
  3719. var canvas = this.get('canvas');
  3720. var groupClass = this.getGroupClass();
  3721. cfg = Util.mix({}, cfg);
  3722. cfg.canvas = canvas;
  3723. cfg.parent = this;
  3724. var rst = new groupClass(cfg);
  3725. this.add(rst);
  3726. return rst;
  3727. },
  3728. contain: function contain(item) {
  3729. var children = this.get('children');
  3730. return children.indexOf(item) > -1;
  3731. },
  3732. sort: function sort() {
  3733. var children = this.get('children');
  3734. for (var i = 0, len = children.length; i < len; i++) {
  3735. var child = children[i];
  3736. child[INDEX] = i;
  3737. }
  3738. children.sort(getComparer(function (obj1, obj2) {
  3739. return obj1.get('zIndex') - obj2.get('zIndex');
  3740. }));
  3741. return this;
  3742. },
  3743. clear: function clear() {
  3744. var children = this.get('children');
  3745. while (children.length !== 0) {
  3746. children[children.length - 1].remove(true);
  3747. }
  3748. return this;
  3749. },
  3750. add: function add(items) {
  3751. var self = this;
  3752. var children = self.get('children');
  3753. if (!Util.isArray(items)) {
  3754. items = [items];
  3755. }
  3756. for (var i = 0, len = items.length; i < len; i++) {
  3757. var item = items[i];
  3758. var parent = item.get('parent');
  3759. if (parent) {
  3760. var descendants = parent.get('children');
  3761. Util.Array.remove(descendants, item);
  3762. }
  3763. self._setEvn(item);
  3764. children.push(item);
  3765. }
  3766. return self;
  3767. },
  3768. _setEvn: function _setEvn(item) {
  3769. var self = this;
  3770. item._attrs.parent = self;
  3771. item._attrs.context = self._attrs.context;
  3772. item._attrs.canvas = self._attrs.canvas;
  3773. var clip = item._attrs.attrs.clip;
  3774. if (clip) {
  3775. clip.set('parent', self);
  3776. clip.set('context', self.get('context'));
  3777. }
  3778. if (item._attrs.isGroup) {
  3779. var children = item._attrs.children;
  3780. for (var i = 0, len = children.length; i < len; i++) {
  3781. item._setEvn(children[i]);
  3782. }
  3783. }
  3784. }
  3785. };
  3786. /***/ }),
  3787. /* 31 */
  3788. /***/ (function(module, exports, __webpack_require__) {
  3789. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  3790. var Util = __webpack_require__(0);
  3791. var Element = __webpack_require__(25);
  3792. var Container = __webpack_require__(30);
  3793. var Vector2 = __webpack_require__(4);
  3794. var Group =
  3795. /*#__PURE__*/
  3796. function (_Element) {
  3797. _inheritsLoose(Group, _Element);
  3798. function Group() {
  3799. return _Element.apply(this, arguments) || this;
  3800. }
  3801. var _proto = Group.prototype;
  3802. _proto._initProperties = function _initProperties() {
  3803. this._attrs = {
  3804. zIndex: 0,
  3805. visible: true,
  3806. destroyed: false,
  3807. isGroup: true,
  3808. children: []
  3809. };
  3810. };
  3811. _proto.drawInner = function drawInner(context) {
  3812. var children = this.get('children');
  3813. for (var i = 0, len = children.length; i < len; i++) {
  3814. var child = children[i];
  3815. child.draw(context);
  3816. }
  3817. return this;
  3818. };
  3819. _proto.getBBox = function getBBox() {
  3820. var self = this;
  3821. var minX = Infinity;
  3822. var maxX = -Infinity;
  3823. var minY = Infinity;
  3824. var maxY = -Infinity;
  3825. var children = self.get('children');
  3826. for (var i = 0, length = children.length; i < length; i++) {
  3827. var child = children[i];
  3828. if (child.get('visible')) {
  3829. var box = child.getBBox();
  3830. if (!box) {
  3831. continue;
  3832. }
  3833. var leftTop = [box.minX, box.minY];
  3834. var leftBottom = [box.minX, box.maxY];
  3835. var rightTop = [box.maxX, box.minY];
  3836. var rightBottom = [box.maxX, box.maxY];
  3837. var matrix = child.attr('matrix');
  3838. Vector2.transformMat2d(leftTop, leftTop, matrix);
  3839. Vector2.transformMat2d(leftBottom, leftBottom, matrix);
  3840. Vector2.transformMat2d(rightTop, rightTop, matrix);
  3841. Vector2.transformMat2d(rightBottom, rightBottom, matrix);
  3842. minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
  3843. maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
  3844. minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
  3845. maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
  3846. }
  3847. }
  3848. return {
  3849. minX: minX,
  3850. minY: minY,
  3851. maxX: maxX,
  3852. maxY: maxY,
  3853. x: minX,
  3854. y: minY,
  3855. width: maxX - minX,
  3856. height: maxY - minY
  3857. };
  3858. };
  3859. _proto.destroy = function destroy() {
  3860. if (this.get('destroyed')) {
  3861. return;
  3862. }
  3863. this.clear();
  3864. _Element.prototype.destroy.call(this);
  3865. };
  3866. return Group;
  3867. }(Element);
  3868. Util.mix(Group.prototype, Container, {
  3869. getGroupClass: function getGroupClass() {
  3870. return Group;
  3871. }
  3872. });
  3873. module.exports = Group;
  3874. /***/ }),
  3875. /* 32 */
  3876. /***/ (function(module, exports, __webpack_require__) {
  3877. var Util = __webpack_require__(0);
  3878. var Shape = __webpack_require__(9);
  3879. var ShapeUtil = __webpack_require__(20);
  3880. var Global = __webpack_require__(1); // register line geom
  3881. var Line = Shape.registerFactory('line', {
  3882. defaultShapeType: 'line'
  3883. });
  3884. function getStyle(cfg) {
  3885. var style = {
  3886. strokeStyle: cfg.color
  3887. };
  3888. if (cfg.size >= 0) {
  3889. style.lineWidth = cfg.size;
  3890. }
  3891. Util.mix(style, cfg.style);
  3892. return Util.mix({}, Global.shape.line, style);
  3893. }
  3894. function drawLines(cfg, container, style, smooth) {
  3895. var points = cfg.points;
  3896. if (points.length && Util.isArray(points[0].y)) {
  3897. var topPoints = [];
  3898. var bottomPoints = [];
  3899. for (var i = 0, len = points.length; i < len; i++) {
  3900. var point = points[i];
  3901. var tmp = ShapeUtil.splitPoints(point);
  3902. bottomPoints.push(tmp[0]);
  3903. topPoints.push(tmp[1]);
  3904. }
  3905. if (cfg.isInCircle) {
  3906. topPoints.push(topPoints[0]);
  3907. bottomPoints.push(bottomPoints[0]);
  3908. }
  3909. if (cfg.isStack) {
  3910. return container.addShape('Polyline', {
  3911. className: 'line',
  3912. attrs: Util.mix({
  3913. points: topPoints,
  3914. smooth: smooth
  3915. }, style)
  3916. });
  3917. }
  3918. var topShape = container.addShape('Polyline', {
  3919. className: 'line',
  3920. attrs: Util.mix({
  3921. points: topPoints,
  3922. smooth: smooth
  3923. }, style)
  3924. });
  3925. var bottomShape = container.addShape('Polyline', {
  3926. className: 'line',
  3927. attrs: Util.mix({
  3928. points: bottomPoints,
  3929. smooth: smooth
  3930. }, style)
  3931. });
  3932. return [topShape, bottomShape];
  3933. }
  3934. if (cfg.isInCircle) {
  3935. points.push(points[0]);
  3936. }
  3937. return container.addShape('Polyline', {
  3938. className: 'line',
  3939. attrs: Util.mix({
  3940. points: points,
  3941. smooth: smooth
  3942. }, style)
  3943. });
  3944. }
  3945. var SHAPES = ['line', 'smooth', 'dash'];
  3946. Util.each(SHAPES, function (shapeType) {
  3947. Shape.registerShape('line', shapeType, {
  3948. draw: function draw(cfg, container) {
  3949. var smooth = shapeType === 'smooth';
  3950. var style = getStyle(cfg);
  3951. if (shapeType === 'dash') {
  3952. style.lineDash = Global.lineDash;
  3953. }
  3954. return drawLines(cfg, container, style, smooth);
  3955. }
  3956. });
  3957. });
  3958. module.exports = Line;
  3959. /***/ }),
  3960. /* 33 */
  3961. /***/ (function(module, exports, __webpack_require__) {
  3962. var isType = __webpack_require__(8);
  3963. var isDate = function isDate(value) {
  3964. return isType(value, 'Date');
  3965. };
  3966. module.exports = isDate;
  3967. /***/ }),
  3968. /* 34 */
  3969. /***/ (function(module, exports, __webpack_require__) {
  3970. function _inheritsLoose(subClass, superClass) {
  3971. subClass.prototype = Object.create(superClass.prototype);
  3972. subClass.prototype.constructor = subClass;
  3973. subClass.__proto__ = superClass;
  3974. }
  3975. var Base = __webpack_require__(14);
  3976. var catAuto = __webpack_require__(35);
  3977. var each = __webpack_require__(3);
  3978. var isNumber = __webpack_require__(13);
  3979. var isString = __webpack_require__(15);
  3980. var Category =
  3981. /*#__PURE__*/
  3982. function (_Base) {
  3983. _inheritsLoose(Category, _Base);
  3984. function Category() {
  3985. return _Base.apply(this, arguments) || this;
  3986. }
  3987. var _proto = Category.prototype;
  3988. _proto._initDefaultCfg = function _initDefaultCfg() {
  3989. _Base.prototype._initDefaultCfg.call(this);
  3990. this.type = 'cat';
  3991. /**
  3992. * 是否分类度量
  3993. * @type {Boolean}
  3994. */
  3995. this.isCategory = true;
  3996. this.isRounding = true; // 是否进行取整操作
  3997. };
  3998. /**
  3999. * @override
  4000. */
  4001. _proto.init = function init() {
  4002. var self = this;
  4003. var values = self.values;
  4004. var tickCount = self.tickCount;
  4005. each(values, function (v, i) {
  4006. values[i] = v.toString();
  4007. });
  4008. if (!self.ticks) {
  4009. var ticks = values;
  4010. if (tickCount) {
  4011. var temp = catAuto({
  4012. maxCount: tickCount,
  4013. data: values,
  4014. isRounding: self.isRounding
  4015. });
  4016. ticks = temp.ticks;
  4017. }
  4018. this.ticks = ticks;
  4019. }
  4020. };
  4021. /**
  4022. * @override
  4023. */
  4024. _proto.getText = function getText(value) {
  4025. if (this.values.indexOf(value) === -1 && isNumber(value)) {
  4026. value = this.values[Math.round(value)];
  4027. }
  4028. return _Base.prototype.getText.call(this, value);
  4029. };
  4030. /**
  4031. * @override
  4032. */
  4033. _proto.translate = function translate(value) {
  4034. var index = this.values.indexOf(value);
  4035. if (index === -1 && isNumber(value)) {
  4036. index = value;
  4037. } else if (index === -1) {
  4038. index = NaN;
  4039. }
  4040. return index;
  4041. };
  4042. /**
  4043. * @override
  4044. */
  4045. _proto.scale = function scale(value) {
  4046. var rangeMin = this.rangeMin();
  4047. var rangeMax = this.rangeMax();
  4048. var percent;
  4049. if (isString(value) || this.values.indexOf(value) !== -1) {
  4050. value = this.translate(value);
  4051. }
  4052. if (this.values.length > 1) {
  4053. percent = value / (this.values.length - 1);
  4054. } else {
  4055. percent = value;
  4056. }
  4057. return rangeMin + percent * (rangeMax - rangeMin);
  4058. };
  4059. /**
  4060. * @override
  4061. */
  4062. _proto.invert = function invert(value) {
  4063. if (isString(value)) {
  4064. // 如果已经是字符串
  4065. return value;
  4066. }
  4067. var min = this.rangeMin();
  4068. var max = this.rangeMax(); // 归一到 范围内
  4069. if (value < min) {
  4070. value = min;
  4071. }
  4072. if (value > max) {
  4073. value = max;
  4074. }
  4075. var percent = (value - min) / (max - min);
  4076. var index = Math.round(percent * (this.values.length - 1)) % this.values.length;
  4077. index = index || 0;
  4078. return this.values[index];
  4079. };
  4080. return Category;
  4081. }(Base);
  4082. Base.Cat = Category;
  4083. module.exports = Category;
  4084. /***/ }),
  4085. /* 35 */
  4086. /***/ (function(module, exports, __webpack_require__) {
  4087. /**
  4088. * @fileOverview 计算分类的的坐标点
  4089. * @author dxq613@gmail.com
  4090. */
  4091. var each = __webpack_require__(3);
  4092. var MAX_COUNT = 8;
  4093. var SUB_COUNT = 4; // 控制个数不能过小
  4094. function getSimpleArray(data) {
  4095. var arr = [];
  4096. each(data, function (sub) {
  4097. arr = arr.concat(sub);
  4098. });
  4099. return arr;
  4100. }
  4101. function getGreatestFactor(count, number) {
  4102. var i;
  4103. for (i = number; i > 0; i--) {
  4104. if (count % i === 0) {
  4105. break;
  4106. }
  4107. } // 如果是素数,没有可以整除的数字
  4108. if (i === 1) {
  4109. for (i = number; i > 0; i--) {
  4110. if ((count - 1) % i === 0) {
  4111. break;
  4112. }
  4113. }
  4114. }
  4115. return i;
  4116. }
  4117. module.exports = function (info) {
  4118. var rst = {};
  4119. var ticks = [];
  4120. var isRounding = info.isRounding;
  4121. var categories = getSimpleArray(info.data);
  4122. var length = categories.length;
  4123. var maxCount = info.maxCount || MAX_COUNT;
  4124. var tickCount;
  4125. if (isRounding) {
  4126. // 取整操作
  4127. tickCount = getGreatestFactor(length - 1, maxCount - 1) + 1; // 如果计算出来只有两个坐标点,则直接使用传入的 maxCount
  4128. if (tickCount === 2) {
  4129. tickCount = maxCount;
  4130. } else if (tickCount < maxCount - SUB_COUNT) {
  4131. tickCount = maxCount - SUB_COUNT;
  4132. }
  4133. } else {
  4134. tickCount = maxCount;
  4135. }
  4136. if (!isRounding && length <= tickCount + tickCount / 2) {
  4137. ticks = [].concat(categories);
  4138. } else {
  4139. var step = parseInt(length / (tickCount - 1), 10);
  4140. var groups = categories.map(function (e, i) {
  4141. return i % step === 0 ? categories.slice(i, i + step) : null;
  4142. }).filter(function (e) {
  4143. return e;
  4144. });
  4145. for (var i = 1, groupLen = groups.length; i < groupLen && (isRounding ? i * step < length - step : i < tickCount - 1); i++) {
  4146. ticks.push(groups[i][0]);
  4147. }
  4148. if (categories.length) {
  4149. ticks.unshift(categories[0]);
  4150. var last = categories[length - 1];
  4151. if (ticks.indexOf(last) === -1) {
  4152. ticks.push(last);
  4153. }
  4154. }
  4155. }
  4156. rst.categories = categories;
  4157. rst.ticks = ticks;
  4158. return rst;
  4159. };
  4160. /***/ }),
  4161. /* 36 */
  4162. /***/ (function(module, exports) {
  4163. module.exports = {
  4164. requestAnimationFrame: typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
  4165. return setTimeout(fn, 16);
  4166. }
  4167. };
  4168. /***/ }),
  4169. /* 37 */
  4170. /***/ (function(module, exports, __webpack_require__) {
  4171. /**
  4172. * @fileOverview convert the line to curve
  4173. * @author dxq613@gmail.com
  4174. */
  4175. var Vector2 = __webpack_require__(4);
  4176. function getPoint(v) {
  4177. return [v.x, v.y];
  4178. }
  4179. function smoothBezier(points, smooth, isLoop, constraint) {
  4180. var cps = [];
  4181. var prevPoint;
  4182. var nextPoint;
  4183. var hasConstraint = !!constraint;
  4184. var min;
  4185. var max;
  4186. var point;
  4187. var len;
  4188. var l;
  4189. var i;
  4190. if (hasConstraint) {
  4191. min = [Infinity, Infinity];
  4192. max = [-Infinity, -Infinity];
  4193. for (i = 0, l = points.length; i < l; i++) {
  4194. point = getPoint(points[i]);
  4195. Vector2.min(min, min, point);
  4196. Vector2.max(max, max, point);
  4197. }
  4198. Vector2.min(min, min, constraint[0]);
  4199. Vector2.max(max, max, constraint[1]);
  4200. }
  4201. for (i = 0, len = points.length; i < len; i++) {
  4202. point = getPoint(points[i]);
  4203. if (isLoop) {
  4204. prevPoint = getPoint(points[i ? i - 1 : len - 1]);
  4205. nextPoint = getPoint(points[(i + 1) % len]);
  4206. } else {
  4207. if (i === 0 || i === len - 1) {
  4208. cps.push([point[0], point[1]]);
  4209. continue;
  4210. } else {
  4211. prevPoint = getPoint(points[i - 1]);
  4212. nextPoint = getPoint(points[i + 1]);
  4213. }
  4214. }
  4215. var v = Vector2.sub([], nextPoint, prevPoint);
  4216. Vector2.scale(v, v, smooth);
  4217. var d0 = Vector2.distance(point, prevPoint);
  4218. var d1 = Vector2.distance(point, nextPoint);
  4219. var sum = d0 + d1;
  4220. if (sum !== 0) {
  4221. d0 /= sum;
  4222. d1 /= sum;
  4223. }
  4224. var v1 = Vector2.scale([], v, -d0);
  4225. var v2 = Vector2.scale([], v, d1);
  4226. var cp0 = Vector2.add([], point, v1);
  4227. var cp1 = Vector2.add([], point, v2);
  4228. if (hasConstraint) {
  4229. Vector2.max(cp0, cp0, min);
  4230. Vector2.min(cp0, cp0, max);
  4231. Vector2.max(cp1, cp1, min);
  4232. Vector2.min(cp1, cp1, max);
  4233. }
  4234. cps.push([cp0[0], cp0[1]]);
  4235. cps.push([cp1[0], cp1[1]]);
  4236. }
  4237. if (isLoop) {
  4238. cps.push(cps.shift());
  4239. }
  4240. return cps;
  4241. }
  4242. function catmullRom2bezier(pointList, z, constraint) {
  4243. var isLoop = !!z;
  4244. var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
  4245. var len = pointList.length;
  4246. var d1 = [];
  4247. var cp1;
  4248. var cp2;
  4249. var p;
  4250. for (var i = 0; i < len - 1; i++) {
  4251. cp1 = controlPointList[i * 2];
  4252. cp2 = controlPointList[i * 2 + 1];
  4253. p = pointList[i + 1];
  4254. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  4255. }
  4256. if (isLoop) {
  4257. cp1 = controlPointList[len];
  4258. cp2 = controlPointList[len + 1];
  4259. p = pointList[0];
  4260. d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
  4261. }
  4262. return d1;
  4263. }
  4264. module.exports = {
  4265. smooth: catmullRom2bezier
  4266. };
  4267. /***/ }),
  4268. /* 38 */
  4269. /***/ (function(module, exports, __webpack_require__) {
  4270. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4271. var Geom = __webpack_require__(6);
  4272. var ShapeUtil = __webpack_require__(20);
  4273. var Util = __webpack_require__(0);
  4274. __webpack_require__(32);
  4275. var Path =
  4276. /*#__PURE__*/
  4277. function (_Geom) {
  4278. _inheritsLoose(Path, _Geom);
  4279. function Path() {
  4280. return _Geom.apply(this, arguments) || this;
  4281. }
  4282. var _proto = Path.prototype;
  4283. _proto.getDefaultCfg = function getDefaultCfg() {
  4284. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  4285. cfg.type = 'path';
  4286. cfg.shapeType = 'line';
  4287. return cfg;
  4288. };
  4289. _proto.getDrawCfg = function getDrawCfg(obj) {
  4290. var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
  4291. cfg.isStack = this.hasAdjust('stack');
  4292. return cfg;
  4293. };
  4294. _proto.draw = function draw(data, shapeFactory) {
  4295. var self = this;
  4296. var container = self.get('container');
  4297. var yScale = self.getYScale();
  4298. var connectNulls = self.get('connectNulls');
  4299. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  4300. var cfg = this.getDrawCfg(data[0]);
  4301. cfg.origin = data;
  4302. Util.each(splitArray, function (subData, splitedIndex) {
  4303. cfg.splitedIndex = splitedIndex;
  4304. cfg.points = subData;
  4305. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  4306. });
  4307. };
  4308. return Path;
  4309. }(Geom);
  4310. Geom.Path = Path;
  4311. module.exports = Path;
  4312. /***/ }),
  4313. /* 39 */
  4314. /***/ (function(module, exports, __webpack_require__) {
  4315. /**
  4316. * @fileOverview Utility for calculate the with ratui in x axis
  4317. * @author sima.zhang1990@gmail.com
  4318. * @author dxq613@gmail.com
  4319. */
  4320. var Global = __webpack_require__(1);
  4321. var Util = __webpack_require__(0);
  4322. var SizeMixin = {
  4323. getDefalutSize: function getDefalutSize() {
  4324. var defaultSize = this.get('defaultSize');
  4325. if (!defaultSize) {
  4326. var coord = this.get('coord');
  4327. var xScale = this.getXScale();
  4328. var dataArray = this.get('dataArray');
  4329. var count = xScale.values.length;
  4330. var range = xScale.range;
  4331. var normalizeSize = 1 / count;
  4332. var widthRatio = 1;
  4333. if (coord && coord.isPolar) {
  4334. if (coord.transposed && count > 1) {
  4335. widthRatio = Global.widthRatio.multiplePie;
  4336. } else {
  4337. widthRatio = Global.widthRatio.rose;
  4338. }
  4339. } else {
  4340. if (xScale.isLinear) {
  4341. normalizeSize *= range[1] - range[0];
  4342. }
  4343. widthRatio = Global.widthRatio.column;
  4344. }
  4345. normalizeSize *= widthRatio;
  4346. if (this.hasAdjust('dodge')) {
  4347. normalizeSize = normalizeSize / dataArray.length;
  4348. }
  4349. defaultSize = normalizeSize;
  4350. this.set('defaultSize', defaultSize);
  4351. }
  4352. return defaultSize;
  4353. },
  4354. getDimWidth: function getDimWidth(dimName) {
  4355. var coord = this.get('coord');
  4356. var start = coord.convertPoint({
  4357. x: 0,
  4358. y: 0
  4359. });
  4360. var end = coord.convertPoint({
  4361. x: dimName === 'x' ? 1 : 0,
  4362. y: dimName === 'x' ? 0 : 1
  4363. });
  4364. var width = 0;
  4365. if (start && end) {
  4366. width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
  4367. }
  4368. return width;
  4369. },
  4370. _getWidth: function _getWidth() {
  4371. var width = this.get('_width');
  4372. if (!width) {
  4373. var coord = this.get('coord');
  4374. if (coord && coord.isPolar && !coord.transposed) {
  4375. width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
  4376. } else {
  4377. width = this.getDimWidth('x');
  4378. }
  4379. this.set('_width', width);
  4380. }
  4381. return width;
  4382. },
  4383. _toNormalizedSize: function _toNormalizedSize(size) {
  4384. var width = this._getWidth();
  4385. return size / width;
  4386. },
  4387. _toCoordSize: function _toCoordSize(normalizeSize) {
  4388. var width = this._getWidth();
  4389. return width * normalizeSize;
  4390. },
  4391. getNormalizedSize: function getNormalizedSize(obj) {
  4392. var size = this.getAttrValue('size', obj);
  4393. if (Util.isNil(size)) {
  4394. size = this.getDefalutSize();
  4395. } else {
  4396. size = this._toNormalizedSize(size);
  4397. }
  4398. return size;
  4399. },
  4400. getSize: function getSize(obj) {
  4401. var size = this.getAttrValue('size', obj);
  4402. if (Util.isNil(size)) {
  4403. var normalizeSize = this.getDefalutSize();
  4404. size = this._toCoordSize(normalizeSize);
  4405. }
  4406. return size;
  4407. }
  4408. };
  4409. module.exports = SizeMixin;
  4410. /***/ }),
  4411. /* 40 */,
  4412. /* 41 */
  4413. /***/ (function(module, exports, __webpack_require__) {
  4414. var Core = {};
  4415. var Global = __webpack_require__(1);
  4416. Core.Global = Global;
  4417. Core.version = Global.version;
  4418. Core.Chart = __webpack_require__(19);
  4419. Core.Shape = __webpack_require__(9);
  4420. Core.G = __webpack_require__(5);
  4421. Core.Util = __webpack_require__(0);
  4422. Core.track = function (enable) {
  4423. Global.trackable = enable;
  4424. };
  4425. __webpack_require__(79);
  4426. module.exports = Core;
  4427. /***/ }),
  4428. /* 42 */
  4429. /***/ (function(module, exports, __webpack_require__) {
  4430. /**
  4431. * @fileOverview default theme
  4432. * @author dxq613@gail.com
  4433. */
  4434. var Util = __webpack_require__(0);
  4435. var color1 = '#E8E8E8'; // color of axis-line and axis-grid
  4436. var color2 = '#808080'; // color of axis label
  4437. var defaultAxis = {
  4438. label: {
  4439. fill: color2,
  4440. fontSize: 10
  4441. },
  4442. line: {
  4443. stroke: color1,
  4444. lineWidth: 1
  4445. },
  4446. grid: {
  4447. type: 'line',
  4448. stroke: color1,
  4449. lineWidth: 1,
  4450. lineDash: [2]
  4451. },
  4452. tickLine: null,
  4453. labelOffset: 7.5
  4454. };
  4455. var Theme = {
  4456. fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
  4457. defaultColor: '#1890FF',
  4458. pixelRatio: 1,
  4459. padding: 'auto',
  4460. appendPadding: 15,
  4461. colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
  4462. shapes: {
  4463. line: ['line', 'dash'],
  4464. point: ['circle', 'hollowCircle']
  4465. },
  4466. sizes: [4, 10],
  4467. axis: {
  4468. common: defaultAxis,
  4469. // common axis configuration
  4470. bottom: Util.mix({}, defaultAxis, {
  4471. grid: null
  4472. }),
  4473. left: Util.mix({}, defaultAxis, {
  4474. line: null
  4475. }),
  4476. right: Util.mix({}, defaultAxis, {
  4477. line: null
  4478. }),
  4479. circle: Util.mix({}, defaultAxis, {
  4480. line: null
  4481. }),
  4482. radius: Util.mix({}, defaultAxis, {
  4483. labelOffset: 4
  4484. })
  4485. },
  4486. shape: {
  4487. line: {
  4488. lineWidth: 2,
  4489. lineJoin: 'round',
  4490. lineCap: 'round'
  4491. },
  4492. point: {
  4493. lineWidth: 0,
  4494. size: 3
  4495. },
  4496. area: {
  4497. fillOpacity: 0.1
  4498. }
  4499. },
  4500. _defaultAxis: defaultAxis
  4501. };
  4502. module.exports = Theme;
  4503. /***/ }),
  4504. /* 43 */
  4505. /***/ (function(module, exports) {
  4506. var DomUtil;
  4507. /**
  4508. * Detects support for options object argument in addEventListener.
  4509. * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
  4510. * @private
  4511. */
  4512. var supportsEventListenerOptions = function () {
  4513. var supports = false;
  4514. try {
  4515. var options = Object.defineProperty({}, 'passive', {
  4516. get: function get() {
  4517. supports = true;
  4518. }
  4519. });
  4520. window.addEventListener('e', null, options);
  4521. } catch (e) {// continue regardless of error
  4522. }
  4523. return supports;
  4524. }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
  4525. // https://github.com/chartjs/Chart.js/issues/4287
  4526. var eventListenerOptions = supportsEventListenerOptions ? {
  4527. passive: true
  4528. } : false;
  4529. function createEvent(type, chart, x, y, nativeEvent) {
  4530. return {
  4531. type: type,
  4532. chart: chart,
  4533. native: nativeEvent || null,
  4534. x: x !== undefined ? x : null,
  4535. y: y !== undefined ? y : null
  4536. };
  4537. }
  4538. function fromNativeEvent(event, chart) {
  4539. var type = event.type;
  4540. var point = {};
  4541. var touches = event.targetTouches;
  4542. if (touches && touches.length > 0) {
  4543. point.x = touches[0].clientX;
  4544. point.y = touches[0].clientY;
  4545. } else {
  4546. point.x = event.clientX;
  4547. point.y = event.clientY;
  4548. }
  4549. var canvas = chart.get('canvas');
  4550. var pos = DomUtil.getRelativePosition(point, canvas);
  4551. return createEvent(type, chart, pos.x, pos.y, event);
  4552. }
  4553. DomUtil = {
  4554. /* global wx, my, module */
  4555. isWx: typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function',
  4556. // weixin miniprogram
  4557. isMy: typeof my === 'object' && typeof my.getSystemInfoSync === 'function',
  4558. // ant miniprogram
  4559. isNode: typeof module !== 'undefined' && typeof module.exports !== 'undefined',
  4560. // in node
  4561. isBrowser: typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined',
  4562. // in browser
  4563. getPixelRatio: function getPixelRatio() {
  4564. return window && window.devicePixelRatio || 1;
  4565. },
  4566. getStyle: function getStyle(el, property) {
  4567. return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
  4568. },
  4569. getWidth: function getWidth(el) {
  4570. var width = this.getStyle(el, 'width');
  4571. if (width === 'auto') {
  4572. width = el.offsetWidth;
  4573. }
  4574. return parseFloat(width);
  4575. },
  4576. getHeight: function getHeight(el) {
  4577. var height = this.getStyle(el, 'height');
  4578. if (height === 'auto') {
  4579. height = el.offsetHeight;
  4580. }
  4581. return parseFloat(height);
  4582. },
  4583. getDomById: function getDomById(id) {
  4584. if (!id) {
  4585. return null;
  4586. }
  4587. return document.getElementById(id);
  4588. },
  4589. getRelativePosition: function getRelativePosition(point, canvas) {
  4590. var canvasDom = canvas.get('el');
  4591. var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
  4592. top = _canvasDom$getBoundin.top,
  4593. right = _canvasDom$getBoundin.right,
  4594. bottom = _canvasDom$getBoundin.bottom,
  4595. left = _canvasDom$getBoundin.left;
  4596. var paddingLeft = parseFloat(this.getStyle(canvasDom, 'padding-left'));
  4597. var paddingTop = parseFloat(this.getStyle(canvasDom, 'padding-top'));
  4598. var paddingRight = parseFloat(this.getStyle(canvasDom, 'padding-right'));
  4599. var paddingBottom = parseFloat(this.getStyle(canvasDom, 'padding-bottom'));
  4600. var width = right - left - paddingLeft - paddingRight;
  4601. var height = bottom - top - paddingTop - paddingBottom;
  4602. var pixelRatio = canvas.get('pixelRatio');
  4603. var mouseX = (point.x - left - paddingLeft) / width * canvasDom.width / pixelRatio;
  4604. var mouseY = (point.y - top - paddingTop) / height * canvasDom.height / pixelRatio;
  4605. return {
  4606. x: mouseX,
  4607. y: mouseY
  4608. };
  4609. },
  4610. addEventListener: function addEventListener(source, type, listener) {
  4611. DomUtil.isBrowser && source.addEventListener(type, listener, eventListenerOptions);
  4612. },
  4613. removeEventListener: function removeEventListener(source, type, listener) {
  4614. DomUtil.isBrowser && source.removeEventListener(type, listener, eventListenerOptions);
  4615. },
  4616. createEvent: function createEvent(event, chart) {
  4617. return fromNativeEvent(event, chart);
  4618. },
  4619. measureText: function measureText(text, font, ctx) {
  4620. if (!ctx) {
  4621. ctx = document.createElement('canvas').getContext('2d');
  4622. }
  4623. ctx.font = font || '12px sans-serif';
  4624. return ctx.measureText(text);
  4625. }
  4626. };
  4627. module.exports = DomUtil;
  4628. /***/ }),
  4629. /* 44 */
  4630. /***/ (function(module, exports, __webpack_require__) {
  4631. var toString = __webpack_require__(27);
  4632. var upperFirst = function upperFirst(value) {
  4633. var str = toString(value);
  4634. return str.charAt(0).toUpperCase() + str.substring(1);
  4635. };
  4636. module.exports = upperFirst;
  4637. /***/ }),
  4638. /* 45 */
  4639. /***/ (function(module, exports, __webpack_require__) {
  4640. var toString = __webpack_require__(27);
  4641. var lowerFirst = function lowerFirst(value) {
  4642. var str = toString(value);
  4643. return str.charAt(0).toLowerCase() + str.substring(1);
  4644. };
  4645. module.exports = lowerFirst;
  4646. /***/ }),
  4647. /* 46 */
  4648. /***/ (function(module, exports, __webpack_require__) {
  4649. /**
  4650. * 是否是布尔类型
  4651. *
  4652. * @param {Object} value 测试的值
  4653. * @return {Boolean}
  4654. */
  4655. var isType = __webpack_require__(8);
  4656. var isBoolean = function isBoolean(value) {
  4657. return isType(value, 'Boolean');
  4658. };
  4659. module.exports = isBoolean;
  4660. /***/ }),
  4661. /* 47 */
  4662. /***/ (function(module, exports, __webpack_require__) {
  4663. /**
  4664. * 是否为函数
  4665. * @param {*} fn 对象
  4666. * @return {Boolean} 是否函数
  4667. */
  4668. var isType = __webpack_require__(8);
  4669. var isFunction = function isFunction(value) {
  4670. return isType(value, 'Function');
  4671. };
  4672. module.exports = isFunction;
  4673. /***/ }),
  4674. /* 48 */
  4675. /***/ (function(module, exports) {
  4676. var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
  4677. return typeof obj;
  4678. } : function (obj) {
  4679. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  4680. };
  4681. var isObjectLike = function isObjectLike(value) {
  4682. /**
  4683. * isObjectLike({}) => true
  4684. * isObjectLike([1, 2, 3]) => true
  4685. * isObjectLike(Function) => false
  4686. * isObjectLike(null) => false
  4687. */
  4688. return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
  4689. };
  4690. module.exports = isObjectLike;
  4691. /***/ }),
  4692. /* 49 */
  4693. /***/ (function(module, exports, __webpack_require__) {
  4694. var isPlainObject = __webpack_require__(28);
  4695. var isArray = __webpack_require__(10);
  4696. var MAX_MIX_LEVEL = 5;
  4697. function _deepMix(dist, src, level, maxLevel) {
  4698. level = level || 0;
  4699. maxLevel = maxLevel || MAX_MIX_LEVEL;
  4700. for (var key in src) {
  4701. if (src.hasOwnProperty(key)) {
  4702. var value = src[key];
  4703. if (value !== null && isPlainObject(value)) {
  4704. if (!isPlainObject(dist[key])) {
  4705. dist[key] = {};
  4706. }
  4707. if (level < maxLevel) {
  4708. _deepMix(dist[key], value, level + 1, maxLevel);
  4709. } else {
  4710. dist[key] = src[key];
  4711. }
  4712. } else if (isArray(value)) {
  4713. dist[key] = [];
  4714. dist[key] = dist[key].concat(value);
  4715. } else if (value !== undefined) {
  4716. dist[key] = value;
  4717. }
  4718. }
  4719. }
  4720. }
  4721. var deepMix = function deepMix() {
  4722. var args = new Array(arguments.length);
  4723. var length = args.length;
  4724. for (var i = 0; i < length; i++) {
  4725. args[i] = arguments[i];
  4726. }
  4727. var rst = args[0];
  4728. for (var _i = 1; _i < length; _i++) {
  4729. _deepMix(rst, args[_i]);
  4730. }
  4731. return rst;
  4732. };
  4733. module.exports = deepMix;
  4734. /***/ }),
  4735. /* 50 */
  4736. /***/ (function(module, exports, __webpack_require__) {
  4737. var Util = __webpack_require__(0);
  4738. var Plot =
  4739. /*#__PURE__*/
  4740. function () {
  4741. function Plot(cfg) {
  4742. Util.mix(this, cfg);
  4743. this._init();
  4744. }
  4745. var _proto = Plot.prototype;
  4746. _proto._init = function _init() {
  4747. var self = this;
  4748. var start = self.start;
  4749. var end = self.end;
  4750. var xMin = Math.min(start.x, end.x);
  4751. var xMax = Math.max(start.x, end.x);
  4752. var yMin = Math.min(start.y, end.y);
  4753. var yMax = Math.max(start.y, end.y);
  4754. this.tl = {
  4755. x: xMin,
  4756. y: yMin
  4757. };
  4758. this.tr = {
  4759. x: xMax,
  4760. y: yMin
  4761. };
  4762. this.bl = {
  4763. x: xMin,
  4764. y: yMax
  4765. };
  4766. this.br = {
  4767. x: xMax,
  4768. y: yMax
  4769. };
  4770. this.width = xMax - xMin;
  4771. this.height = yMax - yMin;
  4772. };
  4773. /**
  4774. * reset
  4775. * @param {Object} start start point
  4776. * @param {Object} end end point
  4777. */
  4778. _proto.reset = function reset(start, end) {
  4779. this.start = start;
  4780. this.end = end;
  4781. this._init();
  4782. };
  4783. /**
  4784. * check the point is in the range of plot
  4785. * @param {Nubmer} x x value
  4786. * @param {[type]} y y value
  4787. * @return {Boolean} return the result
  4788. */
  4789. _proto.isInRange = function isInRange(x, y) {
  4790. if (Util.isObject(x)) {
  4791. y = x.y;
  4792. x = x.x;
  4793. }
  4794. var tl = this.tl;
  4795. var br = this.br;
  4796. return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
  4797. };
  4798. return Plot;
  4799. }();
  4800. module.exports = Plot;
  4801. /***/ }),
  4802. /* 51 */
  4803. /***/ (function(module, exports, __webpack_require__) {
  4804. var Coord = __webpack_require__(21);
  4805. __webpack_require__(52);
  4806. module.exports = Coord;
  4807. /***/ }),
  4808. /* 52 */
  4809. /***/ (function(module, exports, __webpack_require__) {
  4810. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  4811. var Base = __webpack_require__(21);
  4812. var Cartesian =
  4813. /*#__PURE__*/
  4814. function (_Base) {
  4815. _inheritsLoose(Cartesian, _Base);
  4816. function Cartesian() {
  4817. return _Base.apply(this, arguments) || this;
  4818. }
  4819. var _proto = Cartesian.prototype;
  4820. _proto._initDefaultCfg = function _initDefaultCfg() {
  4821. this.type = 'cartesian';
  4822. this.transposed = false;
  4823. this.isRect = true;
  4824. };
  4825. _proto.init = function init(start, end) {
  4826. this.x = {
  4827. start: start.x,
  4828. end: end.x
  4829. };
  4830. this.y = {
  4831. start: start.y,
  4832. end: end.y
  4833. };
  4834. };
  4835. _proto.convertPoint = function convertPoint(point) {
  4836. var self = this;
  4837. var transposed = self.transposed;
  4838. var xDim = transposed ? 'y' : 'x';
  4839. var yDim = transposed ? 'x' : 'y';
  4840. var x = self.x;
  4841. var y = self.y;
  4842. return {
  4843. x: x.start + (x.end - x.start) * point[xDim],
  4844. y: y.start + (y.end - y.start) * point[yDim]
  4845. };
  4846. };
  4847. _proto.invertPoint = function invertPoint(point) {
  4848. var self = this;
  4849. var transposed = self.transposed;
  4850. var xDim = transposed ? 'y' : 'x';
  4851. var yDim = transposed ? 'x' : 'y';
  4852. var x = self.x;
  4853. var y = self.y;
  4854. var rst = {};
  4855. rst[xDim] = (point.x - x.start) / (x.end - x.start);
  4856. rst[yDim] = (point.y - y.start) / (y.end - y.start);
  4857. return rst;
  4858. };
  4859. return Cartesian;
  4860. }(Base);
  4861. Base.Cartesian = Cartesian;
  4862. Base.Rect = Cartesian;
  4863. module.exports = Cartesian;
  4864. /***/ }),
  4865. /* 53 */
  4866. /***/ (function(module, exports, __webpack_require__) {
  4867. module.exports = {
  4868. Position: __webpack_require__(54),
  4869. Shape: __webpack_require__(55),
  4870. Size: __webpack_require__(56),
  4871. Color: __webpack_require__(57)
  4872. };
  4873. /***/ }),
  4874. /* 54 */
  4875. /***/ (function(module, exports, __webpack_require__) {
  4876. function _inheritsLoose(subClass, superClass) {
  4877. subClass.prototype = Object.create(superClass.prototype);
  4878. subClass.prototype.constructor = subClass;
  4879. subClass.__proto__ = superClass;
  4880. }
  4881. var isNil = __webpack_require__(7);
  4882. var isArray = __webpack_require__(10);
  4883. var each = __webpack_require__(3);
  4884. var Base = __webpack_require__(17);
  4885. var Position =
  4886. /*#__PURE__*/
  4887. function (_Base) {
  4888. _inheritsLoose(Position, _Base);
  4889. function Position(cfg) {
  4890. var _this;
  4891. _this = _Base.call(this, cfg) || this;
  4892. _this.names = ['x', 'y'];
  4893. _this.type = 'position';
  4894. return _this;
  4895. }
  4896. var _proto = Position.prototype;
  4897. _proto.mapping = function mapping(x, y) {
  4898. var scales = this.scales;
  4899. var coord = this.coord;
  4900. var scaleX = scales[0];
  4901. var scaleY = scales[1];
  4902. var rstX;
  4903. var rstY;
  4904. var obj;
  4905. if (isNil(x) || isNil(y)) {
  4906. return [];
  4907. }
  4908. if (isArray(y) && isArray(x)) {
  4909. rstX = [];
  4910. rstY = [];
  4911. for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
  4912. obj = coord.convertPoint({
  4913. x: scaleX.scale(x[i]),
  4914. y: scaleY.scale(y[j])
  4915. });
  4916. rstX.push(obj.x);
  4917. rstY.push(obj.y);
  4918. }
  4919. } else if (isArray(y)) {
  4920. x = scaleX.scale(x);
  4921. rstY = [];
  4922. each(y, function (yVal) {
  4923. yVal = scaleY.scale(yVal);
  4924. obj = coord.convertPoint({
  4925. x: x,
  4926. y: yVal
  4927. });
  4928. if (rstX && rstX !== obj.x) {
  4929. if (!isArray(rstX)) {
  4930. rstX = [rstX];
  4931. }
  4932. rstX.push(obj.x);
  4933. } else {
  4934. rstX = obj.x;
  4935. }
  4936. rstY.push(obj.y);
  4937. });
  4938. } else if (isArray(x)) {
  4939. y = scaleY.scale(y);
  4940. rstX = [];
  4941. each(x, function (xVal) {
  4942. xVal = scaleX.scale(xVal);
  4943. obj = coord.convertPoint({
  4944. x: xVal,
  4945. y: y
  4946. });
  4947. if (rstY && rstY !== obj.y) {
  4948. if (!isArray(rstY)) {
  4949. rstY = [rstY];
  4950. }
  4951. rstY.push(obj.y);
  4952. } else {
  4953. rstY = obj.y;
  4954. }
  4955. rstX.push(obj.x);
  4956. });
  4957. } else {
  4958. x = scaleX.scale(x);
  4959. y = scaleY.scale(y);
  4960. var point = coord.convertPoint({
  4961. x: x,
  4962. y: y
  4963. });
  4964. rstX = point.x;
  4965. rstY = point.y;
  4966. }
  4967. return [rstX, rstY];
  4968. };
  4969. return Position;
  4970. }(Base);
  4971. module.exports = Position;
  4972. /***/ }),
  4973. /* 55 */
  4974. /***/ (function(module, exports, __webpack_require__) {
  4975. function _inheritsLoose(subClass, superClass) {
  4976. subClass.prototype = Object.create(superClass.prototype);
  4977. subClass.prototype.constructor = subClass;
  4978. subClass.__proto__ = superClass;
  4979. }
  4980. var Base = __webpack_require__(17);
  4981. var Shape =
  4982. /*#__PURE__*/
  4983. function (_Base) {
  4984. _inheritsLoose(Shape, _Base);
  4985. function Shape(cfg) {
  4986. var _this;
  4987. _this = _Base.call(this, cfg) || this;
  4988. _this.names = ['shape'];
  4989. _this.type = 'shape';
  4990. _this.gradient = null;
  4991. return _this;
  4992. }
  4993. /**
  4994. * @override
  4995. */
  4996. var _proto = Shape.prototype;
  4997. _proto.getLinearValue = function getLinearValue(percent) {
  4998. var values = this.values;
  4999. var index = Math.round((values.length - 1) * percent);
  5000. return values[index];
  5001. };
  5002. return Shape;
  5003. }(Base);
  5004. module.exports = Shape;
  5005. /***/ }),
  5006. /* 56 */
  5007. /***/ (function(module, exports, __webpack_require__) {
  5008. function _inheritsLoose(subClass, superClass) {
  5009. subClass.prototype = Object.create(superClass.prototype);
  5010. subClass.prototype.constructor = subClass;
  5011. subClass.__proto__ = superClass;
  5012. }
  5013. var Base = __webpack_require__(17);
  5014. var Size =
  5015. /*#__PURE__*/
  5016. function (_Base) {
  5017. _inheritsLoose(Size, _Base);
  5018. function Size(cfg) {
  5019. var _this;
  5020. _this = _Base.call(this, cfg) || this;
  5021. _this.names = ['size'];
  5022. _this.type = 'size';
  5023. _this.gradient = null;
  5024. return _this;
  5025. }
  5026. return Size;
  5027. }(Base);
  5028. module.exports = Size;
  5029. /***/ }),
  5030. /* 57 */
  5031. /***/ (function(module, exports, __webpack_require__) {
  5032. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  5033. var Util = __webpack_require__(0);
  5034. var ColorUtil = __webpack_require__(58);
  5035. var Base = __webpack_require__(17);
  5036. var Color =
  5037. /*#__PURE__*/
  5038. function (_Base) {
  5039. _inheritsLoose(Color, _Base);
  5040. function Color(cfg) {
  5041. var _this;
  5042. _this = _Base.call(this, cfg) || this;
  5043. _this.names = ['color'];
  5044. _this.type = 'color';
  5045. _this.gradient = null;
  5046. if (Util.isString(_this.values)) {
  5047. _this.linear = true;
  5048. }
  5049. return _this;
  5050. }
  5051. /**
  5052. * @override
  5053. */
  5054. var _proto = Color.prototype;
  5055. _proto.getLinearValue = function getLinearValue(percent) {
  5056. var gradient = this.gradient;
  5057. if (!gradient) {
  5058. var values = this.values;
  5059. gradient = ColorUtil.gradient(values);
  5060. this.gradient = gradient;
  5061. }
  5062. return gradient(percent);
  5063. };
  5064. return Color;
  5065. }(Base);
  5066. module.exports = Color;
  5067. /***/ }),
  5068. /* 58 */
  5069. /***/ (function(module, exports, __webpack_require__) {
  5070. var Util = __webpack_require__(0); // Get the interpolation between colors
  5071. function getValue(start, end, percent, index) {
  5072. var value = start[index] + (end[index] - start[index]) * percent;
  5073. return value;
  5074. } // convert to hex
  5075. function arr2hex(arr) {
  5076. return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
  5077. }
  5078. function toRGBValue(value) {
  5079. value = Math.round(value);
  5080. value = value.toString(16);
  5081. if (value.length === 1) {
  5082. value = '0' + value;
  5083. }
  5084. return value;
  5085. }
  5086. function calColor(colors, percent) {
  5087. var steps = colors.length - 1;
  5088. var step = Math.floor(steps * percent);
  5089. var left = steps * percent - step;
  5090. var start = colors[step];
  5091. var end = step === steps ? start : colors[step + 1];
  5092. var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
  5093. return rgb;
  5094. }
  5095. function hex2arr(str) {
  5096. var arr = [];
  5097. arr.push(parseInt(str.substr(1, 2), 16));
  5098. arr.push(parseInt(str.substr(3, 2), 16));
  5099. arr.push(parseInt(str.substr(5, 2), 16));
  5100. return arr;
  5101. }
  5102. var colorCache = {
  5103. black: '#000000',
  5104. blue: '#0000ff',
  5105. grey: '#808080',
  5106. green: '#008000',
  5107. orange: '#ffa500',
  5108. pink: '#ffc0cb',
  5109. purple: '#800080',
  5110. red: '#ff0000',
  5111. white: '#ffffff',
  5112. yellow: '#ffff00'
  5113. };
  5114. var ColorUtil = {
  5115. /**
  5116. * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
  5117. * @param {String} color color value
  5118. * @return {String} Returns a hexadecimal string
  5119. */
  5120. toHex: function toHex(color) {
  5121. if (colorCache[color]) {
  5122. return colorCache[color];
  5123. }
  5124. if (color[0] === '#') {
  5125. if (color.length === 7) {
  5126. return color;
  5127. }
  5128. var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
  5129. return '#' + r + r + g + g + b + b;
  5130. }); // hex3 to hex6
  5131. colorCache[color] = hex;
  5132. return hex;
  5133. } // rgb/rgba to hex
  5134. var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
  5135. rst.shift();
  5136. rst = arr2hex(rst);
  5137. colorCache[color] = rst;
  5138. return rst;
  5139. },
  5140. hex2arr: hex2arr,
  5141. /**
  5142. * handle the gradient color
  5143. * @param {Array} colors the colors
  5144. * @return {String} return the color value
  5145. */
  5146. gradient: function gradient(colors) {
  5147. var points = [];
  5148. if (Util.isString(colors)) {
  5149. colors = colors.split('-');
  5150. }
  5151. Util.each(colors, function (color) {
  5152. if (color.indexOf('#') === -1) {
  5153. color = ColorUtil.toHex(color);
  5154. }
  5155. points.push(hex2arr(color));
  5156. });
  5157. return function (percent) {
  5158. return calColor(points, percent);
  5159. };
  5160. }
  5161. };
  5162. module.exports = ColorUtil;
  5163. /***/ }),
  5164. /* 59 */
  5165. /***/ (function(module, exports, __webpack_require__) {
  5166. var Util = __webpack_require__(0);
  5167. var Global = __webpack_require__(1);
  5168. var Scale = __webpack_require__(60);
  5169. var SCALE_TYPES_MAP = {
  5170. linear: 'Linear',
  5171. cat: 'Cat',
  5172. timeCat: 'TimeCat',
  5173. identity: 'Identity'
  5174. };
  5175. var ScaleController =
  5176. /*#__PURE__*/
  5177. function () {
  5178. function ScaleController(cfg) {
  5179. // defs 列定义
  5180. this.defs = {};
  5181. Util.mix(this, cfg);
  5182. }
  5183. var _proto = ScaleController.prototype;
  5184. _proto._getDef = function _getDef(field) {
  5185. var defs = this.defs;
  5186. var def = null;
  5187. if (Global.scales[field] || defs[field]) {
  5188. def = Util.mix({}, Global.scales[field]);
  5189. Util.each(defs[field], function (v, k) {
  5190. if (Util.isNil(v)) {
  5191. delete def[k];
  5192. } else {
  5193. def[k] = v;
  5194. }
  5195. });
  5196. }
  5197. return def;
  5198. };
  5199. _proto._getDefaultType = function _getDefaultType(field, data, def) {
  5200. if (def && def.type) {
  5201. return def.type;
  5202. }
  5203. var type = 'linear';
  5204. var value = Util.Array.firstValue(data, field);
  5205. if (Util.isArray(value)) {
  5206. value = value[0];
  5207. }
  5208. if (Util.isString(value)) {
  5209. type = 'cat';
  5210. }
  5211. return type;
  5212. };
  5213. _proto._getScaleCfg = function _getScaleCfg(type, field, data, def) {
  5214. var values;
  5215. if (def && def.values) {
  5216. values = def.values;
  5217. } else {
  5218. values = Util.Array.values(data, field);
  5219. }
  5220. var cfg = {
  5221. field: field,
  5222. values: values
  5223. };
  5224. if (type !== 'cat' && type !== 'timeCat') {
  5225. if (!def || !(def.min && def.max)) {
  5226. var _Util$Array$getRange = Util.Array.getRange(values),
  5227. min = _Util$Array$getRange.min,
  5228. max = _Util$Array$getRange.max;
  5229. cfg.min = min;
  5230. cfg.max = max;
  5231. cfg.nice = true;
  5232. }
  5233. }
  5234. if (type === 'cat' || type === 'timeCat') {
  5235. cfg.isRounding = false; // used for tickCount calculation
  5236. }
  5237. return cfg;
  5238. };
  5239. _proto.createScale = function createScale(field, data) {
  5240. var self = this;
  5241. var def = self._getDef(field);
  5242. var scale;
  5243. if (!data || !data.length) {
  5244. if (def && def.type) {
  5245. def.field = field;
  5246. scale = new Scale[SCALE_TYPES_MAP[def.type]](def);
  5247. } else {
  5248. scale = new Scale.Identity({
  5249. value: field,
  5250. field: field.toString(),
  5251. values: [field]
  5252. });
  5253. }
  5254. return scale;
  5255. }
  5256. var firstObj = data[0];
  5257. var firstValue = firstObj[field];
  5258. if (firstValue === null) {
  5259. firstValue = Util.Array.firstValue(data, field);
  5260. }
  5261. if (Util.isNumber(field) || Util.isNil(firstValue) && !def) {
  5262. scale = new Scale.Identity({
  5263. value: field,
  5264. field: field.toString(),
  5265. values: [field]
  5266. });
  5267. } else {
  5268. var type = self._getDefaultType(field, data, def);
  5269. var cfg = self._getScaleCfg(type, field, data, def);
  5270. def && Util.mix(cfg, def);
  5271. scale = new Scale[SCALE_TYPES_MAP[type]](cfg);
  5272. }
  5273. return scale;
  5274. };
  5275. return ScaleController;
  5276. }();
  5277. module.exports = ScaleController;
  5278. /***/ }),
  5279. /* 60 */
  5280. /***/ (function(module, exports, __webpack_require__) {
  5281. var Scale = __webpack_require__(14);
  5282. __webpack_require__(61);
  5283. __webpack_require__(64);
  5284. __webpack_require__(34);
  5285. module.exports = Scale;
  5286. /***/ }),
  5287. /* 61 */
  5288. /***/ (function(module, exports, __webpack_require__) {
  5289. function _inheritsLoose(subClass, superClass) {
  5290. subClass.prototype = Object.create(superClass.prototype);
  5291. subClass.prototype.constructor = subClass;
  5292. subClass.__proto__ = superClass;
  5293. }
  5294. /**
  5295. * @fileOverview The measurement of linear data scale function
  5296. * @author dxq613@gmail.com
  5297. */
  5298. var isNil = __webpack_require__(7);
  5299. var each = __webpack_require__(3);
  5300. var Base = __webpack_require__(14);
  5301. var numberAuto = __webpack_require__(62);
  5302. /**
  5303. * 线性度量
  5304. * @class Scale.Linear
  5305. */
  5306. var Linear =
  5307. /*#__PURE__*/
  5308. function (_Base) {
  5309. _inheritsLoose(Linear, _Base);
  5310. function Linear() {
  5311. return _Base.apply(this, arguments) || this;
  5312. }
  5313. var _proto = Linear.prototype;
  5314. _proto._initDefaultCfg = function _initDefaultCfg() {
  5315. _Base.prototype._initDefaultCfg.call(this);
  5316. var self = this;
  5317. self.type = 'linear';
  5318. self.isLinear = true;
  5319. /**
  5320. * 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks
  5321. * @type {Boolean}
  5322. * @default false
  5323. */
  5324. self.nice = false;
  5325. /**
  5326. * min value of the scale
  5327. * @type {Number}
  5328. * @default null
  5329. */
  5330. self.min = null;
  5331. /**
  5332. * min value limitted of the scale
  5333. * @type {Number}
  5334. * @default null
  5335. */
  5336. self.minLimit = null;
  5337. /**
  5338. * max value of the scale
  5339. * @type {Number}
  5340. * @default null
  5341. */
  5342. self.max = null;
  5343. /**
  5344. * max value limitted of the scale
  5345. * @type {Number}
  5346. * @default null
  5347. */
  5348. self.maxLimit = null;
  5349. /**
  5350. * 自动生成标记时的个数
  5351. * @type {Number}
  5352. * @default null
  5353. */
  5354. self.tickCount = null;
  5355. /**
  5356. * 坐标轴点之间的间距,指的是真实数据的差值
  5357. * @type {Number}
  5358. * @default null
  5359. */
  5360. self.tickInterval = null;
  5361. /**
  5362. * 坐标轴点之间的最小间距,指的是真实数据的差值
  5363. * @type {Number}
  5364. * @default null
  5365. */
  5366. self.minTickInterval = null;
  5367. /**
  5368. * 用于计算坐标点时逼近的数组
  5369. * @type {Array}
  5370. */
  5371. self.snapArray = null;
  5372. };
  5373. /**
  5374. * @protected
  5375. * @override
  5376. */
  5377. _proto.init = function init() {
  5378. var self = this;
  5379. if (!self.ticks) {
  5380. self.min = self.translate(self.min);
  5381. self.max = self.translate(self.max);
  5382. self.initTicks();
  5383. } else {
  5384. var ticks = self.ticks;
  5385. var firstValue = self.translate(ticks[0]);
  5386. var lastValue = self.translate(ticks[ticks.length - 1]);
  5387. if (isNil(self.min) || self.min > firstValue) {
  5388. self.min = firstValue;
  5389. }
  5390. if (isNil(self.max) || self.max < lastValue) {
  5391. self.max = lastValue;
  5392. }
  5393. }
  5394. };
  5395. /**
  5396. * 计算坐标点
  5397. * @protected
  5398. * @return {Array} 计算完成的坐标点
  5399. */
  5400. _proto.calculateTicks = function calculateTicks() {
  5401. var min = this.min,
  5402. max = this.max,
  5403. minLimit = this.minLimit,
  5404. maxLimit = this.maxLimit,
  5405. tickCount = this.tickCount,
  5406. tickInterval = this.tickInterval,
  5407. minTickInterval = this.minTickInterval,
  5408. snapArray = this.snapArray;
  5409. if (tickCount === 1) {
  5410. throw new Error('linear scale\'tickCount should not be 1');
  5411. }
  5412. if (max < min) {
  5413. throw new Error("max: " + max + " should not be less than min: " + min);
  5414. }
  5415. var tmp = numberAuto({
  5416. min: min,
  5417. max: max,
  5418. minLimit: minLimit,
  5419. maxLimit: maxLimit,
  5420. minCount: tickCount,
  5421. maxCount: tickCount,
  5422. interval: tickInterval,
  5423. minTickInterval: minTickInterval,
  5424. snapArray: snapArray
  5425. });
  5426. return tmp.ticks;
  5427. }; // 初始化ticks
  5428. _proto.initTicks = function initTicks() {
  5429. var self = this;
  5430. var calTicks = self.calculateTicks();
  5431. if (self.nice) {
  5432. // 如果需要优化显示的tick
  5433. self.ticks = calTicks;
  5434. self.min = calTicks[0];
  5435. self.max = calTicks[calTicks.length - 1];
  5436. } else {
  5437. var ticks = [];
  5438. each(calTicks, function (tick) {
  5439. if (tick >= self.min && tick <= self.max) {
  5440. ticks.push(tick);
  5441. }
  5442. }); // 如果 ticks 为空,直接输入最小值、最大值
  5443. if (!ticks.length) {
  5444. ticks.push(self.min);
  5445. ticks.push(self.max);
  5446. }
  5447. self.ticks = ticks;
  5448. }
  5449. };
  5450. /**
  5451. * @override
  5452. */
  5453. _proto.scale = function scale(value) {
  5454. if (isNil(value)) {
  5455. return NaN;
  5456. }
  5457. var max = this.max;
  5458. var min = this.min;
  5459. if (max === min) {
  5460. return 0;
  5461. }
  5462. var percent = (value - min) / (max - min);
  5463. var rangeMin = this.rangeMin();
  5464. var rangeMax = this.rangeMax();
  5465. return rangeMin + percent * (rangeMax - rangeMin);
  5466. };
  5467. /**
  5468. * @override
  5469. */
  5470. _proto.invert = function invert(value) {
  5471. var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
  5472. return this.min + percent * (this.max - this.min);
  5473. };
  5474. return Linear;
  5475. }(Base);
  5476. Base.Linear = Linear;
  5477. module.exports = Linear;
  5478. /***/ }),
  5479. /* 62 */
  5480. /***/ (function(module, exports, __webpack_require__) {
  5481. /**
  5482. * @fileOverview 自动计算数字坐标轴
  5483. * @author dxq613@gmail.com
  5484. */
  5485. var isNil = __webpack_require__(7);
  5486. var isNumber = __webpack_require__(13);
  5487. var AutoUtil = __webpack_require__(63);
  5488. var MIN_COUNT = 5;
  5489. var MAX_COUNT = 7;
  5490. var SNAP_COUNT_ARRAY = [0, 1, 1.2, 1.5, 1.6, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10];
  5491. var SNAP_ARRAY = [0, 1, 2, 4, 5, 10];
  5492. module.exports = function (info) {
  5493. var min = info.min;
  5494. var max = info.max;
  5495. var interval = info.interval;
  5496. var minTickInterval = info.minTickInterval;
  5497. var ticks = [];
  5498. var minCount = info.minCount || MIN_COUNT;
  5499. var maxCount = info.maxCount || MAX_COUNT;
  5500. var isFixedCount = minCount === maxCount; // 是否限定死了个数
  5501. var minLimit = isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值
  5502. var maxLimit = isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值
  5503. var avgCount = (minCount + maxCount) / 2;
  5504. var count = avgCount; // 用户传入的逼近数组
  5505. var snapArray = info.snapArray ? info.snapArray : isFixedCount ? SNAP_COUNT_ARRAY : SNAP_ARRAY; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分
  5506. if (min === minLimit && max === maxLimit && isFixedCount) {
  5507. interval = (max - min) / (count - 1);
  5508. }
  5509. if (isNil(min)) {
  5510. min = 0;
  5511. }
  5512. if (isNil(max)) {
  5513. max = 0;
  5514. }
  5515. if (max === min) {
  5516. if (min === 0) {
  5517. max = 1;
  5518. } else {
  5519. if (min > 0) {
  5520. min = 0;
  5521. } else {
  5522. max = 0;
  5523. }
  5524. }
  5525. if (max - min < 5 && !interval && max - min >= 1) {
  5526. interval = 1;
  5527. }
  5528. }
  5529. if (isNil(interval)) {
  5530. // 计算间距
  5531. var temp = (max - min) / (avgCount - 1);
  5532. interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil');
  5533. if (maxCount !== minCount) {
  5534. count = parseInt((max - min) / interval, 10);
  5535. if (count > maxCount) {
  5536. count = maxCount;
  5537. }
  5538. if (count < minCount) {
  5539. count = minCount;
  5540. } // 不确定tick的个数时,使得tick偏小
  5541. interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor');
  5542. }
  5543. } // interval should not be less than minTickInterval
  5544. if (isNumber(minTickInterval) && interval < minTickInterval) {
  5545. interval = minTickInterval;
  5546. }
  5547. if (info.interval || maxCount !== minCount) {
  5548. // 校正 max 和 min
  5549. max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近
  5550. min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近
  5551. count = Math.round((max - min) / interval);
  5552. min = AutoUtil.fixedBase(min, interval);
  5553. max = AutoUtil.fixedBase(max, interval);
  5554. } else {
  5555. avgCount = parseInt(avgCount, 10); // 取整
  5556. var avg = (max + min) / 2;
  5557. var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil');
  5558. var sideCount = Math.floor((avgCount - 2) / 2);
  5559. var maxTick = avgTick + sideCount * interval;
  5560. var minTick;
  5561. if (avgCount % 2 === 0) {
  5562. minTick = avgTick - sideCount * interval;
  5563. } else {
  5564. minTick = avgTick - (sideCount + 1) * interval;
  5565. }
  5566. if (maxTick < max) {
  5567. maxTick = maxTick + interval;
  5568. }
  5569. if (minTick > min) {
  5570. minTick = minTick - interval;
  5571. }
  5572. max = AutoUtil.fixedBase(maxTick, interval);
  5573. min = AutoUtil.fixedBase(minTick, interval);
  5574. }
  5575. max = Math.min(max, maxLimit);
  5576. min = Math.max(min, minLimit);
  5577. ticks.push(min);
  5578. for (var i = 1; i < count; i++) {
  5579. var tickValue = AutoUtil.fixedBase(interval * i + min, interval);
  5580. if (tickValue < max) {
  5581. ticks.push(tickValue);
  5582. }
  5583. }
  5584. if (ticks[ticks.length - 1] < max) {
  5585. ticks.push(max);
  5586. }
  5587. return {
  5588. min: min,
  5589. max: max,
  5590. interval: interval,
  5591. count: count,
  5592. ticks: ticks
  5593. };
  5594. };
  5595. /***/ }),
  5596. /* 63 */
  5597. /***/ (function(module, exports) {
  5598. /**
  5599. * @fileOverview 计算方法
  5600. * @author dxq613@gmail.com
  5601. */
  5602. // 如果小数点后面超过 10 位浮点数时进行一下处理
  5603. var DECIMAL_LENGTH = 12; // 获取系数
  5604. function getFactor(v) {
  5605. var factor = 1;
  5606. if (v === Infinity || v === -Infinity) {
  5607. throw new Error('Not support Infinity!');
  5608. }
  5609. if (v < 1) {
  5610. var count = 0;
  5611. while (v < 1) {
  5612. factor = factor / 10;
  5613. v = v * 10;
  5614. count++;
  5615. } // 浮点数计算出现问题
  5616. if (factor.toString().length > DECIMAL_LENGTH) {
  5617. factor = parseFloat(factor.toFixed(count));
  5618. }
  5619. } else {
  5620. while (v > 10) {
  5621. factor = factor * 10;
  5622. v = v / 10;
  5623. }
  5624. }
  5625. return factor;
  5626. } // 取小于当前值的
  5627. function arrayFloor(values, value) {
  5628. var length = values.length;
  5629. if (length === 0) {
  5630. return NaN;
  5631. }
  5632. var pre = values[0];
  5633. if (value < values[0]) {
  5634. return NaN;
  5635. }
  5636. if (value >= values[length - 1]) {
  5637. return values[length - 1];
  5638. }
  5639. for (var i = 1; i < values.length; i++) {
  5640. if (value < values[i]) {
  5641. break;
  5642. }
  5643. pre = values[i];
  5644. }
  5645. return pre;
  5646. } // 大于当前值的第一个
  5647. function arrayCeiling(values, value) {
  5648. var length = values.length;
  5649. if (length === 0) {
  5650. return NaN;
  5651. } // var pre = values[0];
  5652. var rst;
  5653. if (value > values[length - 1]) {
  5654. return NaN;
  5655. }
  5656. if (value < values[0]) {
  5657. return values[0];
  5658. }
  5659. for (var i = 1; i < values.length; i++) {
  5660. if (value <= values[i]) {
  5661. rst = values[i];
  5662. break;
  5663. }
  5664. }
  5665. return rst;
  5666. }
  5667. var Util = {
  5668. // 获取逼近的数值
  5669. snapFactorTo: function snapFactorTo(v, arr, snapType) {
  5670. // 假设 v = -512,isFloor = true
  5671. if (isNaN(v)) {
  5672. return NaN;
  5673. }
  5674. var factor = 1; // 计算系数
  5675. if (v !== 0) {
  5676. if (v < 0) {
  5677. factor = -1;
  5678. }
  5679. v = v * factor; // v = 512
  5680. var tmpFactor = getFactor(v);
  5681. factor = factor * tmpFactor; // factor = -100
  5682. v = v / tmpFactor; // v = 5.12
  5683. }
  5684. if (snapType === 'floor') {
  5685. v = Util.snapFloor(arr, v); // v = 5
  5686. } else if (snapType === 'ceil') {
  5687. v = Util.snapCeiling(arr, v); // v = 6
  5688. } else {
  5689. v = Util.snapTo(arr, v); // 四舍五入 5
  5690. }
  5691. var rst = v * factor; // 如果出现浮点数计算问题,需要处理一下
  5692. if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
  5693. var decimalVal = parseInt(1 / factor);
  5694. var symbol = factor > 0 ? 1 : -1;
  5695. rst = v / decimalVal * symbol;
  5696. }
  5697. return rst;
  5698. },
  5699. // 获取逼近的倍数
  5700. snapMultiple: function snapMultiple(v, base, snapType) {
  5701. var div;
  5702. if (snapType === 'ceil') {
  5703. div = Math.ceil(v / base);
  5704. } else if (snapType === 'floor') {
  5705. div = Math.floor(v / base);
  5706. } else {
  5707. div = Math.round(v / base);
  5708. }
  5709. return div * base;
  5710. },
  5711. /**
  5712. * 获取逼近的值,用于对齐数据
  5713. * @param {Array} values 数据集合
  5714. * @param {Number} value 数值
  5715. * @return {Number} 逼近的值
  5716. */
  5717. snapTo: function snapTo(values, value) {
  5718. // 这里假定values是升序排列
  5719. var floorVal = arrayFloor(values, value);
  5720. var ceilingVal = arrayCeiling(values, value);
  5721. if (isNaN(floorVal) || isNaN(ceilingVal)) {
  5722. if (values[0] >= value) {
  5723. return values[0];
  5724. }
  5725. var last = values[values.length - 1];
  5726. if (last <= value) {
  5727. return last;
  5728. }
  5729. }
  5730. if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) {
  5731. return floorVal;
  5732. }
  5733. return ceilingVal;
  5734. },
  5735. /**
  5736. * 获取逼近的最小值,用于对齐数据
  5737. * @param {Array} values 数据集合
  5738. * @param {Number} value 数值
  5739. * @return {Number} 逼近的最小值
  5740. */
  5741. snapFloor: function snapFloor(values, value) {
  5742. // 这里假定values是升序排列
  5743. return arrayFloor(values, value);
  5744. },
  5745. /**
  5746. * 获取逼近的最大值,用于对齐数据
  5747. * @param {Array} values 数据集合
  5748. * @param {Number} value 数值
  5749. * @return {Number} 逼近的最大值
  5750. */
  5751. snapCeiling: function snapCeiling(values, value) {
  5752. // 这里假定values是升序排列
  5753. return arrayCeiling(values, value);
  5754. },
  5755. fixedBase: function fixedBase(v, base) {
  5756. var str = base.toString();
  5757. var index = str.indexOf('.');
  5758. if (index === -1) {
  5759. return Math.round(v);
  5760. }
  5761. var length = str.substr(index + 1).length;
  5762. if (length > 20) {
  5763. length = 20;
  5764. }
  5765. return parseFloat(v.toFixed(length));
  5766. }
  5767. };
  5768. module.exports = Util;
  5769. /***/ }),
  5770. /* 64 */
  5771. /***/ (function(module, exports, __webpack_require__) {
  5772. function _inheritsLoose(subClass, superClass) {
  5773. subClass.prototype = Object.create(superClass.prototype);
  5774. subClass.prototype.constructor = subClass;
  5775. subClass.__proto__ = superClass;
  5776. }
  5777. var Base = __webpack_require__(14);
  5778. var isNumber = __webpack_require__(13);
  5779. var Identity =
  5780. /*#__PURE__*/
  5781. function (_Base) {
  5782. _inheritsLoose(Identity, _Base);
  5783. function Identity() {
  5784. return _Base.apply(this, arguments) || this;
  5785. }
  5786. var _proto = Identity.prototype;
  5787. _proto._initDefaultCfg = function _initDefaultCfg() {
  5788. _Base.prototype._initDefaultCfg.call(this);
  5789. this.isIdentity = true;
  5790. this.type = 'identity';
  5791. /**
  5792. * 常量值
  5793. * @type {*}
  5794. */
  5795. this.value = null;
  5796. };
  5797. /**
  5798. * @override
  5799. */
  5800. _proto.getText = function getText() {
  5801. return this.value.toString();
  5802. };
  5803. /**
  5804. * @override
  5805. */
  5806. _proto.scale = function scale(value) {
  5807. if (this.value !== value && isNumber(value)) {
  5808. return value;
  5809. }
  5810. return this.range[0];
  5811. };
  5812. /**
  5813. * @override
  5814. */
  5815. _proto.invert = function invert() {
  5816. return this.value;
  5817. };
  5818. return Identity;
  5819. }(Base);
  5820. Base.Identity = Identity;
  5821. module.exports = Identity;
  5822. /***/ }),
  5823. /* 65 */
  5824. /***/ (function(module, exports, __webpack_require__) {
  5825. var Util = __webpack_require__(0);
  5826. var Axis = __webpack_require__(66);
  5827. var Global = __webpack_require__(1);
  5828. var _require = __webpack_require__(5),
  5829. Shape = _require.Shape;
  5830. function formatTicks(ticks) {
  5831. var tmp = ticks.slice(0);
  5832. if (tmp.length > 0) {
  5833. var first = tmp[0];
  5834. var last = tmp[tmp.length - 1];
  5835. if (first.value !== 0) {
  5836. tmp.unshift({
  5837. value: 0
  5838. });
  5839. }
  5840. if (last.value !== 1) {
  5841. tmp.push({
  5842. value: 1
  5843. });
  5844. }
  5845. }
  5846. return tmp;
  5847. }
  5848. var AxisController =
  5849. /*#__PURE__*/
  5850. function () {
  5851. function AxisController(cfg) {
  5852. this.axisCfg = {};
  5853. this.frontPlot = null;
  5854. this.backPlot = null;
  5855. this.axes = {}; // store the axes's options
  5856. Util.mix(this, cfg);
  5857. }
  5858. var _proto = AxisController.prototype;
  5859. _proto._isHide = function _isHide(field) {
  5860. var axisCfg = this.axisCfg;
  5861. return !axisCfg || axisCfg[field] === false;
  5862. };
  5863. _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
  5864. var position = '';
  5865. var field = scale.field;
  5866. var axisCfg = this.axisCfg;
  5867. if (axisCfg[field] && axisCfg[field].position) {
  5868. position = axisCfg[field].position;
  5869. } else if (dimType === 'x') {
  5870. position = transposed ? 'left' : 'bottom';
  5871. } else if (dimType === 'y') {
  5872. position = index ? 'right' : 'left';
  5873. if (transposed) {
  5874. position = 'bottom';
  5875. }
  5876. }
  5877. return position;
  5878. };
  5879. _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
  5880. var start;
  5881. var end;
  5882. var factor = 1; // Mark clockwise or counterclockwise
  5883. if (dimType === 'x') {
  5884. start = {
  5885. x: 0,
  5886. y: 0
  5887. };
  5888. end = {
  5889. x: 1,
  5890. y: 0
  5891. };
  5892. } else {
  5893. if (position === 'right') {
  5894. // there will be several y axes
  5895. start = {
  5896. x: 1,
  5897. y: 0
  5898. };
  5899. end = {
  5900. x: 1,
  5901. y: 1
  5902. };
  5903. } else {
  5904. start = {
  5905. x: 0,
  5906. y: 0
  5907. };
  5908. end = {
  5909. x: 0,
  5910. y: 1
  5911. };
  5912. factor = -1;
  5913. }
  5914. }
  5915. if (coord.transposed) {
  5916. factor *= -1;
  5917. }
  5918. return {
  5919. offsetFactor: factor,
  5920. start: coord.convertPoint(start),
  5921. end: coord.convertPoint(end)
  5922. };
  5923. };
  5924. _proto._getCircleCfg = function _getCircleCfg(coord) {
  5925. return {
  5926. startAngle: coord.startAngle,
  5927. endAngle: coord.endAngle,
  5928. center: coord.center,
  5929. radius: coord.circleRadius
  5930. };
  5931. };
  5932. _proto._getRadiusCfg = function _getRadiusCfg(coord) {
  5933. var transposed = coord.transposed;
  5934. var start;
  5935. var end;
  5936. if (transposed) {
  5937. start = {
  5938. x: 0,
  5939. y: 0
  5940. };
  5941. end = {
  5942. x: 1,
  5943. y: 0
  5944. };
  5945. } else {
  5946. start = {
  5947. x: 0,
  5948. y: 0
  5949. };
  5950. end = {
  5951. x: 0,
  5952. y: 1
  5953. };
  5954. }
  5955. return {
  5956. offsetFactor: -1,
  5957. start: coord.convertPoint(start),
  5958. end: coord.convertPoint(end)
  5959. };
  5960. };
  5961. _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
  5962. var self = this;
  5963. var axisCfg = this.axisCfg;
  5964. var ticks = scale.getTicks();
  5965. var cfg = Util.deepMix({
  5966. ticks: ticks,
  5967. frontContainer: this.frontPlot,
  5968. backContainer: this.backPlot
  5969. }, defaultCfg, axisCfg[scale.field]);
  5970. var labels = [];
  5971. var label = cfg.label;
  5972. var count = ticks.length;
  5973. var maxWidth = 0;
  5974. var maxHeight = 0;
  5975. var labelCfg = label;
  5976. Util.each(ticks, function (tick, index) {
  5977. if (Util.isFunction(label)) {
  5978. var executedLabel = label(tick.text, index, count);
  5979. labelCfg = executedLabel ? Util.mix({}, Global._defaultAxis.label, executedLabel) : null;
  5980. }
  5981. if (labelCfg) {
  5982. var textStyle = {};
  5983. if (labelCfg.textAlign) {
  5984. textStyle.textAlign = labelCfg.textAlign;
  5985. }
  5986. if (labelCfg.textBaseline) {
  5987. textStyle.textBaseline = labelCfg.textBaseline;
  5988. }
  5989. var axisLabel = new Shape.Text({
  5990. className: 'axis-label',
  5991. attrs: Util.mix({
  5992. x: 0,
  5993. y: 0,
  5994. text: tick.text,
  5995. fontFamily: self.chart.get('canvas').get('fontFamily')
  5996. }, labelCfg),
  5997. value: tick.value,
  5998. textStyle: textStyle,
  5999. top: labelCfg.top,
  6000. context: self.chart.get('canvas').get('context')
  6001. });
  6002. labels.push(axisLabel);
  6003. var _axisLabel$getBBox = axisLabel.getBBox(),
  6004. width = _axisLabel$getBBox.width,
  6005. height = _axisLabel$getBBox.height;
  6006. maxWidth = Math.max(maxWidth, width);
  6007. maxHeight = Math.max(maxHeight, height);
  6008. }
  6009. });
  6010. cfg.labels = labels;
  6011. cfg.maxWidth = maxWidth;
  6012. cfg.maxHeight = maxHeight;
  6013. return cfg;
  6014. };
  6015. _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
  6016. if (index === void 0) {
  6017. index = '';
  6018. }
  6019. var self = this;
  6020. var coordType = coord.type;
  6021. var transposed = coord.transposed;
  6022. var type;
  6023. var key;
  6024. var defaultCfg;
  6025. if (coordType === 'cartesian' || coordType === 'rect') {
  6026. var position = self._getLinePosition(scale, dimType, index, transposed);
  6027. defaultCfg = Global.axis[position];
  6028. defaultCfg.position = position;
  6029. type = 'Line';
  6030. key = position;
  6031. } else {
  6032. if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
  6033. defaultCfg = Global.axis.circle;
  6034. type = 'Circle';
  6035. key = 'circle';
  6036. } else {
  6037. defaultCfg = Global.axis.radius;
  6038. type = 'Line';
  6039. key = 'radius';
  6040. }
  6041. }
  6042. var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);
  6043. cfg.type = type;
  6044. cfg.dimType = dimType;
  6045. cfg.verticalScale = verticalScale;
  6046. cfg.index = index;
  6047. this.axes[key] = cfg;
  6048. };
  6049. _proto.createAxis = function createAxis(coord, xScale, yScales) {
  6050. var self = this;
  6051. if (xScale && !self._isHide(xScale.field)) {
  6052. self._createAxis(coord, xScale, yScales[0], 'x');
  6053. }
  6054. Util.each(yScales, function (yScale, index) {
  6055. if (!self._isHide(yScale.field)) {
  6056. self._createAxis(coord, yScale, xScale, 'y', index);
  6057. }
  6058. });
  6059. var axes = this.axes;
  6060. var chart = self.chart;
  6061. if (chart._isAutoPadding()) {
  6062. var userPadding = Util.parsePadding(chart.get('padding'));
  6063. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  6064. var legendRange = chart.get('legendRange') || {
  6065. top: 0,
  6066. right: 0,
  6067. bottom: 0,
  6068. left: 0
  6069. };
  6070. 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]];
  6071. if (coord.isPolar) {
  6072. var circleAxis = axes.circle;
  6073. if (circleAxis) {
  6074. var maxHeight = circleAxis.maxHeight,
  6075. maxWidth = circleAxis.maxWidth,
  6076. labelOffset = circleAxis.labelOffset;
  6077. padding[0] += maxHeight + labelOffset;
  6078. padding[1] += maxWidth + labelOffset;
  6079. padding[2] += maxHeight + labelOffset;
  6080. padding[3] += maxWidth + labelOffset;
  6081. }
  6082. } else {
  6083. if (axes.right && userPadding[1] === 'auto') {
  6084. var _axes$right = axes.right,
  6085. _maxWidth = _axes$right.maxWidth,
  6086. _labelOffset = _axes$right.labelOffset;
  6087. padding[1] += _maxWidth + _labelOffset;
  6088. }
  6089. if (axes.left && userPadding[3] === 'auto') {
  6090. var _axes$left = axes.left,
  6091. _maxWidth2 = _axes$left.maxWidth,
  6092. _labelOffset2 = _axes$left.labelOffset;
  6093. padding[3] += _maxWidth2 + _labelOffset2;
  6094. }
  6095. if (axes.bottom && userPadding[2] === 'auto') {
  6096. var _axes$bottom = axes.bottom,
  6097. _maxHeight = _axes$bottom.maxHeight,
  6098. _labelOffset3 = _axes$bottom.labelOffset;
  6099. padding[2] += _maxHeight + _labelOffset3;
  6100. }
  6101. }
  6102. chart.set('_padding', padding);
  6103. chart._updateLayout(padding);
  6104. }
  6105. Util.each(axes, function (axis) {
  6106. var type = axis.type,
  6107. grid = axis.grid,
  6108. verticalScale = axis.verticalScale,
  6109. ticks = axis.ticks,
  6110. dimType = axis.dimType,
  6111. position = axis.position,
  6112. index = axis.index;
  6113. var appendCfg;
  6114. if (coord.isPolar) {
  6115. if (type === 'Line') {
  6116. appendCfg = self._getRadiusCfg(coord);
  6117. } else if (type === 'Circle') {
  6118. appendCfg = self._getCircleCfg(coord);
  6119. }
  6120. } else {
  6121. appendCfg = self._getLineCfg(coord, dimType, position);
  6122. }
  6123. if (grid && verticalScale) {
  6124. var gridPoints = [];
  6125. var verticalTicks = formatTicks(verticalScale.getTicks());
  6126. Util.each(ticks, function (tick) {
  6127. var subPoints = [];
  6128. Util.each(verticalTicks, function (verticalTick) {
  6129. var x = dimType === 'x' ? tick.value : verticalTick.value;
  6130. var y = dimType === 'x' ? verticalTick.value : tick.value;
  6131. if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
  6132. var point = coord.convertPoint({
  6133. x: x,
  6134. y: y
  6135. });
  6136. subPoints.push(point);
  6137. }
  6138. });
  6139. gridPoints.push({
  6140. points: subPoints,
  6141. _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
  6142. });
  6143. });
  6144. axis.gridPoints = gridPoints;
  6145. if (coord.isPolar) {
  6146. axis.center = coord.center;
  6147. axis.startAngle = coord.startAngle;
  6148. axis.endAngle = coord.endAngle;
  6149. }
  6150. }
  6151. appendCfg._id = 'axis-' + dimType;
  6152. if (!Util.isNil(index)) {
  6153. appendCfg._id = 'axis-' + dimType + index;
  6154. }
  6155. new Axis[type](Util.mix(axis, appendCfg));
  6156. });
  6157. };
  6158. _proto.clear = function clear() {
  6159. this.axes = {};
  6160. this.frontPlot.clear();
  6161. this.backPlot.clear();
  6162. };
  6163. return AxisController;
  6164. }();
  6165. module.exports = AxisController;
  6166. /***/ }),
  6167. /* 66 */
  6168. /***/ (function(module, exports, __webpack_require__) {
  6169. var Abstract = __webpack_require__(24);
  6170. __webpack_require__(67);
  6171. module.exports = Abstract;
  6172. /***/ }),
  6173. /* 67 */
  6174. /***/ (function(module, exports, __webpack_require__) {
  6175. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6176. var Util = __webpack_require__(0);
  6177. var Abstract = __webpack_require__(24);
  6178. var Line =
  6179. /*#__PURE__*/
  6180. function (_Abstract) {
  6181. _inheritsLoose(Line, _Abstract);
  6182. function Line() {
  6183. return _Abstract.apply(this, arguments) || this;
  6184. }
  6185. var _proto = Line.prototype;
  6186. _proto._initDefaultCfg = function _initDefaultCfg() {
  6187. _Abstract.prototype._initDefaultCfg.call(this);
  6188. this.start = null;
  6189. this.end = null;
  6190. };
  6191. _proto.getOffsetPoint = function getOffsetPoint(value) {
  6192. var start = this.start,
  6193. end = this.end;
  6194. return {
  6195. x: start.x + (end.x - start.x) * value,
  6196. y: start.y + (end.y - start.y) * value
  6197. };
  6198. };
  6199. _proto.getAxisVector = function getAxisVector() {
  6200. var start = this.start,
  6201. end = this.end;
  6202. return [end.x - start.x, end.y - start.y];
  6203. };
  6204. _proto.drawLine = function drawLine(lineCfg) {
  6205. var container = this.getContainer(lineCfg.top);
  6206. var start = this.start,
  6207. end = this.end;
  6208. container.addShape('line', {
  6209. className: 'axis-line',
  6210. attrs: Util.mix({
  6211. x1: start.x,
  6212. y1: start.y,
  6213. x2: end.x,
  6214. y2: end.y
  6215. }, lineCfg)
  6216. });
  6217. };
  6218. return Line;
  6219. }(Abstract);
  6220. Abstract.Line = Line;
  6221. module.exports = Line;
  6222. /***/ }),
  6223. /* 68 */
  6224. /***/ (function(module, exports, __webpack_require__) {
  6225. var Util = __webpack_require__(0);
  6226. var Container = __webpack_require__(30);
  6227. var Group = __webpack_require__(31);
  6228. var _require = __webpack_require__(36),
  6229. requestAnimationFrame = _require.requestAnimationFrame;
  6230. var Canvas =
  6231. /*#__PURE__*/
  6232. function () {
  6233. var _proto = Canvas.prototype;
  6234. _proto.get = function get(name) {
  6235. return this._attrs[name];
  6236. };
  6237. _proto.set = function set(name, value) {
  6238. this._attrs[name] = value;
  6239. };
  6240. function Canvas(cfg) {
  6241. this._attrs = Util.mix({
  6242. type: 'canvas',
  6243. children: []
  6244. }, cfg);
  6245. this._initPixelRatio();
  6246. this._initCanvas();
  6247. }
  6248. _proto._initPixelRatio = function _initPixelRatio() {
  6249. var pixelRatio = this.get('pixelRatio');
  6250. if (!pixelRatio) {
  6251. this.set('pixelRatio', Util.getPixelRatio());
  6252. }
  6253. };
  6254. _proto.beforeDraw = function beforeDraw() {
  6255. var context = this._attrs.context;
  6256. var el = this._attrs.el;
  6257. !Util.isWx && !Util.isMy && context && context.clearRect(0, 0, el.width, el.height);
  6258. };
  6259. _proto._initCanvas = function _initCanvas() {
  6260. var self = this;
  6261. var el = self.get('el');
  6262. var context = self.get('context');
  6263. var canvas;
  6264. if (context) {
  6265. // CanvasRenderingContext2D
  6266. canvas = context.canvas;
  6267. } else if (Util.isString(el)) {
  6268. // HTMLElement's id
  6269. canvas = Util.getDomById(el);
  6270. } else {
  6271. // HTMLElement
  6272. canvas = el;
  6273. }
  6274. if (!canvas) {
  6275. throw new Error('Please specify the id or el of the chart!');
  6276. }
  6277. if (context && canvas && !canvas.getContext) {
  6278. canvas.getContext = function () {
  6279. return context;
  6280. };
  6281. }
  6282. var width = self.get('width');
  6283. if (!width) {
  6284. width = Util.getWidth(canvas);
  6285. }
  6286. var height = self.get('height');
  6287. if (!height) {
  6288. height = Util.getHeight(canvas);
  6289. }
  6290. self.set('canvas', this);
  6291. self.set('el', canvas);
  6292. self.set('context', context || canvas.getContext('2d'));
  6293. self.changeSize(width, height);
  6294. };
  6295. _proto.changeSize = function changeSize(width, height) {
  6296. var pixelRatio = this.get('pixelRatio');
  6297. var canvasDOM = this.get('el');
  6298. if (Util.isBrowser) {
  6299. canvasDOM.style.width = width + 'px';
  6300. canvasDOM.style.height = height + 'px';
  6301. }
  6302. if (!Util.isWx && !Util.isMy) {
  6303. canvasDOM.width = width * pixelRatio;
  6304. canvasDOM.height = height * pixelRatio;
  6305. if (pixelRatio !== 1) {
  6306. var ctx = this.get('context');
  6307. ctx.scale(pixelRatio, pixelRatio);
  6308. }
  6309. }
  6310. this.set('width', width);
  6311. this.set('height', height);
  6312. };
  6313. _proto.getWidth = function getWidth() {
  6314. var pixelRatio = this.get('pixelRatio');
  6315. var width = this.get('width');
  6316. return width * pixelRatio;
  6317. };
  6318. _proto.getHeight = function getHeight() {
  6319. var pixelRatio = this.get('pixelRatio');
  6320. var height = this.get('height');
  6321. return height * pixelRatio;
  6322. };
  6323. _proto.getPointByClient = function getPointByClient(clientX, clientY) {
  6324. var el = this.get('el');
  6325. var bbox = el.getBoundingClientRect();
  6326. var width = bbox.right - bbox.left;
  6327. var height = bbox.bottom - bbox.top;
  6328. return {
  6329. x: (clientX - bbox.left) * (el.width / width),
  6330. y: (clientY - bbox.top) * (el.height / height)
  6331. };
  6332. };
  6333. _proto._beginDraw = function _beginDraw() {
  6334. this._attrs.toDraw = true;
  6335. };
  6336. _proto._endDraw = function _endDraw() {
  6337. this._attrs.toDraw = false;
  6338. };
  6339. _proto.draw = function draw() {
  6340. var self = this;
  6341. function drawInner() {
  6342. self.set('animateHandler', requestAnimationFrame(function () {
  6343. self.set('animateHandler', undefined);
  6344. if (self.get('toDraw')) {
  6345. drawInner();
  6346. }
  6347. }));
  6348. self.beforeDraw();
  6349. try {
  6350. var context = self._attrs.context;
  6351. var children = self._attrs.children;
  6352. for (var i = 0, len = children.length; i < len; i++) {
  6353. var child = children[i];
  6354. child.draw(context);
  6355. }
  6356. if (Util.isWx || Util.isMy) {
  6357. context.draw();
  6358. }
  6359. } catch (ev) {
  6360. console.warn('error in draw canvas, detail as:');
  6361. console.warn(ev);
  6362. self._endDraw();
  6363. }
  6364. self._endDraw();
  6365. }
  6366. if (self.get('destroyed')) {
  6367. return;
  6368. }
  6369. if (self.get('animateHandler')) {
  6370. this._beginDraw();
  6371. } else {
  6372. drawInner();
  6373. }
  6374. };
  6375. _proto.destroy = function destroy() {
  6376. if (this.get('destroyed')) {
  6377. return;
  6378. }
  6379. this.clear();
  6380. this._attrs = {};
  6381. this.set('destroyed', true);
  6382. };
  6383. _proto.isDestroyed = function isDestroyed() {
  6384. return this.get('destroyed');
  6385. };
  6386. return Canvas;
  6387. }();
  6388. Util.mix(Canvas.prototype, Container, {
  6389. getGroupClass: function getGroupClass() {
  6390. return Group;
  6391. }
  6392. });
  6393. module.exports = Canvas;
  6394. /***/ }),
  6395. /* 69 */
  6396. /***/ (function(module, exports, __webpack_require__) {
  6397. var Util = __webpack_require__(0);
  6398. function _mod(n, m) {
  6399. return (n % m + m) % m;
  6400. }
  6401. function _addStop(steps, gradient) {
  6402. Util.each(steps, function (item) {
  6403. item = item.split(':');
  6404. gradient.addColorStop(Number(item[0]), item[1]);
  6405. });
  6406. } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'
  6407. function _parseLineGradient(color, shape, context) {
  6408. var arr = color.split(' ');
  6409. var angle = arr[0].slice(2, arr[0].length - 1);
  6410. angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
  6411. var steps = arr.slice(1);
  6412. var _shape$getBBox = shape.getBBox(),
  6413. minX = _shape$getBBox.minX,
  6414. minY = _shape$getBBox.minY,
  6415. maxX = _shape$getBBox.maxX,
  6416. maxY = _shape$getBBox.maxY;
  6417. var start;
  6418. var end;
  6419. if (angle >= 0 && angle < 0.5 * Math.PI) {
  6420. start = {
  6421. x: minX,
  6422. y: minY
  6423. };
  6424. end = {
  6425. x: maxX,
  6426. y: maxY
  6427. };
  6428. } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
  6429. start = {
  6430. x: maxX,
  6431. y: minY
  6432. };
  6433. end = {
  6434. x: minX,
  6435. y: maxY
  6436. };
  6437. } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
  6438. start = {
  6439. x: maxX,
  6440. y: maxY
  6441. };
  6442. end = {
  6443. x: minX,
  6444. y: minY
  6445. };
  6446. } else {
  6447. start = {
  6448. x: minX,
  6449. y: maxY
  6450. };
  6451. end = {
  6452. x: maxX,
  6453. y: minY
  6454. };
  6455. }
  6456. var tanTheta = Math.tan(angle);
  6457. var tanTheta2 = tanTheta * tanTheta;
  6458. var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
  6459. var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
  6460. var gradient = context.createLinearGradient(start.x, start.y, x, y);
  6461. _addStop(steps, gradient);
  6462. return gradient;
  6463. } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'
  6464. function _parseRadialGradient(color, shape, context) {
  6465. var arr = color.split(' ');
  6466. var circleCfg = arr[0].slice(2, arr[0].length - 1);
  6467. circleCfg = circleCfg.split(',');
  6468. var fx = parseFloat(circleCfg[0]);
  6469. var fy = parseFloat(circleCfg[1]);
  6470. var fr = parseFloat(circleCfg[2]);
  6471. var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color
  6472. if (fr === 0) {
  6473. var _color = steps[steps.length - 1];
  6474. return _color.split(':')[1];
  6475. }
  6476. var _shape$getBBox2 = shape.getBBox(),
  6477. width = _shape$getBBox2.width,
  6478. height = _shape$getBBox2.height,
  6479. minX = _shape$getBBox2.minX,
  6480. minY = _shape$getBBox2.minY;
  6481. var r = Math.sqrt(width * width + height * height) / 2;
  6482. var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);
  6483. _addStop(steps, gradient);
  6484. return gradient;
  6485. }
  6486. module.exports = {
  6487. parseStyle: function parseStyle(color, shape, context) {
  6488. if (color[1] === '(') {
  6489. try {
  6490. var firstCode = color[0];
  6491. if (firstCode === 'l') {
  6492. return _parseLineGradient(color, shape, context);
  6493. } else if (firstCode === 'r') {
  6494. return _parseRadialGradient(color, shape, context);
  6495. }
  6496. } catch (ev) {
  6497. console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
  6498. console.error(ev);
  6499. }
  6500. }
  6501. return color;
  6502. }
  6503. };
  6504. /***/ }),
  6505. /* 70 */
  6506. /***/ (function(module, exports, __webpack_require__) {
  6507. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6508. var Util = __webpack_require__(0);
  6509. var Shape = __webpack_require__(2);
  6510. var Rect =
  6511. /*#__PURE__*/
  6512. function (_Shape) {
  6513. _inheritsLoose(Rect, _Shape);
  6514. function Rect() {
  6515. return _Shape.apply(this, arguments) || this;
  6516. }
  6517. var _proto = Rect.prototype;
  6518. _proto._initProperties = function _initProperties() {
  6519. _Shape.prototype._initProperties.call(this);
  6520. this._attrs.canFill = true;
  6521. this._attrs.canStroke = true;
  6522. this._attrs.type = 'rect';
  6523. };
  6524. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6525. return {
  6526. x: 0,
  6527. y: 0,
  6528. width: 0,
  6529. height: 0,
  6530. radius: 0,
  6531. lineWidth: 0
  6532. };
  6533. };
  6534. _proto.createPath = function createPath(context) {
  6535. var self = this;
  6536. var attrs = self.get('attrs');
  6537. var x = attrs.x,
  6538. y = attrs.y,
  6539. width = attrs.width,
  6540. height = attrs.height;
  6541. context.beginPath();
  6542. var radius = attrs.radius;
  6543. if (!radius || !(width * height)) {
  6544. context.rect(x, y, width, height);
  6545. } else {
  6546. radius = Util.parsePadding(radius);
  6547. context.moveTo(x + radius[0], y);
  6548. context.lineTo(x + width - radius[1], y);
  6549. context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
  6550. context.lineTo(x + width, y + height - radius[2]);
  6551. context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
  6552. context.lineTo(x + radius[3], y + height);
  6553. context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
  6554. context.lineTo(x, y + radius[0]);
  6555. context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
  6556. context.closePath();
  6557. }
  6558. };
  6559. _proto.calculateBox = function calculateBox() {
  6560. var attrs = this.get('attrs');
  6561. var x = attrs.x,
  6562. y = attrs.y,
  6563. width = attrs.width,
  6564. height = attrs.height;
  6565. return {
  6566. minX: x,
  6567. minY: y,
  6568. maxX: x + width,
  6569. maxY: y + height
  6570. };
  6571. };
  6572. return Rect;
  6573. }(Shape);
  6574. Shape.Rect = Rect;
  6575. module.exports = Rect;
  6576. /***/ }),
  6577. /* 71 */
  6578. /***/ (function(module, exports, __webpack_require__) {
  6579. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6580. var Shape = __webpack_require__(2);
  6581. var Circle =
  6582. /*#__PURE__*/
  6583. function (_Shape) {
  6584. _inheritsLoose(Circle, _Shape);
  6585. function Circle() {
  6586. return _Shape.apply(this, arguments) || this;
  6587. }
  6588. var _proto = Circle.prototype;
  6589. _proto._initProperties = function _initProperties() {
  6590. _Shape.prototype._initProperties.call(this);
  6591. this._attrs.canFill = true;
  6592. this._attrs.canStroke = true;
  6593. this._attrs.type = 'circle';
  6594. };
  6595. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6596. return {
  6597. x: 0,
  6598. y: 0,
  6599. r: 0,
  6600. lineWidth: 0
  6601. };
  6602. };
  6603. _proto.createPath = function createPath(context) {
  6604. var attrs = this.get('attrs');
  6605. var x = attrs.x,
  6606. y = attrs.y,
  6607. r = attrs.r;
  6608. context.beginPath();
  6609. context.arc(x, y, r, 0, Math.PI * 2, false);
  6610. context.closePath();
  6611. };
  6612. _proto.calculateBox = function calculateBox() {
  6613. var attrs = this.get('attrs');
  6614. var x = attrs.x,
  6615. y = attrs.y,
  6616. r = attrs.r;
  6617. return {
  6618. minX: x - r,
  6619. maxX: x + r,
  6620. minY: y - r,
  6621. maxY: y + r
  6622. };
  6623. };
  6624. return Circle;
  6625. }(Shape);
  6626. Shape.Circle = Circle;
  6627. module.exports = Circle;
  6628. /***/ }),
  6629. /* 72 */
  6630. /***/ (function(module, exports, __webpack_require__) {
  6631. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6632. var Shape = __webpack_require__(2);
  6633. var bbox = __webpack_require__(11);
  6634. var Line =
  6635. /*#__PURE__*/
  6636. function (_Shape) {
  6637. _inheritsLoose(Line, _Shape);
  6638. function Line() {
  6639. return _Shape.apply(this, arguments) || this;
  6640. }
  6641. var _proto = Line.prototype;
  6642. _proto._initProperties = function _initProperties() {
  6643. _Shape.prototype._initProperties.call(this);
  6644. this._attrs.canStroke = true;
  6645. this._attrs.type = 'line';
  6646. };
  6647. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6648. return {
  6649. x1: 0,
  6650. y1: 0,
  6651. x2: 0,
  6652. y2: 0,
  6653. lineWidth: 1
  6654. };
  6655. };
  6656. _proto.createPath = function createPath(context) {
  6657. var attrs = this.get('attrs');
  6658. var x1 = attrs.x1,
  6659. y1 = attrs.y1,
  6660. x2 = attrs.x2,
  6661. y2 = attrs.y2;
  6662. context.beginPath();
  6663. context.moveTo(x1, y1);
  6664. context.lineTo(x2, y2);
  6665. };
  6666. _proto.calculateBox = function calculateBox() {
  6667. var attrs = this.get('attrs');
  6668. var x1 = attrs.x1,
  6669. y1 = attrs.y1,
  6670. x2 = attrs.x2,
  6671. y2 = attrs.y2,
  6672. lineWidth = attrs.lineWidth;
  6673. return bbox.getBBoxFromLine(x1, y1, x2, y2, lineWidth);
  6674. };
  6675. return Line;
  6676. }(Shape);
  6677. Shape.Line = Line;
  6678. module.exports = Line;
  6679. /***/ }),
  6680. /* 73 */
  6681. /***/ (function(module, exports, __webpack_require__) {
  6682. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6683. var Shape = __webpack_require__(2);
  6684. var bbox = __webpack_require__(11);
  6685. var Polygon =
  6686. /*#__PURE__*/
  6687. function (_Shape) {
  6688. _inheritsLoose(Polygon, _Shape);
  6689. function Polygon() {
  6690. return _Shape.apply(this, arguments) || this;
  6691. }
  6692. var _proto = Polygon.prototype;
  6693. _proto._initProperties = function _initProperties() {
  6694. _Shape.prototype._initProperties.call(this);
  6695. this._attrs.canFill = true;
  6696. this._attrs.canStroke = true;
  6697. this._attrs.type = 'polygon';
  6698. };
  6699. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6700. return {
  6701. points: null,
  6702. lineWidth: 0
  6703. };
  6704. };
  6705. _proto.createPath = function createPath(context) {
  6706. var self = this;
  6707. var attrs = self.get('attrs');
  6708. var points = attrs.points;
  6709. context.beginPath();
  6710. for (var i = 0, len = points.length; i < len; i++) {
  6711. var point = points[i];
  6712. if (i === 0) {
  6713. context.moveTo(point.x, point.y);
  6714. } else {
  6715. context.lineTo(point.x, point.y);
  6716. }
  6717. }
  6718. context.closePath();
  6719. };
  6720. _proto.calculateBox = function calculateBox() {
  6721. var attrs = this.get('attrs');
  6722. var points = attrs.points;
  6723. return bbox.getBBoxFromPoints(points);
  6724. };
  6725. return Polygon;
  6726. }(Shape);
  6727. Shape.Polygon = Polygon;
  6728. module.exports = Polygon;
  6729. /***/ }),
  6730. /* 74 */
  6731. /***/ (function(module, exports, __webpack_require__) {
  6732. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6733. var Shape = __webpack_require__(2);
  6734. var Smooth = __webpack_require__(37);
  6735. var bbox = __webpack_require__(11);
  6736. var Polyline =
  6737. /*#__PURE__*/
  6738. function (_Shape) {
  6739. _inheritsLoose(Polyline, _Shape);
  6740. function Polyline() {
  6741. return _Shape.apply(this, arguments) || this;
  6742. }
  6743. var _proto = Polyline.prototype;
  6744. _proto._initProperties = function _initProperties() {
  6745. _Shape.prototype._initProperties.call(this);
  6746. this._attrs.canFill = true;
  6747. this._attrs.canStroke = true;
  6748. this._attrs.type = 'polyline';
  6749. };
  6750. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6751. return {
  6752. points: null,
  6753. lineWidth: 1,
  6754. smooth: false
  6755. };
  6756. };
  6757. _proto.createPath = function createPath(context) {
  6758. var self = this;
  6759. var attrs = self.get('attrs');
  6760. var points = attrs.points,
  6761. smooth = attrs.smooth;
  6762. var filteredPoints = []; // filter the point which x or y is NaN
  6763. for (var i = 0, len = points.length; i < len; i++) {
  6764. var point = points[i];
  6765. if (!isNaN(point.x) && !isNaN(point.y)) {
  6766. filteredPoints.push(point);
  6767. }
  6768. }
  6769. context.beginPath();
  6770. if (filteredPoints.length) {
  6771. context.moveTo(filteredPoints[0].x, filteredPoints[0].y);
  6772. if (smooth) {
  6773. var constaint = [[0, 0], [1, 1]];
  6774. var sps = Smooth.smooth(filteredPoints, false, constaint);
  6775. for (var _i = 0, n = sps.length; _i < n; _i++) {
  6776. var sp = sps[_i];
  6777. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  6778. }
  6779. } else {
  6780. var _i2;
  6781. var l;
  6782. for (_i2 = 1, l = filteredPoints.length - 1; _i2 < l; _i2++) {
  6783. context.lineTo(filteredPoints[_i2].x, filteredPoints[_i2].y);
  6784. }
  6785. context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
  6786. }
  6787. }
  6788. };
  6789. _proto.calculateBox = function calculateBox() {
  6790. var attrs = this.get('attrs');
  6791. var points = attrs.points,
  6792. smooth = attrs.smooth,
  6793. lineWidth = attrs.lineWidth;
  6794. if (smooth) {
  6795. var newPoints = [];
  6796. var constaint = [[0, 0], [1, 1]];
  6797. var sps = Smooth.smooth(points, false, constaint);
  6798. for (var i = 0, n = sps.length; i < n; i++) {
  6799. var sp = sps[i];
  6800. if (i === 0) {
  6801. newPoints.push([points[0].x, points[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  6802. } else {
  6803. var lastPoint = sps[i - 1];
  6804. newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
  6805. }
  6806. }
  6807. return bbox.getBBoxFromBezierGroup(newPoints, lineWidth);
  6808. }
  6809. return bbox.getBBoxFromPoints(points, lineWidth);
  6810. };
  6811. return Polyline;
  6812. }(Shape);
  6813. Shape.Polyline = Polyline;
  6814. module.exports = Polyline;
  6815. /***/ }),
  6816. /* 75 */
  6817. /***/ (function(module, exports, __webpack_require__) {
  6818. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6819. var Shape = __webpack_require__(2);
  6820. var bbox = __webpack_require__(11);
  6821. var Arc =
  6822. /*#__PURE__*/
  6823. function (_Shape) {
  6824. _inheritsLoose(Arc, _Shape);
  6825. function Arc() {
  6826. return _Shape.apply(this, arguments) || this;
  6827. }
  6828. var _proto = Arc.prototype;
  6829. _proto._initProperties = function _initProperties() {
  6830. _Shape.prototype._initProperties.call(this);
  6831. this._attrs.canStroke = true;
  6832. this._attrs.canFill = true;
  6833. this._attrs.type = 'arc';
  6834. };
  6835. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6836. return {
  6837. x: 0,
  6838. y: 0,
  6839. r: 0,
  6840. startAngle: 0,
  6841. endAngle: Math.PI * 2,
  6842. clockwise: false,
  6843. lineWidth: 1
  6844. };
  6845. };
  6846. _proto.createPath = function createPath(context) {
  6847. var attrs = this.get('attrs');
  6848. var x = attrs.x,
  6849. y = attrs.y,
  6850. r = attrs.r,
  6851. startAngle = attrs.startAngle,
  6852. endAngle = attrs.endAngle,
  6853. clockwise = attrs.clockwise;
  6854. context.beginPath();
  6855. context.arc(x, y, r, startAngle, endAngle, clockwise);
  6856. };
  6857. _proto.calculateBox = function calculateBox() {
  6858. var attrs = this.get('attrs');
  6859. var x = attrs.x,
  6860. y = attrs.y,
  6861. r = attrs.r,
  6862. startAngle = attrs.startAngle,
  6863. endAngle = attrs.endAngle,
  6864. clockwise = attrs.clockwise;
  6865. return bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
  6866. };
  6867. return Arc;
  6868. }(Shape);
  6869. Shape.Arc = Arc;
  6870. module.exports = Arc;
  6871. /***/ }),
  6872. /* 76 */
  6873. /***/ (function(module, exports, __webpack_require__) {
  6874. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6875. var Shape = __webpack_require__(2);
  6876. var bbox = __webpack_require__(11);
  6877. var Sector =
  6878. /*#__PURE__*/
  6879. function (_Shape) {
  6880. _inheritsLoose(Sector, _Shape);
  6881. function Sector() {
  6882. return _Shape.apply(this, arguments) || this;
  6883. }
  6884. var _proto = Sector.prototype;
  6885. _proto._initProperties = function _initProperties() {
  6886. _Shape.prototype._initProperties.call(this);
  6887. this._attrs.canFill = true;
  6888. this._attrs.canStroke = true;
  6889. this._attrs.type = 'sector';
  6890. };
  6891. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6892. return {
  6893. x: 0,
  6894. y: 0,
  6895. lineWidth: 0,
  6896. r: 0,
  6897. r0: 0,
  6898. startAngle: 0,
  6899. endAngle: Math.PI * 2,
  6900. clockwise: false
  6901. };
  6902. };
  6903. _proto.createPath = function createPath(context) {
  6904. var attrs = this.get('attrs');
  6905. var x = attrs.x,
  6906. y = attrs.y,
  6907. startAngle = attrs.startAngle,
  6908. endAngle = attrs.endAngle,
  6909. r = attrs.r,
  6910. r0 = attrs.r0,
  6911. clockwise = attrs.clockwise;
  6912. context.beginPath();
  6913. var unitX = Math.cos(startAngle);
  6914. var unitY = Math.sin(startAngle);
  6915. context.moveTo(unitX * r0 + x, unitY * r0 + y);
  6916. context.lineTo(unitX * r + x, unitY * r + y);
  6917. context.arc(x, y, r, startAngle, endAngle, clockwise);
  6918. context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
  6919. if (r0 !== 0) {
  6920. context.arc(x, y, r0, endAngle, startAngle, !clockwise);
  6921. }
  6922. context.closePath();
  6923. };
  6924. _proto.calculateBox = function calculateBox() {
  6925. var attrs = this.get('attrs');
  6926. var x = attrs.x,
  6927. y = attrs.y,
  6928. r = attrs.r,
  6929. r0 = attrs.r0,
  6930. startAngle = attrs.startAngle,
  6931. endAngle = attrs.endAngle,
  6932. clockwise = attrs.clockwise;
  6933. var outerBBox = bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
  6934. var innerBBox = bbox.getBBoxFromArc(x, y, r0, startAngle, endAngle, clockwise);
  6935. return {
  6936. minX: Math.min(outerBBox.minX, innerBBox.minX),
  6937. minY: Math.min(outerBBox.minY, innerBBox.minY),
  6938. maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
  6939. maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
  6940. };
  6941. };
  6942. return Sector;
  6943. }(Shape);
  6944. Shape.Sector = Sector;
  6945. module.exports = Sector;
  6946. /***/ }),
  6947. /* 77 */
  6948. /***/ (function(module, exports, __webpack_require__) {
  6949. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  6950. var Util = __webpack_require__(0);
  6951. var Shape = __webpack_require__(2);
  6952. var textWidthCacheCounter = 0;
  6953. var textWidthCache = {};
  6954. var TEXT_CACHE_MAX = 5000;
  6955. var Text =
  6956. /*#__PURE__*/
  6957. function (_Shape) {
  6958. _inheritsLoose(Text, _Shape);
  6959. function Text() {
  6960. return _Shape.apply(this, arguments) || this;
  6961. }
  6962. var _proto = Text.prototype;
  6963. _proto._initProperties = function _initProperties() {
  6964. _Shape.prototype._initProperties.call(this);
  6965. this._attrs.canFill = true;
  6966. this._attrs.canStroke = true;
  6967. this._attrs.type = 'text';
  6968. };
  6969. _proto.getDefaultAttrs = function getDefaultAttrs() {
  6970. return {
  6971. lineWidth: 0,
  6972. lineCount: 1,
  6973. fontSize: 12,
  6974. fontFamily: 'sans-serif',
  6975. fontStyle: 'normal',
  6976. fontWeight: 'normal',
  6977. fontVariant: 'normal',
  6978. textAlign: 'start',
  6979. textBaseline: 'bottom',
  6980. lineHeight: null,
  6981. textArr: null
  6982. };
  6983. };
  6984. _proto._getFontStyle = function _getFontStyle() {
  6985. var attrs = this._attrs.attrs;
  6986. var fontSize = attrs.fontSize,
  6987. fontFamily = attrs.fontFamily,
  6988. fontWeight = attrs.fontWeight,
  6989. fontStyle = attrs.fontStyle,
  6990. fontVariant = attrs.fontVariant;
  6991. return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
  6992. };
  6993. _proto._afterAttrsSet = function _afterAttrsSet() {
  6994. var attrs = this._attrs.attrs;
  6995. attrs.font = this._getFontStyle();
  6996. if (attrs.text) {
  6997. var text = attrs.text;
  6998. var textArr = null;
  6999. var lineCount = 1;
  7000. if (Util.isString(text) && text.indexOf('\n') !== -1) {
  7001. textArr = text.split('\n');
  7002. lineCount = textArr.length;
  7003. }
  7004. attrs.lineCount = lineCount;
  7005. attrs.textArr = textArr;
  7006. }
  7007. this.set('attrs', attrs);
  7008. };
  7009. _proto._getTextHeight = function _getTextHeight() {
  7010. var attrs = this._attrs.attrs;
  7011. if (attrs.height) {
  7012. return attrs.height;
  7013. }
  7014. var lineCount = attrs.lineCount;
  7015. var fontSize = attrs.fontSize * 1;
  7016. if (lineCount > 1) {
  7017. var spaceingY = this._getSpaceingY();
  7018. return fontSize * lineCount + spaceingY * (lineCount - 1);
  7019. }
  7020. return fontSize;
  7021. };
  7022. _proto._getSpaceingY = function _getSpaceingY() {
  7023. var attrs = this._attrs.attrs;
  7024. var lineHeight = attrs.lineHeight;
  7025. var fontSize = attrs.fontSize * 1;
  7026. return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
  7027. };
  7028. _proto.drawInner = function drawInner(context) {
  7029. var self = this;
  7030. var attrs = self._attrs.attrs;
  7031. var text = attrs.text;
  7032. var x = attrs.x;
  7033. var y = attrs.y;
  7034. if (Util.isNil(text) || isNaN(x) || isNaN(y)) {
  7035. // text will be 0
  7036. return;
  7037. }
  7038. var textArr = attrs.textArr;
  7039. var fontSize = attrs.fontSize * 1;
  7040. var spaceingY = self._getSpaceingY();
  7041. if (attrs.rotate) {
  7042. // do rotation
  7043. context.translate(x, y);
  7044. context.rotate(attrs.rotate);
  7045. x = 0;
  7046. y = 0;
  7047. }
  7048. var textBaseline = attrs.textBaseline;
  7049. var height;
  7050. if (textArr) {
  7051. height = self._getTextHeight();
  7052. }
  7053. var subY; // context.beginPath();
  7054. if (self.hasFill()) {
  7055. var fillOpacity = attrs.fillOpacity;
  7056. if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
  7057. context.globalAlpha = fillOpacity;
  7058. }
  7059. if (textArr) {
  7060. for (var i = 0, len = textArr.length; i < len; i++) {
  7061. var subText = textArr[i];
  7062. subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;
  7063. if (textBaseline === 'middle') {
  7064. subY += height - fontSize - (height - fontSize) / 2;
  7065. }
  7066. if (textBaseline === 'top') {
  7067. subY += height - fontSize;
  7068. }
  7069. context.fillText(subText, x, subY);
  7070. }
  7071. } else {
  7072. context.fillText(text, x, y);
  7073. }
  7074. }
  7075. if (self.hasStroke()) {
  7076. if (textArr) {
  7077. for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
  7078. var _subText = textArr[_i];
  7079. subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;
  7080. if (textBaseline === 'middle') {
  7081. subY += height - fontSize - (height - fontSize) / 2;
  7082. }
  7083. if (textBaseline === 'top') {
  7084. subY += height - fontSize;
  7085. }
  7086. context.strokeText(_subText, x, subY);
  7087. }
  7088. } else {
  7089. context.strokeText(text, x, y);
  7090. }
  7091. }
  7092. };
  7093. _proto.calculateBox = function calculateBox() {
  7094. var self = this;
  7095. var attrs = self._attrs.attrs;
  7096. var x = attrs.x,
  7097. y = attrs.y,
  7098. textAlign = attrs.textAlign,
  7099. textBaseline = attrs.textBaseline;
  7100. var width = self._getTextWidth(); // attrs.width
  7101. if (!width) {
  7102. return {
  7103. minX: x,
  7104. minY: y,
  7105. maxX: x,
  7106. maxY: y
  7107. };
  7108. }
  7109. var height = self._getTextHeight(); // attrs.height
  7110. var point = {
  7111. x: x,
  7112. y: y - height
  7113. }; // default textAlign: start, textBaseline: bottom
  7114. if (textAlign) {
  7115. if (textAlign === 'end' || textAlign === 'right') {
  7116. point.x -= width;
  7117. } else if (textAlign === 'center') {
  7118. point.x -= width / 2;
  7119. }
  7120. }
  7121. if (textBaseline) {
  7122. if (textBaseline === 'top') {
  7123. point.y += height;
  7124. } else if (textBaseline === 'middle') {
  7125. point.y += height / 2;
  7126. }
  7127. }
  7128. return {
  7129. minX: point.x,
  7130. minY: point.y,
  7131. maxX: point.x + width,
  7132. maxY: point.y + height
  7133. };
  7134. };
  7135. _proto._getTextWidth = function _getTextWidth() {
  7136. var attrs = this._attrs.attrs;
  7137. if (attrs.width) {
  7138. return attrs.width;
  7139. }
  7140. var text = attrs.text;
  7141. var context = this.get('context');
  7142. if (Util.isNil(text)) return undefined;
  7143. var font = attrs.font;
  7144. var textArr = attrs.textArr;
  7145. var key = text + '' + font;
  7146. if (textWidthCache[key]) {
  7147. return textWidthCache[key];
  7148. }
  7149. var width = 0;
  7150. if (textArr) {
  7151. for (var i = 0, length = textArr.length; i < length; i++) {
  7152. var subText = textArr[i];
  7153. width = Math.max(width, Util.measureText(subText, font, context).width);
  7154. }
  7155. } else {
  7156. width = Util.measureText(text, font, context).width;
  7157. }
  7158. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  7159. textWidthCacheCounter = 0;
  7160. textWidthCache = {};
  7161. }
  7162. textWidthCacheCounter++;
  7163. textWidthCache[key] = width;
  7164. return width;
  7165. };
  7166. return Text;
  7167. }(Shape);
  7168. Shape.Text = Text;
  7169. module.exports = Text;
  7170. /***/ }),
  7171. /* 78 */
  7172. /***/ (function(module, exports, __webpack_require__) {
  7173. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7174. var Shape = __webpack_require__(2);
  7175. var Custom =
  7176. /*#__PURE__*/
  7177. function (_Shape) {
  7178. _inheritsLoose(Custom, _Shape);
  7179. function Custom() {
  7180. return _Shape.apply(this, arguments) || this;
  7181. }
  7182. var _proto = Custom.prototype;
  7183. _proto._initProperties = function _initProperties() {
  7184. _Shape.prototype._initProperties.call(this);
  7185. this._attrs.canFill = true;
  7186. this._attrs.canStroke = true;
  7187. this._attrs.createPath = null;
  7188. this._attrs.type = 'custom';
  7189. };
  7190. _proto.createPath = function createPath(context) {
  7191. var createPath = this.get('createPath');
  7192. createPath && createPath.call(this, context);
  7193. };
  7194. _proto.calculateBox = function calculateBox() {
  7195. var calculateBox = this.get('calculateBox');
  7196. return calculateBox && calculateBox.call(this);
  7197. };
  7198. return Custom;
  7199. }(Shape);
  7200. Shape.Custom = Custom;
  7201. module.exports = Custom;
  7202. /***/ }),
  7203. /* 79 */
  7204. /***/ (function(module, exports, __webpack_require__) {
  7205. /**
  7206. * @fileOverview track f2
  7207. * @author sima.zhang1990@gmail.com
  7208. */
  7209. var Global = __webpack_require__(1);
  7210. var Util = __webpack_require__(0);
  7211. var SERVER_URL = 'https://kcart.alipay.com/web/bi.do';
  7212. setTimeout(function () {
  7213. if (Global.trackable && Util.isBrowser) {
  7214. // Only works for H5 env
  7215. var image = new Image();
  7216. var newObj = {
  7217. pg: document.URL,
  7218. r: new Date().getTime(),
  7219. f2: true,
  7220. version: Global.version,
  7221. page_type: 'syslog'
  7222. };
  7223. var d = encodeURIComponent(JSON.stringify([newObj]));
  7224. image.src = SERVER_URL + "?BIProfile=merge&d=" + d;
  7225. }
  7226. }, 3000);
  7227. /***/ }),
  7228. /* 80 */
  7229. /***/ (function(module, exports, __webpack_require__) {
  7230. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7231. var Path = __webpack_require__(38);
  7232. var Geom = __webpack_require__(6);
  7233. __webpack_require__(32);
  7234. var Line =
  7235. /*#__PURE__*/
  7236. function (_Path) {
  7237. _inheritsLoose(Line, _Path);
  7238. function Line() {
  7239. return _Path.apply(this, arguments) || this;
  7240. }
  7241. var _proto = Line.prototype;
  7242. _proto.getDefaultCfg = function getDefaultCfg() {
  7243. var cfg = _Path.prototype.getDefaultCfg.call(this);
  7244. cfg.type = 'line';
  7245. cfg.sortable = true;
  7246. return cfg;
  7247. };
  7248. return Line;
  7249. }(Path);
  7250. Geom.Line = Line;
  7251. module.exports = Line;
  7252. /***/ }),
  7253. /* 81 */
  7254. /***/ (function(module, exports, __webpack_require__) {
  7255. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7256. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  7257. var Geom = __webpack_require__(6);
  7258. var Util = __webpack_require__(0);
  7259. var SizeMixin = __webpack_require__(39);
  7260. __webpack_require__(82);
  7261. var Interval =
  7262. /*#__PURE__*/
  7263. function (_Geom) {
  7264. _inheritsLoose(Interval, _Geom);
  7265. var _proto = Interval.prototype;
  7266. _proto.getDefaultCfg = function getDefaultCfg() {
  7267. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  7268. cfg.type = 'interval';
  7269. cfg.shapeType = 'interval';
  7270. cfg.generatePoints = true;
  7271. return cfg;
  7272. };
  7273. function Interval(cfg) {
  7274. var _this;
  7275. _this = _Geom.call(this, cfg) || this;
  7276. Util.mix(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
  7277. return _this;
  7278. }
  7279. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  7280. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  7281. cfg.size = this.getNormalizedSize(obj);
  7282. return cfg;
  7283. };
  7284. _proto.clearInner = function clearInner() {
  7285. _Geom.prototype.clearInner.call(this);
  7286. this.set('defaultSize', null);
  7287. };
  7288. return Interval;
  7289. }(Geom);
  7290. Geom.Interval = Interval;
  7291. module.exports = Interval;
  7292. /***/ }),
  7293. /* 82 */
  7294. /***/ (function(module, exports, __webpack_require__) {
  7295. var Util = __webpack_require__(0);
  7296. var Shape = __webpack_require__(9);
  7297. var Vector2 = __webpack_require__(4);
  7298. var Global = __webpack_require__(1);
  7299. function getRectPoints(cfg) {
  7300. var x = cfg.x,
  7301. y = cfg.y,
  7302. y0 = cfg.y0,
  7303. size = cfg.size;
  7304. var ymin = y0;
  7305. var ymax = y;
  7306. if (Util.isArray(y)) {
  7307. ymax = y[1];
  7308. ymin = y[0];
  7309. }
  7310. var xmin;
  7311. var xmax;
  7312. if (Util.isArray(x)) {
  7313. xmin = x[0];
  7314. xmax = x[1];
  7315. } else {
  7316. xmin = x - size / 2;
  7317. xmax = x + size / 2;
  7318. }
  7319. return [{
  7320. x: xmin,
  7321. y: ymin
  7322. }, {
  7323. x: xmin,
  7324. y: ymax
  7325. }, {
  7326. x: xmax,
  7327. y: ymax
  7328. }, {
  7329. x: xmax,
  7330. y: ymin
  7331. }];
  7332. }
  7333. function getRectRange(points) {
  7334. var xValues = [];
  7335. var yValues = [];
  7336. for (var i = 0, len = points.length; i < len; i++) {
  7337. var point = points[i];
  7338. xValues.push(point.x);
  7339. yValues.push(point.y);
  7340. }
  7341. var xMin = Math.min.apply(null, xValues);
  7342. var yMin = Math.min.apply(null, yValues);
  7343. var xMax = Math.max.apply(null, xValues);
  7344. var yMax = Math.max.apply(null, yValues);
  7345. return {
  7346. x: xMin,
  7347. y: yMin,
  7348. width: xMax - xMin,
  7349. height: yMax - yMin
  7350. };
  7351. }
  7352. var Interval = Shape.registerFactory('interval', {
  7353. defaultShapeType: 'rect',
  7354. getDefaultPoints: function getDefaultPoints(cfg) {
  7355. return getRectPoints(cfg);
  7356. }
  7357. });
  7358. Shape.registerShape('interval', 'rect', {
  7359. draw: function draw(cfg, container) {
  7360. var points = this.parsePoints(cfg.points);
  7361. var style = Util.mix({
  7362. fill: cfg.color
  7363. }, Global.shape.interval, cfg.style);
  7364. if (cfg.isInCircle) {
  7365. var newPoints = points.slice(0);
  7366. if (this._coord.transposed) {
  7367. newPoints = [points[0], points[3], points[2], points[1]];
  7368. }
  7369. var _cfg$center = cfg.center,
  7370. x = _cfg$center.x,
  7371. y = _cfg$center.y;
  7372. var v = [1, 0];
  7373. var v0 = [newPoints[0].x - x, newPoints[0].y - y];
  7374. var v1 = [newPoints[1].x - x, newPoints[1].y - y];
  7375. var v2 = [newPoints[2].x - x, newPoints[2].y - y];
  7376. var startAngle = Vector2.angleTo(v, v1);
  7377. var endAngle = Vector2.angleTo(v, v2);
  7378. var r0 = Vector2.length(v0);
  7379. var r = Vector2.length(v1);
  7380. if (startAngle >= 1.5 * Math.PI) {
  7381. startAngle = startAngle - 2 * Math.PI;
  7382. }
  7383. if (endAngle >= 1.5 * Math.PI) {
  7384. endAngle = endAngle - 2 * Math.PI;
  7385. }
  7386. return container.addShape('Sector', {
  7387. className: 'interval',
  7388. attrs: Util.mix({
  7389. x: x,
  7390. y: y,
  7391. r: r,
  7392. r0: r0,
  7393. startAngle: startAngle,
  7394. endAngle: endAngle
  7395. }, style)
  7396. });
  7397. }
  7398. var rectCfg = getRectRange(points);
  7399. return container.addShape('rect', {
  7400. className: 'interval',
  7401. attrs: Util.mix(rectCfg, style)
  7402. });
  7403. }
  7404. });
  7405. module.exports = Interval;
  7406. /***/ }),
  7407. /* 83 */
  7408. /***/ (function(module, exports, __webpack_require__) {
  7409. module.exports = {
  7410. Stack: __webpack_require__(84),
  7411. Dodge: __webpack_require__(86)
  7412. };
  7413. /***/ }),
  7414. /* 84 */
  7415. /***/ (function(module, exports, __webpack_require__) {
  7416. var Stack = __webpack_require__(85);
  7417. module.exports = Stack;
  7418. /***/ }),
  7419. /* 85 */
  7420. /***/ (function(module, exports, __webpack_require__) {
  7421. function _inheritsLoose(subClass, superClass) {
  7422. subClass.prototype = Object.create(superClass.prototype);
  7423. subClass.prototype.constructor = subClass;
  7424. subClass.__proto__ = superClass;
  7425. }
  7426. var isArray = __webpack_require__(10);
  7427. var isNil = __webpack_require__(7);
  7428. var Adjust = __webpack_require__(22);
  7429. var Stack =
  7430. /*#__PURE__*/
  7431. function (_Adjust) {
  7432. _inheritsLoose(Stack, _Adjust);
  7433. function Stack() {
  7434. return _Adjust.apply(this, arguments) || this;
  7435. }
  7436. var _proto = Stack.prototype;
  7437. _proto._initDefaultCfg = function _initDefaultCfg() {
  7438. this.xField = null; // 调整对应的 x 方向对应的字段名称
  7439. this.yField = null; // 调整对应的 y 方向对应的字段名称
  7440. };
  7441. _proto.processAdjust = function processAdjust(dataArray) {
  7442. this.processStack(dataArray);
  7443. };
  7444. _proto.processStack = function processStack(dataArray) {
  7445. var self = this;
  7446. var xField = self.xField;
  7447. var yField = self.yField;
  7448. var count = dataArray.length;
  7449. var stackCache = {
  7450. positive: {},
  7451. negative: {}
  7452. }; // 层叠顺序翻转
  7453. if (self.reverseOrder) {
  7454. dataArray = dataArray.slice(0).reverse();
  7455. }
  7456. for (var i = 0; i < count; i++) {
  7457. var data = dataArray[i];
  7458. for (var j = 0, len = data.length; j < len; j++) {
  7459. var item = data[j];
  7460. var x = item[xField] || 0;
  7461. var y = item[yField];
  7462. var xkey = x.toString();
  7463. y = isArray(y) ? y[1] : y;
  7464. if (!isNil(y)) {
  7465. var direction = y >= 0 ? 'positive' : 'negative';
  7466. if (!stackCache[direction][xkey]) {
  7467. stackCache[direction][xkey] = 0;
  7468. }
  7469. item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];
  7470. stackCache[direction][xkey] += y;
  7471. }
  7472. }
  7473. }
  7474. };
  7475. return Stack;
  7476. }(Adjust);
  7477. Adjust.Stack = Stack;
  7478. module.exports = Stack;
  7479. /***/ }),
  7480. /* 86 */
  7481. /***/ (function(module, exports, __webpack_require__) {
  7482. var Dodge = __webpack_require__(87);
  7483. module.exports = Dodge;
  7484. /***/ }),
  7485. /* 87 */
  7486. /***/ (function(module, exports, __webpack_require__) {
  7487. function _inheritsLoose(subClass, superClass) {
  7488. subClass.prototype = Object.create(superClass.prototype);
  7489. subClass.prototype.constructor = subClass;
  7490. subClass.__proto__ = superClass;
  7491. }
  7492. var Adjust = __webpack_require__(22);
  7493. var each = __webpack_require__(3);
  7494. var MARGIN_RATIO = 1 / 2;
  7495. var DODGE_RATIO = 1 / 2;
  7496. var Dodge =
  7497. /*#__PURE__*/
  7498. function (_Adjust) {
  7499. _inheritsLoose(Dodge, _Adjust);
  7500. function Dodge() {
  7501. return _Adjust.apply(this, arguments) || this;
  7502. }
  7503. var _proto = Dodge.prototype;
  7504. _proto._initDefaultCfg = function _initDefaultCfg() {
  7505. /**
  7506. * 调整过程中,2个数据的间距
  7507. * @type {Number}
  7508. */
  7509. this.marginRatio = MARGIN_RATIO;
  7510. /**
  7511. * 调整占单位宽度的比例,例如:占2个分类间距的 1/2
  7512. * @type {Number}
  7513. */
  7514. this.dodgeRatio = DODGE_RATIO;
  7515. this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
  7516. };
  7517. _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {
  7518. var self = this;
  7519. var pre = range.pre;
  7520. var next = range.next;
  7521. var tickLength = next - pre;
  7522. var width = tickLength * self.dodgeRatio / count;
  7523. var margin = self.marginRatio * width;
  7524. var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;
  7525. return (pre + next) / 2 + offset;
  7526. };
  7527. _proto.processAdjust = function processAdjust(dataArray) {
  7528. var self = this;
  7529. var count = dataArray.length;
  7530. var xField = self.xField;
  7531. each(dataArray, function (data, index) {
  7532. for (var i = 0, len = data.length; i < len; i++) {
  7533. var obj = data[i];
  7534. var value = obj[xField];
  7535. var range = {
  7536. pre: value - 0.5,
  7537. next: value + 0.5
  7538. };
  7539. var dodgeValue = self.getDodgeOffset(range, index, count);
  7540. obj[xField] = dodgeValue;
  7541. }
  7542. });
  7543. };
  7544. return Dodge;
  7545. }(Adjust);
  7546. Adjust.Dodge = Dodge;
  7547. module.exports = Dodge;
  7548. /***/ }),
  7549. /* 88 */
  7550. /***/ (function(module, exports, __webpack_require__) {
  7551. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7552. var Base = __webpack_require__(21);
  7553. var Vector2 = __webpack_require__(4);
  7554. var Matrix = __webpack_require__(23);
  7555. var Polar =
  7556. /*#__PURE__*/
  7557. function (_Base) {
  7558. _inheritsLoose(Polar, _Base);
  7559. function Polar() {
  7560. return _Base.apply(this, arguments) || this;
  7561. }
  7562. var _proto = Polar.prototype;
  7563. _proto._initDefaultCfg = function _initDefaultCfg() {
  7564. this.type = 'polar';
  7565. this.startAngle = -Math.PI / 2;
  7566. this.endAngle = Math.PI * 3 / 2;
  7567. this.inner = 0;
  7568. this.innerRadius = 0; // alias
  7569. this.isPolar = true;
  7570. this.transposed = false;
  7571. this.center = null;
  7572. this.radius = null; // relative, 0 ~ 1
  7573. };
  7574. _proto.init = function init(start, end) {
  7575. var self = this;
  7576. var inner = self.inner || self.innerRadius;
  7577. var width = Math.abs(end.x - start.x);
  7578. var height = Math.abs(end.y - start.y);
  7579. var maxRadius;
  7580. var center;
  7581. if (self.startAngle === -Math.PI && self.endAngle === 0) {
  7582. maxRadius = Math.min(width / 2, height);
  7583. center = {
  7584. x: (start.x + end.x) / 2,
  7585. y: start.y
  7586. };
  7587. } else {
  7588. maxRadius = Math.min(width, height) / 2;
  7589. center = {
  7590. x: (start.x + end.x) / 2,
  7591. y: (start.y + end.y) / 2
  7592. };
  7593. }
  7594. var radius = self.radius;
  7595. if (radius > 0 && radius <= 1) {
  7596. maxRadius = maxRadius * radius;
  7597. }
  7598. this.x = {
  7599. start: self.startAngle,
  7600. end: self.endAngle
  7601. };
  7602. this.y = {
  7603. start: maxRadius * inner,
  7604. end: maxRadius
  7605. };
  7606. this.center = center;
  7607. this.circleRadius = maxRadius; // the radius value in px
  7608. };
  7609. _proto.convertPoint = function convertPoint(point) {
  7610. var self = this;
  7611. var center = self.center;
  7612. var transposed = self.transposed;
  7613. var xDim = transposed ? 'y' : 'x';
  7614. var yDim = transposed ? 'x' : 'y';
  7615. var x = self.x;
  7616. var y = self.y;
  7617. var angle = x.start + (x.end - x.start) * point[xDim];
  7618. var radius = y.start + (y.end - y.start) * point[yDim];
  7619. return {
  7620. x: center.x + Math.cos(angle) * radius,
  7621. y: center.y + Math.sin(angle) * radius
  7622. };
  7623. };
  7624. _proto.invertPoint = function invertPoint(point) {
  7625. var self = this;
  7626. var center = self.center,
  7627. transposed = self.transposed,
  7628. x = self.x,
  7629. y = self.y;
  7630. var xDim = transposed ? 'y' : 'x';
  7631. var yDim = transposed ? 'x' : 'y';
  7632. var m = [1, 0, 0, 1, 0, 0];
  7633. Matrix.rotate(m, m, x.start);
  7634. var startV = [1, 0];
  7635. Vector2.transformMat2d(startV, startV, m);
  7636. startV = [startV[0], startV[1]];
  7637. var pointV = [point.x - center.x, point.y - center.y];
  7638. if (Vector2.zero(pointV)) {
  7639. return {
  7640. x: 0,
  7641. y: 0
  7642. };
  7643. }
  7644. var theta = Vector2.angleTo(startV, pointV, x.end < x.start);
  7645. if (Math.abs(theta - Math.PI * 2) < 0.001) {
  7646. theta = 0;
  7647. }
  7648. var l = Vector2.length(pointV);
  7649. var percentX = theta / (x.end - x.start);
  7650. percentX = x.end - x.start > 0 ? percentX : -percentX;
  7651. var percentY = (l - y.start) / (y.end - y.start);
  7652. var rst = {};
  7653. rst[xDim] = percentX;
  7654. rst[yDim] = percentY;
  7655. return rst;
  7656. };
  7657. return Polar;
  7658. }(Base);
  7659. Base.Polar = Polar;
  7660. module.exports = Polar;
  7661. /***/ }),
  7662. /* 89 */
  7663. /***/ (function(module, exports, __webpack_require__) {
  7664. /**
  7665. * @fileOverview 提取公共代码到util方法
  7666. * @author dxq613@gmail.com
  7667. */
  7668. var isString = __webpack_require__(15);
  7669. var isDate = __webpack_require__(33);
  7670. module.exports = {
  7671. toTimeStamp: function toTimeStamp(value) {
  7672. if (isString(value)) {
  7673. if (value.indexOf('T') > 0) {
  7674. value = new Date(value).getTime();
  7675. } else {
  7676. value = new Date(value.replace(/-/ig, '/')).getTime();
  7677. }
  7678. }
  7679. if (isDate(value)) {
  7680. value = value.getTime();
  7681. }
  7682. return value;
  7683. }
  7684. };
  7685. /***/ }),
  7686. /* 90 */
  7687. /***/ (function(module, exports, __webpack_require__) {
  7688. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7689. /**
  7690. * marker shapes,used for tooltip and legend
  7691. */
  7692. var Util = __webpack_require__(0);
  7693. var _require = __webpack_require__(5),
  7694. Shape = _require.Shape;
  7695. var SYMBOLS = {
  7696. circle: function circle(x, y, r, ctx) {
  7697. ctx.arc(x, y, r, 0, Math.PI * 2, false);
  7698. },
  7699. square: function square(x, y, r, ctx) {
  7700. ctx.moveTo(x - r, y - r);
  7701. ctx.lineTo(x + r, y - r);
  7702. ctx.lineTo(x + r, y + r);
  7703. ctx.lineTo(x - r, y + r);
  7704. ctx.closePath();
  7705. }
  7706. };
  7707. var Marker =
  7708. /*#__PURE__*/
  7709. function (_Shape) {
  7710. _inheritsLoose(Marker, _Shape);
  7711. function Marker() {
  7712. return _Shape.apply(this, arguments) || this;
  7713. }
  7714. var _proto = Marker.prototype;
  7715. _proto._initProperties = function _initProperties() {
  7716. _Shape.prototype._initProperties.call(this);
  7717. this._attrs.canFill = true;
  7718. this._attrs.canStroke = true;
  7719. this._attrs.type = 'marker';
  7720. };
  7721. _proto.getDefaultAttrs = function getDefaultAttrs() {
  7722. return {
  7723. x: 0,
  7724. y: 0,
  7725. lineWidth: 0
  7726. };
  7727. };
  7728. _proto.createPath = function createPath(context) {
  7729. var attrs = this.get('attrs');
  7730. var x = attrs.x,
  7731. y = attrs.y,
  7732. radius = attrs.radius;
  7733. var symbol = attrs.symbol || 'circle';
  7734. var method;
  7735. if (Util.isFunction(symbol)) {
  7736. method = symbol;
  7737. } else {
  7738. method = SYMBOLS[symbol];
  7739. }
  7740. context.beginPath();
  7741. method(x, y, radius, context, this);
  7742. };
  7743. _proto.calculateBox = function calculateBox() {
  7744. var attrs = this.get('attrs');
  7745. var x = attrs.x,
  7746. y = attrs.y,
  7747. radius = attrs.radius;
  7748. return {
  7749. minX: x - radius,
  7750. minY: y - radius,
  7751. maxX: x + radius,
  7752. maxY: y + radius
  7753. };
  7754. };
  7755. return Marker;
  7756. }(Shape);
  7757. module.exports = Marker;
  7758. /***/ }),
  7759. /* 91 */
  7760. /***/ (function(module, exports, __webpack_require__) {
  7761. var Util = __webpack_require__(0);
  7762. var _require = __webpack_require__(5),
  7763. Group = _require.Group;
  7764. var Marker = __webpack_require__(90);
  7765. var MARKER_RADIUS = 3;
  7766. var List =
  7767. /*#__PURE__*/
  7768. function () {
  7769. var _proto = List.prototype;
  7770. _proto.getDefaultCfg = function getDefaultCfg() {
  7771. return {
  7772. showTitle: false,
  7773. /**
  7774. * title string
  7775. * @type {?String}
  7776. */
  7777. title: null,
  7778. /**
  7779. * items array
  7780. * @type {?Array}
  7781. */
  7782. items: null,
  7783. /**
  7784. * offset between title and items
  7785. * @type {Number}
  7786. */
  7787. titleGap: 12,
  7788. /**
  7789. * offset between each item
  7790. * @type {Number}
  7791. */
  7792. itemGap: 10,
  7793. /**
  7794. * the offset between each item in vertical direaction
  7795. * @type {Number}
  7796. */
  7797. itemMarginBottom: 12,
  7798. /**
  7799. * the formatter for item text
  7800. * @type {[type]}
  7801. */
  7802. itemFormatter: null,
  7803. itemWidth: null,
  7804. /**
  7805. * offset between marker and text
  7806. * @type {Number}
  7807. */
  7808. wordSpace: 6,
  7809. x: 0,
  7810. y: 0,
  7811. layout: 'horizontal',
  7812. /**
  7813. * the join string of `name` and `value`
  7814. * @type {String}
  7815. */
  7816. joinString: ': '
  7817. };
  7818. };
  7819. function List(cfg) {
  7820. Util.deepMix(this, this.getDefaultCfg(), cfg);
  7821. this._init();
  7822. this._renderTitle();
  7823. this._renderItems();
  7824. }
  7825. _proto._init = function _init() {
  7826. var container = new Group({
  7827. zIndex: this.zIndex || 0
  7828. });
  7829. this.container = container;
  7830. var wrapper = container.addGroup();
  7831. this.wrapper = wrapper;
  7832. var itemsGroup = wrapper.addGroup({
  7833. className: 'itemsGroup'
  7834. });
  7835. this.itemsGroup = itemsGroup;
  7836. if (this.parent) {
  7837. this.parent.add(container);
  7838. }
  7839. };
  7840. _proto._renderTitle = function _renderTitle(title) {
  7841. title = title || this.title;
  7842. var titleShape = this.titleShape;
  7843. var titleHeight = 0;
  7844. if (this.showTitle && title) {
  7845. if (titleShape && !titleShape.get('destroyed')) {
  7846. titleShape.attr('text', title);
  7847. } else {
  7848. var wrapper = this.wrapper,
  7849. titleStyle = this.titleStyle;
  7850. titleShape = wrapper.addShape('text', {
  7851. className: 'title',
  7852. attrs: Util.mix({
  7853. x: 0,
  7854. y: 0,
  7855. text: title
  7856. }, titleStyle)
  7857. });
  7858. this.titleShape = titleShape;
  7859. }
  7860. titleHeight = titleShape.getBBox().height + this.titleGap;
  7861. }
  7862. this._titleHeight = titleHeight;
  7863. };
  7864. _proto._renderItems = function _renderItems(items) {
  7865. var self = this;
  7866. items = items || self.items;
  7867. if (!items) {
  7868. return;
  7869. }
  7870. if (self.reversed) {
  7871. items.reverse();
  7872. }
  7873. Util.each(items, function (item, index) {
  7874. self._addItem(item, index);
  7875. });
  7876. if (items.length > 1) {
  7877. this._adjustItems();
  7878. }
  7879. this._renderBackground();
  7880. };
  7881. _proto._renderBackground = function _renderBackground() {
  7882. var background = this.background;
  7883. if (background) {
  7884. var container = this.container;
  7885. var wrapper = this.wrapper;
  7886. var _wrapper$getBBox = wrapper.getBBox(),
  7887. minX = _wrapper$getBBox.minX,
  7888. minY = _wrapper$getBBox.minY,
  7889. width = _wrapper$getBBox.width,
  7890. height = _wrapper$getBBox.height;
  7891. var padding = background.padding || [0, 0, 0, 0];
  7892. padding = Util.parsePadding(padding);
  7893. var attrs = Util.mix({
  7894. x: minX - padding[3],
  7895. y: minY - padding[0],
  7896. width: width + padding[1] + padding[3],
  7897. height: height + padding[0] + padding[2]
  7898. }, background);
  7899. var backShape = this.backShape;
  7900. if (backShape) {
  7901. backShape.attr(attrs);
  7902. } else {
  7903. backShape = container.addShape('Rect', {
  7904. zIndex: -1,
  7905. attrs: attrs
  7906. });
  7907. }
  7908. this.backShape = backShape;
  7909. container.sort();
  7910. }
  7911. };
  7912. _proto._addItem = function _addItem(item) {
  7913. var itemsGroup = this.itemsGroup;
  7914. var itemGroup = itemsGroup.addGroup({
  7915. name: item.name,
  7916. value: item.value,
  7917. dataValue: item.dataValue,
  7918. checked: item.checked
  7919. });
  7920. var unCheckStyle = this.unCheckStyle,
  7921. unCheckColor = this.unCheckColor,
  7922. nameStyle = this.nameStyle,
  7923. valueStyle = this.valueStyle,
  7924. wordSpace = this.wordSpace;
  7925. var marker = item.marker,
  7926. value = item.value;
  7927. var startX = 0;
  7928. if (unCheckColor) {
  7929. unCheckStyle.fill = unCheckColor;
  7930. }
  7931. if (marker) {
  7932. var radius = marker.radius || MARKER_RADIUS;
  7933. var markerAttrs = Util.mix({
  7934. x: radius,
  7935. y: this._titleHeight
  7936. }, marker);
  7937. if (item.checked === false) {
  7938. Util.mix(markerAttrs, unCheckStyle);
  7939. }
  7940. var markerShape = new Marker({
  7941. className: 'item-marker',
  7942. attrs: markerAttrs
  7943. });
  7944. itemGroup.add(markerShape);
  7945. startX += markerShape.getBBox().width + wordSpace;
  7946. }
  7947. var nameText;
  7948. var name = item.name;
  7949. if (name) {
  7950. var joinString = this.joinString || '';
  7951. name = value ? name + joinString : name;
  7952. nameText = itemGroup.addShape('text', {
  7953. className: 'name',
  7954. attrs: Util.mix({
  7955. x: startX,
  7956. y: this._titleHeight,
  7957. text: this._formatItemValue(name)
  7958. }, nameStyle, item.checked === false ? unCheckStyle : null)
  7959. });
  7960. }
  7961. if (value) {
  7962. var valueX = startX;
  7963. if (nameText) {
  7964. valueX += nameText.getBBox().width;
  7965. }
  7966. itemGroup.addShape('text', {
  7967. className: 'value',
  7968. attrs: Util.mix({
  7969. x: valueX,
  7970. y: this._titleHeight,
  7971. text: value
  7972. }, valueStyle, item.checked === false ? unCheckStyle : null)
  7973. });
  7974. }
  7975. return itemGroup;
  7976. };
  7977. _proto._formatItemValue = function _formatItemValue(value) {
  7978. var formatter = this.itemFormatter;
  7979. if (formatter) {
  7980. value = formatter.call(this, value);
  7981. }
  7982. return value;
  7983. };
  7984. _proto._getMaxItemWidth = function _getMaxItemWidth() {
  7985. var width;
  7986. var itemWidth = this.itemWidth;
  7987. if (Util.isNumber(itemWidth) || Util.isNil(itemWidth)) {
  7988. return itemWidth;
  7989. }
  7990. if (itemWidth === 'auto') {
  7991. var itemsGroup = this.itemsGroup;
  7992. var children = itemsGroup.get('children');
  7993. var count = children.length;
  7994. var maxItemWidth = 0;
  7995. for (var i = 0; i < count; i++) {
  7996. var _children$i$getBBox = children[i].getBBox(),
  7997. _width = _children$i$getBBox.width;
  7998. maxItemWidth = Math.max(maxItemWidth, _width);
  7999. }
  8000. var maxLength = this.maxLength;
  8001. var itemGap = this.itemGap;
  8002. var twoAvgWidth = (maxLength - itemGap) / 2;
  8003. var threeAvgWidth = (maxLength - itemGap * 2) / 3;
  8004. if (count === 2) {
  8005. width = Math.max(maxItemWidth, twoAvgWidth);
  8006. } else {
  8007. // 1. max <= 3Avg, 3Avg
  8008. // 2. 3Avg < max && max < 2avg, 2avg
  8009. // 3. max > 2avg, max, one column
  8010. if (maxItemWidth <= threeAvgWidth) {
  8011. width = threeAvgWidth;
  8012. } else if (maxItemWidth <= twoAvgWidth) {
  8013. width = twoAvgWidth;
  8014. } else {
  8015. width = maxItemWidth;
  8016. }
  8017. }
  8018. return width;
  8019. }
  8020. };
  8021. _proto._adjustHorizontal = function _adjustHorizontal() {
  8022. var maxLength = this.maxLength,
  8023. itemsGroup = this.itemsGroup;
  8024. var children = itemsGroup.get('children');
  8025. var itemGap = this.itemGap,
  8026. itemMarginBottom = this.itemMarginBottom;
  8027. var titleHeight = this._titleHeight;
  8028. var row = 0;
  8029. var rowWidth = 0;
  8030. var width;
  8031. var height;
  8032. var itemWidth = this._getMaxItemWidth();
  8033. var legendHitBoxes = [];
  8034. for (var i = 0, len = children.length; i < len; i++) {
  8035. var child = children[i];
  8036. var box = child.getBBox();
  8037. var childHeight = box.height;
  8038. var childWidth = box.width;
  8039. width = itemWidth || childWidth;
  8040. height = childHeight + itemMarginBottom;
  8041. if (width - (maxLength - rowWidth) > 0.0001) {
  8042. row++;
  8043. rowWidth = 0;
  8044. }
  8045. child.moveTo(rowWidth, row * height);
  8046. legendHitBoxes.push({
  8047. x: rowWidth,
  8048. y: row * height + titleHeight - childHeight / 2,
  8049. width: childWidth * 1.375,
  8050. height: childHeight * 1.375
  8051. });
  8052. rowWidth += width + itemGap;
  8053. }
  8054. this.legendHitBoxes = legendHitBoxes;
  8055. return;
  8056. };
  8057. _proto._adjustVertical = function _adjustVertical() {
  8058. var maxLength = this.maxLength,
  8059. itemsGroup = this.itemsGroup;
  8060. var itemGap = this.itemGap,
  8061. itemMarginBottom = this.itemMarginBottom,
  8062. itemWidth = this.itemWidth;
  8063. var titleHeight = this._titleHeight;
  8064. var children = itemsGroup.get('children');
  8065. var colHeight = 0;
  8066. var width;
  8067. var height;
  8068. var maxItemWidth = 0;
  8069. var totalWidth = 0;
  8070. var legendHitBoxes = [];
  8071. for (var i = 0, length = children.length; i < length; i++) {
  8072. var child = children[i];
  8073. var bbox = child.getBBox();
  8074. width = bbox.width;
  8075. height = bbox.height;
  8076. if (Util.isNumber(itemWidth)) {
  8077. maxItemWidth = itemWidth + itemGap;
  8078. } else if (width > maxItemWidth) {
  8079. maxItemWidth = width + itemGap;
  8080. }
  8081. if (maxLength - colHeight < height) {
  8082. colHeight = 0;
  8083. totalWidth += maxItemWidth;
  8084. child.moveTo(totalWidth, 0);
  8085. legendHitBoxes.push({
  8086. x: totalWidth,
  8087. y: titleHeight - height / 2,
  8088. width: width * 1.375,
  8089. height: height * 1.375
  8090. });
  8091. } else {
  8092. child.moveTo(totalWidth, colHeight);
  8093. legendHitBoxes.push({
  8094. x: totalWidth,
  8095. y: colHeight - height / 2 + titleHeight,
  8096. width: width * 1.375,
  8097. height: height * 1.375
  8098. });
  8099. }
  8100. colHeight += height + itemMarginBottom;
  8101. }
  8102. this.legendHitBoxes = legendHitBoxes;
  8103. return;
  8104. };
  8105. _proto._adjustItems = function _adjustItems() {
  8106. var layout = this.layout;
  8107. if (layout === 'horizontal') {
  8108. this._adjustHorizontal();
  8109. } else {
  8110. this._adjustVertical();
  8111. }
  8112. };
  8113. _proto.moveTo = function moveTo(x, y) {
  8114. this.x = x;
  8115. this.y = y;
  8116. var container = this.container;
  8117. container && container.moveTo(x, y);
  8118. return this;
  8119. };
  8120. _proto.setItems = function setItems(items) {
  8121. this.clearItems();
  8122. this._renderItems(items);
  8123. };
  8124. _proto.setTitle = function setTitle(title) {
  8125. this._renderTitle(title);
  8126. };
  8127. _proto.clearItems = function clearItems() {
  8128. var itemsGroup = this.itemsGroup;
  8129. itemsGroup.clear();
  8130. };
  8131. _proto.getWidth = function getWidth() {
  8132. var container = this.container;
  8133. var bbox = container.getBBox();
  8134. return bbox.width;
  8135. };
  8136. _proto.getHeight = function getHeight() {
  8137. var container = this.container;
  8138. var bbox = container.getBBox();
  8139. return bbox.height;
  8140. };
  8141. _proto.show = function show() {
  8142. var container = this.container;
  8143. container.show();
  8144. };
  8145. _proto.hide = function hide() {
  8146. var container = this.container;
  8147. container.hide();
  8148. };
  8149. _proto.clear = function clear() {
  8150. var container = this.container;
  8151. container.clear();
  8152. container.remove(true);
  8153. };
  8154. return List;
  8155. }();
  8156. module.exports = List;
  8157. /***/ }),
  8158. /* 92 */
  8159. /***/ (function(module, exports, __webpack_require__) {
  8160. /**
  8161. * Animate configuration and register
  8162. * @author sima.zhang1990@gmail.com
  8163. */
  8164. var Util = __webpack_require__(0);
  8165. var defaultAnimationCfg = {
  8166. appear: {
  8167. duration: 450,
  8168. easing: 'quadraticOut'
  8169. },
  8170. // 'appear' animation options
  8171. update: {
  8172. duration: 300,
  8173. easing: 'quadraticOut'
  8174. },
  8175. // 'update' animation options
  8176. enter: {
  8177. duration: 300,
  8178. easing: 'quadraticOut'
  8179. },
  8180. // 'enter' animation options
  8181. leave: {
  8182. duration: 350,
  8183. easing: 'quadraticIn' // 'leave' animation options
  8184. }
  8185. };
  8186. var Animate = {
  8187. defaultCfg: {},
  8188. Action: {},
  8189. getAnimation: function getAnimation(geomType, coord, animationType) {
  8190. var geomAnimateCfg = this.defaultCfg[geomType];
  8191. if (geomAnimateCfg) {
  8192. var animation = geomAnimateCfg[animationType];
  8193. if (Util.isFunction(animation)) {
  8194. return animation(coord);
  8195. }
  8196. }
  8197. return false;
  8198. },
  8199. getAnimateCfg: function getAnimateCfg(geomType, animationType) {
  8200. var defaultCfg = defaultAnimationCfg[animationType];
  8201. var geomConfig = this.defaultCfg[geomType];
  8202. if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
  8203. return Util.deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
  8204. }
  8205. return defaultCfg;
  8206. },
  8207. registerAnimation: function registerAnimation(animationName, animationFun) {
  8208. if (!this.Action) {
  8209. this.Action = {};
  8210. }
  8211. this.Action[animationName] = animationFun;
  8212. }
  8213. };
  8214. module.exports = Animate;
  8215. /***/ }),
  8216. /* 93 */
  8217. /***/ (function(module, exports, __webpack_require__) {
  8218. /**
  8219. * Utility
  8220. * @author sima.zhang1990@gmail.com
  8221. */
  8222. var _require = __webpack_require__(5),
  8223. Matrix = _require.Matrix;
  8224. var Util = __webpack_require__(0);
  8225. var Helpers = {
  8226. getCoordInfo: function getCoordInfo(coord) {
  8227. var start = coord.start;
  8228. var end = coord.end;
  8229. return {
  8230. start: start,
  8231. end: end,
  8232. width: end.x - start.x,
  8233. height: Math.abs(end.y - start.y)
  8234. };
  8235. },
  8236. getScaledMatrix: function getScaledMatrix(shape, v, direct) {
  8237. var scaledMatrix;
  8238. shape.apply(v);
  8239. var x = v[0];
  8240. var y = v[1];
  8241. if (direct === 'x') {
  8242. shape.transform([['t', x, y], ['s', 0.01, 1], ['t', -x, -y]]);
  8243. var matrix = shape.getMatrix();
  8244. scaledMatrix = Matrix.transform(matrix, [['t', x, y], ['s', 100, 1], ['t', -x, -y]]);
  8245. } else if (direct === 'y') {
  8246. shape.transform([['t', x, y], ['s', 1, 0.01], ['t', -x, -y]]);
  8247. var _matrix = shape.getMatrix();
  8248. scaledMatrix = Matrix.transform(_matrix, [['t', x, y], ['s', 1, 100], ['t', -x, -y]]);
  8249. } else if (direct === 'xy') {
  8250. shape.transform([['t', x, y], ['s', 0.01, 0.01], ['t', -x, -y]]);
  8251. var _matrix2 = shape.getMatrix();
  8252. scaledMatrix = Matrix.transform(_matrix2, [['t', x, y], ['s', 100, 100], ['t', -x, -y]]);
  8253. }
  8254. return scaledMatrix;
  8255. },
  8256. getAnimateParam: function getAnimateParam(animateCfg, index, id) {
  8257. var result = {};
  8258. if (animateCfg.delay) {
  8259. result.delay = Util.isFunction(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
  8260. }
  8261. result.easing = animateCfg.easing;
  8262. result.duration = animateCfg.duration;
  8263. result.delay = animateCfg.delay;
  8264. return result;
  8265. },
  8266. doAnimation: function doAnimation(shape, endState, animateCfg, callback) {
  8267. var id = shape._id;
  8268. var index = shape.get('index');
  8269. var _Helpers$getAnimatePa = Helpers.getAnimateParam(animateCfg, index, id),
  8270. easing = _Helpers$getAnimatePa.easing,
  8271. delay = _Helpers$getAnimatePa.delay,
  8272. duration = _Helpers$getAnimatePa.duration;
  8273. var anim = shape.animate().to({
  8274. attrs: endState,
  8275. duration: duration,
  8276. delay: delay,
  8277. easing: easing
  8278. });
  8279. if (callback) {
  8280. anim.onEnd(function () {
  8281. callback();
  8282. });
  8283. }
  8284. }
  8285. };
  8286. module.exports = Helpers;
  8287. /***/ }),
  8288. /* 94 */,
  8289. /* 95 */
  8290. /***/ (function(module, exports, __webpack_require__) {
  8291. var Geom = __webpack_require__(6);
  8292. __webpack_require__(96);
  8293. __webpack_require__(38);
  8294. __webpack_require__(80);
  8295. __webpack_require__(98);
  8296. __webpack_require__(81);
  8297. __webpack_require__(100);
  8298. __webpack_require__(102);
  8299. module.exports = Geom;
  8300. /***/ }),
  8301. /* 96 */
  8302. /***/ (function(module, exports, __webpack_require__) {
  8303. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8304. var Util = __webpack_require__(0);
  8305. var Geom = __webpack_require__(6);
  8306. __webpack_require__(97);
  8307. var Point =
  8308. /*#__PURE__*/
  8309. function (_Geom) {
  8310. _inheritsLoose(Point, _Geom);
  8311. function Point() {
  8312. return _Geom.apply(this, arguments) || this;
  8313. }
  8314. var _proto = Point.prototype;
  8315. _proto.getDefaultCfg = function getDefaultCfg() {
  8316. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  8317. cfg.type = 'point';
  8318. cfg.shapeType = 'point';
  8319. cfg.generatePoints = true;
  8320. return cfg;
  8321. };
  8322. _proto.draw = function draw(data, shapeFactory) {
  8323. var self = this;
  8324. var container = self.get('container');
  8325. Util.each(data, function (obj) {
  8326. var shape = obj.shape;
  8327. var cfg = self.getDrawCfg(obj);
  8328. if (Util.isArray(obj.y)) {
  8329. var hasStack = self.hasAdjust('stack');
  8330. Util.each(obj.y, function (y, idx) {
  8331. cfg.y = y;
  8332. if (!hasStack || idx !== 0) {
  8333. self.drawShape(shape, obj, cfg, container, shapeFactory);
  8334. }
  8335. });
  8336. } else if (!Util.isNil(obj.y)) {
  8337. self.drawShape(shape, obj, cfg, container, shapeFactory);
  8338. }
  8339. });
  8340. };
  8341. return Point;
  8342. }(Geom);
  8343. Geom.Point = Point;
  8344. module.exports = Point;
  8345. /***/ }),
  8346. /* 97 */
  8347. /***/ (function(module, exports, __webpack_require__) {
  8348. var Util = __webpack_require__(0);
  8349. var Global = __webpack_require__(1);
  8350. var ShapeUtil = __webpack_require__(20);
  8351. var Shape = __webpack_require__(9);
  8352. var SHAPES = ['circle', 'hollowCircle', 'rect'];
  8353. var Point = Shape.registerFactory('point', {
  8354. defaultShapeType: 'circle',
  8355. getDefaultPoints: function getDefaultPoints(pointInfo) {
  8356. return ShapeUtil.splitPoints(pointInfo);
  8357. }
  8358. });
  8359. function getPointsCfg(cfg) {
  8360. var style = {
  8361. lineWidth: 0,
  8362. stroke: cfg.color,
  8363. fill: cfg.color
  8364. };
  8365. if (cfg.size) {
  8366. style.size = cfg.size;
  8367. }
  8368. Util.mix(style, cfg.style);
  8369. return Util.mix({}, Global.shape.point, style);
  8370. }
  8371. function drawShape(cfg, container, shape) {
  8372. if (cfg.size === 0) return;
  8373. var pointCfg = getPointsCfg(cfg);
  8374. var size = pointCfg.r || pointCfg.size;
  8375. var x = cfg.x;
  8376. var y = !Util.isArray(cfg.y) ? [cfg.y] : cfg.y;
  8377. if (shape === 'hollowCircle') {
  8378. pointCfg.lineWidth = 1;
  8379. pointCfg.fill = null;
  8380. }
  8381. for (var i = 0, len = y.length; i < len; i++) {
  8382. if (shape === 'rect') {
  8383. return container.addShape('Rect', {
  8384. className: 'point',
  8385. attrs: Util.mix({
  8386. x: x - size,
  8387. y: y[i] - size,
  8388. width: size * 2,
  8389. height: size * 2
  8390. }, pointCfg)
  8391. });
  8392. }
  8393. return container.addShape('Circle', {
  8394. className: 'point',
  8395. attrs: Util.mix({
  8396. x: x,
  8397. y: y[i],
  8398. r: size
  8399. }, pointCfg)
  8400. });
  8401. }
  8402. }
  8403. Util.each(SHAPES, function (shapeType) {
  8404. Shape.registerShape('point', shapeType, {
  8405. draw: function draw(cfg, container) {
  8406. return drawShape(cfg, container, shapeType);
  8407. }
  8408. });
  8409. });
  8410. module.exports = Point;
  8411. /***/ }),
  8412. /* 98 */
  8413. /***/ (function(module, exports, __webpack_require__) {
  8414. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8415. /**
  8416. * @fileOverview area geometry
  8417. * @author dxq613 @gmail.com
  8418. * @author sima.zhang1990@gmail.com
  8419. */
  8420. var Geom = __webpack_require__(6);
  8421. var ShapeUtil = __webpack_require__(20);
  8422. var Util = __webpack_require__(0);
  8423. __webpack_require__(99);
  8424. var Area =
  8425. /*#__PURE__*/
  8426. function (_Geom) {
  8427. _inheritsLoose(Area, _Geom);
  8428. function Area() {
  8429. return _Geom.apply(this, arguments) || this;
  8430. }
  8431. var _proto = Area.prototype;
  8432. /**
  8433. * get the default configuration
  8434. * @protected
  8435. * @return {Object} return the result
  8436. */
  8437. _proto.getDefaultCfg = function getDefaultCfg() {
  8438. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  8439. cfg.type = 'area';
  8440. cfg.shapeType = 'area';
  8441. cfg.generatePoints = true;
  8442. cfg.sortable = true;
  8443. return cfg;
  8444. };
  8445. _proto.draw = function draw(data, shapeFactory) {
  8446. var self = this;
  8447. var container = self.get('container');
  8448. var cfg = this.getDrawCfg(data[0]);
  8449. var yScale = self.getYScale();
  8450. var connectNulls = self.get('connectNulls');
  8451. var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
  8452. cfg.origin = data;
  8453. Util.each(splitArray, function (subData, splitedIndex) {
  8454. cfg.splitedIndex = splitedIndex;
  8455. var points = subData.map(function (obj) {
  8456. return obj.points;
  8457. });
  8458. cfg.points = points;
  8459. self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
  8460. });
  8461. };
  8462. return Area;
  8463. }(Geom);
  8464. Geom.Area = Area;
  8465. module.exports = Area;
  8466. /***/ }),
  8467. /* 99 */
  8468. /***/ (function(module, exports, __webpack_require__) {
  8469. var Util = __webpack_require__(0);
  8470. var Shape = __webpack_require__(9);
  8471. var Smooth = __webpack_require__(37);
  8472. var bbox = __webpack_require__(11);
  8473. var Global = __webpack_require__(1);
  8474. function equals(v1, v2) {
  8475. return Math.abs(v1 - v2) < 0.00001;
  8476. }
  8477. function notEmpty(value) {
  8478. return !isNaN(value) && !Util.isNil(value);
  8479. }
  8480. function filterPoints(points) {
  8481. var filteredPoints = []; // filter the point which x or y is NaN
  8482. for (var i = 0, len = points.length; i < len; i++) {
  8483. var point = points[i];
  8484. if (notEmpty(point.x) && notEmpty(point.y)) {
  8485. filteredPoints.push(point);
  8486. }
  8487. }
  8488. return filteredPoints;
  8489. }
  8490. function equalsCenter(points, center) {
  8491. var eqls = true;
  8492. Util.each(points, function (point) {
  8493. if (!equals(point.x, center.x) || !equals(point.y, center.y)) {
  8494. eqls = false;
  8495. return false;
  8496. }
  8497. });
  8498. return eqls;
  8499. }
  8500. function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
  8501. var shape;
  8502. var points = topPoints.concat(bottomPoints);
  8503. if (isSmooth) {
  8504. shape = container.addShape('Custom', {
  8505. className: 'area',
  8506. attrs: Util.mix({
  8507. points: points
  8508. }, style),
  8509. createPath: function createPath(context) {
  8510. var constaint = [[0, 0], [1, 1]];
  8511. var points = filterPoints(this._attrs.attrs.points);
  8512. var pointsLen = points.length;
  8513. var topPoints = points.slice(0, pointsLen / 2);
  8514. var bottomPoints = points.slice(pointsLen / 2, pointsLen);
  8515. var topSps = Smooth.smooth(topPoints, false, constaint);
  8516. context.beginPath();
  8517. context.moveTo(topPoints[0].x, topPoints[0].y);
  8518. for (var i = 0, n = topSps.length; i < n; i++) {
  8519. var sp = topSps[i];
  8520. context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
  8521. }
  8522. if (bottomPoints.length) {
  8523. var bottomSps = Smooth.smooth(bottomPoints, false, constaint);
  8524. context.lineTo(bottomPoints[0].x, bottomPoints[0].y);
  8525. for (var _i = 0, _n = bottomSps.length; _i < _n; _i++) {
  8526. var _sp = bottomSps[_i];
  8527. context.bezierCurveTo(_sp[1], _sp[2], _sp[3], _sp[4], _sp[5], _sp[6]);
  8528. }
  8529. }
  8530. context.closePath();
  8531. },
  8532. calculateBox: function calculateBox() {
  8533. var points = filterPoints(this._attrs.attrs.points);
  8534. return bbox.getBBoxFromPoints(points);
  8535. }
  8536. });
  8537. } else {
  8538. shape = container.addShape('Polyline', {
  8539. className: 'area',
  8540. attrs: Util.mix({
  8541. points: points
  8542. }, style)
  8543. });
  8544. }
  8545. return shape;
  8546. }
  8547. function drawShape(cfg, container, isSmooth) {
  8548. var self = this;
  8549. var points = cfg.points;
  8550. var topPoints = [];
  8551. var bottomPoints = [];
  8552. Util.each(points, function (point) {
  8553. bottomPoints.push(point[0]);
  8554. topPoints.push(point[1]);
  8555. });
  8556. var style = Util.mix({
  8557. fillStyle: cfg.color
  8558. }, Global.shape.area, cfg.style);
  8559. bottomPoints.reverse();
  8560. topPoints = self.parsePoints(topPoints);
  8561. bottomPoints = self.parsePoints(bottomPoints);
  8562. if (cfg.isInCircle) {
  8563. topPoints.push(topPoints[0]);
  8564. bottomPoints.unshift(bottomPoints[bottomPoints.length - 1]);
  8565. if (equalsCenter(bottomPoints, cfg.center)) {
  8566. bottomPoints = [];
  8567. }
  8568. }
  8569. return drawRectShape(topPoints, bottomPoints, container, style, isSmooth);
  8570. }
  8571. var Area = Shape.registerFactory('area', {
  8572. defaultShapeType: 'area',
  8573. getDefaultPoints: function getDefaultPoints(obj) {
  8574. var x = obj.x;
  8575. var y = obj.y;
  8576. var y0 = obj.y0;
  8577. y = Util.isArray(y) ? y : [y0, y];
  8578. var points = [];
  8579. points.push({
  8580. x: x,
  8581. y: y[0]
  8582. }, {
  8583. x: x,
  8584. y: y[1]
  8585. });
  8586. return points;
  8587. }
  8588. });
  8589. var SHAPES = ['area', 'smooth'];
  8590. Util.each(SHAPES, function (shapeType) {
  8591. Shape.registerShape('area', shapeType, {
  8592. draw: function draw(cfg, container) {
  8593. var smooth = shapeType === 'smooth';
  8594. return drawShape.call(this, cfg, container, smooth);
  8595. }
  8596. });
  8597. });
  8598. module.exports = Area;
  8599. /***/ }),
  8600. /* 100 */
  8601. /***/ (function(module, exports, __webpack_require__) {
  8602. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8603. var Geom = __webpack_require__(6);
  8604. var Util = __webpack_require__(0);
  8605. __webpack_require__(101);
  8606. var Polygon =
  8607. /*#__PURE__*/
  8608. function (_Geom) {
  8609. _inheritsLoose(Polygon, _Geom);
  8610. function Polygon() {
  8611. return _Geom.apply(this, arguments) || this;
  8612. }
  8613. var _proto = Polygon.prototype;
  8614. _proto.getDefaultCfg = function getDefaultCfg() {
  8615. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  8616. cfg.type = 'polygon';
  8617. cfg.shapeType = 'polygon';
  8618. cfg.generatePoints = true;
  8619. return cfg;
  8620. };
  8621. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  8622. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  8623. var self = this;
  8624. var x = cfg.x;
  8625. var y = cfg.y;
  8626. var temp;
  8627. if (!(Util.isArray(x) && Util.isArray(y))) {
  8628. var xScale = self.getXScale();
  8629. var yScale = self.getYScale();
  8630. var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
  8631. var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
  8632. var xOffset = 0.5 * 1 / xCount;
  8633. var yOffset = 0.5 * 1 / yCount;
  8634. if (xScale.isCategory && yScale.isCategory) {
  8635. x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
  8636. y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
  8637. } else if (Util.isArray(x)) {
  8638. temp = x;
  8639. x = [temp[0], temp[0], temp[1], temp[1]];
  8640. y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
  8641. } else if (Util.isArray(y)) {
  8642. temp = y;
  8643. y = [temp[0], temp[1], temp[1], temp[0]];
  8644. x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
  8645. }
  8646. cfg.x = x;
  8647. cfg.y = y;
  8648. }
  8649. return cfg;
  8650. };
  8651. return Polygon;
  8652. }(Geom);
  8653. Geom.Polygon = Polygon;
  8654. module.exports = Polygon;
  8655. /***/ }),
  8656. /* 101 */
  8657. /***/ (function(module, exports, __webpack_require__) {
  8658. var Shape = __webpack_require__(9);
  8659. var Util = __webpack_require__(0);
  8660. var Polygon = Shape.registerFactory('polygon', {
  8661. defaultShapeType: 'polygon',
  8662. getDefaultPoints: function getDefaultPoints(pointInfo) {
  8663. var points = [];
  8664. var x = pointInfo.x,
  8665. y = pointInfo.y;
  8666. for (var i = 0, len = x.length; i < len; i++) {
  8667. points.push({
  8668. x: x[i],
  8669. y: y[i]
  8670. });
  8671. }
  8672. return points;
  8673. }
  8674. });
  8675. Shape.registerShape('polygon', 'polygon', {
  8676. draw: function draw(cfg, container) {
  8677. var points = this.parsePoints(cfg.points);
  8678. var style = Util.mix({
  8679. fill: cfg.color,
  8680. points: points
  8681. }, cfg.style);
  8682. return container.addShape('Polygon', {
  8683. className: 'polygon',
  8684. attrs: style
  8685. });
  8686. }
  8687. });
  8688. module.exports = Polygon;
  8689. /***/ }),
  8690. /* 102 */
  8691. /***/ (function(module, exports, __webpack_require__) {
  8692. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8693. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  8694. var Geom = __webpack_require__(6);
  8695. var Util = __webpack_require__(0);
  8696. var SizeMixin = __webpack_require__(39);
  8697. __webpack_require__(103);
  8698. var Schema =
  8699. /*#__PURE__*/
  8700. function (_Geom) {
  8701. _inheritsLoose(Schema, _Geom);
  8702. var _proto = Schema.prototype;
  8703. _proto.getDefaultCfg = function getDefaultCfg() {
  8704. var cfg = _Geom.prototype.getDefaultCfg.call(this);
  8705. cfg.type = 'schema';
  8706. cfg.shapeType = 'schema';
  8707. cfg.generatePoints = true;
  8708. return cfg;
  8709. };
  8710. function Schema(cfg) {
  8711. var _this;
  8712. _this = _Geom.call(this, cfg) || this;
  8713. Util.mix(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
  8714. return _this;
  8715. }
  8716. _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
  8717. var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
  8718. cfg.size = this.getNormalizedSize(obj);
  8719. return cfg;
  8720. };
  8721. _proto.clearInner = function clearInner() {
  8722. _Geom.prototype.clearInner.call(this);
  8723. this.set('defaultSize', null);
  8724. };
  8725. return Schema;
  8726. }(Geom);
  8727. Geom.Schema = Schema;
  8728. module.exports = Schema;
  8729. /***/ }),
  8730. /* 103 */
  8731. /***/ (function(module, exports, __webpack_require__) {
  8732. var Shape = __webpack_require__(9);
  8733. var Util = __webpack_require__(0);
  8734. function _sortValue(value) {
  8735. var sorted = value.sort(function (a, b) {
  8736. return a < b ? 1 : -1;
  8737. });
  8738. var length = sorted.length;
  8739. if (length < 4) {
  8740. var min = sorted[length - 1];
  8741. for (var i = 0; i < 4 - length; i++) {
  8742. sorted.push(min);
  8743. }
  8744. }
  8745. return sorted;
  8746. } // from left bottom corner, and clockwise
  8747. function getCandlePoints(x, y, width) {
  8748. var yValues = _sortValue(y);
  8749. var points = [{
  8750. x: x,
  8751. y: yValues[0]
  8752. }, {
  8753. x: x,
  8754. y: yValues[1]
  8755. }, {
  8756. x: x - width / 2,
  8757. y: yValues[2]
  8758. }, {
  8759. x: x - width / 2,
  8760. y: yValues[1]
  8761. }, {
  8762. x: x + width / 2,
  8763. y: yValues[1]
  8764. }, {
  8765. x: x + width / 2,
  8766. y: yValues[2]
  8767. }, {
  8768. x: x,
  8769. y: yValues[2]
  8770. }, {
  8771. x: x,
  8772. y: yValues[3]
  8773. }];
  8774. return points;
  8775. }
  8776. var Schema = Shape.registerFactory('schema', {});
  8777. Shape.registerShape('schema', 'candle', {
  8778. getPoints: function getPoints(cfg) {
  8779. return getCandlePoints(cfg.x, cfg.y, cfg.size);
  8780. },
  8781. draw: function draw(cfg, container) {
  8782. var points = this.parsePoints(cfg.points);
  8783. var style = Util.mix({
  8784. stroke: cfg.color,
  8785. fill: cfg.color,
  8786. lineWidth: 1
  8787. }, cfg.style);
  8788. return container.addShape('Custom', {
  8789. className: 'schema',
  8790. attrs: style,
  8791. createPath: function createPath(ctx) {
  8792. ctx.beginPath();
  8793. ctx.moveTo(points[0].x, points[0].y);
  8794. ctx.lineTo(points[1].x, points[1].y);
  8795. ctx.moveTo(points[2].x, points[2].y);
  8796. for (var i = 3; i < 6; i++) {
  8797. ctx.lineTo(points[i].x, points[i].y);
  8798. }
  8799. ctx.closePath();
  8800. ctx.moveTo(points[6].x, points[6].y);
  8801. ctx.lineTo(points[7].x, points[7].y);
  8802. }
  8803. });
  8804. }
  8805. });
  8806. module.exports = Schema;
  8807. /***/ }),
  8808. /* 104 */
  8809. /***/ (function(module, exports, __webpack_require__) {
  8810. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  8811. var Util = __webpack_require__(0);
  8812. var Abstract = __webpack_require__(24);
  8813. var Circle =
  8814. /*#__PURE__*/
  8815. function (_Abstract) {
  8816. _inheritsLoose(Circle, _Abstract);
  8817. function Circle() {
  8818. return _Abstract.apply(this, arguments) || this;
  8819. }
  8820. var _proto = Circle.prototype;
  8821. _proto._initDefaultCfg = function _initDefaultCfg() {
  8822. _Abstract.prototype._initDefaultCfg.call(this);
  8823. this.startAngle = -Math.PI / 2; // start angle,in radian
  8824. this.endAngle = Math.PI * 3 / 2; // end angle, in radian
  8825. this.radius = null; // radius
  8826. this.center = null; // center
  8827. };
  8828. _proto.getOffsetPoint = function getOffsetPoint(value) {
  8829. var startAngle = this.startAngle,
  8830. endAngle = this.endAngle;
  8831. var angle = startAngle + (endAngle - startAngle) * value;
  8832. return this._getCirclePoint(angle);
  8833. };
  8834. _proto._getCirclePoint = function _getCirclePoint(angle, radius) {
  8835. var self = this;
  8836. var center = self.center;
  8837. radius = radius || self.radius;
  8838. return {
  8839. x: center.x + Math.cos(angle) * radius,
  8840. y: center.y + Math.sin(angle) * radius
  8841. };
  8842. };
  8843. _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
  8844. var self = this;
  8845. var offsetVector = self.getOffsetVector(point, offset);
  8846. var align;
  8847. var baseLine = 'middle';
  8848. if (offsetVector[0] > 0) {
  8849. align = 'left';
  8850. } else if (offsetVector[0] < 0) {
  8851. align = 'right';
  8852. } else {
  8853. align = 'center';
  8854. if (offsetVector[1] > 0) {
  8855. baseLine = 'top';
  8856. } else if (offsetVector[1] < 0) {
  8857. baseLine = 'bottom';
  8858. }
  8859. }
  8860. return {
  8861. textAlign: align,
  8862. textBaseline: baseLine
  8863. };
  8864. };
  8865. _proto.getAxisVector = function getAxisVector(point) {
  8866. var center = this.center;
  8867. var factor = this.offsetFactor;
  8868. return [(point.y - center.y) * factor, (point.x - center.x) * -1 * factor];
  8869. };
  8870. _proto.drawLine = function drawLine(lineCfg) {
  8871. var center = this.center,
  8872. radius = this.radius,
  8873. startAngle = this.startAngle,
  8874. endAngle = this.endAngle;
  8875. var container = this.getContainer(lineCfg.top);
  8876. container.addShape('arc', {
  8877. className: 'axis-line',
  8878. attrs: Util.mix({
  8879. x: center.x,
  8880. y: center.y,
  8881. r: radius,
  8882. startAngle: startAngle,
  8883. endAngle: endAngle
  8884. }, lineCfg)
  8885. });
  8886. };
  8887. return Circle;
  8888. }(Abstract);
  8889. Abstract.Circle = Circle;
  8890. module.exports = Circle;
  8891. /***/ }),
  8892. /* 105 */
  8893. /***/ (function(module, exports, __webpack_require__) {
  8894. var TimeCat = __webpack_require__(106);
  8895. module.exports = TimeCat;
  8896. /***/ }),
  8897. /* 106 */
  8898. /***/ (function(module, exports, __webpack_require__) {
  8899. function _inheritsLoose(subClass, superClass) {
  8900. subClass.prototype = Object.create(superClass.prototype);
  8901. subClass.prototype.constructor = subClass;
  8902. subClass.__proto__ = superClass;
  8903. }
  8904. /**
  8905. * @fileOverview 时间数据作为分类类型
  8906. * @author dxq613@gmail.com
  8907. */
  8908. var Base = __webpack_require__(14);
  8909. var Category = __webpack_require__(34);
  8910. var fecha = __webpack_require__(107);
  8911. var catAuto = __webpack_require__(35);
  8912. var TimeUtil = __webpack_require__(89);
  8913. var each = __webpack_require__(3);
  8914. var isNumber = __webpack_require__(13);
  8915. var isObject = __webpack_require__(18);
  8916. var isString = __webpack_require__(15);
  8917. /**
  8918. * 度量的构造函数
  8919. * @class Scale.TimeCategory
  8920. */
  8921. var TimeCategory =
  8922. /*#__PURE__*/
  8923. function (_Category) {
  8924. _inheritsLoose(TimeCategory, _Category);
  8925. function TimeCategory() {
  8926. return _Category.apply(this, arguments) || this;
  8927. }
  8928. var _proto = TimeCategory.prototype;
  8929. _proto._initDefaultCfg = function _initDefaultCfg() {
  8930. _Category.prototype._initDefaultCfg.call(this);
  8931. this.type = 'timeCat';
  8932. /**
  8933. * 是否需要排序,默认进行排序
  8934. * @type {Boolean}
  8935. */
  8936. this.sortable = true;
  8937. this.tickCount = 5;
  8938. /**
  8939. * 时间格式化
  8940. * @type {String}
  8941. */
  8942. this.mask = 'YYYY-MM-DD';
  8943. };
  8944. _proto.init = function init() {
  8945. var self = this;
  8946. var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳
  8947. each(values, function (v, i) {
  8948. values[i] = self._toTimeStamp(v);
  8949. });
  8950. if (this.sortable) {
  8951. // 允许排序
  8952. values.sort(function (v1, v2) {
  8953. return v1 - v2;
  8954. });
  8955. }
  8956. if (!self.ticks) {
  8957. self.ticks = this.calculateTicks();
  8958. }
  8959. };
  8960. /**
  8961. * 计算 ticks
  8962. * @return {array} 返回 ticks 数组
  8963. */
  8964. _proto.calculateTicks = function calculateTicks() {
  8965. var self = this;
  8966. var count = self.tickCount;
  8967. var ticks;
  8968. if (count) {
  8969. var temp = catAuto({
  8970. maxCount: count,
  8971. data: self.values,
  8972. isRounding: self.isRounding
  8973. });
  8974. ticks = temp.ticks;
  8975. } else {
  8976. ticks = self.values;
  8977. }
  8978. return ticks;
  8979. };
  8980. /**
  8981. * @override
  8982. */
  8983. _proto.translate = function translate(value) {
  8984. value = this._toTimeStamp(value);
  8985. var index = this.values.indexOf(value);
  8986. if (index === -1) {
  8987. if (isNumber(value) && value < this.values.length) {
  8988. index = value;
  8989. } else {
  8990. index = NaN;
  8991. }
  8992. }
  8993. return index;
  8994. };
  8995. /**
  8996. * @override
  8997. */
  8998. _proto.scale = function scale(value) {
  8999. var rangeMin = this.rangeMin();
  9000. var rangeMax = this.rangeMax();
  9001. var index = this.translate(value);
  9002. var percent;
  9003. if (this.values.length === 1 || isNaN(index)) {
  9004. // is index is NAN should not be set as 0
  9005. percent = index;
  9006. } else if (index > -1) {
  9007. percent = index / (this.values.length - 1);
  9008. } else {
  9009. percent = 0;
  9010. }
  9011. return rangeMin + percent * (rangeMax - rangeMin);
  9012. };
  9013. /**
  9014. * @override
  9015. */
  9016. _proto.getText = function getText(value) {
  9017. var result = '';
  9018. var index = this.translate(value);
  9019. if (index > -1) {
  9020. result = this.values[index];
  9021. } else {
  9022. result = value;
  9023. }
  9024. var formatter = this.formatter;
  9025. result = parseInt(result, 10);
  9026. result = formatter ? formatter(result) : fecha.format(result, this.mask);
  9027. return result;
  9028. };
  9029. /**
  9030. * @override
  9031. */
  9032. _proto.getTicks = function getTicks() {
  9033. var self = this;
  9034. var ticks = this.ticks;
  9035. var rst = [];
  9036. each(ticks, function (tick) {
  9037. var obj;
  9038. if (isObject(tick)) {
  9039. obj = tick;
  9040. } else {
  9041. obj = {
  9042. text: isString(tick) ? tick : self.getText(tick),
  9043. value: self.scale(tick),
  9044. tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
  9045. };
  9046. }
  9047. rst.push(obj);
  9048. });
  9049. return rst;
  9050. }; // 将时间转换为时间戳
  9051. _proto._toTimeStamp = function _toTimeStamp(value) {
  9052. return TimeUtil.toTimeStamp(value);
  9053. };
  9054. return TimeCategory;
  9055. }(Category);
  9056. Base.TimeCat = TimeCategory;
  9057. module.exports = TimeCategory;
  9058. /***/ }),
  9059. /* 107 */
  9060. /***/ (function(module, exports, __webpack_require__) {
  9061. var __WEBPACK_AMD_DEFINE_RESULT__;(function (main) {
  9062. 'use strict';
  9063. /**
  9064. * Parse or format dates
  9065. * @class fecha
  9066. */
  9067. var fecha = {};
  9068. var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
  9069. var twoDigits = /\d\d?/;
  9070. var threeDigits = /\d{3}/;
  9071. var fourDigits = /\d{4}/;
  9072. var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
  9073. var literal = /\[([^]*?)\]/gm;
  9074. var noop = function () {};
  9075. function shorten(arr, sLen) {
  9076. var newArr = [];
  9077. for (var i = 0, len = arr.length; i < len; i++) {
  9078. newArr.push(arr[i].substr(0, sLen));
  9079. }
  9080. return newArr;
  9081. }
  9082. function monthUpdate(arrName) {
  9083. return function (d, v, i18n) {
  9084. var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
  9085. if (~index) {
  9086. d.month = index;
  9087. }
  9088. };
  9089. }
  9090. function pad(val, len) {
  9091. val = String(val);
  9092. len = len || 2;
  9093. while (val.length < len) {
  9094. val = '0' + val;
  9095. }
  9096. return val;
  9097. }
  9098. var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
  9099. var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
  9100. var monthNamesShort = shorten(monthNames, 3);
  9101. var dayNamesShort = shorten(dayNames, 3);
  9102. fecha.i18n = {
  9103. dayNamesShort: dayNamesShort,
  9104. dayNames: dayNames,
  9105. monthNamesShort: monthNamesShort,
  9106. monthNames: monthNames,
  9107. amPm: ['am', 'pm'],
  9108. DoFn: function DoFn(D) {
  9109. return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
  9110. }
  9111. };
  9112. var formatFlags = {
  9113. D: function (dateObj) {
  9114. return dateObj.getDate();
  9115. },
  9116. DD: function (dateObj) {
  9117. return pad(dateObj.getDate());
  9118. },
  9119. Do: function (dateObj, i18n) {
  9120. return i18n.DoFn(dateObj.getDate());
  9121. },
  9122. d: function (dateObj) {
  9123. return dateObj.getDay();
  9124. },
  9125. dd: function (dateObj) {
  9126. return pad(dateObj.getDay());
  9127. },
  9128. ddd: function (dateObj, i18n) {
  9129. return i18n.dayNamesShort[dateObj.getDay()];
  9130. },
  9131. dddd: function (dateObj, i18n) {
  9132. return i18n.dayNames[dateObj.getDay()];
  9133. },
  9134. M: function (dateObj) {
  9135. return dateObj.getMonth() + 1;
  9136. },
  9137. MM: function (dateObj) {
  9138. return pad(dateObj.getMonth() + 1);
  9139. },
  9140. MMM: function (dateObj, i18n) {
  9141. return i18n.monthNamesShort[dateObj.getMonth()];
  9142. },
  9143. MMMM: function (dateObj, i18n) {
  9144. return i18n.monthNames[dateObj.getMonth()];
  9145. },
  9146. YY: function (dateObj) {
  9147. return String(dateObj.getFullYear()).substr(2);
  9148. },
  9149. YYYY: function (dateObj) {
  9150. return pad(dateObj.getFullYear(), 4);
  9151. },
  9152. h: function (dateObj) {
  9153. return dateObj.getHours() % 12 || 12;
  9154. },
  9155. hh: function (dateObj) {
  9156. return pad(dateObj.getHours() % 12 || 12);
  9157. },
  9158. H: function (dateObj) {
  9159. return dateObj.getHours();
  9160. },
  9161. HH: function (dateObj) {
  9162. return pad(dateObj.getHours());
  9163. },
  9164. m: function (dateObj) {
  9165. return dateObj.getMinutes();
  9166. },
  9167. mm: function (dateObj) {
  9168. return pad(dateObj.getMinutes());
  9169. },
  9170. s: function (dateObj) {
  9171. return dateObj.getSeconds();
  9172. },
  9173. ss: function (dateObj) {
  9174. return pad(dateObj.getSeconds());
  9175. },
  9176. S: function (dateObj) {
  9177. return Math.round(dateObj.getMilliseconds() / 100);
  9178. },
  9179. SS: function (dateObj) {
  9180. return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
  9181. },
  9182. SSS: function (dateObj) {
  9183. return pad(dateObj.getMilliseconds(), 3);
  9184. },
  9185. a: function (dateObj, i18n) {
  9186. return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
  9187. },
  9188. A: function (dateObj, i18n) {
  9189. return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
  9190. },
  9191. ZZ: function (dateObj) {
  9192. var o = dateObj.getTimezoneOffset();
  9193. return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
  9194. }
  9195. };
  9196. var parseFlags = {
  9197. D: [twoDigits, function (d, v) {
  9198. d.day = v;
  9199. }],
  9200. Do: [new RegExp(twoDigits.source + word.source), function (d, v) {
  9201. d.day = parseInt(v, 10);
  9202. }],
  9203. M: [twoDigits, function (d, v) {
  9204. d.month = v - 1;
  9205. }],
  9206. YY: [twoDigits, function (d, v) {
  9207. var da = new Date(),
  9208. cent = +('' + da.getFullYear()).substr(0, 2);
  9209. d.year = '' + (v > 68 ? cent - 1 : cent) + v;
  9210. }],
  9211. h: [twoDigits, function (d, v) {
  9212. d.hour = v;
  9213. }],
  9214. m: [twoDigits, function (d, v) {
  9215. d.minute = v;
  9216. }],
  9217. s: [twoDigits, function (d, v) {
  9218. d.second = v;
  9219. }],
  9220. YYYY: [fourDigits, function (d, v) {
  9221. d.year = v;
  9222. }],
  9223. S: [/\d/, function (d, v) {
  9224. d.millisecond = v * 100;
  9225. }],
  9226. SS: [/\d{2}/, function (d, v) {
  9227. d.millisecond = v * 10;
  9228. }],
  9229. SSS: [threeDigits, function (d, v) {
  9230. d.millisecond = v;
  9231. }],
  9232. d: [twoDigits, noop],
  9233. ddd: [word, noop],
  9234. MMM: [word, monthUpdate('monthNamesShort')],
  9235. MMMM: [word, monthUpdate('monthNames')],
  9236. a: [word, function (d, v, i18n) {
  9237. var val = v.toLowerCase();
  9238. if (val === i18n.amPm[0]) {
  9239. d.isPm = false;
  9240. } else if (val === i18n.amPm[1]) {
  9241. d.isPm = true;
  9242. }
  9243. }],
  9244. ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) {
  9245. if (v === 'Z') v = '+00:00';
  9246. var parts = (v + '').match(/([\+\-]|\d\d)/gi),
  9247. minutes;
  9248. if (parts) {
  9249. minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
  9250. d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
  9251. }
  9252. }]
  9253. };
  9254. parseFlags.dd = parseFlags.d;
  9255. parseFlags.dddd = parseFlags.ddd;
  9256. parseFlags.DD = parseFlags.D;
  9257. parseFlags.mm = parseFlags.m;
  9258. parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
  9259. parseFlags.MM = parseFlags.M;
  9260. parseFlags.ss = parseFlags.s;
  9261. parseFlags.A = parseFlags.a; // Some common format strings
  9262. fecha.masks = {
  9263. default: 'ddd MMM DD YYYY HH:mm:ss',
  9264. shortDate: 'M/D/YY',
  9265. mediumDate: 'MMM D, YYYY',
  9266. longDate: 'MMMM D, YYYY',
  9267. fullDate: 'dddd, MMMM D, YYYY',
  9268. shortTime: 'HH:mm',
  9269. mediumTime: 'HH:mm:ss',
  9270. longTime: 'HH:mm:ss.SSS'
  9271. };
  9272. /***
  9273. * Format a date
  9274. * @method format
  9275. * @param {Date|number} dateObj
  9276. * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
  9277. */
  9278. fecha.format = function (dateObj, mask, i18nSettings) {
  9279. var i18n = i18nSettings || fecha.i18n;
  9280. if (typeof dateObj === 'number') {
  9281. dateObj = new Date(dateObj);
  9282. }
  9283. if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
  9284. throw new Error('Invalid Date in fecha.format');
  9285. }
  9286. mask = fecha.masks[mask] || mask || fecha.masks['default'];
  9287. var literals = []; // Make literals inactive by replacing them with ??
  9288. mask = mask.replace(literal, function ($0, $1) {
  9289. literals.push($1);
  9290. return '??';
  9291. }); // Apply formatting rules
  9292. mask = mask.replace(token, function ($0) {
  9293. return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
  9294. }); // Inline literal values back into the formatted value
  9295. return mask.replace(/\?\?/g, function () {
  9296. return literals.shift();
  9297. });
  9298. };
  9299. /**
  9300. * Parse a date string into an object, changes - into /
  9301. * @method parse
  9302. * @param {string} dateStr Date string
  9303. * @param {string} format Date parse format
  9304. * @returns {Date|boolean}
  9305. */
  9306. fecha.parse = function (dateStr, format, i18nSettings) {
  9307. var i18n = i18nSettings || fecha.i18n;
  9308. if (typeof format !== 'string') {
  9309. throw new Error('Invalid format in fecha.parse');
  9310. }
  9311. format = fecha.masks[format] || format; // Avoid regular expression denial of service, fail early for really long strings
  9312. // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
  9313. if (dateStr.length > 1000) {
  9314. return false;
  9315. }
  9316. var isValid = true;
  9317. var dateInfo = {};
  9318. format.replace(token, function ($0) {
  9319. if (parseFlags[$0]) {
  9320. var info = parseFlags[$0];
  9321. var index = dateStr.search(info[0]);
  9322. if (!~index) {
  9323. isValid = false;
  9324. } else {
  9325. dateStr.replace(info[0], function (result) {
  9326. info[1](dateInfo, result, i18n);
  9327. dateStr = dateStr.substr(index + result.length);
  9328. return result;
  9329. });
  9330. }
  9331. }
  9332. return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
  9333. });
  9334. if (!isValid) {
  9335. return false;
  9336. }
  9337. var today = new Date();
  9338. if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
  9339. dateInfo.hour = +dateInfo.hour + 12;
  9340. } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
  9341. dateInfo.hour = 0;
  9342. }
  9343. var date;
  9344. if (dateInfo.timezoneOffset != null) {
  9345. dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
  9346. date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
  9347. } else {
  9348. date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1, dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
  9349. }
  9350. return date;
  9351. };
  9352. /* istanbul ignore next */
  9353. if (typeof module !== 'undefined' && module.exports) {
  9354. module.exports = fecha;
  9355. } else if (true) {
  9356. !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
  9357. return fecha;
  9358. }.call(exports, __webpack_require__, exports, module),
  9359. __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
  9360. } else {
  9361. main.fecha = fecha;
  9362. }
  9363. })(this);
  9364. /***/ }),
  9365. /* 108 */
  9366. /***/ (function(module, exports, __webpack_require__) {
  9367. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9368. var Util = __webpack_require__(0);
  9369. var GuideBase = __webpack_require__(12);
  9370. var Arc =
  9371. /*#__PURE__*/
  9372. function (_GuideBase) {
  9373. _inheritsLoose(Arc, _GuideBase);
  9374. function Arc() {
  9375. return _GuideBase.apply(this, arguments) || this;
  9376. }
  9377. var _proto = Arc.prototype;
  9378. _proto._initDefaultCfg = function _initDefaultCfg() {
  9379. this.type = 'arc';
  9380. /**
  9381. * start point
  9382. * @type {Array | Function}
  9383. */
  9384. this.start = [];
  9385. /**
  9386. * end point
  9387. * @type {Array | Function}
  9388. */
  9389. this.end = [];
  9390. /**
  9391. * style configuration
  9392. * @type {Object}
  9393. */
  9394. this.style = {
  9395. stroke: '#999',
  9396. lineWidth: 1
  9397. };
  9398. };
  9399. _proto.render = function render(coord, container) {
  9400. var self = this;
  9401. var start = self.parsePoint(coord, self.start);
  9402. var end = self.parsePoint(coord, self.end);
  9403. if (!start || !end) {
  9404. return;
  9405. }
  9406. var coordCenter = coord.center;
  9407. var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
  9408. var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x);
  9409. var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x);
  9410. var shape = container.addShape('arc', {
  9411. className: 'guide-arc',
  9412. attrs: Util.mix({
  9413. x: coordCenter.x,
  9414. y: coordCenter.y,
  9415. r: radius,
  9416. startAngle: startAngle,
  9417. endAngle: endAngle
  9418. }, self.style)
  9419. });
  9420. self.element = shape;
  9421. return shape;
  9422. };
  9423. return Arc;
  9424. }(GuideBase);
  9425. GuideBase.Arc = Arc;
  9426. module.exports = Arc;
  9427. /***/ }),
  9428. /* 109 */
  9429. /***/ (function(module, exports, __webpack_require__) {
  9430. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9431. var Util = __webpack_require__(0);
  9432. var GuideBase = __webpack_require__(12);
  9433. function getOffsetFromAlign(alignX, alignY, width, height) {
  9434. var result = [];
  9435. if (alignX === 'left' && alignY === 'top') {
  9436. result[0] = 0;
  9437. result[1] = 0;
  9438. } else if (alignX === 'right' && alignY === 'top') {
  9439. result[0] = -width;
  9440. result[1] = 0;
  9441. } else if (alignX === 'left' && alignY === 'bottom') {
  9442. result[0] = 0;
  9443. result[1] = Math.floor(-height);
  9444. } else if (alignX === 'right' && alignY === 'bottom') {
  9445. result[0] = Math.floor(-width);
  9446. result[1] = Math.floor(-height);
  9447. } else if (alignX === 'right' && alignY === 'middle') {
  9448. result[0] = Math.floor(-width);
  9449. result[1] = Math.floor(-height / 2);
  9450. } else if (alignX === 'left' && alignY === 'middle') {
  9451. result[0] = 0;
  9452. result[1] = Math.floor(-height / 2);
  9453. } else if (alignX === 'center' && alignY === 'bottom') {
  9454. result[0] = Math.floor(-width / 2);
  9455. result[1] = Math.floor(-height);
  9456. } else if (alignX === 'center' && alignY === 'top') {
  9457. result[0] = Math.floor(-width / 2);
  9458. result[1] = 0;
  9459. } else {
  9460. result[0] = Math.floor(-width / 2);
  9461. result[1] = Math.floor(-height / 2);
  9462. }
  9463. return result;
  9464. }
  9465. function modifyCSS(DOM, CSS) {
  9466. for (var key in CSS) {
  9467. if (CSS.hasOwnProperty(key)) {
  9468. DOM.style[key] = CSS[key];
  9469. }
  9470. }
  9471. return DOM;
  9472. }
  9473. function createDom(str) {
  9474. var container = document.createElement('div');
  9475. str = str.replace(/(^\s*)|(\s*$)/g, '');
  9476. container.innerHTML = '' + str;
  9477. return container.childNodes[0];
  9478. }
  9479. var Html =
  9480. /*#__PURE__*/
  9481. function (_GuideBase) {
  9482. _inheritsLoose(Html, _GuideBase);
  9483. function Html() {
  9484. return _GuideBase.apply(this, arguments) || this;
  9485. }
  9486. var _proto = Html.prototype;
  9487. _proto._initDefaultCfg = function _initDefaultCfg() {
  9488. this.type = 'html';
  9489. /**
  9490. * dom position
  9491. * @type {Object | Array}
  9492. */
  9493. this.position = null;
  9494. /**
  9495. * alignment for horizontal direction,can be 'left','center','right'
  9496. * @type {String}
  9497. */
  9498. this.alignX = 'center';
  9499. /**
  9500. * alignment for vertical direction,can be 'top', 'middle', 'bottom'
  9501. * @type {String}
  9502. */
  9503. this.alignY = 'middle';
  9504. /**
  9505. * offset for horizontal direction
  9506. * @type {Number}
  9507. */
  9508. this.offsetX = null;
  9509. /**
  9510. * offset for vertical direction
  9511. * @type {Number}
  9512. */
  9513. this.offsetY = null;
  9514. /**
  9515. * the html string
  9516. *@type {String | Function}
  9517. */
  9518. this.html = null;
  9519. }; // override paint
  9520. _proto.render = function render(coord, container) {
  9521. var self = this;
  9522. var position = self.parsePoint(coord, self.position);
  9523. if (!position) {
  9524. return;
  9525. }
  9526. var myNode = createDom(self.html);
  9527. myNode = modifyCSS(myNode, {
  9528. position: 'absolute',
  9529. top: Math.floor(position.y) + 'px',
  9530. left: Math.floor(position.x) + 'px',
  9531. visibility: 'hidden'
  9532. });
  9533. var canvasDom = container.get('canvas').get('el');
  9534. var parentNode = canvasDom.parentNode;
  9535. parentNode = modifyCSS(parentNode, {
  9536. position: 'relative'
  9537. });
  9538. var wrapperNode = createDom('<div class="guideWapper" style="position: absolute;top: 0; left: 0;"></div>');
  9539. parentNode.appendChild(wrapperNode);
  9540. wrapperNode.appendChild(myNode);
  9541. var canvasOffsetTop = canvasDom.offsetTop;
  9542. var canvasOffsetLeft = canvasDom.offsetLeft;
  9543. var alignX = self.alignX,
  9544. alignY = self.alignY,
  9545. offsetX = self.offsetX,
  9546. offsetY = self.offsetY;
  9547. var width = Util.getWidth(myNode);
  9548. var height = Util.getHeight(myNode);
  9549. var newOffset = getOffsetFromAlign(alignX, alignY, width, height);
  9550. position.x = position.x + newOffset[0] + canvasOffsetLeft;
  9551. position.y = position.y + newOffset[1] + canvasOffsetTop;
  9552. if (offsetX) {
  9553. position.x += offsetX;
  9554. }
  9555. if (offsetY) {
  9556. position.y += offsetY;
  9557. }
  9558. modifyCSS(myNode, {
  9559. top: Math.floor(position.y) + 'px',
  9560. left: Math.floor(position.x) + 'px',
  9561. visibility: 'visible'
  9562. });
  9563. self.element = wrapperNode;
  9564. };
  9565. _proto.remove = function remove() {
  9566. var element = this.element;
  9567. element && element.parentNode && element.parentNode.removeChild(element);
  9568. };
  9569. return Html;
  9570. }(GuideBase);
  9571. GuideBase.Html = Html;
  9572. module.exports = Html;
  9573. /***/ }),
  9574. /* 110 */
  9575. /***/ (function(module, exports, __webpack_require__) {
  9576. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9577. var Util = __webpack_require__(0);
  9578. var GuideBase = __webpack_require__(12);
  9579. var Line =
  9580. /*#__PURE__*/
  9581. function (_GuideBase) {
  9582. _inheritsLoose(Line, _GuideBase);
  9583. function Line() {
  9584. return _GuideBase.apply(this, arguments) || this;
  9585. }
  9586. var _proto = Line.prototype;
  9587. _proto._initDefaultCfg = function _initDefaultCfg() {
  9588. this.type = 'line';
  9589. this.start = [];
  9590. this.end = [];
  9591. this.style = {
  9592. stroke: '#000',
  9593. lineWidth: 1
  9594. };
  9595. };
  9596. _proto.render = function render(coord, container) {
  9597. var points = [];
  9598. points[0] = this.parsePoint(coord, this.start);
  9599. points[1] = this.parsePoint(coord, this.end);
  9600. if (!points[0] || !points[1]) {
  9601. return;
  9602. }
  9603. var shape = container.addShape('Line', {
  9604. className: 'guide-line',
  9605. attrs: Util.mix({
  9606. x1: points[0].x,
  9607. y1: points[0].y,
  9608. x2: points[1].x,
  9609. y2: points[1].y
  9610. }, this.style)
  9611. });
  9612. this.element = shape;
  9613. return shape;
  9614. };
  9615. return Line;
  9616. }(GuideBase);
  9617. GuideBase.Line = Line;
  9618. module.exports = Line;
  9619. /***/ }),
  9620. /* 111 */
  9621. /***/ (function(module, exports, __webpack_require__) {
  9622. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9623. var Util = __webpack_require__(0);
  9624. var GuideBase = __webpack_require__(12);
  9625. var Rect =
  9626. /*#__PURE__*/
  9627. function (_GuideBase) {
  9628. _inheritsLoose(Rect, _GuideBase);
  9629. function Rect() {
  9630. return _GuideBase.apply(this, arguments) || this;
  9631. }
  9632. var _proto = Rect.prototype;
  9633. _proto._initDefaultCfg = function _initDefaultCfg() {
  9634. this.type = 'rect';
  9635. this.start = [];
  9636. this.end = [];
  9637. this.style = {
  9638. fill: '#CCD7EB',
  9639. opacity: 0.4
  9640. };
  9641. };
  9642. _proto.render = function render(coord, container) {
  9643. var start = this.parsePoint(coord, this.start);
  9644. var end = this.parsePoint(coord, this.end);
  9645. if (!start || !end) {
  9646. return;
  9647. }
  9648. var shape = container.addShape('rect', {
  9649. className: 'guide-rect',
  9650. attrs: Util.mix({
  9651. x: Math.min(start.x, end.x),
  9652. y: Math.min(start.y, end.y),
  9653. width: Math.abs(end.x - start.x),
  9654. height: Math.abs(start.y - end.y)
  9655. }, this.style)
  9656. });
  9657. this.element = shape;
  9658. return shape;
  9659. };
  9660. return Rect;
  9661. }(GuideBase);
  9662. GuideBase.Rect = Rect;
  9663. module.exports = Rect;
  9664. /***/ }),
  9665. /* 112 */
  9666. /***/ (function(module, exports, __webpack_require__) {
  9667. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9668. var Util = __webpack_require__(0);
  9669. var GuideBase = __webpack_require__(12);
  9670. var Text =
  9671. /*#__PURE__*/
  9672. function (_GuideBase) {
  9673. _inheritsLoose(Text, _GuideBase);
  9674. function Text() {
  9675. return _GuideBase.apply(this, arguments) || this;
  9676. }
  9677. var _proto = Text.prototype;
  9678. _proto._initDefaultCfg = function _initDefaultCfg() {
  9679. this.type = 'text';
  9680. /**
  9681. * the position of text
  9682. * @type {Function | Array}
  9683. */
  9684. this.position = null;
  9685. /**
  9686. * the display content
  9687. * @type {String}
  9688. */
  9689. this.content = null;
  9690. /**
  9691. * style configuration for text
  9692. * @type {Object}
  9693. */
  9694. this.style = {
  9695. fill: '#000'
  9696. };
  9697. /**
  9698. * offset of horizontal direction
  9699. * @type {Number}
  9700. */
  9701. this.offsetX = 0;
  9702. /**
  9703. * offset of vertical direction
  9704. * @type {Number}
  9705. */
  9706. this.offsetY = 0;
  9707. };
  9708. _proto.render = function render(coord, container) {
  9709. var position = this.position;
  9710. var point = this.parsePoint(coord, position);
  9711. if (!point) {
  9712. return;
  9713. }
  9714. var content = this.content,
  9715. style = this.style,
  9716. offsetX = this.offsetX,
  9717. offsetY = this.offsetY;
  9718. if (offsetX) {
  9719. point.x += offsetX;
  9720. }
  9721. if (offsetY) {
  9722. point.y += offsetY;
  9723. }
  9724. var shape = container.addShape('text', {
  9725. className: 'guide-text',
  9726. attrs: Util.mix({
  9727. x: point.x,
  9728. y: point.y,
  9729. text: content
  9730. }, style)
  9731. });
  9732. this.element = shape;
  9733. return shape;
  9734. };
  9735. return Text;
  9736. }(GuideBase);
  9737. GuideBase.Text = Text;
  9738. module.exports = Text;
  9739. /***/ }),
  9740. /* 113 */
  9741. /***/ (function(module, exports, __webpack_require__) {
  9742. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  9743. var Util = __webpack_require__(0);
  9744. var GuideBase = __webpack_require__(12);
  9745. var Tag =
  9746. /*#__PURE__*/
  9747. function (_GuideBase) {
  9748. _inheritsLoose(Tag, _GuideBase);
  9749. function Tag() {
  9750. return _GuideBase.apply(this, arguments) || this;
  9751. }
  9752. var _proto = Tag.prototype;
  9753. _proto._initDefaultCfg = function _initDefaultCfg() {
  9754. this.type = 'tag';
  9755. this.position = null;
  9756. this.content = null;
  9757. this.direct = 'tl';
  9758. this.autoAdjust = true;
  9759. this.offsetX = 0;
  9760. this.offsetY = 0;
  9761. this.side = 4;
  9762. this.background = {
  9763. padding: 5,
  9764. radius: 2,
  9765. fill: '#1890FF'
  9766. };
  9767. this.textStyle = {
  9768. fontSize: 12,
  9769. fill: '#fff',
  9770. textAlign: 'center',
  9771. textBaseline: 'middle'
  9772. };
  9773. this.withPoint = true;
  9774. this.pointStyle = {
  9775. fill: '#1890FF',
  9776. r: 3,
  9777. lineWidth: 1,
  9778. stroke: '#fff'
  9779. };
  9780. };
  9781. _proto._getDirect = function _getDirect(container, point, tagWidth, tagHeight) {
  9782. var direct = this.direct;
  9783. var side = this.side;
  9784. var canvas = container.get('canvas');
  9785. var clientWidth = canvas.get('width');
  9786. var clientHeight = canvas.get('height');
  9787. var x = point.x,
  9788. y = point.y;
  9789. var vertical = direct[0];
  9790. var horizontal = direct[1]; // adjust for vertical direction
  9791. if (vertical === 't' && y - side - tagHeight < 0) {
  9792. vertical = 'b';
  9793. } else if (vertical === 'b' && y + side + tagHeight > clientHeight) {
  9794. vertical = 't';
  9795. } // adjust for horizontal direction
  9796. var diff = vertical === 'c' ? side : 0;
  9797. if (horizontal === 'l' && x - diff - tagWidth < 0) {
  9798. horizontal = 'r';
  9799. } else if (horizontal === 'r' && x + diff + tagWidth > clientWidth) {
  9800. horizontal = 'l';
  9801. } else if (horizontal === 'c') {
  9802. if (tagWidth / 2 + x + diff > clientWidth) {
  9803. horizontal = 'l';
  9804. } else if (x - tagWidth / 2 - diff < 0) {
  9805. horizontal = 'r';
  9806. }
  9807. }
  9808. direct = vertical + horizontal;
  9809. return direct;
  9810. };
  9811. _proto.render = function render(coord, container) {
  9812. var position = this.parsePoint(coord, this.position);
  9813. if (!position) {
  9814. return;
  9815. }
  9816. var content = this.content,
  9817. background = this.background,
  9818. textStyle = this.textStyle;
  9819. var shapes = [];
  9820. var wrapperContainer = container.addGroup({
  9821. className: 'guide-tag'
  9822. });
  9823. if (this.withPoint) {
  9824. var pointShape = wrapperContainer.addShape('Circle', {
  9825. className: 'guide-tag-point',
  9826. attrs: Util.mix({
  9827. x: position.x,
  9828. y: position.y
  9829. }, this.pointStyle)
  9830. });
  9831. shapes.push(pointShape);
  9832. }
  9833. var tagContainer = wrapperContainer.addGroup(); // create a text shape
  9834. var tagText = tagContainer.addShape('text', {
  9835. className: 'guide-tag-text',
  9836. zIndex: 1,
  9837. attrs: Util.mix({
  9838. x: 0,
  9839. y: 0,
  9840. text: content
  9841. }, textStyle)
  9842. });
  9843. shapes.push(tagText); // create background box
  9844. var textBBox = tagText.getBBox();
  9845. var padding = Util.parsePadding(background.padding);
  9846. var tagWidth = textBBox.width + padding[1] + padding[3];
  9847. var tagHeight = textBBox.height + padding[0] + padding[2];
  9848. var yMin = textBBox.minY - padding[0];
  9849. var xMin = textBBox.minX - padding[3];
  9850. var tagBg = tagContainer.addShape('rect', {
  9851. className: 'guide-tag-bg',
  9852. zIndex: -1,
  9853. attrs: Util.mix({
  9854. x: xMin,
  9855. y: yMin,
  9856. width: tagWidth,
  9857. height: tagHeight
  9858. }, background)
  9859. });
  9860. shapes.push(tagBg);
  9861. var direct = this.autoAdjust ? this._getDirect(container, position, tagWidth, tagHeight) : this.direct;
  9862. var side = this.side;
  9863. var x = position.x + this.offsetX;
  9864. var y = position.y + this.offsetY;
  9865. var arrowPoints;
  9866. var radius = Util.parsePadding(background.radius);
  9867. if (direct === 'tl') {
  9868. arrowPoints = [{
  9869. x: tagWidth + xMin - side - 1,
  9870. y: tagHeight + yMin - 1
  9871. }, // 这个 1 是为了防止出现白边
  9872. {
  9873. x: tagWidth + xMin,
  9874. y: tagHeight + yMin - 1
  9875. }, {
  9876. x: tagWidth + xMin,
  9877. y: tagHeight + side + yMin
  9878. }];
  9879. radius[2] = 0;
  9880. x = x - tagWidth;
  9881. y = y - side - tagHeight;
  9882. } else if (direct === 'cl') {
  9883. arrowPoints = [{
  9884. x: tagWidth + xMin - 1,
  9885. y: (tagHeight - side) / 2 + yMin - 1
  9886. }, {
  9887. x: tagWidth + xMin - 1,
  9888. y: (tagHeight + side) / 2 + yMin + 1
  9889. }, {
  9890. x: tagWidth + side + xMin,
  9891. y: tagHeight / 2 + yMin
  9892. }];
  9893. x = x - tagWidth - side;
  9894. y = y - tagHeight / 2;
  9895. } else if (direct === 'bl') {
  9896. arrowPoints = [{
  9897. x: tagWidth + xMin,
  9898. y: -side + yMin
  9899. }, {
  9900. x: tagWidth + xMin - side - 1,
  9901. y: yMin + 1
  9902. }, {
  9903. x: tagWidth + xMin,
  9904. y: yMin + 1
  9905. }];
  9906. radius[1] = 0;
  9907. x = x - tagWidth;
  9908. y = y + side;
  9909. } else if (direct === 'bc') {
  9910. arrowPoints = [{
  9911. x: tagWidth / 2 + xMin,
  9912. y: -side + yMin
  9913. }, {
  9914. x: (tagWidth - side) / 2 + xMin - 1,
  9915. y: yMin + 1
  9916. }, {
  9917. x: (tagWidth + side) / 2 + xMin + 1,
  9918. y: yMin + 1
  9919. }];
  9920. x = x - tagWidth / 2;
  9921. y = y + side;
  9922. } else if (direct === 'br') {
  9923. arrowPoints = [{
  9924. x: xMin,
  9925. y: yMin - side
  9926. }, {
  9927. x: xMin,
  9928. y: yMin + 1
  9929. }, {
  9930. x: xMin + side + 1,
  9931. y: yMin + 1
  9932. }];
  9933. radius[0] = 0;
  9934. y = y + side;
  9935. } else if (direct === 'cr') {
  9936. arrowPoints = [{
  9937. x: xMin - side,
  9938. y: tagHeight / 2 + yMin
  9939. }, {
  9940. x: xMin + 1,
  9941. y: (tagHeight - side) / 2 + yMin - 1
  9942. }, {
  9943. x: xMin + 1,
  9944. y: (tagHeight + side) / 2 + yMin + 1
  9945. }];
  9946. x = x + side;
  9947. y = y - tagHeight / 2;
  9948. } else if (direct === 'tr') {
  9949. arrowPoints = [{
  9950. x: xMin,
  9951. y: tagHeight + side + yMin
  9952. }, {
  9953. x: xMin,
  9954. y: tagHeight + yMin - 1
  9955. }, {
  9956. x: side + xMin + 1,
  9957. y: tagHeight + yMin - 1
  9958. }];
  9959. radius[3] = 0;
  9960. y = y - tagHeight - side;
  9961. } else if (direct === 'tc') {
  9962. arrowPoints = [{
  9963. x: (tagWidth - side) / 2 + xMin - 1,
  9964. y: tagHeight + yMin - 1
  9965. }, {
  9966. x: (tagWidth + side) / 2 + xMin + 1,
  9967. y: tagHeight + yMin - 1
  9968. }, {
  9969. x: tagWidth / 2 + xMin,
  9970. y: tagHeight + side + yMin
  9971. }];
  9972. x = x - tagWidth / 2;
  9973. y = y - tagHeight - side;
  9974. }
  9975. var sideShape = tagContainer.addShape('Polygon', {
  9976. className: 'guide-tag-side',
  9977. zIndex: 0,
  9978. attrs: {
  9979. points: arrowPoints,
  9980. fill: background.fill
  9981. }
  9982. });
  9983. shapes.push(sideShape);
  9984. tagBg.attr('radius', radius);
  9985. tagContainer.moveTo(x - xMin, y - yMin);
  9986. tagContainer.sort();
  9987. this.element = wrapperContainer;
  9988. return shapes;
  9989. };
  9990. return Tag;
  9991. }(GuideBase);
  9992. GuideBase.Tag = Tag;
  9993. module.exports = Tag;
  9994. /***/ }),
  9995. /* 114 */
  9996. /***/ (function(module, exports, __webpack_require__) {
  9997. var Util = __webpack_require__(0);
  9998. var Global = __webpack_require__(1);
  9999. var Tooltip = __webpack_require__(115);
  10000. var Helper = __webpack_require__(26); // Register the default configuration for Tooltip
  10001. Global.tooltip = Util.deepMix({
  10002. triggerOn: ['touchstart', 'touchmove'],
  10003. // triggerOff: 'touchend',
  10004. alwaysShow: false,
  10005. showTitle: false,
  10006. showCrosshairs: false,
  10007. crosshairsStyle: {
  10008. stroke: 'rgba(0, 0, 0, 0.25)',
  10009. lineWidth: 1
  10010. },
  10011. showTooltipMarker: true,
  10012. background: {
  10013. radius: 1,
  10014. fill: 'rgba(0, 0, 0, 0.65)',
  10015. padding: [3, 5]
  10016. },
  10017. titleStyle: {
  10018. fontSize: 12,
  10019. fill: '#fff',
  10020. textAlign: 'start',
  10021. textBaseline: 'top'
  10022. },
  10023. nameStyle: {
  10024. fontSize: 12,
  10025. fill: 'rgba(255, 255, 255, 0.65)',
  10026. textAlign: 'start',
  10027. textBaseline: 'middle'
  10028. },
  10029. valueStyle: {
  10030. fontSize: 12,
  10031. fill: '#fff',
  10032. textAlign: 'start',
  10033. textBaseline: 'middle'
  10034. },
  10035. showItemMarker: true,
  10036. itemMarkerStyle: {
  10037. radius: 3,
  10038. symbol: 'circle',
  10039. lineWidth: 1,
  10040. stroke: '#fff'
  10041. },
  10042. layout: 'horizontal',
  10043. snap: false
  10044. }, Global.tooltip || {});
  10045. function _getTooltipValueScale(geom) {
  10046. var colorAttr = geom.getAttr('color');
  10047. if (colorAttr) {
  10048. var colorScale = colorAttr.getScale(colorAttr.type);
  10049. if (colorScale.isLinear) {
  10050. return colorScale;
  10051. }
  10052. }
  10053. var xScale = geom.getXScale();
  10054. var yScale = geom.getYScale();
  10055. if (yScale) {
  10056. return yScale;
  10057. }
  10058. return xScale;
  10059. }
  10060. function getTooltipName(geom, origin) {
  10061. var name;
  10062. var nameScale;
  10063. var groupScales = geom._getGroupScales();
  10064. if (groupScales.length) {
  10065. Util.each(groupScales, function (scale) {
  10066. nameScale = scale;
  10067. return false;
  10068. });
  10069. }
  10070. if (nameScale) {
  10071. var field = nameScale.field;
  10072. name = nameScale.getText(origin[field]);
  10073. } else {
  10074. var valueScale = _getTooltipValueScale(geom);
  10075. name = valueScale.alias || valueScale.field;
  10076. }
  10077. return name;
  10078. }
  10079. function getTooltipValue(geom, origin) {
  10080. var scale = _getTooltipValueScale(geom);
  10081. return scale.getText(origin[scale.field]);
  10082. }
  10083. function getTooltipTitle(geom, origin) {
  10084. var position = geom.getAttr('position');
  10085. var field = position.getFields()[0];
  10086. var scale = geom.get('scales')[field];
  10087. return scale.getText(origin[scale.field]);
  10088. }
  10089. function _indexOfArray(items, item) {
  10090. var rst = -1;
  10091. Util.each(items, function (sub, index) {
  10092. if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) {
  10093. rst = index;
  10094. return false;
  10095. }
  10096. });
  10097. return rst;
  10098. }
  10099. function _uniqItems(items) {
  10100. var tmp = [];
  10101. Util.each(items, function (item) {
  10102. var index = _indexOfArray(tmp, item);
  10103. if (index === -1) {
  10104. tmp.push(item);
  10105. } else {
  10106. tmp[index] = item;
  10107. }
  10108. });
  10109. return tmp;
  10110. }
  10111. function isEqual(arr1, arr2) {
  10112. return JSON.stringify(arr1) === JSON.stringify(arr2);
  10113. }
  10114. var TooltipController =
  10115. /*#__PURE__*/
  10116. function () {
  10117. function TooltipController(cfg) {
  10118. this.enable = true;
  10119. this.cfg = {};
  10120. this.tooltip = null;
  10121. this.chart = null;
  10122. this.timeStamp = 0;
  10123. Util.mix(this, cfg);
  10124. var chart = this.chart;
  10125. this.canvasDom = chart.get('canvas').get('el');
  10126. }
  10127. var _proto = TooltipController.prototype;
  10128. _proto._setCrosshairsCfg = function _setCrosshairsCfg() {
  10129. var self = this;
  10130. var chart = self.chart;
  10131. var defaultCfg = Util.mix({}, Global.tooltip);
  10132. var geoms = chart.get('geoms');
  10133. var shapes = [];
  10134. Util.each(geoms, function (geom) {
  10135. var type = geom.get('type');
  10136. if (shapes.indexOf(type) === -1) {
  10137. shapes.push(type);
  10138. }
  10139. });
  10140. var coordType = chart.get('coord').type;
  10141. if (geoms.length && (coordType === 'cartesian' || coordType === 'rect')) {
  10142. if (shapes.length === 1 && ['line', 'area', 'path', 'point'].indexOf(shapes[0]) !== -1) {
  10143. Util.mix(defaultCfg, {
  10144. showCrosshairs: true
  10145. });
  10146. }
  10147. }
  10148. return defaultCfg;
  10149. };
  10150. _proto._getMaxLength = function _getMaxLength(cfg) {
  10151. if (cfg === void 0) {
  10152. cfg = {};
  10153. }
  10154. var _cfg = cfg,
  10155. layout = _cfg.layout,
  10156. plotRange = _cfg.plotRange;
  10157. return layout === 'horizontal' ? plotRange.br.x - plotRange.bl.x : plotRange.bl.y - plotRange.tr.y;
  10158. };
  10159. _proto.render = function render() {
  10160. var self = this;
  10161. if (self.tooltip) {
  10162. return;
  10163. }
  10164. var chart = self.chart;
  10165. var canvas = chart.get('canvas');
  10166. var frontPlot = chart.get('frontPlot').addGroup({
  10167. className: 'tooltipContainer',
  10168. zIndex: 10
  10169. });
  10170. var backPlot = chart.get('backPlot').addGroup({
  10171. className: 'tooltipContainer'
  10172. });
  10173. var plotRange = chart.get('plotRange');
  10174. var coord = chart.get('coord');
  10175. var defaultCfg = self._setCrosshairsCfg();
  10176. var cfg = self.cfg;
  10177. cfg = Util.deepMix({
  10178. plotRange: plotRange,
  10179. frontPlot: frontPlot,
  10180. backPlot: backPlot,
  10181. canvas: canvas,
  10182. fixed: coord.transposed || coord.isPolar
  10183. }, defaultCfg, cfg);
  10184. cfg.maxLength = self._getMaxLength(cfg);
  10185. this.cfg = cfg;
  10186. var tooltip = new Tooltip(cfg);
  10187. self.tooltip = tooltip;
  10188. self.bindEvents();
  10189. };
  10190. _proto.clear = function clear() {
  10191. var tooltip = this.tooltip;
  10192. tooltip && tooltip.destroy();
  10193. this.tooltip = null;
  10194. this.prePoint = null;
  10195. this._lastActive = null;
  10196. this.unBindEvents();
  10197. };
  10198. _proto._getTooltipMarkerStyle = function _getTooltipMarkerStyle(cfg) {
  10199. if (cfg === void 0) {
  10200. cfg = {};
  10201. }
  10202. var _cfg2 = cfg,
  10203. type = _cfg2.type,
  10204. items = _cfg2.items;
  10205. var tooltipCfg = this.cfg;
  10206. if (type === 'rect') {
  10207. var x;
  10208. var y;
  10209. var width;
  10210. var height;
  10211. var chart = this.chart;
  10212. var _chart$get = chart.get('plotRange'),
  10213. tl = _chart$get.tl,
  10214. br = _chart$get.br;
  10215. var coord = chart.get('coord');
  10216. var firstItem = items[0];
  10217. var lastItem = items[items.length - 1];
  10218. var intervalWidth = firstItem.width;
  10219. if (coord.transposed) {
  10220. x = tl.x;
  10221. y = lastItem.y - intervalWidth * 0.75;
  10222. width = br.x - tl.x;
  10223. height = firstItem.y - lastItem.y + 1.5 * intervalWidth;
  10224. } else {
  10225. x = firstItem.x - intervalWidth * 0.75;
  10226. y = tl.y;
  10227. width = lastItem.x - firstItem.x + 1.5 * intervalWidth;
  10228. height = br.y - tl.y;
  10229. }
  10230. cfg.style = Util.mix({
  10231. x: x,
  10232. y: y,
  10233. width: width,
  10234. height: height,
  10235. fill: '#CCD6EC',
  10236. opacity: 0.3
  10237. }, tooltipCfg.tooltipMarkerStyle);
  10238. } else {
  10239. cfg.style = Util.mix({
  10240. radius: 4,
  10241. fill: '#fff',
  10242. lineWidth: 2
  10243. }, tooltipCfg.tooltipMarkerStyle);
  10244. }
  10245. return cfg;
  10246. };
  10247. _proto._setTooltip = function _setTooltip(point, items, tooltipMarkerCfg) {
  10248. if (tooltipMarkerCfg === void 0) {
  10249. tooltipMarkerCfg = {};
  10250. }
  10251. var lastActive = this._lastActive;
  10252. var tooltip = this.tooltip;
  10253. var cfg = this.cfg;
  10254. items = _uniqItems(items);
  10255. var chart = this.chart;
  10256. var coord = chart.get('coord');
  10257. var yScale = chart.getYScales()[0];
  10258. var snap = cfg.snap;
  10259. if (snap === false && yScale.isLinear) {
  10260. var invertPoint = coord.invertPoint(point);
  10261. var plot = chart.get('plotRange');
  10262. var tip;
  10263. var pos;
  10264. if (Helper.isPointInPlot(point, plot)) {
  10265. if (coord.transposed) {
  10266. tip = yScale.invert(invertPoint.x);
  10267. pos = point.x;
  10268. tooltip.setXTipContent(tip);
  10269. tooltip.setXTipPosition(pos);
  10270. tooltip.setYCrosshairPosition(pos);
  10271. } else {
  10272. tip = yScale.invert(invertPoint.y);
  10273. pos = point.y;
  10274. tooltip.setYTipContent(tip);
  10275. tooltip.setYTipPosition(pos);
  10276. tooltip.setXCrosshairPosition(pos);
  10277. }
  10278. }
  10279. }
  10280. if (cfg.onShow) {
  10281. cfg.onShow({
  10282. x: point.x,
  10283. y: point.y,
  10284. tooltip: tooltip,
  10285. items: items,
  10286. tooltipMarkerCfg: tooltipMarkerCfg
  10287. });
  10288. }
  10289. if (isEqual(lastActive, items)) {
  10290. if (snap === false && (Util.directionEnabled(cfg.crosshairsType, 'y') || cfg.showYTip)) {
  10291. var canvas = this.chart.get('canvas');
  10292. canvas.draw();
  10293. }
  10294. return;
  10295. }
  10296. this._lastActive = items;
  10297. var onChange = cfg.onChange;
  10298. if (onChange) {
  10299. onChange({
  10300. x: point.x,
  10301. y: point.y,
  10302. tooltip: tooltip,
  10303. items: items,
  10304. tooltipMarkerCfg: tooltipMarkerCfg
  10305. });
  10306. }
  10307. var first = items[0];
  10308. var title = first.title || first.name;
  10309. var xTipPosX = first.x;
  10310. if (items.length > 1) {
  10311. xTipPosX = (items[0].x + items[items.length - 1].x) / 2;
  10312. }
  10313. tooltip.setContent(title, items, coord.transposed);
  10314. tooltip.setPosition(items, point);
  10315. if (coord.transposed) {
  10316. var yTipPosY = first.y;
  10317. if (items.length > 1) {
  10318. yTipPosY = (items[0].y + items[items.length - 1].y) / 2;
  10319. }
  10320. tooltip.setYTipContent(title);
  10321. tooltip.setYTipPosition(yTipPosY);
  10322. tooltip.setXCrosshairPosition(yTipPosY);
  10323. if (snap) {
  10324. tooltip.setXTipContent(first.value);
  10325. tooltip.setXTipPosition(xTipPosX);
  10326. tooltip.setYCrosshairPosition(xTipPosX);
  10327. }
  10328. } else {
  10329. tooltip.setXTipContent(title);
  10330. tooltip.setXTipPosition(xTipPosX);
  10331. tooltip.setYCrosshairPosition(xTipPosX);
  10332. if (snap) {
  10333. tooltip.setYTipContent(first.value);
  10334. tooltip.setYTipPosition(first.y);
  10335. tooltip.setXCrosshairPosition(first.y);
  10336. }
  10337. }
  10338. var markerItems = tooltipMarkerCfg.items;
  10339. if (cfg.showTooltipMarker && markerItems.length) {
  10340. tooltipMarkerCfg = this._getTooltipMarkerStyle(tooltipMarkerCfg);
  10341. tooltip.setMarkers(tooltipMarkerCfg);
  10342. } else {
  10343. tooltip.clearMarkers();
  10344. }
  10345. tooltip.show();
  10346. };
  10347. _proto.showTooltip = function showTooltip(point) {
  10348. var self = this;
  10349. var chart = self.chart;
  10350. var tooltipMarkerType;
  10351. var tooltipMarkerItems = [];
  10352. var items = [];
  10353. var cfg = self.cfg;
  10354. var marker;
  10355. if (cfg.showItemMarker) {
  10356. marker = cfg.itemMarkerStyle;
  10357. }
  10358. var geoms = chart.get('geoms');
  10359. var coord = chart.get('coord');
  10360. Util.each(geoms, function (geom) {
  10361. if (geom.get('visible')) {
  10362. var type = geom.get('type');
  10363. var records = geom.getSnapRecords(point);
  10364. Util.each(records, function (record) {
  10365. if (record.x && record.y) {
  10366. var x = record.x,
  10367. y = record.y,
  10368. _origin = record._origin,
  10369. color = record.color;
  10370. var tooltipItem = {
  10371. x: x,
  10372. y: Util.isArray(y) ? y[1] : y,
  10373. color: color || Global.defaultColor,
  10374. origin: _origin,
  10375. name: getTooltipName(geom, _origin),
  10376. value: getTooltipValue(geom, _origin),
  10377. title: getTooltipTitle(geom, _origin)
  10378. };
  10379. if (marker) {
  10380. tooltipItem.marker = Util.mix({
  10381. fill: color || Global.defaultColor
  10382. }, marker);
  10383. }
  10384. items.push(tooltipItem);
  10385. if (['line', 'area', 'path'].indexOf(type) !== -1) {
  10386. tooltipMarkerType = 'circle';
  10387. tooltipMarkerItems.push(tooltipItem);
  10388. } else if (type === 'interval' && (coord.type === 'cartesian' || coord.type === 'rect')) {
  10389. tooltipMarkerType = 'rect';
  10390. tooltipItem.width = geom.getSize(record._origin);
  10391. tooltipMarkerItems.push(tooltipItem);
  10392. }
  10393. }
  10394. });
  10395. }
  10396. });
  10397. if (items.length) {
  10398. var tooltipMarkerCfg = {
  10399. items: tooltipMarkerItems,
  10400. type: tooltipMarkerType
  10401. };
  10402. self._setTooltip(point, items, tooltipMarkerCfg);
  10403. } else {
  10404. self.hideTooltip();
  10405. }
  10406. };
  10407. _proto.hideTooltip = function hideTooltip() {
  10408. var cfg = this.cfg;
  10409. this._lastActive = null;
  10410. var tooltip = this.tooltip;
  10411. if (tooltip) {
  10412. tooltip.hide();
  10413. if (cfg.onHide) {
  10414. cfg.onHide({
  10415. tooltip: tooltip
  10416. });
  10417. }
  10418. var canvas = this.chart.get('canvas');
  10419. canvas.draw();
  10420. }
  10421. };
  10422. _proto.handleShowEvent = function handleShowEvent(ev) {
  10423. var chart = this.chart;
  10424. if (!this.enable || chart.get('_closeTooltip')) return;
  10425. var plot = chart.get('plotRange');
  10426. var point = Util.createEvent(ev, chart);
  10427. if (!Helper.isPointInPlot(point, plot) && !this.cfg.alwaysShow) {
  10428. // not in chart plot
  10429. this.hideTooltip();
  10430. return;
  10431. }
  10432. var lastTimeStamp = this.timeStamp;
  10433. var timeStamp = +new Date();
  10434. if (timeStamp - lastTimeStamp > 16) {
  10435. this.showTooltip(point);
  10436. this.timeStamp = timeStamp;
  10437. }
  10438. };
  10439. _proto.handleHideEvent = function handleHideEvent() {
  10440. var chart = this.chart;
  10441. if (!this.enable || chart.get('_closeTooltip')) return;
  10442. this.hideTooltip();
  10443. };
  10444. _proto.handleDocEvent = function handleDocEvent(ev) {
  10445. var chart = this.chart;
  10446. if (!this.enable || chart.get('_closeTooltip')) return;
  10447. var canvasDom = this.canvasDom;
  10448. if (ev.target !== canvasDom) {
  10449. this.hideTooltip();
  10450. }
  10451. };
  10452. _proto._handleEvent = function _handleEvent(methodName, method, action) {
  10453. var canvasDom = this.canvasDom;
  10454. Util.each([].concat(methodName), function (aMethod) {
  10455. if (action === 'bind') {
  10456. Util.addEventListener(canvasDom, aMethod, method);
  10457. } else {
  10458. Util.removeEventListener(canvasDom, aMethod, method);
  10459. }
  10460. });
  10461. };
  10462. _proto.bindEvents = function bindEvents() {
  10463. var cfg = this.cfg;
  10464. var triggerOn = cfg.triggerOn,
  10465. triggerOff = cfg.triggerOff,
  10466. alwaysShow = cfg.alwaysShow;
  10467. var showMethod = Util.wrapBehavior(this, 'handleShowEvent');
  10468. var hideMethod = Util.wrapBehavior(this, 'handleHideEvent');
  10469. triggerOn && this._handleEvent(triggerOn, showMethod, 'bind');
  10470. triggerOff && this._handleEvent(triggerOff, hideMethod, 'bind'); // TODO: 当用户点击 canvas 外的事件时 tooltip 消失
  10471. if (!alwaysShow) {
  10472. var docMethod = Util.wrapBehavior(this, 'handleDocEvent');
  10473. Util.isBrowser && Util.addEventListener(document, 'touchstart', docMethod);
  10474. }
  10475. };
  10476. _proto.unBindEvents = function unBindEvents() {
  10477. var cfg = this.cfg;
  10478. var triggerOn = cfg.triggerOn,
  10479. triggerOff = cfg.triggerOff,
  10480. alwaysShow = cfg.alwaysShow;
  10481. var showMethod = Util.getWrapBehavior(this, 'handleShowEvent');
  10482. var hideMethod = Util.getWrapBehavior(this, 'handleHideEvent');
  10483. triggerOn && this._handleEvent(triggerOn, showMethod, 'unBind');
  10484. triggerOff && this._handleEvent(triggerOff, hideMethod, 'unBind');
  10485. if (!alwaysShow) {
  10486. var docMethod = Util.getWrapBehavior(this, 'handleDocEvent');
  10487. Util.isBrowser && Util.removeEventListener(document, 'touchstart', docMethod);
  10488. }
  10489. };
  10490. return TooltipController;
  10491. }();
  10492. module.exports = {
  10493. init: function init(chart) {
  10494. var tooltipController = new TooltipController({
  10495. chart: chart
  10496. });
  10497. chart.set('tooltipController', tooltipController);
  10498. chart.tooltip = function (enable, cfg) {
  10499. if (Util.isObject(enable)) {
  10500. cfg = enable;
  10501. enable = true;
  10502. }
  10503. tooltipController.enable = enable;
  10504. if (cfg) {
  10505. tooltipController.cfg = cfg;
  10506. }
  10507. return this;
  10508. };
  10509. },
  10510. afterGeomDraw: function afterGeomDraw(chart) {
  10511. var tooltipController = chart.get('tooltipController');
  10512. tooltipController.render();
  10513. chart.showTooltip = function (point) {
  10514. tooltipController.showTooltip(point);
  10515. return this;
  10516. };
  10517. chart.hideTooltip = function () {
  10518. tooltipController.hideTooltip();
  10519. return this;
  10520. };
  10521. },
  10522. clearInner: function clearInner(chart) {
  10523. var tooltipController = chart.get('tooltipController');
  10524. tooltipController.clear();
  10525. }
  10526. };
  10527. /***/ }),
  10528. /* 115 */
  10529. /***/ (function(module, exports, __webpack_require__) {
  10530. var Util = __webpack_require__(0);
  10531. var Marker = __webpack_require__(90);
  10532. var Container = __webpack_require__(91);
  10533. var TextBox = __webpack_require__(116);
  10534. var GAP = 4;
  10535. /**
  10536. * TODOList:
  10537. * 1. 移除 fixed 参数
  10538. */
  10539. var Tooltip =
  10540. /*#__PURE__*/
  10541. function () {
  10542. var _proto = Tooltip.prototype;
  10543. _proto.getDefaultCfg = function getDefaultCfg() {
  10544. return {
  10545. /**
  10546. * wether show the crosshairs
  10547. * @type {Object}
  10548. */
  10549. showCrosshairs: false,
  10550. /**
  10551. * the style for crosshairs
  10552. * @type {Object}
  10553. */
  10554. crosshairsStyle: {
  10555. stroke: 'rgba(0, 0, 0, 0.25)',
  10556. lineWidth: 1
  10557. },
  10558. /**
  10559. * the type of crosshairs, optional value is 'x', 'y' or 'xy', default is 'y'
  10560. */
  10561. crosshairsType: 'y',
  10562. /**
  10563. * show or hide the x axis tip
  10564. */
  10565. showXTip: false,
  10566. /**
  10567. * show or hide the y axis tip
  10568. */
  10569. showYTip: false,
  10570. xTip: null,
  10571. xTipBackground: {
  10572. radius: 1,
  10573. fill: 'rgba(0, 0, 0, 0.65)',
  10574. padding: [3, 5]
  10575. },
  10576. yTip: null,
  10577. yTipBackground: {
  10578. radius: 1,
  10579. fill: 'rgba(0, 0, 0, 0.65)',
  10580. padding: [3, 5]
  10581. },
  10582. /**
  10583. * the style for tooltip container's background
  10584. * @type {Object}
  10585. */
  10586. background: null,
  10587. /**
  10588. * layout, can be horizontal or vertical
  10589. * @type {String}
  10590. */
  10591. layout: 'horizontal',
  10592. offsetX: 0,
  10593. offsetY: 0
  10594. };
  10595. };
  10596. function Tooltip(cfg) {
  10597. Util.deepMix(this, this.getDefaultCfg(), cfg);
  10598. var frontPlot = this.frontPlot,
  10599. custom = this.custom;
  10600. if (!custom) {
  10601. // custom means user do customize
  10602. var container = new Container(Util.mix({
  10603. parent: frontPlot,
  10604. zIndex: 3
  10605. }, cfg));
  10606. this.container = container;
  10607. var fixed = this.fixed,
  10608. background = this.background;
  10609. if (!fixed) {
  10610. this.tooltipArrow = frontPlot.addShape('Polygon', {
  10611. className: 'tooltip-arrow',
  10612. visible: false,
  10613. zIndex: 2,
  10614. attrs: Util.mix({
  10615. points: []
  10616. }, background)
  10617. });
  10618. }
  10619. }
  10620. if (this.showXTip) {
  10621. var xTipBackground = this.xTipBackground;
  10622. var xTipBox = new TextBox({
  10623. className: 'xTip',
  10624. background: xTipBackground,
  10625. visible: false
  10626. });
  10627. frontPlot.add(xTipBox.container);
  10628. this.xTipBox = xTipBox;
  10629. }
  10630. if (this.showYTip) {
  10631. var yTipBackground = this.yTipBackground;
  10632. var yTipBox = new TextBox({
  10633. className: 'yTip',
  10634. background: yTipBackground,
  10635. visible: false
  10636. });
  10637. frontPlot.add(yTipBox.container);
  10638. this.yTipBox = yTipBox;
  10639. }
  10640. if (this.showCrosshairs) {
  10641. this._renderCrosshairs();
  10642. }
  10643. frontPlot.sort();
  10644. }
  10645. _proto.setContent = function setContent(title, items) {
  10646. this.title = title;
  10647. this.items = items;
  10648. if (!this.custom) {
  10649. var container = this.container;
  10650. container.setTitle(title);
  10651. container.setItems(items);
  10652. }
  10653. };
  10654. _proto.setYTipContent = function setYTipContent(val) {
  10655. var yTip = this.yTip;
  10656. if (Util.isFunction(yTip)) {
  10657. val = yTip(val);
  10658. } else {
  10659. val = Util.mix({
  10660. text: val
  10661. }, yTip);
  10662. }
  10663. this.yTipBox && this.yTipBox.updateContent(val);
  10664. };
  10665. _proto.setYTipPosition = function setYTipPosition(pos) {
  10666. var plotRange = this.plotRange;
  10667. var crosshairsShapeX = this.crosshairsShapeX;
  10668. if (this.showYTip) {
  10669. var yTipBox = this.yTipBox;
  10670. var yTipHeight = yTipBox.getHeight();
  10671. var yTipWidth = yTipBox.getWidth();
  10672. var posX = plotRange.tl.x - yTipWidth;
  10673. var posY = pos - yTipHeight / 2;
  10674. if (posY <= plotRange.tl.y) {
  10675. posY = plotRange.tl.y;
  10676. }
  10677. if (posY + yTipHeight >= plotRange.br.y) {
  10678. posY = plotRange.br.y - yTipHeight;
  10679. }
  10680. if (posX < 0) {
  10681. posX = plotRange.tl.x;
  10682. crosshairsShapeX && crosshairsShapeX.attr('x1', plotRange.tl.x + yTipWidth);
  10683. }
  10684. yTipBox.updatePosition(posX, posY);
  10685. }
  10686. };
  10687. _proto.setXTipContent = function setXTipContent(val) {
  10688. var xTip = this.xTip;
  10689. if (Util.isFunction(xTip)) {
  10690. val = xTip(val);
  10691. } else {
  10692. val = Util.mix({
  10693. text: val
  10694. }, xTip);
  10695. }
  10696. this.xTipBox && this.xTipBox.updateContent(val);
  10697. };
  10698. _proto.setXTipPosition = function setXTipPosition(pos) {
  10699. var showXTip = this.showXTip,
  10700. canvas = this.canvas,
  10701. plotRange = this.plotRange,
  10702. xTipBox = this.xTipBox,
  10703. crosshairsShapeY = this.crosshairsShapeY;
  10704. if (showXTip) {
  10705. // const el = canvas.get('el');
  10706. // const canvasHeight = Util.getHeight(el);
  10707. var canvasHeight = canvas.get('height');
  10708. var xTipWidth = xTipBox.getWidth();
  10709. var xTipHeight = xTipBox.getHeight();
  10710. var posX = pos - xTipWidth / 2;
  10711. var posY = plotRange.br.y;
  10712. if (posX <= plotRange.tl.x) {
  10713. posX = plotRange.tl.x;
  10714. }
  10715. if (posX + xTipWidth >= plotRange.tr.x) {
  10716. posX = plotRange.tr.x - xTipWidth;
  10717. }
  10718. if (canvasHeight - posY < xTipHeight) {
  10719. posY -= xTipHeight;
  10720. }
  10721. xTipBox.updatePosition(posX, posY);
  10722. crosshairsShapeY && crosshairsShapeY.attr('y1', posY);
  10723. }
  10724. };
  10725. _proto.setXCrosshairPosition = function setXCrosshairPosition(pos) {
  10726. this.crosshairsShapeX && this.crosshairsShapeX.moveTo(0, pos);
  10727. };
  10728. _proto.setYCrosshairPosition = function setYCrosshairPosition(pos) {
  10729. this.crosshairsShapeY && this.crosshairsShapeY.moveTo(pos, 0);
  10730. };
  10731. _proto.setPosition = function setPosition(items) {
  10732. var container = this.container,
  10733. plotRange = this.plotRange,
  10734. offsetX = this.offsetX,
  10735. offsetY = this.offsetY,
  10736. fixed = this.fixed,
  10737. tooltipArrow = this.tooltipArrow;
  10738. if (!container) {
  10739. return;
  10740. }
  10741. var containerBBox = container.container.getBBox();
  10742. var minX = containerBBox.minX,
  10743. minY = containerBBox.minY,
  10744. width = containerBBox.width,
  10745. height = containerBBox.height;
  10746. var tl = plotRange.tl,
  10747. tr = plotRange.tr;
  10748. var posX = 0;
  10749. var posY = tl.y - height - GAP + offsetY;
  10750. if (fixed) {
  10751. var x = (tl.x + tr.x) / 2;
  10752. posX = x - width / 2 + offsetX;
  10753. } else {
  10754. var _x;
  10755. if (items.length > 1) {
  10756. _x = (items[0].x + items[items.length - 1].x) / 2;
  10757. } else {
  10758. _x = items[0].x;
  10759. }
  10760. posX = _x - width / 2 + offsetX;
  10761. if (posX < tl.x) {
  10762. posX = tl.x;
  10763. }
  10764. if (posX + width > tr.x) {
  10765. posX = tr.x - width;
  10766. }
  10767. if (tooltipArrow) {
  10768. tooltipArrow.attr('points', [{
  10769. x: _x - 3,
  10770. y: tl.y - GAP + offsetY
  10771. }, {
  10772. x: _x + 3,
  10773. y: tl.y - GAP + offsetY
  10774. }, {
  10775. x: _x,
  10776. y: tl.y + offsetY
  10777. }]);
  10778. var backShape = container.backShape;
  10779. var radius = Util.parsePadding(backShape.attr('radius'));
  10780. if (_x === tl.x) {
  10781. radius[3] = 0;
  10782. tooltipArrow.attr('points', [{
  10783. x: tl.x,
  10784. y: tl.y + offsetY
  10785. }, {
  10786. x: tl.x,
  10787. y: tl.y - GAP + offsetY
  10788. }, {
  10789. x: tl.x + GAP,
  10790. y: tl.y - GAP + offsetY
  10791. }]);
  10792. } else if (_x === tr.x) {
  10793. radius[2] = 0;
  10794. tooltipArrow.attr('points', [{
  10795. x: tr.x,
  10796. y: tl.y + offsetY
  10797. }, {
  10798. x: tr.x - GAP,
  10799. y: tl.y - GAP + offsetY
  10800. }, {
  10801. x: tr.x,
  10802. y: tl.y - GAP + offsetY
  10803. }]);
  10804. }
  10805. backShape.attr('radius', radius);
  10806. }
  10807. }
  10808. container.moveTo(posX - minX, posY - minY);
  10809. };
  10810. _proto.setMarkers = function setMarkers(cfg) {
  10811. if (cfg === void 0) {
  10812. cfg = {};
  10813. }
  10814. var self = this;
  10815. var _cfg = cfg,
  10816. items = _cfg.items,
  10817. style = _cfg.style,
  10818. type = _cfg.type;
  10819. var markerGroup = self._getMarkerGroup(type);
  10820. if (type === 'circle') {
  10821. for (var i = 0, length = items.length; i < length; i++) {
  10822. var item = items[i];
  10823. var marker = new Marker({
  10824. className: 'tooltip-circle-marker',
  10825. attrs: Util.mix({
  10826. x: item.x,
  10827. y: item.y,
  10828. stroke: item.color
  10829. }, style)
  10830. });
  10831. markerGroup.add(marker);
  10832. }
  10833. } else {
  10834. markerGroup.addShape('rect', {
  10835. className: 'tooltip-rect-marker',
  10836. attrs: style
  10837. });
  10838. }
  10839. };
  10840. _proto.clearMarkers = function clearMarkers() {
  10841. var markerGroup = this.markerGroup;
  10842. markerGroup && markerGroup.clear();
  10843. };
  10844. _proto.show = function show() {
  10845. var crosshairsShapeX = this.crosshairsShapeX;
  10846. var crosshairsShapeY = this.crosshairsShapeY;
  10847. var markerGroup = this.markerGroup;
  10848. var container = this.container;
  10849. var tooltipArrow = this.tooltipArrow;
  10850. var xTipBox = this.xTipBox;
  10851. var yTipBox = this.yTipBox;
  10852. var canvas = this.canvas;
  10853. crosshairsShapeX && crosshairsShapeX.show();
  10854. crosshairsShapeY && crosshairsShapeY.show();
  10855. markerGroup && markerGroup.show();
  10856. container && container.show();
  10857. tooltipArrow && tooltipArrow.show();
  10858. xTipBox && xTipBox.show();
  10859. yTipBox && yTipBox.show();
  10860. canvas.draw();
  10861. };
  10862. _proto.hide = function hide() {
  10863. var crosshairsShapeX = this.crosshairsShapeX;
  10864. var crosshairsShapeY = this.crosshairsShapeY;
  10865. var markerGroup = this.markerGroup;
  10866. var container = this.container;
  10867. var tooltipArrow = this.tooltipArrow;
  10868. var xTipBox = this.xTipBox;
  10869. var yTipBox = this.yTipBox;
  10870. crosshairsShapeX && crosshairsShapeX.hide();
  10871. crosshairsShapeY && crosshairsShapeY.hide();
  10872. markerGroup && markerGroup.hide();
  10873. container && container.hide();
  10874. tooltipArrow && tooltipArrow.hide();
  10875. xTipBox && xTipBox.hide();
  10876. yTipBox && yTipBox.hide();
  10877. };
  10878. _proto.destroy = function destroy() {
  10879. var crosshairsShapeX = this.crosshairsShapeX;
  10880. var crosshairsShapeY = this.crosshairsShapeY;
  10881. var markerGroup = this.markerGroup;
  10882. var container = this.container;
  10883. var tooltipArrow = this.tooltipArrow;
  10884. var xTipBox = this.xTipBox;
  10885. var yTipBox = this.yTipBox;
  10886. crosshairsShapeX && crosshairsShapeX.remove(true);
  10887. crosshairsShapeY && crosshairsShapeY.remove(true);
  10888. markerGroup && markerGroup.remove(true);
  10889. tooltipArrow && tooltipArrow.remove(true);
  10890. container && container.clear();
  10891. xTipBox && xTipBox.clear();
  10892. yTipBox && yTipBox.clear();
  10893. this.destroyed = true;
  10894. };
  10895. _proto._getMarkerGroup = function _getMarkerGroup(type) {
  10896. var markerGroup = this.markerGroup;
  10897. if (!markerGroup) {
  10898. if (type === 'circle') {
  10899. markerGroup = this.frontPlot.addGroup({
  10900. zIndex: 1
  10901. });
  10902. this.frontPlot.sort();
  10903. } else {
  10904. markerGroup = this.backPlot.addGroup();
  10905. }
  10906. this.markerGroup = markerGroup;
  10907. } else {
  10908. markerGroup.clear();
  10909. }
  10910. return markerGroup;
  10911. };
  10912. _proto._renderCrosshairs = function _renderCrosshairs() {
  10913. var crosshairsType = this.crosshairsType,
  10914. crosshairsStyle = this.crosshairsStyle,
  10915. frontPlot = this.frontPlot,
  10916. plotRange = this.plotRange;
  10917. var tl = plotRange.tl,
  10918. br = plotRange.br;
  10919. if (Util.directionEnabled(crosshairsType, 'x')) {
  10920. this.crosshairsShapeX = frontPlot.addShape('Line', {
  10921. className: 'tooltip-crosshairs-x',
  10922. zIndex: 0,
  10923. visible: false,
  10924. attrs: Util.mix({
  10925. x1: tl.x,
  10926. y1: 0,
  10927. x2: br.x,
  10928. y2: 0
  10929. }, crosshairsStyle)
  10930. });
  10931. }
  10932. if (Util.directionEnabled(crosshairsType, 'y')) {
  10933. this.crosshairsShapeY = frontPlot.addShape('Line', {
  10934. className: 'tooltip-crosshairs-y',
  10935. zIndex: 0,
  10936. visible: false,
  10937. attrs: Util.mix({
  10938. x1: 0,
  10939. y1: br.y,
  10940. x2: 0,
  10941. y2: tl.y
  10942. }, crosshairsStyle)
  10943. });
  10944. }
  10945. };
  10946. return Tooltip;
  10947. }();
  10948. module.exports = Tooltip;
  10949. /***/ }),
  10950. /* 116 */
  10951. /***/ (function(module, exports, __webpack_require__) {
  10952. var Util = __webpack_require__(0);
  10953. var _require = __webpack_require__(5),
  10954. Group = _require.Group;
  10955. var TextBox =
  10956. /*#__PURE__*/
  10957. function () {
  10958. var _proto = TextBox.prototype;
  10959. _proto.getDefaultCfg = function getDefaultCfg() {
  10960. return {
  10961. x: 0,
  10962. y: 0,
  10963. content: '',
  10964. textStyle: {
  10965. fontSize: 12,
  10966. fill: '#fff',
  10967. textAlign: 'center',
  10968. textBaseline: 'middle'
  10969. },
  10970. background: {
  10971. radius: 1,
  10972. fill: 'rgba(0, 0, 0, 0.65)',
  10973. padding: [3, 5]
  10974. },
  10975. width: 0,
  10976. height: 0,
  10977. className: ''
  10978. };
  10979. };
  10980. function TextBox(cfg) {
  10981. Util.deepMix(this, this.getDefaultCfg(), cfg);
  10982. this._init();
  10983. var content = this.content,
  10984. x = this.x,
  10985. y = this.y;
  10986. if (!Util.isNil(content)) {
  10987. this.updateContent(content);
  10988. }
  10989. this.updatePosition(x, y);
  10990. }
  10991. _proto._init = function _init() {
  10992. var content = this.content,
  10993. textStyle = this.textStyle,
  10994. background = this.background,
  10995. className = this.className,
  10996. visible = this.visible;
  10997. var container = new Group({
  10998. className: className,
  10999. zIndex: 0,
  11000. visible: visible
  11001. });
  11002. var text = container.addShape('Text', {
  11003. className: className + '-text',
  11004. zIndex: 1,
  11005. attrs: Util.mix({
  11006. text: content,
  11007. x: 0,
  11008. y: 0
  11009. }, textStyle)
  11010. });
  11011. var backgroundShape = container.addShape('Rect', {
  11012. className: className + '-bg',
  11013. zIndex: -1,
  11014. attrs: Util.mix({
  11015. x: 0,
  11016. y: 0,
  11017. width: 0,
  11018. height: 0
  11019. }, background)
  11020. });
  11021. container.sort();
  11022. this.container = container;
  11023. this.textShape = text;
  11024. this.backgroundShape = backgroundShape;
  11025. };
  11026. _proto._getBBox = function _getBBox() {
  11027. var textShape = this.textShape;
  11028. var background = this.background;
  11029. var textBBox = textShape.getBBox();
  11030. var padding = Util.parsePadding(background.padding);
  11031. var width = textBBox.width + padding[1] + padding[3];
  11032. var height = textBBox.height + padding[0] + padding[2];
  11033. var x = textBBox.minX - padding[3];
  11034. var y = textBBox.minY - padding[0];
  11035. return {
  11036. x: x,
  11037. y: y,
  11038. width: width,
  11039. height: height
  11040. };
  11041. };
  11042. _proto.updateContent = function updateContent(text) {
  11043. var textShape = this.textShape,
  11044. backgroundShape = this.backgroundShape;
  11045. if (!Util.isNil(text)) {
  11046. if (!Util.isObject(text)) {
  11047. text = {
  11048. text: text
  11049. };
  11050. }
  11051. textShape.attr(text); // update box shape
  11052. var _this$_getBBox = this._getBBox(),
  11053. x = _this$_getBBox.x,
  11054. y = _this$_getBBox.y,
  11055. tipWidth = _this$_getBBox.width,
  11056. tipHeight = _this$_getBBox.height;
  11057. var width = this.width || tipWidth;
  11058. var height = this.height || tipHeight;
  11059. backgroundShape.attr({
  11060. x: x,
  11061. y: y,
  11062. width: width,
  11063. height: height
  11064. });
  11065. this._width = width;
  11066. this._height = height;
  11067. this.content = text.text;
  11068. }
  11069. };
  11070. _proto.updatePosition = function updatePosition(x, y) {
  11071. var container = this.container;
  11072. var _this$_getBBox2 = this._getBBox(),
  11073. xMin = _this$_getBBox2.x,
  11074. yMin = _this$_getBBox2.y;
  11075. container.moveTo(x - xMin, y - yMin);
  11076. this.x = x - xMin;
  11077. this.y = y - yMin;
  11078. };
  11079. _proto.getWidth = function getWidth() {
  11080. return this._width;
  11081. };
  11082. _proto.getHeight = function getHeight() {
  11083. return this._height;
  11084. };
  11085. _proto.show = function show() {
  11086. this.container.show();
  11087. };
  11088. _proto.hide = function hide() {
  11089. this.container.hide();
  11090. };
  11091. _proto.clear = function clear() {
  11092. var container = this.container;
  11093. container.clear();
  11094. container.remove(true);
  11095. this.container = null;
  11096. this.textShape = null;
  11097. this.backgroundShape = null;
  11098. };
  11099. return TextBox;
  11100. }();
  11101. module.exports = TextBox;
  11102. /***/ }),
  11103. /* 117 */
  11104. /***/ (function(module, exports, __webpack_require__) {
  11105. var Util = __webpack_require__(0);
  11106. var Guide = __webpack_require__(12);
  11107. var Global = __webpack_require__(1); // register the default configuration for Guide
  11108. Global.guide = Util.deepMix({
  11109. line: {
  11110. style: {
  11111. stroke: '#a3a3a3',
  11112. lineWidth: 1
  11113. },
  11114. top: true
  11115. },
  11116. text: {
  11117. style: {
  11118. fill: '#787878',
  11119. textAlign: 'center',
  11120. textBaseline: 'middle'
  11121. },
  11122. offsetX: 0,
  11123. offsetY: 0,
  11124. top: true
  11125. },
  11126. rect: {
  11127. style: {
  11128. fill: '#fafafa'
  11129. },
  11130. top: false
  11131. },
  11132. arc: {
  11133. style: {
  11134. stroke: '#a3a3a3'
  11135. },
  11136. top: true
  11137. },
  11138. html: {
  11139. offsetX: 0,
  11140. offsetY: 0,
  11141. alignX: 'center',
  11142. alignY: 'middle'
  11143. },
  11144. tag: {
  11145. top: true,
  11146. offsetX: 0,
  11147. offsetY: 0,
  11148. side: 4,
  11149. background: {
  11150. padding: 5,
  11151. radius: 2,
  11152. fill: '#1890FF'
  11153. },
  11154. textStyle: {
  11155. fontSize: 12,
  11156. fill: '#fff',
  11157. textAlign: 'center',
  11158. textBaseline: 'middle'
  11159. }
  11160. },
  11161. point: {
  11162. top: true,
  11163. offsetX: 0,
  11164. offsetY: 0,
  11165. style: {
  11166. fill: '#fff',
  11167. r: 3,
  11168. lineWidth: 2,
  11169. stroke: '#1890ff'
  11170. }
  11171. }
  11172. }, Global.guide || {});
  11173. var GuideController =
  11174. /*#__PURE__*/
  11175. function () {
  11176. function GuideController(cfg) {
  11177. this.guides = [];
  11178. this.xScale = null;
  11179. this.yScales = null;
  11180. this.guideShapes = [];
  11181. Util.mix(this, cfg);
  11182. }
  11183. var _proto = GuideController.prototype;
  11184. _proto._toString = function _toString(position) {
  11185. if (Util.isFunction(position)) {
  11186. position = position(this.xScale, this.yScales);
  11187. }
  11188. position = position.toString();
  11189. return position;
  11190. };
  11191. _proto._getId = function _getId(shape, guide) {
  11192. var id = guide.id;
  11193. if (!id) {
  11194. var type = guide.type;
  11195. if (type === 'arc' || type === 'line' || type === 'rect') {
  11196. id = this._toString(guide.start) + '-' + this._toString(guide.end);
  11197. } else {
  11198. id = this._toString(guide.position);
  11199. }
  11200. }
  11201. return id;
  11202. };
  11203. _proto.paint = function paint(coord) {
  11204. var self = this;
  11205. var chart = self.chart,
  11206. guides = self.guides,
  11207. xScale = self.xScale,
  11208. yScales = self.yScales;
  11209. var guideShapes = [];
  11210. Util.each(guides, function (guide, idx) {
  11211. guide.xScale = xScale;
  11212. guide.yScales = yScales;
  11213. var container;
  11214. if (guide.type === 'regionFilter') {
  11215. // TODO: RegionFilter support animation
  11216. guide.chart = chart;
  11217. } else {
  11218. container = guide.top ? self.frontPlot : self.backPlot;
  11219. }
  11220. guide.coord = coord;
  11221. guide.container = container;
  11222. guide.canvas = chart.get('canvas');
  11223. var shape = guide.render(coord, container);
  11224. if (shape) {
  11225. var id = self._getId(shape, guide);
  11226. [].concat(shape).forEach(function (s) {
  11227. s._id = s.get('className') + '-' + id;
  11228. s.set('index', idx);
  11229. guideShapes.push(s);
  11230. });
  11231. }
  11232. });
  11233. self.guideShapes = guideShapes;
  11234. };
  11235. _proto.clear = function clear() {
  11236. this.reset();
  11237. this.guides = [];
  11238. return this;
  11239. };
  11240. _proto.reset = function reset() {
  11241. var guides = this.guides;
  11242. Util.each(guides, function (guide) {
  11243. guide.remove();
  11244. });
  11245. };
  11246. _proto._createGuide = function _createGuide(type, cfg) {
  11247. var ClassName = Util.upperFirst(type);
  11248. var guide = new Guide[ClassName](Util.deepMix({}, Global.guide[type], cfg));
  11249. this.guides.push(guide);
  11250. return guide;
  11251. };
  11252. _proto.line = function line(cfg) {
  11253. if (cfg === void 0) {
  11254. cfg = {};
  11255. }
  11256. return this._createGuide('line', cfg);
  11257. };
  11258. _proto.text = function text(cfg) {
  11259. if (cfg === void 0) {
  11260. cfg = {};
  11261. }
  11262. return this._createGuide('text', cfg);
  11263. };
  11264. _proto.arc = function arc(cfg) {
  11265. if (cfg === void 0) {
  11266. cfg = {};
  11267. }
  11268. return this._createGuide('arc', cfg);
  11269. };
  11270. _proto.html = function html(cfg) {
  11271. if (cfg === void 0) {
  11272. cfg = {};
  11273. }
  11274. return this._createGuide('html', cfg);
  11275. };
  11276. _proto.rect = function rect(cfg) {
  11277. if (cfg === void 0) {
  11278. cfg = {};
  11279. }
  11280. return this._createGuide('rect', cfg);
  11281. };
  11282. _proto.tag = function tag(cfg) {
  11283. if (cfg === void 0) {
  11284. cfg = {};
  11285. }
  11286. return this._createGuide('tag', cfg);
  11287. };
  11288. _proto.point = function point(cfg) {
  11289. if (cfg === void 0) {
  11290. cfg = {};
  11291. }
  11292. return this._createGuide('point', cfg);
  11293. };
  11294. _proto.regionFilter = function regionFilter(cfg) {
  11295. if (cfg === void 0) {
  11296. cfg = {};
  11297. }
  11298. return this._createGuide('regionFilter', cfg);
  11299. };
  11300. return GuideController;
  11301. }();
  11302. module.exports = {
  11303. init: function init(chart) {
  11304. var guideController = new GuideController({
  11305. frontPlot: chart.get('frontPlot').addGroup({
  11306. zIndex: 20,
  11307. className: 'guideContainer'
  11308. }),
  11309. backPlot: chart.get('backPlot').addGroup({
  11310. className: 'guideContainer'
  11311. })
  11312. });
  11313. chart.set('guideController', guideController);
  11314. /**
  11315. * 为图表添加 guide
  11316. * @return {GuideController} 返回 guide 控制器
  11317. */
  11318. chart.guide = function () {
  11319. return guideController;
  11320. };
  11321. },
  11322. afterGeomDraw: function afterGeomDraw(chart) {
  11323. var guideController = chart.get('guideController');
  11324. if (!guideController.guides.length) {
  11325. return;
  11326. }
  11327. var xScale = chart.getXScale();
  11328. var yScales = chart.getYScales();
  11329. var coord = chart.get('coord');
  11330. guideController.xScale = xScale;
  11331. guideController.yScales = yScales;
  11332. guideController.chart = chart; // for regionFilter
  11333. guideController.paint(coord);
  11334. },
  11335. clear: function clear(chart) {
  11336. chart.get('guideController').clear();
  11337. },
  11338. repaint: function repaint(chart) {
  11339. chart.get('guideController').reset();
  11340. }
  11341. };
  11342. /***/ }),
  11343. /* 118 */
  11344. /***/ (function(module, exports, __webpack_require__) {
  11345. var Util = __webpack_require__(0);
  11346. var List = __webpack_require__(91);
  11347. var Global = __webpack_require__(1);
  11348. var LEGEND_GAP = 12;
  11349. var MARKER_SIZE = 3;
  11350. var DEFAULT_CFG = {
  11351. itemMarginBottom: 12,
  11352. itemGap: 10,
  11353. showTitle: false,
  11354. titleStyle: {
  11355. fontSize: 12,
  11356. fill: '#808080',
  11357. textAlign: 'start',
  11358. textBaseline: 'top'
  11359. },
  11360. nameStyle: {
  11361. fill: '#808080',
  11362. fontSize: 12,
  11363. textAlign: 'start',
  11364. textBaseline: 'middle'
  11365. },
  11366. valueStyle: {
  11367. fill: '#000000',
  11368. fontSize: 12,
  11369. textAlign: 'start',
  11370. textBaseline: 'middle'
  11371. },
  11372. unCheckStyle: {
  11373. fill: '#bfbfbf'
  11374. },
  11375. itemWidth: 'auto',
  11376. wordSpace: 6,
  11377. selectedMode: 'multiple' // 'multiple' or 'single'
  11378. }; // Register the default configuration for Legend
  11379. Global.legend = Util.deepMix({
  11380. common: DEFAULT_CFG,
  11381. // common legend configuration
  11382. right: Util.mix({
  11383. position: 'right',
  11384. layout: 'vertical'
  11385. }, DEFAULT_CFG),
  11386. left: Util.mix({
  11387. position: 'left',
  11388. layout: 'vertical'
  11389. }, DEFAULT_CFG),
  11390. top: Util.mix({
  11391. position: 'top',
  11392. layout: 'horizontal'
  11393. }, DEFAULT_CFG),
  11394. bottom: Util.mix({
  11395. position: 'bottom',
  11396. layout: 'horizontal'
  11397. }, DEFAULT_CFG)
  11398. }, Global.legend || {});
  11399. function getPaddingByPos(pos, appendPadding) {
  11400. var padding = 0;
  11401. appendPadding = Util.parsePadding(appendPadding);
  11402. switch (pos) {
  11403. case 'top':
  11404. padding = appendPadding[0];
  11405. break;
  11406. case 'right':
  11407. padding = appendPadding[1];
  11408. break;
  11409. case 'bottom':
  11410. padding = appendPadding[2];
  11411. break;
  11412. case 'left':
  11413. padding = appendPadding[3];
  11414. break;
  11415. default:
  11416. break;
  11417. }
  11418. return padding;
  11419. }
  11420. var LegendController =
  11421. /*#__PURE__*/
  11422. function () {
  11423. function LegendController(cfg) {
  11424. this.legendCfg = {};
  11425. this.enable = true;
  11426. this.position = 'top';
  11427. Util.mix(this, cfg);
  11428. var chart = this.chart;
  11429. this.canvasDom = chart.get('canvas').get('el');
  11430. this.clear();
  11431. }
  11432. var _proto = LegendController.prototype;
  11433. _proto.addLegend = function addLegend(scale, items, filterVals) {
  11434. var self = this;
  11435. var legendCfg = self.legendCfg;
  11436. var field = scale.field;
  11437. var fieldCfg = legendCfg[field];
  11438. if (fieldCfg === false) {
  11439. return null;
  11440. }
  11441. if (fieldCfg && fieldCfg.custom) {
  11442. self.addCustomLegend(field);
  11443. } else {
  11444. var position = legendCfg.position || self.position;
  11445. if (fieldCfg && fieldCfg.position) {
  11446. position = fieldCfg.position;
  11447. }
  11448. if (scale.isCategory) {
  11449. self._addCategoryLegend(scale, items, position, filterVals);
  11450. }
  11451. }
  11452. };
  11453. _proto.addCustomLegend = function addCustomLegend(field) {
  11454. var self = this;
  11455. var legendCfg = self.legendCfg;
  11456. if (field && legendCfg[field]) {
  11457. legendCfg = legendCfg[field];
  11458. }
  11459. var position = legendCfg.position || self.position;
  11460. var legends = self.legends;
  11461. legends[position] = legends[position] || [];
  11462. var items = legendCfg.items;
  11463. if (!items) {
  11464. return null;
  11465. }
  11466. var container = self.container;
  11467. Util.each(items, function (item) {
  11468. if (!Util.isPlainObject(item.marker)) {
  11469. item.marker = {
  11470. symbol: item.marker || 'circle',
  11471. fill: item.fill,
  11472. radius: MARKER_SIZE
  11473. };
  11474. } else {
  11475. item.marker.radius = item.marker.radius || MARKER_SIZE;
  11476. }
  11477. item.checked = Util.isNil(item.checked) ? true : item.checked;
  11478. item.name = item.name || item.value;
  11479. });
  11480. var legend = new List(Util.deepMix({}, Global.legend[position], legendCfg, {
  11481. maxLength: self._getMaxLength(position),
  11482. items: items,
  11483. parent: container
  11484. }));
  11485. legends[position].push(legend);
  11486. };
  11487. _proto.clear = function clear() {
  11488. var legends = this.legends;
  11489. Util.each(legends, function (legendItems) {
  11490. Util.each(legendItems, function (legend) {
  11491. legend.clear();
  11492. });
  11493. });
  11494. this.legends = {};
  11495. this.unBindEvents();
  11496. };
  11497. _proto._isFiltered = function _isFiltered(scale, values, value) {
  11498. var rst = false;
  11499. Util.each(values, function (val) {
  11500. rst = rst || scale.getText(val) === scale.getText(value);
  11501. if (rst) {
  11502. return false;
  11503. }
  11504. });
  11505. return rst;
  11506. };
  11507. _proto._getMaxLength = function _getMaxLength(position) {
  11508. var chart = this.chart;
  11509. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  11510. return position === 'right' || position === 'left' ? chart.get('height') - (appendPadding[0] + appendPadding[2]) : chart.get('width') - (appendPadding[1] + appendPadding[3]);
  11511. };
  11512. _proto._addCategoryLegend = function _addCategoryLegend(scale, items, position, filterVals) {
  11513. var self = this;
  11514. var legendCfg = self.legendCfg,
  11515. legends = self.legends,
  11516. container = self.container,
  11517. chart = self.chart;
  11518. var field = scale.field;
  11519. legends[position] = legends[position] || [];
  11520. var symbol = 'circle';
  11521. if (legendCfg[field] && legendCfg[field].marker) {
  11522. symbol = legendCfg[field].marker;
  11523. } else if (legendCfg.marker) {
  11524. symbol = legendCfg.marker;
  11525. }
  11526. Util.each(items, function (item) {
  11527. if (Util.isPlainObject(symbol)) {
  11528. Util.mix(item.marker, symbol);
  11529. } else {
  11530. item.marker.symbol = symbol;
  11531. }
  11532. if (filterVals) {
  11533. item.checked = self._isFiltered(scale, filterVals, item.dataValue);
  11534. }
  11535. });
  11536. var legendItems = chart.get('legendItems');
  11537. legendItems[field] = items;
  11538. var lastCfg = Util.deepMix({}, Global.legend[position], legendCfg[field] || legendCfg, {
  11539. maxLength: self._getMaxLength(position),
  11540. items: items,
  11541. field: field,
  11542. filterVals: filterVals,
  11543. parent: container
  11544. });
  11545. if (lastCfg.showTitle) {
  11546. Util.deepMix(lastCfg, {
  11547. title: scale.alias || scale.field
  11548. });
  11549. }
  11550. var legend = new List(lastCfg);
  11551. legends[position].push(legend);
  11552. return legend;
  11553. };
  11554. _proto._alignLegend = function _alignLegend(legend, pre, position) {
  11555. var self = this;
  11556. var _self$plotRange = self.plotRange,
  11557. tl = _self$plotRange.tl,
  11558. bl = _self$plotRange.bl;
  11559. var chart = self.chart;
  11560. var offsetX = legend.offsetX || 0;
  11561. var offsetY = legend.offsetY || 0;
  11562. var chartWidth = chart.get('width');
  11563. var chartHeight = chart.get('height');
  11564. var appendPadding = Util.parsePadding(chart.get('appendPadding'));
  11565. var legendHeight = legend.getHeight();
  11566. var legendWidth = legend.getWidth();
  11567. var x = 0;
  11568. var y = 0;
  11569. if (position === 'left' || position === 'right') {
  11570. var verticalAlign = legend.verticalAlign || 'middle';
  11571. var height = Math.abs(tl.y - bl.y);
  11572. x = position === 'left' ? appendPadding[3] : chartWidth - legendWidth - appendPadding[1];
  11573. y = (height - legendHeight) / 2 + tl.y;
  11574. if (verticalAlign === 'top') {
  11575. y = tl.y;
  11576. } else if (verticalAlign === 'bottom') {
  11577. y = bl.y - legendHeight;
  11578. }
  11579. if (pre) {
  11580. y = pre.get('y') - legendHeight - LEGEND_GAP;
  11581. }
  11582. } else {
  11583. var align = legend.align || 'left';
  11584. x = appendPadding[3];
  11585. if (align === 'center') {
  11586. x = chartWidth / 2 - legendWidth / 2;
  11587. } else if (align === 'right') {
  11588. x = chartWidth - (legendWidth + appendPadding[1]);
  11589. }
  11590. y = position === 'top' ? appendPadding[0] + Math.abs(legend.container.getBBox().minY) : chartHeight - legendHeight;
  11591. if (pre) {
  11592. var preWidth = pre.getWidth();
  11593. x = pre.x + preWidth + LEGEND_GAP;
  11594. }
  11595. }
  11596. if (position === 'bottom' && offsetY > 0) {
  11597. offsetY = 0;
  11598. }
  11599. if (position === 'right' && offsetX > 0) {
  11600. offsetX = 0;
  11601. }
  11602. legend.moveTo(x + offsetX, y + offsetY);
  11603. };
  11604. _proto.alignLegends = function alignLegends() {
  11605. var self = this;
  11606. var legends = self.legends;
  11607. Util.each(legends, function (legendItems, position) {
  11608. Util.each(legendItems, function (legend, index) {
  11609. var pre = legendItems[index - 1];
  11610. self._alignLegend(legend, pre, position);
  11611. });
  11612. });
  11613. return self;
  11614. };
  11615. _proto.handleEvent = function handleEvent(ev) {
  11616. var self = this;
  11617. function findItem(x, y) {
  11618. var result = null;
  11619. var legends = self.legends;
  11620. Util.each(legends, function (legendItems) {
  11621. Util.each(legendItems, function (legend) {
  11622. var itemsGroup = legend.itemsGroup,
  11623. legendHitBoxes = legend.legendHitBoxes;
  11624. var children = itemsGroup.get('children');
  11625. if (children.length) {
  11626. var legendPosX = legend.x;
  11627. var legendPosY = legend.y;
  11628. Util.each(legendHitBoxes, function (box, index) {
  11629. if (x >= box.x + legendPosX && x <= box.x + box.width + legendPosX && y >= box.y + legendPosY && y <= box.height + box.y + legendPosY) {
  11630. // inbox
  11631. result = {
  11632. clickedItem: children[index],
  11633. clickedLegend: legend
  11634. };
  11635. return false;
  11636. }
  11637. });
  11638. }
  11639. });
  11640. });
  11641. return result;
  11642. }
  11643. var chart = self.chart;
  11644. var _Util$createEvent = Util.createEvent(ev, chart),
  11645. x = _Util$createEvent.x,
  11646. y = _Util$createEvent.y;
  11647. var clicked = findItem(x, y);
  11648. if (clicked && clicked.clickedLegend.clickable !== false) {
  11649. var clickedItem = clicked.clickedItem,
  11650. clickedLegend = clicked.clickedLegend;
  11651. if (clickedLegend.onClick) {
  11652. ev.clickedItem = clickedItem;
  11653. clickedLegend.onClick(ev);
  11654. } else if (!clickedLegend.custom) {
  11655. var checked = clickedItem.get('checked');
  11656. var value = clickedItem.get('dataValue');
  11657. var filterVals = clickedLegend.filterVals,
  11658. field = clickedLegend.field,
  11659. selectedMode = clickedLegend.selectedMode;
  11660. var isSingeSelected = selectedMode === 'single';
  11661. if (isSingeSelected) {
  11662. chart.filter(field, function (val) {
  11663. return val === value;
  11664. });
  11665. } else {
  11666. if (!checked) {
  11667. filterVals.push(value);
  11668. } else {
  11669. Util.Array.remove(filterVals, value);
  11670. }
  11671. chart.filter(field, function (val) {
  11672. return filterVals.indexOf(val) !== -1;
  11673. });
  11674. }
  11675. chart.repaint();
  11676. }
  11677. }
  11678. };
  11679. _proto.bindEvents = function bindEvents() {
  11680. var legendCfg = this.legendCfg;
  11681. var triggerOn = legendCfg.triggerOn || 'touchstart';
  11682. var method = Util.wrapBehavior(this, 'handleEvent');
  11683. Util.addEventListener(this.canvasDom, triggerOn, method);
  11684. };
  11685. _proto.unBindEvents = function unBindEvents() {
  11686. var legendCfg = this.legendCfg;
  11687. var triggerOn = legendCfg.triggerOn || 'touchstart';
  11688. var method = Util.getWrapBehavior(this, 'handleEvent');
  11689. Util.removeEventListener(this.canvasDom, triggerOn, method);
  11690. };
  11691. return LegendController;
  11692. }();
  11693. module.exports = {
  11694. init: function init(chart) {
  11695. var legendController = new LegendController({
  11696. container: chart.get('backPlot'),
  11697. plotRange: chart.get('plotRange'),
  11698. chart: chart
  11699. });
  11700. chart.set('legendController', legendController);
  11701. chart.legend = function (field, cfg) {
  11702. var legendCfg = legendController.legendCfg;
  11703. legendController.enable = true;
  11704. if (Util.isBoolean(field)) {
  11705. legendController.enable = field;
  11706. legendCfg = cfg || {};
  11707. } else if (Util.isObject(field)) {
  11708. legendCfg = field;
  11709. } else {
  11710. legendCfg[field] = cfg;
  11711. }
  11712. legendController.legendCfg = legendCfg;
  11713. return this;
  11714. };
  11715. },
  11716. beforeGeomDraw: function beforeGeomDraw(chart) {
  11717. var legendController = chart.get('legendController');
  11718. if (!legendController.enable) return null; // legend is not displayed
  11719. var legendCfg = legendController.legendCfg;
  11720. if (legendCfg && legendCfg.custom) {
  11721. legendController.addCustomLegend();
  11722. } else {
  11723. var legendItems = chart.getLegendItems();
  11724. var scales = chart.get('scales');
  11725. var filters = chart.get('filters');
  11726. Util.each(legendItems, function (items, field) {
  11727. var scale = scales[field];
  11728. var values = scale.values;
  11729. var filterVals;
  11730. if (filters && filters[field]) {
  11731. filterVals = values.filter(filters[field]);
  11732. } else {
  11733. filterVals = values.slice(0);
  11734. }
  11735. legendController.addLegend(scale, items, filterVals);
  11736. });
  11737. }
  11738. if (legendCfg && legendCfg.clickable !== false) {
  11739. legendController.bindEvents();
  11740. }
  11741. var legends = legendController.legends;
  11742. var legendRange = {
  11743. top: 0,
  11744. right: 0,
  11745. bottom: 0,
  11746. left: 0
  11747. };
  11748. Util.each(legends, function (legendItems, position) {
  11749. var padding = 0;
  11750. Util.each(legendItems, function (legend) {
  11751. var width = legend.getWidth();
  11752. var height = legend.getHeight();
  11753. if (position === 'top' || position === 'bottom') {
  11754. padding = Math.max(padding, height);
  11755. if (legend.offsetY > 0) {
  11756. padding += legend.offsetY;
  11757. }
  11758. } else {
  11759. padding = Math.max(padding, width);
  11760. if (legend.offsetX > 0) {
  11761. padding += legend.offsetX;
  11762. }
  11763. }
  11764. });
  11765. legendRange[position] = padding + getPaddingByPos(position, chart.get('appendPadding'));
  11766. });
  11767. chart.set('legendRange', legendRange);
  11768. },
  11769. afterGeomDraw: function afterGeomDraw(chart) {
  11770. var legendController = chart.get('legendController');
  11771. legendController.alignLegends();
  11772. },
  11773. clearInner: function clearInner(chart) {
  11774. var legendController = chart.get('legendController');
  11775. legendController.clear();
  11776. chart.set('legendRange', null);
  11777. }
  11778. };
  11779. /***/ }),
  11780. /* 119 */
  11781. /***/ (function(module, exports, __webpack_require__) {
  11782. /**
  11783. * Handle the detail animations
  11784. * @author sima.zhang1990@gmail.com
  11785. */
  11786. var Util = __webpack_require__(0);
  11787. var Element = __webpack_require__(25);
  11788. var Timeline = __webpack_require__(120);
  11789. var Animator = __webpack_require__(121);
  11790. var Animate = __webpack_require__(92);
  11791. var ShapeAction = __webpack_require__(123);
  11792. var GroupAction = __webpack_require__(124);
  11793. var Chart = __webpack_require__(19);
  11794. var timeline;
  11795. Element.prototype.animate = function () {
  11796. var attrs = Util.mix({}, this.get('attrs'));
  11797. return new Animator(this, attrs, timeline);
  11798. };
  11799. Chart.prototype.animate = function (cfg) {
  11800. this.set('animate', cfg);
  11801. return this;
  11802. };
  11803. Animate.Action = ShapeAction;
  11804. Animate.defaultCfg = {
  11805. interval: {
  11806. enter: function enter(coord) {
  11807. if (coord.isPolar && coord.transposed) {
  11808. // for pie chart
  11809. return function (shape) {
  11810. shape.set('zIndex', -1);
  11811. var container = shape.get('parent');
  11812. container.sort();
  11813. };
  11814. }
  11815. return ShapeAction.fadeIn;
  11816. }
  11817. },
  11818. area: {
  11819. enter: function enter(coord) {
  11820. if (coord.isPolar) return null;
  11821. return ShapeAction.fadeIn;
  11822. }
  11823. },
  11824. line: {
  11825. enter: function enter(coord) {
  11826. if (coord.isPolar) return null;
  11827. return ShapeAction.fadeIn;
  11828. }
  11829. },
  11830. path: {
  11831. enter: function enter(coord) {
  11832. if (coord.isPolar) return null;
  11833. return ShapeAction.fadeIn;
  11834. }
  11835. }
  11836. };
  11837. var GROUP_ANIMATION = {
  11838. line: function line(coord) {
  11839. if (coord.isPolar) {
  11840. return GroupAction.groupScaleInXY;
  11841. }
  11842. return GroupAction.groupWaveIn;
  11843. },
  11844. area: function area(coord) {
  11845. if (coord.isPolar) {
  11846. return GroupAction.groupScaleInXY;
  11847. }
  11848. return GroupAction.groupWaveIn;
  11849. },
  11850. path: function path(coord) {
  11851. if (coord.isPolar) {
  11852. return GroupAction.groupScaleInXY;
  11853. }
  11854. return GroupAction.groupWaveIn;
  11855. },
  11856. point: function point() {
  11857. return GroupAction.shapesScaleInXY;
  11858. },
  11859. interval: function interval(coord) {
  11860. var result;
  11861. if (coord.isPolar) {
  11862. // polar coodinate
  11863. result = GroupAction.groupScaleInXY;
  11864. if (coord.transposed) {
  11865. // pie chart
  11866. result = GroupAction.groupWaveIn;
  11867. }
  11868. } else {
  11869. result = coord.transposed ? GroupAction.groupScaleInX : GroupAction.groupScaleInY;
  11870. }
  11871. return result;
  11872. },
  11873. schema: function schema() {
  11874. return GroupAction.groupWaveIn;
  11875. }
  11876. };
  11877. function diff(fromAttrs, toAttrs) {
  11878. var endState = {};
  11879. for (var k in toAttrs) {
  11880. if (Util.isNumber(fromAttrs[k]) && fromAttrs[k] !== toAttrs[k]) {
  11881. endState[k] = toAttrs[k];
  11882. } else if (Util.isArray(fromAttrs[k]) && JSON.stringify(fromAttrs[k]) !== JSON.stringify(toAttrs[k])) {
  11883. endState[k] = toAttrs[k];
  11884. }
  11885. }
  11886. return endState;
  11887. } // Add a unique id identifier to each shape
  11888. function _getShapeId(geom, dataObj, geomIdx) {
  11889. var type = geom.get('type');
  11890. var id = 'geom' + geomIdx + '-' + type;
  11891. var xScale = geom.getXScale();
  11892. var yScale = geom.getYScale();
  11893. var xField = xScale.field || 'x';
  11894. var yField = yScale.field || 'y';
  11895. var yVal = dataObj[yField];
  11896. var xVal;
  11897. if (xScale.isIdentity) {
  11898. xVal = xScale.value;
  11899. } else {
  11900. xVal = dataObj[xField];
  11901. }
  11902. if (type === 'interval' || type === 'schema') {
  11903. id += '-' + xVal;
  11904. } else if (type === 'line' || type === 'area' || type === 'path') {
  11905. id += '-' + type;
  11906. } else {
  11907. id += xScale.isCategory ? '-' + xVal : '-' + xVal + '-' + yVal;
  11908. }
  11909. var groupScales = geom._getGroupScales();
  11910. Util.each(groupScales, function (groupScale) {
  11911. var field = groupScale.field;
  11912. if (groupScale.type !== 'identity') {
  11913. id += '-' + dataObj[field];
  11914. }
  11915. });
  11916. return id;
  11917. } // get geometry's shapes
  11918. function getShapes(geoms, chart, coord) {
  11919. var shapes = [];
  11920. Util.each(geoms, function (geom, geomIdx) {
  11921. var geomContainer = geom.get('container');
  11922. var geomShapes = geomContainer.get('children');
  11923. var type = geom.get('type');
  11924. var animateCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
  11925. if (animateCfg !== false) {
  11926. Util.each(geomShapes, function (shape, index) {
  11927. if (shape.get('className') === type) {
  11928. shape._id = _getShapeId(geom, shape.get('origin')._origin, geomIdx);
  11929. shape.set('coord', coord);
  11930. shape.set('animateCfg', animateCfg);
  11931. shape.set('index', index);
  11932. shapes.push(shape);
  11933. }
  11934. });
  11935. }
  11936. geom.set('shapes', geomShapes);
  11937. });
  11938. return shapes;
  11939. }
  11940. function cache(shapes) {
  11941. var rst = {};
  11942. for (var i = 0, len = shapes.length; i < len; i++) {
  11943. var shape = shapes[i];
  11944. if (!shape._id || shape.isClip) continue;
  11945. var id = shape._id;
  11946. rst[id] = {
  11947. _id: id,
  11948. type: shape.get('type'),
  11949. // the type of shape
  11950. attrs: Util.mix({}, shape._attrs.attrs),
  11951. // the graphics attributes of shape
  11952. className: shape.get('className'),
  11953. geomType: shape.get('className'),
  11954. index: shape.get('index'),
  11955. coord: shape.get('coord'),
  11956. animateCfg: shape.get('animateCfg')
  11957. };
  11958. }
  11959. return rst;
  11960. }
  11961. function getAnimate(geomType, coord, animationType, animationName) {
  11962. var result;
  11963. if (Util.isFunction(animationName)) {
  11964. result = animationName;
  11965. } else if (Util.isString(animationName)) {
  11966. result = Animate.Action[animationName];
  11967. } else {
  11968. result = Animate.getAnimation(geomType, coord, animationType);
  11969. }
  11970. return result;
  11971. }
  11972. function getAnimateCfg(geomType, animationType, animateCfg) {
  11973. if (animateCfg === false || Util.isObject(animateCfg) && animateCfg[animationType] === false) {
  11974. return false;
  11975. }
  11976. var defaultCfg = Animate.getAnimateCfg(geomType, animationType);
  11977. if (animateCfg && animateCfg[animationType]) {
  11978. return Util.deepMix({}, defaultCfg, animateCfg[animationType]);
  11979. }
  11980. return defaultCfg;
  11981. }
  11982. function addAnimate(cache, shapes, canvas) {
  11983. var animate;
  11984. var animateCfg; // the order of animation: leave -> update -> enter
  11985. var updateShapes = [];
  11986. var newShapes = [];
  11987. Util.each(shapes, function (shape) {
  11988. var result = cache[shape._id];
  11989. if (!result) {
  11990. newShapes.push(shape);
  11991. } else {
  11992. shape.set('cacheShape', result);
  11993. updateShapes.push(shape);
  11994. delete cache[shape._id];
  11995. }
  11996. }); // first do the leave animation
  11997. Util.each(cache, function (deletedShape) {
  11998. var className = deletedShape.className,
  11999. coord = deletedShape.coord,
  12000. _id = deletedShape._id,
  12001. attrs = deletedShape.attrs,
  12002. index = deletedShape.index,
  12003. type = deletedShape.type;
  12004. animateCfg = getAnimateCfg(className, 'leave', deletedShape.animateCfg);
  12005. if (animateCfg === false) return true;
  12006. animate = getAnimate(className, coord, 'leave', animateCfg.animation);
  12007. if (Util.isFunction(animate)) {
  12008. var tempShape = canvas.addShape(type, {
  12009. attrs: attrs,
  12010. index: index,
  12011. canvas: canvas,
  12012. className: className
  12013. });
  12014. tempShape._id = _id;
  12015. animate(tempShape, animateCfg, coord);
  12016. }
  12017. }); // then do the update animation
  12018. Util.each(updateShapes, function (updateShape) {
  12019. var className = updateShape.get('className');
  12020. animateCfg = getAnimateCfg(className, 'update', updateShape.get('animateCfg'));
  12021. if (animateCfg === false) return true;
  12022. var coord = updateShape.get('coord');
  12023. var cacheAttrs = updateShape.get('cacheShape').attrs;
  12024. var endState = diff(cacheAttrs, updateShape._attrs.attrs); // 判断如果属性相同的话就不进行变换
  12025. if (Object.keys(endState).length) {
  12026. animate = getAnimate(className, coord, 'update', animateCfg.animation);
  12027. if (Util.isFunction(animate)) {
  12028. animate(updateShape, animateCfg, coord);
  12029. } else {
  12030. updateShape.attr(cacheAttrs);
  12031. updateShape.animate().to({
  12032. attrs: endState,
  12033. duration: animateCfg.duration,
  12034. easing: animateCfg.easing,
  12035. delay: animateCfg.delay
  12036. }).onEnd(function () {
  12037. updateShape.set('cacheShape', null);
  12038. });
  12039. }
  12040. }
  12041. }); // last, enter animation
  12042. Util.each(newShapes, function (newShape) {
  12043. // 新图形元素的进场元素
  12044. var className = newShape.get('className');
  12045. var coord = newShape.get('coord');
  12046. animateCfg = getAnimateCfg(className, 'enter', newShape.get('animateCfg'));
  12047. if (animateCfg === false) return true;
  12048. animate = getAnimate(className, coord, 'enter', animateCfg.animation);
  12049. if (Util.isFunction(animate)) {
  12050. if (className === 'interval' && coord.isPolar && coord.transposed) {
  12051. var index = newShape.get('index');
  12052. var lastShape = updateShapes[index - 1];
  12053. animate(newShape, animateCfg, lastShape);
  12054. } else {
  12055. animate(newShape, animateCfg, coord);
  12056. }
  12057. }
  12058. });
  12059. }
  12060. function _getAnimateCfgByShapeType(type, chart) {
  12061. if (!type) {
  12062. return null;
  12063. }
  12064. var animateCfg = chart.get('animate');
  12065. if (type.indexOf('guide-tag') > -1) {
  12066. type = 'guide-tag';
  12067. }
  12068. if (Util.isObject(animateCfg)) {
  12069. return animateCfg[type];
  12070. }
  12071. if (animateCfg === false) {
  12072. return false;
  12073. }
  12074. return null;
  12075. }
  12076. module.exports = {
  12077. afterCanvasInit: function afterCanvasInit()
  12078. /* chart */
  12079. {
  12080. timeline = new Timeline();
  12081. timeline.play();
  12082. },
  12083. beforeCanvasDraw: function beforeCanvasDraw(chart) {
  12084. if (chart.get('animate') === false) {
  12085. return;
  12086. }
  12087. var isUpdate = chart.get('isUpdate');
  12088. var canvas = chart.get('canvas');
  12089. var coord = chart.get('coord');
  12090. var geoms = chart.get('geoms');
  12091. var caches = canvas.get('caches') || [];
  12092. if (caches.length === 0) {
  12093. isUpdate = false;
  12094. }
  12095. var cacheShapes = getShapes(geoms, chart, coord);
  12096. var _chart$get = chart.get('axisController'),
  12097. frontPlot = _chart$get.frontPlot,
  12098. backPlot = _chart$get.backPlot;
  12099. var axisShapes = frontPlot.get('children').concat(backPlot.get('children'));
  12100. var guideShapes = [];
  12101. if (chart.get('guideController')) {
  12102. guideShapes = chart.get('guideController').guideShapes;
  12103. }
  12104. var componentShapes = [];
  12105. axisShapes.concat(guideShapes).forEach(function (s) {
  12106. var className = s.get('className');
  12107. var animateCfg = _getAnimateCfgByShapeType(className, chart);
  12108. s.set('coord', coord);
  12109. s.set('animateCfg', animateCfg);
  12110. componentShapes.push(s);
  12111. cacheShapes.push(s);
  12112. });
  12113. canvas.set('caches', cache(cacheShapes));
  12114. if (isUpdate) {
  12115. addAnimate(caches, cacheShapes, canvas);
  12116. } else {
  12117. // do the appear animation
  12118. var animateCfg;
  12119. var animate;
  12120. Util.each(geoms, function (geom) {
  12121. var type = geom.get('type');
  12122. var geomCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
  12123. if (geomCfg !== false) {
  12124. animateCfg = getAnimateCfg(type, 'appear', geomCfg);
  12125. animate = getAnimate(type, coord, 'appear', animateCfg.animation);
  12126. if (Util.isFunction(animate)) {
  12127. var shapes = geom.get('shapes');
  12128. Util.each(shapes, function (shape) {
  12129. animate(shape, animateCfg, coord);
  12130. });
  12131. } else if (GROUP_ANIMATION[type]) {
  12132. // do the default animation
  12133. animate = GroupAction[animateCfg.animation] || GROUP_ANIMATION[type](coord);
  12134. var yScale = geom.getYScale();
  12135. var zeroY = coord.convertPoint({
  12136. x: 0,
  12137. y: yScale.scale(geom.getYMinValue())
  12138. });
  12139. var container = geom.get('container');
  12140. animate && animate(container, animateCfg, coord, zeroY);
  12141. }
  12142. }
  12143. }); // do the animation of components
  12144. Util.each(componentShapes, function (shape) {
  12145. var animateCfg = shape.get('animateCfg');
  12146. var className = shape.get('className');
  12147. if (animateCfg && animateCfg.appear) {
  12148. // if user configure
  12149. var defaultCfg = Animate.getAnimateCfg(className, 'appear');
  12150. var appearCfg = Util.deepMix({}, defaultCfg, animateCfg.appear);
  12151. var _animate = getAnimate(className, coord, 'appear', appearCfg.animation);
  12152. if (Util.isFunction(_animate)) {
  12153. _animate(shape, appearCfg, coord);
  12154. }
  12155. }
  12156. });
  12157. }
  12158. },
  12159. afterCanvasDestroyed: function afterCanvasDestroyed()
  12160. /* chart */
  12161. {
  12162. timeline.stop();
  12163. }
  12164. };
  12165. /***/ }),
  12166. /* 120 */
  12167. /***/ (function(module, exports, __webpack_require__) {
  12168. var _require = __webpack_require__(36),
  12169. requestAnimationFrame = _require.requestAnimationFrame;
  12170. var clock = typeof performance === 'object' && performance.now ? performance : Date;
  12171. var Timeline =
  12172. /*#__PURE__*/
  12173. function () {
  12174. function Timeline() {
  12175. this.anims = [];
  12176. this.time = null;
  12177. this.playing = false;
  12178. this.canvas = [];
  12179. }
  12180. var _proto = Timeline.prototype;
  12181. _proto.play = function play() {
  12182. var self = this;
  12183. self.time = clock.now();
  12184. self.playing = true;
  12185. function step() {
  12186. if (self.playing) {
  12187. requestAnimationFrame(step);
  12188. self.update();
  12189. }
  12190. }
  12191. requestAnimationFrame(step);
  12192. };
  12193. _proto.stop = function stop() {
  12194. this.playing = false;
  12195. this.time = null;
  12196. this.canvas = [];
  12197. };
  12198. _proto.update = function update() {
  12199. var currentTime = clock.now();
  12200. this.canvas = [];
  12201. for (var i = 0; i < this.anims.length; i++) {
  12202. var propertyAnim = this.anims[i];
  12203. if (currentTime < propertyAnim.startTime || propertyAnim.hasEnded) {
  12204. continue;
  12205. }
  12206. var shape = propertyAnim.shape; // shape
  12207. if (shape.get('destroyed')) {
  12208. this.anims.splice(i, 1);
  12209. i--;
  12210. continue;
  12211. }
  12212. var startState = propertyAnim.startState,
  12213. endState = propertyAnim.endState,
  12214. interpolate = propertyAnim.interpolate,
  12215. duration = propertyAnim.duration;
  12216. if (currentTime >= propertyAnim.startTime && !propertyAnim.hasStarted) {
  12217. propertyAnim.hasStarted = true;
  12218. if (propertyAnim.onStart) {
  12219. propertyAnim.onStart();
  12220. }
  12221. }
  12222. var t = (currentTime - propertyAnim.startTime) / duration;
  12223. t = Math.max(0, Math.min(t, 1));
  12224. t = propertyAnim.easing(t);
  12225. if (propertyAnim.onFrame) {
  12226. propertyAnim.onFrame(t);
  12227. } else {
  12228. for (var key in interpolate) {
  12229. var diff = interpolate[key];
  12230. var value = diff(t);
  12231. var newValue = void 0;
  12232. if (key === 'points') {
  12233. newValue = [];
  12234. var aLen = Math.max(startState.points.length, endState.points.length);
  12235. for (var j = 0; j < aLen; j += 2) {
  12236. newValue.push({
  12237. x: value[j],
  12238. y: value[j + 1]
  12239. });
  12240. }
  12241. } else {
  12242. newValue = value;
  12243. }
  12244. shape._attrs.attrs[key] = newValue;
  12245. shape._attrs.bbox = null; // should clear calculated bbox
  12246. }
  12247. }
  12248. var canvas = shape.get('canvas');
  12249. if (this.canvas.indexOf(canvas) === -1) {
  12250. this.canvas.push(canvas);
  12251. }
  12252. if (propertyAnim.onUpdate) {
  12253. propertyAnim.onUpdate(t);
  12254. }
  12255. if (currentTime >= propertyAnim.endTime && !propertyAnim.hasEnded) {
  12256. propertyAnim.hasEnded = true;
  12257. if (propertyAnim.onEnd) {
  12258. propertyAnim.onEnd();
  12259. }
  12260. }
  12261. if (t === 1) {
  12262. // end
  12263. this.anims.splice(i, 1);
  12264. i--;
  12265. }
  12266. }
  12267. this.canvas.map(function (c) {
  12268. c.draw();
  12269. return c;
  12270. });
  12271. this.time = clock.now();
  12272. };
  12273. return Timeline;
  12274. }();
  12275. module.exports = Timeline;
  12276. /***/ }),
  12277. /* 121 */
  12278. /***/ (function(module, exports, __webpack_require__) {
  12279. var Easing = __webpack_require__(122);
  12280. function plainArray(arr) {
  12281. var result = [];
  12282. for (var i = 0, len = arr.length; i < len; i++) {
  12283. if (arr[i]) {
  12284. result.push(arr[i].x);
  12285. result.push(arr[i].y);
  12286. }
  12287. }
  12288. return result;
  12289. }
  12290. function interpolateNumber(a, b) {
  12291. a = +a;
  12292. b -= a;
  12293. return function (t) {
  12294. return a + b * t;
  12295. };
  12296. }
  12297. function interpolateArray(a, b) {
  12298. var nb = b ? b.length : 0;
  12299. var na = a ? Math.min(nb, a.length) : 0;
  12300. var x = new Array(na);
  12301. var c = new Array(nb);
  12302. var i;
  12303. for (i = 0; i < na; ++i) {
  12304. x[i] = interpolateNumber(a[i], b[i]);
  12305. }
  12306. for (; i < nb; ++i) {
  12307. c[i] = b[i];
  12308. }
  12309. return function (t) {
  12310. for (i = 0; i < na; ++i) {
  12311. c[i] = x[i](t);
  12312. }
  12313. return c;
  12314. };
  12315. }
  12316. var Animator =
  12317. /*#__PURE__*/
  12318. function () {
  12319. function Animator(shape, source, timeline) {
  12320. this.hasStarted = false;
  12321. this.hasEnded = false;
  12322. this.shape = shape;
  12323. this.source = source;
  12324. this.timeline = timeline;
  12325. this.animate = null;
  12326. } // delay, attrs, duration, easing
  12327. var _proto = Animator.prototype;
  12328. _proto.to = function to(cfg) {
  12329. if (cfg === void 0) {
  12330. cfg = {};
  12331. }
  12332. var delay = cfg.delay || 0;
  12333. var attrs = cfg.attrs || {};
  12334. var duration = cfg.duration || 1000;
  12335. var easing; // 缓动函数
  12336. if (typeof cfg.easing === 'function') {
  12337. easing = cfg.easing;
  12338. } else {
  12339. easing = Easing[cfg.easing] || Easing.linear;
  12340. }
  12341. var animInfo = {
  12342. shape: this.shape,
  12343. startTime: this.timeline.time + delay,
  12344. duration: duration,
  12345. easing: easing
  12346. };
  12347. var interpolate = {}; // 差值函数
  12348. for (var attrName in attrs) {
  12349. var startValue = this.source[attrName];
  12350. var endValue = attrs[attrName];
  12351. if (attrName === 'points') {
  12352. startValue = plainArray(startValue);
  12353. endValue = plainArray(endValue);
  12354. interpolate.points = interpolateArray(startValue, endValue);
  12355. this.source.points = startValue;
  12356. attrs.points = endValue;
  12357. } else if (attrName === 'matrix') {
  12358. interpolate.matrix = interpolateArray(startValue, endValue);
  12359. } else {
  12360. interpolate[attrName] = interpolateNumber(startValue, endValue);
  12361. }
  12362. }
  12363. animInfo.interpolate = interpolate;
  12364. animInfo.startState = this.source;
  12365. animInfo.endState = attrs;
  12366. animInfo.endTime = animInfo.startTime + duration;
  12367. this.timeline.anims.push(animInfo);
  12368. this.animate = animInfo;
  12369. return this;
  12370. };
  12371. _proto.onFrame = function onFrame(callback) {
  12372. // 自定义每一帧动画的动作
  12373. if (this.animate) {
  12374. this.animate.onFrame = function (frame) {
  12375. callback(frame);
  12376. };
  12377. }
  12378. return this;
  12379. };
  12380. _proto.onStart = function onStart(callback) {
  12381. if (this.animate) {
  12382. this.animate.onStart = function () {
  12383. callback();
  12384. };
  12385. }
  12386. return this;
  12387. };
  12388. _proto.onUpdate = function onUpdate(callback) {
  12389. if (this.animate) {
  12390. this.animate.onUpdate = function (frame) {
  12391. callback(frame);
  12392. };
  12393. }
  12394. return this;
  12395. };
  12396. _proto.onEnd = function onEnd(callback) {
  12397. if (this.animate) {
  12398. this.animate.onEnd = function () {
  12399. callback();
  12400. };
  12401. }
  12402. return this;
  12403. };
  12404. return Animator;
  12405. }();
  12406. module.exports = Animator;
  12407. /***/ }),
  12408. /* 122 */
  12409. /***/ (function(module, exports) {
  12410. var Easing = {
  12411. linear: function linear(k) {
  12412. return k;
  12413. },
  12414. quadraticIn: function quadraticIn(k) {
  12415. return k * k;
  12416. },
  12417. quadraticOut: function quadraticOut(k) {
  12418. return k * (2 - k);
  12419. },
  12420. quadraticInOut: function quadraticInOut(k) {
  12421. if ((k *= 2) < 1) {
  12422. return 0.5 * k * k;
  12423. }
  12424. return -0.5 * (--k * (k - 2) - 1);
  12425. },
  12426. cubicIn: function cubicIn(k) {
  12427. return k * k * k;
  12428. },
  12429. cubicOut: function cubicOut(k) {
  12430. return --k * k * k + 1;
  12431. },
  12432. cubicInOut: function cubicInOut(k) {
  12433. if ((k *= 2) < 1) {
  12434. return 0.5 * k * k * k;
  12435. }
  12436. return 0.5 * ((k -= 2) * k * k + 2);
  12437. },
  12438. elasticIn: function elasticIn(k) {
  12439. var s;
  12440. var a = 0.1;
  12441. var p = 0.4;
  12442. if (k === 0) return 0;
  12443. if (k === 1) return 1;
  12444. if (!p) {
  12445. p = 0.3;
  12446. }
  12447. if (!a || a < 1) {
  12448. a = 1;
  12449. s = p / 4;
  12450. } else {
  12451. s = p / (2 * Math.PI) * Math.asin(1 / a);
  12452. }
  12453. return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  12454. },
  12455. elasticOut: function elasticOut(k) {
  12456. var s;
  12457. var a = 0.1;
  12458. var p = 0.4;
  12459. if (k === 0) return 0;
  12460. if (k === 1) return 1;
  12461. if (!p) {
  12462. p = 0.3;
  12463. }
  12464. if (!a || a < 1) {
  12465. a = 1;
  12466. s = p / 4;
  12467. } else {
  12468. s = p / (2 * Math.PI) * Math.asin(1 / a);
  12469. }
  12470. return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
  12471. },
  12472. elasticInOut: function elasticInOut(k) {
  12473. var s;
  12474. var a = 0.1;
  12475. var p = 0.4;
  12476. if (k === 0) return 0;
  12477. if (k === 1) return 1;
  12478. if (!p) {
  12479. p = 0.3;
  12480. }
  12481. if (!a || a < 1) {
  12482. a = 1;
  12483. s = p / 4;
  12484. } else {
  12485. s = p / (2 * Math.PI) * Math.asin(1 / a);
  12486. }
  12487. if ((k *= 2) < 1) {
  12488. return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  12489. }
  12490. return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  12491. },
  12492. backIn: function backIn(k) {
  12493. var s = 1.70158;
  12494. return k * k * ((s + 1) * k - s);
  12495. },
  12496. backOut: function backOut(k) {
  12497. var s = 1.70158;
  12498. return (k = k - 1) * k * ((s + 1) * k + s) + 1;
  12499. },
  12500. backInOut: function backInOut(k) {
  12501. var s = 1.70158 * 1.525;
  12502. if ((k *= 2) < 1) {
  12503. return 0.5 * (k * k * ((s + 1) * k - s));
  12504. }
  12505. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  12506. },
  12507. bounceIn: function bounceIn(k) {
  12508. return 1 - Easing.bounceOut(1 - k);
  12509. },
  12510. bounceOut: function bounceOut(k) {
  12511. if ((k /= 1) < 1 / 2.75) {
  12512. return 7.5625 * k * k;
  12513. } else if (k < 2 / 2.75) {
  12514. return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
  12515. } else if (k < 2.5 / 2.75) {
  12516. return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
  12517. }
  12518. return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
  12519. },
  12520. bounceInOut: function bounceInOut(k) {
  12521. if (k < 0.5) {
  12522. return Easing.bounceIn(k * 2) * 0.5;
  12523. }
  12524. return Easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  12525. }
  12526. };
  12527. module.exports = Easing;
  12528. /***/ }),
  12529. /* 123 */
  12530. /***/ (function(module, exports, __webpack_require__) {
  12531. /**
  12532. * Animation functions for shape
  12533. * @author sima.zhang1990@gmail.com
  12534. */
  12535. var Util = __webpack_require__(0);
  12536. var Helpers = __webpack_require__(93);
  12537. /*
  12538. function waveIn(shape, animateCfg, coord) {
  12539. const clip = Helpers.getClip(coord);
  12540. clip.set('canvas', shape.get('canvas'));
  12541. shape.attr('clip', clip);
  12542. const onEnd = function() {
  12543. shape.attr('clip', null);
  12544. clip.remove(true);
  12545. };
  12546. Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
  12547. }
  12548. function scaleInX(shape, animateCfg) {
  12549. const box = shape.getBBox();
  12550. const points = shape.get('origin').points;
  12551. let x;
  12552. const y = (box.minY + box.maxY) / 2;
  12553. if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
  12554. x = box.maxX;
  12555. } else {
  12556. x = box.minX;
  12557. }
  12558. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  12559. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  12560. }
  12561. function scaleInY(shape, animateCfg) {
  12562. const box = shape.getBBox();
  12563. const points = shape.get('origin').points;
  12564. const x = (box.minX + box.maxX) / 2;
  12565. let y;
  12566. if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
  12567. y = box.maxY;
  12568. } else {
  12569. y = box.minY;
  12570. }
  12571. const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
  12572. Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
  12573. }
  12574. */
  12575. function fadeIn(shape, animateCfg) {
  12576. var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
  12577. var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
  12578. shape.attr('fillOpacity', 0);
  12579. shape.attr('strokeOpacity', 0);
  12580. var endState = {
  12581. fillOpacity: fillOpacity,
  12582. strokeOpacity: strokeOpacity
  12583. };
  12584. Helpers.doAnimation(shape, endState, animateCfg);
  12585. }
  12586. module.exports = {
  12587. // waveIn,
  12588. // scaleInX,
  12589. // scaleInY,
  12590. fadeIn: fadeIn
  12591. };
  12592. /***/ }),
  12593. /* 124 */
  12594. /***/ (function(module, exports, __webpack_require__) {
  12595. /**
  12596. * Group animate functions
  12597. * @author sima.zhang1990@gmail.com
  12598. */
  12599. var Util = __webpack_require__(93);
  12600. var Helper = __webpack_require__(26);
  12601. var _require = __webpack_require__(5),
  12602. Shape = _require.Shape;
  12603. function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
  12604. var _Util$getCoordInfo = Util.getCoordInfo(coord),
  12605. start = _Util$getCoordInfo.start,
  12606. end = _Util$getCoordInfo.end,
  12607. width = _Util$getCoordInfo.width,
  12608. height = _Util$getCoordInfo.height;
  12609. var x;
  12610. var y;
  12611. var clip = new Shape.Rect({
  12612. attrs: {
  12613. x: start.x,
  12614. y: end.y,
  12615. width: width,
  12616. height: height
  12617. }
  12618. });
  12619. if (type === 'y') {
  12620. x = start.x + width / 2;
  12621. y = zeroY.y < start.y ? zeroY.y : start.y;
  12622. } else if (type === 'x') {
  12623. x = zeroY.x > start.x ? zeroY.x : start.x;
  12624. y = start.y + height / 2;
  12625. } else if (type === 'xy') {
  12626. if (coord.isPolar) {
  12627. x = coord.center.x;
  12628. y = coord.center.y;
  12629. } else {
  12630. x = (start.x + end.x) / 2;
  12631. y = (start.y + end.y) / 2;
  12632. }
  12633. }
  12634. var endMatrix = Util.getScaledMatrix(clip, [x, y], type);
  12635. clip.isClip = true;
  12636. clip.endState = {
  12637. matrix: endMatrix
  12638. };
  12639. clip.set('canvas', container.get('canvas'));
  12640. container.attr('clip', clip);
  12641. var onEnd = function onEnd() {
  12642. container.attr('clip', null);
  12643. clip.remove(true);
  12644. };
  12645. Util.doAnimation(clip, clip.endState, animateCfg, onEnd);
  12646. }
  12647. function _shapeScale(container, animateCfg, type) {
  12648. var shapes = container.get('children');
  12649. var x;
  12650. var y;
  12651. var endMatrix;
  12652. for (var i = 0, len = shapes.length; i < len; i++) {
  12653. var shape = shapes[i];
  12654. var box = shape.getBBox();
  12655. x = (box.minX + box.maxX) / 2;
  12656. y = (box.minY + box.maxY) / 2;
  12657. endMatrix = Util.getScaledMatrix(shape, [x, y], type);
  12658. Util.doAnimation(shape, {
  12659. matrix: endMatrix
  12660. }, animateCfg);
  12661. }
  12662. }
  12663. function groupScaleInX(container, animateCfg, coord, zeroY) {
  12664. _groupScaleIn(container, animateCfg, coord, zeroY, 'x');
  12665. }
  12666. function groupScaleInY(container, animateCfg, coord, zeroY) {
  12667. _groupScaleIn(container, animateCfg, coord, zeroY, 'y');
  12668. }
  12669. function groupScaleInXY(container, animateCfg, coord, zeroY) {
  12670. _groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
  12671. }
  12672. function shapesScaleInX(container, animateCfg) {
  12673. _shapeScale(container, animateCfg, 'x');
  12674. }
  12675. function shapesScaleInY(container, animateCfg) {
  12676. _shapeScale(container, animateCfg, 'y');
  12677. }
  12678. function shapesScaleInXY(container, animateCfg) {
  12679. _shapeScale(container, animateCfg, 'xy');
  12680. }
  12681. function groupWaveIn(container, animateCfg, coord) {
  12682. var clip = Helper.getClip(coord);
  12683. clip.set('canvas', container.get('canvas'));
  12684. container.attr('clip', clip);
  12685. var onEnd = function onEnd() {
  12686. container.attr('clip', null);
  12687. clip.remove(true);
  12688. };
  12689. var endState = {};
  12690. if (coord.isPolar) {
  12691. var startAngle = coord.startAngle,
  12692. endAngle = coord.endAngle;
  12693. endState.endAngle = endAngle;
  12694. clip.attr('endAngle', startAngle);
  12695. } else {
  12696. var start = coord.start,
  12697. end = coord.end;
  12698. var width = Math.abs(start.x - end.x);
  12699. var height = Math.abs(start.y - end.y);
  12700. if (coord.isTransposed) {
  12701. clip.attr('height', 0);
  12702. endState.height = height;
  12703. } else {
  12704. clip.attr('width', 0);
  12705. endState.width = width;
  12706. }
  12707. }
  12708. Util.doAnimation(clip, endState, animateCfg, onEnd);
  12709. }
  12710. module.exports = {
  12711. groupWaveIn: groupWaveIn,
  12712. groupScaleInX: groupScaleInX,
  12713. groupScaleInY: groupScaleInY,
  12714. groupScaleInXY: groupScaleInXY,
  12715. shapesScaleInX: shapesScaleInX,
  12716. shapesScaleInY: shapesScaleInY,
  12717. shapesScaleInXY: shapesScaleInXY
  12718. };
  12719. /***/ }),
  12720. /* 125 */,
  12721. /* 126 */,
  12722. /* 127 */,
  12723. /* 128 */,
  12724. /* 129 */
  12725. /***/ (function(module, exports, __webpack_require__) {
  12726. /**
  12727. * Default, without interactins
  12728. */
  12729. var F2 = __webpack_require__(41);
  12730. __webpack_require__(95);
  12731. __webpack_require__(83);
  12732. __webpack_require__(88); // polar coordinate
  12733. __webpack_require__(104); // the axis for polar coordinate
  12734. __webpack_require__(105); // timeCat scale
  12735. __webpack_require__(108);
  12736. __webpack_require__(109);
  12737. __webpack_require__(110);
  12738. __webpack_require__(111);
  12739. __webpack_require__(112);
  12740. __webpack_require__(113);
  12741. var Tooltip = __webpack_require__(114);
  12742. var Guide = __webpack_require__(117);
  12743. var Legend = __webpack_require__(118);
  12744. var Animation = __webpack_require__(119);
  12745. F2.Animate = __webpack_require__(92); // register plugins
  12746. F2.Chart.plugins.register([Tooltip, Legend, Guide, Animation]);
  12747. module.exports = F2;
  12748. /***/ })
  12749. /******/ ]);
  12750. });