echarts-liquidfill.js 486 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("echarts"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["echarts"], factory);
  6. else if(typeof exports === 'object')
  7. exports["echarts-liquidfill"] = factory(require("echarts"));
  8. else
  9. root["echarts-liquidfill"] = factory(root["echarts"]);
  10. })(window, function(__WEBPACK_EXTERNAL_MODULE_echarts_lib_echarts__) {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./index.js");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "./index.js":
  99. /*!******************!*\
  100. !*** ./index.js ***!
  101. \******************/
  102. /*! no static exports found */
  103. /***/ (function(module, exports, __webpack_require__) {
  104. module.exports = __webpack_require__(/*! ./src/liquidFill */ "./src/liquidFill.js");
  105. /***/ }),
  106. /***/ "./node_modules/echarts/lib/config.js":
  107. /*!********************************************!*\
  108. !*** ./node_modules/echarts/lib/config.js ***!
  109. \********************************************/
  110. /*! no static exports found */
  111. /***/ (function(module, exports, __webpack_require__) {
  112. /* WEBPACK VAR INJECTION */(function(global) {
  113. /*
  114. * Licensed to the Apache Software Foundation (ASF) under one
  115. * or more contributor license agreements. See the NOTICE file
  116. * distributed with this work for additional information
  117. * regarding copyright ownership. The ASF licenses this file
  118. * to you under the Apache License, Version 2.0 (the
  119. * "License"); you may not use this file except in compliance
  120. * with the License. You may obtain a copy of the License at
  121. *
  122. * http://www.apache.org/licenses/LICENSE-2.0
  123. *
  124. * Unless required by applicable law or agreed to in writing,
  125. * software distributed under the License is distributed on an
  126. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  127. * KIND, either express or implied. See the License for the
  128. * specific language governing permissions and limitations
  129. * under the License.
  130. */
  131. /*
  132. * Licensed to the Apache Software Foundation (ASF) under one
  133. * or more contributor license agreements. See the NOTICE file
  134. * distributed with this work for additional information
  135. * regarding copyright ownership. The ASF licenses this file
  136. * to you under the Apache License, Version 2.0 (the
  137. * "License"); you may not use this file except in compliance
  138. * with the License. You may obtain a copy of the License at
  139. *
  140. * http://www.apache.org/licenses/LICENSE-2.0
  141. *
  142. * Unless required by applicable law or agreed to in writing,
  143. * software distributed under the License is distributed on an
  144. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  145. * KIND, either express or implied. See the License for the
  146. * specific language governing permissions and limitations
  147. * under the License.
  148. */
  149. // (1) The code `if (__DEV__) ...` can be removed by build tool.
  150. // (2) If intend to use `__DEV__`, this module should be imported. Use a global
  151. // variable `__DEV__` may cause that miss the declaration (see #6535), or the
  152. // declaration is behind of the using position (for example in `Model.extent`,
  153. // And tools like rollup can not analysis the dependency if not import).
  154. var dev; // In browser
  155. if (typeof window !== 'undefined') {
  156. dev = window.__DEV__;
  157. } // In node
  158. else if (typeof global !== 'undefined') {
  159. dev = global.__DEV__;
  160. }
  161. if (typeof dev === 'undefined') {
  162. dev = true;
  163. }
  164. var __DEV__ = dev;
  165. exports.__DEV__ = __DEV__;
  166. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../webpack/buildin/global.js */ "./node_modules/webpack/buildin/global.js")))
  167. /***/ }),
  168. /***/ "./node_modules/echarts/lib/data/DataDimensionInfo.js":
  169. /*!************************************************************!*\
  170. !*** ./node_modules/echarts/lib/data/DataDimensionInfo.js ***!
  171. \************************************************************/
  172. /*! no static exports found */
  173. /***/ (function(module, exports, __webpack_require__) {
  174. /*
  175. * Licensed to the Apache Software Foundation (ASF) under one
  176. * or more contributor license agreements. See the NOTICE file
  177. * distributed with this work for additional information
  178. * regarding copyright ownership. The ASF licenses this file
  179. * to you under the Apache License, Version 2.0 (the
  180. * "License"); you may not use this file except in compliance
  181. * with the License. You may obtain a copy of the License at
  182. *
  183. * http://www.apache.org/licenses/LICENSE-2.0
  184. *
  185. * Unless required by applicable law or agreed to in writing,
  186. * software distributed under the License is distributed on an
  187. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  188. * KIND, either express or implied. See the License for the
  189. * specific language governing permissions and limitations
  190. * under the License.
  191. */
  192. var zrUtil = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  193. /*
  194. * Licensed to the Apache Software Foundation (ASF) under one
  195. * or more contributor license agreements. See the NOTICE file
  196. * distributed with this work for additional information
  197. * regarding copyright ownership. The ASF licenses this file
  198. * to you under the Apache License, Version 2.0 (the
  199. * "License"); you may not use this file except in compliance
  200. * with the License. You may obtain a copy of the License at
  201. *
  202. * http://www.apache.org/licenses/LICENSE-2.0
  203. *
  204. * Unless required by applicable law or agreed to in writing,
  205. * software distributed under the License is distributed on an
  206. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  207. * KIND, either express or implied. See the License for the
  208. * specific language governing permissions and limitations
  209. * under the License.
  210. */
  211. /**
  212. * @class
  213. * @param {Object|DataDimensionInfo} [opt] All of the fields will be shallow copied.
  214. */
  215. function DataDimensionInfo(opt) {
  216. if (opt != null) {
  217. zrUtil.extend(this, opt);
  218. }
  219. /**
  220. * Dimension name.
  221. * Mandatory.
  222. * @type {string}
  223. */
  224. // this.name;
  225. /**
  226. * The origin name in dimsDef, see source helper.
  227. * If displayName given, the tooltip will displayed vertically.
  228. * Optional.
  229. * @type {string}
  230. */
  231. // this.displayName;
  232. /**
  233. * Which coordSys dimension this dimension mapped to.
  234. * A `coordDim` can be a "coordSysDim" that the coordSys required
  235. * (for example, an item in `coordSysDims` of `model/referHelper#CoordSysInfo`),
  236. * or an generated "extra coord name" if does not mapped to any "coordSysDim"
  237. * (That is determined by whether `isExtraCoord` is `true`).
  238. * Mandatory.
  239. * @type {string}
  240. */
  241. // this.coordDim;
  242. /**
  243. * The index of this dimension in `series.encode[coordDim]`.
  244. * Mandatory.
  245. * @type {number}
  246. */
  247. // this.coordDimIndex;
  248. /**
  249. * Dimension type. The enumerable values are the key of
  250. * `dataCtors` of `data/List`.
  251. * Optional.
  252. * @type {string}
  253. */
  254. // this.type;
  255. /**
  256. * This index of this dimension info in `data/List#_dimensionInfos`.
  257. * Mandatory after added to `data/List`.
  258. * @type {number}
  259. */
  260. // this.index;
  261. /**
  262. * The format of `otherDims` is:
  263. * ```js
  264. * {
  265. * tooltip: number optional,
  266. * label: number optional,
  267. * itemName: number optional,
  268. * seriesName: number optional,
  269. * }
  270. * ```
  271. *
  272. * A `series.encode` can specified these fields:
  273. * ```js
  274. * encode: {
  275. * // "3, 1, 5" is the index of data dimension.
  276. * tooltip: [3, 1, 5],
  277. * label: [0, 3],
  278. * ...
  279. * }
  280. * ```
  281. * `otherDims` is the parse result of the `series.encode` above, like:
  282. * ```js
  283. * // Suppose the index of this data dimension is `3`.
  284. * this.otherDims = {
  285. * // `3` is at the index `0` of the `encode.tooltip`
  286. * tooltip: 0,
  287. * // `3` is at the index `1` of the `encode.tooltip`
  288. * label: 1
  289. * };
  290. * ```
  291. *
  292. * This prop should never be `null`/`undefined` after initialized.
  293. * @type {Object}
  294. */
  295. this.otherDims = {};
  296. /**
  297. * Be `true` if this dimension is not mapped to any "coordSysDim" that the
  298. * "coordSys" required.
  299. * Mandatory.
  300. * @type {boolean}
  301. */
  302. // this.isExtraCoord;
  303. /**
  304. * @type {module:data/OrdinalMeta}
  305. */
  306. // this.ordinalMeta;
  307. /**
  308. * Whether to create inverted indices.
  309. * @type {boolean}
  310. */
  311. // this.createInvertedIndices;
  312. }
  313. ;
  314. var _default = DataDimensionInfo;
  315. module.exports = _default;
  316. /***/ }),
  317. /***/ "./node_modules/echarts/lib/data/Source.js":
  318. /*!*************************************************!*\
  319. !*** ./node_modules/echarts/lib/data/Source.js ***!
  320. \*************************************************/
  321. /*! no static exports found */
  322. /***/ (function(module, exports, __webpack_require__) {
  323. /*
  324. * Licensed to the Apache Software Foundation (ASF) under one
  325. * or more contributor license agreements. See the NOTICE file
  326. * distributed with this work for additional information
  327. * regarding copyright ownership. The ASF licenses this file
  328. * to you under the Apache License, Version 2.0 (the
  329. * "License"); you may not use this file except in compliance
  330. * with the License. You may obtain a copy of the License at
  331. *
  332. * http://www.apache.org/licenses/LICENSE-2.0
  333. *
  334. * Unless required by applicable law or agreed to in writing,
  335. * software distributed under the License is distributed on an
  336. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  337. * KIND, either express or implied. See the License for the
  338. * specific language governing permissions and limitations
  339. * under the License.
  340. */
  341. var _util = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  342. var createHashMap = _util.createHashMap;
  343. var isTypedArray = _util.isTypedArray;
  344. var _clazz = __webpack_require__(/*! ../util/clazz */ "./node_modules/echarts/lib/util/clazz.js");
  345. var enableClassCheck = _clazz.enableClassCheck;
  346. var _sourceType = __webpack_require__(/*! ./helper/sourceType */ "./node_modules/echarts/lib/data/helper/sourceType.js");
  347. var SOURCE_FORMAT_ORIGINAL = _sourceType.SOURCE_FORMAT_ORIGINAL;
  348. var SERIES_LAYOUT_BY_COLUMN = _sourceType.SERIES_LAYOUT_BY_COLUMN;
  349. var SOURCE_FORMAT_UNKNOWN = _sourceType.SOURCE_FORMAT_UNKNOWN;
  350. var SOURCE_FORMAT_TYPED_ARRAY = _sourceType.SOURCE_FORMAT_TYPED_ARRAY;
  351. var SOURCE_FORMAT_KEYED_COLUMNS = _sourceType.SOURCE_FORMAT_KEYED_COLUMNS;
  352. /*
  353. * Licensed to the Apache Software Foundation (ASF) under one
  354. * or more contributor license agreements. See the NOTICE file
  355. * distributed with this work for additional information
  356. * regarding copyright ownership. The ASF licenses this file
  357. * to you under the Apache License, Version 2.0 (the
  358. * "License"); you may not use this file except in compliance
  359. * with the License. You may obtain a copy of the License at
  360. *
  361. * http://www.apache.org/licenses/LICENSE-2.0
  362. *
  363. * Unless required by applicable law or agreed to in writing,
  364. * software distributed under the License is distributed on an
  365. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  366. * KIND, either express or implied. See the License for the
  367. * specific language governing permissions and limitations
  368. * under the License.
  369. */
  370. /**
  371. * [sourceFormat]
  372. *
  373. * + "original":
  374. * This format is only used in series.data, where
  375. * itemStyle can be specified in data item.
  376. *
  377. * + "arrayRows":
  378. * [
  379. * ['product', 'score', 'amount'],
  380. * ['Matcha Latte', 89.3, 95.8],
  381. * ['Milk Tea', 92.1, 89.4],
  382. * ['Cheese Cocoa', 94.4, 91.2],
  383. * ['Walnut Brownie', 85.4, 76.9]
  384. * ]
  385. *
  386. * + "objectRows":
  387. * [
  388. * {product: 'Matcha Latte', score: 89.3, amount: 95.8},
  389. * {product: 'Milk Tea', score: 92.1, amount: 89.4},
  390. * {product: 'Cheese Cocoa', score: 94.4, amount: 91.2},
  391. * {product: 'Walnut Brownie', score: 85.4, amount: 76.9}
  392. * ]
  393. *
  394. * + "keyedColumns":
  395. * {
  396. * 'product': ['Matcha Latte', 'Milk Tea', 'Cheese Cocoa', 'Walnut Brownie'],
  397. * 'count': [823, 235, 1042, 988],
  398. * 'score': [95.8, 81.4, 91.2, 76.9]
  399. * }
  400. *
  401. * + "typedArray"
  402. *
  403. * + "unknown"
  404. */
  405. /**
  406. * @constructor
  407. * @param {Object} fields
  408. * @param {string} fields.sourceFormat
  409. * @param {Array|Object} fields.fromDataset
  410. * @param {Array|Object} [fields.data]
  411. * @param {string} [seriesLayoutBy='column']
  412. * @param {Array.<Object|string>} [dimensionsDefine]
  413. * @param {Objet|HashMap} [encodeDefine]
  414. * @param {number} [startIndex=0]
  415. * @param {number} [dimensionsDetectCount]
  416. */
  417. function Source(fields) {
  418. /**
  419. * @type {boolean}
  420. */
  421. this.fromDataset = fields.fromDataset;
  422. /**
  423. * Not null/undefined.
  424. * @type {Array|Object}
  425. */
  426. this.data = fields.data || (fields.sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS ? {} : []);
  427. /**
  428. * See also "detectSourceFormat".
  429. * Not null/undefined.
  430. * @type {string}
  431. */
  432. this.sourceFormat = fields.sourceFormat || SOURCE_FORMAT_UNKNOWN;
  433. /**
  434. * 'row' or 'column'
  435. * Not null/undefined.
  436. * @type {string} seriesLayoutBy
  437. */
  438. this.seriesLayoutBy = fields.seriesLayoutBy || SERIES_LAYOUT_BY_COLUMN;
  439. /**
  440. * dimensions definition in option.
  441. * can be null/undefined.
  442. * @type {Array.<Object|string>}
  443. */
  444. this.dimensionsDefine = fields.dimensionsDefine;
  445. /**
  446. * encode definition in option.
  447. * can be null/undefined.
  448. * @type {Objet|HashMap}
  449. */
  450. this.encodeDefine = fields.encodeDefine && createHashMap(fields.encodeDefine);
  451. /**
  452. * Not null/undefined, uint.
  453. * @type {number}
  454. */
  455. this.startIndex = fields.startIndex || 0;
  456. /**
  457. * Can be null/undefined (when unknown), uint.
  458. * @type {number}
  459. */
  460. this.dimensionsDetectCount = fields.dimensionsDetectCount;
  461. }
  462. /**
  463. * Wrap original series data for some compatibility cases.
  464. */
  465. Source.seriesDataToSource = function (data) {
  466. return new Source({
  467. data: data,
  468. sourceFormat: isTypedArray(data) ? SOURCE_FORMAT_TYPED_ARRAY : SOURCE_FORMAT_ORIGINAL,
  469. fromDataset: false
  470. });
  471. };
  472. enableClassCheck(Source);
  473. var _default = Source;
  474. module.exports = _default;
  475. /***/ }),
  476. /***/ "./node_modules/echarts/lib/data/helper/completeDimensions.js":
  477. /*!********************************************************************!*\
  478. !*** ./node_modules/echarts/lib/data/helper/completeDimensions.js ***!
  479. \********************************************************************/
  480. /*! no static exports found */
  481. /***/ (function(module, exports, __webpack_require__) {
  482. /*
  483. * Licensed to the Apache Software Foundation (ASF) under one
  484. * or more contributor license agreements. See the NOTICE file
  485. * distributed with this work for additional information
  486. * regarding copyright ownership. The ASF licenses this file
  487. * to you under the Apache License, Version 2.0 (the
  488. * "License"); you may not use this file except in compliance
  489. * with the License. You may obtain a copy of the License at
  490. *
  491. * http://www.apache.org/licenses/LICENSE-2.0
  492. *
  493. * Unless required by applicable law or agreed to in writing,
  494. * software distributed under the License is distributed on an
  495. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  496. * KIND, either express or implied. See the License for the
  497. * specific language governing permissions and limitations
  498. * under the License.
  499. */
  500. var _util = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  501. var createHashMap = _util.createHashMap;
  502. var each = _util.each;
  503. var isString = _util.isString;
  504. var defaults = _util.defaults;
  505. var extend = _util.extend;
  506. var isObject = _util.isObject;
  507. var clone = _util.clone;
  508. var _model = __webpack_require__(/*! ../../util/model */ "./node_modules/echarts/lib/util/model.js");
  509. var normalizeToArray = _model.normalizeToArray;
  510. var _sourceHelper = __webpack_require__(/*! ./sourceHelper */ "./node_modules/echarts/lib/data/helper/sourceHelper.js");
  511. var guessOrdinal = _sourceHelper.guessOrdinal;
  512. var BE_ORDINAL = _sourceHelper.BE_ORDINAL;
  513. var Source = __webpack_require__(/*! ../Source */ "./node_modules/echarts/lib/data/Source.js");
  514. var _dimensionHelper = __webpack_require__(/*! ./dimensionHelper */ "./node_modules/echarts/lib/data/helper/dimensionHelper.js");
  515. var OTHER_DIMENSIONS = _dimensionHelper.OTHER_DIMENSIONS;
  516. var DataDimensionInfo = __webpack_require__(/*! ../DataDimensionInfo */ "./node_modules/echarts/lib/data/DataDimensionInfo.js");
  517. /*
  518. * Licensed to the Apache Software Foundation (ASF) under one
  519. * or more contributor license agreements. See the NOTICE file
  520. * distributed with this work for additional information
  521. * regarding copyright ownership. The ASF licenses this file
  522. * to you under the Apache License, Version 2.0 (the
  523. * "License"); you may not use this file except in compliance
  524. * with the License. You may obtain a copy of the License at
  525. *
  526. * http://www.apache.org/licenses/LICENSE-2.0
  527. *
  528. * Unless required by applicable law or agreed to in writing,
  529. * software distributed under the License is distributed on an
  530. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  531. * KIND, either express or implied. See the License for the
  532. * specific language governing permissions and limitations
  533. * under the License.
  534. */
  535. /**
  536. * @deprecated
  537. * Use `echarts/data/helper/createDimensions` instead.
  538. */
  539. /**
  540. * @see {module:echarts/test/ut/spec/data/completeDimensions}
  541. *
  542. * This method builds the relationship between:
  543. * + "what the coord sys or series requires (see `sysDims`)",
  544. * + "what the user defines (in `encode` and `dimensions`, see `opt.dimsDef` and `opt.encodeDef`)"
  545. * + "what the data source provids (see `source`)".
  546. *
  547. * Some guess strategy will be adapted if user does not define something.
  548. * If no 'value' dimension specified, the first no-named dimension will be
  549. * named as 'value'.
  550. *
  551. * @param {Array.<string>} sysDims Necessary dimensions, like ['x', 'y'], which
  552. * provides not only dim template, but also default order.
  553. * properties: 'name', 'type', 'displayName'.
  554. * `name` of each item provides default coord name.
  555. * [{dimsDef: [string|Object, ...]}, ...] dimsDef of sysDim item provides default dim name, and
  556. * provide dims count that the sysDim required.
  557. * [{ordinalMeta}] can be specified.
  558. * @param {module:echarts/data/Source|Array|Object} source or data (for compatibal with pervious)
  559. * @param {Object} [opt]
  560. * @param {Array.<Object|string>} [opt.dimsDef] option.series.dimensions User defined dimensions
  561. * For example: ['asdf', {name, type}, ...].
  562. * @param {Object|HashMap} [opt.encodeDef] option.series.encode {x: 2, y: [3, 1], tooltip: [1, 2], label: 3}
  563. * @param {Function} [opt.encodeDefaulter] Called if no `opt.encodeDef` exists.
  564. * If not specified, auto find the next available data dim.
  565. * param source {module:data/Source}
  566. * param dimCount {number}
  567. * return {Object} encode Never be `null/undefined`.
  568. * @param {string} [opt.generateCoord] Generate coord dim with the given name.
  569. * If not specified, extra dim names will be:
  570. * 'value', 'value0', 'value1', ...
  571. * @param {number} [opt.generateCoordCount] By default, the generated dim name is `generateCoord`.
  572. * If `generateCoordCount` specified, the generated dim names will be:
  573. * `generateCoord` + 0, `generateCoord` + 1, ...
  574. * can be Infinity, indicate that use all of the remain columns.
  575. * @param {number} [opt.dimCount] If not specified, guess by the first data item.
  576. * @return {Array.<module:data/DataDimensionInfo>}
  577. */
  578. function completeDimensions(sysDims, source, opt) {
  579. if (!Source.isInstance(source)) {
  580. source = Source.seriesDataToSource(source);
  581. }
  582. opt = opt || {};
  583. sysDims = (sysDims || []).slice();
  584. var dimsDef = (opt.dimsDef || []).slice();
  585. var dataDimNameMap = createHashMap();
  586. var coordDimNameMap = createHashMap(); // var valueCandidate;
  587. var result = [];
  588. var dimCount = getDimCount(source, sysDims, dimsDef, opt.dimCount); // Apply user defined dims (`name` and `type`) and init result.
  589. for (var i = 0; i < dimCount; i++) {
  590. var dimDefItem = dimsDef[i] = extend({}, isObject(dimsDef[i]) ? dimsDef[i] : {
  591. name: dimsDef[i]
  592. });
  593. var userDimName = dimDefItem.name;
  594. var resultItem = result[i] = new DataDimensionInfo(); // Name will be applied later for avoiding duplication.
  595. if (userDimName != null && dataDimNameMap.get(userDimName) == null) {
  596. // Only if `series.dimensions` is defined in option
  597. // displayName, will be set, and dimension will be diplayed vertically in
  598. // tooltip by default.
  599. resultItem.name = resultItem.displayName = userDimName;
  600. dataDimNameMap.set(userDimName, i);
  601. }
  602. dimDefItem.type != null && (resultItem.type = dimDefItem.type);
  603. dimDefItem.displayName != null && (resultItem.displayName = dimDefItem.displayName);
  604. }
  605. var encodeDef = opt.encodeDef;
  606. if (!encodeDef && opt.encodeDefaulter) {
  607. encodeDef = opt.encodeDefaulter(source, dimCount);
  608. }
  609. encodeDef = createHashMap(encodeDef); // Set `coordDim` and `coordDimIndex` by `encodeDef` and normalize `encodeDef`.
  610. encodeDef.each(function (dataDims, coordDim) {
  611. dataDims = normalizeToArray(dataDims).slice(); // Note: It is allowed that `dataDims.length` is `0`, e.g., options is
  612. // `{encode: {x: -1, y: 1}}`. Should not filter anything in
  613. // this case.
  614. if (dataDims.length === 1 && !isString(dataDims[0]) && dataDims[0] < 0) {
  615. encodeDef.set(coordDim, false);
  616. return;
  617. }
  618. var validDataDims = encodeDef.set(coordDim, []);
  619. each(dataDims, function (resultDimIdx, idx) {
  620. // The input resultDimIdx can be dim name or index.
  621. isString(resultDimIdx) && (resultDimIdx = dataDimNameMap.get(resultDimIdx));
  622. if (resultDimIdx != null && resultDimIdx < dimCount) {
  623. validDataDims[idx] = resultDimIdx;
  624. applyDim(result[resultDimIdx], coordDim, idx);
  625. }
  626. });
  627. }); // Apply templetes and default order from `sysDims`.
  628. var availDimIdx = 0;
  629. each(sysDims, function (sysDimItem, sysDimIndex) {
  630. var coordDim;
  631. var sysDimItem;
  632. var sysDimItemDimsDef;
  633. var sysDimItemOtherDims;
  634. if (isString(sysDimItem)) {
  635. coordDim = sysDimItem;
  636. sysDimItem = {};
  637. } else {
  638. coordDim = sysDimItem.name;
  639. var ordinalMeta = sysDimItem.ordinalMeta;
  640. sysDimItem.ordinalMeta = null;
  641. sysDimItem = clone(sysDimItem);
  642. sysDimItem.ordinalMeta = ordinalMeta; // `coordDimIndex` should not be set directly.
  643. sysDimItemDimsDef = sysDimItem.dimsDef;
  644. sysDimItemOtherDims = sysDimItem.otherDims;
  645. sysDimItem.name = sysDimItem.coordDim = sysDimItem.coordDimIndex = sysDimItem.dimsDef = sysDimItem.otherDims = null;
  646. }
  647. var dataDims = encodeDef.get(coordDim); // negative resultDimIdx means no need to mapping.
  648. if (dataDims === false) {
  649. return;
  650. }
  651. var dataDims = normalizeToArray(dataDims); // dimensions provides default dim sequences.
  652. if (!dataDims.length) {
  653. for (var i = 0; i < (sysDimItemDimsDef && sysDimItemDimsDef.length || 1); i++) {
  654. while (availDimIdx < result.length && result[availDimIdx].coordDim != null) {
  655. availDimIdx++;
  656. }
  657. availDimIdx < result.length && dataDims.push(availDimIdx++);
  658. }
  659. } // Apply templates.
  660. each(dataDims, function (resultDimIdx, coordDimIndex) {
  661. var resultItem = result[resultDimIdx];
  662. applyDim(defaults(resultItem, sysDimItem), coordDim, coordDimIndex);
  663. if (resultItem.name == null && sysDimItemDimsDef) {
  664. var sysDimItemDimsDefItem = sysDimItemDimsDef[coordDimIndex];
  665. !isObject(sysDimItemDimsDefItem) && (sysDimItemDimsDefItem = {
  666. name: sysDimItemDimsDefItem
  667. });
  668. resultItem.name = resultItem.displayName = sysDimItemDimsDefItem.name;
  669. resultItem.defaultTooltip = sysDimItemDimsDefItem.defaultTooltip;
  670. } // FIXME refactor, currently only used in case: {otherDims: {tooltip: false}}
  671. sysDimItemOtherDims && defaults(resultItem.otherDims, sysDimItemOtherDims);
  672. });
  673. });
  674. function applyDim(resultItem, coordDim, coordDimIndex) {
  675. if (OTHER_DIMENSIONS.get(coordDim) != null) {
  676. resultItem.otherDims[coordDim] = coordDimIndex;
  677. } else {
  678. resultItem.coordDim = coordDim;
  679. resultItem.coordDimIndex = coordDimIndex;
  680. coordDimNameMap.set(coordDim, true);
  681. }
  682. } // Make sure the first extra dim is 'value'.
  683. var generateCoord = opt.generateCoord;
  684. var generateCoordCount = opt.generateCoordCount;
  685. var fromZero = generateCoordCount != null;
  686. generateCoordCount = generateCoord ? generateCoordCount || 1 : 0;
  687. var extra = generateCoord || 'value'; // Set dim `name` and other `coordDim` and other props.
  688. for (var resultDimIdx = 0; resultDimIdx < dimCount; resultDimIdx++) {
  689. var resultItem = result[resultDimIdx] = result[resultDimIdx] || new DataDimensionInfo();
  690. var coordDim = resultItem.coordDim;
  691. if (coordDim == null) {
  692. resultItem.coordDim = genName(extra, coordDimNameMap, fromZero);
  693. resultItem.coordDimIndex = 0;
  694. if (!generateCoord || generateCoordCount <= 0) {
  695. resultItem.isExtraCoord = true;
  696. }
  697. generateCoordCount--;
  698. }
  699. resultItem.name == null && (resultItem.name = genName(resultItem.coordDim, dataDimNameMap));
  700. if (resultItem.type == null && (guessOrdinal(source, resultDimIdx, resultItem.name) === BE_ORDINAL.Must // Consider the case:
  701. // {
  702. // dataset: {source: [
  703. // ['2001', 123],
  704. // ['2002', 456],
  705. // ...
  706. // ['The others', 987],
  707. // ]},
  708. // series: {type: 'pie'}
  709. // }
  710. // The first colum should better be treated as a "ordinal" although it
  711. // might not able to be detected as an "ordinal" by `guessOrdinal`.
  712. || resultItem.isExtraCoord && (resultItem.otherDims.itemName != null || resultItem.otherDims.seriesName != null))) {
  713. resultItem.type = 'ordinal';
  714. }
  715. }
  716. return result;
  717. } // ??? TODO
  718. // Originally detect dimCount by data[0]. Should we
  719. // optimize it to only by sysDims and dimensions and encode.
  720. // So only necessary dims will be initialized.
  721. // But
  722. // (1) custom series should be considered. where other dims
  723. // may be visited.
  724. // (2) sometimes user need to calcualte bubble size or use visualMap
  725. // on other dimensions besides coordSys needed.
  726. // So, dims that is not used by system, should be shared in storage?
  727. function getDimCount(source, sysDims, dimsDef, optDimCount) {
  728. // Note that the result dimCount should not small than columns count
  729. // of data, otherwise `dataDimNameMap` checking will be incorrect.
  730. var dimCount = Math.max(source.dimensionsDetectCount || 1, sysDims.length, dimsDef.length, optDimCount || 0);
  731. each(sysDims, function (sysDimItem) {
  732. var sysDimItemDimsDef = sysDimItem.dimsDef;
  733. sysDimItemDimsDef && (dimCount = Math.max(dimCount, sysDimItemDimsDef.length));
  734. });
  735. return dimCount;
  736. }
  737. function genName(name, map, fromZero) {
  738. if (fromZero || map.get(name) != null) {
  739. var i = 0;
  740. while (map.get(name + i) != null) {
  741. i++;
  742. }
  743. name += i;
  744. }
  745. map.set(name, true);
  746. return name;
  747. }
  748. var _default = completeDimensions;
  749. module.exports = _default;
  750. /***/ }),
  751. /***/ "./node_modules/echarts/lib/data/helper/dimensionHelper.js":
  752. /*!*****************************************************************!*\
  753. !*** ./node_modules/echarts/lib/data/helper/dimensionHelper.js ***!
  754. \*****************************************************************/
  755. /*! no static exports found */
  756. /***/ (function(module, exports, __webpack_require__) {
  757. /*
  758. * Licensed to the Apache Software Foundation (ASF) under one
  759. * or more contributor license agreements. See the NOTICE file
  760. * distributed with this work for additional information
  761. * regarding copyright ownership. The ASF licenses this file
  762. * to you under the Apache License, Version 2.0 (the
  763. * "License"); you may not use this file except in compliance
  764. * with the License. You may obtain a copy of the License at
  765. *
  766. * http://www.apache.org/licenses/LICENSE-2.0
  767. *
  768. * Unless required by applicable law or agreed to in writing,
  769. * software distributed under the License is distributed on an
  770. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  771. * KIND, either express or implied. See the License for the
  772. * specific language governing permissions and limitations
  773. * under the License.
  774. */
  775. var _util = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  776. var each = _util.each;
  777. var createHashMap = _util.createHashMap;
  778. var assert = _util.assert;
  779. var _config = __webpack_require__(/*! ../../config */ "./node_modules/echarts/lib/config.js");
  780. var __DEV__ = _config.__DEV__;
  781. /*
  782. * Licensed to the Apache Software Foundation (ASF) under one
  783. * or more contributor license agreements. See the NOTICE file
  784. * distributed with this work for additional information
  785. * regarding copyright ownership. The ASF licenses this file
  786. * to you under the Apache License, Version 2.0 (the
  787. * "License"); you may not use this file except in compliance
  788. * with the License. You may obtain a copy of the License at
  789. *
  790. * http://www.apache.org/licenses/LICENSE-2.0
  791. *
  792. * Unless required by applicable law or agreed to in writing,
  793. * software distributed under the License is distributed on an
  794. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  795. * KIND, either express or implied. See the License for the
  796. * specific language governing permissions and limitations
  797. * under the License.
  798. */
  799. var OTHER_DIMENSIONS = createHashMap(['tooltip', 'label', 'itemName', 'itemId', 'seriesName']);
  800. function summarizeDimensions(data) {
  801. var summary = {};
  802. var encode = summary.encode = {};
  803. var notExtraCoordDimMap = createHashMap();
  804. var defaultedLabel = [];
  805. var defaultedTooltip = []; // See the comment of `List.js#userOutput`.
  806. var userOutput = summary.userOutput = {
  807. dimensionNames: data.dimensions.slice(),
  808. encode: {}
  809. };
  810. each(data.dimensions, function (dimName) {
  811. var dimItem = data.getDimensionInfo(dimName);
  812. var coordDim = dimItem.coordDim;
  813. if (coordDim) {
  814. var coordDimIndex = dimItem.coordDimIndex;
  815. getOrCreateEncodeArr(encode, coordDim)[coordDimIndex] = dimName;
  816. if (!dimItem.isExtraCoord) {
  817. notExtraCoordDimMap.set(coordDim, 1); // Use the last coord dim (and label friendly) as default label,
  818. // because when dataset is used, it is hard to guess which dimension
  819. // can be value dimension. If both show x, y on label is not look good,
  820. // and conventionally y axis is focused more.
  821. if (mayLabelDimType(dimItem.type)) {
  822. defaultedLabel[0] = dimName;
  823. } // User output encode do not contain generated coords.
  824. // And it only has index. User can use index to retrieve value from the raw item array.
  825. getOrCreateEncodeArr(userOutput.encode, coordDim)[coordDimIndex] = dimItem.index;
  826. }
  827. if (dimItem.defaultTooltip) {
  828. defaultedTooltip.push(dimName);
  829. }
  830. }
  831. OTHER_DIMENSIONS.each(function (v, otherDim) {
  832. var encodeArr = getOrCreateEncodeArr(encode, otherDim);
  833. var dimIndex = dimItem.otherDims[otherDim];
  834. if (dimIndex != null && dimIndex !== false) {
  835. encodeArr[dimIndex] = dimItem.name;
  836. }
  837. });
  838. });
  839. var dataDimsOnCoord = [];
  840. var encodeFirstDimNotExtra = {};
  841. notExtraCoordDimMap.each(function (v, coordDim) {
  842. var dimArr = encode[coordDim]; // ??? FIXME extra coord should not be set in dataDimsOnCoord.
  843. // But should fix the case that radar axes: simplify the logic
  844. // of `completeDimension`, remove `extraPrefix`.
  845. encodeFirstDimNotExtra[coordDim] = dimArr[0]; // Not necessary to remove duplicate, because a data
  846. // dim canot on more than one coordDim.
  847. dataDimsOnCoord = dataDimsOnCoord.concat(dimArr);
  848. });
  849. summary.dataDimsOnCoord = dataDimsOnCoord;
  850. summary.encodeFirstDimNotExtra = encodeFirstDimNotExtra;
  851. var encodeLabel = encode.label; // FIXME `encode.label` is not recommanded, because formatter can not be set
  852. // in this way. Use label.formatter instead. May be remove this approach someday.
  853. if (encodeLabel && encodeLabel.length) {
  854. defaultedLabel = encodeLabel.slice();
  855. }
  856. var encodeTooltip = encode.tooltip;
  857. if (encodeTooltip && encodeTooltip.length) {
  858. defaultedTooltip = encodeTooltip.slice();
  859. } else if (!defaultedTooltip.length) {
  860. defaultedTooltip = defaultedLabel.slice();
  861. }
  862. encode.defaultedLabel = defaultedLabel;
  863. encode.defaultedTooltip = defaultedTooltip;
  864. return summary;
  865. }
  866. function getOrCreateEncodeArr(encode, dim) {
  867. if (!encode.hasOwnProperty(dim)) {
  868. encode[dim] = [];
  869. }
  870. return encode[dim];
  871. }
  872. function getDimensionTypeByAxis(axisType) {
  873. return axisType === 'category' ? 'ordinal' : axisType === 'time' ? 'time' : 'float';
  874. }
  875. function mayLabelDimType(dimType) {
  876. // In most cases, ordinal and time do not suitable for label.
  877. // Ordinal info can be displayed on axis. Time is too long.
  878. return !(dimType === 'ordinal' || dimType === 'time');
  879. } // function findTheLastDimMayLabel(data) {
  880. // // Get last value dim
  881. // var dimensions = data.dimensions.slice();
  882. // var valueType;
  883. // var valueDim;
  884. // while (dimensions.length && (
  885. // valueDim = dimensions.pop(),
  886. // valueType = data.getDimensionInfo(valueDim).type,
  887. // valueType === 'ordinal' || valueType === 'time'
  888. // )) {} // jshint ignore:line
  889. // return valueDim;
  890. // }
  891. exports.OTHER_DIMENSIONS = OTHER_DIMENSIONS;
  892. exports.summarizeDimensions = summarizeDimensions;
  893. exports.getDimensionTypeByAxis = getDimensionTypeByAxis;
  894. /***/ }),
  895. /***/ "./node_modules/echarts/lib/data/helper/sourceHelper.js":
  896. /*!**************************************************************!*\
  897. !*** ./node_modules/echarts/lib/data/helper/sourceHelper.js ***!
  898. \**************************************************************/
  899. /*! no static exports found */
  900. /***/ (function(module, exports, __webpack_require__) {
  901. /*
  902. * Licensed to the Apache Software Foundation (ASF) under one
  903. * or more contributor license agreements. See the NOTICE file
  904. * distributed with this work for additional information
  905. * regarding copyright ownership. The ASF licenses this file
  906. * to you under the Apache License, Version 2.0 (the
  907. * "License"); you may not use this file except in compliance
  908. * with the License. You may obtain a copy of the License at
  909. *
  910. * http://www.apache.org/licenses/LICENSE-2.0
  911. *
  912. * Unless required by applicable law or agreed to in writing,
  913. * software distributed under the License is distributed on an
  914. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  915. * KIND, either express or implied. See the License for the
  916. * specific language governing permissions and limitations
  917. * under the License.
  918. */
  919. var _config = __webpack_require__(/*! ../../config */ "./node_modules/echarts/lib/config.js");
  920. var __DEV__ = _config.__DEV__;
  921. var _model = __webpack_require__(/*! ../../util/model */ "./node_modules/echarts/lib/util/model.js");
  922. var makeInner = _model.makeInner;
  923. var getDataItemValue = _model.getDataItemValue;
  924. var _util = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  925. var createHashMap = _util.createHashMap;
  926. var each = _util.each;
  927. var map = _util.map;
  928. var isArray = _util.isArray;
  929. var isString = _util.isString;
  930. var isObject = _util.isObject;
  931. var isTypedArray = _util.isTypedArray;
  932. var isArrayLike = _util.isArrayLike;
  933. var extend = _util.extend;
  934. var assert = _util.assert;
  935. var Source = __webpack_require__(/*! ../Source */ "./node_modules/echarts/lib/data/Source.js");
  936. var _sourceType = __webpack_require__(/*! ./sourceType */ "./node_modules/echarts/lib/data/helper/sourceType.js");
  937. var SOURCE_FORMAT_ORIGINAL = _sourceType.SOURCE_FORMAT_ORIGINAL;
  938. var SOURCE_FORMAT_ARRAY_ROWS = _sourceType.SOURCE_FORMAT_ARRAY_ROWS;
  939. var SOURCE_FORMAT_OBJECT_ROWS = _sourceType.SOURCE_FORMAT_OBJECT_ROWS;
  940. var SOURCE_FORMAT_KEYED_COLUMNS = _sourceType.SOURCE_FORMAT_KEYED_COLUMNS;
  941. var SOURCE_FORMAT_UNKNOWN = _sourceType.SOURCE_FORMAT_UNKNOWN;
  942. var SOURCE_FORMAT_TYPED_ARRAY = _sourceType.SOURCE_FORMAT_TYPED_ARRAY;
  943. var SERIES_LAYOUT_BY_ROW = _sourceType.SERIES_LAYOUT_BY_ROW;
  944. /*
  945. * Licensed to the Apache Software Foundation (ASF) under one
  946. * or more contributor license agreements. See the NOTICE file
  947. * distributed with this work for additional information
  948. * regarding copyright ownership. The ASF licenses this file
  949. * to you under the Apache License, Version 2.0 (the
  950. * "License"); you may not use this file except in compliance
  951. * with the License. You may obtain a copy of the License at
  952. *
  953. * http://www.apache.org/licenses/LICENSE-2.0
  954. *
  955. * Unless required by applicable law or agreed to in writing,
  956. * software distributed under the License is distributed on an
  957. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  958. * KIND, either express or implied. See the License for the
  959. * specific language governing permissions and limitations
  960. * under the License.
  961. */
  962. // The result of `guessOrdinal`.
  963. var BE_ORDINAL = {
  964. Must: 1,
  965. // Encounter string but not '-' and not number-like.
  966. Might: 2,
  967. // Encounter string but number-like.
  968. Not: 3 // Other cases
  969. };
  970. var inner = makeInner();
  971. /**
  972. * @see {module:echarts/data/Source}
  973. * @param {module:echarts/component/dataset/DatasetModel} datasetModel
  974. * @return {string} sourceFormat
  975. */
  976. function detectSourceFormat(datasetModel) {
  977. var data = datasetModel.option.source;
  978. var sourceFormat = SOURCE_FORMAT_UNKNOWN;
  979. if (isTypedArray(data)) {
  980. sourceFormat = SOURCE_FORMAT_TYPED_ARRAY;
  981. } else if (isArray(data)) {
  982. // FIXME Whether tolerate null in top level array?
  983. if (data.length === 0) {
  984. sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
  985. }
  986. for (var i = 0, len = data.length; i < len; i++) {
  987. var item = data[i];
  988. if (item == null) {
  989. continue;
  990. } else if (isArray(item)) {
  991. sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
  992. break;
  993. } else if (isObject(item)) {
  994. sourceFormat = SOURCE_FORMAT_OBJECT_ROWS;
  995. break;
  996. }
  997. }
  998. } else if (isObject(data)) {
  999. for (var key in data) {
  1000. if (data.hasOwnProperty(key) && isArrayLike(data[key])) {
  1001. sourceFormat = SOURCE_FORMAT_KEYED_COLUMNS;
  1002. break;
  1003. }
  1004. }
  1005. } else if (data != null) {
  1006. throw new Error('Invalid data');
  1007. }
  1008. inner(datasetModel).sourceFormat = sourceFormat;
  1009. }
  1010. /**
  1011. * [Scenarios]:
  1012. * (1) Provide source data directly:
  1013. * series: {
  1014. * encode: {...},
  1015. * dimensions: [...]
  1016. * seriesLayoutBy: 'row',
  1017. * data: [[...]]
  1018. * }
  1019. * (2) Refer to datasetModel.
  1020. * series: [{
  1021. * encode: {...}
  1022. * // Ignore datasetIndex means `datasetIndex: 0`
  1023. * // and the dimensions defination in dataset is used
  1024. * }, {
  1025. * encode: {...},
  1026. * seriesLayoutBy: 'column',
  1027. * datasetIndex: 1
  1028. * }]
  1029. *
  1030. * Get data from series itself or datset.
  1031. * @return {module:echarts/data/Source} source
  1032. */
  1033. function getSource(seriesModel) {
  1034. return inner(seriesModel).source;
  1035. }
  1036. /**
  1037. * MUST be called before mergeOption of all series.
  1038. * @param {module:echarts/model/Global} ecModel
  1039. */
  1040. function resetSourceDefaulter(ecModel) {
  1041. // `datasetMap` is used to make default encode.
  1042. inner(ecModel).datasetMap = createHashMap();
  1043. }
  1044. /**
  1045. * [Caution]:
  1046. * MUST be called after series option merged and
  1047. * before "series.getInitailData()" called.
  1048. *
  1049. * [The rule of making default encode]:
  1050. * Category axis (if exists) alway map to the first dimension.
  1051. * Each other axis occupies a subsequent dimension.
  1052. *
  1053. * [Why make default encode]:
  1054. * Simplify the typing of encode in option, avoiding the case like that:
  1055. * series: [{encode: {x: 0, y: 1}}, {encode: {x: 0, y: 2}}, {encode: {x: 0, y: 3}}],
  1056. * where the "y" have to be manually typed as "1, 2, 3, ...".
  1057. *
  1058. * @param {module:echarts/model/Series} seriesModel
  1059. */
  1060. function prepareSource(seriesModel) {
  1061. var seriesOption = seriesModel.option;
  1062. var data = seriesOption.data;
  1063. var sourceFormat = isTypedArray(data) ? SOURCE_FORMAT_TYPED_ARRAY : SOURCE_FORMAT_ORIGINAL;
  1064. var fromDataset = false;
  1065. var seriesLayoutBy = seriesOption.seriesLayoutBy;
  1066. var sourceHeader = seriesOption.sourceHeader;
  1067. var dimensionsDefine = seriesOption.dimensions;
  1068. var datasetModel = getDatasetModel(seriesModel);
  1069. if (datasetModel) {
  1070. var datasetOption = datasetModel.option;
  1071. data = datasetOption.source;
  1072. sourceFormat = inner(datasetModel).sourceFormat;
  1073. fromDataset = true; // These settings from series has higher priority.
  1074. seriesLayoutBy = seriesLayoutBy || datasetOption.seriesLayoutBy;
  1075. sourceHeader == null && (sourceHeader = datasetOption.sourceHeader);
  1076. dimensionsDefine = dimensionsDefine || datasetOption.dimensions;
  1077. }
  1078. var completeResult = completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine);
  1079. inner(seriesModel).source = new Source({
  1080. data: data,
  1081. fromDataset: fromDataset,
  1082. seriesLayoutBy: seriesLayoutBy,
  1083. sourceFormat: sourceFormat,
  1084. dimensionsDefine: completeResult.dimensionsDefine,
  1085. startIndex: completeResult.startIndex,
  1086. dimensionsDetectCount: completeResult.dimensionsDetectCount,
  1087. // Note: dataset option does not have `encode`.
  1088. encodeDefine: seriesOption.encode
  1089. });
  1090. } // return {startIndex, dimensionsDefine, dimensionsCount}
  1091. function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine) {
  1092. if (!data) {
  1093. return {
  1094. dimensionsDefine: normalizeDimensionsDefine(dimensionsDefine)
  1095. };
  1096. }
  1097. var dimensionsDetectCount;
  1098. var startIndex;
  1099. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  1100. // Rule: Most of the first line are string: it is header.
  1101. // Caution: consider a line with 5 string and 1 number,
  1102. // it still can not be sure it is a head, because the
  1103. // 5 string may be 5 values of category columns.
  1104. if (sourceHeader === 'auto' || sourceHeader == null) {
  1105. arrayRowsTravelFirst(function (val) {
  1106. // '-' is regarded as null/undefined.
  1107. if (val != null && val !== '-') {
  1108. if (isString(val)) {
  1109. startIndex == null && (startIndex = 1);
  1110. } else {
  1111. startIndex = 0;
  1112. }
  1113. } // 10 is an experience number, avoid long loop.
  1114. }, seriesLayoutBy, data, 10);
  1115. } else {
  1116. startIndex = sourceHeader ? 1 : 0;
  1117. }
  1118. if (!dimensionsDefine && startIndex === 1) {
  1119. dimensionsDefine = [];
  1120. arrayRowsTravelFirst(function (val, index) {
  1121. dimensionsDefine[index] = val != null ? val : '';
  1122. }, seriesLayoutBy, data);
  1123. }
  1124. dimensionsDetectCount = dimensionsDefine ? dimensionsDefine.length : seriesLayoutBy === SERIES_LAYOUT_BY_ROW ? data.length : data[0] ? data[0].length : null;
  1125. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  1126. if (!dimensionsDefine) {
  1127. dimensionsDefine = objectRowsCollectDimensions(data);
  1128. }
  1129. } else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  1130. if (!dimensionsDefine) {
  1131. dimensionsDefine = [];
  1132. each(data, function (colArr, key) {
  1133. dimensionsDefine.push(key);
  1134. });
  1135. }
  1136. } else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  1137. var value0 = getDataItemValue(data[0]);
  1138. dimensionsDetectCount = isArray(value0) && value0.length || 1;
  1139. } else if (sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) {}
  1140. return {
  1141. startIndex: startIndex,
  1142. dimensionsDefine: normalizeDimensionsDefine(dimensionsDefine),
  1143. dimensionsDetectCount: dimensionsDetectCount
  1144. };
  1145. } // Consider dimensions defined like ['A', 'price', 'B', 'price', 'C', 'price'],
  1146. // which is reasonable. But dimension name is duplicated.
  1147. // Returns undefined or an array contains only object without null/undefiend or string.
  1148. function normalizeDimensionsDefine(dimensionsDefine) {
  1149. if (!dimensionsDefine) {
  1150. // The meaning of null/undefined is different from empty array.
  1151. return;
  1152. }
  1153. var nameMap = createHashMap();
  1154. return map(dimensionsDefine, function (item, index) {
  1155. item = extend({}, isObject(item) ? item : {
  1156. name: item
  1157. }); // User can set null in dimensions.
  1158. // We dont auto specify name, othewise a given name may
  1159. // cause it be refered unexpectedly.
  1160. if (item.name == null) {
  1161. return item;
  1162. } // Also consider number form like 2012.
  1163. item.name += ''; // User may also specify displayName.
  1164. // displayName will always exists except user not
  1165. // specified or dim name is not specified or detected.
  1166. // (A auto generated dim name will not be used as
  1167. // displayName).
  1168. if (item.displayName == null) {
  1169. item.displayName = item.name;
  1170. }
  1171. var exist = nameMap.get(item.name);
  1172. if (!exist) {
  1173. nameMap.set(item.name, {
  1174. count: 1
  1175. });
  1176. } else {
  1177. item.name += '-' + exist.count++;
  1178. }
  1179. return item;
  1180. });
  1181. }
  1182. function arrayRowsTravelFirst(cb, seriesLayoutBy, data, maxLoop) {
  1183. maxLoop == null && (maxLoop = Infinity);
  1184. if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
  1185. for (var i = 0; i < data.length && i < maxLoop; i++) {
  1186. cb(data[i] ? data[i][0] : null, i);
  1187. }
  1188. } else {
  1189. var value0 = data[0] || [];
  1190. for (var i = 0; i < value0.length && i < maxLoop; i++) {
  1191. cb(value0[i], i);
  1192. }
  1193. }
  1194. }
  1195. function objectRowsCollectDimensions(data) {
  1196. var firstIndex = 0;
  1197. var obj;
  1198. while (firstIndex < data.length && !(obj = data[firstIndex++])) {} // jshint ignore: line
  1199. if (obj) {
  1200. var dimensions = [];
  1201. each(obj, function (value, key) {
  1202. dimensions.push(key);
  1203. });
  1204. return dimensions;
  1205. }
  1206. }
  1207. /**
  1208. * [The strategy of the arrengment of data dimensions for dataset]:
  1209. * "value way": all axes are non-category axes. So series one by one take
  1210. * several (the number is coordSysDims.length) dimensions from dataset.
  1211. * The result of data arrengment of data dimensions like:
  1212. * | ser0_x | ser0_y | ser1_x | ser1_y | ser2_x | ser2_y |
  1213. * "category way": at least one axis is category axis. So the the first data
  1214. * dimension is always mapped to the first category axis and shared by
  1215. * all of the series. The other data dimensions are taken by series like
  1216. * "value way" does.
  1217. * The result of data arrengment of data dimensions like:
  1218. * | ser_shared_x | ser0_y | ser1_y | ser2_y |
  1219. *
  1220. * @param {Array.<Object|string>} coordDimensions [{name: <string>, type: <string>, dimsDef: <Array>}, ...]
  1221. * @param {module:model/Series} seriesModel
  1222. * @param {module:data/Source} source
  1223. * @return {Object} encode Never be `null/undefined`.
  1224. */
  1225. function makeSeriesEncodeForAxisCoordSys(coordDimensions, seriesModel, source) {
  1226. var encode = {};
  1227. var datasetModel = getDatasetModel(seriesModel); // Currently only make default when using dataset, util more reqirements occur.
  1228. if (!datasetModel || !coordDimensions) {
  1229. return encode;
  1230. }
  1231. var encodeItemName = [];
  1232. var encodeSeriesName = [];
  1233. var ecModel = seriesModel.ecModel;
  1234. var datasetMap = inner(ecModel).datasetMap;
  1235. var key = datasetModel.uid + '_' + source.seriesLayoutBy;
  1236. var baseCategoryDimIndex;
  1237. var categoryWayValueDimStart;
  1238. coordDimensions = coordDimensions.slice();
  1239. each(coordDimensions, function (coordDimInfo, coordDimIdx) {
  1240. !isObject(coordDimInfo) && (coordDimensions[coordDimIdx] = {
  1241. name: coordDimInfo
  1242. });
  1243. if (coordDimInfo.type === 'ordinal' && baseCategoryDimIndex == null) {
  1244. baseCategoryDimIndex = coordDimIdx;
  1245. categoryWayValueDimStart = getDataDimCountOnCoordDim(coordDimensions[coordDimIdx]);
  1246. }
  1247. encode[coordDimInfo.name] = [];
  1248. });
  1249. var datasetRecord = datasetMap.get(key) || datasetMap.set(key, {
  1250. categoryWayDim: categoryWayValueDimStart,
  1251. valueWayDim: 0
  1252. }); // TODO
  1253. // Auto detect first time axis and do arrangement.
  1254. each(coordDimensions, function (coordDimInfo, coordDimIdx) {
  1255. var coordDimName = coordDimInfo.name;
  1256. var count = getDataDimCountOnCoordDim(coordDimInfo); // In value way.
  1257. if (baseCategoryDimIndex == null) {
  1258. var start = datasetRecord.valueWayDim;
  1259. pushDim(encode[coordDimName], start, count);
  1260. pushDim(encodeSeriesName, start, count);
  1261. datasetRecord.valueWayDim += count; // ??? TODO give a better default series name rule?
  1262. // especially when encode x y specified.
  1263. // consider: when mutiple series share one dimension
  1264. // category axis, series name should better use
  1265. // the other dimsion name. On the other hand, use
  1266. // both dimensions name.
  1267. } // In category way, the first category axis.
  1268. else if (baseCategoryDimIndex === coordDimIdx) {
  1269. pushDim(encode[coordDimName], 0, count);
  1270. pushDim(encodeItemName, 0, count);
  1271. } // In category way, the other axis.
  1272. else {
  1273. var start = datasetRecord.categoryWayDim;
  1274. pushDim(encode[coordDimName], start, count);
  1275. pushDim(encodeSeriesName, start, count);
  1276. datasetRecord.categoryWayDim += count;
  1277. }
  1278. });
  1279. function pushDim(dimIdxArr, idxFrom, idxCount) {
  1280. for (var i = 0; i < idxCount; i++) {
  1281. dimIdxArr.push(idxFrom + i);
  1282. }
  1283. }
  1284. function getDataDimCountOnCoordDim(coordDimInfo) {
  1285. var dimsDef = coordDimInfo.dimsDef;
  1286. return dimsDef ? dimsDef.length : 1;
  1287. }
  1288. encodeItemName.length && (encode.itemName = encodeItemName);
  1289. encodeSeriesName.length && (encode.seriesName = encodeSeriesName);
  1290. return encode;
  1291. }
  1292. /**
  1293. * Work for data like [{name: ..., value: ...}, ...].
  1294. *
  1295. * @param {module:model/Series} seriesModel
  1296. * @param {module:data/Source} source
  1297. * @return {Object} encode Never be `null/undefined`.
  1298. */
  1299. function makeSeriesEncodeForNameBased(seriesModel, source, dimCount) {
  1300. var encode = {};
  1301. var datasetModel = getDatasetModel(seriesModel); // Currently only make default when using dataset, util more reqirements occur.
  1302. if (!datasetModel) {
  1303. return encode;
  1304. }
  1305. var sourceFormat = source.sourceFormat;
  1306. var dimensionsDefine = source.dimensionsDefine;
  1307. var potentialNameDimIndex;
  1308. if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS || sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  1309. each(dimensionsDefine, function (dim, idx) {
  1310. if ((isObject(dim) ? dim.name : dim) === 'name') {
  1311. potentialNameDimIndex = idx;
  1312. }
  1313. });
  1314. } // idxResult: {v, n}.
  1315. var idxResult = function () {
  1316. var idxRes0 = {};
  1317. var idxRes1 = {};
  1318. var guessRecords = []; // 5 is an experience value.
  1319. for (var i = 0, len = Math.min(5, dimCount); i < len; i++) {
  1320. var guessResult = doGuessOrdinal(source.data, sourceFormat, source.seriesLayoutBy, dimensionsDefine, source.startIndex, i);
  1321. guessRecords.push(guessResult);
  1322. var isPureNumber = guessResult === BE_ORDINAL.Not; // [Strategy of idxRes0]: find the first BE_ORDINAL.Not as the value dim,
  1323. // and then find a name dim with the priority:
  1324. // "BE_ORDINAL.Might|BE_ORDINAL.Must" > "other dim" > "the value dim itself".
  1325. if (isPureNumber && idxRes0.v == null && i !== potentialNameDimIndex) {
  1326. idxRes0.v = i;
  1327. }
  1328. if (idxRes0.n == null || idxRes0.n === idxRes0.v || !isPureNumber && guessRecords[idxRes0.n] === BE_ORDINAL.Not) {
  1329. idxRes0.n = i;
  1330. }
  1331. if (fulfilled(idxRes0) && guessRecords[idxRes0.n] !== BE_ORDINAL.Not) {
  1332. return idxRes0;
  1333. } // [Strategy of idxRes1]: if idxRes0 not satisfied (that is, no BE_ORDINAL.Not),
  1334. // find the first BE_ORDINAL.Might as the value dim,
  1335. // and then find a name dim with the priority:
  1336. // "other dim" > "the value dim itself".
  1337. // That is for backward compat: number-like (e.g., `'3'`, `'55'`) can be
  1338. // treated as number.
  1339. if (!isPureNumber) {
  1340. if (guessResult === BE_ORDINAL.Might && idxRes1.v == null && i !== potentialNameDimIndex) {
  1341. idxRes1.v = i;
  1342. }
  1343. if (idxRes1.n == null || idxRes1.n === idxRes1.v) {
  1344. idxRes1.n = i;
  1345. }
  1346. }
  1347. }
  1348. function fulfilled(idxResult) {
  1349. return idxResult.v != null && idxResult.n != null;
  1350. }
  1351. return fulfilled(idxRes0) ? idxRes0 : fulfilled(idxRes1) ? idxRes1 : null;
  1352. }();
  1353. if (idxResult) {
  1354. encode.value = idxResult.v; // `potentialNameDimIndex` has highest priority.
  1355. var nameDimIndex = potentialNameDimIndex != null ? potentialNameDimIndex : idxResult.n; // By default, label use itemName in charts.
  1356. // So we dont set encodeLabel here.
  1357. encode.itemName = [nameDimIndex];
  1358. encode.seriesName = [nameDimIndex];
  1359. }
  1360. return encode;
  1361. }
  1362. /**
  1363. * If return null/undefined, indicate that should not use datasetModel.
  1364. */
  1365. function getDatasetModel(seriesModel) {
  1366. var option = seriesModel.option; // Caution: consider the scenario:
  1367. // A dataset is declared and a series is not expected to use the dataset,
  1368. // and at the beginning `setOption({series: { noData })` (just prepare other
  1369. // option but no data), then `setOption({series: {data: [...]}); In this case,
  1370. // the user should set an empty array to avoid that dataset is used by default.
  1371. var thisData = option.data;
  1372. if (!thisData) {
  1373. return seriesModel.ecModel.getComponent('dataset', option.datasetIndex || 0);
  1374. }
  1375. }
  1376. /**
  1377. * The rule should not be complex, otherwise user might not
  1378. * be able to known where the data is wrong.
  1379. * The code is ugly, but how to make it neat?
  1380. *
  1381. * @param {module:echars/data/Source} source
  1382. * @param {number} dimIndex
  1383. * @return {BE_ORDINAL} guess result.
  1384. */
  1385. function guessOrdinal(source, dimIndex) {
  1386. return doGuessOrdinal(source.data, source.sourceFormat, source.seriesLayoutBy, source.dimensionsDefine, source.startIndex, dimIndex);
  1387. } // dimIndex may be overflow source data.
  1388. // return {BE_ORDINAL}
  1389. function doGuessOrdinal(data, sourceFormat, seriesLayoutBy, dimensionsDefine, startIndex, dimIndex) {
  1390. var result; // Experience value.
  1391. var maxLoop = 5;
  1392. if (isTypedArray(data)) {
  1393. return BE_ORDINAL.Not;
  1394. } // When sourceType is 'objectRows' or 'keyedColumns', dimensionsDefine
  1395. // always exists in source.
  1396. var dimName;
  1397. var dimType;
  1398. if (dimensionsDefine) {
  1399. var dimDefItem = dimensionsDefine[dimIndex];
  1400. if (isObject(dimDefItem)) {
  1401. dimName = dimDefItem.name;
  1402. dimType = dimDefItem.type;
  1403. } else if (isString(dimDefItem)) {
  1404. dimName = dimDefItem;
  1405. }
  1406. }
  1407. if (dimType != null) {
  1408. return dimType === 'ordinal' ? BE_ORDINAL.Must : BE_ORDINAL.Not;
  1409. }
  1410. if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
  1411. if (seriesLayoutBy === SERIES_LAYOUT_BY_ROW) {
  1412. var sample = data[dimIndex];
  1413. for (var i = 0; i < (sample || []).length && i < maxLoop; i++) {
  1414. if ((result = detectValue(sample[startIndex + i])) != null) {
  1415. return result;
  1416. }
  1417. }
  1418. } else {
  1419. for (var i = 0; i < data.length && i < maxLoop; i++) {
  1420. var row = data[startIndex + i];
  1421. if (row && (result = detectValue(row[dimIndex])) != null) {
  1422. return result;
  1423. }
  1424. }
  1425. }
  1426. } else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
  1427. if (!dimName) {
  1428. return BE_ORDINAL.Not;
  1429. }
  1430. for (var i = 0; i < data.length && i < maxLoop; i++) {
  1431. var item = data[i];
  1432. if (item && (result = detectValue(item[dimName])) != null) {
  1433. return result;
  1434. }
  1435. }
  1436. } else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
  1437. if (!dimName) {
  1438. return BE_ORDINAL.Not;
  1439. }
  1440. var sample = data[dimName];
  1441. if (!sample || isTypedArray(sample)) {
  1442. return BE_ORDINAL.Not;
  1443. }
  1444. for (var i = 0; i < sample.length && i < maxLoop; i++) {
  1445. if ((result = detectValue(sample[i])) != null) {
  1446. return result;
  1447. }
  1448. }
  1449. } else if (sourceFormat === SOURCE_FORMAT_ORIGINAL) {
  1450. for (var i = 0; i < data.length && i < maxLoop; i++) {
  1451. var item = data[i];
  1452. var val = getDataItemValue(item);
  1453. if (!isArray(val)) {
  1454. return BE_ORDINAL.Not;
  1455. }
  1456. if ((result = detectValue(val[dimIndex])) != null) {
  1457. return result;
  1458. }
  1459. }
  1460. }
  1461. function detectValue(val) {
  1462. var beStr = isString(val); // Consider usage convenience, '1', '2' will be treated as "number".
  1463. // `isFinit('')` get `true`.
  1464. if (val != null && isFinite(val) && val !== '') {
  1465. return beStr ? BE_ORDINAL.Might : BE_ORDINAL.Not;
  1466. } else if (beStr && val !== '-') {
  1467. return BE_ORDINAL.Must;
  1468. }
  1469. }
  1470. return BE_ORDINAL.Not;
  1471. }
  1472. exports.BE_ORDINAL = BE_ORDINAL;
  1473. exports.detectSourceFormat = detectSourceFormat;
  1474. exports.getSource = getSource;
  1475. exports.resetSourceDefaulter = resetSourceDefaulter;
  1476. exports.prepareSource = prepareSource;
  1477. exports.makeSeriesEncodeForAxisCoordSys = makeSeriesEncodeForAxisCoordSys;
  1478. exports.makeSeriesEncodeForNameBased = makeSeriesEncodeForNameBased;
  1479. exports.guessOrdinal = guessOrdinal;
  1480. /***/ }),
  1481. /***/ "./node_modules/echarts/lib/data/helper/sourceType.js":
  1482. /*!************************************************************!*\
  1483. !*** ./node_modules/echarts/lib/data/helper/sourceType.js ***!
  1484. \************************************************************/
  1485. /*! no static exports found */
  1486. /***/ (function(module, exports) {
  1487. /*
  1488. * Licensed to the Apache Software Foundation (ASF) under one
  1489. * or more contributor license agreements. See the NOTICE file
  1490. * distributed with this work for additional information
  1491. * regarding copyright ownership. The ASF licenses this file
  1492. * to you under the Apache License, Version 2.0 (the
  1493. * "License"); you may not use this file except in compliance
  1494. * with the License. You may obtain a copy of the License at
  1495. *
  1496. * http://www.apache.org/licenses/LICENSE-2.0
  1497. *
  1498. * Unless required by applicable law or agreed to in writing,
  1499. * software distributed under the License is distributed on an
  1500. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1501. * KIND, either express or implied. See the License for the
  1502. * specific language governing permissions and limitations
  1503. * under the License.
  1504. */
  1505. /*
  1506. * Licensed to the Apache Software Foundation (ASF) under one
  1507. * or more contributor license agreements. See the NOTICE file
  1508. * distributed with this work for additional information
  1509. * regarding copyright ownership. The ASF licenses this file
  1510. * to you under the Apache License, Version 2.0 (the
  1511. * "License"); you may not use this file except in compliance
  1512. * with the License. You may obtain a copy of the License at
  1513. *
  1514. * http://www.apache.org/licenses/LICENSE-2.0
  1515. *
  1516. * Unless required by applicable law or agreed to in writing,
  1517. * software distributed under the License is distributed on an
  1518. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1519. * KIND, either express or implied. See the License for the
  1520. * specific language governing permissions and limitations
  1521. * under the License.
  1522. */
  1523. // Avoid typo.
  1524. var SOURCE_FORMAT_ORIGINAL = 'original';
  1525. var SOURCE_FORMAT_ARRAY_ROWS = 'arrayRows';
  1526. var SOURCE_FORMAT_OBJECT_ROWS = 'objectRows';
  1527. var SOURCE_FORMAT_KEYED_COLUMNS = 'keyedColumns';
  1528. var SOURCE_FORMAT_UNKNOWN = 'unknown'; // ??? CHANGE A NAME
  1529. var SOURCE_FORMAT_TYPED_ARRAY = 'typedArray';
  1530. var SERIES_LAYOUT_BY_COLUMN = 'column';
  1531. var SERIES_LAYOUT_BY_ROW = 'row';
  1532. exports.SOURCE_FORMAT_ORIGINAL = SOURCE_FORMAT_ORIGINAL;
  1533. exports.SOURCE_FORMAT_ARRAY_ROWS = SOURCE_FORMAT_ARRAY_ROWS;
  1534. exports.SOURCE_FORMAT_OBJECT_ROWS = SOURCE_FORMAT_OBJECT_ROWS;
  1535. exports.SOURCE_FORMAT_KEYED_COLUMNS = SOURCE_FORMAT_KEYED_COLUMNS;
  1536. exports.SOURCE_FORMAT_UNKNOWN = SOURCE_FORMAT_UNKNOWN;
  1537. exports.SOURCE_FORMAT_TYPED_ARRAY = SOURCE_FORMAT_TYPED_ARRAY;
  1538. exports.SERIES_LAYOUT_BY_COLUMN = SERIES_LAYOUT_BY_COLUMN;
  1539. exports.SERIES_LAYOUT_BY_ROW = SERIES_LAYOUT_BY_ROW;
  1540. /***/ }),
  1541. /***/ "./node_modules/echarts/lib/util/clazz.js":
  1542. /*!************************************************!*\
  1543. !*** ./node_modules/echarts/lib/util/clazz.js ***!
  1544. \************************************************/
  1545. /*! no static exports found */
  1546. /***/ (function(module, exports, __webpack_require__) {
  1547. /*
  1548. * Licensed to the Apache Software Foundation (ASF) under one
  1549. * or more contributor license agreements. See the NOTICE file
  1550. * distributed with this work for additional information
  1551. * regarding copyright ownership. The ASF licenses this file
  1552. * to you under the Apache License, Version 2.0 (the
  1553. * "License"); you may not use this file except in compliance
  1554. * with the License. You may obtain a copy of the License at
  1555. *
  1556. * http://www.apache.org/licenses/LICENSE-2.0
  1557. *
  1558. * Unless required by applicable law or agreed to in writing,
  1559. * software distributed under the License is distributed on an
  1560. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1561. * KIND, either express or implied. See the License for the
  1562. * specific language governing permissions and limitations
  1563. * under the License.
  1564. */
  1565. var _config = __webpack_require__(/*! ../config */ "./node_modules/echarts/lib/config.js");
  1566. var __DEV__ = _config.__DEV__;
  1567. var zrUtil = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  1568. /*
  1569. * Licensed to the Apache Software Foundation (ASF) under one
  1570. * or more contributor license agreements. See the NOTICE file
  1571. * distributed with this work for additional information
  1572. * regarding copyright ownership. The ASF licenses this file
  1573. * to you under the Apache License, Version 2.0 (the
  1574. * "License"); you may not use this file except in compliance
  1575. * with the License. You may obtain a copy of the License at
  1576. *
  1577. * http://www.apache.org/licenses/LICENSE-2.0
  1578. *
  1579. * Unless required by applicable law or agreed to in writing,
  1580. * software distributed under the License is distributed on an
  1581. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1582. * KIND, either express or implied. See the License for the
  1583. * specific language governing permissions and limitations
  1584. * under the License.
  1585. */
  1586. var TYPE_DELIMITER = '.';
  1587. var IS_CONTAINER = '___EC__COMPONENT__CONTAINER___';
  1588. /**
  1589. * Notice, parseClassType('') should returns {main: '', sub: ''}
  1590. * @public
  1591. */
  1592. function parseClassType(componentType) {
  1593. var ret = {
  1594. main: '',
  1595. sub: ''
  1596. };
  1597. if (componentType) {
  1598. componentType = componentType.split(TYPE_DELIMITER);
  1599. ret.main = componentType[0] || '';
  1600. ret.sub = componentType[1] || '';
  1601. }
  1602. return ret;
  1603. }
  1604. /**
  1605. * @public
  1606. */
  1607. function checkClassType(componentType) {
  1608. zrUtil.assert(/^[a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)?$/.test(componentType), 'componentType "' + componentType + '" illegal');
  1609. }
  1610. /**
  1611. * @public
  1612. */
  1613. function enableClassExtend(RootClass, mandatoryMethods) {
  1614. RootClass.$constructor = RootClass;
  1615. RootClass.extend = function (proto) {
  1616. var superClass = this;
  1617. var ExtendedClass = function () {
  1618. if (!proto.$constructor) {
  1619. superClass.apply(this, arguments);
  1620. } else {
  1621. proto.$constructor.apply(this, arguments);
  1622. }
  1623. };
  1624. zrUtil.extend(ExtendedClass.prototype, proto);
  1625. ExtendedClass.extend = this.extend;
  1626. ExtendedClass.superCall = superCall;
  1627. ExtendedClass.superApply = superApply;
  1628. zrUtil.inherits(ExtendedClass, this);
  1629. ExtendedClass.superClass = superClass;
  1630. return ExtendedClass;
  1631. };
  1632. }
  1633. var classBase = 0;
  1634. /**
  1635. * Can not use instanceof, consider different scope by
  1636. * cross domain or es module import in ec extensions.
  1637. * Mount a method "isInstance()" to Clz.
  1638. */
  1639. function enableClassCheck(Clz) {
  1640. var classAttr = ['__\0is_clz', classBase++, Math.random().toFixed(3)].join('_');
  1641. Clz.prototype[classAttr] = true;
  1642. Clz.isInstance = function (obj) {
  1643. return !!(obj && obj[classAttr]);
  1644. };
  1645. } // superCall should have class info, which can not be fetch from 'this'.
  1646. // Consider this case:
  1647. // class A has method f,
  1648. // class B inherits class A, overrides method f, f call superApply('f'),
  1649. // class C inherits class B, do not overrides method f,
  1650. // then when method of class C is called, dead loop occured.
  1651. function superCall(context, methodName) {
  1652. var args = zrUtil.slice(arguments, 2);
  1653. return this.superClass.prototype[methodName].apply(context, args);
  1654. }
  1655. function superApply(context, methodName, args) {
  1656. return this.superClass.prototype[methodName].apply(context, args);
  1657. }
  1658. /**
  1659. * @param {Object} entity
  1660. * @param {Object} options
  1661. * @param {boolean} [options.registerWhenExtend]
  1662. * @public
  1663. */
  1664. function enableClassManagement(entity, options) {
  1665. options = options || {};
  1666. /**
  1667. * Component model classes
  1668. * key: componentType,
  1669. * value:
  1670. * componentClass, when componentType is 'xxx'
  1671. * or Object.<subKey, componentClass>, when componentType is 'xxx.yy'
  1672. * @type {Object}
  1673. */
  1674. var storage = {};
  1675. entity.registerClass = function (Clazz, componentType) {
  1676. if (componentType) {
  1677. checkClassType(componentType);
  1678. componentType = parseClassType(componentType);
  1679. if (!componentType.sub) {
  1680. storage[componentType.main] = Clazz;
  1681. } else if (componentType.sub !== IS_CONTAINER) {
  1682. var container = makeContainer(componentType);
  1683. container[componentType.sub] = Clazz;
  1684. }
  1685. }
  1686. return Clazz;
  1687. };
  1688. entity.getClass = function (componentMainType, subType, throwWhenNotFound) {
  1689. var Clazz = storage[componentMainType];
  1690. if (Clazz && Clazz[IS_CONTAINER]) {
  1691. Clazz = subType ? Clazz[subType] : null;
  1692. }
  1693. if (throwWhenNotFound && !Clazz) {
  1694. throw new Error(!subType ? componentMainType + '.' + 'type should be specified.' : 'Component ' + componentMainType + '.' + (subType || '') + ' not exists. Load it first.');
  1695. }
  1696. return Clazz;
  1697. };
  1698. entity.getClassesByMainType = function (componentType) {
  1699. componentType = parseClassType(componentType);
  1700. var result = [];
  1701. var obj = storage[componentType.main];
  1702. if (obj && obj[IS_CONTAINER]) {
  1703. zrUtil.each(obj, function (o, type) {
  1704. type !== IS_CONTAINER && result.push(o);
  1705. });
  1706. } else {
  1707. result.push(obj);
  1708. }
  1709. return result;
  1710. };
  1711. entity.hasClass = function (componentType) {
  1712. // Just consider componentType.main.
  1713. componentType = parseClassType(componentType);
  1714. return !!storage[componentType.main];
  1715. };
  1716. /**
  1717. * @return {Array.<string>} Like ['aa', 'bb'], but can not be ['aa.xx']
  1718. */
  1719. entity.getAllClassMainTypes = function () {
  1720. var types = [];
  1721. zrUtil.each(storage, function (obj, type) {
  1722. types.push(type);
  1723. });
  1724. return types;
  1725. };
  1726. /**
  1727. * If a main type is container and has sub types
  1728. * @param {string} mainType
  1729. * @return {boolean}
  1730. */
  1731. entity.hasSubTypes = function (componentType) {
  1732. componentType = parseClassType(componentType);
  1733. var obj = storage[componentType.main];
  1734. return obj && obj[IS_CONTAINER];
  1735. };
  1736. entity.parseClassType = parseClassType;
  1737. function makeContainer(componentType) {
  1738. var container = storage[componentType.main];
  1739. if (!container || !container[IS_CONTAINER]) {
  1740. container = storage[componentType.main] = {};
  1741. container[IS_CONTAINER] = true;
  1742. }
  1743. return container;
  1744. }
  1745. if (options.registerWhenExtend) {
  1746. var originalExtend = entity.extend;
  1747. if (originalExtend) {
  1748. entity.extend = function (proto) {
  1749. var ExtendedClass = originalExtend.call(this, proto);
  1750. return entity.registerClass(ExtendedClass, proto.type);
  1751. };
  1752. }
  1753. }
  1754. return entity;
  1755. }
  1756. /**
  1757. * @param {string|Array.<string>} properties
  1758. */
  1759. function setReadOnly(obj, properties) {// FIXME It seems broken in IE8 simulation of IE11
  1760. // if (!zrUtil.isArray(properties)) {
  1761. // properties = properties != null ? [properties] : [];
  1762. // }
  1763. // zrUtil.each(properties, function (prop) {
  1764. // var value = obj[prop];
  1765. // Object.defineProperty
  1766. // && Object.defineProperty(obj, prop, {
  1767. // value: value, writable: false
  1768. // });
  1769. // zrUtil.isArray(obj[prop])
  1770. // && Object.freeze
  1771. // && Object.freeze(obj[prop]);
  1772. // });
  1773. }
  1774. exports.parseClassType = parseClassType;
  1775. exports.enableClassExtend = enableClassExtend;
  1776. exports.enableClassCheck = enableClassCheck;
  1777. exports.enableClassManagement = enableClassManagement;
  1778. exports.setReadOnly = setReadOnly;
  1779. /***/ }),
  1780. /***/ "./node_modules/echarts/lib/util/graphic.js":
  1781. /*!**************************************************!*\
  1782. !*** ./node_modules/echarts/lib/util/graphic.js ***!
  1783. \**************************************************/
  1784. /*! no static exports found */
  1785. /***/ (function(module, exports, __webpack_require__) {
  1786. /*
  1787. * Licensed to the Apache Software Foundation (ASF) under one
  1788. * or more contributor license agreements. See the NOTICE file
  1789. * distributed with this work for additional information
  1790. * regarding copyright ownership. The ASF licenses this file
  1791. * to you under the Apache License, Version 2.0 (the
  1792. * "License"); you may not use this file except in compliance
  1793. * with the License. You may obtain a copy of the License at
  1794. *
  1795. * http://www.apache.org/licenses/LICENSE-2.0
  1796. *
  1797. * Unless required by applicable law or agreed to in writing,
  1798. * software distributed under the License is distributed on an
  1799. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1800. * KIND, either express or implied. See the License for the
  1801. * specific language governing permissions and limitations
  1802. * under the License.
  1803. */
  1804. var zrUtil = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  1805. var pathTool = __webpack_require__(/*! zrender/lib/tool/path */ "./node_modules/zrender/lib/tool/path.js");
  1806. var colorTool = __webpack_require__(/*! zrender/lib/tool/color */ "./node_modules/zrender/lib/tool/color.js");
  1807. var matrix = __webpack_require__(/*! zrender/lib/core/matrix */ "./node_modules/zrender/lib/core/matrix.js");
  1808. var vector = __webpack_require__(/*! zrender/lib/core/vector */ "./node_modules/zrender/lib/core/vector.js");
  1809. var Path = __webpack_require__(/*! zrender/lib/graphic/Path */ "./node_modules/zrender/lib/graphic/Path.js");
  1810. var Transformable = __webpack_require__(/*! zrender/lib/mixin/Transformable */ "./node_modules/zrender/lib/mixin/Transformable.js");
  1811. var ZImage = __webpack_require__(/*! zrender/lib/graphic/Image */ "./node_modules/zrender/lib/graphic/Image.js");
  1812. exports.Image = ZImage;
  1813. var Group = __webpack_require__(/*! zrender/lib/container/Group */ "./node_modules/zrender/lib/container/Group.js");
  1814. exports.Group = Group;
  1815. var Text = __webpack_require__(/*! zrender/lib/graphic/Text */ "./node_modules/zrender/lib/graphic/Text.js");
  1816. exports.Text = Text;
  1817. var Circle = __webpack_require__(/*! zrender/lib/graphic/shape/Circle */ "./node_modules/zrender/lib/graphic/shape/Circle.js");
  1818. exports.Circle = Circle;
  1819. var Sector = __webpack_require__(/*! zrender/lib/graphic/shape/Sector */ "./node_modules/zrender/lib/graphic/shape/Sector.js");
  1820. exports.Sector = Sector;
  1821. var Ring = __webpack_require__(/*! zrender/lib/graphic/shape/Ring */ "./node_modules/zrender/lib/graphic/shape/Ring.js");
  1822. exports.Ring = Ring;
  1823. var Polygon = __webpack_require__(/*! zrender/lib/graphic/shape/Polygon */ "./node_modules/zrender/lib/graphic/shape/Polygon.js");
  1824. exports.Polygon = Polygon;
  1825. var Polyline = __webpack_require__(/*! zrender/lib/graphic/shape/Polyline */ "./node_modules/zrender/lib/graphic/shape/Polyline.js");
  1826. exports.Polyline = Polyline;
  1827. var Rect = __webpack_require__(/*! zrender/lib/graphic/shape/Rect */ "./node_modules/zrender/lib/graphic/shape/Rect.js");
  1828. exports.Rect = Rect;
  1829. var Line = __webpack_require__(/*! zrender/lib/graphic/shape/Line */ "./node_modules/zrender/lib/graphic/shape/Line.js");
  1830. exports.Line = Line;
  1831. var BezierCurve = __webpack_require__(/*! zrender/lib/graphic/shape/BezierCurve */ "./node_modules/zrender/lib/graphic/shape/BezierCurve.js");
  1832. exports.BezierCurve = BezierCurve;
  1833. var Arc = __webpack_require__(/*! zrender/lib/graphic/shape/Arc */ "./node_modules/zrender/lib/graphic/shape/Arc.js");
  1834. exports.Arc = Arc;
  1835. var CompoundPath = __webpack_require__(/*! zrender/lib/graphic/CompoundPath */ "./node_modules/zrender/lib/graphic/CompoundPath.js");
  1836. exports.CompoundPath = CompoundPath;
  1837. var LinearGradient = __webpack_require__(/*! zrender/lib/graphic/LinearGradient */ "./node_modules/zrender/lib/graphic/LinearGradient.js");
  1838. exports.LinearGradient = LinearGradient;
  1839. var RadialGradient = __webpack_require__(/*! zrender/lib/graphic/RadialGradient */ "./node_modules/zrender/lib/graphic/RadialGradient.js");
  1840. exports.RadialGradient = RadialGradient;
  1841. var BoundingRect = __webpack_require__(/*! zrender/lib/core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  1842. exports.BoundingRect = BoundingRect;
  1843. var IncrementalDisplayable = __webpack_require__(/*! zrender/lib/graphic/IncrementalDisplayable */ "./node_modules/zrender/lib/graphic/IncrementalDisplayable.js");
  1844. exports.IncrementalDisplayable = IncrementalDisplayable;
  1845. var subPixelOptimizeUtil = __webpack_require__(/*! zrender/lib/graphic/helper/subPixelOptimize */ "./node_modules/zrender/lib/graphic/helper/subPixelOptimize.js");
  1846. /*
  1847. * Licensed to the Apache Software Foundation (ASF) under one
  1848. * or more contributor license agreements. See the NOTICE file
  1849. * distributed with this work for additional information
  1850. * regarding copyright ownership. The ASF licenses this file
  1851. * to you under the Apache License, Version 2.0 (the
  1852. * "License"); you may not use this file except in compliance
  1853. * with the License. You may obtain a copy of the License at
  1854. *
  1855. * http://www.apache.org/licenses/LICENSE-2.0
  1856. *
  1857. * Unless required by applicable law or agreed to in writing,
  1858. * software distributed under the License is distributed on an
  1859. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  1860. * KIND, either express or implied. See the License for the
  1861. * specific language governing permissions and limitations
  1862. * under the License.
  1863. */
  1864. var mathMax = Math.max;
  1865. var mathMin = Math.min;
  1866. var EMPTY_OBJ = {};
  1867. var Z2_EMPHASIS_LIFT = 1; // key: label model property nane, value: style property name.
  1868. var CACHED_LABEL_STYLE_PROPERTIES = {
  1869. color: 'textFill',
  1870. textBorderColor: 'textStroke',
  1871. textBorderWidth: 'textStrokeWidth'
  1872. };
  1873. var EMPHASIS = 'emphasis';
  1874. var NORMAL = 'normal'; // Reserve 0 as default.
  1875. var _highlightNextDigit = 1;
  1876. var _highlightKeyMap = {};
  1877. var _customShapeMap = {};
  1878. /**
  1879. * Extend shape with parameters
  1880. */
  1881. function extendShape(opts) {
  1882. return Path.extend(opts);
  1883. }
  1884. /**
  1885. * Extend path
  1886. */
  1887. function extendPath(pathData, opts) {
  1888. return pathTool.extendFromString(pathData, opts);
  1889. }
  1890. /**
  1891. * Register a user defined shape.
  1892. * The shape class can be fetched by `getShapeClass`
  1893. * This method will overwrite the registered shapes, including
  1894. * the registered built-in shapes, if using the same `name`.
  1895. * The shape can be used in `custom series` and
  1896. * `graphic component` by declaring `{type: name}`.
  1897. *
  1898. * @param {string} name
  1899. * @param {Object} ShapeClass Can be generated by `extendShape`.
  1900. */
  1901. function registerShape(name, ShapeClass) {
  1902. _customShapeMap[name] = ShapeClass;
  1903. }
  1904. /**
  1905. * Find shape class registered by `registerShape`. Usually used in
  1906. * fetching user defined shape.
  1907. *
  1908. * [Caution]:
  1909. * (1) This method **MUST NOT be used inside echarts !!!**, unless it is prepared
  1910. * to use user registered shapes.
  1911. * Because the built-in shape (see `getBuiltInShape`) will be registered by
  1912. * `registerShape` by default. That enables users to get both built-in
  1913. * shapes as well as the shapes belonging to themsleves. But users can overwrite
  1914. * the built-in shapes by using names like 'circle', 'rect' via calling
  1915. * `registerShape`. So the echarts inner featrues should not fetch shapes from here
  1916. * in case that it is overwritten by users, except that some features, like
  1917. * `custom series`, `graphic component`, do it deliberately.
  1918. *
  1919. * (2) In the features like `custom series`, `graphic component`, the user input
  1920. * `{tpye: 'xxx'}` does not only specify shapes but also specify other graphic
  1921. * elements like `'group'`, `'text'`, `'image'` or event `'path'`. Those names
  1922. * are reserved names, that is, if some user register a shape named `'image'`,
  1923. * the shape will not be used. If we intending to add some more reserved names
  1924. * in feature, that might bring break changes (disable some existing user shape
  1925. * names). But that case probably rearly happen. So we dont make more mechanism
  1926. * to resolve this issue here.
  1927. *
  1928. * @param {string} name
  1929. * @return {Object} The shape class. If not found, return nothing.
  1930. */
  1931. function getShapeClass(name) {
  1932. if (_customShapeMap.hasOwnProperty(name)) {
  1933. return _customShapeMap[name];
  1934. }
  1935. }
  1936. /**
  1937. * Create a path element from path data string
  1938. * @param {string} pathData
  1939. * @param {Object} opts
  1940. * @param {module:zrender/core/BoundingRect} rect
  1941. * @param {string} [layout=cover] 'center' or 'cover'
  1942. */
  1943. function makePath(pathData, opts, rect, layout) {
  1944. var path = pathTool.createFromString(pathData, opts);
  1945. if (rect) {
  1946. if (layout === 'center') {
  1947. rect = centerGraphic(rect, path.getBoundingRect());
  1948. }
  1949. resizePath(path, rect);
  1950. }
  1951. return path;
  1952. }
  1953. /**
  1954. * Create a image element from image url
  1955. * @param {string} imageUrl image url
  1956. * @param {Object} opts options
  1957. * @param {module:zrender/core/BoundingRect} rect constrain rect
  1958. * @param {string} [layout=cover] 'center' or 'cover'
  1959. */
  1960. function makeImage(imageUrl, rect, layout) {
  1961. var path = new ZImage({
  1962. style: {
  1963. image: imageUrl,
  1964. x: rect.x,
  1965. y: rect.y,
  1966. width: rect.width,
  1967. height: rect.height
  1968. },
  1969. onload: function (img) {
  1970. if (layout === 'center') {
  1971. var boundingRect = {
  1972. width: img.width,
  1973. height: img.height
  1974. };
  1975. path.setStyle(centerGraphic(rect, boundingRect));
  1976. }
  1977. }
  1978. });
  1979. return path;
  1980. }
  1981. /**
  1982. * Get position of centered element in bounding box.
  1983. *
  1984. * @param {Object} rect element local bounding box
  1985. * @param {Object} boundingRect constraint bounding box
  1986. * @return {Object} element position containing x, y, width, and height
  1987. */
  1988. function centerGraphic(rect, boundingRect) {
  1989. // Set rect to center, keep width / height ratio.
  1990. var aspect = boundingRect.width / boundingRect.height;
  1991. var width = rect.height * aspect;
  1992. var height;
  1993. if (width <= rect.width) {
  1994. height = rect.height;
  1995. } else {
  1996. width = rect.width;
  1997. height = width / aspect;
  1998. }
  1999. var cx = rect.x + rect.width / 2;
  2000. var cy = rect.y + rect.height / 2;
  2001. return {
  2002. x: cx - width / 2,
  2003. y: cy - height / 2,
  2004. width: width,
  2005. height: height
  2006. };
  2007. }
  2008. var mergePath = pathTool.mergePath;
  2009. /**
  2010. * Resize a path to fit the rect
  2011. * @param {module:zrender/graphic/Path} path
  2012. * @param {Object} rect
  2013. */
  2014. function resizePath(path, rect) {
  2015. if (!path.applyTransform) {
  2016. return;
  2017. }
  2018. var pathRect = path.getBoundingRect();
  2019. var m = pathRect.calculateTransform(rect);
  2020. path.applyTransform(m);
  2021. }
  2022. /**
  2023. * Sub pixel optimize line for canvas
  2024. *
  2025. * @param {Object} param
  2026. * @param {Object} [param.shape]
  2027. * @param {number} [param.shape.x1]
  2028. * @param {number} [param.shape.y1]
  2029. * @param {number} [param.shape.x2]
  2030. * @param {number} [param.shape.y2]
  2031. * @param {Object} [param.style]
  2032. * @param {number} [param.style.lineWidth]
  2033. * @return {Object} Modified param
  2034. */
  2035. function subPixelOptimizeLine(param) {
  2036. subPixelOptimizeUtil.subPixelOptimizeLine(param.shape, param.shape, param.style);
  2037. return param;
  2038. }
  2039. /**
  2040. * Sub pixel optimize rect for canvas
  2041. *
  2042. * @param {Object} param
  2043. * @param {Object} [param.shape]
  2044. * @param {number} [param.shape.x]
  2045. * @param {number} [param.shape.y]
  2046. * @param {number} [param.shape.width]
  2047. * @param {number} [param.shape.height]
  2048. * @param {Object} [param.style]
  2049. * @param {number} [param.style.lineWidth]
  2050. * @return {Object} Modified param
  2051. */
  2052. function subPixelOptimizeRect(param) {
  2053. subPixelOptimizeUtil.subPixelOptimizeRect(param.shape, param.shape, param.style);
  2054. return param;
  2055. }
  2056. /**
  2057. * Sub pixel optimize for canvas
  2058. *
  2059. * @param {number} position Coordinate, such as x, y
  2060. * @param {number} lineWidth Should be nonnegative integer.
  2061. * @param {boolean=} positiveOrNegative Default false (negative).
  2062. * @return {number} Optimized position.
  2063. */
  2064. var subPixelOptimize = subPixelOptimizeUtil.subPixelOptimize;
  2065. function hasFillOrStroke(fillOrStroke) {
  2066. return fillOrStroke != null && fillOrStroke !== 'none';
  2067. } // Most lifted color are duplicated.
  2068. var liftedColorMap = zrUtil.createHashMap();
  2069. var liftedColorCount = 0;
  2070. function liftColor(color) {
  2071. if (typeof color !== 'string') {
  2072. return color;
  2073. }
  2074. var liftedColor = liftedColorMap.get(color);
  2075. if (!liftedColor) {
  2076. liftedColor = colorTool.lift(color, -0.1);
  2077. if (liftedColorCount < 10000) {
  2078. liftedColorMap.set(color, liftedColor);
  2079. liftedColorCount++;
  2080. }
  2081. }
  2082. return liftedColor;
  2083. }
  2084. function cacheElementStl(el) {
  2085. if (!el.__hoverStlDirty) {
  2086. return;
  2087. }
  2088. el.__hoverStlDirty = false;
  2089. var hoverStyle = el.__hoverStl;
  2090. if (!hoverStyle) {
  2091. el.__cachedNormalStl = el.__cachedNormalZ2 = null;
  2092. return;
  2093. }
  2094. var normalStyle = el.__cachedNormalStl = {};
  2095. el.__cachedNormalZ2 = el.z2;
  2096. var elStyle = el.style;
  2097. for (var name in hoverStyle) {
  2098. // See comment in `singleEnterEmphasis`.
  2099. if (hoverStyle[name] != null) {
  2100. normalStyle[name] = elStyle[name];
  2101. }
  2102. } // Always cache fill and stroke to normalStyle for lifting color.
  2103. normalStyle.fill = elStyle.fill;
  2104. normalStyle.stroke = elStyle.stroke;
  2105. }
  2106. function singleEnterEmphasis(el) {
  2107. var hoverStl = el.__hoverStl;
  2108. if (!hoverStl || el.__highlighted) {
  2109. return;
  2110. }
  2111. var zr = el.__zr;
  2112. var useHoverLayer = el.useHoverLayer && zr && zr.painter.type === 'canvas';
  2113. el.__highlighted = useHoverLayer ? 'layer' : 'plain';
  2114. if (el.isGroup || !zr && el.useHoverLayer) {
  2115. return;
  2116. }
  2117. var elTarget = el;
  2118. var targetStyle = el.style;
  2119. if (useHoverLayer) {
  2120. elTarget = zr.addHover(el);
  2121. targetStyle = elTarget.style;
  2122. }
  2123. rollbackDefaultTextStyle(targetStyle);
  2124. if (!useHoverLayer) {
  2125. cacheElementStl(elTarget);
  2126. } // styles can be:
  2127. // {
  2128. // label: {
  2129. // show: false,
  2130. // position: 'outside',
  2131. // fontSize: 18
  2132. // },
  2133. // emphasis: {
  2134. // label: {
  2135. // show: true
  2136. // }
  2137. // }
  2138. // },
  2139. // where properties of `emphasis` may not appear in `normal`. We previously use
  2140. // module:echarts/util/model#defaultEmphasis to merge `normal` to `emphasis`.
  2141. // But consider rich text and setOption in merge mode, it is impossible to cover
  2142. // all properties in merge. So we use merge mode when setting style here.
  2143. // But we choose the merge strategy that only properties that is not `null/undefined`.
  2144. // Because when making a textStyle (espacially rich text), it is not easy to distinguish
  2145. // `hasOwnProperty` and `null/undefined` in code, so we trade them as the same for simplicity.
  2146. // But this strategy brings a trouble that `null/undefined` can not be used to remove
  2147. // style any more in `emphasis`. Users can both set properties directly on normal and
  2148. // emphasis to avoid this issue, or we might support `'none'` for this case if required.
  2149. targetStyle.extendFrom(hoverStl);
  2150. setDefaultHoverFillStroke(targetStyle, hoverStl, 'fill');
  2151. setDefaultHoverFillStroke(targetStyle, hoverStl, 'stroke');
  2152. applyDefaultTextStyle(targetStyle);
  2153. if (!useHoverLayer) {
  2154. el.dirty(false);
  2155. el.z2 += Z2_EMPHASIS_LIFT;
  2156. }
  2157. }
  2158. function setDefaultHoverFillStroke(targetStyle, hoverStyle, prop) {
  2159. if (!hasFillOrStroke(hoverStyle[prop]) && hasFillOrStroke(targetStyle[prop])) {
  2160. targetStyle[prop] = liftColor(targetStyle[prop]);
  2161. }
  2162. }
  2163. function singleEnterNormal(el) {
  2164. var highlighted = el.__highlighted;
  2165. if (!highlighted) {
  2166. return;
  2167. }
  2168. el.__highlighted = false;
  2169. if (el.isGroup) {
  2170. return;
  2171. }
  2172. if (highlighted === 'layer') {
  2173. el.__zr && el.__zr.removeHover(el);
  2174. } else {
  2175. var style = el.style;
  2176. var normalStl = el.__cachedNormalStl;
  2177. if (normalStl) {
  2178. rollbackDefaultTextStyle(style);
  2179. el.setStyle(normalStl);
  2180. applyDefaultTextStyle(style);
  2181. } // `__cachedNormalZ2` will not be reset if calling `setElementHoverStyle`
  2182. // when `el` is on emphasis state. So here by comparing with 1, we try
  2183. // hard to make the bug case rare.
  2184. var normalZ2 = el.__cachedNormalZ2;
  2185. if (normalZ2 != null && el.z2 - normalZ2 === Z2_EMPHASIS_LIFT) {
  2186. el.z2 = normalZ2;
  2187. }
  2188. }
  2189. }
  2190. function traverseUpdate(el, updater, commonParam) {
  2191. // If root is group, also enter updater for `highDownOnUpdate`.
  2192. var fromState = NORMAL;
  2193. var toState = NORMAL;
  2194. var trigger; // See the rule of `highDownOnUpdate` on `graphic.setAsHighDownDispatcher`.
  2195. el.__highlighted && (fromState = EMPHASIS, trigger = true);
  2196. updater(el, commonParam);
  2197. el.__highlighted && (toState = EMPHASIS, trigger = true);
  2198. el.isGroup && el.traverse(function (child) {
  2199. !child.isGroup && updater(child, commonParam);
  2200. });
  2201. trigger && el.__highDownOnUpdate && el.__highDownOnUpdate(fromState, toState);
  2202. }
  2203. /**
  2204. * Set hover style (namely "emphasis style") of element, based on the current
  2205. * style of the given `el`.
  2206. * This method should be called after all of the normal styles have been adopted
  2207. * to the `el`. See the reason on `setHoverStyle`.
  2208. *
  2209. * @param {module:zrender/Element} el Should not be `zrender/container/Group`.
  2210. * @param {Object} [el.hoverStyle] Can be set on el or its descendants,
  2211. * e.g., `el.hoverStyle = ...; graphic.setHoverStyle(el); `.
  2212. * Often used when item group has a label element and it's hoverStyle is different.
  2213. * @param {Object|boolean} [hoverStl] The specified hover style.
  2214. * If set as `false`, disable the hover style.
  2215. * Similarly, The `el.hoverStyle` can alse be set
  2216. * as `false` to disable the hover style.
  2217. * Otherwise, use the default hover style if not provided.
  2218. */
  2219. function setElementHoverStyle(el, hoverStl) {
  2220. // For performance consideration, it might be better to make the "hover style" only the
  2221. // difference properties from the "normal style", but not a entire copy of all styles.
  2222. hoverStl = el.__hoverStl = hoverStl !== false && (el.hoverStyle || hoverStl || {});
  2223. el.__hoverStlDirty = true; // FIXME
  2224. // It is not completely right to save "normal"/"emphasis" flag on elements.
  2225. // It probably should be saved on `data` of series. Consider the cases:
  2226. // (1) A highlighted elements are moved out of the view port and re-enter
  2227. // again by dataZoom.
  2228. // (2) call `setOption` and replace elements totally when they are highlighted.
  2229. if (el.__highlighted) {
  2230. // Consider the case:
  2231. // The styles of a highlighted `el` is being updated. The new "emphasis style"
  2232. // should be adapted to the `el`. Notice here new "normal styles" should have
  2233. // been set outside and the cached "normal style" is out of date.
  2234. el.__cachedNormalStl = null; // Do not clear `__cachedNormalZ2` here, because setting `z2` is not a constraint
  2235. // of this method. In most cases, `z2` is not set and hover style should be able
  2236. // to rollback. Of course, that would bring bug, but only in a rare case, see
  2237. // `doSingleLeaveHover` for details.
  2238. singleEnterNormal(el);
  2239. singleEnterEmphasis(el);
  2240. }
  2241. }
  2242. function onElementMouseOver(e) {
  2243. !shouldSilent(this, e) // "emphasis" event highlight has higher priority than mouse highlight.
  2244. && !this.__highByOuter && traverseUpdate(this, singleEnterEmphasis);
  2245. }
  2246. function onElementMouseOut(e) {
  2247. !shouldSilent(this, e) // "emphasis" event highlight has higher priority than mouse highlight.
  2248. && !this.__highByOuter && traverseUpdate(this, singleEnterNormal);
  2249. }
  2250. function onElementEmphasisEvent(highlightDigit) {
  2251. this.__highByOuter |= 1 << (highlightDigit || 0);
  2252. traverseUpdate(this, singleEnterEmphasis);
  2253. }
  2254. function onElementNormalEvent(highlightDigit) {
  2255. !(this.__highByOuter &= ~(1 << (highlightDigit || 0))) && traverseUpdate(this, singleEnterNormal);
  2256. }
  2257. function shouldSilent(el, e) {
  2258. return el.__highDownSilentOnTouch && e.zrByTouch;
  2259. }
  2260. /**
  2261. * Set hover style (namely "emphasis style") of element,
  2262. * based on the current style of the given `el`.
  2263. *
  2264. * (1)
  2265. * **CONSTRAINTS** for this method:
  2266. * <A> This method MUST be called after all of the normal styles having been adopted
  2267. * to the `el`.
  2268. * <B> The input `hoverStyle` (that is, "emphasis style") MUST be the subset of the
  2269. * "normal style" having been set to the el.
  2270. * <C> `color` MUST be one of the "normal styles" (because color might be lifted as
  2271. * a default hover style).
  2272. *
  2273. * The reason: this method treat the current style of the `el` as the "normal style"
  2274. * and cache them when enter/update the "emphasis style". Consider the case: the `el`
  2275. * is in "emphasis" state and `setOption`/`dispatchAction` trigger the style updating
  2276. * logic, where the el should shift from the original emphasis style to the new
  2277. * "emphasis style" and should be able to "downplay" back to the new "normal style".
  2278. *
  2279. * Indeed, it is error-prone to make a interface has so many constraints, but I have
  2280. * not found a better solution yet to fit the backward compatibility, performance and
  2281. * the current programming style.
  2282. *
  2283. * (2)
  2284. * Call the method for a "root" element once. Do not call it for each descendants.
  2285. * If the descendants elemenets of a group has itself hover style different from the
  2286. * root group, we can simply mount the style on `el.hoverStyle` for them, but should
  2287. * not call this method for them.
  2288. *
  2289. * (3) These input parameters can be set directly on `el`:
  2290. *
  2291. * @param {module:zrender/Element} el
  2292. * @param {Object} [el.hoverStyle] See `graphic.setElementHoverStyle`.
  2293. * @param {boolean} [el.highDownSilentOnTouch=false] See `graphic.setAsHighDownDispatcher`.
  2294. * @param {Function} [el.highDownOnUpdate] See `graphic.setAsHighDownDispatcher`.
  2295. * @param {Object|boolean} [hoverStyle] See `graphic.setElementHoverStyle`.
  2296. */
  2297. function setHoverStyle(el, hoverStyle) {
  2298. setAsHighDownDispatcher(el, true);
  2299. traverseUpdate(el, setElementHoverStyle, hoverStyle);
  2300. }
  2301. /**
  2302. * @param {module:zrender/Element} el
  2303. * @param {Function} [el.highDownOnUpdate] Called when state updated.
  2304. * Since `setHoverStyle` has the constraint that it must be called after
  2305. * all of the normal style updated, `highDownOnUpdate` is not needed to
  2306. * trigger if both `fromState` and `toState` is 'normal', and needed to
  2307. * trigger if both `fromState` and `toState` is 'emphasis', which enables
  2308. * to sync outside style settings to "emphasis" state.
  2309. * @this {string} This dispatcher `el`.
  2310. * @param {string} fromState Can be "normal" or "emphasis".
  2311. * `fromState` might equal to `toState`,
  2312. * for example, when this method is called when `el` is
  2313. * on "emphasis" state.
  2314. * @param {string} toState Can be "normal" or "emphasis".
  2315. *
  2316. * FIXME
  2317. * CAUTION: Do not expose `highDownOnUpdate` outside echarts.
  2318. * Because it is not a complete solution. The update
  2319. * listener should not have been mount in element,
  2320. * and the normal/emphasis state should not have
  2321. * mantained on elements.
  2322. *
  2323. * @param {boolean} [el.highDownSilentOnTouch=false]
  2324. * In touch device, mouseover event will be trigger on touchstart event
  2325. * (see module:zrender/dom/HandlerProxy). By this mechanism, we can
  2326. * conveniently use hoverStyle when tap on touch screen without additional
  2327. * code for compatibility.
  2328. * But if the chart/component has select feature, which usually also use
  2329. * hoverStyle, there might be conflict between 'select-highlight' and
  2330. * 'hover-highlight' especially when roam is enabled (see geo for example).
  2331. * In this case, `highDownSilentOnTouch` should be used to disable
  2332. * hover-highlight on touch device.
  2333. * @param {boolean} [asDispatcher=true] If `false`, do not set as "highDownDispatcher".
  2334. */
  2335. function setAsHighDownDispatcher(el, asDispatcher) {
  2336. var disable = asDispatcher === false; // Make `highDownSilentOnTouch` and `highDownOnUpdate` only work after
  2337. // `setAsHighDownDispatcher` called. Avoid it is modified by user unexpectedly.
  2338. el.__highDownSilentOnTouch = el.highDownSilentOnTouch;
  2339. el.__highDownOnUpdate = el.highDownOnUpdate; // Simple optimize, since this method might be
  2340. // called for each elements of a group in some cases.
  2341. if (!disable || el.__highDownDispatcher) {
  2342. var method = disable ? 'off' : 'on'; // Duplicated function will be auto-ignored, see Eventful.js.
  2343. el[method]('mouseover', onElementMouseOver)[method]('mouseout', onElementMouseOut); // Emphasis, normal can be triggered manually by API or other components like hover link.
  2344. el[method]('emphasis', onElementEmphasisEvent)[method]('normal', onElementNormalEvent); // Also keep previous record.
  2345. el.__highByOuter = el.__highByOuter || 0;
  2346. el.__highDownDispatcher = !disable;
  2347. }
  2348. }
  2349. /**
  2350. * @param {module:zrender/src/Element} el
  2351. * @return {boolean}
  2352. */
  2353. function isHighDownDispatcher(el) {
  2354. return !!(el && el.__highDownDispatcher);
  2355. }
  2356. /**
  2357. * Support hightlight/downplay record on each elements.
  2358. * For the case: hover highlight/downplay (legend, visualMap, ...) and
  2359. * user triggerred hightlight/downplay should not conflict.
  2360. * Only all of the highlightDigit cleared, return to normal.
  2361. * @param {string} highlightKey
  2362. * @return {number} highlightDigit
  2363. */
  2364. function getHighlightDigit(highlightKey) {
  2365. var highlightDigit = _highlightKeyMap[highlightKey];
  2366. if (highlightDigit == null && _highlightNextDigit <= 32) {
  2367. highlightDigit = _highlightKeyMap[highlightKey] = _highlightNextDigit++;
  2368. }
  2369. return highlightDigit;
  2370. }
  2371. /**
  2372. * See more info in `setTextStyleCommon`.
  2373. * @param {Object|module:zrender/graphic/Style} normalStyle
  2374. * @param {Object} emphasisStyle
  2375. * @param {module:echarts/model/Model} normalModel
  2376. * @param {module:echarts/model/Model} emphasisModel
  2377. * @param {Object} opt Check `opt` of `setTextStyleCommon` to find other props.
  2378. * @param {string|Function} [opt.defaultText]
  2379. * @param {module:echarts/model/Model} [opt.labelFetcher] Fetch text by
  2380. * `opt.labelFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex, opt.labelProp)`
  2381. * @param {number} [opt.labelDataIndex] Fetch text by
  2382. * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex, opt.labelProp)`
  2383. * @param {number} [opt.labelDimIndex] Fetch text by
  2384. * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex, opt.labelProp)`
  2385. * @param {string} [opt.labelProp] Fetch text by
  2386. * `opt.textFetcher.getFormattedLabel(opt.labelDataIndex, 'normal'/'emphasis', null, opt.labelDimIndex, opt.labelProp)`
  2387. * @param {Object} [normalSpecified]
  2388. * @param {Object} [emphasisSpecified]
  2389. */
  2390. function setLabelStyle(normalStyle, emphasisStyle, normalModel, emphasisModel, opt, normalSpecified, emphasisSpecified) {
  2391. opt = opt || EMPTY_OBJ;
  2392. var labelFetcher = opt.labelFetcher;
  2393. var labelDataIndex = opt.labelDataIndex;
  2394. var labelDimIndex = opt.labelDimIndex;
  2395. var labelProp = opt.labelProp; // This scenario, `label.normal.show = true; label.emphasis.show = false`,
  2396. // is not supported util someone requests.
  2397. var showNormal = normalModel.getShallow('show');
  2398. var showEmphasis = emphasisModel.getShallow('show'); // Consider performance, only fetch label when necessary.
  2399. // If `normal.show` is `false` and `emphasis.show` is `true` and `emphasis.formatter` is not set,
  2400. // label should be displayed, where text is fetched by `normal.formatter` or `opt.defaultText`.
  2401. var baseText;
  2402. if (showNormal || showEmphasis) {
  2403. if (labelFetcher) {
  2404. baseText = labelFetcher.getFormattedLabel(labelDataIndex, 'normal', null, labelDimIndex, labelProp);
  2405. }
  2406. if (baseText == null) {
  2407. baseText = zrUtil.isFunction(opt.defaultText) ? opt.defaultText(labelDataIndex, opt) : opt.defaultText;
  2408. }
  2409. }
  2410. var normalStyleText = showNormal ? baseText : null;
  2411. var emphasisStyleText = showEmphasis ? zrUtil.retrieve2(labelFetcher ? labelFetcher.getFormattedLabel(labelDataIndex, 'emphasis', null, labelDimIndex, labelProp) : null, baseText) : null; // Optimize: If style.text is null, text will not be drawn.
  2412. if (normalStyleText != null || emphasisStyleText != null) {
  2413. // Always set `textStyle` even if `normalStyle.text` is null, because default
  2414. // values have to be set on `normalStyle`.
  2415. // If we set default values on `emphasisStyle`, consider case:
  2416. // Firstly, `setOption(... label: {normal: {text: null}, emphasis: {show: true}} ...);`
  2417. // Secondly, `setOption(... label: {noraml: {show: true, text: 'abc', color: 'red'} ...);`
  2418. // Then the 'red' will not work on emphasis.
  2419. setTextStyle(normalStyle, normalModel, normalSpecified, opt);
  2420. setTextStyle(emphasisStyle, emphasisModel, emphasisSpecified, opt, true);
  2421. }
  2422. normalStyle.text = normalStyleText;
  2423. emphasisStyle.text = emphasisStyleText;
  2424. }
  2425. /**
  2426. * Modify label style manually.
  2427. * Only works after `setLabelStyle` and `setElementHoverStyle` called.
  2428. *
  2429. * @param {module:zrender/src/Element} el
  2430. * @param {Object} [normalStyleProps] optional
  2431. * @param {Object} [emphasisStyleProps] optional
  2432. */
  2433. function modifyLabelStyle(el, normalStyleProps, emphasisStyleProps) {
  2434. var elStyle = el.style;
  2435. if (normalStyleProps) {
  2436. rollbackDefaultTextStyle(elStyle);
  2437. el.setStyle(normalStyleProps);
  2438. applyDefaultTextStyle(elStyle);
  2439. }
  2440. elStyle = el.__hoverStl;
  2441. if (emphasisStyleProps && elStyle) {
  2442. rollbackDefaultTextStyle(elStyle);
  2443. zrUtil.extend(elStyle, emphasisStyleProps);
  2444. applyDefaultTextStyle(elStyle);
  2445. }
  2446. }
  2447. /**
  2448. * Set basic textStyle properties.
  2449. * See more info in `setTextStyleCommon`.
  2450. * @param {Object|module:zrender/graphic/Style} textStyle
  2451. * @param {module:echarts/model/Model} model
  2452. * @param {Object} [specifiedTextStyle] Can be overrided by settings in model.
  2453. * @param {Object} [opt] See `opt` of `setTextStyleCommon`.
  2454. * @param {boolean} [isEmphasis]
  2455. */
  2456. function setTextStyle(textStyle, textStyleModel, specifiedTextStyle, opt, isEmphasis) {
  2457. setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis);
  2458. specifiedTextStyle && zrUtil.extend(textStyle, specifiedTextStyle); // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
  2459. return textStyle;
  2460. }
  2461. /**
  2462. * Set text option in the style.
  2463. * See more info in `setTextStyleCommon`.
  2464. * @deprecated
  2465. * @param {Object} textStyle
  2466. * @param {module:echarts/model/Model} labelModel
  2467. * @param {string|boolean} defaultColor Default text color.
  2468. * If set as false, it will be processed as a emphasis style.
  2469. */
  2470. function setText(textStyle, labelModel, defaultColor) {
  2471. var opt = {
  2472. isRectText: true
  2473. };
  2474. var isEmphasis;
  2475. if (defaultColor === false) {
  2476. isEmphasis = true;
  2477. } else {
  2478. // Support setting color as 'auto' to get visual color.
  2479. opt.autoColor = defaultColor;
  2480. }
  2481. setTextStyleCommon(textStyle, labelModel, opt, isEmphasis); // textStyle.host && textStyle.host.dirty && textStyle.host.dirty(false);
  2482. }
  2483. /**
  2484. * The uniform entry of set text style, that is, retrieve style definitions
  2485. * from `model` and set to `textStyle` object.
  2486. *
  2487. * Never in merge mode, but in overwrite mode, that is, all of the text style
  2488. * properties will be set. (Consider the states of normal and emphasis and
  2489. * default value can be adopted, merge would make the logic too complicated
  2490. * to manage.)
  2491. *
  2492. * The `textStyle` object can either be a plain object or an instance of
  2493. * `zrender/src/graphic/Style`, and either be the style of normal or emphasis.
  2494. * After this mothod called, the `textStyle` object can then be used in
  2495. * `el.setStyle(textStyle)` or `el.hoverStyle = textStyle`.
  2496. *
  2497. * Default value will be adopted and `insideRollbackOpt` will be created.
  2498. * See `applyDefaultTextStyle` `rollbackDefaultTextStyle` for more details.
  2499. *
  2500. * opt: {
  2501. * disableBox: boolean, Whether diable drawing box of block (outer most).
  2502. * isRectText: boolean,
  2503. * autoColor: string, specify a color when color is 'auto',
  2504. * for textFill, textStroke, textBackgroundColor, and textBorderColor.
  2505. * If autoColor specified, it is used as default textFill.
  2506. * useInsideStyle:
  2507. * `true`: Use inside style (textFill, textStroke, textStrokeWidth)
  2508. * if `textFill` is not specified.
  2509. * `false`: Do not use inside style.
  2510. * `null/undefined`: use inside style if `isRectText` is true and
  2511. * `textFill` is not specified and textPosition contains `'inside'`.
  2512. * forceRich: boolean
  2513. * }
  2514. */
  2515. function setTextStyleCommon(textStyle, textStyleModel, opt, isEmphasis) {
  2516. // Consider there will be abnormal when merge hover style to normal style if given default value.
  2517. opt = opt || EMPTY_OBJ;
  2518. if (opt.isRectText) {
  2519. var textPosition;
  2520. if (opt.getTextPosition) {
  2521. textPosition = opt.getTextPosition(textStyleModel, isEmphasis);
  2522. } else {
  2523. textPosition = textStyleModel.getShallow('position') || (isEmphasis ? null : 'inside'); // 'outside' is not a valid zr textPostion value, but used
  2524. // in bar series, and magric type should be considered.
  2525. textPosition === 'outside' && (textPosition = 'top');
  2526. }
  2527. textStyle.textPosition = textPosition;
  2528. textStyle.textOffset = textStyleModel.getShallow('offset');
  2529. var labelRotate = textStyleModel.getShallow('rotate');
  2530. labelRotate != null && (labelRotate *= Math.PI / 180);
  2531. textStyle.textRotation = labelRotate;
  2532. textStyle.textDistance = zrUtil.retrieve2(textStyleModel.getShallow('distance'), isEmphasis ? null : 5);
  2533. }
  2534. var ecModel = textStyleModel.ecModel;
  2535. var globalTextStyle = ecModel && ecModel.option.textStyle; // Consider case:
  2536. // {
  2537. // data: [{
  2538. // value: 12,
  2539. // label: {
  2540. // rich: {
  2541. // // no 'a' here but using parent 'a'.
  2542. // }
  2543. // }
  2544. // }],
  2545. // rich: {
  2546. // a: { ... }
  2547. // }
  2548. // }
  2549. var richItemNames = getRichItemNames(textStyleModel);
  2550. var richResult;
  2551. if (richItemNames) {
  2552. richResult = {};
  2553. for (var name in richItemNames) {
  2554. if (richItemNames.hasOwnProperty(name)) {
  2555. // Cascade is supported in rich.
  2556. var richTextStyle = textStyleModel.getModel(['rich', name]); // In rich, never `disableBox`.
  2557. // FIXME: consider `label: {formatter: '{a|xx}', color: 'blue', rich: {a: {}}}`,
  2558. // the default color `'blue'` will not be adopted if no color declared in `rich`.
  2559. // That might confuses users. So probably we should put `textStyleModel` as the
  2560. // root ancestor of the `richTextStyle`. But that would be a break change.
  2561. setTokenTextStyle(richResult[name] = {}, richTextStyle, globalTextStyle, opt, isEmphasis);
  2562. }
  2563. }
  2564. }
  2565. textStyle.rich = richResult;
  2566. setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, true);
  2567. if (opt.forceRich && !opt.textStyle) {
  2568. opt.textStyle = {};
  2569. }
  2570. return textStyle;
  2571. } // Consider case:
  2572. // {
  2573. // data: [{
  2574. // value: 12,
  2575. // label: {
  2576. // rich: {
  2577. // // no 'a' here but using parent 'a'.
  2578. // }
  2579. // }
  2580. // }],
  2581. // rich: {
  2582. // a: { ... }
  2583. // }
  2584. // }
  2585. function getRichItemNames(textStyleModel) {
  2586. // Use object to remove duplicated names.
  2587. var richItemNameMap;
  2588. while (textStyleModel && textStyleModel !== textStyleModel.ecModel) {
  2589. var rich = (textStyleModel.option || EMPTY_OBJ).rich;
  2590. if (rich) {
  2591. richItemNameMap = richItemNameMap || {};
  2592. for (var name in rich) {
  2593. if (rich.hasOwnProperty(name)) {
  2594. richItemNameMap[name] = 1;
  2595. }
  2596. }
  2597. }
  2598. textStyleModel = textStyleModel.parentModel;
  2599. }
  2600. return richItemNameMap;
  2601. }
  2602. function setTokenTextStyle(textStyle, textStyleModel, globalTextStyle, opt, isEmphasis, isBlock) {
  2603. // In merge mode, default value should not be given.
  2604. globalTextStyle = !isEmphasis && globalTextStyle || EMPTY_OBJ;
  2605. textStyle.textFill = getAutoColor(textStyleModel.getShallow('color'), opt) || globalTextStyle.color;
  2606. textStyle.textStroke = getAutoColor(textStyleModel.getShallow('textBorderColor'), opt) || globalTextStyle.textBorderColor;
  2607. textStyle.textStrokeWidth = zrUtil.retrieve2(textStyleModel.getShallow('textBorderWidth'), globalTextStyle.textBorderWidth);
  2608. if (!isEmphasis) {
  2609. if (isBlock) {
  2610. textStyle.insideRollbackOpt = opt;
  2611. applyDefaultTextStyle(textStyle);
  2612. } // Set default finally.
  2613. if (textStyle.textFill == null) {
  2614. textStyle.textFill = opt.autoColor;
  2615. }
  2616. } // Do not use `getFont` here, because merge should be supported, where
  2617. // part of these properties may be changed in emphasis style, and the
  2618. // others should remain their original value got from normal style.
  2619. textStyle.fontStyle = textStyleModel.getShallow('fontStyle') || globalTextStyle.fontStyle;
  2620. textStyle.fontWeight = textStyleModel.getShallow('fontWeight') || globalTextStyle.fontWeight;
  2621. textStyle.fontSize = textStyleModel.getShallow('fontSize') || globalTextStyle.fontSize;
  2622. textStyle.fontFamily = textStyleModel.getShallow('fontFamily') || globalTextStyle.fontFamily;
  2623. textStyle.textAlign = textStyleModel.getShallow('align');
  2624. textStyle.textVerticalAlign = textStyleModel.getShallow('verticalAlign') || textStyleModel.getShallow('baseline');
  2625. textStyle.textLineHeight = textStyleModel.getShallow('lineHeight');
  2626. textStyle.textWidth = textStyleModel.getShallow('width');
  2627. textStyle.textHeight = textStyleModel.getShallow('height');
  2628. textStyle.textTag = textStyleModel.getShallow('tag');
  2629. if (!isBlock || !opt.disableBox) {
  2630. textStyle.textBackgroundColor = getAutoColor(textStyleModel.getShallow('backgroundColor'), opt);
  2631. textStyle.textPadding = textStyleModel.getShallow('padding');
  2632. textStyle.textBorderColor = getAutoColor(textStyleModel.getShallow('borderColor'), opt);
  2633. textStyle.textBorderWidth = textStyleModel.getShallow('borderWidth');
  2634. textStyle.textBorderRadius = textStyleModel.getShallow('borderRadius');
  2635. textStyle.textBoxShadowColor = textStyleModel.getShallow('shadowColor');
  2636. textStyle.textBoxShadowBlur = textStyleModel.getShallow('shadowBlur');
  2637. textStyle.textBoxShadowOffsetX = textStyleModel.getShallow('shadowOffsetX');
  2638. textStyle.textBoxShadowOffsetY = textStyleModel.getShallow('shadowOffsetY');
  2639. }
  2640. textStyle.textShadowColor = textStyleModel.getShallow('textShadowColor') || globalTextStyle.textShadowColor;
  2641. textStyle.textShadowBlur = textStyleModel.getShallow('textShadowBlur') || globalTextStyle.textShadowBlur;
  2642. textStyle.textShadowOffsetX = textStyleModel.getShallow('textShadowOffsetX') || globalTextStyle.textShadowOffsetX;
  2643. textStyle.textShadowOffsetY = textStyleModel.getShallow('textShadowOffsetY') || globalTextStyle.textShadowOffsetY;
  2644. }
  2645. function getAutoColor(color, opt) {
  2646. return color !== 'auto' ? color : opt && opt.autoColor ? opt.autoColor : null;
  2647. }
  2648. /**
  2649. * Give some default value to the input `textStyle` object, based on the current settings
  2650. * in this `textStyle` object.
  2651. *
  2652. * The Scenario:
  2653. * when text position is `inside` and `textFill` is not specified, we show
  2654. * text border by default for better view. But it should be considered that text position
  2655. * might be changed when hovering or being emphasis, where the `insideRollback` is used to
  2656. * restore the style.
  2657. *
  2658. * Usage (& NOTICE):
  2659. * When a style object (eithor plain object or instance of `zrender/src/graphic/Style`) is
  2660. * about to be modified on its text related properties, `rollbackDefaultTextStyle` should
  2661. * be called before the modification and `applyDefaultTextStyle` should be called after that.
  2662. * (For the case that all of the text related properties is reset, like `setTextStyleCommon`
  2663. * does, `rollbackDefaultTextStyle` is not needed to be called).
  2664. */
  2665. function applyDefaultTextStyle(textStyle) {
  2666. var textPosition = textStyle.textPosition;
  2667. var opt = textStyle.insideRollbackOpt;
  2668. var insideRollback;
  2669. if (opt && textStyle.textFill == null) {
  2670. var autoColor = opt.autoColor;
  2671. var isRectText = opt.isRectText;
  2672. var useInsideStyle = opt.useInsideStyle;
  2673. var useInsideStyleCache = useInsideStyle !== false && (useInsideStyle === true || isRectText && textPosition // textPosition can be [10, 30]
  2674. && typeof textPosition === 'string' && textPosition.indexOf('inside') >= 0);
  2675. var useAutoColorCache = !useInsideStyleCache && autoColor != null; // All of the props declared in `CACHED_LABEL_STYLE_PROPERTIES` are to be cached.
  2676. if (useInsideStyleCache || useAutoColorCache) {
  2677. insideRollback = {
  2678. textFill: textStyle.textFill,
  2679. textStroke: textStyle.textStroke,
  2680. textStrokeWidth: textStyle.textStrokeWidth
  2681. };
  2682. }
  2683. if (useInsideStyleCache) {
  2684. textStyle.textFill = '#fff'; // Consider text with #fff overflow its container.
  2685. if (textStyle.textStroke == null) {
  2686. textStyle.textStroke = autoColor;
  2687. textStyle.textStrokeWidth == null && (textStyle.textStrokeWidth = 2);
  2688. }
  2689. }
  2690. if (useAutoColorCache) {
  2691. textStyle.textFill = autoColor;
  2692. }
  2693. } // Always set `insideRollback`, so that the previous one can be cleared.
  2694. textStyle.insideRollback = insideRollback;
  2695. }
  2696. /**
  2697. * Consider the case: in a scatter,
  2698. * label: {
  2699. * normal: {position: 'inside'},
  2700. * emphasis: {position: 'top'}
  2701. * }
  2702. * In the normal state, the `textFill` will be set as '#fff' for pretty view (see
  2703. * `applyDefaultTextStyle`), but when switching to emphasis state, the `textFill`
  2704. * should be retured to 'autoColor', but not keep '#fff'.
  2705. */
  2706. function rollbackDefaultTextStyle(style) {
  2707. var insideRollback = style.insideRollback;
  2708. if (insideRollback) {
  2709. // Reset all of the props in `CACHED_LABEL_STYLE_PROPERTIES`.
  2710. style.textFill = insideRollback.textFill;
  2711. style.textStroke = insideRollback.textStroke;
  2712. style.textStrokeWidth = insideRollback.textStrokeWidth;
  2713. style.insideRollback = null;
  2714. }
  2715. }
  2716. function getFont(opt, ecModel) {
  2717. var gTextStyleModel = ecModel && ecModel.getModel('textStyle');
  2718. return zrUtil.trim([// FIXME in node-canvas fontWeight is before fontStyle
  2719. opt.fontStyle || gTextStyleModel && gTextStyleModel.getShallow('fontStyle') || '', opt.fontWeight || gTextStyleModel && gTextStyleModel.getShallow('fontWeight') || '', (opt.fontSize || gTextStyleModel && gTextStyleModel.getShallow('fontSize') || 12) + 'px', opt.fontFamily || gTextStyleModel && gTextStyleModel.getShallow('fontFamily') || 'sans-serif'].join(' '));
  2720. }
  2721. function animateOrSetProps(isUpdate, el, props, animatableModel, dataIndex, cb) {
  2722. if (typeof dataIndex === 'function') {
  2723. cb = dataIndex;
  2724. dataIndex = null;
  2725. } // Do not check 'animation' property directly here. Consider this case:
  2726. // animation model is an `itemModel`, whose does not have `isAnimationEnabled`
  2727. // but its parent model (`seriesModel`) does.
  2728. var animationEnabled = animatableModel && animatableModel.isAnimationEnabled();
  2729. if (animationEnabled) {
  2730. var postfix = isUpdate ? 'Update' : '';
  2731. var duration = animatableModel.getShallow('animationDuration' + postfix);
  2732. var animationEasing = animatableModel.getShallow('animationEasing' + postfix);
  2733. var animationDelay = animatableModel.getShallow('animationDelay' + postfix);
  2734. if (typeof animationDelay === 'function') {
  2735. animationDelay = animationDelay(dataIndex, animatableModel.getAnimationDelayParams ? animatableModel.getAnimationDelayParams(el, dataIndex) : null);
  2736. }
  2737. if (typeof duration === 'function') {
  2738. duration = duration(dataIndex);
  2739. }
  2740. duration > 0 ? el.animateTo(props, duration, animationDelay || 0, animationEasing, cb, !!cb) : (el.stopAnimation(), el.attr(props), cb && cb());
  2741. } else {
  2742. el.stopAnimation();
  2743. el.attr(props);
  2744. cb && cb();
  2745. }
  2746. }
  2747. /**
  2748. * Update graphic element properties with or without animation according to the
  2749. * configuration in series.
  2750. *
  2751. * Caution: this method will stop previous animation.
  2752. * So do not use this method to one element twice before
  2753. * animation starts, unless you know what you are doing.
  2754. *
  2755. * @param {module:zrender/Element} el
  2756. * @param {Object} props
  2757. * @param {module:echarts/model/Model} [animatableModel]
  2758. * @param {number} [dataIndex]
  2759. * @param {Function} [cb]
  2760. * @example
  2761. * graphic.updateProps(el, {
  2762. * position: [100, 100]
  2763. * }, seriesModel, dataIndex, function () { console.log('Animation done!'); });
  2764. * // Or
  2765. * graphic.updateProps(el, {
  2766. * position: [100, 100]
  2767. * }, seriesModel, function () { console.log('Animation done!'); });
  2768. */
  2769. function updateProps(el, props, animatableModel, dataIndex, cb) {
  2770. animateOrSetProps(true, el, props, animatableModel, dataIndex, cb);
  2771. }
  2772. /**
  2773. * Init graphic element properties with or without animation according to the
  2774. * configuration in series.
  2775. *
  2776. * Caution: this method will stop previous animation.
  2777. * So do not use this method to one element twice before
  2778. * animation starts, unless you know what you are doing.
  2779. *
  2780. * @param {module:zrender/Element} el
  2781. * @param {Object} props
  2782. * @param {module:echarts/model/Model} [animatableModel]
  2783. * @param {number} [dataIndex]
  2784. * @param {Function} cb
  2785. */
  2786. function initProps(el, props, animatableModel, dataIndex, cb) {
  2787. animateOrSetProps(false, el, props, animatableModel, dataIndex, cb);
  2788. }
  2789. /**
  2790. * Get transform matrix of target (param target),
  2791. * in coordinate of its ancestor (param ancestor)
  2792. *
  2793. * @param {module:zrender/mixin/Transformable} target
  2794. * @param {module:zrender/mixin/Transformable} [ancestor]
  2795. */
  2796. function getTransform(target, ancestor) {
  2797. var mat = matrix.identity([]);
  2798. while (target && target !== ancestor) {
  2799. matrix.mul(mat, target.getLocalTransform(), mat);
  2800. target = target.parent;
  2801. }
  2802. return mat;
  2803. }
  2804. /**
  2805. * Apply transform to an vertex.
  2806. * @param {Array.<number>} target [x, y]
  2807. * @param {Array.<number>|TypedArray.<number>|Object} transform Can be:
  2808. * + Transform matrix: like [1, 0, 0, 1, 0, 0]
  2809. * + {position, rotation, scale}, the same as `zrender/Transformable`.
  2810. * @param {boolean=} invert Whether use invert matrix.
  2811. * @return {Array.<number>} [x, y]
  2812. */
  2813. function applyTransform(target, transform, invert) {
  2814. if (transform && !zrUtil.isArrayLike(transform)) {
  2815. transform = Transformable.getLocalTransform(transform);
  2816. }
  2817. if (invert) {
  2818. transform = matrix.invert([], transform);
  2819. }
  2820. return vector.applyTransform([], target, transform);
  2821. }
  2822. /**
  2823. * @param {string} direction 'left' 'right' 'top' 'bottom'
  2824. * @param {Array.<number>} transform Transform matrix: like [1, 0, 0, 1, 0, 0]
  2825. * @param {boolean=} invert Whether use invert matrix.
  2826. * @return {string} Transformed direction. 'left' 'right' 'top' 'bottom'
  2827. */
  2828. function transformDirection(direction, transform, invert) {
  2829. // Pick a base, ensure that transform result will not be (0, 0).
  2830. var hBase = transform[4] === 0 || transform[5] === 0 || transform[0] === 0 ? 1 : Math.abs(2 * transform[4] / transform[0]);
  2831. var vBase = transform[4] === 0 || transform[5] === 0 || transform[2] === 0 ? 1 : Math.abs(2 * transform[4] / transform[2]);
  2832. var vertex = [direction === 'left' ? -hBase : direction === 'right' ? hBase : 0, direction === 'top' ? -vBase : direction === 'bottom' ? vBase : 0];
  2833. vertex = applyTransform(vertex, transform, invert);
  2834. return Math.abs(vertex[0]) > Math.abs(vertex[1]) ? vertex[0] > 0 ? 'right' : 'left' : vertex[1] > 0 ? 'bottom' : 'top';
  2835. }
  2836. /**
  2837. * Apply group transition animation from g1 to g2.
  2838. * If no animatableModel, no animation.
  2839. */
  2840. function groupTransition(g1, g2, animatableModel, cb) {
  2841. if (!g1 || !g2) {
  2842. return;
  2843. }
  2844. function getElMap(g) {
  2845. var elMap = {};
  2846. g.traverse(function (el) {
  2847. if (!el.isGroup && el.anid) {
  2848. elMap[el.anid] = el;
  2849. }
  2850. });
  2851. return elMap;
  2852. }
  2853. function getAnimatableProps(el) {
  2854. var obj = {
  2855. position: vector.clone(el.position),
  2856. rotation: el.rotation
  2857. };
  2858. if (el.shape) {
  2859. obj.shape = zrUtil.extend({}, el.shape);
  2860. }
  2861. return obj;
  2862. }
  2863. var elMap1 = getElMap(g1);
  2864. g2.traverse(function (el) {
  2865. if (!el.isGroup && el.anid) {
  2866. var oldEl = elMap1[el.anid];
  2867. if (oldEl) {
  2868. var newProp = getAnimatableProps(el);
  2869. el.attr(getAnimatableProps(oldEl));
  2870. updateProps(el, newProp, animatableModel, el.dataIndex);
  2871. } // else {
  2872. // if (el.previousProps) {
  2873. // graphic.updateProps
  2874. // }
  2875. // }
  2876. }
  2877. });
  2878. }
  2879. /**
  2880. * @param {Array.<Array.<number>>} points Like: [[23, 44], [53, 66], ...]
  2881. * @param {Object} rect {x, y, width, height}
  2882. * @return {Array.<Array.<number>>} A new clipped points.
  2883. */
  2884. function clipPointsByRect(points, rect) {
  2885. // FIXME: this way migth be incorrect when grpahic clipped by a corner.
  2886. // and when element have border.
  2887. return zrUtil.map(points, function (point) {
  2888. var x = point[0];
  2889. x = mathMax(x, rect.x);
  2890. x = mathMin(x, rect.x + rect.width);
  2891. var y = point[1];
  2892. y = mathMax(y, rect.y);
  2893. y = mathMin(y, rect.y + rect.height);
  2894. return [x, y];
  2895. });
  2896. }
  2897. /**
  2898. * @param {Object} targetRect {x, y, width, height}
  2899. * @param {Object} rect {x, y, width, height}
  2900. * @return {Object} A new clipped rect. If rect size are negative, return undefined.
  2901. */
  2902. function clipRectByRect(targetRect, rect) {
  2903. var x = mathMax(targetRect.x, rect.x);
  2904. var x2 = mathMin(targetRect.x + targetRect.width, rect.x + rect.width);
  2905. var y = mathMax(targetRect.y, rect.y);
  2906. var y2 = mathMin(targetRect.y + targetRect.height, rect.y + rect.height); // If the total rect is cliped, nothing, including the border,
  2907. // should be painted. So return undefined.
  2908. if (x2 >= x && y2 >= y) {
  2909. return {
  2910. x: x,
  2911. y: y,
  2912. width: x2 - x,
  2913. height: y2 - y
  2914. };
  2915. }
  2916. }
  2917. /**
  2918. * @param {string} iconStr Support 'image://' or 'path://' or direct svg path.
  2919. * @param {Object} [opt] Properties of `module:zrender/Element`, except `style`.
  2920. * @param {Object} [rect] {x, y, width, height}
  2921. * @return {module:zrender/Element} Icon path or image element.
  2922. */
  2923. function createIcon(iconStr, opt, rect) {
  2924. opt = zrUtil.extend({
  2925. rectHover: true
  2926. }, opt);
  2927. var style = opt.style = {
  2928. strokeNoScale: true
  2929. };
  2930. rect = rect || {
  2931. x: -1,
  2932. y: -1,
  2933. width: 2,
  2934. height: 2
  2935. };
  2936. if (iconStr) {
  2937. return iconStr.indexOf('image://') === 0 ? (style.image = iconStr.slice(8), zrUtil.defaults(style, rect), new ZImage(opt)) : makePath(iconStr.replace('path://', ''), opt, rect, 'center');
  2938. }
  2939. }
  2940. /**
  2941. * Return `true` if the given line (line `a`) and the given polygon
  2942. * are intersect.
  2943. * Note that we do not count colinear as intersect here because no
  2944. * requirement for that. We could do that if required in future.
  2945. *
  2946. * @param {number} a1x
  2947. * @param {number} a1y
  2948. * @param {number} a2x
  2949. * @param {number} a2y
  2950. * @param {Array.<Array.<number>>} points Points of the polygon.
  2951. * @return {boolean}
  2952. */
  2953. function linePolygonIntersect(a1x, a1y, a2x, a2y, points) {
  2954. for (var i = 0, p2 = points[points.length - 1]; i < points.length; i++) {
  2955. var p = points[i];
  2956. if (lineLineIntersect(a1x, a1y, a2x, a2y, p[0], p[1], p2[0], p2[1])) {
  2957. return true;
  2958. }
  2959. p2 = p;
  2960. }
  2961. }
  2962. /**
  2963. * Return `true` if the given two lines (line `a` and line `b`)
  2964. * are intersect.
  2965. * Note that we do not count colinear as intersect here because no
  2966. * requirement for that. We could do that if required in future.
  2967. *
  2968. * @param {number} a1x
  2969. * @param {number} a1y
  2970. * @param {number} a2x
  2971. * @param {number} a2y
  2972. * @param {number} b1x
  2973. * @param {number} b1y
  2974. * @param {number} b2x
  2975. * @param {number} b2y
  2976. * @return {boolean}
  2977. */
  2978. function lineLineIntersect(a1x, a1y, a2x, a2y, b1x, b1y, b2x, b2y) {
  2979. // let `vec_m` to be `vec_a2 - vec_a1` and `vec_n` to be `vec_b2 - vec_b1`.
  2980. var mx = a2x - a1x;
  2981. var my = a2y - a1y;
  2982. var nx = b2x - b1x;
  2983. var ny = b2y - b1y; // `vec_m` and `vec_n` are parallel iff
  2984. // exising `k` such that `vec_m = k · vec_n`, equivalent to `vec_m X vec_n = 0`.
  2985. var nmCrossProduct = crossProduct2d(nx, ny, mx, my);
  2986. if (nearZero(nmCrossProduct)) {
  2987. return false;
  2988. } // `vec_m` and `vec_n` are intersect iff
  2989. // existing `p` and `q` in [0, 1] such that `vec_a1 + p * vec_m = vec_b1 + q * vec_n`,
  2990. // such that `q = ((vec_a1 - vec_b1) X vec_m) / (vec_n X vec_m)`
  2991. // and `p = ((vec_a1 - vec_b1) X vec_n) / (vec_n X vec_m)`.
  2992. var b1a1x = a1x - b1x;
  2993. var b1a1y = a1y - b1y;
  2994. var q = crossProduct2d(b1a1x, b1a1y, mx, my) / nmCrossProduct;
  2995. if (q < 0 || q > 1) {
  2996. return false;
  2997. }
  2998. var p = crossProduct2d(b1a1x, b1a1y, nx, ny) / nmCrossProduct;
  2999. if (p < 0 || p > 1) {
  3000. return false;
  3001. }
  3002. return true;
  3003. }
  3004. /**
  3005. * Cross product of 2-dimension vector.
  3006. */
  3007. function crossProduct2d(x1, y1, x2, y2) {
  3008. return x1 * y2 - x2 * y1;
  3009. }
  3010. function nearZero(val) {
  3011. return val <= 1e-6 && val >= -1e-6;
  3012. } // Register built-in shapes. These shapes might be overwirtten
  3013. // by users, although we do not recommend that.
  3014. registerShape('circle', Circle);
  3015. registerShape('sector', Sector);
  3016. registerShape('ring', Ring);
  3017. registerShape('polygon', Polygon);
  3018. registerShape('polyline', Polyline);
  3019. registerShape('rect', Rect);
  3020. registerShape('line', Line);
  3021. registerShape('bezierCurve', BezierCurve);
  3022. registerShape('arc', Arc);
  3023. exports.Z2_EMPHASIS_LIFT = Z2_EMPHASIS_LIFT;
  3024. exports.CACHED_LABEL_STYLE_PROPERTIES = CACHED_LABEL_STYLE_PROPERTIES;
  3025. exports.extendShape = extendShape;
  3026. exports.extendPath = extendPath;
  3027. exports.registerShape = registerShape;
  3028. exports.getShapeClass = getShapeClass;
  3029. exports.makePath = makePath;
  3030. exports.makeImage = makeImage;
  3031. exports.mergePath = mergePath;
  3032. exports.resizePath = resizePath;
  3033. exports.subPixelOptimizeLine = subPixelOptimizeLine;
  3034. exports.subPixelOptimizeRect = subPixelOptimizeRect;
  3035. exports.subPixelOptimize = subPixelOptimize;
  3036. exports.setElementHoverStyle = setElementHoverStyle;
  3037. exports.setHoverStyle = setHoverStyle;
  3038. exports.setAsHighDownDispatcher = setAsHighDownDispatcher;
  3039. exports.isHighDownDispatcher = isHighDownDispatcher;
  3040. exports.getHighlightDigit = getHighlightDigit;
  3041. exports.setLabelStyle = setLabelStyle;
  3042. exports.modifyLabelStyle = modifyLabelStyle;
  3043. exports.setTextStyle = setTextStyle;
  3044. exports.setText = setText;
  3045. exports.getFont = getFont;
  3046. exports.updateProps = updateProps;
  3047. exports.initProps = initProps;
  3048. exports.getTransform = getTransform;
  3049. exports.applyTransform = applyTransform;
  3050. exports.transformDirection = transformDirection;
  3051. exports.groupTransition = groupTransition;
  3052. exports.clipPointsByRect = clipPointsByRect;
  3053. exports.clipRectByRect = clipRectByRect;
  3054. exports.createIcon = createIcon;
  3055. exports.linePolygonIntersect = linePolygonIntersect;
  3056. exports.lineLineIntersect = lineLineIntersect;
  3057. /***/ }),
  3058. /***/ "./node_modules/echarts/lib/util/model.js":
  3059. /*!************************************************!*\
  3060. !*** ./node_modules/echarts/lib/util/model.js ***!
  3061. \************************************************/
  3062. /*! no static exports found */
  3063. /***/ (function(module, exports, __webpack_require__) {
  3064. /*
  3065. * Licensed to the Apache Software Foundation (ASF) under one
  3066. * or more contributor license agreements. See the NOTICE file
  3067. * distributed with this work for additional information
  3068. * regarding copyright ownership. The ASF licenses this file
  3069. * to you under the Apache License, Version 2.0 (the
  3070. * "License"); you may not use this file except in compliance
  3071. * with the License. You may obtain a copy of the License at
  3072. *
  3073. * http://www.apache.org/licenses/LICENSE-2.0
  3074. *
  3075. * Unless required by applicable law or agreed to in writing,
  3076. * software distributed under the License is distributed on an
  3077. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3078. * KIND, either express or implied. See the License for the
  3079. * specific language governing permissions and limitations
  3080. * under the License.
  3081. */
  3082. var zrUtil = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  3083. var env = __webpack_require__(/*! zrender/lib/core/env */ "./node_modules/zrender/lib/core/env.js");
  3084. /*
  3085. * Licensed to the Apache Software Foundation (ASF) under one
  3086. * or more contributor license agreements. See the NOTICE file
  3087. * distributed with this work for additional information
  3088. * regarding copyright ownership. The ASF licenses this file
  3089. * to you under the Apache License, Version 2.0 (the
  3090. * "License"); you may not use this file except in compliance
  3091. * with the License. You may obtain a copy of the License at
  3092. *
  3093. * http://www.apache.org/licenses/LICENSE-2.0
  3094. *
  3095. * Unless required by applicable law or agreed to in writing,
  3096. * software distributed under the License is distributed on an
  3097. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3098. * KIND, either express or implied. See the License for the
  3099. * specific language governing permissions and limitations
  3100. * under the License.
  3101. */
  3102. var each = zrUtil.each;
  3103. var isObject = zrUtil.isObject;
  3104. var isArray = zrUtil.isArray;
  3105. /**
  3106. * Make the name displayable. But we should
  3107. * make sure it is not duplicated with user
  3108. * specified name, so use '\0';
  3109. */
  3110. var DUMMY_COMPONENT_NAME_PREFIX = 'series\0';
  3111. /**
  3112. * If value is not array, then translate it to array.
  3113. * @param {*} value
  3114. * @return {Array} [value] or value
  3115. */
  3116. function normalizeToArray(value) {
  3117. return value instanceof Array ? value : value == null ? [] : [value];
  3118. }
  3119. /**
  3120. * Sync default option between normal and emphasis like `position` and `show`
  3121. * In case some one will write code like
  3122. * label: {
  3123. * show: false,
  3124. * position: 'outside',
  3125. * fontSize: 18
  3126. * },
  3127. * emphasis: {
  3128. * label: { show: true }
  3129. * }
  3130. * @param {Object} opt
  3131. * @param {string} key
  3132. * @param {Array.<string>} subOpts
  3133. */
  3134. function defaultEmphasis(opt, key, subOpts) {
  3135. // Caution: performance sensitive.
  3136. if (opt) {
  3137. opt[key] = opt[key] || {};
  3138. opt.emphasis = opt.emphasis || {};
  3139. opt.emphasis[key] = opt.emphasis[key] || {}; // Default emphasis option from normal
  3140. for (var i = 0, len = subOpts.length; i < len; i++) {
  3141. var subOptName = subOpts[i];
  3142. if (!opt.emphasis[key].hasOwnProperty(subOptName) && opt[key].hasOwnProperty(subOptName)) {
  3143. opt.emphasis[key][subOptName] = opt[key][subOptName];
  3144. }
  3145. }
  3146. }
  3147. }
  3148. var TEXT_STYLE_OPTIONS = ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'rich', 'tag', 'color', 'textBorderColor', 'textBorderWidth', 'width', 'height', 'lineHeight', 'align', 'verticalAlign', 'baseline', 'shadowColor', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'textShadowColor', 'textShadowBlur', 'textShadowOffsetX', 'textShadowOffsetY', 'backgroundColor', 'borderColor', 'borderWidth', 'borderRadius', 'padding']; // modelUtil.LABEL_OPTIONS = modelUtil.TEXT_STYLE_OPTIONS.concat([
  3149. // 'position', 'offset', 'rotate', 'origin', 'show', 'distance', 'formatter',
  3150. // 'fontStyle', 'fontWeight', 'fontSize', 'fontFamily',
  3151. // // FIXME: deprecated, check and remove it.
  3152. // 'textStyle'
  3153. // ]);
  3154. /**
  3155. * The method do not ensure performance.
  3156. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  3157. * This helper method retieves value from data.
  3158. * @param {string|number|Date|Array|Object} dataItem
  3159. * @return {number|string|Date|Array.<number|string|Date>}
  3160. */
  3161. function getDataItemValue(dataItem) {
  3162. return isObject(dataItem) && !isArray(dataItem) && !(dataItem instanceof Date) ? dataItem.value : dataItem;
  3163. }
  3164. /**
  3165. * data could be [12, 2323, {value: 223}, [1221, 23], {value: [2, 23]}]
  3166. * This helper method determine if dataItem has extra option besides value
  3167. * @param {string|number|Date|Array|Object} dataItem
  3168. */
  3169. function isDataItemOption(dataItem) {
  3170. return isObject(dataItem) && !(dataItem instanceof Array); // // markLine data can be array
  3171. // && !(dataItem[0] && isObject(dataItem[0]) && !(dataItem[0] instanceof Array));
  3172. }
  3173. /**
  3174. * Mapping to exists for merge.
  3175. *
  3176. * @public
  3177. * @param {Array.<Object>|Array.<module:echarts/model/Component>} exists
  3178. * @param {Object|Array.<Object>} newCptOptions
  3179. * @return {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3180. * index of which is the same as exists.
  3181. */
  3182. function mappingToExists(exists, newCptOptions) {
  3183. // Mapping by the order by original option (but not order of
  3184. // new option) in merge mode. Because we should ensure
  3185. // some specified index (like xAxisIndex) is consistent with
  3186. // original option, which is easy to understand, espatially in
  3187. // media query. And in most case, merge option is used to
  3188. // update partial option but not be expected to change order.
  3189. newCptOptions = (newCptOptions || []).slice();
  3190. var result = zrUtil.map(exists || [], function (obj, index) {
  3191. return {
  3192. exist: obj
  3193. };
  3194. }); // Mapping by id or name if specified.
  3195. each(newCptOptions, function (cptOption, index) {
  3196. if (!isObject(cptOption)) {
  3197. return;
  3198. } // id has highest priority.
  3199. for (var i = 0; i < result.length; i++) {
  3200. if (!result[i].option // Consider name: two map to one.
  3201. && cptOption.id != null && result[i].exist.id === cptOption.id + '') {
  3202. result[i].option = cptOption;
  3203. newCptOptions[index] = null;
  3204. return;
  3205. }
  3206. }
  3207. for (var i = 0; i < result.length; i++) {
  3208. var exist = result[i].exist;
  3209. if (!result[i].option // Consider name: two map to one.
  3210. // Can not match when both ids exist but different.
  3211. && (exist.id == null || cptOption.id == null) && cptOption.name != null && !isIdInner(cptOption) && !isIdInner(exist) && exist.name === cptOption.name + '') {
  3212. result[i].option = cptOption;
  3213. newCptOptions[index] = null;
  3214. return;
  3215. }
  3216. }
  3217. }); // Otherwise mapping by index.
  3218. each(newCptOptions, function (cptOption, index) {
  3219. if (!isObject(cptOption)) {
  3220. return;
  3221. }
  3222. var i = 0;
  3223. for (; i < result.length; i++) {
  3224. var exist = result[i].exist;
  3225. if (!result[i].option // Existing model that already has id should be able to
  3226. // mapped to (because after mapping performed model may
  3227. // be assigned with a id, whish should not affect next
  3228. // mapping), except those has inner id.
  3229. && !isIdInner(exist) // Caution:
  3230. // Do not overwrite id. But name can be overwritten,
  3231. // because axis use name as 'show label text'.
  3232. // 'exist' always has id and name and we dont
  3233. // need to check it.
  3234. && cptOption.id == null) {
  3235. result[i].option = cptOption;
  3236. break;
  3237. }
  3238. }
  3239. if (i >= result.length) {
  3240. result.push({
  3241. option: cptOption
  3242. });
  3243. }
  3244. });
  3245. return result;
  3246. }
  3247. /**
  3248. * Make id and name for mapping result (result of mappingToExists)
  3249. * into `keyInfo` field.
  3250. *
  3251. * @public
  3252. * @param {Array.<Object>} Result, like [{exist: ..., option: ...}, {}],
  3253. * which order is the same as exists.
  3254. * @return {Array.<Object>} The input.
  3255. */
  3256. function makeIdAndName(mapResult) {
  3257. // We use this id to hash component models and view instances
  3258. // in echarts. id can be specified by user, or auto generated.
  3259. // The id generation rule ensures new view instance are able
  3260. // to mapped to old instance when setOption are called in
  3261. // no-merge mode. So we generate model id by name and plus
  3262. // type in view id.
  3263. // name can be duplicated among components, which is convenient
  3264. // to specify multi components (like series) by one name.
  3265. // Ensure that each id is distinct.
  3266. var idMap = zrUtil.createHashMap();
  3267. each(mapResult, function (item, index) {
  3268. var existCpt = item.exist;
  3269. existCpt && idMap.set(existCpt.id, item);
  3270. });
  3271. each(mapResult, function (item, index) {
  3272. var opt = item.option;
  3273. zrUtil.assert(!opt || opt.id == null || !idMap.get(opt.id) || idMap.get(opt.id) === item, 'id duplicates: ' + (opt && opt.id));
  3274. opt && opt.id != null && idMap.set(opt.id, item);
  3275. !item.keyInfo && (item.keyInfo = {});
  3276. }); // Make name and id.
  3277. each(mapResult, function (item, index) {
  3278. var existCpt = item.exist;
  3279. var opt = item.option;
  3280. var keyInfo = item.keyInfo;
  3281. if (!isObject(opt)) {
  3282. return;
  3283. } // name can be overwitten. Consider case: axis.name = '20km'.
  3284. // But id generated by name will not be changed, which affect
  3285. // only in that case: setOption with 'not merge mode' and view
  3286. // instance will be recreated, which can be accepted.
  3287. keyInfo.name = opt.name != null ? opt.name + '' : existCpt ? existCpt.name // Avoid diffferent series has the same name,
  3288. // because name may be used like in color pallet.
  3289. : DUMMY_COMPONENT_NAME_PREFIX + index;
  3290. if (existCpt) {
  3291. keyInfo.id = existCpt.id;
  3292. } else if (opt.id != null) {
  3293. keyInfo.id = opt.id + '';
  3294. } else {
  3295. // Consider this situatoin:
  3296. // optionA: [{name: 'a'}, {name: 'a'}, {..}]
  3297. // optionB [{..}, {name: 'a'}, {name: 'a'}]
  3298. // Series with the same name between optionA and optionB
  3299. // should be mapped.
  3300. var idNum = 0;
  3301. do {
  3302. keyInfo.id = '\0' + keyInfo.name + '\0' + idNum++;
  3303. } while (idMap.get(keyInfo.id));
  3304. }
  3305. idMap.set(keyInfo.id, item);
  3306. });
  3307. }
  3308. function isNameSpecified(componentModel) {
  3309. var name = componentModel.name; // Is specified when `indexOf` get -1 or > 0.
  3310. return !!(name && name.indexOf(DUMMY_COMPONENT_NAME_PREFIX));
  3311. }
  3312. /**
  3313. * @public
  3314. * @param {Object} cptOption
  3315. * @return {boolean}
  3316. */
  3317. function isIdInner(cptOption) {
  3318. return isObject(cptOption) && cptOption.id && (cptOption.id + '').indexOf('\0_ec_\0') === 0;
  3319. }
  3320. /**
  3321. * A helper for removing duplicate items between batchA and batchB,
  3322. * and in themselves, and categorize by series.
  3323. *
  3324. * @param {Array.<Object>} batchA Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3325. * @param {Array.<Object>} batchB Like: [{seriesId: 2, dataIndex: [32, 4, 5]}, ...]
  3326. * @return {Array.<Array.<Object>, Array.<Object>>} result: [resultBatchA, resultBatchB]
  3327. */
  3328. function compressBatches(batchA, batchB) {
  3329. var mapA = {};
  3330. var mapB = {};
  3331. makeMap(batchA || [], mapA);
  3332. makeMap(batchB || [], mapB, mapA);
  3333. return [mapToArray(mapA), mapToArray(mapB)];
  3334. function makeMap(sourceBatch, map, otherMap) {
  3335. for (var i = 0, len = sourceBatch.length; i < len; i++) {
  3336. var seriesId = sourceBatch[i].seriesId;
  3337. var dataIndices = normalizeToArray(sourceBatch[i].dataIndex);
  3338. var otherDataIndices = otherMap && otherMap[seriesId];
  3339. for (var j = 0, lenj = dataIndices.length; j < lenj; j++) {
  3340. var dataIndex = dataIndices[j];
  3341. if (otherDataIndices && otherDataIndices[dataIndex]) {
  3342. otherDataIndices[dataIndex] = null;
  3343. } else {
  3344. (map[seriesId] || (map[seriesId] = {}))[dataIndex] = 1;
  3345. }
  3346. }
  3347. }
  3348. }
  3349. function mapToArray(map, isData) {
  3350. var result = [];
  3351. for (var i in map) {
  3352. if (map.hasOwnProperty(i) && map[i] != null) {
  3353. if (isData) {
  3354. result.push(+i);
  3355. } else {
  3356. var dataIndices = mapToArray(map[i], true);
  3357. dataIndices.length && result.push({
  3358. seriesId: i,
  3359. dataIndex: dataIndices
  3360. });
  3361. }
  3362. }
  3363. }
  3364. return result;
  3365. }
  3366. }
  3367. /**
  3368. * @param {module:echarts/data/List} data
  3369. * @param {Object} payload Contains dataIndex (means rawIndex) / dataIndexInside / name
  3370. * each of which can be Array or primary type.
  3371. * @return {number|Array.<number>} dataIndex If not found, return undefined/null.
  3372. */
  3373. function queryDataIndex(data, payload) {
  3374. if (payload.dataIndexInside != null) {
  3375. return payload.dataIndexInside;
  3376. } else if (payload.dataIndex != null) {
  3377. return zrUtil.isArray(payload.dataIndex) ? zrUtil.map(payload.dataIndex, function (value) {
  3378. return data.indexOfRawIndex(value);
  3379. }) : data.indexOfRawIndex(payload.dataIndex);
  3380. } else if (payload.name != null) {
  3381. return zrUtil.isArray(payload.name) ? zrUtil.map(payload.name, function (value) {
  3382. return data.indexOfName(value);
  3383. }) : data.indexOfName(payload.name);
  3384. }
  3385. }
  3386. /**
  3387. * Enable property storage to any host object.
  3388. * Notice: Serialization is not supported.
  3389. *
  3390. * For example:
  3391. * var inner = zrUitl.makeInner();
  3392. *
  3393. * function some1(hostObj) {
  3394. * inner(hostObj).someProperty = 1212;
  3395. * ...
  3396. * }
  3397. * function some2() {
  3398. * var fields = inner(this);
  3399. * fields.someProperty1 = 1212;
  3400. * fields.someProperty2 = 'xx';
  3401. * ...
  3402. * }
  3403. *
  3404. * @return {Function}
  3405. */
  3406. function makeInner() {
  3407. // Consider different scope by es module import.
  3408. var key = '__\0ec_inner_' + innerUniqueIndex++ + '_' + Math.random().toFixed(5);
  3409. return function (hostObj) {
  3410. return hostObj[key] || (hostObj[key] = {});
  3411. };
  3412. }
  3413. var innerUniqueIndex = 0;
  3414. /**
  3415. * @param {module:echarts/model/Global} ecModel
  3416. * @param {string|Object} finder
  3417. * If string, e.g., 'geo', means {geoIndex: 0}.
  3418. * If Object, could contain some of these properties below:
  3419. * {
  3420. * seriesIndex, seriesId, seriesName,
  3421. * geoIndex, geoId, geoName,
  3422. * bmapIndex, bmapId, bmapName,
  3423. * xAxisIndex, xAxisId, xAxisName,
  3424. * yAxisIndex, yAxisId, yAxisName,
  3425. * gridIndex, gridId, gridName,
  3426. * ... (can be extended)
  3427. * }
  3428. * Each properties can be number|string|Array.<number>|Array.<string>
  3429. * For example, a finder could be
  3430. * {
  3431. * seriesIndex: 3,
  3432. * geoId: ['aa', 'cc'],
  3433. * gridName: ['xx', 'rr']
  3434. * }
  3435. * xxxIndex can be set as 'all' (means all xxx) or 'none' (means not specify)
  3436. * If nothing or null/undefined specified, return nothing.
  3437. * @param {Object} [opt]
  3438. * @param {string} [opt.defaultMainType]
  3439. * @param {Array.<string>} [opt.includeMainTypes]
  3440. * @return {Object} result like:
  3441. * {
  3442. * seriesModels: [seriesModel1, seriesModel2],
  3443. * seriesModel: seriesModel1, // The first model
  3444. * geoModels: [geoModel1, geoModel2],
  3445. * geoModel: geoModel1, // The first model
  3446. * ...
  3447. * }
  3448. */
  3449. function parseFinder(ecModel, finder, opt) {
  3450. if (zrUtil.isString(finder)) {
  3451. var obj = {};
  3452. obj[finder + 'Index'] = 0;
  3453. finder = obj;
  3454. }
  3455. var defaultMainType = opt && opt.defaultMainType;
  3456. if (defaultMainType && !has(finder, defaultMainType + 'Index') && !has(finder, defaultMainType + 'Id') && !has(finder, defaultMainType + 'Name')) {
  3457. finder[defaultMainType + 'Index'] = 0;
  3458. }
  3459. var result = {};
  3460. each(finder, function (value, key) {
  3461. var value = finder[key]; // Exclude 'dataIndex' and other illgal keys.
  3462. if (key === 'dataIndex' || key === 'dataIndexInside') {
  3463. result[key] = value;
  3464. return;
  3465. }
  3466. var parsedKey = key.match(/^(\w+)(Index|Id|Name)$/) || [];
  3467. var mainType = parsedKey[1];
  3468. var queryType = (parsedKey[2] || '').toLowerCase();
  3469. if (!mainType || !queryType || value == null || queryType === 'index' && value === 'none' || opt && opt.includeMainTypes && zrUtil.indexOf(opt.includeMainTypes, mainType) < 0) {
  3470. return;
  3471. }
  3472. var queryParam = {
  3473. mainType: mainType
  3474. };
  3475. if (queryType !== 'index' || value !== 'all') {
  3476. queryParam[queryType] = value;
  3477. }
  3478. var models = ecModel.queryComponents(queryParam);
  3479. result[mainType + 'Models'] = models;
  3480. result[mainType + 'Model'] = models[0];
  3481. });
  3482. return result;
  3483. }
  3484. function has(obj, prop) {
  3485. return obj && obj.hasOwnProperty(prop);
  3486. }
  3487. function setAttribute(dom, key, value) {
  3488. dom.setAttribute ? dom.setAttribute(key, value) : dom[key] = value;
  3489. }
  3490. function getAttribute(dom, key) {
  3491. return dom.getAttribute ? dom.getAttribute(key) : dom[key];
  3492. }
  3493. function getTooltipRenderMode(renderModeOption) {
  3494. if (renderModeOption === 'auto') {
  3495. // Using html when `document` exists, use richText otherwise
  3496. return env.domSupported ? 'html' : 'richText';
  3497. } else {
  3498. return renderModeOption || 'html';
  3499. }
  3500. }
  3501. /**
  3502. * Group a list by key.
  3503. *
  3504. * @param {Array} array
  3505. * @param {Function} getKey
  3506. * param {*} Array item
  3507. * return {string} key
  3508. * @return {Object} Result
  3509. * {Array}: keys,
  3510. * {module:zrender/core/util/HashMap} buckets: {key -> Array}
  3511. */
  3512. function groupData(array, getKey) {
  3513. var buckets = zrUtil.createHashMap();
  3514. var keys = [];
  3515. zrUtil.each(array, function (item) {
  3516. var key = getKey(item);
  3517. (buckets.get(key) || (keys.push(key), buckets.set(key, []))).push(item);
  3518. });
  3519. return {
  3520. keys: keys,
  3521. buckets: buckets
  3522. };
  3523. }
  3524. exports.normalizeToArray = normalizeToArray;
  3525. exports.defaultEmphasis = defaultEmphasis;
  3526. exports.TEXT_STYLE_OPTIONS = TEXT_STYLE_OPTIONS;
  3527. exports.getDataItemValue = getDataItemValue;
  3528. exports.isDataItemOption = isDataItemOption;
  3529. exports.mappingToExists = mappingToExists;
  3530. exports.makeIdAndName = makeIdAndName;
  3531. exports.isNameSpecified = isNameSpecified;
  3532. exports.isIdInner = isIdInner;
  3533. exports.compressBatches = compressBatches;
  3534. exports.queryDataIndex = queryDataIndex;
  3535. exports.makeInner = makeInner;
  3536. exports.parseFinder = parseFinder;
  3537. exports.setAttribute = setAttribute;
  3538. exports.getAttribute = getAttribute;
  3539. exports.getTooltipRenderMode = getTooltipRenderMode;
  3540. exports.groupData = groupData;
  3541. /***/ }),
  3542. /***/ "./node_modules/echarts/lib/util/symbol.js":
  3543. /*!*************************************************!*\
  3544. !*** ./node_modules/echarts/lib/util/symbol.js ***!
  3545. \*************************************************/
  3546. /*! no static exports found */
  3547. /***/ (function(module, exports, __webpack_require__) {
  3548. /*
  3549. * Licensed to the Apache Software Foundation (ASF) under one
  3550. * or more contributor license agreements. See the NOTICE file
  3551. * distributed with this work for additional information
  3552. * regarding copyright ownership. The ASF licenses this file
  3553. * to you under the Apache License, Version 2.0 (the
  3554. * "License"); you may not use this file except in compliance
  3555. * with the License. You may obtain a copy of the License at
  3556. *
  3557. * http://www.apache.org/licenses/LICENSE-2.0
  3558. *
  3559. * Unless required by applicable law or agreed to in writing,
  3560. * software distributed under the License is distributed on an
  3561. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3562. * KIND, either express or implied. See the License for the
  3563. * specific language governing permissions and limitations
  3564. * under the License.
  3565. */
  3566. var zrUtil = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  3567. var graphic = __webpack_require__(/*! ./graphic */ "./node_modules/echarts/lib/util/graphic.js");
  3568. var BoundingRect = __webpack_require__(/*! zrender/lib/core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  3569. var _text = __webpack_require__(/*! zrender/lib/contain/text */ "./node_modules/zrender/lib/contain/text.js");
  3570. var calculateTextPosition = _text.calculateTextPosition;
  3571. /*
  3572. * Licensed to the Apache Software Foundation (ASF) under one
  3573. * or more contributor license agreements. See the NOTICE file
  3574. * distributed with this work for additional information
  3575. * regarding copyright ownership. The ASF licenses this file
  3576. * to you under the Apache License, Version 2.0 (the
  3577. * "License"); you may not use this file except in compliance
  3578. * with the License. You may obtain a copy of the License at
  3579. *
  3580. * http://www.apache.org/licenses/LICENSE-2.0
  3581. *
  3582. * Unless required by applicable law or agreed to in writing,
  3583. * software distributed under the License is distributed on an
  3584. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3585. * KIND, either express or implied. See the License for the
  3586. * specific language governing permissions and limitations
  3587. * under the License.
  3588. */
  3589. // Symbol factory
  3590. /**
  3591. * Triangle shape
  3592. * @inner
  3593. */
  3594. var Triangle = graphic.extendShape({
  3595. type: 'triangle',
  3596. shape: {
  3597. cx: 0,
  3598. cy: 0,
  3599. width: 0,
  3600. height: 0
  3601. },
  3602. buildPath: function (path, shape) {
  3603. var cx = shape.cx;
  3604. var cy = shape.cy;
  3605. var width = shape.width / 2;
  3606. var height = shape.height / 2;
  3607. path.moveTo(cx, cy - height);
  3608. path.lineTo(cx + width, cy + height);
  3609. path.lineTo(cx - width, cy + height);
  3610. path.closePath();
  3611. }
  3612. });
  3613. /**
  3614. * Diamond shape
  3615. * @inner
  3616. */
  3617. var Diamond = graphic.extendShape({
  3618. type: 'diamond',
  3619. shape: {
  3620. cx: 0,
  3621. cy: 0,
  3622. width: 0,
  3623. height: 0
  3624. },
  3625. buildPath: function (path, shape) {
  3626. var cx = shape.cx;
  3627. var cy = shape.cy;
  3628. var width = shape.width / 2;
  3629. var height = shape.height / 2;
  3630. path.moveTo(cx, cy - height);
  3631. path.lineTo(cx + width, cy);
  3632. path.lineTo(cx, cy + height);
  3633. path.lineTo(cx - width, cy);
  3634. path.closePath();
  3635. }
  3636. });
  3637. /**
  3638. * Pin shape
  3639. * @inner
  3640. */
  3641. var Pin = graphic.extendShape({
  3642. type: 'pin',
  3643. shape: {
  3644. // x, y on the cusp
  3645. x: 0,
  3646. y: 0,
  3647. width: 0,
  3648. height: 0
  3649. },
  3650. buildPath: function (path, shape) {
  3651. var x = shape.x;
  3652. var y = shape.y;
  3653. var w = shape.width / 5 * 3; // Height must be larger than width
  3654. var h = Math.max(w, shape.height);
  3655. var r = w / 2; // Dist on y with tangent point and circle center
  3656. var dy = r * r / (h - r);
  3657. var cy = y - h + r + dy;
  3658. var angle = Math.asin(dy / r); // Dist on x with tangent point and circle center
  3659. var dx = Math.cos(angle) * r;
  3660. var tanX = Math.sin(angle);
  3661. var tanY = Math.cos(angle);
  3662. var cpLen = r * 0.6;
  3663. var cpLen2 = r * 0.7;
  3664. path.moveTo(x - dx, cy + dy);
  3665. path.arc(x, cy, r, Math.PI - angle, Math.PI * 2 + angle);
  3666. path.bezierCurveTo(x + dx - tanX * cpLen, cy + dy + tanY * cpLen, x, y - cpLen2, x, y);
  3667. path.bezierCurveTo(x, y - cpLen2, x - dx + tanX * cpLen, cy + dy + tanY * cpLen, x - dx, cy + dy);
  3668. path.closePath();
  3669. }
  3670. });
  3671. /**
  3672. * Arrow shape
  3673. * @inner
  3674. */
  3675. var Arrow = graphic.extendShape({
  3676. type: 'arrow',
  3677. shape: {
  3678. x: 0,
  3679. y: 0,
  3680. width: 0,
  3681. height: 0
  3682. },
  3683. buildPath: function (ctx, shape) {
  3684. var height = shape.height;
  3685. var width = shape.width;
  3686. var x = shape.x;
  3687. var y = shape.y;
  3688. var dx = width / 3 * 2;
  3689. ctx.moveTo(x, y);
  3690. ctx.lineTo(x + dx, y + height);
  3691. ctx.lineTo(x, y + height / 4 * 3);
  3692. ctx.lineTo(x - dx, y + height);
  3693. ctx.lineTo(x, y);
  3694. ctx.closePath();
  3695. }
  3696. });
  3697. /**
  3698. * Map of path contructors
  3699. * @type {Object.<string, module:zrender/graphic/Path>}
  3700. */
  3701. var symbolCtors = {
  3702. line: graphic.Line,
  3703. rect: graphic.Rect,
  3704. roundRect: graphic.Rect,
  3705. square: graphic.Rect,
  3706. circle: graphic.Circle,
  3707. diamond: Diamond,
  3708. pin: Pin,
  3709. arrow: Arrow,
  3710. triangle: Triangle
  3711. };
  3712. var symbolShapeMakers = {
  3713. line: function (x, y, w, h, shape) {
  3714. // FIXME
  3715. shape.x1 = x;
  3716. shape.y1 = y + h / 2;
  3717. shape.x2 = x + w;
  3718. shape.y2 = y + h / 2;
  3719. },
  3720. rect: function (x, y, w, h, shape) {
  3721. shape.x = x;
  3722. shape.y = y;
  3723. shape.width = w;
  3724. shape.height = h;
  3725. },
  3726. roundRect: function (x, y, w, h, shape) {
  3727. shape.x = x;
  3728. shape.y = y;
  3729. shape.width = w;
  3730. shape.height = h;
  3731. shape.r = Math.min(w, h) / 4;
  3732. },
  3733. square: function (x, y, w, h, shape) {
  3734. var size = Math.min(w, h);
  3735. shape.x = x;
  3736. shape.y = y;
  3737. shape.width = size;
  3738. shape.height = size;
  3739. },
  3740. circle: function (x, y, w, h, shape) {
  3741. // Put circle in the center of square
  3742. shape.cx = x + w / 2;
  3743. shape.cy = y + h / 2;
  3744. shape.r = Math.min(w, h) / 2;
  3745. },
  3746. diamond: function (x, y, w, h, shape) {
  3747. shape.cx = x + w / 2;
  3748. shape.cy = y + h / 2;
  3749. shape.width = w;
  3750. shape.height = h;
  3751. },
  3752. pin: function (x, y, w, h, shape) {
  3753. shape.x = x + w / 2;
  3754. shape.y = y + h / 2;
  3755. shape.width = w;
  3756. shape.height = h;
  3757. },
  3758. arrow: function (x, y, w, h, shape) {
  3759. shape.x = x + w / 2;
  3760. shape.y = y + h / 2;
  3761. shape.width = w;
  3762. shape.height = h;
  3763. },
  3764. triangle: function (x, y, w, h, shape) {
  3765. shape.cx = x + w / 2;
  3766. shape.cy = y + h / 2;
  3767. shape.width = w;
  3768. shape.height = h;
  3769. }
  3770. };
  3771. var symbolBuildProxies = {};
  3772. zrUtil.each(symbolCtors, function (Ctor, name) {
  3773. symbolBuildProxies[name] = new Ctor();
  3774. });
  3775. var SymbolClz = graphic.extendShape({
  3776. type: 'symbol',
  3777. shape: {
  3778. symbolType: '',
  3779. x: 0,
  3780. y: 0,
  3781. width: 0,
  3782. height: 0
  3783. },
  3784. calculateTextPosition: function (out, style, rect) {
  3785. var res = calculateTextPosition(out, style, rect);
  3786. var shape = this.shape;
  3787. if (shape && shape.symbolType === 'pin' && style.textPosition === 'inside') {
  3788. res.y = rect.y + rect.height * 0.4;
  3789. }
  3790. return res;
  3791. },
  3792. buildPath: function (ctx, shape, inBundle) {
  3793. var symbolType = shape.symbolType;
  3794. if (symbolType !== 'none') {
  3795. var proxySymbol = symbolBuildProxies[symbolType];
  3796. if (!proxySymbol) {
  3797. // Default rect
  3798. symbolType = 'rect';
  3799. proxySymbol = symbolBuildProxies[symbolType];
  3800. }
  3801. symbolShapeMakers[symbolType](shape.x, shape.y, shape.width, shape.height, proxySymbol.shape);
  3802. proxySymbol.buildPath(ctx, proxySymbol.shape, inBundle);
  3803. }
  3804. }
  3805. }); // Provide setColor helper method to avoid determine if set the fill or stroke outside
  3806. function symbolPathSetColor(color, innerColor) {
  3807. if (this.type !== 'image') {
  3808. var symbolStyle = this.style;
  3809. var symbolShape = this.shape;
  3810. if (symbolShape && symbolShape.symbolType === 'line') {
  3811. symbolStyle.stroke = color;
  3812. } else if (this.__isEmptyBrush) {
  3813. symbolStyle.stroke = color;
  3814. symbolStyle.fill = innerColor || '#fff';
  3815. } else {
  3816. // FIXME 判断图形默认是填充还是描边,使用 onlyStroke ?
  3817. symbolStyle.fill && (symbolStyle.fill = color);
  3818. symbolStyle.stroke && (symbolStyle.stroke = color);
  3819. }
  3820. this.dirty(false);
  3821. }
  3822. }
  3823. /**
  3824. * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
  3825. * @param {string} symbolType
  3826. * @param {number} x
  3827. * @param {number} y
  3828. * @param {number} w
  3829. * @param {number} h
  3830. * @param {string} color
  3831. * @param {boolean} [keepAspect=false] whether to keep the ratio of w/h,
  3832. * for path and image only.
  3833. */
  3834. function createSymbol(symbolType, x, y, w, h, color, keepAspect) {
  3835. // TODO Support image object, DynamicImage.
  3836. var isEmpty = symbolType.indexOf('empty') === 0;
  3837. if (isEmpty) {
  3838. symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
  3839. }
  3840. var symbolPath;
  3841. if (symbolType.indexOf('image://') === 0) {
  3842. symbolPath = graphic.makeImage(symbolType.slice(8), new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');
  3843. } else if (symbolType.indexOf('path://') === 0) {
  3844. symbolPath = graphic.makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');
  3845. } else {
  3846. symbolPath = new SymbolClz({
  3847. shape: {
  3848. symbolType: symbolType,
  3849. x: x,
  3850. y: y,
  3851. width: w,
  3852. height: h
  3853. }
  3854. });
  3855. }
  3856. symbolPath.__isEmptyBrush = isEmpty;
  3857. symbolPath.setColor = symbolPathSetColor;
  3858. symbolPath.setColor(color);
  3859. return symbolPath;
  3860. }
  3861. exports.createSymbol = createSymbol;
  3862. /***/ }),
  3863. /***/ "./node_modules/echarts/lib/visual/dataColor.js":
  3864. /*!******************************************************!*\
  3865. !*** ./node_modules/echarts/lib/visual/dataColor.js ***!
  3866. \******************************************************/
  3867. /*! no static exports found */
  3868. /***/ (function(module, exports, __webpack_require__) {
  3869. /*
  3870. * Licensed to the Apache Software Foundation (ASF) under one
  3871. * or more contributor license agreements. See the NOTICE file
  3872. * distributed with this work for additional information
  3873. * regarding copyright ownership. The ASF licenses this file
  3874. * to you under the Apache License, Version 2.0 (the
  3875. * "License"); you may not use this file except in compliance
  3876. * with the License. You may obtain a copy of the License at
  3877. *
  3878. * http://www.apache.org/licenses/LICENSE-2.0
  3879. *
  3880. * Unless required by applicable law or agreed to in writing,
  3881. * software distributed under the License is distributed on an
  3882. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3883. * KIND, either express or implied. See the License for the
  3884. * specific language governing permissions and limitations
  3885. * under the License.
  3886. */
  3887. var _util = __webpack_require__(/*! zrender/lib/core/util */ "./node_modules/zrender/lib/core/util.js");
  3888. var createHashMap = _util.createHashMap;
  3889. /*
  3890. * Licensed to the Apache Software Foundation (ASF) under one
  3891. * or more contributor license agreements. See the NOTICE file
  3892. * distributed with this work for additional information
  3893. * regarding copyright ownership. The ASF licenses this file
  3894. * to you under the Apache License, Version 2.0 (the
  3895. * "License"); you may not use this file except in compliance
  3896. * with the License. You may obtain a copy of the License at
  3897. *
  3898. * http://www.apache.org/licenses/LICENSE-2.0
  3899. *
  3900. * Unless required by applicable law or agreed to in writing,
  3901. * software distributed under the License is distributed on an
  3902. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  3903. * KIND, either express or implied. See the License for the
  3904. * specific language governing permissions and limitations
  3905. * under the License.
  3906. */
  3907. // Pick color from palette for each data item.
  3908. // Applicable for charts that require applying color palette
  3909. // in data level (like pie, funnel, chord).
  3910. function _default(seriesType) {
  3911. return {
  3912. getTargetSeries: function (ecModel) {
  3913. // Pie and funnel may use diferrent scope
  3914. var paletteScope = {};
  3915. var seiresModelMap = createHashMap();
  3916. ecModel.eachSeriesByType(seriesType, function (seriesModel) {
  3917. seriesModel.__paletteScope = paletteScope;
  3918. seiresModelMap.set(seriesModel.uid, seriesModel);
  3919. });
  3920. return seiresModelMap;
  3921. },
  3922. reset: function (seriesModel, ecModel) {
  3923. var dataAll = seriesModel.getRawData();
  3924. var idxMap = {};
  3925. var data = seriesModel.getData();
  3926. data.each(function (idx) {
  3927. var rawIdx = data.getRawIndex(idx);
  3928. idxMap[rawIdx] = idx;
  3929. });
  3930. dataAll.each(function (rawIdx) {
  3931. var filteredIdx = idxMap[rawIdx]; // If series.itemStyle.normal.color is a function. itemVisual may be encoded
  3932. var singleDataColor = filteredIdx != null && data.getItemVisual(filteredIdx, 'color', true);
  3933. var singleDataBorderColor = filteredIdx != null && data.getItemVisual(filteredIdx, 'borderColor', true);
  3934. var itemModel;
  3935. if (!singleDataColor || !singleDataBorderColor) {
  3936. // FIXME Performance
  3937. itemModel = dataAll.getItemModel(rawIdx);
  3938. }
  3939. if (!singleDataColor) {
  3940. var color = itemModel.get('itemStyle.color') || seriesModel.getColorFromPalette(dataAll.getName(rawIdx) || rawIdx + '', seriesModel.__paletteScope, dataAll.count()); // Data is not filtered
  3941. if (filteredIdx != null) {
  3942. data.setItemVisual(filteredIdx, 'color', color);
  3943. }
  3944. }
  3945. if (!singleDataBorderColor) {
  3946. var borderColor = itemModel.get('itemStyle.borderColor'); // Data is not filtered
  3947. if (filteredIdx != null) {
  3948. data.setItemVisual(filteredIdx, 'borderColor', borderColor);
  3949. }
  3950. }
  3951. });
  3952. }
  3953. };
  3954. }
  3955. module.exports = _default;
  3956. /***/ }),
  3957. /***/ "./node_modules/webpack/buildin/global.js":
  3958. /*!***********************************!*\
  3959. !*** (webpack)/buildin/global.js ***!
  3960. \***********************************/
  3961. /*! no static exports found */
  3962. /***/ (function(module, exports) {
  3963. var g;
  3964. // This works in non-strict mode
  3965. g = (function() {
  3966. return this;
  3967. })();
  3968. try {
  3969. // This works if eval is allowed (see CSP)
  3970. g = g || new Function("return this")();
  3971. } catch (e) {
  3972. // This works if the window reference is available
  3973. if (typeof window === "object") g = window;
  3974. }
  3975. // g can still be undefined, but nothing to do about it...
  3976. // We return undefined, instead of nothing here, so it's
  3977. // easier to handle this case. if(!global) { ...}
  3978. module.exports = g;
  3979. /***/ }),
  3980. /***/ "./node_modules/zrender/lib/Element.js":
  3981. /*!*********************************************!*\
  3982. !*** ./node_modules/zrender/lib/Element.js ***!
  3983. \*********************************************/
  3984. /*! no static exports found */
  3985. /***/ (function(module, exports, __webpack_require__) {
  3986. var guid = __webpack_require__(/*! ./core/guid */ "./node_modules/zrender/lib/core/guid.js");
  3987. var Eventful = __webpack_require__(/*! ./mixin/Eventful */ "./node_modules/zrender/lib/mixin/Eventful.js");
  3988. var Transformable = __webpack_require__(/*! ./mixin/Transformable */ "./node_modules/zrender/lib/mixin/Transformable.js");
  3989. var Animatable = __webpack_require__(/*! ./mixin/Animatable */ "./node_modules/zrender/lib/mixin/Animatable.js");
  3990. var zrUtil = __webpack_require__(/*! ./core/util */ "./node_modules/zrender/lib/core/util.js");
  3991. /**
  3992. * @alias module:zrender/Element
  3993. * @constructor
  3994. * @extends {module:zrender/mixin/Animatable}
  3995. * @extends {module:zrender/mixin/Transformable}
  3996. * @extends {module:zrender/mixin/Eventful}
  3997. */
  3998. var Element = function (opts) {
  3999. // jshint ignore:line
  4000. Transformable.call(this, opts);
  4001. Eventful.call(this, opts);
  4002. Animatable.call(this, opts);
  4003. /**
  4004. * 画布元素ID
  4005. * @type {string}
  4006. */
  4007. this.id = opts.id || guid();
  4008. };
  4009. Element.prototype = {
  4010. /**
  4011. * 元素类型
  4012. * Element type
  4013. * @type {string}
  4014. */
  4015. type: 'element',
  4016. /**
  4017. * 元素名字
  4018. * Element name
  4019. * @type {string}
  4020. */
  4021. name: '',
  4022. /**
  4023. * ZRender 实例对象,会在 element 添加到 zrender 实例中后自动赋值
  4024. * ZRender instance will be assigned when element is associated with zrender
  4025. * @name module:/zrender/Element#__zr
  4026. * @type {module:zrender/ZRender}
  4027. */
  4028. __zr: null,
  4029. /**
  4030. * 图形是否忽略,为true时忽略图形的绘制以及事件触发
  4031. * If ignore drawing and events of the element object
  4032. * @name module:/zrender/Element#ignore
  4033. * @type {boolean}
  4034. * @default false
  4035. */
  4036. ignore: false,
  4037. /**
  4038. * 用于裁剪的路径(shape),所有 Group 内的路径在绘制时都会被这个路径裁剪
  4039. * 该路径会继承被裁减对象的变换
  4040. * @type {module:zrender/graphic/Path}
  4041. * @see http://www.w3.org/TR/2dcontext/#clipping-region
  4042. * @readOnly
  4043. */
  4044. clipPath: null,
  4045. /**
  4046. * 是否是 Group
  4047. * @type {boolean}
  4048. */
  4049. isGroup: false,
  4050. /**
  4051. * Drift element
  4052. * @param {number} dx dx on the global space
  4053. * @param {number} dy dy on the global space
  4054. */
  4055. drift: function (dx, dy) {
  4056. switch (this.draggable) {
  4057. case 'horizontal':
  4058. dy = 0;
  4059. break;
  4060. case 'vertical':
  4061. dx = 0;
  4062. break;
  4063. }
  4064. var m = this.transform;
  4065. if (!m) {
  4066. m = this.transform = [1, 0, 0, 1, 0, 0];
  4067. }
  4068. m[4] += dx;
  4069. m[5] += dy;
  4070. this.decomposeTransform();
  4071. this.dirty(false);
  4072. },
  4073. /**
  4074. * Hook before update
  4075. */
  4076. beforeUpdate: function () {},
  4077. /**
  4078. * Hook after update
  4079. */
  4080. afterUpdate: function () {},
  4081. /**
  4082. * Update each frame
  4083. */
  4084. update: function () {
  4085. this.updateTransform();
  4086. },
  4087. /**
  4088. * @param {Function} cb
  4089. * @param {} context
  4090. */
  4091. traverse: function (cb, context) {},
  4092. /**
  4093. * @protected
  4094. */
  4095. attrKV: function (key, value) {
  4096. if (key === 'position' || key === 'scale' || key === 'origin') {
  4097. // Copy the array
  4098. if (value) {
  4099. var target = this[key];
  4100. if (!target) {
  4101. target = this[key] = [];
  4102. }
  4103. target[0] = value[0];
  4104. target[1] = value[1];
  4105. }
  4106. } else {
  4107. this[key] = value;
  4108. }
  4109. },
  4110. /**
  4111. * Hide the element
  4112. */
  4113. hide: function () {
  4114. this.ignore = true;
  4115. this.__zr && this.__zr.refresh();
  4116. },
  4117. /**
  4118. * Show the element
  4119. */
  4120. show: function () {
  4121. this.ignore = false;
  4122. this.__zr && this.__zr.refresh();
  4123. },
  4124. /**
  4125. * @param {string|Object} key
  4126. * @param {*} value
  4127. */
  4128. attr: function (key, value) {
  4129. if (typeof key === 'string') {
  4130. this.attrKV(key, value);
  4131. } else if (zrUtil.isObject(key)) {
  4132. for (var name in key) {
  4133. if (key.hasOwnProperty(name)) {
  4134. this.attrKV(name, key[name]);
  4135. }
  4136. }
  4137. }
  4138. this.dirty(false);
  4139. return this;
  4140. },
  4141. /**
  4142. * @param {module:zrender/graphic/Path} clipPath
  4143. */
  4144. setClipPath: function (clipPath) {
  4145. var zr = this.__zr;
  4146. if (zr) {
  4147. clipPath.addSelfToZr(zr);
  4148. } // Remove previous clip path
  4149. if (this.clipPath && this.clipPath !== clipPath) {
  4150. this.removeClipPath();
  4151. }
  4152. this.clipPath = clipPath;
  4153. clipPath.__zr = zr;
  4154. clipPath.__clipTarget = this;
  4155. this.dirty(false);
  4156. },
  4157. /**
  4158. */
  4159. removeClipPath: function () {
  4160. var clipPath = this.clipPath;
  4161. if (clipPath) {
  4162. if (clipPath.__zr) {
  4163. clipPath.removeSelfFromZr(clipPath.__zr);
  4164. }
  4165. clipPath.__zr = null;
  4166. clipPath.__clipTarget = null;
  4167. this.clipPath = null;
  4168. this.dirty(false);
  4169. }
  4170. },
  4171. /**
  4172. * Add self from zrender instance.
  4173. * Not recursively because it will be invoked when element added to storage.
  4174. * @param {module:zrender/ZRender} zr
  4175. */
  4176. addSelfToZr: function (zr) {
  4177. this.__zr = zr; // 添加动画
  4178. var animators = this.animators;
  4179. if (animators) {
  4180. for (var i = 0; i < animators.length; i++) {
  4181. zr.animation.addAnimator(animators[i]);
  4182. }
  4183. }
  4184. if (this.clipPath) {
  4185. this.clipPath.addSelfToZr(zr);
  4186. }
  4187. },
  4188. /**
  4189. * Remove self from zrender instance.
  4190. * Not recursively because it will be invoked when element added to storage.
  4191. * @param {module:zrender/ZRender} zr
  4192. */
  4193. removeSelfFromZr: function (zr) {
  4194. this.__zr = null; // 移除动画
  4195. var animators = this.animators;
  4196. if (animators) {
  4197. for (var i = 0; i < animators.length; i++) {
  4198. zr.animation.removeAnimator(animators[i]);
  4199. }
  4200. }
  4201. if (this.clipPath) {
  4202. this.clipPath.removeSelfFromZr(zr);
  4203. }
  4204. }
  4205. };
  4206. zrUtil.mixin(Element, Animatable);
  4207. zrUtil.mixin(Element, Transformable);
  4208. zrUtil.mixin(Element, Eventful);
  4209. var _default = Element;
  4210. module.exports = _default;
  4211. /***/ }),
  4212. /***/ "./node_modules/zrender/lib/animation/Animator.js":
  4213. /*!********************************************************!*\
  4214. !*** ./node_modules/zrender/lib/animation/Animator.js ***!
  4215. \********************************************************/
  4216. /*! no static exports found */
  4217. /***/ (function(module, exports, __webpack_require__) {
  4218. var Clip = __webpack_require__(/*! ./Clip */ "./node_modules/zrender/lib/animation/Clip.js");
  4219. var color = __webpack_require__(/*! ../tool/color */ "./node_modules/zrender/lib/tool/color.js");
  4220. var _util = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  4221. var isArrayLike = _util.isArrayLike;
  4222. /**
  4223. * @module echarts/animation/Animator
  4224. */
  4225. var arraySlice = Array.prototype.slice;
  4226. function defaultGetter(target, key) {
  4227. return target[key];
  4228. }
  4229. function defaultSetter(target, key, value) {
  4230. target[key] = value;
  4231. }
  4232. /**
  4233. * @param {number} p0
  4234. * @param {number} p1
  4235. * @param {number} percent
  4236. * @return {number}
  4237. */
  4238. function interpolateNumber(p0, p1, percent) {
  4239. return (p1 - p0) * percent + p0;
  4240. }
  4241. /**
  4242. * @param {string} p0
  4243. * @param {string} p1
  4244. * @param {number} percent
  4245. * @return {string}
  4246. */
  4247. function interpolateString(p0, p1, percent) {
  4248. return percent > 0.5 ? p1 : p0;
  4249. }
  4250. /**
  4251. * @param {Array} p0
  4252. * @param {Array} p1
  4253. * @param {number} percent
  4254. * @param {Array} out
  4255. * @param {number} arrDim
  4256. */
  4257. function interpolateArray(p0, p1, percent, out, arrDim) {
  4258. var len = p0.length;
  4259. if (arrDim === 1) {
  4260. for (var i = 0; i < len; i++) {
  4261. out[i] = interpolateNumber(p0[i], p1[i], percent);
  4262. }
  4263. } else {
  4264. var len2 = len && p0[0].length;
  4265. for (var i = 0; i < len; i++) {
  4266. for (var j = 0; j < len2; j++) {
  4267. out[i][j] = interpolateNumber(p0[i][j], p1[i][j], percent);
  4268. }
  4269. }
  4270. }
  4271. } // arr0 is source array, arr1 is target array.
  4272. // Do some preprocess to avoid error happened when interpolating from arr0 to arr1
  4273. function fillArr(arr0, arr1, arrDim) {
  4274. var arr0Len = arr0.length;
  4275. var arr1Len = arr1.length;
  4276. if (arr0Len !== arr1Len) {
  4277. // FIXME Not work for TypedArray
  4278. var isPreviousLarger = arr0Len > arr1Len;
  4279. if (isPreviousLarger) {
  4280. // Cut the previous
  4281. arr0.length = arr1Len;
  4282. } else {
  4283. // Fill the previous
  4284. for (var i = arr0Len; i < arr1Len; i++) {
  4285. arr0.push(arrDim === 1 ? arr1[i] : arraySlice.call(arr1[i]));
  4286. }
  4287. }
  4288. } // Handling NaN value
  4289. var len2 = arr0[0] && arr0[0].length;
  4290. for (var i = 0; i < arr0.length; i++) {
  4291. if (arrDim === 1) {
  4292. if (isNaN(arr0[i])) {
  4293. arr0[i] = arr1[i];
  4294. }
  4295. } else {
  4296. for (var j = 0; j < len2; j++) {
  4297. if (isNaN(arr0[i][j])) {
  4298. arr0[i][j] = arr1[i][j];
  4299. }
  4300. }
  4301. }
  4302. }
  4303. }
  4304. /**
  4305. * @param {Array} arr0
  4306. * @param {Array} arr1
  4307. * @param {number} arrDim
  4308. * @return {boolean}
  4309. */
  4310. function isArraySame(arr0, arr1, arrDim) {
  4311. if (arr0 === arr1) {
  4312. return true;
  4313. }
  4314. var len = arr0.length;
  4315. if (len !== arr1.length) {
  4316. return false;
  4317. }
  4318. if (arrDim === 1) {
  4319. for (var i = 0; i < len; i++) {
  4320. if (arr0[i] !== arr1[i]) {
  4321. return false;
  4322. }
  4323. }
  4324. } else {
  4325. var len2 = arr0[0].length;
  4326. for (var i = 0; i < len; i++) {
  4327. for (var j = 0; j < len2; j++) {
  4328. if (arr0[i][j] !== arr1[i][j]) {
  4329. return false;
  4330. }
  4331. }
  4332. }
  4333. }
  4334. return true;
  4335. }
  4336. /**
  4337. * Catmull Rom interpolate array
  4338. * @param {Array} p0
  4339. * @param {Array} p1
  4340. * @param {Array} p2
  4341. * @param {Array} p3
  4342. * @param {number} t
  4343. * @param {number} t2
  4344. * @param {number} t3
  4345. * @param {Array} out
  4346. * @param {number} arrDim
  4347. */
  4348. function catmullRomInterpolateArray(p0, p1, p2, p3, t, t2, t3, out, arrDim) {
  4349. var len = p0.length;
  4350. if (arrDim === 1) {
  4351. for (var i = 0; i < len; i++) {
  4352. out[i] = catmullRomInterpolate(p0[i], p1[i], p2[i], p3[i], t, t2, t3);
  4353. }
  4354. } else {
  4355. var len2 = p0[0].length;
  4356. for (var i = 0; i < len; i++) {
  4357. for (var j = 0; j < len2; j++) {
  4358. out[i][j] = catmullRomInterpolate(p0[i][j], p1[i][j], p2[i][j], p3[i][j], t, t2, t3);
  4359. }
  4360. }
  4361. }
  4362. }
  4363. /**
  4364. * Catmull Rom interpolate number
  4365. * @param {number} p0
  4366. * @param {number} p1
  4367. * @param {number} p2
  4368. * @param {number} p3
  4369. * @param {number} t
  4370. * @param {number} t2
  4371. * @param {number} t3
  4372. * @return {number}
  4373. */
  4374. function catmullRomInterpolate(p0, p1, p2, p3, t, t2, t3) {
  4375. var v0 = (p2 - p0) * 0.5;
  4376. var v1 = (p3 - p1) * 0.5;
  4377. return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
  4378. }
  4379. function cloneValue(value) {
  4380. if (isArrayLike(value)) {
  4381. var len = value.length;
  4382. if (isArrayLike(value[0])) {
  4383. var ret = [];
  4384. for (var i = 0; i < len; i++) {
  4385. ret.push(arraySlice.call(value[i]));
  4386. }
  4387. return ret;
  4388. }
  4389. return arraySlice.call(value);
  4390. }
  4391. return value;
  4392. }
  4393. function rgba2String(rgba) {
  4394. rgba[0] = Math.floor(rgba[0]);
  4395. rgba[1] = Math.floor(rgba[1]);
  4396. rgba[2] = Math.floor(rgba[2]);
  4397. return 'rgba(' + rgba.join(',') + ')';
  4398. }
  4399. function getArrayDim(keyframes) {
  4400. var lastValue = keyframes[keyframes.length - 1].value;
  4401. return isArrayLike(lastValue && lastValue[0]) ? 2 : 1;
  4402. }
  4403. function createTrackClip(animator, easing, oneTrackDone, keyframes, propName, forceAnimate) {
  4404. var getter = animator._getter;
  4405. var setter = animator._setter;
  4406. var useSpline = easing === 'spline';
  4407. var trackLen = keyframes.length;
  4408. if (!trackLen) {
  4409. return;
  4410. } // Guess data type
  4411. var firstVal = keyframes[0].value;
  4412. var isValueArray = isArrayLike(firstVal);
  4413. var isValueColor = false;
  4414. var isValueString = false; // For vertices morphing
  4415. var arrDim = isValueArray ? getArrayDim(keyframes) : 0;
  4416. var trackMaxTime; // Sort keyframe as ascending
  4417. keyframes.sort(function (a, b) {
  4418. return a.time - b.time;
  4419. });
  4420. trackMaxTime = keyframes[trackLen - 1].time; // Percents of each keyframe
  4421. var kfPercents = []; // Value of each keyframe
  4422. var kfValues = [];
  4423. var prevValue = keyframes[0].value;
  4424. var isAllValueEqual = true;
  4425. for (var i = 0; i < trackLen; i++) {
  4426. kfPercents.push(keyframes[i].time / trackMaxTime); // Assume value is a color when it is a string
  4427. var value = keyframes[i].value; // Check if value is equal, deep check if value is array
  4428. if (!(isValueArray && isArraySame(value, prevValue, arrDim) || !isValueArray && value === prevValue)) {
  4429. isAllValueEqual = false;
  4430. }
  4431. prevValue = value; // Try converting a string to a color array
  4432. if (typeof value === 'string') {
  4433. var colorArray = color.parse(value);
  4434. if (colorArray) {
  4435. value = colorArray;
  4436. isValueColor = true;
  4437. } else {
  4438. isValueString = true;
  4439. }
  4440. }
  4441. kfValues.push(value);
  4442. }
  4443. if (!forceAnimate && isAllValueEqual) {
  4444. return;
  4445. }
  4446. var lastValue = kfValues[trackLen - 1]; // Polyfill array and NaN value
  4447. for (var i = 0; i < trackLen - 1; i++) {
  4448. if (isValueArray) {
  4449. fillArr(kfValues[i], lastValue, arrDim);
  4450. } else {
  4451. if (isNaN(kfValues[i]) && !isNaN(lastValue) && !isValueString && !isValueColor) {
  4452. kfValues[i] = lastValue;
  4453. }
  4454. }
  4455. }
  4456. isValueArray && fillArr(getter(animator._target, propName), lastValue, arrDim); // Cache the key of last frame to speed up when
  4457. // animation playback is sequency
  4458. var lastFrame = 0;
  4459. var lastFramePercent = 0;
  4460. var start;
  4461. var w;
  4462. var p0;
  4463. var p1;
  4464. var p2;
  4465. var p3;
  4466. if (isValueColor) {
  4467. var rgba = [0, 0, 0, 0];
  4468. }
  4469. var onframe = function (target, percent) {
  4470. // Find the range keyframes
  4471. // kf1-----kf2---------current--------kf3
  4472. // find kf2 and kf3 and do interpolation
  4473. var frame; // In the easing function like elasticOut, percent may less than 0
  4474. if (percent < 0) {
  4475. frame = 0;
  4476. } else if (percent < lastFramePercent) {
  4477. // Start from next key
  4478. // PENDING start from lastFrame ?
  4479. start = Math.min(lastFrame + 1, trackLen - 1);
  4480. for (frame = start; frame >= 0; frame--) {
  4481. if (kfPercents[frame] <= percent) {
  4482. break;
  4483. }
  4484. } // PENDING really need to do this ?
  4485. frame = Math.min(frame, trackLen - 2);
  4486. } else {
  4487. for (frame = lastFrame; frame < trackLen; frame++) {
  4488. if (kfPercents[frame] > percent) {
  4489. break;
  4490. }
  4491. }
  4492. frame = Math.min(frame - 1, trackLen - 2);
  4493. }
  4494. lastFrame = frame;
  4495. lastFramePercent = percent;
  4496. var range = kfPercents[frame + 1] - kfPercents[frame];
  4497. if (range === 0) {
  4498. return;
  4499. } else {
  4500. w = (percent - kfPercents[frame]) / range;
  4501. }
  4502. if (useSpline) {
  4503. p1 = kfValues[frame];
  4504. p0 = kfValues[frame === 0 ? frame : frame - 1];
  4505. p2 = kfValues[frame > trackLen - 2 ? trackLen - 1 : frame + 1];
  4506. p3 = kfValues[frame > trackLen - 3 ? trackLen - 1 : frame + 2];
  4507. if (isValueArray) {
  4508. catmullRomInterpolateArray(p0, p1, p2, p3, w, w * w, w * w * w, getter(target, propName), arrDim);
  4509. } else {
  4510. var value;
  4511. if (isValueColor) {
  4512. value = catmullRomInterpolateArray(p0, p1, p2, p3, w, w * w, w * w * w, rgba, 1);
  4513. value = rgba2String(rgba);
  4514. } else if (isValueString) {
  4515. // String is step(0.5)
  4516. return interpolateString(p1, p2, w);
  4517. } else {
  4518. value = catmullRomInterpolate(p0, p1, p2, p3, w, w * w, w * w * w);
  4519. }
  4520. setter(target, propName, value);
  4521. }
  4522. } else {
  4523. if (isValueArray) {
  4524. interpolateArray(kfValues[frame], kfValues[frame + 1], w, getter(target, propName), arrDim);
  4525. } else {
  4526. var value;
  4527. if (isValueColor) {
  4528. interpolateArray(kfValues[frame], kfValues[frame + 1], w, rgba, 1);
  4529. value = rgba2String(rgba);
  4530. } else if (isValueString) {
  4531. // String is step(0.5)
  4532. return interpolateString(kfValues[frame], kfValues[frame + 1], w);
  4533. } else {
  4534. value = interpolateNumber(kfValues[frame], kfValues[frame + 1], w);
  4535. }
  4536. setter(target, propName, value);
  4537. }
  4538. }
  4539. };
  4540. var clip = new Clip({
  4541. target: animator._target,
  4542. life: trackMaxTime,
  4543. loop: animator._loop,
  4544. delay: animator._delay,
  4545. onframe: onframe,
  4546. ondestroy: oneTrackDone
  4547. });
  4548. if (easing && easing !== 'spline') {
  4549. clip.easing = easing;
  4550. }
  4551. return clip;
  4552. }
  4553. /**
  4554. * @alias module:zrender/animation/Animator
  4555. * @constructor
  4556. * @param {Object} target
  4557. * @param {boolean} loop
  4558. * @param {Function} getter
  4559. * @param {Function} setter
  4560. */
  4561. var Animator = function (target, loop, getter, setter) {
  4562. this._tracks = {};
  4563. this._target = target;
  4564. this._loop = loop || false;
  4565. this._getter = getter || defaultGetter;
  4566. this._setter = setter || defaultSetter;
  4567. this._clipCount = 0;
  4568. this._delay = 0;
  4569. this._doneList = [];
  4570. this._onframeList = [];
  4571. this._clipList = [];
  4572. };
  4573. Animator.prototype = {
  4574. /**
  4575. * Set Animation keyframe
  4576. * @param {number} time 关键帧时间,单位是ms
  4577. * @param {Object} props 关键帧的属性值,key-value表示
  4578. * @return {module:zrender/animation/Animator}
  4579. */
  4580. when: function (time
  4581. /* ms */
  4582. , props) {
  4583. var tracks = this._tracks;
  4584. for (var propName in props) {
  4585. if (!props.hasOwnProperty(propName)) {
  4586. continue;
  4587. }
  4588. if (!tracks[propName]) {
  4589. tracks[propName] = []; // Invalid value
  4590. var value = this._getter(this._target, propName);
  4591. if (value == null) {
  4592. // zrLog('Invalid property ' + propName);
  4593. continue;
  4594. } // If time is 0
  4595. // Then props is given initialize value
  4596. // Else
  4597. // Initialize value from current prop value
  4598. if (time !== 0) {
  4599. tracks[propName].push({
  4600. time: 0,
  4601. value: cloneValue(value)
  4602. });
  4603. }
  4604. }
  4605. tracks[propName].push({
  4606. time: time,
  4607. value: props[propName]
  4608. });
  4609. }
  4610. return this;
  4611. },
  4612. /**
  4613. * 添加动画每一帧的回调函数
  4614. * @param {Function} callback
  4615. * @return {module:zrender/animation/Animator}
  4616. */
  4617. during: function (callback) {
  4618. this._onframeList.push(callback);
  4619. return this;
  4620. },
  4621. pause: function () {
  4622. for (var i = 0; i < this._clipList.length; i++) {
  4623. this._clipList[i].pause();
  4624. }
  4625. this._paused = true;
  4626. },
  4627. resume: function () {
  4628. for (var i = 0; i < this._clipList.length; i++) {
  4629. this._clipList[i].resume();
  4630. }
  4631. this._paused = false;
  4632. },
  4633. isPaused: function () {
  4634. return !!this._paused;
  4635. },
  4636. _doneCallback: function () {
  4637. // Clear all tracks
  4638. this._tracks = {}; // Clear all clips
  4639. this._clipList.length = 0;
  4640. var doneList = this._doneList;
  4641. var len = doneList.length;
  4642. for (var i = 0; i < len; i++) {
  4643. doneList[i].call(this);
  4644. }
  4645. },
  4646. /**
  4647. * Start the animation
  4648. * @param {string|Function} [easing]
  4649. * 动画缓动函数,详见{@link module:zrender/animation/easing}
  4650. * @param {boolean} forceAnimate
  4651. * @return {module:zrender/animation/Animator}
  4652. */
  4653. start: function (easing, forceAnimate) {
  4654. var self = this;
  4655. var clipCount = 0;
  4656. var oneTrackDone = function () {
  4657. clipCount--;
  4658. if (!clipCount) {
  4659. self._doneCallback();
  4660. }
  4661. };
  4662. var lastClip;
  4663. for (var propName in this._tracks) {
  4664. if (!this._tracks.hasOwnProperty(propName)) {
  4665. continue;
  4666. }
  4667. var clip = createTrackClip(this, easing, oneTrackDone, this._tracks[propName], propName, forceAnimate);
  4668. if (clip) {
  4669. this._clipList.push(clip);
  4670. clipCount++; // If start after added to animation
  4671. if (this.animation) {
  4672. this.animation.addClip(clip);
  4673. }
  4674. lastClip = clip;
  4675. }
  4676. } // Add during callback on the last clip
  4677. if (lastClip) {
  4678. var oldOnFrame = lastClip.onframe;
  4679. lastClip.onframe = function (target, percent) {
  4680. oldOnFrame(target, percent);
  4681. for (var i = 0; i < self._onframeList.length; i++) {
  4682. self._onframeList[i](target, percent);
  4683. }
  4684. };
  4685. } // This optimization will help the case that in the upper application
  4686. // the view may be refreshed frequently, where animation will be
  4687. // called repeatly but nothing changed.
  4688. if (!clipCount) {
  4689. this._doneCallback();
  4690. }
  4691. return this;
  4692. },
  4693. /**
  4694. * Stop animation
  4695. * @param {boolean} forwardToLast If move to last frame before stop
  4696. */
  4697. stop: function (forwardToLast) {
  4698. var clipList = this._clipList;
  4699. var animation = this.animation;
  4700. for (var i = 0; i < clipList.length; i++) {
  4701. var clip = clipList[i];
  4702. if (forwardToLast) {
  4703. // Move to last frame before stop
  4704. clip.onframe(this._target, 1);
  4705. }
  4706. animation && animation.removeClip(clip);
  4707. }
  4708. clipList.length = 0;
  4709. },
  4710. /**
  4711. * Set when animation delay starts
  4712. * @param {number} time 单位ms
  4713. * @return {module:zrender/animation/Animator}
  4714. */
  4715. delay: function (time) {
  4716. this._delay = time;
  4717. return this;
  4718. },
  4719. /**
  4720. * Add callback for animation end
  4721. * @param {Function} cb
  4722. * @return {module:zrender/animation/Animator}
  4723. */
  4724. done: function (cb) {
  4725. if (cb) {
  4726. this._doneList.push(cb);
  4727. }
  4728. return this;
  4729. },
  4730. /**
  4731. * @return {Array.<module:zrender/animation/Clip>}
  4732. */
  4733. getClips: function () {
  4734. return this._clipList;
  4735. }
  4736. };
  4737. var _default = Animator;
  4738. module.exports = _default;
  4739. /***/ }),
  4740. /***/ "./node_modules/zrender/lib/animation/Clip.js":
  4741. /*!****************************************************!*\
  4742. !*** ./node_modules/zrender/lib/animation/Clip.js ***!
  4743. \****************************************************/
  4744. /*! no static exports found */
  4745. /***/ (function(module, exports, __webpack_require__) {
  4746. var easingFuncs = __webpack_require__(/*! ./easing */ "./node_modules/zrender/lib/animation/easing.js");
  4747. /**
  4748. * 动画主控制器
  4749. * @config target 动画对象,可以是数组,如果是数组的话会批量分发onframe等事件
  4750. * @config life(1000) 动画时长
  4751. * @config delay(0) 动画延迟时间
  4752. * @config loop(true)
  4753. * @config gap(0) 循环的间隔时间
  4754. * @config onframe
  4755. * @config easing(optional)
  4756. * @config ondestroy(optional)
  4757. * @config onrestart(optional)
  4758. *
  4759. * TODO pause
  4760. */
  4761. function Clip(options) {
  4762. this._target = options.target; // 生命周期
  4763. this._life = options.life || 1000; // 延时
  4764. this._delay = options.delay || 0; // 开始时间
  4765. // this._startTime = new Date().getTime() + this._delay;// 单位毫秒
  4766. this._initialized = false; // 是否循环
  4767. this.loop = options.loop == null ? false : options.loop;
  4768. this.gap = options.gap || 0;
  4769. this.easing = options.easing || 'Linear';
  4770. this.onframe = options.onframe;
  4771. this.ondestroy = options.ondestroy;
  4772. this.onrestart = options.onrestart;
  4773. this._pausedTime = 0;
  4774. this._paused = false;
  4775. }
  4776. Clip.prototype = {
  4777. constructor: Clip,
  4778. step: function (globalTime, deltaTime) {
  4779. // Set startTime on first step, or _startTime may has milleseconds different between clips
  4780. // PENDING
  4781. if (!this._initialized) {
  4782. this._startTime = globalTime + this._delay;
  4783. this._initialized = true;
  4784. }
  4785. if (this._paused) {
  4786. this._pausedTime += deltaTime;
  4787. return;
  4788. }
  4789. var percent = (globalTime - this._startTime - this._pausedTime) / this._life; // 还没开始
  4790. if (percent < 0) {
  4791. return;
  4792. }
  4793. percent = Math.min(percent, 1);
  4794. var easing = this.easing;
  4795. var easingFunc = typeof easing === 'string' ? easingFuncs[easing] : easing;
  4796. var schedule = typeof easingFunc === 'function' ? easingFunc(percent) : percent;
  4797. this.fire('frame', schedule); // 结束
  4798. if (percent === 1) {
  4799. if (this.loop) {
  4800. this.restart(globalTime); // 重新开始周期
  4801. // 抛出而不是直接调用事件直到 stage.update 后再统一调用这些事件
  4802. return 'restart';
  4803. } // 动画完成将这个控制器标识为待删除
  4804. // 在Animation.update中进行批量删除
  4805. this._needsRemove = true;
  4806. return 'destroy';
  4807. }
  4808. return null;
  4809. },
  4810. restart: function (globalTime) {
  4811. var remainder = (globalTime - this._startTime - this._pausedTime) % this._life;
  4812. this._startTime = globalTime - remainder + this.gap;
  4813. this._pausedTime = 0;
  4814. this._needsRemove = false;
  4815. },
  4816. fire: function (eventType, arg) {
  4817. eventType = 'on' + eventType;
  4818. if (this[eventType]) {
  4819. this[eventType](this._target, arg);
  4820. }
  4821. },
  4822. pause: function () {
  4823. this._paused = true;
  4824. },
  4825. resume: function () {
  4826. this._paused = false;
  4827. }
  4828. };
  4829. var _default = Clip;
  4830. module.exports = _default;
  4831. /***/ }),
  4832. /***/ "./node_modules/zrender/lib/animation/easing.js":
  4833. /*!******************************************************!*\
  4834. !*** ./node_modules/zrender/lib/animation/easing.js ***!
  4835. \******************************************************/
  4836. /*! no static exports found */
  4837. /***/ (function(module, exports) {
  4838. /**
  4839. * 缓动代码来自 https://github.com/sole/tween.js/blob/master/src/Tween.js
  4840. * @see http://sole.github.io/tween.js/examples/03_graphs.html
  4841. * @exports zrender/animation/easing
  4842. */
  4843. var easing = {
  4844. /**
  4845. * @param {number} k
  4846. * @return {number}
  4847. */
  4848. linear: function (k) {
  4849. return k;
  4850. },
  4851. /**
  4852. * @param {number} k
  4853. * @return {number}
  4854. */
  4855. quadraticIn: function (k) {
  4856. return k * k;
  4857. },
  4858. /**
  4859. * @param {number} k
  4860. * @return {number}
  4861. */
  4862. quadraticOut: function (k) {
  4863. return k * (2 - k);
  4864. },
  4865. /**
  4866. * @param {number} k
  4867. * @return {number}
  4868. */
  4869. quadraticInOut: function (k) {
  4870. if ((k *= 2) < 1) {
  4871. return 0.5 * k * k;
  4872. }
  4873. return -0.5 * (--k * (k - 2) - 1);
  4874. },
  4875. // 三次方的缓动(t^3)
  4876. /**
  4877. * @param {number} k
  4878. * @return {number}
  4879. */
  4880. cubicIn: function (k) {
  4881. return k * k * k;
  4882. },
  4883. /**
  4884. * @param {number} k
  4885. * @return {number}
  4886. */
  4887. cubicOut: function (k) {
  4888. return --k * k * k + 1;
  4889. },
  4890. /**
  4891. * @param {number} k
  4892. * @return {number}
  4893. */
  4894. cubicInOut: function (k) {
  4895. if ((k *= 2) < 1) {
  4896. return 0.5 * k * k * k;
  4897. }
  4898. return 0.5 * ((k -= 2) * k * k + 2);
  4899. },
  4900. // 四次方的缓动(t^4)
  4901. /**
  4902. * @param {number} k
  4903. * @return {number}
  4904. */
  4905. quarticIn: function (k) {
  4906. return k * k * k * k;
  4907. },
  4908. /**
  4909. * @param {number} k
  4910. * @return {number}
  4911. */
  4912. quarticOut: function (k) {
  4913. return 1 - --k * k * k * k;
  4914. },
  4915. /**
  4916. * @param {number} k
  4917. * @return {number}
  4918. */
  4919. quarticInOut: function (k) {
  4920. if ((k *= 2) < 1) {
  4921. return 0.5 * k * k * k * k;
  4922. }
  4923. return -0.5 * ((k -= 2) * k * k * k - 2);
  4924. },
  4925. // 五次方的缓动(t^5)
  4926. /**
  4927. * @param {number} k
  4928. * @return {number}
  4929. */
  4930. quinticIn: function (k) {
  4931. return k * k * k * k * k;
  4932. },
  4933. /**
  4934. * @param {number} k
  4935. * @return {number}
  4936. */
  4937. quinticOut: function (k) {
  4938. return --k * k * k * k * k + 1;
  4939. },
  4940. /**
  4941. * @param {number} k
  4942. * @return {number}
  4943. */
  4944. quinticInOut: function (k) {
  4945. if ((k *= 2) < 1) {
  4946. return 0.5 * k * k * k * k * k;
  4947. }
  4948. return 0.5 * ((k -= 2) * k * k * k * k + 2);
  4949. },
  4950. // 正弦曲线的缓动(sin(t))
  4951. /**
  4952. * @param {number} k
  4953. * @return {number}
  4954. */
  4955. sinusoidalIn: function (k) {
  4956. return 1 - Math.cos(k * Math.PI / 2);
  4957. },
  4958. /**
  4959. * @param {number} k
  4960. * @return {number}
  4961. */
  4962. sinusoidalOut: function (k) {
  4963. return Math.sin(k * Math.PI / 2);
  4964. },
  4965. /**
  4966. * @param {number} k
  4967. * @return {number}
  4968. */
  4969. sinusoidalInOut: function (k) {
  4970. return 0.5 * (1 - Math.cos(Math.PI * k));
  4971. },
  4972. // 指数曲线的缓动(2^t)
  4973. /**
  4974. * @param {number} k
  4975. * @return {number}
  4976. */
  4977. exponentialIn: function (k) {
  4978. return k === 0 ? 0 : Math.pow(1024, k - 1);
  4979. },
  4980. /**
  4981. * @param {number} k
  4982. * @return {number}
  4983. */
  4984. exponentialOut: function (k) {
  4985. return k === 1 ? 1 : 1 - Math.pow(2, -10 * k);
  4986. },
  4987. /**
  4988. * @param {number} k
  4989. * @return {number}
  4990. */
  4991. exponentialInOut: function (k) {
  4992. if (k === 0) {
  4993. return 0;
  4994. }
  4995. if (k === 1) {
  4996. return 1;
  4997. }
  4998. if ((k *= 2) < 1) {
  4999. return 0.5 * Math.pow(1024, k - 1);
  5000. }
  5001. return 0.5 * (-Math.pow(2, -10 * (k - 1)) + 2);
  5002. },
  5003. // 圆形曲线的缓动(sqrt(1-t^2))
  5004. /**
  5005. * @param {number} k
  5006. * @return {number}
  5007. */
  5008. circularIn: function (k) {
  5009. return 1 - Math.sqrt(1 - k * k);
  5010. },
  5011. /**
  5012. * @param {number} k
  5013. * @return {number}
  5014. */
  5015. circularOut: function (k) {
  5016. return Math.sqrt(1 - --k * k);
  5017. },
  5018. /**
  5019. * @param {number} k
  5020. * @return {number}
  5021. */
  5022. circularInOut: function (k) {
  5023. if ((k *= 2) < 1) {
  5024. return -0.5 * (Math.sqrt(1 - k * k) - 1);
  5025. }
  5026. return 0.5 * (Math.sqrt(1 - (k -= 2) * k) + 1);
  5027. },
  5028. // 创建类似于弹簧在停止前来回振荡的动画
  5029. /**
  5030. * @param {number} k
  5031. * @return {number}
  5032. */
  5033. elasticIn: function (k) {
  5034. var s;
  5035. var a = 0.1;
  5036. var p = 0.4;
  5037. if (k === 0) {
  5038. return 0;
  5039. }
  5040. if (k === 1) {
  5041. return 1;
  5042. }
  5043. if (!a || a < 1) {
  5044. a = 1;
  5045. s = p / 4;
  5046. } else {
  5047. s = p * Math.asin(1 / a) / (2 * Math.PI);
  5048. }
  5049. return -(a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  5050. },
  5051. /**
  5052. * @param {number} k
  5053. * @return {number}
  5054. */
  5055. elasticOut: function (k) {
  5056. var s;
  5057. var a = 0.1;
  5058. var p = 0.4;
  5059. if (k === 0) {
  5060. return 0;
  5061. }
  5062. if (k === 1) {
  5063. return 1;
  5064. }
  5065. if (!a || a < 1) {
  5066. a = 1;
  5067. s = p / 4;
  5068. } else {
  5069. s = p * Math.asin(1 / a) / (2 * Math.PI);
  5070. }
  5071. return a * Math.pow(2, -10 * k) * Math.sin((k - s) * (2 * Math.PI) / p) + 1;
  5072. },
  5073. /**
  5074. * @param {number} k
  5075. * @return {number}
  5076. */
  5077. elasticInOut: function (k) {
  5078. var s;
  5079. var a = 0.1;
  5080. var p = 0.4;
  5081. if (k === 0) {
  5082. return 0;
  5083. }
  5084. if (k === 1) {
  5085. return 1;
  5086. }
  5087. if (!a || a < 1) {
  5088. a = 1;
  5089. s = p / 4;
  5090. } else {
  5091. s = p * Math.asin(1 / a) / (2 * Math.PI);
  5092. }
  5093. if ((k *= 2) < 1) {
  5094. return -0.5 * (a * Math.pow(2, 10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p));
  5095. }
  5096. return a * Math.pow(2, -10 * (k -= 1)) * Math.sin((k - s) * (2 * Math.PI) / p) * 0.5 + 1;
  5097. },
  5098. // 在某一动画开始沿指示的路径进行动画处理前稍稍收回该动画的移动
  5099. /**
  5100. * @param {number} k
  5101. * @return {number}
  5102. */
  5103. backIn: function (k) {
  5104. var s = 1.70158;
  5105. return k * k * ((s + 1) * k - s);
  5106. },
  5107. /**
  5108. * @param {number} k
  5109. * @return {number}
  5110. */
  5111. backOut: function (k) {
  5112. var s = 1.70158;
  5113. return --k * k * ((s + 1) * k + s) + 1;
  5114. },
  5115. /**
  5116. * @param {number} k
  5117. * @return {number}
  5118. */
  5119. backInOut: function (k) {
  5120. var s = 1.70158 * 1.525;
  5121. if ((k *= 2) < 1) {
  5122. return 0.5 * (k * k * ((s + 1) * k - s));
  5123. }
  5124. return 0.5 * ((k -= 2) * k * ((s + 1) * k + s) + 2);
  5125. },
  5126. // 创建弹跳效果
  5127. /**
  5128. * @param {number} k
  5129. * @return {number}
  5130. */
  5131. bounceIn: function (k) {
  5132. return 1 - easing.bounceOut(1 - k);
  5133. },
  5134. /**
  5135. * @param {number} k
  5136. * @return {number}
  5137. */
  5138. bounceOut: function (k) {
  5139. if (k < 1 / 2.75) {
  5140. return 7.5625 * k * k;
  5141. } else if (k < 2 / 2.75) {
  5142. return 7.5625 * (k -= 1.5 / 2.75) * k + 0.75;
  5143. } else if (k < 2.5 / 2.75) {
  5144. return 7.5625 * (k -= 2.25 / 2.75) * k + 0.9375;
  5145. } else {
  5146. return 7.5625 * (k -= 2.625 / 2.75) * k + 0.984375;
  5147. }
  5148. },
  5149. /**
  5150. * @param {number} k
  5151. * @return {number}
  5152. */
  5153. bounceInOut: function (k) {
  5154. if (k < 0.5) {
  5155. return easing.bounceIn(k * 2) * 0.5;
  5156. }
  5157. return easing.bounceOut(k * 2 - 1) * 0.5 + 0.5;
  5158. }
  5159. };
  5160. var _default = easing;
  5161. module.exports = _default;
  5162. /***/ }),
  5163. /***/ "./node_modules/zrender/lib/config.js":
  5164. /*!********************************************!*\
  5165. !*** ./node_modules/zrender/lib/config.js ***!
  5166. \********************************************/
  5167. /*! no static exports found */
  5168. /***/ (function(module, exports) {
  5169. var dpr = 1; // If in browser environment
  5170. if (typeof window !== 'undefined') {
  5171. dpr = Math.max(window.devicePixelRatio || 1, 1);
  5172. }
  5173. /**
  5174. * config默认配置项
  5175. * @exports zrender/config
  5176. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  5177. */
  5178. /**
  5179. * Debug log mode:
  5180. * 0: Do nothing, for release.
  5181. * 1: console.error, for debug.
  5182. */
  5183. var debugMode = 0; // retina 屏幕优化
  5184. var devicePixelRatio = dpr;
  5185. exports.debugMode = debugMode;
  5186. exports.devicePixelRatio = devicePixelRatio;
  5187. /***/ }),
  5188. /***/ "./node_modules/zrender/lib/contain/arc.js":
  5189. /*!*************************************************!*\
  5190. !*** ./node_modules/zrender/lib/contain/arc.js ***!
  5191. \*************************************************/
  5192. /*! no static exports found */
  5193. /***/ (function(module, exports, __webpack_require__) {
  5194. var _util = __webpack_require__(/*! ./util */ "./node_modules/zrender/lib/contain/util.js");
  5195. var normalizeRadian = _util.normalizeRadian;
  5196. var PI2 = Math.PI * 2;
  5197. /**
  5198. * 圆弧描边包含判断
  5199. * @param {number} cx
  5200. * @param {number} cy
  5201. * @param {number} r
  5202. * @param {number} startAngle
  5203. * @param {number} endAngle
  5204. * @param {boolean} anticlockwise
  5205. * @param {number} lineWidth
  5206. * @param {number} x
  5207. * @param {number} y
  5208. * @return {Boolean}
  5209. */
  5210. function containStroke(cx, cy, r, startAngle, endAngle, anticlockwise, lineWidth, x, y) {
  5211. if (lineWidth === 0) {
  5212. return false;
  5213. }
  5214. var _l = lineWidth;
  5215. x -= cx;
  5216. y -= cy;
  5217. var d = Math.sqrt(x * x + y * y);
  5218. if (d - _l > r || d + _l < r) {
  5219. return false;
  5220. }
  5221. if (Math.abs(startAngle - endAngle) % PI2 < 1e-4) {
  5222. // Is a circle
  5223. return true;
  5224. }
  5225. if (anticlockwise) {
  5226. var tmp = startAngle;
  5227. startAngle = normalizeRadian(endAngle);
  5228. endAngle = normalizeRadian(tmp);
  5229. } else {
  5230. startAngle = normalizeRadian(startAngle);
  5231. endAngle = normalizeRadian(endAngle);
  5232. }
  5233. if (startAngle > endAngle) {
  5234. endAngle += PI2;
  5235. }
  5236. var angle = Math.atan2(y, x);
  5237. if (angle < 0) {
  5238. angle += PI2;
  5239. }
  5240. return angle >= startAngle && angle <= endAngle || angle + PI2 >= startAngle && angle + PI2 <= endAngle;
  5241. }
  5242. exports.containStroke = containStroke;
  5243. /***/ }),
  5244. /***/ "./node_modules/zrender/lib/contain/cubic.js":
  5245. /*!***************************************************!*\
  5246. !*** ./node_modules/zrender/lib/contain/cubic.js ***!
  5247. \***************************************************/
  5248. /*! no static exports found */
  5249. /***/ (function(module, exports, __webpack_require__) {
  5250. var curve = __webpack_require__(/*! ../core/curve */ "./node_modules/zrender/lib/core/curve.js");
  5251. /**
  5252. * 三次贝塞尔曲线描边包含判断
  5253. * @param {number} x0
  5254. * @param {number} y0
  5255. * @param {number} x1
  5256. * @param {number} y1
  5257. * @param {number} x2
  5258. * @param {number} y2
  5259. * @param {number} x3
  5260. * @param {number} y3
  5261. * @param {number} lineWidth
  5262. * @param {number} x
  5263. * @param {number} y
  5264. * @return {boolean}
  5265. */
  5266. function containStroke(x0, y0, x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
  5267. if (lineWidth === 0) {
  5268. return false;
  5269. }
  5270. var _l = lineWidth; // Quick reject
  5271. if (y > y0 + _l && y > y1 + _l && y > y2 + _l && y > y3 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l && y < y3 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l && x > x3 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l && x < x3 - _l) {
  5272. return false;
  5273. }
  5274. var d = curve.cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, null);
  5275. return d <= _l / 2;
  5276. }
  5277. exports.containStroke = containStroke;
  5278. /***/ }),
  5279. /***/ "./node_modules/zrender/lib/contain/line.js":
  5280. /*!**************************************************!*\
  5281. !*** ./node_modules/zrender/lib/contain/line.js ***!
  5282. \**************************************************/
  5283. /*! no static exports found */
  5284. /***/ (function(module, exports) {
  5285. /**
  5286. * 线段包含判断
  5287. * @param {number} x0
  5288. * @param {number} y0
  5289. * @param {number} x1
  5290. * @param {number} y1
  5291. * @param {number} lineWidth
  5292. * @param {number} x
  5293. * @param {number} y
  5294. * @return {boolean}
  5295. */
  5296. function containStroke(x0, y0, x1, y1, lineWidth, x, y) {
  5297. if (lineWidth === 0) {
  5298. return false;
  5299. }
  5300. var _l = lineWidth;
  5301. var _a = 0;
  5302. var _b = x0; // Quick reject
  5303. if (y > y0 + _l && y > y1 + _l || y < y0 - _l && y < y1 - _l || x > x0 + _l && x > x1 + _l || x < x0 - _l && x < x1 - _l) {
  5304. return false;
  5305. }
  5306. if (x0 !== x1) {
  5307. _a = (y0 - y1) / (x0 - x1);
  5308. _b = (x0 * y1 - x1 * y0) / (x0 - x1);
  5309. } else {
  5310. return Math.abs(x - x0) <= _l / 2;
  5311. }
  5312. var tmp = _a * x - y + _b;
  5313. var _s = tmp * tmp / (_a * _a + 1);
  5314. return _s <= _l / 2 * _l / 2;
  5315. }
  5316. exports.containStroke = containStroke;
  5317. /***/ }),
  5318. /***/ "./node_modules/zrender/lib/contain/path.js":
  5319. /*!**************************************************!*\
  5320. !*** ./node_modules/zrender/lib/contain/path.js ***!
  5321. \**************************************************/
  5322. /*! no static exports found */
  5323. /***/ (function(module, exports, __webpack_require__) {
  5324. var PathProxy = __webpack_require__(/*! ../core/PathProxy */ "./node_modules/zrender/lib/core/PathProxy.js");
  5325. var line = __webpack_require__(/*! ./line */ "./node_modules/zrender/lib/contain/line.js");
  5326. var cubic = __webpack_require__(/*! ./cubic */ "./node_modules/zrender/lib/contain/cubic.js");
  5327. var quadratic = __webpack_require__(/*! ./quadratic */ "./node_modules/zrender/lib/contain/quadratic.js");
  5328. var arc = __webpack_require__(/*! ./arc */ "./node_modules/zrender/lib/contain/arc.js");
  5329. var _util = __webpack_require__(/*! ./util */ "./node_modules/zrender/lib/contain/util.js");
  5330. var normalizeRadian = _util.normalizeRadian;
  5331. var curve = __webpack_require__(/*! ../core/curve */ "./node_modules/zrender/lib/core/curve.js");
  5332. var windingLine = __webpack_require__(/*! ./windingLine */ "./node_modules/zrender/lib/contain/windingLine.js");
  5333. var CMD = PathProxy.CMD;
  5334. var PI2 = Math.PI * 2;
  5335. var EPSILON = 1e-4;
  5336. function isAroundEqual(a, b) {
  5337. return Math.abs(a - b) < EPSILON;
  5338. } // 临时数组
  5339. var roots = [-1, -1, -1];
  5340. var extrema = [-1, -1];
  5341. function swapExtrema() {
  5342. var tmp = extrema[0];
  5343. extrema[0] = extrema[1];
  5344. extrema[1] = tmp;
  5345. }
  5346. function windingCubic(x0, y0, x1, y1, x2, y2, x3, y3, x, y) {
  5347. // Quick reject
  5348. if (y > y0 && y > y1 && y > y2 && y > y3 || y < y0 && y < y1 && y < y2 && y < y3) {
  5349. return 0;
  5350. }
  5351. var nRoots = curve.cubicRootAt(y0, y1, y2, y3, y, roots);
  5352. if (nRoots === 0) {
  5353. return 0;
  5354. } else {
  5355. var w = 0;
  5356. var nExtrema = -1;
  5357. var y0_;
  5358. var y1_;
  5359. for (var i = 0; i < nRoots; i++) {
  5360. var t = roots[i]; // Avoid winding error when intersection point is the connect point of two line of polygon
  5361. var unit = t === 0 || t === 1 ? 0.5 : 1;
  5362. var x_ = curve.cubicAt(x0, x1, x2, x3, t);
  5363. if (x_ < x) {
  5364. // Quick reject
  5365. continue;
  5366. }
  5367. if (nExtrema < 0) {
  5368. nExtrema = curve.cubicExtrema(y0, y1, y2, y3, extrema);
  5369. if (extrema[1] < extrema[0] && nExtrema > 1) {
  5370. swapExtrema();
  5371. }
  5372. y0_ = curve.cubicAt(y0, y1, y2, y3, extrema[0]);
  5373. if (nExtrema > 1) {
  5374. y1_ = curve.cubicAt(y0, y1, y2, y3, extrema[1]);
  5375. }
  5376. }
  5377. if (nExtrema === 2) {
  5378. // 分成三段单调函数
  5379. if (t < extrema[0]) {
  5380. w += y0_ < y0 ? unit : -unit;
  5381. } else if (t < extrema[1]) {
  5382. w += y1_ < y0_ ? unit : -unit;
  5383. } else {
  5384. w += y3 < y1_ ? unit : -unit;
  5385. }
  5386. } else {
  5387. // 分成两段单调函数
  5388. if (t < extrema[0]) {
  5389. w += y0_ < y0 ? unit : -unit;
  5390. } else {
  5391. w += y3 < y0_ ? unit : -unit;
  5392. }
  5393. }
  5394. }
  5395. return w;
  5396. }
  5397. }
  5398. function windingQuadratic(x0, y0, x1, y1, x2, y2, x, y) {
  5399. // Quick reject
  5400. if (y > y0 && y > y1 && y > y2 || y < y0 && y < y1 && y < y2) {
  5401. return 0;
  5402. }
  5403. var nRoots = curve.quadraticRootAt(y0, y1, y2, y, roots);
  5404. if (nRoots === 0) {
  5405. return 0;
  5406. } else {
  5407. var t = curve.quadraticExtremum(y0, y1, y2);
  5408. if (t >= 0 && t <= 1) {
  5409. var w = 0;
  5410. var y_ = curve.quadraticAt(y0, y1, y2, t);
  5411. for (var i = 0; i < nRoots; i++) {
  5412. // Remove one endpoint.
  5413. var unit = roots[i] === 0 || roots[i] === 1 ? 0.5 : 1;
  5414. var x_ = curve.quadraticAt(x0, x1, x2, roots[i]);
  5415. if (x_ < x) {
  5416. // Quick reject
  5417. continue;
  5418. }
  5419. if (roots[i] < t) {
  5420. w += y_ < y0 ? unit : -unit;
  5421. } else {
  5422. w += y2 < y_ ? unit : -unit;
  5423. }
  5424. }
  5425. return w;
  5426. } else {
  5427. // Remove one endpoint.
  5428. var unit = roots[0] === 0 || roots[0] === 1 ? 0.5 : 1;
  5429. var x_ = curve.quadraticAt(x0, x1, x2, roots[0]);
  5430. if (x_ < x) {
  5431. // Quick reject
  5432. return 0;
  5433. }
  5434. return y2 < y0 ? unit : -unit;
  5435. }
  5436. }
  5437. } // TODO
  5438. // Arc 旋转
  5439. function windingArc(cx, cy, r, startAngle, endAngle, anticlockwise, x, y) {
  5440. y -= cy;
  5441. if (y > r || y < -r) {
  5442. return 0;
  5443. }
  5444. var tmp = Math.sqrt(r * r - y * y);
  5445. roots[0] = -tmp;
  5446. roots[1] = tmp;
  5447. var diff = Math.abs(startAngle - endAngle);
  5448. if (diff < 1e-4) {
  5449. return 0;
  5450. }
  5451. if (diff % PI2 < 1e-4) {
  5452. // Is a circle
  5453. startAngle = 0;
  5454. endAngle = PI2;
  5455. var dir = anticlockwise ? 1 : -1;
  5456. if (x >= roots[0] + cx && x <= roots[1] + cx) {
  5457. return dir;
  5458. } else {
  5459. return 0;
  5460. }
  5461. }
  5462. if (anticlockwise) {
  5463. var tmp = startAngle;
  5464. startAngle = normalizeRadian(endAngle);
  5465. endAngle = normalizeRadian(tmp);
  5466. } else {
  5467. startAngle = normalizeRadian(startAngle);
  5468. endAngle = normalizeRadian(endAngle);
  5469. }
  5470. if (startAngle > endAngle) {
  5471. endAngle += PI2;
  5472. }
  5473. var w = 0;
  5474. for (var i = 0; i < 2; i++) {
  5475. var x_ = roots[i];
  5476. if (x_ + cx > x) {
  5477. var angle = Math.atan2(y, x_);
  5478. var dir = anticlockwise ? 1 : -1;
  5479. if (angle < 0) {
  5480. angle = PI2 + angle;
  5481. }
  5482. if (angle >= startAngle && angle <= endAngle || angle + PI2 >= startAngle && angle + PI2 <= endAngle) {
  5483. if (angle > Math.PI / 2 && angle < Math.PI * 1.5) {
  5484. dir = -dir;
  5485. }
  5486. w += dir;
  5487. }
  5488. }
  5489. }
  5490. return w;
  5491. }
  5492. function containPath(data, lineWidth, isStroke, x, y) {
  5493. var w = 0;
  5494. var xi = 0;
  5495. var yi = 0;
  5496. var x0 = 0;
  5497. var y0 = 0;
  5498. for (var i = 0; i < data.length;) {
  5499. var cmd = data[i++]; // Begin a new subpath
  5500. if (cmd === CMD.M && i > 1) {
  5501. // Close previous subpath
  5502. if (!isStroke) {
  5503. w += windingLine(xi, yi, x0, y0, x, y);
  5504. } // 如果被任何一个 subpath 包含
  5505. // if (w !== 0) {
  5506. // return true;
  5507. // }
  5508. }
  5509. if (i === 1) {
  5510. // 如果第一个命令是 L, C, Q
  5511. // 则 previous point 同绘制命令的第一个 point
  5512. //
  5513. // 第一个命令为 Arc 的情况下会在后面特殊处理
  5514. xi = data[i];
  5515. yi = data[i + 1];
  5516. x0 = xi;
  5517. y0 = yi;
  5518. }
  5519. switch (cmd) {
  5520. case CMD.M:
  5521. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  5522. // 在 closePath 的时候使用
  5523. x0 = data[i++];
  5524. y0 = data[i++];
  5525. xi = x0;
  5526. yi = y0;
  5527. break;
  5528. case CMD.L:
  5529. if (isStroke) {
  5530. if (line.containStroke(xi, yi, data[i], data[i + 1], lineWidth, x, y)) {
  5531. return true;
  5532. }
  5533. } else {
  5534. // NOTE 在第一个命令为 L, C, Q 的时候会计算出 NaN
  5535. w += windingLine(xi, yi, data[i], data[i + 1], x, y) || 0;
  5536. }
  5537. xi = data[i++];
  5538. yi = data[i++];
  5539. break;
  5540. case CMD.C:
  5541. if (isStroke) {
  5542. if (cubic.containStroke(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], lineWidth, x, y)) {
  5543. return true;
  5544. }
  5545. } else {
  5546. w += windingCubic(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], x, y) || 0;
  5547. }
  5548. xi = data[i++];
  5549. yi = data[i++];
  5550. break;
  5551. case CMD.Q:
  5552. if (isStroke) {
  5553. if (quadratic.containStroke(xi, yi, data[i++], data[i++], data[i], data[i + 1], lineWidth, x, y)) {
  5554. return true;
  5555. }
  5556. } else {
  5557. w += windingQuadratic(xi, yi, data[i++], data[i++], data[i], data[i + 1], x, y) || 0;
  5558. }
  5559. xi = data[i++];
  5560. yi = data[i++];
  5561. break;
  5562. case CMD.A:
  5563. // TODO Arc 判断的开销比较大
  5564. var cx = data[i++];
  5565. var cy = data[i++];
  5566. var rx = data[i++];
  5567. var ry = data[i++];
  5568. var theta = data[i++];
  5569. var dTheta = data[i++]; // TODO Arc 旋转
  5570. i += 1;
  5571. var anticlockwise = 1 - data[i++];
  5572. var x1 = Math.cos(theta) * rx + cx;
  5573. var y1 = Math.sin(theta) * ry + cy; // 不是直接使用 arc 命令
  5574. if (i > 1) {
  5575. w += windingLine(xi, yi, x1, y1, x, y);
  5576. } else {
  5577. // 第一个命令起点还未定义
  5578. x0 = x1;
  5579. y0 = y1;
  5580. } // zr 使用scale来模拟椭圆, 这里也对x做一定的缩放
  5581. var _x = (x - cx) * ry / rx + cx;
  5582. if (isStroke) {
  5583. if (arc.containStroke(cx, cy, ry, theta, theta + dTheta, anticlockwise, lineWidth, _x, y)) {
  5584. return true;
  5585. }
  5586. } else {
  5587. w += windingArc(cx, cy, ry, theta, theta + dTheta, anticlockwise, _x, y);
  5588. }
  5589. xi = Math.cos(theta + dTheta) * rx + cx;
  5590. yi = Math.sin(theta + dTheta) * ry + cy;
  5591. break;
  5592. case CMD.R:
  5593. x0 = xi = data[i++];
  5594. y0 = yi = data[i++];
  5595. var width = data[i++];
  5596. var height = data[i++];
  5597. var x1 = x0 + width;
  5598. var y1 = y0 + height;
  5599. if (isStroke) {
  5600. if (line.containStroke(x0, y0, x1, y0, lineWidth, x, y) || line.containStroke(x1, y0, x1, y1, lineWidth, x, y) || line.containStroke(x1, y1, x0, y1, lineWidth, x, y) || line.containStroke(x0, y1, x0, y0, lineWidth, x, y)) {
  5601. return true;
  5602. }
  5603. } else {
  5604. // FIXME Clockwise ?
  5605. w += windingLine(x1, y0, x1, y1, x, y);
  5606. w += windingLine(x0, y1, x0, y0, x, y);
  5607. }
  5608. break;
  5609. case CMD.Z:
  5610. if (isStroke) {
  5611. if (line.containStroke(xi, yi, x0, y0, lineWidth, x, y)) {
  5612. return true;
  5613. }
  5614. } else {
  5615. // Close a subpath
  5616. w += windingLine(xi, yi, x0, y0, x, y); // 如果被任何一个 subpath 包含
  5617. // FIXME subpaths may overlap
  5618. // if (w !== 0) {
  5619. // return true;
  5620. // }
  5621. }
  5622. xi = x0;
  5623. yi = y0;
  5624. break;
  5625. }
  5626. }
  5627. if (!isStroke && !isAroundEqual(yi, y0)) {
  5628. w += windingLine(xi, yi, x0, y0, x, y) || 0;
  5629. }
  5630. return w !== 0;
  5631. }
  5632. function contain(pathData, x, y) {
  5633. return containPath(pathData, 0, false, x, y);
  5634. }
  5635. function containStroke(pathData, lineWidth, x, y) {
  5636. return containPath(pathData, lineWidth, true, x, y);
  5637. }
  5638. exports.contain = contain;
  5639. exports.containStroke = containStroke;
  5640. /***/ }),
  5641. /***/ "./node_modules/zrender/lib/contain/quadratic.js":
  5642. /*!*******************************************************!*\
  5643. !*** ./node_modules/zrender/lib/contain/quadratic.js ***!
  5644. \*******************************************************/
  5645. /*! no static exports found */
  5646. /***/ (function(module, exports, __webpack_require__) {
  5647. var _curve = __webpack_require__(/*! ../core/curve */ "./node_modules/zrender/lib/core/curve.js");
  5648. var quadraticProjectPoint = _curve.quadraticProjectPoint;
  5649. /**
  5650. * 二次贝塞尔曲线描边包含判断
  5651. * @param {number} x0
  5652. * @param {number} y0
  5653. * @param {number} x1
  5654. * @param {number} y1
  5655. * @param {number} x2
  5656. * @param {number} y2
  5657. * @param {number} lineWidth
  5658. * @param {number} x
  5659. * @param {number} y
  5660. * @return {boolean}
  5661. */
  5662. function containStroke(x0, y0, x1, y1, x2, y2, lineWidth, x, y) {
  5663. if (lineWidth === 0) {
  5664. return false;
  5665. }
  5666. var _l = lineWidth; // Quick reject
  5667. if (y > y0 + _l && y > y1 + _l && y > y2 + _l || y < y0 - _l && y < y1 - _l && y < y2 - _l || x > x0 + _l && x > x1 + _l && x > x2 + _l || x < x0 - _l && x < x1 - _l && x < x2 - _l) {
  5668. return false;
  5669. }
  5670. var d = quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, null);
  5671. return d <= _l / 2;
  5672. }
  5673. exports.containStroke = containStroke;
  5674. /***/ }),
  5675. /***/ "./node_modules/zrender/lib/contain/text.js":
  5676. /*!**************************************************!*\
  5677. !*** ./node_modules/zrender/lib/contain/text.js ***!
  5678. \**************************************************/
  5679. /*! no static exports found */
  5680. /***/ (function(module, exports, __webpack_require__) {
  5681. var BoundingRect = __webpack_require__(/*! ../core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  5682. var imageHelper = __webpack_require__(/*! ../graphic/helper/image */ "./node_modules/zrender/lib/graphic/helper/image.js");
  5683. var _util = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  5684. var getContext = _util.getContext;
  5685. var extend = _util.extend;
  5686. var retrieve2 = _util.retrieve2;
  5687. var retrieve3 = _util.retrieve3;
  5688. var trim = _util.trim;
  5689. var textWidthCache = {};
  5690. var textWidthCacheCounter = 0;
  5691. var TEXT_CACHE_MAX = 5000;
  5692. var STYLE_REG = /\{([a-zA-Z0-9_]+)\|([^}]*)\}/g;
  5693. var DEFAULT_FONT = '12px sans-serif'; // Avoid assign to an exported variable, for transforming to cjs.
  5694. var methods = {};
  5695. function $override(name, fn) {
  5696. methods[name] = fn;
  5697. }
  5698. /**
  5699. * @public
  5700. * @param {string} text
  5701. * @param {string} font
  5702. * @return {number} width
  5703. */
  5704. function getWidth(text, font) {
  5705. font = font || DEFAULT_FONT;
  5706. var key = text + ':' + font;
  5707. if (textWidthCache[key]) {
  5708. return textWidthCache[key];
  5709. }
  5710. var textLines = (text + '').split('\n');
  5711. var width = 0;
  5712. for (var i = 0, l = textLines.length; i < l; i++) {
  5713. // textContain.measureText may be overrided in SVG or VML
  5714. width = Math.max(measureText(textLines[i], font).width, width);
  5715. }
  5716. if (textWidthCacheCounter > TEXT_CACHE_MAX) {
  5717. textWidthCacheCounter = 0;
  5718. textWidthCache = {};
  5719. }
  5720. textWidthCacheCounter++;
  5721. textWidthCache[key] = width;
  5722. return width;
  5723. }
  5724. /**
  5725. * @public
  5726. * @param {string} text
  5727. * @param {string} font
  5728. * @param {string} [textAlign='left']
  5729. * @param {string} [textVerticalAlign='top']
  5730. * @param {Array.<number>} [textPadding]
  5731. * @param {Object} [rich]
  5732. * @param {Object} [truncate]
  5733. * @return {Object} {x, y, width, height, lineHeight}
  5734. */
  5735. function getBoundingRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, rich, truncate) {
  5736. return rich ? getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, rich, truncate) : getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, truncate);
  5737. }
  5738. function getPlainTextRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, truncate) {
  5739. var contentBlock = parsePlainText(text, font, textPadding, textLineHeight, truncate);
  5740. var outerWidth = getWidth(text, font);
  5741. if (textPadding) {
  5742. outerWidth += textPadding[1] + textPadding[3];
  5743. }
  5744. var outerHeight = contentBlock.outerHeight;
  5745. var x = adjustTextX(0, outerWidth, textAlign);
  5746. var y = adjustTextY(0, outerHeight, textVerticalAlign);
  5747. var rect = new BoundingRect(x, y, outerWidth, outerHeight);
  5748. rect.lineHeight = contentBlock.lineHeight;
  5749. return rect;
  5750. }
  5751. function getRichTextRect(text, font, textAlign, textVerticalAlign, textPadding, textLineHeight, rich, truncate) {
  5752. var contentBlock = parseRichText(text, {
  5753. rich: rich,
  5754. truncate: truncate,
  5755. font: font,
  5756. textAlign: textAlign,
  5757. textPadding: textPadding,
  5758. textLineHeight: textLineHeight
  5759. });
  5760. var outerWidth = contentBlock.outerWidth;
  5761. var outerHeight = contentBlock.outerHeight;
  5762. var x = adjustTextX(0, outerWidth, textAlign);
  5763. var y = adjustTextY(0, outerHeight, textVerticalAlign);
  5764. return new BoundingRect(x, y, outerWidth, outerHeight);
  5765. }
  5766. /**
  5767. * @public
  5768. * @param {number} x
  5769. * @param {number} width
  5770. * @param {string} [textAlign='left']
  5771. * @return {number} Adjusted x.
  5772. */
  5773. function adjustTextX(x, width, textAlign) {
  5774. // FIXME Right to left language
  5775. if (textAlign === 'right') {
  5776. x -= width;
  5777. } else if (textAlign === 'center') {
  5778. x -= width / 2;
  5779. }
  5780. return x;
  5781. }
  5782. /**
  5783. * @public
  5784. * @param {number} y
  5785. * @param {number} height
  5786. * @param {string} [textVerticalAlign='top']
  5787. * @return {number} Adjusted y.
  5788. */
  5789. function adjustTextY(y, height, textVerticalAlign) {
  5790. if (textVerticalAlign === 'middle') {
  5791. y -= height / 2;
  5792. } else if (textVerticalAlign === 'bottom') {
  5793. y -= height;
  5794. }
  5795. return y;
  5796. }
  5797. /**
  5798. * Follow same interface to `Displayable.prototype.calculateTextPosition`.
  5799. * @public
  5800. * @param {Obejct} [out] Prepared out object. If not input, auto created in the method.
  5801. * @param {module:zrender/graphic/Style} style where `textPosition` and `textDistance` are visited.
  5802. * @param {Object} rect {x, y, width, height} Rect of the host elment, according to which the text positioned.
  5803. * @return {Object} The input `out`. Set: {x, y, textAlign, textVerticalAlign}
  5804. */
  5805. function calculateTextPosition(out, style, rect) {
  5806. var textPosition = style.textPosition;
  5807. var distance = style.textDistance;
  5808. var x = rect.x;
  5809. var y = rect.y;
  5810. distance = distance || 0;
  5811. var height = rect.height;
  5812. var width = rect.width;
  5813. var halfHeight = height / 2;
  5814. var textAlign = 'left';
  5815. var textVerticalAlign = 'top';
  5816. switch (textPosition) {
  5817. case 'left':
  5818. x -= distance;
  5819. y += halfHeight;
  5820. textAlign = 'right';
  5821. textVerticalAlign = 'middle';
  5822. break;
  5823. case 'right':
  5824. x += distance + width;
  5825. y += halfHeight;
  5826. textVerticalAlign = 'middle';
  5827. break;
  5828. case 'top':
  5829. x += width / 2;
  5830. y -= distance;
  5831. textAlign = 'center';
  5832. textVerticalAlign = 'bottom';
  5833. break;
  5834. case 'bottom':
  5835. x += width / 2;
  5836. y += height + distance;
  5837. textAlign = 'center';
  5838. break;
  5839. case 'inside':
  5840. x += width / 2;
  5841. y += halfHeight;
  5842. textAlign = 'center';
  5843. textVerticalAlign = 'middle';
  5844. break;
  5845. case 'insideLeft':
  5846. x += distance;
  5847. y += halfHeight;
  5848. textVerticalAlign = 'middle';
  5849. break;
  5850. case 'insideRight':
  5851. x += width - distance;
  5852. y += halfHeight;
  5853. textAlign = 'right';
  5854. textVerticalAlign = 'middle';
  5855. break;
  5856. case 'insideTop':
  5857. x += width / 2;
  5858. y += distance;
  5859. textAlign = 'center';
  5860. break;
  5861. case 'insideBottom':
  5862. x += width / 2;
  5863. y += height - distance;
  5864. textAlign = 'center';
  5865. textVerticalAlign = 'bottom';
  5866. break;
  5867. case 'insideTopLeft':
  5868. x += distance;
  5869. y += distance;
  5870. break;
  5871. case 'insideTopRight':
  5872. x += width - distance;
  5873. y += distance;
  5874. textAlign = 'right';
  5875. break;
  5876. case 'insideBottomLeft':
  5877. x += distance;
  5878. y += height - distance;
  5879. textVerticalAlign = 'bottom';
  5880. break;
  5881. case 'insideBottomRight':
  5882. x += width - distance;
  5883. y += height - distance;
  5884. textAlign = 'right';
  5885. textVerticalAlign = 'bottom';
  5886. break;
  5887. }
  5888. out = out || {};
  5889. out.x = x;
  5890. out.y = y;
  5891. out.textAlign = textAlign;
  5892. out.textVerticalAlign = textVerticalAlign;
  5893. return out;
  5894. }
  5895. /**
  5896. * To be removed. But still do not remove in case that some one has imported it.
  5897. * @deprecated
  5898. * @public
  5899. * @param {stirng} textPosition
  5900. * @param {Object} rect {x, y, width, height}
  5901. * @param {number} distance
  5902. * @return {Object} {x, y, textAlign, textVerticalAlign}
  5903. */
  5904. function adjustTextPositionOnRect(textPosition, rect, distance) {
  5905. var dummyStyle = {
  5906. textPosition: textPosition,
  5907. textDistance: distance
  5908. };
  5909. return calculateTextPosition({}, dummyStyle, rect);
  5910. }
  5911. /**
  5912. * Show ellipsis if overflow.
  5913. *
  5914. * @public
  5915. * @param {string} text
  5916. * @param {string} containerWidth
  5917. * @param {string} font
  5918. * @param {number} [ellipsis='...']
  5919. * @param {Object} [options]
  5920. * @param {number} [options.maxIterations=3]
  5921. * @param {number} [options.minChar=0] If truncate result are less
  5922. * then minChar, ellipsis will not show, which is
  5923. * better for user hint in some cases.
  5924. * @param {number} [options.placeholder=''] When all truncated, use the placeholder.
  5925. * @return {string}
  5926. */
  5927. function truncateText(text, containerWidth, font, ellipsis, options) {
  5928. if (!containerWidth) {
  5929. return '';
  5930. }
  5931. var textLines = (text + '').split('\n');
  5932. options = prepareTruncateOptions(containerWidth, font, ellipsis, options); // FIXME
  5933. // It is not appropriate that every line has '...' when truncate multiple lines.
  5934. for (var i = 0, len = textLines.length; i < len; i++) {
  5935. textLines[i] = truncateSingleLine(textLines[i], options);
  5936. }
  5937. return textLines.join('\n');
  5938. }
  5939. function prepareTruncateOptions(containerWidth, font, ellipsis, options) {
  5940. options = extend({}, options);
  5941. options.font = font;
  5942. var ellipsis = retrieve2(ellipsis, '...');
  5943. options.maxIterations = retrieve2(options.maxIterations, 2);
  5944. var minChar = options.minChar = retrieve2(options.minChar, 0); // FIXME
  5945. // Other languages?
  5946. options.cnCharWidth = getWidth('国', font); // FIXME
  5947. // Consider proportional font?
  5948. var ascCharWidth = options.ascCharWidth = getWidth('a', font);
  5949. options.placeholder = retrieve2(options.placeholder, ''); // Example 1: minChar: 3, text: 'asdfzxcv', truncate result: 'asdf', but not: 'a...'.
  5950. // Example 2: minChar: 3, text: '维度', truncate result: '维', but not: '...'.
  5951. var contentWidth = containerWidth = Math.max(0, containerWidth - 1); // Reserve some gap.
  5952. for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {
  5953. contentWidth -= ascCharWidth;
  5954. }
  5955. var ellipsisWidth = getWidth(ellipsis, font);
  5956. if (ellipsisWidth > contentWidth) {
  5957. ellipsis = '';
  5958. ellipsisWidth = 0;
  5959. }
  5960. contentWidth = containerWidth - ellipsisWidth;
  5961. options.ellipsis = ellipsis;
  5962. options.ellipsisWidth = ellipsisWidth;
  5963. options.contentWidth = contentWidth;
  5964. options.containerWidth = containerWidth;
  5965. return options;
  5966. }
  5967. function truncateSingleLine(textLine, options) {
  5968. var containerWidth = options.containerWidth;
  5969. var font = options.font;
  5970. var contentWidth = options.contentWidth;
  5971. if (!containerWidth) {
  5972. return '';
  5973. }
  5974. var lineWidth = getWidth(textLine, font);
  5975. if (lineWidth <= containerWidth) {
  5976. return textLine;
  5977. }
  5978. for (var j = 0;; j++) {
  5979. if (lineWidth <= contentWidth || j >= options.maxIterations) {
  5980. textLine += options.ellipsis;
  5981. break;
  5982. }
  5983. var subLength = j === 0 ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth) : lineWidth > 0 ? Math.floor(textLine.length * contentWidth / lineWidth) : 0;
  5984. textLine = textLine.substr(0, subLength);
  5985. lineWidth = getWidth(textLine, font);
  5986. }
  5987. if (textLine === '') {
  5988. textLine = options.placeholder;
  5989. }
  5990. return textLine;
  5991. }
  5992. function estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {
  5993. var width = 0;
  5994. var i = 0;
  5995. for (var len = text.length; i < len && width < contentWidth; i++) {
  5996. var charCode = text.charCodeAt(i);
  5997. width += 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth;
  5998. }
  5999. return i;
  6000. }
  6001. /**
  6002. * @public
  6003. * @param {string} font
  6004. * @return {number} line height
  6005. */
  6006. function getLineHeight(font) {
  6007. // FIXME A rough approach.
  6008. return getWidth('国', font);
  6009. }
  6010. /**
  6011. * @public
  6012. * @param {string} text
  6013. * @param {string} font
  6014. * @return {Object} width
  6015. */
  6016. function measureText(text, font) {
  6017. return methods.measureText(text, font);
  6018. } // Avoid assign to an exported variable, for transforming to cjs.
  6019. methods.measureText = function (text, font) {
  6020. var ctx = getContext();
  6021. ctx.font = font || DEFAULT_FONT;
  6022. return ctx.measureText(text);
  6023. };
  6024. /**
  6025. * @public
  6026. * @param {string} text
  6027. * @param {string} font
  6028. * @param {Object} [truncate]
  6029. * @return {Object} block: {lineHeight, lines, height, outerHeight, canCacheByTextString}
  6030. * Notice: for performance, do not calculate outerWidth util needed.
  6031. * `canCacheByTextString` means the result `lines` is only determined by the input `text`.
  6032. * Thus we can simply comparing the `input` text to determin whether the result changed,
  6033. * without travel the result `lines`.
  6034. */
  6035. function parsePlainText(text, font, padding, textLineHeight, truncate) {
  6036. text != null && (text += '');
  6037. var lineHeight = retrieve2(textLineHeight, getLineHeight(font));
  6038. var lines = text ? text.split('\n') : [];
  6039. var height = lines.length * lineHeight;
  6040. var outerHeight = height;
  6041. var canCacheByTextString = true;
  6042. if (padding) {
  6043. outerHeight += padding[0] + padding[2];
  6044. }
  6045. if (text && truncate) {
  6046. canCacheByTextString = false;
  6047. var truncOuterHeight = truncate.outerHeight;
  6048. var truncOuterWidth = truncate.outerWidth;
  6049. if (truncOuterHeight != null && outerHeight > truncOuterHeight) {
  6050. text = '';
  6051. lines = [];
  6052. } else if (truncOuterWidth != null) {
  6053. var options = prepareTruncateOptions(truncOuterWidth - (padding ? padding[1] + padding[3] : 0), font, truncate.ellipsis, {
  6054. minChar: truncate.minChar,
  6055. placeholder: truncate.placeholder
  6056. }); // FIXME
  6057. // It is not appropriate that every line has '...' when truncate multiple lines.
  6058. for (var i = 0, len = lines.length; i < len; i++) {
  6059. lines[i] = truncateSingleLine(lines[i], options);
  6060. }
  6061. }
  6062. }
  6063. return {
  6064. lines: lines,
  6065. height: height,
  6066. outerHeight: outerHeight,
  6067. lineHeight: lineHeight,
  6068. canCacheByTextString: canCacheByTextString
  6069. };
  6070. }
  6071. /**
  6072. * For example: 'some text {a|some text}other text{b|some text}xxx{c|}xxx'
  6073. * Also consider 'bbbb{a|xxx\nzzz}xxxx\naaaa'.
  6074. *
  6075. * @public
  6076. * @param {string} text
  6077. * @param {Object} style
  6078. * @return {Object} block
  6079. * {
  6080. * width,
  6081. * height,
  6082. * lines: [{
  6083. * lineHeight,
  6084. * width,
  6085. * tokens: [[{
  6086. * styleName,
  6087. * text,
  6088. * width, // include textPadding
  6089. * height, // include textPadding
  6090. * textWidth, // pure text width
  6091. * textHeight, // pure text height
  6092. * lineHeihgt,
  6093. * font,
  6094. * textAlign,
  6095. * textVerticalAlign
  6096. * }], [...], ...]
  6097. * }, ...]
  6098. * }
  6099. * If styleName is undefined, it is plain text.
  6100. */
  6101. function parseRichText(text, style) {
  6102. var contentBlock = {
  6103. lines: [],
  6104. width: 0,
  6105. height: 0
  6106. };
  6107. text != null && (text += '');
  6108. if (!text) {
  6109. return contentBlock;
  6110. }
  6111. var lastIndex = STYLE_REG.lastIndex = 0;
  6112. var result;
  6113. while ((result = STYLE_REG.exec(text)) != null) {
  6114. var matchedIndex = result.index;
  6115. if (matchedIndex > lastIndex) {
  6116. pushTokens(contentBlock, text.substring(lastIndex, matchedIndex));
  6117. }
  6118. pushTokens(contentBlock, result[2], result[1]);
  6119. lastIndex = STYLE_REG.lastIndex;
  6120. }
  6121. if (lastIndex < text.length) {
  6122. pushTokens(contentBlock, text.substring(lastIndex, text.length));
  6123. }
  6124. var lines = contentBlock.lines;
  6125. var contentHeight = 0;
  6126. var contentWidth = 0; // For `textWidth: 100%`
  6127. var pendingList = [];
  6128. var stlPadding = style.textPadding;
  6129. var truncate = style.truncate;
  6130. var truncateWidth = truncate && truncate.outerWidth;
  6131. var truncateHeight = truncate && truncate.outerHeight;
  6132. if (stlPadding) {
  6133. truncateWidth != null && (truncateWidth -= stlPadding[1] + stlPadding[3]);
  6134. truncateHeight != null && (truncateHeight -= stlPadding[0] + stlPadding[2]);
  6135. } // Calculate layout info of tokens.
  6136. for (var i = 0; i < lines.length; i++) {
  6137. var line = lines[i];
  6138. var lineHeight = 0;
  6139. var lineWidth = 0;
  6140. for (var j = 0; j < line.tokens.length; j++) {
  6141. var token = line.tokens[j];
  6142. var tokenStyle = token.styleName && style.rich[token.styleName] || {}; // textPadding should not inherit from style.
  6143. var textPadding = token.textPadding = tokenStyle.textPadding; // textFont has been asigned to font by `normalizeStyle`.
  6144. var font = token.font = tokenStyle.font || style.font; // textHeight can be used when textVerticalAlign is specified in token.
  6145. var tokenHeight = token.textHeight = retrieve2( // textHeight should not be inherited, consider it can be specified
  6146. // as box height of the block.
  6147. tokenStyle.textHeight, getLineHeight(font));
  6148. textPadding && (tokenHeight += textPadding[0] + textPadding[2]);
  6149. token.height = tokenHeight;
  6150. token.lineHeight = retrieve3(tokenStyle.textLineHeight, style.textLineHeight, tokenHeight);
  6151. token.textAlign = tokenStyle && tokenStyle.textAlign || style.textAlign;
  6152. token.textVerticalAlign = tokenStyle && tokenStyle.textVerticalAlign || 'middle';
  6153. if (truncateHeight != null && contentHeight + token.lineHeight > truncateHeight) {
  6154. return {
  6155. lines: [],
  6156. width: 0,
  6157. height: 0
  6158. };
  6159. }
  6160. token.textWidth = getWidth(token.text, font);
  6161. var tokenWidth = tokenStyle.textWidth;
  6162. var tokenWidthNotSpecified = tokenWidth == null || tokenWidth === 'auto'; // Percent width, can be `100%`, can be used in drawing separate
  6163. // line when box width is needed to be auto.
  6164. if (typeof tokenWidth === 'string' && tokenWidth.charAt(tokenWidth.length - 1) === '%') {
  6165. token.percentWidth = tokenWidth;
  6166. pendingList.push(token);
  6167. tokenWidth = 0; // Do not truncate in this case, because there is no user case
  6168. // and it is too complicated.
  6169. } else {
  6170. if (tokenWidthNotSpecified) {
  6171. tokenWidth = token.textWidth; // FIXME: If image is not loaded and textWidth is not specified, calling
  6172. // `getBoundingRect()` will not get correct result.
  6173. var textBackgroundColor = tokenStyle.textBackgroundColor;
  6174. var bgImg = textBackgroundColor && textBackgroundColor.image; // Use cases:
  6175. // (1) If image is not loaded, it will be loaded at render phase and call
  6176. // `dirty()` and `textBackgroundColor.image` will be replaced with the loaded
  6177. // image, and then the right size will be calculated here at the next tick.
  6178. // See `graphic/helper/text.js`.
  6179. // (2) If image loaded, and `textBackgroundColor.image` is image src string,
  6180. // use `imageHelper.findExistImage` to find cached image.
  6181. // `imageHelper.findExistImage` will always be called here before
  6182. // `imageHelper.createOrUpdateImage` in `graphic/helper/text.js#renderRichText`
  6183. // which ensures that image will not be rendered before correct size calcualted.
  6184. if (bgImg) {
  6185. bgImg = imageHelper.findExistImage(bgImg);
  6186. if (imageHelper.isImageReady(bgImg)) {
  6187. tokenWidth = Math.max(tokenWidth, bgImg.width * tokenHeight / bgImg.height);
  6188. }
  6189. }
  6190. }
  6191. var paddingW = textPadding ? textPadding[1] + textPadding[3] : 0;
  6192. tokenWidth += paddingW;
  6193. var remianTruncWidth = truncateWidth != null ? truncateWidth - lineWidth : null;
  6194. if (remianTruncWidth != null && remianTruncWidth < tokenWidth) {
  6195. if (!tokenWidthNotSpecified || remianTruncWidth < paddingW) {
  6196. token.text = '';
  6197. token.textWidth = tokenWidth = 0;
  6198. } else {
  6199. token.text = truncateText(token.text, remianTruncWidth - paddingW, font, truncate.ellipsis, {
  6200. minChar: truncate.minChar
  6201. });
  6202. token.textWidth = getWidth(token.text, font);
  6203. tokenWidth = token.textWidth + paddingW;
  6204. }
  6205. }
  6206. }
  6207. lineWidth += token.width = tokenWidth;
  6208. tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));
  6209. }
  6210. line.width = lineWidth;
  6211. line.lineHeight = lineHeight;
  6212. contentHeight += lineHeight;
  6213. contentWidth = Math.max(contentWidth, lineWidth);
  6214. }
  6215. contentBlock.outerWidth = contentBlock.width = retrieve2(style.textWidth, contentWidth);
  6216. contentBlock.outerHeight = contentBlock.height = retrieve2(style.textHeight, contentHeight);
  6217. if (stlPadding) {
  6218. contentBlock.outerWidth += stlPadding[1] + stlPadding[3];
  6219. contentBlock.outerHeight += stlPadding[0] + stlPadding[2];
  6220. }
  6221. for (var i = 0; i < pendingList.length; i++) {
  6222. var token = pendingList[i];
  6223. var percentWidth = token.percentWidth; // Should not base on outerWidth, because token can not be placed out of padding.
  6224. token.width = parseInt(percentWidth, 10) / 100 * contentWidth;
  6225. }
  6226. return contentBlock;
  6227. }
  6228. function pushTokens(block, str, styleName) {
  6229. var isEmptyStr = str === '';
  6230. var strs = str.split('\n');
  6231. var lines = block.lines;
  6232. for (var i = 0; i < strs.length; i++) {
  6233. var text = strs[i];
  6234. var token = {
  6235. styleName: styleName,
  6236. text: text,
  6237. isLineHolder: !text && !isEmptyStr
  6238. }; // The first token should be appended to the last line.
  6239. if (!i) {
  6240. var tokens = (lines[lines.length - 1] || (lines[0] = {
  6241. tokens: []
  6242. })).tokens; // Consider cases:
  6243. // (1) ''.split('\n') => ['', '\n', ''], the '' at the first item
  6244. // (which is a placeholder) should be replaced by new token.
  6245. // (2) A image backage, where token likes {a|}.
  6246. // (3) A redundant '' will affect textAlign in line.
  6247. // (4) tokens with the same tplName should not be merged, because
  6248. // they should be displayed in different box (with border and padding).
  6249. var tokensLen = tokens.length;
  6250. tokensLen === 1 && tokens[0].isLineHolder ? tokens[0] = token : // Consider text is '', only insert when it is the "lineHolder" or
  6251. // "emptyStr". Otherwise a redundant '' will affect textAlign in line.
  6252. (text || !tokensLen || isEmptyStr) && tokens.push(token);
  6253. } // Other tokens always start a new line.
  6254. else {
  6255. // If there is '', insert it as a placeholder.
  6256. lines.push({
  6257. tokens: [token]
  6258. });
  6259. }
  6260. }
  6261. }
  6262. function makeFont(style) {
  6263. // FIXME in node-canvas fontWeight is before fontStyle
  6264. // Use `fontSize` `fontFamily` to check whether font properties are defined.
  6265. var font = (style.fontSize || style.fontFamily) && [style.fontStyle, style.fontWeight, (style.fontSize || 12) + 'px', // If font properties are defined, `fontFamily` should not be ignored.
  6266. style.fontFamily || 'sans-serif'].join(' ');
  6267. return font && trim(font) || style.textFont || style.font;
  6268. }
  6269. exports.DEFAULT_FONT = DEFAULT_FONT;
  6270. exports.$override = $override;
  6271. exports.getWidth = getWidth;
  6272. exports.getBoundingRect = getBoundingRect;
  6273. exports.adjustTextX = adjustTextX;
  6274. exports.adjustTextY = adjustTextY;
  6275. exports.calculateTextPosition = calculateTextPosition;
  6276. exports.adjustTextPositionOnRect = adjustTextPositionOnRect;
  6277. exports.truncateText = truncateText;
  6278. exports.getLineHeight = getLineHeight;
  6279. exports.measureText = measureText;
  6280. exports.parsePlainText = parsePlainText;
  6281. exports.parseRichText = parseRichText;
  6282. exports.makeFont = makeFont;
  6283. /***/ }),
  6284. /***/ "./node_modules/zrender/lib/contain/util.js":
  6285. /*!**************************************************!*\
  6286. !*** ./node_modules/zrender/lib/contain/util.js ***!
  6287. \**************************************************/
  6288. /*! no static exports found */
  6289. /***/ (function(module, exports) {
  6290. var PI2 = Math.PI * 2;
  6291. function normalizeRadian(angle) {
  6292. angle %= PI2;
  6293. if (angle < 0) {
  6294. angle += PI2;
  6295. }
  6296. return angle;
  6297. }
  6298. exports.normalizeRadian = normalizeRadian;
  6299. /***/ }),
  6300. /***/ "./node_modules/zrender/lib/contain/windingLine.js":
  6301. /*!*********************************************************!*\
  6302. !*** ./node_modules/zrender/lib/contain/windingLine.js ***!
  6303. \*********************************************************/
  6304. /*! no static exports found */
  6305. /***/ (function(module, exports) {
  6306. function windingLine(x0, y0, x1, y1, x, y) {
  6307. if (y > y0 && y > y1 || y < y0 && y < y1) {
  6308. return 0;
  6309. } // Ignore horizontal line
  6310. if (y1 === y0) {
  6311. return 0;
  6312. }
  6313. var dir = y1 < y0 ? 1 : -1;
  6314. var t = (y - y0) / (y1 - y0); // Avoid winding error when intersection point is the connect point of two line of polygon
  6315. if (t === 1 || t === 0) {
  6316. dir = y1 < y0 ? 0.5 : -0.5;
  6317. }
  6318. var x_ = t * (x1 - x0) + x0; // If (x, y) on the line, considered as "contain".
  6319. return x_ === x ? Infinity : x_ > x ? dir : 0;
  6320. }
  6321. module.exports = windingLine;
  6322. /***/ }),
  6323. /***/ "./node_modules/zrender/lib/container/Group.js":
  6324. /*!*****************************************************!*\
  6325. !*** ./node_modules/zrender/lib/container/Group.js ***!
  6326. \*****************************************************/
  6327. /*! no static exports found */
  6328. /***/ (function(module, exports, __webpack_require__) {
  6329. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  6330. var Element = __webpack_require__(/*! ../Element */ "./node_modules/zrender/lib/Element.js");
  6331. var BoundingRect = __webpack_require__(/*! ../core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  6332. /**
  6333. * Group是一个容器,可以插入子节点,Group的变换也会被应用到子节点上
  6334. * @module zrender/graphic/Group
  6335. * @example
  6336. * var Group = require('zrender/container/Group');
  6337. * var Circle = require('zrender/graphic/shape/Circle');
  6338. * var g = new Group();
  6339. * g.position[0] = 100;
  6340. * g.position[1] = 100;
  6341. * g.add(new Circle({
  6342. * style: {
  6343. * x: 100,
  6344. * y: 100,
  6345. * r: 20,
  6346. * }
  6347. * }));
  6348. * zr.add(g);
  6349. */
  6350. /**
  6351. * @alias module:zrender/graphic/Group
  6352. * @constructor
  6353. * @extends module:zrender/mixin/Transformable
  6354. * @extends module:zrender/mixin/Eventful
  6355. */
  6356. var Group = function (opts) {
  6357. opts = opts || {};
  6358. Element.call(this, opts);
  6359. for (var key in opts) {
  6360. if (opts.hasOwnProperty(key)) {
  6361. this[key] = opts[key];
  6362. }
  6363. }
  6364. this._children = [];
  6365. this.__storage = null;
  6366. this.__dirty = true;
  6367. };
  6368. Group.prototype = {
  6369. constructor: Group,
  6370. isGroup: true,
  6371. /**
  6372. * @type {string}
  6373. */
  6374. type: 'group',
  6375. /**
  6376. * 所有子孙元素是否响应鼠标事件
  6377. * @name module:/zrender/container/Group#silent
  6378. * @type {boolean}
  6379. * @default false
  6380. */
  6381. silent: false,
  6382. /**
  6383. * @return {Array.<module:zrender/Element>}
  6384. */
  6385. children: function () {
  6386. return this._children.slice();
  6387. },
  6388. /**
  6389. * 获取指定 index 的儿子节点
  6390. * @param {number} idx
  6391. * @return {module:zrender/Element}
  6392. */
  6393. childAt: function (idx) {
  6394. return this._children[idx];
  6395. },
  6396. /**
  6397. * 获取指定名字的儿子节点
  6398. * @param {string} name
  6399. * @return {module:zrender/Element}
  6400. */
  6401. childOfName: function (name) {
  6402. var children = this._children;
  6403. for (var i = 0; i < children.length; i++) {
  6404. if (children[i].name === name) {
  6405. return children[i];
  6406. }
  6407. }
  6408. },
  6409. /**
  6410. * @return {number}
  6411. */
  6412. childCount: function () {
  6413. return this._children.length;
  6414. },
  6415. /**
  6416. * 添加子节点到最后
  6417. * @param {module:zrender/Element} child
  6418. */
  6419. add: function (child) {
  6420. if (child && child !== this && child.parent !== this) {
  6421. this._children.push(child);
  6422. this._doAdd(child);
  6423. }
  6424. return this;
  6425. },
  6426. /**
  6427. * 添加子节点在 nextSibling 之前
  6428. * @param {module:zrender/Element} child
  6429. * @param {module:zrender/Element} nextSibling
  6430. */
  6431. addBefore: function (child, nextSibling) {
  6432. if (child && child !== this && child.parent !== this && nextSibling && nextSibling.parent === this) {
  6433. var children = this._children;
  6434. var idx = children.indexOf(nextSibling);
  6435. if (idx >= 0) {
  6436. children.splice(idx, 0, child);
  6437. this._doAdd(child);
  6438. }
  6439. }
  6440. return this;
  6441. },
  6442. _doAdd: function (child) {
  6443. if (child.parent) {
  6444. child.parent.remove(child);
  6445. }
  6446. child.parent = this;
  6447. var storage = this.__storage;
  6448. var zr = this.__zr;
  6449. if (storage && storage !== child.__storage) {
  6450. storage.addToStorage(child);
  6451. if (child instanceof Group) {
  6452. child.addChildrenToStorage(storage);
  6453. }
  6454. }
  6455. zr && zr.refresh();
  6456. },
  6457. /**
  6458. * 移除子节点
  6459. * @param {module:zrender/Element} child
  6460. */
  6461. remove: function (child) {
  6462. var zr = this.__zr;
  6463. var storage = this.__storage;
  6464. var children = this._children;
  6465. var idx = zrUtil.indexOf(children, child);
  6466. if (idx < 0) {
  6467. return this;
  6468. }
  6469. children.splice(idx, 1);
  6470. child.parent = null;
  6471. if (storage) {
  6472. storage.delFromStorage(child);
  6473. if (child instanceof Group) {
  6474. child.delChildrenFromStorage(storage);
  6475. }
  6476. }
  6477. zr && zr.refresh();
  6478. return this;
  6479. },
  6480. /**
  6481. * 移除所有子节点
  6482. */
  6483. removeAll: function () {
  6484. var children = this._children;
  6485. var storage = this.__storage;
  6486. var child;
  6487. var i;
  6488. for (i = 0; i < children.length; i++) {
  6489. child = children[i];
  6490. if (storage) {
  6491. storage.delFromStorage(child);
  6492. if (child instanceof Group) {
  6493. child.delChildrenFromStorage(storage);
  6494. }
  6495. }
  6496. child.parent = null;
  6497. }
  6498. children.length = 0;
  6499. return this;
  6500. },
  6501. /**
  6502. * 遍历所有子节点
  6503. * @param {Function} cb
  6504. * @param {} context
  6505. */
  6506. eachChild: function (cb, context) {
  6507. var children = this._children;
  6508. for (var i = 0; i < children.length; i++) {
  6509. var child = children[i];
  6510. cb.call(context, child, i);
  6511. }
  6512. return this;
  6513. },
  6514. /**
  6515. * 深度优先遍历所有子孙节点
  6516. * @param {Function} cb
  6517. * @param {} context
  6518. */
  6519. traverse: function (cb, context) {
  6520. for (var i = 0; i < this._children.length; i++) {
  6521. var child = this._children[i];
  6522. cb.call(context, child);
  6523. if (child.type === 'group') {
  6524. child.traverse(cb, context);
  6525. }
  6526. }
  6527. return this;
  6528. },
  6529. addChildrenToStorage: function (storage) {
  6530. for (var i = 0; i < this._children.length; i++) {
  6531. var child = this._children[i];
  6532. storage.addToStorage(child);
  6533. if (child instanceof Group) {
  6534. child.addChildrenToStorage(storage);
  6535. }
  6536. }
  6537. },
  6538. delChildrenFromStorage: function (storage) {
  6539. for (var i = 0; i < this._children.length; i++) {
  6540. var child = this._children[i];
  6541. storage.delFromStorage(child);
  6542. if (child instanceof Group) {
  6543. child.delChildrenFromStorage(storage);
  6544. }
  6545. }
  6546. },
  6547. dirty: function () {
  6548. this.__dirty = true;
  6549. this.__zr && this.__zr.refresh();
  6550. return this;
  6551. },
  6552. /**
  6553. * @return {module:zrender/core/BoundingRect}
  6554. */
  6555. getBoundingRect: function (includeChildren) {
  6556. // TODO Caching
  6557. var rect = null;
  6558. var tmpRect = new BoundingRect(0, 0, 0, 0);
  6559. var children = includeChildren || this._children;
  6560. var tmpMat = [];
  6561. for (var i = 0; i < children.length; i++) {
  6562. var child = children[i];
  6563. if (child.ignore || child.invisible) {
  6564. continue;
  6565. }
  6566. var childRect = child.getBoundingRect();
  6567. var transform = child.getLocalTransform(tmpMat); // TODO
  6568. // The boundingRect cacluated by transforming original
  6569. // rect may be bigger than the actual bundingRect when rotation
  6570. // is used. (Consider a circle rotated aginst its center, where
  6571. // the actual boundingRect should be the same as that not be
  6572. // rotated.) But we can not find better approach to calculate
  6573. // actual boundingRect yet, considering performance.
  6574. if (transform) {
  6575. tmpRect.copy(childRect);
  6576. tmpRect.applyTransform(transform);
  6577. rect = rect || tmpRect.clone();
  6578. rect.union(tmpRect);
  6579. } else {
  6580. rect = rect || childRect.clone();
  6581. rect.union(childRect);
  6582. }
  6583. }
  6584. return rect || tmpRect;
  6585. }
  6586. };
  6587. zrUtil.inherits(Group, Element);
  6588. var _default = Group;
  6589. module.exports = _default;
  6590. /***/ }),
  6591. /***/ "./node_modules/zrender/lib/core/BoundingRect.js":
  6592. /*!*******************************************************!*\
  6593. !*** ./node_modules/zrender/lib/core/BoundingRect.js ***!
  6594. \*******************************************************/
  6595. /*! no static exports found */
  6596. /***/ (function(module, exports, __webpack_require__) {
  6597. var vec2 = __webpack_require__(/*! ./vector */ "./node_modules/zrender/lib/core/vector.js");
  6598. var matrix = __webpack_require__(/*! ./matrix */ "./node_modules/zrender/lib/core/matrix.js");
  6599. /**
  6600. * @module echarts/core/BoundingRect
  6601. */
  6602. var v2ApplyTransform = vec2.applyTransform;
  6603. var mathMin = Math.min;
  6604. var mathMax = Math.max;
  6605. /**
  6606. * @alias module:echarts/core/BoundingRect
  6607. */
  6608. function BoundingRect(x, y, width, height) {
  6609. if (width < 0) {
  6610. x = x + width;
  6611. width = -width;
  6612. }
  6613. if (height < 0) {
  6614. y = y + height;
  6615. height = -height;
  6616. }
  6617. /**
  6618. * @type {number}
  6619. */
  6620. this.x = x;
  6621. /**
  6622. * @type {number}
  6623. */
  6624. this.y = y;
  6625. /**
  6626. * @type {number}
  6627. */
  6628. this.width = width;
  6629. /**
  6630. * @type {number}
  6631. */
  6632. this.height = height;
  6633. }
  6634. BoundingRect.prototype = {
  6635. constructor: BoundingRect,
  6636. /**
  6637. * @param {module:echarts/core/BoundingRect} other
  6638. */
  6639. union: function (other) {
  6640. var x = mathMin(other.x, this.x);
  6641. var y = mathMin(other.y, this.y);
  6642. this.width = mathMax(other.x + other.width, this.x + this.width) - x;
  6643. this.height = mathMax(other.y + other.height, this.y + this.height) - y;
  6644. this.x = x;
  6645. this.y = y;
  6646. },
  6647. /**
  6648. * @param {Array.<number>} m
  6649. * @methods
  6650. */
  6651. applyTransform: function () {
  6652. var lt = [];
  6653. var rb = [];
  6654. var lb = [];
  6655. var rt = [];
  6656. return function (m) {
  6657. // In case usage like this
  6658. // el.getBoundingRect().applyTransform(el.transform)
  6659. // And element has no transform
  6660. if (!m) {
  6661. return;
  6662. }
  6663. lt[0] = lb[0] = this.x;
  6664. lt[1] = rt[1] = this.y;
  6665. rb[0] = rt[0] = this.x + this.width;
  6666. rb[1] = lb[1] = this.y + this.height;
  6667. v2ApplyTransform(lt, lt, m);
  6668. v2ApplyTransform(rb, rb, m);
  6669. v2ApplyTransform(lb, lb, m);
  6670. v2ApplyTransform(rt, rt, m);
  6671. this.x = mathMin(lt[0], rb[0], lb[0], rt[0]);
  6672. this.y = mathMin(lt[1], rb[1], lb[1], rt[1]);
  6673. var maxX = mathMax(lt[0], rb[0], lb[0], rt[0]);
  6674. var maxY = mathMax(lt[1], rb[1], lb[1], rt[1]);
  6675. this.width = maxX - this.x;
  6676. this.height = maxY - this.y;
  6677. };
  6678. }(),
  6679. /**
  6680. * Calculate matrix of transforming from self to target rect
  6681. * @param {module:zrender/core/BoundingRect} b
  6682. * @return {Array.<number>}
  6683. */
  6684. calculateTransform: function (b) {
  6685. var a = this;
  6686. var sx = b.width / a.width;
  6687. var sy = b.height / a.height;
  6688. var m = matrix.create(); // 矩阵右乘
  6689. matrix.translate(m, m, [-a.x, -a.y]);
  6690. matrix.scale(m, m, [sx, sy]);
  6691. matrix.translate(m, m, [b.x, b.y]);
  6692. return m;
  6693. },
  6694. /**
  6695. * @param {(module:echarts/core/BoundingRect|Object)} b
  6696. * @return {boolean}
  6697. */
  6698. intersect: function (b) {
  6699. if (!b) {
  6700. return false;
  6701. }
  6702. if (!(b instanceof BoundingRect)) {
  6703. // Normalize negative width/height.
  6704. b = BoundingRect.create(b);
  6705. }
  6706. var a = this;
  6707. var ax0 = a.x;
  6708. var ax1 = a.x + a.width;
  6709. var ay0 = a.y;
  6710. var ay1 = a.y + a.height;
  6711. var bx0 = b.x;
  6712. var bx1 = b.x + b.width;
  6713. var by0 = b.y;
  6714. var by1 = b.y + b.height;
  6715. return !(ax1 < bx0 || bx1 < ax0 || ay1 < by0 || by1 < ay0);
  6716. },
  6717. contain: function (x, y) {
  6718. var rect = this;
  6719. return x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
  6720. },
  6721. /**
  6722. * @return {module:echarts/core/BoundingRect}
  6723. */
  6724. clone: function () {
  6725. return new BoundingRect(this.x, this.y, this.width, this.height);
  6726. },
  6727. /**
  6728. * Copy from another rect
  6729. */
  6730. copy: function (other) {
  6731. this.x = other.x;
  6732. this.y = other.y;
  6733. this.width = other.width;
  6734. this.height = other.height;
  6735. },
  6736. plain: function () {
  6737. return {
  6738. x: this.x,
  6739. y: this.y,
  6740. width: this.width,
  6741. height: this.height
  6742. };
  6743. }
  6744. };
  6745. /**
  6746. * @param {Object|module:zrender/core/BoundingRect} rect
  6747. * @param {number} rect.x
  6748. * @param {number} rect.y
  6749. * @param {number} rect.width
  6750. * @param {number} rect.height
  6751. * @return {module:zrender/core/BoundingRect}
  6752. */
  6753. BoundingRect.create = function (rect) {
  6754. return new BoundingRect(rect.x, rect.y, rect.width, rect.height);
  6755. };
  6756. var _default = BoundingRect;
  6757. module.exports = _default;
  6758. /***/ }),
  6759. /***/ "./node_modules/zrender/lib/core/LRU.js":
  6760. /*!**********************************************!*\
  6761. !*** ./node_modules/zrender/lib/core/LRU.js ***!
  6762. \**********************************************/
  6763. /*! no static exports found */
  6764. /***/ (function(module, exports) {
  6765. // Simple LRU cache use doubly linked list
  6766. // @module zrender/core/LRU
  6767. /**
  6768. * Simple double linked list. Compared with array, it has O(1) remove operation.
  6769. * @constructor
  6770. */
  6771. var LinkedList = function () {
  6772. /**
  6773. * @type {module:zrender/core/LRU~Entry}
  6774. */
  6775. this.head = null;
  6776. /**
  6777. * @type {module:zrender/core/LRU~Entry}
  6778. */
  6779. this.tail = null;
  6780. this._len = 0;
  6781. };
  6782. var linkedListProto = LinkedList.prototype;
  6783. /**
  6784. * Insert a new value at the tail
  6785. * @param {} val
  6786. * @return {module:zrender/core/LRU~Entry}
  6787. */
  6788. linkedListProto.insert = function (val) {
  6789. var entry = new Entry(val);
  6790. this.insertEntry(entry);
  6791. return entry;
  6792. };
  6793. /**
  6794. * Insert an entry at the tail
  6795. * @param {module:zrender/core/LRU~Entry} entry
  6796. */
  6797. linkedListProto.insertEntry = function (entry) {
  6798. if (!this.head) {
  6799. this.head = this.tail = entry;
  6800. } else {
  6801. this.tail.next = entry;
  6802. entry.prev = this.tail;
  6803. entry.next = null;
  6804. this.tail = entry;
  6805. }
  6806. this._len++;
  6807. };
  6808. /**
  6809. * Remove entry.
  6810. * @param {module:zrender/core/LRU~Entry} entry
  6811. */
  6812. linkedListProto.remove = function (entry) {
  6813. var prev = entry.prev;
  6814. var next = entry.next;
  6815. if (prev) {
  6816. prev.next = next;
  6817. } else {
  6818. // Is head
  6819. this.head = next;
  6820. }
  6821. if (next) {
  6822. next.prev = prev;
  6823. } else {
  6824. // Is tail
  6825. this.tail = prev;
  6826. }
  6827. entry.next = entry.prev = null;
  6828. this._len--;
  6829. };
  6830. /**
  6831. * @return {number}
  6832. */
  6833. linkedListProto.len = function () {
  6834. return this._len;
  6835. };
  6836. /**
  6837. * Clear list
  6838. */
  6839. linkedListProto.clear = function () {
  6840. this.head = this.tail = null;
  6841. this._len = 0;
  6842. };
  6843. /**
  6844. * @constructor
  6845. * @param {} val
  6846. */
  6847. var Entry = function (val) {
  6848. /**
  6849. * @type {}
  6850. */
  6851. this.value = val;
  6852. /**
  6853. * @type {module:zrender/core/LRU~Entry}
  6854. */
  6855. this.next;
  6856. /**
  6857. * @type {module:zrender/core/LRU~Entry}
  6858. */
  6859. this.prev;
  6860. };
  6861. /**
  6862. * LRU Cache
  6863. * @constructor
  6864. * @alias module:zrender/core/LRU
  6865. */
  6866. var LRU = function (maxSize) {
  6867. this._list = new LinkedList();
  6868. this._map = {};
  6869. this._maxSize = maxSize || 10;
  6870. this._lastRemovedEntry = null;
  6871. };
  6872. var LRUProto = LRU.prototype;
  6873. /**
  6874. * @param {string} key
  6875. * @param {} value
  6876. * @return {} Removed value
  6877. */
  6878. LRUProto.put = function (key, value) {
  6879. var list = this._list;
  6880. var map = this._map;
  6881. var removed = null;
  6882. if (map[key] == null) {
  6883. var len = list.len(); // Reuse last removed entry
  6884. var entry = this._lastRemovedEntry;
  6885. if (len >= this._maxSize && len > 0) {
  6886. // Remove the least recently used
  6887. var leastUsedEntry = list.head;
  6888. list.remove(leastUsedEntry);
  6889. delete map[leastUsedEntry.key];
  6890. removed = leastUsedEntry.value;
  6891. this._lastRemovedEntry = leastUsedEntry;
  6892. }
  6893. if (entry) {
  6894. entry.value = value;
  6895. } else {
  6896. entry = new Entry(value);
  6897. }
  6898. entry.key = key;
  6899. list.insertEntry(entry);
  6900. map[key] = entry;
  6901. }
  6902. return removed;
  6903. };
  6904. /**
  6905. * @param {string} key
  6906. * @return {}
  6907. */
  6908. LRUProto.get = function (key) {
  6909. var entry = this._map[key];
  6910. var list = this._list;
  6911. if (entry != null) {
  6912. // Put the latest used entry in the tail
  6913. if (entry !== list.tail) {
  6914. list.remove(entry);
  6915. list.insertEntry(entry);
  6916. }
  6917. return entry.value;
  6918. }
  6919. };
  6920. /**
  6921. * Clear the cache
  6922. */
  6923. LRUProto.clear = function () {
  6924. this._list.clear();
  6925. this._map = {};
  6926. };
  6927. var _default = LRU;
  6928. module.exports = _default;
  6929. /***/ }),
  6930. /***/ "./node_modules/zrender/lib/core/PathProxy.js":
  6931. /*!****************************************************!*\
  6932. !*** ./node_modules/zrender/lib/core/PathProxy.js ***!
  6933. \****************************************************/
  6934. /*! no static exports found */
  6935. /***/ (function(module, exports, __webpack_require__) {
  6936. var curve = __webpack_require__(/*! ./curve */ "./node_modules/zrender/lib/core/curve.js");
  6937. var vec2 = __webpack_require__(/*! ./vector */ "./node_modules/zrender/lib/core/vector.js");
  6938. var bbox = __webpack_require__(/*! ./bbox */ "./node_modules/zrender/lib/core/bbox.js");
  6939. var BoundingRect = __webpack_require__(/*! ./BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  6940. var _config = __webpack_require__(/*! ../config */ "./node_modules/zrender/lib/config.js");
  6941. var dpr = _config.devicePixelRatio;
  6942. /**
  6943. * Path 代理,可以在`buildPath`中用于替代`ctx`, 会保存每个path操作的命令到pathCommands属性中
  6944. * 可以用于 isInsidePath 判断以及获取boundingRect
  6945. *
  6946. * @module zrender/core/PathProxy
  6947. * @author Yi Shen (http://www.github.com/pissang)
  6948. */
  6949. // TODO getTotalLength, getPointAtLength
  6950. /* global Float32Array */
  6951. var CMD = {
  6952. M: 1,
  6953. L: 2,
  6954. C: 3,
  6955. Q: 4,
  6956. A: 5,
  6957. Z: 6,
  6958. // Rect
  6959. R: 7
  6960. }; // var CMD_MEM_SIZE = {
  6961. // M: 3,
  6962. // L: 3,
  6963. // C: 7,
  6964. // Q: 5,
  6965. // A: 9,
  6966. // R: 5,
  6967. // Z: 1
  6968. // };
  6969. var min = [];
  6970. var max = [];
  6971. var min2 = [];
  6972. var max2 = [];
  6973. var mathMin = Math.min;
  6974. var mathMax = Math.max;
  6975. var mathCos = Math.cos;
  6976. var mathSin = Math.sin;
  6977. var mathSqrt = Math.sqrt;
  6978. var mathAbs = Math.abs;
  6979. var hasTypedArray = typeof Float32Array !== 'undefined';
  6980. /**
  6981. * @alias module:zrender/core/PathProxy
  6982. * @constructor
  6983. */
  6984. var PathProxy = function (notSaveData) {
  6985. this._saveData = !(notSaveData || false);
  6986. if (this._saveData) {
  6987. /**
  6988. * Path data. Stored as flat array
  6989. * @type {Array.<Object>}
  6990. */
  6991. this.data = [];
  6992. }
  6993. this._ctx = null;
  6994. };
  6995. /**
  6996. * 快速计算Path包围盒(并不是最小包围盒)
  6997. * @return {Object}
  6998. */
  6999. PathProxy.prototype = {
  7000. constructor: PathProxy,
  7001. _xi: 0,
  7002. _yi: 0,
  7003. _x0: 0,
  7004. _y0: 0,
  7005. // Unit x, Unit y. Provide for avoiding drawing that too short line segment
  7006. _ux: 0,
  7007. _uy: 0,
  7008. _len: 0,
  7009. _lineDash: null,
  7010. _dashOffset: 0,
  7011. _dashIdx: 0,
  7012. _dashSum: 0,
  7013. /**
  7014. * @readOnly
  7015. */
  7016. setScale: function (sx, sy, segmentIgnoreThreshold) {
  7017. // Compat. Previously there is no segmentIgnoreThreshold.
  7018. segmentIgnoreThreshold = segmentIgnoreThreshold || 0;
  7019. this._ux = mathAbs(segmentIgnoreThreshold / dpr / sx) || 0;
  7020. this._uy = mathAbs(segmentIgnoreThreshold / dpr / sy) || 0;
  7021. },
  7022. getContext: function () {
  7023. return this._ctx;
  7024. },
  7025. /**
  7026. * @param {CanvasRenderingContext2D} ctx
  7027. * @return {module:zrender/core/PathProxy}
  7028. */
  7029. beginPath: function (ctx) {
  7030. this._ctx = ctx;
  7031. ctx && ctx.beginPath();
  7032. ctx && (this.dpr = ctx.dpr); // Reset
  7033. if (this._saveData) {
  7034. this._len = 0;
  7035. }
  7036. if (this._lineDash) {
  7037. this._lineDash = null;
  7038. this._dashOffset = 0;
  7039. }
  7040. return this;
  7041. },
  7042. /**
  7043. * @param {number} x
  7044. * @param {number} y
  7045. * @return {module:zrender/core/PathProxy}
  7046. */
  7047. moveTo: function (x, y) {
  7048. this.addData(CMD.M, x, y);
  7049. this._ctx && this._ctx.moveTo(x, y); // x0, y0, xi, yi 是记录在 _dashedXXXXTo 方法中使用
  7050. // xi, yi 记录当前点, x0, y0 在 closePath 的时候回到起始点。
  7051. // 有可能在 beginPath 之后直接调用 lineTo,这时候 x0, y0 需要
  7052. // 在 lineTo 方法中记录,这里先不考虑这种情况,dashed line 也只在 IE10- 中不支持
  7053. this._x0 = x;
  7054. this._y0 = y;
  7055. this._xi = x;
  7056. this._yi = y;
  7057. return this;
  7058. },
  7059. /**
  7060. * @param {number} x
  7061. * @param {number} y
  7062. * @return {module:zrender/core/PathProxy}
  7063. */
  7064. lineTo: function (x, y) {
  7065. var exceedUnit = mathAbs(x - this._xi) > this._ux || mathAbs(y - this._yi) > this._uy // Force draw the first segment
  7066. || this._len < 5;
  7067. this.addData(CMD.L, x, y);
  7068. if (this._ctx && exceedUnit) {
  7069. this._needsDash() ? this._dashedLineTo(x, y) : this._ctx.lineTo(x, y);
  7070. }
  7071. if (exceedUnit) {
  7072. this._xi = x;
  7073. this._yi = y;
  7074. }
  7075. return this;
  7076. },
  7077. /**
  7078. * @param {number} x1
  7079. * @param {number} y1
  7080. * @param {number} x2
  7081. * @param {number} y2
  7082. * @param {number} x3
  7083. * @param {number} y3
  7084. * @return {module:zrender/core/PathProxy}
  7085. */
  7086. bezierCurveTo: function (x1, y1, x2, y2, x3, y3) {
  7087. this.addData(CMD.C, x1, y1, x2, y2, x3, y3);
  7088. if (this._ctx) {
  7089. this._needsDash() ? this._dashedBezierTo(x1, y1, x2, y2, x3, y3) : this._ctx.bezierCurveTo(x1, y1, x2, y2, x3, y3);
  7090. }
  7091. this._xi = x3;
  7092. this._yi = y3;
  7093. return this;
  7094. },
  7095. /**
  7096. * @param {number} x1
  7097. * @param {number} y1
  7098. * @param {number} x2
  7099. * @param {number} y2
  7100. * @return {module:zrender/core/PathProxy}
  7101. */
  7102. quadraticCurveTo: function (x1, y1, x2, y2) {
  7103. this.addData(CMD.Q, x1, y1, x2, y2);
  7104. if (this._ctx) {
  7105. this._needsDash() ? this._dashedQuadraticTo(x1, y1, x2, y2) : this._ctx.quadraticCurveTo(x1, y1, x2, y2);
  7106. }
  7107. this._xi = x2;
  7108. this._yi = y2;
  7109. return this;
  7110. },
  7111. /**
  7112. * @param {number} cx
  7113. * @param {number} cy
  7114. * @param {number} r
  7115. * @param {number} startAngle
  7116. * @param {number} endAngle
  7117. * @param {boolean} anticlockwise
  7118. * @return {module:zrender/core/PathProxy}
  7119. */
  7120. arc: function (cx, cy, r, startAngle, endAngle, anticlockwise) {
  7121. this.addData(CMD.A, cx, cy, r, r, startAngle, endAngle - startAngle, 0, anticlockwise ? 0 : 1);
  7122. this._ctx && this._ctx.arc(cx, cy, r, startAngle, endAngle, anticlockwise);
  7123. this._xi = mathCos(endAngle) * r + cx;
  7124. this._yi = mathSin(endAngle) * r + cy;
  7125. return this;
  7126. },
  7127. // TODO
  7128. arcTo: function (x1, y1, x2, y2, radius) {
  7129. if (this._ctx) {
  7130. this._ctx.arcTo(x1, y1, x2, y2, radius);
  7131. }
  7132. return this;
  7133. },
  7134. // TODO
  7135. rect: function (x, y, w, h) {
  7136. this._ctx && this._ctx.rect(x, y, w, h);
  7137. this.addData(CMD.R, x, y, w, h);
  7138. return this;
  7139. },
  7140. /**
  7141. * @return {module:zrender/core/PathProxy}
  7142. */
  7143. closePath: function () {
  7144. this.addData(CMD.Z);
  7145. var ctx = this._ctx;
  7146. var x0 = this._x0;
  7147. var y0 = this._y0;
  7148. if (ctx) {
  7149. this._needsDash() && this._dashedLineTo(x0, y0);
  7150. ctx.closePath();
  7151. }
  7152. this._xi = x0;
  7153. this._yi = y0;
  7154. return this;
  7155. },
  7156. /**
  7157. * Context 从外部传入,因为有可能是 rebuildPath 完之后再 fill。
  7158. * stroke 同样
  7159. * @param {CanvasRenderingContext2D} ctx
  7160. * @return {module:zrender/core/PathProxy}
  7161. */
  7162. fill: function (ctx) {
  7163. ctx && ctx.fill();
  7164. this.toStatic();
  7165. },
  7166. /**
  7167. * @param {CanvasRenderingContext2D} ctx
  7168. * @return {module:zrender/core/PathProxy}
  7169. */
  7170. stroke: function (ctx) {
  7171. ctx && ctx.stroke();
  7172. this.toStatic();
  7173. },
  7174. /**
  7175. * 必须在其它绘制命令前调用
  7176. * Must be invoked before all other path drawing methods
  7177. * @return {module:zrender/core/PathProxy}
  7178. */
  7179. setLineDash: function (lineDash) {
  7180. if (lineDash instanceof Array) {
  7181. this._lineDash = lineDash;
  7182. this._dashIdx = 0;
  7183. var lineDashSum = 0;
  7184. for (var i = 0; i < lineDash.length; i++) {
  7185. lineDashSum += lineDash[i];
  7186. }
  7187. this._dashSum = lineDashSum;
  7188. }
  7189. return this;
  7190. },
  7191. /**
  7192. * 必须在其它绘制命令前调用
  7193. * Must be invoked before all other path drawing methods
  7194. * @return {module:zrender/core/PathProxy}
  7195. */
  7196. setLineDashOffset: function (offset) {
  7197. this._dashOffset = offset;
  7198. return this;
  7199. },
  7200. /**
  7201. *
  7202. * @return {boolean}
  7203. */
  7204. len: function () {
  7205. return this._len;
  7206. },
  7207. /**
  7208. * 直接设置 Path 数据
  7209. */
  7210. setData: function (data) {
  7211. var len = data.length;
  7212. if (!(this.data && this.data.length === len) && hasTypedArray) {
  7213. this.data = new Float32Array(len);
  7214. }
  7215. for (var i = 0; i < len; i++) {
  7216. this.data[i] = data[i];
  7217. }
  7218. this._len = len;
  7219. },
  7220. /**
  7221. * 添加子路径
  7222. * @param {module:zrender/core/PathProxy|Array.<module:zrender/core/PathProxy>} path
  7223. */
  7224. appendPath: function (path) {
  7225. if (!(path instanceof Array)) {
  7226. path = [path];
  7227. }
  7228. var len = path.length;
  7229. var appendSize = 0;
  7230. var offset = this._len;
  7231. for (var i = 0; i < len; i++) {
  7232. appendSize += path[i].len();
  7233. }
  7234. if (hasTypedArray && this.data instanceof Float32Array) {
  7235. this.data = new Float32Array(offset + appendSize);
  7236. }
  7237. for (var i = 0; i < len; i++) {
  7238. var appendPathData = path[i].data;
  7239. for (var k = 0; k < appendPathData.length; k++) {
  7240. this.data[offset++] = appendPathData[k];
  7241. }
  7242. }
  7243. this._len = offset;
  7244. },
  7245. /**
  7246. * 填充 Path 数据。
  7247. * 尽量复用而不申明新的数组。大部分图形重绘的指令数据长度都是不变的。
  7248. */
  7249. addData: function (cmd) {
  7250. if (!this._saveData) {
  7251. return;
  7252. }
  7253. var data = this.data;
  7254. if (this._len + arguments.length > data.length) {
  7255. // 因为之前的数组已经转换成静态的 Float32Array
  7256. // 所以不够用时需要扩展一个新的动态数组
  7257. this._expandData();
  7258. data = this.data;
  7259. }
  7260. for (var i = 0; i < arguments.length; i++) {
  7261. data[this._len++] = arguments[i];
  7262. }
  7263. this._prevCmd = cmd;
  7264. },
  7265. _expandData: function () {
  7266. // Only if data is Float32Array
  7267. if (!(this.data instanceof Array)) {
  7268. var newData = [];
  7269. for (var i = 0; i < this._len; i++) {
  7270. newData[i] = this.data[i];
  7271. }
  7272. this.data = newData;
  7273. }
  7274. },
  7275. /**
  7276. * If needs js implemented dashed line
  7277. * @return {boolean}
  7278. * @private
  7279. */
  7280. _needsDash: function () {
  7281. return this._lineDash;
  7282. },
  7283. _dashedLineTo: function (x1, y1) {
  7284. var dashSum = this._dashSum;
  7285. var offset = this._dashOffset;
  7286. var lineDash = this._lineDash;
  7287. var ctx = this._ctx;
  7288. var x0 = this._xi;
  7289. var y0 = this._yi;
  7290. var dx = x1 - x0;
  7291. var dy = y1 - y0;
  7292. var dist = mathSqrt(dx * dx + dy * dy);
  7293. var x = x0;
  7294. var y = y0;
  7295. var dash;
  7296. var nDash = lineDash.length;
  7297. var idx;
  7298. dx /= dist;
  7299. dy /= dist;
  7300. if (offset < 0) {
  7301. // Convert to positive offset
  7302. offset = dashSum + offset;
  7303. }
  7304. offset %= dashSum;
  7305. x -= offset * dx;
  7306. y -= offset * dy;
  7307. while (dx > 0 && x <= x1 || dx < 0 && x >= x1 || dx === 0 && (dy > 0 && y <= y1 || dy < 0 && y >= y1)) {
  7308. idx = this._dashIdx;
  7309. dash = lineDash[idx];
  7310. x += dx * dash;
  7311. y += dy * dash;
  7312. this._dashIdx = (idx + 1) % nDash; // Skip positive offset
  7313. if (dx > 0 && x < x0 || dx < 0 && x > x0 || dy > 0 && y < y0 || dy < 0 && y > y0) {
  7314. continue;
  7315. }
  7316. ctx[idx % 2 ? 'moveTo' : 'lineTo'](dx >= 0 ? mathMin(x, x1) : mathMax(x, x1), dy >= 0 ? mathMin(y, y1) : mathMax(y, y1));
  7317. } // Offset for next lineTo
  7318. dx = x - x1;
  7319. dy = y - y1;
  7320. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  7321. },
  7322. // Not accurate dashed line to
  7323. _dashedBezierTo: function (x1, y1, x2, y2, x3, y3) {
  7324. var dashSum = this._dashSum;
  7325. var offset = this._dashOffset;
  7326. var lineDash = this._lineDash;
  7327. var ctx = this._ctx;
  7328. var x0 = this._xi;
  7329. var y0 = this._yi;
  7330. var t;
  7331. var dx;
  7332. var dy;
  7333. var cubicAt = curve.cubicAt;
  7334. var bezierLen = 0;
  7335. var idx = this._dashIdx;
  7336. var nDash = lineDash.length;
  7337. var x;
  7338. var y;
  7339. var tmpLen = 0;
  7340. if (offset < 0) {
  7341. // Convert to positive offset
  7342. offset = dashSum + offset;
  7343. }
  7344. offset %= dashSum; // Bezier approx length
  7345. for (t = 0; t < 1; t += 0.1) {
  7346. dx = cubicAt(x0, x1, x2, x3, t + 0.1) - cubicAt(x0, x1, x2, x3, t);
  7347. dy = cubicAt(y0, y1, y2, y3, t + 0.1) - cubicAt(y0, y1, y2, y3, t);
  7348. bezierLen += mathSqrt(dx * dx + dy * dy);
  7349. } // Find idx after add offset
  7350. for (; idx < nDash; idx++) {
  7351. tmpLen += lineDash[idx];
  7352. if (tmpLen > offset) {
  7353. break;
  7354. }
  7355. }
  7356. t = (tmpLen - offset) / bezierLen;
  7357. while (t <= 1) {
  7358. x = cubicAt(x0, x1, x2, x3, t);
  7359. y = cubicAt(y0, y1, y2, y3, t); // Use line to approximate dashed bezier
  7360. // Bad result if dash is long
  7361. idx % 2 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
  7362. t += lineDash[idx] / bezierLen;
  7363. idx = (idx + 1) % nDash;
  7364. } // Finish the last segment and calculate the new offset
  7365. idx % 2 !== 0 && ctx.lineTo(x3, y3);
  7366. dx = x3 - x;
  7367. dy = y3 - y;
  7368. this._dashOffset = -mathSqrt(dx * dx + dy * dy);
  7369. },
  7370. _dashedQuadraticTo: function (x1, y1, x2, y2) {
  7371. // Convert quadratic to cubic using degree elevation
  7372. var x3 = x2;
  7373. var y3 = y2;
  7374. x2 = (x2 + 2 * x1) / 3;
  7375. y2 = (y2 + 2 * y1) / 3;
  7376. x1 = (this._xi + 2 * x1) / 3;
  7377. y1 = (this._yi + 2 * y1) / 3;
  7378. this._dashedBezierTo(x1, y1, x2, y2, x3, y3);
  7379. },
  7380. /**
  7381. * 转成静态的 Float32Array 减少堆内存占用
  7382. * Convert dynamic array to static Float32Array
  7383. */
  7384. toStatic: function () {
  7385. var data = this.data;
  7386. if (data instanceof Array) {
  7387. data.length = this._len;
  7388. if (hasTypedArray) {
  7389. this.data = new Float32Array(data);
  7390. }
  7391. }
  7392. },
  7393. /**
  7394. * @return {module:zrender/core/BoundingRect}
  7395. */
  7396. getBoundingRect: function () {
  7397. min[0] = min[1] = min2[0] = min2[1] = Number.MAX_VALUE;
  7398. max[0] = max[1] = max2[0] = max2[1] = -Number.MAX_VALUE;
  7399. var data = this.data;
  7400. var xi = 0;
  7401. var yi = 0;
  7402. var x0 = 0;
  7403. var y0 = 0;
  7404. for (var i = 0; i < data.length;) {
  7405. var cmd = data[i++];
  7406. if (i === 1) {
  7407. // 如果第一个命令是 L, C, Q
  7408. // 则 previous point 同绘制命令的第一个 point
  7409. //
  7410. // 第一个命令为 Arc 的情况下会在后面特殊处理
  7411. xi = data[i];
  7412. yi = data[i + 1];
  7413. x0 = xi;
  7414. y0 = yi;
  7415. }
  7416. switch (cmd) {
  7417. case CMD.M:
  7418. // moveTo 命令重新创建一个新的 subpath, 并且更新新的起点
  7419. // 在 closePath 的时候使用
  7420. x0 = data[i++];
  7421. y0 = data[i++];
  7422. xi = x0;
  7423. yi = y0;
  7424. min2[0] = x0;
  7425. min2[1] = y0;
  7426. max2[0] = x0;
  7427. max2[1] = y0;
  7428. break;
  7429. case CMD.L:
  7430. bbox.fromLine(xi, yi, data[i], data[i + 1], min2, max2);
  7431. xi = data[i++];
  7432. yi = data[i++];
  7433. break;
  7434. case CMD.C:
  7435. bbox.fromCubic(xi, yi, data[i++], data[i++], data[i++], data[i++], data[i], data[i + 1], min2, max2);
  7436. xi = data[i++];
  7437. yi = data[i++];
  7438. break;
  7439. case CMD.Q:
  7440. bbox.fromQuadratic(xi, yi, data[i++], data[i++], data[i], data[i + 1], min2, max2);
  7441. xi = data[i++];
  7442. yi = data[i++];
  7443. break;
  7444. case CMD.A:
  7445. // TODO Arc 判断的开销比较大
  7446. var cx = data[i++];
  7447. var cy = data[i++];
  7448. var rx = data[i++];
  7449. var ry = data[i++];
  7450. var startAngle = data[i++];
  7451. var endAngle = data[i++] + startAngle; // TODO Arc 旋转
  7452. i += 1;
  7453. var anticlockwise = 1 - data[i++];
  7454. if (i === 1) {
  7455. // 直接使用 arc 命令
  7456. // 第一个命令起点还未定义
  7457. x0 = mathCos(startAngle) * rx + cx;
  7458. y0 = mathSin(startAngle) * ry + cy;
  7459. }
  7460. bbox.fromArc(cx, cy, rx, ry, startAngle, endAngle, anticlockwise, min2, max2);
  7461. xi = mathCos(endAngle) * rx + cx;
  7462. yi = mathSin(endAngle) * ry + cy;
  7463. break;
  7464. case CMD.R:
  7465. x0 = xi = data[i++];
  7466. y0 = yi = data[i++];
  7467. var width = data[i++];
  7468. var height = data[i++]; // Use fromLine
  7469. bbox.fromLine(x0, y0, x0 + width, y0 + height, min2, max2);
  7470. break;
  7471. case CMD.Z:
  7472. xi = x0;
  7473. yi = y0;
  7474. break;
  7475. } // Union
  7476. vec2.min(min, min, min2);
  7477. vec2.max(max, max, max2);
  7478. } // No data
  7479. if (i === 0) {
  7480. min[0] = min[1] = max[0] = max[1] = 0;
  7481. }
  7482. return new BoundingRect(min[0], min[1], max[0] - min[0], max[1] - min[1]);
  7483. },
  7484. /**
  7485. * Rebuild path from current data
  7486. * Rebuild path will not consider javascript implemented line dash.
  7487. * @param {CanvasRenderingContext2D} ctx
  7488. */
  7489. rebuildPath: function (ctx) {
  7490. var d = this.data;
  7491. var x0;
  7492. var y0;
  7493. var xi;
  7494. var yi;
  7495. var x;
  7496. var y;
  7497. var ux = this._ux;
  7498. var uy = this._uy;
  7499. var len = this._len;
  7500. for (var i = 0; i < len;) {
  7501. var cmd = d[i++];
  7502. if (i === 1) {
  7503. // 如果第一个命令是 L, C, Q
  7504. // 则 previous point 同绘制命令的第一个 point
  7505. //
  7506. // 第一个命令为 Arc 的情况下会在后面特殊处理
  7507. xi = d[i];
  7508. yi = d[i + 1];
  7509. x0 = xi;
  7510. y0 = yi;
  7511. }
  7512. switch (cmd) {
  7513. case CMD.M:
  7514. x0 = xi = d[i++];
  7515. y0 = yi = d[i++];
  7516. ctx.moveTo(xi, yi);
  7517. break;
  7518. case CMD.L:
  7519. x = d[i++];
  7520. y = d[i++]; // Not draw too small seg between
  7521. if (mathAbs(x - xi) > ux || mathAbs(y - yi) > uy || i === len - 1) {
  7522. ctx.lineTo(x, y);
  7523. xi = x;
  7524. yi = y;
  7525. }
  7526. break;
  7527. case CMD.C:
  7528. ctx.bezierCurveTo(d[i++], d[i++], d[i++], d[i++], d[i++], d[i++]);
  7529. xi = d[i - 2];
  7530. yi = d[i - 1];
  7531. break;
  7532. case CMD.Q:
  7533. ctx.quadraticCurveTo(d[i++], d[i++], d[i++], d[i++]);
  7534. xi = d[i - 2];
  7535. yi = d[i - 1];
  7536. break;
  7537. case CMD.A:
  7538. var cx = d[i++];
  7539. var cy = d[i++];
  7540. var rx = d[i++];
  7541. var ry = d[i++];
  7542. var theta = d[i++];
  7543. var dTheta = d[i++];
  7544. var psi = d[i++];
  7545. var fs = d[i++];
  7546. var r = rx > ry ? rx : ry;
  7547. var scaleX = rx > ry ? 1 : rx / ry;
  7548. var scaleY = rx > ry ? ry / rx : 1;
  7549. var isEllipse = Math.abs(rx - ry) > 1e-3;
  7550. var endAngle = theta + dTheta;
  7551. if (isEllipse) {
  7552. ctx.translate(cx, cy);
  7553. ctx.rotate(psi);
  7554. ctx.scale(scaleX, scaleY);
  7555. ctx.arc(0, 0, r, theta, endAngle, 1 - fs);
  7556. ctx.scale(1 / scaleX, 1 / scaleY);
  7557. ctx.rotate(-psi);
  7558. ctx.translate(-cx, -cy);
  7559. } else {
  7560. ctx.arc(cx, cy, r, theta, endAngle, 1 - fs);
  7561. }
  7562. if (i === 1) {
  7563. // 直接使用 arc 命令
  7564. // 第一个命令起点还未定义
  7565. x0 = mathCos(theta) * rx + cx;
  7566. y0 = mathSin(theta) * ry + cy;
  7567. }
  7568. xi = mathCos(endAngle) * rx + cx;
  7569. yi = mathSin(endAngle) * ry + cy;
  7570. break;
  7571. case CMD.R:
  7572. x0 = xi = d[i];
  7573. y0 = yi = d[i + 1];
  7574. ctx.rect(d[i++], d[i++], d[i++], d[i++]);
  7575. break;
  7576. case CMD.Z:
  7577. ctx.closePath();
  7578. xi = x0;
  7579. yi = y0;
  7580. }
  7581. }
  7582. }
  7583. };
  7584. PathProxy.CMD = CMD;
  7585. var _default = PathProxy;
  7586. module.exports = _default;
  7587. /***/ }),
  7588. /***/ "./node_modules/zrender/lib/core/bbox.js":
  7589. /*!***********************************************!*\
  7590. !*** ./node_modules/zrender/lib/core/bbox.js ***!
  7591. \***********************************************/
  7592. /*! no static exports found */
  7593. /***/ (function(module, exports, __webpack_require__) {
  7594. var vec2 = __webpack_require__(/*! ./vector */ "./node_modules/zrender/lib/core/vector.js");
  7595. var curve = __webpack_require__(/*! ./curve */ "./node_modules/zrender/lib/core/curve.js");
  7596. /**
  7597. * @author Yi Shen(https://github.com/pissang)
  7598. */
  7599. var mathMin = Math.min;
  7600. var mathMax = Math.max;
  7601. var mathSin = Math.sin;
  7602. var mathCos = Math.cos;
  7603. var PI2 = Math.PI * 2;
  7604. var start = vec2.create();
  7605. var end = vec2.create();
  7606. var extremity = vec2.create();
  7607. /**
  7608. * 从顶点数组中计算出最小包围盒,写入`min`和`max`中
  7609. * @module zrender/core/bbox
  7610. * @param {Array<Object>} points 顶点数组
  7611. * @param {number} min
  7612. * @param {number} max
  7613. */
  7614. function fromPoints(points, min, max) {
  7615. if (points.length === 0) {
  7616. return;
  7617. }
  7618. var p = points[0];
  7619. var left = p[0];
  7620. var right = p[0];
  7621. var top = p[1];
  7622. var bottom = p[1];
  7623. var i;
  7624. for (i = 1; i < points.length; i++) {
  7625. p = points[i];
  7626. left = mathMin(left, p[0]);
  7627. right = mathMax(right, p[0]);
  7628. top = mathMin(top, p[1]);
  7629. bottom = mathMax(bottom, p[1]);
  7630. }
  7631. min[0] = left;
  7632. min[1] = top;
  7633. max[0] = right;
  7634. max[1] = bottom;
  7635. }
  7636. /**
  7637. * @memberOf module:zrender/core/bbox
  7638. * @param {number} x0
  7639. * @param {number} y0
  7640. * @param {number} x1
  7641. * @param {number} y1
  7642. * @param {Array.<number>} min
  7643. * @param {Array.<number>} max
  7644. */
  7645. function fromLine(x0, y0, x1, y1, min, max) {
  7646. min[0] = mathMin(x0, x1);
  7647. min[1] = mathMin(y0, y1);
  7648. max[0] = mathMax(x0, x1);
  7649. max[1] = mathMax(y0, y1);
  7650. }
  7651. var xDim = [];
  7652. var yDim = [];
  7653. /**
  7654. * 从三阶贝塞尔曲线(p0, p1, p2, p3)中计算出最小包围盒,写入`min`和`max`中
  7655. * @memberOf module:zrender/core/bbox
  7656. * @param {number} x0
  7657. * @param {number} y0
  7658. * @param {number} x1
  7659. * @param {number} y1
  7660. * @param {number} x2
  7661. * @param {number} y2
  7662. * @param {number} x3
  7663. * @param {number} y3
  7664. * @param {Array.<number>} min
  7665. * @param {Array.<number>} max
  7666. */
  7667. function fromCubic(x0, y0, x1, y1, x2, y2, x3, y3, min, max) {
  7668. var cubicExtrema = curve.cubicExtrema;
  7669. var cubicAt = curve.cubicAt;
  7670. var i;
  7671. var n = cubicExtrema(x0, x1, x2, x3, xDim);
  7672. min[0] = Infinity;
  7673. min[1] = Infinity;
  7674. max[0] = -Infinity;
  7675. max[1] = -Infinity;
  7676. for (i = 0; i < n; i++) {
  7677. var x = cubicAt(x0, x1, x2, x3, xDim[i]);
  7678. min[0] = mathMin(x, min[0]);
  7679. max[0] = mathMax(x, max[0]);
  7680. }
  7681. n = cubicExtrema(y0, y1, y2, y3, yDim);
  7682. for (i = 0; i < n; i++) {
  7683. var y = cubicAt(y0, y1, y2, y3, yDim[i]);
  7684. min[1] = mathMin(y, min[1]);
  7685. max[1] = mathMax(y, max[1]);
  7686. }
  7687. min[0] = mathMin(x0, min[0]);
  7688. max[0] = mathMax(x0, max[0]);
  7689. min[0] = mathMin(x3, min[0]);
  7690. max[0] = mathMax(x3, max[0]);
  7691. min[1] = mathMin(y0, min[1]);
  7692. max[1] = mathMax(y0, max[1]);
  7693. min[1] = mathMin(y3, min[1]);
  7694. max[1] = mathMax(y3, max[1]);
  7695. }
  7696. /**
  7697. * 从二阶贝塞尔曲线(p0, p1, p2)中计算出最小包围盒,写入`min`和`max`中
  7698. * @memberOf module:zrender/core/bbox
  7699. * @param {number} x0
  7700. * @param {number} y0
  7701. * @param {number} x1
  7702. * @param {number} y1
  7703. * @param {number} x2
  7704. * @param {number} y2
  7705. * @param {Array.<number>} min
  7706. * @param {Array.<number>} max
  7707. */
  7708. function fromQuadratic(x0, y0, x1, y1, x2, y2, min, max) {
  7709. var quadraticExtremum = curve.quadraticExtremum;
  7710. var quadraticAt = curve.quadraticAt; // Find extremities, where derivative in x dim or y dim is zero
  7711. var tx = mathMax(mathMin(quadraticExtremum(x0, x1, x2), 1), 0);
  7712. var ty = mathMax(mathMin(quadraticExtremum(y0, y1, y2), 1), 0);
  7713. var x = quadraticAt(x0, x1, x2, tx);
  7714. var y = quadraticAt(y0, y1, y2, ty);
  7715. min[0] = mathMin(x0, x2, x);
  7716. min[1] = mathMin(y0, y2, y);
  7717. max[0] = mathMax(x0, x2, x);
  7718. max[1] = mathMax(y0, y2, y);
  7719. }
  7720. /**
  7721. * 从圆弧中计算出最小包围盒,写入`min`和`max`中
  7722. * @method
  7723. * @memberOf module:zrender/core/bbox
  7724. * @param {number} x
  7725. * @param {number} y
  7726. * @param {number} rx
  7727. * @param {number} ry
  7728. * @param {number} startAngle
  7729. * @param {number} endAngle
  7730. * @param {number} anticlockwise
  7731. * @param {Array.<number>} min
  7732. * @param {Array.<number>} max
  7733. */
  7734. function fromArc(x, y, rx, ry, startAngle, endAngle, anticlockwise, min, max) {
  7735. var vec2Min = vec2.min;
  7736. var vec2Max = vec2.max;
  7737. var diff = Math.abs(startAngle - endAngle);
  7738. if (diff % PI2 < 1e-4 && diff > 1e-4) {
  7739. // Is a circle
  7740. min[0] = x - rx;
  7741. min[1] = y - ry;
  7742. max[0] = x + rx;
  7743. max[1] = y + ry;
  7744. return;
  7745. }
  7746. start[0] = mathCos(startAngle) * rx + x;
  7747. start[1] = mathSin(startAngle) * ry + y;
  7748. end[0] = mathCos(endAngle) * rx + x;
  7749. end[1] = mathSin(endAngle) * ry + y;
  7750. vec2Min(min, start, end);
  7751. vec2Max(max, start, end); // Thresh to [0, Math.PI * 2]
  7752. startAngle = startAngle % PI2;
  7753. if (startAngle < 0) {
  7754. startAngle = startAngle + PI2;
  7755. }
  7756. endAngle = endAngle % PI2;
  7757. if (endAngle < 0) {
  7758. endAngle = endAngle + PI2;
  7759. }
  7760. if (startAngle > endAngle && !anticlockwise) {
  7761. endAngle += PI2;
  7762. } else if (startAngle < endAngle && anticlockwise) {
  7763. startAngle += PI2;
  7764. }
  7765. if (anticlockwise) {
  7766. var tmp = endAngle;
  7767. endAngle = startAngle;
  7768. startAngle = tmp;
  7769. } // var number = 0;
  7770. // var step = (anticlockwise ? -Math.PI : Math.PI) / 2;
  7771. for (var angle = 0; angle < endAngle; angle += Math.PI / 2) {
  7772. if (angle > startAngle) {
  7773. extremity[0] = mathCos(angle) * rx + x;
  7774. extremity[1] = mathSin(angle) * ry + y;
  7775. vec2Min(min, extremity, min);
  7776. vec2Max(max, extremity, max);
  7777. }
  7778. }
  7779. }
  7780. exports.fromPoints = fromPoints;
  7781. exports.fromLine = fromLine;
  7782. exports.fromCubic = fromCubic;
  7783. exports.fromQuadratic = fromQuadratic;
  7784. exports.fromArc = fromArc;
  7785. /***/ }),
  7786. /***/ "./node_modules/zrender/lib/core/curve.js":
  7787. /*!************************************************!*\
  7788. !*** ./node_modules/zrender/lib/core/curve.js ***!
  7789. \************************************************/
  7790. /*! no static exports found */
  7791. /***/ (function(module, exports, __webpack_require__) {
  7792. var _vector = __webpack_require__(/*! ./vector */ "./node_modules/zrender/lib/core/vector.js");
  7793. var v2Create = _vector.create;
  7794. var v2DistSquare = _vector.distSquare;
  7795. /**
  7796. * 曲线辅助模块
  7797. * @module zrender/core/curve
  7798. * @author pissang(https://www.github.com/pissang)
  7799. */
  7800. var mathPow = Math.pow;
  7801. var mathSqrt = Math.sqrt;
  7802. var EPSILON = 1e-8;
  7803. var EPSILON_NUMERIC = 1e-4;
  7804. var THREE_SQRT = mathSqrt(3);
  7805. var ONE_THIRD = 1 / 3; // 临时变量
  7806. var _v0 = v2Create();
  7807. var _v1 = v2Create();
  7808. var _v2 = v2Create();
  7809. function isAroundZero(val) {
  7810. return val > -EPSILON && val < EPSILON;
  7811. }
  7812. function isNotAroundZero(val) {
  7813. return val > EPSILON || val < -EPSILON;
  7814. }
  7815. /**
  7816. * 计算三次贝塞尔值
  7817. * @memberOf module:zrender/core/curve
  7818. * @param {number} p0
  7819. * @param {number} p1
  7820. * @param {number} p2
  7821. * @param {number} p3
  7822. * @param {number} t
  7823. * @return {number}
  7824. */
  7825. function cubicAt(p0, p1, p2, p3, t) {
  7826. var onet = 1 - t;
  7827. return onet * onet * (onet * p0 + 3 * t * p1) + t * t * (t * p3 + 3 * onet * p2);
  7828. }
  7829. /**
  7830. * 计算三次贝塞尔导数值
  7831. * @memberOf module:zrender/core/curve
  7832. * @param {number} p0
  7833. * @param {number} p1
  7834. * @param {number} p2
  7835. * @param {number} p3
  7836. * @param {number} t
  7837. * @return {number}
  7838. */
  7839. function cubicDerivativeAt(p0, p1, p2, p3, t) {
  7840. var onet = 1 - t;
  7841. return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
  7842. }
  7843. /**
  7844. * 计算三次贝塞尔方程根,使用盛金公式
  7845. * @memberOf module:zrender/core/curve
  7846. * @param {number} p0
  7847. * @param {number} p1
  7848. * @param {number} p2
  7849. * @param {number} p3
  7850. * @param {number} val
  7851. * @param {Array.<number>} roots
  7852. * @return {number} 有效根数目
  7853. */
  7854. function cubicRootAt(p0, p1, p2, p3, val, roots) {
  7855. // Evaluate roots of cubic functions
  7856. var a = p3 + 3 * (p1 - p2) - p0;
  7857. var b = 3 * (p2 - p1 * 2 + p0);
  7858. var c = 3 * (p1 - p0);
  7859. var d = p0 - val;
  7860. var A = b * b - 3 * a * c;
  7861. var B = b * c - 9 * a * d;
  7862. var C = c * c - 3 * b * d;
  7863. var n = 0;
  7864. if (isAroundZero(A) && isAroundZero(B)) {
  7865. if (isAroundZero(b)) {
  7866. roots[0] = 0;
  7867. } else {
  7868. var t1 = -c / b; //t1, t2, t3, b is not zero
  7869. if (t1 >= 0 && t1 <= 1) {
  7870. roots[n++] = t1;
  7871. }
  7872. }
  7873. } else {
  7874. var disc = B * B - 4 * A * C;
  7875. if (isAroundZero(disc)) {
  7876. var K = B / A;
  7877. var t1 = -b / a + K; // t1, a is not zero
  7878. var t2 = -K / 2; // t2, t3
  7879. if (t1 >= 0 && t1 <= 1) {
  7880. roots[n++] = t1;
  7881. }
  7882. if (t2 >= 0 && t2 <= 1) {
  7883. roots[n++] = t2;
  7884. }
  7885. } else if (disc > 0) {
  7886. var discSqrt = mathSqrt(disc);
  7887. var Y1 = A * b + 1.5 * a * (-B + discSqrt);
  7888. var Y2 = A * b + 1.5 * a * (-B - discSqrt);
  7889. if (Y1 < 0) {
  7890. Y1 = -mathPow(-Y1, ONE_THIRD);
  7891. } else {
  7892. Y1 = mathPow(Y1, ONE_THIRD);
  7893. }
  7894. if (Y2 < 0) {
  7895. Y2 = -mathPow(-Y2, ONE_THIRD);
  7896. } else {
  7897. Y2 = mathPow(Y2, ONE_THIRD);
  7898. }
  7899. var t1 = (-b - (Y1 + Y2)) / (3 * a);
  7900. if (t1 >= 0 && t1 <= 1) {
  7901. roots[n++] = t1;
  7902. }
  7903. } else {
  7904. var T = (2 * A * b - 3 * a * B) / (2 * mathSqrt(A * A * A));
  7905. var theta = Math.acos(T) / 3;
  7906. var ASqrt = mathSqrt(A);
  7907. var tmp = Math.cos(theta);
  7908. var t1 = (-b - 2 * ASqrt * tmp) / (3 * a);
  7909. var t2 = (-b + ASqrt * (tmp + THREE_SQRT * Math.sin(theta))) / (3 * a);
  7910. var t3 = (-b + ASqrt * (tmp - THREE_SQRT * Math.sin(theta))) / (3 * a);
  7911. if (t1 >= 0 && t1 <= 1) {
  7912. roots[n++] = t1;
  7913. }
  7914. if (t2 >= 0 && t2 <= 1) {
  7915. roots[n++] = t2;
  7916. }
  7917. if (t3 >= 0 && t3 <= 1) {
  7918. roots[n++] = t3;
  7919. }
  7920. }
  7921. }
  7922. return n;
  7923. }
  7924. /**
  7925. * 计算三次贝塞尔方程极限值的位置
  7926. * @memberOf module:zrender/core/curve
  7927. * @param {number} p0
  7928. * @param {number} p1
  7929. * @param {number} p2
  7930. * @param {number} p3
  7931. * @param {Array.<number>} extrema
  7932. * @return {number} 有效数目
  7933. */
  7934. function cubicExtrema(p0, p1, p2, p3, extrema) {
  7935. var b = 6 * p2 - 12 * p1 + 6 * p0;
  7936. var a = 9 * p1 + 3 * p3 - 3 * p0 - 9 * p2;
  7937. var c = 3 * p1 - 3 * p0;
  7938. var n = 0;
  7939. if (isAroundZero(a)) {
  7940. if (isNotAroundZero(b)) {
  7941. var t1 = -c / b;
  7942. if (t1 >= 0 && t1 <= 1) {
  7943. extrema[n++] = t1;
  7944. }
  7945. }
  7946. } else {
  7947. var disc = b * b - 4 * a * c;
  7948. if (isAroundZero(disc)) {
  7949. extrema[0] = -b / (2 * a);
  7950. } else if (disc > 0) {
  7951. var discSqrt = mathSqrt(disc);
  7952. var t1 = (-b + discSqrt) / (2 * a);
  7953. var t2 = (-b - discSqrt) / (2 * a);
  7954. if (t1 >= 0 && t1 <= 1) {
  7955. extrema[n++] = t1;
  7956. }
  7957. if (t2 >= 0 && t2 <= 1) {
  7958. extrema[n++] = t2;
  7959. }
  7960. }
  7961. }
  7962. return n;
  7963. }
  7964. /**
  7965. * 细分三次贝塞尔曲线
  7966. * @memberOf module:zrender/core/curve
  7967. * @param {number} p0
  7968. * @param {number} p1
  7969. * @param {number} p2
  7970. * @param {number} p3
  7971. * @param {number} t
  7972. * @param {Array.<number>} out
  7973. */
  7974. function cubicSubdivide(p0, p1, p2, p3, t, out) {
  7975. var p01 = (p1 - p0) * t + p0;
  7976. var p12 = (p2 - p1) * t + p1;
  7977. var p23 = (p3 - p2) * t + p2;
  7978. var p012 = (p12 - p01) * t + p01;
  7979. var p123 = (p23 - p12) * t + p12;
  7980. var p0123 = (p123 - p012) * t + p012; // Seg0
  7981. out[0] = p0;
  7982. out[1] = p01;
  7983. out[2] = p012;
  7984. out[3] = p0123; // Seg1
  7985. out[4] = p0123;
  7986. out[5] = p123;
  7987. out[6] = p23;
  7988. out[7] = p3;
  7989. }
  7990. /**
  7991. * 投射点到三次贝塞尔曲线上,返回投射距离。
  7992. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  7993. * @param {number} x0
  7994. * @param {number} y0
  7995. * @param {number} x1
  7996. * @param {number} y1
  7997. * @param {number} x2
  7998. * @param {number} y2
  7999. * @param {number} x3
  8000. * @param {number} y3
  8001. * @param {number} x
  8002. * @param {number} y
  8003. * @param {Array.<number>} [out] 投射点
  8004. * @return {number}
  8005. */
  8006. function cubicProjectPoint(x0, y0, x1, y1, x2, y2, x3, y3, x, y, out) {
  8007. // http://pomax.github.io/bezierinfo/#projections
  8008. var t;
  8009. var interval = 0.005;
  8010. var d = Infinity;
  8011. var prev;
  8012. var next;
  8013. var d1;
  8014. var d2;
  8015. _v0[0] = x;
  8016. _v0[1] = y; // 先粗略估计一下可能的最小距离的 t 值
  8017. // PENDING
  8018. for (var _t = 0; _t < 1; _t += 0.05) {
  8019. _v1[0] = cubicAt(x0, x1, x2, x3, _t);
  8020. _v1[1] = cubicAt(y0, y1, y2, y3, _t);
  8021. d1 = v2DistSquare(_v0, _v1);
  8022. if (d1 < d) {
  8023. t = _t;
  8024. d = d1;
  8025. }
  8026. }
  8027. d = Infinity; // At most 32 iteration
  8028. for (var i = 0; i < 32; i++) {
  8029. if (interval < EPSILON_NUMERIC) {
  8030. break;
  8031. }
  8032. prev = t - interval;
  8033. next = t + interval; // t - interval
  8034. _v1[0] = cubicAt(x0, x1, x2, x3, prev);
  8035. _v1[1] = cubicAt(y0, y1, y2, y3, prev);
  8036. d1 = v2DistSquare(_v1, _v0);
  8037. if (prev >= 0 && d1 < d) {
  8038. t = prev;
  8039. d = d1;
  8040. } else {
  8041. // t + interval
  8042. _v2[0] = cubicAt(x0, x1, x2, x3, next);
  8043. _v2[1] = cubicAt(y0, y1, y2, y3, next);
  8044. d2 = v2DistSquare(_v2, _v0);
  8045. if (next <= 1 && d2 < d) {
  8046. t = next;
  8047. d = d2;
  8048. } else {
  8049. interval *= 0.5;
  8050. }
  8051. }
  8052. } // t
  8053. if (out) {
  8054. out[0] = cubicAt(x0, x1, x2, x3, t);
  8055. out[1] = cubicAt(y0, y1, y2, y3, t);
  8056. } // console.log(interval, i);
  8057. return mathSqrt(d);
  8058. }
  8059. /**
  8060. * 计算二次方贝塞尔值
  8061. * @param {number} p0
  8062. * @param {number} p1
  8063. * @param {number} p2
  8064. * @param {number} t
  8065. * @return {number}
  8066. */
  8067. function quadraticAt(p0, p1, p2, t) {
  8068. var onet = 1 - t;
  8069. return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
  8070. }
  8071. /**
  8072. * 计算二次方贝塞尔导数值
  8073. * @param {number} p0
  8074. * @param {number} p1
  8075. * @param {number} p2
  8076. * @param {number} t
  8077. * @return {number}
  8078. */
  8079. function quadraticDerivativeAt(p0, p1, p2, t) {
  8080. return 2 * ((1 - t) * (p1 - p0) + t * (p2 - p1));
  8081. }
  8082. /**
  8083. * 计算二次方贝塞尔方程根
  8084. * @param {number} p0
  8085. * @param {number} p1
  8086. * @param {number} p2
  8087. * @param {number} t
  8088. * @param {Array.<number>} roots
  8089. * @return {number} 有效根数目
  8090. */
  8091. function quadraticRootAt(p0, p1, p2, val, roots) {
  8092. var a = p0 - 2 * p1 + p2;
  8093. var b = 2 * (p1 - p0);
  8094. var c = p0 - val;
  8095. var n = 0;
  8096. if (isAroundZero(a)) {
  8097. if (isNotAroundZero(b)) {
  8098. var t1 = -c / b;
  8099. if (t1 >= 0 && t1 <= 1) {
  8100. roots[n++] = t1;
  8101. }
  8102. }
  8103. } else {
  8104. var disc = b * b - 4 * a * c;
  8105. if (isAroundZero(disc)) {
  8106. var t1 = -b / (2 * a);
  8107. if (t1 >= 0 && t1 <= 1) {
  8108. roots[n++] = t1;
  8109. }
  8110. } else if (disc > 0) {
  8111. var discSqrt = mathSqrt(disc);
  8112. var t1 = (-b + discSqrt) / (2 * a);
  8113. var t2 = (-b - discSqrt) / (2 * a);
  8114. if (t1 >= 0 && t1 <= 1) {
  8115. roots[n++] = t1;
  8116. }
  8117. if (t2 >= 0 && t2 <= 1) {
  8118. roots[n++] = t2;
  8119. }
  8120. }
  8121. }
  8122. return n;
  8123. }
  8124. /**
  8125. * 计算二次贝塞尔方程极限值
  8126. * @memberOf module:zrender/core/curve
  8127. * @param {number} p0
  8128. * @param {number} p1
  8129. * @param {number} p2
  8130. * @return {number}
  8131. */
  8132. function quadraticExtremum(p0, p1, p2) {
  8133. var divider = p0 + p2 - 2 * p1;
  8134. if (divider === 0) {
  8135. // p1 is center of p0 and p2
  8136. return 0.5;
  8137. } else {
  8138. return (p0 - p1) / divider;
  8139. }
  8140. }
  8141. /**
  8142. * 细分二次贝塞尔曲线
  8143. * @memberOf module:zrender/core/curve
  8144. * @param {number} p0
  8145. * @param {number} p1
  8146. * @param {number} p2
  8147. * @param {number} t
  8148. * @param {Array.<number>} out
  8149. */
  8150. function quadraticSubdivide(p0, p1, p2, t, out) {
  8151. var p01 = (p1 - p0) * t + p0;
  8152. var p12 = (p2 - p1) * t + p1;
  8153. var p012 = (p12 - p01) * t + p01; // Seg0
  8154. out[0] = p0;
  8155. out[1] = p01;
  8156. out[2] = p012; // Seg1
  8157. out[3] = p012;
  8158. out[4] = p12;
  8159. out[5] = p2;
  8160. }
  8161. /**
  8162. * 投射点到二次贝塞尔曲线上,返回投射距离。
  8163. * 投射点有可能会有一个或者多个,这里只返回其中距离最短的一个。
  8164. * @param {number} x0
  8165. * @param {number} y0
  8166. * @param {number} x1
  8167. * @param {number} y1
  8168. * @param {number} x2
  8169. * @param {number} y2
  8170. * @param {number} x
  8171. * @param {number} y
  8172. * @param {Array.<number>} out 投射点
  8173. * @return {number}
  8174. */
  8175. function quadraticProjectPoint(x0, y0, x1, y1, x2, y2, x, y, out) {
  8176. // http://pomax.github.io/bezierinfo/#projections
  8177. var t;
  8178. var interval = 0.005;
  8179. var d = Infinity;
  8180. _v0[0] = x;
  8181. _v0[1] = y; // 先粗略估计一下可能的最小距离的 t 值
  8182. // PENDING
  8183. for (var _t = 0; _t < 1; _t += 0.05) {
  8184. _v1[0] = quadraticAt(x0, x1, x2, _t);
  8185. _v1[1] = quadraticAt(y0, y1, y2, _t);
  8186. var d1 = v2DistSquare(_v0, _v1);
  8187. if (d1 < d) {
  8188. t = _t;
  8189. d = d1;
  8190. }
  8191. }
  8192. d = Infinity; // At most 32 iteration
  8193. for (var i = 0; i < 32; i++) {
  8194. if (interval < EPSILON_NUMERIC) {
  8195. break;
  8196. }
  8197. var prev = t - interval;
  8198. var next = t + interval; // t - interval
  8199. _v1[0] = quadraticAt(x0, x1, x2, prev);
  8200. _v1[1] = quadraticAt(y0, y1, y2, prev);
  8201. var d1 = v2DistSquare(_v1, _v0);
  8202. if (prev >= 0 && d1 < d) {
  8203. t = prev;
  8204. d = d1;
  8205. } else {
  8206. // t + interval
  8207. _v2[0] = quadraticAt(x0, x1, x2, next);
  8208. _v2[1] = quadraticAt(y0, y1, y2, next);
  8209. var d2 = v2DistSquare(_v2, _v0);
  8210. if (next <= 1 && d2 < d) {
  8211. t = next;
  8212. d = d2;
  8213. } else {
  8214. interval *= 0.5;
  8215. }
  8216. }
  8217. } // t
  8218. if (out) {
  8219. out[0] = quadraticAt(x0, x1, x2, t);
  8220. out[1] = quadraticAt(y0, y1, y2, t);
  8221. } // console.log(interval, i);
  8222. return mathSqrt(d);
  8223. }
  8224. exports.cubicAt = cubicAt;
  8225. exports.cubicDerivativeAt = cubicDerivativeAt;
  8226. exports.cubicRootAt = cubicRootAt;
  8227. exports.cubicExtrema = cubicExtrema;
  8228. exports.cubicSubdivide = cubicSubdivide;
  8229. exports.cubicProjectPoint = cubicProjectPoint;
  8230. exports.quadraticAt = quadraticAt;
  8231. exports.quadraticDerivativeAt = quadraticDerivativeAt;
  8232. exports.quadraticRootAt = quadraticRootAt;
  8233. exports.quadraticExtremum = quadraticExtremum;
  8234. exports.quadraticSubdivide = quadraticSubdivide;
  8235. exports.quadraticProjectPoint = quadraticProjectPoint;
  8236. /***/ }),
  8237. /***/ "./node_modules/zrender/lib/core/env.js":
  8238. /*!**********************************************!*\
  8239. !*** ./node_modules/zrender/lib/core/env.js ***!
  8240. \**********************************************/
  8241. /*! no static exports found */
  8242. /***/ (function(module, exports) {
  8243. /**
  8244. * echarts设备环境识别
  8245. *
  8246. * @desc echarts基于Canvas,纯Javascript图表库,提供直观,生动,可交互,可个性化定制的数据统计图表。
  8247. * @author firede[firede@firede.us]
  8248. * @desc thanks zepto.
  8249. */
  8250. /* global wx */
  8251. var env = {};
  8252. if (typeof wx === 'object' && typeof wx.getSystemInfoSync === 'function') {
  8253. // In Weixin Application
  8254. env = {
  8255. browser: {},
  8256. os: {},
  8257. node: false,
  8258. wxa: true,
  8259. // Weixin Application
  8260. canvasSupported: true,
  8261. svgSupported: false,
  8262. touchEventsSupported: true,
  8263. domSupported: false
  8264. };
  8265. } else if (typeof document === 'undefined' && typeof self !== 'undefined') {
  8266. // In worker
  8267. env = {
  8268. browser: {},
  8269. os: {},
  8270. node: false,
  8271. worker: true,
  8272. canvasSupported: true,
  8273. domSupported: false
  8274. };
  8275. } else if (typeof navigator === 'undefined') {
  8276. // In node
  8277. env = {
  8278. browser: {},
  8279. os: {},
  8280. node: true,
  8281. worker: false,
  8282. // Assume canvas is supported
  8283. canvasSupported: true,
  8284. svgSupported: true,
  8285. domSupported: false
  8286. };
  8287. } else {
  8288. env = detect(navigator.userAgent);
  8289. }
  8290. var _default = env; // Zepto.js
  8291. // (c) 2010-2013 Thomas Fuchs
  8292. // Zepto.js may be freely distributed under the MIT license.
  8293. function detect(ua) {
  8294. var os = {};
  8295. var browser = {}; // var webkit = ua.match(/Web[kK]it[\/]{0,1}([\d.]+)/);
  8296. // var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
  8297. // var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
  8298. // var ipod = ua.match(/(iPod)(.*OS\s([\d_]+))?/);
  8299. // var iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/);
  8300. // var webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/);
  8301. // var touchpad = webos && ua.match(/TouchPad/);
  8302. // var kindle = ua.match(/Kindle\/([\d.]+)/);
  8303. // var silk = ua.match(/Silk\/([\d._]+)/);
  8304. // var blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  8305. // var bb10 = ua.match(/(BB10).*Version\/([\d.]+)/);
  8306. // var rimtabletos = ua.match(/(RIM\sTablet\sOS)\s([\d.]+)/);
  8307. // var playbook = ua.match(/PlayBook/);
  8308. // var chrome = ua.match(/Chrome\/([\d.]+)/) || ua.match(/CriOS\/([\d.]+)/);
  8309. var firefox = ua.match(/Firefox\/([\d.]+)/); // var safari = webkit && ua.match(/Mobile\//) && !chrome;
  8310. // var webview = ua.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)/) && !chrome;
  8311. var ie = ua.match(/MSIE\s([\d.]+)/) // IE 11 Trident/7.0; rv:11.0
  8312. || ua.match(/Trident\/.+?rv:(([\d.]+))/);
  8313. var edge = ua.match(/Edge\/([\d.]+)/); // IE 12 and 12+
  8314. var weChat = /micromessenger/i.test(ua); // Todo: clean this up with a better OS/browser seperation:
  8315. // - discern (more) between multiple browsers on android
  8316. // - decide if kindle fire in silk mode is android or not
  8317. // - Firefox on Android doesn't specify the Android version
  8318. // - possibly devide in os, device and browser hashes
  8319. // if (browser.webkit = !!webkit) browser.version = webkit[1];
  8320. // if (android) os.android = true, os.version = android[2];
  8321. // if (iphone && !ipod) os.ios = os.iphone = true, os.version = iphone[2].replace(/_/g, '.');
  8322. // if (ipad) os.ios = os.ipad = true, os.version = ipad[2].replace(/_/g, '.');
  8323. // if (ipod) os.ios = os.ipod = true, os.version = ipod[3] ? ipod[3].replace(/_/g, '.') : null;
  8324. // if (webos) os.webos = true, os.version = webos[2];
  8325. // if (touchpad) os.touchpad = true;
  8326. // if (blackberry) os.blackberry = true, os.version = blackberry[2];
  8327. // if (bb10) os.bb10 = true, os.version = bb10[2];
  8328. // if (rimtabletos) os.rimtabletos = true, os.version = rimtabletos[2];
  8329. // if (playbook) browser.playbook = true;
  8330. // if (kindle) os.kindle = true, os.version = kindle[1];
  8331. // if (silk) browser.silk = true, browser.version = silk[1];
  8332. // if (!silk && os.android && ua.match(/Kindle Fire/)) browser.silk = true;
  8333. // if (chrome) browser.chrome = true, browser.version = chrome[1];
  8334. if (firefox) {
  8335. browser.firefox = true;
  8336. browser.version = firefox[1];
  8337. } // if (safari && (ua.match(/Safari/) || !!os.ios)) browser.safari = true;
  8338. // if (webview) browser.webview = true;
  8339. if (ie) {
  8340. browser.ie = true;
  8341. browser.version = ie[1];
  8342. }
  8343. if (edge) {
  8344. browser.edge = true;
  8345. browser.version = edge[1];
  8346. } // It is difficult to detect WeChat in Win Phone precisely, because ua can
  8347. // not be set on win phone. So we do not consider Win Phone.
  8348. if (weChat) {
  8349. browser.weChat = true;
  8350. } // os.tablet = !!(ipad || playbook || (android && !ua.match(/Mobile/)) ||
  8351. // (firefox && ua.match(/Tablet/)) || (ie && !ua.match(/Phone/) && ua.match(/Touch/)));
  8352. // os.phone = !!(!os.tablet && !os.ipod && (android || iphone || webos ||
  8353. // (chrome && ua.match(/Android/)) || (chrome && ua.match(/CriOS\/([\d.]+)/)) ||
  8354. // (firefox && ua.match(/Mobile/)) || (ie && ua.match(/Touch/))));
  8355. return {
  8356. browser: browser,
  8357. os: os,
  8358. node: false,
  8359. // 原生canvas支持,改极端点了
  8360. // canvasSupported : !(browser.ie && parseFloat(browser.version) < 9)
  8361. canvasSupported: !!document.createElement('canvas').getContext,
  8362. svgSupported: typeof SVGRect !== 'undefined',
  8363. // works on most browsers
  8364. // IE10/11 does not support touch event, and MS Edge supports them but not by
  8365. // default, so we dont check navigator.maxTouchPoints for them here.
  8366. touchEventsSupported: 'ontouchstart' in window && !browser.ie && !browser.edge,
  8367. // <http://caniuse.com/#search=pointer%20event>.
  8368. pointerEventsSupported: // (1) Firefox supports pointer but not by default, only MS browsers are reliable on pointer
  8369. // events currently. So we dont use that on other browsers unless tested sufficiently.
  8370. // For example, in iOS 13 Mobile Chromium 78, if the touching behavior starts page
  8371. // scroll, the `pointermove` event can not be fired any more. That will break some
  8372. // features like "pan horizontally to move something and pan vertically to page scroll".
  8373. // The horizontal pan probably be interrupted by the casually triggered page scroll.
  8374. // (2) Although IE 10 supports pointer event, it use old style and is different from the
  8375. // standard. So we exclude that. (IE 10 is hardly used on touch device)
  8376. 'onpointerdown' in window && (browser.edge || browser.ie && browser.version >= 11),
  8377. // passiveSupported: detectPassiveSupport()
  8378. domSupported: typeof document !== 'undefined'
  8379. };
  8380. } // See https://github.com/WICG/EventListenerOptions/blob/gh-pages/explainer.md#feature-detection
  8381. // function detectPassiveSupport() {
  8382. // // Test via a getter in the options object to see if the passive property is accessed
  8383. // var supportsPassive = false;
  8384. // try {
  8385. // var opts = Object.defineProperty({}, 'passive', {
  8386. // get: function() {
  8387. // supportsPassive = true;
  8388. // }
  8389. // });
  8390. // window.addEventListener('testPassive', function() {}, opts);
  8391. // } catch (e) {
  8392. // }
  8393. // return supportsPassive;
  8394. // }
  8395. module.exports = _default;
  8396. /***/ }),
  8397. /***/ "./node_modules/zrender/lib/core/guid.js":
  8398. /*!***********************************************!*\
  8399. !*** ./node_modules/zrender/lib/core/guid.js ***!
  8400. \***********************************************/
  8401. /*! no static exports found */
  8402. /***/ (function(module, exports) {
  8403. /**
  8404. * zrender: 生成唯一id
  8405. *
  8406. * @author errorrik (errorrik@gmail.com)
  8407. */
  8408. var idStart = 0x0907;
  8409. function _default() {
  8410. return idStart++;
  8411. }
  8412. module.exports = _default;
  8413. /***/ }),
  8414. /***/ "./node_modules/zrender/lib/core/log.js":
  8415. /*!**********************************************!*\
  8416. !*** ./node_modules/zrender/lib/core/log.js ***!
  8417. \**********************************************/
  8418. /*! no static exports found */
  8419. /***/ (function(module, exports, __webpack_require__) {
  8420. var _config = __webpack_require__(/*! ../config */ "./node_modules/zrender/lib/config.js");
  8421. var debugMode = _config.debugMode;
  8422. var logError = function () {};
  8423. if (debugMode === 1) {
  8424. logError = console.error;
  8425. }
  8426. var _default = logError;
  8427. module.exports = _default;
  8428. /***/ }),
  8429. /***/ "./node_modules/zrender/lib/core/matrix.js":
  8430. /*!*************************************************!*\
  8431. !*** ./node_modules/zrender/lib/core/matrix.js ***!
  8432. \*************************************************/
  8433. /*! no static exports found */
  8434. /***/ (function(module, exports) {
  8435. /**
  8436. * 3x2矩阵操作类
  8437. * @exports zrender/tool/matrix
  8438. */
  8439. /* global Float32Array */
  8440. var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array;
  8441. /**
  8442. * Create a identity matrix.
  8443. * @return {Float32Array|Array.<number>}
  8444. */
  8445. function create() {
  8446. var out = new ArrayCtor(6);
  8447. identity(out);
  8448. return out;
  8449. }
  8450. /**
  8451. * 设置矩阵为单位矩阵
  8452. * @param {Float32Array|Array.<number>} out
  8453. */
  8454. function identity(out) {
  8455. out[0] = 1;
  8456. out[1] = 0;
  8457. out[2] = 0;
  8458. out[3] = 1;
  8459. out[4] = 0;
  8460. out[5] = 0;
  8461. return out;
  8462. }
  8463. /**
  8464. * 复制矩阵
  8465. * @param {Float32Array|Array.<number>} out
  8466. * @param {Float32Array|Array.<number>} m
  8467. */
  8468. function copy(out, m) {
  8469. out[0] = m[0];
  8470. out[1] = m[1];
  8471. out[2] = m[2];
  8472. out[3] = m[3];
  8473. out[4] = m[4];
  8474. out[5] = m[5];
  8475. return out;
  8476. }
  8477. /**
  8478. * 矩阵相乘
  8479. * @param {Float32Array|Array.<number>} out
  8480. * @param {Float32Array|Array.<number>} m1
  8481. * @param {Float32Array|Array.<number>} m2
  8482. */
  8483. function mul(out, m1, m2) {
  8484. // Consider matrix.mul(m, m2, m);
  8485. // where out is the same as m2.
  8486. // So use temp variable to escape error.
  8487. var out0 = m1[0] * m2[0] + m1[2] * m2[1];
  8488. var out1 = m1[1] * m2[0] + m1[3] * m2[1];
  8489. var out2 = m1[0] * m2[2] + m1[2] * m2[3];
  8490. var out3 = m1[1] * m2[2] + m1[3] * m2[3];
  8491. var out4 = m1[0] * m2[4] + m1[2] * m2[5] + m1[4];
  8492. var out5 = m1[1] * m2[4] + m1[3] * m2[5] + m1[5];
  8493. out[0] = out0;
  8494. out[1] = out1;
  8495. out[2] = out2;
  8496. out[3] = out3;
  8497. out[4] = out4;
  8498. out[5] = out5;
  8499. return out;
  8500. }
  8501. /**
  8502. * 平移变换
  8503. * @param {Float32Array|Array.<number>} out
  8504. * @param {Float32Array|Array.<number>} a
  8505. * @param {Float32Array|Array.<number>} v
  8506. */
  8507. function translate(out, a, v) {
  8508. out[0] = a[0];
  8509. out[1] = a[1];
  8510. out[2] = a[2];
  8511. out[3] = a[3];
  8512. out[4] = a[4] + v[0];
  8513. out[5] = a[5] + v[1];
  8514. return out;
  8515. }
  8516. /**
  8517. * 旋转变换
  8518. * @param {Float32Array|Array.<number>} out
  8519. * @param {Float32Array|Array.<number>} a
  8520. * @param {number} rad
  8521. */
  8522. function rotate(out, a, rad) {
  8523. var aa = a[0];
  8524. var ac = a[2];
  8525. var atx = a[4];
  8526. var ab = a[1];
  8527. var ad = a[3];
  8528. var aty = a[5];
  8529. var st = Math.sin(rad);
  8530. var ct = Math.cos(rad);
  8531. out[0] = aa * ct + ab * st;
  8532. out[1] = -aa * st + ab * ct;
  8533. out[2] = ac * ct + ad * st;
  8534. out[3] = -ac * st + ct * ad;
  8535. out[4] = ct * atx + st * aty;
  8536. out[5] = ct * aty - st * atx;
  8537. return out;
  8538. }
  8539. /**
  8540. * 缩放变换
  8541. * @param {Float32Array|Array.<number>} out
  8542. * @param {Float32Array|Array.<number>} a
  8543. * @param {Float32Array|Array.<number>} v
  8544. */
  8545. function scale(out, a, v) {
  8546. var vx = v[0];
  8547. var vy = v[1];
  8548. out[0] = a[0] * vx;
  8549. out[1] = a[1] * vy;
  8550. out[2] = a[2] * vx;
  8551. out[3] = a[3] * vy;
  8552. out[4] = a[4] * vx;
  8553. out[5] = a[5] * vy;
  8554. return out;
  8555. }
  8556. /**
  8557. * 求逆矩阵
  8558. * @param {Float32Array|Array.<number>} out
  8559. * @param {Float32Array|Array.<number>} a
  8560. */
  8561. function invert(out, a) {
  8562. var aa = a[0];
  8563. var ac = a[2];
  8564. var atx = a[4];
  8565. var ab = a[1];
  8566. var ad = a[3];
  8567. var aty = a[5];
  8568. var det = aa * ad - ab * ac;
  8569. if (!det) {
  8570. return null;
  8571. }
  8572. det = 1.0 / det;
  8573. out[0] = ad * det;
  8574. out[1] = -ab * det;
  8575. out[2] = -ac * det;
  8576. out[3] = aa * det;
  8577. out[4] = (ac * aty - ad * atx) * det;
  8578. out[5] = (ab * atx - aa * aty) * det;
  8579. return out;
  8580. }
  8581. /**
  8582. * Clone a new matrix.
  8583. * @param {Float32Array|Array.<number>} a
  8584. */
  8585. function clone(a) {
  8586. var b = create();
  8587. copy(b, a);
  8588. return b;
  8589. }
  8590. exports.create = create;
  8591. exports.identity = identity;
  8592. exports.copy = copy;
  8593. exports.mul = mul;
  8594. exports.translate = translate;
  8595. exports.rotate = rotate;
  8596. exports.scale = scale;
  8597. exports.invert = invert;
  8598. exports.clone = clone;
  8599. /***/ }),
  8600. /***/ "./node_modules/zrender/lib/core/util.js":
  8601. /*!***********************************************!*\
  8602. !*** ./node_modules/zrender/lib/core/util.js ***!
  8603. \***********************************************/
  8604. /*! no static exports found */
  8605. /***/ (function(module, exports) {
  8606. /**
  8607. * @module zrender/core/util
  8608. */
  8609. // 用于处理merge时无法遍历Date等对象的问题
  8610. var BUILTIN_OBJECT = {
  8611. '[object Function]': 1,
  8612. '[object RegExp]': 1,
  8613. '[object Date]': 1,
  8614. '[object Error]': 1,
  8615. '[object CanvasGradient]': 1,
  8616. '[object CanvasPattern]': 1,
  8617. // For node-canvas
  8618. '[object Image]': 1,
  8619. '[object Canvas]': 1
  8620. };
  8621. var TYPED_ARRAY = {
  8622. '[object Int8Array]': 1,
  8623. '[object Uint8Array]': 1,
  8624. '[object Uint8ClampedArray]': 1,
  8625. '[object Int16Array]': 1,
  8626. '[object Uint16Array]': 1,
  8627. '[object Int32Array]': 1,
  8628. '[object Uint32Array]': 1,
  8629. '[object Float32Array]': 1,
  8630. '[object Float64Array]': 1
  8631. };
  8632. var objToString = Object.prototype.toString;
  8633. var arrayProto = Array.prototype;
  8634. var nativeForEach = arrayProto.forEach;
  8635. var nativeFilter = arrayProto.filter;
  8636. var nativeSlice = arrayProto.slice;
  8637. var nativeMap = arrayProto.map;
  8638. var nativeReduce = arrayProto.reduce; // Avoid assign to an exported variable, for transforming to cjs.
  8639. var methods = {};
  8640. function $override(name, fn) {
  8641. // Clear ctx instance for different environment
  8642. if (name === 'createCanvas') {
  8643. _ctx = null;
  8644. }
  8645. methods[name] = fn;
  8646. }
  8647. /**
  8648. * Those data types can be cloned:
  8649. * Plain object, Array, TypedArray, number, string, null, undefined.
  8650. * Those data types will be assgined using the orginal data:
  8651. * BUILTIN_OBJECT
  8652. * Instance of user defined class will be cloned to a plain object, without
  8653. * properties in prototype.
  8654. * Other data types is not supported (not sure what will happen).
  8655. *
  8656. * Caution: do not support clone Date, for performance consideration.
  8657. * (There might be a large number of date in `series.data`).
  8658. * So date should not be modified in and out of echarts.
  8659. *
  8660. * @param {*} source
  8661. * @return {*} new
  8662. */
  8663. function clone(source) {
  8664. if (source == null || typeof source !== 'object') {
  8665. return source;
  8666. }
  8667. var result = source;
  8668. var typeStr = objToString.call(source);
  8669. if (typeStr === '[object Array]') {
  8670. if (!isPrimitive(source)) {
  8671. result = [];
  8672. for (var i = 0, len = source.length; i < len; i++) {
  8673. result[i] = clone(source[i]);
  8674. }
  8675. }
  8676. } else if (TYPED_ARRAY[typeStr]) {
  8677. if (!isPrimitive(source)) {
  8678. var Ctor = source.constructor;
  8679. if (source.constructor.from) {
  8680. result = Ctor.from(source);
  8681. } else {
  8682. result = new Ctor(source.length);
  8683. for (var i = 0, len = source.length; i < len; i++) {
  8684. result[i] = clone(source[i]);
  8685. }
  8686. }
  8687. }
  8688. } else if (!BUILTIN_OBJECT[typeStr] && !isPrimitive(source) && !isDom(source)) {
  8689. result = {};
  8690. for (var key in source) {
  8691. if (source.hasOwnProperty(key)) {
  8692. result[key] = clone(source[key]);
  8693. }
  8694. }
  8695. }
  8696. return result;
  8697. }
  8698. /**
  8699. * @memberOf module:zrender/core/util
  8700. * @param {*} target
  8701. * @param {*} source
  8702. * @param {boolean} [overwrite=false]
  8703. */
  8704. function merge(target, source, overwrite) {
  8705. // We should escapse that source is string
  8706. // and enter for ... in ...
  8707. if (!isObject(source) || !isObject(target)) {
  8708. return overwrite ? clone(source) : target;
  8709. }
  8710. for (var key in source) {
  8711. if (source.hasOwnProperty(key)) {
  8712. var targetProp = target[key];
  8713. var sourceProp = source[key];
  8714. if (isObject(sourceProp) && isObject(targetProp) && !isArray(sourceProp) && !isArray(targetProp) && !isDom(sourceProp) && !isDom(targetProp) && !isBuiltInObject(sourceProp) && !isBuiltInObject(targetProp) && !isPrimitive(sourceProp) && !isPrimitive(targetProp)) {
  8715. // 如果需要递归覆盖,就递归调用merge
  8716. merge(targetProp, sourceProp, overwrite);
  8717. } else if (overwrite || !(key in target)) {
  8718. // 否则只处理overwrite为true,或者在目标对象中没有此属性的情况
  8719. // NOTE,在 target[key] 不存在的时候也是直接覆盖
  8720. target[key] = clone(source[key], true);
  8721. }
  8722. }
  8723. }
  8724. return target;
  8725. }
  8726. /**
  8727. * @param {Array} targetAndSources The first item is target, and the rests are source.
  8728. * @param {boolean} [overwrite=false]
  8729. * @return {*} target
  8730. */
  8731. function mergeAll(targetAndSources, overwrite) {
  8732. var result = targetAndSources[0];
  8733. for (var i = 1, len = targetAndSources.length; i < len; i++) {
  8734. result = merge(result, targetAndSources[i], overwrite);
  8735. }
  8736. return result;
  8737. }
  8738. /**
  8739. * @param {*} target
  8740. * @param {*} source
  8741. * @memberOf module:zrender/core/util
  8742. */
  8743. function extend(target, source) {
  8744. for (var key in source) {
  8745. if (source.hasOwnProperty(key)) {
  8746. target[key] = source[key];
  8747. }
  8748. }
  8749. return target;
  8750. }
  8751. /**
  8752. * @param {*} target
  8753. * @param {*} source
  8754. * @param {boolean} [overlay=false]
  8755. * @memberOf module:zrender/core/util
  8756. */
  8757. function defaults(target, source, overlay) {
  8758. for (var key in source) {
  8759. if (source.hasOwnProperty(key) && (overlay ? source[key] != null : target[key] == null)) {
  8760. target[key] = source[key];
  8761. }
  8762. }
  8763. return target;
  8764. }
  8765. var createCanvas = function () {
  8766. return methods.createCanvas();
  8767. };
  8768. methods.createCanvas = function () {
  8769. return document.createElement('canvas');
  8770. }; // FIXME
  8771. var _ctx;
  8772. function getContext() {
  8773. if (!_ctx) {
  8774. // Use util.createCanvas instead of createCanvas
  8775. // because createCanvas may be overwritten in different environment
  8776. _ctx = createCanvas().getContext('2d');
  8777. }
  8778. return _ctx;
  8779. }
  8780. /**
  8781. * 查询数组中元素的index
  8782. * @memberOf module:zrender/core/util
  8783. */
  8784. function indexOf(array, value) {
  8785. if (array) {
  8786. if (array.indexOf) {
  8787. return array.indexOf(value);
  8788. }
  8789. for (var i = 0, len = array.length; i < len; i++) {
  8790. if (array[i] === value) {
  8791. return i;
  8792. }
  8793. }
  8794. }
  8795. return -1;
  8796. }
  8797. /**
  8798. * 构造类继承关系
  8799. *
  8800. * @memberOf module:zrender/core/util
  8801. * @param {Function} clazz 源类
  8802. * @param {Function} baseClazz 基类
  8803. */
  8804. function inherits(clazz, baseClazz) {
  8805. var clazzPrototype = clazz.prototype;
  8806. function F() {}
  8807. F.prototype = baseClazz.prototype;
  8808. clazz.prototype = new F();
  8809. for (var prop in clazzPrototype) {
  8810. if (clazzPrototype.hasOwnProperty(prop)) {
  8811. clazz.prototype[prop] = clazzPrototype[prop];
  8812. }
  8813. }
  8814. clazz.prototype.constructor = clazz;
  8815. clazz.superClass = baseClazz;
  8816. }
  8817. /**
  8818. * @memberOf module:zrender/core/util
  8819. * @param {Object|Function} target
  8820. * @param {Object|Function} sorce
  8821. * @param {boolean} overlay
  8822. */
  8823. function mixin(target, source, overlay) {
  8824. target = 'prototype' in target ? target.prototype : target;
  8825. source = 'prototype' in source ? source.prototype : source;
  8826. defaults(target, source, overlay);
  8827. }
  8828. /**
  8829. * Consider typed array.
  8830. * @param {Array|TypedArray} data
  8831. */
  8832. function isArrayLike(data) {
  8833. if (!data) {
  8834. return;
  8835. }
  8836. if (typeof data === 'string') {
  8837. return false;
  8838. }
  8839. return typeof data.length === 'number';
  8840. }
  8841. /**
  8842. * 数组或对象遍历
  8843. * @memberOf module:zrender/core/util
  8844. * @param {Object|Array} obj
  8845. * @param {Function} cb
  8846. * @param {*} [context]
  8847. */
  8848. function each(obj, cb, context) {
  8849. if (!(obj && cb)) {
  8850. return;
  8851. }
  8852. if (obj.forEach && obj.forEach === nativeForEach) {
  8853. obj.forEach(cb, context);
  8854. } else if (obj.length === +obj.length) {
  8855. for (var i = 0, len = obj.length; i < len; i++) {
  8856. cb.call(context, obj[i], i, obj);
  8857. }
  8858. } else {
  8859. for (var key in obj) {
  8860. if (obj.hasOwnProperty(key)) {
  8861. cb.call(context, obj[key], key, obj);
  8862. }
  8863. }
  8864. }
  8865. }
  8866. /**
  8867. * 数组映射
  8868. * @memberOf module:zrender/core/util
  8869. * @param {Array} obj
  8870. * @param {Function} cb
  8871. * @param {*} [context]
  8872. * @return {Array}
  8873. */
  8874. function map(obj, cb, context) {
  8875. if (!(obj && cb)) {
  8876. return;
  8877. }
  8878. if (obj.map && obj.map === nativeMap) {
  8879. return obj.map(cb, context);
  8880. } else {
  8881. var result = [];
  8882. for (var i = 0, len = obj.length; i < len; i++) {
  8883. result.push(cb.call(context, obj[i], i, obj));
  8884. }
  8885. return result;
  8886. }
  8887. }
  8888. /**
  8889. * @memberOf module:zrender/core/util
  8890. * @param {Array} obj
  8891. * @param {Function} cb
  8892. * @param {Object} [memo]
  8893. * @param {*} [context]
  8894. * @return {Array}
  8895. */
  8896. function reduce(obj, cb, memo, context) {
  8897. if (!(obj && cb)) {
  8898. return;
  8899. }
  8900. if (obj.reduce && obj.reduce === nativeReduce) {
  8901. return obj.reduce(cb, memo, context);
  8902. } else {
  8903. for (var i = 0, len = obj.length; i < len; i++) {
  8904. memo = cb.call(context, memo, obj[i], i, obj);
  8905. }
  8906. return memo;
  8907. }
  8908. }
  8909. /**
  8910. * 数组过滤
  8911. * @memberOf module:zrender/core/util
  8912. * @param {Array} obj
  8913. * @param {Function} cb
  8914. * @param {*} [context]
  8915. * @return {Array}
  8916. */
  8917. function filter(obj, cb, context) {
  8918. if (!(obj && cb)) {
  8919. return;
  8920. }
  8921. if (obj.filter && obj.filter === nativeFilter) {
  8922. return obj.filter(cb, context);
  8923. } else {
  8924. var result = [];
  8925. for (var i = 0, len = obj.length; i < len; i++) {
  8926. if (cb.call(context, obj[i], i, obj)) {
  8927. result.push(obj[i]);
  8928. }
  8929. }
  8930. return result;
  8931. }
  8932. }
  8933. /**
  8934. * 数组项查找
  8935. * @memberOf module:zrender/core/util
  8936. * @param {Array} obj
  8937. * @param {Function} cb
  8938. * @param {*} [context]
  8939. * @return {*}
  8940. */
  8941. function find(obj, cb, context) {
  8942. if (!(obj && cb)) {
  8943. return;
  8944. }
  8945. for (var i = 0, len = obj.length; i < len; i++) {
  8946. if (cb.call(context, obj[i], i, obj)) {
  8947. return obj[i];
  8948. }
  8949. }
  8950. }
  8951. /**
  8952. * @memberOf module:zrender/core/util
  8953. * @param {Function} func
  8954. * @param {*} context
  8955. * @return {Function}
  8956. */
  8957. function bind(func, context) {
  8958. var args = nativeSlice.call(arguments, 2);
  8959. return function () {
  8960. return func.apply(context, args.concat(nativeSlice.call(arguments)));
  8961. };
  8962. }
  8963. /**
  8964. * @memberOf module:zrender/core/util
  8965. * @param {Function} func
  8966. * @return {Function}
  8967. */
  8968. function curry(func) {
  8969. var args = nativeSlice.call(arguments, 1);
  8970. return function () {
  8971. return func.apply(this, args.concat(nativeSlice.call(arguments)));
  8972. };
  8973. }
  8974. /**
  8975. * @memberOf module:zrender/core/util
  8976. * @param {*} value
  8977. * @return {boolean}
  8978. */
  8979. function isArray(value) {
  8980. return objToString.call(value) === '[object Array]';
  8981. }
  8982. /**
  8983. * @memberOf module:zrender/core/util
  8984. * @param {*} value
  8985. * @return {boolean}
  8986. */
  8987. function isFunction(value) {
  8988. return typeof value === 'function';
  8989. }
  8990. /**
  8991. * @memberOf module:zrender/core/util
  8992. * @param {*} value
  8993. * @return {boolean}
  8994. */
  8995. function isString(value) {
  8996. return objToString.call(value) === '[object String]';
  8997. }
  8998. /**
  8999. * @memberOf module:zrender/core/util
  9000. * @param {*} value
  9001. * @return {boolean}
  9002. */
  9003. function isObject(value) {
  9004. // Avoid a V8 JIT bug in Chrome 19-20.
  9005. // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
  9006. var type = typeof value;
  9007. return type === 'function' || !!value && type === 'object';
  9008. }
  9009. /**
  9010. * @memberOf module:zrender/core/util
  9011. * @param {*} value
  9012. * @return {boolean}
  9013. */
  9014. function isBuiltInObject(value) {
  9015. return !!BUILTIN_OBJECT[objToString.call(value)];
  9016. }
  9017. /**
  9018. * @memberOf module:zrender/core/util
  9019. * @param {*} value
  9020. * @return {boolean}
  9021. */
  9022. function isTypedArray(value) {
  9023. return !!TYPED_ARRAY[objToString.call(value)];
  9024. }
  9025. /**
  9026. * @memberOf module:zrender/core/util
  9027. * @param {*} value
  9028. * @return {boolean}
  9029. */
  9030. function isDom(value) {
  9031. return typeof value === 'object' && typeof value.nodeType === 'number' && typeof value.ownerDocument === 'object';
  9032. }
  9033. /**
  9034. * Whether is exactly NaN. Notice isNaN('a') returns true.
  9035. * @param {*} value
  9036. * @return {boolean}
  9037. */
  9038. function eqNaN(value) {
  9039. /* eslint-disable-next-line no-self-compare */
  9040. return value !== value;
  9041. }
  9042. /**
  9043. * If value1 is not null, then return value1, otherwise judget rest of values.
  9044. * Low performance.
  9045. * @memberOf module:zrender/core/util
  9046. * @return {*} Final value
  9047. */
  9048. function retrieve(values) {
  9049. for (var i = 0, len = arguments.length; i < len; i++) {
  9050. if (arguments[i] != null) {
  9051. return arguments[i];
  9052. }
  9053. }
  9054. }
  9055. function retrieve2(value0, value1) {
  9056. return value0 != null ? value0 : value1;
  9057. }
  9058. function retrieve3(value0, value1, value2) {
  9059. return value0 != null ? value0 : value1 != null ? value1 : value2;
  9060. }
  9061. /**
  9062. * @memberOf module:zrender/core/util
  9063. * @param {Array} arr
  9064. * @param {number} startIndex
  9065. * @param {number} endIndex
  9066. * @return {Array}
  9067. */
  9068. function slice() {
  9069. return Function.call.apply(nativeSlice, arguments);
  9070. }
  9071. /**
  9072. * Normalize css liked array configuration
  9073. * e.g.
  9074. * 3 => [3, 3, 3, 3]
  9075. * [4, 2] => [4, 2, 4, 2]
  9076. * [4, 3, 2] => [4, 3, 2, 3]
  9077. * @param {number|Array.<number>} val
  9078. * @return {Array.<number>}
  9079. */
  9080. function normalizeCssArray(val) {
  9081. if (typeof val === 'number') {
  9082. return [val, val, val, val];
  9083. }
  9084. var len = val.length;
  9085. if (len === 2) {
  9086. // vertical | horizontal
  9087. return [val[0], val[1], val[0], val[1]];
  9088. } else if (len === 3) {
  9089. // top | horizontal | bottom
  9090. return [val[0], val[1], val[2], val[1]];
  9091. }
  9092. return val;
  9093. }
  9094. /**
  9095. * @memberOf module:zrender/core/util
  9096. * @param {boolean} condition
  9097. * @param {string} message
  9098. */
  9099. function assert(condition, message) {
  9100. if (!condition) {
  9101. throw new Error(message);
  9102. }
  9103. }
  9104. /**
  9105. * @memberOf module:zrender/core/util
  9106. * @param {string} str string to be trimed
  9107. * @return {string} trimed string
  9108. */
  9109. function trim(str) {
  9110. if (str == null) {
  9111. return null;
  9112. } else if (typeof str.trim === 'function') {
  9113. return str.trim();
  9114. } else {
  9115. return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  9116. }
  9117. }
  9118. var primitiveKey = '__ec_primitive__';
  9119. /**
  9120. * Set an object as primitive to be ignored traversing children in clone or merge
  9121. */
  9122. function setAsPrimitive(obj) {
  9123. obj[primitiveKey] = true;
  9124. }
  9125. function isPrimitive(obj) {
  9126. return obj[primitiveKey];
  9127. }
  9128. /**
  9129. * @constructor
  9130. * @param {Object} obj Only apply `ownProperty`.
  9131. */
  9132. function HashMap(obj) {
  9133. var isArr = isArray(obj); // Key should not be set on this, otherwise
  9134. // methods get/set/... may be overrided.
  9135. this.data = {};
  9136. var thisMap = this;
  9137. obj instanceof HashMap ? obj.each(visit) : obj && each(obj, visit);
  9138. function visit(value, key) {
  9139. isArr ? thisMap.set(value, key) : thisMap.set(key, value);
  9140. }
  9141. }
  9142. HashMap.prototype = {
  9143. constructor: HashMap,
  9144. // Do not provide `has` method to avoid defining what is `has`.
  9145. // (We usually treat `null` and `undefined` as the same, different
  9146. // from ES6 Map).
  9147. get: function (key) {
  9148. return this.data.hasOwnProperty(key) ? this.data[key] : null;
  9149. },
  9150. set: function (key, value) {
  9151. // Comparing with invocation chaining, `return value` is more commonly
  9152. // used in this case: `var someVal = map.set('a', genVal());`
  9153. return this.data[key] = value;
  9154. },
  9155. // Although util.each can be performed on this hashMap directly, user
  9156. // should not use the exposed keys, who are prefixed.
  9157. each: function (cb, context) {
  9158. context !== void 0 && (cb = bind(cb, context));
  9159. /* eslint-disable guard-for-in */
  9160. for (var key in this.data) {
  9161. this.data.hasOwnProperty(key) && cb(this.data[key], key);
  9162. }
  9163. /* eslint-enable guard-for-in */
  9164. },
  9165. // Do not use this method if performance sensitive.
  9166. removeKey: function (key) {
  9167. delete this.data[key];
  9168. }
  9169. };
  9170. function createHashMap(obj) {
  9171. return new HashMap(obj);
  9172. }
  9173. function concatArray(a, b) {
  9174. var newArray = new a.constructor(a.length + b.length);
  9175. for (var i = 0; i < a.length; i++) {
  9176. newArray[i] = a[i];
  9177. }
  9178. var offset = a.length;
  9179. for (i = 0; i < b.length; i++) {
  9180. newArray[i + offset] = b[i];
  9181. }
  9182. return newArray;
  9183. }
  9184. function noop() {}
  9185. exports.$override = $override;
  9186. exports.clone = clone;
  9187. exports.merge = merge;
  9188. exports.mergeAll = mergeAll;
  9189. exports.extend = extend;
  9190. exports.defaults = defaults;
  9191. exports.createCanvas = createCanvas;
  9192. exports.getContext = getContext;
  9193. exports.indexOf = indexOf;
  9194. exports.inherits = inherits;
  9195. exports.mixin = mixin;
  9196. exports.isArrayLike = isArrayLike;
  9197. exports.each = each;
  9198. exports.map = map;
  9199. exports.reduce = reduce;
  9200. exports.filter = filter;
  9201. exports.find = find;
  9202. exports.bind = bind;
  9203. exports.curry = curry;
  9204. exports.isArray = isArray;
  9205. exports.isFunction = isFunction;
  9206. exports.isString = isString;
  9207. exports.isObject = isObject;
  9208. exports.isBuiltInObject = isBuiltInObject;
  9209. exports.isTypedArray = isTypedArray;
  9210. exports.isDom = isDom;
  9211. exports.eqNaN = eqNaN;
  9212. exports.retrieve = retrieve;
  9213. exports.retrieve2 = retrieve2;
  9214. exports.retrieve3 = retrieve3;
  9215. exports.slice = slice;
  9216. exports.normalizeCssArray = normalizeCssArray;
  9217. exports.assert = assert;
  9218. exports.trim = trim;
  9219. exports.setAsPrimitive = setAsPrimitive;
  9220. exports.isPrimitive = isPrimitive;
  9221. exports.createHashMap = createHashMap;
  9222. exports.concatArray = concatArray;
  9223. exports.noop = noop;
  9224. /***/ }),
  9225. /***/ "./node_modules/zrender/lib/core/vector.js":
  9226. /*!*************************************************!*\
  9227. !*** ./node_modules/zrender/lib/core/vector.js ***!
  9228. \*************************************************/
  9229. /*! no static exports found */
  9230. /***/ (function(module, exports) {
  9231. /* global Float32Array */
  9232. var ArrayCtor = typeof Float32Array === 'undefined' ? Array : Float32Array;
  9233. /**
  9234. * 创建一个向量
  9235. * @param {number} [x=0]
  9236. * @param {number} [y=0]
  9237. * @return {Vector2}
  9238. */
  9239. function create(x, y) {
  9240. var out = new ArrayCtor(2);
  9241. if (x == null) {
  9242. x = 0;
  9243. }
  9244. if (y == null) {
  9245. y = 0;
  9246. }
  9247. out[0] = x;
  9248. out[1] = y;
  9249. return out;
  9250. }
  9251. /**
  9252. * 复制向量数据
  9253. * @param {Vector2} out
  9254. * @param {Vector2} v
  9255. * @return {Vector2}
  9256. */
  9257. function copy(out, v) {
  9258. out[0] = v[0];
  9259. out[1] = v[1];
  9260. return out;
  9261. }
  9262. /**
  9263. * 克隆一个向量
  9264. * @param {Vector2} v
  9265. * @return {Vector2}
  9266. */
  9267. function clone(v) {
  9268. var out = new ArrayCtor(2);
  9269. out[0] = v[0];
  9270. out[1] = v[1];
  9271. return out;
  9272. }
  9273. /**
  9274. * 设置向量的两个项
  9275. * @param {Vector2} out
  9276. * @param {number} a
  9277. * @param {number} b
  9278. * @return {Vector2} 结果
  9279. */
  9280. function set(out, a, b) {
  9281. out[0] = a;
  9282. out[1] = b;
  9283. return out;
  9284. }
  9285. /**
  9286. * 向量相加
  9287. * @param {Vector2} out
  9288. * @param {Vector2} v1
  9289. * @param {Vector2} v2
  9290. */
  9291. function add(out, v1, v2) {
  9292. out[0] = v1[0] + v2[0];
  9293. out[1] = v1[1] + v2[1];
  9294. return out;
  9295. }
  9296. /**
  9297. * 向量缩放后相加
  9298. * @param {Vector2} out
  9299. * @param {Vector2} v1
  9300. * @param {Vector2} v2
  9301. * @param {number} a
  9302. */
  9303. function scaleAndAdd(out, v1, v2, a) {
  9304. out[0] = v1[0] + v2[0] * a;
  9305. out[1] = v1[1] + v2[1] * a;
  9306. return out;
  9307. }
  9308. /**
  9309. * 向量相减
  9310. * @param {Vector2} out
  9311. * @param {Vector2} v1
  9312. * @param {Vector2} v2
  9313. */
  9314. function sub(out, v1, v2) {
  9315. out[0] = v1[0] - v2[0];
  9316. out[1] = v1[1] - v2[1];
  9317. return out;
  9318. }
  9319. /**
  9320. * 向量长度
  9321. * @param {Vector2} v
  9322. * @return {number}
  9323. */
  9324. function len(v) {
  9325. return Math.sqrt(lenSquare(v));
  9326. }
  9327. var length = len; // jshint ignore:line
  9328. /**
  9329. * 向量长度平方
  9330. * @param {Vector2} v
  9331. * @return {number}
  9332. */
  9333. function lenSquare(v) {
  9334. return v[0] * v[0] + v[1] * v[1];
  9335. }
  9336. var lengthSquare = lenSquare;
  9337. /**
  9338. * 向量乘法
  9339. * @param {Vector2} out
  9340. * @param {Vector2} v1
  9341. * @param {Vector2} v2
  9342. */
  9343. function mul(out, v1, v2) {
  9344. out[0] = v1[0] * v2[0];
  9345. out[1] = v1[1] * v2[1];
  9346. return out;
  9347. }
  9348. /**
  9349. * 向量除法
  9350. * @param {Vector2} out
  9351. * @param {Vector2} v1
  9352. * @param {Vector2} v2
  9353. */
  9354. function div(out, v1, v2) {
  9355. out[0] = v1[0] / v2[0];
  9356. out[1] = v1[1] / v2[1];
  9357. return out;
  9358. }
  9359. /**
  9360. * 向量点乘
  9361. * @param {Vector2} v1
  9362. * @param {Vector2} v2
  9363. * @return {number}
  9364. */
  9365. function dot(v1, v2) {
  9366. return v1[0] * v2[0] + v1[1] * v2[1];
  9367. }
  9368. /**
  9369. * 向量缩放
  9370. * @param {Vector2} out
  9371. * @param {Vector2} v
  9372. * @param {number} s
  9373. */
  9374. function scale(out, v, s) {
  9375. out[0] = v[0] * s;
  9376. out[1] = v[1] * s;
  9377. return out;
  9378. }
  9379. /**
  9380. * 向量归一化
  9381. * @param {Vector2} out
  9382. * @param {Vector2} v
  9383. */
  9384. function normalize(out, v) {
  9385. var d = len(v);
  9386. if (d === 0) {
  9387. out[0] = 0;
  9388. out[1] = 0;
  9389. } else {
  9390. out[0] = v[0] / d;
  9391. out[1] = v[1] / d;
  9392. }
  9393. return out;
  9394. }
  9395. /**
  9396. * 计算向量间距离
  9397. * @param {Vector2} v1
  9398. * @param {Vector2} v2
  9399. * @return {number}
  9400. */
  9401. function distance(v1, v2) {
  9402. return Math.sqrt((v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]));
  9403. }
  9404. var dist = distance;
  9405. /**
  9406. * 向量距离平方
  9407. * @param {Vector2} v1
  9408. * @param {Vector2} v2
  9409. * @return {number}
  9410. */
  9411. function distanceSquare(v1, v2) {
  9412. return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]);
  9413. }
  9414. var distSquare = distanceSquare;
  9415. /**
  9416. * 求负向量
  9417. * @param {Vector2} out
  9418. * @param {Vector2} v
  9419. */
  9420. function negate(out, v) {
  9421. out[0] = -v[0];
  9422. out[1] = -v[1];
  9423. return out;
  9424. }
  9425. /**
  9426. * 插值两个点
  9427. * @param {Vector2} out
  9428. * @param {Vector2} v1
  9429. * @param {Vector2} v2
  9430. * @param {number} t
  9431. */
  9432. function lerp(out, v1, v2, t) {
  9433. out[0] = v1[0] + t * (v2[0] - v1[0]);
  9434. out[1] = v1[1] + t * (v2[1] - v1[1]);
  9435. return out;
  9436. }
  9437. /**
  9438. * 矩阵左乘向量
  9439. * @param {Vector2} out
  9440. * @param {Vector2} v
  9441. * @param {Vector2} m
  9442. */
  9443. function applyTransform(out, v, m) {
  9444. var x = v[0];
  9445. var y = v[1];
  9446. out[0] = m[0] * x + m[2] * y + m[4];
  9447. out[1] = m[1] * x + m[3] * y + m[5];
  9448. return out;
  9449. }
  9450. /**
  9451. * 求两个向量最小值
  9452. * @param {Vector2} out
  9453. * @param {Vector2} v1
  9454. * @param {Vector2} v2
  9455. */
  9456. function min(out, v1, v2) {
  9457. out[0] = Math.min(v1[0], v2[0]);
  9458. out[1] = Math.min(v1[1], v2[1]);
  9459. return out;
  9460. }
  9461. /**
  9462. * 求两个向量最大值
  9463. * @param {Vector2} out
  9464. * @param {Vector2} v1
  9465. * @param {Vector2} v2
  9466. */
  9467. function max(out, v1, v2) {
  9468. out[0] = Math.max(v1[0], v2[0]);
  9469. out[1] = Math.max(v1[1], v2[1]);
  9470. return out;
  9471. }
  9472. exports.create = create;
  9473. exports.copy = copy;
  9474. exports.clone = clone;
  9475. exports.set = set;
  9476. exports.add = add;
  9477. exports.scaleAndAdd = scaleAndAdd;
  9478. exports.sub = sub;
  9479. exports.len = len;
  9480. exports.length = length;
  9481. exports.lenSquare = lenSquare;
  9482. exports.lengthSquare = lengthSquare;
  9483. exports.mul = mul;
  9484. exports.div = div;
  9485. exports.dot = dot;
  9486. exports.scale = scale;
  9487. exports.normalize = normalize;
  9488. exports.distance = distance;
  9489. exports.dist = dist;
  9490. exports.distanceSquare = distanceSquare;
  9491. exports.distSquare = distSquare;
  9492. exports.negate = negate;
  9493. exports.lerp = lerp;
  9494. exports.applyTransform = applyTransform;
  9495. exports.min = min;
  9496. exports.max = max;
  9497. /***/ }),
  9498. /***/ "./node_modules/zrender/lib/graphic/CompoundPath.js":
  9499. /*!**********************************************************!*\
  9500. !*** ./node_modules/zrender/lib/graphic/CompoundPath.js ***!
  9501. \**********************************************************/
  9502. /*! no static exports found */
  9503. /***/ (function(module, exports, __webpack_require__) {
  9504. var Path = __webpack_require__(/*! ./Path */ "./node_modules/zrender/lib/graphic/Path.js");
  9505. // CompoundPath to improve performance
  9506. var _default = Path.extend({
  9507. type: 'compound',
  9508. shape: {
  9509. paths: null
  9510. },
  9511. _updatePathDirty: function () {
  9512. var dirtyPath = this.__dirtyPath;
  9513. var paths = this.shape.paths;
  9514. for (var i = 0; i < paths.length; i++) {
  9515. // Mark as dirty if any subpath is dirty
  9516. dirtyPath = dirtyPath || paths[i].__dirtyPath;
  9517. }
  9518. this.__dirtyPath = dirtyPath;
  9519. this.__dirty = this.__dirty || dirtyPath;
  9520. },
  9521. beforeBrush: function () {
  9522. this._updatePathDirty();
  9523. var paths = this.shape.paths || [];
  9524. var scale = this.getGlobalScale(); // Update path scale
  9525. for (var i = 0; i < paths.length; i++) {
  9526. if (!paths[i].path) {
  9527. paths[i].createPathProxy();
  9528. }
  9529. paths[i].path.setScale(scale[0], scale[1], paths[i].segmentIgnoreThreshold);
  9530. }
  9531. },
  9532. buildPath: function (ctx, shape) {
  9533. var paths = shape.paths || [];
  9534. for (var i = 0; i < paths.length; i++) {
  9535. paths[i].buildPath(ctx, paths[i].shape, true);
  9536. }
  9537. },
  9538. afterBrush: function () {
  9539. var paths = this.shape.paths || [];
  9540. for (var i = 0; i < paths.length; i++) {
  9541. paths[i].__dirtyPath = false;
  9542. }
  9543. },
  9544. getBoundingRect: function () {
  9545. this._updatePathDirty();
  9546. return Path.prototype.getBoundingRect.call(this);
  9547. }
  9548. });
  9549. module.exports = _default;
  9550. /***/ }),
  9551. /***/ "./node_modules/zrender/lib/graphic/Displayable.js":
  9552. /*!*********************************************************!*\
  9553. !*** ./node_modules/zrender/lib/graphic/Displayable.js ***!
  9554. \*********************************************************/
  9555. /*! no static exports found */
  9556. /***/ (function(module, exports, __webpack_require__) {
  9557. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  9558. var Style = __webpack_require__(/*! ./Style */ "./node_modules/zrender/lib/graphic/Style.js");
  9559. var Element = __webpack_require__(/*! ../Element */ "./node_modules/zrender/lib/Element.js");
  9560. var RectText = __webpack_require__(/*! ./mixin/RectText */ "./node_modules/zrender/lib/graphic/mixin/RectText.js");
  9561. /**
  9562. * Base class of all displayable graphic objects
  9563. * @module zrender/graphic/Displayable
  9564. */
  9565. /**
  9566. * @alias module:zrender/graphic/Displayable
  9567. * @extends module:zrender/Element
  9568. * @extends module:zrender/graphic/mixin/RectText
  9569. */
  9570. function Displayable(opts) {
  9571. opts = opts || {};
  9572. Element.call(this, opts); // Extend properties
  9573. for (var name in opts) {
  9574. if (opts.hasOwnProperty(name) && name !== 'style') {
  9575. this[name] = opts[name];
  9576. }
  9577. }
  9578. /**
  9579. * @type {module:zrender/graphic/Style}
  9580. */
  9581. this.style = new Style(opts.style, this);
  9582. this._rect = null; // Shapes for cascade clipping.
  9583. // Can only be `null`/`undefined` or an non-empty array, MUST NOT be an empty array.
  9584. // because it is easy to only using null to check whether clipPaths changed.
  9585. this.__clipPaths = null; // FIXME Stateful must be mixined after style is setted
  9586. // Stateful.call(this, opts);
  9587. }
  9588. Displayable.prototype = {
  9589. constructor: Displayable,
  9590. type: 'displayable',
  9591. /**
  9592. * Dirty flag. From which painter will determine if this displayable object needs brush.
  9593. * @name module:zrender/graphic/Displayable#__dirty
  9594. * @type {boolean}
  9595. */
  9596. __dirty: true,
  9597. /**
  9598. * Whether the displayable object is visible. when it is true, the displayable object
  9599. * is not drawn, but the mouse event can still trigger the object.
  9600. * @name module:/zrender/graphic/Displayable#invisible
  9601. * @type {boolean}
  9602. * @default false
  9603. */
  9604. invisible: false,
  9605. /**
  9606. * @name module:/zrender/graphic/Displayable#z
  9607. * @type {number}
  9608. * @default 0
  9609. */
  9610. z: 0,
  9611. /**
  9612. * @name module:/zrender/graphic/Displayable#z
  9613. * @type {number}
  9614. * @default 0
  9615. */
  9616. z2: 0,
  9617. /**
  9618. * The z level determines the displayable object can be drawn in which layer canvas.
  9619. * @name module:/zrender/graphic/Displayable#zlevel
  9620. * @type {number}
  9621. * @default 0
  9622. */
  9623. zlevel: 0,
  9624. /**
  9625. * Whether it can be dragged.
  9626. * @name module:/zrender/graphic/Displayable#draggable
  9627. * @type {boolean}
  9628. * @default false
  9629. */
  9630. draggable: false,
  9631. /**
  9632. * Whether is it dragging.
  9633. * @name module:/zrender/graphic/Displayable#draggable
  9634. * @type {boolean}
  9635. * @default false
  9636. */
  9637. dragging: false,
  9638. /**
  9639. * Whether to respond to mouse events.
  9640. * @name module:/zrender/graphic/Displayable#silent
  9641. * @type {boolean}
  9642. * @default false
  9643. */
  9644. silent: false,
  9645. /**
  9646. * If enable culling
  9647. * @type {boolean}
  9648. * @default false
  9649. */
  9650. culling: false,
  9651. /**
  9652. * Mouse cursor when hovered
  9653. * @name module:/zrender/graphic/Displayable#cursor
  9654. * @type {string}
  9655. */
  9656. cursor: 'pointer',
  9657. /**
  9658. * If hover area is bounding rect
  9659. * @name module:/zrender/graphic/Displayable#rectHover
  9660. * @type {string}
  9661. */
  9662. rectHover: false,
  9663. /**
  9664. * Render the element progressively when the value >= 0,
  9665. * usefull for large data.
  9666. * @type {boolean}
  9667. */
  9668. progressive: false,
  9669. /**
  9670. * @type {boolean}
  9671. */
  9672. incremental: false,
  9673. /**
  9674. * Scale ratio for global scale.
  9675. * @type {boolean}
  9676. */
  9677. globalScaleRatio: 1,
  9678. beforeBrush: function (ctx) {},
  9679. afterBrush: function (ctx) {},
  9680. /**
  9681. * Graphic drawing method.
  9682. * @param {CanvasRenderingContext2D} ctx
  9683. */
  9684. // Interface
  9685. brush: function (ctx, prevEl) {},
  9686. /**
  9687. * Get the minimum bounding box.
  9688. * @return {module:zrender/core/BoundingRect}
  9689. */
  9690. // Interface
  9691. getBoundingRect: function () {},
  9692. /**
  9693. * If displayable element contain coord x, y
  9694. * @param {number} x
  9695. * @param {number} y
  9696. * @return {boolean}
  9697. */
  9698. contain: function (x, y) {
  9699. return this.rectContain(x, y);
  9700. },
  9701. /**
  9702. * @param {Function} cb
  9703. * @param {} context
  9704. */
  9705. traverse: function (cb, context) {
  9706. cb.call(context, this);
  9707. },
  9708. /**
  9709. * If bounding rect of element contain coord x, y
  9710. * @param {number} x
  9711. * @param {number} y
  9712. * @return {boolean}
  9713. */
  9714. rectContain: function (x, y) {
  9715. var coord = this.transformCoordToLocal(x, y);
  9716. var rect = this.getBoundingRect();
  9717. return rect.contain(coord[0], coord[1]);
  9718. },
  9719. /**
  9720. * Mark displayable element dirty and refresh next frame
  9721. */
  9722. dirty: function () {
  9723. this.__dirty = this.__dirtyText = true;
  9724. this._rect = null;
  9725. this.__zr && this.__zr.refresh();
  9726. },
  9727. /**
  9728. * If displayable object binded any event
  9729. * @return {boolean}
  9730. */
  9731. // TODO, events bound by bind
  9732. // isSilent: function () {
  9733. // return !(
  9734. // this.hoverable || this.draggable
  9735. // || this.onmousemove || this.onmouseover || this.onmouseout
  9736. // || this.onmousedown || this.onmouseup || this.onclick
  9737. // || this.ondragenter || this.ondragover || this.ondragleave
  9738. // || this.ondrop
  9739. // );
  9740. // },
  9741. /**
  9742. * Alias for animate('style')
  9743. * @param {boolean} loop
  9744. */
  9745. animateStyle: function (loop) {
  9746. return this.animate('style', loop);
  9747. },
  9748. attrKV: function (key, value) {
  9749. if (key !== 'style') {
  9750. Element.prototype.attrKV.call(this, key, value);
  9751. } else {
  9752. this.style.set(value);
  9753. }
  9754. },
  9755. /**
  9756. * @param {Object|string} key
  9757. * @param {*} value
  9758. */
  9759. setStyle: function (key, value) {
  9760. this.style.set(key, value);
  9761. this.dirty(false);
  9762. return this;
  9763. },
  9764. /**
  9765. * Use given style object
  9766. * @param {Object} obj
  9767. */
  9768. useStyle: function (obj) {
  9769. this.style = new Style(obj, this);
  9770. this.dirty(false);
  9771. return this;
  9772. },
  9773. /**
  9774. * The string value of `textPosition` needs to be calculated to a real postion.
  9775. * For example, `'inside'` is calculated to `[rect.width/2, rect.height/2]`
  9776. * by default. See `contain/text.js#calculateTextPosition` for more details.
  9777. * But some coutom shapes like "pin", "flag" have center that is not exactly
  9778. * `[width/2, height/2]`. So we provide this hook to customize the calculation
  9779. * for those shapes. It will be called if the `style.textPosition` is a string.
  9780. * @param {Obejct} [out] Prepared out object. If not provided, this method should
  9781. * be responsible for creating one.
  9782. * @param {module:zrender/graphic/Style} style
  9783. * @param {Object} rect {x, y, width, height}
  9784. * @return {Obejct} out The same as the input out.
  9785. * {
  9786. * x: number. mandatory.
  9787. * y: number. mandatory.
  9788. * textAlign: string. optional. use style.textAlign by default.
  9789. * textVerticalAlign: string. optional. use style.textVerticalAlign by default.
  9790. * }
  9791. */
  9792. calculateTextPosition: null
  9793. };
  9794. zrUtil.inherits(Displayable, Element);
  9795. zrUtil.mixin(Displayable, RectText); // zrUtil.mixin(Displayable, Stateful);
  9796. var _default = Displayable;
  9797. module.exports = _default;
  9798. /***/ }),
  9799. /***/ "./node_modules/zrender/lib/graphic/Gradient.js":
  9800. /*!******************************************************!*\
  9801. !*** ./node_modules/zrender/lib/graphic/Gradient.js ***!
  9802. \******************************************************/
  9803. /*! no static exports found */
  9804. /***/ (function(module, exports) {
  9805. /**
  9806. * @param {Array.<Object>} colorStops
  9807. */
  9808. var Gradient = function (colorStops) {
  9809. this.colorStops = colorStops || [];
  9810. };
  9811. Gradient.prototype = {
  9812. constructor: Gradient,
  9813. addColorStop: function (offset, color) {
  9814. this.colorStops.push({
  9815. offset: offset,
  9816. color: color
  9817. });
  9818. }
  9819. };
  9820. var _default = Gradient;
  9821. module.exports = _default;
  9822. /***/ }),
  9823. /***/ "./node_modules/zrender/lib/graphic/Image.js":
  9824. /*!***************************************************!*\
  9825. !*** ./node_modules/zrender/lib/graphic/Image.js ***!
  9826. \***************************************************/
  9827. /*! no static exports found */
  9828. /***/ (function(module, exports, __webpack_require__) {
  9829. var Displayable = __webpack_require__(/*! ./Displayable */ "./node_modules/zrender/lib/graphic/Displayable.js");
  9830. var BoundingRect = __webpack_require__(/*! ../core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  9831. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  9832. var imageHelper = __webpack_require__(/*! ./helper/image */ "./node_modules/zrender/lib/graphic/helper/image.js");
  9833. /**
  9834. * @alias zrender/graphic/Image
  9835. * @extends module:zrender/graphic/Displayable
  9836. * @constructor
  9837. * @param {Object} opts
  9838. */
  9839. function ZImage(opts) {
  9840. Displayable.call(this, opts);
  9841. }
  9842. ZImage.prototype = {
  9843. constructor: ZImage,
  9844. type: 'image',
  9845. brush: function (ctx, prevEl) {
  9846. var style = this.style;
  9847. var src = style.image; // Must bind each time
  9848. style.bind(ctx, this, prevEl);
  9849. var image = this._image = imageHelper.createOrUpdateImage(src, this._image, this, this.onload);
  9850. if (!image || !imageHelper.isImageReady(image)) {
  9851. return;
  9852. } // 图片已经加载完成
  9853. // if (image.nodeName.toUpperCase() == 'IMG') {
  9854. // if (!image.complete) {
  9855. // return;
  9856. // }
  9857. // }
  9858. // Else is canvas
  9859. var x = style.x || 0;
  9860. var y = style.y || 0;
  9861. var width = style.width;
  9862. var height = style.height;
  9863. var aspect = image.width / image.height;
  9864. if (width == null && height != null) {
  9865. // Keep image/height ratio
  9866. width = height * aspect;
  9867. } else if (height == null && width != null) {
  9868. height = width / aspect;
  9869. } else if (width == null && height == null) {
  9870. width = image.width;
  9871. height = image.height;
  9872. } // 设置transform
  9873. this.setTransform(ctx);
  9874. if (style.sWidth && style.sHeight) {
  9875. var sx = style.sx || 0;
  9876. var sy = style.sy || 0;
  9877. ctx.drawImage(image, sx, sy, style.sWidth, style.sHeight, x, y, width, height);
  9878. } else if (style.sx && style.sy) {
  9879. var sx = style.sx;
  9880. var sy = style.sy;
  9881. var sWidth = width - sx;
  9882. var sHeight = height - sy;
  9883. ctx.drawImage(image, sx, sy, sWidth, sHeight, x, y, width, height);
  9884. } else {
  9885. ctx.drawImage(image, x, y, width, height);
  9886. } // Draw rect text
  9887. if (style.text != null) {
  9888. // Only restore transform when needs draw text.
  9889. this.restoreTransform(ctx);
  9890. this.drawRectText(ctx, this.getBoundingRect());
  9891. }
  9892. },
  9893. getBoundingRect: function () {
  9894. var style = this.style;
  9895. if (!this._rect) {
  9896. this._rect = new BoundingRect(style.x || 0, style.y || 0, style.width || 0, style.height || 0);
  9897. }
  9898. return this._rect;
  9899. }
  9900. };
  9901. zrUtil.inherits(ZImage, Displayable);
  9902. var _default = ZImage;
  9903. module.exports = _default;
  9904. /***/ }),
  9905. /***/ "./node_modules/zrender/lib/graphic/IncrementalDisplayable.js":
  9906. /*!********************************************************************!*\
  9907. !*** ./node_modules/zrender/lib/graphic/IncrementalDisplayable.js ***!
  9908. \********************************************************************/
  9909. /*! no static exports found */
  9910. /***/ (function(module, exports, __webpack_require__) {
  9911. var _util = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  9912. var inherits = _util.inherits;
  9913. var Displayble = __webpack_require__(/*! ./Displayable */ "./node_modules/zrender/lib/graphic/Displayable.js");
  9914. var BoundingRect = __webpack_require__(/*! ../core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  9915. /**
  9916. * Displayable for incremental rendering. It will be rendered in a separate layer
  9917. * IncrementalDisplay have two main methods. `clearDisplayables` and `addDisplayables`
  9918. * addDisplayables will render the added displayables incremetally.
  9919. *
  9920. * It use a not clearFlag to tell the painter don't clear the layer if it's the first element.
  9921. */
  9922. // TODO Style override ?
  9923. function IncrementalDisplayble(opts) {
  9924. Displayble.call(this, opts);
  9925. this._displayables = [];
  9926. this._temporaryDisplayables = [];
  9927. this._cursor = 0;
  9928. this.notClear = true;
  9929. }
  9930. IncrementalDisplayble.prototype.incremental = true;
  9931. IncrementalDisplayble.prototype.clearDisplaybles = function () {
  9932. this._displayables = [];
  9933. this._temporaryDisplayables = [];
  9934. this._cursor = 0;
  9935. this.dirty();
  9936. this.notClear = false;
  9937. };
  9938. IncrementalDisplayble.prototype.addDisplayable = function (displayable, notPersistent) {
  9939. if (notPersistent) {
  9940. this._temporaryDisplayables.push(displayable);
  9941. } else {
  9942. this._displayables.push(displayable);
  9943. }
  9944. this.dirty();
  9945. };
  9946. IncrementalDisplayble.prototype.addDisplayables = function (displayables, notPersistent) {
  9947. notPersistent = notPersistent || false;
  9948. for (var i = 0; i < displayables.length; i++) {
  9949. this.addDisplayable(displayables[i], notPersistent);
  9950. }
  9951. };
  9952. IncrementalDisplayble.prototype.eachPendingDisplayable = function (cb) {
  9953. for (var i = this._cursor; i < this._displayables.length; i++) {
  9954. cb && cb(this._displayables[i]);
  9955. }
  9956. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  9957. cb && cb(this._temporaryDisplayables[i]);
  9958. }
  9959. };
  9960. IncrementalDisplayble.prototype.update = function () {
  9961. this.updateTransform();
  9962. for (var i = this._cursor; i < this._displayables.length; i++) {
  9963. var displayable = this._displayables[i]; // PENDING
  9964. displayable.parent = this;
  9965. displayable.update();
  9966. displayable.parent = null;
  9967. }
  9968. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  9969. var displayable = this._temporaryDisplayables[i]; // PENDING
  9970. displayable.parent = this;
  9971. displayable.update();
  9972. displayable.parent = null;
  9973. }
  9974. };
  9975. IncrementalDisplayble.prototype.brush = function (ctx, prevEl) {
  9976. // Render persistant displayables.
  9977. for (var i = this._cursor; i < this._displayables.length; i++) {
  9978. var displayable = this._displayables[i];
  9979. displayable.beforeBrush && displayable.beforeBrush(ctx);
  9980. displayable.brush(ctx, i === this._cursor ? null : this._displayables[i - 1]);
  9981. displayable.afterBrush && displayable.afterBrush(ctx);
  9982. }
  9983. this._cursor = i; // Render temporary displayables.
  9984. for (var i = 0; i < this._temporaryDisplayables.length; i++) {
  9985. var displayable = this._temporaryDisplayables[i];
  9986. displayable.beforeBrush && displayable.beforeBrush(ctx);
  9987. displayable.brush(ctx, i === 0 ? null : this._temporaryDisplayables[i - 1]);
  9988. displayable.afterBrush && displayable.afterBrush(ctx);
  9989. }
  9990. this._temporaryDisplayables = [];
  9991. this.notClear = true;
  9992. };
  9993. var m = [];
  9994. IncrementalDisplayble.prototype.getBoundingRect = function () {
  9995. if (!this._rect) {
  9996. var rect = new BoundingRect(Infinity, Infinity, -Infinity, -Infinity);
  9997. for (var i = 0; i < this._displayables.length; i++) {
  9998. var displayable = this._displayables[i];
  9999. var childRect = displayable.getBoundingRect().clone();
  10000. if (displayable.needLocalTransform()) {
  10001. childRect.applyTransform(displayable.getLocalTransform(m));
  10002. }
  10003. rect.union(childRect);
  10004. }
  10005. this._rect = rect;
  10006. }
  10007. return this._rect;
  10008. };
  10009. IncrementalDisplayble.prototype.contain = function (x, y) {
  10010. var localPos = this.transformCoordToLocal(x, y);
  10011. var rect = this.getBoundingRect();
  10012. if (rect.contain(localPos[0], localPos[1])) {
  10013. for (var i = 0; i < this._displayables.length; i++) {
  10014. var displayable = this._displayables[i];
  10015. if (displayable.contain(x, y)) {
  10016. return true;
  10017. }
  10018. }
  10019. }
  10020. return false;
  10021. };
  10022. inherits(IncrementalDisplayble, Displayble);
  10023. var _default = IncrementalDisplayble;
  10024. module.exports = _default;
  10025. /***/ }),
  10026. /***/ "./node_modules/zrender/lib/graphic/LinearGradient.js":
  10027. /*!************************************************************!*\
  10028. !*** ./node_modules/zrender/lib/graphic/LinearGradient.js ***!
  10029. \************************************************************/
  10030. /*! no static exports found */
  10031. /***/ (function(module, exports, __webpack_require__) {
  10032. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  10033. var Gradient = __webpack_require__(/*! ./Gradient */ "./node_modules/zrender/lib/graphic/Gradient.js");
  10034. /**
  10035. * x, y, x2, y2 are all percent from 0 to 1
  10036. * @param {number} [x=0]
  10037. * @param {number} [y=0]
  10038. * @param {number} [x2=1]
  10039. * @param {number} [y2=0]
  10040. * @param {Array.<Object>} colorStops
  10041. * @param {boolean} [globalCoord=false]
  10042. */
  10043. var LinearGradient = function (x, y, x2, y2, colorStops, globalCoord) {
  10044. // Should do nothing more in this constructor. Because gradient can be
  10045. // declard by `color: {type: 'linear', colorStops: ...}`, where
  10046. // this constructor will not be called.
  10047. this.x = x == null ? 0 : x;
  10048. this.y = y == null ? 0 : y;
  10049. this.x2 = x2 == null ? 1 : x2;
  10050. this.y2 = y2 == null ? 0 : y2; // Can be cloned
  10051. this.type = 'linear'; // If use global coord
  10052. this.global = globalCoord || false;
  10053. Gradient.call(this, colorStops);
  10054. };
  10055. LinearGradient.prototype = {
  10056. constructor: LinearGradient
  10057. };
  10058. zrUtil.inherits(LinearGradient, Gradient);
  10059. var _default = LinearGradient;
  10060. module.exports = _default;
  10061. /***/ }),
  10062. /***/ "./node_modules/zrender/lib/graphic/Path.js":
  10063. /*!**************************************************!*\
  10064. !*** ./node_modules/zrender/lib/graphic/Path.js ***!
  10065. \**************************************************/
  10066. /*! no static exports found */
  10067. /***/ (function(module, exports, __webpack_require__) {
  10068. var Displayable = __webpack_require__(/*! ./Displayable */ "./node_modules/zrender/lib/graphic/Displayable.js");
  10069. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  10070. var PathProxy = __webpack_require__(/*! ../core/PathProxy */ "./node_modules/zrender/lib/core/PathProxy.js");
  10071. var pathContain = __webpack_require__(/*! ../contain/path */ "./node_modules/zrender/lib/contain/path.js");
  10072. var Pattern = __webpack_require__(/*! ./Pattern */ "./node_modules/zrender/lib/graphic/Pattern.js");
  10073. var getCanvasPattern = Pattern.prototype.getCanvasPattern;
  10074. var abs = Math.abs;
  10075. var pathProxyForDraw = new PathProxy(true);
  10076. /**
  10077. * @alias module:zrender/graphic/Path
  10078. * @extends module:zrender/graphic/Displayable
  10079. * @constructor
  10080. * @param {Object} opts
  10081. */
  10082. function Path(opts) {
  10083. Displayable.call(this, opts);
  10084. /**
  10085. * @type {module:zrender/core/PathProxy}
  10086. * @readOnly
  10087. */
  10088. this.path = null;
  10089. }
  10090. Path.prototype = {
  10091. constructor: Path,
  10092. type: 'path',
  10093. __dirtyPath: true,
  10094. strokeContainThreshold: 5,
  10095. // This item default to be false. But in map series in echarts,
  10096. // in order to improve performance, it should be set to true,
  10097. // so the shorty segment won't draw.
  10098. segmentIgnoreThreshold: 0,
  10099. /**
  10100. * See `module:zrender/src/graphic/helper/subPixelOptimize`.
  10101. * @type {boolean}
  10102. */
  10103. subPixelOptimize: false,
  10104. brush: function (ctx, prevEl) {
  10105. var style = this.style;
  10106. var path = this.path || pathProxyForDraw;
  10107. var hasStroke = style.hasStroke();
  10108. var hasFill = style.hasFill();
  10109. var fill = style.fill;
  10110. var stroke = style.stroke;
  10111. var hasFillGradient = hasFill && !!fill.colorStops;
  10112. var hasStrokeGradient = hasStroke && !!stroke.colorStops;
  10113. var hasFillPattern = hasFill && !!fill.image;
  10114. var hasStrokePattern = hasStroke && !!stroke.image;
  10115. style.bind(ctx, this, prevEl);
  10116. this.setTransform(ctx);
  10117. if (this.__dirty) {
  10118. var rect; // Update gradient because bounding rect may changed
  10119. if (hasFillGradient) {
  10120. rect = rect || this.getBoundingRect();
  10121. this._fillGradient = style.getGradient(ctx, fill, rect);
  10122. }
  10123. if (hasStrokeGradient) {
  10124. rect = rect || this.getBoundingRect();
  10125. this._strokeGradient = style.getGradient(ctx, stroke, rect);
  10126. }
  10127. } // Use the gradient or pattern
  10128. if (hasFillGradient) {
  10129. // PENDING If may have affect the state
  10130. ctx.fillStyle = this._fillGradient;
  10131. } else if (hasFillPattern) {
  10132. ctx.fillStyle = getCanvasPattern.call(fill, ctx);
  10133. }
  10134. if (hasStrokeGradient) {
  10135. ctx.strokeStyle = this._strokeGradient;
  10136. } else if (hasStrokePattern) {
  10137. ctx.strokeStyle = getCanvasPattern.call(stroke, ctx);
  10138. }
  10139. var lineDash = style.lineDash;
  10140. var lineDashOffset = style.lineDashOffset;
  10141. var ctxLineDash = !!ctx.setLineDash; // Update path sx, sy
  10142. var scale = this.getGlobalScale();
  10143. path.setScale(scale[0], scale[1], this.segmentIgnoreThreshold); // Proxy context
  10144. // Rebuild path in following 2 cases
  10145. // 1. Path is dirty
  10146. // 2. Path needs javascript implemented lineDash stroking.
  10147. // In this case, lineDash information will not be saved in PathProxy
  10148. if (this.__dirtyPath || lineDash && !ctxLineDash && hasStroke) {
  10149. path.beginPath(ctx); // Setting line dash before build path
  10150. if (lineDash && !ctxLineDash) {
  10151. path.setLineDash(lineDash);
  10152. path.setLineDashOffset(lineDashOffset);
  10153. }
  10154. this.buildPath(path, this.shape, false); // Clear path dirty flag
  10155. if (this.path) {
  10156. this.__dirtyPath = false;
  10157. }
  10158. } else {
  10159. // Replay path building
  10160. ctx.beginPath();
  10161. this.path.rebuildPath(ctx);
  10162. }
  10163. if (hasFill) {
  10164. if (style.fillOpacity != null) {
  10165. var originalGlobalAlpha = ctx.globalAlpha;
  10166. ctx.globalAlpha = style.fillOpacity * style.opacity;
  10167. path.fill(ctx);
  10168. ctx.globalAlpha = originalGlobalAlpha;
  10169. } else {
  10170. path.fill(ctx);
  10171. }
  10172. }
  10173. if (lineDash && ctxLineDash) {
  10174. ctx.setLineDash(lineDash);
  10175. ctx.lineDashOffset = lineDashOffset;
  10176. }
  10177. if (hasStroke) {
  10178. if (style.strokeOpacity != null) {
  10179. var originalGlobalAlpha = ctx.globalAlpha;
  10180. ctx.globalAlpha = style.strokeOpacity * style.opacity;
  10181. path.stroke(ctx);
  10182. ctx.globalAlpha = originalGlobalAlpha;
  10183. } else {
  10184. path.stroke(ctx);
  10185. }
  10186. }
  10187. if (lineDash && ctxLineDash) {
  10188. // PENDING
  10189. // Remove lineDash
  10190. ctx.setLineDash([]);
  10191. } // Draw rect text
  10192. if (style.text != null) {
  10193. // Only restore transform when needs draw text.
  10194. this.restoreTransform(ctx);
  10195. this.drawRectText(ctx, this.getBoundingRect());
  10196. }
  10197. },
  10198. // When bundling path, some shape may decide if use moveTo to begin a new subpath or closePath
  10199. // Like in circle
  10200. buildPath: function (ctx, shapeCfg, inBundle) {},
  10201. createPathProxy: function () {
  10202. this.path = new PathProxy();
  10203. },
  10204. getBoundingRect: function () {
  10205. var rect = this._rect;
  10206. var style = this.style;
  10207. var needsUpdateRect = !rect;
  10208. if (needsUpdateRect) {
  10209. var path = this.path;
  10210. if (!path) {
  10211. // Create path on demand.
  10212. path = this.path = new PathProxy();
  10213. }
  10214. if (this.__dirtyPath) {
  10215. path.beginPath();
  10216. this.buildPath(path, this.shape, false);
  10217. }
  10218. rect = path.getBoundingRect();
  10219. }
  10220. this._rect = rect;
  10221. if (style.hasStroke()) {
  10222. // Needs update rect with stroke lineWidth when
  10223. // 1. Element changes scale or lineWidth
  10224. // 2. Shape is changed
  10225. var rectWithStroke = this._rectWithStroke || (this._rectWithStroke = rect.clone());
  10226. if (this.__dirty || needsUpdateRect) {
  10227. rectWithStroke.copy(rect); // FIXME Must after updateTransform
  10228. var w = style.lineWidth; // PENDING, Min line width is needed when line is horizontal or vertical
  10229. var lineScale = style.strokeNoScale ? this.getLineScale() : 1; // Only add extra hover lineWidth when there are no fill
  10230. if (!style.hasFill()) {
  10231. w = Math.max(w, this.strokeContainThreshold || 4);
  10232. } // Consider line width
  10233. // Line scale can't be 0;
  10234. if (lineScale > 1e-10) {
  10235. rectWithStroke.width += w / lineScale;
  10236. rectWithStroke.height += w / lineScale;
  10237. rectWithStroke.x -= w / lineScale / 2;
  10238. rectWithStroke.y -= w / lineScale / 2;
  10239. }
  10240. } // Return rect with stroke
  10241. return rectWithStroke;
  10242. }
  10243. return rect;
  10244. },
  10245. contain: function (x, y) {
  10246. var localPos = this.transformCoordToLocal(x, y);
  10247. var rect = this.getBoundingRect();
  10248. var style = this.style;
  10249. x = localPos[0];
  10250. y = localPos[1];
  10251. if (rect.contain(x, y)) {
  10252. var pathData = this.path.data;
  10253. if (style.hasStroke()) {
  10254. var lineWidth = style.lineWidth;
  10255. var lineScale = style.strokeNoScale ? this.getLineScale() : 1; // Line scale can't be 0;
  10256. if (lineScale > 1e-10) {
  10257. // Only add extra hover lineWidth when there are no fill
  10258. if (!style.hasFill()) {
  10259. lineWidth = Math.max(lineWidth, this.strokeContainThreshold);
  10260. }
  10261. if (pathContain.containStroke(pathData, lineWidth / lineScale, x, y)) {
  10262. return true;
  10263. }
  10264. }
  10265. }
  10266. if (style.hasFill()) {
  10267. return pathContain.contain(pathData, x, y);
  10268. }
  10269. }
  10270. return false;
  10271. },
  10272. /**
  10273. * @param {boolean} dirtyPath
  10274. */
  10275. dirty: function (dirtyPath) {
  10276. if (dirtyPath == null) {
  10277. dirtyPath = true;
  10278. } // Only mark dirty, not mark clean
  10279. if (dirtyPath) {
  10280. this.__dirtyPath = dirtyPath;
  10281. this._rect = null;
  10282. }
  10283. this.__dirty = this.__dirtyText = true;
  10284. this.__zr && this.__zr.refresh(); // Used as a clipping path
  10285. if (this.__clipTarget) {
  10286. this.__clipTarget.dirty();
  10287. }
  10288. },
  10289. /**
  10290. * Alias for animate('shape')
  10291. * @param {boolean} loop
  10292. */
  10293. animateShape: function (loop) {
  10294. return this.animate('shape', loop);
  10295. },
  10296. // Overwrite attrKV
  10297. attrKV: function (key, value) {
  10298. // FIXME
  10299. if (key === 'shape') {
  10300. this.setShape(value);
  10301. this.__dirtyPath = true;
  10302. this._rect = null;
  10303. } else {
  10304. Displayable.prototype.attrKV.call(this, key, value);
  10305. }
  10306. },
  10307. /**
  10308. * @param {Object|string} key
  10309. * @param {*} value
  10310. */
  10311. setShape: function (key, value) {
  10312. var shape = this.shape; // Path from string may not have shape
  10313. if (shape) {
  10314. if (zrUtil.isObject(key)) {
  10315. for (var name in key) {
  10316. if (key.hasOwnProperty(name)) {
  10317. shape[name] = key[name];
  10318. }
  10319. }
  10320. } else {
  10321. shape[key] = value;
  10322. }
  10323. this.dirty(true);
  10324. }
  10325. return this;
  10326. },
  10327. getLineScale: function () {
  10328. var m = this.transform; // Get the line scale.
  10329. // Determinant of `m` means how much the area is enlarged by the
  10330. // transformation. So its square root can be used as a scale factor
  10331. // for width.
  10332. return m && abs(m[0] - 1) > 1e-10 && abs(m[3] - 1) > 1e-10 ? Math.sqrt(abs(m[0] * m[3] - m[2] * m[1])) : 1;
  10333. }
  10334. };
  10335. /**
  10336. * 扩展一个 Path element, 比如星形,圆等。
  10337. * Extend a path element
  10338. * @param {Object} props
  10339. * @param {string} props.type Path type
  10340. * @param {Function} props.init Initialize
  10341. * @param {Function} props.buildPath Overwrite buildPath method
  10342. * @param {Object} [props.style] Extended default style config
  10343. * @param {Object} [props.shape] Extended default shape config
  10344. */
  10345. Path.extend = function (defaults) {
  10346. var Sub = function (opts) {
  10347. Path.call(this, opts);
  10348. if (defaults.style) {
  10349. // Extend default style
  10350. this.style.extendFrom(defaults.style, false);
  10351. } // Extend default shape
  10352. var defaultShape = defaults.shape;
  10353. if (defaultShape) {
  10354. this.shape = this.shape || {};
  10355. var thisShape = this.shape;
  10356. for (var name in defaultShape) {
  10357. if (!thisShape.hasOwnProperty(name) && defaultShape.hasOwnProperty(name)) {
  10358. thisShape[name] = defaultShape[name];
  10359. }
  10360. }
  10361. }
  10362. defaults.init && defaults.init.call(this, opts);
  10363. };
  10364. zrUtil.inherits(Sub, Path); // FIXME 不能 extend position, rotation 等引用对象
  10365. for (var name in defaults) {
  10366. // Extending prototype values and methods
  10367. if (name !== 'style' && name !== 'shape') {
  10368. Sub.prototype[name] = defaults[name];
  10369. }
  10370. }
  10371. return Sub;
  10372. };
  10373. zrUtil.inherits(Path, Displayable);
  10374. var _default = Path;
  10375. module.exports = _default;
  10376. /***/ }),
  10377. /***/ "./node_modules/zrender/lib/graphic/Pattern.js":
  10378. /*!*****************************************************!*\
  10379. !*** ./node_modules/zrender/lib/graphic/Pattern.js ***!
  10380. \*****************************************************/
  10381. /*! no static exports found */
  10382. /***/ (function(module, exports) {
  10383. var Pattern = function (image, repeat) {
  10384. // Should do nothing more in this constructor. Because gradient can be
  10385. // declard by `color: {image: ...}`, where this constructor will not be called.
  10386. this.image = image;
  10387. this.repeat = repeat; // Can be cloned
  10388. this.type = 'pattern';
  10389. };
  10390. Pattern.prototype.getCanvasPattern = function (ctx) {
  10391. return ctx.createPattern(this.image, this.repeat || 'repeat');
  10392. };
  10393. var _default = Pattern;
  10394. module.exports = _default;
  10395. /***/ }),
  10396. /***/ "./node_modules/zrender/lib/graphic/RadialGradient.js":
  10397. /*!************************************************************!*\
  10398. !*** ./node_modules/zrender/lib/graphic/RadialGradient.js ***!
  10399. \************************************************************/
  10400. /*! no static exports found */
  10401. /***/ (function(module, exports, __webpack_require__) {
  10402. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  10403. var Gradient = __webpack_require__(/*! ./Gradient */ "./node_modules/zrender/lib/graphic/Gradient.js");
  10404. /**
  10405. * x, y, r are all percent from 0 to 1
  10406. * @param {number} [x=0.5]
  10407. * @param {number} [y=0.5]
  10408. * @param {number} [r=0.5]
  10409. * @param {Array.<Object>} [colorStops]
  10410. * @param {boolean} [globalCoord=false]
  10411. */
  10412. var RadialGradient = function (x, y, r, colorStops, globalCoord) {
  10413. // Should do nothing more in this constructor. Because gradient can be
  10414. // declard by `color: {type: 'radial', colorStops: ...}`, where
  10415. // this constructor will not be called.
  10416. this.x = x == null ? 0.5 : x;
  10417. this.y = y == null ? 0.5 : y;
  10418. this.r = r == null ? 0.5 : r; // Can be cloned
  10419. this.type = 'radial'; // If use global coord
  10420. this.global = globalCoord || false;
  10421. Gradient.call(this, colorStops);
  10422. };
  10423. RadialGradient.prototype = {
  10424. constructor: RadialGradient
  10425. };
  10426. zrUtil.inherits(RadialGradient, Gradient);
  10427. var _default = RadialGradient;
  10428. module.exports = _default;
  10429. /***/ }),
  10430. /***/ "./node_modules/zrender/lib/graphic/Style.js":
  10431. /*!***************************************************!*\
  10432. !*** ./node_modules/zrender/lib/graphic/Style.js ***!
  10433. \***************************************************/
  10434. /*! no static exports found */
  10435. /***/ (function(module, exports, __webpack_require__) {
  10436. var fixShadow = __webpack_require__(/*! ./helper/fixShadow */ "./node_modules/zrender/lib/graphic/helper/fixShadow.js");
  10437. var _constant = __webpack_require__(/*! ./constant */ "./node_modules/zrender/lib/graphic/constant.js");
  10438. var ContextCachedBy = _constant.ContextCachedBy;
  10439. var STYLE_COMMON_PROPS = [['shadowBlur', 0], ['shadowOffsetX', 0], ['shadowOffsetY', 0], ['shadowColor', '#000'], ['lineCap', 'butt'], ['lineJoin', 'miter'], ['miterLimit', 10]]; // var SHADOW_PROPS = STYLE_COMMON_PROPS.slice(0, 4);
  10440. // var LINE_PROPS = STYLE_COMMON_PROPS.slice(4);
  10441. var Style = function (opts) {
  10442. this.extendFrom(opts, false);
  10443. };
  10444. function createLinearGradient(ctx, obj, rect) {
  10445. var x = obj.x == null ? 0 : obj.x;
  10446. var x2 = obj.x2 == null ? 1 : obj.x2;
  10447. var y = obj.y == null ? 0 : obj.y;
  10448. var y2 = obj.y2 == null ? 0 : obj.y2;
  10449. if (!obj.global) {
  10450. x = x * rect.width + rect.x;
  10451. x2 = x2 * rect.width + rect.x;
  10452. y = y * rect.height + rect.y;
  10453. y2 = y2 * rect.height + rect.y;
  10454. } // Fix NaN when rect is Infinity
  10455. x = isNaN(x) ? 0 : x;
  10456. x2 = isNaN(x2) ? 1 : x2;
  10457. y = isNaN(y) ? 0 : y;
  10458. y2 = isNaN(y2) ? 0 : y2;
  10459. var canvasGradient = ctx.createLinearGradient(x, y, x2, y2);
  10460. return canvasGradient;
  10461. }
  10462. function createRadialGradient(ctx, obj, rect) {
  10463. var width = rect.width;
  10464. var height = rect.height;
  10465. var min = Math.min(width, height);
  10466. var x = obj.x == null ? 0.5 : obj.x;
  10467. var y = obj.y == null ? 0.5 : obj.y;
  10468. var r = obj.r == null ? 0.5 : obj.r;
  10469. if (!obj.global) {
  10470. x = x * width + rect.x;
  10471. y = y * height + rect.y;
  10472. r = r * min;
  10473. }
  10474. var canvasGradient = ctx.createRadialGradient(x, y, 0, x, y, r);
  10475. return canvasGradient;
  10476. }
  10477. Style.prototype = {
  10478. constructor: Style,
  10479. /**
  10480. * @type {string}
  10481. */
  10482. fill: '#000',
  10483. /**
  10484. * @type {string}
  10485. */
  10486. stroke: null,
  10487. /**
  10488. * @type {number}
  10489. */
  10490. opacity: 1,
  10491. /**
  10492. * @type {number}
  10493. */
  10494. fillOpacity: null,
  10495. /**
  10496. * @type {number}
  10497. */
  10498. strokeOpacity: null,
  10499. /**
  10500. * `true` is not supported.
  10501. * `false`/`null`/`undefined` are the same.
  10502. * `false` is used to remove lineDash in some
  10503. * case that `null`/`undefined` can not be set.
  10504. * (e.g., emphasis.lineStyle in echarts)
  10505. * @type {Array.<number>|boolean}
  10506. */
  10507. lineDash: null,
  10508. /**
  10509. * @type {number}
  10510. */
  10511. lineDashOffset: 0,
  10512. /**
  10513. * @type {number}
  10514. */
  10515. shadowBlur: 0,
  10516. /**
  10517. * @type {number}
  10518. */
  10519. shadowOffsetX: 0,
  10520. /**
  10521. * @type {number}
  10522. */
  10523. shadowOffsetY: 0,
  10524. /**
  10525. * @type {number}
  10526. */
  10527. lineWidth: 1,
  10528. /**
  10529. * If stroke ignore scale
  10530. * @type {Boolean}
  10531. */
  10532. strokeNoScale: false,
  10533. // Bounding rect text configuration
  10534. // Not affected by element transform
  10535. /**
  10536. * @type {string}
  10537. */
  10538. text: null,
  10539. /**
  10540. * If `fontSize` or `fontFamily` exists, `font` will be reset by
  10541. * `fontSize`, `fontStyle`, `fontWeight`, `fontFamily`.
  10542. * So do not visit it directly in upper application (like echarts),
  10543. * but use `contain/text#makeFont` instead.
  10544. * @type {string}
  10545. */
  10546. font: null,
  10547. /**
  10548. * The same as font. Use font please.
  10549. * @deprecated
  10550. * @type {string}
  10551. */
  10552. textFont: null,
  10553. /**
  10554. * It helps merging respectively, rather than parsing an entire font string.
  10555. * @type {string}
  10556. */
  10557. fontStyle: null,
  10558. /**
  10559. * It helps merging respectively, rather than parsing an entire font string.
  10560. * @type {string}
  10561. */
  10562. fontWeight: null,
  10563. /**
  10564. * It helps merging respectively, rather than parsing an entire font string.
  10565. * Should be 12 but not '12px'.
  10566. * @type {number}
  10567. */
  10568. fontSize: null,
  10569. /**
  10570. * It helps merging respectively, rather than parsing an entire font string.
  10571. * @type {string}
  10572. */
  10573. fontFamily: null,
  10574. /**
  10575. * Reserved for special functinality, like 'hr'.
  10576. * @type {string}
  10577. */
  10578. textTag: null,
  10579. /**
  10580. * @type {string}
  10581. */
  10582. textFill: '#000',
  10583. /**
  10584. * @type {string}
  10585. */
  10586. textStroke: null,
  10587. /**
  10588. * @type {number}
  10589. */
  10590. textWidth: null,
  10591. /**
  10592. * Only for textBackground.
  10593. * @type {number}
  10594. */
  10595. textHeight: null,
  10596. /**
  10597. * textStroke may be set as some color as a default
  10598. * value in upper applicaion, where the default value
  10599. * of textStrokeWidth should be 0 to make sure that
  10600. * user can choose to do not use text stroke.
  10601. * @type {number}
  10602. */
  10603. textStrokeWidth: 0,
  10604. /**
  10605. * @type {number}
  10606. */
  10607. textLineHeight: null,
  10608. /**
  10609. * 'inside', 'left', 'right', 'top', 'bottom'
  10610. * [x, y]
  10611. * Based on x, y of rect.
  10612. * @type {string|Array.<number>}
  10613. * @default 'inside'
  10614. */
  10615. textPosition: 'inside',
  10616. /**
  10617. * If not specified, use the boundingRect of a `displayable`.
  10618. * @type {Object}
  10619. */
  10620. textRect: null,
  10621. /**
  10622. * [x, y]
  10623. * @type {Array.<number>}
  10624. */
  10625. textOffset: null,
  10626. /**
  10627. * @type {string}
  10628. */
  10629. textAlign: null,
  10630. /**
  10631. * @type {string}
  10632. */
  10633. textVerticalAlign: null,
  10634. /**
  10635. * @type {number}
  10636. */
  10637. textDistance: 5,
  10638. /**
  10639. * @type {string}
  10640. */
  10641. textShadowColor: 'transparent',
  10642. /**
  10643. * @type {number}
  10644. */
  10645. textShadowBlur: 0,
  10646. /**
  10647. * @type {number}
  10648. */
  10649. textShadowOffsetX: 0,
  10650. /**
  10651. * @type {number}
  10652. */
  10653. textShadowOffsetY: 0,
  10654. /**
  10655. * @type {string}
  10656. */
  10657. textBoxShadowColor: 'transparent',
  10658. /**
  10659. * @type {number}
  10660. */
  10661. textBoxShadowBlur: 0,
  10662. /**
  10663. * @type {number}
  10664. */
  10665. textBoxShadowOffsetX: 0,
  10666. /**
  10667. * @type {number}
  10668. */
  10669. textBoxShadowOffsetY: 0,
  10670. /**
  10671. * Whether transform text.
  10672. * Only available in Path and Image element,
  10673. * where the text is called as `RectText`.
  10674. * @type {boolean}
  10675. */
  10676. transformText: false,
  10677. /**
  10678. * Text rotate around position of Path or Image.
  10679. * The origin of the rotation can be specified by `textOrigin`.
  10680. * Only available in Path and Image element,
  10681. * where the text is called as `RectText`.
  10682. */
  10683. textRotation: 0,
  10684. /**
  10685. * Text origin of text rotation.
  10686. * Useful in the case like label rotation of circular symbol.
  10687. * Only available in Path and Image element, where the text is called
  10688. * as `RectText` and the element is called as "host element".
  10689. * The value can be:
  10690. * + If specified as a coordinate like `[10, 40]`, it is the `[x, y]`
  10691. * base on the left-top corner of the rect of its host element.
  10692. * + If specified as a string `center`, it is the center of the rect of
  10693. * its host element.
  10694. * + By default, this origin is the `textPosition`.
  10695. * @type {string|Array.<number>}
  10696. */
  10697. textOrigin: null,
  10698. /**
  10699. * @type {string}
  10700. */
  10701. textBackgroundColor: null,
  10702. /**
  10703. * @type {string}
  10704. */
  10705. textBorderColor: null,
  10706. /**
  10707. * @type {number}
  10708. */
  10709. textBorderWidth: 0,
  10710. /**
  10711. * @type {number}
  10712. */
  10713. textBorderRadius: 0,
  10714. /**
  10715. * Can be `2` or `[2, 4]` or `[2, 3, 4, 5]`
  10716. * @type {number|Array.<number>}
  10717. */
  10718. textPadding: null,
  10719. /**
  10720. * Text styles for rich text.
  10721. * @type {Object}
  10722. */
  10723. rich: null,
  10724. /**
  10725. * {outerWidth, outerHeight, ellipsis, placeholder}
  10726. * @type {Object}
  10727. */
  10728. truncate: null,
  10729. /**
  10730. * https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
  10731. * @type {string}
  10732. */
  10733. blend: null,
  10734. /**
  10735. * @param {CanvasRenderingContext2D} ctx
  10736. */
  10737. bind: function (ctx, el, prevEl) {
  10738. var style = this;
  10739. var prevStyle = prevEl && prevEl.style; // If no prevStyle, it means first draw.
  10740. // Only apply cache if the last time cachced by this function.
  10741. var notCheckCache = !prevStyle || ctx.__attrCachedBy !== ContextCachedBy.STYLE_BIND;
  10742. ctx.__attrCachedBy = ContextCachedBy.STYLE_BIND;
  10743. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  10744. var prop = STYLE_COMMON_PROPS[i];
  10745. var styleName = prop[0];
  10746. if (notCheckCache || style[styleName] !== prevStyle[styleName]) {
  10747. // FIXME Invalid property value will cause style leak from previous element.
  10748. ctx[styleName] = fixShadow(ctx, styleName, style[styleName] || prop[1]);
  10749. }
  10750. }
  10751. if (notCheckCache || style.fill !== prevStyle.fill) {
  10752. ctx.fillStyle = style.fill;
  10753. }
  10754. if (notCheckCache || style.stroke !== prevStyle.stroke) {
  10755. ctx.strokeStyle = style.stroke;
  10756. }
  10757. if (notCheckCache || style.opacity !== prevStyle.opacity) {
  10758. ctx.globalAlpha = style.opacity == null ? 1 : style.opacity;
  10759. }
  10760. if (notCheckCache || style.blend !== prevStyle.blend) {
  10761. ctx.globalCompositeOperation = style.blend || 'source-over';
  10762. }
  10763. if (this.hasStroke()) {
  10764. var lineWidth = style.lineWidth;
  10765. ctx.lineWidth = lineWidth / (this.strokeNoScale && el && el.getLineScale ? el.getLineScale() : 1);
  10766. }
  10767. },
  10768. hasFill: function () {
  10769. var fill = this.fill;
  10770. return fill != null && fill !== 'none';
  10771. },
  10772. hasStroke: function () {
  10773. var stroke = this.stroke;
  10774. return stroke != null && stroke !== 'none' && this.lineWidth > 0;
  10775. },
  10776. /**
  10777. * Extend from other style
  10778. * @param {zrender/graphic/Style} otherStyle
  10779. * @param {boolean} overwrite true: overwrirte any way.
  10780. * false: overwrite only when !target.hasOwnProperty
  10781. * others: overwrite when property is not null/undefined.
  10782. */
  10783. extendFrom: function (otherStyle, overwrite) {
  10784. if (otherStyle) {
  10785. for (var name in otherStyle) {
  10786. if (otherStyle.hasOwnProperty(name) && (overwrite === true || (overwrite === false ? !this.hasOwnProperty(name) : otherStyle[name] != null))) {
  10787. this[name] = otherStyle[name];
  10788. }
  10789. }
  10790. }
  10791. },
  10792. /**
  10793. * Batch setting style with a given object
  10794. * @param {Object|string} obj
  10795. * @param {*} [obj]
  10796. */
  10797. set: function (obj, value) {
  10798. if (typeof obj === 'string') {
  10799. this[obj] = value;
  10800. } else {
  10801. this.extendFrom(obj, true);
  10802. }
  10803. },
  10804. /**
  10805. * Clone
  10806. * @return {zrender/graphic/Style} [description]
  10807. */
  10808. clone: function () {
  10809. var newStyle = new this.constructor();
  10810. newStyle.extendFrom(this, true);
  10811. return newStyle;
  10812. },
  10813. getGradient: function (ctx, obj, rect) {
  10814. var method = obj.type === 'radial' ? createRadialGradient : createLinearGradient;
  10815. var canvasGradient = method(ctx, obj, rect);
  10816. var colorStops = obj.colorStops;
  10817. for (var i = 0; i < colorStops.length; i++) {
  10818. canvasGradient.addColorStop(colorStops[i].offset, colorStops[i].color);
  10819. }
  10820. return canvasGradient;
  10821. }
  10822. };
  10823. var styleProto = Style.prototype;
  10824. for (var i = 0; i < STYLE_COMMON_PROPS.length; i++) {
  10825. var prop = STYLE_COMMON_PROPS[i];
  10826. if (!(prop[0] in styleProto)) {
  10827. styleProto[prop[0]] = prop[1];
  10828. }
  10829. } // Provide for others
  10830. Style.getGradient = styleProto.getGradient;
  10831. var _default = Style;
  10832. module.exports = _default;
  10833. /***/ }),
  10834. /***/ "./node_modules/zrender/lib/graphic/Text.js":
  10835. /*!**************************************************!*\
  10836. !*** ./node_modules/zrender/lib/graphic/Text.js ***!
  10837. \**************************************************/
  10838. /*! no static exports found */
  10839. /***/ (function(module, exports, __webpack_require__) {
  10840. var Displayable = __webpack_require__(/*! ./Displayable */ "./node_modules/zrender/lib/graphic/Displayable.js");
  10841. var zrUtil = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  10842. var textContain = __webpack_require__(/*! ../contain/text */ "./node_modules/zrender/lib/contain/text.js");
  10843. var textHelper = __webpack_require__(/*! ./helper/text */ "./node_modules/zrender/lib/graphic/helper/text.js");
  10844. var _constant = __webpack_require__(/*! ./constant */ "./node_modules/zrender/lib/graphic/constant.js");
  10845. var ContextCachedBy = _constant.ContextCachedBy;
  10846. /**
  10847. * @alias zrender/graphic/Text
  10848. * @extends module:zrender/graphic/Displayable
  10849. * @constructor
  10850. * @param {Object} opts
  10851. */
  10852. var Text = function (opts) {
  10853. // jshint ignore:line
  10854. Displayable.call(this, opts);
  10855. };
  10856. Text.prototype = {
  10857. constructor: Text,
  10858. type: 'text',
  10859. brush: function (ctx, prevEl) {
  10860. var style = this.style; // Optimize, avoid normalize every time.
  10861. this.__dirty && textHelper.normalizeTextStyle(style, true); // Use props with prefix 'text'.
  10862. style.fill = style.stroke = style.shadowBlur = style.shadowColor = style.shadowOffsetX = style.shadowOffsetY = null;
  10863. var text = style.text; // Convert to string
  10864. text != null && (text += ''); // Do not apply style.bind in Text node. Because the real bind job
  10865. // is in textHelper.renderText, and performance of text render should
  10866. // be considered.
  10867. // style.bind(ctx, this, prevEl);
  10868. if (!textHelper.needDrawText(text, style)) {
  10869. // The current el.style is not applied
  10870. // and should not be used as cache.
  10871. ctx.__attrCachedBy = ContextCachedBy.NONE;
  10872. return;
  10873. }
  10874. this.setTransform(ctx);
  10875. textHelper.renderText(this, ctx, text, style, null, prevEl);
  10876. this.restoreTransform(ctx);
  10877. },
  10878. getBoundingRect: function () {
  10879. var style = this.style; // Optimize, avoid normalize every time.
  10880. this.__dirty && textHelper.normalizeTextStyle(style, true);
  10881. if (!this._rect) {
  10882. var text = style.text;
  10883. text != null ? text += '' : text = '';
  10884. var rect = textContain.getBoundingRect(style.text + '', style.font, style.textAlign, style.textVerticalAlign, style.textPadding, style.textLineHeight, style.rich);
  10885. rect.x += style.x || 0;
  10886. rect.y += style.y || 0;
  10887. if (textHelper.getStroke(style.textStroke, style.textStrokeWidth)) {
  10888. var w = style.textStrokeWidth;
  10889. rect.x -= w / 2;
  10890. rect.y -= w / 2;
  10891. rect.width += w;
  10892. rect.height += w;
  10893. }
  10894. this._rect = rect;
  10895. }
  10896. return this._rect;
  10897. }
  10898. };
  10899. zrUtil.inherits(Text, Displayable);
  10900. var _default = Text;
  10901. module.exports = _default;
  10902. /***/ }),
  10903. /***/ "./node_modules/zrender/lib/graphic/constant.js":
  10904. /*!******************************************************!*\
  10905. !*** ./node_modules/zrender/lib/graphic/constant.js ***!
  10906. \******************************************************/
  10907. /*! no static exports found */
  10908. /***/ (function(module, exports) {
  10909. var ContextCachedBy = {
  10910. NONE: 0,
  10911. STYLE_BIND: 1,
  10912. PLAIN_TEXT: 2
  10913. }; // Avoid confused with 0/false.
  10914. var WILL_BE_RESTORED = 9;
  10915. exports.ContextCachedBy = ContextCachedBy;
  10916. exports.WILL_BE_RESTORED = WILL_BE_RESTORED;
  10917. /***/ }),
  10918. /***/ "./node_modules/zrender/lib/graphic/helper/fixClipWithShadow.js":
  10919. /*!**********************************************************************!*\
  10920. !*** ./node_modules/zrender/lib/graphic/helper/fixClipWithShadow.js ***!
  10921. \**********************************************************************/
  10922. /*! no static exports found */
  10923. /***/ (function(module, exports, __webpack_require__) {
  10924. var env = __webpack_require__(/*! ../../core/env */ "./node_modules/zrender/lib/core/env.js");
  10925. // Fix weird bug in some version of IE11 (like 11.0.9600.178**),
  10926. // where exception "unexpected call to method or property access"
  10927. // might be thrown when calling ctx.fill or ctx.stroke after a path
  10928. // whose area size is zero is drawn and ctx.clip() is called and
  10929. // shadowBlur is set. See #4572, #3112, #5777.
  10930. // (e.g.,
  10931. // ctx.moveTo(10, 10);
  10932. // ctx.lineTo(20, 10);
  10933. // ctx.closePath();
  10934. // ctx.clip();
  10935. // ctx.shadowBlur = 10;
  10936. // ...
  10937. // ctx.fill();
  10938. // )
  10939. var shadowTemp = [['shadowBlur', 0], ['shadowColor', '#000'], ['shadowOffsetX', 0], ['shadowOffsetY', 0]];
  10940. function _default(orignalBrush) {
  10941. // version string can be: '11.0'
  10942. return env.browser.ie && env.browser.version >= 11 ? function () {
  10943. var clipPaths = this.__clipPaths;
  10944. var style = this.style;
  10945. var modified;
  10946. if (clipPaths) {
  10947. for (var i = 0; i < clipPaths.length; i++) {
  10948. var clipPath = clipPaths[i];
  10949. var shape = clipPath && clipPath.shape;
  10950. var type = clipPath && clipPath.type;
  10951. if (shape && (type === 'sector' && shape.startAngle === shape.endAngle || type === 'rect' && (!shape.width || !shape.height))) {
  10952. for (var j = 0; j < shadowTemp.length; j++) {
  10953. // It is save to put shadowTemp static, because shadowTemp
  10954. // will be all modified each item brush called.
  10955. shadowTemp[j][2] = style[shadowTemp[j][0]];
  10956. style[shadowTemp[j][0]] = shadowTemp[j][1];
  10957. }
  10958. modified = true;
  10959. break;
  10960. }
  10961. }
  10962. }
  10963. orignalBrush.apply(this, arguments);
  10964. if (modified) {
  10965. for (var j = 0; j < shadowTemp.length; j++) {
  10966. style[shadowTemp[j][0]] = shadowTemp[j][2];
  10967. }
  10968. }
  10969. } : orignalBrush;
  10970. }
  10971. module.exports = _default;
  10972. /***/ }),
  10973. /***/ "./node_modules/zrender/lib/graphic/helper/fixShadow.js":
  10974. /*!**************************************************************!*\
  10975. !*** ./node_modules/zrender/lib/graphic/helper/fixShadow.js ***!
  10976. \**************************************************************/
  10977. /*! no static exports found */
  10978. /***/ (function(module, exports) {
  10979. var SHADOW_PROPS = {
  10980. 'shadowBlur': 1,
  10981. 'shadowOffsetX': 1,
  10982. 'shadowOffsetY': 1,
  10983. 'textShadowBlur': 1,
  10984. 'textShadowOffsetX': 1,
  10985. 'textShadowOffsetY': 1,
  10986. 'textBoxShadowBlur': 1,
  10987. 'textBoxShadowOffsetX': 1,
  10988. 'textBoxShadowOffsetY': 1
  10989. };
  10990. function _default(ctx, propName, value) {
  10991. if (SHADOW_PROPS.hasOwnProperty(propName)) {
  10992. return value *= ctx.dpr;
  10993. }
  10994. return value;
  10995. }
  10996. module.exports = _default;
  10997. /***/ }),
  10998. /***/ "./node_modules/zrender/lib/graphic/helper/image.js":
  10999. /*!**********************************************************!*\
  11000. !*** ./node_modules/zrender/lib/graphic/helper/image.js ***!
  11001. \**********************************************************/
  11002. /*! no static exports found */
  11003. /***/ (function(module, exports, __webpack_require__) {
  11004. var LRU = __webpack_require__(/*! ../../core/LRU */ "./node_modules/zrender/lib/core/LRU.js");
  11005. var globalImageCache = new LRU(50);
  11006. /**
  11007. * @param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
  11008. * @return {HTMLImageElement|HTMLCanvasElement|Canvas} image
  11009. */
  11010. function findExistImage(newImageOrSrc) {
  11011. if (typeof newImageOrSrc === 'string') {
  11012. var cachedImgObj = globalImageCache.get(newImageOrSrc);
  11013. return cachedImgObj && cachedImgObj.image;
  11014. } else {
  11015. return newImageOrSrc;
  11016. }
  11017. }
  11018. /**
  11019. * Caution: User should cache loaded images, but not just count on LRU.
  11020. * Consider if required images more than LRU size, will dead loop occur?
  11021. *
  11022. * @param {string|HTMLImageElement|HTMLCanvasElement|Canvas} newImageOrSrc
  11023. * @param {HTMLImageElement|HTMLCanvasElement|Canvas} image Existent image.
  11024. * @param {module:zrender/Element} [hostEl] For calling `dirty`.
  11025. * @param {Function} [cb] params: (image, cbPayload)
  11026. * @param {Object} [cbPayload] Payload on cb calling.
  11027. * @return {HTMLImageElement|HTMLCanvasElement|Canvas} image
  11028. */
  11029. function createOrUpdateImage(newImageOrSrc, image, hostEl, cb, cbPayload) {
  11030. if (!newImageOrSrc) {
  11031. return image;
  11032. } else if (typeof newImageOrSrc === 'string') {
  11033. // Image should not be loaded repeatly.
  11034. if (image && image.__zrImageSrc === newImageOrSrc || !hostEl) {
  11035. return image;
  11036. } // Only when there is no existent image or existent image src
  11037. // is different, this method is responsible for load.
  11038. var cachedImgObj = globalImageCache.get(newImageOrSrc);
  11039. var pendingWrap = {
  11040. hostEl: hostEl,
  11041. cb: cb,
  11042. cbPayload: cbPayload
  11043. };
  11044. if (cachedImgObj) {
  11045. image = cachedImgObj.image;
  11046. !isImageReady(image) && cachedImgObj.pending.push(pendingWrap);
  11047. } else {
  11048. image = new Image();
  11049. image.onload = image.onerror = imageOnLoad;
  11050. globalImageCache.put(newImageOrSrc, image.__cachedImgObj = {
  11051. image: image,
  11052. pending: [pendingWrap]
  11053. });
  11054. image.src = image.__zrImageSrc = newImageOrSrc;
  11055. }
  11056. return image;
  11057. } // newImageOrSrc is an HTMLImageElement or HTMLCanvasElement or Canvas
  11058. else {
  11059. return newImageOrSrc;
  11060. }
  11061. }
  11062. function imageOnLoad() {
  11063. var cachedImgObj = this.__cachedImgObj;
  11064. this.onload = this.onerror = this.__cachedImgObj = null;
  11065. for (var i = 0; i < cachedImgObj.pending.length; i++) {
  11066. var pendingWrap = cachedImgObj.pending[i];
  11067. var cb = pendingWrap.cb;
  11068. cb && cb(this, pendingWrap.cbPayload);
  11069. pendingWrap.hostEl.dirty();
  11070. }
  11071. cachedImgObj.pending.length = 0;
  11072. }
  11073. function isImageReady(image) {
  11074. return image && image.width && image.height;
  11075. }
  11076. exports.findExistImage = findExistImage;
  11077. exports.createOrUpdateImage = createOrUpdateImage;
  11078. exports.isImageReady = isImageReady;
  11079. /***/ }),
  11080. /***/ "./node_modules/zrender/lib/graphic/helper/poly.js":
  11081. /*!*********************************************************!*\
  11082. !*** ./node_modules/zrender/lib/graphic/helper/poly.js ***!
  11083. \*********************************************************/
  11084. /*! no static exports found */
  11085. /***/ (function(module, exports, __webpack_require__) {
  11086. var smoothSpline = __webpack_require__(/*! ./smoothSpline */ "./node_modules/zrender/lib/graphic/helper/smoothSpline.js");
  11087. var smoothBezier = __webpack_require__(/*! ./smoothBezier */ "./node_modules/zrender/lib/graphic/helper/smoothBezier.js");
  11088. function buildPath(ctx, shape, closePath) {
  11089. var points = shape.points;
  11090. var smooth = shape.smooth;
  11091. if (points && points.length >= 2) {
  11092. if (smooth && smooth !== 'spline') {
  11093. var controlPoints = smoothBezier(points, smooth, closePath, shape.smoothConstraint);
  11094. ctx.moveTo(points[0][0], points[0][1]);
  11095. var len = points.length;
  11096. for (var i = 0; i < (closePath ? len : len - 1); i++) {
  11097. var cp1 = controlPoints[i * 2];
  11098. var cp2 = controlPoints[i * 2 + 1];
  11099. var p = points[(i + 1) % len];
  11100. ctx.bezierCurveTo(cp1[0], cp1[1], cp2[0], cp2[1], p[0], p[1]);
  11101. }
  11102. } else {
  11103. if (smooth === 'spline') {
  11104. points = smoothSpline(points, closePath);
  11105. }
  11106. ctx.moveTo(points[0][0], points[0][1]);
  11107. for (var i = 1, l = points.length; i < l; i++) {
  11108. ctx.lineTo(points[i][0], points[i][1]);
  11109. }
  11110. }
  11111. closePath && ctx.closePath();
  11112. }
  11113. }
  11114. exports.buildPath = buildPath;
  11115. /***/ }),
  11116. /***/ "./node_modules/zrender/lib/graphic/helper/roundRect.js":
  11117. /*!**************************************************************!*\
  11118. !*** ./node_modules/zrender/lib/graphic/helper/roundRect.js ***!
  11119. \**************************************************************/
  11120. /*! no static exports found */
  11121. /***/ (function(module, exports) {
  11122. /**
  11123. * @param {Object} ctx
  11124. * @param {Object} shape
  11125. * @param {number} shape.x
  11126. * @param {number} shape.y
  11127. * @param {number} shape.width
  11128. * @param {number} shape.height
  11129. * @param {number} shape.r
  11130. */
  11131. function buildPath(ctx, shape) {
  11132. var x = shape.x;
  11133. var y = shape.y;
  11134. var width = shape.width;
  11135. var height = shape.height;
  11136. var r = shape.r;
  11137. var r1;
  11138. var r2;
  11139. var r3;
  11140. var r4; // Convert width and height to positive for better borderRadius
  11141. if (width < 0) {
  11142. x = x + width;
  11143. width = -width;
  11144. }
  11145. if (height < 0) {
  11146. y = y + height;
  11147. height = -height;
  11148. }
  11149. if (typeof r === 'number') {
  11150. r1 = r2 = r3 = r4 = r;
  11151. } else if (r instanceof Array) {
  11152. if (r.length === 1) {
  11153. r1 = r2 = r3 = r4 = r[0];
  11154. } else if (r.length === 2) {
  11155. r1 = r3 = r[0];
  11156. r2 = r4 = r[1];
  11157. } else if (r.length === 3) {
  11158. r1 = r[0];
  11159. r2 = r4 = r[1];
  11160. r3 = r[2];
  11161. } else {
  11162. r1 = r[0];
  11163. r2 = r[1];
  11164. r3 = r[2];
  11165. r4 = r[3];
  11166. }
  11167. } else {
  11168. r1 = r2 = r3 = r4 = 0;
  11169. }
  11170. var total;
  11171. if (r1 + r2 > width) {
  11172. total = r1 + r2;
  11173. r1 *= width / total;
  11174. r2 *= width / total;
  11175. }
  11176. if (r3 + r4 > width) {
  11177. total = r3 + r4;
  11178. r3 *= width / total;
  11179. r4 *= width / total;
  11180. }
  11181. if (r2 + r3 > height) {
  11182. total = r2 + r3;
  11183. r2 *= height / total;
  11184. r3 *= height / total;
  11185. }
  11186. if (r1 + r4 > height) {
  11187. total = r1 + r4;
  11188. r1 *= height / total;
  11189. r4 *= height / total;
  11190. }
  11191. ctx.moveTo(x + r1, y);
  11192. ctx.lineTo(x + width - r2, y);
  11193. r2 !== 0 && ctx.arc(x + width - r2, y + r2, r2, -Math.PI / 2, 0);
  11194. ctx.lineTo(x + width, y + height - r3);
  11195. r3 !== 0 && ctx.arc(x + width - r3, y + height - r3, r3, 0, Math.PI / 2);
  11196. ctx.lineTo(x + r4, y + height);
  11197. r4 !== 0 && ctx.arc(x + r4, y + height - r4, r4, Math.PI / 2, Math.PI);
  11198. ctx.lineTo(x, y + r1);
  11199. r1 !== 0 && ctx.arc(x + r1, y + r1, r1, Math.PI, Math.PI * 1.5);
  11200. }
  11201. exports.buildPath = buildPath;
  11202. /***/ }),
  11203. /***/ "./node_modules/zrender/lib/graphic/helper/smoothBezier.js":
  11204. /*!*****************************************************************!*\
  11205. !*** ./node_modules/zrender/lib/graphic/helper/smoothBezier.js ***!
  11206. \*****************************************************************/
  11207. /*! no static exports found */
  11208. /***/ (function(module, exports, __webpack_require__) {
  11209. var _vector = __webpack_require__(/*! ../../core/vector */ "./node_modules/zrender/lib/core/vector.js");
  11210. var v2Min = _vector.min;
  11211. var v2Max = _vector.max;
  11212. var v2Scale = _vector.scale;
  11213. var v2Distance = _vector.distance;
  11214. var v2Add = _vector.add;
  11215. var v2Clone = _vector.clone;
  11216. var v2Sub = _vector.sub;
  11217. /**
  11218. * 贝塞尔平滑曲线
  11219. * @module zrender/shape/util/smoothBezier
  11220. * @author pissang (https://www.github.com/pissang)
  11221. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  11222. * errorrik (errorrik@gmail.com)
  11223. */
  11224. /**
  11225. * 贝塞尔平滑曲线
  11226. * @alias module:zrender/shape/util/smoothBezier
  11227. * @param {Array} points 线段顶点数组
  11228. * @param {number} smooth 平滑等级, 0-1
  11229. * @param {boolean} isLoop
  11230. * @param {Array} constraint 将计算出来的控制点约束在一个包围盒内
  11231. * 比如 [[0, 0], [100, 100]], 这个包围盒会与
  11232. * 整个折线的包围盒做一个并集用来约束控制点。
  11233. * @param {Array} 计算出来的控制点数组
  11234. */
  11235. function _default(points, smooth, isLoop, constraint) {
  11236. var cps = [];
  11237. var v = [];
  11238. var v1 = [];
  11239. var v2 = [];
  11240. var prevPoint;
  11241. var nextPoint;
  11242. var min;
  11243. var max;
  11244. if (constraint) {
  11245. min = [Infinity, Infinity];
  11246. max = [-Infinity, -Infinity];
  11247. for (var i = 0, len = points.length; i < len; i++) {
  11248. v2Min(min, min, points[i]);
  11249. v2Max(max, max, points[i]);
  11250. } // 与指定的包围盒做并集
  11251. v2Min(min, min, constraint[0]);
  11252. v2Max(max, max, constraint[1]);
  11253. }
  11254. for (var i = 0, len = points.length; i < len; i++) {
  11255. var point = points[i];
  11256. if (isLoop) {
  11257. prevPoint = points[i ? i - 1 : len - 1];
  11258. nextPoint = points[(i + 1) % len];
  11259. } else {
  11260. if (i === 0 || i === len - 1) {
  11261. cps.push(v2Clone(points[i]));
  11262. continue;
  11263. } else {
  11264. prevPoint = points[i - 1];
  11265. nextPoint = points[i + 1];
  11266. }
  11267. }
  11268. v2Sub(v, nextPoint, prevPoint); // use degree to scale the handle length
  11269. v2Scale(v, v, smooth);
  11270. var d0 = v2Distance(point, prevPoint);
  11271. var d1 = v2Distance(point, nextPoint);
  11272. var sum = d0 + d1;
  11273. if (sum !== 0) {
  11274. d0 /= sum;
  11275. d1 /= sum;
  11276. }
  11277. v2Scale(v1, v, -d0);
  11278. v2Scale(v2, v, d1);
  11279. var cp0 = v2Add([], point, v1);
  11280. var cp1 = v2Add([], point, v2);
  11281. if (constraint) {
  11282. v2Max(cp0, cp0, min);
  11283. v2Min(cp0, cp0, max);
  11284. v2Max(cp1, cp1, min);
  11285. v2Min(cp1, cp1, max);
  11286. }
  11287. cps.push(cp0);
  11288. cps.push(cp1);
  11289. }
  11290. if (isLoop) {
  11291. cps.push(cps.shift());
  11292. }
  11293. return cps;
  11294. }
  11295. module.exports = _default;
  11296. /***/ }),
  11297. /***/ "./node_modules/zrender/lib/graphic/helper/smoothSpline.js":
  11298. /*!*****************************************************************!*\
  11299. !*** ./node_modules/zrender/lib/graphic/helper/smoothSpline.js ***!
  11300. \*****************************************************************/
  11301. /*! no static exports found */
  11302. /***/ (function(module, exports, __webpack_require__) {
  11303. var _vector = __webpack_require__(/*! ../../core/vector */ "./node_modules/zrender/lib/core/vector.js");
  11304. var v2Distance = _vector.distance;
  11305. /**
  11306. * Catmull-Rom spline 插值折线
  11307. * @module zrender/shape/util/smoothSpline
  11308. * @author pissang (https://www.github.com/pissang)
  11309. * Kener (@Kener-林峰, kener.linfeng@gmail.com)
  11310. * errorrik (errorrik@gmail.com)
  11311. */
  11312. /**
  11313. * @inner
  11314. */
  11315. function interpolate(p0, p1, p2, p3, t, t2, t3) {
  11316. var v0 = (p2 - p0) * 0.5;
  11317. var v1 = (p3 - p1) * 0.5;
  11318. return (2 * (p1 - p2) + v0 + v1) * t3 + (-3 * (p1 - p2) - 2 * v0 - v1) * t2 + v0 * t + p1;
  11319. }
  11320. /**
  11321. * @alias module:zrender/shape/util/smoothSpline
  11322. * @param {Array} points 线段顶点数组
  11323. * @param {boolean} isLoop
  11324. * @return {Array}
  11325. */
  11326. function _default(points, isLoop) {
  11327. var len = points.length;
  11328. var ret = [];
  11329. var distance = 0;
  11330. for (var i = 1; i < len; i++) {
  11331. distance += v2Distance(points[i - 1], points[i]);
  11332. }
  11333. var segs = distance / 2;
  11334. segs = segs < len ? len : segs;
  11335. for (var i = 0; i < segs; i++) {
  11336. var pos = i / (segs - 1) * (isLoop ? len : len - 1);
  11337. var idx = Math.floor(pos);
  11338. var w = pos - idx;
  11339. var p0;
  11340. var p1 = points[idx % len];
  11341. var p2;
  11342. var p3;
  11343. if (!isLoop) {
  11344. p0 = points[idx === 0 ? idx : idx - 1];
  11345. p2 = points[idx > len - 2 ? len - 1 : idx + 1];
  11346. p3 = points[idx > len - 3 ? len - 1 : idx + 2];
  11347. } else {
  11348. p0 = points[(idx - 1 + len) % len];
  11349. p2 = points[(idx + 1) % len];
  11350. p3 = points[(idx + 2) % len];
  11351. }
  11352. var w2 = w * w;
  11353. var w3 = w * w2;
  11354. ret.push([interpolate(p0[0], p1[0], p2[0], p3[0], w, w2, w3), interpolate(p0[1], p1[1], p2[1], p3[1], w, w2, w3)]);
  11355. }
  11356. return ret;
  11357. }
  11358. module.exports = _default;
  11359. /***/ }),
  11360. /***/ "./node_modules/zrender/lib/graphic/helper/subPixelOptimize.js":
  11361. /*!*********************************************************************!*\
  11362. !*** ./node_modules/zrender/lib/graphic/helper/subPixelOptimize.js ***!
  11363. \*********************************************************************/
  11364. /*! no static exports found */
  11365. /***/ (function(module, exports) {
  11366. /**
  11367. * Sub-pixel optimize for canvas rendering, prevent from blur
  11368. * when rendering a thin vertical/horizontal line.
  11369. */
  11370. var round = Math.round;
  11371. /**
  11372. * Sub pixel optimize line for canvas
  11373. *
  11374. * @param {Object} outputShape The modification will be performed on `outputShape`.
  11375. * `outputShape` and `inputShape` can be the same object.
  11376. * `outputShape` object can be used repeatly, because all of
  11377. * the `x1`, `x2`, `y1`, `y2` will be assigned in this method.
  11378. * @param {Object} [inputShape]
  11379. * @param {number} [inputShape.x1]
  11380. * @param {number} [inputShape.y1]
  11381. * @param {number} [inputShape.x2]
  11382. * @param {number} [inputShape.y2]
  11383. * @param {Object} [style]
  11384. * @param {number} [style.lineWidth] If `null`/`undefined`/`0`, do not optimize.
  11385. */
  11386. function subPixelOptimizeLine(outputShape, inputShape, style) {
  11387. if (!inputShape) {
  11388. return;
  11389. }
  11390. var x1 = inputShape.x1;
  11391. var x2 = inputShape.x2;
  11392. var y1 = inputShape.y1;
  11393. var y2 = inputShape.y2;
  11394. outputShape.x1 = x1;
  11395. outputShape.x2 = x2;
  11396. outputShape.y1 = y1;
  11397. outputShape.y2 = y2;
  11398. var lineWidth = style && style.lineWidth;
  11399. if (!lineWidth) {
  11400. return;
  11401. }
  11402. if (round(x1 * 2) === round(x2 * 2)) {
  11403. outputShape.x1 = outputShape.x2 = subPixelOptimize(x1, lineWidth, true);
  11404. }
  11405. if (round(y1 * 2) === round(y2 * 2)) {
  11406. outputShape.y1 = outputShape.y2 = subPixelOptimize(y1, lineWidth, true);
  11407. }
  11408. }
  11409. /**
  11410. * Sub pixel optimize rect for canvas
  11411. *
  11412. * @param {Object} outputShape The modification will be performed on `outputShape`.
  11413. * `outputShape` and `inputShape` can be the same object.
  11414. * `outputShape` object can be used repeatly, because all of
  11415. * the `x`, `y`, `width`, `height` will be assigned in this method.
  11416. * @param {Object} [inputShape]
  11417. * @param {number} [inputShape.x]
  11418. * @param {number} [inputShape.y]
  11419. * @param {number} [inputShape.width]
  11420. * @param {number} [inputShape.height]
  11421. * @param {Object} [style]
  11422. * @param {number} [style.lineWidth] If `null`/`undefined`/`0`, do not optimize.
  11423. */
  11424. function subPixelOptimizeRect(outputShape, inputShape, style) {
  11425. if (!inputShape) {
  11426. return;
  11427. }
  11428. var originX = inputShape.x;
  11429. var originY = inputShape.y;
  11430. var originWidth = inputShape.width;
  11431. var originHeight = inputShape.height;
  11432. outputShape.x = originX;
  11433. outputShape.y = originY;
  11434. outputShape.width = originWidth;
  11435. outputShape.height = originHeight;
  11436. var lineWidth = style && style.lineWidth;
  11437. if (!lineWidth) {
  11438. return;
  11439. }
  11440. outputShape.x = subPixelOptimize(originX, lineWidth, true);
  11441. outputShape.y = subPixelOptimize(originY, lineWidth, true);
  11442. outputShape.width = Math.max(subPixelOptimize(originX + originWidth, lineWidth, false) - outputShape.x, originWidth === 0 ? 0 : 1);
  11443. outputShape.height = Math.max(subPixelOptimize(originY + originHeight, lineWidth, false) - outputShape.y, originHeight === 0 ? 0 : 1);
  11444. }
  11445. /**
  11446. * Sub pixel optimize for canvas
  11447. *
  11448. * @param {number} position Coordinate, such as x, y
  11449. * @param {number} lineWidth If `null`/`undefined`/`0`, do not optimize.
  11450. * @param {boolean=} positiveOrNegative Default false (negative).
  11451. * @return {number} Optimized position.
  11452. */
  11453. function subPixelOptimize(position, lineWidth, positiveOrNegative) {
  11454. if (!lineWidth) {
  11455. return position;
  11456. } // Assure that (position + lineWidth / 2) is near integer edge,
  11457. // otherwise line will be fuzzy in canvas.
  11458. var doubledPosition = round(position * 2);
  11459. return (doubledPosition + round(lineWidth)) % 2 === 0 ? doubledPosition / 2 : (doubledPosition + (positiveOrNegative ? 1 : -1)) / 2;
  11460. }
  11461. exports.subPixelOptimizeLine = subPixelOptimizeLine;
  11462. exports.subPixelOptimizeRect = subPixelOptimizeRect;
  11463. exports.subPixelOptimize = subPixelOptimize;
  11464. /***/ }),
  11465. /***/ "./node_modules/zrender/lib/graphic/helper/text.js":
  11466. /*!*********************************************************!*\
  11467. !*** ./node_modules/zrender/lib/graphic/helper/text.js ***!
  11468. \*********************************************************/
  11469. /*! no static exports found */
  11470. /***/ (function(module, exports, __webpack_require__) {
  11471. var _util = __webpack_require__(/*! ../../core/util */ "./node_modules/zrender/lib/core/util.js");
  11472. var retrieve2 = _util.retrieve2;
  11473. var retrieve3 = _util.retrieve3;
  11474. var each = _util.each;
  11475. var normalizeCssArray = _util.normalizeCssArray;
  11476. var isString = _util.isString;
  11477. var isObject = _util.isObject;
  11478. var textContain = __webpack_require__(/*! ../../contain/text */ "./node_modules/zrender/lib/contain/text.js");
  11479. var roundRectHelper = __webpack_require__(/*! ./roundRect */ "./node_modules/zrender/lib/graphic/helper/roundRect.js");
  11480. var imageHelper = __webpack_require__(/*! ./image */ "./node_modules/zrender/lib/graphic/helper/image.js");
  11481. var fixShadow = __webpack_require__(/*! ./fixShadow */ "./node_modules/zrender/lib/graphic/helper/fixShadow.js");
  11482. var _constant = __webpack_require__(/*! ../constant */ "./node_modules/zrender/lib/graphic/constant.js");
  11483. var ContextCachedBy = _constant.ContextCachedBy;
  11484. var WILL_BE_RESTORED = _constant.WILL_BE_RESTORED;
  11485. var DEFAULT_FONT = textContain.DEFAULT_FONT; // TODO: Have not support 'start', 'end' yet.
  11486. var VALID_TEXT_ALIGN = {
  11487. left: 1,
  11488. right: 1,
  11489. center: 1
  11490. };
  11491. var VALID_TEXT_VERTICAL_ALIGN = {
  11492. top: 1,
  11493. bottom: 1,
  11494. middle: 1
  11495. }; // Different from `STYLE_COMMON_PROPS` of `graphic/Style`,
  11496. // the default value of shadowColor is `'transparent'`.
  11497. var SHADOW_STYLE_COMMON_PROPS = [['textShadowBlur', 'shadowBlur', 0], ['textShadowOffsetX', 'shadowOffsetX', 0], ['textShadowOffsetY', 'shadowOffsetY', 0], ['textShadowColor', 'shadowColor', 'transparent']];
  11498. var _tmpTextPositionResult = {};
  11499. var _tmpBoxPositionResult = {};
  11500. /**
  11501. * @param {module:zrender/graphic/Style} style
  11502. * @return {module:zrender/graphic/Style} The input style.
  11503. */
  11504. function normalizeTextStyle(style) {
  11505. normalizeStyle(style);
  11506. each(style.rich, normalizeStyle);
  11507. return style;
  11508. }
  11509. function normalizeStyle(style) {
  11510. if (style) {
  11511. style.font = textContain.makeFont(style);
  11512. var textAlign = style.textAlign;
  11513. textAlign === 'middle' && (textAlign = 'center');
  11514. style.textAlign = textAlign == null || VALID_TEXT_ALIGN[textAlign] ? textAlign : 'left'; // Compatible with textBaseline.
  11515. var textVerticalAlign = style.textVerticalAlign || style.textBaseline;
  11516. textVerticalAlign === 'center' && (textVerticalAlign = 'middle');
  11517. style.textVerticalAlign = textVerticalAlign == null || VALID_TEXT_VERTICAL_ALIGN[textVerticalAlign] ? textVerticalAlign : 'top';
  11518. var textPadding = style.textPadding;
  11519. if (textPadding) {
  11520. style.textPadding = normalizeCssArray(style.textPadding);
  11521. }
  11522. }
  11523. }
  11524. /**
  11525. * @param {CanvasRenderingContext2D} ctx
  11526. * @param {string} text
  11527. * @param {module:zrender/graphic/Style} style
  11528. * @param {Object|boolean} [rect] {x, y, width, height}
  11529. * If set false, rect text is not used.
  11530. * @param {Element|module:zrender/graphic/helper/constant.WILL_BE_RESTORED} [prevEl] For ctx prop cache.
  11531. */
  11532. function renderText(hostEl, ctx, text, style, rect, prevEl) {
  11533. style.rich ? renderRichText(hostEl, ctx, text, style, rect, prevEl) : renderPlainText(hostEl, ctx, text, style, rect, prevEl);
  11534. } // Avoid setting to ctx according to prevEl if possible for
  11535. // performance in scenarios of large amount text.
  11536. function renderPlainText(hostEl, ctx, text, style, rect, prevEl) {
  11537. 'use strict';
  11538. var needDrawBg = needDrawBackground(style);
  11539. var prevStyle;
  11540. var checkCache = false;
  11541. var cachedByMe = ctx.__attrCachedBy === ContextCachedBy.PLAIN_TEXT; // Only take and check cache for `Text` el, but not RectText.
  11542. if (prevEl !== WILL_BE_RESTORED) {
  11543. if (prevEl) {
  11544. prevStyle = prevEl.style;
  11545. checkCache = !needDrawBg && cachedByMe && prevStyle;
  11546. } // Prevent from using cache in `Style::bind`, because of the case:
  11547. // ctx property is modified by other properties than `Style::bind`
  11548. // used, and Style::bind is called next.
  11549. ctx.__attrCachedBy = needDrawBg ? ContextCachedBy.NONE : ContextCachedBy.PLAIN_TEXT;
  11550. } // Since this will be restored, prevent from using these props to check cache in the next
  11551. // entering of this method. But do not need to clear other cache like `Style::bind`.
  11552. else if (cachedByMe) {
  11553. ctx.__attrCachedBy = ContextCachedBy.NONE;
  11554. }
  11555. var styleFont = style.font || DEFAULT_FONT; // PENDING
  11556. // Only `Text` el set `font` and keep it (`RectText` will restore). So theoretically
  11557. // we can make font cache on ctx, which can cache for text el that are discontinuous.
  11558. // But layer save/restore needed to be considered.
  11559. // if (styleFont !== ctx.__fontCache) {
  11560. // ctx.font = styleFont;
  11561. // if (prevEl !== WILL_BE_RESTORED) {
  11562. // ctx.__fontCache = styleFont;
  11563. // }
  11564. // }
  11565. if (!checkCache || styleFont !== (prevStyle.font || DEFAULT_FONT)) {
  11566. ctx.font = styleFont;
  11567. } // Use the final font from context-2d, because the final
  11568. // font might not be the style.font when it is illegal.
  11569. // But get `ctx.font` might be time consuming.
  11570. var computedFont = hostEl.__computedFont;
  11571. if (hostEl.__styleFont !== styleFont) {
  11572. hostEl.__styleFont = styleFont;
  11573. computedFont = hostEl.__computedFont = ctx.font;
  11574. }
  11575. var textPadding = style.textPadding;
  11576. var textLineHeight = style.textLineHeight;
  11577. var contentBlock = hostEl.__textCotentBlock;
  11578. if (!contentBlock || hostEl.__dirtyText) {
  11579. contentBlock = hostEl.__textCotentBlock = textContain.parsePlainText(text, computedFont, textPadding, textLineHeight, style.truncate);
  11580. }
  11581. var outerHeight = contentBlock.outerHeight;
  11582. var textLines = contentBlock.lines;
  11583. var lineHeight = contentBlock.lineHeight;
  11584. var boxPos = getBoxPosition(_tmpBoxPositionResult, hostEl, style, rect);
  11585. var baseX = boxPos.baseX;
  11586. var baseY = boxPos.baseY;
  11587. var textAlign = boxPos.textAlign || 'left';
  11588. var textVerticalAlign = boxPos.textVerticalAlign; // Origin of textRotation should be the base point of text drawing.
  11589. applyTextRotation(ctx, style, rect, baseX, baseY);
  11590. var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
  11591. var textX = baseX;
  11592. var textY = boxY;
  11593. if (needDrawBg || textPadding) {
  11594. // Consider performance, do not call getTextWidth util necessary.
  11595. var textWidth = textContain.getWidth(text, computedFont);
  11596. var outerWidth = textWidth;
  11597. textPadding && (outerWidth += textPadding[1] + textPadding[3]);
  11598. var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
  11599. needDrawBg && drawBackground(hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight);
  11600. if (textPadding) {
  11601. textX = getTextXForPadding(baseX, textAlign, textPadding);
  11602. textY += textPadding[0];
  11603. }
  11604. } // Always set textAlign and textBase line, because it is difficute to calculate
  11605. // textAlign from prevEl, and we dont sure whether textAlign will be reset if
  11606. // font set happened.
  11607. ctx.textAlign = textAlign; // Force baseline to be "middle". Otherwise, if using "top", the
  11608. // text will offset downward a little bit in font "Microsoft YaHei".
  11609. ctx.textBaseline = 'middle'; // Set text opacity
  11610. ctx.globalAlpha = style.opacity || 1; // Always set shadowBlur and shadowOffset to avoid leak from displayable.
  11611. for (var i = 0; i < SHADOW_STYLE_COMMON_PROPS.length; i++) {
  11612. var propItem = SHADOW_STYLE_COMMON_PROPS[i];
  11613. var styleProp = propItem[0];
  11614. var ctxProp = propItem[1];
  11615. var val = style[styleProp];
  11616. if (!checkCache || val !== prevStyle[styleProp]) {
  11617. ctx[ctxProp] = fixShadow(ctx, ctxProp, val || propItem[2]);
  11618. }
  11619. } // `textBaseline` is set as 'middle'.
  11620. textY += lineHeight / 2;
  11621. var textStrokeWidth = style.textStrokeWidth;
  11622. var textStrokeWidthPrev = checkCache ? prevStyle.textStrokeWidth : null;
  11623. var strokeWidthChanged = !checkCache || textStrokeWidth !== textStrokeWidthPrev;
  11624. var strokeChanged = !checkCache || strokeWidthChanged || style.textStroke !== prevStyle.textStroke;
  11625. var textStroke = getStroke(style.textStroke, textStrokeWidth);
  11626. var textFill = getFill(style.textFill);
  11627. if (textStroke) {
  11628. if (strokeWidthChanged) {
  11629. ctx.lineWidth = textStrokeWidth;
  11630. }
  11631. if (strokeChanged) {
  11632. ctx.strokeStyle = textStroke;
  11633. }
  11634. }
  11635. if (textFill) {
  11636. if (!checkCache || style.textFill !== prevStyle.textFill) {
  11637. ctx.fillStyle = textFill;
  11638. }
  11639. } // Optimize simply, in most cases only one line exists.
  11640. if (textLines.length === 1) {
  11641. // Fill after stroke so the outline will not cover the main part.
  11642. textStroke && ctx.strokeText(textLines[0], textX, textY);
  11643. textFill && ctx.fillText(textLines[0], textX, textY);
  11644. } else {
  11645. for (var i = 0; i < textLines.length; i++) {
  11646. // Fill after stroke so the outline will not cover the main part.
  11647. textStroke && ctx.strokeText(textLines[i], textX, textY);
  11648. textFill && ctx.fillText(textLines[i], textX, textY);
  11649. textY += lineHeight;
  11650. }
  11651. }
  11652. }
  11653. function renderRichText(hostEl, ctx, text, style, rect, prevEl) {
  11654. // Do not do cache for rich text because of the complexity.
  11655. // But `RectText` this will be restored, do not need to clear other cache like `Style::bind`.
  11656. if (prevEl !== WILL_BE_RESTORED) {
  11657. ctx.__attrCachedBy = ContextCachedBy.NONE;
  11658. }
  11659. var contentBlock = hostEl.__textCotentBlock;
  11660. if (!contentBlock || hostEl.__dirtyText) {
  11661. contentBlock = hostEl.__textCotentBlock = textContain.parseRichText(text, style);
  11662. }
  11663. drawRichText(hostEl, ctx, contentBlock, style, rect);
  11664. }
  11665. function drawRichText(hostEl, ctx, contentBlock, style, rect) {
  11666. var contentWidth = contentBlock.width;
  11667. var outerWidth = contentBlock.outerWidth;
  11668. var outerHeight = contentBlock.outerHeight;
  11669. var textPadding = style.textPadding;
  11670. var boxPos = getBoxPosition(_tmpBoxPositionResult, hostEl, style, rect);
  11671. var baseX = boxPos.baseX;
  11672. var baseY = boxPos.baseY;
  11673. var textAlign = boxPos.textAlign;
  11674. var textVerticalAlign = boxPos.textVerticalAlign; // Origin of textRotation should be the base point of text drawing.
  11675. applyTextRotation(ctx, style, rect, baseX, baseY);
  11676. var boxX = textContain.adjustTextX(baseX, outerWidth, textAlign);
  11677. var boxY = textContain.adjustTextY(baseY, outerHeight, textVerticalAlign);
  11678. var xLeft = boxX;
  11679. var lineTop = boxY;
  11680. if (textPadding) {
  11681. xLeft += textPadding[3];
  11682. lineTop += textPadding[0];
  11683. }
  11684. var xRight = xLeft + contentWidth;
  11685. needDrawBackground(style) && drawBackground(hostEl, ctx, style, boxX, boxY, outerWidth, outerHeight);
  11686. for (var i = 0; i < contentBlock.lines.length; i++) {
  11687. var line = contentBlock.lines[i];
  11688. var tokens = line.tokens;
  11689. var tokenCount = tokens.length;
  11690. var lineHeight = line.lineHeight;
  11691. var usedWidth = line.width;
  11692. var leftIndex = 0;
  11693. var lineXLeft = xLeft;
  11694. var lineXRight = xRight;
  11695. var rightIndex = tokenCount - 1;
  11696. var token;
  11697. while (leftIndex < tokenCount && (token = tokens[leftIndex], !token.textAlign || token.textAlign === 'left')) {
  11698. placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft, 'left');
  11699. usedWidth -= token.width;
  11700. lineXLeft += token.width;
  11701. leftIndex++;
  11702. }
  11703. while (rightIndex >= 0 && (token = tokens[rightIndex], token.textAlign === 'right')) {
  11704. placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXRight, 'right');
  11705. usedWidth -= token.width;
  11706. lineXRight -= token.width;
  11707. rightIndex--;
  11708. } // The other tokens are placed as textAlign 'center' if there is enough space.
  11709. lineXLeft += (contentWidth - (lineXLeft - xLeft) - (xRight - lineXRight) - usedWidth) / 2;
  11710. while (leftIndex <= rightIndex) {
  11711. token = tokens[leftIndex]; // Consider width specified by user, use 'center' rather than 'left'.
  11712. placeToken(hostEl, ctx, token, style, lineHeight, lineTop, lineXLeft + token.width / 2, 'center');
  11713. lineXLeft += token.width;
  11714. leftIndex++;
  11715. }
  11716. lineTop += lineHeight;
  11717. }
  11718. }
  11719. function applyTextRotation(ctx, style, rect, x, y) {
  11720. // textRotation only apply in RectText.
  11721. if (rect && style.textRotation) {
  11722. var origin = style.textOrigin;
  11723. if (origin === 'center') {
  11724. x = rect.width / 2 + rect.x;
  11725. y = rect.height / 2 + rect.y;
  11726. } else if (origin) {
  11727. x = origin[0] + rect.x;
  11728. y = origin[1] + rect.y;
  11729. }
  11730. ctx.translate(x, y); // Positive: anticlockwise
  11731. ctx.rotate(-style.textRotation);
  11732. ctx.translate(-x, -y);
  11733. }
  11734. }
  11735. function placeToken(hostEl, ctx, token, style, lineHeight, lineTop, x, textAlign) {
  11736. var tokenStyle = style.rich[token.styleName] || {};
  11737. tokenStyle.text = token.text; // 'ctx.textBaseline' is always set as 'middle', for sake of
  11738. // the bias of "Microsoft YaHei".
  11739. var textVerticalAlign = token.textVerticalAlign;
  11740. var y = lineTop + lineHeight / 2;
  11741. if (textVerticalAlign === 'top') {
  11742. y = lineTop + token.height / 2;
  11743. } else if (textVerticalAlign === 'bottom') {
  11744. y = lineTop + lineHeight - token.height / 2;
  11745. }
  11746. !token.isLineHolder && needDrawBackground(tokenStyle) && drawBackground(hostEl, ctx, tokenStyle, textAlign === 'right' ? x - token.width : textAlign === 'center' ? x - token.width / 2 : x, y - token.height / 2, token.width, token.height);
  11747. var textPadding = token.textPadding;
  11748. if (textPadding) {
  11749. x = getTextXForPadding(x, textAlign, textPadding);
  11750. y -= token.height / 2 - textPadding[2] - token.textHeight / 2;
  11751. }
  11752. setCtx(ctx, 'shadowBlur', retrieve3(tokenStyle.textShadowBlur, style.textShadowBlur, 0));
  11753. setCtx(ctx, 'shadowColor', tokenStyle.textShadowColor || style.textShadowColor || 'transparent');
  11754. setCtx(ctx, 'shadowOffsetX', retrieve3(tokenStyle.textShadowOffsetX, style.textShadowOffsetX, 0));
  11755. setCtx(ctx, 'shadowOffsetY', retrieve3(tokenStyle.textShadowOffsetY, style.textShadowOffsetY, 0));
  11756. setCtx(ctx, 'textAlign', textAlign); // Force baseline to be "middle". Otherwise, if using "top", the
  11757. // text will offset downward a little bit in font "Microsoft YaHei".
  11758. setCtx(ctx, 'textBaseline', 'middle');
  11759. setCtx(ctx, 'font', token.font || DEFAULT_FONT);
  11760. var textStroke = getStroke(tokenStyle.textStroke || style.textStroke, textStrokeWidth);
  11761. var textFill = getFill(tokenStyle.textFill || style.textFill);
  11762. var textStrokeWidth = retrieve2(tokenStyle.textStrokeWidth, style.textStrokeWidth); // Fill after stroke so the outline will not cover the main part.
  11763. if (textStroke) {
  11764. setCtx(ctx, 'lineWidth', textStrokeWidth);
  11765. setCtx(ctx, 'strokeStyle', textStroke);
  11766. ctx.strokeText(token.text, x, y);
  11767. }
  11768. if (textFill) {
  11769. setCtx(ctx, 'fillStyle', textFill);
  11770. ctx.fillText(token.text, x, y);
  11771. }
  11772. }
  11773. function needDrawBackground(style) {
  11774. return !!(style.textBackgroundColor || style.textBorderWidth && style.textBorderColor);
  11775. } // style: {textBackgroundColor, textBorderWidth, textBorderColor, textBorderRadius, text}
  11776. // shape: {x, y, width, height}
  11777. function drawBackground(hostEl, ctx, style, x, y, width, height) {
  11778. var textBackgroundColor = style.textBackgroundColor;
  11779. var textBorderWidth = style.textBorderWidth;
  11780. var textBorderColor = style.textBorderColor;
  11781. var isPlainBg = isString(textBackgroundColor);
  11782. setCtx(ctx, 'shadowBlur', style.textBoxShadowBlur || 0);
  11783. setCtx(ctx, 'shadowColor', style.textBoxShadowColor || 'transparent');
  11784. setCtx(ctx, 'shadowOffsetX', style.textBoxShadowOffsetX || 0);
  11785. setCtx(ctx, 'shadowOffsetY', style.textBoxShadowOffsetY || 0);
  11786. if (isPlainBg || textBorderWidth && textBorderColor) {
  11787. ctx.beginPath();
  11788. var textBorderRadius = style.textBorderRadius;
  11789. if (!textBorderRadius) {
  11790. ctx.rect(x, y, width, height);
  11791. } else {
  11792. roundRectHelper.buildPath(ctx, {
  11793. x: x,
  11794. y: y,
  11795. width: width,
  11796. height: height,
  11797. r: textBorderRadius
  11798. });
  11799. }
  11800. ctx.closePath();
  11801. }
  11802. if (isPlainBg) {
  11803. setCtx(ctx, 'fillStyle', textBackgroundColor);
  11804. if (style.fillOpacity != null) {
  11805. var originalGlobalAlpha = ctx.globalAlpha;
  11806. ctx.globalAlpha = style.fillOpacity * style.opacity;
  11807. ctx.fill();
  11808. ctx.globalAlpha = originalGlobalAlpha;
  11809. } else {
  11810. ctx.fill();
  11811. }
  11812. } else if (isObject(textBackgroundColor)) {
  11813. var image = textBackgroundColor.image;
  11814. image = imageHelper.createOrUpdateImage(image, null, hostEl, onBgImageLoaded, textBackgroundColor);
  11815. if (image && imageHelper.isImageReady(image)) {
  11816. ctx.drawImage(image, x, y, width, height);
  11817. }
  11818. }
  11819. if (textBorderWidth && textBorderColor) {
  11820. setCtx(ctx, 'lineWidth', textBorderWidth);
  11821. setCtx(ctx, 'strokeStyle', textBorderColor);
  11822. if (style.strokeOpacity != null) {
  11823. var originalGlobalAlpha = ctx.globalAlpha;
  11824. ctx.globalAlpha = style.strokeOpacity * style.opacity;
  11825. ctx.stroke();
  11826. ctx.globalAlpha = originalGlobalAlpha;
  11827. } else {
  11828. ctx.stroke();
  11829. }
  11830. }
  11831. }
  11832. function onBgImageLoaded(image, textBackgroundColor) {
  11833. // Replace image, so that `contain/text.js#parseRichText`
  11834. // will get correct result in next tick.
  11835. textBackgroundColor.image = image;
  11836. }
  11837. function getBoxPosition(out, hostEl, style, rect) {
  11838. var baseX = style.x || 0;
  11839. var baseY = style.y || 0;
  11840. var textAlign = style.textAlign;
  11841. var textVerticalAlign = style.textVerticalAlign; // Text position represented by coord
  11842. if (rect) {
  11843. var textPosition = style.textPosition;
  11844. if (textPosition instanceof Array) {
  11845. // Percent
  11846. baseX = rect.x + parsePercent(textPosition[0], rect.width);
  11847. baseY = rect.y + parsePercent(textPosition[1], rect.height);
  11848. } else {
  11849. var res = hostEl && hostEl.calculateTextPosition ? hostEl.calculateTextPosition(_tmpTextPositionResult, style, rect) : textContain.calculateTextPosition(_tmpTextPositionResult, style, rect);
  11850. baseX = res.x;
  11851. baseY = res.y; // Default align and baseline when has textPosition
  11852. textAlign = textAlign || res.textAlign;
  11853. textVerticalAlign = textVerticalAlign || res.textVerticalAlign;
  11854. } // textOffset is only support in RectText, otherwise
  11855. // we have to adjust boundingRect for textOffset.
  11856. var textOffset = style.textOffset;
  11857. if (textOffset) {
  11858. baseX += textOffset[0];
  11859. baseY += textOffset[1];
  11860. }
  11861. }
  11862. out = out || {};
  11863. out.baseX = baseX;
  11864. out.baseY = baseY;
  11865. out.textAlign = textAlign;
  11866. out.textVerticalAlign = textVerticalAlign;
  11867. return out;
  11868. }
  11869. function setCtx(ctx, prop, value) {
  11870. ctx[prop] = fixShadow(ctx, prop, value);
  11871. return ctx[prop];
  11872. }
  11873. /**
  11874. * @param {string} [stroke] If specified, do not check style.textStroke.
  11875. * @param {string} [lineWidth] If specified, do not check style.textStroke.
  11876. * @param {number} style
  11877. */
  11878. function getStroke(stroke, lineWidth) {
  11879. return stroke == null || lineWidth <= 0 || stroke === 'transparent' || stroke === 'none' ? null // TODO pattern and gradient?
  11880. : stroke.image || stroke.colorStops ? '#000' : stroke;
  11881. }
  11882. function getFill(fill) {
  11883. return fill == null || fill === 'none' ? null // TODO pattern and gradient?
  11884. : fill.image || fill.colorStops ? '#000' : fill;
  11885. }
  11886. function parsePercent(value, maxValue) {
  11887. if (typeof value === 'string') {
  11888. if (value.lastIndexOf('%') >= 0) {
  11889. return parseFloat(value) / 100 * maxValue;
  11890. }
  11891. return parseFloat(value);
  11892. }
  11893. return value;
  11894. }
  11895. function getTextXForPadding(x, textAlign, textPadding) {
  11896. return textAlign === 'right' ? x - textPadding[1] : textAlign === 'center' ? x + textPadding[3] / 2 - textPadding[1] / 2 : x + textPadding[3];
  11897. }
  11898. /**
  11899. * @param {string} text
  11900. * @param {module:zrender/Style} style
  11901. * @return {boolean}
  11902. */
  11903. function needDrawText(text, style) {
  11904. return text != null && (text || style.textBackgroundColor || style.textBorderWidth && style.textBorderColor || style.textPadding);
  11905. }
  11906. exports.normalizeTextStyle = normalizeTextStyle;
  11907. exports.renderText = renderText;
  11908. exports.getBoxPosition = getBoxPosition;
  11909. exports.getStroke = getStroke;
  11910. exports.getFill = getFill;
  11911. exports.parsePercent = parsePercent;
  11912. exports.needDrawText = needDrawText;
  11913. /***/ }),
  11914. /***/ "./node_modules/zrender/lib/graphic/mixin/RectText.js":
  11915. /*!************************************************************!*\
  11916. !*** ./node_modules/zrender/lib/graphic/mixin/RectText.js ***!
  11917. \************************************************************/
  11918. /*! no static exports found */
  11919. /***/ (function(module, exports, __webpack_require__) {
  11920. var textHelper = __webpack_require__(/*! ../helper/text */ "./node_modules/zrender/lib/graphic/helper/text.js");
  11921. var BoundingRect = __webpack_require__(/*! ../../core/BoundingRect */ "./node_modules/zrender/lib/core/BoundingRect.js");
  11922. var _constant = __webpack_require__(/*! ../constant */ "./node_modules/zrender/lib/graphic/constant.js");
  11923. var WILL_BE_RESTORED = _constant.WILL_BE_RESTORED;
  11924. /**
  11925. * Mixin for drawing text in a element bounding rect
  11926. * @module zrender/mixin/RectText
  11927. */
  11928. var tmpRect = new BoundingRect();
  11929. var RectText = function () {};
  11930. RectText.prototype = {
  11931. constructor: RectText,
  11932. /**
  11933. * Draw text in a rect with specified position.
  11934. * @param {CanvasRenderingContext2D} ctx
  11935. * @param {Object} rect Displayable rect
  11936. */
  11937. drawRectText: function (ctx, rect) {
  11938. var style = this.style;
  11939. rect = style.textRect || rect; // Optimize, avoid normalize every time.
  11940. this.__dirty && textHelper.normalizeTextStyle(style, true);
  11941. var text = style.text; // Convert to string
  11942. text != null && (text += '');
  11943. if (!textHelper.needDrawText(text, style)) {
  11944. return;
  11945. } // FIXME
  11946. // Do not provide prevEl to `textHelper.renderText` for ctx prop cache,
  11947. // but use `ctx.save()` and `ctx.restore()`. Because the cache for rect
  11948. // text propably break the cache for its host elements.
  11949. ctx.save(); // Transform rect to view space
  11950. var transform = this.transform;
  11951. if (!style.transformText) {
  11952. if (transform) {
  11953. tmpRect.copy(rect);
  11954. tmpRect.applyTransform(transform);
  11955. rect = tmpRect;
  11956. }
  11957. } else {
  11958. this.setTransform(ctx);
  11959. } // transformText and textRotation can not be used at the same time.
  11960. textHelper.renderText(this, ctx, text, style, rect, WILL_BE_RESTORED);
  11961. ctx.restore();
  11962. }
  11963. };
  11964. var _default = RectText;
  11965. module.exports = _default;
  11966. /***/ }),
  11967. /***/ "./node_modules/zrender/lib/graphic/shape/Arc.js":
  11968. /*!*******************************************************!*\
  11969. !*** ./node_modules/zrender/lib/graphic/shape/Arc.js ***!
  11970. \*******************************************************/
  11971. /*! no static exports found */
  11972. /***/ (function(module, exports, __webpack_require__) {
  11973. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  11974. /**
  11975. * 圆弧
  11976. * @module zrender/graphic/shape/Arc
  11977. */
  11978. var _default = Path.extend({
  11979. type: 'arc',
  11980. shape: {
  11981. cx: 0,
  11982. cy: 0,
  11983. r: 0,
  11984. startAngle: 0,
  11985. endAngle: Math.PI * 2,
  11986. clockwise: true
  11987. },
  11988. style: {
  11989. stroke: '#000',
  11990. fill: null
  11991. },
  11992. buildPath: function (ctx, shape) {
  11993. var x = shape.cx;
  11994. var y = shape.cy;
  11995. var r = Math.max(shape.r, 0);
  11996. var startAngle = shape.startAngle;
  11997. var endAngle = shape.endAngle;
  11998. var clockwise = shape.clockwise;
  11999. var unitX = Math.cos(startAngle);
  12000. var unitY = Math.sin(startAngle);
  12001. ctx.moveTo(unitX * r + x, unitY * r + y);
  12002. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  12003. }
  12004. });
  12005. module.exports = _default;
  12006. /***/ }),
  12007. /***/ "./node_modules/zrender/lib/graphic/shape/BezierCurve.js":
  12008. /*!***************************************************************!*\
  12009. !*** ./node_modules/zrender/lib/graphic/shape/BezierCurve.js ***!
  12010. \***************************************************************/
  12011. /*! no static exports found */
  12012. /***/ (function(module, exports, __webpack_require__) {
  12013. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12014. var vec2 = __webpack_require__(/*! ../../core/vector */ "./node_modules/zrender/lib/core/vector.js");
  12015. var _curve = __webpack_require__(/*! ../../core/curve */ "./node_modules/zrender/lib/core/curve.js");
  12016. var quadraticSubdivide = _curve.quadraticSubdivide;
  12017. var cubicSubdivide = _curve.cubicSubdivide;
  12018. var quadraticAt = _curve.quadraticAt;
  12019. var cubicAt = _curve.cubicAt;
  12020. var quadraticDerivativeAt = _curve.quadraticDerivativeAt;
  12021. var cubicDerivativeAt = _curve.cubicDerivativeAt;
  12022. /**
  12023. * 贝塞尔曲线
  12024. * @module zrender/shape/BezierCurve
  12025. */
  12026. var out = [];
  12027. function someVectorAt(shape, t, isTangent) {
  12028. var cpx2 = shape.cpx2;
  12029. var cpy2 = shape.cpy2;
  12030. if (cpx2 === null || cpy2 === null) {
  12031. return [(isTangent ? cubicDerivativeAt : cubicAt)(shape.x1, shape.cpx1, shape.cpx2, shape.x2, t), (isTangent ? cubicDerivativeAt : cubicAt)(shape.y1, shape.cpy1, shape.cpy2, shape.y2, t)];
  12032. } else {
  12033. return [(isTangent ? quadraticDerivativeAt : quadraticAt)(shape.x1, shape.cpx1, shape.x2, t), (isTangent ? quadraticDerivativeAt : quadraticAt)(shape.y1, shape.cpy1, shape.y2, t)];
  12034. }
  12035. }
  12036. var _default = Path.extend({
  12037. type: 'bezier-curve',
  12038. shape: {
  12039. x1: 0,
  12040. y1: 0,
  12041. x2: 0,
  12042. y2: 0,
  12043. cpx1: 0,
  12044. cpy1: 0,
  12045. // cpx2: 0,
  12046. // cpy2: 0
  12047. // Curve show percent, for animating
  12048. percent: 1
  12049. },
  12050. style: {
  12051. stroke: '#000',
  12052. fill: null
  12053. },
  12054. buildPath: function (ctx, shape) {
  12055. var x1 = shape.x1;
  12056. var y1 = shape.y1;
  12057. var x2 = shape.x2;
  12058. var y2 = shape.y2;
  12059. var cpx1 = shape.cpx1;
  12060. var cpy1 = shape.cpy1;
  12061. var cpx2 = shape.cpx2;
  12062. var cpy2 = shape.cpy2;
  12063. var percent = shape.percent;
  12064. if (percent === 0) {
  12065. return;
  12066. }
  12067. ctx.moveTo(x1, y1);
  12068. if (cpx2 == null || cpy2 == null) {
  12069. if (percent < 1) {
  12070. quadraticSubdivide(x1, cpx1, x2, percent, out);
  12071. cpx1 = out[1];
  12072. x2 = out[2];
  12073. quadraticSubdivide(y1, cpy1, y2, percent, out);
  12074. cpy1 = out[1];
  12075. y2 = out[2];
  12076. }
  12077. ctx.quadraticCurveTo(cpx1, cpy1, x2, y2);
  12078. } else {
  12079. if (percent < 1) {
  12080. cubicSubdivide(x1, cpx1, cpx2, x2, percent, out);
  12081. cpx1 = out[1];
  12082. cpx2 = out[2];
  12083. x2 = out[3];
  12084. cubicSubdivide(y1, cpy1, cpy2, y2, percent, out);
  12085. cpy1 = out[1];
  12086. cpy2 = out[2];
  12087. y2 = out[3];
  12088. }
  12089. ctx.bezierCurveTo(cpx1, cpy1, cpx2, cpy2, x2, y2);
  12090. }
  12091. },
  12092. /**
  12093. * Get point at percent
  12094. * @param {number} t
  12095. * @return {Array.<number>}
  12096. */
  12097. pointAt: function (t) {
  12098. return someVectorAt(this.shape, t, false);
  12099. },
  12100. /**
  12101. * Get tangent at percent
  12102. * @param {number} t
  12103. * @return {Array.<number>}
  12104. */
  12105. tangentAt: function (t) {
  12106. var p = someVectorAt(this.shape, t, true);
  12107. return vec2.normalize(p, p);
  12108. }
  12109. });
  12110. module.exports = _default;
  12111. /***/ }),
  12112. /***/ "./node_modules/zrender/lib/graphic/shape/Circle.js":
  12113. /*!**********************************************************!*\
  12114. !*** ./node_modules/zrender/lib/graphic/shape/Circle.js ***!
  12115. \**********************************************************/
  12116. /*! no static exports found */
  12117. /***/ (function(module, exports, __webpack_require__) {
  12118. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12119. /**
  12120. * 圆形
  12121. * @module zrender/shape/Circle
  12122. */
  12123. var _default = Path.extend({
  12124. type: 'circle',
  12125. shape: {
  12126. cx: 0,
  12127. cy: 0,
  12128. r: 0
  12129. },
  12130. buildPath: function (ctx, shape, inBundle) {
  12131. // Better stroking in ShapeBundle
  12132. // Always do it may have performence issue ( fill may be 2x more cost)
  12133. if (inBundle) {
  12134. ctx.moveTo(shape.cx + shape.r, shape.cy);
  12135. } // else {
  12136. // if (ctx.allocate && !ctx.data.length) {
  12137. // ctx.allocate(ctx.CMD_MEM_SIZE.A);
  12138. // }
  12139. // }
  12140. // Better stroking in ShapeBundle
  12141. // ctx.moveTo(shape.cx + shape.r, shape.cy);
  12142. ctx.arc(shape.cx, shape.cy, shape.r, 0, Math.PI * 2, true);
  12143. }
  12144. });
  12145. module.exports = _default;
  12146. /***/ }),
  12147. /***/ "./node_modules/zrender/lib/graphic/shape/Line.js":
  12148. /*!********************************************************!*\
  12149. !*** ./node_modules/zrender/lib/graphic/shape/Line.js ***!
  12150. \********************************************************/
  12151. /*! no static exports found */
  12152. /***/ (function(module, exports, __webpack_require__) {
  12153. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12154. var _subPixelOptimize = __webpack_require__(/*! ../helper/subPixelOptimize */ "./node_modules/zrender/lib/graphic/helper/subPixelOptimize.js");
  12155. var subPixelOptimizeLine = _subPixelOptimize.subPixelOptimizeLine;
  12156. /**
  12157. * 直线
  12158. * @module zrender/graphic/shape/Line
  12159. */
  12160. // Avoid create repeatly.
  12161. var subPixelOptimizeOutputShape = {};
  12162. var _default = Path.extend({
  12163. type: 'line',
  12164. shape: {
  12165. // Start point
  12166. x1: 0,
  12167. y1: 0,
  12168. // End point
  12169. x2: 0,
  12170. y2: 0,
  12171. percent: 1
  12172. },
  12173. style: {
  12174. stroke: '#000',
  12175. fill: null
  12176. },
  12177. buildPath: function (ctx, shape) {
  12178. var x1;
  12179. var y1;
  12180. var x2;
  12181. var y2;
  12182. if (this.subPixelOptimize) {
  12183. subPixelOptimizeLine(subPixelOptimizeOutputShape, shape, this.style);
  12184. x1 = subPixelOptimizeOutputShape.x1;
  12185. y1 = subPixelOptimizeOutputShape.y1;
  12186. x2 = subPixelOptimizeOutputShape.x2;
  12187. y2 = subPixelOptimizeOutputShape.y2;
  12188. } else {
  12189. x1 = shape.x1;
  12190. y1 = shape.y1;
  12191. x2 = shape.x2;
  12192. y2 = shape.y2;
  12193. }
  12194. var percent = shape.percent;
  12195. if (percent === 0) {
  12196. return;
  12197. }
  12198. ctx.moveTo(x1, y1);
  12199. if (percent < 1) {
  12200. x2 = x1 * (1 - percent) + x2 * percent;
  12201. y2 = y1 * (1 - percent) + y2 * percent;
  12202. }
  12203. ctx.lineTo(x2, y2);
  12204. },
  12205. /**
  12206. * Get point at percent
  12207. * @param {number} percent
  12208. * @return {Array.<number>}
  12209. */
  12210. pointAt: function (p) {
  12211. var shape = this.shape;
  12212. return [shape.x1 * (1 - p) + shape.x2 * p, shape.y1 * (1 - p) + shape.y2 * p];
  12213. }
  12214. });
  12215. module.exports = _default;
  12216. /***/ }),
  12217. /***/ "./node_modules/zrender/lib/graphic/shape/Polygon.js":
  12218. /*!***********************************************************!*\
  12219. !*** ./node_modules/zrender/lib/graphic/shape/Polygon.js ***!
  12220. \***********************************************************/
  12221. /*! no static exports found */
  12222. /***/ (function(module, exports, __webpack_require__) {
  12223. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12224. var polyHelper = __webpack_require__(/*! ../helper/poly */ "./node_modules/zrender/lib/graphic/helper/poly.js");
  12225. /**
  12226. * 多边形
  12227. * @module zrender/shape/Polygon
  12228. */
  12229. var _default = Path.extend({
  12230. type: 'polygon',
  12231. shape: {
  12232. points: null,
  12233. smooth: false,
  12234. smoothConstraint: null
  12235. },
  12236. buildPath: function (ctx, shape) {
  12237. polyHelper.buildPath(ctx, shape, true);
  12238. }
  12239. });
  12240. module.exports = _default;
  12241. /***/ }),
  12242. /***/ "./node_modules/zrender/lib/graphic/shape/Polyline.js":
  12243. /*!************************************************************!*\
  12244. !*** ./node_modules/zrender/lib/graphic/shape/Polyline.js ***!
  12245. \************************************************************/
  12246. /*! no static exports found */
  12247. /***/ (function(module, exports, __webpack_require__) {
  12248. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12249. var polyHelper = __webpack_require__(/*! ../helper/poly */ "./node_modules/zrender/lib/graphic/helper/poly.js");
  12250. /**
  12251. * @module zrender/graphic/shape/Polyline
  12252. */
  12253. var _default = Path.extend({
  12254. type: 'polyline',
  12255. shape: {
  12256. points: null,
  12257. smooth: false,
  12258. smoothConstraint: null
  12259. },
  12260. style: {
  12261. stroke: '#000',
  12262. fill: null
  12263. },
  12264. buildPath: function (ctx, shape) {
  12265. polyHelper.buildPath(ctx, shape, false);
  12266. }
  12267. });
  12268. module.exports = _default;
  12269. /***/ }),
  12270. /***/ "./node_modules/zrender/lib/graphic/shape/Rect.js":
  12271. /*!********************************************************!*\
  12272. !*** ./node_modules/zrender/lib/graphic/shape/Rect.js ***!
  12273. \********************************************************/
  12274. /*! no static exports found */
  12275. /***/ (function(module, exports, __webpack_require__) {
  12276. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12277. var roundRectHelper = __webpack_require__(/*! ../helper/roundRect */ "./node_modules/zrender/lib/graphic/helper/roundRect.js");
  12278. var _subPixelOptimize = __webpack_require__(/*! ../helper/subPixelOptimize */ "./node_modules/zrender/lib/graphic/helper/subPixelOptimize.js");
  12279. var subPixelOptimizeRect = _subPixelOptimize.subPixelOptimizeRect;
  12280. /**
  12281. * 矩形
  12282. * @module zrender/graphic/shape/Rect
  12283. */
  12284. // Avoid create repeatly.
  12285. var subPixelOptimizeOutputShape = {};
  12286. var _default = Path.extend({
  12287. type: 'rect',
  12288. shape: {
  12289. // 左上、右上、右下、左下角的半径依次为r1、r2、r3、r4
  12290. // r缩写为1 相当于 [1, 1, 1, 1]
  12291. // r缩写为[1] 相当于 [1, 1, 1, 1]
  12292. // r缩写为[1, 2] 相当于 [1, 2, 1, 2]
  12293. // r缩写为[1, 2, 3] 相当于 [1, 2, 3, 2]
  12294. r: 0,
  12295. x: 0,
  12296. y: 0,
  12297. width: 0,
  12298. height: 0
  12299. },
  12300. buildPath: function (ctx, shape) {
  12301. var x;
  12302. var y;
  12303. var width;
  12304. var height;
  12305. if (this.subPixelOptimize) {
  12306. subPixelOptimizeRect(subPixelOptimizeOutputShape, shape, this.style);
  12307. x = subPixelOptimizeOutputShape.x;
  12308. y = subPixelOptimizeOutputShape.y;
  12309. width = subPixelOptimizeOutputShape.width;
  12310. height = subPixelOptimizeOutputShape.height;
  12311. subPixelOptimizeOutputShape.r = shape.r;
  12312. shape = subPixelOptimizeOutputShape;
  12313. } else {
  12314. x = shape.x;
  12315. y = shape.y;
  12316. width = shape.width;
  12317. height = shape.height;
  12318. }
  12319. if (!shape.r) {
  12320. ctx.rect(x, y, width, height);
  12321. } else {
  12322. roundRectHelper.buildPath(ctx, shape);
  12323. }
  12324. ctx.closePath();
  12325. return;
  12326. }
  12327. });
  12328. module.exports = _default;
  12329. /***/ }),
  12330. /***/ "./node_modules/zrender/lib/graphic/shape/Ring.js":
  12331. /*!********************************************************!*\
  12332. !*** ./node_modules/zrender/lib/graphic/shape/Ring.js ***!
  12333. \********************************************************/
  12334. /*! no static exports found */
  12335. /***/ (function(module, exports, __webpack_require__) {
  12336. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12337. /**
  12338. * 圆环
  12339. * @module zrender/graphic/shape/Ring
  12340. */
  12341. var _default = Path.extend({
  12342. type: 'ring',
  12343. shape: {
  12344. cx: 0,
  12345. cy: 0,
  12346. r: 0,
  12347. r0: 0
  12348. },
  12349. buildPath: function (ctx, shape) {
  12350. var x = shape.cx;
  12351. var y = shape.cy;
  12352. var PI2 = Math.PI * 2;
  12353. ctx.moveTo(x + shape.r, y);
  12354. ctx.arc(x, y, shape.r, 0, PI2, false);
  12355. ctx.moveTo(x + shape.r0, y);
  12356. ctx.arc(x, y, shape.r0, 0, PI2, true);
  12357. }
  12358. });
  12359. module.exports = _default;
  12360. /***/ }),
  12361. /***/ "./node_modules/zrender/lib/graphic/shape/Sector.js":
  12362. /*!**********************************************************!*\
  12363. !*** ./node_modules/zrender/lib/graphic/shape/Sector.js ***!
  12364. \**********************************************************/
  12365. /*! no static exports found */
  12366. /***/ (function(module, exports, __webpack_require__) {
  12367. var Path = __webpack_require__(/*! ../Path */ "./node_modules/zrender/lib/graphic/Path.js");
  12368. var fixClipWithShadow = __webpack_require__(/*! ../helper/fixClipWithShadow */ "./node_modules/zrender/lib/graphic/helper/fixClipWithShadow.js");
  12369. /**
  12370. * 扇形
  12371. * @module zrender/graphic/shape/Sector
  12372. */
  12373. var _default = Path.extend({
  12374. type: 'sector',
  12375. shape: {
  12376. cx: 0,
  12377. cy: 0,
  12378. r0: 0,
  12379. r: 0,
  12380. startAngle: 0,
  12381. endAngle: Math.PI * 2,
  12382. clockwise: true
  12383. },
  12384. brush: fixClipWithShadow(Path.prototype.brush),
  12385. buildPath: function (ctx, shape) {
  12386. var x = shape.cx;
  12387. var y = shape.cy;
  12388. var r0 = Math.max(shape.r0 || 0, 0);
  12389. var r = Math.max(shape.r, 0);
  12390. var startAngle = shape.startAngle;
  12391. var endAngle = shape.endAngle;
  12392. var clockwise = shape.clockwise;
  12393. var unitX = Math.cos(startAngle);
  12394. var unitY = Math.sin(startAngle);
  12395. ctx.moveTo(unitX * r0 + x, unitY * r0 + y);
  12396. ctx.lineTo(unitX * r + x, unitY * r + y);
  12397. ctx.arc(x, y, r, startAngle, endAngle, !clockwise);
  12398. ctx.lineTo(Math.cos(endAngle) * r0 + x, Math.sin(endAngle) * r0 + y);
  12399. if (r0 !== 0) {
  12400. ctx.arc(x, y, r0, endAngle, startAngle, clockwise);
  12401. }
  12402. ctx.closePath();
  12403. }
  12404. });
  12405. module.exports = _default;
  12406. /***/ }),
  12407. /***/ "./node_modules/zrender/lib/mixin/Animatable.js":
  12408. /*!******************************************************!*\
  12409. !*** ./node_modules/zrender/lib/mixin/Animatable.js ***!
  12410. \******************************************************/
  12411. /*! no static exports found */
  12412. /***/ (function(module, exports, __webpack_require__) {
  12413. var Animator = __webpack_require__(/*! ../animation/Animator */ "./node_modules/zrender/lib/animation/Animator.js");
  12414. var logError = __webpack_require__(/*! ../core/log */ "./node_modules/zrender/lib/core/log.js");
  12415. var _util = __webpack_require__(/*! ../core/util */ "./node_modules/zrender/lib/core/util.js");
  12416. var isString = _util.isString;
  12417. var isFunction = _util.isFunction;
  12418. var isObject = _util.isObject;
  12419. var isArrayLike = _util.isArrayLike;
  12420. var indexOf = _util.indexOf;
  12421. /**
  12422. * @alias module:zrender/mixin/Animatable
  12423. * @constructor
  12424. */
  12425. var Animatable = function () {
  12426. /**
  12427. * @type {Array.<module:zrender/animation/Animator>}
  12428. * @readOnly
  12429. */
  12430. this.animators = [];
  12431. };
  12432. Animatable.prototype = {
  12433. constructor: Animatable,
  12434. /**
  12435. * 动画
  12436. *
  12437. * @param {string} path The path to fetch value from object, like 'a.b.c'.
  12438. * @param {boolean} [loop] Whether to loop animation.
  12439. * @return {module:zrender/animation/Animator}
  12440. * @example:
  12441. * el.animate('style', false)
  12442. * .when(1000, {x: 10} )
  12443. * .done(function(){ // Animation done })
  12444. * .start()
  12445. */
  12446. animate: function (path, loop) {
  12447. var target;
  12448. var animatingShape = false;
  12449. var el = this;
  12450. var zr = this.__zr;
  12451. if (path) {
  12452. var pathSplitted = path.split('.');
  12453. var prop = el; // If animating shape
  12454. animatingShape = pathSplitted[0] === 'shape';
  12455. for (var i = 0, l = pathSplitted.length; i < l; i++) {
  12456. if (!prop) {
  12457. continue;
  12458. }
  12459. prop = prop[pathSplitted[i]];
  12460. }
  12461. if (prop) {
  12462. target = prop;
  12463. }
  12464. } else {
  12465. target = el;
  12466. }
  12467. if (!target) {
  12468. logError('Property "' + path + '" is not existed in element ' + el.id);
  12469. return;
  12470. }
  12471. var animators = el.animators;
  12472. var animator = new Animator(target, loop);
  12473. animator.during(function (target) {
  12474. el.dirty(animatingShape);
  12475. }).done(function () {
  12476. // FIXME Animator will not be removed if use `Animator#stop` to stop animation
  12477. animators.splice(indexOf(animators, animator), 1);
  12478. });
  12479. animators.push(animator); // If animate after added to the zrender
  12480. if (zr) {
  12481. zr.animation.addAnimator(animator);
  12482. }
  12483. return animator;
  12484. },
  12485. /**
  12486. * 停止动画
  12487. * @param {boolean} forwardToLast If move to last frame before stop
  12488. */
  12489. stopAnimation: function (forwardToLast) {
  12490. var animators = this.animators;
  12491. var len = animators.length;
  12492. for (var i = 0; i < len; i++) {
  12493. animators[i].stop(forwardToLast);
  12494. }
  12495. animators.length = 0;
  12496. return this;
  12497. },
  12498. /**
  12499. * Caution: this method will stop previous animation.
  12500. * So do not use this method to one element twice before
  12501. * animation starts, unless you know what you are doing.
  12502. * @param {Object} target
  12503. * @param {number} [time=500] Time in ms
  12504. * @param {string} [easing='linear']
  12505. * @param {number} [delay=0]
  12506. * @param {Function} [callback]
  12507. * @param {Function} [forceAnimate] Prevent stop animation and callback
  12508. * immediently when target values are the same as current values.
  12509. *
  12510. * @example
  12511. * // Animate position
  12512. * el.animateTo({
  12513. * position: [10, 10]
  12514. * }, function () { // done })
  12515. *
  12516. * // Animate shape, style and position in 100ms, delayed 100ms, with cubicOut easing
  12517. * el.animateTo({
  12518. * shape: {
  12519. * width: 500
  12520. * },
  12521. * style: {
  12522. * fill: 'red'
  12523. * }
  12524. * position: [10, 10]
  12525. * }, 100, 100, 'cubicOut', function () { // done })
  12526. */
  12527. // TODO Return animation key
  12528. animateTo: function (target, time, delay, easing, callback, forceAnimate) {
  12529. animateTo(this, target, time, delay, easing, callback, forceAnimate);
  12530. },
  12531. /**
  12532. * Animate from the target state to current state.
  12533. * The params and the return value are the same as `this.animateTo`.
  12534. */
  12535. animateFrom: function (target, time, delay, easing, callback, forceAnimate) {
  12536. animateTo(this, target, time, delay, easing, callback, forceAnimate, true);
  12537. }
  12538. };
  12539. function animateTo(animatable, target, time, delay, easing, callback, forceAnimate, reverse) {
  12540. // animateTo(target, time, easing, callback);
  12541. if (isString(delay)) {
  12542. callback = easing;
  12543. easing = delay;
  12544. delay = 0;
  12545. } // animateTo(target, time, delay, callback);
  12546. else if (isFunction(easing)) {
  12547. callback = easing;
  12548. easing = 'linear';
  12549. delay = 0;
  12550. } // animateTo(target, time, callback);
  12551. else if (isFunction(delay)) {
  12552. callback = delay;
  12553. delay = 0;
  12554. } // animateTo(target, callback)
  12555. else if (isFunction(time)) {
  12556. callback = time;
  12557. time = 500;
  12558. } // animateTo(target)
  12559. else if (!time) {
  12560. time = 500;
  12561. } // Stop all previous animations
  12562. animatable.stopAnimation();
  12563. animateToShallow(animatable, '', animatable, target, time, delay, reverse); // Animators may be removed immediately after start
  12564. // if there is nothing to animate
  12565. var animators = animatable.animators.slice();
  12566. var count = animators.length;
  12567. function done() {
  12568. count--;
  12569. if (!count) {
  12570. callback && callback();
  12571. }
  12572. } // No animators. This should be checked before animators[i].start(),
  12573. // because 'done' may be executed immediately if no need to animate.
  12574. if (!count) {
  12575. callback && callback();
  12576. } // Start after all animators created
  12577. // Incase any animator is done immediately when all animation properties are not changed
  12578. for (var i = 0; i < animators.length; i++) {
  12579. animators[i].done(done).start(easing, forceAnimate);
  12580. }
  12581. }
  12582. /**
  12583. * @param {string} path=''
  12584. * @param {Object} source=animatable
  12585. * @param {Object} target
  12586. * @param {number} [time=500]
  12587. * @param {number} [delay=0]
  12588. * @param {boolean} [reverse] If `true`, animate
  12589. * from the `target` to current state.
  12590. *
  12591. * @example
  12592. * // Animate position
  12593. * el._animateToShallow({
  12594. * position: [10, 10]
  12595. * })
  12596. *
  12597. * // Animate shape, style and position in 100ms, delayed 100ms
  12598. * el._animateToShallow({
  12599. * shape: {
  12600. * width: 500
  12601. * },
  12602. * style: {
  12603. * fill: 'red'
  12604. * }
  12605. * position: [10, 10]
  12606. * }, 100, 100)
  12607. */
  12608. function animateToShallow(animatable, path, source, target, time, delay, reverse) {
  12609. var objShallow = {};
  12610. var propertyCount = 0;
  12611. for (var name in target) {
  12612. if (!target.hasOwnProperty(name)) {
  12613. continue;
  12614. }
  12615. if (source[name] != null) {
  12616. if (isObject(target[name]) && !isArrayLike(target[name])) {
  12617. animateToShallow(animatable, path ? path + '.' + name : name, source[name], target[name], time, delay, reverse);
  12618. } else {
  12619. if (reverse) {
  12620. objShallow[name] = source[name];
  12621. setAttrByPath(animatable, path, name, target[name]);
  12622. } else {
  12623. objShallow[name] = target[name];
  12624. }
  12625. propertyCount++;
  12626. }
  12627. } else if (target[name] != null && !reverse) {
  12628. setAttrByPath(animatable, path, name, target[name]);
  12629. }
  12630. }
  12631. if (propertyCount > 0) {
  12632. animatable.animate(path, false).when(time == null ? 500 : time, objShallow).delay(delay || 0);
  12633. }
  12634. }
  12635. function setAttrByPath(el, path, name, value) {
  12636. // Attr directly if not has property
  12637. // FIXME, if some property not needed for element ?
  12638. if (!path) {
  12639. el.attr(name, value);
  12640. } else {
  12641. // Only support set shape or style
  12642. var props = {};
  12643. props[path] = {};
  12644. props[path][name] = value;
  12645. el.attr(props);
  12646. }
  12647. }
  12648. var _default = Animatable;
  12649. module.exports = _default;
  12650. /***/ }),
  12651. /***/ "./node_modules/zrender/lib/mixin/Eventful.js":
  12652. /*!****************************************************!*\
  12653. !*** ./node_modules/zrender/lib/mixin/Eventful.js ***!
  12654. \****************************************************/
  12655. /*! no static exports found */
  12656. /***/ (function(module, exports) {
  12657. /**
  12658. * Event Mixin
  12659. * @module zrender/mixin/Eventful
  12660. * @author Kener (@Kener-林峰, kener.linfeng@gmail.com)
  12661. * pissang (https://www.github.com/pissang)
  12662. */
  12663. var arrySlice = Array.prototype.slice;
  12664. /**
  12665. * Event dispatcher.
  12666. *
  12667. * @alias module:zrender/mixin/Eventful
  12668. * @constructor
  12669. * @param {Object} [eventProcessor] The object eventProcessor is the scope when
  12670. * `eventProcessor.xxx` called.
  12671. * @param {Function} [eventProcessor.normalizeQuery]
  12672. * param: {string|Object} Raw query.
  12673. * return: {string|Object} Normalized query.
  12674. * @param {Function} [eventProcessor.filter] Event will be dispatched only
  12675. * if it returns `true`.
  12676. * param: {string} eventType
  12677. * param: {string|Object} query
  12678. * return: {boolean}
  12679. * @param {Function} [eventProcessor.afterTrigger] Called after all handlers called.
  12680. * param: {string} eventType
  12681. */
  12682. var Eventful = function (eventProcessor) {
  12683. this._$handlers = {};
  12684. this._$eventProcessor = eventProcessor;
  12685. };
  12686. Eventful.prototype = {
  12687. constructor: Eventful,
  12688. /**
  12689. * The handler can only be triggered once, then removed.
  12690. *
  12691. * @param {string} event The event name.
  12692. * @param {string|Object} [query] Condition used on event filter.
  12693. * @param {Function} handler The event handler.
  12694. * @param {Object} context
  12695. */
  12696. one: function (event, query, handler, context) {
  12697. return on(this, event, query, handler, context, true);
  12698. },
  12699. /**
  12700. * Bind a handler.
  12701. *
  12702. * @param {string} event The event name.
  12703. * @param {string|Object} [query] Condition used on event filter.
  12704. * @param {Function} handler The event handler.
  12705. * @param {Object} [context]
  12706. */
  12707. on: function (event, query, handler, context) {
  12708. return on(this, event, query, handler, context, false);
  12709. },
  12710. /**
  12711. * Whether any handler has bound.
  12712. *
  12713. * @param {string} event
  12714. * @return {boolean}
  12715. */
  12716. isSilent: function (event) {
  12717. var _h = this._$handlers;
  12718. return !_h[event] || !_h[event].length;
  12719. },
  12720. /**
  12721. * Unbind a event.
  12722. *
  12723. * @param {string} [event] The event name.
  12724. * If no `event` input, "off" all listeners.
  12725. * @param {Function} [handler] The event handler.
  12726. * If no `handler` input, "off" all listeners of the `event`.
  12727. */
  12728. off: function (event, handler) {
  12729. var _h = this._$handlers;
  12730. if (!event) {
  12731. this._$handlers = {};
  12732. return this;
  12733. }
  12734. if (handler) {
  12735. if (_h[event]) {
  12736. var newList = [];
  12737. for (var i = 0, l = _h[event].length; i < l; i++) {
  12738. if (_h[event][i].h !== handler) {
  12739. newList.push(_h[event][i]);
  12740. }
  12741. }
  12742. _h[event] = newList;
  12743. }
  12744. if (_h[event] && _h[event].length === 0) {
  12745. delete _h[event];
  12746. }
  12747. } else {
  12748. delete _h[event];
  12749. }
  12750. return this;
  12751. },
  12752. /**
  12753. * Dispatch a event.
  12754. *
  12755. * @param {string} type The event name.
  12756. */
  12757. trigger: function (type) {
  12758. var _h = this._$handlers[type];
  12759. var eventProcessor = this._$eventProcessor;
  12760. if (_h) {
  12761. var args = arguments;
  12762. var argLen = args.length;
  12763. if (argLen > 3) {
  12764. args = arrySlice.call(args, 1);
  12765. }
  12766. var len = _h.length;
  12767. for (var i = 0; i < len;) {
  12768. var hItem = _h[i];
  12769. if (eventProcessor && eventProcessor.filter && hItem.query != null && !eventProcessor.filter(type, hItem.query)) {
  12770. i++;
  12771. continue;
  12772. } // Optimize advise from backbone
  12773. switch (argLen) {
  12774. case 1:
  12775. hItem.h.call(hItem.ctx);
  12776. break;
  12777. case 2:
  12778. hItem.h.call(hItem.ctx, args[1]);
  12779. break;
  12780. case 3:
  12781. hItem.h.call(hItem.ctx, args[1], args[2]);
  12782. break;
  12783. default:
  12784. // have more than 2 given arguments
  12785. hItem.h.apply(hItem.ctx, args);
  12786. break;
  12787. }
  12788. if (hItem.one) {
  12789. _h.splice(i, 1);
  12790. len--;
  12791. } else {
  12792. i++;
  12793. }
  12794. }
  12795. }
  12796. eventProcessor && eventProcessor.afterTrigger && eventProcessor.afterTrigger(type);
  12797. return this;
  12798. },
  12799. /**
  12800. * Dispatch a event with context, which is specified at the last parameter.
  12801. *
  12802. * @param {string} type The event name.
  12803. */
  12804. triggerWithContext: function (type) {
  12805. var _h = this._$handlers[type];
  12806. var eventProcessor = this._$eventProcessor;
  12807. if (_h) {
  12808. var args = arguments;
  12809. var argLen = args.length;
  12810. if (argLen > 4) {
  12811. args = arrySlice.call(args, 1, args.length - 1);
  12812. }
  12813. var ctx = args[args.length - 1];
  12814. var len = _h.length;
  12815. for (var i = 0; i < len;) {
  12816. var hItem = _h[i];
  12817. if (eventProcessor && eventProcessor.filter && hItem.query != null && !eventProcessor.filter(type, hItem.query)) {
  12818. i++;
  12819. continue;
  12820. } // Optimize advise from backbone
  12821. switch (argLen) {
  12822. case 1:
  12823. hItem.h.call(ctx);
  12824. break;
  12825. case 2:
  12826. hItem.h.call(ctx, args[1]);
  12827. break;
  12828. case 3:
  12829. hItem.h.call(ctx, args[1], args[2]);
  12830. break;
  12831. default:
  12832. // have more than 2 given arguments
  12833. hItem.h.apply(ctx, args);
  12834. break;
  12835. }
  12836. if (hItem.one) {
  12837. _h.splice(i, 1);
  12838. len--;
  12839. } else {
  12840. i++;
  12841. }
  12842. }
  12843. }
  12844. eventProcessor && eventProcessor.afterTrigger && eventProcessor.afterTrigger(type);
  12845. return this;
  12846. }
  12847. };
  12848. function normalizeQuery(host, query) {
  12849. var eventProcessor = host._$eventProcessor;
  12850. if (query != null && eventProcessor && eventProcessor.normalizeQuery) {
  12851. query = eventProcessor.normalizeQuery(query);
  12852. }
  12853. return query;
  12854. }
  12855. function on(eventful, event, query, handler, context, isOnce) {
  12856. var _h = eventful._$handlers;
  12857. if (typeof query === 'function') {
  12858. context = handler;
  12859. handler = query;
  12860. query = null;
  12861. }
  12862. if (!handler || !event) {
  12863. return eventful;
  12864. }
  12865. query = normalizeQuery(eventful, query);
  12866. if (!_h[event]) {
  12867. _h[event] = [];
  12868. }
  12869. for (var i = 0; i < _h[event].length; i++) {
  12870. if (_h[event][i].h === handler) {
  12871. return eventful;
  12872. }
  12873. }
  12874. var wrap = {
  12875. h: handler,
  12876. one: isOnce,
  12877. query: query,
  12878. ctx: context || eventful,
  12879. // FIXME
  12880. // Do not publish this feature util it is proved that it makes sense.
  12881. callAtLast: handler.zrEventfulCallAtLast
  12882. };
  12883. var lastIndex = _h[event].length - 1;
  12884. var lastWrap = _h[event][lastIndex];
  12885. lastWrap && lastWrap.callAtLast ? _h[event].splice(lastIndex, 0, wrap) : _h[event].push(wrap);
  12886. return eventful;
  12887. } // ----------------------
  12888. // The events in zrender
  12889. // ----------------------
  12890. /**
  12891. * @event module:zrender/mixin/Eventful#onclick
  12892. * @type {Function}
  12893. * @default null
  12894. */
  12895. /**
  12896. * @event module:zrender/mixin/Eventful#onmouseover
  12897. * @type {Function}
  12898. * @default null
  12899. */
  12900. /**
  12901. * @event module:zrender/mixin/Eventful#onmouseout
  12902. * @type {Function}
  12903. * @default null
  12904. */
  12905. /**
  12906. * @event module:zrender/mixin/Eventful#onmousemove
  12907. * @type {Function}
  12908. * @default null
  12909. */
  12910. /**
  12911. * @event module:zrender/mixin/Eventful#onmousewheel
  12912. * @type {Function}
  12913. * @default null
  12914. */
  12915. /**
  12916. * @event module:zrender/mixin/Eventful#onmousedown
  12917. * @type {Function}
  12918. * @default null
  12919. */
  12920. /**
  12921. * @event module:zrender/mixin/Eventful#onmouseup
  12922. * @type {Function}
  12923. * @default null
  12924. */
  12925. /**
  12926. * @event module:zrender/mixin/Eventful#ondrag
  12927. * @type {Function}
  12928. * @default null
  12929. */
  12930. /**
  12931. * @event module:zrender/mixin/Eventful#ondragstart
  12932. * @type {Function}
  12933. * @default null
  12934. */
  12935. /**
  12936. * @event module:zrender/mixin/Eventful#ondragend
  12937. * @type {Function}
  12938. * @default null
  12939. */
  12940. /**
  12941. * @event module:zrender/mixin/Eventful#ondragenter
  12942. * @type {Function}
  12943. * @default null
  12944. */
  12945. /**
  12946. * @event module:zrender/mixin/Eventful#ondragleave
  12947. * @type {Function}
  12948. * @default null
  12949. */
  12950. /**
  12951. * @event module:zrender/mixin/Eventful#ondragover
  12952. * @type {Function}
  12953. * @default null
  12954. */
  12955. /**
  12956. * @event module:zrender/mixin/Eventful#ondrop
  12957. * @type {Function}
  12958. * @default null
  12959. */
  12960. var _default = Eventful;
  12961. module.exports = _default;
  12962. /***/ }),
  12963. /***/ "./node_modules/zrender/lib/mixin/Transformable.js":
  12964. /*!*********************************************************!*\
  12965. !*** ./node_modules/zrender/lib/mixin/Transformable.js ***!
  12966. \*********************************************************/
  12967. /*! no static exports found */
  12968. /***/ (function(module, exports, __webpack_require__) {
  12969. var matrix = __webpack_require__(/*! ../core/matrix */ "./node_modules/zrender/lib/core/matrix.js");
  12970. var vector = __webpack_require__(/*! ../core/vector */ "./node_modules/zrender/lib/core/vector.js");
  12971. /**
  12972. * 提供变换扩展
  12973. * @module zrender/mixin/Transformable
  12974. * @author pissang (https://www.github.com/pissang)
  12975. */
  12976. var mIdentity = matrix.identity;
  12977. var EPSILON = 5e-5;
  12978. function isNotAroundZero(val) {
  12979. return val > EPSILON || val < -EPSILON;
  12980. }
  12981. /**
  12982. * @alias module:zrender/mixin/Transformable
  12983. * @constructor
  12984. */
  12985. var Transformable = function (opts) {
  12986. opts = opts || {}; // If there are no given position, rotation, scale
  12987. if (!opts.position) {
  12988. /**
  12989. * 平移
  12990. * @type {Array.<number>}
  12991. * @default [0, 0]
  12992. */
  12993. this.position = [0, 0];
  12994. }
  12995. if (opts.rotation == null) {
  12996. /**
  12997. * 旋转
  12998. * @type {Array.<number>}
  12999. * @default 0
  13000. */
  13001. this.rotation = 0;
  13002. }
  13003. if (!opts.scale) {
  13004. /**
  13005. * 缩放
  13006. * @type {Array.<number>}
  13007. * @default [1, 1]
  13008. */
  13009. this.scale = [1, 1];
  13010. }
  13011. /**
  13012. * 旋转和缩放的原点
  13013. * @type {Array.<number>}
  13014. * @default null
  13015. */
  13016. this.origin = this.origin || null;
  13017. };
  13018. var transformableProto = Transformable.prototype;
  13019. transformableProto.transform = null;
  13020. /**
  13021. * 判断是否需要有坐标变换
  13022. * 如果有坐标变换, 则从position, rotation, scale以及父节点的transform计算出自身的transform矩阵
  13023. */
  13024. transformableProto.needLocalTransform = function () {
  13025. return isNotAroundZero(this.rotation) || isNotAroundZero(this.position[0]) || isNotAroundZero(this.position[1]) || isNotAroundZero(this.scale[0] - 1) || isNotAroundZero(this.scale[1] - 1);
  13026. };
  13027. var scaleTmp = [];
  13028. transformableProto.updateTransform = function () {
  13029. var parent = this.parent;
  13030. var parentHasTransform = parent && parent.transform;
  13031. var needLocalTransform = this.needLocalTransform();
  13032. var m = this.transform;
  13033. if (!(needLocalTransform || parentHasTransform)) {
  13034. m && mIdentity(m);
  13035. return;
  13036. }
  13037. m = m || matrix.create();
  13038. if (needLocalTransform) {
  13039. this.getLocalTransform(m);
  13040. } else {
  13041. mIdentity(m);
  13042. } // 应用父节点变换
  13043. if (parentHasTransform) {
  13044. if (needLocalTransform) {
  13045. matrix.mul(m, parent.transform, m);
  13046. } else {
  13047. matrix.copy(m, parent.transform);
  13048. }
  13049. } // 保存这个变换矩阵
  13050. this.transform = m;
  13051. var globalScaleRatio = this.globalScaleRatio;
  13052. if (globalScaleRatio != null && globalScaleRatio !== 1) {
  13053. this.getGlobalScale(scaleTmp);
  13054. var relX = scaleTmp[0] < 0 ? -1 : 1;
  13055. var relY = scaleTmp[1] < 0 ? -1 : 1;
  13056. var sx = ((scaleTmp[0] - relX) * globalScaleRatio + relX) / scaleTmp[0] || 0;
  13057. var sy = ((scaleTmp[1] - relY) * globalScaleRatio + relY) / scaleTmp[1] || 0;
  13058. m[0] *= sx;
  13059. m[1] *= sx;
  13060. m[2] *= sy;
  13061. m[3] *= sy;
  13062. }
  13063. this.invTransform = this.invTransform || matrix.create();
  13064. matrix.invert(this.invTransform, m);
  13065. };
  13066. transformableProto.getLocalTransform = function (m) {
  13067. return Transformable.getLocalTransform(this, m);
  13068. };
  13069. /**
  13070. * 将自己的transform应用到context上
  13071. * @param {CanvasRenderingContext2D} ctx
  13072. */
  13073. transformableProto.setTransform = function (ctx) {
  13074. var m = this.transform;
  13075. var dpr = ctx.dpr || 1;
  13076. if (m) {
  13077. ctx.setTransform(dpr * m[0], dpr * m[1], dpr * m[2], dpr * m[3], dpr * m[4], dpr * m[5]);
  13078. } else {
  13079. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  13080. }
  13081. };
  13082. transformableProto.restoreTransform = function (ctx) {
  13083. var dpr = ctx.dpr || 1;
  13084. ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
  13085. };
  13086. var tmpTransform = [];
  13087. var originTransform = matrix.create();
  13088. transformableProto.setLocalTransform = function (m) {
  13089. if (!m) {
  13090. // TODO return or set identity?
  13091. return;
  13092. }
  13093. var sx = m[0] * m[0] + m[1] * m[1];
  13094. var sy = m[2] * m[2] + m[3] * m[3];
  13095. var position = this.position;
  13096. var scale = this.scale;
  13097. if (isNotAroundZero(sx - 1)) {
  13098. sx = Math.sqrt(sx);
  13099. }
  13100. if (isNotAroundZero(sy - 1)) {
  13101. sy = Math.sqrt(sy);
  13102. }
  13103. if (m[0] < 0) {
  13104. sx = -sx;
  13105. }
  13106. if (m[3] < 0) {
  13107. sy = -sy;
  13108. }
  13109. position[0] = m[4];
  13110. position[1] = m[5];
  13111. scale[0] = sx;
  13112. scale[1] = sy;
  13113. this.rotation = Math.atan2(-m[1] / sy, m[0] / sx);
  13114. };
  13115. /**
  13116. * 分解`transform`矩阵到`position`, `rotation`, `scale`
  13117. */
  13118. transformableProto.decomposeTransform = function () {
  13119. if (!this.transform) {
  13120. return;
  13121. }
  13122. var parent = this.parent;
  13123. var m = this.transform;
  13124. if (parent && parent.transform) {
  13125. // Get local transform and decompose them to position, scale, rotation
  13126. matrix.mul(tmpTransform, parent.invTransform, m);
  13127. m = tmpTransform;
  13128. }
  13129. var origin = this.origin;
  13130. if (origin && (origin[0] || origin[1])) {
  13131. originTransform[4] = origin[0];
  13132. originTransform[5] = origin[1];
  13133. matrix.mul(tmpTransform, m, originTransform);
  13134. tmpTransform[4] -= origin[0];
  13135. tmpTransform[5] -= origin[1];
  13136. m = tmpTransform;
  13137. }
  13138. this.setLocalTransform(m);
  13139. };
  13140. /**
  13141. * Get global scale
  13142. * @return {Array.<number>}
  13143. */
  13144. transformableProto.getGlobalScale = function (out) {
  13145. var m = this.transform;
  13146. out = out || [];
  13147. if (!m) {
  13148. out[0] = 1;
  13149. out[1] = 1;
  13150. return out;
  13151. }
  13152. out[0] = Math.sqrt(m[0] * m[0] + m[1] * m[1]);
  13153. out[1] = Math.sqrt(m[2] * m[2] + m[3] * m[3]);
  13154. if (m[0] < 0) {
  13155. out[0] = -out[0];
  13156. }
  13157. if (m[3] < 0) {
  13158. out[1] = -out[1];
  13159. }
  13160. return out;
  13161. };
  13162. /**
  13163. * 变换坐标位置到 shape 的局部坐标空间
  13164. * @method
  13165. * @param {number} x
  13166. * @param {number} y
  13167. * @return {Array.<number>}
  13168. */
  13169. transformableProto.transformCoordToLocal = function (x, y) {
  13170. var v2 = [x, y];
  13171. var invTransform = this.invTransform;
  13172. if (invTransform) {
  13173. vector.applyTransform(v2, v2, invTransform);
  13174. }
  13175. return v2;
  13176. };
  13177. /**
  13178. * 变换局部坐标位置到全局坐标空间
  13179. * @method
  13180. * @param {number} x
  13181. * @param {number} y
  13182. * @return {Array.<number>}
  13183. */
  13184. transformableProto.transformCoordToGlobal = function (x, y) {
  13185. var v2 = [x, y];
  13186. var transform = this.transform;
  13187. if (transform) {
  13188. vector.applyTransform(v2, v2, transform);
  13189. }
  13190. return v2;
  13191. };
  13192. /**
  13193. * @static
  13194. * @param {Object} target
  13195. * @param {Array.<number>} target.origin
  13196. * @param {number} target.rotation
  13197. * @param {Array.<number>} target.position
  13198. * @param {Array.<number>} [m]
  13199. */
  13200. Transformable.getLocalTransform = function (target, m) {
  13201. m = m || [];
  13202. mIdentity(m);
  13203. var origin = target.origin;
  13204. var scale = target.scale || [1, 1];
  13205. var rotation = target.rotation || 0;
  13206. var position = target.position || [0, 0];
  13207. if (origin) {
  13208. // Translate to origin
  13209. m[4] -= origin[0];
  13210. m[5] -= origin[1];
  13211. }
  13212. matrix.scale(m, m, scale);
  13213. if (rotation) {
  13214. matrix.rotate(m, m, rotation);
  13215. }
  13216. if (origin) {
  13217. // Translate back from origin
  13218. m[4] += origin[0];
  13219. m[5] += origin[1];
  13220. }
  13221. m[4] += position[0];
  13222. m[5] += position[1];
  13223. return m;
  13224. };
  13225. var _default = Transformable;
  13226. module.exports = _default;
  13227. /***/ }),
  13228. /***/ "./node_modules/zrender/lib/tool/color.js":
  13229. /*!************************************************!*\
  13230. !*** ./node_modules/zrender/lib/tool/color.js ***!
  13231. \************************************************/
  13232. /*! no static exports found */
  13233. /***/ (function(module, exports, __webpack_require__) {
  13234. var LRU = __webpack_require__(/*! ../core/LRU */ "./node_modules/zrender/lib/core/LRU.js");
  13235. var kCSSColorTable = {
  13236. 'transparent': [0, 0, 0, 0],
  13237. 'aliceblue': [240, 248, 255, 1],
  13238. 'antiquewhite': [250, 235, 215, 1],
  13239. 'aqua': [0, 255, 255, 1],
  13240. 'aquamarine': [127, 255, 212, 1],
  13241. 'azure': [240, 255, 255, 1],
  13242. 'beige': [245, 245, 220, 1],
  13243. 'bisque': [255, 228, 196, 1],
  13244. 'black': [0, 0, 0, 1],
  13245. 'blanchedalmond': [255, 235, 205, 1],
  13246. 'blue': [0, 0, 255, 1],
  13247. 'blueviolet': [138, 43, 226, 1],
  13248. 'brown': [165, 42, 42, 1],
  13249. 'burlywood': [222, 184, 135, 1],
  13250. 'cadetblue': [95, 158, 160, 1],
  13251. 'chartreuse': [127, 255, 0, 1],
  13252. 'chocolate': [210, 105, 30, 1],
  13253. 'coral': [255, 127, 80, 1],
  13254. 'cornflowerblue': [100, 149, 237, 1],
  13255. 'cornsilk': [255, 248, 220, 1],
  13256. 'crimson': [220, 20, 60, 1],
  13257. 'cyan': [0, 255, 255, 1],
  13258. 'darkblue': [0, 0, 139, 1],
  13259. 'darkcyan': [0, 139, 139, 1],
  13260. 'darkgoldenrod': [184, 134, 11, 1],
  13261. 'darkgray': [169, 169, 169, 1],
  13262. 'darkgreen': [0, 100, 0, 1],
  13263. 'darkgrey': [169, 169, 169, 1],
  13264. 'darkkhaki': [189, 183, 107, 1],
  13265. 'darkmagenta': [139, 0, 139, 1],
  13266. 'darkolivegreen': [85, 107, 47, 1],
  13267. 'darkorange': [255, 140, 0, 1],
  13268. 'darkorchid': [153, 50, 204, 1],
  13269. 'darkred': [139, 0, 0, 1],
  13270. 'darksalmon': [233, 150, 122, 1],
  13271. 'darkseagreen': [143, 188, 143, 1],
  13272. 'darkslateblue': [72, 61, 139, 1],
  13273. 'darkslategray': [47, 79, 79, 1],
  13274. 'darkslategrey': [47, 79, 79, 1],
  13275. 'darkturquoise': [0, 206, 209, 1],
  13276. 'darkviolet': [148, 0, 211, 1],
  13277. 'deeppink': [255, 20, 147, 1],
  13278. 'deepskyblue': [0, 191, 255, 1],
  13279. 'dimgray': [105, 105, 105, 1],
  13280. 'dimgrey': [105, 105, 105, 1],
  13281. 'dodgerblue': [30, 144, 255, 1],
  13282. 'firebrick': [178, 34, 34, 1],
  13283. 'floralwhite': [255, 250, 240, 1],
  13284. 'forestgreen': [34, 139, 34, 1],
  13285. 'fuchsia': [255, 0, 255, 1],
  13286. 'gainsboro': [220, 220, 220, 1],
  13287. 'ghostwhite': [248, 248, 255, 1],
  13288. 'gold': [255, 215, 0, 1],
  13289. 'goldenrod': [218, 165, 32, 1],
  13290. 'gray': [128, 128, 128, 1],
  13291. 'green': [0, 128, 0, 1],
  13292. 'greenyellow': [173, 255, 47, 1],
  13293. 'grey': [128, 128, 128, 1],
  13294. 'honeydew': [240, 255, 240, 1],
  13295. 'hotpink': [255, 105, 180, 1],
  13296. 'indianred': [205, 92, 92, 1],
  13297. 'indigo': [75, 0, 130, 1],
  13298. 'ivory': [255, 255, 240, 1],
  13299. 'khaki': [240, 230, 140, 1],
  13300. 'lavender': [230, 230, 250, 1],
  13301. 'lavenderblush': [255, 240, 245, 1],
  13302. 'lawngreen': [124, 252, 0, 1],
  13303. 'lemonchiffon': [255, 250, 205, 1],
  13304. 'lightblue': [173, 216, 230, 1],
  13305. 'lightcoral': [240, 128, 128, 1],
  13306. 'lightcyan': [224, 255, 255, 1],
  13307. 'lightgoldenrodyellow': [250, 250, 210, 1],
  13308. 'lightgray': [211, 211, 211, 1],
  13309. 'lightgreen': [144, 238, 144, 1],
  13310. 'lightgrey': [211, 211, 211, 1],
  13311. 'lightpink': [255, 182, 193, 1],
  13312. 'lightsalmon': [255, 160, 122, 1],
  13313. 'lightseagreen': [32, 178, 170, 1],
  13314. 'lightskyblue': [135, 206, 250, 1],
  13315. 'lightslategray': [119, 136, 153, 1],
  13316. 'lightslategrey': [119, 136, 153, 1],
  13317. 'lightsteelblue': [176, 196, 222, 1],
  13318. 'lightyellow': [255, 255, 224, 1],
  13319. 'lime': [0, 255, 0, 1],
  13320. 'limegreen': [50, 205, 50, 1],
  13321. 'linen': [250, 240, 230, 1],
  13322. 'magenta': [255, 0, 255, 1],
  13323. 'maroon': [128, 0, 0, 1],
  13324. 'mediumaquamarine': [102, 205, 170, 1],
  13325. 'mediumblue': [0, 0, 205, 1],
  13326. 'mediumorchid': [186, 85, 211, 1],
  13327. 'mediumpurple': [147, 112, 219, 1],
  13328. 'mediumseagreen': [60, 179, 113, 1],
  13329. 'mediumslateblue': [123, 104, 238, 1],
  13330. 'mediumspringgreen': [0, 250, 154, 1],
  13331. 'mediumturquoise': [72, 209, 204, 1],
  13332. 'mediumvioletred': [199, 21, 133, 1],
  13333. 'midnightblue': [25, 25, 112, 1],
  13334. 'mintcream': [245, 255, 250, 1],
  13335. 'mistyrose': [255, 228, 225, 1],
  13336. 'moccasin': [255, 228, 181, 1],
  13337. 'navajowhite': [255, 222, 173, 1],
  13338. 'navy': [0, 0, 128, 1],
  13339. 'oldlace': [253, 245, 230, 1],
  13340. 'olive': [128, 128, 0, 1],
  13341. 'olivedrab': [107, 142, 35, 1],
  13342. 'orange': [255, 165, 0, 1],
  13343. 'orangered': [255, 69, 0, 1],
  13344. 'orchid': [218, 112, 214, 1],
  13345. 'palegoldenrod': [238, 232, 170, 1],
  13346. 'palegreen': [152, 251, 152, 1],
  13347. 'paleturquoise': [175, 238, 238, 1],
  13348. 'palevioletred': [219, 112, 147, 1],
  13349. 'papayawhip': [255, 239, 213, 1],
  13350. 'peachpuff': [255, 218, 185, 1],
  13351. 'peru': [205, 133, 63, 1],
  13352. 'pink': [255, 192, 203, 1],
  13353. 'plum': [221, 160, 221, 1],
  13354. 'powderblue': [176, 224, 230, 1],
  13355. 'purple': [128, 0, 128, 1],
  13356. 'red': [255, 0, 0, 1],
  13357. 'rosybrown': [188, 143, 143, 1],
  13358. 'royalblue': [65, 105, 225, 1],
  13359. 'saddlebrown': [139, 69, 19, 1],
  13360. 'salmon': [250, 128, 114, 1],
  13361. 'sandybrown': [244, 164, 96, 1],
  13362. 'seagreen': [46, 139, 87, 1],
  13363. 'seashell': [255, 245, 238, 1],
  13364. 'sienna': [160, 82, 45, 1],
  13365. 'silver': [192, 192, 192, 1],
  13366. 'skyblue': [135, 206, 235, 1],
  13367. 'slateblue': [106, 90, 205, 1],
  13368. 'slategray': [112, 128, 144, 1],
  13369. 'slategrey': [112, 128, 144, 1],
  13370. 'snow': [255, 250, 250, 1],
  13371. 'springgreen': [0, 255, 127, 1],
  13372. 'steelblue': [70, 130, 180, 1],
  13373. 'tan': [210, 180, 140, 1],
  13374. 'teal': [0, 128, 128, 1],
  13375. 'thistle': [216, 191, 216, 1],
  13376. 'tomato': [255, 99, 71, 1],
  13377. 'turquoise': [64, 224, 208, 1],
  13378. 'violet': [238, 130, 238, 1],
  13379. 'wheat': [245, 222, 179, 1],
  13380. 'white': [255, 255, 255, 1],
  13381. 'whitesmoke': [245, 245, 245, 1],
  13382. 'yellow': [255, 255, 0, 1],
  13383. 'yellowgreen': [154, 205, 50, 1]
  13384. };
  13385. function clampCssByte(i) {
  13386. // Clamp to integer 0 .. 255.
  13387. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  13388. return i < 0 ? 0 : i > 255 ? 255 : i;
  13389. }
  13390. function clampCssAngle(i) {
  13391. // Clamp to integer 0 .. 360.
  13392. i = Math.round(i); // Seems to be what Chrome does (vs truncation).
  13393. return i < 0 ? 0 : i > 360 ? 360 : i;
  13394. }
  13395. function clampCssFloat(f) {
  13396. // Clamp to float 0.0 .. 1.0.
  13397. return f < 0 ? 0 : f > 1 ? 1 : f;
  13398. }
  13399. function parseCssInt(str) {
  13400. // int or percentage.
  13401. if (str.length && str.charAt(str.length - 1) === '%') {
  13402. return clampCssByte(parseFloat(str) / 100 * 255);
  13403. }
  13404. return clampCssByte(parseInt(str, 10));
  13405. }
  13406. function parseCssFloat(str) {
  13407. // float or percentage.
  13408. if (str.length && str.charAt(str.length - 1) === '%') {
  13409. return clampCssFloat(parseFloat(str) / 100);
  13410. }
  13411. return clampCssFloat(parseFloat(str));
  13412. }
  13413. function cssHueToRgb(m1, m2, h) {
  13414. if (h < 0) {
  13415. h += 1;
  13416. } else if (h > 1) {
  13417. h -= 1;
  13418. }
  13419. if (h * 6 < 1) {
  13420. return m1 + (m2 - m1) * h * 6;
  13421. }
  13422. if (h * 2 < 1) {
  13423. return m2;
  13424. }
  13425. if (h * 3 < 2) {
  13426. return m1 + (m2 - m1) * (2 / 3 - h) * 6;
  13427. }
  13428. return m1;
  13429. }
  13430. function lerpNumber(a, b, p) {
  13431. return a + (b - a) * p;
  13432. }
  13433. function setRgba(out, r, g, b, a) {
  13434. out[0] = r;
  13435. out[1] = g;
  13436. out[2] = b;
  13437. out[3] = a;
  13438. return out;
  13439. }
  13440. function copyRgba(out, a) {
  13441. out[0] = a[0];
  13442. out[1] = a[1];
  13443. out[2] = a[2];
  13444. out[3] = a[3];
  13445. return out;
  13446. }
  13447. var colorCache = new LRU(20);
  13448. var lastRemovedArr = null;
  13449. function putToCache(colorStr, rgbaArr) {
  13450. // Reuse removed array
  13451. if (lastRemovedArr) {
  13452. copyRgba(lastRemovedArr, rgbaArr);
  13453. }
  13454. lastRemovedArr = colorCache.put(colorStr, lastRemovedArr || rgbaArr.slice());
  13455. }
  13456. /**
  13457. * @param {string} colorStr
  13458. * @param {Array.<number>} out
  13459. * @return {Array.<number>}
  13460. * @memberOf module:zrender/util/color
  13461. */
  13462. function parse(colorStr, rgbaArr) {
  13463. if (!colorStr) {
  13464. return;
  13465. }
  13466. rgbaArr = rgbaArr || [];
  13467. var cached = colorCache.get(colorStr);
  13468. if (cached) {
  13469. return copyRgba(rgbaArr, cached);
  13470. } // colorStr may be not string
  13471. colorStr = colorStr + ''; // Remove all whitespace, not compliant, but should just be more accepting.
  13472. var str = colorStr.replace(/ /g, '').toLowerCase(); // Color keywords (and transparent) lookup.
  13473. if (str in kCSSColorTable) {
  13474. copyRgba(rgbaArr, kCSSColorTable[str]);
  13475. putToCache(colorStr, rgbaArr);
  13476. return rgbaArr;
  13477. } // #abc and #abc123 syntax.
  13478. if (str.charAt(0) === '#') {
  13479. if (str.length === 4) {
  13480. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  13481. if (!(iv >= 0 && iv <= 0xfff)) {
  13482. setRgba(rgbaArr, 0, 0, 0, 1);
  13483. return; // Covers NaN.
  13484. }
  13485. setRgba(rgbaArr, (iv & 0xf00) >> 4 | (iv & 0xf00) >> 8, iv & 0xf0 | (iv & 0xf0) >> 4, iv & 0xf | (iv & 0xf) << 4, 1);
  13486. putToCache(colorStr, rgbaArr);
  13487. return rgbaArr;
  13488. } else if (str.length === 7) {
  13489. var iv = parseInt(str.substr(1), 16); // TODO(deanm): Stricter parsing.
  13490. if (!(iv >= 0 && iv <= 0xffffff)) {
  13491. setRgba(rgbaArr, 0, 0, 0, 1);
  13492. return; // Covers NaN.
  13493. }
  13494. setRgba(rgbaArr, (iv & 0xff0000) >> 16, (iv & 0xff00) >> 8, iv & 0xff, 1);
  13495. putToCache(colorStr, rgbaArr);
  13496. return rgbaArr;
  13497. }
  13498. return;
  13499. }
  13500. var op = str.indexOf('(');
  13501. var ep = str.indexOf(')');
  13502. if (op !== -1 && ep + 1 === str.length) {
  13503. var fname = str.substr(0, op);
  13504. var params = str.substr(op + 1, ep - (op + 1)).split(',');
  13505. var alpha = 1; // To allow case fallthrough.
  13506. switch (fname) {
  13507. case 'rgba':
  13508. if (params.length !== 4) {
  13509. setRgba(rgbaArr, 0, 0, 0, 1);
  13510. return;
  13511. }
  13512. alpha = parseCssFloat(params.pop());
  13513. // jshint ignore:line
  13514. // Fall through.
  13515. case 'rgb':
  13516. if (params.length !== 3) {
  13517. setRgba(rgbaArr, 0, 0, 0, 1);
  13518. return;
  13519. }
  13520. setRgba(rgbaArr, parseCssInt(params[0]), parseCssInt(params[1]), parseCssInt(params[2]), alpha);
  13521. putToCache(colorStr, rgbaArr);
  13522. return rgbaArr;
  13523. case 'hsla':
  13524. if (params.length !== 4) {
  13525. setRgba(rgbaArr, 0, 0, 0, 1);
  13526. return;
  13527. }
  13528. params[3] = parseCssFloat(params[3]);
  13529. hsla2rgba(params, rgbaArr);
  13530. putToCache(colorStr, rgbaArr);
  13531. return rgbaArr;
  13532. case 'hsl':
  13533. if (params.length !== 3) {
  13534. setRgba(rgbaArr, 0, 0, 0, 1);
  13535. return;
  13536. }
  13537. hsla2rgba(params, rgbaArr);
  13538. putToCache(colorStr, rgbaArr);
  13539. return rgbaArr;
  13540. default:
  13541. return;
  13542. }
  13543. }
  13544. setRgba(rgbaArr, 0, 0, 0, 1);
  13545. return;
  13546. }
  13547. /**
  13548. * @param {Array.<number>} hsla
  13549. * @param {Array.<number>} rgba
  13550. * @return {Array.<number>} rgba
  13551. */
  13552. function hsla2rgba(hsla, rgba) {
  13553. var h = (parseFloat(hsla[0]) % 360 + 360) % 360 / 360; // 0 .. 1
  13554. // NOTE(deanm): According to the CSS spec s/l should only be
  13555. // percentages, but we don't bother and let float or percentage.
  13556. var s = parseCssFloat(hsla[1]);
  13557. var l = parseCssFloat(hsla[2]);
  13558. var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
  13559. var m1 = l * 2 - m2;
  13560. rgba = rgba || [];
  13561. setRgba(rgba, clampCssByte(cssHueToRgb(m1, m2, h + 1 / 3) * 255), clampCssByte(cssHueToRgb(m1, m2, h) * 255), clampCssByte(cssHueToRgb(m1, m2, h - 1 / 3) * 255), 1);
  13562. if (hsla.length === 4) {
  13563. rgba[3] = hsla[3];
  13564. }
  13565. return rgba;
  13566. }
  13567. /**
  13568. * @param {Array.<number>} rgba
  13569. * @return {Array.<number>} hsla
  13570. */
  13571. function rgba2hsla(rgba) {
  13572. if (!rgba) {
  13573. return;
  13574. } // RGB from 0 to 255
  13575. var R = rgba[0] / 255;
  13576. var G = rgba[1] / 255;
  13577. var B = rgba[2] / 255;
  13578. var vMin = Math.min(R, G, B); // Min. value of RGB
  13579. var vMax = Math.max(R, G, B); // Max. value of RGB
  13580. var delta = vMax - vMin; // Delta RGB value
  13581. var L = (vMax + vMin) / 2;
  13582. var H;
  13583. var S; // HSL results from 0 to 1
  13584. if (delta === 0) {
  13585. H = 0;
  13586. S = 0;
  13587. } else {
  13588. if (L < 0.5) {
  13589. S = delta / (vMax + vMin);
  13590. } else {
  13591. S = delta / (2 - vMax - vMin);
  13592. }
  13593. var deltaR = ((vMax - R) / 6 + delta / 2) / delta;
  13594. var deltaG = ((vMax - G) / 6 + delta / 2) / delta;
  13595. var deltaB = ((vMax - B) / 6 + delta / 2) / delta;
  13596. if (R === vMax) {
  13597. H = deltaB - deltaG;
  13598. } else if (G === vMax) {
  13599. H = 1 / 3 + deltaR - deltaB;
  13600. } else if (B === vMax) {
  13601. H = 2 / 3 + deltaG - deltaR;
  13602. }
  13603. if (H < 0) {
  13604. H += 1;
  13605. }
  13606. if (H > 1) {
  13607. H -= 1;
  13608. }
  13609. }
  13610. var hsla = [H * 360, S, L];
  13611. if (rgba[3] != null) {
  13612. hsla.push(rgba[3]);
  13613. }
  13614. return hsla;
  13615. }
  13616. /**
  13617. * @param {string} color
  13618. * @param {number} level
  13619. * @return {string}
  13620. * @memberOf module:zrender/util/color
  13621. */
  13622. function lift(color, level) {
  13623. var colorArr = parse(color);
  13624. if (colorArr) {
  13625. for (var i = 0; i < 3; i++) {
  13626. if (level < 0) {
  13627. colorArr[i] = colorArr[i] * (1 - level) | 0;
  13628. } else {
  13629. colorArr[i] = (255 - colorArr[i]) * level + colorArr[i] | 0;
  13630. }
  13631. if (colorArr[i] > 255) {
  13632. colorArr[i] = 255;
  13633. } else if (color[i] < 0) {
  13634. colorArr[i] = 0;
  13635. }
  13636. }
  13637. return stringify(colorArr, colorArr.length === 4 ? 'rgba' : 'rgb');
  13638. }
  13639. }
  13640. /**
  13641. * @param {string} color
  13642. * @return {string}
  13643. * @memberOf module:zrender/util/color
  13644. */
  13645. function toHex(color) {
  13646. var colorArr = parse(color);
  13647. if (colorArr) {
  13648. return ((1 << 24) + (colorArr[0] << 16) + (colorArr[1] << 8) + +colorArr[2]).toString(16).slice(1);
  13649. }
  13650. }
  13651. /**
  13652. * Map value to color. Faster than lerp methods because color is represented by rgba array.
  13653. * @param {number} normalizedValue A float between 0 and 1.
  13654. * @param {Array.<Array.<number>>} colors List of rgba color array
  13655. * @param {Array.<number>} [out] Mapped gba color array
  13656. * @return {Array.<number>} will be null/undefined if input illegal.
  13657. */
  13658. function fastLerp(normalizedValue, colors, out) {
  13659. if (!(colors && colors.length) || !(normalizedValue >= 0 && normalizedValue <= 1)) {
  13660. return;
  13661. }
  13662. out = out || [];
  13663. var value = normalizedValue * (colors.length - 1);
  13664. var leftIndex = Math.floor(value);
  13665. var rightIndex = Math.ceil(value);
  13666. var leftColor = colors[leftIndex];
  13667. var rightColor = colors[rightIndex];
  13668. var dv = value - leftIndex;
  13669. out[0] = clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv));
  13670. out[1] = clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv));
  13671. out[2] = clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv));
  13672. out[3] = clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv));
  13673. return out;
  13674. }
  13675. /**
  13676. * @deprecated
  13677. */
  13678. var fastMapToColor = fastLerp;
  13679. /**
  13680. * @param {number} normalizedValue A float between 0 and 1.
  13681. * @param {Array.<string>} colors Color list.
  13682. * @param {boolean=} fullOutput Default false.
  13683. * @return {(string|Object)} Result color. If fullOutput,
  13684. * return {color: ..., leftIndex: ..., rightIndex: ..., value: ...},
  13685. * @memberOf module:zrender/util/color
  13686. */
  13687. function lerp(normalizedValue, colors, fullOutput) {
  13688. if (!(colors && colors.length) || !(normalizedValue >= 0 && normalizedValue <= 1)) {
  13689. return;
  13690. }
  13691. var value = normalizedValue * (colors.length - 1);
  13692. var leftIndex = Math.floor(value);
  13693. var rightIndex = Math.ceil(value);
  13694. var leftColor = parse(colors[leftIndex]);
  13695. var rightColor = parse(colors[rightIndex]);
  13696. var dv = value - leftIndex;
  13697. var color = stringify([clampCssByte(lerpNumber(leftColor[0], rightColor[0], dv)), clampCssByte(lerpNumber(leftColor[1], rightColor[1], dv)), clampCssByte(lerpNumber(leftColor[2], rightColor[2], dv)), clampCssFloat(lerpNumber(leftColor[3], rightColor[3], dv))], 'rgba');
  13698. return fullOutput ? {
  13699. color: color,
  13700. leftIndex: leftIndex,
  13701. rightIndex: rightIndex,
  13702. value: value
  13703. } : color;
  13704. }
  13705. /**
  13706. * @deprecated
  13707. */
  13708. var mapToColor = lerp;
  13709. /**
  13710. * @param {string} color
  13711. * @param {number=} h 0 ~ 360, ignore when null.
  13712. * @param {number=} s 0 ~ 1, ignore when null.
  13713. * @param {number=} l 0 ~ 1, ignore when null.
  13714. * @return {string} Color string in rgba format.
  13715. * @memberOf module:zrender/util/color
  13716. */
  13717. function modifyHSL(color, h, s, l) {
  13718. color = parse(color);
  13719. if (color) {
  13720. color = rgba2hsla(color);
  13721. h != null && (color[0] = clampCssAngle(h));
  13722. s != null && (color[1] = parseCssFloat(s));
  13723. l != null && (color[2] = parseCssFloat(l));
  13724. return stringify(hsla2rgba(color), 'rgba');
  13725. }
  13726. }
  13727. /**
  13728. * @param {string} color
  13729. * @param {number=} alpha 0 ~ 1
  13730. * @return {string} Color string in rgba format.
  13731. * @memberOf module:zrender/util/color
  13732. */
  13733. function modifyAlpha(color, alpha) {
  13734. color = parse(color);
  13735. if (color && alpha != null) {
  13736. color[3] = clampCssFloat(alpha);
  13737. return stringify(color, 'rgba');
  13738. }
  13739. }
  13740. /**
  13741. * @param {Array.<number>} arrColor like [12,33,44,0.4]
  13742. * @param {string} type 'rgba', 'hsva', ...
  13743. * @return {string} Result color. (If input illegal, return undefined).
  13744. */
  13745. function stringify(arrColor, type) {
  13746. if (!arrColor || !arrColor.length) {
  13747. return;
  13748. }
  13749. var colorStr = arrColor[0] + ',' + arrColor[1] + ',' + arrColor[2];
  13750. if (type === 'rgba' || type === 'hsva' || type === 'hsla') {
  13751. colorStr += ',' + arrColor[3];
  13752. }
  13753. return type + '(' + colorStr + ')';
  13754. }
  13755. exports.parse = parse;
  13756. exports.lift = lift;
  13757. exports.toHex = toHex;
  13758. exports.fastLerp = fastLerp;
  13759. exports.fastMapToColor = fastMapToColor;
  13760. exports.lerp = lerp;
  13761. exports.mapToColor = mapToColor;
  13762. exports.modifyHSL = modifyHSL;
  13763. exports.modifyAlpha = modifyAlpha;
  13764. exports.stringify = stringify;
  13765. /***/ }),
  13766. /***/ "./node_modules/zrender/lib/tool/path.js":
  13767. /*!***********************************************!*\
  13768. !*** ./node_modules/zrender/lib/tool/path.js ***!
  13769. \***********************************************/
  13770. /*! no static exports found */
  13771. /***/ (function(module, exports, __webpack_require__) {
  13772. var Path = __webpack_require__(/*! ../graphic/Path */ "./node_modules/zrender/lib/graphic/Path.js");
  13773. var PathProxy = __webpack_require__(/*! ../core/PathProxy */ "./node_modules/zrender/lib/core/PathProxy.js");
  13774. var transformPath = __webpack_require__(/*! ./transformPath */ "./node_modules/zrender/lib/tool/transformPath.js");
  13775. // command chars
  13776. // var cc = [
  13777. // 'm', 'M', 'l', 'L', 'v', 'V', 'h', 'H', 'z', 'Z',
  13778. // 'c', 'C', 'q', 'Q', 't', 'T', 's', 'S', 'a', 'A'
  13779. // ];
  13780. var mathSqrt = Math.sqrt;
  13781. var mathSin = Math.sin;
  13782. var mathCos = Math.cos;
  13783. var PI = Math.PI;
  13784. var vMag = function (v) {
  13785. return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
  13786. };
  13787. var vRatio = function (u, v) {
  13788. return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
  13789. };
  13790. var vAngle = function (u, v) {
  13791. return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
  13792. };
  13793. function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
  13794. var psi = psiDeg * (PI / 180.0);
  13795. var xp = mathCos(psi) * (x1 - x2) / 2.0 + mathSin(psi) * (y1 - y2) / 2.0;
  13796. var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0 + mathCos(psi) * (y1 - y2) / 2.0;
  13797. var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
  13798. if (lambda > 1) {
  13799. rx *= mathSqrt(lambda);
  13800. ry *= mathSqrt(lambda);
  13801. }
  13802. var f = (fa === fs ? -1 : 1) * mathSqrt((rx * rx * (ry * ry) - rx * rx * (yp * yp) - ry * ry * (xp * xp)) / (rx * rx * (yp * yp) + ry * ry * (xp * xp))) || 0;
  13803. var cxp = f * rx * yp / ry;
  13804. var cyp = f * -ry * xp / rx;
  13805. var cx = (x1 + x2) / 2.0 + mathCos(psi) * cxp - mathSin(psi) * cyp;
  13806. var cy = (y1 + y2) / 2.0 + mathSin(psi) * cxp + mathCos(psi) * cyp;
  13807. var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
  13808. var u = [(xp - cxp) / rx, (yp - cyp) / ry];
  13809. var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
  13810. var dTheta = vAngle(u, v);
  13811. if (vRatio(u, v) <= -1) {
  13812. dTheta = PI;
  13813. }
  13814. if (vRatio(u, v) >= 1) {
  13815. dTheta = 0;
  13816. }
  13817. if (fs === 0 && dTheta > 0) {
  13818. dTheta = dTheta - 2 * PI;
  13819. }
  13820. if (fs === 1 && dTheta < 0) {
  13821. dTheta = dTheta + 2 * PI;
  13822. }
  13823. path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
  13824. }
  13825. var commandReg = /([mlvhzcqtsa])([^mlvhzcqtsa]*)/ig; // Consider case:
  13826. // (1) delimiter can be comma or space, where continuous commas
  13827. // or spaces should be seen as one comma.
  13828. // (2) value can be like:
  13829. // '2e-4', 'l.5.9' (ignore 0), 'M-10-10', 'l-2.43e-1,34.9983',
  13830. // 'l-.5E1,54', '121-23-44-11' (no delimiter)
  13831. var numberReg = /-?([0-9]*\.)?[0-9]+([eE]-?[0-9]+)?/g; // var valueSplitReg = /[\s,]+/;
  13832. function createPathProxyFromString(data) {
  13833. if (!data) {
  13834. return new PathProxy();
  13835. } // var data = data.replace(/-/g, ' -')
  13836. // .replace(/ /g, ' ')
  13837. // .replace(/ /g, ',')
  13838. // .replace(/,,/g, ',');
  13839. // var n;
  13840. // create pipes so that we can split the data
  13841. // for (n = 0; n < cc.length; n++) {
  13842. // cs = cs.replace(new RegExp(cc[n], 'g'), '|' + cc[n]);
  13843. // }
  13844. // data = data.replace(/-/g, ',-');
  13845. // create array
  13846. // var arr = cs.split('|');
  13847. // init context point
  13848. var cpx = 0;
  13849. var cpy = 0;
  13850. var subpathX = cpx;
  13851. var subpathY = cpy;
  13852. var prevCmd;
  13853. var path = new PathProxy();
  13854. var CMD = PathProxy.CMD; // commandReg.lastIndex = 0;
  13855. // var cmdResult;
  13856. // while ((cmdResult = commandReg.exec(data)) != null) {
  13857. // var cmdStr = cmdResult[1];
  13858. // var cmdContent = cmdResult[2];
  13859. var cmdList = data.match(commandReg);
  13860. for (var l = 0; l < cmdList.length; l++) {
  13861. var cmdText = cmdList[l];
  13862. var cmdStr = cmdText.charAt(0);
  13863. var cmd; // String#split is faster a little bit than String#replace or RegExp#exec.
  13864. // var p = cmdContent.split(valueSplitReg);
  13865. // var pLen = 0;
  13866. // for (var i = 0; i < p.length; i++) {
  13867. // // '' and other invalid str => NaN
  13868. // var val = parseFloat(p[i]);
  13869. // !isNaN(val) && (p[pLen++] = val);
  13870. // }
  13871. var p = cmdText.match(numberReg) || [];
  13872. var pLen = p.length;
  13873. for (var i = 0; i < pLen; i++) {
  13874. p[i] = parseFloat(p[i]);
  13875. }
  13876. var off = 0;
  13877. while (off < pLen) {
  13878. var ctlPtx;
  13879. var ctlPty;
  13880. var rx;
  13881. var ry;
  13882. var psi;
  13883. var fa;
  13884. var fs;
  13885. var x1 = cpx;
  13886. var y1 = cpy; // convert l, H, h, V, and v to L
  13887. switch (cmdStr) {
  13888. case 'l':
  13889. cpx += p[off++];
  13890. cpy += p[off++];
  13891. cmd = CMD.L;
  13892. path.addData(cmd, cpx, cpy);
  13893. break;
  13894. case 'L':
  13895. cpx = p[off++];
  13896. cpy = p[off++];
  13897. cmd = CMD.L;
  13898. path.addData(cmd, cpx, cpy);
  13899. break;
  13900. case 'm':
  13901. cpx += p[off++];
  13902. cpy += p[off++];
  13903. cmd = CMD.M;
  13904. path.addData(cmd, cpx, cpy);
  13905. subpathX = cpx;
  13906. subpathY = cpy;
  13907. cmdStr = 'l';
  13908. break;
  13909. case 'M':
  13910. cpx = p[off++];
  13911. cpy = p[off++];
  13912. cmd = CMD.M;
  13913. path.addData(cmd, cpx, cpy);
  13914. subpathX = cpx;
  13915. subpathY = cpy;
  13916. cmdStr = 'L';
  13917. break;
  13918. case 'h':
  13919. cpx += p[off++];
  13920. cmd = CMD.L;
  13921. path.addData(cmd, cpx, cpy);
  13922. break;
  13923. case 'H':
  13924. cpx = p[off++];
  13925. cmd = CMD.L;
  13926. path.addData(cmd, cpx, cpy);
  13927. break;
  13928. case 'v':
  13929. cpy += p[off++];
  13930. cmd = CMD.L;
  13931. path.addData(cmd, cpx, cpy);
  13932. break;
  13933. case 'V':
  13934. cpy = p[off++];
  13935. cmd = CMD.L;
  13936. path.addData(cmd, cpx, cpy);
  13937. break;
  13938. case 'C':
  13939. cmd = CMD.C;
  13940. path.addData(cmd, p[off++], p[off++], p[off++], p[off++], p[off++], p[off++]);
  13941. cpx = p[off - 2];
  13942. cpy = p[off - 1];
  13943. break;
  13944. case 'c':
  13945. cmd = CMD.C;
  13946. path.addData(cmd, p[off++] + cpx, p[off++] + cpy, p[off++] + cpx, p[off++] + cpy, p[off++] + cpx, p[off++] + cpy);
  13947. cpx += p[off - 2];
  13948. cpy += p[off - 1];
  13949. break;
  13950. case 'S':
  13951. ctlPtx = cpx;
  13952. ctlPty = cpy;
  13953. var len = path.len();
  13954. var pathData = path.data;
  13955. if (prevCmd === CMD.C) {
  13956. ctlPtx += cpx - pathData[len - 4];
  13957. ctlPty += cpy - pathData[len - 3];
  13958. }
  13959. cmd = CMD.C;
  13960. x1 = p[off++];
  13961. y1 = p[off++];
  13962. cpx = p[off++];
  13963. cpy = p[off++];
  13964. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  13965. break;
  13966. case 's':
  13967. ctlPtx = cpx;
  13968. ctlPty = cpy;
  13969. var len = path.len();
  13970. var pathData = path.data;
  13971. if (prevCmd === CMD.C) {
  13972. ctlPtx += cpx - pathData[len - 4];
  13973. ctlPty += cpy - pathData[len - 3];
  13974. }
  13975. cmd = CMD.C;
  13976. x1 = cpx + p[off++];
  13977. y1 = cpy + p[off++];
  13978. cpx += p[off++];
  13979. cpy += p[off++];
  13980. path.addData(cmd, ctlPtx, ctlPty, x1, y1, cpx, cpy);
  13981. break;
  13982. case 'Q':
  13983. x1 = p[off++];
  13984. y1 = p[off++];
  13985. cpx = p[off++];
  13986. cpy = p[off++];
  13987. cmd = CMD.Q;
  13988. path.addData(cmd, x1, y1, cpx, cpy);
  13989. break;
  13990. case 'q':
  13991. x1 = p[off++] + cpx;
  13992. y1 = p[off++] + cpy;
  13993. cpx += p[off++];
  13994. cpy += p[off++];
  13995. cmd = CMD.Q;
  13996. path.addData(cmd, x1, y1, cpx, cpy);
  13997. break;
  13998. case 'T':
  13999. ctlPtx = cpx;
  14000. ctlPty = cpy;
  14001. var len = path.len();
  14002. var pathData = path.data;
  14003. if (prevCmd === CMD.Q) {
  14004. ctlPtx += cpx - pathData[len - 4];
  14005. ctlPty += cpy - pathData[len - 3];
  14006. }
  14007. cpx = p[off++];
  14008. cpy = p[off++];
  14009. cmd = CMD.Q;
  14010. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  14011. break;
  14012. case 't':
  14013. ctlPtx = cpx;
  14014. ctlPty = cpy;
  14015. var len = path.len();
  14016. var pathData = path.data;
  14017. if (prevCmd === CMD.Q) {
  14018. ctlPtx += cpx - pathData[len - 4];
  14019. ctlPty += cpy - pathData[len - 3];
  14020. }
  14021. cpx += p[off++];
  14022. cpy += p[off++];
  14023. cmd = CMD.Q;
  14024. path.addData(cmd, ctlPtx, ctlPty, cpx, cpy);
  14025. break;
  14026. case 'A':
  14027. rx = p[off++];
  14028. ry = p[off++];
  14029. psi = p[off++];
  14030. fa = p[off++];
  14031. fs = p[off++];
  14032. x1 = cpx, y1 = cpy;
  14033. cpx = p[off++];
  14034. cpy = p[off++];
  14035. cmd = CMD.A;
  14036. processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path);
  14037. break;
  14038. case 'a':
  14039. rx = p[off++];
  14040. ry = p[off++];
  14041. psi = p[off++];
  14042. fa = p[off++];
  14043. fs = p[off++];
  14044. x1 = cpx, y1 = cpy;
  14045. cpx += p[off++];
  14046. cpy += p[off++];
  14047. cmd = CMD.A;
  14048. processArc(x1, y1, cpx, cpy, fa, fs, rx, ry, psi, cmd, path);
  14049. break;
  14050. }
  14051. }
  14052. if (cmdStr === 'z' || cmdStr === 'Z') {
  14053. cmd = CMD.Z;
  14054. path.addData(cmd); // z may be in the middle of the path.
  14055. cpx = subpathX;
  14056. cpy = subpathY;
  14057. }
  14058. prevCmd = cmd;
  14059. }
  14060. path.toStatic();
  14061. return path;
  14062. } // TODO Optimize double memory cost problem
  14063. function createPathOptions(str, opts) {
  14064. var pathProxy = createPathProxyFromString(str);
  14065. opts = opts || {};
  14066. opts.buildPath = function (path) {
  14067. if (path.setData) {
  14068. path.setData(pathProxy.data); // Svg and vml renderer don't have context
  14069. var ctx = path.getContext();
  14070. if (ctx) {
  14071. path.rebuildPath(ctx);
  14072. }
  14073. } else {
  14074. var ctx = path;
  14075. pathProxy.rebuildPath(ctx);
  14076. }
  14077. };
  14078. opts.applyTransform = function (m) {
  14079. transformPath(pathProxy, m);
  14080. this.dirty(true);
  14081. };
  14082. return opts;
  14083. }
  14084. /**
  14085. * Create a Path object from path string data
  14086. * http://www.w3.org/TR/SVG/paths.html#PathData
  14087. * @param {Object} opts Other options
  14088. */
  14089. function createFromString(str, opts) {
  14090. return new Path(createPathOptions(str, opts));
  14091. }
  14092. /**
  14093. * Create a Path class from path string data
  14094. * @param {string} str
  14095. * @param {Object} opts Other options
  14096. */
  14097. function extendFromString(str, opts) {
  14098. return Path.extend(createPathOptions(str, opts));
  14099. }
  14100. /**
  14101. * Merge multiple paths
  14102. */
  14103. // TODO Apply transform
  14104. // TODO stroke dash
  14105. // TODO Optimize double memory cost problem
  14106. function mergePath(pathEls, opts) {
  14107. var pathList = [];
  14108. var len = pathEls.length;
  14109. for (var i = 0; i < len; i++) {
  14110. var pathEl = pathEls[i];
  14111. if (!pathEl.path) {
  14112. pathEl.createPathProxy();
  14113. }
  14114. if (pathEl.__dirtyPath) {
  14115. pathEl.buildPath(pathEl.path, pathEl.shape, true);
  14116. }
  14117. pathList.push(pathEl.path);
  14118. }
  14119. var pathBundle = new Path(opts); // Need path proxy.
  14120. pathBundle.createPathProxy();
  14121. pathBundle.buildPath = function (path) {
  14122. path.appendPath(pathList); // Svg and vml renderer don't have context
  14123. var ctx = path.getContext();
  14124. if (ctx) {
  14125. path.rebuildPath(ctx);
  14126. }
  14127. };
  14128. return pathBundle;
  14129. }
  14130. exports.createFromString = createFromString;
  14131. exports.extendFromString = extendFromString;
  14132. exports.mergePath = mergePath;
  14133. /***/ }),
  14134. /***/ "./node_modules/zrender/lib/tool/transformPath.js":
  14135. /*!********************************************************!*\
  14136. !*** ./node_modules/zrender/lib/tool/transformPath.js ***!
  14137. \********************************************************/
  14138. /*! no static exports found */
  14139. /***/ (function(module, exports, __webpack_require__) {
  14140. var PathProxy = __webpack_require__(/*! ../core/PathProxy */ "./node_modules/zrender/lib/core/PathProxy.js");
  14141. var _vector = __webpack_require__(/*! ../core/vector */ "./node_modules/zrender/lib/core/vector.js");
  14142. var v2ApplyTransform = _vector.applyTransform;
  14143. var CMD = PathProxy.CMD;
  14144. var points = [[], [], []];
  14145. var mathSqrt = Math.sqrt;
  14146. var mathAtan2 = Math.atan2;
  14147. function _default(path, m) {
  14148. var data = path.data;
  14149. var cmd;
  14150. var nPoint;
  14151. var i;
  14152. var j;
  14153. var k;
  14154. var p;
  14155. var M = CMD.M;
  14156. var C = CMD.C;
  14157. var L = CMD.L;
  14158. var R = CMD.R;
  14159. var A = CMD.A;
  14160. var Q = CMD.Q;
  14161. for (i = 0, j = 0; i < data.length;) {
  14162. cmd = data[i++];
  14163. j = i;
  14164. nPoint = 0;
  14165. switch (cmd) {
  14166. case M:
  14167. nPoint = 1;
  14168. break;
  14169. case L:
  14170. nPoint = 1;
  14171. break;
  14172. case C:
  14173. nPoint = 3;
  14174. break;
  14175. case Q:
  14176. nPoint = 2;
  14177. break;
  14178. case A:
  14179. var x = m[4];
  14180. var y = m[5];
  14181. var sx = mathSqrt(m[0] * m[0] + m[1] * m[1]);
  14182. var sy = mathSqrt(m[2] * m[2] + m[3] * m[3]);
  14183. var angle = mathAtan2(-m[1] / sy, m[0] / sx); // cx
  14184. data[i] *= sx;
  14185. data[i++] += x; // cy
  14186. data[i] *= sy;
  14187. data[i++] += y; // Scale rx and ry
  14188. // FIXME Assume psi is 0 here
  14189. data[i++] *= sx;
  14190. data[i++] *= sy; // Start angle
  14191. data[i++] += angle; // end angle
  14192. data[i++] += angle; // FIXME psi
  14193. i += 2;
  14194. j = i;
  14195. break;
  14196. case R:
  14197. // x0, y0
  14198. p[0] = data[i++];
  14199. p[1] = data[i++];
  14200. v2ApplyTransform(p, p, m);
  14201. data[j++] = p[0];
  14202. data[j++] = p[1]; // x1, y1
  14203. p[0] += data[i++];
  14204. p[1] += data[i++];
  14205. v2ApplyTransform(p, p, m);
  14206. data[j++] = p[0];
  14207. data[j++] = p[1];
  14208. }
  14209. for (k = 0; k < nPoint; k++) {
  14210. var p = points[k];
  14211. p[0] = data[i++];
  14212. p[1] = data[i++];
  14213. v2ApplyTransform(p, p, m); // Write back
  14214. data[j++] = p[0];
  14215. data[j++] = p[1];
  14216. }
  14217. }
  14218. }
  14219. module.exports = _default;
  14220. /***/ }),
  14221. /***/ "./src/liquidFill.js":
  14222. /*!***************************!*\
  14223. !*** ./src/liquidFill.js ***!
  14224. \***************************/
  14225. /*! no static exports found */
  14226. /***/ (function(module, exports, __webpack_require__) {
  14227. var echarts = __webpack_require__(/*! echarts/lib/echarts */ "echarts/lib/echarts");
  14228. __webpack_require__(/*! ./liquidFillSeries */ "./src/liquidFillSeries.js");
  14229. __webpack_require__(/*! ./liquidFillView */ "./src/liquidFillView.js");
  14230. echarts.registerVisual(
  14231. echarts.util.curry(
  14232. __webpack_require__(/*! echarts/lib/visual/dataColor */ "./node_modules/echarts/lib/visual/dataColor.js"), 'liquidFill'
  14233. )
  14234. );
  14235. /***/ }),
  14236. /***/ "./src/liquidFillLayout.js":
  14237. /*!*********************************!*\
  14238. !*** ./src/liquidFillLayout.js ***!
  14239. \*********************************/
  14240. /*! no static exports found */
  14241. /***/ (function(module, exports, __webpack_require__) {
  14242. var echarts = __webpack_require__(/*! echarts/lib/echarts */ "echarts/lib/echarts");
  14243. module.exports = echarts.graphic.extendShape({
  14244. type: 'ec-liquid-fill',
  14245. shape: {
  14246. waveLength: 0,
  14247. radius: 0,
  14248. radiusY: 0,
  14249. cx: 0,
  14250. cy: 0,
  14251. waterLevel: 0,
  14252. amplitude: 0,
  14253. phase: 0,
  14254. inverse: false
  14255. },
  14256. buildPath: function (ctx, shape) {
  14257. if (shape.radiusY == null) {
  14258. shape.radiusY = shape.radius;
  14259. }
  14260. /**
  14261. * We define a sine wave having 4 waves, and make sure at least 8 curves
  14262. * is drawn. Otherwise, it may cause blank area for some waves when
  14263. * wave length is large enough.
  14264. */
  14265. var curves = Math.max(
  14266. Math.ceil(2 * shape.radius / shape.waveLength * 4) * 2,
  14267. 8
  14268. );
  14269. // map phase to [-Math.PI * 2, 0]
  14270. while (shape.phase < -Math.PI * 2) {
  14271. shape.phase += Math.PI * 2;
  14272. }
  14273. while (shape.phase > 0) {
  14274. shape.phase -= Math.PI * 2;
  14275. }
  14276. var phase = shape.phase / Math.PI / 2 * shape.waveLength;
  14277. var left = shape.cx - shape.radius + phase - shape.radius * 2;
  14278. /**
  14279. * top-left corner as start point
  14280. *
  14281. * draws this point
  14282. * |
  14283. * \|/
  14284. * ~~~~~~~~
  14285. * | |
  14286. * +------+
  14287. */
  14288. ctx.moveTo(left, shape.waterLevel);
  14289. /**
  14290. * top wave
  14291. *
  14292. * ~~~~~~~~ <- draws this sine wave
  14293. * | |
  14294. * +------+
  14295. */
  14296. var waveRight = 0;
  14297. for (var c = 0; c < curves; ++c) {
  14298. var stage = c % 4;
  14299. var pos = getWaterPositions(c * shape.waveLength / 4, stage,
  14300. shape.waveLength, shape.amplitude);
  14301. ctx.bezierCurveTo(pos[0][0] + left, -pos[0][1] + shape.waterLevel,
  14302. pos[1][0] + left, -pos[1][1] + shape.waterLevel,
  14303. pos[2][0] + left, -pos[2][1] + shape.waterLevel);
  14304. if (c === curves - 1) {
  14305. waveRight = pos[2][0];
  14306. }
  14307. }
  14308. if (shape.inverse) {
  14309. /**
  14310. * top-right corner
  14311. * 2. draws this line
  14312. * |
  14313. * +------+
  14314. * 3. draws this line -> | | <- 1. draws this line
  14315. * ~~~~~~~~
  14316. */
  14317. ctx.lineTo(waveRight + left, shape.cy - shape.radiusY);
  14318. ctx.lineTo(left, shape.cy - shape.radiusY);
  14319. ctx.lineTo(left, shape.waterLevel);
  14320. }
  14321. else {
  14322. /**
  14323. * top-right corner
  14324. *
  14325. * ~~~~~~~~
  14326. * 3. draws this line -> | | <- 1. draws this line
  14327. * +------+
  14328. * ^
  14329. * |
  14330. * 2. draws this line
  14331. */
  14332. ctx.lineTo(waveRight + left, shape.cy + shape.radiusY);
  14333. ctx.lineTo(left, shape.cy + shape.radiusY);
  14334. ctx.lineTo(left, shape.waterLevel);
  14335. }
  14336. ctx.closePath();
  14337. }
  14338. });
  14339. /**
  14340. * Using Bezier curves to fit sine wave.
  14341. * There is 4 control points for each curve of wave,
  14342. * which is at 1/4 wave length of the sine wave.
  14343. *
  14344. * The control points for a wave from (a) to (d) are a-b-c-d:
  14345. * c *----* d
  14346. * b *
  14347. * |
  14348. * ... a * ..................
  14349. *
  14350. * whose positions are a: (0, 0), b: (0.5, 0.5), c: (1, 1), d: (PI / 2, 1)
  14351. *
  14352. * @param {number} x x position of the left-most point (a)
  14353. * @param {number} stage 0-3, stating which part of the wave it is
  14354. * @param {number} waveLength wave length of the sine wave
  14355. * @param {number} amplitude wave amplitude
  14356. */
  14357. function getWaterPositions(x, stage, waveLength, amplitude) {
  14358. if (stage === 0) {
  14359. return [
  14360. [x + 1 / 2 * waveLength / Math.PI / 2, amplitude / 2],
  14361. [x + 1 / 2 * waveLength / Math.PI, amplitude],
  14362. [x + waveLength / 4, amplitude]
  14363. ];
  14364. }
  14365. else if (stage === 1) {
  14366. return [
  14367. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2),
  14368. amplitude],
  14369. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1),
  14370. amplitude / 2],
  14371. [x + waveLength / 4, 0]
  14372. ]
  14373. }
  14374. else if (stage === 2) {
  14375. return [
  14376. [x + 1 / 2 * waveLength / Math.PI / 2, -amplitude / 2],
  14377. [x + 1 / 2 * waveLength / Math.PI, -amplitude],
  14378. [x + waveLength / 4, -amplitude]
  14379. ]
  14380. }
  14381. else {
  14382. return [
  14383. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 2),
  14384. -amplitude],
  14385. [x + 1 / 2 * waveLength / Math.PI / 2 * (Math.PI - 1),
  14386. -amplitude / 2],
  14387. [x + waveLength / 4, 0]
  14388. ]
  14389. }
  14390. }
  14391. /***/ }),
  14392. /***/ "./src/liquidFillSeries.js":
  14393. /*!*********************************!*\
  14394. !*** ./src/liquidFillSeries.js ***!
  14395. \*********************************/
  14396. /*! no static exports found */
  14397. /***/ (function(module, exports, __webpack_require__) {
  14398. var completeDimensions = __webpack_require__(/*! echarts/lib/data/helper/completeDimensions */ "./node_modules/echarts/lib/data/helper/completeDimensions.js");
  14399. var echarts = __webpack_require__(/*! echarts/lib/echarts */ "echarts/lib/echarts");
  14400. echarts.extendSeriesModel({
  14401. type: 'series.liquidFill',
  14402. visualColorAccessPath: 'textStyle.normal.color',
  14403. optionUpdated: function () {
  14404. var option = this.option;
  14405. option.gridSize = Math.max(Math.floor(option.gridSize), 4);
  14406. },
  14407. getInitialData: function (option, ecModel) {
  14408. var dimensions = completeDimensions(['value'], option.data);
  14409. var list = new echarts.List(dimensions, this);
  14410. list.initData(option.data);
  14411. return list;
  14412. },
  14413. defaultOption: {
  14414. color: ['#294D99', '#156ACF', '#1598ED', '#45BDFF'],
  14415. center: ['50%', '50%'],
  14416. radius: '50%',
  14417. amplitude: '8%',
  14418. waveLength: '80%',
  14419. phase: 'auto',
  14420. period: 'auto',
  14421. direction: 'right',
  14422. shape: 'circle',
  14423. waveAnimation: true,
  14424. animationEasing: 'linear',
  14425. animationEasingUpdate: 'linear',
  14426. animationDuration: 2000,
  14427. animationDurationUpdate: 1000,
  14428. outline: {
  14429. show: true,
  14430. borderDistance: 8,
  14431. itemStyle: {
  14432. color: 'none',
  14433. borderColor: '#294D99',
  14434. borderWidth: 8,
  14435. shadowBlur: 20,
  14436. shadowColor: 'rgba(0, 0, 0, 0.25)'
  14437. }
  14438. },
  14439. backgroundStyle: {
  14440. color: '#E3F7FF'
  14441. },
  14442. itemStyle: {
  14443. opacity: 0.95,
  14444. shadowBlur: 50,
  14445. shadowColor: 'rgba(0, 0, 0, 0.4)'
  14446. },
  14447. label: {
  14448. show: true,
  14449. color: '#294D99',
  14450. insideColor: '#fff',
  14451. fontSize: 50,
  14452. fontWeight: 'bold',
  14453. align: 'center',
  14454. baseline: 'middle',
  14455. position: 'inside'
  14456. },
  14457. emphasis: {
  14458. itemStyle: {
  14459. opacity: 0.8
  14460. }
  14461. }
  14462. }
  14463. });
  14464. /***/ }),
  14465. /***/ "./src/liquidFillView.js":
  14466. /*!*******************************!*\
  14467. !*** ./src/liquidFillView.js ***!
  14468. \*******************************/
  14469. /*! no static exports found */
  14470. /***/ (function(module, exports, __webpack_require__) {
  14471. var echarts = __webpack_require__(/*! echarts/lib/echarts */ "echarts/lib/echarts");
  14472. var numberUtil = echarts.number;
  14473. var symbolUtil = __webpack_require__(/*! echarts/lib/util/symbol */ "./node_modules/echarts/lib/util/symbol.js");
  14474. var parsePercent = numberUtil.parsePercent;
  14475. var LiquidLayout = __webpack_require__(/*! ./liquidFillLayout */ "./src/liquidFillLayout.js");
  14476. function getShallow(model, path) {
  14477. return model && model.getShallow(path);
  14478. }
  14479. echarts.extendChartView({
  14480. type: 'liquidFill',
  14481. render: function (seriesModel, ecModel, api) {
  14482. var group = this.group;
  14483. group.removeAll();
  14484. var data = seriesModel.getData();
  14485. var itemModel = data.getItemModel(0);
  14486. var center = itemModel.get('center');
  14487. var radius = itemModel.get('radius');
  14488. var width = api.getWidth();
  14489. var height = api.getHeight();
  14490. var size = Math.min(width, height);
  14491. // itemStyle
  14492. var outlineDistance = 0;
  14493. var outlineBorderWidth = 0;
  14494. var showOutline = seriesModel.get('outline.show');
  14495. if (showOutline) {
  14496. outlineDistance = seriesModel.get('outline.borderDistance');
  14497. outlineBorderWidth = parsePercent(
  14498. seriesModel.get('outline.itemStyle.borderWidth'), size
  14499. );
  14500. }
  14501. var cx = parsePercent(center[0], width);
  14502. var cy = parsePercent(center[1], height);
  14503. var outterRadius;
  14504. var innerRadius;
  14505. var paddingRadius;
  14506. var isFillContainer = false;
  14507. var symbol = seriesModel.get('shape');
  14508. if (symbol === 'container') {
  14509. // a shape that fully fills the container
  14510. isFillContainer = true;
  14511. outterRadius = [
  14512. width / 2,
  14513. height / 2
  14514. ];
  14515. innerRadius = [
  14516. outterRadius[0] - outlineBorderWidth / 2,
  14517. outterRadius[1] - outlineBorderWidth / 2
  14518. ];
  14519. paddingRadius = [
  14520. parsePercent(outlineDistance, width),
  14521. parsePercent(outlineDistance, height)
  14522. ];
  14523. radius = [
  14524. Math.max(innerRadius[0] - paddingRadius[0], 0),
  14525. Math.max(innerRadius[1] - paddingRadius[1], 0)
  14526. ];
  14527. }
  14528. else {
  14529. outterRadius = parsePercent(radius, size) / 2;
  14530. innerRadius = outterRadius - outlineBorderWidth / 2;
  14531. paddingRadius = parsePercent(outlineDistance, size);
  14532. radius = Math.max(innerRadius - paddingRadius, 0);
  14533. }
  14534. if (showOutline) {
  14535. var outline = getOutline();
  14536. outline.style.lineWidth = outlineBorderWidth;
  14537. group.add(getOutline());
  14538. }
  14539. var left = isFillContainer ? 0 : cx - radius;
  14540. var top = isFillContainer ? 0 : cy - radius;
  14541. var wavePath = null;
  14542. group.add(getBackground());
  14543. // each data item for a wave
  14544. var oldData = this._data;
  14545. var waves = [];
  14546. data.diff(oldData)
  14547. .add(function (idx) {
  14548. var wave = getWave(idx, false);
  14549. var waterLevel = wave.shape.waterLevel;
  14550. wave.shape.waterLevel = isFillContainer ? height / 2 : radius;
  14551. echarts.graphic.initProps(wave, {
  14552. shape: {
  14553. waterLevel: waterLevel
  14554. }
  14555. }, seriesModel);
  14556. wave.z2 = 2;
  14557. setWaveAnimation(idx, wave, null);
  14558. group.add(wave);
  14559. data.setItemGraphicEl(idx, wave);
  14560. waves.push(wave);
  14561. })
  14562. .update(function (newIdx, oldIdx) {
  14563. var waveElement = oldData.getItemGraphicEl(oldIdx);
  14564. // new wave is used to calculate position, but not added
  14565. var newWave = getWave(newIdx, false, waveElement);
  14566. // changes with animation
  14567. var shape = {};
  14568. var shapeAttrs = ['amplitude', 'cx', 'cy', 'phase', 'radius', 'radiusY', 'waterLevel', 'waveLength'];
  14569. for (var i = 0; i < shapeAttrs.length; ++i) {
  14570. var attr = shapeAttrs[i];
  14571. if (newWave.shape.hasOwnProperty(attr)) {
  14572. shape[attr] = newWave.shape[attr];
  14573. }
  14574. }
  14575. var style = {};
  14576. var styleAttrs = ['fill', 'opacity', 'shadowBlur', 'shadowColor'];
  14577. for (var i = 0; i < styleAttrs.length; ++i) {
  14578. var attr = styleAttrs[i];
  14579. if (newWave.style.hasOwnProperty(attr)) {
  14580. style[attr] = newWave.style[attr];
  14581. }
  14582. }
  14583. if (isFillContainer) {
  14584. shape.radiusY = height / 2;
  14585. }
  14586. // changes with animation
  14587. echarts.graphic.updateProps(waveElement, {
  14588. shape: shape
  14589. }, seriesModel);
  14590. waveElement.useStyle(style);
  14591. // instant changes
  14592. waveElement.position = newWave.position;
  14593. waveElement.setClipPath(newWave.clipPath);
  14594. waveElement.shape.inverse = newWave.inverse;
  14595. setWaveAnimation(newIdx, waveElement, waveElement);
  14596. group.add(waveElement);
  14597. data.setItemGraphicEl(newIdx, waveElement);
  14598. waves.push(waveElement);
  14599. })
  14600. .remove(function (idx) {
  14601. var wave = oldData.getItemGraphicEl(idx);
  14602. group.remove(wave);
  14603. })
  14604. .execute();
  14605. if (itemModel.get('label.show')) {
  14606. group.add(getText(waves));
  14607. }
  14608. this._data = data;
  14609. /**
  14610. * Get path for outline, background and clipping
  14611. *
  14612. * @param {number} r outter radius of shape
  14613. * @param {boolean|undefined} isForClipping if the shape is used
  14614. * for clipping
  14615. */
  14616. function getPath(r, isForClipping) {
  14617. if (symbol) {
  14618. // customed symbol path
  14619. if (symbol.indexOf('path://') === 0) {
  14620. var path = echarts.graphic.makePath(symbol.slice(7), {});
  14621. var bouding = path.getBoundingRect();
  14622. var w = bouding.width;
  14623. var h = bouding.height;
  14624. if (w > h) {
  14625. h = r * 2 / w * h;
  14626. w = r * 2;
  14627. }
  14628. else {
  14629. w = r * 2 / h * w;
  14630. h = r * 2;
  14631. }
  14632. var left = isForClipping ? 0 : cx - w / 2;
  14633. var top = isForClipping ? 0 : cy - h / 2;
  14634. path = echarts.graphic.makePath(
  14635. symbol.slice(7),
  14636. {},
  14637. new echarts.graphic.BoundingRect(left, top, w, h)
  14638. );
  14639. if (isForClipping) {
  14640. path.position = [-w / 2, -h / 2];
  14641. }
  14642. return path;
  14643. }
  14644. else if (isFillContainer) {
  14645. // fully fill the container
  14646. var x = isForClipping ? -r[0] : cx - r[0];
  14647. var y = isForClipping ? -r[1] : cy - r[1];
  14648. return symbolUtil.createSymbol(
  14649. 'rect', x, y, r[0] * 2, r[1] * 2
  14650. );
  14651. }
  14652. else {
  14653. var x = isForClipping ? -r : cx - r;
  14654. var y = isForClipping ? -r : cy - r;
  14655. if (symbol === 'pin') {
  14656. y += r;
  14657. }
  14658. else if (symbol === 'arrow') {
  14659. y -= r;
  14660. }
  14661. return symbolUtil.createSymbol(symbol, x, y, r * 2, r * 2);
  14662. }
  14663. }
  14664. return new echarts.graphic.Circle({
  14665. shape: {
  14666. cx: isForClipping ? 0 : cx,
  14667. cy: isForClipping ? 0 : cy,
  14668. r: r
  14669. }
  14670. });
  14671. }
  14672. /**
  14673. * Create outline
  14674. */
  14675. function getOutline() {
  14676. var outlinePath = getPath(outterRadius);
  14677. outlinePath.style.fill = null;
  14678. outlinePath.setStyle(seriesModel.getModel('outline.itemStyle')
  14679. .getItemStyle());
  14680. return outlinePath;
  14681. }
  14682. /**
  14683. * Create background
  14684. */
  14685. function getBackground() {
  14686. // Seperate stroke and fill, so we can use stroke to cover the alias of clipping.
  14687. var strokePath = getPath(radius);
  14688. strokePath.setStyle(seriesModel.getModel('backgroundStyle')
  14689. .getItemStyle());
  14690. strokePath.style.fill = null;
  14691. // Stroke is front of wave
  14692. strokePath.z2 = 5;
  14693. var fillPath = getPath(radius);
  14694. fillPath.setStyle(seriesModel.getModel('backgroundStyle')
  14695. .getItemStyle());
  14696. fillPath.style.stroke = null;
  14697. var group = new echarts.graphic.Group();
  14698. group.add(strokePath);
  14699. group.add(fillPath);
  14700. return group;
  14701. }
  14702. /**
  14703. * wave shape
  14704. */
  14705. function getWave(idx, isInverse, oldWave) {
  14706. var radiusX = isFillContainer ? radius[0] : radius;
  14707. var radiusY = isFillContainer ? height / 2 : radius;
  14708. var itemModel = data.getItemModel(idx);
  14709. var itemStyleModel = itemModel.getModel('itemStyle');
  14710. var phase = itemModel.get('phase');
  14711. var amplitude = parsePercent(itemModel.get('amplitude'),
  14712. radiusY * 2);
  14713. var waveLength = parsePercent(itemModel.get('waveLength'),
  14714. radiusX * 2);
  14715. var value = data.get('value', idx);
  14716. var waterLevel = radiusY - value * radiusY * 2;
  14717. phase = oldWave ? oldWave.shape.phase
  14718. : (phase === 'auto' ? idx * Math.PI / 4 : phase);
  14719. var normalStyle = itemStyleModel.getItemStyle();
  14720. if (!normalStyle.fill) {
  14721. var seriesColor = seriesModel.get('color');
  14722. var id = idx % seriesColor.length;
  14723. normalStyle.fill = seriesColor[id];
  14724. }
  14725. var x = radiusX * 2;
  14726. var wave = new LiquidLayout({
  14727. shape: {
  14728. waveLength: waveLength,
  14729. radius: radiusX,
  14730. radiusY: radiusY,
  14731. cx: x,
  14732. cy: 0,
  14733. waterLevel: waterLevel,
  14734. amplitude: amplitude,
  14735. phase: phase,
  14736. inverse: isInverse
  14737. },
  14738. style: normalStyle,
  14739. position: [cx, cy]
  14740. });
  14741. wave.shape._waterLevel = waterLevel;
  14742. var hoverStyle = itemModel.getModel('emphasis.itemStyle')
  14743. .getItemStyle();
  14744. hoverStyle.lineWidth = 0;
  14745. echarts.graphic.setHoverStyle(wave, hoverStyle);
  14746. // clip out the part outside the circle
  14747. var clip = getPath(radius, true);
  14748. // set fill for clipPath, otherwise it will not trigger hover event
  14749. clip.setStyle({
  14750. fill: 'white'
  14751. });
  14752. wave.setClipPath(clip);
  14753. return wave;
  14754. }
  14755. function setWaveAnimation(idx, wave, oldWave) {
  14756. var itemModel = data.getItemModel(idx);
  14757. var maxSpeed = itemModel.get('period');
  14758. var direction = itemModel.get('direction');
  14759. var value = data.get('value', idx);
  14760. var phase = itemModel.get('phase');
  14761. phase = oldWave ? oldWave.shape.phase
  14762. : (phase === 'auto' ? idx * Math.PI / 4 : phase);
  14763. var defaultSpeed = function (maxSpeed) {
  14764. var cnt = data.count();
  14765. return cnt === 0 ? maxSpeed : maxSpeed *
  14766. (0.2 + (cnt - idx) / cnt * 0.8);
  14767. };
  14768. var speed = 0;
  14769. if (maxSpeed === 'auto') {
  14770. speed = defaultSpeed(5000);
  14771. }
  14772. else {
  14773. speed = typeof maxSpeed === 'function'
  14774. ? maxSpeed(value, idx) : maxSpeed;
  14775. }
  14776. // phase for moving left/right
  14777. var phaseOffset = 0;
  14778. if (direction === 'right' || direction == null) {
  14779. phaseOffset = Math.PI;
  14780. }
  14781. else if (direction === 'left') {
  14782. phaseOffset = -Math.PI;
  14783. }
  14784. else if (direction === 'none') {
  14785. phaseOffset = 0;
  14786. }
  14787. else {
  14788. console.error('Illegal direction value for liquid fill.');
  14789. }
  14790. // wave animation of moving left/right
  14791. if (direction !== 'none' && itemModel.get('waveAnimation')) {
  14792. wave
  14793. .animate('shape', true)
  14794. .when(0, {
  14795. phase: phase
  14796. })
  14797. .when(speed / 2, {
  14798. phase: phaseOffset + phase
  14799. })
  14800. .when(speed, {
  14801. phase: phaseOffset * 2 + phase
  14802. })
  14803. .during(function () {
  14804. if (wavePath) {
  14805. wavePath.dirty(true);
  14806. }
  14807. })
  14808. .start();
  14809. }
  14810. }
  14811. /**
  14812. * text on wave
  14813. */
  14814. function getText(waves) {
  14815. var labelModel = itemModel.getModel('label');
  14816. function formatLabel() {
  14817. var formatted = seriesModel.getFormattedLabel(0, 'normal');
  14818. var defaultVal = (data.get('value', 0) * 100);
  14819. var defaultLabel = data.getName(0) || seriesModel.name;
  14820. if (!isNaN(defaultVal)) {
  14821. defaultLabel = defaultVal.toFixed(0) + '%';
  14822. }
  14823. return formatted == null ? defaultLabel : formatted;
  14824. }
  14825. var textOption = {
  14826. z2: 10,
  14827. shape: {
  14828. x: left,
  14829. y: top,
  14830. width: (isFillContainer ? radius[0] : radius) * 2,
  14831. height: (isFillContainer ? radius[1] : radius) * 2
  14832. },
  14833. style: {
  14834. fill: 'transparent',
  14835. text: formatLabel(),
  14836. textAlign: labelModel.get('align'),
  14837. textVerticalAlign: labelModel.get('baseline')
  14838. },
  14839. silent: true
  14840. };
  14841. var outsideTextRect = new echarts.graphic.Rect(textOption);
  14842. var color = labelModel.get('color');
  14843. echarts.graphic.setText(outsideTextRect.style, labelModel, color);
  14844. var insideTextRect = new echarts.graphic.Rect(textOption);
  14845. var insColor = labelModel.get('insideColor');
  14846. echarts.graphic.setText(insideTextRect.style, labelModel, insColor);
  14847. insideTextRect.style.textFill = insColor;
  14848. var group = new echarts.graphic.Group();
  14849. group.add(outsideTextRect);
  14850. group.add(insideTextRect);
  14851. // clip out waves for insideText
  14852. var boundingCircle = getPath(radius, true);
  14853. wavePath = new echarts.graphic.CompoundPath({
  14854. shape: {
  14855. paths: waves
  14856. },
  14857. position: [cx, cy]
  14858. });
  14859. wavePath.setClipPath(boundingCircle);
  14860. insideTextRect.setClipPath(wavePath);
  14861. return group;
  14862. }
  14863. },
  14864. dispose: function () {
  14865. // dispose nothing here
  14866. }
  14867. });
  14868. /***/ }),
  14869. /***/ "echarts/lib/echarts":
  14870. /*!**************************!*\
  14871. !*** external "echarts" ***!
  14872. \**************************/
  14873. /*! no static exports found */
  14874. /***/ (function(module, exports) {
  14875. module.exports = __WEBPACK_EXTERNAL_MODULE_echarts_lib_echarts__;
  14876. /***/ })
  14877. /******/ });
  14878. });
  14879. //# sourceMappingURL=echarts-liquidfill.js.map