| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define([], factory);
- else if(typeof exports === 'object')
- exports["F2"] = factory();
- else
- root["F2"] = factory();
- })(this, function() {
- return /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId]) {
- /******/ return installedModules[moduleId].exports;
- /******/ }
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 129);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview Utility for F2
- * @author dxq613@gmail.com
- */
- var DomUtil = __webpack_require__(43);
- var Util = {
- upperFirst: __webpack_require__(44),
- lowerFirst: __webpack_require__(45),
- isString: __webpack_require__(15),
- isNumber: __webpack_require__(13),
- isBoolean: __webpack_require__(46),
- isFunction: __webpack_require__(47),
- isDate: __webpack_require__(33),
- isArray: __webpack_require__(10),
- isNil: __webpack_require__(7),
- isObject: __webpack_require__(18),
- isPlainObject: __webpack_require__(28),
- deepMix: __webpack_require__(49),
- mix: __webpack_require__(16),
- each: __webpack_require__(3),
- isObjectValueEqual: function isObjectValueEqual(a, b) {
- // for vue.js
- a = Object.assign({}, a);
- b = Object.assign({}, b);
- var aProps = Object.getOwnPropertyNames(a);
- var bProps = Object.getOwnPropertyNames(b);
- if (aProps.length !== bProps.length) {
- return false;
- }
- for (var i = 0, len = aProps.length; i < len; i++) {
- var propName = aProps[i];
- if (a[propName] !== b[propName]) {
- return false;
- }
- }
- return true;
- },
- wrapBehavior: function wrapBehavior(obj, action) {
- if (obj['_wrap_' + action]) {
- return obj['_wrap_' + action];
- }
- var method = function method(e) {
- obj[action](e);
- };
- obj['_wrap_' + action] = method;
- return method;
- },
- getWrapBehavior: function getWrapBehavior(obj, action) {
- return obj['_wrap_' + action];
- },
- parsePadding: function parsePadding(padding) {
- var top;
- var right;
- var bottom;
- var left;
- if (Util.isNumber(padding) || Util.isString(padding)) {
- top = bottom = left = right = padding;
- } else if (Util.isArray(padding)) {
- top = padding[0];
- right = !Util.isNil(padding[1]) ? padding[1] : padding[0];
- bottom = !Util.isNil(padding[2]) ? padding[2] : padding[0];
- left = !Util.isNil(padding[3]) ? padding[3] : right;
- }
- return [top, right, bottom, left];
- },
- directionEnabled: function directionEnabled(mode, dir) {
- if (mode === undefined) {
- return true;
- } else if (typeof mode === 'string') {
- return mode.indexOf(dir) !== -1;
- }
- return false;
- }
- };
- Util.Array = {
- merge: function merge(dataArray) {
- var rst = [];
- for (var i = 0, len = dataArray.length; i < len; i++) {
- rst = rst.concat(dataArray[i]);
- }
- return rst;
- },
- values: function values(data, name) {
- var rst = [];
- var tmpMap = {};
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!Util.isNil(value)) {
- if (!Util.isArray(value)) {
- if (!tmpMap[value]) {
- rst.push(value);
- tmpMap[value] = true;
- }
- } else {
- Util.each(value, function (val) {
- if (!tmpMap[val]) {
- rst.push(val);
- tmpMap[val] = true;
- }
- });
- }
- }
- }
- return rst;
- },
- firstValue: function firstValue(data, name) {
- var rst = null;
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var value = obj[name];
- if (!Util.isNil(value)) {
- if (Util.isArray(value)) {
- rst = value[0];
- } else {
- rst = value;
- }
- break;
- }
- }
- return rst;
- },
- group: function group(data, fields, appendConditions) {
- if (appendConditions === void 0) {
- appendConditions = {};
- }
- if (!fields) {
- return [data];
- }
- var groups = Util.Array.groupToMap(data, fields);
- var array = [];
- if (fields.length === 1 && appendConditions[fields[0]]) {
- var values = appendConditions[fields[0]];
- Util.each(values, function (value) {
- value = '_' + value;
- array.push(groups[value]);
- });
- } else {
- for (var i in groups) {
- array.push(groups[i]);
- }
- }
- return array;
- },
- groupToMap: function groupToMap(data, fields) {
- if (!fields) {
- return {
- 0: data
- };
- }
- var callback = function callback(row) {
- var unique = '_';
- for (var i = 0, l = fields.length; i < l; i++) {
- unique += row[fields[i]] && row[fields[i]].toString();
- }
- return unique;
- };
- var groups = {};
- for (var i = 0, len = data.length; i < len; i++) {
- var row = data[i];
- var key = callback(row);
- if (groups[key]) {
- groups[key].push(row);
- } else {
- groups[key] = [row];
- }
- }
- return groups;
- },
- remove: function remove(arr, obj) {
- if (!arr) {
- return;
- }
- var index = arr.indexOf(obj);
- if (index !== -1) {
- arr.splice(index, 1);
- }
- },
- getRange: function getRange(values) {
- if (!values.length) {
- return {
- min: 0,
- max: 0
- };
- }
- var max = Math.max.apply(null, values);
- var min = Math.min.apply(null, values);
- return {
- min: min,
- max: max
- };
- }
- };
- Util.mix(Util, DomUtil);
- module.exports = Util;
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- var Theme = __webpack_require__(42);
- var Util = __webpack_require__(0);
- var Global = {
- version: '3.3.3',
- trackable: true,
- scales: {},
- widthRatio: {
- column: 1 / 2,
- rose: 0.999999,
- multiplePie: 3 / 4
- },
- lineDash: [4, 4]
- };
- Global.setTheme = function (theme) {
- Util.deepMix(this, theme);
- };
- Global.setTheme(Theme);
- module.exports = Global;
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Element = __webpack_require__(25);
- var Shape =
- /*#__PURE__*/
- function (_Element) {
- _inheritsLoose(Shape, _Element);
- function Shape() {
- return _Element.apply(this, arguments) || this;
- }
- var _proto = Shape.prototype;
- _proto._initProperties = function _initProperties() {
- this._attrs = {
- zIndex: 0,
- visible: true,
- destroyed: false,
- isShape: true,
- attrs: {}
- };
- };
- _proto.getType = function getType() {
- return this._attrs.type;
- };
- _proto.drawInner = function drawInner(context) {
- var self = this;
- var attrs = self.get('attrs');
- self.createPath(context);
- var originOpacity = context.globalAlpha;
- if (self.hasFill()) {
- var fillOpacity = attrs.fillOpacity;
- if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
- context.globalAlpha = fillOpacity;
- context.fill();
- context.globalAlpha = originOpacity;
- } else {
- context.fill();
- }
- }
- if (self.hasStroke()) {
- var lineWidth = attrs.lineWidth;
- if (lineWidth > 0) {
- var strokeOpacity = attrs.strokeOpacity;
- if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
- context.globalAlpha = strokeOpacity;
- }
- context.stroke();
- }
- }
- };
- _proto.getBBox = function getBBox() {
- var bbox = this._attrs.bbox;
- if (!bbox) {
- bbox = this.calculateBox();
- if (bbox) {
- bbox.x = bbox.minX;
- bbox.y = bbox.minY;
- bbox.width = bbox.maxX - bbox.minX;
- bbox.height = bbox.maxY - bbox.minY;
- }
- this._attrs.bbox = bbox;
- }
- return bbox;
- };
- _proto.calculateBox = function calculateBox() {
- return null;
- };
- _proto.createPath = function createPath() {};
- return Shape;
- }(Element);
- module.exports = Shape;
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObject = __webpack_require__(18);
- var isArray = __webpack_require__(10);
- var each = function each(elements, func) {
- if (!elements) {
- return;
- }
- var rst = void 0;
- if (isArray(elements)) {
- for (var i = 0, len = elements.length; i < len; i++) {
- rst = func(elements[i], i);
- if (rst === false) {
- break;
- }
- }
- } else if (isObject(elements)) {
- for (var k in elements) {
- if (elements.hasOwnProperty(k)) {
- rst = func(elements[k], k);
- if (rst === false) {
- break;
- }
- }
- }
- }
- };
- module.exports = each;
- /***/ }),
- /* 4 */
- /***/ (function(module, exports) {
- /**
- * 2 Dimensional Vector
- * @module vector2
- */
- module.exports = {
- /**
- * Creates a new, empty vector2
- *
- * @return {vector2} a new 2D vector
- */
- create: function create() {
- return [0, 0];
- },
- /**
- * Calculates the length of a vector2
- *
- * @param {vector2} v vector to calculate length of
- * @return {Number} length of v
- */
- length: function length(v) {
- var x = v[0];
- var y = v[1];
- return Math.sqrt(x * x + y * y);
- },
- /**
- * Normalize a vector2
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v vector to normalize
- * @return {vector2} out
- */
- normalize: function normalize(out, v) {
- var len = this.length(v);
- if (len === 0) {
- out[0] = 0;
- out[1] = 0;
- } else {
- out[0] = v[0] / len;
- out[1] = v[1] / len;
- }
- return out;
- },
- /**
- * Adds two vector2's
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- add: function add(out, v1, v2) {
- out[0] = v1[0] + v2[0];
- out[1] = v1[1] + v2[1];
- return out;
- },
- /**
- * Subtracts vector v2 from vector v1
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- sub: function sub(out, v1, v2) {
- out[0] = v1[0] - v2[0];
- out[1] = v1[1] - v2[1];
- return out;
- },
- /**
- * Scales a vector2 by a scalar number
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v the vector to scale
- * @param {Number} s amount to scale the vector by
- * @return {vector2} out
- */
- scale: function scale(out, v, s) {
- out[0] = v[0] * s;
- out[1] = v[1] * s;
- return out;
- },
- /**
- * Calculates the dot product of two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Number} dot product of v1 and v2
- */
- dot: function dot(v1, v2) {
- return v1[0] * v2[0] + v1[1] * v2[1];
- },
- /**
- * Calculates the direction of two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Boolean} the direction of v1 and v2
- */
- direction: function direction(v1, v2) {
- return v1[0] * v2[1] - v2[0] * v1[1];
- },
- /**
- * Calculates the angle of two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Number} angle of v1 and v2
- */
- angle: function angle(v1, v2) {
- var theta = this.dot(v1, v2) / (this.length(v1) * this.length(v2));
- return Math.acos(theta);
- },
- /**
- * Calculates the angle of two vector2's with direction
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @param {Boolean} direction the direction of two vector2's
- * @return {Number} angle of v1 and v2
- */
- angleTo: function angleTo(v1, v2, direction) {
- var angle = this.angle(v1, v2);
- var angleLargeThanPI = this.direction(v1, v2) >= 0;
- if (direction) {
- if (angleLargeThanPI) {
- return Math.PI * 2 - angle;
- }
- return angle;
- }
- if (angleLargeThanPI) {
- return angle;
- }
- return Math.PI * 2 - angle;
- },
- /**
- * whether a vector2 is zero vector
- *
- * @param {vector2} v vector to calculate
- * @return {Boolean} is or not a zero vector
- */
- zero: function zero(v) {
- return v[0] === 0 && v[1] === 0;
- },
- /**
- * Calculates the euclidian distance between two vector2's
- *
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {Number} distance between a and b
- */
- distance: function distance(v1, v2) {
- var x = v2[0] - v1[0];
- var y = v2[1] - v1[1];
- return Math.sqrt(x * x + y * y);
- },
- /**
- * Creates a new vector2 initialized with values from an existing vector
- *
- * @param {vector2} v vector to clone
- * @return {Array} a new 2D vector
- */
- clone: function clone(v) {
- return [v[0], v[1]];
- },
- /**
- * Return the minimum of two vector2's
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- min: function min(out, v1, v2) {
- out[0] = Math.min(v1[0], v2[0]);
- out[1] = Math.min(v1[1], v2[1]);
- return out;
- },
- /**
- * Return the maximum of two vector2's
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v1 the first operand
- * @param {vector2} v2 the second operand
- * @return {vector2} out
- */
- max: function max(out, v1, v2) {
- out[0] = Math.max(v1[0], v2[0]);
- out[1] = Math.max(v1[1], v2[1]);
- return out;
- },
- /**
- * Transforms the vector2 with a mat2d
- *
- * @param {vector2} out the receiving vector
- * @param {vector2} v the vector to transform
- * @param {mat2d} m matrix to transform with
- * @return {vector2} out
- */
- transformMat2d: function transformMat2d(out, v, m) {
- var x = v[0];
- var y = v[1];
- out[0] = m[0] * x + m[2] * y + m[4];
- out[1] = m[1] * x + m[3] * y + m[5];
- return out;
- }
- };
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
- var G = {
- Canvas: __webpack_require__(68),
- Group: __webpack_require__(31),
- Shape: __webpack_require__(2),
- Matrix: __webpack_require__(23),
- Vector2: __webpack_require__(4)
- };
- __webpack_require__(70);
- __webpack_require__(71);
- __webpack_require__(72);
- __webpack_require__(73);
- __webpack_require__(74);
- __webpack_require__(75);
- __webpack_require__(76);
- __webpack_require__(77);
- __webpack_require__(78);
- module.exports = G;
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Base = __webpack_require__(29);
- var GROUP_ATTRS = ['color', 'size', 'shape'];
- var FIELD_ORIGIN = '_origin';
- var FIELD_ORIGIN_Y = '_originY';
- var Global = __webpack_require__(1);
- var Attr = __webpack_require__(53);
- var GeometryShape = __webpack_require__(9);
- var Adjust = __webpack_require__(22);
- function parseFields(field) {
- if (Util.isArray(field)) {
- return field;
- }
- if (Util.isString(field)) {
- return field.split('*');
- }
- return [field];
- }
- /**
- * The parent class for Geometry
- * @class Geom
- */
- var Geom =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Geom, _Base);
- function Geom() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Geom.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- /**
- * geometry type
- * @type {String}
- */
- type: null,
- /**
- * the data of geometry
- * @type {Array}
- */
- data: null,
- /**
- * the attrs of geo,etry
- * @type {Object}
- */
- attrs: {},
- scales: {},
- /**
- * group for storing the shapes
- * @type {Canvas}
- */
- container: null,
- /**
- * style options
- * @type {Object}
- */
- styleOptions: null,
- chart: null,
- shapeType: '',
- /**
- * wether to generate key points for each shape
- * @protected
- * @type {Boolean}
- */
- generatePoints: false,
- attrOptions: {},
- sortable: false,
- startOnZero: true,
- visible: true,
- connectNulls: false
- };
- };
- _proto.init = function init() {
- var self = this;
- self._initAttrs();
- var dataArray = self._processData();
- if (self.get('adjust')) {
- self._adjustData(dataArray);
- }
- self.set('dataArray', dataArray);
- };
- _proto._getGroupScales = function _getGroupScales() {
- var self = this;
- var scales = [];
- Util.each(GROUP_ATTRS, function (attrName) {
- var attr = self.getAttr(attrName);
- if (attr) {
- var attrScales = attr.scales;
- Util.each(attrScales, function (scale) {
- if (scale && scale.isCategory && scales.indexOf(scale) === -1) {
- scales.push(scale);
- }
- });
- }
- });
- return scales;
- };
- _proto._groupData = function _groupData(data) {
- var self = this;
- var colDefs = self.get('colDefs');
- var groupScales = self._getGroupScales();
- if (groupScales.length) {
- var appendConditions = {};
- var names = [];
- Util.each(groupScales, function (scale) {
- var field = scale.field;
- names.push(field);
- if (colDefs && colDefs[field] && colDefs[field].values) {
- // users have defined
- appendConditions[scale.field] = colDefs[field].values;
- }
- });
- return Util.Array.group(data, names, appendConditions);
- }
- return [data];
- };
- _proto._setAttrOptions = function _setAttrOptions(attrName, attrCfg) {
- var options = this.get('attrOptions');
- options[attrName] = attrCfg;
- };
- _proto._createAttrOption = function _createAttrOption(attrName, field, cfg, defaultValues) {
- var attrCfg = {};
- attrCfg.field = field;
- if (cfg) {
- if (Util.isFunction(cfg)) {
- attrCfg.callback = cfg;
- } else {
- attrCfg.values = cfg;
- }
- } else {
- attrCfg.values = defaultValues;
- }
- this._setAttrOptions(attrName, attrCfg);
- };
- _proto._initAttrs = function _initAttrs() {
- var self = this;
- var attrs = self.get('attrs');
- var attrOptions = self.get('attrOptions');
- var coord = self.get('coord');
- for (var type in attrOptions) {
- if (attrOptions.hasOwnProperty(type)) {
- var option = attrOptions[type];
- var className = Util.upperFirst(type);
- var fields = parseFields(option.field);
- if (type === 'position') {
- option.coord = coord;
- }
- var scales = [];
- for (var i = 0, len = fields.length; i < len; i++) {
- var field = fields[i];
- var scale = self._createScale(field);
- scales.push(scale);
- }
- if (type === 'position') {
- var yScale = scales[1];
- if (coord.type === 'polar' && coord.transposed && self.hasAdjust('stack')) {
- if (yScale.values.length) {
- yScale.change({
- nice: false,
- min: 0,
- max: Math.max.apply(null, yScale.values)
- });
- }
- }
- }
- option.scales = scales;
- var attr = new Attr[className](option);
- attrs[type] = attr;
- }
- }
- };
- _proto._createScale = function _createScale(field) {
- var scales = this.get('scales');
- var scale = scales[field];
- if (!scale) {
- scale = this.get('chart').createScale(field);
- scales[field] = scale;
- }
- return scale;
- };
- _proto._processData = function _processData() {
- var self = this;
- var data = this.get('data');
- var dataArray = [];
- var groupedArray = this._groupData(data);
- for (var i = 0, len = groupedArray.length; i < len; i++) {
- var subData = groupedArray[i];
- var tempData = self._saveOrigin(subData);
- if (this.hasAdjust('dodge')) {
- self._numberic(tempData);
- }
- dataArray.push(tempData);
- }
- return dataArray;
- };
- _proto._saveOrigin = function _saveOrigin(data) {
- var rst = [];
- for (var i = 0, len = data.length; i < len; i++) {
- var origin = data[i];
- var obj = {};
- for (var k in origin) {
- obj[k] = origin[k];
- }
- obj[FIELD_ORIGIN] = origin;
- rst.push(obj);
- }
- return rst;
- };
- _proto._numberic = function _numberic(data) {
- var positionAttr = this.getAttr('position');
- var scales = positionAttr.scales;
- for (var j = 0, len = data.length; j < len; j++) {
- var obj = data[j];
- var count = Math.min(2, scales.length);
- for (var i = 0; i < count; i++) {
- var scale = scales[i];
- if (scale.isCategory) {
- var field = scale.field;
- obj[field] = scale.translate(obj[field]);
- }
- }
- }
- };
- _proto._adjustData = function _adjustData(dataArray) {
- var self = this;
- var adjust = self.get('adjust');
- if (adjust) {
- var adjustType = Util.upperFirst(adjust.type);
- if (!Adjust[adjustType]) {
- throw new Error('not support such adjust : ' + adjust);
- }
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var cfg = Util.mix({
- xField: xScale.field,
- yField: yScale.field
- }, adjust);
- var adjustObject = new Adjust[adjustType](cfg);
- adjustObject.processAdjust(dataArray);
- if (adjustType === 'Stack') {
- self._updateStackRange(yScale.field, yScale, dataArray);
- }
- }
- };
- _proto._updateStackRange = function _updateStackRange(field, scale, dataArray) {
- var mergeArray = Util.Array.merge(dataArray);
- var min = scale.min;
- var max = scale.max;
- for (var i = 0, len = mergeArray.length; i < len; i++) {
- var obj = mergeArray[i];
- var tmpMin = Math.min.apply(null, obj[field]);
- var tmpMax = Math.max.apply(null, obj[field]);
- if (tmpMin < min) {
- min = tmpMin;
- }
- if (tmpMax > max) {
- max = tmpMax;
- }
- }
- if (min < scale.min || max > scale.max) {
- scale.change({
- min: min,
- max: max
- });
- }
- };
- _proto._sort = function _sort(mappedArray) {
- var self = this;
- var xScale = self.getXScale();
- var field = xScale.field,
- type = xScale.type;
- if (type !== 'identity' && xScale.values.length > 1) {
- Util.each(mappedArray, function (itemArr) {
- itemArr.sort(function (obj1, obj2) {
- if (type === 'timeCat') {
- return xScale._toTimeStamp(obj1[FIELD_ORIGIN][field]) - xScale._toTimeStamp(obj2[FIELD_ORIGIN][field]);
- }
- return xScale.translate(obj1[FIELD_ORIGIN][field]) - xScale.translate(obj2[FIELD_ORIGIN][field]);
- });
- });
- }
- self.set('hasSorted', true);
- self.set('dataArray', mappedArray);
- };
- _proto.paint = function paint() {
- var self = this;
- var dataArray = self.get('dataArray');
- var mappedArray = [];
- var shapeFactory = self.getShapeFactory();
- shapeFactory.setCoord(self.get('coord'));
- self._beforeMapping(dataArray);
- for (var i = 0, len = dataArray.length; i < len; i++) {
- var data = dataArray[i];
- if (data.length) {
- data = self._mapping(data);
- mappedArray.push(data);
- self.draw(data, shapeFactory);
- }
- }
- self.set('dataArray', mappedArray);
- };
- _proto.getShapeFactory = function getShapeFactory() {
- var shapeFactory = this.get('shapeFactory');
- if (!shapeFactory) {
- var shapeType = this.get('shapeType');
- shapeFactory = GeometryShape.getShapeFactory(shapeType);
- this.set('shapeFactory', shapeFactory);
- }
- return shapeFactory;
- };
- _proto._mapping = function _mapping(data) {
- var self = this;
- var attrs = self.get('attrs');
- var yField = self.getYScale().field;
- var mappedData = [];
- for (var i = 0, len = data.length; i < len; i++) {
- var record = data[i];
- var newRecord = {};
- newRecord[FIELD_ORIGIN] = record[FIELD_ORIGIN];
- newRecord.points = record.points; // 避免
- newRecord[FIELD_ORIGIN_Y] = record[yField];
- for (var k in attrs) {
- if (attrs.hasOwnProperty(k)) {
- var attr = attrs[k];
- var names = attr.names;
- var values = self._getAttrValues(attr, record);
- if (names.length > 1) {
- for (var j = 0, _len = values.length; j < _len; j++) {
- var val = values[j];
- var name = names[j];
- newRecord[name] = Util.isArray(val) && val.length === 1 ? val[0] : val;
- }
- } else {
- newRecord[names[0]] = values.length === 1 ? values[0] : values;
- }
- }
- }
- mappedData.push(newRecord);
- }
- return mappedData;
- };
- _proto._getAttrValues = function _getAttrValues(attr, record) {
- var scales = attr.scales;
- var params = [];
- for (var i = 0, len = scales.length; i < len; i++) {
- var scale = scales[i];
- var field = scale.field;
- if (scale.type === 'identity') {
- params.push(scale.value);
- } else {
- params.push(record[field]);
- }
- }
- var values = attr.mapping.apply(attr, params);
- return values;
- };
- _proto.getAttrValue = function getAttrValue(attrName, record) {
- var attr = this.getAttr(attrName);
- var rst = null;
- if (attr) {
- var values = this._getAttrValues(attr, record);
- rst = values[0];
- }
- return rst;
- };
- _proto._beforeMapping = function _beforeMapping(dataArray) {
- var self = this;
- if (self.get('sortable')) {
- self._sort(dataArray);
- }
- if (self.get('generatePoints')) {
- Util.each(dataArray, function (data) {
- self._generatePoints(data);
- });
- }
- };
- _proto.isInCircle = function isInCircle() {
- var coord = this.get('coord');
- return coord && coord.isPolar;
- };
- _proto.getCallbackCfg = function getCallbackCfg(fields, cfg, origin) {
- if (!fields) {
- return cfg;
- }
- var tmpCfg = {};
- var params = fields.map(function (field) {
- return origin[field];
- });
- Util.each(cfg, function (v, k) {
- if (Util.isFunction(v)) {
- tmpCfg[k] = v.apply(null, params);
- } else {
- tmpCfg[k] = v;
- }
- });
- return tmpCfg;
- };
- _proto.getDrawCfg = function getDrawCfg(obj) {
- var self = this;
- var isInCircle = self.isInCircle();
- var cfg = {
- origin: obj,
- x: obj.x,
- y: obj.y,
- color: obj.color,
- size: obj.size,
- shape: obj.shape,
- isInCircle: isInCircle,
- opacity: obj.opacity
- };
- var styleOptions = self.get('styleOptions');
- if (styleOptions && styleOptions.style) {
- cfg.style = self.getCallbackCfg(styleOptions.fields, styleOptions.style, obj[FIELD_ORIGIN]);
- }
- if (self.get('generatePoints')) {
- cfg.points = obj.points;
- }
- if (isInCircle) {
- cfg.center = self.get('coord').center;
- }
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- var yScale = self.getYScale();
- Util.each(data, function (obj, index) {
- if (yScale && Util.isNil(obj._origin[yScale.field])) {
- return;
- }
- obj.index = index;
- var cfg = self.getDrawCfg(obj);
- var shape = obj.shape;
- self.drawShape(shape, obj, cfg, container, shapeFactory);
- });
- };
- _proto.drawShape = function drawShape(shape, shapeData, cfg, container, shapeFactory) {
- var gShape = shapeFactory.drawShape(shape, cfg, container);
- if (gShape) {
- Util.each([].concat(gShape), function (s) {
- s.set('origin', shapeData);
- });
- }
- };
- _proto._generatePoints = function _generatePoints(data) {
- var self = this;
- var shapeFactory = self.getShapeFactory();
- var shapeAttr = self.getAttr('shape');
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var cfg = self.createShapePointsCfg(obj);
- var shape = shapeAttr ? self._getAttrValues(shapeAttr, obj) : null;
- var points = shapeFactory.getShapePoints(shape, cfg);
- obj.points = points;
- }
- };
- /**
- * get the info of each shape
- * @protected
- * @param {Object} obj the data item
- * @return {Object} cfg return the result
- */
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var xScale = this.getXScale();
- var yScale = this.getYScale();
- var x = this._normalizeValues(obj[xScale.field], xScale);
- var y;
- if (yScale) {
- y = this._normalizeValues(obj[yScale.field], yScale);
- } else {
- y = obj.y ? obj.y : 0.1;
- }
- return {
- x: x,
- y: y,
- y0: yScale ? yScale.scale(this.getYMinValue()) : undefined
- };
- };
- _proto.getYMinValue = function getYMinValue() {
- var yScale = this.getYScale();
- var min = yScale.min,
- max = yScale.max;
- var value;
- if (this.get('startOnZero')) {
- if (max <= 0 && min <= 0) {
- value = max;
- } else {
- value = min >= 0 ? min : 0;
- }
- } else {
- value = min;
- }
- return value;
- };
- _proto._normalizeValues = function _normalizeValues(values, scale) {
- var rst = [];
- if (Util.isArray(values)) {
- for (var i = 0, len = values.length; i < len; i++) {
- var v = values[i];
- rst.push(scale.scale(v));
- }
- } else {
- rst = scale.scale(values);
- }
- return rst;
- };
- _proto.getAttr = function getAttr(name) {
- return this.get('attrs')[name];
- };
- _proto.getXScale = function getXScale() {
- return this.getAttr('position').scales[0];
- };
- _proto.getYScale = function getYScale() {
- return this.getAttr('position').scales[1];
- };
- _proto.hasAdjust = function hasAdjust(adjust) {
- return this.get('adjust') && this.get('adjust').type === adjust;
- };
- _proto._getSnap = function _getSnap(scale, item, arr) {
- var i = 0;
- var values;
- var yField = this.getYScale().field; // 叠加的维度
- if (this.hasAdjust('stack') && scale.field === yField) {
- values = [];
- arr.forEach(function (obj) {
- values.push(obj[FIELD_ORIGIN_Y]);
- });
- for (var len = values.length; i < len; i++) {
- if (values[0][0] > item) {
- break;
- }
- if (values[values.length - 1][1] <= item) {
- i = values.length - 1;
- break;
- }
- if (values[i][0] <= item && values[i][1] > item) {
- break;
- }
- }
- } else {
- values = scale.values;
- values.sort(function (a, b) {
- return a - b;
- });
- for (var _len2 = values.length; i < _len2; i++) {
- if ((values[0] + values[1]) / 2 > item) {
- break;
- }
- if ((values[i - 1] + values[i]) / 2 <= item && (values[i + 1] + values[i]) / 2 > item) {
- break;
- }
- if ((values[values.length - 2] + values[values.length - 1]) / 2 <= item) {
- i = values.length - 1;
- break;
- }
- }
- }
- var result = values[i];
- return result;
- };
- _proto.getSnapRecords = function getSnapRecords(point) {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var xfield = xScale.field;
- var dataArray = self.get('dataArray');
- if (!this.get('hasSorted')) {
- this._sort(dataArray);
- }
- var rst = [];
- var invertPoint = coord.invertPoint(point);
- var invertPointX = invertPoint.x;
- if (self.isInCircle() && !coord.transposed && invertPointX > (1 + xScale.rangeMax()) / 2) {
- invertPointX = xScale.rangeMin();
- }
- var xValue = xScale.invert(invertPointX);
- if (!xScale.isCategory) {
- xValue = self._getSnap(xScale, xValue);
- }
- var tmp = [];
- dataArray.forEach(function (data) {
- data.forEach(function (obj) {
- var originValue = Util.isNil(obj[FIELD_ORIGIN]) ? obj[xfield] : obj[FIELD_ORIGIN][xfield];
- if (self._isEqual(originValue, xValue, xScale)) {
- tmp.push(obj);
- }
- });
- }); // special for pie chart
- if (this.hasAdjust('stack') && coord.isPolar && coord.transposed && xScale.values.length === 1) {
- if (invertPointX >= 0 && invertPointX <= 1) {
- var yValue = yScale.invert(invertPoint.y);
- yValue = self._getSnap(yScale, yValue, tmp);
- tmp.forEach(function (obj) {
- if (Util.isArray(yValue) ? obj[FIELD_ORIGIN_Y].toString() === yValue.toString() : obj[FIELD_ORIGIN_Y] === yValue) {
- rst.push(obj);
- }
- });
- }
- } else {
- rst = tmp;
- }
- return rst;
- };
- _proto._isEqual = function _isEqual(originValue, value, scale) {
- if (scale.type === 'timeCat') {
- return scale._toTimeStamp(originValue) === value;
- }
- return value === originValue;
- };
- _proto.position = function position(field) {
- this._setAttrOptions('position', {
- field: field
- });
- return this;
- };
- _proto.color = function color(field, values) {
- this._createAttrOption('color', field, values, Global.colors);
- return this;
- };
- _proto.size = function size(field, values) {
- this._createAttrOption('size', field, values, Global.sizes);
- return this;
- };
- _proto.shape = function shape(field, values) {
- var type = this.get('type');
- var shapes = Global.shapes[type] || [];
- this._createAttrOption('shape', field, values, shapes);
- return this;
- };
- _proto.style = function style(field, cfg) {
- var styleOptions = this.get('styleOptions');
- if (!styleOptions) {
- styleOptions = {};
- this.set('styleOptions', styleOptions);
- }
- if (Util.isObject(field)) {
- cfg = field;
- field = null;
- }
- var fields;
- if (field) {
- fields = parseFields(field);
- }
- styleOptions.fields = fields;
- styleOptions.style = cfg;
- return this;
- };
- _proto.adjust = function adjust(type) {
- if (Util.isString(type)) {
- type = {
- type: type
- };
- }
- this.set('adjust', type);
- return this;
- };
- _proto.animate = function animate(cfg) {
- this.set('animateCfg', cfg);
- return this;
- };
- _proto.reset = function reset() {
- this.set('attrOptions', {});
- this.set('adjust', null);
- this.clearInner();
- };
- _proto.clearInner = function clearInner() {
- var container = this.get('container');
- if (container) {
- container.clear();
- container.setMatrix([1, 0, 0, 1, 0, 0]);
- }
- container && container.clear();
- this.set('attrs', {});
- this.set('groupScales', null);
- this.set('xDistance', null);
- this.set('_width', null);
- };
- _proto.clear = function clear() {
- this.clearInner();
- this.set('scales', {});
- };
- _proto.destroy = function destroy() {
- this.clear();
- _Base.prototype.destroy.call(this);
- };
- _proto._display = function _display(visible) {
- this.set('visible', visible);
- var container = this.get('container');
- var canvas = container.get('canvas');
- container.set('visible', visible);
- canvas.draw();
- };
- _proto.show = function show() {
- this._display(true);
- };
- _proto.hide = function hide() {
- this._display(false);
- };
- return Geom;
- }(Base);
- module.exports = Geom;
- /***/ }),
- /* 7 */
- /***/ (function(module, exports) {
- // isFinite,
- var isNil = function isNil(value) {
- /**
- * isNil(null) => true
- * isNil() => true
- */
- return value === null || value === undefined;
- };
- module.exports = isNil;
- /***/ }),
- /* 8 */
- /***/ (function(module, exports) {
- var toString = {}.toString;
- var isType = function isType(value, type) {
- return toString.call(value) === '[object ' + type + ']';
- };
- module.exports = isType;
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(1);
- var Shape = {};
- var ShapeBase = {
- _coord: null,
- /**
- * draw the shape
- * @param {Object} cfg options
- * @param {Object} container container to store the shapes
- */
- draw: function draw(cfg, container) {
- if (this.drawShape) {
- this.drawShape(cfg, container);
- }
- },
- /**
- * set the coordinate instance
- * @param {Coord} coord coordinate instance
- */
- setCoord: function setCoord(coord) {
- this._coord = coord;
- },
- /**
- * convert the normalized value to the canvas position
- * @param {point} point the point to convert
- * @return {point} point return the result
- */
- parsePoint: function parsePoint(point) {
- var coord = this._coord;
- if (coord.isPolar) {
- if (point.x === 1) point.x = 0.9999999;
- if (point.y === 1) point.y = 0.9999999;
- }
- return coord.convertPoint(point);
- },
- /**
- * convert the normalized value to the canvas position
- * @param {points} points the array that store the points
- * @return {points} points return the result
- */
- parsePoints: function parsePoints(points) {
- if (!points) return false;
- var self = this;
- var rst = [];
- points.forEach(function (point) {
- rst.push(self.parsePoint(point));
- });
- return rst;
- }
- };
- var ShapeFactoryBase = {
- defaultShapeType: null,
- setCoord: function setCoord(coord) {
- this._coord = coord;
- },
- getShape: function getShape(type) {
- var self = this;
- if (Util.isArray(type)) {
- type = type[0];
- }
- var shape = self[type] || self[self.defaultShapeType];
- shape._coord = self._coord;
- return shape;
- },
- getShapePoints: function getShapePoints(type, cfg) {
- var shape = this.getShape(type);
- var fn = shape.getPoints || shape.getShapePoints || this.getDefaultPoints;
- var points = fn(cfg);
- return points;
- },
- getDefaultPoints: function getDefaultPoints()
- /* cfg */
- {
- return [];
- },
- drawShape: function drawShape(type, cfg, container) {
- var shape = this.getShape(type);
- if (!cfg.color) {
- cfg.color = Global.colors[0];
- }
- return shape.draw(cfg, container);
- }
- };
- Shape.registerFactory = function (factoryName, cfg) {
- var className = Util.upperFirst(factoryName);
- var geomObj = Util.mix({}, ShapeFactoryBase, cfg);
- Shape[className] = geomObj;
- geomObj.name = factoryName;
- return geomObj;
- };
- Shape.registerShape = function (factoryName, shapeType, cfg) {
- var className = Util.upperFirst(factoryName);
- var factory = Shape[className];
- var shapeObj = Util.mix({}, ShapeBase, cfg);
- factory[shapeType] = shapeObj;
- return shapeObj;
- };
- Shape.registShape = Shape.registerShape;
- Shape.getShapeFactory = function (factoryName) {
- var self = this;
- factoryName = factoryName || 'point';
- var className = Util.upperFirst(factoryName);
- return self[className];
- };
- module.exports = Shape;
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(8);
- var isArray = Array.isArray ? Array.isArray : function (value) {
- return isType(value, 'Array');
- };
- module.exports = isArray;
- /***/ }),
- /* 11 */
- /***/ (function(module, exports, __webpack_require__) {
- var Vector2 = __webpack_require__(4);
- var start = Vector2.create();
- var end = Vector2.create();
- var extremity = Vector2.create();
- function getCubicBezierXYatT(startPt, controlPt1, controlPt2, endPt, T) {
- var x = CubicN(T, startPt.x, controlPt1.x, controlPt2.x, endPt.x);
- var y = CubicN(T, startPt.y, controlPt1.y, controlPt2.y, endPt.y);
- return {
- x: x,
- y: y
- };
- } // cubic helper formula at T distance
- function CubicN(T, a, b, c, d) {
- var t2 = T * T;
- var t3 = t2 * T;
- 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;
- }
- function cubicBezierBounds(c) {
- var minX = Infinity;
- var maxX = -Infinity;
- var minY = Infinity;
- var maxY = -Infinity;
- var s = {
- x: c[0],
- y: c[1]
- };
- var c1 = {
- x: c[2],
- y: c[3]
- };
- var c2 = {
- x: c[4],
- y: c[5]
- };
- var e = {
- x: c[6],
- y: c[7]
- };
- for (var t = 0; t < 100; t++) {
- var pt = getCubicBezierXYatT(s, c1, c2, e, t / 100);
- if (pt.x < minX) {
- minX = pt.x;
- }
- if (pt.x > maxX) {
- maxX = pt.x;
- }
- if (pt.y < minY) {
- minY = pt.y;
- }
- if (pt.y > maxY) {
- maxY = pt.y;
- }
- }
- return {
- minX: minX,
- minY: minY,
- maxX: maxX,
- maxY: maxY
- };
- }
- module.exports = {
- getBBoxFromPoints: function getBBoxFromPoints(points, lineWidth) {
- if (points.length === 0) {
- return;
- }
- var p = points[0];
- var left = p.x;
- var right = p.x;
- var top = p.y;
- var bottom = p.y;
- var len = points.length;
- for (var i = 1; i < len; i++) {
- p = points[i];
- left = Math.min(left, p.x);
- right = Math.max(right, p.x);
- top = Math.min(top, p.y);
- bottom = Math.max(bottom, p.y);
- }
- lineWidth = lineWidth / 2 || 0;
- return {
- minX: left - lineWidth,
- minY: top - lineWidth,
- maxX: right + lineWidth,
- maxY: bottom + lineWidth
- };
- },
- getBBoxFromLine: function getBBoxFromLine(x0, y0, x1, y1, lineWidth) {
- lineWidth = lineWidth / 2 || 0;
- return {
- minX: Math.min(x0, x1) - lineWidth,
- minY: Math.min(y0, y1) - lineWidth,
- maxX: Math.max(x0, x1) + lineWidth,
- maxY: Math.max(y0, y1) + lineWidth
- };
- },
- getBBoxFromArc: function getBBoxFromArc(x, y, r, startAngle, endAngle, anticlockwise) {
- var diff = Math.abs(startAngle - endAngle);
- if (diff % Math.PI * 2 < 1e-4 && diff > 1e-4) {
- // Is a circle
- return {
- minX: x - r,
- minY: y - r,
- maxX: x + r,
- maxY: y + r
- };
- }
- start[0] = Math.cos(startAngle) * r + x;
- start[1] = Math.sin(startAngle) * r + y;
- end[0] = Math.cos(endAngle) * r + x;
- end[1] = Math.sin(endAngle) * r + y;
- var min = [0, 0];
- var max = [0, 0];
- Vector2.min(min, start, end);
- Vector2.max(max, start, end); // Thresh to [0, Math.PI * 2]
- startAngle = startAngle % (Math.PI * 2);
- if (startAngle < 0) {
- startAngle = startAngle + Math.PI * 2;
- }
- endAngle = endAngle % (Math.PI * 2);
- if (endAngle < 0) {
- endAngle = endAngle + Math.PI * 2;
- }
- if (startAngle > endAngle && !anticlockwise) {
- endAngle += Math.PI * 2;
- } else if (startAngle < endAngle && anticlockwise) {
- startAngle += Math.PI * 2;
- }
- if (anticlockwise) {
- var tmp = endAngle;
- endAngle = startAngle;
- startAngle = tmp;
- }
- for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
- if (angle > startAngle) {
- extremity[0] = Math.cos(angle) * r + x;
- extremity[1] = Math.sin(angle) * r + y;
- Vector2.min(min, extremity, min);
- Vector2.max(max, extremity, max);
- }
- }
- return {
- minX: min[0],
- minY: min[1],
- maxX: max[0],
- maxY: max[1]
- };
- },
- getBBoxFromBezierGroup: function getBBoxFromBezierGroup(points, lineWidth) {
- var minX = Infinity;
- var maxX = -Infinity;
- var minY = Infinity;
- var maxY = -Infinity;
- for (var i = 0, len = points.length; i < len; i++) {
- var bbox = cubicBezierBounds(points[i]);
- if (bbox.minX < minX) {
- minX = bbox.minX;
- }
- if (bbox.maxX > maxX) {
- maxX = bbox.maxX;
- }
- if (bbox.minY < minY) {
- minY = bbox.minY;
- }
- if (bbox.maxY > maxY) {
- maxY = bbox.maxY;
- }
- }
- lineWidth = lineWidth / 2 || 0;
- return {
- minX: minX - lineWidth,
- minY: minY - lineWidth,
- maxX: maxX + lineWidth,
- maxY: maxY + lineWidth
- };
- }
- };
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var KEYWORDS_PERCENT = {
- min: 0,
- median: 0.5,
- max: 1
- };
- var GuideBase =
- /*#__PURE__*/
- function () {
- var _proto = GuideBase.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {};
- function GuideBase(cfg) {
- this._initDefaultCfg();
- Util.deepMix(this, cfg);
- }
- _proto._getNormalizedValue = function _getNormalizedValue(val, scale) {
- var rst;
- if (Util.isNil(KEYWORDS_PERCENT[val])) {
- rst = scale.scale(val);
- } else {
- rst = KEYWORDS_PERCENT[val];
- }
- return rst;
- };
- _proto.parsePercentPoint = function parsePercentPoint(coord, position) {
- var xPercent = parseFloat(position[0]) / 100;
- var yPercent = parseFloat(position[1]) / 100;
- var start = coord.start;
- var end = coord.end;
- var width = Math.abs(start.x - end.x);
- var height = Math.abs(start.y - end.y);
- var x = width * xPercent + Math.min(start.x, end.x);
- var y = height * yPercent + Math.min(start.y, end.y);
- return {
- x: x,
- y: y
- };
- };
- _proto.parsePoint = function parsePoint(coord, position) {
- var self = this;
- var xScale = self.xScale;
- var yScales = self.yScales;
- if (Util.isFunction(position)) {
- position = position(xScale, yScales); // position 必须是对象
- } // 如果数据格式是 ['50%', '50%'] 的格式
- if (Util.isString(position[0]) && position[0].indexOf('%') !== -1) {
- return this.parsePercentPoint(coord, position);
- }
- var x = self._getNormalizedValue(position[0], xScale);
- var y = self._getNormalizedValue(position[1], yScales[0]);
- var point = coord.convertPoint({
- x: x,
- y: y
- });
- if (self.limitInPlot) {
- // limit in chart plotRange
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
- return point;
- }
- return null;
- }
- return point;
- };
- /**
- * render the guide component
- * @param {Coord} coord coordinate instance
- * @param {Canvas.Group} group the container
- */
- _proto.render = function render()
- /* coord,group */
- {};
- _proto.repaint = function repaint() {
- this.remove();
- var coord = this.coord,
- container = this.container,
- canvas = this.canvas;
- if (container && !container.isDestroyed()) {
- this.render(coord, container);
- canvas.draw();
- }
- };
- _proto.remove = function remove() {
- var element = this.element;
- element && element.remove(true);
- };
- _proto.changeVisible = function changeVisible(visible) {
- var self = this;
- self.visible = visible;
- var element = self.element;
- if (!element) return;
- if (element.set) {
- element.set('visible', visible);
- } else {
- element.style.display = visible ? '' : 'none';
- }
- };
- return GuideBase;
- }();
- module.exports = GuideBase;
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 判断是否数字
- * @return {Boolean} 是否数字
- */
- var isType = __webpack_require__(8);
- var isNumber = function isNumber(value) {
- return isType(value, 'Number');
- };
- module.exports = isNumber;
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- var mix = __webpack_require__(16);
- var each = __webpack_require__(3);
- var isObject = __webpack_require__(18);
- var isNil = __webpack_require__(7);
- var Scale =
- /*#__PURE__*/
- function () {
- var _proto = Scale.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'base';
- /**
- * 格式化函数,输出文本或者tick时的格式化函数
- * @type {Function}
- */
- this.formatter = null;
- /**
- * 输出的值域
- * @type {Array}
- */
- this.range = [0, 1];
- /**
- * 度量的标记
- * @type {Array}
- */
- this.ticks = null;
- /**
- * 参与度量计算的值,可选项
- * @type {Array}
- */
- this.values = [];
- };
- function Scale(cfg) {
- this._initDefaultCfg();
- mix(this, cfg);
- this.init();
- }
- /**
- * 度量初始化
- * @protected
- */
- _proto.init = function init() {};
- /**
- * 获取该度量的ticks,返回的是多个对象,
- * - text: tick 的文本
- * - value: 对应的度量转换后的值
- * <code>
- * [
- * {text: 0,value:0}
- * {text: 1,value:0.2}
- * {text: 2,value:0.4}
- * {text: 3,value:0.6}
- * {text: 4,value:0.8}
- * {text: 5,value:1}
- * ]
- * </code>
- * @param {Number} count 输出tick的个数的近似值,默认是 10
- * @return {Array} 返回 ticks 数组
- */
- _proto.getTicks = function getTicks() {
- var self = this;
- var ticks = self.ticks;
- var rst = [];
- each(ticks, function (tick) {
- var obj;
- if (isObject(tick)) {
- obj = tick;
- } else {
- obj = {
- text: self.getText(tick),
- tickValue: tick,
- value: self.scale(tick)
- };
- }
- rst.push(obj);
- });
- return rst;
- };
- /**
- * 获取格式化后的文本
- * @param {*} value 输入的数据
- * @param {*} key 字段的 key
- * @return {String} 格式化的文本
- */
- _proto.getText = function getText(value, key) {
- var formatter = this.formatter;
- value = formatter ? formatter(value, key) : value;
- if (isNil(value) || !value.toString) {
- value = '';
- }
- return value.toString();
- };
- /**
- * 输出的值域最小值
- * @protected
- * @return {Number} 返回最小的值
- */
- _proto.rangeMin = function rangeMin() {
- return this.range[0];
- };
- /**
- * 输出的值域最大值
- * @protected
- * @return {Number} 返回最大的值
- */
- _proto.rangeMax = function rangeMax() {
- var range = this.range;
- return range[range.length - 1];
- };
- /**
- * 度量转换后的结果,翻转回输入域
- * @param {Number} value 需要翻转的数值
- * @return {*} 度量的输入值
- */
- _proto.invert = function invert(value) {
- return value;
- };
- /**
- * 将传入的值从非数值转换成数值格式,如分类字符串、时间字符串等
- * @param {*} value 传入的值
- * @return {Number} 转换的值
- */
- _proto.translate = function translate(value) {
- return value;
- };
- /**
- * 进行度量转换
- * @param {*} value 输入值
- * @return {Number} 输出值,在设定的输出值域之间,默认[0,1]
- */
- _proto.scale = function scale(value) {
- return value;
- };
- /**
- * 克隆一个新的scale,拥有跟当前scale相同的输入域、输出域等
- * @return {Scale} 克隆的度量
- */
- _proto.clone = function clone() {
- var self = this;
- var constr = self.constructor;
- var cfg = {};
- each(self, function (v, k) {
- cfg[k] = self[k];
- });
- return new constr(cfg);
- };
- /**
- * 更改度量的属性信息
- * @param {Object} info 属性信息
- * @chainable
- * @return {Scale} 返回自身的引用
- */
- _proto.change = function change(info) {
- this.ticks = null;
- mix(this, info);
- this.init();
- return this;
- };
- return Scale;
- }();
- module.exports = Scale;
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(8);
- var isString = function isString(str) {
- return isType(str, 'String');
- };
- module.exports = isString;
- /***/ }),
- /* 16 */
- /***/ (function(module, exports) {
- function _mix(dist, obj) {
- for (var key in obj) {
- if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
- dist[key] = obj[key];
- }
- }
- }
- var mix = function mix(dist, src1, src2, src3) {
- if (src1) _mix(dist, src1);
- if (src2) _mix(dist, src2);
- if (src3) _mix(dist, src3);
- return dist;
- };
- module.exports = mix;
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview the Attribute base class
- */
- var isString = __webpack_require__(15);
- var isArray = __webpack_require__(10);
- var mix = __webpack_require__(16);
- var each = __webpack_require__(3);
- function toScaleString(scale, value) {
- if (isString(value)) {
- return value;
- }
- return scale.invert(scale.scale(value));
- }
- /**
- * 所有视觉通道属性的基类
- * @class Attr
- */
- var AttributeBase =
- /*#__PURE__*/
- function () {
- function AttributeBase(cfg) {
- /**
- * 属性的类型
- * @type {String}
- */
- this.type = 'base';
- /**
- * 属性的名称
- * @type {String}
- */
- this.name = null;
- /**
- * 回调函数
- * @type {Function}
- */
- this.method = null;
- /**
- * 备选的值数组
- * @type {Array}
- */
- this.values = [];
- /**
- * 属性内部的度量
- * @type {Array}
- */
- this.scales = [];
- /**
- * 是否通过线性取值, 如果未指定,则根据数值的类型判定
- * @type {Boolean}
- */
- this.linear = null;
- mix(this, cfg);
- } // 获取属性值,将值映射到视觉通道
- var _proto = AttributeBase.prototype;
- _proto._getAttrValue = function _getAttrValue(scale, value) {
- var values = this.values;
- if (scale.isCategory && !this.linear) {
- var index = scale.translate(value);
- return values[index % values.length];
- }
- var percent = scale.scale(value);
- return this.getLinearValue(percent);
- };
- /**
- * 如果进行线性映射,返回对应的映射值
- * @protected
- * @param {Number} percent 百分比
- * @return {*} 颜色值、形状、大小等
- */
- _proto.getLinearValue = function getLinearValue(percent) {
- var values = this.values;
- var steps = values.length - 1;
- var step = Math.floor(steps * percent);
- var leftPercent = steps * percent - step;
- var start = values[step];
- var end = step === steps ? start : values[step + 1];
- var rstValue = start + (end - start) * leftPercent;
- return rstValue;
- };
- /**
- * 默认的回调函数
- * @param {*} value 回调函数的值
- * @type {Function}
- * @return {Array} 返回映射后的值
- */
- _proto.callback = function callback(value) {
- var self = this;
- var scale = self.scales[0];
- var rstValue = null;
- if (scale.type === 'identity') {
- rstValue = scale.value;
- } else {
- rstValue = self._getAttrValue(scale, value);
- }
- return rstValue;
- };
- /**
- * 根据度量获取属性名
- * @return {Array} dims of this Attribute
- */
- _proto.getNames = function getNames() {
- var scales = this.scales;
- var names = this.names;
- var length = Math.min(scales.length, names.length);
- var rst = [];
- for (var i = 0; i < length; i++) {
- rst.push(names[i]);
- }
- return rst;
- };
- /**
- * 根据度量获取维度名
- * @return {Array} dims of this Attribute
- */
- _proto.getFields = function getFields() {
- var scales = this.scales;
- var rst = [];
- each(scales, function (scale) {
- rst.push(scale.field);
- });
- return rst;
- };
- /**
- * 根据名称获取度量
- * @param {String} name the name of scale
- * @return {Scale} scale
- */
- _proto.getScale = function getScale(name) {
- var scales = this.scales;
- var names = this.names;
- var index = names.indexOf(name);
- return scales[index];
- };
- /**
- * 映射数据
- * @param {*} param1...paramn 多个数值
- * @return {Array} 映射的值组成的数组
- */
- _proto.mapping = function mapping() {
- var scales = this.scales;
- var callback = this.callback;
- for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
- params[_key] = arguments[_key];
- }
- var values = params;
- if (callback) {
- for (var i = 0, len = params.length; i < len; i++) {
- params[i] = this._toOriginParam(params[i], scales[i]);
- }
- values = callback.apply(this, params);
- }
- values = [].concat(values);
- return values;
- }; // 原始的参数
- _proto._toOriginParam = function _toOriginParam(param, scale) {
- var rst = param;
- if (!scale.isLinear) {
- if (isArray(param)) {
- rst = [];
- for (var i = 0, len = param.length; i < len; i++) {
- rst.push(toScaleString(scale, param[i]));
- }
- } else {
- rst = toScaleString(scale, param);
- }
- }
- return rst;
- };
- return AttributeBase;
- }();
- module.exports = AttributeBase;
- /***/ }),
- /* 18 */
- /***/ (function(module, exports) {
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- var isObject = function isObject(value) {
- /**
- * isObject({}) => true
- * isObject([1, 2, 3]) => true
- * isObject(Function) => true
- * isObject(null) => false
- */
- var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
- return value !== null && type === 'object' || type === 'function';
- };
- module.exports = isObject;
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- var Base = __webpack_require__(29);
- var Plot = __webpack_require__(50);
- var Util = __webpack_require__(0);
- var Coord = __webpack_require__(51);
- var Geom = __webpack_require__(6);
- var ScaleController = __webpack_require__(59);
- var AxisController = __webpack_require__(65);
- var Global = __webpack_require__(1);
- var _require = __webpack_require__(5),
- Canvas = _require.Canvas;
- var Helper = __webpack_require__(26);
- function isFullCircle(coord) {
- var startAngle = coord.startAngle;
- var endAngle = coord.endAngle;
- if (!Util.isNil(startAngle) && !Util.isNil(endAngle) && endAngle - startAngle < Math.PI * 2) {
- return false;
- }
- return true;
- }
- function compare(a, b) {
- return a - b;
- }
- function _isScaleExist(scales, compareScale) {
- var flag = false;
- Util.each(scales, function (scale) {
- var scaleValues = [].concat(scale.values);
- var compareScaleValues = [].concat(compareScale.values);
- if (scale.type === compareScale.type && scale.field === compareScale.field && scaleValues.sort(compare).toString() === compareScaleValues.sort(compare).toString()) {
- flag = true;
- return;
- }
- });
- return flag;
- }
- var Chart =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Chart, _Base);
- Chart.initPlugins = function initPlugins() {
- return {
- _plugins: [],
- _cacheId: 0,
- register: function register(plugins) {
- var p = this._plugins;
- [].concat(plugins).forEach(function (plugin) {
- if (p.indexOf(plugin) === -1) {
- p.push(plugin);
- }
- });
- this._cacheId++;
- },
- unregister: function unregister(plugins) {
- var p = this._plugins;
- [].concat(plugins).forEach(function (plugin) {
- var idx = p.indexOf(plugin);
- if (idx !== -1) {
- p.splice(idx, 1);
- }
- });
- this._cacheId++;
- },
- clear: function clear() {
- this._plugins = [];
- this._cacheId++;
- },
- count: function count() {
- return this._plugins.length;
- },
- getAll: function getAll() {
- return this._plugins;
- },
- notify: function notify(chart, hook, args) {
- var descriptors = this.descriptors(chart);
- var ilen = descriptors.length;
- var i;
- var descriptor;
- var plugin;
- var params;
- var method;
- for (i = 0; i < ilen; ++i) {
- descriptor = descriptors[i];
- plugin = descriptor.plugin;
- method = plugin[hook];
- if (typeof method === 'function') {
- params = [chart].concat(args || []);
- if (method.apply(plugin, params) === false) {
- return false;
- }
- }
- }
- return true;
- },
- descriptors: function descriptors(chart) {
- var cache = chart._plugins || (chart._plugins = {});
- if (cache.id === this._cacheId) {
- return cache.descriptors;
- }
- var plugins = [];
- var descriptors = [];
- this._plugins.concat(chart && chart.get('plugins') || []).forEach(function (plugin) {
- var idx = plugins.indexOf(plugin);
- if (idx !== -1) {
- return;
- }
- plugins.push(plugin);
- descriptors.push({
- plugin: plugin
- });
- });
- cache.descriptors = descriptors;
- cache.id = this._cacheId;
- return descriptors;
- }
- };
- };
- var _proto = Chart.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- /**
- * the id of canvas
- * @type {String}
- */
- id: null,
- /**
- * padding
- * @type {Array|Number}
- */
- padding: Global.padding,
- /**
- * data
- * @type {Array}
- */
- data: null,
- /**
- * scales of chart
- * @type {Object}
- */
- scales: {},
- /**
- * @private
- * geometry instances
- * @type {Array}
- */
- geoms: null,
- /**
- * scale configuration
- * @type {Object}
- */
- colDefs: null,
- pixelRatio: Global.pixelRatio,
- /**
- * filter options
- * @type {Object}
- */
- filters: null,
- appendPadding: Global.appendPadding
- };
- };
- _proto._syncYScales = function _syncYScales() {
- var geoms = this.get('geoms');
- var syncScales = [];
- var min = [];
- var max = [];
- Util.each(geoms, function (geom) {
- var yScale = geom.getYScale();
- if (yScale.isLinear) {
- syncScales.push(yScale);
- min.push(yScale.min);
- max.push(yScale.max);
- }
- });
- min = Math.min.apply(null, min);
- max = Math.max.apply(null, max);
- Util.each(syncScales, function (scale) {
- scale.change({
- min: min
- });
- scale.change({
- max: max
- });
- });
- };
- _proto._getFieldsForLegend = function _getFieldsForLegend() {
- var fields = [];
- var geoms = this.get('geoms');
- Util.each(geoms, function (geom) {
- var attrOptions = geom.get('attrOptions');
- var attrCfg = attrOptions.color;
- if (attrCfg && attrCfg.field && Util.isString(attrCfg.field)) {
- var arr = attrCfg.field.split('*');
- Util.each(arr, function (item) {
- if (fields.indexOf(item) === -1) {
- fields.push(item);
- }
- });
- }
- });
- return fields;
- };
- _proto._createScale = function _createScale(field, data) {
- var scaleController = this.get('scaleController');
- return scaleController.createScale(field, data);
- };
- _proto._adjustScale = function _adjustScale() {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScales = self.getYScales();
- var scales = [];
- xScale && scales.push(xScale);
- scales = scales.concat(yScales);
- var inFullCircle = coord.isPolar && isFullCircle(coord);
- var scaleController = self.get('scaleController');
- var colDefs = scaleController.defs;
- Util.each(scales, function (scale) {
- if ((scale.isCategory || scale.isIdentity) && scale.values && !(colDefs[scale.field] && colDefs[scale.field].range)) {
- var count = scale.values.length;
- var range;
- if (count === 1) {
- range = [0.5, 1];
- } else {
- var widthRatio = 1;
- var offset = 0;
- if (inFullCircle) {
- if (!coord.transposed) {
- range = [0, 1 - 1 / count];
- } else {
- widthRatio = Global.widthRatio.multiplePie;
- offset = 1 / count * widthRatio;
- range = [offset / 2, 1 - offset / 2];
- }
- } else {
- offset = 1 / count * 1 / 2;
- range = [offset, 1 - offset];
- }
- }
- scale.range = range;
- }
- });
- var geoms = this.get('geoms');
- for (var i = 0; i < geoms.length; i++) {
- var geom = geoms[i];
- if (geom.get('type') === 'interval') {
- var yScale = geom.getYScale();
- var field = yScale.field,
- min = yScale.min,
- max = yScale.max,
- type = yScale.type;
- if (!(colDefs[field] && colDefs[field].min) && type !== 'time') {
- if (min > 0) {
- yScale.change({
- min: 0
- });
- } else if (max <= 0) {
- yScale.change({
- max: 0
- });
- }
- }
- }
- }
- };
- _proto._removeGeoms = function _removeGeoms() {
- var geoms = this.get('geoms');
- while (geoms.length > 0) {
- var geom = geoms.shift();
- geom.destroy();
- }
- };
- _proto._clearGeoms = function _clearGeoms() {
- var geoms = this.get('geoms');
- for (var i = 0, length = geoms.length; i < length; i++) {
- var geom = geoms[i];
- geom.clear();
- }
- };
- _proto._clearInner = function _clearInner() {
- this.set('scales', {});
- this.set('legendItems', null);
- this._clearGeoms();
- Chart.plugins.notify(this, 'clearInner');
- this.get('axisController') && this.get('axisController').clear();
- };
- _proto._execFilter = function _execFilter(data) {
- var filters = this.get('filters');
- if (filters) {
- data = data.filter(function (obj) {
- var rst = true;
- Util.each(filters, function (fn, k) {
- if (fn) {
- rst = fn(obj[k], obj);
- if (!rst) {
- return false;
- }
- }
- });
- return rst;
- });
- }
- return data;
- };
- _proto._initGeoms = function _initGeoms(geoms) {
- var coord = this.get('coord');
- var data = this.get('filteredData');
- var colDefs = this.get('colDefs');
- for (var i = 0, length = geoms.length; i < length; i++) {
- var geom = geoms[i];
- geom.set('data', data);
- geom.set('coord', coord);
- geom.set('colDefs', colDefs);
- geom.init();
- }
- };
- _proto._initCoord = function _initCoord() {
- var plot = this.get('plotRange');
- var coordCfg = Util.mix({
- type: 'cartesian'
- }, this.get('coordCfg'), {
- plot: plot
- });
- var type = coordCfg.type;
- var C = Coord[Util.upperFirst(type)];
- var coord = new C(coordCfg);
- this.set('coord', coord);
- };
- _proto._initLayout = function _initLayout() {
- var padding = this.get('_padding');
- if (!padding) {
- padding = this.get('margin') || this.get('padding');
- padding = Util.parsePadding(padding);
- }
- var top = padding[0] === 'auto' ? 0 : padding[0];
- var right = padding[1] === 'auto' ? 0 : padding[1];
- var bottom = padding[2] === 'auto' ? 0 : padding[2];
- var left = padding[3] === 'auto' ? 0 : padding[3];
- var width = this.get('width');
- var height = this.get('height');
- var plot = new Plot({
- start: {
- x: left,
- y: top
- },
- end: {
- x: width - right,
- y: height - bottom
- }
- });
- this.set('plotRange', plot);
- this.set('plot', plot);
- };
- _proto._initCanvas = function _initCanvas() {
- var self = this;
- try {
- var canvas = new Canvas({
- el: self.get('el') || self.get('id'),
- context: self.get('context'),
- pixelRatio: self.get('pixelRatio'),
- width: self.get('width'),
- height: self.get('height'),
- fontFamily: Global.fontFamily
- });
- self.set('canvas', canvas);
- self.set('width', canvas.get('width'));
- self.set('height', canvas.get('height'));
- } catch (error) {
- throw error;
- }
- Chart.plugins.notify(self, 'afterCanvasInit');
- self._initLayout();
- };
- _proto._initLayers = function _initLayers() {
- var canvas = this.get('canvas');
- this.set('backPlot', canvas.addGroup());
- this.set('middlePlot', canvas.addGroup({
- zIndex: 10
- }));
- this.set('frontPlot', canvas.addGroup({
- zIndex: 20
- }));
- };
- _proto._init = function _init() {
- var self = this;
- self._initCanvas();
- self._initLayers();
- self.set('geoms', []);
- self.set('scaleController', new ScaleController());
- self.set('axisController', new AxisController({
- frontPlot: self.get('frontPlot').addGroup({
- className: 'axisContainer'
- }),
- backPlot: self.get('backPlot').addGroup({
- className: 'axisContainer'
- }),
- chart: self
- }));
- Chart.plugins.notify(self, 'init');
- };
- function Chart(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- var self = _assertThisInitialized(_assertThisInitialized(_this));
- Util.each(Geom, function (geomConstructor, className) {
- var methodName = Util.lowerFirst(className);
- self[methodName] = function (cfg) {
- var geom = new geomConstructor(cfg);
- self.addGeom(geom);
- return geom;
- };
- });
- self._init();
- return _this;
- }
- /**
- * set data and some scale configuration
- * @chainable
- * @param {Array} data the dataset to visualize
- * @param {Object} colDefs the configuration for scales
- * @return {Chart} return the chart instance
- */
- _proto.source = function source(data, colDefs) {
- this.set('data', data);
- if (colDefs) {
- this.scale(colDefs);
- }
- return this;
- };
- _proto.scale = function scale(field, cfg) {
- var colDefs = this.get('colDefs') || {};
- if (Util.isObject(field)) {
- Util.mix(colDefs, field);
- } else {
- colDefs[field] = cfg;
- }
- this.set('colDefs', colDefs);
- var scaleController = this.get('scaleController');
- scaleController.defs = colDefs;
- return this;
- };
- /**
- * configure the axis
- * @chainable
- * @param {String|Boolean} field the field name of data
- * @param {Object} cfg configuration for axis
- * @return {Chart} return the chart instance
- */
- _proto.axis = function axis(field, cfg) {
- var axisController = this.get('axisController');
- if (!field) {
- axisController.axisCfg = null;
- } else {
- axisController.axisCfg = axisController.axisCfg || {};
- axisController.axisCfg[field] = cfg;
- }
- return this;
- };
- /**
- * configure the coordinate
- * @chainable
- * @param {String} type set the type of coodinate
- * @param {Object} cfg configuration for coordinate
- * @return {Chart} return the chart instance
- */
- _proto.coord = function coord(type, cfg) {
- var coordCfg;
- if (Util.isObject(type)) {
- coordCfg = type;
- } else {
- coordCfg = cfg || {};
- coordCfg.type = type || 'cartesian';
- }
- this.set('coordCfg', coordCfg);
- return this;
- };
- _proto.filter = function filter(field, condition) {
- var filters = this.get('filters') || {};
- filters[field] = condition;
- this.set('filters', filters);
- };
- /**
- * render the chart
- * @chainable
- * @return {Chart} return the chart instance
- */
- _proto.render = function render() {
- var canvas = this.get('canvas');
- var geoms = this.get('geoms');
- var data = this.get('data') || [];
- var filteredData = this._execFilter(data); // filter data
- this.set('filteredData', filteredData);
- this._initCoord(); // initialization coordinate instance
- Chart.plugins.notify(this, 'beforeGeomInit');
- this._initGeoms(geoms); // init all geometry instances
- this.get('syncY') && this._syncYScales();
- this._adjustScale(); // do some adjust for data
- Chart.plugins.notify(this, 'beforeGeomDraw');
- this._renderAxis();
- var middlePlot = this.get('middlePlot');
- if (this.get('limitInPlot') && !middlePlot.attr('clip')) {
- var coord = this.get('coord');
- var clip = Helper.getClip(coord);
- clip.set('canvas', middlePlot.get('canvas'));
- middlePlot.attr('clip', clip);
- }
- for (var i = 0, length = geoms.length; i < length; i++) {
- var geom = geoms[i];
- geom.paint();
- }
- Chart.plugins.notify(this, 'afterGeomDraw');
- canvas.sort();
- this.get('frontPlot').sort();
- Chart.plugins.notify(this, 'beforeCanvasDraw');
- canvas.draw();
- return this;
- };
- /**
- * clear the chart, include geometris and all the shapes
- * @chainable
- * @return {Chart} return the chart
- */
- _proto.clear = function clear() {
- Chart.plugins.notify(this, 'clear');
- this._removeGeoms();
- this._clearInner();
- this.set('filters', null);
- this.set('isUpdate', false);
- this.set('_padding', null);
- var canvas = this.get('canvas');
- canvas.draw();
- return this;
- };
- _proto.repaint = function repaint() {
- this.set('isUpdate', true);
- Chart.plugins.notify(this, 'repaint');
- this._clearInner();
- this.render();
- };
- _proto.changeData = function changeData(data) {
- this.set('data', data);
- Chart.plugins.notify(this, 'changeData');
- this.set('_padding', null);
- this.repaint();
- };
- _proto.changeSize = function changeSize(width, height) {
- if (width) {
- this.set('width', width);
- } else {
- width = this.get('width');
- }
- if (height) {
- this.set('height', height);
- } else {
- height = this.get('height');
- }
- var canvas = this.get('canvas');
- canvas.changeSize(width, height);
- this._initLayout();
- this.repaint();
- return this;
- };
- _proto.destroy = function destroy() {
- this.clear();
- var canvas = this.get('canvas');
- canvas.destroy();
- Chart.plugins.notify(this, 'afterCanvasDestroyed');
- if (this._interactions) {
- Util.each(this._interactions, function (interaction) {
- interaction.destroy();
- });
- }
- _Base.prototype.destroy.call(this);
- };
- /**
- * calculate dataset's position on canvas
- * @param {Object} record the dataset
- * @return {Object} return the position
- */
- _proto.getPosition = function getPosition(record) {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScale = self.getYScales()[0];
- var xField = xScale.field;
- var x = xScale.scale(record[xField]);
- var yField = yScale.field;
- var y = yScale.scale(record[yField]);
- return coord.convertPoint({
- x: x,
- y: y
- });
- };
- /**
- * get the data item of the point
- * @param {Object} point canvas position
- * @return {Object} return the data item
- */
- _proto.getRecord = function getRecord(point) {
- var self = this;
- var coord = self.get('coord');
- var xScale = self.getXScale();
- var yScale = self.getYScales()[0];
- var invertPoint = coord.invertPoint(point);
- var record = {};
- record[xScale.field] = xScale.invert(invertPoint.x);
- record[yScale.field] = yScale.invert(invertPoint.y);
- return record;
- };
- /**
- * get the dataset of the point
- * @param {Object} point canvas position
- * @return {Array} return the dataset
- **/
- _proto.getSnapRecords = function getSnapRecords(point) {
- var geom = this.get('geoms')[0];
- var data = [];
- if (geom) {
- // need to judge
- data = geom.getSnapRecords(point);
- }
- return data;
- };
- /**
- * creat scale instances
- * @param {String} field field name of data
- * @return {Scale} return the scale
- */
- _proto.createScale = function createScale(field) {
- var data = this.get('data');
- var filteredData = this.get('filteredData');
- if (filteredData.length) {
- var legendFields = this._getFieldsForLegend();
- if (legendFields.indexOf(field) === -1) {
- data = filteredData;
- }
- }
- var scales = this.get('scales');
- if (!scales[field]) {
- scales[field] = this._createScale(field, data);
- }
- return scales[field];
- };
- /**
- * @protected
- * add geometry instance to geoms
- * @param {Geom} geom geometry instance
- */
- _proto.addGeom = function addGeom(geom) {
- var geoms = this.get('geoms');
- var middlePlot = this.get('middlePlot');
- geoms.push(geom);
- geom.set('chart', this);
- geom.set('container', middlePlot.addGroup());
- };
- /**
- * get the scale of x axis
- * @return {Scale} return the scale
- */
- _proto.getXScale = function getXScale() {
- var self = this;
- var geoms = self.get('geoms');
- var xScale = geoms[0].getXScale();
- return xScale;
- };
- /**
- * get the scale of y axis
- * @return {Array} return the scale
- */
- _proto.getYScales = function getYScales() {
- var geoms = this.get('geoms');
- var rst = [];
- Util.each(geoms, function (geom) {
- var yScale = geom.getYScale();
- if (rst.indexOf(yScale) === -1) {
- rst.push(yScale);
- }
- });
- return rst;
- };
- _proto.getLegendItems = function getLegendItems() {
- if (this.get('legendItems')) {
- return this.get('legendItems');
- }
- var legendItems = {};
- var scales = [];
- var geoms = this.get('geoms');
- Util.each(geoms, function (geom) {
- var colorAttr = geom.getAttr('color');
- if (colorAttr) {
- var scale = colorAttr.getScale('color');
- if (scale.type !== 'identity' && !_isScaleExist(scales, scale)) {
- scales.push(scale);
- var field = scale.field;
- var ticks = scale.getTicks();
- var items = [];
- Util.each(ticks, function (tick) {
- var text = tick.text;
- var name = text;
- var scaleValue = tick.value;
- var value = scale.invert(scaleValue);
- var color = colorAttr.mapping(value).join('') || Global.defaultColor;
- var marker = {
- fill: color,
- radius: 3,
- symbol: 'circle',
- stroke: '#fff'
- };
- items.push({
- name: name,
- // for display
- dataValue: value,
- // the origin value
- checked: true,
- marker: marker
- });
- });
- legendItems[field] = items;
- }
- }
- });
- this.set('legendItems', legendItems);
- return legendItems;
- }; // register the plugins
- _proto.registerPlugins = function registerPlugins(plugins) {
- var self = this;
- var chartPlugins = self.get('plugins') || [];
- if (!Util.isArray(chartPlugins)) {
- chartPlugins = [chartPlugins];
- }
- [].concat(plugins).forEach(function (plugin) {
- if (chartPlugins.indexOf(plugin) === -1) {
- plugin.init && plugin.init(self); // init
- chartPlugins.push(plugin);
- }
- });
- Chart.plugins._cacheId++;
- self.set('plugins', chartPlugins);
- };
- _proto._renderAxis = function _renderAxis() {
- var axisController = this.get('axisController');
- var xScale = this.getXScale();
- var yScales = this.getYScales();
- var coord = this.get('coord');
- Chart.plugins.notify(this, 'beforeRenderAxis');
- axisController.createAxis(coord, xScale, yScales);
- };
- _proto._isAutoPadding = function _isAutoPadding() {
- if (this.get('_padding')) {
- return false;
- }
- var padding = this.get('padding');
- if (Util.isArray(padding)) {
- return padding.indexOf('auto') !== -1;
- }
- return padding === 'auto';
- };
- _proto._updateLayout = function _updateLayout(padding) {
- var width = this.get('width');
- var height = this.get('height');
- var start = {
- x: padding[3],
- y: padding[0]
- };
- var end = {
- x: width - padding[1],
- y: height - padding[2]
- };
- var plot = this.get('plot');
- var coord = this.get('coord');
- plot.reset(start, end);
- coord.reset(plot);
- };
- return Chart;
- }(Base);
- Chart.plugins = Chart.initPlugins();
- module.exports = Chart;
- /***/ }),
- /* 20 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview shape util
- * @author dxq613@gmail.com
- */
- var Util = __webpack_require__(0);
- var ShapeUtil = {
- splitPoints: function splitPoints(obj) {
- var points = [];
- var x = obj.x;
- var y = obj.y;
- y = Util.isArray(y) ? y : [y];
- y.forEach(function (yItem, index) {
- var point = {
- x: Util.isArray(x) ? x[index] : x,
- y: yItem
- };
- points.push(point);
- });
- return points;
- },
- splitArray: function splitArray(data, yField, connectNulls) {
- if (!data.length) return [];
- var arr = [];
- var tmp = [];
- var yValue;
- Util.each(data, function (obj) {
- yValue = obj._origin ? obj._origin[yField] : obj[yField];
- if (connectNulls) {
- if (!Util.isNil(yValue)) {
- tmp.push(obj);
- }
- } else {
- if (Util.isArray(yValue) && Util.isNil(yValue[0]) || Util.isNil(yValue)) {
- if (tmp.length) {
- arr.push(tmp);
- tmp = [];
- }
- } else {
- tmp.push(obj);
- }
- }
- });
- if (tmp.length) {
- arr.push(tmp);
- }
- return arr;
- }
- };
- module.exports = ShapeUtil;
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Base =
- /*#__PURE__*/
- function () {
- var _proto = Base.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {};
- function Base(cfg) {
- this._initDefaultCfg();
- Util.mix(this, cfg);
- var start;
- var end;
- if (this.plot) {
- start = this.plot.bl;
- end = this.plot.tr;
- this.start = start;
- this.end = end;
- } else {
- start = this.start;
- end = this.end;
- }
- this.init(start, end);
- }
- _proto.init = function init() {};
- _proto.convertPoint = function convertPoint(point) {
- return point;
- };
- _proto.invertPoint = function invertPoint(point) {
- return point;
- };
- _proto.reset = function reset(plot) {
- this.plot = plot;
- var bl = plot.bl,
- tr = plot.tr;
- this.start = bl;
- this.end = tr;
- this.init(bl, tr);
- };
- return Base;
- }();
- module.exports = Base;
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- var mix = __webpack_require__(16);
- var Adjust =
- /*#__PURE__*/
- function () {
- var _proto = Adjust.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
- };
- function Adjust(cfg) {
- this._initDefaultCfg();
- mix(this, cfg);
- }
- /**
- * @override
- */
- _proto.processAdjust = function processAdjust()
- /* dataArray */
- {};
- return Adjust;
- }();
- module.exports = Adjust;
- /***/ }),
- /* 23 */
- /***/ (function(module, exports) {
- var Matrix = {
- multiply: function multiply(m1, m2) {
- var m11 = m1[0] * m2[0] + m1[2] * m2[1];
- var m12 = m1[1] * m2[0] + m1[3] * m2[1];
- var m21 = m1[0] * m2[2] + m1[2] * m2[3];
- var m22 = m1[1] * m2[2] + m1[3] * m2[3];
- var dx = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
- var dy = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
- return [m11, m12, m21, m22, dx, dy];
- },
- scale: function scale(out, m, v) {
- out[0] = m[0] * v[0];
- out[1] = m[1] * v[0];
- out[2] = m[2] * v[1];
- out[3] = m[3] * v[1];
- out[4] = m[4];
- out[5] = m[5];
- return out;
- },
- rotate: function rotate(out, m, radian) {
- var c = Math.cos(radian);
- var s = Math.sin(radian);
- var m11 = m[0] * c + m[2] * s;
- var m12 = m[1] * c + m[3] * s;
- var m21 = m[0] * -s + m[2] * c;
- var m22 = m[1] * -s + m[3] * c;
- out[0] = m11;
- out[1] = m12;
- out[2] = m21;
- out[3] = m22;
- out[4] = m[4];
- out[5] = m[5];
- return out;
- },
- translate: function translate(out, m, v) {
- out[0] = m[0];
- out[1] = m[1];
- out[2] = m[2];
- out[3] = m[3];
- out[4] = m[4] + m[0] * v[0] + m[2] * v[1];
- out[5] = m[5] + m[1] * v[0] + m[3] * v[1];
- return out;
- },
- transform: function transform(m, actions) {
- var out = [].concat(m);
- for (var i = 0, len = actions.length; i < len; i++) {
- var action = actions[i];
- switch (action[0]) {
- case 't':
- Matrix.translate(out, out, [action[1], action[2]]);
- break;
- case 's':
- Matrix.scale(out, out, [action[1], action[2]]);
- break;
- case 'r':
- Matrix.rotate(out, out, action[1]);
- break;
- default:
- break;
- }
- }
- return out;
- }
- };
- module.exports = Matrix;
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(1);
- var Vector2 = __webpack_require__(4);
- var Abastract =
- /*#__PURE__*/
- function () {
- var _proto = Abastract.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- /**
- * ticks
- * @type {Array}
- */
- this.ticks = [];
- /**
- * the configuration for tickLine
- * @type {Object}
- */
- this.tickLine = {};
- /**
- * the direction of ticks, 1 means clockwise
- * @type {Number}
- */
- this.offsetFactor = 1;
- /**
- * the top container
- * @type {container}
- */
- this.frontContainer = null;
- /**
- * the back container
- * @type {[type]}
- */
- this.backContainer = null;
- /**
- * points for draw grid line
- * @type {Array}
- */
- this.gridPoints = [];
- };
- function Abastract(cfg) {
- this._initDefaultCfg();
- Util.mix(this, cfg);
- this.draw();
- }
- _proto.draw = function draw() {
- var line = this.line,
- tickLine = this.tickLine,
- label = this.label,
- grid = this.grid;
- grid && this.drawGrid(grid); // draw the grid lines
- tickLine && this.drawTicks(tickLine); // draw the tickLine
- line && this.drawLine(line); // draw axis line
- label && this.drawLabels(); // draw ticks
- };
- _proto.drawTicks = function drawTicks(tickCfg) {
- var self = this;
- var ticks = self.ticks;
- var length = tickCfg.length;
- var container = self.getContainer(tickCfg.top);
- Util.each(ticks, function (tick) {
- var start = self.getOffsetPoint(tick.value);
- var end = self.getSidePoint(start, length);
- var shape = container.addShape('line', {
- className: 'axis-tick',
- attrs: Util.mix({
- x1: start.x,
- y1: start.y,
- x2: end.x,
- y2: end.y
- }, tickCfg)
- });
- shape._id = self._id + '-ticks';
- });
- };
- _proto.drawLabels = function drawLabels() {
- var self = this;
- var labelOffset = self.labelOffset;
- var labels = self.labels;
- Util.each(labels, function (labelShape) {
- var container = self.getContainer(labelShape.get('top'));
- var start = self.getOffsetPoint(labelShape.get('value'));
- var _self$getSidePoint = self.getSidePoint(start, labelOffset),
- x = _self$getSidePoint.x,
- y = _self$getSidePoint.y;
- labelShape.attr(Util.mix({
- x: x,
- y: y
- }, self.getTextAlignInfo(start, labelOffset), labelShape.get('textStyle')));
- labelShape._id = self._id + '-' + labelShape.attr('text');
- container.add(labelShape);
- });
- };
- _proto.drawLine = function drawLine() {};
- _proto.drawGrid = function drawGrid(grid) {
- var self = this;
- var gridPoints = self.gridPoints,
- ticks = self.ticks;
- var gridCfg = grid;
- var count = gridPoints.length;
- Util.each(gridPoints, function (subPoints, index) {
- if (Util.isFunction(grid)) {
- var tick = ticks[index] || {};
- var executedGrid = grid(tick.text, index, count);
- gridCfg = executedGrid ? Util.mix({}, Global._defaultAxis.grid, executedGrid) : null;
- }
- if (gridCfg) {
- var type = gridCfg.type; // has two types: 'line' and 'arc'
- var points = subPoints.points;
- var container = self.getContainer(gridCfg.top);
- var shape;
- if (type === 'arc') {
- var center = self.center,
- startAngle = self.startAngle,
- endAngle = self.endAngle;
- var radius = Vector2.length([points[0].x - center.x, points[0].y - center.y]);
- shape = container.addShape('Arc', {
- className: 'axis-grid',
- attrs: Util.mix({
- x: center.x,
- y: center.y,
- startAngle: startAngle,
- endAngle: endAngle,
- r: radius
- }, gridCfg)
- });
- } else {
- shape = container.addShape('Polyline', {
- className: 'axis-grid',
- attrs: Util.mix({
- points: points
- }, gridCfg)
- });
- }
- shape._id = subPoints._id;
- }
- });
- };
- _proto.getOffsetPoint = function getOffsetPoint() {};
- _proto.getAxisVector = function getAxisVector() {};
- _proto.getOffsetVector = function getOffsetVector(point, offset) {
- var self = this;
- var axisVector = self.getAxisVector(point);
- var normal = Vector2.normalize([], axisVector);
- var factor = self.offsetFactor;
- var verticalVector = [normal[1] * -1 * factor, normal[0] * factor];
- return Vector2.scale([], verticalVector, offset);
- };
- _proto.getSidePoint = function getSidePoint(point, offset) {
- var self = this;
- var offsetVector = self.getOffsetVector(point, offset);
- return {
- x: point.x + offsetVector[0],
- y: point.y + offsetVector[1]
- };
- };
- _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
- var self = this;
- var offsetVector = self.getOffsetVector(point, offset);
- var align;
- var baseLine;
- if (offsetVector[0] > 0) {
- align = 'left';
- } else if (offsetVector[0] < 0) {
- align = 'right';
- } else {
- align = 'center';
- }
- if (offsetVector[1] > 0) {
- baseLine = 'top';
- } else if (offsetVector[1] < 0) {
- baseLine = 'bottom';
- } else {
- baseLine = 'middle';
- }
- return {
- textAlign: align,
- textBaseline: baseLine
- };
- };
- _proto.getContainer = function getContainer(isTop) {
- var frontContainer = this.frontContainer,
- backContainer = this.backContainer;
- return isTop ? frontContainer : backContainer;
- };
- return Abastract;
- }();
- module.exports = Abastract;
- /***/ }),
- /* 25 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var MatrixUtil = __webpack_require__(23);
- var Vector2 = __webpack_require__(4);
- var StyleUtil = __webpack_require__(69);
- function isUnchanged(m) {
- return m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1 && m[4] === 0 && m[5] === 0;
- }
- var ALIAS_ATTRS_MAP = {
- stroke: 'strokeStyle',
- fill: 'fillStyle',
- opacity: 'globalAlpha'
- };
- var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash'];
- var CLIP_SHAPES = ['circle', 'sector', 'polygon', 'rect', 'polyline'];
- var Element =
- /*#__PURE__*/
- function () {
- var _proto = Element.prototype;
- _proto._initProperties = function _initProperties() {
- this._attrs = {
- zIndex: 0,
- visible: true,
- destroyed: false
- };
- };
- function Element(cfg) {
- this._initProperties();
- Util.mix(this._attrs, cfg);
- var attrs = this._attrs.attrs;
- if (attrs) {
- this.initAttrs(attrs);
- }
- this.initTransform();
- }
- _proto.get = function get(name) {
- return this._attrs[name];
- };
- _proto.set = function set(name, value) {
- this._attrs[name] = value;
- };
- _proto.isGroup = function isGroup() {
- return this.get('isGroup');
- };
- _proto.isShape = function isShape() {
- return this.get('isShape');
- };
- _proto.initAttrs = function initAttrs(attrs) {
- this.attr(Util.mix(this.getDefaultAttrs(), attrs));
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {};
- };
- _proto._setAttr = function _setAttr(name, value) {
- var attrs = this._attrs.attrs;
- if (name === 'clip') {
- value = this._setAttrClip(value);
- } else {
- var alias = ALIAS_ATTRS_MAP[name];
- if (alias) {
- attrs[alias] = value;
- }
- }
- attrs[name] = value;
- };
- _proto._getAttr = function _getAttr(name) {
- return this._attrs.attrs[name];
- }; // _afterAttrsSet() {}
- _proto._setAttrClip = function _setAttrClip(clip) {
- if (clip && CLIP_SHAPES.indexOf(clip._attrs.type) > -1) {
- if (clip.get('canvas') === null) {
- clip = Object.assign({}, clip);
- }
- clip.set('parent', this.get('parent'));
- clip.set('context', this.get('context'));
- return clip;
- }
- return null;
- };
- _proto.attr = function attr(name, value) {
- var self = this;
- if (self.get('destroyed')) return null;
- var argumentsLen = arguments.length;
- if (argumentsLen === 0) {
- return self._attrs.attrs;
- }
- if (Util.isObject(name)) {
- this._attrs.bbox = null;
- for (var k in name) {
- self._setAttr(k, name[k]);
- }
- if (self._afterAttrsSet) {
- self._afterAttrsSet();
- }
- return self;
- }
- if (argumentsLen === 2) {
- this._attrs.bbox = null;
- self._setAttr(name, value);
- if (self._afterAttrsSet) {
- self._afterAttrsSet();
- }
- return self;
- }
- return self._getAttr(name);
- };
- _proto.getParent = function getParent() {
- return this.get('parent');
- };
- _proto.draw = function draw(context) {
- if (this.get('destroyed')) {
- return;
- }
- if (this.get('visible')) {
- this.setContext(context);
- this.drawInner(context);
- this.restoreContext(context);
- }
- };
- _proto.setContext = function setContext(context) {
- var clip = this._attrs.attrs.clip;
- context.save();
- if (clip) {
- clip.resetTransform(context);
- clip.createPath(context);
- context.clip();
- }
- this.resetContext(context);
- this.resetTransform(context);
- };
- _proto.restoreContext = function restoreContext(context) {
- context.restore();
- };
- _proto.resetContext = function resetContext(context) {
- var elAttrs = this._attrs.attrs;
- if (!this._attrs.isGroup) {
- for (var k in elAttrs) {
- if (SHAPE_ATTRS.indexOf(k) > -1) {
- var v = elAttrs[k];
- if (k === 'fillStyle' || k === 'strokeStyle') {
- v = StyleUtil.parseStyle(v, this, context);
- }
- if (k === 'lineDash' && context.setLineDash && Util.isArray(v)) {
- context.setLineDash(v);
- } else {
- context[k] = v;
- }
- }
- }
- }
- };
- _proto.hasFill = function hasFill() {
- return this.get('canFill') && this._attrs.attrs.fillStyle;
- };
- _proto.hasStroke = function hasStroke() {
- return this.get('canStroke') && this._attrs.attrs.strokeStyle;
- };
- _proto.drawInner = function drawInner()
- /* context */
- {};
- _proto.show = function show() {
- this.set('visible', true);
- return this;
- };
- _proto.hide = function hide() {
- this.set('visible', false);
- return this;
- };
- _proto.isVisible = function isVisible() {
- return this.get('visible');
- };
- _proto._removeFromParent = function _removeFromParent() {
- var parent = this.get('parent');
- if (parent) {
- var children = parent.get('children');
- Util.Array.remove(children, this);
- }
- return this;
- };
- _proto.remove = function remove(destroy) {
- if (destroy) {
- this.destroy();
- } else {
- this._removeFromParent();
- }
- };
- _proto.destroy = function destroy() {
- var destroyed = this.get('destroyed');
- if (destroyed) {
- return null;
- }
- this._removeFromParent();
- this._attrs = {};
- this.set('destroyed', true);
- };
- _proto.getBBox = function getBBox() {
- return {
- minX: 0,
- maxX: 0,
- minY: 0,
- maxY: 0,
- width: 0,
- height: 0
- };
- };
- _proto.initTransform = function initTransform() {
- var attrs = this._attrs.attrs || {};
- if (!attrs.matrix) {
- attrs.matrix = [1, 0, 0, 1, 0, 0];
- }
- this._attrs.attrs = attrs;
- };
- _proto.getMatrix = function getMatrix() {
- return this._attrs.attrs.matrix;
- };
- _proto.setMatrix = function setMatrix(m) {
- this._attrs.attrs.matrix = [m[0], m[1], m[2], m[3], m[4], m[5]];
- };
- _proto.transform = function transform(actions) {
- var matrix = this._attrs.attrs.matrix;
- this._attrs.attrs.matrix = MatrixUtil.transform(matrix, actions);
- return this;
- };
- _proto.setTransform = function setTransform(actions) {
- this._attrs.attrs.matrix = [1, 0, 0, 1, 0, 0];
- return this.transform(actions);
- };
- _proto.translate = function translate(x, y) {
- var matrix = this._attrs.attrs.matrix;
- MatrixUtil.translate(matrix, matrix, [x, y]);
- };
- _proto.rotate = function rotate(rad) {
- var matrix = this._attrs.attrs.matrix;
- MatrixUtil.rotate(matrix, matrix, rad);
- };
- _proto.scale = function scale(sx, sy) {
- var matrix = this._attrs.attrs.matrix;
- MatrixUtil.scale(matrix, matrix, [sx, sy]);
- };
- _proto.moveTo = function moveTo(x, y) {
- var cx = this._attrs.x || 0;
- var cy = this._attrs.y || 0;
- this.translate(x - cx, y - cy);
- this.set('x', x);
- this.set('y', y);
- };
- _proto.apply = function apply(v) {
- var m = this._attrs.attrs.matrix;
- Vector2.transformMat2d(v, v, m);
- return this;
- };
- _proto.resetTransform = function resetTransform(context) {
- var mo = this._attrs.attrs.matrix;
- if (!isUnchanged(mo)) {
- context.transform(mo[0], mo[1], mo[2], mo[3], mo[4], mo[5]);
- }
- };
- _proto.isDestroyed = function isDestroyed() {
- return this.get('destroyed');
- };
- return Element;
- }();
- module.exports = Element;
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
- var _require = __webpack_require__(5),
- Shape = _require.Shape;
- module.exports = {
- getClip: function getClip(coord) {
- var start = coord.start;
- var end = coord.end;
- var width = end.x - start.x;
- var height = Math.abs(end.y - start.y);
- var margin = 10;
- var clip;
- if (coord.isPolar) {
- var circleRadius = coord.circleRadius,
- center = coord.center,
- startAngle = coord.startAngle,
- endAngle = coord.endAngle;
- clip = new Shape.Sector({
- attrs: {
- x: center.x,
- y: center.y,
- r: circleRadius,
- r0: 0,
- startAngle: startAngle,
- endAngle: endAngle
- }
- });
- } else {
- clip = new Shape.Rect({
- attrs: {
- x: start.x,
- y: end.y - margin,
- width: width,
- height: height + 2 * margin
- }
- });
- }
- clip.isClip = true;
- return clip;
- },
- isPointInPlot: function isPointInPlot(point, plot) {
- var x = point.x,
- y = point.y;
- var tl = plot.tl,
- tr = plot.tr,
- br = plot.br;
- return x >= tl.x && x <= tr.x && y >= tl.y && y <= br.y;
- }
- };
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
- var isNil = __webpack_require__(7);
- function toString(value) {
- if (isNil(value)) return '';
- return value.toString();
- }
- module.exports = toString;
- /***/ }),
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
- var isObjectLike = __webpack_require__(48);
- var isType = __webpack_require__(8);
- var isPlainObject = function isPlainObject(value) {
- /**
- * isObjectLike(new Foo) => false
- * isObjectLike([1, 2, 3]) => false
- * isObjectLike({ x: 0, y: 0 }) => true
- * isObjectLike(Object.create(null)) => true
- */
- if (!isObjectLike(value) || !isType(value, 'Object')) {
- return false;
- }
- if (Object.getPrototypeOf(value) === null) {
- return true;
- }
- var proto = value;
- while (Object.getPrototypeOf(proto) !== null) {
- proto = Object.getPrototypeOf(proto);
- }
- return Object.getPrototypeOf(value) === proto;
- };
- module.exports = isPlainObject;
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview Base class of chart and geometry
- * @author dxq613@gmail.com
- */
- var Util = __webpack_require__(0);
- var Base =
- /*#__PURE__*/
- function () {
- var _proto = Base.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {};
- };
- function Base(cfg) {
- var attrs = {};
- var defaultCfg = this.getDefaultCfg();
- this._attrs = attrs;
- Util.mix(attrs, defaultCfg, cfg);
- }
- _proto.get = function get(name) {
- return this._attrs[name];
- };
- _proto.set = function set(name, value) {
- this._attrs[name] = value;
- };
- _proto.destroy = function destroy() {
- this._attrs = {};
- this.destroyed = true;
- };
- return Base;
- }();
- module.exports = Base;
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(2);
- var SHAPE_MAP = {};
- var INDEX = '_INDEX';
- function getComparer(compare) {
- return function (left, right) {
- var result = compare(left, right);
- return result === 0 ? left[INDEX] - right[INDEX] : result;
- };
- }
- module.exports = {
- getGroupClass: function getGroupClass() {},
- getChildren: function getChildren() {
- return this.get('children');
- },
- addShape: function addShape(type, cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var canvas = this.get('canvas');
- var shapeType = SHAPE_MAP[type];
- if (!shapeType) {
- shapeType = Util.upperFirst(type);
- SHAPE_MAP[type] = shapeType;
- }
- cfg.canvas = canvas;
- if (shapeType === 'Text' && canvas && canvas.get('fontFamily')) {
- cfg.attrs.fontFamily = cfg.attrs.fontFamily || canvas.get('fontFamily');
- }
- var shape = new Shape[shapeType](cfg);
- this.add(shape);
- return shape;
- },
- addGroup: function addGroup(cfg) {
- var canvas = this.get('canvas');
- var groupClass = this.getGroupClass();
- cfg = Util.mix({}, cfg);
- cfg.canvas = canvas;
- cfg.parent = this;
- var rst = new groupClass(cfg);
- this.add(rst);
- return rst;
- },
- contain: function contain(item) {
- var children = this.get('children');
- return children.indexOf(item) > -1;
- },
- sort: function sort() {
- var children = this.get('children');
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- child[INDEX] = i;
- }
- children.sort(getComparer(function (obj1, obj2) {
- return obj1.get('zIndex') - obj2.get('zIndex');
- }));
- return this;
- },
- clear: function clear() {
- var children = this.get('children');
- while (children.length !== 0) {
- children[children.length - 1].remove(true);
- }
- return this;
- },
- add: function add(items) {
- var self = this;
- var children = self.get('children');
- if (!Util.isArray(items)) {
- items = [items];
- }
- for (var i = 0, len = items.length; i < len; i++) {
- var item = items[i];
- var parent = item.get('parent');
- if (parent) {
- var descendants = parent.get('children');
- Util.Array.remove(descendants, item);
- }
- self._setEvn(item);
- children.push(item);
- }
- return self;
- },
- _setEvn: function _setEvn(item) {
- var self = this;
- item._attrs.parent = self;
- item._attrs.context = self._attrs.context;
- item._attrs.canvas = self._attrs.canvas;
- var clip = item._attrs.attrs.clip;
- if (clip) {
- clip.set('parent', self);
- clip.set('context', self.get('context'));
- }
- if (item._attrs.isGroup) {
- var children = item._attrs.children;
- for (var i = 0, len = children.length; i < len; i++) {
- item._setEvn(children[i]);
- }
- }
- }
- };
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Element = __webpack_require__(25);
- var Container = __webpack_require__(30);
- var Vector2 = __webpack_require__(4);
- var Group =
- /*#__PURE__*/
- function (_Element) {
- _inheritsLoose(Group, _Element);
- function Group() {
- return _Element.apply(this, arguments) || this;
- }
- var _proto = Group.prototype;
- _proto._initProperties = function _initProperties() {
- this._attrs = {
- zIndex: 0,
- visible: true,
- destroyed: false,
- isGroup: true,
- children: []
- };
- };
- _proto.drawInner = function drawInner(context) {
- var children = this.get('children');
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- child.draw(context);
- }
- return this;
- };
- _proto.getBBox = function getBBox() {
- var self = this;
- var minX = Infinity;
- var maxX = -Infinity;
- var minY = Infinity;
- var maxY = -Infinity;
- var children = self.get('children');
- for (var i = 0, length = children.length; i < length; i++) {
- var child = children[i];
- if (child.get('visible')) {
- var box = child.getBBox();
- if (!box) {
- continue;
- }
- var leftTop = [box.minX, box.minY];
- var leftBottom = [box.minX, box.maxY];
- var rightTop = [box.maxX, box.minY];
- var rightBottom = [box.maxX, box.maxY];
- var matrix = child.attr('matrix');
- Vector2.transformMat2d(leftTop, leftTop, matrix);
- Vector2.transformMat2d(leftBottom, leftBottom, matrix);
- Vector2.transformMat2d(rightTop, rightTop, matrix);
- Vector2.transformMat2d(rightBottom, rightBottom, matrix);
- minX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], minX);
- maxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0], maxX);
- minY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], minY);
- maxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1], maxY);
- }
- }
- return {
- minX: minX,
- minY: minY,
- maxX: maxX,
- maxY: maxY,
- x: minX,
- y: minY,
- width: maxX - minX,
- height: maxY - minY
- };
- };
- _proto.destroy = function destroy() {
- if (this.get('destroyed')) {
- return;
- }
- this.clear();
- _Element.prototype.destroy.call(this);
- };
- return Group;
- }(Element);
- Util.mix(Group.prototype, Container, {
- getGroupClass: function getGroupClass() {
- return Group;
- }
- });
- module.exports = Group;
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(9);
- var ShapeUtil = __webpack_require__(20);
- var Global = __webpack_require__(1); // register line geom
- var Line = Shape.registerFactory('line', {
- defaultShapeType: 'line'
- });
- function getStyle(cfg) {
- var style = {
- strokeStyle: cfg.color
- };
- if (cfg.size >= 0) {
- style.lineWidth = cfg.size;
- }
- Util.mix(style, cfg.style);
- return Util.mix({}, Global.shape.line, style);
- }
- function drawLines(cfg, container, style, smooth) {
- var points = cfg.points;
- if (points.length && Util.isArray(points[0].y)) {
- var topPoints = [];
- var bottomPoints = [];
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- var tmp = ShapeUtil.splitPoints(point);
- bottomPoints.push(tmp[0]);
- topPoints.push(tmp[1]);
- }
- if (cfg.isInCircle) {
- topPoints.push(topPoints[0]);
- bottomPoints.push(bottomPoints[0]);
- }
- if (cfg.isStack) {
- return container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: topPoints,
- smooth: smooth
- }, style)
- });
- }
- var topShape = container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: topPoints,
- smooth: smooth
- }, style)
- });
- var bottomShape = container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: bottomPoints,
- smooth: smooth
- }, style)
- });
- return [topShape, bottomShape];
- }
- if (cfg.isInCircle) {
- points.push(points[0]);
- }
- return container.addShape('Polyline', {
- className: 'line',
- attrs: Util.mix({
- points: points,
- smooth: smooth
- }, style)
- });
- }
- var SHAPES = ['line', 'smooth', 'dash'];
- Util.each(SHAPES, function (shapeType) {
- Shape.registerShape('line', shapeType, {
- draw: function draw(cfg, container) {
- var smooth = shapeType === 'smooth';
- var style = getStyle(cfg);
- if (shapeType === 'dash') {
- style.lineDash = Global.lineDash;
- }
- return drawLines(cfg, container, style, smooth);
- }
- });
- });
- module.exports = Line;
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- var isType = __webpack_require__(8);
- var isDate = function isDate(value) {
- return isType(value, 'Date');
- };
- module.exports = isDate;
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Base = __webpack_require__(14);
- var catAuto = __webpack_require__(35);
- var each = __webpack_require__(3);
- var isNumber = __webpack_require__(13);
- var isString = __webpack_require__(15);
- var Category =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Category, _Base);
- function Category() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Category.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Base.prototype._initDefaultCfg.call(this);
- this.type = 'cat';
- /**
- * 是否分类度量
- * @type {Boolean}
- */
- this.isCategory = true;
- this.isRounding = true; // 是否进行取整操作
- };
- /**
- * @override
- */
- _proto.init = function init() {
- var self = this;
- var values = self.values;
- var tickCount = self.tickCount;
- each(values, function (v, i) {
- values[i] = v.toString();
- });
- if (!self.ticks) {
- var ticks = values;
- if (tickCount) {
- var temp = catAuto({
- maxCount: tickCount,
- data: values,
- isRounding: self.isRounding
- });
- ticks = temp.ticks;
- }
- this.ticks = ticks;
- }
- };
- /**
- * @override
- */
- _proto.getText = function getText(value) {
- if (this.values.indexOf(value) === -1 && isNumber(value)) {
- value = this.values[Math.round(value)];
- }
- return _Base.prototype.getText.call(this, value);
- };
- /**
- * @override
- */
- _proto.translate = function translate(value) {
- var index = this.values.indexOf(value);
- if (index === -1 && isNumber(value)) {
- index = value;
- } else if (index === -1) {
- index = NaN;
- }
- return index;
- };
- /**
- * @override
- */
- _proto.scale = function scale(value) {
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- var percent;
- if (isString(value) || this.values.indexOf(value) !== -1) {
- value = this.translate(value);
- }
- if (this.values.length > 1) {
- percent = value / (this.values.length - 1);
- } else {
- percent = value;
- }
- return rangeMin + percent * (rangeMax - rangeMin);
- };
- /**
- * @override
- */
- _proto.invert = function invert(value) {
- if (isString(value)) {
- // 如果已经是字符串
- return value;
- }
- var min = this.rangeMin();
- var max = this.rangeMax(); // 归一到 范围内
- if (value < min) {
- value = min;
- }
- if (value > max) {
- value = max;
- }
- var percent = (value - min) / (max - min);
- var index = Math.round(percent * (this.values.length - 1)) % this.values.length;
- index = index || 0;
- return this.values[index];
- };
- return Category;
- }(Base);
- Base.Cat = Category;
- module.exports = Category;
- /***/ }),
- /* 35 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview 计算分类的的坐标点
- * @author dxq613@gmail.com
- */
- var each = __webpack_require__(3);
- var MAX_COUNT = 8;
- var SUB_COUNT = 4; // 控制个数不能过小
- function getSimpleArray(data) {
- var arr = [];
- each(data, function (sub) {
- arr = arr.concat(sub);
- });
- return arr;
- }
- function getGreatestFactor(count, number) {
- var i;
- for (i = number; i > 0; i--) {
- if (count % i === 0) {
- break;
- }
- } // 如果是素数,没有可以整除的数字
- if (i === 1) {
- for (i = number; i > 0; i--) {
- if ((count - 1) % i === 0) {
- break;
- }
- }
- }
- return i;
- }
- module.exports = function (info) {
- var rst = {};
- var ticks = [];
- var isRounding = info.isRounding;
- var categories = getSimpleArray(info.data);
- var length = categories.length;
- var maxCount = info.maxCount || MAX_COUNT;
- var tickCount;
- if (isRounding) {
- // 取整操作
- tickCount = getGreatestFactor(length - 1, maxCount - 1) + 1; // 如果计算出来只有两个坐标点,则直接使用传入的 maxCount
- if (tickCount === 2) {
- tickCount = maxCount;
- } else if (tickCount < maxCount - SUB_COUNT) {
- tickCount = maxCount - SUB_COUNT;
- }
- } else {
- tickCount = maxCount;
- }
- if (!isRounding && length <= tickCount + tickCount / 2) {
- ticks = [].concat(categories);
- } else {
- var step = parseInt(length / (tickCount - 1), 10);
- var groups = categories.map(function (e, i) {
- return i % step === 0 ? categories.slice(i, i + step) : null;
- }).filter(function (e) {
- return e;
- });
- for (var i = 1, groupLen = groups.length; i < groupLen && (isRounding ? i * step < length - step : i < tickCount - 1); i++) {
- ticks.push(groups[i][0]);
- }
- if (categories.length) {
- ticks.unshift(categories[0]);
- var last = categories[length - 1];
- if (ticks.indexOf(last) === -1) {
- ticks.push(last);
- }
- }
- }
- rst.categories = categories;
- rst.ticks = ticks;
- return rst;
- };
- /***/ }),
- /* 36 */
- /***/ (function(module, exports) {
- module.exports = {
- requestAnimationFrame: typeof window === 'object' && window.requestAnimationFrame ? window.requestAnimationFrame : function (fn) {
- return setTimeout(fn, 16);
- }
- };
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview convert the line to curve
- * @author dxq613@gmail.com
- */
- var Vector2 = __webpack_require__(4);
- function getPoint(v) {
- return [v.x, v.y];
- }
- function smoothBezier(points, smooth, isLoop, constraint) {
- var cps = [];
- var prevPoint;
- var nextPoint;
- var hasConstraint = !!constraint;
- var min;
- var max;
- var point;
- var len;
- var l;
- var i;
- if (hasConstraint) {
- min = [Infinity, Infinity];
- max = [-Infinity, -Infinity];
- for (i = 0, l = points.length; i < l; i++) {
- point = getPoint(points[i]);
- Vector2.min(min, min, point);
- Vector2.max(max, max, point);
- }
- Vector2.min(min, min, constraint[0]);
- Vector2.max(max, max, constraint[1]);
- }
- for (i = 0, len = points.length; i < len; i++) {
- point = getPoint(points[i]);
- if (isLoop) {
- prevPoint = getPoint(points[i ? i - 1 : len - 1]);
- nextPoint = getPoint(points[(i + 1) % len]);
- } else {
- if (i === 0 || i === len - 1) {
- cps.push([point[0], point[1]]);
- continue;
- } else {
- prevPoint = getPoint(points[i - 1]);
- nextPoint = getPoint(points[i + 1]);
- }
- }
- var v = Vector2.sub([], nextPoint, prevPoint);
- Vector2.scale(v, v, smooth);
- var d0 = Vector2.distance(point, prevPoint);
- var d1 = Vector2.distance(point, nextPoint);
- var sum = d0 + d1;
- if (sum !== 0) {
- d0 /= sum;
- d1 /= sum;
- }
- var v1 = Vector2.scale([], v, -d0);
- var v2 = Vector2.scale([], v, d1);
- var cp0 = Vector2.add([], point, v1);
- var cp1 = Vector2.add([], point, v2);
- if (hasConstraint) {
- Vector2.max(cp0, cp0, min);
- Vector2.min(cp0, cp0, max);
- Vector2.max(cp1, cp1, min);
- Vector2.min(cp1, cp1, max);
- }
- cps.push([cp0[0], cp0[1]]);
- cps.push([cp1[0], cp1[1]]);
- }
- if (isLoop) {
- cps.push(cps.shift());
- }
- return cps;
- }
- function catmullRom2bezier(pointList, z, constraint) {
- var isLoop = !!z;
- var controlPointList = smoothBezier(pointList, 0.4, isLoop, constraint);
- var len = pointList.length;
- var d1 = [];
- var cp1;
- var cp2;
- var p;
- for (var i = 0; i < len - 1; i++) {
- cp1 = controlPointList[i * 2];
- cp2 = controlPointList[i * 2 + 1];
- p = pointList[i + 1];
- d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
- }
- if (isLoop) {
- cp1 = controlPointList[len];
- cp2 = controlPointList[len + 1];
- p = pointList[0];
- d1.push(['C', cp1[0], cp1[1], cp2[0], cp2[1], p.x, p.y]);
- }
- return d1;
- }
- module.exports = {
- smooth: catmullRom2bezier
- };
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Geom = __webpack_require__(6);
- var ShapeUtil = __webpack_require__(20);
- var Util = __webpack_require__(0);
- __webpack_require__(32);
- var Path =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Path, _Geom);
- function Path() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Path.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'path';
- cfg.shapeType = 'line';
- return cfg;
- };
- _proto.getDrawCfg = function getDrawCfg(obj) {
- var cfg = _Geom.prototype.getDrawCfg.call(this, obj);
- cfg.isStack = this.hasAdjust('stack');
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- var yScale = self.getYScale();
- var connectNulls = self.get('connectNulls');
- var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
- var cfg = this.getDrawCfg(data[0]);
- cfg.origin = data;
- Util.each(splitArray, function (subData, splitedIndex) {
- cfg.splitedIndex = splitedIndex;
- cfg.points = subData;
- self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
- });
- };
- return Path;
- }(Geom);
- Geom.Path = Path;
- module.exports = Path;
- /***/ }),
- /* 39 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview Utility for calculate the with ratui in x axis
- * @author sima.zhang1990@gmail.com
- * @author dxq613@gmail.com
- */
- var Global = __webpack_require__(1);
- var Util = __webpack_require__(0);
- var SizeMixin = {
- getDefalutSize: function getDefalutSize() {
- var defaultSize = this.get('defaultSize');
- if (!defaultSize) {
- var coord = this.get('coord');
- var xScale = this.getXScale();
- var dataArray = this.get('dataArray');
- var count = xScale.values.length;
- var range = xScale.range;
- var normalizeSize = 1 / count;
- var widthRatio = 1;
- if (coord && coord.isPolar) {
- if (coord.transposed && count > 1) {
- widthRatio = Global.widthRatio.multiplePie;
- } else {
- widthRatio = Global.widthRatio.rose;
- }
- } else {
- if (xScale.isLinear) {
- normalizeSize *= range[1] - range[0];
- }
- widthRatio = Global.widthRatio.column;
- }
- normalizeSize *= widthRatio;
- if (this.hasAdjust('dodge')) {
- normalizeSize = normalizeSize / dataArray.length;
- }
- defaultSize = normalizeSize;
- this.set('defaultSize', defaultSize);
- }
- return defaultSize;
- },
- getDimWidth: function getDimWidth(dimName) {
- var coord = this.get('coord');
- var start = coord.convertPoint({
- x: 0,
- y: 0
- });
- var end = coord.convertPoint({
- x: dimName === 'x' ? 1 : 0,
- y: dimName === 'x' ? 0 : 1
- });
- var width = 0;
- if (start && end) {
- width = Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));
- }
- return width;
- },
- _getWidth: function _getWidth() {
- var width = this.get('_width');
- if (!width) {
- var coord = this.get('coord');
- if (coord && coord.isPolar && !coord.transposed) {
- width = (coord.endAngle - coord.startAngle) * coord.circleRadius;
- } else {
- width = this.getDimWidth('x');
- }
- this.set('_width', width);
- }
- return width;
- },
- _toNormalizedSize: function _toNormalizedSize(size) {
- var width = this._getWidth();
- return size / width;
- },
- _toCoordSize: function _toCoordSize(normalizeSize) {
- var width = this._getWidth();
- return width * normalizeSize;
- },
- getNormalizedSize: function getNormalizedSize(obj) {
- var size = this.getAttrValue('size', obj);
- if (Util.isNil(size)) {
- size = this.getDefalutSize();
- } else {
- size = this._toNormalizedSize(size);
- }
- return size;
- },
- getSize: function getSize(obj) {
- var size = this.getAttrValue('size', obj);
- if (Util.isNil(size)) {
- var normalizeSize = this.getDefalutSize();
- size = this._toCoordSize(normalizeSize);
- }
- return size;
- }
- };
- module.exports = SizeMixin;
- /***/ }),
- /* 40 */,
- /* 41 */
- /***/ (function(module, exports, __webpack_require__) {
- var Core = {};
- var Global = __webpack_require__(1);
- Core.Global = Global;
- Core.version = Global.version;
- Core.Chart = __webpack_require__(19);
- Core.Shape = __webpack_require__(9);
- Core.G = __webpack_require__(5);
- Core.Util = __webpack_require__(0);
- Core.track = function (enable) {
- Global.trackable = enable;
- };
- __webpack_require__(79);
- module.exports = Core;
- /***/ }),
- /* 42 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview default theme
- * @author dxq613@gail.com
- */
- var Util = __webpack_require__(0);
- var color1 = '#E8E8E8'; // color of axis-line and axis-grid
- var color2 = '#808080'; // color of axis label
- var defaultAxis = {
- label: {
- fill: color2,
- fontSize: 10
- },
- line: {
- stroke: color1,
- lineWidth: 1
- },
- grid: {
- type: 'line',
- stroke: color1,
- lineWidth: 1,
- lineDash: [2]
- },
- tickLine: null,
- labelOffset: 7.5
- };
- var Theme = {
- fontFamily: '"Helvetica Neue", "San Francisco", Helvetica, Tahoma, Arial, "PingFang SC", "Hiragino Sans GB", "Heiti SC", "Microsoft YaHei", sans-serif',
- defaultColor: '#1890FF',
- pixelRatio: 1,
- padding: 'auto',
- appendPadding: 15,
- colors: ['#1890FF', '#2FC25B', '#FACC14', '#223273', '#8543E0', '#13C2C2', '#3436C7', '#F04864'],
- shapes: {
- line: ['line', 'dash'],
- point: ['circle', 'hollowCircle']
- },
- sizes: [4, 10],
- axis: {
- common: defaultAxis,
- // common axis configuration
- bottom: Util.mix({}, defaultAxis, {
- grid: null
- }),
- left: Util.mix({}, defaultAxis, {
- line: null
- }),
- right: Util.mix({}, defaultAxis, {
- line: null
- }),
- circle: Util.mix({}, defaultAxis, {
- line: null
- }),
- radius: Util.mix({}, defaultAxis, {
- labelOffset: 4
- })
- },
- shape: {
- line: {
- lineWidth: 2,
- lineJoin: 'round',
- lineCap: 'round'
- },
- point: {
- lineWidth: 0,
- size: 3
- },
- area: {
- fillOpacity: 0.1
- }
- },
- _defaultAxis: defaultAxis
- };
- module.exports = Theme;
- /***/ }),
- /* 43 */
- /***/ (function(module, exports) {
- var DomUtil;
- /**
- * Detects support for options object argument in addEventListener.
- * https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support
- * @private
- */
- var supportsEventListenerOptions = function () {
- var supports = false;
- try {
- var options = Object.defineProperty({}, 'passive', {
- get: function get() {
- supports = true;
- }
- });
- window.addEventListener('e', null, options);
- } catch (e) {// continue regardless of error
- }
- return supports;
- }(); // Default passive to true as expected by Chrome for 'touchstart' and 'touchend' events.
- // https://github.com/chartjs/Chart.js/issues/4287
- var eventListenerOptions = supportsEventListenerOptions ? {
- passive: true
- } : false;
- function createEvent(type, chart, x, y, nativeEvent) {
- return {
- type: type,
- chart: chart,
- native: nativeEvent || null,
- x: x !== undefined ? x : null,
- y: y !== undefined ? y : null
- };
- }
- function fromNativeEvent(event, chart) {
- var type = event.type;
- var point = {};
- var touches = event.targetTouches;
- if (touches && touches.length > 0) {
- point.x = touches[0].clientX;
- point.y = touches[0].clientY;
- } else {
- point.x = event.clientX;
- point.y = event.clientY;
- }
- var canvas = chart.get('canvas');
- var pos = DomUtil.getRelativePosition(point, canvas);
- return createEvent(type, chart, pos.x, pos.y, event);
- }
- DomUtil = {
- /* global wx, my, module */
- isWx: typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function',
- // weixin miniprogram
- isMy: typeof my === 'object' && typeof my.getSystemInfoSync === 'function',
- // ant miniprogram
- isNode: typeof module !== 'undefined' && typeof module.exports !== 'undefined',
- // in node
- isBrowser: typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.sessionStorage !== 'undefined',
- // in browser
- getPixelRatio: function getPixelRatio() {
- return window && window.devicePixelRatio || 1;
- },
- getStyle: function getStyle(el, property) {
- return el.currentStyle ? el.currentStyle[property] : document.defaultView.getComputedStyle(el, null).getPropertyValue(property);
- },
- getWidth: function getWidth(el) {
- var width = this.getStyle(el, 'width');
- if (width === 'auto') {
- width = el.offsetWidth;
- }
- return parseFloat(width);
- },
- getHeight: function getHeight(el) {
- var height = this.getStyle(el, 'height');
- if (height === 'auto') {
- height = el.offsetHeight;
- }
- return parseFloat(height);
- },
- getDomById: function getDomById(id) {
- if (!id) {
- return null;
- }
- return document.getElementById(id);
- },
- getRelativePosition: function getRelativePosition(point, canvas) {
- var canvasDom = canvas.get('el');
- var _canvasDom$getBoundin = canvasDom.getBoundingClientRect(),
- top = _canvasDom$getBoundin.top,
- right = _canvasDom$getBoundin.right,
- bottom = _canvasDom$getBoundin.bottom,
- left = _canvasDom$getBoundin.left;
- var paddingLeft = parseFloat(this.getStyle(canvasDom, 'padding-left'));
- var paddingTop = parseFloat(this.getStyle(canvasDom, 'padding-top'));
- var paddingRight = parseFloat(this.getStyle(canvasDom, 'padding-right'));
- var paddingBottom = parseFloat(this.getStyle(canvasDom, 'padding-bottom'));
- var width = right - left - paddingLeft - paddingRight;
- var height = bottom - top - paddingTop - paddingBottom;
- var pixelRatio = canvas.get('pixelRatio');
- var mouseX = (point.x - left - paddingLeft) / width * canvasDom.width / pixelRatio;
- var mouseY = (point.y - top - paddingTop) / height * canvasDom.height / pixelRatio;
- return {
- x: mouseX,
- y: mouseY
- };
- },
- addEventListener: function addEventListener(source, type, listener) {
- DomUtil.isBrowser && source.addEventListener(type, listener, eventListenerOptions);
- },
- removeEventListener: function removeEventListener(source, type, listener) {
- DomUtil.isBrowser && source.removeEventListener(type, listener, eventListenerOptions);
- },
- createEvent: function createEvent(event, chart) {
- return fromNativeEvent(event, chart);
- },
- measureText: function measureText(text, font, ctx) {
- if (!ctx) {
- ctx = document.createElement('canvas').getContext('2d');
- }
- ctx.font = font || '12px sans-serif';
- return ctx.measureText(text);
- }
- };
- module.exports = DomUtil;
- /***/ }),
- /* 44 */
- /***/ (function(module, exports, __webpack_require__) {
- var toString = __webpack_require__(27);
- var upperFirst = function upperFirst(value) {
- var str = toString(value);
- return str.charAt(0).toUpperCase() + str.substring(1);
- };
- module.exports = upperFirst;
- /***/ }),
- /* 45 */
- /***/ (function(module, exports, __webpack_require__) {
- var toString = __webpack_require__(27);
- var lowerFirst = function lowerFirst(value) {
- var str = toString(value);
- return str.charAt(0).toLowerCase() + str.substring(1);
- };
- module.exports = lowerFirst;
- /***/ }),
- /* 46 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 是否是布尔类型
- *
- * @param {Object} value 测试的值
- * @return {Boolean}
- */
- var isType = __webpack_require__(8);
- var isBoolean = function isBoolean(value) {
- return isType(value, 'Boolean');
- };
- module.exports = isBoolean;
- /***/ }),
- /* 47 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * 是否为函数
- * @param {*} fn 对象
- * @return {Boolean} 是否函数
- */
- var isType = __webpack_require__(8);
- var isFunction = function isFunction(value) {
- return isType(value, 'Function');
- };
- module.exports = isFunction;
- /***/ }),
- /* 48 */
- /***/ (function(module, exports) {
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
- return typeof obj;
- } : function (obj) {
- return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
- };
- var isObjectLike = function isObjectLike(value) {
- /**
- * isObjectLike({}) => true
- * isObjectLike([1, 2, 3]) => true
- * isObjectLike(Function) => false
- * isObjectLike(null) => false
- */
- return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
- };
- module.exports = isObjectLike;
- /***/ }),
- /* 49 */
- /***/ (function(module, exports, __webpack_require__) {
- var isPlainObject = __webpack_require__(28);
- var isArray = __webpack_require__(10);
- var MAX_MIX_LEVEL = 5;
- function _deepMix(dist, src, level, maxLevel) {
- level = level || 0;
- maxLevel = maxLevel || MAX_MIX_LEVEL;
- for (var key in src) {
- if (src.hasOwnProperty(key)) {
- var value = src[key];
- if (value !== null && isPlainObject(value)) {
- if (!isPlainObject(dist[key])) {
- dist[key] = {};
- }
- if (level < maxLevel) {
- _deepMix(dist[key], value, level + 1, maxLevel);
- } else {
- dist[key] = src[key];
- }
- } else if (isArray(value)) {
- dist[key] = [];
- dist[key] = dist[key].concat(value);
- } else if (value !== undefined) {
- dist[key] = value;
- }
- }
- }
- }
- var deepMix = function deepMix() {
- var args = new Array(arguments.length);
- var length = args.length;
- for (var i = 0; i < length; i++) {
- args[i] = arguments[i];
- }
- var rst = args[0];
- for (var _i = 1; _i < length; _i++) {
- _deepMix(rst, args[_i]);
- }
- return rst;
- };
- module.exports = deepMix;
- /***/ }),
- /* 50 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Plot =
- /*#__PURE__*/
- function () {
- function Plot(cfg) {
- Util.mix(this, cfg);
- this._init();
- }
- var _proto = Plot.prototype;
- _proto._init = function _init() {
- var self = this;
- var start = self.start;
- var end = self.end;
- var xMin = Math.min(start.x, end.x);
- var xMax = Math.max(start.x, end.x);
- var yMin = Math.min(start.y, end.y);
- var yMax = Math.max(start.y, end.y);
- this.tl = {
- x: xMin,
- y: yMin
- };
- this.tr = {
- x: xMax,
- y: yMin
- };
- this.bl = {
- x: xMin,
- y: yMax
- };
- this.br = {
- x: xMax,
- y: yMax
- };
- this.width = xMax - xMin;
- this.height = yMax - yMin;
- };
- /**
- * reset
- * @param {Object} start start point
- * @param {Object} end end point
- */
- _proto.reset = function reset(start, end) {
- this.start = start;
- this.end = end;
- this._init();
- };
- /**
- * check the point is in the range of plot
- * @param {Nubmer} x x value
- * @param {[type]} y y value
- * @return {Boolean} return the result
- */
- _proto.isInRange = function isInRange(x, y) {
- if (Util.isObject(x)) {
- y = x.y;
- x = x.x;
- }
- var tl = this.tl;
- var br = this.br;
- return tl.x <= x && x <= br.x && tl.y <= y && y <= br.y;
- };
- return Plot;
- }();
- module.exports = Plot;
- /***/ }),
- /* 51 */
- /***/ (function(module, exports, __webpack_require__) {
- var Coord = __webpack_require__(21);
- __webpack_require__(52);
- module.exports = Coord;
- /***/ }),
- /* 52 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Base = __webpack_require__(21);
- var Cartesian =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Cartesian, _Base);
- function Cartesian() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Cartesian.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'cartesian';
- this.transposed = false;
- this.isRect = true;
- };
- _proto.init = function init(start, end) {
- this.x = {
- start: start.x,
- end: end.x
- };
- this.y = {
- start: start.y,
- end: end.y
- };
- };
- _proto.convertPoint = function convertPoint(point) {
- var self = this;
- var transposed = self.transposed;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var x = self.x;
- var y = self.y;
- return {
- x: x.start + (x.end - x.start) * point[xDim],
- y: y.start + (y.end - y.start) * point[yDim]
- };
- };
- _proto.invertPoint = function invertPoint(point) {
- var self = this;
- var transposed = self.transposed;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var x = self.x;
- var y = self.y;
- var rst = {};
- rst[xDim] = (point.x - x.start) / (x.end - x.start);
- rst[yDim] = (point.y - y.start) / (y.end - y.start);
- return rst;
- };
- return Cartesian;
- }(Base);
- Base.Cartesian = Cartesian;
- Base.Rect = Cartesian;
- module.exports = Cartesian;
- /***/ }),
- /* 53 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- Position: __webpack_require__(54),
- Shape: __webpack_require__(55),
- Size: __webpack_require__(56),
- Color: __webpack_require__(57)
- };
- /***/ }),
- /* 54 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var isNil = __webpack_require__(7);
- var isArray = __webpack_require__(10);
- var each = __webpack_require__(3);
- var Base = __webpack_require__(17);
- var Position =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Position, _Base);
- function Position(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['x', 'y'];
- _this.type = 'position';
- return _this;
- }
- var _proto = Position.prototype;
- _proto.mapping = function mapping(x, y) {
- var scales = this.scales;
- var coord = this.coord;
- var scaleX = scales[0];
- var scaleY = scales[1];
- var rstX;
- var rstY;
- var obj;
- if (isNil(x) || isNil(y)) {
- return [];
- }
- if (isArray(y) && isArray(x)) {
- rstX = [];
- rstY = [];
- for (var i = 0, j = 0, xLen = x.length, yLen = y.length; i < xLen && j < yLen; i++, j++) {
- obj = coord.convertPoint({
- x: scaleX.scale(x[i]),
- y: scaleY.scale(y[j])
- });
- rstX.push(obj.x);
- rstY.push(obj.y);
- }
- } else if (isArray(y)) {
- x = scaleX.scale(x);
- rstY = [];
- each(y, function (yVal) {
- yVal = scaleY.scale(yVal);
- obj = coord.convertPoint({
- x: x,
- y: yVal
- });
- if (rstX && rstX !== obj.x) {
- if (!isArray(rstX)) {
- rstX = [rstX];
- }
- rstX.push(obj.x);
- } else {
- rstX = obj.x;
- }
- rstY.push(obj.y);
- });
- } else if (isArray(x)) {
- y = scaleY.scale(y);
- rstX = [];
- each(x, function (xVal) {
- xVal = scaleX.scale(xVal);
- obj = coord.convertPoint({
- x: xVal,
- y: y
- });
- if (rstY && rstY !== obj.y) {
- if (!isArray(rstY)) {
- rstY = [rstY];
- }
- rstY.push(obj.y);
- } else {
- rstY = obj.y;
- }
- rstX.push(obj.x);
- });
- } else {
- x = scaleX.scale(x);
- y = scaleY.scale(y);
- var point = coord.convertPoint({
- x: x,
- y: y
- });
- rstX = point.x;
- rstY = point.y;
- }
- return [rstX, rstY];
- };
- return Position;
- }(Base);
- module.exports = Position;
- /***/ }),
- /* 55 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Base = __webpack_require__(17);
- var Shape =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Shape, _Base);
- function Shape(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['shape'];
- _this.type = 'shape';
- _this.gradient = null;
- return _this;
- }
- /**
- * @override
- */
- var _proto = Shape.prototype;
- _proto.getLinearValue = function getLinearValue(percent) {
- var values = this.values;
- var index = Math.round((values.length - 1) * percent);
- return values[index];
- };
- return Shape;
- }(Base);
- module.exports = Shape;
- /***/ }),
- /* 56 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Base = __webpack_require__(17);
- var Size =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Size, _Base);
- function Size(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['size'];
- _this.type = 'size';
- _this.gradient = null;
- return _this;
- }
- return Size;
- }(Base);
- module.exports = Size;
- /***/ }),
- /* 57 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var ColorUtil = __webpack_require__(58);
- var Base = __webpack_require__(17);
- var Color =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Color, _Base);
- function Color(cfg) {
- var _this;
- _this = _Base.call(this, cfg) || this;
- _this.names = ['color'];
- _this.type = 'color';
- _this.gradient = null;
- if (Util.isString(_this.values)) {
- _this.linear = true;
- }
- return _this;
- }
- /**
- * @override
- */
- var _proto = Color.prototype;
- _proto.getLinearValue = function getLinearValue(percent) {
- var gradient = this.gradient;
- if (!gradient) {
- var values = this.values;
- gradient = ColorUtil.gradient(values);
- this.gradient = gradient;
- }
- return gradient(percent);
- };
- return Color;
- }(Base);
- module.exports = Color;
- /***/ }),
- /* 58 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0); // Get the interpolation between colors
- function getValue(start, end, percent, index) {
- var value = start[index] + (end[index] - start[index]) * percent;
- return value;
- } // convert to hex
- function arr2hex(arr) {
- return '#' + toRGBValue(arr[0]) + toRGBValue(arr[1]) + toRGBValue(arr[2]);
- }
- function toRGBValue(value) {
- value = Math.round(value);
- value = value.toString(16);
- if (value.length === 1) {
- value = '0' + value;
- }
- return value;
- }
- function calColor(colors, percent) {
- var steps = colors.length - 1;
- var step = Math.floor(steps * percent);
- var left = steps * percent - step;
- var start = colors[step];
- var end = step === steps ? start : colors[step + 1];
- var rgb = arr2hex([getValue(start, end, left, 0), getValue(start, end, left, 1), getValue(start, end, left, 2)]);
- return rgb;
- }
- function hex2arr(str) {
- var arr = [];
- arr.push(parseInt(str.substr(1, 2), 16));
- arr.push(parseInt(str.substr(3, 2), 16));
- arr.push(parseInt(str.substr(5, 2), 16));
- return arr;
- }
- var colorCache = {
- black: '#000000',
- blue: '#0000ff',
- grey: '#808080',
- green: '#008000',
- orange: '#ffa500',
- pink: '#ffc0cb',
- purple: '#800080',
- red: '#ff0000',
- white: '#ffffff',
- yellow: '#ffff00'
- };
- var ColorUtil = {
- /**
- * Returns a hexadecimal string representing this color in RGB space, such as #f7eaba.
- * @param {String} color color value
- * @return {String} Returns a hexadecimal string
- */
- toHex: function toHex(color) {
- if (colorCache[color]) {
- return colorCache[color];
- }
- if (color[0] === '#') {
- if (color.length === 7) {
- return color;
- }
- var hex = color.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i, function (m, r, g, b) {
- return '#' + r + r + g + g + b + b;
- }); // hex3 to hex6
- colorCache[color] = hex;
- return hex;
- } // rgb/rgba to hex
- var rst = color.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
- rst.shift();
- rst = arr2hex(rst);
- colorCache[color] = rst;
- return rst;
- },
- hex2arr: hex2arr,
- /**
- * handle the gradient color
- * @param {Array} colors the colors
- * @return {String} return the color value
- */
- gradient: function gradient(colors) {
- var points = [];
- if (Util.isString(colors)) {
- colors = colors.split('-');
- }
- Util.each(colors, function (color) {
- if (color.indexOf('#') === -1) {
- color = ColorUtil.toHex(color);
- }
- points.push(hex2arr(color));
- });
- return function (percent) {
- return calColor(points, percent);
- };
- }
- };
- module.exports = ColorUtil;
- /***/ }),
- /* 59 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(1);
- var Scale = __webpack_require__(60);
- var SCALE_TYPES_MAP = {
- linear: 'Linear',
- cat: 'Cat',
- timeCat: 'TimeCat',
- identity: 'Identity'
- };
- var ScaleController =
- /*#__PURE__*/
- function () {
- function ScaleController(cfg) {
- // defs 列定义
- this.defs = {};
- Util.mix(this, cfg);
- }
- var _proto = ScaleController.prototype;
- _proto._getDef = function _getDef(field) {
- var defs = this.defs;
- var def = null;
- if (Global.scales[field] || defs[field]) {
- def = Util.mix({}, Global.scales[field]);
- Util.each(defs[field], function (v, k) {
- if (Util.isNil(v)) {
- delete def[k];
- } else {
- def[k] = v;
- }
- });
- }
- return def;
- };
- _proto._getDefaultType = function _getDefaultType(field, data, def) {
- if (def && def.type) {
- return def.type;
- }
- var type = 'linear';
- var value = Util.Array.firstValue(data, field);
- if (Util.isArray(value)) {
- value = value[0];
- }
- if (Util.isString(value)) {
- type = 'cat';
- }
- return type;
- };
- _proto._getScaleCfg = function _getScaleCfg(type, field, data, def) {
- var values;
- if (def && def.values) {
- values = def.values;
- } else {
- values = Util.Array.values(data, field);
- }
- var cfg = {
- field: field,
- values: values
- };
- if (type !== 'cat' && type !== 'timeCat') {
- if (!def || !(def.min && def.max)) {
- var _Util$Array$getRange = Util.Array.getRange(values),
- min = _Util$Array$getRange.min,
- max = _Util$Array$getRange.max;
- cfg.min = min;
- cfg.max = max;
- cfg.nice = true;
- }
- }
- if (type === 'cat' || type === 'timeCat') {
- cfg.isRounding = false; // used for tickCount calculation
- }
- return cfg;
- };
- _proto.createScale = function createScale(field, data) {
- var self = this;
- var def = self._getDef(field);
- var scale;
- if (!data || !data.length) {
- if (def && def.type) {
- def.field = field;
- scale = new Scale[SCALE_TYPES_MAP[def.type]](def);
- } else {
- scale = new Scale.Identity({
- value: field,
- field: field.toString(),
- values: [field]
- });
- }
- return scale;
- }
- var firstObj = data[0];
- var firstValue = firstObj[field];
- if (firstValue === null) {
- firstValue = Util.Array.firstValue(data, field);
- }
- if (Util.isNumber(field) || Util.isNil(firstValue) && !def) {
- scale = new Scale.Identity({
- value: field,
- field: field.toString(),
- values: [field]
- });
- } else {
- var type = self._getDefaultType(field, data, def);
- var cfg = self._getScaleCfg(type, field, data, def);
- def && Util.mix(cfg, def);
- scale = new Scale[SCALE_TYPES_MAP[type]](cfg);
- }
- return scale;
- };
- return ScaleController;
- }();
- module.exports = ScaleController;
- /***/ }),
- /* 60 */
- /***/ (function(module, exports, __webpack_require__) {
- var Scale = __webpack_require__(14);
- __webpack_require__(61);
- __webpack_require__(64);
- __webpack_require__(34);
- module.exports = Scale;
- /***/ }),
- /* 61 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- /**
- * @fileOverview The measurement of linear data scale function
- * @author dxq613@gmail.com
- */
- var isNil = __webpack_require__(7);
- var each = __webpack_require__(3);
- var Base = __webpack_require__(14);
- var numberAuto = __webpack_require__(62);
- /**
- * 线性度量
- * @class Scale.Linear
- */
- var Linear =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Linear, _Base);
- function Linear() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Linear.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Base.prototype._initDefaultCfg.call(this);
- var self = this;
- self.type = 'linear';
- self.isLinear = true;
- /**
- * 是否为了用户习惯,优化min,max和ticks,如果进行优化,则会根据生成的ticks调整min,max,否则舍弃(min,max)范围之外的ticks
- * @type {Boolean}
- * @default false
- */
- self.nice = false;
- /**
- * min value of the scale
- * @type {Number}
- * @default null
- */
- self.min = null;
- /**
- * min value limitted of the scale
- * @type {Number}
- * @default null
- */
- self.minLimit = null;
- /**
- * max value of the scale
- * @type {Number}
- * @default null
- */
- self.max = null;
- /**
- * max value limitted of the scale
- * @type {Number}
- * @default null
- */
- self.maxLimit = null;
- /**
- * 自动生成标记时的个数
- * @type {Number}
- * @default null
- */
- self.tickCount = null;
- /**
- * 坐标轴点之间的间距,指的是真实数据的差值
- * @type {Number}
- * @default null
- */
- self.tickInterval = null;
- /**
- * 坐标轴点之间的最小间距,指的是真实数据的差值
- * @type {Number}
- * @default null
- */
- self.minTickInterval = null;
- /**
- * 用于计算坐标点时逼近的数组
- * @type {Array}
- */
- self.snapArray = null;
- };
- /**
- * @protected
- * @override
- */
- _proto.init = function init() {
- var self = this;
- if (!self.ticks) {
- self.min = self.translate(self.min);
- self.max = self.translate(self.max);
- self.initTicks();
- } else {
- var ticks = self.ticks;
- var firstValue = self.translate(ticks[0]);
- var lastValue = self.translate(ticks[ticks.length - 1]);
- if (isNil(self.min) || self.min > firstValue) {
- self.min = firstValue;
- }
- if (isNil(self.max) || self.max < lastValue) {
- self.max = lastValue;
- }
- }
- };
- /**
- * 计算坐标点
- * @protected
- * @return {Array} 计算完成的坐标点
- */
- _proto.calculateTicks = function calculateTicks() {
- var min = this.min,
- max = this.max,
- minLimit = this.minLimit,
- maxLimit = this.maxLimit,
- tickCount = this.tickCount,
- tickInterval = this.tickInterval,
- minTickInterval = this.minTickInterval,
- snapArray = this.snapArray;
- if (tickCount === 1) {
- throw new Error('linear scale\'tickCount should not be 1');
- }
- if (max < min) {
- throw new Error("max: " + max + " should not be less than min: " + min);
- }
- var tmp = numberAuto({
- min: min,
- max: max,
- minLimit: minLimit,
- maxLimit: maxLimit,
- minCount: tickCount,
- maxCount: tickCount,
- interval: tickInterval,
- minTickInterval: minTickInterval,
- snapArray: snapArray
- });
- return tmp.ticks;
- }; // 初始化ticks
- _proto.initTicks = function initTicks() {
- var self = this;
- var calTicks = self.calculateTicks();
- if (self.nice) {
- // 如果需要优化显示的tick
- self.ticks = calTicks;
- self.min = calTicks[0];
- self.max = calTicks[calTicks.length - 1];
- } else {
- var ticks = [];
- each(calTicks, function (tick) {
- if (tick >= self.min && tick <= self.max) {
- ticks.push(tick);
- }
- }); // 如果 ticks 为空,直接输入最小值、最大值
- if (!ticks.length) {
- ticks.push(self.min);
- ticks.push(self.max);
- }
- self.ticks = ticks;
- }
- };
- /**
- * @override
- */
- _proto.scale = function scale(value) {
- if (isNil(value)) {
- return NaN;
- }
- var max = this.max;
- var min = this.min;
- if (max === min) {
- return 0;
- }
- var percent = (value - min) / (max - min);
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- return rangeMin + percent * (rangeMax - rangeMin);
- };
- /**
- * @override
- */
- _proto.invert = function invert(value) {
- var percent = (value - this.rangeMin()) / (this.rangeMax() - this.rangeMin());
- return this.min + percent * (this.max - this.min);
- };
- return Linear;
- }(Base);
- Base.Linear = Linear;
- module.exports = Linear;
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview 自动计算数字坐标轴
- * @author dxq613@gmail.com
- */
- var isNil = __webpack_require__(7);
- var isNumber = __webpack_require__(13);
- var AutoUtil = __webpack_require__(63);
- var MIN_COUNT = 5;
- var MAX_COUNT = 7;
- 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];
- var SNAP_ARRAY = [0, 1, 2, 4, 5, 10];
- module.exports = function (info) {
- var min = info.min;
- var max = info.max;
- var interval = info.interval;
- var minTickInterval = info.minTickInterval;
- var ticks = [];
- var minCount = info.minCount || MIN_COUNT;
- var maxCount = info.maxCount || MAX_COUNT;
- var isFixedCount = minCount === maxCount; // 是否限定死了个数
- var minLimit = isNil(info.minLimit) ? -Infinity : info.minLimit; // 限定的最小值
- var maxLimit = isNil(info.maxLimit) ? Infinity : info.maxLimit; // 限定最大值
- var avgCount = (minCount + maxCount) / 2;
- var count = avgCount; // 用户传入的逼近数组
- var snapArray = info.snapArray ? info.snapArray : isFixedCount ? SNAP_COUNT_ARRAY : SNAP_ARRAY; // 如果限定大小范围,同时大小范围等于用户传入的范围,同时限定了个数,interval 按照个数均分
- if (min === minLimit && max === maxLimit && isFixedCount) {
- interval = (max - min) / (count - 1);
- }
- if (isNil(min)) {
- min = 0;
- }
- if (isNil(max)) {
- max = 0;
- }
- if (max === min) {
- if (min === 0) {
- max = 1;
- } else {
- if (min > 0) {
- min = 0;
- } else {
- max = 0;
- }
- }
- if (max - min < 5 && !interval && max - min >= 1) {
- interval = 1;
- }
- }
- if (isNil(interval)) {
- // 计算间距
- var temp = (max - min) / (avgCount - 1);
- interval = AutoUtil.snapFactorTo(temp, snapArray, 'ceil');
- if (maxCount !== minCount) {
- count = parseInt((max - min) / interval, 10);
- if (count > maxCount) {
- count = maxCount;
- }
- if (count < minCount) {
- count = minCount;
- } // 不确定tick的个数时,使得tick偏小
- interval = AutoUtil.snapFactorTo((max - min) / (count - 1), snapArray, 'floor');
- }
- } // interval should not be less than minTickInterval
- if (isNumber(minTickInterval) && interval < minTickInterval) {
- interval = minTickInterval;
- }
- if (info.interval || maxCount !== minCount) {
- // 校正 max 和 min
- max = Math.min(AutoUtil.snapMultiple(max, interval, 'ceil'), maxLimit); // 向上逼近
- min = Math.max(AutoUtil.snapMultiple(min, interval, 'floor'), minLimit); // 向下逼近
- count = Math.round((max - min) / interval);
- min = AutoUtil.fixedBase(min, interval);
- max = AutoUtil.fixedBase(max, interval);
- } else {
- avgCount = parseInt(avgCount, 10); // 取整
- var avg = (max + min) / 2;
- var avgTick = AutoUtil.snapMultiple(avg, interval, 'ceil');
- var sideCount = Math.floor((avgCount - 2) / 2);
- var maxTick = avgTick + sideCount * interval;
- var minTick;
- if (avgCount % 2 === 0) {
- minTick = avgTick - sideCount * interval;
- } else {
- minTick = avgTick - (sideCount + 1) * interval;
- }
- if (maxTick < max) {
- maxTick = maxTick + interval;
- }
- if (minTick > min) {
- minTick = minTick - interval;
- }
- max = AutoUtil.fixedBase(maxTick, interval);
- min = AutoUtil.fixedBase(minTick, interval);
- }
- max = Math.min(max, maxLimit);
- min = Math.max(min, minLimit);
- ticks.push(min);
- for (var i = 1; i < count; i++) {
- var tickValue = AutoUtil.fixedBase(interval * i + min, interval);
- if (tickValue < max) {
- ticks.push(tickValue);
- }
- }
- if (ticks[ticks.length - 1] < max) {
- ticks.push(max);
- }
- return {
- min: min,
- max: max,
- interval: interval,
- count: count,
- ticks: ticks
- };
- };
- /***/ }),
- /* 63 */
- /***/ (function(module, exports) {
- /**
- * @fileOverview 计算方法
- * @author dxq613@gmail.com
- */
- // 如果小数点后面超过 10 位浮点数时进行一下处理
- var DECIMAL_LENGTH = 12; // 获取系数
- function getFactor(v) {
- var factor = 1;
- if (v === Infinity || v === -Infinity) {
- throw new Error('Not support Infinity!');
- }
- if (v < 1) {
- var count = 0;
- while (v < 1) {
- factor = factor / 10;
- v = v * 10;
- count++;
- } // 浮点数计算出现问题
- if (factor.toString().length > DECIMAL_LENGTH) {
- factor = parseFloat(factor.toFixed(count));
- }
- } else {
- while (v > 10) {
- factor = factor * 10;
- v = v / 10;
- }
- }
- return factor;
- } // 取小于当前值的
- function arrayFloor(values, value) {
- var length = values.length;
- if (length === 0) {
- return NaN;
- }
- var pre = values[0];
- if (value < values[0]) {
- return NaN;
- }
- if (value >= values[length - 1]) {
- return values[length - 1];
- }
- for (var i = 1; i < values.length; i++) {
- if (value < values[i]) {
- break;
- }
- pre = values[i];
- }
- return pre;
- } // 大于当前值的第一个
- function arrayCeiling(values, value) {
- var length = values.length;
- if (length === 0) {
- return NaN;
- } // var pre = values[0];
- var rst;
- if (value > values[length - 1]) {
- return NaN;
- }
- if (value < values[0]) {
- return values[0];
- }
- for (var i = 1; i < values.length; i++) {
- if (value <= values[i]) {
- rst = values[i];
- break;
- }
- }
- return rst;
- }
- var Util = {
- // 获取逼近的数值
- snapFactorTo: function snapFactorTo(v, arr, snapType) {
- // 假设 v = -512,isFloor = true
- if (isNaN(v)) {
- return NaN;
- }
- var factor = 1; // 计算系数
- if (v !== 0) {
- if (v < 0) {
- factor = -1;
- }
- v = v * factor; // v = 512
- var tmpFactor = getFactor(v);
- factor = factor * tmpFactor; // factor = -100
- v = v / tmpFactor; // v = 5.12
- }
- if (snapType === 'floor') {
- v = Util.snapFloor(arr, v); // v = 5
- } else if (snapType === 'ceil') {
- v = Util.snapCeiling(arr, v); // v = 6
- } else {
- v = Util.snapTo(arr, v); // 四舍五入 5
- }
- var rst = v * factor; // 如果出现浮点数计算问题,需要处理一下
- if (Math.abs(factor) < 1 && rst.toString().length > DECIMAL_LENGTH) {
- var decimalVal = parseInt(1 / factor);
- var symbol = factor > 0 ? 1 : -1;
- rst = v / decimalVal * symbol;
- }
- return rst;
- },
- // 获取逼近的倍数
- snapMultiple: function snapMultiple(v, base, snapType) {
- var div;
- if (snapType === 'ceil') {
- div = Math.ceil(v / base);
- } else if (snapType === 'floor') {
- div = Math.floor(v / base);
- } else {
- div = Math.round(v / base);
- }
- return div * base;
- },
- /**
- * 获取逼近的值,用于对齐数据
- * @param {Array} values 数据集合
- * @param {Number} value 数值
- * @return {Number} 逼近的值
- */
- snapTo: function snapTo(values, value) {
- // 这里假定values是升序排列
- var floorVal = arrayFloor(values, value);
- var ceilingVal = arrayCeiling(values, value);
- if (isNaN(floorVal) || isNaN(ceilingVal)) {
- if (values[0] >= value) {
- return values[0];
- }
- var last = values[values.length - 1];
- if (last <= value) {
- return last;
- }
- }
- if (Math.abs(value - floorVal) < Math.abs(ceilingVal - value)) {
- return floorVal;
- }
- return ceilingVal;
- },
- /**
- * 获取逼近的最小值,用于对齐数据
- * @param {Array} values 数据集合
- * @param {Number} value 数值
- * @return {Number} 逼近的最小值
- */
- snapFloor: function snapFloor(values, value) {
- // 这里假定values是升序排列
- return arrayFloor(values, value);
- },
- /**
- * 获取逼近的最大值,用于对齐数据
- * @param {Array} values 数据集合
- * @param {Number} value 数值
- * @return {Number} 逼近的最大值
- */
- snapCeiling: function snapCeiling(values, value) {
- // 这里假定values是升序排列
- return arrayCeiling(values, value);
- },
- fixedBase: function fixedBase(v, base) {
- var str = base.toString();
- var index = str.indexOf('.');
- if (index === -1) {
- return Math.round(v);
- }
- var length = str.substr(index + 1).length;
- if (length > 20) {
- length = 20;
- }
- return parseFloat(v.toFixed(length));
- }
- };
- module.exports = Util;
- /***/ }),
- /* 64 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Base = __webpack_require__(14);
- var isNumber = __webpack_require__(13);
- var Identity =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Identity, _Base);
- function Identity() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Identity.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Base.prototype._initDefaultCfg.call(this);
- this.isIdentity = true;
- this.type = 'identity';
- /**
- * 常量值
- * @type {*}
- */
- this.value = null;
- };
- /**
- * @override
- */
- _proto.getText = function getText() {
- return this.value.toString();
- };
- /**
- * @override
- */
- _proto.scale = function scale(value) {
- if (this.value !== value && isNumber(value)) {
- return value;
- }
- return this.range[0];
- };
- /**
- * @override
- */
- _proto.invert = function invert() {
- return this.value;
- };
- return Identity;
- }(Base);
- Base.Identity = Identity;
- module.exports = Identity;
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Axis = __webpack_require__(66);
- var Global = __webpack_require__(1);
- var _require = __webpack_require__(5),
- Shape = _require.Shape;
- function formatTicks(ticks) {
- var tmp = ticks.slice(0);
- if (tmp.length > 0) {
- var first = tmp[0];
- var last = tmp[tmp.length - 1];
- if (first.value !== 0) {
- tmp.unshift({
- value: 0
- });
- }
- if (last.value !== 1) {
- tmp.push({
- value: 1
- });
- }
- }
- return tmp;
- }
- var AxisController =
- /*#__PURE__*/
- function () {
- function AxisController(cfg) {
- this.axisCfg = {};
- this.frontPlot = null;
- this.backPlot = null;
- this.axes = {}; // store the axes's options
- Util.mix(this, cfg);
- }
- var _proto = AxisController.prototype;
- _proto._isHide = function _isHide(field) {
- var axisCfg = this.axisCfg;
- return !axisCfg || axisCfg[field] === false;
- };
- _proto._getLinePosition = function _getLinePosition(scale, dimType, index, transposed) {
- var position = '';
- var field = scale.field;
- var axisCfg = this.axisCfg;
- if (axisCfg[field] && axisCfg[field].position) {
- position = axisCfg[field].position;
- } else if (dimType === 'x') {
- position = transposed ? 'left' : 'bottom';
- } else if (dimType === 'y') {
- position = index ? 'right' : 'left';
- if (transposed) {
- position = 'bottom';
- }
- }
- return position;
- };
- _proto._getLineCfg = function _getLineCfg(coord, dimType, position) {
- var start;
- var end;
- var factor = 1; // Mark clockwise or counterclockwise
- if (dimType === 'x') {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 1,
- y: 0
- };
- } else {
- if (position === 'right') {
- // there will be several y axes
- start = {
- x: 1,
- y: 0
- };
- end = {
- x: 1,
- y: 1
- };
- } else {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 0,
- y: 1
- };
- factor = -1;
- }
- }
- if (coord.transposed) {
- factor *= -1;
- }
- return {
- offsetFactor: factor,
- start: coord.convertPoint(start),
- end: coord.convertPoint(end)
- };
- };
- _proto._getCircleCfg = function _getCircleCfg(coord) {
- return {
- startAngle: coord.startAngle,
- endAngle: coord.endAngle,
- center: coord.center,
- radius: coord.circleRadius
- };
- };
- _proto._getRadiusCfg = function _getRadiusCfg(coord) {
- var transposed = coord.transposed;
- var start;
- var end;
- if (transposed) {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 1,
- y: 0
- };
- } else {
- start = {
- x: 0,
- y: 0
- };
- end = {
- x: 0,
- y: 1
- };
- }
- return {
- offsetFactor: -1,
- start: coord.convertPoint(start),
- end: coord.convertPoint(end)
- };
- };
- _proto._getAxisCfg = function _getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg) {
- var self = this;
- var axisCfg = this.axisCfg;
- var ticks = scale.getTicks();
- var cfg = Util.deepMix({
- ticks: ticks,
- frontContainer: this.frontPlot,
- backContainer: this.backPlot
- }, defaultCfg, axisCfg[scale.field]);
- var labels = [];
- var label = cfg.label;
- var count = ticks.length;
- var maxWidth = 0;
- var maxHeight = 0;
- var labelCfg = label;
- Util.each(ticks, function (tick, index) {
- if (Util.isFunction(label)) {
- var executedLabel = label(tick.text, index, count);
- labelCfg = executedLabel ? Util.mix({}, Global._defaultAxis.label, executedLabel) : null;
- }
- if (labelCfg) {
- var textStyle = {};
- if (labelCfg.textAlign) {
- textStyle.textAlign = labelCfg.textAlign;
- }
- if (labelCfg.textBaseline) {
- textStyle.textBaseline = labelCfg.textBaseline;
- }
- var axisLabel = new Shape.Text({
- className: 'axis-label',
- attrs: Util.mix({
- x: 0,
- y: 0,
- text: tick.text,
- fontFamily: self.chart.get('canvas').get('fontFamily')
- }, labelCfg),
- value: tick.value,
- textStyle: textStyle,
- top: labelCfg.top,
- context: self.chart.get('canvas').get('context')
- });
- labels.push(axisLabel);
- var _axisLabel$getBBox = axisLabel.getBBox(),
- width = _axisLabel$getBBox.width,
- height = _axisLabel$getBBox.height;
- maxWidth = Math.max(maxWidth, width);
- maxHeight = Math.max(maxHeight, height);
- }
- });
- cfg.labels = labels;
- cfg.maxWidth = maxWidth;
- cfg.maxHeight = maxHeight;
- return cfg;
- };
- _proto._createAxis = function _createAxis(coord, scale, verticalScale, dimType, index) {
- if (index === void 0) {
- index = '';
- }
- var self = this;
- var coordType = coord.type;
- var transposed = coord.transposed;
- var type;
- var key;
- var defaultCfg;
- if (coordType === 'cartesian' || coordType === 'rect') {
- var position = self._getLinePosition(scale, dimType, index, transposed);
- defaultCfg = Global.axis[position];
- defaultCfg.position = position;
- type = 'Line';
- key = position;
- } else {
- if (dimType === 'x' && !transposed || dimType === 'y' && transposed) {
- defaultCfg = Global.axis.circle;
- type = 'Circle';
- key = 'circle';
- } else {
- defaultCfg = Global.axis.radius;
- type = 'Line';
- key = 'radius';
- }
- }
- var cfg = self._getAxisCfg(coord, scale, verticalScale, dimType, defaultCfg);
- cfg.type = type;
- cfg.dimType = dimType;
- cfg.verticalScale = verticalScale;
- cfg.index = index;
- this.axes[key] = cfg;
- };
- _proto.createAxis = function createAxis(coord, xScale, yScales) {
- var self = this;
- if (xScale && !self._isHide(xScale.field)) {
- self._createAxis(coord, xScale, yScales[0], 'x');
- }
- Util.each(yScales, function (yScale, index) {
- if (!self._isHide(yScale.field)) {
- self._createAxis(coord, yScale, xScale, 'y', index);
- }
- });
- var axes = this.axes;
- var chart = self.chart;
- if (chart._isAutoPadding()) {
- var userPadding = Util.parsePadding(chart.get('padding'));
- var appendPadding = Util.parsePadding(chart.get('appendPadding'));
- var legendRange = chart.get('legendRange') || {
- top: 0,
- right: 0,
- bottom: 0,
- left: 0
- };
- 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]];
- if (coord.isPolar) {
- var circleAxis = axes.circle;
- if (circleAxis) {
- var maxHeight = circleAxis.maxHeight,
- maxWidth = circleAxis.maxWidth,
- labelOffset = circleAxis.labelOffset;
- padding[0] += maxHeight + labelOffset;
- padding[1] += maxWidth + labelOffset;
- padding[2] += maxHeight + labelOffset;
- padding[3] += maxWidth + labelOffset;
- }
- } else {
- if (axes.right && userPadding[1] === 'auto') {
- var _axes$right = axes.right,
- _maxWidth = _axes$right.maxWidth,
- _labelOffset = _axes$right.labelOffset;
- padding[1] += _maxWidth + _labelOffset;
- }
- if (axes.left && userPadding[3] === 'auto') {
- var _axes$left = axes.left,
- _maxWidth2 = _axes$left.maxWidth,
- _labelOffset2 = _axes$left.labelOffset;
- padding[3] += _maxWidth2 + _labelOffset2;
- }
- if (axes.bottom && userPadding[2] === 'auto') {
- var _axes$bottom = axes.bottom,
- _maxHeight = _axes$bottom.maxHeight,
- _labelOffset3 = _axes$bottom.labelOffset;
- padding[2] += _maxHeight + _labelOffset3;
- }
- }
- chart.set('_padding', padding);
- chart._updateLayout(padding);
- }
- Util.each(axes, function (axis) {
- var type = axis.type,
- grid = axis.grid,
- verticalScale = axis.verticalScale,
- ticks = axis.ticks,
- dimType = axis.dimType,
- position = axis.position,
- index = axis.index;
- var appendCfg;
- if (coord.isPolar) {
- if (type === 'Line') {
- appendCfg = self._getRadiusCfg(coord);
- } else if (type === 'Circle') {
- appendCfg = self._getCircleCfg(coord);
- }
- } else {
- appendCfg = self._getLineCfg(coord, dimType, position);
- }
- if (grid && verticalScale) {
- var gridPoints = [];
- var verticalTicks = formatTicks(verticalScale.getTicks());
- Util.each(ticks, function (tick) {
- var subPoints = [];
- Util.each(verticalTicks, function (verticalTick) {
- var x = dimType === 'x' ? tick.value : verticalTick.value;
- var y = dimType === 'x' ? verticalTick.value : tick.value;
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1) {
- var point = coord.convertPoint({
- x: x,
- y: y
- });
- subPoints.push(point);
- }
- });
- gridPoints.push({
- points: subPoints,
- _id: 'axis-' + dimType + index + '-grid-' + tick.tickValue
- });
- });
- axis.gridPoints = gridPoints;
- if (coord.isPolar) {
- axis.center = coord.center;
- axis.startAngle = coord.startAngle;
- axis.endAngle = coord.endAngle;
- }
- }
- appendCfg._id = 'axis-' + dimType;
- if (!Util.isNil(index)) {
- appendCfg._id = 'axis-' + dimType + index;
- }
- new Axis[type](Util.mix(axis, appendCfg));
- });
- };
- _proto.clear = function clear() {
- this.axes = {};
- this.frontPlot.clear();
- this.backPlot.clear();
- };
- return AxisController;
- }();
- module.exports = AxisController;
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
- var Abstract = __webpack_require__(24);
- __webpack_require__(67);
- module.exports = Abstract;
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Abstract = __webpack_require__(24);
- var Line =
- /*#__PURE__*/
- function (_Abstract) {
- _inheritsLoose(Line, _Abstract);
- function Line() {
- return _Abstract.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Abstract.prototype._initDefaultCfg.call(this);
- this.start = null;
- this.end = null;
- };
- _proto.getOffsetPoint = function getOffsetPoint(value) {
- var start = this.start,
- end = this.end;
- return {
- x: start.x + (end.x - start.x) * value,
- y: start.y + (end.y - start.y) * value
- };
- };
- _proto.getAxisVector = function getAxisVector() {
- var start = this.start,
- end = this.end;
- return [end.x - start.x, end.y - start.y];
- };
- _proto.drawLine = function drawLine(lineCfg) {
- var container = this.getContainer(lineCfg.top);
- var start = this.start,
- end = this.end;
- container.addShape('line', {
- className: 'axis-line',
- attrs: Util.mix({
- x1: start.x,
- y1: start.y,
- x2: end.x,
- y2: end.y
- }, lineCfg)
- });
- };
- return Line;
- }(Abstract);
- Abstract.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 68 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Container = __webpack_require__(30);
- var Group = __webpack_require__(31);
- var _require = __webpack_require__(36),
- requestAnimationFrame = _require.requestAnimationFrame;
- var Canvas =
- /*#__PURE__*/
- function () {
- var _proto = Canvas.prototype;
- _proto.get = function get(name) {
- return this._attrs[name];
- };
- _proto.set = function set(name, value) {
- this._attrs[name] = value;
- };
- function Canvas(cfg) {
- this._attrs = Util.mix({
- type: 'canvas',
- children: []
- }, cfg);
- this._initPixelRatio();
- this._initCanvas();
- }
- _proto._initPixelRatio = function _initPixelRatio() {
- var pixelRatio = this.get('pixelRatio');
- if (!pixelRatio) {
- this.set('pixelRatio', Util.getPixelRatio());
- }
- };
- _proto.beforeDraw = function beforeDraw() {
- var context = this._attrs.context;
- var el = this._attrs.el;
- !Util.isWx && !Util.isMy && context && context.clearRect(0, 0, el.width, el.height);
- };
- _proto._initCanvas = function _initCanvas() {
- var self = this;
- var el = self.get('el');
- var context = self.get('context');
- var canvas;
- if (context) {
- // CanvasRenderingContext2D
- canvas = context.canvas;
- } else if (Util.isString(el)) {
- // HTMLElement's id
- canvas = Util.getDomById(el);
- } else {
- // HTMLElement
- canvas = el;
- }
- if (!canvas) {
- throw new Error('Please specify the id or el of the chart!');
- }
- if (context && canvas && !canvas.getContext) {
- canvas.getContext = function () {
- return context;
- };
- }
- var width = self.get('width');
- if (!width) {
- width = Util.getWidth(canvas);
- }
- var height = self.get('height');
- if (!height) {
- height = Util.getHeight(canvas);
- }
- self.set('canvas', this);
- self.set('el', canvas);
- self.set('context', context || canvas.getContext('2d'));
- self.changeSize(width, height);
- };
- _proto.changeSize = function changeSize(width, height) {
- var pixelRatio = this.get('pixelRatio');
- var canvasDOM = this.get('el');
- if (Util.isBrowser) {
- canvasDOM.style.width = width + 'px';
- canvasDOM.style.height = height + 'px';
- }
- if (!Util.isWx && !Util.isMy) {
- canvasDOM.width = width * pixelRatio;
- canvasDOM.height = height * pixelRatio;
- if (pixelRatio !== 1) {
- var ctx = this.get('context');
- ctx.scale(pixelRatio, pixelRatio);
- }
- }
- this.set('width', width);
- this.set('height', height);
- };
- _proto.getWidth = function getWidth() {
- var pixelRatio = this.get('pixelRatio');
- var width = this.get('width');
- return width * pixelRatio;
- };
- _proto.getHeight = function getHeight() {
- var pixelRatio = this.get('pixelRatio');
- var height = this.get('height');
- return height * pixelRatio;
- };
- _proto.getPointByClient = function getPointByClient(clientX, clientY) {
- var el = this.get('el');
- var bbox = el.getBoundingClientRect();
- var width = bbox.right - bbox.left;
- var height = bbox.bottom - bbox.top;
- return {
- x: (clientX - bbox.left) * (el.width / width),
- y: (clientY - bbox.top) * (el.height / height)
- };
- };
- _proto._beginDraw = function _beginDraw() {
- this._attrs.toDraw = true;
- };
- _proto._endDraw = function _endDraw() {
- this._attrs.toDraw = false;
- };
- _proto.draw = function draw() {
- var self = this;
- function drawInner() {
- self.set('animateHandler', requestAnimationFrame(function () {
- self.set('animateHandler', undefined);
- if (self.get('toDraw')) {
- drawInner();
- }
- }));
- self.beforeDraw();
- try {
- var context = self._attrs.context;
- var children = self._attrs.children;
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- child.draw(context);
- }
- if (Util.isWx || Util.isMy) {
- context.draw();
- }
- } catch (ev) {
- console.warn('error in draw canvas, detail as:');
- console.warn(ev);
- self._endDraw();
- }
- self._endDraw();
- }
- if (self.get('destroyed')) {
- return;
- }
- if (self.get('animateHandler')) {
- this._beginDraw();
- } else {
- drawInner();
- }
- };
- _proto.destroy = function destroy() {
- if (this.get('destroyed')) {
- return;
- }
- this.clear();
- this._attrs = {};
- this.set('destroyed', true);
- };
- _proto.isDestroyed = function isDestroyed() {
- return this.get('destroyed');
- };
- return Canvas;
- }();
- Util.mix(Canvas.prototype, Container, {
- getGroupClass: function getGroupClass() {
- return Group;
- }
- });
- module.exports = Canvas;
- /***/ }),
- /* 69 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- function _mod(n, m) {
- return (n % m + m) % m;
- }
- function _addStop(steps, gradient) {
- Util.each(steps, function (item) {
- item = item.split(':');
- gradient.addColorStop(Number(item[0]), item[1]);
- });
- } // the string format: 'l(0) 0:#ffffff 0.5:#7ec2f3 1:#1890ff'
- function _parseLineGradient(color, shape, context) {
- var arr = color.split(' ');
- var angle = arr[0].slice(2, arr[0].length - 1);
- angle = _mod(parseFloat(angle) * Math.PI / 180, Math.PI * 2);
- var steps = arr.slice(1);
- var _shape$getBBox = shape.getBBox(),
- minX = _shape$getBBox.minX,
- minY = _shape$getBBox.minY,
- maxX = _shape$getBBox.maxX,
- maxY = _shape$getBBox.maxY;
- var start;
- var end;
- if (angle >= 0 && angle < 0.5 * Math.PI) {
- start = {
- x: minX,
- y: minY
- };
- end = {
- x: maxX,
- y: maxY
- };
- } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
- start = {
- x: maxX,
- y: minY
- };
- end = {
- x: minX,
- y: maxY
- };
- } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
- start = {
- x: maxX,
- y: maxY
- };
- end = {
- x: minX,
- y: minY
- };
- } else {
- start = {
- x: minX,
- y: maxY
- };
- end = {
- x: maxX,
- y: minY
- };
- }
- var tanTheta = Math.tan(angle);
- var tanTheta2 = tanTheta * tanTheta;
- var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
- var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
- var gradient = context.createLinearGradient(start.x, start.y, x, y);
- _addStop(steps, gradient);
- return gradient;
- } // the string format: 'r(0.5, 0.5, 0.1) 0:#ffffff 1:#1890ff'
- function _parseRadialGradient(color, shape, context) {
- var arr = color.split(' ');
- var circleCfg = arr[0].slice(2, arr[0].length - 1);
- circleCfg = circleCfg.split(',');
- var fx = parseFloat(circleCfg[0]);
- var fy = parseFloat(circleCfg[1]);
- var fr = parseFloat(circleCfg[2]);
- var steps = arr.slice(1); // if radius is 0, no gradient, stroke with the last color
- if (fr === 0) {
- var _color = steps[steps.length - 1];
- return _color.split(':')[1];
- }
- var _shape$getBBox2 = shape.getBBox(),
- width = _shape$getBBox2.width,
- height = _shape$getBBox2.height,
- minX = _shape$getBBox2.minX,
- minY = _shape$getBBox2.minY;
- var r = Math.sqrt(width * width + height * height) / 2;
- var gradient = context.createRadialGradient(minX + width * fx, minY + height * fy, fr * r, minX + width / 2, minY + height / 2, r);
- _addStop(steps, gradient);
- return gradient;
- }
- module.exports = {
- parseStyle: function parseStyle(color, shape, context) {
- if (color[1] === '(') {
- try {
- var firstCode = color[0];
- if (firstCode === 'l') {
- return _parseLineGradient(color, shape, context);
- } else if (firstCode === 'r') {
- return _parseRadialGradient(color, shape, context);
- }
- } catch (ev) {
- console.error('error in parsing gradient string, please check if there are any extra whitespaces.');
- console.error(ev);
- }
- }
- return color;
- }
- };
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(2);
- var Rect =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Rect, _Shape);
- function Rect() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Rect.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'rect';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- width: 0,
- height: 0,
- radius: 0,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- width = attrs.width,
- height = attrs.height;
- context.beginPath();
- var radius = attrs.radius;
- if (!radius || !(width * height)) {
- context.rect(x, y, width, height);
- } else {
- radius = Util.parsePadding(radius);
- context.moveTo(x + radius[0], y);
- context.lineTo(x + width - radius[1], y);
- context.arc(x + width - radius[1], y + radius[1], radius[1], -Math.PI / 2, 0, false);
- context.lineTo(x + width, y + height - radius[2]);
- context.arc(x + width - radius[2], y + height - radius[2], radius[2], 0, Math.PI / 2, false);
- context.lineTo(x + radius[3], y + height);
- context.arc(x + radius[3], y + height - radius[3], radius[3], Math.PI / 2, Math.PI, false);
- context.lineTo(x, y + radius[0]);
- context.arc(x + radius[0], y + radius[0], radius[0], Math.PI, Math.PI * 3 / 2, false);
- context.closePath();
- }
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- width = attrs.width,
- height = attrs.height;
- return {
- minX: x,
- minY: y,
- maxX: x + width,
- maxY: y + height
- };
- };
- return Rect;
- }(Shape);
- Shape.Rect = Rect;
- module.exports = Rect;
- /***/ }),
- /* 71 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var Circle =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Circle, _Shape);
- function Circle() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Circle.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'circle';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- r: 0,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r;
- context.beginPath();
- context.arc(x, y, r, 0, Math.PI * 2, false);
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r;
- return {
- minX: x - r,
- maxX: x + r,
- minY: y - r,
- maxY: y + r
- };
- };
- return Circle;
- }(Shape);
- Shape.Circle = Circle;
- module.exports = Circle;
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var bbox = __webpack_require__(11);
- var Line =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Line, _Shape);
- function Line() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canStroke = true;
- this._attrs.type = 'line';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x1: 0,
- y1: 0,
- x2: 0,
- y2: 0,
- lineWidth: 1
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x1 = attrs.x1,
- y1 = attrs.y1,
- x2 = attrs.x2,
- y2 = attrs.y2;
- context.beginPath();
- context.moveTo(x1, y1);
- context.lineTo(x2, y2);
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x1 = attrs.x1,
- y1 = attrs.y1,
- x2 = attrs.x2,
- y2 = attrs.y2,
- lineWidth = attrs.lineWidth;
- return bbox.getBBoxFromLine(x1, y1, x2, y2, lineWidth);
- };
- return Line;
- }(Shape);
- Shape.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var bbox = __webpack_require__(11);
- var Polygon =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Polygon, _Shape);
- function Polygon() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Polygon.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'polygon';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- points: null,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var points = attrs.points;
- context.beginPath();
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (i === 0) {
- context.moveTo(point.x, point.y);
- } else {
- context.lineTo(point.x, point.y);
- }
- }
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var points = attrs.points;
- return bbox.getBBoxFromPoints(points);
- };
- return Polygon;
- }(Shape);
- Shape.Polygon = Polygon;
- module.exports = Polygon;
- /***/ }),
- /* 74 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var Smooth = __webpack_require__(37);
- var bbox = __webpack_require__(11);
- var Polyline =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Polyline, _Shape);
- function Polyline() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Polyline.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'polyline';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- points: null,
- lineWidth: 1,
- smooth: false
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var points = attrs.points,
- smooth = attrs.smooth;
- var filteredPoints = []; // filter the point which x or y is NaN
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (!isNaN(point.x) && !isNaN(point.y)) {
- filteredPoints.push(point);
- }
- }
- context.beginPath();
- if (filteredPoints.length) {
- context.moveTo(filteredPoints[0].x, filteredPoints[0].y);
- if (smooth) {
- var constaint = [[0, 0], [1, 1]];
- var sps = Smooth.smooth(filteredPoints, false, constaint);
- for (var _i = 0, n = sps.length; _i < n; _i++) {
- var sp = sps[_i];
- context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
- }
- } else {
- var _i2;
- var l;
- for (_i2 = 1, l = filteredPoints.length - 1; _i2 < l; _i2++) {
- context.lineTo(filteredPoints[_i2].x, filteredPoints[_i2].y);
- }
- context.lineTo(filteredPoints[l].x, filteredPoints[l].y);
- }
- }
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var points = attrs.points,
- smooth = attrs.smooth,
- lineWidth = attrs.lineWidth;
- if (smooth) {
- var newPoints = [];
- var constaint = [[0, 0], [1, 1]];
- var sps = Smooth.smooth(points, false, constaint);
- for (var i = 0, n = sps.length; i < n; i++) {
- var sp = sps[i];
- if (i === 0) {
- newPoints.push([points[0].x, points[0].y, sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
- } else {
- var lastPoint = sps[i - 1];
- newPoints.push([lastPoint[5], lastPoint[6], sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]]);
- }
- }
- return bbox.getBBoxFromBezierGroup(newPoints, lineWidth);
- }
- return bbox.getBBoxFromPoints(points, lineWidth);
- };
- return Polyline;
- }(Shape);
- Shape.Polyline = Polyline;
- module.exports = Polyline;
- /***/ }),
- /* 75 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var bbox = __webpack_require__(11);
- var Arc =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Arc, _Shape);
- function Arc() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Arc.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canStroke = true;
- this._attrs.canFill = true;
- this._attrs.type = 'arc';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- r: 0,
- startAngle: 0,
- endAngle: Math.PI * 2,
- clockwise: false,
- lineWidth: 1
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- clockwise = attrs.clockwise;
- context.beginPath();
- context.arc(x, y, r, startAngle, endAngle, clockwise);
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- clockwise = attrs.clockwise;
- return bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
- };
- return Arc;
- }(Shape);
- Shape.Arc = Arc;
- module.exports = Arc;
- /***/ }),
- /* 76 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var bbox = __webpack_require__(11);
- var Sector =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Sector, _Shape);
- function Sector() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Sector.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'sector';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- lineWidth: 0,
- r: 0,
- r0: 0,
- startAngle: 0,
- endAngle: Math.PI * 2,
- clockwise: false
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- r = attrs.r,
- r0 = attrs.r0,
- clockwise = attrs.clockwise;
- context.beginPath();
- var unitX = Math.cos(startAngle);
- var unitY = Math.sin(startAngle);
- context.moveTo(unitX * r0 + x, unitY * r0 + y);
- context.lineTo(unitX * r + x, unitY * r + y);
- context.arc(x, y, r, startAngle, endAngle, clockwise);
- context.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
- if (r0 !== 0) {
- context.arc(x, y, r0, endAngle, startAngle, !clockwise);
- }
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- r = attrs.r,
- r0 = attrs.r0,
- startAngle = attrs.startAngle,
- endAngle = attrs.endAngle,
- clockwise = attrs.clockwise;
- var outerBBox = bbox.getBBoxFromArc(x, y, r, startAngle, endAngle, clockwise);
- var innerBBox = bbox.getBBoxFromArc(x, y, r0, startAngle, endAngle, clockwise);
- return {
- minX: Math.min(outerBBox.minX, innerBBox.minX),
- minY: Math.min(outerBBox.minY, innerBBox.minY),
- maxX: Math.max(outerBBox.maxX, innerBBox.maxX),
- maxY: Math.max(outerBBox.maxY, innerBBox.maxY)
- };
- };
- return Sector;
- }(Shape);
- Shape.Sector = Sector;
- module.exports = Sector;
- /***/ }),
- /* 77 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(2);
- var textWidthCacheCounter = 0;
- var textWidthCache = {};
- var TEXT_CACHE_MAX = 5000;
- var Text =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Text, _Shape);
- function Text() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Text.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'text';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- lineWidth: 0,
- lineCount: 1,
- fontSize: 12,
- fontFamily: 'sans-serif',
- fontStyle: 'normal',
- fontWeight: 'normal',
- fontVariant: 'normal',
- textAlign: 'start',
- textBaseline: 'bottom',
- lineHeight: null,
- textArr: null
- };
- };
- _proto._getFontStyle = function _getFontStyle() {
- var attrs = this._attrs.attrs;
- var fontSize = attrs.fontSize,
- fontFamily = attrs.fontFamily,
- fontWeight = attrs.fontWeight,
- fontStyle = attrs.fontStyle,
- fontVariant = attrs.fontVariant;
- return fontStyle + " " + fontVariant + " " + fontWeight + " " + fontSize + "px " + fontFamily;
- };
- _proto._afterAttrsSet = function _afterAttrsSet() {
- var attrs = this._attrs.attrs;
- attrs.font = this._getFontStyle();
- if (attrs.text) {
- var text = attrs.text;
- var textArr = null;
- var lineCount = 1;
- if (Util.isString(text) && text.indexOf('\n') !== -1) {
- textArr = text.split('\n');
- lineCount = textArr.length;
- }
- attrs.lineCount = lineCount;
- attrs.textArr = textArr;
- }
- this.set('attrs', attrs);
- };
- _proto._getTextHeight = function _getTextHeight() {
- var attrs = this._attrs.attrs;
- if (attrs.height) {
- return attrs.height;
- }
- var lineCount = attrs.lineCount;
- var fontSize = attrs.fontSize * 1;
- if (lineCount > 1) {
- var spaceingY = this._getSpaceingY();
- return fontSize * lineCount + spaceingY * (lineCount - 1);
- }
- return fontSize;
- };
- _proto._getSpaceingY = function _getSpaceingY() {
- var attrs = this._attrs.attrs;
- var lineHeight = attrs.lineHeight;
- var fontSize = attrs.fontSize * 1;
- return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
- };
- _proto.drawInner = function drawInner(context) {
- var self = this;
- var attrs = self._attrs.attrs;
- var text = attrs.text;
- var x = attrs.x;
- var y = attrs.y;
- if (Util.isNil(text) || isNaN(x) || isNaN(y)) {
- // text will be 0
- return;
- }
- var textArr = attrs.textArr;
- var fontSize = attrs.fontSize * 1;
- var spaceingY = self._getSpaceingY();
- if (attrs.rotate) {
- // do rotation
- context.translate(x, y);
- context.rotate(attrs.rotate);
- x = 0;
- y = 0;
- }
- var textBaseline = attrs.textBaseline;
- var height;
- if (textArr) {
- height = self._getTextHeight();
- }
- var subY; // context.beginPath();
- if (self.hasFill()) {
- var fillOpacity = attrs.fillOpacity;
- if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
- context.globalAlpha = fillOpacity;
- }
- if (textArr) {
- for (var i = 0, len = textArr.length; i < len; i++) {
- var subText = textArr[i];
- subY = y + i * (spaceingY + fontSize) - height + fontSize; // bottom;
- if (textBaseline === 'middle') {
- subY += height - fontSize - (height - fontSize) / 2;
- }
- if (textBaseline === 'top') {
- subY += height - fontSize;
- }
- context.fillText(subText, x, subY);
- }
- } else {
- context.fillText(text, x, y);
- }
- }
- if (self.hasStroke()) {
- if (textArr) {
- for (var _i = 0, _len = textArr.length; _i < _len; _i++) {
- var _subText = textArr[_i];
- subY = y + _i * (spaceingY + fontSize) - height + fontSize; // bottom;
- if (textBaseline === 'middle') {
- subY += height - fontSize - (height - fontSize) / 2;
- }
- if (textBaseline === 'top') {
- subY += height - fontSize;
- }
- context.strokeText(_subText, x, subY);
- }
- } else {
- context.strokeText(text, x, y);
- }
- }
- };
- _proto.calculateBox = function calculateBox() {
- var self = this;
- var attrs = self._attrs.attrs;
- var x = attrs.x,
- y = attrs.y,
- textAlign = attrs.textAlign,
- textBaseline = attrs.textBaseline;
- var width = self._getTextWidth(); // attrs.width
- if (!width) {
- return {
- minX: x,
- minY: y,
- maxX: x,
- maxY: y
- };
- }
- var height = self._getTextHeight(); // attrs.height
- var point = {
- x: x,
- y: y - height
- }; // default textAlign: start, textBaseline: bottom
- if (textAlign) {
- if (textAlign === 'end' || textAlign === 'right') {
- point.x -= width;
- } else if (textAlign === 'center') {
- point.x -= width / 2;
- }
- }
- if (textBaseline) {
- if (textBaseline === 'top') {
- point.y += height;
- } else if (textBaseline === 'middle') {
- point.y += height / 2;
- }
- }
- return {
- minX: point.x,
- minY: point.y,
- maxX: point.x + width,
- maxY: point.y + height
- };
- };
- _proto._getTextWidth = function _getTextWidth() {
- var attrs = this._attrs.attrs;
- if (attrs.width) {
- return attrs.width;
- }
- var text = attrs.text;
- var context = this.get('context');
- if (Util.isNil(text)) return undefined;
- var font = attrs.font;
- var textArr = attrs.textArr;
- var key = text + '' + font;
- if (textWidthCache[key]) {
- return textWidthCache[key];
- }
- var width = 0;
- if (textArr) {
- for (var i = 0, length = textArr.length; i < length; i++) {
- var subText = textArr[i];
- width = Math.max(width, Util.measureText(subText, font, context).width);
- }
- } else {
- width = Util.measureText(text, font, context).width;
- }
- if (textWidthCacheCounter > TEXT_CACHE_MAX) {
- textWidthCacheCounter = 0;
- textWidthCache = {};
- }
- textWidthCacheCounter++;
- textWidthCache[key] = width;
- return width;
- };
- return Text;
- }(Shape);
- Shape.Text = Text;
- module.exports = Text;
- /***/ }),
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = __webpack_require__(2);
- var Custom =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Custom, _Shape);
- function Custom() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Custom.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.createPath = null;
- this._attrs.type = 'custom';
- };
- _proto.createPath = function createPath(context) {
- var createPath = this.get('createPath');
- createPath && createPath.call(this, context);
- };
- _proto.calculateBox = function calculateBox() {
- var calculateBox = this.get('calculateBox');
- return calculateBox && calculateBox.call(this);
- };
- return Custom;
- }(Shape);
- Shape.Custom = Custom;
- module.exports = Custom;
- /***/ }),
- /* 79 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview track f2
- * @author sima.zhang1990@gmail.com
- */
- var Global = __webpack_require__(1);
- var Util = __webpack_require__(0);
- var SERVER_URL = 'https://kcart.alipay.com/web/bi.do';
- setTimeout(function () {
- if (Global.trackable && Util.isBrowser) {
- // Only works for H5 env
- var image = new Image();
- var newObj = {
- pg: document.URL,
- r: new Date().getTime(),
- f2: true,
- version: Global.version,
- page_type: 'syslog'
- };
- var d = encodeURIComponent(JSON.stringify([newObj]));
- image.src = SERVER_URL + "?BIProfile=merge&d=" + d;
- }
- }, 3000);
- /***/ }),
- /* 80 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Path = __webpack_require__(38);
- var Geom = __webpack_require__(6);
- __webpack_require__(32);
- var Line =
- /*#__PURE__*/
- function (_Path) {
- _inheritsLoose(Line, _Path);
- function Line() {
- return _Path.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Path.prototype.getDefaultCfg.call(this);
- cfg.type = 'line';
- cfg.sortable = true;
- return cfg;
- };
- return Line;
- }(Path);
- Geom.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 81 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- var Geom = __webpack_require__(6);
- var Util = __webpack_require__(0);
- var SizeMixin = __webpack_require__(39);
- __webpack_require__(82);
- var Interval =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Interval, _Geom);
- var _proto = Interval.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'interval';
- cfg.shapeType = 'interval';
- cfg.generatePoints = true;
- return cfg;
- };
- function Interval(cfg) {
- var _this;
- _this = _Geom.call(this, cfg) || this;
- Util.mix(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
- return _this;
- }
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- cfg.size = this.getNormalizedSize(obj);
- return cfg;
- };
- _proto.clearInner = function clearInner() {
- _Geom.prototype.clearInner.call(this);
- this.set('defaultSize', null);
- };
- return Interval;
- }(Geom);
- Geom.Interval = Interval;
- module.exports = Interval;
- /***/ }),
- /* 82 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(9);
- var Vector2 = __webpack_require__(4);
- var Global = __webpack_require__(1);
- function getRectPoints(cfg) {
- var x = cfg.x,
- y = cfg.y,
- y0 = cfg.y0,
- size = cfg.size;
- var ymin = y0;
- var ymax = y;
- if (Util.isArray(y)) {
- ymax = y[1];
- ymin = y[0];
- }
- var xmin;
- var xmax;
- if (Util.isArray(x)) {
- xmin = x[0];
- xmax = x[1];
- } else {
- xmin = x - size / 2;
- xmax = x + size / 2;
- }
- return [{
- x: xmin,
- y: ymin
- }, {
- x: xmin,
- y: ymax
- }, {
- x: xmax,
- y: ymax
- }, {
- x: xmax,
- y: ymin
- }];
- }
- function getRectRange(points) {
- var xValues = [];
- var yValues = [];
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- xValues.push(point.x);
- yValues.push(point.y);
- }
- var xMin = Math.min.apply(null, xValues);
- var yMin = Math.min.apply(null, yValues);
- var xMax = Math.max.apply(null, xValues);
- var yMax = Math.max.apply(null, yValues);
- return {
- x: xMin,
- y: yMin,
- width: xMax - xMin,
- height: yMax - yMin
- };
- }
- var Interval = Shape.registerFactory('interval', {
- defaultShapeType: 'rect',
- getDefaultPoints: function getDefaultPoints(cfg) {
- return getRectPoints(cfg);
- }
- });
- Shape.registerShape('interval', 'rect', {
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var style = Util.mix({
- fill: cfg.color
- }, Global.shape.interval, cfg.style);
- if (cfg.isInCircle) {
- var newPoints = points.slice(0);
- if (this._coord.transposed) {
- newPoints = [points[0], points[3], points[2], points[1]];
- }
- var _cfg$center = cfg.center,
- x = _cfg$center.x,
- y = _cfg$center.y;
- var v = [1, 0];
- var v0 = [newPoints[0].x - x, newPoints[0].y - y];
- var v1 = [newPoints[1].x - x, newPoints[1].y - y];
- var v2 = [newPoints[2].x - x, newPoints[2].y - y];
- var startAngle = Vector2.angleTo(v, v1);
- var endAngle = Vector2.angleTo(v, v2);
- var r0 = Vector2.length(v0);
- var r = Vector2.length(v1);
- if (startAngle >= 1.5 * Math.PI) {
- startAngle = startAngle - 2 * Math.PI;
- }
- if (endAngle >= 1.5 * Math.PI) {
- endAngle = endAngle - 2 * Math.PI;
- }
- return container.addShape('Sector', {
- className: 'interval',
- attrs: Util.mix({
- x: x,
- y: y,
- r: r,
- r0: r0,
- startAngle: startAngle,
- endAngle: endAngle
- }, style)
- });
- }
- var rectCfg = getRectRange(points);
- return container.addShape('rect', {
- className: 'interval',
- attrs: Util.mix(rectCfg, style)
- });
- }
- });
- module.exports = Interval;
- /***/ }),
- /* 83 */
- /***/ (function(module, exports, __webpack_require__) {
- module.exports = {
- Stack: __webpack_require__(84),
- Dodge: __webpack_require__(86)
- };
- /***/ }),
- /* 84 */
- /***/ (function(module, exports, __webpack_require__) {
- var Stack = __webpack_require__(85);
- module.exports = Stack;
- /***/ }),
- /* 85 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var isArray = __webpack_require__(10);
- var isNil = __webpack_require__(7);
- var Adjust = __webpack_require__(22);
- var Stack =
- /*#__PURE__*/
- function (_Adjust) {
- _inheritsLoose(Stack, _Adjust);
- function Stack() {
- return _Adjust.apply(this, arguments) || this;
- }
- var _proto = Stack.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.xField = null; // 调整对应的 x 方向对应的字段名称
- this.yField = null; // 调整对应的 y 方向对应的字段名称
- };
- _proto.processAdjust = function processAdjust(dataArray) {
- this.processStack(dataArray);
- };
- _proto.processStack = function processStack(dataArray) {
- var self = this;
- var xField = self.xField;
- var yField = self.yField;
- var count = dataArray.length;
- var stackCache = {
- positive: {},
- negative: {}
- }; // 层叠顺序翻转
- if (self.reverseOrder) {
- dataArray = dataArray.slice(0).reverse();
- }
- for (var i = 0; i < count; i++) {
- var data = dataArray[i];
- for (var j = 0, len = data.length; j < len; j++) {
- var item = data[j];
- var x = item[xField] || 0;
- var y = item[yField];
- var xkey = x.toString();
- y = isArray(y) ? y[1] : y;
- if (!isNil(y)) {
- var direction = y >= 0 ? 'positive' : 'negative';
- if (!stackCache[direction][xkey]) {
- stackCache[direction][xkey] = 0;
- }
- item[yField] = [stackCache[direction][xkey], y + stackCache[direction][xkey]];
- stackCache[direction][xkey] += y;
- }
- }
- }
- };
- return Stack;
- }(Adjust);
- Adjust.Stack = Stack;
- module.exports = Stack;
- /***/ }),
- /* 86 */
- /***/ (function(module, exports, __webpack_require__) {
- var Dodge = __webpack_require__(87);
- module.exports = Dodge;
- /***/ }),
- /* 87 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- var Adjust = __webpack_require__(22);
- var each = __webpack_require__(3);
- var MARGIN_RATIO = 1 / 2;
- var DODGE_RATIO = 1 / 2;
- var Dodge =
- /*#__PURE__*/
- function (_Adjust) {
- _inheritsLoose(Dodge, _Adjust);
- function Dodge() {
- return _Adjust.apply(this, arguments) || this;
- }
- var _proto = Dodge.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- /**
- * 调整过程中,2个数据的间距
- * @type {Number}
- */
- this.marginRatio = MARGIN_RATIO;
- /**
- * 调整占单位宽度的比例,例如:占2个分类间距的 1/2
- * @type {Number}
- */
- this.dodgeRatio = DODGE_RATIO;
- this.adjustNames = ['x', 'y']; // 调整的维度,默认,x,y都做调整
- };
- _proto.getDodgeOffset = function getDodgeOffset(range, index, count) {
- var self = this;
- var pre = range.pre;
- var next = range.next;
- var tickLength = next - pre;
- var width = tickLength * self.dodgeRatio / count;
- var margin = self.marginRatio * width;
- var offset = 1 / 2 * (tickLength - count * width - (count - 1) * margin) + ((index + 1) * width + index * margin) - 1 / 2 * width - 1 / 2 * tickLength;
- return (pre + next) / 2 + offset;
- };
- _proto.processAdjust = function processAdjust(dataArray) {
- var self = this;
- var count = dataArray.length;
- var xField = self.xField;
- each(dataArray, function (data, index) {
- for (var i = 0, len = data.length; i < len; i++) {
- var obj = data[i];
- var value = obj[xField];
- var range = {
- pre: value - 0.5,
- next: value + 0.5
- };
- var dodgeValue = self.getDodgeOffset(range, index, count);
- obj[xField] = dodgeValue;
- }
- });
- };
- return Dodge;
- }(Adjust);
- Adjust.Dodge = Dodge;
- module.exports = Dodge;
- /***/ }),
- /* 88 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Base = __webpack_require__(21);
- var Vector2 = __webpack_require__(4);
- var Matrix = __webpack_require__(23);
- var Polar =
- /*#__PURE__*/
- function (_Base) {
- _inheritsLoose(Polar, _Base);
- function Polar() {
- return _Base.apply(this, arguments) || this;
- }
- var _proto = Polar.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'polar';
- this.startAngle = -Math.PI / 2;
- this.endAngle = Math.PI * 3 / 2;
- this.inner = 0;
- this.innerRadius = 0; // alias
- this.isPolar = true;
- this.transposed = false;
- this.center = null;
- this.radius = null; // relative, 0 ~ 1
- };
- _proto.init = function init(start, end) {
- var self = this;
- var inner = self.inner || self.innerRadius;
- var width = Math.abs(end.x - start.x);
- var height = Math.abs(end.y - start.y);
- var maxRadius;
- var center;
- if (self.startAngle === -Math.PI && self.endAngle === 0) {
- maxRadius = Math.min(width / 2, height);
- center = {
- x: (start.x + end.x) / 2,
- y: start.y
- };
- } else {
- maxRadius = Math.min(width, height) / 2;
- center = {
- x: (start.x + end.x) / 2,
- y: (start.y + end.y) / 2
- };
- }
- var radius = self.radius;
- if (radius > 0 && radius <= 1) {
- maxRadius = maxRadius * radius;
- }
- this.x = {
- start: self.startAngle,
- end: self.endAngle
- };
- this.y = {
- start: maxRadius * inner,
- end: maxRadius
- };
- this.center = center;
- this.circleRadius = maxRadius; // the radius value in px
- };
- _proto.convertPoint = function convertPoint(point) {
- var self = this;
- var center = self.center;
- var transposed = self.transposed;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var x = self.x;
- var y = self.y;
- var angle = x.start + (x.end - x.start) * point[xDim];
- var radius = y.start + (y.end - y.start) * point[yDim];
- return {
- x: center.x + Math.cos(angle) * radius,
- y: center.y + Math.sin(angle) * radius
- };
- };
- _proto.invertPoint = function invertPoint(point) {
- var self = this;
- var center = self.center,
- transposed = self.transposed,
- x = self.x,
- y = self.y;
- var xDim = transposed ? 'y' : 'x';
- var yDim = transposed ? 'x' : 'y';
- var m = [1, 0, 0, 1, 0, 0];
- Matrix.rotate(m, m, x.start);
- var startV = [1, 0];
- Vector2.transformMat2d(startV, startV, m);
- startV = [startV[0], startV[1]];
- var pointV = [point.x - center.x, point.y - center.y];
- if (Vector2.zero(pointV)) {
- return {
- x: 0,
- y: 0
- };
- }
- var theta = Vector2.angleTo(startV, pointV, x.end < x.start);
- if (Math.abs(theta - Math.PI * 2) < 0.001) {
- theta = 0;
- }
- var l = Vector2.length(pointV);
- var percentX = theta / (x.end - x.start);
- percentX = x.end - x.start > 0 ? percentX : -percentX;
- var percentY = (l - y.start) / (y.end - y.start);
- var rst = {};
- rst[xDim] = percentX;
- rst[yDim] = percentY;
- return rst;
- };
- return Polar;
- }(Base);
- Base.Polar = Polar;
- module.exports = Polar;
- /***/ }),
- /* 89 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * @fileOverview 提取公共代码到util方法
- * @author dxq613@gmail.com
- */
- var isString = __webpack_require__(15);
- var isDate = __webpack_require__(33);
- module.exports = {
- toTimeStamp: function toTimeStamp(value) {
- if (isString(value)) {
- if (value.indexOf('T') > 0) {
- value = new Date(value).getTime();
- } else {
- value = new Date(value.replace(/-/ig, '/')).getTime();
- }
- }
- if (isDate(value)) {
- value = value.getTime();
- }
- return value;
- }
- };
- /***/ }),
- /* 90 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- /**
- * marker shapes,used for tooltip and legend
- */
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(5),
- Shape = _require.Shape;
- var SYMBOLS = {
- circle: function circle(x, y, r, ctx) {
- ctx.arc(x, y, r, 0, Math.PI * 2, false);
- },
- square: function square(x, y, r, ctx) {
- ctx.moveTo(x - r, y - r);
- ctx.lineTo(x + r, y - r);
- ctx.lineTo(x + r, y + r);
- ctx.lineTo(x - r, y + r);
- ctx.closePath();
- }
- };
- var Marker =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Marker, _Shape);
- function Marker() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Marker.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'marker';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- x: 0,
- y: 0,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- radius = attrs.radius;
- var symbol = attrs.symbol || 'circle';
- var method;
- if (Util.isFunction(symbol)) {
- method = symbol;
- } else {
- method = SYMBOLS[symbol];
- }
- context.beginPath();
- method(x, y, radius, context, this);
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var x = attrs.x,
- y = attrs.y,
- radius = attrs.radius;
- return {
- minX: x - radius,
- minY: y - radius,
- maxX: x + radius,
- maxY: y + radius
- };
- };
- return Marker;
- }(Shape);
- module.exports = Marker;
- /***/ }),
- /* 91 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(5),
- Group = _require.Group;
- var Marker = __webpack_require__(90);
- var MARKER_RADIUS = 3;
- var List =
- /*#__PURE__*/
- function () {
- var _proto = List.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- showTitle: false,
- /**
- * title string
- * @type {?String}
- */
- title: null,
- /**
- * items array
- * @type {?Array}
- */
- items: null,
- /**
- * offset between title and items
- * @type {Number}
- */
- titleGap: 12,
- /**
- * offset between each item
- * @type {Number}
- */
- itemGap: 10,
- /**
- * the offset between each item in vertical direaction
- * @type {Number}
- */
- itemMarginBottom: 12,
- /**
- * the formatter for item text
- * @type {[type]}
- */
- itemFormatter: null,
- itemWidth: null,
- /**
- * offset between marker and text
- * @type {Number}
- */
- wordSpace: 6,
- x: 0,
- y: 0,
- layout: 'horizontal',
- /**
- * the join string of `name` and `value`
- * @type {String}
- */
- joinString: ': '
- };
- };
- function List(cfg) {
- Util.deepMix(this, this.getDefaultCfg(), cfg);
- this._init();
- this._renderTitle();
- this._renderItems();
- }
- _proto._init = function _init() {
- var container = new Group({
- zIndex: this.zIndex || 0
- });
- this.container = container;
- var wrapper = container.addGroup();
- this.wrapper = wrapper;
- var itemsGroup = wrapper.addGroup({
- className: 'itemsGroup'
- });
- this.itemsGroup = itemsGroup;
- if (this.parent) {
- this.parent.add(container);
- }
- };
- _proto._renderTitle = function _renderTitle(title) {
- title = title || this.title;
- var titleShape = this.titleShape;
- var titleHeight = 0;
- if (this.showTitle && title) {
- if (titleShape && !titleShape.get('destroyed')) {
- titleShape.attr('text', title);
- } else {
- var wrapper = this.wrapper,
- titleStyle = this.titleStyle;
- titleShape = wrapper.addShape('text', {
- className: 'title',
- attrs: Util.mix({
- x: 0,
- y: 0,
- text: title
- }, titleStyle)
- });
- this.titleShape = titleShape;
- }
- titleHeight = titleShape.getBBox().height + this.titleGap;
- }
- this._titleHeight = titleHeight;
- };
- _proto._renderItems = function _renderItems(items) {
- var self = this;
- items = items || self.items;
- if (!items) {
- return;
- }
- if (self.reversed) {
- items.reverse();
- }
- Util.each(items, function (item, index) {
- self._addItem(item, index);
- });
- if (items.length > 1) {
- this._adjustItems();
- }
- this._renderBackground();
- };
- _proto._renderBackground = function _renderBackground() {
- var background = this.background;
- if (background) {
- var container = this.container;
- var wrapper = this.wrapper;
- var _wrapper$getBBox = wrapper.getBBox(),
- minX = _wrapper$getBBox.minX,
- minY = _wrapper$getBBox.minY,
- width = _wrapper$getBBox.width,
- height = _wrapper$getBBox.height;
- var padding = background.padding || [0, 0, 0, 0];
- padding = Util.parsePadding(padding);
- var attrs = Util.mix({
- x: minX - padding[3],
- y: minY - padding[0],
- width: width + padding[1] + padding[3],
- height: height + padding[0] + padding[2]
- }, background);
- var backShape = this.backShape;
- if (backShape) {
- backShape.attr(attrs);
- } else {
- backShape = container.addShape('Rect', {
- zIndex: -1,
- attrs: attrs
- });
- }
- this.backShape = backShape;
- container.sort();
- }
- };
- _proto._addItem = function _addItem(item) {
- var itemsGroup = this.itemsGroup;
- var itemGroup = itemsGroup.addGroup({
- name: item.name,
- value: item.value,
- dataValue: item.dataValue,
- checked: item.checked
- });
- var unCheckStyle = this.unCheckStyle,
- unCheckColor = this.unCheckColor,
- nameStyle = this.nameStyle,
- valueStyle = this.valueStyle,
- wordSpace = this.wordSpace;
- var marker = item.marker,
- value = item.value;
- var startX = 0;
- if (unCheckColor) {
- unCheckStyle.fill = unCheckColor;
- }
- if (marker) {
- var radius = marker.radius || MARKER_RADIUS;
- var markerAttrs = Util.mix({
- x: radius,
- y: this._titleHeight
- }, marker);
- if (item.checked === false) {
- Util.mix(markerAttrs, unCheckStyle);
- }
- var markerShape = new Marker({
- className: 'item-marker',
- attrs: markerAttrs
- });
- itemGroup.add(markerShape);
- startX += markerShape.getBBox().width + wordSpace;
- }
- var nameText;
- var name = item.name;
- if (name) {
- var joinString = this.joinString || '';
- name = value ? name + joinString : name;
- nameText = itemGroup.addShape('text', {
- className: 'name',
- attrs: Util.mix({
- x: startX,
- y: this._titleHeight,
- text: this._formatItemValue(name)
- }, nameStyle, item.checked === false ? unCheckStyle : null)
- });
- }
- if (value) {
- var valueX = startX;
- if (nameText) {
- valueX += nameText.getBBox().width;
- }
- itemGroup.addShape('text', {
- className: 'value',
- attrs: Util.mix({
- x: valueX,
- y: this._titleHeight,
- text: value
- }, valueStyle, item.checked === false ? unCheckStyle : null)
- });
- }
- return itemGroup;
- };
- _proto._formatItemValue = function _formatItemValue(value) {
- var formatter = this.itemFormatter;
- if (formatter) {
- value = formatter.call(this, value);
- }
- return value;
- };
- _proto._getMaxItemWidth = function _getMaxItemWidth() {
- var width;
- var itemWidth = this.itemWidth;
- if (Util.isNumber(itemWidth) || Util.isNil(itemWidth)) {
- return itemWidth;
- }
- if (itemWidth === 'auto') {
- var itemsGroup = this.itemsGroup;
- var children = itemsGroup.get('children');
- var count = children.length;
- var maxItemWidth = 0;
- for (var i = 0; i < count; i++) {
- var _children$i$getBBox = children[i].getBBox(),
- _width = _children$i$getBBox.width;
- maxItemWidth = Math.max(maxItemWidth, _width);
- }
- var maxLength = this.maxLength;
- var itemGap = this.itemGap;
- var twoAvgWidth = (maxLength - itemGap) / 2;
- var threeAvgWidth = (maxLength - itemGap * 2) / 3;
- if (count === 2) {
- width = Math.max(maxItemWidth, twoAvgWidth);
- } else {
- // 1. max <= 3Avg, 3Avg
- // 2. 3Avg < max && max < 2avg, 2avg
- // 3. max > 2avg, max, one column
- if (maxItemWidth <= threeAvgWidth) {
- width = threeAvgWidth;
- } else if (maxItemWidth <= twoAvgWidth) {
- width = twoAvgWidth;
- } else {
- width = maxItemWidth;
- }
- }
- return width;
- }
- };
- _proto._adjustHorizontal = function _adjustHorizontal() {
- var maxLength = this.maxLength,
- itemsGroup = this.itemsGroup;
- var children = itemsGroup.get('children');
- var itemGap = this.itemGap,
- itemMarginBottom = this.itemMarginBottom;
- var titleHeight = this._titleHeight;
- var row = 0;
- var rowWidth = 0;
- var width;
- var height;
- var itemWidth = this._getMaxItemWidth();
- var legendHitBoxes = [];
- for (var i = 0, len = children.length; i < len; i++) {
- var child = children[i];
- var box = child.getBBox();
- var childHeight = box.height;
- var childWidth = box.width;
- width = itemWidth || childWidth;
- height = childHeight + itemMarginBottom;
- if (width - (maxLength - rowWidth) > 0.0001) {
- row++;
- rowWidth = 0;
- }
- child.moveTo(rowWidth, row * height);
- legendHitBoxes.push({
- x: rowWidth,
- y: row * height + titleHeight - childHeight / 2,
- width: childWidth * 1.375,
- height: childHeight * 1.375
- });
- rowWidth += width + itemGap;
- }
- this.legendHitBoxes = legendHitBoxes;
- return;
- };
- _proto._adjustVertical = function _adjustVertical() {
- var maxLength = this.maxLength,
- itemsGroup = this.itemsGroup;
- var itemGap = this.itemGap,
- itemMarginBottom = this.itemMarginBottom,
- itemWidth = this.itemWidth;
- var titleHeight = this._titleHeight;
- var children = itemsGroup.get('children');
- var colHeight = 0;
- var width;
- var height;
- var maxItemWidth = 0;
- var totalWidth = 0;
- var legendHitBoxes = [];
- for (var i = 0, length = children.length; i < length; i++) {
- var child = children[i];
- var bbox = child.getBBox();
- width = bbox.width;
- height = bbox.height;
- if (Util.isNumber(itemWidth)) {
- maxItemWidth = itemWidth + itemGap;
- } else if (width > maxItemWidth) {
- maxItemWidth = width + itemGap;
- }
- if (maxLength - colHeight < height) {
- colHeight = 0;
- totalWidth += maxItemWidth;
- child.moveTo(totalWidth, 0);
- legendHitBoxes.push({
- x: totalWidth,
- y: titleHeight - height / 2,
- width: width * 1.375,
- height: height * 1.375
- });
- } else {
- child.moveTo(totalWidth, colHeight);
- legendHitBoxes.push({
- x: totalWidth,
- y: colHeight - height / 2 + titleHeight,
- width: width * 1.375,
- height: height * 1.375
- });
- }
- colHeight += height + itemMarginBottom;
- }
- this.legendHitBoxes = legendHitBoxes;
- return;
- };
- _proto._adjustItems = function _adjustItems() {
- var layout = this.layout;
- if (layout === 'horizontal') {
- this._adjustHorizontal();
- } else {
- this._adjustVertical();
- }
- };
- _proto.moveTo = function moveTo(x, y) {
- this.x = x;
- this.y = y;
- var container = this.container;
- container && container.moveTo(x, y);
- return this;
- };
- _proto.setItems = function setItems(items) {
- this.clearItems();
- this._renderItems(items);
- };
- _proto.setTitle = function setTitle(title) {
- this._renderTitle(title);
- };
- _proto.clearItems = function clearItems() {
- var itemsGroup = this.itemsGroup;
- itemsGroup.clear();
- };
- _proto.getWidth = function getWidth() {
- var container = this.container;
- var bbox = container.getBBox();
- return bbox.width;
- };
- _proto.getHeight = function getHeight() {
- var container = this.container;
- var bbox = container.getBBox();
- return bbox.height;
- };
- _proto.show = function show() {
- var container = this.container;
- container.show();
- };
- _proto.hide = function hide() {
- var container = this.container;
- container.hide();
- };
- _proto.clear = function clear() {
- var container = this.container;
- container.clear();
- container.remove(true);
- };
- return List;
- }();
- module.exports = List;
- /***/ }),
- /* 92 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Animate configuration and register
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var defaultAnimationCfg = {
- appear: {
- duration: 450,
- easing: 'quadraticOut'
- },
- // 'appear' animation options
- update: {
- duration: 300,
- easing: 'quadraticOut'
- },
- // 'update' animation options
- enter: {
- duration: 300,
- easing: 'quadraticOut'
- },
- // 'enter' animation options
- leave: {
- duration: 350,
- easing: 'quadraticIn' // 'leave' animation options
- }
- };
- var Animate = {
- defaultCfg: {},
- Action: {},
- getAnimation: function getAnimation(geomType, coord, animationType) {
- var geomAnimateCfg = this.defaultCfg[geomType];
- if (geomAnimateCfg) {
- var animation = geomAnimateCfg[animationType];
- if (Util.isFunction(animation)) {
- return animation(coord);
- }
- }
- return false;
- },
- getAnimateCfg: function getAnimateCfg(geomType, animationType) {
- var defaultCfg = defaultAnimationCfg[animationType];
- var geomConfig = this.defaultCfg[geomType];
- if (geomConfig && geomConfig.cfg && geomConfig.cfg[animationType]) {
- return Util.deepMix({}, defaultCfg, geomConfig.cfg[animationType]);
- }
- return defaultCfg;
- },
- registerAnimation: function registerAnimation(animationName, animationFun) {
- if (!this.Action) {
- this.Action = {};
- }
- this.Action[animationName] = animationFun;
- }
- };
- module.exports = Animate;
- /***/ }),
- /* 93 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Utility
- * @author sima.zhang1990@gmail.com
- */
- var _require = __webpack_require__(5),
- Matrix = _require.Matrix;
- var Util = __webpack_require__(0);
- var Helpers = {
- getCoordInfo: function getCoordInfo(coord) {
- var start = coord.start;
- var end = coord.end;
- return {
- start: start,
- end: end,
- width: end.x - start.x,
- height: Math.abs(end.y - start.y)
- };
- },
- getScaledMatrix: function getScaledMatrix(shape, v, direct) {
- var scaledMatrix;
- shape.apply(v);
- var x = v[0];
- var y = v[1];
- if (direct === 'x') {
- shape.transform([['t', x, y], ['s', 0.01, 1], ['t', -x, -y]]);
- var matrix = shape.getMatrix();
- scaledMatrix = Matrix.transform(matrix, [['t', x, y], ['s', 100, 1], ['t', -x, -y]]);
- } else if (direct === 'y') {
- shape.transform([['t', x, y], ['s', 1, 0.01], ['t', -x, -y]]);
- var _matrix = shape.getMatrix();
- scaledMatrix = Matrix.transform(_matrix, [['t', x, y], ['s', 1, 100], ['t', -x, -y]]);
- } else if (direct === 'xy') {
- shape.transform([['t', x, y], ['s', 0.01, 0.01], ['t', -x, -y]]);
- var _matrix2 = shape.getMatrix();
- scaledMatrix = Matrix.transform(_matrix2, [['t', x, y], ['s', 100, 100], ['t', -x, -y]]);
- }
- return scaledMatrix;
- },
- getAnimateParam: function getAnimateParam(animateCfg, index, id) {
- var result = {};
- if (animateCfg.delay) {
- result.delay = Util.isFunction(animateCfg.delay) ? animateCfg.delay(index, id) : animateCfg.delay;
- }
- result.easing = animateCfg.easing;
- result.duration = animateCfg.duration;
- result.delay = animateCfg.delay;
- return result;
- },
- doAnimation: function doAnimation(shape, endState, animateCfg, callback) {
- var id = shape._id;
- var index = shape.get('index');
- var _Helpers$getAnimatePa = Helpers.getAnimateParam(animateCfg, index, id),
- easing = _Helpers$getAnimatePa.easing,
- delay = _Helpers$getAnimatePa.delay,
- duration = _Helpers$getAnimatePa.duration;
- var anim = shape.animate().to({
- attrs: endState,
- duration: duration,
- delay: delay,
- easing: easing
- });
- if (callback) {
- anim.onEnd(function () {
- callback();
- });
- }
- }
- };
- module.exports = Helpers;
- /***/ }),
- /* 94 */,
- /* 95 */
- /***/ (function(module, exports, __webpack_require__) {
- var Geom = __webpack_require__(6);
- __webpack_require__(96);
- __webpack_require__(38);
- __webpack_require__(80);
- __webpack_require__(98);
- __webpack_require__(81);
- __webpack_require__(100);
- __webpack_require__(102);
- module.exports = Geom;
- /***/ }),
- /* 96 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Geom = __webpack_require__(6);
- __webpack_require__(97);
- var Point =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Point, _Geom);
- function Point() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Point.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'point';
- cfg.shapeType = 'point';
- cfg.generatePoints = true;
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- Util.each(data, function (obj) {
- var shape = obj.shape;
- var cfg = self.getDrawCfg(obj);
- if (Util.isArray(obj.y)) {
- var hasStack = self.hasAdjust('stack');
- Util.each(obj.y, function (y, idx) {
- cfg.y = y;
- if (!hasStack || idx !== 0) {
- self.drawShape(shape, obj, cfg, container, shapeFactory);
- }
- });
- } else if (!Util.isNil(obj.y)) {
- self.drawShape(shape, obj, cfg, container, shapeFactory);
- }
- });
- };
- return Point;
- }(Geom);
- Geom.Point = Point;
- module.exports = Point;
- /***/ }),
- /* 97 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(1);
- var ShapeUtil = __webpack_require__(20);
- var Shape = __webpack_require__(9);
- var SHAPES = ['circle', 'hollowCircle', 'rect'];
- var Point = Shape.registerFactory('point', {
- defaultShapeType: 'circle',
- getDefaultPoints: function getDefaultPoints(pointInfo) {
- return ShapeUtil.splitPoints(pointInfo);
- }
- });
- function getPointsCfg(cfg) {
- var style = {
- lineWidth: 0,
- stroke: cfg.color,
- fill: cfg.color
- };
- if (cfg.size) {
- style.size = cfg.size;
- }
- Util.mix(style, cfg.style);
- return Util.mix({}, Global.shape.point, style);
- }
- function drawShape(cfg, container, shape) {
- if (cfg.size === 0) return;
- var pointCfg = getPointsCfg(cfg);
- var size = pointCfg.r || pointCfg.size;
- var x = cfg.x;
- var y = !Util.isArray(cfg.y) ? [cfg.y] : cfg.y;
- if (shape === 'hollowCircle') {
- pointCfg.lineWidth = 1;
- pointCfg.fill = null;
- }
- for (var i = 0, len = y.length; i < len; i++) {
- if (shape === 'rect') {
- return container.addShape('Rect', {
- className: 'point',
- attrs: Util.mix({
- x: x - size,
- y: y[i] - size,
- width: size * 2,
- height: size * 2
- }, pointCfg)
- });
- }
- return container.addShape('Circle', {
- className: 'point',
- attrs: Util.mix({
- x: x,
- y: y[i],
- r: size
- }, pointCfg)
- });
- }
- }
- Util.each(SHAPES, function (shapeType) {
- Shape.registerShape('point', shapeType, {
- draw: function draw(cfg, container) {
- return drawShape(cfg, container, shapeType);
- }
- });
- });
- module.exports = Point;
- /***/ }),
- /* 98 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- /**
- * @fileOverview area geometry
- * @author dxq613 @gmail.com
- * @author sima.zhang1990@gmail.com
- */
- var Geom = __webpack_require__(6);
- var ShapeUtil = __webpack_require__(20);
- var Util = __webpack_require__(0);
- __webpack_require__(99);
- var Area =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Area, _Geom);
- function Area() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Area.prototype;
- /**
- * get the default configuration
- * @protected
- * @return {Object} return the result
- */
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'area';
- cfg.shapeType = 'area';
- cfg.generatePoints = true;
- cfg.sortable = true;
- return cfg;
- };
- _proto.draw = function draw(data, shapeFactory) {
- var self = this;
- var container = self.get('container');
- var cfg = this.getDrawCfg(data[0]);
- var yScale = self.getYScale();
- var connectNulls = self.get('connectNulls');
- var splitArray = ShapeUtil.splitArray(data, yScale.field, connectNulls);
- cfg.origin = data;
- Util.each(splitArray, function (subData, splitedIndex) {
- cfg.splitedIndex = splitedIndex;
- var points = subData.map(function (obj) {
- return obj.points;
- });
- cfg.points = points;
- self.drawShape(cfg.shape, data[0], cfg, container, shapeFactory);
- });
- };
- return Area;
- }(Geom);
- Geom.Area = Area;
- module.exports = Area;
- /***/ }),
- /* 99 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Shape = __webpack_require__(9);
- var Smooth = __webpack_require__(37);
- var bbox = __webpack_require__(11);
- var Global = __webpack_require__(1);
- function equals(v1, v2) {
- return Math.abs(v1 - v2) < 0.00001;
- }
- function notEmpty(value) {
- return !isNaN(value) && !Util.isNil(value);
- }
- function filterPoints(points) {
- var filteredPoints = []; // filter the point which x or y is NaN
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (notEmpty(point.x) && notEmpty(point.y)) {
- filteredPoints.push(point);
- }
- }
- return filteredPoints;
- }
- function equalsCenter(points, center) {
- var eqls = true;
- Util.each(points, function (point) {
- if (!equals(point.x, center.x) || !equals(point.y, center.y)) {
- eqls = false;
- return false;
- }
- });
- return eqls;
- }
- function drawRectShape(topPoints, bottomPoints, container, style, isSmooth) {
- var shape;
- var points = topPoints.concat(bottomPoints);
- if (isSmooth) {
- shape = container.addShape('Custom', {
- className: 'area',
- attrs: Util.mix({
- points: points
- }, style),
- createPath: function createPath(context) {
- var constaint = [[0, 0], [1, 1]];
- var points = filterPoints(this._attrs.attrs.points);
- var pointsLen = points.length;
- var topPoints = points.slice(0, pointsLen / 2);
- var bottomPoints = points.slice(pointsLen / 2, pointsLen);
- var topSps = Smooth.smooth(topPoints, false, constaint);
- context.beginPath();
- context.moveTo(topPoints[0].x, topPoints[0].y);
- for (var i = 0, n = topSps.length; i < n; i++) {
- var sp = topSps[i];
- context.bezierCurveTo(sp[1], sp[2], sp[3], sp[4], sp[5], sp[6]);
- }
- if (bottomPoints.length) {
- var bottomSps = Smooth.smooth(bottomPoints, false, constaint);
- context.lineTo(bottomPoints[0].x, bottomPoints[0].y);
- for (var _i = 0, _n = bottomSps.length; _i < _n; _i++) {
- var _sp = bottomSps[_i];
- context.bezierCurveTo(_sp[1], _sp[2], _sp[3], _sp[4], _sp[5], _sp[6]);
- }
- }
- context.closePath();
- },
- calculateBox: function calculateBox() {
- var points = filterPoints(this._attrs.attrs.points);
- return bbox.getBBoxFromPoints(points);
- }
- });
- } else {
- shape = container.addShape('Polyline', {
- className: 'area',
- attrs: Util.mix({
- points: points
- }, style)
- });
- }
- return shape;
- }
- function drawShape(cfg, container, isSmooth) {
- var self = this;
- var points = cfg.points;
- var topPoints = [];
- var bottomPoints = [];
- Util.each(points, function (point) {
- bottomPoints.push(point[0]);
- topPoints.push(point[1]);
- });
- var style = Util.mix({
- fillStyle: cfg.color
- }, Global.shape.area, cfg.style);
- bottomPoints.reverse();
- topPoints = self.parsePoints(topPoints);
- bottomPoints = self.parsePoints(bottomPoints);
- if (cfg.isInCircle) {
- topPoints.push(topPoints[0]);
- bottomPoints.unshift(bottomPoints[bottomPoints.length - 1]);
- if (equalsCenter(bottomPoints, cfg.center)) {
- bottomPoints = [];
- }
- }
- return drawRectShape(topPoints, bottomPoints, container, style, isSmooth);
- }
- var Area = Shape.registerFactory('area', {
- defaultShapeType: 'area',
- getDefaultPoints: function getDefaultPoints(obj) {
- var x = obj.x;
- var y = obj.y;
- var y0 = obj.y0;
- y = Util.isArray(y) ? y : [y0, y];
- var points = [];
- points.push({
- x: x,
- y: y[0]
- }, {
- x: x,
- y: y[1]
- });
- return points;
- }
- });
- var SHAPES = ['area', 'smooth'];
- Util.each(SHAPES, function (shapeType) {
- Shape.registerShape('area', shapeType, {
- draw: function draw(cfg, container) {
- var smooth = shapeType === 'smooth';
- return drawShape.call(this, cfg, container, smooth);
- }
- });
- });
- module.exports = Area;
- /***/ }),
- /* 100 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Geom = __webpack_require__(6);
- var Util = __webpack_require__(0);
- __webpack_require__(101);
- var Polygon =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Polygon, _Geom);
- function Polygon() {
- return _Geom.apply(this, arguments) || this;
- }
- var _proto = Polygon.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'polygon';
- cfg.shapeType = 'polygon';
- cfg.generatePoints = true;
- return cfg;
- };
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- var self = this;
- var x = cfg.x;
- var y = cfg.y;
- var temp;
- if (!(Util.isArray(x) && Util.isArray(y))) {
- var xScale = self.getXScale();
- var yScale = self.getYScale();
- var xCount = xScale.values ? xScale.values.length : xScale.ticks.length;
- var yCount = yScale.values ? yScale.values.length : yScale.ticks.length;
- var xOffset = 0.5 * 1 / xCount;
- var yOffset = 0.5 * 1 / yCount;
- if (xScale.isCategory && yScale.isCategory) {
- x = [x - xOffset, x - xOffset, x + xOffset, x + xOffset];
- y = [y - yOffset, y + yOffset, y + yOffset, y - yOffset];
- } else if (Util.isArray(x)) {
- temp = x;
- x = [temp[0], temp[0], temp[1], temp[1]];
- y = [y - yOffset / 2, y + yOffset / 2, y + yOffset / 2, y - yOffset / 2];
- } else if (Util.isArray(y)) {
- temp = y;
- y = [temp[0], temp[1], temp[1], temp[0]];
- x = [x - xOffset / 2, x - xOffset / 2, x + xOffset / 2, x + xOffset / 2];
- }
- cfg.x = x;
- cfg.y = y;
- }
- return cfg;
- };
- return Polygon;
- }(Geom);
- Geom.Polygon = Polygon;
- module.exports = Polygon;
- /***/ }),
- /* 101 */
- /***/ (function(module, exports, __webpack_require__) {
- var Shape = __webpack_require__(9);
- var Util = __webpack_require__(0);
- var Polygon = Shape.registerFactory('polygon', {
- defaultShapeType: 'polygon',
- getDefaultPoints: function getDefaultPoints(pointInfo) {
- var points = [];
- var x = pointInfo.x,
- y = pointInfo.y;
- for (var i = 0, len = x.length; i < len; i++) {
- points.push({
- x: x[i],
- y: y[i]
- });
- }
- return points;
- }
- });
- Shape.registerShape('polygon', 'polygon', {
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var style = Util.mix({
- fill: cfg.color,
- points: points
- }, cfg.style);
- return container.addShape('Polygon', {
- className: 'polygon',
- attrs: style
- });
- }
- });
- module.exports = Polygon;
- /***/ }),
- /* 102 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
- var Geom = __webpack_require__(6);
- var Util = __webpack_require__(0);
- var SizeMixin = __webpack_require__(39);
- __webpack_require__(103);
- var Schema =
- /*#__PURE__*/
- function (_Geom) {
- _inheritsLoose(Schema, _Geom);
- var _proto = Schema.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- var cfg = _Geom.prototype.getDefaultCfg.call(this);
- cfg.type = 'schema';
- cfg.shapeType = 'schema';
- cfg.generatePoints = true;
- return cfg;
- };
- function Schema(cfg) {
- var _this;
- _this = _Geom.call(this, cfg) || this;
- Util.mix(_assertThisInitialized(_assertThisInitialized(_this)), SizeMixin);
- return _this;
- }
- _proto.createShapePointsCfg = function createShapePointsCfg(obj) {
- var cfg = _Geom.prototype.createShapePointsCfg.call(this, obj);
- cfg.size = this.getNormalizedSize(obj);
- return cfg;
- };
- _proto.clearInner = function clearInner() {
- _Geom.prototype.clearInner.call(this);
- this.set('defaultSize', null);
- };
- return Schema;
- }(Geom);
- Geom.Schema = Schema;
- module.exports = Schema;
- /***/ }),
- /* 103 */
- /***/ (function(module, exports, __webpack_require__) {
- var Shape = __webpack_require__(9);
- var Util = __webpack_require__(0);
- function _sortValue(value) {
- var sorted = value.sort(function (a, b) {
- return a < b ? 1 : -1;
- });
- var length = sorted.length;
- if (length < 4) {
- var min = sorted[length - 1];
- for (var i = 0; i < 4 - length; i++) {
- sorted.push(min);
- }
- }
- return sorted;
- } // from left bottom corner, and clockwise
- function getCandlePoints(x, y, width) {
- var yValues = _sortValue(y);
- var points = [{
- x: x,
- y: yValues[0]
- }, {
- x: x,
- y: yValues[1]
- }, {
- x: x - width / 2,
- y: yValues[2]
- }, {
- x: x - width / 2,
- y: yValues[1]
- }, {
- x: x + width / 2,
- y: yValues[1]
- }, {
- x: x + width / 2,
- y: yValues[2]
- }, {
- x: x,
- y: yValues[2]
- }, {
- x: x,
- y: yValues[3]
- }];
- return points;
- }
- var Schema = Shape.registerFactory('schema', {});
- Shape.registerShape('schema', 'candle', {
- getPoints: function getPoints(cfg) {
- return getCandlePoints(cfg.x, cfg.y, cfg.size);
- },
- draw: function draw(cfg, container) {
- var points = this.parsePoints(cfg.points);
- var style = Util.mix({
- stroke: cfg.color,
- fill: cfg.color,
- lineWidth: 1
- }, cfg.style);
- return container.addShape('Custom', {
- className: 'schema',
- attrs: style,
- createPath: function createPath(ctx) {
- ctx.beginPath();
- ctx.moveTo(points[0].x, points[0].y);
- ctx.lineTo(points[1].x, points[1].y);
- ctx.moveTo(points[2].x, points[2].y);
- for (var i = 3; i < 6; i++) {
- ctx.lineTo(points[i].x, points[i].y);
- }
- ctx.closePath();
- ctx.moveTo(points[6].x, points[6].y);
- ctx.lineTo(points[7].x, points[7].y);
- }
- });
- }
- });
- module.exports = Schema;
- /***/ }),
- /* 104 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var Abstract = __webpack_require__(24);
- var Circle =
- /*#__PURE__*/
- function (_Abstract) {
- _inheritsLoose(Circle, _Abstract);
- function Circle() {
- return _Abstract.apply(this, arguments) || this;
- }
- var _proto = Circle.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Abstract.prototype._initDefaultCfg.call(this);
- this.startAngle = -Math.PI / 2; // start angle,in radian
- this.endAngle = Math.PI * 3 / 2; // end angle, in radian
- this.radius = null; // radius
- this.center = null; // center
- };
- _proto.getOffsetPoint = function getOffsetPoint(value) {
- var startAngle = this.startAngle,
- endAngle = this.endAngle;
- var angle = startAngle + (endAngle - startAngle) * value;
- return this._getCirclePoint(angle);
- };
- _proto._getCirclePoint = function _getCirclePoint(angle, radius) {
- var self = this;
- var center = self.center;
- radius = radius || self.radius;
- return {
- x: center.x + Math.cos(angle) * radius,
- y: center.y + Math.sin(angle) * radius
- };
- };
- _proto.getTextAlignInfo = function getTextAlignInfo(point, offset) {
- var self = this;
- var offsetVector = self.getOffsetVector(point, offset);
- var align;
- var baseLine = 'middle';
- if (offsetVector[0] > 0) {
- align = 'left';
- } else if (offsetVector[0] < 0) {
- align = 'right';
- } else {
- align = 'center';
- if (offsetVector[1] > 0) {
- baseLine = 'top';
- } else if (offsetVector[1] < 0) {
- baseLine = 'bottom';
- }
- }
- return {
- textAlign: align,
- textBaseline: baseLine
- };
- };
- _proto.getAxisVector = function getAxisVector(point) {
- var center = this.center;
- var factor = this.offsetFactor;
- return [(point.y - center.y) * factor, (point.x - center.x) * -1 * factor];
- };
- _proto.drawLine = function drawLine(lineCfg) {
- var center = this.center,
- radius = this.radius,
- startAngle = this.startAngle,
- endAngle = this.endAngle;
- var container = this.getContainer(lineCfg.top);
- container.addShape('arc', {
- className: 'axis-line',
- attrs: Util.mix({
- x: center.x,
- y: center.y,
- r: radius,
- startAngle: startAngle,
- endAngle: endAngle
- }, lineCfg)
- });
- };
- return Circle;
- }(Abstract);
- Abstract.Circle = Circle;
- module.exports = Circle;
- /***/ }),
- /* 105 */
- /***/ (function(module, exports, __webpack_require__) {
- var TimeCat = __webpack_require__(106);
- module.exports = TimeCat;
- /***/ }),
- /* 106 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) {
- subClass.prototype = Object.create(superClass.prototype);
- subClass.prototype.constructor = subClass;
- subClass.__proto__ = superClass;
- }
- /**
- * @fileOverview 时间数据作为分类类型
- * @author dxq613@gmail.com
- */
- var Base = __webpack_require__(14);
- var Category = __webpack_require__(34);
- var fecha = __webpack_require__(107);
- var catAuto = __webpack_require__(35);
- var TimeUtil = __webpack_require__(89);
- var each = __webpack_require__(3);
- var isNumber = __webpack_require__(13);
- var isObject = __webpack_require__(18);
- var isString = __webpack_require__(15);
- /**
- * 度量的构造函数
- * @class Scale.TimeCategory
- */
- var TimeCategory =
- /*#__PURE__*/
- function (_Category) {
- _inheritsLoose(TimeCategory, _Category);
- function TimeCategory() {
- return _Category.apply(this, arguments) || this;
- }
- var _proto = TimeCategory.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- _Category.prototype._initDefaultCfg.call(this);
- this.type = 'timeCat';
- /**
- * 是否需要排序,默认进行排序
- * @type {Boolean}
- */
- this.sortable = true;
- this.tickCount = 5;
- /**
- * 时间格式化
- * @type {String}
- */
- this.mask = 'YYYY-MM-DD';
- };
- _proto.init = function init() {
- var self = this;
- var values = this.values; // 针对时间分类类型,会将时间统一转换为时间戳
- each(values, function (v, i) {
- values[i] = self._toTimeStamp(v);
- });
- if (this.sortable) {
- // 允许排序
- values.sort(function (v1, v2) {
- return v1 - v2;
- });
- }
- if (!self.ticks) {
- self.ticks = this.calculateTicks();
- }
- };
- /**
- * 计算 ticks
- * @return {array} 返回 ticks 数组
- */
- _proto.calculateTicks = function calculateTicks() {
- var self = this;
- var count = self.tickCount;
- var ticks;
- if (count) {
- var temp = catAuto({
- maxCount: count,
- data: self.values,
- isRounding: self.isRounding
- });
- ticks = temp.ticks;
- } else {
- ticks = self.values;
- }
- return ticks;
- };
- /**
- * @override
- */
- _proto.translate = function translate(value) {
- value = this._toTimeStamp(value);
- var index = this.values.indexOf(value);
- if (index === -1) {
- if (isNumber(value) && value < this.values.length) {
- index = value;
- } else {
- index = NaN;
- }
- }
- return index;
- };
- /**
- * @override
- */
- _proto.scale = function scale(value) {
- var rangeMin = this.rangeMin();
- var rangeMax = this.rangeMax();
- var index = this.translate(value);
- var percent;
- if (this.values.length === 1 || isNaN(index)) {
- // is index is NAN should not be set as 0
- percent = index;
- } else if (index > -1) {
- percent = index / (this.values.length - 1);
- } else {
- percent = 0;
- }
- return rangeMin + percent * (rangeMax - rangeMin);
- };
- /**
- * @override
- */
- _proto.getText = function getText(value) {
- var result = '';
- var index = this.translate(value);
- if (index > -1) {
- result = this.values[index];
- } else {
- result = value;
- }
- var formatter = this.formatter;
- result = parseInt(result, 10);
- result = formatter ? formatter(result) : fecha.format(result, this.mask);
- return result;
- };
- /**
- * @override
- */
- _proto.getTicks = function getTicks() {
- var self = this;
- var ticks = this.ticks;
- var rst = [];
- each(ticks, function (tick) {
- var obj;
- if (isObject(tick)) {
- obj = tick;
- } else {
- obj = {
- text: isString(tick) ? tick : self.getText(tick),
- value: self.scale(tick),
- tickValue: tick // 用于坐标轴上文本动画时确定前后帧的对应关系
- };
- }
- rst.push(obj);
- });
- return rst;
- }; // 将时间转换为时间戳
- _proto._toTimeStamp = function _toTimeStamp(value) {
- return TimeUtil.toTimeStamp(value);
- };
- return TimeCategory;
- }(Category);
- Base.TimeCat = TimeCategory;
- module.exports = TimeCategory;
- /***/ }),
- /* 107 */
- /***/ (function(module, exports, __webpack_require__) {
- var __WEBPACK_AMD_DEFINE_RESULT__;(function (main) {
- 'use strict';
- /**
- * Parse or format dates
- * @class fecha
- */
- var fecha = {};
- var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
- var twoDigits = /\d\d?/;
- var threeDigits = /\d{3}/;
- var fourDigits = /\d{4}/;
- var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
- var literal = /\[([^]*?)\]/gm;
- var noop = function () {};
- function shorten(arr, sLen) {
- var newArr = [];
- for (var i = 0, len = arr.length; i < len; i++) {
- newArr.push(arr[i].substr(0, sLen));
- }
- return newArr;
- }
- function monthUpdate(arrName) {
- return function (d, v, i18n) {
- var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
- if (~index) {
- d.month = index;
- }
- };
- }
- function pad(val, len) {
- val = String(val);
- len = len || 2;
- while (val.length < len) {
- val = '0' + val;
- }
- return val;
- }
- var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
- var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
- var monthNamesShort = shorten(monthNames, 3);
- var dayNamesShort = shorten(dayNames, 3);
- fecha.i18n = {
- dayNamesShort: dayNamesShort,
- dayNames: dayNames,
- monthNamesShort: monthNamesShort,
- monthNames: monthNames,
- amPm: ['am', 'pm'],
- DoFn: function DoFn(D) {
- return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
- }
- };
- var formatFlags = {
- D: function (dateObj) {
- return dateObj.getDate();
- },
- DD: function (dateObj) {
- return pad(dateObj.getDate());
- },
- Do: function (dateObj, i18n) {
- return i18n.DoFn(dateObj.getDate());
- },
- d: function (dateObj) {
- return dateObj.getDay();
- },
- dd: function (dateObj) {
- return pad(dateObj.getDay());
- },
- ddd: function (dateObj, i18n) {
- return i18n.dayNamesShort[dateObj.getDay()];
- },
- dddd: function (dateObj, i18n) {
- return i18n.dayNames[dateObj.getDay()];
- },
- M: function (dateObj) {
- return dateObj.getMonth() + 1;
- },
- MM: function (dateObj) {
- return pad(dateObj.getMonth() + 1);
- },
- MMM: function (dateObj, i18n) {
- return i18n.monthNamesShort[dateObj.getMonth()];
- },
- MMMM: function (dateObj, i18n) {
- return i18n.monthNames[dateObj.getMonth()];
- },
- YY: function (dateObj) {
- return String(dateObj.getFullYear()).substr(2);
- },
- YYYY: function (dateObj) {
- return pad(dateObj.getFullYear(), 4);
- },
- h: function (dateObj) {
- return dateObj.getHours() % 12 || 12;
- },
- hh: function (dateObj) {
- return pad(dateObj.getHours() % 12 || 12);
- },
- H: function (dateObj) {
- return dateObj.getHours();
- },
- HH: function (dateObj) {
- return pad(dateObj.getHours());
- },
- m: function (dateObj) {
- return dateObj.getMinutes();
- },
- mm: function (dateObj) {
- return pad(dateObj.getMinutes());
- },
- s: function (dateObj) {
- return dateObj.getSeconds();
- },
- ss: function (dateObj) {
- return pad(dateObj.getSeconds());
- },
- S: function (dateObj) {
- return Math.round(dateObj.getMilliseconds() / 100);
- },
- SS: function (dateObj) {
- return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
- },
- SSS: function (dateObj) {
- return pad(dateObj.getMilliseconds(), 3);
- },
- a: function (dateObj, i18n) {
- return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
- },
- A: function (dateObj, i18n) {
- return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
- },
- ZZ: function (dateObj) {
- var o = dateObj.getTimezoneOffset();
- return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
- }
- };
- var parseFlags = {
- D: [twoDigits, function (d, v) {
- d.day = v;
- }],
- Do: [new RegExp(twoDigits.source + word.source), function (d, v) {
- d.day = parseInt(v, 10);
- }],
- M: [twoDigits, function (d, v) {
- d.month = v - 1;
- }],
- YY: [twoDigits, function (d, v) {
- var da = new Date(),
- cent = +('' + da.getFullYear()).substr(0, 2);
- d.year = '' + (v > 68 ? cent - 1 : cent) + v;
- }],
- h: [twoDigits, function (d, v) {
- d.hour = v;
- }],
- m: [twoDigits, function (d, v) {
- d.minute = v;
- }],
- s: [twoDigits, function (d, v) {
- d.second = v;
- }],
- YYYY: [fourDigits, function (d, v) {
- d.year = v;
- }],
- S: [/\d/, function (d, v) {
- d.millisecond = v * 100;
- }],
- SS: [/\d{2}/, function (d, v) {
- d.millisecond = v * 10;
- }],
- SSS: [threeDigits, function (d, v) {
- d.millisecond = v;
- }],
- d: [twoDigits, noop],
- ddd: [word, noop],
- MMM: [word, monthUpdate('monthNamesShort')],
- MMMM: [word, monthUpdate('monthNames')],
- a: [word, function (d, v, i18n) {
- var val = v.toLowerCase();
- if (val === i18n.amPm[0]) {
- d.isPm = false;
- } else if (val === i18n.amPm[1]) {
- d.isPm = true;
- }
- }],
- ZZ: [/([\+\-]\d\d:?\d\d|Z)/, function (d, v) {
- if (v === 'Z') v = '+00:00';
- var parts = (v + '').match(/([\+\-]|\d\d)/gi),
- minutes;
- if (parts) {
- minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
- d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
- }
- }]
- };
- parseFlags.dd = parseFlags.d;
- parseFlags.dddd = parseFlags.ddd;
- parseFlags.DD = parseFlags.D;
- parseFlags.mm = parseFlags.m;
- parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
- parseFlags.MM = parseFlags.M;
- parseFlags.ss = parseFlags.s;
- parseFlags.A = parseFlags.a; // Some common format strings
- fecha.masks = {
- default: 'ddd MMM DD YYYY HH:mm:ss',
- shortDate: 'M/D/YY',
- mediumDate: 'MMM D, YYYY',
- longDate: 'MMMM D, YYYY',
- fullDate: 'dddd, MMMM D, YYYY',
- shortTime: 'HH:mm',
- mediumTime: 'HH:mm:ss',
- longTime: 'HH:mm:ss.SSS'
- };
- /***
- * Format a date
- * @method format
- * @param {Date|number} dateObj
- * @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
- */
- fecha.format = function (dateObj, mask, i18nSettings) {
- var i18n = i18nSettings || fecha.i18n;
- if (typeof dateObj === 'number') {
- dateObj = new Date(dateObj);
- }
- if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
- throw new Error('Invalid Date in fecha.format');
- }
- mask = fecha.masks[mask] || mask || fecha.masks['default'];
- var literals = []; // Make literals inactive by replacing them with ??
- mask = mask.replace(literal, function ($0, $1) {
- literals.push($1);
- return '??';
- }); // Apply formatting rules
- mask = mask.replace(token, function ($0) {
- return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
- }); // Inline literal values back into the formatted value
- return mask.replace(/\?\?/g, function () {
- return literals.shift();
- });
- };
- /**
- * Parse a date string into an object, changes - into /
- * @method parse
- * @param {string} dateStr Date string
- * @param {string} format Date parse format
- * @returns {Date|boolean}
- */
- fecha.parse = function (dateStr, format, i18nSettings) {
- var i18n = i18nSettings || fecha.i18n;
- if (typeof format !== 'string') {
- throw new Error('Invalid format in fecha.parse');
- }
- format = fecha.masks[format] || format; // Avoid regular expression denial of service, fail early for really long strings
- // https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
- if (dateStr.length > 1000) {
- return false;
- }
- var isValid = true;
- var dateInfo = {};
- format.replace(token, function ($0) {
- if (parseFlags[$0]) {
- var info = parseFlags[$0];
- var index = dateStr.search(info[0]);
- if (!~index) {
- isValid = false;
- } else {
- dateStr.replace(info[0], function (result) {
- info[1](dateInfo, result, i18n);
- dateStr = dateStr.substr(index + result.length);
- return result;
- });
- }
- }
- return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
- });
- if (!isValid) {
- return false;
- }
- var today = new Date();
- if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
- dateInfo.hour = +dateInfo.hour + 12;
- } else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
- dateInfo.hour = 0;
- }
- var date;
- if (dateInfo.timezoneOffset != null) {
- dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
- 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));
- } else {
- 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);
- }
- return date;
- };
- /* istanbul ignore next */
- if (typeof module !== 'undefined' && module.exports) {
- module.exports = fecha;
- } else if (true) {
- !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
- return fecha;
- }.call(exports, __webpack_require__, exports, module),
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
- } else {
- main.fecha = fecha;
- }
- })(this);
- /***/ }),
- /* 108 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(12);
- var Arc =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Arc, _GuideBase);
- function Arc() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Arc.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'arc';
- /**
- * start point
- * @type {Array | Function}
- */
- this.start = [];
- /**
- * end point
- * @type {Array | Function}
- */
- this.end = [];
- /**
- * style configuration
- * @type {Object}
- */
- this.style = {
- stroke: '#999',
- lineWidth: 1
- };
- };
- _proto.render = function render(coord, container) {
- var self = this;
- var start = self.parsePoint(coord, self.start);
- var end = self.parsePoint(coord, self.end);
- if (!start || !end) {
- return;
- }
- var coordCenter = coord.center;
- var radius = Math.sqrt((start.x - coordCenter.x) * (start.x - coordCenter.x) + (start.y - coordCenter.y) * (start.y - coordCenter.y));
- var startAngle = Math.atan2(start.y - coordCenter.y, start.x - coordCenter.x);
- var endAngle = Math.atan2(end.y - coordCenter.y, end.x - coordCenter.x);
- var shape = container.addShape('arc', {
- className: 'guide-arc',
- attrs: Util.mix({
- x: coordCenter.x,
- y: coordCenter.y,
- r: radius,
- startAngle: startAngle,
- endAngle: endAngle
- }, self.style)
- });
- self.element = shape;
- return shape;
- };
- return Arc;
- }(GuideBase);
- GuideBase.Arc = Arc;
- module.exports = Arc;
- /***/ }),
- /* 109 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(12);
- function getOffsetFromAlign(alignX, alignY, width, height) {
- var result = [];
- if (alignX === 'left' && alignY === 'top') {
- result[0] = 0;
- result[1] = 0;
- } else if (alignX === 'right' && alignY === 'top') {
- result[0] = -width;
- result[1] = 0;
- } else if (alignX === 'left' && alignY === 'bottom') {
- result[0] = 0;
- result[1] = Math.floor(-height);
- } else if (alignX === 'right' && alignY === 'bottom') {
- result[0] = Math.floor(-width);
- result[1] = Math.floor(-height);
- } else if (alignX === 'right' && alignY === 'middle') {
- result[0] = Math.floor(-width);
- result[1] = Math.floor(-height / 2);
- } else if (alignX === 'left' && alignY === 'middle') {
- result[0] = 0;
- result[1] = Math.floor(-height / 2);
- } else if (alignX === 'center' && alignY === 'bottom') {
- result[0] = Math.floor(-width / 2);
- result[1] = Math.floor(-height);
- } else if (alignX === 'center' && alignY === 'top') {
- result[0] = Math.floor(-width / 2);
- result[1] = 0;
- } else {
- result[0] = Math.floor(-width / 2);
- result[1] = Math.floor(-height / 2);
- }
- return result;
- }
- function modifyCSS(DOM, CSS) {
- for (var key in CSS) {
- if (CSS.hasOwnProperty(key)) {
- DOM.style[key] = CSS[key];
- }
- }
- return DOM;
- }
- function createDom(str) {
- var container = document.createElement('div');
- str = str.replace(/(^\s*)|(\s*$)/g, '');
- container.innerHTML = '' + str;
- return container.childNodes[0];
- }
- var Html =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Html, _GuideBase);
- function Html() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Html.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'html';
- /**
- * dom position
- * @type {Object | Array}
- */
- this.position = null;
- /**
- * alignment for horizontal direction,can be 'left','center','right'
- * @type {String}
- */
- this.alignX = 'center';
- /**
- * alignment for vertical direction,can be 'top', 'middle', 'bottom'
- * @type {String}
- */
- this.alignY = 'middle';
- /**
- * offset for horizontal direction
- * @type {Number}
- */
- this.offsetX = null;
- /**
- * offset for vertical direction
- * @type {Number}
- */
- this.offsetY = null;
- /**
- * the html string
- *@type {String | Function}
- */
- this.html = null;
- }; // override paint
- _proto.render = function render(coord, container) {
- var self = this;
- var position = self.parsePoint(coord, self.position);
- if (!position) {
- return;
- }
- var myNode = createDom(self.html);
- myNode = modifyCSS(myNode, {
- position: 'absolute',
- top: Math.floor(position.y) + 'px',
- left: Math.floor(position.x) + 'px',
- visibility: 'hidden'
- });
- var canvasDom = container.get('canvas').get('el');
- var parentNode = canvasDom.parentNode;
- parentNode = modifyCSS(parentNode, {
- position: 'relative'
- });
- var wrapperNode = createDom('<div class="guideWapper" style="position: absolute;top: 0; left: 0;"></div>');
- parentNode.appendChild(wrapperNode);
- wrapperNode.appendChild(myNode);
- var canvasOffsetTop = canvasDom.offsetTop;
- var canvasOffsetLeft = canvasDom.offsetLeft;
- var alignX = self.alignX,
- alignY = self.alignY,
- offsetX = self.offsetX,
- offsetY = self.offsetY;
- var width = Util.getWidth(myNode);
- var height = Util.getHeight(myNode);
- var newOffset = getOffsetFromAlign(alignX, alignY, width, height);
- position.x = position.x + newOffset[0] + canvasOffsetLeft;
- position.y = position.y + newOffset[1] + canvasOffsetTop;
- if (offsetX) {
- position.x += offsetX;
- }
- if (offsetY) {
- position.y += offsetY;
- }
- modifyCSS(myNode, {
- top: Math.floor(position.y) + 'px',
- left: Math.floor(position.x) + 'px',
- visibility: 'visible'
- });
- self.element = wrapperNode;
- };
- _proto.remove = function remove() {
- var element = this.element;
- element && element.parentNode && element.parentNode.removeChild(element);
- };
- return Html;
- }(GuideBase);
- GuideBase.Html = Html;
- module.exports = Html;
- /***/ }),
- /* 110 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(12);
- var Line =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Line, _GuideBase);
- function Line() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Line.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'line';
- this.start = [];
- this.end = [];
- this.style = {
- stroke: '#000',
- lineWidth: 1
- };
- };
- _proto.render = function render(coord, container) {
- var points = [];
- points[0] = this.parsePoint(coord, this.start);
- points[1] = this.parsePoint(coord, this.end);
- if (!points[0] || !points[1]) {
- return;
- }
- var shape = container.addShape('Line', {
- className: 'guide-line',
- attrs: Util.mix({
- x1: points[0].x,
- y1: points[0].y,
- x2: points[1].x,
- y2: points[1].y
- }, this.style)
- });
- this.element = shape;
- return shape;
- };
- return Line;
- }(GuideBase);
- GuideBase.Line = Line;
- module.exports = Line;
- /***/ }),
- /* 111 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(12);
- var Rect =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Rect, _GuideBase);
- function Rect() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Rect.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'rect';
- this.start = [];
- this.end = [];
- this.style = {
- fill: '#CCD7EB',
- opacity: 0.4
- };
- };
- _proto.render = function render(coord, container) {
- var start = this.parsePoint(coord, this.start);
- var end = this.parsePoint(coord, this.end);
- if (!start || !end) {
- return;
- }
- var shape = container.addShape('rect', {
- className: 'guide-rect',
- attrs: Util.mix({
- x: Math.min(start.x, end.x),
- y: Math.min(start.y, end.y),
- width: Math.abs(end.x - start.x),
- height: Math.abs(start.y - end.y)
- }, this.style)
- });
- this.element = shape;
- return shape;
- };
- return Rect;
- }(GuideBase);
- GuideBase.Rect = Rect;
- module.exports = Rect;
- /***/ }),
- /* 112 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(12);
- var Text =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Text, _GuideBase);
- function Text() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Text.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'text';
- /**
- * the position of text
- * @type {Function | Array}
- */
- this.position = null;
- /**
- * the display content
- * @type {String}
- */
- this.content = null;
- /**
- * style configuration for text
- * @type {Object}
- */
- this.style = {
- fill: '#000'
- };
- /**
- * offset of horizontal direction
- * @type {Number}
- */
- this.offsetX = 0;
- /**
- * offset of vertical direction
- * @type {Number}
- */
- this.offsetY = 0;
- };
- _proto.render = function render(coord, container) {
- var position = this.position;
- var point = this.parsePoint(coord, position);
- if (!point) {
- return;
- }
- var content = this.content,
- style = this.style,
- offsetX = this.offsetX,
- offsetY = this.offsetY;
- if (offsetX) {
- point.x += offsetX;
- }
- if (offsetY) {
- point.y += offsetY;
- }
- var shape = container.addShape('text', {
- className: 'guide-text',
- attrs: Util.mix({
- x: point.x,
- y: point.y,
- text: content
- }, style)
- });
- this.element = shape;
- return shape;
- };
- return Text;
- }(GuideBase);
- GuideBase.Text = Text;
- module.exports = Text;
- /***/ }),
- /* 113 */
- /***/ (function(module, exports, __webpack_require__) {
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Util = __webpack_require__(0);
- var GuideBase = __webpack_require__(12);
- var Tag =
- /*#__PURE__*/
- function (_GuideBase) {
- _inheritsLoose(Tag, _GuideBase);
- function Tag() {
- return _GuideBase.apply(this, arguments) || this;
- }
- var _proto = Tag.prototype;
- _proto._initDefaultCfg = function _initDefaultCfg() {
- this.type = 'tag';
- this.position = null;
- this.content = null;
- this.direct = 'tl';
- this.autoAdjust = true;
- this.offsetX = 0;
- this.offsetY = 0;
- this.side = 4;
- this.background = {
- padding: 5,
- radius: 2,
- fill: '#1890FF'
- };
- this.textStyle = {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'center',
- textBaseline: 'middle'
- };
- this.withPoint = true;
- this.pointStyle = {
- fill: '#1890FF',
- r: 3,
- lineWidth: 1,
- stroke: '#fff'
- };
- };
- _proto._getDirect = function _getDirect(container, point, tagWidth, tagHeight) {
- var direct = this.direct;
- var side = this.side;
- var canvas = container.get('canvas');
- var clientWidth = canvas.get('width');
- var clientHeight = canvas.get('height');
- var x = point.x,
- y = point.y;
- var vertical = direct[0];
- var horizontal = direct[1]; // adjust for vertical direction
- if (vertical === 't' && y - side - tagHeight < 0) {
- vertical = 'b';
- } else if (vertical === 'b' && y + side + tagHeight > clientHeight) {
- vertical = 't';
- } // adjust for horizontal direction
- var diff = vertical === 'c' ? side : 0;
- if (horizontal === 'l' && x - diff - tagWidth < 0) {
- horizontal = 'r';
- } else if (horizontal === 'r' && x + diff + tagWidth > clientWidth) {
- horizontal = 'l';
- } else if (horizontal === 'c') {
- if (tagWidth / 2 + x + diff > clientWidth) {
- horizontal = 'l';
- } else if (x - tagWidth / 2 - diff < 0) {
- horizontal = 'r';
- }
- }
- direct = vertical + horizontal;
- return direct;
- };
- _proto.render = function render(coord, container) {
- var position = this.parsePoint(coord, this.position);
- if (!position) {
- return;
- }
- var content = this.content,
- background = this.background,
- textStyle = this.textStyle;
- var shapes = [];
- var wrapperContainer = container.addGroup({
- className: 'guide-tag'
- });
- if (this.withPoint) {
- var pointShape = wrapperContainer.addShape('Circle', {
- className: 'guide-tag-point',
- attrs: Util.mix({
- x: position.x,
- y: position.y
- }, this.pointStyle)
- });
- shapes.push(pointShape);
- }
- var tagContainer = wrapperContainer.addGroup(); // create a text shape
- var tagText = tagContainer.addShape('text', {
- className: 'guide-tag-text',
- zIndex: 1,
- attrs: Util.mix({
- x: 0,
- y: 0,
- text: content
- }, textStyle)
- });
- shapes.push(tagText); // create background box
- var textBBox = tagText.getBBox();
- var padding = Util.parsePadding(background.padding);
- var tagWidth = textBBox.width + padding[1] + padding[3];
- var tagHeight = textBBox.height + padding[0] + padding[2];
- var yMin = textBBox.minY - padding[0];
- var xMin = textBBox.minX - padding[3];
- var tagBg = tagContainer.addShape('rect', {
- className: 'guide-tag-bg',
- zIndex: -1,
- attrs: Util.mix({
- x: xMin,
- y: yMin,
- width: tagWidth,
- height: tagHeight
- }, background)
- });
- shapes.push(tagBg);
- var direct = this.autoAdjust ? this._getDirect(container, position, tagWidth, tagHeight) : this.direct;
- var side = this.side;
- var x = position.x + this.offsetX;
- var y = position.y + this.offsetY;
- var arrowPoints;
- var radius = Util.parsePadding(background.radius);
- if (direct === 'tl') {
- arrowPoints = [{
- x: tagWidth + xMin - side - 1,
- y: tagHeight + yMin - 1
- }, // 这个 1 是为了防止出现白边
- {
- x: tagWidth + xMin,
- y: tagHeight + yMin - 1
- }, {
- x: tagWidth + xMin,
- y: tagHeight + side + yMin
- }];
- radius[2] = 0;
- x = x - tagWidth;
- y = y - side - tagHeight;
- } else if (direct === 'cl') {
- arrowPoints = [{
- x: tagWidth + xMin - 1,
- y: (tagHeight - side) / 2 + yMin - 1
- }, {
- x: tagWidth + xMin - 1,
- y: (tagHeight + side) / 2 + yMin + 1
- }, {
- x: tagWidth + side + xMin,
- y: tagHeight / 2 + yMin
- }];
- x = x - tagWidth - side;
- y = y - tagHeight / 2;
- } else if (direct === 'bl') {
- arrowPoints = [{
- x: tagWidth + xMin,
- y: -side + yMin
- }, {
- x: tagWidth + xMin - side - 1,
- y: yMin + 1
- }, {
- x: tagWidth + xMin,
- y: yMin + 1
- }];
- radius[1] = 0;
- x = x - tagWidth;
- y = y + side;
- } else if (direct === 'bc') {
- arrowPoints = [{
- x: tagWidth / 2 + xMin,
- y: -side + yMin
- }, {
- x: (tagWidth - side) / 2 + xMin - 1,
- y: yMin + 1
- }, {
- x: (tagWidth + side) / 2 + xMin + 1,
- y: yMin + 1
- }];
- x = x - tagWidth / 2;
- y = y + side;
- } else if (direct === 'br') {
- arrowPoints = [{
- x: xMin,
- y: yMin - side
- }, {
- x: xMin,
- y: yMin + 1
- }, {
- x: xMin + side + 1,
- y: yMin + 1
- }];
- radius[0] = 0;
- y = y + side;
- } else if (direct === 'cr') {
- arrowPoints = [{
- x: xMin - side,
- y: tagHeight / 2 + yMin
- }, {
- x: xMin + 1,
- y: (tagHeight - side) / 2 + yMin - 1
- }, {
- x: xMin + 1,
- y: (tagHeight + side) / 2 + yMin + 1
- }];
- x = x + side;
- y = y - tagHeight / 2;
- } else if (direct === 'tr') {
- arrowPoints = [{
- x: xMin,
- y: tagHeight + side + yMin
- }, {
- x: xMin,
- y: tagHeight + yMin - 1
- }, {
- x: side + xMin + 1,
- y: tagHeight + yMin - 1
- }];
- radius[3] = 0;
- y = y - tagHeight - side;
- } else if (direct === 'tc') {
- arrowPoints = [{
- x: (tagWidth - side) / 2 + xMin - 1,
- y: tagHeight + yMin - 1
- }, {
- x: (tagWidth + side) / 2 + xMin + 1,
- y: tagHeight + yMin - 1
- }, {
- x: tagWidth / 2 + xMin,
- y: tagHeight + side + yMin
- }];
- x = x - tagWidth / 2;
- y = y - tagHeight - side;
- }
- var sideShape = tagContainer.addShape('Polygon', {
- className: 'guide-tag-side',
- zIndex: 0,
- attrs: {
- points: arrowPoints,
- fill: background.fill
- }
- });
- shapes.push(sideShape);
- tagBg.attr('radius', radius);
- tagContainer.moveTo(x - xMin, y - yMin);
- tagContainer.sort();
- this.element = wrapperContainer;
- return shapes;
- };
- return Tag;
- }(GuideBase);
- GuideBase.Tag = Tag;
- module.exports = Tag;
- /***/ }),
- /* 114 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Global = __webpack_require__(1);
- var Tooltip = __webpack_require__(115);
- var Helper = __webpack_require__(26); // Register the default configuration for Tooltip
- Global.tooltip = Util.deepMix({
- triggerOn: ['touchstart', 'touchmove'],
- // triggerOff: 'touchend',
- alwaysShow: false,
- showTitle: false,
- showCrosshairs: false,
- crosshairsStyle: {
- stroke: 'rgba(0, 0, 0, 0.25)',
- lineWidth: 1
- },
- showTooltipMarker: true,
- background: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- titleStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'start',
- textBaseline: 'top'
- },
- nameStyle: {
- fontSize: 12,
- fill: 'rgba(255, 255, 255, 0.65)',
- textAlign: 'start',
- textBaseline: 'middle'
- },
- valueStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'start',
- textBaseline: 'middle'
- },
- showItemMarker: true,
- itemMarkerStyle: {
- radius: 3,
- symbol: 'circle',
- lineWidth: 1,
- stroke: '#fff'
- },
- layout: 'horizontal',
- snap: false
- }, Global.tooltip || {});
- function _getTooltipValueScale(geom) {
- var colorAttr = geom.getAttr('color');
- if (colorAttr) {
- var colorScale = colorAttr.getScale(colorAttr.type);
- if (colorScale.isLinear) {
- return colorScale;
- }
- }
- var xScale = geom.getXScale();
- var yScale = geom.getYScale();
- if (yScale) {
- return yScale;
- }
- return xScale;
- }
- function getTooltipName(geom, origin) {
- var name;
- var nameScale;
- var groupScales = geom._getGroupScales();
- if (groupScales.length) {
- Util.each(groupScales, function (scale) {
- nameScale = scale;
- return false;
- });
- }
- if (nameScale) {
- var field = nameScale.field;
- name = nameScale.getText(origin[field]);
- } else {
- var valueScale = _getTooltipValueScale(geom);
- name = valueScale.alias || valueScale.field;
- }
- return name;
- }
- function getTooltipValue(geom, origin) {
- var scale = _getTooltipValueScale(geom);
- return scale.getText(origin[scale.field]);
- }
- function getTooltipTitle(geom, origin) {
- var position = geom.getAttr('position');
- var field = position.getFields()[0];
- var scale = geom.get('scales')[field];
- return scale.getText(origin[scale.field]);
- }
- function _indexOfArray(items, item) {
- var rst = -1;
- Util.each(items, function (sub, index) {
- if (sub.title === item.title && sub.name === item.name && sub.value === item.value && sub.color === item.color) {
- rst = index;
- return false;
- }
- });
- return rst;
- }
- function _uniqItems(items) {
- var tmp = [];
- Util.each(items, function (item) {
- var index = _indexOfArray(tmp, item);
- if (index === -1) {
- tmp.push(item);
- } else {
- tmp[index] = item;
- }
- });
- return tmp;
- }
- function isEqual(arr1, arr2) {
- return JSON.stringify(arr1) === JSON.stringify(arr2);
- }
- var TooltipController =
- /*#__PURE__*/
- function () {
- function TooltipController(cfg) {
- this.enable = true;
- this.cfg = {};
- this.tooltip = null;
- this.chart = null;
- this.timeStamp = 0;
- Util.mix(this, cfg);
- var chart = this.chart;
- this.canvasDom = chart.get('canvas').get('el');
- }
- var _proto = TooltipController.prototype;
- _proto._setCrosshairsCfg = function _setCrosshairsCfg() {
- var self = this;
- var chart = self.chart;
- var defaultCfg = Util.mix({}, Global.tooltip);
- var geoms = chart.get('geoms');
- var shapes = [];
- Util.each(geoms, function (geom) {
- var type = geom.get('type');
- if (shapes.indexOf(type) === -1) {
- shapes.push(type);
- }
- });
- var coordType = chart.get('coord').type;
- if (geoms.length && (coordType === 'cartesian' || coordType === 'rect')) {
- if (shapes.length === 1 && ['line', 'area', 'path', 'point'].indexOf(shapes[0]) !== -1) {
- Util.mix(defaultCfg, {
- showCrosshairs: true
- });
- }
- }
- return defaultCfg;
- };
- _proto._getMaxLength = function _getMaxLength(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var _cfg = cfg,
- layout = _cfg.layout,
- plotRange = _cfg.plotRange;
- return layout === 'horizontal' ? plotRange.br.x - plotRange.bl.x : plotRange.bl.y - plotRange.tr.y;
- };
- _proto.render = function render() {
- var self = this;
- if (self.tooltip) {
- return;
- }
- var chart = self.chart;
- var canvas = chart.get('canvas');
- var frontPlot = chart.get('frontPlot').addGroup({
- className: 'tooltipContainer',
- zIndex: 10
- });
- var backPlot = chart.get('backPlot').addGroup({
- className: 'tooltipContainer'
- });
- var plotRange = chart.get('plotRange');
- var coord = chart.get('coord');
- var defaultCfg = self._setCrosshairsCfg();
- var cfg = self.cfg;
- cfg = Util.deepMix({
- plotRange: plotRange,
- frontPlot: frontPlot,
- backPlot: backPlot,
- canvas: canvas,
- fixed: coord.transposed || coord.isPolar
- }, defaultCfg, cfg);
- cfg.maxLength = self._getMaxLength(cfg);
- this.cfg = cfg;
- var tooltip = new Tooltip(cfg);
- self.tooltip = tooltip;
- self.bindEvents();
- };
- _proto.clear = function clear() {
- var tooltip = this.tooltip;
- tooltip && tooltip.destroy();
- this.tooltip = null;
- this.prePoint = null;
- this._lastActive = null;
- this.unBindEvents();
- };
- _proto._getTooltipMarkerStyle = function _getTooltipMarkerStyle(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var _cfg2 = cfg,
- type = _cfg2.type,
- items = _cfg2.items;
- var tooltipCfg = this.cfg;
- if (type === 'rect') {
- var x;
- var y;
- var width;
- var height;
- var chart = this.chart;
- var _chart$get = chart.get('plotRange'),
- tl = _chart$get.tl,
- br = _chart$get.br;
- var coord = chart.get('coord');
- var firstItem = items[0];
- var lastItem = items[items.length - 1];
- var intervalWidth = firstItem.width;
- if (coord.transposed) {
- x = tl.x;
- y = lastItem.y - intervalWidth * 0.75;
- width = br.x - tl.x;
- height = firstItem.y - lastItem.y + 1.5 * intervalWidth;
- } else {
- x = firstItem.x - intervalWidth * 0.75;
- y = tl.y;
- width = lastItem.x - firstItem.x + 1.5 * intervalWidth;
- height = br.y - tl.y;
- }
- cfg.style = Util.mix({
- x: x,
- y: y,
- width: width,
- height: height,
- fill: '#CCD6EC',
- opacity: 0.3
- }, tooltipCfg.tooltipMarkerStyle);
- } else {
- cfg.style = Util.mix({
- radius: 4,
- fill: '#fff',
- lineWidth: 2
- }, tooltipCfg.tooltipMarkerStyle);
- }
- return cfg;
- };
- _proto._setTooltip = function _setTooltip(point, items, tooltipMarkerCfg) {
- if (tooltipMarkerCfg === void 0) {
- tooltipMarkerCfg = {};
- }
- var lastActive = this._lastActive;
- var tooltip = this.tooltip;
- var cfg = this.cfg;
- items = _uniqItems(items);
- var chart = this.chart;
- var coord = chart.get('coord');
- var yScale = chart.getYScales()[0];
- var snap = cfg.snap;
- if (snap === false && yScale.isLinear) {
- var invertPoint = coord.invertPoint(point);
- var plot = chart.get('plotRange');
- var tip;
- var pos;
- if (Helper.isPointInPlot(point, plot)) {
- if (coord.transposed) {
- tip = yScale.invert(invertPoint.x);
- pos = point.x;
- tooltip.setXTipContent(tip);
- tooltip.setXTipPosition(pos);
- tooltip.setYCrosshairPosition(pos);
- } else {
- tip = yScale.invert(invertPoint.y);
- pos = point.y;
- tooltip.setYTipContent(tip);
- tooltip.setYTipPosition(pos);
- tooltip.setXCrosshairPosition(pos);
- }
- }
- }
- if (cfg.onShow) {
- cfg.onShow({
- x: point.x,
- y: point.y,
- tooltip: tooltip,
- items: items,
- tooltipMarkerCfg: tooltipMarkerCfg
- });
- }
- if (isEqual(lastActive, items)) {
- if (snap === false && (Util.directionEnabled(cfg.crosshairsType, 'y') || cfg.showYTip)) {
- var canvas = this.chart.get('canvas');
- canvas.draw();
- }
- return;
- }
- this._lastActive = items;
- var onChange = cfg.onChange;
- if (onChange) {
- onChange({
- x: point.x,
- y: point.y,
- tooltip: tooltip,
- items: items,
- tooltipMarkerCfg: tooltipMarkerCfg
- });
- }
- var first = items[0];
- var title = first.title || first.name;
- var xTipPosX = first.x;
- if (items.length > 1) {
- xTipPosX = (items[0].x + items[items.length - 1].x) / 2;
- }
- tooltip.setContent(title, items, coord.transposed);
- tooltip.setPosition(items, point);
- if (coord.transposed) {
- var yTipPosY = first.y;
- if (items.length > 1) {
- yTipPosY = (items[0].y + items[items.length - 1].y) / 2;
- }
- tooltip.setYTipContent(title);
- tooltip.setYTipPosition(yTipPosY);
- tooltip.setXCrosshairPosition(yTipPosY);
- if (snap) {
- tooltip.setXTipContent(first.value);
- tooltip.setXTipPosition(xTipPosX);
- tooltip.setYCrosshairPosition(xTipPosX);
- }
- } else {
- tooltip.setXTipContent(title);
- tooltip.setXTipPosition(xTipPosX);
- tooltip.setYCrosshairPosition(xTipPosX);
- if (snap) {
- tooltip.setYTipContent(first.value);
- tooltip.setYTipPosition(first.y);
- tooltip.setXCrosshairPosition(first.y);
- }
- }
- var markerItems = tooltipMarkerCfg.items;
- if (cfg.showTooltipMarker && markerItems.length) {
- tooltipMarkerCfg = this._getTooltipMarkerStyle(tooltipMarkerCfg);
- tooltip.setMarkers(tooltipMarkerCfg);
- } else {
- tooltip.clearMarkers();
- }
- tooltip.show();
- };
- _proto.showTooltip = function showTooltip(point) {
- var self = this;
- var chart = self.chart;
- var tooltipMarkerType;
- var tooltipMarkerItems = [];
- var items = [];
- var cfg = self.cfg;
- var marker;
- if (cfg.showItemMarker) {
- marker = cfg.itemMarkerStyle;
- }
- var geoms = chart.get('geoms');
- var coord = chart.get('coord');
- Util.each(geoms, function (geom) {
- if (geom.get('visible')) {
- var type = geom.get('type');
- var records = geom.getSnapRecords(point);
- Util.each(records, function (record) {
- if (record.x && record.y) {
- var x = record.x,
- y = record.y,
- _origin = record._origin,
- color = record.color;
- var tooltipItem = {
- x: x,
- y: Util.isArray(y) ? y[1] : y,
- color: color || Global.defaultColor,
- origin: _origin,
- name: getTooltipName(geom, _origin),
- value: getTooltipValue(geom, _origin),
- title: getTooltipTitle(geom, _origin)
- };
- if (marker) {
- tooltipItem.marker = Util.mix({
- fill: color || Global.defaultColor
- }, marker);
- }
- items.push(tooltipItem);
- if (['line', 'area', 'path'].indexOf(type) !== -1) {
- tooltipMarkerType = 'circle';
- tooltipMarkerItems.push(tooltipItem);
- } else if (type === 'interval' && (coord.type === 'cartesian' || coord.type === 'rect')) {
- tooltipMarkerType = 'rect';
- tooltipItem.width = geom.getSize(record._origin);
- tooltipMarkerItems.push(tooltipItem);
- }
- }
- });
- }
- });
- if (items.length) {
- var tooltipMarkerCfg = {
- items: tooltipMarkerItems,
- type: tooltipMarkerType
- };
- self._setTooltip(point, items, tooltipMarkerCfg);
- } else {
- self.hideTooltip();
- }
- };
- _proto.hideTooltip = function hideTooltip() {
- var cfg = this.cfg;
- this._lastActive = null;
- var tooltip = this.tooltip;
- if (tooltip) {
- tooltip.hide();
- if (cfg.onHide) {
- cfg.onHide({
- tooltip: tooltip
- });
- }
- var canvas = this.chart.get('canvas');
- canvas.draw();
- }
- };
- _proto.handleShowEvent = function handleShowEvent(ev) {
- var chart = this.chart;
- if (!this.enable || chart.get('_closeTooltip')) return;
- var plot = chart.get('plotRange');
- var point = Util.createEvent(ev, chart);
- if (!Helper.isPointInPlot(point, plot) && !this.cfg.alwaysShow) {
- // not in chart plot
- this.hideTooltip();
- return;
- }
- var lastTimeStamp = this.timeStamp;
- var timeStamp = +new Date();
- if (timeStamp - lastTimeStamp > 16) {
- this.showTooltip(point);
- this.timeStamp = timeStamp;
- }
- };
- _proto.handleHideEvent = function handleHideEvent() {
- var chart = this.chart;
- if (!this.enable || chart.get('_closeTooltip')) return;
- this.hideTooltip();
- };
- _proto.handleDocEvent = function handleDocEvent(ev) {
- var chart = this.chart;
- if (!this.enable || chart.get('_closeTooltip')) return;
- var canvasDom = this.canvasDom;
- if (ev.target !== canvasDom) {
- this.hideTooltip();
- }
- };
- _proto._handleEvent = function _handleEvent(methodName, method, action) {
- var canvasDom = this.canvasDom;
- Util.each([].concat(methodName), function (aMethod) {
- if (action === 'bind') {
- Util.addEventListener(canvasDom, aMethod, method);
- } else {
- Util.removeEventListener(canvasDom, aMethod, method);
- }
- });
- };
- _proto.bindEvents = function bindEvents() {
- var cfg = this.cfg;
- var triggerOn = cfg.triggerOn,
- triggerOff = cfg.triggerOff,
- alwaysShow = cfg.alwaysShow;
- var showMethod = Util.wrapBehavior(this, 'handleShowEvent');
- var hideMethod = Util.wrapBehavior(this, 'handleHideEvent');
- triggerOn && this._handleEvent(triggerOn, showMethod, 'bind');
- triggerOff && this._handleEvent(triggerOff, hideMethod, 'bind'); // TODO: 当用户点击 canvas 外的事件时 tooltip 消失
- if (!alwaysShow) {
- var docMethod = Util.wrapBehavior(this, 'handleDocEvent');
- Util.isBrowser && Util.addEventListener(document, 'touchstart', docMethod);
- }
- };
- _proto.unBindEvents = function unBindEvents() {
- var cfg = this.cfg;
- var triggerOn = cfg.triggerOn,
- triggerOff = cfg.triggerOff,
- alwaysShow = cfg.alwaysShow;
- var showMethod = Util.getWrapBehavior(this, 'handleShowEvent');
- var hideMethod = Util.getWrapBehavior(this, 'handleHideEvent');
- triggerOn && this._handleEvent(triggerOn, showMethod, 'unBind');
- triggerOff && this._handleEvent(triggerOff, hideMethod, 'unBind');
- if (!alwaysShow) {
- var docMethod = Util.getWrapBehavior(this, 'handleDocEvent');
- Util.isBrowser && Util.removeEventListener(document, 'touchstart', docMethod);
- }
- };
- return TooltipController;
- }();
- module.exports = {
- init: function init(chart) {
- var tooltipController = new TooltipController({
- chart: chart
- });
- chart.set('tooltipController', tooltipController);
- chart.tooltip = function (enable, cfg) {
- if (Util.isObject(enable)) {
- cfg = enable;
- enable = true;
- }
- tooltipController.enable = enable;
- if (cfg) {
- tooltipController.cfg = cfg;
- }
- return this;
- };
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var tooltipController = chart.get('tooltipController');
- tooltipController.render();
- chart.showTooltip = function (point) {
- tooltipController.showTooltip(point);
- return this;
- };
- chart.hideTooltip = function () {
- tooltipController.hideTooltip();
- return this;
- };
- },
- clearInner: function clearInner(chart) {
- var tooltipController = chart.get('tooltipController');
- tooltipController.clear();
- }
- };
- /***/ }),
- /* 115 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Marker = __webpack_require__(90);
- var Container = __webpack_require__(91);
- var TextBox = __webpack_require__(116);
- var GAP = 4;
- /**
- * TODOList:
- * 1. 移除 fixed 参数
- */
- var Tooltip =
- /*#__PURE__*/
- function () {
- var _proto = Tooltip.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- /**
- * wether show the crosshairs
- * @type {Object}
- */
- showCrosshairs: false,
- /**
- * the style for crosshairs
- * @type {Object}
- */
- crosshairsStyle: {
- stroke: 'rgba(0, 0, 0, 0.25)',
- lineWidth: 1
- },
- /**
- * the type of crosshairs, optional value is 'x', 'y' or 'xy', default is 'y'
- */
- crosshairsType: 'y',
- /**
- * show or hide the x axis tip
- */
- showXTip: false,
- /**
- * show or hide the y axis tip
- */
- showYTip: false,
- xTip: null,
- xTipBackground: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- yTip: null,
- yTipBackground: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- /**
- * the style for tooltip container's background
- * @type {Object}
- */
- background: null,
- /**
- * layout, can be horizontal or vertical
- * @type {String}
- */
- layout: 'horizontal',
- offsetX: 0,
- offsetY: 0
- };
- };
- function Tooltip(cfg) {
- Util.deepMix(this, this.getDefaultCfg(), cfg);
- var frontPlot = this.frontPlot,
- custom = this.custom;
- if (!custom) {
- // custom means user do customize
- var container = new Container(Util.mix({
- parent: frontPlot,
- zIndex: 3
- }, cfg));
- this.container = container;
- var fixed = this.fixed,
- background = this.background;
- if (!fixed) {
- this.tooltipArrow = frontPlot.addShape('Polygon', {
- className: 'tooltip-arrow',
- visible: false,
- zIndex: 2,
- attrs: Util.mix({
- points: []
- }, background)
- });
- }
- }
- if (this.showXTip) {
- var xTipBackground = this.xTipBackground;
- var xTipBox = new TextBox({
- className: 'xTip',
- background: xTipBackground,
- visible: false
- });
- frontPlot.add(xTipBox.container);
- this.xTipBox = xTipBox;
- }
- if (this.showYTip) {
- var yTipBackground = this.yTipBackground;
- var yTipBox = new TextBox({
- className: 'yTip',
- background: yTipBackground,
- visible: false
- });
- frontPlot.add(yTipBox.container);
- this.yTipBox = yTipBox;
- }
- if (this.showCrosshairs) {
- this._renderCrosshairs();
- }
- frontPlot.sort();
- }
- _proto.setContent = function setContent(title, items) {
- this.title = title;
- this.items = items;
- if (!this.custom) {
- var container = this.container;
- container.setTitle(title);
- container.setItems(items);
- }
- };
- _proto.setYTipContent = function setYTipContent(val) {
- var yTip = this.yTip;
- if (Util.isFunction(yTip)) {
- val = yTip(val);
- } else {
- val = Util.mix({
- text: val
- }, yTip);
- }
- this.yTipBox && this.yTipBox.updateContent(val);
- };
- _proto.setYTipPosition = function setYTipPosition(pos) {
- var plotRange = this.plotRange;
- var crosshairsShapeX = this.crosshairsShapeX;
- if (this.showYTip) {
- var yTipBox = this.yTipBox;
- var yTipHeight = yTipBox.getHeight();
- var yTipWidth = yTipBox.getWidth();
- var posX = plotRange.tl.x - yTipWidth;
- var posY = pos - yTipHeight / 2;
- if (posY <= plotRange.tl.y) {
- posY = plotRange.tl.y;
- }
- if (posY + yTipHeight >= plotRange.br.y) {
- posY = plotRange.br.y - yTipHeight;
- }
- if (posX < 0) {
- posX = plotRange.tl.x;
- crosshairsShapeX && crosshairsShapeX.attr('x1', plotRange.tl.x + yTipWidth);
- }
- yTipBox.updatePosition(posX, posY);
- }
- };
- _proto.setXTipContent = function setXTipContent(val) {
- var xTip = this.xTip;
- if (Util.isFunction(xTip)) {
- val = xTip(val);
- } else {
- val = Util.mix({
- text: val
- }, xTip);
- }
- this.xTipBox && this.xTipBox.updateContent(val);
- };
- _proto.setXTipPosition = function setXTipPosition(pos) {
- var showXTip = this.showXTip,
- canvas = this.canvas,
- plotRange = this.plotRange,
- xTipBox = this.xTipBox,
- crosshairsShapeY = this.crosshairsShapeY;
- if (showXTip) {
- // const el = canvas.get('el');
- // const canvasHeight = Util.getHeight(el);
- var canvasHeight = canvas.get('height');
- var xTipWidth = xTipBox.getWidth();
- var xTipHeight = xTipBox.getHeight();
- var posX = pos - xTipWidth / 2;
- var posY = plotRange.br.y;
- if (posX <= plotRange.tl.x) {
- posX = plotRange.tl.x;
- }
- if (posX + xTipWidth >= plotRange.tr.x) {
- posX = plotRange.tr.x - xTipWidth;
- }
- if (canvasHeight - posY < xTipHeight) {
- posY -= xTipHeight;
- }
- xTipBox.updatePosition(posX, posY);
- crosshairsShapeY && crosshairsShapeY.attr('y1', posY);
- }
- };
- _proto.setXCrosshairPosition = function setXCrosshairPosition(pos) {
- this.crosshairsShapeX && this.crosshairsShapeX.moveTo(0, pos);
- };
- _proto.setYCrosshairPosition = function setYCrosshairPosition(pos) {
- this.crosshairsShapeY && this.crosshairsShapeY.moveTo(pos, 0);
- };
- _proto.setPosition = function setPosition(items) {
- var container = this.container,
- plotRange = this.plotRange,
- offsetX = this.offsetX,
- offsetY = this.offsetY,
- fixed = this.fixed,
- tooltipArrow = this.tooltipArrow;
- if (!container) {
- return;
- }
- var containerBBox = container.container.getBBox();
- var minX = containerBBox.minX,
- minY = containerBBox.minY,
- width = containerBBox.width,
- height = containerBBox.height;
- var tl = plotRange.tl,
- tr = plotRange.tr;
- var posX = 0;
- var posY = tl.y - height - GAP + offsetY;
- if (fixed) {
- var x = (tl.x + tr.x) / 2;
- posX = x - width / 2 + offsetX;
- } else {
- var _x;
- if (items.length > 1) {
- _x = (items[0].x + items[items.length - 1].x) / 2;
- } else {
- _x = items[0].x;
- }
- posX = _x - width / 2 + offsetX;
- if (posX < tl.x) {
- posX = tl.x;
- }
- if (posX + width > tr.x) {
- posX = tr.x - width;
- }
- if (tooltipArrow) {
- tooltipArrow.attr('points', [{
- x: _x - 3,
- y: tl.y - GAP + offsetY
- }, {
- x: _x + 3,
- y: tl.y - GAP + offsetY
- }, {
- x: _x,
- y: tl.y + offsetY
- }]);
- var backShape = container.backShape;
- var radius = Util.parsePadding(backShape.attr('radius'));
- if (_x === tl.x) {
- radius[3] = 0;
- tooltipArrow.attr('points', [{
- x: tl.x,
- y: tl.y + offsetY
- }, {
- x: tl.x,
- y: tl.y - GAP + offsetY
- }, {
- x: tl.x + GAP,
- y: tl.y - GAP + offsetY
- }]);
- } else if (_x === tr.x) {
- radius[2] = 0;
- tooltipArrow.attr('points', [{
- x: tr.x,
- y: tl.y + offsetY
- }, {
- x: tr.x - GAP,
- y: tl.y - GAP + offsetY
- }, {
- x: tr.x,
- y: tl.y - GAP + offsetY
- }]);
- }
- backShape.attr('radius', radius);
- }
- }
- container.moveTo(posX - minX, posY - minY);
- };
- _proto.setMarkers = function setMarkers(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var self = this;
- var _cfg = cfg,
- items = _cfg.items,
- style = _cfg.style,
- type = _cfg.type;
- var markerGroup = self._getMarkerGroup(type);
- if (type === 'circle') {
- for (var i = 0, length = items.length; i < length; i++) {
- var item = items[i];
- var marker = new Marker({
- className: 'tooltip-circle-marker',
- attrs: Util.mix({
- x: item.x,
- y: item.y,
- stroke: item.color
- }, style)
- });
- markerGroup.add(marker);
- }
- } else {
- markerGroup.addShape('rect', {
- className: 'tooltip-rect-marker',
- attrs: style
- });
- }
- };
- _proto.clearMarkers = function clearMarkers() {
- var markerGroup = this.markerGroup;
- markerGroup && markerGroup.clear();
- };
- _proto.show = function show() {
- var crosshairsShapeX = this.crosshairsShapeX;
- var crosshairsShapeY = this.crosshairsShapeY;
- var markerGroup = this.markerGroup;
- var container = this.container;
- var tooltipArrow = this.tooltipArrow;
- var xTipBox = this.xTipBox;
- var yTipBox = this.yTipBox;
- var canvas = this.canvas;
- crosshairsShapeX && crosshairsShapeX.show();
- crosshairsShapeY && crosshairsShapeY.show();
- markerGroup && markerGroup.show();
- container && container.show();
- tooltipArrow && tooltipArrow.show();
- xTipBox && xTipBox.show();
- yTipBox && yTipBox.show();
- canvas.draw();
- };
- _proto.hide = function hide() {
- var crosshairsShapeX = this.crosshairsShapeX;
- var crosshairsShapeY = this.crosshairsShapeY;
- var markerGroup = this.markerGroup;
- var container = this.container;
- var tooltipArrow = this.tooltipArrow;
- var xTipBox = this.xTipBox;
- var yTipBox = this.yTipBox;
- crosshairsShapeX && crosshairsShapeX.hide();
- crosshairsShapeY && crosshairsShapeY.hide();
- markerGroup && markerGroup.hide();
- container && container.hide();
- tooltipArrow && tooltipArrow.hide();
- xTipBox && xTipBox.hide();
- yTipBox && yTipBox.hide();
- };
- _proto.destroy = function destroy() {
- var crosshairsShapeX = this.crosshairsShapeX;
- var crosshairsShapeY = this.crosshairsShapeY;
- var markerGroup = this.markerGroup;
- var container = this.container;
- var tooltipArrow = this.tooltipArrow;
- var xTipBox = this.xTipBox;
- var yTipBox = this.yTipBox;
- crosshairsShapeX && crosshairsShapeX.remove(true);
- crosshairsShapeY && crosshairsShapeY.remove(true);
- markerGroup && markerGroup.remove(true);
- tooltipArrow && tooltipArrow.remove(true);
- container && container.clear();
- xTipBox && xTipBox.clear();
- yTipBox && yTipBox.clear();
- this.destroyed = true;
- };
- _proto._getMarkerGroup = function _getMarkerGroup(type) {
- var markerGroup = this.markerGroup;
- if (!markerGroup) {
- if (type === 'circle') {
- markerGroup = this.frontPlot.addGroup({
- zIndex: 1
- });
- this.frontPlot.sort();
- } else {
- markerGroup = this.backPlot.addGroup();
- }
- this.markerGroup = markerGroup;
- } else {
- markerGroup.clear();
- }
- return markerGroup;
- };
- _proto._renderCrosshairs = function _renderCrosshairs() {
- var crosshairsType = this.crosshairsType,
- crosshairsStyle = this.crosshairsStyle,
- frontPlot = this.frontPlot,
- plotRange = this.plotRange;
- var tl = plotRange.tl,
- br = plotRange.br;
- if (Util.directionEnabled(crosshairsType, 'x')) {
- this.crosshairsShapeX = frontPlot.addShape('Line', {
- className: 'tooltip-crosshairs-x',
- zIndex: 0,
- visible: false,
- attrs: Util.mix({
- x1: tl.x,
- y1: 0,
- x2: br.x,
- y2: 0
- }, crosshairsStyle)
- });
- }
- if (Util.directionEnabled(crosshairsType, 'y')) {
- this.crosshairsShapeY = frontPlot.addShape('Line', {
- className: 'tooltip-crosshairs-y',
- zIndex: 0,
- visible: false,
- attrs: Util.mix({
- x1: 0,
- y1: br.y,
- x2: 0,
- y2: tl.y
- }, crosshairsStyle)
- });
- }
- };
- return Tooltip;
- }();
- module.exports = Tooltip;
- /***/ }),
- /* 116 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var _require = __webpack_require__(5),
- Group = _require.Group;
- var TextBox =
- /*#__PURE__*/
- function () {
- var _proto = TextBox.prototype;
- _proto.getDefaultCfg = function getDefaultCfg() {
- return {
- x: 0,
- y: 0,
- content: '',
- textStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'center',
- textBaseline: 'middle'
- },
- background: {
- radius: 1,
- fill: 'rgba(0, 0, 0, 0.65)',
- padding: [3, 5]
- },
- width: 0,
- height: 0,
- className: ''
- };
- };
- function TextBox(cfg) {
- Util.deepMix(this, this.getDefaultCfg(), cfg);
- this._init();
- var content = this.content,
- x = this.x,
- y = this.y;
- if (!Util.isNil(content)) {
- this.updateContent(content);
- }
- this.updatePosition(x, y);
- }
- _proto._init = function _init() {
- var content = this.content,
- textStyle = this.textStyle,
- background = this.background,
- className = this.className,
- visible = this.visible;
- var container = new Group({
- className: className,
- zIndex: 0,
- visible: visible
- });
- var text = container.addShape('Text', {
- className: className + '-text',
- zIndex: 1,
- attrs: Util.mix({
- text: content,
- x: 0,
- y: 0
- }, textStyle)
- });
- var backgroundShape = container.addShape('Rect', {
- className: className + '-bg',
- zIndex: -1,
- attrs: Util.mix({
- x: 0,
- y: 0,
- width: 0,
- height: 0
- }, background)
- });
- container.sort();
- this.container = container;
- this.textShape = text;
- this.backgroundShape = backgroundShape;
- };
- _proto._getBBox = function _getBBox() {
- var textShape = this.textShape;
- var background = this.background;
- var textBBox = textShape.getBBox();
- var padding = Util.parsePadding(background.padding);
- var width = textBBox.width + padding[1] + padding[3];
- var height = textBBox.height + padding[0] + padding[2];
- var x = textBBox.minX - padding[3];
- var y = textBBox.minY - padding[0];
- return {
- x: x,
- y: y,
- width: width,
- height: height
- };
- };
- _proto.updateContent = function updateContent(text) {
- var textShape = this.textShape,
- backgroundShape = this.backgroundShape;
- if (!Util.isNil(text)) {
- if (!Util.isObject(text)) {
- text = {
- text: text
- };
- }
- textShape.attr(text); // update box shape
- var _this$_getBBox = this._getBBox(),
- x = _this$_getBBox.x,
- y = _this$_getBBox.y,
- tipWidth = _this$_getBBox.width,
- tipHeight = _this$_getBBox.height;
- var width = this.width || tipWidth;
- var height = this.height || tipHeight;
- backgroundShape.attr({
- x: x,
- y: y,
- width: width,
- height: height
- });
- this._width = width;
- this._height = height;
- this.content = text.text;
- }
- };
- _proto.updatePosition = function updatePosition(x, y) {
- var container = this.container;
- var _this$_getBBox2 = this._getBBox(),
- xMin = _this$_getBBox2.x,
- yMin = _this$_getBBox2.y;
- container.moveTo(x - xMin, y - yMin);
- this.x = x - xMin;
- this.y = y - yMin;
- };
- _proto.getWidth = function getWidth() {
- return this._width;
- };
- _proto.getHeight = function getHeight() {
- return this._height;
- };
- _proto.show = function show() {
- this.container.show();
- };
- _proto.hide = function hide() {
- this.container.hide();
- };
- _proto.clear = function clear() {
- var container = this.container;
- container.clear();
- container.remove(true);
- this.container = null;
- this.textShape = null;
- this.backgroundShape = null;
- };
- return TextBox;
- }();
- module.exports = TextBox;
- /***/ }),
- /* 117 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var Guide = __webpack_require__(12);
- var Global = __webpack_require__(1); // register the default configuration for Guide
- Global.guide = Util.deepMix({
- line: {
- style: {
- stroke: '#a3a3a3',
- lineWidth: 1
- },
- top: true
- },
- text: {
- style: {
- fill: '#787878',
- textAlign: 'center',
- textBaseline: 'middle'
- },
- offsetX: 0,
- offsetY: 0,
- top: true
- },
- rect: {
- style: {
- fill: '#fafafa'
- },
- top: false
- },
- arc: {
- style: {
- stroke: '#a3a3a3'
- },
- top: true
- },
- html: {
- offsetX: 0,
- offsetY: 0,
- alignX: 'center',
- alignY: 'middle'
- },
- tag: {
- top: true,
- offsetX: 0,
- offsetY: 0,
- side: 4,
- background: {
- padding: 5,
- radius: 2,
- fill: '#1890FF'
- },
- textStyle: {
- fontSize: 12,
- fill: '#fff',
- textAlign: 'center',
- textBaseline: 'middle'
- }
- },
- point: {
- top: true,
- offsetX: 0,
- offsetY: 0,
- style: {
- fill: '#fff',
- r: 3,
- lineWidth: 2,
- stroke: '#1890ff'
- }
- }
- }, Global.guide || {});
- var GuideController =
- /*#__PURE__*/
- function () {
- function GuideController(cfg) {
- this.guides = [];
- this.xScale = null;
- this.yScales = null;
- this.guideShapes = [];
- Util.mix(this, cfg);
- }
- var _proto = GuideController.prototype;
- _proto._toString = function _toString(position) {
- if (Util.isFunction(position)) {
- position = position(this.xScale, this.yScales);
- }
- position = position.toString();
- return position;
- };
- _proto._getId = function _getId(shape, guide) {
- var id = guide.id;
- if (!id) {
- var type = guide.type;
- if (type === 'arc' || type === 'line' || type === 'rect') {
- id = this._toString(guide.start) + '-' + this._toString(guide.end);
- } else {
- id = this._toString(guide.position);
- }
- }
- return id;
- };
- _proto.paint = function paint(coord) {
- var self = this;
- var chart = self.chart,
- guides = self.guides,
- xScale = self.xScale,
- yScales = self.yScales;
- var guideShapes = [];
- Util.each(guides, function (guide, idx) {
- guide.xScale = xScale;
- guide.yScales = yScales;
- var container;
- if (guide.type === 'regionFilter') {
- // TODO: RegionFilter support animation
- guide.chart = chart;
- } else {
- container = guide.top ? self.frontPlot : self.backPlot;
- }
- guide.coord = coord;
- guide.container = container;
- guide.canvas = chart.get('canvas');
- var shape = guide.render(coord, container);
- if (shape) {
- var id = self._getId(shape, guide);
- [].concat(shape).forEach(function (s) {
- s._id = s.get('className') + '-' + id;
- s.set('index', idx);
- guideShapes.push(s);
- });
- }
- });
- self.guideShapes = guideShapes;
- };
- _proto.clear = function clear() {
- this.reset();
- this.guides = [];
- return this;
- };
- _proto.reset = function reset() {
- var guides = this.guides;
- Util.each(guides, function (guide) {
- guide.remove();
- });
- };
- _proto._createGuide = function _createGuide(type, cfg) {
- var ClassName = Util.upperFirst(type);
- var guide = new Guide[ClassName](Util.deepMix({}, Global.guide[type], cfg));
- this.guides.push(guide);
- return guide;
- };
- _proto.line = function line(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('line', cfg);
- };
- _proto.text = function text(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('text', cfg);
- };
- _proto.arc = function arc(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('arc', cfg);
- };
- _proto.html = function html(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('html', cfg);
- };
- _proto.rect = function rect(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('rect', cfg);
- };
- _proto.tag = function tag(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('tag', cfg);
- };
- _proto.point = function point(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('point', cfg);
- };
- _proto.regionFilter = function regionFilter(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- return this._createGuide('regionFilter', cfg);
- };
- return GuideController;
- }();
- module.exports = {
- init: function init(chart) {
- var guideController = new GuideController({
- frontPlot: chart.get('frontPlot').addGroup({
- zIndex: 20,
- className: 'guideContainer'
- }),
- backPlot: chart.get('backPlot').addGroup({
- className: 'guideContainer'
- })
- });
- chart.set('guideController', guideController);
- /**
- * 为图表添加 guide
- * @return {GuideController} 返回 guide 控制器
- */
- chart.guide = function () {
- return guideController;
- };
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var guideController = chart.get('guideController');
- if (!guideController.guides.length) {
- return;
- }
- var xScale = chart.getXScale();
- var yScales = chart.getYScales();
- var coord = chart.get('coord');
- guideController.xScale = xScale;
- guideController.yScales = yScales;
- guideController.chart = chart; // for regionFilter
- guideController.paint(coord);
- },
- clear: function clear(chart) {
- chart.get('guideController').clear();
- },
- repaint: function repaint(chart) {
- chart.get('guideController').reset();
- }
- };
- /***/ }),
- /* 118 */
- /***/ (function(module, exports, __webpack_require__) {
- var Util = __webpack_require__(0);
- var List = __webpack_require__(91);
- var Global = __webpack_require__(1);
- var LEGEND_GAP = 12;
- var MARKER_SIZE = 3;
- var DEFAULT_CFG = {
- itemMarginBottom: 12,
- itemGap: 10,
- showTitle: false,
- titleStyle: {
- fontSize: 12,
- fill: '#808080',
- textAlign: 'start',
- textBaseline: 'top'
- },
- nameStyle: {
- fill: '#808080',
- fontSize: 12,
- textAlign: 'start',
- textBaseline: 'middle'
- },
- valueStyle: {
- fill: '#000000',
- fontSize: 12,
- textAlign: 'start',
- textBaseline: 'middle'
- },
- unCheckStyle: {
- fill: '#bfbfbf'
- },
- itemWidth: 'auto',
- wordSpace: 6,
- selectedMode: 'multiple' // 'multiple' or 'single'
- }; // Register the default configuration for Legend
- Global.legend = Util.deepMix({
- common: DEFAULT_CFG,
- // common legend configuration
- right: Util.mix({
- position: 'right',
- layout: 'vertical'
- }, DEFAULT_CFG),
- left: Util.mix({
- position: 'left',
- layout: 'vertical'
- }, DEFAULT_CFG),
- top: Util.mix({
- position: 'top',
- layout: 'horizontal'
- }, DEFAULT_CFG),
- bottom: Util.mix({
- position: 'bottom',
- layout: 'horizontal'
- }, DEFAULT_CFG)
- }, Global.legend || {});
- function getPaddingByPos(pos, appendPadding) {
- var padding = 0;
- appendPadding = Util.parsePadding(appendPadding);
- switch (pos) {
- case 'top':
- padding = appendPadding[0];
- break;
- case 'right':
- padding = appendPadding[1];
- break;
- case 'bottom':
- padding = appendPadding[2];
- break;
- case 'left':
- padding = appendPadding[3];
- break;
- default:
- break;
- }
- return padding;
- }
- var LegendController =
- /*#__PURE__*/
- function () {
- function LegendController(cfg) {
- this.legendCfg = {};
- this.enable = true;
- this.position = 'top';
- Util.mix(this, cfg);
- var chart = this.chart;
- this.canvasDom = chart.get('canvas').get('el');
- this.clear();
- }
- var _proto = LegendController.prototype;
- _proto.addLegend = function addLegend(scale, items, filterVals) {
- var self = this;
- var legendCfg = self.legendCfg;
- var field = scale.field;
- var fieldCfg = legendCfg[field];
- if (fieldCfg === false) {
- return null;
- }
- if (fieldCfg && fieldCfg.custom) {
- self.addCustomLegend(field);
- } else {
- var position = legendCfg.position || self.position;
- if (fieldCfg && fieldCfg.position) {
- position = fieldCfg.position;
- }
- if (scale.isCategory) {
- self._addCategoryLegend(scale, items, position, filterVals);
- }
- }
- };
- _proto.addCustomLegend = function addCustomLegend(field) {
- var self = this;
- var legendCfg = self.legendCfg;
- if (field && legendCfg[field]) {
- legendCfg = legendCfg[field];
- }
- var position = legendCfg.position || self.position;
- var legends = self.legends;
- legends[position] = legends[position] || [];
- var items = legendCfg.items;
- if (!items) {
- return null;
- }
- var container = self.container;
- Util.each(items, function (item) {
- if (!Util.isPlainObject(item.marker)) {
- item.marker = {
- symbol: item.marker || 'circle',
- fill: item.fill,
- radius: MARKER_SIZE
- };
- } else {
- item.marker.radius = item.marker.radius || MARKER_SIZE;
- }
- item.checked = Util.isNil(item.checked) ? true : item.checked;
- item.name = item.name || item.value;
- });
- var legend = new List(Util.deepMix({}, Global.legend[position], legendCfg, {
- maxLength: self._getMaxLength(position),
- items: items,
- parent: container
- }));
- legends[position].push(legend);
- };
- _proto.clear = function clear() {
- var legends = this.legends;
- Util.each(legends, function (legendItems) {
- Util.each(legendItems, function (legend) {
- legend.clear();
- });
- });
- this.legends = {};
- this.unBindEvents();
- };
- _proto._isFiltered = function _isFiltered(scale, values, value) {
- var rst = false;
- Util.each(values, function (val) {
- rst = rst || scale.getText(val) === scale.getText(value);
- if (rst) {
- return false;
- }
- });
- return rst;
- };
- _proto._getMaxLength = function _getMaxLength(position) {
- var chart = this.chart;
- var appendPadding = Util.parsePadding(chart.get('appendPadding'));
- return position === 'right' || position === 'left' ? chart.get('height') - (appendPadding[0] + appendPadding[2]) : chart.get('width') - (appendPadding[1] + appendPadding[3]);
- };
- _proto._addCategoryLegend = function _addCategoryLegend(scale, items, position, filterVals) {
- var self = this;
- var legendCfg = self.legendCfg,
- legends = self.legends,
- container = self.container,
- chart = self.chart;
- var field = scale.field;
- legends[position] = legends[position] || [];
- var symbol = 'circle';
- if (legendCfg[field] && legendCfg[field].marker) {
- symbol = legendCfg[field].marker;
- } else if (legendCfg.marker) {
- symbol = legendCfg.marker;
- }
- Util.each(items, function (item) {
- if (Util.isPlainObject(symbol)) {
- Util.mix(item.marker, symbol);
- } else {
- item.marker.symbol = symbol;
- }
- if (filterVals) {
- item.checked = self._isFiltered(scale, filterVals, item.dataValue);
- }
- });
- var legendItems = chart.get('legendItems');
- legendItems[field] = items;
- var lastCfg = Util.deepMix({}, Global.legend[position], legendCfg[field] || legendCfg, {
- maxLength: self._getMaxLength(position),
- items: items,
- field: field,
- filterVals: filterVals,
- parent: container
- });
- if (lastCfg.showTitle) {
- Util.deepMix(lastCfg, {
- title: scale.alias || scale.field
- });
- }
- var legend = new List(lastCfg);
- legends[position].push(legend);
- return legend;
- };
- _proto._alignLegend = function _alignLegend(legend, pre, position) {
- var self = this;
- var _self$plotRange = self.plotRange,
- tl = _self$plotRange.tl,
- bl = _self$plotRange.bl;
- var chart = self.chart;
- var offsetX = legend.offsetX || 0;
- var offsetY = legend.offsetY || 0;
- var chartWidth = chart.get('width');
- var chartHeight = chart.get('height');
- var appendPadding = Util.parsePadding(chart.get('appendPadding'));
- var legendHeight = legend.getHeight();
- var legendWidth = legend.getWidth();
- var x = 0;
- var y = 0;
- if (position === 'left' || position === 'right') {
- var verticalAlign = legend.verticalAlign || 'middle';
- var height = Math.abs(tl.y - bl.y);
- x = position === 'left' ? appendPadding[3] : chartWidth - legendWidth - appendPadding[1];
- y = (height - legendHeight) / 2 + tl.y;
- if (verticalAlign === 'top') {
- y = tl.y;
- } else if (verticalAlign === 'bottom') {
- y = bl.y - legendHeight;
- }
- if (pre) {
- y = pre.get('y') - legendHeight - LEGEND_GAP;
- }
- } else {
- var align = legend.align || 'left';
- x = appendPadding[3];
- if (align === 'center') {
- x = chartWidth / 2 - legendWidth / 2;
- } else if (align === 'right') {
- x = chartWidth - (legendWidth + appendPadding[1]);
- }
- y = position === 'top' ? appendPadding[0] + Math.abs(legend.container.getBBox().minY) : chartHeight - legendHeight;
- if (pre) {
- var preWidth = pre.getWidth();
- x = pre.x + preWidth + LEGEND_GAP;
- }
- }
- if (position === 'bottom' && offsetY > 0) {
- offsetY = 0;
- }
- if (position === 'right' && offsetX > 0) {
- offsetX = 0;
- }
- legend.moveTo(x + offsetX, y + offsetY);
- };
- _proto.alignLegends = function alignLegends() {
- var self = this;
- var legends = self.legends;
- Util.each(legends, function (legendItems, position) {
- Util.each(legendItems, function (legend, index) {
- var pre = legendItems[index - 1];
- self._alignLegend(legend, pre, position);
- });
- });
- return self;
- };
- _proto.handleEvent = function handleEvent(ev) {
- var self = this;
- function findItem(x, y) {
- var result = null;
- var legends = self.legends;
- Util.each(legends, function (legendItems) {
- Util.each(legendItems, function (legend) {
- var itemsGroup = legend.itemsGroup,
- legendHitBoxes = legend.legendHitBoxes;
- var children = itemsGroup.get('children');
- if (children.length) {
- var legendPosX = legend.x;
- var legendPosY = legend.y;
- Util.each(legendHitBoxes, function (box, index) {
- if (x >= box.x + legendPosX && x <= box.x + box.width + legendPosX && y >= box.y + legendPosY && y <= box.height + box.y + legendPosY) {
- // inbox
- result = {
- clickedItem: children[index],
- clickedLegend: legend
- };
- return false;
- }
- });
- }
- });
- });
- return result;
- }
- var chart = self.chart;
- var _Util$createEvent = Util.createEvent(ev, chart),
- x = _Util$createEvent.x,
- y = _Util$createEvent.y;
- var clicked = findItem(x, y);
- if (clicked && clicked.clickedLegend.clickable !== false) {
- var clickedItem = clicked.clickedItem,
- clickedLegend = clicked.clickedLegend;
- if (clickedLegend.onClick) {
- ev.clickedItem = clickedItem;
- clickedLegend.onClick(ev);
- } else if (!clickedLegend.custom) {
- var checked = clickedItem.get('checked');
- var value = clickedItem.get('dataValue');
- var filterVals = clickedLegend.filterVals,
- field = clickedLegend.field,
- selectedMode = clickedLegend.selectedMode;
- var isSingeSelected = selectedMode === 'single';
- if (isSingeSelected) {
- chart.filter(field, function (val) {
- return val === value;
- });
- } else {
- if (!checked) {
- filterVals.push(value);
- } else {
- Util.Array.remove(filterVals, value);
- }
- chart.filter(field, function (val) {
- return filterVals.indexOf(val) !== -1;
- });
- }
- chart.repaint();
- }
- }
- };
- _proto.bindEvents = function bindEvents() {
- var legendCfg = this.legendCfg;
- var triggerOn = legendCfg.triggerOn || 'touchstart';
- var method = Util.wrapBehavior(this, 'handleEvent');
- Util.addEventListener(this.canvasDom, triggerOn, method);
- };
- _proto.unBindEvents = function unBindEvents() {
- var legendCfg = this.legendCfg;
- var triggerOn = legendCfg.triggerOn || 'touchstart';
- var method = Util.getWrapBehavior(this, 'handleEvent');
- Util.removeEventListener(this.canvasDom, triggerOn, method);
- };
- return LegendController;
- }();
- module.exports = {
- init: function init(chart) {
- var legendController = new LegendController({
- container: chart.get('backPlot'),
- plotRange: chart.get('plotRange'),
- chart: chart
- });
- chart.set('legendController', legendController);
- chart.legend = function (field, cfg) {
- var legendCfg = legendController.legendCfg;
- legendController.enable = true;
- if (Util.isBoolean(field)) {
- legendController.enable = field;
- legendCfg = cfg || {};
- } else if (Util.isObject(field)) {
- legendCfg = field;
- } else {
- legendCfg[field] = cfg;
- }
- legendController.legendCfg = legendCfg;
- return this;
- };
- },
- beforeGeomDraw: function beforeGeomDraw(chart) {
- var legendController = chart.get('legendController');
- if (!legendController.enable) return null; // legend is not displayed
- var legendCfg = legendController.legendCfg;
- if (legendCfg && legendCfg.custom) {
- legendController.addCustomLegend();
- } else {
- var legendItems = chart.getLegendItems();
- var scales = chart.get('scales');
- var filters = chart.get('filters');
- Util.each(legendItems, function (items, field) {
- var scale = scales[field];
- var values = scale.values;
- var filterVals;
- if (filters && filters[field]) {
- filterVals = values.filter(filters[field]);
- } else {
- filterVals = values.slice(0);
- }
- legendController.addLegend(scale, items, filterVals);
- });
- }
- if (legendCfg && legendCfg.clickable !== false) {
- legendController.bindEvents();
- }
- var legends = legendController.legends;
- var legendRange = {
- top: 0,
- right: 0,
- bottom: 0,
- left: 0
- };
- Util.each(legends, function (legendItems, position) {
- var padding = 0;
- Util.each(legendItems, function (legend) {
- var width = legend.getWidth();
- var height = legend.getHeight();
- if (position === 'top' || position === 'bottom') {
- padding = Math.max(padding, height);
- if (legend.offsetY > 0) {
- padding += legend.offsetY;
- }
- } else {
- padding = Math.max(padding, width);
- if (legend.offsetX > 0) {
- padding += legend.offsetX;
- }
- }
- });
- legendRange[position] = padding + getPaddingByPos(position, chart.get('appendPadding'));
- });
- chart.set('legendRange', legendRange);
- },
- afterGeomDraw: function afterGeomDraw(chart) {
- var legendController = chart.get('legendController');
- legendController.alignLegends();
- },
- clearInner: function clearInner(chart) {
- var legendController = chart.get('legendController');
- legendController.clear();
- chart.set('legendRange', null);
- }
- };
- /***/ }),
- /* 119 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Handle the detail animations
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var Element = __webpack_require__(25);
- var Timeline = __webpack_require__(120);
- var Animator = __webpack_require__(121);
- var Animate = __webpack_require__(92);
- var ShapeAction = __webpack_require__(123);
- var GroupAction = __webpack_require__(124);
- var Chart = __webpack_require__(19);
- var timeline;
- Element.prototype.animate = function () {
- var attrs = Util.mix({}, this.get('attrs'));
- return new Animator(this, attrs, timeline);
- };
- Chart.prototype.animate = function (cfg) {
- this.set('animate', cfg);
- return this;
- };
- Animate.Action = ShapeAction;
- Animate.defaultCfg = {
- interval: {
- enter: function enter(coord) {
- if (coord.isPolar && coord.transposed) {
- // for pie chart
- return function (shape) {
- shape.set('zIndex', -1);
- var container = shape.get('parent');
- container.sort();
- };
- }
- return ShapeAction.fadeIn;
- }
- },
- area: {
- enter: function enter(coord) {
- if (coord.isPolar) return null;
- return ShapeAction.fadeIn;
- }
- },
- line: {
- enter: function enter(coord) {
- if (coord.isPolar) return null;
- return ShapeAction.fadeIn;
- }
- },
- path: {
- enter: function enter(coord) {
- if (coord.isPolar) return null;
- return ShapeAction.fadeIn;
- }
- }
- };
- var GROUP_ANIMATION = {
- line: function line(coord) {
- if (coord.isPolar) {
- return GroupAction.groupScaleInXY;
- }
- return GroupAction.groupWaveIn;
- },
- area: function area(coord) {
- if (coord.isPolar) {
- return GroupAction.groupScaleInXY;
- }
- return GroupAction.groupWaveIn;
- },
- path: function path(coord) {
- if (coord.isPolar) {
- return GroupAction.groupScaleInXY;
- }
- return GroupAction.groupWaveIn;
- },
- point: function point() {
- return GroupAction.shapesScaleInXY;
- },
- interval: function interval(coord) {
- var result;
- if (coord.isPolar) {
- // polar coodinate
- result = GroupAction.groupScaleInXY;
- if (coord.transposed) {
- // pie chart
- result = GroupAction.groupWaveIn;
- }
- } else {
- result = coord.transposed ? GroupAction.groupScaleInX : GroupAction.groupScaleInY;
- }
- return result;
- },
- schema: function schema() {
- return GroupAction.groupWaveIn;
- }
- };
- function diff(fromAttrs, toAttrs) {
- var endState = {};
- for (var k in toAttrs) {
- if (Util.isNumber(fromAttrs[k]) && fromAttrs[k] !== toAttrs[k]) {
- endState[k] = toAttrs[k];
- } else if (Util.isArray(fromAttrs[k]) && JSON.stringify(fromAttrs[k]) !== JSON.stringify(toAttrs[k])) {
- endState[k] = toAttrs[k];
- }
- }
- return endState;
- } // Add a unique id identifier to each shape
- function _getShapeId(geom, dataObj, geomIdx) {
- var type = geom.get('type');
- var id = 'geom' + geomIdx + '-' + type;
- var xScale = geom.getXScale();
- var yScale = geom.getYScale();
- var xField = xScale.field || 'x';
- var yField = yScale.field || 'y';
- var yVal = dataObj[yField];
- var xVal;
- if (xScale.isIdentity) {
- xVal = xScale.value;
- } else {
- xVal = dataObj[xField];
- }
- if (type === 'interval' || type === 'schema') {
- id += '-' + xVal;
- } else if (type === 'line' || type === 'area' || type === 'path') {
- id += '-' + type;
- } else {
- id += xScale.isCategory ? '-' + xVal : '-' + xVal + '-' + yVal;
- }
- var groupScales = geom._getGroupScales();
- Util.each(groupScales, function (groupScale) {
- var field = groupScale.field;
- if (groupScale.type !== 'identity') {
- id += '-' + dataObj[field];
- }
- });
- return id;
- } // get geometry's shapes
- function getShapes(geoms, chart, coord) {
- var shapes = [];
- Util.each(geoms, function (geom, geomIdx) {
- var geomContainer = geom.get('container');
- var geomShapes = geomContainer.get('children');
- var type = geom.get('type');
- var animateCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
- if (animateCfg !== false) {
- Util.each(geomShapes, function (shape, index) {
- if (shape.get('className') === type) {
- shape._id = _getShapeId(geom, shape.get('origin')._origin, geomIdx);
- shape.set('coord', coord);
- shape.set('animateCfg', animateCfg);
- shape.set('index', index);
- shapes.push(shape);
- }
- });
- }
- geom.set('shapes', geomShapes);
- });
- return shapes;
- }
- function cache(shapes) {
- var rst = {};
- for (var i = 0, len = shapes.length; i < len; i++) {
- var shape = shapes[i];
- if (!shape._id || shape.isClip) continue;
- var id = shape._id;
- rst[id] = {
- _id: id,
- type: shape.get('type'),
- // the type of shape
- attrs: Util.mix({}, shape._attrs.attrs),
- // the graphics attributes of shape
- className: shape.get('className'),
- geomType: shape.get('className'),
- index: shape.get('index'),
- coord: shape.get('coord'),
- animateCfg: shape.get('animateCfg')
- };
- }
- return rst;
- }
- function getAnimate(geomType, coord, animationType, animationName) {
- var result;
- if (Util.isFunction(animationName)) {
- result = animationName;
- } else if (Util.isString(animationName)) {
- result = Animate.Action[animationName];
- } else {
- result = Animate.getAnimation(geomType, coord, animationType);
- }
- return result;
- }
- function getAnimateCfg(geomType, animationType, animateCfg) {
- if (animateCfg === false || Util.isObject(animateCfg) && animateCfg[animationType] === false) {
- return false;
- }
- var defaultCfg = Animate.getAnimateCfg(geomType, animationType);
- if (animateCfg && animateCfg[animationType]) {
- return Util.deepMix({}, defaultCfg, animateCfg[animationType]);
- }
- return defaultCfg;
- }
- function addAnimate(cache, shapes, canvas) {
- var animate;
- var animateCfg; // the order of animation: leave -> update -> enter
- var updateShapes = [];
- var newShapes = [];
- Util.each(shapes, function (shape) {
- var result = cache[shape._id];
- if (!result) {
- newShapes.push(shape);
- } else {
- shape.set('cacheShape', result);
- updateShapes.push(shape);
- delete cache[shape._id];
- }
- }); // first do the leave animation
- Util.each(cache, function (deletedShape) {
- var className = deletedShape.className,
- coord = deletedShape.coord,
- _id = deletedShape._id,
- attrs = deletedShape.attrs,
- index = deletedShape.index,
- type = deletedShape.type;
- animateCfg = getAnimateCfg(className, 'leave', deletedShape.animateCfg);
- if (animateCfg === false) return true;
- animate = getAnimate(className, coord, 'leave', animateCfg.animation);
- if (Util.isFunction(animate)) {
- var tempShape = canvas.addShape(type, {
- attrs: attrs,
- index: index,
- canvas: canvas,
- className: className
- });
- tempShape._id = _id;
- animate(tempShape, animateCfg, coord);
- }
- }); // then do the update animation
- Util.each(updateShapes, function (updateShape) {
- var className = updateShape.get('className');
- animateCfg = getAnimateCfg(className, 'update', updateShape.get('animateCfg'));
- if (animateCfg === false) return true;
- var coord = updateShape.get('coord');
- var cacheAttrs = updateShape.get('cacheShape').attrs;
- var endState = diff(cacheAttrs, updateShape._attrs.attrs); // 判断如果属性相同的话就不进行变换
- if (Object.keys(endState).length) {
- animate = getAnimate(className, coord, 'update', animateCfg.animation);
- if (Util.isFunction(animate)) {
- animate(updateShape, animateCfg, coord);
- } else {
- updateShape.attr(cacheAttrs);
- updateShape.animate().to({
- attrs: endState,
- duration: animateCfg.duration,
- easing: animateCfg.easing,
- delay: animateCfg.delay
- }).onEnd(function () {
- updateShape.set('cacheShape', null);
- });
- }
- }
- }); // last, enter animation
- Util.each(newShapes, function (newShape) {
- // 新图形元素的进场元素
- var className = newShape.get('className');
- var coord = newShape.get('coord');
- animateCfg = getAnimateCfg(className, 'enter', newShape.get('animateCfg'));
- if (animateCfg === false) return true;
- animate = getAnimate(className, coord, 'enter', animateCfg.animation);
- if (Util.isFunction(animate)) {
- if (className === 'interval' && coord.isPolar && coord.transposed) {
- var index = newShape.get('index');
- var lastShape = updateShapes[index - 1];
- animate(newShape, animateCfg, lastShape);
- } else {
- animate(newShape, animateCfg, coord);
- }
- }
- });
- }
- function _getAnimateCfgByShapeType(type, chart) {
- if (!type) {
- return null;
- }
- var animateCfg = chart.get('animate');
- if (type.indexOf('guide-tag') > -1) {
- type = 'guide-tag';
- }
- if (Util.isObject(animateCfg)) {
- return animateCfg[type];
- }
- if (animateCfg === false) {
- return false;
- }
- return null;
- }
- module.exports = {
- afterCanvasInit: function afterCanvasInit()
- /* chart */
- {
- timeline = new Timeline();
- timeline.play();
- },
- beforeCanvasDraw: function beforeCanvasDraw(chart) {
- if (chart.get('animate') === false) {
- return;
- }
- var isUpdate = chart.get('isUpdate');
- var canvas = chart.get('canvas');
- var coord = chart.get('coord');
- var geoms = chart.get('geoms');
- var caches = canvas.get('caches') || [];
- if (caches.length === 0) {
- isUpdate = false;
- }
- var cacheShapes = getShapes(geoms, chart, coord);
- var _chart$get = chart.get('axisController'),
- frontPlot = _chart$get.frontPlot,
- backPlot = _chart$get.backPlot;
- var axisShapes = frontPlot.get('children').concat(backPlot.get('children'));
- var guideShapes = [];
- if (chart.get('guideController')) {
- guideShapes = chart.get('guideController').guideShapes;
- }
- var componentShapes = [];
- axisShapes.concat(guideShapes).forEach(function (s) {
- var className = s.get('className');
- var animateCfg = _getAnimateCfgByShapeType(className, chart);
- s.set('coord', coord);
- s.set('animateCfg', animateCfg);
- componentShapes.push(s);
- cacheShapes.push(s);
- });
- canvas.set('caches', cache(cacheShapes));
- if (isUpdate) {
- addAnimate(caches, cacheShapes, canvas);
- } else {
- // do the appear animation
- var animateCfg;
- var animate;
- Util.each(geoms, function (geom) {
- var type = geom.get('type');
- var geomCfg = Util.isNil(geom.get('animateCfg')) ? _getAnimateCfgByShapeType(type, chart) : geom.get('animateCfg');
- if (geomCfg !== false) {
- animateCfg = getAnimateCfg(type, 'appear', geomCfg);
- animate = getAnimate(type, coord, 'appear', animateCfg.animation);
- if (Util.isFunction(animate)) {
- var shapes = geom.get('shapes');
- Util.each(shapes, function (shape) {
- animate(shape, animateCfg, coord);
- });
- } else if (GROUP_ANIMATION[type]) {
- // do the default animation
- animate = GroupAction[animateCfg.animation] || GROUP_ANIMATION[type](coord);
- var yScale = geom.getYScale();
- var zeroY = coord.convertPoint({
- x: 0,
- y: yScale.scale(geom.getYMinValue())
- });
- var container = geom.get('container');
- animate && animate(container, animateCfg, coord, zeroY);
- }
- }
- }); // do the animation of components
- Util.each(componentShapes, function (shape) {
- var animateCfg = shape.get('animateCfg');
- var className = shape.get('className');
- if (animateCfg && animateCfg.appear) {
- // if user configure
- var defaultCfg = Animate.getAnimateCfg(className, 'appear');
- var appearCfg = Util.deepMix({}, defaultCfg, animateCfg.appear);
- var _animate = getAnimate(className, coord, 'appear', appearCfg.animation);
- if (Util.isFunction(_animate)) {
- _animate(shape, appearCfg, coord);
- }
- }
- });
- }
- },
- afterCanvasDestroyed: function afterCanvasDestroyed()
- /* chart */
- {
- timeline.stop();
- }
- };
- /***/ }),
- /* 120 */
- /***/ (function(module, exports, __webpack_require__) {
- var _require = __webpack_require__(36),
- requestAnimationFrame = _require.requestAnimationFrame;
- var clock = typeof performance === 'object' && performance.now ? performance : Date;
- var Timeline =
- /*#__PURE__*/
- function () {
- function Timeline() {
- this.anims = [];
- this.time = null;
- this.playing = false;
- this.canvas = [];
- }
- var _proto = Timeline.prototype;
- _proto.play = function play() {
- var self = this;
- self.time = clock.now();
- self.playing = true;
- function step() {
- if (self.playing) {
- requestAnimationFrame(step);
- self.update();
- }
- }
- requestAnimationFrame(step);
- };
- _proto.stop = function stop() {
- this.playing = false;
- this.time = null;
- this.canvas = [];
- };
- _proto.update = function update() {
- var currentTime = clock.now();
- this.canvas = [];
- for (var i = 0; i < this.anims.length; i++) {
- var propertyAnim = this.anims[i];
- if (currentTime < propertyAnim.startTime || propertyAnim.hasEnded) {
- continue;
- }
- var shape = propertyAnim.shape; // shape
- if (shape.get('destroyed')) {
- this.anims.splice(i, 1);
- i--;
- continue;
- }
- var startState = propertyAnim.startState,
- endState = propertyAnim.endState,
- interpolate = propertyAnim.interpolate,
- duration = propertyAnim.duration;
- if (currentTime >= propertyAnim.startTime && !propertyAnim.hasStarted) {
- propertyAnim.hasStarted = true;
- if (propertyAnim.onStart) {
- propertyAnim.onStart();
- }
- }
- var t = (currentTime - propertyAnim.startTime) / duration;
- t = Math.max(0, Math.min(t, 1));
- t = propertyAnim.easing(t);
- if (propertyAnim.onFrame) {
- propertyAnim.onFrame(t);
- } else {
- for (var key in interpolate) {
- var diff = interpolate[key];
- var value = diff(t);
- var newValue = void 0;
- if (key === 'points') {
- newValue = [];
- var aLen = Math.max(startState.points.length, endState.points.length);
- for (var j = 0; j < aLen; j += 2) {
- newValue.push({
- x: value[j],
- y: value[j + 1]
- });
- }
- } else {
- newValue = value;
- }
- shape._attrs.attrs[key] = newValue;
- shape._attrs.bbox = null; // should clear calculated bbox
- }
- }
- var canvas = shape.get('canvas');
- if (this.canvas.indexOf(canvas) === -1) {
- this.canvas.push(canvas);
- }
- if (propertyAnim.onUpdate) {
- propertyAnim.onUpdate(t);
- }
- if (currentTime >= propertyAnim.endTime && !propertyAnim.hasEnded) {
- propertyAnim.hasEnded = true;
- if (propertyAnim.onEnd) {
- propertyAnim.onEnd();
- }
- }
- if (t === 1) {
- // end
- this.anims.splice(i, 1);
- i--;
- }
- }
- this.canvas.map(function (c) {
- c.draw();
- return c;
- });
- this.time = clock.now();
- };
- return Timeline;
- }();
- module.exports = Timeline;
- /***/ }),
- /* 121 */
- /***/ (function(module, exports, __webpack_require__) {
- var Easing = __webpack_require__(122);
- function plainArray(arr) {
- var result = [];
- for (var i = 0, len = arr.length; i < len; i++) {
- if (arr[i]) {
- result.push(arr[i].x);
- result.push(arr[i].y);
- }
- }
- return result;
- }
- function interpolateNumber(a, b) {
- a = +a;
- b -= a;
- return function (t) {
- return a + b * t;
- };
- }
- function interpolateArray(a, b) {
- var nb = b ? b.length : 0;
- var na = a ? Math.min(nb, a.length) : 0;
- var x = new Array(na);
- var c = new Array(nb);
- var i;
- for (i = 0; i < na; ++i) {
- x[i] = interpolateNumber(a[i], b[i]);
- }
- for (; i < nb; ++i) {
- c[i] = b[i];
- }
- return function (t) {
- for (i = 0; i < na; ++i) {
- c[i] = x[i](t);
- }
- return c;
- };
- }
- var Animator =
- /*#__PURE__*/
- function () {
- function Animator(shape, source, timeline) {
- this.hasStarted = false;
- this.hasEnded = false;
- this.shape = shape;
- this.source = source;
- this.timeline = timeline;
- this.animate = null;
- } // delay, attrs, duration, easing
- var _proto = Animator.prototype;
- _proto.to = function to(cfg) {
- if (cfg === void 0) {
- cfg = {};
- }
- var delay = cfg.delay || 0;
- var attrs = cfg.attrs || {};
- var duration = cfg.duration || 1000;
- var easing; // 缓动函数
- if (typeof cfg.easing === 'function') {
- easing = cfg.easing;
- } else {
- easing = Easing[cfg.easing] || Easing.linear;
- }
- var animInfo = {
- shape: this.shape,
- startTime: this.timeline.time + delay,
- duration: duration,
- easing: easing
- };
- var interpolate = {}; // 差值函数
- for (var attrName in attrs) {
- var startValue = this.source[attrName];
- var endValue = attrs[attrName];
- if (attrName === 'points') {
- startValue = plainArray(startValue);
- endValue = plainArray(endValue);
- interpolate.points = interpolateArray(startValue, endValue);
- this.source.points = startValue;
- attrs.points = endValue;
- } else if (attrName === 'matrix') {
- interpolate.matrix = interpolateArray(startValue, endValue);
- } else {
- interpolate[attrName] = interpolateNumber(startValue, endValue);
- }
- }
- animInfo.interpolate = interpolate;
- animInfo.startState = this.source;
- animInfo.endState = attrs;
- animInfo.endTime = animInfo.startTime + duration;
- this.timeline.anims.push(animInfo);
- this.animate = animInfo;
- return this;
- };
- _proto.onFrame = function onFrame(callback) {
- // 自定义每一帧动画的动作
- if (this.animate) {
- this.animate.onFrame = function (frame) {
- callback(frame);
- };
- }
- return this;
- };
- _proto.onStart = function onStart(callback) {
- if (this.animate) {
- this.animate.onStart = function () {
- callback();
- };
- }
- return this;
- };
- _proto.onUpdate = function onUpdate(callback) {
- if (this.animate) {
- this.animate.onUpdate = function (frame) {
- callback(frame);
- };
- }
- return this;
- };
- _proto.onEnd = function onEnd(callback) {
- if (this.animate) {
- this.animate.onEnd = function () {
- callback();
- };
- }
- return this;
- };
- return Animator;
- }();
- module.exports = Animator;
- /***/ }),
- /* 122 */
- /***/ (function(module, exports) {
- var Easing = {
- linear: function linear(k) {
- return k;
- },
- quadraticIn: function quadraticIn(k) {
- return k * k;
- },
- quadraticOut: function quadraticOut(k) {
- return k * (2 - k);
- },
- quadraticInOut: function quadraticInOut(k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k;
- }
- return -0.5 * (--k * (k - 2) - 1);
- },
- cubicIn: function cubicIn(k) {
- return k * k * k;
- },
- cubicOut: function cubicOut(k) {
- return --k * k * k + 1;
- },
- cubicInOut: function cubicInOut(k) {
- if ((k *= 2) < 1) {
- return 0.5 * k * k * k;
- }
- return 0.5 * ((k -= 2) * k * k + 2);
- },
- elasticIn: function elasticIn(k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!p) {
- p = 0.3;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p / (2 * Math.PI) * Math.asin(1 / a);
- }
- return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- },
- elasticOut: function elasticOut(k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!p) {
- p = 0.3;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p / (2 * Math.PI) * Math.asin(1 / a);
- }
- return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
- },
- elasticInOut: function elasticInOut(k) {
- var s;
- var a = 0.1;
- var p = 0.4;
- if (k === 0) return 0;
- if (k === 1) return 1;
- if (!p) {
- p = 0.3;
- }
- if (!a || a < 1) {
- a = 1;
- s = p / 4;
- } else {
- s = p / (2 * Math.PI) * Math.asin(1 / a);
- }
- if ((k *= 2) < 1) {
- return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
- }
- return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
- },
- backIn: function backIn(k) {
- var s = 1.70158;
- return k * k * ((s + 1) * k - s);
- },
- backOut: function backOut(k) {
- var s = 1.70158;
- return (k = k - 1) * k * ((s + 1) * k + s) + 1;
- },
- backInOut: function backInOut(k) {
- var s = 1.70158 * 1.525;
- if ((k *= 2) < 1) {
- return 0.5 * (k * k * ((s + 1) * k - s));
- }
- return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
- },
- bounceIn: function bounceIn(k) {
- return 1 - Easing.bounceOut(1 - k);
- },
- bounceOut: function bounceOut(k) {
- if ((k /= 1) < 1 / 2.75) {
- return 7.5625 * k * k;
- } else if (k < 2 / 2.75) {
- return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
- } else if (k < 2.5 / 2.75) {
- return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
- }
- return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
- },
- bounceInOut: function bounceInOut(k) {
- if (k < 0.5) {
- return Easing.bounceIn(k * 2) * 0.5;
- }
- return Easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
- }
- };
- module.exports = Easing;
- /***/ }),
- /* 123 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Animation functions for shape
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(0);
- var Helpers = __webpack_require__(93);
- /*
- function waveIn(shape, animateCfg, coord) {
- const clip = Helpers.getClip(coord);
- clip.set('canvas', shape.get('canvas'));
- shape.attr('clip', clip);
- const onEnd = function() {
- shape.attr('clip', null);
- clip.remove(true);
- };
- Helpers.doAnimation(clip, clip.endState, animateCfg, onEnd);
- }
- function scaleInX(shape, animateCfg) {
- const box = shape.getBBox();
- const points = shape.get('origin').points;
- let x;
- const y = (box.minY + box.maxY) / 2;
- if (points[0].y - points[1].y > 0) { // 当顶点在零点之下
- x = box.maxX;
- } else {
- x = box.minX;
- }
- const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
- Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
- }
- function scaleInY(shape, animateCfg) {
- const box = shape.getBBox();
- const points = shape.get('origin').points;
- const x = (box.minX + box.maxX) / 2;
- let y;
- if (points[0].y - points[1].y <= 0) { // 当顶点在零点之下
- y = box.maxY;
- } else {
- y = box.minY;
- }
- const scaledMatrix = Helpers.getScaledMatrix(shape, [ x, y ], 'x');
- Helpers.doAnimation(shape, { matrix: scaledMatrix }, animateCfg);
- }
- */
- function fadeIn(shape, animateCfg) {
- var fillOpacity = Util.isNil(shape.attr('fillOpacity')) ? 1 : shape.attr('fillOpacity');
- var strokeOpacity = Util.isNil(shape.attr('strokeOpacity')) ? 1 : shape.attr('strokeOpacity');
- shape.attr('fillOpacity', 0);
- shape.attr('strokeOpacity', 0);
- var endState = {
- fillOpacity: fillOpacity,
- strokeOpacity: strokeOpacity
- };
- Helpers.doAnimation(shape, endState, animateCfg);
- }
- module.exports = {
- // waveIn,
- // scaleInX,
- // scaleInY,
- fadeIn: fadeIn
- };
- /***/ }),
- /* 124 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Group animate functions
- * @author sima.zhang1990@gmail.com
- */
- var Util = __webpack_require__(93);
- var Helper = __webpack_require__(26);
- var _require = __webpack_require__(5),
- Shape = _require.Shape;
- function _groupScaleIn(container, animateCfg, coord, zeroY, type) {
- var _Util$getCoordInfo = Util.getCoordInfo(coord),
- start = _Util$getCoordInfo.start,
- end = _Util$getCoordInfo.end,
- width = _Util$getCoordInfo.width,
- height = _Util$getCoordInfo.height;
- var x;
- var y;
- var clip = new Shape.Rect({
- attrs: {
- x: start.x,
- y: end.y,
- width: width,
- height: height
- }
- });
- if (type === 'y') {
- x = start.x + width / 2;
- y = zeroY.y < start.y ? zeroY.y : start.y;
- } else if (type === 'x') {
- x = zeroY.x > start.x ? zeroY.x : start.x;
- y = start.y + height / 2;
- } else if (type === 'xy') {
- if (coord.isPolar) {
- x = coord.center.x;
- y = coord.center.y;
- } else {
- x = (start.x + end.x) / 2;
- y = (start.y + end.y) / 2;
- }
- }
- var endMatrix = Util.getScaledMatrix(clip, [x, y], type);
- clip.isClip = true;
- clip.endState = {
- matrix: endMatrix
- };
- clip.set('canvas', container.get('canvas'));
- container.attr('clip', clip);
- var onEnd = function onEnd() {
- container.attr('clip', null);
- clip.remove(true);
- };
- Util.doAnimation(clip, clip.endState, animateCfg, onEnd);
- }
- function _shapeScale(container, animateCfg, type) {
- var shapes = container.get('children');
- var x;
- var y;
- var endMatrix;
- for (var i = 0, len = shapes.length; i < len; i++) {
- var shape = shapes[i];
- var box = shape.getBBox();
- x = (box.minX + box.maxX) / 2;
- y = (box.minY + box.maxY) / 2;
- endMatrix = Util.getScaledMatrix(shape, [x, y], type);
- Util.doAnimation(shape, {
- matrix: endMatrix
- }, animateCfg);
- }
- }
- function groupScaleInX(container, animateCfg, coord, zeroY) {
- _groupScaleIn(container, animateCfg, coord, zeroY, 'x');
- }
- function groupScaleInY(container, animateCfg, coord, zeroY) {
- _groupScaleIn(container, animateCfg, coord, zeroY, 'y');
- }
- function groupScaleInXY(container, animateCfg, coord, zeroY) {
- _groupScaleIn(container, animateCfg, coord, zeroY, 'xy');
- }
- function shapesScaleInX(container, animateCfg) {
- _shapeScale(container, animateCfg, 'x');
- }
- function shapesScaleInY(container, animateCfg) {
- _shapeScale(container, animateCfg, 'y');
- }
- function shapesScaleInXY(container, animateCfg) {
- _shapeScale(container, animateCfg, 'xy');
- }
- function groupWaveIn(container, animateCfg, coord) {
- var clip = Helper.getClip(coord);
- clip.set('canvas', container.get('canvas'));
- container.attr('clip', clip);
- var onEnd = function onEnd() {
- container.attr('clip', null);
- clip.remove(true);
- };
- var endState = {};
- if (coord.isPolar) {
- var startAngle = coord.startAngle,
- endAngle = coord.endAngle;
- endState.endAngle = endAngle;
- clip.attr('endAngle', startAngle);
- } else {
- var start = coord.start,
- end = coord.end;
- var width = Math.abs(start.x - end.x);
- var height = Math.abs(start.y - end.y);
- if (coord.isTransposed) {
- clip.attr('height', 0);
- endState.height = height;
- } else {
- clip.attr('width', 0);
- endState.width = width;
- }
- }
- Util.doAnimation(clip, endState, animateCfg, onEnd);
- }
- module.exports = {
- groupWaveIn: groupWaveIn,
- groupScaleInX: groupScaleInX,
- groupScaleInY: groupScaleInY,
- groupScaleInXY: groupScaleInXY,
- shapesScaleInX: shapesScaleInX,
- shapesScaleInY: shapesScaleInY,
- shapesScaleInXY: shapesScaleInXY
- };
- /***/ }),
- /* 125 */,
- /* 126 */,
- /* 127 */,
- /* 128 */,
- /* 129 */
- /***/ (function(module, exports, __webpack_require__) {
- /**
- * Default, without interactins
- */
- var F2 = __webpack_require__(41);
- __webpack_require__(95);
- __webpack_require__(83);
- __webpack_require__(88); // polar coordinate
- __webpack_require__(104); // the axis for polar coordinate
- __webpack_require__(105); // timeCat scale
- __webpack_require__(108);
- __webpack_require__(109);
- __webpack_require__(110);
- __webpack_require__(111);
- __webpack_require__(112);
- __webpack_require__(113);
- var Tooltip = __webpack_require__(114);
- var Guide = __webpack_require__(117);
- var Legend = __webpack_require__(118);
- var Animation = __webpack_require__(119);
- F2.Animate = __webpack_require__(92); // register plugins
- F2.Chart.plugins.register([Tooltip, Legend, Guide, Animation]);
- module.exports = F2;
- /***/ })
- /******/ ]);
- });
|