echarts.simple.js 802 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define([], factory);
  6. else if(typeof exports === 'object')
  7. exports["echarts"] = factory();
  8. else
  9. root["echarts"] = factory();
  10. })(this, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/ // The require function
  15. /******/ function __webpack_require__(moduleId) {
  16. /******/ // Check if module is in cache
  17. /******/ if(installedModules[moduleId])
  18. /******/ return installedModules[moduleId].exports;
  19. /******/ // Create a new module (and put it into the cache)
  20. /******/ var module = installedModules[moduleId] = {
  21. /******/ exports: {},
  22. /******/ id: moduleId,
  23. /******/ loaded: false
  24. /******/ };
  25. /******/ // Execute the module function
  26. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  27. /******/ // Flag the module as loaded
  28. /******/ module.loaded = true;
  29. /******/ // Return the exports of the module
  30. /******/ return module.exports;
  31. /******/ }
  32. /******/ // expose the modules object (__webpack_modules__)
  33. /******/ __webpack_require__.m = modules;
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/ // __webpack_public_path__
  37. /******/ __webpack_require__.p = "";
  38. /******/ // Load entry module and return exports
  39. /******/ return __webpack_require__(0);
  40. /******/ })
  41. /************************************************************************/
  42. /******/ ([
  43. /* 0 */
  44. /***/ function(module, exports, __webpack_require__) {
  45. /**
  46. * Export echarts as CommonJS module
  47. */
  48. module.exports = __webpack_require__(1);
  49. __webpack_require__(92);
  50. __webpack_require__(128);
  51. __webpack_require__(133);
  52. __webpack_require__(107);
  53. /***/ },
  54. /* 1 */
  55. /***/ function(module, exports, __webpack_require__) {
  56. /*!
  57. * ECharts, a javascript interactive chart library.
  58. *
  59. * Copyright (c) 2015, Baidu Inc.
  60. * All rights reserved.
  61. *
  62. * LICENSE
  63. * https://github.com/ecomfe/echarts/blob/master/LICENSE.txt
  64. */
  65. /**
  66. * @module echarts
  67. */
  68. var GlobalModel = __webpack_require__(2);
  69. var ExtensionAPI = __webpack_require__(24);
  70. var CoordinateSystemManager = __webpack_require__(25);
  71. var OptionManager = __webpack_require__(26);
  72. var ComponentModel = __webpack_require__(19);
  73. var SeriesModel = __webpack_require__(27);
  74. var ComponentView = __webpack_require__(28);
  75. var ChartView = __webpack_require__(41);
  76. var graphic = __webpack_require__(42);
  77. var zrender = __webpack_require__(78);
  78. var zrUtil = __webpack_require__(3);
  79. var colorTool = __webpack_require__(38);
  80. var env = __webpack_require__(79);
  81. var Eventful = __webpack_require__(32);
  82. var each = zrUtil.each;
  83. var VISUAL_CODING_STAGES = ['echarts', 'chart', 'component'];
  84. // TODO Transform first or filter first
  85. var PROCESSOR_STAGES = ['transform', 'filter', 'statistic'];
  86. function createRegisterEventWithLowercaseName(method) {
  87. return function (eventName, handler, context) {
  88. // Event name is all lowercase
  89. eventName = eventName && eventName.toLowerCase();
  90. Eventful.prototype[method].call(this, eventName, handler, context);
  91. };
  92. }
  93. /**
  94. * @module echarts~MessageCenter
  95. */
  96. function MessageCenter() {
  97. Eventful.call(this);
  98. }
  99. MessageCenter.prototype.on = createRegisterEventWithLowercaseName('on');
  100. MessageCenter.prototype.off = createRegisterEventWithLowercaseName('off');
  101. MessageCenter.prototype.one = createRegisterEventWithLowercaseName('one');
  102. zrUtil.mixin(MessageCenter, Eventful);
  103. /**
  104. * @module echarts~ECharts
  105. */
  106. function ECharts (dom, theme, opts) {
  107. opts = opts || {};
  108. // Get theme by name
  109. if (typeof theme === 'string') {
  110. theme = themeStorage[theme];
  111. }
  112. if (theme) {
  113. each(optionPreprocessorFuncs, function (preProcess) {
  114. preProcess(theme);
  115. });
  116. }
  117. /**
  118. * @type {string}
  119. */
  120. this.id;
  121. /**
  122. * Group id
  123. * @type {string}
  124. */
  125. this.group;
  126. /**
  127. * @type {HTMLDomElement}
  128. * @private
  129. */
  130. this._dom = dom;
  131. /**
  132. * @type {module:zrender/ZRender}
  133. * @private
  134. */
  135. this._zr = zrender.init(dom, {
  136. renderer: opts.renderer || 'canvas',
  137. devicePixelRatio: opts.devicePixelRatio
  138. });
  139. /**
  140. * @type {Object}
  141. * @private
  142. */
  143. this._theme = zrUtil.clone(theme);
  144. /**
  145. * @type {Array.<module:echarts/view/Chart>}
  146. * @private
  147. */
  148. this._chartsViews = [];
  149. /**
  150. * @type {Object.<string, module:echarts/view/Chart>}
  151. * @private
  152. */
  153. this._chartsMap = {};
  154. /**
  155. * @type {Array.<module:echarts/view/Component>}
  156. * @private
  157. */
  158. this._componentsViews = [];
  159. /**
  160. * @type {Object.<string, module:echarts/view/Component>}
  161. * @private
  162. */
  163. this._componentsMap = {};
  164. /**
  165. * @type {module:echarts/ExtensionAPI}
  166. * @private
  167. */
  168. this._api = new ExtensionAPI(this);
  169. /**
  170. * @type {module:echarts/CoordinateSystem}
  171. * @private
  172. */
  173. this._coordSysMgr = new CoordinateSystemManager();
  174. Eventful.call(this);
  175. /**
  176. * @type {module:echarts~MessageCenter}
  177. * @private
  178. */
  179. this._messageCenter = new MessageCenter();
  180. // Init mouse events
  181. this._initEvents();
  182. // In case some people write `window.onresize = chart.resize`
  183. this.resize = zrUtil.bind(this.resize, this);
  184. }
  185. var echartsProto = ECharts.prototype;
  186. /**
  187. * @return {HTMLDomElement}
  188. */
  189. echartsProto.getDom = function () {
  190. return this._dom;
  191. };
  192. /**
  193. * @return {module:zrender~ZRender}
  194. */
  195. echartsProto.getZr = function () {
  196. return this._zr;
  197. };
  198. /**
  199. * @param {Object} option
  200. * @param {boolean} notMerge
  201. * @param {boolean} [notRefreshImmediately=false] Useful when setOption frequently.
  202. */
  203. echartsProto.setOption = function (option, notMerge, notRefreshImmediately) {
  204. if (!this._model || notMerge) {
  205. this._model = new GlobalModel(
  206. null, null, this._theme, new OptionManager(this._api)
  207. );
  208. }
  209. this._model.setOption(option, optionPreprocessorFuncs);
  210. updateMethods.prepareAndUpdate.call(this);
  211. !notRefreshImmediately && this._zr.refreshImmediately();
  212. };
  213. /**
  214. * @DEPRECATED
  215. */
  216. echartsProto.setTheme = function () {
  217. console.log('ECharts#setTheme() is DEPRECATED in ECharts 3.0');
  218. };
  219. /**
  220. * @return {module:echarts/model/Global}
  221. */
  222. echartsProto.getModel = function () {
  223. return this._model;
  224. };
  225. /**
  226. * @return {Object}
  227. */
  228. echartsProto.getOption = function () {
  229. return this._model.getOption();
  230. };
  231. /**
  232. * @return {number}
  233. */
  234. echartsProto.getWidth = function () {
  235. return this._zr.getWidth();
  236. };
  237. /**
  238. * @return {number}
  239. */
  240. echartsProto.getHeight = function () {
  241. return this._zr.getHeight();
  242. };
  243. /**
  244. * Get canvas which has all thing rendered
  245. * @param {Object} opts
  246. * @param {string} [opts.backgroundColor]
  247. */
  248. echartsProto.getRenderedCanvas = function (opts) {
  249. if (!env.canvasSupported) {
  250. return;
  251. }
  252. opts = opts || {};
  253. opts.pixelRatio = opts.pixelRatio || 1;
  254. opts.backgroundColor = opts.backgroundColor
  255. || this._model.get('backgroundColor');
  256. var zr = this._zr;
  257. var list = zr.storage.getDisplayList();
  258. // Stop animations
  259. zrUtil.each(list, function (el) {
  260. el.stopAnimation(true);
  261. });
  262. return zr.painter.getRenderedCanvas(opts);
  263. };
  264. /**
  265. * @return {string}
  266. * @param {Object} opts
  267. * @param {string} [opts.type='png']
  268. * @param {string} [opts.pixelRatio=1]
  269. * @param {string} [opts.backgroundColor]
  270. */
  271. echartsProto.getDataURL = function (opts) {
  272. opts = opts || {};
  273. var excludeComponents = opts.excludeComponents;
  274. var ecModel = this._model;
  275. var excludesComponentViews = [];
  276. var self = this;
  277. each(excludeComponents, function (componentType) {
  278. ecModel.eachComponent({
  279. mainType: componentType
  280. }, function (component) {
  281. var view = self._componentsMap[component.__viewId];
  282. if (!view.group.ignore) {
  283. excludesComponentViews.push(view);
  284. view.group.ignore = true;
  285. }
  286. });
  287. });
  288. var url = this.getRenderedCanvas(opts).toDataURL(
  289. 'image/' + (opts && opts.type || 'png')
  290. );
  291. each(excludesComponentViews, function (view) {
  292. view.group.ignore = false;
  293. });
  294. return url;
  295. };
  296. /**
  297. * @return {string}
  298. * @param {Object} opts
  299. * @param {string} [opts.type='png']
  300. * @param {string} [opts.pixelRatio=1]
  301. * @param {string} [opts.backgroundColor]
  302. */
  303. echartsProto.getConnectedDataURL = function (opts) {
  304. if (!env.canvasSupported) {
  305. return;
  306. }
  307. var groupId = this.group;
  308. var mathMin = Math.min;
  309. var mathMax = Math.max;
  310. var MAX_NUMBER = Infinity;
  311. if (connectedGroups[groupId]) {
  312. var left = MAX_NUMBER;
  313. var top = MAX_NUMBER;
  314. var right = -MAX_NUMBER;
  315. var bottom = -MAX_NUMBER;
  316. var canvasList = [];
  317. var dpr = (opts && opts.pixelRatio) || 1;
  318. for (var id in instances) {
  319. var chart = instances[id];
  320. if (chart.group === groupId) {
  321. var canvas = chart.getRenderedCanvas(
  322. zrUtil.clone(opts)
  323. );
  324. var boundingRect = chart.getDom().getBoundingClientRect();
  325. left = mathMin(boundingRect.left, left);
  326. top = mathMin(boundingRect.top, top);
  327. right = mathMax(boundingRect.right, right);
  328. bottom = mathMax(boundingRect.bottom, bottom);
  329. canvasList.push({
  330. dom: canvas,
  331. left: boundingRect.left,
  332. top: boundingRect.top
  333. });
  334. }
  335. }
  336. left *= dpr;
  337. top *= dpr;
  338. right *= dpr;
  339. bottom *= dpr;
  340. var width = right - left;
  341. var height = bottom - top;
  342. var targetCanvas = zrUtil.createCanvas();
  343. targetCanvas.width = width;
  344. targetCanvas.height = height;
  345. var zr = zrender.init(targetCanvas);
  346. each(canvasList, function (item) {
  347. var img = new graphic.Image({
  348. style: {
  349. x: item.left * dpr - left,
  350. y: item.top * dpr - top,
  351. image: item.dom
  352. }
  353. });
  354. zr.add(img);
  355. });
  356. zr.refreshImmediately();
  357. return targetCanvas.toDataURL('image/' + (opts && opts.type || 'png'));
  358. }
  359. else {
  360. return this.getDataURL(opts);
  361. }
  362. };
  363. var updateMethods = {
  364. /**
  365. * @param {Object} payload
  366. * @private
  367. */
  368. update: function (payload) {
  369. // console.time && console.time('update');
  370. var ecModel = this._model;
  371. var api = this._api;
  372. var coordSysMgr = this._coordSysMgr;
  373. // update before setOption
  374. if (!ecModel) {
  375. return;
  376. }
  377. // Fixme First time update ?
  378. ecModel.restoreData();
  379. // TODO
  380. // Save total ecModel here for undo/redo (after restoring data and before processing data).
  381. // Undo (restoration of total ecModel) can be carried out in 'action' or outside API call.
  382. // Create new coordinate system each update
  383. // In LineView may save the old coordinate system and use it to get the orignal point
  384. coordSysMgr.create(this._model, this._api);
  385. processData.call(this, ecModel, api);
  386. stackSeriesData.call(this, ecModel);
  387. coordSysMgr.update(ecModel, api);
  388. doLayout.call(this, ecModel, payload);
  389. doVisualCoding.call(this, ecModel, payload);
  390. doRender.call(this, ecModel, payload);
  391. // Set background
  392. var backgroundColor = ecModel.get('backgroundColor') || 'transparent';
  393. var painter = this._zr.painter;
  394. // TODO all use clearColor ?
  395. if (painter.isSingleCanvas && painter.isSingleCanvas()) {
  396. this._zr.configLayer(0, {
  397. clearColor: backgroundColor
  398. });
  399. }
  400. else {
  401. // In IE8
  402. if (!env.canvasSupported) {
  403. var colorArr = colorTool.parse(backgroundColor);
  404. backgroundColor = colorTool.stringify(colorArr, 'rgb');
  405. if (colorArr[3] === 0) {
  406. backgroundColor = 'transparent';
  407. }
  408. }
  409. backgroundColor = backgroundColor;
  410. this._dom.style.backgroundColor = backgroundColor;
  411. }
  412. // console.time && console.timeEnd('update');
  413. },
  414. // PENDING
  415. /**
  416. * @param {Object} payload
  417. * @private
  418. */
  419. updateView: function (payload) {
  420. var ecModel = this._model;
  421. // update before setOption
  422. if (!ecModel) {
  423. return;
  424. }
  425. doLayout.call(this, ecModel, payload);
  426. doVisualCoding.call(this, ecModel, payload);
  427. invokeUpdateMethod.call(this, 'updateView', ecModel, payload);
  428. },
  429. /**
  430. * @param {Object} payload
  431. * @private
  432. */
  433. updateVisual: function (payload) {
  434. var ecModel = this._model;
  435. // update before setOption
  436. if (!ecModel) {
  437. return;
  438. }
  439. doVisualCoding.call(this, ecModel, payload);
  440. invokeUpdateMethod.call(this, 'updateVisual', ecModel, payload);
  441. },
  442. /**
  443. * @param {Object} payload
  444. * @private
  445. */
  446. updateLayout: function (payload) {
  447. var ecModel = this._model;
  448. // update before setOption
  449. if (!ecModel) {
  450. return;
  451. }
  452. doLayout.call(this, ecModel, payload);
  453. invokeUpdateMethod.call(this, 'updateLayout', ecModel, payload);
  454. },
  455. /**
  456. * @param {Object} payload
  457. * @private
  458. */
  459. highlight: function (payload) {
  460. toggleHighlight.call(this, 'highlight', payload);
  461. },
  462. /**
  463. * @param {Object} payload
  464. * @private
  465. */
  466. downplay: function (payload) {
  467. toggleHighlight.call(this, 'downplay', payload);
  468. },
  469. /**
  470. * @param {Object} payload
  471. * @private
  472. */
  473. prepareAndUpdate: function (payload) {
  474. var ecModel = this._model;
  475. prepareView.call(this, 'component', ecModel);
  476. prepareView.call(this, 'chart', ecModel);
  477. updateMethods.update.call(this, payload);
  478. }
  479. };
  480. /**
  481. * @param {Object} payload
  482. * @private
  483. */
  484. function toggleHighlight(method, payload) {
  485. var ecModel = this._model;
  486. // dispatchAction before setOption
  487. if (!ecModel) {
  488. return;
  489. }
  490. ecModel.eachComponent(
  491. {mainType: 'series', query: payload},
  492. function (seriesModel, index) {
  493. var chartView = this._chartsMap[seriesModel.__viewId];
  494. if (chartView && chartView.__alive) {
  495. chartView[method](
  496. seriesModel, ecModel, this._api, payload
  497. );
  498. }
  499. },
  500. this
  501. );
  502. }
  503. /**
  504. * Resize the chart
  505. */
  506. echartsProto.resize = function () {
  507. this._zr.resize();
  508. var optionChanged = this._model && this._model.resetOption('media');
  509. updateMethods[optionChanged ? 'prepareAndUpdate' : 'update'].call(this);
  510. // Resize loading effect
  511. this._loadingFX && this._loadingFX.resize();
  512. };
  513. var defaultLoadingEffect = __webpack_require__(88);
  514. /**
  515. * Show loading effect
  516. * @param {string} [name='default']
  517. * @param {Object} [cfg]
  518. */
  519. echartsProto.showLoading = function (name, cfg) {
  520. if (zrUtil.isObject(name)) {
  521. cfg = name;
  522. name = 'default';
  523. }
  524. this.hideLoading();
  525. var el = defaultLoadingEffect(this._api, cfg);
  526. var zr = this._zr;
  527. this._loadingFX = el;
  528. zr.add(el);
  529. };
  530. /**
  531. * Hide loading effect
  532. */
  533. echartsProto.hideLoading = function () {
  534. this._loadingFX && this._zr.remove(this._loadingFX);
  535. this._loadingFX = null;
  536. };
  537. /**
  538. * @param {Object} eventObj
  539. * @return {Object}
  540. */
  541. echartsProto.makeActionFromEvent = function (eventObj) {
  542. var payload = zrUtil.extend({}, eventObj);
  543. payload.type = eventActionMap[eventObj.type];
  544. return payload;
  545. };
  546. /**
  547. * @pubilc
  548. * @param {Object} payload
  549. * @param {string} [payload.type] Action type
  550. * @param {boolean} [silent=false] Whether trigger event.
  551. */
  552. echartsProto.dispatchAction = function (payload, silent) {
  553. var actionWrap = actions[payload.type];
  554. if (actionWrap) {
  555. var actionInfo = actionWrap.actionInfo;
  556. var updateMethod = actionInfo.update || 'update';
  557. var payloads = [payload];
  558. var batched = false;
  559. // Batch action
  560. if (payload.batch) {
  561. batched = true;
  562. payloads = zrUtil.map(payload.batch, function (item) {
  563. item = zrUtil.defaults(zrUtil.extend({}, item), payload);
  564. item.batch = null;
  565. return item;
  566. });
  567. }
  568. var eventObjBatch = [];
  569. var eventObj;
  570. var isHighlightOrDownplay = payload.type === 'highlight' || payload.type === 'downplay';
  571. for (var i = 0; i < payloads.length; i++) {
  572. var batchItem = payloads[i];
  573. // Action can specify the event by return it.
  574. eventObj = actionWrap.action(batchItem, this._model);
  575. // Emit event outside
  576. eventObj = eventObj || zrUtil.extend({}, batchItem);
  577. // Convert type to eventType
  578. eventObj.type = actionInfo.event || eventObj.type;
  579. eventObjBatch.push(eventObj);
  580. // Highlight and downplay are special.
  581. isHighlightOrDownplay && updateMethods[updateMethod].call(this, batchItem);
  582. }
  583. (updateMethod !== 'none' && !isHighlightOrDownplay)
  584. && updateMethods[updateMethod].call(this, payload);
  585. if (!silent) {
  586. // Follow the rule of action batch
  587. if (batched) {
  588. eventObj = {
  589. type: actionInfo.event || payload.type,
  590. batch: eventObjBatch
  591. };
  592. }
  593. else {
  594. eventObj = eventObjBatch[0];
  595. }
  596. this._messageCenter.trigger(eventObj.type, eventObj);
  597. }
  598. }
  599. };
  600. /**
  601. * Register event
  602. * @method
  603. */
  604. echartsProto.on = createRegisterEventWithLowercaseName('on');
  605. echartsProto.off = createRegisterEventWithLowercaseName('off');
  606. echartsProto.one = createRegisterEventWithLowercaseName('one');
  607. /**
  608. * @param {string} methodName
  609. * @private
  610. */
  611. function invokeUpdateMethod(methodName, ecModel, payload) {
  612. var api = this._api;
  613. // Update all components
  614. each(this._componentsViews, function (component) {
  615. var componentModel = component.__model;
  616. component[methodName](componentModel, ecModel, api, payload);
  617. updateZ(componentModel, component);
  618. }, this);
  619. // Upate all charts
  620. ecModel.eachSeries(function (seriesModel, idx) {
  621. var chart = this._chartsMap[seriesModel.__viewId];
  622. chart[methodName](seriesModel, ecModel, api, payload);
  623. updateZ(seriesModel, chart);
  624. }, this);
  625. }
  626. /**
  627. * Prepare view instances of charts and components
  628. * @param {module:echarts/model/Global} ecModel
  629. * @private
  630. */
  631. function prepareView(type, ecModel) {
  632. var isComponent = type === 'component';
  633. var viewList = isComponent ? this._componentsViews : this._chartsViews;
  634. var viewMap = isComponent ? this._componentsMap : this._chartsMap;
  635. var zr = this._zr;
  636. for (var i = 0; i < viewList.length; i++) {
  637. viewList[i].__alive = false;
  638. }
  639. ecModel[isComponent ? 'eachComponent' : 'eachSeries'](function (componentType, model) {
  640. if (isComponent) {
  641. if (componentType === 'series') {
  642. return;
  643. }
  644. }
  645. else {
  646. model = componentType;
  647. }
  648. // Consider: id same and type changed.
  649. var viewId = model.id + '_' + model.type;
  650. var view = viewMap[viewId];
  651. if (!view) {
  652. var classType = ComponentModel.parseClassType(model.type);
  653. var Clazz = isComponent
  654. ? ComponentView.getClass(classType.main, classType.sub)
  655. : ChartView.getClass(classType.sub);
  656. if (Clazz) {
  657. view = new Clazz();
  658. view.init(ecModel, this._api);
  659. viewMap[viewId] = view;
  660. viewList.push(view);
  661. zr.add(view.group);
  662. }
  663. else {
  664. // Error
  665. return;
  666. }
  667. }
  668. model.__viewId = viewId;
  669. view.__alive = true;
  670. view.__id = viewId;
  671. view.__model = model;
  672. }, this);
  673. for (var i = 0; i < viewList.length;) {
  674. var view = viewList[i];
  675. if (!view.__alive) {
  676. zr.remove(view.group);
  677. view.dispose(ecModel, this._api);
  678. viewList.splice(i, 1);
  679. delete viewMap[view.__id];
  680. }
  681. else {
  682. i++;
  683. }
  684. }
  685. }
  686. /**
  687. * Processor data in each series
  688. *
  689. * @param {module:echarts/model/Global} ecModel
  690. * @private
  691. */
  692. function processData(ecModel, api) {
  693. each(PROCESSOR_STAGES, function (stage) {
  694. each(dataProcessorFuncs[stage] || [], function (process) {
  695. process(ecModel, api);
  696. });
  697. });
  698. }
  699. /**
  700. * @private
  701. */
  702. function stackSeriesData(ecModel) {
  703. var stackedDataMap = {};
  704. ecModel.eachSeries(function (series) {
  705. var stack = series.get('stack');
  706. var data = series.getData();
  707. if (stack && data.type === 'list') {
  708. var previousStack = stackedDataMap[stack];
  709. if (previousStack) {
  710. data.stackedOn = previousStack;
  711. }
  712. stackedDataMap[stack] = data;
  713. }
  714. });
  715. }
  716. /**
  717. * Layout before each chart render there series, after visual coding and data processing
  718. *
  719. * @param {module:echarts/model/Global} ecModel
  720. * @private
  721. */
  722. function doLayout(ecModel, payload) {
  723. var api = this._api;
  724. each(layoutFuncs, function (layout) {
  725. layout(ecModel, api, payload);
  726. });
  727. }
  728. /**
  729. * Code visual infomation from data after data processing
  730. *
  731. * @param {module:echarts/model/Global} ecModel
  732. * @private
  733. */
  734. function doVisualCoding(ecModel, payload) {
  735. each(VISUAL_CODING_STAGES, function (stage) {
  736. each(visualCodingFuncs[stage] || [], function (visualCoding) {
  737. visualCoding(ecModel, payload);
  738. });
  739. });
  740. }
  741. /**
  742. * Render each chart and component
  743. * @private
  744. */
  745. function doRender(ecModel, payload) {
  746. var api = this._api;
  747. // Render all components
  748. each(this._componentsViews, function (componentView) {
  749. var componentModel = componentView.__model;
  750. componentView.render(componentModel, ecModel, api, payload);
  751. updateZ(componentModel, componentView);
  752. }, this);
  753. each(this._chartsViews, function (chart) {
  754. chart.__alive = false;
  755. }, this);
  756. // Render all charts
  757. ecModel.eachSeries(function (seriesModel, idx) {
  758. var chartView = this._chartsMap[seriesModel.__viewId];
  759. chartView.__alive = true;
  760. chartView.render(seriesModel, ecModel, api, payload);
  761. chartView.group.silent = !!seriesModel.get('silent');
  762. updateZ(seriesModel, chartView);
  763. }, this);
  764. // Remove groups of unrendered charts
  765. each(this._chartsViews, function (chart) {
  766. if (!chart.__alive) {
  767. chart.remove(ecModel, api);
  768. }
  769. }, this);
  770. }
  771. var MOUSE_EVENT_NAMES = [
  772. 'click', 'dblclick', 'mouseover', 'mouseout', 'mousedown', 'mouseup', 'globalout'
  773. ];
  774. /**
  775. * @private
  776. */
  777. echartsProto._initEvents = function () {
  778. each(MOUSE_EVENT_NAMES, function (eveName) {
  779. this._zr.on(eveName, function (e) {
  780. var ecModel = this.getModel();
  781. var el = e.target;
  782. if (el && el.dataIndex != null) {
  783. var dataModel = el.dataModel || ecModel.getSeriesByIndex(el.seriesIndex);
  784. var params = dataModel && dataModel.getDataParams(el.dataIndex, el.dataType) || {};
  785. params.event = e;
  786. params.type = eveName;
  787. this.trigger(eveName, params);
  788. }
  789. // If element has custom eventData of components
  790. else if (el && el.eventData) {
  791. this.trigger(eveName, el.eventData);
  792. }
  793. }, this);
  794. }, this);
  795. each(eventActionMap, function (actionType, eventType) {
  796. this._messageCenter.on(eventType, function (event) {
  797. this.trigger(eventType, event);
  798. }, this);
  799. }, this);
  800. };
  801. /**
  802. * @return {boolean}
  803. */
  804. echartsProto.isDisposed = function () {
  805. return this._disposed;
  806. };
  807. /**
  808. * Clear
  809. */
  810. echartsProto.clear = function () {
  811. this.setOption({}, true);
  812. };
  813. /**
  814. * Dispose instance
  815. */
  816. echartsProto.dispose = function () {
  817. this._disposed = true;
  818. var api = this._api;
  819. var ecModel = this._model;
  820. each(this._componentsViews, function (component) {
  821. component.dispose(ecModel, api);
  822. });
  823. each(this._chartsViews, function (chart) {
  824. chart.dispose(ecModel, api);
  825. });
  826. this._zr.dispose();
  827. delete instances[this.id];
  828. };
  829. zrUtil.mixin(ECharts, Eventful);
  830. /**
  831. * @param {module:echarts/model/Series|module:echarts/model/Component} model
  832. * @param {module:echarts/view/Component|module:echarts/view/Chart} view
  833. * @return {string}
  834. */
  835. function updateZ(model, view) {
  836. var z = model.get('z');
  837. var zlevel = model.get('zlevel');
  838. // Set z and zlevel
  839. view.group.traverse(function (el) {
  840. z != null && (el.z = z);
  841. zlevel != null && (el.zlevel = zlevel);
  842. });
  843. }
  844. /**
  845. * @type {Array.<Function>}
  846. * @inner
  847. */
  848. var actions = [];
  849. /**
  850. * Map eventType to actionType
  851. * @type {Object}
  852. */
  853. var eventActionMap = {};
  854. /**
  855. * @type {Array.<Function>}
  856. * @inner
  857. */
  858. var layoutFuncs = [];
  859. /**
  860. * Data processor functions of each stage
  861. * @type {Array.<Object.<string, Function>>}
  862. * @inner
  863. */
  864. var dataProcessorFuncs = {};
  865. /**
  866. * @type {Array.<Function>}
  867. * @inner
  868. */
  869. var optionPreprocessorFuncs = [];
  870. /**
  871. * Visual coding functions of each stage
  872. * @type {Array.<Object.<string, Function>>}
  873. * @inner
  874. */
  875. var visualCodingFuncs = {};
  876. /**
  877. * Theme storage
  878. * @type {Object.<key, Object>}
  879. */
  880. var themeStorage = {};
  881. var instances = {};
  882. var connectedGroups = {};
  883. var idBase = new Date() - 0;
  884. var groupIdBase = new Date() - 0;
  885. var DOM_ATTRIBUTE_KEY = '_echarts_instance_';
  886. /**
  887. * @alias module:echarts
  888. */
  889. var echarts = {
  890. /**
  891. * @type {number}
  892. */
  893. version: '3.1.10',
  894. dependencies: {
  895. zrender: '3.1.0'
  896. }
  897. };
  898. function enableConnect(chart) {
  899. var STATUS_PENDING = 0;
  900. var STATUS_UPDATING = 1;
  901. var STATUS_UPDATED = 2;
  902. var STATUS_KEY = '__connectUpdateStatus';
  903. function updateConnectedChartsStatus(charts, status) {
  904. for (var i = 0; i < charts.length; i++) {
  905. var otherChart = charts[i];
  906. otherChart[STATUS_KEY] = status;
  907. }
  908. }
  909. zrUtil.each(eventActionMap, function (actionType, eventType) {
  910. chart._messageCenter.on(eventType, function (event) {
  911. if (connectedGroups[chart.group] && chart[STATUS_KEY] !== STATUS_PENDING) {
  912. var action = chart.makeActionFromEvent(event);
  913. var otherCharts = [];
  914. for (var id in instances) {
  915. var otherChart = instances[id];
  916. if (otherChart !== chart && otherChart.group === chart.group) {
  917. otherCharts.push(otherChart);
  918. }
  919. }
  920. updateConnectedChartsStatus(otherCharts, STATUS_PENDING);
  921. each(otherCharts, function (otherChart) {
  922. if (otherChart[STATUS_KEY] !== STATUS_UPDATING) {
  923. otherChart.dispatchAction(action);
  924. }
  925. });
  926. updateConnectedChartsStatus(otherCharts, STATUS_UPDATED);
  927. }
  928. });
  929. });
  930. }
  931. /**
  932. * @param {HTMLDomElement} dom
  933. * @param {Object} [theme]
  934. * @param {Object} opts
  935. */
  936. echarts.init = function (dom, theme, opts) {
  937. // Check version
  938. if ((zrender.version.replace('.', '') - 0) < (echarts.dependencies.zrender.replace('.', '') - 0)) {
  939. throw new Error(
  940. 'ZRender ' + zrender.version
  941. + ' is too old for ECharts ' + echarts.version
  942. + '. Current version need ZRender '
  943. + echarts.dependencies.zrender + '+'
  944. );
  945. }
  946. if (!dom) {
  947. throw new Error('Initialize failed: invalid dom.');
  948. }
  949. var chart = new ECharts(dom, theme, opts);
  950. chart.id = 'ec_' + idBase++;
  951. instances[chart.id] = chart;
  952. dom.setAttribute &&
  953. dom.setAttribute(DOM_ATTRIBUTE_KEY, chart.id);
  954. enableConnect(chart);
  955. return chart;
  956. };
  957. /**
  958. * @return {string|Array.<module:echarts~ECharts>} groupId
  959. */
  960. echarts.connect = function (groupId) {
  961. // Is array of charts
  962. if (zrUtil.isArray(groupId)) {
  963. var charts = groupId;
  964. groupId = null;
  965. // If any chart has group
  966. zrUtil.each(charts, function (chart) {
  967. if (chart.group != null) {
  968. groupId = chart.group;
  969. }
  970. });
  971. groupId = groupId || ('g_' + groupIdBase++);
  972. zrUtil.each(charts, function (chart) {
  973. chart.group = groupId;
  974. });
  975. }
  976. connectedGroups[groupId] = true;
  977. return groupId;
  978. };
  979. /**
  980. * @return {string} groupId
  981. */
  982. echarts.disConnect = function (groupId) {
  983. connectedGroups[groupId] = false;
  984. };
  985. /**
  986. * Dispose a chart instance
  987. * @param {module:echarts~ECharts|HTMLDomElement|string} chart
  988. */
  989. echarts.dispose = function (chart) {
  990. if (zrUtil.isDom(chart)) {
  991. chart = echarts.getInstanceByDom(chart);
  992. }
  993. else if (typeof chart === 'string') {
  994. chart = instances[chart];
  995. }
  996. if ((chart instanceof ECharts) && !chart.isDisposed()) {
  997. chart.dispose();
  998. }
  999. };
  1000. /**
  1001. * @param {HTMLDomElement} dom
  1002. * @return {echarts~ECharts}
  1003. */
  1004. echarts.getInstanceByDom = function (dom) {
  1005. var key = dom.getAttribute(DOM_ATTRIBUTE_KEY);
  1006. return instances[key];
  1007. };
  1008. /**
  1009. * @param {string} key
  1010. * @return {echarts~ECharts}
  1011. */
  1012. echarts.getInstanceById = function (key) {
  1013. return instances[key];
  1014. };
  1015. /**
  1016. * Register theme
  1017. */
  1018. echarts.registerTheme = function (name, theme) {
  1019. themeStorage[name] = theme;
  1020. };
  1021. /**
  1022. * Register option preprocessor
  1023. * @param {Function} preprocessorFunc
  1024. */
  1025. echarts.registerPreprocessor = function (preprocessorFunc) {
  1026. optionPreprocessorFuncs.push(preprocessorFunc);
  1027. };
  1028. /**
  1029. * @param {string} stage
  1030. * @param {Function} processorFunc
  1031. */
  1032. echarts.registerProcessor = function (stage, processorFunc) {
  1033. if (zrUtil.indexOf(PROCESSOR_STAGES, stage) < 0) {
  1034. throw new Error('stage should be one of ' + PROCESSOR_STAGES);
  1035. }
  1036. var funcs = dataProcessorFuncs[stage] || (dataProcessorFuncs[stage] = []);
  1037. funcs.push(processorFunc);
  1038. };
  1039. /**
  1040. * Usage:
  1041. * registerAction('someAction', 'someEvent', function () { ... });
  1042. * registerAction('someAction', function () { ... });
  1043. * registerAction(
  1044. * {type: 'someAction', event: 'someEvent', update: 'updateView'},
  1045. * function () { ... }
  1046. * );
  1047. *
  1048. * @param {(string|Object)} actionInfo
  1049. * @param {string} actionInfo.type
  1050. * @param {string} [actionInfo.event]
  1051. * @param {string} [actionInfo.update]
  1052. * @param {string} [eventName]
  1053. * @param {Function} action
  1054. */
  1055. echarts.registerAction = function (actionInfo, eventName, action) {
  1056. if (typeof eventName === 'function') {
  1057. action = eventName;
  1058. eventName = '';
  1059. }
  1060. var actionType = zrUtil.isObject(actionInfo)
  1061. ? actionInfo.type
  1062. : ([actionInfo, actionInfo = {
  1063. event: eventName
  1064. }][0]);
  1065. // Event name is all lowercase
  1066. actionInfo.event = (actionInfo.event || actionType).toLowerCase();
  1067. eventName = actionInfo.event;
  1068. if (!actions[actionType]) {
  1069. actions[actionType] = {action: action, actionInfo: actionInfo};
  1070. }
  1071. eventActionMap[eventName] = actionType;
  1072. };
  1073. /**
  1074. * @param {string} type
  1075. * @param {*} CoordinateSystem
  1076. */
  1077. echarts.registerCoordinateSystem = function (type, CoordinateSystem) {
  1078. CoordinateSystemManager.register(type, CoordinateSystem);
  1079. };
  1080. /**
  1081. * @param {*} layout
  1082. */
  1083. echarts.registerLayout = function (layout) {
  1084. // PENDING All functions ?
  1085. if (zrUtil.indexOf(layoutFuncs, layout) < 0) {
  1086. layoutFuncs.push(layout);
  1087. }
  1088. };
  1089. /**
  1090. * @param {string} stage
  1091. * @param {Function} visualCodingFunc
  1092. */
  1093. echarts.registerVisualCoding = function (stage, visualCodingFunc) {
  1094. if (zrUtil.indexOf(VISUAL_CODING_STAGES, stage) < 0) {
  1095. throw new Error('stage should be one of ' + VISUAL_CODING_STAGES);
  1096. }
  1097. var funcs = visualCodingFuncs[stage] || (visualCodingFuncs[stage] = []);
  1098. funcs.push(visualCodingFunc);
  1099. };
  1100. /**
  1101. * @param {Object} opts
  1102. */
  1103. echarts.extendChartView = function (opts) {
  1104. return ChartView.extend(opts);
  1105. };
  1106. /**
  1107. * @param {Object} opts
  1108. */
  1109. echarts.extendComponentModel = function (opts) {
  1110. return ComponentModel.extend(opts);
  1111. };
  1112. /**
  1113. * @param {Object} opts
  1114. */
  1115. echarts.extendSeriesModel = function (opts) {
  1116. return SeriesModel.extend(opts);
  1117. };
  1118. /**
  1119. * @param {Object} opts
  1120. */
  1121. echarts.extendComponentView = function (opts) {
  1122. return ComponentView.extend(opts);
  1123. };
  1124. /**
  1125. * ZRender need a canvas context to do measureText.
  1126. * But in node environment canvas may be created by node-canvas.
  1127. * So we need to specify how to create a canvas instead of using document.createElement('canvas')
  1128. *
  1129. * Be careful of using it in the browser.
  1130. *
  1131. * @param {Function} creator
  1132. * @example
  1133. * var Canvas = require('canvas');
  1134. * var echarts = require('echarts');
  1135. * echarts.setCanvasCreator(function () {
  1136. * // Small size is enough.
  1137. * return new Canvas(32, 32);
  1138. * });
  1139. */
  1140. echarts.setCanvasCreator = function (creator) {
  1141. zrUtil.createCanvas = creator;
  1142. };
  1143. echarts.registerVisualCoding('echarts', zrUtil.curry(
  1144. __webpack_require__(89), '', 'itemStyle'
  1145. ));
  1146. echarts.registerPreprocessor(__webpack_require__(90));
  1147. // Default action
  1148. echarts.registerAction({
  1149. type: 'highlight',
  1150. event: 'highlight',
  1151. update: 'highlight'
  1152. }, zrUtil.noop);
  1153. echarts.registerAction({
  1154. type: 'downplay',
  1155. event: 'downplay',
  1156. update: 'downplay'
  1157. }, zrUtil.noop);
  1158. // --------
  1159. // Exports
  1160. // --------
  1161. echarts.graphic = __webpack_require__(42);
  1162. echarts.number = __webpack_require__(7);
  1163. echarts.format = __webpack_require__(6);
  1164. echarts.matrix = __webpack_require__(17);
  1165. echarts.vector = __webpack_require__(16);
  1166. echarts.util = {};
  1167. each([
  1168. 'map', 'each', 'filter', 'indexOf', 'inherits',
  1169. 'reduce', 'filter', 'bind', 'curry', 'isArray',
  1170. 'isString', 'isObject', 'isFunction', 'extend'
  1171. ],
  1172. function (name) {
  1173. echarts.util[name] = zrUtil[name];
  1174. }
  1175. );
  1176. module.exports = echarts;
  1177. /***/ },
  1178. /* 2 */
  1179. /***/ function(module, exports, __webpack_require__) {
  1180. /**
  1181. * ECharts global model
  1182. *
  1183. * @module {echarts/model/Global}
  1184. *
  1185. */
  1186. var zrUtil = __webpack_require__(3);
  1187. var modelUtil = __webpack_require__(5);
  1188. var Model = __webpack_require__(8);
  1189. var each = zrUtil.each;
  1190. var filter = zrUtil.filter;
  1191. var map = zrUtil.map;
  1192. var isArray = zrUtil.isArray;
  1193. var indexOf = zrUtil.indexOf;
  1194. var isObject = zrUtil.isObject;
  1195. var ComponentModel = __webpack_require__(19);
  1196. var globalDefault = __webpack_require__(23);
  1197. var OPTION_INNER_KEY = '\0_ec_inner';
  1198. /**
  1199. * @alias module:echarts/model/Global
  1200. *
  1201. * @param {Object} option
  1202. * @param {module:echarts/model/Model} parentModel
  1203. * @param {Object} theme
  1204. */
  1205. var GlobalModel = Model.extend({
  1206. constructor: GlobalModel,
  1207. init: function (option, parentModel, theme, optionManager) {
  1208. theme = theme || {};
  1209. this.option = null; // Mark as not initialized.
  1210. /**
  1211. * @type {module:echarts/model/Model}
  1212. * @private
  1213. */
  1214. this._theme = new Model(theme);
  1215. /**
  1216. * @type {module:echarts/model/OptionManager}
  1217. */
  1218. this._optionManager = optionManager;
  1219. },
  1220. setOption: function (option, optionPreprocessorFuncs) {
  1221. zrUtil.assert(
  1222. !(OPTION_INNER_KEY in option),
  1223. 'please use chart.getOption()'
  1224. );
  1225. this._optionManager.setOption(option, optionPreprocessorFuncs);
  1226. this.resetOption();
  1227. },
  1228. /**
  1229. * @param {string} type null/undefined: reset all.
  1230. * 'recreate': force recreate all.
  1231. * 'timeline': only reset timeline option
  1232. * 'media': only reset media query option
  1233. * @return {boolean} Whether option changed.
  1234. */
  1235. resetOption: function (type) {
  1236. var optionChanged = false;
  1237. var optionManager = this._optionManager;
  1238. if (!type || type === 'recreate') {
  1239. var baseOption = optionManager.mountOption(type === 'recreate');
  1240. if (!this.option || type === 'recreate') {
  1241. initBase.call(this, baseOption);
  1242. }
  1243. else {
  1244. this.restoreData();
  1245. this.mergeOption(baseOption);
  1246. }
  1247. optionChanged = true;
  1248. }
  1249. if (type === 'timeline' || type === 'media') {
  1250. this.restoreData();
  1251. }
  1252. if (!type || type === 'recreate' || type === 'timeline') {
  1253. var timelineOption = optionManager.getTimelineOption(this);
  1254. timelineOption && (this.mergeOption(timelineOption), optionChanged = true);
  1255. }
  1256. if (!type || type === 'recreate' || type === 'media') {
  1257. var mediaOptions = optionManager.getMediaOption(this, this._api);
  1258. if (mediaOptions.length) {
  1259. each(mediaOptions, function (mediaOption) {
  1260. this.mergeOption(mediaOption, optionChanged = true);
  1261. }, this);
  1262. }
  1263. }
  1264. return optionChanged;
  1265. },
  1266. /**
  1267. * @protected
  1268. */
  1269. mergeOption: function (newOption) {
  1270. var option = this.option;
  1271. var componentsMap = this._componentsMap;
  1272. var newCptTypes = [];
  1273. // 如果不存在对应的 component model 则直接 merge
  1274. each(newOption, function (componentOption, mainType) {
  1275. if (componentOption == null) {
  1276. return;
  1277. }
  1278. if (!ComponentModel.hasClass(mainType)) {
  1279. option[mainType] = option[mainType] == null
  1280. ? zrUtil.clone(componentOption)
  1281. : zrUtil.merge(option[mainType], componentOption, true);
  1282. }
  1283. else {
  1284. newCptTypes.push(mainType);
  1285. }
  1286. });
  1287. // FIXME OPTION 同步是否要改回原来的
  1288. ComponentModel.topologicalTravel(
  1289. newCptTypes, ComponentModel.getAllClassMainTypes(), visitComponent, this
  1290. );
  1291. function visitComponent(mainType, dependencies) {
  1292. var newCptOptionList = modelUtil.normalizeToArray(newOption[mainType]);
  1293. var mapResult = modelUtil.mappingToExists(
  1294. componentsMap[mainType], newCptOptionList
  1295. );
  1296. makeKeyInfo(mainType, mapResult);
  1297. var dependentModels = getComponentsByTypes(
  1298. componentsMap, dependencies
  1299. );
  1300. option[mainType] = [];
  1301. componentsMap[mainType] = [];
  1302. each(mapResult, function (resultItem, index) {
  1303. var componentModel = resultItem.exist;
  1304. var newCptOption = resultItem.option;
  1305. zrUtil.assert(
  1306. isObject(newCptOption) || componentModel,
  1307. 'Empty component definition'
  1308. );
  1309. // Consider where is no new option and should be merged using {},
  1310. // see removeEdgeAndAdd in topologicalTravel and
  1311. // ComponentModel.getAllClassMainTypes.
  1312. if (!newCptOption) {
  1313. componentModel.mergeOption({}, this);
  1314. componentModel.optionUpdated(this);
  1315. }
  1316. else {
  1317. var ComponentModelClass = ComponentModel.getClass(
  1318. mainType, resultItem.keyInfo.subType, true
  1319. );
  1320. if (componentModel && componentModel instanceof ComponentModelClass) {
  1321. componentModel.mergeOption(newCptOption, this);
  1322. componentModel.optionUpdated(this);
  1323. }
  1324. else {
  1325. // PENDING Global as parent ?
  1326. componentModel = new ComponentModelClass(
  1327. newCptOption, this, this,
  1328. zrUtil.extend(
  1329. {
  1330. dependentModels: dependentModels,
  1331. componentIndex: index
  1332. },
  1333. resultItem.keyInfo
  1334. )
  1335. );
  1336. // Call optionUpdated after init
  1337. componentModel.optionUpdated(this);
  1338. }
  1339. }
  1340. componentsMap[mainType][index] = componentModel;
  1341. option[mainType][index] = componentModel.option;
  1342. }, this);
  1343. // Backup series for filtering.
  1344. if (mainType === 'series') {
  1345. this._seriesIndices = createSeriesIndices(componentsMap.series);
  1346. }
  1347. }
  1348. },
  1349. /**
  1350. * Get option for output (cloned option and inner info removed)
  1351. * @public
  1352. * @return {Object}
  1353. */
  1354. getOption: function () {
  1355. var option = zrUtil.clone(this.option);
  1356. each(option, function (opts, mainType) {
  1357. if (ComponentModel.hasClass(mainType)) {
  1358. var opts = modelUtil.normalizeToArray(opts);
  1359. for (var i = opts.length - 1; i >= 0; i--) {
  1360. // Remove options with inner id.
  1361. if (modelUtil.isIdInner(opts[i])) {
  1362. opts.splice(i, 1);
  1363. }
  1364. }
  1365. option[mainType] = opts;
  1366. }
  1367. });
  1368. delete option[OPTION_INNER_KEY];
  1369. return option;
  1370. },
  1371. /**
  1372. * @return {module:echarts/model/Model}
  1373. */
  1374. getTheme: function () {
  1375. return this._theme;
  1376. },
  1377. /**
  1378. * @param {string} mainType
  1379. * @param {number} [idx=0]
  1380. * @return {module:echarts/model/Component}
  1381. */
  1382. getComponent: function (mainType, idx) {
  1383. var list = this._componentsMap[mainType];
  1384. if (list) {
  1385. return list[idx || 0];
  1386. }
  1387. },
  1388. /**
  1389. * @param {Object} condition
  1390. * @param {string} condition.mainType
  1391. * @param {string} [condition.subType] If ignore, only query by mainType
  1392. * @param {number} [condition.index] Either input index or id or name.
  1393. * @param {string} [condition.id] Either input index or id or name.
  1394. * @param {string} [condition.name] Either input index or id or name.
  1395. * @return {Array.<module:echarts/model/Component>}
  1396. */
  1397. queryComponents: function (condition) {
  1398. var mainType = condition.mainType;
  1399. if (!mainType) {
  1400. return [];
  1401. }
  1402. var index = condition.index;
  1403. var id = condition.id;
  1404. var name = condition.name;
  1405. var cpts = this._componentsMap[mainType];
  1406. if (!cpts || !cpts.length) {
  1407. return [];
  1408. }
  1409. var result;
  1410. if (index != null) {
  1411. if (!isArray(index)) {
  1412. index = [index];
  1413. }
  1414. result = filter(map(index, function (idx) {
  1415. return cpts[idx];
  1416. }), function (val) {
  1417. return !!val;
  1418. });
  1419. }
  1420. else if (id != null) {
  1421. var isIdArray = isArray(id);
  1422. result = filter(cpts, function (cpt) {
  1423. return (isIdArray && indexOf(id, cpt.id) >= 0)
  1424. || (!isIdArray && cpt.id === id);
  1425. });
  1426. }
  1427. else if (name != null) {
  1428. var isNameArray = isArray(name);
  1429. result = filter(cpts, function (cpt) {
  1430. return (isNameArray && indexOf(name, cpt.name) >= 0)
  1431. || (!isNameArray && cpt.name === name);
  1432. });
  1433. }
  1434. return filterBySubType(result, condition);
  1435. },
  1436. /**
  1437. * The interface is different from queryComponents,
  1438. * which is convenient for inner usage.
  1439. *
  1440. * @usage
  1441. * var result = findComponents(
  1442. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}}
  1443. * );
  1444. * var result = findComponents(
  1445. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}}
  1446. * );
  1447. * var result = findComponents(
  1448. * {mainType: 'series'},
  1449. * function (model, index) {...}
  1450. * );
  1451. * // result like [component0, componnet1, ...]
  1452. *
  1453. * @param {Object} condition
  1454. * @param {string} condition.mainType Mandatory.
  1455. * @param {string} [condition.subType] Optional.
  1456. * @param {Object} [condition.query] like {xxxIndex, xxxId, xxxName},
  1457. * where xxx is mainType.
  1458. * If query attribute is null/undefined or has no index/id/name,
  1459. * do not filtering by query conditions, which is convenient for
  1460. * no-payload situations or when target of action is global.
  1461. * @param {Function} [condition.filter] parameter: component, return boolean.
  1462. * @return {Array.<module:echarts/model/Component>}
  1463. */
  1464. findComponents: function (condition) {
  1465. var query = condition.query;
  1466. var mainType = condition.mainType;
  1467. var queryCond = getQueryCond(query);
  1468. var result = queryCond
  1469. ? this.queryComponents(queryCond)
  1470. : this._componentsMap[mainType];
  1471. return doFilter(filterBySubType(result, condition));
  1472. function getQueryCond(q) {
  1473. var indexAttr = mainType + 'Index';
  1474. var idAttr = mainType + 'Id';
  1475. var nameAttr = mainType + 'Name';
  1476. return q && (
  1477. q.hasOwnProperty(indexAttr)
  1478. || q.hasOwnProperty(idAttr)
  1479. || q.hasOwnProperty(nameAttr)
  1480. )
  1481. ? {
  1482. mainType: mainType,
  1483. // subType will be filtered finally.
  1484. index: q[indexAttr],
  1485. id: q[idAttr],
  1486. name: q[nameAttr]
  1487. }
  1488. : null;
  1489. }
  1490. function doFilter(res) {
  1491. return condition.filter
  1492. ? filter(res, condition.filter)
  1493. : res;
  1494. }
  1495. },
  1496. /**
  1497. * @usage
  1498. * eachComponent('legend', function (legendModel, index) {
  1499. * ...
  1500. * });
  1501. * eachComponent(function (componentType, model, index) {
  1502. * // componentType does not include subType
  1503. * // (componentType is 'xxx' but not 'xxx.aa')
  1504. * });
  1505. * eachComponent(
  1506. * {mainType: 'dataZoom', query: {dataZoomId: 'abc'}},
  1507. * function (model, index) {...}
  1508. * );
  1509. * eachComponent(
  1510. * {mainType: 'series', subType: 'pie', query: {seriesName: 'uio'}},
  1511. * function (model, index) {...}
  1512. * );
  1513. *
  1514. * @param {string|Object=} mainType When mainType is object, the definition
  1515. * is the same as the method 'findComponents'.
  1516. * @param {Function} cb
  1517. * @param {*} context
  1518. */
  1519. eachComponent: function (mainType, cb, context) {
  1520. var componentsMap = this._componentsMap;
  1521. if (typeof mainType === 'function') {
  1522. context = cb;
  1523. cb = mainType;
  1524. each(componentsMap, function (components, componentType) {
  1525. each(components, function (component, index) {
  1526. cb.call(context, componentType, component, index);
  1527. });
  1528. });
  1529. }
  1530. else if (zrUtil.isString(mainType)) {
  1531. each(componentsMap[mainType], cb, context);
  1532. }
  1533. else if (isObject(mainType)) {
  1534. var queryResult = this.findComponents(mainType);
  1535. each(queryResult, cb, context);
  1536. }
  1537. },
  1538. /**
  1539. * @param {string} name
  1540. * @return {Array.<module:echarts/model/Series>}
  1541. */
  1542. getSeriesByName: function (name) {
  1543. var series = this._componentsMap.series;
  1544. return filter(series, function (oneSeries) {
  1545. return oneSeries.name === name;
  1546. });
  1547. },
  1548. /**
  1549. * @param {number} seriesIndex
  1550. * @return {module:echarts/model/Series}
  1551. */
  1552. getSeriesByIndex: function (seriesIndex) {
  1553. return this._componentsMap.series[seriesIndex];
  1554. },
  1555. /**
  1556. * @param {string} subType
  1557. * @return {Array.<module:echarts/model/Series>}
  1558. */
  1559. getSeriesByType: function (subType) {
  1560. var series = this._componentsMap.series;
  1561. return filter(series, function (oneSeries) {
  1562. return oneSeries.subType === subType;
  1563. });
  1564. },
  1565. /**
  1566. * @return {Array.<module:echarts/model/Series>}
  1567. */
  1568. getSeries: function () {
  1569. return this._componentsMap.series.slice();
  1570. },
  1571. /**
  1572. * After filtering, series may be different
  1573. * frome raw series.
  1574. *
  1575. * @param {Function} cb
  1576. * @param {*} context
  1577. */
  1578. eachSeries: function (cb, context) {
  1579. assertSeriesInitialized(this);
  1580. each(this._seriesIndices, function (rawSeriesIndex) {
  1581. var series = this._componentsMap.series[rawSeriesIndex];
  1582. cb.call(context, series, rawSeriesIndex);
  1583. }, this);
  1584. },
  1585. /**
  1586. * Iterate raw series before filtered.
  1587. *
  1588. * @param {Function} cb
  1589. * @param {*} context
  1590. */
  1591. eachRawSeries: function (cb, context) {
  1592. each(this._componentsMap.series, cb, context);
  1593. },
  1594. /**
  1595. * After filtering, series may be different.
  1596. * frome raw series.
  1597. *
  1598. * @parma {string} subType
  1599. * @param {Function} cb
  1600. * @param {*} context
  1601. */
  1602. eachSeriesByType: function (subType, cb, context) {
  1603. assertSeriesInitialized(this);
  1604. each(this._seriesIndices, function (rawSeriesIndex) {
  1605. var series = this._componentsMap.series[rawSeriesIndex];
  1606. if (series.subType === subType) {
  1607. cb.call(context, series, rawSeriesIndex);
  1608. }
  1609. }, this);
  1610. },
  1611. /**
  1612. * Iterate raw series before filtered of given type.
  1613. *
  1614. * @parma {string} subType
  1615. * @param {Function} cb
  1616. * @param {*} context
  1617. */
  1618. eachRawSeriesByType: function (subType, cb, context) {
  1619. return each(this.getSeriesByType(subType), cb, context);
  1620. },
  1621. /**
  1622. * @param {module:echarts/model/Series} seriesModel
  1623. */
  1624. isSeriesFiltered: function (seriesModel) {
  1625. assertSeriesInitialized(this);
  1626. return zrUtil.indexOf(this._seriesIndices, seriesModel.componentIndex) < 0;
  1627. },
  1628. /**
  1629. * @param {Function} cb
  1630. * @param {*} context
  1631. */
  1632. filterSeries: function (cb, context) {
  1633. assertSeriesInitialized(this);
  1634. var filteredSeries = filter(
  1635. this._componentsMap.series, cb, context
  1636. );
  1637. this._seriesIndices = createSeriesIndices(filteredSeries);
  1638. },
  1639. restoreData: function () {
  1640. var componentsMap = this._componentsMap;
  1641. this._seriesIndices = createSeriesIndices(componentsMap.series);
  1642. var componentTypes = [];
  1643. each(componentsMap, function (components, componentType) {
  1644. componentTypes.push(componentType);
  1645. });
  1646. ComponentModel.topologicalTravel(
  1647. componentTypes,
  1648. ComponentModel.getAllClassMainTypes(),
  1649. function (componentType, dependencies) {
  1650. each(componentsMap[componentType], function (component) {
  1651. component.restoreData();
  1652. });
  1653. }
  1654. );
  1655. }
  1656. });
  1657. /**
  1658. * @inner
  1659. */
  1660. function mergeTheme(option, theme) {
  1661. for (var name in theme) {
  1662. // 如果有 component model 则把具体的 merge 逻辑交给该 model 处理
  1663. if (!ComponentModel.hasClass(name)) {
  1664. if (typeof theme[name] === 'object') {
  1665. option[name] = !option[name]
  1666. ? zrUtil.clone(theme[name])
  1667. : zrUtil.merge(option[name], theme[name], false);
  1668. }
  1669. else {
  1670. if (option[name] == null) {
  1671. option[name] = theme[name];
  1672. }
  1673. }
  1674. }
  1675. }
  1676. }
  1677. function initBase(baseOption) {
  1678. baseOption = baseOption;
  1679. // Using OPTION_INNER_KEY to mark that this option can not be used outside,
  1680. // i.e. `chart.setOption(chart.getModel().option);` is forbiden.
  1681. this.option = {};
  1682. this.option[OPTION_INNER_KEY] = 1;
  1683. /**
  1684. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  1685. * @private
  1686. */
  1687. this._componentsMap = {};
  1688. /**
  1689. * Mapping between filtered series list and raw series list.
  1690. * key: filtered series indices, value: raw series indices.
  1691. * @type {Array.<nubmer>}
  1692. * @private
  1693. */
  1694. this._seriesIndices = null;
  1695. mergeTheme(baseOption, this._theme.option);
  1696. // TODO Needs clone when merging to the unexisted property
  1697. zrUtil.merge(baseOption, globalDefault, false);
  1698. this.mergeOption(baseOption);
  1699. }
  1700. /**
  1701. * @inner
  1702. * @param {Array.<string>|string} types model types
  1703. * @return {Object} key: {string} type, value: {Array.<Object>} models
  1704. */
  1705. function getComponentsByTypes(componentsMap, types) {
  1706. if (!zrUtil.isArray(types)) {
  1707. types = types ? [types] : [];
  1708. }
  1709. var ret = {};
  1710. each(types, function (type) {
  1711. ret[type] = (componentsMap[type] || []).slice();
  1712. });
  1713. return ret;
  1714. }
  1715. /**
  1716. * @inner
  1717. */
  1718. function makeKeyInfo(mainType, mapResult) {
  1719. // We use this id to hash component models and view instances
  1720. // in echarts. id can be specified by user, or auto generated.
  1721. // The id generation rule ensures new view instance are able
  1722. // to mapped to old instance when setOption are called in
  1723. // no-merge mode. So we generate model id by name and plus
  1724. // type in view id.
  1725. // name can be duplicated among components, which is convenient
  1726. // to specify multi components (like series) by one name.
  1727. // Ensure that each id is distinct.
  1728. var idMap = {};
  1729. each(mapResult, function (item, index) {
  1730. var existCpt = item.exist;
  1731. existCpt && (idMap[existCpt.id] = item);
  1732. });
  1733. each(mapResult, function (item, index) {
  1734. var opt = item.option;
  1735. zrUtil.assert(
  1736. !opt || opt.id == null || !idMap[opt.id] || idMap[opt.id] === item,
  1737. 'id duplicates: ' + (opt && opt.id)
  1738. );
  1739. opt && opt.id != null && (idMap[opt.id] = item);
  1740. // Complete subType
  1741. if (isObject(opt)) {
  1742. var subType = determineSubType(mainType, opt, item.exist);
  1743. item.keyInfo = {mainType: mainType, subType: subType};
  1744. }
  1745. });
  1746. // Make name and id.
  1747. each(mapResult, function (item, index) {
  1748. var existCpt = item.exist;
  1749. var opt = item.option;
  1750. var keyInfo = item.keyInfo;
  1751. if (!isObject(opt)) {
  1752. return;
  1753. }
  1754. // name can be overwitten. Consider case: axis.name = '20km'.
  1755. // But id generated by name will not be changed, which affect
  1756. // only in that case: setOption with 'not merge mode' and view
  1757. // instance will be recreated, which can be accepted.
  1758. keyInfo.name = opt.name != null
  1759. ? opt.name + ''
  1760. : existCpt
  1761. ? existCpt.name
  1762. : '\0-';
  1763. if (existCpt) {
  1764. keyInfo.id = existCpt.id;
  1765. }
  1766. else if (opt.id != null) {
  1767. keyInfo.id = opt.id + '';
  1768. }
  1769. else {
  1770. // Consider this situatoin:
  1771. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  1772. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  1773. // Series with the same name between optionA and optionB
  1774. // should be mapped.
  1775. var idNum = 0;
  1776. do {
  1777. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  1778. }
  1779. while (idMap[keyInfo.id]);
  1780. }
  1781. idMap[keyInfo.id] = item;
  1782. });
  1783. }
  1784. /**
  1785. * @inner
  1786. */
  1787. function determineSubType(mainType, newCptOption, existComponent) {
  1788. var subType = newCptOption.type
  1789. ? newCptOption.type
  1790. : existComponent
  1791. ? existComponent.subType
  1792. // Use determineSubType only when there is no existComponent.
  1793. : ComponentModel.determineSubType(mainType, newCptOption);
  1794. // tooltip, markline, markpoint may always has no subType
  1795. return subType;
  1796. }
  1797. /**
  1798. * @inner
  1799. */
  1800. function createSeriesIndices(seriesModels) {
  1801. return map(seriesModels, function (series) {
  1802. return series.componentIndex;
  1803. }) || [];
  1804. }
  1805. /**
  1806. * @inner
  1807. */
  1808. function filterBySubType(components, condition) {
  1809. // Using hasOwnProperty for restrict. Consider
  1810. // subType is undefined in user payload.
  1811. return condition.hasOwnProperty('subType')
  1812. ? filter(components, function (cpt) {
  1813. return cpt.subType === condition.subType;
  1814. })
  1815. : components;
  1816. }
  1817. /**
  1818. * @inner
  1819. */
  1820. function assertSeriesInitialized(ecModel) {
  1821. // Components that use _seriesIndices should depends on series component,
  1822. // which make sure that their initialization is after series.
  1823. if (!ecModel._seriesIndices) {
  1824. throw new Error('Series has not been initialized yet.');
  1825. }
  1826. }
  1827. module.exports = GlobalModel;
  1828. /***/ },
  1829. /* 3 */
  1830. /***/ function(module, exports, __webpack_require__) {
  1831. /**
  1832. * @module zrender/core/util
  1833. */
  1834. var Gradient = __webpack_require__(4);
  1835. // 用于处理merge时无法遍历Date等对象的问题
  1836. var BUILTIN_OBJECT = {
  1837. '[object Function]': 1,
  1838. '[object RegExp]': 1,
  1839. '[object Date]': 1,
  1840. '[object Error]': 1,
  1841. '[object CanvasGradient]': 1
  1842. };
  1843. var objToString = Object.prototype.toString;
  1844. var arrayProto = Array.prototype;
  1845. var nativeForEach = arrayProto.forEach;
  1846. var nativeFilter = arrayProto.filter;
  1847. var nativeSlice = arrayProto.slice;
  1848. var nativeMap = arrayProto.map;
  1849. var nativeReduce = arrayProto.reduce;
  1850. /**
  1851. * @param {*} source
  1852. * @return {*} 拷贝后的新对象
  1853. */
  1854. function clone(source) {
  1855. if (typeof source == 'object' && source !== null) {
  1856. var result = source;
  1857. if (source instanceof Array) {
  1858. result = [];
  1859. for (var i = 0, len = source.length; i < len; i++) {
  1860. result[i] = clone(source[i]);
  1861. }
  1862. }
  1863. else if (
  1864. !isBuildInObject(source)
  1865. // 是否为 dom 对象
  1866. && !isDom(source)
  1867. ) {
  1868. result = {};
  1869. for (var key in source) {
  1870. if (source.hasOwnProperty(key)) {
  1871. result[key] = clone(source[key]);
  1872. }
  1873. }
  1874. }
  1875. return result;
  1876. }
  1877. return source;
  1878. }
  1879. /**
  1880. * @memberOf module:zrender/core/util
  1881. * @param {*} target
  1882. * @param {*} source
  1883. * @param {boolean} [overwrite=false]
  1884. */
  1885. function merge(target, source, overwrite) {
  1886. // We should escapse that source is string
  1887. // and enter for ... in ...
  1888. if (!isObject(source) || !isObject(target)) {
  1889. return overwrite ? clone(source) : target;
  1890. }
  1891. for (var key in source) {
  1892. if (source.hasOwnProperty(key)) {
  1893. var targetProp = target[key];
  1894. var sourceProp = source[key];
  1895. if (isObject(sourceProp)
  1896. && isObject(targetProp)
  1897. && !isArray(sourceProp)
  1898. && !isArray(targetProp)
  1899. && !isDom(sourceProp)
  1900. && !isDom(targetProp)
  1901. && !isBuildInObject(sourceProp)
  1902. && !isBuildInObject(targetProp)
  1903. ) {
  1904. // 如果需要递归覆盖,就递归调用merge
  1905. merge(targetProp, sourceProp, overwrite);
  1906. }
  1907. else if (overwrite || !(key in target)) {
  1908. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  1909. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  1910. target[key] = clone(source[key], true);
  1911. }
  1912. }
  1913. }
  1914. return target;
  1915. }
  1916. /**
  1917. * @param {Array} targetAndSources The first item is target, and the rests are source.
  1918. * @param {boolean} [overwrite=false]
  1919. * @return {*} target
  1920. */
  1921. function mergeAll(targetAndSources, overwrite) {
  1922. var result = targetAndSources[0];
  1923. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  1924. result = merge(result, targetAndSources[i], overwrite);
  1925. }
  1926. return result;
  1927. }
  1928. /**
  1929. * @param {*} target
  1930. * @param {*} source
  1931. * @memberOf module:zrender/core/util
  1932. */
  1933. function extend(target, source) {
  1934. for (var key in source) {
  1935. if (source.hasOwnProperty(key)) {
  1936. target[key] = source[key];
  1937. }
  1938. }
  1939. return target;
  1940. }
  1941. /**
  1942. * @param {*} target
  1943. * @param {*} source
  1944. * @param {boolen} [overlay=false]
  1945. * @memberOf module:zrender/core/util
  1946. */
  1947. function defaults(target, source, overlay) {
  1948. for (var key in source) {
  1949. if (source.hasOwnProperty(key)
  1950. && (overlay ? source[key] != null : target[key] == null)
  1951. ) {
  1952. target[key] = source[key];
  1953. }
  1954. }
  1955. return target;
  1956. }
  1957. function createCanvas() {
  1958. return document.createElement('canvas');
  1959. }
  1960. // FIXME
  1961. var _ctx;
  1962. function getContext() {
  1963. if (!_ctx) {
  1964. // Use util.createCanvas instead of createCanvas
  1965. // because createCanvas may be overwritten in different environment
  1966. _ctx = util.createCanvas().getContext('2d');
  1967. }
  1968. return _ctx;
  1969. }
  1970. /**
  1971. * 查询数组中元素的index
  1972. * @memberOf module:zrender/core/util
  1973. */
  1974. function indexOf(array, value) {
  1975. if (array) {
  1976. if (array.indexOf) {
  1977. return array.indexOf(value);
  1978. }
  1979. for (var i = 0, len = array.length; i < len; i++) {
  1980. if (array[i] === value) {
  1981. return i;
  1982. }
  1983. }
  1984. }
  1985. return -1;
  1986. }
  1987. /**
  1988. * 构造类继承关系
  1989. *
  1990. * @memberOf module:zrender/core/util
  1991. * @param {Function} clazz 源类
  1992. * @param {Function} baseClazz 基类
  1993. */
  1994. function inherits(clazz, baseClazz) {
  1995. var clazzPrototype = clazz.prototype;
  1996. function F() {}
  1997. F.prototype = baseClazz.prototype;
  1998. clazz.prototype = new F();
  1999. for (var prop in clazzPrototype) {
  2000. clazz.prototype[prop] = clazzPrototype[prop];
  2001. }
  2002. clazz.prototype.constructor = clazz;
  2003. clazz.superClass = baseClazz;
  2004. }
  2005. /**
  2006. * @memberOf module:zrender/core/util
  2007. * @param {Object|Function} target
  2008. * @param {Object|Function} sorce
  2009. * @param {boolean} overlay
  2010. */
  2011. function mixin(target, source, overlay) {
  2012. target = 'prototype' in target ? target.prototype : target;
  2013. source = 'prototype' in source ? source.prototype : source;
  2014. defaults(target, source, overlay);
  2015. }
  2016. /**
  2017. * @param {Array|TypedArray} data
  2018. */
  2019. function isArrayLike(data) {
  2020. if (! data) {
  2021. return;
  2022. }
  2023. if (typeof data == 'string') {
  2024. return false;
  2025. }
  2026. return typeof data.length == 'number';
  2027. }
  2028. /**
  2029. * 数组或对象遍历
  2030. * @memberOf module:zrender/core/util
  2031. * @param {Object|Array} obj
  2032. * @param {Function} cb
  2033. * @param {*} [context]
  2034. */
  2035. function each(obj, cb, context) {
  2036. if (!(obj && cb)) {
  2037. return;
  2038. }
  2039. if (obj.forEach && obj.forEach === nativeForEach) {
  2040. obj.forEach(cb, context);
  2041. }
  2042. else if (obj.length === +obj.length) {
  2043. for (var i = 0, len = obj.length; i < len; i++) {
  2044. cb.call(context, obj[i], i, obj);
  2045. }
  2046. }
  2047. else {
  2048. for (var key in obj) {
  2049. if (obj.hasOwnProperty(key)) {
  2050. cb.call(context, obj[key], key, obj);
  2051. }
  2052. }
  2053. }
  2054. }
  2055. /**
  2056. * 数组映射
  2057. * @memberOf module:zrender/core/util
  2058. * @param {Array} obj
  2059. * @param {Function} cb
  2060. * @param {*} [context]
  2061. * @return {Array}
  2062. */
  2063. function map(obj, cb, context) {
  2064. if (!(obj && cb)) {
  2065. return;
  2066. }
  2067. if (obj.map && obj.map === nativeMap) {
  2068. return obj.map(cb, context);
  2069. }
  2070. else {
  2071. var result = [];
  2072. for (var i = 0, len = obj.length; i < len; i++) {
  2073. result.push(cb.call(context, obj[i], i, obj));
  2074. }
  2075. return result;
  2076. }
  2077. }
  2078. /**
  2079. * @memberOf module:zrender/core/util
  2080. * @param {Array} obj
  2081. * @param {Function} cb
  2082. * @param {Object} [memo]
  2083. * @param {*} [context]
  2084. * @return {Array}
  2085. */
  2086. function reduce(obj, cb, memo, context) {
  2087. if (!(obj && cb)) {
  2088. return;
  2089. }
  2090. if (obj.reduce && obj.reduce === nativeReduce) {
  2091. return obj.reduce(cb, memo, context);
  2092. }
  2093. else {
  2094. for (var i = 0, len = obj.length; i < len; i++) {
  2095. memo = cb.call(context, memo, obj[i], i, obj);
  2096. }
  2097. return memo;
  2098. }
  2099. }
  2100. /**
  2101. * 数组过滤
  2102. * @memberOf module:zrender/core/util
  2103. * @param {Array} obj
  2104. * @param {Function} cb
  2105. * @param {*} [context]
  2106. * @return {Array}
  2107. */
  2108. function filter(obj, cb, context) {
  2109. if (!(obj && cb)) {
  2110. return;
  2111. }
  2112. if (obj.filter && obj.filter === nativeFilter) {
  2113. return obj.filter(cb, context);
  2114. }
  2115. else {
  2116. var result = [];
  2117. for (var i = 0, len = obj.length; i < len; i++) {
  2118. if (cb.call(context, obj[i], i, obj)) {
  2119. result.push(obj[i]);
  2120. }
  2121. }
  2122. return result;
  2123. }
  2124. }
  2125. /**
  2126. * 数组项查找
  2127. * @memberOf module:zrender/core/util
  2128. * @param {Array} obj
  2129. * @param {Function} cb
  2130. * @param {*} [context]
  2131. * @return {Array}
  2132. */
  2133. function find(obj, cb, context) {
  2134. if (!(obj && cb)) {
  2135. return;
  2136. }
  2137. for (var i = 0, len = obj.length; i < len; i++) {
  2138. if (cb.call(context, obj[i], i, obj)) {
  2139. return obj[i];
  2140. }
  2141. }
  2142. }
  2143. /**
  2144. * @memberOf module:zrender/core/util
  2145. * @param {Function} func
  2146. * @param {*} context
  2147. * @return {Function}
  2148. */
  2149. function bind(func, context) {
  2150. var args = nativeSlice.call(arguments, 2);
  2151. return function () {
  2152. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  2153. };
  2154. }
  2155. /**
  2156. * @memberOf module:zrender/core/util
  2157. * @param {Function} func
  2158. * @return {Function}
  2159. */
  2160. function curry(func) {
  2161. var args = nativeSlice.call(arguments, 1);
  2162. return function () {
  2163. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  2164. };
  2165. }
  2166. /**
  2167. * @memberOf module:zrender/core/util
  2168. * @param {*} value
  2169. * @return {boolean}
  2170. */
  2171. function isArray(value) {
  2172. return objToString.call(value) === '[object Array]';
  2173. }
  2174. /**
  2175. * @memberOf module:zrender/core/util
  2176. * @param {*} value
  2177. * @return {boolean}
  2178. */
  2179. function isFunction(value) {
  2180. return typeof value === 'function';
  2181. }
  2182. /**
  2183. * @memberOf module:zrender/core/util
  2184. * @param {*} value
  2185. * @return {boolean}
  2186. */
  2187. function isString(value) {
  2188. return objToString.call(value) === '[object String]';
  2189. }
  2190. /**
  2191. * @memberOf module:zrender/core/util
  2192. * @param {*} value
  2193. * @return {boolean}
  2194. */
  2195. function isObject(value) {
  2196. // Avoid a V8 JIT bug in Chrome 19-20.
  2197. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  2198. var type = typeof value;
  2199. return type === 'function' || (!!value && type == 'object');
  2200. }
  2201. /**
  2202. * @memberOf module:zrender/core/util
  2203. * @param {*} value
  2204. * @return {boolean}
  2205. */
  2206. function isBuildInObject(value) {
  2207. return !!BUILTIN_OBJECT[objToString.call(value)]
  2208. || (value instanceof Gradient);
  2209. }
  2210. /**
  2211. * @memberOf module:zrender/core/util
  2212. * @param {*} value
  2213. * @return {boolean}
  2214. */
  2215. function isDom(value) {
  2216. return value && value.nodeType === 1
  2217. && typeof(value.nodeName) == 'string';
  2218. }
  2219. /**
  2220. * If value1 is not null, then return value1, otherwise judget rest of values.
  2221. * @memberOf module:zrender/core/util
  2222. * @return {*} Final value
  2223. */
  2224. function retrieve(values) {
  2225. for (var i = 0, len = arguments.length; i < len; i++) {
  2226. if (arguments[i] != null) {
  2227. return arguments[i];
  2228. }
  2229. }
  2230. }
  2231. /**
  2232. * @memberOf module:zrender/core/util
  2233. * @param {Array} arr
  2234. * @param {number} startIndex
  2235. * @param {number} endIndex
  2236. * @return {Array}
  2237. */
  2238. function slice() {
  2239. return Function.call.apply(nativeSlice, arguments);
  2240. }
  2241. /**
  2242. * @memberOf module:zrender/core/util
  2243. * @param {boolean} condition
  2244. * @param {string} message
  2245. */
  2246. function assert(condition, message) {
  2247. if (!condition) {
  2248. throw new Error(message);
  2249. }
  2250. }
  2251. var util = {
  2252. inherits: inherits,
  2253. mixin: mixin,
  2254. clone: clone,
  2255. merge: merge,
  2256. mergeAll: mergeAll,
  2257. extend: extend,
  2258. defaults: defaults,
  2259. getContext: getContext,
  2260. createCanvas: createCanvas,
  2261. indexOf: indexOf,
  2262. slice: slice,
  2263. find: find,
  2264. isArrayLike: isArrayLike,
  2265. each: each,
  2266. map: map,
  2267. reduce: reduce,
  2268. filter: filter,
  2269. bind: bind,
  2270. curry: curry,
  2271. isArray: isArray,
  2272. isString: isString,
  2273. isObject: isObject,
  2274. isFunction: isFunction,
  2275. isBuildInObject: isBuildInObject,
  2276. isDom: isDom,
  2277. retrieve: retrieve,
  2278. assert: assert,
  2279. noop: function () {}
  2280. };
  2281. module.exports = util;
  2282. /***/ },
  2283. /* 4 */
  2284. /***/ function(module, exports) {
  2285. /**
  2286. * @param {Array.<Object>} colorStops
  2287. */
  2288. var Gradient = function (colorStops) {
  2289. this.colorStops = colorStops || [];
  2290. };
  2291. Gradient.prototype = {
  2292. constructor: Gradient,
  2293. addColorStop: function (offset, color) {
  2294. this.colorStops.push({
  2295. offset: offset,
  2296. color: color
  2297. });
  2298. }
  2299. };
  2300. module.exports = Gradient;
  2301. /***/ },
  2302. /* 5 */
  2303. /***/ function(module, exports, __webpack_require__) {
  2304. var formatUtil = __webpack_require__(6);
  2305. var nubmerUtil = __webpack_require__(7);
  2306. var zrUtil = __webpack_require__(3);
  2307. var AXIS_DIMS = ['x', 'y', 'z', 'radius', 'angle'];
  2308. var modelUtil = {};
  2309. /**
  2310. * Create "each" method to iterate names.
  2311. *
  2312. * @pubilc
  2313. * @param {Array.<string>} names
  2314. * @param {Array.<string>=} attrs
  2315. * @return {Function}
  2316. */
  2317. modelUtil.createNameEach = function (names, attrs) {
  2318. names = names.slice();
  2319. var capitalNames = zrUtil.map(names, modelUtil.capitalFirst);
  2320. attrs = (attrs || []).slice();
  2321. var capitalAttrs = zrUtil.map(attrs, modelUtil.capitalFirst);
  2322. return function (callback, context) {
  2323. zrUtil.each(names, function (name, index) {
  2324. var nameObj = {name: name, capital: capitalNames[index]};
  2325. for (var j = 0; j < attrs.length; j++) {
  2326. nameObj[attrs[j]] = name + capitalAttrs[j];
  2327. }
  2328. callback.call(context, nameObj);
  2329. });
  2330. };
  2331. };
  2332. /**
  2333. * @public
  2334. */
  2335. modelUtil.capitalFirst = function (str) {
  2336. return str ? str.charAt(0).toUpperCase() + str.substr(1) : str;
  2337. };
  2338. /**
  2339. * Iterate each dimension name.
  2340. *
  2341. * @public
  2342. * @param {Function} callback The parameter is like:
  2343. * {
  2344. * name: 'angle',
  2345. * capital: 'Angle',
  2346. * axis: 'angleAxis',
  2347. * axisIndex: 'angleAixs',
  2348. * index: 'angleIndex'
  2349. * }
  2350. * @param {Object} context
  2351. */
  2352. modelUtil.eachAxisDim = modelUtil.createNameEach(AXIS_DIMS, ['axisIndex', 'axis', 'index']);
  2353. /**
  2354. * If value is not array, then translate it to array.
  2355. * @param {*} value
  2356. * @return {Array} [value] or value
  2357. */
  2358. modelUtil.normalizeToArray = function (value) {
  2359. return zrUtil.isArray(value)
  2360. ? value
  2361. : value == null
  2362. ? []
  2363. : [value];
  2364. };
  2365. /**
  2366. * If tow dataZoomModels has the same axis controlled, we say that they are 'linked'.
  2367. * dataZoomModels and 'links' make up one or more graphics.
  2368. * This function finds the graphic where the source dataZoomModel is in.
  2369. *
  2370. * @public
  2371. * @param {Function} forEachNode Node iterator.
  2372. * @param {Function} forEachEdgeType edgeType iterator
  2373. * @param {Function} edgeIdGetter Giving node and edgeType, return an array of edge id.
  2374. * @return {Function} Input: sourceNode, Output: Like {nodes: [], dims: {}}
  2375. */
  2376. modelUtil.createLinkedNodesFinder = function (forEachNode, forEachEdgeType, edgeIdGetter) {
  2377. return function (sourceNode) {
  2378. var result = {
  2379. nodes: [],
  2380. records: {} // key: edgeType.name, value: Object (key: edge id, value: boolean).
  2381. };
  2382. forEachEdgeType(function (edgeType) {
  2383. result.records[edgeType.name] = {};
  2384. });
  2385. if (!sourceNode) {
  2386. return result;
  2387. }
  2388. absorb(sourceNode, result);
  2389. var existsLink;
  2390. do {
  2391. existsLink = false;
  2392. forEachNode(processSingleNode);
  2393. }
  2394. while (existsLink);
  2395. function processSingleNode(node) {
  2396. if (!isNodeAbsorded(node, result) && isLinked(node, result)) {
  2397. absorb(node, result);
  2398. existsLink = true;
  2399. }
  2400. }
  2401. return result;
  2402. };
  2403. function isNodeAbsorded(node, result) {
  2404. return zrUtil.indexOf(result.nodes, node) >= 0;
  2405. }
  2406. function isLinked(node, result) {
  2407. var hasLink = false;
  2408. forEachEdgeType(function (edgeType) {
  2409. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  2410. result.records[edgeType.name][edgeId] && (hasLink = true);
  2411. });
  2412. });
  2413. return hasLink;
  2414. }
  2415. function absorb(node, result) {
  2416. result.nodes.push(node);
  2417. forEachEdgeType(function (edgeType) {
  2418. zrUtil.each(edgeIdGetter(node, edgeType) || [], function (edgeId) {
  2419. result.records[edgeType.name][edgeId] = true;
  2420. });
  2421. });
  2422. }
  2423. };
  2424. /**
  2425. * Sync default option between normal and emphasis like `position` and `show`
  2426. * In case some one will write code like
  2427. * label: {
  2428. * normal: {
  2429. * show: false,
  2430. * position: 'outside',
  2431. * textStyle: {
  2432. * fontSize: 18
  2433. * }
  2434. * },
  2435. * emphasis: {
  2436. * show: true
  2437. * }
  2438. * }
  2439. * @param {Object} opt
  2440. * @param {Array.<string>} subOpts
  2441. */
  2442. modelUtil.defaultEmphasis = function (opt, subOpts) {
  2443. if (opt) {
  2444. var emphasisOpt = opt.emphasis = opt.emphasis || {};
  2445. var normalOpt = opt.normal = opt.normal || {};
  2446. // Default emphasis option from normal
  2447. zrUtil.each(subOpts, function (subOptName) {
  2448. var val = zrUtil.retrieve(emphasisOpt[subOptName], normalOpt[subOptName]);
  2449. if (val != null) {
  2450. emphasisOpt[subOptName] = val;
  2451. }
  2452. });
  2453. }
  2454. };
  2455. modelUtil.LABEL_OPTIONS = ['position', 'show', 'textStyle', 'distance', 'formatter'];
  2456. /**
  2457. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  2458. * This helper method retieves value from data.
  2459. * @param {string|number|Date|Array|Object} dataItem
  2460. * @return {number|string|Date|Array.<number|string|Date>}
  2461. */
  2462. modelUtil.getDataItemValue = function (dataItem) {
  2463. // Performance sensitive.
  2464. return dataItem && (dataItem.value == null ? dataItem : dataItem.value);
  2465. };
  2466. /**
  2467. * This helper method convert value in data.
  2468. * @param {string|number|Date} value
  2469. * @param {Object|string} [dimInfo] If string (like 'x'), dimType defaults 'number'.
  2470. */
  2471. modelUtil.converDataValue = function (value, dimInfo) {
  2472. // Performance sensitive.
  2473. var dimType = dimInfo && dimInfo.type;
  2474. if (dimType === 'ordinal') {
  2475. return value;
  2476. }
  2477. if (dimType === 'time' && !isFinite(value) && value != null && value !== '-') {
  2478. value = +nubmerUtil.parseDate(value);
  2479. }
  2480. // dimType defaults 'number'.
  2481. // If dimType is not ordinal and value is null or undefined or NaN or '-',
  2482. // parse to NaN.
  2483. return (value == null || value === '')
  2484. ? NaN : +value; // If string (like '-'), using '+' parse to NaN
  2485. };
  2486. modelUtil.dataFormatMixin = {
  2487. /**
  2488. * Get params for formatter
  2489. * @param {number} dataIndex
  2490. * @param {string} [dataType]
  2491. * @return {Object}
  2492. */
  2493. getDataParams: function (dataIndex, dataType) {
  2494. var data = this.getData(dataType);
  2495. var seriesIndex = this.seriesIndex;
  2496. var seriesName = this.name;
  2497. var rawValue = this.getRawValue(dataIndex, dataType);
  2498. var rawDataIndex = data.getRawIndex(dataIndex);
  2499. var name = data.getName(dataIndex, true);
  2500. var itemOpt = data.getRawDataItem(dataIndex);
  2501. return {
  2502. componentType: this.mainType,
  2503. componentSubType: this.subType,
  2504. seriesType: this.mainType === 'series' ? this.subType : null,
  2505. seriesIndex: seriesIndex,
  2506. seriesName: seriesName,
  2507. name: name,
  2508. dataIndex: rawDataIndex,
  2509. data: itemOpt,
  2510. dataType: dataType,
  2511. value: rawValue,
  2512. color: data.getItemVisual(dataIndex, 'color'),
  2513. // Param name list for mapping `a`, `b`, `c`, `d`, `e`
  2514. $vars: ['seriesName', 'name', 'value']
  2515. };
  2516. },
  2517. /**
  2518. * Format label
  2519. * @param {number} dataIndex
  2520. * @param {string} [status='normal'] 'normal' or 'emphasis'
  2521. * @param {string} [dataType]
  2522. * @param {number} [dimIndex]
  2523. * @return {string}
  2524. */
  2525. getFormattedLabel: function (dataIndex, status, dataType, dimIndex) {
  2526. status = status || 'normal';
  2527. var data = this.getData(dataType);
  2528. var itemModel = data.getItemModel(dataIndex);
  2529. var params = this.getDataParams(dataIndex, dataType);
  2530. if (dimIndex != null && zrUtil.isArray(params.value)) {
  2531. params.value = params.value[dimIndex];
  2532. }
  2533. var formatter = itemModel.get(['label', status, 'formatter']);
  2534. if (typeof formatter === 'function') {
  2535. params.status = status;
  2536. return formatter(params);
  2537. }
  2538. else if (typeof formatter === 'string') {
  2539. return formatUtil.formatTpl(formatter, params);
  2540. }
  2541. },
  2542. /**
  2543. * Get raw value in option
  2544. * @param {number} idx
  2545. * @param {string} [dataType]
  2546. * @return {Object}
  2547. */
  2548. getRawValue: function (idx, dataType) {
  2549. var data = this.getData(dataType);
  2550. var dataItem = data.getRawDataItem(idx);
  2551. if (dataItem != null) {
  2552. return (zrUtil.isObject(dataItem) && !zrUtil.isArray(dataItem))
  2553. ? dataItem.value : dataItem;
  2554. }
  2555. },
  2556. /**
  2557. * Should be implemented.
  2558. * @param {number} dataIndex
  2559. * @param {boolean} [multipleSeries=false]
  2560. * @param {number} [dataType]
  2561. * @return {string} tooltip string
  2562. */
  2563. formatTooltip: zrUtil.noop
  2564. };
  2565. /**
  2566. * Mapping to exists for merge.
  2567. *
  2568. * @public
  2569. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  2570. * @param {Object|Array.<Object>} newCptOptions
  2571. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  2572. * which order is the same as exists.
  2573. */
  2574. modelUtil.mappingToExists = function (exists, newCptOptions) {
  2575. // Mapping by the order by original option (but not order of
  2576. // new option) in merge mode. Because we should ensure
  2577. // some specified index (like xAxisIndex) is consistent with
  2578. // original option, which is easy to understand, espatially in
  2579. // media query. And in most case, merge option is used to
  2580. // update partial option but not be expected to change order.
  2581. newCptOptions = (newCptOptions || []).slice();
  2582. var result = zrUtil.map(exists || [], function (obj, index) {
  2583. return {exist: obj};
  2584. });
  2585. // Mapping by id or name if specified.
  2586. zrUtil.each(newCptOptions, function (cptOption, index) {
  2587. if (!zrUtil.isObject(cptOption)) {
  2588. return;
  2589. }
  2590. for (var i = 0; i < result.length; i++) {
  2591. var exist = result[i].exist;
  2592. if (!result[i].option // Consider name: two map to one.
  2593. && (
  2594. // id has highest priority.
  2595. (cptOption.id != null && exist.id === cptOption.id + '')
  2596. || (cptOption.name != null
  2597. && !modelUtil.isIdInner(cptOption)
  2598. && !modelUtil.isIdInner(exist)
  2599. && exist.name === cptOption.name + ''
  2600. )
  2601. )
  2602. ) {
  2603. result[i].option = cptOption;
  2604. newCptOptions[index] = null;
  2605. break;
  2606. }
  2607. }
  2608. });
  2609. // Otherwise mapping by index.
  2610. zrUtil.each(newCptOptions, function (cptOption, index) {
  2611. if (!zrUtil.isObject(cptOption)) {
  2612. return;
  2613. }
  2614. var i = 0;
  2615. for (; i < result.length; i++) {
  2616. var exist = result[i].exist;
  2617. if (!result[i].option
  2618. && !modelUtil.isIdInner(exist)
  2619. // Caution:
  2620. // Do not overwrite id. But name can be overwritten,
  2621. // because axis use name as 'show label text'.
  2622. // 'exist' always has id and name and we dont
  2623. // need to check it.
  2624. && cptOption.id == null
  2625. ) {
  2626. result[i].option = cptOption;
  2627. break;
  2628. }
  2629. }
  2630. if (i >= result.length) {
  2631. result.push({option: cptOption});
  2632. }
  2633. });
  2634. return result;
  2635. };
  2636. /**
  2637. * @public
  2638. * @param {Object} cptOption
  2639. * @return {boolean}
  2640. */
  2641. modelUtil.isIdInner = function (cptOption) {
  2642. return zrUtil.isObject(cptOption)
  2643. && cptOption.id
  2644. && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  2645. };
  2646. module.exports = modelUtil;
  2647. /***/ },
  2648. /* 6 */
  2649. /***/ function(module, exports, __webpack_require__) {
  2650. var zrUtil = __webpack_require__(3);
  2651. var numberUtil = __webpack_require__(7);
  2652. /**
  2653. * 每三位默认加,格式化
  2654. * @type {string|number} x
  2655. */
  2656. function addCommas(x) {
  2657. if (isNaN(x)) {
  2658. return '-';
  2659. }
  2660. x = (x + '').split('.');
  2661. return x[0].replace(/(\d{1,3})(?=(?:\d{3})+(?!\d))/g,'$1,')
  2662. + (x.length > 1 ? ('.' + x[1]) : '');
  2663. }
  2664. /**
  2665. * @param {string} str
  2666. * @return {string} str
  2667. */
  2668. function toCamelCase(str) {
  2669. return str.toLowerCase().replace(/-(.)/g, function(match, group1) {
  2670. return group1.toUpperCase();
  2671. });
  2672. }
  2673. /**
  2674. * Normalize css liked array configuration
  2675. * e.g.
  2676. * 3 => [3, 3, 3, 3]
  2677. * [4, 2] => [4, 2, 4, 2]
  2678. * [4, 3, 2] => [4, 3, 2, 3]
  2679. * @param {number|Array.<number>} val
  2680. */
  2681. function normalizeCssArray(val) {
  2682. var len = val.length;
  2683. if (typeof (val) === 'number') {
  2684. return [val, val, val, val];
  2685. }
  2686. else if (len === 2) {
  2687. // vertical | horizontal
  2688. return [val[0], val[1], val[0], val[1]];
  2689. }
  2690. else if (len === 3) {
  2691. // top | horizontal | bottom
  2692. return [val[0], val[1], val[2], val[1]];
  2693. }
  2694. return val;
  2695. }
  2696. function encodeHTML(source) {
  2697. return String(source)
  2698. .replace(/&/g, '&amp;')
  2699. .replace(/</g, '&lt;')
  2700. .replace(/>/g, '&gt;')
  2701. .replace(/"/g, '&quot;')
  2702. .replace(/'/g, '&#39;');
  2703. }
  2704. var TPL_VAR_ALIAS = ['a', 'b', 'c', 'd', 'e', 'f', 'g'];
  2705. function wrapVar(varName, seriesIdx) {
  2706. return '{' + varName + (seriesIdx == null ? '' : seriesIdx) + '}';
  2707. }
  2708. /**
  2709. * Template formatter
  2710. * @param {string} tpl
  2711. * @param {Array.<Object>|Object} paramsList
  2712. * @return {string}
  2713. */
  2714. function formatTpl(tpl, paramsList) {
  2715. if (!zrUtil.isArray(paramsList)) {
  2716. paramsList = [paramsList];
  2717. }
  2718. var seriesLen = paramsList.length;
  2719. if (!seriesLen) {
  2720. return '';
  2721. }
  2722. var $vars = paramsList[0].$vars;
  2723. for (var i = 0; i < $vars.length; i++) {
  2724. var alias = TPL_VAR_ALIAS[i];
  2725. tpl = tpl.replace(wrapVar(alias), wrapVar(alias, 0));
  2726. }
  2727. for (var seriesIdx = 0; seriesIdx < seriesLen; seriesIdx++) {
  2728. for (var k = 0; k < $vars.length; k++) {
  2729. tpl = tpl.replace(
  2730. wrapVar(TPL_VAR_ALIAS[k], seriesIdx),
  2731. paramsList[seriesIdx][$vars[k]]
  2732. );
  2733. }
  2734. }
  2735. return tpl;
  2736. }
  2737. /**
  2738. * ISO Date format
  2739. * @param {string} tpl
  2740. * @param {number} value
  2741. * @inner
  2742. */
  2743. function formatTime(tpl, value) {
  2744. if (tpl === 'week'
  2745. || tpl === 'month'
  2746. || tpl === 'quarter'
  2747. || tpl === 'half-year'
  2748. || tpl === 'year'
  2749. ) {
  2750. tpl = 'MM-dd\nyyyy';
  2751. }
  2752. var date = numberUtil.parseDate(value);
  2753. var y = date.getFullYear();
  2754. var M = date.getMonth() + 1;
  2755. var d = date.getDate();
  2756. var h = date.getHours();
  2757. var m = date.getMinutes();
  2758. var s = date.getSeconds();
  2759. tpl = tpl.replace('MM', s2d(M))
  2760. .toLowerCase()
  2761. .replace('yyyy', y)
  2762. .replace('yy', y % 100)
  2763. .replace('dd', s2d(d))
  2764. .replace('d', d)
  2765. .replace('hh', s2d(h))
  2766. .replace('h', h)
  2767. .replace('mm', s2d(m))
  2768. .replace('m', m)
  2769. .replace('ss', s2d(s))
  2770. .replace('s', s);
  2771. return tpl;
  2772. }
  2773. /**
  2774. * @param {string} str
  2775. * @return {string}
  2776. * @inner
  2777. */
  2778. function s2d(str) {
  2779. return str < 10 ? ('0' + str) : str;
  2780. }
  2781. module.exports = {
  2782. normalizeCssArray: normalizeCssArray,
  2783. addCommas: addCommas,
  2784. toCamelCase: toCamelCase,
  2785. encodeHTML: encodeHTML,
  2786. formatTpl: formatTpl,
  2787. formatTime: formatTime
  2788. };
  2789. /***/ },
  2790. /* 7 */
  2791. /***/ function(module, exports) {
  2792. /**
  2793. * 数值处理模块
  2794. * @module echarts/util/number
  2795. */
  2796. var number = {};
  2797. var RADIAN_EPSILON = 1e-4;
  2798. function _trim(str) {
  2799. return str.replace(/^\s+/, '').replace(/\s+$/, '');
  2800. }
  2801. /**
  2802. * Linear mapping a value from domain to range
  2803. * @memberOf module:echarts/util/number
  2804. * @param {(number|Array.<number>)} val
  2805. * @param {Array.<number>} domain Domain extent domain[0] can be bigger than domain[1]
  2806. * @param {Array.<number>} range Range extent range[0] can be bigger than range[1]
  2807. * @param {boolean} clamp
  2808. * @return {(number|Array.<number>}
  2809. */
  2810. number.linearMap = function (val, domain, range, clamp) {
  2811. var subDomain = domain[1] - domain[0];
  2812. var subRange = range[1] - range[0];
  2813. if (subDomain === 0) {
  2814. return subRange === 0
  2815. ? range[0]
  2816. : (range[0] + range[1]) / 2;
  2817. }
  2818. // Avoid accuracy problem in edge, such as
  2819. // 146.39 - 62.83 === 83.55999999999999.
  2820. // See echarts/test/ut/spec/util/number.js#linearMap#accuracyError
  2821. // It is a little verbose for efficiency considering this method
  2822. // is a hotspot.
  2823. if (clamp) {
  2824. if (subDomain > 0) {
  2825. if (val <= domain[0]) {
  2826. return range[0];
  2827. }
  2828. else if (val >= domain[1]) {
  2829. return range[1];
  2830. }
  2831. }
  2832. else {
  2833. if (val >= domain[0]) {
  2834. return range[0];
  2835. }
  2836. else if (val <= domain[1]) {
  2837. return range[1];
  2838. }
  2839. }
  2840. }
  2841. else {
  2842. if (val === domain[0]) {
  2843. return range[0];
  2844. }
  2845. if (val === domain[1]) {
  2846. return range[1];
  2847. }
  2848. }
  2849. return (val - domain[0]) / subDomain * subRange + range[0];
  2850. };
  2851. /**
  2852. * Convert a percent string to absolute number.
  2853. * Returns NaN if percent is not a valid string or number
  2854. * @memberOf module:echarts/util/number
  2855. * @param {string|number} percent
  2856. * @param {number} all
  2857. * @return {number}
  2858. */
  2859. number.parsePercent = function(percent, all) {
  2860. switch (percent) {
  2861. case 'center':
  2862. case 'middle':
  2863. percent = '50%';
  2864. break;
  2865. case 'left':
  2866. case 'top':
  2867. percent = '0%';
  2868. break;
  2869. case 'right':
  2870. case 'bottom':
  2871. percent = '100%';
  2872. break;
  2873. }
  2874. if (typeof percent === 'string') {
  2875. if (_trim(percent).match(/%$/)) {
  2876. return parseFloat(percent) / 100 * all;
  2877. }
  2878. return parseFloat(percent);
  2879. }
  2880. return percent == null ? NaN : +percent;
  2881. };
  2882. /**
  2883. * Fix rounding error of float numbers
  2884. * @param {number} x
  2885. * @return {number}
  2886. */
  2887. number.round = function (x) {
  2888. // PENDING
  2889. return +(+x).toFixed(10);
  2890. };
  2891. number.asc = function (arr) {
  2892. arr.sort(function (a, b) {
  2893. return a - b;
  2894. });
  2895. return arr;
  2896. };
  2897. /**
  2898. * Get precision
  2899. * @param {number} val
  2900. */
  2901. number.getPrecision = function (val) {
  2902. if (isNaN(val)) {
  2903. return 0;
  2904. }
  2905. // It is much faster than methods converting number to string as follows
  2906. // var tmp = val.toString();
  2907. // return tmp.length - 1 - tmp.indexOf('.');
  2908. // especially when precision is low
  2909. var e = 1;
  2910. var count = 0;
  2911. while (Math.round(val * e) / e !== val) {
  2912. e *= 10;
  2913. count++;
  2914. }
  2915. return count;
  2916. };
  2917. /**
  2918. * @param {Array.<number>} dataExtent
  2919. * @param {Array.<number>} pixelExtent
  2920. * @return {number} precision
  2921. */
  2922. number.getPixelPrecision = function (dataExtent, pixelExtent) {
  2923. var log = Math.log;
  2924. var LN10 = Math.LN10;
  2925. var dataQuantity = Math.floor(log(dataExtent[1] - dataExtent[0]) / LN10);
  2926. var sizeQuantity = Math.round(log(Math.abs(pixelExtent[1] - pixelExtent[0])) / LN10);
  2927. return Math.max(
  2928. -dataQuantity + sizeQuantity,
  2929. 0
  2930. );
  2931. };
  2932. // Number.MAX_SAFE_INTEGER, ie do not support.
  2933. number.MAX_SAFE_INTEGER = 9007199254740991;
  2934. /**
  2935. * To 0 - 2 * PI, considering negative radian.
  2936. * @param {number} radian
  2937. * @return {number}
  2938. */
  2939. number.remRadian = function (radian) {
  2940. var pi2 = Math.PI * 2;
  2941. return (radian % pi2 + pi2) % pi2;
  2942. };
  2943. /**
  2944. * @param {type} radian
  2945. * @return {boolean}
  2946. */
  2947. number.isRadianAroundZero = function (val) {
  2948. return val > -RADIAN_EPSILON && val < RADIAN_EPSILON;
  2949. };
  2950. /**
  2951. * @param {string|Date|number} value
  2952. * @return {number} timestamp
  2953. */
  2954. number.parseDate = function (value) {
  2955. return value instanceof Date
  2956. ? value
  2957. : new Date(
  2958. typeof value === 'string'
  2959. ? value.replace(/-/g, '/')
  2960. : Math.round(value)
  2961. );
  2962. };
  2963. /**
  2964. * Quantity of a number. e.g. 0.1, 1, 10, 100
  2965. * @param {number} val
  2966. * @return {number}
  2967. */
  2968. number.quantity = function (val) {
  2969. return Math.pow(10, Math.floor(Math.log(val) / Math.LN10));
  2970. };
  2971. // "Nice Numbers for Graph Labels" of Graphic Gems
  2972. /**
  2973. * find a “nice” number approximately equal to x. Round the number if round = true, take ceiling if round = false
  2974. * The primary observation is that the “nicest” numbers in decimal are 1, 2, and 5, and all power-of-ten multiples of these numbers.
  2975. * @param {number} val
  2976. * @param {boolean} round
  2977. * @return {number}
  2978. */
  2979. number.nice = function (val, round) {
  2980. var exp10 = number.quantity(val);
  2981. var f = val / exp10; // between 1 and 10
  2982. var nf;
  2983. if (round) {
  2984. if (f < 1.5) { nf = 1; }
  2985. else if (f < 2.5) { nf = 2; }
  2986. else if (f < 4) { nf = 3; }
  2987. else if (f < 7) { nf = 5; }
  2988. else { nf = 10; }
  2989. }
  2990. else {
  2991. if (f < 1) { nf = 1; }
  2992. else if (f < 2) { nf = 2; }
  2993. else if (f < 3) { nf = 3; }
  2994. else if (f < 5) { nf = 5; }
  2995. else { nf = 10; }
  2996. }
  2997. return nf * exp10;
  2998. };
  2999. module.exports = number;
  3000. /***/ },
  3001. /* 8 */
  3002. /***/ function(module, exports, __webpack_require__) {
  3003. /**
  3004. * @module echarts/model/Model
  3005. */
  3006. var zrUtil = __webpack_require__(3);
  3007. var clazzUtil = __webpack_require__(9);
  3008. /**
  3009. * @alias module:echarts/model/Model
  3010. * @constructor
  3011. * @param {Object} option
  3012. * @param {module:echarts/model/Model} [parentModel]
  3013. * @param {module:echarts/model/Global} [ecModel]
  3014. * @param {Object} extraOpt
  3015. */
  3016. function Model(option, parentModel, ecModel, extraOpt) {
  3017. /**
  3018. * @type {module:echarts/model/Model}
  3019. * @readOnly
  3020. */
  3021. this.parentModel = parentModel;
  3022. /**
  3023. * @type {module:echarts/model/Global}
  3024. * @readOnly
  3025. */
  3026. this.ecModel = ecModel;
  3027. /**
  3028. * @type {Object}
  3029. * @protected
  3030. */
  3031. this.option = option;
  3032. // Simple optimization
  3033. if (this.init) {
  3034. if (arguments.length <= 4) {
  3035. this.init(option, parentModel, ecModel, extraOpt);
  3036. }
  3037. else {
  3038. this.init.apply(this, arguments);
  3039. }
  3040. }
  3041. }
  3042. Model.prototype = {
  3043. constructor: Model,
  3044. /**
  3045. * Model 的初始化函数
  3046. * @param {Object} option
  3047. */
  3048. init: null,
  3049. /**
  3050. * 从新的 Option merge
  3051. */
  3052. mergeOption: function (option) {
  3053. zrUtil.merge(this.option, option, true);
  3054. },
  3055. /**
  3056. * @param {string} path
  3057. * @param {boolean} [ignoreParent=false]
  3058. * @return {*}
  3059. */
  3060. get: function (path, ignoreParent) {
  3061. if (!path) {
  3062. return this.option;
  3063. }
  3064. if (typeof path === 'string') {
  3065. path = path.split('.');
  3066. }
  3067. var obj = this.option;
  3068. var parentModel = this.parentModel;
  3069. for (var i = 0; i < path.length; i++) {
  3070. // Ignore empty
  3071. if (!path[i]) {
  3072. continue;
  3073. }
  3074. // obj could be number/string/... (like 0)
  3075. obj = (obj && typeof obj === 'object') ? obj[path[i]] : null;
  3076. if (obj == null) {
  3077. break;
  3078. }
  3079. }
  3080. if (obj == null && parentModel && !ignoreParent) {
  3081. obj = parentModel.get(path);
  3082. }
  3083. return obj;
  3084. },
  3085. /**
  3086. * @param {string} key
  3087. * @param {boolean} [ignoreParent=false]
  3088. * @return {*}
  3089. */
  3090. getShallow: function (key, ignoreParent) {
  3091. var option = this.option;
  3092. var val = option && option[key];
  3093. var parentModel = this.parentModel;
  3094. if (val == null && parentModel && !ignoreParent) {
  3095. val = parentModel.getShallow(key);
  3096. }
  3097. return val;
  3098. },
  3099. /**
  3100. * @param {string} path
  3101. * @param {module:echarts/model/Model} [parentModel]
  3102. * @return {module:echarts/model/Model}
  3103. */
  3104. getModel: function (path, parentModel) {
  3105. var obj = this.get(path, true);
  3106. var thisParentModel = this.parentModel;
  3107. var model = new Model(
  3108. obj, parentModel || (thisParentModel && thisParentModel.getModel(path)),
  3109. this.ecModel
  3110. );
  3111. return model;
  3112. },
  3113. /**
  3114. * If model has option
  3115. */
  3116. isEmpty: function () {
  3117. return this.option == null;
  3118. },
  3119. restoreData: function () {},
  3120. // Pending
  3121. clone: function () {
  3122. var Ctor = this.constructor;
  3123. return new Ctor(zrUtil.clone(this.option));
  3124. },
  3125. setReadOnly: function (properties) {
  3126. clazzUtil.setReadOnly(this, properties);
  3127. }
  3128. };
  3129. // Enable Model.extend.
  3130. clazzUtil.enableClassExtend(Model);
  3131. var mixin = zrUtil.mixin;
  3132. mixin(Model, __webpack_require__(10));
  3133. mixin(Model, __webpack_require__(12));
  3134. mixin(Model, __webpack_require__(13));
  3135. mixin(Model, __webpack_require__(18));
  3136. module.exports = Model;
  3137. /***/ },
  3138. /* 9 */
  3139. /***/ function(module, exports, __webpack_require__) {
  3140. var zrUtil = __webpack_require__(3);
  3141. var clazz = {};
  3142. var TYPE_DELIMITER = '.';
  3143. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  3144. /**
  3145. * @public
  3146. */
  3147. var parseClassType = clazz.parseClassType = function (componentType) {
  3148. var ret = {main: '', sub: ''};
  3149. if (componentType) {
  3150. componentType = componentType.split(TYPE_DELIMITER);
  3151. ret.main = componentType[0] || '';
  3152. ret.sub = componentType[1] || '';
  3153. }
  3154. return ret;
  3155. };
  3156. /**
  3157. * @public
  3158. */
  3159. clazz.enableClassExtend = function (RootClass, preConstruct) {
  3160. RootClass.extend = function (proto) {
  3161. var ExtendedClass = function () {
  3162. preConstruct && preConstruct.apply(this, arguments);
  3163. RootClass.apply(this, arguments);
  3164. };
  3165. zrUtil.extend(ExtendedClass.prototype, proto);
  3166. ExtendedClass.extend = this.extend;
  3167. ExtendedClass.superCall = superCall;
  3168. ExtendedClass.superApply = superApply;
  3169. zrUtil.inherits(ExtendedClass, this);
  3170. ExtendedClass.superClass = this;
  3171. return ExtendedClass;
  3172. };
  3173. };
  3174. // superCall should have class info, which can not be fetch from 'this'.
  3175. // Consider this case:
  3176. // class A has method f,
  3177. // class B inherits class A, overrides method f, f call superApply('f'),
  3178. // class C inherits class B, do not overrides method f,
  3179. // then when method of class C is called, dead loop occured.
  3180. function superCall(context, methodName) {
  3181. var args = zrUtil.slice(arguments, 2);
  3182. return this.superClass.prototype[methodName].apply(context, args);
  3183. }
  3184. function superApply(context, methodName, args) {
  3185. return this.superClass.prototype[methodName].apply(context, args);
  3186. }
  3187. /**
  3188. * @param {Object} entity
  3189. * @param {Object} options
  3190. * @param {boolean} [options.registerWhenExtend]
  3191. * @public
  3192. */
  3193. clazz.enableClassManagement = function (entity, options) {
  3194. options = options || {};
  3195. /**
  3196. * Component model classes
  3197. * key: componentType,
  3198. * value:
  3199. * componentClass, when componentType is 'xxx'
  3200. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  3201. * @type {Object}
  3202. */
  3203. var storage = {};
  3204. entity.registerClass = function (Clazz, componentType) {
  3205. if (componentType) {
  3206. componentType = parseClassType(componentType);
  3207. if (!componentType.sub) {
  3208. if (storage[componentType.main]) {
  3209. throw new Error(componentType.main + 'exists.');
  3210. }
  3211. storage[componentType.main] = Clazz;
  3212. }
  3213. else if (componentType.sub !== IS_CONTAINER) {
  3214. var container = makeContainer(componentType);
  3215. container[componentType.sub] = Clazz;
  3216. }
  3217. }
  3218. return Clazz;
  3219. };
  3220. entity.getClass = function (componentTypeMain, subType, throwWhenNotFound) {
  3221. var Clazz = storage[componentTypeMain];
  3222. if (Clazz && Clazz[IS_CONTAINER]) {
  3223. Clazz = subType ? Clazz[subType] : null;
  3224. }
  3225. if (throwWhenNotFound && !Clazz) {
  3226. throw new Error(
  3227. 'Component ' + componentTypeMain + '.' + (subType || '') + ' not exists. Load it first.'
  3228. );
  3229. }
  3230. return Clazz;
  3231. };
  3232. entity.getClassesByMainType = function (componentType) {
  3233. componentType = parseClassType(componentType);
  3234. var result = [];
  3235. var obj = storage[componentType.main];
  3236. if (obj && obj[IS_CONTAINER]) {
  3237. zrUtil.each(obj, function (o, type) {
  3238. type !== IS_CONTAINER && result.push(o);
  3239. });
  3240. }
  3241. else {
  3242. result.push(obj);
  3243. }
  3244. return result;
  3245. };
  3246. entity.hasClass = function (componentType) {
  3247. // Just consider componentType.main.
  3248. componentType = parseClassType(componentType);
  3249. return !!storage[componentType.main];
  3250. };
  3251. /**
  3252. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  3253. */
  3254. entity.getAllClassMainTypes = function () {
  3255. var types = [];
  3256. zrUtil.each(storage, function (obj, type) {
  3257. types.push(type);
  3258. });
  3259. return types;
  3260. };
  3261. /**
  3262. * If a main type is container and has sub types
  3263. * @param {string} mainType
  3264. * @return {boolean}
  3265. */
  3266. entity.hasSubTypes = function (componentType) {
  3267. componentType = parseClassType(componentType);
  3268. var obj = storage[componentType.main];
  3269. return obj && obj[IS_CONTAINER];
  3270. };
  3271. entity.parseClassType = parseClassType;
  3272. function makeContainer(componentType) {
  3273. var container = storage[componentType.main];
  3274. if (!container || !container[IS_CONTAINER]) {
  3275. container = storage[componentType.main] = {};
  3276. container[IS_CONTAINER] = true;
  3277. }
  3278. return container;
  3279. }
  3280. if (options.registerWhenExtend) {
  3281. var originalExtend = entity.extend;
  3282. if (originalExtend) {
  3283. entity.extend = function (proto) {
  3284. var ExtendedClass = originalExtend.call(this, proto);
  3285. return entity.registerClass(ExtendedClass, proto.type);
  3286. };
  3287. }
  3288. }
  3289. return entity;
  3290. };
  3291. /**
  3292. * @param {string|Array.<string>} properties
  3293. */
  3294. clazz.setReadOnly = function (obj, properties) {
  3295. // FIXME It seems broken in IE8 simulation of IE11
  3296. // if (!zrUtil.isArray(properties)) {
  3297. // properties = properties != null ? [properties] : [];
  3298. // }
  3299. // zrUtil.each(properties, function (prop) {
  3300. // var value = obj[prop];
  3301. // Object.defineProperty
  3302. // && Object.defineProperty(obj, prop, {
  3303. // value: value, writable: false
  3304. // });
  3305. // zrUtil.isArray(obj[prop])
  3306. // && Object.freeze
  3307. // && Object.freeze(obj[prop]);
  3308. // });
  3309. };
  3310. module.exports = clazz;
  3311. /***/ },
  3312. /* 10 */
  3313. /***/ function(module, exports, __webpack_require__) {
  3314. var getLineStyle = __webpack_require__(11)(
  3315. [
  3316. ['lineWidth', 'width'],
  3317. ['stroke', 'color'],
  3318. ['opacity'],
  3319. ['shadowBlur'],
  3320. ['shadowOffsetX'],
  3321. ['shadowOffsetY'],
  3322. ['shadowColor']
  3323. ]
  3324. );
  3325. module.exports = {
  3326. getLineStyle: function (excludes) {
  3327. var style = getLineStyle.call(this, excludes);
  3328. var lineDash = this.getLineDash();
  3329. lineDash && (style.lineDash = lineDash);
  3330. return style;
  3331. },
  3332. getLineDash: function () {
  3333. var lineType = this.get('type');
  3334. return (lineType === 'solid' || lineType == null) ? null
  3335. : (lineType === 'dashed' ? [5, 5] : [1, 1]);
  3336. }
  3337. };
  3338. /***/ },
  3339. /* 11 */
  3340. /***/ function(module, exports, __webpack_require__) {
  3341. // TODO Parse shadow style
  3342. // TODO Only shallow path support
  3343. var zrUtil = __webpack_require__(3);
  3344. module.exports = function (properties) {
  3345. // Normalize
  3346. for (var i = 0; i < properties.length; i++) {
  3347. if (!properties[i][1]) {
  3348. properties[i][1] = properties[i][0];
  3349. }
  3350. }
  3351. return function (excludes) {
  3352. var style = {};
  3353. for (var i = 0; i < properties.length; i++) {
  3354. var propName = properties[i][1];
  3355. if (excludes && zrUtil.indexOf(excludes, propName) >= 0) {
  3356. continue;
  3357. }
  3358. var val = this.getShallow(propName);
  3359. if (val != null) {
  3360. style[properties[i][0]] = val;
  3361. }
  3362. }
  3363. return style;
  3364. };
  3365. };
  3366. /***/ },
  3367. /* 12 */
  3368. /***/ function(module, exports, __webpack_require__) {
  3369. module.exports = {
  3370. getAreaStyle: __webpack_require__(11)(
  3371. [
  3372. ['fill', 'color'],
  3373. ['shadowBlur'],
  3374. ['shadowOffsetX'],
  3375. ['shadowOffsetY'],
  3376. ['opacity'],
  3377. ['shadowColor']
  3378. ]
  3379. )
  3380. };
  3381. /***/ },
  3382. /* 13 */
  3383. /***/ function(module, exports, __webpack_require__) {
  3384. var textContain = __webpack_require__(14);
  3385. function getShallow(model, path) {
  3386. return model && model.getShallow(path);
  3387. }
  3388. module.exports = {
  3389. /**
  3390. * Get color property or get color from option.textStyle.color
  3391. * @return {string}
  3392. */
  3393. getTextColor: function () {
  3394. var ecModel = this.ecModel;
  3395. return this.getShallow('color')
  3396. || (ecModel && ecModel.get('textStyle.color'));
  3397. },
  3398. /**
  3399. * Create font string from fontStyle, fontWeight, fontSize, fontFamily
  3400. * @return {string}
  3401. */
  3402. getFont: function () {
  3403. var ecModel = this.ecModel;
  3404. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  3405. return [
  3406. // FIXME in node-canvas fontWeight is before fontStyle
  3407. this.getShallow('fontStyle') || getShallow(gTextStyleModel, 'fontStyle'),
  3408. this.getShallow('fontWeight') || getShallow(gTextStyleModel, 'fontWeight'),
  3409. (this.getShallow('fontSize') || getShallow(gTextStyleModel, 'fontSize') || 12) + 'px',
  3410. this.getShallow('fontFamily') || getShallow(gTextStyleModel, 'fontFamily') || 'sans-serif'
  3411. ].join(' ');
  3412. },
  3413. getTextRect: function (text) {
  3414. var textStyle = this.get('textStyle') || {};
  3415. return textContain.getBoundingRect(
  3416. text,
  3417. this.getFont(),
  3418. textStyle.align,
  3419. textStyle.baseline
  3420. );
  3421. },
  3422. ellipsis: function (text, containerWidth, options) {
  3423. return textContain.ellipsis(
  3424. text, this.getFont(), containerWidth, options
  3425. );
  3426. }
  3427. };
  3428. /***/ },
  3429. /* 14 */
  3430. /***/ function(module, exports, __webpack_require__) {
  3431. var textWidthCache = {};
  3432. var textWidthCacheCounter = 0;
  3433. var TEXT_CACHE_MAX = 5000;
  3434. var util = __webpack_require__(3);
  3435. var BoundingRect = __webpack_require__(15);
  3436. function getTextWidth(text, textFont) {
  3437. var key = text + ':' + textFont;
  3438. if (textWidthCache[key]) {
  3439. return textWidthCache[key];
  3440. }
  3441. var textLines = (text + '').split('\n');
  3442. var width = 0;
  3443. for (var i = 0, l = textLines.length; i < l; i++) {
  3444. // measureText 可以被覆盖以兼容不支持 Canvas 的环境
  3445. width = Math.max(textContain.measureText(textLines[i], textFont).width, width);
  3446. }
  3447. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  3448. textWidthCacheCounter = 0;
  3449. textWidthCache = {};
  3450. }
  3451. textWidthCacheCounter++;
  3452. textWidthCache[key] = width;
  3453. return width;
  3454. }
  3455. function getTextRect(text, textFont, textAlign, textBaseline) {
  3456. var textLineLen = ((text || '') + '').split('\n').length;
  3457. var width = getTextWidth(text, textFont);
  3458. // FIXME 高度计算比较粗暴
  3459. var lineHeight = getTextWidth('国', textFont);
  3460. var height = textLineLen * lineHeight;
  3461. var rect = new BoundingRect(0, 0, width, height);
  3462. // Text has a special line height property
  3463. rect.lineHeight = lineHeight;
  3464. switch (textBaseline) {
  3465. case 'bottom':
  3466. case 'alphabetic':
  3467. rect.y -= lineHeight;
  3468. break;
  3469. case 'middle':
  3470. rect.y -= lineHeight / 2;
  3471. break;
  3472. // case 'hanging':
  3473. // case 'top':
  3474. }
  3475. // FIXME Right to left language
  3476. switch (textAlign) {
  3477. case 'end':
  3478. case 'right':
  3479. rect.x -= rect.width;
  3480. break;
  3481. case 'center':
  3482. rect.x -= rect.width / 2;
  3483. break;
  3484. // case 'start':
  3485. // case 'left':
  3486. }
  3487. return rect;
  3488. }
  3489. function adjustTextPositionOnRect(textPosition, rect, textRect, distance) {
  3490. var x = rect.x;
  3491. var y = rect.y;
  3492. var height = rect.height;
  3493. var width = rect.width;
  3494. var textHeight = textRect.height;
  3495. var halfHeight = height / 2 - textHeight / 2;
  3496. var textAlign = 'left';
  3497. switch (textPosition) {
  3498. case 'left':
  3499. x -= distance;
  3500. y += halfHeight;
  3501. textAlign = 'right';
  3502. break;
  3503. case 'right':
  3504. x += distance + width;
  3505. y += halfHeight;
  3506. textAlign = 'left';
  3507. break;
  3508. case 'top':
  3509. x += width / 2;
  3510. y -= distance + textHeight;
  3511. textAlign = 'center';
  3512. break;
  3513. case 'bottom':
  3514. x += width / 2;
  3515. y += height + distance;
  3516. textAlign = 'center';
  3517. break;
  3518. case 'inside':
  3519. x += width / 2;
  3520. y += halfHeight;
  3521. textAlign = 'center';
  3522. break;
  3523. case 'insideLeft':
  3524. x += distance;
  3525. y += halfHeight;
  3526. textAlign = 'left';
  3527. break;
  3528. case 'insideRight':
  3529. x += width - distance;
  3530. y += halfHeight;
  3531. textAlign = 'right';
  3532. break;
  3533. case 'insideTop':
  3534. x += width / 2;
  3535. y += distance;
  3536. textAlign = 'center';
  3537. break;
  3538. case 'insideBottom':
  3539. x += width / 2;
  3540. y += height - textHeight - distance;
  3541. textAlign = 'center';
  3542. break;
  3543. case 'insideTopLeft':
  3544. x += distance;
  3545. y += distance;
  3546. textAlign = 'left';
  3547. break;
  3548. case 'insideTopRight':
  3549. x += width - distance;
  3550. y += distance;
  3551. textAlign = 'right';
  3552. break;
  3553. case 'insideBottomLeft':
  3554. x += distance;
  3555. y += height - textHeight - distance;
  3556. break;
  3557. case 'insideBottomRight':
  3558. x += width - distance;
  3559. y += height - textHeight - distance;
  3560. textAlign = 'right';
  3561. break;
  3562. }
  3563. return {
  3564. x: x,
  3565. y: y,
  3566. textAlign: textAlign,
  3567. textBaseline: 'top'
  3568. };
  3569. }
  3570. /**
  3571. * Show ellipsis if overflow.
  3572. *
  3573. * @param {string} text
  3574. * @param {string} textFont
  3575. * @param {string} containerWidth
  3576. * @param {Object} [options]
  3577. * @param {number} [options.ellipsis='...']
  3578. * @param {number} [options.maxIterations=3]
  3579. * @param {number} [options.minCharacters=3]
  3580. * @return {string}
  3581. */
  3582. function textEllipsis(text, textFont, containerWidth, options) {
  3583. if (!containerWidth) {
  3584. return '';
  3585. }
  3586. options = util.defaults({
  3587. ellipsis: '...',
  3588. minCharacters: 3,
  3589. maxIterations: 3,
  3590. cnCharWidth: getTextWidth('国', textFont),
  3591. // FIXME
  3592. // 未考虑非等宽字体
  3593. ascCharWidth: getTextWidth('a', textFont)
  3594. }, options, true);
  3595. containerWidth -= getTextWidth(options.ellipsis);
  3596. var textLines = (text + '').split('\n');
  3597. for (var i = 0, len = textLines.length; i < len; i++) {
  3598. textLines[i] = textLineTruncate(
  3599. textLines[i], textFont, containerWidth, options
  3600. );
  3601. }
  3602. return textLines.join('\n');
  3603. }
  3604. function textLineTruncate(text, textFont, containerWidth, options) {
  3605. // FIXME
  3606. // 粗糙得写的,尚未考虑性能和各种语言、字体的效果。
  3607. for (var i = 0;; i++) {
  3608. var lineWidth = getTextWidth(text, textFont);
  3609. if (lineWidth < containerWidth || i >= options.maxIterations) {
  3610. text += options.ellipsis;
  3611. break;
  3612. }
  3613. var subLength = i === 0
  3614. ? estimateLength(text, containerWidth, options)
  3615. : Math.floor(text.length * containerWidth / lineWidth);
  3616. if (subLength < options.minCharacters) {
  3617. text = '';
  3618. break;
  3619. }
  3620. text = text.substr(0, subLength);
  3621. }
  3622. return text;
  3623. }
  3624. function estimateLength(text, containerWidth, options) {
  3625. var width = 0;
  3626. var i = 0;
  3627. for (var len = text.length; i < len && width < containerWidth; i++) {
  3628. var charCode = text.charCodeAt(i);
  3629. width += (0 <= charCode && charCode <= 127)
  3630. ? options.ascCharWidth : options.cnCharWidth;
  3631. }
  3632. return i;
  3633. }
  3634. var textContain = {
  3635. getWidth: getTextWidth,
  3636. getBoundingRect: getTextRect,
  3637. adjustTextPositionOnRect: adjustTextPositionOnRect,
  3638. ellipsis: textEllipsis,
  3639. measureText: function (text, textFont) {
  3640. var ctx = util.getContext();
  3641. ctx.font = textFont;
  3642. return ctx.measureText(text);
  3643. }
  3644. };
  3645. module.exports = textContain;
  3646. /***/ },
  3647. /* 15 */
  3648. /***/ function(module, exports, __webpack_require__) {
  3649. 'use strict';
  3650. /**
  3651. * @module echarts/core/BoundingRect
  3652. */
  3653. var vec2 = __webpack_require__(16);
  3654. var matrix = __webpack_require__(17);
  3655. var v2ApplyTransform = vec2.applyTransform;
  3656. var mathMin = Math.min;
  3657. var mathAbs = Math.abs;
  3658. var mathMax = Math.max;
  3659. /**
  3660. * @alias module:echarts/core/BoundingRect
  3661. */
  3662. function BoundingRect(x, y, width, height) {
  3663. /**
  3664. * @type {number}
  3665. */
  3666. this.x = x;
  3667. /**
  3668. * @type {number}
  3669. */
  3670. this.y = y;
  3671. /**
  3672. * @type {number}
  3673. */
  3674. this.width = width;
  3675. /**
  3676. * @type {number}
  3677. */
  3678. this.height = height;
  3679. }
  3680. BoundingRect.prototype = {
  3681. constructor: BoundingRect,
  3682. /**
  3683. * @param {module:echarts/core/BoundingRect} other
  3684. */
  3685. union: function (other) {
  3686. var x = mathMin(other.x, this.x);
  3687. var y = mathMin(other.y, this.y);
  3688. this.width = mathMax(
  3689. other.x + other.width,
  3690. this.x + this.width
  3691. ) - x;
  3692. this.height = mathMax(
  3693. other.y + other.height,
  3694. this.y + this.height
  3695. ) - y;
  3696. this.x = x;
  3697. this.y = y;
  3698. },
  3699. /**
  3700. * @param {Array.<number>} m
  3701. * @methods
  3702. */
  3703. applyTransform: (function () {
  3704. var min = [];
  3705. var max = [];
  3706. return function (m) {
  3707. // In case usage like this
  3708. // el.getBoundingRect().applyTransform(el.transform)
  3709. // And element has no transform
  3710. if (!m) {
  3711. return;
  3712. }
  3713. min[0] = this.x;
  3714. min[1] = this.y;
  3715. max[0] = this.x + this.width;
  3716. max[1] = this.y + this.height;
  3717. v2ApplyTransform(min, min, m);
  3718. v2ApplyTransform(max, max, m);
  3719. this.x = mathMin(min[0], max[0]);
  3720. this.y = mathMin(min[1], max[1]);
  3721. this.width = mathAbs(max[0] - min[0]);
  3722. this.height = mathAbs(max[1] - min[1]);
  3723. };
  3724. })(),
  3725. /**
  3726. * Calculate matrix of transforming from self to target rect
  3727. * @param {module:zrender/core/BoundingRect} b
  3728. * @return {Array.<number>}
  3729. */
  3730. calculateTransform: function (b) {
  3731. var a = this;
  3732. var sx = b.width / a.width;
  3733. var sy = b.height / a.height;
  3734. var m = matrix.create();
  3735. // 矩阵右乘
  3736. matrix.translate(m, m, [-a.x, -a.y]);
  3737. matrix.scale(m, m, [sx, sy]);
  3738. matrix.translate(m, m, [b.x, b.y]);
  3739. return m;
  3740. },
  3741. /**
  3742. * @param {(module:echarts/core/BoundingRect|Object)} b
  3743. * @return {boolean}
  3744. */
  3745. intersect: function (b) {
  3746. var a = this;
  3747. var ax0 = a.x;
  3748. var ax1 = a.x + a.width;
  3749. var ay0 = a.y;
  3750. var ay1 = a.y + a.height;
  3751. var bx0 = b.x;
  3752. var bx1 = b.x + b.width;
  3753. var by0 = b.y;
  3754. var by1 = b.y + b.height;
  3755. return ! (ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  3756. },
  3757. contain: function (x, y) {
  3758. var rect = this;
  3759. return x >= rect.x
  3760. && x <= (rect.x + rect.width)
  3761. && y >= rect.y
  3762. && y <= (rect.y + rect.height);
  3763. },
  3764. /**
  3765. * @return {module:echarts/core/BoundingRect}
  3766. */
  3767. clone: function () {
  3768. return new BoundingRect(this.x, this.y, this.width, this.height);
  3769. },
  3770. /**
  3771. * Copy from another rect
  3772. */
  3773. copy: function (other) {
  3774. this.x = other.x;
  3775. this.y = other.y;
  3776. this.width = other.width;
  3777. this.height = other.height;
  3778. }
  3779. };
  3780. module.exports = BoundingRect;
  3781. /***/ },
  3782. /* 16 */
  3783. /***/ function(module, exports) {
  3784. var ArrayCtor = typeof Float32Array === 'undefined'
  3785. ? Array
  3786. : Float32Array;
  3787. /**
  3788. * @typedef {Float32Array|Array.<number>} Vector2
  3789. */
  3790. /**
  3791. * 二维向量类
  3792. * @exports zrender/tool/vector
  3793. */
  3794. var vector = {
  3795. /**
  3796. * 创建一个向量
  3797. * @param {number} [x=0]
  3798. * @param {number} [y=0]
  3799. * @return {Vector2}
  3800. */
  3801. create: function (x, y) {
  3802. var out = new ArrayCtor(2);
  3803. out[0] = x || 0;
  3804. out[1] = y || 0;
  3805. return out;
  3806. },
  3807. /**
  3808. * 复制向量数据
  3809. * @param {Vector2} out
  3810. * @param {Vector2} v
  3811. * @return {Vector2}
  3812. */
  3813. copy: function (out, v) {
  3814. out[0] = v[0];
  3815. out[1] = v[1];
  3816. return out;
  3817. },
  3818. /**
  3819. * 克隆一个向量
  3820. * @param {Vector2} v
  3821. * @return {Vector2}
  3822. */
  3823. clone: function (v) {
  3824. var out = new ArrayCtor(2);
  3825. out[0] = v[0];
  3826. out[1] = v[1];
  3827. return out;
  3828. },
  3829. /**
  3830. * 设置向量的两个项
  3831. * @param {Vector2} out
  3832. * @param {number} a
  3833. * @param {number} b
  3834. * @return {Vector2} 结果
  3835. */
  3836. set: function (out, a, b) {
  3837. out[0] = a;
  3838. out[1] = b;
  3839. return out;
  3840. },
  3841. /**
  3842. * 向量相加
  3843. * @param {Vector2} out
  3844. * @param {Vector2} v1
  3845. * @param {Vector2} v2
  3846. */
  3847. add: function (out, v1, v2) {
  3848. out[0] = v1[0] + v2[0];
  3849. out[1] = v1[1] + v2[1];
  3850. return out;
  3851. },
  3852. /**
  3853. * 向量缩放后相加
  3854. * @param {Vector2} out
  3855. * @param {Vector2} v1
  3856. * @param {Vector2} v2
  3857. * @param {number} a
  3858. */
  3859. scaleAndAdd: function (out, v1, v2, a) {
  3860. out[0] = v1[0] + v2[0] * a;
  3861. out[1] = v1[1] + v2[1] * a;
  3862. return out;
  3863. },
  3864. /**
  3865. * 向量相减
  3866. * @param {Vector2} out
  3867. * @param {Vector2} v1
  3868. * @param {Vector2} v2
  3869. */
  3870. sub: function (out, v1, v2) {
  3871. out[0] = v1[0] - v2[0];
  3872. out[1] = v1[1] - v2[1];
  3873. return out;
  3874. },
  3875. /**
  3876. * 向量长度
  3877. * @param {Vector2} v
  3878. * @return {number}
  3879. */
  3880. len: function (v) {
  3881. return Math.sqrt(this.lenSquare(v));
  3882. },
  3883. /**
  3884. * 向量长度平方
  3885. * @param {Vector2} v
  3886. * @return {number}
  3887. */
  3888. lenSquare: function (v) {
  3889. return v[0] * v[0] + v[1] * v[1];
  3890. },
  3891. /**
  3892. * 向量乘法
  3893. * @param {Vector2} out
  3894. * @param {Vector2} v1
  3895. * @param {Vector2} v2
  3896. */
  3897. mul: function (out, v1, v2) {
  3898. out[0] = v1[0] * v2[0];
  3899. out[1] = v1[1] * v2[1];
  3900. return out;
  3901. },
  3902. /**
  3903. * 向量除法
  3904. * @param {Vector2} out
  3905. * @param {Vector2} v1
  3906. * @param {Vector2} v2
  3907. */
  3908. div: function (out, v1, v2) {
  3909. out[0] = v1[0] / v2[0];
  3910. out[1] = v1[1] / v2[1];
  3911. return out;
  3912. },
  3913. /**
  3914. * 向量点乘
  3915. * @param {Vector2} v1
  3916. * @param {Vector2} v2
  3917. * @return {number}
  3918. */
  3919. dot: function (v1, v2) {
  3920. return v1[0] * v2[0] + v1[1] * v2[1];
  3921. },
  3922. /**
  3923. * 向量缩放
  3924. * @param {Vector2} out
  3925. * @param {Vector2} v
  3926. * @param {number} s
  3927. */
  3928. scale: function (out, v, s) {
  3929. out[0] = v[0] * s;
  3930. out[1] = v[1] * s;
  3931. return out;
  3932. },
  3933. /**
  3934. * 向量归一化
  3935. * @param {Vector2} out
  3936. * @param {Vector2} v
  3937. */
  3938. normalize: function (out, v) {
  3939. var d = vector.len(v);
  3940. if (d === 0) {
  3941. out[0] = 0;
  3942. out[1] = 0;
  3943. }
  3944. else {
  3945. out[0] = v[0] / d;
  3946. out[1] = v[1] / d;
  3947. }
  3948. return out;
  3949. },
  3950. /**
  3951. * 计算向量间距离
  3952. * @param {Vector2} v1
  3953. * @param {Vector2} v2
  3954. * @return {number}
  3955. */
  3956. distance: function (v1, v2) {
  3957. return Math.sqrt(
  3958. (v1[0] - v2[0]) * (v1[0] - v2[0])
  3959. + (v1[1] - v2[1]) * (v1[1] - v2[1])
  3960. );
  3961. },
  3962. /**
  3963. * 向量距离平方
  3964. * @param {Vector2} v1
  3965. * @param {Vector2} v2
  3966. * @return {number}
  3967. */
  3968. distanceSquare: function (v1, v2) {
  3969. return (v1[0] - v2[0]) * (v1[0] - v2[0])
  3970. + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  3971. },
  3972. /**
  3973. * 求负向量
  3974. * @param {Vector2} out
  3975. * @param {Vector2} v
  3976. */
  3977. negate: function (out, v) {
  3978. out[0] = -v[0];
  3979. out[1] = -v[1];
  3980. return out;
  3981. },
  3982. /**
  3983. * 插值两个点
  3984. * @param {Vector2} out
  3985. * @param {Vector2} v1
  3986. * @param {Vector2} v2
  3987. * @param {number} t
  3988. */
  3989. lerp: function (out, v1, v2, t) {
  3990. out[0] = v1[0] + t * (v2[0] - v1[0]);
  3991. out[1] = v1[1] + t * (v2[1] - v1[1]);
  3992. return out;
  3993. },
  3994. /**
  3995. * 矩阵左乘向量
  3996. * @param {Vector2} out
  3997. * @param {Vector2} v
  3998. * @param {Vector2} m
  3999. */
  4000. applyTransform: function (out, v, m) {
  4001. var x = v[0];
  4002. var y = v[1];
  4003. out[0] = m[0] * x + m[2] * y + m[4];
  4004. out[1] = m[1] * x + m[3] * y + m[5];
  4005. return out;
  4006. },
  4007. /**
  4008. * 求两个向量最小值
  4009. * @param {Vector2} out
  4010. * @param {Vector2} v1
  4011. * @param {Vector2} v2
  4012. */
  4013. min: function (out, v1, v2) {
  4014. out[0] = Math.min(v1[0], v2[0]);
  4015. out[1] = Math.min(v1[1], v2[1]);
  4016. return out;
  4017. },
  4018. /**
  4019. * 求两个向量最大值
  4020. * @param {Vector2} out
  4021. * @param {Vector2} v1
  4022. * @param {Vector2} v2
  4023. */
  4024. max: function (out, v1, v2) {
  4025. out[0] = Math.max(v1[0], v2[0]);
  4026. out[1] = Math.max(v1[1], v2[1]);
  4027. return out;
  4028. }
  4029. };
  4030. vector.length = vector.len;
  4031. vector.lengthSquare = vector.lenSquare;
  4032. vector.dist = vector.distance;
  4033. vector.distSquare = vector.distanceSquare;
  4034. module.exports = vector;
  4035. /***/ },
  4036. /* 17 */
  4037. /***/ function(module, exports) {
  4038. var ArrayCtor = typeof Float32Array === 'undefined'
  4039. ? Array
  4040. : Float32Array;
  4041. /**
  4042. * 3x2矩阵操作类
  4043. * @exports zrender/tool/matrix
  4044. */
  4045. var matrix = {
  4046. /**
  4047. * 创建一个单位矩阵
  4048. * @return {Float32Array|Array.<number>}
  4049. */
  4050. create : function() {
  4051. var out = new ArrayCtor(6);
  4052. matrix.identity(out);
  4053. return out;
  4054. },
  4055. /**
  4056. * 设置矩阵为单位矩阵
  4057. * @param {Float32Array|Array.<number>} out
  4058. */
  4059. identity : function(out) {
  4060. out[0] = 1;
  4061. out[1] = 0;
  4062. out[2] = 0;
  4063. out[3] = 1;
  4064. out[4] = 0;
  4065. out[5] = 0;
  4066. return out;
  4067. },
  4068. /**
  4069. * 复制矩阵
  4070. * @param {Float32Array|Array.<number>} out
  4071. * @param {Float32Array|Array.<number>} m
  4072. */
  4073. copy: function(out, m) {
  4074. out[0] = m[0];
  4075. out[1] = m[1];
  4076. out[2] = m[2];
  4077. out[3] = m[3];
  4078. out[4] = m[4];
  4079. out[5] = m[5];
  4080. return out;
  4081. },
  4082. /**
  4083. * 矩阵相乘
  4084. * @param {Float32Array|Array.<number>} out
  4085. * @param {Float32Array|Array.<number>} m1
  4086. * @param {Float32Array|Array.<number>} m2
  4087. */
  4088. mul : function (out, m1, m2) {
  4089. // Consider matrix.mul(m, m2, m);
  4090. // where out is the same as m2.
  4091. // So use temp variable to escape error.
  4092. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  4093. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  4094. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  4095. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  4096. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  4097. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  4098. out[0] = out0;
  4099. out[1] = out1;
  4100. out[2] = out2;
  4101. out[3] = out3;
  4102. out[4] = out4;
  4103. out[5] = out5;
  4104. return out;
  4105. },
  4106. /**
  4107. * 平移变换
  4108. * @param {Float32Array|Array.<number>} out
  4109. * @param {Float32Array|Array.<number>} a
  4110. * @param {Float32Array|Array.<number>} v
  4111. */
  4112. translate : function(out, a, v) {
  4113. out[0] = a[0];
  4114. out[1] = a[1];
  4115. out[2] = a[2];
  4116. out[3] = a[3];
  4117. out[4] = a[4] + v[0];
  4118. out[5] = a[5] + v[1];
  4119. return out;
  4120. },
  4121. /**
  4122. * 旋转变换
  4123. * @param {Float32Array|Array.<number>} out
  4124. * @param {Float32Array|Array.<number>} a
  4125. * @param {number} rad
  4126. */
  4127. rotate : function(out, a, rad) {
  4128. var aa = a[0];
  4129. var ac = a[2];
  4130. var atx = a[4];
  4131. var ab = a[1];
  4132. var ad = a[3];
  4133. var aty = a[5];
  4134. var st = Math.sin(rad);
  4135. var ct = Math.cos(rad);
  4136. out[0] = aa * ct + ab * st;
  4137. out[1] = -aa * st + ab * ct;
  4138. out[2] = ac * ct + ad * st;
  4139. out[3] = -ac * st + ct * ad;
  4140. out[4] = ct * atx + st * aty;
  4141. out[5] = ct * aty - st * atx;
  4142. return out;
  4143. },
  4144. /**
  4145. * 缩放变换
  4146. * @param {Float32Array|Array.<number>} out
  4147. * @param {Float32Array|Array.<number>} a
  4148. * @param {Float32Array|Array.<number>} v
  4149. */
  4150. scale : function(out, a, v) {
  4151. var vx = v[0];
  4152. var vy = v[1];
  4153. out[0] = a[0] * vx;
  4154. out[1] = a[1] * vy;
  4155. out[2] = a[2] * vx;
  4156. out[3] = a[3] * vy;
  4157. out[4] = a[4] * vx;
  4158. out[5] = a[5] * vy;
  4159. return out;
  4160. },
  4161. /**
  4162. * 求逆矩阵
  4163. * @param {Float32Array|Array.<number>} out
  4164. * @param {Float32Array|Array.<number>} a
  4165. */
  4166. invert : function(out, a) {
  4167. var aa = a[0];
  4168. var ac = a[2];
  4169. var atx = a[4];
  4170. var ab = a[1];
  4171. var ad = a[3];
  4172. var aty = a[5];
  4173. var det = aa * ad - ab * ac;
  4174. if (!det) {
  4175. return null;
  4176. }
  4177. det = 1.0 / det;
  4178. out[0] = ad * det;
  4179. out[1] = -ab * det;
  4180. out[2] = -ac * det;
  4181. out[3] = aa * det;
  4182. out[4] = (ac * aty - ad * atx) * det;
  4183. out[5] = (ab * atx - aa * aty) * det;
  4184. return out;
  4185. }
  4186. };
  4187. module.exports = matrix;
  4188. /***/ },
  4189. /* 18 */
  4190. /***/ function(module, exports, __webpack_require__) {
  4191. module.exports = {
  4192. getItemStyle: __webpack_require__(11)(
  4193. [
  4194. ['fill', 'color'],
  4195. ['stroke', 'borderColor'],
  4196. ['lineWidth', 'borderWidth'],
  4197. ['opacity'],
  4198. ['shadowBlur'],
  4199. ['shadowOffsetX'],
  4200. ['shadowOffsetY'],
  4201. ['shadowColor']
  4202. ]
  4203. )
  4204. };
  4205. /***/ },
  4206. /* 19 */
  4207. /***/ function(module, exports, __webpack_require__) {
  4208. /**
  4209. * Component model
  4210. *
  4211. * @module echarts/model/Component
  4212. */
  4213. var Model = __webpack_require__(8);
  4214. var zrUtil = __webpack_require__(3);
  4215. var arrayPush = Array.prototype.push;
  4216. var componentUtil = __webpack_require__(20);
  4217. var clazzUtil = __webpack_require__(9);
  4218. var layout = __webpack_require__(21);
  4219. /**
  4220. * @alias module:echarts/model/Component
  4221. * @constructor
  4222. * @param {Object} option
  4223. * @param {module:echarts/model/Model} parentModel
  4224. * @param {module:echarts/model/Model} ecModel
  4225. */
  4226. var ComponentModel = Model.extend({
  4227. type: 'component',
  4228. /**
  4229. * @readOnly
  4230. * @type {string}
  4231. */
  4232. id: '',
  4233. /**
  4234. * @readOnly
  4235. */
  4236. name: '',
  4237. /**
  4238. * @readOnly
  4239. * @type {string}
  4240. */
  4241. mainType: '',
  4242. /**
  4243. * @readOnly
  4244. * @type {string}
  4245. */
  4246. subType: '',
  4247. /**
  4248. * @readOnly
  4249. * @type {number}
  4250. */
  4251. componentIndex: 0,
  4252. /**
  4253. * @type {Object}
  4254. * @protected
  4255. */
  4256. defaultOption: null,
  4257. /**
  4258. * @type {module:echarts/model/Global}
  4259. * @readOnly
  4260. */
  4261. ecModel: null,
  4262. /**
  4263. * key: componentType
  4264. * value: Component model list, can not be null.
  4265. * @type {Object.<string, Array.<module:echarts/model/Model>>}
  4266. * @readOnly
  4267. */
  4268. dependentModels: [],
  4269. /**
  4270. * @type {string}
  4271. * @readOnly
  4272. */
  4273. uid: null,
  4274. /**
  4275. * Support merge layout params.
  4276. * Only support 'box' now (left/right/top/bottom/width/height).
  4277. * @type {string|Object} Object can be {ignoreSize: true}
  4278. * @readOnly
  4279. */
  4280. layoutMode: null,
  4281. init: function (option, parentModel, ecModel, extraOpt) {
  4282. this.mergeDefaultAndTheme(this.option, this.ecModel);
  4283. },
  4284. mergeDefaultAndTheme: function (option, ecModel) {
  4285. var layoutMode = this.layoutMode;
  4286. var inputPositionParams = layoutMode
  4287. ? layout.getLayoutParams(option) : {};
  4288. var themeModel = ecModel.getTheme();
  4289. zrUtil.merge(option, themeModel.get(this.mainType));
  4290. zrUtil.merge(option, this.getDefaultOption());
  4291. if (layoutMode) {
  4292. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  4293. }
  4294. },
  4295. mergeOption: function (option) {
  4296. zrUtil.merge(this.option, option, true);
  4297. var layoutMode = this.layoutMode;
  4298. if (layoutMode) {
  4299. layout.mergeLayoutParam(this.option, option, layoutMode);
  4300. }
  4301. },
  4302. // Hooker after init or mergeOption
  4303. optionUpdated: function (ecModel) {},
  4304. getDefaultOption: function () {
  4305. if (!this.hasOwnProperty('__defaultOption')) {
  4306. var optList = [];
  4307. var Class = this.constructor;
  4308. while (Class) {
  4309. var opt = Class.prototype.defaultOption;
  4310. opt && optList.push(opt);
  4311. Class = Class.superClass;
  4312. }
  4313. var defaultOption = {};
  4314. for (var i = optList.length - 1; i >= 0; i--) {
  4315. defaultOption = zrUtil.merge(defaultOption, optList[i], true);
  4316. }
  4317. this.__defaultOption = defaultOption;
  4318. }
  4319. return this.__defaultOption;
  4320. }
  4321. });
  4322. // Reset ComponentModel.extend, add preConstruct.
  4323. clazzUtil.enableClassExtend(
  4324. ComponentModel,
  4325. function (option, parentModel, ecModel, extraOpt) {
  4326. // Set dependentModels, componentIndex, name, id, mainType, subType.
  4327. zrUtil.extend(this, extraOpt);
  4328. this.uid = componentUtil.getUID('componentModel');
  4329. // this.setReadOnly([
  4330. // 'type', 'id', 'uid', 'name', 'mainType', 'subType',
  4331. // 'dependentModels', 'componentIndex'
  4332. // ]);
  4333. }
  4334. );
  4335. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  4336. clazzUtil.enableClassManagement(
  4337. ComponentModel, {registerWhenExtend: true}
  4338. );
  4339. componentUtil.enableSubTypeDefaulter(ComponentModel);
  4340. // Add capability of ComponentModel.topologicalTravel.
  4341. componentUtil.enableTopologicalTravel(ComponentModel, getDependencies);
  4342. function getDependencies(componentType) {
  4343. var deps = [];
  4344. zrUtil.each(ComponentModel.getClassesByMainType(componentType), function (Clazz) {
  4345. arrayPush.apply(deps, Clazz.prototype.dependencies || []);
  4346. });
  4347. // Ensure main type
  4348. return zrUtil.map(deps, function (type) {
  4349. return clazzUtil.parseClassType(type).main;
  4350. });
  4351. }
  4352. zrUtil.mixin(ComponentModel, __webpack_require__(22));
  4353. module.exports = ComponentModel;
  4354. /***/ },
  4355. /* 20 */
  4356. /***/ function(module, exports, __webpack_require__) {
  4357. var zrUtil = __webpack_require__(3);
  4358. var clazz = __webpack_require__(9);
  4359. var parseClassType = clazz.parseClassType;
  4360. var base = 0;
  4361. var componentUtil = {};
  4362. var DELIMITER = '_';
  4363. /**
  4364. * @public
  4365. * @param {string} type
  4366. * @return {string}
  4367. */
  4368. componentUtil.getUID = function (type) {
  4369. // Considering the case of crossing js context,
  4370. // use Math.random to make id as unique as possible.
  4371. return [(type || ''), base++, Math.random()].join(DELIMITER);
  4372. };
  4373. /**
  4374. * @inner
  4375. */
  4376. componentUtil.enableSubTypeDefaulter = function (entity) {
  4377. var subTypeDefaulters = {};
  4378. entity.registerSubTypeDefaulter = function (componentType, defaulter) {
  4379. componentType = parseClassType(componentType);
  4380. subTypeDefaulters[componentType.main] = defaulter;
  4381. };
  4382. entity.determineSubType = function (componentType, option) {
  4383. var type = option.type;
  4384. if (!type) {
  4385. var componentTypeMain = parseClassType(componentType).main;
  4386. if (entity.hasSubTypes(componentType) && subTypeDefaulters[componentTypeMain]) {
  4387. type = subTypeDefaulters[componentTypeMain](option);
  4388. }
  4389. }
  4390. return type;
  4391. };
  4392. return entity;
  4393. };
  4394. /**
  4395. * Topological travel on Activity Network (Activity On Vertices).
  4396. * Dependencies is defined in Model.prototype.dependencies, like ['xAxis', 'yAxis'].
  4397. *
  4398. * If 'xAxis' or 'yAxis' is absent in componentTypeList, just ignore it in topology.
  4399. *
  4400. * If there is circle dependencey, Error will be thrown.
  4401. *
  4402. */
  4403. componentUtil.enableTopologicalTravel = function (entity, dependencyGetter) {
  4404. /**
  4405. * @public
  4406. * @param {Array.<string>} targetNameList Target Component type list.
  4407. * Can be ['aa', 'bb', 'aa.xx']
  4408. * @param {Array.<string>} fullNameList By which we can build dependency graph.
  4409. * @param {Function} callback Params: componentType, dependencies.
  4410. * @param {Object} context Scope of callback.
  4411. */
  4412. entity.topologicalTravel = function (targetNameList, fullNameList, callback, context) {
  4413. if (!targetNameList.length) {
  4414. return;
  4415. }
  4416. var result = makeDepndencyGraph(fullNameList);
  4417. var graph = result.graph;
  4418. var stack = result.noEntryList;
  4419. var targetNameSet = {};
  4420. zrUtil.each(targetNameList, function (name) {
  4421. targetNameSet[name] = true;
  4422. });
  4423. while (stack.length) {
  4424. var currComponentType = stack.pop();
  4425. var currVertex = graph[currComponentType];
  4426. var isInTargetNameSet = !!targetNameSet[currComponentType];
  4427. if (isInTargetNameSet) {
  4428. callback.call(context, currComponentType, currVertex.originalDeps.slice());
  4429. delete targetNameSet[currComponentType];
  4430. }
  4431. zrUtil.each(
  4432. currVertex.successor,
  4433. isInTargetNameSet ? removeEdgeAndAdd : removeEdge
  4434. );
  4435. }
  4436. zrUtil.each(targetNameSet, function () {
  4437. throw new Error('Circle dependency may exists');
  4438. });
  4439. function removeEdge(succComponentType) {
  4440. graph[succComponentType].entryCount--;
  4441. if (graph[succComponentType].entryCount === 0) {
  4442. stack.push(succComponentType);
  4443. }
  4444. }
  4445. // Consider this case: legend depends on series, and we call
  4446. // chart.setOption({series: [...]}), where only series is in option.
  4447. // If we do not have 'removeEdgeAndAdd', legendModel.mergeOption will
  4448. // not be called, but only sereis.mergeOption is called. Thus legend
  4449. // have no chance to update its local record about series (like which
  4450. // name of series is available in legend).
  4451. function removeEdgeAndAdd(succComponentType) {
  4452. targetNameSet[succComponentType] = true;
  4453. removeEdge(succComponentType);
  4454. }
  4455. };
  4456. /**
  4457. * DepndencyGraph: {Object}
  4458. * key: conponentType,
  4459. * value: {
  4460. * successor: [conponentTypes...],
  4461. * originalDeps: [conponentTypes...],
  4462. * entryCount: {number}
  4463. * }
  4464. */
  4465. function makeDepndencyGraph(fullNameList) {
  4466. var graph = {};
  4467. var noEntryList = [];
  4468. zrUtil.each(fullNameList, function (name) {
  4469. var thisItem = createDependencyGraphItem(graph, name);
  4470. var originalDeps = thisItem.originalDeps = dependencyGetter(name);
  4471. var availableDeps = getAvailableDependencies(originalDeps, fullNameList);
  4472. thisItem.entryCount = availableDeps.length;
  4473. if (thisItem.entryCount === 0) {
  4474. noEntryList.push(name);
  4475. }
  4476. zrUtil.each(availableDeps, function (dependentName) {
  4477. if (zrUtil.indexOf(thisItem.predecessor, dependentName) < 0) {
  4478. thisItem.predecessor.push(dependentName);
  4479. }
  4480. var thatItem = createDependencyGraphItem(graph, dependentName);
  4481. if (zrUtil.indexOf(thatItem.successor, dependentName) < 0) {
  4482. thatItem.successor.push(name);
  4483. }
  4484. });
  4485. });
  4486. return {graph: graph, noEntryList: noEntryList};
  4487. }
  4488. function createDependencyGraphItem(graph, name) {
  4489. if (!graph[name]) {
  4490. graph[name] = {predecessor: [], successor: []};
  4491. }
  4492. return graph[name];
  4493. }
  4494. function getAvailableDependencies(originalDeps, fullNameList) {
  4495. var availableDeps = [];
  4496. zrUtil.each(originalDeps, function (dep) {
  4497. zrUtil.indexOf(fullNameList, dep) >= 0 && availableDeps.push(dep);
  4498. });
  4499. return availableDeps;
  4500. }
  4501. };
  4502. module.exports = componentUtil;
  4503. /***/ },
  4504. /* 21 */
  4505. /***/ function(module, exports, __webpack_require__) {
  4506. 'use strict';
  4507. // Layout helpers for each component positioning
  4508. var zrUtil = __webpack_require__(3);
  4509. var BoundingRect = __webpack_require__(15);
  4510. var numberUtil = __webpack_require__(7);
  4511. var formatUtil = __webpack_require__(6);
  4512. var parsePercent = numberUtil.parsePercent;
  4513. var each = zrUtil.each;
  4514. var layout = {};
  4515. var LOCATION_PARAMS = ['left', 'right', 'top', 'bottom', 'width', 'height'];
  4516. function boxLayout(orient, group, gap, maxWidth, maxHeight) {
  4517. var x = 0;
  4518. var y = 0;
  4519. if (maxWidth == null) {
  4520. maxWidth = Infinity;
  4521. }
  4522. if (maxHeight == null) {
  4523. maxHeight = Infinity;
  4524. }
  4525. var currentLineMaxSize = 0;
  4526. group.eachChild(function (child, idx) {
  4527. var position = child.position;
  4528. var rect = child.getBoundingRect();
  4529. var nextChild = group.childAt(idx + 1);
  4530. var nextChildRect = nextChild && nextChild.getBoundingRect();
  4531. var nextX;
  4532. var nextY;
  4533. if (orient === 'horizontal') {
  4534. var moveX = rect.width + (nextChildRect ? (-nextChildRect.x + rect.x) : 0);
  4535. nextX = x + moveX;
  4536. // Wrap when width exceeds maxWidth or meet a `newline` group
  4537. if (nextX > maxWidth || child.newline) {
  4538. x = 0;
  4539. nextX = moveX;
  4540. y += currentLineMaxSize + gap;
  4541. currentLineMaxSize = rect.height;
  4542. }
  4543. else {
  4544. currentLineMaxSize = Math.max(currentLineMaxSize, rect.height);
  4545. }
  4546. }
  4547. else {
  4548. var moveY = rect.height + (nextChildRect ? (-nextChildRect.y + rect.y) : 0);
  4549. nextY = y + moveY;
  4550. // Wrap when width exceeds maxHeight or meet a `newline` group
  4551. if (nextY > maxHeight || child.newline) {
  4552. x += currentLineMaxSize + gap;
  4553. y = 0;
  4554. nextY = moveY;
  4555. currentLineMaxSize = rect.width;
  4556. }
  4557. else {
  4558. currentLineMaxSize = Math.max(currentLineMaxSize, rect.width);
  4559. }
  4560. }
  4561. if (child.newline) {
  4562. return;
  4563. }
  4564. position[0] = x;
  4565. position[1] = y;
  4566. orient === 'horizontal'
  4567. ? (x = nextX + gap)
  4568. : (y = nextY + gap);
  4569. });
  4570. }
  4571. /**
  4572. * VBox or HBox layouting
  4573. * @param {string} orient
  4574. * @param {module:zrender/container/Group} group
  4575. * @param {number} gap
  4576. * @param {number} [width=Infinity]
  4577. * @param {number} [height=Infinity]
  4578. */
  4579. layout.box = boxLayout;
  4580. /**
  4581. * VBox layouting
  4582. * @param {module:zrender/container/Group} group
  4583. * @param {number} gap
  4584. * @param {number} [width=Infinity]
  4585. * @param {number} [height=Infinity]
  4586. */
  4587. layout.vbox = zrUtil.curry(boxLayout, 'vertical');
  4588. /**
  4589. * HBox layouting
  4590. * @param {module:zrender/container/Group} group
  4591. * @param {number} gap
  4592. * @param {number} [width=Infinity]
  4593. * @param {number} [height=Infinity]
  4594. */
  4595. layout.hbox = zrUtil.curry(boxLayout, 'horizontal');
  4596. /**
  4597. * If x or x2 is not specified or 'center' 'left' 'right',
  4598. * the width would be as long as possible.
  4599. * If y or y2 is not specified or 'middle' 'top' 'bottom',
  4600. * the height would be as long as possible.
  4601. *
  4602. * @param {Object} positionInfo
  4603. * @param {number|string} [positionInfo.x]
  4604. * @param {number|string} [positionInfo.y]
  4605. * @param {number|string} [positionInfo.x2]
  4606. * @param {number|string} [positionInfo.y2]
  4607. * @param {Object} containerRect
  4608. * @param {string|number} margin
  4609. * @return {Object} {width, height}
  4610. */
  4611. layout.getAvailableSize = function (positionInfo, containerRect, margin) {
  4612. var containerWidth = containerRect.width;
  4613. var containerHeight = containerRect.height;
  4614. var x = parsePercent(positionInfo.x, containerWidth);
  4615. var y = parsePercent(positionInfo.y, containerHeight);
  4616. var x2 = parsePercent(positionInfo.x2, containerWidth);
  4617. var y2 = parsePercent(positionInfo.y2, containerHeight);
  4618. (isNaN(x) || isNaN(parseFloat(positionInfo.x))) && (x = 0);
  4619. (isNaN(x2) || isNaN(parseFloat(positionInfo.x2))) && (x2 = containerWidth);
  4620. (isNaN(y) || isNaN(parseFloat(positionInfo.y))) && (y = 0);
  4621. (isNaN(y2) || isNaN(parseFloat(positionInfo.y2))) && (y2 = containerHeight);
  4622. margin = formatUtil.normalizeCssArray(margin || 0);
  4623. return {
  4624. width: Math.max(x2 - x - margin[1] - margin[3], 0),
  4625. height: Math.max(y2 - y - margin[0] - margin[2], 0)
  4626. };
  4627. };
  4628. /**
  4629. * Parse position info.
  4630. *
  4631. * @param {Object} positionInfo
  4632. * @param {number|string} [positionInfo.left]
  4633. * @param {number|string} [positionInfo.top]
  4634. * @param {number|string} [positionInfo.right]
  4635. * @param {number|string} [positionInfo.bottom]
  4636. * @param {number|string} [positionInfo.width]
  4637. * @param {number|string} [positionInfo.height]
  4638. * @param {number|string} [positionInfo.aspect] Aspect is width / height
  4639. * @param {Object} containerRect
  4640. * @param {string|number} [margin]
  4641. *
  4642. * @return {module:zrender/core/BoundingRect}
  4643. */
  4644. layout.getLayoutRect = function (
  4645. positionInfo, containerRect, margin
  4646. ) {
  4647. margin = formatUtil.normalizeCssArray(margin || 0);
  4648. var containerWidth = containerRect.width;
  4649. var containerHeight = containerRect.height;
  4650. var left = parsePercent(positionInfo.left, containerWidth);
  4651. var top = parsePercent(positionInfo.top, containerHeight);
  4652. var right = parsePercent(positionInfo.right, containerWidth);
  4653. var bottom = parsePercent(positionInfo.bottom, containerHeight);
  4654. var width = parsePercent(positionInfo.width, containerWidth);
  4655. var height = parsePercent(positionInfo.height, containerHeight);
  4656. var verticalMargin = margin[2] + margin[0];
  4657. var horizontalMargin = margin[1] + margin[3];
  4658. var aspect = positionInfo.aspect;
  4659. // If width is not specified, calculate width from left and right
  4660. if (isNaN(width)) {
  4661. width = containerWidth - right - horizontalMargin - left;
  4662. }
  4663. if (isNaN(height)) {
  4664. height = containerHeight - bottom - verticalMargin - top;
  4665. }
  4666. // If width and height are not given
  4667. // 1. Graph should not exceeds the container
  4668. // 2. Aspect must be keeped
  4669. // 3. Graph should take the space as more as possible
  4670. if (isNaN(width) && isNaN(height)) {
  4671. if (aspect > containerWidth / containerHeight) {
  4672. width = containerWidth * 0.8;
  4673. }
  4674. else {
  4675. height = containerHeight * 0.8;
  4676. }
  4677. }
  4678. if (aspect != null) {
  4679. // Calculate width or height with given aspect
  4680. if (isNaN(width)) {
  4681. width = aspect * height;
  4682. }
  4683. if (isNaN(height)) {
  4684. height = width / aspect;
  4685. }
  4686. }
  4687. // If left is not specified, calculate left from right and width
  4688. if (isNaN(left)) {
  4689. left = containerWidth - right - width - horizontalMargin;
  4690. }
  4691. if (isNaN(top)) {
  4692. top = containerHeight - bottom - height - verticalMargin;
  4693. }
  4694. // Align left and top
  4695. switch (positionInfo.left || positionInfo.right) {
  4696. case 'center':
  4697. left = containerWidth / 2 - width / 2 - margin[3];
  4698. break;
  4699. case 'right':
  4700. left = containerWidth - width - horizontalMargin;
  4701. break;
  4702. }
  4703. switch (positionInfo.top || positionInfo.bottom) {
  4704. case 'middle':
  4705. case 'center':
  4706. top = containerHeight / 2 - height / 2 - margin[0];
  4707. break;
  4708. case 'bottom':
  4709. top = containerHeight - height - verticalMargin;
  4710. break;
  4711. }
  4712. // If something is wrong and left, top, width, height are calculated as NaN
  4713. left = left || 0;
  4714. top = top || 0;
  4715. if (isNaN(width)) {
  4716. // Width may be NaN if only one value is given except width
  4717. width = containerWidth - left - (right || 0);
  4718. }
  4719. if (isNaN(height)) {
  4720. // Height may be NaN if only one value is given except height
  4721. height = containerHeight - top - (bottom || 0);
  4722. }
  4723. var rect = new BoundingRect(left + margin[3], top + margin[0], width, height);
  4724. rect.margin = margin;
  4725. return rect;
  4726. };
  4727. /**
  4728. * Position group of component in viewport
  4729. * Group position is specified by either
  4730. * {left, top}, {right, bottom}
  4731. * If all properties exists, right and bottom will be igonred.
  4732. *
  4733. * @param {module:zrender/container/Group} group
  4734. * @param {Object} positionInfo
  4735. * @param {number|string} [positionInfo.left]
  4736. * @param {number|string} [positionInfo.top]
  4737. * @param {number|string} [positionInfo.right]
  4738. * @param {number|string} [positionInfo.bottom]
  4739. * @param {Object} containerRect
  4740. * @param {string|number} margin
  4741. */
  4742. layout.positionGroup = function (
  4743. group, positionInfo, containerRect, margin
  4744. ) {
  4745. var groupRect = group.getBoundingRect();
  4746. positionInfo = zrUtil.extend(zrUtil.clone(positionInfo), {
  4747. width: groupRect.width,
  4748. height: groupRect.height
  4749. });
  4750. positionInfo = layout.getLayoutRect(
  4751. positionInfo, containerRect, margin
  4752. );
  4753. group.position = [
  4754. positionInfo.x - groupRect.x,
  4755. positionInfo.y - groupRect.y
  4756. ];
  4757. };
  4758. /**
  4759. * Consider Case:
  4760. * When defulat option has {left: 0, width: 100}, and we set {right: 0}
  4761. * through setOption or media query, using normal zrUtil.merge will cause
  4762. * {right: 0} does not take effect.
  4763. *
  4764. * @example
  4765. * ComponentModel.extend({
  4766. * init: function () {
  4767. * ...
  4768. * var inputPositionParams = layout.getLayoutParams(option);
  4769. * this.mergeOption(inputPositionParams);
  4770. * },
  4771. * mergeOption: function (newOption) {
  4772. * newOption && zrUtil.merge(thisOption, newOption, true);
  4773. * layout.mergeLayoutParam(thisOption, newOption);
  4774. * }
  4775. * });
  4776. *
  4777. * @param {Object} targetOption
  4778. * @param {Object} newOption
  4779. * @param {Object|string} [opt]
  4780. * @param {boolean} [opt.ignoreSize=false] Some component must has width and height.
  4781. */
  4782. layout.mergeLayoutParam = function (targetOption, newOption, opt) {
  4783. !zrUtil.isObject(opt) && (opt = {});
  4784. var hNames = ['width', 'left', 'right']; // Order by priority.
  4785. var vNames = ['height', 'top', 'bottom']; // Order by priority.
  4786. var hResult = merge(hNames);
  4787. var vResult = merge(vNames);
  4788. copy(hNames, targetOption, hResult);
  4789. copy(vNames, targetOption, vResult);
  4790. function merge(names) {
  4791. var newParams = {};
  4792. var newValueCount = 0;
  4793. var merged = {};
  4794. var mergedValueCount = 0;
  4795. var enoughParamNumber = opt.ignoreSize ? 1 : 2;
  4796. each(names, function (name) {
  4797. merged[name] = targetOption[name];
  4798. });
  4799. each(names, function (name) {
  4800. // Consider case: newOption.width is null, which is
  4801. // set by user for removing width setting.
  4802. hasProp(newOption, name) && (newParams[name] = merged[name] = newOption[name]);
  4803. hasValue(newParams, name) && newValueCount++;
  4804. hasValue(merged, name) && mergedValueCount++;
  4805. });
  4806. // Case: newOption: {width: ..., right: ...},
  4807. // or targetOption: {right: ...} and newOption: {width: ...},
  4808. // There is no conflict when merged only has params count
  4809. // little than enoughParamNumber.
  4810. if (mergedValueCount === enoughParamNumber || !newValueCount) {
  4811. return merged;
  4812. }
  4813. // Case: newOption: {width: ..., right: ...},
  4814. // Than we can make sure user only want those two, and ignore
  4815. // all origin params in targetOption.
  4816. else if (newValueCount >= enoughParamNumber) {
  4817. return newParams;
  4818. }
  4819. else {
  4820. // Chose another param from targetOption by priority.
  4821. // When 'ignoreSize', enoughParamNumber is 1 and those will not happen.
  4822. for (var i = 0; i < names.length; i++) {
  4823. var name = names[i];
  4824. if (!hasProp(newParams, name) && hasProp(targetOption, name)) {
  4825. newParams[name] = targetOption[name];
  4826. break;
  4827. }
  4828. }
  4829. return newParams;
  4830. }
  4831. }
  4832. function hasProp(obj, name) {
  4833. return obj.hasOwnProperty(name);
  4834. }
  4835. function hasValue(obj, name) {
  4836. return obj[name] != null && obj[name] !== 'auto';
  4837. }
  4838. function copy(names, target, source) {
  4839. each(names, function (name) {
  4840. target[name] = source[name];
  4841. });
  4842. }
  4843. };
  4844. /**
  4845. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  4846. * @param {Object} source
  4847. * @return {Object} Result contains those props.
  4848. */
  4849. layout.getLayoutParams = function (source) {
  4850. return layout.copyLayoutParams({}, source);
  4851. };
  4852. /**
  4853. * Retrieve 'left', 'right', 'top', 'bottom', 'width', 'height' from object.
  4854. * @param {Object} source
  4855. * @return {Object} Result contains those props.
  4856. */
  4857. layout.copyLayoutParams = function (target, source) {
  4858. source && target && each(LOCATION_PARAMS, function (name) {
  4859. source.hasOwnProperty(name) && (target[name] = source[name]);
  4860. });
  4861. return target;
  4862. };
  4863. module.exports = layout;
  4864. /***/ },
  4865. /* 22 */
  4866. /***/ function(module, exports) {
  4867. module.exports = {
  4868. getBoxLayoutParams: function () {
  4869. return {
  4870. left: this.get('left'),
  4871. top: this.get('top'),
  4872. right: this.get('right'),
  4873. bottom: this.get('bottom'),
  4874. width: this.get('width'),
  4875. height: this.get('height')
  4876. };
  4877. }
  4878. };
  4879. /***/ },
  4880. /* 23 */
  4881. /***/ function(module, exports) {
  4882. var platform = '';
  4883. // Navigator not exists in node
  4884. if (typeof navigator !== 'undefined') {
  4885. platform = navigator.platform || '';
  4886. }
  4887. module.exports = {
  4888. // 全图默认背景
  4889. // backgroundColor: 'rgba(0,0,0,0)',
  4890. // https://dribbble.com/shots/1065960-Infographic-Pie-chart-visualization
  4891. // color: ['#5793f3', '#d14a61', '#fd9c35', '#675bba', '#fec42c', '#dd4444', '#d4df5a', '#cd4870'],
  4892. // 浅色
  4893. // color: ['#bcd3bb', '#e88f70', '#edc1a5', '#9dc5c8', '#e1e8c8', '#7b7c68', '#e5b5b5', '#f0b489', '#928ea8', '#bda29a'],
  4894. // color: ['#cc5664', '#9bd6ec', '#ea946e', '#8acaaa', '#f1ec64', '#ee8686', '#a48dc1', '#5da6bc', '#b9dcae'],
  4895. // 深色
  4896. color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83', '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
  4897. // 默认需要 Grid 配置项
  4898. grid: {},
  4899. // 主题,主题
  4900. textStyle: {
  4901. // color: '#000',
  4902. // decoration: 'none',
  4903. // PENDING
  4904. fontFamily: platform.match(/^Win/) ? 'Microsoft YaHei' : 'sans-serif',
  4905. // fontFamily: 'Arial, Verdana, sans-serif',
  4906. fontSize: 12,
  4907. fontStyle: 'normal',
  4908. fontWeight: 'normal'
  4909. },
  4910. // 主题,默认标志图形类型列表
  4911. // symbolList: [
  4912. // 'circle', 'rectangle', 'triangle', 'diamond',
  4913. // 'emptyCircle', 'emptyRectangle', 'emptyTriangle', 'emptyDiamond'
  4914. // ],
  4915. animation: true, // 过渡动画是否开启
  4916. animationThreshold: 2000, // 动画元素阀值,产生的图形原素超过2000不出动画
  4917. animationDuration: 1000, // 过渡动画参数:进入
  4918. animationDurationUpdate: 300, // 过渡动画参数:更新
  4919. animationEasing: 'exponentialOut', //BounceOut
  4920. animationEasingUpdate: 'cubicOut'
  4921. };
  4922. /***/ },
  4923. /* 24 */
  4924. /***/ function(module, exports, __webpack_require__) {
  4925. 'use strict';
  4926. var zrUtil = __webpack_require__(3);
  4927. var echartsAPIList = [
  4928. 'getDom', 'getZr', 'getWidth', 'getHeight', 'dispatchAction',
  4929. 'on', 'off', 'getDataURL', 'getConnectedDataURL', 'getModel', 'getOption'
  4930. ];
  4931. function ExtensionAPI(chartInstance) {
  4932. zrUtil.each(echartsAPIList, function (name) {
  4933. this[name] = zrUtil.bind(chartInstance[name], chartInstance);
  4934. }, this);
  4935. }
  4936. module.exports = ExtensionAPI;
  4937. /***/ },
  4938. /* 25 */
  4939. /***/ function(module, exports) {
  4940. 'use strict';
  4941. // var zrUtil = require('zrender/lib/core/util');
  4942. var coordinateSystemCreators = {};
  4943. function CoordinateSystemManager() {
  4944. this._coordinateSystems = [];
  4945. }
  4946. CoordinateSystemManager.prototype = {
  4947. constructor: CoordinateSystemManager,
  4948. create: function (ecModel, api) {
  4949. var coordinateSystems = [];
  4950. for (var type in coordinateSystemCreators) {
  4951. var list = coordinateSystemCreators[type].create(ecModel, api);
  4952. list && (coordinateSystems = coordinateSystems.concat(list));
  4953. }
  4954. this._coordinateSystems = coordinateSystems;
  4955. },
  4956. update: function (ecModel, api) {
  4957. var coordinateSystems = this._coordinateSystems;
  4958. for (var i = 0; i < coordinateSystems.length; i++) {
  4959. // FIXME MUST have
  4960. coordinateSystems[i].update && coordinateSystems[i].update(ecModel, api);
  4961. }
  4962. }
  4963. };
  4964. CoordinateSystemManager.register = function (type, coordinateSystemCreator) {
  4965. coordinateSystemCreators[type] = coordinateSystemCreator;
  4966. };
  4967. CoordinateSystemManager.get = function (type) {
  4968. return coordinateSystemCreators[type];
  4969. };
  4970. module.exports = CoordinateSystemManager;
  4971. /***/ },
  4972. /* 26 */
  4973. /***/ function(module, exports, __webpack_require__) {
  4974. /**
  4975. * ECharts option manager
  4976. *
  4977. * @module {echarts/model/OptionManager}
  4978. */
  4979. var zrUtil = __webpack_require__(3);
  4980. var modelUtil = __webpack_require__(5);
  4981. var ComponentModel = __webpack_require__(19);
  4982. var each = zrUtil.each;
  4983. var clone = zrUtil.clone;
  4984. var map = zrUtil.map;
  4985. var merge = zrUtil.merge;
  4986. var QUERY_REG = /^(min|max)?(.+)$/;
  4987. /**
  4988. * TERM EXPLANATIONS:
  4989. *
  4990. * [option]:
  4991. *
  4992. * An object that contains definitions of components. For example:
  4993. * var option = {
  4994. * title: {...},
  4995. * legend: {...},
  4996. * visualMap: {...},
  4997. * series: [
  4998. * {data: [...]},
  4999. * {data: [...]},
  5000. * ...
  5001. * ]
  5002. * };
  5003. *
  5004. * [rawOption]:
  5005. *
  5006. * An object input to echarts.setOption. 'rawOption' may be an
  5007. * 'option', or may be an object contains multi-options. For example:
  5008. * var option = {
  5009. * baseOption: {
  5010. * title: {...},
  5011. * legend: {...},
  5012. * series: [
  5013. * {data: [...]},
  5014. * {data: [...]},
  5015. * ...
  5016. * ]
  5017. * },
  5018. * timeline: {...},
  5019. * options: [
  5020. * {title: {...}, series: {data: [...]}},
  5021. * {title: {...}, series: {data: [...]}},
  5022. * ...
  5023. * ],
  5024. * media: [
  5025. * {
  5026. * query: {maxWidth: 320},
  5027. * option: {series: {x: 20}, visualMap: {show: false}}
  5028. * },
  5029. * {
  5030. * query: {minWidth: 320, maxWidth: 720},
  5031. * option: {series: {x: 500}, visualMap: {show: true}}
  5032. * },
  5033. * {
  5034. * option: {series: {x: 1200}, visualMap: {show: true}}
  5035. * }
  5036. * ]
  5037. * };
  5038. *
  5039. * @alias module:echarts/model/OptionManager
  5040. * @param {module:echarts/ExtensionAPI} api
  5041. */
  5042. function OptionManager(api) {
  5043. /**
  5044. * @private
  5045. * @type {module:echarts/ExtensionAPI}
  5046. */
  5047. this._api = api;
  5048. /**
  5049. * @private
  5050. * @type {Array.<number>}
  5051. */
  5052. this._timelineOptions = [];
  5053. /**
  5054. * @private
  5055. * @type {Array.<Object>}
  5056. */
  5057. this._mediaList = [];
  5058. /**
  5059. * @private
  5060. * @type {Object}
  5061. */
  5062. this._mediaDefault;
  5063. /**
  5064. * -1, means default.
  5065. * empty means no media.
  5066. * @private
  5067. * @type {Array.<number>}
  5068. */
  5069. this._currentMediaIndices = [];
  5070. /**
  5071. * @private
  5072. * @type {Object}
  5073. */
  5074. this._optionBackup;
  5075. /**
  5076. * @private
  5077. * @type {Object}
  5078. */
  5079. this._newBaseOption;
  5080. }
  5081. // timeline.notMerge is not supported in ec3. Firstly there is rearly
  5082. // case that notMerge is needed. Secondly supporting 'notMerge' requires
  5083. // rawOption cloned and backuped when timeline changed, which does no
  5084. // good to performance. What's more, that both timeline and setOption
  5085. // method supply 'notMerge' brings complex and some problems.
  5086. // Consider this case:
  5087. // (step1) chart.setOption({timeline: {notMerge: false}, ...}, false);
  5088. // (step2) chart.setOption({timeline: {notMerge: true}, ...}, false);
  5089. OptionManager.prototype = {
  5090. constructor: OptionManager,
  5091. /**
  5092. * @public
  5093. * @param {Object} rawOption Raw option.
  5094. * @param {module:echarts/model/Global} ecModel
  5095. * @param {Array.<Function>} optionPreprocessorFuncs
  5096. * @return {Object} Init option
  5097. */
  5098. setOption: function (rawOption, optionPreprocessorFuncs) {
  5099. rawOption = clone(rawOption, true);
  5100. // FIXME
  5101. // 如果 timeline options 或者 media 中设置了某个属性,而baseOption中没有设置,则进行警告。
  5102. var oldOptionBackup = this._optionBackup;
  5103. var newParsedOption = parseRawOption.call(
  5104. this, rawOption, optionPreprocessorFuncs
  5105. );
  5106. this._newBaseOption = newParsedOption.baseOption;
  5107. // For setOption at second time (using merge mode);
  5108. if (oldOptionBackup) {
  5109. // Only baseOption can be merged.
  5110. mergeOption(oldOptionBackup.baseOption, newParsedOption.baseOption);
  5111. // For simplicity, timeline options and media options do not support merge,
  5112. // that is, if you `setOption` twice and both has timeline options, the latter
  5113. // timeline opitons will not be merged to the formers, but just substitude them.
  5114. if (newParsedOption.timelineOptions.length) {
  5115. oldOptionBackup.timelineOptions = newParsedOption.timelineOptions;
  5116. }
  5117. if (newParsedOption.mediaList.length) {
  5118. oldOptionBackup.mediaList = newParsedOption.mediaList;
  5119. }
  5120. if (newParsedOption.mediaDefault) {
  5121. oldOptionBackup.mediaDefault = newParsedOption.mediaDefault;
  5122. }
  5123. }
  5124. else {
  5125. this._optionBackup = newParsedOption;
  5126. }
  5127. },
  5128. /**
  5129. * @param {boolean} isRecreate
  5130. * @return {Object}
  5131. */
  5132. mountOption: function (isRecreate) {
  5133. var optionBackup = this._optionBackup;
  5134. // TODO
  5135. // 如果没有reset功能则不clone。
  5136. this._timelineOptions = map(optionBackup.timelineOptions, clone);
  5137. this._mediaList = map(optionBackup.mediaList, clone);
  5138. this._mediaDefault = clone(optionBackup.mediaDefault);
  5139. this._currentMediaIndices = [];
  5140. return clone(isRecreate
  5141. // this._optionBackup.baseOption, which is created at the first `setOption`
  5142. // called, and is merged into every new option by inner method `mergeOption`
  5143. // each time `setOption` called, can be only used in `isRecreate`, because
  5144. // its reliability is under suspicion. In other cases option merge is
  5145. // proformed by `model.mergeOption`.
  5146. ? optionBackup.baseOption : this._newBaseOption
  5147. );
  5148. },
  5149. /**
  5150. * @param {module:echarts/model/Global} ecModel
  5151. * @return {Object}
  5152. */
  5153. getTimelineOption: function (ecModel) {
  5154. var option;
  5155. var timelineOptions = this._timelineOptions;
  5156. if (timelineOptions.length) {
  5157. // getTimelineOption can only be called after ecModel inited,
  5158. // so we can get currentIndex from timelineModel.
  5159. var timelineModel = ecModel.getComponent('timeline');
  5160. if (timelineModel) {
  5161. option = clone(
  5162. timelineOptions[timelineModel.getCurrentIndex()],
  5163. true
  5164. );
  5165. }
  5166. }
  5167. return option;
  5168. },
  5169. /**
  5170. * @param {module:echarts/model/Global} ecModel
  5171. * @return {Array.<Object>}
  5172. */
  5173. getMediaOption: function (ecModel) {
  5174. var ecWidth = this._api.getWidth();
  5175. var ecHeight = this._api.getHeight();
  5176. var mediaList = this._mediaList;
  5177. var mediaDefault = this._mediaDefault;
  5178. var indices = [];
  5179. var result = [];
  5180. // No media defined.
  5181. if (!mediaList.length && !mediaDefault) {
  5182. return result;
  5183. }
  5184. // Multi media may be applied, the latter defined media has higher priority.
  5185. for (var i = 0, len = mediaList.length; i < len; i++) {
  5186. if (applyMediaQuery(mediaList[i].query, ecWidth, ecHeight)) {
  5187. indices.push(i);
  5188. }
  5189. }
  5190. // FIXME
  5191. // 是否mediaDefault应该强制用户设置,否则可能修改不能回归。
  5192. if (!indices.length && mediaDefault) {
  5193. indices = [-1];
  5194. }
  5195. if (indices.length && !indicesEquals(indices, this._currentMediaIndices)) {
  5196. result = map(indices, function (index) {
  5197. return clone(
  5198. index === -1 ? mediaDefault.option : mediaList[index].option
  5199. );
  5200. });
  5201. }
  5202. // Otherwise return nothing.
  5203. this._currentMediaIndices = indices;
  5204. return result;
  5205. }
  5206. };
  5207. function parseRawOption(rawOption, optionPreprocessorFuncs) {
  5208. var timelineOptions = [];
  5209. var mediaList = [];
  5210. var mediaDefault;
  5211. var baseOption;
  5212. // Compatible with ec2.
  5213. var timelineOpt = rawOption.timeline;
  5214. if (rawOption.baseOption) {
  5215. baseOption = rawOption.baseOption;
  5216. }
  5217. // For timeline
  5218. if (timelineOpt || rawOption.options) {
  5219. baseOption = baseOption || {};
  5220. timelineOptions = (rawOption.options || []).slice();
  5221. }
  5222. // For media query
  5223. if (rawOption.media) {
  5224. baseOption = baseOption || {};
  5225. var media = rawOption.media;
  5226. each(media, function (singleMedia) {
  5227. if (singleMedia && singleMedia.option) {
  5228. if (singleMedia.query) {
  5229. mediaList.push(singleMedia);
  5230. }
  5231. else if (!mediaDefault) {
  5232. // Use the first media default.
  5233. mediaDefault = singleMedia;
  5234. }
  5235. }
  5236. });
  5237. }
  5238. // For normal option
  5239. if (!baseOption) {
  5240. baseOption = rawOption;
  5241. }
  5242. // Set timelineOpt to baseOption in ec3,
  5243. // which is convenient for merge option.
  5244. if (!baseOption.timeline) {
  5245. baseOption.timeline = timelineOpt;
  5246. }
  5247. // Preprocess.
  5248. each([baseOption].concat(timelineOptions)
  5249. .concat(zrUtil.map(mediaList, function (media) {
  5250. return media.option;
  5251. })),
  5252. function (option) {
  5253. each(optionPreprocessorFuncs, function (preProcess) {
  5254. preProcess(option);
  5255. });
  5256. }
  5257. );
  5258. return {
  5259. baseOption: baseOption,
  5260. timelineOptions: timelineOptions,
  5261. mediaDefault: mediaDefault,
  5262. mediaList: mediaList
  5263. };
  5264. }
  5265. /**
  5266. * @see <http://www.w3.org/TR/css3-mediaqueries/#media1>
  5267. * Support: width, height, aspectRatio
  5268. * Can use max or min as prefix.
  5269. */
  5270. function applyMediaQuery(query, ecWidth, ecHeight) {
  5271. var realMap = {
  5272. width: ecWidth,
  5273. height: ecHeight,
  5274. aspectratio: ecWidth / ecHeight // lowser case for convenientce.
  5275. };
  5276. var applicatable = true;
  5277. zrUtil.each(query, function (value, attr) {
  5278. var matched = attr.match(QUERY_REG);
  5279. if (!matched || !matched[1] || !matched[2]) {
  5280. return;
  5281. }
  5282. var operator = matched[1];
  5283. var realAttr = matched[2].toLowerCase();
  5284. if (!compare(realMap[realAttr], value, operator)) {
  5285. applicatable = false;
  5286. }
  5287. });
  5288. return applicatable;
  5289. }
  5290. function compare(real, expect, operator) {
  5291. if (operator === 'min') {
  5292. return real >= expect;
  5293. }
  5294. else if (operator === 'max') {
  5295. return real <= expect;
  5296. }
  5297. else { // Equals
  5298. return real === expect;
  5299. }
  5300. }
  5301. function indicesEquals(indices1, indices2) {
  5302. // indices is always order by asc and has only finite number.
  5303. return indices1.join(',') === indices2.join(',');
  5304. }
  5305. /**
  5306. * Consider case:
  5307. * `chart.setOption(opt1);`
  5308. * Then user do some interaction like dataZoom, dataView changing.
  5309. * `chart.setOption(opt2);`
  5310. * Then user press 'reset button' in toolbox.
  5311. *
  5312. * After doing that all of the interaction effects should be reset, the
  5313. * chart should be the same as the result of invoke
  5314. * `chart.setOption(opt1); chart.setOption(opt2);`.
  5315. *
  5316. * Although it is not able ensure that
  5317. * `chart.setOption(opt1); chart.setOption(opt2);` is equivalents to
  5318. * `chart.setOption(merge(opt1, opt2));` exactly,
  5319. * this might be the only simple way to implement that feature.
  5320. *
  5321. * MEMO: We've considered some other approaches:
  5322. * 1. Each model handle its self restoration but not uniform treatment.
  5323. * (Too complex in logic and error-prone)
  5324. * 2. Use a shadow ecModel. (Performace expensive)
  5325. */
  5326. function mergeOption(oldOption, newOption) {
  5327. newOption = newOption || {};
  5328. each(newOption, function (newCptOpt, mainType) {
  5329. if (newCptOpt == null) {
  5330. return;
  5331. }
  5332. var oldCptOpt = oldOption[mainType];
  5333. if (!ComponentModel.hasClass(mainType)) {
  5334. oldOption[mainType] = merge(oldCptOpt, newCptOpt, true);
  5335. }
  5336. else {
  5337. newCptOpt = modelUtil.normalizeToArray(newCptOpt);
  5338. oldCptOpt = modelUtil.normalizeToArray(oldCptOpt);
  5339. var mapResult = modelUtil.mappingToExists(oldCptOpt, newCptOpt);
  5340. oldOption[mainType] = map(mapResult, function (item) {
  5341. return (item.option && item.exist)
  5342. ? merge(item.exist, item.option, true)
  5343. : (item.exist || item.option);
  5344. });
  5345. }
  5346. });
  5347. }
  5348. module.exports = OptionManager;
  5349. /***/ },
  5350. /* 27 */
  5351. /***/ function(module, exports, __webpack_require__) {
  5352. 'use strict';
  5353. var zrUtil = __webpack_require__(3);
  5354. var formatUtil = __webpack_require__(6);
  5355. var modelUtil = __webpack_require__(5);
  5356. var ComponentModel = __webpack_require__(19);
  5357. var encodeHTML = formatUtil.encodeHTML;
  5358. var addCommas = formatUtil.addCommas;
  5359. var SeriesModel = ComponentModel.extend({
  5360. type: 'series.__base__',
  5361. /**
  5362. * @readOnly
  5363. */
  5364. seriesIndex: 0,
  5365. // coodinateSystem will be injected in the echarts/CoordinateSystem
  5366. coordinateSystem: null,
  5367. /**
  5368. * @type {Object}
  5369. * @protected
  5370. */
  5371. defaultOption: null,
  5372. /**
  5373. * Data provided for legend
  5374. * @type {Function}
  5375. */
  5376. // PENDING
  5377. legendDataProvider: null,
  5378. init: function (option, parentModel, ecModel, extraOpt) {
  5379. /**
  5380. * @type {number}
  5381. * @readOnly
  5382. */
  5383. this.seriesIndex = this.componentIndex;
  5384. this.mergeDefaultAndTheme(option, ecModel);
  5385. /**
  5386. * @type {module:echarts/data/List|module:echarts/data/Tree|module:echarts/data/Graph}
  5387. * @private
  5388. */
  5389. this._dataBeforeProcessed = this.getInitialData(option, ecModel);
  5390. // If we reverse the order (make this._data firstly, and then make
  5391. // this._dataBeforeProcessed by cloneShallow), cloneShallow will
  5392. // cause this._data.graph.data !== this._data when using
  5393. // module:echarts/data/Graph or module:echarts/data/Tree.
  5394. // See module:echarts/data/helper/linkList
  5395. this._data = this._dataBeforeProcessed.cloneShallow();
  5396. },
  5397. /**
  5398. * Util for merge default and theme to option
  5399. * @param {Object} option
  5400. * @param {module:echarts/model/Global} ecModel
  5401. */
  5402. mergeDefaultAndTheme: function (option, ecModel) {
  5403. zrUtil.merge(
  5404. option,
  5405. ecModel.getTheme().get(this.subType)
  5406. );
  5407. zrUtil.merge(option, this.getDefaultOption());
  5408. // Default label emphasis `position` and `show`
  5409. // FIXME Set label in mergeOption
  5410. modelUtil.defaultEmphasis(option.label, modelUtil.LABEL_OPTIONS);
  5411. this.fillDataTextStyle(option.data);
  5412. },
  5413. mergeOption: function (newSeriesOption, ecModel) {
  5414. newSeriesOption = zrUtil.merge(this.option, newSeriesOption, true);
  5415. this.fillDataTextStyle(newSeriesOption.data);
  5416. var data = this.getInitialData(newSeriesOption, ecModel);
  5417. // TODO Merge data?
  5418. if (data) {
  5419. this._data = data;
  5420. this._dataBeforeProcessed = data.cloneShallow();
  5421. }
  5422. },
  5423. fillDataTextStyle: function (data) {
  5424. // Default data label emphasis `position` and `show`
  5425. // FIXME Tree structure data ?
  5426. // FIXME Performance ?
  5427. if (data) {
  5428. for (var i = 0; i < data.length; i++) {
  5429. if (data[i] && data[i].label) {
  5430. modelUtil.defaultEmphasis(data[i].label, modelUtil.LABEL_OPTIONS);
  5431. }
  5432. }
  5433. }
  5434. },
  5435. /**
  5436. * Init a data structure from data related option in series
  5437. * Must be overwritten
  5438. */
  5439. getInitialData: function () {},
  5440. /**
  5441. * @param {string} [dataType]
  5442. * @return {module:echarts/data/List}
  5443. */
  5444. getData: function (dataType) {
  5445. return dataType == null ? this._data : this._data.getLinkedData(dataType);
  5446. },
  5447. /**
  5448. * @param {module:echarts/data/List} data
  5449. */
  5450. setData: function (data) {
  5451. this._data = data;
  5452. },
  5453. /**
  5454. * Get data before processed
  5455. * @return {module:echarts/data/List}
  5456. */
  5457. getRawData: function () {
  5458. return this._dataBeforeProcessed;
  5459. },
  5460. /**
  5461. * Coord dimension to data dimension.
  5462. *
  5463. * By default the result is the same as dimensions of series data.
  5464. * But in some series data dimensions are different from coord dimensions (i.e.
  5465. * candlestick and boxplot). Override this method to handle those cases.
  5466. *
  5467. * Coord dimension to data dimension can be one-to-many
  5468. *
  5469. * @param {string} coordDim
  5470. * @return {Array.<string>} dimensions on the axis.
  5471. */
  5472. coordDimToDataDim: function (coordDim) {
  5473. return [coordDim];
  5474. },
  5475. /**
  5476. * Convert data dimension to coord dimension.
  5477. *
  5478. * @param {string|number} dataDim
  5479. * @return {string}
  5480. */
  5481. dataDimToCoordDim: function (dataDim) {
  5482. return dataDim;
  5483. },
  5484. /**
  5485. * Get base axis if has coordinate system and has axis.
  5486. * By default use coordSys.getBaseAxis();
  5487. * Can be overrided for some chart.
  5488. * @return {type} description
  5489. */
  5490. getBaseAxis: function () {
  5491. var coordSys = this.coordinateSystem;
  5492. return coordSys && coordSys.getBaseAxis && coordSys.getBaseAxis();
  5493. },
  5494. // FIXME
  5495. /**
  5496. * Default tooltip formatter
  5497. *
  5498. * @param {number} dataIndex
  5499. * @param {boolean} [multipleSeries=false]
  5500. * @param {number} [dataType]
  5501. */
  5502. formatTooltip: function (dataIndex, multipleSeries, dataType) {
  5503. var data = this._data;
  5504. var value = this.getRawValue(dataIndex);
  5505. var formattedValue = zrUtil.isArray(value)
  5506. ? zrUtil.map(value, addCommas).join(', ') : addCommas(value);
  5507. var name = data.getName(dataIndex);
  5508. var color = data.getItemVisual(dataIndex, 'color');
  5509. var colorEl = '<span style="display:inline-block;margin-right:5px;'
  5510. + 'border-radius:10px;width:9px;height:9px;background-color:' + color + '"></span>';
  5511. var seriesName = this.name;
  5512. // FIXME
  5513. if (seriesName === '\0-') {
  5514. // Not show '-'
  5515. seriesName = '';
  5516. }
  5517. return !multipleSeries
  5518. ? ((seriesName && encodeHTML(seriesName) + '<br />') + colorEl
  5519. + (name
  5520. ? encodeHTML(name) + ' : ' + formattedValue
  5521. : formattedValue)
  5522. )
  5523. : (colorEl + encodeHTML(this.name) + ' : ' + formattedValue);
  5524. },
  5525. restoreData: function () {
  5526. this._data = this._dataBeforeProcessed.cloneShallow();
  5527. },
  5528. getAxisTooltipDataIndex: null
  5529. });
  5530. zrUtil.mixin(SeriesModel, modelUtil.dataFormatMixin);
  5531. module.exports = SeriesModel;
  5532. /***/ },
  5533. /* 28 */
  5534. /***/ function(module, exports, __webpack_require__) {
  5535. var Group = __webpack_require__(29);
  5536. var componentUtil = __webpack_require__(20);
  5537. var clazzUtil = __webpack_require__(9);
  5538. var Component = function () {
  5539. /**
  5540. * @type {module:zrender/container/Group}
  5541. * @readOnly
  5542. */
  5543. this.group = new Group();
  5544. /**
  5545. * @type {string}
  5546. * @readOnly
  5547. */
  5548. this.uid = componentUtil.getUID('viewComponent');
  5549. };
  5550. Component.prototype = {
  5551. constructor: Component,
  5552. init: function (ecModel, api) {},
  5553. render: function (componentModel, ecModel, api, payload) {},
  5554. dispose: function () {}
  5555. };
  5556. var componentProto = Component.prototype;
  5557. componentProto.updateView
  5558. = componentProto.updateLayout
  5559. = componentProto.updateVisual
  5560. = function (seriesModel, ecModel, api, payload) {
  5561. // Do nothing;
  5562. };
  5563. // Enable Component.extend.
  5564. clazzUtil.enableClassExtend(Component);
  5565. // Enable capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  5566. clazzUtil.enableClassManagement(Component, {registerWhenExtend: true});
  5567. module.exports = Component;
  5568. /***/ },
  5569. /* 29 */
  5570. /***/ function(module, exports, __webpack_require__) {
  5571. /**
  5572. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  5573. * @module zrender/graphic/Group
  5574. * @example
  5575. * var Group = require('zrender/lib/container/Group');
  5576. * var Circle = require('zrender/lib/graphic/shape/Circle');
  5577. * var g = new Group();
  5578. * g.position[0] = 100;
  5579. * g.position[1] = 100;
  5580. * g.add(new Circle({
  5581. * style: {
  5582. * x: 100,
  5583. * y: 100,
  5584. * r: 20,
  5585. * }
  5586. * }));
  5587. * zr.add(g);
  5588. */
  5589. var zrUtil = __webpack_require__(3);
  5590. var Element = __webpack_require__(30);
  5591. var BoundingRect = __webpack_require__(15);
  5592. /**
  5593. * @alias module:zrender/graphic/Group
  5594. * @constructor
  5595. * @extends module:zrender/mixin/Transformable
  5596. * @extends module:zrender/mixin/Eventful
  5597. */
  5598. var Group = function (opts) {
  5599. opts = opts || {};
  5600. Element.call(this, opts);
  5601. for (var key in opts) {
  5602. this[key] = opts[key];
  5603. }
  5604. this._children = [];
  5605. this.__storage = null;
  5606. this.__dirty = true;
  5607. };
  5608. Group.prototype = {
  5609. constructor: Group,
  5610. /**
  5611. * @type {string}
  5612. */
  5613. type: 'group',
  5614. /**
  5615. * 所有子孙元素是否响应鼠标事件
  5616. * @name module:/zrender/container/Group#silent
  5617. * @type {boolean}
  5618. * @default false
  5619. */
  5620. silent: false,
  5621. /**
  5622. * @return {Array.<module:zrender/Element>}
  5623. */
  5624. children: function () {
  5625. return this._children.slice();
  5626. },
  5627. /**
  5628. * 获取指定 index 的儿子节点
  5629. * @param {number} idx
  5630. * @return {module:zrender/Element}
  5631. */
  5632. childAt: function (idx) {
  5633. return this._children[idx];
  5634. },
  5635. /**
  5636. * 获取指定名字的儿子节点
  5637. * @param {string} name
  5638. * @return {module:zrender/Element}
  5639. */
  5640. childOfName: function (name) {
  5641. var children = this._children;
  5642. for (var i = 0; i < children.length; i++) {
  5643. if (children[i].name === name) {
  5644. return children[i];
  5645. }
  5646. }
  5647. },
  5648. /**
  5649. * @return {number}
  5650. */
  5651. childCount: function () {
  5652. return this._children.length;
  5653. },
  5654. /**
  5655. * 添加子节点到最后
  5656. * @param {module:zrender/Element} child
  5657. */
  5658. add: function (child) {
  5659. if (child && child !== this && child.parent !== this) {
  5660. this._children.push(child);
  5661. this._doAdd(child);
  5662. }
  5663. return this;
  5664. },
  5665. /**
  5666. * 添加子节点在 nextSibling 之前
  5667. * @param {module:zrender/Element} child
  5668. * @param {module:zrender/Element} nextSibling
  5669. */
  5670. addBefore: function (child, nextSibling) {
  5671. if (child && child !== this && child.parent !== this
  5672. && nextSibling && nextSibling.parent === this) {
  5673. var children = this._children;
  5674. var idx = children.indexOf(nextSibling);
  5675. if (idx >= 0) {
  5676. children.splice(idx, 0, child);
  5677. this._doAdd(child);
  5678. }
  5679. }
  5680. return this;
  5681. },
  5682. _doAdd: function (child) {
  5683. if (child.parent) {
  5684. child.parent.remove(child);
  5685. }
  5686. child.parent = this;
  5687. var storage = this.__storage;
  5688. var zr = this.__zr;
  5689. if (storage && storage !== child.__storage) {
  5690. storage.addToMap(child);
  5691. if (child instanceof Group) {
  5692. child.addChildrenToStorage(storage);
  5693. }
  5694. }
  5695. zr && zr.refresh();
  5696. },
  5697. /**
  5698. * 移除子节点
  5699. * @param {module:zrender/Element} child
  5700. */
  5701. remove: function (child) {
  5702. var zr = this.__zr;
  5703. var storage = this.__storage;
  5704. var children = this._children;
  5705. var idx = zrUtil.indexOf(children, child);
  5706. if (idx < 0) {
  5707. return this;
  5708. }
  5709. children.splice(idx, 1);
  5710. child.parent = null;
  5711. if (storage) {
  5712. storage.delFromMap(child.id);
  5713. if (child instanceof Group) {
  5714. child.delChildrenFromStorage(storage);
  5715. }
  5716. }
  5717. zr && zr.refresh();
  5718. return this;
  5719. },
  5720. /**
  5721. * 移除所有子节点
  5722. */
  5723. removeAll: function () {
  5724. var children = this._children;
  5725. var storage = this.__storage;
  5726. var child;
  5727. var i;
  5728. for (i = 0; i < children.length; i++) {
  5729. child = children[i];
  5730. if (storage) {
  5731. storage.delFromMap(child.id);
  5732. if (child instanceof Group) {
  5733. child.delChildrenFromStorage(storage);
  5734. }
  5735. }
  5736. child.parent = null;
  5737. }
  5738. children.length = 0;
  5739. return this;
  5740. },
  5741. /**
  5742. * 遍历所有子节点
  5743. * @param {Function} cb
  5744. * @param {} context
  5745. */
  5746. eachChild: function (cb, context) {
  5747. var children = this._children;
  5748. for (var i = 0; i < children.length; i++) {
  5749. var child = children[i];
  5750. cb.call(context, child, i);
  5751. }
  5752. return this;
  5753. },
  5754. /**
  5755. * 深度优先遍历所有子孙节点
  5756. * @param {Function} cb
  5757. * @param {} context
  5758. */
  5759. traverse: function (cb, context) {
  5760. for (var i = 0; i < this._children.length; i++) {
  5761. var child = this._children[i];
  5762. cb.call(context, child);
  5763. if (child.type === 'group') {
  5764. child.traverse(cb, context);
  5765. }
  5766. }
  5767. return this;
  5768. },
  5769. addChildrenToStorage: function (storage) {
  5770. for (var i = 0; i < this._children.length; i++) {
  5771. var child = this._children[i];
  5772. storage.addToMap(child);
  5773. if (child instanceof Group) {
  5774. child.addChildrenToStorage(storage);
  5775. }
  5776. }
  5777. },
  5778. delChildrenFromStorage: function (storage) {
  5779. for (var i = 0; i < this._children.length; i++) {
  5780. var child = this._children[i];
  5781. storage.delFromMap(child.id);
  5782. if (child instanceof Group) {
  5783. child.delChildrenFromStorage(storage);
  5784. }
  5785. }
  5786. },
  5787. dirty: function () {
  5788. this.__dirty = true;
  5789. this.__zr && this.__zr.refresh();
  5790. return this;
  5791. },
  5792. /**
  5793. * @return {module:zrender/core/BoundingRect}
  5794. */
  5795. getBoundingRect: function (includeChildren) {
  5796. // TODO Caching
  5797. // TODO Transform
  5798. var rect = null;
  5799. var tmpRect = new BoundingRect(0, 0, 0, 0);
  5800. var children = includeChildren || this._children;
  5801. var tmpMat = [];
  5802. for (var i = 0; i < children.length; i++) {
  5803. var child = children[i];
  5804. if (child.ignore || child.invisible) {
  5805. continue;
  5806. }
  5807. var childRect = child.getBoundingRect();
  5808. var transform = child.getLocalTransform(tmpMat);
  5809. if (transform) {
  5810. tmpRect.copy(childRect);
  5811. tmpRect.applyTransform(transform);
  5812. rect = rect || tmpRect.clone();
  5813. rect.union(tmpRect);
  5814. }
  5815. else {
  5816. rect = rect || childRect.clone();
  5817. rect.union(childRect);
  5818. }
  5819. }
  5820. return rect || tmpRect;
  5821. }
  5822. };
  5823. zrUtil.inherits(Group, Element);
  5824. module.exports = Group;
  5825. /***/ },
  5826. /* 30 */
  5827. /***/ function(module, exports, __webpack_require__) {
  5828. 'use strict';
  5829. /**
  5830. * @module zrender/Element
  5831. */
  5832. var guid = __webpack_require__(31);
  5833. var Eventful = __webpack_require__(32);
  5834. var Transformable = __webpack_require__(33);
  5835. var Animatable = __webpack_require__(34);
  5836. var zrUtil = __webpack_require__(3);
  5837. /**
  5838. * @alias module:zrender/Element
  5839. * @constructor
  5840. * @extends {module:zrender/mixin/Animatable}
  5841. * @extends {module:zrender/mixin/Transformable}
  5842. * @extends {module:zrender/mixin/Eventful}
  5843. */
  5844. var Element = function (opts) {
  5845. Transformable.call(this, opts);
  5846. Eventful.call(this, opts);
  5847. Animatable.call(this, opts);
  5848. /**
  5849. * 画布元素ID
  5850. * @type {string}
  5851. */
  5852. this.id = opts.id || guid();
  5853. };
  5854. Element.prototype = {
  5855. /**
  5856. * 元素类型
  5857. * Element type
  5858. * @type {string}
  5859. */
  5860. type: 'element',
  5861. /**
  5862. * 元素名字
  5863. * Element name
  5864. * @type {string}
  5865. */
  5866. name: '',
  5867. /**
  5868. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  5869. * ZRender instance will be assigned when element is associated with zrender
  5870. * @name module:/zrender/Element#__zr
  5871. * @type {module:zrender/ZRender}
  5872. */
  5873. __zr: null,
  5874. /**
  5875. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  5876. * If ignore drawing and events of the element object
  5877. * @name module:/zrender/Element#ignore
  5878. * @type {boolean}
  5879. * @default false
  5880. */
  5881. ignore: false,
  5882. /**
  5883. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  5884. * 该路径会继承被裁减对象的变换
  5885. * @type {module:zrender/graphic/Path}
  5886. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  5887. * @readOnly
  5888. */
  5889. clipPath: null,
  5890. /**
  5891. * Drift element
  5892. * @param {number} dx dx on the global space
  5893. * @param {number} dy dy on the global space
  5894. */
  5895. drift: function (dx, dy) {
  5896. switch (this.draggable) {
  5897. case 'horizontal':
  5898. dy = 0;
  5899. break;
  5900. case 'vertical':
  5901. dx = 0;
  5902. break;
  5903. }
  5904. var m = this.transform;
  5905. if (!m) {
  5906. m = this.transform = [1, 0, 0, 1, 0, 0];
  5907. }
  5908. m[4] += dx;
  5909. m[5] += dy;
  5910. this.decomposeTransform();
  5911. this.dirty();
  5912. },
  5913. /**
  5914. * Hook before update
  5915. */
  5916. beforeUpdate: function () {},
  5917. /**
  5918. * Hook after update
  5919. */
  5920. afterUpdate: function () {},
  5921. /**
  5922. * Update each frame
  5923. */
  5924. update: function () {
  5925. this.updateTransform();
  5926. },
  5927. /**
  5928. * @param {Function} cb
  5929. * @param {} context
  5930. */
  5931. traverse: function (cb, context) {},
  5932. /**
  5933. * @protected
  5934. */
  5935. attrKV: function (key, value) {
  5936. if (key === 'position' || key === 'scale' || key === 'origin') {
  5937. // Copy the array
  5938. if (value) {
  5939. var target = this[key];
  5940. if (!target) {
  5941. target = this[key] = [];
  5942. }
  5943. target[0] = value[0];
  5944. target[1] = value[1];
  5945. }
  5946. }
  5947. else {
  5948. this[key] = value;
  5949. }
  5950. },
  5951. /**
  5952. * Hide the element
  5953. */
  5954. hide: function () {
  5955. this.ignore = true;
  5956. this.__zr && this.__zr.refresh();
  5957. },
  5958. /**
  5959. * Show the element
  5960. */
  5961. show: function () {
  5962. this.ignore = false;
  5963. this.__zr && this.__zr.refresh();
  5964. },
  5965. /**
  5966. * @param {string|Object} key
  5967. * @param {*} value
  5968. */
  5969. attr: function (key, value) {
  5970. if (typeof key === 'string') {
  5971. this.attrKV(key, value);
  5972. }
  5973. else if (zrUtil.isObject(key)) {
  5974. for (var name in key) {
  5975. if (key.hasOwnProperty(name)) {
  5976. this.attrKV(name, key[name]);
  5977. }
  5978. }
  5979. }
  5980. this.dirty();
  5981. return this;
  5982. },
  5983. /**
  5984. * @param {module:zrender/graphic/Path} clipPath
  5985. */
  5986. setClipPath: function (clipPath) {
  5987. var zr = this.__zr;
  5988. if (zr) {
  5989. clipPath.addSelfToZr(zr);
  5990. }
  5991. // Remove previous clip path
  5992. if (this.clipPath && this.clipPath !== clipPath) {
  5993. this.removeClipPath();
  5994. }
  5995. this.clipPath = clipPath;
  5996. clipPath.__zr = zr;
  5997. clipPath.__clipTarget = this;
  5998. this.dirty();
  5999. },
  6000. /**
  6001. */
  6002. removeClipPath: function () {
  6003. var clipPath = this.clipPath;
  6004. if (clipPath) {
  6005. if (clipPath.__zr) {
  6006. clipPath.removeSelfFromZr(clipPath.__zr);
  6007. }
  6008. clipPath.__zr = null;
  6009. clipPath.__clipTarget = null;
  6010. this.clipPath = null;
  6011. this.dirty();
  6012. }
  6013. },
  6014. /**
  6015. * Add self from zrender instance.
  6016. * Not recursively because it will be invoked when element added to storage.
  6017. * @param {module:zrender/ZRender} zr
  6018. */
  6019. addSelfToZr: function (zr) {
  6020. this.__zr = zr;
  6021. // 添加动画
  6022. var animators = this.animators;
  6023. if (animators) {
  6024. for (var i = 0; i < animators.length; i++) {
  6025. zr.animation.addAnimator(animators[i]);
  6026. }
  6027. }
  6028. if (this.clipPath) {
  6029. this.clipPath.addSelfToZr(zr);
  6030. }
  6031. },
  6032. /**
  6033. * Remove self from zrender instance.
  6034. * Not recursively because it will be invoked when element added to storage.
  6035. * @param {module:zrender/ZRender} zr
  6036. */
  6037. removeSelfFromZr: function (zr) {
  6038. this.__zr = null;
  6039. // 移除动画
  6040. var animators = this.animators;
  6041. if (animators) {
  6042. for (var i = 0; i < animators.length; i++) {
  6043. zr.animation.removeAnimator(animators[i]);
  6044. }
  6045. }
  6046. if (this.clipPath) {
  6047. this.clipPath.removeSelfFromZr(zr);
  6048. }
  6049. }
  6050. };
  6051. zrUtil.mixin(Element, Animatable);
  6052. zrUtil.mixin(Element, Transformable);
  6053. zrUtil.mixin(Element, Eventful);
  6054. module.exports = Element;
  6055. /***/ },
  6056. /* 31 */
  6057. /***/ function(module, exports) {
  6058. /**
  6059. * zrender: 生成唯一id
  6060. *
  6061. * @author errorrik (errorrik@gmail.com)
  6062. */
  6063. var idStart = 0x0907;
  6064. module.exports = function () {
  6065. return 'zr_' + (idStart++);
  6066. };
  6067. /***/ },
  6068. /* 32 */
  6069. /***/ function(module, exports, __webpack_require__) {
  6070. /**
  6071. * 事件扩展
  6072. * @module zrender/mixin/Eventful
  6073. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  6074. * pissang (https://www.github.com/pissang)
  6075. */
  6076. var arrySlice = Array.prototype.slice;
  6077. var zrUtil = __webpack_require__(3);
  6078. var indexOf = zrUtil.indexOf;
  6079. /**
  6080. * 事件分发器
  6081. * @alias module:zrender/mixin/Eventful
  6082. * @constructor
  6083. */
  6084. var Eventful = function () {
  6085. this._$handlers = {};
  6086. };
  6087. Eventful.prototype = {
  6088. constructor: Eventful,
  6089. /**
  6090. * 单次触发绑定,trigger后销毁
  6091. *
  6092. * @param {string} event 事件名
  6093. * @param {Function} handler 响应函数
  6094. * @param {Object} context
  6095. */
  6096. one: function (event, handler, context) {
  6097. var _h = this._$handlers;
  6098. if (!handler || !event) {
  6099. return this;
  6100. }
  6101. if (!_h[event]) {
  6102. _h[event] = [];
  6103. }
  6104. if (indexOf(_h[event], event) >= 0) {
  6105. return this;
  6106. }
  6107. _h[event].push({
  6108. h: handler,
  6109. one: true,
  6110. ctx: context || this
  6111. });
  6112. return this;
  6113. },
  6114. /**
  6115. * 绑定事件
  6116. * @param {string} event 事件名
  6117. * @param {Function} handler 事件处理函数
  6118. * @param {Object} [context]
  6119. */
  6120. on: function (event, handler, context) {
  6121. var _h = this._$handlers;
  6122. if (!handler || !event) {
  6123. return this;
  6124. }
  6125. if (!_h[event]) {
  6126. _h[event] = [];
  6127. }
  6128. _h[event].push({
  6129. h: handler,
  6130. one: false,
  6131. ctx: context || this
  6132. });
  6133. return this;
  6134. },
  6135. /**
  6136. * 是否绑定了事件
  6137. * @param {string} event
  6138. * @return {boolean}
  6139. */
  6140. isSilent: function (event) {
  6141. var _h = this._$handlers;
  6142. return _h[event] && _h[event].length;
  6143. },
  6144. /**
  6145. * 解绑事件
  6146. * @param {string} event 事件名
  6147. * @param {Function} [handler] 事件处理函数
  6148. */
  6149. off: function (event, handler) {
  6150. var _h = this._$handlers;
  6151. if (!event) {
  6152. this._$handlers = {};
  6153. return this;
  6154. }
  6155. if (handler) {
  6156. if (_h[event]) {
  6157. var newList = [];
  6158. for (var i = 0, l = _h[event].length; i < l; i++) {
  6159. if (_h[event][i]['h'] != handler) {
  6160. newList.push(_h[event][i]);
  6161. }
  6162. }
  6163. _h[event] = newList;
  6164. }
  6165. if (_h[event] && _h[event].length === 0) {
  6166. delete _h[event];
  6167. }
  6168. }
  6169. else {
  6170. delete _h[event];
  6171. }
  6172. return this;
  6173. },
  6174. /**
  6175. * 事件分发
  6176. *
  6177. * @param {string} type 事件类型
  6178. */
  6179. trigger: function (type) {
  6180. if (this._$handlers[type]) {
  6181. var args = arguments;
  6182. var argLen = args.length;
  6183. if (argLen > 3) {
  6184. args = arrySlice.call(args, 1);
  6185. }
  6186. var _h = this._$handlers[type];
  6187. var len = _h.length;
  6188. for (var i = 0; i < len;) {
  6189. // Optimize advise from backbone
  6190. switch (argLen) {
  6191. case 1:
  6192. _h[i]['h'].call(_h[i]['ctx']);
  6193. break;
  6194. case 2:
  6195. _h[i]['h'].call(_h[i]['ctx'], args[1]);
  6196. break;
  6197. case 3:
  6198. _h[i]['h'].call(_h[i]['ctx'], args[1], args[2]);
  6199. break;
  6200. default:
  6201. // have more than 2 given arguments
  6202. _h[i]['h'].apply(_h[i]['ctx'], args);
  6203. break;
  6204. }
  6205. if (_h[i]['one']) {
  6206. _h.splice(i, 1);
  6207. len--;
  6208. }
  6209. else {
  6210. i++;
  6211. }
  6212. }
  6213. }
  6214. return this;
  6215. },
  6216. /**
  6217. * 带有context的事件分发, 最后一个参数是事件回调的context
  6218. * @param {string} type 事件类型
  6219. */
  6220. triggerWithContext: function (type) {
  6221. if (this._$handlers[type]) {
  6222. var args = arguments;
  6223. var argLen = args.length;
  6224. if (argLen > 4) {
  6225. args = arrySlice.call(args, 1, args.length - 1);
  6226. }
  6227. var ctx = args[args.length - 1];
  6228. var _h = this._$handlers[type];
  6229. var len = _h.length;
  6230. for (var i = 0; i < len;) {
  6231. // Optimize advise from backbone
  6232. switch (argLen) {
  6233. case 1:
  6234. _h[i]['h'].call(ctx);
  6235. break;
  6236. case 2:
  6237. _h[i]['h'].call(ctx, args[1]);
  6238. break;
  6239. case 3:
  6240. _h[i]['h'].call(ctx, args[1], args[2]);
  6241. break;
  6242. default:
  6243. // have more than 2 given arguments
  6244. _h[i]['h'].apply(ctx, args);
  6245. break;
  6246. }
  6247. if (_h[i]['one']) {
  6248. _h.splice(i, 1);
  6249. len--;
  6250. }
  6251. else {
  6252. i++;
  6253. }
  6254. }
  6255. }
  6256. return this;
  6257. }
  6258. };
  6259. // 对象可以通过 onxxxx 绑定事件
  6260. /**
  6261. * @event module:zrender/mixin/Eventful#onclick
  6262. * @type {Function}
  6263. * @default null
  6264. */
  6265. /**
  6266. * @event module:zrender/mixin/Eventful#onmouseover
  6267. * @type {Function}
  6268. * @default null
  6269. */
  6270. /**
  6271. * @event module:zrender/mixin/Eventful#onmouseout
  6272. * @type {Function}
  6273. * @default null
  6274. */
  6275. /**
  6276. * @event module:zrender/mixin/Eventful#onmousemove
  6277. * @type {Function}
  6278. * @default null
  6279. */
  6280. /**
  6281. * @event module:zrender/mixin/Eventful#onmousewheel
  6282. * @type {Function}
  6283. * @default null
  6284. */
  6285. /**
  6286. * @event module:zrender/mixin/Eventful#onmousedown
  6287. * @type {Function}
  6288. * @default null
  6289. */
  6290. /**
  6291. * @event module:zrender/mixin/Eventful#onmouseup
  6292. * @type {Function}
  6293. * @default null
  6294. */
  6295. /**
  6296. * @event module:zrender/mixin/Eventful#ondragstart
  6297. * @type {Function}
  6298. * @default null
  6299. */
  6300. /**
  6301. * @event module:zrender/mixin/Eventful#ondragend
  6302. * @type {Function}
  6303. * @default null
  6304. */
  6305. /**
  6306. * @event module:zrender/mixin/Eventful#ondragenter
  6307. * @type {Function}
  6308. * @default null
  6309. */
  6310. /**
  6311. * @event module:zrender/mixin/Eventful#ondragleave
  6312. * @type {Function}
  6313. * @default null
  6314. */
  6315. /**
  6316. * @event module:zrender/mixin/Eventful#ondragover
  6317. * @type {Function}
  6318. * @default null
  6319. */
  6320. /**
  6321. * @event module:zrender/mixin/Eventful#ondrop
  6322. * @type {Function}
  6323. * @default null
  6324. */
  6325. module.exports = Eventful;
  6326. /***/ },
  6327. /* 33 */
  6328. /***/ function(module, exports, __webpack_require__) {
  6329. 'use strict';
  6330. /**
  6331. * 提供变换扩展
  6332. * @module zrender/mixin/Transformable
  6333. * @author pissang (https://www.github.com/pissang)
  6334. */
  6335. var matrix = __webpack_require__(17);
  6336. var vector = __webpack_require__(16);
  6337. var mIdentity = matrix.identity;
  6338. var EPSILON = 5e-5;
  6339. function isNotAroundZero(val) {
  6340. return val > EPSILON || val < -EPSILON;
  6341. }
  6342. /**
  6343. * @alias module:zrender/mixin/Transformable
  6344. * @constructor
  6345. */
  6346. var Transformable = function (opts) {
  6347. opts = opts || {};
  6348. // If there are no given position, rotation, scale
  6349. if (!opts.position) {
  6350. /**
  6351. * 平移
  6352. * @type {Array.<number>}
  6353. * @default [0, 0]
  6354. */
  6355. this.position = [0, 0];
  6356. }
  6357. if (opts.rotation == null) {
  6358. /**
  6359. * 旋转
  6360. * @type {Array.<number>}
  6361. * @default 0
  6362. */
  6363. this.rotation = 0;
  6364. }
  6365. if (!opts.scale) {
  6366. /**
  6367. * 缩放
  6368. * @type {Array.<number>}
  6369. * @default [1, 1]
  6370. */
  6371. this.scale = [1, 1];
  6372. }
  6373. /**
  6374. * 旋转和缩放的原点
  6375. * @type {Array.<number>}
  6376. * @default null
  6377. */
  6378. this.origin = this.origin || null;
  6379. };
  6380. var transformableProto = Transformable.prototype;
  6381. transformableProto.transform = null;
  6382. /**
  6383. * 判断是否需要有坐标变换
  6384. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  6385. */
  6386. transformableProto.needLocalTransform = function () {
  6387. return isNotAroundZero(this.rotation)
  6388. || isNotAroundZero(this.position[0])
  6389. || isNotAroundZero(this.position[1])
  6390. || isNotAroundZero(this.scale[0] - 1)
  6391. || isNotAroundZero(this.scale[1] - 1);
  6392. };
  6393. transformableProto.updateTransform = function () {
  6394. var parent = this.parent;
  6395. var parentHasTransform = parent && parent.transform;
  6396. var needLocalTransform = this.needLocalTransform();
  6397. var m = this.transform;
  6398. if (!(needLocalTransform || parentHasTransform)) {
  6399. m && mIdentity(m);
  6400. return;
  6401. }
  6402. m = m || matrix.create();
  6403. if (needLocalTransform) {
  6404. this.getLocalTransform(m);
  6405. }
  6406. else {
  6407. mIdentity(m);
  6408. }
  6409. // 应用父节点变换
  6410. if (parentHasTransform) {
  6411. if (needLocalTransform) {
  6412. matrix.mul(m, parent.transform, m);
  6413. }
  6414. else {
  6415. matrix.copy(m, parent.transform);
  6416. }
  6417. }
  6418. // 保存这个变换矩阵
  6419. this.transform = m;
  6420. this.invTransform = this.invTransform || matrix.create();
  6421. matrix.invert(this.invTransform, m);
  6422. };
  6423. transformableProto.getLocalTransform = function (m) {
  6424. m = m || [];
  6425. mIdentity(m);
  6426. var origin = this.origin;
  6427. var scale = this.scale;
  6428. var rotation = this.rotation;
  6429. var position = this.position;
  6430. if (origin) {
  6431. // Translate to origin
  6432. m[4] -= origin[0];
  6433. m[5] -= origin[1];
  6434. }
  6435. matrix.scale(m, m, scale);
  6436. if (rotation) {
  6437. matrix.rotate(m, m, rotation);
  6438. }
  6439. if (origin) {
  6440. // Translate back from origin
  6441. m[4] += origin[0];
  6442. m[5] += origin[1];
  6443. }
  6444. m[4] += position[0];
  6445. m[5] += position[1];
  6446. return m;
  6447. };
  6448. /**
  6449. * 将自己的transform应用到context上
  6450. * @param {Context2D} ctx
  6451. */
  6452. transformableProto.setTransform = function (ctx) {
  6453. var m = this.transform;
  6454. if (m) {
  6455. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  6456. }
  6457. };
  6458. var tmpTransform = [];
  6459. /**
  6460. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  6461. */
  6462. transformableProto.decomposeTransform = function () {
  6463. if (!this.transform) {
  6464. return;
  6465. }
  6466. var parent = this.parent;
  6467. var m = this.transform;
  6468. if (parent && parent.transform) {
  6469. // Get local transform and decompose them to position, scale, rotation
  6470. matrix.mul(tmpTransform, parent.invTransform, m);
  6471. m = tmpTransform;
  6472. }
  6473. var sx = m[0] * m[0] + m[1] * m[1];
  6474. var sy = m[2] * m[2] + m[3] * m[3];
  6475. var position = this.position;
  6476. var scale = this.scale;
  6477. if (isNotAroundZero(sx - 1)) {
  6478. sx = Math.sqrt(sx);
  6479. }
  6480. if (isNotAroundZero(sy - 1)) {
  6481. sy = Math.sqrt(sy);
  6482. }
  6483. if (m[0] < 0) {
  6484. sx = -sx;
  6485. }
  6486. if (m[3] < 0) {
  6487. sy = -sy;
  6488. }
  6489. position[0] = m[4];
  6490. position[1] = m[5];
  6491. scale[0] = sx;
  6492. scale[1] = sy;
  6493. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  6494. };
  6495. /**
  6496. * Get global scale
  6497. * @return {Array.<number>}
  6498. */
  6499. transformableProto.getGlobalScale = function () {
  6500. var m = this.transform;
  6501. if (!m) {
  6502. return [1, 1];
  6503. }
  6504. var sx = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  6505. var sy = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  6506. if (m[0] < 0) {
  6507. sx = -sx;
  6508. }
  6509. if (m[3] < 0) {
  6510. sy = -sy;
  6511. }
  6512. return [sx, sy];
  6513. };
  6514. /**
  6515. * 变换坐标位置到 shape 的局部坐标空间
  6516. * @method
  6517. * @param {number} x
  6518. * @param {number} y
  6519. * @return {Array.<number>}
  6520. */
  6521. transformableProto.transformCoordToLocal = function (x, y) {
  6522. var v2 = [x, y];
  6523. var invTransform = this.invTransform;
  6524. if (invTransform) {
  6525. vector.applyTransform(v2, v2, invTransform);
  6526. }
  6527. return v2;
  6528. };
  6529. /**
  6530. * 变换局部坐标位置到全局坐标空间
  6531. * @method
  6532. * @param {number} x
  6533. * @param {number} y
  6534. * @return {Array.<number>}
  6535. */
  6536. transformableProto.transformCoordToGlobal = function (x, y) {
  6537. var v2 = [x, y];
  6538. var transform = this.transform;
  6539. if (transform) {
  6540. vector.applyTransform(v2, v2, transform);
  6541. }
  6542. return v2;
  6543. };
  6544. module.exports = Transformable;
  6545. /***/ },
  6546. /* 34 */
  6547. /***/ function(module, exports, __webpack_require__) {
  6548. 'use strict';
  6549. /**
  6550. * @module zrender/mixin/Animatable
  6551. */
  6552. var Animator = __webpack_require__(35);
  6553. var util = __webpack_require__(3);
  6554. var isString = util.isString;
  6555. var isFunction = util.isFunction;
  6556. var isObject = util.isObject;
  6557. var log = __webpack_require__(39);
  6558. /**
  6559. * @alias modue:zrender/mixin/Animatable
  6560. * @constructor
  6561. */
  6562. var Animatable = function () {
  6563. /**
  6564. * @type {Array.<module:zrender/animation/Animator>}
  6565. * @readOnly
  6566. */
  6567. this.animators = [];
  6568. };
  6569. Animatable.prototype = {
  6570. constructor: Animatable,
  6571. /**
  6572. * 动画
  6573. *
  6574. * @param {string} path 需要添加动画的属性获取路径,可以通过a.b.c来获取深层的属性
  6575. * @param {boolean} [loop] 动画是否循环
  6576. * @return {module:zrender/animation/Animator}
  6577. * @example:
  6578. * el.animate('style', false)
  6579. * .when(1000, {x: 10} )
  6580. * .done(function(){ // Animation done })
  6581. * .start()
  6582. */
  6583. animate: function (path, loop) {
  6584. var target;
  6585. var animatingShape = false;
  6586. var el = this;
  6587. var zr = this.__zr;
  6588. if (path) {
  6589. var pathSplitted = path.split('.');
  6590. var prop = el;
  6591. // If animating shape
  6592. animatingShape = pathSplitted[0] === 'shape';
  6593. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  6594. if (!prop) {
  6595. continue;
  6596. }
  6597. prop = prop[pathSplitted[i]];
  6598. }
  6599. if (prop) {
  6600. target = prop;
  6601. }
  6602. }
  6603. else {
  6604. target = el;
  6605. }
  6606. if (!target) {
  6607. log(
  6608. 'Property "'
  6609. + path
  6610. + '" is not existed in element '
  6611. + el.id
  6612. );
  6613. return;
  6614. }
  6615. var animators = el.animators;
  6616. var animator = new Animator(target, loop);
  6617. animator.during(function (target) {
  6618. el.dirty(animatingShape);
  6619. })
  6620. .done(function () {
  6621. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  6622. animators.splice(util.indexOf(animators, animator), 1);
  6623. });
  6624. animators.push(animator);
  6625. // If animate after added to the zrender
  6626. if (zr) {
  6627. zr.animation.addAnimator(animator);
  6628. }
  6629. return animator;
  6630. },
  6631. /**
  6632. * 停止动画
  6633. * @param {boolean} forwardToLast If move to last frame before stop
  6634. */
  6635. stopAnimation: function (forwardToLast) {
  6636. var animators = this.animators;
  6637. var len = animators.length;
  6638. for (var i = 0; i < len; i++) {
  6639. animators[i].stop(forwardToLast);
  6640. }
  6641. animators.length = 0;
  6642. return this;
  6643. },
  6644. /**
  6645. * @param {Object} target
  6646. * @param {number} [time=500] Time in ms
  6647. * @param {string} [easing='linear']
  6648. * @param {number} [delay=0]
  6649. * @param {Function} [callback]
  6650. *
  6651. * @example
  6652. * // Animate position
  6653. * el.animateTo({
  6654. * position: [10, 10]
  6655. * }, function () { // done })
  6656. *
  6657. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  6658. * el.animateTo({
  6659. * shape: {
  6660. * width: 500
  6661. * },
  6662. * style: {
  6663. * fill: 'red'
  6664. * }
  6665. * position: [10, 10]
  6666. * }, 100, 100, 'cubicOut', function () { // done })
  6667. */
  6668. // TODO Return animation key
  6669. animateTo: function (target, time, delay, easing, callback) {
  6670. // animateTo(target, time, easing, callback);
  6671. if (isString(delay)) {
  6672. callback = easing;
  6673. easing = delay;
  6674. delay = 0;
  6675. }
  6676. // animateTo(target, time, delay, callback);
  6677. else if (isFunction(easing)) {
  6678. callback = easing;
  6679. easing = 'linear';
  6680. delay = 0;
  6681. }
  6682. // animateTo(target, time, callback);
  6683. else if (isFunction(delay)) {
  6684. callback = delay;
  6685. delay = 0;
  6686. }
  6687. // animateTo(target, callback)
  6688. else if (isFunction(time)) {
  6689. callback = time;
  6690. time = 500;
  6691. }
  6692. // animateTo(target)
  6693. else if (!time) {
  6694. time = 500;
  6695. }
  6696. // Stop all previous animations
  6697. this.stopAnimation();
  6698. this._animateToShallow('', this, target, time, delay, easing, callback);
  6699. // Animators may be removed immediately after start
  6700. // if there is nothing to animate
  6701. var animators = this.animators.slice();
  6702. var count = animators.length;
  6703. function done() {
  6704. count--;
  6705. if (!count) {
  6706. callback && callback();
  6707. }
  6708. }
  6709. // No animators. This should be checked before animators[i].start(),
  6710. // because 'done' may be executed immediately if no need to animate.
  6711. if (!count) {
  6712. callback && callback();
  6713. }
  6714. // Start after all animators created
  6715. // Incase any animator is done immediately when all animation properties are not changed
  6716. for (var i = 0; i < animators.length; i++) {
  6717. animators[i]
  6718. .done(done)
  6719. .start(easing);
  6720. }
  6721. },
  6722. /**
  6723. * @private
  6724. * @param {string} path=''
  6725. * @param {Object} source=this
  6726. * @param {Object} target
  6727. * @param {number} [time=500]
  6728. * @param {number} [delay=0]
  6729. *
  6730. * @example
  6731. * // Animate position
  6732. * el._animateToShallow({
  6733. * position: [10, 10]
  6734. * })
  6735. *
  6736. * // Animate shape, style and position in 100ms, delayed 100ms
  6737. * el._animateToShallow({
  6738. * shape: {
  6739. * width: 500
  6740. * },
  6741. * style: {
  6742. * fill: 'red'
  6743. * }
  6744. * position: [10, 10]
  6745. * }, 100, 100)
  6746. */
  6747. _animateToShallow: function (path, source, target, time, delay) {
  6748. var objShallow = {};
  6749. var propertyCount = 0;
  6750. for (var name in target) {
  6751. if (source[name] != null) {
  6752. if (isObject(target[name]) && !util.isArrayLike(target[name])) {
  6753. this._animateToShallow(
  6754. path ? path + '.' + name : name,
  6755. source[name],
  6756. target[name],
  6757. time,
  6758. delay
  6759. );
  6760. }
  6761. else {
  6762. objShallow[name] = target[name];
  6763. propertyCount++;
  6764. }
  6765. }
  6766. else if (target[name] != null) {
  6767. // Attr directly if not has property
  6768. // FIXME, if some property not needed for element ?
  6769. if (!path) {
  6770. this.attr(name, target[name]);
  6771. }
  6772. else { // Shape or style
  6773. var props = {};
  6774. props[path] = {};
  6775. props[path][name] = target[name];
  6776. this.attr(props);
  6777. }
  6778. }
  6779. }
  6780. if (propertyCount > 0) {
  6781. this.animate(path, false)
  6782. .when(time == null ? 500 : time, objShallow)
  6783. .delay(delay || 0);
  6784. }
  6785. return this;
  6786. }
  6787. };
  6788. module.exports = Animatable;
  6789. /***/ },
  6790. /* 35 */
  6791. /***/ function(module, exports, __webpack_require__) {
  6792. /**
  6793. * @module echarts/animation/Animator
  6794. */
  6795. var Clip = __webpack_require__(36);
  6796. var color = __webpack_require__(38);
  6797. var util = __webpack_require__(3);
  6798. var isArrayLike = util.isArrayLike;
  6799. var arraySlice = Array.prototype.slice;
  6800. function defaultGetter(target, key) {
  6801. return target[key];
  6802. }
  6803. function defaultSetter(target, key, value) {
  6804. target[key] = value;
  6805. }
  6806. /**
  6807. * @param {number} p0
  6808. * @param {number} p1
  6809. * @param {number} percent
  6810. * @return {number}
  6811. */
  6812. function interpolateNumber(p0, p1, percent) {
  6813. return (p1 - p0) * percent + p0;
  6814. }
  6815. /**
  6816. * @param {string} p0
  6817. * @param {string} p1
  6818. * @param {number} percent
  6819. * @return {string}
  6820. */
  6821. function interpolateString(p0, p1, percent) {
  6822. return percent > 0.5 ? p1 : p0;
  6823. }
  6824. /**
  6825. * @param {Array} p0
  6826. * @param {Array} p1
  6827. * @param {number} percent
  6828. * @param {Array} out
  6829. * @param {number} arrDim
  6830. */
  6831. function interpolateArray(p0, p1, percent, out, arrDim) {
  6832. var len = p0.length;
  6833. if (arrDim == 1) {
  6834. for (var i = 0; i < len; i++) {
  6835. out[i] = interpolateNumber(p0[i], p1[i], percent);
  6836. }
  6837. }
  6838. else {
  6839. var len2 = p0[0].length;
  6840. for (var i = 0; i < len; i++) {
  6841. for (var j = 0; j < len2; j++) {
  6842. out[i][j] = interpolateNumber(
  6843. p0[i][j], p1[i][j], percent
  6844. );
  6845. }
  6846. }
  6847. }
  6848. }
  6849. // arr0 is source array, arr1 is target array.
  6850. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  6851. function fillArr(arr0, arr1, arrDim) {
  6852. var arr0Len = arr0.length;
  6853. var arr1Len = arr1.length;
  6854. if (arr0Len !== arr1Len) {
  6855. // FIXME Not work for TypedArray
  6856. var isPreviousLarger = arr0Len > arr1Len;
  6857. if (isPreviousLarger) {
  6858. // Cut the previous
  6859. arr0.length = arr1Len;
  6860. }
  6861. else {
  6862. // Fill the previous
  6863. for (var i = arr0Len; i < arr1Len; i++) {
  6864. arr0.push(
  6865. arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i])
  6866. );
  6867. }
  6868. }
  6869. }
  6870. // Handling NaN value
  6871. var len2 = arr0[0] && arr0[0].length;
  6872. for (var i = 0; i < arr0.length; i++) {
  6873. if (arrDim === 1) {
  6874. if (isNaN(arr0[i])) {
  6875. arr0[i] = arr1[i];
  6876. }
  6877. }
  6878. else {
  6879. for (var j = 0; j < len2; j++) {
  6880. if (isNaN(arr0[i][j])) {
  6881. arr0[i][j] = arr1[i][j];
  6882. }
  6883. }
  6884. }
  6885. }
  6886. }
  6887. /**
  6888. * @param {Array} arr0
  6889. * @param {Array} arr1
  6890. * @param {number} arrDim
  6891. * @return {boolean}
  6892. */
  6893. function isArraySame(arr0, arr1, arrDim) {
  6894. if (arr0 === arr1) {
  6895. return true;
  6896. }
  6897. var len = arr0.length;
  6898. if (len !== arr1.length) {
  6899. return false;
  6900. }
  6901. if (arrDim === 1) {
  6902. for (var i = 0; i < len; i++) {
  6903. if (arr0[i] !== arr1[i]) {
  6904. return false;
  6905. }
  6906. }
  6907. }
  6908. else {
  6909. var len2 = arr0[0].length;
  6910. for (var i = 0; i < len; i++) {
  6911. for (var j = 0; j < len2; j++) {
  6912. if (arr0[i][j] !== arr1[i][j]) {
  6913. return false;
  6914. }
  6915. }
  6916. }
  6917. }
  6918. return true;
  6919. }
  6920. /**
  6921. * Catmull Rom interpolate array
  6922. * @param {Array} p0
  6923. * @param {Array} p1
  6924. * @param {Array} p2
  6925. * @param {Array} p3
  6926. * @param {number} t
  6927. * @param {number} t2
  6928. * @param {number} t3
  6929. * @param {Array} out
  6930. * @param {number} arrDim
  6931. */
  6932. function catmullRomInterpolateArray(
  6933. p0, p1, p2, p3, t, t2, t3, out, arrDim
  6934. ) {
  6935. var len = p0.length;
  6936. if (arrDim == 1) {
  6937. for (var i = 0; i < len; i++) {
  6938. out[i] = catmullRomInterpolate(
  6939. p0[i], p1[i], p2[i], p3[i], t, t2, t3
  6940. );
  6941. }
  6942. }
  6943. else {
  6944. var len2 = p0[0].length;
  6945. for (var i = 0; i < len; i++) {
  6946. for (var j = 0; j < len2; j++) {
  6947. out[i][j] = catmullRomInterpolate(
  6948. p0[i][j], p1[i][j], p2[i][j], p3[i][j],
  6949. t, t2, t3
  6950. );
  6951. }
  6952. }
  6953. }
  6954. }
  6955. /**
  6956. * Catmull Rom interpolate number
  6957. * @param {number} p0
  6958. * @param {number} p1
  6959. * @param {number} p2
  6960. * @param {number} p3
  6961. * @param {number} t
  6962. * @param {number} t2
  6963. * @param {number} t3
  6964. * @return {number}
  6965. */
  6966. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  6967. var v0 = (p2 - p0) * 0.5;
  6968. var v1 = (p3 - p1) * 0.5;
  6969. return (2 * (p1 - p2) + v0 + v1) * t3
  6970. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  6971. + v0 * t + p1;
  6972. }
  6973. function cloneValue(value) {
  6974. if (isArrayLike(value)) {
  6975. var len = value.length;
  6976. if (isArrayLike(value[0])) {
  6977. var ret = [];
  6978. for (var i = 0; i < len; i++) {
  6979. ret.push(arraySlice.call(value[i]));
  6980. }
  6981. return ret;
  6982. }
  6983. return arraySlice.call(value);
  6984. }
  6985. return value;
  6986. }
  6987. function rgba2String(rgba) {
  6988. rgba[0] = Math.floor(rgba[0]);
  6989. rgba[1] = Math.floor(rgba[1]);
  6990. rgba[2] = Math.floor(rgba[2]);
  6991. return 'rgba(' + rgba.join(',') + ')';
  6992. }
  6993. function createTrackClip (animator, easing, oneTrackDone, keyframes, propName) {
  6994. var getter = animator._getter;
  6995. var setter = animator._setter;
  6996. var useSpline = easing === 'spline';
  6997. var trackLen = keyframes.length;
  6998. if (!trackLen) {
  6999. return;
  7000. }
  7001. // Guess data type
  7002. var firstVal = keyframes[0].value;
  7003. var isValueArray = isArrayLike(firstVal);
  7004. var isValueColor = false;
  7005. var isValueString = false;
  7006. // For vertices morphing
  7007. var arrDim = (
  7008. isValueArray
  7009. && isArrayLike(firstVal[0])
  7010. )
  7011. ? 2 : 1;
  7012. var trackMaxTime;
  7013. // Sort keyframe as ascending
  7014. keyframes.sort(function(a, b) {
  7015. return a.time - b.time;
  7016. });
  7017. trackMaxTime = keyframes[trackLen - 1].time;
  7018. // Percents of each keyframe
  7019. var kfPercents = [];
  7020. // Value of each keyframe
  7021. var kfValues = [];
  7022. var prevValue = keyframes[0].value;
  7023. var isAllValueEqual = true;
  7024. for (var i = 0; i < trackLen; i++) {
  7025. kfPercents.push(keyframes[i].time / trackMaxTime);
  7026. // Assume value is a color when it is a string
  7027. var value = keyframes[i].value;
  7028. // Check if value is equal, deep check if value is array
  7029. if (!((isValueArray && isArraySame(value, prevValue, arrDim))
  7030. || (!isValueArray && value === prevValue))) {
  7031. isAllValueEqual = false;
  7032. }
  7033. prevValue = value;
  7034. // Try converting a string to a color array
  7035. if (typeof value == 'string') {
  7036. var colorArray = color.parse(value);
  7037. if (colorArray) {
  7038. value = colorArray;
  7039. isValueColor = true;
  7040. }
  7041. else {
  7042. isValueString = true;
  7043. }
  7044. }
  7045. kfValues.push(value);
  7046. }
  7047. if (isAllValueEqual) {
  7048. return;
  7049. }
  7050. var lastValue = kfValues[trackLen - 1];
  7051. // Polyfill array and NaN value
  7052. for (var i = 0; i < trackLen - 1; i++) {
  7053. if (isValueArray) {
  7054. fillArr(kfValues[i], lastValue, arrDim);
  7055. }
  7056. else {
  7057. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  7058. kfValues[i] = lastValue;
  7059. }
  7060. }
  7061. }
  7062. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim);
  7063. // Cache the key of last frame to speed up when
  7064. // animation playback is sequency
  7065. var lastFrame = 0;
  7066. var lastFramePercent = 0;
  7067. var start;
  7068. var w;
  7069. var p0;
  7070. var p1;
  7071. var p2;
  7072. var p3;
  7073. if (isValueColor) {
  7074. var rgba = [0, 0, 0, 0];
  7075. }
  7076. var onframe = function (target, percent) {
  7077. // Find the range keyframes
  7078. // kf1-----kf2---------current--------kf3
  7079. // find kf2 and kf3 and do interpolation
  7080. var frame;
  7081. if (percent < lastFramePercent) {
  7082. // Start from next key
  7083. start = Math.min(lastFrame + 1, trackLen - 1);
  7084. for (frame = start; frame >= 0; frame--) {
  7085. if (kfPercents[frame] <= percent) {
  7086. break;
  7087. }
  7088. }
  7089. frame = Math.min(frame, trackLen - 2);
  7090. }
  7091. else {
  7092. for (frame = lastFrame; frame < trackLen; frame++) {
  7093. if (kfPercents[frame] > percent) {
  7094. break;
  7095. }
  7096. }
  7097. frame = Math.min(frame - 1, trackLen - 2);
  7098. }
  7099. lastFrame = frame;
  7100. lastFramePercent = percent;
  7101. var range = (kfPercents[frame + 1] - kfPercents[frame]);
  7102. if (range === 0) {
  7103. return;
  7104. }
  7105. else {
  7106. w = (percent - kfPercents[frame]) / range;
  7107. }
  7108. if (useSpline) {
  7109. p1 = kfValues[frame];
  7110. p0 = kfValues[frame === 0 ? frame : frame - 1];
  7111. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  7112. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  7113. if (isValueArray) {
  7114. catmullRomInterpolateArray(
  7115. p0, p1, p2, p3, w, w * w, w * w * w,
  7116. getter(target, propName),
  7117. arrDim
  7118. );
  7119. }
  7120. else {
  7121. var value;
  7122. if (isValueColor) {
  7123. value = catmullRomInterpolateArray(
  7124. p0, p1, p2, p3, w, w * w, w * w * w,
  7125. rgba, 1
  7126. );
  7127. value = rgba2String(rgba);
  7128. }
  7129. else if (isValueString) {
  7130. // String is step(0.5)
  7131. return interpolateString(p1, p2, w);
  7132. }
  7133. else {
  7134. value = catmullRomInterpolate(
  7135. p0, p1, p2, p3, w, w * w, w * w * w
  7136. );
  7137. }
  7138. setter(
  7139. target,
  7140. propName,
  7141. value
  7142. );
  7143. }
  7144. }
  7145. else {
  7146. if (isValueArray) {
  7147. interpolateArray(
  7148. kfValues[frame], kfValues[frame + 1], w,
  7149. getter(target, propName),
  7150. arrDim
  7151. );
  7152. }
  7153. else {
  7154. var value;
  7155. if (isValueColor) {
  7156. interpolateArray(
  7157. kfValues[frame], kfValues[frame + 1], w,
  7158. rgba, 1
  7159. );
  7160. value = rgba2String(rgba);
  7161. }
  7162. else if (isValueString) {
  7163. // String is step(0.5)
  7164. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  7165. }
  7166. else {
  7167. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  7168. }
  7169. setter(
  7170. target,
  7171. propName,
  7172. value
  7173. );
  7174. }
  7175. }
  7176. };
  7177. var clip = new Clip({
  7178. target: animator._target,
  7179. life: trackMaxTime,
  7180. loop: animator._loop,
  7181. delay: animator._delay,
  7182. onframe: onframe,
  7183. ondestroy: oneTrackDone
  7184. });
  7185. if (easing && easing !== 'spline') {
  7186. clip.easing = easing;
  7187. }
  7188. return clip;
  7189. }
  7190. /**
  7191. * @alias module:zrender/animation/Animator
  7192. * @constructor
  7193. * @param {Object} target
  7194. * @param {boolean} loop
  7195. * @param {Function} getter
  7196. * @param {Function} setter
  7197. */
  7198. var Animator = function(target, loop, getter, setter) {
  7199. this._tracks = {};
  7200. this._target = target;
  7201. this._loop = loop || false;
  7202. this._getter = getter || defaultGetter;
  7203. this._setter = setter || defaultSetter;
  7204. this._clipCount = 0;
  7205. this._delay = 0;
  7206. this._doneList = [];
  7207. this._onframeList = [];
  7208. this._clipList = [];
  7209. };
  7210. Animator.prototype = {
  7211. /**
  7212. * 设置动画关键帧
  7213. * @param {number} time 关键帧时间,单位是ms
  7214. * @param {Object} props 关键帧的属性值,key-value表示
  7215. * @return {module:zrender/animation/Animator}
  7216. */
  7217. when: function(time /* ms */, props) {
  7218. var tracks = this._tracks;
  7219. for (var propName in props) {
  7220. if (!tracks[propName]) {
  7221. tracks[propName] = [];
  7222. // Invalid value
  7223. var value = this._getter(this._target, propName);
  7224. if (value == null) {
  7225. // zrLog('Invalid property ' + propName);
  7226. continue;
  7227. }
  7228. // If time is 0
  7229. // Then props is given initialize value
  7230. // Else
  7231. // Initialize value from current prop value
  7232. if (time !== 0) {
  7233. tracks[propName].push({
  7234. time: 0,
  7235. value: cloneValue(value)
  7236. });
  7237. }
  7238. }
  7239. tracks[propName].push({
  7240. time: time,
  7241. value: props[propName]
  7242. });
  7243. }
  7244. return this;
  7245. },
  7246. /**
  7247. * 添加动画每一帧的回调函数
  7248. * @param {Function} callback
  7249. * @return {module:zrender/animation/Animator}
  7250. */
  7251. during: function (callback) {
  7252. this._onframeList.push(callback);
  7253. return this;
  7254. },
  7255. _doneCallback: function () {
  7256. // Clear all tracks
  7257. this._tracks = {};
  7258. // Clear all clips
  7259. this._clipList.length = 0;
  7260. var doneList = this._doneList;
  7261. var len = doneList.length;
  7262. for (var i = 0; i < len; i++) {
  7263. doneList[i].call(this);
  7264. }
  7265. },
  7266. /**
  7267. * 开始执行动画
  7268. * @param {string|Function} easing
  7269. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  7270. * @return {module:zrender/animation/Animator}
  7271. */
  7272. start: function (easing) {
  7273. var self = this;
  7274. var clipCount = 0;
  7275. var oneTrackDone = function() {
  7276. clipCount--;
  7277. if (!clipCount) {
  7278. self._doneCallback();
  7279. }
  7280. };
  7281. var lastClip;
  7282. for (var propName in this._tracks) {
  7283. var clip = createTrackClip(
  7284. this, easing, oneTrackDone,
  7285. this._tracks[propName], propName
  7286. );
  7287. if (clip) {
  7288. this._clipList.push(clip);
  7289. clipCount++;
  7290. // If start after added to animation
  7291. if (this.animation) {
  7292. this.animation.addClip(clip);
  7293. }
  7294. lastClip = clip;
  7295. }
  7296. }
  7297. // Add during callback on the last clip
  7298. if (lastClip) {
  7299. var oldOnFrame = lastClip.onframe;
  7300. lastClip.onframe = function (target, percent) {
  7301. oldOnFrame(target, percent);
  7302. for (var i = 0; i < self._onframeList.length; i++) {
  7303. self._onframeList[i](target, percent);
  7304. }
  7305. };
  7306. }
  7307. if (!clipCount) {
  7308. this._doneCallback();
  7309. }
  7310. return this;
  7311. },
  7312. /**
  7313. * 停止动画
  7314. * @param {boolean} forwardToLast If move to last frame before stop
  7315. */
  7316. stop: function (forwardToLast) {
  7317. var clipList = this._clipList;
  7318. var animation = this.animation;
  7319. for (var i = 0; i < clipList.length; i++) {
  7320. var clip = clipList[i];
  7321. if (forwardToLast) {
  7322. // Move to last frame before stop
  7323. clip.onframe(this._target, 1);
  7324. }
  7325. animation && animation.removeClip(clip);
  7326. }
  7327. clipList.length = 0;
  7328. },
  7329. /**
  7330. * 设置动画延迟开始的时间
  7331. * @param {number} time 单位ms
  7332. * @return {module:zrender/animation/Animator}
  7333. */
  7334. delay: function (time) {
  7335. this._delay = time;
  7336. return this;
  7337. },
  7338. /**
  7339. * 添加动画结束的回调
  7340. * @param {Function} cb
  7341. * @return {module:zrender/animation/Animator}
  7342. */
  7343. done: function(cb) {
  7344. if (cb) {
  7345. this._doneList.push(cb);
  7346. }
  7347. return this;
  7348. },
  7349. /**
  7350. * @return {Array.<module:zrender/animation/Clip>}
  7351. */
  7352. getClips: function () {
  7353. return this._clipList;
  7354. }
  7355. };
  7356. module.exports = Animator;
  7357. /***/ },
  7358. /* 36 */
  7359. /***/ function(module, exports, __webpack_require__) {
  7360. /**
  7361. * 动画主控制器
  7362. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  7363. * @config life(1000) 动画时长
  7364. * @config delay(0) 动画延迟时间
  7365. * @config loop(true)
  7366. * @config gap(0) 循环的间隔时间
  7367. * @config onframe
  7368. * @config easing(optional)
  7369. * @config ondestroy(optional)
  7370. * @config onrestart(optional)
  7371. *
  7372. * TODO pause
  7373. */
  7374. var easingFuncs = __webpack_require__(37);
  7375. function Clip(options) {
  7376. this._target = options.target;
  7377. // 生命周期
  7378. this._life = options.life || 1000;
  7379. // 延时
  7380. this._delay = options.delay || 0;
  7381. // 开始时间
  7382. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  7383. this._initialized = false;
  7384. // 是否循环
  7385. this.loop = options.loop == null ? false : options.loop;
  7386. this.gap = options.gap || 0;
  7387. this.easing = options.easing || 'Linear';
  7388. this.onframe = options.onframe;
  7389. this.ondestroy = options.ondestroy;
  7390. this.onrestart = options.onrestart;
  7391. }
  7392. Clip.prototype = {
  7393. constructor: Clip,
  7394. step: function (time) {
  7395. // Set startTime on first step, or _startTime may has milleseconds different between clips
  7396. // PENDING
  7397. if (!this._initialized) {
  7398. this._startTime = new Date().getTime() + this._delay;
  7399. this._initialized = true;
  7400. }
  7401. var percent = (time - this._startTime) / this._life;
  7402. // 还没开始
  7403. if (percent < 0) {
  7404. return;
  7405. }
  7406. percent = Math.min(percent, 1);
  7407. var easing = this.easing;
  7408. var easingFunc = typeof easing == 'string' ? easingFuncs[easing] : easing;
  7409. var schedule = typeof easingFunc === 'function'
  7410. ? easingFunc(percent)
  7411. : percent;
  7412. this.fire('frame', schedule);
  7413. // 结束
  7414. if (percent == 1) {
  7415. if (this.loop) {
  7416. this.restart();
  7417. // 重新开始周期
  7418. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  7419. return 'restart';
  7420. }
  7421. // 动画完成将这个控制器标识为待删除
  7422. // 在Animation.update中进行批量删除
  7423. this._needsRemove = true;
  7424. return 'destroy';
  7425. }
  7426. return null;
  7427. },
  7428. restart: function() {
  7429. var time = new Date().getTime();
  7430. var remainder = (time - this._startTime) % this._life;
  7431. this._startTime = new Date().getTime() - remainder + this.gap;
  7432. this._needsRemove = false;
  7433. },
  7434. fire: function(eventType, arg) {
  7435. eventType = 'on' + eventType;
  7436. if (this[eventType]) {
  7437. this[eventType](this._target, arg);
  7438. }
  7439. }
  7440. };
  7441. module.exports = Clip;
  7442. /***/ },
  7443. /* 37 */
  7444. /***/ function(module, exports) {
  7445. /**
  7446. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  7447. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  7448. * @exports zrender/animation/easing
  7449. */
  7450. var easing = {
  7451. /**
  7452. * @param {number} k
  7453. * @return {number}
  7454. */
  7455. linear: function (k) {
  7456. return k;
  7457. },
  7458. /**
  7459. * @param {number} k
  7460. * @return {number}
  7461. */
  7462. quadraticIn: function (k) {
  7463. return k * k;
  7464. },
  7465. /**
  7466. * @param {number} k
  7467. * @return {number}
  7468. */
  7469. quadraticOut: function (k) {
  7470. return k * (2 - k);
  7471. },
  7472. /**
  7473. * @param {number} k
  7474. * @return {number}
  7475. */
  7476. quadraticInOut: function (k) {
  7477. if ((k *= 2) < 1) {
  7478. return 0.5 * k * k;
  7479. }
  7480. return -0.5 * (--k * (k - 2) - 1);
  7481. },
  7482. // 三次方的缓动(t^3)
  7483. /**
  7484. * @param {number} k
  7485. * @return {number}
  7486. */
  7487. cubicIn: function (k) {
  7488. return k * k * k;
  7489. },
  7490. /**
  7491. * @param {number} k
  7492. * @return {number}
  7493. */
  7494. cubicOut: function (k) {
  7495. return --k * k * k + 1;
  7496. },
  7497. /**
  7498. * @param {number} k
  7499. * @return {number}
  7500. */
  7501. cubicInOut: function (k) {
  7502. if ((k *= 2) < 1) {
  7503. return 0.5 * k * k * k;
  7504. }
  7505. return 0.5 * ((k -= 2) * k * k + 2);
  7506. },
  7507. // 四次方的缓动(t^4)
  7508. /**
  7509. * @param {number} k
  7510. * @return {number}
  7511. */
  7512. quarticIn: function (k) {
  7513. return k * k * k * k;
  7514. },
  7515. /**
  7516. * @param {number} k
  7517. * @return {number}
  7518. */
  7519. quarticOut: function (k) {
  7520. return 1 - (--k * k * k * k);
  7521. },
  7522. /**
  7523. * @param {number} k
  7524. * @return {number}
  7525. */
  7526. quarticInOut: function (k) {
  7527. if ((k *= 2) < 1) {
  7528. return 0.5 * k * k * k * k;
  7529. }
  7530. return -0.5 * ((k -= 2) * k * k * k - 2);
  7531. },
  7532. // 五次方的缓动(t^5)
  7533. /**
  7534. * @param {number} k
  7535. * @return {number}
  7536. */
  7537. quinticIn: function (k) {
  7538. return k * k * k * k * k;
  7539. },
  7540. /**
  7541. * @param {number} k
  7542. * @return {number}
  7543. */
  7544. quinticOut: function (k) {
  7545. return --k * k * k * k * k + 1;
  7546. },
  7547. /**
  7548. * @param {number} k
  7549. * @return {number}
  7550. */
  7551. quinticInOut: function (k) {
  7552. if ((k *= 2) < 1) {
  7553. return 0.5 * k * k * k * k * k;
  7554. }
  7555. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  7556. },
  7557. // 正弦曲线的缓动(sin(t))
  7558. /**
  7559. * @param {number} k
  7560. * @return {number}
  7561. */
  7562. sinusoidalIn: function (k) {
  7563. return 1 - Math.cos(k * Math.PI / 2);
  7564. },
  7565. /**
  7566. * @param {number} k
  7567. * @return {number}
  7568. */
  7569. sinusoidalOut: function (k) {
  7570. return Math.sin(k * Math.PI / 2);
  7571. },
  7572. /**
  7573. * @param {number} k
  7574. * @return {number}
  7575. */
  7576. sinusoidalInOut: function (k) {
  7577. return 0.5 * (1 - Math.cos(Math.PI * k));
  7578. },
  7579. // 指数曲线的缓动(2^t)
  7580. /**
  7581. * @param {number} k
  7582. * @return {number}
  7583. */
  7584. exponentialIn: function (k) {
  7585. return k === 0 ? 0 : Math.pow(1024, k - 1);
  7586. },
  7587. /**
  7588. * @param {number} k
  7589. * @return {number}
  7590. */
  7591. exponentialOut: function (k) {
  7592. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  7593. },
  7594. /**
  7595. * @param {number} k
  7596. * @return {number}
  7597. */
  7598. exponentialInOut: function (k) {
  7599. if (k === 0) {
  7600. return 0;
  7601. }
  7602. if (k === 1) {
  7603. return 1;
  7604. }
  7605. if ((k *= 2) < 1) {
  7606. return 0.5 * Math.pow(1024, k - 1);
  7607. }
  7608. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  7609. },
  7610. // 圆形曲线的缓动(sqrt(1-t^2))
  7611. /**
  7612. * @param {number} k
  7613. * @return {number}
  7614. */
  7615. circularIn: function (k) {
  7616. return 1 - Math.sqrt(1 - k * k);
  7617. },
  7618. /**
  7619. * @param {number} k
  7620. * @return {number}
  7621. */
  7622. circularOut: function (k) {
  7623. return Math.sqrt(1 - (--k * k));
  7624. },
  7625. /**
  7626. * @param {number} k
  7627. * @return {number}
  7628. */
  7629. circularInOut: function (k) {
  7630. if ((k *= 2) < 1) {
  7631. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  7632. }
  7633. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  7634. },
  7635. // 创建类似于弹簧在停止前来回振荡的动画
  7636. /**
  7637. * @param {number} k
  7638. * @return {number}
  7639. */
  7640. elasticIn: function (k) {
  7641. var s;
  7642. var a = 0.1;
  7643. var p = 0.4;
  7644. if (k === 0) {
  7645. return 0;
  7646. }
  7647. if (k === 1) {
  7648. return 1;
  7649. }
  7650. if (!a || a < 1) {
  7651. a = 1; s = p / 4;
  7652. }
  7653. else {
  7654. s = p * Math.asin(1 / a) / (2 * Math.PI);
  7655. }
  7656. return -(a * Math.pow(2, 10 * (k -= 1)) *
  7657. Math.sin((k - s) * (2 * Math.PI) / p));
  7658. },
  7659. /**
  7660. * @param {number} k
  7661. * @return {number}
  7662. */
  7663. elasticOut: function (k) {
  7664. var s;
  7665. var a = 0.1;
  7666. var p = 0.4;
  7667. if (k === 0) {
  7668. return 0;
  7669. }
  7670. if (k === 1) {
  7671. return 1;
  7672. }
  7673. if (!a || a < 1) {
  7674. a = 1; s = p / 4;
  7675. }
  7676. else {
  7677. s = p * Math.asin(1 / a) / (2 * Math.PI);
  7678. }
  7679. return (a * Math.pow(2, -10 * k) *
  7680. Math.sin((k - s) * (2 * Math.PI) / p) + 1);
  7681. },
  7682. /**
  7683. * @param {number} k
  7684. * @return {number}
  7685. */
  7686. elasticInOut: function (k) {
  7687. var s;
  7688. var a = 0.1;
  7689. var p = 0.4;
  7690. if (k === 0) {
  7691. return 0;
  7692. }
  7693. if (k === 1) {
  7694. return 1;
  7695. }
  7696. if (!a || a < 1) {
  7697. a = 1; s = p / 4;
  7698. }
  7699. else {
  7700. s = p * Math.asin(1 / a) / (2 * Math.PI);
  7701. }
  7702. if ((k *= 2) < 1) {
  7703. return -0.5 * (a * Math.pow(2, 10 * (k -= 1))
  7704. * Math.sin((k - s) * (2 * Math.PI) / p));
  7705. }
  7706. return a * Math.pow(2, -10 * (k -= 1))
  7707. * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  7708. },
  7709. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  7710. /**
  7711. * @param {number} k
  7712. * @return {number}
  7713. */
  7714. backIn: function (k) {
  7715. var s = 1.70158;
  7716. return k * k * ((s + 1) * k - s);
  7717. },
  7718. /**
  7719. * @param {number} k
  7720. * @return {number}
  7721. */
  7722. backOut: function (k) {
  7723. var s = 1.70158;
  7724. return --k * k * ((s + 1) * k + s) + 1;
  7725. },
  7726. /**
  7727. * @param {number} k
  7728. * @return {number}
  7729. */
  7730. backInOut: function (k) {
  7731. var s = 1.70158 * 1.525;
  7732. if ((k *= 2) < 1) {
  7733. return 0.5 * (k * k * ((s + 1) * k - s));
  7734. }
  7735. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  7736. },
  7737. // 创建弹跳效果
  7738. /**
  7739. * @param {number} k
  7740. * @return {number}
  7741. */
  7742. bounceIn: function (k) {
  7743. return 1 - easing.bounceOut(1 - k);
  7744. },
  7745. /**
  7746. * @param {number} k
  7747. * @return {number}
  7748. */
  7749. bounceOut: function (k) {
  7750. if (k < (1 / 2.75)) {
  7751. return 7.5625 * k * k;
  7752. }
  7753. else if (k < (2 / 2.75)) {
  7754. return 7.5625 * (k -= (1.5 / 2.75)) * k + 0.75;
  7755. }
  7756. else if (k < (2.5 / 2.75)) {
  7757. return 7.5625 * (k -= (2.25 / 2.75)) * k + 0.9375;
  7758. }
  7759. else {
  7760. return 7.5625 * (k -= (2.625 / 2.75)) * k + 0.984375;
  7761. }
  7762. },
  7763. /**
  7764. * @param {number} k
  7765. * @return {number}
  7766. */
  7767. bounceInOut: function (k) {
  7768. if (k < 0.5) {
  7769. return easing.bounceIn(k * 2) * 0.5;
  7770. }
  7771. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  7772. }
  7773. };
  7774. module.exports = easing;
  7775. /***/ },
  7776. /* 38 */
  7777. /***/ function(module, exports) {
  7778. /**
  7779. * @module zrender/tool/color
  7780. */
  7781. var kCSSColorTable = {
  7782. 'transparent': [0,0,0,0], 'aliceblue': [240,248,255,1],
  7783. 'antiquewhite': [250,235,215,1], 'aqua': [0,255,255,1],
  7784. 'aquamarine': [127,255,212,1], 'azure': [240,255,255,1],
  7785. 'beige': [245,245,220,1], 'bisque': [255,228,196,1],
  7786. 'black': [0,0,0,1], 'blanchedalmond': [255,235,205,1],
  7787. 'blue': [0,0,255,1], 'blueviolet': [138,43,226,1],
  7788. 'brown': [165,42,42,1], 'burlywood': [222,184,135,1],
  7789. 'cadetblue': [95,158,160,1], 'chartreuse': [127,255,0,1],
  7790. 'chocolate': [210,105,30,1], 'coral': [255,127,80,1],
  7791. 'cornflowerblue': [100,149,237,1], 'cornsilk': [255,248,220,1],
  7792. 'crimson': [220,20,60,1], 'cyan': [0,255,255,1],
  7793. 'darkblue': [0,0,139,1], 'darkcyan': [0,139,139,1],
  7794. 'darkgoldenrod': [184,134,11,1], 'darkgray': [169,169,169,1],
  7795. 'darkgreen': [0,100,0,1], 'darkgrey': [169,169,169,1],
  7796. 'darkkhaki': [189,183,107,1], 'darkmagenta': [139,0,139,1],
  7797. 'darkolivegreen': [85,107,47,1], 'darkorange': [255,140,0,1],
  7798. 'darkorchid': [153,50,204,1], 'darkred': [139,0,0,1],
  7799. 'darksalmon': [233,150,122,1], 'darkseagreen': [143,188,143,1],
  7800. 'darkslateblue': [72,61,139,1], 'darkslategray': [47,79,79,1],
  7801. 'darkslategrey': [47,79,79,1], 'darkturquoise': [0,206,209,1],
  7802. 'darkviolet': [148,0,211,1], 'deeppink': [255,20,147,1],
  7803. 'deepskyblue': [0,191,255,1], 'dimgray': [105,105,105,1],
  7804. 'dimgrey': [105,105,105,1], 'dodgerblue': [30,144,255,1],
  7805. 'firebrick': [178,34,34,1], 'floralwhite': [255,250,240,1],
  7806. 'forestgreen': [34,139,34,1], 'fuchsia': [255,0,255,1],
  7807. 'gainsboro': [220,220,220,1], 'ghostwhite': [248,248,255,1],
  7808. 'gold': [255,215,0,1], 'goldenrod': [218,165,32,1],
  7809. 'gray': [128,128,128,1], 'green': [0,128,0,1],
  7810. 'greenyellow': [173,255,47,1], 'grey': [128,128,128,1],
  7811. 'honeydew': [240,255,240,1], 'hotpink': [255,105,180,1],
  7812. 'indianred': [205,92,92,1], 'indigo': [75,0,130,1],
  7813. 'ivory': [255,255,240,1], 'khaki': [240,230,140,1],
  7814. 'lavender': [230,230,250,1], 'lavenderblush': [255,240,245,1],
  7815. 'lawngreen': [124,252,0,1], 'lemonchiffon': [255,250,205,1],
  7816. 'lightblue': [173,216,230,1], 'lightcoral': [240,128,128,1],
  7817. 'lightcyan': [224,255,255,1], 'lightgoldenrodyellow': [250,250,210,1],
  7818. 'lightgray': [211,211,211,1], 'lightgreen': [144,238,144,1],
  7819. 'lightgrey': [211,211,211,1], 'lightpink': [255,182,193,1],
  7820. 'lightsalmon': [255,160,122,1], 'lightseagreen': [32,178,170,1],
  7821. 'lightskyblue': [135,206,250,1], 'lightslategray': [119,136,153,1],
  7822. 'lightslategrey': [119,136,153,1], 'lightsteelblue': [176,196,222,1],
  7823. 'lightyellow': [255,255,224,1], 'lime': [0,255,0,1],
  7824. 'limegreen': [50,205,50,1], 'linen': [250,240,230,1],
  7825. 'magenta': [255,0,255,1], 'maroon': [128,0,0,1],
  7826. 'mediumaquamarine': [102,205,170,1], 'mediumblue': [0,0,205,1],
  7827. 'mediumorchid': [186,85,211,1], 'mediumpurple': [147,112,219,1],
  7828. 'mediumseagreen': [60,179,113,1], 'mediumslateblue': [123,104,238,1],
  7829. 'mediumspringgreen': [0,250,154,1], 'mediumturquoise': [72,209,204,1],
  7830. 'mediumvioletred': [199,21,133,1], 'midnightblue': [25,25,112,1],
  7831. 'mintcream': [245,255,250,1], 'mistyrose': [255,228,225,1],
  7832. 'moccasin': [255,228,181,1], 'navajowhite': [255,222,173,1],
  7833. 'navy': [0,0,128,1], 'oldlace': [253,245,230,1],
  7834. 'olive': [128,128,0,1], 'olivedrab': [107,142,35,1],
  7835. 'orange': [255,165,0,1], 'orangered': [255,69,0,1],
  7836. 'orchid': [218,112,214,1], 'palegoldenrod': [238,232,170,1],
  7837. 'palegreen': [152,251,152,1], 'paleturquoise': [175,238,238,1],
  7838. 'palevioletred': [219,112,147,1], 'papayawhip': [255,239,213,1],
  7839. 'peachpuff': [255,218,185,1], 'peru': [205,133,63,1],
  7840. 'pink': [255,192,203,1], 'plum': [221,160,221,1],
  7841. 'powderblue': [176,224,230,1], 'purple': [128,0,128,1],
  7842. 'red': [255,0,0,1], 'rosybrown': [188,143,143,1],
  7843. 'royalblue': [65,105,225,1], 'saddlebrown': [139,69,19,1],
  7844. 'salmon': [250,128,114,1], 'sandybrown': [244,164,96,1],
  7845. 'seagreen': [46,139,87,1], 'seashell': [255,245,238,1],
  7846. 'sienna': [160,82,45,1], 'silver': [192,192,192,1],
  7847. 'skyblue': [135,206,235,1], 'slateblue': [106,90,205,1],
  7848. 'slategray': [112,128,144,1], 'slategrey': [112,128,144,1],
  7849. 'snow': [255,250,250,1], 'springgreen': [0,255,127,1],
  7850. 'steelblue': [70,130,180,1], 'tan': [210,180,140,1],
  7851. 'teal': [0,128,128,1], 'thistle': [216,191,216,1],
  7852. 'tomato': [255,99,71,1], 'turquoise': [64,224,208,1],
  7853. 'violet': [238,130,238,1], 'wheat': [245,222,179,1],
  7854. 'white': [255,255,255,1], 'whitesmoke': [245,245,245,1],
  7855. 'yellow': [255,255,0,1], 'yellowgreen': [154,205,50,1]
  7856. };
  7857. function clampCssByte(i) { // Clamp to integer 0 .. 255.
  7858. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  7859. return i < 0 ? 0 : i > 255 ? 255 : i;
  7860. }
  7861. function clampCssAngle(i) { // Clamp to integer 0 .. 360.
  7862. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  7863. return i < 0 ? 0 : i > 360 ? 360 : i;
  7864. }
  7865. function clampCssFloat(f) { // Clamp to float 0.0 .. 1.0.
  7866. return f < 0 ? 0 : f > 1 ? 1 : f;
  7867. }
  7868. function parseCssInt(str) { // int or percentage.
  7869. if (str.length && str.charAt(str.length - 1) === '%') {
  7870. return clampCssByte(parseFloat(str) / 100 * 255);
  7871. }
  7872. return clampCssByte(parseInt(str, 10));
  7873. }
  7874. function parseCssFloat(str) { // float or percentage.
  7875. if (str.length && str.charAt(str.length - 1) === '%') {
  7876. return clampCssFloat(parseFloat(str) / 100);
  7877. }
  7878. return clampCssFloat(parseFloat(str));
  7879. }
  7880. function cssHueToRgb(m1, m2, h) {
  7881. if (h < 0) {
  7882. h += 1;
  7883. }
  7884. else if (h > 1) {
  7885. h -= 1;
  7886. }
  7887. if (h * 6 < 1) {
  7888. return m1 + (m2 - m1) * h * 6;
  7889. }
  7890. if (h * 2 < 1) {
  7891. return m2;
  7892. }
  7893. if (h * 3 < 2) {
  7894. return m1 + (m2 - m1) * (2/3 - h) * 6;
  7895. }
  7896. return m1;
  7897. }
  7898. function lerp(a, b, p) {
  7899. return a + (b - a) * p;
  7900. }
  7901. /**
  7902. * @param {string} colorStr
  7903. * @return {Array.<number>}
  7904. * @memberOf module:zrender/util/color
  7905. */
  7906. function parse(colorStr) {
  7907. if (!colorStr) {
  7908. return;
  7909. }
  7910. // colorStr may be not string
  7911. colorStr = colorStr + '';
  7912. // Remove all whitespace, not compliant, but should just be more accepting.
  7913. var str = colorStr.replace(/ /g, '').toLowerCase();
  7914. // Color keywords (and transparent) lookup.
  7915. if (str in kCSSColorTable) {
  7916. return kCSSColorTable[str].slice(); // dup.
  7917. }
  7918. // #abc and #abc123 syntax.
  7919. if (str.charAt(0) === '#') {
  7920. if (str.length === 4) {
  7921. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  7922. if (!(iv >= 0 && iv <= 0xfff)) {
  7923. return; // Covers NaN.
  7924. }
  7925. return [
  7926. ((iv & 0xf00) >> 4) | ((iv & 0xf00) >> 8),
  7927. (iv & 0xf0) | ((iv & 0xf0) >> 4),
  7928. (iv & 0xf) | ((iv & 0xf) << 4),
  7929. 1
  7930. ];
  7931. }
  7932. else if (str.length === 7) {
  7933. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  7934. if (!(iv >= 0 && iv <= 0xffffff)) {
  7935. return; // Covers NaN.
  7936. }
  7937. return [
  7938. (iv & 0xff0000) >> 16,
  7939. (iv & 0xff00) >> 8,
  7940. iv & 0xff,
  7941. 1
  7942. ];
  7943. }
  7944. return;
  7945. }
  7946. var op = str.indexOf('('), ep = str.indexOf(')');
  7947. if (op !== -1 && ep + 1 === str.length) {
  7948. var fname = str.substr(0, op);
  7949. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  7950. var alpha = 1; // To allow case fallthrough.
  7951. switch (fname) {
  7952. case 'rgba':
  7953. if (params.length !== 4) {
  7954. return;
  7955. }
  7956. alpha = parseCssFloat(params.pop()); // jshint ignore:line
  7957. // Fall through.
  7958. case 'rgb':
  7959. if (params.length !== 3) {
  7960. return;
  7961. }
  7962. return [
  7963. parseCssInt(params[0]),
  7964. parseCssInt(params[1]),
  7965. parseCssInt(params[2]),
  7966. alpha
  7967. ];
  7968. case 'hsla':
  7969. if (params.length !== 4) {
  7970. return;
  7971. }
  7972. params[3] = parseCssFloat(params[3]);
  7973. return hsla2rgba(params);
  7974. case 'hsl':
  7975. if (params.length !== 3) {
  7976. return;
  7977. }
  7978. return hsla2rgba(params);
  7979. default:
  7980. return;
  7981. }
  7982. }
  7983. return;
  7984. }
  7985. /**
  7986. * @param {Array.<number>} hsla
  7987. * @return {Array.<number>} rgba
  7988. */
  7989. function hsla2rgba(hsla) {
  7990. var h = (((parseFloat(hsla[0]) % 360) + 360) % 360) / 360; // 0 .. 1
  7991. // NOTE(deanm): According to the CSS spec s/l should only be
  7992. // percentages, but we don't bother and let float or percentage.
  7993. var s = parseCssFloat(hsla[1]);
  7994. var l = parseCssFloat(hsla[2]);
  7995. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  7996. var m1 = l * 2 - m2;
  7997. var rgba = [
  7998. clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255),
  7999. clampCssByte(cssHueToRgb(m1, m2, h) * 255),
  8000. clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255)
  8001. ];
  8002. if (hsla.length === 4) {
  8003. rgba[3] = hsla[3];
  8004. }
  8005. return rgba;
  8006. }
  8007. /**
  8008. * @param {Array.<number>} rgba
  8009. * @return {Array.<number>} hsla
  8010. */
  8011. function rgba2hsla(rgba) {
  8012. if (!rgba) {
  8013. return;
  8014. }
  8015. // RGB from 0 to 255
  8016. var R = rgba[0] / 255;
  8017. var G = rgba[1] / 255;
  8018. var B = rgba[2] / 255;
  8019. var vMin = Math.min(R, G, B); // Min. value of RGB
  8020. var vMax = Math.max(R, G, B); // Max. value of RGB
  8021. var delta = vMax - vMin; // Delta RGB value
  8022. var L = (vMax + vMin) / 2;
  8023. var H;
  8024. var S;
  8025. // HSL results from 0 to 1
  8026. if (delta === 0) {
  8027. H = 0;
  8028. S = 0;
  8029. }
  8030. else {
  8031. if (L < 0.5) {
  8032. S = delta / (vMax + vMin);
  8033. }
  8034. else {
  8035. S = delta / (2 - vMax - vMin);
  8036. }
  8037. var deltaR = (((vMax - R) / 6) + (delta / 2)) / delta;
  8038. var deltaG = (((vMax - G) / 6) + (delta / 2)) / delta;
  8039. var deltaB = (((vMax - B) / 6) + (delta / 2)) / delta;
  8040. if (R === vMax) {
  8041. H = deltaB - deltaG;
  8042. }
  8043. else if (G === vMax) {
  8044. H = (1 / 3) + deltaR - deltaB;
  8045. }
  8046. else if (B === vMax) {
  8047. H = (2 / 3) + deltaG - deltaR;
  8048. }
  8049. if (H < 0) {
  8050. H += 1;
  8051. }
  8052. if (H > 1) {
  8053. H -= 1;
  8054. }
  8055. }
  8056. var hsla = [H * 360, S, L];
  8057. if (rgba[3] != null) {
  8058. hsla.push(rgba[3]);
  8059. }
  8060. return hsla;
  8061. }
  8062. /**
  8063. * @param {string} color
  8064. * @param {number} level
  8065. * @return {string}
  8066. * @memberOf module:zrender/util/color
  8067. */
  8068. function lift(color, level) {
  8069. var colorArr = parse(color);
  8070. if (colorArr) {
  8071. for (var i = 0; i < 3; i++) {
  8072. if (level < 0) {
  8073. colorArr[i] = colorArr[i] * (1 - level) | 0;
  8074. }
  8075. else {
  8076. colorArr[i] = ((255 - colorArr[i]) * level + colorArr[i]) | 0;
  8077. }
  8078. }
  8079. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  8080. }
  8081. }
  8082. /**
  8083. * @param {string} color
  8084. * @return {string}
  8085. * @memberOf module:zrender/util/color
  8086. */
  8087. function toHex(color, level) {
  8088. var colorArr = parse(color);
  8089. if (colorArr) {
  8090. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + (+colorArr[2])).toString(16).slice(1);
  8091. }
  8092. }
  8093. /**
  8094. * Map value to color. Faster than mapToColor methods because color is represented by rgba array
  8095. * @param {number} normalizedValue A float between 0 and 1.
  8096. * @param {Array.<Array.<number>>} colors List of rgba color array
  8097. * @param {Array.<number>} [out] Mapped gba color array
  8098. * @return {Array.<number>}
  8099. */
  8100. function fastMapToColor(normalizedValue, colors, out) {
  8101. if (!(colors && colors.length)
  8102. || !(normalizedValue >= 0 && normalizedValue <= 1)
  8103. ) {
  8104. return;
  8105. }
  8106. out = out || [0, 0, 0, 0];
  8107. var value = normalizedValue * (colors.length - 1);
  8108. var leftIndex = Math.floor(value);
  8109. var rightIndex = Math.ceil(value);
  8110. var leftColor = colors[leftIndex];
  8111. var rightColor = colors[rightIndex];
  8112. var dv = value - leftIndex;
  8113. out[0] = clampCssByte(lerp(leftColor[0], rightColor[0], dv));
  8114. out[1] = clampCssByte(lerp(leftColor[1], rightColor[1], dv));
  8115. out[2] = clampCssByte(lerp(leftColor[2], rightColor[2], dv));
  8116. out[3] = clampCssByte(lerp(leftColor[3], rightColor[3], dv));
  8117. return out;
  8118. }
  8119. /**
  8120. * @param {number} normalizedValue A float between 0 and 1.
  8121. * @param {Array.<string>} colors Color list.
  8122. * @param {boolean=} fullOutput Default false.
  8123. * @return {(string|Object)} Result color. If fullOutput,
  8124. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  8125. * @memberOf module:zrender/util/color
  8126. */
  8127. function mapToColor(normalizedValue, colors, fullOutput) {
  8128. if (!(colors && colors.length)
  8129. || !(normalizedValue >= 0 && normalizedValue <= 1)
  8130. ) {
  8131. return;
  8132. }
  8133. var value = normalizedValue * (colors.length - 1);
  8134. var leftIndex = Math.floor(value);
  8135. var rightIndex = Math.ceil(value);
  8136. var leftColor = parse(colors[leftIndex]);
  8137. var rightColor = parse(colors[rightIndex]);
  8138. var dv = value - leftIndex;
  8139. var color = stringify(
  8140. [
  8141. clampCssByte(lerp(leftColor[0], rightColor[0], dv)),
  8142. clampCssByte(lerp(leftColor[1], rightColor[1], dv)),
  8143. clampCssByte(lerp(leftColor[2], rightColor[2], dv)),
  8144. clampCssFloat(lerp(leftColor[3], rightColor[3], dv))
  8145. ],
  8146. 'rgba'
  8147. );
  8148. return fullOutput
  8149. ? {
  8150. color: color,
  8151. leftIndex: leftIndex,
  8152. rightIndex: rightIndex,
  8153. value: value
  8154. }
  8155. : color;
  8156. }
  8157. /**
  8158. * @param {string} color
  8159. * @param {number=} h 0 ~ 360, ignore when null.
  8160. * @param {number=} s 0 ~ 1, ignore when null.
  8161. * @param {number=} l 0 ~ 1, ignore when null.
  8162. * @return {string} Color string in rgba format.
  8163. * @memberOf module:zrender/util/color
  8164. */
  8165. function modifyHSL(color, h, s, l) {
  8166. color = parse(color);
  8167. if (color) {
  8168. color = rgba2hsla(color);
  8169. h != null && (color[0] = clampCssAngle(h));
  8170. s != null && (color[1] = parseCssFloat(s));
  8171. l != null && (color[2] = parseCssFloat(l));
  8172. return stringify(hsla2rgba(color), 'rgba');
  8173. }
  8174. }
  8175. /**
  8176. * @param {string} color
  8177. * @param {number=} alpha 0 ~ 1
  8178. * @return {string} Color string in rgba format.
  8179. * @memberOf module:zrender/util/color
  8180. */
  8181. function modifyAlpha(color, alpha) {
  8182. color = parse(color);
  8183. if (color && alpha != null) {
  8184. color[3] = clampCssFloat(alpha);
  8185. return stringify(color, 'rgba');
  8186. }
  8187. }
  8188. /**
  8189. * @param {Array.<string>} colors Color list.
  8190. * @param {string} type 'rgba', 'hsva', ...
  8191. * @return {string} Result color.
  8192. */
  8193. function stringify(arrColor, type) {
  8194. if (type === 'rgb' || type === 'hsv' || type === 'hsl') {
  8195. arrColor = arrColor.slice(0, 3);
  8196. }
  8197. return type + '(' + arrColor.join(',') + ')';
  8198. }
  8199. module.exports = {
  8200. parse: parse,
  8201. lift: lift,
  8202. toHex: toHex,
  8203. fastMapToColor: fastMapToColor,
  8204. mapToColor: mapToColor,
  8205. modifyHSL: modifyHSL,
  8206. modifyAlpha: modifyAlpha,
  8207. stringify: stringify
  8208. };
  8209. /***/ },
  8210. /* 39 */
  8211. /***/ function(module, exports, __webpack_require__) {
  8212. var config = __webpack_require__(40);
  8213. /**
  8214. * @exports zrender/tool/log
  8215. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8216. */
  8217. module.exports = function() {
  8218. if (config.debugMode === 0) {
  8219. return;
  8220. }
  8221. else if (config.debugMode == 1) {
  8222. for (var k in arguments) {
  8223. throw new Error(arguments[k]);
  8224. }
  8225. }
  8226. else if (config.debugMode > 1) {
  8227. for (var k in arguments) {
  8228. console.log(arguments[k]);
  8229. }
  8230. }
  8231. };
  8232. /* for debug
  8233. return function(mes) {
  8234. document.getElementById('wrong-message').innerHTML =
  8235. mes + ' ' + (new Date() - 0)
  8236. + '<br/>'
  8237. + document.getElementById('wrong-message').innerHTML;
  8238. };
  8239. */
  8240. /***/ },
  8241. /* 40 */
  8242. /***/ function(module, exports) {
  8243. var dpr = 1;
  8244. // If in browser environment
  8245. if (typeof window !== 'undefined') {
  8246. dpr = Math.max(window.devicePixelRatio || 1, 1);
  8247. }
  8248. /**
  8249. * config默认配置项
  8250. * @exports zrender/config
  8251. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  8252. */
  8253. var config = {
  8254. /**
  8255. * debug日志选项:catchBrushException为true下有效
  8256. * 0 : 不生成debug数据,发布用
  8257. * 1 : 异常抛出,调试用
  8258. * 2 : 控制台输出,调试用
  8259. */
  8260. debugMode: 0,
  8261. // retina 屏幕优化
  8262. devicePixelRatio: dpr
  8263. };
  8264. module.exports = config;
  8265. /***/ },
  8266. /* 41 */
  8267. /***/ function(module, exports, __webpack_require__) {
  8268. var Group = __webpack_require__(29);
  8269. var componentUtil = __webpack_require__(20);
  8270. var clazzUtil = __webpack_require__(9);
  8271. function Chart() {
  8272. /**
  8273. * @type {module:zrender/container/Group}
  8274. * @readOnly
  8275. */
  8276. this.group = new Group();
  8277. /**
  8278. * @type {string}
  8279. * @readOnly
  8280. */
  8281. this.uid = componentUtil.getUID('viewChart');
  8282. }
  8283. Chart.prototype = {
  8284. type: 'chart',
  8285. /**
  8286. * Init the chart
  8287. * @param {module:echarts/model/Global} ecModel
  8288. * @param {module:echarts/ExtensionAPI} api
  8289. */
  8290. init: function (ecModel, api) {},
  8291. /**
  8292. * Render the chart
  8293. * @param {module:echarts/model/Series} seriesModel
  8294. * @param {module:echarts/model/Global} ecModel
  8295. * @param {module:echarts/ExtensionAPI} api
  8296. * @param {Object} payload
  8297. */
  8298. render: function (seriesModel, ecModel, api, payload) {},
  8299. /**
  8300. * Highlight series or specified data item
  8301. * @param {module:echarts/model/Series} seriesModel
  8302. * @param {module:echarts/model/Global} ecModel
  8303. * @param {module:echarts/ExtensionAPI} api
  8304. * @param {Object} payload
  8305. */
  8306. highlight: function (seriesModel, ecModel, api, payload) {
  8307. toggleHighlight(seriesModel.getData(), payload, 'emphasis');
  8308. },
  8309. /**
  8310. * Downplay series or specified data item
  8311. * @param {module:echarts/model/Series} seriesModel
  8312. * @param {module:echarts/model/Global} ecModel
  8313. * @param {module:echarts/ExtensionAPI} api
  8314. * @param {Object} payload
  8315. */
  8316. downplay: function (seriesModel, ecModel, api, payload) {
  8317. toggleHighlight(seriesModel.getData(), payload, 'normal');
  8318. },
  8319. /**
  8320. * Remove self
  8321. * @param {module:echarts/model/Global} ecModel
  8322. * @param {module:echarts/ExtensionAPI} api
  8323. */
  8324. remove: function (ecModel, api) {
  8325. this.group.removeAll();
  8326. },
  8327. /**
  8328. * Dispose self
  8329. * @param {module:echarts/model/Global} ecModel
  8330. * @param {module:echarts/ExtensionAPI} api
  8331. */
  8332. dispose: function () {}
  8333. };
  8334. var chartProto = Chart.prototype;
  8335. chartProto.updateView
  8336. = chartProto.updateLayout
  8337. = chartProto.updateVisual
  8338. = function (seriesModel, ecModel, api, payload) {
  8339. this.render(seriesModel, ecModel, api, payload);
  8340. };
  8341. /**
  8342. * Set state of single element
  8343. * @param {module:zrender/Element} el
  8344. * @param {string} state
  8345. */
  8346. function elSetState(el, state) {
  8347. if (el) {
  8348. el.trigger(state);
  8349. if (el.type === 'group') {
  8350. for (var i = 0; i < el.childCount(); i++) {
  8351. elSetState(el.childAt(i), state);
  8352. }
  8353. }
  8354. }
  8355. }
  8356. /**
  8357. * @param {module:echarts/data/List} data
  8358. * @param {Object} payload
  8359. * @param {string} state 'normal'|'emphasis'
  8360. * @inner
  8361. */
  8362. function toggleHighlight(data, payload, state) {
  8363. if (payload.dataIndex != null) {
  8364. var el = data.getItemGraphicEl(payload.dataIndex);
  8365. elSetState(el, state);
  8366. }
  8367. else if (payload.name) {
  8368. var dataIndex = data.indexOfName(payload.name);
  8369. var el = data.getItemGraphicEl(dataIndex);
  8370. elSetState(el, state);
  8371. }
  8372. else {
  8373. data.eachItemGraphicEl(function (el) {
  8374. elSetState(el, state);
  8375. });
  8376. }
  8377. }
  8378. // Enable Chart.extend.
  8379. clazzUtil.enableClassExtend(Chart);
  8380. // Add capability of registerClass, getClass, hasClass, registerSubTypeDefaulter and so on.
  8381. clazzUtil.enableClassManagement(Chart, {registerWhenExtend: true});
  8382. module.exports = Chart;
  8383. /***/ },
  8384. /* 42 */
  8385. /***/ function(module, exports, __webpack_require__) {
  8386. 'use strict';
  8387. var zrUtil = __webpack_require__(3);
  8388. var pathTool = __webpack_require__(43);
  8389. var round = Math.round;
  8390. var Path = __webpack_require__(44);
  8391. var colorTool = __webpack_require__(38);
  8392. var matrix = __webpack_require__(17);
  8393. var vector = __webpack_require__(16);
  8394. var Gradient = __webpack_require__(4);
  8395. var graphic = {};
  8396. graphic.Group = __webpack_require__(29);
  8397. graphic.Image = __webpack_require__(59);
  8398. graphic.Text = __webpack_require__(62);
  8399. graphic.Circle = __webpack_require__(63);
  8400. graphic.Sector = __webpack_require__(64);
  8401. graphic.Ring = __webpack_require__(65);
  8402. graphic.Polygon = __webpack_require__(66);
  8403. graphic.Polyline = __webpack_require__(70);
  8404. graphic.Rect = __webpack_require__(71);
  8405. graphic.Line = __webpack_require__(72);
  8406. graphic.BezierCurve = __webpack_require__(73);
  8407. graphic.Arc = __webpack_require__(74);
  8408. graphic.CompoundPath = __webpack_require__(75);
  8409. graphic.LinearGradient = __webpack_require__(76);
  8410. graphic.RadialGradient = __webpack_require__(77);
  8411. graphic.BoundingRect = __webpack_require__(15);
  8412. /**
  8413. * Extend shape with parameters
  8414. */
  8415. graphic.extendShape = function (opts) {
  8416. return Path.extend(opts);
  8417. };
  8418. /**
  8419. * Extend path
  8420. */
  8421. graphic.extendPath = function (pathData, opts) {
  8422. return pathTool.extendFromString(pathData, opts);
  8423. };
  8424. /**
  8425. * Create a path element from path data string
  8426. * @param {string} pathData
  8427. * @param {Object} opts
  8428. * @param {module:zrender/core/BoundingRect} rect
  8429. * @param {string} [layout=cover] 'center' or 'cover'
  8430. */
  8431. graphic.makePath = function (pathData, opts, rect, layout) {
  8432. var path = pathTool.createFromString(pathData, opts);
  8433. var boundingRect = path.getBoundingRect();
  8434. if (rect) {
  8435. var aspect = boundingRect.width / boundingRect.height;
  8436. if (layout === 'center') {
  8437. // Set rect to center, keep width / height ratio.
  8438. var width = rect.height * aspect;
  8439. var height;
  8440. if (width <= rect.width) {
  8441. height = rect.height;
  8442. }
  8443. else {
  8444. width = rect.width;
  8445. height = width / aspect;
  8446. }
  8447. var cx = rect.x + rect.width / 2;
  8448. var cy = rect.y + rect.height / 2;
  8449. rect.x = cx - width / 2;
  8450. rect.y = cy - height / 2;
  8451. rect.width = width;
  8452. rect.height = height;
  8453. }
  8454. this.resizePath(path, rect);
  8455. }
  8456. return path;
  8457. };
  8458. graphic.mergePath = pathTool.mergePath,
  8459. /**
  8460. * Resize a path to fit the rect
  8461. * @param {module:zrender/graphic/Path} path
  8462. * @param {Object} rect
  8463. */
  8464. graphic.resizePath = function (path, rect) {
  8465. if (!path.applyTransform) {
  8466. return;
  8467. }
  8468. var pathRect = path.getBoundingRect();
  8469. var m = pathRect.calculateTransform(rect);
  8470. path.applyTransform(m);
  8471. };
  8472. /**
  8473. * Sub pixel optimize line for canvas
  8474. *
  8475. * @param {Object} param
  8476. * @param {Object} [param.shape]
  8477. * @param {number} [param.shape.x1]
  8478. * @param {number} [param.shape.y1]
  8479. * @param {number} [param.shape.x2]
  8480. * @param {number} [param.shape.y2]
  8481. * @param {Object} [param.style]
  8482. * @param {number} [param.style.lineWidth]
  8483. * @return {Object} Modified param
  8484. */
  8485. graphic.subPixelOptimizeLine = function (param) {
  8486. var subPixelOptimize = graphic.subPixelOptimize;
  8487. var shape = param.shape;
  8488. var lineWidth = param.style.lineWidth;
  8489. if (round(shape.x1 * 2) === round(shape.x2 * 2)) {
  8490. shape.x1 = shape.x2 = subPixelOptimize(shape.x1, lineWidth, true);
  8491. }
  8492. if (round(shape.y1 * 2) === round(shape.y2 * 2)) {
  8493. shape.y1 = shape.y2 = subPixelOptimize(shape.y1, lineWidth, true);
  8494. }
  8495. return param;
  8496. };
  8497. /**
  8498. * Sub pixel optimize rect for canvas
  8499. *
  8500. * @param {Object} param
  8501. * @param {Object} [param.shape]
  8502. * @param {number} [param.shape.x]
  8503. * @param {number} [param.shape.y]
  8504. * @param {number} [param.shape.width]
  8505. * @param {number} [param.shape.height]
  8506. * @param {Object} [param.style]
  8507. * @param {number} [param.style.lineWidth]
  8508. * @return {Object} Modified param
  8509. */
  8510. graphic.subPixelOptimizeRect = function (param) {
  8511. var subPixelOptimize = graphic.subPixelOptimize;
  8512. var shape = param.shape;
  8513. var lineWidth = param.style.lineWidth;
  8514. var originX = shape.x;
  8515. var originY = shape.y;
  8516. var originWidth = shape.width;
  8517. var originHeight = shape.height;
  8518. shape.x = subPixelOptimize(shape.x, lineWidth, true);
  8519. shape.y = subPixelOptimize(shape.y, lineWidth, true);
  8520. shape.width = Math.max(
  8521. subPixelOptimize(originX + originWidth, lineWidth, false) - shape.x,
  8522. originWidth === 0 ? 0 : 1
  8523. );
  8524. shape.height = Math.max(
  8525. subPixelOptimize(originY + originHeight, lineWidth, false) - shape.y,
  8526. originHeight === 0 ? 0 : 1
  8527. );
  8528. return param;
  8529. };
  8530. /**
  8531. * Sub pixel optimize for canvas
  8532. *
  8533. * @param {number} position Coordinate, such as x, y
  8534. * @param {number} lineWidth Should be nonnegative integer.
  8535. * @param {boolean=} positiveOrNegative Default false (negative).
  8536. * @return {number} Optimized position.
  8537. */
  8538. graphic.subPixelOptimize = function (position, lineWidth, positiveOrNegative) {
  8539. // Assure that (position + lineWidth / 2) is near integer edge,
  8540. // otherwise line will be fuzzy in canvas.
  8541. var doubledPosition = round(position * 2);
  8542. return (doubledPosition + round(lineWidth)) % 2 === 0
  8543. ? doubledPosition / 2
  8544. : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  8545. };
  8546. function hasFillOrStroke(fillOrStroke) {
  8547. return fillOrStroke != null && fillOrStroke != 'none';
  8548. }
  8549. function liftColor(color) {
  8550. return color instanceof Gradient ? color : colorTool.lift(color, -0.1);
  8551. }
  8552. /**
  8553. * @private
  8554. */
  8555. function cacheElementStl(el) {
  8556. if (el.__hoverStlDirty) {
  8557. var stroke = el.style.stroke;
  8558. var fill = el.style.fill;
  8559. // Create hoverStyle on mouseover
  8560. var hoverStyle = el.__hoverStl;
  8561. hoverStyle.fill = hoverStyle.fill
  8562. || (hasFillOrStroke(fill) ? liftColor(fill) : null);
  8563. hoverStyle.stroke = hoverStyle.stroke
  8564. || (hasFillOrStroke(stroke) ? liftColor(stroke) : null);
  8565. var normalStyle = {};
  8566. for (var name in hoverStyle) {
  8567. if (hoverStyle.hasOwnProperty(name)) {
  8568. normalStyle[name] = el.style[name];
  8569. }
  8570. }
  8571. el.__normalStl = normalStyle;
  8572. el.__hoverStlDirty = false;
  8573. }
  8574. }
  8575. /**
  8576. * @private
  8577. */
  8578. function doSingleEnterHover(el) {
  8579. if (el.__isHover) {
  8580. return;
  8581. }
  8582. cacheElementStl(el);
  8583. el.setStyle(el.__hoverStl);
  8584. el.z2 += 1;
  8585. el.__isHover = true;
  8586. }
  8587. /**
  8588. * @inner
  8589. */
  8590. function doSingleLeaveHover(el) {
  8591. if (!el.__isHover) {
  8592. return;
  8593. }
  8594. var normalStl = el.__normalStl;
  8595. normalStl && el.setStyle(normalStl);
  8596. el.z2 -= 1;
  8597. el.__isHover = false;
  8598. }
  8599. /**
  8600. * @inner
  8601. */
  8602. function doEnterHover(el) {
  8603. el.type === 'group'
  8604. ? el.traverse(function (child) {
  8605. if (child.type !== 'group') {
  8606. doSingleEnterHover(child);
  8607. }
  8608. })
  8609. : doSingleEnterHover(el);
  8610. }
  8611. function doLeaveHover(el) {
  8612. el.type === 'group'
  8613. ? el.traverse(function (child) {
  8614. if (child.type !== 'group') {
  8615. doSingleLeaveHover(child);
  8616. }
  8617. })
  8618. : doSingleLeaveHover(el);
  8619. }
  8620. /**
  8621. * @inner
  8622. */
  8623. function setElementHoverStl(el, hoverStl) {
  8624. // If element has sepcified hoverStyle, then use it instead of given hoverStyle
  8625. // Often used when item group has a label element and it's hoverStyle is different
  8626. el.__hoverStl = el.hoverStyle || hoverStl || {};
  8627. el.__hoverStlDirty = true;
  8628. if (el.__isHover) {
  8629. cacheElementStl(el);
  8630. }
  8631. }
  8632. /**
  8633. * @inner
  8634. */
  8635. function onElementMouseOver() {
  8636. // Only if element is not in emphasis status
  8637. !this.__isEmphasis && doEnterHover(this);
  8638. }
  8639. /**
  8640. * @inner
  8641. */
  8642. function onElementMouseOut() {
  8643. // Only if element is not in emphasis status
  8644. !this.__isEmphasis && doLeaveHover(this);
  8645. }
  8646. /**
  8647. * @inner
  8648. */
  8649. function enterEmphasis() {
  8650. this.__isEmphasis = true;
  8651. doEnterHover(this);
  8652. }
  8653. /**
  8654. * @inner
  8655. */
  8656. function leaveEmphasis() {
  8657. this.__isEmphasis = false;
  8658. doLeaveHover(this);
  8659. }
  8660. /**
  8661. * Set hover style of element
  8662. * @param {module:zrender/Element} el
  8663. * @param {Object} [hoverStyle]
  8664. */
  8665. graphic.setHoverStyle = function (el, hoverStyle) {
  8666. el.type === 'group'
  8667. ? el.traverse(function (child) {
  8668. if (child.type !== 'group') {
  8669. setElementHoverStl(child, hoverStyle);
  8670. }
  8671. })
  8672. : setElementHoverStl(el, hoverStyle);
  8673. // Remove previous bound handlers
  8674. el.on('mouseover', onElementMouseOver)
  8675. .on('mouseout', onElementMouseOut);
  8676. // Emphasis, normal can be triggered manually
  8677. el.on('emphasis', enterEmphasis)
  8678. .on('normal', leaveEmphasis);
  8679. };
  8680. /**
  8681. * Set text option in the style
  8682. * @param {Object} textStyle
  8683. * @param {module:echarts/model/Model} labelModel
  8684. * @param {string} color
  8685. */
  8686. graphic.setText = function (textStyle, labelModel, color) {
  8687. var labelPosition = labelModel.getShallow('position') || 'inside';
  8688. var labelColor = labelPosition.indexOf('inside') >= 0 ? 'white' : color;
  8689. var textStyleModel = labelModel.getModel('textStyle');
  8690. zrUtil.extend(textStyle, {
  8691. textDistance: labelModel.getShallow('distance') || 5,
  8692. textFont: textStyleModel.getFont(),
  8693. textPosition: labelPosition,
  8694. textFill: textStyleModel.getTextColor() || labelColor
  8695. });
  8696. };
  8697. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  8698. if (typeof dataIndex === 'function') {
  8699. cb = dataIndex;
  8700. dataIndex = null;
  8701. }
  8702. var postfix = isUpdate ? 'Update' : '';
  8703. var duration = animatableModel
  8704. && animatableModel.getShallow('animationDuration' + postfix);
  8705. var animationEasing = animatableModel
  8706. && animatableModel.getShallow('animationEasing' + postfix);
  8707. var animationDelay = animatableModel
  8708. && animatableModel.getShallow('animationDelay' + postfix);
  8709. if (typeof animationDelay === 'function') {
  8710. animationDelay = animationDelay(dataIndex);
  8711. }
  8712. animatableModel && animatableModel.getShallow('animation')
  8713. ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb)
  8714. : (el.attr(props), cb && cb());
  8715. }
  8716. /**
  8717. * Update graphic element properties with or without animation according to the configuration in series
  8718. * @param {module:zrender/Element} el
  8719. * @param {Object} props
  8720. * @param {module:echarts/model/Model} [animatableModel]
  8721. * @param {number} [dataIndex]
  8722. * @param {Function} [cb]
  8723. * @example
  8724. * graphic.updateProps(el, {
  8725. * position: [100, 100]
  8726. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  8727. * // Or
  8728. * graphic.updateProps(el, {
  8729. * position: [100, 100]
  8730. * }, seriesModel, function () { console.log('Animation done!'); });
  8731. */
  8732. graphic.updateProps = zrUtil.curry(animateOrSetProps, true);
  8733. /**
  8734. * Init graphic element properties with or without animation according to the configuration in series
  8735. * @param {module:zrender/Element} el
  8736. * @param {Object} props
  8737. * @param {module:echarts/model/Model} [animatableModel]
  8738. * @param {Function} cb
  8739. */
  8740. graphic.initProps = zrUtil.curry(animateOrSetProps, false);
  8741. /**
  8742. * Get transform matrix of target (param target),
  8743. * in coordinate of its ancestor (param ancestor)
  8744. *
  8745. * @param {module:zrender/mixin/Transformable} target
  8746. * @param {module:zrender/mixin/Transformable} [ancestor]
  8747. */
  8748. graphic.getTransform = function (target, ancestor) {
  8749. var mat = matrix.identity([]);
  8750. while (target && target !== ancestor) {
  8751. matrix.mul(mat, target.getLocalTransform(), mat);
  8752. target = target.parent;
  8753. }
  8754. return mat;
  8755. };
  8756. /**
  8757. * Apply transform to an vertex.
  8758. * @param {Array.<number>} vertex [x, y]
  8759. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  8760. * @param {boolean=} invert Whether use invert matrix.
  8761. * @return {Array.<number>} [x, y]
  8762. */
  8763. graphic.applyTransform = function (vertex, transform, invert) {
  8764. if (invert) {
  8765. transform = matrix.invert([], transform);
  8766. }
  8767. return vector.applyTransform([], vertex, transform);
  8768. };
  8769. /**
  8770. * @param {string} direction 'left' 'right' 'top' 'bottom'
  8771. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  8772. * @param {boolean=} invert Whether use invert matrix.
  8773. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  8774. */
  8775. graphic.transformDirection = function (direction, transform, invert) {
  8776. // Pick a base, ensure that transform result will not be (0, 0).
  8777. var hBase = (transform[4] === 0 || transform[5] === 0 || transform[0] === 0)
  8778. ? 1 : Math.abs(2 * transform[4] / transform[0]);
  8779. var vBase = (transform[4] === 0 || transform[5] === 0 || transform[2] === 0)
  8780. ? 1 : Math.abs(2 * transform[4] / transform[2]);
  8781. var vertex = [
  8782. direction === 'left' ? -hBase : direction === 'right' ? hBase : 0,
  8783. direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0
  8784. ];
  8785. vertex = graphic.applyTransform(vertex, transform, invert);
  8786. return Math.abs(vertex[0]) > Math.abs(vertex[1])
  8787. ? (vertex[0] > 0 ? 'right' : 'left')
  8788. : (vertex[1] > 0 ? 'bottom' : 'top');
  8789. };
  8790. module.exports = graphic;
  8791. /***/ },
  8792. /* 43 */
  8793. /***/ function(module, exports, __webpack_require__) {
  8794. var Path = __webpack_require__(44);
  8795. var PathProxy = __webpack_require__(48);
  8796. var transformPath = __webpack_require__(58);
  8797. var matrix = __webpack_require__(17);
  8798. // command chars
  8799. var cc = [
  8800. 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  8801. 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  8802. ];
  8803. var mathSqrt = Math.sqrt;
  8804. var mathSin = Math.sin;
  8805. var mathCos = Math.cos;
  8806. var PI = Math.PI;
  8807. var vMag = function(v) {
  8808. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  8809. };
  8810. var vRatio = function(u, v) {
  8811. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  8812. };
  8813. var vAngle = function(u, v) {
  8814. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1)
  8815. * Math.acos(vRatio(u, v));
  8816. };
  8817. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  8818. var psi = psiDeg * (PI / 180.0);
  8819. var xp = mathCos(psi) * (x1 - x2) / 2.0
  8820. + mathSin(psi) * (y1 - y2) / 2.0;
  8821. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
  8822. + mathCos(psi) * (y1 - y2) / 2.0;
  8823. var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
  8824. if (lambda > 1) {
  8825. rx *= mathSqrt(lambda);
  8826. ry *= mathSqrt(lambda);
  8827. }
  8828. var f = (fa === fs ? -1 : 1)
  8829. * mathSqrt((((rx * rx) * (ry * ry))
  8830. - ((rx * rx) * (yp * yp))
  8831. - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
  8832. + (ry * ry) * (xp * xp))
  8833. ) || 0;
  8834. var cxp = f * rx * yp / ry;
  8835. var cyp = f * -ry * xp / rx;
  8836. var cx = (x1 + x2) / 2.0
  8837. + mathCos(psi) * cxp
  8838. - mathSin(psi) * cyp;
  8839. var cy = (y1 + y2) / 2.0
  8840. + mathSin(psi) * cxp
  8841. + mathCos(psi) * cyp;
  8842. var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
  8843. var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
  8844. var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
  8845. var dTheta = vAngle(u, v);
  8846. if (vRatio(u, v) <= -1) {
  8847. dTheta = PI;
  8848. }
  8849. if (vRatio(u, v) >= 1) {
  8850. dTheta = 0;
  8851. }
  8852. if (fs === 0 && dTheta > 0) {
  8853. dTheta = dTheta - 2 * PI;
  8854. }
  8855. if (fs === 1 && dTheta < 0) {
  8856. dTheta = dTheta + 2 * PI;
  8857. }
  8858. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  8859. }
  8860. function createPathProxyFromString(data) {
  8861. if (!data) {
  8862. return [];
  8863. }
  8864. // command string
  8865. var cs = data.replace(/-/g, ' -')
  8866. .replace(/ /g, ' ')
  8867. .replace(/ /g, ',')
  8868. .replace(/,,/g, ',');
  8869. var n;
  8870. // create pipes so that we can split the data
  8871. for (n = 0; n < cc.length; n++) {
  8872. cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  8873. }
  8874. // create array
  8875. var arr = cs.split('|');
  8876. // init context point
  8877. var cpx = 0;
  8878. var cpy = 0;
  8879. var path = new PathProxy();
  8880. var CMD = PathProxy.CMD;
  8881. var prevCmd;
  8882. for (n = 1; n < arr.length; n++) {
  8883. var str = arr[n];
  8884. var c = str.charAt(0);
  8885. var off = 0;
  8886. var p = str.slice(1).replace(/e,-/g, 'e-').split(',');
  8887. var cmd;
  8888. if (p.length > 0 && p[0] === '') {
  8889. p.shift();
  8890. }
  8891. for (var i = 0; i < p.length; i++) {
  8892. p[i] = parseFloat(p[i]);
  8893. }
  8894. while (off < p.length && !isNaN(p[off])) {
  8895. if (isNaN(p[0])) {
  8896. break;
  8897. }
  8898. var ctlPtx;
  8899. var ctlPty;
  8900. var rx;
  8901. var ry;
  8902. var psi;
  8903. var fa;
  8904. var fs;
  8905. var x1 = cpx;
  8906. var y1 = cpy;
  8907. // convert l, H, h, V, and v to L
  8908. switch (c) {
  8909. case 'l':
  8910. cpx += p[off++];
  8911. cpy += p[off++];
  8912. cmd = CMD.L;
  8913. path.addData(cmd, cpx, cpy);
  8914. break;
  8915. case 'L':
  8916. cpx = p[off++];
  8917. cpy = p[off++];
  8918. cmd = CMD.L;
  8919. path.addData(cmd, cpx, cpy);
  8920. break;
  8921. case 'm':
  8922. cpx += p[off++];
  8923. cpy += p[off++];
  8924. cmd = CMD.M;
  8925. path.addData(cmd, cpx, cpy);
  8926. c = 'l';
  8927. break;
  8928. case 'M':
  8929. cpx = p[off++];
  8930. cpy = p[off++];
  8931. cmd = CMD.M;
  8932. path.addData(cmd, cpx, cpy);
  8933. c = 'L';
  8934. break;
  8935. case 'h':
  8936. cpx += p[off++];
  8937. cmd = CMD.L;
  8938. path.addData(cmd, cpx, cpy);
  8939. break;
  8940. case 'H':
  8941. cpx = p[off++];
  8942. cmd = CMD.L;
  8943. path.addData(cmd, cpx, cpy);
  8944. break;
  8945. case 'v':
  8946. cpy += p[off++];
  8947. cmd = CMD.L;
  8948. path.addData(cmd, cpx, cpy);
  8949. break;
  8950. case 'V':
  8951. cpy = p[off++];
  8952. cmd = CMD.L;
  8953. path.addData(cmd, cpx, cpy);
  8954. break;
  8955. case 'C':
  8956. cmd = CMD.C;
  8957. path.addData(
  8958. cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]
  8959. );
  8960. cpx = p[off - 2];
  8961. cpy = p[off - 1];
  8962. break;
  8963. case 'c':
  8964. cmd = CMD.C;
  8965. path.addData(
  8966. cmd,
  8967. p[off++] + cpx, p[off++] + cpy,
  8968. p[off++] + cpx, p[off++] + cpy,
  8969. p[off++] + cpx, p[off++] + cpy
  8970. );
  8971. cpx += p[off - 2];
  8972. cpy += p[off - 1];
  8973. break;
  8974. case 'S':
  8975. ctlPtx = cpx;
  8976. ctlPty = cpy;
  8977. var len = path.len();
  8978. var pathData = path.data;
  8979. if (prevCmd === CMD.C) {
  8980. ctlPtx += cpx - pathData[len - 4];
  8981. ctlPty += cpy - pathData[len - 3];
  8982. }
  8983. cmd = CMD.C;
  8984. x1 = p[off++];
  8985. y1 = p[off++];
  8986. cpx = p[off++];
  8987. cpy = p[off++];
  8988. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  8989. break;
  8990. case 's':
  8991. ctlPtx = cpx;
  8992. ctlPty = cpy;
  8993. var len = path.len();
  8994. var pathData = path.data;
  8995. if (prevCmd === CMD.C) {
  8996. ctlPtx += cpx - pathData[len - 4];
  8997. ctlPty += cpy - pathData[len - 3];
  8998. }
  8999. cmd = CMD.C;
  9000. x1 = cpx + p[off++];
  9001. y1 = cpy + p[off++];
  9002. cpx += p[off++];
  9003. cpy += p[off++];
  9004. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  9005. break;
  9006. case 'Q':
  9007. x1 = p[off++];
  9008. y1 = p[off++];
  9009. cpx = p[off++];
  9010. cpy = p[off++];
  9011. cmd = CMD.Q;
  9012. path.addData(cmd, x1, y1, cpx, cpy);
  9013. break;
  9014. case 'q':
  9015. x1 = p[off++] + cpx;
  9016. y1 = p[off++] + cpy;
  9017. cpx += p[off++];
  9018. cpy += p[off++];
  9019. cmd = CMD.Q;
  9020. path.addData(cmd, x1, y1, cpx, cpy);
  9021. break;
  9022. case 'T':
  9023. ctlPtx = cpx;
  9024. ctlPty = cpy;
  9025. var len = path.len();
  9026. var pathData = path.data;
  9027. if (prevCmd === CMD.Q) {
  9028. ctlPtx += cpx - pathData[len - 4];
  9029. ctlPty += cpy - pathData[len - 3];
  9030. }
  9031. cpx = p[off++];
  9032. cpy = p[off++];
  9033. cmd = CMD.Q;
  9034. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  9035. break;
  9036. case 't':
  9037. ctlPtx = cpx;
  9038. ctlPty = cpy;
  9039. var len = path.len();
  9040. var pathData = path.data;
  9041. if (prevCmd === CMD.Q) {
  9042. ctlPtx += cpx - pathData[len - 4];
  9043. ctlPty += cpy - pathData[len - 3];
  9044. }
  9045. cpx += p[off++];
  9046. cpy += p[off++];
  9047. cmd = CMD.Q;
  9048. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  9049. break;
  9050. case 'A':
  9051. rx = p[off++];
  9052. ry = p[off++];
  9053. psi = p[off++];
  9054. fa = p[off++];
  9055. fs = p[off++];
  9056. x1 = cpx, y1 = cpy;
  9057. cpx = p[off++];
  9058. cpy = p[off++];
  9059. cmd = CMD.A;
  9060. processArc(
  9061. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  9062. );
  9063. break;
  9064. case 'a':
  9065. rx = p[off++];
  9066. ry = p[off++];
  9067. psi = p[off++];
  9068. fa = p[off++];
  9069. fs = p[off++];
  9070. x1 = cpx, y1 = cpy;
  9071. cpx += p[off++];
  9072. cpy += p[off++];
  9073. cmd = CMD.A;
  9074. processArc(
  9075. x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path
  9076. );
  9077. break;
  9078. }
  9079. }
  9080. if (c === 'z' || c === 'Z') {
  9081. cmd = CMD.Z;
  9082. path.addData(cmd);
  9083. }
  9084. prevCmd = cmd;
  9085. }
  9086. path.toStatic();
  9087. return path;
  9088. }
  9089. // TODO Optimize double memory cost problem
  9090. function createPathOptions(str, opts) {
  9091. var pathProxy = createPathProxyFromString(str);
  9092. var transform;
  9093. opts = opts || {};
  9094. opts.buildPath = function (path) {
  9095. path.setData(pathProxy.data);
  9096. transform && transformPath(path, transform);
  9097. // Svg and vml renderer don't have context
  9098. var ctx = path.getContext();
  9099. if (ctx) {
  9100. path.rebuildPath(ctx);
  9101. }
  9102. };
  9103. opts.applyTransform = function (m) {
  9104. if (!transform) {
  9105. transform = matrix.create();
  9106. }
  9107. matrix.mul(transform, m, transform);
  9108. };
  9109. return opts;
  9110. }
  9111. module.exports = {
  9112. /**
  9113. * Create a Path object from path string data
  9114. * http://www.w3.org/TR/SVG/paths.html#PathData
  9115. * @param {Object} opts Other options
  9116. */
  9117. createFromString: function (str, opts) {
  9118. return new Path(createPathOptions(str, opts));
  9119. },
  9120. /**
  9121. * Create a Path class from path string data
  9122. * @param {string} str
  9123. * @param {Object} opts Other options
  9124. */
  9125. extendFromString: function (str, opts) {
  9126. return Path.extend(createPathOptions(str, opts));
  9127. },
  9128. /**
  9129. * Merge multiple paths
  9130. */
  9131. // TODO Apply transform
  9132. // TODO stroke dash
  9133. // TODO Optimize double memory cost problem
  9134. mergePath: function (pathEls, opts) {
  9135. var pathList = [];
  9136. var len = pathEls.length;
  9137. var pathEl;
  9138. var i;
  9139. for (i = 0; i < len; i++) {
  9140. pathEl = pathEls[i];
  9141. if (pathEl.__dirty) {
  9142. pathEl.buildPath(pathEl.path, pathEl.shape);
  9143. }
  9144. pathList.push(pathEl.path);
  9145. }
  9146. var pathBundle = new Path(opts);
  9147. pathBundle.buildPath = function (path) {
  9148. path.appendPath(pathList);
  9149. // Svg and vml renderer don't have context
  9150. var ctx = path.getContext();
  9151. if (ctx) {
  9152. path.rebuildPath(ctx);
  9153. }
  9154. };
  9155. return pathBundle;
  9156. }
  9157. };
  9158. /***/ },
  9159. /* 44 */
  9160. /***/ function(module, exports, __webpack_require__) {
  9161. /**
  9162. * Path element
  9163. * @module zrender/graphic/Path
  9164. */
  9165. var Displayable = __webpack_require__(45);
  9166. var zrUtil = __webpack_require__(3);
  9167. var PathProxy = __webpack_require__(48);
  9168. var pathContain = __webpack_require__(51);
  9169. var Gradient = __webpack_require__(4);
  9170. function pathHasFill(style) {
  9171. var fill = style.fill;
  9172. return fill != null && fill !== 'none';
  9173. }
  9174. function pathHasStroke(style) {
  9175. var stroke = style.stroke;
  9176. return stroke != null && stroke !== 'none' && style.lineWidth > 0;
  9177. }
  9178. var abs = Math.abs;
  9179. /**
  9180. * @alias module:zrender/graphic/Path
  9181. * @extends module:zrender/graphic/Displayable
  9182. * @constructor
  9183. * @param {Object} opts
  9184. */
  9185. function Path(opts) {
  9186. Displayable.call(this, opts);
  9187. /**
  9188. * @type {module:zrender/core/PathProxy}
  9189. * @readOnly
  9190. */
  9191. this.path = new PathProxy();
  9192. }
  9193. Path.prototype = {
  9194. constructor: Path,
  9195. type: 'path',
  9196. __dirtyPath: true,
  9197. strokeContainThreshold: 5,
  9198. brush: function (ctx) {
  9199. ctx.save();
  9200. var style = this.style;
  9201. var path = this.path;
  9202. var hasStroke = pathHasStroke(style);
  9203. var hasFill = pathHasFill(style);
  9204. var hasFillGradient = hasFill && !!(style.fill.colorStops);
  9205. var hasStrokeGradient = hasStroke && !!(style.stroke.colorStops);
  9206. style.bind(ctx, this);
  9207. this.setTransform(ctx);
  9208. if (this.__dirtyPath) {
  9209. var rect = this.getBoundingRect();
  9210. // Update gradient because bounding rect may changed
  9211. if (hasFillGradient) {
  9212. this._fillGradient = style.getGradient(ctx, style.fill, rect);
  9213. }
  9214. if (hasStrokeGradient) {
  9215. this._strokeGradient = style.getGradient(ctx, style.stroke, rect);
  9216. }
  9217. }
  9218. // Use the gradient
  9219. if (hasFillGradient) {
  9220. ctx.fillStyle = this._fillGradient;
  9221. }
  9222. if (hasStrokeGradient) {
  9223. ctx.strokeStyle = this._strokeGradient;
  9224. }
  9225. var lineDash = style.lineDash;
  9226. var lineDashOffset = style.lineDashOffset;
  9227. var ctxLineDash = !!ctx.setLineDash;
  9228. // Update path sx, sy
  9229. var scale = this.getGlobalScale();
  9230. path.setScale(scale[0], scale[1]);
  9231. // Proxy context
  9232. // Rebuild path in following 2 cases
  9233. // 1. Path is dirty
  9234. // 2. Path needs javascript implemented lineDash stroking.
  9235. // In this case, lineDash information will not be saved in PathProxy
  9236. if (this.__dirtyPath || (
  9237. lineDash && !ctxLineDash && hasStroke
  9238. )) {
  9239. path = this.path.beginPath(ctx);
  9240. // Setting line dash before build path
  9241. if (lineDash && !ctxLineDash) {
  9242. path.setLineDash(lineDash);
  9243. path.setLineDashOffset(lineDashOffset);
  9244. }
  9245. this.buildPath(path, this.shape);
  9246. // Clear path dirty flag
  9247. this.__dirtyPath = false;
  9248. }
  9249. else {
  9250. // Replay path building
  9251. ctx.beginPath();
  9252. this.path.rebuildPath(ctx);
  9253. }
  9254. hasFill && path.fill(ctx);
  9255. if (lineDash && ctxLineDash) {
  9256. ctx.setLineDash(lineDash);
  9257. ctx.lineDashOffset = lineDashOffset;
  9258. }
  9259. hasStroke && path.stroke(ctx);
  9260. // Draw rect text
  9261. if (style.text != null) {
  9262. // var rect = this.getBoundingRect();
  9263. this.drawRectText(ctx, this.getBoundingRect());
  9264. }
  9265. ctx.restore();
  9266. },
  9267. buildPath: function (ctx, shapeCfg) {},
  9268. getBoundingRect: function () {
  9269. var rect = this._rect;
  9270. var style = this.style;
  9271. var needsUpdateRect = !rect;
  9272. if (needsUpdateRect) {
  9273. var path = this.path;
  9274. if (this.__dirtyPath) {
  9275. path.beginPath();
  9276. this.buildPath(path, this.shape);
  9277. }
  9278. rect = path.getBoundingRect();
  9279. }
  9280. this._rect = rect;
  9281. if (pathHasStroke(style)) {
  9282. // Needs update rect with stroke lineWidth when
  9283. // 1. Element changes scale or lineWidth
  9284. // 2. Shape is changed
  9285. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  9286. if (this.__dirty || needsUpdateRect) {
  9287. rectWithStroke.copy(rect);
  9288. // FIXME Must after updateTransform
  9289. var w = style.lineWidth;
  9290. // PENDING, Min line width is needed when line is horizontal or vertical
  9291. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  9292. // Only add extra hover lineWidth when there are no fill
  9293. if (!pathHasFill(style)) {
  9294. w = Math.max(w, this.strokeContainThreshold);
  9295. }
  9296. // Consider line width
  9297. // Line scale can't be 0;
  9298. if (lineScale > 1e-10) {
  9299. rectWithStroke.width += w / lineScale;
  9300. rectWithStroke.height += w / lineScale;
  9301. rectWithStroke.x -= w / lineScale / 2;
  9302. rectWithStroke.y -= w / lineScale / 2;
  9303. }
  9304. }
  9305. // Return rect with stroke
  9306. return rectWithStroke;
  9307. }
  9308. return rect;
  9309. },
  9310. contain: function (x, y) {
  9311. var localPos = this.transformCoordToLocal(x, y);
  9312. var rect = this.getBoundingRect();
  9313. var style = this.style;
  9314. x = localPos[0];
  9315. y = localPos[1];
  9316. if (rect.contain(x, y)) {
  9317. var pathData = this.path.data;
  9318. if (pathHasStroke(style)) {
  9319. var lineWidth = style.lineWidth;
  9320. var lineScale = style.strokeNoScale ? this.getLineScale() : 1;
  9321. // Line scale can't be 0;
  9322. if (lineScale > 1e-10) {
  9323. // Only add extra hover lineWidth when there are no fill
  9324. if (!pathHasFill(style)) {
  9325. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  9326. }
  9327. if (pathContain.containStroke(
  9328. pathData, lineWidth / lineScale, x, y
  9329. )) {
  9330. return true;
  9331. }
  9332. }
  9333. }
  9334. if (pathHasFill(style)) {
  9335. return pathContain.contain(pathData, x, y);
  9336. }
  9337. }
  9338. return false;
  9339. },
  9340. /**
  9341. * @param {boolean} dirtyPath
  9342. */
  9343. dirty: function (dirtyPath) {
  9344. if (arguments.length ===0) {
  9345. dirtyPath = true;
  9346. }
  9347. // Only mark dirty, not mark clean
  9348. if (dirtyPath) {
  9349. this.__dirtyPath = dirtyPath;
  9350. this._rect = null;
  9351. }
  9352. this.__dirty = true;
  9353. this.__zr && this.__zr.refresh();
  9354. // Used as a clipping path
  9355. if (this.__clipTarget) {
  9356. this.__clipTarget.dirty();
  9357. }
  9358. },
  9359. /**
  9360. * Alias for animate('shape')
  9361. * @param {boolean} loop
  9362. */
  9363. animateShape: function (loop) {
  9364. return this.animate('shape', loop);
  9365. },
  9366. // Overwrite attrKV
  9367. attrKV: function (key, value) {
  9368. // FIXME
  9369. if (key === 'shape') {
  9370. this.setShape(value);
  9371. }
  9372. else {
  9373. Displayable.prototype.attrKV.call(this, key, value);
  9374. }
  9375. },
  9376. /**
  9377. * @param {Object|string} key
  9378. * @param {*} value
  9379. */
  9380. setShape: function (key, value) {
  9381. var shape = this.shape;
  9382. // Path from string may not have shape
  9383. if (shape) {
  9384. if (zrUtil.isObject(key)) {
  9385. for (var name in key) {
  9386. shape[name] = key[name];
  9387. }
  9388. }
  9389. else {
  9390. shape[key] = value;
  9391. }
  9392. this.dirty(true);
  9393. }
  9394. return this;
  9395. },
  9396. getLineScale: function () {
  9397. var m = this.transform;
  9398. // Get the line scale.
  9399. // Determinant of `m` means how much the area is enlarged by the
  9400. // transformation. So its square root can be used as a scale factor
  9401. // for width.
  9402. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10
  9403. ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1]))
  9404. : 1;
  9405. }
  9406. };
  9407. /**
  9408. * 扩展一个 Path element, 比如星形,圆等。
  9409. * Extend a path element
  9410. * @param {Object} props
  9411. * @param {string} props.type Path type
  9412. * @param {Function} props.init Initialize
  9413. * @param {Function} props.buildPath Overwrite buildPath method
  9414. * @param {Object} [props.style] Extended default style config
  9415. * @param {Object} [props.shape] Extended default shape config
  9416. */
  9417. Path.extend = function (defaults) {
  9418. var Sub = function (opts) {
  9419. Path.call(this, opts);
  9420. if (defaults.style) {
  9421. // Extend default style
  9422. this.style.extendFrom(defaults.style, false);
  9423. }
  9424. // Extend default shape
  9425. var defaultShape = defaults.shape;
  9426. if (defaultShape) {
  9427. this.shape = this.shape || {};
  9428. var thisShape = this.shape;
  9429. for (var name in defaultShape) {
  9430. if (
  9431. ! thisShape.hasOwnProperty(name)
  9432. && defaultShape.hasOwnProperty(name)
  9433. ) {
  9434. thisShape[name] = defaultShape[name];
  9435. }
  9436. }
  9437. }
  9438. defaults.init && defaults.init.call(this, opts);
  9439. };
  9440. zrUtil.inherits(Sub, Path);
  9441. // FIXME 不能 extend position, rotation 等引用对象
  9442. for (var name in defaults) {
  9443. // Extending prototype values and methods
  9444. if (name !== 'style' && name !== 'shape') {
  9445. Sub.prototype[name] = defaults[name];
  9446. }
  9447. }
  9448. return Sub;
  9449. };
  9450. zrUtil.inherits(Path, Displayable);
  9451. module.exports = Path;
  9452. /***/ },
  9453. /* 45 */
  9454. /***/ function(module, exports, __webpack_require__) {
  9455. /**
  9456. * 可绘制的图形基类
  9457. * Base class of all displayable graphic objects
  9458. * @module zrender/graphic/Displayable
  9459. */
  9460. var zrUtil = __webpack_require__(3);
  9461. var Style = __webpack_require__(46);
  9462. var Element = __webpack_require__(30);
  9463. var RectText = __webpack_require__(47);
  9464. // var Stateful = require('./mixin/Stateful');
  9465. /**
  9466. * @alias module:zrender/graphic/Displayable
  9467. * @extends module:zrender/Element
  9468. * @extends module:zrender/graphic/mixin/RectText
  9469. */
  9470. function Displayable(opts) {
  9471. opts = opts || {};
  9472. Element.call(this, opts);
  9473. // Extend properties
  9474. for (var name in opts) {
  9475. if (
  9476. opts.hasOwnProperty(name) &&
  9477. name !== 'style'
  9478. ) {
  9479. this[name] = opts[name];
  9480. }
  9481. }
  9482. /**
  9483. * @type {module:zrender/graphic/Style}
  9484. */
  9485. this.style = new Style(opts.style);
  9486. this._rect = null;
  9487. // Shapes for cascade clipping.
  9488. this.__clipPaths = [];
  9489. // FIXME Stateful must be mixined after style is setted
  9490. // Stateful.call(this, opts);
  9491. }
  9492. Displayable.prototype = {
  9493. constructor: Displayable,
  9494. type: 'displayable',
  9495. /**
  9496. * Displayable 是否为脏,Painter 中会根据该标记判断是否需要是否需要重新绘制
  9497. * Dirty flag. From which painter will determine if this displayable object needs brush
  9498. * @name module:zrender/graphic/Displayable#__dirty
  9499. * @type {boolean}
  9500. */
  9501. __dirty: true,
  9502. /**
  9503. * 图形是否可见,为true时不绘制图形,但是仍能触发鼠标事件
  9504. * If ignore drawing of the displayable object. Mouse event will still be triggered
  9505. * @name module:/zrender/graphic/Displayable#invisible
  9506. * @type {boolean}
  9507. * @default false
  9508. */
  9509. invisible: false,
  9510. /**
  9511. * @name module:/zrender/graphic/Displayable#z
  9512. * @type {number}
  9513. * @default 0
  9514. */
  9515. z: 0,
  9516. /**
  9517. * @name module:/zrender/graphic/Displayable#z
  9518. * @type {number}
  9519. * @default 0
  9520. */
  9521. z2: 0,
  9522. /**
  9523. * z层level,决定绘画在哪层canvas中
  9524. * @name module:/zrender/graphic/Displayable#zlevel
  9525. * @type {number}
  9526. * @default 0
  9527. */
  9528. zlevel: 0,
  9529. /**
  9530. * 是否可拖拽
  9531. * @name module:/zrender/graphic/Displayable#draggable
  9532. * @type {boolean}
  9533. * @default false
  9534. */
  9535. draggable: false,
  9536. /**
  9537. * 是否正在拖拽
  9538. * @name module:/zrender/graphic/Displayable#draggable
  9539. * @type {boolean}
  9540. * @default false
  9541. */
  9542. dragging: false,
  9543. /**
  9544. * 是否相应鼠标事件
  9545. * @name module:/zrender/graphic/Displayable#silent
  9546. * @type {boolean}
  9547. * @default false
  9548. */
  9549. silent: false,
  9550. /**
  9551. * If enable culling
  9552. * @type {boolean}
  9553. * @default false
  9554. */
  9555. culling: false,
  9556. /**
  9557. * Mouse cursor when hovered
  9558. * @name module:/zrender/graphic/Displayable#cursor
  9559. * @type {string}
  9560. */
  9561. cursor: 'pointer',
  9562. /**
  9563. * If hover area is bounding rect
  9564. * @name module:/zrender/graphic/Displayable#rectHover
  9565. * @type {string}
  9566. */
  9567. rectHover: false,
  9568. beforeBrush: function (ctx) {},
  9569. afterBrush: function (ctx) {},
  9570. /**
  9571. * 图形绘制方法
  9572. * @param {Canvas2DRenderingContext} ctx
  9573. */
  9574. // Interface
  9575. brush: function (ctx) {},
  9576. /**
  9577. * 获取最小包围盒
  9578. * @return {module:zrender/core/BoundingRect}
  9579. */
  9580. // Interface
  9581. getBoundingRect: function () {},
  9582. /**
  9583. * 判断坐标 x, y 是否在图形上
  9584. * If displayable element contain coord x, y
  9585. * @param {number} x
  9586. * @param {number} y
  9587. * @return {boolean}
  9588. */
  9589. contain: function (x, y) {
  9590. return this.rectContain(x, y);
  9591. },
  9592. /**
  9593. * @param {Function} cb
  9594. * @param {} context
  9595. */
  9596. traverse: function (cb, context) {
  9597. cb.call(context, this);
  9598. },
  9599. /**
  9600. * 判断坐标 x, y 是否在图形的包围盒上
  9601. * If bounding rect of element contain coord x, y
  9602. * @param {number} x
  9603. * @param {number} y
  9604. * @return {boolean}
  9605. */
  9606. rectContain: function (x, y) {
  9607. var coord = this.transformCoordToLocal(x, y);
  9608. var rect = this.getBoundingRect();
  9609. return rect.contain(coord[0], coord[1]);
  9610. },
  9611. /**
  9612. * 标记图形元素为脏,并且在下一帧重绘
  9613. * Mark displayable element dirty and refresh next frame
  9614. */
  9615. dirty: function () {
  9616. this.__dirty = true;
  9617. this._rect = null;
  9618. this.__zr && this.__zr.refresh();
  9619. },
  9620. /**
  9621. * 图形是否会触发事件
  9622. * If displayable object binded any event
  9623. * @return {boolean}
  9624. */
  9625. // TODO, 通过 bind 绑定的事件
  9626. // isSilent: function () {
  9627. // return !(
  9628. // this.hoverable || this.draggable
  9629. // || this.onmousemove || this.onmouseover || this.onmouseout
  9630. // || this.onmousedown || this.onmouseup || this.onclick
  9631. // || this.ondragenter || this.ondragover || this.ondragleave
  9632. // || this.ondrop
  9633. // );
  9634. // },
  9635. /**
  9636. * Alias for animate('style')
  9637. * @param {boolean} loop
  9638. */
  9639. animateStyle: function (loop) {
  9640. return this.animate('style', loop);
  9641. },
  9642. attrKV: function (key, value) {
  9643. if (key !== 'style') {
  9644. Element.prototype.attrKV.call(this, key, value);
  9645. }
  9646. else {
  9647. this.style.set(value);
  9648. }
  9649. },
  9650. /**
  9651. * @param {Object|string} key
  9652. * @param {*} value
  9653. */
  9654. setStyle: function (key, value) {
  9655. this.style.set(key, value);
  9656. this.dirty(false);
  9657. return this;
  9658. },
  9659. /**
  9660. * Use given style object
  9661. * @param {Object} obj
  9662. */
  9663. useStyle: function (obj) {
  9664. this.style = new Style(obj);
  9665. this.dirty(false);
  9666. return this;
  9667. }
  9668. };
  9669. zrUtil.inherits(Displayable, Element);
  9670. zrUtil.mixin(Displayable, RectText);
  9671. // zrUtil.mixin(Displayable, Stateful);
  9672. module.exports = Displayable;
  9673. /***/ },
  9674. /* 46 */
  9675. /***/ function(module, exports) {
  9676. /**
  9677. * @module zrender/graphic/Style
  9678. */
  9679. var STYLE_LIST_COMMON = [
  9680. 'lineCap', 'lineJoin', 'miterLimit',
  9681. 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'shadowColor'
  9682. ];
  9683. var Style = function (opts) {
  9684. this.extendFrom(opts);
  9685. };
  9686. Style.prototype = {
  9687. constructor: Style,
  9688. /**
  9689. * @type {string}
  9690. */
  9691. fill: '#000000',
  9692. /**
  9693. * @type {string}
  9694. */
  9695. stroke: null,
  9696. /**
  9697. * @type {number}
  9698. */
  9699. opacity: 1,
  9700. /**
  9701. * @type {Array.<number>}
  9702. */
  9703. lineDash: null,
  9704. /**
  9705. * @type {number}
  9706. */
  9707. lineDashOffset: 0,
  9708. /**
  9709. * @type {number}
  9710. */
  9711. shadowBlur: 0,
  9712. /**
  9713. * @type {number}
  9714. */
  9715. shadowOffsetX: 0,
  9716. /**
  9717. * @type {number}
  9718. */
  9719. shadowOffsetY: 0,
  9720. /**
  9721. * @type {number}
  9722. */
  9723. lineWidth: 1,
  9724. /**
  9725. * If stroke ignore scale
  9726. * @type {Boolean}
  9727. */
  9728. strokeNoScale: false,
  9729. // Bounding rect text configuration
  9730. // Not affected by element transform
  9731. /**
  9732. * @type {string}
  9733. */
  9734. text: null,
  9735. /**
  9736. * @type {string}
  9737. */
  9738. textFill: '#000',
  9739. /**
  9740. * @type {string}
  9741. */
  9742. textStroke: null,
  9743. /**
  9744. * 'inside', 'left', 'right', 'top', 'bottom'
  9745. * [x, y]
  9746. * @type {string|Array.<number>}
  9747. * @default 'inside'
  9748. */
  9749. textPosition: 'inside',
  9750. /**
  9751. * @type {string}
  9752. */
  9753. textBaseline: null,
  9754. /**
  9755. * @type {string}
  9756. */
  9757. textAlign: null,
  9758. /**
  9759. * @type {string}
  9760. */
  9761. textVerticalAlign: null,
  9762. /**
  9763. * @type {number}
  9764. */
  9765. textDistance: 5,
  9766. /**
  9767. * @type {number}
  9768. */
  9769. textShadowBlur: 0,
  9770. /**
  9771. * @type {number}
  9772. */
  9773. textShadowOffsetX: 0,
  9774. /**
  9775. * @type {number}
  9776. */
  9777. textShadowOffsetY: 0,
  9778. /**
  9779. * @param {CanvasRenderingContext2D} ctx
  9780. */
  9781. bind: function (ctx, el) {
  9782. var fill = this.fill;
  9783. var stroke = this.stroke;
  9784. for (var i = 0; i < STYLE_LIST_COMMON.length; i++) {
  9785. var styleName = STYLE_LIST_COMMON[i];
  9786. if (this[styleName] != null) {
  9787. ctx[styleName] = this[styleName];
  9788. }
  9789. }
  9790. if (stroke != null) {
  9791. var lineWidth = this.lineWidth;
  9792. ctx.lineWidth = lineWidth / (
  9793. (this.strokeNoScale && el && el.getLineScale) ? el.getLineScale() : 1
  9794. );
  9795. }
  9796. // Gradient will be created and set in Path#brush. So ignore it here
  9797. if (fill != null && fill !== 'none' && !fill.colorStops) {
  9798. ctx.fillStyle = fill;
  9799. }
  9800. if (stroke != null && stroke !== 'none' && !stroke.colorStops) {
  9801. // Use canvas gradient if has
  9802. ctx.strokeStyle = stroke;
  9803. }
  9804. this.opacity != null && (ctx.globalAlpha = this.opacity);
  9805. },
  9806. /**
  9807. * Extend from other style
  9808. * @param {zrender/graphic/Style} otherStyle
  9809. * @param {boolean} overwrite
  9810. */
  9811. extendFrom: function (otherStyle, overwrite) {
  9812. if (otherStyle) {
  9813. var target = this;
  9814. for (var name in otherStyle) {
  9815. if (otherStyle.hasOwnProperty(name)
  9816. && (overwrite || ! target.hasOwnProperty(name))
  9817. ) {
  9818. target[name] = otherStyle[name];
  9819. }
  9820. }
  9821. }
  9822. },
  9823. /**
  9824. * Batch setting style with a given object
  9825. * @param {Object|string} obj
  9826. * @param {*} [obj]
  9827. */
  9828. set: function (obj, value) {
  9829. if (typeof obj === 'string') {
  9830. this[obj] = value;
  9831. }
  9832. else {
  9833. this.extendFrom(obj, true);
  9834. }
  9835. },
  9836. /**
  9837. * Clone
  9838. * @return {zrender/graphic/Style} [description]
  9839. */
  9840. clone: function () {
  9841. var newStyle = new this.constructor();
  9842. newStyle.extendFrom(this, true);
  9843. return newStyle;
  9844. },
  9845. createLinearGradient: function (ctx, obj, rect) {
  9846. // var size =
  9847. var x = obj.x * rect.width + rect.x;
  9848. var x2 = obj.x2 * rect.width + rect.x;
  9849. var y = obj.y * rect.height + rect.y;
  9850. var y2 = obj.y2 * rect.height + rect.y;
  9851. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  9852. return canvasGradient;
  9853. },
  9854. createRadialGradient: function (ctx, obj, rect) {
  9855. var width = rect.width;
  9856. var height = rect.height;
  9857. var min = Math.min(width, height);
  9858. var x = obj.x * width + rect.x;
  9859. var y = obj.y * height + rect.y;
  9860. var r = obj.r * min;
  9861. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  9862. return canvasGradient;
  9863. },
  9864. getGradient: function (ctx, obj, rect) {
  9865. var method = obj.type === 'radial' ? 'createRadialGradient' : 'createLinearGradient';
  9866. var canvasGradient = this[method](ctx, obj, rect);
  9867. var colorStops = obj.colorStops;
  9868. for (var i = 0; i < colorStops.length; i++) {
  9869. canvasGradient.addColorStop(
  9870. colorStops[i].offset, colorStops[i].color
  9871. );
  9872. }
  9873. return canvasGradient;
  9874. }
  9875. };
  9876. var styleProto = Style.prototype;
  9877. var name;
  9878. var i;
  9879. for (i = 0; i < STYLE_LIST_COMMON.length; i++) {
  9880. name = STYLE_LIST_COMMON[i];
  9881. if (!(name in styleProto)) {
  9882. styleProto[name] = null;
  9883. }
  9884. }
  9885. module.exports = Style;
  9886. /***/ },
  9887. /* 47 */
  9888. /***/ function(module, exports, __webpack_require__) {
  9889. /**
  9890. * Mixin for drawing text in a element bounding rect
  9891. * @module zrender/mixin/RectText
  9892. */
  9893. var textContain = __webpack_require__(14);
  9894. var BoundingRect = __webpack_require__(15);
  9895. var tmpRect = new BoundingRect();
  9896. var RectText = function () {};
  9897. function parsePercent(value, maxValue) {
  9898. if (typeof value === 'string') {
  9899. if (value.lastIndexOf('%') >= 0) {
  9900. return parseFloat(value) / 100 * maxValue;
  9901. }
  9902. return parseFloat(value);
  9903. }
  9904. return value;
  9905. }
  9906. function setTransform(ctx, m) {
  9907. ctx.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
  9908. }
  9909. RectText.prototype = {
  9910. constructor: RectText,
  9911. /**
  9912. * Draw text in a rect with specified position.
  9913. * @param {CanvasRenderingContext} ctx
  9914. * @param {Object} rect Displayable rect
  9915. * @return {Object} textRect Alternative precalculated text bounding rect
  9916. */
  9917. drawRectText: function (ctx, rect, textRect) {
  9918. var style = this.style;
  9919. var text = style.text;
  9920. // Convert to string
  9921. text != null && (text += '');
  9922. if (!text) {
  9923. return;
  9924. }
  9925. var x;
  9926. var y;
  9927. var textPosition = style.textPosition;
  9928. var distance = style.textDistance;
  9929. var align = style.textAlign;
  9930. var font = style.textFont || style.font;
  9931. var baseline = style.textBaseline;
  9932. var verticalAlign = style.textVerticalAlign;
  9933. textRect = textRect || textContain.getBoundingRect(text, font, align, baseline);
  9934. // Transform rect to view space
  9935. var transform = this.transform;
  9936. var invTransform = this.invTransform;
  9937. if (transform) {
  9938. tmpRect.copy(rect);
  9939. tmpRect.applyTransform(transform);
  9940. rect = tmpRect;
  9941. // Transform back
  9942. setTransform(ctx, invTransform);
  9943. }
  9944. // Text position represented by coord
  9945. if (textPosition instanceof Array) {
  9946. // Percent
  9947. x = rect.x + parsePercent(textPosition[0], rect.width);
  9948. y = rect.y + parsePercent(textPosition[1], rect.height);
  9949. align = align || 'left';
  9950. baseline = baseline || 'top';
  9951. if (verticalAlign) {
  9952. switch (verticalAlign) {
  9953. case 'middle':
  9954. y -= textRect.height / 2 - textRect.lineHeight / 2;
  9955. break;
  9956. case 'bottom':
  9957. y -= textRect.height - textRect.lineHeight / 2;
  9958. break;
  9959. default:
  9960. y += textRect.lineHeight / 2;
  9961. }
  9962. // Force bseline to be middle
  9963. baseline = 'middle';
  9964. }
  9965. }
  9966. else {
  9967. var res = textContain.adjustTextPositionOnRect(
  9968. textPosition, rect, textRect, distance
  9969. );
  9970. x = res.x;
  9971. y = res.y;
  9972. // Default align and baseline when has textPosition
  9973. align = align || res.textAlign;
  9974. baseline = baseline || res.textBaseline;
  9975. }
  9976. ctx.textAlign = align;
  9977. ctx.textBaseline = baseline;
  9978. var textFill = style.textFill;
  9979. var textStroke = style.textStroke;
  9980. textFill && (ctx.fillStyle = textFill);
  9981. textStroke && (ctx.strokeStyle = textStroke);
  9982. ctx.font = font;
  9983. // Text shadow
  9984. ctx.shadowColor = style.textShadowColor;
  9985. ctx.shadowBlur = style.textShadowBlur;
  9986. ctx.shadowOffsetX = style.textShadowOffsetX;
  9987. ctx.shadowOffsetY = style.textShadowOffsetY;
  9988. var textLines = text.split('\n');
  9989. for (var i = 0; i < textLines.length; i++) {
  9990. textFill && ctx.fillText(textLines[i], x, y);
  9991. textStroke && ctx.strokeText(textLines[i], x, y);
  9992. y += textRect.lineHeight;
  9993. }
  9994. // Transform again
  9995. transform && setTransform(ctx, transform);
  9996. }
  9997. };
  9998. module.exports = RectText;
  9999. /***/ },
  10000. /* 48 */
  10001. /***/ function(module, exports, __webpack_require__) {
  10002. 'use strict';
  10003. /**
  10004. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  10005. * 可以用于 isInsidePath 判断以及获取boundingRect
  10006. *
  10007. * @module zrender/core/PathProxy
  10008. * @author Yi Shen (http://www.github.com/pissang)
  10009. */
  10010. // TODO getTotalLength, getPointAtLength
  10011. var curve = __webpack_require__(49);
  10012. var vec2 = __webpack_require__(16);
  10013. var bbox = __webpack_require__(50);
  10014. var BoundingRect = __webpack_require__(15);
  10015. var dpr = __webpack_require__(40).devicePixelRatio;
  10016. var CMD = {
  10017. M: 1,
  10018. L: 2,
  10019. C: 3,
  10020. Q: 4,
  10021. A: 5,
  10022. Z: 6,
  10023. // Rect
  10024. R: 7
  10025. };
  10026. var min = [];
  10027. var max = [];
  10028. var min2 = [];
  10029. var max2 = [];
  10030. var mathMin = Math.min;
  10031. var mathMax = Math.max;
  10032. var mathCos = Math.cos;
  10033. var mathSin = Math.sin;
  10034. var mathSqrt = Math.sqrt;
  10035. var mathAbs = Math.abs;
  10036. var hasTypedArray = typeof Float32Array != 'undefined';
  10037. /**
  10038. * @alias module:zrender/core/PathProxy
  10039. * @constructor
  10040. */
  10041. var PathProxy = function () {
  10042. /**
  10043. * Path data. Stored as flat array
  10044. * @type {Array.<Object>}
  10045. */
  10046. this.data = [];
  10047. this._len = 0;
  10048. this._ctx = null;
  10049. this._xi = 0;
  10050. this._yi = 0;
  10051. this._x0 = 0;
  10052. this._y0 = 0;
  10053. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  10054. this._ux = 0;
  10055. this._uy = 0;
  10056. };
  10057. /**
  10058. * 快速计算Path包围盒(并不是最小包围盒)
  10059. * @return {Object}
  10060. */
  10061. PathProxy.prototype = {
  10062. constructor: PathProxy,
  10063. _lineDash: null,
  10064. _dashOffset: 0,
  10065. _dashIdx: 0,
  10066. _dashSum: 0,
  10067. /**
  10068. * @readOnly
  10069. */
  10070. setScale: function (sx, sy) {
  10071. this._ux = mathAbs(1 / dpr / sx) || 0;
  10072. this._uy = mathAbs(1 / dpr / sy) || 0;
  10073. },
  10074. getContext: function () {
  10075. return this._ctx;
  10076. },
  10077. /**
  10078. * @param {CanvasRenderingContext2D} ctx
  10079. * @return {module:zrender/core/PathProxy}
  10080. */
  10081. beginPath: function (ctx) {
  10082. this._ctx = ctx;
  10083. ctx && ctx.beginPath();
  10084. // Reset
  10085. this._len = 0;
  10086. if (this._lineDash) {
  10087. this._lineDash = null;
  10088. this._dashOffset = 0;
  10089. }
  10090. return this;
  10091. },
  10092. /**
  10093. * @param {number} x
  10094. * @param {number} y
  10095. * @return {module:zrender/core/PathProxy}
  10096. */
  10097. moveTo: function (x, y) {
  10098. this.addData(CMD.M, x, y);
  10099. this._ctx && this._ctx.moveTo(x, y);
  10100. // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  10101. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  10102. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  10103. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  10104. this._x0 = x;
  10105. this._y0 = y;
  10106. this._xi = x;
  10107. this._yi = y;
  10108. return this;
  10109. },
  10110. /**
  10111. * @param {number} x
  10112. * @param {number} y
  10113. * @return {module:zrender/core/PathProxy}
  10114. */
  10115. lineTo: function (x, y) {
  10116. var exceedUnit = mathAbs(x - this._xi) > this._ux
  10117. || mathAbs(y - this._yi) > this._uy
  10118. // Force draw the first segment
  10119. || this._len === 0;
  10120. this.addData(CMD.L, x, y);
  10121. if (this._ctx && exceedUnit) {
  10122. this._needsDash() ? this._dashedLineTo(x, y)
  10123. : this._ctx.lineTo(x, y);
  10124. }
  10125. if (exceedUnit) {
  10126. this._xi = x;
  10127. this._yi = y;
  10128. }
  10129. return this;
  10130. },
  10131. /**
  10132. * @param {number} x1
  10133. * @param {number} y1
  10134. * @param {number} x2
  10135. * @param {number} y2
  10136. * @param {number} x3
  10137. * @param {number} y3
  10138. * @return {module:zrender/core/PathProxy}
  10139. */
  10140. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  10141. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  10142. if (this._ctx) {
  10143. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3)
  10144. : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  10145. }
  10146. this._xi = x3;
  10147. this._yi = y3;
  10148. return this;
  10149. },
  10150. /**
  10151. * @param {number} x1
  10152. * @param {number} y1
  10153. * @param {number} x2
  10154. * @param {number} y2
  10155. * @return {module:zrender/core/PathProxy}
  10156. */
  10157. quadraticCurveTo: function (x1, y1, x2, y2) {
  10158. this.addData(CMD.Q, x1, y1, x2, y2);
  10159. if (this._ctx) {
  10160. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2)
  10161. : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  10162. }
  10163. this._xi = x2;
  10164. this._yi = y2;
  10165. return this;
  10166. },
  10167. /**
  10168. * @param {number} cx
  10169. * @param {number} cy
  10170. * @param {number} r
  10171. * @param {number} startAngle
  10172. * @param {number} endAngle
  10173. * @param {boolean} anticlockwise
  10174. * @return {module:zrender/core/PathProxy}
  10175. */
  10176. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  10177. this.addData(
  10178. CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1
  10179. );
  10180. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  10181. this._xi = mathCos(endAngle) * r + cx;
  10182. this._xi = mathSin(endAngle) * r + cx;
  10183. return this;
  10184. },
  10185. // TODO
  10186. arcTo: function (x1, y1, x2, y2, radius) {
  10187. if (this._ctx) {
  10188. this._ctx.arcTo(x1, y1, x2, y2, radius);
  10189. }
  10190. return this;
  10191. },
  10192. // TODO
  10193. rect: function (x, y, w, h) {
  10194. this._ctx && this._ctx.rect(x, y, w, h);
  10195. this.addData(CMD.R, x, y, w, h);
  10196. return this;
  10197. },
  10198. /**
  10199. * @return {module:zrender/core/PathProxy}
  10200. */
  10201. closePath: function () {
  10202. this.addData(CMD.Z);
  10203. var ctx = this._ctx;
  10204. var x0 = this._x0;
  10205. var y0 = this._y0;
  10206. if (ctx) {
  10207. this._needsDash() && this._dashedLineTo(x0, y0);
  10208. ctx.closePath();
  10209. }
  10210. this._xi = x0;
  10211. this._yi = y0;
  10212. return this;
  10213. },
  10214. /**
  10215. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  10216. * stroke 同样
  10217. * @param {CanvasRenderingContext2D} ctx
  10218. * @return {module:zrender/core/PathProxy}
  10219. */
  10220. fill: function (ctx) {
  10221. ctx && ctx.fill();
  10222. this.toStatic();
  10223. },
  10224. /**
  10225. * @param {CanvasRenderingContext2D} ctx
  10226. * @return {module:zrender/core/PathProxy}
  10227. */
  10228. stroke: function (ctx) {
  10229. ctx && ctx.stroke();
  10230. this.toStatic();
  10231. },
  10232. /**
  10233. * 必须在其它绘制命令前调用
  10234. * Must be invoked before all other path drawing methods
  10235. * @return {module:zrender/core/PathProxy}
  10236. */
  10237. setLineDash: function (lineDash) {
  10238. if (lineDash instanceof Array) {
  10239. this._lineDash = lineDash;
  10240. this._dashIdx = 0;
  10241. var lineDashSum = 0;
  10242. for (var i = 0; i < lineDash.length; i++) {
  10243. lineDashSum += lineDash[i];
  10244. }
  10245. this._dashSum = lineDashSum;
  10246. }
  10247. return this;
  10248. },
  10249. /**
  10250. * 必须在其它绘制命令前调用
  10251. * Must be invoked before all other path drawing methods
  10252. * @return {module:zrender/core/PathProxy}
  10253. */
  10254. setLineDashOffset: function (offset) {
  10255. this._dashOffset = offset;
  10256. return this;
  10257. },
  10258. /**
  10259. *
  10260. * @return {boolean}
  10261. */
  10262. len: function () {
  10263. return this._len;
  10264. },
  10265. /**
  10266. * 直接设置 Path 数据
  10267. */
  10268. setData: function (data) {
  10269. var len = data.length;
  10270. if (! (this.data && this.data.length == len) && hasTypedArray) {
  10271. this.data = new Float32Array(len);
  10272. }
  10273. for (var i = 0; i < len; i++) {
  10274. this.data[i] = data[i];
  10275. }
  10276. this._len = len;
  10277. },
  10278. /**
  10279. * 添加子路径
  10280. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  10281. */
  10282. appendPath: function (path) {
  10283. if (!(path instanceof Array)) {
  10284. path = [path];
  10285. }
  10286. var len = path.length;
  10287. var appendSize = 0;
  10288. var offset = this._len;
  10289. for (var i = 0; i < len; i++) {
  10290. appendSize += path[i].len();
  10291. }
  10292. if (hasTypedArray && (this.data instanceof Float32Array)) {
  10293. this.data = new Float32Array(offset + appendSize);
  10294. }
  10295. for (var i = 0; i < len; i++) {
  10296. var appendPathData = path[i].data;
  10297. for (var k = 0; k < appendPathData.length; k++) {
  10298. this.data[offset++] = appendPathData[k];
  10299. }
  10300. }
  10301. this._len = offset;
  10302. },
  10303. /**
  10304. * 填充 Path 数据。
  10305. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  10306. */
  10307. addData: function (cmd) {
  10308. var data = this.data;
  10309. if (this._len + arguments.length > data.length) {
  10310. // 因为之前的数组已经转换成静态的 Float32Array
  10311. // 所以不够用时需要扩展一个新的动态数组
  10312. this._expandData();
  10313. data = this.data;
  10314. }
  10315. for (var i = 0; i < arguments.length; i++) {
  10316. data[this._len++] = arguments[i];
  10317. }
  10318. this._prevCmd = cmd;
  10319. },
  10320. _expandData: function () {
  10321. // Only if data is Float32Array
  10322. if (!(this.data instanceof Array)) {
  10323. var newData = [];
  10324. for (var i = 0; i < this._len; i++) {
  10325. newData[i] = this.data[i];
  10326. }
  10327. this.data = newData;
  10328. }
  10329. },
  10330. /**
  10331. * If needs js implemented dashed line
  10332. * @return {boolean}
  10333. * @private
  10334. */
  10335. _needsDash: function () {
  10336. return this._lineDash;
  10337. },
  10338. _dashedLineTo: function (x1, y1) {
  10339. var dashSum = this._dashSum;
  10340. var offset = this._dashOffset;
  10341. var lineDash = this._lineDash;
  10342. var ctx = this._ctx;
  10343. var x0 = this._xi;
  10344. var y0 = this._yi;
  10345. var dx = x1 - x0;
  10346. var dy = y1 - y0;
  10347. var dist = mathSqrt(dx * dx + dy * dy);
  10348. var x = x0;
  10349. var y = y0;
  10350. var dash;
  10351. var nDash = lineDash.length;
  10352. var idx;
  10353. dx /= dist;
  10354. dy /= dist;
  10355. if (offset < 0) {
  10356. // Convert to positive offset
  10357. offset = dashSum + offset;
  10358. }
  10359. offset %= dashSum;
  10360. x -= offset * dx;
  10361. y -= offset * dy;
  10362. while ((dx >= 0 && x <= x1) || (dx < 0 && x > x1)) {
  10363. idx = this._dashIdx;
  10364. dash = lineDash[idx];
  10365. x += dx * dash;
  10366. y += dy * dash;
  10367. this._dashIdx = (idx + 1) % nDash;
  10368. // Skip positive offset
  10369. if ((dx > 0 && x < x0) || (dx < 0 && x > x0)) {
  10370. continue;
  10371. }
  10372. ctx[idx % 2 ? 'moveTo' : 'lineTo'](
  10373. dx >= 0 ? mathMin(x, x1) : mathMax(x, x1),
  10374. dy >= 0 ? mathMin(y, y1) : mathMax(y, y1)
  10375. );
  10376. }
  10377. // Offset for next lineTo
  10378. dx = x - x1;
  10379. dy = y - y1;
  10380. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  10381. },
  10382. // Not accurate dashed line to
  10383. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  10384. var dashSum = this._dashSum;
  10385. var offset = this._dashOffset;
  10386. var lineDash = this._lineDash;
  10387. var ctx = this._ctx;
  10388. var x0 = this._xi;
  10389. var y0 = this._yi;
  10390. var t;
  10391. var dx;
  10392. var dy;
  10393. var cubicAt = curve.cubicAt;
  10394. var bezierLen = 0;
  10395. var idx = this._dashIdx;
  10396. var nDash = lineDash.length;
  10397. var x;
  10398. var y;
  10399. var tmpLen = 0;
  10400. if (offset < 0) {
  10401. // Convert to positive offset
  10402. offset = dashSum + offset;
  10403. }
  10404. offset %= dashSum;
  10405. // Bezier approx length
  10406. for (t = 0; t < 1; t += 0.1) {
  10407. dx = cubicAt(x0, x1, x2, x3, t + 0.1)
  10408. - cubicAt(x0, x1, x2, x3, t);
  10409. dy = cubicAt(y0, y1, y2, y3, t + 0.1)
  10410. - cubicAt(y0, y1, y2, y3, t);
  10411. bezierLen += mathSqrt(dx * dx + dy * dy);
  10412. }
  10413. // Find idx after add offset
  10414. for (; idx < nDash; idx++) {
  10415. tmpLen += lineDash[idx];
  10416. if (tmpLen > offset) {
  10417. break;
  10418. }
  10419. }
  10420. t = (tmpLen - offset) / bezierLen;
  10421. while (t <= 1) {
  10422. x = cubicAt(x0, x1, x2, x3, t);
  10423. y = cubicAt(y0, y1, y2, y3, t);
  10424. // Use line to approximate dashed bezier
  10425. // Bad result if dash is long
  10426. idx % 2 ? ctx.moveTo(x, y)
  10427. : ctx.lineTo(x, y);
  10428. t += lineDash[idx] / bezierLen;
  10429. idx = (idx + 1) % nDash;
  10430. }
  10431. // Finish the last segment and calculate the new offset
  10432. (idx % 2 !== 0) && ctx.lineTo(x3, y3);
  10433. dx = x3 - x;
  10434. dy = y3 - y;
  10435. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  10436. },
  10437. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  10438. // Convert quadratic to cubic using degree elevation
  10439. var x3 = x2;
  10440. var y3 = y2;
  10441. x2 = (x2 + 2 * x1) / 3;
  10442. y2 = (y2 + 2 * y1) / 3;
  10443. x1 = (this._xi + 2 * x1) / 3;
  10444. y1 = (this._yi + 2 * y1) / 3;
  10445. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  10446. },
  10447. /**
  10448. * 转成静态的 Float32Array 减少堆内存占用
  10449. * Convert dynamic array to static Float32Array
  10450. */
  10451. toStatic: function () {
  10452. var data = this.data;
  10453. if (data instanceof Array) {
  10454. data.length = this._len;
  10455. if (hasTypedArray) {
  10456. this.data = new Float32Array(data);
  10457. }
  10458. }
  10459. },
  10460. /**
  10461. * @return {module:zrender/core/BoundingRect}
  10462. */
  10463. getBoundingRect: function () {
  10464. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  10465. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  10466. var data = this.data;
  10467. var xi = 0;
  10468. var yi = 0;
  10469. var x0 = 0;
  10470. var y0 = 0;
  10471. for (var i = 0; i < data.length;) {
  10472. var cmd = data[i++];
  10473. if (i == 1) {
  10474. // 如果第一个命令是 L, C, Q
  10475. // 则 previous point 同绘制命令的第一个 point
  10476. //
  10477. // 第一个命令为 Arc 的情况下会在后面特殊处理
  10478. xi = data[i];
  10479. yi = data[i + 1];
  10480. x0 = xi;
  10481. y0 = yi;
  10482. }
  10483. switch (cmd) {
  10484. case CMD.M:
  10485. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  10486. // 在 closePath 的时候使用
  10487. x0 = data[i++];
  10488. y0 = data[i++];
  10489. xi = x0;
  10490. yi = y0;
  10491. min2[0] = x0;
  10492. min2[1] = y0;
  10493. max2[0] = x0;
  10494. max2[1] = y0;
  10495. break;
  10496. case CMD.L:
  10497. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  10498. xi = data[i++];
  10499. yi = data[i++];
  10500. break;
  10501. case CMD.C:
  10502. bbox.fromCubic(
  10503. xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  10504. min2, max2
  10505. );
  10506. xi = data[i++];
  10507. yi = data[i++];
  10508. break;
  10509. case CMD.Q:
  10510. bbox.fromQuadratic(
  10511. xi, yi, data[i++], data[i++], data[i], data[i + 1],
  10512. min2, max2
  10513. );
  10514. xi = data[i++];
  10515. yi = data[i++];
  10516. break;
  10517. case CMD.A:
  10518. // TODO Arc 判断的开销比较大
  10519. var cx = data[i++];
  10520. var cy = data[i++];
  10521. var rx = data[i++];
  10522. var ry = data[i++];
  10523. var startAngle = data[i++];
  10524. var endAngle = data[i++] + startAngle;
  10525. // TODO Arc 旋转
  10526. var psi = data[i++];
  10527. var anticlockwise = 1 - data[i++];
  10528. if (i == 1) {
  10529. // 直接使用 arc 命令
  10530. // 第一个命令起点还未定义
  10531. x0 = mathCos(startAngle) * rx + cx;
  10532. y0 = mathSin(startAngle) * ry + cy;
  10533. }
  10534. bbox.fromArc(
  10535. cx, cy, rx, ry, startAngle, endAngle,
  10536. anticlockwise, min2, max2
  10537. );
  10538. xi = mathCos(endAngle) * rx + cx;
  10539. yi = mathSin(endAngle) * ry + cy;
  10540. break;
  10541. case CMD.R:
  10542. x0 = xi = data[i++];
  10543. y0 = yi = data[i++];
  10544. var width = data[i++];
  10545. var height = data[i++];
  10546. // Use fromLine
  10547. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  10548. break;
  10549. case CMD.Z:
  10550. xi = x0;
  10551. yi = y0;
  10552. break;
  10553. }
  10554. // Union
  10555. vec2.min(min, min, min2);
  10556. vec2.max(max, max, max2);
  10557. }
  10558. // No data
  10559. if (i === 0) {
  10560. min[0] = min[1] = max[0] = max[1] = 0;
  10561. }
  10562. return new BoundingRect(
  10563. min[0], min[1], max[0] - min[0], max[1] - min[1]
  10564. );
  10565. },
  10566. /**
  10567. * Rebuild path from current data
  10568. * Rebuild path will not consider javascript implemented line dash.
  10569. * @param {CanvasRenderingContext} ctx
  10570. */
  10571. rebuildPath: function (ctx) {
  10572. var d = this.data;
  10573. var x0, y0;
  10574. var xi, yi;
  10575. var x, y;
  10576. var ux = this._ux;
  10577. var uy = this._uy;
  10578. var len = this._len;
  10579. for (var i = 0; i < len;) {
  10580. var cmd = d[i++];
  10581. if (i == 1) {
  10582. // 如果第一个命令是 L, C, Q
  10583. // 则 previous point 同绘制命令的第一个 point
  10584. //
  10585. // 第一个命令为 Arc 的情况下会在后面特殊处理
  10586. xi = d[i];
  10587. yi = d[i + 1];
  10588. x0 = xi;
  10589. y0 = yi;
  10590. }
  10591. switch (cmd) {
  10592. case CMD.M:
  10593. x0 = xi = d[i++];
  10594. y0 = yi = d[i++];
  10595. ctx.moveTo(xi, yi);
  10596. break;
  10597. case CMD.L:
  10598. x = d[i++];
  10599. y = d[i++];
  10600. // Not draw too small seg between
  10601. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  10602. ctx.lineTo(x, y);
  10603. xi = x;
  10604. yi = y;
  10605. }
  10606. break;
  10607. case CMD.C:
  10608. ctx.bezierCurveTo(
  10609. d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]
  10610. );
  10611. xi = d[i - 2];
  10612. yi = d[i - 1];
  10613. break;
  10614. case CMD.Q:
  10615. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  10616. xi = d[i - 2];
  10617. yi = d[i - 1];
  10618. break;
  10619. case CMD.A:
  10620. var cx = d[i++];
  10621. var cy = d[i++];
  10622. var rx = d[i++];
  10623. var ry = d[i++];
  10624. var theta = d[i++];
  10625. var dTheta = d[i++];
  10626. var psi = d[i++];
  10627. var fs = d[i++];
  10628. var r = (rx > ry) ? rx : ry;
  10629. var scaleX = (rx > ry) ? 1 : rx / ry;
  10630. var scaleY = (rx > ry) ? ry / rx : 1;
  10631. var isEllipse = Math.abs(rx - ry) > 1e-3;
  10632. var endAngle = theta + dTheta;
  10633. if (isEllipse) {
  10634. ctx.translate(cx, cy);
  10635. ctx.rotate(psi);
  10636. ctx.scale(scaleX, scaleY);
  10637. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  10638. ctx.scale(1 / scaleX, 1 / scaleY);
  10639. ctx.rotate(-psi);
  10640. ctx.translate(-cx, -cy);
  10641. }
  10642. else {
  10643. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  10644. }
  10645. if (i == 1) {
  10646. // 直接使用 arc 命令
  10647. // 第一个命令起点还未定义
  10648. x0 = mathCos(theta) * rx + cx;
  10649. y0 = mathSin(theta) * ry + cy;
  10650. }
  10651. xi = mathCos(endAngle) * rx + cx;
  10652. yi = mathSin(endAngle) * ry + cy;
  10653. break;
  10654. case CMD.R:
  10655. x0 = xi = d[i];
  10656. y0 = yi = d[i + 1];
  10657. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  10658. break;
  10659. case CMD.Z:
  10660. ctx.closePath();
  10661. xi = x0;
  10662. yi = y0;
  10663. }
  10664. }
  10665. }
  10666. };
  10667. PathProxy.CMD = CMD;
  10668. module.exports = PathProxy;
  10669. /***/ },
  10670. /* 49 */
  10671. /***/ function(module, exports, __webpack_require__) {
  10672. 'use strict';
  10673. /**
  10674. * 曲线辅助模块
  10675. * @module zrender/core/curve
  10676. * @author pissang(https://www.github.com/pissang)
  10677. */
  10678. var vec2 = __webpack_require__(16);
  10679. var v2Create = vec2.create;
  10680. var v2DistSquare = vec2.distSquare;
  10681. var mathPow = Math.pow;
  10682. var mathSqrt = Math.sqrt;
  10683. var EPSILON = 1e-8;
  10684. var EPSILON_NUMERIC = 1e-4;
  10685. var THREE_SQRT = mathSqrt(3);
  10686. var ONE_THIRD = 1 / 3;
  10687. // 临时变量
  10688. var _v0 = v2Create();
  10689. var _v1 = v2Create();
  10690. var _v2 = v2Create();
  10691. // var _v3 = vec2.create();
  10692. function isAroundZero(val) {
  10693. return val > -EPSILON && val < EPSILON;
  10694. }
  10695. function isNotAroundZero(val) {
  10696. return val > EPSILON || val < -EPSILON;
  10697. }
  10698. /**
  10699. * 计算三次贝塞尔值
  10700. * @memberOf module:zrender/core/curve
  10701. * @param {number} p0
  10702. * @param {number} p1
  10703. * @param {number} p2
  10704. * @param {number} p3
  10705. * @param {number} t
  10706. * @return {number}
  10707. */
  10708. function cubicAt(p0, p1, p2, p3, t) {
  10709. var onet = 1 - t;
  10710. return onet * onet * (onet * p0 + 3 * t * p1)
  10711. + t * t * (t * p3 + 3 * onet * p2);
  10712. }
  10713. /**
  10714. * 计算三次贝塞尔导数值
  10715. * @memberOf module:zrender/core/curve
  10716. * @param {number} p0
  10717. * @param {number} p1
  10718. * @param {number} p2
  10719. * @param {number} p3
  10720. * @param {number} t
  10721. * @return {number}
  10722. */
  10723. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  10724. var onet = 1 - t;
  10725. return 3 * (
  10726. ((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet
  10727. + (p3 - p2) * t * t
  10728. );
  10729. }
  10730. /**
  10731. * 计算三次贝塞尔方程根,使用盛金公式
  10732. * @memberOf module:zrender/core/curve
  10733. * @param {number} p0
  10734. * @param {number} p1
  10735. * @param {number} p2
  10736. * @param {number} p3
  10737. * @param {number} val
  10738. * @param {Array.<number>} roots
  10739. * @return {number} 有效根数目
  10740. */
  10741. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  10742. // Evaluate roots of cubic functions
  10743. var a = p3 + 3 * (p1 - p2) - p0;
  10744. var b = 3 * (p2 - p1 * 2 + p0);
  10745. var c = 3 * (p1 - p0);
  10746. var d = p0 - val;
  10747. var A = b * b - 3 * a * c;
  10748. var B = b * c - 9 * a * d;
  10749. var C = c * c - 3 * b * d;
  10750. var n = 0;
  10751. if (isAroundZero(A) && isAroundZero(B)) {
  10752. if (isAroundZero(b)) {
  10753. roots[0] = 0;
  10754. }
  10755. else {
  10756. var t1 = -c / b; //t1, t2, t3, b is not zero
  10757. if (t1 >= 0 && t1 <= 1) {
  10758. roots[n++] = t1;
  10759. }
  10760. }
  10761. }
  10762. else {
  10763. var disc = B * B - 4 * A * C;
  10764. if (isAroundZero(disc)) {
  10765. var K = B / A;
  10766. var t1 = -b / a + K; // t1, a is not zero
  10767. var t2 = -K / 2; // t2, t3
  10768. if (t1 >= 0 && t1 <= 1) {
  10769. roots[n++] = t1;
  10770. }
  10771. if (t2 >= 0 && t2 <= 1) {
  10772. roots[n++] = t2;
  10773. }
  10774. }
  10775. else if (disc > 0) {
  10776. var discSqrt = mathSqrt(disc);
  10777. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  10778. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  10779. if (Y1 < 0) {
  10780. Y1 = -mathPow(-Y1, ONE_THIRD);
  10781. }
  10782. else {
  10783. Y1 = mathPow(Y1, ONE_THIRD);
  10784. }
  10785. if (Y2 < 0) {
  10786. Y2 = -mathPow(-Y2, ONE_THIRD);
  10787. }
  10788. else {
  10789. Y2 = mathPow(Y2, ONE_THIRD);
  10790. }
  10791. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  10792. if (t1 >= 0 && t1 <= 1) {
  10793. roots[n++] = t1;
  10794. }
  10795. }
  10796. else {
  10797. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  10798. var theta = Math.acos(T) / 3;
  10799. var ASqrt = mathSqrt(A);
  10800. var tmp = Math.cos(theta);
  10801. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  10802. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  10803. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  10804. if (t1 >= 0 && t1 <= 1) {
  10805. roots[n++] = t1;
  10806. }
  10807. if (t2 >= 0 && t2 <= 1) {
  10808. roots[n++] = t2;
  10809. }
  10810. if (t3 >= 0 && t3 <= 1) {
  10811. roots[n++] = t3;
  10812. }
  10813. }
  10814. }
  10815. return n;
  10816. }
  10817. /**
  10818. * 计算三次贝塞尔方程极限值的位置
  10819. * @memberOf module:zrender/core/curve
  10820. * @param {number} p0
  10821. * @param {number} p1
  10822. * @param {number} p2
  10823. * @param {number} p3
  10824. * @param {Array.<number>} extrema
  10825. * @return {number} 有效数目
  10826. */
  10827. function cubicExtrema(p0, p1, p2, p3, extrema) {
  10828. var b = 6 * p2 - 12 * p1 + 6 * p0;
  10829. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  10830. var c = 3 * p1 - 3 * p0;
  10831. var n = 0;
  10832. if (isAroundZero(a)) {
  10833. if (isNotAroundZero(b)) {
  10834. var t1 = -c / b;
  10835. if (t1 >= 0 && t1 <=1) {
  10836. extrema[n++] = t1;
  10837. }
  10838. }
  10839. }
  10840. else {
  10841. var disc = b * b - 4 * a * c;
  10842. if (isAroundZero(disc)) {
  10843. extrema[0] = -b / (2 * a);
  10844. }
  10845. else if (disc > 0) {
  10846. var discSqrt = mathSqrt(disc);
  10847. var t1 = (-b + discSqrt) / (2 * a);
  10848. var t2 = (-b - discSqrt) / (2 * a);
  10849. if (t1 >= 0 && t1 <= 1) {
  10850. extrema[n++] = t1;
  10851. }
  10852. if (t2 >= 0 && t2 <= 1) {
  10853. extrema[n++] = t2;
  10854. }
  10855. }
  10856. }
  10857. return n;
  10858. }
  10859. /**
  10860. * 细分三次贝塞尔曲线
  10861. * @memberOf module:zrender/core/curve
  10862. * @param {number} p0
  10863. * @param {number} p1
  10864. * @param {number} p2
  10865. * @param {number} p3
  10866. * @param {number} t
  10867. * @param {Array.<number>} out
  10868. */
  10869. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  10870. var p01 = (p1 - p0) * t + p0;
  10871. var p12 = (p2 - p1) * t + p1;
  10872. var p23 = (p3 - p2) * t + p2;
  10873. var p012 = (p12 - p01) * t + p01;
  10874. var p123 = (p23 - p12) * t + p12;
  10875. var p0123 = (p123 - p012) * t + p012;
  10876. // Seg0
  10877. out[0] = p0;
  10878. out[1] = p01;
  10879. out[2] = p012;
  10880. out[3] = p0123;
  10881. // Seg1
  10882. out[4] = p0123;
  10883. out[5] = p123;
  10884. out[6] = p23;
  10885. out[7] = p3;
  10886. }
  10887. /**
  10888. * 投射点到三次贝塞尔曲线上,返回投射距离。
  10889. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  10890. * @param {number} x0
  10891. * @param {number} y0
  10892. * @param {number} x1
  10893. * @param {number} y1
  10894. * @param {number} x2
  10895. * @param {number} y2
  10896. * @param {number} x3
  10897. * @param {number} y3
  10898. * @param {number} x
  10899. * @param {number} y
  10900. * @param {Array.<number>} [out] 投射点
  10901. * @return {number}
  10902. */
  10903. function cubicProjectPoint(
  10904. x0, y0, x1, y1, x2, y2, x3, y3,
  10905. x, y, out
  10906. ) {
  10907. // http://pomax.github.io/bezierinfo/#projections
  10908. var t;
  10909. var interval = 0.005;
  10910. var d = Infinity;
  10911. var prev;
  10912. var next;
  10913. var d1;
  10914. var d2;
  10915. _v0[0] = x;
  10916. _v0[1] = y;
  10917. // 先粗略估计一下可能的最小距离的 t 值
  10918. // PENDING
  10919. for (var _t = 0; _t < 1; _t += 0.05) {
  10920. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  10921. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  10922. d1 = v2DistSquare(_v0, _v1);
  10923. if (d1 < d) {
  10924. t = _t;
  10925. d = d1;
  10926. }
  10927. }
  10928. d = Infinity;
  10929. // At most 32 iteration
  10930. for (var i = 0; i < 32; i++) {
  10931. if (interval < EPSILON_NUMERIC) {
  10932. break;
  10933. }
  10934. prev = t - interval;
  10935. next = t + interval;
  10936. // t - interval
  10937. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  10938. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  10939. d1 = v2DistSquare(_v1, _v0);
  10940. if (prev >= 0 && d1 < d) {
  10941. t = prev;
  10942. d = d1;
  10943. }
  10944. else {
  10945. // t + interval
  10946. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  10947. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  10948. d2 = v2DistSquare(_v2, _v0);
  10949. if (next <= 1 && d2 < d) {
  10950. t = next;
  10951. d = d2;
  10952. }
  10953. else {
  10954. interval *= 0.5;
  10955. }
  10956. }
  10957. }
  10958. // t
  10959. if (out) {
  10960. out[0] = cubicAt(x0, x1, x2, x3, t);
  10961. out[1] = cubicAt(y0, y1, y2, y3, t);
  10962. }
  10963. // console.log(interval, i);
  10964. return mathSqrt(d);
  10965. }
  10966. /**
  10967. * 计算二次方贝塞尔值
  10968. * @param {number} p0
  10969. * @param {number} p1
  10970. * @param {number} p2
  10971. * @param {number} t
  10972. * @return {number}
  10973. */
  10974. function quadraticAt(p0, p1, p2, t) {
  10975. var onet = 1 - t;
  10976. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  10977. }
  10978. /**
  10979. * 计算二次方贝塞尔导数值
  10980. * @param {number} p0
  10981. * @param {number} p1
  10982. * @param {number} p2
  10983. * @param {number} t
  10984. * @return {number}
  10985. */
  10986. function quadraticDerivativeAt(p0, p1, p2, t) {
  10987. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  10988. }
  10989. /**
  10990. * 计算二次方贝塞尔方程根
  10991. * @param {number} p0
  10992. * @param {number} p1
  10993. * @param {number} p2
  10994. * @param {number} t
  10995. * @param {Array.<number>} roots
  10996. * @return {number} 有效根数目
  10997. */
  10998. function quadraticRootAt(p0, p1, p2, val, roots) {
  10999. var a = p0 - 2 * p1 + p2;
  11000. var b = 2 * (p1 - p0);
  11001. var c = p0 - val;
  11002. var n = 0;
  11003. if (isAroundZero(a)) {
  11004. if (isNotAroundZero(b)) {
  11005. var t1 = -c / b;
  11006. if (t1 >= 0 && t1 <= 1) {
  11007. roots[n++] = t1;
  11008. }
  11009. }
  11010. }
  11011. else {
  11012. var disc = b * b - 4 * a * c;
  11013. if (isAroundZero(disc)) {
  11014. var t1 = -b / (2 * a);
  11015. if (t1 >= 0 && t1 <= 1) {
  11016. roots[n++] = t1;
  11017. }
  11018. }
  11019. else if (disc > 0) {
  11020. var discSqrt = mathSqrt(disc);
  11021. var t1 = (-b + discSqrt) / (2 * a);
  11022. var t2 = (-b - discSqrt) / (2 * a);
  11023. if (t1 >= 0 && t1 <= 1) {
  11024. roots[n++] = t1;
  11025. }
  11026. if (t2 >= 0 && t2 <= 1) {
  11027. roots[n++] = t2;
  11028. }
  11029. }
  11030. }
  11031. return n;
  11032. }
  11033. /**
  11034. * 计算二次贝塞尔方程极限值
  11035. * @memberOf module:zrender/core/curve
  11036. * @param {number} p0
  11037. * @param {number} p1
  11038. * @param {number} p2
  11039. * @return {number}
  11040. */
  11041. function quadraticExtremum(p0, p1, p2) {
  11042. var divider = p0 + p2 - 2 * p1;
  11043. if (divider === 0) {
  11044. // p1 is center of p0 and p2
  11045. return 0.5;
  11046. }
  11047. else {
  11048. return (p0 - p1) / divider;
  11049. }
  11050. }
  11051. /**
  11052. * 细分二次贝塞尔曲线
  11053. * @memberOf module:zrender/core/curve
  11054. * @param {number} p0
  11055. * @param {number} p1
  11056. * @param {number} p2
  11057. * @param {number} t
  11058. * @param {Array.<number>} out
  11059. */
  11060. function quadraticSubdivide(p0, p1, p2, t, out) {
  11061. var p01 = (p1 - p0) * t + p0;
  11062. var p12 = (p2 - p1) * t + p1;
  11063. var p012 = (p12 - p01) * t + p01;
  11064. // Seg0
  11065. out[0] = p0;
  11066. out[1] = p01;
  11067. out[2] = p012;
  11068. // Seg1
  11069. out[3] = p012;
  11070. out[4] = p12;
  11071. out[5] = p2;
  11072. }
  11073. /**
  11074. * 投射点到二次贝塞尔曲线上,返回投射距离。
  11075. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  11076. * @param {number} x0
  11077. * @param {number} y0
  11078. * @param {number} x1
  11079. * @param {number} y1
  11080. * @param {number} x2
  11081. * @param {number} y2
  11082. * @param {number} x
  11083. * @param {number} y
  11084. * @param {Array.<number>} out 投射点
  11085. * @return {number}
  11086. */
  11087. function quadraticProjectPoint(
  11088. x0, y0, x1, y1, x2, y2,
  11089. x, y, out
  11090. ) {
  11091. // http://pomax.github.io/bezierinfo/#projections
  11092. var t;
  11093. var interval = 0.005;
  11094. var d = Infinity;
  11095. _v0[0] = x;
  11096. _v0[1] = y;
  11097. // 先粗略估计一下可能的最小距离的 t 值
  11098. // PENDING
  11099. for (var _t = 0; _t < 1; _t += 0.05) {
  11100. _v1[0] = quadraticAt(x0, x1, x2, _t);
  11101. _v1[1] = quadraticAt(y0, y1, y2, _t);
  11102. var d1 = v2DistSquare(_v0, _v1);
  11103. if (d1 < d) {
  11104. t = _t;
  11105. d = d1;
  11106. }
  11107. }
  11108. d = Infinity;
  11109. // At most 32 iteration
  11110. for (var i = 0; i < 32; i++) {
  11111. if (interval < EPSILON_NUMERIC) {
  11112. break;
  11113. }
  11114. var prev = t - interval;
  11115. var next = t + interval;
  11116. // t - interval
  11117. _v1[0] = quadraticAt(x0, x1, x2, prev);
  11118. _v1[1] = quadraticAt(y0, y1, y2, prev);
  11119. var d1 = v2DistSquare(_v1, _v0);
  11120. if (prev >= 0 && d1 < d) {
  11121. t = prev;
  11122. d = d1;
  11123. }
  11124. else {
  11125. // t + interval
  11126. _v2[0] = quadraticAt(x0, x1, x2, next);
  11127. _v2[1] = quadraticAt(y0, y1, y2, next);
  11128. var d2 = v2DistSquare(_v2, _v0);
  11129. if (next <= 1 && d2 < d) {
  11130. t = next;
  11131. d = d2;
  11132. }
  11133. else {
  11134. interval *= 0.5;
  11135. }
  11136. }
  11137. }
  11138. // t
  11139. if (out) {
  11140. out[0] = quadraticAt(x0, x1, x2, t);
  11141. out[1] = quadraticAt(y0, y1, y2, t);
  11142. }
  11143. // console.log(interval, i);
  11144. return mathSqrt(d);
  11145. }
  11146. module.exports = {
  11147. cubicAt: cubicAt,
  11148. cubicDerivativeAt: cubicDerivativeAt,
  11149. cubicRootAt: cubicRootAt,
  11150. cubicExtrema: cubicExtrema,
  11151. cubicSubdivide: cubicSubdivide,
  11152. cubicProjectPoint: cubicProjectPoint,
  11153. quadraticAt: quadraticAt,
  11154. quadraticDerivativeAt: quadraticDerivativeAt,
  11155. quadraticRootAt: quadraticRootAt,
  11156. quadraticExtremum: quadraticExtremum,
  11157. quadraticSubdivide: quadraticSubdivide,
  11158. quadraticProjectPoint: quadraticProjectPoint
  11159. };
  11160. /***/ },
  11161. /* 50 */
  11162. /***/ function(module, exports, __webpack_require__) {
  11163. /**
  11164. * @author Yi Shen(https://github.com/pissang)
  11165. */
  11166. var vec2 = __webpack_require__(16);
  11167. var curve = __webpack_require__(49);
  11168. var bbox = {};
  11169. var mathMin = Math.min;
  11170. var mathMax = Math.max;
  11171. var mathSin = Math.sin;
  11172. var mathCos = Math.cos;
  11173. var start = vec2.create();
  11174. var end = vec2.create();
  11175. var extremity = vec2.create();
  11176. var PI2 = Math.PI * 2;
  11177. /**
  11178. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  11179. * @module zrender/core/bbox
  11180. * @param {Array<Object>} points 顶点数组
  11181. * @param {number} min
  11182. * @param {number} max
  11183. */
  11184. bbox.fromPoints = function(points, min, max) {
  11185. if (points.length === 0) {
  11186. return;
  11187. }
  11188. var p = points[0];
  11189. var left = p[0];
  11190. var right = p[0];
  11191. var top = p[1];
  11192. var bottom = p[1];
  11193. var i;
  11194. for (i = 1; i < points.length; i++) {
  11195. p = points[i];
  11196. left = mathMin(left, p[0]);
  11197. right = mathMax(right, p[0]);
  11198. top = mathMin(top, p[1]);
  11199. bottom = mathMax(bottom, p[1]);
  11200. }
  11201. min[0] = left;
  11202. min[1] = top;
  11203. max[0] = right;
  11204. max[1] = bottom;
  11205. };
  11206. /**
  11207. * @memberOf module:zrender/core/bbox
  11208. * @param {number} x0
  11209. * @param {number} y0
  11210. * @param {number} x1
  11211. * @param {number} y1
  11212. * @param {Array.<number>} min
  11213. * @param {Array.<number>} max
  11214. */
  11215. bbox.fromLine = function (x0, y0, x1, y1, min, max) {
  11216. min[0] = mathMin(x0, x1);
  11217. min[1] = mathMin(y0, y1);
  11218. max[0] = mathMax(x0, x1);
  11219. max[1] = mathMax(y0, y1);
  11220. };
  11221. var xDim = [];
  11222. var yDim = [];
  11223. /**
  11224. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  11225. * @memberOf module:zrender/core/bbox
  11226. * @param {number} x0
  11227. * @param {number} y0
  11228. * @param {number} x1
  11229. * @param {number} y1
  11230. * @param {number} x2
  11231. * @param {number} y2
  11232. * @param {number} x3
  11233. * @param {number} y3
  11234. * @param {Array.<number>} min
  11235. * @param {Array.<number>} max
  11236. */
  11237. bbox.fromCubic = function(
  11238. x0, y0, x1, y1, x2, y2, x3, y3, min, max
  11239. ) {
  11240. var cubicExtrema = curve.cubicExtrema;
  11241. var cubicAt = curve.cubicAt;
  11242. var i;
  11243. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  11244. min[0] = Infinity;
  11245. min[1] = Infinity;
  11246. max[0] = -Infinity;
  11247. max[1] = -Infinity;
  11248. for (i = 0; i < n; i++) {
  11249. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  11250. min[0] = mathMin(x, min[0]);
  11251. max[0] = mathMax(x, max[0]);
  11252. }
  11253. n = cubicExtrema(y0, y1, y2, y3, yDim);
  11254. for (i = 0; i < n; i++) {
  11255. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  11256. min[1] = mathMin(y, min[1]);
  11257. max[1] = mathMax(y, max[1]);
  11258. }
  11259. min[0] = mathMin(x0, min[0]);
  11260. max[0] = mathMax(x0, max[0]);
  11261. min[0] = mathMin(x3, min[0]);
  11262. max[0] = mathMax(x3, max[0]);
  11263. min[1] = mathMin(y0, min[1]);
  11264. max[1] = mathMax(y0, max[1]);
  11265. min[1] = mathMin(y3, min[1]);
  11266. max[1] = mathMax(y3, max[1]);
  11267. };
  11268. /**
  11269. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  11270. * @memberOf module:zrender/core/bbox
  11271. * @param {number} x0
  11272. * @param {number} y0
  11273. * @param {number} x1
  11274. * @param {number} y1
  11275. * @param {number} x2
  11276. * @param {number} y2
  11277. * @param {Array.<number>} min
  11278. * @param {Array.<number>} max
  11279. */
  11280. bbox.fromQuadratic = function(x0, y0, x1, y1, x2, y2, min, max) {
  11281. var quadraticExtremum = curve.quadraticExtremum;
  11282. var quadraticAt = curve.quadraticAt;
  11283. // Find extremities, where derivative in x dim or y dim is zero
  11284. var tx =
  11285. mathMax(
  11286. mathMin(quadraticExtremum(x0, x1, x2), 1), 0
  11287. );
  11288. var ty =
  11289. mathMax(
  11290. mathMin(quadraticExtremum(y0, y1, y2), 1), 0
  11291. );
  11292. var x = quadraticAt(x0, x1, x2, tx);
  11293. var y = quadraticAt(y0, y1, y2, ty);
  11294. min[0] = mathMin(x0, x2, x);
  11295. min[1] = mathMin(y0, y2, y);
  11296. max[0] = mathMax(x0, x2, x);
  11297. max[1] = mathMax(y0, y2, y);
  11298. };
  11299. /**
  11300. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  11301. * @method
  11302. * @memberOf module:zrender/core/bbox
  11303. * @param {number} x
  11304. * @param {number} y
  11305. * @param {number} rx
  11306. * @param {number} ry
  11307. * @param {number} startAngle
  11308. * @param {number} endAngle
  11309. * @param {number} anticlockwise
  11310. * @param {Array.<number>} min
  11311. * @param {Array.<number>} max
  11312. */
  11313. bbox.fromArc = function (
  11314. x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max
  11315. ) {
  11316. var vec2Min = vec2.min;
  11317. var vec2Max = vec2.max;
  11318. var diff = Math.abs(startAngle - endAngle);
  11319. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  11320. // Is a circle
  11321. min[0] = x - rx;
  11322. min[1] = y - ry;
  11323. max[0] = x + rx;
  11324. max[1] = y + ry;
  11325. return;
  11326. }
  11327. start[0] = mathCos(startAngle) * rx + x;
  11328. start[1] = mathSin(startAngle) * ry + y;
  11329. end[0] = mathCos(endAngle) * rx + x;
  11330. end[1] = mathSin(endAngle) * ry + y;
  11331. vec2Min(min, start, end);
  11332. vec2Max(max, start, end);
  11333. // Thresh to [0, Math.PI * 2]
  11334. startAngle = startAngle % (PI2);
  11335. if (startAngle < 0) {
  11336. startAngle = startAngle + PI2;
  11337. }
  11338. endAngle = endAngle % (PI2);
  11339. if (endAngle < 0) {
  11340. endAngle = endAngle + PI2;
  11341. }
  11342. if (startAngle > endAngle && !anticlockwise) {
  11343. endAngle += PI2;
  11344. }
  11345. else if (startAngle < endAngle && anticlockwise) {
  11346. startAngle += PI2;
  11347. }
  11348. if (anticlockwise) {
  11349. var tmp = endAngle;
  11350. endAngle = startAngle;
  11351. startAngle = tmp;
  11352. }
  11353. // var number = 0;
  11354. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  11355. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  11356. if (angle > startAngle) {
  11357. extremity[0] = mathCos(angle) * rx + x;
  11358. extremity[1] = mathSin(angle) * ry + y;
  11359. vec2Min(min, extremity, min);
  11360. vec2Max(max, extremity, max);
  11361. }
  11362. }
  11363. };
  11364. module.exports = bbox;
  11365. /***/ },
  11366. /* 51 */
  11367. /***/ function(module, exports, __webpack_require__) {
  11368. 'use strict';
  11369. var CMD = __webpack_require__(48).CMD;
  11370. var line = __webpack_require__(52);
  11371. var cubic = __webpack_require__(53);
  11372. var quadratic = __webpack_require__(54);
  11373. var arc = __webpack_require__(55);
  11374. var normalizeRadian = __webpack_require__(56).normalizeRadian;
  11375. var curve = __webpack_require__(49);
  11376. var windingLine = __webpack_require__(57);
  11377. var containStroke = line.containStroke;
  11378. var PI2 = Math.PI * 2;
  11379. var EPSILON = 1e-4;
  11380. function isAroundEqual(a, b) {
  11381. return Math.abs(a - b) < EPSILON;
  11382. }
  11383. // 临时数组
  11384. var roots = [-1, -1, -1];
  11385. var extrema = [-1, -1];
  11386. function swapExtrema() {
  11387. var tmp = extrema[0];
  11388. extrema[0] = extrema[1];
  11389. extrema[1] = tmp;
  11390. }
  11391. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  11392. // Quick reject
  11393. if (
  11394. (y > y0 && y > y1 && y > y2 && y > y3)
  11395. || (y < y0 && y < y1 && y < y2 && y < y3)
  11396. ) {
  11397. return 0;
  11398. }
  11399. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  11400. if (nRoots === 0) {
  11401. return 0;
  11402. }
  11403. else {
  11404. var w = 0;
  11405. var nExtrema = -1;
  11406. var y0_, y1_;
  11407. for (var i = 0; i < nRoots; i++) {
  11408. var t = roots[i];
  11409. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  11410. if (x_ < x) { // Quick reject
  11411. continue;
  11412. }
  11413. if (nExtrema < 0) {
  11414. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  11415. if (extrema[1] < extrema[0] && nExtrema > 1) {
  11416. swapExtrema();
  11417. }
  11418. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  11419. if (nExtrema > 1) {
  11420. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  11421. }
  11422. }
  11423. if (nExtrema == 2) {
  11424. // 分成三段单调函数
  11425. if (t < extrema[0]) {
  11426. w += y0_ < y0 ? 1 : -1;
  11427. }
  11428. else if (t < extrema[1]) {
  11429. w += y1_ < y0_ ? 1 : -1;
  11430. }
  11431. else {
  11432. w += y3 < y1_ ? 1 : -1;
  11433. }
  11434. }
  11435. else {
  11436. // 分成两段单调函数
  11437. if (t < extrema[0]) {
  11438. w += y0_ < y0 ? 1 : -1;
  11439. }
  11440. else {
  11441. w += y3 < y0_ ? 1 : -1;
  11442. }
  11443. }
  11444. }
  11445. return w;
  11446. }
  11447. }
  11448. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  11449. // Quick reject
  11450. if (
  11451. (y > y0 && y > y1 && y > y2)
  11452. || (y < y0 && y < y1 && y < y2)
  11453. ) {
  11454. return 0;
  11455. }
  11456. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  11457. if (nRoots === 0) {
  11458. return 0;
  11459. }
  11460. else {
  11461. var t = curve.quadraticExtremum(y0, y1, y2);
  11462. if (t >= 0 && t <= 1) {
  11463. var w = 0;
  11464. var y_ = curve.quadraticAt(y0, y1, y2, t);
  11465. for (var i = 0; i < nRoots; i++) {
  11466. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  11467. if (x_ < x) { // Quick reject
  11468. continue;
  11469. }
  11470. if (roots[i] < t) {
  11471. w += y_ < y0 ? 1 : -1;
  11472. }
  11473. else {
  11474. w += y2 < y_ ? 1 : -1;
  11475. }
  11476. }
  11477. return w;
  11478. }
  11479. else {
  11480. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  11481. if (x_ < x) { // Quick reject
  11482. return 0;
  11483. }
  11484. return y2 < y0 ? 1 : -1;
  11485. }
  11486. }
  11487. }
  11488. // TODO
  11489. // Arc 旋转
  11490. function windingArc(
  11491. cx, cy, r, startAngle, endAngle, anticlockwise, x, y
  11492. ) {
  11493. y -= cy;
  11494. if (y > r || y < -r) {
  11495. return 0;
  11496. }
  11497. var tmp = Math.sqrt(r * r - y * y);
  11498. roots[0] = -tmp;
  11499. roots[1] = tmp;
  11500. var diff = Math.abs(startAngle - endAngle);
  11501. if (diff < 1e-4) {
  11502. return 0;
  11503. }
  11504. if (diff % PI2 < 1e-4) {
  11505. // Is a circle
  11506. startAngle = 0;
  11507. endAngle = PI2;
  11508. var dir = anticlockwise ? 1 : -1;
  11509. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  11510. return dir;
  11511. } else {
  11512. return 0;
  11513. }
  11514. }
  11515. if (anticlockwise) {
  11516. var tmp = startAngle;
  11517. startAngle = normalizeRadian(endAngle);
  11518. endAngle = normalizeRadian(tmp);
  11519. }
  11520. else {
  11521. startAngle = normalizeRadian(startAngle);
  11522. endAngle = normalizeRadian(endAngle);
  11523. }
  11524. if (startAngle > endAngle) {
  11525. endAngle += PI2;
  11526. }
  11527. var w = 0;
  11528. for (var i = 0; i < 2; i++) {
  11529. var x_ = roots[i];
  11530. if (x_ + cx > x) {
  11531. var angle = Math.atan2(y, x_);
  11532. var dir = anticlockwise ? 1 : -1;
  11533. if (angle < 0) {
  11534. angle = PI2 + angle;
  11535. }
  11536. if (
  11537. (angle >= startAngle && angle <= endAngle)
  11538. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle)
  11539. ) {
  11540. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  11541. dir = -dir;
  11542. }
  11543. w += dir;
  11544. }
  11545. }
  11546. }
  11547. return w;
  11548. }
  11549. function containPath(data, lineWidth, isStroke, x, y) {
  11550. var w = 0;
  11551. var xi = 0;
  11552. var yi = 0;
  11553. var x0 = 0;
  11554. var y0 = 0;
  11555. for (var i = 0; i < data.length;) {
  11556. var cmd = data[i++];
  11557. // Begin a new subpath
  11558. if (cmd === CMD.M && i > 1) {
  11559. // Close previous subpath
  11560. if (!isStroke) {
  11561. w += windingLine(xi, yi, x0, y0, x, y);
  11562. }
  11563. // 如果被任何一个 subpath 包含
  11564. if (w !== 0) {
  11565. return true;
  11566. }
  11567. }
  11568. if (i == 1) {
  11569. // 如果第一个命令是 L, C, Q
  11570. // 则 previous point 同绘制命令的第一个 point
  11571. //
  11572. // 第一个命令为 Arc 的情况下会在后面特殊处理
  11573. xi = data[i];
  11574. yi = data[i + 1];
  11575. x0 = xi;
  11576. y0 = yi;
  11577. }
  11578. switch (cmd) {
  11579. case CMD.M:
  11580. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  11581. // 在 closePath 的时候使用
  11582. x0 = data[i++];
  11583. y0 = data[i++];
  11584. xi = x0;
  11585. yi = y0;
  11586. break;
  11587. case CMD.L:
  11588. if (isStroke) {
  11589. if (containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  11590. return true;
  11591. }
  11592. }
  11593. else {
  11594. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  11595. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  11596. }
  11597. xi = data[i++];
  11598. yi = data[i++];
  11599. break;
  11600. case CMD.C:
  11601. if (isStroke) {
  11602. if (cubic.containStroke(xi, yi,
  11603. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11604. lineWidth, x, y
  11605. )) {
  11606. return true;
  11607. }
  11608. }
  11609. else {
  11610. w += windingCubic(
  11611. xi, yi,
  11612. data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1],
  11613. x, y
  11614. ) || 0;
  11615. }
  11616. xi = data[i++];
  11617. yi = data[i++];
  11618. break;
  11619. case CMD.Q:
  11620. if (isStroke) {
  11621. if (quadratic.containStroke(xi, yi,
  11622. data[i++], data[i++], data[i], data[i + 1],
  11623. lineWidth, x, y
  11624. )) {
  11625. return true;
  11626. }
  11627. }
  11628. else {
  11629. w += windingQuadratic(
  11630. xi, yi,
  11631. data[i++], data[i++], data[i], data[i + 1],
  11632. x, y
  11633. ) || 0;
  11634. }
  11635. xi = data[i++];
  11636. yi = data[i++];
  11637. break;
  11638. case CMD.A:
  11639. // TODO Arc 判断的开销比较大
  11640. var cx = data[i++];
  11641. var cy = data[i++];
  11642. var rx = data[i++];
  11643. var ry = data[i++];
  11644. var theta = data[i++];
  11645. var dTheta = data[i++];
  11646. // TODO Arc 旋转
  11647. var psi = data[i++];
  11648. var anticlockwise = 1 - data[i++];
  11649. var x1 = Math.cos(theta) * rx + cx;
  11650. var y1 = Math.sin(theta) * ry + cy;
  11651. // 不是直接使用 arc 命令
  11652. if (i > 1) {
  11653. w += windingLine(xi, yi, x1, y1, x, y);
  11654. }
  11655. else {
  11656. // 第一个命令起点还未定义
  11657. x0 = x1;
  11658. y0 = y1;
  11659. }
  11660. // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  11661. var _x = (x - cx) * ry / rx + cx;
  11662. if (isStroke) {
  11663. if (arc.containStroke(
  11664. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  11665. lineWidth, _x, y
  11666. )) {
  11667. return true;
  11668. }
  11669. }
  11670. else {
  11671. w += windingArc(
  11672. cx, cy, ry, theta, theta + dTheta, anticlockwise,
  11673. _x, y
  11674. );
  11675. }
  11676. xi = Math.cos(theta + dTheta) * rx + cx;
  11677. yi = Math.sin(theta + dTheta) * ry + cy;
  11678. break;
  11679. case CMD.R:
  11680. x0 = xi = data[i++];
  11681. y0 = yi = data[i++];
  11682. var width = data[i++];
  11683. var height = data[i++];
  11684. var x1 = x0 + width;
  11685. var y1 = y0 + height;
  11686. if (isStroke) {
  11687. if (containStroke(x0, y0, x1, y0, lineWidth, x, y)
  11688. || containStroke(x1, y0, x1, y1, lineWidth, x, y)
  11689. || containStroke(x1, y1, x0, y1, lineWidth, x, y)
  11690. || containStroke(x0, y1, x1, y1, lineWidth, x, y)
  11691. ) {
  11692. return true;
  11693. }
  11694. }
  11695. else {
  11696. // FIXME Clockwise ?
  11697. w += windingLine(x1, y0, x1, y1, x, y);
  11698. w += windingLine(x0, y1, x0, y0, x, y);
  11699. }
  11700. break;
  11701. case CMD.Z:
  11702. if (isStroke) {
  11703. if (containStroke(
  11704. xi, yi, x0, y0, lineWidth, x, y
  11705. )) {
  11706. return true;
  11707. }
  11708. }
  11709. else {
  11710. // Close a subpath
  11711. w += windingLine(xi, yi, x0, y0, x, y);
  11712. // 如果被任何一个 subpath 包含
  11713. if (w !== 0) {
  11714. return true;
  11715. }
  11716. }
  11717. xi = x0;
  11718. yi = y0;
  11719. break;
  11720. }
  11721. }
  11722. if (!isStroke && !isAroundEqual(yi, y0)) {
  11723. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  11724. }
  11725. return w !== 0;
  11726. }
  11727. module.exports = {
  11728. contain: function (pathData, x, y) {
  11729. return containPath(pathData, 0, false, x, y);
  11730. },
  11731. containStroke: function (pathData, lineWidth, x, y) {
  11732. return containPath(pathData, lineWidth, true, x, y);
  11733. }
  11734. };
  11735. /***/ },
  11736. /* 52 */
  11737. /***/ function(module, exports) {
  11738. module.exports = {
  11739. /**
  11740. * 线段包含判断
  11741. * @param {number} x0
  11742. * @param {number} y0
  11743. * @param {number} x1
  11744. * @param {number} y1
  11745. * @param {number} lineWidth
  11746. * @param {number} x
  11747. * @param {number} y
  11748. * @return {boolean}
  11749. */
  11750. containStroke: function (x0, y0, x1, y1, lineWidth, x, y) {
  11751. if (lineWidth === 0) {
  11752. return false;
  11753. }
  11754. var _l = lineWidth;
  11755. var _a = 0;
  11756. var _b = x0;
  11757. // Quick reject
  11758. if (
  11759. (y > y0 + _l && y > y1 + _l)
  11760. || (y < y0 - _l && y < y1 - _l)
  11761. || (x > x0 + _l && x > x1 + _l)
  11762. || (x < x0 - _l && x < x1 - _l)
  11763. ) {
  11764. return false;
  11765. }
  11766. if (x0 !== x1) {
  11767. _a = (y0 - y1) / (x0 - x1);
  11768. _b = (x0 * y1 - x1 * y0) / (x0 - x1) ;
  11769. }
  11770. else {
  11771. return Math.abs(x - x0) <= _l / 2;
  11772. }
  11773. var tmp = _a * x - y + _b;
  11774. var _s = tmp * tmp / (_a * _a + 1);
  11775. return _s <= _l / 2 * _l / 2;
  11776. }
  11777. };
  11778. /***/ },
  11779. /* 53 */
  11780. /***/ function(module, exports, __webpack_require__) {
  11781. var curve = __webpack_require__(49);
  11782. module.exports = {
  11783. /**
  11784. * 三次贝塞尔曲线描边包含判断
  11785. * @param {number} x0
  11786. * @param {number} y0
  11787. * @param {number} x1
  11788. * @param {number} y1
  11789. * @param {number} x2
  11790. * @param {number} y2
  11791. * @param {number} x3
  11792. * @param {number} y3
  11793. * @param {number} lineWidth
  11794. * @param {number} x
  11795. * @param {number} y
  11796. * @return {boolean}
  11797. */
  11798. containStroke: function(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  11799. if (lineWidth === 0) {
  11800. return false;
  11801. }
  11802. var _l = lineWidth;
  11803. // Quick reject
  11804. if (
  11805. (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l)
  11806. || (y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l)
  11807. || (x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l)
  11808. || (x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l)
  11809. ) {
  11810. return false;
  11811. }
  11812. var d = curve.cubicProjectPoint(
  11813. x0, y0, x1, y1, x2, y2, x3, y3,
  11814. x, y, null
  11815. );
  11816. return d <= _l / 2;
  11817. }
  11818. };
  11819. /***/ },
  11820. /* 54 */
  11821. /***/ function(module, exports, __webpack_require__) {
  11822. var curve = __webpack_require__(49);
  11823. module.exports = {
  11824. /**
  11825. * 二次贝塞尔曲线描边包含判断
  11826. * @param {number} x0
  11827. * @param {number} y0
  11828. * @param {number} x1
  11829. * @param {number} y1
  11830. * @param {number} x2
  11831. * @param {number} y2
  11832. * @param {number} lineWidth
  11833. * @param {number} x
  11834. * @param {number} y
  11835. * @return {boolean}
  11836. */
  11837. containStroke: function (x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  11838. if (lineWidth === 0) {
  11839. return false;
  11840. }
  11841. var _l = lineWidth;
  11842. // Quick reject
  11843. if (
  11844. (y > y0 + _l && y > y1 + _l && y > y2 + _l)
  11845. || (y < y0 - _l && y < y1 - _l && y < y2 - _l)
  11846. || (x > x0 + _l && x > x1 + _l && x > x2 + _l)
  11847. || (x < x0 - _l && x < x1 - _l && x < x2 - _l)
  11848. ) {
  11849. return false;
  11850. }
  11851. var d = curve.quadraticProjectPoint(
  11852. x0, y0, x1, y1, x2, y2,
  11853. x, y, null
  11854. );
  11855. return d <= _l / 2;
  11856. }
  11857. };
  11858. /***/ },
  11859. /* 55 */
  11860. /***/ function(module, exports, __webpack_require__) {
  11861. var normalizeRadian = __webpack_require__(56).normalizeRadian;
  11862. var PI2 = Math.PI * 2;
  11863. module.exports = {
  11864. /**
  11865. * 圆弧描边包含判断
  11866. * @param {number} cx
  11867. * @param {number} cy
  11868. * @param {number} r
  11869. * @param {number} startAngle
  11870. * @param {number} endAngle
  11871. * @param {boolean} anticlockwise
  11872. * @param {number} lineWidth
  11873. * @param {number} x
  11874. * @param {number} y
  11875. * @return {Boolean}
  11876. */
  11877. containStroke: function (
  11878. cx, cy, r, startAngle, endAngle, anticlockwise,
  11879. lineWidth, x, y
  11880. ) {
  11881. if (lineWidth === 0) {
  11882. return false;
  11883. }
  11884. var _l = lineWidth;
  11885. x -= cx;
  11886. y -= cy;
  11887. var d = Math.sqrt(x * x + y * y);
  11888. if ((d - _l > r) || (d + _l < r)) {
  11889. return false;
  11890. }
  11891. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  11892. // Is a circle
  11893. return true;
  11894. }
  11895. if (anticlockwise) {
  11896. var tmp = startAngle;
  11897. startAngle = normalizeRadian(endAngle);
  11898. endAngle = normalizeRadian(tmp);
  11899. } else {
  11900. startAngle = normalizeRadian(startAngle);
  11901. endAngle = normalizeRadian(endAngle);
  11902. }
  11903. if (startAngle > endAngle) {
  11904. endAngle += PI2;
  11905. }
  11906. var angle = Math.atan2(y, x);
  11907. if (angle < 0) {
  11908. angle += PI2;
  11909. }
  11910. return (angle >= startAngle && angle <= endAngle)
  11911. || (angle + PI2 >= startAngle && angle + PI2 <= endAngle);
  11912. }
  11913. };
  11914. /***/ },
  11915. /* 56 */
  11916. /***/ function(module, exports) {
  11917. var PI2 = Math.PI * 2;
  11918. module.exports = {
  11919. normalizeRadian: function(angle) {
  11920. angle %= PI2;
  11921. if (angle < 0) {
  11922. angle += PI2;
  11923. }
  11924. return angle;
  11925. }
  11926. };
  11927. /***/ },
  11928. /* 57 */
  11929. /***/ function(module, exports) {
  11930. module.exports = function windingLine(x0, y0, x1, y1, x, y) {
  11931. if ((y > y0 && y > y1) || (y < y0 && y < y1)) {
  11932. return 0;
  11933. }
  11934. if (y1 === y0) {
  11935. return 0;
  11936. }
  11937. var dir = y1 < y0 ? 1 : -1;
  11938. var t = (y - y0) / (y1 - y0);
  11939. var x_ = t * (x1 - x0) + x0;
  11940. return x_ > x ? dir : 0;
  11941. };
  11942. /***/ },
  11943. /* 58 */
  11944. /***/ function(module, exports, __webpack_require__) {
  11945. var CMD = __webpack_require__(48).CMD;
  11946. var vec2 = __webpack_require__(16);
  11947. var v2ApplyTransform = vec2.applyTransform;
  11948. var points = [[], [], []];
  11949. var mathSqrt = Math.sqrt;
  11950. var mathAtan2 = Math.atan2;
  11951. function transformPath(path, m) {
  11952. var data = path.data;
  11953. var cmd;
  11954. var nPoint;
  11955. var i;
  11956. var j;
  11957. var k;
  11958. var p;
  11959. var M = CMD.M;
  11960. var C = CMD.C;
  11961. var L = CMD.L;
  11962. var R = CMD.R;
  11963. var A = CMD.A;
  11964. var Q = CMD.Q;
  11965. for (i = 0, j = 0; i < data.length;) {
  11966. cmd = data[i++];
  11967. j = i;
  11968. nPoint = 0;
  11969. switch (cmd) {
  11970. case M:
  11971. nPoint = 1;
  11972. break;
  11973. case L:
  11974. nPoint = 1;
  11975. break;
  11976. case C:
  11977. nPoint = 3;
  11978. break;
  11979. case Q:
  11980. nPoint = 2;
  11981. break;
  11982. case A:
  11983. var x = m[4];
  11984. var y = m[5];
  11985. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  11986. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  11987. var angle = mathAtan2(-m[1] / sy, m[0] / sx);
  11988. // cx
  11989. data[i++] += x;
  11990. // cy
  11991. data[i++] += y;
  11992. // Scale rx and ry
  11993. // FIXME Assume psi is 0 here
  11994. data[i++] *= sx;
  11995. data[i++] *= sy;
  11996. // Start angle
  11997. data[i++] += angle;
  11998. // end angle
  11999. data[i++] += angle;
  12000. // FIXME psi
  12001. i += 2;
  12002. j = i;
  12003. break;
  12004. case R:
  12005. // x0, y0
  12006. p[0] = data[i++];
  12007. p[1] = data[i++];
  12008. v2ApplyTransform(p, p, m);
  12009. data[j++] = p[0];
  12010. data[j++] = p[1];
  12011. // x1, y1
  12012. p[0] += data[i++];
  12013. p[1] += data[i++];
  12014. v2ApplyTransform(p, p, m);
  12015. data[j++] = p[0];
  12016. data[j++] = p[1];
  12017. }
  12018. for (k = 0; k < nPoint; k++) {
  12019. var p = points[k];
  12020. p[0] = data[i++];
  12021. p[1] = data[i++];
  12022. v2ApplyTransform(p, p, m);
  12023. // Write back
  12024. data[j++] = p[0];
  12025. data[j++] = p[1];
  12026. }
  12027. }
  12028. }
  12029. module.exports = transformPath;
  12030. /***/ },
  12031. /* 59 */
  12032. /***/ function(module, exports, __webpack_require__) {
  12033. /**
  12034. * Image element
  12035. * @module zrender/graphic/Image
  12036. */
  12037. var Displayable = __webpack_require__(45);
  12038. var BoundingRect = __webpack_require__(15);
  12039. var zrUtil = __webpack_require__(3);
  12040. var roundRectHelper = __webpack_require__(60);
  12041. var LRU = __webpack_require__(61);
  12042. var globalImageCache = new LRU(50);
  12043. /**
  12044. * @alias zrender/graphic/Image
  12045. * @extends module:zrender/graphic/Displayable
  12046. * @constructor
  12047. * @param {Object} opts
  12048. */
  12049. function ZImage(opts) {
  12050. Displayable.call(this, opts);
  12051. }
  12052. ZImage.prototype = {
  12053. constructor: ZImage,
  12054. type: 'image',
  12055. brush: function (ctx) {
  12056. var style = this.style;
  12057. var src = style.image;
  12058. var image;
  12059. // style.image is a url string
  12060. if (typeof src === 'string') {
  12061. image = this._image;
  12062. }
  12063. // style.image is an HTMLImageElement or HTMLCanvasElement or Canvas
  12064. else {
  12065. image = src;
  12066. }
  12067. // FIXME Case create many images with src
  12068. if (!image && src) {
  12069. // Try get from global image cache
  12070. var cachedImgObj = globalImageCache.get(src);
  12071. if (!cachedImgObj) {
  12072. // Create a new image
  12073. image = new Image();
  12074. image.onload = function () {
  12075. image.onload = null;
  12076. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  12077. cachedImgObj.pending[i].dirty();
  12078. }
  12079. };
  12080. cachedImgObj = {
  12081. image: image,
  12082. pending: [this]
  12083. };
  12084. image.src = src;
  12085. globalImageCache.put(src, cachedImgObj);
  12086. this._image = image;
  12087. return;
  12088. }
  12089. else {
  12090. image = cachedImgObj.image;
  12091. this._image = image;
  12092. // Image is not complete finish, add to pending list
  12093. if (!image.width || !image.height) {
  12094. cachedImgObj.pending.push(this);
  12095. return;
  12096. }
  12097. }
  12098. }
  12099. if (image) {
  12100. // 图片已经加载完成
  12101. // if (image.nodeName.toUpperCase() == 'IMG') {
  12102. // if (!image.complete) {
  12103. // return;
  12104. // }
  12105. // }
  12106. // Else is canvas
  12107. var width = style.width || image.width;
  12108. var height = style.height || image.height;
  12109. var x = style.x || 0;
  12110. var y = style.y || 0;
  12111. // 图片加载失败
  12112. if (!image.width || !image.height) {
  12113. return;
  12114. }
  12115. ctx.save();
  12116. style.bind(ctx);
  12117. // 设置transform
  12118. this.setTransform(ctx);
  12119. if (style.r) {
  12120. // Border radius clipping
  12121. // FIXME
  12122. ctx.beginPath();
  12123. roundRectHelper.buildPath(ctx, style);
  12124. ctx.clip();
  12125. }
  12126. if (style.sWidth && style.sHeight) {
  12127. var sx = style.sx || 0;
  12128. var sy = style.sy || 0;
  12129. ctx.drawImage(
  12130. image,
  12131. sx, sy, style.sWidth, style.sHeight,
  12132. x, y, width, height
  12133. );
  12134. }
  12135. else if (style.sx && style.sy) {
  12136. var sx = style.sx;
  12137. var sy = style.sy;
  12138. var sWidth = width - sx;
  12139. var sHeight = height - sy;
  12140. ctx.drawImage(
  12141. image,
  12142. sx, sy, sWidth, sHeight,
  12143. x, y, width, height
  12144. );
  12145. }
  12146. else {
  12147. ctx.drawImage(image, x, y, width, height);
  12148. }
  12149. // 如果没设置宽和高的话自动根据图片宽高设置
  12150. if (style.width == null) {
  12151. style.width = width;
  12152. }
  12153. if (style.height == null) {
  12154. style.height = height;
  12155. }
  12156. // Draw rect text
  12157. if (style.text != null) {
  12158. this.drawRectText(ctx, this.getBoundingRect());
  12159. }
  12160. ctx.restore();
  12161. }
  12162. },
  12163. getBoundingRect: function () {
  12164. var style = this.style;
  12165. if (! this._rect) {
  12166. this._rect = new BoundingRect(
  12167. style.x || 0, style.y || 0, style.width || 0, style.height || 0
  12168. );
  12169. }
  12170. return this._rect;
  12171. }
  12172. };
  12173. zrUtil.inherits(ZImage, Displayable);
  12174. module.exports = ZImage;
  12175. /***/ },
  12176. /* 60 */
  12177. /***/ function(module, exports) {
  12178. module.exports = {
  12179. buildPath: function (ctx, shape) {
  12180. var x = shape.x;
  12181. var y = shape.y;
  12182. var width = shape.width;
  12183. var height = shape.height;
  12184. var r = shape.r;
  12185. var r1;
  12186. var r2;
  12187. var r3;
  12188. var r4;
  12189. // Convert width and height to positive for better borderRadius
  12190. if (width < 0) {
  12191. x = x + width;
  12192. width = -width;
  12193. }
  12194. if (height < 0) {
  12195. y = y + height;
  12196. height = -height;
  12197. }
  12198. if (typeof r === 'number') {
  12199. r1 = r2 = r3 = r4 = r;
  12200. }
  12201. else if (r instanceof Array) {
  12202. if (r.length === 1) {
  12203. r1 = r2 = r3 = r4 = r[0];
  12204. }
  12205. else if (r.length === 2) {
  12206. r1 = r3 = r[0];
  12207. r2 = r4 = r[1];
  12208. }
  12209. else if (r.length === 3) {
  12210. r1 = r[0];
  12211. r2 = r4 = r[1];
  12212. r3 = r[2];
  12213. }
  12214. else {
  12215. r1 = r[0];
  12216. r2 = r[1];
  12217. r3 = r[2];
  12218. r4 = r[3];
  12219. }
  12220. }
  12221. else {
  12222. r1 = r2 = r3 = r4 = 0;
  12223. }
  12224. var total;
  12225. if (r1 + r2 > width) {
  12226. total = r1 + r2;
  12227. r1 *= width / total;
  12228. r2 *= width / total;
  12229. }
  12230. if (r3 + r4 > width) {
  12231. total = r3 + r4;
  12232. r3 *= width / total;
  12233. r4 *= width / total;
  12234. }
  12235. if (r2 + r3 > height) {
  12236. total = r2 + r3;
  12237. r2 *= height / total;
  12238. r3 *= height / total;
  12239. }
  12240. if (r1 + r4 > height) {
  12241. total = r1 + r4;
  12242. r1 *= height / total;
  12243. r4 *= height / total;
  12244. }
  12245. ctx.moveTo(x + r1, y);
  12246. ctx.lineTo(x + width - r2, y);
  12247. r2 !== 0 && ctx.quadraticCurveTo(
  12248. x + width, y, x + width, y + r2
  12249. );
  12250. ctx.lineTo(x + width, y + height - r3);
  12251. r3 !== 0 && ctx.quadraticCurveTo(
  12252. x + width, y + height, x + width - r3, y + height
  12253. );
  12254. ctx.lineTo(x + r4, y + height);
  12255. r4 !== 0 && ctx.quadraticCurveTo(
  12256. x, y + height, x, y + height - r4
  12257. );
  12258. ctx.lineTo(x, y + r1);
  12259. r1 !== 0 && ctx.quadraticCurveTo(x, y, x + r1, y);
  12260. }
  12261. };
  12262. /***/ },
  12263. /* 61 */
  12264. /***/ function(module, exports) {
  12265. // Simple LRU cache use doubly linked list
  12266. // @module zrender/core/LRU
  12267. /**
  12268. * Simple double linked list. Compared with array, it has O(1) remove operation.
  12269. * @constructor
  12270. */
  12271. var LinkedList = function() {
  12272. /**
  12273. * @type {module:zrender/core/LRU~Entry}
  12274. */
  12275. this.head = null;
  12276. /**
  12277. * @type {module:zrender/core/LRU~Entry}
  12278. */
  12279. this.tail = null;
  12280. this._len = 0;
  12281. };
  12282. var linkedListProto = LinkedList.prototype;
  12283. /**
  12284. * Insert a new value at the tail
  12285. * @param {} val
  12286. * @return {module:zrender/core/LRU~Entry}
  12287. */
  12288. linkedListProto.insert = function(val) {
  12289. var entry = new Entry(val);
  12290. this.insertEntry(entry);
  12291. return entry;
  12292. };
  12293. /**
  12294. * Insert an entry at the tail
  12295. * @param {module:zrender/core/LRU~Entry} entry
  12296. */
  12297. linkedListProto.insertEntry = function(entry) {
  12298. if (!this.head) {
  12299. this.head = this.tail = entry;
  12300. }
  12301. else {
  12302. this.tail.next = entry;
  12303. entry.prev = this.tail;
  12304. this.tail = entry;
  12305. }
  12306. this._len++;
  12307. };
  12308. /**
  12309. * Remove entry.
  12310. * @param {module:zrender/core/LRU~Entry} entry
  12311. */
  12312. linkedListProto.remove = function(entry) {
  12313. var prev = entry.prev;
  12314. var next = entry.next;
  12315. if (prev) {
  12316. prev.next = next;
  12317. }
  12318. else {
  12319. // Is head
  12320. this.head = next;
  12321. }
  12322. if (next) {
  12323. next.prev = prev;
  12324. }
  12325. else {
  12326. // Is tail
  12327. this.tail = prev;
  12328. }
  12329. entry.next = entry.prev = null;
  12330. this._len--;
  12331. };
  12332. /**
  12333. * @return {number}
  12334. */
  12335. linkedListProto.len = function() {
  12336. return this._len;
  12337. };
  12338. /**
  12339. * @constructor
  12340. * @param {} val
  12341. */
  12342. var Entry = function(val) {
  12343. /**
  12344. * @type {}
  12345. */
  12346. this.value = val;
  12347. /**
  12348. * @type {module:zrender/core/LRU~Entry}
  12349. */
  12350. this.next;
  12351. /**
  12352. * @type {module:zrender/core/LRU~Entry}
  12353. */
  12354. this.prev;
  12355. };
  12356. /**
  12357. * LRU Cache
  12358. * @constructor
  12359. * @alias module:zrender/core/LRU
  12360. */
  12361. var LRU = function(maxSize) {
  12362. this._list = new LinkedList();
  12363. this._map = {};
  12364. this._maxSize = maxSize || 10;
  12365. };
  12366. var LRUProto = LRU.prototype;
  12367. /**
  12368. * @param {string} key
  12369. * @param {} value
  12370. */
  12371. LRUProto.put = function(key, value) {
  12372. var list = this._list;
  12373. var map = this._map;
  12374. if (map[key] == null) {
  12375. var len = list.len();
  12376. if (len >= this._maxSize && len > 0) {
  12377. // Remove the least recently used
  12378. var leastUsedEntry = list.head;
  12379. list.remove(leastUsedEntry);
  12380. delete map[leastUsedEntry.key];
  12381. }
  12382. var entry = list.insert(value);
  12383. entry.key = key;
  12384. map[key] = entry;
  12385. }
  12386. };
  12387. /**
  12388. * @param {string} key
  12389. * @return {}
  12390. */
  12391. LRUProto.get = function(key) {
  12392. var entry = this._map[key];
  12393. var list = this._list;
  12394. if (entry != null) {
  12395. // Put the latest used entry in the tail
  12396. if (entry !== list.tail) {
  12397. list.remove(entry);
  12398. list.insertEntry(entry);
  12399. }
  12400. return entry.value;
  12401. }
  12402. };
  12403. /**
  12404. * Clear the cache
  12405. */
  12406. LRUProto.clear = function() {
  12407. this._list.clear();
  12408. this._map = {};
  12409. };
  12410. module.exports = LRU;
  12411. /***/ },
  12412. /* 62 */
  12413. /***/ function(module, exports, __webpack_require__) {
  12414. /**
  12415. * Text element
  12416. * @module zrender/graphic/Text
  12417. *
  12418. * TODO Wrapping
  12419. *
  12420. * Text not support gradient
  12421. */
  12422. var Displayable = __webpack_require__(45);
  12423. var zrUtil = __webpack_require__(3);
  12424. var textContain = __webpack_require__(14);
  12425. /**
  12426. * @alias zrender/graphic/Text
  12427. * @extends module:zrender/graphic/Displayable
  12428. * @constructor
  12429. * @param {Object} opts
  12430. */
  12431. var Text = function (opts) {
  12432. Displayable.call(this, opts);
  12433. };
  12434. Text.prototype = {
  12435. constructor: Text,
  12436. type: 'text',
  12437. brush: function (ctx) {
  12438. var style = this.style;
  12439. var x = style.x || 0;
  12440. var y = style.y || 0;
  12441. // Convert to string
  12442. var text = style.text;
  12443. var textFill = style.fill;
  12444. var textStroke = style.stroke;
  12445. // Convert to string
  12446. text != null && (text += '');
  12447. if (text) {
  12448. ctx.save();
  12449. this.style.bind(ctx);
  12450. this.setTransform(ctx);
  12451. textFill && (ctx.fillStyle = textFill);
  12452. textStroke && (ctx.strokeStyle = textStroke);
  12453. ctx.font = style.textFont || style.font;
  12454. ctx.textAlign = style.textAlign;
  12455. if (style.textVerticalAlign) {
  12456. var rect = textContain.getBoundingRect(
  12457. text, ctx.font, style.textAlign, 'top'
  12458. );
  12459. // Ignore textBaseline
  12460. ctx.textBaseline = 'middle';
  12461. switch (style.textVerticalAlign) {
  12462. case 'middle':
  12463. y -= rect.height / 2 - rect.lineHeight / 2;
  12464. break;
  12465. case 'bottom':
  12466. y -= rect.height - rect.lineHeight / 2;
  12467. break;
  12468. default:
  12469. y += rect.lineHeight / 2;
  12470. }
  12471. }
  12472. else {
  12473. ctx.textBaseline = style.textBaseline;
  12474. }
  12475. var lineHeight = textContain.measureText('国', ctx.font).width;
  12476. var textLines = text.split('\n');
  12477. for (var i = 0; i < textLines.length; i++) {
  12478. textFill && ctx.fillText(textLines[i], x, y);
  12479. textStroke && ctx.strokeText(textLines[i], x, y);
  12480. y += lineHeight;
  12481. }
  12482. ctx.restore();
  12483. }
  12484. },
  12485. getBoundingRect: function () {
  12486. if (!this._rect) {
  12487. var style = this.style;
  12488. var textVerticalAlign = style.textVerticalAlign;
  12489. var rect = textContain.getBoundingRect(
  12490. style.text + '', style.textFont || style.font, style.textAlign,
  12491. textVerticalAlign ? 'top' : style.textBaseline
  12492. );
  12493. switch (textVerticalAlign) {
  12494. case 'middle':
  12495. rect.y -= rect.height / 2;
  12496. break;
  12497. case 'bottom':
  12498. rect.y -= rect.height;
  12499. break;
  12500. }
  12501. rect.x += style.x || 0;
  12502. rect.y += style.y || 0;
  12503. this._rect = rect;
  12504. }
  12505. return this._rect;
  12506. }
  12507. };
  12508. zrUtil.inherits(Text, Displayable);
  12509. module.exports = Text;
  12510. /***/ },
  12511. /* 63 */
  12512. /***/ function(module, exports, __webpack_require__) {
  12513. 'use strict';
  12514. /**
  12515. * 圆形
  12516. * @module zrender/shape/Circle
  12517. */
  12518. module.exports = __webpack_require__(44).extend({
  12519. type: 'circle',
  12520. shape: {
  12521. cx: 0,
  12522. cy: 0,
  12523. r: 0
  12524. },
  12525. buildPath : function (ctx, shape) {
  12526. // Better stroking in ShapeBundle
  12527. ctx.moveTo(shape.cx + shape.r, shape.cy);
  12528. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  12529. return;
  12530. }
  12531. });
  12532. /***/ },
  12533. /* 64 */
  12534. /***/ function(module, exports, __webpack_require__) {
  12535. /**
  12536. * 扇形
  12537. * @module zrender/graphic/shape/Sector
  12538. */
  12539. // FIXME clockwise seems wrong
  12540. module.exports = __webpack_require__(44).extend({
  12541. type: 'sector',
  12542. shape: {
  12543. cx: 0,
  12544. cy: 0,
  12545. r0: 0,
  12546. r: 0,
  12547. startAngle: 0,
  12548. endAngle: Math.PI * 2,
  12549. clockwise: true
  12550. },
  12551. buildPath: function (ctx, shape) {
  12552. var x = shape.cx;
  12553. var y = shape.cy;
  12554. var r0 = Math.max(shape.r0 || 0, 0);
  12555. var r = Math.max(shape.r, 0);
  12556. var startAngle = shape.startAngle;
  12557. var endAngle = shape.endAngle;
  12558. var clockwise = shape.clockwise;
  12559. var unitX = Math.cos(startAngle);
  12560. var unitY = Math.sin(startAngle);
  12561. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  12562. ctx.lineTo(unitX * r + x, unitY * r + y);
  12563. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  12564. ctx.lineTo(
  12565. Math.cos(endAngle) * r0 + x,
  12566. Math.sin(endAngle) * r0 + y
  12567. );
  12568. if (r0 !== 0) {
  12569. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  12570. }
  12571. ctx.closePath();
  12572. }
  12573. });
  12574. /***/ },
  12575. /* 65 */
  12576. /***/ function(module, exports, __webpack_require__) {
  12577. /**
  12578. * 圆环
  12579. * @module zrender/graphic/shape/Ring
  12580. */
  12581. module.exports = __webpack_require__(44).extend({
  12582. type: 'ring',
  12583. shape: {
  12584. cx: 0,
  12585. cy: 0,
  12586. r: 0,
  12587. r0: 0
  12588. },
  12589. buildPath: function (ctx, shape) {
  12590. var x = shape.cx;
  12591. var y = shape.cy;
  12592. var PI2 = Math.PI * 2;
  12593. ctx.moveTo(x + shape.r, y);
  12594. ctx.arc(x, y, shape.r, 0, PI2, false);
  12595. ctx.moveTo(x + shape.r0, y);
  12596. ctx.arc(x, y, shape.r0, 0, PI2, true);
  12597. }
  12598. });
  12599. /***/ },
  12600. /* 66 */
  12601. /***/ function(module, exports, __webpack_require__) {
  12602. /**
  12603. * 多边形
  12604. * @module zrender/shape/Polygon
  12605. */
  12606. var polyHelper = __webpack_require__(67);
  12607. module.exports = __webpack_require__(44).extend({
  12608. type: 'polygon',
  12609. shape: {
  12610. points: null,
  12611. smooth: false,
  12612. smoothConstraint: null
  12613. },
  12614. buildPath: function (ctx, shape) {
  12615. polyHelper.buildPath(ctx, shape, true);
  12616. }
  12617. });
  12618. /***/ },
  12619. /* 67 */
  12620. /***/ function(module, exports, __webpack_require__) {
  12621. var smoothSpline = __webpack_require__(68);
  12622. var smoothBezier = __webpack_require__(69);
  12623. module.exports = {
  12624. buildPath: function (ctx, shape, closePath) {
  12625. var points = shape.points;
  12626. var smooth = shape.smooth;
  12627. if (points && points.length >= 2) {
  12628. if (smooth && smooth !== 'spline') {
  12629. var controlPoints = smoothBezier(
  12630. points, smooth, closePath, shape.smoothConstraint
  12631. );
  12632. ctx.moveTo(points[0][0], points[0][1]);
  12633. var len = points.length;
  12634. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  12635. var cp1 = controlPoints[i * 2];
  12636. var cp2 = controlPoints[i * 2 + 1];
  12637. var p = points[(i + 1) % len];
  12638. ctx.bezierCurveTo(
  12639. cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]
  12640. );
  12641. }
  12642. }
  12643. else {
  12644. if (smooth === 'spline') {
  12645. points = smoothSpline(points, closePath);
  12646. }
  12647. ctx.moveTo(points[0][0], points[0][1]);
  12648. for (var i = 1, l = points.length; i < l; i++) {
  12649. ctx.lineTo(points[i][0], points[i][1]);
  12650. }
  12651. }
  12652. closePath && ctx.closePath();
  12653. }
  12654. }
  12655. };
  12656. /***/ },
  12657. /* 68 */
  12658. /***/ function(module, exports, __webpack_require__) {
  12659. /**
  12660. * Catmull-Rom spline 插值折线
  12661. * @module zrender/shape/util/smoothSpline
  12662. * @author pissang (https://www.github.com/pissang)
  12663. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  12664. * errorrik (errorrik@gmail.com)
  12665. */
  12666. var vec2 = __webpack_require__(16);
  12667. /**
  12668. * @inner
  12669. */
  12670. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  12671. var v0 = (p2 - p0) * 0.5;
  12672. var v1 = (p3 - p1) * 0.5;
  12673. return (2 * (p1 - p2) + v0 + v1) * t3
  12674. + (-3 * (p1 - p2) - 2 * v0 - v1) * t2
  12675. + v0 * t + p1;
  12676. }
  12677. /**
  12678. * @alias module:zrender/shape/util/smoothSpline
  12679. * @param {Array} points 线段顶点数组
  12680. * @param {boolean} isLoop
  12681. * @return {Array}
  12682. */
  12683. module.exports = function (points, isLoop) {
  12684. var len = points.length;
  12685. var ret = [];
  12686. var distance = 0;
  12687. for (var i = 1; i < len; i++) {
  12688. distance += vec2.distance(points[i - 1], points[i]);
  12689. }
  12690. var segs = distance / 2;
  12691. segs = segs < len ? len : segs;
  12692. for (var i = 0; i < segs; i++) {
  12693. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  12694. var idx = Math.floor(pos);
  12695. var w = pos - idx;
  12696. var p0;
  12697. var p1 = points[idx % len];
  12698. var p2;
  12699. var p3;
  12700. if (!isLoop) {
  12701. p0 = points[idx === 0 ? idx : idx - 1];
  12702. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  12703. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  12704. }
  12705. else {
  12706. p0 = points[(idx - 1 + len) % len];
  12707. p2 = points[(idx + 1) % len];
  12708. p3 = points[(idx + 2) % len];
  12709. }
  12710. var w2 = w * w;
  12711. var w3 = w * w2;
  12712. ret.push([
  12713. interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3),
  12714. interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)
  12715. ]);
  12716. }
  12717. return ret;
  12718. };
  12719. /***/ },
  12720. /* 69 */
  12721. /***/ function(module, exports, __webpack_require__) {
  12722. /**
  12723. * 贝塞尔平滑曲线
  12724. * @module zrender/shape/util/smoothBezier
  12725. * @author pissang (https://www.github.com/pissang)
  12726. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  12727. * errorrik (errorrik@gmail.com)
  12728. */
  12729. var vec2 = __webpack_require__(16);
  12730. var v2Min = vec2.min;
  12731. var v2Max = vec2.max;
  12732. var v2Scale = vec2.scale;
  12733. var v2Distance = vec2.distance;
  12734. var v2Add = vec2.add;
  12735. /**
  12736. * 贝塞尔平滑曲线
  12737. * @alias module:zrender/shape/util/smoothBezier
  12738. * @param {Array} points 线段顶点数组
  12739. * @param {number} smooth 平滑等级, 0-1
  12740. * @param {boolean} isLoop
  12741. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  12742. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  12743. * 整个折线的包围盒做一个并集用来约束控制点。
  12744. * @param {Array} 计算出来的控制点数组
  12745. */
  12746. module.exports = function (points, smooth, isLoop, constraint) {
  12747. var cps = [];
  12748. var v = [];
  12749. var v1 = [];
  12750. var v2 = [];
  12751. var prevPoint;
  12752. var nextPoint;
  12753. var min, max;
  12754. if (constraint) {
  12755. min = [Infinity, Infinity];
  12756. max = [-Infinity, -Infinity];
  12757. for (var i = 0, len = points.length; i < len; i++) {
  12758. v2Min(min, min, points[i]);
  12759. v2Max(max, max, points[i]);
  12760. }
  12761. // 与指定的包围盒做并集
  12762. v2Min(min, min, constraint[0]);
  12763. v2Max(max, max, constraint[1]);
  12764. }
  12765. for (var i = 0, len = points.length; i < len; i++) {
  12766. var point = points[i];
  12767. if (isLoop) {
  12768. prevPoint = points[i ? i - 1 : len - 1];
  12769. nextPoint = points[(i + 1) % len];
  12770. }
  12771. else {
  12772. if (i === 0 || i === len - 1) {
  12773. cps.push(vec2.clone(points[i]));
  12774. continue;
  12775. }
  12776. else {
  12777. prevPoint = points[i - 1];
  12778. nextPoint = points[i + 1];
  12779. }
  12780. }
  12781. vec2.sub(v, nextPoint, prevPoint);
  12782. // use degree to scale the handle length
  12783. v2Scale(v, v, smooth);
  12784. var d0 = v2Distance(point, prevPoint);
  12785. var d1 = v2Distance(point, nextPoint);
  12786. var sum = d0 + d1;
  12787. if (sum !== 0) {
  12788. d0 /= sum;
  12789. d1 /= sum;
  12790. }
  12791. v2Scale(v1, v, -d0);
  12792. v2Scale(v2, v, d1);
  12793. var cp0 = v2Add([], point, v1);
  12794. var cp1 = v2Add([], point, v2);
  12795. if (constraint) {
  12796. v2Max(cp0, cp0, min);
  12797. v2Min(cp0, cp0, max);
  12798. v2Max(cp1, cp1, min);
  12799. v2Min(cp1, cp1, max);
  12800. }
  12801. cps.push(cp0);
  12802. cps.push(cp1);
  12803. }
  12804. if (isLoop) {
  12805. cps.push(cps.shift());
  12806. }
  12807. return cps;
  12808. };
  12809. /***/ },
  12810. /* 70 */
  12811. /***/ function(module, exports, __webpack_require__) {
  12812. /**
  12813. * @module zrender/graphic/shape/Polyline
  12814. */
  12815. var polyHelper = __webpack_require__(67);
  12816. module.exports = __webpack_require__(44).extend({
  12817. type: 'polyline',
  12818. shape: {
  12819. points: null,
  12820. smooth: false,
  12821. smoothConstraint: null
  12822. },
  12823. style: {
  12824. stroke: '#000',
  12825. fill: null
  12826. },
  12827. buildPath: function (ctx, shape) {
  12828. polyHelper.buildPath(ctx, shape, false);
  12829. }
  12830. });
  12831. /***/ },
  12832. /* 71 */
  12833. /***/ function(module, exports, __webpack_require__) {
  12834. /**
  12835. * 矩形
  12836. * @module zrender/graphic/shape/Rect
  12837. */
  12838. var roundRectHelper = __webpack_require__(60);
  12839. module.exports = __webpack_require__(44).extend({
  12840. type: 'rect',
  12841. shape: {
  12842. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  12843. // r缩写为1 相当于 [1, 1, 1, 1]
  12844. // r缩写为[1] 相当于 [1, 1, 1, 1]
  12845. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  12846. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  12847. r: 0,
  12848. x: 0,
  12849. y: 0,
  12850. width: 0,
  12851. height: 0
  12852. },
  12853. buildPath: function (ctx, shape) {
  12854. var x = shape.x;
  12855. var y = shape.y;
  12856. var width = shape.width;
  12857. var height = shape.height;
  12858. if (!shape.r) {
  12859. ctx.rect(x, y, width, height);
  12860. }
  12861. else {
  12862. roundRectHelper.buildPath(ctx, shape);
  12863. }
  12864. ctx.closePath();
  12865. return;
  12866. }
  12867. });
  12868. /***/ },
  12869. /* 72 */
  12870. /***/ function(module, exports, __webpack_require__) {
  12871. /**
  12872. * 直线
  12873. * @module zrender/graphic/shape/Line
  12874. */
  12875. module.exports = __webpack_require__(44).extend({
  12876. type: 'line',
  12877. shape: {
  12878. // Start point
  12879. x1: 0,
  12880. y1: 0,
  12881. // End point
  12882. x2: 0,
  12883. y2: 0,
  12884. percent: 1
  12885. },
  12886. style: {
  12887. stroke: '#000',
  12888. fill: null
  12889. },
  12890. buildPath: function (ctx, shape) {
  12891. var x1 = shape.x1;
  12892. var y1 = shape.y1;
  12893. var x2 = shape.x2;
  12894. var y2 = shape.y2;
  12895. var percent = shape.percent;
  12896. if (percent === 0) {
  12897. return;
  12898. }
  12899. ctx.moveTo(x1, y1);
  12900. if (percent < 1) {
  12901. x2 = x1 * (1 - percent) + x2 * percent;
  12902. y2 = y1 * (1 - percent) + y2 * percent;
  12903. }
  12904. ctx.lineTo(x2, y2);
  12905. },
  12906. /**
  12907. * Get point at percent
  12908. * @param {number} percent
  12909. * @return {Array.<number>}
  12910. */
  12911. pointAt: function (p) {
  12912. var shape = this.shape;
  12913. return [
  12914. shape.x1 * (1 - p) + shape.x2 * p,
  12915. shape.y1 * (1 - p) + shape.y2 * p
  12916. ];
  12917. }
  12918. });
  12919. /***/ },
  12920. /* 73 */
  12921. /***/ function(module, exports, __webpack_require__) {
  12922. 'use strict';
  12923. /**
  12924. * 贝塞尔曲线
  12925. * @module zrender/shape/BezierCurve
  12926. */
  12927. var curveTool = __webpack_require__(49);
  12928. var vec2 = __webpack_require__(16);
  12929. var quadraticSubdivide = curveTool.quadraticSubdivide;
  12930. var cubicSubdivide = curveTool.cubicSubdivide;
  12931. var quadraticAt = curveTool.quadraticAt;
  12932. var cubicAt = curveTool.cubicAt;
  12933. var quadraticDerivativeAt = curveTool.quadraticDerivativeAt;
  12934. var cubicDerivativeAt = curveTool.cubicDerivativeAt;
  12935. var out = [];
  12936. function someVectorAt(shape, t, isTangent) {
  12937. var cpx2 = shape.cpx2;
  12938. var cpy2 = shape.cpy2;
  12939. if (cpx2 === null || cpy2 === null) {
  12940. return [
  12941. (isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t),
  12942. (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)
  12943. ];
  12944. }
  12945. else {
  12946. return [
  12947. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t),
  12948. (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)
  12949. ];
  12950. }
  12951. }
  12952. module.exports = __webpack_require__(44).extend({
  12953. type: 'bezier-curve',
  12954. shape: {
  12955. x1: 0,
  12956. y1: 0,
  12957. x2: 0,
  12958. y2: 0,
  12959. cpx1: 0,
  12960. cpy1: 0,
  12961. // cpx2: 0,
  12962. // cpy2: 0
  12963. // Curve show percent, for animating
  12964. percent: 1
  12965. },
  12966. style: {
  12967. stroke: '#000',
  12968. fill: null
  12969. },
  12970. buildPath: function (ctx, shape) {
  12971. var x1 = shape.x1;
  12972. var y1 = shape.y1;
  12973. var x2 = shape.x2;
  12974. var y2 = shape.y2;
  12975. var cpx1 = shape.cpx1;
  12976. var cpy1 = shape.cpy1;
  12977. var cpx2 = shape.cpx2;
  12978. var cpy2 = shape.cpy2;
  12979. var percent = shape.percent;
  12980. if (percent === 0) {
  12981. return;
  12982. }
  12983. ctx.moveTo(x1, y1);
  12984. if (cpx2 == null || cpy2 == null) {
  12985. if (percent < 1) {
  12986. quadraticSubdivide(
  12987. x1, cpx1, x2, percent, out
  12988. );
  12989. cpx1 = out[1];
  12990. x2 = out[2];
  12991. quadraticSubdivide(
  12992. y1, cpy1, y2, percent, out
  12993. );
  12994. cpy1 = out[1];
  12995. y2 = out[2];
  12996. }
  12997. ctx.quadraticCurveTo(
  12998. cpx1, cpy1,
  12999. x2, y2
  13000. );
  13001. }
  13002. else {
  13003. if (percent < 1) {
  13004. cubicSubdivide(
  13005. x1, cpx1, cpx2, x2, percent, out
  13006. );
  13007. cpx1 = out[1];
  13008. cpx2 = out[2];
  13009. x2 = out[3];
  13010. cubicSubdivide(
  13011. y1, cpy1, cpy2, y2, percent, out
  13012. );
  13013. cpy1 = out[1];
  13014. cpy2 = out[2];
  13015. y2 = out[3];
  13016. }
  13017. ctx.bezierCurveTo(
  13018. cpx1, cpy1,
  13019. cpx2, cpy2,
  13020. x2, y2
  13021. );
  13022. }
  13023. },
  13024. /**
  13025. * Get point at percent
  13026. * @param {number} t
  13027. * @return {Array.<number>}
  13028. */
  13029. pointAt: function (t) {
  13030. return someVectorAt(this.shape, t, false);
  13031. },
  13032. /**
  13033. * Get tangent at percent
  13034. * @param {number} t
  13035. * @return {Array.<number>}
  13036. */
  13037. tangentAt: function (t) {
  13038. var p = someVectorAt(this.shape, t, true);
  13039. return vec2.normalize(p, p);
  13040. }
  13041. });
  13042. /***/ },
  13043. /* 74 */
  13044. /***/ function(module, exports, __webpack_require__) {
  13045. /**
  13046. * 圆弧
  13047. * @module zrender/graphic/shape/Arc
  13048. */
  13049. module.exports = __webpack_require__(44).extend({
  13050. type: 'arc',
  13051. shape: {
  13052. cx: 0,
  13053. cy: 0,
  13054. r: 0,
  13055. startAngle: 0,
  13056. endAngle: Math.PI * 2,
  13057. clockwise: true
  13058. },
  13059. style: {
  13060. stroke: '#000',
  13061. fill: null
  13062. },
  13063. buildPath: function (ctx, shape) {
  13064. var x = shape.cx;
  13065. var y = shape.cy;
  13066. var r = Math.max(shape.r, 0);
  13067. var startAngle = shape.startAngle;
  13068. var endAngle = shape.endAngle;
  13069. var clockwise = shape.clockwise;
  13070. var unitX = Math.cos(startAngle);
  13071. var unitY = Math.sin(startAngle);
  13072. ctx.moveTo(unitX * r + x, unitY * r + y);
  13073. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  13074. }
  13075. });
  13076. /***/ },
  13077. /* 75 */
  13078. /***/ function(module, exports, __webpack_require__) {
  13079. // CompoundPath to improve performance
  13080. var Path = __webpack_require__(44);
  13081. module.exports = Path.extend({
  13082. type: 'compound',
  13083. shape: {
  13084. paths: null
  13085. },
  13086. _updatePathDirty: function () {
  13087. var dirtyPath = this.__dirtyPath;
  13088. var paths = this.shape.paths;
  13089. for (var i = 0; i < paths.length; i++) {
  13090. // Mark as dirty if any subpath is dirty
  13091. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  13092. }
  13093. this.__dirtyPath = dirtyPath;
  13094. this.__dirty = this.__dirty || dirtyPath;
  13095. },
  13096. beforeBrush: function () {
  13097. this._updatePathDirty();
  13098. var paths = this.shape.paths || [];
  13099. var scale = this.getGlobalScale();
  13100. // Update path scale
  13101. for (var i = 0; i < paths.length; i++) {
  13102. paths[i].path.setScale(scale[0], scale[1]);
  13103. }
  13104. },
  13105. buildPath: function (ctx, shape) {
  13106. var paths = shape.paths || [];
  13107. for (var i = 0; i < paths.length; i++) {
  13108. paths[i].buildPath(ctx, paths[i].shape);
  13109. }
  13110. },
  13111. afterBrush: function () {
  13112. var paths = this.shape.paths;
  13113. for (var i = 0; i < paths.length; i++) {
  13114. paths[i].__dirtyPath = false;
  13115. }
  13116. },
  13117. getBoundingRect: function () {
  13118. this._updatePathDirty();
  13119. return Path.prototype.getBoundingRect.call(this);
  13120. }
  13121. });
  13122. /***/ },
  13123. /* 76 */
  13124. /***/ function(module, exports, __webpack_require__) {
  13125. 'use strict';
  13126. var zrUtil = __webpack_require__(3);
  13127. var Gradient = __webpack_require__(4);
  13128. /**
  13129. * x, y, x2, y2 are all percent from 0 to 1
  13130. * @param {number} [x=0]
  13131. * @param {number} [y=0]
  13132. * @param {number} [x2=1]
  13133. * @param {number} [y2=0]
  13134. * @param {Array.<Object>} colorStops
  13135. */
  13136. var LinearGradient = function (x, y, x2, y2, colorStops) {
  13137. this.x = x == null ? 0 : x;
  13138. this.y = y == null ? 0 : y;
  13139. this.x2 = x2 == null ? 1 : x2;
  13140. this.y2 = y2 == null ? 0 : y2;
  13141. Gradient.call(this, colorStops);
  13142. };
  13143. LinearGradient.prototype = {
  13144. constructor: LinearGradient,
  13145. type: 'linear'
  13146. };
  13147. zrUtil.inherits(LinearGradient, Gradient);
  13148. module.exports = LinearGradient;
  13149. /***/ },
  13150. /* 77 */
  13151. /***/ function(module, exports, __webpack_require__) {
  13152. 'use strict';
  13153. var zrUtil = __webpack_require__(3);
  13154. var Gradient = __webpack_require__(4);
  13155. /**
  13156. * x, y, r are all percent from 0 to 1
  13157. * @param {number} [x=0.5]
  13158. * @param {number} [y=0.5]
  13159. * @param {number} [r=0.5]
  13160. * @param {Array.<Object>} [colorStops]
  13161. */
  13162. var RadialGradient = function (x, y, r, colorStops) {
  13163. this.x = x == null ? 0.5 : x;
  13164. this.y = y == null ? 0.5 : y;
  13165. this.r = r == null ? 0.5 : r;
  13166. Gradient.call(this, colorStops);
  13167. };
  13168. RadialGradient.prototype = {
  13169. constructor: RadialGradient,
  13170. type: 'radial'
  13171. };
  13172. zrUtil.inherits(RadialGradient, Gradient);
  13173. module.exports = RadialGradient;
  13174. /***/ },
  13175. /* 78 */
  13176. /***/ function(module, exports, __webpack_require__) {
  13177. /*!
  13178. * ZRender, a high performance 2d drawing library.
  13179. *
  13180. * Copyright (c) 2013, Baidu Inc.
  13181. * All rights reserved.
  13182. *
  13183. * LICENSE
  13184. * https://github.com/ecomfe/zrender/blob/master/LICENSE.txt
  13185. */
  13186. // Global defines
  13187. var guid = __webpack_require__(31);
  13188. var env = __webpack_require__(79);
  13189. var Handler = __webpack_require__(80);
  13190. var Storage = __webpack_require__(84);
  13191. var Animation = __webpack_require__(85);
  13192. var useVML = !env.canvasSupported;
  13193. var painterCtors = {
  13194. canvas: __webpack_require__(86)
  13195. };
  13196. var instances = {}; // ZRender实例map索引
  13197. var zrender = {};
  13198. /**
  13199. * @type {string}
  13200. */
  13201. zrender.version = '3.1.0';
  13202. /**
  13203. * Initializing a zrender instance
  13204. * @param {HTMLElement} dom
  13205. * @param {Object} opts
  13206. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  13207. * @param {number} [opts.devicePixelRatio]
  13208. * @return {module:zrender/ZRender}
  13209. */
  13210. zrender.init = function(dom, opts) {
  13211. var zr = new ZRender(guid(), dom, opts);
  13212. instances[zr.id] = zr;
  13213. return zr;
  13214. };
  13215. /**
  13216. * Dispose zrender instance
  13217. * @param {module:zrender/ZRender} zr
  13218. */
  13219. zrender.dispose = function (zr) {
  13220. if (zr) {
  13221. zr.dispose();
  13222. }
  13223. else {
  13224. for (var key in instances) {
  13225. instances[key].dispose();
  13226. }
  13227. instances = {};
  13228. }
  13229. return zrender;
  13230. };
  13231. /**
  13232. * Get zrender instance by id
  13233. * @param {string} id zrender instance id
  13234. * @return {module:zrender/ZRender}
  13235. */
  13236. zrender.getInstance = function (id) {
  13237. return instances[id];
  13238. };
  13239. zrender.registerPainter = function (name, Ctor) {
  13240. painterCtors[name] = Ctor;
  13241. };
  13242. function delInstance(id) {
  13243. delete instances[id];
  13244. }
  13245. /**
  13246. * @module zrender/ZRender
  13247. */
  13248. /**
  13249. * @constructor
  13250. * @alias module:zrender/ZRender
  13251. * @param {string} id
  13252. * @param {HTMLDomElement} dom
  13253. * @param {Object} opts
  13254. * @param {string} [opts.renderer='canvas'] 'canvas' or 'svg'
  13255. * @param {number} [opts.devicePixelRatio]
  13256. */
  13257. var ZRender = function(id, dom, opts) {
  13258. opts = opts || {};
  13259. /**
  13260. * @type {HTMLDomElement}
  13261. */
  13262. this.dom = dom;
  13263. /**
  13264. * @type {string}
  13265. */
  13266. this.id = id;
  13267. var self = this;
  13268. var storage = new Storage();
  13269. var rendererType = opts.renderer;
  13270. if (useVML) {
  13271. if (!painterCtors.vml) {
  13272. throw new Error('You need to require \'zrender/vml/vml\' to support IE8');
  13273. }
  13274. rendererType = 'vml';
  13275. }
  13276. else if (!rendererType || !painterCtors[rendererType]) {
  13277. rendererType = 'canvas';
  13278. }
  13279. var painter = new painterCtors[rendererType](dom, storage, opts);
  13280. this.storage = storage;
  13281. this.painter = painter;
  13282. if (!env.node) {
  13283. this.handler = new Handler(painter.getViewportRoot(), storage, painter);
  13284. }
  13285. /**
  13286. * @type {module:zrender/animation/Animation}
  13287. */
  13288. this.animation = new Animation({
  13289. stage: {
  13290. update: function () {
  13291. if (self._needsRefresh) {
  13292. self.refreshImmediately();
  13293. }
  13294. }
  13295. }
  13296. });
  13297. this.animation.start();
  13298. /**
  13299. * @type {boolean}
  13300. * @private
  13301. */
  13302. this._needsRefresh;
  13303. // 修改 storage.delFromMap, 每次删除元素之前删除动画
  13304. // FIXME 有点ugly
  13305. var oldDelFromMap = storage.delFromMap;
  13306. var oldAddToMap = storage.addToMap;
  13307. storage.delFromMap = function (elId) {
  13308. var el = storage.get(elId);
  13309. oldDelFromMap.call(storage, elId);
  13310. el && el.removeSelfFromZr(self);
  13311. };
  13312. storage.addToMap = function (el) {
  13313. oldAddToMap.call(storage, el);
  13314. el.addSelfToZr(self);
  13315. };
  13316. };
  13317. ZRender.prototype = {
  13318. constructor: ZRender,
  13319. /**
  13320. * 获取实例唯一标识
  13321. * @return {string}
  13322. */
  13323. getId: function () {
  13324. return this.id;
  13325. },
  13326. /**
  13327. * 添加元素
  13328. * @param {string|module:zrender/Element} el
  13329. */
  13330. add: function (el) {
  13331. this.storage.addRoot(el);
  13332. this._needsRefresh = true;
  13333. },
  13334. /**
  13335. * 删除元素
  13336. * @param {string|module:zrender/Element} el
  13337. */
  13338. remove: function (el) {
  13339. this.storage.delRoot(el);
  13340. this._needsRefresh = true;
  13341. },
  13342. /**
  13343. * Change configuration of layer
  13344. * @param {string} zLevel
  13345. * @param {Object} config
  13346. * @param {string} [config.clearColor=0] Clear color
  13347. * @param {string} [config.motionBlur=false] If enable motion blur
  13348. * @param {number} [config.lastFrameAlpha=0.7] Motion blur factor. Larger value cause longer trailer
  13349. */
  13350. configLayer: function (zLevel, config) {
  13351. this.painter.configLayer(zLevel, config);
  13352. this._needsRefresh = true;
  13353. },
  13354. /**
  13355. * Repaint the canvas immediately
  13356. */
  13357. refreshImmediately: function () {
  13358. // Clear needsRefresh ahead to avoid something wrong happens in refresh
  13359. // Or it will cause zrender refreshes again and again.
  13360. this._needsRefresh = false;
  13361. this.painter.refresh();
  13362. /**
  13363. * Avoid trigger zr.refresh in Element#beforeUpdate hook
  13364. */
  13365. this._needsRefresh = false;
  13366. },
  13367. /**
  13368. * Mark and repaint the canvas in the next frame of browser
  13369. */
  13370. refresh: function() {
  13371. this._needsRefresh = true;
  13372. },
  13373. /**
  13374. * Resize the canvas.
  13375. * Should be invoked when container size is changed
  13376. */
  13377. resize: function() {
  13378. this.painter.resize();
  13379. this.handler && this.handler.resize();
  13380. },
  13381. /**
  13382. * Stop and clear all animation immediately
  13383. */
  13384. clearAnimation: function () {
  13385. this.animation.clear();
  13386. },
  13387. /**
  13388. * Get container width
  13389. */
  13390. getWidth: function() {
  13391. return this.painter.getWidth();
  13392. },
  13393. /**
  13394. * Get container height
  13395. */
  13396. getHeight: function() {
  13397. return this.painter.getHeight();
  13398. },
  13399. /**
  13400. * Export the canvas as Base64 URL
  13401. * @param {string} type
  13402. * @param {string} [backgroundColor='#fff']
  13403. * @return {string} Base64 URL
  13404. */
  13405. // toDataURL: function(type, backgroundColor) {
  13406. // return this.painter.getRenderedCanvas({
  13407. // backgroundColor: backgroundColor
  13408. // }).toDataURL(type);
  13409. // },
  13410. /**
  13411. * Converting a path to image.
  13412. * It has much better performance of drawing image rather than drawing a vector path.
  13413. * @param {module:zrender/graphic/Path} e
  13414. * @param {number} width
  13415. * @param {number} height
  13416. */
  13417. pathToImage: function(e, width, height) {
  13418. var id = guid();
  13419. return this.painter.pathToImage(id, e, width, height);
  13420. },
  13421. /**
  13422. * Set default cursor
  13423. * @param {string} cursorStyle 例如 crosshair
  13424. */
  13425. setDefaultCursorStyle: function (cursorStyle) {
  13426. this.handler.setDefaultCursorStyle(cursorStyle);
  13427. },
  13428. /**
  13429. * Bind event
  13430. *
  13431. * @param {string} eventName Event name
  13432. * @param {Function} eventHandler Handler function
  13433. * @param {Object} [context] Context object
  13434. */
  13435. on: function(eventName, eventHandler, context) {
  13436. this.handler && this.handler.on(eventName, eventHandler, context);
  13437. },
  13438. /**
  13439. * Unbind event
  13440. * @param {string} eventName Event name
  13441. * @param {Function} [eventHandler] Handler function
  13442. */
  13443. off: function(eventName, eventHandler) {
  13444. this.handler && this.handler.off(eventName, eventHandler);
  13445. },
  13446. /**
  13447. * Trigger event manually
  13448. *
  13449. * @param {string} eventName Event name
  13450. * @param {event=} event Event object
  13451. */
  13452. trigger: function (eventName, event) {
  13453. this.handler && this.handler.trigger(eventName, event);
  13454. },
  13455. /**
  13456. * Clear all objects and the canvas.
  13457. */
  13458. clear: function () {
  13459. this.storage.delRoot();
  13460. this.painter.clear();
  13461. },
  13462. /**
  13463. * Dispose self.
  13464. */
  13465. dispose: function () {
  13466. this.animation.stop();
  13467. this.clear();
  13468. this.storage.dispose();
  13469. this.painter.dispose();
  13470. this.handler && this.handler.dispose();
  13471. this.animation =
  13472. this.storage =
  13473. this.painter =
  13474. this.handler = null;
  13475. delInstance(this.id);
  13476. }
  13477. };
  13478. module.exports = zrender;
  13479. /***/ },
  13480. /* 79 */
  13481. /***/ function(module, exports) {
  13482. /**
  13483. * echarts设备环境识别
  13484. *
  13485. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  13486. * @author firede[firede@firede.us]
  13487. * @desc thanks zepto.
  13488. */
  13489. var env = {};
  13490. if (typeof navigator === 'undefined') {
  13491. // In node
  13492. env = {
  13493. browser: {},
  13494. os: {},
  13495. node: true,
  13496. // Assume canvas is supported
  13497. canvasSupported: true
  13498. };
  13499. }
  13500. else {
  13501. env = detect(navigator.userAgent);
  13502. }
  13503. module.exports = env;
  13504. // Zepto.js
  13505. // (c) 2010-2013 Thomas Fuchs
  13506. // Zepto.js may be freely distributed under the MIT license.
  13507. function detect(ua) {
  13508. var os = {};
  13509. var browser = {};
  13510. var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  13511. var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  13512. var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  13513. var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  13514. var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  13515. var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  13516. var touchpad = webos && ua.match(/TouchPad/);
  13517. var kindle = ua.match(/Kindle\/([\d.]+)/);
  13518. var silk = ua.match(/Silk\/([\d._]+)/);
  13519. var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  13520. var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  13521. var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  13522. var playbook = ua.match(/PlayBook/);
  13523. var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  13524. var firefox = ua.match(/Firefox\/([\d.]+)/);
  13525. var safari = webkit && ua.match(/Mobile\//) && !chrome;
  13526. var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  13527. var ie = ua.match(/MSIE\s([\d.]+)/)
  13528. // IE 11 Trident/7.0; rv:11.0
  13529. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  13530. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  13531. // Todo: clean this up with a better OS/browser seperation:
  13532. // - discern (more) between multiple browsers on android
  13533. // - decide if kindle fire in silk mode is android or not
  13534. // - Firefox on Android doesn't specify the Android version
  13535. // - possibly devide in os, device and browser hashes
  13536. if (browser.webkit = !!webkit) browser.version = webkit[1];
  13537. if (android) os.android = true, os.version = android[2];
  13538. if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  13539. if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  13540. if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  13541. if (webos) os.webos = true, os.version = webos[2];
  13542. if (touchpad) os.touchpad = true;
  13543. if (blackberry) os.blackberry = true, os.version = blackberry[2];
  13544. if (bb10) os.bb10 = true, os.version = bb10[2];
  13545. if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  13546. if (playbook) browser.playbook = true;
  13547. if (kindle) os.kindle = true, os.version = kindle[1];
  13548. if (silk) browser.silk = true, browser.version = silk[1];
  13549. if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  13550. if (chrome) browser.chrome = true, browser.version = chrome[1];
  13551. if (firefox) browser.firefox = true, browser.version = firefox[1];
  13552. if (ie) browser.ie = true, browser.version = ie[1];
  13553. if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  13554. if (webview) browser.webview = true;
  13555. if (ie) browser.ie = true, browser.version = ie[1];
  13556. if (edge) browser.edge = true, browser.version = edge[1];
  13557. os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  13558. (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  13559. os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos || blackberry || bb10 ||
  13560. (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  13561. (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  13562. return {
  13563. browser: browser,
  13564. os: os,
  13565. node: false,
  13566. // 原生canvas支持,改极端点了
  13567. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  13568. canvasSupported : document.createElement('canvas').getContext ? true : false,
  13569. // @see <http://stackoverflow.com/questions/4817029/whats-the-best-way-to-detect-a-touch-screen-device-using-javascript>
  13570. // works on most browsers
  13571. // IE10/11 does not support touch event, and MS Edge supports them but not by
  13572. // default, so we dont check navigator.maxTouchPoints for them here.
  13573. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  13574. // <http://caniuse.com/#search=pointer%20event>.
  13575. pointerEventsSupported: 'onpointerdown' in window
  13576. // Firefox supports pointer but not by default,
  13577. // only MS browsers are reliable on pointer events currently.
  13578. && (browser.edge || (browser.ie && browser.version >= 10))
  13579. };
  13580. }
  13581. /***/ },
  13582. /* 80 */
  13583. /***/ function(module, exports, __webpack_require__) {
  13584. 'use strict';
  13585. /**
  13586. * Handler
  13587. * @module zrender/Handler
  13588. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  13589. * errorrik (errorrik@gmail.com)
  13590. * pissang (shenyi.914@gmail.com)
  13591. */
  13592. var env = __webpack_require__(79);
  13593. var eventTool = __webpack_require__(81);
  13594. var util = __webpack_require__(3);
  13595. var Draggable = __webpack_require__(82);
  13596. var GestureMgr = __webpack_require__(83);
  13597. var Eventful = __webpack_require__(32);
  13598. var mouseHandlerNames = [
  13599. 'click', 'dblclick', 'mousewheel', 'mouseout'
  13600. ];
  13601. !usePointerEvent() && mouseHandlerNames.push(
  13602. 'mouseup', 'mousedown', 'mousemove'
  13603. );
  13604. var touchHandlerNames = [
  13605. 'touchstart', 'touchend', 'touchmove'
  13606. ];
  13607. var pointerHandlerNames = [
  13608. 'pointerdown', 'pointerup', 'pointermove'
  13609. ];
  13610. var TOUCH_CLICK_DELAY = 300;
  13611. var addEventListener = eventTool.addEventListener;
  13612. var removeEventListener = eventTool.removeEventListener;
  13613. var normalizeEvent = eventTool.normalizeEvent;
  13614. function makeEventPacket(eveType, target, event) {
  13615. return {
  13616. type: eveType,
  13617. event: event,
  13618. target: target,
  13619. cancelBubble: false,
  13620. offsetX: event.zrX,
  13621. offsetY: event.zrY,
  13622. gestureEvent: event.gestureEvent,
  13623. pinchX: event.pinchX,
  13624. pinchY: event.pinchY,
  13625. pinchScale: event.pinchScale,
  13626. wheelDelta: event.zrDelta
  13627. };
  13628. }
  13629. var domHandlers = {
  13630. /**
  13631. * Mouse move handler
  13632. * @inner
  13633. * @param {Event} event
  13634. */
  13635. mousemove: function (event) {
  13636. event = normalizeEvent(this.root, event);
  13637. var x = event.zrX;
  13638. var y = event.zrY;
  13639. var hovered = this.findHover(x, y, null);
  13640. var lastHovered = this._hovered;
  13641. this._hovered = hovered;
  13642. this.root.style.cursor = hovered ? hovered.cursor : this._defaultCursorStyle;
  13643. // Mouse out on previous hovered element
  13644. if (lastHovered && hovered !== lastHovered && lastHovered.__zr) {
  13645. this._dispatchProxy(lastHovered, 'mouseout', event);
  13646. }
  13647. // Mouse moving on one element
  13648. this._dispatchProxy(hovered, 'mousemove', event);
  13649. // Mouse over on a new element
  13650. if (hovered && hovered !== lastHovered) {
  13651. this._dispatchProxy(hovered, 'mouseover', event);
  13652. }
  13653. },
  13654. /**
  13655. * Mouse out handler
  13656. * @inner
  13657. * @param {Event} event
  13658. */
  13659. mouseout: function (event) {
  13660. event = normalizeEvent(this.root, event);
  13661. var element = event.toElement || event.relatedTarget;
  13662. if (element != this.root) {
  13663. while (element && element.nodeType != 9) {
  13664. // 忽略包含在root中的dom引起的mouseOut
  13665. if (element === this.root) {
  13666. return;
  13667. }
  13668. element = element.parentNode;
  13669. }
  13670. }
  13671. this._dispatchProxy(this._hovered, 'mouseout', event);
  13672. this.trigger('globalout', {
  13673. event: event
  13674. });
  13675. },
  13676. /**
  13677. * Touch开始响应函数
  13678. * @inner
  13679. * @param {Event} event
  13680. */
  13681. touchstart: function (event) {
  13682. // Default mouse behaviour should not be disabled here.
  13683. // For example, page may needs to be slided.
  13684. // eventTool.stop(event);
  13685. event = normalizeEvent(this.root, event);
  13686. this._lastTouchMoment = new Date();
  13687. processGesture(this, event, 'start');
  13688. // 平板补充一次findHover
  13689. // this._mobileFindFixed(event);
  13690. // Trigger mousemove and mousedown
  13691. domHandlers.mousemove.call(this, event);
  13692. domHandlers.mousedown.call(this, event);
  13693. setTouchTimer(this);
  13694. },
  13695. /**
  13696. * Touch移动响应函数
  13697. * @inner
  13698. * @param {Event} event
  13699. */
  13700. touchmove: function (event) {
  13701. // eventTool.stop(event);// 阻止浏览器默认事件,重要
  13702. event = normalizeEvent(this.root, event);
  13703. processGesture(this, event, 'change');
  13704. // Mouse move should always be triggered no matter whether
  13705. // there is gestrue event, because mouse move and pinch may
  13706. // be used at the same time.
  13707. domHandlers.mousemove.call(this, event);
  13708. setTouchTimer(this);
  13709. },
  13710. /**
  13711. * Touch结束响应函数
  13712. * @inner
  13713. * @param {Event} event
  13714. */
  13715. touchend: function (event) {
  13716. // eventTool.stop(event);// 阻止浏览器默认事件,重要
  13717. event = normalizeEvent(this.root, event);
  13718. processGesture(this, event, 'end');
  13719. domHandlers.mouseup.call(this, event);
  13720. // click event should always be triggered no matter whether
  13721. // there is gestrue event. System click can not be prevented.
  13722. if (+new Date() - this._lastTouchMoment < TOUCH_CLICK_DELAY) {
  13723. // this._mobileFindFixed(event);
  13724. domHandlers.click.call(this, event);
  13725. }
  13726. setTouchTimer(this);
  13727. }
  13728. };
  13729. // Common handlers
  13730. util.each(['click', 'mousedown', 'mouseup', 'mousewheel', 'dblclick'], function (name) {
  13731. domHandlers[name] = function (event) {
  13732. event = normalizeEvent(this.root, event);
  13733. // Find hover again to avoid click event is dispatched manually. Or click is triggered without mouseover
  13734. var hovered = this.findHover(event.zrX, event.zrY, null);
  13735. if (name === 'mousedown') {
  13736. this._downel = hovered;
  13737. // In case click triggered before mouseup
  13738. this._upel = hovered;
  13739. }
  13740. else if (name === 'mosueup') {
  13741. this._upel = hovered;
  13742. }
  13743. else if (name === 'click') {
  13744. if (this._downel !== this._upel) {
  13745. return;
  13746. }
  13747. }
  13748. this._dispatchProxy(hovered, name, event);
  13749. };
  13750. });
  13751. // Pointer event handlers
  13752. // util.each(['pointerdown', 'pointermove', 'pointerup'], function (name) {
  13753. // domHandlers[name] = function (event) {
  13754. // var mouseName = name.replace('pointer', 'mouse');
  13755. // domHandlers[mouseName].call(this, event);
  13756. // };
  13757. // });
  13758. function processGesture(zrHandler, event, stage) {
  13759. var gestureMgr = zrHandler._gestureMgr;
  13760. stage === 'start' && gestureMgr.clear();
  13761. var gestureInfo = gestureMgr.recognize(
  13762. event,
  13763. zrHandler.findHover(event.zrX, event.zrY, null)
  13764. );
  13765. stage === 'end' && gestureMgr.clear();
  13766. if (gestureInfo) {
  13767. // eventTool.stop(event);
  13768. var type = gestureInfo.type;
  13769. event.gestureEvent = type;
  13770. zrHandler._dispatchProxy(gestureInfo.target, type, gestureInfo.event);
  13771. }
  13772. }
  13773. /**
  13774. * 为控制类实例初始化dom 事件处理函数
  13775. *
  13776. * @inner
  13777. * @param {module:zrender/Handler} instance 控制类实例
  13778. */
  13779. function initDomHandler(instance) {
  13780. var handlerNames = touchHandlerNames.concat(pointerHandlerNames);
  13781. for (var i = 0; i < handlerNames.length; i++) {
  13782. var name = handlerNames[i];
  13783. instance._handlers[name] = util.bind(domHandlers[name], instance);
  13784. }
  13785. for (var i = 0; i < mouseHandlerNames.length; i++) {
  13786. var name = mouseHandlerNames[i];
  13787. instance._handlers[name] = makeMouseHandler(domHandlers[name], instance);
  13788. }
  13789. function makeMouseHandler(fn, instance) {
  13790. return function () {
  13791. if (instance._touching) {
  13792. return;
  13793. }
  13794. return fn.apply(instance, arguments);
  13795. };
  13796. }
  13797. }
  13798. /**
  13799. * @alias module:zrender/Handler
  13800. * @constructor
  13801. * @extends module:zrender/mixin/Eventful
  13802. * @param {HTMLElement} root Main HTML element for painting.
  13803. * @param {module:zrender/Storage} storage Storage instance.
  13804. * @param {module:zrender/Painter} painter Painter instance.
  13805. */
  13806. var Handler = function(root, storage, painter) {
  13807. Eventful.call(this);
  13808. this.root = root;
  13809. this.storage = storage;
  13810. this.painter = painter;
  13811. /**
  13812. * @private
  13813. * @type {boolean}
  13814. */
  13815. this._hovered;
  13816. /**
  13817. * @private
  13818. * @type {Date}
  13819. */
  13820. this._lastTouchMoment;
  13821. /**
  13822. * @private
  13823. * @type {number}
  13824. */
  13825. this._lastX;
  13826. /**
  13827. * @private
  13828. * @type {number}
  13829. */
  13830. this._lastY;
  13831. /**
  13832. * @private
  13833. * @type {string}
  13834. */
  13835. this._defaultCursorStyle = 'default';
  13836. /**
  13837. * @private
  13838. * @type {module:zrender/core/GestureMgr}
  13839. */
  13840. this._gestureMgr = new GestureMgr();
  13841. /**
  13842. * @private
  13843. * @type {Array.<Function>}
  13844. */
  13845. this._handlers = [];
  13846. /**
  13847. * @private
  13848. * @type {boolean}
  13849. */
  13850. this._touching = false;
  13851. /**
  13852. * @private
  13853. * @type {number}
  13854. */
  13855. this._touchTimer;
  13856. initDomHandler(this);
  13857. if (usePointerEvent()) {
  13858. mountHandlers(pointerHandlerNames, this);
  13859. }
  13860. else if (useTouchEvent()) {
  13861. mountHandlers(touchHandlerNames, this);
  13862. // Handler of 'mouseout' event is needed in touch mode, which will be mounted below.
  13863. // addEventListener(root, 'mouseout', this._mouseoutHandler);
  13864. }
  13865. // Considering some devices that both enable touch and mouse event (like MS Surface
  13866. // and lenovo X240, @see #2350), we make mouse event be always listened, otherwise
  13867. // mouse event can not be handle in those devices.
  13868. mountHandlers(mouseHandlerNames, this);
  13869. Draggable.call(this);
  13870. function mountHandlers(handlerNames, instance) {
  13871. util.each(handlerNames, function (name) {
  13872. addEventListener(root, eventNameFix(name), instance._handlers[name]);
  13873. }, instance);
  13874. }
  13875. };
  13876. Handler.prototype = {
  13877. constructor: Handler,
  13878. /**
  13879. * Resize
  13880. */
  13881. resize: function (event) {
  13882. this._hovered = null;
  13883. },
  13884. /**
  13885. * Dispatch event
  13886. * @param {string} eventName
  13887. * @param {event=} eventArgs
  13888. */
  13889. dispatch: function (eventName, eventArgs) {
  13890. var handler = this._handlers[eventName];
  13891. handler && handler.call(this, eventArgs);
  13892. },
  13893. /**
  13894. * Dispose
  13895. */
  13896. dispose: function () {
  13897. var root = this.root;
  13898. var handlerNames = mouseHandlerNames.concat(touchHandlerNames);
  13899. for (var i = 0; i < handlerNames.length; i++) {
  13900. var name = handlerNames[i];
  13901. removeEventListener(root, eventNameFix(name), this._handlers[name]);
  13902. }
  13903. this.root =
  13904. this.storage =
  13905. this.painter = null;
  13906. },
  13907. /**
  13908. * 设置默认的cursor style
  13909. * @param {string} cursorStyle 例如 crosshair
  13910. */
  13911. setDefaultCursorStyle: function (cursorStyle) {
  13912. this._defaultCursorStyle = cursorStyle;
  13913. },
  13914. /**
  13915. * 事件分发代理
  13916. *
  13917. * @private
  13918. * @param {Object} targetEl 目标图形元素
  13919. * @param {string} eventName 事件名称
  13920. * @param {Object} event 事件对象
  13921. */
  13922. _dispatchProxy: function (targetEl, eventName, event) {
  13923. var eventHandler = 'on' + eventName;
  13924. var eventPacket = makeEventPacket(eventName, targetEl, event);
  13925. var el = targetEl;
  13926. while (el) {
  13927. el[eventHandler]
  13928. && (eventPacket.cancelBubble = el[eventHandler].call(el, eventPacket));
  13929. el.trigger(eventName, eventPacket);
  13930. el = el.parent;
  13931. if (eventPacket.cancelBubble) {
  13932. break;
  13933. }
  13934. }
  13935. if (!eventPacket.cancelBubble) {
  13936. // 冒泡到顶级 zrender 对象
  13937. this.trigger(eventName, eventPacket);
  13938. // 分发事件到用户自定义层
  13939. // 用户有可能在全局 click 事件中 dispose,所以需要判断下 painter 是否存在
  13940. this.painter && this.painter.eachOtherLayer(function (layer) {
  13941. if (typeof(layer[eventHandler]) == 'function') {
  13942. layer[eventHandler].call(layer, eventPacket);
  13943. }
  13944. if (layer.trigger) {
  13945. layer.trigger(eventName, eventPacket);
  13946. }
  13947. });
  13948. }
  13949. },
  13950. /**
  13951. * @private
  13952. * @param {number} x
  13953. * @param {number} y
  13954. * @param {module:zrender/graphic/Displayable} exclude
  13955. * @method
  13956. */
  13957. findHover: function(x, y, exclude) {
  13958. var list = this.storage.getDisplayList();
  13959. for (var i = list.length - 1; i >= 0 ; i--) {
  13960. if (!list[i].silent
  13961. && list[i] !== exclude
  13962. // getDisplayList may include ignored item in VML mode
  13963. && !list[i].ignore
  13964. && isHover(list[i], x, y)) {
  13965. return list[i];
  13966. }
  13967. }
  13968. }
  13969. };
  13970. function isHover(displayable, x, y) {
  13971. if (displayable[displayable.rectHover ? 'rectContain' : 'contain'](x, y)) {
  13972. var el = displayable;
  13973. while (el) {
  13974. // If ancestor is silent or clipped by ancestor
  13975. if (el.silent || (el.clipPath && !el.clipPath.contain(x, y))) {
  13976. return false;
  13977. }
  13978. el = el.parent;
  13979. }
  13980. return true;
  13981. }
  13982. return false;
  13983. }
  13984. /**
  13985. * Prevent mouse event from being dispatched after Touch Events action
  13986. * @see <https://github.com/deltakosh/handjs/blob/master/src/hand.base.js>
  13987. * 1. Mobile browsers dispatch mouse events 300ms after touchend.
  13988. * 2. Chrome for Android dispatch mousedown for long-touch about 650ms
  13989. * Result: Blocking Mouse Events for 700ms.
  13990. */
  13991. function setTouchTimer(instance) {
  13992. instance._touching = true;
  13993. clearTimeout(instance._touchTimer);
  13994. instance._touchTimer = setTimeout(function () {
  13995. instance._touching = false;
  13996. }, 700);
  13997. }
  13998. /**
  13999. * Althought MS Surface support screen touch, IE10/11 do not support
  14000. * touch event and MS Edge supported them but not by default (but chrome
  14001. * and firefox do). Thus we use Pointer event on MS browsers to handle touch.
  14002. */
  14003. function usePointerEvent() {
  14004. // TODO
  14005. // pointermove event dont trigger when using finger.
  14006. // We may figger it out latter.
  14007. return false;
  14008. // return env.pointerEventsSupported
  14009. // In no-touch device we dont use pointer evnets but just
  14010. // use mouse event for avoiding problems.
  14011. // && window.navigator.maxTouchPoints;
  14012. }
  14013. function useTouchEvent() {
  14014. return env.touchEventsSupported;
  14015. }
  14016. function eventNameFix(name) {
  14017. return (name === 'mousewheel' && env.browser.firefox) ? 'DOMMouseScroll' : name;
  14018. }
  14019. util.mixin(Handler, Eventful);
  14020. util.mixin(Handler, Draggable);
  14021. module.exports = Handler;
  14022. /***/ },
  14023. /* 81 */
  14024. /***/ function(module, exports, __webpack_require__) {
  14025. 'use strict';
  14026. /**
  14027. * 事件辅助类
  14028. * @module zrender/core/event
  14029. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14030. */
  14031. var Eventful = __webpack_require__(32);
  14032. var isDomLevel2 = (typeof window !== 'undefined') && !!window.addEventListener;
  14033. function getBoundingClientRect(el) {
  14034. // BlackBerry 5, iOS 3 (original iPhone) don't have getBoundingRect
  14035. return el.getBoundingClientRect ? el.getBoundingClientRect() : { left: 0, top: 0};
  14036. }
  14037. /**
  14038. * 如果存在第三方嵌入的一些dom触发的事件,或touch事件,需要转换一下事件坐标
  14039. */
  14040. function normalizeEvent(el, e) {
  14041. e = e || window.event;
  14042. if (e.zrX != null) {
  14043. return e;
  14044. }
  14045. var eventType = e.type;
  14046. var isTouch = eventType && eventType.indexOf('touch') >= 0;
  14047. if (!isTouch) {
  14048. var box = getBoundingClientRect(el);
  14049. e.zrX = e.clientX - box.left;
  14050. e.zrY = e.clientY - box.top;
  14051. e.zrDelta = (e.wheelDelta) ? e.wheelDelta / 120 : -(e.detail || 0) / 3;
  14052. }
  14053. else {
  14054. var touch = eventType != 'touchend'
  14055. ? e.targetTouches[0]
  14056. : e.changedTouches[0];
  14057. if (touch) {
  14058. var rBounding = getBoundingClientRect(el);
  14059. // touch事件坐标是全屏的~
  14060. e.zrX = touch.clientX - rBounding.left;
  14061. e.zrY = touch.clientY - rBounding.top;
  14062. }
  14063. }
  14064. return e;
  14065. }
  14066. function addEventListener(el, name, handler) {
  14067. if (isDomLevel2) {
  14068. el.addEventListener(name, handler);
  14069. }
  14070. else {
  14071. el.attachEvent('on' + name, handler);
  14072. }
  14073. }
  14074. function removeEventListener(el, name, handler) {
  14075. if (isDomLevel2) {
  14076. el.removeEventListener(name, handler);
  14077. }
  14078. else {
  14079. el.detachEvent('on' + name, handler);
  14080. }
  14081. }
  14082. /**
  14083. * 停止冒泡和阻止默认行为
  14084. * @memberOf module:zrender/core/event
  14085. * @method
  14086. * @param {Event} e : event对象
  14087. */
  14088. var stop = isDomLevel2
  14089. ? function (e) {
  14090. e.preventDefault();
  14091. e.stopPropagation();
  14092. e.cancelBubble = true;
  14093. }
  14094. : function (e) {
  14095. e.returnValue = false;
  14096. e.cancelBubble = true;
  14097. };
  14098. module.exports = {
  14099. normalizeEvent: normalizeEvent,
  14100. addEventListener: addEventListener,
  14101. removeEventListener: removeEventListener,
  14102. stop: stop,
  14103. // 做向上兼容
  14104. Dispatcher: Eventful
  14105. };
  14106. /***/ },
  14107. /* 82 */
  14108. /***/ function(module, exports) {
  14109. // TODO Draggable for group
  14110. // FIXME Draggable on element which has parent rotation or scale
  14111. function Draggable() {
  14112. this.on('mousedown', this._dragStart, this);
  14113. this.on('mousemove', this._drag, this);
  14114. this.on('mouseup', this._dragEnd, this);
  14115. this.on('globalout', this._dragEnd, this);
  14116. // this._dropTarget = null;
  14117. // this._draggingTarget = null;
  14118. // this._x = 0;
  14119. // this._y = 0;
  14120. }
  14121. Draggable.prototype = {
  14122. constructor: Draggable,
  14123. _dragStart: function (e) {
  14124. var draggingTarget = e.target;
  14125. if (draggingTarget && draggingTarget.draggable) {
  14126. this._draggingTarget = draggingTarget;
  14127. draggingTarget.dragging = true;
  14128. this._x = e.offsetX;
  14129. this._y = e.offsetY;
  14130. this._dispatchProxy(draggingTarget, 'dragstart', e.event);
  14131. }
  14132. },
  14133. _drag: function (e) {
  14134. var draggingTarget = this._draggingTarget;
  14135. if (draggingTarget) {
  14136. var x = e.offsetX;
  14137. var y = e.offsetY;
  14138. var dx = x - this._x;
  14139. var dy = y - this._y;
  14140. this._x = x;
  14141. this._y = y;
  14142. draggingTarget.drift(dx, dy, e);
  14143. this._dispatchProxy(draggingTarget, 'drag', e.event);
  14144. var dropTarget = this.findHover(x, y, draggingTarget);
  14145. var lastDropTarget = this._dropTarget;
  14146. this._dropTarget = dropTarget;
  14147. if (draggingTarget !== dropTarget) {
  14148. if (lastDropTarget && dropTarget !== lastDropTarget) {
  14149. this._dispatchProxy(lastDropTarget, 'dragleave', e.event);
  14150. }
  14151. if (dropTarget && dropTarget !== lastDropTarget) {
  14152. this._dispatchProxy(dropTarget, 'dragenter', e.event);
  14153. }
  14154. }
  14155. }
  14156. },
  14157. _dragEnd: function (e) {
  14158. var draggingTarget = this._draggingTarget;
  14159. if (draggingTarget) {
  14160. draggingTarget.dragging = false;
  14161. }
  14162. this._dispatchProxy(draggingTarget, 'dragend', e.event);
  14163. if (this._dropTarget) {
  14164. this._dispatchProxy(this._dropTarget, 'drop', e.event);
  14165. }
  14166. this._draggingTarget = null;
  14167. this._dropTarget = null;
  14168. }
  14169. };
  14170. module.exports = Draggable;
  14171. /***/ },
  14172. /* 83 */
  14173. /***/ function(module, exports) {
  14174. 'use strict';
  14175. /**
  14176. * Only implements needed gestures for mobile.
  14177. */
  14178. var GestureMgr = function () {
  14179. /**
  14180. * @private
  14181. * @type {Array.<Object>}
  14182. */
  14183. this._track = [];
  14184. };
  14185. GestureMgr.prototype = {
  14186. constructor: GestureMgr,
  14187. recognize: function (event, target) {
  14188. this._doTrack(event, target);
  14189. return this._recognize(event);
  14190. },
  14191. clear: function () {
  14192. this._track.length = 0;
  14193. return this;
  14194. },
  14195. _doTrack: function (event, target) {
  14196. var touches = event.touches;
  14197. if (!touches) {
  14198. return;
  14199. }
  14200. var trackItem = {
  14201. points: [],
  14202. touches: [],
  14203. target: target,
  14204. event: event
  14205. };
  14206. for (var i = 0, len = touches.length; i < len; i++) {
  14207. var touch = touches[i];
  14208. trackItem.points.push([touch.clientX, touch.clientY]);
  14209. trackItem.touches.push(touch);
  14210. }
  14211. this._track.push(trackItem);
  14212. },
  14213. _recognize: function (event) {
  14214. for (var eventName in recognizers) {
  14215. if (recognizers.hasOwnProperty(eventName)) {
  14216. var gestureInfo = recognizers[eventName](this._track, event);
  14217. if (gestureInfo) {
  14218. return gestureInfo;
  14219. }
  14220. }
  14221. }
  14222. }
  14223. };
  14224. function dist(pointPair) {
  14225. var dx = pointPair[1][0] - pointPair[0][0];
  14226. var dy = pointPair[1][1] - pointPair[0][1];
  14227. return Math.sqrt(dx * dx + dy * dy);
  14228. }
  14229. function center(pointPair) {
  14230. return [
  14231. (pointPair[0][0] + pointPair[1][0]) / 2,
  14232. (pointPair[0][1] + pointPair[1][1]) / 2
  14233. ];
  14234. }
  14235. var recognizers = {
  14236. pinch: function (track, event) {
  14237. var trackLen = track.length;
  14238. if (!trackLen) {
  14239. return;
  14240. }
  14241. var pinchEnd = (track[trackLen - 1] || {}).points;
  14242. var pinchPre = (track[trackLen - 2] || {}).points || pinchEnd;
  14243. if (pinchPre
  14244. && pinchPre.length > 1
  14245. && pinchEnd
  14246. && pinchEnd.length > 1
  14247. ) {
  14248. var pinchScale = dist(pinchEnd) / dist(pinchPre);
  14249. !isFinite(pinchScale) && (pinchScale = 1);
  14250. event.pinchScale = pinchScale;
  14251. var pinchCenter = center(pinchEnd);
  14252. event.pinchX = pinchCenter[0];
  14253. event.pinchY = pinchCenter[1];
  14254. return {
  14255. type: 'pinch',
  14256. target: track[0].target,
  14257. event: event
  14258. };
  14259. }
  14260. }
  14261. // Only pinch currently.
  14262. };
  14263. module.exports = GestureMgr;
  14264. /***/ },
  14265. /* 84 */
  14266. /***/ function(module, exports, __webpack_require__) {
  14267. 'use strict';
  14268. /**
  14269. * Storage内容仓库模块
  14270. * @module zrender/Storage
  14271. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14272. * @author errorrik (errorrik@gmail.com)
  14273. * @author pissang (https://github.com/pissang/)
  14274. */
  14275. var util = __webpack_require__(3);
  14276. var Group = __webpack_require__(29);
  14277. function shapeCompareFunc(a, b) {
  14278. if (a.zlevel === b.zlevel) {
  14279. if (a.z === b.z) {
  14280. if (a.z2 === b.z2) {
  14281. return a.__renderidx - b.__renderidx;
  14282. }
  14283. return a.z2 - b.z2;
  14284. }
  14285. return a.z - b.z;
  14286. }
  14287. return a.zlevel - b.zlevel;
  14288. }
  14289. /**
  14290. * 内容仓库 (M)
  14291. * @alias module:zrender/Storage
  14292. * @constructor
  14293. */
  14294. var Storage = function () {
  14295. // 所有常规形状,id索引的map
  14296. this._elements = {};
  14297. this._roots = [];
  14298. this._displayList = [];
  14299. this._displayListLen = 0;
  14300. };
  14301. Storage.prototype = {
  14302. constructor: Storage,
  14303. /**
  14304. * 返回所有图形的绘制队列
  14305. * @param {boolean} [update=false] 是否在返回前更新该数组
  14306. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组, 在 update 为 true 的时候有效
  14307. *
  14308. * 详见{@link module:zrender/graphic/Displayable.prototype.updateDisplayList}
  14309. * @return {Array.<module:zrender/graphic/Displayable>}
  14310. */
  14311. getDisplayList: function (update, includeIgnore) {
  14312. includeIgnore = includeIgnore || false;
  14313. if (update) {
  14314. this.updateDisplayList(includeIgnore);
  14315. }
  14316. return this._displayList;
  14317. },
  14318. /**
  14319. * 更新图形的绘制队列。
  14320. * 每次绘制前都会调用,该方法会先深度优先遍历整个树,更新所有Group和Shape的变换并且把所有可见的Shape保存到数组中,
  14321. * 最后根据绘制的优先级(zlevel > z > 插入顺序)排序得到绘制队列
  14322. * @param {boolean} [includeIgnore=false] 是否包含 ignore 的数组
  14323. */
  14324. updateDisplayList: function (includeIgnore) {
  14325. this._displayListLen = 0;
  14326. var roots = this._roots;
  14327. var displayList = this._displayList;
  14328. for (var i = 0, len = roots.length; i < len; i++) {
  14329. this._updateAndAddDisplayable(roots[i], null, includeIgnore);
  14330. }
  14331. displayList.length = this._displayListLen;
  14332. for (var i = 0, len = displayList.length; i < len; i++) {
  14333. displayList[i].__renderidx = i;
  14334. }
  14335. displayList.sort(shapeCompareFunc);
  14336. },
  14337. _updateAndAddDisplayable: function (el, clipPaths, includeIgnore) {
  14338. if (el.ignore && !includeIgnore) {
  14339. return;
  14340. }
  14341. el.beforeUpdate();
  14342. el.update();
  14343. el.afterUpdate();
  14344. var clipPath = el.clipPath;
  14345. if (clipPath) {
  14346. // clipPath 的变换是基于 group 的变换
  14347. clipPath.parent = el;
  14348. clipPath.updateTransform();
  14349. // FIXME 效率影响
  14350. if (clipPaths) {
  14351. clipPaths = clipPaths.slice();
  14352. clipPaths.push(clipPath);
  14353. }
  14354. else {
  14355. clipPaths = [clipPath];
  14356. }
  14357. }
  14358. if (el.type == 'group') {
  14359. var children = el._children;
  14360. for (var i = 0; i < children.length; i++) {
  14361. var child = children[i];
  14362. // Force to mark as dirty if group is dirty
  14363. // FIXME __dirtyPath ?
  14364. child.__dirty = el.__dirty || child.__dirty;
  14365. this._updateAndAddDisplayable(child, clipPaths, includeIgnore);
  14366. }
  14367. // Mark group clean here
  14368. el.__dirty = false;
  14369. }
  14370. else {
  14371. el.__clipPaths = clipPaths;
  14372. this._displayList[this._displayListLen++] = el;
  14373. }
  14374. },
  14375. /**
  14376. * 添加图形(Shape)或者组(Group)到根节点
  14377. * @param {module:zrender/Element} el
  14378. */
  14379. addRoot: function (el) {
  14380. // Element has been added
  14381. if (this._elements[el.id]) {
  14382. return;
  14383. }
  14384. if (el instanceof Group) {
  14385. el.addChildrenToStorage(this);
  14386. }
  14387. this.addToMap(el);
  14388. this._roots.push(el);
  14389. },
  14390. /**
  14391. * 删除指定的图形(Shape)或者组(Group)
  14392. * @param {string|Array.<string>} [elId] 如果为空清空整个Storage
  14393. */
  14394. delRoot: function (elId) {
  14395. if (elId == null) {
  14396. // 不指定elId清空
  14397. for (var i = 0; i < this._roots.length; i++) {
  14398. var root = this._roots[i];
  14399. if (root instanceof Group) {
  14400. root.delChildrenFromStorage(this);
  14401. }
  14402. }
  14403. this._elements = {};
  14404. this._roots = [];
  14405. this._displayList = [];
  14406. this._displayListLen = 0;
  14407. return;
  14408. }
  14409. if (elId instanceof Array) {
  14410. for (var i = 0, l = elId.length; i < l; i++) {
  14411. this.delRoot(elId[i]);
  14412. }
  14413. return;
  14414. }
  14415. var el;
  14416. if (typeof(elId) == 'string') {
  14417. el = this._elements[elId];
  14418. }
  14419. else {
  14420. el = elId;
  14421. }
  14422. var idx = util.indexOf(this._roots, el);
  14423. if (idx >= 0) {
  14424. this.delFromMap(el.id);
  14425. this._roots.splice(idx, 1);
  14426. if (el instanceof Group) {
  14427. el.delChildrenFromStorage(this);
  14428. }
  14429. }
  14430. },
  14431. addToMap: function (el) {
  14432. if (el instanceof Group) {
  14433. el.__storage = this;
  14434. }
  14435. el.dirty();
  14436. this._elements[el.id] = el;
  14437. return this;
  14438. },
  14439. get: function (elId) {
  14440. return this._elements[elId];
  14441. },
  14442. delFromMap: function (elId) {
  14443. var elements = this._elements;
  14444. var el = elements[elId];
  14445. if (el) {
  14446. delete elements[elId];
  14447. if (el instanceof Group) {
  14448. el.__storage = null;
  14449. }
  14450. }
  14451. return this;
  14452. },
  14453. /**
  14454. * 清空并且释放Storage
  14455. */
  14456. dispose: function () {
  14457. this._elements =
  14458. this._renderList =
  14459. this._roots = null;
  14460. }
  14461. };
  14462. module.exports = Storage;
  14463. /***/ },
  14464. /* 85 */
  14465. /***/ function(module, exports, __webpack_require__) {
  14466. 'use strict';
  14467. /**
  14468. * 动画主类, 调度和管理所有动画控制器
  14469. *
  14470. * @module zrender/animation/Animation
  14471. * @author pissang(https://github.com/pissang)
  14472. */
  14473. // TODO Additive animation
  14474. // http://iosoteric.com/additive-animations-animatewithduration-in-ios-8/
  14475. // https://developer.apple.com/videos/wwdc2014/#236
  14476. var util = __webpack_require__(3);
  14477. var Dispatcher = __webpack_require__(81).Dispatcher;
  14478. var requestAnimationFrame = (typeof window !== 'undefined' &&
  14479. (window.requestAnimationFrame
  14480. || window.msRequestAnimationFrame
  14481. || window.mozRequestAnimationFrame
  14482. || window.webkitRequestAnimationFrame))
  14483. || function (func) {
  14484. setTimeout(func, 16);
  14485. };
  14486. var Animator = __webpack_require__(35);
  14487. /**
  14488. * @typedef {Object} IZRenderStage
  14489. * @property {Function} update
  14490. */
  14491. /**
  14492. * @alias module:zrender/animation/Animation
  14493. * @constructor
  14494. * @param {Object} [options]
  14495. * @param {Function} [options.onframe]
  14496. * @param {IZRenderStage} [options.stage]
  14497. * @example
  14498. * var animation = new Animation();
  14499. * var obj = {
  14500. * x: 100,
  14501. * y: 100
  14502. * };
  14503. * animation.animate(node.position)
  14504. * .when(1000, {
  14505. * x: 500,
  14506. * y: 500
  14507. * })
  14508. * .when(2000, {
  14509. * x: 100,
  14510. * y: 100
  14511. * })
  14512. * .start('spline');
  14513. */
  14514. var Animation = function (options) {
  14515. options = options || {};
  14516. this.stage = options.stage || {};
  14517. this.onframe = options.onframe || function() {};
  14518. // private properties
  14519. this._clips = [];
  14520. this._running = false;
  14521. this._time = 0;
  14522. Dispatcher.call(this);
  14523. };
  14524. Animation.prototype = {
  14525. constructor: Animation,
  14526. /**
  14527. * 添加 clip
  14528. * @param {module:zrender/animation/Clip} clip
  14529. */
  14530. addClip: function (clip) {
  14531. this._clips.push(clip);
  14532. },
  14533. /**
  14534. * 添加 animator
  14535. * @param {module:zrender/animation/Animator} animator
  14536. */
  14537. addAnimator: function (animator) {
  14538. animator.animation = this;
  14539. var clips = animator.getClips();
  14540. for (var i = 0; i < clips.length; i++) {
  14541. this.addClip(clips[i]);
  14542. }
  14543. },
  14544. /**
  14545. * 删除动画片段
  14546. * @param {module:zrender/animation/Clip} clip
  14547. */
  14548. removeClip: function(clip) {
  14549. var idx = util.indexOf(this._clips, clip);
  14550. if (idx >= 0) {
  14551. this._clips.splice(idx, 1);
  14552. }
  14553. },
  14554. /**
  14555. * 删除动画片段
  14556. * @param {module:zrender/animation/Animator} animator
  14557. */
  14558. removeAnimator: function (animator) {
  14559. var clips = animator.getClips();
  14560. for (var i = 0; i < clips.length; i++) {
  14561. this.removeClip(clips[i]);
  14562. }
  14563. animator.animation = null;
  14564. },
  14565. _update: function() {
  14566. var time = new Date().getTime();
  14567. var delta = time - this._time;
  14568. var clips = this._clips;
  14569. var len = clips.length;
  14570. var deferredEvents = [];
  14571. var deferredClips = [];
  14572. for (var i = 0; i < len; i++) {
  14573. var clip = clips[i];
  14574. var e = clip.step(time);
  14575. // Throw out the events need to be called after
  14576. // stage.update, like destroy
  14577. if (e) {
  14578. deferredEvents.push(e);
  14579. deferredClips.push(clip);
  14580. }
  14581. }
  14582. // Remove the finished clip
  14583. for (var i = 0; i < len;) {
  14584. if (clips[i]._needsRemove) {
  14585. clips[i] = clips[len - 1];
  14586. clips.pop();
  14587. len--;
  14588. }
  14589. else {
  14590. i++;
  14591. }
  14592. }
  14593. len = deferredEvents.length;
  14594. for (var i = 0; i < len; i++) {
  14595. deferredClips[i].fire(deferredEvents[i]);
  14596. }
  14597. this._time = time;
  14598. this.onframe(delta);
  14599. this.trigger('frame', delta);
  14600. if (this.stage.update) {
  14601. this.stage.update();
  14602. }
  14603. },
  14604. /**
  14605. * 开始运行动画
  14606. */
  14607. start: function () {
  14608. var self = this;
  14609. this._running = true;
  14610. function step() {
  14611. if (self._running) {
  14612. requestAnimationFrame(step);
  14613. self._update();
  14614. }
  14615. }
  14616. this._time = new Date().getTime();
  14617. requestAnimationFrame(step);
  14618. },
  14619. /**
  14620. * 停止运行动画
  14621. */
  14622. stop: function () {
  14623. this._running = false;
  14624. },
  14625. /**
  14626. * 清除所有动画片段
  14627. */
  14628. clear: function () {
  14629. this._clips = [];
  14630. },
  14631. /**
  14632. * 对一个目标创建一个animator对象,可以指定目标中的属性使用动画
  14633. * @param {Object} target
  14634. * @param {Object} options
  14635. * @param {boolean} [options.loop=false] 是否循环播放动画
  14636. * @param {Function} [options.getter=null]
  14637. * 如果指定getter函数,会通过getter函数取属性值
  14638. * @param {Function} [options.setter=null]
  14639. * 如果指定setter函数,会通过setter函数设置属性值
  14640. * @return {module:zrender/animation/Animation~Animator}
  14641. */
  14642. animate: function (target, options) {
  14643. options = options || {};
  14644. var animator = new Animator(
  14645. target,
  14646. options.loop,
  14647. options.getter,
  14648. options.setter
  14649. );
  14650. return animator;
  14651. }
  14652. };
  14653. util.mixin(Animation, Dispatcher);
  14654. module.exports = Animation;
  14655. /***/ },
  14656. /* 86 */
  14657. /***/ function(module, exports, __webpack_require__) {
  14658. 'use strict';
  14659. /**
  14660. * Default canvas painter
  14661. * @module zrender/Painter
  14662. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  14663. * errorrik (errorrik@gmail.com)
  14664. * pissang (https://www.github.com/pissang)
  14665. */
  14666. var config = __webpack_require__(40);
  14667. var util = __webpack_require__(3);
  14668. var log = __webpack_require__(39);
  14669. var BoundingRect = __webpack_require__(15);
  14670. var Layer = __webpack_require__(87);
  14671. function parseInt10(val) {
  14672. return parseInt(val, 10);
  14673. }
  14674. function isLayerValid(layer) {
  14675. if (!layer) {
  14676. return false;
  14677. }
  14678. if (layer.isBuildin) {
  14679. return true;
  14680. }
  14681. if (typeof(layer.resize) !== 'function'
  14682. || typeof(layer.refresh) !== 'function'
  14683. ) {
  14684. return false;
  14685. }
  14686. return true;
  14687. }
  14688. function preProcessLayer(layer) {
  14689. layer.__unusedCount++;
  14690. }
  14691. function postProcessLayer(layer) {
  14692. layer.__dirty = false;
  14693. if (layer.__unusedCount == 1) {
  14694. layer.clear();
  14695. }
  14696. }
  14697. var tmpRect = new BoundingRect(0, 0, 0, 0);
  14698. var viewRect = new BoundingRect(0, 0, 0, 0);
  14699. function isDisplayableCulled(el, width, height) {
  14700. tmpRect.copy(el.getBoundingRect());
  14701. if (el.transform) {
  14702. tmpRect.applyTransform(el.transform);
  14703. }
  14704. viewRect.width = width;
  14705. viewRect.height = height;
  14706. return !tmpRect.intersect(viewRect);
  14707. }
  14708. function isClipPathChanged(clipPaths, prevClipPaths) {
  14709. if (!clipPaths || !prevClipPaths || (clipPaths.length !== prevClipPaths.length)) {
  14710. return true;
  14711. }
  14712. for (var i = 0; i < clipPaths.length; i++) {
  14713. if (clipPaths[i] !== prevClipPaths[i]) {
  14714. return true;
  14715. }
  14716. }
  14717. }
  14718. function doClip(clipPaths, ctx) {
  14719. for (var i = 0; i < clipPaths.length; i++) {
  14720. var clipPath = clipPaths[i];
  14721. var m;
  14722. if (clipPath.transform) {
  14723. m = clipPath.transform;
  14724. ctx.transform(
  14725. m[0], m[1],
  14726. m[2], m[3],
  14727. m[4], m[5]
  14728. );
  14729. }
  14730. var path = clipPath.path;
  14731. path.beginPath(ctx);
  14732. clipPath.buildPath(path, clipPath.shape);
  14733. ctx.clip();
  14734. // Transform back
  14735. if (clipPath.transform) {
  14736. m = clipPath.invTransform;
  14737. ctx.transform(
  14738. m[0], m[1],
  14739. m[2], m[3],
  14740. m[4], m[5]
  14741. );
  14742. }
  14743. }
  14744. }
  14745. /**
  14746. * @alias module:zrender/Painter
  14747. * @constructor
  14748. * @param {HTMLElement} root 绘图容器
  14749. * @param {module:zrender/Storage} storage
  14750. * @param {Ojbect} opts
  14751. */
  14752. var Painter = function (root, storage, opts) {
  14753. var singleCanvas = !root.nodeName // In node ?
  14754. || root.nodeName.toUpperCase() === 'CANVAS';
  14755. opts = opts || {};
  14756. /**
  14757. * @type {number}
  14758. */
  14759. this.dpr = opts.devicePixelRatio || config.devicePixelRatio;
  14760. /**
  14761. * @type {boolean}
  14762. * @private
  14763. */
  14764. this._singleCanvas = singleCanvas;
  14765. /**
  14766. * 绘图容器
  14767. * @type {HTMLElement}
  14768. */
  14769. this.root = root;
  14770. var rootStyle = root.style;
  14771. // In node environment using node-canvas
  14772. if (rootStyle) {
  14773. rootStyle['-webkit-tap-highlight-color'] = 'transparent';
  14774. rootStyle['-webkit-user-select'] = 'none';
  14775. rootStyle['user-select'] = 'none';
  14776. rootStyle['-webkit-touch-callout'] = 'none';
  14777. root.innerHTML = '';
  14778. }
  14779. /**
  14780. * @type {module:zrender/Storage}
  14781. */
  14782. this.storage = storage;
  14783. if (!singleCanvas) {
  14784. var width = this._getWidth();
  14785. var height = this._getHeight();
  14786. this._width = width;
  14787. this._height = height;
  14788. var domRoot = document.createElement('div');
  14789. this._domRoot = domRoot;
  14790. var domRootStyle = domRoot.style;
  14791. // domRoot.onselectstart = returnFalse; // 避免页面选中的尴尬
  14792. domRootStyle.position = 'relative';
  14793. domRootStyle.overflow = 'hidden';
  14794. domRootStyle.width = this._width + 'px';
  14795. domRootStyle.height = this._height + 'px';
  14796. root.appendChild(domRoot);
  14797. /**
  14798. * @type {Object.<key, module:zrender/Layer>}
  14799. * @private
  14800. */
  14801. this._layers = {};
  14802. /**
  14803. * @type {Array.<number>}
  14804. * @private
  14805. */
  14806. this._zlevelList = [];
  14807. }
  14808. else {
  14809. // Use canvas width and height directly
  14810. var width = root.width;
  14811. var height = root.height;
  14812. this._width = width;
  14813. this._height = height;
  14814. // Create layer if only one given canvas
  14815. // Device pixel ratio is fixed to 1 because given canvas has its specified width and height
  14816. var mainLayer = new Layer(root, this, 1);
  14817. mainLayer.initContext();
  14818. // FIXME Use canvas width and height
  14819. // mainLayer.resize(width, height);
  14820. this._layers = {
  14821. 0: mainLayer
  14822. };
  14823. this._zlevelList = [0];
  14824. }
  14825. this._layerConfig = {};
  14826. this.pathToImage = this._createPathToImage();
  14827. };
  14828. Painter.prototype = {
  14829. constructor: Painter,
  14830. /**
  14831. * If painter use a single canvas
  14832. * @return {boolean}
  14833. */
  14834. isSingleCanvas: function () {
  14835. return this._singleCanvas;
  14836. },
  14837. /**
  14838. * @return {HTMLDivElement}
  14839. */
  14840. getViewportRoot: function () {
  14841. return this._singleCanvas ? this._layers[0].dom : this._domRoot;
  14842. },
  14843. /**
  14844. * 刷新
  14845. * @param {boolean} [paintAll=false] 强制绘制所有displayable
  14846. */
  14847. refresh: function (paintAll) {
  14848. var list = this.storage.getDisplayList(true);
  14849. var zlevelList = this._zlevelList;
  14850. this._paintList(list, paintAll);
  14851. // Paint custum layers
  14852. for (var i = 0; i < zlevelList.length; i++) {
  14853. var z = zlevelList[i];
  14854. var layer = this._layers[z];
  14855. if (!layer.isBuildin && layer.refresh) {
  14856. layer.refresh();
  14857. }
  14858. }
  14859. return this;
  14860. },
  14861. _paintList: function (list, paintAll) {
  14862. if (paintAll == null) {
  14863. paintAll = false;
  14864. }
  14865. this._updateLayerStatus(list);
  14866. var currentLayer;
  14867. var currentZLevel;
  14868. var ctx;
  14869. var viewWidth = this._width;
  14870. var viewHeight = this._height;
  14871. this.eachBuildinLayer(preProcessLayer);
  14872. // var invTransform = [];
  14873. var prevElClipPaths = null;
  14874. for (var i = 0, l = list.length; i < l; i++) {
  14875. var el = list[i];
  14876. var elZLevel = this._singleCanvas ? 0 : el.zlevel;
  14877. // Change draw layer
  14878. if (currentZLevel !== elZLevel) {
  14879. // Only 0 zlevel if only has one canvas
  14880. currentZLevel = elZLevel;
  14881. currentLayer = this.getLayer(currentZLevel);
  14882. if (!currentLayer.isBuildin) {
  14883. log(
  14884. 'ZLevel ' + currentZLevel
  14885. + ' has been used by unkown layer ' + currentLayer.id
  14886. );
  14887. }
  14888. ctx = currentLayer.ctx;
  14889. // Reset the count
  14890. currentLayer.__unusedCount = 0;
  14891. if (currentLayer.__dirty || paintAll) {
  14892. currentLayer.clear();
  14893. }
  14894. }
  14895. if (
  14896. (currentLayer.__dirty || paintAll)
  14897. // Ignore invisible element
  14898. && !el.invisible
  14899. // Ignore transparent element
  14900. && el.style.opacity !== 0
  14901. // Ignore scale 0 element, in some environment like node-canvas
  14902. // Draw a scale 0 element can cause all following draw wrong
  14903. && el.scale[0] && el.scale[1]
  14904. // Ignore culled element
  14905. && !(el.culling && isDisplayableCulled(el, viewWidth, viewHeight))
  14906. ) {
  14907. var clipPaths = el.__clipPaths;
  14908. // Optimize when clipping on group with several elements
  14909. if (isClipPathChanged(clipPaths, prevElClipPaths)) {
  14910. // If has previous clipping state, restore from it
  14911. if (prevElClipPaths) {
  14912. ctx.restore();
  14913. }
  14914. // New clipping state
  14915. if (clipPaths) {
  14916. ctx.save();
  14917. doClip(clipPaths, ctx);
  14918. }
  14919. prevElClipPaths = clipPaths;
  14920. }
  14921. el.beforeBrush && el.beforeBrush(ctx);
  14922. el.brush(ctx, false);
  14923. el.afterBrush && el.afterBrush(ctx);
  14924. }
  14925. el.__dirty = false;
  14926. }
  14927. // If still has clipping state
  14928. if (prevElClipPaths) {
  14929. ctx.restore();
  14930. }
  14931. this.eachBuildinLayer(postProcessLayer);
  14932. },
  14933. /**
  14934. * 获取 zlevel 所在层,如果不存在则会创建一个新的层
  14935. * @param {number} zlevel
  14936. * @return {module:zrender/Layer}
  14937. */
  14938. getLayer: function (zlevel) {
  14939. if (this._singleCanvas) {
  14940. return this._layers[0];
  14941. }
  14942. var layer = this._layers[zlevel];
  14943. if (!layer) {
  14944. // Create a new layer
  14945. layer = new Layer('zr_' + zlevel, this, this.dpr);
  14946. layer.isBuildin = true;
  14947. if (this._layerConfig[zlevel]) {
  14948. util.merge(layer, this._layerConfig[zlevel], true);
  14949. }
  14950. this.insertLayer(zlevel, layer);
  14951. // Context is created after dom inserted to document
  14952. // Or excanvas will get 0px clientWidth and clientHeight
  14953. layer.initContext();
  14954. }
  14955. return layer;
  14956. },
  14957. insertLayer: function (zlevel, layer) {
  14958. var layersMap = this._layers;
  14959. var zlevelList = this._zlevelList;
  14960. var len = zlevelList.length;
  14961. var prevLayer = null;
  14962. var i = -1;
  14963. var domRoot = this._domRoot;
  14964. if (layersMap[zlevel]) {
  14965. log('ZLevel ' + zlevel + ' has been used already');
  14966. return;
  14967. }
  14968. // Check if is a valid layer
  14969. if (!isLayerValid(layer)) {
  14970. log('Layer of zlevel ' + zlevel + ' is not valid');
  14971. return;
  14972. }
  14973. if (len > 0 && zlevel > zlevelList[0]) {
  14974. for (i = 0; i < len - 1; i++) {
  14975. if (
  14976. zlevelList[i] < zlevel
  14977. && zlevelList[i + 1] > zlevel
  14978. ) {
  14979. break;
  14980. }
  14981. }
  14982. prevLayer = layersMap[zlevelList[i]];
  14983. }
  14984. zlevelList.splice(i + 1, 0, zlevel);
  14985. if (prevLayer) {
  14986. var prevDom = prevLayer.dom;
  14987. if (prevDom.nextSibling) {
  14988. domRoot.insertBefore(
  14989. layer.dom,
  14990. prevDom.nextSibling
  14991. );
  14992. }
  14993. else {
  14994. domRoot.appendChild(layer.dom);
  14995. }
  14996. }
  14997. else {
  14998. if (domRoot.firstChild) {
  14999. domRoot.insertBefore(layer.dom, domRoot.firstChild);
  15000. }
  15001. else {
  15002. domRoot.appendChild(layer.dom);
  15003. }
  15004. }
  15005. layersMap[zlevel] = layer;
  15006. },
  15007. // Iterate each layer
  15008. eachLayer: function (cb, context) {
  15009. var zlevelList = this._zlevelList;
  15010. var z;
  15011. var i;
  15012. for (i = 0; i < zlevelList.length; i++) {
  15013. z = zlevelList[i];
  15014. cb.call(context, this._layers[z], z);
  15015. }
  15016. },
  15017. // Iterate each buildin layer
  15018. eachBuildinLayer: function (cb, context) {
  15019. var zlevelList = this._zlevelList;
  15020. var layer;
  15021. var z;
  15022. var i;
  15023. for (i = 0; i < zlevelList.length; i++) {
  15024. z = zlevelList[i];
  15025. layer = this._layers[z];
  15026. if (layer.isBuildin) {
  15027. cb.call(context, layer, z);
  15028. }
  15029. }
  15030. },
  15031. // Iterate each other layer except buildin layer
  15032. eachOtherLayer: function (cb, context) {
  15033. var zlevelList = this._zlevelList;
  15034. var layer;
  15035. var z;
  15036. var i;
  15037. for (i = 0; i < zlevelList.length; i++) {
  15038. z = zlevelList[i];
  15039. layer = this._layers[z];
  15040. if (! layer.isBuildin) {
  15041. cb.call(context, layer, z);
  15042. }
  15043. }
  15044. },
  15045. /**
  15046. * 获取所有已创建的层
  15047. * @param {Array.<module:zrender/Layer>} [prevLayer]
  15048. */
  15049. getLayers: function () {
  15050. return this._layers;
  15051. },
  15052. _updateLayerStatus: function (list) {
  15053. var layers = this._layers;
  15054. var elCounts = {};
  15055. this.eachBuildinLayer(function (layer, z) {
  15056. elCounts[z] = layer.elCount;
  15057. layer.elCount = 0;
  15058. });
  15059. for (var i = 0, l = list.length; i < l; i++) {
  15060. var el = list[i];
  15061. var zlevel = this._singleCanvas ? 0 : el.zlevel;
  15062. var layer = layers[zlevel];
  15063. if (layer) {
  15064. layer.elCount++;
  15065. // 已经被标记为需要刷新
  15066. if (layer.__dirty) {
  15067. continue;
  15068. }
  15069. layer.__dirty = el.__dirty;
  15070. }
  15071. }
  15072. // 层中的元素数量有发生变化
  15073. this.eachBuildinLayer(function (layer, z) {
  15074. if (elCounts[z] !== layer.elCount) {
  15075. layer.__dirty = true;
  15076. }
  15077. });
  15078. },
  15079. /**
  15080. * 清除hover层外所有内容
  15081. */
  15082. clear: function () {
  15083. this.eachBuildinLayer(this._clearLayer);
  15084. return this;
  15085. },
  15086. _clearLayer: function (layer) {
  15087. layer.clear();
  15088. },
  15089. /**
  15090. * 修改指定zlevel的绘制参数
  15091. *
  15092. * @param {string} zlevel
  15093. * @param {Object} config 配置对象
  15094. * @param {string} [config.clearColor=0] 每次清空画布的颜色
  15095. * @param {string} [config.motionBlur=false] 是否开启动态模糊
  15096. * @param {number} [config.lastFrameAlpha=0.7]
  15097. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  15098. */
  15099. configLayer: function (zlevel, config) {
  15100. if (config) {
  15101. var layerConfig = this._layerConfig;
  15102. if (!layerConfig[zlevel]) {
  15103. layerConfig[zlevel] = config;
  15104. }
  15105. else {
  15106. util.merge(layerConfig[zlevel], config, true);
  15107. }
  15108. var layer = this._layers[zlevel];
  15109. if (layer) {
  15110. util.merge(layer, layerConfig[zlevel], true);
  15111. }
  15112. }
  15113. },
  15114. /**
  15115. * 删除指定层
  15116. * @param {number} zlevel 层所在的zlevel
  15117. */
  15118. delLayer: function (zlevel) {
  15119. var layers = this._layers;
  15120. var zlevelList = this._zlevelList;
  15121. var layer = layers[zlevel];
  15122. if (!layer) {
  15123. return;
  15124. }
  15125. layer.dom.parentNode.removeChild(layer.dom);
  15126. delete layers[zlevel];
  15127. zlevelList.splice(util.indexOf(zlevelList, zlevel), 1);
  15128. },
  15129. /**
  15130. * 区域大小变化后重绘
  15131. */
  15132. resize: function (width, height) {
  15133. var domRoot = this._domRoot;
  15134. // FIXME Why ?
  15135. domRoot.style.display = 'none';
  15136. width = width || this._getWidth();
  15137. height = height || this._getHeight();
  15138. domRoot.style.display = '';
  15139. // 优化没有实际改变的resize
  15140. if (this._width != width || height != this._height) {
  15141. domRoot.style.width = width + 'px';
  15142. domRoot.style.height = height + 'px';
  15143. for (var id in this._layers) {
  15144. this._layers[id].resize(width, height);
  15145. }
  15146. this.refresh(true);
  15147. }
  15148. this._width = width;
  15149. this._height = height;
  15150. return this;
  15151. },
  15152. /**
  15153. * 清除单独的一个层
  15154. * @param {number} zlevel
  15155. */
  15156. clearLayer: function (zlevel) {
  15157. var layer = this._layers[zlevel];
  15158. if (layer) {
  15159. layer.clear();
  15160. }
  15161. },
  15162. /**
  15163. * 释放
  15164. */
  15165. dispose: function () {
  15166. this.root.innerHTML = '';
  15167. this.root =
  15168. this.storage =
  15169. this._domRoot =
  15170. this._layers = null;
  15171. },
  15172. /**
  15173. * Get canvas which has all thing rendered
  15174. * @param {Object} opts
  15175. * @param {string} [opts.backgroundColor]
  15176. */
  15177. getRenderedCanvas: function (opts) {
  15178. opts = opts || {};
  15179. if (this._singleCanvas) {
  15180. return this._layers[0].dom;
  15181. }
  15182. var imageLayer = new Layer('image', this, opts.pixelRatio || this.dpr);
  15183. imageLayer.initContext();
  15184. var ctx = imageLayer.ctx;
  15185. imageLayer.clearColor = opts.backgroundColor;
  15186. imageLayer.clear();
  15187. var displayList = this.storage.getDisplayList(true);
  15188. for (var i = 0; i < displayList.length; i++) {
  15189. var el = displayList[i];
  15190. if (!el.invisible) {
  15191. el.beforeBrush && el.beforeBrush(ctx);
  15192. // TODO Check image cross origin
  15193. el.brush(ctx, false);
  15194. el.afterBrush && el.afterBrush(ctx);
  15195. }
  15196. }
  15197. return imageLayer.dom;
  15198. },
  15199. /**
  15200. * 获取绘图区域宽度
  15201. */
  15202. getWidth: function () {
  15203. return this._width;
  15204. },
  15205. /**
  15206. * 获取绘图区域高度
  15207. */
  15208. getHeight: function () {
  15209. return this._height;
  15210. },
  15211. _getWidth: function () {
  15212. var root = this.root;
  15213. var stl = document.defaultView.getComputedStyle(root);
  15214. // FIXME Better way to get the width and height when element has not been append to the document
  15215. return ((root.clientWidth || parseInt10(stl.width) || parseInt10(root.style.width))
  15216. - (parseInt10(stl.paddingLeft) || 0)
  15217. - (parseInt10(stl.paddingRight) || 0)) | 0;
  15218. },
  15219. _getHeight: function () {
  15220. var root = this.root;
  15221. var stl = document.defaultView.getComputedStyle(root);
  15222. return ((root.clientHeight || parseInt10(stl.height) || parseInt10(root.style.height))
  15223. - (parseInt10(stl.paddingTop) || 0)
  15224. - (parseInt10(stl.paddingBottom) || 0)) | 0;
  15225. },
  15226. _pathToImage: function (id, path, width, height, dpr) {
  15227. var canvas = document.createElement('canvas');
  15228. var ctx = canvas.getContext('2d');
  15229. canvas.width = width * dpr;
  15230. canvas.height = height * dpr;
  15231. ctx.clearRect(0, 0, width * dpr, height * dpr);
  15232. var pathTransform = {
  15233. position: path.position,
  15234. rotation: path.rotation,
  15235. scale: path.scale
  15236. };
  15237. path.position = [0, 0, 0];
  15238. path.rotation = 0;
  15239. path.scale = [1, 1];
  15240. if (path) {
  15241. path.brush(ctx);
  15242. }
  15243. var ImageShape = __webpack_require__(59);
  15244. var imgShape = new ImageShape({
  15245. id: id,
  15246. style: {
  15247. x: 0,
  15248. y: 0,
  15249. image: canvas
  15250. }
  15251. });
  15252. if (pathTransform.position != null) {
  15253. imgShape.position = path.position = pathTransform.position;
  15254. }
  15255. if (pathTransform.rotation != null) {
  15256. imgShape.rotation = path.rotation = pathTransform.rotation;
  15257. }
  15258. if (pathTransform.scale != null) {
  15259. imgShape.scale = path.scale = pathTransform.scale;
  15260. }
  15261. return imgShape;
  15262. },
  15263. _createPathToImage: function () {
  15264. var me = this;
  15265. return function (id, e, width, height) {
  15266. return me._pathToImage(
  15267. id, e, width, height, me.dpr
  15268. );
  15269. };
  15270. }
  15271. };
  15272. module.exports = Painter;
  15273. /***/ },
  15274. /* 87 */
  15275. /***/ function(module, exports, __webpack_require__) {
  15276. /**
  15277. * @module zrender/Layer
  15278. * @author pissang(https://www.github.com/pissang)
  15279. */
  15280. var util = __webpack_require__(3);
  15281. var config = __webpack_require__(40);
  15282. function returnFalse() {
  15283. return false;
  15284. }
  15285. /**
  15286. * 创建dom
  15287. *
  15288. * @inner
  15289. * @param {string} id dom id 待用
  15290. * @param {string} type dom type,such as canvas, div etc.
  15291. * @param {Painter} painter painter instance
  15292. * @param {number} number
  15293. */
  15294. function createDom(id, type, painter, dpr) {
  15295. var newDom = document.createElement(type);
  15296. var width = painter.getWidth();
  15297. var height = painter.getHeight();
  15298. var newDomStyle = newDom.style;
  15299. // 没append呢,请原谅我这样写,清晰~
  15300. newDomStyle.position = 'absolute';
  15301. newDomStyle.left = 0;
  15302. newDomStyle.top = 0;
  15303. newDomStyle.width = width + 'px';
  15304. newDomStyle.height = height + 'px';
  15305. newDom.width = width * dpr;
  15306. newDom.height = height * dpr;
  15307. // id不作为索引用,避免可能造成的重名,定义为私有属性
  15308. newDom.setAttribute('data-zr-dom-id', id);
  15309. return newDom;
  15310. }
  15311. /**
  15312. * @alias module:zrender/Layer
  15313. * @constructor
  15314. * @extends module:zrender/mixin/Transformable
  15315. * @param {string} id
  15316. * @param {module:zrender/Painter} painter
  15317. * @param {number} [dpr]
  15318. */
  15319. var Layer = function(id, painter, dpr) {
  15320. var dom;
  15321. dpr = dpr || config.devicePixelRatio;
  15322. if (typeof id === 'string') {
  15323. dom = createDom(id, 'canvas', painter, dpr);
  15324. }
  15325. // Not using isDom because in node it will return false
  15326. else if (util.isObject(id)) {
  15327. dom = id;
  15328. id = dom.id;
  15329. }
  15330. this.id = id;
  15331. this.dom = dom;
  15332. var domStyle = dom.style;
  15333. if (domStyle) { // Not in node
  15334. dom.onselectstart = returnFalse; // 避免页面选中的尴尬
  15335. domStyle['-webkit-user-select'] = 'none';
  15336. domStyle['user-select'] = 'none';
  15337. domStyle['-webkit-touch-callout'] = 'none';
  15338. domStyle['-webkit-tap-highlight-color'] = 'rgba(0,0,0,0)';
  15339. }
  15340. this.domBack = null;
  15341. this.ctxBack = null;
  15342. this.painter = painter;
  15343. this.config = null;
  15344. // Configs
  15345. /**
  15346. * 每次清空画布的颜色
  15347. * @type {string}
  15348. * @default 0
  15349. */
  15350. this.clearColor = 0;
  15351. /**
  15352. * 是否开启动态模糊
  15353. * @type {boolean}
  15354. * @default false
  15355. */
  15356. this.motionBlur = false;
  15357. /**
  15358. * 在开启动态模糊的时候使用,与上一帧混合的alpha值,值越大尾迹越明显
  15359. * @type {number}
  15360. * @default 0.7
  15361. */
  15362. this.lastFrameAlpha = 0.7;
  15363. /**
  15364. * Layer dpr
  15365. * @type {number}
  15366. */
  15367. this.dpr = dpr;
  15368. };
  15369. Layer.prototype = {
  15370. constructor: Layer,
  15371. elCount: 0,
  15372. __dirty: true,
  15373. initContext: function () {
  15374. this.ctx = this.dom.getContext('2d');
  15375. var dpr = this.dpr;
  15376. if (dpr != 1) {
  15377. this.ctx.scale(dpr, dpr);
  15378. }
  15379. },
  15380. createBackBuffer: function () {
  15381. var dpr = this.dpr;
  15382. this.domBack = createDom('back-' + this.id, 'canvas', this.painter, dpr);
  15383. this.ctxBack = this.domBack.getContext('2d');
  15384. if (dpr != 1) {
  15385. this.ctxBack.scale(dpr, dpr);
  15386. }
  15387. },
  15388. /**
  15389. * @param {number} width
  15390. * @param {number} height
  15391. */
  15392. resize: function (width, height) {
  15393. var dpr = this.dpr;
  15394. var dom = this.dom;
  15395. var domStyle = dom.style;
  15396. var domBack = this.domBack;
  15397. domStyle.width = width + 'px';
  15398. domStyle.height = height + 'px';
  15399. dom.width = width * dpr;
  15400. dom.height = height * dpr;
  15401. if (dpr != 1) {
  15402. this.ctx.scale(dpr, dpr);
  15403. }
  15404. if (domBack) {
  15405. domBack.width = width * dpr;
  15406. domBack.height = height * dpr;
  15407. if (dpr != 1) {
  15408. this.ctxBack.scale(dpr, dpr);
  15409. }
  15410. }
  15411. },
  15412. /**
  15413. * 清空该层画布
  15414. * @param {boolean} clearAll Clear all with out motion blur
  15415. */
  15416. clear: function (clearAll) {
  15417. var dom = this.dom;
  15418. var ctx = this.ctx;
  15419. var width = dom.width;
  15420. var height = dom.height;
  15421. var haveClearColor = this.clearColor;
  15422. var haveMotionBLur = this.motionBlur && !clearAll;
  15423. var lastFrameAlpha = this.lastFrameAlpha;
  15424. var dpr = this.dpr;
  15425. if (haveMotionBLur) {
  15426. if (!this.domBack) {
  15427. this.createBackBuffer();
  15428. }
  15429. this.ctxBack.globalCompositeOperation = 'copy';
  15430. this.ctxBack.drawImage(
  15431. dom, 0, 0,
  15432. width / dpr,
  15433. height / dpr
  15434. );
  15435. }
  15436. ctx.clearRect(0, 0, width / dpr, height / dpr);
  15437. if (haveClearColor) {
  15438. ctx.save();
  15439. ctx.fillStyle = this.clearColor;
  15440. ctx.fillRect(0, 0, width / dpr, height / dpr);
  15441. ctx.restore();
  15442. }
  15443. if (haveMotionBLur) {
  15444. var domBack = this.domBack;
  15445. ctx.save();
  15446. ctx.globalAlpha = lastFrameAlpha;
  15447. ctx.drawImage(domBack, 0, 0, width / dpr, height / dpr);
  15448. ctx.restore();
  15449. }
  15450. }
  15451. };
  15452. module.exports = Layer;
  15453. /***/ },
  15454. /* 88 */
  15455. /***/ function(module, exports, __webpack_require__) {
  15456. var graphic = __webpack_require__(42);
  15457. var zrUtil = __webpack_require__(3);
  15458. var PI = Math.PI;
  15459. /**
  15460. * @param {module:echarts/ExtensionAPI} api
  15461. * @param {Object} [opts]
  15462. * @param {string} [opts.text]
  15463. * @param {string} [opts.color]
  15464. * @param {string} [opts.textColor]
  15465. * @return {module:zrender/Element}
  15466. */
  15467. module.exports = function (api, opts) {
  15468. opts = opts || {};
  15469. zrUtil.defaults(opts, {
  15470. text: 'loading',
  15471. color: '#c23531',
  15472. textColor: '#000',
  15473. maskColor: 'rgba(255, 255, 255, 0.8)',
  15474. zlevel: 0
  15475. });
  15476. var mask = new graphic.Rect({
  15477. style: {
  15478. fill: opts.maskColor
  15479. },
  15480. zlevel: opts.zlevel,
  15481. z: 10000
  15482. });
  15483. var arc = new graphic.Arc({
  15484. shape: {
  15485. startAngle: -PI / 2,
  15486. endAngle: -PI / 2 + 0.1,
  15487. r: 10
  15488. },
  15489. style: {
  15490. stroke: opts.color,
  15491. lineCap: 'round',
  15492. lineWidth: 5
  15493. },
  15494. zlevel: opts.zlevel,
  15495. z: 10001
  15496. });
  15497. var labelRect = new graphic.Rect({
  15498. style: {
  15499. fill: 'none',
  15500. text: opts.text,
  15501. textPosition: 'right',
  15502. textDistance: 10,
  15503. textFill: opts.textColor
  15504. },
  15505. zlevel: opts.zlevel,
  15506. z: 10001
  15507. });
  15508. arc.animateShape(true)
  15509. .when(1000, {
  15510. endAngle: PI * 3 / 2
  15511. })
  15512. .start('circularInOut');
  15513. arc.animateShape(true)
  15514. .when(1000, {
  15515. startAngle: PI * 3 / 2
  15516. })
  15517. .delay(300)
  15518. .start('circularInOut');
  15519. var group = new graphic.Group();
  15520. group.add(arc);
  15521. group.add(labelRect);
  15522. group.add(mask);
  15523. // Inject resize
  15524. group.resize = function () {
  15525. var cx = api.getWidth() / 2;
  15526. var cy = api.getHeight() / 2;
  15527. arc.setShape({
  15528. cx: cx,
  15529. cy: cy
  15530. });
  15531. var r = arc.shape.r;
  15532. labelRect.setShape({
  15533. x: cx - r,
  15534. y: cy - r,
  15535. width: r * 2,
  15536. height: r * 2
  15537. });
  15538. mask.setShape({
  15539. x: 0,
  15540. y: 0,
  15541. width: api.getWidth(),
  15542. height: api.getHeight()
  15543. });
  15544. };
  15545. group.resize();
  15546. return group;
  15547. };
  15548. /***/ },
  15549. /* 89 */
  15550. /***/ function(module, exports, __webpack_require__) {
  15551. var Gradient = __webpack_require__(4);
  15552. module.exports = function (seriesType, styleType, ecModel) {
  15553. function encodeColor(seriesModel) {
  15554. var colorAccessPath = [styleType, 'normal', 'color'];
  15555. var colorList = ecModel.get('color');
  15556. var data = seriesModel.getData();
  15557. var color = seriesModel.get(colorAccessPath) // Set in itemStyle
  15558. || colorList[seriesModel.seriesIndex % colorList.length]; // Default color
  15559. // FIXME Set color function or use the platte color
  15560. data.setVisual('color', color);
  15561. // Only visible series has each data be visual encoded
  15562. if (!ecModel.isSeriesFiltered(seriesModel)) {
  15563. if (typeof color === 'function' && !(color instanceof Gradient)) {
  15564. data.each(function (idx) {
  15565. data.setItemVisual(
  15566. idx, 'color', color(seriesModel.getDataParams(idx))
  15567. );
  15568. });
  15569. }
  15570. data.each(function (idx) {
  15571. var itemModel = data.getItemModel(idx);
  15572. var color = itemModel.get(colorAccessPath, true);
  15573. if (color != null) {
  15574. data.setItemVisual(idx, 'color', color);
  15575. }
  15576. });
  15577. }
  15578. }
  15579. seriesType ? ecModel.eachSeriesByType(seriesType, encodeColor)
  15580. : ecModel.eachSeries(encodeColor);
  15581. };
  15582. /***/ },
  15583. /* 90 */
  15584. /***/ function(module, exports, __webpack_require__) {
  15585. // Compatitable with 2.0
  15586. var zrUtil = __webpack_require__(3);
  15587. var compatStyle = __webpack_require__(91);
  15588. function get(opt, path) {
  15589. path = path.split(',');
  15590. var obj = opt;
  15591. for (var i = 0; i < path.length; i++) {
  15592. obj = obj && obj[path[i]];
  15593. if (obj == null) {
  15594. break;
  15595. }
  15596. }
  15597. return obj;
  15598. }
  15599. function set(opt, path, val, overwrite) {
  15600. path = path.split(',');
  15601. var obj = opt;
  15602. var key;
  15603. for (var i = 0; i < path.length - 1; i++) {
  15604. key = path[i];
  15605. if (obj[key] == null) {
  15606. obj[key] = {};
  15607. }
  15608. obj = obj[key];
  15609. }
  15610. if (overwrite || obj[path[i]] == null) {
  15611. obj[path[i]] = val;
  15612. }
  15613. }
  15614. function compatLayoutProperties(option) {
  15615. each(LAYOUT_PROPERTIES, function (prop) {
  15616. if (prop[0] in option && !(prop[1] in option)) {
  15617. option[prop[1]] = option[prop[0]];
  15618. }
  15619. });
  15620. }
  15621. var LAYOUT_PROPERTIES = [
  15622. ['x', 'left'], ['y', 'top'], ['x2', 'right'], ['y2', 'bottom']
  15623. ];
  15624. var COMPATITABLE_COMPONENTS = [
  15625. 'grid', 'geo', 'parallel', 'legend', 'toolbox', 'title', 'visualMap', 'dataZoom', 'timeline'
  15626. ];
  15627. var COMPATITABLE_SERIES = [
  15628. 'bar', 'boxplot', 'candlestick', 'chord', 'effectScatter',
  15629. 'funnel', 'gauge', 'lines', 'graph', 'heatmap', 'line', 'map', 'parallel',
  15630. 'pie', 'radar', 'sankey', 'scatter', 'treemap'
  15631. ];
  15632. var each = zrUtil.each;
  15633. module.exports = function (option) {
  15634. each(option.series, function (seriesOpt) {
  15635. if (!zrUtil.isObject(seriesOpt)) {
  15636. return;
  15637. }
  15638. var seriesType = seriesOpt.type;
  15639. compatStyle(seriesOpt);
  15640. if (seriesType === 'pie' || seriesType === 'gauge') {
  15641. if (seriesOpt.clockWise != null) {
  15642. seriesOpt.clockwise = seriesOpt.clockWise;
  15643. }
  15644. }
  15645. if (seriesType === 'gauge') {
  15646. var pointerColor = get(seriesOpt, 'pointer.color');
  15647. pointerColor != null
  15648. && set(seriesOpt, 'itemStyle.normal.color', pointerColor);
  15649. }
  15650. for (var i = 0; i < COMPATITABLE_SERIES.length; i++) {
  15651. if (COMPATITABLE_SERIES[i] === seriesOpt.type) {
  15652. compatLayoutProperties(seriesOpt);
  15653. break;
  15654. }
  15655. }
  15656. });
  15657. // dataRange has changed to visualMap
  15658. if (option.dataRange) {
  15659. option.visualMap = option.dataRange;
  15660. }
  15661. each(COMPATITABLE_COMPONENTS, function (componentName) {
  15662. var options = option[componentName];
  15663. if (options) {
  15664. if (!zrUtil.isArray(options)) {
  15665. options = [options];
  15666. }
  15667. each(options, function (option) {
  15668. compatLayoutProperties(option);
  15669. });
  15670. }
  15671. });
  15672. };
  15673. /***/ },
  15674. /* 91 */
  15675. /***/ function(module, exports, __webpack_require__) {
  15676. var zrUtil = __webpack_require__(3);
  15677. var POSSIBLE_STYLES = [
  15678. 'areaStyle', 'lineStyle', 'nodeStyle', 'linkStyle',
  15679. 'chordStyle', 'label', 'labelLine'
  15680. ];
  15681. function compatItemStyle(opt) {
  15682. var itemStyleOpt = opt && opt.itemStyle;
  15683. if (itemStyleOpt) {
  15684. zrUtil.each(POSSIBLE_STYLES, function (styleName) {
  15685. var normalItemStyleOpt = itemStyleOpt.normal;
  15686. var emphasisItemStyleOpt = itemStyleOpt.emphasis;
  15687. if (normalItemStyleOpt && normalItemStyleOpt[styleName]) {
  15688. opt[styleName] = opt[styleName] || {};
  15689. if (!opt[styleName].normal) {
  15690. opt[styleName].normal = normalItemStyleOpt[styleName];
  15691. }
  15692. else {
  15693. zrUtil.merge(opt[styleName].normal, normalItemStyleOpt[styleName]);
  15694. }
  15695. normalItemStyleOpt[styleName] = null;
  15696. }
  15697. if (emphasisItemStyleOpt && emphasisItemStyleOpt[styleName]) {
  15698. opt[styleName] = opt[styleName] || {};
  15699. if (!opt[styleName].emphasis) {
  15700. opt[styleName].emphasis = emphasisItemStyleOpt[styleName];
  15701. }
  15702. else {
  15703. zrUtil.merge(opt[styleName].emphasis, emphasisItemStyleOpt[styleName]);
  15704. }
  15705. emphasisItemStyleOpt[styleName] = null;
  15706. }
  15707. });
  15708. }
  15709. }
  15710. module.exports = function (seriesOpt) {
  15711. if (!seriesOpt) {
  15712. return;
  15713. }
  15714. compatItemStyle(seriesOpt);
  15715. compatItemStyle(seriesOpt.markPoint);
  15716. compatItemStyle(seriesOpt.markLine);
  15717. var data = seriesOpt.data;
  15718. if (data) {
  15719. for (var i = 0; i < data.length; i++) {
  15720. compatItemStyle(data[i]);
  15721. }
  15722. // mark point data
  15723. var markPoint = seriesOpt.markPoint;
  15724. if (markPoint && markPoint.data) {
  15725. var mpData = markPoint.data;
  15726. for (var i = 0; i < mpData.length; i++) {
  15727. compatItemStyle(mpData[i]);
  15728. }
  15729. }
  15730. // mark line data
  15731. var markLine = seriesOpt.markLine;
  15732. if (markLine && markLine.data) {
  15733. var mlData = markLine.data;
  15734. for (var i = 0; i < mlData.length; i++) {
  15735. if (zrUtil.isArray(mlData[i])) {
  15736. compatItemStyle(mlData[i][0]);
  15737. compatItemStyle(mlData[i][1]);
  15738. }
  15739. else {
  15740. compatItemStyle(mlData[i]);
  15741. }
  15742. }
  15743. }
  15744. }
  15745. };
  15746. /***/ },
  15747. /* 92 */
  15748. /***/ function(module, exports, __webpack_require__) {
  15749. var zrUtil = __webpack_require__(3);
  15750. var echarts = __webpack_require__(1);
  15751. __webpack_require__(93);
  15752. __webpack_require__(98);
  15753. echarts.registerVisualCoding('chart', zrUtil.curry(
  15754. __webpack_require__(104), 'line', 'circle', 'line'
  15755. ));
  15756. echarts.registerLayout(zrUtil.curry(
  15757. __webpack_require__(105), 'line'
  15758. ));
  15759. // Down sample after filter
  15760. echarts.registerProcessor('statistic', zrUtil.curry(
  15761. __webpack_require__(106), 'line'
  15762. ));
  15763. // In case developer forget to include grid component
  15764. __webpack_require__(107);
  15765. /***/ },
  15766. /* 93 */
  15767. /***/ function(module, exports, __webpack_require__) {
  15768. 'use strict';
  15769. var createListFromArray = __webpack_require__(94);
  15770. var SeriesModel = __webpack_require__(27);
  15771. module.exports = SeriesModel.extend({
  15772. type: 'series.line',
  15773. dependencies: ['grid', 'polar'],
  15774. getInitialData: function (option, ecModel) {
  15775. return createListFromArray(option.data, this, ecModel);
  15776. },
  15777. defaultOption: {
  15778. zlevel: 0, // 一级层叠
  15779. z: 2, // 二级层叠
  15780. coordinateSystem: 'cartesian2d',
  15781. legendHoverLink: true,
  15782. hoverAnimation: true,
  15783. // stack: null
  15784. xAxisIndex: 0,
  15785. yAxisIndex: 0,
  15786. polarIndex: 0,
  15787. // If clip the overflow value
  15788. clipOverflow: true,
  15789. label: {
  15790. normal: {
  15791. position: 'top'
  15792. }
  15793. },
  15794. // itemStyle: {
  15795. // normal: {},
  15796. // emphasis: {}
  15797. // },
  15798. lineStyle: {
  15799. normal: {
  15800. width: 2,
  15801. type: 'solid'
  15802. }
  15803. },
  15804. // areaStyle: {},
  15805. smooth: false,
  15806. smoothMonotone: null,
  15807. // 拐点图形类型
  15808. symbol: 'emptyCircle',
  15809. // 拐点图形大小
  15810. symbolSize: 4,
  15811. // 拐点图形旋转控制
  15812. symbolRotate: null,
  15813. // 是否显示 symbol, 只有在 tooltip hover 的时候显示
  15814. showSymbol: true,
  15815. // 标志图形默认只有主轴显示(随主轴标签间隔隐藏策略)
  15816. showAllSymbol: false,
  15817. // 是否连接断点
  15818. connectNulls: false,
  15819. // 数据过滤,'average', 'max', 'min', 'sum'
  15820. sampling: 'none',
  15821. animationEasing: 'linear'
  15822. }
  15823. });
  15824. /***/ },
  15825. /* 94 */
  15826. /***/ function(module, exports, __webpack_require__) {
  15827. 'use strict';
  15828. var List = __webpack_require__(95);
  15829. var completeDimensions = __webpack_require__(97);
  15830. var zrUtil = __webpack_require__(3);
  15831. var modelUtil = __webpack_require__(5);
  15832. var CoordinateSystem = __webpack_require__(25);
  15833. var getDataItemValue = modelUtil.getDataItemValue;
  15834. var converDataValue = modelUtil.converDataValue;
  15835. function firstDataNotNull(data) {
  15836. var i = 0;
  15837. while (i < data.length && data[i] == null) {
  15838. i++;
  15839. }
  15840. return data[i];
  15841. }
  15842. function ifNeedCompleteOrdinalData(data) {
  15843. var sampleItem = firstDataNotNull(data);
  15844. return sampleItem != null
  15845. && !zrUtil.isArray(getDataItemValue(sampleItem));
  15846. }
  15847. /**
  15848. * Helper function to create a list from option data
  15849. */
  15850. function createListFromArray(data, seriesModel, ecModel) {
  15851. // If data is undefined
  15852. data = data || [];
  15853. if (!zrUtil.isArray(data)) {
  15854. throw new Error('Invalid data.');
  15855. }
  15856. var coordSysName = seriesModel.get('coordinateSystem');
  15857. var creator = creators[coordSysName];
  15858. var registeredCoordSys = CoordinateSystem.get(coordSysName);
  15859. // FIXME
  15860. var result = creator && creator(data, seriesModel, ecModel);
  15861. var dimensions = result && result.dimensions;
  15862. if (!dimensions) {
  15863. // Get dimensions from registered coordinate system
  15864. dimensions = (registeredCoordSys && registeredCoordSys.dimensions) || ['x', 'y'];
  15865. dimensions = completeDimensions(dimensions, data, dimensions.concat(['value']));
  15866. }
  15867. var categoryAxisModel = result && result.categoryAxisModel;
  15868. var categories;
  15869. var categoryDimIndex = dimensions[0].type === 'ordinal'
  15870. ? 0 : (dimensions[1].type === 'ordinal' ? 1 : -1);
  15871. var list = new List(dimensions, seriesModel);
  15872. var nameList = createNameList(result, data);
  15873. var dimValueGetter = (categoryAxisModel && ifNeedCompleteOrdinalData(data))
  15874. ? function (itemOpt, dimName, dataIndex, dimIndex) {
  15875. // Use dataIndex as ordinal value in categoryAxis
  15876. return dimIndex === categoryDimIndex
  15877. ? dataIndex
  15878. : converDataValue(getDataItemValue(itemOpt), dimensions[dimIndex]);
  15879. }
  15880. : function (itemOpt, dimName, dataIndex, dimIndex) {
  15881. var value = getDataItemValue(itemOpt);
  15882. var val = converDataValue(value && value[dimIndex], dimensions[dimIndex]);
  15883. if (categoryDimIndex === dimIndex) {
  15884. // If given value is a category string
  15885. if (typeof val === 'string') {
  15886. // Lazy get categories
  15887. categories = categories || categoryAxisModel.getCategories();
  15888. val = zrUtil.indexOf(categories, val);
  15889. if (val < 0 && !isNaN(val)) {
  15890. // In case some one write '1', '2' istead of 1, 2
  15891. val = +val;
  15892. }
  15893. }
  15894. }
  15895. return val;
  15896. };
  15897. list.initData(data, nameList, dimValueGetter);
  15898. return list;
  15899. }
  15900. function isStackable(axisType) {
  15901. return axisType !== 'category' && axisType !== 'time';
  15902. }
  15903. function getDimTypeByAxis(axisType) {
  15904. return axisType === 'category'
  15905. ? 'ordinal'
  15906. : axisType === 'time'
  15907. ? 'time'
  15908. : 'float';
  15909. }
  15910. /**
  15911. * Creaters for each coord system.
  15912. * @return {Object} {dimensions, categoryAxisModel};
  15913. */
  15914. var creators = {
  15915. cartesian2d: function (data, seriesModel, ecModel) {
  15916. var xAxisModel = ecModel.getComponent('xAxis', seriesModel.get('xAxisIndex'));
  15917. var yAxisModel = ecModel.getComponent('yAxis', seriesModel.get('yAxisIndex'));
  15918. if (!xAxisModel || !yAxisModel) {
  15919. throw new Error('Axis option not found');
  15920. }
  15921. var xAxisType = xAxisModel.get('type');
  15922. var yAxisType = yAxisModel.get('type');
  15923. var dimensions = [
  15924. {
  15925. name: 'x',
  15926. type: getDimTypeByAxis(xAxisType),
  15927. stackable: isStackable(xAxisType)
  15928. },
  15929. {
  15930. name: 'y',
  15931. // If two category axes
  15932. type: getDimTypeByAxis(yAxisType),
  15933. stackable: isStackable(yAxisType)
  15934. }
  15935. ];
  15936. var isXAxisCateogry = xAxisType === 'category';
  15937. completeDimensions(dimensions, data, ['x', 'y', 'z']);
  15938. return {
  15939. dimensions: dimensions,
  15940. categoryIndex: isXAxisCateogry ? 0 : 1,
  15941. categoryAxisModel: isXAxisCateogry
  15942. ? xAxisModel
  15943. : (yAxisType === 'category' ? yAxisModel : null)
  15944. };
  15945. },
  15946. polar: function (data, seriesModel, ecModel) {
  15947. var polarIndex = seriesModel.get('polarIndex') || 0;
  15948. var axisFinder = function (axisModel) {
  15949. return axisModel.get('polarIndex') === polarIndex;
  15950. };
  15951. var angleAxisModel = ecModel.findComponents({
  15952. mainType: 'angleAxis', filter: axisFinder
  15953. })[0];
  15954. var radiusAxisModel = ecModel.findComponents({
  15955. mainType: 'radiusAxis', filter: axisFinder
  15956. })[0];
  15957. if (!angleAxisModel || !radiusAxisModel) {
  15958. throw new Error('Axis option not found');
  15959. }
  15960. var radiusAxisType = radiusAxisModel.get('type');
  15961. var angleAxisType = angleAxisModel.get('type');
  15962. var dimensions = [
  15963. {
  15964. name: 'radius',
  15965. type: getDimTypeByAxis(radiusAxisType),
  15966. stackable: isStackable(radiusAxisType)
  15967. },
  15968. {
  15969. name: 'angle',
  15970. type: getDimTypeByAxis(angleAxisType),
  15971. stackable: isStackable(angleAxisType)
  15972. }
  15973. ];
  15974. var isAngleAxisCateogry = angleAxisType === 'category';
  15975. completeDimensions(dimensions, data, ['radius', 'angle', 'value']);
  15976. return {
  15977. dimensions: dimensions,
  15978. categoryIndex: isAngleAxisCateogry ? 1 : 0,
  15979. categoryAxisModel: isAngleAxisCateogry
  15980. ? angleAxisModel
  15981. : (radiusAxisType === 'category' ? radiusAxisModel : null)
  15982. };
  15983. },
  15984. geo: function (data, seriesModel, ecModel) {
  15985. // TODO Region
  15986. // 多个散点图系列在同一个地区的时候
  15987. return {
  15988. dimensions: completeDimensions([
  15989. {name: 'lng'},
  15990. {name: 'lat'}
  15991. ], data, ['lng', 'lat', 'value'])
  15992. };
  15993. }
  15994. };
  15995. function createNameList(result, data) {
  15996. var nameList = [];
  15997. if (result && result.categoryAxisModel) {
  15998. // FIXME Two category axis
  15999. var categories = result.categoryAxisModel.getCategories();
  16000. if (categories) {
  16001. var dataLen = data.length;
  16002. // Ordered data is given explicitly like
  16003. // [[3, 0.2], [1, 0.3], [2, 0.15]]
  16004. // or given scatter data,
  16005. // pick the category
  16006. if (zrUtil.isArray(data[0]) && data[0].length > 1) {
  16007. nameList = [];
  16008. for (var i = 0; i < dataLen; i++) {
  16009. nameList[i] = categories[data[i][result.categoryIndex || 0]];
  16010. }
  16011. }
  16012. else {
  16013. nameList = categories.slice(0);
  16014. }
  16015. }
  16016. }
  16017. return nameList;
  16018. }
  16019. module.exports = createListFromArray;
  16020. /***/ },
  16021. /* 95 */
  16022. /***/ function(module, exports, __webpack_require__) {
  16023. /* WEBPACK VAR INJECTION */(function(global) {/**
  16024. * List for data storage
  16025. * @module echarts/data/List
  16026. */
  16027. var UNDEFINED = 'undefined';
  16028. var globalObj = typeof window === 'undefined' ? global : window;
  16029. var Float64Array = typeof globalObj.Float64Array === UNDEFINED
  16030. ? Array : globalObj.Float64Array;
  16031. var Int32Array = typeof globalObj.Int32Array === UNDEFINED
  16032. ? Array : globalObj.Int32Array;
  16033. var dataCtors = {
  16034. 'float': Float64Array,
  16035. 'int': Int32Array,
  16036. // Ordinal data type can be string or int
  16037. 'ordinal': Array,
  16038. 'number': Array,
  16039. 'time': Array
  16040. };
  16041. var Model = __webpack_require__(8);
  16042. var DataDiffer = __webpack_require__(96);
  16043. var zrUtil = __webpack_require__(3);
  16044. var modelUtil = __webpack_require__(5);
  16045. var isObject = zrUtil.isObject;
  16046. var IMMUTABLE_PROPERTIES = [
  16047. 'stackedOn', '_nameList', '_idList', '_rawData'
  16048. ];
  16049. var transferImmuProperties = function (a, b) {
  16050. zrUtil.each(IMMUTABLE_PROPERTIES.concat(b.__wrappedMethods || []), function (propName) {
  16051. if (b.hasOwnProperty(propName)) {
  16052. a[propName] = b[propName];
  16053. }
  16054. });
  16055. a.__wrappedMethods = b.__wrappedMethods;
  16056. };
  16057. /**
  16058. * @constructor
  16059. * @alias module:echarts/data/List
  16060. *
  16061. * @param {Array.<string>} dimensions
  16062. * Dimensions should be concrete names like x, y, z, lng, lat, angle, radius
  16063. * @param {module:echarts/model/Model} hostModel
  16064. */
  16065. var List = function (dimensions, hostModel) {
  16066. dimensions = dimensions || ['x', 'y'];
  16067. var dimensionInfos = {};
  16068. var dimensionNames = [];
  16069. for (var i = 0; i < dimensions.length; i++) {
  16070. var dimensionName;
  16071. var dimensionInfo = {};
  16072. if (typeof dimensions[i] === 'string') {
  16073. dimensionName = dimensions[i];
  16074. dimensionInfo = {
  16075. name: dimensionName,
  16076. stackable: false,
  16077. // Type can be 'float', 'int', 'number'
  16078. // Default is number, Precision of float may not enough
  16079. type: 'number'
  16080. };
  16081. }
  16082. else {
  16083. dimensionInfo = dimensions[i];
  16084. dimensionName = dimensionInfo.name;
  16085. dimensionInfo.type = dimensionInfo.type || 'number';
  16086. }
  16087. dimensionNames.push(dimensionName);
  16088. dimensionInfos[dimensionName] = dimensionInfo;
  16089. }
  16090. /**
  16091. * @readOnly
  16092. * @type {Array.<string>}
  16093. */
  16094. this.dimensions = dimensionNames;
  16095. /**
  16096. * Infomation of each data dimension, like data type.
  16097. * @type {Object}
  16098. */
  16099. this._dimensionInfos = dimensionInfos;
  16100. /**
  16101. * @type {module:echarts/model/Model}
  16102. */
  16103. this.hostModel = hostModel;
  16104. /**
  16105. * @type {module:echarts/model/Model}
  16106. */
  16107. this.dataType;
  16108. /**
  16109. * Indices stores the indices of data subset after filtered.
  16110. * This data subset will be used in chart.
  16111. * @type {Array.<number>}
  16112. * @readOnly
  16113. */
  16114. this.indices = [];
  16115. /**
  16116. * Data storage
  16117. * @type {Object.<key, TypedArray|Array>}
  16118. * @private
  16119. */
  16120. this._storage = {};
  16121. /**
  16122. * @type {Array.<string>}
  16123. */
  16124. this._nameList = [];
  16125. /**
  16126. * @type {Array.<string>}
  16127. */
  16128. this._idList = [];
  16129. /**
  16130. * Models of data option is stored sparse for optimizing memory cost
  16131. * @type {Array.<module:echarts/model/Model>}
  16132. * @private
  16133. */
  16134. this._optionModels = [];
  16135. /**
  16136. * @param {module:echarts/data/List}
  16137. */
  16138. this.stackedOn = null;
  16139. /**
  16140. * Global visual properties after visual coding
  16141. * @type {Object}
  16142. * @private
  16143. */
  16144. this._visual = {};
  16145. /**
  16146. * Globel layout properties.
  16147. * @type {Object}
  16148. * @private
  16149. */
  16150. this._layout = {};
  16151. /**
  16152. * Item visual properties after visual coding
  16153. * @type {Array.<Object>}
  16154. * @private
  16155. */
  16156. this._itemVisuals = [];
  16157. /**
  16158. * Item layout properties after layout
  16159. * @type {Array.<Object>}
  16160. * @private
  16161. */
  16162. this._itemLayouts = [];
  16163. /**
  16164. * Graphic elemnents
  16165. * @type {Array.<module:zrender/Element>}
  16166. * @private
  16167. */
  16168. this._graphicEls = [];
  16169. /**
  16170. * @type {Array.<Array|Object>}
  16171. * @private
  16172. */
  16173. this._rawData;
  16174. /**
  16175. * @type {Object}
  16176. * @private
  16177. */
  16178. this._extent;
  16179. };
  16180. var listProto = List.prototype;
  16181. listProto.type = 'list';
  16182. /**
  16183. * Get dimension name
  16184. * @param {string|number} dim
  16185. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  16186. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  16187. * @return {string} Concrete dim name.
  16188. */
  16189. listProto.getDimension = function (dim) {
  16190. if (!isNaN(dim)) {
  16191. dim = this.dimensions[dim] || dim;
  16192. }
  16193. return dim;
  16194. };
  16195. /**
  16196. * Get type and stackable info of particular dimension
  16197. * @param {string|number} dim
  16198. * Dimension can be concrete names like x, y, z, lng, lat, angle, radius
  16199. * Or a ordinal number. For example getDimensionInfo(0) will return 'x' or 'lng' or 'radius'
  16200. */
  16201. listProto.getDimensionInfo = function (dim) {
  16202. return zrUtil.clone(this._dimensionInfos[this.getDimension(dim)]);
  16203. };
  16204. /**
  16205. * Initialize from data
  16206. * @param {Array.<Object|number|Array>} data
  16207. * @param {Array.<string>} [nameList]
  16208. * @param {Function} [dimValueGetter] (dataItem, dimName, dataIndex, dimIndex) => number
  16209. */
  16210. listProto.initData = function (data, nameList, dimValueGetter) {
  16211. data = data || [];
  16212. if (!zrUtil.isArray(data)) {
  16213. throw new Error('Invalid data.');
  16214. }
  16215. this._rawData = data;
  16216. // Clear
  16217. var storage = this._storage = {};
  16218. var indices = this.indices = [];
  16219. var dimensions = this.dimensions;
  16220. var size = data.length;
  16221. var dimensionInfoMap = this._dimensionInfos;
  16222. var idList = [];
  16223. var nameRepeatCount = {};
  16224. nameList = nameList || [];
  16225. // Init storage
  16226. for (var i = 0; i < dimensions.length; i++) {
  16227. var dimInfo = dimensionInfoMap[dimensions[i]];
  16228. var DataCtor = dataCtors[dimInfo.type];
  16229. storage[dimensions[i]] = new DataCtor(size);
  16230. }
  16231. // Default dim value getter
  16232. dimValueGetter = dimValueGetter || function (dataItem, dimName, dataIndex, dimIndex) {
  16233. var value = modelUtil.getDataItemValue(dataItem);
  16234. return modelUtil.converDataValue(
  16235. zrUtil.isArray(value)
  16236. ? value[dimIndex]
  16237. // If value is a single number or something else not array.
  16238. : value,
  16239. dimensionInfoMap[dimName]
  16240. );
  16241. };
  16242. for (var idx = 0; idx < data.length; idx++) {
  16243. var dataItem = data[idx];
  16244. // Each data item is value
  16245. // [1, 2]
  16246. // 2
  16247. // Bar chart, line chart which uses category axis
  16248. // only gives the 'y' value. 'x' value is the indices of cateogry
  16249. // Use a tempValue to normalize the value to be a (x, y) value
  16250. // Store the data by dimensions
  16251. for (var k = 0; k < dimensions.length; k++) {
  16252. var dim = dimensions[k];
  16253. var dimStorage = storage[dim];
  16254. // PENDING NULL is empty or zero
  16255. dimStorage[idx] = dimValueGetter(dataItem, dim, idx, k);
  16256. }
  16257. indices.push(idx);
  16258. }
  16259. // Use the name in option and create id
  16260. for (var i = 0; i < data.length; i++) {
  16261. var id = '';
  16262. if (!nameList[i]) {
  16263. nameList[i] = data[i].name;
  16264. // Try using the id in option
  16265. id = data[i].id;
  16266. }
  16267. var name = nameList[i] || '';
  16268. if (!id && name) {
  16269. // Use name as id and add counter to avoid same name
  16270. nameRepeatCount[name] = nameRepeatCount[name] || 0;
  16271. id = name;
  16272. if (nameRepeatCount[name] > 0) {
  16273. id += '__ec__' + nameRepeatCount[name];
  16274. }
  16275. nameRepeatCount[name]++;
  16276. }
  16277. id && (idList[i] = id);
  16278. }
  16279. this._nameList = nameList;
  16280. this._idList = idList;
  16281. };
  16282. /**
  16283. * @return {number}
  16284. */
  16285. listProto.count = function () {
  16286. return this.indices.length;
  16287. };
  16288. /**
  16289. * Get value. Return NaN if idx is out of range.
  16290. * @param {string} dim Dim must be concrete name.
  16291. * @param {number} idx
  16292. * @param {boolean} stack
  16293. * @return {number}
  16294. */
  16295. listProto.get = function (dim, idx, stack) {
  16296. var storage = this._storage;
  16297. var dataIndex = this.indices[idx];
  16298. // If value not exists
  16299. if (dataIndex == null) {
  16300. return NaN;
  16301. }
  16302. var value = storage[dim] && storage[dim][dataIndex];
  16303. // FIXME ordinal data type is not stackable
  16304. if (stack) {
  16305. var dimensionInfo = this._dimensionInfos[dim];
  16306. if (dimensionInfo && dimensionInfo.stackable) {
  16307. var stackedOn = this.stackedOn;
  16308. while (stackedOn) {
  16309. // Get no stacked data of stacked on
  16310. var stackedValue = stackedOn.get(dim, idx);
  16311. // Considering positive stack, negative stack and empty data
  16312. if ((value >= 0 && stackedValue > 0) // Positive stack
  16313. || (value <= 0 && stackedValue < 0) // Negative stack
  16314. ) {
  16315. value += stackedValue;
  16316. }
  16317. stackedOn = stackedOn.stackedOn;
  16318. }
  16319. }
  16320. }
  16321. return value;
  16322. };
  16323. /**
  16324. * Get value for multi dimensions.
  16325. * @param {Array.<string>} [dimensions] If ignored, using all dimensions.
  16326. * @param {number} idx
  16327. * @param {boolean} stack
  16328. * @return {number}
  16329. */
  16330. listProto.getValues = function (dimensions, idx, stack) {
  16331. var values = [];
  16332. if (!zrUtil.isArray(dimensions)) {
  16333. stack = idx;
  16334. idx = dimensions;
  16335. dimensions = this.dimensions;
  16336. }
  16337. for (var i = 0, len = dimensions.length; i < len; i++) {
  16338. values.push(this.get(dimensions[i], idx, stack));
  16339. }
  16340. return values;
  16341. };
  16342. /**
  16343. * If value is NaN. Inlcuding '-'
  16344. * @param {string} dim
  16345. * @param {number} idx
  16346. * @return {number}
  16347. */
  16348. listProto.hasValue = function (idx) {
  16349. var dimensions = this.dimensions;
  16350. var dimensionInfos = this._dimensionInfos;
  16351. for (var i = 0, len = dimensions.length; i < len; i++) {
  16352. if (
  16353. // Ordinal type can be string or number
  16354. dimensionInfos[dimensions[i]].type !== 'ordinal'
  16355. && isNaN(this.get(dimensions[i], idx))
  16356. ) {
  16357. return false;
  16358. }
  16359. }
  16360. return true;
  16361. };
  16362. /**
  16363. * Get extent of data in one dimension
  16364. * @param {string} dim
  16365. * @param {boolean} stack
  16366. */
  16367. listProto.getDataExtent = function (dim, stack) {
  16368. var dimData = this._storage[dim];
  16369. var dimInfo = this.getDimensionInfo(dim);
  16370. stack = (dimInfo && dimInfo.stackable) && stack;
  16371. var dimExtent = (this._extent || (this._extent = {}))[dim + (!!stack)];
  16372. var value;
  16373. if (dimExtent) {
  16374. return dimExtent;
  16375. }
  16376. // var dimInfo = this._dimensionInfos[dim];
  16377. if (dimData) {
  16378. var min = Infinity;
  16379. var max = -Infinity;
  16380. // var isOrdinal = dimInfo.type === 'ordinal';
  16381. for (var i = 0, len = this.count(); i < len; i++) {
  16382. value = this.get(dim, i, stack);
  16383. // FIXME
  16384. // if (isOrdinal && typeof value === 'string') {
  16385. // value = zrUtil.indexOf(dimData, value);
  16386. // }
  16387. value < min && (min = value);
  16388. value > max && (max = value);
  16389. }
  16390. return (this._extent[dim + stack] = [min, max]);
  16391. }
  16392. else {
  16393. return [Infinity, -Infinity];
  16394. }
  16395. };
  16396. /**
  16397. * Get sum of data in one dimension
  16398. * @param {string} dim
  16399. * @param {boolean} stack
  16400. */
  16401. listProto.getSum = function (dim, stack) {
  16402. var dimData = this._storage[dim];
  16403. var sum = 0;
  16404. if (dimData) {
  16405. for (var i = 0, len = this.count(); i < len; i++) {
  16406. var value = this.get(dim, i, stack);
  16407. if (!isNaN(value)) {
  16408. sum += value;
  16409. }
  16410. }
  16411. }
  16412. return sum;
  16413. };
  16414. /**
  16415. * Retreive the index with given value
  16416. * @param {number} idx
  16417. * @param {number} value
  16418. * @return {number}
  16419. */
  16420. // FIXME Precision of float value
  16421. listProto.indexOf = function (dim, value) {
  16422. var storage = this._storage;
  16423. var dimData = storage[dim];
  16424. var indices = this.indices;
  16425. if (dimData) {
  16426. for (var i = 0, len = indices.length; i < len; i++) {
  16427. var rawIndex = indices[i];
  16428. if (dimData[rawIndex] === value) {
  16429. return i;
  16430. }
  16431. }
  16432. }
  16433. return -1;
  16434. };
  16435. /**
  16436. * Retreive the index with given name
  16437. * @param {number} idx
  16438. * @param {number} name
  16439. * @return {number}
  16440. */
  16441. listProto.indexOfName = function (name) {
  16442. var indices = this.indices;
  16443. var nameList = this._nameList;
  16444. for (var i = 0, len = indices.length; i < len; i++) {
  16445. var rawIndex = indices[i];
  16446. if (nameList[rawIndex] === name) {
  16447. return i;
  16448. }
  16449. }
  16450. return -1;
  16451. };
  16452. /**
  16453. * Retreive the index of nearest value
  16454. * @param {string} dim
  16455. * @param {number} value
  16456. * @param {boolean} stack If given value is after stacked
  16457. * @return {number}
  16458. */
  16459. listProto.indexOfNearest = function (dim, value, stack) {
  16460. var storage = this._storage;
  16461. var dimData = storage[dim];
  16462. if (dimData) {
  16463. var minDist = Number.MAX_VALUE;
  16464. var nearestIdx = -1;
  16465. for (var i = 0, len = this.count(); i < len; i++) {
  16466. var diff = value - this.get(dim, i, stack);
  16467. var dist = Math.abs(diff);
  16468. if (dist < minDist
  16469. // For the case of two data are same on xAxis, which has sequence data.
  16470. // Show the nearest index
  16471. // https://github.com/ecomfe/echarts/issues/2869
  16472. || (dist === minDist && diff > 0)
  16473. ) {
  16474. minDist = dist;
  16475. nearestIdx = i;
  16476. }
  16477. }
  16478. return nearestIdx;
  16479. }
  16480. return -1;
  16481. };
  16482. /**
  16483. * Get raw data index
  16484. * @param {number} idx
  16485. * @return {number}
  16486. */
  16487. listProto.getRawIndex = function (idx) {
  16488. var rawIdx = this.indices[idx];
  16489. return rawIdx == null ? -1 : rawIdx;
  16490. };
  16491. /**
  16492. * Get raw data item
  16493. * @param {number} idx
  16494. * @return {number}
  16495. */
  16496. listProto.getRawDataItem = function (idx) {
  16497. return this._rawData[this.getRawIndex(idx)];
  16498. };
  16499. /**
  16500. * @param {number} idx
  16501. * @param {boolean} [notDefaultIdx=false]
  16502. * @return {string}
  16503. */
  16504. listProto.getName = function (idx) {
  16505. return this._nameList[this.indices[idx]] || '';
  16506. };
  16507. /**
  16508. * @param {number} idx
  16509. * @param {boolean} [notDefaultIdx=false]
  16510. * @return {string}
  16511. */
  16512. listProto.getId = function (idx) {
  16513. return this._idList[this.indices[idx]] || (this.getRawIndex(idx) + '');
  16514. };
  16515. function normalizeDimensions(dimensions) {
  16516. if (!zrUtil.isArray(dimensions)) {
  16517. dimensions = [dimensions];
  16518. }
  16519. return dimensions;
  16520. }
  16521. /**
  16522. * Data iteration
  16523. * @param {string|Array.<string>}
  16524. * @param {Function} cb
  16525. * @param {boolean} [stack=false]
  16526. * @param {*} [context=this]
  16527. *
  16528. * @example
  16529. * list.each('x', function (x, idx) {});
  16530. * list.each(['x', 'y'], function (x, y, idx) {});
  16531. * list.each(function (idx) {})
  16532. */
  16533. listProto.each = function (dimensions, cb, stack, context) {
  16534. if (typeof dimensions === 'function') {
  16535. context = stack;
  16536. stack = cb;
  16537. cb = dimensions;
  16538. dimensions = [];
  16539. }
  16540. dimensions = zrUtil.map(
  16541. normalizeDimensions(dimensions), this.getDimension, this
  16542. );
  16543. var value = [];
  16544. var dimSize = dimensions.length;
  16545. var indices = this.indices;
  16546. context = context || this;
  16547. for (var i = 0; i < indices.length; i++) {
  16548. if (dimSize === 0) {
  16549. cb.call(context, i);
  16550. }
  16551. // Simple optimization
  16552. else if (dimSize === 1) {
  16553. cb.call(context, this.get(dimensions[0], i, stack), i);
  16554. }
  16555. else {
  16556. for (var k = 0; k < dimSize; k++) {
  16557. value[k] = this.get(dimensions[k], i, stack);
  16558. }
  16559. // Index
  16560. value[k] = i;
  16561. cb.apply(context, value);
  16562. }
  16563. }
  16564. };
  16565. /**
  16566. * Data filter
  16567. * @param {string|Array.<string>}
  16568. * @param {Function} cb
  16569. * @param {boolean} [stack=false]
  16570. * @param {*} [context=this]
  16571. */
  16572. listProto.filterSelf = function (dimensions, cb, stack, context) {
  16573. if (typeof dimensions === 'function') {
  16574. context = stack;
  16575. stack = cb;
  16576. cb = dimensions;
  16577. dimensions = [];
  16578. }
  16579. dimensions = zrUtil.map(
  16580. normalizeDimensions(dimensions), this.getDimension, this
  16581. );
  16582. var newIndices = [];
  16583. var value = [];
  16584. var dimSize = dimensions.length;
  16585. var indices = this.indices;
  16586. context = context || this;
  16587. for (var i = 0; i < indices.length; i++) {
  16588. var keep;
  16589. // Simple optimization
  16590. if (dimSize === 1) {
  16591. keep = cb.call(
  16592. context, this.get(dimensions[0], i, stack), i
  16593. );
  16594. }
  16595. else {
  16596. for (var k = 0; k < dimSize; k++) {
  16597. value[k] = this.get(dimensions[k], i, stack);
  16598. }
  16599. value[k] = i;
  16600. keep = cb.apply(context, value);
  16601. }
  16602. if (keep) {
  16603. newIndices.push(indices[i]);
  16604. }
  16605. }
  16606. this.indices = newIndices;
  16607. // Reset data extent
  16608. this._extent = {};
  16609. return this;
  16610. };
  16611. /**
  16612. * Data mapping to a plain array
  16613. * @param {string|Array.<string>} [dimensions]
  16614. * @param {Function} cb
  16615. * @param {boolean} [stack=false]
  16616. * @param {*} [context=this]
  16617. * @return {Array}
  16618. */
  16619. listProto.mapArray = function (dimensions, cb, stack, context) {
  16620. if (typeof dimensions === 'function') {
  16621. context = stack;
  16622. stack = cb;
  16623. cb = dimensions;
  16624. dimensions = [];
  16625. }
  16626. var result = [];
  16627. this.each(dimensions, function () {
  16628. result.push(cb && cb.apply(this, arguments));
  16629. }, stack, context);
  16630. return result;
  16631. };
  16632. function cloneListForMapAndSample(original, excludeDimensions) {
  16633. var allDimensions = original.dimensions;
  16634. var list = new List(
  16635. zrUtil.map(allDimensions, original.getDimensionInfo, original),
  16636. original.hostModel
  16637. );
  16638. // FIXME If needs stackedOn, value may already been stacked
  16639. transferImmuProperties(list, original);
  16640. var storage = list._storage = {};
  16641. var originalStorage = original._storage;
  16642. // Init storage
  16643. for (var i = 0; i < allDimensions.length; i++) {
  16644. var dim = allDimensions[i];
  16645. var dimStore = originalStorage[dim];
  16646. if (zrUtil.indexOf(excludeDimensions, dim) >= 0) {
  16647. storage[dim] = new dimStore.constructor(
  16648. originalStorage[dim].length
  16649. );
  16650. }
  16651. else {
  16652. // Direct reference for other dimensions
  16653. storage[dim] = originalStorage[dim];
  16654. }
  16655. }
  16656. return list;
  16657. }
  16658. /**
  16659. * Data mapping to a new List with given dimensions
  16660. * @param {string|Array.<string>} dimensions
  16661. * @param {Function} cb
  16662. * @param {boolean} [stack=false]
  16663. * @param {*} [context=this]
  16664. * @return {Array}
  16665. */
  16666. listProto.map = function (dimensions, cb, stack, context) {
  16667. dimensions = zrUtil.map(
  16668. normalizeDimensions(dimensions), this.getDimension, this
  16669. );
  16670. var list = cloneListForMapAndSample(this, dimensions);
  16671. // Following properties are all immutable.
  16672. // So we can reference to the same value
  16673. var indices = list.indices = this.indices;
  16674. var storage = list._storage;
  16675. var tmpRetValue = [];
  16676. this.each(dimensions, function () {
  16677. var idx = arguments[arguments.length - 1];
  16678. var retValue = cb && cb.apply(this, arguments);
  16679. if (retValue != null) {
  16680. // a number
  16681. if (typeof retValue === 'number') {
  16682. tmpRetValue[0] = retValue;
  16683. retValue = tmpRetValue;
  16684. }
  16685. for (var i = 0; i < retValue.length; i++) {
  16686. var dim = dimensions[i];
  16687. var dimStore = storage[dim];
  16688. var rawIdx = indices[idx];
  16689. if (dimStore) {
  16690. dimStore[rawIdx] = retValue[i];
  16691. }
  16692. }
  16693. }
  16694. }, stack, context);
  16695. return list;
  16696. };
  16697. /**
  16698. * Large data down sampling on given dimension
  16699. * @param {string} dimension
  16700. * @param {number} rate
  16701. * @param {Function} sampleValue
  16702. * @param {Function} sampleIndex Sample index for name and id
  16703. */
  16704. listProto.downSample = function (dimension, rate, sampleValue, sampleIndex) {
  16705. var list = cloneListForMapAndSample(this, [dimension]);
  16706. var storage = this._storage;
  16707. var targetStorage = list._storage;
  16708. var originalIndices = this.indices;
  16709. var indices = list.indices = [];
  16710. var frameValues = [];
  16711. var frameIndices = [];
  16712. var frameSize = Math.floor(1 / rate);
  16713. var dimStore = targetStorage[dimension];
  16714. var len = this.count();
  16715. // Copy data from original data
  16716. for (var i = 0; i < storage[dimension].length; i++) {
  16717. targetStorage[dimension][i] = storage[dimension][i];
  16718. }
  16719. for (var i = 0; i < len; i += frameSize) {
  16720. // Last frame
  16721. if (frameSize > len - i) {
  16722. frameSize = len - i;
  16723. frameValues.length = frameSize;
  16724. }
  16725. for (var k = 0; k < frameSize; k++) {
  16726. var idx = originalIndices[i + k];
  16727. frameValues[k] = dimStore[idx];
  16728. frameIndices[k] = idx;
  16729. }
  16730. var value = sampleValue(frameValues);
  16731. var idx = frameIndices[sampleIndex(frameValues, value) || 0];
  16732. // Only write value on the filtered data
  16733. dimStore[idx] = value;
  16734. indices.push(idx);
  16735. }
  16736. return list;
  16737. };
  16738. /**
  16739. * Get model of one data item.
  16740. *
  16741. * @param {number} idx
  16742. */
  16743. // FIXME Model proxy ?
  16744. listProto.getItemModel = function (idx) {
  16745. var hostModel = this.hostModel;
  16746. idx = this.indices[idx];
  16747. return new Model(this._rawData[idx], hostModel, hostModel && hostModel.ecModel);
  16748. };
  16749. /**
  16750. * Create a data differ
  16751. * @param {module:echarts/data/List} otherList
  16752. * @return {module:echarts/data/DataDiffer}
  16753. */
  16754. listProto.diff = function (otherList) {
  16755. var idList = this._idList;
  16756. var otherIdList = otherList && otherList._idList;
  16757. return new DataDiffer(
  16758. otherList ? otherList.indices : [], this.indices, function (idx) {
  16759. return otherIdList[idx] || (idx + '');
  16760. }, function (idx) {
  16761. return idList[idx] || (idx + '');
  16762. }
  16763. );
  16764. };
  16765. /**
  16766. * Get visual property.
  16767. * @param {string} key
  16768. */
  16769. listProto.getVisual = function (key) {
  16770. var visual = this._visual;
  16771. return visual && visual[key];
  16772. };
  16773. /**
  16774. * Set visual property
  16775. * @param {string|Object} key
  16776. * @param {*} [value]
  16777. *
  16778. * @example
  16779. * setVisual('color', color);
  16780. * setVisual({
  16781. * 'color': color
  16782. * });
  16783. */
  16784. listProto.setVisual = function (key, val) {
  16785. if (isObject(key)) {
  16786. for (var name in key) {
  16787. if (key.hasOwnProperty(name)) {
  16788. this.setVisual(name, key[name]);
  16789. }
  16790. }
  16791. return;
  16792. }
  16793. this._visual = this._visual || {};
  16794. this._visual[key] = val;
  16795. };
  16796. /**
  16797. * Set layout property.
  16798. * @param {string} key
  16799. * @param {*} [val]
  16800. */
  16801. listProto.setLayout = function (key, val) {
  16802. if (isObject(key)) {
  16803. for (var name in key) {
  16804. if (key.hasOwnProperty(name)) {
  16805. this.setLayout(name, key[name]);
  16806. }
  16807. }
  16808. return;
  16809. }
  16810. this._layout[key] = val;
  16811. };
  16812. /**
  16813. * Get layout property.
  16814. * @param {string} key.
  16815. * @return {*}
  16816. */
  16817. listProto.getLayout = function (key) {
  16818. return this._layout[key];
  16819. };
  16820. /**
  16821. * Get layout of single data item
  16822. * @param {number} idx
  16823. */
  16824. listProto.getItemLayout = function (idx) {
  16825. return this._itemLayouts[idx];
  16826. };
  16827. /**
  16828. * Set layout of single data item
  16829. * @param {number} idx
  16830. * @param {Object} layout
  16831. * @param {boolean=} [merge=false]
  16832. */
  16833. listProto.setItemLayout = function (idx, layout, merge) {
  16834. this._itemLayouts[idx] = merge
  16835. ? zrUtil.extend(this._itemLayouts[idx] || {}, layout)
  16836. : layout;
  16837. };
  16838. /**
  16839. * Clear all layout of single data item
  16840. */
  16841. listProto.clearItemLayouts = function () {
  16842. this._itemLayouts.length = 0;
  16843. };
  16844. /**
  16845. * Get visual property of single data item
  16846. * @param {number} idx
  16847. * @param {string} key
  16848. * @param {boolean} ignoreParent
  16849. */
  16850. listProto.getItemVisual = function (idx, key, ignoreParent) {
  16851. var itemVisual = this._itemVisuals[idx];
  16852. var val = itemVisual && itemVisual[key];
  16853. if (val == null && !ignoreParent) {
  16854. // Use global visual property
  16855. return this.getVisual(key);
  16856. }
  16857. return val;
  16858. };
  16859. /**
  16860. * Set visual property of single data item
  16861. *
  16862. * @param {number} idx
  16863. * @param {string|Object} key
  16864. * @param {*} [value]
  16865. *
  16866. * @example
  16867. * setItemVisual(0, 'color', color);
  16868. * setItemVisual(0, {
  16869. * 'color': color
  16870. * });
  16871. */
  16872. listProto.setItemVisual = function (idx, key, value) {
  16873. var itemVisual = this._itemVisuals[idx] || {};
  16874. this._itemVisuals[idx] = itemVisual;
  16875. if (isObject(key)) {
  16876. for (var name in key) {
  16877. if (key.hasOwnProperty(name)) {
  16878. itemVisual[name] = key[name];
  16879. }
  16880. }
  16881. return;
  16882. }
  16883. itemVisual[key] = value;
  16884. };
  16885. var setItemDataAndSeriesIndex = function (child) {
  16886. child.seriesIndex = this.seriesIndex;
  16887. child.dataIndex = this.dataIndex;
  16888. child.dataType = this.dataType;
  16889. };
  16890. /**
  16891. * Set graphic element relative to data. It can be set as null
  16892. * @param {number} idx
  16893. * @param {module:zrender/Element} [el]
  16894. */
  16895. listProto.setItemGraphicEl = function (idx, el) {
  16896. var hostModel = this.hostModel;
  16897. if (el) {
  16898. // Add data index and series index for indexing the data by element
  16899. // Useful in tooltip
  16900. el.dataIndex = idx;
  16901. el.dataType = this.dataType;
  16902. el.seriesIndex = hostModel && hostModel.seriesIndex;
  16903. if (el.type === 'group') {
  16904. el.traverse(setItemDataAndSeriesIndex, el);
  16905. }
  16906. }
  16907. this._graphicEls[idx] = el;
  16908. };
  16909. /**
  16910. * @param {number} idx
  16911. * @return {module:zrender/Element}
  16912. */
  16913. listProto.getItemGraphicEl = function (idx) {
  16914. return this._graphicEls[idx];
  16915. };
  16916. /**
  16917. * @param {Function} cb
  16918. * @param {*} context
  16919. */
  16920. listProto.eachItemGraphicEl = function (cb, context) {
  16921. zrUtil.each(this._graphicEls, function (el, idx) {
  16922. if (el) {
  16923. cb && cb.call(context, el, idx);
  16924. }
  16925. });
  16926. };
  16927. /**
  16928. * Shallow clone a new list except visual and layout properties, and graph elements.
  16929. * New list only change the indices.
  16930. */
  16931. listProto.cloneShallow = function () {
  16932. var dimensionInfoList = zrUtil.map(this.dimensions, this.getDimensionInfo, this);
  16933. var list = new List(dimensionInfoList, this.hostModel);
  16934. // FIXME
  16935. list._storage = this._storage;
  16936. transferImmuProperties(list, this);
  16937. list.indices = this.indices.slice();
  16938. return list;
  16939. };
  16940. /**
  16941. * Wrap some method to add more feature
  16942. * @param {string} methodName
  16943. * @param {Function} injectFunction
  16944. */
  16945. listProto.wrapMethod = function (methodName, injectFunction) {
  16946. var originalMethod = this[methodName];
  16947. if (typeof originalMethod !== 'function') {
  16948. return;
  16949. }
  16950. this.__wrappedMethods = this.__wrappedMethods || [];
  16951. this.__wrappedMethods.push(methodName);
  16952. this[methodName] = function () {
  16953. var res = originalMethod.apply(this, arguments);
  16954. return injectFunction.apply(this, [res].concat(zrUtil.slice(arguments)));
  16955. };
  16956. };
  16957. // Methods that create a new list based on this list should be listed here.
  16958. // Notice that those method should `RETURN` the new list.
  16959. listProto.TRANSFERABLE_METHODS = ['cloneShallow', 'downSample', 'map'];
  16960. // Methods that change indices of this list should be listed here.
  16961. listProto.CHANGABLE_METHODS = ['filterSelf'];
  16962. module.exports = List;
  16963. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  16964. /***/ },
  16965. /* 96 */
  16966. /***/ function(module, exports) {
  16967. 'use strict';
  16968. function defaultKeyGetter(item) {
  16969. return item;
  16970. }
  16971. function DataDiffer(oldArr, newArr, oldKeyGetter, newKeyGetter) {
  16972. this._old = oldArr;
  16973. this._new = newArr;
  16974. this._oldKeyGetter = oldKeyGetter || defaultKeyGetter;
  16975. this._newKeyGetter = newKeyGetter || defaultKeyGetter;
  16976. }
  16977. DataDiffer.prototype = {
  16978. constructor: DataDiffer,
  16979. /**
  16980. * Callback function when add a data
  16981. */
  16982. add: function (func) {
  16983. this._add = func;
  16984. return this;
  16985. },
  16986. /**
  16987. * Callback function when update a data
  16988. */
  16989. update: function (func) {
  16990. this._update = func;
  16991. return this;
  16992. },
  16993. /**
  16994. * Callback function when remove a data
  16995. */
  16996. remove: function (func) {
  16997. this._remove = func;
  16998. return this;
  16999. },
  17000. execute: function () {
  17001. var oldArr = this._old;
  17002. var newArr = this._new;
  17003. var oldKeyGetter = this._oldKeyGetter;
  17004. var newKeyGetter = this._newKeyGetter;
  17005. var oldDataIndexMap = {};
  17006. var newDataIndexMap = {};
  17007. var i;
  17008. initIndexMap(oldArr, oldDataIndexMap, oldKeyGetter);
  17009. initIndexMap(newArr, newDataIndexMap, newKeyGetter);
  17010. // Travel by inverted order to make sure order consistency
  17011. // when duplicate keys exists (consider newDataIndex.pop() below).
  17012. // For performance consideration, these code below do not look neat.
  17013. for (i = 0; i < oldArr.length; i++) {
  17014. var key = oldKeyGetter(oldArr[i]);
  17015. var idx = newDataIndexMap[key];
  17016. // idx can never be empty array here. see 'set null' logic below.
  17017. if (idx != null) {
  17018. // Consider there is duplicate key (for example, use dataItem.name as key).
  17019. // We should make sure every item in newArr and oldArr can be visited.
  17020. var len = idx.length;
  17021. if (len) {
  17022. len === 1 && (newDataIndexMap[key] = null);
  17023. idx = idx.unshift();
  17024. }
  17025. else {
  17026. newDataIndexMap[key] = null;
  17027. }
  17028. this._update && this._update(idx, i);
  17029. }
  17030. else {
  17031. this._remove && this._remove(i);
  17032. }
  17033. }
  17034. for (var key in newDataIndexMap) {
  17035. if (newDataIndexMap.hasOwnProperty(key)) {
  17036. var idx = newDataIndexMap[key];
  17037. if (idx == null) {
  17038. continue;
  17039. }
  17040. // idx can never be empty array here. see 'set null' logic above.
  17041. if (!idx.length) {
  17042. this._add && this._add(idx);
  17043. }
  17044. else {
  17045. for (var i = 0, len = idx.length; i < len; i++) {
  17046. this._add && this._add(idx[i]);
  17047. }
  17048. }
  17049. }
  17050. }
  17051. }
  17052. };
  17053. function initIndexMap(arr, map, keyGetter) {
  17054. for (var i = 0; i < arr.length; i++) {
  17055. var key = keyGetter(arr[i]);
  17056. var existence = map[key];
  17057. if (existence == null) {
  17058. map[key] = i;
  17059. }
  17060. else {
  17061. if (!existence.length) {
  17062. map[key] = existence = [existence];
  17063. }
  17064. existence.push(i);
  17065. }
  17066. }
  17067. }
  17068. module.exports = DataDiffer;
  17069. /***/ },
  17070. /* 97 */
  17071. /***/ function(module, exports, __webpack_require__) {
  17072. /**
  17073. * Complete dimensions by data (guess dimension).
  17074. */
  17075. var zrUtil = __webpack_require__(3);
  17076. /**
  17077. * Complete the dimensions array guessed from the data structure.
  17078. * @param {Array.<string>} dimensions Necessary dimensions, like ['x', 'y']
  17079. * @param {Array} data Data list. [[1, 2, 3], [2, 3, 4]]
  17080. * @param {Array.<string>} defaultNames Default names to fill not necessary dimensions, like ['value']
  17081. * @param {string} extraPrefix Prefix of name when filling the left dimensions.
  17082. * @return {Array.<string>}
  17083. */
  17084. function completeDimensions(dimensions, data, defaultNames, extraPrefix) {
  17085. if (!data) {
  17086. return dimensions;
  17087. }
  17088. var value0 = retrieveValue(data[0]);
  17089. var dimSize = zrUtil.isArray(value0) && value0.length || 1;
  17090. defaultNames = defaultNames || [];
  17091. extraPrefix = extraPrefix || 'extra';
  17092. for (var i = 0; i < dimSize; i++) {
  17093. if (!dimensions[i]) {
  17094. var name = defaultNames[i] || (extraPrefix + (i - defaultNames.length));
  17095. dimensions[i] = guessOrdinal(data, i)
  17096. ? {type: 'ordinal', name: name}
  17097. : name;
  17098. }
  17099. }
  17100. return dimensions;
  17101. }
  17102. // The rule should not be complex, otherwise user might not
  17103. // be able to known where the data is wrong.
  17104. function guessOrdinal(data, dimIndex) {
  17105. for (var i = 0, len = data.length; i < len; i++) {
  17106. var value = retrieveValue(data[i]);
  17107. if (!zrUtil.isArray(value)) {
  17108. return false;
  17109. }
  17110. var value = value[dimIndex];
  17111. if (value != null && isFinite(value)) {
  17112. return false;
  17113. }
  17114. else if (zrUtil.isString(value) && value !== '-') {
  17115. return true;
  17116. }
  17117. }
  17118. return false;
  17119. }
  17120. function retrieveValue(o) {
  17121. return zrUtil.isArray(o) ? o : zrUtil.isObject(o) ? o.value: o;
  17122. }
  17123. module.exports = completeDimensions;
  17124. /***/ },
  17125. /* 98 */
  17126. /***/ function(module, exports, __webpack_require__) {
  17127. 'use strict';
  17128. var zrUtil = __webpack_require__(3);
  17129. var SymbolDraw = __webpack_require__(99);
  17130. var Symbol = __webpack_require__(100);
  17131. var lineAnimationDiff = __webpack_require__(102);
  17132. var graphic = __webpack_require__(42);
  17133. var polyHelper = __webpack_require__(103);
  17134. var ChartView = __webpack_require__(41);
  17135. function isPointsSame(points1, points2) {
  17136. if (points1.length !== points2.length) {
  17137. return;
  17138. }
  17139. for (var i = 0; i < points1.length; i++) {
  17140. var p1 = points1[i];
  17141. var p2 = points2[i];
  17142. if (p1[0] !== p2[0] || p1[1] !== p2[1]) {
  17143. return;
  17144. }
  17145. }
  17146. return true;
  17147. }
  17148. function getSmooth(smooth) {
  17149. return typeof (smooth) === 'number' ? smooth : (smooth ? 0.3 : 0);
  17150. }
  17151. function getAxisExtentWithGap(axis) {
  17152. var extent = axis.getGlobalExtent();
  17153. if (axis.onBand) {
  17154. // Remove extra 1px to avoid line miter in clipped edge
  17155. var halfBandWidth = axis.getBandWidth() / 2 - 1;
  17156. var dir = extent[1] > extent[0] ? 1 : -1;
  17157. extent[0] += dir * halfBandWidth;
  17158. extent[1] -= dir * halfBandWidth;
  17159. }
  17160. return extent;
  17161. }
  17162. function sign(val) {
  17163. return val >= 0 ? 1 : -1;
  17164. }
  17165. /**
  17166. * @param {module:echarts/coord/cartesian/Cartesian2D|module:echarts/coord/polar/Polar} coordSys
  17167. * @param {module:echarts/data/List} data
  17168. * @param {Array.<Array.<number>>} points
  17169. * @private
  17170. */
  17171. function getStackedOnPoints(coordSys, data) {
  17172. var baseAxis = coordSys.getBaseAxis();
  17173. var valueAxis = coordSys.getOtherAxis(baseAxis);
  17174. var valueStart = baseAxis.onZero
  17175. ? 0 : valueAxis.scale.getExtent()[0];
  17176. var valueDim = valueAxis.dim;
  17177. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  17178. return data.mapArray([valueDim], function (val, idx) {
  17179. var stackedOnSameSign;
  17180. var stackedOn = data.stackedOn;
  17181. // Find first stacked value with same sign
  17182. while (stackedOn &&
  17183. sign(stackedOn.get(valueDim, idx)) === sign(val)
  17184. ) {
  17185. stackedOnSameSign = stackedOn;
  17186. break;
  17187. }
  17188. var stackedData = [];
  17189. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  17190. stackedData[1 - baseDataOffset] = stackedOnSameSign
  17191. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  17192. return coordSys.dataToPoint(stackedData);
  17193. }, true);
  17194. }
  17195. function queryDataIndex(data, payload) {
  17196. if (payload.dataIndex != null) {
  17197. return payload.dataIndex;
  17198. }
  17199. else if (payload.name != null) {
  17200. return data.indexOfName(payload.name);
  17201. }
  17202. }
  17203. function createGridClipShape(cartesian, hasAnimation, seriesModel) {
  17204. var xExtent = getAxisExtentWithGap(cartesian.getAxis('x'));
  17205. var yExtent = getAxisExtentWithGap(cartesian.getAxis('y'));
  17206. var isHorizontal = cartesian.getBaseAxis().isHorizontal();
  17207. var x = Math.min(xExtent[0], xExtent[1]);
  17208. var y = Math.min(yExtent[0], yExtent[1]);
  17209. var width = Math.max(xExtent[0], xExtent[1]) - x;
  17210. var height = Math.max(yExtent[0], yExtent[1]) - y;
  17211. var lineWidth = seriesModel.get('lineStyle.normal.width') || 2;
  17212. // Expand clip shape to avoid clipping when line value exceeds axis
  17213. var expandSize = seriesModel.get('clipOverflow') ? lineWidth / 2 : Math.max(width, height);
  17214. if (isHorizontal) {
  17215. y -= expandSize;
  17216. height += expandSize * 2;
  17217. }
  17218. else {
  17219. x -= expandSize;
  17220. width += expandSize * 2;
  17221. }
  17222. var clipPath = new graphic.Rect({
  17223. shape: {
  17224. x: x,
  17225. y: y,
  17226. width: width,
  17227. height: height
  17228. }
  17229. });
  17230. if (hasAnimation) {
  17231. clipPath.shape[isHorizontal ? 'width' : 'height'] = 0;
  17232. graphic.initProps(clipPath, {
  17233. shape: {
  17234. width: width,
  17235. height: height
  17236. }
  17237. }, seriesModel);
  17238. }
  17239. return clipPath;
  17240. }
  17241. function createPolarClipShape(polar, hasAnimation, seriesModel) {
  17242. var angleAxis = polar.getAngleAxis();
  17243. var radiusAxis = polar.getRadiusAxis();
  17244. var radiusExtent = radiusAxis.getExtent();
  17245. var angleExtent = angleAxis.getExtent();
  17246. var RADIAN = Math.PI / 180;
  17247. var clipPath = new graphic.Sector({
  17248. shape: {
  17249. cx: polar.cx,
  17250. cy: polar.cy,
  17251. r0: radiusExtent[0],
  17252. r: radiusExtent[1],
  17253. startAngle: -angleExtent[0] * RADIAN,
  17254. endAngle: -angleExtent[1] * RADIAN,
  17255. clockwise: angleAxis.inverse
  17256. }
  17257. });
  17258. if (hasAnimation) {
  17259. clipPath.shape.endAngle = -angleExtent[0] * RADIAN;
  17260. graphic.initProps(clipPath, {
  17261. shape: {
  17262. endAngle: -angleExtent[1] * RADIAN
  17263. }
  17264. }, seriesModel);
  17265. }
  17266. return clipPath;
  17267. }
  17268. function createClipShape(coordSys, hasAnimation, seriesModel) {
  17269. return coordSys.type === 'polar'
  17270. ? createPolarClipShape(coordSys, hasAnimation, seriesModel)
  17271. : createGridClipShape(coordSys, hasAnimation, seriesModel);
  17272. }
  17273. module.exports = ChartView.extend({
  17274. type: 'line',
  17275. init: function () {
  17276. var lineGroup = new graphic.Group();
  17277. var symbolDraw = new SymbolDraw();
  17278. this.group.add(symbolDraw.group);
  17279. this._symbolDraw = symbolDraw;
  17280. this._lineGroup = lineGroup;
  17281. },
  17282. render: function (seriesModel, ecModel, api) {
  17283. var coordSys = seriesModel.coordinateSystem;
  17284. var group = this.group;
  17285. var data = seriesModel.getData();
  17286. var lineStyleModel = seriesModel.getModel('lineStyle.normal');
  17287. var areaStyleModel = seriesModel.getModel('areaStyle.normal');
  17288. var points = data.mapArray(data.getItemLayout, true);
  17289. var isCoordSysPolar = coordSys.type === 'polar';
  17290. var prevCoordSys = this._coordSys;
  17291. var symbolDraw = this._symbolDraw;
  17292. var polyline = this._polyline;
  17293. var polygon = this._polygon;
  17294. var lineGroup = this._lineGroup;
  17295. var hasAnimation = seriesModel.get('animation');
  17296. var isAreaChart = !areaStyleModel.isEmpty();
  17297. var stackedOnPoints = getStackedOnPoints(coordSys, data);
  17298. var showSymbol = seriesModel.get('showSymbol');
  17299. var isSymbolIgnore = showSymbol && !isCoordSysPolar && !seriesModel.get('showAllSymbol')
  17300. && this._getSymbolIgnoreFunc(data, coordSys);
  17301. // Remove temporary symbols
  17302. var oldData = this._data;
  17303. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  17304. if (el.__temp) {
  17305. group.remove(el);
  17306. oldData.setItemGraphicEl(idx, null);
  17307. }
  17308. });
  17309. // Remove previous created symbols if showSymbol changed to false
  17310. if (!showSymbol) {
  17311. symbolDraw.remove();
  17312. }
  17313. group.add(lineGroup);
  17314. // Initialization animation or coordinate system changed
  17315. if (
  17316. !(polyline && prevCoordSys.type === coordSys.type)
  17317. ) {
  17318. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  17319. polyline = this._newPolyline(points, coordSys, hasAnimation);
  17320. if (isAreaChart) {
  17321. polygon = this._newPolygon(
  17322. points, stackedOnPoints,
  17323. coordSys, hasAnimation
  17324. );
  17325. }
  17326. lineGroup.setClipPath(createClipShape(coordSys, true, seriesModel));
  17327. }
  17328. else {
  17329. if (isAreaChart && !polygon) {
  17330. // If areaStyle is added
  17331. polygon = this._newPolygon(
  17332. points, stackedOnPoints,
  17333. coordSys, hasAnimation
  17334. );
  17335. }
  17336. else if (polygon && !isAreaChart) {
  17337. // If areaStyle is removed
  17338. lineGroup.remove(polygon);
  17339. polygon = this._polygon = null;
  17340. }
  17341. // Update clipPath
  17342. lineGroup.setClipPath(createClipShape(coordSys, false, seriesModel));
  17343. // Always update, or it is wrong in the case turning on legend
  17344. // because points are not changed
  17345. showSymbol && symbolDraw.updateData(data, isSymbolIgnore);
  17346. // Stop symbol animation and sync with line points
  17347. // FIXME performance?
  17348. data.eachItemGraphicEl(function (el) {
  17349. el.stopAnimation(true);
  17350. });
  17351. // In the case data zoom triggerred refreshing frequently
  17352. // Data may not change if line has a category axis. So it should animate nothing
  17353. if (!isPointsSame(this._stackedOnPoints, stackedOnPoints)
  17354. || !isPointsSame(this._points, points)
  17355. ) {
  17356. if (hasAnimation) {
  17357. this._updateAnimation(
  17358. data, stackedOnPoints, coordSys, api
  17359. );
  17360. }
  17361. else {
  17362. polyline.setShape({
  17363. points: points
  17364. });
  17365. polygon && polygon.setShape({
  17366. points: points,
  17367. stackedOnPoints: stackedOnPoints
  17368. });
  17369. }
  17370. }
  17371. }
  17372. polyline.useStyle(zrUtil.defaults(
  17373. // Use color in lineStyle first
  17374. lineStyleModel.getLineStyle(),
  17375. {
  17376. fill: 'none',
  17377. stroke: data.getVisual('color'),
  17378. lineJoin: 'bevel'
  17379. }
  17380. ));
  17381. var smooth = seriesModel.get('smooth');
  17382. smooth = getSmooth(seriesModel.get('smooth'));
  17383. polyline.setShape({
  17384. smooth: smooth,
  17385. smoothMonotone: seriesModel.get('smoothMonotone'),
  17386. connectNulls: seriesModel.get('connectNulls')
  17387. });
  17388. if (polygon) {
  17389. var stackedOn = data.stackedOn;
  17390. var stackedOnSmooth = 0;
  17391. polygon.useStyle(zrUtil.defaults(
  17392. areaStyleModel.getAreaStyle(),
  17393. {
  17394. fill: data.getVisual('color'),
  17395. opacity: 0.7,
  17396. lineJoin: 'bevel'
  17397. }
  17398. ));
  17399. if (stackedOn) {
  17400. var stackedOnSeries = stackedOn.hostModel;
  17401. stackedOnSmooth = getSmooth(stackedOnSeries.get('smooth'));
  17402. }
  17403. polygon.setShape({
  17404. smooth: smooth,
  17405. stackedOnSmooth: stackedOnSmooth,
  17406. smoothMonotone: seriesModel.get('smoothMonotone'),
  17407. connectNulls: seriesModel.get('connectNulls')
  17408. });
  17409. }
  17410. this._data = data;
  17411. // Save the coordinate system for transition animation when data changed
  17412. this._coordSys = coordSys;
  17413. this._stackedOnPoints = stackedOnPoints;
  17414. this._points = points;
  17415. },
  17416. highlight: function (seriesModel, ecModel, api, payload) {
  17417. var data = seriesModel.getData();
  17418. var dataIndex = queryDataIndex(data, payload);
  17419. if (dataIndex != null && dataIndex >= 0) {
  17420. var symbol = data.getItemGraphicEl(dataIndex);
  17421. if (!symbol) {
  17422. // Create a temporary symbol if it is not exists
  17423. var pt = data.getItemLayout(dataIndex);
  17424. symbol = new Symbol(data, dataIndex, api);
  17425. symbol.position = pt;
  17426. symbol.setZ(
  17427. seriesModel.get('zlevel'),
  17428. seriesModel.get('z')
  17429. );
  17430. symbol.ignore = isNaN(pt[0]) || isNaN(pt[1]);
  17431. symbol.__temp = true;
  17432. data.setItemGraphicEl(dataIndex, symbol);
  17433. // Stop scale animation
  17434. symbol.stopSymbolAnimation(true);
  17435. this.group.add(symbol);
  17436. }
  17437. symbol.highlight();
  17438. }
  17439. else {
  17440. // Highlight whole series
  17441. ChartView.prototype.highlight.call(
  17442. this, seriesModel, ecModel, api, payload
  17443. );
  17444. }
  17445. },
  17446. downplay: function (seriesModel, ecModel, api, payload) {
  17447. var data = seriesModel.getData();
  17448. var dataIndex = queryDataIndex(data, payload);
  17449. if (dataIndex != null && dataIndex >= 0) {
  17450. var symbol = data.getItemGraphicEl(dataIndex);
  17451. if (symbol) {
  17452. if (symbol.__temp) {
  17453. data.setItemGraphicEl(dataIndex, null);
  17454. this.group.remove(symbol);
  17455. }
  17456. else {
  17457. symbol.downplay();
  17458. }
  17459. }
  17460. }
  17461. else {
  17462. // Downplay whole series
  17463. ChartView.prototype.downplay.call(
  17464. this, seriesModel, ecModel, api, payload
  17465. );
  17466. }
  17467. },
  17468. /**
  17469. * @param {module:zrender/container/Group} group
  17470. * @param {Array.<Array.<number>>} points
  17471. * @private
  17472. */
  17473. _newPolyline: function (points) {
  17474. var polyline = this._polyline;
  17475. // Remove previous created polyline
  17476. if (polyline) {
  17477. this._lineGroup.remove(polyline);
  17478. }
  17479. polyline = new polyHelper.Polyline({
  17480. shape: {
  17481. points: points
  17482. },
  17483. silent: true,
  17484. z2: 10
  17485. });
  17486. this._lineGroup.add(polyline);
  17487. this._polyline = polyline;
  17488. return polyline;
  17489. },
  17490. /**
  17491. * @param {module:zrender/container/Group} group
  17492. * @param {Array.<Array.<number>>} stackedOnPoints
  17493. * @param {Array.<Array.<number>>} points
  17494. * @private
  17495. */
  17496. _newPolygon: function (points, stackedOnPoints) {
  17497. var polygon = this._polygon;
  17498. // Remove previous created polygon
  17499. if (polygon) {
  17500. this._lineGroup.remove(polygon);
  17501. }
  17502. polygon = new polyHelper.Polygon({
  17503. shape: {
  17504. points: points,
  17505. stackedOnPoints: stackedOnPoints
  17506. },
  17507. silent: true
  17508. });
  17509. this._lineGroup.add(polygon);
  17510. this._polygon = polygon;
  17511. return polygon;
  17512. },
  17513. /**
  17514. * @private
  17515. */
  17516. _getSymbolIgnoreFunc: function (data, coordSys) {
  17517. var categoryAxis = coordSys.getAxesByScale('ordinal')[0];
  17518. // `getLabelInterval` is provided by echarts/component/axis
  17519. if (categoryAxis && categoryAxis.isLabelIgnored) {
  17520. return zrUtil.bind(categoryAxis.isLabelIgnored, categoryAxis);
  17521. }
  17522. },
  17523. /**
  17524. * @private
  17525. */
  17526. // FIXME Two value axis
  17527. _updateAnimation: function (data, stackedOnPoints, coordSys, api) {
  17528. var polyline = this._polyline;
  17529. var polygon = this._polygon;
  17530. var seriesModel = data.hostModel;
  17531. var diff = lineAnimationDiff(
  17532. this._data, data,
  17533. this._stackedOnPoints, stackedOnPoints,
  17534. this._coordSys, coordSys
  17535. );
  17536. polyline.shape.points = diff.current;
  17537. graphic.updateProps(polyline, {
  17538. shape: {
  17539. points: diff.next
  17540. }
  17541. }, seriesModel);
  17542. if (polygon) {
  17543. polygon.setShape({
  17544. points: diff.current,
  17545. stackedOnPoints: diff.stackedOnCurrent
  17546. });
  17547. graphic.updateProps(polygon, {
  17548. shape: {
  17549. points: diff.next,
  17550. stackedOnPoints: diff.stackedOnNext
  17551. }
  17552. }, seriesModel);
  17553. }
  17554. var updatedDataInfo = [];
  17555. var diffStatus = diff.status;
  17556. for (var i = 0; i < diffStatus.length; i++) {
  17557. var cmd = diffStatus[i].cmd;
  17558. if (cmd === '=') {
  17559. var el = data.getItemGraphicEl(diffStatus[i].idx1);
  17560. if (el) {
  17561. updatedDataInfo.push({
  17562. el: el,
  17563. ptIdx: i // Index of points
  17564. });
  17565. }
  17566. }
  17567. }
  17568. if (polyline.animators && polyline.animators.length) {
  17569. polyline.animators[0].during(function () {
  17570. for (var i = 0; i < updatedDataInfo.length; i++) {
  17571. var el = updatedDataInfo[i].el;
  17572. el.attr('position', polyline.shape.points[updatedDataInfo[i].ptIdx]);
  17573. }
  17574. });
  17575. }
  17576. },
  17577. remove: function (ecModel) {
  17578. var group = this.group;
  17579. var oldData = this._data;
  17580. this._lineGroup.removeAll();
  17581. this._symbolDraw.remove(true);
  17582. // Remove temporary created elements when highlighting
  17583. oldData && oldData.eachItemGraphicEl(function (el, idx) {
  17584. if (el.__temp) {
  17585. group.remove(el);
  17586. oldData.setItemGraphicEl(idx, null);
  17587. }
  17588. });
  17589. this._polyline =
  17590. this._polygon =
  17591. this._coordSys =
  17592. this._points =
  17593. this._stackedOnPoints =
  17594. this._data = null;
  17595. }
  17596. });
  17597. /***/ },
  17598. /* 99 */
  17599. /***/ function(module, exports, __webpack_require__) {
  17600. /**
  17601. * @module echarts/chart/helper/SymbolDraw
  17602. */
  17603. var graphic = __webpack_require__(42);
  17604. var Symbol = __webpack_require__(100);
  17605. /**
  17606. * @constructor
  17607. * @alias module:echarts/chart/helper/SymbolDraw
  17608. * @param {module:zrender/graphic/Group} [symbolCtor]
  17609. */
  17610. function SymbolDraw(symbolCtor) {
  17611. this.group = new graphic.Group();
  17612. this._symbolCtor = symbolCtor || Symbol;
  17613. }
  17614. var symbolDrawProto = SymbolDraw.prototype;
  17615. function symbolNeedsDraw(data, idx, isIgnore) {
  17616. var point = data.getItemLayout(idx);
  17617. return point && !isNaN(point[0]) && !isNaN(point[1]) && !(isIgnore && isIgnore(idx))
  17618. && data.getItemVisual(idx, 'symbol') !== 'none';
  17619. }
  17620. /**
  17621. * Update symbols draw by new data
  17622. * @param {module:echarts/data/List} data
  17623. * @param {Array.<boolean>} [isIgnore]
  17624. */
  17625. symbolDrawProto.updateData = function (data, isIgnore) {
  17626. var group = this.group;
  17627. var seriesModel = data.hostModel;
  17628. var oldData = this._data;
  17629. var SymbolCtor = this._symbolCtor;
  17630. data.diff(oldData)
  17631. .add(function (newIdx) {
  17632. var point = data.getItemLayout(newIdx);
  17633. if (symbolNeedsDraw(data, newIdx, isIgnore)) {
  17634. var symbolEl = new SymbolCtor(data, newIdx);
  17635. symbolEl.attr('position', point);
  17636. data.setItemGraphicEl(newIdx, symbolEl);
  17637. group.add(symbolEl);
  17638. }
  17639. })
  17640. .update(function (newIdx, oldIdx) {
  17641. var symbolEl = oldData.getItemGraphicEl(oldIdx);
  17642. var point = data.getItemLayout(newIdx);
  17643. if (!symbolNeedsDraw(data, newIdx, isIgnore)) {
  17644. group.remove(symbolEl);
  17645. return;
  17646. }
  17647. if (!symbolEl) {
  17648. symbolEl = new SymbolCtor(data, newIdx);
  17649. symbolEl.attr('position', point);
  17650. }
  17651. else {
  17652. symbolEl.updateData(data, newIdx);
  17653. graphic.updateProps(symbolEl, {
  17654. position: point
  17655. }, seriesModel);
  17656. }
  17657. // Add back
  17658. group.add(symbolEl);
  17659. data.setItemGraphicEl(newIdx, symbolEl);
  17660. })
  17661. .remove(function (oldIdx) {
  17662. var el = oldData.getItemGraphicEl(oldIdx);
  17663. el && el.fadeOut(function () {
  17664. group.remove(el);
  17665. });
  17666. })
  17667. .execute();
  17668. this._data = data;
  17669. };
  17670. symbolDrawProto.updateLayout = function () {
  17671. var data = this._data;
  17672. if (data) {
  17673. // Not use animation
  17674. data.eachItemGraphicEl(function (el, idx) {
  17675. el.attr('position', data.getItemLayout(idx));
  17676. });
  17677. }
  17678. };
  17679. symbolDrawProto.remove = function (enableAnimation) {
  17680. var group = this.group;
  17681. var data = this._data;
  17682. if (data) {
  17683. if (enableAnimation) {
  17684. data.eachItemGraphicEl(function (el) {
  17685. el.fadeOut(function () {
  17686. group.remove(el);
  17687. });
  17688. });
  17689. }
  17690. else {
  17691. group.removeAll();
  17692. }
  17693. }
  17694. };
  17695. module.exports = SymbolDraw;
  17696. /***/ },
  17697. /* 100 */
  17698. /***/ function(module, exports, __webpack_require__) {
  17699. /**
  17700. * @module echarts/chart/helper/Symbol
  17701. */
  17702. var zrUtil = __webpack_require__(3);
  17703. var symbolUtil = __webpack_require__(101);
  17704. var graphic = __webpack_require__(42);
  17705. var numberUtil = __webpack_require__(7);
  17706. function normalizeSymbolSize(symbolSize) {
  17707. if (!zrUtil.isArray(symbolSize)) {
  17708. symbolSize = [+symbolSize, +symbolSize];
  17709. }
  17710. return symbolSize;
  17711. }
  17712. /**
  17713. * @constructor
  17714. * @alias {module:echarts/chart/helper/Symbol}
  17715. * @param {module:echarts/data/List} data
  17716. * @param {number} idx
  17717. * @extends {module:zrender/graphic/Group}
  17718. */
  17719. function Symbol(data, idx) {
  17720. graphic.Group.call(this);
  17721. this.updateData(data, idx);
  17722. }
  17723. var symbolProto = Symbol.prototype;
  17724. function driftSymbol(dx, dy) {
  17725. this.parent.drift(dx, dy);
  17726. }
  17727. symbolProto._createSymbol = function (symbolType, data, idx) {
  17728. // Remove paths created before
  17729. this.removeAll();
  17730. var seriesModel = data.hostModel;
  17731. var color = data.getItemVisual(idx, 'color');
  17732. var symbolPath = symbolUtil.createSymbol(
  17733. symbolType, -0.5, -0.5, 1, 1, color
  17734. );
  17735. symbolPath.attr({
  17736. z2: 100,
  17737. culling: true,
  17738. scale: [0, 0]
  17739. });
  17740. // Rewrite drift method
  17741. symbolPath.drift = driftSymbol;
  17742. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  17743. graphic.initProps(symbolPath, {
  17744. scale: size
  17745. }, seriesModel, idx);
  17746. this._symbolType = symbolType;
  17747. this.add(symbolPath);
  17748. };
  17749. /**
  17750. * Stop animation
  17751. * @param {boolean} toLastFrame
  17752. */
  17753. symbolProto.stopSymbolAnimation = function (toLastFrame) {
  17754. this.childAt(0).stopAnimation(toLastFrame);
  17755. };
  17756. /**
  17757. * Get scale(aka, current symbol size).
  17758. * Including the change caused by animation
  17759. */
  17760. symbolProto.getScale = function () {
  17761. return this.childAt(0).scale;
  17762. };
  17763. /**
  17764. * Highlight symbol
  17765. */
  17766. symbolProto.highlight = function () {
  17767. this.childAt(0).trigger('emphasis');
  17768. };
  17769. /**
  17770. * Downplay symbol
  17771. */
  17772. symbolProto.downplay = function () {
  17773. this.childAt(0).trigger('normal');
  17774. };
  17775. /**
  17776. * @param {number} zlevel
  17777. * @param {number} z
  17778. */
  17779. symbolProto.setZ = function (zlevel, z) {
  17780. var symbolPath = this.childAt(0);
  17781. symbolPath.zlevel = zlevel;
  17782. symbolPath.z = z;
  17783. };
  17784. symbolProto.setDraggable = function (draggable) {
  17785. var symbolPath = this.childAt(0);
  17786. symbolPath.draggable = draggable;
  17787. symbolPath.cursor = draggable ? 'move' : 'pointer';
  17788. };
  17789. /**
  17790. * Update symbol properties
  17791. * @param {module:echarts/data/List} data
  17792. * @param {number} idx
  17793. */
  17794. symbolProto.updateData = function (data, idx) {
  17795. var symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
  17796. var seriesModel = data.hostModel;
  17797. var symbolSize = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  17798. if (symbolType !== this._symbolType) {
  17799. this._createSymbol(symbolType, data, idx);
  17800. }
  17801. else {
  17802. var symbolPath = this.childAt(0);
  17803. graphic.updateProps(symbolPath, {
  17804. scale: symbolSize
  17805. }, seriesModel, idx);
  17806. }
  17807. this._updateCommon(data, idx, symbolSize);
  17808. this._seriesModel = seriesModel;
  17809. };
  17810. // Update common properties
  17811. var normalStyleAccessPath = ['itemStyle', 'normal'];
  17812. var emphasisStyleAccessPath = ['itemStyle', 'emphasis'];
  17813. var normalLabelAccessPath = ['label', 'normal'];
  17814. var emphasisLabelAccessPath = ['label', 'emphasis'];
  17815. symbolProto._updateCommon = function (data, idx, symbolSize) {
  17816. var symbolPath = this.childAt(0);
  17817. var seriesModel = data.hostModel;
  17818. var itemModel = data.getItemModel(idx);
  17819. var normalItemStyleModel = itemModel.getModel(normalStyleAccessPath);
  17820. var color = data.getItemVisual(idx, 'color');
  17821. // Reset style
  17822. if (symbolPath.type !== 'image') {
  17823. symbolPath.useStyle({
  17824. strokeNoScale: true
  17825. });
  17826. }
  17827. var elStyle = symbolPath.style;
  17828. var hoverStyle = itemModel.getModel(emphasisStyleAccessPath).getItemStyle();
  17829. symbolPath.rotation = (itemModel.getShallow('symbolRotate') || 0) * Math.PI / 180 || 0;
  17830. var symbolOffset = itemModel.getShallow('symbolOffset');
  17831. if (symbolOffset) {
  17832. var pos = symbolPath.position;
  17833. pos[0] = numberUtil.parsePercent(symbolOffset[0], symbolSize[0]);
  17834. pos[1] = numberUtil.parsePercent(symbolOffset[1], symbolSize[1]);
  17835. }
  17836. symbolPath.setColor(color);
  17837. zrUtil.extend(
  17838. elStyle,
  17839. // Color must be excluded.
  17840. // Because symbol provide setColor individually to set fill and stroke
  17841. normalItemStyleModel.getItemStyle(['color'])
  17842. );
  17843. var opacity = data.getItemVisual(idx, 'opacity');
  17844. if (opacity != null) {
  17845. elStyle.opacity = opacity;
  17846. }
  17847. var labelModel = itemModel.getModel(normalLabelAccessPath);
  17848. var hoverLabelModel = itemModel.getModel(emphasisLabelAccessPath);
  17849. // Get last value dim
  17850. var dimensions = data.dimensions.slice();
  17851. var valueDim;
  17852. var dataType;
  17853. while (dimensions.length && (
  17854. valueDim = dimensions.pop(),
  17855. dataType = data.getDimensionInfo(valueDim).type,
  17856. dataType === 'ordinal' || dataType === 'time'
  17857. )) {} // jshint ignore:line
  17858. if (valueDim != null && labelModel.get('show')) {
  17859. graphic.setText(elStyle, labelModel, color);
  17860. elStyle.text = zrUtil.retrieve(
  17861. seriesModel.getFormattedLabel(idx, 'normal'),
  17862. data.get(valueDim, idx)
  17863. );
  17864. }
  17865. else {
  17866. elStyle.text = '';
  17867. }
  17868. if (valueDim != null && hoverLabelModel.getShallow('show')) {
  17869. graphic.setText(hoverStyle, hoverLabelModel, color);
  17870. hoverStyle.text = zrUtil.retrieve(
  17871. seriesModel.getFormattedLabel(idx, 'emphasis'),
  17872. data.get(valueDim, idx)
  17873. );
  17874. }
  17875. else {
  17876. hoverStyle.text = '';
  17877. }
  17878. var size = normalizeSymbolSize(data.getItemVisual(idx, 'symbolSize'));
  17879. symbolPath.off('mouseover')
  17880. .off('mouseout')
  17881. .off('emphasis')
  17882. .off('normal');
  17883. graphic.setHoverStyle(symbolPath, hoverStyle);
  17884. if (itemModel.getShallow('hoverAnimation')) {
  17885. var onEmphasis = function() {
  17886. var ratio = size[1] / size[0];
  17887. this.animateTo({
  17888. scale: [
  17889. Math.max(size[0] * 1.1, size[0] + 3),
  17890. Math.max(size[1] * 1.1, size[1] + 3 * ratio)
  17891. ]
  17892. }, 400, 'elasticOut');
  17893. };
  17894. var onNormal = function() {
  17895. this.animateTo({
  17896. scale: size
  17897. }, 400, 'elasticOut');
  17898. };
  17899. symbolPath.on('mouseover', onEmphasis)
  17900. .on('mouseout', onNormal)
  17901. .on('emphasis', onEmphasis)
  17902. .on('normal', onNormal);
  17903. }
  17904. };
  17905. symbolProto.fadeOut = function (cb) {
  17906. var symbolPath = this.childAt(0);
  17907. // Avoid trigger hoverAnimation when fading
  17908. symbolPath.off('mouseover')
  17909. .off('mouseout')
  17910. .off('emphasis')
  17911. .off('normal');
  17912. // Not show text when animating
  17913. symbolPath.style.text = '';
  17914. graphic.updateProps(symbolPath, {
  17915. scale: [0, 0]
  17916. }, this._seriesModel, this.dataIndex, cb);
  17917. };
  17918. zrUtil.inherits(Symbol, graphic.Group);
  17919. module.exports = Symbol;
  17920. /***/ },
  17921. /* 101 */
  17922. /***/ function(module, exports, __webpack_require__) {
  17923. 'use strict';
  17924. // Symbol factory
  17925. var graphic = __webpack_require__(42);
  17926. var BoundingRect = __webpack_require__(15);
  17927. /**
  17928. * Triangle shape
  17929. * @inner
  17930. */
  17931. var Triangle = graphic.extendShape({
  17932. type: 'triangle',
  17933. shape: {
  17934. cx: 0,
  17935. cy: 0,
  17936. width: 0,
  17937. height: 0
  17938. },
  17939. buildPath: function (path, shape) {
  17940. var cx = shape.cx;
  17941. var cy = shape.cy;
  17942. var width = shape.width / 2;
  17943. var height = shape.height / 2;
  17944. path.moveTo(cx, cy - height);
  17945. path.lineTo(cx + width, cy + height);
  17946. path.lineTo(cx - width, cy + height);
  17947. path.closePath();
  17948. }
  17949. });
  17950. /**
  17951. * Diamond shape
  17952. * @inner
  17953. */
  17954. var Diamond = graphic.extendShape({
  17955. type: 'diamond',
  17956. shape: {
  17957. cx: 0,
  17958. cy: 0,
  17959. width: 0,
  17960. height: 0
  17961. },
  17962. buildPath: function (path, shape) {
  17963. var cx = shape.cx;
  17964. var cy = shape.cy;
  17965. var width = shape.width / 2;
  17966. var height = shape.height / 2;
  17967. path.moveTo(cx, cy - height);
  17968. path.lineTo(cx + width, cy);
  17969. path.lineTo(cx, cy + height);
  17970. path.lineTo(cx - width, cy);
  17971. path.closePath();
  17972. }
  17973. });
  17974. /**
  17975. * Pin shape
  17976. * @inner
  17977. */
  17978. var Pin = graphic.extendShape({
  17979. type: 'pin',
  17980. shape: {
  17981. // x, y on the cusp
  17982. x: 0,
  17983. y: 0,
  17984. width: 0,
  17985. height: 0
  17986. },
  17987. buildPath: function (path, shape) {
  17988. var x = shape.x;
  17989. var y = shape.y;
  17990. var w = shape.width / 5 * 3;
  17991. // Height must be larger than width
  17992. var h = Math.max(w, shape.height);
  17993. var r = w / 2;
  17994. // Dist on y with tangent point and circle center
  17995. var dy = r * r / (h - r);
  17996. var cy = y - h + r + dy;
  17997. var angle = Math.asin(dy / r);
  17998. // Dist on x with tangent point and circle center
  17999. var dx = Math.cos(angle) * r;
  18000. var tanX = Math.sin(angle);
  18001. var tanY = Math.cos(angle);
  18002. path.arc(
  18003. x, cy, r,
  18004. Math.PI - angle,
  18005. Math.PI * 2 + angle
  18006. );
  18007. var cpLen = r * 0.6;
  18008. var cpLen2 = r * 0.7;
  18009. path.bezierCurveTo(
  18010. x + dx - tanX * cpLen, cy + dy + tanY * cpLen,
  18011. x, y - cpLen2,
  18012. x, y
  18013. );
  18014. path.bezierCurveTo(
  18015. x, y - cpLen2,
  18016. x - dx + tanX * cpLen, cy + dy + tanY * cpLen,
  18017. x - dx, cy + dy
  18018. );
  18019. path.closePath();
  18020. }
  18021. });
  18022. /**
  18023. * Arrow shape
  18024. * @inner
  18025. */
  18026. var Arrow = graphic.extendShape({
  18027. type: 'arrow',
  18028. shape: {
  18029. x: 0,
  18030. y: 0,
  18031. width: 0,
  18032. height: 0
  18033. },
  18034. buildPath: function (ctx, shape) {
  18035. var height = shape.height;
  18036. var width = shape.width;
  18037. var x = shape.x;
  18038. var y = shape.y;
  18039. var dx = width / 3 * 2;
  18040. ctx.moveTo(x, y);
  18041. ctx.lineTo(x + dx, y + height);
  18042. ctx.lineTo(x, y + height / 4 * 3);
  18043. ctx.lineTo(x - dx, y + height);
  18044. ctx.lineTo(x, y);
  18045. ctx.closePath();
  18046. }
  18047. });
  18048. /**
  18049. * Map of path contructors
  18050. * @type {Object.<string, module:zrender/graphic/Path>}
  18051. */
  18052. var symbolCtors = {
  18053. line: graphic.Line,
  18054. rect: graphic.Rect,
  18055. roundRect: graphic.Rect,
  18056. square: graphic.Rect,
  18057. circle: graphic.Circle,
  18058. diamond: Diamond,
  18059. pin: Pin,
  18060. arrow: Arrow,
  18061. triangle: Triangle
  18062. };
  18063. var symbolShapeMakers = {
  18064. line: function (x, y, w, h, shape) {
  18065. // FIXME
  18066. shape.x1 = x;
  18067. shape.y1 = y + h / 2;
  18068. shape.x2 = x + w;
  18069. shape.y2 = y + h / 2;
  18070. },
  18071. rect: function (x, y, w, h, shape) {
  18072. shape.x = x;
  18073. shape.y = y;
  18074. shape.width = w;
  18075. shape.height = h;
  18076. },
  18077. roundRect: function (x, y, w, h, shape) {
  18078. shape.x = x;
  18079. shape.y = y;
  18080. shape.width = w;
  18081. shape.height = h;
  18082. shape.r = Math.min(w, h) / 4;
  18083. },
  18084. square: function (x, y, w, h, shape) {
  18085. var size = Math.min(w, h);
  18086. shape.x = x;
  18087. shape.y = y;
  18088. shape.width = size;
  18089. shape.height = size;
  18090. },
  18091. circle: function (x, y, w, h, shape) {
  18092. // Put circle in the center of square
  18093. shape.cx = x + w / 2;
  18094. shape.cy = y + h / 2;
  18095. shape.r = Math.min(w, h) / 2;
  18096. },
  18097. diamond: function (x, y, w, h, shape) {
  18098. shape.cx = x + w / 2;
  18099. shape.cy = y + h / 2;
  18100. shape.width = w;
  18101. shape.height = h;
  18102. },
  18103. pin: function (x, y, w, h, shape) {
  18104. shape.x = x + w / 2;
  18105. shape.y = y + h / 2;
  18106. shape.width = w;
  18107. shape.height = h;
  18108. },
  18109. arrow: function (x, y, w, h, shape) {
  18110. shape.x = x + w / 2;
  18111. shape.y = y + h / 2;
  18112. shape.width = w;
  18113. shape.height = h;
  18114. },
  18115. triangle: function (x, y, w, h, shape) {
  18116. shape.cx = x + w / 2;
  18117. shape.cy = y + h / 2;
  18118. shape.width = w;
  18119. shape.height = h;
  18120. }
  18121. };
  18122. var symbolBuildProxies = {};
  18123. for (var name in symbolCtors) {
  18124. symbolBuildProxies[name] = new symbolCtors[name]();
  18125. }
  18126. var Symbol = graphic.extendShape({
  18127. type: 'symbol',
  18128. shape: {
  18129. symbolType: '',
  18130. x: 0,
  18131. y: 0,
  18132. width: 0,
  18133. height: 0
  18134. },
  18135. beforeBrush: function () {
  18136. var style = this.style;
  18137. var shape = this.shape;
  18138. // FIXME
  18139. if (shape.symbolType === 'pin' && style.textPosition === 'inside') {
  18140. style.textPosition = ['50%', '40%'];
  18141. style.textAlign = 'center';
  18142. style.textVerticalAlign = 'middle';
  18143. }
  18144. },
  18145. buildPath: function (ctx, shape) {
  18146. var symbolType = shape.symbolType;
  18147. var proxySymbol = symbolBuildProxies[symbolType];
  18148. if (shape.symbolType !== 'none') {
  18149. if (!proxySymbol) {
  18150. // Default rect
  18151. symbolType = 'rect';
  18152. proxySymbol = symbolBuildProxies[symbolType];
  18153. }
  18154. symbolShapeMakers[symbolType](
  18155. shape.x, shape.y, shape.width, shape.height, proxySymbol.shape
  18156. );
  18157. proxySymbol.buildPath(ctx, proxySymbol.shape);
  18158. }
  18159. }
  18160. });
  18161. // Provide setColor helper method to avoid determine if set the fill or stroke outside
  18162. var symbolPathSetColor = function (color) {
  18163. if (this.type !== 'image') {
  18164. var symbolStyle = this.style;
  18165. var symbolShape = this.shape;
  18166. if (symbolShape && symbolShape.symbolType === 'line') {
  18167. symbolStyle.stroke = color;
  18168. }
  18169. else if (this.__isEmptyBrush) {
  18170. symbolStyle.stroke = color;
  18171. symbolStyle.fill = '#fff';
  18172. }
  18173. else {
  18174. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  18175. symbolStyle.fill && (symbolStyle.fill = color);
  18176. symbolStyle.stroke && (symbolStyle.stroke = color);
  18177. }
  18178. this.dirty();
  18179. }
  18180. };
  18181. var symbolUtil = {
  18182. /**
  18183. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  18184. * @param {string} symbolType
  18185. * @param {number} x
  18186. * @param {number} y
  18187. * @param {number} w
  18188. * @param {number} h
  18189. * @param {string} color
  18190. */
  18191. createSymbol: function (symbolType, x, y, w, h, color) {
  18192. var isEmpty = symbolType.indexOf('empty') === 0;
  18193. if (isEmpty) {
  18194. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  18195. }
  18196. var symbolPath;
  18197. if (symbolType.indexOf('image://') === 0) {
  18198. symbolPath = new graphic.Image({
  18199. style: {
  18200. image: symbolType.slice(8),
  18201. x: x,
  18202. y: y,
  18203. width: w,
  18204. height: h
  18205. }
  18206. });
  18207. }
  18208. else if (symbolType.indexOf('path://') === 0) {
  18209. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h));
  18210. }
  18211. else {
  18212. symbolPath = new Symbol({
  18213. shape: {
  18214. symbolType: symbolType,
  18215. x: x,
  18216. y: y,
  18217. width: w,
  18218. height: h
  18219. }
  18220. });
  18221. }
  18222. symbolPath.__isEmptyBrush = isEmpty;
  18223. symbolPath.setColor = symbolPathSetColor;
  18224. symbolPath.setColor(color);
  18225. return symbolPath;
  18226. }
  18227. };
  18228. module.exports = symbolUtil;
  18229. /***/ },
  18230. /* 102 */
  18231. /***/ function(module, exports) {
  18232. // var arrayDiff = require('zrender/lib/core/arrayDiff');
  18233. // 'zrender/core/arrayDiff' has been used before, but it did
  18234. // not do well in performance when roam with fixed dataZoom window.
  18235. function sign(val) {
  18236. return val >= 0 ? 1 : -1;
  18237. }
  18238. function getStackedOnPoint(coordSys, data, idx) {
  18239. var baseAxis = coordSys.getBaseAxis();
  18240. var valueAxis = coordSys.getOtherAxis(baseAxis);
  18241. var valueStart = baseAxis.onZero
  18242. ? 0 : valueAxis.scale.getExtent()[0];
  18243. var valueDim = valueAxis.dim;
  18244. var baseDataOffset = valueDim === 'x' || valueDim === 'radius' ? 1 : 0;
  18245. var stackedOnSameSign;
  18246. var stackedOn = data.stackedOn;
  18247. var val = data.get(valueDim, idx);
  18248. // Find first stacked value with same sign
  18249. while (stackedOn &&
  18250. sign(stackedOn.get(valueDim, idx)) === sign(val)
  18251. ) {
  18252. stackedOnSameSign = stackedOn;
  18253. break;
  18254. }
  18255. var stackedData = [];
  18256. stackedData[baseDataOffset] = data.get(baseAxis.dim, idx);
  18257. stackedData[1 - baseDataOffset] = stackedOnSameSign
  18258. ? stackedOnSameSign.get(valueDim, idx, true) : valueStart;
  18259. return coordSys.dataToPoint(stackedData);
  18260. }
  18261. // function convertToIntId(newIdList, oldIdList) {
  18262. // // Generate int id instead of string id.
  18263. // // Compare string maybe slow in score function of arrDiff
  18264. // // Assume id in idList are all unique
  18265. // var idIndicesMap = {};
  18266. // var idx = 0;
  18267. // for (var i = 0; i < newIdList.length; i++) {
  18268. // idIndicesMap[newIdList[i]] = idx;
  18269. // newIdList[i] = idx++;
  18270. // }
  18271. // for (var i = 0; i < oldIdList.length; i++) {
  18272. // var oldId = oldIdList[i];
  18273. // // Same with newIdList
  18274. // if (idIndicesMap[oldId]) {
  18275. // oldIdList[i] = idIndicesMap[oldId];
  18276. // }
  18277. // else {
  18278. // oldIdList[i] = idx++;
  18279. // }
  18280. // }
  18281. // }
  18282. function diffData(oldData, newData) {
  18283. var diffResult = [];
  18284. newData.diff(oldData)
  18285. .add(function (idx) {
  18286. diffResult.push({cmd: '+', idx: idx});
  18287. })
  18288. .update(function (newIdx, oldIdx) {
  18289. diffResult.push({cmd: '=', idx: oldIdx, idx1: newIdx});
  18290. })
  18291. .remove(function (idx) {
  18292. diffResult.push({cmd: '-', idx: idx});
  18293. })
  18294. .execute();
  18295. return diffResult;
  18296. }
  18297. module.exports = function (
  18298. oldData, newData,
  18299. oldStackedOnPoints, newStackedOnPoints,
  18300. oldCoordSys, newCoordSys
  18301. ) {
  18302. var diff = diffData(oldData, newData);
  18303. // var newIdList = newData.mapArray(newData.getId);
  18304. // var oldIdList = oldData.mapArray(oldData.getId);
  18305. // convertToIntId(newIdList, oldIdList);
  18306. // // FIXME One data ?
  18307. // diff = arrayDiff(oldIdList, newIdList);
  18308. var currPoints = [];
  18309. var nextPoints = [];
  18310. // Points for stacking base line
  18311. var currStackedPoints = [];
  18312. var nextStackedPoints = [];
  18313. var status = [];
  18314. var sortedIndices = [];
  18315. var rawIndices = [];
  18316. var dims = newCoordSys.dimensions;
  18317. for (var i = 0; i < diff.length; i++) {
  18318. var diffItem = diff[i];
  18319. var pointAdded = true;
  18320. // FIXME, animation is not so perfect when dataZoom window moves fast
  18321. // Which is in case remvoing or add more than one data in the tail or head
  18322. switch (diffItem.cmd) {
  18323. case '=':
  18324. var currentPt = oldData.getItemLayout(diffItem.idx);
  18325. var nextPt = newData.getItemLayout(diffItem.idx1);
  18326. // If previous data is NaN, use next point directly
  18327. if (isNaN(currentPt[0]) || isNaN(currentPt[1])) {
  18328. currentPt = nextPt.slice();
  18329. }
  18330. currPoints.push(currentPt);
  18331. nextPoints.push(nextPt);
  18332. currStackedPoints.push(oldStackedOnPoints[diffItem.idx]);
  18333. nextStackedPoints.push(newStackedOnPoints[diffItem.idx1]);
  18334. rawIndices.push(newData.getRawIndex(diffItem.idx1));
  18335. break;
  18336. case '+':
  18337. var idx = diffItem.idx;
  18338. currPoints.push(
  18339. oldCoordSys.dataToPoint([
  18340. newData.get(dims[0], idx, true), newData.get(dims[1], idx, true)
  18341. ])
  18342. );
  18343. nextPoints.push(newData.getItemLayout(idx).slice());
  18344. currStackedPoints.push(
  18345. getStackedOnPoint(oldCoordSys, newData, idx)
  18346. );
  18347. nextStackedPoints.push(newStackedOnPoints[idx]);
  18348. rawIndices.push(newData.getRawIndex(idx));
  18349. break;
  18350. case '-':
  18351. var idx = diffItem.idx;
  18352. var rawIndex = oldData.getRawIndex(idx);
  18353. // Data is replaced. In the case of dynamic data queue
  18354. // FIXME FIXME FIXME
  18355. if (rawIndex !== idx) {
  18356. currPoints.push(oldData.getItemLayout(idx));
  18357. nextPoints.push(newCoordSys.dataToPoint([
  18358. oldData.get(dims[0], idx, true), oldData.get(dims[1], idx, true)
  18359. ]));
  18360. currStackedPoints.push(oldStackedOnPoints[idx]);
  18361. nextStackedPoints.push(
  18362. getStackedOnPoint(
  18363. newCoordSys, oldData, idx
  18364. )
  18365. );
  18366. rawIndices.push(rawIndex);
  18367. }
  18368. else {
  18369. pointAdded = false;
  18370. }
  18371. }
  18372. // Original indices
  18373. if (pointAdded) {
  18374. status.push(diffItem);
  18375. sortedIndices.push(sortedIndices.length);
  18376. }
  18377. }
  18378. // Diff result may be crossed if all items are changed
  18379. // Sort by data index
  18380. sortedIndices.sort(function (a, b) {
  18381. return rawIndices[a] - rawIndices[b];
  18382. });
  18383. var sortedCurrPoints = [];
  18384. var sortedNextPoints = [];
  18385. var sortedCurrStackedPoints = [];
  18386. var sortedNextStackedPoints = [];
  18387. var sortedStatus = [];
  18388. for (var i = 0; i < sortedIndices.length; i++) {
  18389. var idx = sortedIndices[i];
  18390. sortedCurrPoints[i] = currPoints[idx];
  18391. sortedNextPoints[i] = nextPoints[idx];
  18392. sortedCurrStackedPoints[i] = currStackedPoints[idx];
  18393. sortedNextStackedPoints[i] = nextStackedPoints[idx];
  18394. sortedStatus[i] = status[idx];
  18395. }
  18396. return {
  18397. current: sortedCurrPoints,
  18398. next: sortedNextPoints,
  18399. stackedOnCurrent: sortedCurrStackedPoints,
  18400. stackedOnNext: sortedNextStackedPoints,
  18401. status: sortedStatus
  18402. };
  18403. };
  18404. /***/ },
  18405. /* 103 */
  18406. /***/ function(module, exports, __webpack_require__) {
  18407. // Poly path support NaN point
  18408. var Path = __webpack_require__(44);
  18409. var vec2 = __webpack_require__(16);
  18410. var vec2Min = vec2.min;
  18411. var vec2Max = vec2.max;
  18412. var scaleAndAdd = vec2.scaleAndAdd;
  18413. var v2Copy = vec2.copy;
  18414. // Temporary variable
  18415. var v = [];
  18416. var cp0 = [];
  18417. var cp1 = [];
  18418. function isPointNull(p) {
  18419. return isNaN(p[0]) || isNaN(p[1]);
  18420. }
  18421. function drawSegment(
  18422. ctx, points, start, segLen, allLen,
  18423. dir, smoothMin, smoothMax, smooth, smoothMonotone, connectNulls
  18424. ) {
  18425. var prevIdx = 0;
  18426. var idx = start;
  18427. for (var k = 0; k < segLen; k++) {
  18428. var p = points[idx];
  18429. if (idx >= allLen || idx < 0) {
  18430. break;
  18431. }
  18432. if (isPointNull(p)) {
  18433. if (connectNulls) {
  18434. idx += dir;
  18435. continue;
  18436. }
  18437. break;
  18438. }
  18439. if (idx === start) {
  18440. ctx[dir > 0 ? 'moveTo' : 'lineTo'](p[0], p[1]);
  18441. v2Copy(cp0, p);
  18442. }
  18443. else {
  18444. if (smooth > 0) {
  18445. var nextIdx = idx + dir;
  18446. var nextP = points[nextIdx];
  18447. if (connectNulls) {
  18448. // Find next point not null
  18449. while (nextP && isPointNull(points[nextIdx])) {
  18450. nextIdx += dir;
  18451. nextP = points[nextIdx];
  18452. }
  18453. }
  18454. var ratioNextSeg = 0.5;
  18455. var prevP = points[prevIdx];
  18456. var nextP = points[nextIdx];
  18457. // Last point
  18458. if (!nextP || isPointNull(nextP)) {
  18459. v2Copy(cp1, p);
  18460. }
  18461. else {
  18462. // If next data is null in not connect case
  18463. if (isPointNull(nextP) && !connectNulls) {
  18464. nextP = p;
  18465. }
  18466. vec2.sub(v, nextP, prevP);
  18467. var lenPrevSeg;
  18468. var lenNextSeg;
  18469. if (smoothMonotone === 'x' || smoothMonotone === 'y') {
  18470. var dim = smoothMonotone === 'x' ? 0 : 1;
  18471. lenPrevSeg = Math.abs(p[dim] - prevP[dim]);
  18472. lenNextSeg = Math.abs(p[dim] - nextP[dim]);
  18473. }
  18474. else {
  18475. lenPrevSeg = vec2.dist(p, prevP);
  18476. lenNextSeg = vec2.dist(p, nextP);
  18477. }
  18478. // Use ratio of seg length
  18479. ratioNextSeg = lenNextSeg / (lenNextSeg + lenPrevSeg);
  18480. scaleAndAdd(cp1, p, v, -smooth * (1 - ratioNextSeg));
  18481. }
  18482. // Smooth constraint
  18483. vec2Min(cp0, cp0, smoothMax);
  18484. vec2Max(cp0, cp0, smoothMin);
  18485. vec2Min(cp1, cp1, smoothMax);
  18486. vec2Max(cp1, cp1, smoothMin);
  18487. ctx.bezierCurveTo(
  18488. cp0[0], cp0[1],
  18489. cp1[0], cp1[1],
  18490. p[0], p[1]
  18491. );
  18492. // cp0 of next segment
  18493. scaleAndAdd(cp0, p, v, smooth * ratioNextSeg);
  18494. }
  18495. else {
  18496. ctx.lineTo(p[0], p[1]);
  18497. }
  18498. }
  18499. prevIdx = idx;
  18500. idx += dir;
  18501. }
  18502. return k;
  18503. }
  18504. function getBoundingBox(points, smoothConstraint) {
  18505. var ptMin = [Infinity, Infinity];
  18506. var ptMax = [-Infinity, -Infinity];
  18507. if (smoothConstraint) {
  18508. for (var i = 0; i < points.length; i++) {
  18509. var pt = points[i];
  18510. if (pt[0] < ptMin[0]) { ptMin[0] = pt[0]; }
  18511. if (pt[1] < ptMin[1]) { ptMin[1] = pt[1]; }
  18512. if (pt[0] > ptMax[0]) { ptMax[0] = pt[0]; }
  18513. if (pt[1] > ptMax[1]) { ptMax[1] = pt[1]; }
  18514. }
  18515. }
  18516. return {
  18517. min: smoothConstraint ? ptMin : ptMax,
  18518. max: smoothConstraint ? ptMax : ptMin
  18519. };
  18520. }
  18521. module.exports = {
  18522. Polyline: Path.extend({
  18523. type: 'ec-polyline',
  18524. shape: {
  18525. points: [],
  18526. smooth: 0,
  18527. smoothConstraint: true,
  18528. smoothMonotone: null,
  18529. connectNulls: false
  18530. },
  18531. style: {
  18532. fill: null,
  18533. stroke: '#000'
  18534. },
  18535. buildPath: function (ctx, shape) {
  18536. var points = shape.points;
  18537. var i = 0;
  18538. var len = points.length;
  18539. var result = getBoundingBox(points, shape.smoothConstraint);
  18540. if (shape.connectNulls) {
  18541. // Must remove first and last null values avoid draw error in polygon
  18542. for (; len > 0; len--) {
  18543. if (!isPointNull(points[len - 1])) {
  18544. break;
  18545. }
  18546. }
  18547. for (; i < len; i++) {
  18548. if (!isPointNull(points[i])) {
  18549. break;
  18550. }
  18551. }
  18552. }
  18553. while (i < len) {
  18554. i += drawSegment(
  18555. ctx, points, i, len, len,
  18556. 1, result.min, result.max, shape.smooth,
  18557. shape.smoothMonotone, shape.connectNulls
  18558. ) + 1;
  18559. }
  18560. }
  18561. }),
  18562. Polygon: Path.extend({
  18563. type: 'ec-polygon',
  18564. shape: {
  18565. points: [],
  18566. // Offset between stacked base points and points
  18567. stackedOnPoints: [],
  18568. smooth: 0,
  18569. stackedOnSmooth: 0,
  18570. smoothConstraint: true,
  18571. smoothMonotone: null,
  18572. connectNulls: false
  18573. },
  18574. buildPath: function (ctx, shape) {
  18575. var points = shape.points;
  18576. var stackedOnPoints = shape.stackedOnPoints;
  18577. var i = 0;
  18578. var len = points.length;
  18579. var smoothMonotone = shape.smoothMonotone;
  18580. var bbox = getBoundingBox(points, shape.smoothConstraint);
  18581. var stackedOnBBox = getBoundingBox(stackedOnPoints, shape.smoothConstraint);
  18582. if (shape.connectNulls) {
  18583. // Must remove first and last null values avoid draw error in polygon
  18584. for (; len > 0; len--) {
  18585. if (!isPointNull(points[len - 1])) {
  18586. break;
  18587. }
  18588. }
  18589. for (; i < len; i++) {
  18590. if (!isPointNull(points[i])) {
  18591. break;
  18592. }
  18593. }
  18594. }
  18595. while (i < len) {
  18596. var k = drawSegment(
  18597. ctx, points, i, len, len,
  18598. 1, bbox.min, bbox.max, shape.smooth,
  18599. smoothMonotone, shape.connectNulls
  18600. );
  18601. drawSegment(
  18602. ctx, stackedOnPoints, i + k - 1, k, len,
  18603. -1, stackedOnBBox.min, stackedOnBBox.max, shape.stackedOnSmooth,
  18604. smoothMonotone, shape.connectNulls
  18605. );
  18606. i += k + 1;
  18607. ctx.closePath();
  18608. }
  18609. }
  18610. })
  18611. };
  18612. /***/ },
  18613. /* 104 */
  18614. /***/ function(module, exports) {
  18615. module.exports = function (seriesType, defaultSymbolType, legendSymbol, ecModel, api) {
  18616. // Encoding visual for all series include which is filtered for legend drawing
  18617. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  18618. var data = seriesModel.getData();
  18619. var symbolType = seriesModel.get('symbol') || defaultSymbolType;
  18620. var symbolSize = seriesModel.get('symbolSize');
  18621. data.setVisual({
  18622. legendSymbol: legendSymbol || symbolType,
  18623. symbol: symbolType,
  18624. symbolSize: symbolSize
  18625. });
  18626. // Only visible series has each data be visual encoded
  18627. if (!ecModel.isSeriesFiltered(seriesModel)) {
  18628. if (typeof symbolSize === 'function') {
  18629. data.each(function (idx) {
  18630. var rawValue = seriesModel.getRawValue(idx);
  18631. // FIXME
  18632. var params = seriesModel.getDataParams(idx);
  18633. data.setItemVisual(idx, 'symbolSize', symbolSize(rawValue, params));
  18634. });
  18635. }
  18636. data.each(function (idx) {
  18637. var itemModel = data.getItemModel(idx);
  18638. var itemSymbolType = itemModel.get('symbol', true);
  18639. var itemSymbolSize = itemModel.get('symbolSize', true);
  18640. // If has item symbol
  18641. if (itemSymbolType != null) {
  18642. data.setItemVisual(idx, 'symbol', itemSymbolType);
  18643. }
  18644. if (itemSymbolSize != null) {
  18645. // PENDING Transform symbolSize ?
  18646. data.setItemVisual(idx, 'symbolSize', itemSymbolSize);
  18647. }
  18648. });
  18649. }
  18650. });
  18651. };
  18652. /***/ },
  18653. /* 105 */
  18654. /***/ function(module, exports) {
  18655. module.exports = function (seriesType, ecModel, api) {
  18656. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  18657. var data = seriesModel.getData();
  18658. var coordSys = seriesModel.coordinateSystem;
  18659. if (coordSys) {
  18660. var dims = coordSys.dimensions;
  18661. data.each(dims, function (x, y, idx) {
  18662. var point;
  18663. if (!isNaN(x) && !isNaN(y)) {
  18664. point = coordSys.dataToPoint([x, y]);
  18665. }
  18666. else {
  18667. // Also {Array.<number>}, not undefined to avoid if...else... statement
  18668. point = [NaN, NaN];
  18669. }
  18670. data.setItemLayout(idx, point);
  18671. }, true);
  18672. }
  18673. });
  18674. };
  18675. /***/ },
  18676. /* 106 */
  18677. /***/ function(module, exports) {
  18678. var samplers = {
  18679. average: function (frame) {
  18680. var sum = 0;
  18681. var count = 0;
  18682. for (var i = 0; i < frame.length; i++) {
  18683. if (!isNaN(frame[i])) {
  18684. sum += frame[i];
  18685. count++;
  18686. }
  18687. }
  18688. // Return NaN if count is 0
  18689. return count === 0 ? NaN : sum / count;
  18690. },
  18691. sum: function (frame) {
  18692. var sum = 0;
  18693. for (var i = 0; i < frame.length; i++) {
  18694. // Ignore NaN
  18695. sum += frame[i] || 0;
  18696. }
  18697. return sum;
  18698. },
  18699. max: function (frame) {
  18700. var max = -Infinity;
  18701. for (var i = 0; i < frame.length; i++) {
  18702. frame[i] > max && (max = frame[i]);
  18703. }
  18704. return max;
  18705. },
  18706. min: function (frame) {
  18707. var min = Infinity;
  18708. for (var i = 0; i < frame.length; i++) {
  18709. frame[i] < min && (min = frame[i]);
  18710. }
  18711. return min;
  18712. },
  18713. // TODO
  18714. // Median
  18715. nearest: function (frame) {
  18716. return frame[0];
  18717. }
  18718. };
  18719. var indexSampler = function (frame, value) {
  18720. return Math.round(frame.length / 2);
  18721. };
  18722. module.exports = function (seriesType, ecModel, api) {
  18723. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  18724. var data = seriesModel.getData();
  18725. var sampling = seriesModel.get('sampling');
  18726. var coordSys = seriesModel.coordinateSystem;
  18727. // Only cartesian2d support down sampling
  18728. if (coordSys.type === 'cartesian2d' && sampling) {
  18729. var baseAxis = coordSys.getBaseAxis();
  18730. var valueAxis = coordSys.getOtherAxis(baseAxis);
  18731. var extent = baseAxis.getExtent();
  18732. // Coordinste system has been resized
  18733. var size = extent[1] - extent[0];
  18734. var rate = Math.round(data.count() / size);
  18735. if (rate > 1) {
  18736. var sampler;
  18737. if (typeof sampling === 'string') {
  18738. sampler = samplers[sampling];
  18739. }
  18740. else if (typeof sampling === 'function') {
  18741. sampler = sampling;
  18742. }
  18743. if (sampler) {
  18744. data = data.downSample(
  18745. valueAxis.dim, 1 / rate, sampler, indexSampler
  18746. );
  18747. seriesModel.setData(data);
  18748. }
  18749. }
  18750. }
  18751. }, this);
  18752. };
  18753. /***/ },
  18754. /* 107 */
  18755. /***/ function(module, exports, __webpack_require__) {
  18756. 'use strict';
  18757. var graphic = __webpack_require__(42);
  18758. var zrUtil = __webpack_require__(3);
  18759. __webpack_require__(108);
  18760. __webpack_require__(125);
  18761. // Grid view
  18762. __webpack_require__(1).extendComponentView({
  18763. type: 'grid',
  18764. render: function (gridModel, ecModel) {
  18765. this.group.removeAll();
  18766. if (gridModel.get('show')) {
  18767. this.group.add(new graphic.Rect({
  18768. shape:gridModel.coordinateSystem.getRect(),
  18769. style: zrUtil.defaults({
  18770. fill: gridModel.get('backgroundColor')
  18771. }, gridModel.getItemStyle()),
  18772. silent: true
  18773. }));
  18774. }
  18775. }
  18776. });
  18777. /***/ },
  18778. /* 108 */
  18779. /***/ function(module, exports, __webpack_require__) {
  18780. /**
  18781. * Grid is a region which contains at most 4 cartesian systems
  18782. *
  18783. * TODO Default cartesian
  18784. */
  18785. var factory = exports;
  18786. var layout = __webpack_require__(21);
  18787. var axisHelper = __webpack_require__(109);
  18788. var zrUtil = __webpack_require__(3);
  18789. var Cartesian2D = __webpack_require__(115);
  18790. var Axis2D = __webpack_require__(117);
  18791. var each = zrUtil.each;
  18792. var ifAxisCrossZero = axisHelper.ifAxisCrossZero;
  18793. var niceScaleExtent = axisHelper.niceScaleExtent;
  18794. // 依赖 GridModel, AxisModel 做预处理
  18795. __webpack_require__(120);
  18796. /**
  18797. * Check if the axis is used in the specified grid
  18798. * @inner
  18799. */
  18800. function isAxisUsedInTheGrid(axisModel, gridModel, ecModel) {
  18801. return ecModel.getComponent('grid', axisModel.get('gridIndex')) === gridModel;
  18802. }
  18803. function getLabelUnionRect(axis) {
  18804. var axisModel = axis.model;
  18805. var labels = axisModel.getFormattedLabels();
  18806. var rect;
  18807. var step = 1;
  18808. var labelCount = labels.length;
  18809. if (labelCount > 40) {
  18810. // Simple optimization for large amount of labels
  18811. step = Math.ceil(labelCount / 40);
  18812. }
  18813. for (var i = 0; i < labelCount; i += step) {
  18814. if (!axis.isLabelIgnored(i)) {
  18815. var singleRect = axisModel.getTextRect(labels[i]);
  18816. // FIXME consider label rotate
  18817. rect ? rect.union(singleRect) : (rect = singleRect);
  18818. }
  18819. }
  18820. return rect;
  18821. }
  18822. function Grid(gridModel, ecModel, api) {
  18823. /**
  18824. * @type {Object.<string, module:echarts/coord/cartesian/Cartesian2D>}
  18825. * @private
  18826. */
  18827. this._coordsMap = {};
  18828. /**
  18829. * @type {Array.<module:echarts/coord/cartesian/Cartesian>}
  18830. * @private
  18831. */
  18832. this._coordsList = [];
  18833. /**
  18834. * @type {Object.<string, module:echarts/coord/cartesian/Axis2D>}
  18835. * @private
  18836. */
  18837. this._axesMap = {};
  18838. /**
  18839. * @type {Array.<module:echarts/coord/cartesian/Axis2D>}
  18840. * @private
  18841. */
  18842. this._axesList = [];
  18843. this._initCartesian(gridModel, ecModel, api);
  18844. this._model = gridModel;
  18845. }
  18846. var gridProto = Grid.prototype;
  18847. gridProto.type = 'grid';
  18848. gridProto.getRect = function () {
  18849. return this._rect;
  18850. };
  18851. gridProto.update = function (ecModel, api) {
  18852. var axesMap = this._axesMap;
  18853. this._updateScale(ecModel, this._model);
  18854. function ifAxisCanNotOnZero(otherAxisDim) {
  18855. var axes = axesMap[otherAxisDim];
  18856. for (var idx in axes) {
  18857. var axis = axes[idx];
  18858. if (axis && (axis.type === 'category' || !ifAxisCrossZero(axis))) {
  18859. return true;
  18860. }
  18861. }
  18862. return false;
  18863. }
  18864. each(axesMap.x, function (xAxis) {
  18865. niceScaleExtent(xAxis, xAxis.model);
  18866. });
  18867. each(axesMap.y, function (yAxis) {
  18868. niceScaleExtent(yAxis, yAxis.model);
  18869. });
  18870. // Fix configuration
  18871. each(axesMap.x, function (xAxis) {
  18872. // onZero can not be enabled in these two situations
  18873. // 1. When any other axis is a category axis
  18874. // 2. When any other axis not across 0 point
  18875. if (ifAxisCanNotOnZero('y')) {
  18876. xAxis.onZero = false;
  18877. }
  18878. });
  18879. each(axesMap.y, function (yAxis) {
  18880. if (ifAxisCanNotOnZero('x')) {
  18881. yAxis.onZero = false;
  18882. }
  18883. });
  18884. // Resize again if containLabel is enabled
  18885. // FIXME It may cause getting wrong grid size in data processing stage
  18886. this.resize(this._model, api);
  18887. };
  18888. /**
  18889. * Resize the grid
  18890. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  18891. * @param {module:echarts/ExtensionAPI} api
  18892. */
  18893. gridProto.resize = function (gridModel, api) {
  18894. var gridRect = layout.getLayoutRect(
  18895. gridModel.getBoxLayoutParams(), {
  18896. width: api.getWidth(),
  18897. height: api.getHeight()
  18898. });
  18899. this._rect = gridRect;
  18900. var axesList = this._axesList;
  18901. adjustAxes();
  18902. // Minus label size
  18903. if (gridModel.get('containLabel')) {
  18904. each(axesList, function (axis) {
  18905. if (!axis.model.get('axisLabel.inside')) {
  18906. var labelUnionRect = getLabelUnionRect(axis);
  18907. if (labelUnionRect) {
  18908. var dim = axis.isHorizontal() ? 'height' : 'width';
  18909. var margin = axis.model.get('axisLabel.margin');
  18910. gridRect[dim] -= labelUnionRect[dim] + margin;
  18911. if (axis.position === 'top') {
  18912. gridRect.y += labelUnionRect.height + margin;
  18913. }
  18914. else if (axis.position === 'left') {
  18915. gridRect.x += labelUnionRect.width + margin;
  18916. }
  18917. }
  18918. }
  18919. });
  18920. adjustAxes();
  18921. }
  18922. function adjustAxes() {
  18923. each(axesList, function (axis) {
  18924. var isHorizontal = axis.isHorizontal();
  18925. var extent = isHorizontal ? [0, gridRect.width] : [0, gridRect.height];
  18926. var idx = axis.inverse ? 1 : 0;
  18927. axis.setExtent(extent[idx], extent[1 - idx]);
  18928. updateAxisTransfrom(axis, isHorizontal ? gridRect.x : gridRect.y);
  18929. });
  18930. }
  18931. };
  18932. /**
  18933. * @param {string} axisType
  18934. * @param {ndumber} [axisIndex]
  18935. */
  18936. gridProto.getAxis = function (axisType, axisIndex) {
  18937. var axesMapOnDim = this._axesMap[axisType];
  18938. if (axesMapOnDim != null) {
  18939. if (axisIndex == null) {
  18940. // Find first axis
  18941. for (var name in axesMapOnDim) {
  18942. return axesMapOnDim[name];
  18943. }
  18944. }
  18945. return axesMapOnDim[axisIndex];
  18946. }
  18947. };
  18948. gridProto.getCartesian = function (xAxisIndex, yAxisIndex) {
  18949. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  18950. return this._coordsMap[key];
  18951. };
  18952. /**
  18953. * Initialize cartesian coordinate systems
  18954. * @private
  18955. */
  18956. gridProto._initCartesian = function (gridModel, ecModel, api) {
  18957. var axisPositionUsed = {
  18958. left: false,
  18959. right: false,
  18960. top: false,
  18961. bottom: false
  18962. };
  18963. var axesMap = {
  18964. x: {},
  18965. y: {}
  18966. };
  18967. var axesCount = {
  18968. x: 0,
  18969. y: 0
  18970. };
  18971. /// Create axis
  18972. ecModel.eachComponent('xAxis', createAxisCreator('x'), this);
  18973. ecModel.eachComponent('yAxis', createAxisCreator('y'), this);
  18974. if (!axesCount.x || !axesCount.y) {
  18975. // Roll back when there no either x or y axis
  18976. this._axesMap = {};
  18977. this._axesList = [];
  18978. return;
  18979. }
  18980. this._axesMap = axesMap;
  18981. /// Create cartesian2d
  18982. each(axesMap.x, function (xAxis, xAxisIndex) {
  18983. each(axesMap.y, function (yAxis, yAxisIndex) {
  18984. var key = 'x' + xAxisIndex + 'y' + yAxisIndex;
  18985. var cartesian = new Cartesian2D(key);
  18986. cartesian.grid = this;
  18987. this._coordsMap[key] = cartesian;
  18988. this._coordsList.push(cartesian);
  18989. cartesian.addAxis(xAxis);
  18990. cartesian.addAxis(yAxis);
  18991. }, this);
  18992. }, this);
  18993. function createAxisCreator(axisType) {
  18994. return function (axisModel, idx) {
  18995. if (!isAxisUsedInTheGrid(axisModel, gridModel, ecModel)) {
  18996. return;
  18997. }
  18998. var axisPosition = axisModel.get('position');
  18999. if (axisType === 'x') {
  19000. // Fix position
  19001. if (axisPosition !== 'top' && axisPosition !== 'bottom') {
  19002. // Default bottom of X
  19003. axisPosition = 'bottom';
  19004. }
  19005. if (axisPositionUsed[axisPosition]) {
  19006. axisPosition = axisPosition === 'top' ? 'bottom' : 'top';
  19007. }
  19008. }
  19009. else {
  19010. // Fix position
  19011. if (axisPosition !== 'left' && axisPosition !== 'right') {
  19012. // Default left of Y
  19013. axisPosition = 'left';
  19014. }
  19015. if (axisPositionUsed[axisPosition]) {
  19016. axisPosition = axisPosition === 'left' ? 'right' : 'left';
  19017. }
  19018. }
  19019. axisPositionUsed[axisPosition] = true;
  19020. var axis = new Axis2D(
  19021. axisType, axisHelper.createScaleByModel(axisModel),
  19022. [0, 0],
  19023. axisModel.get('type'),
  19024. axisPosition
  19025. );
  19026. var isCategory = axis.type === 'category';
  19027. axis.onBand = isCategory && axisModel.get('boundaryGap');
  19028. axis.inverse = axisModel.get('inverse');
  19029. axis.onZero = axisModel.get('axisLine.onZero');
  19030. // Inject axis into axisModel
  19031. axisModel.axis = axis;
  19032. // Inject axisModel into axis
  19033. axis.model = axisModel;
  19034. // Index of axis, can be used as key
  19035. axis.index = idx;
  19036. this._axesList.push(axis);
  19037. axesMap[axisType][idx] = axis;
  19038. axesCount[axisType]++;
  19039. };
  19040. }
  19041. };
  19042. /**
  19043. * Update cartesian properties from series
  19044. * @param {module:echarts/model/Option} option
  19045. * @private
  19046. */
  19047. gridProto._updateScale = function (ecModel, gridModel) {
  19048. // Reset scale
  19049. zrUtil.each(this._axesList, function (axis) {
  19050. axis.scale.setExtent(Infinity, -Infinity);
  19051. });
  19052. ecModel.eachSeries(function (seriesModel) {
  19053. if (seriesModel.get('coordinateSystem') === 'cartesian2d') {
  19054. var xAxisIndex = seriesModel.get('xAxisIndex');
  19055. var yAxisIndex = seriesModel.get('yAxisIndex');
  19056. var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex);
  19057. var yAxisModel = ecModel.getComponent('yAxis', yAxisIndex);
  19058. if (!isAxisUsedInTheGrid(xAxisModel, gridModel, ecModel)
  19059. || !isAxisUsedInTheGrid(yAxisModel, gridModel, ecModel)
  19060. ) {
  19061. return;
  19062. }
  19063. var cartesian = this.getCartesian(xAxisIndex, yAxisIndex);
  19064. var data = seriesModel.getData();
  19065. var xAxis = cartesian.getAxis('x');
  19066. var yAxis = cartesian.getAxis('y');
  19067. if (data.type === 'list') {
  19068. unionExtent(data, xAxis, seriesModel);
  19069. unionExtent(data, yAxis, seriesModel);
  19070. }
  19071. }
  19072. }, this);
  19073. function unionExtent(data, axis, seriesModel) {
  19074. each(seriesModel.coordDimToDataDim(axis.dim), function (dim) {
  19075. axis.scale.unionExtent(data.getDataExtent(
  19076. dim, axis.scale.type !== 'ordinal'
  19077. ));
  19078. });
  19079. }
  19080. };
  19081. /**
  19082. * @inner
  19083. */
  19084. function updateAxisTransfrom(axis, coordBase) {
  19085. var axisExtent = axis.getExtent();
  19086. var axisExtentSum = axisExtent[0] + axisExtent[1];
  19087. // Fast transform
  19088. axis.toGlobalCoord = axis.dim === 'x'
  19089. ? function (coord) {
  19090. return coord + coordBase;
  19091. }
  19092. : function (coord) {
  19093. return axisExtentSum - coord + coordBase;
  19094. };
  19095. axis.toLocalCoord = axis.dim === 'x'
  19096. ? function (coord) {
  19097. return coord - coordBase;
  19098. }
  19099. : function (coord) {
  19100. return axisExtentSum - coord + coordBase;
  19101. };
  19102. }
  19103. Grid.create = function (ecModel, api) {
  19104. var grids = [];
  19105. ecModel.eachComponent('grid', function (gridModel, idx) {
  19106. var grid = new Grid(gridModel, ecModel, api);
  19107. grid.name = 'grid_' + idx;
  19108. grid.resize(gridModel, api);
  19109. gridModel.coordinateSystem = grid;
  19110. grids.push(grid);
  19111. });
  19112. // Inject the coordinateSystems into seriesModel
  19113. ecModel.eachSeries(function (seriesModel) {
  19114. if (seriesModel.get('coordinateSystem') !== 'cartesian2d') {
  19115. return;
  19116. }
  19117. var xAxisIndex = seriesModel.get('xAxisIndex');
  19118. // TODO Validate
  19119. var xAxisModel = ecModel.getComponent('xAxis', xAxisIndex);
  19120. var grid = grids[xAxisModel.get('gridIndex')];
  19121. seriesModel.coordinateSystem = grid.getCartesian(
  19122. xAxisIndex, seriesModel.get('yAxisIndex')
  19123. );
  19124. });
  19125. return grids;
  19126. };
  19127. // For deciding which dimensions to use when creating list data
  19128. Grid.dimensions = Cartesian2D.prototype.dimensions;
  19129. __webpack_require__(25).register('cartesian2d', Grid);
  19130. module.exports = Grid;
  19131. /***/ },
  19132. /* 109 */
  19133. /***/ function(module, exports, __webpack_require__) {
  19134. var OrdinalScale = __webpack_require__(110);
  19135. var IntervalScale = __webpack_require__(112);
  19136. __webpack_require__(113);
  19137. __webpack_require__(114);
  19138. var Scale = __webpack_require__(111);
  19139. var numberUtil = __webpack_require__(7);
  19140. var zrUtil = __webpack_require__(3);
  19141. var textContain = __webpack_require__(14);
  19142. var axisHelper = {};
  19143. /**
  19144. * Get axis scale extent before niced.
  19145. */
  19146. axisHelper.getScaleExtent = function (axis, model) {
  19147. var scale = axis.scale;
  19148. var originalExtent = scale.getExtent();
  19149. var span = originalExtent[1] - originalExtent[0];
  19150. if (scale.type === 'ordinal') {
  19151. // If series has no data, scale extent may be wrong
  19152. if (!isFinite(span)) {
  19153. return [0, 0];
  19154. }
  19155. else {
  19156. return originalExtent;
  19157. }
  19158. }
  19159. var min = model.getMin ? model.getMin() : model.get('min');
  19160. var max = model.getMax ? model.getMax() : model.get('max');
  19161. var crossZero = model.getNeedCrossZero
  19162. ? model.getNeedCrossZero() : !model.get('scale');
  19163. var boundaryGap = model.get('boundaryGap');
  19164. if (!zrUtil.isArray(boundaryGap)) {
  19165. boundaryGap = [boundaryGap || 0, boundaryGap || 0];
  19166. }
  19167. boundaryGap[0] = numberUtil.parsePercent(boundaryGap[0], 1);
  19168. boundaryGap[1] = numberUtil.parsePercent(boundaryGap[1], 1);
  19169. var fixMin = true;
  19170. var fixMax = true;
  19171. // Add boundary gap
  19172. if (min == null) {
  19173. min = originalExtent[0] - boundaryGap[0] * span;
  19174. fixMin = false;
  19175. }
  19176. if (max == null) {
  19177. max = originalExtent[1] + boundaryGap[1] * span;
  19178. fixMax = false;
  19179. }
  19180. if (min === 'dataMin') {
  19181. min = originalExtent[0];
  19182. }
  19183. if (max === 'dataMax') {
  19184. max = originalExtent[1];
  19185. }
  19186. // Evaluate if axis needs cross zero
  19187. if (crossZero) {
  19188. // Axis is over zero and min is not set
  19189. if (min > 0 && max > 0 && !fixMin) {
  19190. min = 0;
  19191. }
  19192. // Axis is under zero and max is not set
  19193. if (min < 0 && max < 0 && !fixMax) {
  19194. max = 0;
  19195. }
  19196. }
  19197. return [min, max];
  19198. };
  19199. axisHelper.niceScaleExtent = function (axis, model) {
  19200. var scale = axis.scale;
  19201. var extent = axisHelper.getScaleExtent(axis, model);
  19202. var fixMin = (model.getMin ? model.getMin() : model.get('min')) != null;
  19203. var fixMax = (model.getMax ? model.getMax() : model.get('max')) != null;
  19204. var splitNumber = model.get('splitNumber');
  19205. scale.setExtent(extent[0], extent[1]);
  19206. scale.niceExtent(splitNumber, fixMin, fixMax);
  19207. // Use minInterval to constraint the calculated interval.
  19208. // If calculated interval is less than minInterval. increase the interval quantity until
  19209. // it is larger than minInterval.
  19210. // For example:
  19211. // minInterval is 1, calculated interval is 0.2, so increase it to be 1. In this way we can get
  19212. // an integer axis.
  19213. var minInterval = model.get('minInterval');
  19214. if (isFinite(minInterval) && !fixMin && !fixMax && scale.type === 'interval') {
  19215. var interval = scale.getInterval();
  19216. var intervalScale = Math.max(Math.abs(interval), minInterval) / interval;
  19217. // while (interval < minInterval) {
  19218. // var quantity = numberUtil.quantity(interval);
  19219. // interval = quantity * 10;
  19220. // scaleQuantity *= 10;
  19221. // }
  19222. extent = scale.getExtent();
  19223. scale.setExtent(intervalScale * extent[0], extent[1] * intervalScale);
  19224. scale.niceExtent(splitNumber);
  19225. }
  19226. // If some one specified the min, max. And the default calculated interval
  19227. // is not good enough. He can specify the interval. It is often appeared
  19228. // in angle axis with angle 0 - 360. Interval calculated in interval scale is hard
  19229. // to be 60.
  19230. // FIXME
  19231. var interval = model.get('interval');
  19232. if (interval != null) {
  19233. scale.setInterval && scale.setInterval(interval);
  19234. }
  19235. };
  19236. /**
  19237. * @param {module:echarts/model/Model} model
  19238. * @param {string} [axisType] Default retrieve from model.type
  19239. * @return {module:echarts/scale/*}
  19240. */
  19241. axisHelper.createScaleByModel = function(model, axisType) {
  19242. axisType = axisType || model.get('type');
  19243. if (axisType) {
  19244. switch (axisType) {
  19245. // Buildin scale
  19246. case 'category':
  19247. return new OrdinalScale(
  19248. model.getCategories(), [Infinity, -Infinity]
  19249. );
  19250. case 'value':
  19251. return new IntervalScale();
  19252. // Extended scale, like time and log
  19253. default:
  19254. return (Scale.getClass(axisType) || IntervalScale).create(model);
  19255. }
  19256. }
  19257. };
  19258. /**
  19259. * Check if the axis corss 0
  19260. */
  19261. axisHelper.ifAxisCrossZero = function (axis) {
  19262. var dataExtent = axis.scale.getExtent();
  19263. var min = dataExtent[0];
  19264. var max = dataExtent[1];
  19265. return !((min > 0 && max > 0) || (min < 0 && max < 0));
  19266. };
  19267. /**
  19268. * @param {Array.<number>} tickCoords In axis self coordinate.
  19269. * @param {Array.<string>} labels
  19270. * @param {string} font
  19271. * @param {boolean} isAxisHorizontal
  19272. * @return {number}
  19273. */
  19274. axisHelper.getAxisLabelInterval = function (tickCoords, labels, font, isAxisHorizontal) {
  19275. // FIXME
  19276. // 不同角的axis和label,不只是horizontal和vertical.
  19277. var textSpaceTakenRect;
  19278. var autoLabelInterval = 0;
  19279. var accumulatedLabelInterval = 0;
  19280. var step = 1;
  19281. if (labels.length > 40) {
  19282. // Simple optimization for large amount of labels
  19283. step = Math.round(labels.length / 40);
  19284. }
  19285. for (var i = 0; i < tickCoords.length; i += step) {
  19286. var tickCoord = tickCoords[i];
  19287. var rect = textContain.getBoundingRect(
  19288. labels[i], font, 'center', 'top'
  19289. );
  19290. rect[isAxisHorizontal ? 'x' : 'y'] += tickCoord;
  19291. rect[isAxisHorizontal ? 'width' : 'height'] *= 1.5;
  19292. if (!textSpaceTakenRect) {
  19293. textSpaceTakenRect = rect.clone();
  19294. }
  19295. // There is no space for current label;
  19296. else if (textSpaceTakenRect.intersect(rect)) {
  19297. accumulatedLabelInterval++;
  19298. autoLabelInterval = Math.max(autoLabelInterval, accumulatedLabelInterval);
  19299. }
  19300. else {
  19301. textSpaceTakenRect.union(rect);
  19302. // Reset
  19303. accumulatedLabelInterval = 0;
  19304. }
  19305. }
  19306. if (autoLabelInterval === 0 && step > 1) {
  19307. return step;
  19308. }
  19309. return autoLabelInterval * step;
  19310. };
  19311. /**
  19312. * @param {Object} axis
  19313. * @param {Function} labelFormatter
  19314. * @return {Array.<string>}
  19315. */
  19316. axisHelper.getFormattedLabels = function (axis, labelFormatter) {
  19317. var scale = axis.scale;
  19318. var labels = scale.getTicksLabels();
  19319. var ticks = scale.getTicks();
  19320. if (typeof labelFormatter === 'string') {
  19321. labelFormatter = (function (tpl) {
  19322. return function (val) {
  19323. return tpl.replace('{value}', val);
  19324. };
  19325. })(labelFormatter);
  19326. return zrUtil.map(labels, labelFormatter);
  19327. }
  19328. else if (typeof labelFormatter === 'function') {
  19329. return zrUtil.map(ticks, function (tick, idx) {
  19330. return labelFormatter(
  19331. axis.type === 'category' ? scale.getLabel(tick) : tick,
  19332. idx
  19333. );
  19334. }, this);
  19335. }
  19336. else {
  19337. return labels;
  19338. }
  19339. };
  19340. module.exports = axisHelper;
  19341. /***/ },
  19342. /* 110 */
  19343. /***/ function(module, exports, __webpack_require__) {
  19344. /**
  19345. * Linear continuous scale
  19346. * @module echarts/coord/scale/Ordinal
  19347. *
  19348. * http://en.wikipedia.org/wiki/Level_of_measurement
  19349. */
  19350. // FIXME only one data
  19351. var zrUtil = __webpack_require__(3);
  19352. var Scale = __webpack_require__(111);
  19353. var scaleProto = Scale.prototype;
  19354. var OrdinalScale = Scale.extend({
  19355. type: 'ordinal',
  19356. init: function (data, extent) {
  19357. this._data = data;
  19358. this._extent = extent || [0, data.length - 1];
  19359. },
  19360. parse: function (val) {
  19361. return typeof val === 'string'
  19362. ? zrUtil.indexOf(this._data, val)
  19363. // val might be float.
  19364. : Math.round(val);
  19365. },
  19366. contain: function (rank) {
  19367. rank = this.parse(rank);
  19368. return scaleProto.contain.call(this, rank)
  19369. && this._data[rank] != null;
  19370. },
  19371. /**
  19372. * Normalize given rank or name to linear [0, 1]
  19373. * @param {number|string} [val]
  19374. * @return {number}
  19375. */
  19376. normalize: function (val) {
  19377. return scaleProto.normalize.call(this, this.parse(val));
  19378. },
  19379. scale: function (val) {
  19380. return Math.round(scaleProto.scale.call(this, val));
  19381. },
  19382. /**
  19383. * @return {Array}
  19384. */
  19385. getTicks: function () {
  19386. var ticks = [];
  19387. var extent = this._extent;
  19388. var rank = extent[0];
  19389. while (rank <= extent[1]) {
  19390. ticks.push(rank);
  19391. rank++;
  19392. }
  19393. return ticks;
  19394. },
  19395. /**
  19396. * Get item on rank n
  19397. * @param {number} n
  19398. * @return {string}
  19399. */
  19400. getLabel: function (n) {
  19401. return this._data[n];
  19402. },
  19403. /**
  19404. * @return {number}
  19405. */
  19406. count: function () {
  19407. return this._extent[1] - this._extent[0] + 1;
  19408. },
  19409. niceTicks: zrUtil.noop,
  19410. niceExtent: zrUtil.noop
  19411. });
  19412. /**
  19413. * @return {module:echarts/scale/Time}
  19414. */
  19415. OrdinalScale.create = function () {
  19416. return new OrdinalScale();
  19417. };
  19418. module.exports = OrdinalScale;
  19419. /***/ },
  19420. /* 111 */
  19421. /***/ function(module, exports, __webpack_require__) {
  19422. /**
  19423. * // Scale class management
  19424. * @module echarts/scale/Scale
  19425. */
  19426. var clazzUtil = __webpack_require__(9);
  19427. function Scale() {
  19428. /**
  19429. * Extent
  19430. * @type {Array.<number>}
  19431. * @protected
  19432. */
  19433. this._extent = [Infinity, -Infinity];
  19434. /**
  19435. * Step is calculated in adjustExtent
  19436. * @type {Array.<number>}
  19437. * @protected
  19438. */
  19439. this._interval = 0;
  19440. this.init && this.init.apply(this, arguments);
  19441. }
  19442. var scaleProto = Scale.prototype;
  19443. /**
  19444. * Parse input val to valid inner number.
  19445. * @param {*} val
  19446. * @return {number}
  19447. */
  19448. scaleProto.parse = function (val) {
  19449. // Notice: This would be a trap here, If the implementation
  19450. // of this method depends on extent, and this method is used
  19451. // before extent set (like in dataZoom), it would be wrong.
  19452. // Nevertheless, parse does not depend on extent generally.
  19453. return val;
  19454. };
  19455. scaleProto.contain = function (val) {
  19456. var extent = this._extent;
  19457. return val >= extent[0] && val <= extent[1];
  19458. };
  19459. /**
  19460. * Normalize value to linear [0, 1], return 0.5 if extent span is 0
  19461. * @param {number} val
  19462. * @return {number}
  19463. */
  19464. scaleProto.normalize = function (val) {
  19465. var extent = this._extent;
  19466. if (extent[1] === extent[0]) {
  19467. return 0.5;
  19468. }
  19469. return (val - extent[0]) / (extent[1] - extent[0]);
  19470. };
  19471. /**
  19472. * Scale normalized value
  19473. * @param {number} val
  19474. * @return {number}
  19475. */
  19476. scaleProto.scale = function (val) {
  19477. var extent = this._extent;
  19478. return val * (extent[1] - extent[0]) + extent[0];
  19479. };
  19480. /**
  19481. * Set extent from data
  19482. * @param {Array.<number>} other
  19483. */
  19484. scaleProto.unionExtent = function (other) {
  19485. var extent = this._extent;
  19486. other[0] < extent[0] && (extent[0] = other[0]);
  19487. other[1] > extent[1] && (extent[1] = other[1]);
  19488. // not setExtent because in log axis it may transformed to power
  19489. // this.setExtent(extent[0], extent[1]);
  19490. };
  19491. /**
  19492. * Get extent
  19493. * @return {Array.<number>}
  19494. */
  19495. scaleProto.getExtent = function () {
  19496. return this._extent.slice();
  19497. };
  19498. /**
  19499. * Set extent
  19500. * @param {number} start
  19501. * @param {number} end
  19502. */
  19503. scaleProto.setExtent = function (start, end) {
  19504. var thisExtent = this._extent;
  19505. if (!isNaN(start)) {
  19506. thisExtent[0] = start;
  19507. }
  19508. if (!isNaN(end)) {
  19509. thisExtent[1] = end;
  19510. }
  19511. };
  19512. /**
  19513. * @return {Array.<string>}
  19514. */
  19515. scaleProto.getTicksLabels = function () {
  19516. var labels = [];
  19517. var ticks = this.getTicks();
  19518. for (var i = 0; i < ticks.length; i++) {
  19519. labels.push(this.getLabel(ticks[i]));
  19520. }
  19521. return labels;
  19522. };
  19523. clazzUtil.enableClassExtend(Scale);
  19524. clazzUtil.enableClassManagement(Scale, {
  19525. registerWhenExtend: true
  19526. });
  19527. module.exports = Scale;
  19528. /***/ },
  19529. /* 112 */
  19530. /***/ function(module, exports, __webpack_require__) {
  19531. /**
  19532. * Interval scale
  19533. * @module echarts/scale/Interval
  19534. */
  19535. var numberUtil = __webpack_require__(7);
  19536. var formatUtil = __webpack_require__(6);
  19537. var Scale = __webpack_require__(111);
  19538. var mathFloor = Math.floor;
  19539. var mathCeil = Math.ceil;
  19540. /**
  19541. * @alias module:echarts/coord/scale/Interval
  19542. * @constructor
  19543. */
  19544. var IntervalScale = Scale.extend({
  19545. type: 'interval',
  19546. _interval: 0,
  19547. setExtent: function (start, end) {
  19548. var thisExtent = this._extent;
  19549. //start,end may be a Number like '25',so...
  19550. if (!isNaN(start)) {
  19551. thisExtent[0] = parseFloat(start);
  19552. }
  19553. if (!isNaN(end)) {
  19554. thisExtent[1] = parseFloat(end);
  19555. }
  19556. },
  19557. unionExtent: function (other) {
  19558. var extent = this._extent;
  19559. other[0] < extent[0] && (extent[0] = other[0]);
  19560. other[1] > extent[1] && (extent[1] = other[1]);
  19561. // unionExtent may called by it's sub classes
  19562. IntervalScale.prototype.setExtent.call(this, extent[0], extent[1]);
  19563. },
  19564. /**
  19565. * Get interval
  19566. */
  19567. getInterval: function () {
  19568. if (!this._interval) {
  19569. this.niceTicks();
  19570. }
  19571. return this._interval;
  19572. },
  19573. /**
  19574. * Set interval
  19575. */
  19576. setInterval: function (interval) {
  19577. this._interval = interval;
  19578. // Dropped auto calculated niceExtent and use user setted extent
  19579. // We assume user wan't to set both interval, min, max to get a better result
  19580. this._niceExtent = this._extent.slice();
  19581. },
  19582. /**
  19583. * @return {Array.<number>}
  19584. */
  19585. getTicks: function () {
  19586. if (!this._interval) {
  19587. this.niceTicks();
  19588. }
  19589. var interval = this._interval;
  19590. var extent = this._extent;
  19591. var ticks = [];
  19592. // Consider this case: using dataZoom toolbox, zoom and zoom.
  19593. var safeLimit = 10000;
  19594. if (interval) {
  19595. var niceExtent = this._niceExtent;
  19596. if (extent[0] < niceExtent[0]) {
  19597. ticks.push(extent[0]);
  19598. }
  19599. var tick = niceExtent[0];
  19600. while (tick <= niceExtent[1]) {
  19601. ticks.push(tick);
  19602. // Avoid rounding error
  19603. tick = numberUtil.round(tick + interval);
  19604. if (ticks.length > safeLimit) {
  19605. return [];
  19606. }
  19607. }
  19608. if (extent[1] > niceExtent[1]) {
  19609. ticks.push(extent[1]);
  19610. }
  19611. }
  19612. return ticks;
  19613. },
  19614. /**
  19615. * @return {Array.<string>}
  19616. */
  19617. getTicksLabels: function () {
  19618. var labels = [];
  19619. var ticks = this.getTicks();
  19620. for (var i = 0; i < ticks.length; i++) {
  19621. labels.push(this.getLabel(ticks[i]));
  19622. }
  19623. return labels;
  19624. },
  19625. /**
  19626. * @param {number} n
  19627. * @return {number}
  19628. */
  19629. getLabel: function (data) {
  19630. return formatUtil.addCommas(data);
  19631. },
  19632. /**
  19633. * Update interval and extent of intervals for nice ticks
  19634. *
  19635. * @param {number} [splitNumber = 5] Desired number of ticks
  19636. */
  19637. niceTicks: function (splitNumber) {
  19638. splitNumber = splitNumber || 5;
  19639. var extent = this._extent;
  19640. var span = extent[1] - extent[0];
  19641. if (!isFinite(span)) {
  19642. return;
  19643. }
  19644. // User may set axis min 0 and data are all negative
  19645. // FIXME If it needs to reverse ?
  19646. if (span < 0) {
  19647. span = -span;
  19648. extent.reverse();
  19649. }
  19650. // From "Nice Numbers for Graph Labels" of Graphic Gems
  19651. // var niceSpan = numberUtil.nice(span, false);
  19652. var step = numberUtil.nice(span / splitNumber, true);
  19653. // Niced extent inside original extent
  19654. var niceExtent = [
  19655. numberUtil.round(mathCeil(extent[0] / step) * step),
  19656. numberUtil.round(mathFloor(extent[1] / step) * step)
  19657. ];
  19658. this._interval = step;
  19659. this._niceExtent = niceExtent;
  19660. },
  19661. /**
  19662. * Nice extent.
  19663. * @param {number} [splitNumber = 5] Given approx tick number
  19664. * @param {boolean} [fixMin=false]
  19665. * @param {boolean} [fixMax=false]
  19666. */
  19667. niceExtent: function (splitNumber, fixMin, fixMax) {
  19668. var extent = this._extent;
  19669. // If extent start and end are same, expand them
  19670. if (extent[0] === extent[1]) {
  19671. if (extent[0] !== 0) {
  19672. // Expand extent
  19673. var expandSize = extent[0] / 2;
  19674. extent[0] -= expandSize;
  19675. extent[1] += expandSize;
  19676. }
  19677. else {
  19678. extent[1] = 1;
  19679. }
  19680. }
  19681. var span = extent[1] - extent[0];
  19682. // If there are no data and extent are [Infinity, -Infinity]
  19683. if (!isFinite(span)) {
  19684. extent[0] = 0;
  19685. extent[1] = 1;
  19686. }
  19687. this.niceTicks(splitNumber);
  19688. // var extent = this._extent;
  19689. var interval = this._interval;
  19690. if (!fixMin) {
  19691. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  19692. }
  19693. if (!fixMax) {
  19694. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  19695. }
  19696. }
  19697. });
  19698. /**
  19699. * @return {module:echarts/scale/Time}
  19700. */
  19701. IntervalScale.create = function () {
  19702. return new IntervalScale();
  19703. };
  19704. module.exports = IntervalScale;
  19705. /***/ },
  19706. /* 113 */
  19707. /***/ function(module, exports, __webpack_require__) {
  19708. /**
  19709. * Interval scale
  19710. * @module echarts/coord/scale/Time
  19711. */
  19712. var zrUtil = __webpack_require__(3);
  19713. var numberUtil = __webpack_require__(7);
  19714. var formatUtil = __webpack_require__(6);
  19715. var IntervalScale = __webpack_require__(112);
  19716. var intervalScaleProto = IntervalScale.prototype;
  19717. var mathCeil = Math.ceil;
  19718. var mathFloor = Math.floor;
  19719. var ONE_SECOND = 1000;
  19720. var ONE_MINUTE = ONE_SECOND * 60;
  19721. var ONE_HOUR = ONE_MINUTE * 60;
  19722. var ONE_DAY = ONE_HOUR * 24;
  19723. // FIXME 公用?
  19724. var bisect = function (a, x, lo, hi) {
  19725. while (lo < hi) {
  19726. var mid = lo + hi >>> 1;
  19727. if (a[mid][2] < x) {
  19728. lo = mid + 1;
  19729. }
  19730. else {
  19731. hi = mid;
  19732. }
  19733. }
  19734. return lo;
  19735. };
  19736. /**
  19737. * @alias module:echarts/coord/scale/Time
  19738. * @constructor
  19739. */
  19740. var TimeScale = IntervalScale.extend({
  19741. type: 'time',
  19742. // Overwrite
  19743. getLabel: function (val) {
  19744. var stepLvl = this._stepLvl;
  19745. var date = new Date(val);
  19746. return formatUtil.formatTime(stepLvl[0], date);
  19747. },
  19748. // Overwrite
  19749. niceExtent: function (approxTickNum, fixMin, fixMax) {
  19750. var extent = this._extent;
  19751. // If extent start and end are same, expand them
  19752. if (extent[0] === extent[1]) {
  19753. // Expand extent
  19754. extent[0] -= ONE_DAY;
  19755. extent[1] += ONE_DAY;
  19756. }
  19757. // If there are no data and extent are [Infinity, -Infinity]
  19758. if (extent[1] === -Infinity && extent[0] === Infinity) {
  19759. var d = new Date();
  19760. extent[1] = new Date(d.getFullYear(), d.getMonth(), d.getDate());
  19761. extent[0] = extent[1] - ONE_DAY;
  19762. }
  19763. this.niceTicks(approxTickNum);
  19764. // var extent = this._extent;
  19765. var interval = this._interval;
  19766. if (!fixMin) {
  19767. extent[0] = numberUtil.round(mathFloor(extent[0] / interval) * interval);
  19768. }
  19769. if (!fixMax) {
  19770. extent[1] = numberUtil.round(mathCeil(extent[1] / interval) * interval);
  19771. }
  19772. },
  19773. // Overwrite
  19774. niceTicks: function (approxTickNum) {
  19775. approxTickNum = approxTickNum || 10;
  19776. var extent = this._extent;
  19777. var span = extent[1] - extent[0];
  19778. var approxInterval = span / approxTickNum;
  19779. var scaleLevelsLen = scaleLevels.length;
  19780. var idx = bisect(scaleLevels, approxInterval, 0, scaleLevelsLen);
  19781. var level = scaleLevels[Math.min(idx, scaleLevelsLen - 1)];
  19782. var interval = level[2];
  19783. // Same with interval scale if span is much larger than 1 year
  19784. if (level[0] === 'year') {
  19785. var yearSpan = span / interval;
  19786. // From "Nice Numbers for Graph Labels" of Graphic Gems
  19787. // var niceYearSpan = numberUtil.nice(yearSpan, false);
  19788. var yearStep = numberUtil.nice(yearSpan / approxTickNum, true);
  19789. interval *= yearStep;
  19790. }
  19791. var niceExtent = [
  19792. mathCeil(extent[0] / interval) * interval,
  19793. mathFloor(extent[1] / interval) * interval
  19794. ];
  19795. this._stepLvl = level;
  19796. // Interval will be used in getTicks
  19797. this._interval = interval;
  19798. this._niceExtent = niceExtent;
  19799. },
  19800. parse: function (val) {
  19801. // val might be float.
  19802. return +numberUtil.parseDate(val);
  19803. }
  19804. });
  19805. zrUtil.each(['contain', 'normalize'], function (methodName) {
  19806. TimeScale.prototype[methodName] = function (val) {
  19807. return intervalScaleProto[methodName].call(this, this.parse(val));
  19808. };
  19809. });
  19810. // Steps from d3
  19811. var scaleLevels = [
  19812. // Format step interval
  19813. ['hh:mm:ss', 1, ONE_SECOND], // 1s
  19814. ['hh:mm:ss', 5, ONE_SECOND * 5], // 5s
  19815. ['hh:mm:ss', 10, ONE_SECOND * 10], // 10s
  19816. ['hh:mm:ss', 15, ONE_SECOND * 15], // 15s
  19817. ['hh:mm:ss', 30, ONE_SECOND * 30], // 30s
  19818. ['hh:mm\nMM-dd',1, ONE_MINUTE], // 1m
  19819. ['hh:mm\nMM-dd',5, ONE_MINUTE * 5], // 5m
  19820. ['hh:mm\nMM-dd',10, ONE_MINUTE * 10], // 10m
  19821. ['hh:mm\nMM-dd',15, ONE_MINUTE * 15], // 15m
  19822. ['hh:mm\nMM-dd',30, ONE_MINUTE * 30], // 30m
  19823. ['hh:mm\nMM-dd',1, ONE_HOUR], // 1h
  19824. ['hh:mm\nMM-dd',2, ONE_HOUR * 2], // 2h
  19825. ['hh:mm\nMM-dd',6, ONE_HOUR * 6], // 6h
  19826. ['hh:mm\nMM-dd',12, ONE_HOUR * 12], // 12h
  19827. ['MM-dd\nyyyy', 1, ONE_DAY], // 1d
  19828. ['week', 7, ONE_DAY * 7], // 7d
  19829. ['month', 1, ONE_DAY * 31], // 1M
  19830. ['quarter', 3, ONE_DAY * 380 / 4], // 3M
  19831. ['half-year', 6, ONE_DAY * 380 / 2], // 6M
  19832. ['year', 1, ONE_DAY * 380] // 1Y
  19833. ];
  19834. /**
  19835. * @return {module:echarts/scale/Time}
  19836. */
  19837. TimeScale.create = function () {
  19838. return new TimeScale();
  19839. };
  19840. module.exports = TimeScale;
  19841. /***/ },
  19842. /* 114 */
  19843. /***/ function(module, exports, __webpack_require__) {
  19844. /**
  19845. * Log scale
  19846. * @module echarts/scale/Log
  19847. */
  19848. var zrUtil = __webpack_require__(3);
  19849. var Scale = __webpack_require__(111);
  19850. var numberUtil = __webpack_require__(7);
  19851. // Use some method of IntervalScale
  19852. var IntervalScale = __webpack_require__(112);
  19853. var scaleProto = Scale.prototype;
  19854. var intervalScaleProto = IntervalScale.prototype;
  19855. var mathFloor = Math.floor;
  19856. var mathCeil = Math.ceil;
  19857. var mathPow = Math.pow;
  19858. var LOG_BASE = 10;
  19859. var mathLog = Math.log;
  19860. var LogScale = Scale.extend({
  19861. type: 'log',
  19862. /**
  19863. * @return {Array.<number>}
  19864. */
  19865. getTicks: function () {
  19866. return zrUtil.map(intervalScaleProto.getTicks.call(this), function (val) {
  19867. return numberUtil.round(mathPow(LOG_BASE, val));
  19868. });
  19869. },
  19870. /**
  19871. * @param {number} val
  19872. * @return {string}
  19873. */
  19874. getLabel: intervalScaleProto.getLabel,
  19875. /**
  19876. * @param {number} val
  19877. * @return {number}
  19878. */
  19879. scale: function (val) {
  19880. val = scaleProto.scale.call(this, val);
  19881. return mathPow(LOG_BASE, val);
  19882. },
  19883. /**
  19884. * @param {number} start
  19885. * @param {number} end
  19886. */
  19887. setExtent: function (start, end) {
  19888. start = mathLog(start) / mathLog(LOG_BASE);
  19889. end = mathLog(end) / mathLog(LOG_BASE);
  19890. intervalScaleProto.setExtent.call(this, start, end);
  19891. },
  19892. /**
  19893. * @return {number} end
  19894. */
  19895. getExtent: function () {
  19896. var extent = scaleProto.getExtent.call(this);
  19897. extent[0] = mathPow(LOG_BASE, extent[0]);
  19898. extent[1] = mathPow(LOG_BASE, extent[1]);
  19899. return extent;
  19900. },
  19901. /**
  19902. * @param {Array.<number>} extent
  19903. */
  19904. unionExtent: function (extent) {
  19905. extent[0] = mathLog(extent[0]) / mathLog(LOG_BASE);
  19906. extent[1] = mathLog(extent[1]) / mathLog(LOG_BASE);
  19907. scaleProto.unionExtent.call(this, extent);
  19908. },
  19909. /**
  19910. * Update interval and extent of intervals for nice ticks
  19911. * @param {number} [approxTickNum = 10] Given approx tick number
  19912. */
  19913. niceTicks: function (approxTickNum) {
  19914. approxTickNum = approxTickNum || 10;
  19915. var extent = this._extent;
  19916. var span = extent[1] - extent[0];
  19917. if (span === Infinity || span <= 0) {
  19918. return;
  19919. }
  19920. var interval = mathPow(10, mathFloor(mathLog(span / approxTickNum) / Math.LN10));
  19921. var err = approxTickNum / span * interval;
  19922. // Filter ticks to get closer to the desired count.
  19923. if (err <= 0.5) {
  19924. interval *= 10;
  19925. }
  19926. var niceExtent = [
  19927. numberUtil.round(mathCeil(extent[0] / interval) * interval),
  19928. numberUtil.round(mathFloor(extent[1] / interval) * interval)
  19929. ];
  19930. this._interval = interval;
  19931. this._niceExtent = niceExtent;
  19932. },
  19933. /**
  19934. * Nice extent.
  19935. * @param {number} [approxTickNum = 10] Given approx tick number
  19936. * @param {boolean} [fixMin=false]
  19937. * @param {boolean} [fixMax=false]
  19938. */
  19939. niceExtent: intervalScaleProto.niceExtent
  19940. });
  19941. zrUtil.each(['contain', 'normalize'], function (methodName) {
  19942. LogScale.prototype[methodName] = function (val) {
  19943. val = mathLog(val) / mathLog(LOG_BASE);
  19944. return scaleProto[methodName].call(this, val);
  19945. };
  19946. });
  19947. LogScale.create = function () {
  19948. return new LogScale();
  19949. };
  19950. module.exports = LogScale;
  19951. /***/ },
  19952. /* 115 */
  19953. /***/ function(module, exports, __webpack_require__) {
  19954. 'use strict';
  19955. var zrUtil = __webpack_require__(3);
  19956. var Cartesian = __webpack_require__(116);
  19957. function Cartesian2D(name) {
  19958. Cartesian.call(this, name);
  19959. }
  19960. Cartesian2D.prototype = {
  19961. constructor: Cartesian2D,
  19962. type: 'cartesian2d',
  19963. /**
  19964. * @type {Array.<string>}
  19965. * @readOnly
  19966. */
  19967. dimensions: ['x', 'y'],
  19968. /**
  19969. * Base axis will be used on stacking.
  19970. *
  19971. * @return {module:echarts/coord/cartesian/Axis2D}
  19972. */
  19973. getBaseAxis: function () {
  19974. return this.getAxesByScale('ordinal')[0]
  19975. || this.getAxesByScale('time')[0]
  19976. || this.getAxis('x');
  19977. },
  19978. /**
  19979. * If contain point
  19980. * @param {Array.<number>} point
  19981. * @return {boolean}
  19982. */
  19983. containPoint: function (point) {
  19984. var axisX = this.getAxis('x');
  19985. var axisY = this.getAxis('y');
  19986. return axisX.contain(axisX.toLocalCoord(point[0]))
  19987. && axisY.contain(axisY.toLocalCoord(point[1]));
  19988. },
  19989. /**
  19990. * If contain data
  19991. * @param {Array.<number>} data
  19992. * @return {boolean}
  19993. */
  19994. containData: function (data) {
  19995. return this.getAxis('x').containData(data[0])
  19996. && this.getAxis('y').containData(data[1]);
  19997. },
  19998. /**
  19999. * Convert series data to an array of points
  20000. * @param {module:echarts/data/List} data
  20001. * @param {boolean} stack
  20002. * @return {Array}
  20003. * Return array of points. For example:
  20004. * `[[10, 10], [20, 20], [30, 30]]`
  20005. */
  20006. dataToPoints: function (data, stack) {
  20007. return data.mapArray(['x', 'y'], function (x, y) {
  20008. return this.dataToPoint([x, y]);
  20009. }, stack, this);
  20010. },
  20011. /**
  20012. * @param {Array.<number>} data
  20013. * @param {boolean} [clamp=false]
  20014. * @return {Array.<number>}
  20015. */
  20016. dataToPoint: function (data, clamp) {
  20017. var xAxis = this.getAxis('x');
  20018. var yAxis = this.getAxis('y');
  20019. return [
  20020. xAxis.toGlobalCoord(xAxis.dataToCoord(data[0], clamp)),
  20021. yAxis.toGlobalCoord(yAxis.dataToCoord(data[1], clamp))
  20022. ];
  20023. },
  20024. /**
  20025. * @param {Array.<number>} point
  20026. * @param {boolean} [clamp=false]
  20027. * @return {Array.<number>}
  20028. */
  20029. pointToData: function (point, clamp) {
  20030. var xAxis = this.getAxis('x');
  20031. var yAxis = this.getAxis('y');
  20032. return [
  20033. xAxis.coordToData(xAxis.toLocalCoord(point[0]), clamp),
  20034. yAxis.coordToData(yAxis.toLocalCoord(point[1]), clamp)
  20035. ];
  20036. },
  20037. /**
  20038. * Get other axis
  20039. * @param {module:echarts/coord/cartesian/Axis2D} axis
  20040. */
  20041. getOtherAxis: function (axis) {
  20042. return this.getAxis(axis.dim === 'x' ? 'y' : 'x');
  20043. }
  20044. };
  20045. zrUtil.inherits(Cartesian2D, Cartesian);
  20046. module.exports = Cartesian2D;
  20047. /***/ },
  20048. /* 116 */
  20049. /***/ function(module, exports, __webpack_require__) {
  20050. 'use strict';
  20051. /**
  20052. * Cartesian coordinate system
  20053. * @module echarts/coord/Cartesian
  20054. *
  20055. */
  20056. var zrUtil = __webpack_require__(3);
  20057. function dimAxisMapper(dim) {
  20058. return this._axes[dim];
  20059. }
  20060. /**
  20061. * @alias module:echarts/coord/Cartesian
  20062. * @constructor
  20063. */
  20064. var Cartesian = function (name) {
  20065. this._axes = {};
  20066. this._dimList = [];
  20067. /**
  20068. * @type {string}
  20069. */
  20070. this.name = name || '';
  20071. };
  20072. Cartesian.prototype = {
  20073. constructor: Cartesian,
  20074. type: 'cartesian',
  20075. /**
  20076. * Get axis
  20077. * @param {number|string} dim
  20078. * @return {module:echarts/coord/Cartesian~Axis}
  20079. */
  20080. getAxis: function (dim) {
  20081. return this._axes[dim];
  20082. },
  20083. /**
  20084. * Get axes list
  20085. * @return {Array.<module:echarts/coord/Cartesian~Axis>}
  20086. */
  20087. getAxes: function () {
  20088. return zrUtil.map(this._dimList, dimAxisMapper, this);
  20089. },
  20090. /**
  20091. * Get axes list by given scale type
  20092. */
  20093. getAxesByScale: function (scaleType) {
  20094. scaleType = scaleType.toLowerCase();
  20095. return zrUtil.filter(
  20096. this.getAxes(),
  20097. function (axis) {
  20098. return axis.scale.type === scaleType;
  20099. }
  20100. );
  20101. },
  20102. /**
  20103. * Add axis
  20104. * @param {module:echarts/coord/Cartesian.Axis}
  20105. */
  20106. addAxis: function (axis) {
  20107. var dim = axis.dim;
  20108. this._axes[dim] = axis;
  20109. this._dimList.push(dim);
  20110. },
  20111. /**
  20112. * Convert data to coord in nd space
  20113. * @param {Array.<number>|Object.<string, number>} val
  20114. * @return {Array.<number>|Object.<string, number>}
  20115. */
  20116. dataToCoord: function (val) {
  20117. return this._dataCoordConvert(val, 'dataToCoord');
  20118. },
  20119. /**
  20120. * Convert coord in nd space to data
  20121. * @param {Array.<number>|Object.<string, number>} val
  20122. * @return {Array.<number>|Object.<string, number>}
  20123. */
  20124. coordToData: function (val) {
  20125. return this._dataCoordConvert(val, 'coordToData');
  20126. },
  20127. _dataCoordConvert: function (input, method) {
  20128. var dimList = this._dimList;
  20129. var output = input instanceof Array ? [] : {};
  20130. for (var i = 0; i < dimList.length; i++) {
  20131. var dim = dimList[i];
  20132. var axis = this._axes[dim];
  20133. output[dim] = axis[method](input[dim]);
  20134. }
  20135. return output;
  20136. }
  20137. };
  20138. module.exports = Cartesian;
  20139. /***/ },
  20140. /* 117 */
  20141. /***/ function(module, exports, __webpack_require__) {
  20142. var zrUtil = __webpack_require__(3);
  20143. var Axis = __webpack_require__(118);
  20144. var axisLabelInterval = __webpack_require__(119);
  20145. /**
  20146. * Extend axis 2d
  20147. * @constructor module:echarts/coord/cartesian/Axis2D
  20148. * @extends {module:echarts/coord/cartesian/Axis}
  20149. * @param {string} dim
  20150. * @param {*} scale
  20151. * @param {Array.<number>} coordExtent
  20152. * @param {string} axisType
  20153. * @param {string} position
  20154. */
  20155. var Axis2D = function (dim, scale, coordExtent, axisType, position) {
  20156. Axis.call(this, dim, scale, coordExtent);
  20157. /**
  20158. * Axis type
  20159. * - 'category'
  20160. * - 'value'
  20161. * - 'time'
  20162. * - 'log'
  20163. * @type {string}
  20164. */
  20165. this.type = axisType || 'value';
  20166. /**
  20167. * Axis position
  20168. * - 'top'
  20169. * - 'bottom'
  20170. * - 'left'
  20171. * - 'right'
  20172. */
  20173. this.position = position || 'bottom';
  20174. };
  20175. Axis2D.prototype = {
  20176. constructor: Axis2D,
  20177. /**
  20178. * Index of axis, can be used as key
  20179. */
  20180. index: 0,
  20181. /**
  20182. * If axis is on the zero position of the other axis
  20183. * @type {boolean}
  20184. */
  20185. onZero: false,
  20186. /**
  20187. * Axis model
  20188. * @param {module:echarts/coord/cartesian/AxisModel}
  20189. */
  20190. model: null,
  20191. isHorizontal: function () {
  20192. var position = this.position;
  20193. return position === 'top' || position === 'bottom';
  20194. },
  20195. getGlobalExtent: function () {
  20196. var ret = this.getExtent();
  20197. ret[0] = this.toGlobalCoord(ret[0]);
  20198. ret[1] = this.toGlobalCoord(ret[1]);
  20199. return ret;
  20200. },
  20201. /**
  20202. * @return {number}
  20203. */
  20204. getLabelInterval: function () {
  20205. var labelInterval = this._labelInterval;
  20206. if (!labelInterval) {
  20207. labelInterval = this._labelInterval = axisLabelInterval(this);
  20208. }
  20209. return labelInterval;
  20210. },
  20211. /**
  20212. * If label is ignored.
  20213. * Automatically used when axis is category and label can not be all shown
  20214. * @param {number} idx
  20215. * @return {boolean}
  20216. */
  20217. isLabelIgnored: function (idx) {
  20218. if (this.type === 'category') {
  20219. var labelInterval = this.getLabelInterval();
  20220. return ((typeof labelInterval === 'function')
  20221. && !labelInterval(idx, this.scale.getLabel(idx)))
  20222. || idx % (labelInterval + 1);
  20223. }
  20224. },
  20225. /**
  20226. * Transform global coord to local coord,
  20227. * i.e. var localCoord = axis.toLocalCoord(80);
  20228. * designate by module:echarts/coord/cartesian/Grid.
  20229. * @type {Function}
  20230. */
  20231. toLocalCoord: null,
  20232. /**
  20233. * Transform global coord to local coord,
  20234. * i.e. var globalCoord = axis.toLocalCoord(40);
  20235. * designate by module:echarts/coord/cartesian/Grid.
  20236. * @type {Function}
  20237. */
  20238. toGlobalCoord: null
  20239. };
  20240. zrUtil.inherits(Axis2D, Axis);
  20241. module.exports = Axis2D;
  20242. /***/ },
  20243. /* 118 */
  20244. /***/ function(module, exports, __webpack_require__) {
  20245. var numberUtil = __webpack_require__(7);
  20246. var linearMap = numberUtil.linearMap;
  20247. var zrUtil = __webpack_require__(3);
  20248. function fixExtentWithBands(extent, nTick) {
  20249. var size = extent[1] - extent[0];
  20250. var len = nTick;
  20251. var margin = size / len / 2;
  20252. extent[0] += margin;
  20253. extent[1] -= margin;
  20254. }
  20255. var normalizedExtent = [0, 1];
  20256. /**
  20257. * @name module:echarts/coord/CartesianAxis
  20258. * @constructor
  20259. */
  20260. var Axis = function (dim, scale, extent) {
  20261. /**
  20262. * Axis dimension. Such as 'x', 'y', 'z', 'angle', 'radius'
  20263. * @type {string}
  20264. */
  20265. this.dim = dim;
  20266. /**
  20267. * Axis scale
  20268. * @type {module:echarts/coord/scale/*}
  20269. */
  20270. this.scale = scale;
  20271. /**
  20272. * @type {Array.<number>}
  20273. * @private
  20274. */
  20275. this._extent = extent || [0, 0];
  20276. /**
  20277. * @type {boolean}
  20278. */
  20279. this.inverse = false;
  20280. /**
  20281. * Usually true when axis has a ordinal scale
  20282. * @type {boolean}
  20283. */
  20284. this.onBand = false;
  20285. };
  20286. Axis.prototype = {
  20287. constructor: Axis,
  20288. /**
  20289. * If axis extent contain given coord
  20290. * @param {number} coord
  20291. * @return {boolean}
  20292. */
  20293. contain: function (coord) {
  20294. var extent = this._extent;
  20295. var min = Math.min(extent[0], extent[1]);
  20296. var max = Math.max(extent[0], extent[1]);
  20297. return coord >= min && coord <= max;
  20298. },
  20299. /**
  20300. * If axis extent contain given data
  20301. * @param {number} data
  20302. * @return {boolean}
  20303. */
  20304. containData: function (data) {
  20305. return this.contain(this.dataToCoord(data));
  20306. },
  20307. /**
  20308. * Get coord extent.
  20309. * @return {Array.<number>}
  20310. */
  20311. getExtent: function () {
  20312. var ret = this._extent.slice();
  20313. return ret;
  20314. },
  20315. /**
  20316. * Get precision used for formatting
  20317. * @param {Array.<number>} [dataExtent]
  20318. * @return {number}
  20319. */
  20320. getPixelPrecision: function (dataExtent) {
  20321. return numberUtil.getPixelPrecision(
  20322. dataExtent || this.scale.getExtent(),
  20323. this._extent
  20324. );
  20325. },
  20326. /**
  20327. * Set coord extent
  20328. * @param {number} start
  20329. * @param {number} end
  20330. */
  20331. setExtent: function (start, end) {
  20332. var extent = this._extent;
  20333. extent[0] = start;
  20334. extent[1] = end;
  20335. },
  20336. /**
  20337. * Convert data to coord. Data is the rank if it has a ordinal scale
  20338. * @param {number} data
  20339. * @param {boolean} clamp
  20340. * @return {number}
  20341. */
  20342. dataToCoord: function (data, clamp) {
  20343. var extent = this._extent;
  20344. var scale = this.scale;
  20345. data = scale.normalize(data);
  20346. if (this.onBand && scale.type === 'ordinal') {
  20347. extent = extent.slice();
  20348. fixExtentWithBands(extent, scale.count());
  20349. }
  20350. return linearMap(data, normalizedExtent, extent, clamp);
  20351. },
  20352. /**
  20353. * Convert coord to data. Data is the rank if it has a ordinal scale
  20354. * @param {number} coord
  20355. * @param {boolean} clamp
  20356. * @return {number}
  20357. */
  20358. coordToData: function (coord, clamp) {
  20359. var extent = this._extent;
  20360. var scale = this.scale;
  20361. if (this.onBand && scale.type === 'ordinal') {
  20362. extent = extent.slice();
  20363. fixExtentWithBands(extent, scale.count());
  20364. }
  20365. var t = linearMap(coord, extent, normalizedExtent, clamp);
  20366. return this.scale.scale(t);
  20367. },
  20368. /**
  20369. * @return {Array.<number>}
  20370. */
  20371. getTicksCoords: function () {
  20372. if (this.onBand) {
  20373. var bands = this.getBands();
  20374. var coords = [];
  20375. for (var i = 0; i < bands.length; i++) {
  20376. coords.push(bands[i][0]);
  20377. }
  20378. if (bands[i - 1]) {
  20379. coords.push(bands[i - 1][1]);
  20380. }
  20381. return coords;
  20382. }
  20383. else {
  20384. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  20385. }
  20386. },
  20387. /**
  20388. * Coords of labels are on the ticks or on the middle of bands
  20389. * @return {Array.<number>}
  20390. */
  20391. getLabelsCoords: function () {
  20392. if (this.onBand) {
  20393. var bands = this.getBands();
  20394. var coords = [];
  20395. var band;
  20396. for (var i = 0; i < bands.length; i++) {
  20397. band = bands[i];
  20398. coords.push((band[0] + band[1]) / 2);
  20399. }
  20400. return coords;
  20401. }
  20402. else {
  20403. return zrUtil.map(this.scale.getTicks(), this.dataToCoord, this);
  20404. }
  20405. },
  20406. /**
  20407. * Get bands.
  20408. *
  20409. * If axis has labels [1, 2, 3, 4]. Bands on the axis are
  20410. * |---1---|---2---|---3---|---4---|.
  20411. *
  20412. * @return {Array}
  20413. */
  20414. // FIXME Situation when labels is on ticks
  20415. getBands: function () {
  20416. var extent = this.getExtent();
  20417. var bands = [];
  20418. var len = this.scale.count();
  20419. var start = extent[0];
  20420. var end = extent[1];
  20421. var span = end - start;
  20422. for (var i = 0; i < len; i++) {
  20423. bands.push([
  20424. span * i / len + start,
  20425. span * (i + 1) / len + start
  20426. ]);
  20427. }
  20428. return bands;
  20429. },
  20430. /**
  20431. * Get width of band
  20432. * @return {number}
  20433. */
  20434. getBandWidth: function () {
  20435. var axisExtent = this._extent;
  20436. var dataExtent = this.scale.getExtent();
  20437. var len = dataExtent[1] - dataExtent[0] + (this.onBand ? 1 : 0);
  20438. // Fix #2728, avoid NaN when only one data.
  20439. len === 0 && (len = 1);
  20440. var size = Math.abs(axisExtent[1] - axisExtent[0]);
  20441. return Math.abs(size) / len;
  20442. }
  20443. };
  20444. module.exports = Axis;
  20445. /***/ },
  20446. /* 119 */
  20447. /***/ function(module, exports, __webpack_require__) {
  20448. 'use strict';
  20449. /**
  20450. * Helper function for axisLabelInterval calculation
  20451. */
  20452. var zrUtil = __webpack_require__(3);
  20453. var axisHelper = __webpack_require__(109);
  20454. module.exports = function (axis) {
  20455. var axisModel = axis.model;
  20456. var labelModel = axisModel.getModel('axisLabel');
  20457. var labelInterval = labelModel.get('interval');
  20458. if (!(axis.type === 'category' && labelInterval === 'auto')) {
  20459. return labelInterval === 'auto' ? 0 : labelInterval;
  20460. }
  20461. return axisHelper.getAxisLabelInterval(
  20462. zrUtil.map(axis.scale.getTicks(), axis.dataToCoord, axis),
  20463. axisModel.getFormattedLabels(),
  20464. labelModel.getModel('textStyle').getFont(),
  20465. axis.isHorizontal()
  20466. );
  20467. };
  20468. /***/ },
  20469. /* 120 */
  20470. /***/ function(module, exports, __webpack_require__) {
  20471. 'use strict';
  20472. // Grid 是在有直角坐标系的时候必须要存在的
  20473. // 所以这里也要被 Cartesian2D 依赖
  20474. __webpack_require__(121);
  20475. var ComponentModel = __webpack_require__(19);
  20476. module.exports = ComponentModel.extend({
  20477. type: 'grid',
  20478. dependencies: ['xAxis', 'yAxis'],
  20479. layoutMode: 'box',
  20480. /**
  20481. * @type {module:echarts/coord/cartesian/Grid}
  20482. */
  20483. coordinateSystem: null,
  20484. defaultOption: {
  20485. show: false,
  20486. zlevel: 0,
  20487. z: 0,
  20488. left: '10%',
  20489. top: 60,
  20490. right: '10%',
  20491. bottom: 60,
  20492. // If grid size contain label
  20493. containLabel: false,
  20494. // width: {totalWidth} - left - right,
  20495. // height: {totalHeight} - top - bottom,
  20496. backgroundColor: 'rgba(0,0,0,0)',
  20497. borderWidth: 1,
  20498. borderColor: '#ccc'
  20499. }
  20500. });
  20501. /***/ },
  20502. /* 121 */
  20503. /***/ function(module, exports, __webpack_require__) {
  20504. 'use strict';
  20505. var ComponentModel = __webpack_require__(19);
  20506. var zrUtil = __webpack_require__(3);
  20507. var axisModelCreator = __webpack_require__(122);
  20508. var AxisModel = ComponentModel.extend({
  20509. type: 'cartesian2dAxis',
  20510. /**
  20511. * @type {module:echarts/coord/cartesian/Axis2D}
  20512. */
  20513. axis: null,
  20514. /**
  20515. * @override
  20516. */
  20517. init: function () {
  20518. AxisModel.superApply(this, 'init', arguments);
  20519. this._resetRange();
  20520. },
  20521. /**
  20522. * @override
  20523. */
  20524. mergeOption: function () {
  20525. AxisModel.superApply(this, 'mergeOption', arguments);
  20526. this._resetRange();
  20527. },
  20528. /**
  20529. * @override
  20530. */
  20531. restoreData: function () {
  20532. AxisModel.superApply(this, 'restoreData', arguments);
  20533. this._resetRange();
  20534. },
  20535. /**
  20536. * @public
  20537. * @param {number} rangeStart
  20538. * @param {number} rangeEnd
  20539. */
  20540. setRange: function (rangeStart, rangeEnd) {
  20541. this.option.rangeStart = rangeStart;
  20542. this.option.rangeEnd = rangeEnd;
  20543. },
  20544. /**
  20545. * @public
  20546. * @return {Array.<number|string|Date>}
  20547. */
  20548. getMin: function () {
  20549. var option = this.option;
  20550. return option.rangeStart != null ? option.rangeStart : option.min;
  20551. },
  20552. /**
  20553. * @public
  20554. * @return {Array.<number|string|Date>}
  20555. */
  20556. getMax: function () {
  20557. var option = this.option;
  20558. return option.rangeEnd != null ? option.rangeEnd : option.max;
  20559. },
  20560. /**
  20561. * @public
  20562. * @return {boolean}
  20563. */
  20564. getNeedCrossZero: function () {
  20565. var option = this.option;
  20566. return (option.rangeStart != null || option.rangeEnd != null)
  20567. ? false : !option.scale;
  20568. },
  20569. /**
  20570. * @private
  20571. */
  20572. _resetRange: function () {
  20573. // rangeStart and rangeEnd is readonly.
  20574. this.option.rangeStart = this.option.rangeEnd = null;
  20575. }
  20576. });
  20577. function getAxisType(axisDim, option) {
  20578. // Default axis with data is category axis
  20579. return option.type || (option.data ? 'category' : 'value');
  20580. }
  20581. zrUtil.merge(AxisModel.prototype, __webpack_require__(124));
  20582. var extraOption = {
  20583. gridIndex: 0
  20584. };
  20585. axisModelCreator('x', AxisModel, getAxisType, extraOption);
  20586. axisModelCreator('y', AxisModel, getAxisType, extraOption);
  20587. module.exports = AxisModel;
  20588. /***/ },
  20589. /* 122 */
  20590. /***/ function(module, exports, __webpack_require__) {
  20591. var axisDefault = __webpack_require__(123);
  20592. var zrUtil = __webpack_require__(3);
  20593. var ComponentModel = __webpack_require__(19);
  20594. var layout = __webpack_require__(21);
  20595. // FIXME axisType is fixed ?
  20596. var AXIS_TYPES = ['value', 'category', 'time', 'log'];
  20597. /**
  20598. * Generate sub axis model class
  20599. * @param {string} axisName 'x' 'y' 'radius' 'angle' 'parallel'
  20600. * @param {module:echarts/model/Component} BaseAxisModelClass
  20601. * @param {Function} axisTypeDefaulter
  20602. * @param {Object} [extraDefaultOption]
  20603. */
  20604. module.exports = function (axisName, BaseAxisModelClass, axisTypeDefaulter, extraDefaultOption) {
  20605. zrUtil.each(AXIS_TYPES, function (axisType) {
  20606. BaseAxisModelClass.extend({
  20607. type: axisName + 'Axis.' + axisType,
  20608. mergeDefaultAndTheme: function (option, ecModel) {
  20609. var layoutMode = this.layoutMode;
  20610. var inputPositionParams = layoutMode
  20611. ? layout.getLayoutParams(option) : {};
  20612. var themeModel = ecModel.getTheme();
  20613. zrUtil.merge(option, themeModel.get(axisType + 'Axis'));
  20614. zrUtil.merge(option, this.getDefaultOption());
  20615. option.type = axisTypeDefaulter(axisName, option);
  20616. if (layoutMode) {
  20617. layout.mergeLayoutParam(option, inputPositionParams, layoutMode);
  20618. }
  20619. },
  20620. defaultOption: zrUtil.mergeAll(
  20621. [
  20622. {},
  20623. axisDefault[axisType + 'Axis'],
  20624. extraDefaultOption
  20625. ],
  20626. true
  20627. )
  20628. });
  20629. });
  20630. ComponentModel.registerSubTypeDefaulter(
  20631. axisName + 'Axis',
  20632. zrUtil.curry(axisTypeDefaulter, axisName)
  20633. );
  20634. };
  20635. /***/ },
  20636. /* 123 */
  20637. /***/ function(module, exports, __webpack_require__) {
  20638. var zrUtil = __webpack_require__(3);
  20639. var defaultOption = {
  20640. show: true,
  20641. zlevel: 0, // 一级层叠
  20642. z: 0, // 二级层叠
  20643. // 反向坐标轴
  20644. inverse: false,
  20645. // 坐标轴名字,默认为空
  20646. name: '',
  20647. // 坐标轴名字位置,支持'start' | 'middle' | 'end'
  20648. nameLocation: 'end',
  20649. // 坐标轴文字样式,默认取全局样式
  20650. nameTextStyle: {},
  20651. // 文字与轴线距离
  20652. nameGap: 15,
  20653. // 是否能触发鼠标事件
  20654. silent: true,
  20655. // 坐标轴线
  20656. axisLine: {
  20657. // 默认显示,属性show控制显示与否
  20658. show: true,
  20659. onZero: true,
  20660. // 属性lineStyle控制线条样式
  20661. lineStyle: {
  20662. color: '#333',
  20663. width: 1,
  20664. type: 'solid'
  20665. }
  20666. },
  20667. // 坐标轴小标记
  20668. axisTick: {
  20669. // 属性show控制显示与否,默认显示
  20670. show: true,
  20671. // 控制小标记是否在grid里
  20672. inside: false,
  20673. // 属性length控制线长
  20674. length: 5,
  20675. // 属性lineStyle控制线条样式
  20676. lineStyle: {
  20677. color: '#333',
  20678. width: 1
  20679. }
  20680. },
  20681. // 坐标轴文本标签,详见axis.axisLabel
  20682. axisLabel: {
  20683. show: true,
  20684. // 控制文本标签是否在grid里
  20685. inside: false,
  20686. rotate: 0,
  20687. margin: 8,
  20688. // formatter: null,
  20689. // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  20690. textStyle: {
  20691. color: '#333',
  20692. fontSize: 12
  20693. }
  20694. },
  20695. // 分隔线
  20696. splitLine: {
  20697. // 默认显示,属性show控制显示与否
  20698. show: true,
  20699. // 属性lineStyle(详见lineStyle)控制线条样式
  20700. lineStyle: {
  20701. color: ['#ccc'],
  20702. width: 1,
  20703. type: 'solid'
  20704. }
  20705. },
  20706. // 分隔区域
  20707. splitArea: {
  20708. // 默认不显示,属性show控制显示与否
  20709. show: false,
  20710. // 属性areaStyle(详见areaStyle)控制区域样式
  20711. areaStyle: {
  20712. color: ['rgba(250,250,250,0.3)','rgba(200,200,200,0.3)']
  20713. }
  20714. }
  20715. };
  20716. var categoryAxis = zrUtil.merge({
  20717. // 类目起始和结束两端空白策略
  20718. boundaryGap: true,
  20719. // 坐标轴小标记
  20720. axisTick: {
  20721. interval: 'auto'
  20722. },
  20723. // 坐标轴文本标签,详见axis.axisLabel
  20724. axisLabel: {
  20725. interval: 'auto'
  20726. }
  20727. }, defaultOption);
  20728. var valueAxis = zrUtil.defaults({
  20729. // 数值起始和结束两端空白策略
  20730. boundaryGap: [0, 0],
  20731. // 最小值, 设置成 'dataMin' 则从数据中计算最小值
  20732. // min: null,
  20733. // 最大值,设置成 'dataMax' 则从数据中计算最大值
  20734. // max: null,
  20735. // Readonly prop, specifies start value of the range when using data zoom.
  20736. // rangeStart: null
  20737. // Readonly prop, specifies end value of the range when using data zoom.
  20738. // rangeEnd: null
  20739. // 脱离0值比例,放大聚焦到最终_min,_max区间
  20740. // scale: false,
  20741. // 分割段数,默认为5
  20742. splitNumber: 5
  20743. // Minimum interval
  20744. // minInterval: null
  20745. }, defaultOption);
  20746. // FIXME
  20747. var timeAxis = zrUtil.defaults({
  20748. scale: true,
  20749. min: 'dataMin',
  20750. max: 'dataMax'
  20751. }, valueAxis);
  20752. var logAxis = zrUtil.defaults({}, valueAxis);
  20753. logAxis.scale = true;
  20754. module.exports = {
  20755. categoryAxis: categoryAxis,
  20756. valueAxis: valueAxis,
  20757. timeAxis: timeAxis,
  20758. logAxis: logAxis
  20759. };
  20760. /***/ },
  20761. /* 124 */
  20762. /***/ function(module, exports, __webpack_require__) {
  20763. var zrUtil = __webpack_require__(3);
  20764. var axisHelper = __webpack_require__(109);
  20765. function getName(obj) {
  20766. if (zrUtil.isObject(obj) && obj.value != null) {
  20767. return obj.value;
  20768. }
  20769. else {
  20770. return obj;
  20771. }
  20772. }
  20773. /**
  20774. * Get categories
  20775. */
  20776. function getCategories() {
  20777. return this.get('type') === 'category'
  20778. && zrUtil.map(this.get('data'), getName);
  20779. }
  20780. /**
  20781. * Format labels
  20782. * @return {Array.<string>}
  20783. */
  20784. function getFormattedLabels() {
  20785. return axisHelper.getFormattedLabels(
  20786. this.axis,
  20787. this.get('axisLabel.formatter')
  20788. );
  20789. }
  20790. module.exports = {
  20791. getFormattedLabels: getFormattedLabels,
  20792. getCategories: getCategories
  20793. };
  20794. /***/ },
  20795. /* 125 */
  20796. /***/ function(module, exports, __webpack_require__) {
  20797. 'use strict';
  20798. // TODO boundaryGap
  20799. __webpack_require__(121);
  20800. __webpack_require__(126);
  20801. /***/ },
  20802. /* 126 */
  20803. /***/ function(module, exports, __webpack_require__) {
  20804. var zrUtil = __webpack_require__(3);
  20805. var graphic = __webpack_require__(42);
  20806. var AxisBuilder = __webpack_require__(127);
  20807. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick;
  20808. var getInterval = AxisBuilder.getInterval;
  20809. var axisBuilderAttrs = [
  20810. 'axisLine', 'axisLabel', 'axisTick', 'axisName'
  20811. ];
  20812. var selfBuilderAttrs = [
  20813. 'splitLine', 'splitArea'
  20814. ];
  20815. var AxisView = __webpack_require__(1).extendComponentView({
  20816. type: 'axis',
  20817. render: function (axisModel, ecModel) {
  20818. this.group.removeAll();
  20819. if (!axisModel.get('show')) {
  20820. return;
  20821. }
  20822. var gridModel = ecModel.getComponent('grid', axisModel.get('gridIndex'));
  20823. var layout = layoutAxis(gridModel, axisModel);
  20824. var axisBuilder = new AxisBuilder(axisModel, layout);
  20825. zrUtil.each(axisBuilderAttrs, axisBuilder.add, axisBuilder);
  20826. this.group.add(axisBuilder.getGroup());
  20827. zrUtil.each(selfBuilderAttrs, function (name) {
  20828. if (axisModel.get(name +'.show')) {
  20829. this['_' + name](axisModel, gridModel, layout.labelInterval);
  20830. }
  20831. }, this);
  20832. },
  20833. /**
  20834. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  20835. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  20836. * @param {number|Function} labelInterval
  20837. * @private
  20838. */
  20839. _splitLine: function (axisModel, gridModel, labelInterval) {
  20840. var axis = axisModel.axis;
  20841. var splitLineModel = axisModel.getModel('splitLine');
  20842. var lineStyleModel = splitLineModel.getModel('lineStyle');
  20843. var lineWidth = lineStyleModel.get('width');
  20844. var lineColors = lineStyleModel.get('color');
  20845. var lineInterval = getInterval(splitLineModel, labelInterval);
  20846. lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];
  20847. var gridRect = gridModel.coordinateSystem.getRect();
  20848. var isHorizontal = axis.isHorizontal();
  20849. var splitLines = [];
  20850. var lineCount = 0;
  20851. var ticksCoords = axis.getTicksCoords();
  20852. var p1 = [];
  20853. var p2 = [];
  20854. for (var i = 0; i < ticksCoords.length; i++) {
  20855. if (ifIgnoreOnTick(axis, i, lineInterval)) {
  20856. continue;
  20857. }
  20858. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  20859. if (isHorizontal) {
  20860. p1[0] = tickCoord;
  20861. p1[1] = gridRect.y;
  20862. p2[0] = tickCoord;
  20863. p2[1] = gridRect.y + gridRect.height;
  20864. }
  20865. else {
  20866. p1[0] = gridRect.x;
  20867. p1[1] = tickCoord;
  20868. p2[0] = gridRect.x + gridRect.width;
  20869. p2[1] = tickCoord;
  20870. }
  20871. var colorIndex = (lineCount++) % lineColors.length;
  20872. splitLines[colorIndex] = splitLines[colorIndex] || [];
  20873. splitLines[colorIndex].push(new graphic.Line(graphic.subPixelOptimizeLine({
  20874. shape: {
  20875. x1: p1[0],
  20876. y1: p1[1],
  20877. x2: p2[0],
  20878. y2: p2[1]
  20879. },
  20880. style: {
  20881. lineWidth: lineWidth
  20882. },
  20883. silent: true
  20884. })));
  20885. }
  20886. // Simple optimization
  20887. // Batching the lines if color are the same
  20888. var lineStyle = lineStyleModel.getLineStyle();
  20889. for (var i = 0; i < splitLines.length; i++) {
  20890. this.group.add(graphic.mergePath(splitLines[i], {
  20891. style: zrUtil.defaults({
  20892. stroke: lineColors[i % lineColors.length]
  20893. }, lineStyle),
  20894. silent: true
  20895. }));
  20896. }
  20897. },
  20898. /**
  20899. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  20900. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  20901. * @param {number|Function} labelInterval
  20902. * @private
  20903. */
  20904. _splitArea: function (axisModel, gridModel, labelInterval) {
  20905. var axis = axisModel.axis;
  20906. var splitAreaModel = axisModel.getModel('splitArea');
  20907. var areaStyleModel = splitAreaModel.getModel('areaStyle');
  20908. var areaColors = areaStyleModel.get('color');
  20909. var gridRect = gridModel.coordinateSystem.getRect();
  20910. var ticksCoords = axis.getTicksCoords();
  20911. var prevX = axis.toGlobalCoord(ticksCoords[0]);
  20912. var prevY = axis.toGlobalCoord(ticksCoords[0]);
  20913. var splitAreaRects = [];
  20914. var count = 0;
  20915. var areaInterval = getInterval(splitAreaModel, labelInterval);
  20916. areaColors = zrUtil.isArray(areaColors) ? areaColors : [areaColors];
  20917. for (var i = 1; i < ticksCoords.length; i++) {
  20918. if (ifIgnoreOnTick(axis, i, areaInterval)) {
  20919. continue;
  20920. }
  20921. var tickCoord = axis.toGlobalCoord(ticksCoords[i]);
  20922. var x;
  20923. var y;
  20924. var width;
  20925. var height;
  20926. if (axis.isHorizontal()) {
  20927. x = prevX;
  20928. y = gridRect.y;
  20929. width = tickCoord - x;
  20930. height = gridRect.height;
  20931. }
  20932. else {
  20933. x = gridRect.x;
  20934. y = prevY;
  20935. width = gridRect.width;
  20936. height = tickCoord - y;
  20937. }
  20938. var colorIndex = (count++) % areaColors.length;
  20939. splitAreaRects[colorIndex] = splitAreaRects[colorIndex] || [];
  20940. splitAreaRects[colorIndex].push(new graphic.Rect({
  20941. shape: {
  20942. x: x,
  20943. y: y,
  20944. width: width,
  20945. height: height
  20946. },
  20947. silent: true
  20948. }));
  20949. prevX = x + width;
  20950. prevY = y + height;
  20951. }
  20952. // Simple optimization
  20953. // Batching the rects if color are the same
  20954. var areaStyle = areaStyleModel.getAreaStyle();
  20955. for (var i = 0; i < splitAreaRects.length; i++) {
  20956. this.group.add(graphic.mergePath(splitAreaRects[i], {
  20957. style: zrUtil.defaults({
  20958. fill: areaColors[i % areaColors.length]
  20959. }, areaStyle),
  20960. silent: true
  20961. }));
  20962. }
  20963. }
  20964. });
  20965. AxisView.extend({
  20966. type: 'xAxis'
  20967. });
  20968. AxisView.extend({
  20969. type: 'yAxis'
  20970. });
  20971. /**
  20972. * @inner
  20973. */
  20974. function layoutAxis(gridModel, axisModel) {
  20975. var grid = gridModel.coordinateSystem;
  20976. var axis = axisModel.axis;
  20977. var layout = {};
  20978. var rawAxisPosition = axis.position;
  20979. var axisPosition = axis.onZero ? 'onZero' : rawAxisPosition;
  20980. var axisDim = axis.dim;
  20981. // [left, right, top, bottom]
  20982. var rect = grid.getRect();
  20983. var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
  20984. var posMap = {
  20985. x: {top: rectBound[2], bottom: rectBound[3]},
  20986. y: {left: rectBound[0], right: rectBound[1]}
  20987. };
  20988. posMap.x.onZero = Math.max(Math.min(getZero('y'), posMap.x.bottom), posMap.x.top);
  20989. posMap.y.onZero = Math.max(Math.min(getZero('x'), posMap.y.right), posMap.y.left);
  20990. function getZero(dim, val) {
  20991. var theAxis = grid.getAxis(dim);
  20992. return theAxis.toGlobalCoord(theAxis.dataToCoord(0));
  20993. }
  20994. // Axis position
  20995. layout.position = [
  20996. axisDim === 'y' ? posMap.y[axisPosition] : rectBound[0],
  20997. axisDim === 'x' ? posMap.x[axisPosition] : rectBound[3]
  20998. ];
  20999. // Axis rotation
  21000. var r = {x: 0, y: 1};
  21001. layout.rotation = Math.PI / 2 * r[axisDim];
  21002. // Tick and label direction, x y is axisDim
  21003. var dirMap = {top: -1, bottom: 1, left: -1, right: 1};
  21004. layout.labelDirection = layout.tickDirection = layout.nameDirection = dirMap[rawAxisPosition];
  21005. if (axis.onZero) {
  21006. layout.labelOffset = posMap[axisDim][rawAxisPosition] - posMap[axisDim].onZero;
  21007. }
  21008. if (axisModel.getModel('axisTick').get('inside')) {
  21009. layout.tickDirection = -layout.tickDirection;
  21010. }
  21011. if (axisModel.getModel('axisLabel').get('inside')) {
  21012. layout.labelDirection = -layout.labelDirection;
  21013. }
  21014. // Special label rotation
  21015. var labelRotation = axisModel.getModel('axisLabel').get('rotate');
  21016. layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
  21017. // label interval when auto mode.
  21018. layout.labelInterval = axis.getLabelInterval();
  21019. // Over splitLine and splitArea
  21020. layout.z2 = 1;
  21021. return layout;
  21022. }
  21023. /***/ },
  21024. /* 127 */
  21025. /***/ function(module, exports, __webpack_require__) {
  21026. var zrUtil = __webpack_require__(3);
  21027. var graphic = __webpack_require__(42);
  21028. var Model = __webpack_require__(8);
  21029. var numberUtil = __webpack_require__(7);
  21030. var remRadian = numberUtil.remRadian;
  21031. var isRadianAroundZero = numberUtil.isRadianAroundZero;
  21032. var PI = Math.PI;
  21033. function makeAxisEventDataBase(axisModel) {
  21034. var eventData = {
  21035. componentType: axisModel.mainType
  21036. };
  21037. eventData[axisModel.mainType + 'Index'] = axisModel.componentIndex;
  21038. return eventData;
  21039. }
  21040. /**
  21041. * A final axis is translated and rotated from a "standard axis".
  21042. * So opt.position and opt.rotation is required.
  21043. *
  21044. * A standard axis is and axis from [0, 0] to [0, axisExtent[1]],
  21045. * for example: (0, 0) ------------> (0, 50)
  21046. *
  21047. * nameDirection or tickDirection or labelDirection is 1 means tick
  21048. * or label is below the standard axis, whereas is -1 means above
  21049. * the standard axis. labelOffset means offset between label and axis,
  21050. * which is useful when 'onZero', where axisLabel is in the grid and
  21051. * label in outside grid.
  21052. *
  21053. * Tips: like always,
  21054. * positive rotation represents anticlockwise, and negative rotation
  21055. * represents clockwise.
  21056. * The direction of position coordinate is the same as the direction
  21057. * of screen coordinate.
  21058. *
  21059. * Do not need to consider axis 'inverse', which is auto processed by
  21060. * axis extent.
  21061. *
  21062. * @param {module:zrender/container/Group} group
  21063. * @param {Object} axisModel
  21064. * @param {Object} opt Standard axis parameters.
  21065. * @param {Array.<number>} opt.position [x, y]
  21066. * @param {number} opt.rotation by radian
  21067. * @param {number} [opt.nameDirection=1] 1 or -1 Used when nameLocation is 'middle'.
  21068. * @param {number} [opt.tickDirection=1] 1 or -1
  21069. * @param {number} [opt.labelDirection=1] 1 or -1
  21070. * @param {number} [opt.labelOffset=0] Usefull when onZero.
  21071. * @param {string} [opt.axisName] default get from axisModel.
  21072. * @param {number} [opt.labelRotation] by degree, default get from axisModel.
  21073. * @param {number} [opt.labelInterval] Default label interval when label
  21074. * interval from model is null or 'auto'.
  21075. * @param {number} [opt.strokeContainThreshold] Default label interval when label
  21076. * @param {number} [opt.axisLineSilent=true] If axis line is silent
  21077. */
  21078. var AxisBuilder = function (axisModel, opt) {
  21079. /**
  21080. * @readOnly
  21081. */
  21082. this.opt = opt;
  21083. /**
  21084. * @readOnly
  21085. */
  21086. this.axisModel = axisModel;
  21087. // Default value
  21088. zrUtil.defaults(
  21089. opt,
  21090. {
  21091. labelOffset: 0,
  21092. nameDirection: 1,
  21093. tickDirection: 1,
  21094. labelDirection: 1,
  21095. silent: true
  21096. }
  21097. );
  21098. /**
  21099. * @readOnly
  21100. */
  21101. this.group = new graphic.Group({
  21102. position: opt.position.slice(),
  21103. rotation: opt.rotation
  21104. });
  21105. };
  21106. AxisBuilder.prototype = {
  21107. constructor: AxisBuilder,
  21108. hasBuilder: function (name) {
  21109. return !!builders[name];
  21110. },
  21111. add: function (name) {
  21112. builders[name].call(this);
  21113. },
  21114. getGroup: function () {
  21115. return this.group;
  21116. }
  21117. };
  21118. var builders = {
  21119. /**
  21120. * @private
  21121. */
  21122. axisLine: function () {
  21123. var opt = this.opt;
  21124. var axisModel = this.axisModel;
  21125. if (!axisModel.get('axisLine.show')) {
  21126. return;
  21127. }
  21128. var extent = this.axisModel.axis.getExtent();
  21129. this.group.add(new graphic.Line({
  21130. shape: {
  21131. x1: extent[0],
  21132. y1: 0,
  21133. x2: extent[1],
  21134. y2: 0
  21135. },
  21136. style: zrUtil.extend(
  21137. {lineCap: 'round'},
  21138. axisModel.getModel('axisLine.lineStyle').getLineStyle()
  21139. ),
  21140. strokeContainThreshold: opt.strokeContainThreshold,
  21141. silent: !!opt.axisLineSilent,
  21142. z2: 1
  21143. }));
  21144. },
  21145. /**
  21146. * @private
  21147. */
  21148. axisTick: function () {
  21149. var axisModel = this.axisModel;
  21150. if (!axisModel.get('axisTick.show')) {
  21151. return;
  21152. }
  21153. var axis = axisModel.axis;
  21154. var tickModel = axisModel.getModel('axisTick');
  21155. var opt = this.opt;
  21156. var lineStyleModel = tickModel.getModel('lineStyle');
  21157. var tickLen = tickModel.get('length');
  21158. var tickInterval = getInterval(tickModel, opt.labelInterval);
  21159. var ticksCoords = axis.getTicksCoords();
  21160. var tickLines = [];
  21161. for (var i = 0; i < ticksCoords.length; i++) {
  21162. // Only ordinal scale support tick interval
  21163. if (ifIgnoreOnTick(axis, i, tickInterval)) {
  21164. continue;
  21165. }
  21166. var tickCoord = ticksCoords[i];
  21167. // Tick line
  21168. tickLines.push(new graphic.Line(graphic.subPixelOptimizeLine({
  21169. shape: {
  21170. x1: tickCoord,
  21171. y1: 0,
  21172. x2: tickCoord,
  21173. y2: opt.tickDirection * tickLen
  21174. },
  21175. style: {
  21176. lineWidth: lineStyleModel.get('width')
  21177. },
  21178. silent: true
  21179. })));
  21180. }
  21181. this.group.add(graphic.mergePath(tickLines, {
  21182. style: lineStyleModel.getLineStyle(),
  21183. z2: 2,
  21184. silent: true
  21185. }));
  21186. },
  21187. /**
  21188. * @param {module:echarts/coord/cartesian/AxisModel} axisModel
  21189. * @param {module:echarts/coord/cartesian/GridModel} gridModel
  21190. * @private
  21191. */
  21192. axisLabel: function () {
  21193. var axisModel = this.axisModel;
  21194. if (!axisModel.get('axisLabel.show')) {
  21195. return;
  21196. }
  21197. var opt = this.opt;
  21198. var axis = axisModel.axis;
  21199. var labelModel = axisModel.getModel('axisLabel');
  21200. var textStyleModel = labelModel.getModel('textStyle');
  21201. var labelMargin = labelModel.get('margin');
  21202. var ticks = axis.scale.getTicks();
  21203. var labels = axisModel.getFormattedLabels();
  21204. // Special label rotate.
  21205. var labelRotation = opt.labelRotation;
  21206. if (labelRotation == null) {
  21207. labelRotation = labelModel.get('rotate') || 0;
  21208. }
  21209. // To radian.
  21210. labelRotation = labelRotation * PI / 180;
  21211. var labelLayout = innerTextLayout(opt, labelRotation, opt.labelDirection);
  21212. var categoryData = axisModel.get('data');
  21213. var textEls = [];
  21214. var isSilent = axisModel.get('silent');
  21215. for (var i = 0; i < ticks.length; i++) {
  21216. if (ifIgnoreOnTick(axis, i, opt.labelInterval)) {
  21217. continue;
  21218. }
  21219. var itemTextStyleModel = textStyleModel;
  21220. if (categoryData && categoryData[i] && categoryData[i].textStyle) {
  21221. itemTextStyleModel = new Model(
  21222. categoryData[i].textStyle, textStyleModel, axisModel.ecModel
  21223. );
  21224. }
  21225. var textColor = itemTextStyleModel.getTextColor();
  21226. var tickCoord = axis.dataToCoord(ticks[i]);
  21227. var pos = [
  21228. tickCoord,
  21229. opt.labelOffset + opt.labelDirection * labelMargin
  21230. ];
  21231. var labelBeforeFormat = axis.scale.getLabel(ticks[i]);
  21232. var textEl = new graphic.Text({
  21233. style: {
  21234. text: labels[i],
  21235. textAlign: itemTextStyleModel.get('align', true) || labelLayout.textAlign,
  21236. textVerticalAlign: itemTextStyleModel.get('baseline', true) || labelLayout.verticalAlign,
  21237. textFont: itemTextStyleModel.getFont(),
  21238. fill: typeof textColor === 'function' ? textColor(labelBeforeFormat) : textColor
  21239. },
  21240. position: pos,
  21241. rotation: labelLayout.rotation,
  21242. silent: isSilent,
  21243. z2: 10
  21244. });
  21245. // Pack data for mouse event
  21246. textEl.eventData = makeAxisEventDataBase(axisModel);
  21247. textEl.eventData.targetType = 'axisLabel';
  21248. textEl.eventData.value = labelBeforeFormat;
  21249. textEls.push(textEl);
  21250. this.group.add(textEl);
  21251. }
  21252. function isTwoLabelOverlapped(current, next) {
  21253. var firstRect = current && current.getBoundingRect().clone();
  21254. var nextRect = next && next.getBoundingRect().clone();
  21255. if (firstRect && nextRect) {
  21256. firstRect.applyTransform(current.getLocalTransform());
  21257. nextRect.applyTransform(next.getLocalTransform());
  21258. return firstRect.intersect(nextRect);
  21259. }
  21260. }
  21261. if (axis.type !== 'category') {
  21262. // If min or max are user set, we need to check
  21263. // If the tick on min(max) are overlap on their neighbour tick
  21264. // If they are overlapped, we need to hide the min(max) tick label
  21265. if (axisModel.getMin ? axisModel.getMin() : axisModel.get('min')) {
  21266. var firstLabel = textEls[0];
  21267. var nextLabel = textEls[1];
  21268. if (isTwoLabelOverlapped(firstLabel, nextLabel)) {
  21269. firstLabel.ignore = true;
  21270. }
  21271. }
  21272. if (axisModel.getMax ? axisModel.getMax() : axisModel.get('max')) {
  21273. var lastLabel = textEls[textEls.length - 1];
  21274. var prevLabel = textEls[textEls.length - 2];
  21275. if (isTwoLabelOverlapped(prevLabel, lastLabel)) {
  21276. lastLabel.ignore = true;
  21277. }
  21278. }
  21279. }
  21280. },
  21281. /**
  21282. * @private
  21283. */
  21284. axisName: function () {
  21285. var opt = this.opt;
  21286. var axisModel = this.axisModel;
  21287. var name = this.opt.axisName;
  21288. // If name is '', do not get name from axisMode.
  21289. if (name == null) {
  21290. name = axisModel.get('name');
  21291. }
  21292. if (!name) {
  21293. return;
  21294. }
  21295. var nameLocation = axisModel.get('nameLocation');
  21296. var nameDirection = opt.nameDirection;
  21297. var textStyleModel = axisModel.getModel('nameTextStyle');
  21298. var gap = axisModel.get('nameGap') || 0;
  21299. var extent = this.axisModel.axis.getExtent();
  21300. var gapSignal = extent[0] > extent[1] ? -1 : 1;
  21301. var pos = [
  21302. nameLocation === 'start'
  21303. ? extent[0] - gapSignal * gap
  21304. : nameLocation === 'end'
  21305. ? extent[1] + gapSignal * gap
  21306. : (extent[0] + extent[1]) / 2, // 'middle'
  21307. // Reuse labelOffset.
  21308. nameLocation === 'middle' ? opt.labelOffset + nameDirection * gap : 0
  21309. ];
  21310. var labelLayout;
  21311. if (nameLocation === 'middle') {
  21312. labelLayout = innerTextLayout(opt, opt.rotation, nameDirection);
  21313. }
  21314. else {
  21315. labelLayout = endTextLayout(opt, nameLocation, extent);
  21316. }
  21317. var textEl = new graphic.Text({
  21318. style: {
  21319. text: name,
  21320. textFont: textStyleModel.getFont(),
  21321. fill: textStyleModel.getTextColor()
  21322. || axisModel.get('axisLine.lineStyle.color'),
  21323. textAlign: labelLayout.textAlign,
  21324. textVerticalAlign: labelLayout.verticalAlign
  21325. },
  21326. position: pos,
  21327. rotation: labelLayout.rotation,
  21328. silent: axisModel.get('silent'),
  21329. z2: 1
  21330. });
  21331. textEl.eventData = makeAxisEventDataBase(axisModel);
  21332. textEl.eventData.targetType = 'axisName';
  21333. textEl.eventData.name = name;
  21334. this.group.add(textEl);
  21335. }
  21336. };
  21337. /**
  21338. * @inner
  21339. */
  21340. function innerTextLayout(opt, textRotation, direction) {
  21341. var rotationDiff = remRadian(textRotation - opt.rotation);
  21342. var textAlign;
  21343. var verticalAlign;
  21344. if (isRadianAroundZero(rotationDiff)) { // Label is parallel with axis line.
  21345. verticalAlign = direction > 0 ? 'top' : 'bottom';
  21346. textAlign = 'center';
  21347. }
  21348. else if (isRadianAroundZero(rotationDiff - PI)) { // Label is inverse parallel with axis line.
  21349. verticalAlign = direction > 0 ? 'bottom' : 'top';
  21350. textAlign = 'center';
  21351. }
  21352. else {
  21353. verticalAlign = 'middle';
  21354. if (rotationDiff > 0 && rotationDiff < PI) {
  21355. textAlign = direction > 0 ? 'right' : 'left';
  21356. }
  21357. else {
  21358. textAlign = direction > 0 ? 'left' : 'right';
  21359. }
  21360. }
  21361. return {
  21362. rotation: rotationDiff,
  21363. textAlign: textAlign,
  21364. verticalAlign: verticalAlign
  21365. };
  21366. }
  21367. /**
  21368. * @inner
  21369. */
  21370. function endTextLayout(opt, textPosition, extent) {
  21371. var rotationDiff = remRadian(-opt.rotation);
  21372. var textAlign;
  21373. var verticalAlign;
  21374. var inverse = extent[0] > extent[1];
  21375. var onLeft = (textPosition === 'start' && !inverse)
  21376. || (textPosition !== 'start' && inverse);
  21377. if (isRadianAroundZero(rotationDiff - PI / 2)) {
  21378. verticalAlign = onLeft ? 'bottom' : 'top';
  21379. textAlign = 'center';
  21380. }
  21381. else if (isRadianAroundZero(rotationDiff - PI * 1.5)) {
  21382. verticalAlign = onLeft ? 'top' : 'bottom';
  21383. textAlign = 'center';
  21384. }
  21385. else {
  21386. verticalAlign = 'middle';
  21387. if (rotationDiff < PI * 1.5 && rotationDiff > PI / 2) {
  21388. textAlign = onLeft ? 'left' : 'right';
  21389. }
  21390. else {
  21391. textAlign = onLeft ? 'right' : 'left';
  21392. }
  21393. }
  21394. return {
  21395. rotation: rotationDiff,
  21396. textAlign: textAlign,
  21397. verticalAlign: verticalAlign
  21398. };
  21399. }
  21400. /**
  21401. * @static
  21402. */
  21403. var ifIgnoreOnTick = AxisBuilder.ifIgnoreOnTick = function (axis, i, interval) {
  21404. var rawTick;
  21405. var scale = axis.scale;
  21406. return scale.type === 'ordinal'
  21407. && (
  21408. typeof interval === 'function'
  21409. ? (
  21410. rawTick = scale.getTicks()[i],
  21411. !interval(rawTick, scale.getLabel(rawTick))
  21412. )
  21413. : i % (interval + 1)
  21414. );
  21415. };
  21416. /**
  21417. * @static
  21418. */
  21419. var getInterval = AxisBuilder.getInterval = function (model, labelInterval) {
  21420. var interval = model.get('interval');
  21421. if (interval == null || interval == 'auto') {
  21422. interval = labelInterval;
  21423. }
  21424. return interval;
  21425. };
  21426. module.exports = AxisBuilder;
  21427. /***/ },
  21428. /* 128 */
  21429. /***/ function(module, exports, __webpack_require__) {
  21430. var zrUtil = __webpack_require__(3);
  21431. __webpack_require__(108);
  21432. __webpack_require__(129);
  21433. __webpack_require__(130);
  21434. var barLayoutGrid = __webpack_require__(132);
  21435. var echarts = __webpack_require__(1);
  21436. echarts.registerLayout(zrUtil.curry(barLayoutGrid, 'bar'));
  21437. // Visual coding for legend
  21438. echarts.registerVisualCoding('chart', function (ecModel) {
  21439. ecModel.eachSeriesByType('bar', function (seriesModel) {
  21440. var data = seriesModel.getData();
  21441. data.setVisual('legendSymbol', 'roundRect');
  21442. });
  21443. });
  21444. // In case developer forget to include grid component
  21445. __webpack_require__(107);
  21446. /***/ },
  21447. /* 129 */
  21448. /***/ function(module, exports, __webpack_require__) {
  21449. 'use strict';
  21450. var SeriesModel = __webpack_require__(27);
  21451. var createListFromArray = __webpack_require__(94);
  21452. module.exports = SeriesModel.extend({
  21453. type: 'series.bar',
  21454. dependencies: ['grid', 'polar'],
  21455. getInitialData: function (option, ecModel) {
  21456. return createListFromArray(option.data, this, ecModel);
  21457. },
  21458. getMarkerPosition: function (value) {
  21459. var coordSys = this.coordinateSystem;
  21460. if (coordSys) {
  21461. var pt = coordSys.dataToPoint(value);
  21462. var data = this.getData();
  21463. var offset = data.getLayout('offset');
  21464. var size = data.getLayout('size');
  21465. var offsetIndex = coordSys.getBaseAxis().isHorizontal() ? 0 : 1;
  21466. pt[offsetIndex] += offset + size / 2;
  21467. return pt;
  21468. }
  21469. return [NaN, NaN];
  21470. },
  21471. defaultOption: {
  21472. zlevel: 0, // 一级层叠
  21473. z: 2, // 二级层叠
  21474. coordinateSystem: 'cartesian2d',
  21475. legendHoverLink: true,
  21476. // stack: null
  21477. // Cartesian coordinate system
  21478. xAxisIndex: 0,
  21479. yAxisIndex: 0,
  21480. // 最小高度改为0
  21481. barMinHeight: 0,
  21482. // barMaxWidth: null,
  21483. // 默认自适应
  21484. // barWidth: null,
  21485. // 柱间距离,默认为柱形宽度的30%,可设固定值
  21486. // barGap: '30%',
  21487. // 类目间柱形距离,默认为类目间距的20%,可设固定值
  21488. // barCategoryGap: '20%',
  21489. // label: {
  21490. // normal: {
  21491. // show: false
  21492. // }
  21493. // },
  21494. itemStyle: {
  21495. normal: {
  21496. // color: '各异',
  21497. // 柱条边线
  21498. barBorderColor: '#fff',
  21499. // 柱条边线线宽,单位px,默认为1
  21500. barBorderWidth: 0
  21501. },
  21502. emphasis: {
  21503. // color: '各异',
  21504. // 柱条边线
  21505. barBorderColor: '#fff',
  21506. // 柱条边线线宽,单位px,默认为1
  21507. barBorderWidth: 0
  21508. }
  21509. }
  21510. }
  21511. });
  21512. /***/ },
  21513. /* 130 */
  21514. /***/ function(module, exports, __webpack_require__) {
  21515. 'use strict';
  21516. var zrUtil = __webpack_require__(3);
  21517. var graphic = __webpack_require__(42);
  21518. zrUtil.extend(__webpack_require__(8).prototype, __webpack_require__(131));
  21519. function fixLayoutWithLineWidth(layout, lineWidth) {
  21520. var signX = layout.width > 0 ? 1 : -1;
  21521. var signY = layout.height > 0 ? 1 : -1;
  21522. // In case width or height are too small.
  21523. lineWidth = Math.min(lineWidth, Math.abs(layout.width), Math.abs(layout.height));
  21524. layout.x += signX * lineWidth / 2;
  21525. layout.y += signY * lineWidth / 2;
  21526. layout.width -= signX * lineWidth;
  21527. layout.height -= signY * lineWidth;
  21528. }
  21529. module.exports = __webpack_require__(1).extendChartView({
  21530. type: 'bar',
  21531. render: function (seriesModel, ecModel, api) {
  21532. var coordinateSystemType = seriesModel.get('coordinateSystem');
  21533. if (coordinateSystemType === 'cartesian2d') {
  21534. this._renderOnCartesian(seriesModel, ecModel, api);
  21535. }
  21536. return this.group;
  21537. },
  21538. _renderOnCartesian: function (seriesModel, ecModel, api) {
  21539. var group = this.group;
  21540. var data = seriesModel.getData();
  21541. var oldData = this._data;
  21542. var cartesian = seriesModel.coordinateSystem;
  21543. var baseAxis = cartesian.getBaseAxis();
  21544. var isHorizontal = baseAxis.isHorizontal();
  21545. var enableAnimation = seriesModel.get('animation');
  21546. var barBorderWidthQuery = ['itemStyle', 'normal', 'barBorderWidth'];
  21547. function createRect(dataIndex, isUpdate) {
  21548. var layout = data.getItemLayout(dataIndex);
  21549. var lineWidth = data.getItemModel(dataIndex).get(barBorderWidthQuery) || 0;
  21550. fixLayoutWithLineWidth(layout, lineWidth);
  21551. var rect = new graphic.Rect({
  21552. shape: zrUtil.extend({}, layout)
  21553. });
  21554. // Animation
  21555. if (enableAnimation) {
  21556. var rectShape = rect.shape;
  21557. var animateProperty = isHorizontal ? 'height' : 'width';
  21558. var animateTarget = {};
  21559. rectShape[animateProperty] = 0;
  21560. animateTarget[animateProperty] = layout[animateProperty];
  21561. graphic[isUpdate? 'updateProps' : 'initProps'](rect, {
  21562. shape: animateTarget
  21563. }, seriesModel, dataIndex);
  21564. }
  21565. return rect;
  21566. }
  21567. data.diff(oldData)
  21568. .add(function (dataIndex) {
  21569. // 空数据
  21570. if (!data.hasValue(dataIndex)) {
  21571. return;
  21572. }
  21573. var rect = createRect(dataIndex);
  21574. data.setItemGraphicEl(dataIndex, rect);
  21575. group.add(rect);
  21576. })
  21577. .update(function (newIndex, oldIndex) {
  21578. var rect = oldData.getItemGraphicEl(oldIndex);
  21579. // 空数据
  21580. if (!data.hasValue(newIndex)) {
  21581. group.remove(rect);
  21582. return;
  21583. }
  21584. if (!rect) {
  21585. rect = createRect(newIndex, true);
  21586. }
  21587. var layout = data.getItemLayout(newIndex);
  21588. var lineWidth = data.getItemModel(newIndex).get(barBorderWidthQuery) || 0;
  21589. fixLayoutWithLineWidth(layout, lineWidth);
  21590. graphic.updateProps(rect, {
  21591. shape: layout
  21592. }, seriesModel, newIndex);
  21593. data.setItemGraphicEl(newIndex, rect);
  21594. // Add back
  21595. group.add(rect);
  21596. })
  21597. .remove(function (idx) {
  21598. var rect = oldData.getItemGraphicEl(idx);
  21599. if (rect) {
  21600. // Not show text when animating
  21601. rect.style.text = '';
  21602. graphic.updateProps(rect, {
  21603. shape: {
  21604. width: 0
  21605. }
  21606. }, seriesModel, idx, function () {
  21607. group.remove(rect);
  21608. });
  21609. }
  21610. })
  21611. .execute();
  21612. this._updateStyle(seriesModel, data, isHorizontal);
  21613. this._data = data;
  21614. },
  21615. _updateStyle: function (seriesModel, data, isHorizontal) {
  21616. function setLabel(style, model, color, labelText, labelPositionOutside) {
  21617. graphic.setText(style, model, color);
  21618. style.text = labelText;
  21619. if (style.textPosition === 'outside') {
  21620. style.textPosition = labelPositionOutside;
  21621. }
  21622. }
  21623. data.eachItemGraphicEl(function (rect, idx) {
  21624. var itemModel = data.getItemModel(idx);
  21625. var color = data.getItemVisual(idx, 'color');
  21626. var opacity = data.getItemVisual(idx, 'opacity');
  21627. var layout = data.getItemLayout(idx);
  21628. var itemStyleModel = itemModel.getModel('itemStyle.normal');
  21629. var hoverStyle = itemModel.getModel('itemStyle.emphasis').getBarItemStyle();
  21630. rect.setShape('r', itemStyleModel.get('barBorderRadius') || 0);
  21631. rect.useStyle(zrUtil.defaults(
  21632. {
  21633. fill: color,
  21634. opacity: opacity
  21635. },
  21636. itemStyleModel.getBarItemStyle()
  21637. ));
  21638. var labelPositionOutside = isHorizontal
  21639. ? (layout.height > 0 ? 'bottom' : 'top')
  21640. : (layout.width > 0 ? 'left' : 'right');
  21641. var labelModel = itemModel.getModel('label.normal');
  21642. var hoverLabelModel = itemModel.getModel('label.emphasis');
  21643. var rectStyle = rect.style;
  21644. if (labelModel.get('show')) {
  21645. setLabel(
  21646. rectStyle, labelModel, color,
  21647. zrUtil.retrieve(
  21648. seriesModel.getFormattedLabel(idx, 'normal'),
  21649. seriesModel.getRawValue(idx)
  21650. ),
  21651. labelPositionOutside
  21652. );
  21653. }
  21654. else {
  21655. rectStyle.text = '';
  21656. }
  21657. if (hoverLabelModel.get('show')) {
  21658. setLabel(
  21659. hoverStyle, hoverLabelModel, color,
  21660. zrUtil.retrieve(
  21661. seriesModel.getFormattedLabel(idx, 'emphasis'),
  21662. seriesModel.getRawValue(idx)
  21663. ),
  21664. labelPositionOutside
  21665. );
  21666. }
  21667. else {
  21668. hoverStyle.text = '';
  21669. }
  21670. graphic.setHoverStyle(rect, hoverStyle);
  21671. });
  21672. },
  21673. remove: function (ecModel, api) {
  21674. var group = this.group;
  21675. if (ecModel.get('animation')) {
  21676. if (this._data) {
  21677. this._data.eachItemGraphicEl(function (el) {
  21678. // Not show text when animating
  21679. el.style.text = '';
  21680. graphic.updateProps(el, {
  21681. shape: {
  21682. width: 0
  21683. }
  21684. }, ecModel, el.dataIndex, function () {
  21685. group.remove(el);
  21686. });
  21687. });
  21688. }
  21689. }
  21690. else {
  21691. group.removeAll();
  21692. }
  21693. }
  21694. });
  21695. /***/ },
  21696. /* 131 */
  21697. /***/ function(module, exports, __webpack_require__) {
  21698. module.exports = {
  21699. getBarItemStyle: __webpack_require__(11)(
  21700. [
  21701. ['fill', 'color'],
  21702. ['stroke', 'borderColor'],
  21703. ['lineWidth', 'borderWidth'],
  21704. // Compatitable with 2
  21705. ['stroke', 'barBorderColor'],
  21706. ['lineWidth', 'barBorderWidth'],
  21707. ['opacity'],
  21708. ['shadowBlur'],
  21709. ['shadowOffsetX'],
  21710. ['shadowOffsetY'],
  21711. ['shadowColor']
  21712. ]
  21713. )
  21714. };
  21715. /***/ },
  21716. /* 132 */
  21717. /***/ function(module, exports, __webpack_require__) {
  21718. 'use strict';
  21719. var zrUtil = __webpack_require__(3);
  21720. var numberUtil = __webpack_require__(7);
  21721. var parsePercent = numberUtil.parsePercent;
  21722. function getSeriesStackId(seriesModel) {
  21723. return seriesModel.get('stack') || '__ec_stack_' + seriesModel.seriesIndex;
  21724. }
  21725. function calBarWidthAndOffset(barSeries, api) {
  21726. // Columns info on each category axis. Key is cartesian name
  21727. var columnsMap = {};
  21728. zrUtil.each(barSeries, function (seriesModel, idx) {
  21729. var cartesian = seriesModel.coordinateSystem;
  21730. var baseAxis = cartesian.getBaseAxis();
  21731. var columnsOnAxis = columnsMap[baseAxis.index] || {
  21732. remainedWidth: baseAxis.getBandWidth(),
  21733. autoWidthCount: 0,
  21734. categoryGap: '20%',
  21735. gap: '30%',
  21736. axis: baseAxis,
  21737. stacks: {}
  21738. };
  21739. var stacks = columnsOnAxis.stacks;
  21740. columnsMap[baseAxis.index] = columnsOnAxis;
  21741. var stackId = getSeriesStackId(seriesModel);
  21742. if (!stacks[stackId]) {
  21743. columnsOnAxis.autoWidthCount++;
  21744. }
  21745. stacks[stackId] = stacks[stackId] || {
  21746. width: 0,
  21747. maxWidth: 0
  21748. };
  21749. var barWidth = seriesModel.get('barWidth');
  21750. var barMaxWidth = seriesModel.get('barMaxWidth');
  21751. var barGap = seriesModel.get('barGap');
  21752. var barCategoryGap = seriesModel.get('barCategoryGap');
  21753. // TODO
  21754. if (barWidth && ! stacks[stackId].width) {
  21755. barWidth = Math.min(columnsOnAxis.remainedWidth, barWidth);
  21756. stacks[stackId].width = barWidth;
  21757. columnsOnAxis.remainedWidth -= barWidth;
  21758. }
  21759. barMaxWidth && (stacks[stackId].maxWidth = barMaxWidth);
  21760. (barGap != null) && (columnsOnAxis.gap = barGap);
  21761. (barCategoryGap != null) && (columnsOnAxis.categoryGap = barCategoryGap);
  21762. });
  21763. var result = {};
  21764. zrUtil.each(columnsMap, function (columnsOnAxis, coordSysName) {
  21765. result[coordSysName] = {};
  21766. var stacks = columnsOnAxis.stacks;
  21767. var baseAxis = columnsOnAxis.axis;
  21768. var bandWidth = baseAxis.getBandWidth();
  21769. var categoryGap = parsePercent(columnsOnAxis.categoryGap, bandWidth);
  21770. var barGapPercent = parsePercent(columnsOnAxis.gap, 1);
  21771. var remainedWidth = columnsOnAxis.remainedWidth;
  21772. var autoWidthCount = columnsOnAxis.autoWidthCount;
  21773. var autoWidth = (remainedWidth - categoryGap)
  21774. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  21775. autoWidth = Math.max(autoWidth, 0);
  21776. // Find if any auto calculated bar exceeded maxBarWidth
  21777. zrUtil.each(stacks, function (column, stack) {
  21778. var maxWidth = column.maxWidth;
  21779. if (!column.width && maxWidth && maxWidth < autoWidth) {
  21780. maxWidth = Math.min(maxWidth, remainedWidth);
  21781. remainedWidth -= maxWidth;
  21782. column.width = maxWidth;
  21783. autoWidthCount--;
  21784. }
  21785. });
  21786. // Recalculate width again
  21787. autoWidth = (remainedWidth - categoryGap)
  21788. / (autoWidthCount + (autoWidthCount - 1) * barGapPercent);
  21789. autoWidth = Math.max(autoWidth, 0);
  21790. var widthSum = 0;
  21791. var lastColumn;
  21792. zrUtil.each(stacks, function (column, idx) {
  21793. if (!column.width) {
  21794. column.width = autoWidth;
  21795. }
  21796. lastColumn = column;
  21797. widthSum += column.width * (1 + barGapPercent);
  21798. });
  21799. if (lastColumn) {
  21800. widthSum -= lastColumn.width * barGapPercent;
  21801. }
  21802. var offset = -widthSum / 2;
  21803. zrUtil.each(stacks, function (column, stackId) {
  21804. result[coordSysName][stackId] = result[coordSysName][stackId] || {
  21805. offset: offset,
  21806. width: column.width
  21807. };
  21808. offset += column.width * (1 + barGapPercent);
  21809. });
  21810. });
  21811. return result;
  21812. }
  21813. /**
  21814. * @param {string} seriesType
  21815. * @param {module:echarts/model/Global} ecModel
  21816. * @param {module:echarts/ExtensionAPI} api
  21817. */
  21818. function barLayoutGrid(seriesType, ecModel, api) {
  21819. var barWidthAndOffset = calBarWidthAndOffset(
  21820. zrUtil.filter(
  21821. ecModel.getSeriesByType(seriesType),
  21822. function (seriesModel) {
  21823. return !ecModel.isSeriesFiltered(seriesModel)
  21824. && seriesModel.coordinateSystem
  21825. && seriesModel.coordinateSystem.type === 'cartesian2d';
  21826. }
  21827. )
  21828. );
  21829. var lastStackCoords = {};
  21830. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  21831. var data = seriesModel.getData();
  21832. var cartesian = seriesModel.coordinateSystem;
  21833. var baseAxis = cartesian.getBaseAxis();
  21834. var stackId = getSeriesStackId(seriesModel);
  21835. var columnLayoutInfo = barWidthAndOffset[baseAxis.index][stackId];
  21836. var columnOffset = columnLayoutInfo.offset;
  21837. var columnWidth = columnLayoutInfo.width;
  21838. var valueAxis = cartesian.getOtherAxis(baseAxis);
  21839. var barMinHeight = seriesModel.get('barMinHeight') || 0;
  21840. var valueAxisStart = baseAxis.onZero
  21841. ? valueAxis.toGlobalCoord(valueAxis.dataToCoord(0))
  21842. : valueAxis.getGlobalExtent()[0];
  21843. var coords = cartesian.dataToPoints(data, true);
  21844. lastStackCoords[stackId] = lastStackCoords[stackId] || [];
  21845. data.setLayout({
  21846. offset: columnOffset,
  21847. size: columnWidth
  21848. });
  21849. data.each(valueAxis.dim, function (value, idx) {
  21850. // 空数据
  21851. if (isNaN(value)) {
  21852. return;
  21853. }
  21854. if (!lastStackCoords[stackId][idx]) {
  21855. lastStackCoords[stackId][idx] = {
  21856. // Positive stack
  21857. p: valueAxisStart,
  21858. // Negative stack
  21859. n: valueAxisStart
  21860. };
  21861. }
  21862. var sign = value >= 0 ? 'p' : 'n';
  21863. var coord = coords[idx];
  21864. var lastCoord = lastStackCoords[stackId][idx][sign];
  21865. var x, y, width, height;
  21866. if (valueAxis.isHorizontal()) {
  21867. x = lastCoord;
  21868. y = coord[1] + columnOffset;
  21869. width = coord[0] - lastCoord;
  21870. height = columnWidth;
  21871. if (Math.abs(width) < barMinHeight) {
  21872. width = (width < 0 ? -1 : 1) * barMinHeight;
  21873. }
  21874. lastStackCoords[stackId][idx][sign] += width;
  21875. }
  21876. else {
  21877. x = coord[0] + columnOffset;
  21878. y = lastCoord;
  21879. width = columnWidth;
  21880. height = coord[1] - lastCoord;
  21881. if (Math.abs(height) < barMinHeight) {
  21882. // Include zero to has a positive bar
  21883. height = (height <= 0 ? -1 : 1) * barMinHeight;
  21884. }
  21885. lastStackCoords[stackId][idx][sign] += height;
  21886. }
  21887. data.setItemLayout(idx, {
  21888. x: x,
  21889. y: y,
  21890. width: width,
  21891. height: height
  21892. });
  21893. }, true);
  21894. }, this);
  21895. }
  21896. module.exports = barLayoutGrid;
  21897. /***/ },
  21898. /* 133 */
  21899. /***/ function(module, exports, __webpack_require__) {
  21900. var zrUtil = __webpack_require__(3);
  21901. var echarts = __webpack_require__(1);
  21902. __webpack_require__(134);
  21903. __webpack_require__(136);
  21904. __webpack_require__(137)('pie', [{
  21905. type: 'pieToggleSelect',
  21906. event: 'pieselectchanged',
  21907. method: 'toggleSelected'
  21908. }, {
  21909. type: 'pieSelect',
  21910. event: 'pieselected',
  21911. method: 'select'
  21912. }, {
  21913. type: 'pieUnSelect',
  21914. event: 'pieunselected',
  21915. method: 'unSelect'
  21916. }]);
  21917. echarts.registerVisualCoding(
  21918. 'chart', zrUtil.curry(__webpack_require__(138), 'pie')
  21919. );
  21920. echarts.registerLayout(zrUtil.curry(
  21921. __webpack_require__(139), 'pie'
  21922. ));
  21923. echarts.registerProcessor(
  21924. 'filter', zrUtil.curry(__webpack_require__(141), 'pie')
  21925. );
  21926. /***/ },
  21927. /* 134 */
  21928. /***/ function(module, exports, __webpack_require__) {
  21929. 'use strict';
  21930. var List = __webpack_require__(95);
  21931. var zrUtil = __webpack_require__(3);
  21932. var modelUtil = __webpack_require__(5);
  21933. var completeDimensions = __webpack_require__(97);
  21934. var dataSelectableMixin = __webpack_require__(135);
  21935. var PieSeries = __webpack_require__(1).extendSeriesModel({
  21936. type: 'series.pie',
  21937. // Overwrite
  21938. init: function (option) {
  21939. PieSeries.superApply(this, 'init', arguments);
  21940. // Enable legend selection for each data item
  21941. // Use a function instead of direct access because data reference may changed
  21942. this.legendDataProvider = function () {
  21943. return this._dataBeforeProcessed;
  21944. };
  21945. this.updateSelectedMap(option.data);
  21946. this._defaultLabelLine(option);
  21947. },
  21948. // Overwrite
  21949. mergeOption: function (newOption) {
  21950. PieSeries.superCall(this, 'mergeOption', newOption);
  21951. this.updateSelectedMap(this.option.data);
  21952. },
  21953. getInitialData: function (option, ecModel) {
  21954. var dimensions = completeDimensions(['value'], option.data);
  21955. var list = new List(dimensions, this);
  21956. list.initData(option.data);
  21957. return list;
  21958. },
  21959. // Overwrite
  21960. getDataParams: function (dataIndex) {
  21961. var data = this._data;
  21962. var params = PieSeries.superCall(this, 'getDataParams', dataIndex);
  21963. var sum = data.getSum('value');
  21964. // FIXME toFixed?
  21965. //
  21966. // Percent is 0 if sum is 0
  21967. params.percent = !sum ? 0 : +(data.get('value', dataIndex) / sum * 100).toFixed(2);
  21968. params.$vars.push('percent');
  21969. return params;
  21970. },
  21971. _defaultLabelLine: function (option) {
  21972. // Extend labelLine emphasis
  21973. modelUtil.defaultEmphasis(option.labelLine, ['show']);
  21974. var labelLineNormalOpt = option.labelLine.normal;
  21975. var labelLineEmphasisOpt = option.labelLine.emphasis;
  21976. // Not show label line if `label.normal.show = false`
  21977. labelLineNormalOpt.show = labelLineNormalOpt.show
  21978. && option.label.normal.show;
  21979. labelLineEmphasisOpt.show = labelLineEmphasisOpt.show
  21980. && option.label.emphasis.show;
  21981. },
  21982. defaultOption: {
  21983. zlevel: 0,
  21984. z: 2,
  21985. legendHoverLink: true,
  21986. hoverAnimation: true,
  21987. // 默认全局居中
  21988. center: ['50%', '50%'],
  21989. radius: [0, '75%'],
  21990. // 默认顺时针
  21991. clockwise: true,
  21992. startAngle: 90,
  21993. // 最小角度改为0
  21994. minAngle: 0,
  21995. // 选中是扇区偏移量
  21996. selectedOffset: 10,
  21997. // If use strategy to avoid label overlapping
  21998. avoidLabelOverlap: true,
  21999. // 选择模式,默认关闭,可选single,multiple
  22000. // selectedMode: false,
  22001. // 南丁格尔玫瑰图模式,'radius'(半径) | 'area'(面积)
  22002. // roseType: null,
  22003. label: {
  22004. normal: {
  22005. // If rotate around circle
  22006. rotate: false,
  22007. show: true,
  22008. // 'outer', 'inside', 'center'
  22009. position: 'outer'
  22010. // formatter: 标签文本格式器,同Tooltip.formatter,不支持异步回调
  22011. // textStyle: null // 默认使用全局文本样式,详见TEXTSTYLE
  22012. // distance: 当position为inner时有效,为label位置到圆心的距离与圆半径(环状图为内外半径和)的比例系数
  22013. },
  22014. emphasis: {}
  22015. },
  22016. // Enabled when label.normal.position is 'outer'
  22017. labelLine: {
  22018. normal: {
  22019. show: true,
  22020. // 引导线两段中的第一段长度
  22021. length: 15,
  22022. // 引导线两段中的第二段长度
  22023. length2: 15,
  22024. smooth: false,
  22025. lineStyle: {
  22026. // color: 各异,
  22027. width: 1,
  22028. type: 'solid'
  22029. }
  22030. }
  22031. },
  22032. itemStyle: {
  22033. normal: {
  22034. // color: 各异,
  22035. borderColor: 'rgba(0,0,0,0)',
  22036. borderWidth: 1
  22037. },
  22038. emphasis: {
  22039. // color: 各异,
  22040. borderColor: 'rgba(0,0,0,0)',
  22041. borderWidth: 1
  22042. }
  22043. },
  22044. animationEasing: 'cubicOut',
  22045. data: []
  22046. }
  22047. });
  22048. zrUtil.mixin(PieSeries, dataSelectableMixin);
  22049. module.exports = PieSeries;
  22050. /***/ },
  22051. /* 135 */
  22052. /***/ function(module, exports, __webpack_require__) {
  22053. /**
  22054. * Data selectable mixin for chart series.
  22055. * To eanble data select, option of series must have `selectedMode`.
  22056. * And each data item will use `selected` to toggle itself selected status
  22057. *
  22058. * @module echarts/chart/helper/DataSelectable
  22059. */
  22060. var zrUtil = __webpack_require__(3);
  22061. module.exports = {
  22062. updateSelectedMap: function (targetList) {
  22063. this._selectTargetMap = zrUtil.reduce(targetList || [], function (targetMap, target) {
  22064. targetMap[target.name] = target;
  22065. return targetMap;
  22066. }, {});
  22067. },
  22068. /**
  22069. * @param {string} name
  22070. */
  22071. // PENGING If selectedMode is null ?
  22072. select: function (name) {
  22073. var targetMap = this._selectTargetMap;
  22074. var target = targetMap[name];
  22075. var selectedMode = this.get('selectedMode');
  22076. if (selectedMode === 'single') {
  22077. zrUtil.each(targetMap, function (target) {
  22078. target.selected = false;
  22079. });
  22080. }
  22081. target && (target.selected = true);
  22082. },
  22083. /**
  22084. * @param {string} name
  22085. */
  22086. unSelect: function (name) {
  22087. var target = this._selectTargetMap[name];
  22088. // var selectedMode = this.get('selectedMode');
  22089. // selectedMode !== 'single' && target && (target.selected = false);
  22090. target && (target.selected = false);
  22091. },
  22092. /**
  22093. * @param {string} name
  22094. */
  22095. toggleSelected: function (name) {
  22096. var target = this._selectTargetMap[name];
  22097. if (target != null) {
  22098. this[target.selected ? 'unSelect' : 'select'](name);
  22099. return target.selected;
  22100. }
  22101. },
  22102. /**
  22103. * @param {string} name
  22104. */
  22105. isSelected: function (name) {
  22106. var target = this._selectTargetMap[name];
  22107. return target && target.selected;
  22108. }
  22109. };
  22110. /***/ },
  22111. /* 136 */
  22112. /***/ function(module, exports, __webpack_require__) {
  22113. var graphic = __webpack_require__(42);
  22114. var zrUtil = __webpack_require__(3);
  22115. /**
  22116. * @param {module:echarts/model/Series} seriesModel
  22117. * @param {boolean} hasAnimation
  22118. * @inner
  22119. */
  22120. function updateDataSelected(uid, seriesModel, hasAnimation, api) {
  22121. var data = seriesModel.getData();
  22122. var dataIndex = this.dataIndex;
  22123. var name = data.getName(dataIndex);
  22124. var selectedOffset = seriesModel.get('selectedOffset');
  22125. api.dispatchAction({
  22126. type: 'pieToggleSelect',
  22127. from: uid,
  22128. name: name,
  22129. seriesId: seriesModel.id
  22130. });
  22131. data.each(function (idx) {
  22132. toggleItemSelected(
  22133. data.getItemGraphicEl(idx),
  22134. data.getItemLayout(idx),
  22135. seriesModel.isSelected(data.getName(idx)),
  22136. selectedOffset,
  22137. hasAnimation
  22138. );
  22139. });
  22140. }
  22141. /**
  22142. * @param {module:zrender/graphic/Sector} el
  22143. * @param {Object} layout
  22144. * @param {boolean} isSelected
  22145. * @param {number} selectedOffset
  22146. * @param {boolean} hasAnimation
  22147. * @inner
  22148. */
  22149. function toggleItemSelected(el, layout, isSelected, selectedOffset, hasAnimation) {
  22150. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  22151. var dx = Math.cos(midAngle);
  22152. var dy = Math.sin(midAngle);
  22153. var offset = isSelected ? selectedOffset : 0;
  22154. var position = [dx * offset, dy * offset];
  22155. hasAnimation
  22156. // animateTo will stop revious animation like update transition
  22157. ? el.animate()
  22158. .when(200, {
  22159. position: position
  22160. })
  22161. .start('bounceOut')
  22162. : el.attr('position', position);
  22163. }
  22164. /**
  22165. * Piece of pie including Sector, Label, LabelLine
  22166. * @constructor
  22167. * @extends {module:zrender/graphic/Group}
  22168. */
  22169. function PiePiece(data, idx) {
  22170. graphic.Group.call(this);
  22171. var sector = new graphic.Sector({
  22172. z2: 2
  22173. });
  22174. var polyline = new graphic.Polyline();
  22175. var text = new graphic.Text();
  22176. this.add(sector);
  22177. this.add(polyline);
  22178. this.add(text);
  22179. this.updateData(data, idx, true);
  22180. // Hover to change label and labelLine
  22181. function onEmphasis() {
  22182. polyline.ignore = polyline.hoverIgnore;
  22183. text.ignore = text.hoverIgnore;
  22184. }
  22185. function onNormal() {
  22186. polyline.ignore = polyline.normalIgnore;
  22187. text.ignore = text.normalIgnore;
  22188. }
  22189. this.on('emphasis', onEmphasis)
  22190. .on('normal', onNormal)
  22191. .on('mouseover', onEmphasis)
  22192. .on('mouseout', onNormal);
  22193. }
  22194. var piePieceProto = PiePiece.prototype;
  22195. function getLabelStyle(data, idx, state, labelModel, labelPosition) {
  22196. var textStyleModel = labelModel.getModel('textStyle');
  22197. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  22198. return {
  22199. fill: textStyleModel.getTextColor()
  22200. || (isLabelInside ? '#fff' : data.getItemVisual(idx, 'color')),
  22201. opacity: data.getItemVisual(idx, 'opacity'),
  22202. textFont: textStyleModel.getFont(),
  22203. text: zrUtil.retrieve(
  22204. data.hostModel.getFormattedLabel(idx, state), data.getName(idx)
  22205. )
  22206. };
  22207. }
  22208. piePieceProto.updateData = function (data, idx, firstCreate) {
  22209. var sector = this.childAt(0);
  22210. var seriesModel = data.hostModel;
  22211. var itemModel = data.getItemModel(idx);
  22212. var layout = data.getItemLayout(idx);
  22213. var sectorShape = zrUtil.extend({}, layout);
  22214. sectorShape.label = null;
  22215. if (firstCreate) {
  22216. sector.setShape(sectorShape);
  22217. sector.shape.endAngle = layout.startAngle;
  22218. graphic.updateProps(sector, {
  22219. shape: {
  22220. endAngle: layout.endAngle
  22221. }
  22222. }, seriesModel, idx);
  22223. }
  22224. else {
  22225. graphic.updateProps(sector, {
  22226. shape: sectorShape
  22227. }, seriesModel, idx);
  22228. }
  22229. // Update common style
  22230. var itemStyleModel = itemModel.getModel('itemStyle');
  22231. var visualColor = data.getItemVisual(idx, 'color');
  22232. sector.useStyle(
  22233. zrUtil.defaults(
  22234. {
  22235. fill: visualColor
  22236. },
  22237. itemStyleModel.getModel('normal').getItemStyle()
  22238. )
  22239. );
  22240. sector.hoverStyle = itemStyleModel.getModel('emphasis').getItemStyle();
  22241. // Toggle selected
  22242. toggleItemSelected(
  22243. this,
  22244. data.getItemLayout(idx),
  22245. itemModel.get('selected'),
  22246. seriesModel.get('selectedOffset'),
  22247. seriesModel.get('animation')
  22248. );
  22249. function onEmphasis() {
  22250. // Sector may has animation of updating data. Force to move to the last frame
  22251. // Or it may stopped on the wrong shape
  22252. sector.stopAnimation(true);
  22253. sector.animateTo({
  22254. shape: {
  22255. r: layout.r + 10
  22256. }
  22257. }, 300, 'elasticOut');
  22258. }
  22259. function onNormal() {
  22260. sector.stopAnimation(true);
  22261. sector.animateTo({
  22262. shape: {
  22263. r: layout.r
  22264. }
  22265. }, 300, 'elasticOut');
  22266. }
  22267. sector.off('mouseover').off('mouseout').off('emphasis').off('normal');
  22268. if (itemModel.get('hoverAnimation')) {
  22269. sector
  22270. .on('mouseover', onEmphasis)
  22271. .on('mouseout', onNormal)
  22272. .on('emphasis', onEmphasis)
  22273. .on('normal', onNormal);
  22274. }
  22275. this._updateLabel(data, idx);
  22276. graphic.setHoverStyle(this);
  22277. };
  22278. piePieceProto._updateLabel = function (data, idx) {
  22279. var labelLine = this.childAt(1);
  22280. var labelText = this.childAt(2);
  22281. var seriesModel = data.hostModel;
  22282. var itemModel = data.getItemModel(idx);
  22283. var layout = data.getItemLayout(idx);
  22284. var labelLayout = layout.label;
  22285. var visualColor = data.getItemVisual(idx, 'color');
  22286. graphic.updateProps(labelLine, {
  22287. shape: {
  22288. points: labelLayout.linePoints || [
  22289. [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y], [labelLayout.x, labelLayout.y]
  22290. ]
  22291. }
  22292. }, seriesModel, idx);
  22293. graphic.updateProps(labelText, {
  22294. style: {
  22295. x: labelLayout.x,
  22296. y: labelLayout.y
  22297. }
  22298. }, seriesModel, idx);
  22299. labelText.attr({
  22300. style: {
  22301. textVerticalAlign: labelLayout.verticalAlign,
  22302. textAlign: labelLayout.textAlign,
  22303. textFont: labelLayout.font
  22304. },
  22305. rotation: labelLayout.rotation,
  22306. origin: [labelLayout.x, labelLayout.y],
  22307. z2: 10
  22308. });
  22309. var labelModel = itemModel.getModel('label.normal');
  22310. var labelHoverModel = itemModel.getModel('label.emphasis');
  22311. var labelLineModel = itemModel.getModel('labelLine.normal');
  22312. var labelLineHoverModel = itemModel.getModel('labelLine.emphasis');
  22313. var labelPosition = labelModel.get('position') || labelHoverModel.get('position');
  22314. labelText.setStyle(getLabelStyle(data, idx, 'normal', labelModel, labelPosition));
  22315. labelText.ignore = labelText.normalIgnore = !labelModel.get('show');
  22316. labelText.hoverIgnore = !labelHoverModel.get('show');
  22317. labelLine.ignore = labelLine.normalIgnore = !labelLineModel.get('show');
  22318. labelLine.hoverIgnore = !labelLineHoverModel.get('show');
  22319. // Default use item visual color
  22320. labelLine.setStyle({
  22321. stroke: visualColor,
  22322. opacity: data.getItemVisual(idx, 'opacity')
  22323. });
  22324. labelLine.setStyle(labelLineModel.getModel('lineStyle').getLineStyle());
  22325. labelText.hoverStyle = getLabelStyle(data, idx, 'emphasis', labelHoverModel, labelPosition);
  22326. labelLine.hoverStyle = labelLineHoverModel.getModel('lineStyle').getLineStyle();
  22327. var smooth = labelLineModel.get('smooth');
  22328. if (smooth && smooth === true) {
  22329. smooth = 0.4;
  22330. }
  22331. labelLine.setShape({
  22332. smooth: smooth
  22333. });
  22334. };
  22335. zrUtil.inherits(PiePiece, graphic.Group);
  22336. // Pie view
  22337. var Pie = __webpack_require__(41).extend({
  22338. type: 'pie',
  22339. init: function () {
  22340. var sectorGroup = new graphic.Group();
  22341. this._sectorGroup = sectorGroup;
  22342. },
  22343. render: function (seriesModel, ecModel, api, payload) {
  22344. if (payload && (payload.from === this.uid)) {
  22345. return;
  22346. }
  22347. var data = seriesModel.getData();
  22348. var oldData = this._data;
  22349. var group = this.group;
  22350. var hasAnimation = ecModel.get('animation');
  22351. var isFirstRender = !oldData;
  22352. var onSectorClick = zrUtil.curry(
  22353. updateDataSelected, this.uid, seriesModel, hasAnimation, api
  22354. );
  22355. var selectedMode = seriesModel.get('selectedMode');
  22356. data.diff(oldData)
  22357. .add(function (idx) {
  22358. var piePiece = new PiePiece(data, idx);
  22359. if (isFirstRender) {
  22360. piePiece.eachChild(function (child) {
  22361. child.stopAnimation(true);
  22362. });
  22363. }
  22364. selectedMode && piePiece.on('click', onSectorClick);
  22365. data.setItemGraphicEl(idx, piePiece);
  22366. group.add(piePiece);
  22367. })
  22368. .update(function (newIdx, oldIdx) {
  22369. var piePiece = oldData.getItemGraphicEl(oldIdx);
  22370. piePiece.updateData(data, newIdx);
  22371. piePiece.off('click');
  22372. selectedMode && piePiece.on('click', onSectorClick);
  22373. group.add(piePiece);
  22374. data.setItemGraphicEl(newIdx, piePiece);
  22375. })
  22376. .remove(function (idx) {
  22377. var piePiece = oldData.getItemGraphicEl(idx);
  22378. group.remove(piePiece);
  22379. })
  22380. .execute();
  22381. if (hasAnimation && isFirstRender && data.count() > 0) {
  22382. var shape = data.getItemLayout(0);
  22383. var r = Math.max(api.getWidth(), api.getHeight()) / 2;
  22384. var removeClipPath = zrUtil.bind(group.removeClipPath, group);
  22385. group.setClipPath(this._createClipPath(
  22386. shape.cx, shape.cy, r, shape.startAngle, shape.clockwise, removeClipPath, seriesModel
  22387. ));
  22388. }
  22389. this._data = data;
  22390. },
  22391. _createClipPath: function (
  22392. cx, cy, r, startAngle, clockwise, cb, seriesModel
  22393. ) {
  22394. var clipPath = new graphic.Sector({
  22395. shape: {
  22396. cx: cx,
  22397. cy: cy,
  22398. r0: 0,
  22399. r: r,
  22400. startAngle: startAngle,
  22401. endAngle: startAngle,
  22402. clockwise: clockwise
  22403. }
  22404. });
  22405. graphic.initProps(clipPath, {
  22406. shape: {
  22407. endAngle: startAngle + (clockwise ? 1 : -1) * Math.PI * 2
  22408. }
  22409. }, seriesModel, cb);
  22410. return clipPath;
  22411. }
  22412. });
  22413. module.exports = Pie;
  22414. /***/ },
  22415. /* 137 */
  22416. /***/ function(module, exports, __webpack_require__) {
  22417. var echarts = __webpack_require__(1);
  22418. var zrUtil = __webpack_require__(3);
  22419. module.exports = function (seriesType, actionInfos) {
  22420. zrUtil.each(actionInfos, function (actionInfo) {
  22421. actionInfo.update = 'updateView';
  22422. /**
  22423. * @payload
  22424. * @property {string} seriesName
  22425. * @property {string} name
  22426. */
  22427. echarts.registerAction(actionInfo, function (payload, ecModel) {
  22428. var selected = {};
  22429. ecModel.eachComponent(
  22430. {mainType: 'series', subType: seriesType, query: payload},
  22431. function (seriesModel) {
  22432. if (seriesModel[actionInfo.method]) {
  22433. seriesModel[actionInfo.method](payload.name);
  22434. }
  22435. var data = seriesModel.getData();
  22436. // Create selected map
  22437. data.each(function (idx) {
  22438. var name = data.getName(idx);
  22439. selected[name] = seriesModel.isSelected(name) || false;
  22440. });
  22441. }
  22442. );
  22443. return {
  22444. name: payload.name,
  22445. selected: selected
  22446. };
  22447. });
  22448. });
  22449. };
  22450. /***/ },
  22451. /* 138 */
  22452. /***/ function(module, exports) {
  22453. // Pick color from palette for each data item
  22454. module.exports = function (seriesType, ecModel) {
  22455. var globalColorList = ecModel.get('color');
  22456. var offset = 0;
  22457. ecModel.eachRawSeriesByType(seriesType, function (seriesModel) {
  22458. var colorList = seriesModel.get('color', true);
  22459. var dataAll = seriesModel.getRawData();
  22460. if (!ecModel.isSeriesFiltered(seriesModel)) {
  22461. var data = seriesModel.getData();
  22462. data.each(function (idx) {
  22463. var itemModel = data.getItemModel(idx);
  22464. var rawIdx = data.getRawIndex(idx);
  22465. // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  22466. var singleDataColor = data.getItemVisual(idx, 'color', true);
  22467. if (!singleDataColor) {
  22468. var paletteColor = colorList ? colorList[rawIdx % colorList.length]
  22469. : globalColorList[(rawIdx + offset) % globalColorList.length];
  22470. var color = itemModel.get('itemStyle.normal.color') || paletteColor;
  22471. // Legend may use the visual info in data before processed
  22472. dataAll.setItemVisual(rawIdx, 'color', color);
  22473. data.setItemVisual(idx, 'color', color);
  22474. }
  22475. else {
  22476. // Set data all color for legend
  22477. dataAll.setItemVisual(rawIdx, 'color', singleDataColor);
  22478. }
  22479. });
  22480. }
  22481. offset += dataAll.count();
  22482. });
  22483. };
  22484. /***/ },
  22485. /* 139 */
  22486. /***/ function(module, exports, __webpack_require__) {
  22487. // TODO minAngle
  22488. var numberUtil = __webpack_require__(7);
  22489. var parsePercent = numberUtil.parsePercent;
  22490. var labelLayout = __webpack_require__(140);
  22491. var zrUtil = __webpack_require__(3);
  22492. var PI2 = Math.PI * 2;
  22493. var RADIAN = Math.PI / 180;
  22494. module.exports = function (seriesType, ecModel, api) {
  22495. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  22496. var center = seriesModel.get('center');
  22497. var radius = seriesModel.get('radius');
  22498. if (!zrUtil.isArray(radius)) {
  22499. radius = [0, radius];
  22500. }
  22501. if (!zrUtil.isArray(center)) {
  22502. center = [center, center];
  22503. }
  22504. var width = api.getWidth();
  22505. var height = api.getHeight();
  22506. var size = Math.min(width, height);
  22507. var cx = parsePercent(center[0], width);
  22508. var cy = parsePercent(center[1], height);
  22509. var r0 = parsePercent(radius[0], size / 2);
  22510. var r = parsePercent(radius[1], size / 2);
  22511. var data = seriesModel.getData();
  22512. var startAngle = -seriesModel.get('startAngle') * RADIAN;
  22513. var minAngle = seriesModel.get('minAngle') * RADIAN;
  22514. var sum = data.getSum('value');
  22515. // Sum may be 0
  22516. var unitRadian = Math.PI / (sum || data.count()) * 2;
  22517. var clockwise = seriesModel.get('clockwise');
  22518. var roseType = seriesModel.get('roseType');
  22519. // [0...max]
  22520. var extent = data.getDataExtent('value');
  22521. extent[0] = 0;
  22522. // In the case some sector angle is smaller than minAngle
  22523. var restAngle = PI2;
  22524. var valueSumLargerThanMinAngle = 0;
  22525. var currentAngle = startAngle;
  22526. var dir = clockwise ? 1 : -1;
  22527. data.each('value', function (value, idx) {
  22528. var angle;
  22529. // FIXME 兼容 2.0 但是 roseType 是 area 的时候才是这样?
  22530. if (roseType !== 'area') {
  22531. angle = sum === 0 ? unitRadian : (value * unitRadian);
  22532. }
  22533. else {
  22534. angle = PI2 / (data.count() || 1);
  22535. }
  22536. if (angle < minAngle) {
  22537. angle = minAngle;
  22538. restAngle -= minAngle;
  22539. }
  22540. else {
  22541. valueSumLargerThanMinAngle += value;
  22542. }
  22543. var endAngle = currentAngle + dir * angle;
  22544. data.setItemLayout(idx, {
  22545. angle: angle,
  22546. startAngle: currentAngle,
  22547. endAngle: endAngle,
  22548. clockwise: clockwise,
  22549. cx: cx,
  22550. cy: cy,
  22551. r0: r0,
  22552. r: roseType
  22553. ? numberUtil.linearMap(value, extent, [r0, r])
  22554. : r
  22555. });
  22556. currentAngle = endAngle;
  22557. }, true);
  22558. // Some sector is constrained by minAngle
  22559. // Rest sectors needs recalculate angle
  22560. if (restAngle < PI2) {
  22561. // Average the angle if rest angle is not enough after all angles is
  22562. // Constrained by minAngle
  22563. if (restAngle <= 1e-3) {
  22564. var angle = PI2 / data.count();
  22565. data.each(function (idx) {
  22566. var layout = data.getItemLayout(idx);
  22567. layout.startAngle = startAngle + dir * idx * angle;
  22568. layout.endAngle = startAngle + dir * (idx + 1) * angle;
  22569. });
  22570. }
  22571. else {
  22572. unitRadian = restAngle / valueSumLargerThanMinAngle;
  22573. currentAngle = startAngle;
  22574. data.each('value', function (value, idx) {
  22575. var layout = data.getItemLayout(idx);
  22576. var angle = layout.angle === minAngle
  22577. ? minAngle : value * unitRadian;
  22578. layout.startAngle = currentAngle;
  22579. layout.endAngle = currentAngle + dir * angle;
  22580. currentAngle += angle;
  22581. });
  22582. }
  22583. }
  22584. labelLayout(seriesModel, r, width, height);
  22585. });
  22586. };
  22587. /***/ },
  22588. /* 140 */
  22589. /***/ function(module, exports, __webpack_require__) {
  22590. 'use strict';
  22591. // FIXME emphasis label position is not same with normal label position
  22592. var textContain = __webpack_require__(14);
  22593. function adjustSingleSide(list, cx, cy, r, dir, viewWidth, viewHeight) {
  22594. list.sort(function (a, b) {
  22595. return a.y - b.y;
  22596. });
  22597. // 压
  22598. function shiftDown(start, end, delta, dir) {
  22599. for (var j = start; j < end; j++) {
  22600. list[j].y += delta;
  22601. if (j > start
  22602. && j + 1 < end
  22603. && list[j + 1].y > list[j].y + list[j].height
  22604. ) {
  22605. shiftUp(j, delta / 2);
  22606. return;
  22607. }
  22608. }
  22609. shiftUp(end - 1, delta / 2);
  22610. }
  22611. // 弹
  22612. function shiftUp(end, delta) {
  22613. for (var j = end; j >= 0; j--) {
  22614. list[j].y -= delta;
  22615. if (j > 0
  22616. && list[j].y > list[j - 1].y + list[j - 1].height
  22617. ) {
  22618. break;
  22619. }
  22620. }
  22621. }
  22622. function changeX(list, isDownList, cx, cy, r, dir) {
  22623. var lastDeltaX = dir > 0
  22624. ? isDownList // 右侧
  22625. ? Number.MAX_VALUE // 下
  22626. : 0 // 上
  22627. : isDownList // 左侧
  22628. ? Number.MAX_VALUE // 下
  22629. : 0; // 上
  22630. for (var i = 0, l = list.length; i < l; i++) {
  22631. // Not change x for center label
  22632. if (list[i].position === 'center') {
  22633. continue;
  22634. }
  22635. var deltaY = Math.abs(list[i].y - cy);
  22636. var length = list[i].len;
  22637. var length2 = list[i].len2;
  22638. var deltaX = (deltaY < r + length)
  22639. ? Math.sqrt(
  22640. (r + length + length2) * (r + length + length2)
  22641. - deltaY * deltaY
  22642. )
  22643. : Math.abs(list[i].x - cx);
  22644. if (isDownList && deltaX >= lastDeltaX) {
  22645. // 右下,左下
  22646. deltaX = lastDeltaX - 10;
  22647. }
  22648. if (!isDownList && deltaX <= lastDeltaX) {
  22649. // 右上,左上
  22650. deltaX = lastDeltaX + 10;
  22651. }
  22652. list[i].x = cx + deltaX * dir;
  22653. lastDeltaX = deltaX;
  22654. }
  22655. }
  22656. var lastY = 0;
  22657. var delta;
  22658. var len = list.length;
  22659. var upList = [];
  22660. var downList = [];
  22661. for (var i = 0; i < len; i++) {
  22662. delta = list[i].y - lastY;
  22663. if (delta < 0) {
  22664. shiftDown(i, len, -delta, dir);
  22665. }
  22666. lastY = list[i].y + list[i].height;
  22667. }
  22668. if (viewHeight - lastY < 0) {
  22669. shiftUp(len - 1, lastY - viewHeight);
  22670. }
  22671. for (var i = 0; i < len; i++) {
  22672. if (list[i].y >= cy) {
  22673. downList.push(list[i]);
  22674. }
  22675. else {
  22676. upList.push(list[i]);
  22677. }
  22678. }
  22679. changeX(upList, false, cx, cy, r, dir);
  22680. changeX(downList, true, cx, cy, r, dir);
  22681. }
  22682. function avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight) {
  22683. var leftList = [];
  22684. var rightList = [];
  22685. for (var i = 0; i < labelLayoutList.length; i++) {
  22686. if (labelLayoutList[i].x < cx) {
  22687. leftList.push(labelLayoutList[i]);
  22688. }
  22689. else {
  22690. rightList.push(labelLayoutList[i]);
  22691. }
  22692. }
  22693. adjustSingleSide(rightList, cx, cy, r, 1, viewWidth, viewHeight);
  22694. adjustSingleSide(leftList, cx, cy, r, -1, viewWidth, viewHeight);
  22695. for (var i = 0; i < labelLayoutList.length; i++) {
  22696. var linePoints = labelLayoutList[i].linePoints;
  22697. if (linePoints) {
  22698. var dist = linePoints[1][0] - linePoints[2][0];
  22699. if (labelLayoutList[i].x < cx) {
  22700. linePoints[2][0] = labelLayoutList[i].x + 3;
  22701. }
  22702. else {
  22703. linePoints[2][0] = labelLayoutList[i].x - 3;
  22704. }
  22705. linePoints[1][1] = linePoints[2][1] = labelLayoutList[i].y;
  22706. linePoints[1][0] = linePoints[2][0] + dist;
  22707. }
  22708. }
  22709. }
  22710. module.exports = function (seriesModel, r, viewWidth, viewHeight) {
  22711. var data = seriesModel.getData();
  22712. var labelLayoutList = [];
  22713. var cx;
  22714. var cy;
  22715. var hasLabelRotate = false;
  22716. data.each(function (idx) {
  22717. var layout = data.getItemLayout(idx);
  22718. var itemModel = data.getItemModel(idx);
  22719. var labelModel = itemModel.getModel('label.normal');
  22720. // Use position in normal or emphasis
  22721. var labelPosition = labelModel.get('position') || itemModel.get('label.emphasis.position');
  22722. var labelLineModel = itemModel.getModel('labelLine.normal');
  22723. var labelLineLen = labelLineModel.get('length');
  22724. var labelLineLen2 = labelLineModel.get('length2');
  22725. var midAngle = (layout.startAngle + layout.endAngle) / 2;
  22726. var dx = Math.cos(midAngle);
  22727. var dy = Math.sin(midAngle);
  22728. var textX;
  22729. var textY;
  22730. var linePoints;
  22731. var textAlign;
  22732. cx = layout.cx;
  22733. cy = layout.cy;
  22734. var isLabelInside = labelPosition === 'inside' || labelPosition === 'inner';
  22735. if (labelPosition === 'center') {
  22736. textX = layout.cx;
  22737. textY = layout.cy;
  22738. textAlign = 'center';
  22739. }
  22740. else {
  22741. var x1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dx : layout.r * dx) + cx;
  22742. var y1 = (isLabelInside ? (layout.r + layout.r0) / 2 * dy : layout.r * dy) + cy;
  22743. textX = x1 + dx * 3;
  22744. textY = y1 + dy * 3;
  22745. if (!isLabelInside) {
  22746. // For roseType
  22747. var x2 = x1 + dx * (labelLineLen + r - layout.r);
  22748. var y2 = y1 + dy * (labelLineLen + r - layout.r);
  22749. var x3 = x2 + ((dx < 0 ? -1 : 1) * labelLineLen2);
  22750. var y3 = y2;
  22751. textX = x3 + (dx < 0 ? -5 : 5);
  22752. textY = y3;
  22753. linePoints = [[x1, y1], [x2, y2], [x3, y3]];
  22754. }
  22755. textAlign = isLabelInside ? 'center' : (dx > 0 ? 'left' : 'right');
  22756. }
  22757. var font = labelModel.getModel('textStyle').getFont();
  22758. var labelRotate = labelModel.get('rotate')
  22759. ? (dx < 0 ? -midAngle + Math.PI : -midAngle) : 0;
  22760. var text = seriesModel.getFormattedLabel(idx, 'normal')
  22761. || data.getName(idx);
  22762. var textRect = textContain.getBoundingRect(
  22763. text, font, textAlign, 'top'
  22764. );
  22765. hasLabelRotate = !!labelRotate;
  22766. layout.label = {
  22767. x: textX,
  22768. y: textY,
  22769. position: labelPosition,
  22770. height: textRect.height,
  22771. len: labelLineLen,
  22772. len2: labelLineLen2,
  22773. linePoints: linePoints,
  22774. textAlign: textAlign,
  22775. verticalAlign: 'middle',
  22776. font: font,
  22777. rotation: labelRotate
  22778. };
  22779. // Not layout the inside label
  22780. if (!isLabelInside) {
  22781. labelLayoutList.push(layout.label);
  22782. }
  22783. });
  22784. if (!hasLabelRotate && seriesModel.get('avoidLabelOverlap')) {
  22785. avoidOverlap(labelLayoutList, cx, cy, r, viewWidth, viewHeight);
  22786. }
  22787. };
  22788. /***/ },
  22789. /* 141 */
  22790. /***/ function(module, exports) {
  22791. module.exports = function (seriesType, ecModel) {
  22792. var legendModels = ecModel.findComponents({
  22793. mainType: 'legend'
  22794. });
  22795. if (!legendModels || !legendModels.length) {
  22796. return;
  22797. }
  22798. ecModel.eachSeriesByType(seriesType, function (series) {
  22799. var data = series.getData();
  22800. data.filterSelf(function (idx) {
  22801. var name = data.getName(idx);
  22802. // If in any legend component the status is not selected.
  22803. for (var i = 0; i < legendModels.length; i++) {
  22804. if (!legendModels[i].isSelected(name)) {
  22805. return false;
  22806. }
  22807. }
  22808. return true;
  22809. }, this);
  22810. }, this);
  22811. };
  22812. /***/ }
  22813. /******/ ])
  22814. });
  22815. ;